xref: /openbmc/qemu/configure (revision 87430d5b)
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
2195b808275SLluís Vilanovahave_backend () {
2205b808275SLluís Vilanova    echo "$trace_backends" | grep "$1" >/dev/null
2215b808275SLluís Vilanova}
2225b808275SLluís Vilanova
2233b6b7550SPaolo Bonziniglob() {
2243b6b7550SPaolo Bonzini    eval test -z '"${1#'"$2"'}"'
2253b6b7550SPaolo Bonzini}
2263b6b7550SPaolo Bonzini
227e9a3591fSChristian Borntraegerld_has() {
228e9a3591fSChristian Borntraeger    $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
229e9a3591fSChristian Borntraeger}
230e9a3591fSChristian Borntraeger
2314ace32e2SAntonio Ospiteif printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]";
2324ace32e2SAntonio Ospitethen
2334ace32e2SAntonio Ospite  error_exit "main directory cannot contain spaces nor colons"
2344ace32e2SAntonio Ospitefi
2354ace32e2SAntonio Ospite
23614211825SAntonio Ospite# default parameters
2372ff6b91eSJuan Quintelacpu=""
238a31a8642SMichael S. Tsirkiniasl="iasl"
2391e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
24043ce4dfeSbellardstatic="no"
2413812c0c4SJoelle van Dynecross_compile="no"
2427d13299dSbellardcross_prefix=""
243*87430d5bSPaolo Bonziniaudio_drv_list="default"
244b64ec4e4SFam Zhengblock_drv_rw_whitelist=""
245b64ec4e4SFam Zhengblock_drv_ro_whitelist=""
246e5f05f8cSKevin Wolfblock_drv_whitelist_tools="no"
247e49d021eSPeter Maydellhost_cc="cc"
248957f1f99SMichael Rothlibs_qga=""
2495bc62e01SGerd Hoffmanndebug_info="yes"
250cdad781dSDaniele Buonolto="false"
25163678e17SSteven Noonanstack_protector=""
2521e4f6065SDaniele Buonosafe_stack=""
253afc3a8f9SAlex Bennéeuse_containers="yes"
254f2385398SAlex Bennéegdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
255ac0df51dSaliguori
25692712822SDaniel P. Berrangeif test -e "$source_path/.git"
25792712822SDaniel P. Berrangethen
2587d7dbf9dSDan Streetman    git_submodules_action="update"
25992712822SDaniel P. Berrangeelse
2607d7dbf9dSDan Streetman    git_submodules_action="ignore"
26192712822SDaniel P. Berrangefi
2622d652f24SPaolo Bonzini
2632d652f24SPaolo Bonzinigit_submodules="ui/keycodemapdb"
264cc84d63aSDaniel P. Berrangegit="git"
265ac0df51dSaliguori
266afb63ebdSStefan Weil# Don't accept a target_list environment variable.
267afb63ebdSStefan Weilunset target_list
268447e133fSAlex Bennéeunset target_list_exclude
269377529c0SPaolo Bonzini
270377529c0SPaolo Bonzini# Default value for a variable defining feature "foo".
271377529c0SPaolo Bonzini#  * foo="no"  feature will only be used if --enable-foo arg is given
272377529c0SPaolo Bonzini#  * foo=""    feature will be searched for, and if found, will be used
273377529c0SPaolo Bonzini#              unless --disable-foo is given
274377529c0SPaolo Bonzini#  * foo="yes" this value will only be set by --enable-foo flag.
275377529c0SPaolo Bonzini#              feature will searched for,
276377529c0SPaolo Bonzini#              if not found, configure exits with error
277377529c0SPaolo Bonzini#
278377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args.
279377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it
280377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found.
281377529c0SPaolo Bonzini
282c87ea116SAlex Bennéedefault_feature=""
283c87ea116SAlex Bennée# parse CC options second
284c87ea116SAlex Bennéefor opt do
285c87ea116SAlex Bennée  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
286c87ea116SAlex Bennée  case "$opt" in
287c87ea116SAlex Bennée      --without-default-features)
288c87ea116SAlex Bennée          default_feature="no"
289c87ea116SAlex Bennée  ;;
290c87ea116SAlex Bennée  esac
291c87ea116SAlex Bennéedone
292c87ea116SAlex Bennée
2938c6d4ff4SPaolo Bonzinibrlapi="auto"
294f9cd86feSPaolo Bonzinicurl="auto"
2955285e593SYonggang Luoiconv="auto"
2965285e593SYonggang Luocurses="auto"
297e3667660SYonggang Luodocs="auto"
298fbb4121dSPaolo Bonzinifdt="auto"
29958952137SVincenzo Maffionenetmap="no"
30035be72baSPaolo Bonzinisdl="auto"
30135be72baSPaolo Bonzinisdl_image="auto"
302cece116cSMisono Tomohirovirtiofsd="auto"
30369202b40SPaolo Bonzinivirtfs="auto"
3045c53015aSPaolo Bonzinilibudev="auto"
3056ec0e15dSPaolo Bonzinimpath="auto"
3063a6a1256SThomas Huthvnc="auto"
307deb62371SPaolo Bonzinisparse="auto"
308c87ea116SAlex Bennéevde="$default_feature"
309a0b93237SPaolo Bonzinivnc_sasl="auto"
310a0b93237SPaolo Bonzinivnc_jpeg="auto"
311a0b93237SPaolo Bonzinivnc_png="auto"
3124113f4cfSLaurent Vivierxkbcommon="auto"
313bcf0a7daSThomas Huthxen=${default_feature:+disabled}
314c87ea116SAlex Bennéexen_ctrl_version="$default_feature"
3151badb709SPaolo Bonzinixen_pci_passthrough="auto"
316c87ea116SAlex Bennéelinux_aio="$default_feature"
31753c22b68SPaolo Bonzinilinux_io_uring="auto"
318727c8bb8SPaolo Bonzinicap_ng="auto"
319f7f2d651SPaolo Bonziniattr="auto"
320c87ea116SAlex Bennéexfs="$default_feature"
3211badb709SPaolo Bonzinitcg="enabled"
322c87ea116SAlex Bennéemembarrier="$default_feature"
3230848f8acSThomas Huthvhost_kernel="$default_feature"
324c87ea116SAlex Bennéevhost_net="$default_feature"
325c87ea116SAlex Bennéevhost_crypto="$default_feature"
326c87ea116SAlex Bennéevhost_scsi="$default_feature"
327c87ea116SAlex Bennéevhost_vsock="$default_feature"
328d88618f7SStefan Hajnoczivhost_user="no"
329e5e856c1SStefan Hajnoczivhost_user_blk_server="auto"
330c87ea116SAlex Bennéevhost_user_fs="$default_feature"
3310848f8acSThomas Huthvhost_vdpa="$default_feature"
33246627f41SAndrew Melnychenkobpf="auto"
3333bd40ec7SPaolo Bonzinikvm="auto"
3343bd40ec7SPaolo Bonzinihax="auto"
3353bd40ec7SPaolo Bonzinihvf="auto"
3363bd40ec7SPaolo Bonziniwhpx="auto"
33774a414a1SReinoud Zandijknvmm="auto"
338c87ea116SAlex Bennéerdma="$default_feature"
339c87ea116SAlex Bennéepvrdma="$default_feature"
340377529c0SPaolo Bonzinigprof="no"
341377529c0SPaolo Bonzinidebug_tcg="no"
342377529c0SPaolo Bonzinidebug="no"
343247724cbSMarc-André Lureausanitizers="no"
3440aebab04SLingfeng Yangtsan="no"
345c87ea116SAlex Bennéefortify_source="$default_feature"
346377529c0SPaolo Bonzinistrip_opt="yes"
34723a77b2dSPaolo Bonzinitcg_interpreter="false"
348377529c0SPaolo Bonzinibigendian="no"
349377529c0SPaolo Bonzinimingw32="no"
3501d728c39SBlue Swirlgcov="no"
351c7328271SMiroslav RezaninaEXESUF=""
352484e2cc7SPaolo BonziniHOST_DSOSUF=".so"
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"
372c87ea116SAlex Bennéespice="$default_feature"
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"
433adc28027SAlexander Bulekovfuzzing="no"
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
563adc28027SAlexander Bulekovwrite_c_fuzzer_skeleton() {
564adc28027SAlexander Bulekov    cat > $TMPC <<EOF
565adc28027SAlexander Bulekov#include <stdint.h>
566adc28027SAlexander Bulekov#include <sys/types.h>
567adc28027SAlexander Bulekovint LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
568adc28027SAlexander Bulekovint LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { return 0; }
569adc28027SAlexander BulekovEOF
570adc28027SAlexander Bulekov}
571adc28027SAlexander Bulekov
572bbea4050SPeter Maydellif check_define __linux__ ; then
573bbea4050SPeter Maydell  targetos="Linux"
574bbea4050SPeter Maydellelif check_define _WIN32 ; then
575bbea4050SPeter Maydell  targetos='MINGW32'
576bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
577bbea4050SPeter Maydell  targetos='OpenBSD'
578bbea4050SPeter Maydellelif check_define __sun__ ; then
579bbea4050SPeter Maydell  targetos='SunOS'
580bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
581bbea4050SPeter Maydell  targetos='Haiku'
582951fedfcSPeter Maydellelif check_define __FreeBSD__ ; then
583951fedfcSPeter Maydell  targetos='FreeBSD'
584951fedfcSPeter Maydellelif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
585951fedfcSPeter Maydell  targetos='GNU/kFreeBSD'
586951fedfcSPeter Maydellelif check_define __DragonFly__ ; then
587951fedfcSPeter Maydell  targetos='DragonFly'
588951fedfcSPeter Maydellelif check_define __NetBSD__; then
589951fedfcSPeter Maydell  targetos='NetBSD'
590951fedfcSPeter Maydellelif check_define __APPLE__; then
591951fedfcSPeter Maydell  targetos='Darwin'
592bbea4050SPeter Maydellelse
593951fedfcSPeter Maydell  # This is a fatal error, but don't report it yet, because we
594951fedfcSPeter Maydell  # might be going to just print the --help text, or it might
595951fedfcSPeter Maydell  # be the result of a missing compiler.
596951fedfcSPeter Maydell  targetos='bogus'
597bbea4050SPeter Maydellfi
598bbea4050SPeter Maydell
599bbea4050SPeter Maydell# Some host OSes need non-standard checks for which CPU to use.
600bbea4050SPeter Maydell# Note that these checks are broken for cross-compilation: if you're
601bbea4050SPeter Maydell# cross-compiling to one of these OSes then you'll need to specify
602bbea4050SPeter Maydell# the correct CPU with the --cpu option.
603bbea4050SPeter Maydellcase $targetos in
604bbea4050SPeter MaydellDarwin)
6055869f8ddSGerd Hoffmann  HOST_DSOSUF=".dylib"
606bbea4050SPeter Maydell  ;;
607bbea4050SPeter MaydellSunOS)
60889138857SStefan Weil  # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
609bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
610bbea4050SPeter Maydell    cpu="x86_64"
611bbea4050SPeter Maydell  fi
612bbea4050SPeter Maydellesac
613bbea4050SPeter Maydell
6142ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
6152ff6b91eSJuan Quintela  # command line argument
6162ff6b91eSJuan Quintela  :
6172ff6b91eSJuan Quintelaelif check_define __i386__ ; then
618ac0df51dSaliguori  cpu="i386"
619ac0df51dSaliguorielif check_define __x86_64__ ; then
620c72b26ecSRichard Henderson  if check_define __ILP32__ ; then
621c72b26ecSRichard Henderson    cpu="x32"
622c72b26ecSRichard Henderson  else
623ac0df51dSaliguori    cpu="x86_64"
624c72b26ecSRichard Henderson  fi
6253aa9bd6cSblueswir1elif check_define __sparc__ ; then
6263aa9bd6cSblueswir1  if check_define __arch64__ ; then
6273aa9bd6cSblueswir1    cpu="sparc64"
6283aa9bd6cSblueswir1  else
6293aa9bd6cSblueswir1    cpu="sparc"
6303aa9bd6cSblueswir1  fi
631fdf7ed96Smalcelif check_define _ARCH_PPC ; then
632fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
633f8378accSRichard Henderson    if check_define _LITTLE_ENDIAN ; then
634f8378accSRichard Henderson      cpu="ppc64le"
635f8378accSRichard Henderson    else
636fdf7ed96Smalc      cpu="ppc64"
637f8378accSRichard Henderson    fi
638ac0df51dSaliguori  else
639fdf7ed96Smalc    cpu="ppc"
640fdf7ed96Smalc  fi
641afa05235SAurelien Jarnoelif check_define __mips__ ; then
642afa05235SAurelien Jarno  cpu="mips"
643d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
644d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
645d66ed0eaSAurelien Jarno    cpu="s390x"
646d66ed0eaSAurelien Jarno  else
647d66ed0eaSAurelien Jarno    cpu="s390"
648d66ed0eaSAurelien Jarno  fi
649c4f80543SAlistair Franciselif check_define __riscv ; then
650c4f80543SAlistair Francis  if check_define _LP64 ; then
651c4f80543SAlistair Francis    cpu="riscv64"
652c4f80543SAlistair Francis  else
653c4f80543SAlistair Francis    cpu="riscv32"
654c4f80543SAlistair Francis  fi
65521d89f84SPeter Maydellelif check_define __arm__ ; then
65621d89f84SPeter Maydell  cpu="arm"
6571f080313SClaudio Fontanaelif check_define __aarch64__ ; then
6581f080313SClaudio Fontana  cpu="aarch64"
659fdf7ed96Smalcelse
66089138857SStefan Weil  cpu=$(uname -m)
661ac0df51dSaliguorifi
662ac0df51dSaliguori
663359bc95dSPeter MaydellARCH=
664359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
665359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
6667d13299dSbellardcase "$cpu" in
667ee35e968SThomas Huth  ppc|ppc64|s390x|sparc64|x32|riscv32|riscv64)
668898be3e0SPeter Maydell  ;;
669f8378accSRichard Henderson  ppc64le)
670f8378accSRichard Henderson    ARCH="ppc64"
671f8378accSRichard Henderson  ;;
6727d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
67397a847bcSbellard    cpu="i386"
6747d13299dSbellard  ;;
675aaa5fa14Saurel32  x86_64|amd64)
676aaa5fa14Saurel32    cpu="x86_64"
677aaa5fa14Saurel32  ;;
67821d89f84SPeter Maydell  armv*b|armv*l|arm)
67921d89f84SPeter Maydell    cpu="arm"
6807d13299dSbellard  ;;
6811f080313SClaudio Fontana  aarch64)
6821f080313SClaudio Fontana    cpu="aarch64"
6831f080313SClaudio Fontana  ;;
684afa05235SAurelien Jarno  mips*)
685afa05235SAurelien Jarno    cpu="mips"
686afa05235SAurelien Jarno  ;;
6873142255cSblueswir1  sparc|sun4[cdmuv])
688ae228531Sbellard    cpu="sparc"
689ae228531Sbellard  ;;
6907d13299dSbellard  *)
691359bc95dSPeter Maydell    # This will result in either an error or falling back to TCI later
692359bc95dSPeter Maydell    ARCH=unknown
6937d13299dSbellard  ;;
6947d13299dSbellardesac
695359bc95dSPeter Maydellif test -z "$ARCH"; then
696359bc95dSPeter Maydell  ARCH="$cpu"
697359bc95dSPeter Maydellfi
698e2d52ad3SJuan Quintela
6997d13299dSbellard# OS specific
7000dbfc675SJuan Quintela
7017d13299dSbellardcase $targetos in
70267b915a5SbellardMINGW32*)
70367b915a5Sbellard  mingw32="yes"
704898be3e0SPeter Maydell  supported_os="yes"
7059b8e4298SAlex Bennée  plugins="no"
706fb648e9cSDaniel P. Berrangé  pie="no"
70767b915a5Sbellard;;
7085c40d2bdSthsGNU/kFreeBSD)
709a167ba50SAurelien Jarno  bsd="yes"
7105c40d2bdSths;;
7117d3505c5SbellardFreeBSD)
7127d3505c5Sbellard  bsd="yes"
713e2a74729SWarner Losh  bsd_user="yes"
7140db4a067SPaolo Bonzini  make="${MAKE-gmake}"
715f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
71658952137SVincenzo Maffione  netmap=""  # enable netmap autodetect
7177d3505c5Sbellard;;
718c5e97233Sblueswir1DragonFly)
719c5e97233Sblueswir1  bsd="yes"
7200db4a067SPaolo Bonzini  make="${MAKE-gmake}"
721c5e97233Sblueswir1;;
7227d3505c5SbellardNetBSD)
7237d3505c5Sbellard  bsd="yes"
7240db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7257d3505c5Sbellard;;
7267d3505c5SbellardOpenBSD)
7277d3505c5Sbellard  bsd="yes"
7280db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7297d3505c5Sbellard;;
73083fb7adfSbellardDarwin)
73183fb7adfSbellard  bsd="yes"
73283fb7adfSbellard  darwin="yes"
733a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
734a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
735a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
73683fb7adfSbellard;;
737ec530c81SbellardSunOS)
738ec530c81Sbellard  solaris="yes"
7390db4a067SPaolo Bonzini  make="${MAKE-gmake}"
740e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
741d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
742d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
743d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
744d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
745ec530c81Sbellard;;
746179cf400SAndreas FärberHaiku)
747179cf400SAndreas Färber  haiku="yes"
748b8ee198dSRichard Zak  pie="no"
749b8ee198dSRichard Zak  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE -fPIC $QEMU_CFLAGS"
750179cf400SAndreas Färber;;
751898be3e0SPeter MaydellLinux)
7525327cf48Sbellard  linux="yes"
753831b7825Sths  linux_user="yes"
754c87ea116SAlex Bennée  vhost_user=${default_feature:-yes}
755898be3e0SPeter Maydell;;
7567d13299dSbellardesac
7577d13299dSbellard
7580db4a067SPaolo Bonzini: ${make=${MAKE-make}}
759b6daf4d3SPaolo Bonzini
760faf44142SDaniel P. Berrangé# We prefer python 3.x. A bare 'python' is traditionally
761faf44142SDaniel P. Berrangé# python 2.x, but some distros have it as python 3.x, so
762ddf90699SEduardo Habkost# we check that too
763faf44142SDaniel P. Berrangépython=
7640a01d76fSMarc-André Lureauexplicit_python=no
765ddf90699SEduardo Habkostfor binary in "${PYTHON-python3}" python
766faf44142SDaniel P. Berrangédo
767faf44142SDaniel P. Berrangé    if has "$binary"
768faf44142SDaniel P. Berrangé    then
76995c5f2deSPaolo Bonzini        python=$(command -v "$binary")
770faf44142SDaniel P. Berrangé        break
771faf44142SDaniel P. Berrangé    fi
772faf44142SDaniel P. Berrangédone
773903458c8SMarkus Armbruster
774903458c8SMarkus Armbruster
77539d87c8cSAlex Bennée# Check for ancillary tools used in testing
77639d87c8cSAlex Bennéegenisoimage=
7773df437c7SAlex Bennéefor binary in genisoimage mkisofs
77839d87c8cSAlex Bennéedo
77939d87c8cSAlex Bennée    if has $binary
78039d87c8cSAlex Bennée    then
78139d87c8cSAlex Bennée        genisoimage=$(command -v "$binary")
78239d87c8cSAlex Bennée        break
78339d87c8cSAlex Bennée    fi
78439d87c8cSAlex Bennéedone
78539d87c8cSAlex Bennée
7863c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
7873c4a4d0dSPeter Maydellif has clang; then
7883c4a4d0dSPeter Maydell  objcc=clang
7893c4a4d0dSPeter Maydellelse
7903c4a4d0dSPeter Maydell  objcc="$cc"
7913c4a4d0dSPeter Maydellfi
7923c4a4d0dSPeter Maydell
7933457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
7943457a3f8SJuan Quintela  EXESUF=".exe"
795484e2cc7SPaolo Bonzini  HOST_DSOSUF=".dll"
79678e9d4adSStefan Weil  # MinGW needs -mthreads for TLS and macro _MT.
7975770e8afSPaolo Bonzini  CONFIGURE_CFLAGS="-mthreads $CONFIGURE_CFLAGS"
79893b25869SJohn Snow  write_c_skeleton;
799d17f305aSPaolo Bonzini  prefix="/qemu"
80077433a5fSMarc-André Lureau  qemu_suffix=""
801105fad6bSBishara AbuHattoum  libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
8023457a3f8SJuan Quintelafi
8033457a3f8SJuan Quintela
804487fefdbSAnthony Liguoriwerror=""
80585aa5189Sbellard
8067d13299dSbellardfor opt do
80789138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
8087d13299dSbellard  case "$opt" in
8092efc3265Sbellard  --help|-h) show_help=yes
8102efc3265Sbellard  ;;
81199123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
81299123e13SMike Frysinger  ;;
813b1a550a0Spbrook  --prefix=*) prefix="$optarg"
8147d13299dSbellard  ;;
815b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
81632ce6337Sbellard  ;;
817ac0df51dSaliguori  --cross-prefix=*)
8187d13299dSbellard  ;;
819ac0df51dSaliguori  --cc=*)
8207d13299dSbellard  ;;
821b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
82283469015Sbellard  ;;
82383f73fceSTomoki Sekiyama  --cxx=*)
82483f73fceSTomoki Sekiyama  ;;
825e007dbecSMichael S. Tsirkin  --iasl=*) iasl="$optarg"
826e007dbecSMichael S. Tsirkin  ;;
8273c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
8283c4a4d0dSPeter Maydell  ;;
829b1a550a0Spbrook  --make=*) make="$optarg"
8307d13299dSbellard  ;;
831b6daf4d3SPaolo Bonzini  --install=*)
8326a882643Spbrook  ;;
8330a01d76fSMarc-André Lureau  --python=*) python="$optarg" ; explicit_python=yes
834c886edfbSBlue Swirl  ;;
8352eb054c2SPeter Maydell  --sphinx-build=*) sphinx_build="$optarg"
8362eb054c2SPeter Maydell  ;;
837a5665051SPaolo Bonzini  --skip-meson) skip_meson=yes
838a5665051SPaolo Bonzini  ;;
839a5665051SPaolo Bonzini  --meson=*) meson="$optarg"
840a5665051SPaolo Bonzini  ;;
84148328880SPaolo Bonzini  --ninja=*) ninja="$optarg"
84248328880SPaolo Bonzini  ;;
843e2d8830eSBrad  --smbd=*) smbd="$optarg"
844e2d8830eSBrad  ;;
845e2a2ed06SJuan Quintela  --extra-cflags=*)
8467d13299dSbellard  ;;
84711cde1c8SBruno Dominguez  --extra-cxxflags=*)
84811cde1c8SBruno Dominguez  ;;
849e2a2ed06SJuan Quintela  --extra-ldflags=*)
8507d13299dSbellard  ;;
8515bc62e01SGerd Hoffmann  --enable-debug-info)
8525bc62e01SGerd Hoffmann  ;;
8535bc62e01SGerd Hoffmann  --disable-debug-info)
8545bc62e01SGerd Hoffmann  ;;
855d75402b5SAlex Bennée  --cross-cc-*)
856d75402b5SAlex Bennée  ;;
85717969268SFam Zheng  --enable-modules)
85817969268SFam Zheng      modules="yes"
85917969268SFam Zheng  ;;
8603aa88b31SStefan Hajnoczi  --disable-modules)
8613aa88b31SStefan Hajnoczi      modules="no"
8623aa88b31SStefan Hajnoczi  ;;
863bd83c861SChristian Ehrhardt  --disable-module-upgrades) module_upgrades="no"
864bd83c861SChristian Ehrhardt  ;;
865bd83c861SChristian Ehrhardt  --enable-module-upgrades) module_upgrades="yes"
866bd83c861SChristian Ehrhardt  ;;
8672ff6b91eSJuan Quintela  --cpu=*)
8687d13299dSbellard  ;;
869b1a550a0Spbrook  --target-list=*) target_list="$optarg"
870447e133fSAlex Bennée                   if test "$target_list_exclude"; then
871447e133fSAlex Bennée                       error_exit "Can't mix --target-list with --target-list-exclude"
872447e133fSAlex Bennée                   fi
873447e133fSAlex Bennée  ;;
874447e133fSAlex Bennée  --target-list-exclude=*) target_list_exclude="$optarg"
875447e133fSAlex Bennée                   if test "$target_list"; then
876447e133fSAlex Bennée                       error_exit "Can't mix --target-list-exclude with --target-list"
877447e133fSAlex Bennée                   fi
878de83cd02Sbellard  ;;
8795b808275SLluís Vilanova  --enable-trace-backends=*) trace_backends="$optarg"
8805b808275SLluís Vilanova  ;;
8815b808275SLluís Vilanova  # XXX: backwards compatibility
8825b808275SLluís Vilanova  --enable-trace-backend=*) trace_backends="$optarg"
88394a420b1SStefan Hajnoczi  ;;
88474242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
8859410b56cSPrerna Saxena  ;;
8867bc3ca7fSPaolo Bonzini  --with-default-devices) default_devices="true"
887f3494749SPaolo Bonzini  ;;
8887bc3ca7fSPaolo Bonzini  --without-default-devices) default_devices="false"
889f3494749SPaolo Bonzini  ;;
890d1d5e9eeSAlex Bennée  --with-devices-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --with-devices-FOO option"
891d1d5e9eeSAlex Bennée  ;;
892d1d5e9eeSAlex Bennée  --with-devices-*) device_arch=${opt#--with-devices-};
893d1d5e9eeSAlex Bennée                    device_arch=${device_arch%%=*}
894d1d5e9eeSAlex Bennée                    cf=$source_path/configs/devices/$device_arch-softmmu/$optarg.mak
895d1d5e9eeSAlex Bennée                    if test -f "$cf"; then
896d1d5e9eeSAlex Bennée                        device_archs="$device_archs $device_arch"
897d1d5e9eeSAlex Bennée                        eval "devices_${device_arch}=\$optarg"
898d1d5e9eeSAlex Bennée                    else
899d1d5e9eeSAlex Bennée                        error_exit "File $cf does not exist"
900d1d5e9eeSAlex Bennée                    fi
901d1d5e9eeSAlex Bennée  ;;
902c87ea116SAlex Bennée  --without-default-features) # processed above
903c87ea116SAlex Bennée  ;;
9047d13299dSbellard  --enable-gprof) gprof="yes"
9057d13299dSbellard  ;;
9061d728c39SBlue Swirl  --enable-gcov) gcov="yes"
9071d728c39SBlue Swirl  ;;
90879427693SLoïc Minier  --static)
90979427693SLoïc Minier    static="yes"
91017884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
91143ce4dfeSbellard  ;;
9120b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
9130b24e75fSPaolo Bonzini  ;;
9140b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
9150b24e75fSPaolo Bonzini  ;;
9163aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
9173aa5d2beSAlon Levy  ;;
9188bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
9198bf188aaSMichael Tokarev  ;;
9200f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
9210f94d6daSAlon Levy  ;;
922528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
9230b24e75fSPaolo Bonzini  ;;
92477433a5fSMarc-André Lureau  --with-suffix=*) qemu_suffix="$optarg"
925023d3d67SEduardo Habkost  ;;
926c6502638SBruce Rogers  --docdir=*) docdir="$optarg"
9270b24e75fSPaolo Bonzini  ;;
928fe0038beSPaolo Bonzini  --localedir=*) localedir="$optarg"
929fe0038beSPaolo Bonzini  ;;
930ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
93107381cc1SAnthony Liguori  ;;
932785c23aeSLuiz Capitulino  --localstatedir=*) local_statedir="$optarg"
933785c23aeSLuiz Capitulino  ;;
9343d5eecabSGerd Hoffmann  --firmwarepath=*) firmwarepath="$optarg"
9353d5eecabSGerd Hoffmann  ;;
936181ce1d0SOlaf Hering  --host=*|--build=*|\
937181ce1d0SOlaf Hering  --disable-dependency-tracking|\
938785c23aeSLuiz Capitulino  --sbindir=*|--sharedstatedir=*|\
939fe0038beSPaolo Bonzini  --oldincludedir=*|--datarootdir=*|--infodir=*|\
940023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
941023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
942023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
943023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
944023ddd74SMax Filippov    # lots of directory switches by default.
945023ddd74SMax Filippov  ;;
94635be72baSPaolo Bonzini  --disable-sdl) sdl="disabled"
94797a847bcSbellard  ;;
94835be72baSPaolo Bonzini  --enable-sdl) sdl="enabled"
949c4198157SJuan Quintela  ;;
95035be72baSPaolo Bonzini  --disable-sdl-image) sdl_image="disabled"
951a442fe2fSDaniel P. Berrangé  ;;
95235be72baSPaolo Bonzini  --enable-sdl-image) sdl_image="enabled"
953a442fe2fSDaniel P. Berrangé  ;;
9543556c233SPaolo Bonzini  --disable-qom-cast-debug) qom_cast_debug="no"
9553556c233SPaolo Bonzini  ;;
9563556c233SPaolo Bonzini  --enable-qom-cast-debug) qom_cast_debug="yes"
9573556c233SPaolo Bonzini  ;;
95869202b40SPaolo Bonzini  --disable-virtfs) virtfs="disabled"
959983eef5aSMeador Inge  ;;
96069202b40SPaolo Bonzini  --enable-virtfs) virtfs="enabled"
961983eef5aSMeador Inge  ;;
9625c53015aSPaolo Bonzini  --disable-libudev) libudev="disabled"
9635c53015aSPaolo Bonzini  ;;
9645c53015aSPaolo Bonzini  --enable-libudev) libudev="enabled"
9655c53015aSPaolo Bonzini  ;;
966cece116cSMisono Tomohiro  --disable-virtiofsd) virtiofsd="disabled"
967cece116cSMisono Tomohiro  ;;
968cece116cSMisono Tomohiro  --enable-virtiofsd) virtiofsd="enabled"
969cece116cSMisono Tomohiro  ;;
9706ec0e15dSPaolo Bonzini  --disable-mpath) mpath="disabled"
971fe8fc5aeSPaolo Bonzini  ;;
9726ec0e15dSPaolo Bonzini  --enable-mpath) mpath="enabled"
973fe8fc5aeSPaolo Bonzini  ;;
974a0b93237SPaolo Bonzini  --disable-vnc) vnc="disabled"
975821601eaSJes Sorensen  ;;
976a0b93237SPaolo Bonzini  --enable-vnc) vnc="enabled"
977821601eaSJes Sorensen  ;;
9780e8e77d4SAlex Bennée  --disable-gettext) gettext="disabled"
979e8f3bd71SMarc-André Lureau  ;;
9800e8e77d4SAlex Bennée  --enable-gettext) gettext="enabled"
981e8f3bd71SMarc-André Lureau  ;;
9820c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
9830c58ac1cSmalc  ;;
98489138857SStefan Weil  --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
985b64ec4e4SFam Zheng  ;;
98689138857SStefan Weil  --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
987eb852011SMarkus Armbruster  ;;
988e5f05f8cSKevin Wolf  --enable-block-drv-whitelist-in-tools) block_drv_whitelist_tools="yes"
989e5f05f8cSKevin Wolf  ;;
990e5f05f8cSKevin Wolf  --disable-block-drv-whitelist-in-tools) block_drv_whitelist_tools="no"
991e5f05f8cSKevin Wolf  ;;
992f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
993f8393946Saurel32  ;;
994f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
995f8393946Saurel32  ;;
996f3d08ee6SPaul Brook  --enable-debug)
997f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
998f3d08ee6SPaul Brook      debug_tcg="yes"
9991fcc6d42SPeter Xu      debug_mutex="yes"
1000f3d08ee6SPaul Brook      debug="yes"
1001f3d08ee6SPaul Brook      strip_opt="no"
1002b553a042SJohn Snow      fortify_source="no"
1003f3d08ee6SPaul Brook  ;;
1004247724cbSMarc-André Lureau  --enable-sanitizers) sanitizers="yes"
1005247724cbSMarc-André Lureau  ;;
1006247724cbSMarc-André Lureau  --disable-sanitizers) sanitizers="no"
1007247724cbSMarc-André Lureau  ;;
10080aebab04SLingfeng Yang  --enable-tsan) tsan="yes"
10090aebab04SLingfeng Yang  ;;
10100aebab04SLingfeng Yang  --disable-tsan) tsan="no"
10110aebab04SLingfeng Yang  ;;
1012deb62371SPaolo Bonzini  --enable-sparse) sparse="enabled"
101303b4fe7dSaliguori  ;;
1014deb62371SPaolo Bonzini  --disable-sparse) sparse="disabled"
101503b4fe7dSaliguori  ;;
10161625af87Saliguori  --disable-strip) strip_opt="no"
10171625af87Saliguori  ;;
1018a0b93237SPaolo Bonzini  --disable-vnc-sasl) vnc_sasl="disabled"
10192f9606b3Saliguori  ;;
1020a0b93237SPaolo Bonzini  --enable-vnc-sasl) vnc_sasl="enabled"
1021ea784e3bSJuan Quintela  ;;
1022a0b93237SPaolo Bonzini  --disable-vnc-jpeg) vnc_jpeg="disabled"
10232f6f5c7aSCorentin Chary  ;;
1024a0b93237SPaolo Bonzini  --enable-vnc-jpeg) vnc_jpeg="enabled"
10252f6f5c7aSCorentin Chary  ;;
1026a0b93237SPaolo Bonzini  --disable-vnc-png) vnc_png="disabled"
1027efe556adSCorentin Chary  ;;
1028a0b93237SPaolo Bonzini  --enable-vnc-png) vnc_png="enabled"
1029efe556adSCorentin Chary  ;;
10304d34a86bSPaolo Bonzini  --disable-slirp) slirp="disabled"
1031c20709aaSbellard  ;;
1032fd6fc214SPaolo Bonzini  --enable-slirp) slirp="enabled"
1033fd6fc214SPaolo Bonzini  ;;
10344d34a86bSPaolo Bonzini  --enable-slirp=git) slirp="internal"
10357c57bdd8SMarc-André Lureau  ;;
1036675b9b53SMarc-André Lureau  --enable-slirp=system) slirp="system"
1037675b9b53SMarc-André Lureau  ;;
1038e0e6c8c0Saliguori  --disable-vde) vde="no"
10398a16d273Sths  ;;
1040dfb278bdSJuan Quintela  --enable-vde) vde="yes"
1041dfb278bdSJuan Quintela  ;;
104258952137SVincenzo Maffione  --disable-netmap) netmap="no"
104358952137SVincenzo Maffione  ;;
104458952137SVincenzo Maffione  --enable-netmap) netmap="yes"
104558952137SVincenzo Maffione  ;;
10461badb709SPaolo Bonzini  --disable-xen) xen="disabled"
1047e37630caSaliguori  ;;
10481badb709SPaolo Bonzini  --enable-xen) xen="enabled"
1049fc321b4bSJuan Quintela  ;;
10501badb709SPaolo Bonzini  --disable-xen-pci-passthrough) xen_pci_passthrough="disabled"
1051eb6fda0fSAnthony PERARD  ;;
10521badb709SPaolo Bonzini  --enable-xen-pci-passthrough) xen_pci_passthrough="enabled"
1053eb6fda0fSAnthony PERARD  ;;
10548c6d4ff4SPaolo Bonzini  --disable-brlapi) brlapi="disabled"
10552e4d9fb1Saurel32  ;;
10568c6d4ff4SPaolo Bonzini  --enable-brlapi) brlapi="enabled"
10574ffcedb6SJuan Quintela  ;;
10581badb709SPaolo Bonzini  --disable-kvm) kvm="disabled"
10597ba1e619Saliguori  ;;
10601badb709SPaolo Bonzini  --enable-kvm) kvm="enabled"
1061b31a0277SJuan Quintela  ;;
10621badb709SPaolo Bonzini  --disable-hax) hax="disabled"
1063180fb750Szhanghailiang  ;;
10641badb709SPaolo Bonzini  --enable-hax) hax="enabled"
1065180fb750Szhanghailiang  ;;
10661badb709SPaolo Bonzini  --disable-hvf) hvf="disabled"
1067c97d6d2cSSergio Andres Gomez Del Real  ;;
10681badb709SPaolo Bonzini  --enable-hvf) hvf="enabled"
1069c97d6d2cSSergio Andres Gomez Del Real  ;;
107074a414a1SReinoud Zandijk  --disable-nvmm) nvmm="disabled"
107174a414a1SReinoud Zandijk  ;;
107274a414a1SReinoud Zandijk  --enable-nvmm) nvmm="enabled"
107374a414a1SReinoud Zandijk  ;;
10741badb709SPaolo Bonzini  --disable-whpx) whpx="disabled"
1075d661d9a4SJustin Terry (VM)  ;;
10761badb709SPaolo Bonzini  --enable-whpx) whpx="enabled"
1077d661d9a4SJustin Terry (VM)  ;;
1078c6fbea47SRichard Henderson  --disable-tcg-interpreter) tcg_interpreter="false"
10799195b2c2SStefan Weil  ;;
1080c6fbea47SRichard Henderson  --enable-tcg-interpreter) tcg_interpreter="true"
10819195b2c2SStefan Weil  ;;
1082727c8bb8SPaolo Bonzini  --disable-cap-ng)  cap_ng="disabled"
108347e98658SCorey Bryant  ;;
1084727c8bb8SPaolo Bonzini  --enable-cap-ng) cap_ng="enabled"
108547e98658SCorey Bryant  ;;
10861badb709SPaolo Bonzini  --disable-tcg) tcg="disabled"
1087d1a14257SAlex Bennée                 plugins="no"
1088b3f6ea7eSPaolo Bonzini  ;;
10891badb709SPaolo Bonzini  --enable-tcg) tcg="enabled"
1090b3f6ea7eSPaolo Bonzini  ;;
1091aa087962SPaolo Bonzini  --disable-malloc-trim) malloc_trim="disabled"
10925a22ab71SYang Zhong  ;;
1093aa087962SPaolo Bonzini  --enable-malloc-trim) malloc_trim="enabled"
10945a22ab71SYang Zhong  ;;
1095cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
1096cd4ec0b4SGerd Hoffmann  ;;
109758d3f3ffSGerd Hoffmann  --enable-spice)
109858d3f3ffSGerd Hoffmann      spice_protocol="yes"
109958d3f3ffSGerd Hoffmann      spice="yes"
110058d3f3ffSGerd Hoffmann  ;;
110158d3f3ffSGerd Hoffmann  --disable-spice-protocol)
110258d3f3ffSGerd Hoffmann      spice_protocol="no"
110358d3f3ffSGerd Hoffmann      spice="no"
110458d3f3ffSGerd Hoffmann  ;;
110558d3f3ffSGerd Hoffmann  --enable-spice-protocol) spice_protocol="yes"
1106cd4ec0b4SGerd Hoffmann  ;;
11079db405a3SPaolo Bonzini  --disable-libiscsi) libiscsi="disabled"
1108c589b249SRonnie Sahlberg  ;;
11099db405a3SPaolo Bonzini  --enable-libiscsi) libiscsi="enabled"
1110c589b249SRonnie Sahlberg  ;;
111130045c05SPaolo Bonzini  --disable-libnfs) libnfs="disabled"
11126542aa9cSPeter Lieven  ;;
111330045c05SPaolo Bonzini  --enable-libnfs) libnfs="enabled"
11146542aa9cSPeter Lieven  ;;
111505c2a3e7Sbellard  --enable-profiler) profiler="yes"
111605c2a3e7Sbellard  ;;
1117b4e312e9SPaolo Bonzini  --disable-cocoa) cocoa="disabled"
111814821030SPavel Borzenkov  ;;
1119a23a6789SPaolo Bonzini  --enable-cocoa) cocoa="enabled"
11205b0753e0Sbellard  ;;
1121cad25d69Spbrook  --disable-system) softmmu="no"
11220a8e90f4Spbrook  ;;
1123cad25d69Spbrook  --enable-system) softmmu="yes"
11240a8e90f4Spbrook  ;;
11250953a80fSZachary Amsden  --disable-user)
11260953a80fSZachary Amsden      linux_user="no" ;
11270953a80fSZachary Amsden      bsd_user="no" ;
11280953a80fSZachary Amsden  ;;
11290953a80fSZachary Amsden  --enable-user) ;;
1130831b7825Sths  --disable-linux-user) linux_user="no"
11310a8e90f4Spbrook  ;;
1132831b7825Sths  --enable-linux-user) linux_user="yes"
1133831b7825Sths  ;;
113484778508Sblueswir1  --disable-bsd-user) bsd_user="no"
113584778508Sblueswir1  ;;
113684778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
113784778508Sblueswir1  ;;
113840d6444eSAvi Kivity  --enable-pie) pie="yes"
113934005a00SKirill A. Shutemov  ;;
114040d6444eSAvi Kivity  --disable-pie) pie="no"
114134005a00SKirill A. Shutemov  ;;
114285aa5189Sbellard  --enable-werror) werror="yes"
114385aa5189Sbellard  ;;
114485aa5189Sbellard  --disable-werror) werror="no"
114585aa5189Sbellard  ;;
1146cdad781dSDaniele Buono  --enable-lto) lto="true"
1147cdad781dSDaniele Buono  ;;
1148cdad781dSDaniele Buono  --disable-lto) lto="false"
1149cdad781dSDaniele Buono  ;;
115063678e17SSteven Noonan  --enable-stack-protector) stack_protector="yes"
115163678e17SSteven Noonan  ;;
115263678e17SSteven Noonan  --disable-stack-protector) stack_protector="no"
115363678e17SSteven Noonan  ;;
11541e4f6065SDaniele Buono  --enable-safe-stack) safe_stack="yes"
11551e4f6065SDaniele Buono  ;;
11561e4f6065SDaniele Buono  --disable-safe-stack) safe_stack="no"
11571e4f6065SDaniele Buono  ;;
11589e62ba48SDaniele Buono  --enable-cfi)
11599e62ba48SDaniele Buono      cfi="true";
11609e62ba48SDaniele Buono      lto="true";
11619e62ba48SDaniele Buono  ;;
11629e62ba48SDaniele Buono  --disable-cfi) cfi="false"
11639e62ba48SDaniele Buono  ;;
11649e62ba48SDaniele Buono  --enable-cfi-debug) cfi_debug="true"
11659e62ba48SDaniele Buono  ;;
11669e62ba48SDaniele Buono  --disable-cfi-debug) cfi_debug="false"
11679e62ba48SDaniele Buono  ;;
11685285e593SYonggang Luo  --disable-curses) curses="disabled"
11694d3b6f6eSbalrog  ;;
11705285e593SYonggang Luo  --enable-curses) curses="enabled"
1171c584a6d0SJuan Quintela  ;;
11725285e593SYonggang Luo  --disable-iconv) iconv="disabled"
1173e08bb301SSamuel Thibault  ;;
11745285e593SYonggang Luo  --enable-iconv) iconv="enabled"
1175e08bb301SSamuel Thibault  ;;
1176f9cd86feSPaolo Bonzini  --disable-curl) curl="disabled"
1177769ce76dSAlexander Graf  ;;
1178f9cd86feSPaolo Bonzini  --enable-curl) curl="enabled"
1179788c8196SJuan Quintela  ;;
1180fbb4121dSPaolo Bonzini  --disable-fdt) fdt="disabled"
11812df87df7SJuan Quintela  ;;
1182fbb4121dSPaolo Bonzini  --enable-fdt) fdt="enabled"
1183fbb4121dSPaolo Bonzini  ;;
1184fbb4121dSPaolo Bonzini  --enable-fdt=git) fdt="internal"
1185fbb4121dSPaolo Bonzini  ;;
1186fbb4121dSPaolo Bonzini  --enable-fdt=system) fdt="system"
11872df87df7SJuan Quintela  ;;
11885c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
11895c6c3a6cSChristoph Hellwig  ;;
11905c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
11915c6c3a6cSChristoph Hellwig  ;;
119253c22b68SPaolo Bonzini  --disable-linux-io-uring) linux_io_uring="disabled"
1193c10dd856SAarushi Mehta  ;;
119453c22b68SPaolo Bonzini  --enable-linux-io-uring) linux_io_uring="enabled"
1195c10dd856SAarushi Mehta  ;;
1196f7f2d651SPaolo Bonzini  --disable-attr) attr="disabled"
1197758e8e38SVenkateswararao Jujjuri (JV)  ;;
1198f7f2d651SPaolo Bonzini  --enable-attr) attr="enabled"
1199758e8e38SVenkateswararao Jujjuri (JV)  ;;
1200a40161cbSPaolo Bonzini  --disable-membarrier) membarrier="no"
1201a40161cbSPaolo Bonzini  ;;
1202a40161cbSPaolo Bonzini  --enable-membarrier) membarrier="yes"
1203a40161cbSPaolo Bonzini  ;;
120446627f41SAndrew Melnychenko  --disable-bpf) bpf="disabled"
120546627f41SAndrew Melnychenko  ;;
120646627f41SAndrew Melnychenko  --enable-bpf) bpf="enabled"
120746627f41SAndrew Melnychenko  ;;
1208c8d5450bSPaolo Bonzini  --disable-blobs) blobs="false"
120977755340Sths  ;;
12107e563bfbSThomas Huth  --with-pkgversion=*) pkgversion="$optarg"
12114a19f1ecSpbrook  ;;
1212519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
1213519175a2SAlex Barcelo  ;;
121470c60c08SStefan Hajnoczi  --disable-coroutine-pool) coroutine_pool="no"
121570c60c08SStefan Hajnoczi  ;;
121670c60c08SStefan Hajnoczi  --enable-coroutine-pool) coroutine_pool="yes"
121770c60c08SStefan Hajnoczi  ;;
12187d992e4dSPeter Lieven  --enable-debug-stack-usage) debug_stack_usage="yes"
12197d992e4dSPeter Lieven  ;;
1220f0d92b56SLongpeng(Mike)  --enable-crypto-afalg) crypto_afalg="yes"
1221f0d92b56SLongpeng(Mike)  ;;
1222f0d92b56SLongpeng(Mike)  --disable-crypto-afalg) crypto_afalg="no"
1223f0d92b56SLongpeng(Mike)  ;;
1224e3667660SYonggang Luo  --disable-docs) docs="disabled"
122570ec5dc0SAnthony Liguori  ;;
1226e3667660SYonggang Luo  --enable-docs) docs="enabled"
122783a3ab8bSJuan Quintela  ;;
1228d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
1229d5970055SMichael S. Tsirkin  ;;
1230d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
1231d5970055SMichael S. Tsirkin  ;;
1232042cea27SGonglei  --disable-vhost-crypto) vhost_crypto="no"
1233042cea27SGonglei  ;;
1234299e6f19SPaolo Bonzini  --enable-vhost-crypto) vhost_crypto="yes"
1235042cea27SGonglei  ;;
12365e9be92dSNicholas Bellinger  --disable-vhost-scsi) vhost_scsi="no"
12375e9be92dSNicholas Bellinger  ;;
12385e9be92dSNicholas Bellinger  --enable-vhost-scsi) vhost_scsi="yes"
12395e9be92dSNicholas Bellinger  ;;
1240fc0b9b0eSStefan Hajnoczi  --disable-vhost-vsock) vhost_vsock="no"
1241fc0b9b0eSStefan Hajnoczi  ;;
1242fc0b9b0eSStefan Hajnoczi  --enable-vhost-vsock) vhost_vsock="yes"
1243fc0b9b0eSStefan Hajnoczi  ;;
1244e5e856c1SStefan Hajnoczi  --disable-vhost-user-blk-server) vhost_user_blk_server="disabled"
1245bc15e44cSStefan Hajnoczi  ;;
1246e5e856c1SStefan Hajnoczi  --enable-vhost-user-blk-server) vhost_user_blk_server="enabled"
1247bc15e44cSStefan Hajnoczi  ;;
124898fc1adaSDr. David Alan Gilbert  --disable-vhost-user-fs) vhost_user_fs="no"
124998fc1adaSDr. David Alan Gilbert  ;;
125098fc1adaSDr. David Alan Gilbert  --enable-vhost-user-fs) vhost_user_fs="yes"
125198fc1adaSDr. David Alan Gilbert  ;;
1252da076ffeSGerd Hoffmann  --disable-opengl) opengl="no"
125320ff075bSMichael Walle  ;;
1254da076ffeSGerd Hoffmann  --enable-opengl) opengl="yes"
125520ff075bSMichael Walle  ;;
1256fabd1e93SPaolo Bonzini  --disable-rbd) rbd="disabled"
1257f27aaf4bSChristian Brunner  ;;
1258fabd1e93SPaolo Bonzini  --enable-rbd) rbd="enabled"
1259f27aaf4bSChristian Brunner  ;;
12608c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
12618c84cf11SSergei Trofimovich  ;;
12628c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
12638c84cf11SSergei Trofimovich  ;;
12645f364c57SPaolo Bonzini  --disable-smartcard) smartcard="disabled"
1265111a38b0SRobert Relyea  ;;
12665f364c57SPaolo Bonzini  --enable-smartcard) smartcard="enabled"
1267111a38b0SRobert Relyea  ;;
12680a40bcb7SCésar Belley  --disable-u2f) u2f="disabled"
12690a40bcb7SCésar Belley  ;;
12700a40bcb7SCésar Belley  --enable-u2f) u2f="enabled"
12710a40bcb7SCésar Belley  ;;
127290540f32SPaolo Bonzini  --disable-libusb) libusb="disabled"
12732b2325ffSGerd Hoffmann  ;;
127490540f32SPaolo Bonzini  --enable-libusb) libusb="enabled"
12752b2325ffSGerd Hoffmann  ;;
127618f31e60SPaolo Bonzini  --disable-usb-redir) usb_redir="disabled"
127769354a83SHans de Goede  ;;
127818f31e60SPaolo Bonzini  --enable-usb-redir) usb_redir="enabled"
127969354a83SHans de Goede  ;;
12801ffb3bbbSPaolo Bonzini  --disable-zlib-test)
12811ece9905SAlon Levy  ;;
12820c32a0aeSPaolo Bonzini  --disable-lzo) lzo="disabled"
1283b25c9dffSStefan Weil  ;;
12840c32a0aeSPaolo Bonzini  --enable-lzo) lzo="enabled"
1285607dacd0Sqiaonuohan  ;;
1286241611eaSPaolo Bonzini  --disable-snappy) snappy="disabled"
1287b25c9dffSStefan Weil  ;;
1288241611eaSPaolo Bonzini  --enable-snappy) snappy="enabled"
1289607dacd0Sqiaonuohan  ;;
129029ba6116SPaolo Bonzini  --disable-bzip2) bzip2="disabled"
12916b383c08SPeter Wu  ;;
129229ba6116SPaolo Bonzini  --enable-bzip2) bzip2="enabled"
12936b383c08SPeter Wu  ;;
1294ecea3696SPaolo Bonzini  --enable-lzfse) lzfse="enabled"
129583bc1f97SJulio Faracco  ;;
1296ecea3696SPaolo Bonzini  --disable-lzfse) lzfse="disabled"
129783bc1f97SJulio Faracco  ;;
1298b1def33dSPaolo Bonzini  --disable-zstd) zstd="disabled"
12993a678481SJuan Quintela  ;;
1300b1def33dSPaolo Bonzini  --enable-zstd) zstd="enabled"
13013a678481SJuan Quintela  ;;
1302d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
1303d138cee9SMichael Roth  ;;
1304d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
1305d138cee9SMichael Roth  ;;
1306b846ab7cSPaolo Bonzini  --enable-guest-agent-msi) guest_agent_msi="enabled"
13079dacf32dSYossi Hindin  ;;
1308b846ab7cSPaolo Bonzini  --disable-guest-agent-msi) guest_agent_msi="disabled"
13099dacf32dSYossi Hindin  ;;
1310d9840e25STomoki Sekiyama  --with-vss-sdk) vss_win32_sdk=""
1311d9840e25STomoki Sekiyama  ;;
1312d9840e25STomoki Sekiyama  --with-vss-sdk=*) vss_win32_sdk="$optarg"
1313d9840e25STomoki Sekiyama  ;;
1314d9840e25STomoki Sekiyama  --without-vss-sdk) vss_win32_sdk="no"
1315d9840e25STomoki Sekiyama  ;;
1316d9840e25STomoki Sekiyama  --with-win-sdk) win_sdk=""
1317d9840e25STomoki Sekiyama  ;;
1318d9840e25STomoki Sekiyama  --with-win-sdk=*) win_sdk="$optarg"
1319d9840e25STomoki Sekiyama  ;;
1320d9840e25STomoki Sekiyama  --without-win-sdk) win_sdk="no"
1321d9840e25STomoki Sekiyama  ;;
13224b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
13234b1c11fdSDaniel P. Berrange  ;;
13244b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
13254b1c11fdSDaniel P. Berrange  ;;
132690835c2bSPaolo Bonzini  --enable-seccomp) seccomp="enabled"
1327f794573eSEduardo Otubo  ;;
132890835c2bSPaolo Bonzini  --disable-seccomp) seccomp="disabled"
1329f794573eSEduardo Otubo  ;;
133008821ca2SPaolo Bonzini  --disable-glusterfs) glusterfs="disabled"
1331eb100396SBharata B Rao  ;;
133286583a07SLiam Merwick  --disable-avx2) avx2_opt="no"
133386583a07SLiam Merwick  ;;
133486583a07SLiam Merwick  --enable-avx2) avx2_opt="yes"
133586583a07SLiam Merwick  ;;
13366b8cd447SRobert Hoo  --disable-avx512f) avx512f_opt="no"
13376b8cd447SRobert Hoo  ;;
13386b8cd447SRobert Hoo  --enable-avx512f) avx512f_opt="yes"
13396b8cd447SRobert Hoo  ;;
13406b8cd447SRobert Hoo
134108821ca2SPaolo Bonzini  --enable-glusterfs) glusterfs="enabled"
1342eb100396SBharata B Rao  ;;
134352b53c04SFam Zheng  --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
134452b53c04SFam Zheng      echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1345583f6e7bSStefan Hajnoczi  ;;
1346cb6414dfSFam Zheng  --enable-vhdx|--disable-vhdx)
1347cb6414dfSFam Zheng      echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1348cb6414dfSFam Zheng  ;;
1349315d3184SFam Zheng  --enable-uuid|--disable-uuid)
1350315d3184SFam Zheng      echo "$0: $opt is obsolete, UUID support is always built" >&2
1351315d3184SFam Zheng  ;;
13521b695471SPaolo Bonzini  --disable-gtk) gtk="disabled"
1353a4ccabcfSAnthony Liguori  ;;
13541b695471SPaolo Bonzini  --enable-gtk) gtk="enabled"
1355a4ccabcfSAnthony Liguori  ;;
1356a1c5e949SDaniel P. Berrange  --tls-priority=*) tls_priority="$optarg"
1357a1c5e949SDaniel P. Berrange  ;;
135857612511SPaolo Bonzini  --disable-gnutls) gnutls="disabled"
1359ddbb0d09SDaniel P. Berrange  ;;
136057612511SPaolo Bonzini  --enable-gnutls) gnutls="enabled"
1361ddbb0d09SDaniel P. Berrange  ;;
136257612511SPaolo Bonzini  --disable-nettle) nettle="disabled"
136391bfcdb0SDaniel P. Berrange  ;;
136457612511SPaolo Bonzini  --enable-nettle) nettle="enabled"
136591bfcdb0SDaniel P. Berrange  ;;
136657612511SPaolo Bonzini  --disable-gcrypt) gcrypt="disabled"
136791bfcdb0SDaniel P. Berrange  ;;
136857612511SPaolo Bonzini  --enable-gcrypt) gcrypt="enabled"
136991bfcdb0SDaniel P. Berrange  ;;
137005e391aeSPaolo Bonzini  --disable-auth-pam) auth_pam="disabled"
13718953caf3SDaniel P. Berrange  ;;
137205e391aeSPaolo Bonzini  --enable-auth-pam) auth_pam="enabled"
13738953caf3SDaniel P. Berrange  ;;
13742da776dbSMichael R. Hines  --enable-rdma) rdma="yes"
13752da776dbSMichael R. Hines  ;;
13762da776dbSMichael R. Hines  --disable-rdma) rdma="no"
13772da776dbSMichael R. Hines  ;;
137821ab34c9SMarcel Apfelbaum  --enable-pvrdma) pvrdma="yes"
137921ab34c9SMarcel Apfelbaum  ;;
138021ab34c9SMarcel Apfelbaum  --disable-pvrdma) pvrdma="no"
138121ab34c9SMarcel Apfelbaum  ;;
1382c23d7b4eSPaolo Bonzini  --disable-vte) vte="disabled"
1383bbbf9bfbSStefan Weil  ;;
1384c23d7b4eSPaolo Bonzini  --enable-vte) vte="enabled"
1385bbbf9bfbSStefan Weil  ;;
1386587d59d6SPaolo Bonzini  --disable-virglrenderer) virglrenderer="disabled"
13879d9e1521SGerd Hoffmann  ;;
1388587d59d6SPaolo Bonzini  --enable-virglrenderer) virglrenderer="enabled"
13899d9e1521SGerd Hoffmann  ;;
1390e91c793cSCole Robinson  --disable-tpm) tpm="no"
1391e91c793cSCole Robinson  ;;
1392ab214c29SStefan Berger  --enable-tpm) tpm="yes"
1393ab214c29SStefan Berger  ;;
1394b10d49d7SPino Toscano  --disable-libssh) libssh="no"
13950a12ec87SRichard W.M. Jones  ;;
1396b10d49d7SPino Toscano  --enable-libssh) libssh="yes"
13970a12ec87SRichard W.M. Jones  ;;
1398ed1701c6SDr. David Alan Gilbert  --disable-live-block-migration) live_block_migration="no"
1399ed1701c6SDr. David Alan Gilbert  ;;
1400ed1701c6SDr. David Alan Gilbert  --enable-live-block-migration) live_block_migration="yes"
1401ed1701c6SDr. David Alan Gilbert  ;;
1402a99d57bbSWanlong Gao  --disable-numa) numa="no"
1403a99d57bbSWanlong Gao  ;;
1404a99d57bbSWanlong Gao  --enable-numa) numa="yes"
1405a99d57bbSWanlong Gao  ;;
1406c5b36c25SPaolo Bonzini  --disable-libxml2) libxml2="disabled"
1407ed279a06SKlim Kireev  ;;
1408c5b36c25SPaolo Bonzini  --enable-libxml2) libxml2="enabled"
1409ed279a06SKlim Kireev  ;;
14102847b469SFam Zheng  --disable-tcmalloc) tcmalloc="no"
14112847b469SFam Zheng  ;;
14122847b469SFam Zheng  --enable-tcmalloc) tcmalloc="yes"
14132847b469SFam Zheng  ;;
14147b01cb97SAlexandre Derumier  --disable-jemalloc) jemalloc="no"
14157b01cb97SAlexandre Derumier  ;;
14167b01cb97SAlexandre Derumier  --enable-jemalloc) jemalloc="yes"
14177b01cb97SAlexandre Derumier  ;;
1418a6b1d4c0SChanglong Xie  --disable-replication) replication="no"
1419a6b1d4c0SChanglong Xie  ;;
1420a6b1d4c0SChanglong Xie  --enable-replication) replication="yes"
1421a6b1d4c0SChanglong Xie  ;;
14222f740136SJeff Cody  --disable-bochs) bochs="no"
14232f740136SJeff Cody  ;;
14242f740136SJeff Cody  --enable-bochs) bochs="yes"
14252f740136SJeff Cody  ;;
14262f740136SJeff Cody  --disable-cloop) cloop="no"
14272f740136SJeff Cody  ;;
14282f740136SJeff Cody  --enable-cloop) cloop="yes"
14292f740136SJeff Cody  ;;
14302f740136SJeff Cody  --disable-dmg) dmg="no"
14312f740136SJeff Cody  ;;
14322f740136SJeff Cody  --enable-dmg) dmg="yes"
14332f740136SJeff Cody  ;;
14342f740136SJeff Cody  --disable-qcow1) qcow1="no"
14352f740136SJeff Cody  ;;
14362f740136SJeff Cody  --enable-qcow1) qcow1="yes"
14372f740136SJeff Cody  ;;
14382f740136SJeff Cody  --disable-vdi) vdi="no"
14392f740136SJeff Cody  ;;
14402f740136SJeff Cody  --enable-vdi) vdi="yes"
14412f740136SJeff Cody  ;;
14422f740136SJeff Cody  --disable-vvfat) vvfat="no"
14432f740136SJeff Cody  ;;
14442f740136SJeff Cody  --enable-vvfat) vvfat="yes"
14452f740136SJeff Cody  ;;
14462f740136SJeff Cody  --disable-qed) qed="no"
14472f740136SJeff Cody  ;;
14482f740136SJeff Cody  --enable-qed) qed="yes"
14492f740136SJeff Cody  ;;
14502f740136SJeff Cody  --disable-parallels) parallels="no"
14512f740136SJeff Cody  ;;
14522f740136SJeff Cody  --enable-parallels) parallels="yes"
14532f740136SJeff Cody  ;;
1454e6a74868SMarc-André Lureau  --disable-vhost-user) vhost_user="no"
1455e6a74868SMarc-André Lureau  ;;
1456299e6f19SPaolo Bonzini  --enable-vhost-user) vhost_user="yes"
1457299e6f19SPaolo Bonzini  ;;
1458108a6481SCindy Lu  --disable-vhost-vdpa) vhost_vdpa="no"
1459108a6481SCindy Lu  ;;
1460108a6481SCindy Lu  --enable-vhost-vdpa) vhost_vdpa="yes"
1461108a6481SCindy Lu  ;;
1462299e6f19SPaolo Bonzini  --disable-vhost-kernel) vhost_kernel="no"
1463299e6f19SPaolo Bonzini  ;;
1464299e6f19SPaolo Bonzini  --enable-vhost-kernel) vhost_kernel="yes"
1465e6a74868SMarc-André Lureau  ;;
14668b18cdbfSRichard Henderson  --disable-capstone) capstone="disabled"
14678ca80760SRichard Henderson  ;;
14688b18cdbfSRichard Henderson  --enable-capstone) capstone="enabled"
14698ca80760SRichard Henderson  ;;
14708b18cdbfSRichard Henderson  --enable-capstone=git) capstone="internal"
1471e219c499SRichard Henderson  ;;
1472e219c499SRichard Henderson  --enable-capstone=system) capstone="system"
1473e219c499SRichard Henderson  ;;
1474cc84d63aSDaniel P. Berrange  --with-git=*) git="$optarg"
1475cc84d63aSDaniel P. Berrange  ;;
14767d7dbf9dSDan Streetman  --enable-git-update)
14777d7dbf9dSDan Streetman      git_submodules_action="update"
14787d7dbf9dSDan Streetman      echo "--enable-git-update deprecated, use --with-git-submodules=update"
1479f62bbee5SDaniel P. Berrange  ;;
14807d7dbf9dSDan Streetman  --disable-git-update)
14817d7dbf9dSDan Streetman      git_submodules_action="validate"
14827d7dbf9dSDan Streetman      echo "--disable-git-update deprecated, use --with-git-submodules=validate"
14837d7dbf9dSDan Streetman  ;;
14847d7dbf9dSDan Streetman  --with-git-submodules=*)
14857d7dbf9dSDan Streetman      git_submodules_action="$optarg"
1486f62bbee5SDaniel P. Berrange  ;;
1487ba59fb77SPaolo Bonzini  --enable-debug-mutex) debug_mutex=yes
1488ba59fb77SPaolo Bonzini  ;;
1489ba59fb77SPaolo Bonzini  --disable-debug-mutex) debug_mutex=no
1490ba59fb77SPaolo Bonzini  ;;
14915cd5d8a7SMiroslav Rezanina  --enable-libpmem) libpmem="enabled"
149217824406SJunyan He  ;;
14935cd5d8a7SMiroslav Rezanina  --disable-libpmem) libpmem="disabled"
149417824406SJunyan He  ;;
14954113f4cfSLaurent Vivier  --enable-xkbcommon) xkbcommon="enabled"
149675411919SJames Le Cuirot  ;;
14974113f4cfSLaurent Vivier  --disable-xkbcommon) xkbcommon="disabled"
149875411919SJames Le Cuirot  ;;
14999b8e4298SAlex Bennée  --enable-plugins) if test "$mingw32" = "yes"; then
15009b8e4298SAlex Bennée                        error_exit "TCG plugins not currently supported on Windows platforms"
15019b8e4298SAlex Bennée                    else
15029b8e4298SAlex Bennée                        plugins="yes"
15039b8e4298SAlex Bennée                    fi
150440e8c6f4SAlex Bennée  ;;
150540e8c6f4SAlex Bennée  --disable-plugins) plugins="no"
150640e8c6f4SAlex Bennée  ;;
1507afc3a8f9SAlex Bennée  --enable-containers) use_containers="yes"
1508afc3a8f9SAlex Bennée  ;;
1509afc3a8f9SAlex Bennée  --disable-containers) use_containers="no"
1510afc3a8f9SAlex Bennée  ;;
1511adc28027SAlexander Bulekov  --enable-fuzzing) fuzzing=yes
1512adc28027SAlexander Bulekov  ;;
1513adc28027SAlexander Bulekov  --disable-fuzzing) fuzzing=no
1514adc28027SAlexander Bulekov  ;;
1515f48e590aSAlex Bennée  --gdb=*) gdb_bin="$optarg"
1516f48e590aSAlex Bennée  ;;
1517b767d257SMarek Marczykowski-Górecki  --enable-rng-none) rng_none=yes
1518b767d257SMarek Marczykowski-Górecki  ;;
1519b767d257SMarek Marczykowski-Górecki  --disable-rng-none) rng_none=no
1520b767d257SMarek Marczykowski-Górecki  ;;
152154e7aac0SAlexey Krasikov  --enable-keyring) secret_keyring="yes"
152254e7aac0SAlexey Krasikov  ;;
152354e7aac0SAlexey Krasikov  --disable-keyring) secret_keyring="no"
152454e7aac0SAlexey Krasikov  ;;
152512033e16SMiroslav Rezanina  --enable-libdaxctl) libdaxctl="enabled"
152621b2eca6SJingqi Liu  ;;
152712033e16SMiroslav Rezanina  --disable-libdaxctl) libdaxctl="disabled"
152821b2eca6SJingqi Liu  ;;
1529a484a719SMax Reitz  --enable-fuse) fuse="enabled"
1530a484a719SMax Reitz  ;;
1531a484a719SMax Reitz  --disable-fuse) fuse="disabled"
1532a484a719SMax Reitz  ;;
1533df4ea709SMax Reitz  --enable-fuse-lseek) fuse_lseek="enabled"
1534df4ea709SMax Reitz  ;;
1535df4ea709SMax Reitz  --disable-fuse-lseek) fuse_lseek="disabled"
1536df4ea709SMax Reitz  ;;
1537106ad1f9SPaolo Bonzini  --enable-multiprocess) multiprocess="enabled"
15383090de69SJagannathan Raman  ;;
1539106ad1f9SPaolo Bonzini  --disable-multiprocess) multiprocess="disabled"
15403090de69SJagannathan Raman  ;;
154120cf7b8eSDenis Plotnikov  --enable-gio) gio=yes
154220cf7b8eSDenis Plotnikov  ;;
154320cf7b8eSDenis Plotnikov  --disable-gio) gio=no
154420cf7b8eSDenis Plotnikov  ;;
1545b8e0c493SJoelle van Dyne  --enable-slirp-smbd) slirp_smbd=yes
1546b8e0c493SJoelle van Dyne  ;;
1547b8e0c493SJoelle van Dyne  --disable-slirp-smbd) slirp_smbd=no
1548b8e0c493SJoelle van Dyne  ;;
15492d2ad6d0SFam Zheng  *)
15502d2ad6d0SFam Zheng      echo "ERROR: unknown option $opt"
15512d2ad6d0SFam Zheng      echo "Try '$0 --help' for more information"
15522d2ad6d0SFam Zheng      exit 1
15537f1559c6Sbalrog  ;;
15547d13299dSbellard  esac
15557d13299dSbellarddone
15567d13299dSbellard
1557d1a14257SAlex Bennée# test for any invalid configuration combinations
1558d1a14257SAlex Bennéeif test "$plugins" = "yes" -a "$tcg" = "disabled"; then
1559d1a14257SAlex Bennée    error_exit "Can't enable plugins on non-TCG builds"
1560d1a14257SAlex Bennéefi
1561d1a14257SAlex Bennée
15627d7dbf9dSDan Streetmancase $git_submodules_action in
15637d7dbf9dSDan Streetman    update|validate)
15647d7dbf9dSDan Streetman        if test ! -e "$source_path/.git"; then
15657d7dbf9dSDan Streetman            echo "ERROR: cannot $git_submodules_action git submodules without .git"
15667d7dbf9dSDan Streetman            exit 1
15677d7dbf9dSDan Streetman        fi
15687d7dbf9dSDan Streetman    ;;
15697d7dbf9dSDan Streetman    ignore)
1570b80fd281SPaolo Bonzini        if ! test -f "$source_path/ui/keycodemapdb/README"
1571b80fd281SPaolo Bonzini        then
1572b80fd281SPaolo Bonzini            echo
1573b80fd281SPaolo Bonzini            echo "ERROR: missing GIT submodules"
1574b80fd281SPaolo Bonzini            echo
1575b80fd281SPaolo Bonzini            if test -e "$source_path/.git"; then
1576b80fd281SPaolo Bonzini                echo "--with-git-submodules=ignore specified but submodules were not"
1577b80fd281SPaolo Bonzini                echo "checked out.  Please initialize and update submodules."
1578b80fd281SPaolo Bonzini            else
1579b80fd281SPaolo Bonzini                echo "This is not a GIT checkout but module content appears to"
1580b80fd281SPaolo Bonzini                echo "be missing. Do not use 'git archive' or GitHub download links"
1581b80fd281SPaolo Bonzini                echo "to acquire QEMU source archives. Non-GIT builds are only"
1582b80fd281SPaolo Bonzini                echo "supported with source archives linked from:"
1583b80fd281SPaolo Bonzini                echo
1584b80fd281SPaolo Bonzini                echo "  https://www.qemu.org/download/#source"
1585b80fd281SPaolo Bonzini                echo
1586b80fd281SPaolo Bonzini                echo "Developers working with GIT can use scripts/archive-source.sh"
1587b80fd281SPaolo Bonzini                echo "if they need to create valid source archives."
1588b80fd281SPaolo Bonzini            fi
1589b80fd281SPaolo Bonzini            echo
1590b80fd281SPaolo Bonzini            exit 1
1591b80fd281SPaolo Bonzini        fi
15927d7dbf9dSDan Streetman    ;;
15937d7dbf9dSDan Streetman    *)
15947d7dbf9dSDan Streetman        echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'"
15957d7dbf9dSDan Streetman        exit 1
15967d7dbf9dSDan Streetman    ;;
15977d7dbf9dSDan Streetmanesac
15987d7dbf9dSDan Streetman
159922a87800SMarc-André Lureaulibdir="${libdir:-$prefix/lib}"
160022a87800SMarc-André Lureaulibexecdir="${libexecdir:-$prefix/libexec}"
160122a87800SMarc-André Lureauincludedir="${includedir:-$prefix/include}"
160222a87800SMarc-André Lureau
160322a87800SMarc-André Lureauif test "$mingw32" = "yes" ; then
160415588a62SJoshua Watt    bindir="${bindir:-$prefix}"
160522a87800SMarc-André Lureauelse
160615588a62SJoshua Watt    bindir="${bindir:-$prefix/bin}"
160715588a62SJoshua Wattfi
160822a87800SMarc-André Lureaumandir="${mandir:-$prefix/share/man}"
160922a87800SMarc-André Lureaudatadir="${datadir:-$prefix/share}"
1610ca8c0909SMarc-André Lureaudocdir="${docdir:-$prefix/share/doc}"
161122a87800SMarc-André Lureausysconfdir="${sysconfdir:-$prefix/etc}"
161222a87800SMarc-André Lureaulocal_statedir="${local_statedir:-$prefix/var}"
161316bf7a33SPaolo Bonzinifirmwarepath="${firmwarepath:-$datadir/qemu-firmware}"
161416bf7a33SPaolo Bonzinilocaledir="${localedir:-$datadir/locale}"
161522a87800SMarc-André Lureau
161640293e58Sbellardcase "$cpu" in
1617e3608d66SRichard Henderson    ppc)
1618e3608d66SRichard Henderson           CPU_CFLAGS="-m32"
1619db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m32 $QEMU_LDFLAGS"
1620e3608d66SRichard Henderson           ;;
1621e3608d66SRichard Henderson    ppc64)
1622e3608d66SRichard Henderson           CPU_CFLAGS="-m64"
1623db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
1624e3608d66SRichard Henderson           ;;
16259b9c37c3SRichard Henderson    sparc)
1626f1079bb8SRichard Henderson           CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
1627db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m32 -mv8plus $QEMU_LDFLAGS"
16283142255cSblueswir1           ;;
1629ed968ff1SJuan Quintela    sparc64)
163079f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1631db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
16323142255cSblueswir1           ;;
163376d83bdeSths    s390)
1634061cdd81SRichard Henderson           CPU_CFLAGS="-m31"
1635db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m31 $QEMU_LDFLAGS"
163628d7cc49SRichard Henderson           ;;
163728d7cc49SRichard Henderson    s390x)
1638061cdd81SRichard Henderson           CPU_CFLAGS="-m64"
1639db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
164076d83bdeSths           ;;
164140293e58Sbellard    i386)
164279f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32"
1643db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m32 $QEMU_LDFLAGS"
164440293e58Sbellard           ;;
164540293e58Sbellard    x86_64)
16467ebee43eSRichard Henderson           # ??? Only extremely old AMD cpus do not have cmpxchg16b.
16477ebee43eSRichard Henderson           # If we truly care, we should simply detect this case at
16487ebee43eSRichard Henderson           # runtime and generate the fallback to serial emulation.
16497ebee43eSRichard Henderson           CPU_CFLAGS="-m64 -mcx16"
1650db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
1651379f6698SPaul Brook           ;;
1652c72b26ecSRichard Henderson    x32)
1653c72b26ecSRichard Henderson           CPU_CFLAGS="-mx32"
1654db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-mx32 $QEMU_LDFLAGS"
1655c72b26ecSRichard Henderson           ;;
165630163d89SPeter Maydell    # No special flags required for other host CPUs
16573142255cSblueswir1esac
16583142255cSblueswir1
16599557af9cSAlex Bennéeif eval test -z "\${cross_cc_$cpu}"; then
1660b1aa4de1SAlex Bennée    eval "cross_cc_${cpu}=\$cc"
16612038f8c8SPaolo Bonzini    cross_cc_vars="$cross_cc_vars cross_cc_${cpu}"
16629557af9cSAlex Bennéefi
166379f3b12fSPeter Crosthwaite
1664affc88ccSPeter Maydell# For user-mode emulation the host arch has to be one we explicitly
1665affc88ccSPeter Maydell# support, even if we're using TCI.
1666affc88ccSPeter Maydellif [ "$ARCH" = "unknown" ]; then
1667affc88ccSPeter Maydell  bsd_user="no"
1668affc88ccSPeter Maydell  linux_user="no"
1669affc88ccSPeter Maydellfi
1670affc88ccSPeter Maydell
167160e0df25SPeter Maydelldefault_target_list=""
167243692239SMarkus Armbrusterdeprecated_targets_list=ppc64abi32-linux-user
1673fdb75aefSPaolo Bonzinideprecated_features=""
16746e92f823SPeter Maydellmak_wilds=""
16756e92f823SPeter Maydell
167660e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then
1677812b31d3SAlex Bennée    mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak"
167860e0df25SPeter Maydellfi
167960e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then
1680812b31d3SAlex Bennée    mak_wilds="${mak_wilds} $source_path/configs/targets/*-linux-user.mak"
168160e0df25SPeter Maydellfi
168260e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then
1683812b31d3SAlex Bennée    mak_wilds="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak"
168460e0df25SPeter Maydellfi
168560e0df25SPeter Maydell
16863a5ae4a9SAlex Bennée# If the user doesn't explicitly specify a deprecated target we will
16873a5ae4a9SAlex Bennée# skip it.
16883a5ae4a9SAlex Bennéeif test -z "$target_list"; then
16893a5ae4a9SAlex Bennée    if test -z "$target_list_exclude"; then
16903a5ae4a9SAlex Bennée        target_list_exclude="$deprecated_targets_list"
16913a5ae4a9SAlex Bennée    else
16923a5ae4a9SAlex Bennée        target_list_exclude="$target_list_exclude,$deprecated_targets_list"
16933a5ae4a9SAlex Bennée    fi
16942d838d9bSAlex Bennéefi
16952d838d9bSAlex Bennée
1696447e133fSAlex Bennéefor config in $mak_wilds; do
1697447e133fSAlex Bennée    target="$(basename "$config" .mak)"
169898db9a06SAlex Bennée    if echo "$target_list_exclude" | grep -vq "$target"; then
1699447e133fSAlex Bennée        default_target_list="${default_target_list} $target"
1700447e133fSAlex Bennée    fi
1701447e133fSAlex Bennéedone
17026e92f823SPeter Maydell
1703c53eeaf7SStefan Hajnoczi# Enumerate public trace backends for --help output
170464a6047dSGreg Kurztrace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
1705c53eeaf7SStefan Hajnoczi
1706af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1707af5db58eSpbrookcat << EOF
1708af5db58eSpbrook
1709af5db58eSpbrookUsage: configure [options]
1710af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1711af5db58eSpbrook
171208fb77edSStefan WeilStandard options:
171308fb77edSStefan Weil  --help                   print this message
171408fb77edSStefan Weil  --prefix=PREFIX          install in PREFIX [$prefix]
171508fb77edSStefan Weil  --interp-prefix=PREFIX   where to find shared libraries, etc.
171608fb77edSStefan Weil                           use %M for cpu name [$interp_prefix]
17172deca810SAlex Bennée  --target-list=LIST       set target list (default: build all non-deprecated)
171808fb77edSStefan Weil$(echo Available targets: $default_target_list | \
171908fb77edSStefan Weil  fold -s -w 53 | sed -e 's/^/                           /')
17202deca810SAlex Bennée$(echo Deprecated targets: $deprecated_targets_list | \
17212deca810SAlex Bennée  fold -s -w 53 | sed -e 's/^/                           /')
1722447e133fSAlex Bennée  --target-list-exclude=LIST exclude a set of targets from the default target-list
172308fb77edSStefan Weil
172408fb77edSStefan WeilAdvanced options (experts only):
17253812c0c4SJoelle van Dyne  --cross-prefix=PREFIX    use PREFIX for compile tools, PREFIX can be blank [$cross_prefix]
172608fb77edSStefan Weil  --cc=CC                  use C compiler CC [$cc]
172708fb77edSStefan Weil  --iasl=IASL              use ACPI compiler IASL [$iasl]
172808fb77edSStefan Weil  --host-cc=CC             use C compiler CC [$host_cc] for code run at
172908fb77edSStefan Weil                           build time
173008fb77edSStefan Weil  --cxx=CXX                use C++ compiler CXX [$cxx]
173108fb77edSStefan Weil  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]
173208fb77edSStefan Weil  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS
173311cde1c8SBruno Dominguez  --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
173408fb77edSStefan Weil  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
1735d75402b5SAlex Bennée  --cross-cc-ARCH=CC       use compiler when building ARCH guest test cases
1736d422b2bcSAlex Bennée  --cross-cc-flags-ARCH=   use compiler flags when building ARCH guest tests
173708fb77edSStefan Weil  --make=MAKE              use specified make [$make]
173808fb77edSStefan Weil  --python=PYTHON          use specified python [$python]
17392eb054c2SPeter Maydell  --sphinx-build=SPHINX    use specified sphinx-build [$sphinx_build]
1740a5665051SPaolo Bonzini  --meson=MESON            use specified meson [$meson]
174148328880SPaolo Bonzini  --ninja=NINJA            use specified ninja [$ninja]
174208fb77edSStefan Weil  --smbd=SMBD              use specified smbd [$smbd]
1743db1b5f13SThomas Huth  --with-git=GIT           use specified git [$git]
17447d7dbf9dSDan Streetman  --with-git-submodules=update   update git submodules (default if .git dir exists)
17457d7dbf9dSDan Streetman  --with-git-submodules=validate fail if git submodules are not up to date
17467d7dbf9dSDan Streetman  --with-git-submodules=ignore   do not update or check git submodules (default if no .git dir)
174708fb77edSStefan Weil  --static                 enable static build [$static]
174808fb77edSStefan Weil  --mandir=PATH            install man pages in PATH
174910ff82d1SMarc-André Lureau  --datadir=PATH           install firmware in PATH/$qemu_suffix
1750fe0038beSPaolo Bonzini  --localedir=PATH         install translation in PATH/$qemu_suffix
175110ff82d1SMarc-André Lureau  --docdir=PATH            install documentation in PATH/$qemu_suffix
175208fb77edSStefan Weil  --bindir=PATH            install binaries in PATH
175308fb77edSStefan Weil  --libdir=PATH            install libraries in PATH
1754db1b5f13SThomas Huth  --libexecdir=PATH        install helper binaries in PATH
175510ff82d1SMarc-André Lureau  --sysconfdir=PATH        install config in PATH/$qemu_suffix
175608fb77edSStefan Weil  --localstatedir=PATH     install local state in PATH (set at runtime on win32)
17573d5eecabSGerd Hoffmann  --firmwarepath=PATH      search PATH for firmware files
175813336606SRobert Foley  --efi-aarch64=PATH       PATH of efi file to use for aarch64 VMs.
1759ca8c0909SMarc-André Lureau  --with-suffix=SUFFIX     suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix]
1760db1b5f13SThomas Huth  --with-pkgversion=VERS   use specified string as sub-version of the package
1761c035c8d6SPaolo Bonzini  --without-default-features default all --enable-* options to "disabled"
1762c035c8d6SPaolo Bonzini  --without-default-devices  do not include any device that is not needed to
1763c035c8d6SPaolo Bonzini                           start the emulator (only use if you are including
1764d1d5e9eeSAlex Bennée                           desired devices in configs/devices/)
1765d1d5e9eeSAlex Bennée  --with-devices-ARCH=NAME override default configs/devices
176608fb77edSStefan Weil  --enable-debug           enable common debug build options
1767247724cbSMarc-André Lureau  --enable-sanitizers      enable default sanitizers
17680aebab04SLingfeng Yang  --enable-tsan            enable thread sanitizer
176908fb77edSStefan Weil  --disable-strip          disable stripping binaries
177008fb77edSStefan Weil  --disable-werror         disable compilation abort on warning
177163678e17SSteven Noonan  --disable-stack-protector disable compiler-provided stack protection
1772*87430d5bSPaolo Bonzini  --audio-drv-list=LIST    set audio drivers list
177308fb77edSStefan Weil  --block-drv-whitelist=L  Same as --block-drv-rw-whitelist=L
177408fb77edSStefan Weil  --block-drv-rw-whitelist=L
177508fb77edSStefan Weil                           set block driver read-write whitelist
1776e5f05f8cSKevin Wolf                           (by default affects only QEMU, not tools like qemu-img)
177708fb77edSStefan Weil  --block-drv-ro-whitelist=L
177808fb77edSStefan Weil                           set block driver read-only whitelist
1779e5f05f8cSKevin Wolf                           (by default affects only QEMU, not tools like qemu-img)
1780e5f05f8cSKevin Wolf  --enable-block-drv-whitelist-in-tools
1781e5f05f8cSKevin Wolf                           use block whitelist also in tools instead of only QEMU
17825b808275SLluís Vilanova  --enable-trace-backends=B Set trace backend
1783c53eeaf7SStefan Hajnoczi                           Available backends: $trace_backend_list
178408fb77edSStefan Weil  --with-trace-file=NAME   Full PATH,NAME of file to store traces
178508fb77edSStefan Weil                           Default:trace-<pid>
1786c23f23b9SMichael Tokarev  --disable-slirp          disable SLIRP userspace network connectivity
1787e9a16e38SPhilippe Mathieu-Daudé  --enable-tcg-interpreter enable TCI (TCG with bytecode interpreter, experimental and slow)
17885a22ab71SYang Zhong  --enable-malloc-trim     enable libc malloc_trim() for memory optimization
1789c23f23b9SMichael Tokarev  --cpu=CPU                Build for host CPU [$cpu]
179008fb77edSStefan Weil  --with-coroutine=BACKEND coroutine backend. Supported options:
179133c53c54SDaniel P. Berrange                           ucontext, sigaltstack, windows
179208fb77edSStefan Weil  --enable-gcov            enable test coverage analysis with gcov
1793c23f23b9SMichael Tokarev  --disable-blobs          disable installing provided firmware blobs
1794c23f23b9SMichael Tokarev  --with-vss-sdk=SDK-path  enable Windows VSS support in QEMU Guest Agent
1795c23f23b9SMichael Tokarev  --with-win-sdk=SDK-path  path to Windows Platform SDK (to build VSS .tlb)
1796a1c5e949SDaniel P. Berrange  --tls-priority           default TLS protocol/cipher priority string
1797c12d66aaSLin Ma  --enable-gprof           QEMU profiling with gprof
1798c12d66aaSLin Ma  --enable-profiler        profiler support
1799c12d66aaSLin Ma  --enable-debug-stack-usage
1800c12d66aaSLin Ma                           track the maximum stack usage of stacks created by qemu_alloc_stack
180140e8c6f4SAlex Bennée  --enable-plugins
180240e8c6f4SAlex Bennée                           enable plugins via shared library loading
1803afc3a8f9SAlex Bennée  --disable-containers     don't use containers for cross-building
1804f48e590aSAlex Bennée  --gdb=GDB-path           gdb to use for gdbstub tests [$gdb_bin]
1805c23f23b9SMichael Tokarev
1806c23f23b9SMichael TokarevOptional features, enabled with --enable-FEATURE and
1807c87ea116SAlex Bennéedisabled with --disable-FEATURE, default is enabled if available
1808c87ea116SAlex Bennée(unless built with --without-default-features):
1809c23f23b9SMichael Tokarev
1810c23f23b9SMichael Tokarev  system          all system emulation targets
1811c23f23b9SMichael Tokarev  user            supported user emulation targets
1812c23f23b9SMichael Tokarev  linux-user      all linux usermode emulation targets
1813c23f23b9SMichael Tokarev  bsd-user        all BSD usermode emulation targets
1814c23f23b9SMichael Tokarev  docs            build documentation
1815c23f23b9SMichael Tokarev  guest-agent     build the QEMU Guest Agent
1816c23f23b9SMichael Tokarev  guest-agent-msi build guest agent Windows MSI installation package
1817c23f23b9SMichael Tokarev  pie             Position Independent Executables
181821e709aaSMarc-André Lureau  modules         modules support (non-Windows)
1819bd83c861SChristian Ehrhardt  module-upgrades try to load modules from alternate paths for upgrades
1820c23f23b9SMichael Tokarev  debug-tcg       TCG debugging (default is disabled)
1821c23f23b9SMichael Tokarev  debug-info      debugging information
1822cdad781dSDaniele Buono  lto             Enable Link-Time Optimization.
1823c23f23b9SMichael Tokarev  sparse          sparse checker
18241e4f6065SDaniele Buono  safe-stack      SafeStack Stack Smash Protection. Depends on
18251e4f6065SDaniele Buono                  clang/llvm >= 3.7 and requires coroutine backend ucontext.
18269e62ba48SDaniele Buono  cfi             Enable Control-Flow Integrity for indirect function calls.
18279e62ba48SDaniele Buono                  In case of a cfi violation, QEMU is terminated with SIGILL
18289e62ba48SDaniele Buono                  Depends on lto and is incompatible with modules
18299e62ba48SDaniele Buono                  Automatically enables Link-Time Optimization (lto)
18309e62ba48SDaniele Buono  cfi-debug       In case of a cfi violation, a message containing the line that
18319e62ba48SDaniele Buono                  triggered the error is written to stderr. After the error,
18329e62ba48SDaniele Buono                  QEMU is still terminated with SIGILL
1833ddbb0d09SDaniel P. Berrange  gnutls          GNUTLS cryptography support
183491bfcdb0SDaniel P. Berrange  nettle          nettle cryptography support
183591bfcdb0SDaniel P. Berrange  gcrypt          libgcrypt cryptography support
18368953caf3SDaniel P. Berrange  auth-pam        PAM access control
1837c23f23b9SMichael Tokarev  sdl             SDL UI
183804c6e16fSMarkus Armbruster  sdl-image       SDL Image support for icons
1839c23f23b9SMichael Tokarev  gtk             gtk UI
1840c23f23b9SMichael Tokarev  vte             vte support for the gtk UI
1841c23f23b9SMichael Tokarev  curses          curses UI
1842e08bb301SSamuel Thibault  iconv           font glyph conversion support
1843c23f23b9SMichael Tokarev  vnc             VNC UI support
1844c23f23b9SMichael Tokarev  vnc-sasl        SASL encryption for VNC server
1845c23f23b9SMichael Tokarev  vnc-jpeg        JPEG lossy compression for VNC server
1846c23f23b9SMichael Tokarev  vnc-png         PNG compression for VNC server
1847c23f23b9SMichael Tokarev  cocoa           Cocoa UI (Mac OS X only)
1848c23f23b9SMichael Tokarev  virtfs          VirtFS
1849cece116cSMisono Tomohiro  virtiofsd       build virtiofs daemon (virtiofsd)
18505c53015aSPaolo Bonzini  libudev         Use libudev to enumerate host devices
1851fe8fc5aeSPaolo Bonzini  mpath           Multipath persistent reservation passthrough
1852c23f23b9SMichael Tokarev  xen             xen backend driver support
185370c292afSAnthony PERARD  xen-pci-passthrough    PCI passthrough support for Xen
1854c23f23b9SMichael Tokarev  brlapi          BrlAPI (Braile)
1855c23f23b9SMichael Tokarev  curl            curl connectivity
1856a40161cbSPaolo Bonzini  membarrier      membarrier system call (for Linux 4.14+ or Windows)
1857c23f23b9SMichael Tokarev  fdt             fdt device tree
1858c23f23b9SMichael Tokarev  kvm             KVM acceleration support
1859b0cb0a66SVincent Palatin  hax             HAX acceleration support
1860c97d6d2cSSergio Andres Gomez Del Real  hvf             Hypervisor.framework acceleration support
186174a414a1SReinoud Zandijk  nvmm            NVMM acceleration support
1862d661d9a4SJustin Terry (VM)  whpx            Windows Hypervisor Platform acceleration support
186321ab34c9SMarcel Apfelbaum  rdma            Enable RDMA-based migration
186421ab34c9SMarcel Apfelbaum  pvrdma          Enable PVRDMA support
1865c23f23b9SMichael Tokarev  vde             support for vde network
1866c23f23b9SMichael Tokarev  netmap          support for netmap network
1867c23f23b9SMichael Tokarev  linux-aio       Linux AIO support
1868c10dd856SAarushi Mehta  linux-io-uring  Linux io_uring support
1869c23f23b9SMichael Tokarev  cap-ng          libcap-ng support
1870c23f23b9SMichael Tokarev  attr            attr and xattr support
1871299e6f19SPaolo Bonzini  vhost-net       vhost-net kernel acceleration support
1872299e6f19SPaolo Bonzini  vhost-vsock     virtio sockets device support
1873299e6f19SPaolo Bonzini  vhost-scsi      vhost-scsi kernel target support
1874299e6f19SPaolo Bonzini  vhost-crypto    vhost-user-crypto backend support
1875299e6f19SPaolo Bonzini  vhost-kernel    vhost kernel backend support
1876299e6f19SPaolo Bonzini  vhost-user      vhost-user backend support
1877bc15e44cSStefan Hajnoczi  vhost-user-blk-server    vhost-user-blk server support
1878108a6481SCindy Lu  vhost-vdpa      vhost-vdpa kernel backend support
187946627f41SAndrew Melnychenko  bpf             BPF kernel support
1880c23f23b9SMichael Tokarev  spice           spice
188158d3f3ffSGerd Hoffmann  spice-protocol  spice-protocol
1882c23f23b9SMichael Tokarev  rbd             rados block device (rbd)
1883c23f23b9SMichael Tokarev  libiscsi        iscsi support
1884c23f23b9SMichael Tokarev  libnfs          nfs support
18857b02f544SMarc-André Lureau  smartcard       smartcard support (libcacard)
18860a40bcb7SCésar Belley  u2f             U2F support (u2f-emu)
1887c23f23b9SMichael Tokarev  libusb          libusb (for usb passthrough)
1888ed1701c6SDr. David Alan Gilbert  live-block-migration   Block migration in the main migration stream
1889c23f23b9SMichael Tokarev  usb-redir       usb network redirection support
1890c23f23b9SMichael Tokarev  lzo             support of lzo compression library
1891c23f23b9SMichael Tokarev  snappy          support of snappy compression library
1892c23f23b9SMichael Tokarev  bzip2           support of bzip2 compression library
1893c23f23b9SMichael Tokarev                  (for reading bzip2-compressed dmg images)
189483bc1f97SJulio Faracco  lzfse           support of lzfse compression library
189583bc1f97SJulio Faracco                  (for reading lzfse-compressed dmg images)
18963a678481SJuan Quintela  zstd            support for zstd compression library
1897d298ac10SDenis Plotnikov                  (for migration compression and qcow2 cluster compression)
1898c23f23b9SMichael Tokarev  seccomp         seccomp support
1899c23f23b9SMichael Tokarev  coroutine-pool  coroutine freelist (better performance)
1900c23f23b9SMichael Tokarev  glusterfs       GlusterFS backend
1901c23f23b9SMichael Tokarev  tpm             TPM support
1902b10d49d7SPino Toscano  libssh          ssh block device support
1903c23f23b9SMichael Tokarev  numa            libnuma support
1904ed279a06SKlim Kireev  libxml2         for Parallels image format
1905c23f23b9SMichael Tokarev  tcmalloc        tcmalloc support
19067b01cb97SAlexandre Derumier  jemalloc        jemalloc support
190786583a07SLiam Merwick  avx2            AVX2 optimization support
19086b8cd447SRobert Hoo  avx512f         AVX512F optimization support
1909a6b1d4c0SChanglong Xie  replication     replication support
1910c12d66aaSLin Ma  opengl          opengl support
1911c12d66aaSLin Ma  virglrenderer   virgl rendering support
1912c12d66aaSLin Ma  xfsctl          xfsctl support
1913c12d66aaSLin Ma  qom-cast-debug  cast debugging support
19148de73fa8SCleber Rosa  tools           build qemu-io, qemu-nbd and qemu-img tools
19152f740136SJeff Cody  bochs           bochs image format support
19162f740136SJeff Cody  cloop           cloop image format support
19172f740136SJeff Cody  dmg             dmg image format support
19182f740136SJeff Cody  qcow1           qcow v1 image format support
19192f740136SJeff Cody  vdi             vdi image format support
19202f740136SJeff Cody  vvfat           vvfat image format support
19212f740136SJeff Cody  qed             qed image format support
19222f740136SJeff Cody  parallels       parallels image format support
1923f0d92b56SLongpeng(Mike)  crypto-afalg    Linux AF_ALG crypto backend driver
19248ca80760SRichard Henderson  capstone        capstone disassembler support
1925ba59fb77SPaolo Bonzini  debug-mutex     mutex debugging support
192617824406SJunyan He  libpmem         libpmem support
192775411919SJames Le Cuirot  xkbcommon       xkbcommon support
1928b767d257SMarek Marczykowski-Górecki  rng-none        dummy RNG, avoid using /dev/(u)random and getrandom()
192921b2eca6SJingqi Liu  libdaxctl       libdaxctl support
1930a484a719SMax Reitz  fuse            FUSE block device export
1931df4ea709SMax Reitz  fuse-lseek      SEEK_HOLE/SEEK_DATA support for FUSE exports
1932106ad1f9SPaolo Bonzini  multiprocess    Out of process device emulation support
193320cf7b8eSDenis Plotnikov  gio             libgio support
1934b8e0c493SJoelle van Dyne  slirp-smbd      use smbd (at path --smbd=*) in slirp networking
193508fb77edSStefan Weil
193608fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched
1937af5db58eSpbrookEOF
19382d2ad6d0SFam Zhengexit 0
1939af5db58eSpbrookfi
1940af5db58eSpbrook
19419c790242SThomas Huth# Remove old dependency files to make sure that they get properly regenerated
1942bb768f71SThomas Huthrm -f */config-devices.mak.d
19439c790242SThomas Huth
1944faf44142SDaniel P. Berrangéif test -z "$python"
1945faf44142SDaniel P. Berrangéthen
1946c53eeaf7SStefan Hajnoczi    error_exit "Python not found. Use --python=/path/to/python"
1947c53eeaf7SStefan Hajnoczifi
19488e2c76bdSRoman Bolshakovif ! has "$make"
19498e2c76bdSRoman Bolshakovthen
19508e2c76bdSRoman Bolshakov    error_exit "GNU make ($make) not found"
19518e2c76bdSRoman Bolshakovfi
1952c53eeaf7SStefan Hajnoczi
1953c53eeaf7SStefan Hajnoczi# Note that if the Python conditional here evaluates True we will exit
1954c53eeaf7SStefan Hajnoczi# with status 1 which is a shell 'false' value.
19551b11f28dSThomas Huthif ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then
19561b11f28dSThomas Huth  error_exit "Cannot use '$python', Python >= 3.6 is required." \
1957c53eeaf7SStefan Hajnoczi      "Use --python=/path/to/python to specify a supported Python."
1958c53eeaf7SStefan Hajnoczifi
1959c53eeaf7SStefan Hajnoczi
1960755ee70fSCleber Rosa# Preserve python version since some functionality is dependent on it
1961406ab2f3SCleber 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)
1962755ee70fSCleber Rosa
1963c53eeaf7SStefan Hajnoczi# Suppress writing compiled files
1964c53eeaf7SStefan Hajnoczipython="$python -B"
1965c53eeaf7SStefan Hajnoczi
19660a01d76fSMarc-André Lureauif test -z "$meson"; then
1967654d6b04SPaolo Bonzini    if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.59.2; then
19680a01d76fSMarc-André Lureau        meson=meson
19697d7dbf9dSDan Streetman    elif test $git_submodules_action != 'ignore' ; then
19700a01d76fSMarc-André Lureau        meson=git
19710a01d76fSMarc-André Lureau    elif test -e "${source_path}/meson/meson.py" ; then
19720a01d76fSMarc-André Lureau        meson=internal
19730a01d76fSMarc-André Lureau    else
19740a01d76fSMarc-André Lureau        if test "$explicit_python" = yes; then
19750a01d76fSMarc-André Lureau            error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found."
19760a01d76fSMarc-André Lureau        else
1977a5665051SPaolo Bonzini            error_exit "Meson not found.  Use --meson=/path/to/meson"
1978a5665051SPaolo Bonzini        fi
19790a01d76fSMarc-André Lureau    fi
19800a01d76fSMarc-André Lureauelse
19810a01d76fSMarc-André Lureau    # Meson uses its own Python interpreter to invoke other Python scripts,
19820a01d76fSMarc-André Lureau    # but the user wants to use the one they specified with --python.
19830a01d76fSMarc-André Lureau    #
19840a01d76fSMarc-André Lureau    # We do not want to override the distro Python interpreter (and sometimes
19850a01d76fSMarc-André Lureau    # cannot: for example in Homebrew /usr/bin/meson is a bash script), so
19860a01d76fSMarc-André Lureau    # just require --meson=git|internal together with --python.
19870a01d76fSMarc-André Lureau    if test "$explicit_python" = yes; then
19880a01d76fSMarc-André Lureau        case "$meson" in
19890a01d76fSMarc-André Lureau            git | internal) ;;
19900a01d76fSMarc-André Lureau            *) error_exit "--python requires using QEMU's embedded Meson distribution." ;;
19910a01d76fSMarc-André Lureau        esac
19920a01d76fSMarc-André Lureau    fi
19930a01d76fSMarc-André Lureaufi
1994a5665051SPaolo Bonzini
19950a01d76fSMarc-André Lureauif test "$meson" = git; then
19960a01d76fSMarc-André Lureau    git_submodules="${git_submodules} meson"
19970a01d76fSMarc-André Lureaufi
19980a01d76fSMarc-André Lureau
19990a01d76fSMarc-André Lureaucase "$meson" in
20000a01d76fSMarc-André Lureau    git | internal)
20010a01d76fSMarc-André Lureau        meson="$python ${source_path}/meson/meson.py"
20020a01d76fSMarc-André Lureau        ;;
200384ec0c24SPaolo Bonzini    *) meson=$(command -v "$meson") ;;
20040a01d76fSMarc-André Lureauesac
20050a01d76fSMarc-André Lureau
200609e93326SPaolo Bonzini# Probe for ninja
200748328880SPaolo Bonzini
200848328880SPaolo Bonziniif test -z "$ninja"; then
200948328880SPaolo Bonzini    for c in ninja ninja-build samu; do
201048328880SPaolo Bonzini        if has $c; then
201148328880SPaolo Bonzini            ninja=$(command -v "$c")
201248328880SPaolo Bonzini            break
201348328880SPaolo Bonzini        fi
201448328880SPaolo Bonzini    done
201509e93326SPaolo Bonzini    if test -z "$ninja"; then
201609e93326SPaolo Bonzini      error_exit "Cannot find Ninja"
201709e93326SPaolo Bonzini    fi
201848328880SPaolo Bonzinifi
2019a5665051SPaolo Bonzini
20209aae6e54SDaniel Henrique Barboza# Check that the C compiler works. Doing this here before testing
20219aae6e54SDaniel Henrique Barboza# the host CPU ensures that we had a valid CC to autodetect the
20229aae6e54SDaniel Henrique Barboza# $cpu var (and we should bail right here if that's not the case).
20239aae6e54SDaniel Henrique Barboza# It also allows the help message to be printed without a CC.
20249aae6e54SDaniel Henrique Barbozawrite_c_skeleton;
20259aae6e54SDaniel Henrique Barbozaif compile_object ; then
20269aae6e54SDaniel Henrique Barboza  : C compiler works ok
20279aae6e54SDaniel Henrique Barbozaelse
20289aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" either does not exist or does not work"
20299aae6e54SDaniel Henrique Barbozafi
20309aae6e54SDaniel Henrique Barbozaif ! compile_prog ; then
20319aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
20329aae6e54SDaniel Henrique Barbozafi
20339aae6e54SDaniel Henrique Barboza
20349c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror
20359c83ffd8SPeter Maydell# by default.  Only enable by default for git builds
20369c83ffd8SPeter Maydellif test -z "$werror" ; then
20377d7dbf9dSDan Streetman    if test "$git_submodules_action" != "ignore" && \
2038e633a5c6SEric Blake        { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
20399c83ffd8SPeter Maydell        werror="yes"
20409c83ffd8SPeter Maydell    else
20419c83ffd8SPeter Maydell        werror="no"
20429c83ffd8SPeter Maydell    fi
20439c83ffd8SPeter Maydellfi
20449c83ffd8SPeter Maydell
2045975ff037SPaolo Bonziniif test "$targetos" = "bogus"; then
2046fb59dabdSPeter Maydell    # Now that we know that we're not printing the help and that
2047fb59dabdSPeter Maydell    # the compiler works (so the results of the check_defines we used
2048fb59dabdSPeter Maydell    # to identify the OS are reliable), if we didn't recognize the
2049fb59dabdSPeter Maydell    # host OS we should stop now.
2050951fedfcSPeter Maydell    error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
2051fb59dabdSPeter Maydellfi
2052fb59dabdSPeter Maydell
2053efc6c070SThomas Huth# Check whether the compiler matches our minimum requirements:
2054efc6c070SThomas Huthcat > $TMPC << EOF
2055efc6c070SThomas Huth#if defined(__clang_major__) && defined(__clang_minor__)
2056efc6c070SThomas Huth# ifdef __apple_build_version__
20572a85a08cSDaniel P. Berrangé#  if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0)
20582a85a08cSDaniel P. Berrangé#   error You need at least XCode Clang v10.0 to compile QEMU
2059efc6c070SThomas Huth#  endif
2060efc6c070SThomas Huth# else
20612a85a08cSDaniel P. Berrangé#  if __clang_major__ < 6 || (__clang_major__ == 6 && __clang_minor__ < 0)
20622a85a08cSDaniel P. Berrangé#   error You need at least Clang v6.0 to compile QEMU
2063efc6c070SThomas Huth#  endif
2064efc6c070SThomas Huth# endif
2065efc6c070SThomas Huth#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
20663830df5fSnia# if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4)
20673830df5fSnia#  error You need at least GCC v7.4.0 to compile QEMU
2068efc6c070SThomas Huth# endif
2069efc6c070SThomas Huth#else
2070efc6c070SThomas Huth# error You either need GCC or Clang to compiler QEMU
2071efc6c070SThomas Huth#endif
2072efc6c070SThomas Huthint main (void) { return 0; }
2073efc6c070SThomas HuthEOF
2074efc6c070SThomas Huthif ! compile_prog "" "" ; then
20753830df5fSnia    error_exit "You need at least GCC v7.4 or Clang v6.0 (or XCode Clang v10.0)"
2076efc6c070SThomas Huthfi
2077efc6c070SThomas Huth
207800849b92SRichard Henderson# Accumulate -Wfoo and -Wno-bar separately.
207900849b92SRichard Henderson# We will list all of the enable flags first, and the disable flags second.
208000849b92SRichard Henderson# Note that we do not add -Werror, because that would enable it for all
208100849b92SRichard Henderson# configure tests. If a configure test failed due to -Werror this would
208200849b92SRichard Henderson# just silently disable some features, so it's too error prone.
208300849b92SRichard Henderson
208400849b92SRichard Hendersonwarn_flags=
208500849b92SRichard Hendersonadd_to warn_flags -Wold-style-declaration
208600849b92SRichard Hendersonadd_to warn_flags -Wold-style-definition
208700849b92SRichard Hendersonadd_to warn_flags -Wtype-limits
208800849b92SRichard Hendersonadd_to warn_flags -Wformat-security
208900849b92SRichard Hendersonadd_to warn_flags -Wformat-y2k
209000849b92SRichard Hendersonadd_to warn_flags -Winit-self
209100849b92SRichard Hendersonadd_to warn_flags -Wignored-qualifiers
209200849b92SRichard Hendersonadd_to warn_flags -Wempty-body
209300849b92SRichard Hendersonadd_to warn_flags -Wnested-externs
209400849b92SRichard Hendersonadd_to warn_flags -Wendif-labels
209500849b92SRichard Hendersonadd_to warn_flags -Wexpansion-to-defined
20960a2ebce9SThomas Huthadd_to warn_flags -Wimplicit-fallthrough=2
209700849b92SRichard Henderson
209800849b92SRichard Hendersonnowarn_flags=
209900849b92SRichard Hendersonadd_to nowarn_flags -Wno-initializer-overrides
210000849b92SRichard Hendersonadd_to nowarn_flags -Wno-missing-include-dirs
210100849b92SRichard Hendersonadd_to nowarn_flags -Wno-shift-negative-value
210200849b92SRichard Hendersonadd_to nowarn_flags -Wno-string-plus-int
210300849b92SRichard Hendersonadd_to nowarn_flags -Wno-typedef-redefinition
2104aabab967SRichard Hendersonadd_to nowarn_flags -Wno-tautological-type-limit-compare
2105bac8d222SRichard Hendersonadd_to nowarn_flags -Wno-psabi
210600849b92SRichard Henderson
210700849b92SRichard Hendersongcc_flags="$warn_flags $nowarn_flags"
210893b25869SJohn Snow
210993b25869SJohn Snowcc_has_warning_flag() {
211093b25869SJohn Snow    write_c_skeleton;
211193b25869SJohn Snow
2112a1d29d6cSPeter Maydell    # Use the positive sense of the flag when testing for -Wno-wombat
2113a1d29d6cSPeter Maydell    # support (gcc will happily accept the -Wno- form of unknown
2114a1d29d6cSPeter Maydell    # warning options).
211593b25869SJohn Snow    optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
211693b25869SJohn Snow    compile_prog "-Werror $optflag" ""
211793b25869SJohn Snow}
211893b25869SJohn Snow
211993b25869SJohn Snowfor flag in $gcc_flags; do
212093b25869SJohn Snow    if cc_has_warning_flag $flag ; then
21218d05095cSPaolo Bonzini        QEMU_CFLAGS="$QEMU_CFLAGS $flag"
21228d05095cSPaolo Bonzini    fi
21238d05095cSPaolo Bonzinidone
21248d05095cSPaolo Bonzini
212563678e17SSteven Noonanif test "$stack_protector" != "no"; then
2126fccd35a0SRodrigo Rebello  cat > $TMPC << EOF
2127fccd35a0SRodrigo Rebelloint main(int argc, char *argv[])
2128fccd35a0SRodrigo Rebello{
2129fccd35a0SRodrigo Rebello    char arr[64], *p = arr, *c = argv[0];
2130fccd35a0SRodrigo Rebello    while (*c) {
2131fccd35a0SRodrigo Rebello        *p++ = *c++;
2132fccd35a0SRodrigo Rebello    }
2133fccd35a0SRodrigo Rebello    return 0;
2134fccd35a0SRodrigo Rebello}
2135fccd35a0SRodrigo RebelloEOF
213663678e17SSteven Noonan  gcc_flags="-fstack-protector-strong -fstack-protector-all"
21373b463a3fSMiroslav Rezanina  sp_on=0
213863678e17SSteven Noonan  for flag in $gcc_flags; do
2139590e5dd9SPeter Maydell    # We need to check both a compile and a link, since some compiler
2140590e5dd9SPeter Maydell    # setups fail only on a .c->.o compile and some only at link time
2141086d5f75SPaolo Bonzini    if compile_object "-Werror $flag" &&
2142590e5dd9SPeter Maydell       compile_prog "-Werror $flag" ""; then
214363678e17SSteven Noonan      QEMU_CFLAGS="$QEMU_CFLAGS $flag"
2144db5adeaaSPaolo Bonzini      QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
21453b463a3fSMiroslav Rezanina      sp_on=1
214663678e17SSteven Noonan      break
214763678e17SSteven Noonan    fi
214863678e17SSteven Noonan  done
21493b463a3fSMiroslav Rezanina  if test "$stack_protector" = yes; then
21503b463a3fSMiroslav Rezanina    if test $sp_on = 0; then
21513b463a3fSMiroslav Rezanina      error_exit "Stack protector not supported"
21523b463a3fSMiroslav Rezanina    fi
21533b463a3fSMiroslav Rezanina  fi
215437746c5eSMarc-André Lureaufi
215537746c5eSMarc-André Lureau
215620bc94a2SPaolo Bonzini# Disable -Wmissing-braces on older compilers that warn even for
215720bc94a2SPaolo Bonzini# the "universal" C zero initializer {0}.
215820bc94a2SPaolo Bonzinicat > $TMPC << EOF
215920bc94a2SPaolo Bonzinistruct {
216020bc94a2SPaolo Bonzini  int a[2];
216120bc94a2SPaolo Bonzini} x = {0};
216220bc94a2SPaolo BonziniEOF
216320bc94a2SPaolo Bonziniif compile_object "-Werror" "" ; then
216420bc94a2SPaolo Bonzini  :
216520bc94a2SPaolo Bonzinielse
216620bc94a2SPaolo Bonzini  QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
216720bc94a2SPaolo Bonzinifi
216820bc94a2SPaolo Bonzini
216921e709aaSMarc-André Lureau# Our module code doesn't support Windows
217021e709aaSMarc-André Lureauif test "$modules" = "yes" && test "$mingw32" = "yes" ; then
217121e709aaSMarc-André Lureau  error_exit "Modules are not available for Windows"
217221e709aaSMarc-André Lureaufi
217321e709aaSMarc-André Lureau
2174bd83c861SChristian Ehrhardt# module_upgrades is only reasonable if modules are enabled
2175bd83c861SChristian Ehrhardtif test "$modules" = "no" && test "$module_upgrades" = "yes" ; then
2176bd83c861SChristian Ehrhardt  error_exit "Can't enable module-upgrades as Modules are not enabled"
2177bd83c861SChristian Ehrhardtfi
2178bd83c861SChristian Ehrhardt
21795f2453acSAlex Bennée# Static linking is not possible with plugins, modules or PIE
218040d6444eSAvi Kivityif test "$static" = "yes" ; then
2181aa0d1f44SPaolo Bonzini  if test "$modules" = "yes" ; then
2182aa0d1f44SPaolo Bonzini    error_exit "static and modules are mutually incompatible"
2183aa0d1f44SPaolo Bonzini  fi
21845f2453acSAlex Bennée  if test "$plugins" = "yes"; then
21855f2453acSAlex Bennée    error_exit "static and plugins are mutually incompatible"
2186ba4dd2aaSAlex Bennée  else
2187ba4dd2aaSAlex Bennée    plugins="no"
21885f2453acSAlex Bennée  fi
218940d6444eSAvi Kivityfi
219040d6444eSAvi Kivity
2191768b7855SEmilio G. Cota# Unconditional check for compiler __thread support
2192768b7855SEmilio G. Cota  cat > $TMPC << EOF
2193768b7855SEmilio G. Cotastatic __thread int tls_var;
2194768b7855SEmilio G. Cotaint main(void) { return tls_var; }
2195768b7855SEmilio G. CotaEOF
2196768b7855SEmilio G. Cota
2197768b7855SEmilio G. Cotaif ! compile_prog "-Werror" "" ; then
2198768b7855SEmilio G. Cota    error_exit "Your compiler does not support the __thread specifier for " \
2199768b7855SEmilio G. Cota	"Thread-Local Storage (TLS). Please upgrade to a version that does."
2200768b7855SEmilio G. Cotafi
2201768b7855SEmilio G. Cota
220240d6444eSAvi Kivitycat > $TMPC << EOF
220321d4a791SAvi Kivity
220421d4a791SAvi Kivity#ifdef __linux__
220521d4a791SAvi Kivity#  define THREAD __thread
220621d4a791SAvi Kivity#else
220721d4a791SAvi Kivity#  define THREAD
220821d4a791SAvi Kivity#endif
220921d4a791SAvi Kivitystatic THREAD int tls_var;
221021d4a791SAvi Kivityint main(void) { return tls_var; }
221140d6444eSAvi KivityEOF
2212b2634124SRichard Henderson
2213b2634124SRichard Henderson# Check we support --no-pie first; we will need this for building ROMs.
2214412aeacdSAlex Bennéeif compile_prog "-Werror -fno-pie" "-no-pie"; then
2215412aeacdSAlex Bennée  CFLAGS_NOPIE="-fno-pie"
2216412aeacdSAlex Bennéefi
2217412aeacdSAlex Bennée
221812781462SRichard Hendersonif test "$static" = "yes"; then
2219eca7a8e6SRichard Henderson  if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then
22205770e8afSPaolo Bonzini    CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
222112781462SRichard Henderson    QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS"
222212781462SRichard Henderson    pie="yes"
222312781462SRichard Henderson  elif test "$pie" = "yes"; then
222412781462SRichard Henderson    error_exit "-static-pie not available due to missing toolchain support"
222512781462SRichard Henderson  else
222612781462SRichard Henderson    QEMU_LDFLAGS="-static $QEMU_LDFLAGS"
222712781462SRichard Henderson    pie="no"
222812781462SRichard Henderson  fi
222912781462SRichard Hendersonelif test "$pie" = "no"; then
22305770e8afSPaolo Bonzini  CONFIGURE_CFLAGS="$CFLAGS_NOPIE $CONFIGURE_CFLAGS"
2231eca7a8e6SRichard Hendersonelif compile_prog "-Werror -fPIE -DPIE" "-pie"; then
22325770e8afSPaolo Bonzini  CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
22335770e8afSPaolo Bonzini  CONFIGURE_LDFLAGS="-pie $CONFIGURE_LDFLAGS"
223440d6444eSAvi Kivity  pie="yes"
22352c674109SRichard Hendersonelif test "$pie" = "yes"; then
223676ad07a4SPeter Maydell  error_exit "PIE not available due to missing toolchain support"
223740d6444eSAvi Kivityelse
223840d6444eSAvi Kivity  echo "Disabling PIE due to missing toolchain support"
223940d6444eSAvi Kivity  pie="no"
224040d6444eSAvi Kivityfi
224140d6444eSAvi Kivity
2242e6cbd751SRichard Henderson# Detect support for PT_GNU_RELRO + DT_BIND_NOW.
2243e6cbd751SRichard Henderson# The combination is known as "full relro", because .got.plt is read-only too.
2244e6cbd751SRichard Hendersonif compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
2245e6cbd751SRichard Henderson  QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS"
2246e6cbd751SRichard Hendersonfi
2247e6cbd751SRichard Henderson
224809dada40SPaolo Bonzini##########################################
224909dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains
225009dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit
225109dada40SPaolo Bonzini# specification is necessary
225209dada40SPaolo Bonzini
225309dada40SPaolo Bonziniif test "$cpu" = "i386"; then
225409dada40SPaolo Bonzini  cat > $TMPC << EOF
225509dada40SPaolo Bonzinistatic int sfaa(int *ptr)
225609dada40SPaolo Bonzini{
225709dada40SPaolo Bonzini  return __sync_fetch_and_and(ptr, 0);
225809dada40SPaolo Bonzini}
225909dada40SPaolo Bonzini
226009dada40SPaolo Bonziniint main(void)
226109dada40SPaolo Bonzini{
226209dada40SPaolo Bonzini  int val = 42;
22631405b629SStefan Weil  val = __sync_val_compare_and_swap(&val, 0, 1);
226409dada40SPaolo Bonzini  sfaa(&val);
226509dada40SPaolo Bonzini  return val;
226609dada40SPaolo Bonzini}
226709dada40SPaolo BonziniEOF
226809dada40SPaolo Bonzini  if ! compile_prog "" "" ; then
226909dada40SPaolo Bonzini    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
227009dada40SPaolo Bonzini  fi
227109dada40SPaolo Bonzinifi
227209dada40SPaolo Bonzini
227309dada40SPaolo Bonzini#########################################
2274ec530c81Sbellard# Solaris specific configure tool chain decisions
227509dada40SPaolo Bonzini
2276ec530c81Sbellardif test "$solaris" = "yes" ; then
22776792aa11SLoïc Minier  if has ar; then
22786792aa11SLoïc Minier    :
22796792aa11SLoïc Minier  else
2280ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
228176ad07a4SPeter Maydell      error_exit "No path includes ar" \
228276ad07a4SPeter Maydell          "Add /usr/ccs/bin to your path and rerun configure"
2283ec530c81Sbellard    fi
228476ad07a4SPeter Maydell    error_exit "No path includes ar"
2285ec530c81Sbellard  fi
2286ec530c81Sbellardfi
2287ec530c81Sbellard
228856267b62SPhilippe Mathieu-Daudéif test "$tcg" = "enabled"; then
228956267b62SPhilippe Mathieu-Daudé    git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
229056267b62SPhilippe Mathieu-Daudé    git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
229156267b62SPhilippe Mathieu-Daudéfi
229256267b62SPhilippe Mathieu-Daudé
2293afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then
2294fdb75aefSPaolo Bonzini    default_targets=yes
2295d880a3baSPaolo Bonzini    for target in $default_target_list; do
2296d880a3baSPaolo Bonzini        target_list="$target_list $target"
2297d880a3baSPaolo Bonzini    done
2298d880a3baSPaolo Bonzini    target_list="${target_list# }"
2299121afa9eSAnthony Liguorielse
2300fdb75aefSPaolo Bonzini    default_targets=no
230189138857SStefan Weil    target_list=$(echo "$target_list" | sed -e 's/,/ /g')
2302d880a3baSPaolo Bonzini    for target in $target_list; do
230325b48338SPeter Maydell        # Check that we recognised the target name; this allows a more
230425b48338SPeter Maydell        # friendly error message than if we let it fall through.
230525b48338SPeter Maydell        case " $default_target_list " in
230625b48338SPeter Maydell            *" $target "*)
230725b48338SPeter Maydell                ;;
230825b48338SPeter Maydell            *)
230925b48338SPeter Maydell                error_exit "Unknown target name '$target'"
231025b48338SPeter Maydell                ;;
231125b48338SPeter Maydell        esac
231225b48338SPeter Maydell    done
2313d880a3baSPaolo Bonzinifi
231425b48338SPeter Maydell
2315fdb75aefSPaolo Bonzinifor target in $target_list; do
2316fdb75aefSPaolo Bonzini    # if a deprecated target is enabled we note it here
2317fdb75aefSPaolo Bonzini    if echo "$deprecated_targets_list" | grep -q "$target"; then
2318fdb75aefSPaolo Bonzini        add_to deprecated_features $target
2319fdb75aefSPaolo Bonzini    fi
2320fdb75aefSPaolo Bonzinidone
2321fdb75aefSPaolo Bonzini
2322f55fe278SPaolo Bonzini# see if system emulation was really requested
2323f55fe278SPaolo Bonzinicase " $target_list " in
2324f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
2325f55fe278SPaolo Bonzini  ;;
2326f55fe278SPaolo Bonzini  *) softmmu=no
2327f55fe278SPaolo Bonzini  ;;
2328f55fe278SPaolo Bonziniesac
23295327cf48Sbellard
2330249247c9SJuan Quintelafeature_not_found() {
2331249247c9SJuan Quintela  feature=$1
233221684af0SStewart Smith  remedy=$2
2333249247c9SJuan Quintela
233476ad07a4SPeter Maydell  error_exit "User requested feature $feature" \
233521684af0SStewart Smith      "configure was not able to find it." \
233621684af0SStewart Smith      "$remedy"
2337249247c9SJuan Quintela}
2338249247c9SJuan Quintela
23397d13299dSbellard# ---
23407d13299dSbellard# big/little endian test
23417d13299dSbellardcat > $TMPC << EOF
2342659eb157SThomas Huth#include <stdio.h>
234361cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
234461cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
2345659eb157SThomas Huthint main(int argc, char *argv[])
2346659eb157SThomas Huth{
2347659eb157SThomas Huth    return printf("%s %s\n", (char *)big_endian, (char *)little_endian);
23487d13299dSbellard}
23497d13299dSbellardEOF
23507d13299dSbellard
2351659eb157SThomas Huthif compile_prog ; then
2352659eb157SThomas Huth    if strings -a $TMPE | grep -q BiGeNdIaN ; then
235361cc919fSMike Frysinger        bigendian="yes"
2354659eb157SThomas Huth    elif strings -a $TMPE | grep -q LiTtLeEnDiAn ; then
235561cc919fSMike Frysinger        bigendian="no"
23567d13299dSbellard    else
23577d13299dSbellard        echo big/little test failed
2358659eb157SThomas Huth        exit 1
23597d13299dSbellard    fi
23607d13299dSbellardelse
236161cc919fSMike Frysinger    echo big/little test failed
2362659eb157SThomas Huth    exit 1
23637d13299dSbellardfi
23647d13299dSbellard
2365b0a47e79SJuan Quintela##########################################
2366e10ee3f5SPhilippe Mathieu-Daudé# system tools
2367e10ee3f5SPhilippe Mathieu-Daudéif test -z "$want_tools"; then
2368e10ee3f5SPhilippe Mathieu-Daudé    if test "$softmmu" = "no"; then
2369e10ee3f5SPhilippe Mathieu-Daudé        want_tools=no
2370e10ee3f5SPhilippe Mathieu-Daudé    else
2371e10ee3f5SPhilippe Mathieu-Daudé        want_tools=yes
2372e10ee3f5SPhilippe Mathieu-Daudé    fi
2373e10ee3f5SPhilippe Mathieu-Daudéfi
2374e10ee3f5SPhilippe Mathieu-Daudé
2375e10ee3f5SPhilippe Mathieu-Daudé##########################################
2376015a33bdSGonglei# L2TPV3 probe
2377015a33bdSGonglei
2378015a33bdSGongleicat > $TMPC <<EOF
2379015a33bdSGonglei#include <sys/socket.h>
2380bff6cb72SMichael Tokarev#include <linux/ip.h>
2381015a33bdSGongleiint main(void) { return sizeof(struct mmsghdr); }
2382015a33bdSGongleiEOF
2383015a33bdSGongleiif compile_prog "" "" ; then
2384015a33bdSGonglei  l2tpv3=yes
2385015a33bdSGongleielse
2386015a33bdSGonglei  l2tpv3=no
2387015a33bdSGongleifi
2388015a33bdSGonglei
2389195588ccSDavid CARLIERcat > $TMPC <<EOF
2390195588ccSDavid CARLIER#include <sys/mman.h>
2391195588ccSDavid CARLIERint main(int argc, char *argv[]) {
2392195588ccSDavid CARLIER    return mlockall(MCL_FUTURE);
2393195588ccSDavid CARLIER}
2394195588ccSDavid CARLIEREOF
2395195588ccSDavid CARLIERif compile_prog "" "" ; then
2396195588ccSDavid CARLIER  have_mlockall=yes
2397195588ccSDavid CARLIERelse
2398195588ccSDavid CARLIER  have_mlockall=no
2399195588ccSDavid CARLIERfi
2400195588ccSDavid CARLIER
2401299e6f19SPaolo Bonzini#########################################
2402299e6f19SPaolo Bonzini# vhost interdependencies and host support
2403299e6f19SPaolo Bonzini
2404299e6f19SPaolo Bonzini# vhost backends
2405d88618f7SStefan Hajnocziif test "$vhost_user" = "yes" && test "$linux" != "yes"; then
2406d88618f7SStefan Hajnoczi  error_exit "vhost-user is only available on Linux"
2407299e6f19SPaolo Bonzinifi
2408108a6481SCindy Lutest "$vhost_vdpa" = "" && vhost_vdpa=$linux
2409108a6481SCindy Luif test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then
2410108a6481SCindy Lu  error_exit "vhost-vdpa is only available on Linux"
2411108a6481SCindy Lufi
2412299e6f19SPaolo Bonzinitest "$vhost_kernel" = "" && vhost_kernel=$linux
2413299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then
2414299e6f19SPaolo Bonzini  error_exit "vhost-kernel is only available on Linux"
2415299e6f19SPaolo Bonzinifi
2416299e6f19SPaolo Bonzini
2417299e6f19SPaolo Bonzini# vhost-kernel devices
2418299e6f19SPaolo Bonzinitest "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel
2419299e6f19SPaolo Bonziniif test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then
2420299e6f19SPaolo Bonzini  error_exit "--enable-vhost-scsi requires --enable-vhost-kernel"
2421299e6f19SPaolo Bonzinifi
2422299e6f19SPaolo Bonzinitest "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel
2423299e6f19SPaolo Bonziniif test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then
2424299e6f19SPaolo Bonzini  error_exit "--enable-vhost-vsock requires --enable-vhost-kernel"
2425299e6f19SPaolo Bonzinifi
2426299e6f19SPaolo Bonzini
2427299e6f19SPaolo Bonzini# vhost-user backends
2428299e6f19SPaolo Bonzinitest "$vhost_net_user" = "" && vhost_net_user=$vhost_user
2429299e6f19SPaolo Bonziniif test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then
2430299e6f19SPaolo Bonzini  error_exit "--enable-vhost-net-user requires --enable-vhost-user"
2431299e6f19SPaolo Bonzinifi
2432299e6f19SPaolo Bonzinitest "$vhost_crypto" = "" && vhost_crypto=$vhost_user
2433299e6f19SPaolo Bonziniif test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then
2434299e6f19SPaolo Bonzini  error_exit "--enable-vhost-crypto requires --enable-vhost-user"
2435299e6f19SPaolo Bonzinifi
243698fc1adaSDr. David Alan Gilberttest "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user
243798fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then
243898fc1adaSDr. David Alan Gilbert  error_exit "--enable-vhost-user-fs requires --enable-vhost-user"
243998fc1adaSDr. David Alan Gilbertfi
2440108a6481SCindy Lu#vhost-vdpa backends
2441108a6481SCindy Lutest "$vhost_net_vdpa" = "" && vhost_net_vdpa=$vhost_vdpa
2442108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" && test "$vhost_vdpa" = "no"; then
2443108a6481SCindy Lu  error_exit "--enable-vhost-net-vdpa requires --enable-vhost-vdpa"
2444108a6481SCindy Lufi
2445299e6f19SPaolo Bonzini
244640bc0ca9SLaurent Vivier# OR the vhost-kernel, vhost-vdpa and vhost-user values for simplicity
2447299e6f19SPaolo Bonziniif test "$vhost_net" = ""; then
2448299e6f19SPaolo Bonzini  test "$vhost_net_user" = "yes" && vhost_net=yes
244940bc0ca9SLaurent Vivier  test "$vhost_net_vdpa" = "yes" && vhost_net=yes
2450299e6f19SPaolo Bonzini  test "$vhost_kernel" = "yes" && vhost_net=yes
2451299e6f19SPaolo Bonzinifi
2452299e6f19SPaolo Bonzini
2453015a33bdSGonglei##########################################
2454779ab5e3SStefan Weil# pkg-config probe
2455779ab5e3SStefan Weil
2456779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then
245776ad07a4SPeter Maydell  error_exit "pkg-config binary '$pkg_config_exe' not found"
2458779ab5e3SStefan Weilfi
2459779ab5e3SStefan Weil
2460779ab5e3SStefan Weil##########################################
2461b0a47e79SJuan Quintela# NPTL probe
2462b0a47e79SJuan Quintela
246324cb36a6SPeter Maydellif test "$linux_user" = "yes"; then
2464bd0c5661Spbrook  cat > $TMPC <<EOF
2465bd0c5661Spbrook#include <sched.h>
246630813ceaSpbrook#include <linux/futex.h>
2467182eacc0SStefan Weilint main(void) {
2468bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
2469bd0c5661Spbrook#error bork
2470bd0c5661Spbrook#endif
2471182eacc0SStefan Weil  return 0;
2472bd0c5661Spbrook}
2473bd0c5661SpbrookEOF
247424cb36a6SPeter Maydell  if ! compile_object ; then
247521684af0SStewart Smith    feature_not_found "nptl" "Install glibc and linux kernel headers."
2476b0a47e79SJuan Quintela  fi
2477bd0c5661Spbrookfi
2478bd0c5661Spbrook
2479ac62922eSbalrog##########################################
2480e37630caSaliguori# xen probe
2481e37630caSaliguori
24821badb709SPaolo Bonziniif test "$xen" != "disabled" ; then
2483c1cdd9d5SJuergen Gross  # Check whether Xen library path is specified via --extra-ldflags to avoid
2484c1cdd9d5SJuergen Gross  # overriding this setting with pkg-config output. If not, try pkg-config
2485c1cdd9d5SJuergen Gross  # to obtain all needed flags.
2486c1cdd9d5SJuergen Gross
2487c1cdd9d5SJuergen Gross  if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2488c1cdd9d5SJuergen Gross     $pkg_config --exists xencontrol ; then
2489c1cdd9d5SJuergen Gross    xen_ctrl_version="$(printf '%d%02d%02d' \
2490c1cdd9d5SJuergen Gross      $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
24911badb709SPaolo Bonzini    xen=enabled
24925b6a8f43SMichael Tokarev    xen_pc="xencontrol xenstore xenforeignmemory xengnttab"
2493c1cdd9d5SJuergen Gross    xen_pc="$xen_pc xenevtchn xendevicemodel"
249458ea9a7aSAnthony PERARD    if $pkg_config --exists xentoolcore; then
249558ea9a7aSAnthony PERARD      xen_pc="$xen_pc xentoolcore"
249658ea9a7aSAnthony PERARD    fi
2497582ea95fSMarc-André Lureau    xen_cflags="$($pkg_config --cflags $xen_pc)"
2498582ea95fSMarc-André Lureau    xen_libs="$($pkg_config --libs $xen_pc)"
2499c1cdd9d5SJuergen Gross  else
2500c1cdd9d5SJuergen Gross
25015b6a8f43SMichael Tokarev    xen_libs="-lxenstore -lxenctrl"
2502d9506cabSAnthony PERARD    xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
2503d5b93ddfSAnthony PERARD
250450ced5b3SStefan Weil    # First we test whether Xen headers and libraries are available.
250550ced5b3SStefan Weil    # If no, we are done and there is no Xen support.
250650ced5b3SStefan Weil    # If yes, more tests are run to detect the Xen version.
250750ced5b3SStefan Weil
250850ced5b3SStefan Weil    # Xen (any)
250950ced5b3SStefan Weil    cat > $TMPC <<EOF
251050ced5b3SStefan Weil#include <xenctrl.h>
251150ced5b3SStefan Weilint main(void) {
251250ced5b3SStefan Weil  return 0;
251350ced5b3SStefan Weil}
251450ced5b3SStefan WeilEOF
251550ced5b3SStefan Weil    if ! compile_prog "" "$xen_libs" ; then
251650ced5b3SStefan Weil      # Xen not found
25171badb709SPaolo Bonzini      if test "$xen" = "enabled" ; then
251821684af0SStewart Smith        feature_not_found "xen" "Install xen devel"
251950ced5b3SStefan Weil      fi
25201badb709SPaolo Bonzini      xen=disabled
252150ced5b3SStefan Weil
2522d5b93ddfSAnthony PERARD    # Xen unstable
252369deef08SPeter Maydell    elif
252469deef08SPeter Maydell        cat > $TMPC <<EOF &&
25252cbf8903SRoss Lagerwall#undef XC_WANT_COMPAT_DEVICEMODEL_API
25262cbf8903SRoss Lagerwall#define __XEN_TOOLS__
25272cbf8903SRoss Lagerwall#include <xendevicemodel.h>
2528d3c49ebbSPaul Durrant#include <xenforeignmemory.h>
25292cbf8903SRoss Lagerwallint main(void) {
25302cbf8903SRoss Lagerwall  xendevicemodel_handle *xd;
2531d3c49ebbSPaul Durrant  xenforeignmemory_handle *xfmem;
25322cbf8903SRoss Lagerwall
25332cbf8903SRoss Lagerwall  xd = xendevicemodel_open(0, 0);
25342cbf8903SRoss Lagerwall  xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
25352cbf8903SRoss Lagerwall
2536d3c49ebbSPaul Durrant  xfmem = xenforeignmemory_open(0, 0);
2537d3c49ebbSPaul Durrant  xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
2538d3c49ebbSPaul Durrant
25392cbf8903SRoss Lagerwall  return 0;
25402cbf8903SRoss Lagerwall}
25412cbf8903SRoss LagerwallEOF
25422cbf8903SRoss Lagerwall        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
25432cbf8903SRoss Lagerwall      then
25442cbf8903SRoss Lagerwall      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
25452cbf8903SRoss Lagerwall      xen_ctrl_version=41100
25461badb709SPaolo Bonzini      xen=enabled
25472cbf8903SRoss Lagerwall    elif
25482cbf8903SRoss Lagerwall        cat > $TMPC <<EOF &&
25495ba3d756SIgor Druzhinin#undef XC_WANT_COMPAT_MAP_FOREIGN_API
25505ba3d756SIgor Druzhinin#include <xenforeignmemory.h>
255158ea9a7aSAnthony PERARD#include <xentoolcore.h>
25525ba3d756SIgor Druzhininint main(void) {
25535ba3d756SIgor Druzhinin  xenforeignmemory_handle *xfmem;
25545ba3d756SIgor Druzhinin
25555ba3d756SIgor Druzhinin  xfmem = xenforeignmemory_open(0, 0);
25565ba3d756SIgor Druzhinin  xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
255758ea9a7aSAnthony PERARD  xentoolcore_restrict_all(0);
25585ba3d756SIgor Druzhinin
25595ba3d756SIgor Druzhinin  return 0;
25605ba3d756SIgor Druzhinin}
25615ba3d756SIgor DruzhininEOF
256258ea9a7aSAnthony PERARD        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
25635ba3d756SIgor Druzhinin      then
256458ea9a7aSAnthony PERARD      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
25655ba3d756SIgor Druzhinin      xen_ctrl_version=41000
25661badb709SPaolo Bonzini      xen=enabled
25675ba3d756SIgor Druzhinin    elif
25685ba3d756SIgor Druzhinin        cat > $TMPC <<EOF &&
2569da8090ccSPaul Durrant#undef XC_WANT_COMPAT_DEVICEMODEL_API
2570da8090ccSPaul Durrant#define __XEN_TOOLS__
2571da8090ccSPaul Durrant#include <xendevicemodel.h>
2572da8090ccSPaul Durrantint main(void) {
2573da8090ccSPaul Durrant  xendevicemodel_handle *xd;
2574da8090ccSPaul Durrant
2575da8090ccSPaul Durrant  xd = xendevicemodel_open(0, 0);
2576da8090ccSPaul Durrant  xendevicemodel_close(xd);
2577da8090ccSPaul Durrant
2578da8090ccSPaul Durrant  return 0;
2579da8090ccSPaul Durrant}
2580da8090ccSPaul DurrantEOF
2581da8090ccSPaul Durrant        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2582da8090ccSPaul Durrant      then
2583da8090ccSPaul Durrant      xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2584f1167ee6SJuergen Gross      xen_ctrl_version=40900
25851badb709SPaolo Bonzini      xen=enabled
2586da8090ccSPaul Durrant    elif
2587da8090ccSPaul Durrant        cat > $TMPC <<EOF &&
25885eeb39c2SIan Campbell/*
25895eeb39c2SIan Campbell * If we have stable libs the we don't want the libxc compat
25905eeb39c2SIan Campbell * layers, regardless of what CFLAGS we may have been given.
2591b6eb9b45SPaulina Szubarczyk *
2592b6eb9b45SPaulina Szubarczyk * Also, check if xengnttab_grant_copy_segment_t is defined and
2593b6eb9b45SPaulina Szubarczyk * grant copy operation is implemented.
2594b6eb9b45SPaulina Szubarczyk */
2595b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_EVTCHN_API
2596b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_GNTTAB_API
2597b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2598b6eb9b45SPaulina Szubarczyk#include <xenctrl.h>
2599b6eb9b45SPaulina Szubarczyk#include <xenstore.h>
2600b6eb9b45SPaulina Szubarczyk#include <xenevtchn.h>
2601b6eb9b45SPaulina Szubarczyk#include <xengnttab.h>
2602b6eb9b45SPaulina Szubarczyk#include <xenforeignmemory.h>
2603b6eb9b45SPaulina Szubarczyk#include <stdint.h>
2604b6eb9b45SPaulina Szubarczyk#include <xen/hvm/hvm_info_table.h>
2605b6eb9b45SPaulina Szubarczyk#if !defined(HVM_MAX_VCPUS)
2606b6eb9b45SPaulina Szubarczyk# error HVM_MAX_VCPUS not defined
2607b6eb9b45SPaulina Szubarczyk#endif
2608b6eb9b45SPaulina Szubarczykint main(void) {
2609b6eb9b45SPaulina Szubarczyk  xc_interface *xc = NULL;
2610b6eb9b45SPaulina Szubarczyk  xenforeignmemory_handle *xfmem;
2611b6eb9b45SPaulina Szubarczyk  xenevtchn_handle *xe;
2612b6eb9b45SPaulina Szubarczyk  xengnttab_handle *xg;
2613b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy_segment_t* seg = NULL;
2614b6eb9b45SPaulina Szubarczyk
2615b6eb9b45SPaulina Szubarczyk  xs_daemon_open();
2616b6eb9b45SPaulina Szubarczyk
2617b6eb9b45SPaulina Szubarczyk  xc = xc_interface_open(0, 0, 0);
2618b6eb9b45SPaulina Szubarczyk  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2619b6eb9b45SPaulina Szubarczyk  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2620b6eb9b45SPaulina Szubarczyk  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2621b6eb9b45SPaulina Szubarczyk  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2622b6eb9b45SPaulina Szubarczyk
2623b6eb9b45SPaulina Szubarczyk  xfmem = xenforeignmemory_open(0, 0);
2624b6eb9b45SPaulina Szubarczyk  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2625b6eb9b45SPaulina Szubarczyk
2626b6eb9b45SPaulina Szubarczyk  xe = xenevtchn_open(0, 0);
2627b6eb9b45SPaulina Szubarczyk  xenevtchn_fd(xe);
2628b6eb9b45SPaulina Szubarczyk
2629b6eb9b45SPaulina Szubarczyk  xg = xengnttab_open(0, 0);
2630b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy(xg, 0, seg);
2631b6eb9b45SPaulina Szubarczyk
2632b6eb9b45SPaulina Szubarczyk  return 0;
2633b6eb9b45SPaulina Szubarczyk}
2634b6eb9b45SPaulina SzubarczykEOF
2635b6eb9b45SPaulina Szubarczyk        compile_prog "" "$xen_libs $xen_stable_libs"
2636b6eb9b45SPaulina Szubarczyk      then
2637f1167ee6SJuergen Gross      xen_ctrl_version=40800
26381badb709SPaolo Bonzini      xen=enabled
2639b6eb9b45SPaulina Szubarczyk    elif
2640b6eb9b45SPaulina Szubarczyk        cat > $TMPC <<EOF &&
2641b6eb9b45SPaulina Szubarczyk/*
2642b6eb9b45SPaulina Szubarczyk * If we have stable libs the we don't want the libxc compat
2643b6eb9b45SPaulina Szubarczyk * layers, regardless of what CFLAGS we may have been given.
26445eeb39c2SIan Campbell */
26455eeb39c2SIan Campbell#undef XC_WANT_COMPAT_EVTCHN_API
26465eeb39c2SIan Campbell#undef XC_WANT_COMPAT_GNTTAB_API
26475eeb39c2SIan Campbell#undef XC_WANT_COMPAT_MAP_FOREIGN_API
26485eeb39c2SIan Campbell#include <xenctrl.h>
26495eeb39c2SIan Campbell#include <xenstore.h>
26505eeb39c2SIan Campbell#include <xenevtchn.h>
26515eeb39c2SIan Campbell#include <xengnttab.h>
26525eeb39c2SIan Campbell#include <xenforeignmemory.h>
26535eeb39c2SIan Campbell#include <stdint.h>
26545eeb39c2SIan Campbell#include <xen/hvm/hvm_info_table.h>
26555eeb39c2SIan Campbell#if !defined(HVM_MAX_VCPUS)
26565eeb39c2SIan Campbell# error HVM_MAX_VCPUS not defined
26575eeb39c2SIan Campbell#endif
26585eeb39c2SIan Campbellint main(void) {
26595eeb39c2SIan Campbell  xc_interface *xc = NULL;
26605eeb39c2SIan Campbell  xenforeignmemory_handle *xfmem;
26615eeb39c2SIan Campbell  xenevtchn_handle *xe;
26625eeb39c2SIan Campbell  xengnttab_handle *xg;
26635eeb39c2SIan Campbell
26645eeb39c2SIan Campbell  xs_daemon_open();
26655eeb39c2SIan Campbell
26665eeb39c2SIan Campbell  xc = xc_interface_open(0, 0, 0);
26675eeb39c2SIan Campbell  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
26685eeb39c2SIan Campbell  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
26695eeb39c2SIan Campbell  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
26705eeb39c2SIan Campbell  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
26715eeb39c2SIan Campbell
26725eeb39c2SIan Campbell  xfmem = xenforeignmemory_open(0, 0);
26735eeb39c2SIan Campbell  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
26745eeb39c2SIan Campbell
26755eeb39c2SIan Campbell  xe = xenevtchn_open(0, 0);
26765eeb39c2SIan Campbell  xenevtchn_fd(xe);
26775eeb39c2SIan Campbell
26785eeb39c2SIan Campbell  xg = xengnttab_open(0, 0);
26795eeb39c2SIan Campbell  xengnttab_map_grant_ref(xg, 0, 0, 0);
26805eeb39c2SIan Campbell
26815eeb39c2SIan Campbell  return 0;
26825eeb39c2SIan Campbell}
26835eeb39c2SIan CampbellEOF
26845eeb39c2SIan Campbell        compile_prog "" "$xen_libs $xen_stable_libs"
26855eeb39c2SIan Campbell      then
2686f1167ee6SJuergen Gross      xen_ctrl_version=40701
26871badb709SPaolo Bonzini      xen=enabled
2688cdadde39SRoger Pau Monne
2689cdadde39SRoger Pau Monne    # Xen 4.6
2690cdadde39SRoger Pau Monne    elif
2691cdadde39SRoger Pau Monne        cat > $TMPC <<EOF &&
2692cdadde39SRoger Pau Monne#include <xenctrl.h>
2693e108a3c1SAnthony PERARD#include <xenstore.h>
2694d5b93ddfSAnthony PERARD#include <stdint.h>
2695d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
2696d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
2697d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
2698d5b93ddfSAnthony PERARD#endif
2699d5b93ddfSAnthony PERARDint main(void) {
2700d5b93ddfSAnthony PERARD  xc_interface *xc;
2701d5b93ddfSAnthony PERARD  xs_daemon_open();
2702d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
2703d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2704d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
2705b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
27068688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2707d8b441a3SJan Beulich  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
270820a544c7SKonrad Rzeszutek Wilk  xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2709d8b441a3SJan Beulich  return 0;
2710d8b441a3SJan Beulich}
2711d8b441a3SJan BeulichEOF
2712d8b441a3SJan Beulich        compile_prog "" "$xen_libs"
2713d8b441a3SJan Beulich      then
2714f1167ee6SJuergen Gross      xen_ctrl_version=40600
27151badb709SPaolo Bonzini      xen=enabled
2716d8b441a3SJan Beulich
2717d8b441a3SJan Beulich    # Xen 4.5
2718d8b441a3SJan Beulich    elif
2719d8b441a3SJan Beulich        cat > $TMPC <<EOF &&
2720d8b441a3SJan Beulich#include <xenctrl.h>
2721d8b441a3SJan Beulich#include <xenstore.h>
2722d8b441a3SJan Beulich#include <stdint.h>
2723d8b441a3SJan Beulich#include <xen/hvm/hvm_info_table.h>
2724d8b441a3SJan Beulich#if !defined(HVM_MAX_VCPUS)
2725d8b441a3SJan Beulich# error HVM_MAX_VCPUS not defined
2726d8b441a3SJan Beulich#endif
2727d8b441a3SJan Beulichint main(void) {
2728d8b441a3SJan Beulich  xc_interface *xc;
2729d8b441a3SJan Beulich  xs_daemon_open();
2730d8b441a3SJan Beulich  xc = xc_interface_open(0, 0, 0);
2731d8b441a3SJan Beulich  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2732d8b441a3SJan Beulich  xc_gnttab_open(NULL, 0);
2733d8b441a3SJan Beulich  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2734d8b441a3SJan Beulich  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
27353996e85cSPaul Durrant  xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
27363996e85cSPaul Durrant  return 0;
27373996e85cSPaul Durrant}
27383996e85cSPaul DurrantEOF
27393996e85cSPaul Durrant        compile_prog "" "$xen_libs"
27403996e85cSPaul Durrant      then
2741f1167ee6SJuergen Gross      xen_ctrl_version=40500
27421badb709SPaolo Bonzini      xen=enabled
27433996e85cSPaul Durrant
27443996e85cSPaul Durrant    elif
27453996e85cSPaul Durrant        cat > $TMPC <<EOF &&
27463996e85cSPaul Durrant#include <xenctrl.h>
27473996e85cSPaul Durrant#include <xenstore.h>
27483996e85cSPaul Durrant#include <stdint.h>
27493996e85cSPaul Durrant#include <xen/hvm/hvm_info_table.h>
27503996e85cSPaul Durrant#if !defined(HVM_MAX_VCPUS)
27513996e85cSPaul Durrant# error HVM_MAX_VCPUS not defined
27523996e85cSPaul Durrant#endif
27533996e85cSPaul Durrantint main(void) {
27543996e85cSPaul Durrant  xc_interface *xc;
27553996e85cSPaul Durrant  xs_daemon_open();
27563996e85cSPaul Durrant  xc = xc_interface_open(0, 0, 0);
27573996e85cSPaul Durrant  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
27583996e85cSPaul Durrant  xc_gnttab_open(NULL, 0);
27593996e85cSPaul Durrant  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
27603996e85cSPaul Durrant  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
27618688e065SStefano Stabellini  return 0;
27628688e065SStefano Stabellini}
27638688e065SStefano StabelliniEOF
27648688e065SStefano Stabellini        compile_prog "" "$xen_libs"
276569deef08SPeter Maydell      then
2766f1167ee6SJuergen Gross      xen_ctrl_version=40200
27671badb709SPaolo Bonzini      xen=enabled
27688688e065SStefano Stabellini
2769e37630caSaliguori    else
27701badb709SPaolo Bonzini      if test "$xen" = "enabled" ; then
2771edfb07edSIan Campbell        feature_not_found "xen (unsupported version)" \
2772edfb07edSIan Campbell                          "Install a supported xen (xen 4.2 or newer)"
2773fc321b4bSJuan Quintela      fi
27741badb709SPaolo Bonzini      xen=disabled
2775e37630caSaliguori    fi
2776d5b93ddfSAnthony PERARD
27771badb709SPaolo Bonzini    if test "$xen" = enabled; then
2778f1167ee6SJuergen Gross      if test $xen_ctrl_version -ge 40701  ; then
2779582ea95fSMarc-André Lureau        xen_libs="$xen_libs $xen_stable_libs "
27805eeb39c2SIan Campbell      fi
2781d5b93ddfSAnthony PERARD    fi
2782e37630caSaliguori  fi
2783c1cdd9d5SJuergen Grossfi
2784e37630caSaliguori
2785d661d9a4SJustin Terry (VM)##########################################
27862da776dbSMichael R. Hines# RDMA needs OpenFabrics libraries
27872da776dbSMichael R. Hinesif test "$rdma" != "no" ; then
27882da776dbSMichael R. Hines  cat > $TMPC <<EOF
27892da776dbSMichael R. Hines#include <rdma/rdma_cma.h>
27902da776dbSMichael R. Hinesint main(void) { return 0; }
27912da776dbSMichael R. HinesEOF
2792ef6d4ccdSYuval Shaia  rdma_libs="-lrdmacm -libverbs -libumad"
27932da776dbSMichael R. Hines  if compile_prog "" "$rdma_libs" ; then
27942da776dbSMichael R. Hines    rdma="yes"
27952da776dbSMichael R. Hines  else
27962da776dbSMichael R. Hines    if test "$rdma" = "yes" ; then
27972da776dbSMichael R. Hines        error_exit \
2798ef6d4ccdSYuval Shaia            " OpenFabrics librdmacm/libibverbs/libibumad not present." \
27992da776dbSMichael R. Hines            " Your options:" \
2800ef6d4ccdSYuval Shaia            "  (1) Fast: Install infiniband packages (devel) from your distro." \
28012da776dbSMichael R. Hines            "  (2) Cleanest: Install libraries from www.openfabrics.org" \
28022da776dbSMichael R. Hines            "  (3) Also: Install softiwarp if you don't have RDMA hardware"
28032da776dbSMichael R. Hines    fi
28042da776dbSMichael R. Hines    rdma="no"
28052da776dbSMichael R. Hines  fi
28062da776dbSMichael R. Hinesfi
28072da776dbSMichael R. Hines
280821ab34c9SMarcel Apfelbaum##########################################
280921ab34c9SMarcel Apfelbaum# PVRDMA detection
281021ab34c9SMarcel Apfelbaum
281121ab34c9SMarcel Apfelbaumcat > $TMPC <<EOF &&
281221ab34c9SMarcel Apfelbaum#include <sys/mman.h>
281321ab34c9SMarcel Apfelbaum
281421ab34c9SMarcel Apfelbaumint
281521ab34c9SMarcel Apfelbaummain(void)
281621ab34c9SMarcel Apfelbaum{
281721ab34c9SMarcel Apfelbaum    char buf = 0;
281821ab34c9SMarcel Apfelbaum    void *addr = &buf;
281921ab34c9SMarcel Apfelbaum    addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED);
282021ab34c9SMarcel Apfelbaum
282121ab34c9SMarcel Apfelbaum    return 0;
282221ab34c9SMarcel Apfelbaum}
282321ab34c9SMarcel ApfelbaumEOF
282421ab34c9SMarcel Apfelbaum
282521ab34c9SMarcel Apfelbaumif test "$rdma" = "yes" ; then
282621ab34c9SMarcel Apfelbaum    case "$pvrdma" in
282721ab34c9SMarcel Apfelbaum    "")
282821ab34c9SMarcel Apfelbaum        if compile_prog "" ""; then
282921ab34c9SMarcel Apfelbaum            pvrdma="yes"
283021ab34c9SMarcel Apfelbaum        else
283121ab34c9SMarcel Apfelbaum            pvrdma="no"
283221ab34c9SMarcel Apfelbaum        fi
283321ab34c9SMarcel Apfelbaum        ;;
283421ab34c9SMarcel Apfelbaum    "yes")
283521ab34c9SMarcel Apfelbaum        if ! compile_prog "" ""; then
283621ab34c9SMarcel Apfelbaum            error_exit "PVRDMA is not supported since mremap is not implemented"
283721ab34c9SMarcel Apfelbaum        fi
283821ab34c9SMarcel Apfelbaum        pvrdma="yes"
283921ab34c9SMarcel Apfelbaum        ;;
284021ab34c9SMarcel Apfelbaum    "no")
284121ab34c9SMarcel Apfelbaum        pvrdma="no"
284221ab34c9SMarcel Apfelbaum        ;;
284321ab34c9SMarcel Apfelbaum    esac
284421ab34c9SMarcel Apfelbaumelse
284521ab34c9SMarcel Apfelbaum    if test "$pvrdma" = "yes" ; then
284621ab34c9SMarcel Apfelbaum        error_exit "PVRDMA requires rdma suppport"
284721ab34c9SMarcel Apfelbaum    fi
284821ab34c9SMarcel Apfelbaum    pvrdma="no"
284921ab34c9SMarcel Apfelbaumfi
285095c6bff3SBenoît Canet
2851ee108585SYuval Shaia# Let's see if enhanced reg_mr is supported
2852ee108585SYuval Shaiaif test "$pvrdma" = "yes" ; then
2853ee108585SYuval Shaia
2854ee108585SYuval Shaiacat > $TMPC <<EOF &&
2855ee108585SYuval Shaia#include <infiniband/verbs.h>
2856ee108585SYuval Shaia
2857ee108585SYuval Shaiaint
2858ee108585SYuval Shaiamain(void)
2859ee108585SYuval Shaia{
2860ee108585SYuval Shaia    struct ibv_mr *mr;
2861ee108585SYuval Shaia    struct ibv_pd *pd = NULL;
2862ee108585SYuval Shaia    size_t length = 10;
2863ee108585SYuval Shaia    uint64_t iova = 0;
2864ee108585SYuval Shaia    int access = 0;
2865ee108585SYuval Shaia    void *addr = NULL;
2866ee108585SYuval Shaia
2867ee108585SYuval Shaia    mr = ibv_reg_mr_iova(pd, addr, length, iova, access);
2868ee108585SYuval Shaia
2869ee108585SYuval Shaia    ibv_dereg_mr(mr);
2870ee108585SYuval Shaia
2871ee108585SYuval Shaia    return 0;
2872ee108585SYuval Shaia}
2873ee108585SYuval ShaiaEOF
2874ee108585SYuval Shaia    if ! compile_prog "" "-libverbs"; then
2875ee108585SYuval Shaia        QEMU_CFLAGS="$QEMU_CFLAGS -DLEGACY_RDMA_REG_MR"
2876ee108585SYuval Shaia    fi
2877ee108585SYuval Shaiafi
2878ee108585SYuval Shaia
287995c6bff3SBenoît Canet##########################################
2880c1bb86cdSEric Blake# xfsctl() probe, used for file-posix.c
2881dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
2882dce512deSChristoph Hellwig  cat > $TMPC << EOF
2883ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
2884dce512deSChristoph Hellwig#include <xfs/xfs.h>
2885dce512deSChristoph Hellwigint main(void)
2886dce512deSChristoph Hellwig{
2887dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
2888dce512deSChristoph Hellwig    return 0;
2889dce512deSChristoph Hellwig}
2890dce512deSChristoph HellwigEOF
2891dce512deSChristoph Hellwig  if compile_prog "" "" ; then
2892dce512deSChristoph Hellwig    xfs="yes"
2893dce512deSChristoph Hellwig  else
2894dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
2895e3a6e0daSzhaolichang      feature_not_found "xfs" "Install xfsprogs/xfslibs devel"
2896dce512deSChristoph Hellwig    fi
2897dce512deSChristoph Hellwig    xfs=no
2898dce512deSChristoph Hellwig  fi
2899dce512deSChristoph Hellwigfi
2900dce512deSChristoph Hellwig
2901dce512deSChristoph Hellwig##########################################
29028a16d273Sths# vde libraries probe
2903dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
29044baae0acSJuan Quintela  vde_libs="-lvdeplug"
29058a16d273Sths  cat > $TMPC << EOF
29068a16d273Sths#include <libvdeplug.h>
29074a7f0e06Spbrookint main(void)
29084a7f0e06Spbrook{
29094a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
2910fea08e08SPeter Maydell    char s[] = "";
2911fea08e08SPeter Maydell    vde_open(s, s, &a);
29124a7f0e06Spbrook    return 0;
29134a7f0e06Spbrook}
29148a16d273SthsEOF
291552166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
29164baae0acSJuan Quintela    vde=yes
2917dfb278bdSJuan Quintela  else
2918dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
291921684af0SStewart Smith      feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
2920dfb278bdSJuan Quintela    fi
2921dfb278bdSJuan Quintela    vde=no
29228a16d273Sths  fi
29238a16d273Sthsfi
29248a16d273Sths
29258a16d273Sths##########################################
29260a985b37SVincenzo Maffione# netmap support probe
29270a985b37SVincenzo Maffione# Apart from looking for netmap headers, we make sure that the host API version
29280a985b37SVincenzo Maffione# supports the netmap backend (>=11). The upper bound (15) is meant to simulate
29290a985b37SVincenzo Maffione# a minor/major version number. Minor new features will be marked with values up
29300a985b37SVincenzo Maffione# to 15, and if something happens that requires a change to the backend we will
29310a985b37SVincenzo Maffione# move above 15, submit the backend fixes and modify this two bounds.
293258952137SVincenzo Maffioneif test "$netmap" != "no" ; then
293358952137SVincenzo Maffione  cat > $TMPC << EOF
293458952137SVincenzo Maffione#include <inttypes.h>
293558952137SVincenzo Maffione#include <net/if.h>
293658952137SVincenzo Maffione#include <net/netmap.h>
293758952137SVincenzo Maffione#include <net/netmap_user.h>
29380a985b37SVincenzo Maffione#if (NETMAP_API < 11) || (NETMAP_API > 15)
29390a985b37SVincenzo Maffione#error
29400a985b37SVincenzo Maffione#endif
294158952137SVincenzo Maffioneint main(void) { return 0; }
294258952137SVincenzo MaffioneEOF
294358952137SVincenzo Maffione  if compile_prog "" "" ; then
294458952137SVincenzo Maffione    netmap=yes
294558952137SVincenzo Maffione  else
294658952137SVincenzo Maffione    if test "$netmap" = "yes" ; then
294758952137SVincenzo Maffione      feature_not_found "netmap"
294858952137SVincenzo Maffione    fi
294958952137SVincenzo Maffione    netmap=no
295058952137SVincenzo Maffione  fi
295158952137SVincenzo Maffionefi
295258952137SVincenzo Maffione
295358952137SVincenzo Maffione##########################################
2954ba4dd2aaSAlex Bennée# plugin linker support probe
2955ba4dd2aaSAlex Bennée
2956ba4dd2aaSAlex Bennéeif test "$plugins" != "no"; then
2957ba4dd2aaSAlex Bennée
2958ba4dd2aaSAlex Bennée    #########################################
2959ba4dd2aaSAlex Bennée    # See if --dynamic-list is supported by the linker
2960ba4dd2aaSAlex Bennée
2961ba4dd2aaSAlex Bennée    ld_dynamic_list="no"
2962ba4dd2aaSAlex Bennée    cat > $TMPTXT <<EOF
2963ba4dd2aaSAlex Bennée{
2964ba4dd2aaSAlex Bennée  foo;
2965ba4dd2aaSAlex Bennée};
2966ba4dd2aaSAlex BennéeEOF
2967ba4dd2aaSAlex Bennée
2968ba4dd2aaSAlex Bennée        cat > $TMPC <<EOF
2969ba4dd2aaSAlex Bennée#include <stdio.h>
2970ba4dd2aaSAlex Bennéevoid foo(void);
2971ba4dd2aaSAlex Bennée
2972ba4dd2aaSAlex Bennéevoid foo(void)
2973ba4dd2aaSAlex Bennée{
2974ba4dd2aaSAlex Bennée  printf("foo\n");
2975ba4dd2aaSAlex Bennée}
2976ba4dd2aaSAlex Bennée
2977ba4dd2aaSAlex Bennéeint main(void)
2978ba4dd2aaSAlex Bennée{
2979ba4dd2aaSAlex Bennée  foo();
2980ba4dd2aaSAlex Bennée  return 0;
2981ba4dd2aaSAlex Bennée}
2982ba4dd2aaSAlex BennéeEOF
2983ba4dd2aaSAlex Bennée
2984ba4dd2aaSAlex Bennée    if compile_prog "" "-Wl,--dynamic-list=$TMPTXT" ; then
2985ba4dd2aaSAlex Bennée        ld_dynamic_list="yes"
2986ba4dd2aaSAlex Bennée    fi
2987ba4dd2aaSAlex Bennée
2988ba4dd2aaSAlex Bennée    #########################################
2989ba4dd2aaSAlex Bennée    # See if -exported_symbols_list is supported by the linker
2990ba4dd2aaSAlex Bennée
2991ba4dd2aaSAlex Bennée    ld_exported_symbols_list="no"
2992ba4dd2aaSAlex Bennée    cat > $TMPTXT <<EOF
2993ba4dd2aaSAlex Bennée  _foo
2994ba4dd2aaSAlex BennéeEOF
2995ba4dd2aaSAlex Bennée
2996ba4dd2aaSAlex Bennée    if compile_prog "" "-Wl,-exported_symbols_list,$TMPTXT" ; then
2997ba4dd2aaSAlex Bennée        ld_exported_symbols_list="yes"
2998ba4dd2aaSAlex Bennée    fi
2999ba4dd2aaSAlex Bennée
3000ba4dd2aaSAlex Bennée    if test "$ld_dynamic_list" = "no" &&
3001ba4dd2aaSAlex Bennée       test "$ld_exported_symbols_list" = "no" ; then
3002ba4dd2aaSAlex Bennée        if test "$plugins" = "yes"; then
3003ba4dd2aaSAlex Bennée            error_exit \
3004ba4dd2aaSAlex Bennée                "Plugin support requires dynamic linking and specifying a set of symbols " \
3005ba4dd2aaSAlex Bennée                "that are exported to plugins. Unfortunately your linker doesn't " \
3006ba4dd2aaSAlex Bennée                "support the flag (--dynamic-list or -exported_symbols_list) used " \
3007ba4dd2aaSAlex Bennée                "for this purpose."
3008ba4dd2aaSAlex Bennée        else
3009ba4dd2aaSAlex Bennée            plugins="no"
3010ba4dd2aaSAlex Bennée        fi
3011ba4dd2aaSAlex Bennée    else
3012ba4dd2aaSAlex Bennée        plugins="yes"
3013ba4dd2aaSAlex Bennée    fi
3014ba4dd2aaSAlex Bennéefi
3015ba4dd2aaSAlex Bennée
3016ba4dd2aaSAlex Bennée##########################################
3017e18df141SAnthony Liguori# glib support probe
3018a52d28afSPaolo Bonzini
3019b4c6036fSDaniel P. Berrangéglib_req_ver=2.56
3020aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0
3021aa0d1f44SPaolo Bonziniif test "$modules" = yes; then
3022a88afc64SGerd Hoffmann    glib_modules="$glib_modules gmodule-export-2.0"
3023b906acacSPaolo Bonzinielif test "$plugins" = "yes"; then
3024b906acacSPaolo Bonzini    glib_modules="$glib_modules gmodule-no-export-2.0"
302554cb65d8SEmilio G. Cotafi
3026e26110cfSFam Zheng
3027aa0d1f44SPaolo Bonzinifor i in $glib_modules; do
3028e26110cfSFam Zheng    if $pkg_config --atleast-version=$glib_req_ver $i; then
302989138857SStefan Weil        glib_cflags=$($pkg_config --cflags $i)
303089138857SStefan Weil        glib_libs=$($pkg_config --libs $i)
3031e18df141SAnthony Liguori    else
3032e26110cfSFam Zheng        error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3033e26110cfSFam Zheng    fi
3034e26110cfSFam Zhengdone
3035e26110cfSFam Zheng
3036215b0c2fSPaolo Bonzini# This workaround is required due to a bug in pkg-config file for glib as it
3037215b0c2fSPaolo Bonzini# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
3038215b0c2fSPaolo Bonzini
3039215b0c2fSPaolo Bonziniif test "$static" = yes && test "$mingw32" = yes; then
3040215b0c2fSPaolo Bonzini    glib_cflags="-DGLIB_STATIC_COMPILATION $glib_cflags"
3041215b0c2fSPaolo Bonzinifi
3042215b0c2fSPaolo Bonzini
304320cf7b8eSDenis Plotnikovif ! test "$gio" = "no"; then
304420cf7b8eSDenis Plotnikov    pass=no
3045f876b765SMarc-André Lureau    if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
3046f876b765SMarc-André Lureau        gio_cflags=$($pkg_config --cflags gio-2.0)
3047f876b765SMarc-André Lureau        gio_libs=$($pkg_config --libs gio-2.0)
304825a97a56SMarc-André Lureau        gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0)
30495ecfb76cSPaolo Bonzini        if ! has "$gdbus_codegen"; then
30500dba4897SMarc-André Lureau            gdbus_codegen=
30510dba4897SMarc-André Lureau        fi
305276346b62SPeter Maydell        # Check that the libraries actually work -- Ubuntu 18.04 ships
305376346b62SPeter Maydell        # with pkg-config --static --libs data for gio-2.0 that is missing
305476346b62SPeter Maydell        # -lblkid and will give a link error.
305513ceae66SPeter Maydell        cat > $TMPC <<EOF
305613ceae66SPeter Maydell#include <gio/gio.h>
305713ceae66SPeter Maydellint main(void)
305813ceae66SPeter Maydell{
305913ceae66SPeter Maydell    g_dbus_proxy_new_sync(0, 0, 0, 0, 0, 0, 0, 0);
306013ceae66SPeter Maydell    return 0;
306113ceae66SPeter Maydell}
306213ceae66SPeter MaydellEOF
306313ceae66SPeter Maydell        if compile_prog "$gio_cflags" "$gio_libs" ; then
306420cf7b8eSDenis Plotnikov            pass=yes
306576346b62SPeter Maydell        else
306620cf7b8eSDenis Plotnikov            pass=no
3067f876b765SMarc-André Lureau        fi
3068f876b765SMarc-André Lureau
306920cf7b8eSDenis Plotnikov        if test "$pass" = "yes" &&
307020cf7b8eSDenis Plotnikov            $pkg_config --atleast-version=$glib_req_ver gio-unix-2.0; then
307125a97a56SMarc-André Lureau            gio_cflags="$gio_cflags $($pkg_config --cflags gio-unix-2.0)"
307225a97a56SMarc-André Lureau            gio_libs="$gio_libs $($pkg_config --libs gio-unix-2.0)"
307325a97a56SMarc-André Lureau        fi
307420cf7b8eSDenis Plotnikov    fi
307520cf7b8eSDenis Plotnikov
307620cf7b8eSDenis Plotnikov    if test "$pass" = "no"; then
307720cf7b8eSDenis Plotnikov        if test "$gio" = "yes"; then
307820cf7b8eSDenis Plotnikov            feature_not_found "gio" "Install libgio >= 2.0"
307920cf7b8eSDenis Plotnikov        else
308020cf7b8eSDenis Plotnikov            gio=no
308120cf7b8eSDenis Plotnikov        fi
308220cf7b8eSDenis Plotnikov    else
308320cf7b8eSDenis Plotnikov        gio=yes
308420cf7b8eSDenis Plotnikov    fi
308520cf7b8eSDenis Plotnikovfi
308625a97a56SMarc-André Lureau
3087977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the
3088977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches
3089977a82abSDaniel P. Berrange# problems on multi-arch where people try to build
3090977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers
3091977a82abSDaniel P. Berrangecat > $TMPC <<EOF
3092977a82abSDaniel P. Berrange#include <glib.h>
3093977a82abSDaniel P. Berrange#include <unistd.h>
3094977a82abSDaniel P. Berrange
3095977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \
3096977a82abSDaniel P. Berrange  typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3097977a82abSDaniel P. Berrange
3098977a82abSDaniel P. Berrangeint main(void) {
3099977a82abSDaniel P. Berrange   QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3100977a82abSDaniel P. Berrange   return 0;
3101977a82abSDaniel P. Berrange}
3102977a82abSDaniel P. BerrangeEOF
3103977a82abSDaniel P. Berrange
3104215b0c2fSPaolo Bonziniif ! compile_prog "$glib_cflags" "$glib_libs" ; then
3105977a82abSDaniel P. Berrange    error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3106977a82abSDaniel P. Berrange               "You probably need to set PKG_CONFIG_LIBDIR"\
3107977a82abSDaniel P. Berrange	       "to point to the right pkg-config files for your"\
3108977a82abSDaniel P. Berrange	       "build target"
3109977a82abSDaniel P. Berrangefi
3110977a82abSDaniel P. Berrange
31119bda600bSEric Blake# Silence clang warnings triggered by glib < 2.57.2
31129bda600bSEric Blakecat > $TMPC << EOF
31139bda600bSEric Blake#include <glib.h>
31149bda600bSEric Blaketypedef struct Foo {
31159bda600bSEric Blake    int i;
31169bda600bSEric Blake} Foo;
31179bda600bSEric Blakestatic void foo_free(Foo *f)
31189bda600bSEric Blake{
31199bda600bSEric Blake    g_free(f);
31209bda600bSEric Blake}
31219bda600bSEric BlakeG_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free);
31229bda600bSEric Blakeint main(void) { return 0; }
31239bda600bSEric BlakeEOF
31249bda600bSEric Blakeif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
31259bda600bSEric Blake    if cc_has_warning_flag "-Wno-unused-function"; then
31269bda600bSEric Blake        glib_cflags="$glib_cflags -Wno-unused-function"
31275770e8afSPaolo Bonzini        CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -Wno-unused-function"
31289bda600bSEric Blake    fi
31299bda600bSEric Blakefi
31309bda600bSEric Blake
3131e26110cfSFam Zheng##########################################
3132e26110cfSFam Zheng# SHA command probe for modules
3133e26110cfSFam Zhengif test "$modules" = yes; then
3134e26110cfSFam Zheng    shacmd_probe="sha1sum sha1 shasum"
3135e26110cfSFam Zheng    for c in $shacmd_probe; do
31368ccefb91SFam Zheng        if has $c; then
3137e26110cfSFam Zheng            shacmd="$c"
3138e26110cfSFam Zheng            break
3139e26110cfSFam Zheng        fi
3140e26110cfSFam Zheng    done
3141e26110cfSFam Zheng    if test "$shacmd" = ""; then
3142e26110cfSFam Zheng        error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3143e26110cfSFam Zheng    fi
3144e18df141SAnthony Liguorifi
3145e18df141SAnthony Liguori
3146e18df141SAnthony Liguori##########################################
3147e5d355d1Saliguori# pthread probe
31484b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
31493c529d93Saliguori
3150e5d355d1Saliguoripthread=no
3151414f0dabSblueswir1cat > $TMPC << EOF
31523c529d93Saliguori#include <pthread.h>
31537a42bbe4SStefan Weilstatic void *f(void *p) { return NULL; }
31547a42bbe4SStefan Weilint main(void) {
31557a42bbe4SStefan Weil  pthread_t thread;
31567a42bbe4SStefan Weil  pthread_create(&thread, 0, f, 0);
31577a42bbe4SStefan Weil  return 0;
31587a42bbe4SStefan Weil}
3159414f0dabSblueswir1EOF
3160bd00d539SAndreas Färberif compile_prog "" "" ; then
3161bd00d539SAndreas Färber  pthread=yes
3162bd00d539SAndreas Färberelse
3163de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
316452166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
3165e5d355d1Saliguori      pthread=yes
3166de65fe0fSSebastian Herbszt      break
3167414f0dabSblueswir1    fi
3168de65fe0fSSebastian Herbszt  done
3169bd00d539SAndreas Färberfi
3170414f0dabSblueswir1
3171e633a5c6SEric Blakeif test "$mingw32" != yes && test "$pthread" = no; then
317276ad07a4SPeter Maydell  error_exit "pthread check failed" \
317376ad07a4SPeter Maydell      "Make sure to have the pthread libs and headers installed."
3174e5d355d1Saliguorifi
3175e5d355d1Saliguori
3176479a5747SRoman Bolshakov# check for pthread_setname_np with thread id
3177479a5747SRoman Bolshakovpthread_setname_np_w_tid=no
31785c312079SDr. David Alan Gilbertcat > $TMPC << EOF
31795c312079SDr. David Alan Gilbert#include <pthread.h>
31805c312079SDr. David Alan Gilbert
31815c312079SDr. David Alan Gilbertstatic void *f(void *p) { return NULL; }
31825c312079SDr. David Alan Gilbertint main(void)
31835c312079SDr. David Alan Gilbert{
31845c312079SDr. David Alan Gilbert    pthread_t thread;
31855c312079SDr. David Alan Gilbert    pthread_create(&thread, 0, f, 0);
31865c312079SDr. David Alan Gilbert    pthread_setname_np(thread, "QEMU");
31875c312079SDr. David Alan Gilbert    return 0;
31885c312079SDr. David Alan Gilbert}
31895c312079SDr. David Alan GilbertEOF
31905c312079SDr. David Alan Gilbertif compile_prog "" "$pthread_lib" ; then
3191479a5747SRoman Bolshakov  pthread_setname_np_w_tid=yes
3192479a5747SRoman Bolshakovfi
3193479a5747SRoman Bolshakov
3194479a5747SRoman Bolshakov# check for pthread_setname_np without thread id
3195479a5747SRoman Bolshakovpthread_setname_np_wo_tid=no
3196479a5747SRoman Bolshakovcat > $TMPC << EOF
3197479a5747SRoman Bolshakov#include <pthread.h>
3198479a5747SRoman Bolshakov
319912a9b8d8SThomas Huthstatic void *f(void *p) { pthread_setname_np("QEMU"); return NULL; }
3200479a5747SRoman Bolshakovint main(void)
3201479a5747SRoman Bolshakov{
3202479a5747SRoman Bolshakov    pthread_t thread;
3203479a5747SRoman Bolshakov    pthread_create(&thread, 0, f, 0);
3204479a5747SRoman Bolshakov    return 0;
3205479a5747SRoman Bolshakov}
3206479a5747SRoman BolshakovEOF
3207479a5747SRoman Bolshakovif compile_prog "" "$pthread_lib" ; then
3208479a5747SRoman Bolshakov  pthread_setname_np_wo_tid=yes
32095c312079SDr. David Alan Gilbertfi
32105c312079SDr. David Alan Gilbert
3211bf9298b9Saliguori##########################################
3212b10d49d7SPino Toscano# libssh probe
3213b10d49d7SPino Toscanoif test "$libssh" != "no" ; then
3214b4c10fc6SThomas Huth  if $pkg_config --exists "libssh >= 0.8.7"; then
3215b10d49d7SPino Toscano    libssh_cflags=$($pkg_config libssh --cflags)
3216b10d49d7SPino Toscano    libssh_libs=$($pkg_config libssh --libs)
3217b10d49d7SPino Toscano    libssh=yes
32180a12ec87SRichard W.M. Jones  else
3219b10d49d7SPino Toscano    if test "$libssh" = "yes" ; then
3220b10d49d7SPino Toscano      error_exit "libssh required for --enable-libssh"
32210a12ec87SRichard W.M. Jones    fi
3222b10d49d7SPino Toscano    libssh=no
32230a12ec87SRichard W.M. Jones  fi
32240a12ec87SRichard W.M. Jonesfi
32250a12ec87SRichard W.M. Jones
32260a12ec87SRichard W.M. Jones##########################################
32275c6c3a6cSChristoph Hellwig# linux-aio probe
32285c6c3a6cSChristoph Hellwig
32295c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
32305c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
32315c6c3a6cSChristoph Hellwig#include <libaio.h>
32325c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
3233832ce9c2SScott Wood#include <stddef.h>
32345c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
32355c6c3a6cSChristoph HellwigEOF
32365c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
32375c6c3a6cSChristoph Hellwig    linux_aio=yes
32385c6c3a6cSChristoph Hellwig  else
32395c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
324021684af0SStewart Smith      feature_not_found "linux AIO" "Install libaio devel"
32415c6c3a6cSChristoph Hellwig    fi
32423cfcae3cSLuiz Capitulino    linux_aio=no
32435c6c3a6cSChristoph Hellwig  fi
32445c6c3a6cSChristoph Hellwigfi
32455c6c3a6cSChristoph Hellwig
32465c6c3a6cSChristoph Hellwig##########################################
32477aaa6a16SPaolo Bonzini# TPM emulation is only on POSIX
32483b8acc11SPaolo Bonzini
32497aaa6a16SPaolo Bonziniif test "$tpm" = ""; then
32507aaa6a16SPaolo Bonzini  if test "$mingw32" = "yes"; then
32517aaa6a16SPaolo Bonzini    tpm=no
32523b8acc11SPaolo Bonzini  else
32537aaa6a16SPaolo Bonzini    tpm=yes
32547aaa6a16SPaolo Bonzini  fi
32557aaa6a16SPaolo Bonzinielif test "$tpm" = "yes"; then
32567aaa6a16SPaolo Bonzini  if test "$mingw32" = "yes" ; then
32577aaa6a16SPaolo Bonzini    error_exit "TPM emulation only available on POSIX systems"
32587aaa6a16SPaolo Bonzini  fi
32593b8acc11SPaolo Bonzinifi
32603b8acc11SPaolo Bonzini
32613b8acc11SPaolo Bonzini##########################################
3262bf9298b9Saliguori# iovec probe
3263bf9298b9Saliguoricat > $TMPC <<EOF
3264db34f0b3Sblueswir1#include <sys/types.h>
3265bf9298b9Saliguori#include <sys/uio.h>
3266db34f0b3Sblueswir1#include <unistd.h>
3267f91f9beeSStefan Weilint main(void) { return sizeof(struct iovec); }
3268bf9298b9SaliguoriEOF
3269bf9298b9Saliguoriiovec=no
327052166aa0SJuan Quintelaif compile_prog "" "" ; then
3271bf9298b9Saliguori  iovec=yes
3272bf9298b9Saliguorifi
3273bf9298b9Saliguori
3274f652e6afSaurel32##########################################
3275f652e6afSaurel32# fdt probe
3276e169e1e1SPeter Maydell
3277fbb4121dSPaolo Bonzinicase "$fdt" in
3278fbb4121dSPaolo Bonzini  auto | enabled | internal)
3279fbb4121dSPaolo Bonzini    # Simpler to always update submodule, even if not needed.
3280aef45d51SDaniel P. Berrange    git_submodules="${git_submodules} dtc"
3281fbb4121dSPaolo Bonzini    ;;
3282fbb4121dSPaolo Bonziniesac
3283f652e6afSaurel32
328420ff075bSMichael Walle##########################################
32859d49bcf6SMarkus Armbruster# opengl probe (for sdl2, gtk)
3286b1546f32SGerd Hoffmann
3287da076ffeSGerd Hoffmannif test "$opengl" != "no" ; then
3288bc6a3565SAkihiko Odaki  epoxy=no
3289bc6a3565SAkihiko Odaki  if $pkg_config epoxy; then
3290bc6a3565SAkihiko Odaki    cat > $TMPC << EOF
3291bc6a3565SAkihiko Odaki#include <epoxy/egl.h>
3292bc6a3565SAkihiko Odakiint main(void) { return 0; }
3293bc6a3565SAkihiko OdakiEOF
3294bc6a3565SAkihiko Odaki    if compile_prog "" "" ; then
3295bc6a3565SAkihiko Odaki      epoxy=yes
3296bc6a3565SAkihiko Odaki    fi
3297bc6a3565SAkihiko Odaki  fi
3298bc6a3565SAkihiko Odaki
3299bc6a3565SAkihiko Odaki  if test "$epoxy" = "yes" ; then
3300bc6a3565SAkihiko Odaki    opengl_cflags="$($pkg_config --cflags epoxy)"
3301bc6a3565SAkihiko Odaki    opengl_libs="$($pkg_config --libs epoxy)"
3302da076ffeSGerd Hoffmann    opengl=yes
330320ff075bSMichael Walle  else
3304da076ffeSGerd Hoffmann    if test "$opengl" = "yes" ; then
3305bc6a3565SAkihiko Odaki      feature_not_found "opengl" "Please install epoxy with EGL"
330620ff075bSMichael Walle    fi
3307f676c67eSJeremy White    opengl_cflags=""
3308da076ffeSGerd Hoffmann    opengl_libs=""
3309da076ffeSGerd Hoffmann    opengl=no
331020ff075bSMichael Walle  fi
331120ff075bSMichael Wallefi
331220ff075bSMichael Walle
3313dcc38d1cSMarcelo Tosatti##########################################
3314a99d57bbSWanlong Gao# libnuma probe
3315a99d57bbSWanlong Gao
3316a99d57bbSWanlong Gaoif test "$numa" != "no" ; then
3317a99d57bbSWanlong Gao  cat > $TMPC << EOF
3318a99d57bbSWanlong Gao#include <numa.h>
3319a99d57bbSWanlong Gaoint main(void) { return numa_available(); }
3320a99d57bbSWanlong GaoEOF
3321a99d57bbSWanlong Gao
3322a99d57bbSWanlong Gao  if compile_prog "" "-lnuma" ; then
3323a99d57bbSWanlong Gao    numa=yes
3324ab318051SMarc-André Lureau    numa_libs="-lnuma"
3325a99d57bbSWanlong Gao  else
3326a99d57bbSWanlong Gao    if test "$numa" = "yes" ; then
3327a99d57bbSWanlong Gao      feature_not_found "numa" "install numactl devel"
3328a99d57bbSWanlong Gao    fi
3329a99d57bbSWanlong Gao    numa=no
3330a99d57bbSWanlong Gao  fi
3331a99d57bbSWanlong Gaofi
3332a99d57bbSWanlong Gao
3333aa087962SPaolo Bonzinimalloc=system
33347b01cb97SAlexandre Derumierif test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
33357b01cb97SAlexandre Derumier    echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
33367b01cb97SAlexandre Derumier    exit 1
3337aa087962SPaolo Bonzinielif test "$tcmalloc" = "yes" ; then
3338aa087962SPaolo Bonzini    malloc=tcmalloc
3339aa087962SPaolo Bonzinielif test "$jemalloc" = "yes" ; then
3340aa087962SPaolo Bonzini    malloc=jemalloc
33417b01cb97SAlexandre Derumierfi
33427b01cb97SAlexandre Derumier
3343955727d2SCortland Tölva# check for usbfs
3344955727d2SCortland Tölvahave_usbfs=no
3345955727d2SCortland Tölvaif test "$linux_user" = "yes"; then
334696566d09SThomas Petazzoni  cat > $TMPC << EOF
334796566d09SThomas Petazzoni#include <linux/usbdevice_fs.h>
334896566d09SThomas Petazzoni
334996566d09SThomas Petazzoni#ifndef USBDEVFS_GET_CAPABILITIES
335096566d09SThomas Petazzoni#error "USBDEVFS_GET_CAPABILITIES undefined"
335196566d09SThomas Petazzoni#endif
335296566d09SThomas Petazzoni
335396566d09SThomas Petazzoni#ifndef USBDEVFS_DISCONNECT_CLAIM
335496566d09SThomas Petazzoni#error "USBDEVFS_DISCONNECT_CLAIM undefined"
335596566d09SThomas Petazzoni#endif
335696566d09SThomas Petazzoni
335796566d09SThomas Petazzoniint main(void)
335896566d09SThomas Petazzoni{
335996566d09SThomas Petazzoni    return 0;
336096566d09SThomas Petazzoni}
336196566d09SThomas PetazzoniEOF
336296566d09SThomas Petazzoni  if compile_prog "" ""; then
3363955727d2SCortland Tölva    have_usbfs=yes
3364955727d2SCortland Tölva  fi
3365955727d2SCortland Tölvafi
3366751bcc39SMarc-André Lureau
3367de5071c5SBlue Swirl##########################################
3368cd4ec0b4SGerd Hoffmann# spice probe
336958d3f3ffSGerd Hoffmannif test "$spice_protocol" != "no" ; then
337058d3f3ffSGerd Hoffmann  spice_protocol_cflags=$($pkg_config --cflags spice-protocol 2>/dev/null)
337158d3f3ffSGerd Hoffmann  if $pkg_config --atleast-version=0.12.3 spice-protocol; then
337258d3f3ffSGerd Hoffmann    spice_protocol="yes"
337358d3f3ffSGerd Hoffmann  else
337458d3f3ffSGerd Hoffmann    if test "$spice_protocol" = "yes" ; then
337558d3f3ffSGerd Hoffmann      feature_not_found "spice_protocol" \
337658d3f3ffSGerd Hoffmann          "Install spice-protocol(>=0.12.3) devel"
337758d3f3ffSGerd Hoffmann    fi
337858d3f3ffSGerd Hoffmann    spice_protocol="no"
337958d3f3ffSGerd Hoffmann  fi
338058d3f3ffSGerd Hoffmannfi
338158d3f3ffSGerd Hoffmann
3382cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
3383cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
3384cd4ec0b4SGerd Hoffmann#include <spice.h>
3385cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
3386cd4ec0b4SGerd HoffmannEOF
3387710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
3388710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
33891b63665cSMarc-André Lureau  if $pkg_config --atleast-version=0.12.5 spice-server && \
339058d3f3ffSGerd Hoffmann     test "$spice_protocol" = "yes" && \
3391cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
3392cd4ec0b4SGerd Hoffmann    spice="yes"
3393cd4ec0b4SGerd Hoffmann  else
3394cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
33958efc9363SHu Tao      feature_not_found "spice" \
339658d3f3ffSGerd Hoffmann          "Install spice-server(>=0.12.5) devel"
3397cd4ec0b4SGerd Hoffmann    fi
3398cd4ec0b4SGerd Hoffmann    spice="no"
3399cd4ec0b4SGerd Hoffmann  fi
3400cd4ec0b4SGerd Hoffmannfi
3401cd4ec0b4SGerd Hoffmann
3402cd4ec0b4SGerd Hoffmann##########################################
3403d9840e25STomoki Sekiyama# check if we have VSS SDK headers for win
3404d9840e25STomoki Sekiyama
3405e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
3406e633a5c6SEric Blake        test "$vss_win32_sdk" != "no" ; then
3407d9840e25STomoki Sekiyama  case "$vss_win32_sdk" in
3408690604f6SMichael Roth    "")   vss_win32_include="-isystem $source_path" ;;
3409d9840e25STomoki Sekiyama    *\ *) # The SDK is installed in "Program Files" by default, but we cannot
3410d9840e25STomoki Sekiyama          # handle path with spaces. So we symlink the headers into ".sdk/vss".
3411690604f6SMichael Roth          vss_win32_include="-isystem $source_path/.sdk/vss"
3412d9840e25STomoki Sekiyama	  symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
3413d9840e25STomoki Sekiyama	  ;;
3414690604f6SMichael Roth    *)    vss_win32_include="-isystem $vss_win32_sdk"
3415d9840e25STomoki Sekiyama  esac
3416d9840e25STomoki Sekiyama  cat > $TMPC << EOF
3417d9840e25STomoki Sekiyama#define __MIDL_user_allocate_free_DEFINED__
3418d9840e25STomoki Sekiyama#include <inc/win2003/vss.h>
3419d9840e25STomoki Sekiyamaint main(void) { return VSS_CTX_BACKUP; }
3420d9840e25STomoki SekiyamaEOF
3421d9840e25STomoki Sekiyama  if compile_prog "$vss_win32_include" "" ; then
3422d9840e25STomoki Sekiyama    guest_agent_with_vss="yes"
3423d9840e25STomoki Sekiyama    QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
3424315d3184SFam Zheng    libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
3425f33ca81fSMichael Roth    qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
3426d9840e25STomoki Sekiyama  else
3427d9840e25STomoki Sekiyama    if test "$vss_win32_sdk" != "" ; then
3428d9840e25STomoki Sekiyama      echo "ERROR: Please download and install Microsoft VSS SDK:"
3429d9840e25STomoki Sekiyama      echo "ERROR:   http://www.microsoft.com/en-us/download/details.aspx?id=23490"
3430d9840e25STomoki Sekiyama      echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
3431d9840e25STomoki Sekiyama      echo "ERROR:   scripts/extract-vsssdk-headers setup.exe"
3432d9840e25STomoki Sekiyama      echo "ERROR: The headers are extracted in the directory \`inc'."
3433d9840e25STomoki Sekiyama      feature_not_found "VSS support"
3434d9840e25STomoki Sekiyama    fi
3435d9840e25STomoki Sekiyama    guest_agent_with_vss="no"
3436d9840e25STomoki Sekiyama  fi
3437d9840e25STomoki Sekiyamafi
3438d9840e25STomoki Sekiyama
3439d9840e25STomoki Sekiyama##########################################
3440d9840e25STomoki Sekiyama# lookup Windows platform SDK (if not specified)
3441d9840e25STomoki Sekiyama# The SDK is needed only to build .tlb (type library) file of guest agent
3442d9840e25STomoki Sekiyama# VSS provider from the source. It is usually unnecessary because the
3443d9840e25STomoki Sekiyama# pre-compiled .tlb file is included.
3444d9840e25STomoki Sekiyama
3445e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
3446e633a5c6SEric Blake        test "$guest_agent_with_vss" = "yes" ; then
3447d9840e25STomoki Sekiyama  if test -z "$win_sdk"; then
3448d9840e25STomoki Sekiyama    programfiles="$PROGRAMFILES"
3449d9840e25STomoki Sekiyama    test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
3450d9840e25STomoki Sekiyama    if test -n "$programfiles"; then
3451d9840e25STomoki Sekiyama      win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
3452d9840e25STomoki Sekiyama    else
3453d9840e25STomoki Sekiyama      feature_not_found "Windows SDK"
3454d9840e25STomoki Sekiyama    fi
3455d9840e25STomoki Sekiyama  elif test "$win_sdk" = "no"; then
3456d9840e25STomoki Sekiyama    win_sdk=""
3457d9840e25STomoki Sekiyama  fi
3458d9840e25STomoki Sekiyamafi
3459d9840e25STomoki Sekiyama
3460d9840e25STomoki Sekiyama##########################################
346150cbebb9SMichael Roth# check if mingw environment provides a recent ntddscsi.h
3462e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no"; then
346350cbebb9SMichael Roth  cat > $TMPC << EOF
346450cbebb9SMichael Roth#include <windows.h>
346550cbebb9SMichael Roth#include <ntddscsi.h>
346650cbebb9SMichael Rothint main(void) {
346750cbebb9SMichael Roth#if !defined(IOCTL_SCSI_GET_ADDRESS)
346850cbebb9SMichael Roth#error Missing required ioctl definitions
346950cbebb9SMichael Roth#endif
347050cbebb9SMichael Roth  SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
347150cbebb9SMichael Roth  return addr.Lun;
347250cbebb9SMichael Roth}
347350cbebb9SMichael RothEOF
347450cbebb9SMichael Roth  if compile_prog "" "" ; then
347550cbebb9SMichael Roth    guest_agent_ntddscsi=yes
3476996b9cdcSMatt Hines    libs_qga="-lsetupapi -lcfgmgr32 $libs_qga"
347750cbebb9SMichael Roth  fi
347850cbebb9SMichael Rothfi
347950cbebb9SMichael Roth
348050cbebb9SMichael Roth##########################################
34818ca80760SRichard Henderson# capstone
34828ca80760SRichard Henderson
3483e219c499SRichard Hendersoncase "$capstone" in
34848b18cdbfSRichard Henderson  auto | enabled | internal)
34858b18cdbfSRichard Henderson    # Simpler to always update submodule, even if not needed.
3486e219c499SRichard Henderson    git_submodules="${git_submodules} capstone"
3487e219c499SRichard Henderson    ;;
3488e219c499SRichard Hendersonesac
34898ca80760SRichard Henderson
34908ca80760SRichard Henderson##########################################
34910a852417SPaul Durrant# check if we have posix_syslog
34920a852417SPaul Durrant
34930a852417SPaul Durrantposix_syslog=no
34940a852417SPaul Durrantcat > $TMPC << EOF
34950a852417SPaul Durrant#include <syslog.h>
34960a852417SPaul Durrantint main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
34970a852417SPaul DurrantEOF
34980a852417SPaul Durrantif compile_prog "" "" ; then
34990a852417SPaul Durrant    posix_syslog=yes
35000a852417SPaul Durrantfi
35010a852417SPaul Durrant
35020a852417SPaul Durrant##########################################
350394a420b1SStefan Hajnoczi# check if trace backend exists
350494a420b1SStefan Hajnoczi
35055b808275SLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends  > /dev/null 2> /dev/null
350694a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
35075b808275SLluís Vilanova  error_exit "invalid trace backends" \
35085b808275SLluís Vilanova      "Please choose supported trace backends."
350994a420b1SStefan Hajnoczifi
351094a420b1SStefan Hajnoczi
35117e24e92aSStefan Hajnoczi##########################################
35127e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
35135b808275SLluís Vilanovaif have_backend "ust"; then
3514bf15f63cSMohamad Gebai  if $pkg_config lttng-ust --exists; then
351589138857SStefan Weil    lttng_ust_libs=$($pkg_config --libs lttng-ust)
35167e24e92aSStefan Hajnoczi  else
3517bf15f63cSMohamad Gebai    error_exit "Trace backend 'ust' missing lttng-ust header files"
35187e24e92aSStefan Hajnoczi  fi
35197e24e92aSStefan Hajnoczifi
3520b3d08c02SDaniel P. Berrange
3521b3d08c02SDaniel P. Berrange##########################################
3522b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
35235b808275SLluís Vilanovaif have_backend "dtrace"; then
3524b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
352576ad07a4SPeter Maydell    error_exit "dtrace command is not found in PATH $PATH"
3526b3d08c02SDaniel P. Berrange  fi
3527c276b17dSDaniel P. Berrange  trace_backend_stap="no"
3528c276b17dSDaniel P. Berrange  if has 'stap' ; then
3529c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
35304b265c79SStefan Hajnoczi
35314b265c79SStefan Hajnoczi    # Workaround to avoid dtrace(1) producing a file with 'hidden' symbol
35324b265c79SStefan Hajnoczi    # visibility. Define STAP_SDT_V2 to produce 'default' symbol visibility
35334b265c79SStefan Hajnoczi    # instead. QEMU --enable-modules depends on this because the SystemTap
35344b265c79SStefan Hajnoczi    # semaphores are linked into the main binary and not the module's shared
35354b265c79SStefan Hajnoczi    # object.
35364b265c79SStefan Hajnoczi    QEMU_CFLAGS="$QEMU_CFLAGS -DSTAP_SDT_V2"
3537c276b17dSDaniel P. Berrange  fi
3538b3d08c02SDaniel P. Berrangefi
3539b3d08c02SDaniel P. Berrange
35407e24e92aSStefan Hajnoczi##########################################
3541519175a2SAlex Barcelo# check and set a backend for coroutine
3542d0e2fce5SAneesh Kumar K.V
35437c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback
354433c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows
354533c53c54SDaniel P. Berrange# specific one.
35467c2acc70SPeter Maydell
35477c2acc70SPeter Maydellucontext_works=no
3548d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
3549d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
3550d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
3551cdf84806SPeter Maydell#ifdef __stub_makecontext
3552cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
3553cdf84806SPeter Maydell#endif
355475cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
3555d0e2fce5SAneesh Kumar K.VEOF
3556d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
35577c2acc70SPeter Maydell    ucontext_works=yes
3558d0e2fce5SAneesh Kumar K.V  fi
3559519175a2SAlex Barcelofi
35607c2acc70SPeter Maydell
35617c2acc70SPeter Maydellif test "$coroutine" = ""; then
35627c2acc70SPeter Maydell  if test "$mingw32" = "yes"; then
35637c2acc70SPeter Maydell    coroutine=win32
35647c2acc70SPeter Maydell  elif test "$ucontext_works" = "yes"; then
35657c2acc70SPeter Maydell    coroutine=ucontext
3566519175a2SAlex Barcelo  else
35677c2acc70SPeter Maydell    coroutine=sigaltstack
35687c2acc70SPeter Maydell  fi
35697c2acc70SPeter Maydellelse
35707c2acc70SPeter Maydell  case $coroutine in
35717c2acc70SPeter Maydell  windows)
35727c2acc70SPeter Maydell    if test "$mingw32" != "yes"; then
35737c2acc70SPeter Maydell      error_exit "'windows' coroutine backend only valid for Windows"
35747c2acc70SPeter Maydell    fi
35757c2acc70SPeter Maydell    # Unfortunately the user visible backend name doesn't match the
35767c2acc70SPeter Maydell    # coroutine-*.c filename for this case, so we have to adjust it here.
35777c2acc70SPeter Maydell    coroutine=win32
35787c2acc70SPeter Maydell    ;;
35797c2acc70SPeter Maydell  ucontext)
35807c2acc70SPeter Maydell    if test "$ucontext_works" != "yes"; then
35817c2acc70SPeter Maydell      feature_not_found "ucontext"
35827c2acc70SPeter Maydell    fi
35837c2acc70SPeter Maydell    ;;
358433c53c54SDaniel P. Berrange  sigaltstack)
35857c2acc70SPeter Maydell    if test "$mingw32" = "yes"; then
35867c2acc70SPeter Maydell      error_exit "only the 'windows' coroutine backend is valid for Windows"
35877c2acc70SPeter Maydell    fi
35887c2acc70SPeter Maydell    ;;
35897c2acc70SPeter Maydell  *)
359076ad07a4SPeter Maydell    error_exit "unknown coroutine backend $coroutine"
35917c2acc70SPeter Maydell    ;;
35927c2acc70SPeter Maydell  esac
3593d0e2fce5SAneesh Kumar K.Vfi
3594d0e2fce5SAneesh Kumar K.V
359570c60c08SStefan Hajnocziif test "$coroutine_pool" = ""; then
359670c60c08SStefan Hajnoczi  coroutine_pool=yes
359770c60c08SStefan Hajnoczifi
359870c60c08SStefan Hajnoczi
35997d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes"; then
36007d992e4dSPeter Lieven  if test "$coroutine_pool" = "yes"; then
36017d992e4dSPeter Lieven    echo "WARN: disabling coroutine pool for stack usage debugging"
36027d992e4dSPeter Lieven    coroutine_pool=no
36037d992e4dSPeter Lieven  fi
36047d992e4dSPeter Lievenfi
36057d992e4dSPeter Lieven
36061e4f6065SDaniele Buono##################################################
36071e4f6065SDaniele Buono# SafeStack
36081e4f6065SDaniele Buono
36091e4f6065SDaniele Buono
36101e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then
36111e4f6065SDaniele Buonocat > $TMPC << EOF
36121e4f6065SDaniele Buonoint main(int argc, char *argv[])
36131e4f6065SDaniele Buono{
36141e4f6065SDaniele Buono#if ! __has_feature(safe_stack)
36151e4f6065SDaniele Buono#error SafeStack Disabled
36161e4f6065SDaniele Buono#endif
36171e4f6065SDaniele Buono    return 0;
36181e4f6065SDaniele Buono}
36191e4f6065SDaniele BuonoEOF
36201e4f6065SDaniele Buono  flag="-fsanitize=safe-stack"
36211e4f6065SDaniele Buono  # Check that safe-stack is supported and enabled.
36221e4f6065SDaniele Buono  if compile_prog "-Werror $flag" "$flag"; then
36231e4f6065SDaniele Buono    # Flag needed both at compilation and at linking
36241e4f6065SDaniele Buono    QEMU_CFLAGS="$QEMU_CFLAGS $flag"
36251e4f6065SDaniele Buono    QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
36261e4f6065SDaniele Buono  else
36271e4f6065SDaniele Buono    error_exit "SafeStack not supported by your compiler"
36281e4f6065SDaniele Buono  fi
36291e4f6065SDaniele Buono  if test "$coroutine" != "ucontext"; then
36301e4f6065SDaniele Buono    error_exit "SafeStack is only supported by the coroutine backend ucontext"
36311e4f6065SDaniele Buono  fi
36321e4f6065SDaniele Buonoelse
36331e4f6065SDaniele Buonocat > $TMPC << EOF
36341e4f6065SDaniele Buonoint main(int argc, char *argv[])
36351e4f6065SDaniele Buono{
36361e4f6065SDaniele Buono#if defined(__has_feature)
36371e4f6065SDaniele Buono#if __has_feature(safe_stack)
36381e4f6065SDaniele Buono#error SafeStack Enabled
36391e4f6065SDaniele Buono#endif
36401e4f6065SDaniele Buono#endif
36411e4f6065SDaniele Buono    return 0;
36421e4f6065SDaniele Buono}
36431e4f6065SDaniele BuonoEOF
36441e4f6065SDaniele Buonoif test "$safe_stack" = "no"; then
36451e4f6065SDaniele Buono  # Make sure that safe-stack is disabled
36461e4f6065SDaniele Buono  if ! compile_prog "-Werror" ""; then
36471e4f6065SDaniele Buono    # SafeStack was already enabled, try to explicitly remove the feature
36481e4f6065SDaniele Buono    flag="-fno-sanitize=safe-stack"
36491e4f6065SDaniele Buono    if ! compile_prog "-Werror $flag" "$flag"; then
36501e4f6065SDaniele Buono      error_exit "Configure cannot disable SafeStack"
36511e4f6065SDaniele Buono    fi
36521e4f6065SDaniele Buono    QEMU_CFLAGS="$QEMU_CFLAGS $flag"
36531e4f6065SDaniele Buono    QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
36541e4f6065SDaniele Buono  fi
36551e4f6065SDaniele Buonoelse # "$safe_stack" = ""
36561e4f6065SDaniele Buono  # Set safe_stack to yes or no based on pre-existing flags
36571e4f6065SDaniele Buono  if compile_prog "-Werror" ""; then
36581e4f6065SDaniele Buono    safe_stack="no"
36591e4f6065SDaniele Buono  else
36601e4f6065SDaniele Buono    safe_stack="yes"
36611e4f6065SDaniele Buono    if test "$coroutine" != "ucontext"; then
36621e4f6065SDaniele Buono      error_exit "SafeStack is only supported by the coroutine backend ucontext"
36631e4f6065SDaniele Buono    fi
36641e4f6065SDaniele Buono  fi
36651e4f6065SDaniele Buonofi
36661e4f6065SDaniele Buonofi
36677d992e4dSPeter Lieven
366876a347e1SRichard Henderson########################################
366976a347e1SRichard Henderson# check if cpuid.h is usable.
367076a347e1SRichard Henderson
367176a347e1SRichard Hendersoncat > $TMPC << EOF
367276a347e1SRichard Henderson#include <cpuid.h>
367376a347e1SRichard Hendersonint main(void) {
3674774d566cSPeter Maydell    unsigned a, b, c, d;
3675774d566cSPeter Maydell    int max = __get_cpuid_max(0, 0);
3676774d566cSPeter Maydell
3677774d566cSPeter Maydell    if (max >= 1) {
3678774d566cSPeter Maydell        __cpuid(1, a, b, c, d);
3679774d566cSPeter Maydell    }
3680774d566cSPeter Maydell
3681774d566cSPeter Maydell    if (max >= 7) {
3682774d566cSPeter Maydell        __cpuid_count(7, 0, a, b, c, d);
3683774d566cSPeter Maydell    }
3684774d566cSPeter Maydell
368576a347e1SRichard Henderson    return 0;
368676a347e1SRichard Henderson}
368776a347e1SRichard HendersonEOF
368876a347e1SRichard Hendersonif compile_prog "" "" ; then
368976a347e1SRichard Henderson    cpuid_h=yes
369076a347e1SRichard Hendersonfi
369176a347e1SRichard Henderson
36925dd89908SRichard Henderson##########################################
36935dd89908SRichard Henderson# avx2 optimization requirement check
36945dd89908SRichard Henderson#
36955dd89908SRichard Henderson# There is no point enabling this if cpuid.h is not usable,
36965dd89908SRichard Henderson# since we won't be able to select the new routines.
36975dd89908SRichard Henderson
3698e633a5c6SEric Blakeif test "$cpuid_h" = "yes" && test "$avx2_opt" != "no"; then
36995dd89908SRichard Henderson  cat > $TMPC << EOF
37005dd89908SRichard Henderson#pragma GCC push_options
37015dd89908SRichard Henderson#pragma GCC target("avx2")
37025dd89908SRichard Henderson#include <cpuid.h>
37035dd89908SRichard Henderson#include <immintrin.h>
37045dd89908SRichard Hendersonstatic int bar(void *a) {
37055dd89908SRichard Henderson    __m256i x = *(__m256i *)a;
37065dd89908SRichard Henderson    return _mm256_testz_si256(x, x);
37075dd89908SRichard Henderson}
37085dd89908SRichard Hendersonint main(int argc, char *argv[]) { return bar(argv[0]); }
37095dd89908SRichard HendersonEOF
37105b945f23SRichard Henderson  if compile_object "-Werror" ; then
37115dd89908SRichard Henderson    avx2_opt="yes"
371286583a07SLiam Merwick  else
371386583a07SLiam Merwick    avx2_opt="no"
37145dd89908SRichard Henderson  fi
37155dd89908SRichard Hendersonfi
37165dd89908SRichard Henderson
37176b8cd447SRobert Hoo##########################################
37186b8cd447SRobert Hoo# avx512f optimization requirement check
37196b8cd447SRobert Hoo#
37206b8cd447SRobert Hoo# There is no point enabling this if cpuid.h is not usable,
37216b8cd447SRobert Hoo# since we won't be able to select the new routines.
37226b8cd447SRobert Hoo# by default, it is turned off.
37236b8cd447SRobert Hoo# if user explicitly want to enable it, check environment
37246b8cd447SRobert Hoo
37256b8cd447SRobert Hooif test "$cpuid_h" = "yes" && test "$avx512f_opt" = "yes"; then
37266b8cd447SRobert Hoo  cat > $TMPC << EOF
37276b8cd447SRobert Hoo#pragma GCC push_options
37286b8cd447SRobert Hoo#pragma GCC target("avx512f")
37296b8cd447SRobert Hoo#include <cpuid.h>
37306b8cd447SRobert Hoo#include <immintrin.h>
37316b8cd447SRobert Hoostatic int bar(void *a) {
37326b8cd447SRobert Hoo    __m512i x = *(__m512i *)a;
37336b8cd447SRobert Hoo    return _mm512_test_epi64_mask(x, x);
37346b8cd447SRobert Hoo}
37356b8cd447SRobert Hooint main(int argc, char *argv[])
37366b8cd447SRobert Hoo{
37376b8cd447SRobert Hoo	return bar(argv[0]);
37386b8cd447SRobert Hoo}
37396b8cd447SRobert HooEOF
37405b945f23SRichard Henderson  if ! compile_object "-Werror" ; then
37416b8cd447SRobert Hoo    avx512f_opt="no"
37426b8cd447SRobert Hoo  fi
37436b8cd447SRobert Hooelse
37446b8cd447SRobert Hoo  avx512f_opt="no"
37456b8cd447SRobert Hoofi
37466b8cd447SRobert Hoo
3747f540166bSRichard Henderson########################################
3748f540166bSRichard Henderson# check if __[u]int128_t is usable.
3749f540166bSRichard Henderson
3750f540166bSRichard Hendersonint128=no
3751f540166bSRichard Hendersoncat > $TMPC << EOF
3752f540166bSRichard Henderson__int128_t a;
3753f540166bSRichard Henderson__uint128_t b;
3754f540166bSRichard Hendersonint main (void) {
3755f540166bSRichard Henderson  a = a + b;
3756f540166bSRichard Henderson  b = a * b;
3757464e3671SPeter Maydell  a = a * a;
3758f540166bSRichard Henderson  return 0;
3759f540166bSRichard Henderson}
3760f540166bSRichard HendersonEOF
3761f540166bSRichard Hendersonif compile_prog "" "" ; then
3762f540166bSRichard Henderson    int128=yes
3763f540166bSRichard Hendersonfi
376476a347e1SRichard Henderson
37657ebee43eSRichard Henderson#########################################
37667ebee43eSRichard Henderson# See if 128-bit atomic operations are supported.
37677ebee43eSRichard Henderson
37687ebee43eSRichard Hendersonatomic128=no
37697ebee43eSRichard Hendersonif test "$int128" = "yes"; then
37707ebee43eSRichard Henderson  cat > $TMPC << EOF
37717ebee43eSRichard Hendersonint main(void)
37727ebee43eSRichard Henderson{
37737ebee43eSRichard Henderson  unsigned __int128 x = 0, y = 0;
3774bceac547SThomas Huth  y = __atomic_load(&x, 0);
3775bceac547SThomas Huth  __atomic_store(&x, y, 0);
3776bceac547SThomas Huth  __atomic_compare_exchange(&x, &y, x, 0, 0, 0);
37777ebee43eSRichard Henderson  return 0;
37787ebee43eSRichard Henderson}
37797ebee43eSRichard HendersonEOF
37807ebee43eSRichard Henderson  if compile_prog "" "" ; then
37817ebee43eSRichard Henderson    atomic128=yes
37827ebee43eSRichard Henderson  fi
37837ebee43eSRichard Hendersonfi
37847ebee43eSRichard Henderson
3785e6cd4bb5SRichard Hendersoncmpxchg128=no
3786e633a5c6SEric Blakeif test "$int128" = yes && test "$atomic128" = no; then
3787e6cd4bb5SRichard Henderson  cat > $TMPC << EOF
3788e6cd4bb5SRichard Hendersonint main(void)
3789e6cd4bb5SRichard Henderson{
3790e6cd4bb5SRichard Henderson  unsigned __int128 x = 0, y = 0;
3791e6cd4bb5SRichard Henderson  __sync_val_compare_and_swap_16(&x, y, x);
3792e6cd4bb5SRichard Henderson  return 0;
3793e6cd4bb5SRichard Henderson}
3794e6cd4bb5SRichard HendersonEOF
3795e6cd4bb5SRichard Henderson  if compile_prog "" "" ; then
3796e6cd4bb5SRichard Henderson    cmpxchg128=yes
3797e6cd4bb5SRichard Henderson  fi
3798e6cd4bb5SRichard Hendersonfi
3799e6cd4bb5SRichard Henderson
3800df79b996SRichard Henderson#########################################
3801df79b996SRichard Henderson# See if 64-bit atomic operations are supported.
3802df79b996SRichard Henderson# Note that without __atomic builtins, we can only
3803df79b996SRichard Henderson# assume atomic loads/stores max at pointer size.
3804df79b996SRichard Henderson
3805df79b996SRichard Hendersoncat > $TMPC << EOF
3806df79b996SRichard Henderson#include <stdint.h>
3807df79b996SRichard Hendersonint main(void)
3808df79b996SRichard Henderson{
3809df79b996SRichard Henderson  uint64_t x = 0, y = 0;
38105fe40765SThomas Huth  y = __atomic_load_n(&x, __ATOMIC_RELAXED);
38115fe40765SThomas Huth  __atomic_store_n(&x, y, __ATOMIC_RELAXED);
38125fe40765SThomas Huth  __atomic_compare_exchange_n(&x, &y, x, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
38135fe40765SThomas Huth  __atomic_exchange_n(&x, y, __ATOMIC_RELAXED);
38145fe40765SThomas Huth  __atomic_fetch_add(&x, y, __ATOMIC_RELAXED);
3815df79b996SRichard Henderson  return 0;
3816df79b996SRichard Henderson}
3817df79b996SRichard HendersonEOF
3818df79b996SRichard Hendersonif compile_prog "" "" ; then
3819df79b996SRichard Henderson  atomic64=yes
3820df79b996SRichard Hendersonfi
3821df79b996SRichard Henderson
38221e6e9acaSRichard Henderson########################################
38231e6e9acaSRichard Henderson# check if getauxval is available.
38241e6e9acaSRichard Henderson
38251e6e9acaSRichard Hendersongetauxval=no
38261e6e9acaSRichard Hendersoncat > $TMPC << EOF
38271e6e9acaSRichard Henderson#include <sys/auxv.h>
38281e6e9acaSRichard Hendersonint main(void) {
38291e6e9acaSRichard Henderson  return getauxval(AT_HWCAP) == 0;
38301e6e9acaSRichard Henderson}
38311e6e9acaSRichard HendersonEOF
38321e6e9acaSRichard Hendersonif compile_prog "" "" ; then
38331e6e9acaSRichard Henderson    getauxval=yes
38341e6e9acaSRichard Hendersonfi
38351e6e9acaSRichard Henderson
3836fd0e6053SJohn Snow########################################
3837fd0e6053SJohn Snow# check if ccache is interfering with
3838fd0e6053SJohn Snow# semantic analysis of macros
3839fd0e6053SJohn Snow
38405e4dfd3dSJohn Snowunset CCACHE_CPP2
3841fd0e6053SJohn Snowccache_cpp2=no
3842fd0e6053SJohn Snowcat > $TMPC << EOF
3843fd0e6053SJohn Snowstatic const int Z = 1;
3844fd0e6053SJohn Snow#define fn() ({ Z; })
3845fd0e6053SJohn Snow#define TAUT(X) ((X) == Z)
3846fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y)
3847fd0e6053SJohn Snow#define ID(X) (X)
3848fd0e6053SJohn Snowint main(int argc, char *argv[])
3849fd0e6053SJohn Snow{
3850fd0e6053SJohn Snow    int x = 0, y = 0;
3851fd0e6053SJohn Snow    x = ID(x);
3852fd0e6053SJohn Snow    x = fn();
3853fd0e6053SJohn Snow    fn();
3854fd0e6053SJohn Snow    if (PAREN(x, y)) return 0;
3855fd0e6053SJohn Snow    if (TAUT(Z)) return 0;
3856fd0e6053SJohn Snow    return 0;
3857fd0e6053SJohn Snow}
3858fd0e6053SJohn SnowEOF
3859fd0e6053SJohn Snow
3860fd0e6053SJohn Snowif ! compile_object "-Werror"; then
3861fd0e6053SJohn Snow    ccache_cpp2=yes
3862fd0e6053SJohn Snowfi
3863fd0e6053SJohn Snow
3864b553a042SJohn Snow#################################################
3865b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE.
3866b553a042SJohn Snow
3867b553a042SJohn Snowif test "$fortify_source" != "no"; then
3868b553a042SJohn Snow  if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
3869b553a042SJohn Snow    fortify_source="no";
3870e189091fSPeter Maydell  elif test -n "$cxx" && has $cxx &&
3871cfcc7c14SJohn Snow       echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
3872b553a042SJohn Snow    fortify_source="no";
3873b553a042SJohn Snow  else
3874b553a042SJohn Snow    fortify_source="yes"
3875b553a042SJohn Snow  fi
3876b553a042SJohn Snowfi
3877b553a042SJohn Snow
3878d2042378SAneesh Kumar K.V##########################################
3879277abf15SJan Vesely# check if struct fsxattr is available via linux/fs.h
3880277abf15SJan Vesely
3881277abf15SJan Veselyhave_fsxattr=no
3882277abf15SJan Veselycat > $TMPC << EOF
3883277abf15SJan Vesely#include <linux/fs.h>
3884277abf15SJan Veselystruct fsxattr foo;
3885277abf15SJan Veselyint main(void) {
3886277abf15SJan Vesely  return 0;
3887277abf15SJan Vesely}
3888277abf15SJan VeselyEOF
3889277abf15SJan Veselyif compile_prog "" "" ; then
3890277abf15SJan Vesely    have_fsxattr=yes
3891277abf15SJan Veselyfi
3892277abf15SJan Vesely
3893b66e10e4SPeter Maydell##########################################
3894a40161cbSPaolo Bonzini# check for usable membarrier system call
3895a40161cbSPaolo Bonziniif test "$membarrier" = "yes"; then
3896a40161cbSPaolo Bonzini    have_membarrier=no
3897a40161cbSPaolo Bonzini    if test "$mingw32" = "yes" ; then
3898a40161cbSPaolo Bonzini        have_membarrier=yes
3899a40161cbSPaolo Bonzini    elif test "$linux" = "yes" ; then
3900a40161cbSPaolo Bonzini        cat > $TMPC << EOF
3901a40161cbSPaolo Bonzini    #include <linux/membarrier.h>
3902a40161cbSPaolo Bonzini    #include <sys/syscall.h>
3903a40161cbSPaolo Bonzini    #include <unistd.h>
3904a40161cbSPaolo Bonzini    #include <stdlib.h>
3905a40161cbSPaolo Bonzini    int main(void) {
3906a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
3907a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0);
3908a40161cbSPaolo Bonzini	exit(0);
3909a40161cbSPaolo Bonzini    }
3910a40161cbSPaolo BonziniEOF
3911a40161cbSPaolo Bonzini        if compile_prog "" "" ; then
3912a40161cbSPaolo Bonzini            have_membarrier=yes
3913a40161cbSPaolo Bonzini        fi
3914a40161cbSPaolo Bonzini    fi
3915a40161cbSPaolo Bonzini    if test "$have_membarrier" = "no"; then
3916a40161cbSPaolo Bonzini      feature_not_found "membarrier" "membarrier system call not available"
3917a40161cbSPaolo Bonzini    fi
3918a40161cbSPaolo Bonzinielse
3919a40161cbSPaolo Bonzini    # Do not enable it by default even for Mingw32, because it doesn't
3920a40161cbSPaolo Bonzini    # work on Wine.
3921a40161cbSPaolo Bonzini    membarrier=no
3922a40161cbSPaolo Bonzinifi
3923a40161cbSPaolo Bonzini
3924a40161cbSPaolo Bonzini##########################################
39256a02c806SStefan Hajnoczi# check for usable AF_VSOCK environment
39266a02c806SStefan Hajnoczihave_af_vsock=no
39276a02c806SStefan Hajnoczicat > $TMPC << EOF
39286a02c806SStefan Hajnoczi#include <errno.h>
39296a02c806SStefan Hajnoczi#include <sys/types.h>
39306a02c806SStefan Hajnoczi#include <sys/socket.h>
39316a02c806SStefan Hajnoczi#if !defined(AF_VSOCK)
39326a02c806SStefan Hajnoczi# error missing AF_VSOCK flag
39336a02c806SStefan Hajnoczi#endif
39346a02c806SStefan Hajnoczi#include <linux/vm_sockets.h>
39356a02c806SStefan Hajnocziint main(void) {
39366a02c806SStefan Hajnoczi    int sock, ret;
39376a02c806SStefan Hajnoczi    struct sockaddr_vm svm;
39386a02c806SStefan Hajnoczi    socklen_t len = sizeof(svm);
39396a02c806SStefan Hajnoczi    sock = socket(AF_VSOCK, SOCK_STREAM, 0);
39406a02c806SStefan Hajnoczi    ret = getpeername(sock, (struct sockaddr *)&svm, &len);
39416a02c806SStefan Hajnoczi    if ((ret == -1) && (errno == ENOTCONN)) {
39426a02c806SStefan Hajnoczi        return 0;
39436a02c806SStefan Hajnoczi    }
39446a02c806SStefan Hajnoczi    return -1;
39456a02c806SStefan Hajnoczi}
39466a02c806SStefan HajnocziEOF
39476a02c806SStefan Hajnocziif compile_prog "" "" ; then
39486a02c806SStefan Hajnoczi    have_af_vsock=yes
39496a02c806SStefan Hajnoczifi
39506a02c806SStefan Hajnoczi
3951f0d92b56SLongpeng(Mike)##########################################
3952f0d92b56SLongpeng(Mike)# check for usable AF_ALG environment
39534f67366eSThomas Huthhave_afalg=no
3954f0d92b56SLongpeng(Mike)cat > $TMPC << EOF
3955f0d92b56SLongpeng(Mike)#include <errno.h>
3956f0d92b56SLongpeng(Mike)#include <sys/types.h>
3957f0d92b56SLongpeng(Mike)#include <sys/socket.h>
3958f0d92b56SLongpeng(Mike)#include <linux/if_alg.h>
3959f0d92b56SLongpeng(Mike)int main(void) {
3960f0d92b56SLongpeng(Mike)    int sock;
3961f0d92b56SLongpeng(Mike)    sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
3962f0d92b56SLongpeng(Mike)    return sock;
3963f0d92b56SLongpeng(Mike)}
3964f0d92b56SLongpeng(Mike)EOF
3965f0d92b56SLongpeng(Mike)if compile_prog "" "" ; then
3966f0d92b56SLongpeng(Mike)    have_afalg=yes
3967f0d92b56SLongpeng(Mike)fi
3968f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes"
3969f0d92b56SLongpeng(Mike)then
3970f0d92b56SLongpeng(Mike)    if test "$have_afalg" != "yes"
3971f0d92b56SLongpeng(Mike)    then
3972f0d92b56SLongpeng(Mike)	error_exit "AF_ALG requested but could not be detected"
3973f0d92b56SLongpeng(Mike)    fi
3974f0d92b56SLongpeng(Mike)fi
3975f0d92b56SLongpeng(Mike)
3976f0d92b56SLongpeng(Mike)
3977db1ed1abSRichard Henderson##########################################
3978247724cbSMarc-André Lureau# checks for sanitizers
3979247724cbSMarc-André Lureau
3980247724cbSMarc-André Lureauhave_asan=no
3981247724cbSMarc-André Lureauhave_ubsan=no
3982d83414e1SMarc-André Lureauhave_asan_iface_h=no
3983d83414e1SMarc-André Lureauhave_asan_iface_fiber=no
3984247724cbSMarc-André Lureau
3985247724cbSMarc-André Lureauif test "$sanitizers" = "yes" ; then
3986b9f44da2SMarc-André Lureau  write_c_skeleton
3987247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
3988247724cbSMarc-André Lureau      have_asan=yes
3989247724cbSMarc-André Lureau  fi
3990b9f44da2SMarc-André Lureau
3991b9f44da2SMarc-André Lureau  # we could use a simple skeleton for flags checks, but this also
3992b9f44da2SMarc-André Lureau  # detect the static linking issue of ubsan, see also:
3993b9f44da2SMarc-André Lureau  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
3994b9f44da2SMarc-André Lureau  cat > $TMPC << EOF
3995b9f44da2SMarc-André Lureau#include <stdlib.h>
3996b9f44da2SMarc-André Lureauint main(void) {
3997b9f44da2SMarc-André Lureau    void *tmp = malloc(10);
3998f2dfe54cSLeonid Bloch    if (tmp != NULL) {
3999b9f44da2SMarc-André Lureau        return *(int *)(tmp + 2);
4000b9f44da2SMarc-André Lureau    }
4001d1abf3fcSOlaf Hering    return 1;
4002f2dfe54cSLeonid Bloch}
4003b9f44da2SMarc-André LureauEOF
4004247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
4005247724cbSMarc-André Lureau      have_ubsan=yes
4006247724cbSMarc-André Lureau  fi
4007d83414e1SMarc-André Lureau
4008d83414e1SMarc-André Lureau  if check_include "sanitizer/asan_interface.h" ; then
4009d83414e1SMarc-André Lureau      have_asan_iface_h=yes
4010d83414e1SMarc-André Lureau  fi
4011d83414e1SMarc-André Lureau
4012d83414e1SMarc-André Lureau  cat > $TMPC << EOF
4013d83414e1SMarc-André Lureau#include <sanitizer/asan_interface.h>
4014d83414e1SMarc-André Lureauint main(void) {
4015d83414e1SMarc-André Lureau  __sanitizer_start_switch_fiber(0, 0, 0);
4016d83414e1SMarc-André Lureau  return 0;
4017d83414e1SMarc-André Lureau}
4018d83414e1SMarc-André LureauEOF
4019d83414e1SMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
4020d83414e1SMarc-André Lureau      have_asan_iface_fiber=yes
4021d83414e1SMarc-André Lureau  fi
4022247724cbSMarc-André Lureaufi
4023247724cbSMarc-André Lureau
4024247724cbSMarc-André Lureau##########################################
4025adc28027SAlexander Bulekov# checks for fuzzer
4026dfc86c0fSAlexander Bulekovif test "$fuzzing" = "yes" ; then
4027adc28027SAlexander Bulekov  write_c_fuzzer_skeleton
4028dfc86c0fSAlexander Bulekov  if test -z "${LIB_FUZZING_ENGINE+xxx}"; then
4029dd016265SAlexander Bulekov    if compile_prog "$CPU_CFLAGS -Werror -fsanitize=fuzzer" ""; then
4030adc28027SAlexander Bulekov      have_fuzzer=yes
403164ed6f92SPaolo Bonzini    else
403264ed6f92SPaolo Bonzini      error_exit "Your compiler doesn't support -fsanitize=fuzzer"
403364ed6f92SPaolo Bonzini      exit 1
4034adc28027SAlexander Bulekov    fi
4035adc28027SAlexander Bulekov  fi
4036adc28027SAlexander Bulekov
4037dfc86c0fSAlexander Bulekov  have_clang_coverage_filter=no
4038dfc86c0fSAlexander Bulekov  echo > $TMPTXT
4039dfc86c0fSAlexander Bulekov  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=fuzzer -fsanitize-coverage-allowlist=$TMPTXT" ""; then
4040dfc86c0fSAlexander Bulekov    have_clang_coverage_filter=yes
4041dfc86c0fSAlexander Bulekov  fi
4042dfc86c0fSAlexander Bulekovfi
4043dfc86c0fSAlexander Bulekov
40440aebab04SLingfeng Yang# Thread sanitizer is, for now, much noisier than the other sanitizers;
40450aebab04SLingfeng Yang# keep it separate until that is not the case.
40460aebab04SLingfeng Yangif test "$tsan" = "yes" && test "$sanitizers" = "yes"; then
40470aebab04SLingfeng Yang  error_exit "TSAN is not supported with other sanitiziers."
40480aebab04SLingfeng Yangfi
40490aebab04SLingfeng Yanghave_tsan=no
40500aebab04SLingfeng Yanghave_tsan_iface_fiber=no
40510aebab04SLingfeng Yangif test "$tsan" = "yes" ; then
40520aebab04SLingfeng Yang  write_c_skeleton
40530aebab04SLingfeng Yang  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
40540aebab04SLingfeng Yang      have_tsan=yes
40550aebab04SLingfeng Yang  fi
40560aebab04SLingfeng Yang  cat > $TMPC << EOF
40570aebab04SLingfeng Yang#include <sanitizer/tsan_interface.h>
40580aebab04SLingfeng Yangint main(void) {
40590aebab04SLingfeng Yang  __tsan_create_fiber(0);
40600aebab04SLingfeng Yang  return 0;
40610aebab04SLingfeng Yang}
40620aebab04SLingfeng YangEOF
40630aebab04SLingfeng Yang  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
40640aebab04SLingfeng Yang      have_tsan_iface_fiber=yes
40650aebab04SLingfeng Yang  fi
40660aebab04SLingfeng Yangfi
40670aebab04SLingfeng Yang
4068adc28027SAlexander Bulekov##########################################
4069675b9b53SMarc-André Lureau# check for slirp
4070675b9b53SMarc-André Lureau
4071675b9b53SMarc-André Lureaucase "$slirp" in
40724d34a86bSPaolo Bonzini  auto | enabled | internal)
40734d34a86bSPaolo Bonzini    # Simpler to always update submodule, even if not needed.
40747c57bdd8SMarc-André Lureau    git_submodules="${git_submodules} slirp"
4075675b9b53SMarc-André Lureau    ;;
4076675b9b53SMarc-André Lureauesac
4077675b9b53SMarc-André Lureau
4078b8e0c493SJoelle van Dyne# Check for slirp smbd dupport
4079b8e0c493SJoelle van Dyne: ${smbd=${SMBD-/usr/sbin/smbd}}
4080b8e0c493SJoelle van Dyneif test "$slirp_smbd" != "no" ; then
4081b8e0c493SJoelle van Dyne  if test "$mingw32" = "yes" ; then
4082b8e0c493SJoelle van Dyne    if test "$slirp_smbd" = "yes" ; then
4083b8e0c493SJoelle van Dyne      error_exit "Host smbd not supported on this platform."
4084b8e0c493SJoelle van Dyne    fi
4085b8e0c493SJoelle van Dyne    slirp_smbd=no
4086b8e0c493SJoelle van Dyne  else
4087b8e0c493SJoelle van Dyne    slirp_smbd=yes
4088b8e0c493SJoelle van Dyne  fi
4089b8e0c493SJoelle van Dynefi
4090b8e0c493SJoelle van Dyne
409154e7aac0SAlexey Krasikov##########################################
409254e7aac0SAlexey Krasikov# check for usable __NR_keyctl syscall
409354e7aac0SAlexey Krasikov
409454e7aac0SAlexey Krasikovif test "$linux" = "yes" ; then
409554e7aac0SAlexey Krasikov
409654e7aac0SAlexey Krasikov    have_keyring=no
409754e7aac0SAlexey Krasikov    cat > $TMPC << EOF
409854e7aac0SAlexey Krasikov#include <errno.h>
409954e7aac0SAlexey Krasikov#include <asm/unistd.h>
410054e7aac0SAlexey Krasikov#include <linux/keyctl.h>
410154e7aac0SAlexey Krasikov#include <unistd.h>
410254e7aac0SAlexey Krasikovint main(void) {
410354e7aac0SAlexey Krasikov    return syscall(__NR_keyctl, KEYCTL_READ, 0, NULL, NULL, 0);
410454e7aac0SAlexey Krasikov}
410554e7aac0SAlexey KrasikovEOF
410654e7aac0SAlexey Krasikov    if compile_prog "" "" ; then
410754e7aac0SAlexey Krasikov        have_keyring=yes
410854e7aac0SAlexey Krasikov    fi
410954e7aac0SAlexey Krasikovfi
411054e7aac0SAlexey Krasikovif test "$secret_keyring" != "no"
411154e7aac0SAlexey Krasikovthen
4112b418d265SDavid Edmondson    if test "$have_keyring" = "yes"
411354e7aac0SAlexey Krasikov    then
411454e7aac0SAlexey Krasikov	secret_keyring=yes
411554e7aac0SAlexey Krasikov    else
411654e7aac0SAlexey Krasikov	if test "$secret_keyring" = "yes"
411754e7aac0SAlexey Krasikov	then
411854e7aac0SAlexey Krasikov	    error_exit "syscall __NR_keyctl requested, \
411954e7aac0SAlexey Krasikovbut not implemented on your system"
412054e7aac0SAlexey Krasikov	else
412154e7aac0SAlexey Krasikov	    secret_keyring=no
412254e7aac0SAlexey Krasikov	fi
412354e7aac0SAlexey Krasikov    fi
412454e7aac0SAlexey Krasikovfi
412554e7aac0SAlexey Krasikov
412692500362SAlexey Krasikov##########################################
4127e86ecd4bSJuan Quintela# End of CC checks
4128e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
4129e86ecd4bSJuan Quintela
4130d83414e1SMarc-André Lureauwrite_c_skeleton
4131d83414e1SMarc-André Lureau
41321d728c39SBlue Swirlif test "$gcov" = "yes" ; then
4133bf0e56a3SMarc-André Lureau  :
4134b553a042SJohn Snowelif test "$fortify_source" = "yes" ; then
4135086d5f75SPaolo Bonzini  QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
4136086d5f75SPaolo Bonzini  debug=no
4137086d5f75SPaolo Bonzinifi
4138086d5f75SPaolo Bonzini
4139086d5f75SPaolo Bonzinicase "$ARCH" in
4140086d5f75SPaolo Bonzinialpha)
4141086d5f75SPaolo Bonzini  # Ensure there's only a single GP
4142086d5f75SPaolo Bonzini  QEMU_CFLAGS="-msmall-data $QEMU_CFLAGS"
4143086d5f75SPaolo Bonzini;;
4144086d5f75SPaolo Bonziniesac
4145086d5f75SPaolo Bonzini
4146086d5f75SPaolo Bonziniif test "$gprof" = "yes" ; then
4147086d5f75SPaolo Bonzini  QEMU_CFLAGS="-p $QEMU_CFLAGS"
4148086d5f75SPaolo Bonzini  QEMU_LDFLAGS="-p $QEMU_LDFLAGS"
4149086d5f75SPaolo Bonzinifi
4150a316e378SJuan Quintela
4151247724cbSMarc-André Lureauif test "$have_asan" = "yes"; then
4152db5adeaaSPaolo Bonzini  QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS"
4153db5adeaaSPaolo Bonzini  QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS"
4154d83414e1SMarc-André Lureau  if test "$have_asan_iface_h" = "no" ; then
4155d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header missing." \
4156d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
4157d83414e1SMarc-André Lureau  elif test "$have_asan_iface_fiber" = "no" ; then
4158d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header is too old." \
4159d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
4160d83414e1SMarc-André Lureau  fi
4161247724cbSMarc-André Lureaufi
41620aebab04SLingfeng Yangif test "$have_tsan" = "yes" ; then
41630aebab04SLingfeng Yang  if test "$have_tsan_iface_fiber" = "yes" ; then
41640aebab04SLingfeng Yang    QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS"
41650aebab04SLingfeng Yang    QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS"
41660aebab04SLingfeng Yang  else
41670aebab04SLingfeng Yang    error_exit "Cannot enable TSAN due to missing fiber annotation interface."
41680aebab04SLingfeng Yang  fi
41690aebab04SLingfeng Yangelif test "$tsan" = "yes" ; then
41700aebab04SLingfeng Yang  error_exit "Cannot enable TSAN due to missing sanitize thread interface."
41710aebab04SLingfeng Yangfi
4172247724cbSMarc-André Lureauif test "$have_ubsan" = "yes"; then
4173db5adeaaSPaolo Bonzini  QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS"
4174db5adeaaSPaolo Bonzini  QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS"
4175247724cbSMarc-André Lureaufi
4176247724cbSMarc-André Lureau
41776542aa9cSPeter Lieven##########################################
41783efac6ebSTomáš Golembiovský
41790aebab04SLingfeng Yang# Exclude --warn-common with TSan to suppress warnings from the TSan libraries.
41800aebab04SLingfeng Yangif test "$solaris" = "no" && test "$tsan" = "no"; then
4181e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
4182db5adeaaSPaolo Bonzini        QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS"
4183e86ecd4bSJuan Quintela    fi
4184e86ecd4bSJuan Quintelafi
4185e86ecd4bSJuan Quintela
4186952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
4187952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
4188cb8baa77SMark Cave-Ayland    flags="--no-seh --nxcompat"
4189cb8baa77SMark Cave-Ayland
4190cb8baa77SMark Cave-Ayland    # Disable ASLR for debug builds to allow debugging with gdb
4191cb8baa77SMark Cave-Ayland    if test "$debug" = "no" ; then
4192cb8baa77SMark Cave-Ayland        flags="--dynamicbase $flags"
4193cb8baa77SMark Cave-Ayland    fi
4194cb8baa77SMark Cave-Ayland
4195cb8baa77SMark Cave-Ayland    for flag in $flags; do
4196e9a3591fSChristian Borntraeger        if ld_has $flag ; then
4197db5adeaaSPaolo Bonzini            QEMU_LDFLAGS="-Wl,$flag $QEMU_LDFLAGS"
4198952afb71SBlue Swirl        fi
4199952afb71SBlue Swirl    done
4200952afb71SBlue Swirlfi
4201952afb71SBlue Swirl
42029d6bc27bSMichael Roth# Probe for guest agent support/options
42039d6bc27bSMichael Roth
4204e8ef31a3SMichael Tokarevif [ "$guest_agent" != "no" ]; then
4205a5125905SLaurent Vivier  if [ "$softmmu" = no -a "$want_tools" = no ] ; then
4206a5125905SLaurent Vivier      guest_agent=no
4207a5125905SLaurent Vivier  elif [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
4208e8ef31a3SMichael Tokarev      guest_agent=yes
4209e8ef31a3SMichael Tokarev  elif [ "$guest_agent" != yes ]; then
4210e8ef31a3SMichael Tokarev      guest_agent=no
4211e8ef31a3SMichael Tokarev  else
4212e8ef31a3SMichael Tokarev      error_exit "Guest agent is not supported on this platform"
4213ca35f780SPaolo Bonzini  fi
42144b1c11fdSDaniel P. Berrangefi
4215ca35f780SPaolo Bonzini
4216b846ab7cSPaolo Bonzini# Guest agent Windows MSI package
42179d6bc27bSMichael Roth
42189d6bc27bSMichael Rothif test "$QEMU_GA_MANUFACTURER" = ""; then
42199d6bc27bSMichael Roth  QEMU_GA_MANUFACTURER=QEMU
42209d6bc27bSMichael Rothfi
42219d6bc27bSMichael Rothif test "$QEMU_GA_DISTRO" = ""; then
42229d6bc27bSMichael Roth  QEMU_GA_DISTRO=Linux
42239d6bc27bSMichael Rothfi
42249d6bc27bSMichael Rothif test "$QEMU_GA_VERSION" = ""; then
422589138857SStefan Weil    QEMU_GA_VERSION=$(cat $source_path/VERSION)
42269d6bc27bSMichael Rothfi
42279d6bc27bSMichael Roth
4228b846ab7cSPaolo BonziniQEMU_GA_MSI_MINGW_DLL_PATH="$($pkg_config --variable=prefix glib-2.0)/bin"
42299d6bc27bSMichael Roth
4230ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
4231ca35f780SPaolo Bonziniroms=
4232e633a5c6SEric Blakeif { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \
4233e633a5c6SEric Blake        test "$targetos" != "Darwin" && test "$targetos" != "SunOS" && \
42347000a12eSThomas Huth        test "$targetos" != "Haiku" && test "$softmmu" = yes ; then
4235e57218b6SPeter Maydell    # Different host OS linkers have different ideas about the name of the ELF
4236c65d5e4eSBrad Smith    # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
4237c65d5e4eSBrad Smith    # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
4238c65d5e4eSBrad Smith    for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
4239e57218b6SPeter Maydell        if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
4240e57218b6SPeter Maydell            ld_i386_emulation="$emu"
4241ca35f780SPaolo Bonzini            roms="optionrom"
4242e57218b6SPeter Maydell            break
4243e57218b6SPeter Maydell        fi
4244e57218b6SPeter Maydell    done
4245ca35f780SPaolo Bonzinifi
4246ca35f780SPaolo Bonzini
42472e33c3f8SThomas Huth# Only build s390-ccw bios if we're on s390x and the compiler has -march=z900
4248a5b2afd5SThomas Huth# or -march=z10 (which is the lowest architecture level that Clang supports)
42499933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then
42502e33c3f8SThomas Huth  write_c_skeleton
4251a5b2afd5SThomas Huth  compile_prog "-march=z900" ""
4252a5b2afd5SThomas Huth  has_z900=$?
42533af448b3SThomas Huth  if [ $has_z900 = 0 ] || compile_object "-march=z10 -msoft-float -Werror"; then
4254a5b2afd5SThomas Huth    if [ $has_z900 != 0 ]; then
4255a5b2afd5SThomas Huth      echo "WARNING: Your compiler does not support the z900!"
4256a5b2afd5SThomas Huth      echo "         The s390-ccw bios will only work with guest CPUs >= z10."
4257a5b2afd5SThomas Huth    fi
42589933c305SChristian Borntraeger    roms="$roms s390-ccw"
42591ef6bfc2SPhilippe Mathieu-Daudé    # SLOF is required for building the s390-ccw firmware on s390x,
42601ef6bfc2SPhilippe Mathieu-Daudé    # since it is using the libnet code from SLOF for network booting.
42611ef6bfc2SPhilippe Mathieu-Daudé    git_submodules="${git_submodules} roms/SLOF"
42621ef6bfc2SPhilippe Mathieu-Daudé  fi
42639933c305SChristian Borntraegerfi
42649933c305SChristian Borntraeger
426511cde1c8SBruno Dominguez# Check that the C++ compiler exists and works with the C compiler.
426611cde1c8SBruno 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.
426711cde1c8SBruno Dominguezif has $cxx; then
426811cde1c8SBruno Dominguez    cat > $TMPC <<EOF
426911cde1c8SBruno Dominguezint c_function(void);
427011cde1c8SBruno Dominguezint main(void) { return c_function(); }
427111cde1c8SBruno DominguezEOF
427211cde1c8SBruno Dominguez
427311cde1c8SBruno Dominguez    compile_object
427411cde1c8SBruno Dominguez
427511cde1c8SBruno Dominguez    cat > $TMPCXX <<EOF
427611cde1c8SBruno Dominguezextern "C" {
427711cde1c8SBruno Dominguez   int c_function(void);
427811cde1c8SBruno Dominguez}
427911cde1c8SBruno Dominguezint c_function(void) { return 42; }
428011cde1c8SBruno DominguezEOF
428111cde1c8SBruno Dominguez
428211cde1c8SBruno Dominguez    update_cxxflags
428311cde1c8SBruno Dominguez
42845770e8afSPaolo Bonzini    if do_cxx $CXXFLAGS $CONFIGURE_CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then
428511cde1c8SBruno Dominguez        # C++ compiler $cxx works ok with C compiler $cc
428611cde1c8SBruno Dominguez        :
428711cde1c8SBruno Dominguez    else
428811cde1c8SBruno Dominguez        echo "C++ compiler $cxx does not work with C compiler $cc"
428911cde1c8SBruno Dominguez        echo "Disabling C++ specific optional code"
429011cde1c8SBruno Dominguez        cxx=
429111cde1c8SBruno Dominguez    fi
429211cde1c8SBruno Dominguezelse
429311cde1c8SBruno Dominguez    echo "No C++ compiler available; disabling C++ specific optional code"
429411cde1c8SBruno Dominguez    cxx=
429511cde1c8SBruno Dominguezfi
429611cde1c8SBruno Dominguez
42977d7dbf9dSDan Streetmanif !(GIT="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then
42987d7dbf9dSDan Streetman    exit 1
42995d91a2edSYonggang Luofi
43005d91a2edSYonggang Luo
430198ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
430297a847bcSbellard
430398ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
430498ec69acSJuan Quintelaecho >> $config_host_mak
430598ec69acSJuan Quintela
4306e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
4307cc84d63aSDaniel P. Berrangeecho "GIT=$git" >> $config_host_mak
4308aef45d51SDaniel P. Berrangeecho "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
43097d7dbf9dSDan Streetmanecho "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak
4310804edf29SJuan Quintela
431198ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
4312727e5283SPaolo Bonzini
4313f8393946Saurel32if test "$debug_tcg" = "yes" ; then
43142358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
4315f8393946Saurel32fi
43161625af87Saliguoriif test "$strip_opt" = "yes" ; then
431752ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
43181625af87Saliguorifi
43197d13299dSbellardif test "$bigendian" = "yes" ; then
4320e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
432197a847bcSbellardfi
432267b915a5Sbellardif test "$mingw32" = "yes" ; then
432398ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
4324d9840e25STomoki Sekiyama  if test "$guest_agent_with_vss" = "yes" ; then
4325d9840e25STomoki Sekiyama    echo "CONFIG_QGA_VSS=y" >> $config_host_mak
4326f33ca81fSMichael Roth    echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
4327d9840e25STomoki Sekiyama    echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
4328d9840e25STomoki Sekiyama  fi
432950cbebb9SMichael Roth  if test "$guest_agent_ntddscsi" = "yes" ; then
433076dc75caSTomáš Golembiovský    echo "CONFIG_QGA_NTDDSCSI=y" >> $config_host_mak
433150cbebb9SMichael Roth  fi
43329dacf32dSYossi Hindin  echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
43339dacf32dSYossi Hindin  echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
43349dacf32dSYossi Hindin  echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
43359dacf32dSYossi Hindin  echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
4336210fa556Spbrookelse
433735f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
4338210fa556Spbrookfi
4339128ab2ffSblueswir1
4340dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
4341dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
4342dffcb71cSMark McLoughlinfi
4343dffcb71cSMark McLoughlin
434483fb7adfSbellardif test "$darwin" = "yes" ; then
434598ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
434683fb7adfSbellardfi
4347b29fe3edSmalc
4348ec530c81Sbellardif test "$solaris" = "yes" ; then
434998ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
4350ec530c81Sbellardfi
4351179cf400SAndreas Färberif test "$haiku" = "yes" ; then
4352179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
4353179cf400SAndreas Färberfi
435497a847bcSbellardif test "$static" = "yes" ; then
435598ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
435697a847bcSbellardfi
43571ba16968SStefan Weilif test "$profiler" = "yes" ; then
43582358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
435905c2a3e7Sbellardfi
4360c932ce31SPaolo Bonziniif test "$want_tools" = "yes" ; then
4361c932ce31SPaolo Bonzini  echo "CONFIG_TOOLS=y" >> $config_host_mak
4362c932ce31SPaolo Bonzinifi
4363f15bff25SPaolo Bonziniif test "$guest_agent" = "yes" ; then
4364f15bff25SPaolo Bonzini  echo "CONFIG_GUEST_AGENT=y" >> $config_host_mak
4365f15bff25SPaolo Bonzinifi
4366b8e0c493SJoelle van Dyneif test "$slirp_smbd" = "yes" ; then
4367b8e0c493SJoelle van Dyne  echo "CONFIG_SLIRP_SMBD=y" >> $config_host_mak
4368e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
4369b8e0c493SJoelle van Dynefi
43708a16d273Sthsif test "$vde" = "yes" ; then
437198ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
4372e2ad6f16SFam Zheng  echo "VDE_LIBS=$vde_libs" >> $config_host_mak
43738a16d273Sthsfi
437458952137SVincenzo Maffioneif test "$netmap" = "yes" ; then
437558952137SVincenzo Maffione  echo "CONFIG_NETMAP=y" >> $config_host_mak
437658952137SVincenzo Maffionefi
4377015a33bdSGongleiif test "$l2tpv3" = "yes" ; then
4378015a33bdSGonglei  echo "CONFIG_L2TPV3=y" >> $config_host_mak
4379015a33bdSGongleifi
43804cc600d2SPaolo Bonziniif test "$gprof" = "yes" ; then
43814cc600d2SPaolo Bonzini  echo "CONFIG_GPROF=y" >> $config_host_mak
43824cc600d2SPaolo Bonzinifi
4383b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
4384b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
4385e5f05f8cSKevin Wolfif test "$block_drv_whitelist_tools" = "yes" ; then
4386e5f05f8cSKevin Wolf  echo "CONFIG_BDRV_WHITELIST_TOOLS=y" >> $config_host_mak
4387e5f05f8cSKevin Wolffi
4388dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
4389dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
4390dce512deSChristoph Hellwigfi
439189138857SStefan Weilqemu_version=$(head $source_path/VERSION)
43922358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
439398ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
43942b1f35b9SAlex Bennéeecho "TARGET_DIRS=$target_list" >> $config_host_mak
439517969268SFam Zhengif test "$modules" = "yes"; then
4396e26110cfSFam Zheng  # $shacmd can generate a hash started with digit, which the compiler doesn't
4397e26110cfSFam Zheng  # like as an symbol. So prefix it with an underscore
439889138857SStefan Weil  echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
439917969268SFam Zheng  echo "CONFIG_MODULES=y" >> $config_host_mak
440017969268SFam Zhengfi
4401bd83c861SChristian Ehrhardtif test "$module_upgrades" = "yes"; then
4402bd83c861SChristian Ehrhardt  echo "CONFIG_MODULE_UPGRADES=y" >> $config_host_mak
4403bd83c861SChristian Ehrhardtfi
4404955727d2SCortland Tölvaif test "$have_usbfs" = "yes" ; then
4405955727d2SCortland Tölva  echo "CONFIG_USBFS=y" >> $config_host_mak
4406955727d2SCortland Tölvafi
4407f876b765SMarc-André Lureauif test "$gio" = "yes" ; then
4408f876b765SMarc-André Lureau    echo "CONFIG_GIO=y" >> $config_host_mak
4409f876b765SMarc-André Lureau    echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak
4410f876b765SMarc-André Lureau    echo "GIO_LIBS=$gio_libs" >> $config_host_mak
44115ecfb76cSPaolo Bonzinifi
44125ecfb76cSPaolo Bonziniif test "$gdbus_codegen" != "" ; then
441325a97a56SMarc-André Lureau    echo "GDBUS_CODEGEN=$gdbus_codegen" >> $config_host_mak
4414f876b765SMarc-André Lureaufi
4415a1c5e949SDaniel P. Berrangeecho "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
4416277abf15SJan Vesely
4417277abf15SJan Vesely# Work around a system header bug with some kernel/XFS header
4418277abf15SJan Vesely# versions where they both try to define 'struct fsxattr':
4419277abf15SJan Vesely# xfs headers will not try to redefine structs from linux headers
4420277abf15SJan Vesely# if this macro is set.
4421277abf15SJan Veselyif test "$have_fsxattr" = "yes" ; then
4422277abf15SJan Vesely    echo "HAVE_FSXATTR=y" >> $config_host_mak
4423277abf15SJan Veselyfi
44241badb709SPaolo Bonziniif test "$xen" = "enabled" ; then
44256dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
4426d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
4427582ea95fSMarc-André Lureau  echo "XEN_CFLAGS=$xen_cflags" >> $config_host_mak
4428582ea95fSMarc-André Lureau  echo "XEN_LIBS=$xen_libs" >> $config_host_mak
4429e37630caSaliguorifi
44305c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
44315c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
44325c6c3a6cSChristoph Hellwigfi
44335e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then
44345e9be92dSNicholas Bellinger  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
44355e9be92dSNicholas Bellingerfi
4436af3bba76SPaolo Bonziniif test "$vhost_net" = "yes" ; then
4437af3bba76SPaolo Bonzini  echo "CONFIG_VHOST_NET=y" >> $config_host_mak
4438af3bba76SPaolo Bonzinifi
4439af3bba76SPaolo Bonziniif test "$vhost_net_user" = "yes" ; then
444056f41de7SPaolo Bonzini  echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak
444103ce5744SNikolay Nikolaevfi
4442108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" ; then
4443108a6481SCindy Lu  echo "CONFIG_VHOST_NET_VDPA=y" >> $config_host_mak
4444108a6481SCindy Lufi
4445042cea27SGongleiif test "$vhost_crypto" = "yes" ; then
4446042cea27SGonglei  echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
4447042cea27SGongleifi
4448fc0b9b0eSStefan Hajnocziif test "$vhost_vsock" = "yes" ; then
4449fc0b9b0eSStefan Hajnoczi  echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
44505fe97d88SStefano Garzarella  if test "$vhost_user" = "yes" ; then
44515fe97d88SStefano Garzarella    echo "CONFIG_VHOST_USER_VSOCK=y" >> $config_host_mak
44525fe97d88SStefano Garzarella  fi
4453fc0b9b0eSStefan Hajnoczifi
4454299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" ; then
4455299e6f19SPaolo Bonzini  echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak
4456299e6f19SPaolo Bonzinifi
4457e6a74868SMarc-André Lureauif test "$vhost_user" = "yes" ; then
4458e6a74868SMarc-André Lureau  echo "CONFIG_VHOST_USER=y" >> $config_host_mak
4459e6a74868SMarc-André Lureaufi
4460108a6481SCindy Luif test "$vhost_vdpa" = "yes" ; then
4461108a6481SCindy Lu  echo "CONFIG_VHOST_VDPA=y" >> $config_host_mak
4462108a6481SCindy Lufi
446398fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" ; then
446498fc1adaSDr. David Alan Gilbert  echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak
446598fc1adaSDr. David Alan Gilbertfi
4466bf9298b9Saliguoriif test "$iovec" = "yes" ; then
44672358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
4468bf9298b9Saliguorifi
4469a40161cbSPaolo Bonziniif test "$membarrier" = "yes" ; then
4470a40161cbSPaolo Bonzini  echo "CONFIG_MEMBARRIER=y" >> $config_host_mak
4471a40161cbSPaolo Bonzinifi
4472e5b46549SRichard Hendersonif test "$tcg" = "enabled" -a "$tcg_interpreter" = "true" ; then
4473e5b46549SRichard Henderson  echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
4474e5b46549SRichard Hendersonfi
447558d3f3ffSGerd Hoffmann
447658d3f3ffSGerd Hoffmannif test "$spice_protocol" = "yes" ; then
447758d3f3ffSGerd Hoffmann  echo "CONFIG_SPICE_PROTOCOL=y" >> $config_host_mak
447858d3f3ffSGerd Hoffmann  echo "SPICE_PROTOCOL_CFLAGS=$spice_protocol_cflags" >> $config_host_mak
447958d3f3ffSGerd Hoffmannfi
4480cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
4481cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
448258d3f3ffSGerd Hoffmann  echo "SPICE_CFLAGS=$spice_cflags $spice_protocol_cflags" >> $config_host_mak
44832634733cSPaolo Bonzini  echo "SPICE_LIBS=$spice_libs" >> $config_host_mak
4484cd4ec0b4SGerd Hoffmannfi
4485cd4ec0b4SGerd Hoffmann
4486da076ffeSGerd Hoffmannif test "$opengl" = "yes" ; then
4487da076ffeSGerd Hoffmann  echo "CONFIG_OPENGL=y" >> $config_host_mak
4488de2d3005SPaolo Bonzini  echo "OPENGL_CFLAGS=$opengl_cflags" >> $config_host_mak
4489da076ffeSGerd Hoffmann  echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
449020ff075bSMichael Wallefi
449120ff075bSMichael Walle
449299f2dbd3SLiang Liif test "$avx2_opt" = "yes" ; then
449399f2dbd3SLiang Li  echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
449499f2dbd3SLiang Lifi
449599f2dbd3SLiang Li
44966b8cd447SRobert Hooif test "$avx512f_opt" = "yes" ; then
44976b8cd447SRobert Hoo  echo "CONFIG_AVX512F_OPT=y" >> $config_host_mak
44986b8cd447SRobert Hoofi
44996b8cd447SRobert Hoo
450083fb7adfSbellard# XXX: suppress that
45017d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
45022358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
45037d3505c5Sbellardfi
45047d3505c5Sbellard
45053556c233SPaolo Bonziniif test "$qom_cast_debug" = "yes" ; then
45063556c233SPaolo Bonzini  echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
45073556c233SPaolo Bonzinifi
450820ff6c80SAnthony Liguori
45097c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
451070c60c08SStefan Hajnocziif test "$coroutine_pool" = "yes" ; then
451170c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
451270c60c08SStefan Hajnoczielse
451370c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
451470c60c08SStefan Hajnoczifi
4515d0e2fce5SAneesh Kumar K.V
45167d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes" ; then
45177d992e4dSPeter Lieven  echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
45187d992e4dSPeter Lievenfi
45197d992e4dSPeter Lieven
4520f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes" ; then
4521f0d92b56SLongpeng(Mike)  echo "CONFIG_AF_ALG=y" >> $config_host_mak
4522f0d92b56SLongpeng(Mike)fi
4523f0d92b56SLongpeng(Mike)
4524d83414e1SMarc-André Lureauif test "$have_asan_iface_fiber" = "yes" ; then
4525d83414e1SMarc-André Lureau    echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
4526d83414e1SMarc-André Lureaufi
4527d83414e1SMarc-André Lureau
45280aebab04SLingfeng Yangif test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then
45290aebab04SLingfeng Yang    echo "CONFIG_TSAN=y" >> $config_host_mak
45300aebab04SLingfeng Yangfi
45310aebab04SLingfeng Yang
453276a347e1SRichard Hendersonif test "$cpuid_h" = "yes" ; then
453376a347e1SRichard Henderson  echo "CONFIG_CPUID_H=y" >> $config_host_mak
453476a347e1SRichard Hendersonfi
453576a347e1SRichard Henderson
4536f540166bSRichard Hendersonif test "$int128" = "yes" ; then
4537f540166bSRichard Henderson  echo "CONFIG_INT128=y" >> $config_host_mak
4538f540166bSRichard Hendersonfi
4539f540166bSRichard Henderson
45407ebee43eSRichard Hendersonif test "$atomic128" = "yes" ; then
45417ebee43eSRichard Henderson  echo "CONFIG_ATOMIC128=y" >> $config_host_mak
45427ebee43eSRichard Hendersonfi
45437ebee43eSRichard Henderson
4544e6cd4bb5SRichard Hendersonif test "$cmpxchg128" = "yes" ; then
4545e6cd4bb5SRichard Henderson  echo "CONFIG_CMPXCHG128=y" >> $config_host_mak
4546e6cd4bb5SRichard Hendersonfi
4547e6cd4bb5SRichard Henderson
4548df79b996SRichard Hendersonif test "$atomic64" = "yes" ; then
4549df79b996SRichard Henderson  echo "CONFIG_ATOMIC64=y" >> $config_host_mak
4550df79b996SRichard Hendersonfi
4551df79b996SRichard Henderson
45521e6e9acaSRichard Hendersonif test "$getauxval" = "yes" ; then
45531e6e9acaSRichard Henderson  echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
45541e6e9acaSRichard Hendersonfi
45551e6e9acaSRichard Henderson
4556b10d49d7SPino Toscanoif test "$libssh" = "yes" ; then
4557484e2cc7SPaolo Bonzini  echo "CONFIG_LIBSSH=y" >> $config_host_mak
4558b10d49d7SPino Toscano  echo "LIBSSH_CFLAGS=$libssh_cflags" >> $config_host_mak
4559b10d49d7SPino Toscano  echo "LIBSSH_LIBS=$libssh_libs" >> $config_host_mak
45600a12ec87SRichard W.M. Jonesfi
45610a12ec87SRichard W.M. Jones
4562ed1701c6SDr. David Alan Gilbertif test "$live_block_migration" = "yes" ; then
4563ed1701c6SDr. David Alan Gilbert  echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
4564ed1701c6SDr. David Alan Gilbertfi
4565ed1701c6SDr. David Alan Gilbert
45663b8acc11SPaolo Bonziniif test "$tpm" = "yes"; then
45673cae16dbSPaolo Bonzini  echo 'CONFIG_TPM=y' >> $config_host_mak
45683b8acc11SPaolo Bonzinifi
45693b8acc11SPaolo Bonzini
45705b808275SLluís Vilanovaecho "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
45715b808275SLluís Vilanovaif have_backend "nop"; then
45726d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
457322890ab5SPrerna Saxenafi
45745b808275SLluís Vilanovaif have_backend "simple"; then
45756d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
45766d8a764eSLluís  # Set the appropriate trace file.
4577953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
45789410b56cSPrerna Saxenafi
4579ed7f5f1dSPaolo Bonziniif have_backend "log"; then
4580ed7f5f1dSPaolo Bonzini  echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
45816d8a764eSLluísfi
45825b808275SLluís Vilanovaif have_backend "ust"; then
45836d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
4584a81df1b6SPaolo Bonzini  echo "LTTNG_UST_LIBS=$lttng_ust_libs" >> $config_host_mak
45856d8a764eSLluísfi
45865b808275SLluís Vilanovaif have_backend "dtrace"; then
45876d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
45886d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
45896d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
45906d8a764eSLluís  fi
4591c276b17dSDaniel P. Berrangefi
45925b808275SLluís Vilanovaif have_backend "ftrace"; then
4593781e9545SEiichi Tsukata  if test "$linux" = "yes" ; then
4594781e9545SEiichi Tsukata    echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
4595781e9545SEiichi Tsukata  else
459621684af0SStewart Smith    feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
4597781e9545SEiichi Tsukata  fi
4598781e9545SEiichi Tsukatafi
45990a852417SPaul Durrantif have_backend "syslog"; then
46000a852417SPaul Durrant  if test "$posix_syslog" = "yes" ; then
46010a852417SPaul Durrant    echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
46020a852417SPaul Durrant  else
46030a852417SPaul Durrant    feature_not_found "syslog(trace backend)" "syslog not available"
46040a852417SPaul Durrant  fi
46050a852417SPaul Durrantfi
46069410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
46079410b56cSPrerna Saxena
46082da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then
46092da776dbSMichael R. Hines  echo "CONFIG_RDMA=y" >> $config_host_mak
4610392fb643SFam Zheng  echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
46112da776dbSMichael R. Hinesfi
46122da776dbSMichael R. Hines
461321ab34c9SMarcel Apfelbaumif test "$pvrdma" = "yes" ; then
461421ab34c9SMarcel Apfelbaum  echo "CONFIG_PVRDMA=y" >> $config_host_mak
461521ab34c9SMarcel Apfelbaumfi
461621ab34c9SMarcel Apfelbaum
4617a6b1d4c0SChanglong Xieif test "$replication" = "yes" ; then
4618a6b1d4c0SChanglong Xie  echo "CONFIG_REPLICATION=y" >> $config_host_mak
4619a6b1d4c0SChanglong Xiefi
4620a6b1d4c0SChanglong Xie
46216a02c806SStefan Hajnocziif test "$have_af_vsock" = "yes" ; then
46226a02c806SStefan Hajnoczi  echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
46236a02c806SStefan Hajnoczifi
46246a02c806SStefan Hajnoczi
4625ba59fb77SPaolo Bonziniif test "$debug_mutex" = "yes" ; then
4626ba59fb77SPaolo Bonzini  echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak
4627ba59fb77SPaolo Bonzinifi
4628e0580342SKamil Rytarowski
46295c312079SDr. David Alan Gilbert# Hold two types of flag:
46305c312079SDr. David Alan Gilbert#   CONFIG_THREAD_SETNAME_BYTHREAD  - we've got a way of setting the name on
46315c312079SDr. David Alan Gilbert#                                     a thread we have a handle to
4632479a5747SRoman Bolshakov#   CONFIG_PTHREAD_SETNAME_NP_W_TID - A way of doing it on a particular
46335c312079SDr. David Alan Gilbert#                                     platform
4634479a5747SRoman Bolshakovif test "$pthread_setname_np_w_tid" = "yes" ; then
46355c312079SDr. David Alan Gilbert  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
4636479a5747SRoman Bolshakov  echo "CONFIG_PTHREAD_SETNAME_NP_W_TID=y" >> $config_host_mak
4637479a5747SRoman Bolshakovelif test "$pthread_setname_np_wo_tid" = "yes" ; then
4638479a5747SRoman Bolshakov  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
4639479a5747SRoman Bolshakov  echo "CONFIG_PTHREAD_SETNAME_NP_WO_TID=y" >> $config_host_mak
46405c312079SDr. David Alan Gilbertfi
46415c312079SDr. David Alan Gilbert
46422f740136SJeff Codyif test "$bochs" = "yes" ; then
46432f740136SJeff Cody  echo "CONFIG_BOCHS=y" >> $config_host_mak
46442f740136SJeff Codyfi
46452f740136SJeff Codyif test "$cloop" = "yes" ; then
46462f740136SJeff Cody  echo "CONFIG_CLOOP=y" >> $config_host_mak
46472f740136SJeff Codyfi
46482f740136SJeff Codyif test "$dmg" = "yes" ; then
46492f740136SJeff Cody  echo "CONFIG_DMG=y" >> $config_host_mak
46502f740136SJeff Codyfi
46512f740136SJeff Codyif test "$qcow1" = "yes" ; then
46522f740136SJeff Cody  echo "CONFIG_QCOW1=y" >> $config_host_mak
46532f740136SJeff Codyfi
46542f740136SJeff Codyif test "$vdi" = "yes" ; then
46552f740136SJeff Cody  echo "CONFIG_VDI=y" >> $config_host_mak
46562f740136SJeff Codyfi
46572f740136SJeff Codyif test "$vvfat" = "yes" ; then
46582f740136SJeff Cody  echo "CONFIG_VVFAT=y" >> $config_host_mak
46592f740136SJeff Codyfi
46602f740136SJeff Codyif test "$qed" = "yes" ; then
46612f740136SJeff Cody  echo "CONFIG_QED=y" >> $config_host_mak
46622f740136SJeff Codyfi
46632f740136SJeff Codyif test "$parallels" = "yes" ; then
46642f740136SJeff Cody  echo "CONFIG_PARALLELS=y" >> $config_host_mak
46652f740136SJeff Codyfi
4666195588ccSDavid CARLIERif test "$have_mlockall" = "yes" ; then
4667195588ccSDavid CARLIER  echo "HAVE_MLOCKALL=y" >> $config_host_mak
4668195588ccSDavid CARLIERfi
4669adc28027SAlexander Bulekovif test "$fuzzing" = "yes" ; then
467054c9e41dSAlexander Bulekov  # If LIB_FUZZING_ENGINE is set, assume we are running on OSS-Fuzz, and the
467154c9e41dSAlexander Bulekov  # needed CFLAGS have already been provided
467254c9e41dSAlexander Bulekov  if test -z "${LIB_FUZZING_ENGINE+xxx}" ; then
4673efce01bcSAlexander Bulekov    # Add CFLAGS to tell clang to add fuzzer-related instrumentation to all the
4674efce01bcSAlexander Bulekov    # compiled code.
4675086d5f75SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS -fsanitize=fuzzer-no-link"
4676efce01bcSAlexander Bulekov    # To build non-fuzzer binaries with --enable-fuzzing, link everything with
4677efce01bcSAlexander Bulekov    # fsanitize=fuzzer-no-link. Otherwise, the linker will be unable to bind
4678efce01bcSAlexander Bulekov    # the fuzzer-related callbacks added by instrumentation.
4679efce01bcSAlexander Bulekov    QEMU_LDFLAGS="$QEMU_LDFLAGS -fsanitize=fuzzer-no-link"
4680efce01bcSAlexander Bulekov    # For the actual fuzzer binaries, we need to link against the libfuzzer
4681efce01bcSAlexander Bulekov    # library. Provide the flags for doing this in FUZZ_EXE_LDFLAGS. The meson
4682efce01bcSAlexander Bulekov    # rule for the fuzzer adds these to the link_args. They need to be
4683efce01bcSAlexander Bulekov    # configurable, to support OSS-Fuzz
468454c9e41dSAlexander Bulekov    FUZZ_EXE_LDFLAGS="-fsanitize=fuzzer"
468554c9e41dSAlexander Bulekov  else
468654c9e41dSAlexander Bulekov    FUZZ_EXE_LDFLAGS="$LIB_FUZZING_ENGINE"
468754c9e41dSAlexander Bulekov  fi
4688dfc86c0fSAlexander Bulekov
4689dfc86c0fSAlexander Bulekov  # Specify a filter to only instrument code that is directly related to
4690dfc86c0fSAlexander Bulekov  # virtual-devices.
4691dfc86c0fSAlexander Bulekov  if test "$have_clang_coverage_filter" = "yes" ; then
4692dfc86c0fSAlexander Bulekov    cp "$source_path/scripts/oss-fuzz/instrumentation-filter-template" \
4693dfc86c0fSAlexander Bulekov       instrumentation-filter
4694dfc86c0fSAlexander Bulekov    QEMU_CFLAGS="$QEMU_CFLAGS -fsanitize-coverage-allowlist=instrumentation-filter"
4695dfc86c0fSAlexander Bulekov  fi
4696adc28027SAlexander Bulekovfi
46972f740136SJeff Cody
469840e8c6f4SAlex Bennéeif test "$plugins" = "yes" ; then
469940e8c6f4SAlex Bennée    echo "CONFIG_PLUGIN=y" >> $config_host_mak
470026fffe29SEmilio G. Cota    # Copy the export object list to the build dir
470126fffe29SEmilio G. Cota    if test "$ld_dynamic_list" = "yes" ; then
470226fffe29SEmilio G. Cota	echo "CONFIG_HAS_LD_DYNAMIC_LIST=yes" >> $config_host_mak
470326fffe29SEmilio G. Cota	ld_symbols=qemu-plugins-ld.symbols
470426fffe29SEmilio G. Cota	cp "$source_path/plugins/qemu-plugins.symbols" $ld_symbols
470526fffe29SEmilio G. Cota    elif test "$ld_exported_symbols_list" = "yes" ; then
470626fffe29SEmilio G. Cota	echo "CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST=yes" >> $config_host_mak
470726fffe29SEmilio G. Cota	ld64_symbols=qemu-plugins-ld64.symbols
470826fffe29SEmilio G. Cota	echo "# Automatically generated by configure - do not modify" > $ld64_symbols
470926fffe29SEmilio G. Cota	grep 'qemu_' "$source_path/plugins/qemu-plugins.symbols" | sed 's/;//g' | \
471026fffe29SEmilio G. Cota	    sed -E 's/^[[:space:]]*(.*)/_\1/' >> $ld64_symbols
471126fffe29SEmilio G. Cota    else
471226fffe29SEmilio G. Cota	error_exit \
471326fffe29SEmilio G. Cota	    "If \$plugins=yes, either \$ld_dynamic_list or " \
471426fffe29SEmilio G. Cota	    "\$ld_exported_symbols_list should have been set to 'yes'."
471526fffe29SEmilio G. Cota    fi
471640e8c6f4SAlex Bennéefi
471740e8c6f4SAlex Bennée
4718f48e590aSAlex Bennéeif test -n "$gdb_bin"; then
4719b1863cccSAlex Bennée    gdb_version=$($gdb_bin --version | head -n 1)
4720d6a66c81SAlex Bennée    if version_ge ${gdb_version##* } 9.1; then
4721f48e590aSAlex Bennée        echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
4722f48e590aSAlex Bennée    fi
4723b1863cccSAlex Bennéefi
4724f48e590aSAlex Bennée
472554e7aac0SAlexey Krasikovif test "$secret_keyring" = "yes" ; then
472654e7aac0SAlexey Krasikov  echo "CONFIG_SECRET_KEYRING=y" >> $config_host_mak
472754e7aac0SAlexey Krasikovfi
472854e7aac0SAlexey Krasikov
472998ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
4730804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
4731c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
473239d87c8cSAlex Bennéeecho "GENISOIMAGE=$genisoimage" >> $config_host_mak
4733a5665051SPaolo Bonziniecho "MESON=$meson" >> $config_host_mak
473409e93326SPaolo Bonziniecho "NINJA=$ninja" >> $config_host_mak
4735804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
4736433de74cSBastian Koppelmannecho "HOST_CC=$host_cc" >> $config_host_mak
4737a31a8642SMichael S. Tsirkinif $iasl -h > /dev/null 2>&1; then
4738859aef02SPaolo Bonzini  echo "CONFIG_IASL=$iasl" >> $config_host_mak
4739a31a8642SMichael S. Tsirkinfi
4740804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
4741cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak
47425f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak
47433dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak
4744804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
4745804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
474646eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
4747a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
474811cde1c8SBruno Dominguezecho "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
4749a81df1b6SPaolo Bonziniecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
4750a81df1b6SPaolo Bonziniecho "GLIB_LIBS=$glib_libs" >> $config_host_mak
47518a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
4752e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
4753804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
4754484e2cc7SPaolo Bonziniecho "HOST_DSOSUF=$HOST_DSOSUF" >> $config_host_mak
4755f15bff25SPaolo Bonziniecho "LIBS_QGA=$libs_qga" >> $config_host_mak
47561d728c39SBlue Swirlif test "$gcov" = "yes" ; then
47571d728c39SBlue Swirl  echo "CONFIG_GCOV=y" >> $config_host_mak
47581d728c39SBlue Swirlfi
4759804edf29SJuan Quintela
4760adc28027SAlexander Bulekovif test "$fuzzing" != "no"; then
4761adc28027SAlexander Bulekov    echo "CONFIG_FUZZ=y" >> $config_host_mak
4762adc28027SAlexander Bulekovfi
476354c9e41dSAlexander Bulekovecho "FUZZ_EXE_LDFLAGS=$FUZZ_EXE_LDFLAGS" >> $config_host_mak
47643efac6ebSTomáš Golembiovský
4765b767d257SMarek Marczykowski-Góreckiif test "$rng_none" = "yes"; then
4766b767d257SMarek Marczykowski-Górecki  echo "CONFIG_RNG_NONE=y" >> $config_host_mak
4767b767d257SMarek Marczykowski-Góreckifi
4768b767d257SMarek Marczykowski-Górecki
47696efd7517SPeter Maydell# use included Linux headers
47706efd7517SPeter Maydellif test "$linux" = "yes" ; then
4771a307beb6SAndreas Färber  mkdir -p linux-headers
47726efd7517SPeter Maydell  case "$cpu" in
4773c72b26ecSRichard Henderson  i386|x86_64|x32)
477408312a63SPeter Maydell    linux_arch=x86
47756efd7517SPeter Maydell    ;;
4776f8378accSRichard Henderson  ppc|ppc64|ppc64le)
477708312a63SPeter Maydell    linux_arch=powerpc
47786efd7517SPeter Maydell    ;;
47796efd7517SPeter Maydell  s390x)
478008312a63SPeter Maydell    linux_arch=s390
478108312a63SPeter Maydell    ;;
47821f080313SClaudio Fontana  aarch64)
47831f080313SClaudio Fontana    linux_arch=arm64
47841f080313SClaudio Fontana    ;;
4785222e7d11SSanjay Lal  mips64)
4786222e7d11SSanjay Lal    linux_arch=mips
4787222e7d11SSanjay Lal    ;;
478808312a63SPeter Maydell  *)
478908312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
479008312a63SPeter Maydell    linux_arch="$cpu"
47916efd7517SPeter Maydell    ;;
47926efd7517SPeter Maydell  esac
479308312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
479408312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
479508312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
479608312a63SPeter Maydell    fi
47976efd7517SPeter Maydellfi
47986efd7517SPeter Maydell
479997a847bcSbellardfor target in $target_list; do
480097a847bcSbellard    target_dir="$target"
480189138857SStefan Weil    target_name=$(echo $target | cut -d '-' -f 1)
480297a847bcSbellard    mkdir -p $target_dir
4803fdb75aefSPaolo Bonzini    case $target in
4804fdb75aefSPaolo Bonzini        *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;;
4805fdb75aefSPaolo Bonzini        *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;;
48062408a527Saurel32    esac
480756aebc89Spbrookdone
48087d13299dSbellard
4809765686d6SPaolo Bonziniecho "CONFIG_QEMU_INTERP_PREFIX=$interp_prefix" | sed 's/%M/@0@/' >> $config_host_mak
4810fdb75aefSPaolo Bonziniif test "$default_targets" = "yes"; then
4811fdb75aefSPaolo Bonzini  echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak
4812fdb75aefSPaolo Bonzinifi
4813a540f158SPeter Crosthwaite
4814a99d57bbSWanlong Gaoif test "$numa" = "yes"; then
4815a99d57bbSWanlong Gao  echo "CONFIG_NUMA=y" >> $config_host_mak
4816ab318051SMarc-André Lureau  echo "NUMA_LIBS=$numa_libs" >> $config_host_mak
4817a99d57bbSWanlong Gaofi
4818a99d57bbSWanlong Gao
4819fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then
4820fd0e6053SJohn Snow  echo "export CCACHE_CPP2=y" >> $config_host_mak
4821fd0e6053SJohn Snowfi
4822fd0e6053SJohn Snow
48231e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then
48241e4f6065SDaniele Buono  echo "CONFIG_SAFESTACK=y" >> $config_host_mak
48251e4f6065SDaniele Buonofi
48261e4f6065SDaniele Buono
4827e29e5c6eSPeter Maydell# If we're using a separate build tree, set it up now.
4828e29e5c6eSPeter Maydell# DIRS are directories which we simply mkdir in the build tree;
4829e29e5c6eSPeter Maydell# LINKS are things to symlink back into the source tree
4830e29e5c6eSPeter Maydell# (these can be both files and directories).
4831e29e5c6eSPeter Maydell# Caution: do not add files or directories here using wildcards. This
4832e29e5c6eSPeter Maydell# will result in problems later if a new file matching the wildcard is
4833e29e5c6eSPeter Maydell# added to the source tree -- nothing will cause configure to be rerun
4834e29e5c6eSPeter Maydell# so the build tree will be missing the link back to the new file, and
4835e29e5c6eSPeter Maydell# tests might fail. Prefer to keep the relevant files in their own
4836e29e5c6eSPeter Maydell# directory and symlink the directory instead.
483709db9b9dSGerd Hoffmann# UNLINK is used to remove symlinks from older development versions
483809db9b9dSGerd Hoffmann# that might get into the way when doing "git update" without doing
483909db9b9dSGerd Hoffmann# a "make distclean" in between.
48409d49bcf6SMarkus ArmbrusterDIRS="tests tests/tcg tests/qapi-schema tests/qtest/libqos"
48411cf4323eSThomas HuthDIRS="$DIRS tests/qtest tests/qemu-iotests tests/vm tests/fp tests/qgraph"
4842b855f8d1SPaolo BonziniDIRS="$DIRS docs docs/interop fsdev scsi"
4843744a928cSAlexey KardashevskiyDIRS="$DIRS pc-bios/optionrom pc-bios/s390-ccw"
48448db2a4fdSGerd HoffmannDIRS="$DIRS roms/seabios"
4845c17a386bSAlex BennéeDIRS="$DIRS contrib/plugins/"
48462038f8c8SPaolo BonziniLINKS="Makefile"
48473941996bSPaolo BonziniLINKS="$LINKS tests/tcg/Makefile.target"
4848ddcf607fSGerd HoffmannLINKS="$LINKS pc-bios/optionrom/Makefile"
4849e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/s390-ccw/Makefile"
48508db2a4fdSGerd HoffmannLINKS="$LINKS roms/seabios/Makefile"
4851e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/qemu-icon.bmp"
4852e29e5c6eSPeter MaydellLINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
485339950353SPeter MaydellLINKS="$LINKS tests/acceptance tests/data"
485439950353SPeter MaydellLINKS="$LINKS tests/qemu-iotests/check"
48558f8fd9edSCleber RosaLINKS="$LINKS python"
4856c17a386bSAlex BennéeLINKS="$LINKS contrib/plugins/Makefile "
485709db9b9dSGerd HoffmannUNLINK="pc-bios/keymaps"
4858753d11f2SRichard Hendersonfor bios_file in \
4859753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
48603a631b8eSBin Meng    $source_path/pc-bios/*.elf \
4861225a9ab8SAlexey Kardashevskiy    $source_path/pc-bios/*.lid \
4862753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
4863753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
4864e89e33e1SDominik Dingel    $source_path/pc-bios/*.img \
4865753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
48664e73c781SAlexander Graf    $source_path/pc-bios/u-boot.* \
486726ce90fdSLaszlo Ersek    $source_path/pc-bios/edk2-*.fd.bz2 \
4868cd946e5cSJohn Arbuckle    $source_path/pc-bios/palcode-* \
4869cd946e5cSJohn Arbuckle    $source_path/pc-bios/qemu_vga.ndrv
4870cd946e5cSJohn Arbuckle
4871753d11f2SRichard Hendersondo
4872e29e5c6eSPeter Maydell    LINKS="$LINKS pc-bios/$(basename $bios_file)"
48737ea78b74SJan Kiszkadone
4874d1807a4fSPaolo Bonzinimkdir -p $DIRS
4875e29e5c6eSPeter Maydellfor f in $LINKS ; do
48760f4d8894SPaolo Bonzini    if [ -e "$source_path/$f" ]; then
4877f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
4878f9245e10SPeter Maydell    fi
48797d13299dSbellarddone
488009db9b9dSGerd Hoffmannfor f in $UNLINK ; do
488109db9b9dSGerd Hoffmann    if [ -L "$f" ]; then
488209db9b9dSGerd Hoffmann        rm -f "$f"
488309db9b9dSGerd Hoffmann    fi
488409db9b9dSGerd Hoffmanndone
48851ad2134fSPaul Brook
48862038f8c8SPaolo Bonzini(for i in $cross_cc_vars; do
48872038f8c8SPaolo Bonzini  export $i
48882038f8c8SPaolo Bonzinidone
4889de6d7e6bSAlex Bennéeexport target_list source_path use_containers ARCH
48902038f8c8SPaolo Bonzini$source_path/tests/tcg/configure.sh)
48912038f8c8SPaolo Bonzini
4892c34ebfdcSAnthony Liguori# temporary config to build submodules
48938db2a4fdSGerd Hoffmannfor rom in seabios; do
4894c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
489537116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
4896c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
4897cdbd727cSRichard Henderson    echo "AS=$as" >> $config_mak
48985f6f0e27SRichard Henderson    echo "CCAS=$ccas" >> $config_mak
4899c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
4900c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
49013dd46c78SBlue Swirl    echo "CPP=$cpp" >> $config_mak
4902c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
4903a31a8642SMichael S. Tsirkin    echo "IASL=$iasl" >> $config_mak
4904c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
49059f81aeb5SAlistair Francis    echo "RANLIB=$ranlib" >> $config_mak
4906c34ebfdcSAnthony Liguoridone
4907c34ebfdcSAnthony Liguori
4908a5665051SPaolo Bonziniif test "$skip_meson" = no; then
4909fc929892SMarc-André Lureau  cross="config-meson.cross.new"
4910fc929892SMarc-André Lureau  meson_quote() {
491147b30835SPaolo Bonzini    echo "'$(echo $* | sed "s/ /','/g")'"
4912fc929892SMarc-André Lureau  }
4913fc929892SMarc-André Lureau
4914fc929892SMarc-André Lureau  echo "# Automatically generated by configure - do not modify" > $cross
4915fc929892SMarc-André Lureau  echo "[properties]" >> $cross
4916d1d5e9eeSAlex Bennée
4917d1d5e9eeSAlex Bennée  # unroll any custom device configs
4918d1d5e9eeSAlex Bennée  for a in $device_archs; do
4919d1d5e9eeSAlex Bennée      eval "c=\$devices_${a}"
4920d1d5e9eeSAlex Bennée      echo "${a}-softmmu = '$c'" >> $cross
4921d1d5e9eeSAlex Bennée  done
4922d1d5e9eeSAlex Bennée
4923fc929892SMarc-André Lureau  test -z "$cxx" && echo "link_language = 'c'" >> $cross
492447b30835SPaolo Bonzini  echo "[built-in options]" >> $cross
492547b30835SPaolo Bonzini  echo "c_args = [${CFLAGS:+$(meson_quote $CFLAGS)}]" >> $cross
492647b30835SPaolo Bonzini  echo "cpp_args = [${CXXFLAGS:+$(meson_quote $CXXFLAGS)}]" >> $cross
492747b30835SPaolo Bonzini  echo "c_link_args = [${LDFLAGS:+$(meson_quote $LDFLAGS)}]" >> $cross
492847b30835SPaolo Bonzini  echo "cpp_link_args = [${LDFLAGS:+$(meson_quote $LDFLAGS)}]" >> $cross
4929fc929892SMarc-André Lureau  echo "[binaries]" >> $cross
49304dba2789SPaolo Bonzini  echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross
49314dba2789SPaolo Bonzini  test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross
49324dba2789SPaolo Bonzini  test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross
493347b30835SPaolo Bonzini  echo "ar = [$(meson_quote $ar)]" >> $cross
493447b30835SPaolo Bonzini  echo "nm = [$(meson_quote $nm)]" >> $cross
493547b30835SPaolo Bonzini  echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross
493647b30835SPaolo Bonzini  echo "ranlib = [$(meson_quote $ranlib)]" >> $cross
4937e8178514SPaolo Bonzini  if has $sdl2_config; then
493847b30835SPaolo Bonzini    echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross
4939e8178514SPaolo Bonzini  fi
494047b30835SPaolo Bonzini  echo "strip = [$(meson_quote $strip)]" >> $cross
494147b30835SPaolo Bonzini  echo "windres = [$(meson_quote $windres)]" >> $cross
49423812c0c4SJoelle van Dyne  if test "$cross_compile" = "yes"; then
4943fc929892SMarc-André Lureau    cross_arg="--cross-file config-meson.cross"
4944fc929892SMarc-André Lureau    echo "[host_machine]" >> $cross
4945fc929892SMarc-André Lureau    if test "$mingw32" = "yes" ; then
4946fc929892SMarc-André Lureau        echo "system = 'windows'" >> $cross
4947fc929892SMarc-André Lureau    fi
4948853b4bafSThomas Huth    if test "$linux" = "yes" ; then
4949853b4bafSThomas Huth        echo "system = 'linux'" >> $cross
4950853b4bafSThomas Huth    fi
49510ca321eaSJoelle van Dyne    if test "$darwin" = "yes" ; then
49520ca321eaSJoelle van Dyne        echo "system = 'darwin'" >> $cross
49530ca321eaSJoelle van Dyne    fi
4954fc929892SMarc-André Lureau    case "$ARCH" in
4955f6bca9dfSJoelle van Dyne        i386)
4956fc929892SMarc-André Lureau            echo "cpu_family = 'x86'" >> $cross
4957fc929892SMarc-André Lureau            ;;
4958f8bb7e1cSDavid Michael        x86_64|x32)
4959f6bca9dfSJoelle van Dyne            echo "cpu_family = 'x86_64'" >> $cross
4960f6bca9dfSJoelle van Dyne            ;;
4961fc929892SMarc-André Lureau        ppc64le)
4962fc929892SMarc-André Lureau            echo "cpu_family = 'ppc64'" >> $cross
4963fc929892SMarc-André Lureau            ;;
4964fc929892SMarc-André Lureau        *)
4965fc929892SMarc-André Lureau            echo "cpu_family = '$ARCH'" >> $cross
4966fc929892SMarc-André Lureau            ;;
4967fc929892SMarc-André Lureau    esac
4968fc929892SMarc-André Lureau    echo "cpu = '$cpu'" >> $cross
4969fc929892SMarc-André Lureau    if test "$bigendian" = "yes" ; then
4970fc929892SMarc-André Lureau        echo "endian = 'big'" >> $cross
4971fc929892SMarc-André Lureau    else
4972fc929892SMarc-André Lureau        echo "endian = 'little'" >> $cross
4973fc929892SMarc-André Lureau    fi
4974fc929892SMarc-André Lureau  else
4975fc929892SMarc-André Lureau    cross_arg="--native-file config-meson.cross"
4976fc929892SMarc-André Lureau  fi
4977fc929892SMarc-André Lureau  mv $cross config-meson.cross
4978fc929892SMarc-André Lureau
4979a5665051SPaolo Bonzini  rm -rf meson-private meson-info meson-logs
498009e93326SPaolo Bonzini  NINJA=$ninja $meson setup \
4981d17f305aSPaolo Bonzini        --prefix "$prefix" \
4982d17f305aSPaolo Bonzini        --libdir "$libdir" \
4983d17f305aSPaolo Bonzini        --libexecdir "$libexecdir" \
4984d17f305aSPaolo Bonzini        --bindir "$bindir" \
4985d17f305aSPaolo Bonzini        --includedir "$includedir" \
4986d17f305aSPaolo Bonzini        --datadir "$datadir" \
4987d17f305aSPaolo Bonzini        --mandir "$mandir" \
4988d17f305aSPaolo Bonzini        --sysconfdir "$sysconfdir" \
498916bf7a33SPaolo Bonzini        --localedir "$localedir" \
4990d17f305aSPaolo Bonzini        --localstatedir "$local_statedir" \
4991d17f305aSPaolo Bonzini        -Ddocdir="$docdir" \
499216bf7a33SPaolo Bonzini        -Dqemu_firmwarepath="$firmwarepath" \
499373f3aa37SMarc-André Lureau        -Dqemu_suffix="$qemu_suffix" \
4994a5665051SPaolo Bonzini        -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) \
4995a5665051SPaolo Bonzini        -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo false; fi) \
4996a5665051SPaolo Bonzini        -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \
4997a5665051SPaolo Bonzini        -Dstrip=$(if test "$strip_opt" = yes; then echo true; else echo false; fi) \
4998da6d48b9SMarc-André Lureau        -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \
4999bf0e56a3SMarc-André Lureau        -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \
50009e62ba48SDaniele Buono        -Db_lto=$lto -Dcfi=$cfi -Dcfi_debug=$cfi_debug \
5001deb62371SPaolo Bonzini        -Dmalloc=$malloc -Dmalloc_trim=$malloc_trim -Dsparse=$sparse \
500274a414a1SReinoud Zandijk        -Dkvm=$kvm -Dhax=$hax -Dwhpx=$whpx -Dhvf=$hvf -Dnvmm=$nvmm \
50031badb709SPaolo Bonzini        -Dxen=$xen -Dxen_pci_passthrough=$xen_pci_passthrough -Dtcg=$tcg \
50041b695471SPaolo Bonzini        -Dcocoa=$cocoa -Dgtk=$gtk -Dmpath=$mpath -Dsdl=$sdl -Dsdl_image=$sdl_image \
5005c23d7b4eSPaolo Bonzini        -Dlibusb=$libusb -Dsmartcard=$smartcard -Dusb_redir=$usb_redir -Dvte=$vte \
5006a0b93237SPaolo Bonzini        -Dvnc=$vnc -Dvnc_sasl=$vnc_sasl -Dvnc_jpeg=$vnc_jpeg -Dvnc_png=$vnc_png \
5007cece116cSMisono Tomohiro        -Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f -Dvirtiofsd=$virtiofsd \
50088c6d4ff4SPaolo Bonzini        -Dcapstone=$capstone -Dslirp=$slirp -Dfdt=$fdt -Dbrlapi=$brlapi \
50099db405a3SPaolo Bonzini        -Dcurl=$curl -Dglusterfs=$glusterfs -Dbzip2=$bzip2 -Dlibiscsi=$libiscsi \
501030045c05SPaolo Bonzini        -Dlibnfs=$libnfs -Diconv=$iconv -Dcurses=$curses -Dlibudev=$libudev\
5011c5b36c25SPaolo Bonzini        -Drbd=$rbd -Dlzo=$lzo -Dsnappy=$snappy -Dlzfse=$lzfse -Dlibxml2=$libxml2 \
501253c22b68SPaolo Bonzini        -Dlibdaxctl=$libdaxctl -Dlibpmem=$libpmem -Dlinux_io_uring=$linux_io_uring \
501305e391aeSPaolo Bonzini        -Dgnutls=$gnutls -Dnettle=$nettle -Dgcrypt=$gcrypt -Dauth_pam=$auth_pam \
5014727c8bb8SPaolo Bonzini        -Dzstd=$zstd -Dseccomp=$seccomp -Dvirtfs=$virtfs -Dcap_ng=$cap_ng \
5015587d59d6SPaolo Bonzini        -Dattr=$attr -Ddefault_devices=$default_devices -Dvirglrenderer=$virglrenderer \
5016c8d5450bSPaolo Bonzini        -Ddocs=$docs -Dsphinx_build=$sphinx_build -Dinstall_blobs=$blobs \
5017106ad1f9SPaolo Bonzini        -Dvhost_user_blk_server=$vhost_user_blk_server -Dmultiprocess=$multiprocess \
501846627f41SAndrew Melnychenko        -Dfuse=$fuse -Dfuse_lseek=$fuse_lseek -Dguest_agent_msi=$guest_agent_msi -Dbpf=$bpf\
5019332008e0SThomas Huth        $(if test "$default_feature" = no; then echo "-Dauto_features=disabled"; fi) \
5020*87430d5bSPaolo Bonzini        -Daudio_drv_list=$audio_drv_list -Dtcg_interpreter=$tcg_interpreter \
5021fc929892SMarc-André Lureau        $cross_arg \
5022a5665051SPaolo Bonzini        "$PWD" "$source_path"
5023a5665051SPaolo Bonzini
5024a5665051SPaolo Bonzini  if test "$?" -ne 0 ; then
5025a5665051SPaolo Bonzini      error_exit "meson setup failed"
5026a5665051SPaolo Bonzini  fi
5027699d3884SPaolo Bonzinielse
5028699d3884SPaolo Bonzini  if test -f meson-private/cmd_line.txt; then
5029699d3884SPaolo Bonzini    # Adjust old command line options whose type was changed
5030699d3884SPaolo Bonzini    # Avoids having to use "setup --wipe" when Meson is upgraded
5031699d3884SPaolo Bonzini    perl -i -ne '
5032699d3884SPaolo Bonzini      s/^gettext = true$/gettext = auto/;
5033699d3884SPaolo Bonzini      s/^gettext = false$/gettext = disabled/;
5034654d6b04SPaolo Bonzini      /^b_staticpic/ && next;
5035699d3884SPaolo Bonzini      print;' meson-private/cmd_line.txt
5036699d3884SPaolo Bonzini  fi
5037a5665051SPaolo Bonzinifi
5038a5665051SPaolo Bonzini
50392d838d9bSAlex Bennéeif test -n "${deprecated_features}"; then
50402d838d9bSAlex Bennée    echo "Warning, deprecated features enabled."
5041a476b216SMao Zhongyi    echo "Please see docs/about/deprecated.rst"
50422d838d9bSAlex Bennée    echo "  features: ${deprecated_features}"
50432d838d9bSAlex Bennéefi
50442d838d9bSAlex Bennée
5045e0447a83SThomas Huth# Create list of config switches that should be poisoned in common code...
5046e0447a83SThomas Huth# but filter out CONFIG_TCG and CONFIG_USER_ONLY which are special.
504754b0306eSThomas Huthtarget_configs_h=$(ls *-config-devices.h *-config-target.h 2>/dev/null)
504854b0306eSThomas Huthif test -n "$target_configs_h" ; then
5049e0447a83SThomas Huth    sed -n -e '/CONFIG_TCG/d' -e '/CONFIG_USER_ONLY/d' \
5050e0447a83SThomas Huth        -e '/^#define / { s///; s/ .*//; s/^/#pragma GCC poison /p; }' \
505154b0306eSThomas Huth        $target_configs_h | sort -u > config-poison.h
505254b0306eSThomas Huthelse
505354b0306eSThomas Huth    :> config-poison.h
505454b0306eSThomas Huthfi
5055e0447a83SThomas Huth
5056dc655404SMichael S. Tsirkin# Save the configure command line for later reuse.
5057dc655404SMichael S. Tsirkincat <<EOD >config.status
5058dc655404SMichael S. Tsirkin#!/bin/sh
5059dc655404SMichael S. Tsirkin# Generated by configure.
5060dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration.
5061dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging
5062dc655404SMichael S. Tsirkin# configure, is in config.log if it exists.
5063dc655404SMichael S. TsirkinEOD
5064e811da7fSDaniel P. Berrangé
5065e811da7fSDaniel P. Berrangépreserve_env() {
5066e811da7fSDaniel P. Berrangé    envname=$1
5067e811da7fSDaniel P. Berrangé
5068e811da7fSDaniel P. Berrangé    eval envval=\$$envname
5069e811da7fSDaniel P. Berrangé
5070e811da7fSDaniel P. Berrangé    if test -n "$envval"
5071e811da7fSDaniel P. Berrangé    then
5072e811da7fSDaniel P. Berrangé	echo "$envname='$envval'" >> config.status
5073e811da7fSDaniel P. Berrangé	echo "export $envname" >> config.status
5074e811da7fSDaniel P. Berrangé    else
5075e811da7fSDaniel P. Berrangé	echo "unset $envname" >> config.status
5076e811da7fSDaniel P. Berrangé    fi
5077e811da7fSDaniel P. Berrangé}
5078e811da7fSDaniel P. Berrangé
5079e811da7fSDaniel P. Berrangé# Preserve various env variables that influence what
5080e811da7fSDaniel P. Berrangé# features/build target configure will detect
5081e811da7fSDaniel P. Berrangépreserve_env AR
5082e811da7fSDaniel P. Berrangépreserve_env AS
5083e811da7fSDaniel P. Berrangépreserve_env CC
5084e811da7fSDaniel P. Berrangépreserve_env CPP
5085e811da7fSDaniel P. Berrangépreserve_env CXX
5086e811da7fSDaniel P. Berrangépreserve_env INSTALL
5087e811da7fSDaniel P. Berrangépreserve_env LD
5088e811da7fSDaniel P. Berrangépreserve_env LD_LIBRARY_PATH
5089e811da7fSDaniel P. Berrangépreserve_env LIBTOOL
5090e811da7fSDaniel P. Berrangépreserve_env MAKE
5091e811da7fSDaniel P. Berrangépreserve_env NM
5092e811da7fSDaniel P. Berrangépreserve_env OBJCOPY
5093e811da7fSDaniel P. Berrangépreserve_env PATH
5094e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG
5095e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_LIBDIR
5096e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_PATH
5097e811da7fSDaniel P. Berrangépreserve_env PYTHON
5098e811da7fSDaniel P. Berrangépreserve_env SDL2_CONFIG
5099e811da7fSDaniel P. Berrangépreserve_env SMBD
5100e811da7fSDaniel P. Berrangépreserve_env STRIP
5101e811da7fSDaniel P. Berrangépreserve_env WINDRES
5102e811da7fSDaniel P. Berrangé
5103dc655404SMichael S. Tsirkinprintf "exec" >>config.status
5104a5665051SPaolo Bonzinifor i in "$0" "$@"; do
5105835af899SPaolo Bonzini  test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status
5106a5665051SPaolo Bonzinidone
5107cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status
5108dc655404SMichael S. Tsirkinchmod +x config.status
5109dc655404SMichael S. Tsirkin
51108cd05ab6SPeter Maydellrm -r "$TMPDIR1"
5111