xref: /openbmc/qemu/configure (revision 03a3c0b3)
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() {
1454dba2789SPaolo Bonzini    do_compiler "$cc" $CPU_CFLAGS "$@"
1469c83ffd8SPeter Maydell}
1479c83ffd8SPeter Maydell
1489c83ffd8SPeter Maydelldo_cxx() {
1494dba2789SPaolo Bonzini    do_compiler "$cxx" $CPU_CFLAGS "$@"
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"
1628a9d3d56SRichard Henderson    CONFIGURE_CXXFLAGS=$(echo "$CONFIGURE_CFLAGS" | sed s/-std=gnu11/-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
2193b6b7550SPaolo Bonziniglob() {
2203b6b7550SPaolo Bonzini    eval test -z '"${1#'"$2"'}"'
2213b6b7550SPaolo Bonzini}
2223b6b7550SPaolo Bonzini
223e9a3591fSChristian Borntraegerld_has() {
224e9a3591fSChristian Borntraeger    $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
225e9a3591fSChristian Borntraeger}
226e9a3591fSChristian Borntraeger
2274ace32e2SAntonio Ospiteif printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]";
2284ace32e2SAntonio Ospitethen
2294ace32e2SAntonio Ospite  error_exit "main directory cannot contain spaces nor colons"
2304ace32e2SAntonio Ospitefi
2314ace32e2SAntonio Ospite
23214211825SAntonio Ospite# default parameters
2332ff6b91eSJuan Quintelacpu=""
234a31a8642SMichael S. Tsirkiniasl="iasl"
2351e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
23643ce4dfeSbellardstatic="no"
2373812c0c4SJoelle van Dynecross_compile="no"
2387d13299dSbellardcross_prefix=""
23987430d5bSPaolo Bonziniaudio_drv_list="default"
240b64ec4e4SFam Zhengblock_drv_rw_whitelist=""
241b64ec4e4SFam Zhengblock_drv_ro_whitelist=""
242e5f05f8cSKevin Wolfblock_drv_whitelist_tools="no"
243e49d021eSPeter Maydellhost_cc="cc"
244957f1f99SMichael Rothlibs_qga=""
2455bc62e01SGerd Hoffmanndebug_info="yes"
246cdad781dSDaniele Buonolto="false"
24763678e17SSteven Noonanstack_protector=""
2481e4f6065SDaniele Buonosafe_stack=""
249afc3a8f9SAlex Bennéeuse_containers="yes"
250f2385398SAlex Bennéegdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
251ac0df51dSaliguori
25292712822SDaniel P. Berrangeif test -e "$source_path/.git"
25392712822SDaniel P. Berrangethen
2547d7dbf9dSDan Streetman    git_submodules_action="update"
25592712822SDaniel P. Berrangeelse
2567d7dbf9dSDan Streetman    git_submodules_action="ignore"
25792712822SDaniel P. Berrangefi
2582d652f24SPaolo Bonzini
2592d652f24SPaolo Bonzinigit_submodules="ui/keycodemapdb"
260cc84d63aSDaniel P. Berrangegit="git"
261ac0df51dSaliguori
262afb63ebdSStefan Weil# Don't accept a target_list environment variable.
263afb63ebdSStefan Weilunset target_list
264447e133fSAlex Bennéeunset target_list_exclude
265377529c0SPaolo Bonzini
266377529c0SPaolo Bonzini# Default value for a variable defining feature "foo".
267377529c0SPaolo Bonzini#  * foo="no"  feature will only be used if --enable-foo arg is given
268377529c0SPaolo Bonzini#  * foo=""    feature will be searched for, and if found, will be used
269377529c0SPaolo Bonzini#              unless --disable-foo is given
270377529c0SPaolo Bonzini#  * foo="yes" this value will only be set by --enable-foo flag.
271377529c0SPaolo Bonzini#              feature will searched for,
272377529c0SPaolo Bonzini#              if not found, configure exits with error
273377529c0SPaolo Bonzini#
274377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args.
275377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it
276377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found.
277377529c0SPaolo Bonzini
278c87ea116SAlex Bennéedefault_feature=""
279c87ea116SAlex Bennée# parse CC options second
280c87ea116SAlex Bennéefor opt do
281c87ea116SAlex Bennée  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
282c87ea116SAlex Bennée  case "$opt" in
283c87ea116SAlex Bennée      --without-default-features)
284c87ea116SAlex Bennée          default_feature="no"
285c87ea116SAlex Bennée  ;;
286c87ea116SAlex Bennée  esac
287c87ea116SAlex Bennéedone
288c87ea116SAlex Bennée
2898c6d4ff4SPaolo Bonzinibrlapi="auto"
290f9cd86feSPaolo Bonzinicurl="auto"
2915285e593SYonggang Luoiconv="auto"
2925285e593SYonggang Luocurses="auto"
293e3667660SYonggang Luodocs="auto"
294fbb4121dSPaolo Bonzinifdt="auto"
295837b84b1SPaolo Bonzininetmap="auto"
29635be72baSPaolo Bonzinisdl="auto"
29735be72baSPaolo Bonzinisdl_image="auto"
298cece116cSMisono Tomohirovirtiofsd="auto"
29969202b40SPaolo Bonzinivirtfs="auto"
3005c53015aSPaolo Bonzinilibudev="auto"
3016ec0e15dSPaolo Bonzinimpath="auto"
3023a6a1256SThomas Huthvnc="auto"
303deb62371SPaolo Bonzinisparse="auto"
304e1723999SPaolo Bonzinivde="auto"
305a0b93237SPaolo Bonzinivnc_sasl="auto"
306a0b93237SPaolo Bonzinivnc_jpeg="auto"
307a0b93237SPaolo Bonzinivnc_png="auto"
3084113f4cfSLaurent Vivierxkbcommon="auto"
309ca50e523SPaolo Bonzinialsa="auto"
310ca50e523SPaolo Bonzinicoreaudio="auto"
311ca50e523SPaolo Bonzinidsound="auto"
312ca50e523SPaolo Bonzinijack="auto"
313ca50e523SPaolo Bonzinioss="auto"
314ca50e523SPaolo Bonzinipa="auto"
315bcf0a7daSThomas Huthxen=${default_feature:+disabled}
316c87ea116SAlex Bennéexen_ctrl_version="$default_feature"
3171badb709SPaolo Bonzinixen_pci_passthrough="auto"
318ff66f3e5SPaolo Bonzinilinux_aio="auto"
31953c22b68SPaolo Bonzinilinux_io_uring="auto"
320727c8bb8SPaolo Bonzinicap_ng="auto"
321f7f2d651SPaolo Bonziniattr="auto"
322c87ea116SAlex Bennéexfs="$default_feature"
3231badb709SPaolo Bonzinitcg="enabled"
324c87ea116SAlex Bennéemembarrier="$default_feature"
3250848f8acSThomas Huthvhost_kernel="$default_feature"
326c87ea116SAlex Bennéevhost_net="$default_feature"
327c87ea116SAlex Bennéevhost_crypto="$default_feature"
328c87ea116SAlex Bennéevhost_scsi="$default_feature"
329c87ea116SAlex Bennéevhost_vsock="$default_feature"
330d88618f7SStefan Hajnoczivhost_user="no"
331e5e856c1SStefan Hajnoczivhost_user_blk_server="auto"
332c87ea116SAlex Bennéevhost_user_fs="$default_feature"
3330848f8acSThomas Huthvhost_vdpa="$default_feature"
33446627f41SAndrew Melnychenkobpf="auto"
3353bd40ec7SPaolo Bonzinikvm="auto"
3363bd40ec7SPaolo Bonzinihax="auto"
3373bd40ec7SPaolo Bonzinihvf="auto"
3383bd40ec7SPaolo Bonziniwhpx="auto"
33974a414a1SReinoud Zandijknvmm="auto"
340c87ea116SAlex Bennéerdma="$default_feature"
341c87ea116SAlex Bennéepvrdma="$default_feature"
342377529c0SPaolo Bonzinigprof="no"
343377529c0SPaolo Bonzinidebug_tcg="no"
344377529c0SPaolo Bonzinidebug="no"
345247724cbSMarc-André Lureausanitizers="no"
3460aebab04SLingfeng Yangtsan="no"
347c87ea116SAlex Bennéefortify_source="$default_feature"
348377529c0SPaolo Bonzinistrip_opt="yes"
34923a77b2dSPaolo Bonzinitcg_interpreter="false"
350377529c0SPaolo Bonzinimingw32="no"
3511d728c39SBlue Swirlgcov="no"
352c7328271SMiroslav RezaninaEXESUF=""
35317969268SFam Zhengmodules="no"
354bd83c861SChristian Ehrhardtmodule_upgrades="no"
355377529c0SPaolo Bonziniprefix="/usr/local"
35610ff82d1SMarc-André Lureauqemu_suffix="qemu"
3574d34a86bSPaolo Bonzinislirp="auto"
358377529c0SPaolo Bonzinibsd="no"
359377529c0SPaolo Bonzinilinux="no"
360377529c0SPaolo Bonzinisolaris="no"
361377529c0SPaolo Bonziniprofiler="no"
362b4e312e9SPaolo Bonzinicocoa="auto"
363377529c0SPaolo Bonzinisoftmmu="yes"
364377529c0SPaolo Bonzinilinux_user="no"
365377529c0SPaolo Bonzinibsd_user="no"
366c8d5450bSPaolo Bonziniblobs="true"
367377529c0SPaolo Bonzinipkgversion=""
36840d6444eSAvi Kivitypie=""
3693556c233SPaolo Bonziniqom_cast_debug="yes"
370baf86d6bSPaolo Bonzinitrace_backends="log"
371377529c0SPaolo Bonzinitrace_file="trace"
3723f0a5d55SMarc-André Lureauspice="auto"
37358d3f3ffSGerd Hoffmannspice_protocol="auto"
374fabd1e93SPaolo Bonzinirbd="auto"
3755f364c57SPaolo Bonzinismartcard="auto"
3760a40bcb7SCésar Belleyu2f="auto"
37790540f32SPaolo Bonzinilibusb="auto"
37818f31e60SPaolo Bonziniusb_redir="auto"
379c87ea116SAlex Bennéeopengl="$default_feature"
3805dd89908SRichard Hendersoncpuid_h="no"
381c87ea116SAlex Bennéeavx2_opt="$default_feature"
3828b18cdbfSRichard Hendersoncapstone="auto"
3830c32a0aeSPaolo Bonzinilzo="auto"
384241611eaSPaolo Bonzinisnappy="auto"
38529ba6116SPaolo Bonzinibzip2="auto"
386ecea3696SPaolo Bonzinilzfse="auto"
387b1def33dSPaolo Bonzinizstd="auto"
388c87ea116SAlex Bennéeguest_agent="$default_feature"
389d9840e25STomoki Sekiyamaguest_agent_with_vss="no"
39050cbebb9SMichael Rothguest_agent_ntddscsi="no"
391b846ab7cSPaolo Bonziniguest_agent_msi="auto"
392c87ea116SAlex Bennéevss_win32_sdk="$default_feature"
393d9840e25STomoki Sekiyamawin_sdk="no"
394c87ea116SAlex Bennéewant_tools="$default_feature"
3959db405a3SPaolo Bonzinilibiscsi="auto"
39630045c05SPaolo Bonzinilibnfs="auto"
397519175a2SAlex Barcelocoroutine=""
398c87ea116SAlex Bennéecoroutine_pool="$default_feature"
3997d992e4dSPeter Lievendebug_stack_usage="no"
400f0d92b56SLongpeng(Mike)crypto_afalg="no"
4019e62ba48SDaniele Buonocfi="false"
4029e62ba48SDaniele Buonocfi_debug="false"
40390835c2bSPaolo Bonziniseccomp="auto"
40408821ca2SPaolo Bonziniglusterfs="auto"
4051b695471SPaolo Bonzinigtk="auto"
406a1c5e949SDaniel P. Berrangetls_priority="NORMAL"
40757612511SPaolo Bonzinignutls="auto"
40857612511SPaolo Bonzininettle="auto"
40957612511SPaolo Bonzinigcrypt="auto"
41005e391aeSPaolo Bonziniauth_pam="auto"
411c23d7b4eSPaolo Bonzinivte="auto"
412587d59d6SPaolo Bonzinivirglrenderer="auto"
413c87ea116SAlex Bennéetpm="$default_feature"
414c87ea116SAlex Bennéelibssh="$default_feature"
415c87ea116SAlex Bennéelive_block_migration=${default_feature:-yes}
416c87ea116SAlex Bennéenuma="$default_feature"
4172847b469SFam Zhengtcmalloc="no"
4187b01cb97SAlexandre Derumierjemalloc="no"
419c87ea116SAlex Bennéereplication=${default_feature:-yes}
420c87ea116SAlex Bennéebochs=${default_feature:-yes}
421c87ea116SAlex Bennéecloop=${default_feature:-yes}
422c87ea116SAlex Bennéedmg=${default_feature:-yes}
423c87ea116SAlex Bennéeqcow1=${default_feature:-yes}
424c87ea116SAlex Bennéevdi=${default_feature:-yes}
425c87ea116SAlex Bennéevvfat=${default_feature:-yes}
426c87ea116SAlex Bennéeqed=${default_feature:-yes}
427c87ea116SAlex Bennéeparallels=${default_feature:-yes}
428c5b36c25SPaolo Bonzinilibxml2="auto"
429ba59fb77SPaolo Bonzinidebug_mutex="no"
430e36e8c70SPaolo Bonzinilibpmem="auto"
4317bc3ca7fSPaolo Bonzinidefault_devices="true"
432ba4dd2aaSAlex Bennéeplugins="$default_feature"
433537b7248SPaolo Bonzinifuzzing="false"
434b767d257SMarek Marczykowski-Góreckirng_none="no"
435c87ea116SAlex Bennéesecret_keyring="$default_feature"
43683ef1682SPaolo Bonzinilibdaxctl="auto"
437a5665051SPaolo Bonzinimeson=""
43848328880SPaolo Bonzinininja=""
439a5665051SPaolo Bonziniskip_meson=no
4400e8e77d4SAlex Bennéegettext="auto"
441a484a719SMax Reitzfuse="auto"
442df4ea709SMax Reitzfuse_lseek="auto"
443106ad1f9SPaolo Bonzinimultiprocess="auto"
444b8e0c493SJoelle van Dyneslirp_smbd="$default_feature"
445377529c0SPaolo Bonzini
446aa087962SPaolo Bonzinimalloc_trim="auto"
44720cf7b8eSDenis Plotnikovgio="$default_feature"
448898be3e0SPeter Maydell
449c87ea116SAlex Bennée# parse CC options second
450ac0df51dSaliguorifor opt do
45189138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
452ac0df51dSaliguori  case "$opt" in
453ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
4543812c0c4SJoelle van Dyne                    cross_compile="yes"
455ac0df51dSaliguori  ;;
4563d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
457ac0df51dSaliguori  ;;
45883f73fceSTomoki Sekiyama  --cxx=*) CXX="$optarg"
45983f73fceSTomoki Sekiyama  ;;
4602ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
4612ff6b91eSJuan Quintela  ;;
462de385287SAlex Bennée  --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
463db5adeaaSPaolo Bonzini                    QEMU_LDFLAGS="$QEMU_LDFLAGS $optarg"
464e2a2ed06SJuan Quintela  ;;
46511cde1c8SBruno Dominguez  --extra-cxxflags=*) QEMU_CXXFLAGS="$QEMU_CXXFLAGS $optarg"
46611cde1c8SBruno Dominguez  ;;
467db5adeaaSPaolo Bonzini  --extra-ldflags=*) QEMU_LDFLAGS="$QEMU_LDFLAGS $optarg"
468f9943cd5SGerd Hoffmann                     EXTRA_LDFLAGS="$optarg"
469e2a2ed06SJuan Quintela  ;;
4705bc62e01SGerd Hoffmann  --enable-debug-info) debug_info="yes"
4715bc62e01SGerd Hoffmann  ;;
4725bc62e01SGerd Hoffmann  --disable-debug-info) debug_info="no"
4735bc62e01SGerd Hoffmann  ;;
474d75402b5SAlex Bennée  --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
475d75402b5SAlex Bennée  ;;
476d422b2bcSAlex Bennée  --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-flags-}; cc_arch=${cc_arch%%=*}
477d422b2bcSAlex Bennée                      eval "cross_cc_cflags_${cc_arch}=\$optarg"
4782038f8c8SPaolo Bonzini                      cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}"
479d422b2bcSAlex Bennée  ;;
480d75402b5SAlex Bennée  --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
4812038f8c8SPaolo Bonzini                cc_archs="$cc_archs $cc_arch"
482d75402b5SAlex Bennée                eval "cross_cc_${cc_arch}=\$optarg"
4832038f8c8SPaolo Bonzini                cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}"
484d75402b5SAlex Bennée  ;;
485ac0df51dSaliguori  esac
486ac0df51dSaliguoridone
487ac0df51dSaliguori# OS specific
488ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
48993148aa5SStefan Weil# we can eliminate its usage altogether.
490ac0df51dSaliguori
491e49d021eSPeter Maydell# Preferred compiler:
492e49d021eSPeter Maydell#  ${CC} (if set)
493e49d021eSPeter Maydell#  ${cross_prefix}gcc (if cross-prefix specified)
494e49d021eSPeter Maydell#  system compiler
495e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then
496e49d021eSPeter Maydell  cc="$host_cc"
497e49d021eSPeter Maydellelse
498b3198cc2SStuart Yoder  cc="${CC-${cross_prefix}gcc}"
499e49d021eSPeter Maydellfi
500e49d021eSPeter Maydell
50183f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then
50283f73fceSTomoki Sekiyama  cxx="c++"
50383f73fceSTomoki Sekiyamaelse
50483f73fceSTomoki Sekiyama  cxx="${CXX-${cross_prefix}g++}"
50583f73fceSTomoki Sekiyamafi
50683f73fceSTomoki Sekiyama
507b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
508cdbd727cSRichard Hendersonas="${AS-${cross_prefix}as}"
5095f6f0e27SRichard Hendersonccas="${CCAS-$cc}"
5103dd46c78SBlue Swirlcpp="${CPP-$cc -E}"
511b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
512b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
5139f81aeb5SAlistair Francisranlib="${RANLIB-${cross_prefix}ranlib}"
5144852ee95SStefan Weilnm="${NM-${cross_prefix}nm}"
515b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
516b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
51717884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
51817884d7bSSergei Trofimovichquery_pkg_config() {
51917884d7bSSergei Trofimovich    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
52017884d7bSSergei Trofimovich}
52117884d7bSSergei Trofimovichpkg_config=query_pkg_config
52247c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
523ac0df51dSaliguori
524be17dc90SMichael S. Tsirkin# default flags for all hosts
5252d31515bSPeter Maydell# We use -fwrapv to tell the compiler that we require a C dialect where
5262d31515bSPeter Maydell# left shift of signed integers is well defined and has the expected
5272d31515bSPeter Maydell# 2s-complement style results. (Both clang and gcc agree that it
5282d31515bSPeter Maydell# provides these semantics.)
529086d5f75SPaolo BonziniQEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
530086d5f75SPaolo BonziniQEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
531c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
532be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
5335770e8afSPaolo Bonzini
5345770e8afSPaolo Bonzini# Flags that are needed during configure but later taken care of by Meson
5358a9d3d56SRichard HendersonCONFIGURE_CFLAGS="-std=gnu11 -Wall"
5365770e8afSPaolo BonziniCONFIGURE_LDFLAGS=
537086d5f75SPaolo Bonzini
538be17dc90SMichael S. Tsirkin
539ac0df51dSaliguoricheck_define() {
540ac0df51dSaliguoricat > $TMPC <<EOF
541ac0df51dSaliguori#if !defined($1)
542fd786e1aSPeter Maydell#error $1 not defined
543ac0df51dSaliguori#endif
544ac0df51dSaliguoriint main(void) { return 0; }
545ac0df51dSaliguoriEOF
54652166aa0SJuan Quintela  compile_object
547ac0df51dSaliguori}
548ac0df51dSaliguori
549307119e7SGerd Hoffmanncheck_include() {
550307119e7SGerd Hoffmanncat > $TMPC <<EOF
551307119e7SGerd Hoffmann#include <$1>
552307119e7SGerd Hoffmannint main(void) { return 0; }
553307119e7SGerd HoffmannEOF
554307119e7SGerd Hoffmann  compile_object
555307119e7SGerd Hoffmann}
556307119e7SGerd Hoffmann
55793b25869SJohn Snowwrite_c_skeleton() {
55893b25869SJohn Snow    cat > $TMPC <<EOF
55993b25869SJohn Snowint main(void) { return 0; }
56093b25869SJohn SnowEOF
56193b25869SJohn Snow}
56293b25869SJohn Snow
563bbea4050SPeter Maydellif check_define __linux__ ; then
564bbea4050SPeter Maydell  targetos="Linux"
565bbea4050SPeter Maydellelif check_define _WIN32 ; then
566bbea4050SPeter Maydell  targetos='MINGW32'
567bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
568bbea4050SPeter Maydell  targetos='OpenBSD'
569bbea4050SPeter Maydellelif check_define __sun__ ; then
570bbea4050SPeter Maydell  targetos='SunOS'
571bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
572bbea4050SPeter Maydell  targetos='Haiku'
573951fedfcSPeter Maydellelif check_define __FreeBSD__ ; then
574951fedfcSPeter Maydell  targetos='FreeBSD'
575951fedfcSPeter Maydellelif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
576951fedfcSPeter Maydell  targetos='GNU/kFreeBSD'
577951fedfcSPeter Maydellelif check_define __DragonFly__ ; then
578951fedfcSPeter Maydell  targetos='DragonFly'
579951fedfcSPeter Maydellelif check_define __NetBSD__; then
580951fedfcSPeter Maydell  targetos='NetBSD'
581951fedfcSPeter Maydellelif check_define __APPLE__; then
582951fedfcSPeter Maydell  targetos='Darwin'
583bbea4050SPeter Maydellelse
584951fedfcSPeter Maydell  # This is a fatal error, but don't report it yet, because we
585951fedfcSPeter Maydell  # might be going to just print the --help text, or it might
586951fedfcSPeter Maydell  # be the result of a missing compiler.
587951fedfcSPeter Maydell  targetos='bogus'
588bbea4050SPeter Maydellfi
589bbea4050SPeter Maydell
590bbea4050SPeter Maydell# Some host OSes need non-standard checks for which CPU to use.
591bbea4050SPeter Maydell# Note that these checks are broken for cross-compilation: if you're
592bbea4050SPeter Maydell# cross-compiling to one of these OSes then you'll need to specify
593bbea4050SPeter Maydell# the correct CPU with the --cpu option.
594bbea4050SPeter Maydellcase $targetos in
595bbea4050SPeter MaydellSunOS)
59689138857SStefan Weil  # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
597bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
598bbea4050SPeter Maydell    cpu="x86_64"
599bbea4050SPeter Maydell  fi
600bbea4050SPeter Maydellesac
601bbea4050SPeter Maydell
6022ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
6032ff6b91eSJuan Quintela  # command line argument
6042ff6b91eSJuan Quintela  :
6052ff6b91eSJuan Quintelaelif check_define __i386__ ; then
606ac0df51dSaliguori  cpu="i386"
607ac0df51dSaliguorielif check_define __x86_64__ ; then
608c72b26ecSRichard Henderson  if check_define __ILP32__ ; then
609c72b26ecSRichard Henderson    cpu="x32"
610c72b26ecSRichard Henderson  else
611ac0df51dSaliguori    cpu="x86_64"
612c72b26ecSRichard Henderson  fi
6133aa9bd6cSblueswir1elif check_define __sparc__ ; then
6143aa9bd6cSblueswir1  if check_define __arch64__ ; then
6153aa9bd6cSblueswir1    cpu="sparc64"
6163aa9bd6cSblueswir1  else
6173aa9bd6cSblueswir1    cpu="sparc"
6183aa9bd6cSblueswir1  fi
619fdf7ed96Smalcelif check_define _ARCH_PPC ; then
620fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
621f8378accSRichard Henderson    if check_define _LITTLE_ENDIAN ; then
622f8378accSRichard Henderson      cpu="ppc64le"
623f8378accSRichard Henderson    else
624fdf7ed96Smalc      cpu="ppc64"
625f8378accSRichard Henderson    fi
626ac0df51dSaliguori  else
627fdf7ed96Smalc    cpu="ppc"
628fdf7ed96Smalc  fi
629afa05235SAurelien Jarnoelif check_define __mips__ ; then
630afa05235SAurelien Jarno  cpu="mips"
631d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
632d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
633d66ed0eaSAurelien Jarno    cpu="s390x"
634d66ed0eaSAurelien Jarno  else
635d66ed0eaSAurelien Jarno    cpu="s390"
636d66ed0eaSAurelien Jarno  fi
637c4f80543SAlistair Franciselif check_define __riscv ; then
638c4f80543SAlistair Francis  if check_define _LP64 ; then
639c4f80543SAlistair Francis    cpu="riscv64"
640c4f80543SAlistair Francis  else
641c4f80543SAlistair Francis    cpu="riscv32"
642c4f80543SAlistair Francis  fi
64321d89f84SPeter Maydellelif check_define __arm__ ; then
64421d89f84SPeter Maydell  cpu="arm"
6451f080313SClaudio Fontanaelif check_define __aarch64__ ; then
6461f080313SClaudio Fontana  cpu="aarch64"
647fdf7ed96Smalcelse
64889138857SStefan Weil  cpu=$(uname -m)
649ac0df51dSaliguorifi
650ac0df51dSaliguori
651359bc95dSPeter MaydellARCH=
652359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
653359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
6547d13299dSbellardcase "$cpu" in
655ee35e968SThomas Huth  ppc|ppc64|s390x|sparc64|x32|riscv32|riscv64)
656898be3e0SPeter Maydell  ;;
657f8378accSRichard Henderson  ppc64le)
658f8378accSRichard Henderson    ARCH="ppc64"
659f8378accSRichard Henderson  ;;
6607d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
66197a847bcSbellard    cpu="i386"
6627d13299dSbellard  ;;
663aaa5fa14Saurel32  x86_64|amd64)
664aaa5fa14Saurel32    cpu="x86_64"
665aaa5fa14Saurel32  ;;
66621d89f84SPeter Maydell  armv*b|armv*l|arm)
66721d89f84SPeter Maydell    cpu="arm"
6687d13299dSbellard  ;;
6691f080313SClaudio Fontana  aarch64)
6701f080313SClaudio Fontana    cpu="aarch64"
6711f080313SClaudio Fontana  ;;
672afa05235SAurelien Jarno  mips*)
673afa05235SAurelien Jarno    cpu="mips"
674afa05235SAurelien Jarno  ;;
6753142255cSblueswir1  sparc|sun4[cdmuv])
676ae228531Sbellard    cpu="sparc"
677ae228531Sbellard  ;;
6787d13299dSbellard  *)
679359bc95dSPeter Maydell    # This will result in either an error or falling back to TCI later
680359bc95dSPeter Maydell    ARCH=unknown
6817d13299dSbellard  ;;
6827d13299dSbellardesac
683359bc95dSPeter Maydellif test -z "$ARCH"; then
684359bc95dSPeter Maydell  ARCH="$cpu"
685359bc95dSPeter Maydellfi
686e2d52ad3SJuan Quintela
6877d13299dSbellard# OS specific
6880dbfc675SJuan Quintela
6897d13299dSbellardcase $targetos in
69067b915a5SbellardMINGW32*)
69167b915a5Sbellard  mingw32="yes"
692898be3e0SPeter Maydell  supported_os="yes"
6939b8e4298SAlex Bennée  plugins="no"
694fb648e9cSDaniel P. Berrangé  pie="no"
69567b915a5Sbellard;;
6965c40d2bdSthsGNU/kFreeBSD)
697a167ba50SAurelien Jarno  bsd="yes"
6985c40d2bdSths;;
6997d3505c5SbellardFreeBSD)
7007d3505c5Sbellard  bsd="yes"
701e2a74729SWarner Losh  bsd_user="yes"
7020db4a067SPaolo Bonzini  make="${MAKE-gmake}"
703f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
7047d3505c5Sbellard;;
705c5e97233Sblueswir1DragonFly)
706c5e97233Sblueswir1  bsd="yes"
7070db4a067SPaolo Bonzini  make="${MAKE-gmake}"
708c5e97233Sblueswir1;;
7097d3505c5SbellardNetBSD)
7107d3505c5Sbellard  bsd="yes"
7110db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7127d3505c5Sbellard;;
7137d3505c5SbellardOpenBSD)
7147d3505c5Sbellard  bsd="yes"
7150db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7167d3505c5Sbellard;;
71783fb7adfSbellardDarwin)
71883fb7adfSbellard  bsd="yes"
71983fb7adfSbellard  darwin="yes"
720a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
721a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
722a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
72383fb7adfSbellard;;
724ec530c81SbellardSunOS)
725ec530c81Sbellard  solaris="yes"
7260db4a067SPaolo Bonzini  make="${MAKE-gmake}"
727e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
728d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
729d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
730d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
731d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
732ec530c81Sbellard;;
733179cf400SAndreas FärberHaiku)
734179cf400SAndreas Färber  haiku="yes"
735b8ee198dSRichard Zak  pie="no"
736b8ee198dSRichard Zak  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE -fPIC $QEMU_CFLAGS"
737179cf400SAndreas Färber;;
738898be3e0SPeter MaydellLinux)
7395327cf48Sbellard  linux="yes"
740831b7825Sths  linux_user="yes"
741c87ea116SAlex Bennée  vhost_user=${default_feature:-yes}
742898be3e0SPeter Maydell;;
7437d13299dSbellardesac
7447d13299dSbellard
7450db4a067SPaolo Bonzini: ${make=${MAKE-make}}
746b6daf4d3SPaolo Bonzini
747faf44142SDaniel P. Berrangé# We prefer python 3.x. A bare 'python' is traditionally
748faf44142SDaniel P. Berrangé# python 2.x, but some distros have it as python 3.x, so
749ddf90699SEduardo Habkost# we check that too
750faf44142SDaniel P. Berrangépython=
7510a01d76fSMarc-André Lureauexplicit_python=no
752ddf90699SEduardo Habkostfor binary in "${PYTHON-python3}" python
753faf44142SDaniel P. Berrangédo
754faf44142SDaniel P. Berrangé    if has "$binary"
755faf44142SDaniel P. Berrangé    then
75695c5f2deSPaolo Bonzini        python=$(command -v "$binary")
757faf44142SDaniel P. Berrangé        break
758faf44142SDaniel P. Berrangé    fi
759faf44142SDaniel P. Berrangédone
760903458c8SMarkus Armbruster
761903458c8SMarkus Armbruster
76239d87c8cSAlex Bennée# Check for ancillary tools used in testing
76339d87c8cSAlex Bennéegenisoimage=
7643df437c7SAlex Bennéefor binary in genisoimage mkisofs
76539d87c8cSAlex Bennéedo
76639d87c8cSAlex Bennée    if has $binary
76739d87c8cSAlex Bennée    then
76839d87c8cSAlex Bennée        genisoimage=$(command -v "$binary")
76939d87c8cSAlex Bennée        break
77039d87c8cSAlex Bennée    fi
77139d87c8cSAlex Bennéedone
77239d87c8cSAlex Bennée
7733c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
7743c4a4d0dSPeter Maydellif has clang; then
7753c4a4d0dSPeter Maydell  objcc=clang
7763c4a4d0dSPeter Maydellelse
7773c4a4d0dSPeter Maydell  objcc="$cc"
7783c4a4d0dSPeter Maydellfi
7793c4a4d0dSPeter Maydell
7803457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
7813457a3f8SJuan Quintela  EXESUF=".exe"
78278e9d4adSStefan Weil  # MinGW needs -mthreads for TLS and macro _MT.
7835770e8afSPaolo Bonzini  CONFIGURE_CFLAGS="-mthreads $CONFIGURE_CFLAGS"
78493b25869SJohn Snow  write_c_skeleton;
785d17f305aSPaolo Bonzini  prefix="/qemu"
78677433a5fSMarc-André Lureau  qemu_suffix=""
787105fad6bSBishara AbuHattoum  libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
7883457a3f8SJuan Quintelafi
7893457a3f8SJuan Quintela
790487fefdbSAnthony Liguoriwerror=""
79185aa5189Sbellard
7927d13299dSbellardfor opt do
79389138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
7947d13299dSbellard  case "$opt" in
7952efc3265Sbellard  --help|-h) show_help=yes
7962efc3265Sbellard  ;;
79799123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
79899123e13SMike Frysinger  ;;
799b1a550a0Spbrook  --prefix=*) prefix="$optarg"
8007d13299dSbellard  ;;
801b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
80232ce6337Sbellard  ;;
803ac0df51dSaliguori  --cross-prefix=*)
8047d13299dSbellard  ;;
805ac0df51dSaliguori  --cc=*)
8067d13299dSbellard  ;;
807b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
80883469015Sbellard  ;;
80983f73fceSTomoki Sekiyama  --cxx=*)
81083f73fceSTomoki Sekiyama  ;;
811e007dbecSMichael S. Tsirkin  --iasl=*) iasl="$optarg"
812e007dbecSMichael S. Tsirkin  ;;
8133c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
8143c4a4d0dSPeter Maydell  ;;
815b1a550a0Spbrook  --make=*) make="$optarg"
8167d13299dSbellard  ;;
817b6daf4d3SPaolo Bonzini  --install=*)
8186a882643Spbrook  ;;
8190a01d76fSMarc-André Lureau  --python=*) python="$optarg" ; explicit_python=yes
820c886edfbSBlue Swirl  ;;
8212eb054c2SPeter Maydell  --sphinx-build=*) sphinx_build="$optarg"
8222eb054c2SPeter Maydell  ;;
823a5665051SPaolo Bonzini  --skip-meson) skip_meson=yes
824a5665051SPaolo Bonzini  ;;
825a5665051SPaolo Bonzini  --meson=*) meson="$optarg"
826a5665051SPaolo Bonzini  ;;
82748328880SPaolo Bonzini  --ninja=*) ninja="$optarg"
82848328880SPaolo Bonzini  ;;
829e2d8830eSBrad  --smbd=*) smbd="$optarg"
830e2d8830eSBrad  ;;
831e2a2ed06SJuan Quintela  --extra-cflags=*)
8327d13299dSbellard  ;;
83311cde1c8SBruno Dominguez  --extra-cxxflags=*)
83411cde1c8SBruno Dominguez  ;;
835e2a2ed06SJuan Quintela  --extra-ldflags=*)
8367d13299dSbellard  ;;
8375bc62e01SGerd Hoffmann  --enable-debug-info)
8385bc62e01SGerd Hoffmann  ;;
8395bc62e01SGerd Hoffmann  --disable-debug-info)
8405bc62e01SGerd Hoffmann  ;;
841d75402b5SAlex Bennée  --cross-cc-*)
842d75402b5SAlex Bennée  ;;
84317969268SFam Zheng  --enable-modules)
84417969268SFam Zheng      modules="yes"
84517969268SFam Zheng  ;;
8463aa88b31SStefan Hajnoczi  --disable-modules)
8473aa88b31SStefan Hajnoczi      modules="no"
8483aa88b31SStefan Hajnoczi  ;;
849bd83c861SChristian Ehrhardt  --disable-module-upgrades) module_upgrades="no"
850bd83c861SChristian Ehrhardt  ;;
851bd83c861SChristian Ehrhardt  --enable-module-upgrades) module_upgrades="yes"
852bd83c861SChristian Ehrhardt  ;;
8532ff6b91eSJuan Quintela  --cpu=*)
8547d13299dSbellard  ;;
855b1a550a0Spbrook  --target-list=*) target_list="$optarg"
856447e133fSAlex Bennée                   if test "$target_list_exclude"; then
857447e133fSAlex Bennée                       error_exit "Can't mix --target-list with --target-list-exclude"
858447e133fSAlex Bennée                   fi
859447e133fSAlex Bennée  ;;
860447e133fSAlex Bennée  --target-list-exclude=*) target_list_exclude="$optarg"
861447e133fSAlex Bennée                   if test "$target_list"; then
862447e133fSAlex Bennée                       error_exit "Can't mix --target-list-exclude with --target-list"
863447e133fSAlex Bennée                   fi
864de83cd02Sbellard  ;;
8655b808275SLluís Vilanova  --enable-trace-backends=*) trace_backends="$optarg"
8665b808275SLluís Vilanova  ;;
8675b808275SLluís Vilanova  # XXX: backwards compatibility
8685b808275SLluís Vilanova  --enable-trace-backend=*) trace_backends="$optarg"
86994a420b1SStefan Hajnoczi  ;;
87074242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
8719410b56cSPrerna Saxena  ;;
8727bc3ca7fSPaolo Bonzini  --with-default-devices) default_devices="true"
873f3494749SPaolo Bonzini  ;;
8747bc3ca7fSPaolo Bonzini  --without-default-devices) default_devices="false"
875f3494749SPaolo Bonzini  ;;
876d1d5e9eeSAlex Bennée  --with-devices-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --with-devices-FOO option"
877d1d5e9eeSAlex Bennée  ;;
878d1d5e9eeSAlex Bennée  --with-devices-*) device_arch=${opt#--with-devices-};
879d1d5e9eeSAlex Bennée                    device_arch=${device_arch%%=*}
880d1d5e9eeSAlex Bennée                    cf=$source_path/configs/devices/$device_arch-softmmu/$optarg.mak
881d1d5e9eeSAlex Bennée                    if test -f "$cf"; then
882d1d5e9eeSAlex Bennée                        device_archs="$device_archs $device_arch"
883d1d5e9eeSAlex Bennée                        eval "devices_${device_arch}=\$optarg"
884d1d5e9eeSAlex Bennée                    else
885d1d5e9eeSAlex Bennée                        error_exit "File $cf does not exist"
886d1d5e9eeSAlex Bennée                    fi
887d1d5e9eeSAlex Bennée  ;;
888c87ea116SAlex Bennée  --without-default-features) # processed above
889c87ea116SAlex Bennée  ;;
8907d13299dSbellard  --enable-gprof) gprof="yes"
8917d13299dSbellard  ;;
8921d728c39SBlue Swirl  --enable-gcov) gcov="yes"
8931d728c39SBlue Swirl  ;;
89479427693SLoïc Minier  --static)
89579427693SLoïc Minier    static="yes"
89617884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
89743ce4dfeSbellard  ;;
8980b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
8990b24e75fSPaolo Bonzini  ;;
9000b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
9010b24e75fSPaolo Bonzini  ;;
9023aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
9033aa5d2beSAlon Levy  ;;
9048bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
9058bf188aaSMichael Tokarev  ;;
9060f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
9070f94d6daSAlon Levy  ;;
908528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
9090b24e75fSPaolo Bonzini  ;;
91077433a5fSMarc-André Lureau  --with-suffix=*) qemu_suffix="$optarg"
911023d3d67SEduardo Habkost  ;;
912c6502638SBruce Rogers  --docdir=*) docdir="$optarg"
9130b24e75fSPaolo Bonzini  ;;
914fe0038beSPaolo Bonzini  --localedir=*) localedir="$optarg"
915fe0038beSPaolo Bonzini  ;;
916ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
91707381cc1SAnthony Liguori  ;;
918785c23aeSLuiz Capitulino  --localstatedir=*) local_statedir="$optarg"
919785c23aeSLuiz Capitulino  ;;
9203d5eecabSGerd Hoffmann  --firmwarepath=*) firmwarepath="$optarg"
9213d5eecabSGerd Hoffmann  ;;
922181ce1d0SOlaf Hering  --host=*|--build=*|\
923181ce1d0SOlaf Hering  --disable-dependency-tracking|\
924785c23aeSLuiz Capitulino  --sbindir=*|--sharedstatedir=*|\
925fe0038beSPaolo Bonzini  --oldincludedir=*|--datarootdir=*|--infodir=*|\
926023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
927023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
928023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
929023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
930023ddd74SMax Filippov    # lots of directory switches by default.
931023ddd74SMax Filippov  ;;
93235be72baSPaolo Bonzini  --disable-sdl) sdl="disabled"
93397a847bcSbellard  ;;
93435be72baSPaolo Bonzini  --enable-sdl) sdl="enabled"
935c4198157SJuan Quintela  ;;
93635be72baSPaolo Bonzini  --disable-sdl-image) sdl_image="disabled"
937a442fe2fSDaniel P. Berrangé  ;;
93835be72baSPaolo Bonzini  --enable-sdl-image) sdl_image="enabled"
939a442fe2fSDaniel P. Berrangé  ;;
9403556c233SPaolo Bonzini  --disable-qom-cast-debug) qom_cast_debug="no"
9413556c233SPaolo Bonzini  ;;
9423556c233SPaolo Bonzini  --enable-qom-cast-debug) qom_cast_debug="yes"
9433556c233SPaolo Bonzini  ;;
94469202b40SPaolo Bonzini  --disable-virtfs) virtfs="disabled"
945983eef5aSMeador Inge  ;;
94669202b40SPaolo Bonzini  --enable-virtfs) virtfs="enabled"
947983eef5aSMeador Inge  ;;
9485c53015aSPaolo Bonzini  --disable-libudev) libudev="disabled"
9495c53015aSPaolo Bonzini  ;;
9505c53015aSPaolo Bonzini  --enable-libudev) libudev="enabled"
9515c53015aSPaolo Bonzini  ;;
952cece116cSMisono Tomohiro  --disable-virtiofsd) virtiofsd="disabled"
953cece116cSMisono Tomohiro  ;;
954cece116cSMisono Tomohiro  --enable-virtiofsd) virtiofsd="enabled"
955cece116cSMisono Tomohiro  ;;
9566ec0e15dSPaolo Bonzini  --disable-mpath) mpath="disabled"
957fe8fc5aeSPaolo Bonzini  ;;
9586ec0e15dSPaolo Bonzini  --enable-mpath) mpath="enabled"
959fe8fc5aeSPaolo Bonzini  ;;
960a0b93237SPaolo Bonzini  --disable-vnc) vnc="disabled"
961821601eaSJes Sorensen  ;;
962a0b93237SPaolo Bonzini  --enable-vnc) vnc="enabled"
963821601eaSJes Sorensen  ;;
9640e8e77d4SAlex Bennée  --disable-gettext) gettext="disabled"
965e8f3bd71SMarc-André Lureau  ;;
9660e8e77d4SAlex Bennée  --enable-gettext) gettext="enabled"
967e8f3bd71SMarc-André Lureau  ;;
9680c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
9690c58ac1cSmalc  ;;
97089138857SStefan Weil  --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
971b64ec4e4SFam Zheng  ;;
97289138857SStefan Weil  --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
973eb852011SMarkus Armbruster  ;;
974e5f05f8cSKevin Wolf  --enable-block-drv-whitelist-in-tools) block_drv_whitelist_tools="yes"
975e5f05f8cSKevin Wolf  ;;
976e5f05f8cSKevin Wolf  --disable-block-drv-whitelist-in-tools) block_drv_whitelist_tools="no"
977e5f05f8cSKevin Wolf  ;;
978f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
979f8393946Saurel32  ;;
980f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
981f8393946Saurel32  ;;
982f3d08ee6SPaul Brook  --enable-debug)
983f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
984f3d08ee6SPaul Brook      debug_tcg="yes"
9851fcc6d42SPeter Xu      debug_mutex="yes"
986f3d08ee6SPaul Brook      debug="yes"
987f3d08ee6SPaul Brook      strip_opt="no"
988b553a042SJohn Snow      fortify_source="no"
989f3d08ee6SPaul Brook  ;;
990247724cbSMarc-André Lureau  --enable-sanitizers) sanitizers="yes"
991247724cbSMarc-André Lureau  ;;
992247724cbSMarc-André Lureau  --disable-sanitizers) sanitizers="no"
993247724cbSMarc-André Lureau  ;;
9940aebab04SLingfeng Yang  --enable-tsan) tsan="yes"
9950aebab04SLingfeng Yang  ;;
9960aebab04SLingfeng Yang  --disable-tsan) tsan="no"
9970aebab04SLingfeng Yang  ;;
998deb62371SPaolo Bonzini  --enable-sparse) sparse="enabled"
99903b4fe7dSaliguori  ;;
1000deb62371SPaolo Bonzini  --disable-sparse) sparse="disabled"
100103b4fe7dSaliguori  ;;
10021625af87Saliguori  --disable-strip) strip_opt="no"
10031625af87Saliguori  ;;
1004a0b93237SPaolo Bonzini  --disable-vnc-sasl) vnc_sasl="disabled"
10052f9606b3Saliguori  ;;
1006a0b93237SPaolo Bonzini  --enable-vnc-sasl) vnc_sasl="enabled"
1007ea784e3bSJuan Quintela  ;;
1008a0b93237SPaolo Bonzini  --disable-vnc-jpeg) vnc_jpeg="disabled"
10092f6f5c7aSCorentin Chary  ;;
1010a0b93237SPaolo Bonzini  --enable-vnc-jpeg) vnc_jpeg="enabled"
10112f6f5c7aSCorentin Chary  ;;
1012a0b93237SPaolo Bonzini  --disable-vnc-png) vnc_png="disabled"
1013efe556adSCorentin Chary  ;;
1014a0b93237SPaolo Bonzini  --enable-vnc-png) vnc_png="enabled"
1015efe556adSCorentin Chary  ;;
10164d34a86bSPaolo Bonzini  --disable-slirp) slirp="disabled"
1017c20709aaSbellard  ;;
1018fd6fc214SPaolo Bonzini  --enable-slirp) slirp="enabled"
1019fd6fc214SPaolo Bonzini  ;;
10204d34a86bSPaolo Bonzini  --enable-slirp=git) slirp="internal"
10217c57bdd8SMarc-André Lureau  ;;
1022*03a3c0b3SPaolo Bonzini  --enable-slirp=*) slirp="$optarg"
1023675b9b53SMarc-André Lureau  ;;
1024e1723999SPaolo Bonzini  --disable-vde) vde="disabled"
10258a16d273Sths  ;;
1026e1723999SPaolo Bonzini  --enable-vde) vde="enabled"
1027dfb278bdSJuan Quintela  ;;
1028837b84b1SPaolo Bonzini  --disable-netmap) netmap="disabled"
102958952137SVincenzo Maffione  ;;
1030837b84b1SPaolo Bonzini  --enable-netmap) netmap="enabled"
103158952137SVincenzo Maffione  ;;
10321badb709SPaolo Bonzini  --disable-xen) xen="disabled"
1033e37630caSaliguori  ;;
10341badb709SPaolo Bonzini  --enable-xen) xen="enabled"
1035fc321b4bSJuan Quintela  ;;
10361badb709SPaolo Bonzini  --disable-xen-pci-passthrough) xen_pci_passthrough="disabled"
1037eb6fda0fSAnthony PERARD  ;;
10381badb709SPaolo Bonzini  --enable-xen-pci-passthrough) xen_pci_passthrough="enabled"
1039eb6fda0fSAnthony PERARD  ;;
1040ca50e523SPaolo Bonzini  --disable-alsa) alsa="disabled"
1041ca50e523SPaolo Bonzini  ;;
1042ca50e523SPaolo Bonzini  --enable-alsa) alsa="enabled"
1043ca50e523SPaolo Bonzini  ;;
1044ca50e523SPaolo Bonzini  --disable-coreaudio) coreaudio="disabled"
1045ca50e523SPaolo Bonzini  ;;
1046ca50e523SPaolo Bonzini  --enable-coreaudio) coreaudio="enabled"
1047ca50e523SPaolo Bonzini  ;;
1048ca50e523SPaolo Bonzini  --disable-dsound) dsound="disabled"
1049ca50e523SPaolo Bonzini  ;;
1050ca50e523SPaolo Bonzini  --enable-dsound) dsound="enabled"
1051ca50e523SPaolo Bonzini  ;;
1052ca50e523SPaolo Bonzini  --disable-jack) jack="disabled"
1053ca50e523SPaolo Bonzini  ;;
1054ca50e523SPaolo Bonzini  --enable-jack) jack="enabled"
1055ca50e523SPaolo Bonzini  ;;
1056ca50e523SPaolo Bonzini  --disable-oss) oss="disabled"
1057ca50e523SPaolo Bonzini  ;;
1058ca50e523SPaolo Bonzini  --enable-oss) oss="enabled"
1059ca50e523SPaolo Bonzini  ;;
1060ca50e523SPaolo Bonzini  --disable-pa) pa="disabled"
1061ca50e523SPaolo Bonzini  ;;
1062ca50e523SPaolo Bonzini  --enable-pa) pa="enabled"
1063ca50e523SPaolo Bonzini  ;;
10648c6d4ff4SPaolo Bonzini  --disable-brlapi) brlapi="disabled"
10652e4d9fb1Saurel32  ;;
10668c6d4ff4SPaolo Bonzini  --enable-brlapi) brlapi="enabled"
10674ffcedb6SJuan Quintela  ;;
10681badb709SPaolo Bonzini  --disable-kvm) kvm="disabled"
10697ba1e619Saliguori  ;;
10701badb709SPaolo Bonzini  --enable-kvm) kvm="enabled"
1071b31a0277SJuan Quintela  ;;
10721badb709SPaolo Bonzini  --disable-hax) hax="disabled"
1073180fb750Szhanghailiang  ;;
10741badb709SPaolo Bonzini  --enable-hax) hax="enabled"
1075180fb750Szhanghailiang  ;;
10761badb709SPaolo Bonzini  --disable-hvf) hvf="disabled"
1077c97d6d2cSSergio Andres Gomez Del Real  ;;
10781badb709SPaolo Bonzini  --enable-hvf) hvf="enabled"
1079c97d6d2cSSergio Andres Gomez Del Real  ;;
108074a414a1SReinoud Zandijk  --disable-nvmm) nvmm="disabled"
108174a414a1SReinoud Zandijk  ;;
108274a414a1SReinoud Zandijk  --enable-nvmm) nvmm="enabled"
108374a414a1SReinoud Zandijk  ;;
10841badb709SPaolo Bonzini  --disable-whpx) whpx="disabled"
1085d661d9a4SJustin Terry (VM)  ;;
10861badb709SPaolo Bonzini  --enable-whpx) whpx="enabled"
1087d661d9a4SJustin Terry (VM)  ;;
1088c6fbea47SRichard Henderson  --disable-tcg-interpreter) tcg_interpreter="false"
10899195b2c2SStefan Weil  ;;
1090c6fbea47SRichard Henderson  --enable-tcg-interpreter) tcg_interpreter="true"
10919195b2c2SStefan Weil  ;;
1092727c8bb8SPaolo Bonzini  --disable-cap-ng)  cap_ng="disabled"
109347e98658SCorey Bryant  ;;
1094727c8bb8SPaolo Bonzini  --enable-cap-ng) cap_ng="enabled"
109547e98658SCorey Bryant  ;;
10961badb709SPaolo Bonzini  --disable-tcg) tcg="disabled"
1097d1a14257SAlex Bennée                 plugins="no"
1098b3f6ea7eSPaolo Bonzini  ;;
10991badb709SPaolo Bonzini  --enable-tcg) tcg="enabled"
1100b3f6ea7eSPaolo Bonzini  ;;
1101aa087962SPaolo Bonzini  --disable-malloc-trim) malloc_trim="disabled"
11025a22ab71SYang Zhong  ;;
1103aa087962SPaolo Bonzini  --enable-malloc-trim) malloc_trim="enabled"
11045a22ab71SYang Zhong  ;;
1105cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
1106cd4ec0b4SGerd Hoffmann  ;;
110758d3f3ffSGerd Hoffmann  --enable-spice)
110858d3f3ffSGerd Hoffmann      spice_protocol="yes"
110958d3f3ffSGerd Hoffmann      spice="yes"
111058d3f3ffSGerd Hoffmann  ;;
111158d3f3ffSGerd Hoffmann  --disable-spice-protocol)
111258d3f3ffSGerd Hoffmann      spice_protocol="no"
111358d3f3ffSGerd Hoffmann      spice="no"
111458d3f3ffSGerd Hoffmann  ;;
111558d3f3ffSGerd Hoffmann  --enable-spice-protocol) spice_protocol="yes"
1116cd4ec0b4SGerd Hoffmann  ;;
11179db405a3SPaolo Bonzini  --disable-libiscsi) libiscsi="disabled"
1118c589b249SRonnie Sahlberg  ;;
11199db405a3SPaolo Bonzini  --enable-libiscsi) libiscsi="enabled"
1120c589b249SRonnie Sahlberg  ;;
112130045c05SPaolo Bonzini  --disable-libnfs) libnfs="disabled"
11226542aa9cSPeter Lieven  ;;
112330045c05SPaolo Bonzini  --enable-libnfs) libnfs="enabled"
11246542aa9cSPeter Lieven  ;;
112505c2a3e7Sbellard  --enable-profiler) profiler="yes"
112605c2a3e7Sbellard  ;;
1127b4e312e9SPaolo Bonzini  --disable-cocoa) cocoa="disabled"
112814821030SPavel Borzenkov  ;;
1129a23a6789SPaolo Bonzini  --enable-cocoa) cocoa="enabled"
11305b0753e0Sbellard  ;;
1131cad25d69Spbrook  --disable-system) softmmu="no"
11320a8e90f4Spbrook  ;;
1133cad25d69Spbrook  --enable-system) softmmu="yes"
11340a8e90f4Spbrook  ;;
11350953a80fSZachary Amsden  --disable-user)
11360953a80fSZachary Amsden      linux_user="no" ;
11370953a80fSZachary Amsden      bsd_user="no" ;
11380953a80fSZachary Amsden  ;;
11390953a80fSZachary Amsden  --enable-user) ;;
1140831b7825Sths  --disable-linux-user) linux_user="no"
11410a8e90f4Spbrook  ;;
1142831b7825Sths  --enable-linux-user) linux_user="yes"
1143831b7825Sths  ;;
114484778508Sblueswir1  --disable-bsd-user) bsd_user="no"
114584778508Sblueswir1  ;;
114684778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
114784778508Sblueswir1  ;;
114840d6444eSAvi Kivity  --enable-pie) pie="yes"
114934005a00SKirill A. Shutemov  ;;
115040d6444eSAvi Kivity  --disable-pie) pie="no"
115134005a00SKirill A. Shutemov  ;;
115285aa5189Sbellard  --enable-werror) werror="yes"
115385aa5189Sbellard  ;;
115485aa5189Sbellard  --disable-werror) werror="no"
115585aa5189Sbellard  ;;
1156cdad781dSDaniele Buono  --enable-lto) lto="true"
1157cdad781dSDaniele Buono  ;;
1158cdad781dSDaniele Buono  --disable-lto) lto="false"
1159cdad781dSDaniele Buono  ;;
116063678e17SSteven Noonan  --enable-stack-protector) stack_protector="yes"
116163678e17SSteven Noonan  ;;
116263678e17SSteven Noonan  --disable-stack-protector) stack_protector="no"
116363678e17SSteven Noonan  ;;
11641e4f6065SDaniele Buono  --enable-safe-stack) safe_stack="yes"
11651e4f6065SDaniele Buono  ;;
11661e4f6065SDaniele Buono  --disable-safe-stack) safe_stack="no"
11671e4f6065SDaniele Buono  ;;
11689e62ba48SDaniele Buono  --enable-cfi)
11699e62ba48SDaniele Buono      cfi="true";
11709e62ba48SDaniele Buono      lto="true";
11719e62ba48SDaniele Buono  ;;
11729e62ba48SDaniele Buono  --disable-cfi) cfi="false"
11739e62ba48SDaniele Buono  ;;
11749e62ba48SDaniele Buono  --enable-cfi-debug) cfi_debug="true"
11759e62ba48SDaniele Buono  ;;
11769e62ba48SDaniele Buono  --disable-cfi-debug) cfi_debug="false"
11779e62ba48SDaniele Buono  ;;
11785285e593SYonggang Luo  --disable-curses) curses="disabled"
11794d3b6f6eSbalrog  ;;
11805285e593SYonggang Luo  --enable-curses) curses="enabled"
1181c584a6d0SJuan Quintela  ;;
11825285e593SYonggang Luo  --disable-iconv) iconv="disabled"
1183e08bb301SSamuel Thibault  ;;
11845285e593SYonggang Luo  --enable-iconv) iconv="enabled"
1185e08bb301SSamuel Thibault  ;;
1186f9cd86feSPaolo Bonzini  --disable-curl) curl="disabled"
1187769ce76dSAlexander Graf  ;;
1188f9cd86feSPaolo Bonzini  --enable-curl) curl="enabled"
1189788c8196SJuan Quintela  ;;
1190fbb4121dSPaolo Bonzini  --disable-fdt) fdt="disabled"
11912df87df7SJuan Quintela  ;;
1192fbb4121dSPaolo Bonzini  --enable-fdt) fdt="enabled"
1193fbb4121dSPaolo Bonzini  ;;
1194fbb4121dSPaolo Bonzini  --enable-fdt=git) fdt="internal"
1195fbb4121dSPaolo Bonzini  ;;
1196*03a3c0b3SPaolo Bonzini  --enable-fdt=*) fdt="$optarg"
11972df87df7SJuan Quintela  ;;
1198ff66f3e5SPaolo Bonzini  --disable-linux-aio) linux_aio="disabled"
11995c6c3a6cSChristoph Hellwig  ;;
1200ff66f3e5SPaolo Bonzini  --enable-linux-aio) linux_aio="enabled"
12015c6c3a6cSChristoph Hellwig  ;;
120253c22b68SPaolo Bonzini  --disable-linux-io-uring) linux_io_uring="disabled"
1203c10dd856SAarushi Mehta  ;;
120453c22b68SPaolo Bonzini  --enable-linux-io-uring) linux_io_uring="enabled"
1205c10dd856SAarushi Mehta  ;;
1206f7f2d651SPaolo Bonzini  --disable-attr) attr="disabled"
1207758e8e38SVenkateswararao Jujjuri (JV)  ;;
1208f7f2d651SPaolo Bonzini  --enable-attr) attr="enabled"
1209758e8e38SVenkateswararao Jujjuri (JV)  ;;
1210a40161cbSPaolo Bonzini  --disable-membarrier) membarrier="no"
1211a40161cbSPaolo Bonzini  ;;
1212a40161cbSPaolo Bonzini  --enable-membarrier) membarrier="yes"
1213a40161cbSPaolo Bonzini  ;;
121446627f41SAndrew Melnychenko  --disable-bpf) bpf="disabled"
121546627f41SAndrew Melnychenko  ;;
121646627f41SAndrew Melnychenko  --enable-bpf) bpf="enabled"
121746627f41SAndrew Melnychenko  ;;
1218c8d5450bSPaolo Bonzini  --disable-blobs) blobs="false"
121977755340Sths  ;;
12207e563bfbSThomas Huth  --with-pkgversion=*) pkgversion="$optarg"
12214a19f1ecSpbrook  ;;
1222519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
1223519175a2SAlex Barcelo  ;;
122470c60c08SStefan Hajnoczi  --disable-coroutine-pool) coroutine_pool="no"
122570c60c08SStefan Hajnoczi  ;;
122670c60c08SStefan Hajnoczi  --enable-coroutine-pool) coroutine_pool="yes"
122770c60c08SStefan Hajnoczi  ;;
12287d992e4dSPeter Lieven  --enable-debug-stack-usage) debug_stack_usage="yes"
12297d992e4dSPeter Lieven  ;;
1230f0d92b56SLongpeng(Mike)  --enable-crypto-afalg) crypto_afalg="yes"
1231f0d92b56SLongpeng(Mike)  ;;
1232f0d92b56SLongpeng(Mike)  --disable-crypto-afalg) crypto_afalg="no"
1233f0d92b56SLongpeng(Mike)  ;;
1234e3667660SYonggang Luo  --disable-docs) docs="disabled"
123570ec5dc0SAnthony Liguori  ;;
1236e3667660SYonggang Luo  --enable-docs) docs="enabled"
123783a3ab8bSJuan Quintela  ;;
1238d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
1239d5970055SMichael S. Tsirkin  ;;
1240d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
1241d5970055SMichael S. Tsirkin  ;;
1242042cea27SGonglei  --disable-vhost-crypto) vhost_crypto="no"
1243042cea27SGonglei  ;;
1244299e6f19SPaolo Bonzini  --enable-vhost-crypto) vhost_crypto="yes"
1245042cea27SGonglei  ;;
12465e9be92dSNicholas Bellinger  --disable-vhost-scsi) vhost_scsi="no"
12475e9be92dSNicholas Bellinger  ;;
12485e9be92dSNicholas Bellinger  --enable-vhost-scsi) vhost_scsi="yes"
12495e9be92dSNicholas Bellinger  ;;
1250fc0b9b0eSStefan Hajnoczi  --disable-vhost-vsock) vhost_vsock="no"
1251fc0b9b0eSStefan Hajnoczi  ;;
1252fc0b9b0eSStefan Hajnoczi  --enable-vhost-vsock) vhost_vsock="yes"
1253fc0b9b0eSStefan Hajnoczi  ;;
1254e5e856c1SStefan Hajnoczi  --disable-vhost-user-blk-server) vhost_user_blk_server="disabled"
1255bc15e44cSStefan Hajnoczi  ;;
1256e5e856c1SStefan Hajnoczi  --enable-vhost-user-blk-server) vhost_user_blk_server="enabled"
1257bc15e44cSStefan Hajnoczi  ;;
125898fc1adaSDr. David Alan Gilbert  --disable-vhost-user-fs) vhost_user_fs="no"
125998fc1adaSDr. David Alan Gilbert  ;;
126098fc1adaSDr. David Alan Gilbert  --enable-vhost-user-fs) vhost_user_fs="yes"
126198fc1adaSDr. David Alan Gilbert  ;;
1262da076ffeSGerd Hoffmann  --disable-opengl) opengl="no"
126320ff075bSMichael Walle  ;;
1264da076ffeSGerd Hoffmann  --enable-opengl) opengl="yes"
126520ff075bSMichael Walle  ;;
1266fabd1e93SPaolo Bonzini  --disable-rbd) rbd="disabled"
1267f27aaf4bSChristian Brunner  ;;
1268fabd1e93SPaolo Bonzini  --enable-rbd) rbd="enabled"
1269f27aaf4bSChristian Brunner  ;;
12708c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
12718c84cf11SSergei Trofimovich  ;;
12728c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
12738c84cf11SSergei Trofimovich  ;;
12745f364c57SPaolo Bonzini  --disable-smartcard) smartcard="disabled"
1275111a38b0SRobert Relyea  ;;
12765f364c57SPaolo Bonzini  --enable-smartcard) smartcard="enabled"
1277111a38b0SRobert Relyea  ;;
12780a40bcb7SCésar Belley  --disable-u2f) u2f="disabled"
12790a40bcb7SCésar Belley  ;;
12800a40bcb7SCésar Belley  --enable-u2f) u2f="enabled"
12810a40bcb7SCésar Belley  ;;
128290540f32SPaolo Bonzini  --disable-libusb) libusb="disabled"
12832b2325ffSGerd Hoffmann  ;;
128490540f32SPaolo Bonzini  --enable-libusb) libusb="enabled"
12852b2325ffSGerd Hoffmann  ;;
128618f31e60SPaolo Bonzini  --disable-usb-redir) usb_redir="disabled"
128769354a83SHans de Goede  ;;
128818f31e60SPaolo Bonzini  --enable-usb-redir) usb_redir="enabled"
128969354a83SHans de Goede  ;;
12901ffb3bbbSPaolo Bonzini  --disable-zlib-test)
12911ece9905SAlon Levy  ;;
12920c32a0aeSPaolo Bonzini  --disable-lzo) lzo="disabled"
1293b25c9dffSStefan Weil  ;;
12940c32a0aeSPaolo Bonzini  --enable-lzo) lzo="enabled"
1295607dacd0Sqiaonuohan  ;;
1296241611eaSPaolo Bonzini  --disable-snappy) snappy="disabled"
1297b25c9dffSStefan Weil  ;;
1298241611eaSPaolo Bonzini  --enable-snappy) snappy="enabled"
1299607dacd0Sqiaonuohan  ;;
130029ba6116SPaolo Bonzini  --disable-bzip2) bzip2="disabled"
13016b383c08SPeter Wu  ;;
130229ba6116SPaolo Bonzini  --enable-bzip2) bzip2="enabled"
13036b383c08SPeter Wu  ;;
1304ecea3696SPaolo Bonzini  --enable-lzfse) lzfse="enabled"
130583bc1f97SJulio Faracco  ;;
1306ecea3696SPaolo Bonzini  --disable-lzfse) lzfse="disabled"
130783bc1f97SJulio Faracco  ;;
1308b1def33dSPaolo Bonzini  --disable-zstd) zstd="disabled"
13093a678481SJuan Quintela  ;;
1310b1def33dSPaolo Bonzini  --enable-zstd) zstd="enabled"
13113a678481SJuan Quintela  ;;
1312d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
1313d138cee9SMichael Roth  ;;
1314d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
1315d138cee9SMichael Roth  ;;
1316b846ab7cSPaolo Bonzini  --enable-guest-agent-msi) guest_agent_msi="enabled"
13179dacf32dSYossi Hindin  ;;
1318b846ab7cSPaolo Bonzini  --disable-guest-agent-msi) guest_agent_msi="disabled"
13199dacf32dSYossi Hindin  ;;
1320d9840e25STomoki Sekiyama  --with-vss-sdk) vss_win32_sdk=""
1321d9840e25STomoki Sekiyama  ;;
1322d9840e25STomoki Sekiyama  --with-vss-sdk=*) vss_win32_sdk="$optarg"
1323d9840e25STomoki Sekiyama  ;;
1324d9840e25STomoki Sekiyama  --without-vss-sdk) vss_win32_sdk="no"
1325d9840e25STomoki Sekiyama  ;;
1326d9840e25STomoki Sekiyama  --with-win-sdk) win_sdk=""
1327d9840e25STomoki Sekiyama  ;;
1328d9840e25STomoki Sekiyama  --with-win-sdk=*) win_sdk="$optarg"
1329d9840e25STomoki Sekiyama  ;;
1330d9840e25STomoki Sekiyama  --without-win-sdk) win_sdk="no"
1331d9840e25STomoki Sekiyama  ;;
13324b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
13334b1c11fdSDaniel P. Berrange  ;;
13344b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
13354b1c11fdSDaniel P. Berrange  ;;
133690835c2bSPaolo Bonzini  --enable-seccomp) seccomp="enabled"
1337f794573eSEduardo Otubo  ;;
133890835c2bSPaolo Bonzini  --disable-seccomp) seccomp="disabled"
1339f794573eSEduardo Otubo  ;;
134008821ca2SPaolo Bonzini  --disable-glusterfs) glusterfs="disabled"
1341eb100396SBharata B Rao  ;;
134286583a07SLiam Merwick  --disable-avx2) avx2_opt="no"
134386583a07SLiam Merwick  ;;
134486583a07SLiam Merwick  --enable-avx2) avx2_opt="yes"
134586583a07SLiam Merwick  ;;
13466b8cd447SRobert Hoo  --disable-avx512f) avx512f_opt="no"
13476b8cd447SRobert Hoo  ;;
13486b8cd447SRobert Hoo  --enable-avx512f) avx512f_opt="yes"
13496b8cd447SRobert Hoo  ;;
13506b8cd447SRobert Hoo
135108821ca2SPaolo Bonzini  --enable-glusterfs) glusterfs="enabled"
1352eb100396SBharata B Rao  ;;
135352b53c04SFam Zheng  --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
135452b53c04SFam Zheng      echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1355583f6e7bSStefan Hajnoczi  ;;
1356cb6414dfSFam Zheng  --enable-vhdx|--disable-vhdx)
1357cb6414dfSFam Zheng      echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1358cb6414dfSFam Zheng  ;;
1359315d3184SFam Zheng  --enable-uuid|--disable-uuid)
1360315d3184SFam Zheng      echo "$0: $opt is obsolete, UUID support is always built" >&2
1361315d3184SFam Zheng  ;;
13621b695471SPaolo Bonzini  --disable-gtk) gtk="disabled"
1363a4ccabcfSAnthony Liguori  ;;
13641b695471SPaolo Bonzini  --enable-gtk) gtk="enabled"
1365a4ccabcfSAnthony Liguori  ;;
1366a1c5e949SDaniel P. Berrange  --tls-priority=*) tls_priority="$optarg"
1367a1c5e949SDaniel P. Berrange  ;;
136857612511SPaolo Bonzini  --disable-gnutls) gnutls="disabled"
1369ddbb0d09SDaniel P. Berrange  ;;
137057612511SPaolo Bonzini  --enable-gnutls) gnutls="enabled"
1371ddbb0d09SDaniel P. Berrange  ;;
137257612511SPaolo Bonzini  --disable-nettle) nettle="disabled"
137391bfcdb0SDaniel P. Berrange  ;;
137457612511SPaolo Bonzini  --enable-nettle) nettle="enabled"
137591bfcdb0SDaniel P. Berrange  ;;
137657612511SPaolo Bonzini  --disable-gcrypt) gcrypt="disabled"
137791bfcdb0SDaniel P. Berrange  ;;
137857612511SPaolo Bonzini  --enable-gcrypt) gcrypt="enabled"
137991bfcdb0SDaniel P. Berrange  ;;
138005e391aeSPaolo Bonzini  --disable-auth-pam) auth_pam="disabled"
13818953caf3SDaniel P. Berrange  ;;
138205e391aeSPaolo Bonzini  --enable-auth-pam) auth_pam="enabled"
13838953caf3SDaniel P. Berrange  ;;
13842da776dbSMichael R. Hines  --enable-rdma) rdma="yes"
13852da776dbSMichael R. Hines  ;;
13862da776dbSMichael R. Hines  --disable-rdma) rdma="no"
13872da776dbSMichael R. Hines  ;;
138821ab34c9SMarcel Apfelbaum  --enable-pvrdma) pvrdma="yes"
138921ab34c9SMarcel Apfelbaum  ;;
139021ab34c9SMarcel Apfelbaum  --disable-pvrdma) pvrdma="no"
139121ab34c9SMarcel Apfelbaum  ;;
1392c23d7b4eSPaolo Bonzini  --disable-vte) vte="disabled"
1393bbbf9bfbSStefan Weil  ;;
1394c23d7b4eSPaolo Bonzini  --enable-vte) vte="enabled"
1395bbbf9bfbSStefan Weil  ;;
1396587d59d6SPaolo Bonzini  --disable-virglrenderer) virglrenderer="disabled"
13979d9e1521SGerd Hoffmann  ;;
1398587d59d6SPaolo Bonzini  --enable-virglrenderer) virglrenderer="enabled"
13999d9e1521SGerd Hoffmann  ;;
1400e91c793cSCole Robinson  --disable-tpm) tpm="no"
1401e91c793cSCole Robinson  ;;
1402ab214c29SStefan Berger  --enable-tpm) tpm="yes"
1403ab214c29SStefan Berger  ;;
1404b10d49d7SPino Toscano  --disable-libssh) libssh="no"
14050a12ec87SRichard W.M. Jones  ;;
1406b10d49d7SPino Toscano  --enable-libssh) libssh="yes"
14070a12ec87SRichard W.M. Jones  ;;
1408ed1701c6SDr. David Alan Gilbert  --disable-live-block-migration) live_block_migration="no"
1409ed1701c6SDr. David Alan Gilbert  ;;
1410ed1701c6SDr. David Alan Gilbert  --enable-live-block-migration) live_block_migration="yes"
1411ed1701c6SDr. David Alan Gilbert  ;;
1412a99d57bbSWanlong Gao  --disable-numa) numa="no"
1413a99d57bbSWanlong Gao  ;;
1414a99d57bbSWanlong Gao  --enable-numa) numa="yes"
1415a99d57bbSWanlong Gao  ;;
1416c5b36c25SPaolo Bonzini  --disable-libxml2) libxml2="disabled"
1417ed279a06SKlim Kireev  ;;
1418c5b36c25SPaolo Bonzini  --enable-libxml2) libxml2="enabled"
1419ed279a06SKlim Kireev  ;;
14202847b469SFam Zheng  --disable-tcmalloc) tcmalloc="no"
14212847b469SFam Zheng  ;;
14222847b469SFam Zheng  --enable-tcmalloc) tcmalloc="yes"
14232847b469SFam Zheng  ;;
14247b01cb97SAlexandre Derumier  --disable-jemalloc) jemalloc="no"
14257b01cb97SAlexandre Derumier  ;;
14267b01cb97SAlexandre Derumier  --enable-jemalloc) jemalloc="yes"
14277b01cb97SAlexandre Derumier  ;;
1428a6b1d4c0SChanglong Xie  --disable-replication) replication="no"
1429a6b1d4c0SChanglong Xie  ;;
1430a6b1d4c0SChanglong Xie  --enable-replication) replication="yes"
1431a6b1d4c0SChanglong Xie  ;;
14322f740136SJeff Cody  --disable-bochs) bochs="no"
14332f740136SJeff Cody  ;;
14342f740136SJeff Cody  --enable-bochs) bochs="yes"
14352f740136SJeff Cody  ;;
14362f740136SJeff Cody  --disable-cloop) cloop="no"
14372f740136SJeff Cody  ;;
14382f740136SJeff Cody  --enable-cloop) cloop="yes"
14392f740136SJeff Cody  ;;
14402f740136SJeff Cody  --disable-dmg) dmg="no"
14412f740136SJeff Cody  ;;
14422f740136SJeff Cody  --enable-dmg) dmg="yes"
14432f740136SJeff Cody  ;;
14442f740136SJeff Cody  --disable-qcow1) qcow1="no"
14452f740136SJeff Cody  ;;
14462f740136SJeff Cody  --enable-qcow1) qcow1="yes"
14472f740136SJeff Cody  ;;
14482f740136SJeff Cody  --disable-vdi) vdi="no"
14492f740136SJeff Cody  ;;
14502f740136SJeff Cody  --enable-vdi) vdi="yes"
14512f740136SJeff Cody  ;;
14522f740136SJeff Cody  --disable-vvfat) vvfat="no"
14532f740136SJeff Cody  ;;
14542f740136SJeff Cody  --enable-vvfat) vvfat="yes"
14552f740136SJeff Cody  ;;
14562f740136SJeff Cody  --disable-qed) qed="no"
14572f740136SJeff Cody  ;;
14582f740136SJeff Cody  --enable-qed) qed="yes"
14592f740136SJeff Cody  ;;
14602f740136SJeff Cody  --disable-parallels) parallels="no"
14612f740136SJeff Cody  ;;
14622f740136SJeff Cody  --enable-parallels) parallels="yes"
14632f740136SJeff Cody  ;;
1464e6a74868SMarc-André Lureau  --disable-vhost-user) vhost_user="no"
1465e6a74868SMarc-André Lureau  ;;
1466299e6f19SPaolo Bonzini  --enable-vhost-user) vhost_user="yes"
1467299e6f19SPaolo Bonzini  ;;
1468108a6481SCindy Lu  --disable-vhost-vdpa) vhost_vdpa="no"
1469108a6481SCindy Lu  ;;
1470108a6481SCindy Lu  --enable-vhost-vdpa) vhost_vdpa="yes"
1471108a6481SCindy Lu  ;;
1472299e6f19SPaolo Bonzini  --disable-vhost-kernel) vhost_kernel="no"
1473299e6f19SPaolo Bonzini  ;;
1474299e6f19SPaolo Bonzini  --enable-vhost-kernel) vhost_kernel="yes"
1475e6a74868SMarc-André Lureau  ;;
14768b18cdbfSRichard Henderson  --disable-capstone) capstone="disabled"
14778ca80760SRichard Henderson  ;;
14788b18cdbfSRichard Henderson  --enable-capstone) capstone="enabled"
14798ca80760SRichard Henderson  ;;
14808b18cdbfSRichard Henderson  --enable-capstone=git) capstone="internal"
1481e219c499SRichard Henderson  ;;
1482*03a3c0b3SPaolo Bonzini  --enable-capstone=*) capstone="$optarg"
1483e219c499SRichard Henderson  ;;
1484cc84d63aSDaniel P. Berrange  --with-git=*) git="$optarg"
1485cc84d63aSDaniel P. Berrange  ;;
14867d7dbf9dSDan Streetman  --with-git-submodules=*)
14877d7dbf9dSDan Streetman      git_submodules_action="$optarg"
1488f62bbee5SDaniel P. Berrange  ;;
1489ba59fb77SPaolo Bonzini  --enable-debug-mutex) debug_mutex=yes
1490ba59fb77SPaolo Bonzini  ;;
1491ba59fb77SPaolo Bonzini  --disable-debug-mutex) debug_mutex=no
1492ba59fb77SPaolo Bonzini  ;;
14935cd5d8a7SMiroslav Rezanina  --enable-libpmem) libpmem="enabled"
149417824406SJunyan He  ;;
14955cd5d8a7SMiroslav Rezanina  --disable-libpmem) libpmem="disabled"
149617824406SJunyan He  ;;
14974113f4cfSLaurent Vivier  --enable-xkbcommon) xkbcommon="enabled"
149875411919SJames Le Cuirot  ;;
14994113f4cfSLaurent Vivier  --disable-xkbcommon) xkbcommon="disabled"
150075411919SJames Le Cuirot  ;;
15019b8e4298SAlex Bennée  --enable-plugins) if test "$mingw32" = "yes"; then
15029b8e4298SAlex Bennée                        error_exit "TCG plugins not currently supported on Windows platforms"
15039b8e4298SAlex Bennée                    else
15049b8e4298SAlex Bennée                        plugins="yes"
15059b8e4298SAlex Bennée                    fi
150640e8c6f4SAlex Bennée  ;;
150740e8c6f4SAlex Bennée  --disable-plugins) plugins="no"
150840e8c6f4SAlex Bennée  ;;
1509afc3a8f9SAlex Bennée  --enable-containers) use_containers="yes"
1510afc3a8f9SAlex Bennée  ;;
1511afc3a8f9SAlex Bennée  --disable-containers) use_containers="no"
1512afc3a8f9SAlex Bennée  ;;
1513537b7248SPaolo Bonzini  --enable-fuzzing) fuzzing=true
1514adc28027SAlexander Bulekov  ;;
1515537b7248SPaolo Bonzini  --disable-fuzzing) fuzzing=false
1516adc28027SAlexander Bulekov  ;;
1517f48e590aSAlex Bennée  --gdb=*) gdb_bin="$optarg"
1518f48e590aSAlex Bennée  ;;
1519b767d257SMarek Marczykowski-Górecki  --enable-rng-none) rng_none=yes
1520b767d257SMarek Marczykowski-Górecki  ;;
1521b767d257SMarek Marczykowski-Górecki  --disable-rng-none) rng_none=no
1522b767d257SMarek Marczykowski-Górecki  ;;
152354e7aac0SAlexey Krasikov  --enable-keyring) secret_keyring="yes"
152454e7aac0SAlexey Krasikov  ;;
152554e7aac0SAlexey Krasikov  --disable-keyring) secret_keyring="no"
152654e7aac0SAlexey Krasikov  ;;
152712033e16SMiroslav Rezanina  --enable-libdaxctl) libdaxctl="enabled"
152821b2eca6SJingqi Liu  ;;
152912033e16SMiroslav Rezanina  --disable-libdaxctl) libdaxctl="disabled"
153021b2eca6SJingqi Liu  ;;
1531a484a719SMax Reitz  --enable-fuse) fuse="enabled"
1532a484a719SMax Reitz  ;;
1533a484a719SMax Reitz  --disable-fuse) fuse="disabled"
1534a484a719SMax Reitz  ;;
1535df4ea709SMax Reitz  --enable-fuse-lseek) fuse_lseek="enabled"
1536df4ea709SMax Reitz  ;;
1537df4ea709SMax Reitz  --disable-fuse-lseek) fuse_lseek="disabled"
1538df4ea709SMax Reitz  ;;
1539106ad1f9SPaolo Bonzini  --enable-multiprocess) multiprocess="enabled"
15403090de69SJagannathan Raman  ;;
1541106ad1f9SPaolo Bonzini  --disable-multiprocess) multiprocess="disabled"
15423090de69SJagannathan Raman  ;;
154320cf7b8eSDenis Plotnikov  --enable-gio) gio=yes
154420cf7b8eSDenis Plotnikov  ;;
154520cf7b8eSDenis Plotnikov  --disable-gio) gio=no
154620cf7b8eSDenis Plotnikov  ;;
1547b8e0c493SJoelle van Dyne  --enable-slirp-smbd) slirp_smbd=yes
1548b8e0c493SJoelle van Dyne  ;;
1549b8e0c493SJoelle van Dyne  --disable-slirp-smbd) slirp_smbd=no
1550b8e0c493SJoelle van Dyne  ;;
15512d2ad6d0SFam Zheng  *)
15522d2ad6d0SFam Zheng      echo "ERROR: unknown option $opt"
15532d2ad6d0SFam Zheng      echo "Try '$0 --help' for more information"
15542d2ad6d0SFam Zheng      exit 1
15557f1559c6Sbalrog  ;;
15567d13299dSbellard  esac
15577d13299dSbellarddone
15587d13299dSbellard
1559d1a14257SAlex Bennée# test for any invalid configuration combinations
1560d1a14257SAlex Bennéeif test "$plugins" = "yes" -a "$tcg" = "disabled"; then
1561d1a14257SAlex Bennée    error_exit "Can't enable plugins on non-TCG builds"
1562d1a14257SAlex Bennéefi
1563d1a14257SAlex Bennée
15647d7dbf9dSDan Streetmancase $git_submodules_action in
15657d7dbf9dSDan Streetman    update|validate)
15667d7dbf9dSDan Streetman        if test ! -e "$source_path/.git"; then
15677d7dbf9dSDan Streetman            echo "ERROR: cannot $git_submodules_action git submodules without .git"
15687d7dbf9dSDan Streetman            exit 1
15697d7dbf9dSDan Streetman        fi
15707d7dbf9dSDan Streetman    ;;
15717d7dbf9dSDan Streetman    ignore)
1572b80fd281SPaolo Bonzini        if ! test -f "$source_path/ui/keycodemapdb/README"
1573b80fd281SPaolo Bonzini        then
1574b80fd281SPaolo Bonzini            echo
1575b80fd281SPaolo Bonzini            echo "ERROR: missing GIT submodules"
1576b80fd281SPaolo Bonzini            echo
1577b80fd281SPaolo Bonzini            if test -e "$source_path/.git"; then
1578b80fd281SPaolo Bonzini                echo "--with-git-submodules=ignore specified but submodules were not"
1579b80fd281SPaolo Bonzini                echo "checked out.  Please initialize and update submodules."
1580b80fd281SPaolo Bonzini            else
1581b80fd281SPaolo Bonzini                echo "This is not a GIT checkout but module content appears to"
1582b80fd281SPaolo Bonzini                echo "be missing. Do not use 'git archive' or GitHub download links"
1583b80fd281SPaolo Bonzini                echo "to acquire QEMU source archives. Non-GIT builds are only"
1584b80fd281SPaolo Bonzini                echo "supported with source archives linked from:"
1585b80fd281SPaolo Bonzini                echo
1586b80fd281SPaolo Bonzini                echo "  https://www.qemu.org/download/#source"
1587b80fd281SPaolo Bonzini                echo
1588b80fd281SPaolo Bonzini                echo "Developers working with GIT can use scripts/archive-source.sh"
1589b80fd281SPaolo Bonzini                echo "if they need to create valid source archives."
1590b80fd281SPaolo Bonzini            fi
1591b80fd281SPaolo Bonzini            echo
1592b80fd281SPaolo Bonzini            exit 1
1593b80fd281SPaolo Bonzini        fi
15947d7dbf9dSDan Streetman    ;;
15957d7dbf9dSDan Streetman    *)
15967d7dbf9dSDan Streetman        echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'"
15977d7dbf9dSDan Streetman        exit 1
15987d7dbf9dSDan Streetman    ;;
15997d7dbf9dSDan Streetmanesac
16007d7dbf9dSDan Streetman
160122a87800SMarc-André Lureaulibdir="${libdir:-$prefix/lib}"
160222a87800SMarc-André Lureaulibexecdir="${libexecdir:-$prefix/libexec}"
160322a87800SMarc-André Lureauincludedir="${includedir:-$prefix/include}"
160422a87800SMarc-André Lureau
160522a87800SMarc-André Lureauif test "$mingw32" = "yes" ; then
160615588a62SJoshua Watt    bindir="${bindir:-$prefix}"
160722a87800SMarc-André Lureauelse
160815588a62SJoshua Watt    bindir="${bindir:-$prefix/bin}"
160915588a62SJoshua Wattfi
161022a87800SMarc-André Lureaumandir="${mandir:-$prefix/share/man}"
161122a87800SMarc-André Lureaudatadir="${datadir:-$prefix/share}"
1612ca8c0909SMarc-André Lureaudocdir="${docdir:-$prefix/share/doc}"
161322a87800SMarc-André Lureausysconfdir="${sysconfdir:-$prefix/etc}"
161422a87800SMarc-André Lureaulocal_statedir="${local_statedir:-$prefix/var}"
161516bf7a33SPaolo Bonzinifirmwarepath="${firmwarepath:-$datadir/qemu-firmware}"
161616bf7a33SPaolo Bonzinilocaledir="${localedir:-$datadir/locale}"
161722a87800SMarc-André Lureau
161840293e58Sbellardcase "$cpu" in
1619e3608d66SRichard Henderson    ppc)
1620e3608d66SRichard Henderson           CPU_CFLAGS="-m32"
1621db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m32 $QEMU_LDFLAGS"
1622e3608d66SRichard Henderson           ;;
1623e3608d66SRichard Henderson    ppc64)
1624e3608d66SRichard Henderson           CPU_CFLAGS="-m64"
1625db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
1626e3608d66SRichard Henderson           ;;
16279b9c37c3SRichard Henderson    sparc)
1628f1079bb8SRichard Henderson           CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
1629db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m32 -mv8plus $QEMU_LDFLAGS"
16303142255cSblueswir1           ;;
1631ed968ff1SJuan Quintela    sparc64)
163279f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1633db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
16343142255cSblueswir1           ;;
163576d83bdeSths    s390)
1636061cdd81SRichard Henderson           CPU_CFLAGS="-m31"
1637db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m31 $QEMU_LDFLAGS"
163828d7cc49SRichard Henderson           ;;
163928d7cc49SRichard Henderson    s390x)
1640061cdd81SRichard Henderson           CPU_CFLAGS="-m64"
1641db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
164276d83bdeSths           ;;
164340293e58Sbellard    i386)
164479f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32"
1645db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m32 $QEMU_LDFLAGS"
164640293e58Sbellard           ;;
164740293e58Sbellard    x86_64)
16487ebee43eSRichard Henderson           # ??? Only extremely old AMD cpus do not have cmpxchg16b.
16497ebee43eSRichard Henderson           # If we truly care, we should simply detect this case at
16507ebee43eSRichard Henderson           # runtime and generate the fallback to serial emulation.
16517ebee43eSRichard Henderson           CPU_CFLAGS="-m64 -mcx16"
1652db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
1653379f6698SPaul Brook           ;;
1654c72b26ecSRichard Henderson    x32)
1655c72b26ecSRichard Henderson           CPU_CFLAGS="-mx32"
1656db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-mx32 $QEMU_LDFLAGS"
1657c72b26ecSRichard Henderson           ;;
165830163d89SPeter Maydell    # No special flags required for other host CPUs
16593142255cSblueswir1esac
16603142255cSblueswir1
16619557af9cSAlex Bennéeif eval test -z "\${cross_cc_$cpu}"; then
1662b1aa4de1SAlex Bennée    eval "cross_cc_${cpu}=\$cc"
16632038f8c8SPaolo Bonzini    cross_cc_vars="$cross_cc_vars cross_cc_${cpu}"
16649557af9cSAlex Bennéefi
166579f3b12fSPeter Crosthwaite
1666affc88ccSPeter Maydell# For user-mode emulation the host arch has to be one we explicitly
1667affc88ccSPeter Maydell# support, even if we're using TCI.
1668affc88ccSPeter Maydellif [ "$ARCH" = "unknown" ]; then
1669affc88ccSPeter Maydell  bsd_user="no"
1670affc88ccSPeter Maydell  linux_user="no"
1671affc88ccSPeter Maydellfi
1672affc88ccSPeter Maydell
167360e0df25SPeter Maydelldefault_target_list=""
167443692239SMarkus Armbrusterdeprecated_targets_list=ppc64abi32-linux-user
1675fdb75aefSPaolo Bonzinideprecated_features=""
16766e92f823SPeter Maydellmak_wilds=""
16776e92f823SPeter Maydell
167860e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then
1679812b31d3SAlex Bennée    mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak"
168060e0df25SPeter Maydellfi
168160e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then
1682812b31d3SAlex Bennée    mak_wilds="${mak_wilds} $source_path/configs/targets/*-linux-user.mak"
168360e0df25SPeter Maydellfi
168460e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then
1685812b31d3SAlex Bennée    mak_wilds="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak"
168660e0df25SPeter Maydellfi
168760e0df25SPeter Maydell
16883a5ae4a9SAlex Bennée# If the user doesn't explicitly specify a deprecated target we will
16893a5ae4a9SAlex Bennée# skip it.
16903a5ae4a9SAlex Bennéeif test -z "$target_list"; then
16913a5ae4a9SAlex Bennée    if test -z "$target_list_exclude"; then
16923a5ae4a9SAlex Bennée        target_list_exclude="$deprecated_targets_list"
16933a5ae4a9SAlex Bennée    else
16943a5ae4a9SAlex Bennée        target_list_exclude="$target_list_exclude,$deprecated_targets_list"
16953a5ae4a9SAlex Bennée    fi
16962d838d9bSAlex Bennéefi
16972d838d9bSAlex Bennée
1698447e133fSAlex Bennéefor config in $mak_wilds; do
1699447e133fSAlex Bennée    target="$(basename "$config" .mak)"
170098db9a06SAlex Bennée    if echo "$target_list_exclude" | grep -vq "$target"; then
1701447e133fSAlex Bennée        default_target_list="${default_target_list} $target"
1702447e133fSAlex Bennée    fi
1703447e133fSAlex Bennéedone
17046e92f823SPeter Maydell
1705c53eeaf7SStefan Hajnoczi# Enumerate public trace backends for --help output
170664a6047dSGreg Kurztrace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
1707c53eeaf7SStefan Hajnoczi
1708af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1709af5db58eSpbrookcat << EOF
1710af5db58eSpbrook
1711af5db58eSpbrookUsage: configure [options]
1712af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1713af5db58eSpbrook
171408fb77edSStefan WeilStandard options:
171508fb77edSStefan Weil  --help                   print this message
171608fb77edSStefan Weil  --prefix=PREFIX          install in PREFIX [$prefix]
171708fb77edSStefan Weil  --interp-prefix=PREFIX   where to find shared libraries, etc.
171808fb77edSStefan Weil                           use %M for cpu name [$interp_prefix]
17192deca810SAlex Bennée  --target-list=LIST       set target list (default: build all non-deprecated)
172008fb77edSStefan Weil$(echo Available targets: $default_target_list | \
172108fb77edSStefan Weil  fold -s -w 53 | sed -e 's/^/                           /')
17222deca810SAlex Bennée$(echo Deprecated targets: $deprecated_targets_list | \
17232deca810SAlex Bennée  fold -s -w 53 | sed -e 's/^/                           /')
1724447e133fSAlex Bennée  --target-list-exclude=LIST exclude a set of targets from the default target-list
172508fb77edSStefan Weil
172608fb77edSStefan WeilAdvanced options (experts only):
17273812c0c4SJoelle van Dyne  --cross-prefix=PREFIX    use PREFIX for compile tools, PREFIX can be blank [$cross_prefix]
172808fb77edSStefan Weil  --cc=CC                  use C compiler CC [$cc]
172908fb77edSStefan Weil  --iasl=IASL              use ACPI compiler IASL [$iasl]
173008fb77edSStefan Weil  --host-cc=CC             use C compiler CC [$host_cc] for code run at
173108fb77edSStefan Weil                           build time
173208fb77edSStefan Weil  --cxx=CXX                use C++ compiler CXX [$cxx]
173308fb77edSStefan Weil  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]
173408fb77edSStefan Weil  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS
173511cde1c8SBruno Dominguez  --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
173608fb77edSStefan Weil  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
1737d75402b5SAlex Bennée  --cross-cc-ARCH=CC       use compiler when building ARCH guest test cases
1738d422b2bcSAlex Bennée  --cross-cc-flags-ARCH=   use compiler flags when building ARCH guest tests
173908fb77edSStefan Weil  --make=MAKE              use specified make [$make]
174008fb77edSStefan Weil  --python=PYTHON          use specified python [$python]
17412eb054c2SPeter Maydell  --sphinx-build=SPHINX    use specified sphinx-build [$sphinx_build]
1742a5665051SPaolo Bonzini  --meson=MESON            use specified meson [$meson]
174348328880SPaolo Bonzini  --ninja=NINJA            use specified ninja [$ninja]
174408fb77edSStefan Weil  --smbd=SMBD              use specified smbd [$smbd]
1745db1b5f13SThomas Huth  --with-git=GIT           use specified git [$git]
17467d7dbf9dSDan Streetman  --with-git-submodules=update   update git submodules (default if .git dir exists)
17477d7dbf9dSDan Streetman  --with-git-submodules=validate fail if git submodules are not up to date
17487d7dbf9dSDan Streetman  --with-git-submodules=ignore   do not update or check git submodules (default if no .git dir)
174908fb77edSStefan Weil  --static                 enable static build [$static]
175008fb77edSStefan Weil  --mandir=PATH            install man pages in PATH
175110ff82d1SMarc-André Lureau  --datadir=PATH           install firmware in PATH/$qemu_suffix
1752fe0038beSPaolo Bonzini  --localedir=PATH         install translation in PATH/$qemu_suffix
175310ff82d1SMarc-André Lureau  --docdir=PATH            install documentation in PATH/$qemu_suffix
175408fb77edSStefan Weil  --bindir=PATH            install binaries in PATH
175508fb77edSStefan Weil  --libdir=PATH            install libraries in PATH
1756db1b5f13SThomas Huth  --libexecdir=PATH        install helper binaries in PATH
175710ff82d1SMarc-André Lureau  --sysconfdir=PATH        install config in PATH/$qemu_suffix
175808fb77edSStefan Weil  --localstatedir=PATH     install local state in PATH (set at runtime on win32)
17593d5eecabSGerd Hoffmann  --firmwarepath=PATH      search PATH for firmware files
176013336606SRobert Foley  --efi-aarch64=PATH       PATH of efi file to use for aarch64 VMs.
1761ca8c0909SMarc-André Lureau  --with-suffix=SUFFIX     suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix]
1762db1b5f13SThomas Huth  --with-pkgversion=VERS   use specified string as sub-version of the package
1763c035c8d6SPaolo Bonzini  --without-default-features default all --enable-* options to "disabled"
1764c035c8d6SPaolo Bonzini  --without-default-devices  do not include any device that is not needed to
1765c035c8d6SPaolo Bonzini                           start the emulator (only use if you are including
1766d1d5e9eeSAlex Bennée                           desired devices in configs/devices/)
1767d1d5e9eeSAlex Bennée  --with-devices-ARCH=NAME override default configs/devices
176808fb77edSStefan Weil  --enable-debug           enable common debug build options
1769247724cbSMarc-André Lureau  --enable-sanitizers      enable default sanitizers
17700aebab04SLingfeng Yang  --enable-tsan            enable thread sanitizer
177108fb77edSStefan Weil  --disable-strip          disable stripping binaries
177208fb77edSStefan Weil  --disable-werror         disable compilation abort on warning
177363678e17SSteven Noonan  --disable-stack-protector disable compiler-provided stack protection
177487430d5bSPaolo Bonzini  --audio-drv-list=LIST    set audio drivers list
177508fb77edSStefan Weil  --block-drv-whitelist=L  Same as --block-drv-rw-whitelist=L
177608fb77edSStefan Weil  --block-drv-rw-whitelist=L
177708fb77edSStefan Weil                           set block driver read-write whitelist
1778e5f05f8cSKevin Wolf                           (by default affects only QEMU, not tools like qemu-img)
177908fb77edSStefan Weil  --block-drv-ro-whitelist=L
178008fb77edSStefan Weil                           set block driver read-only whitelist
1781e5f05f8cSKevin Wolf                           (by default affects only QEMU, not tools like qemu-img)
1782e5f05f8cSKevin Wolf  --enable-block-drv-whitelist-in-tools
1783e5f05f8cSKevin Wolf                           use block whitelist also in tools instead of only QEMU
17845b808275SLluís Vilanova  --enable-trace-backends=B Set trace backend
1785c53eeaf7SStefan Hajnoczi                           Available backends: $trace_backend_list
178608fb77edSStefan Weil  --with-trace-file=NAME   Full PATH,NAME of file to store traces
178708fb77edSStefan Weil                           Default:trace-<pid>
1788c23f23b9SMichael Tokarev  --disable-slirp          disable SLIRP userspace network connectivity
1789e9a16e38SPhilippe Mathieu-Daudé  --enable-tcg-interpreter enable TCI (TCG with bytecode interpreter, experimental and slow)
17905a22ab71SYang Zhong  --enable-malloc-trim     enable libc malloc_trim() for memory optimization
1791c23f23b9SMichael Tokarev  --cpu=CPU                Build for host CPU [$cpu]
179208fb77edSStefan Weil  --with-coroutine=BACKEND coroutine backend. Supported options:
179333c53c54SDaniel P. Berrange                           ucontext, sigaltstack, windows
179408fb77edSStefan Weil  --enable-gcov            enable test coverage analysis with gcov
1795c23f23b9SMichael Tokarev  --disable-blobs          disable installing provided firmware blobs
1796c23f23b9SMichael Tokarev  --with-vss-sdk=SDK-path  enable Windows VSS support in QEMU Guest Agent
1797c23f23b9SMichael Tokarev  --with-win-sdk=SDK-path  path to Windows Platform SDK (to build VSS .tlb)
1798a1c5e949SDaniel P. Berrange  --tls-priority           default TLS protocol/cipher priority string
1799c12d66aaSLin Ma  --enable-gprof           QEMU profiling with gprof
1800c12d66aaSLin Ma  --enable-profiler        profiler support
1801c12d66aaSLin Ma  --enable-debug-stack-usage
1802c12d66aaSLin Ma                           track the maximum stack usage of stacks created by qemu_alloc_stack
180340e8c6f4SAlex Bennée  --enable-plugins
180440e8c6f4SAlex Bennée                           enable plugins via shared library loading
1805afc3a8f9SAlex Bennée  --disable-containers     don't use containers for cross-building
1806f48e590aSAlex Bennée  --gdb=GDB-path           gdb to use for gdbstub tests [$gdb_bin]
1807c23f23b9SMichael Tokarev
1808c23f23b9SMichael TokarevOptional features, enabled with --enable-FEATURE and
1809c87ea116SAlex Bennéedisabled with --disable-FEATURE, default is enabled if available
1810c87ea116SAlex Bennée(unless built with --without-default-features):
1811c23f23b9SMichael Tokarev
1812c23f23b9SMichael Tokarev  system          all system emulation targets
1813c23f23b9SMichael Tokarev  user            supported user emulation targets
1814c23f23b9SMichael Tokarev  linux-user      all linux usermode emulation targets
1815c23f23b9SMichael Tokarev  bsd-user        all BSD usermode emulation targets
1816c23f23b9SMichael Tokarev  docs            build documentation
1817c23f23b9SMichael Tokarev  guest-agent     build the QEMU Guest Agent
1818c23f23b9SMichael Tokarev  guest-agent-msi build guest agent Windows MSI installation package
1819c23f23b9SMichael Tokarev  pie             Position Independent Executables
182021e709aaSMarc-André Lureau  modules         modules support (non-Windows)
1821bd83c861SChristian Ehrhardt  module-upgrades try to load modules from alternate paths for upgrades
1822c23f23b9SMichael Tokarev  debug-tcg       TCG debugging (default is disabled)
1823c23f23b9SMichael Tokarev  debug-info      debugging information
1824cdad781dSDaniele Buono  lto             Enable Link-Time Optimization.
1825c23f23b9SMichael Tokarev  sparse          sparse checker
18261e4f6065SDaniele Buono  safe-stack      SafeStack Stack Smash Protection. Depends on
18271e4f6065SDaniele Buono                  clang/llvm >= 3.7 and requires coroutine backend ucontext.
18289e62ba48SDaniele Buono  cfi             Enable Control-Flow Integrity for indirect function calls.
18299e62ba48SDaniele Buono                  In case of a cfi violation, QEMU is terminated with SIGILL
18309e62ba48SDaniele Buono                  Depends on lto and is incompatible with modules
18319e62ba48SDaniele Buono                  Automatically enables Link-Time Optimization (lto)
18329e62ba48SDaniele Buono  cfi-debug       In case of a cfi violation, a message containing the line that
18339e62ba48SDaniele Buono                  triggered the error is written to stderr. After the error,
18349e62ba48SDaniele Buono                  QEMU is still terminated with SIGILL
1835ddbb0d09SDaniel P. Berrange  gnutls          GNUTLS cryptography support
183691bfcdb0SDaniel P. Berrange  nettle          nettle cryptography support
183791bfcdb0SDaniel P. Berrange  gcrypt          libgcrypt cryptography support
18388953caf3SDaniel P. Berrange  auth-pam        PAM access control
1839c23f23b9SMichael Tokarev  sdl             SDL UI
184004c6e16fSMarkus Armbruster  sdl-image       SDL Image support for icons
1841c23f23b9SMichael Tokarev  gtk             gtk UI
1842c23f23b9SMichael Tokarev  vte             vte support for the gtk UI
1843c23f23b9SMichael Tokarev  curses          curses UI
1844e08bb301SSamuel Thibault  iconv           font glyph conversion support
1845c23f23b9SMichael Tokarev  vnc             VNC UI support
1846c23f23b9SMichael Tokarev  vnc-sasl        SASL encryption for VNC server
1847c23f23b9SMichael Tokarev  vnc-jpeg        JPEG lossy compression for VNC server
1848c23f23b9SMichael Tokarev  vnc-png         PNG compression for VNC server
1849c23f23b9SMichael Tokarev  cocoa           Cocoa UI (Mac OS X only)
1850c23f23b9SMichael Tokarev  virtfs          VirtFS
1851cece116cSMisono Tomohiro  virtiofsd       build virtiofs daemon (virtiofsd)
18525c53015aSPaolo Bonzini  libudev         Use libudev to enumerate host devices
1853fe8fc5aeSPaolo Bonzini  mpath           Multipath persistent reservation passthrough
1854c23f23b9SMichael Tokarev  xen             xen backend driver support
185570c292afSAnthony PERARD  xen-pci-passthrough    PCI passthrough support for Xen
1856ca50e523SPaolo Bonzini  alsa            ALSA sound support
1857ca50e523SPaolo Bonzini  coreaudio       CoreAudio sound support
1858ca50e523SPaolo Bonzini  dsound          DirectSound sound support
1859ca50e523SPaolo Bonzini  jack            JACK sound support
1860ca50e523SPaolo Bonzini  oss             OSS sound support
1861ca50e523SPaolo Bonzini  pa              PulseAudio sound support
1862c23f23b9SMichael Tokarev  brlapi          BrlAPI (Braile)
1863c23f23b9SMichael Tokarev  curl            curl connectivity
1864a40161cbSPaolo Bonzini  membarrier      membarrier system call (for Linux 4.14+ or Windows)
1865c23f23b9SMichael Tokarev  fdt             fdt device tree
1866c23f23b9SMichael Tokarev  kvm             KVM acceleration support
1867b0cb0a66SVincent Palatin  hax             HAX acceleration support
1868c97d6d2cSSergio Andres Gomez Del Real  hvf             Hypervisor.framework acceleration support
186974a414a1SReinoud Zandijk  nvmm            NVMM acceleration support
1870d661d9a4SJustin Terry (VM)  whpx            Windows Hypervisor Platform acceleration support
187121ab34c9SMarcel Apfelbaum  rdma            Enable RDMA-based migration
187221ab34c9SMarcel Apfelbaum  pvrdma          Enable PVRDMA support
1873c23f23b9SMichael Tokarev  vde             support for vde network
1874c23f23b9SMichael Tokarev  netmap          support for netmap network
1875c23f23b9SMichael Tokarev  linux-aio       Linux AIO support
1876c10dd856SAarushi Mehta  linux-io-uring  Linux io_uring support
1877c23f23b9SMichael Tokarev  cap-ng          libcap-ng support
1878c23f23b9SMichael Tokarev  attr            attr and xattr support
1879299e6f19SPaolo Bonzini  vhost-net       vhost-net kernel acceleration support
1880299e6f19SPaolo Bonzini  vhost-vsock     virtio sockets device support
1881299e6f19SPaolo Bonzini  vhost-scsi      vhost-scsi kernel target support
1882299e6f19SPaolo Bonzini  vhost-crypto    vhost-user-crypto backend support
1883299e6f19SPaolo Bonzini  vhost-kernel    vhost kernel backend support
1884299e6f19SPaolo Bonzini  vhost-user      vhost-user backend support
1885bc15e44cSStefan Hajnoczi  vhost-user-blk-server    vhost-user-blk server support
1886108a6481SCindy Lu  vhost-vdpa      vhost-vdpa kernel backend support
188746627f41SAndrew Melnychenko  bpf             BPF kernel support
1888c23f23b9SMichael Tokarev  spice           spice
188958d3f3ffSGerd Hoffmann  spice-protocol  spice-protocol
1890c23f23b9SMichael Tokarev  rbd             rados block device (rbd)
1891c23f23b9SMichael Tokarev  libiscsi        iscsi support
1892c23f23b9SMichael Tokarev  libnfs          nfs support
18937b02f544SMarc-André Lureau  smartcard       smartcard support (libcacard)
18940a40bcb7SCésar Belley  u2f             U2F support (u2f-emu)
1895c23f23b9SMichael Tokarev  libusb          libusb (for usb passthrough)
1896ed1701c6SDr. David Alan Gilbert  live-block-migration   Block migration in the main migration stream
1897c23f23b9SMichael Tokarev  usb-redir       usb network redirection support
1898c23f23b9SMichael Tokarev  lzo             support of lzo compression library
1899c23f23b9SMichael Tokarev  snappy          support of snappy compression library
1900c23f23b9SMichael Tokarev  bzip2           support of bzip2 compression library
1901c23f23b9SMichael Tokarev                  (for reading bzip2-compressed dmg images)
190283bc1f97SJulio Faracco  lzfse           support of lzfse compression library
190383bc1f97SJulio Faracco                  (for reading lzfse-compressed dmg images)
19043a678481SJuan Quintela  zstd            support for zstd compression library
1905d298ac10SDenis Plotnikov                  (for migration compression and qcow2 cluster compression)
1906c23f23b9SMichael Tokarev  seccomp         seccomp support
1907c23f23b9SMichael Tokarev  coroutine-pool  coroutine freelist (better performance)
1908c23f23b9SMichael Tokarev  glusterfs       GlusterFS backend
1909c23f23b9SMichael Tokarev  tpm             TPM support
1910b10d49d7SPino Toscano  libssh          ssh block device support
1911c23f23b9SMichael Tokarev  numa            libnuma support
1912ed279a06SKlim Kireev  libxml2         for Parallels image format
1913c23f23b9SMichael Tokarev  tcmalloc        tcmalloc support
19147b01cb97SAlexandre Derumier  jemalloc        jemalloc support
191586583a07SLiam Merwick  avx2            AVX2 optimization support
19166b8cd447SRobert Hoo  avx512f         AVX512F optimization support
1917a6b1d4c0SChanglong Xie  replication     replication support
1918c12d66aaSLin Ma  opengl          opengl support
1919c12d66aaSLin Ma  virglrenderer   virgl rendering support
1920c12d66aaSLin Ma  xfsctl          xfsctl support
1921c12d66aaSLin Ma  qom-cast-debug  cast debugging support
19228de73fa8SCleber Rosa  tools           build qemu-io, qemu-nbd and qemu-img tools
19232f740136SJeff Cody  bochs           bochs image format support
19242f740136SJeff Cody  cloop           cloop image format support
19252f740136SJeff Cody  dmg             dmg image format support
19262f740136SJeff Cody  qcow1           qcow v1 image format support
19272f740136SJeff Cody  vdi             vdi image format support
19282f740136SJeff Cody  vvfat           vvfat image format support
19292f740136SJeff Cody  qed             qed image format support
19302f740136SJeff Cody  parallels       parallels image format support
1931f0d92b56SLongpeng(Mike)  crypto-afalg    Linux AF_ALG crypto backend driver
19328ca80760SRichard Henderson  capstone        capstone disassembler support
1933ba59fb77SPaolo Bonzini  debug-mutex     mutex debugging support
193417824406SJunyan He  libpmem         libpmem support
193575411919SJames Le Cuirot  xkbcommon       xkbcommon support
1936b767d257SMarek Marczykowski-Górecki  rng-none        dummy RNG, avoid using /dev/(u)random and getrandom()
193721b2eca6SJingqi Liu  libdaxctl       libdaxctl support
1938a484a719SMax Reitz  fuse            FUSE block device export
1939df4ea709SMax Reitz  fuse-lseek      SEEK_HOLE/SEEK_DATA support for FUSE exports
1940106ad1f9SPaolo Bonzini  multiprocess    Out of process device emulation support
194120cf7b8eSDenis Plotnikov  gio             libgio support
1942b8e0c493SJoelle van Dyne  slirp-smbd      use smbd (at path --smbd=*) in slirp networking
194308fb77edSStefan Weil
194408fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched
1945af5db58eSpbrookEOF
19462d2ad6d0SFam Zhengexit 0
1947af5db58eSpbrookfi
1948af5db58eSpbrook
19499c790242SThomas Huth# Remove old dependency files to make sure that they get properly regenerated
1950bb768f71SThomas Huthrm -f */config-devices.mak.d
19519c790242SThomas Huth
1952faf44142SDaniel P. Berrangéif test -z "$python"
1953faf44142SDaniel P. Berrangéthen
1954c53eeaf7SStefan Hajnoczi    error_exit "Python not found. Use --python=/path/to/python"
1955c53eeaf7SStefan Hajnoczifi
19568e2c76bdSRoman Bolshakovif ! has "$make"
19578e2c76bdSRoman Bolshakovthen
19588e2c76bdSRoman Bolshakov    error_exit "GNU make ($make) not found"
19598e2c76bdSRoman Bolshakovfi
1960c53eeaf7SStefan Hajnoczi
1961c53eeaf7SStefan Hajnoczi# Note that if the Python conditional here evaluates True we will exit
1962c53eeaf7SStefan Hajnoczi# with status 1 which is a shell 'false' value.
19631b11f28dSThomas Huthif ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then
19641b11f28dSThomas Huth  error_exit "Cannot use '$python', Python >= 3.6 is required." \
1965c53eeaf7SStefan Hajnoczi      "Use --python=/path/to/python to specify a supported Python."
1966c53eeaf7SStefan Hajnoczifi
1967c53eeaf7SStefan Hajnoczi
1968755ee70fSCleber Rosa# Preserve python version since some functionality is dependent on it
1969406ab2f3SCleber 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)
1970755ee70fSCleber Rosa
1971c53eeaf7SStefan Hajnoczi# Suppress writing compiled files
1972c53eeaf7SStefan Hajnoczipython="$python -B"
1973c53eeaf7SStefan Hajnoczi
19740a01d76fSMarc-André Lureauif test -z "$meson"; then
1975654d6b04SPaolo Bonzini    if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.59.2; then
19760a01d76fSMarc-André Lureau        meson=meson
19777d7dbf9dSDan Streetman    elif test $git_submodules_action != 'ignore' ; then
19780a01d76fSMarc-André Lureau        meson=git
19790a01d76fSMarc-André Lureau    elif test -e "${source_path}/meson/meson.py" ; then
19800a01d76fSMarc-André Lureau        meson=internal
19810a01d76fSMarc-André Lureau    else
19820a01d76fSMarc-André Lureau        if test "$explicit_python" = yes; then
19830a01d76fSMarc-André Lureau            error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found."
19840a01d76fSMarc-André Lureau        else
1985a5665051SPaolo Bonzini            error_exit "Meson not found.  Use --meson=/path/to/meson"
1986a5665051SPaolo Bonzini        fi
19870a01d76fSMarc-André Lureau    fi
19880a01d76fSMarc-André Lureauelse
19890a01d76fSMarc-André Lureau    # Meson uses its own Python interpreter to invoke other Python scripts,
19900a01d76fSMarc-André Lureau    # but the user wants to use the one they specified with --python.
19910a01d76fSMarc-André Lureau    #
19920a01d76fSMarc-André Lureau    # We do not want to override the distro Python interpreter (and sometimes
19930a01d76fSMarc-André Lureau    # cannot: for example in Homebrew /usr/bin/meson is a bash script), so
19940a01d76fSMarc-André Lureau    # just require --meson=git|internal together with --python.
19950a01d76fSMarc-André Lureau    if test "$explicit_python" = yes; then
19960a01d76fSMarc-André Lureau        case "$meson" in
19970a01d76fSMarc-André Lureau            git | internal) ;;
19980a01d76fSMarc-André Lureau            *) error_exit "--python requires using QEMU's embedded Meson distribution." ;;
19990a01d76fSMarc-André Lureau        esac
20000a01d76fSMarc-André Lureau    fi
20010a01d76fSMarc-André Lureaufi
2002a5665051SPaolo Bonzini
20030a01d76fSMarc-André Lureauif test "$meson" = git; then
20040a01d76fSMarc-André Lureau    git_submodules="${git_submodules} meson"
20050a01d76fSMarc-André Lureaufi
20060a01d76fSMarc-André Lureau
20070a01d76fSMarc-André Lureaucase "$meson" in
20080a01d76fSMarc-André Lureau    git | internal)
20090a01d76fSMarc-André Lureau        meson="$python ${source_path}/meson/meson.py"
20100a01d76fSMarc-André Lureau        ;;
201184ec0c24SPaolo Bonzini    *) meson=$(command -v "$meson") ;;
20120a01d76fSMarc-André Lureauesac
20130a01d76fSMarc-André Lureau
201409e93326SPaolo Bonzini# Probe for ninja
201548328880SPaolo Bonzini
201648328880SPaolo Bonziniif test -z "$ninja"; then
201748328880SPaolo Bonzini    for c in ninja ninja-build samu; do
201848328880SPaolo Bonzini        if has $c; then
201948328880SPaolo Bonzini            ninja=$(command -v "$c")
202048328880SPaolo Bonzini            break
202148328880SPaolo Bonzini        fi
202248328880SPaolo Bonzini    done
202309e93326SPaolo Bonzini    if test -z "$ninja"; then
202409e93326SPaolo Bonzini      error_exit "Cannot find Ninja"
202509e93326SPaolo Bonzini    fi
202648328880SPaolo Bonzinifi
2027a5665051SPaolo Bonzini
20289aae6e54SDaniel Henrique Barboza# Check that the C compiler works. Doing this here before testing
20299aae6e54SDaniel Henrique Barboza# the host CPU ensures that we had a valid CC to autodetect the
20309aae6e54SDaniel Henrique Barboza# $cpu var (and we should bail right here if that's not the case).
20319aae6e54SDaniel Henrique Barboza# It also allows the help message to be printed without a CC.
20329aae6e54SDaniel Henrique Barbozawrite_c_skeleton;
20339aae6e54SDaniel Henrique Barbozaif compile_object ; then
20349aae6e54SDaniel Henrique Barboza  : C compiler works ok
20359aae6e54SDaniel Henrique Barbozaelse
20369aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" either does not exist or does not work"
20379aae6e54SDaniel Henrique Barbozafi
20389aae6e54SDaniel Henrique Barbozaif ! compile_prog ; then
20399aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
20409aae6e54SDaniel Henrique Barbozafi
20419aae6e54SDaniel Henrique Barboza
20429c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror
20439c83ffd8SPeter Maydell# by default.  Only enable by default for git builds
20449c83ffd8SPeter Maydellif test -z "$werror" ; then
20457d7dbf9dSDan Streetman    if test "$git_submodules_action" != "ignore" && \
2046e633a5c6SEric Blake        { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
20479c83ffd8SPeter Maydell        werror="yes"
20489c83ffd8SPeter Maydell    else
20499c83ffd8SPeter Maydell        werror="no"
20509c83ffd8SPeter Maydell    fi
20519c83ffd8SPeter Maydellfi
20529c83ffd8SPeter Maydell
2053975ff037SPaolo Bonziniif test "$targetos" = "bogus"; then
2054fb59dabdSPeter Maydell    # Now that we know that we're not printing the help and that
2055fb59dabdSPeter Maydell    # the compiler works (so the results of the check_defines we used
2056fb59dabdSPeter Maydell    # to identify the OS are reliable), if we didn't recognize the
2057fb59dabdSPeter Maydell    # host OS we should stop now.
2058951fedfcSPeter Maydell    error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
2059fb59dabdSPeter Maydellfi
2060fb59dabdSPeter Maydell
2061efc6c070SThomas Huth# Check whether the compiler matches our minimum requirements:
2062efc6c070SThomas Huthcat > $TMPC << EOF
2063efc6c070SThomas Huth#if defined(__clang_major__) && defined(__clang_minor__)
2064efc6c070SThomas Huth# ifdef __apple_build_version__
20652a85a08cSDaniel P. Berrangé#  if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0)
20662a85a08cSDaniel P. Berrangé#   error You need at least XCode Clang v10.0 to compile QEMU
2067efc6c070SThomas Huth#  endif
2068efc6c070SThomas Huth# else
20692a85a08cSDaniel P. Berrangé#  if __clang_major__ < 6 || (__clang_major__ == 6 && __clang_minor__ < 0)
20702a85a08cSDaniel P. Berrangé#   error You need at least Clang v6.0 to compile QEMU
2071efc6c070SThomas Huth#  endif
2072efc6c070SThomas Huth# endif
2073efc6c070SThomas Huth#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
20743830df5fSnia# if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4)
20753830df5fSnia#  error You need at least GCC v7.4.0 to compile QEMU
2076efc6c070SThomas Huth# endif
2077efc6c070SThomas Huth#else
2078efc6c070SThomas Huth# error You either need GCC or Clang to compiler QEMU
2079efc6c070SThomas Huth#endif
2080efc6c070SThomas Huthint main (void) { return 0; }
2081efc6c070SThomas HuthEOF
2082efc6c070SThomas Huthif ! compile_prog "" "" ; then
20833830df5fSnia    error_exit "You need at least GCC v7.4 or Clang v6.0 (or XCode Clang v10.0)"
2084efc6c070SThomas Huthfi
2085efc6c070SThomas Huth
208600849b92SRichard Henderson# Accumulate -Wfoo and -Wno-bar separately.
208700849b92SRichard Henderson# We will list all of the enable flags first, and the disable flags second.
208800849b92SRichard Henderson# Note that we do not add -Werror, because that would enable it for all
208900849b92SRichard Henderson# configure tests. If a configure test failed due to -Werror this would
209000849b92SRichard Henderson# just silently disable some features, so it's too error prone.
209100849b92SRichard Henderson
209200849b92SRichard Hendersonwarn_flags=
209300849b92SRichard Hendersonadd_to warn_flags -Wold-style-declaration
209400849b92SRichard Hendersonadd_to warn_flags -Wold-style-definition
209500849b92SRichard Hendersonadd_to warn_flags -Wtype-limits
209600849b92SRichard Hendersonadd_to warn_flags -Wformat-security
209700849b92SRichard Hendersonadd_to warn_flags -Wformat-y2k
209800849b92SRichard Hendersonadd_to warn_flags -Winit-self
209900849b92SRichard Hendersonadd_to warn_flags -Wignored-qualifiers
210000849b92SRichard Hendersonadd_to warn_flags -Wempty-body
210100849b92SRichard Hendersonadd_to warn_flags -Wnested-externs
210200849b92SRichard Hendersonadd_to warn_flags -Wendif-labels
210300849b92SRichard Hendersonadd_to warn_flags -Wexpansion-to-defined
21040a2ebce9SThomas Huthadd_to warn_flags -Wimplicit-fallthrough=2
210500849b92SRichard Henderson
210600849b92SRichard Hendersonnowarn_flags=
210700849b92SRichard Hendersonadd_to nowarn_flags -Wno-initializer-overrides
210800849b92SRichard Hendersonadd_to nowarn_flags -Wno-missing-include-dirs
210900849b92SRichard Hendersonadd_to nowarn_flags -Wno-shift-negative-value
211000849b92SRichard Hendersonadd_to nowarn_flags -Wno-string-plus-int
211100849b92SRichard Hendersonadd_to nowarn_flags -Wno-typedef-redefinition
2112aabab967SRichard Hendersonadd_to nowarn_flags -Wno-tautological-type-limit-compare
2113bac8d222SRichard Hendersonadd_to nowarn_flags -Wno-psabi
211400849b92SRichard Henderson
211500849b92SRichard Hendersongcc_flags="$warn_flags $nowarn_flags"
211693b25869SJohn Snow
211793b25869SJohn Snowcc_has_warning_flag() {
211893b25869SJohn Snow    write_c_skeleton;
211993b25869SJohn Snow
2120a1d29d6cSPeter Maydell    # Use the positive sense of the flag when testing for -Wno-wombat
2121a1d29d6cSPeter Maydell    # support (gcc will happily accept the -Wno- form of unknown
2122a1d29d6cSPeter Maydell    # warning options).
212393b25869SJohn Snow    optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
212493b25869SJohn Snow    compile_prog "-Werror $optflag" ""
212593b25869SJohn Snow}
212693b25869SJohn Snow
212793b25869SJohn Snowfor flag in $gcc_flags; do
212893b25869SJohn Snow    if cc_has_warning_flag $flag ; then
21298d05095cSPaolo Bonzini        QEMU_CFLAGS="$QEMU_CFLAGS $flag"
21308d05095cSPaolo Bonzini    fi
21318d05095cSPaolo Bonzinidone
21328d05095cSPaolo Bonzini
213363678e17SSteven Noonanif test "$stack_protector" != "no"; then
2134fccd35a0SRodrigo Rebello  cat > $TMPC << EOF
2135fccd35a0SRodrigo Rebelloint main(int argc, char *argv[])
2136fccd35a0SRodrigo Rebello{
2137fccd35a0SRodrigo Rebello    char arr[64], *p = arr, *c = argv[0];
2138fccd35a0SRodrigo Rebello    while (*c) {
2139fccd35a0SRodrigo Rebello        *p++ = *c++;
2140fccd35a0SRodrigo Rebello    }
2141fccd35a0SRodrigo Rebello    return 0;
2142fccd35a0SRodrigo Rebello}
2143fccd35a0SRodrigo RebelloEOF
214463678e17SSteven Noonan  gcc_flags="-fstack-protector-strong -fstack-protector-all"
21453b463a3fSMiroslav Rezanina  sp_on=0
214663678e17SSteven Noonan  for flag in $gcc_flags; do
2147590e5dd9SPeter Maydell    # We need to check both a compile and a link, since some compiler
2148590e5dd9SPeter Maydell    # setups fail only on a .c->.o compile and some only at link time
2149086d5f75SPaolo Bonzini    if compile_object "-Werror $flag" &&
2150590e5dd9SPeter Maydell       compile_prog "-Werror $flag" ""; then
215163678e17SSteven Noonan      QEMU_CFLAGS="$QEMU_CFLAGS $flag"
2152db5adeaaSPaolo Bonzini      QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
21533b463a3fSMiroslav Rezanina      sp_on=1
215463678e17SSteven Noonan      break
215563678e17SSteven Noonan    fi
215663678e17SSteven Noonan  done
21573b463a3fSMiroslav Rezanina  if test "$stack_protector" = yes; then
21583b463a3fSMiroslav Rezanina    if test $sp_on = 0; then
21593b463a3fSMiroslav Rezanina      error_exit "Stack protector not supported"
21603b463a3fSMiroslav Rezanina    fi
21613b463a3fSMiroslav Rezanina  fi
216237746c5eSMarc-André Lureaufi
216337746c5eSMarc-André Lureau
216420bc94a2SPaolo Bonzini# Disable -Wmissing-braces on older compilers that warn even for
216520bc94a2SPaolo Bonzini# the "universal" C zero initializer {0}.
216620bc94a2SPaolo Bonzinicat > $TMPC << EOF
216720bc94a2SPaolo Bonzinistruct {
216820bc94a2SPaolo Bonzini  int a[2];
216920bc94a2SPaolo Bonzini} x = {0};
217020bc94a2SPaolo BonziniEOF
217120bc94a2SPaolo Bonziniif compile_object "-Werror" "" ; then
217220bc94a2SPaolo Bonzini  :
217320bc94a2SPaolo Bonzinielse
217420bc94a2SPaolo Bonzini  QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
217520bc94a2SPaolo Bonzinifi
217620bc94a2SPaolo Bonzini
217721e709aaSMarc-André Lureau# Our module code doesn't support Windows
217821e709aaSMarc-André Lureauif test "$modules" = "yes" && test "$mingw32" = "yes" ; then
217921e709aaSMarc-André Lureau  error_exit "Modules are not available for Windows"
218021e709aaSMarc-André Lureaufi
218121e709aaSMarc-André Lureau
2182bd83c861SChristian Ehrhardt# module_upgrades is only reasonable if modules are enabled
2183bd83c861SChristian Ehrhardtif test "$modules" = "no" && test "$module_upgrades" = "yes" ; then
2184bd83c861SChristian Ehrhardt  error_exit "Can't enable module-upgrades as Modules are not enabled"
2185bd83c861SChristian Ehrhardtfi
2186bd83c861SChristian Ehrhardt
21875f2453acSAlex Bennée# Static linking is not possible with plugins, modules or PIE
218840d6444eSAvi Kivityif test "$static" = "yes" ; then
2189aa0d1f44SPaolo Bonzini  if test "$modules" = "yes" ; then
2190aa0d1f44SPaolo Bonzini    error_exit "static and modules are mutually incompatible"
2191aa0d1f44SPaolo Bonzini  fi
21925f2453acSAlex Bennée  if test "$plugins" = "yes"; then
21935f2453acSAlex Bennée    error_exit "static and plugins are mutually incompatible"
2194ba4dd2aaSAlex Bennée  else
2195ba4dd2aaSAlex Bennée    plugins="no"
21965f2453acSAlex Bennée  fi
219740d6444eSAvi Kivityfi
219840d6444eSAvi Kivity
2199768b7855SEmilio G. Cota# Unconditional check for compiler __thread support
2200768b7855SEmilio G. Cota  cat > $TMPC << EOF
2201768b7855SEmilio G. Cotastatic __thread int tls_var;
2202768b7855SEmilio G. Cotaint main(void) { return tls_var; }
2203768b7855SEmilio G. CotaEOF
2204768b7855SEmilio G. Cota
2205768b7855SEmilio G. Cotaif ! compile_prog "-Werror" "" ; then
2206768b7855SEmilio G. Cota    error_exit "Your compiler does not support the __thread specifier for " \
2207768b7855SEmilio G. Cota	"Thread-Local Storage (TLS). Please upgrade to a version that does."
2208768b7855SEmilio G. Cotafi
2209768b7855SEmilio G. Cota
221040d6444eSAvi Kivitycat > $TMPC << EOF
221121d4a791SAvi Kivity
221221d4a791SAvi Kivity#ifdef __linux__
221321d4a791SAvi Kivity#  define THREAD __thread
221421d4a791SAvi Kivity#else
221521d4a791SAvi Kivity#  define THREAD
221621d4a791SAvi Kivity#endif
221721d4a791SAvi Kivitystatic THREAD int tls_var;
221821d4a791SAvi Kivityint main(void) { return tls_var; }
221940d6444eSAvi KivityEOF
2220b2634124SRichard Henderson
2221b2634124SRichard Henderson# Check we support --no-pie first; we will need this for building ROMs.
2222412aeacdSAlex Bennéeif compile_prog "-Werror -fno-pie" "-no-pie"; then
2223412aeacdSAlex Bennée  CFLAGS_NOPIE="-fno-pie"
2224412aeacdSAlex Bennéefi
2225412aeacdSAlex Bennée
222612781462SRichard Hendersonif test "$static" = "yes"; then
2227eca7a8e6SRichard Henderson  if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then
22285770e8afSPaolo Bonzini    CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
222912781462SRichard Henderson    QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS"
223012781462SRichard Henderson    pie="yes"
223112781462SRichard Henderson  elif test "$pie" = "yes"; then
223212781462SRichard Henderson    error_exit "-static-pie not available due to missing toolchain support"
223312781462SRichard Henderson  else
223412781462SRichard Henderson    QEMU_LDFLAGS="-static $QEMU_LDFLAGS"
223512781462SRichard Henderson    pie="no"
223612781462SRichard Henderson  fi
223712781462SRichard Hendersonelif test "$pie" = "no"; then
22385770e8afSPaolo Bonzini  CONFIGURE_CFLAGS="$CFLAGS_NOPIE $CONFIGURE_CFLAGS"
2239eca7a8e6SRichard Hendersonelif compile_prog "-Werror -fPIE -DPIE" "-pie"; then
22405770e8afSPaolo Bonzini  CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
22415770e8afSPaolo Bonzini  CONFIGURE_LDFLAGS="-pie $CONFIGURE_LDFLAGS"
224240d6444eSAvi Kivity  pie="yes"
22432c674109SRichard Hendersonelif test "$pie" = "yes"; then
224476ad07a4SPeter Maydell  error_exit "PIE not available due to missing toolchain support"
224540d6444eSAvi Kivityelse
224640d6444eSAvi Kivity  echo "Disabling PIE due to missing toolchain support"
224740d6444eSAvi Kivity  pie="no"
224840d6444eSAvi Kivityfi
224940d6444eSAvi Kivity
2250e6cbd751SRichard Henderson# Detect support for PT_GNU_RELRO + DT_BIND_NOW.
2251e6cbd751SRichard Henderson# The combination is known as "full relro", because .got.plt is read-only too.
2252e6cbd751SRichard Hendersonif compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
2253e6cbd751SRichard Henderson  QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS"
2254e6cbd751SRichard Hendersonfi
2255e6cbd751SRichard Henderson
225609dada40SPaolo Bonzini##########################################
225709dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains
225809dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit
225909dada40SPaolo Bonzini# specification is necessary
226009dada40SPaolo Bonzini
226109dada40SPaolo Bonziniif test "$cpu" = "i386"; then
226209dada40SPaolo Bonzini  cat > $TMPC << EOF
226309dada40SPaolo Bonzinistatic int sfaa(int *ptr)
226409dada40SPaolo Bonzini{
226509dada40SPaolo Bonzini  return __sync_fetch_and_and(ptr, 0);
226609dada40SPaolo Bonzini}
226709dada40SPaolo Bonzini
226809dada40SPaolo Bonziniint main(void)
226909dada40SPaolo Bonzini{
227009dada40SPaolo Bonzini  int val = 42;
22711405b629SStefan Weil  val = __sync_val_compare_and_swap(&val, 0, 1);
227209dada40SPaolo Bonzini  sfaa(&val);
227309dada40SPaolo Bonzini  return val;
227409dada40SPaolo Bonzini}
227509dada40SPaolo BonziniEOF
227609dada40SPaolo Bonzini  if ! compile_prog "" "" ; then
227709dada40SPaolo Bonzini    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
227809dada40SPaolo Bonzini  fi
227909dada40SPaolo Bonzinifi
228009dada40SPaolo Bonzini
228156267b62SPhilippe Mathieu-Daudéif test "$tcg" = "enabled"; then
228256267b62SPhilippe Mathieu-Daudé    git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
228356267b62SPhilippe Mathieu-Daudé    git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
228456267b62SPhilippe Mathieu-Daudéfi
228556267b62SPhilippe Mathieu-Daudé
2286afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then
2287fdb75aefSPaolo Bonzini    default_targets=yes
2288d880a3baSPaolo Bonzini    for target in $default_target_list; do
2289d880a3baSPaolo Bonzini        target_list="$target_list $target"
2290d880a3baSPaolo Bonzini    done
2291d880a3baSPaolo Bonzini    target_list="${target_list# }"
2292121afa9eSAnthony Liguorielse
2293fdb75aefSPaolo Bonzini    default_targets=no
229489138857SStefan Weil    target_list=$(echo "$target_list" | sed -e 's/,/ /g')
2295d880a3baSPaolo Bonzini    for target in $target_list; do
229625b48338SPeter Maydell        # Check that we recognised the target name; this allows a more
229725b48338SPeter Maydell        # friendly error message than if we let it fall through.
229825b48338SPeter Maydell        case " $default_target_list " in
229925b48338SPeter Maydell            *" $target "*)
230025b48338SPeter Maydell                ;;
230125b48338SPeter Maydell            *)
230225b48338SPeter Maydell                error_exit "Unknown target name '$target'"
230325b48338SPeter Maydell                ;;
230425b48338SPeter Maydell        esac
230525b48338SPeter Maydell    done
2306d880a3baSPaolo Bonzinifi
230725b48338SPeter Maydell
2308fdb75aefSPaolo Bonzinifor target in $target_list; do
2309fdb75aefSPaolo Bonzini    # if a deprecated target is enabled we note it here
2310fdb75aefSPaolo Bonzini    if echo "$deprecated_targets_list" | grep -q "$target"; then
2311fdb75aefSPaolo Bonzini        add_to deprecated_features $target
2312fdb75aefSPaolo Bonzini    fi
2313fdb75aefSPaolo Bonzinidone
2314fdb75aefSPaolo Bonzini
2315f55fe278SPaolo Bonzini# see if system emulation was really requested
2316f55fe278SPaolo Bonzinicase " $target_list " in
2317f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
2318f55fe278SPaolo Bonzini  ;;
2319f55fe278SPaolo Bonzini  *) softmmu=no
2320f55fe278SPaolo Bonzini  ;;
2321f55fe278SPaolo Bonziniesac
23225327cf48Sbellard
2323249247c9SJuan Quintelafeature_not_found() {
2324249247c9SJuan Quintela  feature=$1
232521684af0SStewart Smith  remedy=$2
2326249247c9SJuan Quintela
232776ad07a4SPeter Maydell  error_exit "User requested feature $feature" \
232821684af0SStewart Smith      "configure was not able to find it." \
232921684af0SStewart Smith      "$remedy"
2330249247c9SJuan Quintela}
2331249247c9SJuan Quintela
23327d13299dSbellard# ---
23337d13299dSbellard# big/little endian test
23347d13299dSbellardcat > $TMPC << EOF
2335659eb157SThomas Huth#include <stdio.h>
233661cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
233761cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
2338659eb157SThomas Huthint main(int argc, char *argv[])
2339659eb157SThomas Huth{
2340659eb157SThomas Huth    return printf("%s %s\n", (char *)big_endian, (char *)little_endian);
23417d13299dSbellard}
23427d13299dSbellardEOF
23437d13299dSbellard
2344659eb157SThomas Huthif compile_prog ; then
2345659eb157SThomas Huth    if strings -a $TMPE | grep -q BiGeNdIaN ; then
234661cc919fSMike Frysinger        bigendian="yes"
2347659eb157SThomas Huth    elif strings -a $TMPE | grep -q LiTtLeEnDiAn ; then
234861cc919fSMike Frysinger        bigendian="no"
23497d13299dSbellard    else
23507d13299dSbellard        echo big/little test failed
2351659eb157SThomas Huth        exit 1
23527d13299dSbellard    fi
23537d13299dSbellardelse
235461cc919fSMike Frysinger    echo big/little test failed
2355659eb157SThomas Huth    exit 1
23567d13299dSbellardfi
23577d13299dSbellard
2358b0a47e79SJuan Quintela##########################################
2359e10ee3f5SPhilippe Mathieu-Daudé# system tools
2360e10ee3f5SPhilippe Mathieu-Daudéif test -z "$want_tools"; then
2361e10ee3f5SPhilippe Mathieu-Daudé    if test "$softmmu" = "no"; then
2362e10ee3f5SPhilippe Mathieu-Daudé        want_tools=no
2363e10ee3f5SPhilippe Mathieu-Daudé    else
2364e10ee3f5SPhilippe Mathieu-Daudé        want_tools=yes
2365e10ee3f5SPhilippe Mathieu-Daudé    fi
2366e10ee3f5SPhilippe Mathieu-Daudéfi
2367e10ee3f5SPhilippe Mathieu-Daudé
2368e10ee3f5SPhilippe Mathieu-Daudé##########################################
2369015a33bdSGonglei# L2TPV3 probe
2370015a33bdSGonglei
2371015a33bdSGongleicat > $TMPC <<EOF
2372015a33bdSGonglei#include <sys/socket.h>
2373bff6cb72SMichael Tokarev#include <linux/ip.h>
2374015a33bdSGongleiint main(void) { return sizeof(struct mmsghdr); }
2375015a33bdSGongleiEOF
2376015a33bdSGongleiif compile_prog "" "" ; then
2377015a33bdSGonglei  l2tpv3=yes
2378015a33bdSGongleielse
2379015a33bdSGonglei  l2tpv3=no
2380015a33bdSGongleifi
2381015a33bdSGonglei
2382299e6f19SPaolo Bonzini#########################################
2383299e6f19SPaolo Bonzini# vhost interdependencies and host support
2384299e6f19SPaolo Bonzini
2385299e6f19SPaolo Bonzini# vhost backends
2386d88618f7SStefan Hajnocziif test "$vhost_user" = "yes" && test "$linux" != "yes"; then
2387d88618f7SStefan Hajnoczi  error_exit "vhost-user is only available on Linux"
2388299e6f19SPaolo Bonzinifi
2389108a6481SCindy Lutest "$vhost_vdpa" = "" && vhost_vdpa=$linux
2390108a6481SCindy Luif test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then
2391108a6481SCindy Lu  error_exit "vhost-vdpa is only available on Linux"
2392108a6481SCindy Lufi
2393299e6f19SPaolo Bonzinitest "$vhost_kernel" = "" && vhost_kernel=$linux
2394299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then
2395299e6f19SPaolo Bonzini  error_exit "vhost-kernel is only available on Linux"
2396299e6f19SPaolo Bonzinifi
2397299e6f19SPaolo Bonzini
2398299e6f19SPaolo Bonzini# vhost-kernel devices
2399299e6f19SPaolo Bonzinitest "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel
2400299e6f19SPaolo Bonziniif test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then
2401299e6f19SPaolo Bonzini  error_exit "--enable-vhost-scsi requires --enable-vhost-kernel"
2402299e6f19SPaolo Bonzinifi
2403299e6f19SPaolo Bonzinitest "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel
2404299e6f19SPaolo Bonziniif test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then
2405299e6f19SPaolo Bonzini  error_exit "--enable-vhost-vsock requires --enable-vhost-kernel"
2406299e6f19SPaolo Bonzinifi
2407299e6f19SPaolo Bonzini
2408299e6f19SPaolo Bonzini# vhost-user backends
2409299e6f19SPaolo Bonzinitest "$vhost_net_user" = "" && vhost_net_user=$vhost_user
2410299e6f19SPaolo Bonziniif test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then
2411299e6f19SPaolo Bonzini  error_exit "--enable-vhost-net-user requires --enable-vhost-user"
2412299e6f19SPaolo Bonzinifi
2413299e6f19SPaolo Bonzinitest "$vhost_crypto" = "" && vhost_crypto=$vhost_user
2414299e6f19SPaolo Bonziniif test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then
2415299e6f19SPaolo Bonzini  error_exit "--enable-vhost-crypto requires --enable-vhost-user"
2416299e6f19SPaolo Bonzinifi
241798fc1adaSDr. David Alan Gilberttest "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user
241898fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then
241998fc1adaSDr. David Alan Gilbert  error_exit "--enable-vhost-user-fs requires --enable-vhost-user"
242098fc1adaSDr. David Alan Gilbertfi
2421108a6481SCindy Lu#vhost-vdpa backends
2422108a6481SCindy Lutest "$vhost_net_vdpa" = "" && vhost_net_vdpa=$vhost_vdpa
2423108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" && test "$vhost_vdpa" = "no"; then
2424108a6481SCindy Lu  error_exit "--enable-vhost-net-vdpa requires --enable-vhost-vdpa"
2425108a6481SCindy Lufi
2426299e6f19SPaolo Bonzini
242740bc0ca9SLaurent Vivier# OR the vhost-kernel, vhost-vdpa and vhost-user values for simplicity
2428299e6f19SPaolo Bonziniif test "$vhost_net" = ""; then
2429299e6f19SPaolo Bonzini  test "$vhost_net_user" = "yes" && vhost_net=yes
243040bc0ca9SLaurent Vivier  test "$vhost_net_vdpa" = "yes" && vhost_net=yes
2431299e6f19SPaolo Bonzini  test "$vhost_kernel" = "yes" && vhost_net=yes
2432299e6f19SPaolo Bonzinifi
2433299e6f19SPaolo Bonzini
2434015a33bdSGonglei##########################################
2435779ab5e3SStefan Weil# pkg-config probe
2436779ab5e3SStefan Weil
2437779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then
243876ad07a4SPeter Maydell  error_exit "pkg-config binary '$pkg_config_exe' not found"
2439779ab5e3SStefan Weilfi
2440779ab5e3SStefan Weil
2441779ab5e3SStefan Weil##########################################
2442b0a47e79SJuan Quintela# NPTL probe
2443b0a47e79SJuan Quintela
244424cb36a6SPeter Maydellif test "$linux_user" = "yes"; then
2445bd0c5661Spbrook  cat > $TMPC <<EOF
2446bd0c5661Spbrook#include <sched.h>
244730813ceaSpbrook#include <linux/futex.h>
2448182eacc0SStefan Weilint main(void) {
2449bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
2450bd0c5661Spbrook#error bork
2451bd0c5661Spbrook#endif
2452182eacc0SStefan Weil  return 0;
2453bd0c5661Spbrook}
2454bd0c5661SpbrookEOF
245524cb36a6SPeter Maydell  if ! compile_object ; then
245621684af0SStewart Smith    feature_not_found "nptl" "Install glibc and linux kernel headers."
2457b0a47e79SJuan Quintela  fi
2458bd0c5661Spbrookfi
2459bd0c5661Spbrook
2460ac62922eSbalrog##########################################
2461e37630caSaliguori# xen probe
2462e37630caSaliguori
24631badb709SPaolo Bonziniif test "$xen" != "disabled" ; then
2464c1cdd9d5SJuergen Gross  # Check whether Xen library path is specified via --extra-ldflags to avoid
2465c1cdd9d5SJuergen Gross  # overriding this setting with pkg-config output. If not, try pkg-config
2466c1cdd9d5SJuergen Gross  # to obtain all needed flags.
2467c1cdd9d5SJuergen Gross
2468c1cdd9d5SJuergen Gross  if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2469c1cdd9d5SJuergen Gross     $pkg_config --exists xencontrol ; then
2470c1cdd9d5SJuergen Gross    xen_ctrl_version="$(printf '%d%02d%02d' \
2471c1cdd9d5SJuergen Gross      $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
24721badb709SPaolo Bonzini    xen=enabled
24735b6a8f43SMichael Tokarev    xen_pc="xencontrol xenstore xenforeignmemory xengnttab"
2474c1cdd9d5SJuergen Gross    xen_pc="$xen_pc xenevtchn xendevicemodel"
247558ea9a7aSAnthony PERARD    if $pkg_config --exists xentoolcore; then
247658ea9a7aSAnthony PERARD      xen_pc="$xen_pc xentoolcore"
247758ea9a7aSAnthony PERARD    fi
2478582ea95fSMarc-André Lureau    xen_cflags="$($pkg_config --cflags $xen_pc)"
2479582ea95fSMarc-André Lureau    xen_libs="$($pkg_config --libs $xen_pc)"
2480c1cdd9d5SJuergen Gross  else
2481c1cdd9d5SJuergen Gross
24825b6a8f43SMichael Tokarev    xen_libs="-lxenstore -lxenctrl"
2483d9506cabSAnthony PERARD    xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
2484d5b93ddfSAnthony PERARD
248550ced5b3SStefan Weil    # First we test whether Xen headers and libraries are available.
248650ced5b3SStefan Weil    # If no, we are done and there is no Xen support.
248750ced5b3SStefan Weil    # If yes, more tests are run to detect the Xen version.
248850ced5b3SStefan Weil
248950ced5b3SStefan Weil    # Xen (any)
249050ced5b3SStefan Weil    cat > $TMPC <<EOF
249150ced5b3SStefan Weil#include <xenctrl.h>
249250ced5b3SStefan Weilint main(void) {
249350ced5b3SStefan Weil  return 0;
249450ced5b3SStefan Weil}
249550ced5b3SStefan WeilEOF
249650ced5b3SStefan Weil    if ! compile_prog "" "$xen_libs" ; then
249750ced5b3SStefan Weil      # Xen not found
24981badb709SPaolo Bonzini      if test "$xen" = "enabled" ; then
249921684af0SStewart Smith        feature_not_found "xen" "Install xen devel"
250050ced5b3SStefan Weil      fi
25011badb709SPaolo Bonzini      xen=disabled
250250ced5b3SStefan Weil
2503d5b93ddfSAnthony PERARD    # Xen unstable
250469deef08SPeter Maydell    elif
250569deef08SPeter Maydell        cat > $TMPC <<EOF &&
25062cbf8903SRoss Lagerwall#undef XC_WANT_COMPAT_DEVICEMODEL_API
25072cbf8903SRoss Lagerwall#define __XEN_TOOLS__
25082cbf8903SRoss Lagerwall#include <xendevicemodel.h>
2509d3c49ebbSPaul Durrant#include <xenforeignmemory.h>
25102cbf8903SRoss Lagerwallint main(void) {
25112cbf8903SRoss Lagerwall  xendevicemodel_handle *xd;
2512d3c49ebbSPaul Durrant  xenforeignmemory_handle *xfmem;
25132cbf8903SRoss Lagerwall
25142cbf8903SRoss Lagerwall  xd = xendevicemodel_open(0, 0);
25152cbf8903SRoss Lagerwall  xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
25162cbf8903SRoss Lagerwall
2517d3c49ebbSPaul Durrant  xfmem = xenforeignmemory_open(0, 0);
2518d3c49ebbSPaul Durrant  xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
2519d3c49ebbSPaul Durrant
25202cbf8903SRoss Lagerwall  return 0;
25212cbf8903SRoss Lagerwall}
25222cbf8903SRoss LagerwallEOF
25232cbf8903SRoss Lagerwall        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
25242cbf8903SRoss Lagerwall      then
25252cbf8903SRoss Lagerwall      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
25262cbf8903SRoss Lagerwall      xen_ctrl_version=41100
25271badb709SPaolo Bonzini      xen=enabled
25282cbf8903SRoss Lagerwall    elif
25292cbf8903SRoss Lagerwall        cat > $TMPC <<EOF &&
25305ba3d756SIgor Druzhinin#undef XC_WANT_COMPAT_MAP_FOREIGN_API
25315ba3d756SIgor Druzhinin#include <xenforeignmemory.h>
253258ea9a7aSAnthony PERARD#include <xentoolcore.h>
25335ba3d756SIgor Druzhininint main(void) {
25345ba3d756SIgor Druzhinin  xenforeignmemory_handle *xfmem;
25355ba3d756SIgor Druzhinin
25365ba3d756SIgor Druzhinin  xfmem = xenforeignmemory_open(0, 0);
25375ba3d756SIgor Druzhinin  xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
253858ea9a7aSAnthony PERARD  xentoolcore_restrict_all(0);
25395ba3d756SIgor Druzhinin
25405ba3d756SIgor Druzhinin  return 0;
25415ba3d756SIgor Druzhinin}
25425ba3d756SIgor DruzhininEOF
254358ea9a7aSAnthony PERARD        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
25445ba3d756SIgor Druzhinin      then
254558ea9a7aSAnthony PERARD      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
25465ba3d756SIgor Druzhinin      xen_ctrl_version=41000
25471badb709SPaolo Bonzini      xen=enabled
25485ba3d756SIgor Druzhinin    elif
25495ba3d756SIgor Druzhinin        cat > $TMPC <<EOF &&
2550da8090ccSPaul Durrant#undef XC_WANT_COMPAT_DEVICEMODEL_API
2551da8090ccSPaul Durrant#define __XEN_TOOLS__
2552da8090ccSPaul Durrant#include <xendevicemodel.h>
2553da8090ccSPaul Durrantint main(void) {
2554da8090ccSPaul Durrant  xendevicemodel_handle *xd;
2555da8090ccSPaul Durrant
2556da8090ccSPaul Durrant  xd = xendevicemodel_open(0, 0);
2557da8090ccSPaul Durrant  xendevicemodel_close(xd);
2558da8090ccSPaul Durrant
2559da8090ccSPaul Durrant  return 0;
2560da8090ccSPaul Durrant}
2561da8090ccSPaul DurrantEOF
2562da8090ccSPaul Durrant        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2563da8090ccSPaul Durrant      then
2564da8090ccSPaul Durrant      xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2565f1167ee6SJuergen Gross      xen_ctrl_version=40900
25661badb709SPaolo Bonzini      xen=enabled
2567da8090ccSPaul Durrant    elif
2568da8090ccSPaul Durrant        cat > $TMPC <<EOF &&
25695eeb39c2SIan Campbell/*
25705eeb39c2SIan Campbell * If we have stable libs the we don't want the libxc compat
25715eeb39c2SIan Campbell * layers, regardless of what CFLAGS we may have been given.
2572b6eb9b45SPaulina Szubarczyk *
2573b6eb9b45SPaulina Szubarczyk * Also, check if xengnttab_grant_copy_segment_t is defined and
2574b6eb9b45SPaulina Szubarczyk * grant copy operation is implemented.
2575b6eb9b45SPaulina Szubarczyk */
2576b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_EVTCHN_API
2577b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_GNTTAB_API
2578b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2579b6eb9b45SPaulina Szubarczyk#include <xenctrl.h>
2580b6eb9b45SPaulina Szubarczyk#include <xenstore.h>
2581b6eb9b45SPaulina Szubarczyk#include <xenevtchn.h>
2582b6eb9b45SPaulina Szubarczyk#include <xengnttab.h>
2583b6eb9b45SPaulina Szubarczyk#include <xenforeignmemory.h>
2584b6eb9b45SPaulina Szubarczyk#include <stdint.h>
2585b6eb9b45SPaulina Szubarczyk#include <xen/hvm/hvm_info_table.h>
2586b6eb9b45SPaulina Szubarczyk#if !defined(HVM_MAX_VCPUS)
2587b6eb9b45SPaulina Szubarczyk# error HVM_MAX_VCPUS not defined
2588b6eb9b45SPaulina Szubarczyk#endif
2589b6eb9b45SPaulina Szubarczykint main(void) {
2590b6eb9b45SPaulina Szubarczyk  xc_interface *xc = NULL;
2591b6eb9b45SPaulina Szubarczyk  xenforeignmemory_handle *xfmem;
2592b6eb9b45SPaulina Szubarczyk  xenevtchn_handle *xe;
2593b6eb9b45SPaulina Szubarczyk  xengnttab_handle *xg;
2594b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy_segment_t* seg = NULL;
2595b6eb9b45SPaulina Szubarczyk
2596b6eb9b45SPaulina Szubarczyk  xs_daemon_open();
2597b6eb9b45SPaulina Szubarczyk
2598b6eb9b45SPaulina Szubarczyk  xc = xc_interface_open(0, 0, 0);
2599b6eb9b45SPaulina Szubarczyk  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2600b6eb9b45SPaulina Szubarczyk  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2601b6eb9b45SPaulina Szubarczyk  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2602b6eb9b45SPaulina Szubarczyk  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2603b6eb9b45SPaulina Szubarczyk
2604b6eb9b45SPaulina Szubarczyk  xfmem = xenforeignmemory_open(0, 0);
2605b6eb9b45SPaulina Szubarczyk  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2606b6eb9b45SPaulina Szubarczyk
2607b6eb9b45SPaulina Szubarczyk  xe = xenevtchn_open(0, 0);
2608b6eb9b45SPaulina Szubarczyk  xenevtchn_fd(xe);
2609b6eb9b45SPaulina Szubarczyk
2610b6eb9b45SPaulina Szubarczyk  xg = xengnttab_open(0, 0);
2611b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy(xg, 0, seg);
2612b6eb9b45SPaulina Szubarczyk
2613b6eb9b45SPaulina Szubarczyk  return 0;
2614b6eb9b45SPaulina Szubarczyk}
2615b6eb9b45SPaulina SzubarczykEOF
2616b6eb9b45SPaulina Szubarczyk        compile_prog "" "$xen_libs $xen_stable_libs"
2617b6eb9b45SPaulina Szubarczyk      then
2618f1167ee6SJuergen Gross      xen_ctrl_version=40800
26191badb709SPaolo Bonzini      xen=enabled
2620b6eb9b45SPaulina Szubarczyk    elif
2621b6eb9b45SPaulina Szubarczyk        cat > $TMPC <<EOF &&
2622b6eb9b45SPaulina Szubarczyk/*
2623b6eb9b45SPaulina Szubarczyk * If we have stable libs the we don't want the libxc compat
2624b6eb9b45SPaulina Szubarczyk * layers, regardless of what CFLAGS we may have been given.
26255eeb39c2SIan Campbell */
26265eeb39c2SIan Campbell#undef XC_WANT_COMPAT_EVTCHN_API
26275eeb39c2SIan Campbell#undef XC_WANT_COMPAT_GNTTAB_API
26285eeb39c2SIan Campbell#undef XC_WANT_COMPAT_MAP_FOREIGN_API
26295eeb39c2SIan Campbell#include <xenctrl.h>
26305eeb39c2SIan Campbell#include <xenstore.h>
26315eeb39c2SIan Campbell#include <xenevtchn.h>
26325eeb39c2SIan Campbell#include <xengnttab.h>
26335eeb39c2SIan Campbell#include <xenforeignmemory.h>
26345eeb39c2SIan Campbell#include <stdint.h>
26355eeb39c2SIan Campbell#include <xen/hvm/hvm_info_table.h>
26365eeb39c2SIan Campbell#if !defined(HVM_MAX_VCPUS)
26375eeb39c2SIan Campbell# error HVM_MAX_VCPUS not defined
26385eeb39c2SIan Campbell#endif
26395eeb39c2SIan Campbellint main(void) {
26405eeb39c2SIan Campbell  xc_interface *xc = NULL;
26415eeb39c2SIan Campbell  xenforeignmemory_handle *xfmem;
26425eeb39c2SIan Campbell  xenevtchn_handle *xe;
26435eeb39c2SIan Campbell  xengnttab_handle *xg;
26445eeb39c2SIan Campbell
26455eeb39c2SIan Campbell  xs_daemon_open();
26465eeb39c2SIan Campbell
26475eeb39c2SIan Campbell  xc = xc_interface_open(0, 0, 0);
26485eeb39c2SIan Campbell  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
26495eeb39c2SIan Campbell  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
26505eeb39c2SIan Campbell  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
26515eeb39c2SIan Campbell  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
26525eeb39c2SIan Campbell
26535eeb39c2SIan Campbell  xfmem = xenforeignmemory_open(0, 0);
26545eeb39c2SIan Campbell  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
26555eeb39c2SIan Campbell
26565eeb39c2SIan Campbell  xe = xenevtchn_open(0, 0);
26575eeb39c2SIan Campbell  xenevtchn_fd(xe);
26585eeb39c2SIan Campbell
26595eeb39c2SIan Campbell  xg = xengnttab_open(0, 0);
26605eeb39c2SIan Campbell  xengnttab_map_grant_ref(xg, 0, 0, 0);
26615eeb39c2SIan Campbell
26625eeb39c2SIan Campbell  return 0;
26635eeb39c2SIan Campbell}
26645eeb39c2SIan CampbellEOF
26655eeb39c2SIan Campbell        compile_prog "" "$xen_libs $xen_stable_libs"
26665eeb39c2SIan Campbell      then
2667f1167ee6SJuergen Gross      xen_ctrl_version=40701
26681badb709SPaolo Bonzini      xen=enabled
2669cdadde39SRoger Pau Monne
2670cdadde39SRoger Pau Monne    # Xen 4.6
2671cdadde39SRoger Pau Monne    elif
2672cdadde39SRoger Pau Monne        cat > $TMPC <<EOF &&
2673cdadde39SRoger Pau Monne#include <xenctrl.h>
2674e108a3c1SAnthony PERARD#include <xenstore.h>
2675d5b93ddfSAnthony PERARD#include <stdint.h>
2676d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
2677d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
2678d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
2679d5b93ddfSAnthony PERARD#endif
2680d5b93ddfSAnthony PERARDint main(void) {
2681d5b93ddfSAnthony PERARD  xc_interface *xc;
2682d5b93ddfSAnthony PERARD  xs_daemon_open();
2683d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
2684d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2685d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
2686b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
26878688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2688d8b441a3SJan Beulich  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
268920a544c7SKonrad Rzeszutek Wilk  xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2690d8b441a3SJan Beulich  return 0;
2691d8b441a3SJan Beulich}
2692d8b441a3SJan BeulichEOF
2693d8b441a3SJan Beulich        compile_prog "" "$xen_libs"
2694d8b441a3SJan Beulich      then
2695f1167ee6SJuergen Gross      xen_ctrl_version=40600
26961badb709SPaolo Bonzini      xen=enabled
2697d8b441a3SJan Beulich
2698d8b441a3SJan Beulich    # Xen 4.5
2699d8b441a3SJan Beulich    elif
2700d8b441a3SJan Beulich        cat > $TMPC <<EOF &&
2701d8b441a3SJan Beulich#include <xenctrl.h>
2702d8b441a3SJan Beulich#include <xenstore.h>
2703d8b441a3SJan Beulich#include <stdint.h>
2704d8b441a3SJan Beulich#include <xen/hvm/hvm_info_table.h>
2705d8b441a3SJan Beulich#if !defined(HVM_MAX_VCPUS)
2706d8b441a3SJan Beulich# error HVM_MAX_VCPUS not defined
2707d8b441a3SJan Beulich#endif
2708d8b441a3SJan Beulichint main(void) {
2709d8b441a3SJan Beulich  xc_interface *xc;
2710d8b441a3SJan Beulich  xs_daemon_open();
2711d8b441a3SJan Beulich  xc = xc_interface_open(0, 0, 0);
2712d8b441a3SJan Beulich  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2713d8b441a3SJan Beulich  xc_gnttab_open(NULL, 0);
2714d8b441a3SJan Beulich  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2715d8b441a3SJan Beulich  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
27163996e85cSPaul Durrant  xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
27173996e85cSPaul Durrant  return 0;
27183996e85cSPaul Durrant}
27193996e85cSPaul DurrantEOF
27203996e85cSPaul Durrant        compile_prog "" "$xen_libs"
27213996e85cSPaul Durrant      then
2722f1167ee6SJuergen Gross      xen_ctrl_version=40500
27231badb709SPaolo Bonzini      xen=enabled
27243996e85cSPaul Durrant
27253996e85cSPaul Durrant    elif
27263996e85cSPaul Durrant        cat > $TMPC <<EOF &&
27273996e85cSPaul Durrant#include <xenctrl.h>
27283996e85cSPaul Durrant#include <xenstore.h>
27293996e85cSPaul Durrant#include <stdint.h>
27303996e85cSPaul Durrant#include <xen/hvm/hvm_info_table.h>
27313996e85cSPaul Durrant#if !defined(HVM_MAX_VCPUS)
27323996e85cSPaul Durrant# error HVM_MAX_VCPUS not defined
27333996e85cSPaul Durrant#endif
27343996e85cSPaul Durrantint main(void) {
27353996e85cSPaul Durrant  xc_interface *xc;
27363996e85cSPaul Durrant  xs_daemon_open();
27373996e85cSPaul Durrant  xc = xc_interface_open(0, 0, 0);
27383996e85cSPaul Durrant  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
27393996e85cSPaul Durrant  xc_gnttab_open(NULL, 0);
27403996e85cSPaul Durrant  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
27413996e85cSPaul Durrant  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
27428688e065SStefano Stabellini  return 0;
27438688e065SStefano Stabellini}
27448688e065SStefano StabelliniEOF
27458688e065SStefano Stabellini        compile_prog "" "$xen_libs"
274669deef08SPeter Maydell      then
2747f1167ee6SJuergen Gross      xen_ctrl_version=40200
27481badb709SPaolo Bonzini      xen=enabled
27498688e065SStefano Stabellini
2750e37630caSaliguori    else
27511badb709SPaolo Bonzini      if test "$xen" = "enabled" ; then
2752edfb07edSIan Campbell        feature_not_found "xen (unsupported version)" \
2753edfb07edSIan Campbell                          "Install a supported xen (xen 4.2 or newer)"
2754fc321b4bSJuan Quintela      fi
27551badb709SPaolo Bonzini      xen=disabled
2756e37630caSaliguori    fi
2757d5b93ddfSAnthony PERARD
27581badb709SPaolo Bonzini    if test "$xen" = enabled; then
2759f1167ee6SJuergen Gross      if test $xen_ctrl_version -ge 40701  ; then
2760582ea95fSMarc-André Lureau        xen_libs="$xen_libs $xen_stable_libs "
27615eeb39c2SIan Campbell      fi
2762d5b93ddfSAnthony PERARD    fi
2763e37630caSaliguori  fi
2764c1cdd9d5SJuergen Grossfi
2765e37630caSaliguori
2766d661d9a4SJustin Terry (VM)##########################################
27672da776dbSMichael R. Hines# RDMA needs OpenFabrics libraries
27682da776dbSMichael R. Hinesif test "$rdma" != "no" ; then
27692da776dbSMichael R. Hines  cat > $TMPC <<EOF
27702da776dbSMichael R. Hines#include <rdma/rdma_cma.h>
27712da776dbSMichael R. Hinesint main(void) { return 0; }
27722da776dbSMichael R. HinesEOF
2773ef6d4ccdSYuval Shaia  rdma_libs="-lrdmacm -libverbs -libumad"
27742da776dbSMichael R. Hines  if compile_prog "" "$rdma_libs" ; then
27752da776dbSMichael R. Hines    rdma="yes"
27762da776dbSMichael R. Hines  else
27772da776dbSMichael R. Hines    if test "$rdma" = "yes" ; then
27782da776dbSMichael R. Hines        error_exit \
2779ef6d4ccdSYuval Shaia            " OpenFabrics librdmacm/libibverbs/libibumad not present." \
27802da776dbSMichael R. Hines            " Your options:" \
2781ef6d4ccdSYuval Shaia            "  (1) Fast: Install infiniband packages (devel) from your distro." \
27822da776dbSMichael R. Hines            "  (2) Cleanest: Install libraries from www.openfabrics.org" \
27832da776dbSMichael R. Hines            "  (3) Also: Install softiwarp if you don't have RDMA hardware"
27842da776dbSMichael R. Hines    fi
27852da776dbSMichael R. Hines    rdma="no"
27862da776dbSMichael R. Hines  fi
27872da776dbSMichael R. Hinesfi
27882da776dbSMichael R. Hines
278921ab34c9SMarcel Apfelbaum##########################################
279021ab34c9SMarcel Apfelbaum# PVRDMA detection
279121ab34c9SMarcel Apfelbaum
279221ab34c9SMarcel Apfelbaumcat > $TMPC <<EOF &&
279321ab34c9SMarcel Apfelbaum#include <sys/mman.h>
279421ab34c9SMarcel Apfelbaum
279521ab34c9SMarcel Apfelbaumint
279621ab34c9SMarcel Apfelbaummain(void)
279721ab34c9SMarcel Apfelbaum{
279821ab34c9SMarcel Apfelbaum    char buf = 0;
279921ab34c9SMarcel Apfelbaum    void *addr = &buf;
280021ab34c9SMarcel Apfelbaum    addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED);
280121ab34c9SMarcel Apfelbaum
280221ab34c9SMarcel Apfelbaum    return 0;
280321ab34c9SMarcel Apfelbaum}
280421ab34c9SMarcel ApfelbaumEOF
280521ab34c9SMarcel Apfelbaum
280621ab34c9SMarcel Apfelbaumif test "$rdma" = "yes" ; then
280721ab34c9SMarcel Apfelbaum    case "$pvrdma" in
280821ab34c9SMarcel Apfelbaum    "")
280921ab34c9SMarcel Apfelbaum        if compile_prog "" ""; then
281021ab34c9SMarcel Apfelbaum            pvrdma="yes"
281121ab34c9SMarcel Apfelbaum        else
281221ab34c9SMarcel Apfelbaum            pvrdma="no"
281321ab34c9SMarcel Apfelbaum        fi
281421ab34c9SMarcel Apfelbaum        ;;
281521ab34c9SMarcel Apfelbaum    "yes")
281621ab34c9SMarcel Apfelbaum        if ! compile_prog "" ""; then
281721ab34c9SMarcel Apfelbaum            error_exit "PVRDMA is not supported since mremap is not implemented"
281821ab34c9SMarcel Apfelbaum        fi
281921ab34c9SMarcel Apfelbaum        pvrdma="yes"
282021ab34c9SMarcel Apfelbaum        ;;
282121ab34c9SMarcel Apfelbaum    "no")
282221ab34c9SMarcel Apfelbaum        pvrdma="no"
282321ab34c9SMarcel Apfelbaum        ;;
282421ab34c9SMarcel Apfelbaum    esac
282521ab34c9SMarcel Apfelbaumelse
282621ab34c9SMarcel Apfelbaum    if test "$pvrdma" = "yes" ; then
282721ab34c9SMarcel Apfelbaum        error_exit "PVRDMA requires rdma suppport"
282821ab34c9SMarcel Apfelbaum    fi
282921ab34c9SMarcel Apfelbaum    pvrdma="no"
283021ab34c9SMarcel Apfelbaumfi
283195c6bff3SBenoît Canet
2832ee108585SYuval Shaia# Let's see if enhanced reg_mr is supported
2833ee108585SYuval Shaiaif test "$pvrdma" = "yes" ; then
2834ee108585SYuval Shaia
2835ee108585SYuval Shaiacat > $TMPC <<EOF &&
2836ee108585SYuval Shaia#include <infiniband/verbs.h>
2837ee108585SYuval Shaia
2838ee108585SYuval Shaiaint
2839ee108585SYuval Shaiamain(void)
2840ee108585SYuval Shaia{
2841ee108585SYuval Shaia    struct ibv_mr *mr;
2842ee108585SYuval Shaia    struct ibv_pd *pd = NULL;
2843ee108585SYuval Shaia    size_t length = 10;
2844ee108585SYuval Shaia    uint64_t iova = 0;
2845ee108585SYuval Shaia    int access = 0;
2846ee108585SYuval Shaia    void *addr = NULL;
2847ee108585SYuval Shaia
2848ee108585SYuval Shaia    mr = ibv_reg_mr_iova(pd, addr, length, iova, access);
2849ee108585SYuval Shaia
2850ee108585SYuval Shaia    ibv_dereg_mr(mr);
2851ee108585SYuval Shaia
2852ee108585SYuval Shaia    return 0;
2853ee108585SYuval Shaia}
2854ee108585SYuval ShaiaEOF
2855ee108585SYuval Shaia    if ! compile_prog "" "-libverbs"; then
2856ee108585SYuval Shaia        QEMU_CFLAGS="$QEMU_CFLAGS -DLEGACY_RDMA_REG_MR"
2857ee108585SYuval Shaia    fi
2858ee108585SYuval Shaiafi
2859ee108585SYuval Shaia
286095c6bff3SBenoît Canet##########################################
2861c1bb86cdSEric Blake# xfsctl() probe, used for file-posix.c
2862dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
2863dce512deSChristoph Hellwig  cat > $TMPC << EOF
2864ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
2865dce512deSChristoph Hellwig#include <xfs/xfs.h>
2866dce512deSChristoph Hellwigint main(void)
2867dce512deSChristoph Hellwig{
2868dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
2869dce512deSChristoph Hellwig    return 0;
2870dce512deSChristoph Hellwig}
2871dce512deSChristoph HellwigEOF
2872dce512deSChristoph Hellwig  if compile_prog "" "" ; then
2873dce512deSChristoph Hellwig    xfs="yes"
2874dce512deSChristoph Hellwig  else
2875dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
2876e3a6e0daSzhaolichang      feature_not_found "xfs" "Install xfsprogs/xfslibs devel"
2877dce512deSChristoph Hellwig    fi
2878dce512deSChristoph Hellwig    xfs=no
2879dce512deSChristoph Hellwig  fi
2880dce512deSChristoph Hellwigfi
2881dce512deSChristoph Hellwig
2882dce512deSChristoph Hellwig##########################################
2883ba4dd2aaSAlex Bennée# plugin linker support probe
2884ba4dd2aaSAlex Bennée
2885ba4dd2aaSAlex Bennéeif test "$plugins" != "no"; then
2886ba4dd2aaSAlex Bennée
2887ba4dd2aaSAlex Bennée    #########################################
2888ba4dd2aaSAlex Bennée    # See if --dynamic-list is supported by the linker
2889ba4dd2aaSAlex Bennée
2890ba4dd2aaSAlex Bennée    ld_dynamic_list="no"
2891ba4dd2aaSAlex Bennée    cat > $TMPTXT <<EOF
2892ba4dd2aaSAlex Bennée{
2893ba4dd2aaSAlex Bennée  foo;
2894ba4dd2aaSAlex Bennée};
2895ba4dd2aaSAlex BennéeEOF
2896ba4dd2aaSAlex Bennée
2897ba4dd2aaSAlex Bennée        cat > $TMPC <<EOF
2898ba4dd2aaSAlex Bennée#include <stdio.h>
2899ba4dd2aaSAlex Bennéevoid foo(void);
2900ba4dd2aaSAlex Bennée
2901ba4dd2aaSAlex Bennéevoid foo(void)
2902ba4dd2aaSAlex Bennée{
2903ba4dd2aaSAlex Bennée  printf("foo\n");
2904ba4dd2aaSAlex Bennée}
2905ba4dd2aaSAlex Bennée
2906ba4dd2aaSAlex Bennéeint main(void)
2907ba4dd2aaSAlex Bennée{
2908ba4dd2aaSAlex Bennée  foo();
2909ba4dd2aaSAlex Bennée  return 0;
2910ba4dd2aaSAlex Bennée}
2911ba4dd2aaSAlex BennéeEOF
2912ba4dd2aaSAlex Bennée
2913ba4dd2aaSAlex Bennée    if compile_prog "" "-Wl,--dynamic-list=$TMPTXT" ; then
2914ba4dd2aaSAlex Bennée        ld_dynamic_list="yes"
2915ba4dd2aaSAlex Bennée    fi
2916ba4dd2aaSAlex Bennée
2917ba4dd2aaSAlex Bennée    #########################################
2918ba4dd2aaSAlex Bennée    # See if -exported_symbols_list is supported by the linker
2919ba4dd2aaSAlex Bennée
2920ba4dd2aaSAlex Bennée    ld_exported_symbols_list="no"
2921ba4dd2aaSAlex Bennée    cat > $TMPTXT <<EOF
2922ba4dd2aaSAlex Bennée  _foo
2923ba4dd2aaSAlex BennéeEOF
2924ba4dd2aaSAlex Bennée
2925ba4dd2aaSAlex Bennée    if compile_prog "" "-Wl,-exported_symbols_list,$TMPTXT" ; then
2926ba4dd2aaSAlex Bennée        ld_exported_symbols_list="yes"
2927ba4dd2aaSAlex Bennée    fi
2928ba4dd2aaSAlex Bennée
2929ba4dd2aaSAlex Bennée    if test "$ld_dynamic_list" = "no" &&
2930ba4dd2aaSAlex Bennée       test "$ld_exported_symbols_list" = "no" ; then
2931ba4dd2aaSAlex Bennée        if test "$plugins" = "yes"; then
2932ba4dd2aaSAlex Bennée            error_exit \
2933ba4dd2aaSAlex Bennée                "Plugin support requires dynamic linking and specifying a set of symbols " \
2934ba4dd2aaSAlex Bennée                "that are exported to plugins. Unfortunately your linker doesn't " \
2935ba4dd2aaSAlex Bennée                "support the flag (--dynamic-list or -exported_symbols_list) used " \
2936ba4dd2aaSAlex Bennée                "for this purpose."
2937ba4dd2aaSAlex Bennée        else
2938ba4dd2aaSAlex Bennée            plugins="no"
2939ba4dd2aaSAlex Bennée        fi
2940ba4dd2aaSAlex Bennée    else
2941ba4dd2aaSAlex Bennée        plugins="yes"
2942ba4dd2aaSAlex Bennée    fi
2943ba4dd2aaSAlex Bennéefi
2944ba4dd2aaSAlex Bennée
2945ba4dd2aaSAlex Bennée##########################################
2946e18df141SAnthony Liguori# glib support probe
2947a52d28afSPaolo Bonzini
2948b4c6036fSDaniel P. Berrangéglib_req_ver=2.56
2949aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0
2950aa0d1f44SPaolo Bonziniif test "$modules" = yes; then
2951a88afc64SGerd Hoffmann    glib_modules="$glib_modules gmodule-export-2.0"
2952b906acacSPaolo Bonzinielif test "$plugins" = "yes"; then
2953b906acacSPaolo Bonzini    glib_modules="$glib_modules gmodule-no-export-2.0"
295454cb65d8SEmilio G. Cotafi
2955e26110cfSFam Zheng
2956aa0d1f44SPaolo Bonzinifor i in $glib_modules; do
2957e26110cfSFam Zheng    if $pkg_config --atleast-version=$glib_req_ver $i; then
295889138857SStefan Weil        glib_cflags=$($pkg_config --cflags $i)
295989138857SStefan Weil        glib_libs=$($pkg_config --libs $i)
2960e18df141SAnthony Liguori    else
2961e26110cfSFam Zheng        error_exit "glib-$glib_req_ver $i is required to compile QEMU"
2962e26110cfSFam Zheng    fi
2963e26110cfSFam Zhengdone
2964e26110cfSFam Zheng
2965215b0c2fSPaolo Bonzini# This workaround is required due to a bug in pkg-config file for glib as it
2966215b0c2fSPaolo Bonzini# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
2967215b0c2fSPaolo Bonzini
2968215b0c2fSPaolo Bonziniif test "$static" = yes && test "$mingw32" = yes; then
2969215b0c2fSPaolo Bonzini    glib_cflags="-DGLIB_STATIC_COMPILATION $glib_cflags"
2970215b0c2fSPaolo Bonzinifi
2971215b0c2fSPaolo Bonzini
297220cf7b8eSDenis Plotnikovif ! test "$gio" = "no"; then
297320cf7b8eSDenis Plotnikov    pass=no
2974f876b765SMarc-André Lureau    if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
2975f876b765SMarc-André Lureau        gio_cflags=$($pkg_config --cflags gio-2.0)
2976f876b765SMarc-André Lureau        gio_libs=$($pkg_config --libs gio-2.0)
297725a97a56SMarc-André Lureau        gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0)
29785ecfb76cSPaolo Bonzini        if ! has "$gdbus_codegen"; then
29790dba4897SMarc-André Lureau            gdbus_codegen=
29800dba4897SMarc-André Lureau        fi
298176346b62SPeter Maydell        # Check that the libraries actually work -- Ubuntu 18.04 ships
298276346b62SPeter Maydell        # with pkg-config --static --libs data for gio-2.0 that is missing
298376346b62SPeter Maydell        # -lblkid and will give a link error.
298413ceae66SPeter Maydell        cat > $TMPC <<EOF
298513ceae66SPeter Maydell#include <gio/gio.h>
298613ceae66SPeter Maydellint main(void)
298713ceae66SPeter Maydell{
298813ceae66SPeter Maydell    g_dbus_proxy_new_sync(0, 0, 0, 0, 0, 0, 0, 0);
298913ceae66SPeter Maydell    return 0;
299013ceae66SPeter Maydell}
299113ceae66SPeter MaydellEOF
299213ceae66SPeter Maydell        if compile_prog "$gio_cflags" "$gio_libs" ; then
299320cf7b8eSDenis Plotnikov            pass=yes
299476346b62SPeter Maydell        else
299520cf7b8eSDenis Plotnikov            pass=no
2996f876b765SMarc-André Lureau        fi
2997f876b765SMarc-André Lureau
299820cf7b8eSDenis Plotnikov        if test "$pass" = "yes" &&
299920cf7b8eSDenis Plotnikov            $pkg_config --atleast-version=$glib_req_ver gio-unix-2.0; then
300025a97a56SMarc-André Lureau            gio_cflags="$gio_cflags $($pkg_config --cflags gio-unix-2.0)"
300125a97a56SMarc-André Lureau            gio_libs="$gio_libs $($pkg_config --libs gio-unix-2.0)"
300225a97a56SMarc-André Lureau        fi
300320cf7b8eSDenis Plotnikov    fi
300420cf7b8eSDenis Plotnikov
300520cf7b8eSDenis Plotnikov    if test "$pass" = "no"; then
300620cf7b8eSDenis Plotnikov        if test "$gio" = "yes"; then
300720cf7b8eSDenis Plotnikov            feature_not_found "gio" "Install libgio >= 2.0"
300820cf7b8eSDenis Plotnikov        else
300920cf7b8eSDenis Plotnikov            gio=no
301020cf7b8eSDenis Plotnikov        fi
301120cf7b8eSDenis Plotnikov    else
301220cf7b8eSDenis Plotnikov        gio=yes
301320cf7b8eSDenis Plotnikov    fi
301420cf7b8eSDenis Plotnikovfi
301525a97a56SMarc-André Lureau
3016977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the
3017977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches
3018977a82abSDaniel P. Berrange# problems on multi-arch where people try to build
3019977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers
3020977a82abSDaniel P. Berrangecat > $TMPC <<EOF
3021977a82abSDaniel P. Berrange#include <glib.h>
3022977a82abSDaniel P. Berrange#include <unistd.h>
3023977a82abSDaniel P. Berrange
3024977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \
3025977a82abSDaniel P. Berrange  typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3026977a82abSDaniel P. Berrange
3027977a82abSDaniel P. Berrangeint main(void) {
3028977a82abSDaniel P. Berrange   QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3029977a82abSDaniel P. Berrange   return 0;
3030977a82abSDaniel P. Berrange}
3031977a82abSDaniel P. BerrangeEOF
3032977a82abSDaniel P. Berrange
3033215b0c2fSPaolo Bonziniif ! compile_prog "$glib_cflags" "$glib_libs" ; then
3034977a82abSDaniel P. Berrange    error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3035977a82abSDaniel P. Berrange               "You probably need to set PKG_CONFIG_LIBDIR"\
3036977a82abSDaniel P. Berrange	       "to point to the right pkg-config files for your"\
3037977a82abSDaniel P. Berrange	       "build target"
3038977a82abSDaniel P. Berrangefi
3039977a82abSDaniel P. Berrange
30409bda600bSEric Blake# Silence clang warnings triggered by glib < 2.57.2
30419bda600bSEric Blakecat > $TMPC << EOF
30429bda600bSEric Blake#include <glib.h>
30439bda600bSEric Blaketypedef struct Foo {
30449bda600bSEric Blake    int i;
30459bda600bSEric Blake} Foo;
30469bda600bSEric Blakestatic void foo_free(Foo *f)
30479bda600bSEric Blake{
30489bda600bSEric Blake    g_free(f);
30499bda600bSEric Blake}
30509bda600bSEric BlakeG_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free);
30519bda600bSEric Blakeint main(void) { return 0; }
30529bda600bSEric BlakeEOF
30539bda600bSEric Blakeif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
30549bda600bSEric Blake    if cc_has_warning_flag "-Wno-unused-function"; then
30559bda600bSEric Blake        glib_cflags="$glib_cflags -Wno-unused-function"
30565770e8afSPaolo Bonzini        CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -Wno-unused-function"
30579bda600bSEric Blake    fi
30589bda600bSEric Blakefi
30599bda600bSEric Blake
3060e26110cfSFam Zheng##########################################
3061e26110cfSFam Zheng# SHA command probe for modules
3062e26110cfSFam Zhengif test "$modules" = yes; then
3063e26110cfSFam Zheng    shacmd_probe="sha1sum sha1 shasum"
3064e26110cfSFam Zheng    for c in $shacmd_probe; do
30658ccefb91SFam Zheng        if has $c; then
3066e26110cfSFam Zheng            shacmd="$c"
3067e26110cfSFam Zheng            break
3068e26110cfSFam Zheng        fi
3069e26110cfSFam Zheng    done
3070e26110cfSFam Zheng    if test "$shacmd" = ""; then
3071e26110cfSFam Zheng        error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3072e26110cfSFam Zheng    fi
3073e18df141SAnthony Liguorifi
3074e18df141SAnthony Liguori
3075e18df141SAnthony Liguori##########################################
3076b10d49d7SPino Toscano# libssh probe
3077b10d49d7SPino Toscanoif test "$libssh" != "no" ; then
3078b4c10fc6SThomas Huth  if $pkg_config --exists "libssh >= 0.8.7"; then
3079b10d49d7SPino Toscano    libssh_cflags=$($pkg_config libssh --cflags)
3080b10d49d7SPino Toscano    libssh_libs=$($pkg_config libssh --libs)
3081b10d49d7SPino Toscano    libssh=yes
30820a12ec87SRichard W.M. Jones  else
3083b10d49d7SPino Toscano    if test "$libssh" = "yes" ; then
3084b10d49d7SPino Toscano      error_exit "libssh required for --enable-libssh"
30850a12ec87SRichard W.M. Jones    fi
3086b10d49d7SPino Toscano    libssh=no
30870a12ec87SRichard W.M. Jones  fi
30880a12ec87SRichard W.M. Jonesfi
30890a12ec87SRichard W.M. Jones
30900a12ec87SRichard W.M. Jones##########################################
30917aaa6a16SPaolo Bonzini# TPM emulation is only on POSIX
30923b8acc11SPaolo Bonzini
30937aaa6a16SPaolo Bonziniif test "$tpm" = ""; then
30947aaa6a16SPaolo Bonzini  if test "$mingw32" = "yes"; then
30957aaa6a16SPaolo Bonzini    tpm=no
30963b8acc11SPaolo Bonzini  else
30977aaa6a16SPaolo Bonzini    tpm=yes
30987aaa6a16SPaolo Bonzini  fi
30997aaa6a16SPaolo Bonzinielif test "$tpm" = "yes"; then
31007aaa6a16SPaolo Bonzini  if test "$mingw32" = "yes" ; then
31017aaa6a16SPaolo Bonzini    error_exit "TPM emulation only available on POSIX systems"
31027aaa6a16SPaolo Bonzini  fi
31033b8acc11SPaolo Bonzinifi
31043b8acc11SPaolo Bonzini
31053b8acc11SPaolo Bonzini##########################################
3106f652e6afSaurel32# fdt probe
3107e169e1e1SPeter Maydell
3108fbb4121dSPaolo Bonzinicase "$fdt" in
3109fbb4121dSPaolo Bonzini  auto | enabled | internal)
3110fbb4121dSPaolo Bonzini    # Simpler to always update submodule, even if not needed.
3111aef45d51SDaniel P. Berrange    git_submodules="${git_submodules} dtc"
3112fbb4121dSPaolo Bonzini    ;;
3113fbb4121dSPaolo Bonziniesac
3114f652e6afSaurel32
311520ff075bSMichael Walle##########################################
31169d49bcf6SMarkus Armbruster# opengl probe (for sdl2, gtk)
3117b1546f32SGerd Hoffmann
3118da076ffeSGerd Hoffmannif test "$opengl" != "no" ; then
3119bc6a3565SAkihiko Odaki  epoxy=no
3120bc6a3565SAkihiko Odaki  if $pkg_config epoxy; then
3121bc6a3565SAkihiko Odaki    cat > $TMPC << EOF
3122bc6a3565SAkihiko Odaki#include <epoxy/egl.h>
3123bc6a3565SAkihiko Odakiint main(void) { return 0; }
3124bc6a3565SAkihiko OdakiEOF
3125bc6a3565SAkihiko Odaki    if compile_prog "" "" ; then
3126bc6a3565SAkihiko Odaki      epoxy=yes
3127bc6a3565SAkihiko Odaki    fi
3128bc6a3565SAkihiko Odaki  fi
3129bc6a3565SAkihiko Odaki
3130bc6a3565SAkihiko Odaki  if test "$epoxy" = "yes" ; then
3131bc6a3565SAkihiko Odaki    opengl_cflags="$($pkg_config --cflags epoxy)"
3132bc6a3565SAkihiko Odaki    opengl_libs="$($pkg_config --libs epoxy)"
3133da076ffeSGerd Hoffmann    opengl=yes
313420ff075bSMichael Walle  else
3135da076ffeSGerd Hoffmann    if test "$opengl" = "yes" ; then
3136bc6a3565SAkihiko Odaki      feature_not_found "opengl" "Please install epoxy with EGL"
313720ff075bSMichael Walle    fi
3138f676c67eSJeremy White    opengl_cflags=""
3139da076ffeSGerd Hoffmann    opengl_libs=""
3140da076ffeSGerd Hoffmann    opengl=no
314120ff075bSMichael Walle  fi
314220ff075bSMichael Wallefi
314320ff075bSMichael Walle
3144dcc38d1cSMarcelo Tosatti##########################################
3145a99d57bbSWanlong Gao# libnuma probe
3146a99d57bbSWanlong Gao
3147a99d57bbSWanlong Gaoif test "$numa" != "no" ; then
3148a99d57bbSWanlong Gao  cat > $TMPC << EOF
3149a99d57bbSWanlong Gao#include <numa.h>
3150a99d57bbSWanlong Gaoint main(void) { return numa_available(); }
3151a99d57bbSWanlong GaoEOF
3152a99d57bbSWanlong Gao
3153a99d57bbSWanlong Gao  if compile_prog "" "-lnuma" ; then
3154a99d57bbSWanlong Gao    numa=yes
3155ab318051SMarc-André Lureau    numa_libs="-lnuma"
3156a99d57bbSWanlong Gao  else
3157a99d57bbSWanlong Gao    if test "$numa" = "yes" ; then
3158a99d57bbSWanlong Gao      feature_not_found "numa" "install numactl devel"
3159a99d57bbSWanlong Gao    fi
3160a99d57bbSWanlong Gao    numa=no
3161a99d57bbSWanlong Gao  fi
3162a99d57bbSWanlong Gaofi
3163a99d57bbSWanlong Gao
3164aa087962SPaolo Bonzinimalloc=system
31657b01cb97SAlexandre Derumierif test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
31667b01cb97SAlexandre Derumier    echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
31677b01cb97SAlexandre Derumier    exit 1
3168aa087962SPaolo Bonzinielif test "$tcmalloc" = "yes" ; then
3169aa087962SPaolo Bonzini    malloc=tcmalloc
3170aa087962SPaolo Bonzinielif test "$jemalloc" = "yes" ; then
3171aa087962SPaolo Bonzini    malloc=jemalloc
31727b01cb97SAlexandre Derumierfi
31737b01cb97SAlexandre Derumier
3174955727d2SCortland Tölva# check for usbfs
3175955727d2SCortland Tölvahave_usbfs=no
3176955727d2SCortland Tölvaif test "$linux_user" = "yes"; then
317796566d09SThomas Petazzoni  cat > $TMPC << EOF
317896566d09SThomas Petazzoni#include <linux/usbdevice_fs.h>
317996566d09SThomas Petazzoni
318096566d09SThomas Petazzoni#ifndef USBDEVFS_GET_CAPABILITIES
318196566d09SThomas Petazzoni#error "USBDEVFS_GET_CAPABILITIES undefined"
318296566d09SThomas Petazzoni#endif
318396566d09SThomas Petazzoni
318496566d09SThomas Petazzoni#ifndef USBDEVFS_DISCONNECT_CLAIM
318596566d09SThomas Petazzoni#error "USBDEVFS_DISCONNECT_CLAIM undefined"
318696566d09SThomas Petazzoni#endif
318796566d09SThomas Petazzoni
318896566d09SThomas Petazzoniint main(void)
318996566d09SThomas Petazzoni{
319096566d09SThomas Petazzoni    return 0;
319196566d09SThomas Petazzoni}
319296566d09SThomas PetazzoniEOF
319396566d09SThomas Petazzoni  if compile_prog "" ""; then
3194955727d2SCortland Tölva    have_usbfs=yes
3195955727d2SCortland Tölva  fi
3196955727d2SCortland Tölvafi
3197751bcc39SMarc-André Lureau
3198de5071c5SBlue Swirl##########################################
3199d9840e25STomoki Sekiyama# check if we have VSS SDK headers for win
3200d9840e25STomoki Sekiyama
3201e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
3202e633a5c6SEric Blake        test "$vss_win32_sdk" != "no" ; then
3203d9840e25STomoki Sekiyama  case "$vss_win32_sdk" in
3204690604f6SMichael Roth    "")   vss_win32_include="-isystem $source_path" ;;
3205d9840e25STomoki Sekiyama    *\ *) # The SDK is installed in "Program Files" by default, but we cannot
3206d9840e25STomoki Sekiyama          # handle path with spaces. So we symlink the headers into ".sdk/vss".
3207690604f6SMichael Roth          vss_win32_include="-isystem $source_path/.sdk/vss"
3208d9840e25STomoki Sekiyama	  symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
3209d9840e25STomoki Sekiyama	  ;;
3210690604f6SMichael Roth    *)    vss_win32_include="-isystem $vss_win32_sdk"
3211d9840e25STomoki Sekiyama  esac
3212d9840e25STomoki Sekiyama  cat > $TMPC << EOF
3213d9840e25STomoki Sekiyama#define __MIDL_user_allocate_free_DEFINED__
3214d9840e25STomoki Sekiyama#include <inc/win2003/vss.h>
3215d9840e25STomoki Sekiyamaint main(void) { return VSS_CTX_BACKUP; }
3216d9840e25STomoki SekiyamaEOF
3217d9840e25STomoki Sekiyama  if compile_prog "$vss_win32_include" "" ; then
3218d9840e25STomoki Sekiyama    guest_agent_with_vss="yes"
3219d9840e25STomoki Sekiyama    QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
3220315d3184SFam Zheng    libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
3221f33ca81fSMichael Roth    qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
3222d9840e25STomoki Sekiyama  else
3223d9840e25STomoki Sekiyama    if test "$vss_win32_sdk" != "" ; then
3224d9840e25STomoki Sekiyama      echo "ERROR: Please download and install Microsoft VSS SDK:"
3225d9840e25STomoki Sekiyama      echo "ERROR:   http://www.microsoft.com/en-us/download/details.aspx?id=23490"
3226d9840e25STomoki Sekiyama      echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
3227d9840e25STomoki Sekiyama      echo "ERROR:   scripts/extract-vsssdk-headers setup.exe"
3228d9840e25STomoki Sekiyama      echo "ERROR: The headers are extracted in the directory \`inc'."
3229d9840e25STomoki Sekiyama      feature_not_found "VSS support"
3230d9840e25STomoki Sekiyama    fi
3231d9840e25STomoki Sekiyama    guest_agent_with_vss="no"
3232d9840e25STomoki Sekiyama  fi
3233d9840e25STomoki Sekiyamafi
3234d9840e25STomoki Sekiyama
3235d9840e25STomoki Sekiyama##########################################
3236d9840e25STomoki Sekiyama# lookup Windows platform SDK (if not specified)
3237d9840e25STomoki Sekiyama# The SDK is needed only to build .tlb (type library) file of guest agent
3238d9840e25STomoki Sekiyama# VSS provider from the source. It is usually unnecessary because the
3239d9840e25STomoki Sekiyama# pre-compiled .tlb file is included.
3240d9840e25STomoki Sekiyama
3241e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
3242e633a5c6SEric Blake        test "$guest_agent_with_vss" = "yes" ; then
3243d9840e25STomoki Sekiyama  if test -z "$win_sdk"; then
3244d9840e25STomoki Sekiyama    programfiles="$PROGRAMFILES"
3245d9840e25STomoki Sekiyama    test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
3246d9840e25STomoki Sekiyama    if test -n "$programfiles"; then
3247d9840e25STomoki Sekiyama      win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
3248d9840e25STomoki Sekiyama    else
3249d9840e25STomoki Sekiyama      feature_not_found "Windows SDK"
3250d9840e25STomoki Sekiyama    fi
3251d9840e25STomoki Sekiyama  elif test "$win_sdk" = "no"; then
3252d9840e25STomoki Sekiyama    win_sdk=""
3253d9840e25STomoki Sekiyama  fi
3254d9840e25STomoki Sekiyamafi
3255d9840e25STomoki Sekiyama
3256d9840e25STomoki Sekiyama##########################################
325750cbebb9SMichael Roth# check if mingw environment provides a recent ntddscsi.h
3258e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no"; then
325950cbebb9SMichael Roth  cat > $TMPC << EOF
326050cbebb9SMichael Roth#include <windows.h>
326150cbebb9SMichael Roth#include <ntddscsi.h>
326250cbebb9SMichael Rothint main(void) {
326350cbebb9SMichael Roth#if !defined(IOCTL_SCSI_GET_ADDRESS)
326450cbebb9SMichael Roth#error Missing required ioctl definitions
326550cbebb9SMichael Roth#endif
326650cbebb9SMichael Roth  SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
326750cbebb9SMichael Roth  return addr.Lun;
326850cbebb9SMichael Roth}
326950cbebb9SMichael RothEOF
327050cbebb9SMichael Roth  if compile_prog "" "" ; then
327150cbebb9SMichael Roth    guest_agent_ntddscsi=yes
3272996b9cdcSMatt Hines    libs_qga="-lsetupapi -lcfgmgr32 $libs_qga"
327350cbebb9SMichael Roth  fi
327450cbebb9SMichael Rothfi
327550cbebb9SMichael Roth
327650cbebb9SMichael Roth##########################################
32778ca80760SRichard Henderson# capstone
32788ca80760SRichard Henderson
3279e219c499SRichard Hendersoncase "$capstone" in
32808b18cdbfSRichard Henderson  auto | enabled | internal)
32818b18cdbfSRichard Henderson    # Simpler to always update submodule, even if not needed.
3282e219c499SRichard Henderson    git_submodules="${git_submodules} capstone"
3283e219c499SRichard Henderson    ;;
3284e219c499SRichard Hendersonesac
32858ca80760SRichard Henderson
32868ca80760SRichard Henderson##########################################
3287519175a2SAlex Barcelo# check and set a backend for coroutine
3288d0e2fce5SAneesh Kumar K.V
32897c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback
329033c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows
329133c53c54SDaniel P. Berrange# specific one.
32927c2acc70SPeter Maydell
32937c2acc70SPeter Maydellucontext_works=no
3294d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
3295d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
3296d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
3297cdf84806SPeter Maydell#ifdef __stub_makecontext
3298cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
3299cdf84806SPeter Maydell#endif
330075cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
3301d0e2fce5SAneesh Kumar K.VEOF
3302d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
33037c2acc70SPeter Maydell    ucontext_works=yes
3304d0e2fce5SAneesh Kumar K.V  fi
3305519175a2SAlex Barcelofi
33067c2acc70SPeter Maydell
33077c2acc70SPeter Maydellif test "$coroutine" = ""; then
33087c2acc70SPeter Maydell  if test "$mingw32" = "yes"; then
33097c2acc70SPeter Maydell    coroutine=win32
33107c2acc70SPeter Maydell  elif test "$ucontext_works" = "yes"; then
33117c2acc70SPeter Maydell    coroutine=ucontext
3312519175a2SAlex Barcelo  else
33137c2acc70SPeter Maydell    coroutine=sigaltstack
33147c2acc70SPeter Maydell  fi
33157c2acc70SPeter Maydellelse
33167c2acc70SPeter Maydell  case $coroutine in
33177c2acc70SPeter Maydell  windows)
33187c2acc70SPeter Maydell    if test "$mingw32" != "yes"; then
33197c2acc70SPeter Maydell      error_exit "'windows' coroutine backend only valid for Windows"
33207c2acc70SPeter Maydell    fi
33217c2acc70SPeter Maydell    # Unfortunately the user visible backend name doesn't match the
33227c2acc70SPeter Maydell    # coroutine-*.c filename for this case, so we have to adjust it here.
33237c2acc70SPeter Maydell    coroutine=win32
33247c2acc70SPeter Maydell    ;;
33257c2acc70SPeter Maydell  ucontext)
33267c2acc70SPeter Maydell    if test "$ucontext_works" != "yes"; then
33277c2acc70SPeter Maydell      feature_not_found "ucontext"
33287c2acc70SPeter Maydell    fi
33297c2acc70SPeter Maydell    ;;
333033c53c54SDaniel P. Berrange  sigaltstack)
33317c2acc70SPeter Maydell    if test "$mingw32" = "yes"; then
33327c2acc70SPeter Maydell      error_exit "only the 'windows' coroutine backend is valid for Windows"
33337c2acc70SPeter Maydell    fi
33347c2acc70SPeter Maydell    ;;
33357c2acc70SPeter Maydell  *)
333676ad07a4SPeter Maydell    error_exit "unknown coroutine backend $coroutine"
33377c2acc70SPeter Maydell    ;;
33387c2acc70SPeter Maydell  esac
3339d0e2fce5SAneesh Kumar K.Vfi
3340d0e2fce5SAneesh Kumar K.V
334170c60c08SStefan Hajnocziif test "$coroutine_pool" = ""; then
334270c60c08SStefan Hajnoczi  coroutine_pool=yes
334370c60c08SStefan Hajnoczifi
334470c60c08SStefan Hajnoczi
33457d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes"; then
33467d992e4dSPeter Lieven  if test "$coroutine_pool" = "yes"; then
33477d992e4dSPeter Lieven    echo "WARN: disabling coroutine pool for stack usage debugging"
33487d992e4dSPeter Lieven    coroutine_pool=no
33497d992e4dSPeter Lieven  fi
33507d992e4dSPeter Lievenfi
33517d992e4dSPeter Lieven
33521e4f6065SDaniele Buono##################################################
33531e4f6065SDaniele Buono# SafeStack
33541e4f6065SDaniele Buono
33551e4f6065SDaniele Buono
33561e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then
33571e4f6065SDaniele Buonocat > $TMPC << EOF
33581e4f6065SDaniele Buonoint main(int argc, char *argv[])
33591e4f6065SDaniele Buono{
33601e4f6065SDaniele Buono#if ! __has_feature(safe_stack)
33611e4f6065SDaniele Buono#error SafeStack Disabled
33621e4f6065SDaniele Buono#endif
33631e4f6065SDaniele Buono    return 0;
33641e4f6065SDaniele Buono}
33651e4f6065SDaniele BuonoEOF
33661e4f6065SDaniele Buono  flag="-fsanitize=safe-stack"
33671e4f6065SDaniele Buono  # Check that safe-stack is supported and enabled.
33681e4f6065SDaniele Buono  if compile_prog "-Werror $flag" "$flag"; then
33691e4f6065SDaniele Buono    # Flag needed both at compilation and at linking
33701e4f6065SDaniele Buono    QEMU_CFLAGS="$QEMU_CFLAGS $flag"
33711e4f6065SDaniele Buono    QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
33721e4f6065SDaniele Buono  else
33731e4f6065SDaniele Buono    error_exit "SafeStack not supported by your compiler"
33741e4f6065SDaniele Buono  fi
33751e4f6065SDaniele Buono  if test "$coroutine" != "ucontext"; then
33761e4f6065SDaniele Buono    error_exit "SafeStack is only supported by the coroutine backend ucontext"
33771e4f6065SDaniele Buono  fi
33781e4f6065SDaniele Buonoelse
33791e4f6065SDaniele Buonocat > $TMPC << EOF
33801e4f6065SDaniele Buonoint main(int argc, char *argv[])
33811e4f6065SDaniele Buono{
33821e4f6065SDaniele Buono#if defined(__has_feature)
33831e4f6065SDaniele Buono#if __has_feature(safe_stack)
33841e4f6065SDaniele Buono#error SafeStack Enabled
33851e4f6065SDaniele Buono#endif
33861e4f6065SDaniele Buono#endif
33871e4f6065SDaniele Buono    return 0;
33881e4f6065SDaniele Buono}
33891e4f6065SDaniele BuonoEOF
33901e4f6065SDaniele Buonoif test "$safe_stack" = "no"; then
33911e4f6065SDaniele Buono  # Make sure that safe-stack is disabled
33921e4f6065SDaniele Buono  if ! compile_prog "-Werror" ""; then
33931e4f6065SDaniele Buono    # SafeStack was already enabled, try to explicitly remove the feature
33941e4f6065SDaniele Buono    flag="-fno-sanitize=safe-stack"
33951e4f6065SDaniele Buono    if ! compile_prog "-Werror $flag" "$flag"; then
33961e4f6065SDaniele Buono      error_exit "Configure cannot disable SafeStack"
33971e4f6065SDaniele Buono    fi
33981e4f6065SDaniele Buono    QEMU_CFLAGS="$QEMU_CFLAGS $flag"
33991e4f6065SDaniele Buono    QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
34001e4f6065SDaniele Buono  fi
34011e4f6065SDaniele Buonoelse # "$safe_stack" = ""
34021e4f6065SDaniele Buono  # Set safe_stack to yes or no based on pre-existing flags
34031e4f6065SDaniele Buono  if compile_prog "-Werror" ""; then
34041e4f6065SDaniele Buono    safe_stack="no"
34051e4f6065SDaniele Buono  else
34061e4f6065SDaniele Buono    safe_stack="yes"
34071e4f6065SDaniele Buono    if test "$coroutine" != "ucontext"; then
34081e4f6065SDaniele Buono      error_exit "SafeStack is only supported by the coroutine backend ucontext"
34091e4f6065SDaniele Buono    fi
34101e4f6065SDaniele Buono  fi
34111e4f6065SDaniele Buonofi
34121e4f6065SDaniele Buonofi
34137d992e4dSPeter Lieven
341476a347e1SRichard Henderson########################################
341576a347e1SRichard Henderson# check if cpuid.h is usable.
341676a347e1SRichard Henderson
341776a347e1SRichard Hendersoncat > $TMPC << EOF
341876a347e1SRichard Henderson#include <cpuid.h>
341976a347e1SRichard Hendersonint main(void) {
3420774d566cSPeter Maydell    unsigned a, b, c, d;
3421774d566cSPeter Maydell    int max = __get_cpuid_max(0, 0);
3422774d566cSPeter Maydell
3423774d566cSPeter Maydell    if (max >= 1) {
3424774d566cSPeter Maydell        __cpuid(1, a, b, c, d);
3425774d566cSPeter Maydell    }
3426774d566cSPeter Maydell
3427774d566cSPeter Maydell    if (max >= 7) {
3428774d566cSPeter Maydell        __cpuid_count(7, 0, a, b, c, d);
3429774d566cSPeter Maydell    }
3430774d566cSPeter Maydell
343176a347e1SRichard Henderson    return 0;
343276a347e1SRichard Henderson}
343376a347e1SRichard HendersonEOF
343476a347e1SRichard Hendersonif compile_prog "" "" ; then
343576a347e1SRichard Henderson    cpuid_h=yes
343676a347e1SRichard Hendersonfi
343776a347e1SRichard Henderson
34385dd89908SRichard Henderson##########################################
34395dd89908SRichard Henderson# avx2 optimization requirement check
34405dd89908SRichard Henderson#
34415dd89908SRichard Henderson# There is no point enabling this if cpuid.h is not usable,
34425dd89908SRichard Henderson# since we won't be able to select the new routines.
34435dd89908SRichard Henderson
3444e633a5c6SEric Blakeif test "$cpuid_h" = "yes" && test "$avx2_opt" != "no"; then
34455dd89908SRichard Henderson  cat > $TMPC << EOF
34465dd89908SRichard Henderson#pragma GCC push_options
34475dd89908SRichard Henderson#pragma GCC target("avx2")
34485dd89908SRichard Henderson#include <cpuid.h>
34495dd89908SRichard Henderson#include <immintrin.h>
34505dd89908SRichard Hendersonstatic int bar(void *a) {
34515dd89908SRichard Henderson    __m256i x = *(__m256i *)a;
34525dd89908SRichard Henderson    return _mm256_testz_si256(x, x);
34535dd89908SRichard Henderson}
34545dd89908SRichard Hendersonint main(int argc, char *argv[]) { return bar(argv[0]); }
34555dd89908SRichard HendersonEOF
34565b945f23SRichard Henderson  if compile_object "-Werror" ; then
34575dd89908SRichard Henderson    avx2_opt="yes"
345886583a07SLiam Merwick  else
345986583a07SLiam Merwick    avx2_opt="no"
34605dd89908SRichard Henderson  fi
34615dd89908SRichard Hendersonfi
34625dd89908SRichard Henderson
34636b8cd447SRobert Hoo##########################################
34646b8cd447SRobert Hoo# avx512f optimization requirement check
34656b8cd447SRobert Hoo#
34666b8cd447SRobert Hoo# There is no point enabling this if cpuid.h is not usable,
34676b8cd447SRobert Hoo# since we won't be able to select the new routines.
34686b8cd447SRobert Hoo# by default, it is turned off.
34696b8cd447SRobert Hoo# if user explicitly want to enable it, check environment
34706b8cd447SRobert Hoo
34716b8cd447SRobert Hooif test "$cpuid_h" = "yes" && test "$avx512f_opt" = "yes"; then
34726b8cd447SRobert Hoo  cat > $TMPC << EOF
34736b8cd447SRobert Hoo#pragma GCC push_options
34746b8cd447SRobert Hoo#pragma GCC target("avx512f")
34756b8cd447SRobert Hoo#include <cpuid.h>
34766b8cd447SRobert Hoo#include <immintrin.h>
34776b8cd447SRobert Hoostatic int bar(void *a) {
34786b8cd447SRobert Hoo    __m512i x = *(__m512i *)a;
34796b8cd447SRobert Hoo    return _mm512_test_epi64_mask(x, x);
34806b8cd447SRobert Hoo}
34816b8cd447SRobert Hooint main(int argc, char *argv[])
34826b8cd447SRobert Hoo{
34836b8cd447SRobert Hoo	return bar(argv[0]);
34846b8cd447SRobert Hoo}
34856b8cd447SRobert HooEOF
34865b945f23SRichard Henderson  if ! compile_object "-Werror" ; then
34876b8cd447SRobert Hoo    avx512f_opt="no"
34886b8cd447SRobert Hoo  fi
34896b8cd447SRobert Hooelse
34906b8cd447SRobert Hoo  avx512f_opt="no"
34916b8cd447SRobert Hoofi
34926b8cd447SRobert Hoo
3493f540166bSRichard Henderson########################################
3494f540166bSRichard Henderson# check if __[u]int128_t is usable.
3495f540166bSRichard Henderson
3496f540166bSRichard Hendersonint128=no
3497f540166bSRichard Hendersoncat > $TMPC << EOF
3498f540166bSRichard Henderson__int128_t a;
3499f540166bSRichard Henderson__uint128_t b;
3500f540166bSRichard Hendersonint main (void) {
3501f540166bSRichard Henderson  a = a + b;
3502f540166bSRichard Henderson  b = a * b;
3503464e3671SPeter Maydell  a = a * a;
3504f540166bSRichard Henderson  return 0;
3505f540166bSRichard Henderson}
3506f540166bSRichard HendersonEOF
3507f540166bSRichard Hendersonif compile_prog "" "" ; then
3508f540166bSRichard Henderson    int128=yes
3509f540166bSRichard Hendersonfi
351076a347e1SRichard Henderson
35117ebee43eSRichard Henderson#########################################
35127ebee43eSRichard Henderson# See if 128-bit atomic operations are supported.
35137ebee43eSRichard Henderson
35147ebee43eSRichard Hendersonatomic128=no
35157ebee43eSRichard Hendersonif test "$int128" = "yes"; then
35167ebee43eSRichard Henderson  cat > $TMPC << EOF
35177ebee43eSRichard Hendersonint main(void)
35187ebee43eSRichard Henderson{
35197ebee43eSRichard Henderson  unsigned __int128 x = 0, y = 0;
3520bceac547SThomas Huth  y = __atomic_load(&x, 0);
3521bceac547SThomas Huth  __atomic_store(&x, y, 0);
3522bceac547SThomas Huth  __atomic_compare_exchange(&x, &y, x, 0, 0, 0);
35237ebee43eSRichard Henderson  return 0;
35247ebee43eSRichard Henderson}
35257ebee43eSRichard HendersonEOF
35267ebee43eSRichard Henderson  if compile_prog "" "" ; then
35277ebee43eSRichard Henderson    atomic128=yes
35287ebee43eSRichard Henderson  fi
35297ebee43eSRichard Hendersonfi
35307ebee43eSRichard Henderson
3531e6cd4bb5SRichard Hendersoncmpxchg128=no
3532e633a5c6SEric Blakeif test "$int128" = yes && test "$atomic128" = no; then
3533e6cd4bb5SRichard Henderson  cat > $TMPC << EOF
3534e6cd4bb5SRichard Hendersonint main(void)
3535e6cd4bb5SRichard Henderson{
3536e6cd4bb5SRichard Henderson  unsigned __int128 x = 0, y = 0;
3537e6cd4bb5SRichard Henderson  __sync_val_compare_and_swap_16(&x, y, x);
3538e6cd4bb5SRichard Henderson  return 0;
3539e6cd4bb5SRichard Henderson}
3540e6cd4bb5SRichard HendersonEOF
3541e6cd4bb5SRichard Henderson  if compile_prog "" "" ; then
3542e6cd4bb5SRichard Henderson    cmpxchg128=yes
3543e6cd4bb5SRichard Henderson  fi
3544e6cd4bb5SRichard Hendersonfi
3545e6cd4bb5SRichard Henderson
3546fd0e6053SJohn Snow########################################
3547fd0e6053SJohn Snow# check if ccache is interfering with
3548fd0e6053SJohn Snow# semantic analysis of macros
3549fd0e6053SJohn Snow
35505e4dfd3dSJohn Snowunset CCACHE_CPP2
3551fd0e6053SJohn Snowccache_cpp2=no
3552fd0e6053SJohn Snowcat > $TMPC << EOF
3553fd0e6053SJohn Snowstatic const int Z = 1;
3554fd0e6053SJohn Snow#define fn() ({ Z; })
3555fd0e6053SJohn Snow#define TAUT(X) ((X) == Z)
3556fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y)
3557fd0e6053SJohn Snow#define ID(X) (X)
3558fd0e6053SJohn Snowint main(int argc, char *argv[])
3559fd0e6053SJohn Snow{
3560fd0e6053SJohn Snow    int x = 0, y = 0;
3561fd0e6053SJohn Snow    x = ID(x);
3562fd0e6053SJohn Snow    x = fn();
3563fd0e6053SJohn Snow    fn();
3564fd0e6053SJohn Snow    if (PAREN(x, y)) return 0;
3565fd0e6053SJohn Snow    if (TAUT(Z)) return 0;
3566fd0e6053SJohn Snow    return 0;
3567fd0e6053SJohn Snow}
3568fd0e6053SJohn SnowEOF
3569fd0e6053SJohn Snow
3570fd0e6053SJohn Snowif ! compile_object "-Werror"; then
3571fd0e6053SJohn Snow    ccache_cpp2=yes
3572fd0e6053SJohn Snowfi
3573fd0e6053SJohn Snow
3574b553a042SJohn Snow#################################################
3575b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE.
3576b553a042SJohn Snow
3577b553a042SJohn Snowif test "$fortify_source" != "no"; then
3578b553a042SJohn Snow  if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
3579b553a042SJohn Snow    fortify_source="no";
3580e189091fSPeter Maydell  elif test -n "$cxx" && has $cxx &&
3581cfcc7c14SJohn Snow       echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
3582b553a042SJohn Snow    fortify_source="no";
3583b553a042SJohn Snow  else
3584b553a042SJohn Snow    fortify_source="yes"
3585b553a042SJohn Snow  fi
3586b553a042SJohn Snowfi
3587b553a042SJohn Snow
3588d2042378SAneesh Kumar K.V##########################################
3589a40161cbSPaolo Bonzini# check for usable membarrier system call
3590a40161cbSPaolo Bonziniif test "$membarrier" = "yes"; then
3591a40161cbSPaolo Bonzini    have_membarrier=no
3592a40161cbSPaolo Bonzini    if test "$mingw32" = "yes" ; then
3593a40161cbSPaolo Bonzini        have_membarrier=yes
3594a40161cbSPaolo Bonzini    elif test "$linux" = "yes" ; then
3595a40161cbSPaolo Bonzini        cat > $TMPC << EOF
3596a40161cbSPaolo Bonzini    #include <linux/membarrier.h>
3597a40161cbSPaolo Bonzini    #include <sys/syscall.h>
3598a40161cbSPaolo Bonzini    #include <unistd.h>
3599a40161cbSPaolo Bonzini    #include <stdlib.h>
3600a40161cbSPaolo Bonzini    int main(void) {
3601a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
3602a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0);
3603a40161cbSPaolo Bonzini	exit(0);
3604a40161cbSPaolo Bonzini    }
3605a40161cbSPaolo BonziniEOF
3606a40161cbSPaolo Bonzini        if compile_prog "" "" ; then
3607a40161cbSPaolo Bonzini            have_membarrier=yes
3608a40161cbSPaolo Bonzini        fi
3609a40161cbSPaolo Bonzini    fi
3610a40161cbSPaolo Bonzini    if test "$have_membarrier" = "no"; then
3611a40161cbSPaolo Bonzini      feature_not_found "membarrier" "membarrier system call not available"
3612a40161cbSPaolo Bonzini    fi
3613a40161cbSPaolo Bonzinielse
3614a40161cbSPaolo Bonzini    # Do not enable it by default even for Mingw32, because it doesn't
3615a40161cbSPaolo Bonzini    # work on Wine.
3616a40161cbSPaolo Bonzini    membarrier=no
3617a40161cbSPaolo Bonzinifi
3618a40161cbSPaolo Bonzini
3619a40161cbSPaolo Bonzini##########################################
3620f0d92b56SLongpeng(Mike)# check for usable AF_ALG environment
36214f67366eSThomas Huthhave_afalg=no
3622f0d92b56SLongpeng(Mike)cat > $TMPC << EOF
3623f0d92b56SLongpeng(Mike)#include <errno.h>
3624f0d92b56SLongpeng(Mike)#include <sys/types.h>
3625f0d92b56SLongpeng(Mike)#include <sys/socket.h>
3626f0d92b56SLongpeng(Mike)#include <linux/if_alg.h>
3627f0d92b56SLongpeng(Mike)int main(void) {
3628f0d92b56SLongpeng(Mike)    int sock;
3629f0d92b56SLongpeng(Mike)    sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
3630f0d92b56SLongpeng(Mike)    return sock;
3631f0d92b56SLongpeng(Mike)}
3632f0d92b56SLongpeng(Mike)EOF
3633f0d92b56SLongpeng(Mike)if compile_prog "" "" ; then
3634f0d92b56SLongpeng(Mike)    have_afalg=yes
3635f0d92b56SLongpeng(Mike)fi
3636f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes"
3637f0d92b56SLongpeng(Mike)then
3638f0d92b56SLongpeng(Mike)    if test "$have_afalg" != "yes"
3639f0d92b56SLongpeng(Mike)    then
3640f0d92b56SLongpeng(Mike)	error_exit "AF_ALG requested but could not be detected"
3641f0d92b56SLongpeng(Mike)    fi
3642f0d92b56SLongpeng(Mike)fi
3643f0d92b56SLongpeng(Mike)
3644f0d92b56SLongpeng(Mike)
3645db1ed1abSRichard Henderson##########################################
3646247724cbSMarc-André Lureau# checks for sanitizers
3647247724cbSMarc-André Lureau
3648247724cbSMarc-André Lureauhave_asan=no
3649247724cbSMarc-André Lureauhave_ubsan=no
3650d83414e1SMarc-André Lureauhave_asan_iface_h=no
3651d83414e1SMarc-André Lureauhave_asan_iface_fiber=no
3652247724cbSMarc-André Lureau
3653247724cbSMarc-André Lureauif test "$sanitizers" = "yes" ; then
3654b9f44da2SMarc-André Lureau  write_c_skeleton
3655247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
3656247724cbSMarc-André Lureau      have_asan=yes
3657247724cbSMarc-André Lureau  fi
3658b9f44da2SMarc-André Lureau
3659b9f44da2SMarc-André Lureau  # we could use a simple skeleton for flags checks, but this also
3660b9f44da2SMarc-André Lureau  # detect the static linking issue of ubsan, see also:
3661b9f44da2SMarc-André Lureau  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
3662b9f44da2SMarc-André Lureau  cat > $TMPC << EOF
3663b9f44da2SMarc-André Lureau#include <stdlib.h>
3664b9f44da2SMarc-André Lureauint main(void) {
3665b9f44da2SMarc-André Lureau    void *tmp = malloc(10);
3666f2dfe54cSLeonid Bloch    if (tmp != NULL) {
3667b9f44da2SMarc-André Lureau        return *(int *)(tmp + 2);
3668b9f44da2SMarc-André Lureau    }
3669d1abf3fcSOlaf Hering    return 1;
3670f2dfe54cSLeonid Bloch}
3671b9f44da2SMarc-André LureauEOF
3672247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
3673247724cbSMarc-André Lureau      have_ubsan=yes
3674247724cbSMarc-André Lureau  fi
3675d83414e1SMarc-André Lureau
3676d83414e1SMarc-André Lureau  if check_include "sanitizer/asan_interface.h" ; then
3677d83414e1SMarc-André Lureau      have_asan_iface_h=yes
3678d83414e1SMarc-André Lureau  fi
3679d83414e1SMarc-André Lureau
3680d83414e1SMarc-André Lureau  cat > $TMPC << EOF
3681d83414e1SMarc-André Lureau#include <sanitizer/asan_interface.h>
3682d83414e1SMarc-André Lureauint main(void) {
3683d83414e1SMarc-André Lureau  __sanitizer_start_switch_fiber(0, 0, 0);
3684d83414e1SMarc-André Lureau  return 0;
3685d83414e1SMarc-André Lureau}
3686d83414e1SMarc-André LureauEOF
3687d83414e1SMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
3688d83414e1SMarc-André Lureau      have_asan_iface_fiber=yes
3689d83414e1SMarc-André Lureau  fi
3690247724cbSMarc-André Lureaufi
3691247724cbSMarc-André Lureau
36920aebab04SLingfeng Yang# Thread sanitizer is, for now, much noisier than the other sanitizers;
36930aebab04SLingfeng Yang# keep it separate until that is not the case.
36940aebab04SLingfeng Yangif test "$tsan" = "yes" && test "$sanitizers" = "yes"; then
36950aebab04SLingfeng Yang  error_exit "TSAN is not supported with other sanitiziers."
36960aebab04SLingfeng Yangfi
36970aebab04SLingfeng Yanghave_tsan=no
36980aebab04SLingfeng Yanghave_tsan_iface_fiber=no
36990aebab04SLingfeng Yangif test "$tsan" = "yes" ; then
37000aebab04SLingfeng Yang  write_c_skeleton
37010aebab04SLingfeng Yang  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
37020aebab04SLingfeng Yang      have_tsan=yes
37030aebab04SLingfeng Yang  fi
37040aebab04SLingfeng Yang  cat > $TMPC << EOF
37050aebab04SLingfeng Yang#include <sanitizer/tsan_interface.h>
37060aebab04SLingfeng Yangint main(void) {
37070aebab04SLingfeng Yang  __tsan_create_fiber(0);
37080aebab04SLingfeng Yang  return 0;
37090aebab04SLingfeng Yang}
37100aebab04SLingfeng YangEOF
37110aebab04SLingfeng Yang  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
37120aebab04SLingfeng Yang      have_tsan_iface_fiber=yes
37130aebab04SLingfeng Yang  fi
37140aebab04SLingfeng Yangfi
37150aebab04SLingfeng Yang
3716adc28027SAlexander Bulekov##########################################
3717675b9b53SMarc-André Lureau# check for slirp
3718675b9b53SMarc-André Lureau
3719675b9b53SMarc-André Lureaucase "$slirp" in
37204d34a86bSPaolo Bonzini  auto | enabled | internal)
37214d34a86bSPaolo Bonzini    # Simpler to always update submodule, even if not needed.
37227c57bdd8SMarc-André Lureau    git_submodules="${git_submodules} slirp"
3723675b9b53SMarc-André Lureau    ;;
3724675b9b53SMarc-André Lureauesac
3725675b9b53SMarc-André Lureau
3726b8e0c493SJoelle van Dyne# Check for slirp smbd dupport
3727b8e0c493SJoelle van Dyne: ${smbd=${SMBD-/usr/sbin/smbd}}
3728b8e0c493SJoelle van Dyneif test "$slirp_smbd" != "no" ; then
3729b8e0c493SJoelle van Dyne  if test "$mingw32" = "yes" ; then
3730b8e0c493SJoelle van Dyne    if test "$slirp_smbd" = "yes" ; then
3731b8e0c493SJoelle van Dyne      error_exit "Host smbd not supported on this platform."
3732b8e0c493SJoelle van Dyne    fi
3733b8e0c493SJoelle van Dyne    slirp_smbd=no
3734b8e0c493SJoelle van Dyne  else
3735b8e0c493SJoelle van Dyne    slirp_smbd=yes
3736b8e0c493SJoelle van Dyne  fi
3737b8e0c493SJoelle van Dynefi
3738b8e0c493SJoelle van Dyne
373954e7aac0SAlexey Krasikov##########################################
374054e7aac0SAlexey Krasikov# check for usable __NR_keyctl syscall
374154e7aac0SAlexey Krasikov
374254e7aac0SAlexey Krasikovif test "$linux" = "yes" ; then
374354e7aac0SAlexey Krasikov
374454e7aac0SAlexey Krasikov    have_keyring=no
374554e7aac0SAlexey Krasikov    cat > $TMPC << EOF
374654e7aac0SAlexey Krasikov#include <errno.h>
374754e7aac0SAlexey Krasikov#include <asm/unistd.h>
374854e7aac0SAlexey Krasikov#include <linux/keyctl.h>
374954e7aac0SAlexey Krasikov#include <unistd.h>
375054e7aac0SAlexey Krasikovint main(void) {
375154e7aac0SAlexey Krasikov    return syscall(__NR_keyctl, KEYCTL_READ, 0, NULL, NULL, 0);
375254e7aac0SAlexey Krasikov}
375354e7aac0SAlexey KrasikovEOF
375454e7aac0SAlexey Krasikov    if compile_prog "" "" ; then
375554e7aac0SAlexey Krasikov        have_keyring=yes
375654e7aac0SAlexey Krasikov    fi
375754e7aac0SAlexey Krasikovfi
375854e7aac0SAlexey Krasikovif test "$secret_keyring" != "no"
375954e7aac0SAlexey Krasikovthen
3760b418d265SDavid Edmondson    if test "$have_keyring" = "yes"
376154e7aac0SAlexey Krasikov    then
376254e7aac0SAlexey Krasikov	secret_keyring=yes
376354e7aac0SAlexey Krasikov    else
376454e7aac0SAlexey Krasikov	if test "$secret_keyring" = "yes"
376554e7aac0SAlexey Krasikov	then
376654e7aac0SAlexey Krasikov	    error_exit "syscall __NR_keyctl requested, \
376754e7aac0SAlexey Krasikovbut not implemented on your system"
376854e7aac0SAlexey Krasikov	else
376954e7aac0SAlexey Krasikov	    secret_keyring=no
377054e7aac0SAlexey Krasikov	fi
377154e7aac0SAlexey Krasikov    fi
377254e7aac0SAlexey Krasikovfi
377354e7aac0SAlexey Krasikov
377492500362SAlexey Krasikov##########################################
3775e86ecd4bSJuan Quintela# End of CC checks
3776e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
3777e86ecd4bSJuan Quintela
3778d83414e1SMarc-André Lureauwrite_c_skeleton
3779d83414e1SMarc-André Lureau
37801d728c39SBlue Swirlif test "$gcov" = "yes" ; then
3781bf0e56a3SMarc-André Lureau  :
3782b553a042SJohn Snowelif test "$fortify_source" = "yes" ; then
3783086d5f75SPaolo Bonzini  QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
3784086d5f75SPaolo Bonzini  debug=no
3785086d5f75SPaolo Bonzinifi
3786086d5f75SPaolo Bonzini
3787086d5f75SPaolo Bonzinicase "$ARCH" in
3788086d5f75SPaolo Bonzinialpha)
3789086d5f75SPaolo Bonzini  # Ensure there's only a single GP
3790086d5f75SPaolo Bonzini  QEMU_CFLAGS="-msmall-data $QEMU_CFLAGS"
3791086d5f75SPaolo Bonzini;;
3792086d5f75SPaolo Bonziniesac
3793086d5f75SPaolo Bonzini
3794086d5f75SPaolo Bonziniif test "$gprof" = "yes" ; then
3795086d5f75SPaolo Bonzini  QEMU_CFLAGS="-p $QEMU_CFLAGS"
3796086d5f75SPaolo Bonzini  QEMU_LDFLAGS="-p $QEMU_LDFLAGS"
3797086d5f75SPaolo Bonzinifi
3798a316e378SJuan Quintela
3799247724cbSMarc-André Lureauif test "$have_asan" = "yes"; then
3800db5adeaaSPaolo Bonzini  QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS"
3801db5adeaaSPaolo Bonzini  QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS"
3802d83414e1SMarc-André Lureau  if test "$have_asan_iface_h" = "no" ; then
3803d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header missing." \
3804d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
3805d83414e1SMarc-André Lureau  elif test "$have_asan_iface_fiber" = "no" ; then
3806d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header is too old." \
3807d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
3808d83414e1SMarc-André Lureau  fi
3809247724cbSMarc-André Lureaufi
38100aebab04SLingfeng Yangif test "$have_tsan" = "yes" ; then
38110aebab04SLingfeng Yang  if test "$have_tsan_iface_fiber" = "yes" ; then
38120aebab04SLingfeng Yang    QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS"
38130aebab04SLingfeng Yang    QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS"
38140aebab04SLingfeng Yang  else
38150aebab04SLingfeng Yang    error_exit "Cannot enable TSAN due to missing fiber annotation interface."
38160aebab04SLingfeng Yang  fi
38170aebab04SLingfeng Yangelif test "$tsan" = "yes" ; then
38180aebab04SLingfeng Yang  error_exit "Cannot enable TSAN due to missing sanitize thread interface."
38190aebab04SLingfeng Yangfi
3820247724cbSMarc-André Lureauif test "$have_ubsan" = "yes"; then
3821db5adeaaSPaolo Bonzini  QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS"
3822db5adeaaSPaolo Bonzini  QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS"
3823247724cbSMarc-André Lureaufi
3824247724cbSMarc-André Lureau
38256542aa9cSPeter Lieven##########################################
38263efac6ebSTomáš Golembiovský
38270aebab04SLingfeng Yang# Exclude --warn-common with TSan to suppress warnings from the TSan libraries.
38280aebab04SLingfeng Yangif test "$solaris" = "no" && test "$tsan" = "no"; then
3829e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
3830db5adeaaSPaolo Bonzini        QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS"
3831e86ecd4bSJuan Quintela    fi
3832e86ecd4bSJuan Quintelafi
3833e86ecd4bSJuan Quintela
3834952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
3835952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
3836cb8baa77SMark Cave-Ayland    flags="--no-seh --nxcompat"
3837cb8baa77SMark Cave-Ayland
3838cb8baa77SMark Cave-Ayland    # Disable ASLR for debug builds to allow debugging with gdb
3839cb8baa77SMark Cave-Ayland    if test "$debug" = "no" ; then
3840cb8baa77SMark Cave-Ayland        flags="--dynamicbase $flags"
3841cb8baa77SMark Cave-Ayland    fi
3842cb8baa77SMark Cave-Ayland
3843cb8baa77SMark Cave-Ayland    for flag in $flags; do
3844e9a3591fSChristian Borntraeger        if ld_has $flag ; then
3845db5adeaaSPaolo Bonzini            QEMU_LDFLAGS="-Wl,$flag $QEMU_LDFLAGS"
3846952afb71SBlue Swirl        fi
3847952afb71SBlue Swirl    done
3848952afb71SBlue Swirlfi
3849952afb71SBlue Swirl
38509d6bc27bSMichael Roth# Probe for guest agent support/options
38519d6bc27bSMichael Roth
3852e8ef31a3SMichael Tokarevif [ "$guest_agent" != "no" ]; then
3853a5125905SLaurent Vivier  if [ "$softmmu" = no -a "$want_tools" = no ] ; then
3854a5125905SLaurent Vivier      guest_agent=no
3855a5125905SLaurent Vivier  elif [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
3856e8ef31a3SMichael Tokarev      guest_agent=yes
3857e8ef31a3SMichael Tokarev  elif [ "$guest_agent" != yes ]; then
3858e8ef31a3SMichael Tokarev      guest_agent=no
3859e8ef31a3SMichael Tokarev  else
3860e8ef31a3SMichael Tokarev      error_exit "Guest agent is not supported on this platform"
3861ca35f780SPaolo Bonzini  fi
38624b1c11fdSDaniel P. Berrangefi
3863ca35f780SPaolo Bonzini
3864b846ab7cSPaolo Bonzini# Guest agent Windows MSI package
38659d6bc27bSMichael Roth
38669d6bc27bSMichael Rothif test "$QEMU_GA_MANUFACTURER" = ""; then
38679d6bc27bSMichael Roth  QEMU_GA_MANUFACTURER=QEMU
38689d6bc27bSMichael Rothfi
38699d6bc27bSMichael Rothif test "$QEMU_GA_DISTRO" = ""; then
38709d6bc27bSMichael Roth  QEMU_GA_DISTRO=Linux
38719d6bc27bSMichael Rothfi
38729d6bc27bSMichael Rothif test "$QEMU_GA_VERSION" = ""; then
387389138857SStefan Weil    QEMU_GA_VERSION=$(cat $source_path/VERSION)
38749d6bc27bSMichael Rothfi
38759d6bc27bSMichael Roth
3876b846ab7cSPaolo BonziniQEMU_GA_MSI_MINGW_DLL_PATH="$($pkg_config --variable=prefix glib-2.0)/bin"
38779d6bc27bSMichael Roth
3878ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
3879ca35f780SPaolo Bonziniroms=
3880e633a5c6SEric Blakeif { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \
3881e633a5c6SEric Blake        test "$targetos" != "Darwin" && test "$targetos" != "SunOS" && \
38827000a12eSThomas Huth        test "$targetos" != "Haiku" && test "$softmmu" = yes ; then
3883e57218b6SPeter Maydell    # Different host OS linkers have different ideas about the name of the ELF
3884c65d5e4eSBrad Smith    # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
3885c65d5e4eSBrad Smith    # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
3886c65d5e4eSBrad Smith    for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
3887e57218b6SPeter Maydell        if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
3888e57218b6SPeter Maydell            ld_i386_emulation="$emu"
3889ca35f780SPaolo Bonzini            roms="optionrom"
3890e57218b6SPeter Maydell            break
3891e57218b6SPeter Maydell        fi
3892e57218b6SPeter Maydell    done
3893ca35f780SPaolo Bonzinifi
3894ca35f780SPaolo Bonzini
38952e33c3f8SThomas Huth# Only build s390-ccw bios if we're on s390x and the compiler has -march=z900
3896a5b2afd5SThomas Huth# or -march=z10 (which is the lowest architecture level that Clang supports)
38979933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then
38982e33c3f8SThomas Huth  write_c_skeleton
3899a5b2afd5SThomas Huth  compile_prog "-march=z900" ""
3900a5b2afd5SThomas Huth  has_z900=$?
39013af448b3SThomas Huth  if [ $has_z900 = 0 ] || compile_object "-march=z10 -msoft-float -Werror"; then
3902a5b2afd5SThomas Huth    if [ $has_z900 != 0 ]; then
3903a5b2afd5SThomas Huth      echo "WARNING: Your compiler does not support the z900!"
3904a5b2afd5SThomas Huth      echo "         The s390-ccw bios will only work with guest CPUs >= z10."
3905a5b2afd5SThomas Huth    fi
39069933c305SChristian Borntraeger    roms="$roms s390-ccw"
39071ef6bfc2SPhilippe Mathieu-Daudé    # SLOF is required for building the s390-ccw firmware on s390x,
39081ef6bfc2SPhilippe Mathieu-Daudé    # since it is using the libnet code from SLOF for network booting.
39091ef6bfc2SPhilippe Mathieu-Daudé    git_submodules="${git_submodules} roms/SLOF"
39101ef6bfc2SPhilippe Mathieu-Daudé  fi
39119933c305SChristian Borntraegerfi
39129933c305SChristian Borntraeger
391311cde1c8SBruno Dominguez# Check that the C++ compiler exists and works with the C compiler.
391411cde1c8SBruno 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.
391511cde1c8SBruno Dominguezif has $cxx; then
391611cde1c8SBruno Dominguez    cat > $TMPC <<EOF
391711cde1c8SBruno Dominguezint c_function(void);
391811cde1c8SBruno Dominguezint main(void) { return c_function(); }
391911cde1c8SBruno DominguezEOF
392011cde1c8SBruno Dominguez
392111cde1c8SBruno Dominguez    compile_object
392211cde1c8SBruno Dominguez
392311cde1c8SBruno Dominguez    cat > $TMPCXX <<EOF
392411cde1c8SBruno Dominguezextern "C" {
392511cde1c8SBruno Dominguez   int c_function(void);
392611cde1c8SBruno Dominguez}
392711cde1c8SBruno Dominguezint c_function(void) { return 42; }
392811cde1c8SBruno DominguezEOF
392911cde1c8SBruno Dominguez
393011cde1c8SBruno Dominguez    update_cxxflags
393111cde1c8SBruno Dominguez
39325770e8afSPaolo Bonzini    if do_cxx $CXXFLAGS $CONFIGURE_CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then
393311cde1c8SBruno Dominguez        # C++ compiler $cxx works ok with C compiler $cc
393411cde1c8SBruno Dominguez        :
393511cde1c8SBruno Dominguez    else
393611cde1c8SBruno Dominguez        echo "C++ compiler $cxx does not work with C compiler $cc"
393711cde1c8SBruno Dominguez        echo "Disabling C++ specific optional code"
393811cde1c8SBruno Dominguez        cxx=
393911cde1c8SBruno Dominguez    fi
394011cde1c8SBruno Dominguezelse
394111cde1c8SBruno Dominguez    echo "No C++ compiler available; disabling C++ specific optional code"
394211cde1c8SBruno Dominguez    cxx=
394311cde1c8SBruno Dominguezfi
394411cde1c8SBruno Dominguez
39457d7dbf9dSDan Streetmanif !(GIT="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then
39467d7dbf9dSDan Streetman    exit 1
39475d91a2edSYonggang Luofi
39485d91a2edSYonggang Luo
394998ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
395097a847bcSbellard
395198ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
395298ec69acSJuan Quintelaecho >> $config_host_mak
395398ec69acSJuan Quintela
3954e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
3955cc84d63aSDaniel P. Berrangeecho "GIT=$git" >> $config_host_mak
3956aef45d51SDaniel P. Berrangeecho "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
39577d7dbf9dSDan Streetmanecho "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak
3958804edf29SJuan Quintela
395998ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
3960727e5283SPaolo Bonzini
3961f8393946Saurel32if test "$debug_tcg" = "yes" ; then
39622358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
3963f8393946Saurel32fi
39641625af87Saliguoriif test "$strip_opt" = "yes" ; then
396552ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
39661625af87Saliguorifi
396767b915a5Sbellardif test "$mingw32" = "yes" ; then
396898ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
3969d9840e25STomoki Sekiyama  if test "$guest_agent_with_vss" = "yes" ; then
3970d9840e25STomoki Sekiyama    echo "CONFIG_QGA_VSS=y" >> $config_host_mak
3971f33ca81fSMichael Roth    echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
3972d9840e25STomoki Sekiyama    echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
3973d9840e25STomoki Sekiyama  fi
397450cbebb9SMichael Roth  if test "$guest_agent_ntddscsi" = "yes" ; then
397576dc75caSTomáš Golembiovský    echo "CONFIG_QGA_NTDDSCSI=y" >> $config_host_mak
397650cbebb9SMichael Roth  fi
39779dacf32dSYossi Hindin  echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
39789dacf32dSYossi Hindin  echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
39799dacf32dSYossi Hindin  echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
39809dacf32dSYossi Hindin  echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
3981210fa556Spbrookelse
398235f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
3983210fa556Spbrookfi
3984128ab2ffSblueswir1
3985dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
3986dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
3987dffcb71cSMark McLoughlinfi
3988dffcb71cSMark McLoughlin
398983fb7adfSbellardif test "$darwin" = "yes" ; then
399098ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
399183fb7adfSbellardfi
3992b29fe3edSmalc
3993ec530c81Sbellardif test "$solaris" = "yes" ; then
399498ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
3995ec530c81Sbellardfi
3996179cf400SAndreas Färberif test "$haiku" = "yes" ; then
3997179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
3998179cf400SAndreas Färberfi
399997a847bcSbellardif test "$static" = "yes" ; then
400098ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
400197a847bcSbellardfi
40021ba16968SStefan Weilif test "$profiler" = "yes" ; then
40032358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
400405c2a3e7Sbellardfi
4005c932ce31SPaolo Bonziniif test "$want_tools" = "yes" ; then
4006c932ce31SPaolo Bonzini  echo "CONFIG_TOOLS=y" >> $config_host_mak
4007c932ce31SPaolo Bonzinifi
4008f15bff25SPaolo Bonziniif test "$guest_agent" = "yes" ; then
4009f15bff25SPaolo Bonzini  echo "CONFIG_GUEST_AGENT=y" >> $config_host_mak
4010f15bff25SPaolo Bonzinifi
4011b8e0c493SJoelle van Dyneif test "$slirp_smbd" = "yes" ; then
4012b8e0c493SJoelle van Dyne  echo "CONFIG_SLIRP_SMBD=y" >> $config_host_mak
4013e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
4014b8e0c493SJoelle van Dynefi
4015015a33bdSGongleiif test "$l2tpv3" = "yes" ; then
4016015a33bdSGonglei  echo "CONFIG_L2TPV3=y" >> $config_host_mak
4017015a33bdSGongleifi
40184cc600d2SPaolo Bonziniif test "$gprof" = "yes" ; then
40194cc600d2SPaolo Bonzini  echo "CONFIG_GPROF=y" >> $config_host_mak
40204cc600d2SPaolo Bonzinifi
4021b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
4022b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
4023e5f05f8cSKevin Wolfif test "$block_drv_whitelist_tools" = "yes" ; then
4024e5f05f8cSKevin Wolf  echo "CONFIG_BDRV_WHITELIST_TOOLS=y" >> $config_host_mak
4025e5f05f8cSKevin Wolffi
4026dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
4027dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
4028dce512deSChristoph Hellwigfi
402989138857SStefan Weilqemu_version=$(head $source_path/VERSION)
40302358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
403198ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
40322b1f35b9SAlex Bennéeecho "TARGET_DIRS=$target_list" >> $config_host_mak
403317969268SFam Zhengif test "$modules" = "yes"; then
4034e26110cfSFam Zheng  # $shacmd can generate a hash started with digit, which the compiler doesn't
4035e26110cfSFam Zheng  # like as an symbol. So prefix it with an underscore
403689138857SStefan Weil  echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
403717969268SFam Zheng  echo "CONFIG_MODULES=y" >> $config_host_mak
403817969268SFam Zhengfi
4039bd83c861SChristian Ehrhardtif test "$module_upgrades" = "yes"; then
4040bd83c861SChristian Ehrhardt  echo "CONFIG_MODULE_UPGRADES=y" >> $config_host_mak
4041bd83c861SChristian Ehrhardtfi
4042955727d2SCortland Tölvaif test "$have_usbfs" = "yes" ; then
4043955727d2SCortland Tölva  echo "CONFIG_USBFS=y" >> $config_host_mak
4044955727d2SCortland Tölvafi
4045f876b765SMarc-André Lureauif test "$gio" = "yes" ; then
4046f876b765SMarc-André Lureau    echo "CONFIG_GIO=y" >> $config_host_mak
4047f876b765SMarc-André Lureau    echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak
4048f876b765SMarc-André Lureau    echo "GIO_LIBS=$gio_libs" >> $config_host_mak
40495ecfb76cSPaolo Bonzinifi
40505ecfb76cSPaolo Bonziniif test "$gdbus_codegen" != "" ; then
405125a97a56SMarc-André Lureau    echo "GDBUS_CODEGEN=$gdbus_codegen" >> $config_host_mak
4052f876b765SMarc-André Lureaufi
4053a1c5e949SDaniel P. Berrangeecho "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
4054277abf15SJan Vesely
40551badb709SPaolo Bonziniif test "$xen" = "enabled" ; then
40566dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
4057d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
4058582ea95fSMarc-André Lureau  echo "XEN_CFLAGS=$xen_cflags" >> $config_host_mak
4059582ea95fSMarc-André Lureau  echo "XEN_LIBS=$xen_libs" >> $config_host_mak
4060e37630caSaliguorifi
40615e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then
40625e9be92dSNicholas Bellinger  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
40635e9be92dSNicholas Bellingerfi
4064af3bba76SPaolo Bonziniif test "$vhost_net" = "yes" ; then
4065af3bba76SPaolo Bonzini  echo "CONFIG_VHOST_NET=y" >> $config_host_mak
4066af3bba76SPaolo Bonzinifi
4067af3bba76SPaolo Bonziniif test "$vhost_net_user" = "yes" ; then
406856f41de7SPaolo Bonzini  echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak
406903ce5744SNikolay Nikolaevfi
4070108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" ; then
4071108a6481SCindy Lu  echo "CONFIG_VHOST_NET_VDPA=y" >> $config_host_mak
4072108a6481SCindy Lufi
4073042cea27SGongleiif test "$vhost_crypto" = "yes" ; then
4074042cea27SGonglei  echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
4075042cea27SGongleifi
4076fc0b9b0eSStefan Hajnocziif test "$vhost_vsock" = "yes" ; then
4077fc0b9b0eSStefan Hajnoczi  echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
40785fe97d88SStefano Garzarella  if test "$vhost_user" = "yes" ; then
40795fe97d88SStefano Garzarella    echo "CONFIG_VHOST_USER_VSOCK=y" >> $config_host_mak
40805fe97d88SStefano Garzarella  fi
4081fc0b9b0eSStefan Hajnoczifi
4082299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" ; then
4083299e6f19SPaolo Bonzini  echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak
4084299e6f19SPaolo Bonzinifi
4085e6a74868SMarc-André Lureauif test "$vhost_user" = "yes" ; then
4086e6a74868SMarc-André Lureau  echo "CONFIG_VHOST_USER=y" >> $config_host_mak
4087e6a74868SMarc-André Lureaufi
4088108a6481SCindy Luif test "$vhost_vdpa" = "yes" ; then
4089108a6481SCindy Lu  echo "CONFIG_VHOST_VDPA=y" >> $config_host_mak
4090108a6481SCindy Lufi
409198fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" ; then
409298fc1adaSDr. David Alan Gilbert  echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak
409398fc1adaSDr. David Alan Gilbertfi
4094a40161cbSPaolo Bonziniif test "$membarrier" = "yes" ; then
4095a40161cbSPaolo Bonzini  echo "CONFIG_MEMBARRIER=y" >> $config_host_mak
4096a40161cbSPaolo Bonzinifi
4097e5b46549SRichard Hendersonif test "$tcg" = "enabled" -a "$tcg_interpreter" = "true" ; then
4098e5b46549SRichard Henderson  echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
4099e5b46549SRichard Hendersonfi
410058d3f3ffSGerd Hoffmann
4101da076ffeSGerd Hoffmannif test "$opengl" = "yes" ; then
4102da076ffeSGerd Hoffmann  echo "CONFIG_OPENGL=y" >> $config_host_mak
4103de2d3005SPaolo Bonzini  echo "OPENGL_CFLAGS=$opengl_cflags" >> $config_host_mak
4104da076ffeSGerd Hoffmann  echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
410520ff075bSMichael Wallefi
410620ff075bSMichael Walle
410799f2dbd3SLiang Liif test "$avx2_opt" = "yes" ; then
410899f2dbd3SLiang Li  echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
410999f2dbd3SLiang Lifi
411099f2dbd3SLiang Li
41116b8cd447SRobert Hooif test "$avx512f_opt" = "yes" ; then
41126b8cd447SRobert Hoo  echo "CONFIG_AVX512F_OPT=y" >> $config_host_mak
41136b8cd447SRobert Hoofi
41146b8cd447SRobert Hoo
411583fb7adfSbellard# XXX: suppress that
41167d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
41172358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
41187d3505c5Sbellardfi
41197d3505c5Sbellard
41203556c233SPaolo Bonziniif test "$qom_cast_debug" = "yes" ; then
41213556c233SPaolo Bonzini  echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
41223556c233SPaolo Bonzinifi
412320ff6c80SAnthony Liguori
41247c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
412570c60c08SStefan Hajnocziif test "$coroutine_pool" = "yes" ; then
412670c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
412770c60c08SStefan Hajnoczielse
412870c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
412970c60c08SStefan Hajnoczifi
4130d0e2fce5SAneesh Kumar K.V
41317d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes" ; then
41327d992e4dSPeter Lieven  echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
41337d992e4dSPeter Lievenfi
41347d992e4dSPeter Lieven
4135f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes" ; then
4136f0d92b56SLongpeng(Mike)  echo "CONFIG_AF_ALG=y" >> $config_host_mak
4137f0d92b56SLongpeng(Mike)fi
4138f0d92b56SLongpeng(Mike)
4139d83414e1SMarc-André Lureauif test "$have_asan_iface_fiber" = "yes" ; then
4140d83414e1SMarc-André Lureau    echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
4141d83414e1SMarc-André Lureaufi
4142d83414e1SMarc-André Lureau
41430aebab04SLingfeng Yangif test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then
41440aebab04SLingfeng Yang    echo "CONFIG_TSAN=y" >> $config_host_mak
41450aebab04SLingfeng Yangfi
41460aebab04SLingfeng Yang
414776a347e1SRichard Hendersonif test "$cpuid_h" = "yes" ; then
414876a347e1SRichard Henderson  echo "CONFIG_CPUID_H=y" >> $config_host_mak
414976a347e1SRichard Hendersonfi
415076a347e1SRichard Henderson
4151f540166bSRichard Hendersonif test "$int128" = "yes" ; then
4152f540166bSRichard Henderson  echo "CONFIG_INT128=y" >> $config_host_mak
4153f540166bSRichard Hendersonfi
4154f540166bSRichard Henderson
41557ebee43eSRichard Hendersonif test "$atomic128" = "yes" ; then
41567ebee43eSRichard Henderson  echo "CONFIG_ATOMIC128=y" >> $config_host_mak
41577ebee43eSRichard Hendersonfi
41587ebee43eSRichard Henderson
4159e6cd4bb5SRichard Hendersonif test "$cmpxchg128" = "yes" ; then
4160e6cd4bb5SRichard Henderson  echo "CONFIG_CMPXCHG128=y" >> $config_host_mak
4161e6cd4bb5SRichard Hendersonfi
4162e6cd4bb5SRichard Henderson
4163b10d49d7SPino Toscanoif test "$libssh" = "yes" ; then
4164484e2cc7SPaolo Bonzini  echo "CONFIG_LIBSSH=y" >> $config_host_mak
4165b10d49d7SPino Toscano  echo "LIBSSH_CFLAGS=$libssh_cflags" >> $config_host_mak
4166b10d49d7SPino Toscano  echo "LIBSSH_LIBS=$libssh_libs" >> $config_host_mak
41670a12ec87SRichard W.M. Jonesfi
41680a12ec87SRichard W.M. Jones
4169ed1701c6SDr. David Alan Gilbertif test "$live_block_migration" = "yes" ; then
4170ed1701c6SDr. David Alan Gilbert  echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
4171ed1701c6SDr. David Alan Gilbertfi
4172ed1701c6SDr. David Alan Gilbert
41733b8acc11SPaolo Bonziniif test "$tpm" = "yes"; then
41743cae16dbSPaolo Bonzini  echo 'CONFIG_TPM=y' >> $config_host_mak
41753b8acc11SPaolo Bonzinifi
41763b8acc11SPaolo Bonzini
41772da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then
41782da776dbSMichael R. Hines  echo "CONFIG_RDMA=y" >> $config_host_mak
4179392fb643SFam Zheng  echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
41802da776dbSMichael R. Hinesfi
41812da776dbSMichael R. Hines
418221ab34c9SMarcel Apfelbaumif test "$pvrdma" = "yes" ; then
418321ab34c9SMarcel Apfelbaum  echo "CONFIG_PVRDMA=y" >> $config_host_mak
418421ab34c9SMarcel Apfelbaumfi
418521ab34c9SMarcel Apfelbaum
4186a6b1d4c0SChanglong Xieif test "$replication" = "yes" ; then
4187a6b1d4c0SChanglong Xie  echo "CONFIG_REPLICATION=y" >> $config_host_mak
4188a6b1d4c0SChanglong Xiefi
4189a6b1d4c0SChanglong Xie
4190ba59fb77SPaolo Bonziniif test "$debug_mutex" = "yes" ; then
4191ba59fb77SPaolo Bonzini  echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak
4192ba59fb77SPaolo Bonzinifi
4193e0580342SKamil Rytarowski
41942f740136SJeff Codyif test "$bochs" = "yes" ; then
41952f740136SJeff Cody  echo "CONFIG_BOCHS=y" >> $config_host_mak
41962f740136SJeff Codyfi
41972f740136SJeff Codyif test "$cloop" = "yes" ; then
41982f740136SJeff Cody  echo "CONFIG_CLOOP=y" >> $config_host_mak
41992f740136SJeff Codyfi
42002f740136SJeff Codyif test "$dmg" = "yes" ; then
42012f740136SJeff Cody  echo "CONFIG_DMG=y" >> $config_host_mak
42022f740136SJeff Codyfi
42032f740136SJeff Codyif test "$qcow1" = "yes" ; then
42042f740136SJeff Cody  echo "CONFIG_QCOW1=y" >> $config_host_mak
42052f740136SJeff Codyfi
42062f740136SJeff Codyif test "$vdi" = "yes" ; then
42072f740136SJeff Cody  echo "CONFIG_VDI=y" >> $config_host_mak
42082f740136SJeff Codyfi
42092f740136SJeff Codyif test "$vvfat" = "yes" ; then
42102f740136SJeff Cody  echo "CONFIG_VVFAT=y" >> $config_host_mak
42112f740136SJeff Codyfi
42122f740136SJeff Codyif test "$qed" = "yes" ; then
42132f740136SJeff Cody  echo "CONFIG_QED=y" >> $config_host_mak
42142f740136SJeff Codyfi
42152f740136SJeff Codyif test "$parallels" = "yes" ; then
42162f740136SJeff Cody  echo "CONFIG_PARALLELS=y" >> $config_host_mak
42172f740136SJeff Codyfi
42182f740136SJeff Cody
421940e8c6f4SAlex Bennéeif test "$plugins" = "yes" ; then
422040e8c6f4SAlex Bennée    echo "CONFIG_PLUGIN=y" >> $config_host_mak
422126fffe29SEmilio G. Cota    # Copy the export object list to the build dir
422226fffe29SEmilio G. Cota    if test "$ld_dynamic_list" = "yes" ; then
422326fffe29SEmilio G. Cota	echo "CONFIG_HAS_LD_DYNAMIC_LIST=yes" >> $config_host_mak
422426fffe29SEmilio G. Cota	ld_symbols=qemu-plugins-ld.symbols
422526fffe29SEmilio G. Cota	cp "$source_path/plugins/qemu-plugins.symbols" $ld_symbols
422626fffe29SEmilio G. Cota    elif test "$ld_exported_symbols_list" = "yes" ; then
422726fffe29SEmilio G. Cota	echo "CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST=yes" >> $config_host_mak
422826fffe29SEmilio G. Cota	ld64_symbols=qemu-plugins-ld64.symbols
422926fffe29SEmilio G. Cota	echo "# Automatically generated by configure - do not modify" > $ld64_symbols
423026fffe29SEmilio G. Cota	grep 'qemu_' "$source_path/plugins/qemu-plugins.symbols" | sed 's/;//g' | \
423126fffe29SEmilio G. Cota	    sed -E 's/^[[:space:]]*(.*)/_\1/' >> $ld64_symbols
423226fffe29SEmilio G. Cota    else
423326fffe29SEmilio G. Cota	error_exit \
423426fffe29SEmilio G. Cota	    "If \$plugins=yes, either \$ld_dynamic_list or " \
423526fffe29SEmilio G. Cota	    "\$ld_exported_symbols_list should have been set to 'yes'."
423626fffe29SEmilio G. Cota    fi
423740e8c6f4SAlex Bennéefi
423840e8c6f4SAlex Bennée
4239f48e590aSAlex Bennéeif test -n "$gdb_bin"; then
4240b1863cccSAlex Bennée    gdb_version=$($gdb_bin --version | head -n 1)
4241d6a66c81SAlex Bennée    if version_ge ${gdb_version##* } 9.1; then
4242f48e590aSAlex Bennée        echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
4243f48e590aSAlex Bennée    fi
4244b1863cccSAlex Bennéefi
4245f48e590aSAlex Bennée
424654e7aac0SAlexey Krasikovif test "$secret_keyring" = "yes" ; then
424754e7aac0SAlexey Krasikov  echo "CONFIG_SECRET_KEYRING=y" >> $config_host_mak
424854e7aac0SAlexey Krasikovfi
424954e7aac0SAlexey Krasikov
425098ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
4251804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
4252c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
425339d87c8cSAlex Bennéeecho "GENISOIMAGE=$genisoimage" >> $config_host_mak
4254a5665051SPaolo Bonziniecho "MESON=$meson" >> $config_host_mak
425509e93326SPaolo Bonziniecho "NINJA=$ninja" >> $config_host_mak
4256804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
4257433de74cSBastian Koppelmannecho "HOST_CC=$host_cc" >> $config_host_mak
4258a31a8642SMichael S. Tsirkinif $iasl -h > /dev/null 2>&1; then
4259859aef02SPaolo Bonzini  echo "CONFIG_IASL=$iasl" >> $config_host_mak
4260a31a8642SMichael S. Tsirkinfi
4261804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
4262cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak
42635f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak
42643dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak
4265804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
4266804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
426746eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
4268a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
426911cde1c8SBruno Dominguezecho "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
4270a81df1b6SPaolo Bonziniecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
4271a81df1b6SPaolo Bonziniecho "GLIB_LIBS=$glib_libs" >> $config_host_mak
42728a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
4273e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
4274804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
4275f15bff25SPaolo Bonziniecho "LIBS_QGA=$libs_qga" >> $config_host_mak
4276804edf29SJuan Quintela
4277b767d257SMarek Marczykowski-Góreckiif test "$rng_none" = "yes"; then
4278b767d257SMarek Marczykowski-Górecki  echo "CONFIG_RNG_NONE=y" >> $config_host_mak
4279b767d257SMarek Marczykowski-Góreckifi
4280b767d257SMarek Marczykowski-Górecki
42816efd7517SPeter Maydell# use included Linux headers
42826efd7517SPeter Maydellif test "$linux" = "yes" ; then
4283a307beb6SAndreas Färber  mkdir -p linux-headers
42846efd7517SPeter Maydell  case "$cpu" in
4285c72b26ecSRichard Henderson  i386|x86_64|x32)
428608312a63SPeter Maydell    linux_arch=x86
42876efd7517SPeter Maydell    ;;
4288f8378accSRichard Henderson  ppc|ppc64|ppc64le)
428908312a63SPeter Maydell    linux_arch=powerpc
42906efd7517SPeter Maydell    ;;
42916efd7517SPeter Maydell  s390x)
429208312a63SPeter Maydell    linux_arch=s390
429308312a63SPeter Maydell    ;;
42941f080313SClaudio Fontana  aarch64)
42951f080313SClaudio Fontana    linux_arch=arm64
42961f080313SClaudio Fontana    ;;
4297222e7d11SSanjay Lal  mips64)
4298222e7d11SSanjay Lal    linux_arch=mips
4299222e7d11SSanjay Lal    ;;
430008312a63SPeter Maydell  *)
430108312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
430208312a63SPeter Maydell    linux_arch="$cpu"
43036efd7517SPeter Maydell    ;;
43046efd7517SPeter Maydell  esac
430508312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
430608312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
430708312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
430808312a63SPeter Maydell    fi
43096efd7517SPeter Maydellfi
43106efd7517SPeter Maydell
431197a847bcSbellardfor target in $target_list; do
431297a847bcSbellard    target_dir="$target"
431389138857SStefan Weil    target_name=$(echo $target | cut -d '-' -f 1)
431497a847bcSbellard    mkdir -p $target_dir
4315fdb75aefSPaolo Bonzini    case $target in
4316fdb75aefSPaolo Bonzini        *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;;
4317fdb75aefSPaolo Bonzini        *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;;
43182408a527Saurel32    esac
431956aebc89Spbrookdone
43207d13299dSbellard
4321765686d6SPaolo Bonziniecho "CONFIG_QEMU_INTERP_PREFIX=$interp_prefix" | sed 's/%M/@0@/' >> $config_host_mak
4322fdb75aefSPaolo Bonziniif test "$default_targets" = "yes"; then
4323fdb75aefSPaolo Bonzini  echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak
4324fdb75aefSPaolo Bonzinifi
4325a540f158SPeter Crosthwaite
4326a99d57bbSWanlong Gaoif test "$numa" = "yes"; then
4327a99d57bbSWanlong Gao  echo "CONFIG_NUMA=y" >> $config_host_mak
4328ab318051SMarc-André Lureau  echo "NUMA_LIBS=$numa_libs" >> $config_host_mak
4329a99d57bbSWanlong Gaofi
4330a99d57bbSWanlong Gao
4331fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then
4332fd0e6053SJohn Snow  echo "export CCACHE_CPP2=y" >> $config_host_mak
4333fd0e6053SJohn Snowfi
4334fd0e6053SJohn Snow
43351e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then
43361e4f6065SDaniele Buono  echo "CONFIG_SAFESTACK=y" >> $config_host_mak
43371e4f6065SDaniele Buonofi
43381e4f6065SDaniele Buono
4339e29e5c6eSPeter Maydell# If we're using a separate build tree, set it up now.
4340e29e5c6eSPeter Maydell# DIRS are directories which we simply mkdir in the build tree;
4341e29e5c6eSPeter Maydell# LINKS are things to symlink back into the source tree
4342e29e5c6eSPeter Maydell# (these can be both files and directories).
4343e29e5c6eSPeter Maydell# Caution: do not add files or directories here using wildcards. This
4344e29e5c6eSPeter Maydell# will result in problems later if a new file matching the wildcard is
4345e29e5c6eSPeter Maydell# added to the source tree -- nothing will cause configure to be rerun
4346e29e5c6eSPeter Maydell# so the build tree will be missing the link back to the new file, and
4347e29e5c6eSPeter Maydell# tests might fail. Prefer to keep the relevant files in their own
4348e29e5c6eSPeter Maydell# directory and symlink the directory instead.
434909db9b9dSGerd Hoffmann# UNLINK is used to remove symlinks from older development versions
435009db9b9dSGerd Hoffmann# that might get into the way when doing "git update" without doing
435109db9b9dSGerd Hoffmann# a "make distclean" in between.
43529d49bcf6SMarkus ArmbrusterDIRS="tests tests/tcg tests/qapi-schema tests/qtest/libqos"
43531cf4323eSThomas HuthDIRS="$DIRS tests/qtest tests/qemu-iotests tests/vm tests/fp tests/qgraph"
4354b855f8d1SPaolo BonziniDIRS="$DIRS docs docs/interop fsdev scsi"
4355744a928cSAlexey KardashevskiyDIRS="$DIRS pc-bios/optionrom pc-bios/s390-ccw"
43568db2a4fdSGerd HoffmannDIRS="$DIRS roms/seabios"
4357c17a386bSAlex BennéeDIRS="$DIRS contrib/plugins/"
43582038f8c8SPaolo BonziniLINKS="Makefile"
43593941996bSPaolo BonziniLINKS="$LINKS tests/tcg/Makefile.target"
4360ddcf607fSGerd HoffmannLINKS="$LINKS pc-bios/optionrom/Makefile"
4361e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/s390-ccw/Makefile"
43628db2a4fdSGerd HoffmannLINKS="$LINKS roms/seabios/Makefile"
4363e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/qemu-icon.bmp"
4364e29e5c6eSPeter MaydellLINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
436539950353SPeter MaydellLINKS="$LINKS tests/acceptance tests/data"
436639950353SPeter MaydellLINKS="$LINKS tests/qemu-iotests/check"
43678f8fd9edSCleber RosaLINKS="$LINKS python"
4368c17a386bSAlex BennéeLINKS="$LINKS contrib/plugins/Makefile "
436909db9b9dSGerd HoffmannUNLINK="pc-bios/keymaps"
4370753d11f2SRichard Hendersonfor bios_file in \
4371753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
43723a631b8eSBin Meng    $source_path/pc-bios/*.elf \
4373225a9ab8SAlexey Kardashevskiy    $source_path/pc-bios/*.lid \
4374753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
4375753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
4376e89e33e1SDominik Dingel    $source_path/pc-bios/*.img \
4377753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
43784e73c781SAlexander Graf    $source_path/pc-bios/u-boot.* \
437926ce90fdSLaszlo Ersek    $source_path/pc-bios/edk2-*.fd.bz2 \
4380cd946e5cSJohn Arbuckle    $source_path/pc-bios/palcode-* \
4381cd946e5cSJohn Arbuckle    $source_path/pc-bios/qemu_vga.ndrv
4382cd946e5cSJohn Arbuckle
4383753d11f2SRichard Hendersondo
4384e29e5c6eSPeter Maydell    LINKS="$LINKS pc-bios/$(basename $bios_file)"
43857ea78b74SJan Kiszkadone
4386d1807a4fSPaolo Bonzinimkdir -p $DIRS
4387e29e5c6eSPeter Maydellfor f in $LINKS ; do
43880f4d8894SPaolo Bonzini    if [ -e "$source_path/$f" ]; then
4389f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
4390f9245e10SPeter Maydell    fi
43917d13299dSbellarddone
439209db9b9dSGerd Hoffmannfor f in $UNLINK ; do
439309db9b9dSGerd Hoffmann    if [ -L "$f" ]; then
439409db9b9dSGerd Hoffmann        rm -f "$f"
439509db9b9dSGerd Hoffmann    fi
439609db9b9dSGerd Hoffmanndone
43971ad2134fSPaul Brook
43982038f8c8SPaolo Bonzini(for i in $cross_cc_vars; do
43992038f8c8SPaolo Bonzini  export $i
44002038f8c8SPaolo Bonzinidone
4401de6d7e6bSAlex Bennéeexport target_list source_path use_containers ARCH
44022038f8c8SPaolo Bonzini$source_path/tests/tcg/configure.sh)
44032038f8c8SPaolo Bonzini
4404c34ebfdcSAnthony Liguori# temporary config to build submodules
44058db2a4fdSGerd Hoffmannfor rom in seabios; do
4406c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
440737116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
4408c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
4409cdbd727cSRichard Henderson    echo "AS=$as" >> $config_mak
44105f6f0e27SRichard Henderson    echo "CCAS=$ccas" >> $config_mak
4411c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
4412c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
44133dd46c78SBlue Swirl    echo "CPP=$cpp" >> $config_mak
4414c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
4415a31a8642SMichael S. Tsirkin    echo "IASL=$iasl" >> $config_mak
4416c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
44179f81aeb5SAlistair Francis    echo "RANLIB=$ranlib" >> $config_mak
4418c34ebfdcSAnthony Liguoridone
4419c34ebfdcSAnthony Liguori
4420a5665051SPaolo Bonziniif test "$skip_meson" = no; then
4421fc929892SMarc-André Lureau  cross="config-meson.cross.new"
4422fc929892SMarc-André Lureau  meson_quote() {
442347b30835SPaolo Bonzini    echo "'$(echo $* | sed "s/ /','/g")'"
4424fc929892SMarc-André Lureau  }
4425fc929892SMarc-André Lureau
4426fc929892SMarc-André Lureau  echo "# Automatically generated by configure - do not modify" > $cross
4427fc929892SMarc-André Lureau  echo "[properties]" >> $cross
4428d1d5e9eeSAlex Bennée
4429d1d5e9eeSAlex Bennée  # unroll any custom device configs
4430d1d5e9eeSAlex Bennée  for a in $device_archs; do
4431d1d5e9eeSAlex Bennée      eval "c=\$devices_${a}"
4432d1d5e9eeSAlex Bennée      echo "${a}-softmmu = '$c'" >> $cross
4433d1d5e9eeSAlex Bennée  done
4434d1d5e9eeSAlex Bennée
4435fc929892SMarc-André Lureau  test -z "$cxx" && echo "link_language = 'c'" >> $cross
443647b30835SPaolo Bonzini  echo "[built-in options]" >> $cross
443747b30835SPaolo Bonzini  echo "c_args = [${CFLAGS:+$(meson_quote $CFLAGS)}]" >> $cross
443847b30835SPaolo Bonzini  echo "cpp_args = [${CXXFLAGS:+$(meson_quote $CXXFLAGS)}]" >> $cross
443947b30835SPaolo Bonzini  echo "c_link_args = [${LDFLAGS:+$(meson_quote $LDFLAGS)}]" >> $cross
444047b30835SPaolo Bonzini  echo "cpp_link_args = [${LDFLAGS:+$(meson_quote $LDFLAGS)}]" >> $cross
4441fc929892SMarc-André Lureau  echo "[binaries]" >> $cross
44424dba2789SPaolo Bonzini  echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross
44434dba2789SPaolo Bonzini  test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross
44444dba2789SPaolo Bonzini  test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross
444547b30835SPaolo Bonzini  echo "ar = [$(meson_quote $ar)]" >> $cross
444647b30835SPaolo Bonzini  echo "nm = [$(meson_quote $nm)]" >> $cross
444747b30835SPaolo Bonzini  echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross
444847b30835SPaolo Bonzini  echo "ranlib = [$(meson_quote $ranlib)]" >> $cross
4449e8178514SPaolo Bonzini  if has $sdl2_config; then
445047b30835SPaolo Bonzini    echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross
4451e8178514SPaolo Bonzini  fi
445247b30835SPaolo Bonzini  echo "strip = [$(meson_quote $strip)]" >> $cross
445347b30835SPaolo Bonzini  echo "windres = [$(meson_quote $windres)]" >> $cross
44543812c0c4SJoelle van Dyne  if test "$cross_compile" = "yes"; then
4455fc929892SMarc-André Lureau    cross_arg="--cross-file config-meson.cross"
4456fc929892SMarc-André Lureau    echo "[host_machine]" >> $cross
4457fc929892SMarc-André Lureau    if test "$mingw32" = "yes" ; then
4458fc929892SMarc-André Lureau        echo "system = 'windows'" >> $cross
4459fc929892SMarc-André Lureau    fi
4460853b4bafSThomas Huth    if test "$linux" = "yes" ; then
4461853b4bafSThomas Huth        echo "system = 'linux'" >> $cross
4462853b4bafSThomas Huth    fi
44630ca321eaSJoelle van Dyne    if test "$darwin" = "yes" ; then
44640ca321eaSJoelle van Dyne        echo "system = 'darwin'" >> $cross
44650ca321eaSJoelle van Dyne    fi
4466fc929892SMarc-André Lureau    case "$ARCH" in
4467f6bca9dfSJoelle van Dyne        i386)
4468fc929892SMarc-André Lureau            echo "cpu_family = 'x86'" >> $cross
4469fc929892SMarc-André Lureau            ;;
4470f8bb7e1cSDavid Michael        x86_64|x32)
4471f6bca9dfSJoelle van Dyne            echo "cpu_family = 'x86_64'" >> $cross
4472f6bca9dfSJoelle van Dyne            ;;
4473fc929892SMarc-André Lureau        ppc64le)
4474fc929892SMarc-André Lureau            echo "cpu_family = 'ppc64'" >> $cross
4475fc929892SMarc-André Lureau            ;;
4476fc929892SMarc-André Lureau        *)
4477fc929892SMarc-André Lureau            echo "cpu_family = '$ARCH'" >> $cross
4478fc929892SMarc-André Lureau            ;;
4479fc929892SMarc-André Lureau    esac
4480fc929892SMarc-André Lureau    echo "cpu = '$cpu'" >> $cross
4481fc929892SMarc-André Lureau    if test "$bigendian" = "yes" ; then
4482fc929892SMarc-André Lureau        echo "endian = 'big'" >> $cross
4483fc929892SMarc-André Lureau    else
4484fc929892SMarc-André Lureau        echo "endian = 'little'" >> $cross
4485fc929892SMarc-André Lureau    fi
4486fc929892SMarc-André Lureau  else
4487fc929892SMarc-André Lureau    cross_arg="--native-file config-meson.cross"
4488fc929892SMarc-André Lureau  fi
4489fc929892SMarc-André Lureau  mv $cross config-meson.cross
4490fc929892SMarc-André Lureau
4491a5665051SPaolo Bonzini  rm -rf meson-private meson-info meson-logs
449209e93326SPaolo Bonzini  NINJA=$ninja $meson setup \
4493d17f305aSPaolo Bonzini        --prefix "$prefix" \
4494d17f305aSPaolo Bonzini        --libdir "$libdir" \
4495d17f305aSPaolo Bonzini        --libexecdir "$libexecdir" \
4496d17f305aSPaolo Bonzini        --bindir "$bindir" \
4497d17f305aSPaolo Bonzini        --includedir "$includedir" \
4498d17f305aSPaolo Bonzini        --datadir "$datadir" \
4499d17f305aSPaolo Bonzini        --mandir "$mandir" \
4500d17f305aSPaolo Bonzini        --sysconfdir "$sysconfdir" \
450116bf7a33SPaolo Bonzini        --localedir "$localedir" \
4502d17f305aSPaolo Bonzini        --localstatedir "$local_statedir" \
4503d17f305aSPaolo Bonzini        -Ddocdir="$docdir" \
450416bf7a33SPaolo Bonzini        -Dqemu_firmwarepath="$firmwarepath" \
450573f3aa37SMarc-André Lureau        -Dqemu_suffix="$qemu_suffix" \
4506a5665051SPaolo Bonzini        -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) \
4507a5665051SPaolo Bonzini        -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo false; fi) \
4508a5665051SPaolo Bonzini        -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \
4509a5665051SPaolo Bonzini        -Dstrip=$(if test "$strip_opt" = yes; then echo true; else echo false; fi) \
4510da6d48b9SMarc-André Lureau        -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \
4511bf0e56a3SMarc-André Lureau        -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \
4512537b7248SPaolo Bonzini        -Db_lto=$lto -Dcfi=$cfi -Dcfi_debug=$cfi_debug -Dfuzzing=$fuzzing \
4513537b7248SPaolo Bonzini        $(test -n "${LIB_FUZZING_ENGINE+xxx}" && echo "-Dfuzzing_engine=$LIB_FUZZING_ENGINE") \
4514deb62371SPaolo Bonzini        -Dmalloc=$malloc -Dmalloc_trim=$malloc_trim -Dsparse=$sparse \
451574a414a1SReinoud Zandijk        -Dkvm=$kvm -Dhax=$hax -Dwhpx=$whpx -Dhvf=$hvf -Dnvmm=$nvmm \
45161badb709SPaolo Bonzini        -Dxen=$xen -Dxen_pci_passthrough=$xen_pci_passthrough -Dtcg=$tcg \
45171b695471SPaolo Bonzini        -Dcocoa=$cocoa -Dgtk=$gtk -Dmpath=$mpath -Dsdl=$sdl -Dsdl_image=$sdl_image \
4518c23d7b4eSPaolo Bonzini        -Dlibusb=$libusb -Dsmartcard=$smartcard -Dusb_redir=$usb_redir -Dvte=$vte \
4519a0b93237SPaolo Bonzini        -Dvnc=$vnc -Dvnc_sasl=$vnc_sasl -Dvnc_jpeg=$vnc_jpeg -Dvnc_png=$vnc_png \
4520cece116cSMisono Tomohiro        -Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f -Dvirtiofsd=$virtiofsd \
45218c6d4ff4SPaolo Bonzini        -Dcapstone=$capstone -Dslirp=$slirp -Dfdt=$fdt -Dbrlapi=$brlapi \
45229db405a3SPaolo Bonzini        -Dcurl=$curl -Dglusterfs=$glusterfs -Dbzip2=$bzip2 -Dlibiscsi=$libiscsi \
452330045c05SPaolo Bonzini        -Dlibnfs=$libnfs -Diconv=$iconv -Dcurses=$curses -Dlibudev=$libudev\
4524c5b36c25SPaolo Bonzini        -Drbd=$rbd -Dlzo=$lzo -Dsnappy=$snappy -Dlzfse=$lzfse -Dlibxml2=$libxml2 \
452553c22b68SPaolo Bonzini        -Dlibdaxctl=$libdaxctl -Dlibpmem=$libpmem -Dlinux_io_uring=$linux_io_uring \
452605e391aeSPaolo Bonzini        -Dgnutls=$gnutls -Dnettle=$nettle -Dgcrypt=$gcrypt -Dauth_pam=$auth_pam \
4527727c8bb8SPaolo Bonzini        -Dzstd=$zstd -Dseccomp=$seccomp -Dvirtfs=$virtfs -Dcap_ng=$cap_ng \
4528587d59d6SPaolo Bonzini        -Dattr=$attr -Ddefault_devices=$default_devices -Dvirglrenderer=$virglrenderer \
4529c8d5450bSPaolo Bonzini        -Ddocs=$docs -Dsphinx_build=$sphinx_build -Dinstall_blobs=$blobs \
4530106ad1f9SPaolo Bonzini        -Dvhost_user_blk_server=$vhost_user_blk_server -Dmultiprocess=$multiprocess \
453146627f41SAndrew Melnychenko        -Dfuse=$fuse -Dfuse_lseek=$fuse_lseek -Dguest_agent_msi=$guest_agent_msi -Dbpf=$bpf\
4532332008e0SThomas Huth        $(if test "$default_feature" = no; then echo "-Dauto_features=disabled"; fi) \
4533ca50e523SPaolo Bonzini        -Dalsa=$alsa -Dcoreaudio=$coreaudio -Ddsound=$dsound -Djack=$jack -Doss=$oss \
4534ca50e523SPaolo Bonzini        -Dpa=$pa -Daudio_drv_list=$audio_drv_list -Dtcg_interpreter=$tcg_interpreter \
4535ff66f3e5SPaolo Bonzini        -Dtrace_backends=$trace_backends -Dtrace_file=$trace_file -Dlinux_aio=$linux_aio \
4536837b84b1SPaolo Bonzini        -Dnetmap=$netmap -Dvde=$vde \
4537fc929892SMarc-André Lureau        $cross_arg \
4538a5665051SPaolo Bonzini        "$PWD" "$source_path"
4539a5665051SPaolo Bonzini
4540a5665051SPaolo Bonzini  if test "$?" -ne 0 ; then
4541a5665051SPaolo Bonzini      error_exit "meson setup failed"
4542a5665051SPaolo Bonzini  fi
4543699d3884SPaolo Bonzinielse
4544699d3884SPaolo Bonzini  if test -f meson-private/cmd_line.txt; then
4545699d3884SPaolo Bonzini    # Adjust old command line options whose type was changed
4546699d3884SPaolo Bonzini    # Avoids having to use "setup --wipe" when Meson is upgraded
4547699d3884SPaolo Bonzini    perl -i -ne '
4548699d3884SPaolo Bonzini      s/^gettext = true$/gettext = auto/;
4549699d3884SPaolo Bonzini      s/^gettext = false$/gettext = disabled/;
4550654d6b04SPaolo Bonzini      /^b_staticpic/ && next;
4551699d3884SPaolo Bonzini      print;' meson-private/cmd_line.txt
4552699d3884SPaolo Bonzini  fi
4553a5665051SPaolo Bonzinifi
4554a5665051SPaolo Bonzini
45552d838d9bSAlex Bennéeif test -n "${deprecated_features}"; then
45562d838d9bSAlex Bennée    echo "Warning, deprecated features enabled."
4557a476b216SMao Zhongyi    echo "Please see docs/about/deprecated.rst"
45582d838d9bSAlex Bennée    echo "  features: ${deprecated_features}"
45592d838d9bSAlex Bennéefi
45602d838d9bSAlex Bennée
4561e0447a83SThomas Huth# Create list of config switches that should be poisoned in common code...
4562e0447a83SThomas Huth# but filter out CONFIG_TCG and CONFIG_USER_ONLY which are special.
456354b0306eSThomas Huthtarget_configs_h=$(ls *-config-devices.h *-config-target.h 2>/dev/null)
456454b0306eSThomas Huthif test -n "$target_configs_h" ; then
4565e0447a83SThomas Huth    sed -n -e '/CONFIG_TCG/d' -e '/CONFIG_USER_ONLY/d' \
4566e0447a83SThomas Huth        -e '/^#define / { s///; s/ .*//; s/^/#pragma GCC poison /p; }' \
456754b0306eSThomas Huth        $target_configs_h | sort -u > config-poison.h
456854b0306eSThomas Huthelse
456954b0306eSThomas Huth    :> config-poison.h
457054b0306eSThomas Huthfi
4571e0447a83SThomas Huth
4572dc655404SMichael S. Tsirkin# Save the configure command line for later reuse.
4573dc655404SMichael S. Tsirkincat <<EOD >config.status
4574dc655404SMichael S. Tsirkin#!/bin/sh
4575dc655404SMichael S. Tsirkin# Generated by configure.
4576dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration.
4577dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging
4578dc655404SMichael S. Tsirkin# configure, is in config.log if it exists.
4579dc655404SMichael S. TsirkinEOD
4580e811da7fSDaniel P. Berrangé
4581e811da7fSDaniel P. Berrangépreserve_env() {
4582e811da7fSDaniel P. Berrangé    envname=$1
4583e811da7fSDaniel P. Berrangé
4584e811da7fSDaniel P. Berrangé    eval envval=\$$envname
4585e811da7fSDaniel P. Berrangé
4586e811da7fSDaniel P. Berrangé    if test -n "$envval"
4587e811da7fSDaniel P. Berrangé    then
4588e811da7fSDaniel P. Berrangé	echo "$envname='$envval'" >> config.status
4589e811da7fSDaniel P. Berrangé	echo "export $envname" >> config.status
4590e811da7fSDaniel P. Berrangé    else
4591e811da7fSDaniel P. Berrangé	echo "unset $envname" >> config.status
4592e811da7fSDaniel P. Berrangé    fi
4593e811da7fSDaniel P. Berrangé}
4594e811da7fSDaniel P. Berrangé
4595e811da7fSDaniel P. Berrangé# Preserve various env variables that influence what
4596e811da7fSDaniel P. Berrangé# features/build target configure will detect
4597e811da7fSDaniel P. Berrangépreserve_env AR
4598e811da7fSDaniel P. Berrangépreserve_env AS
4599e811da7fSDaniel P. Berrangépreserve_env CC
4600e811da7fSDaniel P. Berrangépreserve_env CPP
4601e811da7fSDaniel P. Berrangépreserve_env CXX
4602e811da7fSDaniel P. Berrangépreserve_env INSTALL
4603e811da7fSDaniel P. Berrangépreserve_env LD
4604e811da7fSDaniel P. Berrangépreserve_env LD_LIBRARY_PATH
4605e811da7fSDaniel P. Berrangépreserve_env LIBTOOL
4606e811da7fSDaniel P. Berrangépreserve_env MAKE
4607e811da7fSDaniel P. Berrangépreserve_env NM
4608e811da7fSDaniel P. Berrangépreserve_env OBJCOPY
4609e811da7fSDaniel P. Berrangépreserve_env PATH
4610e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG
4611e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_LIBDIR
4612e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_PATH
4613e811da7fSDaniel P. Berrangépreserve_env PYTHON
4614e811da7fSDaniel P. Berrangépreserve_env SDL2_CONFIG
4615e811da7fSDaniel P. Berrangépreserve_env SMBD
4616e811da7fSDaniel P. Berrangépreserve_env STRIP
4617e811da7fSDaniel P. Berrangépreserve_env WINDRES
4618e811da7fSDaniel P. Berrangé
4619dc655404SMichael S. Tsirkinprintf "exec" >>config.status
4620a5665051SPaolo Bonzinifor i in "$0" "$@"; do
4621835af899SPaolo Bonzini  test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status
4622a5665051SPaolo Bonzinidone
4623cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status
4624dc655404SMichael S. Tsirkinchmod +x config.status
4625dc655404SMichael S. Tsirkin
46268cd05ab6SPeter Maydellrm -r "$TMPDIR1"
4627