xref: /openbmc/qemu/configure (revision d1d5e9eefd7f0165884998f3054836580a69e1a4)
17d13299dSbellard#!/bin/sh
27d13299dSbellard#
33ef693a0Sbellard# qemu configure script (c) 2003 Fabrice Bellard
47d13299dSbellard#
58cd05ab6SPeter Maydell
699519e67SCornelia Huck# Unset some variables known to interfere with behavior of common tools,
799519e67SCornelia Huck# just as autoconf does.
899519e67SCornelia HuckCLICOLOR_FORCE= GREP_OPTIONS=
999519e67SCornelia Huckunset CLICOLOR_FORCE GREP_OPTIONS
1099519e67SCornelia Huck
115e4dfd3dSJohn Snow# Don't allow CCACHE, if present, to use cached results of compile tests!
125e4dfd3dSJohn Snowexport CCACHE_RECACHE=yes
135e4dfd3dSJohn Snow
14dedad027SDaniel P. Berrangé# make source path absolute
15dedad027SDaniel P. Berrangésource_path=$(cd "$(dirname -- "$0")"; pwd)
16dedad027SDaniel P. Berrangé
17dedad027SDaniel P. Berrangéif test "$PWD" = "$source_path"
18dedad027SDaniel P. Berrangéthen
19dedad027SDaniel P. Berrangé    echo "Using './build' as the directory for build output"
20dedad027SDaniel P. Berrangé
21dedad027SDaniel P. Berrangé    MARKER=build/auto-created-by-configure
22dedad027SDaniel P. Berrangé
23dedad027SDaniel P. Berrangé    if test -e build
24dedad027SDaniel P. Berrangé    then
25dedad027SDaniel P. Berrangé        if test -f $MARKER
26dedad027SDaniel P. Berrangé        then
27dedad027SDaniel P. Berrangé           rm -rf build
28dedad027SDaniel P. Berrangé        else
29dedad027SDaniel P. Berrangé            echo "ERROR: ./build dir already exists and was not previously created by configure"
30dedad027SDaniel P. Berrangé            exit 1
31dedad027SDaniel P. Berrangé        fi
32dedad027SDaniel P. Berrangé    fi
33dedad027SDaniel P. Berrangé
34dedad027SDaniel P. Berrangé    mkdir build
35dedad027SDaniel P. Berrangé    touch $MARKER
36dedad027SDaniel P. Berrangé
37dedad027SDaniel P. Berrangé    cat > GNUmakefile <<'EOF'
38dedad027SDaniel P. Berrangé# This file is auto-generated by configure to support in-source tree
39dedad027SDaniel P. Berrangé# 'make' command invocation
40dedad027SDaniel P. Berrangé
41dedad027SDaniel P. Berrangéifeq ($(MAKECMDGOALS),)
42dedad027SDaniel P. Berrangérecurse: all
43dedad027SDaniel P. Berrangéendif
44dedad027SDaniel P. Berrangé
45dedad027SDaniel P. Berrangé.NOTPARALLEL: %
46dedad027SDaniel P. Berrangé%: force
47dedad027SDaniel P. Berrangé	@echo 'changing dir to build for $(MAKE) "$(MAKECMDGOALS)"...'
48dedad027SDaniel P. Berrangé	@$(MAKE) -C build -f Makefile $(MAKECMDGOALS)
49dedad027SDaniel P. Berrangé	@if test "$(MAKECMDGOALS)" = "distclean" && \
50dedad027SDaniel P. Berrangé	    test -e build/auto-created-by-configure ; \
51dedad027SDaniel P. Berrangé	then \
52dedad027SDaniel P. Berrangé	    rm -rf build GNUmakefile ; \
53dedad027SDaniel P. Berrangé	fi
54dedad027SDaniel P. Berrangéforce: ;
55dedad027SDaniel P. Berrangé.PHONY: force
56dedad027SDaniel P. BerrangéGNUmakefile: ;
57dedad027SDaniel P. Berrangé
58dedad027SDaniel P. BerrangéEOF
59dedad027SDaniel P. Berrangé    cd build
60dedad027SDaniel P. Berrangé    exec $source_path/configure "$@"
61dedad027SDaniel P. Berrangéfi
62dedad027SDaniel P. Berrangé
638cd05ab6SPeter Maydell# Temporary directory used for files created while
648cd05ab6SPeter Maydell# configure runs. Since it is in the build directory
658cd05ab6SPeter Maydell# we can safely blow away any previous version of it
668cd05ab6SPeter Maydell# (and we need not jump through hoops to try to delete
678cd05ab6SPeter Maydell# it when configure exits.)
688cd05ab6SPeter MaydellTMPDIR1="config-temp"
698cd05ab6SPeter Maydellrm -rf "${TMPDIR1}"
708cd05ab6SPeter Maydellmkdir -p "${TMPDIR1}"
718cd05ab6SPeter Maydellif [ $? -ne 0 ]; then
728cd05ab6SPeter Maydell    echo "ERROR: failed to create temporary directory"
738cd05ab6SPeter Maydell    exit 1
747d13299dSbellardfi
757d13299dSbellard
768cd05ab6SPeter MaydellTMPB="qemu-conf"
778cd05ab6SPeter MaydellTMPC="${TMPDIR1}/${TMPB}.c"
7866518bf6SDon SlutzTMPO="${TMPDIR1}/${TMPB}.o"
799c83ffd8SPeter MaydellTMPCXX="${TMPDIR1}/${TMPB}.cxx"
808cd05ab6SPeter MaydellTMPE="${TMPDIR1}/${TMPB}.exe"
8126fffe29SEmilio G. CotaTMPTXT="${TMPDIR1}/${TMPB}.txt"
827d13299dSbellard
83da1d85e3SGerd Hoffmannrm -f config.log
849ac81bbbSmalc
85b48e3611SPeter Maydell# Print a helpful header at the top of config.log
86b48e3611SPeter Maydellecho "# QEMU configure log $(date)" >> config.log
87979ae168SPeter Maydellprintf "# Configured with:" >> config.log
88979ae168SPeter Maydellprintf " '%s'" "$0" "$@" >> config.log
89979ae168SPeter Maydellecho >> config.log
90b48e3611SPeter Maydellecho "#" >> config.log
91b48e3611SPeter Maydell
92835af899SPaolo Bonziniquote_sh() {
93835af899SPaolo Bonzini    printf "%s" "$1" | sed "s,','\\\\'',g; s,.*,'&',"
94835af899SPaolo Bonzini}
95835af899SPaolo Bonzini
96d880a3baSPaolo Bonziniprint_error() {
97d880a3baSPaolo Bonzini    (echo
9876ad07a4SPeter Maydell    echo "ERROR: $1"
9976ad07a4SPeter Maydell    while test -n "$2"; do
10076ad07a4SPeter Maydell        echo "       $2"
10176ad07a4SPeter Maydell        shift
10276ad07a4SPeter Maydell    done
103d880a3baSPaolo Bonzini    echo) >&2
104d880a3baSPaolo Bonzini}
105d880a3baSPaolo Bonzini
106d880a3baSPaolo Bonzinierror_exit() {
107d880a3baSPaolo Bonzini    print_error "$@"
10876ad07a4SPeter Maydell    exit 1
10976ad07a4SPeter Maydell}
11076ad07a4SPeter Maydell
1119c83ffd8SPeter Maydelldo_compiler() {
1129c83ffd8SPeter Maydell    # Run the compiler, capturing its output to the log. First argument
1139c83ffd8SPeter Maydell    # is compiler binary to execute.
114630d86b7SDavid CARLIER    compiler="$1"
1159c83ffd8SPeter Maydell    shift
1168bbe05d7SIan Jackson    if test -n "$BASH_VERSION"; then eval '
1178bbe05d7SIan Jackson        echo >>config.log "
1188bbe05d7SIan Jacksonfuncs: ${FUNCNAME[*]}
1198bbe05d7SIan Jacksonlines: ${BASH_LINENO[*]}"
1208bbe05d7SIan Jackson    '; fi
1219c83ffd8SPeter Maydell    echo $compiler "$@" >> config.log
1229c83ffd8SPeter Maydell    $compiler "$@" >> config.log 2>&1 || return $?
1238dc38a78SPeter Maydell    # Test passed. If this is an --enable-werror build, rerun
1248dc38a78SPeter Maydell    # the test with -Werror and bail out if it fails. This
1258dc38a78SPeter Maydell    # makes warning-generating-errors in configure test code
1268dc38a78SPeter Maydell    # obvious to developers.
1278dc38a78SPeter Maydell    if test "$werror" != "yes"; then
1288dc38a78SPeter Maydell        return 0
1298dc38a78SPeter Maydell    fi
1308dc38a78SPeter Maydell    # Don't bother rerunning the compile if we were already using -Werror
1318dc38a78SPeter Maydell    case "$*" in
1328dc38a78SPeter Maydell        *-Werror*)
1338dc38a78SPeter Maydell           return 0
1348dc38a78SPeter Maydell        ;;
1358dc38a78SPeter Maydell    esac
1369c83ffd8SPeter Maydell    echo $compiler -Werror "$@" >> config.log
1379c83ffd8SPeter Maydell    $compiler -Werror "$@" >> config.log 2>&1 && return $?
13876ad07a4SPeter Maydell    error_exit "configure test passed without -Werror but failed with -Werror." \
13976ad07a4SPeter Maydell        "This is probably a bug in the configure script. The failing command" \
14076ad07a4SPeter Maydell        "will be at the bottom of config.log." \
14176ad07a4SPeter Maydell        "You can run configure with --disable-werror to bypass this check."
1428dc38a78SPeter Maydell}
1438dc38a78SPeter Maydell
1449c83ffd8SPeter Maydelldo_cc() {
1459c83ffd8SPeter Maydell    do_compiler "$cc" "$@"
1469c83ffd8SPeter Maydell}
1479c83ffd8SPeter Maydell
1489c83ffd8SPeter Maydelldo_cxx() {
1499c83ffd8SPeter Maydell    do_compiler "$cxx" "$@"
1509c83ffd8SPeter Maydell}
1519c83ffd8SPeter Maydell
15200849b92SRichard Henderson# Append $2 to the variable named $1, with space separation
15300849b92SRichard Hendersonadd_to() {
15400849b92SRichard Henderson    eval $1=\${$1:+\"\$$1 \"}\$2
15500849b92SRichard Henderson}
15600849b92SRichard Henderson
1579c83ffd8SPeter Maydellupdate_cxxflags() {
1589c83ffd8SPeter Maydell    # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
1599c83ffd8SPeter Maydell    # options which some versions of GCC's C++ compiler complain about
1609c83ffd8SPeter Maydell    # because they only make sense for C programs.
16153422040SPaolo Bonzini    QEMU_CXXFLAGS="$QEMU_CXXFLAGS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS"
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=""
2430c58ac1cSmalcaudio_drv_list=""
244b64ec4e4SFam Zhengblock_drv_rw_whitelist=""
245b64ec4e4SFam Zhengblock_drv_ro_whitelist=""
246e49d021eSPeter Maydellhost_cc="cc"
247d5631638Smalcaudio_win_int=""
248957f1f99SMichael Rothlibs_qga=""
2495bc62e01SGerd Hoffmanndebug_info="yes"
250cdad781dSDaniele Buonolto="false"
25163678e17SSteven Noonanstack_protector=""
2521e4f6065SDaniele Buonosafe_stack=""
253afc3a8f9SAlex Bennéeuse_containers="yes"
254f2385398SAlex Bennéegdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
255ac0df51dSaliguori
25692712822SDaniel P. Berrangeif test -e "$source_path/.git"
25792712822SDaniel P. Berrangethen
2587d7dbf9dSDan Streetman    git_submodules_action="update"
25992712822SDaniel P. 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"
302422a5fd0SJoelle van Dynecoreaudio="auto"
303cece116cSMisono Tomohirovirtiofsd="auto"
30469202b40SPaolo Bonzinivirtfs="auto"
3055c53015aSPaolo Bonzinilibudev="auto"
3066ec0e15dSPaolo Bonzinimpath="auto"
307a0b93237SPaolo Bonzinivnc="enabled"
308deb62371SPaolo Bonzinisparse="auto"
309c87ea116SAlex Bennéevde="$default_feature"
310a0b93237SPaolo Bonzinivnc_sasl="auto"
311a0b93237SPaolo Bonzinivnc_jpeg="auto"
312a0b93237SPaolo Bonzinivnc_png="auto"
3134113f4cfSLaurent Vivierxkbcommon="auto"
314c87ea116SAlex Bennéexen="$default_feature"
315c87ea116SAlex Bennéexen_ctrl_version="$default_feature"
3161badb709SPaolo Bonzinixen_pci_passthrough="auto"
317c87ea116SAlex Bennéelinux_aio="$default_feature"
31853c22b68SPaolo Bonzinilinux_io_uring="auto"
319727c8bb8SPaolo Bonzinicap_ng="auto"
320f7f2d651SPaolo Bonziniattr="auto"
321c87ea116SAlex Bennéexfs="$default_feature"
3221badb709SPaolo Bonzinitcg="enabled"
323c87ea116SAlex Bennéemembarrier="$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"
33146627f41SAndrew Melnychenkobpf="auto"
3323bd40ec7SPaolo Bonzinikvm="auto"
3333bd40ec7SPaolo Bonzinihax="auto"
3343bd40ec7SPaolo Bonzinihvf="auto"
3353bd40ec7SPaolo Bonziniwhpx="auto"
33674a414a1SReinoud Zandijknvmm="auto"
337c87ea116SAlex Bennéerdma="$default_feature"
338c87ea116SAlex Bennéepvrdma="$default_feature"
339377529c0SPaolo Bonzinigprof="no"
340377529c0SPaolo Bonzinidebug_tcg="no"
341377529c0SPaolo Bonzinidebug="no"
342247724cbSMarc-André Lureausanitizers="no"
3430aebab04SLingfeng Yangtsan="no"
344c87ea116SAlex Bennéefortify_source="$default_feature"
345377529c0SPaolo Bonzinistrip_opt="yes"
34623a77b2dSPaolo Bonzinitcg_interpreter="false"
347377529c0SPaolo Bonzinibigendian="no"
348377529c0SPaolo Bonzinimingw32="no"
3491d728c39SBlue Swirlgcov="no"
350c7328271SMiroslav RezaninaEXESUF=""
351484e2cc7SPaolo BonziniHOST_DSOSUF=".so"
35217969268SFam Zhengmodules="no"
353bd83c861SChristian Ehrhardtmodule_upgrades="no"
354377529c0SPaolo Bonziniprefix="/usr/local"
35510ff82d1SMarc-André Lureauqemu_suffix="qemu"
3564d34a86bSPaolo Bonzinislirp="auto"
357377529c0SPaolo Bonzinioss_lib=""
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"
43240e8c6f4SAlex Bennéeplugins="no"
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"
7043cec7cc2SKővágó, Zoltán  audio_possible_drivers="dsound sdl"
705307119e7SGerd Hoffmann  if check_include dsound.h; then
7063cec7cc2SKővágó, Zoltán    audio_drv_list="dsound"
707307119e7SGerd Hoffmann  else
708307119e7SGerd Hoffmann    audio_drv_list=""
709307119e7SGerd Hoffmann  fi
710898be3e0SPeter Maydell  supported_os="yes"
711fb648e9cSDaniel P. Berrangé  pie="no"
71267b915a5Sbellard;;
7135c40d2bdSthsGNU/kFreeBSD)
714a167ba50SAurelien Jarno  bsd="yes"
7156a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
7160bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
7175c40d2bdSths;;
7187d3505c5SbellardFreeBSD)
7197d3505c5Sbellard  bsd="yes"
7200db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7216a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
7220bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
723f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
72458952137SVincenzo Maffione  netmap=""  # enable netmap autodetect
7257d3505c5Sbellard;;
726c5e97233Sblueswir1DragonFly)
727c5e97233Sblueswir1  bsd="yes"
7280db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7296a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
7300bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
731c5e97233Sblueswir1;;
7327d3505c5SbellardNetBSD)
7337d3505c5Sbellard  bsd="yes"
7340db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7356a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
7360bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl"
7378ef92a88Sblueswir1  oss_lib="-lossaudio"
7387d3505c5Sbellard;;
7397d3505c5SbellardOpenBSD)
7407d3505c5Sbellard  bsd="yes"
7410db4a067SPaolo Bonzini  make="${MAKE-gmake}"
742f92c7168SGerd Hoffmann  audio_drv_list="try-sdl"
7430bac1111SKővágó, Zoltán  audio_possible_drivers="sdl"
7447d3505c5Sbellard;;
74583fb7adfSbellardDarwin)
74683fb7adfSbellard  bsd="yes"
74783fb7adfSbellard  darwin="yes"
748422a5fd0SJoelle van Dyne  audio_drv_list="try-coreaudio try-sdl"
74914382605SKővágó, Zoltán  audio_possible_drivers="coreaudio sdl"
750a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
751a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
752a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
75383fb7adfSbellard;;
754ec530c81SbellardSunOS)
755ec530c81Sbellard  solaris="yes"
7560db4a067SPaolo Bonzini  make="${MAKE-gmake}"
757e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
7586b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
7596a485418SGerd Hoffmann    audio_drv_list="oss try-sdl"
7606b4d2ba1Sths  fi
761c2de5c91Smalc  audio_possible_drivers="oss sdl"
762d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
763d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
764d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
765d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
766ec530c81Sbellard;;
767179cf400SAndreas FärberHaiku)
768179cf400SAndreas Färber  haiku="yes"
769cde99253SThomas Huth  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE $QEMU_CFLAGS"
770179cf400SAndreas Färber;;
771898be3e0SPeter MaydellLinux)
7727183834aSGerd Hoffmann  audio_drv_list="try-pa oss"
7730bac1111SKővágó, Zoltán  audio_possible_drivers="oss alsa sdl pa"
7745327cf48Sbellard  linux="yes"
775831b7825Sths  linux_user="yes"
776c87ea116SAlex Bennée  vhost_user=${default_feature:-yes}
777898be3e0SPeter Maydell;;
7787d13299dSbellardesac
7797d13299dSbellard
7807d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
781b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
78284778508Sblueswir1    bsd_user="yes"
7837d3505c5Sbellard  fi
78408de3949SAndreas Färberfi
7857d3505c5Sbellard
7860db4a067SPaolo Bonzini: ${make=${MAKE-make}}
787b6daf4d3SPaolo Bonzini
788faf44142SDaniel P. Berrangé# We prefer python 3.x. A bare 'python' is traditionally
789faf44142SDaniel P. Berrangé# python 2.x, but some distros have it as python 3.x, so
790ddf90699SEduardo Habkost# we check that too
791faf44142SDaniel P. Berrangépython=
7920a01d76fSMarc-André Lureauexplicit_python=no
793ddf90699SEduardo Habkostfor binary in "${PYTHON-python3}" python
794faf44142SDaniel P. Berrangédo
795faf44142SDaniel P. Berrangé    if has "$binary"
796faf44142SDaniel P. Berrangé    then
79795c5f2deSPaolo Bonzini        python=$(command -v "$binary")
798faf44142SDaniel P. Berrangé        break
799faf44142SDaniel P. Berrangé    fi
800faf44142SDaniel P. Berrangédone
801903458c8SMarkus Armbruster
802903458c8SMarkus Armbruster
80339d87c8cSAlex Bennée# Check for ancillary tools used in testing
80439d87c8cSAlex Bennéegenisoimage=
8053df437c7SAlex Bennéefor binary in genisoimage mkisofs
80639d87c8cSAlex Bennéedo
80739d87c8cSAlex Bennée    if has $binary
80839d87c8cSAlex Bennée    then
80939d87c8cSAlex Bennée        genisoimage=$(command -v "$binary")
81039d87c8cSAlex Bennée        break
81139d87c8cSAlex Bennée    fi
81239d87c8cSAlex Bennéedone
81339d87c8cSAlex Bennée
8143c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
8153c4a4d0dSPeter Maydellif has clang; then
8163c4a4d0dSPeter Maydell  objcc=clang
8173c4a4d0dSPeter Maydellelse
8183c4a4d0dSPeter Maydell  objcc="$cc"
8193c4a4d0dSPeter Maydellfi
8203c4a4d0dSPeter Maydell
8213457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
8223457a3f8SJuan Quintela  EXESUF=".exe"
823484e2cc7SPaolo Bonzini  HOST_DSOSUF=".dll"
82478e9d4adSStefan Weil  # MinGW needs -mthreads for TLS and macro _MT.
8255770e8afSPaolo Bonzini  CONFIGURE_CFLAGS="-mthreads $CONFIGURE_CFLAGS"
82693b25869SJohn Snow  write_c_skeleton;
827d17f305aSPaolo Bonzini  prefix="/qemu"
82877433a5fSMarc-André Lureau  qemu_suffix=""
829105fad6bSBishara AbuHattoum  libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
8303457a3f8SJuan Quintelafi
8313457a3f8SJuan Quintela
832487fefdbSAnthony Liguoriwerror=""
83385aa5189Sbellard
8347d13299dSbellardfor opt do
83589138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
8367d13299dSbellard  case "$opt" in
8372efc3265Sbellard  --help|-h) show_help=yes
8382efc3265Sbellard  ;;
83999123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
84099123e13SMike Frysinger  ;;
841b1a550a0Spbrook  --prefix=*) prefix="$optarg"
8427d13299dSbellard  ;;
843b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
84432ce6337Sbellard  ;;
845ac0df51dSaliguori  --cross-prefix=*)
8467d13299dSbellard  ;;
847ac0df51dSaliguori  --cc=*)
8487d13299dSbellard  ;;
849b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
85083469015Sbellard  ;;
85183f73fceSTomoki Sekiyama  --cxx=*)
85283f73fceSTomoki Sekiyama  ;;
853e007dbecSMichael S. Tsirkin  --iasl=*) iasl="$optarg"
854e007dbecSMichael S. Tsirkin  ;;
8553c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
8563c4a4d0dSPeter Maydell  ;;
857b1a550a0Spbrook  --make=*) make="$optarg"
8587d13299dSbellard  ;;
859b6daf4d3SPaolo Bonzini  --install=*)
8606a882643Spbrook  ;;
8610a01d76fSMarc-André Lureau  --python=*) python="$optarg" ; explicit_python=yes
862c886edfbSBlue Swirl  ;;
8632eb054c2SPeter Maydell  --sphinx-build=*) sphinx_build="$optarg"
8642eb054c2SPeter Maydell  ;;
865a5665051SPaolo Bonzini  --skip-meson) skip_meson=yes
866a5665051SPaolo Bonzini  ;;
867a5665051SPaolo Bonzini  --meson=*) meson="$optarg"
868a5665051SPaolo Bonzini  ;;
86948328880SPaolo Bonzini  --ninja=*) ninja="$optarg"
87048328880SPaolo Bonzini  ;;
871e2d8830eSBrad  --smbd=*) smbd="$optarg"
872e2d8830eSBrad  ;;
873e2a2ed06SJuan Quintela  --extra-cflags=*)
8747d13299dSbellard  ;;
87511cde1c8SBruno Dominguez  --extra-cxxflags=*)
87611cde1c8SBruno Dominguez  ;;
877e2a2ed06SJuan Quintela  --extra-ldflags=*)
8787d13299dSbellard  ;;
8795bc62e01SGerd Hoffmann  --enable-debug-info)
8805bc62e01SGerd Hoffmann  ;;
8815bc62e01SGerd Hoffmann  --disable-debug-info)
8825bc62e01SGerd Hoffmann  ;;
883d75402b5SAlex Bennée  --cross-cc-*)
884d75402b5SAlex Bennée  ;;
88517969268SFam Zheng  --enable-modules)
88617969268SFam Zheng      modules="yes"
88717969268SFam Zheng  ;;
8883aa88b31SStefan Hajnoczi  --disable-modules)
8893aa88b31SStefan Hajnoczi      modules="no"
8903aa88b31SStefan Hajnoczi  ;;
891bd83c861SChristian Ehrhardt  --disable-module-upgrades) module_upgrades="no"
892bd83c861SChristian Ehrhardt  ;;
893bd83c861SChristian Ehrhardt  --enable-module-upgrades) module_upgrades="yes"
894bd83c861SChristian Ehrhardt  ;;
8952ff6b91eSJuan Quintela  --cpu=*)
8967d13299dSbellard  ;;
897b1a550a0Spbrook  --target-list=*) target_list="$optarg"
898447e133fSAlex Bennée                   if test "$target_list_exclude"; then
899447e133fSAlex Bennée                       error_exit "Can't mix --target-list with --target-list-exclude"
900447e133fSAlex Bennée                   fi
901447e133fSAlex Bennée  ;;
902447e133fSAlex Bennée  --target-list-exclude=*) target_list_exclude="$optarg"
903447e133fSAlex Bennée                   if test "$target_list"; then
904447e133fSAlex Bennée                       error_exit "Can't mix --target-list-exclude with --target-list"
905447e133fSAlex Bennée                   fi
906de83cd02Sbellard  ;;
9075b808275SLluís Vilanova  --enable-trace-backends=*) trace_backends="$optarg"
9085b808275SLluís Vilanova  ;;
9095b808275SLluís Vilanova  # XXX: backwards compatibility
9105b808275SLluís Vilanova  --enable-trace-backend=*) trace_backends="$optarg"
91194a420b1SStefan Hajnoczi  ;;
91274242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
9139410b56cSPrerna Saxena  ;;
9147bc3ca7fSPaolo Bonzini  --with-default-devices) default_devices="true"
915f3494749SPaolo Bonzini  ;;
9167bc3ca7fSPaolo Bonzini  --without-default-devices) default_devices="false"
917f3494749SPaolo Bonzini  ;;
918*d1d5e9eeSAlex Bennée  --with-devices-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --with-devices-FOO option"
919*d1d5e9eeSAlex Bennée  ;;
920*d1d5e9eeSAlex Bennée  --with-devices-*) device_arch=${opt#--with-devices-};
921*d1d5e9eeSAlex Bennée                    device_arch=${device_arch%%=*}
922*d1d5e9eeSAlex Bennée                    cf=$source_path/configs/devices/$device_arch-softmmu/$optarg.mak
923*d1d5e9eeSAlex Bennée                    if test -f "$cf"; then
924*d1d5e9eeSAlex Bennée                        device_archs="$device_archs $device_arch"
925*d1d5e9eeSAlex Bennée                        eval "devices_${device_arch}=\$optarg"
926*d1d5e9eeSAlex Bennée                    else
927*d1d5e9eeSAlex Bennée                        error_exit "File $cf does not exist"
928*d1d5e9eeSAlex Bennée                    fi
929*d1d5e9eeSAlex Bennée  ;;
930c87ea116SAlex Bennée  --without-default-features) # processed above
931c87ea116SAlex Bennée  ;;
9327d13299dSbellard  --enable-gprof) gprof="yes"
9337d13299dSbellard  ;;
9341d728c39SBlue Swirl  --enable-gcov) gcov="yes"
9351d728c39SBlue Swirl  ;;
93679427693SLoïc Minier  --static)
93779427693SLoïc Minier    static="yes"
93817884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
93943ce4dfeSbellard  ;;
9400b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
9410b24e75fSPaolo Bonzini  ;;
9420b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
9430b24e75fSPaolo Bonzini  ;;
9443aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
9453aa5d2beSAlon Levy  ;;
9468bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
9478bf188aaSMichael Tokarev  ;;
9480f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
9490f94d6daSAlon Levy  ;;
950528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
9510b24e75fSPaolo Bonzini  ;;
95277433a5fSMarc-André Lureau  --with-suffix=*) qemu_suffix="$optarg"
953023d3d67SEduardo Habkost  ;;
954c6502638SBruce Rogers  --docdir=*) docdir="$optarg"
9550b24e75fSPaolo Bonzini  ;;
956fe0038beSPaolo Bonzini  --localedir=*) localedir="$optarg"
957fe0038beSPaolo Bonzini  ;;
958ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
95907381cc1SAnthony Liguori  ;;
960785c23aeSLuiz Capitulino  --localstatedir=*) local_statedir="$optarg"
961785c23aeSLuiz Capitulino  ;;
9623d5eecabSGerd Hoffmann  --firmwarepath=*) firmwarepath="$optarg"
9633d5eecabSGerd Hoffmann  ;;
964181ce1d0SOlaf Hering  --host=*|--build=*|\
965181ce1d0SOlaf Hering  --disable-dependency-tracking|\
966785c23aeSLuiz Capitulino  --sbindir=*|--sharedstatedir=*|\
967fe0038beSPaolo Bonzini  --oldincludedir=*|--datarootdir=*|--infodir=*|\
968023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
969023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
970023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
971023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
972023ddd74SMax Filippov    # lots of directory switches by default.
973023ddd74SMax Filippov  ;;
97435be72baSPaolo Bonzini  --disable-sdl) sdl="disabled"
97597a847bcSbellard  ;;
97635be72baSPaolo Bonzini  --enable-sdl) sdl="enabled"
977c4198157SJuan Quintela  ;;
97835be72baSPaolo Bonzini  --disable-sdl-image) sdl_image="disabled"
979a442fe2fSDaniel P. Berrangé  ;;
98035be72baSPaolo Bonzini  --enable-sdl-image) sdl_image="enabled"
981a442fe2fSDaniel P. Berrangé  ;;
9823556c233SPaolo Bonzini  --disable-qom-cast-debug) qom_cast_debug="no"
9833556c233SPaolo Bonzini  ;;
9843556c233SPaolo Bonzini  --enable-qom-cast-debug) qom_cast_debug="yes"
9853556c233SPaolo Bonzini  ;;
98669202b40SPaolo Bonzini  --disable-virtfs) virtfs="disabled"
987983eef5aSMeador Inge  ;;
98869202b40SPaolo Bonzini  --enable-virtfs) virtfs="enabled"
989983eef5aSMeador Inge  ;;
9905c53015aSPaolo Bonzini  --disable-libudev) libudev="disabled"
9915c53015aSPaolo Bonzini  ;;
9925c53015aSPaolo Bonzini  --enable-libudev) libudev="enabled"
9935c53015aSPaolo Bonzini  ;;
994cece116cSMisono Tomohiro  --disable-virtiofsd) virtiofsd="disabled"
995cece116cSMisono Tomohiro  ;;
996cece116cSMisono Tomohiro  --enable-virtiofsd) virtiofsd="enabled"
997cece116cSMisono Tomohiro  ;;
9986ec0e15dSPaolo Bonzini  --disable-mpath) mpath="disabled"
999fe8fc5aeSPaolo Bonzini  ;;
10006ec0e15dSPaolo Bonzini  --enable-mpath) mpath="enabled"
1001fe8fc5aeSPaolo Bonzini  ;;
1002a0b93237SPaolo Bonzini  --disable-vnc) vnc="disabled"
1003821601eaSJes Sorensen  ;;
1004a0b93237SPaolo Bonzini  --enable-vnc) vnc="enabled"
1005821601eaSJes Sorensen  ;;
10060e8e77d4SAlex Bennée  --disable-gettext) gettext="disabled"
1007e8f3bd71SMarc-André Lureau  ;;
10080e8e77d4SAlex Bennée  --enable-gettext) gettext="enabled"
1009e8f3bd71SMarc-André Lureau  ;;
10102f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
10112f6a1ab0Sblueswir1  ;;
10120c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
10130c58ac1cSmalc  ;;
101489138857SStefan Weil  --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1015b64ec4e4SFam Zheng  ;;
101689138857SStefan Weil  --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1017eb852011SMarkus Armbruster  ;;
1018f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
1019f8393946Saurel32  ;;
1020f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
1021f8393946Saurel32  ;;
1022f3d08ee6SPaul Brook  --enable-debug)
1023f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
1024f3d08ee6SPaul Brook      debug_tcg="yes"
10251fcc6d42SPeter Xu      debug_mutex="yes"
1026f3d08ee6SPaul Brook      debug="yes"
1027f3d08ee6SPaul Brook      strip_opt="no"
1028b553a042SJohn Snow      fortify_source="no"
1029f3d08ee6SPaul Brook  ;;
1030247724cbSMarc-André Lureau  --enable-sanitizers) sanitizers="yes"
1031247724cbSMarc-André Lureau  ;;
1032247724cbSMarc-André Lureau  --disable-sanitizers) sanitizers="no"
1033247724cbSMarc-André Lureau  ;;
10340aebab04SLingfeng Yang  --enable-tsan) tsan="yes"
10350aebab04SLingfeng Yang  ;;
10360aebab04SLingfeng Yang  --disable-tsan) tsan="no"
10370aebab04SLingfeng Yang  ;;
1038deb62371SPaolo Bonzini  --enable-sparse) sparse="enabled"
103903b4fe7dSaliguori  ;;
1040deb62371SPaolo Bonzini  --disable-sparse) sparse="disabled"
104103b4fe7dSaliguori  ;;
10421625af87Saliguori  --disable-strip) strip_opt="no"
10431625af87Saliguori  ;;
1044a0b93237SPaolo Bonzini  --disable-vnc-sasl) vnc_sasl="disabled"
10452f9606b3Saliguori  ;;
1046a0b93237SPaolo Bonzini  --enable-vnc-sasl) vnc_sasl="enabled"
1047ea784e3bSJuan Quintela  ;;
1048a0b93237SPaolo Bonzini  --disable-vnc-jpeg) vnc_jpeg="disabled"
10492f6f5c7aSCorentin Chary  ;;
1050a0b93237SPaolo Bonzini  --enable-vnc-jpeg) vnc_jpeg="enabled"
10512f6f5c7aSCorentin Chary  ;;
1052a0b93237SPaolo Bonzini  --disable-vnc-png) vnc_png="disabled"
1053efe556adSCorentin Chary  ;;
1054a0b93237SPaolo Bonzini  --enable-vnc-png) vnc_png="enabled"
1055efe556adSCorentin Chary  ;;
10564d34a86bSPaolo Bonzini  --disable-slirp) slirp="disabled"
1057c20709aaSbellard  ;;
1058fd6fc214SPaolo Bonzini  --enable-slirp) slirp="enabled"
1059fd6fc214SPaolo Bonzini  ;;
10604d34a86bSPaolo Bonzini  --enable-slirp=git) slirp="internal"
10617c57bdd8SMarc-André Lureau  ;;
1062675b9b53SMarc-André Lureau  --enable-slirp=system) slirp="system"
1063675b9b53SMarc-André Lureau  ;;
1064e0e6c8c0Saliguori  --disable-vde) vde="no"
10658a16d273Sths  ;;
1066dfb278bdSJuan Quintela  --enable-vde) vde="yes"
1067dfb278bdSJuan Quintela  ;;
106858952137SVincenzo Maffione  --disable-netmap) netmap="no"
106958952137SVincenzo Maffione  ;;
107058952137SVincenzo Maffione  --enable-netmap) netmap="yes"
107158952137SVincenzo Maffione  ;;
10721badb709SPaolo Bonzini  --disable-xen) xen="disabled"
1073e37630caSaliguori  ;;
10741badb709SPaolo Bonzini  --enable-xen) xen="enabled"
1075fc321b4bSJuan Quintela  ;;
10761badb709SPaolo Bonzini  --disable-xen-pci-passthrough) xen_pci_passthrough="disabled"
1077eb6fda0fSAnthony PERARD  ;;
10781badb709SPaolo Bonzini  --enable-xen-pci-passthrough) xen_pci_passthrough="enabled"
1079eb6fda0fSAnthony PERARD  ;;
10808c6d4ff4SPaolo Bonzini  --disable-brlapi) brlapi="disabled"
10812e4d9fb1Saurel32  ;;
10828c6d4ff4SPaolo Bonzini  --enable-brlapi) brlapi="enabled"
10834ffcedb6SJuan Quintela  ;;
10841badb709SPaolo Bonzini  --disable-kvm) kvm="disabled"
10857ba1e619Saliguori  ;;
10861badb709SPaolo Bonzini  --enable-kvm) kvm="enabled"
1087b31a0277SJuan Quintela  ;;
10881badb709SPaolo Bonzini  --disable-hax) hax="disabled"
1089180fb750Szhanghailiang  ;;
10901badb709SPaolo Bonzini  --enable-hax) hax="enabled"
1091180fb750Szhanghailiang  ;;
10921badb709SPaolo Bonzini  --disable-hvf) hvf="disabled"
1093c97d6d2cSSergio Andres Gomez Del Real  ;;
10941badb709SPaolo Bonzini  --enable-hvf) hvf="enabled"
1095c97d6d2cSSergio Andres Gomez Del Real  ;;
109674a414a1SReinoud Zandijk  --disable-nvmm) nvmm="disabled"
109774a414a1SReinoud Zandijk  ;;
109874a414a1SReinoud Zandijk  --enable-nvmm) nvmm="enabled"
109974a414a1SReinoud Zandijk  ;;
11001badb709SPaolo Bonzini  --disable-whpx) whpx="disabled"
1101d661d9a4SJustin Terry (VM)  ;;
11021badb709SPaolo Bonzini  --enable-whpx) whpx="enabled"
1103d661d9a4SJustin Terry (VM)  ;;
1104c6fbea47SRichard Henderson  --disable-tcg-interpreter) tcg_interpreter="false"
11059195b2c2SStefan Weil  ;;
1106c6fbea47SRichard Henderson  --enable-tcg-interpreter) tcg_interpreter="true"
11079195b2c2SStefan Weil  ;;
1108727c8bb8SPaolo Bonzini  --disable-cap-ng)  cap_ng="disabled"
110947e98658SCorey Bryant  ;;
1110727c8bb8SPaolo Bonzini  --enable-cap-ng) cap_ng="enabled"
111147e98658SCorey Bryant  ;;
11121badb709SPaolo Bonzini  --disable-tcg) tcg="disabled"
1113b3f6ea7eSPaolo Bonzini  ;;
11141badb709SPaolo Bonzini  --enable-tcg) tcg="enabled"
1115b3f6ea7eSPaolo Bonzini  ;;
1116aa087962SPaolo Bonzini  --disable-malloc-trim) malloc_trim="disabled"
11175a22ab71SYang Zhong  ;;
1118aa087962SPaolo Bonzini  --enable-malloc-trim) malloc_trim="enabled"
11195a22ab71SYang Zhong  ;;
1120cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
1121cd4ec0b4SGerd Hoffmann  ;;
112258d3f3ffSGerd Hoffmann  --enable-spice)
112358d3f3ffSGerd Hoffmann      spice_protocol="yes"
112458d3f3ffSGerd Hoffmann      spice="yes"
112558d3f3ffSGerd Hoffmann  ;;
112658d3f3ffSGerd Hoffmann  --disable-spice-protocol)
112758d3f3ffSGerd Hoffmann      spice_protocol="no"
112858d3f3ffSGerd Hoffmann      spice="no"
112958d3f3ffSGerd Hoffmann  ;;
113058d3f3ffSGerd Hoffmann  --enable-spice-protocol) spice_protocol="yes"
1131cd4ec0b4SGerd Hoffmann  ;;
11329db405a3SPaolo Bonzini  --disable-libiscsi) libiscsi="disabled"
1133c589b249SRonnie Sahlberg  ;;
11349db405a3SPaolo Bonzini  --enable-libiscsi) libiscsi="enabled"
1135c589b249SRonnie Sahlberg  ;;
113630045c05SPaolo Bonzini  --disable-libnfs) libnfs="disabled"
11376542aa9cSPeter Lieven  ;;
113830045c05SPaolo Bonzini  --enable-libnfs) libnfs="enabled"
11396542aa9cSPeter Lieven  ;;
114005c2a3e7Sbellard  --enable-profiler) profiler="yes"
114105c2a3e7Sbellard  ;;
1142b4e312e9SPaolo Bonzini  --disable-cocoa) cocoa="disabled"
114314821030SPavel Borzenkov  ;;
1144a23a6789SPaolo Bonzini  --enable-cocoa) cocoa="enabled"
11455b0753e0Sbellard  ;;
1146cad25d69Spbrook  --disable-system) softmmu="no"
11470a8e90f4Spbrook  ;;
1148cad25d69Spbrook  --enable-system) softmmu="yes"
11490a8e90f4Spbrook  ;;
11500953a80fSZachary Amsden  --disable-user)
11510953a80fSZachary Amsden      linux_user="no" ;
11520953a80fSZachary Amsden      bsd_user="no" ;
11530953a80fSZachary Amsden  ;;
11540953a80fSZachary Amsden  --enable-user) ;;
1155831b7825Sths  --disable-linux-user) linux_user="no"
11560a8e90f4Spbrook  ;;
1157831b7825Sths  --enable-linux-user) linux_user="yes"
1158831b7825Sths  ;;
115984778508Sblueswir1  --disable-bsd-user) bsd_user="no"
116084778508Sblueswir1  ;;
116184778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
116284778508Sblueswir1  ;;
116340d6444eSAvi Kivity  --enable-pie) pie="yes"
116434005a00SKirill A. Shutemov  ;;
116540d6444eSAvi Kivity  --disable-pie) pie="no"
116634005a00SKirill A. Shutemov  ;;
116785aa5189Sbellard  --enable-werror) werror="yes"
116885aa5189Sbellard  ;;
116985aa5189Sbellard  --disable-werror) werror="no"
117085aa5189Sbellard  ;;
1171cdad781dSDaniele Buono  --enable-lto) lto="true"
1172cdad781dSDaniele Buono  ;;
1173cdad781dSDaniele Buono  --disable-lto) lto="false"
1174cdad781dSDaniele Buono  ;;
117563678e17SSteven Noonan  --enable-stack-protector) stack_protector="yes"
117663678e17SSteven Noonan  ;;
117763678e17SSteven Noonan  --disable-stack-protector) stack_protector="no"
117863678e17SSteven Noonan  ;;
11791e4f6065SDaniele Buono  --enable-safe-stack) safe_stack="yes"
11801e4f6065SDaniele Buono  ;;
11811e4f6065SDaniele Buono  --disable-safe-stack) safe_stack="no"
11821e4f6065SDaniele Buono  ;;
11839e62ba48SDaniele Buono  --enable-cfi)
11849e62ba48SDaniele Buono      cfi="true";
11859e62ba48SDaniele Buono      lto="true";
11869e62ba48SDaniele Buono  ;;
11879e62ba48SDaniele Buono  --disable-cfi) cfi="false"
11889e62ba48SDaniele Buono  ;;
11899e62ba48SDaniele Buono  --enable-cfi-debug) cfi_debug="true"
11909e62ba48SDaniele Buono  ;;
11919e62ba48SDaniele Buono  --disable-cfi-debug) cfi_debug="false"
11929e62ba48SDaniele Buono  ;;
11935285e593SYonggang Luo  --disable-curses) curses="disabled"
11944d3b6f6eSbalrog  ;;
11955285e593SYonggang Luo  --enable-curses) curses="enabled"
1196c584a6d0SJuan Quintela  ;;
11975285e593SYonggang Luo  --disable-iconv) iconv="disabled"
1198e08bb301SSamuel Thibault  ;;
11995285e593SYonggang Luo  --enable-iconv) iconv="enabled"
1200e08bb301SSamuel Thibault  ;;
1201f9cd86feSPaolo Bonzini  --disable-curl) curl="disabled"
1202769ce76dSAlexander Graf  ;;
1203f9cd86feSPaolo Bonzini  --enable-curl) curl="enabled"
1204788c8196SJuan Quintela  ;;
1205fbb4121dSPaolo Bonzini  --disable-fdt) fdt="disabled"
12062df87df7SJuan Quintela  ;;
1207fbb4121dSPaolo Bonzini  --enable-fdt) fdt="enabled"
1208fbb4121dSPaolo Bonzini  ;;
1209fbb4121dSPaolo Bonzini  --enable-fdt=git) fdt="internal"
1210fbb4121dSPaolo Bonzini  ;;
1211fbb4121dSPaolo Bonzini  --enable-fdt=system) fdt="system"
12122df87df7SJuan Quintela  ;;
12135c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
12145c6c3a6cSChristoph Hellwig  ;;
12155c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
12165c6c3a6cSChristoph Hellwig  ;;
121753c22b68SPaolo Bonzini  --disable-linux-io-uring) linux_io_uring="disabled"
1218c10dd856SAarushi Mehta  ;;
121953c22b68SPaolo Bonzini  --enable-linux-io-uring) linux_io_uring="enabled"
1220c10dd856SAarushi Mehta  ;;
1221f7f2d651SPaolo Bonzini  --disable-attr) attr="disabled"
1222758e8e38SVenkateswararao Jujjuri (JV)  ;;
1223f7f2d651SPaolo Bonzini  --enable-attr) attr="enabled"
1224758e8e38SVenkateswararao Jujjuri (JV)  ;;
1225a40161cbSPaolo Bonzini  --disable-membarrier) membarrier="no"
1226a40161cbSPaolo Bonzini  ;;
1227a40161cbSPaolo Bonzini  --enable-membarrier) membarrier="yes"
1228a40161cbSPaolo Bonzini  ;;
122946627f41SAndrew Melnychenko  --disable-bpf) bpf="disabled"
123046627f41SAndrew Melnychenko  ;;
123146627f41SAndrew Melnychenko  --enable-bpf) bpf="enabled"
123246627f41SAndrew Melnychenko  ;;
1233c8d5450bSPaolo Bonzini  --disable-blobs) blobs="false"
123477755340Sths  ;;
12357e563bfbSThomas Huth  --with-pkgversion=*) pkgversion="$optarg"
12364a19f1ecSpbrook  ;;
1237519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
1238519175a2SAlex Barcelo  ;;
123970c60c08SStefan Hajnoczi  --disable-coroutine-pool) coroutine_pool="no"
124070c60c08SStefan Hajnoczi  ;;
124170c60c08SStefan Hajnoczi  --enable-coroutine-pool) coroutine_pool="yes"
124270c60c08SStefan Hajnoczi  ;;
12437d992e4dSPeter Lieven  --enable-debug-stack-usage) debug_stack_usage="yes"
12447d992e4dSPeter Lieven  ;;
1245f0d92b56SLongpeng(Mike)  --enable-crypto-afalg) crypto_afalg="yes"
1246f0d92b56SLongpeng(Mike)  ;;
1247f0d92b56SLongpeng(Mike)  --disable-crypto-afalg) crypto_afalg="no"
1248f0d92b56SLongpeng(Mike)  ;;
1249e3667660SYonggang Luo  --disable-docs) docs="disabled"
125070ec5dc0SAnthony Liguori  ;;
1251e3667660SYonggang Luo  --enable-docs) docs="enabled"
125283a3ab8bSJuan Quintela  ;;
1253d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
1254d5970055SMichael S. Tsirkin  ;;
1255d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
1256d5970055SMichael S. Tsirkin  ;;
1257042cea27SGonglei  --disable-vhost-crypto) vhost_crypto="no"
1258042cea27SGonglei  ;;
1259299e6f19SPaolo Bonzini  --enable-vhost-crypto) vhost_crypto="yes"
1260042cea27SGonglei  ;;
12615e9be92dSNicholas Bellinger  --disable-vhost-scsi) vhost_scsi="no"
12625e9be92dSNicholas Bellinger  ;;
12635e9be92dSNicholas Bellinger  --enable-vhost-scsi) vhost_scsi="yes"
12645e9be92dSNicholas Bellinger  ;;
1265fc0b9b0eSStefan Hajnoczi  --disable-vhost-vsock) vhost_vsock="no"
1266fc0b9b0eSStefan Hajnoczi  ;;
1267fc0b9b0eSStefan Hajnoczi  --enable-vhost-vsock) vhost_vsock="yes"
1268fc0b9b0eSStefan Hajnoczi  ;;
1269e5e856c1SStefan Hajnoczi  --disable-vhost-user-blk-server) vhost_user_blk_server="disabled"
1270bc15e44cSStefan Hajnoczi  ;;
1271e5e856c1SStefan Hajnoczi  --enable-vhost-user-blk-server) vhost_user_blk_server="enabled"
1272bc15e44cSStefan Hajnoczi  ;;
127398fc1adaSDr. David Alan Gilbert  --disable-vhost-user-fs) vhost_user_fs="no"
127498fc1adaSDr. David Alan Gilbert  ;;
127598fc1adaSDr. David Alan Gilbert  --enable-vhost-user-fs) vhost_user_fs="yes"
127698fc1adaSDr. David Alan Gilbert  ;;
1277da076ffeSGerd Hoffmann  --disable-opengl) opengl="no"
127820ff075bSMichael Walle  ;;
1279da076ffeSGerd Hoffmann  --enable-opengl) opengl="yes"
128020ff075bSMichael Walle  ;;
1281fabd1e93SPaolo Bonzini  --disable-rbd) rbd="disabled"
1282f27aaf4bSChristian Brunner  ;;
1283fabd1e93SPaolo Bonzini  --enable-rbd) rbd="enabled"
1284f27aaf4bSChristian Brunner  ;;
12858c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
12868c84cf11SSergei Trofimovich  ;;
12878c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
12888c84cf11SSergei Trofimovich  ;;
12895f364c57SPaolo Bonzini  --disable-smartcard) smartcard="disabled"
1290111a38b0SRobert Relyea  ;;
12915f364c57SPaolo Bonzini  --enable-smartcard) smartcard="enabled"
1292111a38b0SRobert Relyea  ;;
12930a40bcb7SCésar Belley  --disable-u2f) u2f="disabled"
12940a40bcb7SCésar Belley  ;;
12950a40bcb7SCésar Belley  --enable-u2f) u2f="enabled"
12960a40bcb7SCésar Belley  ;;
129790540f32SPaolo Bonzini  --disable-libusb) libusb="disabled"
12982b2325ffSGerd Hoffmann  ;;
129990540f32SPaolo Bonzini  --enable-libusb) libusb="enabled"
13002b2325ffSGerd Hoffmann  ;;
130118f31e60SPaolo Bonzini  --disable-usb-redir) usb_redir="disabled"
130269354a83SHans de Goede  ;;
130318f31e60SPaolo Bonzini  --enable-usb-redir) usb_redir="enabled"
130469354a83SHans de Goede  ;;
13051ffb3bbbSPaolo Bonzini  --disable-zlib-test)
13061ece9905SAlon Levy  ;;
13070c32a0aeSPaolo Bonzini  --disable-lzo) lzo="disabled"
1308b25c9dffSStefan Weil  ;;
13090c32a0aeSPaolo Bonzini  --enable-lzo) lzo="enabled"
1310607dacd0Sqiaonuohan  ;;
1311241611eaSPaolo Bonzini  --disable-snappy) snappy="disabled"
1312b25c9dffSStefan Weil  ;;
1313241611eaSPaolo Bonzini  --enable-snappy) snappy="enabled"
1314607dacd0Sqiaonuohan  ;;
131529ba6116SPaolo Bonzini  --disable-bzip2) bzip2="disabled"
13166b383c08SPeter Wu  ;;
131729ba6116SPaolo Bonzini  --enable-bzip2) bzip2="enabled"
13186b383c08SPeter Wu  ;;
1319ecea3696SPaolo Bonzini  --enable-lzfse) lzfse="enabled"
132083bc1f97SJulio Faracco  ;;
1321ecea3696SPaolo Bonzini  --disable-lzfse) lzfse="disabled"
132283bc1f97SJulio Faracco  ;;
1323b1def33dSPaolo Bonzini  --disable-zstd) zstd="disabled"
13243a678481SJuan Quintela  ;;
1325b1def33dSPaolo Bonzini  --enable-zstd) zstd="enabled"
13263a678481SJuan Quintela  ;;
1327d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
1328d138cee9SMichael Roth  ;;
1329d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
1330d138cee9SMichael Roth  ;;
1331b846ab7cSPaolo Bonzini  --enable-guest-agent-msi) guest_agent_msi="enabled"
13329dacf32dSYossi Hindin  ;;
1333b846ab7cSPaolo Bonzini  --disable-guest-agent-msi) guest_agent_msi="disabled"
13349dacf32dSYossi Hindin  ;;
1335d9840e25STomoki Sekiyama  --with-vss-sdk) vss_win32_sdk=""
1336d9840e25STomoki Sekiyama  ;;
1337d9840e25STomoki Sekiyama  --with-vss-sdk=*) vss_win32_sdk="$optarg"
1338d9840e25STomoki Sekiyama  ;;
1339d9840e25STomoki Sekiyama  --without-vss-sdk) vss_win32_sdk="no"
1340d9840e25STomoki Sekiyama  ;;
1341d9840e25STomoki Sekiyama  --with-win-sdk) win_sdk=""
1342d9840e25STomoki Sekiyama  ;;
1343d9840e25STomoki Sekiyama  --with-win-sdk=*) win_sdk="$optarg"
1344d9840e25STomoki Sekiyama  ;;
1345d9840e25STomoki Sekiyama  --without-win-sdk) win_sdk="no"
1346d9840e25STomoki Sekiyama  ;;
13474b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
13484b1c11fdSDaniel P. Berrange  ;;
13494b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
13504b1c11fdSDaniel P. Berrange  ;;
135190835c2bSPaolo Bonzini  --enable-seccomp) seccomp="enabled"
1352f794573eSEduardo Otubo  ;;
135390835c2bSPaolo Bonzini  --disable-seccomp) seccomp="disabled"
1354f794573eSEduardo Otubo  ;;
135508821ca2SPaolo Bonzini  --disable-glusterfs) glusterfs="disabled"
1356eb100396SBharata B Rao  ;;
135786583a07SLiam Merwick  --disable-avx2) avx2_opt="no"
135886583a07SLiam Merwick  ;;
135986583a07SLiam Merwick  --enable-avx2) avx2_opt="yes"
136086583a07SLiam Merwick  ;;
13616b8cd447SRobert Hoo  --disable-avx512f) avx512f_opt="no"
13626b8cd447SRobert Hoo  ;;
13636b8cd447SRobert Hoo  --enable-avx512f) avx512f_opt="yes"
13646b8cd447SRobert Hoo  ;;
13656b8cd447SRobert Hoo
136608821ca2SPaolo Bonzini  --enable-glusterfs) glusterfs="enabled"
1367eb100396SBharata B Rao  ;;
136852b53c04SFam Zheng  --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
136952b53c04SFam Zheng      echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1370583f6e7bSStefan Hajnoczi  ;;
1371cb6414dfSFam Zheng  --enable-vhdx|--disable-vhdx)
1372cb6414dfSFam Zheng      echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1373cb6414dfSFam Zheng  ;;
1374315d3184SFam Zheng  --enable-uuid|--disable-uuid)
1375315d3184SFam Zheng      echo "$0: $opt is obsolete, UUID support is always built" >&2
1376315d3184SFam Zheng  ;;
13771b695471SPaolo Bonzini  --disable-gtk) gtk="disabled"
1378a4ccabcfSAnthony Liguori  ;;
13791b695471SPaolo Bonzini  --enable-gtk) gtk="enabled"
1380a4ccabcfSAnthony Liguori  ;;
1381a1c5e949SDaniel P. Berrange  --tls-priority=*) tls_priority="$optarg"
1382a1c5e949SDaniel P. Berrange  ;;
138357612511SPaolo Bonzini  --disable-gnutls) gnutls="disabled"
1384ddbb0d09SDaniel P. Berrange  ;;
138557612511SPaolo Bonzini  --enable-gnutls) gnutls="enabled"
1386ddbb0d09SDaniel P. Berrange  ;;
138757612511SPaolo Bonzini  --disable-nettle) nettle="disabled"
138891bfcdb0SDaniel P. Berrange  ;;
138957612511SPaolo Bonzini  --enable-nettle) nettle="enabled"
139091bfcdb0SDaniel P. Berrange  ;;
139157612511SPaolo Bonzini  --disable-gcrypt) gcrypt="disabled"
139291bfcdb0SDaniel P. Berrange  ;;
139357612511SPaolo Bonzini  --enable-gcrypt) gcrypt="enabled"
139491bfcdb0SDaniel P. Berrange  ;;
139505e391aeSPaolo Bonzini  --disable-auth-pam) auth_pam="disabled"
13968953caf3SDaniel P. Berrange  ;;
139705e391aeSPaolo Bonzini  --enable-auth-pam) auth_pam="enabled"
13988953caf3SDaniel P. Berrange  ;;
13992da776dbSMichael R. Hines  --enable-rdma) rdma="yes"
14002da776dbSMichael R. Hines  ;;
14012da776dbSMichael R. Hines  --disable-rdma) rdma="no"
14022da776dbSMichael R. Hines  ;;
140321ab34c9SMarcel Apfelbaum  --enable-pvrdma) pvrdma="yes"
140421ab34c9SMarcel Apfelbaum  ;;
140521ab34c9SMarcel Apfelbaum  --disable-pvrdma) pvrdma="no"
140621ab34c9SMarcel Apfelbaum  ;;
1407c23d7b4eSPaolo Bonzini  --disable-vte) vte="disabled"
1408bbbf9bfbSStefan Weil  ;;
1409c23d7b4eSPaolo Bonzini  --enable-vte) vte="enabled"
1410bbbf9bfbSStefan Weil  ;;
1411587d59d6SPaolo Bonzini  --disable-virglrenderer) virglrenderer="disabled"
14129d9e1521SGerd Hoffmann  ;;
1413587d59d6SPaolo Bonzini  --enable-virglrenderer) virglrenderer="enabled"
14149d9e1521SGerd Hoffmann  ;;
1415e91c793cSCole Robinson  --disable-tpm) tpm="no"
1416e91c793cSCole Robinson  ;;
1417ab214c29SStefan Berger  --enable-tpm) tpm="yes"
1418ab214c29SStefan Berger  ;;
1419b10d49d7SPino Toscano  --disable-libssh) libssh="no"
14200a12ec87SRichard W.M. Jones  ;;
1421b10d49d7SPino Toscano  --enable-libssh) libssh="yes"
14220a12ec87SRichard W.M. Jones  ;;
1423ed1701c6SDr. David Alan Gilbert  --disable-live-block-migration) live_block_migration="no"
1424ed1701c6SDr. David Alan Gilbert  ;;
1425ed1701c6SDr. David Alan Gilbert  --enable-live-block-migration) live_block_migration="yes"
1426ed1701c6SDr. David Alan Gilbert  ;;
1427a99d57bbSWanlong Gao  --disable-numa) numa="no"
1428a99d57bbSWanlong Gao  ;;
1429a99d57bbSWanlong Gao  --enable-numa) numa="yes"
1430a99d57bbSWanlong Gao  ;;
1431c5b36c25SPaolo Bonzini  --disable-libxml2) libxml2="disabled"
1432ed279a06SKlim Kireev  ;;
1433c5b36c25SPaolo Bonzini  --enable-libxml2) libxml2="enabled"
1434ed279a06SKlim Kireev  ;;
14352847b469SFam Zheng  --disable-tcmalloc) tcmalloc="no"
14362847b469SFam Zheng  ;;
14372847b469SFam Zheng  --enable-tcmalloc) tcmalloc="yes"
14382847b469SFam Zheng  ;;
14397b01cb97SAlexandre Derumier  --disable-jemalloc) jemalloc="no"
14407b01cb97SAlexandre Derumier  ;;
14417b01cb97SAlexandre Derumier  --enable-jemalloc) jemalloc="yes"
14427b01cb97SAlexandre Derumier  ;;
1443a6b1d4c0SChanglong Xie  --disable-replication) replication="no"
1444a6b1d4c0SChanglong Xie  ;;
1445a6b1d4c0SChanglong Xie  --enable-replication) replication="yes"
1446a6b1d4c0SChanglong Xie  ;;
14472f740136SJeff Cody  --disable-bochs) bochs="no"
14482f740136SJeff Cody  ;;
14492f740136SJeff Cody  --enable-bochs) bochs="yes"
14502f740136SJeff Cody  ;;
14512f740136SJeff Cody  --disable-cloop) cloop="no"
14522f740136SJeff Cody  ;;
14532f740136SJeff Cody  --enable-cloop) cloop="yes"
14542f740136SJeff Cody  ;;
14552f740136SJeff Cody  --disable-dmg) dmg="no"
14562f740136SJeff Cody  ;;
14572f740136SJeff Cody  --enable-dmg) dmg="yes"
14582f740136SJeff Cody  ;;
14592f740136SJeff Cody  --disable-qcow1) qcow1="no"
14602f740136SJeff Cody  ;;
14612f740136SJeff Cody  --enable-qcow1) qcow1="yes"
14622f740136SJeff Cody  ;;
14632f740136SJeff Cody  --disable-vdi) vdi="no"
14642f740136SJeff Cody  ;;
14652f740136SJeff Cody  --enable-vdi) vdi="yes"
14662f740136SJeff Cody  ;;
14672f740136SJeff Cody  --disable-vvfat) vvfat="no"
14682f740136SJeff Cody  ;;
14692f740136SJeff Cody  --enable-vvfat) vvfat="yes"
14702f740136SJeff Cody  ;;
14712f740136SJeff Cody  --disable-qed) qed="no"
14722f740136SJeff Cody  ;;
14732f740136SJeff Cody  --enable-qed) qed="yes"
14742f740136SJeff Cody  ;;
14752f740136SJeff Cody  --disable-parallels) parallels="no"
14762f740136SJeff Cody  ;;
14772f740136SJeff Cody  --enable-parallels) parallels="yes"
14782f740136SJeff Cody  ;;
1479e6a74868SMarc-André Lureau  --disable-vhost-user) vhost_user="no"
1480e6a74868SMarc-André Lureau  ;;
1481299e6f19SPaolo Bonzini  --enable-vhost-user) vhost_user="yes"
1482299e6f19SPaolo Bonzini  ;;
1483108a6481SCindy Lu  --disable-vhost-vdpa) vhost_vdpa="no"
1484108a6481SCindy Lu  ;;
1485108a6481SCindy Lu  --enable-vhost-vdpa) vhost_vdpa="yes"
1486108a6481SCindy Lu  ;;
1487299e6f19SPaolo Bonzini  --disable-vhost-kernel) vhost_kernel="no"
1488299e6f19SPaolo Bonzini  ;;
1489299e6f19SPaolo Bonzini  --enable-vhost-kernel) vhost_kernel="yes"
1490e6a74868SMarc-André Lureau  ;;
14918b18cdbfSRichard Henderson  --disable-capstone) capstone="disabled"
14928ca80760SRichard Henderson  ;;
14938b18cdbfSRichard Henderson  --enable-capstone) capstone="enabled"
14948ca80760SRichard Henderson  ;;
14958b18cdbfSRichard Henderson  --enable-capstone=git) capstone="internal"
1496e219c499SRichard Henderson  ;;
1497e219c499SRichard Henderson  --enable-capstone=system) capstone="system"
1498e219c499SRichard Henderson  ;;
1499cc84d63aSDaniel P. Berrange  --with-git=*) git="$optarg"
1500cc84d63aSDaniel P. Berrange  ;;
15017d7dbf9dSDan Streetman  --enable-git-update)
15027d7dbf9dSDan Streetman      git_submodules_action="update"
15037d7dbf9dSDan Streetman      echo "--enable-git-update deprecated, use --with-git-submodules=update"
1504f62bbee5SDaniel P. Berrange  ;;
15057d7dbf9dSDan Streetman  --disable-git-update)
15067d7dbf9dSDan Streetman      git_submodules_action="validate"
15077d7dbf9dSDan Streetman      echo "--disable-git-update deprecated, use --with-git-submodules=validate"
15087d7dbf9dSDan Streetman  ;;
15097d7dbf9dSDan Streetman  --with-git-submodules=*)
15107d7dbf9dSDan Streetman      git_submodules_action="$optarg"
1511f62bbee5SDaniel P. Berrange  ;;
1512ba59fb77SPaolo Bonzini  --enable-debug-mutex) debug_mutex=yes
1513ba59fb77SPaolo Bonzini  ;;
1514ba59fb77SPaolo Bonzini  --disable-debug-mutex) debug_mutex=no
1515ba59fb77SPaolo Bonzini  ;;
15165cd5d8a7SMiroslav Rezanina  --enable-libpmem) libpmem="enabled"
151717824406SJunyan He  ;;
15185cd5d8a7SMiroslav Rezanina  --disable-libpmem) libpmem="disabled"
151917824406SJunyan He  ;;
15204113f4cfSLaurent Vivier  --enable-xkbcommon) xkbcommon="enabled"
152175411919SJames Le Cuirot  ;;
15224113f4cfSLaurent Vivier  --disable-xkbcommon) xkbcommon="disabled"
152375411919SJames Le Cuirot  ;;
152440e8c6f4SAlex Bennée  --enable-plugins) plugins="yes"
152540e8c6f4SAlex Bennée  ;;
152640e8c6f4SAlex Bennée  --disable-plugins) plugins="no"
152740e8c6f4SAlex Bennée  ;;
1528afc3a8f9SAlex Bennée  --enable-containers) use_containers="yes"
1529afc3a8f9SAlex Bennée  ;;
1530afc3a8f9SAlex Bennée  --disable-containers) use_containers="no"
1531afc3a8f9SAlex Bennée  ;;
1532adc28027SAlexander Bulekov  --enable-fuzzing) fuzzing=yes
1533adc28027SAlexander Bulekov  ;;
1534adc28027SAlexander Bulekov  --disable-fuzzing) fuzzing=no
1535adc28027SAlexander Bulekov  ;;
1536f48e590aSAlex Bennée  --gdb=*) gdb_bin="$optarg"
1537f48e590aSAlex Bennée  ;;
1538b767d257SMarek Marczykowski-Górecki  --enable-rng-none) rng_none=yes
1539b767d257SMarek Marczykowski-Górecki  ;;
1540b767d257SMarek Marczykowski-Górecki  --disable-rng-none) rng_none=no
1541b767d257SMarek Marczykowski-Górecki  ;;
154254e7aac0SAlexey Krasikov  --enable-keyring) secret_keyring="yes"
154354e7aac0SAlexey Krasikov  ;;
154454e7aac0SAlexey Krasikov  --disable-keyring) secret_keyring="no"
154554e7aac0SAlexey Krasikov  ;;
154612033e16SMiroslav Rezanina  --enable-libdaxctl) libdaxctl="enabled"
154721b2eca6SJingqi Liu  ;;
154812033e16SMiroslav Rezanina  --disable-libdaxctl) libdaxctl="disabled"
154921b2eca6SJingqi Liu  ;;
1550a484a719SMax Reitz  --enable-fuse) fuse="enabled"
1551a484a719SMax Reitz  ;;
1552a484a719SMax Reitz  --disable-fuse) fuse="disabled"
1553a484a719SMax Reitz  ;;
1554df4ea709SMax Reitz  --enable-fuse-lseek) fuse_lseek="enabled"
1555df4ea709SMax Reitz  ;;
1556df4ea709SMax Reitz  --disable-fuse-lseek) fuse_lseek="disabled"
1557df4ea709SMax Reitz  ;;
1558106ad1f9SPaolo Bonzini  --enable-multiprocess) multiprocess="enabled"
15593090de69SJagannathan Raman  ;;
1560106ad1f9SPaolo Bonzini  --disable-multiprocess) multiprocess="disabled"
15613090de69SJagannathan Raman  ;;
156220cf7b8eSDenis Plotnikov  --enable-gio) gio=yes
156320cf7b8eSDenis Plotnikov  ;;
156420cf7b8eSDenis Plotnikov  --disable-gio) gio=no
156520cf7b8eSDenis Plotnikov  ;;
1566b8e0c493SJoelle van Dyne  --enable-slirp-smbd) slirp_smbd=yes
1567b8e0c493SJoelle van Dyne  ;;
1568b8e0c493SJoelle van Dyne  --disable-slirp-smbd) slirp_smbd=no
1569b8e0c493SJoelle van Dyne  ;;
15702d2ad6d0SFam Zheng  *)
15712d2ad6d0SFam Zheng      echo "ERROR: unknown option $opt"
15722d2ad6d0SFam Zheng      echo "Try '$0 --help' for more information"
15732d2ad6d0SFam Zheng      exit 1
15747f1559c6Sbalrog  ;;
15757d13299dSbellard  esac
15767d13299dSbellarddone
15777d13299dSbellard
15787d7dbf9dSDan Streetmancase $git_submodules_action in
15797d7dbf9dSDan Streetman    update|validate)
15807d7dbf9dSDan Streetman        if test ! -e "$source_path/.git"; then
15817d7dbf9dSDan Streetman            echo "ERROR: cannot $git_submodules_action git submodules without .git"
15827d7dbf9dSDan Streetman            exit 1
15837d7dbf9dSDan Streetman        fi
15847d7dbf9dSDan Streetman    ;;
15857d7dbf9dSDan Streetman    ignore)
1586b80fd281SPaolo Bonzini        if ! test -f "$source_path/ui/keycodemapdb/README"
1587b80fd281SPaolo Bonzini        then
1588b80fd281SPaolo Bonzini            echo
1589b80fd281SPaolo Bonzini            echo "ERROR: missing GIT submodules"
1590b80fd281SPaolo Bonzini            echo
1591b80fd281SPaolo Bonzini            if test -e "$source_path/.git"; then
1592b80fd281SPaolo Bonzini                echo "--with-git-submodules=ignore specified but submodules were not"
1593b80fd281SPaolo Bonzini                echo "checked out.  Please initialize and update submodules."
1594b80fd281SPaolo Bonzini            else
1595b80fd281SPaolo Bonzini                echo "This is not a GIT checkout but module content appears to"
1596b80fd281SPaolo Bonzini                echo "be missing. Do not use 'git archive' or GitHub download links"
1597b80fd281SPaolo Bonzini                echo "to acquire QEMU source archives. Non-GIT builds are only"
1598b80fd281SPaolo Bonzini                echo "supported with source archives linked from:"
1599b80fd281SPaolo Bonzini                echo
1600b80fd281SPaolo Bonzini                echo "  https://www.qemu.org/download/#source"
1601b80fd281SPaolo Bonzini                echo
1602b80fd281SPaolo Bonzini                echo "Developers working with GIT can use scripts/archive-source.sh"
1603b80fd281SPaolo Bonzini                echo "if they need to create valid source archives."
1604b80fd281SPaolo Bonzini            fi
1605b80fd281SPaolo Bonzini            echo
1606b80fd281SPaolo Bonzini            exit 1
1607b80fd281SPaolo Bonzini        fi
16087d7dbf9dSDan Streetman    ;;
16097d7dbf9dSDan Streetman    *)
16107d7dbf9dSDan Streetman        echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'"
16117d7dbf9dSDan Streetman        exit 1
16127d7dbf9dSDan Streetman    ;;
16137d7dbf9dSDan Streetmanesac
16147d7dbf9dSDan Streetman
161522a87800SMarc-André Lureaulibdir="${libdir:-$prefix/lib}"
161622a87800SMarc-André Lureaulibexecdir="${libexecdir:-$prefix/libexec}"
161722a87800SMarc-André Lureauincludedir="${includedir:-$prefix/include}"
161822a87800SMarc-André Lureau
161922a87800SMarc-André Lureauif test "$mingw32" = "yes" ; then
162015588a62SJoshua Watt    bindir="${bindir:-$prefix}"
162122a87800SMarc-André Lureauelse
162215588a62SJoshua Watt    bindir="${bindir:-$prefix/bin}"
162315588a62SJoshua Wattfi
162422a87800SMarc-André Lureaumandir="${mandir:-$prefix/share/man}"
162522a87800SMarc-André Lureaudatadir="${datadir:-$prefix/share}"
1626ca8c0909SMarc-André Lureaudocdir="${docdir:-$prefix/share/doc}"
162722a87800SMarc-André Lureausysconfdir="${sysconfdir:-$prefix/etc}"
162822a87800SMarc-André Lureaulocal_statedir="${local_statedir:-$prefix/var}"
162916bf7a33SPaolo Bonzinifirmwarepath="${firmwarepath:-$datadir/qemu-firmware}"
163016bf7a33SPaolo Bonzinilocaledir="${localedir:-$datadir/locale}"
163122a87800SMarc-André Lureau
163240293e58Sbellardcase "$cpu" in
1633e3608d66SRichard Henderson    ppc)
1634e3608d66SRichard Henderson           CPU_CFLAGS="-m32"
1635db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m32 $QEMU_LDFLAGS"
1636e3608d66SRichard Henderson           ;;
1637e3608d66SRichard Henderson    ppc64)
1638e3608d66SRichard Henderson           CPU_CFLAGS="-m64"
1639db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
1640e3608d66SRichard Henderson           ;;
16419b9c37c3SRichard Henderson    sparc)
1642f1079bb8SRichard Henderson           CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
1643db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m32 -mv8plus $QEMU_LDFLAGS"
16443142255cSblueswir1           ;;
1645ed968ff1SJuan Quintela    sparc64)
164679f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1647db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
16483142255cSblueswir1           ;;
164976d83bdeSths    s390)
1650061cdd81SRichard Henderson           CPU_CFLAGS="-m31"
1651db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m31 $QEMU_LDFLAGS"
165228d7cc49SRichard Henderson           ;;
165328d7cc49SRichard Henderson    s390x)
1654061cdd81SRichard Henderson           CPU_CFLAGS="-m64"
1655db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
165676d83bdeSths           ;;
165740293e58Sbellard    i386)
165879f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32"
1659db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m32 $QEMU_LDFLAGS"
166040293e58Sbellard           ;;
166140293e58Sbellard    x86_64)
16627ebee43eSRichard Henderson           # ??? Only extremely old AMD cpus do not have cmpxchg16b.
16637ebee43eSRichard Henderson           # If we truly care, we should simply detect this case at
16647ebee43eSRichard Henderson           # runtime and generate the fallback to serial emulation.
16657ebee43eSRichard Henderson           CPU_CFLAGS="-m64 -mcx16"
1666db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
1667379f6698SPaul Brook           ;;
1668c72b26ecSRichard Henderson    x32)
1669c72b26ecSRichard Henderson           CPU_CFLAGS="-mx32"
1670db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-mx32 $QEMU_LDFLAGS"
1671c72b26ecSRichard Henderson           ;;
167230163d89SPeter Maydell    # No special flags required for other host CPUs
16733142255cSblueswir1esac
16743142255cSblueswir1
1675b1aa4de1SAlex Bennéeeval "cross_cc_${cpu}=\$cc"
16762038f8c8SPaolo Bonzinicross_cc_vars="$cross_cc_vars cross_cc_${cpu}"
167779f3b12fSPeter CrosthwaiteQEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
167879f3b12fSPeter Crosthwaite
1679affc88ccSPeter Maydell# For user-mode emulation the host arch has to be one we explicitly
1680affc88ccSPeter Maydell# support, even if we're using TCI.
1681affc88ccSPeter Maydellif [ "$ARCH" = "unknown" ]; then
1682affc88ccSPeter Maydell  bsd_user="no"
1683affc88ccSPeter Maydell  linux_user="no"
1684affc88ccSPeter Maydellfi
1685affc88ccSPeter Maydell
168660e0df25SPeter Maydelldefault_target_list=""
168743692239SMarkus Armbrusterdeprecated_targets_list=ppc64abi32-linux-user
1688fdb75aefSPaolo Bonzinideprecated_features=""
16896e92f823SPeter Maydellmak_wilds=""
16906e92f823SPeter Maydell
169160e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then
1692812b31d3SAlex Bennée    mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak"
169360e0df25SPeter Maydellfi
169460e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then
1695812b31d3SAlex Bennée    mak_wilds="${mak_wilds} $source_path/configs/targets/*-linux-user.mak"
169660e0df25SPeter Maydellfi
169760e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then
1698812b31d3SAlex Bennée    mak_wilds="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak"
169960e0df25SPeter Maydellfi
170060e0df25SPeter Maydell
17013a5ae4a9SAlex Bennée# If the user doesn't explicitly specify a deprecated target we will
17023a5ae4a9SAlex Bennée# skip it.
17033a5ae4a9SAlex Bennéeif test -z "$target_list"; then
17043a5ae4a9SAlex Bennée    if test -z "$target_list_exclude"; then
17053a5ae4a9SAlex Bennée        target_list_exclude="$deprecated_targets_list"
17063a5ae4a9SAlex Bennée    else
17073a5ae4a9SAlex Bennée        target_list_exclude="$target_list_exclude,$deprecated_targets_list"
17083a5ae4a9SAlex Bennée    fi
17092d838d9bSAlex Bennéefi
17102d838d9bSAlex Bennée
1711447e133fSAlex Bennéefor config in $mak_wilds; do
1712447e133fSAlex Bennée    target="$(basename "$config" .mak)"
171398db9a06SAlex Bennée    if echo "$target_list_exclude" | grep -vq "$target"; then
1714447e133fSAlex Bennée        default_target_list="${default_target_list} $target"
1715447e133fSAlex Bennée    fi
1716447e133fSAlex Bennéedone
17176e92f823SPeter Maydell
1718c53eeaf7SStefan Hajnoczi# Enumerate public trace backends for --help output
171964a6047dSGreg Kurztrace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
1720c53eeaf7SStefan Hajnoczi
1721af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1722af5db58eSpbrookcat << EOF
1723af5db58eSpbrook
1724af5db58eSpbrookUsage: configure [options]
1725af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1726af5db58eSpbrook
172708fb77edSStefan WeilStandard options:
172808fb77edSStefan Weil  --help                   print this message
172908fb77edSStefan Weil  --prefix=PREFIX          install in PREFIX [$prefix]
173008fb77edSStefan Weil  --interp-prefix=PREFIX   where to find shared libraries, etc.
173108fb77edSStefan Weil                           use %M for cpu name [$interp_prefix]
17322deca810SAlex Bennée  --target-list=LIST       set target list (default: build all non-deprecated)
173308fb77edSStefan Weil$(echo Available targets: $default_target_list | \
173408fb77edSStefan Weil  fold -s -w 53 | sed -e 's/^/                           /')
17352deca810SAlex Bennée$(echo Deprecated targets: $deprecated_targets_list | \
17362deca810SAlex Bennée  fold -s -w 53 | sed -e 's/^/                           /')
1737447e133fSAlex Bennée  --target-list-exclude=LIST exclude a set of targets from the default target-list
173808fb77edSStefan Weil
173908fb77edSStefan WeilAdvanced options (experts only):
17403812c0c4SJoelle van Dyne  --cross-prefix=PREFIX    use PREFIX for compile tools, PREFIX can be blank [$cross_prefix]
174108fb77edSStefan Weil  --cc=CC                  use C compiler CC [$cc]
174208fb77edSStefan Weil  --iasl=IASL              use ACPI compiler IASL [$iasl]
174308fb77edSStefan Weil  --host-cc=CC             use C compiler CC [$host_cc] for code run at
174408fb77edSStefan Weil                           build time
174508fb77edSStefan Weil  --cxx=CXX                use C++ compiler CXX [$cxx]
174608fb77edSStefan Weil  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]
174708fb77edSStefan Weil  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS
174811cde1c8SBruno Dominguez  --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
174908fb77edSStefan Weil  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
1750d75402b5SAlex Bennée  --cross-cc-ARCH=CC       use compiler when building ARCH guest test cases
1751d422b2bcSAlex Bennée  --cross-cc-flags-ARCH=   use compiler flags when building ARCH guest tests
175208fb77edSStefan Weil  --make=MAKE              use specified make [$make]
175308fb77edSStefan Weil  --python=PYTHON          use specified python [$python]
17542eb054c2SPeter Maydell  --sphinx-build=SPHINX    use specified sphinx-build [$sphinx_build]
1755a5665051SPaolo Bonzini  --meson=MESON            use specified meson [$meson]
175648328880SPaolo Bonzini  --ninja=NINJA            use specified ninja [$ninja]
175708fb77edSStefan Weil  --smbd=SMBD              use specified smbd [$smbd]
1758db1b5f13SThomas Huth  --with-git=GIT           use specified git [$git]
17597d7dbf9dSDan Streetman  --with-git-submodules=update   update git submodules (default if .git dir exists)
17607d7dbf9dSDan Streetman  --with-git-submodules=validate fail if git submodules are not up to date
17617d7dbf9dSDan Streetman  --with-git-submodules=ignore   do not update or check git submodules (default if no .git dir)
176208fb77edSStefan Weil  --static                 enable static build [$static]
176308fb77edSStefan Weil  --mandir=PATH            install man pages in PATH
176410ff82d1SMarc-André Lureau  --datadir=PATH           install firmware in PATH/$qemu_suffix
1765fe0038beSPaolo Bonzini  --localedir=PATH         install translation in PATH/$qemu_suffix
176610ff82d1SMarc-André Lureau  --docdir=PATH            install documentation in PATH/$qemu_suffix
176708fb77edSStefan Weil  --bindir=PATH            install binaries in PATH
176808fb77edSStefan Weil  --libdir=PATH            install libraries in PATH
1769db1b5f13SThomas Huth  --libexecdir=PATH        install helper binaries in PATH
177010ff82d1SMarc-André Lureau  --sysconfdir=PATH        install config in PATH/$qemu_suffix
177108fb77edSStefan Weil  --localstatedir=PATH     install local state in PATH (set at runtime on win32)
17723d5eecabSGerd Hoffmann  --firmwarepath=PATH      search PATH for firmware files
177313336606SRobert Foley  --efi-aarch64=PATH       PATH of efi file to use for aarch64 VMs.
1774ca8c0909SMarc-André Lureau  --with-suffix=SUFFIX     suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix]
1775db1b5f13SThomas Huth  --with-pkgversion=VERS   use specified string as sub-version of the package
1776c035c8d6SPaolo Bonzini  --without-default-features default all --enable-* options to "disabled"
1777c035c8d6SPaolo Bonzini  --without-default-devices  do not include any device that is not needed to
1778c035c8d6SPaolo Bonzini                           start the emulator (only use if you are including
1779*d1d5e9eeSAlex Bennée                           desired devices in configs/devices/)
1780*d1d5e9eeSAlex Bennée  --with-devices-ARCH=NAME override default configs/devices
178108fb77edSStefan Weil  --enable-debug           enable common debug build options
1782247724cbSMarc-André Lureau  --enable-sanitizers      enable default sanitizers
17830aebab04SLingfeng Yang  --enable-tsan            enable thread sanitizer
178408fb77edSStefan Weil  --disable-strip          disable stripping binaries
178508fb77edSStefan Weil  --disable-werror         disable compilation abort on warning
178663678e17SSteven Noonan  --disable-stack-protector disable compiler-provided stack protection
178708fb77edSStefan Weil  --audio-drv-list=LIST    set audio drivers list:
178808fb77edSStefan Weil                           Available drivers: $audio_possible_drivers
178908fb77edSStefan Weil  --block-drv-whitelist=L  Same as --block-drv-rw-whitelist=L
179008fb77edSStefan Weil  --block-drv-rw-whitelist=L
179108fb77edSStefan Weil                           set block driver read-write whitelist
179208fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
179308fb77edSStefan Weil  --block-drv-ro-whitelist=L
179408fb77edSStefan Weil                           set block driver read-only whitelist
179508fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
17965b808275SLluís Vilanova  --enable-trace-backends=B Set trace backend
1797c53eeaf7SStefan Hajnoczi                           Available backends: $trace_backend_list
179808fb77edSStefan Weil  --with-trace-file=NAME   Full PATH,NAME of file to store traces
179908fb77edSStefan Weil                           Default:trace-<pid>
1800c23f23b9SMichael Tokarev  --disable-slirp          disable SLIRP userspace network connectivity
1801e9a16e38SPhilippe Mathieu-Daudé  --enable-tcg-interpreter enable TCI (TCG with bytecode interpreter, experimental and slow)
18025a22ab71SYang Zhong  --enable-malloc-trim     enable libc malloc_trim() for memory optimization
1803c23f23b9SMichael Tokarev  --oss-lib                path to OSS library
1804c23f23b9SMichael Tokarev  --cpu=CPU                Build for host CPU [$cpu]
180508fb77edSStefan Weil  --with-coroutine=BACKEND coroutine backend. Supported options:
180633c53c54SDaniel P. Berrange                           ucontext, sigaltstack, windows
180708fb77edSStefan Weil  --enable-gcov            enable test coverage analysis with gcov
1808c23f23b9SMichael Tokarev  --disable-blobs          disable installing provided firmware blobs
1809c23f23b9SMichael Tokarev  --with-vss-sdk=SDK-path  enable Windows VSS support in QEMU Guest Agent
1810c23f23b9SMichael Tokarev  --with-win-sdk=SDK-path  path to Windows Platform SDK (to build VSS .tlb)
1811a1c5e949SDaniel P. Berrange  --tls-priority           default TLS protocol/cipher priority string
1812c12d66aaSLin Ma  --enable-gprof           QEMU profiling with gprof
1813c12d66aaSLin Ma  --enable-profiler        profiler support
1814c12d66aaSLin Ma  --enable-debug-stack-usage
1815c12d66aaSLin Ma                           track the maximum stack usage of stacks created by qemu_alloc_stack
181640e8c6f4SAlex Bennée  --enable-plugins
181740e8c6f4SAlex Bennée                           enable plugins via shared library loading
1818afc3a8f9SAlex Bennée  --disable-containers     don't use containers for cross-building
1819f48e590aSAlex Bennée  --gdb=GDB-path           gdb to use for gdbstub tests [$gdb_bin]
1820c23f23b9SMichael Tokarev
1821c23f23b9SMichael TokarevOptional features, enabled with --enable-FEATURE and
1822c87ea116SAlex Bennéedisabled with --disable-FEATURE, default is enabled if available
1823c87ea116SAlex Bennée(unless built with --without-default-features):
1824c23f23b9SMichael Tokarev
1825c23f23b9SMichael Tokarev  system          all system emulation targets
1826c23f23b9SMichael Tokarev  user            supported user emulation targets
1827c23f23b9SMichael Tokarev  linux-user      all linux usermode emulation targets
1828c23f23b9SMichael Tokarev  bsd-user        all BSD usermode emulation targets
1829c23f23b9SMichael Tokarev  docs            build documentation
1830c23f23b9SMichael Tokarev  guest-agent     build the QEMU Guest Agent
1831c23f23b9SMichael Tokarev  guest-agent-msi build guest agent Windows MSI installation package
1832c23f23b9SMichael Tokarev  pie             Position Independent Executables
183321e709aaSMarc-André Lureau  modules         modules support (non-Windows)
1834bd83c861SChristian Ehrhardt  module-upgrades try to load modules from alternate paths for upgrades
1835c23f23b9SMichael Tokarev  debug-tcg       TCG debugging (default is disabled)
1836c23f23b9SMichael Tokarev  debug-info      debugging information
1837cdad781dSDaniele Buono  lto             Enable Link-Time Optimization.
1838c23f23b9SMichael Tokarev  sparse          sparse checker
18391e4f6065SDaniele Buono  safe-stack      SafeStack Stack Smash Protection. Depends on
18401e4f6065SDaniele Buono                  clang/llvm >= 3.7 and requires coroutine backend ucontext.
18419e62ba48SDaniele Buono  cfi             Enable Control-Flow Integrity for indirect function calls.
18429e62ba48SDaniele Buono                  In case of a cfi violation, QEMU is terminated with SIGILL
18439e62ba48SDaniele Buono                  Depends on lto and is incompatible with modules
18449e62ba48SDaniele Buono                  Automatically enables Link-Time Optimization (lto)
18459e62ba48SDaniele Buono  cfi-debug       In case of a cfi violation, a message containing the line that
18469e62ba48SDaniele Buono                  triggered the error is written to stderr. After the error,
18479e62ba48SDaniele Buono                  QEMU is still terminated with SIGILL
1848ddbb0d09SDaniel P. Berrange  gnutls          GNUTLS cryptography support
184991bfcdb0SDaniel P. Berrange  nettle          nettle cryptography support
185091bfcdb0SDaniel P. Berrange  gcrypt          libgcrypt cryptography support
18518953caf3SDaniel P. Berrange  auth-pam        PAM access control
1852c23f23b9SMichael Tokarev  sdl             SDL UI
185304c6e16fSMarkus Armbruster  sdl-image       SDL Image support for icons
1854c23f23b9SMichael Tokarev  gtk             gtk UI
1855c23f23b9SMichael Tokarev  vte             vte support for the gtk UI
1856c23f23b9SMichael Tokarev  curses          curses UI
1857e08bb301SSamuel Thibault  iconv           font glyph conversion support
1858c23f23b9SMichael Tokarev  vnc             VNC UI support
1859c23f23b9SMichael Tokarev  vnc-sasl        SASL encryption for VNC server
1860c23f23b9SMichael Tokarev  vnc-jpeg        JPEG lossy compression for VNC server
1861c23f23b9SMichael Tokarev  vnc-png         PNG compression for VNC server
1862c23f23b9SMichael Tokarev  cocoa           Cocoa UI (Mac OS X only)
1863c23f23b9SMichael Tokarev  virtfs          VirtFS
1864cece116cSMisono Tomohiro  virtiofsd       build virtiofs daemon (virtiofsd)
18655c53015aSPaolo Bonzini  libudev         Use libudev to enumerate host devices
1866fe8fc5aeSPaolo Bonzini  mpath           Multipath persistent reservation passthrough
1867c23f23b9SMichael Tokarev  xen             xen backend driver support
186870c292afSAnthony PERARD  xen-pci-passthrough    PCI passthrough support for Xen
1869c23f23b9SMichael Tokarev  brlapi          BrlAPI (Braile)
1870c23f23b9SMichael Tokarev  curl            curl connectivity
1871a40161cbSPaolo Bonzini  membarrier      membarrier system call (for Linux 4.14+ or Windows)
1872c23f23b9SMichael Tokarev  fdt             fdt device tree
1873c23f23b9SMichael Tokarev  kvm             KVM acceleration support
1874b0cb0a66SVincent Palatin  hax             HAX acceleration support
1875c97d6d2cSSergio Andres Gomez Del Real  hvf             Hypervisor.framework acceleration support
187674a414a1SReinoud Zandijk  nvmm            NVMM acceleration support
1877d661d9a4SJustin Terry (VM)  whpx            Windows Hypervisor Platform acceleration support
187821ab34c9SMarcel Apfelbaum  rdma            Enable RDMA-based migration
187921ab34c9SMarcel Apfelbaum  pvrdma          Enable PVRDMA support
1880c23f23b9SMichael Tokarev  vde             support for vde network
1881c23f23b9SMichael Tokarev  netmap          support for netmap network
1882c23f23b9SMichael Tokarev  linux-aio       Linux AIO support
1883c10dd856SAarushi Mehta  linux-io-uring  Linux io_uring support
1884c23f23b9SMichael Tokarev  cap-ng          libcap-ng support
1885c23f23b9SMichael Tokarev  attr            attr and xattr support
1886299e6f19SPaolo Bonzini  vhost-net       vhost-net kernel acceleration support
1887299e6f19SPaolo Bonzini  vhost-vsock     virtio sockets device support
1888299e6f19SPaolo Bonzini  vhost-scsi      vhost-scsi kernel target support
1889299e6f19SPaolo Bonzini  vhost-crypto    vhost-user-crypto backend support
1890299e6f19SPaolo Bonzini  vhost-kernel    vhost kernel backend support
1891299e6f19SPaolo Bonzini  vhost-user      vhost-user backend support
1892bc15e44cSStefan Hajnoczi  vhost-user-blk-server    vhost-user-blk server support
1893108a6481SCindy Lu  vhost-vdpa      vhost-vdpa kernel backend support
189446627f41SAndrew Melnychenko  bpf             BPF kernel support
1895c23f23b9SMichael Tokarev  spice           spice
189658d3f3ffSGerd Hoffmann  spice-protocol  spice-protocol
1897c23f23b9SMichael Tokarev  rbd             rados block device (rbd)
1898c23f23b9SMichael Tokarev  libiscsi        iscsi support
1899c23f23b9SMichael Tokarev  libnfs          nfs support
19007b02f544SMarc-André Lureau  smartcard       smartcard support (libcacard)
19010a40bcb7SCésar Belley  u2f             U2F support (u2f-emu)
1902c23f23b9SMichael Tokarev  libusb          libusb (for usb passthrough)
1903ed1701c6SDr. David Alan Gilbert  live-block-migration   Block migration in the main migration stream
1904c23f23b9SMichael Tokarev  usb-redir       usb network redirection support
1905c23f23b9SMichael Tokarev  lzo             support of lzo compression library
1906c23f23b9SMichael Tokarev  snappy          support of snappy compression library
1907c23f23b9SMichael Tokarev  bzip2           support of bzip2 compression library
1908c23f23b9SMichael Tokarev                  (for reading bzip2-compressed dmg images)
190983bc1f97SJulio Faracco  lzfse           support of lzfse compression library
191083bc1f97SJulio Faracco                  (for reading lzfse-compressed dmg images)
19113a678481SJuan Quintela  zstd            support for zstd compression library
1912d298ac10SDenis Plotnikov                  (for migration compression and qcow2 cluster compression)
1913c23f23b9SMichael Tokarev  seccomp         seccomp support
1914c23f23b9SMichael Tokarev  coroutine-pool  coroutine freelist (better performance)
1915c23f23b9SMichael Tokarev  glusterfs       GlusterFS backend
1916c23f23b9SMichael Tokarev  tpm             TPM support
1917b10d49d7SPino Toscano  libssh          ssh block device support
1918c23f23b9SMichael Tokarev  numa            libnuma support
1919ed279a06SKlim Kireev  libxml2         for Parallels image format
1920c23f23b9SMichael Tokarev  tcmalloc        tcmalloc support
19217b01cb97SAlexandre Derumier  jemalloc        jemalloc support
192286583a07SLiam Merwick  avx2            AVX2 optimization support
19236b8cd447SRobert Hoo  avx512f         AVX512F optimization support
1924a6b1d4c0SChanglong Xie  replication     replication support
1925c12d66aaSLin Ma  opengl          opengl support
1926c12d66aaSLin Ma  virglrenderer   virgl rendering support
1927c12d66aaSLin Ma  xfsctl          xfsctl support
1928c12d66aaSLin Ma  qom-cast-debug  cast debugging support
19298de73fa8SCleber Rosa  tools           build qemu-io, qemu-nbd and qemu-img tools
19302f740136SJeff Cody  bochs           bochs image format support
19312f740136SJeff Cody  cloop           cloop image format support
19322f740136SJeff Cody  dmg             dmg image format support
19332f740136SJeff Cody  qcow1           qcow v1 image format support
19342f740136SJeff Cody  vdi             vdi image format support
19352f740136SJeff Cody  vvfat           vvfat image format support
19362f740136SJeff Cody  qed             qed image format support
19372f740136SJeff Cody  parallels       parallels image format support
1938f0d92b56SLongpeng(Mike)  crypto-afalg    Linux AF_ALG crypto backend driver
19398ca80760SRichard Henderson  capstone        capstone disassembler support
1940ba59fb77SPaolo Bonzini  debug-mutex     mutex debugging support
194117824406SJunyan He  libpmem         libpmem support
194275411919SJames Le Cuirot  xkbcommon       xkbcommon support
1943b767d257SMarek Marczykowski-Górecki  rng-none        dummy RNG, avoid using /dev/(u)random and getrandom()
194421b2eca6SJingqi Liu  libdaxctl       libdaxctl support
1945a484a719SMax Reitz  fuse            FUSE block device export
1946df4ea709SMax Reitz  fuse-lseek      SEEK_HOLE/SEEK_DATA support for FUSE exports
1947106ad1f9SPaolo Bonzini  multiprocess    Out of process device emulation support
194820cf7b8eSDenis Plotnikov  gio             libgio support
1949b8e0c493SJoelle van Dyne  slirp-smbd      use smbd (at path --smbd=*) in slirp networking
195008fb77edSStefan Weil
195108fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched
1952af5db58eSpbrookEOF
19532d2ad6d0SFam Zhengexit 0
1954af5db58eSpbrookfi
1955af5db58eSpbrook
19569c790242SThomas Huth# Remove old dependency files to make sure that they get properly regenerated
1957bb768f71SThomas Huthrm -f */config-devices.mak.d
19589c790242SThomas Huth
1959faf44142SDaniel P. Berrangéif test -z "$python"
1960faf44142SDaniel P. Berrangéthen
1961c53eeaf7SStefan Hajnoczi    error_exit "Python not found. Use --python=/path/to/python"
1962c53eeaf7SStefan Hajnoczifi
19638e2c76bdSRoman Bolshakovif ! has "$make"
19648e2c76bdSRoman Bolshakovthen
19658e2c76bdSRoman Bolshakov    error_exit "GNU make ($make) not found"
19668e2c76bdSRoman Bolshakovfi
1967c53eeaf7SStefan Hajnoczi
1968c53eeaf7SStefan Hajnoczi# Note that if the Python conditional here evaluates True we will exit
1969c53eeaf7SStefan Hajnoczi# with status 1 which is a shell 'false' value.
19701b11f28dSThomas Huthif ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then
19711b11f28dSThomas Huth  error_exit "Cannot use '$python', Python >= 3.6 is required." \
1972c53eeaf7SStefan Hajnoczi      "Use --python=/path/to/python to specify a supported Python."
1973c53eeaf7SStefan Hajnoczifi
1974c53eeaf7SStefan Hajnoczi
1975755ee70fSCleber Rosa# Preserve python version since some functionality is dependent on it
1976406ab2f3SCleber 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)
1977755ee70fSCleber Rosa
1978c53eeaf7SStefan Hajnoczi# Suppress writing compiled files
1979c53eeaf7SStefan Hajnoczipython="$python -B"
1980c53eeaf7SStefan Hajnoczi
19810a01d76fSMarc-André Lureauif test -z "$meson"; then
19826ebd89cfSPaolo Bonzini    if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.55.3; then
19830a01d76fSMarc-André Lureau        meson=meson
19847d7dbf9dSDan Streetman    elif test $git_submodules_action != 'ignore' ; then
19850a01d76fSMarc-André Lureau        meson=git
19860a01d76fSMarc-André Lureau    elif test -e "${source_path}/meson/meson.py" ; then
19870a01d76fSMarc-André Lureau        meson=internal
19880a01d76fSMarc-André Lureau    else
19890a01d76fSMarc-André Lureau        if test "$explicit_python" = yes; then
19900a01d76fSMarc-André Lureau            error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found."
19910a01d76fSMarc-André Lureau        else
1992a5665051SPaolo Bonzini            error_exit "Meson not found.  Use --meson=/path/to/meson"
1993a5665051SPaolo Bonzini        fi
19940a01d76fSMarc-André Lureau    fi
19950a01d76fSMarc-André Lureauelse
19960a01d76fSMarc-André Lureau    # Meson uses its own Python interpreter to invoke other Python scripts,
19970a01d76fSMarc-André Lureau    # but the user wants to use the one they specified with --python.
19980a01d76fSMarc-André Lureau    #
19990a01d76fSMarc-André Lureau    # We do not want to override the distro Python interpreter (and sometimes
20000a01d76fSMarc-André Lureau    # cannot: for example in Homebrew /usr/bin/meson is a bash script), so
20010a01d76fSMarc-André Lureau    # just require --meson=git|internal together with --python.
20020a01d76fSMarc-André Lureau    if test "$explicit_python" = yes; then
20030a01d76fSMarc-André Lureau        case "$meson" in
20040a01d76fSMarc-André Lureau            git | internal) ;;
20050a01d76fSMarc-André Lureau            *) error_exit "--python requires using QEMU's embedded Meson distribution." ;;
20060a01d76fSMarc-André Lureau        esac
20070a01d76fSMarc-André Lureau    fi
20080a01d76fSMarc-André Lureaufi
2009a5665051SPaolo Bonzini
20100a01d76fSMarc-André Lureauif test "$meson" = git; then
20110a01d76fSMarc-André Lureau    git_submodules="${git_submodules} meson"
20120a01d76fSMarc-André Lureaufi
20130a01d76fSMarc-André Lureau
20140a01d76fSMarc-André Lureaucase "$meson" in
20150a01d76fSMarc-André Lureau    git | internal)
20160a01d76fSMarc-André Lureau        meson="$python ${source_path}/meson/meson.py"
20170a01d76fSMarc-André Lureau        ;;
201884ec0c24SPaolo Bonzini    *) meson=$(command -v "$meson") ;;
20190a01d76fSMarc-André Lureauesac
20200a01d76fSMarc-André Lureau
202109e93326SPaolo Bonzini# Probe for ninja
202248328880SPaolo Bonzini
202348328880SPaolo Bonziniif test -z "$ninja"; then
202448328880SPaolo Bonzini    for c in ninja ninja-build samu; do
202548328880SPaolo Bonzini        if has $c; then
202648328880SPaolo Bonzini            ninja=$(command -v "$c")
202748328880SPaolo Bonzini            break
202848328880SPaolo Bonzini        fi
202948328880SPaolo Bonzini    done
203009e93326SPaolo Bonzini    if test -z "$ninja"; then
203109e93326SPaolo Bonzini      error_exit "Cannot find Ninja"
203209e93326SPaolo Bonzini    fi
203348328880SPaolo Bonzinifi
2034a5665051SPaolo Bonzini
20359aae6e54SDaniel Henrique Barboza# Check that the C compiler works. Doing this here before testing
20369aae6e54SDaniel Henrique Barboza# the host CPU ensures that we had a valid CC to autodetect the
20379aae6e54SDaniel Henrique Barboza# $cpu var (and we should bail right here if that's not the case).
20389aae6e54SDaniel Henrique Barboza# It also allows the help message to be printed without a CC.
20399aae6e54SDaniel Henrique Barbozawrite_c_skeleton;
20409aae6e54SDaniel Henrique Barbozaif compile_object ; then
20419aae6e54SDaniel Henrique Barboza  : C compiler works ok
20429aae6e54SDaniel Henrique Barbozaelse
20439aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" either does not exist or does not work"
20449aae6e54SDaniel Henrique Barbozafi
20459aae6e54SDaniel Henrique Barbozaif ! compile_prog ; then
20469aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
20479aae6e54SDaniel Henrique Barbozafi
20489aae6e54SDaniel Henrique Barboza
20499c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror
20509c83ffd8SPeter Maydell# by default.  Only enable by default for git builds
20519c83ffd8SPeter Maydellif test -z "$werror" ; then
20527d7dbf9dSDan Streetman    if test "$git_submodules_action" != "ignore" && \
2053e633a5c6SEric Blake        { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
20549c83ffd8SPeter Maydell        werror="yes"
20559c83ffd8SPeter Maydell    else
20569c83ffd8SPeter Maydell        werror="no"
20579c83ffd8SPeter Maydell    fi
20589c83ffd8SPeter Maydellfi
20599c83ffd8SPeter Maydell
2060975ff037SPaolo Bonziniif test "$targetos" = "bogus"; then
2061fb59dabdSPeter Maydell    # Now that we know that we're not printing the help and that
2062fb59dabdSPeter Maydell    # the compiler works (so the results of the check_defines we used
2063fb59dabdSPeter Maydell    # to identify the OS are reliable), if we didn't recognize the
2064fb59dabdSPeter Maydell    # host OS we should stop now.
2065951fedfcSPeter Maydell    error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
2066fb59dabdSPeter Maydellfi
2067fb59dabdSPeter Maydell
2068efc6c070SThomas Huth# Check whether the compiler matches our minimum requirements:
2069efc6c070SThomas Huthcat > $TMPC << EOF
2070efc6c070SThomas Huth#if defined(__clang_major__) && defined(__clang_minor__)
2071efc6c070SThomas Huth# ifdef __apple_build_version__
20722a85a08cSDaniel P. Berrangé#  if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0)
20732a85a08cSDaniel P. Berrangé#   error You need at least XCode Clang v10.0 to compile QEMU
2074efc6c070SThomas Huth#  endif
2075efc6c070SThomas Huth# else
20762a85a08cSDaniel P. Berrangé#  if __clang_major__ < 6 || (__clang_major__ == 6 && __clang_minor__ < 0)
20772a85a08cSDaniel P. Berrangé#   error You need at least Clang v6.0 to compile QEMU
2078efc6c070SThomas Huth#  endif
2079efc6c070SThomas Huth# endif
2080efc6c070SThomas Huth#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
208156208a0dSDaniel P. Berrangé# if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 5)
208256208a0dSDaniel P. Berrangé#  error You need at least GCC v7.5.0 to compile QEMU
2083efc6c070SThomas Huth# endif
2084efc6c070SThomas Huth#else
2085efc6c070SThomas Huth# error You either need GCC or Clang to compiler QEMU
2086efc6c070SThomas Huth#endif
2087efc6c070SThomas Huthint main (void) { return 0; }
2088efc6c070SThomas HuthEOF
2089efc6c070SThomas Huthif ! compile_prog "" "" ; then
20902a85a08cSDaniel P. Berrangé    error_exit "You need at least GCC v7.5 or Clang v6.0 (or XCode Clang v10.0)"
2091efc6c070SThomas Huthfi
2092efc6c070SThomas Huth
209300849b92SRichard Henderson# Accumulate -Wfoo and -Wno-bar separately.
209400849b92SRichard Henderson# We will list all of the enable flags first, and the disable flags second.
209500849b92SRichard Henderson# Note that we do not add -Werror, because that would enable it for all
209600849b92SRichard Henderson# configure tests. If a configure test failed due to -Werror this would
209700849b92SRichard Henderson# just silently disable some features, so it's too error prone.
209800849b92SRichard Henderson
209900849b92SRichard Hendersonwarn_flags=
210000849b92SRichard Hendersonadd_to warn_flags -Wold-style-declaration
210100849b92SRichard Hendersonadd_to warn_flags -Wold-style-definition
210200849b92SRichard Hendersonadd_to warn_flags -Wtype-limits
210300849b92SRichard Hendersonadd_to warn_flags -Wformat-security
210400849b92SRichard Hendersonadd_to warn_flags -Wformat-y2k
210500849b92SRichard Hendersonadd_to warn_flags -Winit-self
210600849b92SRichard Hendersonadd_to warn_flags -Wignored-qualifiers
210700849b92SRichard Hendersonadd_to warn_flags -Wempty-body
210800849b92SRichard Hendersonadd_to warn_flags -Wnested-externs
210900849b92SRichard Hendersonadd_to warn_flags -Wendif-labels
211000849b92SRichard Hendersonadd_to warn_flags -Wexpansion-to-defined
21110a2ebce9SThomas Huthadd_to warn_flags -Wimplicit-fallthrough=2
211200849b92SRichard Henderson
211300849b92SRichard Hendersonnowarn_flags=
211400849b92SRichard Hendersonadd_to nowarn_flags -Wno-initializer-overrides
211500849b92SRichard Hendersonadd_to nowarn_flags -Wno-missing-include-dirs
211600849b92SRichard Hendersonadd_to nowarn_flags -Wno-shift-negative-value
211700849b92SRichard Hendersonadd_to nowarn_flags -Wno-string-plus-int
211800849b92SRichard Hendersonadd_to nowarn_flags -Wno-typedef-redefinition
2119aabab967SRichard Hendersonadd_to nowarn_flags -Wno-tautological-type-limit-compare
2120bac8d222SRichard Hendersonadd_to nowarn_flags -Wno-psabi
212100849b92SRichard Henderson
212200849b92SRichard Hendersongcc_flags="$warn_flags $nowarn_flags"
212393b25869SJohn Snow
212493b25869SJohn Snowcc_has_warning_flag() {
212593b25869SJohn Snow    write_c_skeleton;
212693b25869SJohn Snow
2127a1d29d6cSPeter Maydell    # Use the positive sense of the flag when testing for -Wno-wombat
2128a1d29d6cSPeter Maydell    # support (gcc will happily accept the -Wno- form of unknown
2129a1d29d6cSPeter Maydell    # warning options).
213093b25869SJohn Snow    optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
213193b25869SJohn Snow    compile_prog "-Werror $optflag" ""
213293b25869SJohn Snow}
213393b25869SJohn Snow
213493b25869SJohn Snowfor flag in $gcc_flags; do
213593b25869SJohn Snow    if cc_has_warning_flag $flag ; then
21368d05095cSPaolo Bonzini        QEMU_CFLAGS="$QEMU_CFLAGS $flag"
21378d05095cSPaolo Bonzini    fi
21388d05095cSPaolo Bonzinidone
21398d05095cSPaolo Bonzini
214063678e17SSteven Noonanif test "$stack_protector" != "no"; then
2141fccd35a0SRodrigo Rebello  cat > $TMPC << EOF
2142fccd35a0SRodrigo Rebelloint main(int argc, char *argv[])
2143fccd35a0SRodrigo Rebello{
2144fccd35a0SRodrigo Rebello    char arr[64], *p = arr, *c = argv[0];
2145fccd35a0SRodrigo Rebello    while (*c) {
2146fccd35a0SRodrigo Rebello        *p++ = *c++;
2147fccd35a0SRodrigo Rebello    }
2148fccd35a0SRodrigo Rebello    return 0;
2149fccd35a0SRodrigo Rebello}
2150fccd35a0SRodrigo RebelloEOF
215163678e17SSteven Noonan  gcc_flags="-fstack-protector-strong -fstack-protector-all"
21523b463a3fSMiroslav Rezanina  sp_on=0
215363678e17SSteven Noonan  for flag in $gcc_flags; do
2154590e5dd9SPeter Maydell    # We need to check both a compile and a link, since some compiler
2155590e5dd9SPeter Maydell    # setups fail only on a .c->.o compile and some only at link time
2156086d5f75SPaolo Bonzini    if compile_object "-Werror $flag" &&
2157590e5dd9SPeter Maydell       compile_prog "-Werror $flag" ""; then
215863678e17SSteven Noonan      QEMU_CFLAGS="$QEMU_CFLAGS $flag"
2159db5adeaaSPaolo Bonzini      QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
21603b463a3fSMiroslav Rezanina      sp_on=1
216163678e17SSteven Noonan      break
216263678e17SSteven Noonan    fi
216363678e17SSteven Noonan  done
21643b463a3fSMiroslav Rezanina  if test "$stack_protector" = yes; then
21653b463a3fSMiroslav Rezanina    if test $sp_on = 0; then
21663b463a3fSMiroslav Rezanina      error_exit "Stack protector not supported"
21673b463a3fSMiroslav Rezanina    fi
21683b463a3fSMiroslav Rezanina  fi
216937746c5eSMarc-André Lureaufi
217037746c5eSMarc-André Lureau
217120bc94a2SPaolo Bonzini# Disable -Wmissing-braces on older compilers that warn even for
217220bc94a2SPaolo Bonzini# the "universal" C zero initializer {0}.
217320bc94a2SPaolo Bonzinicat > $TMPC << EOF
217420bc94a2SPaolo Bonzinistruct {
217520bc94a2SPaolo Bonzini  int a[2];
217620bc94a2SPaolo Bonzini} x = {0};
217720bc94a2SPaolo BonziniEOF
217820bc94a2SPaolo Bonziniif compile_object "-Werror" "" ; then
217920bc94a2SPaolo Bonzini  :
218020bc94a2SPaolo Bonzinielse
218120bc94a2SPaolo Bonzini  QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
218220bc94a2SPaolo Bonzinifi
218320bc94a2SPaolo Bonzini
218421e709aaSMarc-André Lureau# Our module code doesn't support Windows
218521e709aaSMarc-André Lureauif test "$modules" = "yes" && test "$mingw32" = "yes" ; then
218621e709aaSMarc-André Lureau  error_exit "Modules are not available for Windows"
218721e709aaSMarc-André Lureaufi
218821e709aaSMarc-André Lureau
2189bd83c861SChristian Ehrhardt# module_upgrades is only reasonable if modules are enabled
2190bd83c861SChristian Ehrhardtif test "$modules" = "no" && test "$module_upgrades" = "yes" ; then
2191bd83c861SChristian Ehrhardt  error_exit "Can't enable module-upgrades as Modules are not enabled"
2192bd83c861SChristian Ehrhardtfi
2193bd83c861SChristian Ehrhardt
2194d376e9deSThomas Huth# Static linking is not possible with modules or PIE
219540d6444eSAvi Kivityif test "$static" = "yes" ; then
2196aa0d1f44SPaolo Bonzini  if test "$modules" = "yes" ; then
2197aa0d1f44SPaolo Bonzini    error_exit "static and modules are mutually incompatible"
2198aa0d1f44SPaolo Bonzini  fi
219940d6444eSAvi Kivityfi
220040d6444eSAvi Kivity
2201768b7855SEmilio G. Cota# Unconditional check for compiler __thread support
2202768b7855SEmilio G. Cota  cat > $TMPC << EOF
2203768b7855SEmilio G. Cotastatic __thread int tls_var;
2204768b7855SEmilio G. Cotaint main(void) { return tls_var; }
2205768b7855SEmilio G. CotaEOF
2206768b7855SEmilio G. Cota
2207768b7855SEmilio G. Cotaif ! compile_prog "-Werror" "" ; then
2208768b7855SEmilio G. Cota    error_exit "Your compiler does not support the __thread specifier for " \
2209768b7855SEmilio G. Cota	"Thread-Local Storage (TLS). Please upgrade to a version that does."
2210768b7855SEmilio G. Cotafi
2211768b7855SEmilio G. Cota
221240d6444eSAvi Kivitycat > $TMPC << EOF
221321d4a791SAvi Kivity
221421d4a791SAvi Kivity#ifdef __linux__
221521d4a791SAvi Kivity#  define THREAD __thread
221621d4a791SAvi Kivity#else
221721d4a791SAvi Kivity#  define THREAD
221821d4a791SAvi Kivity#endif
221921d4a791SAvi Kivitystatic THREAD int tls_var;
222021d4a791SAvi Kivityint main(void) { return tls_var; }
222140d6444eSAvi KivityEOF
2222b2634124SRichard Henderson
2223b2634124SRichard Henderson# Check we support --no-pie first; we will need this for building ROMs.
2224412aeacdSAlex Bennéeif compile_prog "-Werror -fno-pie" "-no-pie"; then
2225412aeacdSAlex Bennée  CFLAGS_NOPIE="-fno-pie"
2226412aeacdSAlex Bennéefi
2227412aeacdSAlex Bennée
222812781462SRichard Hendersonif test "$static" = "yes"; then
2229eca7a8e6SRichard Henderson  if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then
22305770e8afSPaolo Bonzini    CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
223112781462SRichard Henderson    QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS"
223212781462SRichard Henderson    pie="yes"
223312781462SRichard Henderson  elif test "$pie" = "yes"; then
223412781462SRichard Henderson    error_exit "-static-pie not available due to missing toolchain support"
223512781462SRichard Henderson  else
223612781462SRichard Henderson    QEMU_LDFLAGS="-static $QEMU_LDFLAGS"
223712781462SRichard Henderson    pie="no"
223812781462SRichard Henderson  fi
223912781462SRichard Hendersonelif test "$pie" = "no"; then
22405770e8afSPaolo Bonzini  CONFIGURE_CFLAGS="$CFLAGS_NOPIE $CONFIGURE_CFLAGS"
2241eca7a8e6SRichard Hendersonelif compile_prog "-Werror -fPIE -DPIE" "-pie"; then
22425770e8afSPaolo Bonzini  CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
22435770e8afSPaolo Bonzini  CONFIGURE_LDFLAGS="-pie $CONFIGURE_LDFLAGS"
224440d6444eSAvi Kivity  pie="yes"
22452c674109SRichard Hendersonelif test "$pie" = "yes"; then
224676ad07a4SPeter Maydell  error_exit "PIE not available due to missing toolchain support"
224740d6444eSAvi Kivityelse
224840d6444eSAvi Kivity  echo "Disabling PIE due to missing toolchain support"
224940d6444eSAvi Kivity  pie="no"
225040d6444eSAvi Kivityfi
225140d6444eSAvi Kivity
2252e6cbd751SRichard Henderson# Detect support for PT_GNU_RELRO + DT_BIND_NOW.
2253e6cbd751SRichard Henderson# The combination is known as "full relro", because .got.plt is read-only too.
2254e6cbd751SRichard Hendersonif compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
2255e6cbd751SRichard Henderson  QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS"
2256e6cbd751SRichard Hendersonfi
2257e6cbd751SRichard Henderson
225809dada40SPaolo Bonzini##########################################
225909dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains
226009dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit
226109dada40SPaolo Bonzini# specification is necessary
226209dada40SPaolo Bonzini
226309dada40SPaolo Bonziniif test "$cpu" = "i386"; then
226409dada40SPaolo Bonzini  cat > $TMPC << EOF
226509dada40SPaolo Bonzinistatic int sfaa(int *ptr)
226609dada40SPaolo Bonzini{
226709dada40SPaolo Bonzini  return __sync_fetch_and_and(ptr, 0);
226809dada40SPaolo Bonzini}
226909dada40SPaolo Bonzini
227009dada40SPaolo Bonziniint main(void)
227109dada40SPaolo Bonzini{
227209dada40SPaolo Bonzini  int val = 42;
22731405b629SStefan Weil  val = __sync_val_compare_and_swap(&val, 0, 1);
227409dada40SPaolo Bonzini  sfaa(&val);
227509dada40SPaolo Bonzini  return val;
227609dada40SPaolo Bonzini}
227709dada40SPaolo BonziniEOF
227809dada40SPaolo Bonzini  if ! compile_prog "" "" ; then
227909dada40SPaolo Bonzini    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
228009dada40SPaolo Bonzini  fi
228109dada40SPaolo Bonzinifi
228209dada40SPaolo Bonzini
228309dada40SPaolo Bonzini#########################################
2284ec530c81Sbellard# Solaris specific configure tool chain decisions
228509dada40SPaolo Bonzini
2286ec530c81Sbellardif test "$solaris" = "yes" ; then
22876792aa11SLoïc Minier  if has ar; then
22886792aa11SLoïc Minier    :
22896792aa11SLoïc Minier  else
2290ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
229176ad07a4SPeter Maydell      error_exit "No path includes ar" \
229276ad07a4SPeter Maydell          "Add /usr/ccs/bin to your path and rerun configure"
2293ec530c81Sbellard    fi
229476ad07a4SPeter Maydell    error_exit "No path includes ar"
2295ec530c81Sbellard  fi
2296ec530c81Sbellardfi
2297ec530c81Sbellard
229856267b62SPhilippe Mathieu-Daudéif test "$tcg" = "enabled"; then
229956267b62SPhilippe Mathieu-Daudé    git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
230056267b62SPhilippe Mathieu-Daudé    git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
230156267b62SPhilippe Mathieu-Daudéfi
230256267b62SPhilippe Mathieu-Daudé
2303afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then
2304fdb75aefSPaolo Bonzini    default_targets=yes
2305d880a3baSPaolo Bonzini    for target in $default_target_list; do
2306d880a3baSPaolo Bonzini        target_list="$target_list $target"
2307d880a3baSPaolo Bonzini    done
2308d880a3baSPaolo Bonzini    target_list="${target_list# }"
2309121afa9eSAnthony Liguorielse
2310fdb75aefSPaolo Bonzini    default_targets=no
231189138857SStefan Weil    target_list=$(echo "$target_list" | sed -e 's/,/ /g')
2312d880a3baSPaolo Bonzini    for target in $target_list; do
231325b48338SPeter Maydell        # Check that we recognised the target name; this allows a more
231425b48338SPeter Maydell        # friendly error message than if we let it fall through.
231525b48338SPeter Maydell        case " $default_target_list " in
231625b48338SPeter Maydell            *" $target "*)
231725b48338SPeter Maydell                ;;
231825b48338SPeter Maydell            *)
231925b48338SPeter Maydell                error_exit "Unknown target name '$target'"
232025b48338SPeter Maydell                ;;
232125b48338SPeter Maydell        esac
232225b48338SPeter Maydell    done
2323d880a3baSPaolo Bonzinifi
232425b48338SPeter Maydell
2325fdb75aefSPaolo Bonzinifor target in $target_list; do
2326fdb75aefSPaolo Bonzini    # if a deprecated target is enabled we note it here
2327fdb75aefSPaolo Bonzini    if echo "$deprecated_targets_list" | grep -q "$target"; then
2328fdb75aefSPaolo Bonzini        add_to deprecated_features $target
2329fdb75aefSPaolo Bonzini    fi
2330fdb75aefSPaolo Bonzinidone
2331fdb75aefSPaolo Bonzini
2332f55fe278SPaolo Bonzini# see if system emulation was really requested
2333f55fe278SPaolo Bonzinicase " $target_list " in
2334f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
2335f55fe278SPaolo Bonzini  ;;
2336f55fe278SPaolo Bonzini  *) softmmu=no
2337f55fe278SPaolo Bonzini  ;;
2338f55fe278SPaolo Bonziniesac
23395327cf48Sbellard
2340249247c9SJuan Quintelafeature_not_found() {
2341249247c9SJuan Quintela  feature=$1
234221684af0SStewart Smith  remedy=$2
2343249247c9SJuan Quintela
234476ad07a4SPeter Maydell  error_exit "User requested feature $feature" \
234521684af0SStewart Smith      "configure was not able to find it." \
234621684af0SStewart Smith      "$remedy"
2347249247c9SJuan Quintela}
2348249247c9SJuan Quintela
23497d13299dSbellard# ---
23507d13299dSbellard# big/little endian test
23517d13299dSbellardcat > $TMPC << EOF
235261cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
235361cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
235461cc919fSMike Frysingerextern int foo(short *, short *);
235561cc919fSMike Frysingerint main(int argc, char *argv[]) {
235661cc919fSMike Frysinger    return foo(big_endian, little_endian);
23577d13299dSbellard}
23587d13299dSbellardEOF
23597d13299dSbellard
236061cc919fSMike Frysingerif compile_object ; then
236112f15c91SAlice Frosi    if strings -a $TMPO | grep -q BiGeNdIaN ; then
236261cc919fSMike Frysinger        bigendian="yes"
236312f15c91SAlice Frosi    elif strings -a $TMPO | grep -q LiTtLeEnDiAn ; then
236461cc919fSMike Frysinger        bigendian="no"
23657d13299dSbellard    else
23667d13299dSbellard        echo big/little test failed
23677d13299dSbellard    fi
23687d13299dSbellardelse
236961cc919fSMike Frysinger    echo big/little test failed
23707d13299dSbellardfi
23717d13299dSbellard
2372b0a47e79SJuan Quintela##########################################
2373e10ee3f5SPhilippe Mathieu-Daudé# system tools
2374e10ee3f5SPhilippe Mathieu-Daudéif test -z "$want_tools"; then
2375e10ee3f5SPhilippe Mathieu-Daudé    if test "$softmmu" = "no"; then
2376e10ee3f5SPhilippe Mathieu-Daudé        want_tools=no
2377e10ee3f5SPhilippe Mathieu-Daudé    else
2378e10ee3f5SPhilippe Mathieu-Daudé        want_tools=yes
2379e10ee3f5SPhilippe Mathieu-Daudé    fi
2380e10ee3f5SPhilippe Mathieu-Daudéfi
2381e10ee3f5SPhilippe Mathieu-Daudé
2382e10ee3f5SPhilippe Mathieu-Daudé##########################################
238390520ee4SPhilippe Mathieu-Daudé# Disable features only meaningful for system-mode emulation
238490520ee4SPhilippe Mathieu-Daudéif test "$softmmu" = "no"; then
238590520ee4SPhilippe Mathieu-Daudé    audio_drv_list=""
238690520ee4SPhilippe Mathieu-Daudéfi
238790520ee4SPhilippe Mathieu-Daudé
238890520ee4SPhilippe Mathieu-Daudé##########################################
2389015a33bdSGonglei# L2TPV3 probe
2390015a33bdSGonglei
2391015a33bdSGongleicat > $TMPC <<EOF
2392015a33bdSGonglei#include <sys/socket.h>
2393bff6cb72SMichael Tokarev#include <linux/ip.h>
2394015a33bdSGongleiint main(void) { return sizeof(struct mmsghdr); }
2395015a33bdSGongleiEOF
2396015a33bdSGongleiif compile_prog "" "" ; then
2397015a33bdSGonglei  l2tpv3=yes
2398015a33bdSGongleielse
2399015a33bdSGonglei  l2tpv3=no
2400015a33bdSGongleifi
2401015a33bdSGonglei
2402195588ccSDavid CARLIERcat > $TMPC <<EOF
2403195588ccSDavid CARLIER#include <sys/mman.h>
2404195588ccSDavid CARLIERint main(int argc, char *argv[]) {
2405195588ccSDavid CARLIER    return mlockall(MCL_FUTURE);
2406195588ccSDavid CARLIER}
2407195588ccSDavid CARLIEREOF
2408195588ccSDavid CARLIERif compile_prog "" "" ; then
2409195588ccSDavid CARLIER  have_mlockall=yes
2410195588ccSDavid CARLIERelse
2411195588ccSDavid CARLIER  have_mlockall=no
2412195588ccSDavid CARLIERfi
2413195588ccSDavid CARLIER
2414299e6f19SPaolo Bonzini#########################################
2415299e6f19SPaolo Bonzini# vhost interdependencies and host support
2416299e6f19SPaolo Bonzini
2417299e6f19SPaolo Bonzini# vhost backends
2418d88618f7SStefan Hajnocziif test "$vhost_user" = "yes" && test "$linux" != "yes"; then
2419d88618f7SStefan Hajnoczi  error_exit "vhost-user is only available on Linux"
2420299e6f19SPaolo Bonzinifi
2421108a6481SCindy Lutest "$vhost_vdpa" = "" && vhost_vdpa=$linux
2422108a6481SCindy Luif test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then
2423108a6481SCindy Lu  error_exit "vhost-vdpa is only available on Linux"
2424108a6481SCindy Lufi
2425299e6f19SPaolo Bonzinitest "$vhost_kernel" = "" && vhost_kernel=$linux
2426299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then
2427299e6f19SPaolo Bonzini  error_exit "vhost-kernel is only available on Linux"
2428299e6f19SPaolo Bonzinifi
2429299e6f19SPaolo Bonzini
2430299e6f19SPaolo Bonzini# vhost-kernel devices
2431299e6f19SPaolo Bonzinitest "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel
2432299e6f19SPaolo Bonziniif test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then
2433299e6f19SPaolo Bonzini  error_exit "--enable-vhost-scsi requires --enable-vhost-kernel"
2434299e6f19SPaolo Bonzinifi
2435299e6f19SPaolo Bonzinitest "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel
2436299e6f19SPaolo Bonziniif test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then
2437299e6f19SPaolo Bonzini  error_exit "--enable-vhost-vsock requires --enable-vhost-kernel"
2438299e6f19SPaolo Bonzinifi
2439299e6f19SPaolo Bonzini
2440299e6f19SPaolo Bonzini# vhost-user backends
2441299e6f19SPaolo Bonzinitest "$vhost_net_user" = "" && vhost_net_user=$vhost_user
2442299e6f19SPaolo Bonziniif test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then
2443299e6f19SPaolo Bonzini  error_exit "--enable-vhost-net-user requires --enable-vhost-user"
2444299e6f19SPaolo Bonzinifi
2445299e6f19SPaolo Bonzinitest "$vhost_crypto" = "" && vhost_crypto=$vhost_user
2446299e6f19SPaolo Bonziniif test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then
2447299e6f19SPaolo Bonzini  error_exit "--enable-vhost-crypto requires --enable-vhost-user"
2448299e6f19SPaolo Bonzinifi
244998fc1adaSDr. David Alan Gilberttest "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user
245098fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then
245198fc1adaSDr. David Alan Gilbert  error_exit "--enable-vhost-user-fs requires --enable-vhost-user"
245298fc1adaSDr. David Alan Gilbertfi
2453108a6481SCindy Lu#vhost-vdpa backends
2454108a6481SCindy Lutest "$vhost_net_vdpa" = "" && vhost_net_vdpa=$vhost_vdpa
2455108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" && test "$vhost_vdpa" = "no"; then
2456108a6481SCindy Lu  error_exit "--enable-vhost-net-vdpa requires --enable-vhost-vdpa"
2457108a6481SCindy Lufi
2458299e6f19SPaolo Bonzini
245940bc0ca9SLaurent Vivier# OR the vhost-kernel, vhost-vdpa and vhost-user values for simplicity
2460299e6f19SPaolo Bonziniif test "$vhost_net" = ""; then
2461299e6f19SPaolo Bonzini  test "$vhost_net_user" = "yes" && vhost_net=yes
246240bc0ca9SLaurent Vivier  test "$vhost_net_vdpa" = "yes" && vhost_net=yes
2463299e6f19SPaolo Bonzini  test "$vhost_kernel" = "yes" && vhost_net=yes
2464299e6f19SPaolo Bonzinifi
2465299e6f19SPaolo Bonzini
2466015a33bdSGonglei##########################################
2467779ab5e3SStefan Weil# pkg-config probe
2468779ab5e3SStefan Weil
2469779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then
247076ad07a4SPeter Maydell  error_exit "pkg-config binary '$pkg_config_exe' not found"
2471779ab5e3SStefan Weilfi
2472779ab5e3SStefan Weil
2473779ab5e3SStefan Weil##########################################
2474b0a47e79SJuan Quintela# NPTL probe
2475b0a47e79SJuan Quintela
247624cb36a6SPeter Maydellif test "$linux_user" = "yes"; then
2477bd0c5661Spbrook  cat > $TMPC <<EOF
2478bd0c5661Spbrook#include <sched.h>
247930813ceaSpbrook#include <linux/futex.h>
2480182eacc0SStefan Weilint main(void) {
2481bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
2482bd0c5661Spbrook#error bork
2483bd0c5661Spbrook#endif
2484182eacc0SStefan Weil  return 0;
2485bd0c5661Spbrook}
2486bd0c5661SpbrookEOF
248724cb36a6SPeter Maydell  if ! compile_object ; then
248821684af0SStewart Smith    feature_not_found "nptl" "Install glibc and linux kernel headers."
2489b0a47e79SJuan Quintela  fi
2490bd0c5661Spbrookfi
2491bd0c5661Spbrook
2492ac62922eSbalrog##########################################
2493e37630caSaliguori# xen probe
2494e37630caSaliguori
24951badb709SPaolo Bonziniif test "$xen" != "disabled" ; then
2496c1cdd9d5SJuergen Gross  # Check whether Xen library path is specified via --extra-ldflags to avoid
2497c1cdd9d5SJuergen Gross  # overriding this setting with pkg-config output. If not, try pkg-config
2498c1cdd9d5SJuergen Gross  # to obtain all needed flags.
2499c1cdd9d5SJuergen Gross
2500c1cdd9d5SJuergen Gross  if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2501c1cdd9d5SJuergen Gross     $pkg_config --exists xencontrol ; then
2502c1cdd9d5SJuergen Gross    xen_ctrl_version="$(printf '%d%02d%02d' \
2503c1cdd9d5SJuergen Gross      $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
25041badb709SPaolo Bonzini    xen=enabled
25055b6a8f43SMichael Tokarev    xen_pc="xencontrol xenstore xenforeignmemory xengnttab"
2506c1cdd9d5SJuergen Gross    xen_pc="$xen_pc xenevtchn xendevicemodel"
250758ea9a7aSAnthony PERARD    if $pkg_config --exists xentoolcore; then
250858ea9a7aSAnthony PERARD      xen_pc="$xen_pc xentoolcore"
250958ea9a7aSAnthony PERARD    fi
2510582ea95fSMarc-André Lureau    xen_cflags="$($pkg_config --cflags $xen_pc)"
2511582ea95fSMarc-André Lureau    xen_libs="$($pkg_config --libs $xen_pc)"
2512c1cdd9d5SJuergen Gross  else
2513c1cdd9d5SJuergen Gross
25145b6a8f43SMichael Tokarev    xen_libs="-lxenstore -lxenctrl"
2515d9506cabSAnthony PERARD    xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
2516d5b93ddfSAnthony PERARD
251750ced5b3SStefan Weil    # First we test whether Xen headers and libraries are available.
251850ced5b3SStefan Weil    # If no, we are done and there is no Xen support.
251950ced5b3SStefan Weil    # If yes, more tests are run to detect the Xen version.
252050ced5b3SStefan Weil
252150ced5b3SStefan Weil    # Xen (any)
252250ced5b3SStefan Weil    cat > $TMPC <<EOF
252350ced5b3SStefan Weil#include <xenctrl.h>
252450ced5b3SStefan Weilint main(void) {
252550ced5b3SStefan Weil  return 0;
252650ced5b3SStefan Weil}
252750ced5b3SStefan WeilEOF
252850ced5b3SStefan Weil    if ! compile_prog "" "$xen_libs" ; then
252950ced5b3SStefan Weil      # Xen not found
25301badb709SPaolo Bonzini      if test "$xen" = "enabled" ; then
253121684af0SStewart Smith        feature_not_found "xen" "Install xen devel"
253250ced5b3SStefan Weil      fi
25331badb709SPaolo Bonzini      xen=disabled
253450ced5b3SStefan Weil
2535d5b93ddfSAnthony PERARD    # Xen unstable
253669deef08SPeter Maydell    elif
253769deef08SPeter Maydell        cat > $TMPC <<EOF &&
25382cbf8903SRoss Lagerwall#undef XC_WANT_COMPAT_DEVICEMODEL_API
25392cbf8903SRoss Lagerwall#define __XEN_TOOLS__
25402cbf8903SRoss Lagerwall#include <xendevicemodel.h>
2541d3c49ebbSPaul Durrant#include <xenforeignmemory.h>
25422cbf8903SRoss Lagerwallint main(void) {
25432cbf8903SRoss Lagerwall  xendevicemodel_handle *xd;
2544d3c49ebbSPaul Durrant  xenforeignmemory_handle *xfmem;
25452cbf8903SRoss Lagerwall
25462cbf8903SRoss Lagerwall  xd = xendevicemodel_open(0, 0);
25472cbf8903SRoss Lagerwall  xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
25482cbf8903SRoss Lagerwall
2549d3c49ebbSPaul Durrant  xfmem = xenforeignmemory_open(0, 0);
2550d3c49ebbSPaul Durrant  xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
2551d3c49ebbSPaul Durrant
25522cbf8903SRoss Lagerwall  return 0;
25532cbf8903SRoss Lagerwall}
25542cbf8903SRoss LagerwallEOF
25552cbf8903SRoss Lagerwall        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
25562cbf8903SRoss Lagerwall      then
25572cbf8903SRoss Lagerwall      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
25582cbf8903SRoss Lagerwall      xen_ctrl_version=41100
25591badb709SPaolo Bonzini      xen=enabled
25602cbf8903SRoss Lagerwall    elif
25612cbf8903SRoss Lagerwall        cat > $TMPC <<EOF &&
25625ba3d756SIgor Druzhinin#undef XC_WANT_COMPAT_MAP_FOREIGN_API
25635ba3d756SIgor Druzhinin#include <xenforeignmemory.h>
256458ea9a7aSAnthony PERARD#include <xentoolcore.h>
25655ba3d756SIgor Druzhininint main(void) {
25665ba3d756SIgor Druzhinin  xenforeignmemory_handle *xfmem;
25675ba3d756SIgor Druzhinin
25685ba3d756SIgor Druzhinin  xfmem = xenforeignmemory_open(0, 0);
25695ba3d756SIgor Druzhinin  xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
257058ea9a7aSAnthony PERARD  xentoolcore_restrict_all(0);
25715ba3d756SIgor Druzhinin
25725ba3d756SIgor Druzhinin  return 0;
25735ba3d756SIgor Druzhinin}
25745ba3d756SIgor DruzhininEOF
257558ea9a7aSAnthony PERARD        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
25765ba3d756SIgor Druzhinin      then
257758ea9a7aSAnthony PERARD      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
25785ba3d756SIgor Druzhinin      xen_ctrl_version=41000
25791badb709SPaolo Bonzini      xen=enabled
25805ba3d756SIgor Druzhinin    elif
25815ba3d756SIgor Druzhinin        cat > $TMPC <<EOF &&
2582da8090ccSPaul Durrant#undef XC_WANT_COMPAT_DEVICEMODEL_API
2583da8090ccSPaul Durrant#define __XEN_TOOLS__
2584da8090ccSPaul Durrant#include <xendevicemodel.h>
2585da8090ccSPaul Durrantint main(void) {
2586da8090ccSPaul Durrant  xendevicemodel_handle *xd;
2587da8090ccSPaul Durrant
2588da8090ccSPaul Durrant  xd = xendevicemodel_open(0, 0);
2589da8090ccSPaul Durrant  xendevicemodel_close(xd);
2590da8090ccSPaul Durrant
2591da8090ccSPaul Durrant  return 0;
2592da8090ccSPaul Durrant}
2593da8090ccSPaul DurrantEOF
2594da8090ccSPaul Durrant        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2595da8090ccSPaul Durrant      then
2596da8090ccSPaul Durrant      xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2597f1167ee6SJuergen Gross      xen_ctrl_version=40900
25981badb709SPaolo Bonzini      xen=enabled
2599da8090ccSPaul Durrant    elif
2600da8090ccSPaul Durrant        cat > $TMPC <<EOF &&
26015eeb39c2SIan Campbell/*
26025eeb39c2SIan Campbell * If we have stable libs the we don't want the libxc compat
26035eeb39c2SIan Campbell * layers, regardless of what CFLAGS we may have been given.
2604b6eb9b45SPaulina Szubarczyk *
2605b6eb9b45SPaulina Szubarczyk * Also, check if xengnttab_grant_copy_segment_t is defined and
2606b6eb9b45SPaulina Szubarczyk * grant copy operation is implemented.
2607b6eb9b45SPaulina Szubarczyk */
2608b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_EVTCHN_API
2609b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_GNTTAB_API
2610b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2611b6eb9b45SPaulina Szubarczyk#include <xenctrl.h>
2612b6eb9b45SPaulina Szubarczyk#include <xenstore.h>
2613b6eb9b45SPaulina Szubarczyk#include <xenevtchn.h>
2614b6eb9b45SPaulina Szubarczyk#include <xengnttab.h>
2615b6eb9b45SPaulina Szubarczyk#include <xenforeignmemory.h>
2616b6eb9b45SPaulina Szubarczyk#include <stdint.h>
2617b6eb9b45SPaulina Szubarczyk#include <xen/hvm/hvm_info_table.h>
2618b6eb9b45SPaulina Szubarczyk#if !defined(HVM_MAX_VCPUS)
2619b6eb9b45SPaulina Szubarczyk# error HVM_MAX_VCPUS not defined
2620b6eb9b45SPaulina Szubarczyk#endif
2621b6eb9b45SPaulina Szubarczykint main(void) {
2622b6eb9b45SPaulina Szubarczyk  xc_interface *xc = NULL;
2623b6eb9b45SPaulina Szubarczyk  xenforeignmemory_handle *xfmem;
2624b6eb9b45SPaulina Szubarczyk  xenevtchn_handle *xe;
2625b6eb9b45SPaulina Szubarczyk  xengnttab_handle *xg;
2626b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy_segment_t* seg = NULL;
2627b6eb9b45SPaulina Szubarczyk
2628b6eb9b45SPaulina Szubarczyk  xs_daemon_open();
2629b6eb9b45SPaulina Szubarczyk
2630b6eb9b45SPaulina Szubarczyk  xc = xc_interface_open(0, 0, 0);
2631b6eb9b45SPaulina Szubarczyk  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2632b6eb9b45SPaulina Szubarczyk  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2633b6eb9b45SPaulina Szubarczyk  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2634b6eb9b45SPaulina Szubarczyk  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2635b6eb9b45SPaulina Szubarczyk
2636b6eb9b45SPaulina Szubarczyk  xfmem = xenforeignmemory_open(0, 0);
2637b6eb9b45SPaulina Szubarczyk  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2638b6eb9b45SPaulina Szubarczyk
2639b6eb9b45SPaulina Szubarczyk  xe = xenevtchn_open(0, 0);
2640b6eb9b45SPaulina Szubarczyk  xenevtchn_fd(xe);
2641b6eb9b45SPaulina Szubarczyk
2642b6eb9b45SPaulina Szubarczyk  xg = xengnttab_open(0, 0);
2643b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy(xg, 0, seg);
2644b6eb9b45SPaulina Szubarczyk
2645b6eb9b45SPaulina Szubarczyk  return 0;
2646b6eb9b45SPaulina Szubarczyk}
2647b6eb9b45SPaulina SzubarczykEOF
2648b6eb9b45SPaulina Szubarczyk        compile_prog "" "$xen_libs $xen_stable_libs"
2649b6eb9b45SPaulina Szubarczyk      then
2650f1167ee6SJuergen Gross      xen_ctrl_version=40800
26511badb709SPaolo Bonzini      xen=enabled
2652b6eb9b45SPaulina Szubarczyk    elif
2653b6eb9b45SPaulina Szubarczyk        cat > $TMPC <<EOF &&
2654b6eb9b45SPaulina Szubarczyk/*
2655b6eb9b45SPaulina Szubarczyk * If we have stable libs the we don't want the libxc compat
2656b6eb9b45SPaulina Szubarczyk * layers, regardless of what CFLAGS we may have been given.
26575eeb39c2SIan Campbell */
26585eeb39c2SIan Campbell#undef XC_WANT_COMPAT_EVTCHN_API
26595eeb39c2SIan Campbell#undef XC_WANT_COMPAT_GNTTAB_API
26605eeb39c2SIan Campbell#undef XC_WANT_COMPAT_MAP_FOREIGN_API
26615eeb39c2SIan Campbell#include <xenctrl.h>
26625eeb39c2SIan Campbell#include <xenstore.h>
26635eeb39c2SIan Campbell#include <xenevtchn.h>
26645eeb39c2SIan Campbell#include <xengnttab.h>
26655eeb39c2SIan Campbell#include <xenforeignmemory.h>
26665eeb39c2SIan Campbell#include <stdint.h>
26675eeb39c2SIan Campbell#include <xen/hvm/hvm_info_table.h>
26685eeb39c2SIan Campbell#if !defined(HVM_MAX_VCPUS)
26695eeb39c2SIan Campbell# error HVM_MAX_VCPUS not defined
26705eeb39c2SIan Campbell#endif
26715eeb39c2SIan Campbellint main(void) {
26725eeb39c2SIan Campbell  xc_interface *xc = NULL;
26735eeb39c2SIan Campbell  xenforeignmemory_handle *xfmem;
26745eeb39c2SIan Campbell  xenevtchn_handle *xe;
26755eeb39c2SIan Campbell  xengnttab_handle *xg;
26765eeb39c2SIan Campbell
26775eeb39c2SIan Campbell  xs_daemon_open();
26785eeb39c2SIan Campbell
26795eeb39c2SIan Campbell  xc = xc_interface_open(0, 0, 0);
26805eeb39c2SIan Campbell  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
26815eeb39c2SIan Campbell  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
26825eeb39c2SIan Campbell  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
26835eeb39c2SIan Campbell  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
26845eeb39c2SIan Campbell
26855eeb39c2SIan Campbell  xfmem = xenforeignmemory_open(0, 0);
26865eeb39c2SIan Campbell  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
26875eeb39c2SIan Campbell
26885eeb39c2SIan Campbell  xe = xenevtchn_open(0, 0);
26895eeb39c2SIan Campbell  xenevtchn_fd(xe);
26905eeb39c2SIan Campbell
26915eeb39c2SIan Campbell  xg = xengnttab_open(0, 0);
26925eeb39c2SIan Campbell  xengnttab_map_grant_ref(xg, 0, 0, 0);
26935eeb39c2SIan Campbell
26945eeb39c2SIan Campbell  return 0;
26955eeb39c2SIan Campbell}
26965eeb39c2SIan CampbellEOF
26975eeb39c2SIan Campbell        compile_prog "" "$xen_libs $xen_stable_libs"
26985eeb39c2SIan Campbell      then
2699f1167ee6SJuergen Gross      xen_ctrl_version=40701
27001badb709SPaolo Bonzini      xen=enabled
2701cdadde39SRoger Pau Monne
2702cdadde39SRoger Pau Monne    # Xen 4.6
2703cdadde39SRoger Pau Monne    elif
2704cdadde39SRoger Pau Monne        cat > $TMPC <<EOF &&
2705cdadde39SRoger Pau Monne#include <xenctrl.h>
2706e108a3c1SAnthony PERARD#include <xenstore.h>
2707d5b93ddfSAnthony PERARD#include <stdint.h>
2708d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
2709d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
2710d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
2711d5b93ddfSAnthony PERARD#endif
2712d5b93ddfSAnthony PERARDint main(void) {
2713d5b93ddfSAnthony PERARD  xc_interface *xc;
2714d5b93ddfSAnthony PERARD  xs_daemon_open();
2715d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
2716d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2717d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
2718b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
27198688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2720d8b441a3SJan Beulich  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
272120a544c7SKonrad Rzeszutek Wilk  xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2722d8b441a3SJan Beulich  return 0;
2723d8b441a3SJan Beulich}
2724d8b441a3SJan BeulichEOF
2725d8b441a3SJan Beulich        compile_prog "" "$xen_libs"
2726d8b441a3SJan Beulich      then
2727f1167ee6SJuergen Gross      xen_ctrl_version=40600
27281badb709SPaolo Bonzini      xen=enabled
2729d8b441a3SJan Beulich
2730d8b441a3SJan Beulich    # Xen 4.5
2731d8b441a3SJan Beulich    elif
2732d8b441a3SJan Beulich        cat > $TMPC <<EOF &&
2733d8b441a3SJan Beulich#include <xenctrl.h>
2734d8b441a3SJan Beulich#include <xenstore.h>
2735d8b441a3SJan Beulich#include <stdint.h>
2736d8b441a3SJan Beulich#include <xen/hvm/hvm_info_table.h>
2737d8b441a3SJan Beulich#if !defined(HVM_MAX_VCPUS)
2738d8b441a3SJan Beulich# error HVM_MAX_VCPUS not defined
2739d8b441a3SJan Beulich#endif
2740d8b441a3SJan Beulichint main(void) {
2741d8b441a3SJan Beulich  xc_interface *xc;
2742d8b441a3SJan Beulich  xs_daemon_open();
2743d8b441a3SJan Beulich  xc = xc_interface_open(0, 0, 0);
2744d8b441a3SJan Beulich  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2745d8b441a3SJan Beulich  xc_gnttab_open(NULL, 0);
2746d8b441a3SJan Beulich  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2747d8b441a3SJan Beulich  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
27483996e85cSPaul Durrant  xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
27493996e85cSPaul Durrant  return 0;
27503996e85cSPaul Durrant}
27513996e85cSPaul DurrantEOF
27523996e85cSPaul Durrant        compile_prog "" "$xen_libs"
27533996e85cSPaul Durrant      then
2754f1167ee6SJuergen Gross      xen_ctrl_version=40500
27551badb709SPaolo Bonzini      xen=enabled
27563996e85cSPaul Durrant
27573996e85cSPaul Durrant    elif
27583996e85cSPaul Durrant        cat > $TMPC <<EOF &&
27593996e85cSPaul Durrant#include <xenctrl.h>
27603996e85cSPaul Durrant#include <xenstore.h>
27613996e85cSPaul Durrant#include <stdint.h>
27623996e85cSPaul Durrant#include <xen/hvm/hvm_info_table.h>
27633996e85cSPaul Durrant#if !defined(HVM_MAX_VCPUS)
27643996e85cSPaul Durrant# error HVM_MAX_VCPUS not defined
27653996e85cSPaul Durrant#endif
27663996e85cSPaul Durrantint main(void) {
27673996e85cSPaul Durrant  xc_interface *xc;
27683996e85cSPaul Durrant  xs_daemon_open();
27693996e85cSPaul Durrant  xc = xc_interface_open(0, 0, 0);
27703996e85cSPaul Durrant  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
27713996e85cSPaul Durrant  xc_gnttab_open(NULL, 0);
27723996e85cSPaul Durrant  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
27733996e85cSPaul Durrant  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
27748688e065SStefano Stabellini  return 0;
27758688e065SStefano Stabellini}
27768688e065SStefano StabelliniEOF
27778688e065SStefano Stabellini        compile_prog "" "$xen_libs"
277869deef08SPeter Maydell      then
2779f1167ee6SJuergen Gross      xen_ctrl_version=40200
27801badb709SPaolo Bonzini      xen=enabled
27818688e065SStefano Stabellini
2782e37630caSaliguori    else
27831badb709SPaolo Bonzini      if test "$xen" = "enabled" ; then
2784edfb07edSIan Campbell        feature_not_found "xen (unsupported version)" \
2785edfb07edSIan Campbell                          "Install a supported xen (xen 4.2 or newer)"
2786fc321b4bSJuan Quintela      fi
27871badb709SPaolo Bonzini      xen=disabled
2788e37630caSaliguori    fi
2789d5b93ddfSAnthony PERARD
27901badb709SPaolo Bonzini    if test "$xen" = enabled; then
2791f1167ee6SJuergen Gross      if test $xen_ctrl_version -ge 40701  ; then
2792582ea95fSMarc-André Lureau        xen_libs="$xen_libs $xen_stable_libs "
27935eeb39c2SIan Campbell      fi
2794d5b93ddfSAnthony PERARD    fi
2795e37630caSaliguori  fi
2796c1cdd9d5SJuergen Grossfi
2797e37630caSaliguori
2798d661d9a4SJustin Terry (VM)##########################################
27992da776dbSMichael R. Hines# RDMA needs OpenFabrics libraries
28002da776dbSMichael R. Hinesif test "$rdma" != "no" ; then
28012da776dbSMichael R. Hines  cat > $TMPC <<EOF
28022da776dbSMichael R. Hines#include <rdma/rdma_cma.h>
28032da776dbSMichael R. Hinesint main(void) { return 0; }
28042da776dbSMichael R. HinesEOF
2805ef6d4ccdSYuval Shaia  rdma_libs="-lrdmacm -libverbs -libumad"
28062da776dbSMichael R. Hines  if compile_prog "" "$rdma_libs" ; then
28072da776dbSMichael R. Hines    rdma="yes"
28082da776dbSMichael R. Hines  else
28092da776dbSMichael R. Hines    if test "$rdma" = "yes" ; then
28102da776dbSMichael R. Hines        error_exit \
2811ef6d4ccdSYuval Shaia            " OpenFabrics librdmacm/libibverbs/libibumad not present." \
28122da776dbSMichael R. Hines            " Your options:" \
2813ef6d4ccdSYuval Shaia            "  (1) Fast: Install infiniband packages (devel) from your distro." \
28142da776dbSMichael R. Hines            "  (2) Cleanest: Install libraries from www.openfabrics.org" \
28152da776dbSMichael R. Hines            "  (3) Also: Install softiwarp if you don't have RDMA hardware"
28162da776dbSMichael R. Hines    fi
28172da776dbSMichael R. Hines    rdma="no"
28182da776dbSMichael R. Hines  fi
28192da776dbSMichael R. Hinesfi
28202da776dbSMichael R. Hines
282121ab34c9SMarcel Apfelbaum##########################################
282221ab34c9SMarcel Apfelbaum# PVRDMA detection
282321ab34c9SMarcel Apfelbaum
282421ab34c9SMarcel Apfelbaumcat > $TMPC <<EOF &&
282521ab34c9SMarcel Apfelbaum#include <sys/mman.h>
282621ab34c9SMarcel Apfelbaum
282721ab34c9SMarcel Apfelbaumint
282821ab34c9SMarcel Apfelbaummain(void)
282921ab34c9SMarcel Apfelbaum{
283021ab34c9SMarcel Apfelbaum    char buf = 0;
283121ab34c9SMarcel Apfelbaum    void *addr = &buf;
283221ab34c9SMarcel Apfelbaum    addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED);
283321ab34c9SMarcel Apfelbaum
283421ab34c9SMarcel Apfelbaum    return 0;
283521ab34c9SMarcel Apfelbaum}
283621ab34c9SMarcel ApfelbaumEOF
283721ab34c9SMarcel Apfelbaum
283821ab34c9SMarcel Apfelbaumif test "$rdma" = "yes" ; then
283921ab34c9SMarcel Apfelbaum    case "$pvrdma" in
284021ab34c9SMarcel Apfelbaum    "")
284121ab34c9SMarcel Apfelbaum        if compile_prog "" ""; then
284221ab34c9SMarcel Apfelbaum            pvrdma="yes"
284321ab34c9SMarcel Apfelbaum        else
284421ab34c9SMarcel Apfelbaum            pvrdma="no"
284521ab34c9SMarcel Apfelbaum        fi
284621ab34c9SMarcel Apfelbaum        ;;
284721ab34c9SMarcel Apfelbaum    "yes")
284821ab34c9SMarcel Apfelbaum        if ! compile_prog "" ""; then
284921ab34c9SMarcel Apfelbaum            error_exit "PVRDMA is not supported since mremap is not implemented"
285021ab34c9SMarcel Apfelbaum        fi
285121ab34c9SMarcel Apfelbaum        pvrdma="yes"
285221ab34c9SMarcel Apfelbaum        ;;
285321ab34c9SMarcel Apfelbaum    "no")
285421ab34c9SMarcel Apfelbaum        pvrdma="no"
285521ab34c9SMarcel Apfelbaum        ;;
285621ab34c9SMarcel Apfelbaum    esac
285721ab34c9SMarcel Apfelbaumelse
285821ab34c9SMarcel Apfelbaum    if test "$pvrdma" = "yes" ; then
285921ab34c9SMarcel Apfelbaum        error_exit "PVRDMA requires rdma suppport"
286021ab34c9SMarcel Apfelbaum    fi
286121ab34c9SMarcel Apfelbaum    pvrdma="no"
286221ab34c9SMarcel Apfelbaumfi
286395c6bff3SBenoît Canet
2864ee108585SYuval Shaia# Let's see if enhanced reg_mr is supported
2865ee108585SYuval Shaiaif test "$pvrdma" = "yes" ; then
2866ee108585SYuval Shaia
2867ee108585SYuval Shaiacat > $TMPC <<EOF &&
2868ee108585SYuval Shaia#include <infiniband/verbs.h>
2869ee108585SYuval Shaia
2870ee108585SYuval Shaiaint
2871ee108585SYuval Shaiamain(void)
2872ee108585SYuval Shaia{
2873ee108585SYuval Shaia    struct ibv_mr *mr;
2874ee108585SYuval Shaia    struct ibv_pd *pd = NULL;
2875ee108585SYuval Shaia    size_t length = 10;
2876ee108585SYuval Shaia    uint64_t iova = 0;
2877ee108585SYuval Shaia    int access = 0;
2878ee108585SYuval Shaia    void *addr = NULL;
2879ee108585SYuval Shaia
2880ee108585SYuval Shaia    mr = ibv_reg_mr_iova(pd, addr, length, iova, access);
2881ee108585SYuval Shaia
2882ee108585SYuval Shaia    ibv_dereg_mr(mr);
2883ee108585SYuval Shaia
2884ee108585SYuval Shaia    return 0;
2885ee108585SYuval Shaia}
2886ee108585SYuval ShaiaEOF
2887ee108585SYuval Shaia    if ! compile_prog "" "-libverbs"; then
2888ee108585SYuval Shaia        QEMU_CFLAGS="$QEMU_CFLAGS -DLEGACY_RDMA_REG_MR"
2889ee108585SYuval Shaia    fi
2890ee108585SYuval Shaiafi
2891ee108585SYuval Shaia
289295c6bff3SBenoît Canet##########################################
2893c1bb86cdSEric Blake# xfsctl() probe, used for file-posix.c
2894dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
2895dce512deSChristoph Hellwig  cat > $TMPC << EOF
2896ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
2897dce512deSChristoph Hellwig#include <xfs/xfs.h>
2898dce512deSChristoph Hellwigint main(void)
2899dce512deSChristoph Hellwig{
2900dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
2901dce512deSChristoph Hellwig    return 0;
2902dce512deSChristoph Hellwig}
2903dce512deSChristoph HellwigEOF
2904dce512deSChristoph Hellwig  if compile_prog "" "" ; then
2905dce512deSChristoph Hellwig    xfs="yes"
2906dce512deSChristoph Hellwig  else
2907dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
2908e3a6e0daSzhaolichang      feature_not_found "xfs" "Install xfsprogs/xfslibs devel"
2909dce512deSChristoph Hellwig    fi
2910dce512deSChristoph Hellwig    xfs=no
2911dce512deSChristoph Hellwig  fi
2912dce512deSChristoph Hellwigfi
2913dce512deSChristoph Hellwig
2914dce512deSChristoph Hellwig##########################################
29158a16d273Sths# vde libraries probe
2916dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
29174baae0acSJuan Quintela  vde_libs="-lvdeplug"
29188a16d273Sths  cat > $TMPC << EOF
29198a16d273Sths#include <libvdeplug.h>
29204a7f0e06Spbrookint main(void)
29214a7f0e06Spbrook{
29224a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
2923fea08e08SPeter Maydell    char s[] = "";
2924fea08e08SPeter Maydell    vde_open(s, s, &a);
29254a7f0e06Spbrook    return 0;
29264a7f0e06Spbrook}
29278a16d273SthsEOF
292852166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
29294baae0acSJuan Quintela    vde=yes
2930dfb278bdSJuan Quintela  else
2931dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
293221684af0SStewart Smith      feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
2933dfb278bdSJuan Quintela    fi
2934dfb278bdSJuan Quintela    vde=no
29358a16d273Sths  fi
29368a16d273Sthsfi
29378a16d273Sths
29388a16d273Sths##########################################
29390a985b37SVincenzo Maffione# netmap support probe
29400a985b37SVincenzo Maffione# Apart from looking for netmap headers, we make sure that the host API version
29410a985b37SVincenzo Maffione# supports the netmap backend (>=11). The upper bound (15) is meant to simulate
29420a985b37SVincenzo Maffione# a minor/major version number. Minor new features will be marked with values up
29430a985b37SVincenzo Maffione# to 15, and if something happens that requires a change to the backend we will
29440a985b37SVincenzo Maffione# move above 15, submit the backend fixes and modify this two bounds.
294558952137SVincenzo Maffioneif test "$netmap" != "no" ; then
294658952137SVincenzo Maffione  cat > $TMPC << EOF
294758952137SVincenzo Maffione#include <inttypes.h>
294858952137SVincenzo Maffione#include <net/if.h>
294958952137SVincenzo Maffione#include <net/netmap.h>
295058952137SVincenzo Maffione#include <net/netmap_user.h>
29510a985b37SVincenzo Maffione#if (NETMAP_API < 11) || (NETMAP_API > 15)
29520a985b37SVincenzo Maffione#error
29530a985b37SVincenzo Maffione#endif
295458952137SVincenzo Maffioneint main(void) { return 0; }
295558952137SVincenzo MaffioneEOF
295658952137SVincenzo Maffione  if compile_prog "" "" ; then
295758952137SVincenzo Maffione    netmap=yes
295858952137SVincenzo Maffione  else
295958952137SVincenzo Maffione    if test "$netmap" = "yes" ; then
296058952137SVincenzo Maffione      feature_not_found "netmap"
296158952137SVincenzo Maffione    fi
296258952137SVincenzo Maffione    netmap=no
296358952137SVincenzo Maffione  fi
296458952137SVincenzo Maffionefi
296558952137SVincenzo Maffione
296658952137SVincenzo Maffione##########################################
2967422a5fd0SJoelle van Dyne# detect CoreAudio
2968422a5fd0SJoelle van Dyneif test "$coreaudio" != "no" ; then
2969422a5fd0SJoelle van Dyne  coreaudio_libs="-framework CoreAudio"
2970422a5fd0SJoelle van Dyne  cat > $TMPC << EOF
2971422a5fd0SJoelle van Dyne#include <CoreAudio/CoreAudio.h>
2972422a5fd0SJoelle van Dyneint main(void)
2973422a5fd0SJoelle van Dyne{
2974422a5fd0SJoelle van Dyne  return (int)AudioGetCurrentHostTime();
2975422a5fd0SJoelle van Dyne}
2976422a5fd0SJoelle van DyneEOF
2977422a5fd0SJoelle van Dyne  if compile_prog "" "$coreaudio_libs" ; then
2978422a5fd0SJoelle van Dyne    coreaudio=yes
2979422a5fd0SJoelle van Dyne  else
2980422a5fd0SJoelle van Dyne    coreaudio=no
2981422a5fd0SJoelle van Dyne  fi
2982422a5fd0SJoelle van Dynefi
2983422a5fd0SJoelle van Dyne
2984422a5fd0SJoelle van Dyne##########################################
2985c2de5c91Smalc# Sound support libraries probe
29868f28f3fbSths
298789138857SStefan Weilaudio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
2988c2de5c91Smalcfor drv in $audio_drv_list; do
2989c2de5c91Smalc    case $drv in
2990e42975a1SGerd Hoffmann    alsa | try-alsa)
2991c80a867fSGerd Hoffmann    if $pkg_config alsa --exists; then
2992c80a867fSGerd Hoffmann        alsa_libs=$($pkg_config alsa --libs)
2993478e943fSPaolo Bonzini        alsa_cflags=$($pkg_config alsa --cflags)
2994478e943fSPaolo Bonzini        alsa=yes
2995e42975a1SGerd Hoffmann        if test "$drv" = "try-alsa"; then
2996e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa/alsa/')
2997e42975a1SGerd Hoffmann        fi
2998e42975a1SGerd Hoffmann    else
2999e42975a1SGerd Hoffmann        if test "$drv" = "try-alsa"; then
3000e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa//')
3001c80a867fSGerd Hoffmann        else
3002c80a867fSGerd Hoffmann            error_exit "$drv check failed" \
3003c80a867fSGerd Hoffmann                "Make sure to have the $drv libs and headers installed."
3004c80a867fSGerd Hoffmann        fi
3005e42975a1SGerd Hoffmann    fi
3006c2de5c91Smalc    ;;
3007c2de5c91Smalc
3008e42975a1SGerd Hoffmann    pa | try-pa)
3009c80a867fSGerd Hoffmann    if $pkg_config libpulse --exists; then
3010478e943fSPaolo Bonzini        libpulse=yes
3011c80a867fSGerd Hoffmann        pulse_libs=$($pkg_config libpulse --libs)
3012478e943fSPaolo Bonzini        pulse_cflags=$($pkg_config libpulse --cflags)
3013e42975a1SGerd Hoffmann        if test "$drv" = "try-pa"; then
3014e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa/pa/')
3015e42975a1SGerd Hoffmann        fi
3016e42975a1SGerd Hoffmann    else
3017e42975a1SGerd Hoffmann        if test "$drv" = "try-pa"; then
3018e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa//')
3019c80a867fSGerd Hoffmann        else
3020c80a867fSGerd Hoffmann            error_exit "$drv check failed" \
3021c80a867fSGerd Hoffmann                "Make sure to have the $drv libs and headers installed."
3022c80a867fSGerd Hoffmann        fi
3023e42975a1SGerd Hoffmann    fi
3024b8e59f18Smalc    ;;
3025b8e59f18Smalc
3026373967b2SGerd Hoffmann    sdl)
3027373967b2SGerd Hoffmann    if test "$sdl" = "no"; then
3028373967b2SGerd Hoffmann        error_exit "sdl not found or disabled, can not use sdl audio driver"
3029373967b2SGerd Hoffmann    fi
3030373967b2SGerd Hoffmann    ;;
3031373967b2SGerd Hoffmann
3032e42975a1SGerd Hoffmann    try-sdl)
3033e42975a1SGerd Hoffmann    if test "$sdl" = "no"; then
3034e42975a1SGerd Hoffmann        audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl//')
3035e42975a1SGerd Hoffmann    else
3036e42975a1SGerd Hoffmann        audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl/sdl/')
3037e42975a1SGerd Hoffmann    fi
3038e42975a1SGerd Hoffmann    ;;
3039e42975a1SGerd Hoffmann
3040422a5fd0SJoelle van Dyne    coreaudio | try-coreaudio)
3041422a5fd0SJoelle van Dyne    if test "$coreaudio" = "no"; then
3042422a5fd0SJoelle van Dyne      if test "$drv" = "try-coreaudio"; then
3043422a5fd0SJoelle van Dyne        audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-coreaudio//')
3044422a5fd0SJoelle van Dyne      else
3045422a5fd0SJoelle van Dyne        error_exit "$drv check failed" \
3046422a5fd0SJoelle van Dyne                "Make sure to have the $drv is available."
3047422a5fd0SJoelle van Dyne      fi
3048422a5fd0SJoelle van Dyne    else
3049b1149911SFam Zheng      coreaudio_libs="-framework CoreAudio"
3050422a5fd0SJoelle van Dyne      if test "$drv" = "try-coreaudio"; then
3051422a5fd0SJoelle van Dyne        audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-coreaudio/coreaudio/')
3052422a5fd0SJoelle van Dyne      fi
3053422a5fd0SJoelle van Dyne    fi
3054997e690aSJuan Quintela    ;;
3055997e690aSJuan Quintela
3056a4bf6780SJuan Quintela    dsound)
3057b1149911SFam Zheng      dsound_libs="-lole32 -ldxguid"
3058d5631638Smalc      audio_win_int="yes"
3059a4bf6780SJuan Quintela    ;;
3060a4bf6780SJuan Quintela
3061a4bf6780SJuan Quintela    oss)
3062b1149911SFam Zheng      oss_libs="$oss_lib"
3063a4bf6780SJuan Quintela    ;;
3064a4bf6780SJuan Quintela
30652e445703SGeoffrey McRae    jack | try-jack)
30662e445703SGeoffrey McRae    if $pkg_config jack --exists; then
3067478e943fSPaolo Bonzini        libjack=yes
30682e445703SGeoffrey McRae        jack_libs=$($pkg_config jack --libs)
30692e445703SGeoffrey McRae        if test "$drv" = "try-jack"; then
30702e445703SGeoffrey McRae            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-jack/jack/')
30712e445703SGeoffrey McRae        fi
30722e445703SGeoffrey McRae    else
30732e445703SGeoffrey McRae        if test "$drv" = "try-jack"; then
30742e445703SGeoffrey McRae            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-jack//')
30752e445703SGeoffrey McRae        else
30762e445703SGeoffrey McRae            error_exit "$drv check failed" \
30772e445703SGeoffrey McRae                "Make sure to have the $drv libs and headers installed."
30782e445703SGeoffrey McRae        fi
30792e445703SGeoffrey McRae    fi
30802e445703SGeoffrey McRae    ;;
30812e445703SGeoffrey McRae
3082e4c63a6aSmalc    *)
30831c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
308476ad07a4SPeter Maydell        error_exit "Unknown driver '$drv' selected" \
308576ad07a4SPeter Maydell            "Possible drivers are: $audio_possible_drivers"
3086e4c63a6aSmalc    }
3087e4c63a6aSmalc    ;;
3088c2de5c91Smalc    esac
3089c2de5c91Smalcdone
30908f28f3fbSths
30914d3b6f6eSbalrog##########################################
3092e18df141SAnthony Liguori# glib support probe
3093a52d28afSPaolo Bonzini
3094b4c6036fSDaniel P. Berrangéglib_req_ver=2.56
3095aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0
3096aa0d1f44SPaolo Bonziniif test "$modules" = yes; then
3097a88afc64SGerd Hoffmann    glib_modules="$glib_modules gmodule-export-2.0"
3098aa0d1f44SPaolo Bonzinifi
309954cb65d8SEmilio G. Cotaif test "$plugins" = yes; then
310054cb65d8SEmilio G. Cota    glib_modules="$glib_modules gmodule-2.0"
310154cb65d8SEmilio G. Cotafi
3102e26110cfSFam Zheng
3103aa0d1f44SPaolo Bonzinifor i in $glib_modules; do
3104e26110cfSFam Zheng    if $pkg_config --atleast-version=$glib_req_ver $i; then
310589138857SStefan Weil        glib_cflags=$($pkg_config --cflags $i)
310689138857SStefan Weil        glib_libs=$($pkg_config --libs $i)
3107e18df141SAnthony Liguori    else
3108e26110cfSFam Zheng        error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3109e26110cfSFam Zheng    fi
3110e26110cfSFam Zhengdone
3111e26110cfSFam Zheng
3112215b0c2fSPaolo Bonzini# This workaround is required due to a bug in pkg-config file for glib as it
3113215b0c2fSPaolo Bonzini# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
3114215b0c2fSPaolo Bonzini
3115215b0c2fSPaolo Bonziniif test "$static" = yes && test "$mingw32" = yes; then
3116215b0c2fSPaolo Bonzini    glib_cflags="-DGLIB_STATIC_COMPILATION $glib_cflags"
3117215b0c2fSPaolo Bonzinifi
3118215b0c2fSPaolo Bonzini
311920cf7b8eSDenis Plotnikovif ! test "$gio" = "no"; then
312020cf7b8eSDenis Plotnikov    pass=no
3121f876b765SMarc-André Lureau    if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
3122f876b765SMarc-André Lureau        gio_cflags=$($pkg_config --cflags gio-2.0)
3123f876b765SMarc-André Lureau        gio_libs=$($pkg_config --libs gio-2.0)
312425a97a56SMarc-André Lureau        gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0)
31255ecfb76cSPaolo Bonzini        if ! has "$gdbus_codegen"; then
31260dba4897SMarc-André Lureau            gdbus_codegen=
31270dba4897SMarc-André Lureau        fi
312876346b62SPeter Maydell        # Check that the libraries actually work -- Ubuntu 18.04 ships
312976346b62SPeter Maydell        # with pkg-config --static --libs data for gio-2.0 that is missing
313076346b62SPeter Maydell        # -lblkid and will give a link error.
313113ceae66SPeter Maydell        cat > $TMPC <<EOF
313213ceae66SPeter Maydell#include <gio/gio.h>
313313ceae66SPeter Maydellint main(void)
313413ceae66SPeter Maydell{
313513ceae66SPeter Maydell    g_dbus_proxy_new_sync(0, 0, 0, 0, 0, 0, 0, 0);
313613ceae66SPeter Maydell    return 0;
313713ceae66SPeter Maydell}
313813ceae66SPeter MaydellEOF
313913ceae66SPeter Maydell        if compile_prog "$gio_cflags" "$gio_libs" ; then
314020cf7b8eSDenis Plotnikov            pass=yes
314176346b62SPeter Maydell        else
314220cf7b8eSDenis Plotnikov            pass=no
3143f876b765SMarc-André Lureau        fi
3144f876b765SMarc-André Lureau
314520cf7b8eSDenis Plotnikov        if test "$pass" = "yes" &&
314620cf7b8eSDenis Plotnikov            $pkg_config --atleast-version=$glib_req_ver gio-unix-2.0; then
314725a97a56SMarc-André Lureau            gio_cflags="$gio_cflags $($pkg_config --cflags gio-unix-2.0)"
314825a97a56SMarc-André Lureau            gio_libs="$gio_libs $($pkg_config --libs gio-unix-2.0)"
314925a97a56SMarc-André Lureau        fi
315020cf7b8eSDenis Plotnikov    fi
315120cf7b8eSDenis Plotnikov
315220cf7b8eSDenis Plotnikov    if test "$pass" = "no"; then
315320cf7b8eSDenis Plotnikov        if test "$gio" = "yes"; then
315420cf7b8eSDenis Plotnikov            feature_not_found "gio" "Install libgio >= 2.0"
315520cf7b8eSDenis Plotnikov        else
315620cf7b8eSDenis Plotnikov            gio=no
315720cf7b8eSDenis Plotnikov        fi
315820cf7b8eSDenis Plotnikov    else
315920cf7b8eSDenis Plotnikov        gio=yes
316020cf7b8eSDenis Plotnikov    fi
316120cf7b8eSDenis Plotnikovfi
316225a97a56SMarc-André Lureau
3163977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the
3164977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches
3165977a82abSDaniel P. Berrange# problems on multi-arch where people try to build
3166977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers
3167977a82abSDaniel P. Berrangecat > $TMPC <<EOF
3168977a82abSDaniel P. Berrange#include <glib.h>
3169977a82abSDaniel P. Berrange#include <unistd.h>
3170977a82abSDaniel P. Berrange
3171977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \
3172977a82abSDaniel P. Berrange  typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3173977a82abSDaniel P. Berrange
3174977a82abSDaniel P. Berrangeint main(void) {
3175977a82abSDaniel P. Berrange   QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3176977a82abSDaniel P. Berrange   return 0;
3177977a82abSDaniel P. Berrange}
3178977a82abSDaniel P. BerrangeEOF
3179977a82abSDaniel P. Berrange
3180215b0c2fSPaolo Bonziniif ! compile_prog "$glib_cflags" "$glib_libs" ; then
3181977a82abSDaniel P. Berrange    error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3182977a82abSDaniel P. Berrange               "You probably need to set PKG_CONFIG_LIBDIR"\
3183977a82abSDaniel P. Berrange	       "to point to the right pkg-config files for your"\
3184977a82abSDaniel P. Berrange	       "build target"
3185977a82abSDaniel P. Berrangefi
3186977a82abSDaniel P. Berrange
3187bbbf2e04SJohn Snow# Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
3188bbbf2e04SJohn Snowcat > $TMPC << EOF
3189bbbf2e04SJohn Snow#include <glib.h>
3190bbbf2e04SJohn Snowint main(void) { return 0; }
3191bbbf2e04SJohn SnowEOF
3192bbbf2e04SJohn Snowif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3193bbbf2e04SJohn Snow    if cc_has_warning_flag "-Wno-unknown-attributes"; then
3194bbbf2e04SJohn Snow        glib_cflags="-Wno-unknown-attributes $glib_cflags"
31955770e8afSPaolo Bonzini        CONFIGURE_CFLAGS="-Wno-unknown-attributes $CONFIGURE_CFLAGS"
3196bbbf2e04SJohn Snow    fi
3197bbbf2e04SJohn Snowfi
3198bbbf2e04SJohn Snow
31999bda600bSEric Blake# Silence clang warnings triggered by glib < 2.57.2
32009bda600bSEric Blakecat > $TMPC << EOF
32019bda600bSEric Blake#include <glib.h>
32029bda600bSEric Blaketypedef struct Foo {
32039bda600bSEric Blake    int i;
32049bda600bSEric Blake} Foo;
32059bda600bSEric Blakestatic void foo_free(Foo *f)
32069bda600bSEric Blake{
32079bda600bSEric Blake    g_free(f);
32089bda600bSEric Blake}
32099bda600bSEric BlakeG_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free);
32109bda600bSEric Blakeint main(void) { return 0; }
32119bda600bSEric BlakeEOF
32129bda600bSEric Blakeif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
32139bda600bSEric Blake    if cc_has_warning_flag "-Wno-unused-function"; then
32149bda600bSEric Blake        glib_cflags="$glib_cflags -Wno-unused-function"
32155770e8afSPaolo Bonzini        CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -Wno-unused-function"
32169bda600bSEric Blake    fi
32179bda600bSEric Blakefi
32189bda600bSEric Blake
3219e26110cfSFam Zheng##########################################
3220e26110cfSFam Zheng# SHA command probe for modules
3221e26110cfSFam Zhengif test "$modules" = yes; then
3222e26110cfSFam Zheng    shacmd_probe="sha1sum sha1 shasum"
3223e26110cfSFam Zheng    for c in $shacmd_probe; do
32248ccefb91SFam Zheng        if has $c; then
3225e26110cfSFam Zheng            shacmd="$c"
3226e26110cfSFam Zheng            break
3227e26110cfSFam Zheng        fi
3228e26110cfSFam Zheng    done
3229e26110cfSFam Zheng    if test "$shacmd" = ""; then
3230e26110cfSFam Zheng        error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3231e26110cfSFam Zheng    fi
3232e18df141SAnthony Liguorifi
3233e18df141SAnthony Liguori
3234e18df141SAnthony Liguori##########################################
3235e5d355d1Saliguori# pthread probe
32364b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
32373c529d93Saliguori
3238e5d355d1Saliguoripthread=no
3239414f0dabSblueswir1cat > $TMPC << EOF
32403c529d93Saliguori#include <pthread.h>
32417a42bbe4SStefan Weilstatic void *f(void *p) { return NULL; }
32427a42bbe4SStefan Weilint main(void) {
32437a42bbe4SStefan Weil  pthread_t thread;
32447a42bbe4SStefan Weil  pthread_create(&thread, 0, f, 0);
32457a42bbe4SStefan Weil  return 0;
32467a42bbe4SStefan Weil}
3247414f0dabSblueswir1EOF
3248bd00d539SAndreas Färberif compile_prog "" "" ; then
3249bd00d539SAndreas Färber  pthread=yes
3250bd00d539SAndreas Färberelse
3251de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
325252166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
3253e5d355d1Saliguori      pthread=yes
3254de65fe0fSSebastian Herbszt      break
3255414f0dabSblueswir1    fi
3256de65fe0fSSebastian Herbszt  done
3257bd00d539SAndreas Färberfi
3258414f0dabSblueswir1
3259e633a5c6SEric Blakeif test "$mingw32" != yes && test "$pthread" = no; then
326076ad07a4SPeter Maydell  error_exit "pthread check failed" \
326176ad07a4SPeter Maydell      "Make sure to have the pthread libs and headers installed."
3262e5d355d1Saliguorifi
3263e5d355d1Saliguori
3264479a5747SRoman Bolshakov# check for pthread_setname_np with thread id
3265479a5747SRoman Bolshakovpthread_setname_np_w_tid=no
32665c312079SDr. David Alan Gilbertcat > $TMPC << EOF
32675c312079SDr. David Alan Gilbert#include <pthread.h>
32685c312079SDr. David Alan Gilbert
32695c312079SDr. David Alan Gilbertstatic void *f(void *p) { return NULL; }
32705c312079SDr. David Alan Gilbertint main(void)
32715c312079SDr. David Alan Gilbert{
32725c312079SDr. David Alan Gilbert    pthread_t thread;
32735c312079SDr. David Alan Gilbert    pthread_create(&thread, 0, f, 0);
32745c312079SDr. David Alan Gilbert    pthread_setname_np(thread, "QEMU");
32755c312079SDr. David Alan Gilbert    return 0;
32765c312079SDr. David Alan Gilbert}
32775c312079SDr. David Alan GilbertEOF
32785c312079SDr. David Alan Gilbertif compile_prog "" "$pthread_lib" ; then
3279479a5747SRoman Bolshakov  pthread_setname_np_w_tid=yes
3280479a5747SRoman Bolshakovfi
3281479a5747SRoman Bolshakov
3282479a5747SRoman Bolshakov# check for pthread_setname_np without thread id
3283479a5747SRoman Bolshakovpthread_setname_np_wo_tid=no
3284479a5747SRoman Bolshakovcat > $TMPC << EOF
3285479a5747SRoman Bolshakov#include <pthread.h>
3286479a5747SRoman Bolshakov
328712a9b8d8SThomas Huthstatic void *f(void *p) { pthread_setname_np("QEMU"); return NULL; }
3288479a5747SRoman Bolshakovint main(void)
3289479a5747SRoman Bolshakov{
3290479a5747SRoman Bolshakov    pthread_t thread;
3291479a5747SRoman Bolshakov    pthread_create(&thread, 0, f, 0);
3292479a5747SRoman Bolshakov    return 0;
3293479a5747SRoman Bolshakov}
3294479a5747SRoman BolshakovEOF
3295479a5747SRoman Bolshakovif compile_prog "" "$pthread_lib" ; then
3296479a5747SRoman Bolshakov  pthread_setname_np_wo_tid=yes
32975c312079SDr. David Alan Gilbertfi
32985c312079SDr. David Alan Gilbert
3299bf9298b9Saliguori##########################################
3300b10d49d7SPino Toscano# libssh probe
3301b10d49d7SPino Toscanoif test "$libssh" != "no" ; then
3302b4c10fc6SThomas Huth  if $pkg_config --exists "libssh >= 0.8.7"; then
3303b10d49d7SPino Toscano    libssh_cflags=$($pkg_config libssh --cflags)
3304b10d49d7SPino Toscano    libssh_libs=$($pkg_config libssh --libs)
3305b10d49d7SPino Toscano    libssh=yes
33060a12ec87SRichard W.M. Jones  else
3307b10d49d7SPino Toscano    if test "$libssh" = "yes" ; then
3308b10d49d7SPino Toscano      error_exit "libssh required for --enable-libssh"
33090a12ec87SRichard W.M. Jones    fi
3310b10d49d7SPino Toscano    libssh=no
33110a12ec87SRichard W.M. Jones  fi
33120a12ec87SRichard W.M. Jonesfi
33130a12ec87SRichard W.M. Jones
33140a12ec87SRichard W.M. Jones##########################################
33155c6c3a6cSChristoph Hellwig# linux-aio probe
33165c6c3a6cSChristoph Hellwig
33175c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
33185c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
33195c6c3a6cSChristoph Hellwig#include <libaio.h>
33205c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
3321832ce9c2SScott Wood#include <stddef.h>
33225c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
33235c6c3a6cSChristoph HellwigEOF
33245c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
33255c6c3a6cSChristoph Hellwig    linux_aio=yes
33265c6c3a6cSChristoph Hellwig  else
33275c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
332821684af0SStewart Smith      feature_not_found "linux AIO" "Install libaio devel"
33295c6c3a6cSChristoph Hellwig    fi
33303cfcae3cSLuiz Capitulino    linux_aio=no
33315c6c3a6cSChristoph Hellwig  fi
33325c6c3a6cSChristoph Hellwigfi
33335c6c3a6cSChristoph Hellwig
33345c6c3a6cSChristoph Hellwig##########################################
33357aaa6a16SPaolo Bonzini# TPM emulation is only on POSIX
33363b8acc11SPaolo Bonzini
33377aaa6a16SPaolo Bonziniif test "$tpm" = ""; then
33387aaa6a16SPaolo Bonzini  if test "$mingw32" = "yes"; then
33397aaa6a16SPaolo Bonzini    tpm=no
33403b8acc11SPaolo Bonzini  else
33417aaa6a16SPaolo Bonzini    tpm=yes
33427aaa6a16SPaolo Bonzini  fi
33437aaa6a16SPaolo Bonzinielif test "$tpm" = "yes"; then
33447aaa6a16SPaolo Bonzini  if test "$mingw32" = "yes" ; then
33457aaa6a16SPaolo Bonzini    error_exit "TPM emulation only available on POSIX systems"
33467aaa6a16SPaolo Bonzini  fi
33473b8acc11SPaolo Bonzinifi
33483b8acc11SPaolo Bonzini
33493b8acc11SPaolo Bonzini##########################################
3350bf9298b9Saliguori# iovec probe
3351bf9298b9Saliguoricat > $TMPC <<EOF
3352db34f0b3Sblueswir1#include <sys/types.h>
3353bf9298b9Saliguori#include <sys/uio.h>
3354db34f0b3Sblueswir1#include <unistd.h>
3355f91f9beeSStefan Weilint main(void) { return sizeof(struct iovec); }
3356bf9298b9SaliguoriEOF
3357bf9298b9Saliguoriiovec=no
335852166aa0SJuan Quintelaif compile_prog "" "" ; then
3359bf9298b9Saliguori  iovec=yes
3360bf9298b9Saliguorifi
3361bf9298b9Saliguori
3362f652e6afSaurel32##########################################
3363f652e6afSaurel32# fdt probe
3364e169e1e1SPeter Maydell
3365fbb4121dSPaolo Bonzinicase "$fdt" in
3366fbb4121dSPaolo Bonzini  auto | enabled | internal)
3367fbb4121dSPaolo Bonzini    # Simpler to always update submodule, even if not needed.
3368aef45d51SDaniel P. Berrange    git_submodules="${git_submodules} dtc"
3369fbb4121dSPaolo Bonzini    ;;
3370fbb4121dSPaolo Bonziniesac
3371f652e6afSaurel32
337220ff075bSMichael Walle##########################################
33739d49bcf6SMarkus Armbruster# opengl probe (for sdl2, gtk)
3374b1546f32SGerd Hoffmann
3375d52c454aSMarc-André Lureaugbm="no"
3376d52c454aSMarc-André Lureauif $pkg_config gbm; then
3377d52c454aSMarc-André Lureau    gbm_cflags="$($pkg_config --cflags gbm)"
3378d52c454aSMarc-André Lureau    gbm_libs="$($pkg_config --libs gbm)"
3379d52c454aSMarc-André Lureau    gbm="yes"
3380d52c454aSMarc-André Lureaufi
3381d52c454aSMarc-André Lureau
3382da076ffeSGerd Hoffmannif test "$opengl" != "no" ; then
3383bc6a3565SAkihiko Odaki  epoxy=no
3384bc6a3565SAkihiko Odaki  if $pkg_config epoxy; then
3385bc6a3565SAkihiko Odaki    cat > $TMPC << EOF
3386bc6a3565SAkihiko Odaki#include <epoxy/egl.h>
3387bc6a3565SAkihiko Odakiint main(void) { return 0; }
3388bc6a3565SAkihiko OdakiEOF
3389bc6a3565SAkihiko Odaki    if compile_prog "" "" ; then
3390bc6a3565SAkihiko Odaki      epoxy=yes
3391bc6a3565SAkihiko Odaki    fi
3392bc6a3565SAkihiko Odaki  fi
3393bc6a3565SAkihiko Odaki
3394bc6a3565SAkihiko Odaki  if test "$epoxy" = "yes" ; then
3395bc6a3565SAkihiko Odaki    opengl_cflags="$($pkg_config --cflags epoxy)"
3396bc6a3565SAkihiko Odaki    opengl_libs="$($pkg_config --libs epoxy)"
3397da076ffeSGerd Hoffmann    opengl=yes
339820ff075bSMichael Walle  else
3399da076ffeSGerd Hoffmann    if test "$opengl" = "yes" ; then
3400bc6a3565SAkihiko Odaki      feature_not_found "opengl" "Please install epoxy with EGL"
340120ff075bSMichael Walle    fi
3402f676c67eSJeremy White    opengl_cflags=""
3403da076ffeSGerd Hoffmann    opengl_libs=""
3404da076ffeSGerd Hoffmann    opengl=no
340520ff075bSMichael Walle  fi
340620ff075bSMichael Wallefi
340720ff075bSMichael Walle
3408dcc38d1cSMarcelo Tosatti##########################################
3409a99d57bbSWanlong Gao# libnuma probe
3410a99d57bbSWanlong Gao
3411a99d57bbSWanlong Gaoif test "$numa" != "no" ; then
3412a99d57bbSWanlong Gao  cat > $TMPC << EOF
3413a99d57bbSWanlong Gao#include <numa.h>
3414a99d57bbSWanlong Gaoint main(void) { return numa_available(); }
3415a99d57bbSWanlong GaoEOF
3416a99d57bbSWanlong Gao
3417a99d57bbSWanlong Gao  if compile_prog "" "-lnuma" ; then
3418a99d57bbSWanlong Gao    numa=yes
3419ab318051SMarc-André Lureau    numa_libs="-lnuma"
3420a99d57bbSWanlong Gao  else
3421a99d57bbSWanlong Gao    if test "$numa" = "yes" ; then
3422a99d57bbSWanlong Gao      feature_not_found "numa" "install numactl devel"
3423a99d57bbSWanlong Gao    fi
3424a99d57bbSWanlong Gao    numa=no
3425a99d57bbSWanlong Gao  fi
3426a99d57bbSWanlong Gaofi
3427a99d57bbSWanlong Gao
3428aa087962SPaolo Bonzinimalloc=system
34297b01cb97SAlexandre Derumierif test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
34307b01cb97SAlexandre Derumier    echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
34317b01cb97SAlexandre Derumier    exit 1
3432aa087962SPaolo Bonzinielif test "$tcmalloc" = "yes" ; then
3433aa087962SPaolo Bonzini    malloc=tcmalloc
3434aa087962SPaolo Bonzinielif test "$jemalloc" = "yes" ; then
3435aa087962SPaolo Bonzini    malloc=jemalloc
34367b01cb97SAlexandre Derumierfi
34377b01cb97SAlexandre Derumier
3438955727d2SCortland Tölva# check for usbfs
3439955727d2SCortland Tölvahave_usbfs=no
3440955727d2SCortland Tölvaif test "$linux_user" = "yes"; then
344196566d09SThomas Petazzoni  cat > $TMPC << EOF
344296566d09SThomas Petazzoni#include <linux/usbdevice_fs.h>
344396566d09SThomas Petazzoni
344496566d09SThomas Petazzoni#ifndef USBDEVFS_GET_CAPABILITIES
344596566d09SThomas Petazzoni#error "USBDEVFS_GET_CAPABILITIES undefined"
344696566d09SThomas Petazzoni#endif
344796566d09SThomas Petazzoni
344896566d09SThomas Petazzoni#ifndef USBDEVFS_DISCONNECT_CLAIM
344996566d09SThomas Petazzoni#error "USBDEVFS_DISCONNECT_CLAIM undefined"
345096566d09SThomas Petazzoni#endif
345196566d09SThomas Petazzoni
345296566d09SThomas Petazzoniint main(void)
345396566d09SThomas Petazzoni{
345496566d09SThomas Petazzoni    return 0;
345596566d09SThomas Petazzoni}
345696566d09SThomas PetazzoniEOF
345796566d09SThomas Petazzoni  if compile_prog "" ""; then
3458955727d2SCortland Tölva    have_usbfs=yes
3459955727d2SCortland Tölva  fi
3460955727d2SCortland Tölvafi
3461751bcc39SMarc-André Lureau
3462de5071c5SBlue Swirl##########################################
3463cd4ec0b4SGerd Hoffmann# spice probe
346458d3f3ffSGerd Hoffmannif test "$spice_protocol" != "no" ; then
346558d3f3ffSGerd Hoffmann  spice_protocol_cflags=$($pkg_config --cflags spice-protocol 2>/dev/null)
346658d3f3ffSGerd Hoffmann  if $pkg_config --atleast-version=0.12.3 spice-protocol; then
346758d3f3ffSGerd Hoffmann    spice_protocol="yes"
346858d3f3ffSGerd Hoffmann  else
346958d3f3ffSGerd Hoffmann    if test "$spice_protocol" = "yes" ; then
347058d3f3ffSGerd Hoffmann      feature_not_found "spice_protocol" \
347158d3f3ffSGerd Hoffmann          "Install spice-protocol(>=0.12.3) devel"
347258d3f3ffSGerd Hoffmann    fi
347358d3f3ffSGerd Hoffmann    spice_protocol="no"
347458d3f3ffSGerd Hoffmann  fi
347558d3f3ffSGerd Hoffmannfi
347658d3f3ffSGerd Hoffmann
3477cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
3478cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
3479cd4ec0b4SGerd Hoffmann#include <spice.h>
3480cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
3481cd4ec0b4SGerd HoffmannEOF
3482710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
3483710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
34841b63665cSMarc-André Lureau  if $pkg_config --atleast-version=0.12.5 spice-server && \
348558d3f3ffSGerd Hoffmann     test "$spice_protocol" = "yes" && \
3486cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
3487cd4ec0b4SGerd Hoffmann    spice="yes"
3488cd4ec0b4SGerd Hoffmann  else
3489cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
34908efc9363SHu Tao      feature_not_found "spice" \
349158d3f3ffSGerd Hoffmann          "Install spice-server(>=0.12.5) devel"
3492cd4ec0b4SGerd Hoffmann    fi
3493cd4ec0b4SGerd Hoffmann    spice="no"
3494cd4ec0b4SGerd Hoffmann  fi
3495cd4ec0b4SGerd Hoffmannfi
3496cd4ec0b4SGerd Hoffmann
3497cd4ec0b4SGerd Hoffmann##########################################
3498d9840e25STomoki Sekiyama# check if we have VSS SDK headers for win
3499d9840e25STomoki Sekiyama
3500e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
3501e633a5c6SEric Blake        test "$vss_win32_sdk" != "no" ; then
3502d9840e25STomoki Sekiyama  case "$vss_win32_sdk" in
3503690604f6SMichael Roth    "")   vss_win32_include="-isystem $source_path" ;;
3504d9840e25STomoki Sekiyama    *\ *) # The SDK is installed in "Program Files" by default, but we cannot
3505d9840e25STomoki Sekiyama          # handle path with spaces. So we symlink the headers into ".sdk/vss".
3506690604f6SMichael Roth          vss_win32_include="-isystem $source_path/.sdk/vss"
3507d9840e25STomoki Sekiyama	  symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
3508d9840e25STomoki Sekiyama	  ;;
3509690604f6SMichael Roth    *)    vss_win32_include="-isystem $vss_win32_sdk"
3510d9840e25STomoki Sekiyama  esac
3511d9840e25STomoki Sekiyama  cat > $TMPC << EOF
3512d9840e25STomoki Sekiyama#define __MIDL_user_allocate_free_DEFINED__
3513d9840e25STomoki Sekiyama#include <inc/win2003/vss.h>
3514d9840e25STomoki Sekiyamaint main(void) { return VSS_CTX_BACKUP; }
3515d9840e25STomoki SekiyamaEOF
3516d9840e25STomoki Sekiyama  if compile_prog "$vss_win32_include" "" ; then
3517d9840e25STomoki Sekiyama    guest_agent_with_vss="yes"
3518d9840e25STomoki Sekiyama    QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
3519315d3184SFam Zheng    libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
3520f33ca81fSMichael Roth    qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
3521d9840e25STomoki Sekiyama  else
3522d9840e25STomoki Sekiyama    if test "$vss_win32_sdk" != "" ; then
3523d9840e25STomoki Sekiyama      echo "ERROR: Please download and install Microsoft VSS SDK:"
3524d9840e25STomoki Sekiyama      echo "ERROR:   http://www.microsoft.com/en-us/download/details.aspx?id=23490"
3525d9840e25STomoki Sekiyama      echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
3526d9840e25STomoki Sekiyama      echo "ERROR:   scripts/extract-vsssdk-headers setup.exe"
3527d9840e25STomoki Sekiyama      echo "ERROR: The headers are extracted in the directory \`inc'."
3528d9840e25STomoki Sekiyama      feature_not_found "VSS support"
3529d9840e25STomoki Sekiyama    fi
3530d9840e25STomoki Sekiyama    guest_agent_with_vss="no"
3531d9840e25STomoki Sekiyama  fi
3532d9840e25STomoki Sekiyamafi
3533d9840e25STomoki Sekiyama
3534d9840e25STomoki Sekiyama##########################################
3535d9840e25STomoki Sekiyama# lookup Windows platform SDK (if not specified)
3536d9840e25STomoki Sekiyama# The SDK is needed only to build .tlb (type library) file of guest agent
3537d9840e25STomoki Sekiyama# VSS provider from the source. It is usually unnecessary because the
3538d9840e25STomoki Sekiyama# pre-compiled .tlb file is included.
3539d9840e25STomoki Sekiyama
3540e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
3541e633a5c6SEric Blake        test "$guest_agent_with_vss" = "yes" ; then
3542d9840e25STomoki Sekiyama  if test -z "$win_sdk"; then
3543d9840e25STomoki Sekiyama    programfiles="$PROGRAMFILES"
3544d9840e25STomoki Sekiyama    test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
3545d9840e25STomoki Sekiyama    if test -n "$programfiles"; then
3546d9840e25STomoki Sekiyama      win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
3547d9840e25STomoki Sekiyama    else
3548d9840e25STomoki Sekiyama      feature_not_found "Windows SDK"
3549d9840e25STomoki Sekiyama    fi
3550d9840e25STomoki Sekiyama  elif test "$win_sdk" = "no"; then
3551d9840e25STomoki Sekiyama    win_sdk=""
3552d9840e25STomoki Sekiyama  fi
3553d9840e25STomoki Sekiyamafi
3554d9840e25STomoki Sekiyama
3555d9840e25STomoki Sekiyama##########################################
355650cbebb9SMichael Roth# check if mingw environment provides a recent ntddscsi.h
3557e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no"; then
355850cbebb9SMichael Roth  cat > $TMPC << EOF
355950cbebb9SMichael Roth#include <windows.h>
356050cbebb9SMichael Roth#include <ntddscsi.h>
356150cbebb9SMichael Rothint main(void) {
356250cbebb9SMichael Roth#if !defined(IOCTL_SCSI_GET_ADDRESS)
356350cbebb9SMichael Roth#error Missing required ioctl definitions
356450cbebb9SMichael Roth#endif
356550cbebb9SMichael Roth  SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
356650cbebb9SMichael Roth  return addr.Lun;
356750cbebb9SMichael Roth}
356850cbebb9SMichael RothEOF
356950cbebb9SMichael Roth  if compile_prog "" "" ; then
357050cbebb9SMichael Roth    guest_agent_ntddscsi=yes
3571996b9cdcSMatt Hines    libs_qga="-lsetupapi -lcfgmgr32 $libs_qga"
357250cbebb9SMichael Roth  fi
357350cbebb9SMichael Rothfi
357450cbebb9SMichael Roth
357550cbebb9SMichael Roth##########################################
35768ca80760SRichard Henderson# capstone
35778ca80760SRichard Henderson
3578e219c499SRichard Hendersoncase "$capstone" in
35798b18cdbfSRichard Henderson  auto | enabled | internal)
35808b18cdbfSRichard Henderson    # Simpler to always update submodule, even if not needed.
3581e219c499SRichard Henderson    git_submodules="${git_submodules} capstone"
3582e219c499SRichard Henderson    ;;
3583e219c499SRichard Hendersonesac
35848ca80760SRichard Henderson
35858ca80760SRichard Henderson##########################################
35860a852417SPaul Durrant# check if we have posix_syslog
35870a852417SPaul Durrant
35880a852417SPaul Durrantposix_syslog=no
35890a852417SPaul Durrantcat > $TMPC << EOF
35900a852417SPaul Durrant#include <syslog.h>
35910a852417SPaul Durrantint main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
35920a852417SPaul DurrantEOF
35930a852417SPaul Durrantif compile_prog "" "" ; then
35940a852417SPaul Durrant    posix_syslog=yes
35950a852417SPaul Durrantfi
35960a852417SPaul Durrant
35970a852417SPaul Durrant##########################################
359894a420b1SStefan Hajnoczi# check if trace backend exists
359994a420b1SStefan Hajnoczi
36005b808275SLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends  > /dev/null 2> /dev/null
360194a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
36025b808275SLluís Vilanova  error_exit "invalid trace backends" \
36035b808275SLluís Vilanova      "Please choose supported trace backends."
360494a420b1SStefan Hajnoczifi
360594a420b1SStefan Hajnoczi
36067e24e92aSStefan Hajnoczi##########################################
36077e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
36085b808275SLluís Vilanovaif have_backend "ust"; then
36097e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
3610bf15f63cSMohamad Gebai#include <lttng/tracepoint.h>
36117e24e92aSStefan Hajnocziint main(void) { return 0; }
36127e24e92aSStefan HajnocziEOF
3613c79ed23dSFrancis Deslauriers  if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
3614bf15f63cSMohamad Gebai    if $pkg_config lttng-ust --exists; then
361589138857SStefan Weil      lttng_ust_libs=$($pkg_config --libs lttng-ust)
36167e24e92aSStefan Hajnoczi    else
3617c79ed23dSFrancis Deslauriers      lttng_ust_libs="-llttng-ust -ldl"
3618bf15f63cSMohamad Gebai    fi
3619bf15f63cSMohamad Gebai    if $pkg_config liburcu-bp --exists; then
362089138857SStefan Weil      urcu_bp_libs=$($pkg_config --libs liburcu-bp)
3621bf15f63cSMohamad Gebai    else
3622bf15f63cSMohamad Gebai      urcu_bp_libs="-lurcu-bp"
3623bf15f63cSMohamad Gebai    fi
3624bf15f63cSMohamad Gebai  else
3625bf15f63cSMohamad Gebai    error_exit "Trace backend 'ust' missing lttng-ust header files"
36267e24e92aSStefan Hajnoczi  fi
36277e24e92aSStefan Hajnoczifi
3628b3d08c02SDaniel P. Berrange
3629b3d08c02SDaniel P. Berrange##########################################
3630b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
36315b808275SLluís Vilanovaif have_backend "dtrace"; then
3632b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
363376ad07a4SPeter Maydell    error_exit "dtrace command is not found in PATH $PATH"
3634b3d08c02SDaniel P. Berrange  fi
3635c276b17dSDaniel P. Berrange  trace_backend_stap="no"
3636c276b17dSDaniel P. Berrange  if has 'stap' ; then
3637c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
36384b265c79SStefan Hajnoczi
36394b265c79SStefan Hajnoczi    # Workaround to avoid dtrace(1) producing a file with 'hidden' symbol
36404b265c79SStefan Hajnoczi    # visibility. Define STAP_SDT_V2 to produce 'default' symbol visibility
36414b265c79SStefan Hajnoczi    # instead. QEMU --enable-modules depends on this because the SystemTap
36424b265c79SStefan Hajnoczi    # semaphores are linked into the main binary and not the module's shared
36434b265c79SStefan Hajnoczi    # object.
36444b265c79SStefan Hajnoczi    QEMU_CFLAGS="$QEMU_CFLAGS -DSTAP_SDT_V2"
3645c276b17dSDaniel P. Berrange  fi
3646b3d08c02SDaniel P. Berrangefi
3647b3d08c02SDaniel P. Berrange
36487e24e92aSStefan Hajnoczi##########################################
3649519175a2SAlex Barcelo# check and set a backend for coroutine
3650d0e2fce5SAneesh Kumar K.V
36517c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback
365233c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows
365333c53c54SDaniel P. Berrange# specific one.
36547c2acc70SPeter Maydell
36557c2acc70SPeter Maydellucontext_works=no
3656d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
3657d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
3658d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
3659cdf84806SPeter Maydell#ifdef __stub_makecontext
3660cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
3661cdf84806SPeter Maydell#endif
366275cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
3663d0e2fce5SAneesh Kumar K.VEOF
3664d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
36657c2acc70SPeter Maydell    ucontext_works=yes
3666d0e2fce5SAneesh Kumar K.V  fi
3667519175a2SAlex Barcelofi
36687c2acc70SPeter Maydell
36697c2acc70SPeter Maydellif test "$coroutine" = ""; then
36707c2acc70SPeter Maydell  if test "$mingw32" = "yes"; then
36717c2acc70SPeter Maydell    coroutine=win32
36727c2acc70SPeter Maydell  elif test "$ucontext_works" = "yes"; then
36737c2acc70SPeter Maydell    coroutine=ucontext
3674519175a2SAlex Barcelo  else
36757c2acc70SPeter Maydell    coroutine=sigaltstack
36767c2acc70SPeter Maydell  fi
36777c2acc70SPeter Maydellelse
36787c2acc70SPeter Maydell  case $coroutine in
36797c2acc70SPeter Maydell  windows)
36807c2acc70SPeter Maydell    if test "$mingw32" != "yes"; then
36817c2acc70SPeter Maydell      error_exit "'windows' coroutine backend only valid for Windows"
36827c2acc70SPeter Maydell    fi
36837c2acc70SPeter Maydell    # Unfortunately the user visible backend name doesn't match the
36847c2acc70SPeter Maydell    # coroutine-*.c filename for this case, so we have to adjust it here.
36857c2acc70SPeter Maydell    coroutine=win32
36867c2acc70SPeter Maydell    ;;
36877c2acc70SPeter Maydell  ucontext)
36887c2acc70SPeter Maydell    if test "$ucontext_works" != "yes"; then
36897c2acc70SPeter Maydell      feature_not_found "ucontext"
36907c2acc70SPeter Maydell    fi
36917c2acc70SPeter Maydell    ;;
369233c53c54SDaniel P. Berrange  sigaltstack)
36937c2acc70SPeter Maydell    if test "$mingw32" = "yes"; then
36947c2acc70SPeter Maydell      error_exit "only the 'windows' coroutine backend is valid for Windows"
36957c2acc70SPeter Maydell    fi
36967c2acc70SPeter Maydell    ;;
36977c2acc70SPeter Maydell  *)
369876ad07a4SPeter Maydell    error_exit "unknown coroutine backend $coroutine"
36997c2acc70SPeter Maydell    ;;
37007c2acc70SPeter Maydell  esac
3701d0e2fce5SAneesh Kumar K.Vfi
3702d0e2fce5SAneesh Kumar K.V
370370c60c08SStefan Hajnocziif test "$coroutine_pool" = ""; then
370470c60c08SStefan Hajnoczi  coroutine_pool=yes
370570c60c08SStefan Hajnoczifi
370670c60c08SStefan Hajnoczi
37077d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes"; then
37087d992e4dSPeter Lieven  if test "$coroutine_pool" = "yes"; then
37097d992e4dSPeter Lieven    echo "WARN: disabling coroutine pool for stack usage debugging"
37107d992e4dSPeter Lieven    coroutine_pool=no
37117d992e4dSPeter Lieven  fi
37127d992e4dSPeter Lievenfi
37137d992e4dSPeter Lieven
37141e4f6065SDaniele Buono##################################################
37151e4f6065SDaniele Buono# SafeStack
37161e4f6065SDaniele Buono
37171e4f6065SDaniele Buono
37181e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then
37191e4f6065SDaniele Buonocat > $TMPC << EOF
37201e4f6065SDaniele Buonoint main(int argc, char *argv[])
37211e4f6065SDaniele Buono{
37221e4f6065SDaniele Buono#if ! __has_feature(safe_stack)
37231e4f6065SDaniele Buono#error SafeStack Disabled
37241e4f6065SDaniele Buono#endif
37251e4f6065SDaniele Buono    return 0;
37261e4f6065SDaniele Buono}
37271e4f6065SDaniele BuonoEOF
37281e4f6065SDaniele Buono  flag="-fsanitize=safe-stack"
37291e4f6065SDaniele Buono  # Check that safe-stack is supported and enabled.
37301e4f6065SDaniele Buono  if compile_prog "-Werror $flag" "$flag"; then
37311e4f6065SDaniele Buono    # Flag needed both at compilation and at linking
37321e4f6065SDaniele Buono    QEMU_CFLAGS="$QEMU_CFLAGS $flag"
37331e4f6065SDaniele Buono    QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
37341e4f6065SDaniele Buono  else
37351e4f6065SDaniele Buono    error_exit "SafeStack not supported by your compiler"
37361e4f6065SDaniele Buono  fi
37371e4f6065SDaniele Buono  if test "$coroutine" != "ucontext"; then
37381e4f6065SDaniele Buono    error_exit "SafeStack is only supported by the coroutine backend ucontext"
37391e4f6065SDaniele Buono  fi
37401e4f6065SDaniele Buonoelse
37411e4f6065SDaniele Buonocat > $TMPC << EOF
37421e4f6065SDaniele Buonoint main(int argc, char *argv[])
37431e4f6065SDaniele Buono{
37441e4f6065SDaniele Buono#if defined(__has_feature)
37451e4f6065SDaniele Buono#if __has_feature(safe_stack)
37461e4f6065SDaniele Buono#error SafeStack Enabled
37471e4f6065SDaniele Buono#endif
37481e4f6065SDaniele Buono#endif
37491e4f6065SDaniele Buono    return 0;
37501e4f6065SDaniele Buono}
37511e4f6065SDaniele BuonoEOF
37521e4f6065SDaniele Buonoif test "$safe_stack" = "no"; then
37531e4f6065SDaniele Buono  # Make sure that safe-stack is disabled
37541e4f6065SDaniele Buono  if ! compile_prog "-Werror" ""; then
37551e4f6065SDaniele Buono    # SafeStack was already enabled, try to explicitly remove the feature
37561e4f6065SDaniele Buono    flag="-fno-sanitize=safe-stack"
37571e4f6065SDaniele Buono    if ! compile_prog "-Werror $flag" "$flag"; then
37581e4f6065SDaniele Buono      error_exit "Configure cannot disable SafeStack"
37591e4f6065SDaniele Buono    fi
37601e4f6065SDaniele Buono    QEMU_CFLAGS="$QEMU_CFLAGS $flag"
37611e4f6065SDaniele Buono    QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
37621e4f6065SDaniele Buono  fi
37631e4f6065SDaniele Buonoelse # "$safe_stack" = ""
37641e4f6065SDaniele Buono  # Set safe_stack to yes or no based on pre-existing flags
37651e4f6065SDaniele Buono  if compile_prog "-Werror" ""; then
37661e4f6065SDaniele Buono    safe_stack="no"
37671e4f6065SDaniele Buono  else
37681e4f6065SDaniele Buono    safe_stack="yes"
37691e4f6065SDaniele Buono    if test "$coroutine" != "ucontext"; then
37701e4f6065SDaniele Buono      error_exit "SafeStack is only supported by the coroutine backend ucontext"
37711e4f6065SDaniele Buono    fi
37721e4f6065SDaniele Buono  fi
37731e4f6065SDaniele Buonofi
37741e4f6065SDaniele Buonofi
37757d992e4dSPeter Lieven
377676a347e1SRichard Henderson########################################
377776a347e1SRichard Henderson# check if cpuid.h is usable.
377876a347e1SRichard Henderson
377976a347e1SRichard Hendersoncat > $TMPC << EOF
378076a347e1SRichard Henderson#include <cpuid.h>
378176a347e1SRichard Hendersonint main(void) {
3782774d566cSPeter Maydell    unsigned a, b, c, d;
3783774d566cSPeter Maydell    int max = __get_cpuid_max(0, 0);
3784774d566cSPeter Maydell
3785774d566cSPeter Maydell    if (max >= 1) {
3786774d566cSPeter Maydell        __cpuid(1, a, b, c, d);
3787774d566cSPeter Maydell    }
3788774d566cSPeter Maydell
3789774d566cSPeter Maydell    if (max >= 7) {
3790774d566cSPeter Maydell        __cpuid_count(7, 0, a, b, c, d);
3791774d566cSPeter Maydell    }
3792774d566cSPeter Maydell
379376a347e1SRichard Henderson    return 0;
379476a347e1SRichard Henderson}
379576a347e1SRichard HendersonEOF
379676a347e1SRichard Hendersonif compile_prog "" "" ; then
379776a347e1SRichard Henderson    cpuid_h=yes
379876a347e1SRichard Hendersonfi
379976a347e1SRichard Henderson
38005dd89908SRichard Henderson##########################################
38015dd89908SRichard Henderson# avx2 optimization requirement check
38025dd89908SRichard Henderson#
38035dd89908SRichard Henderson# There is no point enabling this if cpuid.h is not usable,
38045dd89908SRichard Henderson# since we won't be able to select the new routines.
38055dd89908SRichard Henderson
3806e633a5c6SEric Blakeif test "$cpuid_h" = "yes" && test "$avx2_opt" != "no"; then
38075dd89908SRichard Henderson  cat > $TMPC << EOF
38085dd89908SRichard Henderson#pragma GCC push_options
38095dd89908SRichard Henderson#pragma GCC target("avx2")
38105dd89908SRichard Henderson#include <cpuid.h>
38115dd89908SRichard Henderson#include <immintrin.h>
38125dd89908SRichard Hendersonstatic int bar(void *a) {
38135dd89908SRichard Henderson    __m256i x = *(__m256i *)a;
38145dd89908SRichard Henderson    return _mm256_testz_si256(x, x);
38155dd89908SRichard Henderson}
38165dd89908SRichard Hendersonint main(int argc, char *argv[]) { return bar(argv[0]); }
38175dd89908SRichard HendersonEOF
38185dd89908SRichard Henderson  if compile_object "" ; then
38195dd89908SRichard Henderson    avx2_opt="yes"
382086583a07SLiam Merwick  else
382186583a07SLiam Merwick    avx2_opt="no"
38225dd89908SRichard Henderson  fi
38235dd89908SRichard Hendersonfi
38245dd89908SRichard Henderson
38256b8cd447SRobert Hoo##########################################
38266b8cd447SRobert Hoo# avx512f optimization requirement check
38276b8cd447SRobert Hoo#
38286b8cd447SRobert Hoo# There is no point enabling this if cpuid.h is not usable,
38296b8cd447SRobert Hoo# since we won't be able to select the new routines.
38306b8cd447SRobert Hoo# by default, it is turned off.
38316b8cd447SRobert Hoo# if user explicitly want to enable it, check environment
38326b8cd447SRobert Hoo
38336b8cd447SRobert Hooif test "$cpuid_h" = "yes" && test "$avx512f_opt" = "yes"; then
38346b8cd447SRobert Hoo  cat > $TMPC << EOF
38356b8cd447SRobert Hoo#pragma GCC push_options
38366b8cd447SRobert Hoo#pragma GCC target("avx512f")
38376b8cd447SRobert Hoo#include <cpuid.h>
38386b8cd447SRobert Hoo#include <immintrin.h>
38396b8cd447SRobert Hoostatic int bar(void *a) {
38406b8cd447SRobert Hoo    __m512i x = *(__m512i *)a;
38416b8cd447SRobert Hoo    return _mm512_test_epi64_mask(x, x);
38426b8cd447SRobert Hoo}
38436b8cd447SRobert Hooint main(int argc, char *argv[])
38446b8cd447SRobert Hoo{
38456b8cd447SRobert Hoo	return bar(argv[0]);
38466b8cd447SRobert Hoo}
38476b8cd447SRobert HooEOF
38486b8cd447SRobert Hoo  if ! compile_object "" ; then
38496b8cd447SRobert Hoo    avx512f_opt="no"
38506b8cd447SRobert Hoo  fi
38516b8cd447SRobert Hooelse
38526b8cd447SRobert Hoo  avx512f_opt="no"
38536b8cd447SRobert Hoofi
38546b8cd447SRobert Hoo
3855f540166bSRichard Henderson########################################
3856f540166bSRichard Henderson# check if __[u]int128_t is usable.
3857f540166bSRichard Henderson
3858f540166bSRichard Hendersonint128=no
3859f540166bSRichard Hendersoncat > $TMPC << EOF
3860f540166bSRichard Henderson__int128_t a;
3861f540166bSRichard Henderson__uint128_t b;
3862f540166bSRichard Hendersonint main (void) {
3863f540166bSRichard Henderson  a = a + b;
3864f540166bSRichard Henderson  b = a * b;
3865464e3671SPeter Maydell  a = a * a;
3866f540166bSRichard Henderson  return 0;
3867f540166bSRichard Henderson}
3868f540166bSRichard HendersonEOF
3869f540166bSRichard Hendersonif compile_prog "" "" ; then
3870f540166bSRichard Henderson    int128=yes
3871f540166bSRichard Hendersonfi
387276a347e1SRichard Henderson
38737ebee43eSRichard Henderson#########################################
38747ebee43eSRichard Henderson# See if 128-bit atomic operations are supported.
38757ebee43eSRichard Henderson
38767ebee43eSRichard Hendersonatomic128=no
38777ebee43eSRichard Hendersonif test "$int128" = "yes"; then
38787ebee43eSRichard Henderson  cat > $TMPC << EOF
38797ebee43eSRichard Hendersonint main(void)
38807ebee43eSRichard Henderson{
38817ebee43eSRichard Henderson  unsigned __int128 x = 0, y = 0;
3882bceac547SThomas Huth  y = __atomic_load(&x, 0);
3883bceac547SThomas Huth  __atomic_store(&x, y, 0);
3884bceac547SThomas Huth  __atomic_compare_exchange(&x, &y, x, 0, 0, 0);
38857ebee43eSRichard Henderson  return 0;
38867ebee43eSRichard Henderson}
38877ebee43eSRichard HendersonEOF
38887ebee43eSRichard Henderson  if compile_prog "" "" ; then
38897ebee43eSRichard Henderson    atomic128=yes
38907ebee43eSRichard Henderson  fi
38917ebee43eSRichard Hendersonfi
38927ebee43eSRichard Henderson
3893e6cd4bb5SRichard Hendersoncmpxchg128=no
3894e633a5c6SEric Blakeif test "$int128" = yes && test "$atomic128" = no; then
3895e6cd4bb5SRichard Henderson  cat > $TMPC << EOF
3896e6cd4bb5SRichard Hendersonint main(void)
3897e6cd4bb5SRichard Henderson{
3898e6cd4bb5SRichard Henderson  unsigned __int128 x = 0, y = 0;
3899e6cd4bb5SRichard Henderson  __sync_val_compare_and_swap_16(&x, y, x);
3900e6cd4bb5SRichard Henderson  return 0;
3901e6cd4bb5SRichard Henderson}
3902e6cd4bb5SRichard HendersonEOF
3903e6cd4bb5SRichard Henderson  if compile_prog "" "" ; then
3904e6cd4bb5SRichard Henderson    cmpxchg128=yes
3905e6cd4bb5SRichard Henderson  fi
3906e6cd4bb5SRichard Hendersonfi
3907e6cd4bb5SRichard Henderson
3908df79b996SRichard Henderson#########################################
3909df79b996SRichard Henderson# See if 64-bit atomic operations are supported.
3910df79b996SRichard Henderson# Note that without __atomic builtins, we can only
3911df79b996SRichard Henderson# assume atomic loads/stores max at pointer size.
3912df79b996SRichard Henderson
3913df79b996SRichard Hendersoncat > $TMPC << EOF
3914df79b996SRichard Henderson#include <stdint.h>
3915df79b996SRichard Hendersonint main(void)
3916df79b996SRichard Henderson{
3917df79b996SRichard Henderson  uint64_t x = 0, y = 0;
3918df79b996SRichard Henderson#ifdef __ATOMIC_RELAXED
39195fe40765SThomas Huth  y = __atomic_load_n(&x, __ATOMIC_RELAXED);
39205fe40765SThomas Huth  __atomic_store_n(&x, y, __ATOMIC_RELAXED);
39215fe40765SThomas Huth  __atomic_compare_exchange_n(&x, &y, x, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
39225fe40765SThomas Huth  __atomic_exchange_n(&x, y, __ATOMIC_RELAXED);
39235fe40765SThomas Huth  __atomic_fetch_add(&x, y, __ATOMIC_RELAXED);
3924df79b996SRichard Henderson#else
3925df79b996SRichard Henderson  typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
3926df79b996SRichard Henderson  __sync_lock_test_and_set(&x, y);
3927df79b996SRichard Henderson  __sync_val_compare_and_swap(&x, y, 0);
3928df79b996SRichard Henderson  __sync_fetch_and_add(&x, y);
3929df79b996SRichard Henderson#endif
3930df79b996SRichard Henderson  return 0;
3931df79b996SRichard Henderson}
3932df79b996SRichard HendersonEOF
3933df79b996SRichard Hendersonif compile_prog "" "" ; then
3934df79b996SRichard Henderson  atomic64=yes
3935df79b996SRichard Hendersonfi
3936df79b996SRichard Henderson
393726fffe29SEmilio G. Cota#########################################
393826fffe29SEmilio G. Cota# See if --dynamic-list is supported by the linker
393926fffe29SEmilio G. Cotald_dynamic_list="no"
394026fffe29SEmilio G. Cotaif test "$static" = "no" ; then
394126fffe29SEmilio G. Cota    cat > $TMPTXT <<EOF
394226fffe29SEmilio G. Cota{
394326fffe29SEmilio G. Cota  foo;
394426fffe29SEmilio G. Cota};
394526fffe29SEmilio G. CotaEOF
394626fffe29SEmilio G. Cota
394726fffe29SEmilio G. Cota    cat > $TMPC <<EOF
394826fffe29SEmilio G. Cota#include <stdio.h>
394926fffe29SEmilio G. Cotavoid foo(void);
395026fffe29SEmilio G. Cota
395126fffe29SEmilio G. Cotavoid foo(void)
395226fffe29SEmilio G. Cota{
395326fffe29SEmilio G. Cota  printf("foo\n");
395426fffe29SEmilio G. Cota}
395526fffe29SEmilio G. Cota
395626fffe29SEmilio G. Cotaint main(void)
395726fffe29SEmilio G. Cota{
395826fffe29SEmilio G. Cota  foo();
395926fffe29SEmilio G. Cota  return 0;
396026fffe29SEmilio G. Cota}
396126fffe29SEmilio G. CotaEOF
396226fffe29SEmilio G. Cota
396326fffe29SEmilio G. Cota    if compile_prog "" "-Wl,--dynamic-list=$TMPTXT" ; then
396426fffe29SEmilio G. Cota        ld_dynamic_list="yes"
396526fffe29SEmilio G. Cota    fi
396626fffe29SEmilio G. Cotafi
396726fffe29SEmilio G. Cota
396826fffe29SEmilio G. Cota#########################################
396926fffe29SEmilio G. Cota# See if -exported_symbols_list is supported by the linker
397026fffe29SEmilio G. Cota
397126fffe29SEmilio G. Cotald_exported_symbols_list="no"
397226fffe29SEmilio G. Cotaif test "$static" = "no" ; then
397326fffe29SEmilio G. Cota    cat > $TMPTXT <<EOF
397426fffe29SEmilio G. Cota  _foo
397526fffe29SEmilio G. CotaEOF
397626fffe29SEmilio G. Cota
397726fffe29SEmilio G. Cota    if compile_prog "" "-Wl,-exported_symbols_list,$TMPTXT" ; then
397826fffe29SEmilio G. Cota        ld_exported_symbols_list="yes"
397926fffe29SEmilio G. Cota    fi
398026fffe29SEmilio G. Cotafi
398126fffe29SEmilio G. Cota
398226fffe29SEmilio G. Cotaif  test "$plugins" = "yes" &&
398326fffe29SEmilio G. Cota    test "$ld_dynamic_list" = "no" &&
398426fffe29SEmilio G. Cota    test "$ld_exported_symbols_list" = "no" ; then
398526fffe29SEmilio G. Cota  error_exit \
398626fffe29SEmilio G. Cota      "Plugin support requires dynamic linking and specifying a set of symbols " \
398726fffe29SEmilio G. Cota      "that are exported to plugins. Unfortunately your linker doesn't " \
398826fffe29SEmilio G. Cota      "support the flag (--dynamic-list or -exported_symbols_list) used " \
398926fffe29SEmilio G. Cota      "for this purpose. You can't build with --static."
399026fffe29SEmilio G. Cotafi
399126fffe29SEmilio G. Cota
39921e6e9acaSRichard Henderson########################################
39931e6e9acaSRichard Henderson# check if getauxval is available.
39941e6e9acaSRichard Henderson
39951e6e9acaSRichard Hendersongetauxval=no
39961e6e9acaSRichard Hendersoncat > $TMPC << EOF
39971e6e9acaSRichard Henderson#include <sys/auxv.h>
39981e6e9acaSRichard Hendersonint main(void) {
39991e6e9acaSRichard Henderson  return getauxval(AT_HWCAP) == 0;
40001e6e9acaSRichard Henderson}
40011e6e9acaSRichard HendersonEOF
40021e6e9acaSRichard Hendersonif compile_prog "" "" ; then
40031e6e9acaSRichard Henderson    getauxval=yes
40041e6e9acaSRichard Hendersonfi
40051e6e9acaSRichard Henderson
4006fd0e6053SJohn Snow########################################
4007fd0e6053SJohn Snow# check if ccache is interfering with
4008fd0e6053SJohn Snow# semantic analysis of macros
4009fd0e6053SJohn Snow
40105e4dfd3dSJohn Snowunset CCACHE_CPP2
4011fd0e6053SJohn Snowccache_cpp2=no
4012fd0e6053SJohn Snowcat > $TMPC << EOF
4013fd0e6053SJohn Snowstatic const int Z = 1;
4014fd0e6053SJohn Snow#define fn() ({ Z; })
4015fd0e6053SJohn Snow#define TAUT(X) ((X) == Z)
4016fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y)
4017fd0e6053SJohn Snow#define ID(X) (X)
4018fd0e6053SJohn Snowint main(int argc, char *argv[])
4019fd0e6053SJohn Snow{
4020fd0e6053SJohn Snow    int x = 0, y = 0;
4021fd0e6053SJohn Snow    x = ID(x);
4022fd0e6053SJohn Snow    x = fn();
4023fd0e6053SJohn Snow    fn();
4024fd0e6053SJohn Snow    if (PAREN(x, y)) return 0;
4025fd0e6053SJohn Snow    if (TAUT(Z)) return 0;
4026fd0e6053SJohn Snow    return 0;
4027fd0e6053SJohn Snow}
4028fd0e6053SJohn SnowEOF
4029fd0e6053SJohn Snow
4030fd0e6053SJohn Snowif ! compile_object "-Werror"; then
4031fd0e6053SJohn Snow    ccache_cpp2=yes
4032fd0e6053SJohn Snowfi
4033fd0e6053SJohn Snow
4034b553a042SJohn Snow#################################################
4035b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE.
4036b553a042SJohn Snow
4037b553a042SJohn Snowif test "$fortify_source" != "no"; then
4038b553a042SJohn Snow  if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
4039b553a042SJohn Snow    fortify_source="no";
4040e189091fSPeter Maydell  elif test -n "$cxx" && has $cxx &&
4041cfcc7c14SJohn Snow       echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
4042b553a042SJohn Snow    fortify_source="no";
4043b553a042SJohn Snow  else
4044b553a042SJohn Snow    fortify_source="yes"
4045b553a042SJohn Snow  fi
4046b553a042SJohn Snowfi
4047b553a042SJohn Snow
4048d2042378SAneesh Kumar K.V##########################################
4049277abf15SJan Vesely# check if struct fsxattr is available via linux/fs.h
4050277abf15SJan Vesely
4051277abf15SJan Veselyhave_fsxattr=no
4052277abf15SJan Veselycat > $TMPC << EOF
4053277abf15SJan Vesely#include <linux/fs.h>
4054277abf15SJan Veselystruct fsxattr foo;
4055277abf15SJan Veselyint main(void) {
4056277abf15SJan Vesely  return 0;
4057277abf15SJan Vesely}
4058277abf15SJan VeselyEOF
4059277abf15SJan Veselyif compile_prog "" "" ; then
4060277abf15SJan Vesely    have_fsxattr=yes
4061277abf15SJan Veselyfi
4062277abf15SJan Vesely
4063b66e10e4SPeter Maydell##########################################
4064a40161cbSPaolo Bonzini# check for usable membarrier system call
4065a40161cbSPaolo Bonziniif test "$membarrier" = "yes"; then
4066a40161cbSPaolo Bonzini    have_membarrier=no
4067a40161cbSPaolo Bonzini    if test "$mingw32" = "yes" ; then
4068a40161cbSPaolo Bonzini        have_membarrier=yes
4069a40161cbSPaolo Bonzini    elif test "$linux" = "yes" ; then
4070a40161cbSPaolo Bonzini        cat > $TMPC << EOF
4071a40161cbSPaolo Bonzini    #include <linux/membarrier.h>
4072a40161cbSPaolo Bonzini    #include <sys/syscall.h>
4073a40161cbSPaolo Bonzini    #include <unistd.h>
4074a40161cbSPaolo Bonzini    #include <stdlib.h>
4075a40161cbSPaolo Bonzini    int main(void) {
4076a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
4077a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0);
4078a40161cbSPaolo Bonzini	exit(0);
4079a40161cbSPaolo Bonzini    }
4080a40161cbSPaolo BonziniEOF
4081a40161cbSPaolo Bonzini        if compile_prog "" "" ; then
4082a40161cbSPaolo Bonzini            have_membarrier=yes
4083a40161cbSPaolo Bonzini        fi
4084a40161cbSPaolo Bonzini    fi
4085a40161cbSPaolo Bonzini    if test "$have_membarrier" = "no"; then
4086a40161cbSPaolo Bonzini      feature_not_found "membarrier" "membarrier system call not available"
4087a40161cbSPaolo Bonzini    fi
4088a40161cbSPaolo Bonzinielse
4089a40161cbSPaolo Bonzini    # Do not enable it by default even for Mingw32, because it doesn't
4090a40161cbSPaolo Bonzini    # work on Wine.
4091a40161cbSPaolo Bonzini    membarrier=no
4092a40161cbSPaolo Bonzinifi
4093a40161cbSPaolo Bonzini
4094a40161cbSPaolo Bonzini##########################################
40956a02c806SStefan Hajnoczi# check for usable AF_VSOCK environment
40966a02c806SStefan Hajnoczihave_af_vsock=no
40976a02c806SStefan Hajnoczicat > $TMPC << EOF
40986a02c806SStefan Hajnoczi#include <errno.h>
40996a02c806SStefan Hajnoczi#include <sys/types.h>
41006a02c806SStefan Hajnoczi#include <sys/socket.h>
41016a02c806SStefan Hajnoczi#if !defined(AF_VSOCK)
41026a02c806SStefan Hajnoczi# error missing AF_VSOCK flag
41036a02c806SStefan Hajnoczi#endif
41046a02c806SStefan Hajnoczi#include <linux/vm_sockets.h>
41056a02c806SStefan Hajnocziint main(void) {
41066a02c806SStefan Hajnoczi    int sock, ret;
41076a02c806SStefan Hajnoczi    struct sockaddr_vm svm;
41086a02c806SStefan Hajnoczi    socklen_t len = sizeof(svm);
41096a02c806SStefan Hajnoczi    sock = socket(AF_VSOCK, SOCK_STREAM, 0);
41106a02c806SStefan Hajnoczi    ret = getpeername(sock, (struct sockaddr *)&svm, &len);
41116a02c806SStefan Hajnoczi    if ((ret == -1) && (errno == ENOTCONN)) {
41126a02c806SStefan Hajnoczi        return 0;
41136a02c806SStefan Hajnoczi    }
41146a02c806SStefan Hajnoczi    return -1;
41156a02c806SStefan Hajnoczi}
41166a02c806SStefan HajnocziEOF
41176a02c806SStefan Hajnocziif compile_prog "" "" ; then
41186a02c806SStefan Hajnoczi    have_af_vsock=yes
41196a02c806SStefan Hajnoczifi
41206a02c806SStefan Hajnoczi
4121f0d92b56SLongpeng(Mike)##########################################
4122f0d92b56SLongpeng(Mike)# check for usable AF_ALG environment
41234f67366eSThomas Huthhave_afalg=no
4124f0d92b56SLongpeng(Mike)cat > $TMPC << EOF
4125f0d92b56SLongpeng(Mike)#include <errno.h>
4126f0d92b56SLongpeng(Mike)#include <sys/types.h>
4127f0d92b56SLongpeng(Mike)#include <sys/socket.h>
4128f0d92b56SLongpeng(Mike)#include <linux/if_alg.h>
4129f0d92b56SLongpeng(Mike)int main(void) {
4130f0d92b56SLongpeng(Mike)    int sock;
4131f0d92b56SLongpeng(Mike)    sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
4132f0d92b56SLongpeng(Mike)    return sock;
4133f0d92b56SLongpeng(Mike)}
4134f0d92b56SLongpeng(Mike)EOF
4135f0d92b56SLongpeng(Mike)if compile_prog "" "" ; then
4136f0d92b56SLongpeng(Mike)    have_afalg=yes
4137f0d92b56SLongpeng(Mike)fi
4138f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes"
4139f0d92b56SLongpeng(Mike)then
4140f0d92b56SLongpeng(Mike)    if test "$have_afalg" != "yes"
4141f0d92b56SLongpeng(Mike)    then
4142f0d92b56SLongpeng(Mike)	error_exit "AF_ALG requested but could not be detected"
4143f0d92b56SLongpeng(Mike)    fi
4144f0d92b56SLongpeng(Mike)fi
4145f0d92b56SLongpeng(Mike)
4146f0d92b56SLongpeng(Mike)
4147db1ed1abSRichard Henderson##########################################
4148247724cbSMarc-André Lureau# checks for sanitizers
4149247724cbSMarc-André Lureau
4150247724cbSMarc-André Lureauhave_asan=no
4151247724cbSMarc-André Lureauhave_ubsan=no
4152d83414e1SMarc-André Lureauhave_asan_iface_h=no
4153d83414e1SMarc-André Lureauhave_asan_iface_fiber=no
4154247724cbSMarc-André Lureau
4155247724cbSMarc-André Lureauif test "$sanitizers" = "yes" ; then
4156b9f44da2SMarc-André Lureau  write_c_skeleton
4157247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
4158247724cbSMarc-André Lureau      have_asan=yes
4159247724cbSMarc-André Lureau  fi
4160b9f44da2SMarc-André Lureau
4161b9f44da2SMarc-André Lureau  # we could use a simple skeleton for flags checks, but this also
4162b9f44da2SMarc-André Lureau  # detect the static linking issue of ubsan, see also:
4163b9f44da2SMarc-André Lureau  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
4164b9f44da2SMarc-André Lureau  cat > $TMPC << EOF
4165b9f44da2SMarc-André Lureau#include <stdlib.h>
4166b9f44da2SMarc-André Lureauint main(void) {
4167b9f44da2SMarc-André Lureau    void *tmp = malloc(10);
4168f2dfe54cSLeonid Bloch    if (tmp != NULL) {
4169b9f44da2SMarc-André Lureau        return *(int *)(tmp + 2);
4170b9f44da2SMarc-André Lureau    }
4171d1abf3fcSOlaf Hering    return 1;
4172f2dfe54cSLeonid Bloch}
4173b9f44da2SMarc-André LureauEOF
4174247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
4175247724cbSMarc-André Lureau      have_ubsan=yes
4176247724cbSMarc-André Lureau  fi
4177d83414e1SMarc-André Lureau
4178d83414e1SMarc-André Lureau  if check_include "sanitizer/asan_interface.h" ; then
4179d83414e1SMarc-André Lureau      have_asan_iface_h=yes
4180d83414e1SMarc-André Lureau  fi
4181d83414e1SMarc-André Lureau
4182d83414e1SMarc-André Lureau  cat > $TMPC << EOF
4183d83414e1SMarc-André Lureau#include <sanitizer/asan_interface.h>
4184d83414e1SMarc-André Lureauint main(void) {
4185d83414e1SMarc-André Lureau  __sanitizer_start_switch_fiber(0, 0, 0);
4186d83414e1SMarc-André Lureau  return 0;
4187d83414e1SMarc-André Lureau}
4188d83414e1SMarc-André LureauEOF
4189d83414e1SMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
4190d83414e1SMarc-André Lureau      have_asan_iface_fiber=yes
4191d83414e1SMarc-André Lureau  fi
4192247724cbSMarc-André Lureaufi
4193247724cbSMarc-André Lureau
4194247724cbSMarc-André Lureau##########################################
4195adc28027SAlexander Bulekov# checks for fuzzer
419654c9e41dSAlexander Bulekovif test "$fuzzing" = "yes" && test -z "${LIB_FUZZING_ENGINE+xxx}"; then
4197adc28027SAlexander Bulekov  write_c_fuzzer_skeleton
4198dd016265SAlexander Bulekov  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=fuzzer" ""; then
4199adc28027SAlexander Bulekov    have_fuzzer=yes
420064ed6f92SPaolo Bonzini  else
420164ed6f92SPaolo Bonzini    error_exit "Your compiler doesn't support -fsanitize=fuzzer"
420264ed6f92SPaolo Bonzini    exit 1
4203adc28027SAlexander Bulekov  fi
4204adc28027SAlexander Bulekovfi
4205adc28027SAlexander Bulekov
42060aebab04SLingfeng Yang# Thread sanitizer is, for now, much noisier than the other sanitizers;
42070aebab04SLingfeng Yang# keep it separate until that is not the case.
42080aebab04SLingfeng Yangif test "$tsan" = "yes" && test "$sanitizers" = "yes"; then
42090aebab04SLingfeng Yang  error_exit "TSAN is not supported with other sanitiziers."
42100aebab04SLingfeng Yangfi
42110aebab04SLingfeng Yanghave_tsan=no
42120aebab04SLingfeng Yanghave_tsan_iface_fiber=no
42130aebab04SLingfeng Yangif test "$tsan" = "yes" ; then
42140aebab04SLingfeng Yang  write_c_skeleton
42150aebab04SLingfeng Yang  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
42160aebab04SLingfeng Yang      have_tsan=yes
42170aebab04SLingfeng Yang  fi
42180aebab04SLingfeng Yang  cat > $TMPC << EOF
42190aebab04SLingfeng Yang#include <sanitizer/tsan_interface.h>
42200aebab04SLingfeng Yangint main(void) {
42210aebab04SLingfeng Yang  __tsan_create_fiber(0);
42220aebab04SLingfeng Yang  return 0;
42230aebab04SLingfeng Yang}
42240aebab04SLingfeng YangEOF
42250aebab04SLingfeng Yang  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
42260aebab04SLingfeng Yang      have_tsan_iface_fiber=yes
42270aebab04SLingfeng Yang  fi
42280aebab04SLingfeng Yangfi
42290aebab04SLingfeng Yang
4230adc28027SAlexander Bulekov##########################################
4231675b9b53SMarc-André Lureau# check for slirp
4232675b9b53SMarc-André Lureau
4233675b9b53SMarc-André Lureaucase "$slirp" in
42344d34a86bSPaolo Bonzini  auto | enabled | internal)
42354d34a86bSPaolo Bonzini    # Simpler to always update submodule, even if not needed.
42367c57bdd8SMarc-André Lureau    git_submodules="${git_submodules} slirp"
4237675b9b53SMarc-André Lureau    ;;
4238675b9b53SMarc-André Lureauesac
4239675b9b53SMarc-André Lureau
4240b8e0c493SJoelle van Dyne# Check for slirp smbd dupport
4241b8e0c493SJoelle van Dyne: ${smbd=${SMBD-/usr/sbin/smbd}}
4242b8e0c493SJoelle van Dyneif test "$slirp_smbd" != "no" ; then
4243b8e0c493SJoelle van Dyne  if test "$mingw32" = "yes" ; then
4244b8e0c493SJoelle van Dyne    if test "$slirp_smbd" = "yes" ; then
4245b8e0c493SJoelle van Dyne      error_exit "Host smbd not supported on this platform."
4246b8e0c493SJoelle van Dyne    fi
4247b8e0c493SJoelle van Dyne    slirp_smbd=no
4248b8e0c493SJoelle van Dyne  else
4249b8e0c493SJoelle van Dyne    slirp_smbd=yes
4250b8e0c493SJoelle van Dyne  fi
4251b8e0c493SJoelle van Dynefi
4252b8e0c493SJoelle van Dyne
425354e7aac0SAlexey Krasikov##########################################
425454e7aac0SAlexey Krasikov# check for usable __NR_keyctl syscall
425554e7aac0SAlexey Krasikov
425654e7aac0SAlexey Krasikovif test "$linux" = "yes" ; then
425754e7aac0SAlexey Krasikov
425854e7aac0SAlexey Krasikov    have_keyring=no
425954e7aac0SAlexey Krasikov    cat > $TMPC << EOF
426054e7aac0SAlexey Krasikov#include <errno.h>
426154e7aac0SAlexey Krasikov#include <asm/unistd.h>
426254e7aac0SAlexey Krasikov#include <linux/keyctl.h>
426354e7aac0SAlexey Krasikov#include <unistd.h>
426454e7aac0SAlexey Krasikovint main(void) {
426554e7aac0SAlexey Krasikov    return syscall(__NR_keyctl, KEYCTL_READ, 0, NULL, NULL, 0);
426654e7aac0SAlexey Krasikov}
426754e7aac0SAlexey KrasikovEOF
426854e7aac0SAlexey Krasikov    if compile_prog "" "" ; then
426954e7aac0SAlexey Krasikov        have_keyring=yes
427054e7aac0SAlexey Krasikov    fi
427154e7aac0SAlexey Krasikovfi
427254e7aac0SAlexey Krasikovif test "$secret_keyring" != "no"
427354e7aac0SAlexey Krasikovthen
4274b418d265SDavid Edmondson    if test "$have_keyring" = "yes"
427554e7aac0SAlexey Krasikov    then
427654e7aac0SAlexey Krasikov	secret_keyring=yes
427754e7aac0SAlexey Krasikov    else
427854e7aac0SAlexey Krasikov	if test "$secret_keyring" = "yes"
427954e7aac0SAlexey Krasikov	then
428054e7aac0SAlexey Krasikov	    error_exit "syscall __NR_keyctl requested, \
428154e7aac0SAlexey Krasikovbut not implemented on your system"
428254e7aac0SAlexey Krasikov	else
428354e7aac0SAlexey Krasikov	    secret_keyring=no
428454e7aac0SAlexey Krasikov	fi
428554e7aac0SAlexey Krasikov    fi
428654e7aac0SAlexey Krasikovfi
428754e7aac0SAlexey Krasikov
428892500362SAlexey Krasikov##########################################
4289e86ecd4bSJuan Quintela# End of CC checks
4290e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
4291e86ecd4bSJuan Quintela
4292d83414e1SMarc-André Lureauwrite_c_skeleton
4293d83414e1SMarc-André Lureau
42941d728c39SBlue Swirlif test "$gcov" = "yes" ; then
4295bf0e56a3SMarc-André Lureau  :
4296b553a042SJohn Snowelif test "$fortify_source" = "yes" ; then
4297086d5f75SPaolo Bonzini  QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
4298086d5f75SPaolo Bonzini  debug=no
4299086d5f75SPaolo Bonzinifi
4300086d5f75SPaolo Bonzini
4301086d5f75SPaolo Bonzinicase "$ARCH" in
4302086d5f75SPaolo Bonzinialpha)
4303086d5f75SPaolo Bonzini  # Ensure there's only a single GP
4304086d5f75SPaolo Bonzini  QEMU_CFLAGS="-msmall-data $QEMU_CFLAGS"
4305086d5f75SPaolo Bonzini;;
4306086d5f75SPaolo Bonziniesac
4307086d5f75SPaolo Bonzini
4308086d5f75SPaolo Bonziniif test "$gprof" = "yes" ; then
4309086d5f75SPaolo Bonzini  QEMU_CFLAGS="-p $QEMU_CFLAGS"
4310086d5f75SPaolo Bonzini  QEMU_LDFLAGS="-p $QEMU_LDFLAGS"
4311086d5f75SPaolo Bonzinifi
4312a316e378SJuan Quintela
4313247724cbSMarc-André Lureauif test "$have_asan" = "yes"; then
4314db5adeaaSPaolo Bonzini  QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS"
4315db5adeaaSPaolo Bonzini  QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS"
4316d83414e1SMarc-André Lureau  if test "$have_asan_iface_h" = "no" ; then
4317d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header missing." \
4318d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
4319d83414e1SMarc-André Lureau  elif test "$have_asan_iface_fiber" = "no" ; then
4320d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header is too old." \
4321d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
4322d83414e1SMarc-André Lureau  fi
4323247724cbSMarc-André Lureaufi
43240aebab04SLingfeng Yangif test "$have_tsan" = "yes" ; then
43250aebab04SLingfeng Yang  if test "$have_tsan_iface_fiber" = "yes" ; then
43260aebab04SLingfeng Yang    QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS"
43270aebab04SLingfeng Yang    QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS"
43280aebab04SLingfeng Yang  else
43290aebab04SLingfeng Yang    error_exit "Cannot enable TSAN due to missing fiber annotation interface."
43300aebab04SLingfeng Yang  fi
43310aebab04SLingfeng Yangelif test "$tsan" = "yes" ; then
43320aebab04SLingfeng Yang  error_exit "Cannot enable TSAN due to missing sanitize thread interface."
43330aebab04SLingfeng Yangfi
4334247724cbSMarc-André Lureauif test "$have_ubsan" = "yes"; then
4335db5adeaaSPaolo Bonzini  QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS"
4336db5adeaaSPaolo Bonzini  QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS"
4337247724cbSMarc-André Lureaufi
4338247724cbSMarc-André Lureau
43396542aa9cSPeter Lieven##########################################
43403efac6ebSTomáš Golembiovský
43410aebab04SLingfeng Yang# Exclude --warn-common with TSan to suppress warnings from the TSan libraries.
43420aebab04SLingfeng Yangif test "$solaris" = "no" && test "$tsan" = "no"; then
4343e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
4344db5adeaaSPaolo Bonzini        QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS"
4345e86ecd4bSJuan Quintela    fi
4346e86ecd4bSJuan Quintelafi
4347e86ecd4bSJuan Quintela
4348952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
4349952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
4350cb8baa77SMark Cave-Ayland    flags="--no-seh --nxcompat"
4351cb8baa77SMark Cave-Ayland
4352cb8baa77SMark Cave-Ayland    # Disable ASLR for debug builds to allow debugging with gdb
4353cb8baa77SMark Cave-Ayland    if test "$debug" = "no" ; then
4354cb8baa77SMark Cave-Ayland        flags="--dynamicbase $flags"
4355cb8baa77SMark Cave-Ayland    fi
4356cb8baa77SMark Cave-Ayland
4357cb8baa77SMark Cave-Ayland    for flag in $flags; do
4358e9a3591fSChristian Borntraeger        if ld_has $flag ; then
4359db5adeaaSPaolo Bonzini            QEMU_LDFLAGS="-Wl,$flag $QEMU_LDFLAGS"
4360952afb71SBlue Swirl        fi
4361952afb71SBlue Swirl    done
4362952afb71SBlue Swirlfi
4363952afb71SBlue Swirl
43649d6bc27bSMichael Roth# Probe for guest agent support/options
43659d6bc27bSMichael Roth
4366e8ef31a3SMichael Tokarevif [ "$guest_agent" != "no" ]; then
4367a5125905SLaurent Vivier  if [ "$softmmu" = no -a "$want_tools" = no ] ; then
4368a5125905SLaurent Vivier      guest_agent=no
4369a5125905SLaurent Vivier  elif [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
4370e8ef31a3SMichael Tokarev      guest_agent=yes
4371e8ef31a3SMichael Tokarev  elif [ "$guest_agent" != yes ]; then
4372e8ef31a3SMichael Tokarev      guest_agent=no
4373e8ef31a3SMichael Tokarev  else
4374e8ef31a3SMichael Tokarev      error_exit "Guest agent is not supported on this platform"
4375ca35f780SPaolo Bonzini  fi
43764b1c11fdSDaniel P. Berrangefi
4377ca35f780SPaolo Bonzini
4378b846ab7cSPaolo Bonzini# Guest agent Windows MSI package
43799d6bc27bSMichael Roth
43809d6bc27bSMichael Rothif test "$QEMU_GA_MANUFACTURER" = ""; then
43819d6bc27bSMichael Roth  QEMU_GA_MANUFACTURER=QEMU
43829d6bc27bSMichael Rothfi
43839d6bc27bSMichael Rothif test "$QEMU_GA_DISTRO" = ""; then
43849d6bc27bSMichael Roth  QEMU_GA_DISTRO=Linux
43859d6bc27bSMichael Rothfi
43869d6bc27bSMichael Rothif test "$QEMU_GA_VERSION" = ""; then
438789138857SStefan Weil    QEMU_GA_VERSION=$(cat $source_path/VERSION)
43889d6bc27bSMichael Rothfi
43899d6bc27bSMichael Roth
4390b846ab7cSPaolo BonziniQEMU_GA_MSI_MINGW_DLL_PATH="$($pkg_config --variable=prefix glib-2.0)/bin"
43919d6bc27bSMichael Roth
4392ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
4393ca35f780SPaolo Bonziniroms=
4394e633a5c6SEric Blakeif { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \
4395e633a5c6SEric Blake        test "$targetos" != "Darwin" && test "$targetos" != "SunOS" && \
43967000a12eSThomas Huth        test "$targetos" != "Haiku" && test "$softmmu" = yes ; then
4397e57218b6SPeter Maydell    # Different host OS linkers have different ideas about the name of the ELF
4398c65d5e4eSBrad Smith    # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
4399c65d5e4eSBrad Smith    # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
4400c65d5e4eSBrad Smith    for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
4401e57218b6SPeter Maydell        if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
4402e57218b6SPeter Maydell            ld_i386_emulation="$emu"
4403ca35f780SPaolo Bonzini            roms="optionrom"
4404e57218b6SPeter Maydell            break
4405e57218b6SPeter Maydell        fi
4406e57218b6SPeter Maydell    done
4407ca35f780SPaolo Bonzinifi
4408ca35f780SPaolo Bonzini
44092e33c3f8SThomas Huth# Only build s390-ccw bios if we're on s390x and the compiler has -march=z900
4410a5b2afd5SThomas Huth# or -march=z10 (which is the lowest architecture level that Clang supports)
44119933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then
44122e33c3f8SThomas Huth  write_c_skeleton
4413a5b2afd5SThomas Huth  compile_prog "-march=z900" ""
4414a5b2afd5SThomas Huth  has_z900=$?
44153af448b3SThomas Huth  if [ $has_z900 = 0 ] || compile_object "-march=z10 -msoft-float -Werror"; then
4416a5b2afd5SThomas Huth    if [ $has_z900 != 0 ]; then
4417a5b2afd5SThomas Huth      echo "WARNING: Your compiler does not support the z900!"
4418a5b2afd5SThomas Huth      echo "         The s390-ccw bios will only work with guest CPUs >= z10."
4419a5b2afd5SThomas Huth    fi
44209933c305SChristian Borntraeger    roms="$roms s390-ccw"
44211ef6bfc2SPhilippe Mathieu-Daudé    # SLOF is required for building the s390-ccw firmware on s390x,
44221ef6bfc2SPhilippe Mathieu-Daudé    # since it is using the libnet code from SLOF for network booting.
44231ef6bfc2SPhilippe Mathieu-Daudé    git_submodules="${git_submodules} roms/SLOF"
44241ef6bfc2SPhilippe Mathieu-Daudé  fi
44259933c305SChristian Borntraegerfi
44269933c305SChristian Borntraeger
442711cde1c8SBruno Dominguez# Check that the C++ compiler exists and works with the C compiler.
442811cde1c8SBruno 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.
442911cde1c8SBruno Dominguezif has $cxx; then
443011cde1c8SBruno Dominguez    cat > $TMPC <<EOF
443111cde1c8SBruno Dominguezint c_function(void);
443211cde1c8SBruno Dominguezint main(void) { return c_function(); }
443311cde1c8SBruno DominguezEOF
443411cde1c8SBruno Dominguez
443511cde1c8SBruno Dominguez    compile_object
443611cde1c8SBruno Dominguez
443711cde1c8SBruno Dominguez    cat > $TMPCXX <<EOF
443811cde1c8SBruno Dominguezextern "C" {
443911cde1c8SBruno Dominguez   int c_function(void);
444011cde1c8SBruno Dominguez}
444111cde1c8SBruno Dominguezint c_function(void) { return 42; }
444211cde1c8SBruno DominguezEOF
444311cde1c8SBruno Dominguez
444411cde1c8SBruno Dominguez    update_cxxflags
444511cde1c8SBruno Dominguez
44465770e8afSPaolo Bonzini    if do_cxx $CXXFLAGS $CONFIGURE_CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then
444711cde1c8SBruno Dominguez        # C++ compiler $cxx works ok with C compiler $cc
444811cde1c8SBruno Dominguez        :
444911cde1c8SBruno Dominguez    else
445011cde1c8SBruno Dominguez        echo "C++ compiler $cxx does not work with C compiler $cc"
445111cde1c8SBruno Dominguez        echo "Disabling C++ specific optional code"
445211cde1c8SBruno Dominguez        cxx=
445311cde1c8SBruno Dominguez    fi
445411cde1c8SBruno Dominguezelse
445511cde1c8SBruno Dominguez    echo "No C++ compiler available; disabling C++ specific optional code"
445611cde1c8SBruno Dominguez    cxx=
445711cde1c8SBruno Dominguezfi
445811cde1c8SBruno Dominguez
44597d7dbf9dSDan Streetmanif !(GIT="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then
44607d7dbf9dSDan Streetman    exit 1
44615d91a2edSYonggang Luofi
44625d91a2edSYonggang Luo
446398ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
446497a847bcSbellard
446598ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
446698ec69acSJuan Quintelaecho >> $config_host_mak
446798ec69acSJuan Quintela
4468e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
4469cc84d63aSDaniel P. Berrangeecho "GIT=$git" >> $config_host_mak
4470aef45d51SDaniel P. Berrangeecho "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
44717d7dbf9dSDan Streetmanecho "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak
4472804edf29SJuan Quintela
447398ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
4474727e5283SPaolo Bonzini
4475f8393946Saurel32if test "$debug_tcg" = "yes" ; then
44762358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
4477f8393946Saurel32fi
44781625af87Saliguoriif test "$strip_opt" = "yes" ; then
447952ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
44801625af87Saliguorifi
44817d13299dSbellardif test "$bigendian" = "yes" ; then
4482e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
448397a847bcSbellardfi
448467b915a5Sbellardif test "$mingw32" = "yes" ; then
448598ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
4486d9840e25STomoki Sekiyama  if test "$guest_agent_with_vss" = "yes" ; then
4487d9840e25STomoki Sekiyama    echo "CONFIG_QGA_VSS=y" >> $config_host_mak
4488f33ca81fSMichael Roth    echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
4489d9840e25STomoki Sekiyama    echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
4490d9840e25STomoki Sekiyama  fi
449150cbebb9SMichael Roth  if test "$guest_agent_ntddscsi" = "yes" ; then
449276dc75caSTomáš Golembiovský    echo "CONFIG_QGA_NTDDSCSI=y" >> $config_host_mak
449350cbebb9SMichael Roth  fi
44949dacf32dSYossi Hindin  echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
44959dacf32dSYossi Hindin  echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
44969dacf32dSYossi Hindin  echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
44979dacf32dSYossi Hindin  echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
4498210fa556Spbrookelse
449935f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
4500210fa556Spbrookfi
4501128ab2ffSblueswir1
4502dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
4503dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
4504dffcb71cSMark McLoughlinfi
4505dffcb71cSMark McLoughlin
450683fb7adfSbellardif test "$darwin" = "yes" ; then
450798ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
450883fb7adfSbellardfi
4509b29fe3edSmalc
4510ec530c81Sbellardif test "$solaris" = "yes" ; then
451198ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
4512ec530c81Sbellardfi
4513179cf400SAndreas Färberif test "$haiku" = "yes" ; then
4514179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
4515179cf400SAndreas Färberfi
451697a847bcSbellardif test "$static" = "yes" ; then
451798ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
451897a847bcSbellardfi
45191ba16968SStefan Weilif test "$profiler" = "yes" ; then
45202358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
452105c2a3e7Sbellardfi
4522c932ce31SPaolo Bonziniif test "$want_tools" = "yes" ; then
4523c932ce31SPaolo Bonzini  echo "CONFIG_TOOLS=y" >> $config_host_mak
4524c932ce31SPaolo Bonzinifi
4525f15bff25SPaolo Bonziniif test "$guest_agent" = "yes" ; then
4526f15bff25SPaolo Bonzini  echo "CONFIG_GUEST_AGENT=y" >> $config_host_mak
4527f15bff25SPaolo Bonzinifi
4528b8e0c493SJoelle van Dyneif test "$slirp_smbd" = "yes" ; then
4529b8e0c493SJoelle van Dyne  echo "CONFIG_SLIRP_SMBD=y" >> $config_host_mak
4530e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
4531b8e0c493SJoelle van Dynefi
45328a16d273Sthsif test "$vde" = "yes" ; then
453398ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
4534e2ad6f16SFam Zheng  echo "VDE_LIBS=$vde_libs" >> $config_host_mak
45358a16d273Sthsfi
453658952137SVincenzo Maffioneif test "$netmap" = "yes" ; then
453758952137SVincenzo Maffione  echo "CONFIG_NETMAP=y" >> $config_host_mak
453858952137SVincenzo Maffionefi
4539015a33bdSGongleiif test "$l2tpv3" = "yes" ; then
4540015a33bdSGonglei  echo "CONFIG_L2TPV3=y" >> $config_host_mak
4541015a33bdSGongleifi
45424cc600d2SPaolo Bonziniif test "$gprof" = "yes" ; then
45434cc600d2SPaolo Bonzini  echo "CONFIG_GPROF=y" >> $config_host_mak
45444cc600d2SPaolo Bonzinifi
45452358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
45460c58ac1cSmalcfor drv in $audio_drv_list; do
45471ef1ec2aSGerd Hoffmann    def=CONFIG_AUDIO_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
4548484e2cc7SPaolo Bonzini    echo "$def=y" >> $config_host_mak
45490c58ac1cSmalcdone
4550478e943fSPaolo Bonziniif test "$alsa" = "yes" ; then
4551478e943fSPaolo Bonzini    echo "CONFIG_ALSA=y" >> $config_host_mak
4552478e943fSPaolo Bonzinifi
4553b1149911SFam Zhengecho "ALSA_LIBS=$alsa_libs" >> $config_host_mak
4554478e943fSPaolo Bonziniecho "ALSA_CFLAGS=$alsa_cflags" >> $config_host_mak
4555478e943fSPaolo Bonziniif test "$libpulse" = "yes" ; then
4556478e943fSPaolo Bonzini    echo "CONFIG_LIBPULSE=y" >> $config_host_mak
4557478e943fSPaolo Bonzinifi
4558b1149911SFam Zhengecho "PULSE_LIBS=$pulse_libs" >> $config_host_mak
4559478e943fSPaolo Bonziniecho "PULSE_CFLAGS=$pulse_cflags" >> $config_host_mak
4560b1149911SFam Zhengecho "COREAUDIO_LIBS=$coreaudio_libs" >> $config_host_mak
4561b1149911SFam Zhengecho "DSOUND_LIBS=$dsound_libs" >> $config_host_mak
4562b1149911SFam Zhengecho "OSS_LIBS=$oss_libs" >> $config_host_mak
4563478e943fSPaolo Bonziniif test "$libjack" = "yes" ; then
4564478e943fSPaolo Bonzini    echo "CONFIG_LIBJACK=y" >> $config_host_mak
4565478e943fSPaolo Bonzinifi
45662e445703SGeoffrey McRaeecho "JACK_LIBS=$jack_libs" >> $config_host_mak
4567d5631638Smalcif test "$audio_win_int" = "yes" ; then
4568d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
4569d5631638Smalcfi
4570b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
4571b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
4572dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
4573dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
4574dce512deSChristoph Hellwigfi
457589138857SStefan Weilqemu_version=$(head $source_path/VERSION)
45762358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
457798ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
45782b1f35b9SAlex Bennéeecho "TARGET_DIRS=$target_list" >> $config_host_mak
457917969268SFam Zhengif test "$modules" = "yes"; then
4580e26110cfSFam Zheng  # $shacmd can generate a hash started with digit, which the compiler doesn't
4581e26110cfSFam Zheng  # like as an symbol. So prefix it with an underscore
458289138857SStefan Weil  echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
458317969268SFam Zheng  echo "CONFIG_MODULES=y" >> $config_host_mak
458417969268SFam Zhengfi
4585bd83c861SChristian Ehrhardtif test "$module_upgrades" = "yes"; then
4586bd83c861SChristian Ehrhardt  echo "CONFIG_MODULE_UPGRADES=y" >> $config_host_mak
4587bd83c861SChristian Ehrhardtfi
4588955727d2SCortland Tölvaif test "$have_usbfs" = "yes" ; then
4589955727d2SCortland Tölva  echo "CONFIG_USBFS=y" >> $config_host_mak
4590955727d2SCortland Tölvafi
4591f876b765SMarc-André Lureauif test "$gio" = "yes" ; then
4592f876b765SMarc-André Lureau    echo "CONFIG_GIO=y" >> $config_host_mak
4593f876b765SMarc-André Lureau    echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak
4594f876b765SMarc-André Lureau    echo "GIO_LIBS=$gio_libs" >> $config_host_mak
45955ecfb76cSPaolo Bonzinifi
45965ecfb76cSPaolo Bonziniif test "$gdbus_codegen" != "" ; then
459725a97a56SMarc-André Lureau    echo "GDBUS_CODEGEN=$gdbus_codegen" >> $config_host_mak
4598f876b765SMarc-André Lureaufi
4599a1c5e949SDaniel P. Berrangeecho "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
4600277abf15SJan Vesely
4601277abf15SJan Vesely# Work around a system header bug with some kernel/XFS header
4602277abf15SJan Vesely# versions where they both try to define 'struct fsxattr':
4603277abf15SJan Vesely# xfs headers will not try to redefine structs from linux headers
4604277abf15SJan Vesely# if this macro is set.
4605277abf15SJan Veselyif test "$have_fsxattr" = "yes" ; then
4606277abf15SJan Vesely    echo "HAVE_FSXATTR=y" >> $config_host_mak
4607277abf15SJan Veselyfi
46081badb709SPaolo Bonziniif test "$xen" = "enabled" ; then
46096dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
4610d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
4611582ea95fSMarc-André Lureau  echo "XEN_CFLAGS=$xen_cflags" >> $config_host_mak
4612582ea95fSMarc-André Lureau  echo "XEN_LIBS=$xen_libs" >> $config_host_mak
4613e37630caSaliguorifi
46145c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
46155c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
46165c6c3a6cSChristoph Hellwigfi
46175e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then
46185e9be92dSNicholas Bellinger  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
46195e9be92dSNicholas Bellingerfi
4620af3bba76SPaolo Bonziniif test "$vhost_net" = "yes" ; then
4621af3bba76SPaolo Bonzini  echo "CONFIG_VHOST_NET=y" >> $config_host_mak
4622af3bba76SPaolo Bonzinifi
4623af3bba76SPaolo Bonziniif test "$vhost_net_user" = "yes" ; then
462456f41de7SPaolo Bonzini  echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak
462503ce5744SNikolay Nikolaevfi
4626108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" ; then
4627108a6481SCindy Lu  echo "CONFIG_VHOST_NET_VDPA=y" >> $config_host_mak
4628108a6481SCindy Lufi
4629042cea27SGongleiif test "$vhost_crypto" = "yes" ; then
4630042cea27SGonglei  echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
4631042cea27SGongleifi
4632fc0b9b0eSStefan Hajnocziif test "$vhost_vsock" = "yes" ; then
4633fc0b9b0eSStefan Hajnoczi  echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
46345fe97d88SStefano Garzarella  if test "$vhost_user" = "yes" ; then
46355fe97d88SStefano Garzarella    echo "CONFIG_VHOST_USER_VSOCK=y" >> $config_host_mak
46365fe97d88SStefano Garzarella  fi
4637fc0b9b0eSStefan Hajnoczifi
4638299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" ; then
4639299e6f19SPaolo Bonzini  echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak
4640299e6f19SPaolo Bonzinifi
4641e6a74868SMarc-André Lureauif test "$vhost_user" = "yes" ; then
4642e6a74868SMarc-André Lureau  echo "CONFIG_VHOST_USER=y" >> $config_host_mak
4643e6a74868SMarc-André Lureaufi
4644108a6481SCindy Luif test "$vhost_vdpa" = "yes" ; then
4645108a6481SCindy Lu  echo "CONFIG_VHOST_VDPA=y" >> $config_host_mak
4646108a6481SCindy Lufi
464798fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" ; then
464898fc1adaSDr. David Alan Gilbert  echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak
464998fc1adaSDr. David Alan Gilbertfi
4650bf9298b9Saliguoriif test "$iovec" = "yes" ; then
46512358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
4652bf9298b9Saliguorifi
4653a40161cbSPaolo Bonziniif test "$membarrier" = "yes" ; then
4654a40161cbSPaolo Bonzini  echo "CONFIG_MEMBARRIER=y" >> $config_host_mak
4655a40161cbSPaolo Bonzinifi
4656e5b46549SRichard Hendersonif test "$tcg" = "enabled" -a "$tcg_interpreter" = "true" ; then
4657e5b46549SRichard Henderson  echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
4658e5b46549SRichard Hendersonfi
465958d3f3ffSGerd Hoffmann
466058d3f3ffSGerd Hoffmannif test "$spice_protocol" = "yes" ; then
466158d3f3ffSGerd Hoffmann  echo "CONFIG_SPICE_PROTOCOL=y" >> $config_host_mak
466258d3f3ffSGerd Hoffmann  echo "SPICE_PROTOCOL_CFLAGS=$spice_protocol_cflags" >> $config_host_mak
466358d3f3ffSGerd Hoffmannfi
4664cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
4665cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
466658d3f3ffSGerd Hoffmann  echo "SPICE_CFLAGS=$spice_cflags $spice_protocol_cflags" >> $config_host_mak
46672634733cSPaolo Bonzini  echo "SPICE_LIBS=$spice_libs" >> $config_host_mak
4668cd4ec0b4SGerd Hoffmannfi
4669cd4ec0b4SGerd Hoffmann
4670da076ffeSGerd Hoffmannif test "$opengl" = "yes" ; then
4671da076ffeSGerd Hoffmann  echo "CONFIG_OPENGL=y" >> $config_host_mak
4672de2d3005SPaolo Bonzini  echo "OPENGL_CFLAGS=$opengl_cflags" >> $config_host_mak
4673da076ffeSGerd Hoffmann  echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
467420ff075bSMichael Wallefi
467520ff075bSMichael Walle
4676d52c454aSMarc-André Lureauif test "$gbm" = "yes" ; then
4677d52c454aSMarc-André Lureau    echo "CONFIG_GBM=y" >> $config_host_mak
4678d52c454aSMarc-André Lureau    echo "GBM_LIBS=$gbm_libs" >> $config_host_mak
4679d52c454aSMarc-André Lureau    echo "GBM_CFLAGS=$gbm_cflags" >> $config_host_mak
4680d52c454aSMarc-André Lureaufi
4681d52c454aSMarc-André Lureau
4682d52c454aSMarc-André Lureau
468399f2dbd3SLiang Liif test "$avx2_opt" = "yes" ; then
468499f2dbd3SLiang Li  echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
468599f2dbd3SLiang Lifi
468699f2dbd3SLiang Li
46876b8cd447SRobert Hooif test "$avx512f_opt" = "yes" ; then
46886b8cd447SRobert Hoo  echo "CONFIG_AVX512F_OPT=y" >> $config_host_mak
46896b8cd447SRobert Hoofi
46906b8cd447SRobert Hoo
469183fb7adfSbellard# XXX: suppress that
46927d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
46932358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
46947d3505c5Sbellardfi
46957d3505c5Sbellard
46963556c233SPaolo Bonziniif test "$qom_cast_debug" = "yes" ; then
46973556c233SPaolo Bonzini  echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
46983556c233SPaolo Bonzinifi
469920ff6c80SAnthony Liguori
47007c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
470170c60c08SStefan Hajnocziif test "$coroutine_pool" = "yes" ; then
470270c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
470370c60c08SStefan Hajnoczielse
470470c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
470570c60c08SStefan Hajnoczifi
4706d0e2fce5SAneesh Kumar K.V
47077d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes" ; then
47087d992e4dSPeter Lieven  echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
47097d992e4dSPeter Lievenfi
47107d992e4dSPeter Lieven
4711f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes" ; then
4712f0d92b56SLongpeng(Mike)  echo "CONFIG_AF_ALG=y" >> $config_host_mak
4713f0d92b56SLongpeng(Mike)fi
4714f0d92b56SLongpeng(Mike)
4715d83414e1SMarc-André Lureauif test "$have_asan_iface_fiber" = "yes" ; then
4716d83414e1SMarc-André Lureau    echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
4717d83414e1SMarc-André Lureaufi
4718d83414e1SMarc-André Lureau
47190aebab04SLingfeng Yangif test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then
47200aebab04SLingfeng Yang    echo "CONFIG_TSAN=y" >> $config_host_mak
47210aebab04SLingfeng Yangfi
47220aebab04SLingfeng Yang
472376a347e1SRichard Hendersonif test "$cpuid_h" = "yes" ; then
472476a347e1SRichard Henderson  echo "CONFIG_CPUID_H=y" >> $config_host_mak
472576a347e1SRichard Hendersonfi
472676a347e1SRichard Henderson
4727f540166bSRichard Hendersonif test "$int128" = "yes" ; then
4728f540166bSRichard Henderson  echo "CONFIG_INT128=y" >> $config_host_mak
4729f540166bSRichard Hendersonfi
4730f540166bSRichard Henderson
47317ebee43eSRichard Hendersonif test "$atomic128" = "yes" ; then
47327ebee43eSRichard Henderson  echo "CONFIG_ATOMIC128=y" >> $config_host_mak
47337ebee43eSRichard Hendersonfi
47347ebee43eSRichard Henderson
4735e6cd4bb5SRichard Hendersonif test "$cmpxchg128" = "yes" ; then
4736e6cd4bb5SRichard Henderson  echo "CONFIG_CMPXCHG128=y" >> $config_host_mak
4737e6cd4bb5SRichard Hendersonfi
4738e6cd4bb5SRichard Henderson
4739df79b996SRichard Hendersonif test "$atomic64" = "yes" ; then
4740df79b996SRichard Henderson  echo "CONFIG_ATOMIC64=y" >> $config_host_mak
4741df79b996SRichard Hendersonfi
4742df79b996SRichard Henderson
47431e6e9acaSRichard Hendersonif test "$getauxval" = "yes" ; then
47441e6e9acaSRichard Henderson  echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
47451e6e9acaSRichard Hendersonfi
47461e6e9acaSRichard Henderson
4747b10d49d7SPino Toscanoif test "$libssh" = "yes" ; then
4748484e2cc7SPaolo Bonzini  echo "CONFIG_LIBSSH=y" >> $config_host_mak
4749b10d49d7SPino Toscano  echo "LIBSSH_CFLAGS=$libssh_cflags" >> $config_host_mak
4750b10d49d7SPino Toscano  echo "LIBSSH_LIBS=$libssh_libs" >> $config_host_mak
47510a12ec87SRichard W.M. Jonesfi
47520a12ec87SRichard W.M. Jones
4753ed1701c6SDr. David Alan Gilbertif test "$live_block_migration" = "yes" ; then
4754ed1701c6SDr. David Alan Gilbert  echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
4755ed1701c6SDr. David Alan Gilbertfi
4756ed1701c6SDr. David Alan Gilbert
47573b8acc11SPaolo Bonziniif test "$tpm" = "yes"; then
47583cae16dbSPaolo Bonzini  echo 'CONFIG_TPM=y' >> $config_host_mak
47593b8acc11SPaolo Bonzinifi
47603b8acc11SPaolo Bonzini
47615b808275SLluís Vilanovaecho "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
47625b808275SLluís Vilanovaif have_backend "nop"; then
47636d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
476422890ab5SPrerna Saxenafi
47655b808275SLluís Vilanovaif have_backend "simple"; then
47666d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
47676d8a764eSLluís  # Set the appropriate trace file.
4768953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
47699410b56cSPrerna Saxenafi
4770ed7f5f1dSPaolo Bonziniif have_backend "log"; then
4771ed7f5f1dSPaolo Bonzini  echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
47726d8a764eSLluísfi
47735b808275SLluís Vilanovaif have_backend "ust"; then
47746d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
4775a81df1b6SPaolo Bonzini  echo "LTTNG_UST_LIBS=$lttng_ust_libs" >> $config_host_mak
4776a81df1b6SPaolo Bonzini  echo "URCU_BP_LIBS=$urcu_bp_libs" >> $config_host_mak
47776d8a764eSLluísfi
47785b808275SLluís Vilanovaif have_backend "dtrace"; then
47796d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
47806d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
47816d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
47826d8a764eSLluís  fi
4783c276b17dSDaniel P. Berrangefi
47845b808275SLluís Vilanovaif have_backend "ftrace"; then
4785781e9545SEiichi Tsukata  if test "$linux" = "yes" ; then
4786781e9545SEiichi Tsukata    echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
4787781e9545SEiichi Tsukata  else
478821684af0SStewart Smith    feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
4789781e9545SEiichi Tsukata  fi
4790781e9545SEiichi Tsukatafi
47910a852417SPaul Durrantif have_backend "syslog"; then
47920a852417SPaul Durrant  if test "$posix_syslog" = "yes" ; then
47930a852417SPaul Durrant    echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
47940a852417SPaul Durrant  else
47950a852417SPaul Durrant    feature_not_found "syslog(trace backend)" "syslog not available"
47960a852417SPaul Durrant  fi
47970a852417SPaul Durrantfi
47989410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
47999410b56cSPrerna Saxena
48002da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then
48012da776dbSMichael R. Hines  echo "CONFIG_RDMA=y" >> $config_host_mak
4802392fb643SFam Zheng  echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
48032da776dbSMichael R. Hinesfi
48042da776dbSMichael R. Hines
480521ab34c9SMarcel Apfelbaumif test "$pvrdma" = "yes" ; then
480621ab34c9SMarcel Apfelbaum  echo "CONFIG_PVRDMA=y" >> $config_host_mak
480721ab34c9SMarcel Apfelbaumfi
480821ab34c9SMarcel Apfelbaum
4809a6b1d4c0SChanglong Xieif test "$replication" = "yes" ; then
4810a6b1d4c0SChanglong Xie  echo "CONFIG_REPLICATION=y" >> $config_host_mak
4811a6b1d4c0SChanglong Xiefi
4812a6b1d4c0SChanglong Xie
48136a02c806SStefan Hajnocziif test "$have_af_vsock" = "yes" ; then
48146a02c806SStefan Hajnoczi  echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
48156a02c806SStefan Hajnoczifi
48166a02c806SStefan Hajnoczi
4817ba59fb77SPaolo Bonziniif test "$debug_mutex" = "yes" ; then
4818ba59fb77SPaolo Bonzini  echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak
4819ba59fb77SPaolo Bonzinifi
4820e0580342SKamil Rytarowski
48215c312079SDr. David Alan Gilbert# Hold two types of flag:
48225c312079SDr. David Alan Gilbert#   CONFIG_THREAD_SETNAME_BYTHREAD  - we've got a way of setting the name on
48235c312079SDr. David Alan Gilbert#                                     a thread we have a handle to
4824479a5747SRoman Bolshakov#   CONFIG_PTHREAD_SETNAME_NP_W_TID - A way of doing it on a particular
48255c312079SDr. David Alan Gilbert#                                     platform
4826479a5747SRoman Bolshakovif test "$pthread_setname_np_w_tid" = "yes" ; then
48275c312079SDr. David Alan Gilbert  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
4828479a5747SRoman Bolshakov  echo "CONFIG_PTHREAD_SETNAME_NP_W_TID=y" >> $config_host_mak
4829479a5747SRoman Bolshakovelif test "$pthread_setname_np_wo_tid" = "yes" ; then
4830479a5747SRoman Bolshakov  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
4831479a5747SRoman Bolshakov  echo "CONFIG_PTHREAD_SETNAME_NP_WO_TID=y" >> $config_host_mak
48325c312079SDr. David Alan Gilbertfi
48335c312079SDr. David Alan Gilbert
48342f740136SJeff Codyif test "$bochs" = "yes" ; then
48352f740136SJeff Cody  echo "CONFIG_BOCHS=y" >> $config_host_mak
48362f740136SJeff Codyfi
48372f740136SJeff Codyif test "$cloop" = "yes" ; then
48382f740136SJeff Cody  echo "CONFIG_CLOOP=y" >> $config_host_mak
48392f740136SJeff Codyfi
48402f740136SJeff Codyif test "$dmg" = "yes" ; then
48412f740136SJeff Cody  echo "CONFIG_DMG=y" >> $config_host_mak
48422f740136SJeff Codyfi
48432f740136SJeff Codyif test "$qcow1" = "yes" ; then
48442f740136SJeff Cody  echo "CONFIG_QCOW1=y" >> $config_host_mak
48452f740136SJeff Codyfi
48462f740136SJeff Codyif test "$vdi" = "yes" ; then
48472f740136SJeff Cody  echo "CONFIG_VDI=y" >> $config_host_mak
48482f740136SJeff Codyfi
48492f740136SJeff Codyif test "$vvfat" = "yes" ; then
48502f740136SJeff Cody  echo "CONFIG_VVFAT=y" >> $config_host_mak
48512f740136SJeff Codyfi
48522f740136SJeff Codyif test "$qed" = "yes" ; then
48532f740136SJeff Cody  echo "CONFIG_QED=y" >> $config_host_mak
48542f740136SJeff Codyfi
48552f740136SJeff Codyif test "$parallels" = "yes" ; then
48562f740136SJeff Cody  echo "CONFIG_PARALLELS=y" >> $config_host_mak
48572f740136SJeff Codyfi
4858195588ccSDavid CARLIERif test "$have_mlockall" = "yes" ; then
4859195588ccSDavid CARLIER  echo "HAVE_MLOCKALL=y" >> $config_host_mak
4860195588ccSDavid CARLIERfi
4861adc28027SAlexander Bulekovif test "$fuzzing" = "yes" ; then
486254c9e41dSAlexander Bulekov  # If LIB_FUZZING_ENGINE is set, assume we are running on OSS-Fuzz, and the
486354c9e41dSAlexander Bulekov  # needed CFLAGS have already been provided
486454c9e41dSAlexander Bulekov  if test -z "${LIB_FUZZING_ENGINE+xxx}" ; then
4865efce01bcSAlexander Bulekov    # Add CFLAGS to tell clang to add fuzzer-related instrumentation to all the
4866efce01bcSAlexander Bulekov    # compiled code.
4867086d5f75SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS -fsanitize=fuzzer-no-link"
4868efce01bcSAlexander Bulekov    # To build non-fuzzer binaries with --enable-fuzzing, link everything with
4869efce01bcSAlexander Bulekov    # fsanitize=fuzzer-no-link. Otherwise, the linker will be unable to bind
4870efce01bcSAlexander Bulekov    # the fuzzer-related callbacks added by instrumentation.
4871efce01bcSAlexander Bulekov    QEMU_LDFLAGS="$QEMU_LDFLAGS -fsanitize=fuzzer-no-link"
4872efce01bcSAlexander Bulekov    # For the actual fuzzer binaries, we need to link against the libfuzzer
4873efce01bcSAlexander Bulekov    # library. Provide the flags for doing this in FUZZ_EXE_LDFLAGS. The meson
4874efce01bcSAlexander Bulekov    # rule for the fuzzer adds these to the link_args. They need to be
4875efce01bcSAlexander Bulekov    # configurable, to support OSS-Fuzz
487654c9e41dSAlexander Bulekov    FUZZ_EXE_LDFLAGS="-fsanitize=fuzzer"
487754c9e41dSAlexander Bulekov  else
487854c9e41dSAlexander Bulekov    FUZZ_EXE_LDFLAGS="$LIB_FUZZING_ENGINE"
487954c9e41dSAlexander Bulekov  fi
4880adc28027SAlexander Bulekovfi
48812f740136SJeff Cody
488240e8c6f4SAlex Bennéeif test "$plugins" = "yes" ; then
488340e8c6f4SAlex Bennée    echo "CONFIG_PLUGIN=y" >> $config_host_mak
488426fffe29SEmilio G. Cota    # Copy the export object list to the build dir
488526fffe29SEmilio G. Cota    if test "$ld_dynamic_list" = "yes" ; then
488626fffe29SEmilio G. Cota	echo "CONFIG_HAS_LD_DYNAMIC_LIST=yes" >> $config_host_mak
488726fffe29SEmilio G. Cota	ld_symbols=qemu-plugins-ld.symbols
488826fffe29SEmilio G. Cota	cp "$source_path/plugins/qemu-plugins.symbols" $ld_symbols
488926fffe29SEmilio G. Cota    elif test "$ld_exported_symbols_list" = "yes" ; then
489026fffe29SEmilio G. Cota	echo "CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST=yes" >> $config_host_mak
489126fffe29SEmilio G. Cota	ld64_symbols=qemu-plugins-ld64.symbols
489226fffe29SEmilio G. Cota	echo "# Automatically generated by configure - do not modify" > $ld64_symbols
489326fffe29SEmilio G. Cota	grep 'qemu_' "$source_path/plugins/qemu-plugins.symbols" | sed 's/;//g' | \
489426fffe29SEmilio G. Cota	    sed -E 's/^[[:space:]]*(.*)/_\1/' >> $ld64_symbols
489526fffe29SEmilio G. Cota    else
489626fffe29SEmilio G. Cota	error_exit \
489726fffe29SEmilio G. Cota	    "If \$plugins=yes, either \$ld_dynamic_list or " \
489826fffe29SEmilio G. Cota	    "\$ld_exported_symbols_list should have been set to 'yes'."
489926fffe29SEmilio G. Cota    fi
490040e8c6f4SAlex Bennéefi
490140e8c6f4SAlex Bennée
4902f48e590aSAlex Bennéeif test -n "$gdb_bin"; then
4903b1863cccSAlex Bennée    gdb_version=$($gdb_bin --version | head -n 1)
4904d6a66c81SAlex Bennée    if version_ge ${gdb_version##* } 9.1; then
4905f48e590aSAlex Bennée        echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
4906f48e590aSAlex Bennée    fi
4907b1863cccSAlex Bennéefi
4908f48e590aSAlex Bennée
490954e7aac0SAlexey Krasikovif test "$secret_keyring" = "yes" ; then
491054e7aac0SAlexey Krasikov  echo "CONFIG_SECRET_KEYRING=y" >> $config_host_mak
491154e7aac0SAlexey Krasikovfi
491254e7aac0SAlexey Krasikov
491398ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
4914804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
4915c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
491639d87c8cSAlex Bennéeecho "GENISOIMAGE=$genisoimage" >> $config_host_mak
4917a5665051SPaolo Bonziniecho "MESON=$meson" >> $config_host_mak
491809e93326SPaolo Bonziniecho "NINJA=$ninja" >> $config_host_mak
4919804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
4920433de74cSBastian Koppelmannecho "HOST_CC=$host_cc" >> $config_host_mak
4921a31a8642SMichael S. Tsirkinif $iasl -h > /dev/null 2>&1; then
4922859aef02SPaolo Bonzini  echo "CONFIG_IASL=$iasl" >> $config_host_mak
4923a31a8642SMichael S. Tsirkinfi
4924804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
4925cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak
49265f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak
49273dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak
4928804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
4929804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
493046eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
4931a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
493211cde1c8SBruno Dominguezecho "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
4933a81df1b6SPaolo Bonziniecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
4934a81df1b6SPaolo Bonziniecho "GLIB_LIBS=$glib_libs" >> $config_host_mak
49358a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
4936e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
4937804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
4938484e2cc7SPaolo Bonziniecho "HOST_DSOSUF=$HOST_DSOSUF" >> $config_host_mak
4939f15bff25SPaolo Bonziniecho "LIBS_QGA=$libs_qga" >> $config_host_mak
49401d728c39SBlue Swirlif test "$gcov" = "yes" ; then
49411d728c39SBlue Swirl  echo "CONFIG_GCOV=y" >> $config_host_mak
49421d728c39SBlue Swirlfi
4943804edf29SJuan Quintela
4944adc28027SAlexander Bulekovif test "$fuzzing" != "no"; then
4945adc28027SAlexander Bulekov    echo "CONFIG_FUZZ=y" >> $config_host_mak
4946adc28027SAlexander Bulekovfi
494754c9e41dSAlexander Bulekovecho "FUZZ_EXE_LDFLAGS=$FUZZ_EXE_LDFLAGS" >> $config_host_mak
49483efac6ebSTomáš Golembiovský
4949b767d257SMarek Marczykowski-Góreckiif test "$rng_none" = "yes"; then
4950b767d257SMarek Marczykowski-Górecki  echo "CONFIG_RNG_NONE=y" >> $config_host_mak
4951b767d257SMarek Marczykowski-Góreckifi
4952b767d257SMarek Marczykowski-Górecki
49536efd7517SPeter Maydell# use included Linux headers
49546efd7517SPeter Maydellif test "$linux" = "yes" ; then
4955a307beb6SAndreas Färber  mkdir -p linux-headers
49566efd7517SPeter Maydell  case "$cpu" in
4957c72b26ecSRichard Henderson  i386|x86_64|x32)
495808312a63SPeter Maydell    linux_arch=x86
49596efd7517SPeter Maydell    ;;
4960f8378accSRichard Henderson  ppc|ppc64|ppc64le)
496108312a63SPeter Maydell    linux_arch=powerpc
49626efd7517SPeter Maydell    ;;
49636efd7517SPeter Maydell  s390x)
496408312a63SPeter Maydell    linux_arch=s390
496508312a63SPeter Maydell    ;;
49661f080313SClaudio Fontana  aarch64)
49671f080313SClaudio Fontana    linux_arch=arm64
49681f080313SClaudio Fontana    ;;
4969222e7d11SSanjay Lal  mips64)
4970222e7d11SSanjay Lal    linux_arch=mips
4971222e7d11SSanjay Lal    ;;
497208312a63SPeter Maydell  *)
497308312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
497408312a63SPeter Maydell    linux_arch="$cpu"
49756efd7517SPeter Maydell    ;;
49766efd7517SPeter Maydell  esac
497708312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
497808312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
497908312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
498008312a63SPeter Maydell    fi
49816efd7517SPeter Maydellfi
49826efd7517SPeter Maydell
498397a847bcSbellardfor target in $target_list; do
498497a847bcSbellard    target_dir="$target"
498589138857SStefan Weil    target_name=$(echo $target | cut -d '-' -f 1)
498697a847bcSbellard    mkdir -p $target_dir
4987fdb75aefSPaolo Bonzini    case $target in
4988fdb75aefSPaolo Bonzini        *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;;
4989fdb75aefSPaolo Bonzini        *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;;
49902408a527Saurel32    esac
499156aebc89Spbrookdone
49927d13299dSbellard
4993765686d6SPaolo Bonziniecho "CONFIG_QEMU_INTERP_PREFIX=$interp_prefix" | sed 's/%M/@0@/' >> $config_host_mak
4994fdb75aefSPaolo Bonziniif test "$default_targets" = "yes"; then
4995fdb75aefSPaolo Bonzini  echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak
4996fdb75aefSPaolo Bonzinifi
4997a540f158SPeter Crosthwaite
4998a99d57bbSWanlong Gaoif test "$numa" = "yes"; then
4999a99d57bbSWanlong Gao  echo "CONFIG_NUMA=y" >> $config_host_mak
5000ab318051SMarc-André Lureau  echo "NUMA_LIBS=$numa_libs" >> $config_host_mak
5001a99d57bbSWanlong Gaofi
5002a99d57bbSWanlong Gao
5003fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then
5004fd0e6053SJohn Snow  echo "export CCACHE_CPP2=y" >> $config_host_mak
5005fd0e6053SJohn Snowfi
5006fd0e6053SJohn Snow
50071e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then
50081e4f6065SDaniele Buono  echo "CONFIG_SAFESTACK=y" >> $config_host_mak
50091e4f6065SDaniele Buonofi
50101e4f6065SDaniele Buono
5011e29e5c6eSPeter Maydell# If we're using a separate build tree, set it up now.
5012e29e5c6eSPeter Maydell# DIRS are directories which we simply mkdir in the build tree;
5013e29e5c6eSPeter Maydell# LINKS are things to symlink back into the source tree
5014e29e5c6eSPeter Maydell# (these can be both files and directories).
5015e29e5c6eSPeter Maydell# Caution: do not add files or directories here using wildcards. This
5016e29e5c6eSPeter Maydell# will result in problems later if a new file matching the wildcard is
5017e29e5c6eSPeter Maydell# added to the source tree -- nothing will cause configure to be rerun
5018e29e5c6eSPeter Maydell# so the build tree will be missing the link back to the new file, and
5019e29e5c6eSPeter Maydell# tests might fail. Prefer to keep the relevant files in their own
5020e29e5c6eSPeter Maydell# directory and symlink the directory instead.
502109db9b9dSGerd Hoffmann# UNLINK is used to remove symlinks from older development versions
502209db9b9dSGerd Hoffmann# that might get into the way when doing "git update" without doing
502309db9b9dSGerd Hoffmann# a "make distclean" in between.
50249d49bcf6SMarkus ArmbrusterDIRS="tests tests/tcg tests/qapi-schema tests/qtest/libqos"
50251cf4323eSThomas HuthDIRS="$DIRS tests/qtest tests/qemu-iotests tests/vm tests/fp tests/qgraph"
5026b855f8d1SPaolo BonziniDIRS="$DIRS docs docs/interop fsdev scsi"
5027744a928cSAlexey KardashevskiyDIRS="$DIRS pc-bios/optionrom pc-bios/s390-ccw"
50288db2a4fdSGerd HoffmannDIRS="$DIRS roms/seabios"
5029c17a386bSAlex BennéeDIRS="$DIRS contrib/plugins/"
50302038f8c8SPaolo BonziniLINKS="Makefile"
50313941996bSPaolo BonziniLINKS="$LINKS tests/tcg/Makefile.target"
5032ddcf607fSGerd HoffmannLINKS="$LINKS pc-bios/optionrom/Makefile"
5033e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/s390-ccw/Makefile"
50348db2a4fdSGerd HoffmannLINKS="$LINKS roms/seabios/Makefile"
5035e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/qemu-icon.bmp"
5036e29e5c6eSPeter MaydellLINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
503739950353SPeter MaydellLINKS="$LINKS tests/acceptance tests/data"
503839950353SPeter MaydellLINKS="$LINKS tests/qemu-iotests/check"
50398f8fd9edSCleber RosaLINKS="$LINKS python"
5040c17a386bSAlex BennéeLINKS="$LINKS contrib/plugins/Makefile "
504109db9b9dSGerd HoffmannUNLINK="pc-bios/keymaps"
5042753d11f2SRichard Hendersonfor bios_file in \
5043753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
50443a631b8eSBin Meng    $source_path/pc-bios/*.elf \
5045225a9ab8SAlexey Kardashevskiy    $source_path/pc-bios/*.lid \
5046753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
5047753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
5048e89e33e1SDominik Dingel    $source_path/pc-bios/*.img \
5049753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
50504e73c781SAlexander Graf    $source_path/pc-bios/u-boot.* \
505126ce90fdSLaszlo Ersek    $source_path/pc-bios/edk2-*.fd.bz2 \
5052753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
5053753d11f2SRichard Hendersondo
5054e29e5c6eSPeter Maydell    LINKS="$LINKS pc-bios/$(basename $bios_file)"
50557ea78b74SJan Kiszkadone
5056d1807a4fSPaolo Bonzinimkdir -p $DIRS
5057e29e5c6eSPeter Maydellfor f in $LINKS ; do
50580f4d8894SPaolo Bonzini    if [ -e "$source_path/$f" ]; then
5059f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
5060f9245e10SPeter Maydell    fi
50617d13299dSbellarddone
506209db9b9dSGerd Hoffmannfor f in $UNLINK ; do
506309db9b9dSGerd Hoffmann    if [ -L "$f" ]; then
506409db9b9dSGerd Hoffmann        rm -f "$f"
506509db9b9dSGerd Hoffmann    fi
506609db9b9dSGerd Hoffmanndone
50671ad2134fSPaul Brook
50682038f8c8SPaolo Bonzini(for i in $cross_cc_vars; do
50692038f8c8SPaolo Bonzini  export $i
50702038f8c8SPaolo Bonzinidone
5071de6d7e6bSAlex Bennéeexport target_list source_path use_containers ARCH
50722038f8c8SPaolo Bonzini$source_path/tests/tcg/configure.sh)
50732038f8c8SPaolo Bonzini
5074c34ebfdcSAnthony Liguori# temporary config to build submodules
50758db2a4fdSGerd Hoffmannfor rom in seabios; do
5076c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
507737116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
5078c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
5079cdbd727cSRichard Henderson    echo "AS=$as" >> $config_mak
50805f6f0e27SRichard Henderson    echo "CCAS=$ccas" >> $config_mak
5081c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
5082c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
50833dd46c78SBlue Swirl    echo "CPP=$cpp" >> $config_mak
5084c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
5085a31a8642SMichael S. Tsirkin    echo "IASL=$iasl" >> $config_mak
5086c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
50879f81aeb5SAlistair Francis    echo "RANLIB=$ranlib" >> $config_mak
5088c34ebfdcSAnthony Liguoridone
5089c34ebfdcSAnthony Liguori
5090a5665051SPaolo Bonziniif test "$skip_meson" = no; then
5091fc929892SMarc-André Lureau  cross="config-meson.cross.new"
5092fc929892SMarc-André Lureau  meson_quote() {
509347b30835SPaolo Bonzini    echo "'$(echo $* | sed "s/ /','/g")'"
5094fc929892SMarc-André Lureau  }
5095fc929892SMarc-André Lureau
5096fc929892SMarc-André Lureau  echo "# Automatically generated by configure - do not modify" > $cross
5097fc929892SMarc-André Lureau  echo "[properties]" >> $cross
5098*d1d5e9eeSAlex Bennée
5099*d1d5e9eeSAlex Bennée  # unroll any custom device configs
5100*d1d5e9eeSAlex Bennée  if test -n "$device_archs"; then
5101*d1d5e9eeSAlex Bennée      for a in $device_archs; do
5102*d1d5e9eeSAlex Bennée          eval "c=\$devices_${a}"
5103*d1d5e9eeSAlex Bennée          echo "${a}-softmmu = '$c'" >> $cross
5104*d1d5e9eeSAlex Bennée      done
5105*d1d5e9eeSAlex Bennée  fi
5106*d1d5e9eeSAlex Bennée
5107fc929892SMarc-André Lureau  test -z "$cxx" && echo "link_language = 'c'" >> $cross
510847b30835SPaolo Bonzini  echo "[built-in options]" >> $cross
510947b30835SPaolo Bonzini  echo "c_args = [${CFLAGS:+$(meson_quote $CFLAGS)}]" >> $cross
511047b30835SPaolo Bonzini  echo "cpp_args = [${CXXFLAGS:+$(meson_quote $CXXFLAGS)}]" >> $cross
511147b30835SPaolo Bonzini  echo "c_link_args = [${LDFLAGS:+$(meson_quote $LDFLAGS)}]" >> $cross
511247b30835SPaolo Bonzini  echo "cpp_link_args = [${LDFLAGS:+$(meson_quote $LDFLAGS)}]" >> $cross
5113fc929892SMarc-André Lureau  echo "[binaries]" >> $cross
511447b30835SPaolo Bonzini  echo "c = [$(meson_quote $cc)]" >> $cross
511547b30835SPaolo Bonzini  test -n "$cxx" && echo "cpp = [$(meson_quote $cxx)]" >> $cross
51160ca321eaSJoelle van Dyne  test -n "$objcc" && echo "objc = [$(meson_quote $objcc)]" >> $cross
511747b30835SPaolo Bonzini  echo "ar = [$(meson_quote $ar)]" >> $cross
511847b30835SPaolo Bonzini  echo "nm = [$(meson_quote $nm)]" >> $cross
511947b30835SPaolo Bonzini  echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross
512047b30835SPaolo Bonzini  echo "ranlib = [$(meson_quote $ranlib)]" >> $cross
5121e8178514SPaolo Bonzini  if has $sdl2_config; then
512247b30835SPaolo Bonzini    echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross
5123e8178514SPaolo Bonzini  fi
512447b30835SPaolo Bonzini  echo "strip = [$(meson_quote $strip)]" >> $cross
512547b30835SPaolo Bonzini  echo "windres = [$(meson_quote $windres)]" >> $cross
51263812c0c4SJoelle van Dyne  if test "$cross_compile" = "yes"; then
5127fc929892SMarc-André Lureau    cross_arg="--cross-file config-meson.cross"
5128fc929892SMarc-André Lureau    echo "[host_machine]" >> $cross
5129fc929892SMarc-André Lureau    if test "$mingw32" = "yes" ; then
5130fc929892SMarc-André Lureau        echo "system = 'windows'" >> $cross
5131fc929892SMarc-André Lureau    fi
5132853b4bafSThomas Huth    if test "$linux" = "yes" ; then
5133853b4bafSThomas Huth        echo "system = 'linux'" >> $cross
5134853b4bafSThomas Huth    fi
51350ca321eaSJoelle van Dyne    if test "$darwin" = "yes" ; then
51360ca321eaSJoelle van Dyne        echo "system = 'darwin'" >> $cross
51370ca321eaSJoelle van Dyne    fi
5138fc929892SMarc-André Lureau    case "$ARCH" in
5139f6bca9dfSJoelle van Dyne        i386)
5140fc929892SMarc-André Lureau            echo "cpu_family = 'x86'" >> $cross
5141fc929892SMarc-André Lureau            ;;
5142f8bb7e1cSDavid Michael        x86_64|x32)
5143f6bca9dfSJoelle van Dyne            echo "cpu_family = 'x86_64'" >> $cross
5144f6bca9dfSJoelle van Dyne            ;;
5145fc929892SMarc-André Lureau        ppc64le)
5146fc929892SMarc-André Lureau            echo "cpu_family = 'ppc64'" >> $cross
5147fc929892SMarc-André Lureau            ;;
5148fc929892SMarc-André Lureau        *)
5149fc929892SMarc-André Lureau            echo "cpu_family = '$ARCH'" >> $cross
5150fc929892SMarc-André Lureau            ;;
5151fc929892SMarc-André Lureau    esac
5152fc929892SMarc-André Lureau    echo "cpu = '$cpu'" >> $cross
5153fc929892SMarc-André Lureau    if test "$bigendian" = "yes" ; then
5154fc929892SMarc-André Lureau        echo "endian = 'big'" >> $cross
5155fc929892SMarc-André Lureau    else
5156fc929892SMarc-André Lureau        echo "endian = 'little'" >> $cross
5157fc929892SMarc-André Lureau    fi
5158fc929892SMarc-André Lureau  else
5159fc929892SMarc-André Lureau    cross_arg="--native-file config-meson.cross"
5160fc929892SMarc-André Lureau  fi
5161fc929892SMarc-André Lureau  mv $cross config-meson.cross
5162fc929892SMarc-André Lureau
5163a5665051SPaolo Bonzini  rm -rf meson-private meson-info meson-logs
5164a5cb7c5aSPaolo Bonzini  unset staticpic
5165a5cb7c5aSPaolo Bonzini  if ! version_ge "$($meson --version)" 0.56.0; then
5166a5cb7c5aSPaolo Bonzini    staticpic=$(if test "$pie" = yes; then echo true; else echo false; fi)
5167a5cb7c5aSPaolo Bonzini  fi
516809e93326SPaolo Bonzini  NINJA=$ninja $meson setup \
5169d17f305aSPaolo Bonzini        --prefix "$prefix" \
5170d17f305aSPaolo Bonzini        --libdir "$libdir" \
5171d17f305aSPaolo Bonzini        --libexecdir "$libexecdir" \
5172d17f305aSPaolo Bonzini        --bindir "$bindir" \
5173d17f305aSPaolo Bonzini        --includedir "$includedir" \
5174d17f305aSPaolo Bonzini        --datadir "$datadir" \
5175d17f305aSPaolo Bonzini        --mandir "$mandir" \
5176d17f305aSPaolo Bonzini        --sysconfdir "$sysconfdir" \
517716bf7a33SPaolo Bonzini        --localedir "$localedir" \
5178d17f305aSPaolo Bonzini        --localstatedir "$local_statedir" \
5179d17f305aSPaolo Bonzini        -Ddocdir="$docdir" \
518016bf7a33SPaolo Bonzini        -Dqemu_firmwarepath="$firmwarepath" \
518173f3aa37SMarc-André Lureau        -Dqemu_suffix="$qemu_suffix" \
5182a5665051SPaolo Bonzini        -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) \
5183a5665051SPaolo Bonzini        -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo false; fi) \
5184a5665051SPaolo Bonzini        -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \
5185a5665051SPaolo Bonzini        -Dstrip=$(if test "$strip_opt" = yes; then echo true; else echo false; fi) \
5186da6d48b9SMarc-André Lureau        -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \
5187a5cb7c5aSPaolo Bonzini        ${staticpic:+-Db_staticpic=$staticpic} \
5188bf0e56a3SMarc-André Lureau        -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \
51899e62ba48SDaniele Buono        -Db_lto=$lto -Dcfi=$cfi -Dcfi_debug=$cfi_debug \
5190deb62371SPaolo Bonzini        -Dmalloc=$malloc -Dmalloc_trim=$malloc_trim -Dsparse=$sparse \
519174a414a1SReinoud Zandijk        -Dkvm=$kvm -Dhax=$hax -Dwhpx=$whpx -Dhvf=$hvf -Dnvmm=$nvmm \
51921badb709SPaolo Bonzini        -Dxen=$xen -Dxen_pci_passthrough=$xen_pci_passthrough -Dtcg=$tcg \
51931b695471SPaolo Bonzini        -Dcocoa=$cocoa -Dgtk=$gtk -Dmpath=$mpath -Dsdl=$sdl -Dsdl_image=$sdl_image \
5194c23d7b4eSPaolo Bonzini        -Dlibusb=$libusb -Dsmartcard=$smartcard -Dusb_redir=$usb_redir -Dvte=$vte \
5195a0b93237SPaolo Bonzini        -Dvnc=$vnc -Dvnc_sasl=$vnc_sasl -Dvnc_jpeg=$vnc_jpeg -Dvnc_png=$vnc_png \
5196cece116cSMisono Tomohiro        -Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f -Dvirtiofsd=$virtiofsd \
51978c6d4ff4SPaolo Bonzini        -Dcapstone=$capstone -Dslirp=$slirp -Dfdt=$fdt -Dbrlapi=$brlapi \
51989db405a3SPaolo Bonzini        -Dcurl=$curl -Dglusterfs=$glusterfs -Dbzip2=$bzip2 -Dlibiscsi=$libiscsi \
519930045c05SPaolo Bonzini        -Dlibnfs=$libnfs -Diconv=$iconv -Dcurses=$curses -Dlibudev=$libudev\
5200c5b36c25SPaolo Bonzini        -Drbd=$rbd -Dlzo=$lzo -Dsnappy=$snappy -Dlzfse=$lzfse -Dlibxml2=$libxml2 \
520153c22b68SPaolo Bonzini        -Dlibdaxctl=$libdaxctl -Dlibpmem=$libpmem -Dlinux_io_uring=$linux_io_uring \
520205e391aeSPaolo Bonzini        -Dgnutls=$gnutls -Dnettle=$nettle -Dgcrypt=$gcrypt -Dauth_pam=$auth_pam \
5203727c8bb8SPaolo Bonzini        -Dzstd=$zstd -Dseccomp=$seccomp -Dvirtfs=$virtfs -Dcap_ng=$cap_ng \
5204587d59d6SPaolo Bonzini        -Dattr=$attr -Ddefault_devices=$default_devices -Dvirglrenderer=$virglrenderer \
5205c8d5450bSPaolo Bonzini        -Ddocs=$docs -Dsphinx_build=$sphinx_build -Dinstall_blobs=$blobs \
5206106ad1f9SPaolo Bonzini        -Dvhost_user_blk_server=$vhost_user_blk_server -Dmultiprocess=$multiprocess \
520746627f41SAndrew Melnychenko        -Dfuse=$fuse -Dfuse_lseek=$fuse_lseek -Dguest_agent_msi=$guest_agent_msi -Dbpf=$bpf\
5208c87ea116SAlex Bennée        $(if test "$default_features" = no; then echo "-Dauto_features=disabled"; fi) \
5209c6fbea47SRichard Henderson	-Dtcg_interpreter=$tcg_interpreter \
5210fc929892SMarc-André Lureau        $cross_arg \
5211a5665051SPaolo Bonzini        "$PWD" "$source_path"
5212a5665051SPaolo Bonzini
5213a5665051SPaolo Bonzini  if test "$?" -ne 0 ; then
5214a5665051SPaolo Bonzini      error_exit "meson setup failed"
5215a5665051SPaolo Bonzini  fi
5216699d3884SPaolo Bonzinielse
5217699d3884SPaolo Bonzini  if test -f meson-private/cmd_line.txt; then
5218699d3884SPaolo Bonzini    # Adjust old command line options whose type was changed
5219699d3884SPaolo Bonzini    # Avoids having to use "setup --wipe" when Meson is upgraded
5220699d3884SPaolo Bonzini    perl -i -ne '
5221699d3884SPaolo Bonzini      s/^gettext = true$/gettext = auto/;
5222699d3884SPaolo Bonzini      s/^gettext = false$/gettext = disabled/;
5223699d3884SPaolo Bonzini      print;' meson-private/cmd_line.txt
5224699d3884SPaolo Bonzini  fi
5225a5665051SPaolo Bonzinifi
5226a5665051SPaolo Bonzini
52272d838d9bSAlex Bennéeif test -n "${deprecated_features}"; then
52282d838d9bSAlex Bennée    echo "Warning, deprecated features enabled."
52292d838d9bSAlex Bennée    echo "Please see docs/system/deprecated.rst"
52302d838d9bSAlex Bennée    echo "  features: ${deprecated_features}"
52312d838d9bSAlex Bennéefi
52322d838d9bSAlex Bennée
5233e0447a83SThomas Huth# Create list of config switches that should be poisoned in common code...
5234e0447a83SThomas Huth# but filter out CONFIG_TCG and CONFIG_USER_ONLY which are special.
523554b0306eSThomas Huthtarget_configs_h=$(ls *-config-devices.h *-config-target.h 2>/dev/null)
523654b0306eSThomas Huthif test -n "$target_configs_h" ; then
5237e0447a83SThomas Huth    sed -n -e '/CONFIG_TCG/d' -e '/CONFIG_USER_ONLY/d' \
5238e0447a83SThomas Huth        -e '/^#define / { s///; s/ .*//; s/^/#pragma GCC poison /p; }' \
523954b0306eSThomas Huth        $target_configs_h | sort -u > config-poison.h
524054b0306eSThomas Huthelse
524154b0306eSThomas Huth    :> config-poison.h
524254b0306eSThomas Huthfi
5243e0447a83SThomas Huth
5244dc655404SMichael S. Tsirkin# Save the configure command line for later reuse.
5245dc655404SMichael S. Tsirkincat <<EOD >config.status
5246dc655404SMichael S. Tsirkin#!/bin/sh
5247dc655404SMichael S. Tsirkin# Generated by configure.
5248dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration.
5249dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging
5250dc655404SMichael S. Tsirkin# configure, is in config.log if it exists.
5251dc655404SMichael S. TsirkinEOD
5252e811da7fSDaniel P. Berrangé
5253e811da7fSDaniel P. Berrangépreserve_env() {
5254e811da7fSDaniel P. Berrangé    envname=$1
5255e811da7fSDaniel P. Berrangé
5256e811da7fSDaniel P. Berrangé    eval envval=\$$envname
5257e811da7fSDaniel P. Berrangé
5258e811da7fSDaniel P. Berrangé    if test -n "$envval"
5259e811da7fSDaniel P. Berrangé    then
5260e811da7fSDaniel P. Berrangé	echo "$envname='$envval'" >> config.status
5261e811da7fSDaniel P. Berrangé	echo "export $envname" >> config.status
5262e811da7fSDaniel P. Berrangé    else
5263e811da7fSDaniel P. Berrangé	echo "unset $envname" >> config.status
5264e811da7fSDaniel P. Berrangé    fi
5265e811da7fSDaniel P. Berrangé}
5266e811da7fSDaniel P. Berrangé
5267e811da7fSDaniel P. Berrangé# Preserve various env variables that influence what
5268e811da7fSDaniel P. Berrangé# features/build target configure will detect
5269e811da7fSDaniel P. Berrangépreserve_env AR
5270e811da7fSDaniel P. Berrangépreserve_env AS
5271e811da7fSDaniel P. Berrangépreserve_env CC
5272e811da7fSDaniel P. Berrangépreserve_env CPP
5273e811da7fSDaniel P. Berrangépreserve_env CXX
5274e811da7fSDaniel P. Berrangépreserve_env INSTALL
5275e811da7fSDaniel P. Berrangépreserve_env LD
5276e811da7fSDaniel P. Berrangépreserve_env LD_LIBRARY_PATH
5277e811da7fSDaniel P. Berrangépreserve_env LIBTOOL
5278e811da7fSDaniel P. Berrangépreserve_env MAKE
5279e811da7fSDaniel P. Berrangépreserve_env NM
5280e811da7fSDaniel P. Berrangépreserve_env OBJCOPY
5281e811da7fSDaniel P. Berrangépreserve_env PATH
5282e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG
5283e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_LIBDIR
5284e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_PATH
5285e811da7fSDaniel P. Berrangépreserve_env PYTHON
5286e811da7fSDaniel P. Berrangépreserve_env SDL2_CONFIG
5287e811da7fSDaniel P. Berrangépreserve_env SMBD
5288e811da7fSDaniel P. Berrangépreserve_env STRIP
5289e811da7fSDaniel P. Berrangépreserve_env WINDRES
5290e811da7fSDaniel P. Berrangé
5291dc655404SMichael S. Tsirkinprintf "exec" >>config.status
5292a5665051SPaolo Bonzinifor i in "$0" "$@"; do
5293835af899SPaolo Bonzini  test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status
5294a5665051SPaolo Bonzinidone
5295cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status
5296dc655404SMichael S. Tsirkinchmod +x config.status
5297dc655404SMichael S. Tsirkin
52988cd05ab6SPeter Maydellrm -r "$TMPDIR1"
5299