xref: /openbmc/qemu/configure (revision ca50e5231cfc120e90d264890bff59330257c361)
17d13299dSbellard#!/bin/sh
27d13299dSbellard#
33ef693a0Sbellard# qemu configure script (c) 2003 Fabrice Bellard
47d13299dSbellard#
58cd05ab6SPeter Maydell
699519e67SCornelia Huck# Unset some variables known to interfere with behavior of common tools,
799519e67SCornelia Huck# just as autoconf does.
899519e67SCornelia HuckCLICOLOR_FORCE= GREP_OPTIONS=
999519e67SCornelia Huckunset CLICOLOR_FORCE GREP_OPTIONS
1099519e67SCornelia Huck
115e4dfd3dSJohn Snow# Don't allow CCACHE, if present, to use cached results of compile tests!
125e4dfd3dSJohn Snowexport CCACHE_RECACHE=yes
135e4dfd3dSJohn Snow
14dedad027SDaniel P. Berrangé# make source path absolute
15dedad027SDaniel P. Berrangésource_path=$(cd "$(dirname -- "$0")"; pwd)
16dedad027SDaniel P. Berrangé
17dedad027SDaniel P. Berrangéif test "$PWD" = "$source_path"
18dedad027SDaniel P. Berrangéthen
19dedad027SDaniel P. Berrangé    echo "Using './build' as the directory for build output"
20dedad027SDaniel P. Berrangé
21dedad027SDaniel P. Berrangé    MARKER=build/auto-created-by-configure
22dedad027SDaniel P. Berrangé
23dedad027SDaniel P. Berrangé    if test -e build
24dedad027SDaniel P. Berrangé    then
25dedad027SDaniel P. Berrangé        if test -f $MARKER
26dedad027SDaniel P. Berrangé        then
27dedad027SDaniel P. Berrangé           rm -rf build
28dedad027SDaniel P. Berrangé        else
29dedad027SDaniel P. Berrangé            echo "ERROR: ./build dir already exists and was not previously created by configure"
30dedad027SDaniel P. Berrangé            exit 1
31dedad027SDaniel P. Berrangé        fi
32dedad027SDaniel P. Berrangé    fi
33dedad027SDaniel P. Berrangé
34dedad027SDaniel P. Berrangé    mkdir build
35dedad027SDaniel P. Berrangé    touch $MARKER
36dedad027SDaniel P. Berrangé
37dedad027SDaniel P. Berrangé    cat > GNUmakefile <<'EOF'
38dedad027SDaniel P. Berrangé# This file is auto-generated by configure to support in-source tree
39dedad027SDaniel P. Berrangé# 'make' command invocation
40dedad027SDaniel P. Berrangé
41dedad027SDaniel P. Berrangéifeq ($(MAKECMDGOALS),)
42dedad027SDaniel P. Berrangérecurse: all
43dedad027SDaniel P. Berrangéendif
44dedad027SDaniel P. Berrangé
45dedad027SDaniel P. Berrangé.NOTPARALLEL: %
46dedad027SDaniel P. Berrangé%: force
47dedad027SDaniel P. Berrangé	@echo 'changing dir to build for $(MAKE) "$(MAKECMDGOALS)"...'
48dedad027SDaniel P. Berrangé	@$(MAKE) -C build -f Makefile $(MAKECMDGOALS)
49dedad027SDaniel P. Berrangé	@if test "$(MAKECMDGOALS)" = "distclean" && \
50dedad027SDaniel P. Berrangé	    test -e build/auto-created-by-configure ; \
51dedad027SDaniel P. Berrangé	then \
52dedad027SDaniel P. Berrangé	    rm -rf build GNUmakefile ; \
53dedad027SDaniel P. Berrangé	fi
54dedad027SDaniel P. Berrangéforce: ;
55dedad027SDaniel P. Berrangé.PHONY: force
56dedad027SDaniel P. BerrangéGNUmakefile: ;
57dedad027SDaniel P. Berrangé
58dedad027SDaniel P. BerrangéEOF
59dedad027SDaniel P. Berrangé    cd build
60dedad027SDaniel P. Berrangé    exec $source_path/configure "$@"
61dedad027SDaniel P. Berrangéfi
62dedad027SDaniel P. Berrangé
638cd05ab6SPeter Maydell# Temporary directory used for files created while
648cd05ab6SPeter Maydell# configure runs. Since it is in the build directory
658cd05ab6SPeter Maydell# we can safely blow away any previous version of it
668cd05ab6SPeter Maydell# (and we need not jump through hoops to try to delete
678cd05ab6SPeter Maydell# it when configure exits.)
688cd05ab6SPeter MaydellTMPDIR1="config-temp"
698cd05ab6SPeter Maydellrm -rf "${TMPDIR1}"
708cd05ab6SPeter Maydellmkdir -p "${TMPDIR1}"
718cd05ab6SPeter Maydellif [ $? -ne 0 ]; then
728cd05ab6SPeter Maydell    echo "ERROR: failed to create temporary directory"
738cd05ab6SPeter Maydell    exit 1
747d13299dSbellardfi
757d13299dSbellard
768cd05ab6SPeter MaydellTMPB="qemu-conf"
778cd05ab6SPeter MaydellTMPC="${TMPDIR1}/${TMPB}.c"
7866518bf6SDon SlutzTMPO="${TMPDIR1}/${TMPB}.o"
799c83ffd8SPeter MaydellTMPCXX="${TMPDIR1}/${TMPB}.cxx"
808cd05ab6SPeter MaydellTMPE="${TMPDIR1}/${TMPB}.exe"
8126fffe29SEmilio G. CotaTMPTXT="${TMPDIR1}/${TMPB}.txt"
827d13299dSbellard
83da1d85e3SGerd Hoffmannrm -f config.log
849ac81bbbSmalc
85b48e3611SPeter Maydell# Print a helpful header at the top of config.log
86b48e3611SPeter Maydellecho "# QEMU configure log $(date)" >> config.log
87979ae168SPeter Maydellprintf "# Configured with:" >> config.log
88979ae168SPeter Maydellprintf " '%s'" "$0" "$@" >> config.log
89979ae168SPeter Maydellecho >> config.log
90b48e3611SPeter Maydellecho "#" >> config.log
91b48e3611SPeter Maydell
92835af899SPaolo Bonziniquote_sh() {
93835af899SPaolo Bonzini    printf "%s" "$1" | sed "s,','\\\\'',g; s,.*,'&',"
94835af899SPaolo Bonzini}
95835af899SPaolo Bonzini
96d880a3baSPaolo Bonziniprint_error() {
97d880a3baSPaolo Bonzini    (echo
9876ad07a4SPeter Maydell    echo "ERROR: $1"
9976ad07a4SPeter Maydell    while test -n "$2"; do
10076ad07a4SPeter Maydell        echo "       $2"
10176ad07a4SPeter Maydell        shift
10276ad07a4SPeter Maydell    done
103d880a3baSPaolo Bonzini    echo) >&2
104d880a3baSPaolo Bonzini}
105d880a3baSPaolo Bonzini
106d880a3baSPaolo Bonzinierror_exit() {
107d880a3baSPaolo Bonzini    print_error "$@"
10876ad07a4SPeter Maydell    exit 1
10976ad07a4SPeter Maydell}
11076ad07a4SPeter Maydell
1119c83ffd8SPeter Maydelldo_compiler() {
1129c83ffd8SPeter Maydell    # Run the compiler, capturing its output to the log. First argument
1139c83ffd8SPeter Maydell    # is compiler binary to execute.
114630d86b7SDavid CARLIER    compiler="$1"
1159c83ffd8SPeter Maydell    shift
1168bbe05d7SIan Jackson    if test -n "$BASH_VERSION"; then eval '
1178bbe05d7SIan Jackson        echo >>config.log "
1188bbe05d7SIan Jacksonfuncs: ${FUNCNAME[*]}
1198bbe05d7SIan Jacksonlines: ${BASH_LINENO[*]}"
1208bbe05d7SIan Jackson    '; fi
1219c83ffd8SPeter Maydell    echo $compiler "$@" >> config.log
1229c83ffd8SPeter Maydell    $compiler "$@" >> config.log 2>&1 || return $?
1238dc38a78SPeter Maydell    # Test passed. If this is an --enable-werror build, rerun
1248dc38a78SPeter Maydell    # the test with -Werror and bail out if it fails. This
1258dc38a78SPeter Maydell    # makes warning-generating-errors in configure test code
1268dc38a78SPeter Maydell    # obvious to developers.
1278dc38a78SPeter Maydell    if test "$werror" != "yes"; then
1288dc38a78SPeter Maydell        return 0
1298dc38a78SPeter Maydell    fi
1308dc38a78SPeter Maydell    # Don't bother rerunning the compile if we were already using -Werror
1318dc38a78SPeter Maydell    case "$*" in
1328dc38a78SPeter Maydell        *-Werror*)
1338dc38a78SPeter Maydell           return 0
1348dc38a78SPeter Maydell        ;;
1358dc38a78SPeter Maydell    esac
1369c83ffd8SPeter Maydell    echo $compiler -Werror "$@" >> config.log
1379c83ffd8SPeter Maydell    $compiler -Werror "$@" >> config.log 2>&1 && return $?
13876ad07a4SPeter Maydell    error_exit "configure test passed without -Werror but failed with -Werror." \
13976ad07a4SPeter Maydell        "This is probably a bug in the configure script. The failing command" \
14076ad07a4SPeter Maydell        "will be at the bottom of config.log." \
14176ad07a4SPeter Maydell        "You can run configure with --disable-werror to bypass this check."
1428dc38a78SPeter Maydell}
1438dc38a78SPeter Maydell
1449c83ffd8SPeter Maydelldo_cc() {
1454dba2789SPaolo Bonzini    do_compiler "$cc" $CPU_CFLAGS "$@"
1469c83ffd8SPeter Maydell}
1479c83ffd8SPeter Maydell
1489c83ffd8SPeter Maydelldo_cxx() {
1494dba2789SPaolo Bonzini    do_compiler "$cxx" $CPU_CFLAGS "$@"
1509c83ffd8SPeter Maydell}
1519c83ffd8SPeter Maydell
15200849b92SRichard Henderson# Append $2 to the variable named $1, with space separation
15300849b92SRichard Hendersonadd_to() {
15400849b92SRichard Henderson    eval $1=\${$1:+\"\$$1 \"}\$2
15500849b92SRichard Henderson}
15600849b92SRichard Henderson
1579c83ffd8SPeter Maydellupdate_cxxflags() {
1589c83ffd8SPeter Maydell    # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
1599c83ffd8SPeter Maydell    # options which some versions of GCC's C++ compiler complain about
1609c83ffd8SPeter Maydell    # because they only make sense for C programs.
16153422040SPaolo Bonzini    QEMU_CXXFLAGS="$QEMU_CXXFLAGS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS"
1628a9d3d56SRichard Henderson    CONFIGURE_CXXFLAGS=$(echo "$CONFIGURE_CFLAGS" | sed s/-std=gnu11/-std=gnu++11/)
1639c83ffd8SPeter Maydell    for arg in $QEMU_CFLAGS; do
1649c83ffd8SPeter Maydell        case $arg in
1659c83ffd8SPeter Maydell            -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
1669c83ffd8SPeter Maydell            -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
1679c83ffd8SPeter Maydell                ;;
1689c83ffd8SPeter Maydell            *)
1699c83ffd8SPeter Maydell                QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
1709c83ffd8SPeter Maydell                ;;
1719c83ffd8SPeter Maydell        esac
1729c83ffd8SPeter Maydell    done
1739c83ffd8SPeter Maydell}
1749c83ffd8SPeter Maydell
17552166aa0SJuan Quintelacompile_object() {
176fd0e6053SJohn Snow  local_cflags="$1"
1775770e8afSPaolo Bonzini  do_cc $CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
17852166aa0SJuan Quintela}
17952166aa0SJuan Quintela
18052166aa0SJuan Quintelacompile_prog() {
18152166aa0SJuan Quintela  local_cflags="$1"
18252166aa0SJuan Quintela  local_ldflags="$2"
1835770e8afSPaolo Bonzini  do_cc $CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC \
1845770e8afSPaolo Bonzini      $LDFLAGS $CONFIGURE_LDFLAGS $QEMU_LDFLAGS $local_ldflags
18552166aa0SJuan Quintela}
18652166aa0SJuan Quintela
18711568d6dSPaolo Bonzini# symbolically link $1 to $2.  Portable version of "ln -sf".
18811568d6dSPaolo Bonzinisymlink() {
18972b8b5a1SStefan Weil  rm -rf "$2"
190ec5b06d7SAnthony Liguori  mkdir -p "$(dirname "$2")"
19172b8b5a1SStefan Weil  ln -s "$1" "$2"
19211568d6dSPaolo Bonzini}
19311568d6dSPaolo Bonzini
1940dba6195SLoïc Minier# check whether a command is available to this shell (may be either an
1950dba6195SLoïc Minier# executable or a builtin)
1960dba6195SLoïc Minierhas() {
1970dba6195SLoïc Minier    type "$1" >/dev/null 2>&1
1980dba6195SLoïc Minier}
1990dba6195SLoïc Minier
2000a01d76fSMarc-André Lureauversion_ge () {
2012df52b9bSAlex Bennée    local_ver1=$(expr "$1" : '\([0-9.]*\)' | tr . ' ')
2022df52b9bSAlex Bennée    local_ver2=$(echo "$2" | tr . ' ')
2030a01d76fSMarc-André Lureau    while true; do
2040a01d76fSMarc-André Lureau        set x $local_ver1
2050a01d76fSMarc-André Lureau        local_first=${2-0}
206c44a33e2SStefano Garzarella        # 'shift 2' if $2 is set, or 'shift' if $2 is not set
207c44a33e2SStefano Garzarella        shift ${2:+2}
2080a01d76fSMarc-André Lureau        local_ver1=$*
2090a01d76fSMarc-André Lureau        set x $local_ver2
2100a01d76fSMarc-André Lureau        # the second argument finished, the first must be greater or equal
2110a01d76fSMarc-André Lureau        test $# = 1 && return 0
2120a01d76fSMarc-André Lureau        test $local_first -lt $2 && return 1
2130a01d76fSMarc-André Lureau        test $local_first -gt $2 && return 0
214c44a33e2SStefano Garzarella        shift ${2:+2}
2150a01d76fSMarc-André Lureau        local_ver2=$*
2160a01d76fSMarc-André Lureau    done
2170a01d76fSMarc-André Lureau}
2180a01d76fSMarc-André Lureau
2195b808275SLluís Vilanovahave_backend () {
2205b808275SLluís Vilanova    echo "$trace_backends" | grep "$1" >/dev/null
2215b808275SLluís Vilanova}
2225b808275SLluís Vilanova
2233b6b7550SPaolo Bonziniglob() {
2243b6b7550SPaolo Bonzini    eval test -z '"${1#'"$2"'}"'
2253b6b7550SPaolo Bonzini}
2263b6b7550SPaolo Bonzini
227e9a3591fSChristian Borntraegerld_has() {
228e9a3591fSChristian Borntraeger    $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
229e9a3591fSChristian Borntraeger}
230e9a3591fSChristian Borntraeger
2314ace32e2SAntonio Ospiteif printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]";
2324ace32e2SAntonio Ospitethen
2334ace32e2SAntonio Ospite  error_exit "main directory cannot contain spaces nor colons"
2344ace32e2SAntonio Ospitefi
2354ace32e2SAntonio Ospite
23614211825SAntonio Ospite# default parameters
2372ff6b91eSJuan Quintelacpu=""
238a31a8642SMichael S. Tsirkiniasl="iasl"
2391e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
24043ce4dfeSbellardstatic="no"
2413812c0c4SJoelle van Dynecross_compile="no"
2427d13299dSbellardcross_prefix=""
24387430d5bSPaolo Bonziniaudio_drv_list="default"
244b64ec4e4SFam Zhengblock_drv_rw_whitelist=""
245b64ec4e4SFam Zhengblock_drv_ro_whitelist=""
246e5f05f8cSKevin Wolfblock_drv_whitelist_tools="no"
247e49d021eSPeter Maydellhost_cc="cc"
248957f1f99SMichael Rothlibs_qga=""
2495bc62e01SGerd Hoffmanndebug_info="yes"
250cdad781dSDaniele Buonolto="false"
25163678e17SSteven Noonanstack_protector=""
2521e4f6065SDaniele Buonosafe_stack=""
253afc3a8f9SAlex Bennéeuse_containers="yes"
254f2385398SAlex Bennéegdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
255ac0df51dSaliguori
25692712822SDaniel P. Berrangeif test -e "$source_path/.git"
25792712822SDaniel P. Berrangethen
2587d7dbf9dSDan Streetman    git_submodules_action="update"
25992712822SDaniel P. Berrangeelse
2607d7dbf9dSDan Streetman    git_submodules_action="ignore"
26192712822SDaniel P. Berrangefi
2622d652f24SPaolo Bonzini
2632d652f24SPaolo Bonzinigit_submodules="ui/keycodemapdb"
264cc84d63aSDaniel P. Berrangegit="git"
265ac0df51dSaliguori
266afb63ebdSStefan Weil# Don't accept a target_list environment variable.
267afb63ebdSStefan Weilunset target_list
268447e133fSAlex Bennéeunset target_list_exclude
269377529c0SPaolo Bonzini
270377529c0SPaolo Bonzini# Default value for a variable defining feature "foo".
271377529c0SPaolo Bonzini#  * foo="no"  feature will only be used if --enable-foo arg is given
272377529c0SPaolo Bonzini#  * foo=""    feature will be searched for, and if found, will be used
273377529c0SPaolo Bonzini#              unless --disable-foo is given
274377529c0SPaolo Bonzini#  * foo="yes" this value will only be set by --enable-foo flag.
275377529c0SPaolo Bonzini#              feature will searched for,
276377529c0SPaolo Bonzini#              if not found, configure exits with error
277377529c0SPaolo Bonzini#
278377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args.
279377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it
280377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found.
281377529c0SPaolo Bonzini
282c87ea116SAlex Bennéedefault_feature=""
283c87ea116SAlex Bennée# parse CC options second
284c87ea116SAlex Bennéefor opt do
285c87ea116SAlex Bennée  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
286c87ea116SAlex Bennée  case "$opt" in
287c87ea116SAlex Bennée      --without-default-features)
288c87ea116SAlex Bennée          default_feature="no"
289c87ea116SAlex Bennée  ;;
290c87ea116SAlex Bennée  esac
291c87ea116SAlex Bennéedone
292c87ea116SAlex Bennée
2938c6d4ff4SPaolo Bonzinibrlapi="auto"
294f9cd86feSPaolo Bonzinicurl="auto"
2955285e593SYonggang Luoiconv="auto"
2965285e593SYonggang Luocurses="auto"
297e3667660SYonggang Luodocs="auto"
298fbb4121dSPaolo Bonzinifdt="auto"
29958952137SVincenzo Maffionenetmap="no"
30035be72baSPaolo Bonzinisdl="auto"
30135be72baSPaolo Bonzinisdl_image="auto"
302cece116cSMisono Tomohirovirtiofsd="auto"
30369202b40SPaolo Bonzinivirtfs="auto"
3045c53015aSPaolo Bonzinilibudev="auto"
3056ec0e15dSPaolo Bonzinimpath="auto"
3063a6a1256SThomas Huthvnc="auto"
307deb62371SPaolo Bonzinisparse="auto"
308c87ea116SAlex Bennéevde="$default_feature"
309a0b93237SPaolo Bonzinivnc_sasl="auto"
310a0b93237SPaolo Bonzinivnc_jpeg="auto"
311a0b93237SPaolo Bonzinivnc_png="auto"
3124113f4cfSLaurent Vivierxkbcommon="auto"
313*ca50e523SPaolo Bonzinialsa="auto"
314*ca50e523SPaolo Bonzinicoreaudio="auto"
315*ca50e523SPaolo Bonzinidsound="auto"
316*ca50e523SPaolo Bonzinijack="auto"
317*ca50e523SPaolo Bonzinioss="auto"
318*ca50e523SPaolo Bonzinipa="auto"
319bcf0a7daSThomas Huthxen=${default_feature:+disabled}
320c87ea116SAlex Bennéexen_ctrl_version="$default_feature"
3211badb709SPaolo Bonzinixen_pci_passthrough="auto"
322c87ea116SAlex Bennéelinux_aio="$default_feature"
32353c22b68SPaolo Bonzinilinux_io_uring="auto"
324727c8bb8SPaolo Bonzinicap_ng="auto"
325f7f2d651SPaolo Bonziniattr="auto"
326c87ea116SAlex Bennéexfs="$default_feature"
3271badb709SPaolo Bonzinitcg="enabled"
328c87ea116SAlex Bennéemembarrier="$default_feature"
3290848f8acSThomas Huthvhost_kernel="$default_feature"
330c87ea116SAlex Bennéevhost_net="$default_feature"
331c87ea116SAlex Bennéevhost_crypto="$default_feature"
332c87ea116SAlex Bennéevhost_scsi="$default_feature"
333c87ea116SAlex Bennéevhost_vsock="$default_feature"
334d88618f7SStefan Hajnoczivhost_user="no"
335e5e856c1SStefan Hajnoczivhost_user_blk_server="auto"
336c87ea116SAlex Bennéevhost_user_fs="$default_feature"
3370848f8acSThomas Huthvhost_vdpa="$default_feature"
33846627f41SAndrew Melnychenkobpf="auto"
3393bd40ec7SPaolo Bonzinikvm="auto"
3403bd40ec7SPaolo Bonzinihax="auto"
3413bd40ec7SPaolo Bonzinihvf="auto"
3423bd40ec7SPaolo Bonziniwhpx="auto"
34374a414a1SReinoud Zandijknvmm="auto"
344c87ea116SAlex Bennéerdma="$default_feature"
345c87ea116SAlex Bennéepvrdma="$default_feature"
346377529c0SPaolo Bonzinigprof="no"
347377529c0SPaolo Bonzinidebug_tcg="no"
348377529c0SPaolo Bonzinidebug="no"
349247724cbSMarc-André Lureausanitizers="no"
3500aebab04SLingfeng Yangtsan="no"
351c87ea116SAlex Bennéefortify_source="$default_feature"
352377529c0SPaolo Bonzinistrip_opt="yes"
35323a77b2dSPaolo Bonzinitcg_interpreter="false"
354377529c0SPaolo Bonzinibigendian="no"
355377529c0SPaolo Bonzinimingw32="no"
3561d728c39SBlue Swirlgcov="no"
357c7328271SMiroslav RezaninaEXESUF=""
358484e2cc7SPaolo BonziniHOST_DSOSUF=".so"
35917969268SFam Zhengmodules="no"
360bd83c861SChristian Ehrhardtmodule_upgrades="no"
361377529c0SPaolo Bonziniprefix="/usr/local"
36210ff82d1SMarc-André Lureauqemu_suffix="qemu"
3634d34a86bSPaolo Bonzinislirp="auto"
364377529c0SPaolo Bonzinibsd="no"
365377529c0SPaolo Bonzinilinux="no"
366377529c0SPaolo Bonzinisolaris="no"
367377529c0SPaolo Bonziniprofiler="no"
368b4e312e9SPaolo Bonzinicocoa="auto"
369377529c0SPaolo Bonzinisoftmmu="yes"
370377529c0SPaolo Bonzinilinux_user="no"
371377529c0SPaolo Bonzinibsd_user="no"
372c8d5450bSPaolo Bonziniblobs="true"
373377529c0SPaolo Bonzinipkgversion=""
37440d6444eSAvi Kivitypie=""
3753556c233SPaolo Bonziniqom_cast_debug="yes"
376baf86d6bSPaolo Bonzinitrace_backends="log"
377377529c0SPaolo Bonzinitrace_file="trace"
378c87ea116SAlex Bennéespice="$default_feature"
37958d3f3ffSGerd Hoffmannspice_protocol="auto"
380fabd1e93SPaolo Bonzinirbd="auto"
3815f364c57SPaolo Bonzinismartcard="auto"
3820a40bcb7SCésar Belleyu2f="auto"
38390540f32SPaolo Bonzinilibusb="auto"
38418f31e60SPaolo Bonziniusb_redir="auto"
385c87ea116SAlex Bennéeopengl="$default_feature"
3865dd89908SRichard Hendersoncpuid_h="no"
387c87ea116SAlex Bennéeavx2_opt="$default_feature"
3888b18cdbfSRichard Hendersoncapstone="auto"
3890c32a0aeSPaolo Bonzinilzo="auto"
390241611eaSPaolo Bonzinisnappy="auto"
39129ba6116SPaolo Bonzinibzip2="auto"
392ecea3696SPaolo Bonzinilzfse="auto"
393b1def33dSPaolo Bonzinizstd="auto"
394c87ea116SAlex Bennéeguest_agent="$default_feature"
395d9840e25STomoki Sekiyamaguest_agent_with_vss="no"
39650cbebb9SMichael Rothguest_agent_ntddscsi="no"
397b846ab7cSPaolo Bonziniguest_agent_msi="auto"
398c87ea116SAlex Bennéevss_win32_sdk="$default_feature"
399d9840e25STomoki Sekiyamawin_sdk="no"
400c87ea116SAlex Bennéewant_tools="$default_feature"
4019db405a3SPaolo Bonzinilibiscsi="auto"
40230045c05SPaolo Bonzinilibnfs="auto"
403519175a2SAlex Barcelocoroutine=""
404c87ea116SAlex Bennéecoroutine_pool="$default_feature"
4057d992e4dSPeter Lievendebug_stack_usage="no"
406f0d92b56SLongpeng(Mike)crypto_afalg="no"
4079e62ba48SDaniele Buonocfi="false"
4089e62ba48SDaniele Buonocfi_debug="false"
40990835c2bSPaolo Bonziniseccomp="auto"
41008821ca2SPaolo Bonziniglusterfs="auto"
4111b695471SPaolo Bonzinigtk="auto"
412a1c5e949SDaniel P. Berrangetls_priority="NORMAL"
41357612511SPaolo Bonzinignutls="auto"
41457612511SPaolo Bonzininettle="auto"
41557612511SPaolo Bonzinigcrypt="auto"
41605e391aeSPaolo Bonziniauth_pam="auto"
417c23d7b4eSPaolo Bonzinivte="auto"
418587d59d6SPaolo Bonzinivirglrenderer="auto"
419c87ea116SAlex Bennéetpm="$default_feature"
420c87ea116SAlex Bennéelibssh="$default_feature"
421c87ea116SAlex Bennéelive_block_migration=${default_feature:-yes}
422c87ea116SAlex Bennéenuma="$default_feature"
4232847b469SFam Zhengtcmalloc="no"
4247b01cb97SAlexandre Derumierjemalloc="no"
425c87ea116SAlex Bennéereplication=${default_feature:-yes}
426c87ea116SAlex Bennéebochs=${default_feature:-yes}
427c87ea116SAlex Bennéecloop=${default_feature:-yes}
428c87ea116SAlex Bennéedmg=${default_feature:-yes}
429c87ea116SAlex Bennéeqcow1=${default_feature:-yes}
430c87ea116SAlex Bennéevdi=${default_feature:-yes}
431c87ea116SAlex Bennéevvfat=${default_feature:-yes}
432c87ea116SAlex Bennéeqed=${default_feature:-yes}
433c87ea116SAlex Bennéeparallels=${default_feature:-yes}
434c5b36c25SPaolo Bonzinilibxml2="auto"
435ba59fb77SPaolo Bonzinidebug_mutex="no"
436e36e8c70SPaolo Bonzinilibpmem="auto"
4377bc3ca7fSPaolo Bonzinidefault_devices="true"
438ba4dd2aaSAlex Bennéeplugins="$default_feature"
439adc28027SAlexander Bulekovfuzzing="no"
440b767d257SMarek Marczykowski-Góreckirng_none="no"
441c87ea116SAlex Bennéesecret_keyring="$default_feature"
44283ef1682SPaolo Bonzinilibdaxctl="auto"
443a5665051SPaolo Bonzinimeson=""
44448328880SPaolo Bonzinininja=""
445a5665051SPaolo Bonziniskip_meson=no
4460e8e77d4SAlex Bennéegettext="auto"
447a484a719SMax Reitzfuse="auto"
448df4ea709SMax Reitzfuse_lseek="auto"
449106ad1f9SPaolo Bonzinimultiprocess="auto"
450b8e0c493SJoelle van Dyneslirp_smbd="$default_feature"
451377529c0SPaolo Bonzini
452aa087962SPaolo Bonzinimalloc_trim="auto"
45320cf7b8eSDenis Plotnikovgio="$default_feature"
454898be3e0SPeter Maydell
455c87ea116SAlex Bennée# parse CC options second
456ac0df51dSaliguorifor opt do
45789138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
458ac0df51dSaliguori  case "$opt" in
459ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
4603812c0c4SJoelle van Dyne                    cross_compile="yes"
461ac0df51dSaliguori  ;;
4623d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
463ac0df51dSaliguori  ;;
46483f73fceSTomoki Sekiyama  --cxx=*) CXX="$optarg"
46583f73fceSTomoki Sekiyama  ;;
4662ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
4672ff6b91eSJuan Quintela  ;;
468de385287SAlex Bennée  --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
469db5adeaaSPaolo Bonzini                    QEMU_LDFLAGS="$QEMU_LDFLAGS $optarg"
470e2a2ed06SJuan Quintela  ;;
47111cde1c8SBruno Dominguez  --extra-cxxflags=*) QEMU_CXXFLAGS="$QEMU_CXXFLAGS $optarg"
47211cde1c8SBruno Dominguez  ;;
473db5adeaaSPaolo Bonzini  --extra-ldflags=*) QEMU_LDFLAGS="$QEMU_LDFLAGS $optarg"
474f9943cd5SGerd Hoffmann                     EXTRA_LDFLAGS="$optarg"
475e2a2ed06SJuan Quintela  ;;
4765bc62e01SGerd Hoffmann  --enable-debug-info) debug_info="yes"
4775bc62e01SGerd Hoffmann  ;;
4785bc62e01SGerd Hoffmann  --disable-debug-info) debug_info="no"
4795bc62e01SGerd Hoffmann  ;;
480d75402b5SAlex Bennée  --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
481d75402b5SAlex Bennée  ;;
482d422b2bcSAlex Bennée  --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-flags-}; cc_arch=${cc_arch%%=*}
483d422b2bcSAlex Bennée                      eval "cross_cc_cflags_${cc_arch}=\$optarg"
4842038f8c8SPaolo Bonzini                      cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}"
485d422b2bcSAlex Bennée  ;;
486d75402b5SAlex Bennée  --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
4872038f8c8SPaolo Bonzini                cc_archs="$cc_archs $cc_arch"
488d75402b5SAlex Bennée                eval "cross_cc_${cc_arch}=\$optarg"
4892038f8c8SPaolo Bonzini                cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}"
490d75402b5SAlex Bennée  ;;
491ac0df51dSaliguori  esac
492ac0df51dSaliguoridone
493ac0df51dSaliguori# OS specific
494ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
49593148aa5SStefan Weil# we can eliminate its usage altogether.
496ac0df51dSaliguori
497e49d021eSPeter Maydell# Preferred compiler:
498e49d021eSPeter Maydell#  ${CC} (if set)
499e49d021eSPeter Maydell#  ${cross_prefix}gcc (if cross-prefix specified)
500e49d021eSPeter Maydell#  system compiler
501e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then
502e49d021eSPeter Maydell  cc="$host_cc"
503e49d021eSPeter Maydellelse
504b3198cc2SStuart Yoder  cc="${CC-${cross_prefix}gcc}"
505e49d021eSPeter Maydellfi
506e49d021eSPeter Maydell
50783f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then
50883f73fceSTomoki Sekiyama  cxx="c++"
50983f73fceSTomoki Sekiyamaelse
51083f73fceSTomoki Sekiyama  cxx="${CXX-${cross_prefix}g++}"
51183f73fceSTomoki Sekiyamafi
51283f73fceSTomoki Sekiyama
513b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
514cdbd727cSRichard Hendersonas="${AS-${cross_prefix}as}"
5155f6f0e27SRichard Hendersonccas="${CCAS-$cc}"
5163dd46c78SBlue Swirlcpp="${CPP-$cc -E}"
517b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
518b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
5199f81aeb5SAlistair Francisranlib="${RANLIB-${cross_prefix}ranlib}"
5204852ee95SStefan Weilnm="${NM-${cross_prefix}nm}"
521b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
522b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
52317884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
52417884d7bSSergei Trofimovichquery_pkg_config() {
52517884d7bSSergei Trofimovich    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
52617884d7bSSergei Trofimovich}
52717884d7bSSergei Trofimovichpkg_config=query_pkg_config
52847c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
529ac0df51dSaliguori
530be17dc90SMichael S. Tsirkin# default flags for all hosts
5312d31515bSPeter Maydell# We use -fwrapv to tell the compiler that we require a C dialect where
5322d31515bSPeter Maydell# left shift of signed integers is well defined and has the expected
5332d31515bSPeter Maydell# 2s-complement style results. (Both clang and gcc agree that it
5342d31515bSPeter Maydell# provides these semantics.)
535086d5f75SPaolo BonziniQEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
536086d5f75SPaolo BonziniQEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
537c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
538be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
5395770e8afSPaolo Bonzini
5405770e8afSPaolo Bonzini# Flags that are needed during configure but later taken care of by Meson
5418a9d3d56SRichard HendersonCONFIGURE_CFLAGS="-std=gnu11 -Wall"
5425770e8afSPaolo BonziniCONFIGURE_LDFLAGS=
543086d5f75SPaolo Bonzini
544be17dc90SMichael S. Tsirkin
545ac0df51dSaliguoricheck_define() {
546ac0df51dSaliguoricat > $TMPC <<EOF
547ac0df51dSaliguori#if !defined($1)
548fd786e1aSPeter Maydell#error $1 not defined
549ac0df51dSaliguori#endif
550ac0df51dSaliguoriint main(void) { return 0; }
551ac0df51dSaliguoriEOF
55252166aa0SJuan Quintela  compile_object
553ac0df51dSaliguori}
554ac0df51dSaliguori
555307119e7SGerd Hoffmanncheck_include() {
556307119e7SGerd Hoffmanncat > $TMPC <<EOF
557307119e7SGerd Hoffmann#include <$1>
558307119e7SGerd Hoffmannint main(void) { return 0; }
559307119e7SGerd HoffmannEOF
560307119e7SGerd Hoffmann  compile_object
561307119e7SGerd Hoffmann}
562307119e7SGerd Hoffmann
56393b25869SJohn Snowwrite_c_skeleton() {
56493b25869SJohn Snow    cat > $TMPC <<EOF
56593b25869SJohn Snowint main(void) { return 0; }
56693b25869SJohn SnowEOF
56793b25869SJohn Snow}
56893b25869SJohn Snow
569adc28027SAlexander Bulekovwrite_c_fuzzer_skeleton() {
570adc28027SAlexander Bulekov    cat > $TMPC <<EOF
571adc28027SAlexander Bulekov#include <stdint.h>
572adc28027SAlexander Bulekov#include <sys/types.h>
573adc28027SAlexander Bulekovint LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
574adc28027SAlexander Bulekovint LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { return 0; }
575adc28027SAlexander BulekovEOF
576adc28027SAlexander Bulekov}
577adc28027SAlexander Bulekov
578bbea4050SPeter Maydellif check_define __linux__ ; then
579bbea4050SPeter Maydell  targetos="Linux"
580bbea4050SPeter Maydellelif check_define _WIN32 ; then
581bbea4050SPeter Maydell  targetos='MINGW32'
582bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
583bbea4050SPeter Maydell  targetos='OpenBSD'
584bbea4050SPeter Maydellelif check_define __sun__ ; then
585bbea4050SPeter Maydell  targetos='SunOS'
586bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
587bbea4050SPeter Maydell  targetos='Haiku'
588951fedfcSPeter Maydellelif check_define __FreeBSD__ ; then
589951fedfcSPeter Maydell  targetos='FreeBSD'
590951fedfcSPeter Maydellelif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
591951fedfcSPeter Maydell  targetos='GNU/kFreeBSD'
592951fedfcSPeter Maydellelif check_define __DragonFly__ ; then
593951fedfcSPeter Maydell  targetos='DragonFly'
594951fedfcSPeter Maydellelif check_define __NetBSD__; then
595951fedfcSPeter Maydell  targetos='NetBSD'
596951fedfcSPeter Maydellelif check_define __APPLE__; then
597951fedfcSPeter Maydell  targetos='Darwin'
598bbea4050SPeter Maydellelse
599951fedfcSPeter Maydell  # This is a fatal error, but don't report it yet, because we
600951fedfcSPeter Maydell  # might be going to just print the --help text, or it might
601951fedfcSPeter Maydell  # be the result of a missing compiler.
602951fedfcSPeter Maydell  targetos='bogus'
603bbea4050SPeter Maydellfi
604bbea4050SPeter Maydell
605bbea4050SPeter Maydell# Some host OSes need non-standard checks for which CPU to use.
606bbea4050SPeter Maydell# Note that these checks are broken for cross-compilation: if you're
607bbea4050SPeter Maydell# cross-compiling to one of these OSes then you'll need to specify
608bbea4050SPeter Maydell# the correct CPU with the --cpu option.
609bbea4050SPeter Maydellcase $targetos in
610bbea4050SPeter MaydellDarwin)
6115869f8ddSGerd Hoffmann  HOST_DSOSUF=".dylib"
612bbea4050SPeter Maydell  ;;
613bbea4050SPeter MaydellSunOS)
61489138857SStefan Weil  # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
615bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
616bbea4050SPeter Maydell    cpu="x86_64"
617bbea4050SPeter Maydell  fi
618bbea4050SPeter Maydellesac
619bbea4050SPeter Maydell
6202ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
6212ff6b91eSJuan Quintela  # command line argument
6222ff6b91eSJuan Quintela  :
6232ff6b91eSJuan Quintelaelif check_define __i386__ ; then
624ac0df51dSaliguori  cpu="i386"
625ac0df51dSaliguorielif check_define __x86_64__ ; then
626c72b26ecSRichard Henderson  if check_define __ILP32__ ; then
627c72b26ecSRichard Henderson    cpu="x32"
628c72b26ecSRichard Henderson  else
629ac0df51dSaliguori    cpu="x86_64"
630c72b26ecSRichard Henderson  fi
6313aa9bd6cSblueswir1elif check_define __sparc__ ; then
6323aa9bd6cSblueswir1  if check_define __arch64__ ; then
6333aa9bd6cSblueswir1    cpu="sparc64"
6343aa9bd6cSblueswir1  else
6353aa9bd6cSblueswir1    cpu="sparc"
6363aa9bd6cSblueswir1  fi
637fdf7ed96Smalcelif check_define _ARCH_PPC ; then
638fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
639f8378accSRichard Henderson    if check_define _LITTLE_ENDIAN ; then
640f8378accSRichard Henderson      cpu="ppc64le"
641f8378accSRichard Henderson    else
642fdf7ed96Smalc      cpu="ppc64"
643f8378accSRichard Henderson    fi
644ac0df51dSaliguori  else
645fdf7ed96Smalc    cpu="ppc"
646fdf7ed96Smalc  fi
647afa05235SAurelien Jarnoelif check_define __mips__ ; then
648afa05235SAurelien Jarno  cpu="mips"
649d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
650d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
651d66ed0eaSAurelien Jarno    cpu="s390x"
652d66ed0eaSAurelien Jarno  else
653d66ed0eaSAurelien Jarno    cpu="s390"
654d66ed0eaSAurelien Jarno  fi
655c4f80543SAlistair Franciselif check_define __riscv ; then
656c4f80543SAlistair Francis  if check_define _LP64 ; then
657c4f80543SAlistair Francis    cpu="riscv64"
658c4f80543SAlistair Francis  else
659c4f80543SAlistair Francis    cpu="riscv32"
660c4f80543SAlistair Francis  fi
66121d89f84SPeter Maydellelif check_define __arm__ ; then
66221d89f84SPeter Maydell  cpu="arm"
6631f080313SClaudio Fontanaelif check_define __aarch64__ ; then
6641f080313SClaudio Fontana  cpu="aarch64"
665fdf7ed96Smalcelse
66689138857SStefan Weil  cpu=$(uname -m)
667ac0df51dSaliguorifi
668ac0df51dSaliguori
669359bc95dSPeter MaydellARCH=
670359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
671359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
6727d13299dSbellardcase "$cpu" in
673ee35e968SThomas Huth  ppc|ppc64|s390x|sparc64|x32|riscv32|riscv64)
674898be3e0SPeter Maydell  ;;
675f8378accSRichard Henderson  ppc64le)
676f8378accSRichard Henderson    ARCH="ppc64"
677f8378accSRichard Henderson  ;;
6787d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
67997a847bcSbellard    cpu="i386"
6807d13299dSbellard  ;;
681aaa5fa14Saurel32  x86_64|amd64)
682aaa5fa14Saurel32    cpu="x86_64"
683aaa5fa14Saurel32  ;;
68421d89f84SPeter Maydell  armv*b|armv*l|arm)
68521d89f84SPeter Maydell    cpu="arm"
6867d13299dSbellard  ;;
6871f080313SClaudio Fontana  aarch64)
6881f080313SClaudio Fontana    cpu="aarch64"
6891f080313SClaudio Fontana  ;;
690afa05235SAurelien Jarno  mips*)
691afa05235SAurelien Jarno    cpu="mips"
692afa05235SAurelien Jarno  ;;
6933142255cSblueswir1  sparc|sun4[cdmuv])
694ae228531Sbellard    cpu="sparc"
695ae228531Sbellard  ;;
6967d13299dSbellard  *)
697359bc95dSPeter Maydell    # This will result in either an error or falling back to TCI later
698359bc95dSPeter Maydell    ARCH=unknown
6997d13299dSbellard  ;;
7007d13299dSbellardesac
701359bc95dSPeter Maydellif test -z "$ARCH"; then
702359bc95dSPeter Maydell  ARCH="$cpu"
703359bc95dSPeter Maydellfi
704e2d52ad3SJuan Quintela
7057d13299dSbellard# OS specific
7060dbfc675SJuan Quintela
7077d13299dSbellardcase $targetos in
70867b915a5SbellardMINGW32*)
70967b915a5Sbellard  mingw32="yes"
710898be3e0SPeter Maydell  supported_os="yes"
7119b8e4298SAlex Bennée  plugins="no"
712fb648e9cSDaniel P. Berrangé  pie="no"
71367b915a5Sbellard;;
7145c40d2bdSthsGNU/kFreeBSD)
715a167ba50SAurelien Jarno  bsd="yes"
7165c40d2bdSths;;
7177d3505c5SbellardFreeBSD)
7187d3505c5Sbellard  bsd="yes"
719e2a74729SWarner Losh  bsd_user="yes"
7200db4a067SPaolo Bonzini  make="${MAKE-gmake}"
721f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
72258952137SVincenzo Maffione  netmap=""  # enable netmap autodetect
7237d3505c5Sbellard;;
724c5e97233Sblueswir1DragonFly)
725c5e97233Sblueswir1  bsd="yes"
7260db4a067SPaolo Bonzini  make="${MAKE-gmake}"
727c5e97233Sblueswir1;;
7287d3505c5SbellardNetBSD)
7297d3505c5Sbellard  bsd="yes"
7300db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7317d3505c5Sbellard;;
7327d3505c5SbellardOpenBSD)
7337d3505c5Sbellard  bsd="yes"
7340db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7357d3505c5Sbellard;;
73683fb7adfSbellardDarwin)
73783fb7adfSbellard  bsd="yes"
73883fb7adfSbellard  darwin="yes"
739a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
740a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
741a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
74283fb7adfSbellard;;
743ec530c81SbellardSunOS)
744ec530c81Sbellard  solaris="yes"
7450db4a067SPaolo Bonzini  make="${MAKE-gmake}"
746e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
747d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
748d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
749d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
750d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
751ec530c81Sbellard;;
752179cf400SAndreas FärberHaiku)
753179cf400SAndreas Färber  haiku="yes"
754b8ee198dSRichard Zak  pie="no"
755b8ee198dSRichard Zak  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE -fPIC $QEMU_CFLAGS"
756179cf400SAndreas Färber;;
757898be3e0SPeter MaydellLinux)
7585327cf48Sbellard  linux="yes"
759831b7825Sths  linux_user="yes"
760c87ea116SAlex Bennée  vhost_user=${default_feature:-yes}
761898be3e0SPeter Maydell;;
7627d13299dSbellardesac
7637d13299dSbellard
7640db4a067SPaolo Bonzini: ${make=${MAKE-make}}
765b6daf4d3SPaolo Bonzini
766faf44142SDaniel P. Berrangé# We prefer python 3.x. A bare 'python' is traditionally
767faf44142SDaniel P. Berrangé# python 2.x, but some distros have it as python 3.x, so
768ddf90699SEduardo Habkost# we check that too
769faf44142SDaniel P. Berrangépython=
7700a01d76fSMarc-André Lureauexplicit_python=no
771ddf90699SEduardo Habkostfor binary in "${PYTHON-python3}" python
772faf44142SDaniel P. Berrangédo
773faf44142SDaniel P. Berrangé    if has "$binary"
774faf44142SDaniel P. Berrangé    then
77595c5f2deSPaolo Bonzini        python=$(command -v "$binary")
776faf44142SDaniel P. Berrangé        break
777faf44142SDaniel P. Berrangé    fi
778faf44142SDaniel P. Berrangédone
779903458c8SMarkus Armbruster
780903458c8SMarkus Armbruster
78139d87c8cSAlex Bennée# Check for ancillary tools used in testing
78239d87c8cSAlex Bennéegenisoimage=
7833df437c7SAlex Bennéefor binary in genisoimage mkisofs
78439d87c8cSAlex Bennéedo
78539d87c8cSAlex Bennée    if has $binary
78639d87c8cSAlex Bennée    then
78739d87c8cSAlex Bennée        genisoimage=$(command -v "$binary")
78839d87c8cSAlex Bennée        break
78939d87c8cSAlex Bennée    fi
79039d87c8cSAlex Bennéedone
79139d87c8cSAlex Bennée
7923c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
7933c4a4d0dSPeter Maydellif has clang; then
7943c4a4d0dSPeter Maydell  objcc=clang
7953c4a4d0dSPeter Maydellelse
7963c4a4d0dSPeter Maydell  objcc="$cc"
7973c4a4d0dSPeter Maydellfi
7983c4a4d0dSPeter Maydell
7993457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
8003457a3f8SJuan Quintela  EXESUF=".exe"
801484e2cc7SPaolo Bonzini  HOST_DSOSUF=".dll"
80278e9d4adSStefan Weil  # MinGW needs -mthreads for TLS and macro _MT.
8035770e8afSPaolo Bonzini  CONFIGURE_CFLAGS="-mthreads $CONFIGURE_CFLAGS"
80493b25869SJohn Snow  write_c_skeleton;
805d17f305aSPaolo Bonzini  prefix="/qemu"
80677433a5fSMarc-André Lureau  qemu_suffix=""
807105fad6bSBishara AbuHattoum  libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
8083457a3f8SJuan Quintelafi
8093457a3f8SJuan Quintela
810487fefdbSAnthony Liguoriwerror=""
81185aa5189Sbellard
8127d13299dSbellardfor opt do
81389138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
8147d13299dSbellard  case "$opt" in
8152efc3265Sbellard  --help|-h) show_help=yes
8162efc3265Sbellard  ;;
81799123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
81899123e13SMike Frysinger  ;;
819b1a550a0Spbrook  --prefix=*) prefix="$optarg"
8207d13299dSbellard  ;;
821b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
82232ce6337Sbellard  ;;
823ac0df51dSaliguori  --cross-prefix=*)
8247d13299dSbellard  ;;
825ac0df51dSaliguori  --cc=*)
8267d13299dSbellard  ;;
827b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
82883469015Sbellard  ;;
82983f73fceSTomoki Sekiyama  --cxx=*)
83083f73fceSTomoki Sekiyama  ;;
831e007dbecSMichael S. Tsirkin  --iasl=*) iasl="$optarg"
832e007dbecSMichael S. Tsirkin  ;;
8333c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
8343c4a4d0dSPeter Maydell  ;;
835b1a550a0Spbrook  --make=*) make="$optarg"
8367d13299dSbellard  ;;
837b6daf4d3SPaolo Bonzini  --install=*)
8386a882643Spbrook  ;;
8390a01d76fSMarc-André Lureau  --python=*) python="$optarg" ; explicit_python=yes
840c886edfbSBlue Swirl  ;;
8412eb054c2SPeter Maydell  --sphinx-build=*) sphinx_build="$optarg"
8422eb054c2SPeter Maydell  ;;
843a5665051SPaolo Bonzini  --skip-meson) skip_meson=yes
844a5665051SPaolo Bonzini  ;;
845a5665051SPaolo Bonzini  --meson=*) meson="$optarg"
846a5665051SPaolo Bonzini  ;;
84748328880SPaolo Bonzini  --ninja=*) ninja="$optarg"
84848328880SPaolo Bonzini  ;;
849e2d8830eSBrad  --smbd=*) smbd="$optarg"
850e2d8830eSBrad  ;;
851e2a2ed06SJuan Quintela  --extra-cflags=*)
8527d13299dSbellard  ;;
85311cde1c8SBruno Dominguez  --extra-cxxflags=*)
85411cde1c8SBruno Dominguez  ;;
855e2a2ed06SJuan Quintela  --extra-ldflags=*)
8567d13299dSbellard  ;;
8575bc62e01SGerd Hoffmann  --enable-debug-info)
8585bc62e01SGerd Hoffmann  ;;
8595bc62e01SGerd Hoffmann  --disable-debug-info)
8605bc62e01SGerd Hoffmann  ;;
861d75402b5SAlex Bennée  --cross-cc-*)
862d75402b5SAlex Bennée  ;;
86317969268SFam Zheng  --enable-modules)
86417969268SFam Zheng      modules="yes"
86517969268SFam Zheng  ;;
8663aa88b31SStefan Hajnoczi  --disable-modules)
8673aa88b31SStefan Hajnoczi      modules="no"
8683aa88b31SStefan Hajnoczi  ;;
869bd83c861SChristian Ehrhardt  --disable-module-upgrades) module_upgrades="no"
870bd83c861SChristian Ehrhardt  ;;
871bd83c861SChristian Ehrhardt  --enable-module-upgrades) module_upgrades="yes"
872bd83c861SChristian Ehrhardt  ;;
8732ff6b91eSJuan Quintela  --cpu=*)
8747d13299dSbellard  ;;
875b1a550a0Spbrook  --target-list=*) target_list="$optarg"
876447e133fSAlex Bennée                   if test "$target_list_exclude"; then
877447e133fSAlex Bennée                       error_exit "Can't mix --target-list with --target-list-exclude"
878447e133fSAlex Bennée                   fi
879447e133fSAlex Bennée  ;;
880447e133fSAlex Bennée  --target-list-exclude=*) target_list_exclude="$optarg"
881447e133fSAlex Bennée                   if test "$target_list"; then
882447e133fSAlex Bennée                       error_exit "Can't mix --target-list-exclude with --target-list"
883447e133fSAlex Bennée                   fi
884de83cd02Sbellard  ;;
8855b808275SLluís Vilanova  --enable-trace-backends=*) trace_backends="$optarg"
8865b808275SLluís Vilanova  ;;
8875b808275SLluís Vilanova  # XXX: backwards compatibility
8885b808275SLluís Vilanova  --enable-trace-backend=*) trace_backends="$optarg"
88994a420b1SStefan Hajnoczi  ;;
89074242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
8919410b56cSPrerna Saxena  ;;
8927bc3ca7fSPaolo Bonzini  --with-default-devices) default_devices="true"
893f3494749SPaolo Bonzini  ;;
8947bc3ca7fSPaolo Bonzini  --without-default-devices) default_devices="false"
895f3494749SPaolo Bonzini  ;;
896d1d5e9eeSAlex Bennée  --with-devices-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --with-devices-FOO option"
897d1d5e9eeSAlex Bennée  ;;
898d1d5e9eeSAlex Bennée  --with-devices-*) device_arch=${opt#--with-devices-};
899d1d5e9eeSAlex Bennée                    device_arch=${device_arch%%=*}
900d1d5e9eeSAlex Bennée                    cf=$source_path/configs/devices/$device_arch-softmmu/$optarg.mak
901d1d5e9eeSAlex Bennée                    if test -f "$cf"; then
902d1d5e9eeSAlex Bennée                        device_archs="$device_archs $device_arch"
903d1d5e9eeSAlex Bennée                        eval "devices_${device_arch}=\$optarg"
904d1d5e9eeSAlex Bennée                    else
905d1d5e9eeSAlex Bennée                        error_exit "File $cf does not exist"
906d1d5e9eeSAlex Bennée                    fi
907d1d5e9eeSAlex Bennée  ;;
908c87ea116SAlex Bennée  --without-default-features) # processed above
909c87ea116SAlex Bennée  ;;
9107d13299dSbellard  --enable-gprof) gprof="yes"
9117d13299dSbellard  ;;
9121d728c39SBlue Swirl  --enable-gcov) gcov="yes"
9131d728c39SBlue Swirl  ;;
91479427693SLoïc Minier  --static)
91579427693SLoïc Minier    static="yes"
91617884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
91743ce4dfeSbellard  ;;
9180b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
9190b24e75fSPaolo Bonzini  ;;
9200b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
9210b24e75fSPaolo Bonzini  ;;
9223aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
9233aa5d2beSAlon Levy  ;;
9248bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
9258bf188aaSMichael Tokarev  ;;
9260f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
9270f94d6daSAlon Levy  ;;
928528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
9290b24e75fSPaolo Bonzini  ;;
93077433a5fSMarc-André Lureau  --with-suffix=*) qemu_suffix="$optarg"
931023d3d67SEduardo Habkost  ;;
932c6502638SBruce Rogers  --docdir=*) docdir="$optarg"
9330b24e75fSPaolo Bonzini  ;;
934fe0038beSPaolo Bonzini  --localedir=*) localedir="$optarg"
935fe0038beSPaolo Bonzini  ;;
936ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
93707381cc1SAnthony Liguori  ;;
938785c23aeSLuiz Capitulino  --localstatedir=*) local_statedir="$optarg"
939785c23aeSLuiz Capitulino  ;;
9403d5eecabSGerd Hoffmann  --firmwarepath=*) firmwarepath="$optarg"
9413d5eecabSGerd Hoffmann  ;;
942181ce1d0SOlaf Hering  --host=*|--build=*|\
943181ce1d0SOlaf Hering  --disable-dependency-tracking|\
944785c23aeSLuiz Capitulino  --sbindir=*|--sharedstatedir=*|\
945fe0038beSPaolo Bonzini  --oldincludedir=*|--datarootdir=*|--infodir=*|\
946023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
947023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
948023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
949023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
950023ddd74SMax Filippov    # lots of directory switches by default.
951023ddd74SMax Filippov  ;;
95235be72baSPaolo Bonzini  --disable-sdl) sdl="disabled"
95397a847bcSbellard  ;;
95435be72baSPaolo Bonzini  --enable-sdl) sdl="enabled"
955c4198157SJuan Quintela  ;;
95635be72baSPaolo Bonzini  --disable-sdl-image) sdl_image="disabled"
957a442fe2fSDaniel P. Berrangé  ;;
95835be72baSPaolo Bonzini  --enable-sdl-image) sdl_image="enabled"
959a442fe2fSDaniel P. Berrangé  ;;
9603556c233SPaolo Bonzini  --disable-qom-cast-debug) qom_cast_debug="no"
9613556c233SPaolo Bonzini  ;;
9623556c233SPaolo Bonzini  --enable-qom-cast-debug) qom_cast_debug="yes"
9633556c233SPaolo Bonzini  ;;
96469202b40SPaolo Bonzini  --disable-virtfs) virtfs="disabled"
965983eef5aSMeador Inge  ;;
96669202b40SPaolo Bonzini  --enable-virtfs) virtfs="enabled"
967983eef5aSMeador Inge  ;;
9685c53015aSPaolo Bonzini  --disable-libudev) libudev="disabled"
9695c53015aSPaolo Bonzini  ;;
9705c53015aSPaolo Bonzini  --enable-libudev) libudev="enabled"
9715c53015aSPaolo Bonzini  ;;
972cece116cSMisono Tomohiro  --disable-virtiofsd) virtiofsd="disabled"
973cece116cSMisono Tomohiro  ;;
974cece116cSMisono Tomohiro  --enable-virtiofsd) virtiofsd="enabled"
975cece116cSMisono Tomohiro  ;;
9766ec0e15dSPaolo Bonzini  --disable-mpath) mpath="disabled"
977fe8fc5aeSPaolo Bonzini  ;;
9786ec0e15dSPaolo Bonzini  --enable-mpath) mpath="enabled"
979fe8fc5aeSPaolo Bonzini  ;;
980a0b93237SPaolo Bonzini  --disable-vnc) vnc="disabled"
981821601eaSJes Sorensen  ;;
982a0b93237SPaolo Bonzini  --enable-vnc) vnc="enabled"
983821601eaSJes Sorensen  ;;
9840e8e77d4SAlex Bennée  --disable-gettext) gettext="disabled"
985e8f3bd71SMarc-André Lureau  ;;
9860e8e77d4SAlex Bennée  --enable-gettext) gettext="enabled"
987e8f3bd71SMarc-André Lureau  ;;
9880c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
9890c58ac1cSmalc  ;;
99089138857SStefan Weil  --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
991b64ec4e4SFam Zheng  ;;
99289138857SStefan Weil  --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
993eb852011SMarkus Armbruster  ;;
994e5f05f8cSKevin Wolf  --enable-block-drv-whitelist-in-tools) block_drv_whitelist_tools="yes"
995e5f05f8cSKevin Wolf  ;;
996e5f05f8cSKevin Wolf  --disable-block-drv-whitelist-in-tools) block_drv_whitelist_tools="no"
997e5f05f8cSKevin Wolf  ;;
998f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
999f8393946Saurel32  ;;
1000f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
1001f8393946Saurel32  ;;
1002f3d08ee6SPaul Brook  --enable-debug)
1003f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
1004f3d08ee6SPaul Brook      debug_tcg="yes"
10051fcc6d42SPeter Xu      debug_mutex="yes"
1006f3d08ee6SPaul Brook      debug="yes"
1007f3d08ee6SPaul Brook      strip_opt="no"
1008b553a042SJohn Snow      fortify_source="no"
1009f3d08ee6SPaul Brook  ;;
1010247724cbSMarc-André Lureau  --enable-sanitizers) sanitizers="yes"
1011247724cbSMarc-André Lureau  ;;
1012247724cbSMarc-André Lureau  --disable-sanitizers) sanitizers="no"
1013247724cbSMarc-André Lureau  ;;
10140aebab04SLingfeng Yang  --enable-tsan) tsan="yes"
10150aebab04SLingfeng Yang  ;;
10160aebab04SLingfeng Yang  --disable-tsan) tsan="no"
10170aebab04SLingfeng Yang  ;;
1018deb62371SPaolo Bonzini  --enable-sparse) sparse="enabled"
101903b4fe7dSaliguori  ;;
1020deb62371SPaolo Bonzini  --disable-sparse) sparse="disabled"
102103b4fe7dSaliguori  ;;
10221625af87Saliguori  --disable-strip) strip_opt="no"
10231625af87Saliguori  ;;
1024a0b93237SPaolo Bonzini  --disable-vnc-sasl) vnc_sasl="disabled"
10252f9606b3Saliguori  ;;
1026a0b93237SPaolo Bonzini  --enable-vnc-sasl) vnc_sasl="enabled"
1027ea784e3bSJuan Quintela  ;;
1028a0b93237SPaolo Bonzini  --disable-vnc-jpeg) vnc_jpeg="disabled"
10292f6f5c7aSCorentin Chary  ;;
1030a0b93237SPaolo Bonzini  --enable-vnc-jpeg) vnc_jpeg="enabled"
10312f6f5c7aSCorentin Chary  ;;
1032a0b93237SPaolo Bonzini  --disable-vnc-png) vnc_png="disabled"
1033efe556adSCorentin Chary  ;;
1034a0b93237SPaolo Bonzini  --enable-vnc-png) vnc_png="enabled"
1035efe556adSCorentin Chary  ;;
10364d34a86bSPaolo Bonzini  --disable-slirp) slirp="disabled"
1037c20709aaSbellard  ;;
1038fd6fc214SPaolo Bonzini  --enable-slirp) slirp="enabled"
1039fd6fc214SPaolo Bonzini  ;;
10404d34a86bSPaolo Bonzini  --enable-slirp=git) slirp="internal"
10417c57bdd8SMarc-André Lureau  ;;
1042675b9b53SMarc-André Lureau  --enable-slirp=system) slirp="system"
1043675b9b53SMarc-André Lureau  ;;
1044e0e6c8c0Saliguori  --disable-vde) vde="no"
10458a16d273Sths  ;;
1046dfb278bdSJuan Quintela  --enable-vde) vde="yes"
1047dfb278bdSJuan Quintela  ;;
104858952137SVincenzo Maffione  --disable-netmap) netmap="no"
104958952137SVincenzo Maffione  ;;
105058952137SVincenzo Maffione  --enable-netmap) netmap="yes"
105158952137SVincenzo Maffione  ;;
10521badb709SPaolo Bonzini  --disable-xen) xen="disabled"
1053e37630caSaliguori  ;;
10541badb709SPaolo Bonzini  --enable-xen) xen="enabled"
1055fc321b4bSJuan Quintela  ;;
10561badb709SPaolo Bonzini  --disable-xen-pci-passthrough) xen_pci_passthrough="disabled"
1057eb6fda0fSAnthony PERARD  ;;
10581badb709SPaolo Bonzini  --enable-xen-pci-passthrough) xen_pci_passthrough="enabled"
1059eb6fda0fSAnthony PERARD  ;;
1060*ca50e523SPaolo Bonzini  --disable-alsa) alsa="disabled"
1061*ca50e523SPaolo Bonzini  ;;
1062*ca50e523SPaolo Bonzini  --enable-alsa) alsa="enabled"
1063*ca50e523SPaolo Bonzini  ;;
1064*ca50e523SPaolo Bonzini  --disable-coreaudio) coreaudio="disabled"
1065*ca50e523SPaolo Bonzini  ;;
1066*ca50e523SPaolo Bonzini  --enable-coreaudio) coreaudio="enabled"
1067*ca50e523SPaolo Bonzini  ;;
1068*ca50e523SPaolo Bonzini  --disable-dsound) dsound="disabled"
1069*ca50e523SPaolo Bonzini  ;;
1070*ca50e523SPaolo Bonzini  --enable-dsound) dsound="enabled"
1071*ca50e523SPaolo Bonzini  ;;
1072*ca50e523SPaolo Bonzini  --disable-jack) jack="disabled"
1073*ca50e523SPaolo Bonzini  ;;
1074*ca50e523SPaolo Bonzini  --enable-jack) jack="enabled"
1075*ca50e523SPaolo Bonzini  ;;
1076*ca50e523SPaolo Bonzini  --disable-oss) oss="disabled"
1077*ca50e523SPaolo Bonzini  ;;
1078*ca50e523SPaolo Bonzini  --enable-oss) oss="enabled"
1079*ca50e523SPaolo Bonzini  ;;
1080*ca50e523SPaolo Bonzini  --disable-pa) pa="disabled"
1081*ca50e523SPaolo Bonzini  ;;
1082*ca50e523SPaolo Bonzini  --enable-pa) pa="enabled"
1083*ca50e523SPaolo Bonzini  ;;
10848c6d4ff4SPaolo Bonzini  --disable-brlapi) brlapi="disabled"
10852e4d9fb1Saurel32  ;;
10868c6d4ff4SPaolo Bonzini  --enable-brlapi) brlapi="enabled"
10874ffcedb6SJuan Quintela  ;;
10881badb709SPaolo Bonzini  --disable-kvm) kvm="disabled"
10897ba1e619Saliguori  ;;
10901badb709SPaolo Bonzini  --enable-kvm) kvm="enabled"
1091b31a0277SJuan Quintela  ;;
10921badb709SPaolo Bonzini  --disable-hax) hax="disabled"
1093180fb750Szhanghailiang  ;;
10941badb709SPaolo Bonzini  --enable-hax) hax="enabled"
1095180fb750Szhanghailiang  ;;
10961badb709SPaolo Bonzini  --disable-hvf) hvf="disabled"
1097c97d6d2cSSergio Andres Gomez Del Real  ;;
10981badb709SPaolo Bonzini  --enable-hvf) hvf="enabled"
1099c97d6d2cSSergio Andres Gomez Del Real  ;;
110074a414a1SReinoud Zandijk  --disable-nvmm) nvmm="disabled"
110174a414a1SReinoud Zandijk  ;;
110274a414a1SReinoud Zandijk  --enable-nvmm) nvmm="enabled"
110374a414a1SReinoud Zandijk  ;;
11041badb709SPaolo Bonzini  --disable-whpx) whpx="disabled"
1105d661d9a4SJustin Terry (VM)  ;;
11061badb709SPaolo Bonzini  --enable-whpx) whpx="enabled"
1107d661d9a4SJustin Terry (VM)  ;;
1108c6fbea47SRichard Henderson  --disable-tcg-interpreter) tcg_interpreter="false"
11099195b2c2SStefan Weil  ;;
1110c6fbea47SRichard Henderson  --enable-tcg-interpreter) tcg_interpreter="true"
11119195b2c2SStefan Weil  ;;
1112727c8bb8SPaolo Bonzini  --disable-cap-ng)  cap_ng="disabled"
111347e98658SCorey Bryant  ;;
1114727c8bb8SPaolo Bonzini  --enable-cap-ng) cap_ng="enabled"
111547e98658SCorey Bryant  ;;
11161badb709SPaolo Bonzini  --disable-tcg) tcg="disabled"
1117d1a14257SAlex Bennée                 plugins="no"
1118b3f6ea7eSPaolo Bonzini  ;;
11191badb709SPaolo Bonzini  --enable-tcg) tcg="enabled"
1120b3f6ea7eSPaolo Bonzini  ;;
1121aa087962SPaolo Bonzini  --disable-malloc-trim) malloc_trim="disabled"
11225a22ab71SYang Zhong  ;;
1123aa087962SPaolo Bonzini  --enable-malloc-trim) malloc_trim="enabled"
11245a22ab71SYang Zhong  ;;
1125cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
1126cd4ec0b4SGerd Hoffmann  ;;
112758d3f3ffSGerd Hoffmann  --enable-spice)
112858d3f3ffSGerd Hoffmann      spice_protocol="yes"
112958d3f3ffSGerd Hoffmann      spice="yes"
113058d3f3ffSGerd Hoffmann  ;;
113158d3f3ffSGerd Hoffmann  --disable-spice-protocol)
113258d3f3ffSGerd Hoffmann      spice_protocol="no"
113358d3f3ffSGerd Hoffmann      spice="no"
113458d3f3ffSGerd Hoffmann  ;;
113558d3f3ffSGerd Hoffmann  --enable-spice-protocol) spice_protocol="yes"
1136cd4ec0b4SGerd Hoffmann  ;;
11379db405a3SPaolo Bonzini  --disable-libiscsi) libiscsi="disabled"
1138c589b249SRonnie Sahlberg  ;;
11399db405a3SPaolo Bonzini  --enable-libiscsi) libiscsi="enabled"
1140c589b249SRonnie Sahlberg  ;;
114130045c05SPaolo Bonzini  --disable-libnfs) libnfs="disabled"
11426542aa9cSPeter Lieven  ;;
114330045c05SPaolo Bonzini  --enable-libnfs) libnfs="enabled"
11446542aa9cSPeter Lieven  ;;
114505c2a3e7Sbellard  --enable-profiler) profiler="yes"
114605c2a3e7Sbellard  ;;
1147b4e312e9SPaolo Bonzini  --disable-cocoa) cocoa="disabled"
114814821030SPavel Borzenkov  ;;
1149a23a6789SPaolo Bonzini  --enable-cocoa) cocoa="enabled"
11505b0753e0Sbellard  ;;
1151cad25d69Spbrook  --disable-system) softmmu="no"
11520a8e90f4Spbrook  ;;
1153cad25d69Spbrook  --enable-system) softmmu="yes"
11540a8e90f4Spbrook  ;;
11550953a80fSZachary Amsden  --disable-user)
11560953a80fSZachary Amsden      linux_user="no" ;
11570953a80fSZachary Amsden      bsd_user="no" ;
11580953a80fSZachary Amsden  ;;
11590953a80fSZachary Amsden  --enable-user) ;;
1160831b7825Sths  --disable-linux-user) linux_user="no"
11610a8e90f4Spbrook  ;;
1162831b7825Sths  --enable-linux-user) linux_user="yes"
1163831b7825Sths  ;;
116484778508Sblueswir1  --disable-bsd-user) bsd_user="no"
116584778508Sblueswir1  ;;
116684778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
116784778508Sblueswir1  ;;
116840d6444eSAvi Kivity  --enable-pie) pie="yes"
116934005a00SKirill A. Shutemov  ;;
117040d6444eSAvi Kivity  --disable-pie) pie="no"
117134005a00SKirill A. Shutemov  ;;
117285aa5189Sbellard  --enable-werror) werror="yes"
117385aa5189Sbellard  ;;
117485aa5189Sbellard  --disable-werror) werror="no"
117585aa5189Sbellard  ;;
1176cdad781dSDaniele Buono  --enable-lto) lto="true"
1177cdad781dSDaniele Buono  ;;
1178cdad781dSDaniele Buono  --disable-lto) lto="false"
1179cdad781dSDaniele Buono  ;;
118063678e17SSteven Noonan  --enable-stack-protector) stack_protector="yes"
118163678e17SSteven Noonan  ;;
118263678e17SSteven Noonan  --disable-stack-protector) stack_protector="no"
118363678e17SSteven Noonan  ;;
11841e4f6065SDaniele Buono  --enable-safe-stack) safe_stack="yes"
11851e4f6065SDaniele Buono  ;;
11861e4f6065SDaniele Buono  --disable-safe-stack) safe_stack="no"
11871e4f6065SDaniele Buono  ;;
11889e62ba48SDaniele Buono  --enable-cfi)
11899e62ba48SDaniele Buono      cfi="true";
11909e62ba48SDaniele Buono      lto="true";
11919e62ba48SDaniele Buono  ;;
11929e62ba48SDaniele Buono  --disable-cfi) cfi="false"
11939e62ba48SDaniele Buono  ;;
11949e62ba48SDaniele Buono  --enable-cfi-debug) cfi_debug="true"
11959e62ba48SDaniele Buono  ;;
11969e62ba48SDaniele Buono  --disable-cfi-debug) cfi_debug="false"
11979e62ba48SDaniele Buono  ;;
11985285e593SYonggang Luo  --disable-curses) curses="disabled"
11994d3b6f6eSbalrog  ;;
12005285e593SYonggang Luo  --enable-curses) curses="enabled"
1201c584a6d0SJuan Quintela  ;;
12025285e593SYonggang Luo  --disable-iconv) iconv="disabled"
1203e08bb301SSamuel Thibault  ;;
12045285e593SYonggang Luo  --enable-iconv) iconv="enabled"
1205e08bb301SSamuel Thibault  ;;
1206f9cd86feSPaolo Bonzini  --disable-curl) curl="disabled"
1207769ce76dSAlexander Graf  ;;
1208f9cd86feSPaolo Bonzini  --enable-curl) curl="enabled"
1209788c8196SJuan Quintela  ;;
1210fbb4121dSPaolo Bonzini  --disable-fdt) fdt="disabled"
12112df87df7SJuan Quintela  ;;
1212fbb4121dSPaolo Bonzini  --enable-fdt) fdt="enabled"
1213fbb4121dSPaolo Bonzini  ;;
1214fbb4121dSPaolo Bonzini  --enable-fdt=git) fdt="internal"
1215fbb4121dSPaolo Bonzini  ;;
1216fbb4121dSPaolo Bonzini  --enable-fdt=system) fdt="system"
12172df87df7SJuan Quintela  ;;
12185c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
12195c6c3a6cSChristoph Hellwig  ;;
12205c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
12215c6c3a6cSChristoph Hellwig  ;;
122253c22b68SPaolo Bonzini  --disable-linux-io-uring) linux_io_uring="disabled"
1223c10dd856SAarushi Mehta  ;;
122453c22b68SPaolo Bonzini  --enable-linux-io-uring) linux_io_uring="enabled"
1225c10dd856SAarushi Mehta  ;;
1226f7f2d651SPaolo Bonzini  --disable-attr) attr="disabled"
1227758e8e38SVenkateswararao Jujjuri (JV)  ;;
1228f7f2d651SPaolo Bonzini  --enable-attr) attr="enabled"
1229758e8e38SVenkateswararao Jujjuri (JV)  ;;
1230a40161cbSPaolo Bonzini  --disable-membarrier) membarrier="no"
1231a40161cbSPaolo Bonzini  ;;
1232a40161cbSPaolo Bonzini  --enable-membarrier) membarrier="yes"
1233a40161cbSPaolo Bonzini  ;;
123446627f41SAndrew Melnychenko  --disable-bpf) bpf="disabled"
123546627f41SAndrew Melnychenko  ;;
123646627f41SAndrew Melnychenko  --enable-bpf) bpf="enabled"
123746627f41SAndrew Melnychenko  ;;
1238c8d5450bSPaolo Bonzini  --disable-blobs) blobs="false"
123977755340Sths  ;;
12407e563bfbSThomas Huth  --with-pkgversion=*) pkgversion="$optarg"
12414a19f1ecSpbrook  ;;
1242519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
1243519175a2SAlex Barcelo  ;;
124470c60c08SStefan Hajnoczi  --disable-coroutine-pool) coroutine_pool="no"
124570c60c08SStefan Hajnoczi  ;;
124670c60c08SStefan Hajnoczi  --enable-coroutine-pool) coroutine_pool="yes"
124770c60c08SStefan Hajnoczi  ;;
12487d992e4dSPeter Lieven  --enable-debug-stack-usage) debug_stack_usage="yes"
12497d992e4dSPeter Lieven  ;;
1250f0d92b56SLongpeng(Mike)  --enable-crypto-afalg) crypto_afalg="yes"
1251f0d92b56SLongpeng(Mike)  ;;
1252f0d92b56SLongpeng(Mike)  --disable-crypto-afalg) crypto_afalg="no"
1253f0d92b56SLongpeng(Mike)  ;;
1254e3667660SYonggang Luo  --disable-docs) docs="disabled"
125570ec5dc0SAnthony Liguori  ;;
1256e3667660SYonggang Luo  --enable-docs) docs="enabled"
125783a3ab8bSJuan Quintela  ;;
1258d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
1259d5970055SMichael S. Tsirkin  ;;
1260d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
1261d5970055SMichael S. Tsirkin  ;;
1262042cea27SGonglei  --disable-vhost-crypto) vhost_crypto="no"
1263042cea27SGonglei  ;;
1264299e6f19SPaolo Bonzini  --enable-vhost-crypto) vhost_crypto="yes"
1265042cea27SGonglei  ;;
12665e9be92dSNicholas Bellinger  --disable-vhost-scsi) vhost_scsi="no"
12675e9be92dSNicholas Bellinger  ;;
12685e9be92dSNicholas Bellinger  --enable-vhost-scsi) vhost_scsi="yes"
12695e9be92dSNicholas Bellinger  ;;
1270fc0b9b0eSStefan Hajnoczi  --disable-vhost-vsock) vhost_vsock="no"
1271fc0b9b0eSStefan Hajnoczi  ;;
1272fc0b9b0eSStefan Hajnoczi  --enable-vhost-vsock) vhost_vsock="yes"
1273fc0b9b0eSStefan Hajnoczi  ;;
1274e5e856c1SStefan Hajnoczi  --disable-vhost-user-blk-server) vhost_user_blk_server="disabled"
1275bc15e44cSStefan Hajnoczi  ;;
1276e5e856c1SStefan Hajnoczi  --enable-vhost-user-blk-server) vhost_user_blk_server="enabled"
1277bc15e44cSStefan Hajnoczi  ;;
127898fc1adaSDr. David Alan Gilbert  --disable-vhost-user-fs) vhost_user_fs="no"
127998fc1adaSDr. David Alan Gilbert  ;;
128098fc1adaSDr. David Alan Gilbert  --enable-vhost-user-fs) vhost_user_fs="yes"
128198fc1adaSDr. David Alan Gilbert  ;;
1282da076ffeSGerd Hoffmann  --disable-opengl) opengl="no"
128320ff075bSMichael Walle  ;;
1284da076ffeSGerd Hoffmann  --enable-opengl) opengl="yes"
128520ff075bSMichael Walle  ;;
1286fabd1e93SPaolo Bonzini  --disable-rbd) rbd="disabled"
1287f27aaf4bSChristian Brunner  ;;
1288fabd1e93SPaolo Bonzini  --enable-rbd) rbd="enabled"
1289f27aaf4bSChristian Brunner  ;;
12908c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
12918c84cf11SSergei Trofimovich  ;;
12928c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
12938c84cf11SSergei Trofimovich  ;;
12945f364c57SPaolo Bonzini  --disable-smartcard) smartcard="disabled"
1295111a38b0SRobert Relyea  ;;
12965f364c57SPaolo Bonzini  --enable-smartcard) smartcard="enabled"
1297111a38b0SRobert Relyea  ;;
12980a40bcb7SCésar Belley  --disable-u2f) u2f="disabled"
12990a40bcb7SCésar Belley  ;;
13000a40bcb7SCésar Belley  --enable-u2f) u2f="enabled"
13010a40bcb7SCésar Belley  ;;
130290540f32SPaolo Bonzini  --disable-libusb) libusb="disabled"
13032b2325ffSGerd Hoffmann  ;;
130490540f32SPaolo Bonzini  --enable-libusb) libusb="enabled"
13052b2325ffSGerd Hoffmann  ;;
130618f31e60SPaolo Bonzini  --disable-usb-redir) usb_redir="disabled"
130769354a83SHans de Goede  ;;
130818f31e60SPaolo Bonzini  --enable-usb-redir) usb_redir="enabled"
130969354a83SHans de Goede  ;;
13101ffb3bbbSPaolo Bonzini  --disable-zlib-test)
13111ece9905SAlon Levy  ;;
13120c32a0aeSPaolo Bonzini  --disable-lzo) lzo="disabled"
1313b25c9dffSStefan Weil  ;;
13140c32a0aeSPaolo Bonzini  --enable-lzo) lzo="enabled"
1315607dacd0Sqiaonuohan  ;;
1316241611eaSPaolo Bonzini  --disable-snappy) snappy="disabled"
1317b25c9dffSStefan Weil  ;;
1318241611eaSPaolo Bonzini  --enable-snappy) snappy="enabled"
1319607dacd0Sqiaonuohan  ;;
132029ba6116SPaolo Bonzini  --disable-bzip2) bzip2="disabled"
13216b383c08SPeter Wu  ;;
132229ba6116SPaolo Bonzini  --enable-bzip2) bzip2="enabled"
13236b383c08SPeter Wu  ;;
1324ecea3696SPaolo Bonzini  --enable-lzfse) lzfse="enabled"
132583bc1f97SJulio Faracco  ;;
1326ecea3696SPaolo Bonzini  --disable-lzfse) lzfse="disabled"
132783bc1f97SJulio Faracco  ;;
1328b1def33dSPaolo Bonzini  --disable-zstd) zstd="disabled"
13293a678481SJuan Quintela  ;;
1330b1def33dSPaolo Bonzini  --enable-zstd) zstd="enabled"
13313a678481SJuan Quintela  ;;
1332d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
1333d138cee9SMichael Roth  ;;
1334d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
1335d138cee9SMichael Roth  ;;
1336b846ab7cSPaolo Bonzini  --enable-guest-agent-msi) guest_agent_msi="enabled"
13379dacf32dSYossi Hindin  ;;
1338b846ab7cSPaolo Bonzini  --disable-guest-agent-msi) guest_agent_msi="disabled"
13399dacf32dSYossi Hindin  ;;
1340d9840e25STomoki Sekiyama  --with-vss-sdk) vss_win32_sdk=""
1341d9840e25STomoki Sekiyama  ;;
1342d9840e25STomoki Sekiyama  --with-vss-sdk=*) vss_win32_sdk="$optarg"
1343d9840e25STomoki Sekiyama  ;;
1344d9840e25STomoki Sekiyama  --without-vss-sdk) vss_win32_sdk="no"
1345d9840e25STomoki Sekiyama  ;;
1346d9840e25STomoki Sekiyama  --with-win-sdk) win_sdk=""
1347d9840e25STomoki Sekiyama  ;;
1348d9840e25STomoki Sekiyama  --with-win-sdk=*) win_sdk="$optarg"
1349d9840e25STomoki Sekiyama  ;;
1350d9840e25STomoki Sekiyama  --without-win-sdk) win_sdk="no"
1351d9840e25STomoki Sekiyama  ;;
13524b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
13534b1c11fdSDaniel P. Berrange  ;;
13544b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
13554b1c11fdSDaniel P. Berrange  ;;
135690835c2bSPaolo Bonzini  --enable-seccomp) seccomp="enabled"
1357f794573eSEduardo Otubo  ;;
135890835c2bSPaolo Bonzini  --disable-seccomp) seccomp="disabled"
1359f794573eSEduardo Otubo  ;;
136008821ca2SPaolo Bonzini  --disable-glusterfs) glusterfs="disabled"
1361eb100396SBharata B Rao  ;;
136286583a07SLiam Merwick  --disable-avx2) avx2_opt="no"
136386583a07SLiam Merwick  ;;
136486583a07SLiam Merwick  --enable-avx2) avx2_opt="yes"
136586583a07SLiam Merwick  ;;
13666b8cd447SRobert Hoo  --disable-avx512f) avx512f_opt="no"
13676b8cd447SRobert Hoo  ;;
13686b8cd447SRobert Hoo  --enable-avx512f) avx512f_opt="yes"
13696b8cd447SRobert Hoo  ;;
13706b8cd447SRobert Hoo
137108821ca2SPaolo Bonzini  --enable-glusterfs) glusterfs="enabled"
1372eb100396SBharata B Rao  ;;
137352b53c04SFam Zheng  --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
137452b53c04SFam Zheng      echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1375583f6e7bSStefan Hajnoczi  ;;
1376cb6414dfSFam Zheng  --enable-vhdx|--disable-vhdx)
1377cb6414dfSFam Zheng      echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1378cb6414dfSFam Zheng  ;;
1379315d3184SFam Zheng  --enable-uuid|--disable-uuid)
1380315d3184SFam Zheng      echo "$0: $opt is obsolete, UUID support is always built" >&2
1381315d3184SFam Zheng  ;;
13821b695471SPaolo Bonzini  --disable-gtk) gtk="disabled"
1383a4ccabcfSAnthony Liguori  ;;
13841b695471SPaolo Bonzini  --enable-gtk) gtk="enabled"
1385a4ccabcfSAnthony Liguori  ;;
1386a1c5e949SDaniel P. Berrange  --tls-priority=*) tls_priority="$optarg"
1387a1c5e949SDaniel P. Berrange  ;;
138857612511SPaolo Bonzini  --disable-gnutls) gnutls="disabled"
1389ddbb0d09SDaniel P. Berrange  ;;
139057612511SPaolo Bonzini  --enable-gnutls) gnutls="enabled"
1391ddbb0d09SDaniel P. Berrange  ;;
139257612511SPaolo Bonzini  --disable-nettle) nettle="disabled"
139391bfcdb0SDaniel P. Berrange  ;;
139457612511SPaolo Bonzini  --enable-nettle) nettle="enabled"
139591bfcdb0SDaniel P. Berrange  ;;
139657612511SPaolo Bonzini  --disable-gcrypt) gcrypt="disabled"
139791bfcdb0SDaniel P. Berrange  ;;
139857612511SPaolo Bonzini  --enable-gcrypt) gcrypt="enabled"
139991bfcdb0SDaniel P. Berrange  ;;
140005e391aeSPaolo Bonzini  --disable-auth-pam) auth_pam="disabled"
14018953caf3SDaniel P. Berrange  ;;
140205e391aeSPaolo Bonzini  --enable-auth-pam) auth_pam="enabled"
14038953caf3SDaniel P. Berrange  ;;
14042da776dbSMichael R. Hines  --enable-rdma) rdma="yes"
14052da776dbSMichael R. Hines  ;;
14062da776dbSMichael R. Hines  --disable-rdma) rdma="no"
14072da776dbSMichael R. Hines  ;;
140821ab34c9SMarcel Apfelbaum  --enable-pvrdma) pvrdma="yes"
140921ab34c9SMarcel Apfelbaum  ;;
141021ab34c9SMarcel Apfelbaum  --disable-pvrdma) pvrdma="no"
141121ab34c9SMarcel Apfelbaum  ;;
1412c23d7b4eSPaolo Bonzini  --disable-vte) vte="disabled"
1413bbbf9bfbSStefan Weil  ;;
1414c23d7b4eSPaolo Bonzini  --enable-vte) vte="enabled"
1415bbbf9bfbSStefan Weil  ;;
1416587d59d6SPaolo Bonzini  --disable-virglrenderer) virglrenderer="disabled"
14179d9e1521SGerd Hoffmann  ;;
1418587d59d6SPaolo Bonzini  --enable-virglrenderer) virglrenderer="enabled"
14199d9e1521SGerd Hoffmann  ;;
1420e91c793cSCole Robinson  --disable-tpm) tpm="no"
1421e91c793cSCole Robinson  ;;
1422ab214c29SStefan Berger  --enable-tpm) tpm="yes"
1423ab214c29SStefan Berger  ;;
1424b10d49d7SPino Toscano  --disable-libssh) libssh="no"
14250a12ec87SRichard W.M. Jones  ;;
1426b10d49d7SPino Toscano  --enable-libssh) libssh="yes"
14270a12ec87SRichard W.M. Jones  ;;
1428ed1701c6SDr. David Alan Gilbert  --disable-live-block-migration) live_block_migration="no"
1429ed1701c6SDr. David Alan Gilbert  ;;
1430ed1701c6SDr. David Alan Gilbert  --enable-live-block-migration) live_block_migration="yes"
1431ed1701c6SDr. David Alan Gilbert  ;;
1432a99d57bbSWanlong Gao  --disable-numa) numa="no"
1433a99d57bbSWanlong Gao  ;;
1434a99d57bbSWanlong Gao  --enable-numa) numa="yes"
1435a99d57bbSWanlong Gao  ;;
1436c5b36c25SPaolo Bonzini  --disable-libxml2) libxml2="disabled"
1437ed279a06SKlim Kireev  ;;
1438c5b36c25SPaolo Bonzini  --enable-libxml2) libxml2="enabled"
1439ed279a06SKlim Kireev  ;;
14402847b469SFam Zheng  --disable-tcmalloc) tcmalloc="no"
14412847b469SFam Zheng  ;;
14422847b469SFam Zheng  --enable-tcmalloc) tcmalloc="yes"
14432847b469SFam Zheng  ;;
14447b01cb97SAlexandre Derumier  --disable-jemalloc) jemalloc="no"
14457b01cb97SAlexandre Derumier  ;;
14467b01cb97SAlexandre Derumier  --enable-jemalloc) jemalloc="yes"
14477b01cb97SAlexandre Derumier  ;;
1448a6b1d4c0SChanglong Xie  --disable-replication) replication="no"
1449a6b1d4c0SChanglong Xie  ;;
1450a6b1d4c0SChanglong Xie  --enable-replication) replication="yes"
1451a6b1d4c0SChanglong Xie  ;;
14522f740136SJeff Cody  --disable-bochs) bochs="no"
14532f740136SJeff Cody  ;;
14542f740136SJeff Cody  --enable-bochs) bochs="yes"
14552f740136SJeff Cody  ;;
14562f740136SJeff Cody  --disable-cloop) cloop="no"
14572f740136SJeff Cody  ;;
14582f740136SJeff Cody  --enable-cloop) cloop="yes"
14592f740136SJeff Cody  ;;
14602f740136SJeff Cody  --disable-dmg) dmg="no"
14612f740136SJeff Cody  ;;
14622f740136SJeff Cody  --enable-dmg) dmg="yes"
14632f740136SJeff Cody  ;;
14642f740136SJeff Cody  --disable-qcow1) qcow1="no"
14652f740136SJeff Cody  ;;
14662f740136SJeff Cody  --enable-qcow1) qcow1="yes"
14672f740136SJeff Cody  ;;
14682f740136SJeff Cody  --disable-vdi) vdi="no"
14692f740136SJeff Cody  ;;
14702f740136SJeff Cody  --enable-vdi) vdi="yes"
14712f740136SJeff Cody  ;;
14722f740136SJeff Cody  --disable-vvfat) vvfat="no"
14732f740136SJeff Cody  ;;
14742f740136SJeff Cody  --enable-vvfat) vvfat="yes"
14752f740136SJeff Cody  ;;
14762f740136SJeff Cody  --disable-qed) qed="no"
14772f740136SJeff Cody  ;;
14782f740136SJeff Cody  --enable-qed) qed="yes"
14792f740136SJeff Cody  ;;
14802f740136SJeff Cody  --disable-parallels) parallels="no"
14812f740136SJeff Cody  ;;
14822f740136SJeff Cody  --enable-parallels) parallels="yes"
14832f740136SJeff Cody  ;;
1484e6a74868SMarc-André Lureau  --disable-vhost-user) vhost_user="no"
1485e6a74868SMarc-André Lureau  ;;
1486299e6f19SPaolo Bonzini  --enable-vhost-user) vhost_user="yes"
1487299e6f19SPaolo Bonzini  ;;
1488108a6481SCindy Lu  --disable-vhost-vdpa) vhost_vdpa="no"
1489108a6481SCindy Lu  ;;
1490108a6481SCindy Lu  --enable-vhost-vdpa) vhost_vdpa="yes"
1491108a6481SCindy Lu  ;;
1492299e6f19SPaolo Bonzini  --disable-vhost-kernel) vhost_kernel="no"
1493299e6f19SPaolo Bonzini  ;;
1494299e6f19SPaolo Bonzini  --enable-vhost-kernel) vhost_kernel="yes"
1495e6a74868SMarc-André Lureau  ;;
14968b18cdbfSRichard Henderson  --disable-capstone) capstone="disabled"
14978ca80760SRichard Henderson  ;;
14988b18cdbfSRichard Henderson  --enable-capstone) capstone="enabled"
14998ca80760SRichard Henderson  ;;
15008b18cdbfSRichard Henderson  --enable-capstone=git) capstone="internal"
1501e219c499SRichard Henderson  ;;
1502e219c499SRichard Henderson  --enable-capstone=system) capstone="system"
1503e219c499SRichard Henderson  ;;
1504cc84d63aSDaniel P. Berrange  --with-git=*) git="$optarg"
1505cc84d63aSDaniel P. Berrange  ;;
15067d7dbf9dSDan Streetman  --enable-git-update)
15077d7dbf9dSDan Streetman      git_submodules_action="update"
15087d7dbf9dSDan Streetman      echo "--enable-git-update deprecated, use --with-git-submodules=update"
1509f62bbee5SDaniel P. Berrange  ;;
15107d7dbf9dSDan Streetman  --disable-git-update)
15117d7dbf9dSDan Streetman      git_submodules_action="validate"
15127d7dbf9dSDan Streetman      echo "--disable-git-update deprecated, use --with-git-submodules=validate"
15137d7dbf9dSDan Streetman  ;;
15147d7dbf9dSDan Streetman  --with-git-submodules=*)
15157d7dbf9dSDan Streetman      git_submodules_action="$optarg"
1516f62bbee5SDaniel P. Berrange  ;;
1517ba59fb77SPaolo Bonzini  --enable-debug-mutex) debug_mutex=yes
1518ba59fb77SPaolo Bonzini  ;;
1519ba59fb77SPaolo Bonzini  --disable-debug-mutex) debug_mutex=no
1520ba59fb77SPaolo Bonzini  ;;
15215cd5d8a7SMiroslav Rezanina  --enable-libpmem) libpmem="enabled"
152217824406SJunyan He  ;;
15235cd5d8a7SMiroslav Rezanina  --disable-libpmem) libpmem="disabled"
152417824406SJunyan He  ;;
15254113f4cfSLaurent Vivier  --enable-xkbcommon) xkbcommon="enabled"
152675411919SJames Le Cuirot  ;;
15274113f4cfSLaurent Vivier  --disable-xkbcommon) xkbcommon="disabled"
152875411919SJames Le Cuirot  ;;
15299b8e4298SAlex Bennée  --enable-plugins) if test "$mingw32" = "yes"; then
15309b8e4298SAlex Bennée                        error_exit "TCG plugins not currently supported on Windows platforms"
15319b8e4298SAlex Bennée                    else
15329b8e4298SAlex Bennée                        plugins="yes"
15339b8e4298SAlex Bennée                    fi
153440e8c6f4SAlex Bennée  ;;
153540e8c6f4SAlex Bennée  --disable-plugins) plugins="no"
153640e8c6f4SAlex Bennée  ;;
1537afc3a8f9SAlex Bennée  --enable-containers) use_containers="yes"
1538afc3a8f9SAlex Bennée  ;;
1539afc3a8f9SAlex Bennée  --disable-containers) use_containers="no"
1540afc3a8f9SAlex Bennée  ;;
1541adc28027SAlexander Bulekov  --enable-fuzzing) fuzzing=yes
1542adc28027SAlexander Bulekov  ;;
1543adc28027SAlexander Bulekov  --disable-fuzzing) fuzzing=no
1544adc28027SAlexander Bulekov  ;;
1545f48e590aSAlex Bennée  --gdb=*) gdb_bin="$optarg"
1546f48e590aSAlex Bennée  ;;
1547b767d257SMarek Marczykowski-Górecki  --enable-rng-none) rng_none=yes
1548b767d257SMarek Marczykowski-Górecki  ;;
1549b767d257SMarek Marczykowski-Górecki  --disable-rng-none) rng_none=no
1550b767d257SMarek Marczykowski-Górecki  ;;
155154e7aac0SAlexey Krasikov  --enable-keyring) secret_keyring="yes"
155254e7aac0SAlexey Krasikov  ;;
155354e7aac0SAlexey Krasikov  --disable-keyring) secret_keyring="no"
155454e7aac0SAlexey Krasikov  ;;
155512033e16SMiroslav Rezanina  --enable-libdaxctl) libdaxctl="enabled"
155621b2eca6SJingqi Liu  ;;
155712033e16SMiroslav Rezanina  --disable-libdaxctl) libdaxctl="disabled"
155821b2eca6SJingqi Liu  ;;
1559a484a719SMax Reitz  --enable-fuse) fuse="enabled"
1560a484a719SMax Reitz  ;;
1561a484a719SMax Reitz  --disable-fuse) fuse="disabled"
1562a484a719SMax Reitz  ;;
1563df4ea709SMax Reitz  --enable-fuse-lseek) fuse_lseek="enabled"
1564df4ea709SMax Reitz  ;;
1565df4ea709SMax Reitz  --disable-fuse-lseek) fuse_lseek="disabled"
1566df4ea709SMax Reitz  ;;
1567106ad1f9SPaolo Bonzini  --enable-multiprocess) multiprocess="enabled"
15683090de69SJagannathan Raman  ;;
1569106ad1f9SPaolo Bonzini  --disable-multiprocess) multiprocess="disabled"
15703090de69SJagannathan Raman  ;;
157120cf7b8eSDenis Plotnikov  --enable-gio) gio=yes
157220cf7b8eSDenis Plotnikov  ;;
157320cf7b8eSDenis Plotnikov  --disable-gio) gio=no
157420cf7b8eSDenis Plotnikov  ;;
1575b8e0c493SJoelle van Dyne  --enable-slirp-smbd) slirp_smbd=yes
1576b8e0c493SJoelle van Dyne  ;;
1577b8e0c493SJoelle van Dyne  --disable-slirp-smbd) slirp_smbd=no
1578b8e0c493SJoelle van Dyne  ;;
15792d2ad6d0SFam Zheng  *)
15802d2ad6d0SFam Zheng      echo "ERROR: unknown option $opt"
15812d2ad6d0SFam Zheng      echo "Try '$0 --help' for more information"
15822d2ad6d0SFam Zheng      exit 1
15837f1559c6Sbalrog  ;;
15847d13299dSbellard  esac
15857d13299dSbellarddone
15867d13299dSbellard
1587d1a14257SAlex Bennée# test for any invalid configuration combinations
1588d1a14257SAlex Bennéeif test "$plugins" = "yes" -a "$tcg" = "disabled"; then
1589d1a14257SAlex Bennée    error_exit "Can't enable plugins on non-TCG builds"
1590d1a14257SAlex Bennéefi
1591d1a14257SAlex Bennée
15927d7dbf9dSDan Streetmancase $git_submodules_action in
15937d7dbf9dSDan Streetman    update|validate)
15947d7dbf9dSDan Streetman        if test ! -e "$source_path/.git"; then
15957d7dbf9dSDan Streetman            echo "ERROR: cannot $git_submodules_action git submodules without .git"
15967d7dbf9dSDan Streetman            exit 1
15977d7dbf9dSDan Streetman        fi
15987d7dbf9dSDan Streetman    ;;
15997d7dbf9dSDan Streetman    ignore)
1600b80fd281SPaolo Bonzini        if ! test -f "$source_path/ui/keycodemapdb/README"
1601b80fd281SPaolo Bonzini        then
1602b80fd281SPaolo Bonzini            echo
1603b80fd281SPaolo Bonzini            echo "ERROR: missing GIT submodules"
1604b80fd281SPaolo Bonzini            echo
1605b80fd281SPaolo Bonzini            if test -e "$source_path/.git"; then
1606b80fd281SPaolo Bonzini                echo "--with-git-submodules=ignore specified but submodules were not"
1607b80fd281SPaolo Bonzini                echo "checked out.  Please initialize and update submodules."
1608b80fd281SPaolo Bonzini            else
1609b80fd281SPaolo Bonzini                echo "This is not a GIT checkout but module content appears to"
1610b80fd281SPaolo Bonzini                echo "be missing. Do not use 'git archive' or GitHub download links"
1611b80fd281SPaolo Bonzini                echo "to acquire QEMU source archives. Non-GIT builds are only"
1612b80fd281SPaolo Bonzini                echo "supported with source archives linked from:"
1613b80fd281SPaolo Bonzini                echo
1614b80fd281SPaolo Bonzini                echo "  https://www.qemu.org/download/#source"
1615b80fd281SPaolo Bonzini                echo
1616b80fd281SPaolo Bonzini                echo "Developers working with GIT can use scripts/archive-source.sh"
1617b80fd281SPaolo Bonzini                echo "if they need to create valid source archives."
1618b80fd281SPaolo Bonzini            fi
1619b80fd281SPaolo Bonzini            echo
1620b80fd281SPaolo Bonzini            exit 1
1621b80fd281SPaolo Bonzini        fi
16227d7dbf9dSDan Streetman    ;;
16237d7dbf9dSDan Streetman    *)
16247d7dbf9dSDan Streetman        echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'"
16257d7dbf9dSDan Streetman        exit 1
16267d7dbf9dSDan Streetman    ;;
16277d7dbf9dSDan Streetmanesac
16287d7dbf9dSDan Streetman
162922a87800SMarc-André Lureaulibdir="${libdir:-$prefix/lib}"
163022a87800SMarc-André Lureaulibexecdir="${libexecdir:-$prefix/libexec}"
163122a87800SMarc-André Lureauincludedir="${includedir:-$prefix/include}"
163222a87800SMarc-André Lureau
163322a87800SMarc-André Lureauif test "$mingw32" = "yes" ; then
163415588a62SJoshua Watt    bindir="${bindir:-$prefix}"
163522a87800SMarc-André Lureauelse
163615588a62SJoshua Watt    bindir="${bindir:-$prefix/bin}"
163715588a62SJoshua Wattfi
163822a87800SMarc-André Lureaumandir="${mandir:-$prefix/share/man}"
163922a87800SMarc-André Lureaudatadir="${datadir:-$prefix/share}"
1640ca8c0909SMarc-André Lureaudocdir="${docdir:-$prefix/share/doc}"
164122a87800SMarc-André Lureausysconfdir="${sysconfdir:-$prefix/etc}"
164222a87800SMarc-André Lureaulocal_statedir="${local_statedir:-$prefix/var}"
164316bf7a33SPaolo Bonzinifirmwarepath="${firmwarepath:-$datadir/qemu-firmware}"
164416bf7a33SPaolo Bonzinilocaledir="${localedir:-$datadir/locale}"
164522a87800SMarc-André Lureau
164640293e58Sbellardcase "$cpu" in
1647e3608d66SRichard Henderson    ppc)
1648e3608d66SRichard Henderson           CPU_CFLAGS="-m32"
1649db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m32 $QEMU_LDFLAGS"
1650e3608d66SRichard Henderson           ;;
1651e3608d66SRichard Henderson    ppc64)
1652e3608d66SRichard Henderson           CPU_CFLAGS="-m64"
1653db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
1654e3608d66SRichard Henderson           ;;
16559b9c37c3SRichard Henderson    sparc)
1656f1079bb8SRichard Henderson           CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
1657db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m32 -mv8plus $QEMU_LDFLAGS"
16583142255cSblueswir1           ;;
1659ed968ff1SJuan Quintela    sparc64)
166079f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1661db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
16623142255cSblueswir1           ;;
166376d83bdeSths    s390)
1664061cdd81SRichard Henderson           CPU_CFLAGS="-m31"
1665db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m31 $QEMU_LDFLAGS"
166628d7cc49SRichard Henderson           ;;
166728d7cc49SRichard Henderson    s390x)
1668061cdd81SRichard Henderson           CPU_CFLAGS="-m64"
1669db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
167076d83bdeSths           ;;
167140293e58Sbellard    i386)
167279f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32"
1673db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m32 $QEMU_LDFLAGS"
167440293e58Sbellard           ;;
167540293e58Sbellard    x86_64)
16767ebee43eSRichard Henderson           # ??? Only extremely old AMD cpus do not have cmpxchg16b.
16777ebee43eSRichard Henderson           # If we truly care, we should simply detect this case at
16787ebee43eSRichard Henderson           # runtime and generate the fallback to serial emulation.
16797ebee43eSRichard Henderson           CPU_CFLAGS="-m64 -mcx16"
1680db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
1681379f6698SPaul Brook           ;;
1682c72b26ecSRichard Henderson    x32)
1683c72b26ecSRichard Henderson           CPU_CFLAGS="-mx32"
1684db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-mx32 $QEMU_LDFLAGS"
1685c72b26ecSRichard Henderson           ;;
168630163d89SPeter Maydell    # No special flags required for other host CPUs
16873142255cSblueswir1esac
16883142255cSblueswir1
16899557af9cSAlex Bennéeif eval test -z "\${cross_cc_$cpu}"; then
1690b1aa4de1SAlex Bennée    eval "cross_cc_${cpu}=\$cc"
16912038f8c8SPaolo Bonzini    cross_cc_vars="$cross_cc_vars cross_cc_${cpu}"
16929557af9cSAlex Bennéefi
169379f3b12fSPeter Crosthwaite
1694affc88ccSPeter Maydell# For user-mode emulation the host arch has to be one we explicitly
1695affc88ccSPeter Maydell# support, even if we're using TCI.
1696affc88ccSPeter Maydellif [ "$ARCH" = "unknown" ]; then
1697affc88ccSPeter Maydell  bsd_user="no"
1698affc88ccSPeter Maydell  linux_user="no"
1699affc88ccSPeter Maydellfi
1700affc88ccSPeter Maydell
170160e0df25SPeter Maydelldefault_target_list=""
170243692239SMarkus Armbrusterdeprecated_targets_list=ppc64abi32-linux-user
1703fdb75aefSPaolo Bonzinideprecated_features=""
17046e92f823SPeter Maydellmak_wilds=""
17056e92f823SPeter Maydell
170660e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then
1707812b31d3SAlex Bennée    mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak"
170860e0df25SPeter Maydellfi
170960e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then
1710812b31d3SAlex Bennée    mak_wilds="${mak_wilds} $source_path/configs/targets/*-linux-user.mak"
171160e0df25SPeter Maydellfi
171260e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then
1713812b31d3SAlex Bennée    mak_wilds="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak"
171460e0df25SPeter Maydellfi
171560e0df25SPeter Maydell
17163a5ae4a9SAlex Bennée# If the user doesn't explicitly specify a deprecated target we will
17173a5ae4a9SAlex Bennée# skip it.
17183a5ae4a9SAlex Bennéeif test -z "$target_list"; then
17193a5ae4a9SAlex Bennée    if test -z "$target_list_exclude"; then
17203a5ae4a9SAlex Bennée        target_list_exclude="$deprecated_targets_list"
17213a5ae4a9SAlex Bennée    else
17223a5ae4a9SAlex Bennée        target_list_exclude="$target_list_exclude,$deprecated_targets_list"
17233a5ae4a9SAlex Bennée    fi
17242d838d9bSAlex Bennéefi
17252d838d9bSAlex Bennée
1726447e133fSAlex Bennéefor config in $mak_wilds; do
1727447e133fSAlex Bennée    target="$(basename "$config" .mak)"
172898db9a06SAlex Bennée    if echo "$target_list_exclude" | grep -vq "$target"; then
1729447e133fSAlex Bennée        default_target_list="${default_target_list} $target"
1730447e133fSAlex Bennée    fi
1731447e133fSAlex Bennéedone
17326e92f823SPeter Maydell
1733c53eeaf7SStefan Hajnoczi# Enumerate public trace backends for --help output
173464a6047dSGreg Kurztrace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
1735c53eeaf7SStefan Hajnoczi
1736af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1737af5db58eSpbrookcat << EOF
1738af5db58eSpbrook
1739af5db58eSpbrookUsage: configure [options]
1740af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1741af5db58eSpbrook
174208fb77edSStefan WeilStandard options:
174308fb77edSStefan Weil  --help                   print this message
174408fb77edSStefan Weil  --prefix=PREFIX          install in PREFIX [$prefix]
174508fb77edSStefan Weil  --interp-prefix=PREFIX   where to find shared libraries, etc.
174608fb77edSStefan Weil                           use %M for cpu name [$interp_prefix]
17472deca810SAlex Bennée  --target-list=LIST       set target list (default: build all non-deprecated)
174808fb77edSStefan Weil$(echo Available targets: $default_target_list | \
174908fb77edSStefan Weil  fold -s -w 53 | sed -e 's/^/                           /')
17502deca810SAlex Bennée$(echo Deprecated targets: $deprecated_targets_list | \
17512deca810SAlex Bennée  fold -s -w 53 | sed -e 's/^/                           /')
1752447e133fSAlex Bennée  --target-list-exclude=LIST exclude a set of targets from the default target-list
175308fb77edSStefan Weil
175408fb77edSStefan WeilAdvanced options (experts only):
17553812c0c4SJoelle van Dyne  --cross-prefix=PREFIX    use PREFIX for compile tools, PREFIX can be blank [$cross_prefix]
175608fb77edSStefan Weil  --cc=CC                  use C compiler CC [$cc]
175708fb77edSStefan Weil  --iasl=IASL              use ACPI compiler IASL [$iasl]
175808fb77edSStefan Weil  --host-cc=CC             use C compiler CC [$host_cc] for code run at
175908fb77edSStefan Weil                           build time
176008fb77edSStefan Weil  --cxx=CXX                use C++ compiler CXX [$cxx]
176108fb77edSStefan Weil  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]
176208fb77edSStefan Weil  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS
176311cde1c8SBruno Dominguez  --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
176408fb77edSStefan Weil  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
1765d75402b5SAlex Bennée  --cross-cc-ARCH=CC       use compiler when building ARCH guest test cases
1766d422b2bcSAlex Bennée  --cross-cc-flags-ARCH=   use compiler flags when building ARCH guest tests
176708fb77edSStefan Weil  --make=MAKE              use specified make [$make]
176808fb77edSStefan Weil  --python=PYTHON          use specified python [$python]
17692eb054c2SPeter Maydell  --sphinx-build=SPHINX    use specified sphinx-build [$sphinx_build]
1770a5665051SPaolo Bonzini  --meson=MESON            use specified meson [$meson]
177148328880SPaolo Bonzini  --ninja=NINJA            use specified ninja [$ninja]
177208fb77edSStefan Weil  --smbd=SMBD              use specified smbd [$smbd]
1773db1b5f13SThomas Huth  --with-git=GIT           use specified git [$git]
17747d7dbf9dSDan Streetman  --with-git-submodules=update   update git submodules (default if .git dir exists)
17757d7dbf9dSDan Streetman  --with-git-submodules=validate fail if git submodules are not up to date
17767d7dbf9dSDan Streetman  --with-git-submodules=ignore   do not update or check git submodules (default if no .git dir)
177708fb77edSStefan Weil  --static                 enable static build [$static]
177808fb77edSStefan Weil  --mandir=PATH            install man pages in PATH
177910ff82d1SMarc-André Lureau  --datadir=PATH           install firmware in PATH/$qemu_suffix
1780fe0038beSPaolo Bonzini  --localedir=PATH         install translation in PATH/$qemu_suffix
178110ff82d1SMarc-André Lureau  --docdir=PATH            install documentation in PATH/$qemu_suffix
178208fb77edSStefan Weil  --bindir=PATH            install binaries in PATH
178308fb77edSStefan Weil  --libdir=PATH            install libraries in PATH
1784db1b5f13SThomas Huth  --libexecdir=PATH        install helper binaries in PATH
178510ff82d1SMarc-André Lureau  --sysconfdir=PATH        install config in PATH/$qemu_suffix
178608fb77edSStefan Weil  --localstatedir=PATH     install local state in PATH (set at runtime on win32)
17873d5eecabSGerd Hoffmann  --firmwarepath=PATH      search PATH for firmware files
178813336606SRobert Foley  --efi-aarch64=PATH       PATH of efi file to use for aarch64 VMs.
1789ca8c0909SMarc-André Lureau  --with-suffix=SUFFIX     suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix]
1790db1b5f13SThomas Huth  --with-pkgversion=VERS   use specified string as sub-version of the package
1791c035c8d6SPaolo Bonzini  --without-default-features default all --enable-* options to "disabled"
1792c035c8d6SPaolo Bonzini  --without-default-devices  do not include any device that is not needed to
1793c035c8d6SPaolo Bonzini                           start the emulator (only use if you are including
1794d1d5e9eeSAlex Bennée                           desired devices in configs/devices/)
1795d1d5e9eeSAlex Bennée  --with-devices-ARCH=NAME override default configs/devices
179608fb77edSStefan Weil  --enable-debug           enable common debug build options
1797247724cbSMarc-André Lureau  --enable-sanitizers      enable default sanitizers
17980aebab04SLingfeng Yang  --enable-tsan            enable thread sanitizer
179908fb77edSStefan Weil  --disable-strip          disable stripping binaries
180008fb77edSStefan Weil  --disable-werror         disable compilation abort on warning
180163678e17SSteven Noonan  --disable-stack-protector disable compiler-provided stack protection
180287430d5bSPaolo Bonzini  --audio-drv-list=LIST    set audio drivers list
180308fb77edSStefan Weil  --block-drv-whitelist=L  Same as --block-drv-rw-whitelist=L
180408fb77edSStefan Weil  --block-drv-rw-whitelist=L
180508fb77edSStefan Weil                           set block driver read-write whitelist
1806e5f05f8cSKevin Wolf                           (by default affects only QEMU, not tools like qemu-img)
180708fb77edSStefan Weil  --block-drv-ro-whitelist=L
180808fb77edSStefan Weil                           set block driver read-only whitelist
1809e5f05f8cSKevin Wolf                           (by default affects only QEMU, not tools like qemu-img)
1810e5f05f8cSKevin Wolf  --enable-block-drv-whitelist-in-tools
1811e5f05f8cSKevin Wolf                           use block whitelist also in tools instead of only QEMU
18125b808275SLluís Vilanova  --enable-trace-backends=B Set trace backend
1813c53eeaf7SStefan Hajnoczi                           Available backends: $trace_backend_list
181408fb77edSStefan Weil  --with-trace-file=NAME   Full PATH,NAME of file to store traces
181508fb77edSStefan Weil                           Default:trace-<pid>
1816c23f23b9SMichael Tokarev  --disable-slirp          disable SLIRP userspace network connectivity
1817e9a16e38SPhilippe Mathieu-Daudé  --enable-tcg-interpreter enable TCI (TCG with bytecode interpreter, experimental and slow)
18185a22ab71SYang Zhong  --enable-malloc-trim     enable libc malloc_trim() for memory optimization
1819c23f23b9SMichael Tokarev  --cpu=CPU                Build for host CPU [$cpu]
182008fb77edSStefan Weil  --with-coroutine=BACKEND coroutine backend. Supported options:
182133c53c54SDaniel P. Berrange                           ucontext, sigaltstack, windows
182208fb77edSStefan Weil  --enable-gcov            enable test coverage analysis with gcov
1823c23f23b9SMichael Tokarev  --disable-blobs          disable installing provided firmware blobs
1824c23f23b9SMichael Tokarev  --with-vss-sdk=SDK-path  enable Windows VSS support in QEMU Guest Agent
1825c23f23b9SMichael Tokarev  --with-win-sdk=SDK-path  path to Windows Platform SDK (to build VSS .tlb)
1826a1c5e949SDaniel P. Berrange  --tls-priority           default TLS protocol/cipher priority string
1827c12d66aaSLin Ma  --enable-gprof           QEMU profiling with gprof
1828c12d66aaSLin Ma  --enable-profiler        profiler support
1829c12d66aaSLin Ma  --enable-debug-stack-usage
1830c12d66aaSLin Ma                           track the maximum stack usage of stacks created by qemu_alloc_stack
183140e8c6f4SAlex Bennée  --enable-plugins
183240e8c6f4SAlex Bennée                           enable plugins via shared library loading
1833afc3a8f9SAlex Bennée  --disable-containers     don't use containers for cross-building
1834f48e590aSAlex Bennée  --gdb=GDB-path           gdb to use for gdbstub tests [$gdb_bin]
1835c23f23b9SMichael Tokarev
1836c23f23b9SMichael TokarevOptional features, enabled with --enable-FEATURE and
1837c87ea116SAlex Bennéedisabled with --disable-FEATURE, default is enabled if available
1838c87ea116SAlex Bennée(unless built with --without-default-features):
1839c23f23b9SMichael Tokarev
1840c23f23b9SMichael Tokarev  system          all system emulation targets
1841c23f23b9SMichael Tokarev  user            supported user emulation targets
1842c23f23b9SMichael Tokarev  linux-user      all linux usermode emulation targets
1843c23f23b9SMichael Tokarev  bsd-user        all BSD usermode emulation targets
1844c23f23b9SMichael Tokarev  docs            build documentation
1845c23f23b9SMichael Tokarev  guest-agent     build the QEMU Guest Agent
1846c23f23b9SMichael Tokarev  guest-agent-msi build guest agent Windows MSI installation package
1847c23f23b9SMichael Tokarev  pie             Position Independent Executables
184821e709aaSMarc-André Lureau  modules         modules support (non-Windows)
1849bd83c861SChristian Ehrhardt  module-upgrades try to load modules from alternate paths for upgrades
1850c23f23b9SMichael Tokarev  debug-tcg       TCG debugging (default is disabled)
1851c23f23b9SMichael Tokarev  debug-info      debugging information
1852cdad781dSDaniele Buono  lto             Enable Link-Time Optimization.
1853c23f23b9SMichael Tokarev  sparse          sparse checker
18541e4f6065SDaniele Buono  safe-stack      SafeStack Stack Smash Protection. Depends on
18551e4f6065SDaniele Buono                  clang/llvm >= 3.7 and requires coroutine backend ucontext.
18569e62ba48SDaniele Buono  cfi             Enable Control-Flow Integrity for indirect function calls.
18579e62ba48SDaniele Buono                  In case of a cfi violation, QEMU is terminated with SIGILL
18589e62ba48SDaniele Buono                  Depends on lto and is incompatible with modules
18599e62ba48SDaniele Buono                  Automatically enables Link-Time Optimization (lto)
18609e62ba48SDaniele Buono  cfi-debug       In case of a cfi violation, a message containing the line that
18619e62ba48SDaniele Buono                  triggered the error is written to stderr. After the error,
18629e62ba48SDaniele Buono                  QEMU is still terminated with SIGILL
1863ddbb0d09SDaniel P. Berrange  gnutls          GNUTLS cryptography support
186491bfcdb0SDaniel P. Berrange  nettle          nettle cryptography support
186591bfcdb0SDaniel P. Berrange  gcrypt          libgcrypt cryptography support
18668953caf3SDaniel P. Berrange  auth-pam        PAM access control
1867c23f23b9SMichael Tokarev  sdl             SDL UI
186804c6e16fSMarkus Armbruster  sdl-image       SDL Image support for icons
1869c23f23b9SMichael Tokarev  gtk             gtk UI
1870c23f23b9SMichael Tokarev  vte             vte support for the gtk UI
1871c23f23b9SMichael Tokarev  curses          curses UI
1872e08bb301SSamuel Thibault  iconv           font glyph conversion support
1873c23f23b9SMichael Tokarev  vnc             VNC UI support
1874c23f23b9SMichael Tokarev  vnc-sasl        SASL encryption for VNC server
1875c23f23b9SMichael Tokarev  vnc-jpeg        JPEG lossy compression for VNC server
1876c23f23b9SMichael Tokarev  vnc-png         PNG compression for VNC server
1877c23f23b9SMichael Tokarev  cocoa           Cocoa UI (Mac OS X only)
1878c23f23b9SMichael Tokarev  virtfs          VirtFS
1879cece116cSMisono Tomohiro  virtiofsd       build virtiofs daemon (virtiofsd)
18805c53015aSPaolo Bonzini  libudev         Use libudev to enumerate host devices
1881fe8fc5aeSPaolo Bonzini  mpath           Multipath persistent reservation passthrough
1882c23f23b9SMichael Tokarev  xen             xen backend driver support
188370c292afSAnthony PERARD  xen-pci-passthrough    PCI passthrough support for Xen
1884*ca50e523SPaolo Bonzini  alsa            ALSA sound support
1885*ca50e523SPaolo Bonzini  coreaudio       CoreAudio sound support
1886*ca50e523SPaolo Bonzini  dsound          DirectSound sound support
1887*ca50e523SPaolo Bonzini  jack            JACK sound support
1888*ca50e523SPaolo Bonzini  oss             OSS sound support
1889*ca50e523SPaolo Bonzini  pa              PulseAudio sound support
1890c23f23b9SMichael Tokarev  brlapi          BrlAPI (Braile)
1891c23f23b9SMichael Tokarev  curl            curl connectivity
1892a40161cbSPaolo Bonzini  membarrier      membarrier system call (for Linux 4.14+ or Windows)
1893c23f23b9SMichael Tokarev  fdt             fdt device tree
1894c23f23b9SMichael Tokarev  kvm             KVM acceleration support
1895b0cb0a66SVincent Palatin  hax             HAX acceleration support
1896c97d6d2cSSergio Andres Gomez Del Real  hvf             Hypervisor.framework acceleration support
189774a414a1SReinoud Zandijk  nvmm            NVMM acceleration support
1898d661d9a4SJustin Terry (VM)  whpx            Windows Hypervisor Platform acceleration support
189921ab34c9SMarcel Apfelbaum  rdma            Enable RDMA-based migration
190021ab34c9SMarcel Apfelbaum  pvrdma          Enable PVRDMA support
1901c23f23b9SMichael Tokarev  vde             support for vde network
1902c23f23b9SMichael Tokarev  netmap          support for netmap network
1903c23f23b9SMichael Tokarev  linux-aio       Linux AIO support
1904c10dd856SAarushi Mehta  linux-io-uring  Linux io_uring support
1905c23f23b9SMichael Tokarev  cap-ng          libcap-ng support
1906c23f23b9SMichael Tokarev  attr            attr and xattr support
1907299e6f19SPaolo Bonzini  vhost-net       vhost-net kernel acceleration support
1908299e6f19SPaolo Bonzini  vhost-vsock     virtio sockets device support
1909299e6f19SPaolo Bonzini  vhost-scsi      vhost-scsi kernel target support
1910299e6f19SPaolo Bonzini  vhost-crypto    vhost-user-crypto backend support
1911299e6f19SPaolo Bonzini  vhost-kernel    vhost kernel backend support
1912299e6f19SPaolo Bonzini  vhost-user      vhost-user backend support
1913bc15e44cSStefan Hajnoczi  vhost-user-blk-server    vhost-user-blk server support
1914108a6481SCindy Lu  vhost-vdpa      vhost-vdpa kernel backend support
191546627f41SAndrew Melnychenko  bpf             BPF kernel support
1916c23f23b9SMichael Tokarev  spice           spice
191758d3f3ffSGerd Hoffmann  spice-protocol  spice-protocol
1918c23f23b9SMichael Tokarev  rbd             rados block device (rbd)
1919c23f23b9SMichael Tokarev  libiscsi        iscsi support
1920c23f23b9SMichael Tokarev  libnfs          nfs support
19217b02f544SMarc-André Lureau  smartcard       smartcard support (libcacard)
19220a40bcb7SCésar Belley  u2f             U2F support (u2f-emu)
1923c23f23b9SMichael Tokarev  libusb          libusb (for usb passthrough)
1924ed1701c6SDr. David Alan Gilbert  live-block-migration   Block migration in the main migration stream
1925c23f23b9SMichael Tokarev  usb-redir       usb network redirection support
1926c23f23b9SMichael Tokarev  lzo             support of lzo compression library
1927c23f23b9SMichael Tokarev  snappy          support of snappy compression library
1928c23f23b9SMichael Tokarev  bzip2           support of bzip2 compression library
1929c23f23b9SMichael Tokarev                  (for reading bzip2-compressed dmg images)
193083bc1f97SJulio Faracco  lzfse           support of lzfse compression library
193183bc1f97SJulio Faracco                  (for reading lzfse-compressed dmg images)
19323a678481SJuan Quintela  zstd            support for zstd compression library
1933d298ac10SDenis Plotnikov                  (for migration compression and qcow2 cluster compression)
1934c23f23b9SMichael Tokarev  seccomp         seccomp support
1935c23f23b9SMichael Tokarev  coroutine-pool  coroutine freelist (better performance)
1936c23f23b9SMichael Tokarev  glusterfs       GlusterFS backend
1937c23f23b9SMichael Tokarev  tpm             TPM support
1938b10d49d7SPino Toscano  libssh          ssh block device support
1939c23f23b9SMichael Tokarev  numa            libnuma support
1940ed279a06SKlim Kireev  libxml2         for Parallels image format
1941c23f23b9SMichael Tokarev  tcmalloc        tcmalloc support
19427b01cb97SAlexandre Derumier  jemalloc        jemalloc support
194386583a07SLiam Merwick  avx2            AVX2 optimization support
19446b8cd447SRobert Hoo  avx512f         AVX512F optimization support
1945a6b1d4c0SChanglong Xie  replication     replication support
1946c12d66aaSLin Ma  opengl          opengl support
1947c12d66aaSLin Ma  virglrenderer   virgl rendering support
1948c12d66aaSLin Ma  xfsctl          xfsctl support
1949c12d66aaSLin Ma  qom-cast-debug  cast debugging support
19508de73fa8SCleber Rosa  tools           build qemu-io, qemu-nbd and qemu-img tools
19512f740136SJeff Cody  bochs           bochs image format support
19522f740136SJeff Cody  cloop           cloop image format support
19532f740136SJeff Cody  dmg             dmg image format support
19542f740136SJeff Cody  qcow1           qcow v1 image format support
19552f740136SJeff Cody  vdi             vdi image format support
19562f740136SJeff Cody  vvfat           vvfat image format support
19572f740136SJeff Cody  qed             qed image format support
19582f740136SJeff Cody  parallels       parallels image format support
1959f0d92b56SLongpeng(Mike)  crypto-afalg    Linux AF_ALG crypto backend driver
19608ca80760SRichard Henderson  capstone        capstone disassembler support
1961ba59fb77SPaolo Bonzini  debug-mutex     mutex debugging support
196217824406SJunyan He  libpmem         libpmem support
196375411919SJames Le Cuirot  xkbcommon       xkbcommon support
1964b767d257SMarek Marczykowski-Górecki  rng-none        dummy RNG, avoid using /dev/(u)random and getrandom()
196521b2eca6SJingqi Liu  libdaxctl       libdaxctl support
1966a484a719SMax Reitz  fuse            FUSE block device export
1967df4ea709SMax Reitz  fuse-lseek      SEEK_HOLE/SEEK_DATA support for FUSE exports
1968106ad1f9SPaolo Bonzini  multiprocess    Out of process device emulation support
196920cf7b8eSDenis Plotnikov  gio             libgio support
1970b8e0c493SJoelle van Dyne  slirp-smbd      use smbd (at path --smbd=*) in slirp networking
197108fb77edSStefan Weil
197208fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched
1973af5db58eSpbrookEOF
19742d2ad6d0SFam Zhengexit 0
1975af5db58eSpbrookfi
1976af5db58eSpbrook
19779c790242SThomas Huth# Remove old dependency files to make sure that they get properly regenerated
1978bb768f71SThomas Huthrm -f */config-devices.mak.d
19799c790242SThomas Huth
1980faf44142SDaniel P. Berrangéif test -z "$python"
1981faf44142SDaniel P. Berrangéthen
1982c53eeaf7SStefan Hajnoczi    error_exit "Python not found. Use --python=/path/to/python"
1983c53eeaf7SStefan Hajnoczifi
19848e2c76bdSRoman Bolshakovif ! has "$make"
19858e2c76bdSRoman Bolshakovthen
19868e2c76bdSRoman Bolshakov    error_exit "GNU make ($make) not found"
19878e2c76bdSRoman Bolshakovfi
1988c53eeaf7SStefan Hajnoczi
1989c53eeaf7SStefan Hajnoczi# Note that if the Python conditional here evaluates True we will exit
1990c53eeaf7SStefan Hajnoczi# with status 1 which is a shell 'false' value.
19911b11f28dSThomas Huthif ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then
19921b11f28dSThomas Huth  error_exit "Cannot use '$python', Python >= 3.6 is required." \
1993c53eeaf7SStefan Hajnoczi      "Use --python=/path/to/python to specify a supported Python."
1994c53eeaf7SStefan Hajnoczifi
1995c53eeaf7SStefan Hajnoczi
1996755ee70fSCleber Rosa# Preserve python version since some functionality is dependent on it
1997406ab2f3SCleber 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)
1998755ee70fSCleber Rosa
1999c53eeaf7SStefan Hajnoczi# Suppress writing compiled files
2000c53eeaf7SStefan Hajnoczipython="$python -B"
2001c53eeaf7SStefan Hajnoczi
20020a01d76fSMarc-André Lureauif test -z "$meson"; then
2003654d6b04SPaolo Bonzini    if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.59.2; then
20040a01d76fSMarc-André Lureau        meson=meson
20057d7dbf9dSDan Streetman    elif test $git_submodules_action != 'ignore' ; then
20060a01d76fSMarc-André Lureau        meson=git
20070a01d76fSMarc-André Lureau    elif test -e "${source_path}/meson/meson.py" ; then
20080a01d76fSMarc-André Lureau        meson=internal
20090a01d76fSMarc-André Lureau    else
20100a01d76fSMarc-André Lureau        if test "$explicit_python" = yes; then
20110a01d76fSMarc-André Lureau            error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found."
20120a01d76fSMarc-André Lureau        else
2013a5665051SPaolo Bonzini            error_exit "Meson not found.  Use --meson=/path/to/meson"
2014a5665051SPaolo Bonzini        fi
20150a01d76fSMarc-André Lureau    fi
20160a01d76fSMarc-André Lureauelse
20170a01d76fSMarc-André Lureau    # Meson uses its own Python interpreter to invoke other Python scripts,
20180a01d76fSMarc-André Lureau    # but the user wants to use the one they specified with --python.
20190a01d76fSMarc-André Lureau    #
20200a01d76fSMarc-André Lureau    # We do not want to override the distro Python interpreter (and sometimes
20210a01d76fSMarc-André Lureau    # cannot: for example in Homebrew /usr/bin/meson is a bash script), so
20220a01d76fSMarc-André Lureau    # just require --meson=git|internal together with --python.
20230a01d76fSMarc-André Lureau    if test "$explicit_python" = yes; then
20240a01d76fSMarc-André Lureau        case "$meson" in
20250a01d76fSMarc-André Lureau            git | internal) ;;
20260a01d76fSMarc-André Lureau            *) error_exit "--python requires using QEMU's embedded Meson distribution." ;;
20270a01d76fSMarc-André Lureau        esac
20280a01d76fSMarc-André Lureau    fi
20290a01d76fSMarc-André Lureaufi
2030a5665051SPaolo Bonzini
20310a01d76fSMarc-André Lureauif test "$meson" = git; then
20320a01d76fSMarc-André Lureau    git_submodules="${git_submodules} meson"
20330a01d76fSMarc-André Lureaufi
20340a01d76fSMarc-André Lureau
20350a01d76fSMarc-André Lureaucase "$meson" in
20360a01d76fSMarc-André Lureau    git | internal)
20370a01d76fSMarc-André Lureau        meson="$python ${source_path}/meson/meson.py"
20380a01d76fSMarc-André Lureau        ;;
203984ec0c24SPaolo Bonzini    *) meson=$(command -v "$meson") ;;
20400a01d76fSMarc-André Lureauesac
20410a01d76fSMarc-André Lureau
204209e93326SPaolo Bonzini# Probe for ninja
204348328880SPaolo Bonzini
204448328880SPaolo Bonziniif test -z "$ninja"; then
204548328880SPaolo Bonzini    for c in ninja ninja-build samu; do
204648328880SPaolo Bonzini        if has $c; then
204748328880SPaolo Bonzini            ninja=$(command -v "$c")
204848328880SPaolo Bonzini            break
204948328880SPaolo Bonzini        fi
205048328880SPaolo Bonzini    done
205109e93326SPaolo Bonzini    if test -z "$ninja"; then
205209e93326SPaolo Bonzini      error_exit "Cannot find Ninja"
205309e93326SPaolo Bonzini    fi
205448328880SPaolo Bonzinifi
2055a5665051SPaolo Bonzini
20569aae6e54SDaniel Henrique Barboza# Check that the C compiler works. Doing this here before testing
20579aae6e54SDaniel Henrique Barboza# the host CPU ensures that we had a valid CC to autodetect the
20589aae6e54SDaniel Henrique Barboza# $cpu var (and we should bail right here if that's not the case).
20599aae6e54SDaniel Henrique Barboza# It also allows the help message to be printed without a CC.
20609aae6e54SDaniel Henrique Barbozawrite_c_skeleton;
20619aae6e54SDaniel Henrique Barbozaif compile_object ; then
20629aae6e54SDaniel Henrique Barboza  : C compiler works ok
20639aae6e54SDaniel Henrique Barbozaelse
20649aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" either does not exist or does not work"
20659aae6e54SDaniel Henrique Barbozafi
20669aae6e54SDaniel Henrique Barbozaif ! compile_prog ; then
20679aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
20689aae6e54SDaniel Henrique Barbozafi
20699aae6e54SDaniel Henrique Barboza
20709c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror
20719c83ffd8SPeter Maydell# by default.  Only enable by default for git builds
20729c83ffd8SPeter Maydellif test -z "$werror" ; then
20737d7dbf9dSDan Streetman    if test "$git_submodules_action" != "ignore" && \
2074e633a5c6SEric Blake        { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
20759c83ffd8SPeter Maydell        werror="yes"
20769c83ffd8SPeter Maydell    else
20779c83ffd8SPeter Maydell        werror="no"
20789c83ffd8SPeter Maydell    fi
20799c83ffd8SPeter Maydellfi
20809c83ffd8SPeter Maydell
2081975ff037SPaolo Bonziniif test "$targetos" = "bogus"; then
2082fb59dabdSPeter Maydell    # Now that we know that we're not printing the help and that
2083fb59dabdSPeter Maydell    # the compiler works (so the results of the check_defines we used
2084fb59dabdSPeter Maydell    # to identify the OS are reliable), if we didn't recognize the
2085fb59dabdSPeter Maydell    # host OS we should stop now.
2086951fedfcSPeter Maydell    error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
2087fb59dabdSPeter Maydellfi
2088fb59dabdSPeter Maydell
2089efc6c070SThomas Huth# Check whether the compiler matches our minimum requirements:
2090efc6c070SThomas Huthcat > $TMPC << EOF
2091efc6c070SThomas Huth#if defined(__clang_major__) && defined(__clang_minor__)
2092efc6c070SThomas Huth# ifdef __apple_build_version__
20932a85a08cSDaniel P. Berrangé#  if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0)
20942a85a08cSDaniel P. Berrangé#   error You need at least XCode Clang v10.0 to compile QEMU
2095efc6c070SThomas Huth#  endif
2096efc6c070SThomas Huth# else
20972a85a08cSDaniel P. Berrangé#  if __clang_major__ < 6 || (__clang_major__ == 6 && __clang_minor__ < 0)
20982a85a08cSDaniel P. Berrangé#   error You need at least Clang v6.0 to compile QEMU
2099efc6c070SThomas Huth#  endif
2100efc6c070SThomas Huth# endif
2101efc6c070SThomas Huth#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
21023830df5fSnia# if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4)
21033830df5fSnia#  error You need at least GCC v7.4.0 to compile QEMU
2104efc6c070SThomas Huth# endif
2105efc6c070SThomas Huth#else
2106efc6c070SThomas Huth# error You either need GCC or Clang to compiler QEMU
2107efc6c070SThomas Huth#endif
2108efc6c070SThomas Huthint main (void) { return 0; }
2109efc6c070SThomas HuthEOF
2110efc6c070SThomas Huthif ! compile_prog "" "" ; then
21113830df5fSnia    error_exit "You need at least GCC v7.4 or Clang v6.0 (or XCode Clang v10.0)"
2112efc6c070SThomas Huthfi
2113efc6c070SThomas Huth
211400849b92SRichard Henderson# Accumulate -Wfoo and -Wno-bar separately.
211500849b92SRichard Henderson# We will list all of the enable flags first, and the disable flags second.
211600849b92SRichard Henderson# Note that we do not add -Werror, because that would enable it for all
211700849b92SRichard Henderson# configure tests. If a configure test failed due to -Werror this would
211800849b92SRichard Henderson# just silently disable some features, so it's too error prone.
211900849b92SRichard Henderson
212000849b92SRichard Hendersonwarn_flags=
212100849b92SRichard Hendersonadd_to warn_flags -Wold-style-declaration
212200849b92SRichard Hendersonadd_to warn_flags -Wold-style-definition
212300849b92SRichard Hendersonadd_to warn_flags -Wtype-limits
212400849b92SRichard Hendersonadd_to warn_flags -Wformat-security
212500849b92SRichard Hendersonadd_to warn_flags -Wformat-y2k
212600849b92SRichard Hendersonadd_to warn_flags -Winit-self
212700849b92SRichard Hendersonadd_to warn_flags -Wignored-qualifiers
212800849b92SRichard Hendersonadd_to warn_flags -Wempty-body
212900849b92SRichard Hendersonadd_to warn_flags -Wnested-externs
213000849b92SRichard Hendersonadd_to warn_flags -Wendif-labels
213100849b92SRichard Hendersonadd_to warn_flags -Wexpansion-to-defined
21320a2ebce9SThomas Huthadd_to warn_flags -Wimplicit-fallthrough=2
213300849b92SRichard Henderson
213400849b92SRichard Hendersonnowarn_flags=
213500849b92SRichard Hendersonadd_to nowarn_flags -Wno-initializer-overrides
213600849b92SRichard Hendersonadd_to nowarn_flags -Wno-missing-include-dirs
213700849b92SRichard Hendersonadd_to nowarn_flags -Wno-shift-negative-value
213800849b92SRichard Hendersonadd_to nowarn_flags -Wno-string-plus-int
213900849b92SRichard Hendersonadd_to nowarn_flags -Wno-typedef-redefinition
2140aabab967SRichard Hendersonadd_to nowarn_flags -Wno-tautological-type-limit-compare
2141bac8d222SRichard Hendersonadd_to nowarn_flags -Wno-psabi
214200849b92SRichard Henderson
214300849b92SRichard Hendersongcc_flags="$warn_flags $nowarn_flags"
214493b25869SJohn Snow
214593b25869SJohn Snowcc_has_warning_flag() {
214693b25869SJohn Snow    write_c_skeleton;
214793b25869SJohn Snow
2148a1d29d6cSPeter Maydell    # Use the positive sense of the flag when testing for -Wno-wombat
2149a1d29d6cSPeter Maydell    # support (gcc will happily accept the -Wno- form of unknown
2150a1d29d6cSPeter Maydell    # warning options).
215193b25869SJohn Snow    optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
215293b25869SJohn Snow    compile_prog "-Werror $optflag" ""
215393b25869SJohn Snow}
215493b25869SJohn Snow
215593b25869SJohn Snowfor flag in $gcc_flags; do
215693b25869SJohn Snow    if cc_has_warning_flag $flag ; then
21578d05095cSPaolo Bonzini        QEMU_CFLAGS="$QEMU_CFLAGS $flag"
21588d05095cSPaolo Bonzini    fi
21598d05095cSPaolo Bonzinidone
21608d05095cSPaolo Bonzini
216163678e17SSteven Noonanif test "$stack_protector" != "no"; then
2162fccd35a0SRodrigo Rebello  cat > $TMPC << EOF
2163fccd35a0SRodrigo Rebelloint main(int argc, char *argv[])
2164fccd35a0SRodrigo Rebello{
2165fccd35a0SRodrigo Rebello    char arr[64], *p = arr, *c = argv[0];
2166fccd35a0SRodrigo Rebello    while (*c) {
2167fccd35a0SRodrigo Rebello        *p++ = *c++;
2168fccd35a0SRodrigo Rebello    }
2169fccd35a0SRodrigo Rebello    return 0;
2170fccd35a0SRodrigo Rebello}
2171fccd35a0SRodrigo RebelloEOF
217263678e17SSteven Noonan  gcc_flags="-fstack-protector-strong -fstack-protector-all"
21733b463a3fSMiroslav Rezanina  sp_on=0
217463678e17SSteven Noonan  for flag in $gcc_flags; do
2175590e5dd9SPeter Maydell    # We need to check both a compile and a link, since some compiler
2176590e5dd9SPeter Maydell    # setups fail only on a .c->.o compile and some only at link time
2177086d5f75SPaolo Bonzini    if compile_object "-Werror $flag" &&
2178590e5dd9SPeter Maydell       compile_prog "-Werror $flag" ""; then
217963678e17SSteven Noonan      QEMU_CFLAGS="$QEMU_CFLAGS $flag"
2180db5adeaaSPaolo Bonzini      QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
21813b463a3fSMiroslav Rezanina      sp_on=1
218263678e17SSteven Noonan      break
218363678e17SSteven Noonan    fi
218463678e17SSteven Noonan  done
21853b463a3fSMiroslav Rezanina  if test "$stack_protector" = yes; then
21863b463a3fSMiroslav Rezanina    if test $sp_on = 0; then
21873b463a3fSMiroslav Rezanina      error_exit "Stack protector not supported"
21883b463a3fSMiroslav Rezanina    fi
21893b463a3fSMiroslav Rezanina  fi
219037746c5eSMarc-André Lureaufi
219137746c5eSMarc-André Lureau
219220bc94a2SPaolo Bonzini# Disable -Wmissing-braces on older compilers that warn even for
219320bc94a2SPaolo Bonzini# the "universal" C zero initializer {0}.
219420bc94a2SPaolo Bonzinicat > $TMPC << EOF
219520bc94a2SPaolo Bonzinistruct {
219620bc94a2SPaolo Bonzini  int a[2];
219720bc94a2SPaolo Bonzini} x = {0};
219820bc94a2SPaolo BonziniEOF
219920bc94a2SPaolo Bonziniif compile_object "-Werror" "" ; then
220020bc94a2SPaolo Bonzini  :
220120bc94a2SPaolo Bonzinielse
220220bc94a2SPaolo Bonzini  QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
220320bc94a2SPaolo Bonzinifi
220420bc94a2SPaolo Bonzini
220521e709aaSMarc-André Lureau# Our module code doesn't support Windows
220621e709aaSMarc-André Lureauif test "$modules" = "yes" && test "$mingw32" = "yes" ; then
220721e709aaSMarc-André Lureau  error_exit "Modules are not available for Windows"
220821e709aaSMarc-André Lureaufi
220921e709aaSMarc-André Lureau
2210bd83c861SChristian Ehrhardt# module_upgrades is only reasonable if modules are enabled
2211bd83c861SChristian Ehrhardtif test "$modules" = "no" && test "$module_upgrades" = "yes" ; then
2212bd83c861SChristian Ehrhardt  error_exit "Can't enable module-upgrades as Modules are not enabled"
2213bd83c861SChristian Ehrhardtfi
2214bd83c861SChristian Ehrhardt
22155f2453acSAlex Bennée# Static linking is not possible with plugins, modules or PIE
221640d6444eSAvi Kivityif test "$static" = "yes" ; then
2217aa0d1f44SPaolo Bonzini  if test "$modules" = "yes" ; then
2218aa0d1f44SPaolo Bonzini    error_exit "static and modules are mutually incompatible"
2219aa0d1f44SPaolo Bonzini  fi
22205f2453acSAlex Bennée  if test "$plugins" = "yes"; then
22215f2453acSAlex Bennée    error_exit "static and plugins are mutually incompatible"
2222ba4dd2aaSAlex Bennée  else
2223ba4dd2aaSAlex Bennée    plugins="no"
22245f2453acSAlex Bennée  fi
222540d6444eSAvi Kivityfi
222640d6444eSAvi Kivity
2227768b7855SEmilio G. Cota# Unconditional check for compiler __thread support
2228768b7855SEmilio G. Cota  cat > $TMPC << EOF
2229768b7855SEmilio G. Cotastatic __thread int tls_var;
2230768b7855SEmilio G. Cotaint main(void) { return tls_var; }
2231768b7855SEmilio G. CotaEOF
2232768b7855SEmilio G. Cota
2233768b7855SEmilio G. Cotaif ! compile_prog "-Werror" "" ; then
2234768b7855SEmilio G. Cota    error_exit "Your compiler does not support the __thread specifier for " \
2235768b7855SEmilio G. Cota	"Thread-Local Storage (TLS). Please upgrade to a version that does."
2236768b7855SEmilio G. Cotafi
2237768b7855SEmilio G. Cota
223840d6444eSAvi Kivitycat > $TMPC << EOF
223921d4a791SAvi Kivity
224021d4a791SAvi Kivity#ifdef __linux__
224121d4a791SAvi Kivity#  define THREAD __thread
224221d4a791SAvi Kivity#else
224321d4a791SAvi Kivity#  define THREAD
224421d4a791SAvi Kivity#endif
224521d4a791SAvi Kivitystatic THREAD int tls_var;
224621d4a791SAvi Kivityint main(void) { return tls_var; }
224740d6444eSAvi KivityEOF
2248b2634124SRichard Henderson
2249b2634124SRichard Henderson# Check we support --no-pie first; we will need this for building ROMs.
2250412aeacdSAlex Bennéeif compile_prog "-Werror -fno-pie" "-no-pie"; then
2251412aeacdSAlex Bennée  CFLAGS_NOPIE="-fno-pie"
2252412aeacdSAlex Bennéefi
2253412aeacdSAlex Bennée
225412781462SRichard Hendersonif test "$static" = "yes"; then
2255eca7a8e6SRichard Henderson  if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then
22565770e8afSPaolo Bonzini    CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
225712781462SRichard Henderson    QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS"
225812781462SRichard Henderson    pie="yes"
225912781462SRichard Henderson  elif test "$pie" = "yes"; then
226012781462SRichard Henderson    error_exit "-static-pie not available due to missing toolchain support"
226112781462SRichard Henderson  else
226212781462SRichard Henderson    QEMU_LDFLAGS="-static $QEMU_LDFLAGS"
226312781462SRichard Henderson    pie="no"
226412781462SRichard Henderson  fi
226512781462SRichard Hendersonelif test "$pie" = "no"; then
22665770e8afSPaolo Bonzini  CONFIGURE_CFLAGS="$CFLAGS_NOPIE $CONFIGURE_CFLAGS"
2267eca7a8e6SRichard Hendersonelif compile_prog "-Werror -fPIE -DPIE" "-pie"; then
22685770e8afSPaolo Bonzini  CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
22695770e8afSPaolo Bonzini  CONFIGURE_LDFLAGS="-pie $CONFIGURE_LDFLAGS"
227040d6444eSAvi Kivity  pie="yes"
22712c674109SRichard Hendersonelif test "$pie" = "yes"; then
227276ad07a4SPeter Maydell  error_exit "PIE not available due to missing toolchain support"
227340d6444eSAvi Kivityelse
227440d6444eSAvi Kivity  echo "Disabling PIE due to missing toolchain support"
227540d6444eSAvi Kivity  pie="no"
227640d6444eSAvi Kivityfi
227740d6444eSAvi Kivity
2278e6cbd751SRichard Henderson# Detect support for PT_GNU_RELRO + DT_BIND_NOW.
2279e6cbd751SRichard Henderson# The combination is known as "full relro", because .got.plt is read-only too.
2280e6cbd751SRichard Hendersonif compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
2281e6cbd751SRichard Henderson  QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS"
2282e6cbd751SRichard Hendersonfi
2283e6cbd751SRichard Henderson
228409dada40SPaolo Bonzini##########################################
228509dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains
228609dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit
228709dada40SPaolo Bonzini# specification is necessary
228809dada40SPaolo Bonzini
228909dada40SPaolo Bonziniif test "$cpu" = "i386"; then
229009dada40SPaolo Bonzini  cat > $TMPC << EOF
229109dada40SPaolo Bonzinistatic int sfaa(int *ptr)
229209dada40SPaolo Bonzini{
229309dada40SPaolo Bonzini  return __sync_fetch_and_and(ptr, 0);
229409dada40SPaolo Bonzini}
229509dada40SPaolo Bonzini
229609dada40SPaolo Bonziniint main(void)
229709dada40SPaolo Bonzini{
229809dada40SPaolo Bonzini  int val = 42;
22991405b629SStefan Weil  val = __sync_val_compare_and_swap(&val, 0, 1);
230009dada40SPaolo Bonzini  sfaa(&val);
230109dada40SPaolo Bonzini  return val;
230209dada40SPaolo Bonzini}
230309dada40SPaolo BonziniEOF
230409dada40SPaolo Bonzini  if ! compile_prog "" "" ; then
230509dada40SPaolo Bonzini    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
230609dada40SPaolo Bonzini  fi
230709dada40SPaolo Bonzinifi
230809dada40SPaolo Bonzini
230909dada40SPaolo Bonzini#########################################
2310ec530c81Sbellard# Solaris specific configure tool chain decisions
231109dada40SPaolo Bonzini
2312ec530c81Sbellardif test "$solaris" = "yes" ; then
23136792aa11SLoïc Minier  if has ar; then
23146792aa11SLoïc Minier    :
23156792aa11SLoïc Minier  else
2316ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
231776ad07a4SPeter Maydell      error_exit "No path includes ar" \
231876ad07a4SPeter Maydell          "Add /usr/ccs/bin to your path and rerun configure"
2319ec530c81Sbellard    fi
232076ad07a4SPeter Maydell    error_exit "No path includes ar"
2321ec530c81Sbellard  fi
2322ec530c81Sbellardfi
2323ec530c81Sbellard
232456267b62SPhilippe Mathieu-Daudéif test "$tcg" = "enabled"; then
232556267b62SPhilippe Mathieu-Daudé    git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
232656267b62SPhilippe Mathieu-Daudé    git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
232756267b62SPhilippe Mathieu-Daudéfi
232856267b62SPhilippe Mathieu-Daudé
2329afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then
2330fdb75aefSPaolo Bonzini    default_targets=yes
2331d880a3baSPaolo Bonzini    for target in $default_target_list; do
2332d880a3baSPaolo Bonzini        target_list="$target_list $target"
2333d880a3baSPaolo Bonzini    done
2334d880a3baSPaolo Bonzini    target_list="${target_list# }"
2335121afa9eSAnthony Liguorielse
2336fdb75aefSPaolo Bonzini    default_targets=no
233789138857SStefan Weil    target_list=$(echo "$target_list" | sed -e 's/,/ /g')
2338d880a3baSPaolo Bonzini    for target in $target_list; do
233925b48338SPeter Maydell        # Check that we recognised the target name; this allows a more
234025b48338SPeter Maydell        # friendly error message than if we let it fall through.
234125b48338SPeter Maydell        case " $default_target_list " in
234225b48338SPeter Maydell            *" $target "*)
234325b48338SPeter Maydell                ;;
234425b48338SPeter Maydell            *)
234525b48338SPeter Maydell                error_exit "Unknown target name '$target'"
234625b48338SPeter Maydell                ;;
234725b48338SPeter Maydell        esac
234825b48338SPeter Maydell    done
2349d880a3baSPaolo Bonzinifi
235025b48338SPeter Maydell
2351fdb75aefSPaolo Bonzinifor target in $target_list; do
2352fdb75aefSPaolo Bonzini    # if a deprecated target is enabled we note it here
2353fdb75aefSPaolo Bonzini    if echo "$deprecated_targets_list" | grep -q "$target"; then
2354fdb75aefSPaolo Bonzini        add_to deprecated_features $target
2355fdb75aefSPaolo Bonzini    fi
2356fdb75aefSPaolo Bonzinidone
2357fdb75aefSPaolo Bonzini
2358f55fe278SPaolo Bonzini# see if system emulation was really requested
2359f55fe278SPaolo Bonzinicase " $target_list " in
2360f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
2361f55fe278SPaolo Bonzini  ;;
2362f55fe278SPaolo Bonzini  *) softmmu=no
2363f55fe278SPaolo Bonzini  ;;
2364f55fe278SPaolo Bonziniesac
23655327cf48Sbellard
2366249247c9SJuan Quintelafeature_not_found() {
2367249247c9SJuan Quintela  feature=$1
236821684af0SStewart Smith  remedy=$2
2369249247c9SJuan Quintela
237076ad07a4SPeter Maydell  error_exit "User requested feature $feature" \
237121684af0SStewart Smith      "configure was not able to find it." \
237221684af0SStewart Smith      "$remedy"
2373249247c9SJuan Quintela}
2374249247c9SJuan Quintela
23757d13299dSbellard# ---
23767d13299dSbellard# big/little endian test
23777d13299dSbellardcat > $TMPC << EOF
2378659eb157SThomas Huth#include <stdio.h>
237961cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
238061cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
2381659eb157SThomas Huthint main(int argc, char *argv[])
2382659eb157SThomas Huth{
2383659eb157SThomas Huth    return printf("%s %s\n", (char *)big_endian, (char *)little_endian);
23847d13299dSbellard}
23857d13299dSbellardEOF
23867d13299dSbellard
2387659eb157SThomas Huthif compile_prog ; then
2388659eb157SThomas Huth    if strings -a $TMPE | grep -q BiGeNdIaN ; then
238961cc919fSMike Frysinger        bigendian="yes"
2390659eb157SThomas Huth    elif strings -a $TMPE | grep -q LiTtLeEnDiAn ; then
239161cc919fSMike Frysinger        bigendian="no"
23927d13299dSbellard    else
23937d13299dSbellard        echo big/little test failed
2394659eb157SThomas Huth        exit 1
23957d13299dSbellard    fi
23967d13299dSbellardelse
239761cc919fSMike Frysinger    echo big/little test failed
2398659eb157SThomas Huth    exit 1
23997d13299dSbellardfi
24007d13299dSbellard
2401b0a47e79SJuan Quintela##########################################
2402e10ee3f5SPhilippe Mathieu-Daudé# system tools
2403e10ee3f5SPhilippe Mathieu-Daudéif test -z "$want_tools"; then
2404e10ee3f5SPhilippe Mathieu-Daudé    if test "$softmmu" = "no"; then
2405e10ee3f5SPhilippe Mathieu-Daudé        want_tools=no
2406e10ee3f5SPhilippe Mathieu-Daudé    else
2407e10ee3f5SPhilippe Mathieu-Daudé        want_tools=yes
2408e10ee3f5SPhilippe Mathieu-Daudé    fi
2409e10ee3f5SPhilippe Mathieu-Daudéfi
2410e10ee3f5SPhilippe Mathieu-Daudé
2411e10ee3f5SPhilippe Mathieu-Daudé##########################################
2412015a33bdSGonglei# L2TPV3 probe
2413015a33bdSGonglei
2414015a33bdSGongleicat > $TMPC <<EOF
2415015a33bdSGonglei#include <sys/socket.h>
2416bff6cb72SMichael Tokarev#include <linux/ip.h>
2417015a33bdSGongleiint main(void) { return sizeof(struct mmsghdr); }
2418015a33bdSGongleiEOF
2419015a33bdSGongleiif compile_prog "" "" ; then
2420015a33bdSGonglei  l2tpv3=yes
2421015a33bdSGongleielse
2422015a33bdSGonglei  l2tpv3=no
2423015a33bdSGongleifi
2424015a33bdSGonglei
2425195588ccSDavid CARLIERcat > $TMPC <<EOF
2426195588ccSDavid CARLIER#include <sys/mman.h>
2427195588ccSDavid CARLIERint main(int argc, char *argv[]) {
2428195588ccSDavid CARLIER    return mlockall(MCL_FUTURE);
2429195588ccSDavid CARLIER}
2430195588ccSDavid CARLIEREOF
2431195588ccSDavid CARLIERif compile_prog "" "" ; then
2432195588ccSDavid CARLIER  have_mlockall=yes
2433195588ccSDavid CARLIERelse
2434195588ccSDavid CARLIER  have_mlockall=no
2435195588ccSDavid CARLIERfi
2436195588ccSDavid CARLIER
2437299e6f19SPaolo Bonzini#########################################
2438299e6f19SPaolo Bonzini# vhost interdependencies and host support
2439299e6f19SPaolo Bonzini
2440299e6f19SPaolo Bonzini# vhost backends
2441d88618f7SStefan Hajnocziif test "$vhost_user" = "yes" && test "$linux" != "yes"; then
2442d88618f7SStefan Hajnoczi  error_exit "vhost-user is only available on Linux"
2443299e6f19SPaolo Bonzinifi
2444108a6481SCindy Lutest "$vhost_vdpa" = "" && vhost_vdpa=$linux
2445108a6481SCindy Luif test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then
2446108a6481SCindy Lu  error_exit "vhost-vdpa is only available on Linux"
2447108a6481SCindy Lufi
2448299e6f19SPaolo Bonzinitest "$vhost_kernel" = "" && vhost_kernel=$linux
2449299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then
2450299e6f19SPaolo Bonzini  error_exit "vhost-kernel is only available on Linux"
2451299e6f19SPaolo Bonzinifi
2452299e6f19SPaolo Bonzini
2453299e6f19SPaolo Bonzini# vhost-kernel devices
2454299e6f19SPaolo Bonzinitest "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel
2455299e6f19SPaolo Bonziniif test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then
2456299e6f19SPaolo Bonzini  error_exit "--enable-vhost-scsi requires --enable-vhost-kernel"
2457299e6f19SPaolo Bonzinifi
2458299e6f19SPaolo Bonzinitest "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel
2459299e6f19SPaolo Bonziniif test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then
2460299e6f19SPaolo Bonzini  error_exit "--enable-vhost-vsock requires --enable-vhost-kernel"
2461299e6f19SPaolo Bonzinifi
2462299e6f19SPaolo Bonzini
2463299e6f19SPaolo Bonzini# vhost-user backends
2464299e6f19SPaolo Bonzinitest "$vhost_net_user" = "" && vhost_net_user=$vhost_user
2465299e6f19SPaolo Bonziniif test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then
2466299e6f19SPaolo Bonzini  error_exit "--enable-vhost-net-user requires --enable-vhost-user"
2467299e6f19SPaolo Bonzinifi
2468299e6f19SPaolo Bonzinitest "$vhost_crypto" = "" && vhost_crypto=$vhost_user
2469299e6f19SPaolo Bonziniif test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then
2470299e6f19SPaolo Bonzini  error_exit "--enable-vhost-crypto requires --enable-vhost-user"
2471299e6f19SPaolo Bonzinifi
247298fc1adaSDr. David Alan Gilberttest "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user
247398fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then
247498fc1adaSDr. David Alan Gilbert  error_exit "--enable-vhost-user-fs requires --enable-vhost-user"
247598fc1adaSDr. David Alan Gilbertfi
2476108a6481SCindy Lu#vhost-vdpa backends
2477108a6481SCindy Lutest "$vhost_net_vdpa" = "" && vhost_net_vdpa=$vhost_vdpa
2478108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" && test "$vhost_vdpa" = "no"; then
2479108a6481SCindy Lu  error_exit "--enable-vhost-net-vdpa requires --enable-vhost-vdpa"
2480108a6481SCindy Lufi
2481299e6f19SPaolo Bonzini
248240bc0ca9SLaurent Vivier# OR the vhost-kernel, vhost-vdpa and vhost-user values for simplicity
2483299e6f19SPaolo Bonziniif test "$vhost_net" = ""; then
2484299e6f19SPaolo Bonzini  test "$vhost_net_user" = "yes" && vhost_net=yes
248540bc0ca9SLaurent Vivier  test "$vhost_net_vdpa" = "yes" && vhost_net=yes
2486299e6f19SPaolo Bonzini  test "$vhost_kernel" = "yes" && vhost_net=yes
2487299e6f19SPaolo Bonzinifi
2488299e6f19SPaolo Bonzini
2489015a33bdSGonglei##########################################
2490779ab5e3SStefan Weil# pkg-config probe
2491779ab5e3SStefan Weil
2492779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then
249376ad07a4SPeter Maydell  error_exit "pkg-config binary '$pkg_config_exe' not found"
2494779ab5e3SStefan Weilfi
2495779ab5e3SStefan Weil
2496779ab5e3SStefan Weil##########################################
2497b0a47e79SJuan Quintela# NPTL probe
2498b0a47e79SJuan Quintela
249924cb36a6SPeter Maydellif test "$linux_user" = "yes"; then
2500bd0c5661Spbrook  cat > $TMPC <<EOF
2501bd0c5661Spbrook#include <sched.h>
250230813ceaSpbrook#include <linux/futex.h>
2503182eacc0SStefan Weilint main(void) {
2504bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
2505bd0c5661Spbrook#error bork
2506bd0c5661Spbrook#endif
2507182eacc0SStefan Weil  return 0;
2508bd0c5661Spbrook}
2509bd0c5661SpbrookEOF
251024cb36a6SPeter Maydell  if ! compile_object ; then
251121684af0SStewart Smith    feature_not_found "nptl" "Install glibc and linux kernel headers."
2512b0a47e79SJuan Quintela  fi
2513bd0c5661Spbrookfi
2514bd0c5661Spbrook
2515ac62922eSbalrog##########################################
2516e37630caSaliguori# xen probe
2517e37630caSaliguori
25181badb709SPaolo Bonziniif test "$xen" != "disabled" ; then
2519c1cdd9d5SJuergen Gross  # Check whether Xen library path is specified via --extra-ldflags to avoid
2520c1cdd9d5SJuergen Gross  # overriding this setting with pkg-config output. If not, try pkg-config
2521c1cdd9d5SJuergen Gross  # to obtain all needed flags.
2522c1cdd9d5SJuergen Gross
2523c1cdd9d5SJuergen Gross  if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2524c1cdd9d5SJuergen Gross     $pkg_config --exists xencontrol ; then
2525c1cdd9d5SJuergen Gross    xen_ctrl_version="$(printf '%d%02d%02d' \
2526c1cdd9d5SJuergen Gross      $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
25271badb709SPaolo Bonzini    xen=enabled
25285b6a8f43SMichael Tokarev    xen_pc="xencontrol xenstore xenforeignmemory xengnttab"
2529c1cdd9d5SJuergen Gross    xen_pc="$xen_pc xenevtchn xendevicemodel"
253058ea9a7aSAnthony PERARD    if $pkg_config --exists xentoolcore; then
253158ea9a7aSAnthony PERARD      xen_pc="$xen_pc xentoolcore"
253258ea9a7aSAnthony PERARD    fi
2533582ea95fSMarc-André Lureau    xen_cflags="$($pkg_config --cflags $xen_pc)"
2534582ea95fSMarc-André Lureau    xen_libs="$($pkg_config --libs $xen_pc)"
2535c1cdd9d5SJuergen Gross  else
2536c1cdd9d5SJuergen Gross
25375b6a8f43SMichael Tokarev    xen_libs="-lxenstore -lxenctrl"
2538d9506cabSAnthony PERARD    xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
2539d5b93ddfSAnthony PERARD
254050ced5b3SStefan Weil    # First we test whether Xen headers and libraries are available.
254150ced5b3SStefan Weil    # If no, we are done and there is no Xen support.
254250ced5b3SStefan Weil    # If yes, more tests are run to detect the Xen version.
254350ced5b3SStefan Weil
254450ced5b3SStefan Weil    # Xen (any)
254550ced5b3SStefan Weil    cat > $TMPC <<EOF
254650ced5b3SStefan Weil#include <xenctrl.h>
254750ced5b3SStefan Weilint main(void) {
254850ced5b3SStefan Weil  return 0;
254950ced5b3SStefan Weil}
255050ced5b3SStefan WeilEOF
255150ced5b3SStefan Weil    if ! compile_prog "" "$xen_libs" ; then
255250ced5b3SStefan Weil      # Xen not found
25531badb709SPaolo Bonzini      if test "$xen" = "enabled" ; then
255421684af0SStewart Smith        feature_not_found "xen" "Install xen devel"
255550ced5b3SStefan Weil      fi
25561badb709SPaolo Bonzini      xen=disabled
255750ced5b3SStefan Weil
2558d5b93ddfSAnthony PERARD    # Xen unstable
255969deef08SPeter Maydell    elif
256069deef08SPeter Maydell        cat > $TMPC <<EOF &&
25612cbf8903SRoss Lagerwall#undef XC_WANT_COMPAT_DEVICEMODEL_API
25622cbf8903SRoss Lagerwall#define __XEN_TOOLS__
25632cbf8903SRoss Lagerwall#include <xendevicemodel.h>
2564d3c49ebbSPaul Durrant#include <xenforeignmemory.h>
25652cbf8903SRoss Lagerwallint main(void) {
25662cbf8903SRoss Lagerwall  xendevicemodel_handle *xd;
2567d3c49ebbSPaul Durrant  xenforeignmemory_handle *xfmem;
25682cbf8903SRoss Lagerwall
25692cbf8903SRoss Lagerwall  xd = xendevicemodel_open(0, 0);
25702cbf8903SRoss Lagerwall  xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
25712cbf8903SRoss Lagerwall
2572d3c49ebbSPaul Durrant  xfmem = xenforeignmemory_open(0, 0);
2573d3c49ebbSPaul Durrant  xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
2574d3c49ebbSPaul Durrant
25752cbf8903SRoss Lagerwall  return 0;
25762cbf8903SRoss Lagerwall}
25772cbf8903SRoss LagerwallEOF
25782cbf8903SRoss Lagerwall        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
25792cbf8903SRoss Lagerwall      then
25802cbf8903SRoss Lagerwall      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
25812cbf8903SRoss Lagerwall      xen_ctrl_version=41100
25821badb709SPaolo Bonzini      xen=enabled
25832cbf8903SRoss Lagerwall    elif
25842cbf8903SRoss Lagerwall        cat > $TMPC <<EOF &&
25855ba3d756SIgor Druzhinin#undef XC_WANT_COMPAT_MAP_FOREIGN_API
25865ba3d756SIgor Druzhinin#include <xenforeignmemory.h>
258758ea9a7aSAnthony PERARD#include <xentoolcore.h>
25885ba3d756SIgor Druzhininint main(void) {
25895ba3d756SIgor Druzhinin  xenforeignmemory_handle *xfmem;
25905ba3d756SIgor Druzhinin
25915ba3d756SIgor Druzhinin  xfmem = xenforeignmemory_open(0, 0);
25925ba3d756SIgor Druzhinin  xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
259358ea9a7aSAnthony PERARD  xentoolcore_restrict_all(0);
25945ba3d756SIgor Druzhinin
25955ba3d756SIgor Druzhinin  return 0;
25965ba3d756SIgor Druzhinin}
25975ba3d756SIgor DruzhininEOF
259858ea9a7aSAnthony PERARD        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
25995ba3d756SIgor Druzhinin      then
260058ea9a7aSAnthony PERARD      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
26015ba3d756SIgor Druzhinin      xen_ctrl_version=41000
26021badb709SPaolo Bonzini      xen=enabled
26035ba3d756SIgor Druzhinin    elif
26045ba3d756SIgor Druzhinin        cat > $TMPC <<EOF &&
2605da8090ccSPaul Durrant#undef XC_WANT_COMPAT_DEVICEMODEL_API
2606da8090ccSPaul Durrant#define __XEN_TOOLS__
2607da8090ccSPaul Durrant#include <xendevicemodel.h>
2608da8090ccSPaul Durrantint main(void) {
2609da8090ccSPaul Durrant  xendevicemodel_handle *xd;
2610da8090ccSPaul Durrant
2611da8090ccSPaul Durrant  xd = xendevicemodel_open(0, 0);
2612da8090ccSPaul Durrant  xendevicemodel_close(xd);
2613da8090ccSPaul Durrant
2614da8090ccSPaul Durrant  return 0;
2615da8090ccSPaul Durrant}
2616da8090ccSPaul DurrantEOF
2617da8090ccSPaul Durrant        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2618da8090ccSPaul Durrant      then
2619da8090ccSPaul Durrant      xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2620f1167ee6SJuergen Gross      xen_ctrl_version=40900
26211badb709SPaolo Bonzini      xen=enabled
2622da8090ccSPaul Durrant    elif
2623da8090ccSPaul Durrant        cat > $TMPC <<EOF &&
26245eeb39c2SIan Campbell/*
26255eeb39c2SIan Campbell * If we have stable libs the we don't want the libxc compat
26265eeb39c2SIan Campbell * layers, regardless of what CFLAGS we may have been given.
2627b6eb9b45SPaulina Szubarczyk *
2628b6eb9b45SPaulina Szubarczyk * Also, check if xengnttab_grant_copy_segment_t is defined and
2629b6eb9b45SPaulina Szubarczyk * grant copy operation is implemented.
2630b6eb9b45SPaulina Szubarczyk */
2631b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_EVTCHN_API
2632b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_GNTTAB_API
2633b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2634b6eb9b45SPaulina Szubarczyk#include <xenctrl.h>
2635b6eb9b45SPaulina Szubarczyk#include <xenstore.h>
2636b6eb9b45SPaulina Szubarczyk#include <xenevtchn.h>
2637b6eb9b45SPaulina Szubarczyk#include <xengnttab.h>
2638b6eb9b45SPaulina Szubarczyk#include <xenforeignmemory.h>
2639b6eb9b45SPaulina Szubarczyk#include <stdint.h>
2640b6eb9b45SPaulina Szubarczyk#include <xen/hvm/hvm_info_table.h>
2641b6eb9b45SPaulina Szubarczyk#if !defined(HVM_MAX_VCPUS)
2642b6eb9b45SPaulina Szubarczyk# error HVM_MAX_VCPUS not defined
2643b6eb9b45SPaulina Szubarczyk#endif
2644b6eb9b45SPaulina Szubarczykint main(void) {
2645b6eb9b45SPaulina Szubarczyk  xc_interface *xc = NULL;
2646b6eb9b45SPaulina Szubarczyk  xenforeignmemory_handle *xfmem;
2647b6eb9b45SPaulina Szubarczyk  xenevtchn_handle *xe;
2648b6eb9b45SPaulina Szubarczyk  xengnttab_handle *xg;
2649b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy_segment_t* seg = NULL;
2650b6eb9b45SPaulina Szubarczyk
2651b6eb9b45SPaulina Szubarczyk  xs_daemon_open();
2652b6eb9b45SPaulina Szubarczyk
2653b6eb9b45SPaulina Szubarczyk  xc = xc_interface_open(0, 0, 0);
2654b6eb9b45SPaulina Szubarczyk  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2655b6eb9b45SPaulina Szubarczyk  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2656b6eb9b45SPaulina Szubarczyk  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2657b6eb9b45SPaulina Szubarczyk  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2658b6eb9b45SPaulina Szubarczyk
2659b6eb9b45SPaulina Szubarczyk  xfmem = xenforeignmemory_open(0, 0);
2660b6eb9b45SPaulina Szubarczyk  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2661b6eb9b45SPaulina Szubarczyk
2662b6eb9b45SPaulina Szubarczyk  xe = xenevtchn_open(0, 0);
2663b6eb9b45SPaulina Szubarczyk  xenevtchn_fd(xe);
2664b6eb9b45SPaulina Szubarczyk
2665b6eb9b45SPaulina Szubarczyk  xg = xengnttab_open(0, 0);
2666b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy(xg, 0, seg);
2667b6eb9b45SPaulina Szubarczyk
2668b6eb9b45SPaulina Szubarczyk  return 0;
2669b6eb9b45SPaulina Szubarczyk}
2670b6eb9b45SPaulina SzubarczykEOF
2671b6eb9b45SPaulina Szubarczyk        compile_prog "" "$xen_libs $xen_stable_libs"
2672b6eb9b45SPaulina Szubarczyk      then
2673f1167ee6SJuergen Gross      xen_ctrl_version=40800
26741badb709SPaolo Bonzini      xen=enabled
2675b6eb9b45SPaulina Szubarczyk    elif
2676b6eb9b45SPaulina Szubarczyk        cat > $TMPC <<EOF &&
2677b6eb9b45SPaulina Szubarczyk/*
2678b6eb9b45SPaulina Szubarczyk * If we have stable libs the we don't want the libxc compat
2679b6eb9b45SPaulina Szubarczyk * layers, regardless of what CFLAGS we may have been given.
26805eeb39c2SIan Campbell */
26815eeb39c2SIan Campbell#undef XC_WANT_COMPAT_EVTCHN_API
26825eeb39c2SIan Campbell#undef XC_WANT_COMPAT_GNTTAB_API
26835eeb39c2SIan Campbell#undef XC_WANT_COMPAT_MAP_FOREIGN_API
26845eeb39c2SIan Campbell#include <xenctrl.h>
26855eeb39c2SIan Campbell#include <xenstore.h>
26865eeb39c2SIan Campbell#include <xenevtchn.h>
26875eeb39c2SIan Campbell#include <xengnttab.h>
26885eeb39c2SIan Campbell#include <xenforeignmemory.h>
26895eeb39c2SIan Campbell#include <stdint.h>
26905eeb39c2SIan Campbell#include <xen/hvm/hvm_info_table.h>
26915eeb39c2SIan Campbell#if !defined(HVM_MAX_VCPUS)
26925eeb39c2SIan Campbell# error HVM_MAX_VCPUS not defined
26935eeb39c2SIan Campbell#endif
26945eeb39c2SIan Campbellint main(void) {
26955eeb39c2SIan Campbell  xc_interface *xc = NULL;
26965eeb39c2SIan Campbell  xenforeignmemory_handle *xfmem;
26975eeb39c2SIan Campbell  xenevtchn_handle *xe;
26985eeb39c2SIan Campbell  xengnttab_handle *xg;
26995eeb39c2SIan Campbell
27005eeb39c2SIan Campbell  xs_daemon_open();
27015eeb39c2SIan Campbell
27025eeb39c2SIan Campbell  xc = xc_interface_open(0, 0, 0);
27035eeb39c2SIan Campbell  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
27045eeb39c2SIan Campbell  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
27055eeb39c2SIan Campbell  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
27065eeb39c2SIan Campbell  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
27075eeb39c2SIan Campbell
27085eeb39c2SIan Campbell  xfmem = xenforeignmemory_open(0, 0);
27095eeb39c2SIan Campbell  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
27105eeb39c2SIan Campbell
27115eeb39c2SIan Campbell  xe = xenevtchn_open(0, 0);
27125eeb39c2SIan Campbell  xenevtchn_fd(xe);
27135eeb39c2SIan Campbell
27145eeb39c2SIan Campbell  xg = xengnttab_open(0, 0);
27155eeb39c2SIan Campbell  xengnttab_map_grant_ref(xg, 0, 0, 0);
27165eeb39c2SIan Campbell
27175eeb39c2SIan Campbell  return 0;
27185eeb39c2SIan Campbell}
27195eeb39c2SIan CampbellEOF
27205eeb39c2SIan Campbell        compile_prog "" "$xen_libs $xen_stable_libs"
27215eeb39c2SIan Campbell      then
2722f1167ee6SJuergen Gross      xen_ctrl_version=40701
27231badb709SPaolo Bonzini      xen=enabled
2724cdadde39SRoger Pau Monne
2725cdadde39SRoger Pau Monne    # Xen 4.6
2726cdadde39SRoger Pau Monne    elif
2727cdadde39SRoger Pau Monne        cat > $TMPC <<EOF &&
2728cdadde39SRoger Pau Monne#include <xenctrl.h>
2729e108a3c1SAnthony PERARD#include <xenstore.h>
2730d5b93ddfSAnthony PERARD#include <stdint.h>
2731d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
2732d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
2733d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
2734d5b93ddfSAnthony PERARD#endif
2735d5b93ddfSAnthony PERARDint main(void) {
2736d5b93ddfSAnthony PERARD  xc_interface *xc;
2737d5b93ddfSAnthony PERARD  xs_daemon_open();
2738d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
2739d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2740d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
2741b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
27428688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2743d8b441a3SJan Beulich  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
274420a544c7SKonrad Rzeszutek Wilk  xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2745d8b441a3SJan Beulich  return 0;
2746d8b441a3SJan Beulich}
2747d8b441a3SJan BeulichEOF
2748d8b441a3SJan Beulich        compile_prog "" "$xen_libs"
2749d8b441a3SJan Beulich      then
2750f1167ee6SJuergen Gross      xen_ctrl_version=40600
27511badb709SPaolo Bonzini      xen=enabled
2752d8b441a3SJan Beulich
2753d8b441a3SJan Beulich    # Xen 4.5
2754d8b441a3SJan Beulich    elif
2755d8b441a3SJan Beulich        cat > $TMPC <<EOF &&
2756d8b441a3SJan Beulich#include <xenctrl.h>
2757d8b441a3SJan Beulich#include <xenstore.h>
2758d8b441a3SJan Beulich#include <stdint.h>
2759d8b441a3SJan Beulich#include <xen/hvm/hvm_info_table.h>
2760d8b441a3SJan Beulich#if !defined(HVM_MAX_VCPUS)
2761d8b441a3SJan Beulich# error HVM_MAX_VCPUS not defined
2762d8b441a3SJan Beulich#endif
2763d8b441a3SJan Beulichint main(void) {
2764d8b441a3SJan Beulich  xc_interface *xc;
2765d8b441a3SJan Beulich  xs_daemon_open();
2766d8b441a3SJan Beulich  xc = xc_interface_open(0, 0, 0);
2767d8b441a3SJan Beulich  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2768d8b441a3SJan Beulich  xc_gnttab_open(NULL, 0);
2769d8b441a3SJan Beulich  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2770d8b441a3SJan Beulich  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
27713996e85cSPaul Durrant  xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
27723996e85cSPaul Durrant  return 0;
27733996e85cSPaul Durrant}
27743996e85cSPaul DurrantEOF
27753996e85cSPaul Durrant        compile_prog "" "$xen_libs"
27763996e85cSPaul Durrant      then
2777f1167ee6SJuergen Gross      xen_ctrl_version=40500
27781badb709SPaolo Bonzini      xen=enabled
27793996e85cSPaul Durrant
27803996e85cSPaul Durrant    elif
27813996e85cSPaul Durrant        cat > $TMPC <<EOF &&
27823996e85cSPaul Durrant#include <xenctrl.h>
27833996e85cSPaul Durrant#include <xenstore.h>
27843996e85cSPaul Durrant#include <stdint.h>
27853996e85cSPaul Durrant#include <xen/hvm/hvm_info_table.h>
27863996e85cSPaul Durrant#if !defined(HVM_MAX_VCPUS)
27873996e85cSPaul Durrant# error HVM_MAX_VCPUS not defined
27883996e85cSPaul Durrant#endif
27893996e85cSPaul Durrantint main(void) {
27903996e85cSPaul Durrant  xc_interface *xc;
27913996e85cSPaul Durrant  xs_daemon_open();
27923996e85cSPaul Durrant  xc = xc_interface_open(0, 0, 0);
27933996e85cSPaul Durrant  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
27943996e85cSPaul Durrant  xc_gnttab_open(NULL, 0);
27953996e85cSPaul Durrant  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
27963996e85cSPaul Durrant  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
27978688e065SStefano Stabellini  return 0;
27988688e065SStefano Stabellini}
27998688e065SStefano StabelliniEOF
28008688e065SStefano Stabellini        compile_prog "" "$xen_libs"
280169deef08SPeter Maydell      then
2802f1167ee6SJuergen Gross      xen_ctrl_version=40200
28031badb709SPaolo Bonzini      xen=enabled
28048688e065SStefano Stabellini
2805e37630caSaliguori    else
28061badb709SPaolo Bonzini      if test "$xen" = "enabled" ; then
2807edfb07edSIan Campbell        feature_not_found "xen (unsupported version)" \
2808edfb07edSIan Campbell                          "Install a supported xen (xen 4.2 or newer)"
2809fc321b4bSJuan Quintela      fi
28101badb709SPaolo Bonzini      xen=disabled
2811e37630caSaliguori    fi
2812d5b93ddfSAnthony PERARD
28131badb709SPaolo Bonzini    if test "$xen" = enabled; then
2814f1167ee6SJuergen Gross      if test $xen_ctrl_version -ge 40701  ; then
2815582ea95fSMarc-André Lureau        xen_libs="$xen_libs $xen_stable_libs "
28165eeb39c2SIan Campbell      fi
2817d5b93ddfSAnthony PERARD    fi
2818e37630caSaliguori  fi
2819c1cdd9d5SJuergen Grossfi
2820e37630caSaliguori
2821d661d9a4SJustin Terry (VM)##########################################
28222da776dbSMichael R. Hines# RDMA needs OpenFabrics libraries
28232da776dbSMichael R. Hinesif test "$rdma" != "no" ; then
28242da776dbSMichael R. Hines  cat > $TMPC <<EOF
28252da776dbSMichael R. Hines#include <rdma/rdma_cma.h>
28262da776dbSMichael R. Hinesint main(void) { return 0; }
28272da776dbSMichael R. HinesEOF
2828ef6d4ccdSYuval Shaia  rdma_libs="-lrdmacm -libverbs -libumad"
28292da776dbSMichael R. Hines  if compile_prog "" "$rdma_libs" ; then
28302da776dbSMichael R. Hines    rdma="yes"
28312da776dbSMichael R. Hines  else
28322da776dbSMichael R. Hines    if test "$rdma" = "yes" ; then
28332da776dbSMichael R. Hines        error_exit \
2834ef6d4ccdSYuval Shaia            " OpenFabrics librdmacm/libibverbs/libibumad not present." \
28352da776dbSMichael R. Hines            " Your options:" \
2836ef6d4ccdSYuval Shaia            "  (1) Fast: Install infiniband packages (devel) from your distro." \
28372da776dbSMichael R. Hines            "  (2) Cleanest: Install libraries from www.openfabrics.org" \
28382da776dbSMichael R. Hines            "  (3) Also: Install softiwarp if you don't have RDMA hardware"
28392da776dbSMichael R. Hines    fi
28402da776dbSMichael R. Hines    rdma="no"
28412da776dbSMichael R. Hines  fi
28422da776dbSMichael R. Hinesfi
28432da776dbSMichael R. Hines
284421ab34c9SMarcel Apfelbaum##########################################
284521ab34c9SMarcel Apfelbaum# PVRDMA detection
284621ab34c9SMarcel Apfelbaum
284721ab34c9SMarcel Apfelbaumcat > $TMPC <<EOF &&
284821ab34c9SMarcel Apfelbaum#include <sys/mman.h>
284921ab34c9SMarcel Apfelbaum
285021ab34c9SMarcel Apfelbaumint
285121ab34c9SMarcel Apfelbaummain(void)
285221ab34c9SMarcel Apfelbaum{
285321ab34c9SMarcel Apfelbaum    char buf = 0;
285421ab34c9SMarcel Apfelbaum    void *addr = &buf;
285521ab34c9SMarcel Apfelbaum    addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED);
285621ab34c9SMarcel Apfelbaum
285721ab34c9SMarcel Apfelbaum    return 0;
285821ab34c9SMarcel Apfelbaum}
285921ab34c9SMarcel ApfelbaumEOF
286021ab34c9SMarcel Apfelbaum
286121ab34c9SMarcel Apfelbaumif test "$rdma" = "yes" ; then
286221ab34c9SMarcel Apfelbaum    case "$pvrdma" in
286321ab34c9SMarcel Apfelbaum    "")
286421ab34c9SMarcel Apfelbaum        if compile_prog "" ""; then
286521ab34c9SMarcel Apfelbaum            pvrdma="yes"
286621ab34c9SMarcel Apfelbaum        else
286721ab34c9SMarcel Apfelbaum            pvrdma="no"
286821ab34c9SMarcel Apfelbaum        fi
286921ab34c9SMarcel Apfelbaum        ;;
287021ab34c9SMarcel Apfelbaum    "yes")
287121ab34c9SMarcel Apfelbaum        if ! compile_prog "" ""; then
287221ab34c9SMarcel Apfelbaum            error_exit "PVRDMA is not supported since mremap is not implemented"
287321ab34c9SMarcel Apfelbaum        fi
287421ab34c9SMarcel Apfelbaum        pvrdma="yes"
287521ab34c9SMarcel Apfelbaum        ;;
287621ab34c9SMarcel Apfelbaum    "no")
287721ab34c9SMarcel Apfelbaum        pvrdma="no"
287821ab34c9SMarcel Apfelbaum        ;;
287921ab34c9SMarcel Apfelbaum    esac
288021ab34c9SMarcel Apfelbaumelse
288121ab34c9SMarcel Apfelbaum    if test "$pvrdma" = "yes" ; then
288221ab34c9SMarcel Apfelbaum        error_exit "PVRDMA requires rdma suppport"
288321ab34c9SMarcel Apfelbaum    fi
288421ab34c9SMarcel Apfelbaum    pvrdma="no"
288521ab34c9SMarcel Apfelbaumfi
288695c6bff3SBenoît Canet
2887ee108585SYuval Shaia# Let's see if enhanced reg_mr is supported
2888ee108585SYuval Shaiaif test "$pvrdma" = "yes" ; then
2889ee108585SYuval Shaia
2890ee108585SYuval Shaiacat > $TMPC <<EOF &&
2891ee108585SYuval Shaia#include <infiniband/verbs.h>
2892ee108585SYuval Shaia
2893ee108585SYuval Shaiaint
2894ee108585SYuval Shaiamain(void)
2895ee108585SYuval Shaia{
2896ee108585SYuval Shaia    struct ibv_mr *mr;
2897ee108585SYuval Shaia    struct ibv_pd *pd = NULL;
2898ee108585SYuval Shaia    size_t length = 10;
2899ee108585SYuval Shaia    uint64_t iova = 0;
2900ee108585SYuval Shaia    int access = 0;
2901ee108585SYuval Shaia    void *addr = NULL;
2902ee108585SYuval Shaia
2903ee108585SYuval Shaia    mr = ibv_reg_mr_iova(pd, addr, length, iova, access);
2904ee108585SYuval Shaia
2905ee108585SYuval Shaia    ibv_dereg_mr(mr);
2906ee108585SYuval Shaia
2907ee108585SYuval Shaia    return 0;
2908ee108585SYuval Shaia}
2909ee108585SYuval ShaiaEOF
2910ee108585SYuval Shaia    if ! compile_prog "" "-libverbs"; then
2911ee108585SYuval Shaia        QEMU_CFLAGS="$QEMU_CFLAGS -DLEGACY_RDMA_REG_MR"
2912ee108585SYuval Shaia    fi
2913ee108585SYuval Shaiafi
2914ee108585SYuval Shaia
291595c6bff3SBenoît Canet##########################################
2916c1bb86cdSEric Blake# xfsctl() probe, used for file-posix.c
2917dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
2918dce512deSChristoph Hellwig  cat > $TMPC << EOF
2919ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
2920dce512deSChristoph Hellwig#include <xfs/xfs.h>
2921dce512deSChristoph Hellwigint main(void)
2922dce512deSChristoph Hellwig{
2923dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
2924dce512deSChristoph Hellwig    return 0;
2925dce512deSChristoph Hellwig}
2926dce512deSChristoph HellwigEOF
2927dce512deSChristoph Hellwig  if compile_prog "" "" ; then
2928dce512deSChristoph Hellwig    xfs="yes"
2929dce512deSChristoph Hellwig  else
2930dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
2931e3a6e0daSzhaolichang      feature_not_found "xfs" "Install xfsprogs/xfslibs devel"
2932dce512deSChristoph Hellwig    fi
2933dce512deSChristoph Hellwig    xfs=no
2934dce512deSChristoph Hellwig  fi
2935dce512deSChristoph Hellwigfi
2936dce512deSChristoph Hellwig
2937dce512deSChristoph Hellwig##########################################
29388a16d273Sths# vde libraries probe
2939dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
29404baae0acSJuan Quintela  vde_libs="-lvdeplug"
29418a16d273Sths  cat > $TMPC << EOF
29428a16d273Sths#include <libvdeplug.h>
29434a7f0e06Spbrookint main(void)
29444a7f0e06Spbrook{
29454a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
2946fea08e08SPeter Maydell    char s[] = "";
2947fea08e08SPeter Maydell    vde_open(s, s, &a);
29484a7f0e06Spbrook    return 0;
29494a7f0e06Spbrook}
29508a16d273SthsEOF
295152166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
29524baae0acSJuan Quintela    vde=yes
2953dfb278bdSJuan Quintela  else
2954dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
295521684af0SStewart Smith      feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
2956dfb278bdSJuan Quintela    fi
2957dfb278bdSJuan Quintela    vde=no
29588a16d273Sths  fi
29598a16d273Sthsfi
29608a16d273Sths
29618a16d273Sths##########################################
29620a985b37SVincenzo Maffione# netmap support probe
29630a985b37SVincenzo Maffione# Apart from looking for netmap headers, we make sure that the host API version
29640a985b37SVincenzo Maffione# supports the netmap backend (>=11). The upper bound (15) is meant to simulate
29650a985b37SVincenzo Maffione# a minor/major version number. Minor new features will be marked with values up
29660a985b37SVincenzo Maffione# to 15, and if something happens that requires a change to the backend we will
29670a985b37SVincenzo Maffione# move above 15, submit the backend fixes and modify this two bounds.
296858952137SVincenzo Maffioneif test "$netmap" != "no" ; then
296958952137SVincenzo Maffione  cat > $TMPC << EOF
297058952137SVincenzo Maffione#include <inttypes.h>
297158952137SVincenzo Maffione#include <net/if.h>
297258952137SVincenzo Maffione#include <net/netmap.h>
297358952137SVincenzo Maffione#include <net/netmap_user.h>
29740a985b37SVincenzo Maffione#if (NETMAP_API < 11) || (NETMAP_API > 15)
29750a985b37SVincenzo Maffione#error
29760a985b37SVincenzo Maffione#endif
297758952137SVincenzo Maffioneint main(void) { return 0; }
297858952137SVincenzo MaffioneEOF
297958952137SVincenzo Maffione  if compile_prog "" "" ; then
298058952137SVincenzo Maffione    netmap=yes
298158952137SVincenzo Maffione  else
298258952137SVincenzo Maffione    if test "$netmap" = "yes" ; then
298358952137SVincenzo Maffione      feature_not_found "netmap"
298458952137SVincenzo Maffione    fi
298558952137SVincenzo Maffione    netmap=no
298658952137SVincenzo Maffione  fi
298758952137SVincenzo Maffionefi
298858952137SVincenzo Maffione
298958952137SVincenzo Maffione##########################################
2990ba4dd2aaSAlex Bennée# plugin linker support probe
2991ba4dd2aaSAlex Bennée
2992ba4dd2aaSAlex Bennéeif test "$plugins" != "no"; then
2993ba4dd2aaSAlex Bennée
2994ba4dd2aaSAlex Bennée    #########################################
2995ba4dd2aaSAlex Bennée    # See if --dynamic-list is supported by the linker
2996ba4dd2aaSAlex Bennée
2997ba4dd2aaSAlex Bennée    ld_dynamic_list="no"
2998ba4dd2aaSAlex Bennée    cat > $TMPTXT <<EOF
2999ba4dd2aaSAlex Bennée{
3000ba4dd2aaSAlex Bennée  foo;
3001ba4dd2aaSAlex Bennée};
3002ba4dd2aaSAlex BennéeEOF
3003ba4dd2aaSAlex Bennée
3004ba4dd2aaSAlex Bennée        cat > $TMPC <<EOF
3005ba4dd2aaSAlex Bennée#include <stdio.h>
3006ba4dd2aaSAlex Bennéevoid foo(void);
3007ba4dd2aaSAlex Bennée
3008ba4dd2aaSAlex Bennéevoid foo(void)
3009ba4dd2aaSAlex Bennée{
3010ba4dd2aaSAlex Bennée  printf("foo\n");
3011ba4dd2aaSAlex Bennée}
3012ba4dd2aaSAlex Bennée
3013ba4dd2aaSAlex Bennéeint main(void)
3014ba4dd2aaSAlex Bennée{
3015ba4dd2aaSAlex Bennée  foo();
3016ba4dd2aaSAlex Bennée  return 0;
3017ba4dd2aaSAlex Bennée}
3018ba4dd2aaSAlex BennéeEOF
3019ba4dd2aaSAlex Bennée
3020ba4dd2aaSAlex Bennée    if compile_prog "" "-Wl,--dynamic-list=$TMPTXT" ; then
3021ba4dd2aaSAlex Bennée        ld_dynamic_list="yes"
3022ba4dd2aaSAlex Bennée    fi
3023ba4dd2aaSAlex Bennée
3024ba4dd2aaSAlex Bennée    #########################################
3025ba4dd2aaSAlex Bennée    # See if -exported_symbols_list is supported by the linker
3026ba4dd2aaSAlex Bennée
3027ba4dd2aaSAlex Bennée    ld_exported_symbols_list="no"
3028ba4dd2aaSAlex Bennée    cat > $TMPTXT <<EOF
3029ba4dd2aaSAlex Bennée  _foo
3030ba4dd2aaSAlex BennéeEOF
3031ba4dd2aaSAlex Bennée
3032ba4dd2aaSAlex Bennée    if compile_prog "" "-Wl,-exported_symbols_list,$TMPTXT" ; then
3033ba4dd2aaSAlex Bennée        ld_exported_symbols_list="yes"
3034ba4dd2aaSAlex Bennée    fi
3035ba4dd2aaSAlex Bennée
3036ba4dd2aaSAlex Bennée    if test "$ld_dynamic_list" = "no" &&
3037ba4dd2aaSAlex Bennée       test "$ld_exported_symbols_list" = "no" ; then
3038ba4dd2aaSAlex Bennée        if test "$plugins" = "yes"; then
3039ba4dd2aaSAlex Bennée            error_exit \
3040ba4dd2aaSAlex Bennée                "Plugin support requires dynamic linking and specifying a set of symbols " \
3041ba4dd2aaSAlex Bennée                "that are exported to plugins. Unfortunately your linker doesn't " \
3042ba4dd2aaSAlex Bennée                "support the flag (--dynamic-list or -exported_symbols_list) used " \
3043ba4dd2aaSAlex Bennée                "for this purpose."
3044ba4dd2aaSAlex Bennée        else
3045ba4dd2aaSAlex Bennée            plugins="no"
3046ba4dd2aaSAlex Bennée        fi
3047ba4dd2aaSAlex Bennée    else
3048ba4dd2aaSAlex Bennée        plugins="yes"
3049ba4dd2aaSAlex Bennée    fi
3050ba4dd2aaSAlex Bennéefi
3051ba4dd2aaSAlex Bennée
3052ba4dd2aaSAlex Bennée##########################################
3053e18df141SAnthony Liguori# glib support probe
3054a52d28afSPaolo Bonzini
3055b4c6036fSDaniel P. Berrangéglib_req_ver=2.56
3056aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0
3057aa0d1f44SPaolo Bonziniif test "$modules" = yes; then
3058a88afc64SGerd Hoffmann    glib_modules="$glib_modules gmodule-export-2.0"
3059b906acacSPaolo Bonzinielif test "$plugins" = "yes"; then
3060b906acacSPaolo Bonzini    glib_modules="$glib_modules gmodule-no-export-2.0"
306154cb65d8SEmilio G. Cotafi
3062e26110cfSFam Zheng
3063aa0d1f44SPaolo Bonzinifor i in $glib_modules; do
3064e26110cfSFam Zheng    if $pkg_config --atleast-version=$glib_req_ver $i; then
306589138857SStefan Weil        glib_cflags=$($pkg_config --cflags $i)
306689138857SStefan Weil        glib_libs=$($pkg_config --libs $i)
3067e18df141SAnthony Liguori    else
3068e26110cfSFam Zheng        error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3069e26110cfSFam Zheng    fi
3070e26110cfSFam Zhengdone
3071e26110cfSFam Zheng
3072215b0c2fSPaolo Bonzini# This workaround is required due to a bug in pkg-config file for glib as it
3073215b0c2fSPaolo Bonzini# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
3074215b0c2fSPaolo Bonzini
3075215b0c2fSPaolo Bonziniif test "$static" = yes && test "$mingw32" = yes; then
3076215b0c2fSPaolo Bonzini    glib_cflags="-DGLIB_STATIC_COMPILATION $glib_cflags"
3077215b0c2fSPaolo Bonzinifi
3078215b0c2fSPaolo Bonzini
307920cf7b8eSDenis Plotnikovif ! test "$gio" = "no"; then
308020cf7b8eSDenis Plotnikov    pass=no
3081f876b765SMarc-André Lureau    if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
3082f876b765SMarc-André Lureau        gio_cflags=$($pkg_config --cflags gio-2.0)
3083f876b765SMarc-André Lureau        gio_libs=$($pkg_config --libs gio-2.0)
308425a97a56SMarc-André Lureau        gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0)
30855ecfb76cSPaolo Bonzini        if ! has "$gdbus_codegen"; then
30860dba4897SMarc-André Lureau            gdbus_codegen=
30870dba4897SMarc-André Lureau        fi
308876346b62SPeter Maydell        # Check that the libraries actually work -- Ubuntu 18.04 ships
308976346b62SPeter Maydell        # with pkg-config --static --libs data for gio-2.0 that is missing
309076346b62SPeter Maydell        # -lblkid and will give a link error.
309113ceae66SPeter Maydell        cat > $TMPC <<EOF
309213ceae66SPeter Maydell#include <gio/gio.h>
309313ceae66SPeter Maydellint main(void)
309413ceae66SPeter Maydell{
309513ceae66SPeter Maydell    g_dbus_proxy_new_sync(0, 0, 0, 0, 0, 0, 0, 0);
309613ceae66SPeter Maydell    return 0;
309713ceae66SPeter Maydell}
309813ceae66SPeter MaydellEOF
309913ceae66SPeter Maydell        if compile_prog "$gio_cflags" "$gio_libs" ; then
310020cf7b8eSDenis Plotnikov            pass=yes
310176346b62SPeter Maydell        else
310220cf7b8eSDenis Plotnikov            pass=no
3103f876b765SMarc-André Lureau        fi
3104f876b765SMarc-André Lureau
310520cf7b8eSDenis Plotnikov        if test "$pass" = "yes" &&
310620cf7b8eSDenis Plotnikov            $pkg_config --atleast-version=$glib_req_ver gio-unix-2.0; then
310725a97a56SMarc-André Lureau            gio_cflags="$gio_cflags $($pkg_config --cflags gio-unix-2.0)"
310825a97a56SMarc-André Lureau            gio_libs="$gio_libs $($pkg_config --libs gio-unix-2.0)"
310925a97a56SMarc-André Lureau        fi
311020cf7b8eSDenis Plotnikov    fi
311120cf7b8eSDenis Plotnikov
311220cf7b8eSDenis Plotnikov    if test "$pass" = "no"; then
311320cf7b8eSDenis Plotnikov        if test "$gio" = "yes"; then
311420cf7b8eSDenis Plotnikov            feature_not_found "gio" "Install libgio >= 2.0"
311520cf7b8eSDenis Plotnikov        else
311620cf7b8eSDenis Plotnikov            gio=no
311720cf7b8eSDenis Plotnikov        fi
311820cf7b8eSDenis Plotnikov    else
311920cf7b8eSDenis Plotnikov        gio=yes
312020cf7b8eSDenis Plotnikov    fi
312120cf7b8eSDenis Plotnikovfi
312225a97a56SMarc-André Lureau
3123977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the
3124977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches
3125977a82abSDaniel P. Berrange# problems on multi-arch where people try to build
3126977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers
3127977a82abSDaniel P. Berrangecat > $TMPC <<EOF
3128977a82abSDaniel P. Berrange#include <glib.h>
3129977a82abSDaniel P. Berrange#include <unistd.h>
3130977a82abSDaniel P. Berrange
3131977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \
3132977a82abSDaniel P. Berrange  typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3133977a82abSDaniel P. Berrange
3134977a82abSDaniel P. Berrangeint main(void) {
3135977a82abSDaniel P. Berrange   QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3136977a82abSDaniel P. Berrange   return 0;
3137977a82abSDaniel P. Berrange}
3138977a82abSDaniel P. BerrangeEOF
3139977a82abSDaniel P. Berrange
3140215b0c2fSPaolo Bonziniif ! compile_prog "$glib_cflags" "$glib_libs" ; then
3141977a82abSDaniel P. Berrange    error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3142977a82abSDaniel P. Berrange               "You probably need to set PKG_CONFIG_LIBDIR"\
3143977a82abSDaniel P. Berrange	       "to point to the right pkg-config files for your"\
3144977a82abSDaniel P. Berrange	       "build target"
3145977a82abSDaniel P. Berrangefi
3146977a82abSDaniel P. Berrange
31479bda600bSEric Blake# Silence clang warnings triggered by glib < 2.57.2
31489bda600bSEric Blakecat > $TMPC << EOF
31499bda600bSEric Blake#include <glib.h>
31509bda600bSEric Blaketypedef struct Foo {
31519bda600bSEric Blake    int i;
31529bda600bSEric Blake} Foo;
31539bda600bSEric Blakestatic void foo_free(Foo *f)
31549bda600bSEric Blake{
31559bda600bSEric Blake    g_free(f);
31569bda600bSEric Blake}
31579bda600bSEric BlakeG_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free);
31589bda600bSEric Blakeint main(void) { return 0; }
31599bda600bSEric BlakeEOF
31609bda600bSEric Blakeif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
31619bda600bSEric Blake    if cc_has_warning_flag "-Wno-unused-function"; then
31629bda600bSEric Blake        glib_cflags="$glib_cflags -Wno-unused-function"
31635770e8afSPaolo Bonzini        CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -Wno-unused-function"
31649bda600bSEric Blake    fi
31659bda600bSEric Blakefi
31669bda600bSEric Blake
3167e26110cfSFam Zheng##########################################
3168e26110cfSFam Zheng# SHA command probe for modules
3169e26110cfSFam Zhengif test "$modules" = yes; then
3170e26110cfSFam Zheng    shacmd_probe="sha1sum sha1 shasum"
3171e26110cfSFam Zheng    for c in $shacmd_probe; do
31728ccefb91SFam Zheng        if has $c; then
3173e26110cfSFam Zheng            shacmd="$c"
3174e26110cfSFam Zheng            break
3175e26110cfSFam Zheng        fi
3176e26110cfSFam Zheng    done
3177e26110cfSFam Zheng    if test "$shacmd" = ""; then
3178e26110cfSFam Zheng        error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3179e26110cfSFam Zheng    fi
3180e18df141SAnthony Liguorifi
3181e18df141SAnthony Liguori
3182e18df141SAnthony Liguori##########################################
3183e5d355d1Saliguori# pthread probe
31844b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
31853c529d93Saliguori
3186e5d355d1Saliguoripthread=no
3187414f0dabSblueswir1cat > $TMPC << EOF
31883c529d93Saliguori#include <pthread.h>
31897a42bbe4SStefan Weilstatic void *f(void *p) { return NULL; }
31907a42bbe4SStefan Weilint main(void) {
31917a42bbe4SStefan Weil  pthread_t thread;
31927a42bbe4SStefan Weil  pthread_create(&thread, 0, f, 0);
31937a42bbe4SStefan Weil  return 0;
31947a42bbe4SStefan Weil}
3195414f0dabSblueswir1EOF
3196bd00d539SAndreas Färberif compile_prog "" "" ; then
3197bd00d539SAndreas Färber  pthread=yes
3198bd00d539SAndreas Färberelse
3199de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
320052166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
3201e5d355d1Saliguori      pthread=yes
3202de65fe0fSSebastian Herbszt      break
3203414f0dabSblueswir1    fi
3204de65fe0fSSebastian Herbszt  done
3205bd00d539SAndreas Färberfi
3206414f0dabSblueswir1
3207e633a5c6SEric Blakeif test "$mingw32" != yes && test "$pthread" = no; then
320876ad07a4SPeter Maydell  error_exit "pthread check failed" \
320976ad07a4SPeter Maydell      "Make sure to have the pthread libs and headers installed."
3210e5d355d1Saliguorifi
3211e5d355d1Saliguori
3212479a5747SRoman Bolshakov# check for pthread_setname_np with thread id
3213479a5747SRoman Bolshakovpthread_setname_np_w_tid=no
32145c312079SDr. David Alan Gilbertcat > $TMPC << EOF
32155c312079SDr. David Alan Gilbert#include <pthread.h>
32165c312079SDr. David Alan Gilbert
32175c312079SDr. David Alan Gilbertstatic void *f(void *p) { return NULL; }
32185c312079SDr. David Alan Gilbertint main(void)
32195c312079SDr. David Alan Gilbert{
32205c312079SDr. David Alan Gilbert    pthread_t thread;
32215c312079SDr. David Alan Gilbert    pthread_create(&thread, 0, f, 0);
32225c312079SDr. David Alan Gilbert    pthread_setname_np(thread, "QEMU");
32235c312079SDr. David Alan Gilbert    return 0;
32245c312079SDr. David Alan Gilbert}
32255c312079SDr. David Alan GilbertEOF
32265c312079SDr. David Alan Gilbertif compile_prog "" "$pthread_lib" ; then
3227479a5747SRoman Bolshakov  pthread_setname_np_w_tid=yes
3228479a5747SRoman Bolshakovfi
3229479a5747SRoman Bolshakov
3230479a5747SRoman Bolshakov# check for pthread_setname_np without thread id
3231479a5747SRoman Bolshakovpthread_setname_np_wo_tid=no
3232479a5747SRoman Bolshakovcat > $TMPC << EOF
3233479a5747SRoman Bolshakov#include <pthread.h>
3234479a5747SRoman Bolshakov
323512a9b8d8SThomas Huthstatic void *f(void *p) { pthread_setname_np("QEMU"); return NULL; }
3236479a5747SRoman Bolshakovint main(void)
3237479a5747SRoman Bolshakov{
3238479a5747SRoman Bolshakov    pthread_t thread;
3239479a5747SRoman Bolshakov    pthread_create(&thread, 0, f, 0);
3240479a5747SRoman Bolshakov    return 0;
3241479a5747SRoman Bolshakov}
3242479a5747SRoman BolshakovEOF
3243479a5747SRoman Bolshakovif compile_prog "" "$pthread_lib" ; then
3244479a5747SRoman Bolshakov  pthread_setname_np_wo_tid=yes
32455c312079SDr. David Alan Gilbertfi
32465c312079SDr. David Alan Gilbert
3247bf9298b9Saliguori##########################################
3248b10d49d7SPino Toscano# libssh probe
3249b10d49d7SPino Toscanoif test "$libssh" != "no" ; then
3250b4c10fc6SThomas Huth  if $pkg_config --exists "libssh >= 0.8.7"; then
3251b10d49d7SPino Toscano    libssh_cflags=$($pkg_config libssh --cflags)
3252b10d49d7SPino Toscano    libssh_libs=$($pkg_config libssh --libs)
3253b10d49d7SPino Toscano    libssh=yes
32540a12ec87SRichard W.M. Jones  else
3255b10d49d7SPino Toscano    if test "$libssh" = "yes" ; then
3256b10d49d7SPino Toscano      error_exit "libssh required for --enable-libssh"
32570a12ec87SRichard W.M. Jones    fi
3258b10d49d7SPino Toscano    libssh=no
32590a12ec87SRichard W.M. Jones  fi
32600a12ec87SRichard W.M. Jonesfi
32610a12ec87SRichard W.M. Jones
32620a12ec87SRichard W.M. Jones##########################################
32635c6c3a6cSChristoph Hellwig# linux-aio probe
32645c6c3a6cSChristoph Hellwig
32655c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
32665c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
32675c6c3a6cSChristoph Hellwig#include <libaio.h>
32685c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
3269832ce9c2SScott Wood#include <stddef.h>
32705c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
32715c6c3a6cSChristoph HellwigEOF
32725c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
32735c6c3a6cSChristoph Hellwig    linux_aio=yes
32745c6c3a6cSChristoph Hellwig  else
32755c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
327621684af0SStewart Smith      feature_not_found "linux AIO" "Install libaio devel"
32775c6c3a6cSChristoph Hellwig    fi
32783cfcae3cSLuiz Capitulino    linux_aio=no
32795c6c3a6cSChristoph Hellwig  fi
32805c6c3a6cSChristoph Hellwigfi
32815c6c3a6cSChristoph Hellwig
32825c6c3a6cSChristoph Hellwig##########################################
32837aaa6a16SPaolo Bonzini# TPM emulation is only on POSIX
32843b8acc11SPaolo Bonzini
32857aaa6a16SPaolo Bonziniif test "$tpm" = ""; then
32867aaa6a16SPaolo Bonzini  if test "$mingw32" = "yes"; then
32877aaa6a16SPaolo Bonzini    tpm=no
32883b8acc11SPaolo Bonzini  else
32897aaa6a16SPaolo Bonzini    tpm=yes
32907aaa6a16SPaolo Bonzini  fi
32917aaa6a16SPaolo Bonzinielif test "$tpm" = "yes"; then
32927aaa6a16SPaolo Bonzini  if test "$mingw32" = "yes" ; then
32937aaa6a16SPaolo Bonzini    error_exit "TPM emulation only available on POSIX systems"
32947aaa6a16SPaolo Bonzini  fi
32953b8acc11SPaolo Bonzinifi
32963b8acc11SPaolo Bonzini
32973b8acc11SPaolo Bonzini##########################################
3298bf9298b9Saliguori# iovec probe
3299bf9298b9Saliguoricat > $TMPC <<EOF
3300db34f0b3Sblueswir1#include <sys/types.h>
3301bf9298b9Saliguori#include <sys/uio.h>
3302db34f0b3Sblueswir1#include <unistd.h>
3303f91f9beeSStefan Weilint main(void) { return sizeof(struct iovec); }
3304bf9298b9SaliguoriEOF
3305bf9298b9Saliguoriiovec=no
330652166aa0SJuan Quintelaif compile_prog "" "" ; then
3307bf9298b9Saliguori  iovec=yes
3308bf9298b9Saliguorifi
3309bf9298b9Saliguori
3310f652e6afSaurel32##########################################
3311f652e6afSaurel32# fdt probe
3312e169e1e1SPeter Maydell
3313fbb4121dSPaolo Bonzinicase "$fdt" in
3314fbb4121dSPaolo Bonzini  auto | enabled | internal)
3315fbb4121dSPaolo Bonzini    # Simpler to always update submodule, even if not needed.
3316aef45d51SDaniel P. Berrange    git_submodules="${git_submodules} dtc"
3317fbb4121dSPaolo Bonzini    ;;
3318fbb4121dSPaolo Bonziniesac
3319f652e6afSaurel32
332020ff075bSMichael Walle##########################################
33219d49bcf6SMarkus Armbruster# opengl probe (for sdl2, gtk)
3322b1546f32SGerd Hoffmann
3323da076ffeSGerd Hoffmannif test "$opengl" != "no" ; then
3324bc6a3565SAkihiko Odaki  epoxy=no
3325bc6a3565SAkihiko Odaki  if $pkg_config epoxy; then
3326bc6a3565SAkihiko Odaki    cat > $TMPC << EOF
3327bc6a3565SAkihiko Odaki#include <epoxy/egl.h>
3328bc6a3565SAkihiko Odakiint main(void) { return 0; }
3329bc6a3565SAkihiko OdakiEOF
3330bc6a3565SAkihiko Odaki    if compile_prog "" "" ; then
3331bc6a3565SAkihiko Odaki      epoxy=yes
3332bc6a3565SAkihiko Odaki    fi
3333bc6a3565SAkihiko Odaki  fi
3334bc6a3565SAkihiko Odaki
3335bc6a3565SAkihiko Odaki  if test "$epoxy" = "yes" ; then
3336bc6a3565SAkihiko Odaki    opengl_cflags="$($pkg_config --cflags epoxy)"
3337bc6a3565SAkihiko Odaki    opengl_libs="$($pkg_config --libs epoxy)"
3338da076ffeSGerd Hoffmann    opengl=yes
333920ff075bSMichael Walle  else
3340da076ffeSGerd Hoffmann    if test "$opengl" = "yes" ; then
3341bc6a3565SAkihiko Odaki      feature_not_found "opengl" "Please install epoxy with EGL"
334220ff075bSMichael Walle    fi
3343f676c67eSJeremy White    opengl_cflags=""
3344da076ffeSGerd Hoffmann    opengl_libs=""
3345da076ffeSGerd Hoffmann    opengl=no
334620ff075bSMichael Walle  fi
334720ff075bSMichael Wallefi
334820ff075bSMichael Walle
3349dcc38d1cSMarcelo Tosatti##########################################
3350a99d57bbSWanlong Gao# libnuma probe
3351a99d57bbSWanlong Gao
3352a99d57bbSWanlong Gaoif test "$numa" != "no" ; then
3353a99d57bbSWanlong Gao  cat > $TMPC << EOF
3354a99d57bbSWanlong Gao#include <numa.h>
3355a99d57bbSWanlong Gaoint main(void) { return numa_available(); }
3356a99d57bbSWanlong GaoEOF
3357a99d57bbSWanlong Gao
3358a99d57bbSWanlong Gao  if compile_prog "" "-lnuma" ; then
3359a99d57bbSWanlong Gao    numa=yes
3360ab318051SMarc-André Lureau    numa_libs="-lnuma"
3361a99d57bbSWanlong Gao  else
3362a99d57bbSWanlong Gao    if test "$numa" = "yes" ; then
3363a99d57bbSWanlong Gao      feature_not_found "numa" "install numactl devel"
3364a99d57bbSWanlong Gao    fi
3365a99d57bbSWanlong Gao    numa=no
3366a99d57bbSWanlong Gao  fi
3367a99d57bbSWanlong Gaofi
3368a99d57bbSWanlong Gao
3369aa087962SPaolo Bonzinimalloc=system
33707b01cb97SAlexandre Derumierif test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
33717b01cb97SAlexandre Derumier    echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
33727b01cb97SAlexandre Derumier    exit 1
3373aa087962SPaolo Bonzinielif test "$tcmalloc" = "yes" ; then
3374aa087962SPaolo Bonzini    malloc=tcmalloc
3375aa087962SPaolo Bonzinielif test "$jemalloc" = "yes" ; then
3376aa087962SPaolo Bonzini    malloc=jemalloc
33777b01cb97SAlexandre Derumierfi
33787b01cb97SAlexandre Derumier
3379955727d2SCortland Tölva# check for usbfs
3380955727d2SCortland Tölvahave_usbfs=no
3381955727d2SCortland Tölvaif test "$linux_user" = "yes"; then
338296566d09SThomas Petazzoni  cat > $TMPC << EOF
338396566d09SThomas Petazzoni#include <linux/usbdevice_fs.h>
338496566d09SThomas Petazzoni
338596566d09SThomas Petazzoni#ifndef USBDEVFS_GET_CAPABILITIES
338696566d09SThomas Petazzoni#error "USBDEVFS_GET_CAPABILITIES undefined"
338796566d09SThomas Petazzoni#endif
338896566d09SThomas Petazzoni
338996566d09SThomas Petazzoni#ifndef USBDEVFS_DISCONNECT_CLAIM
339096566d09SThomas Petazzoni#error "USBDEVFS_DISCONNECT_CLAIM undefined"
339196566d09SThomas Petazzoni#endif
339296566d09SThomas Petazzoni
339396566d09SThomas Petazzoniint main(void)
339496566d09SThomas Petazzoni{
339596566d09SThomas Petazzoni    return 0;
339696566d09SThomas Petazzoni}
339796566d09SThomas PetazzoniEOF
339896566d09SThomas Petazzoni  if compile_prog "" ""; then
3399955727d2SCortland Tölva    have_usbfs=yes
3400955727d2SCortland Tölva  fi
3401955727d2SCortland Tölvafi
3402751bcc39SMarc-André Lureau
3403de5071c5SBlue Swirl##########################################
3404cd4ec0b4SGerd Hoffmann# spice probe
340558d3f3ffSGerd Hoffmannif test "$spice_protocol" != "no" ; then
340658d3f3ffSGerd Hoffmann  spice_protocol_cflags=$($pkg_config --cflags spice-protocol 2>/dev/null)
340758d3f3ffSGerd Hoffmann  if $pkg_config --atleast-version=0.12.3 spice-protocol; then
340858d3f3ffSGerd Hoffmann    spice_protocol="yes"
340958d3f3ffSGerd Hoffmann  else
341058d3f3ffSGerd Hoffmann    if test "$spice_protocol" = "yes" ; then
341158d3f3ffSGerd Hoffmann      feature_not_found "spice_protocol" \
341258d3f3ffSGerd Hoffmann          "Install spice-protocol(>=0.12.3) devel"
341358d3f3ffSGerd Hoffmann    fi
341458d3f3ffSGerd Hoffmann    spice_protocol="no"
341558d3f3ffSGerd Hoffmann  fi
341658d3f3ffSGerd Hoffmannfi
341758d3f3ffSGerd Hoffmann
3418cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
3419cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
3420cd4ec0b4SGerd Hoffmann#include <spice.h>
3421cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
3422cd4ec0b4SGerd HoffmannEOF
3423710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
3424710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
34251b63665cSMarc-André Lureau  if $pkg_config --atleast-version=0.12.5 spice-server && \
342658d3f3ffSGerd Hoffmann     test "$spice_protocol" = "yes" && \
3427cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
3428cd4ec0b4SGerd Hoffmann    spice="yes"
3429cd4ec0b4SGerd Hoffmann  else
3430cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
34318efc9363SHu Tao      feature_not_found "spice" \
343258d3f3ffSGerd Hoffmann          "Install spice-server(>=0.12.5) devel"
3433cd4ec0b4SGerd Hoffmann    fi
3434cd4ec0b4SGerd Hoffmann    spice="no"
3435cd4ec0b4SGerd Hoffmann  fi
3436cd4ec0b4SGerd Hoffmannfi
3437cd4ec0b4SGerd Hoffmann
3438cd4ec0b4SGerd Hoffmann##########################################
3439d9840e25STomoki Sekiyama# check if we have VSS SDK headers for win
3440d9840e25STomoki Sekiyama
3441e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
3442e633a5c6SEric Blake        test "$vss_win32_sdk" != "no" ; then
3443d9840e25STomoki Sekiyama  case "$vss_win32_sdk" in
3444690604f6SMichael Roth    "")   vss_win32_include="-isystem $source_path" ;;
3445d9840e25STomoki Sekiyama    *\ *) # The SDK is installed in "Program Files" by default, but we cannot
3446d9840e25STomoki Sekiyama          # handle path with spaces. So we symlink the headers into ".sdk/vss".
3447690604f6SMichael Roth          vss_win32_include="-isystem $source_path/.sdk/vss"
3448d9840e25STomoki Sekiyama	  symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
3449d9840e25STomoki Sekiyama	  ;;
3450690604f6SMichael Roth    *)    vss_win32_include="-isystem $vss_win32_sdk"
3451d9840e25STomoki Sekiyama  esac
3452d9840e25STomoki Sekiyama  cat > $TMPC << EOF
3453d9840e25STomoki Sekiyama#define __MIDL_user_allocate_free_DEFINED__
3454d9840e25STomoki Sekiyama#include <inc/win2003/vss.h>
3455d9840e25STomoki Sekiyamaint main(void) { return VSS_CTX_BACKUP; }
3456d9840e25STomoki SekiyamaEOF
3457d9840e25STomoki Sekiyama  if compile_prog "$vss_win32_include" "" ; then
3458d9840e25STomoki Sekiyama    guest_agent_with_vss="yes"
3459d9840e25STomoki Sekiyama    QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
3460315d3184SFam Zheng    libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
3461f33ca81fSMichael Roth    qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
3462d9840e25STomoki Sekiyama  else
3463d9840e25STomoki Sekiyama    if test "$vss_win32_sdk" != "" ; then
3464d9840e25STomoki Sekiyama      echo "ERROR: Please download and install Microsoft VSS SDK:"
3465d9840e25STomoki Sekiyama      echo "ERROR:   http://www.microsoft.com/en-us/download/details.aspx?id=23490"
3466d9840e25STomoki Sekiyama      echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
3467d9840e25STomoki Sekiyama      echo "ERROR:   scripts/extract-vsssdk-headers setup.exe"
3468d9840e25STomoki Sekiyama      echo "ERROR: The headers are extracted in the directory \`inc'."
3469d9840e25STomoki Sekiyama      feature_not_found "VSS support"
3470d9840e25STomoki Sekiyama    fi
3471d9840e25STomoki Sekiyama    guest_agent_with_vss="no"
3472d9840e25STomoki Sekiyama  fi
3473d9840e25STomoki Sekiyamafi
3474d9840e25STomoki Sekiyama
3475d9840e25STomoki Sekiyama##########################################
3476d9840e25STomoki Sekiyama# lookup Windows platform SDK (if not specified)
3477d9840e25STomoki Sekiyama# The SDK is needed only to build .tlb (type library) file of guest agent
3478d9840e25STomoki Sekiyama# VSS provider from the source. It is usually unnecessary because the
3479d9840e25STomoki Sekiyama# pre-compiled .tlb file is included.
3480d9840e25STomoki Sekiyama
3481e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
3482e633a5c6SEric Blake        test "$guest_agent_with_vss" = "yes" ; then
3483d9840e25STomoki Sekiyama  if test -z "$win_sdk"; then
3484d9840e25STomoki Sekiyama    programfiles="$PROGRAMFILES"
3485d9840e25STomoki Sekiyama    test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
3486d9840e25STomoki Sekiyama    if test -n "$programfiles"; then
3487d9840e25STomoki Sekiyama      win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
3488d9840e25STomoki Sekiyama    else
3489d9840e25STomoki Sekiyama      feature_not_found "Windows SDK"
3490d9840e25STomoki Sekiyama    fi
3491d9840e25STomoki Sekiyama  elif test "$win_sdk" = "no"; then
3492d9840e25STomoki Sekiyama    win_sdk=""
3493d9840e25STomoki Sekiyama  fi
3494d9840e25STomoki Sekiyamafi
3495d9840e25STomoki Sekiyama
3496d9840e25STomoki Sekiyama##########################################
349750cbebb9SMichael Roth# check if mingw environment provides a recent ntddscsi.h
3498e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no"; then
349950cbebb9SMichael Roth  cat > $TMPC << EOF
350050cbebb9SMichael Roth#include <windows.h>
350150cbebb9SMichael Roth#include <ntddscsi.h>
350250cbebb9SMichael Rothint main(void) {
350350cbebb9SMichael Roth#if !defined(IOCTL_SCSI_GET_ADDRESS)
350450cbebb9SMichael Roth#error Missing required ioctl definitions
350550cbebb9SMichael Roth#endif
350650cbebb9SMichael Roth  SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
350750cbebb9SMichael Roth  return addr.Lun;
350850cbebb9SMichael Roth}
350950cbebb9SMichael RothEOF
351050cbebb9SMichael Roth  if compile_prog "" "" ; then
351150cbebb9SMichael Roth    guest_agent_ntddscsi=yes
3512996b9cdcSMatt Hines    libs_qga="-lsetupapi -lcfgmgr32 $libs_qga"
351350cbebb9SMichael Roth  fi
351450cbebb9SMichael Rothfi
351550cbebb9SMichael Roth
351650cbebb9SMichael Roth##########################################
35178ca80760SRichard Henderson# capstone
35188ca80760SRichard Henderson
3519e219c499SRichard Hendersoncase "$capstone" in
35208b18cdbfSRichard Henderson  auto | enabled | internal)
35218b18cdbfSRichard Henderson    # Simpler to always update submodule, even if not needed.
3522e219c499SRichard Henderson    git_submodules="${git_submodules} capstone"
3523e219c499SRichard Henderson    ;;
3524e219c499SRichard Hendersonesac
35258ca80760SRichard Henderson
35268ca80760SRichard Henderson##########################################
35270a852417SPaul Durrant# check if we have posix_syslog
35280a852417SPaul Durrant
35290a852417SPaul Durrantposix_syslog=no
35300a852417SPaul Durrantcat > $TMPC << EOF
35310a852417SPaul Durrant#include <syslog.h>
35320a852417SPaul Durrantint main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
35330a852417SPaul DurrantEOF
35340a852417SPaul Durrantif compile_prog "" "" ; then
35350a852417SPaul Durrant    posix_syslog=yes
35360a852417SPaul Durrantfi
35370a852417SPaul Durrant
35380a852417SPaul Durrant##########################################
353994a420b1SStefan Hajnoczi# check if trace backend exists
354094a420b1SStefan Hajnoczi
35415b808275SLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends  > /dev/null 2> /dev/null
354294a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
35435b808275SLluís Vilanova  error_exit "invalid trace backends" \
35445b808275SLluís Vilanova      "Please choose supported trace backends."
354594a420b1SStefan Hajnoczifi
354694a420b1SStefan Hajnoczi
35477e24e92aSStefan Hajnoczi##########################################
35487e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
35495b808275SLluís Vilanovaif have_backend "ust"; then
3550bf15f63cSMohamad Gebai  if $pkg_config lttng-ust --exists; then
355189138857SStefan Weil    lttng_ust_libs=$($pkg_config --libs lttng-ust)
35527e24e92aSStefan Hajnoczi  else
3553bf15f63cSMohamad Gebai    error_exit "Trace backend 'ust' missing lttng-ust header files"
35547e24e92aSStefan Hajnoczi  fi
35557e24e92aSStefan Hajnoczifi
3556b3d08c02SDaniel P. Berrange
3557b3d08c02SDaniel P. Berrange##########################################
3558b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
35595b808275SLluís Vilanovaif have_backend "dtrace"; then
3560b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
356176ad07a4SPeter Maydell    error_exit "dtrace command is not found in PATH $PATH"
3562b3d08c02SDaniel P. Berrange  fi
3563c276b17dSDaniel P. Berrange  trace_backend_stap="no"
3564c276b17dSDaniel P. Berrange  if has 'stap' ; then
3565c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
35664b265c79SStefan Hajnoczi
35674b265c79SStefan Hajnoczi    # Workaround to avoid dtrace(1) producing a file with 'hidden' symbol
35684b265c79SStefan Hajnoczi    # visibility. Define STAP_SDT_V2 to produce 'default' symbol visibility
35694b265c79SStefan Hajnoczi    # instead. QEMU --enable-modules depends on this because the SystemTap
35704b265c79SStefan Hajnoczi    # semaphores are linked into the main binary and not the module's shared
35714b265c79SStefan Hajnoczi    # object.
35724b265c79SStefan Hajnoczi    QEMU_CFLAGS="$QEMU_CFLAGS -DSTAP_SDT_V2"
3573c276b17dSDaniel P. Berrange  fi
3574b3d08c02SDaniel P. Berrangefi
3575b3d08c02SDaniel P. Berrange
35767e24e92aSStefan Hajnoczi##########################################
3577519175a2SAlex Barcelo# check and set a backend for coroutine
3578d0e2fce5SAneesh Kumar K.V
35797c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback
358033c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows
358133c53c54SDaniel P. Berrange# specific one.
35827c2acc70SPeter Maydell
35837c2acc70SPeter Maydellucontext_works=no
3584d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
3585d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
3586d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
3587cdf84806SPeter Maydell#ifdef __stub_makecontext
3588cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
3589cdf84806SPeter Maydell#endif
359075cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
3591d0e2fce5SAneesh Kumar K.VEOF
3592d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
35937c2acc70SPeter Maydell    ucontext_works=yes
3594d0e2fce5SAneesh Kumar K.V  fi
3595519175a2SAlex Barcelofi
35967c2acc70SPeter Maydell
35977c2acc70SPeter Maydellif test "$coroutine" = ""; then
35987c2acc70SPeter Maydell  if test "$mingw32" = "yes"; then
35997c2acc70SPeter Maydell    coroutine=win32
36007c2acc70SPeter Maydell  elif test "$ucontext_works" = "yes"; then
36017c2acc70SPeter Maydell    coroutine=ucontext
3602519175a2SAlex Barcelo  else
36037c2acc70SPeter Maydell    coroutine=sigaltstack
36047c2acc70SPeter Maydell  fi
36057c2acc70SPeter Maydellelse
36067c2acc70SPeter Maydell  case $coroutine in
36077c2acc70SPeter Maydell  windows)
36087c2acc70SPeter Maydell    if test "$mingw32" != "yes"; then
36097c2acc70SPeter Maydell      error_exit "'windows' coroutine backend only valid for Windows"
36107c2acc70SPeter Maydell    fi
36117c2acc70SPeter Maydell    # Unfortunately the user visible backend name doesn't match the
36127c2acc70SPeter Maydell    # coroutine-*.c filename for this case, so we have to adjust it here.
36137c2acc70SPeter Maydell    coroutine=win32
36147c2acc70SPeter Maydell    ;;
36157c2acc70SPeter Maydell  ucontext)
36167c2acc70SPeter Maydell    if test "$ucontext_works" != "yes"; then
36177c2acc70SPeter Maydell      feature_not_found "ucontext"
36187c2acc70SPeter Maydell    fi
36197c2acc70SPeter Maydell    ;;
362033c53c54SDaniel P. Berrange  sigaltstack)
36217c2acc70SPeter Maydell    if test "$mingw32" = "yes"; then
36227c2acc70SPeter Maydell      error_exit "only the 'windows' coroutine backend is valid for Windows"
36237c2acc70SPeter Maydell    fi
36247c2acc70SPeter Maydell    ;;
36257c2acc70SPeter Maydell  *)
362676ad07a4SPeter Maydell    error_exit "unknown coroutine backend $coroutine"
36277c2acc70SPeter Maydell    ;;
36287c2acc70SPeter Maydell  esac
3629d0e2fce5SAneesh Kumar K.Vfi
3630d0e2fce5SAneesh Kumar K.V
363170c60c08SStefan Hajnocziif test "$coroutine_pool" = ""; then
363270c60c08SStefan Hajnoczi  coroutine_pool=yes
363370c60c08SStefan Hajnoczifi
363470c60c08SStefan Hajnoczi
36357d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes"; then
36367d992e4dSPeter Lieven  if test "$coroutine_pool" = "yes"; then
36377d992e4dSPeter Lieven    echo "WARN: disabling coroutine pool for stack usage debugging"
36387d992e4dSPeter Lieven    coroutine_pool=no
36397d992e4dSPeter Lieven  fi
36407d992e4dSPeter Lievenfi
36417d992e4dSPeter Lieven
36421e4f6065SDaniele Buono##################################################
36431e4f6065SDaniele Buono# SafeStack
36441e4f6065SDaniele Buono
36451e4f6065SDaniele Buono
36461e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then
36471e4f6065SDaniele Buonocat > $TMPC << EOF
36481e4f6065SDaniele Buonoint main(int argc, char *argv[])
36491e4f6065SDaniele Buono{
36501e4f6065SDaniele Buono#if ! __has_feature(safe_stack)
36511e4f6065SDaniele Buono#error SafeStack Disabled
36521e4f6065SDaniele Buono#endif
36531e4f6065SDaniele Buono    return 0;
36541e4f6065SDaniele Buono}
36551e4f6065SDaniele BuonoEOF
36561e4f6065SDaniele Buono  flag="-fsanitize=safe-stack"
36571e4f6065SDaniele Buono  # Check that safe-stack is supported and enabled.
36581e4f6065SDaniele Buono  if compile_prog "-Werror $flag" "$flag"; then
36591e4f6065SDaniele Buono    # Flag needed both at compilation and at linking
36601e4f6065SDaniele Buono    QEMU_CFLAGS="$QEMU_CFLAGS $flag"
36611e4f6065SDaniele Buono    QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
36621e4f6065SDaniele Buono  else
36631e4f6065SDaniele Buono    error_exit "SafeStack not supported by your compiler"
36641e4f6065SDaniele Buono  fi
36651e4f6065SDaniele Buono  if test "$coroutine" != "ucontext"; then
36661e4f6065SDaniele Buono    error_exit "SafeStack is only supported by the coroutine backend ucontext"
36671e4f6065SDaniele Buono  fi
36681e4f6065SDaniele Buonoelse
36691e4f6065SDaniele Buonocat > $TMPC << EOF
36701e4f6065SDaniele Buonoint main(int argc, char *argv[])
36711e4f6065SDaniele Buono{
36721e4f6065SDaniele Buono#if defined(__has_feature)
36731e4f6065SDaniele Buono#if __has_feature(safe_stack)
36741e4f6065SDaniele Buono#error SafeStack Enabled
36751e4f6065SDaniele Buono#endif
36761e4f6065SDaniele Buono#endif
36771e4f6065SDaniele Buono    return 0;
36781e4f6065SDaniele Buono}
36791e4f6065SDaniele BuonoEOF
36801e4f6065SDaniele Buonoif test "$safe_stack" = "no"; then
36811e4f6065SDaniele Buono  # Make sure that safe-stack is disabled
36821e4f6065SDaniele Buono  if ! compile_prog "-Werror" ""; then
36831e4f6065SDaniele Buono    # SafeStack was already enabled, try to explicitly remove the feature
36841e4f6065SDaniele Buono    flag="-fno-sanitize=safe-stack"
36851e4f6065SDaniele Buono    if ! compile_prog "-Werror $flag" "$flag"; then
36861e4f6065SDaniele Buono      error_exit "Configure cannot disable SafeStack"
36871e4f6065SDaniele Buono    fi
36881e4f6065SDaniele Buono    QEMU_CFLAGS="$QEMU_CFLAGS $flag"
36891e4f6065SDaniele Buono    QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
36901e4f6065SDaniele Buono  fi
36911e4f6065SDaniele Buonoelse # "$safe_stack" = ""
36921e4f6065SDaniele Buono  # Set safe_stack to yes or no based on pre-existing flags
36931e4f6065SDaniele Buono  if compile_prog "-Werror" ""; then
36941e4f6065SDaniele Buono    safe_stack="no"
36951e4f6065SDaniele Buono  else
36961e4f6065SDaniele Buono    safe_stack="yes"
36971e4f6065SDaniele Buono    if test "$coroutine" != "ucontext"; then
36981e4f6065SDaniele Buono      error_exit "SafeStack is only supported by the coroutine backend ucontext"
36991e4f6065SDaniele Buono    fi
37001e4f6065SDaniele Buono  fi
37011e4f6065SDaniele Buonofi
37021e4f6065SDaniele Buonofi
37037d992e4dSPeter Lieven
370476a347e1SRichard Henderson########################################
370576a347e1SRichard Henderson# check if cpuid.h is usable.
370676a347e1SRichard Henderson
370776a347e1SRichard Hendersoncat > $TMPC << EOF
370876a347e1SRichard Henderson#include <cpuid.h>
370976a347e1SRichard Hendersonint main(void) {
3710774d566cSPeter Maydell    unsigned a, b, c, d;
3711774d566cSPeter Maydell    int max = __get_cpuid_max(0, 0);
3712774d566cSPeter Maydell
3713774d566cSPeter Maydell    if (max >= 1) {
3714774d566cSPeter Maydell        __cpuid(1, a, b, c, d);
3715774d566cSPeter Maydell    }
3716774d566cSPeter Maydell
3717774d566cSPeter Maydell    if (max >= 7) {
3718774d566cSPeter Maydell        __cpuid_count(7, 0, a, b, c, d);
3719774d566cSPeter Maydell    }
3720774d566cSPeter Maydell
372176a347e1SRichard Henderson    return 0;
372276a347e1SRichard Henderson}
372376a347e1SRichard HendersonEOF
372476a347e1SRichard Hendersonif compile_prog "" "" ; then
372576a347e1SRichard Henderson    cpuid_h=yes
372676a347e1SRichard Hendersonfi
372776a347e1SRichard Henderson
37285dd89908SRichard Henderson##########################################
37295dd89908SRichard Henderson# avx2 optimization requirement check
37305dd89908SRichard Henderson#
37315dd89908SRichard Henderson# There is no point enabling this if cpuid.h is not usable,
37325dd89908SRichard Henderson# since we won't be able to select the new routines.
37335dd89908SRichard Henderson
3734e633a5c6SEric Blakeif test "$cpuid_h" = "yes" && test "$avx2_opt" != "no"; then
37355dd89908SRichard Henderson  cat > $TMPC << EOF
37365dd89908SRichard Henderson#pragma GCC push_options
37375dd89908SRichard Henderson#pragma GCC target("avx2")
37385dd89908SRichard Henderson#include <cpuid.h>
37395dd89908SRichard Henderson#include <immintrin.h>
37405dd89908SRichard Hendersonstatic int bar(void *a) {
37415dd89908SRichard Henderson    __m256i x = *(__m256i *)a;
37425dd89908SRichard Henderson    return _mm256_testz_si256(x, x);
37435dd89908SRichard Henderson}
37445dd89908SRichard Hendersonint main(int argc, char *argv[]) { return bar(argv[0]); }
37455dd89908SRichard HendersonEOF
37465b945f23SRichard Henderson  if compile_object "-Werror" ; then
37475dd89908SRichard Henderson    avx2_opt="yes"
374886583a07SLiam Merwick  else
374986583a07SLiam Merwick    avx2_opt="no"
37505dd89908SRichard Henderson  fi
37515dd89908SRichard Hendersonfi
37525dd89908SRichard Henderson
37536b8cd447SRobert Hoo##########################################
37546b8cd447SRobert Hoo# avx512f optimization requirement check
37556b8cd447SRobert Hoo#
37566b8cd447SRobert Hoo# There is no point enabling this if cpuid.h is not usable,
37576b8cd447SRobert Hoo# since we won't be able to select the new routines.
37586b8cd447SRobert Hoo# by default, it is turned off.
37596b8cd447SRobert Hoo# if user explicitly want to enable it, check environment
37606b8cd447SRobert Hoo
37616b8cd447SRobert Hooif test "$cpuid_h" = "yes" && test "$avx512f_opt" = "yes"; then
37626b8cd447SRobert Hoo  cat > $TMPC << EOF
37636b8cd447SRobert Hoo#pragma GCC push_options
37646b8cd447SRobert Hoo#pragma GCC target("avx512f")
37656b8cd447SRobert Hoo#include <cpuid.h>
37666b8cd447SRobert Hoo#include <immintrin.h>
37676b8cd447SRobert Hoostatic int bar(void *a) {
37686b8cd447SRobert Hoo    __m512i x = *(__m512i *)a;
37696b8cd447SRobert Hoo    return _mm512_test_epi64_mask(x, x);
37706b8cd447SRobert Hoo}
37716b8cd447SRobert Hooint main(int argc, char *argv[])
37726b8cd447SRobert Hoo{
37736b8cd447SRobert Hoo	return bar(argv[0]);
37746b8cd447SRobert Hoo}
37756b8cd447SRobert HooEOF
37765b945f23SRichard Henderson  if ! compile_object "-Werror" ; then
37776b8cd447SRobert Hoo    avx512f_opt="no"
37786b8cd447SRobert Hoo  fi
37796b8cd447SRobert Hooelse
37806b8cd447SRobert Hoo  avx512f_opt="no"
37816b8cd447SRobert Hoofi
37826b8cd447SRobert Hoo
3783f540166bSRichard Henderson########################################
3784f540166bSRichard Henderson# check if __[u]int128_t is usable.
3785f540166bSRichard Henderson
3786f540166bSRichard Hendersonint128=no
3787f540166bSRichard Hendersoncat > $TMPC << EOF
3788f540166bSRichard Henderson__int128_t a;
3789f540166bSRichard Henderson__uint128_t b;
3790f540166bSRichard Hendersonint main (void) {
3791f540166bSRichard Henderson  a = a + b;
3792f540166bSRichard Henderson  b = a * b;
3793464e3671SPeter Maydell  a = a * a;
3794f540166bSRichard Henderson  return 0;
3795f540166bSRichard Henderson}
3796f540166bSRichard HendersonEOF
3797f540166bSRichard Hendersonif compile_prog "" "" ; then
3798f540166bSRichard Henderson    int128=yes
3799f540166bSRichard Hendersonfi
380076a347e1SRichard Henderson
38017ebee43eSRichard Henderson#########################################
38027ebee43eSRichard Henderson# See if 128-bit atomic operations are supported.
38037ebee43eSRichard Henderson
38047ebee43eSRichard Hendersonatomic128=no
38057ebee43eSRichard Hendersonif test "$int128" = "yes"; then
38067ebee43eSRichard Henderson  cat > $TMPC << EOF
38077ebee43eSRichard Hendersonint main(void)
38087ebee43eSRichard Henderson{
38097ebee43eSRichard Henderson  unsigned __int128 x = 0, y = 0;
3810bceac547SThomas Huth  y = __atomic_load(&x, 0);
3811bceac547SThomas Huth  __atomic_store(&x, y, 0);
3812bceac547SThomas Huth  __atomic_compare_exchange(&x, &y, x, 0, 0, 0);
38137ebee43eSRichard Henderson  return 0;
38147ebee43eSRichard Henderson}
38157ebee43eSRichard HendersonEOF
38167ebee43eSRichard Henderson  if compile_prog "" "" ; then
38177ebee43eSRichard Henderson    atomic128=yes
38187ebee43eSRichard Henderson  fi
38197ebee43eSRichard Hendersonfi
38207ebee43eSRichard Henderson
3821e6cd4bb5SRichard Hendersoncmpxchg128=no
3822e633a5c6SEric Blakeif test "$int128" = yes && test "$atomic128" = no; then
3823e6cd4bb5SRichard Henderson  cat > $TMPC << EOF
3824e6cd4bb5SRichard Hendersonint main(void)
3825e6cd4bb5SRichard Henderson{
3826e6cd4bb5SRichard Henderson  unsigned __int128 x = 0, y = 0;
3827e6cd4bb5SRichard Henderson  __sync_val_compare_and_swap_16(&x, y, x);
3828e6cd4bb5SRichard Henderson  return 0;
3829e6cd4bb5SRichard Henderson}
3830e6cd4bb5SRichard HendersonEOF
3831e6cd4bb5SRichard Henderson  if compile_prog "" "" ; then
3832e6cd4bb5SRichard Henderson    cmpxchg128=yes
3833e6cd4bb5SRichard Henderson  fi
3834e6cd4bb5SRichard Hendersonfi
3835e6cd4bb5SRichard Henderson
3836df79b996SRichard Henderson#########################################
3837df79b996SRichard Henderson# See if 64-bit atomic operations are supported.
3838df79b996SRichard Henderson# Note that without __atomic builtins, we can only
3839df79b996SRichard Henderson# assume atomic loads/stores max at pointer size.
3840df79b996SRichard Henderson
3841df79b996SRichard Hendersoncat > $TMPC << EOF
3842df79b996SRichard Henderson#include <stdint.h>
3843df79b996SRichard Hendersonint main(void)
3844df79b996SRichard Henderson{
3845df79b996SRichard Henderson  uint64_t x = 0, y = 0;
38465fe40765SThomas Huth  y = __atomic_load_n(&x, __ATOMIC_RELAXED);
38475fe40765SThomas Huth  __atomic_store_n(&x, y, __ATOMIC_RELAXED);
38485fe40765SThomas Huth  __atomic_compare_exchange_n(&x, &y, x, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
38495fe40765SThomas Huth  __atomic_exchange_n(&x, y, __ATOMIC_RELAXED);
38505fe40765SThomas Huth  __atomic_fetch_add(&x, y, __ATOMIC_RELAXED);
3851df79b996SRichard Henderson  return 0;
3852df79b996SRichard Henderson}
3853df79b996SRichard HendersonEOF
3854df79b996SRichard Hendersonif compile_prog "" "" ; then
3855df79b996SRichard Henderson  atomic64=yes
3856df79b996SRichard Hendersonfi
3857df79b996SRichard Henderson
38581e6e9acaSRichard Henderson########################################
38591e6e9acaSRichard Henderson# check if getauxval is available.
38601e6e9acaSRichard Henderson
38611e6e9acaSRichard Hendersongetauxval=no
38621e6e9acaSRichard Hendersoncat > $TMPC << EOF
38631e6e9acaSRichard Henderson#include <sys/auxv.h>
38641e6e9acaSRichard Hendersonint main(void) {
38651e6e9acaSRichard Henderson  return getauxval(AT_HWCAP) == 0;
38661e6e9acaSRichard Henderson}
38671e6e9acaSRichard HendersonEOF
38681e6e9acaSRichard Hendersonif compile_prog "" "" ; then
38691e6e9acaSRichard Henderson    getauxval=yes
38701e6e9acaSRichard Hendersonfi
38711e6e9acaSRichard Henderson
3872fd0e6053SJohn Snow########################################
3873fd0e6053SJohn Snow# check if ccache is interfering with
3874fd0e6053SJohn Snow# semantic analysis of macros
3875fd0e6053SJohn Snow
38765e4dfd3dSJohn Snowunset CCACHE_CPP2
3877fd0e6053SJohn Snowccache_cpp2=no
3878fd0e6053SJohn Snowcat > $TMPC << EOF
3879fd0e6053SJohn Snowstatic const int Z = 1;
3880fd0e6053SJohn Snow#define fn() ({ Z; })
3881fd0e6053SJohn Snow#define TAUT(X) ((X) == Z)
3882fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y)
3883fd0e6053SJohn Snow#define ID(X) (X)
3884fd0e6053SJohn Snowint main(int argc, char *argv[])
3885fd0e6053SJohn Snow{
3886fd0e6053SJohn Snow    int x = 0, y = 0;
3887fd0e6053SJohn Snow    x = ID(x);
3888fd0e6053SJohn Snow    x = fn();
3889fd0e6053SJohn Snow    fn();
3890fd0e6053SJohn Snow    if (PAREN(x, y)) return 0;
3891fd0e6053SJohn Snow    if (TAUT(Z)) return 0;
3892fd0e6053SJohn Snow    return 0;
3893fd0e6053SJohn Snow}
3894fd0e6053SJohn SnowEOF
3895fd0e6053SJohn Snow
3896fd0e6053SJohn Snowif ! compile_object "-Werror"; then
3897fd0e6053SJohn Snow    ccache_cpp2=yes
3898fd0e6053SJohn Snowfi
3899fd0e6053SJohn Snow
3900b553a042SJohn Snow#################################################
3901b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE.
3902b553a042SJohn Snow
3903b553a042SJohn Snowif test "$fortify_source" != "no"; then
3904b553a042SJohn Snow  if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
3905b553a042SJohn Snow    fortify_source="no";
3906e189091fSPeter Maydell  elif test -n "$cxx" && has $cxx &&
3907cfcc7c14SJohn Snow       echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
3908b553a042SJohn Snow    fortify_source="no";
3909b553a042SJohn Snow  else
3910b553a042SJohn Snow    fortify_source="yes"
3911b553a042SJohn Snow  fi
3912b553a042SJohn Snowfi
3913b553a042SJohn Snow
3914d2042378SAneesh Kumar K.V##########################################
3915277abf15SJan Vesely# check if struct fsxattr is available via linux/fs.h
3916277abf15SJan Vesely
3917277abf15SJan Veselyhave_fsxattr=no
3918277abf15SJan Veselycat > $TMPC << EOF
3919277abf15SJan Vesely#include <linux/fs.h>
3920277abf15SJan Veselystruct fsxattr foo;
3921277abf15SJan Veselyint main(void) {
3922277abf15SJan Vesely  return 0;
3923277abf15SJan Vesely}
3924277abf15SJan VeselyEOF
3925277abf15SJan Veselyif compile_prog "" "" ; then
3926277abf15SJan Vesely    have_fsxattr=yes
3927277abf15SJan Veselyfi
3928277abf15SJan Vesely
3929b66e10e4SPeter Maydell##########################################
3930a40161cbSPaolo Bonzini# check for usable membarrier system call
3931a40161cbSPaolo Bonziniif test "$membarrier" = "yes"; then
3932a40161cbSPaolo Bonzini    have_membarrier=no
3933a40161cbSPaolo Bonzini    if test "$mingw32" = "yes" ; then
3934a40161cbSPaolo Bonzini        have_membarrier=yes
3935a40161cbSPaolo Bonzini    elif test "$linux" = "yes" ; then
3936a40161cbSPaolo Bonzini        cat > $TMPC << EOF
3937a40161cbSPaolo Bonzini    #include <linux/membarrier.h>
3938a40161cbSPaolo Bonzini    #include <sys/syscall.h>
3939a40161cbSPaolo Bonzini    #include <unistd.h>
3940a40161cbSPaolo Bonzini    #include <stdlib.h>
3941a40161cbSPaolo Bonzini    int main(void) {
3942a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
3943a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0);
3944a40161cbSPaolo Bonzini	exit(0);
3945a40161cbSPaolo Bonzini    }
3946a40161cbSPaolo BonziniEOF
3947a40161cbSPaolo Bonzini        if compile_prog "" "" ; then
3948a40161cbSPaolo Bonzini            have_membarrier=yes
3949a40161cbSPaolo Bonzini        fi
3950a40161cbSPaolo Bonzini    fi
3951a40161cbSPaolo Bonzini    if test "$have_membarrier" = "no"; then
3952a40161cbSPaolo Bonzini      feature_not_found "membarrier" "membarrier system call not available"
3953a40161cbSPaolo Bonzini    fi
3954a40161cbSPaolo Bonzinielse
3955a40161cbSPaolo Bonzini    # Do not enable it by default even for Mingw32, because it doesn't
3956a40161cbSPaolo Bonzini    # work on Wine.
3957a40161cbSPaolo Bonzini    membarrier=no
3958a40161cbSPaolo Bonzinifi
3959a40161cbSPaolo Bonzini
3960a40161cbSPaolo Bonzini##########################################
39616a02c806SStefan Hajnoczi# check for usable AF_VSOCK environment
39626a02c806SStefan Hajnoczihave_af_vsock=no
39636a02c806SStefan Hajnoczicat > $TMPC << EOF
39646a02c806SStefan Hajnoczi#include <errno.h>
39656a02c806SStefan Hajnoczi#include <sys/types.h>
39666a02c806SStefan Hajnoczi#include <sys/socket.h>
39676a02c806SStefan Hajnoczi#if !defined(AF_VSOCK)
39686a02c806SStefan Hajnoczi# error missing AF_VSOCK flag
39696a02c806SStefan Hajnoczi#endif
39706a02c806SStefan Hajnoczi#include <linux/vm_sockets.h>
39716a02c806SStefan Hajnocziint main(void) {
39726a02c806SStefan Hajnoczi    int sock, ret;
39736a02c806SStefan Hajnoczi    struct sockaddr_vm svm;
39746a02c806SStefan Hajnoczi    socklen_t len = sizeof(svm);
39756a02c806SStefan Hajnoczi    sock = socket(AF_VSOCK, SOCK_STREAM, 0);
39766a02c806SStefan Hajnoczi    ret = getpeername(sock, (struct sockaddr *)&svm, &len);
39776a02c806SStefan Hajnoczi    if ((ret == -1) && (errno == ENOTCONN)) {
39786a02c806SStefan Hajnoczi        return 0;
39796a02c806SStefan Hajnoczi    }
39806a02c806SStefan Hajnoczi    return -1;
39816a02c806SStefan Hajnoczi}
39826a02c806SStefan HajnocziEOF
39836a02c806SStefan Hajnocziif compile_prog "" "" ; then
39846a02c806SStefan Hajnoczi    have_af_vsock=yes
39856a02c806SStefan Hajnoczifi
39866a02c806SStefan Hajnoczi
3987f0d92b56SLongpeng(Mike)##########################################
3988f0d92b56SLongpeng(Mike)# check for usable AF_ALG environment
39894f67366eSThomas Huthhave_afalg=no
3990f0d92b56SLongpeng(Mike)cat > $TMPC << EOF
3991f0d92b56SLongpeng(Mike)#include <errno.h>
3992f0d92b56SLongpeng(Mike)#include <sys/types.h>
3993f0d92b56SLongpeng(Mike)#include <sys/socket.h>
3994f0d92b56SLongpeng(Mike)#include <linux/if_alg.h>
3995f0d92b56SLongpeng(Mike)int main(void) {
3996f0d92b56SLongpeng(Mike)    int sock;
3997f0d92b56SLongpeng(Mike)    sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
3998f0d92b56SLongpeng(Mike)    return sock;
3999f0d92b56SLongpeng(Mike)}
4000f0d92b56SLongpeng(Mike)EOF
4001f0d92b56SLongpeng(Mike)if compile_prog "" "" ; then
4002f0d92b56SLongpeng(Mike)    have_afalg=yes
4003f0d92b56SLongpeng(Mike)fi
4004f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes"
4005f0d92b56SLongpeng(Mike)then
4006f0d92b56SLongpeng(Mike)    if test "$have_afalg" != "yes"
4007f0d92b56SLongpeng(Mike)    then
4008f0d92b56SLongpeng(Mike)	error_exit "AF_ALG requested but could not be detected"
4009f0d92b56SLongpeng(Mike)    fi
4010f0d92b56SLongpeng(Mike)fi
4011f0d92b56SLongpeng(Mike)
4012f0d92b56SLongpeng(Mike)
4013db1ed1abSRichard Henderson##########################################
4014247724cbSMarc-André Lureau# checks for sanitizers
4015247724cbSMarc-André Lureau
4016247724cbSMarc-André Lureauhave_asan=no
4017247724cbSMarc-André Lureauhave_ubsan=no
4018d83414e1SMarc-André Lureauhave_asan_iface_h=no
4019d83414e1SMarc-André Lureauhave_asan_iface_fiber=no
4020247724cbSMarc-André Lureau
4021247724cbSMarc-André Lureauif test "$sanitizers" = "yes" ; then
4022b9f44da2SMarc-André Lureau  write_c_skeleton
4023247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
4024247724cbSMarc-André Lureau      have_asan=yes
4025247724cbSMarc-André Lureau  fi
4026b9f44da2SMarc-André Lureau
4027b9f44da2SMarc-André Lureau  # we could use a simple skeleton for flags checks, but this also
4028b9f44da2SMarc-André Lureau  # detect the static linking issue of ubsan, see also:
4029b9f44da2SMarc-André Lureau  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
4030b9f44da2SMarc-André Lureau  cat > $TMPC << EOF
4031b9f44da2SMarc-André Lureau#include <stdlib.h>
4032b9f44da2SMarc-André Lureauint main(void) {
4033b9f44da2SMarc-André Lureau    void *tmp = malloc(10);
4034f2dfe54cSLeonid Bloch    if (tmp != NULL) {
4035b9f44da2SMarc-André Lureau        return *(int *)(tmp + 2);
4036b9f44da2SMarc-André Lureau    }
4037d1abf3fcSOlaf Hering    return 1;
4038f2dfe54cSLeonid Bloch}
4039b9f44da2SMarc-André LureauEOF
4040247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
4041247724cbSMarc-André Lureau      have_ubsan=yes
4042247724cbSMarc-André Lureau  fi
4043d83414e1SMarc-André Lureau
4044d83414e1SMarc-André Lureau  if check_include "sanitizer/asan_interface.h" ; then
4045d83414e1SMarc-André Lureau      have_asan_iface_h=yes
4046d83414e1SMarc-André Lureau  fi
4047d83414e1SMarc-André Lureau
4048d83414e1SMarc-André Lureau  cat > $TMPC << EOF
4049d83414e1SMarc-André Lureau#include <sanitizer/asan_interface.h>
4050d83414e1SMarc-André Lureauint main(void) {
4051d83414e1SMarc-André Lureau  __sanitizer_start_switch_fiber(0, 0, 0);
4052d83414e1SMarc-André Lureau  return 0;
4053d83414e1SMarc-André Lureau}
4054d83414e1SMarc-André LureauEOF
4055d83414e1SMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
4056d83414e1SMarc-André Lureau      have_asan_iface_fiber=yes
4057d83414e1SMarc-André Lureau  fi
4058247724cbSMarc-André Lureaufi
4059247724cbSMarc-André Lureau
4060247724cbSMarc-André Lureau##########################################
4061adc28027SAlexander Bulekov# checks for fuzzer
4062dfc86c0fSAlexander Bulekovif test "$fuzzing" = "yes" ; then
4063adc28027SAlexander Bulekov  write_c_fuzzer_skeleton
4064dfc86c0fSAlexander Bulekov  if test -z "${LIB_FUZZING_ENGINE+xxx}"; then
4065dd016265SAlexander Bulekov    if compile_prog "$CPU_CFLAGS -Werror -fsanitize=fuzzer" ""; then
4066adc28027SAlexander Bulekov      have_fuzzer=yes
406764ed6f92SPaolo Bonzini    else
406864ed6f92SPaolo Bonzini      error_exit "Your compiler doesn't support -fsanitize=fuzzer"
406964ed6f92SPaolo Bonzini      exit 1
4070adc28027SAlexander Bulekov    fi
4071adc28027SAlexander Bulekov  fi
4072adc28027SAlexander Bulekov
4073dfc86c0fSAlexander Bulekov  have_clang_coverage_filter=no
4074dfc86c0fSAlexander Bulekov  echo > $TMPTXT
4075dfc86c0fSAlexander Bulekov  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=fuzzer -fsanitize-coverage-allowlist=$TMPTXT" ""; then
4076dfc86c0fSAlexander Bulekov    have_clang_coverage_filter=yes
4077dfc86c0fSAlexander Bulekov  fi
4078dfc86c0fSAlexander Bulekovfi
4079dfc86c0fSAlexander Bulekov
40800aebab04SLingfeng Yang# Thread sanitizer is, for now, much noisier than the other sanitizers;
40810aebab04SLingfeng Yang# keep it separate until that is not the case.
40820aebab04SLingfeng Yangif test "$tsan" = "yes" && test "$sanitizers" = "yes"; then
40830aebab04SLingfeng Yang  error_exit "TSAN is not supported with other sanitiziers."
40840aebab04SLingfeng Yangfi
40850aebab04SLingfeng Yanghave_tsan=no
40860aebab04SLingfeng Yanghave_tsan_iface_fiber=no
40870aebab04SLingfeng Yangif test "$tsan" = "yes" ; then
40880aebab04SLingfeng Yang  write_c_skeleton
40890aebab04SLingfeng Yang  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
40900aebab04SLingfeng Yang      have_tsan=yes
40910aebab04SLingfeng Yang  fi
40920aebab04SLingfeng Yang  cat > $TMPC << EOF
40930aebab04SLingfeng Yang#include <sanitizer/tsan_interface.h>
40940aebab04SLingfeng Yangint main(void) {
40950aebab04SLingfeng Yang  __tsan_create_fiber(0);
40960aebab04SLingfeng Yang  return 0;
40970aebab04SLingfeng Yang}
40980aebab04SLingfeng YangEOF
40990aebab04SLingfeng Yang  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
41000aebab04SLingfeng Yang      have_tsan_iface_fiber=yes
41010aebab04SLingfeng Yang  fi
41020aebab04SLingfeng Yangfi
41030aebab04SLingfeng Yang
4104adc28027SAlexander Bulekov##########################################
4105675b9b53SMarc-André Lureau# check for slirp
4106675b9b53SMarc-André Lureau
4107675b9b53SMarc-André Lureaucase "$slirp" in
41084d34a86bSPaolo Bonzini  auto | enabled | internal)
41094d34a86bSPaolo Bonzini    # Simpler to always update submodule, even if not needed.
41107c57bdd8SMarc-André Lureau    git_submodules="${git_submodules} slirp"
4111675b9b53SMarc-André Lureau    ;;
4112675b9b53SMarc-André Lureauesac
4113675b9b53SMarc-André Lureau
4114b8e0c493SJoelle van Dyne# Check for slirp smbd dupport
4115b8e0c493SJoelle van Dyne: ${smbd=${SMBD-/usr/sbin/smbd}}
4116b8e0c493SJoelle van Dyneif test "$slirp_smbd" != "no" ; then
4117b8e0c493SJoelle van Dyne  if test "$mingw32" = "yes" ; then
4118b8e0c493SJoelle van Dyne    if test "$slirp_smbd" = "yes" ; then
4119b8e0c493SJoelle van Dyne      error_exit "Host smbd not supported on this platform."
4120b8e0c493SJoelle van Dyne    fi
4121b8e0c493SJoelle van Dyne    slirp_smbd=no
4122b8e0c493SJoelle van Dyne  else
4123b8e0c493SJoelle van Dyne    slirp_smbd=yes
4124b8e0c493SJoelle van Dyne  fi
4125b8e0c493SJoelle van Dynefi
4126b8e0c493SJoelle van Dyne
412754e7aac0SAlexey Krasikov##########################################
412854e7aac0SAlexey Krasikov# check for usable __NR_keyctl syscall
412954e7aac0SAlexey Krasikov
413054e7aac0SAlexey Krasikovif test "$linux" = "yes" ; then
413154e7aac0SAlexey Krasikov
413254e7aac0SAlexey Krasikov    have_keyring=no
413354e7aac0SAlexey Krasikov    cat > $TMPC << EOF
413454e7aac0SAlexey Krasikov#include <errno.h>
413554e7aac0SAlexey Krasikov#include <asm/unistd.h>
413654e7aac0SAlexey Krasikov#include <linux/keyctl.h>
413754e7aac0SAlexey Krasikov#include <unistd.h>
413854e7aac0SAlexey Krasikovint main(void) {
413954e7aac0SAlexey Krasikov    return syscall(__NR_keyctl, KEYCTL_READ, 0, NULL, NULL, 0);
414054e7aac0SAlexey Krasikov}
414154e7aac0SAlexey KrasikovEOF
414254e7aac0SAlexey Krasikov    if compile_prog "" "" ; then
414354e7aac0SAlexey Krasikov        have_keyring=yes
414454e7aac0SAlexey Krasikov    fi
414554e7aac0SAlexey Krasikovfi
414654e7aac0SAlexey Krasikovif test "$secret_keyring" != "no"
414754e7aac0SAlexey Krasikovthen
4148b418d265SDavid Edmondson    if test "$have_keyring" = "yes"
414954e7aac0SAlexey Krasikov    then
415054e7aac0SAlexey Krasikov	secret_keyring=yes
415154e7aac0SAlexey Krasikov    else
415254e7aac0SAlexey Krasikov	if test "$secret_keyring" = "yes"
415354e7aac0SAlexey Krasikov	then
415454e7aac0SAlexey Krasikov	    error_exit "syscall __NR_keyctl requested, \
415554e7aac0SAlexey Krasikovbut not implemented on your system"
415654e7aac0SAlexey Krasikov	else
415754e7aac0SAlexey Krasikov	    secret_keyring=no
415854e7aac0SAlexey Krasikov	fi
415954e7aac0SAlexey Krasikov    fi
416054e7aac0SAlexey Krasikovfi
416154e7aac0SAlexey Krasikov
416292500362SAlexey Krasikov##########################################
4163e86ecd4bSJuan Quintela# End of CC checks
4164e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
4165e86ecd4bSJuan Quintela
4166d83414e1SMarc-André Lureauwrite_c_skeleton
4167d83414e1SMarc-André Lureau
41681d728c39SBlue Swirlif test "$gcov" = "yes" ; then
4169bf0e56a3SMarc-André Lureau  :
4170b553a042SJohn Snowelif test "$fortify_source" = "yes" ; then
4171086d5f75SPaolo Bonzini  QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
4172086d5f75SPaolo Bonzini  debug=no
4173086d5f75SPaolo Bonzinifi
4174086d5f75SPaolo Bonzini
4175086d5f75SPaolo Bonzinicase "$ARCH" in
4176086d5f75SPaolo Bonzinialpha)
4177086d5f75SPaolo Bonzini  # Ensure there's only a single GP
4178086d5f75SPaolo Bonzini  QEMU_CFLAGS="-msmall-data $QEMU_CFLAGS"
4179086d5f75SPaolo Bonzini;;
4180086d5f75SPaolo Bonziniesac
4181086d5f75SPaolo Bonzini
4182086d5f75SPaolo Bonziniif test "$gprof" = "yes" ; then
4183086d5f75SPaolo Bonzini  QEMU_CFLAGS="-p $QEMU_CFLAGS"
4184086d5f75SPaolo Bonzini  QEMU_LDFLAGS="-p $QEMU_LDFLAGS"
4185086d5f75SPaolo Bonzinifi
4186a316e378SJuan Quintela
4187247724cbSMarc-André Lureauif test "$have_asan" = "yes"; then
4188db5adeaaSPaolo Bonzini  QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS"
4189db5adeaaSPaolo Bonzini  QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS"
4190d83414e1SMarc-André Lureau  if test "$have_asan_iface_h" = "no" ; then
4191d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header missing." \
4192d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
4193d83414e1SMarc-André Lureau  elif test "$have_asan_iface_fiber" = "no" ; then
4194d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header is too old." \
4195d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
4196d83414e1SMarc-André Lureau  fi
4197247724cbSMarc-André Lureaufi
41980aebab04SLingfeng Yangif test "$have_tsan" = "yes" ; then
41990aebab04SLingfeng Yang  if test "$have_tsan_iface_fiber" = "yes" ; then
42000aebab04SLingfeng Yang    QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS"
42010aebab04SLingfeng Yang    QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS"
42020aebab04SLingfeng Yang  else
42030aebab04SLingfeng Yang    error_exit "Cannot enable TSAN due to missing fiber annotation interface."
42040aebab04SLingfeng Yang  fi
42050aebab04SLingfeng Yangelif test "$tsan" = "yes" ; then
42060aebab04SLingfeng Yang  error_exit "Cannot enable TSAN due to missing sanitize thread interface."
42070aebab04SLingfeng Yangfi
4208247724cbSMarc-André Lureauif test "$have_ubsan" = "yes"; then
4209db5adeaaSPaolo Bonzini  QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS"
4210db5adeaaSPaolo Bonzini  QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS"
4211247724cbSMarc-André Lureaufi
4212247724cbSMarc-André Lureau
42136542aa9cSPeter Lieven##########################################
42143efac6ebSTomáš Golembiovský
42150aebab04SLingfeng Yang# Exclude --warn-common with TSan to suppress warnings from the TSan libraries.
42160aebab04SLingfeng Yangif test "$solaris" = "no" && test "$tsan" = "no"; then
4217e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
4218db5adeaaSPaolo Bonzini        QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS"
4219e86ecd4bSJuan Quintela    fi
4220e86ecd4bSJuan Quintelafi
4221e86ecd4bSJuan Quintela
4222952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
4223952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
4224cb8baa77SMark Cave-Ayland    flags="--no-seh --nxcompat"
4225cb8baa77SMark Cave-Ayland
4226cb8baa77SMark Cave-Ayland    # Disable ASLR for debug builds to allow debugging with gdb
4227cb8baa77SMark Cave-Ayland    if test "$debug" = "no" ; then
4228cb8baa77SMark Cave-Ayland        flags="--dynamicbase $flags"
4229cb8baa77SMark Cave-Ayland    fi
4230cb8baa77SMark Cave-Ayland
4231cb8baa77SMark Cave-Ayland    for flag in $flags; do
4232e9a3591fSChristian Borntraeger        if ld_has $flag ; then
4233db5adeaaSPaolo Bonzini            QEMU_LDFLAGS="-Wl,$flag $QEMU_LDFLAGS"
4234952afb71SBlue Swirl        fi
4235952afb71SBlue Swirl    done
4236952afb71SBlue Swirlfi
4237952afb71SBlue Swirl
42389d6bc27bSMichael Roth# Probe for guest agent support/options
42399d6bc27bSMichael Roth
4240e8ef31a3SMichael Tokarevif [ "$guest_agent" != "no" ]; then
4241a5125905SLaurent Vivier  if [ "$softmmu" = no -a "$want_tools" = no ] ; then
4242a5125905SLaurent Vivier      guest_agent=no
4243a5125905SLaurent Vivier  elif [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
4244e8ef31a3SMichael Tokarev      guest_agent=yes
4245e8ef31a3SMichael Tokarev  elif [ "$guest_agent" != yes ]; then
4246e8ef31a3SMichael Tokarev      guest_agent=no
4247e8ef31a3SMichael Tokarev  else
4248e8ef31a3SMichael Tokarev      error_exit "Guest agent is not supported on this platform"
4249ca35f780SPaolo Bonzini  fi
42504b1c11fdSDaniel P. Berrangefi
4251ca35f780SPaolo Bonzini
4252b846ab7cSPaolo Bonzini# Guest agent Windows MSI package
42539d6bc27bSMichael Roth
42549d6bc27bSMichael Rothif test "$QEMU_GA_MANUFACTURER" = ""; then
42559d6bc27bSMichael Roth  QEMU_GA_MANUFACTURER=QEMU
42569d6bc27bSMichael Rothfi
42579d6bc27bSMichael Rothif test "$QEMU_GA_DISTRO" = ""; then
42589d6bc27bSMichael Roth  QEMU_GA_DISTRO=Linux
42599d6bc27bSMichael Rothfi
42609d6bc27bSMichael Rothif test "$QEMU_GA_VERSION" = ""; then
426189138857SStefan Weil    QEMU_GA_VERSION=$(cat $source_path/VERSION)
42629d6bc27bSMichael Rothfi
42639d6bc27bSMichael Roth
4264b846ab7cSPaolo BonziniQEMU_GA_MSI_MINGW_DLL_PATH="$($pkg_config --variable=prefix glib-2.0)/bin"
42659d6bc27bSMichael Roth
4266ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
4267ca35f780SPaolo Bonziniroms=
4268e633a5c6SEric Blakeif { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \
4269e633a5c6SEric Blake        test "$targetos" != "Darwin" && test "$targetos" != "SunOS" && \
42707000a12eSThomas Huth        test "$targetos" != "Haiku" && test "$softmmu" = yes ; then
4271e57218b6SPeter Maydell    # Different host OS linkers have different ideas about the name of the ELF
4272c65d5e4eSBrad Smith    # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
4273c65d5e4eSBrad Smith    # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
4274c65d5e4eSBrad Smith    for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
4275e57218b6SPeter Maydell        if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
4276e57218b6SPeter Maydell            ld_i386_emulation="$emu"
4277ca35f780SPaolo Bonzini            roms="optionrom"
4278e57218b6SPeter Maydell            break
4279e57218b6SPeter Maydell        fi
4280e57218b6SPeter Maydell    done
4281ca35f780SPaolo Bonzinifi
4282ca35f780SPaolo Bonzini
42832e33c3f8SThomas Huth# Only build s390-ccw bios if we're on s390x and the compiler has -march=z900
4284a5b2afd5SThomas Huth# or -march=z10 (which is the lowest architecture level that Clang supports)
42859933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then
42862e33c3f8SThomas Huth  write_c_skeleton
4287a5b2afd5SThomas Huth  compile_prog "-march=z900" ""
4288a5b2afd5SThomas Huth  has_z900=$?
42893af448b3SThomas Huth  if [ $has_z900 = 0 ] || compile_object "-march=z10 -msoft-float -Werror"; then
4290a5b2afd5SThomas Huth    if [ $has_z900 != 0 ]; then
4291a5b2afd5SThomas Huth      echo "WARNING: Your compiler does not support the z900!"
4292a5b2afd5SThomas Huth      echo "         The s390-ccw bios will only work with guest CPUs >= z10."
4293a5b2afd5SThomas Huth    fi
42949933c305SChristian Borntraeger    roms="$roms s390-ccw"
42951ef6bfc2SPhilippe Mathieu-Daudé    # SLOF is required for building the s390-ccw firmware on s390x,
42961ef6bfc2SPhilippe Mathieu-Daudé    # since it is using the libnet code from SLOF for network booting.
42971ef6bfc2SPhilippe Mathieu-Daudé    git_submodules="${git_submodules} roms/SLOF"
42981ef6bfc2SPhilippe Mathieu-Daudé  fi
42999933c305SChristian Borntraegerfi
43009933c305SChristian Borntraeger
430111cde1c8SBruno Dominguez# Check that the C++ compiler exists and works with the C compiler.
430211cde1c8SBruno 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.
430311cde1c8SBruno Dominguezif has $cxx; then
430411cde1c8SBruno Dominguez    cat > $TMPC <<EOF
430511cde1c8SBruno Dominguezint c_function(void);
430611cde1c8SBruno Dominguezint main(void) { return c_function(); }
430711cde1c8SBruno DominguezEOF
430811cde1c8SBruno Dominguez
430911cde1c8SBruno Dominguez    compile_object
431011cde1c8SBruno Dominguez
431111cde1c8SBruno Dominguez    cat > $TMPCXX <<EOF
431211cde1c8SBruno Dominguezextern "C" {
431311cde1c8SBruno Dominguez   int c_function(void);
431411cde1c8SBruno Dominguez}
431511cde1c8SBruno Dominguezint c_function(void) { return 42; }
431611cde1c8SBruno DominguezEOF
431711cde1c8SBruno Dominguez
431811cde1c8SBruno Dominguez    update_cxxflags
431911cde1c8SBruno Dominguez
43205770e8afSPaolo Bonzini    if do_cxx $CXXFLAGS $CONFIGURE_CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then
432111cde1c8SBruno Dominguez        # C++ compiler $cxx works ok with C compiler $cc
432211cde1c8SBruno Dominguez        :
432311cde1c8SBruno Dominguez    else
432411cde1c8SBruno Dominguez        echo "C++ compiler $cxx does not work with C compiler $cc"
432511cde1c8SBruno Dominguez        echo "Disabling C++ specific optional code"
432611cde1c8SBruno Dominguez        cxx=
432711cde1c8SBruno Dominguez    fi
432811cde1c8SBruno Dominguezelse
432911cde1c8SBruno Dominguez    echo "No C++ compiler available; disabling C++ specific optional code"
433011cde1c8SBruno Dominguez    cxx=
433111cde1c8SBruno Dominguezfi
433211cde1c8SBruno Dominguez
43337d7dbf9dSDan Streetmanif !(GIT="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then
43347d7dbf9dSDan Streetman    exit 1
43355d91a2edSYonggang Luofi
43365d91a2edSYonggang Luo
433798ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
433897a847bcSbellard
433998ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
434098ec69acSJuan Quintelaecho >> $config_host_mak
434198ec69acSJuan Quintela
4342e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
4343cc84d63aSDaniel P. Berrangeecho "GIT=$git" >> $config_host_mak
4344aef45d51SDaniel P. Berrangeecho "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
43457d7dbf9dSDan Streetmanecho "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak
4346804edf29SJuan Quintela
434798ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
4348727e5283SPaolo Bonzini
4349f8393946Saurel32if test "$debug_tcg" = "yes" ; then
43502358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
4351f8393946Saurel32fi
43521625af87Saliguoriif test "$strip_opt" = "yes" ; then
435352ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
43541625af87Saliguorifi
43557d13299dSbellardif test "$bigendian" = "yes" ; then
4356e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
435797a847bcSbellardfi
435867b915a5Sbellardif test "$mingw32" = "yes" ; then
435998ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
4360d9840e25STomoki Sekiyama  if test "$guest_agent_with_vss" = "yes" ; then
4361d9840e25STomoki Sekiyama    echo "CONFIG_QGA_VSS=y" >> $config_host_mak
4362f33ca81fSMichael Roth    echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
4363d9840e25STomoki Sekiyama    echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
4364d9840e25STomoki Sekiyama  fi
436550cbebb9SMichael Roth  if test "$guest_agent_ntddscsi" = "yes" ; then
436676dc75caSTomáš Golembiovský    echo "CONFIG_QGA_NTDDSCSI=y" >> $config_host_mak
436750cbebb9SMichael Roth  fi
43689dacf32dSYossi Hindin  echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
43699dacf32dSYossi Hindin  echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
43709dacf32dSYossi Hindin  echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
43719dacf32dSYossi Hindin  echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
4372210fa556Spbrookelse
437335f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
4374210fa556Spbrookfi
4375128ab2ffSblueswir1
4376dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
4377dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
4378dffcb71cSMark McLoughlinfi
4379dffcb71cSMark McLoughlin
438083fb7adfSbellardif test "$darwin" = "yes" ; then
438198ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
438283fb7adfSbellardfi
4383b29fe3edSmalc
4384ec530c81Sbellardif test "$solaris" = "yes" ; then
438598ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
4386ec530c81Sbellardfi
4387179cf400SAndreas Färberif test "$haiku" = "yes" ; then
4388179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
4389179cf400SAndreas Färberfi
439097a847bcSbellardif test "$static" = "yes" ; then
439198ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
439297a847bcSbellardfi
43931ba16968SStefan Weilif test "$profiler" = "yes" ; then
43942358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
439505c2a3e7Sbellardfi
4396c932ce31SPaolo Bonziniif test "$want_tools" = "yes" ; then
4397c932ce31SPaolo Bonzini  echo "CONFIG_TOOLS=y" >> $config_host_mak
4398c932ce31SPaolo Bonzinifi
4399f15bff25SPaolo Bonziniif test "$guest_agent" = "yes" ; then
4400f15bff25SPaolo Bonzini  echo "CONFIG_GUEST_AGENT=y" >> $config_host_mak
4401f15bff25SPaolo Bonzinifi
4402b8e0c493SJoelle van Dyneif test "$slirp_smbd" = "yes" ; then
4403b8e0c493SJoelle van Dyne  echo "CONFIG_SLIRP_SMBD=y" >> $config_host_mak
4404e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
4405b8e0c493SJoelle van Dynefi
44068a16d273Sthsif test "$vde" = "yes" ; then
440798ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
4408e2ad6f16SFam Zheng  echo "VDE_LIBS=$vde_libs" >> $config_host_mak
44098a16d273Sthsfi
441058952137SVincenzo Maffioneif test "$netmap" = "yes" ; then
441158952137SVincenzo Maffione  echo "CONFIG_NETMAP=y" >> $config_host_mak
441258952137SVincenzo Maffionefi
4413015a33bdSGongleiif test "$l2tpv3" = "yes" ; then
4414015a33bdSGonglei  echo "CONFIG_L2TPV3=y" >> $config_host_mak
4415015a33bdSGongleifi
44164cc600d2SPaolo Bonziniif test "$gprof" = "yes" ; then
44174cc600d2SPaolo Bonzini  echo "CONFIG_GPROF=y" >> $config_host_mak
44184cc600d2SPaolo Bonzinifi
4419b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
4420b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
4421e5f05f8cSKevin Wolfif test "$block_drv_whitelist_tools" = "yes" ; then
4422e5f05f8cSKevin Wolf  echo "CONFIG_BDRV_WHITELIST_TOOLS=y" >> $config_host_mak
4423e5f05f8cSKevin Wolffi
4424dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
4425dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
4426dce512deSChristoph Hellwigfi
442789138857SStefan Weilqemu_version=$(head $source_path/VERSION)
44282358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
442998ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
44302b1f35b9SAlex Bennéeecho "TARGET_DIRS=$target_list" >> $config_host_mak
443117969268SFam Zhengif test "$modules" = "yes"; then
4432e26110cfSFam Zheng  # $shacmd can generate a hash started with digit, which the compiler doesn't
4433e26110cfSFam Zheng  # like as an symbol. So prefix it with an underscore
443489138857SStefan Weil  echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
443517969268SFam Zheng  echo "CONFIG_MODULES=y" >> $config_host_mak
443617969268SFam Zhengfi
4437bd83c861SChristian Ehrhardtif test "$module_upgrades" = "yes"; then
4438bd83c861SChristian Ehrhardt  echo "CONFIG_MODULE_UPGRADES=y" >> $config_host_mak
4439bd83c861SChristian Ehrhardtfi
4440955727d2SCortland Tölvaif test "$have_usbfs" = "yes" ; then
4441955727d2SCortland Tölva  echo "CONFIG_USBFS=y" >> $config_host_mak
4442955727d2SCortland Tölvafi
4443f876b765SMarc-André Lureauif test "$gio" = "yes" ; then
4444f876b765SMarc-André Lureau    echo "CONFIG_GIO=y" >> $config_host_mak
4445f876b765SMarc-André Lureau    echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak
4446f876b765SMarc-André Lureau    echo "GIO_LIBS=$gio_libs" >> $config_host_mak
44475ecfb76cSPaolo Bonzinifi
44485ecfb76cSPaolo Bonziniif test "$gdbus_codegen" != "" ; then
444925a97a56SMarc-André Lureau    echo "GDBUS_CODEGEN=$gdbus_codegen" >> $config_host_mak
4450f876b765SMarc-André Lureaufi
4451a1c5e949SDaniel P. Berrangeecho "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
4452277abf15SJan Vesely
4453277abf15SJan Vesely# Work around a system header bug with some kernel/XFS header
4454277abf15SJan Vesely# versions where they both try to define 'struct fsxattr':
4455277abf15SJan Vesely# xfs headers will not try to redefine structs from linux headers
4456277abf15SJan Vesely# if this macro is set.
4457277abf15SJan Veselyif test "$have_fsxattr" = "yes" ; then
4458277abf15SJan Vesely    echo "HAVE_FSXATTR=y" >> $config_host_mak
4459277abf15SJan Veselyfi
44601badb709SPaolo Bonziniif test "$xen" = "enabled" ; then
44616dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
4462d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
4463582ea95fSMarc-André Lureau  echo "XEN_CFLAGS=$xen_cflags" >> $config_host_mak
4464582ea95fSMarc-André Lureau  echo "XEN_LIBS=$xen_libs" >> $config_host_mak
4465e37630caSaliguorifi
44665c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
44675c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
44685c6c3a6cSChristoph Hellwigfi
44695e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then
44705e9be92dSNicholas Bellinger  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
44715e9be92dSNicholas Bellingerfi
4472af3bba76SPaolo Bonziniif test "$vhost_net" = "yes" ; then
4473af3bba76SPaolo Bonzini  echo "CONFIG_VHOST_NET=y" >> $config_host_mak
4474af3bba76SPaolo Bonzinifi
4475af3bba76SPaolo Bonziniif test "$vhost_net_user" = "yes" ; then
447656f41de7SPaolo Bonzini  echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak
447703ce5744SNikolay Nikolaevfi
4478108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" ; then
4479108a6481SCindy Lu  echo "CONFIG_VHOST_NET_VDPA=y" >> $config_host_mak
4480108a6481SCindy Lufi
4481042cea27SGongleiif test "$vhost_crypto" = "yes" ; then
4482042cea27SGonglei  echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
4483042cea27SGongleifi
4484fc0b9b0eSStefan Hajnocziif test "$vhost_vsock" = "yes" ; then
4485fc0b9b0eSStefan Hajnoczi  echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
44865fe97d88SStefano Garzarella  if test "$vhost_user" = "yes" ; then
44875fe97d88SStefano Garzarella    echo "CONFIG_VHOST_USER_VSOCK=y" >> $config_host_mak
44885fe97d88SStefano Garzarella  fi
4489fc0b9b0eSStefan Hajnoczifi
4490299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" ; then
4491299e6f19SPaolo Bonzini  echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak
4492299e6f19SPaolo Bonzinifi
4493e6a74868SMarc-André Lureauif test "$vhost_user" = "yes" ; then
4494e6a74868SMarc-André Lureau  echo "CONFIG_VHOST_USER=y" >> $config_host_mak
4495e6a74868SMarc-André Lureaufi
4496108a6481SCindy Luif test "$vhost_vdpa" = "yes" ; then
4497108a6481SCindy Lu  echo "CONFIG_VHOST_VDPA=y" >> $config_host_mak
4498108a6481SCindy Lufi
449998fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" ; then
450098fc1adaSDr. David Alan Gilbert  echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak
450198fc1adaSDr. David Alan Gilbertfi
4502bf9298b9Saliguoriif test "$iovec" = "yes" ; then
45032358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
4504bf9298b9Saliguorifi
4505a40161cbSPaolo Bonziniif test "$membarrier" = "yes" ; then
4506a40161cbSPaolo Bonzini  echo "CONFIG_MEMBARRIER=y" >> $config_host_mak
4507a40161cbSPaolo Bonzinifi
4508e5b46549SRichard Hendersonif test "$tcg" = "enabled" -a "$tcg_interpreter" = "true" ; then
4509e5b46549SRichard Henderson  echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
4510e5b46549SRichard Hendersonfi
451158d3f3ffSGerd Hoffmann
451258d3f3ffSGerd Hoffmannif test "$spice_protocol" = "yes" ; then
451358d3f3ffSGerd Hoffmann  echo "CONFIG_SPICE_PROTOCOL=y" >> $config_host_mak
451458d3f3ffSGerd Hoffmann  echo "SPICE_PROTOCOL_CFLAGS=$spice_protocol_cflags" >> $config_host_mak
451558d3f3ffSGerd Hoffmannfi
4516cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
4517cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
451858d3f3ffSGerd Hoffmann  echo "SPICE_CFLAGS=$spice_cflags $spice_protocol_cflags" >> $config_host_mak
45192634733cSPaolo Bonzini  echo "SPICE_LIBS=$spice_libs" >> $config_host_mak
4520cd4ec0b4SGerd Hoffmannfi
4521cd4ec0b4SGerd Hoffmann
4522da076ffeSGerd Hoffmannif test "$opengl" = "yes" ; then
4523da076ffeSGerd Hoffmann  echo "CONFIG_OPENGL=y" >> $config_host_mak
4524de2d3005SPaolo Bonzini  echo "OPENGL_CFLAGS=$opengl_cflags" >> $config_host_mak
4525da076ffeSGerd Hoffmann  echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
452620ff075bSMichael Wallefi
452720ff075bSMichael Walle
452899f2dbd3SLiang Liif test "$avx2_opt" = "yes" ; then
452999f2dbd3SLiang Li  echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
453099f2dbd3SLiang Lifi
453199f2dbd3SLiang Li
45326b8cd447SRobert Hooif test "$avx512f_opt" = "yes" ; then
45336b8cd447SRobert Hoo  echo "CONFIG_AVX512F_OPT=y" >> $config_host_mak
45346b8cd447SRobert Hoofi
45356b8cd447SRobert Hoo
453683fb7adfSbellard# XXX: suppress that
45377d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
45382358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
45397d3505c5Sbellardfi
45407d3505c5Sbellard
45413556c233SPaolo Bonziniif test "$qom_cast_debug" = "yes" ; then
45423556c233SPaolo Bonzini  echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
45433556c233SPaolo Bonzinifi
454420ff6c80SAnthony Liguori
45457c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
454670c60c08SStefan Hajnocziif test "$coroutine_pool" = "yes" ; then
454770c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
454870c60c08SStefan Hajnoczielse
454970c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
455070c60c08SStefan Hajnoczifi
4551d0e2fce5SAneesh Kumar K.V
45527d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes" ; then
45537d992e4dSPeter Lieven  echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
45547d992e4dSPeter Lievenfi
45557d992e4dSPeter Lieven
4556f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes" ; then
4557f0d92b56SLongpeng(Mike)  echo "CONFIG_AF_ALG=y" >> $config_host_mak
4558f0d92b56SLongpeng(Mike)fi
4559f0d92b56SLongpeng(Mike)
4560d83414e1SMarc-André Lureauif test "$have_asan_iface_fiber" = "yes" ; then
4561d83414e1SMarc-André Lureau    echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
4562d83414e1SMarc-André Lureaufi
4563d83414e1SMarc-André Lureau
45640aebab04SLingfeng Yangif test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then
45650aebab04SLingfeng Yang    echo "CONFIG_TSAN=y" >> $config_host_mak
45660aebab04SLingfeng Yangfi
45670aebab04SLingfeng Yang
456876a347e1SRichard Hendersonif test "$cpuid_h" = "yes" ; then
456976a347e1SRichard Henderson  echo "CONFIG_CPUID_H=y" >> $config_host_mak
457076a347e1SRichard Hendersonfi
457176a347e1SRichard Henderson
4572f540166bSRichard Hendersonif test "$int128" = "yes" ; then
4573f540166bSRichard Henderson  echo "CONFIG_INT128=y" >> $config_host_mak
4574f540166bSRichard Hendersonfi
4575f540166bSRichard Henderson
45767ebee43eSRichard Hendersonif test "$atomic128" = "yes" ; then
45777ebee43eSRichard Henderson  echo "CONFIG_ATOMIC128=y" >> $config_host_mak
45787ebee43eSRichard Hendersonfi
45797ebee43eSRichard Henderson
4580e6cd4bb5SRichard Hendersonif test "$cmpxchg128" = "yes" ; then
4581e6cd4bb5SRichard Henderson  echo "CONFIG_CMPXCHG128=y" >> $config_host_mak
4582e6cd4bb5SRichard Hendersonfi
4583e6cd4bb5SRichard Henderson
4584df79b996SRichard Hendersonif test "$atomic64" = "yes" ; then
4585df79b996SRichard Henderson  echo "CONFIG_ATOMIC64=y" >> $config_host_mak
4586df79b996SRichard Hendersonfi
4587df79b996SRichard Henderson
45881e6e9acaSRichard Hendersonif test "$getauxval" = "yes" ; then
45891e6e9acaSRichard Henderson  echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
45901e6e9acaSRichard Hendersonfi
45911e6e9acaSRichard Henderson
4592b10d49d7SPino Toscanoif test "$libssh" = "yes" ; then
4593484e2cc7SPaolo Bonzini  echo "CONFIG_LIBSSH=y" >> $config_host_mak
4594b10d49d7SPino Toscano  echo "LIBSSH_CFLAGS=$libssh_cflags" >> $config_host_mak
4595b10d49d7SPino Toscano  echo "LIBSSH_LIBS=$libssh_libs" >> $config_host_mak
45960a12ec87SRichard W.M. Jonesfi
45970a12ec87SRichard W.M. Jones
4598ed1701c6SDr. David Alan Gilbertif test "$live_block_migration" = "yes" ; then
4599ed1701c6SDr. David Alan Gilbert  echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
4600ed1701c6SDr. David Alan Gilbertfi
4601ed1701c6SDr. David Alan Gilbert
46023b8acc11SPaolo Bonziniif test "$tpm" = "yes"; then
46033cae16dbSPaolo Bonzini  echo 'CONFIG_TPM=y' >> $config_host_mak
46043b8acc11SPaolo Bonzinifi
46053b8acc11SPaolo Bonzini
46065b808275SLluís Vilanovaecho "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
46075b808275SLluís Vilanovaif have_backend "nop"; then
46086d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
460922890ab5SPrerna Saxenafi
46105b808275SLluís Vilanovaif have_backend "simple"; then
46116d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
46126d8a764eSLluís  # Set the appropriate trace file.
4613953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
46149410b56cSPrerna Saxenafi
4615ed7f5f1dSPaolo Bonziniif have_backend "log"; then
4616ed7f5f1dSPaolo Bonzini  echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
46176d8a764eSLluísfi
46185b808275SLluís Vilanovaif have_backend "ust"; then
46196d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
4620a81df1b6SPaolo Bonzini  echo "LTTNG_UST_LIBS=$lttng_ust_libs" >> $config_host_mak
46216d8a764eSLluísfi
46225b808275SLluís Vilanovaif have_backend "dtrace"; then
46236d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
46246d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
46256d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
46266d8a764eSLluís  fi
4627c276b17dSDaniel P. Berrangefi
46285b808275SLluís Vilanovaif have_backend "ftrace"; then
4629781e9545SEiichi Tsukata  if test "$linux" = "yes" ; then
4630781e9545SEiichi Tsukata    echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
4631781e9545SEiichi Tsukata  else
463221684af0SStewart Smith    feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
4633781e9545SEiichi Tsukata  fi
4634781e9545SEiichi Tsukatafi
46350a852417SPaul Durrantif have_backend "syslog"; then
46360a852417SPaul Durrant  if test "$posix_syslog" = "yes" ; then
46370a852417SPaul Durrant    echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
46380a852417SPaul Durrant  else
46390a852417SPaul Durrant    feature_not_found "syslog(trace backend)" "syslog not available"
46400a852417SPaul Durrant  fi
46410a852417SPaul Durrantfi
46429410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
46439410b56cSPrerna Saxena
46442da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then
46452da776dbSMichael R. Hines  echo "CONFIG_RDMA=y" >> $config_host_mak
4646392fb643SFam Zheng  echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
46472da776dbSMichael R. Hinesfi
46482da776dbSMichael R. Hines
464921ab34c9SMarcel Apfelbaumif test "$pvrdma" = "yes" ; then
465021ab34c9SMarcel Apfelbaum  echo "CONFIG_PVRDMA=y" >> $config_host_mak
465121ab34c9SMarcel Apfelbaumfi
465221ab34c9SMarcel Apfelbaum
4653a6b1d4c0SChanglong Xieif test "$replication" = "yes" ; then
4654a6b1d4c0SChanglong Xie  echo "CONFIG_REPLICATION=y" >> $config_host_mak
4655a6b1d4c0SChanglong Xiefi
4656a6b1d4c0SChanglong Xie
46576a02c806SStefan Hajnocziif test "$have_af_vsock" = "yes" ; then
46586a02c806SStefan Hajnoczi  echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
46596a02c806SStefan Hajnoczifi
46606a02c806SStefan Hajnoczi
4661ba59fb77SPaolo Bonziniif test "$debug_mutex" = "yes" ; then
4662ba59fb77SPaolo Bonzini  echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak
4663ba59fb77SPaolo Bonzinifi
4664e0580342SKamil Rytarowski
46655c312079SDr. David Alan Gilbert# Hold two types of flag:
46665c312079SDr. David Alan Gilbert#   CONFIG_THREAD_SETNAME_BYTHREAD  - we've got a way of setting the name on
46675c312079SDr. David Alan Gilbert#                                     a thread we have a handle to
4668479a5747SRoman Bolshakov#   CONFIG_PTHREAD_SETNAME_NP_W_TID - A way of doing it on a particular
46695c312079SDr. David Alan Gilbert#                                     platform
4670479a5747SRoman Bolshakovif test "$pthread_setname_np_w_tid" = "yes" ; then
46715c312079SDr. David Alan Gilbert  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
4672479a5747SRoman Bolshakov  echo "CONFIG_PTHREAD_SETNAME_NP_W_TID=y" >> $config_host_mak
4673479a5747SRoman Bolshakovelif test "$pthread_setname_np_wo_tid" = "yes" ; then
4674479a5747SRoman Bolshakov  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
4675479a5747SRoman Bolshakov  echo "CONFIG_PTHREAD_SETNAME_NP_WO_TID=y" >> $config_host_mak
46765c312079SDr. David Alan Gilbertfi
46775c312079SDr. David Alan Gilbert
46782f740136SJeff Codyif test "$bochs" = "yes" ; then
46792f740136SJeff Cody  echo "CONFIG_BOCHS=y" >> $config_host_mak
46802f740136SJeff Codyfi
46812f740136SJeff Codyif test "$cloop" = "yes" ; then
46822f740136SJeff Cody  echo "CONFIG_CLOOP=y" >> $config_host_mak
46832f740136SJeff Codyfi
46842f740136SJeff Codyif test "$dmg" = "yes" ; then
46852f740136SJeff Cody  echo "CONFIG_DMG=y" >> $config_host_mak
46862f740136SJeff Codyfi
46872f740136SJeff Codyif test "$qcow1" = "yes" ; then
46882f740136SJeff Cody  echo "CONFIG_QCOW1=y" >> $config_host_mak
46892f740136SJeff Codyfi
46902f740136SJeff Codyif test "$vdi" = "yes" ; then
46912f740136SJeff Cody  echo "CONFIG_VDI=y" >> $config_host_mak
46922f740136SJeff Codyfi
46932f740136SJeff Codyif test "$vvfat" = "yes" ; then
46942f740136SJeff Cody  echo "CONFIG_VVFAT=y" >> $config_host_mak
46952f740136SJeff Codyfi
46962f740136SJeff Codyif test "$qed" = "yes" ; then
46972f740136SJeff Cody  echo "CONFIG_QED=y" >> $config_host_mak
46982f740136SJeff Codyfi
46992f740136SJeff Codyif test "$parallels" = "yes" ; then
47002f740136SJeff Cody  echo "CONFIG_PARALLELS=y" >> $config_host_mak
47012f740136SJeff Codyfi
4702195588ccSDavid CARLIERif test "$have_mlockall" = "yes" ; then
4703195588ccSDavid CARLIER  echo "HAVE_MLOCKALL=y" >> $config_host_mak
4704195588ccSDavid CARLIERfi
4705adc28027SAlexander Bulekovif test "$fuzzing" = "yes" ; then
470654c9e41dSAlexander Bulekov  # If LIB_FUZZING_ENGINE is set, assume we are running on OSS-Fuzz, and the
470754c9e41dSAlexander Bulekov  # needed CFLAGS have already been provided
470854c9e41dSAlexander Bulekov  if test -z "${LIB_FUZZING_ENGINE+xxx}" ; then
4709efce01bcSAlexander Bulekov    # Add CFLAGS to tell clang to add fuzzer-related instrumentation to all the
4710efce01bcSAlexander Bulekov    # compiled code.
4711086d5f75SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS -fsanitize=fuzzer-no-link"
4712efce01bcSAlexander Bulekov    # To build non-fuzzer binaries with --enable-fuzzing, link everything with
4713efce01bcSAlexander Bulekov    # fsanitize=fuzzer-no-link. Otherwise, the linker will be unable to bind
4714efce01bcSAlexander Bulekov    # the fuzzer-related callbacks added by instrumentation.
4715efce01bcSAlexander Bulekov    QEMU_LDFLAGS="$QEMU_LDFLAGS -fsanitize=fuzzer-no-link"
4716efce01bcSAlexander Bulekov    # For the actual fuzzer binaries, we need to link against the libfuzzer
4717efce01bcSAlexander Bulekov    # library. Provide the flags for doing this in FUZZ_EXE_LDFLAGS. The meson
4718efce01bcSAlexander Bulekov    # rule for the fuzzer adds these to the link_args. They need to be
4719efce01bcSAlexander Bulekov    # configurable, to support OSS-Fuzz
472054c9e41dSAlexander Bulekov    FUZZ_EXE_LDFLAGS="-fsanitize=fuzzer"
472154c9e41dSAlexander Bulekov  else
472254c9e41dSAlexander Bulekov    FUZZ_EXE_LDFLAGS="$LIB_FUZZING_ENGINE"
472354c9e41dSAlexander Bulekov  fi
4724dfc86c0fSAlexander Bulekov
4725dfc86c0fSAlexander Bulekov  # Specify a filter to only instrument code that is directly related to
4726dfc86c0fSAlexander Bulekov  # virtual-devices.
4727dfc86c0fSAlexander Bulekov  if test "$have_clang_coverage_filter" = "yes" ; then
4728dfc86c0fSAlexander Bulekov    cp "$source_path/scripts/oss-fuzz/instrumentation-filter-template" \
4729dfc86c0fSAlexander Bulekov       instrumentation-filter
4730dfc86c0fSAlexander Bulekov    QEMU_CFLAGS="$QEMU_CFLAGS -fsanitize-coverage-allowlist=instrumentation-filter"
4731dfc86c0fSAlexander Bulekov  fi
4732adc28027SAlexander Bulekovfi
47332f740136SJeff Cody
473440e8c6f4SAlex Bennéeif test "$plugins" = "yes" ; then
473540e8c6f4SAlex Bennée    echo "CONFIG_PLUGIN=y" >> $config_host_mak
473626fffe29SEmilio G. Cota    # Copy the export object list to the build dir
473726fffe29SEmilio G. Cota    if test "$ld_dynamic_list" = "yes" ; then
473826fffe29SEmilio G. Cota	echo "CONFIG_HAS_LD_DYNAMIC_LIST=yes" >> $config_host_mak
473926fffe29SEmilio G. Cota	ld_symbols=qemu-plugins-ld.symbols
474026fffe29SEmilio G. Cota	cp "$source_path/plugins/qemu-plugins.symbols" $ld_symbols
474126fffe29SEmilio G. Cota    elif test "$ld_exported_symbols_list" = "yes" ; then
474226fffe29SEmilio G. Cota	echo "CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST=yes" >> $config_host_mak
474326fffe29SEmilio G. Cota	ld64_symbols=qemu-plugins-ld64.symbols
474426fffe29SEmilio G. Cota	echo "# Automatically generated by configure - do not modify" > $ld64_symbols
474526fffe29SEmilio G. Cota	grep 'qemu_' "$source_path/plugins/qemu-plugins.symbols" | sed 's/;//g' | \
474626fffe29SEmilio G. Cota	    sed -E 's/^[[:space:]]*(.*)/_\1/' >> $ld64_symbols
474726fffe29SEmilio G. Cota    else
474826fffe29SEmilio G. Cota	error_exit \
474926fffe29SEmilio G. Cota	    "If \$plugins=yes, either \$ld_dynamic_list or " \
475026fffe29SEmilio G. Cota	    "\$ld_exported_symbols_list should have been set to 'yes'."
475126fffe29SEmilio G. Cota    fi
475240e8c6f4SAlex Bennéefi
475340e8c6f4SAlex Bennée
4754f48e590aSAlex Bennéeif test -n "$gdb_bin"; then
4755b1863cccSAlex Bennée    gdb_version=$($gdb_bin --version | head -n 1)
4756d6a66c81SAlex Bennée    if version_ge ${gdb_version##* } 9.1; then
4757f48e590aSAlex Bennée        echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
4758f48e590aSAlex Bennée    fi
4759b1863cccSAlex Bennéefi
4760f48e590aSAlex Bennée
476154e7aac0SAlexey Krasikovif test "$secret_keyring" = "yes" ; then
476254e7aac0SAlexey Krasikov  echo "CONFIG_SECRET_KEYRING=y" >> $config_host_mak
476354e7aac0SAlexey Krasikovfi
476454e7aac0SAlexey Krasikov
476598ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
4766804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
4767c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
476839d87c8cSAlex Bennéeecho "GENISOIMAGE=$genisoimage" >> $config_host_mak
4769a5665051SPaolo Bonziniecho "MESON=$meson" >> $config_host_mak
477009e93326SPaolo Bonziniecho "NINJA=$ninja" >> $config_host_mak
4771804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
4772433de74cSBastian Koppelmannecho "HOST_CC=$host_cc" >> $config_host_mak
4773a31a8642SMichael S. Tsirkinif $iasl -h > /dev/null 2>&1; then
4774859aef02SPaolo Bonzini  echo "CONFIG_IASL=$iasl" >> $config_host_mak
4775a31a8642SMichael S. Tsirkinfi
4776804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
4777cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak
47785f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak
47793dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak
4780804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
4781804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
478246eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
4783a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
478411cde1c8SBruno Dominguezecho "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
4785a81df1b6SPaolo Bonziniecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
4786a81df1b6SPaolo Bonziniecho "GLIB_LIBS=$glib_libs" >> $config_host_mak
47878a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
4788e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
4789804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
4790484e2cc7SPaolo Bonziniecho "HOST_DSOSUF=$HOST_DSOSUF" >> $config_host_mak
4791f15bff25SPaolo Bonziniecho "LIBS_QGA=$libs_qga" >> $config_host_mak
47921d728c39SBlue Swirlif test "$gcov" = "yes" ; then
47931d728c39SBlue Swirl  echo "CONFIG_GCOV=y" >> $config_host_mak
47941d728c39SBlue Swirlfi
4795804edf29SJuan Quintela
4796adc28027SAlexander Bulekovif test "$fuzzing" != "no"; then
4797adc28027SAlexander Bulekov    echo "CONFIG_FUZZ=y" >> $config_host_mak
4798adc28027SAlexander Bulekovfi
479954c9e41dSAlexander Bulekovecho "FUZZ_EXE_LDFLAGS=$FUZZ_EXE_LDFLAGS" >> $config_host_mak
48003efac6ebSTomáš Golembiovský
4801b767d257SMarek Marczykowski-Góreckiif test "$rng_none" = "yes"; then
4802b767d257SMarek Marczykowski-Górecki  echo "CONFIG_RNG_NONE=y" >> $config_host_mak
4803b767d257SMarek Marczykowski-Góreckifi
4804b767d257SMarek Marczykowski-Górecki
48056efd7517SPeter Maydell# use included Linux headers
48066efd7517SPeter Maydellif test "$linux" = "yes" ; then
4807a307beb6SAndreas Färber  mkdir -p linux-headers
48086efd7517SPeter Maydell  case "$cpu" in
4809c72b26ecSRichard Henderson  i386|x86_64|x32)
481008312a63SPeter Maydell    linux_arch=x86
48116efd7517SPeter Maydell    ;;
4812f8378accSRichard Henderson  ppc|ppc64|ppc64le)
481308312a63SPeter Maydell    linux_arch=powerpc
48146efd7517SPeter Maydell    ;;
48156efd7517SPeter Maydell  s390x)
481608312a63SPeter Maydell    linux_arch=s390
481708312a63SPeter Maydell    ;;
48181f080313SClaudio Fontana  aarch64)
48191f080313SClaudio Fontana    linux_arch=arm64
48201f080313SClaudio Fontana    ;;
4821222e7d11SSanjay Lal  mips64)
4822222e7d11SSanjay Lal    linux_arch=mips
4823222e7d11SSanjay Lal    ;;
482408312a63SPeter Maydell  *)
482508312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
482608312a63SPeter Maydell    linux_arch="$cpu"
48276efd7517SPeter Maydell    ;;
48286efd7517SPeter Maydell  esac
482908312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
483008312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
483108312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
483208312a63SPeter Maydell    fi
48336efd7517SPeter Maydellfi
48346efd7517SPeter Maydell
483597a847bcSbellardfor target in $target_list; do
483697a847bcSbellard    target_dir="$target"
483789138857SStefan Weil    target_name=$(echo $target | cut -d '-' -f 1)
483897a847bcSbellard    mkdir -p $target_dir
4839fdb75aefSPaolo Bonzini    case $target in
4840fdb75aefSPaolo Bonzini        *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;;
4841fdb75aefSPaolo Bonzini        *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;;
48422408a527Saurel32    esac
484356aebc89Spbrookdone
48447d13299dSbellard
4845765686d6SPaolo Bonziniecho "CONFIG_QEMU_INTERP_PREFIX=$interp_prefix" | sed 's/%M/@0@/' >> $config_host_mak
4846fdb75aefSPaolo Bonziniif test "$default_targets" = "yes"; then
4847fdb75aefSPaolo Bonzini  echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak
4848fdb75aefSPaolo Bonzinifi
4849a540f158SPeter Crosthwaite
4850a99d57bbSWanlong Gaoif test "$numa" = "yes"; then
4851a99d57bbSWanlong Gao  echo "CONFIG_NUMA=y" >> $config_host_mak
4852ab318051SMarc-André Lureau  echo "NUMA_LIBS=$numa_libs" >> $config_host_mak
4853a99d57bbSWanlong Gaofi
4854a99d57bbSWanlong Gao
4855fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then
4856fd0e6053SJohn Snow  echo "export CCACHE_CPP2=y" >> $config_host_mak
4857fd0e6053SJohn Snowfi
4858fd0e6053SJohn Snow
48591e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then
48601e4f6065SDaniele Buono  echo "CONFIG_SAFESTACK=y" >> $config_host_mak
48611e4f6065SDaniele Buonofi
48621e4f6065SDaniele Buono
4863e29e5c6eSPeter Maydell# If we're using a separate build tree, set it up now.
4864e29e5c6eSPeter Maydell# DIRS are directories which we simply mkdir in the build tree;
4865e29e5c6eSPeter Maydell# LINKS are things to symlink back into the source tree
4866e29e5c6eSPeter Maydell# (these can be both files and directories).
4867e29e5c6eSPeter Maydell# Caution: do not add files or directories here using wildcards. This
4868e29e5c6eSPeter Maydell# will result in problems later if a new file matching the wildcard is
4869e29e5c6eSPeter Maydell# added to the source tree -- nothing will cause configure to be rerun
4870e29e5c6eSPeter Maydell# so the build tree will be missing the link back to the new file, and
4871e29e5c6eSPeter Maydell# tests might fail. Prefer to keep the relevant files in their own
4872e29e5c6eSPeter Maydell# directory and symlink the directory instead.
487309db9b9dSGerd Hoffmann# UNLINK is used to remove symlinks from older development versions
487409db9b9dSGerd Hoffmann# that might get into the way when doing "git update" without doing
487509db9b9dSGerd Hoffmann# a "make distclean" in between.
48769d49bcf6SMarkus ArmbrusterDIRS="tests tests/tcg tests/qapi-schema tests/qtest/libqos"
48771cf4323eSThomas HuthDIRS="$DIRS tests/qtest tests/qemu-iotests tests/vm tests/fp tests/qgraph"
4878b855f8d1SPaolo BonziniDIRS="$DIRS docs docs/interop fsdev scsi"
4879744a928cSAlexey KardashevskiyDIRS="$DIRS pc-bios/optionrom pc-bios/s390-ccw"
48808db2a4fdSGerd HoffmannDIRS="$DIRS roms/seabios"
4881c17a386bSAlex BennéeDIRS="$DIRS contrib/plugins/"
48822038f8c8SPaolo BonziniLINKS="Makefile"
48833941996bSPaolo BonziniLINKS="$LINKS tests/tcg/Makefile.target"
4884ddcf607fSGerd HoffmannLINKS="$LINKS pc-bios/optionrom/Makefile"
4885e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/s390-ccw/Makefile"
48868db2a4fdSGerd HoffmannLINKS="$LINKS roms/seabios/Makefile"
4887e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/qemu-icon.bmp"
4888e29e5c6eSPeter MaydellLINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
488939950353SPeter MaydellLINKS="$LINKS tests/acceptance tests/data"
489039950353SPeter MaydellLINKS="$LINKS tests/qemu-iotests/check"
48918f8fd9edSCleber RosaLINKS="$LINKS python"
4892c17a386bSAlex BennéeLINKS="$LINKS contrib/plugins/Makefile "
489309db9b9dSGerd HoffmannUNLINK="pc-bios/keymaps"
4894753d11f2SRichard Hendersonfor bios_file in \
4895753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
48963a631b8eSBin Meng    $source_path/pc-bios/*.elf \
4897225a9ab8SAlexey Kardashevskiy    $source_path/pc-bios/*.lid \
4898753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
4899753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
4900e89e33e1SDominik Dingel    $source_path/pc-bios/*.img \
4901753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
49024e73c781SAlexander Graf    $source_path/pc-bios/u-boot.* \
490326ce90fdSLaszlo Ersek    $source_path/pc-bios/edk2-*.fd.bz2 \
4904cd946e5cSJohn Arbuckle    $source_path/pc-bios/palcode-* \
4905cd946e5cSJohn Arbuckle    $source_path/pc-bios/qemu_vga.ndrv
4906cd946e5cSJohn Arbuckle
4907753d11f2SRichard Hendersondo
4908e29e5c6eSPeter Maydell    LINKS="$LINKS pc-bios/$(basename $bios_file)"
49097ea78b74SJan Kiszkadone
4910d1807a4fSPaolo Bonzinimkdir -p $DIRS
4911e29e5c6eSPeter Maydellfor f in $LINKS ; do
49120f4d8894SPaolo Bonzini    if [ -e "$source_path/$f" ]; then
4913f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
4914f9245e10SPeter Maydell    fi
49157d13299dSbellarddone
491609db9b9dSGerd Hoffmannfor f in $UNLINK ; do
491709db9b9dSGerd Hoffmann    if [ -L "$f" ]; then
491809db9b9dSGerd Hoffmann        rm -f "$f"
491909db9b9dSGerd Hoffmann    fi
492009db9b9dSGerd Hoffmanndone
49211ad2134fSPaul Brook
49222038f8c8SPaolo Bonzini(for i in $cross_cc_vars; do
49232038f8c8SPaolo Bonzini  export $i
49242038f8c8SPaolo Bonzinidone
4925de6d7e6bSAlex Bennéeexport target_list source_path use_containers ARCH
49262038f8c8SPaolo Bonzini$source_path/tests/tcg/configure.sh)
49272038f8c8SPaolo Bonzini
4928c34ebfdcSAnthony Liguori# temporary config to build submodules
49298db2a4fdSGerd Hoffmannfor rom in seabios; do
4930c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
493137116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
4932c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
4933cdbd727cSRichard Henderson    echo "AS=$as" >> $config_mak
49345f6f0e27SRichard Henderson    echo "CCAS=$ccas" >> $config_mak
4935c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
4936c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
49373dd46c78SBlue Swirl    echo "CPP=$cpp" >> $config_mak
4938c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
4939a31a8642SMichael S. Tsirkin    echo "IASL=$iasl" >> $config_mak
4940c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
49419f81aeb5SAlistair Francis    echo "RANLIB=$ranlib" >> $config_mak
4942c34ebfdcSAnthony Liguoridone
4943c34ebfdcSAnthony Liguori
4944a5665051SPaolo Bonziniif test "$skip_meson" = no; then
4945fc929892SMarc-André Lureau  cross="config-meson.cross.new"
4946fc929892SMarc-André Lureau  meson_quote() {
494747b30835SPaolo Bonzini    echo "'$(echo $* | sed "s/ /','/g")'"
4948fc929892SMarc-André Lureau  }
4949fc929892SMarc-André Lureau
4950fc929892SMarc-André Lureau  echo "# Automatically generated by configure - do not modify" > $cross
4951fc929892SMarc-André Lureau  echo "[properties]" >> $cross
4952d1d5e9eeSAlex Bennée
4953d1d5e9eeSAlex Bennée  # unroll any custom device configs
4954d1d5e9eeSAlex Bennée  for a in $device_archs; do
4955d1d5e9eeSAlex Bennée      eval "c=\$devices_${a}"
4956d1d5e9eeSAlex Bennée      echo "${a}-softmmu = '$c'" >> $cross
4957d1d5e9eeSAlex Bennée  done
4958d1d5e9eeSAlex Bennée
4959fc929892SMarc-André Lureau  test -z "$cxx" && echo "link_language = 'c'" >> $cross
496047b30835SPaolo Bonzini  echo "[built-in options]" >> $cross
496147b30835SPaolo Bonzini  echo "c_args = [${CFLAGS:+$(meson_quote $CFLAGS)}]" >> $cross
496247b30835SPaolo Bonzini  echo "cpp_args = [${CXXFLAGS:+$(meson_quote $CXXFLAGS)}]" >> $cross
496347b30835SPaolo Bonzini  echo "c_link_args = [${LDFLAGS:+$(meson_quote $LDFLAGS)}]" >> $cross
496447b30835SPaolo Bonzini  echo "cpp_link_args = [${LDFLAGS:+$(meson_quote $LDFLAGS)}]" >> $cross
4965fc929892SMarc-André Lureau  echo "[binaries]" >> $cross
49664dba2789SPaolo Bonzini  echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross
49674dba2789SPaolo Bonzini  test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross
49684dba2789SPaolo Bonzini  test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross
496947b30835SPaolo Bonzini  echo "ar = [$(meson_quote $ar)]" >> $cross
497047b30835SPaolo Bonzini  echo "nm = [$(meson_quote $nm)]" >> $cross
497147b30835SPaolo Bonzini  echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross
497247b30835SPaolo Bonzini  echo "ranlib = [$(meson_quote $ranlib)]" >> $cross
4973e8178514SPaolo Bonzini  if has $sdl2_config; then
497447b30835SPaolo Bonzini    echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross
4975e8178514SPaolo Bonzini  fi
497647b30835SPaolo Bonzini  echo "strip = [$(meson_quote $strip)]" >> $cross
497747b30835SPaolo Bonzini  echo "windres = [$(meson_quote $windres)]" >> $cross
49783812c0c4SJoelle van Dyne  if test "$cross_compile" = "yes"; then
4979fc929892SMarc-André Lureau    cross_arg="--cross-file config-meson.cross"
4980fc929892SMarc-André Lureau    echo "[host_machine]" >> $cross
4981fc929892SMarc-André Lureau    if test "$mingw32" = "yes" ; then
4982fc929892SMarc-André Lureau        echo "system = 'windows'" >> $cross
4983fc929892SMarc-André Lureau    fi
4984853b4bafSThomas Huth    if test "$linux" = "yes" ; then
4985853b4bafSThomas Huth        echo "system = 'linux'" >> $cross
4986853b4bafSThomas Huth    fi
49870ca321eaSJoelle van Dyne    if test "$darwin" = "yes" ; then
49880ca321eaSJoelle van Dyne        echo "system = 'darwin'" >> $cross
49890ca321eaSJoelle van Dyne    fi
4990fc929892SMarc-André Lureau    case "$ARCH" in
4991f6bca9dfSJoelle van Dyne        i386)
4992fc929892SMarc-André Lureau            echo "cpu_family = 'x86'" >> $cross
4993fc929892SMarc-André Lureau            ;;
4994f8bb7e1cSDavid Michael        x86_64|x32)
4995f6bca9dfSJoelle van Dyne            echo "cpu_family = 'x86_64'" >> $cross
4996f6bca9dfSJoelle van Dyne            ;;
4997fc929892SMarc-André Lureau        ppc64le)
4998fc929892SMarc-André Lureau            echo "cpu_family = 'ppc64'" >> $cross
4999fc929892SMarc-André Lureau            ;;
5000fc929892SMarc-André Lureau        *)
5001fc929892SMarc-André Lureau            echo "cpu_family = '$ARCH'" >> $cross
5002fc929892SMarc-André Lureau            ;;
5003fc929892SMarc-André Lureau    esac
5004fc929892SMarc-André Lureau    echo "cpu = '$cpu'" >> $cross
5005fc929892SMarc-André Lureau    if test "$bigendian" = "yes" ; then
5006fc929892SMarc-André Lureau        echo "endian = 'big'" >> $cross
5007fc929892SMarc-André Lureau    else
5008fc929892SMarc-André Lureau        echo "endian = 'little'" >> $cross
5009fc929892SMarc-André Lureau    fi
5010fc929892SMarc-André Lureau  else
5011fc929892SMarc-André Lureau    cross_arg="--native-file config-meson.cross"
5012fc929892SMarc-André Lureau  fi
5013fc929892SMarc-André Lureau  mv $cross config-meson.cross
5014fc929892SMarc-André Lureau
5015a5665051SPaolo Bonzini  rm -rf meson-private meson-info meson-logs
501609e93326SPaolo Bonzini  NINJA=$ninja $meson setup \
5017d17f305aSPaolo Bonzini        --prefix "$prefix" \
5018d17f305aSPaolo Bonzini        --libdir "$libdir" \
5019d17f305aSPaolo Bonzini        --libexecdir "$libexecdir" \
5020d17f305aSPaolo Bonzini        --bindir "$bindir" \
5021d17f305aSPaolo Bonzini        --includedir "$includedir" \
5022d17f305aSPaolo Bonzini        --datadir "$datadir" \
5023d17f305aSPaolo Bonzini        --mandir "$mandir" \
5024d17f305aSPaolo Bonzini        --sysconfdir "$sysconfdir" \
502516bf7a33SPaolo Bonzini        --localedir "$localedir" \
5026d17f305aSPaolo Bonzini        --localstatedir "$local_statedir" \
5027d17f305aSPaolo Bonzini        -Ddocdir="$docdir" \
502816bf7a33SPaolo Bonzini        -Dqemu_firmwarepath="$firmwarepath" \
502973f3aa37SMarc-André Lureau        -Dqemu_suffix="$qemu_suffix" \
5030a5665051SPaolo Bonzini        -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) \
5031a5665051SPaolo Bonzini        -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo false; fi) \
5032a5665051SPaolo Bonzini        -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \
5033a5665051SPaolo Bonzini        -Dstrip=$(if test "$strip_opt" = yes; then echo true; else echo false; fi) \
5034da6d48b9SMarc-André Lureau        -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \
5035bf0e56a3SMarc-André Lureau        -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \
50369e62ba48SDaniele Buono        -Db_lto=$lto -Dcfi=$cfi -Dcfi_debug=$cfi_debug \
5037deb62371SPaolo Bonzini        -Dmalloc=$malloc -Dmalloc_trim=$malloc_trim -Dsparse=$sparse \
503874a414a1SReinoud Zandijk        -Dkvm=$kvm -Dhax=$hax -Dwhpx=$whpx -Dhvf=$hvf -Dnvmm=$nvmm \
50391badb709SPaolo Bonzini        -Dxen=$xen -Dxen_pci_passthrough=$xen_pci_passthrough -Dtcg=$tcg \
50401b695471SPaolo Bonzini        -Dcocoa=$cocoa -Dgtk=$gtk -Dmpath=$mpath -Dsdl=$sdl -Dsdl_image=$sdl_image \
5041c23d7b4eSPaolo Bonzini        -Dlibusb=$libusb -Dsmartcard=$smartcard -Dusb_redir=$usb_redir -Dvte=$vte \
5042a0b93237SPaolo Bonzini        -Dvnc=$vnc -Dvnc_sasl=$vnc_sasl -Dvnc_jpeg=$vnc_jpeg -Dvnc_png=$vnc_png \
5043cece116cSMisono Tomohiro        -Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f -Dvirtiofsd=$virtiofsd \
50448c6d4ff4SPaolo Bonzini        -Dcapstone=$capstone -Dslirp=$slirp -Dfdt=$fdt -Dbrlapi=$brlapi \
50459db405a3SPaolo Bonzini        -Dcurl=$curl -Dglusterfs=$glusterfs -Dbzip2=$bzip2 -Dlibiscsi=$libiscsi \
504630045c05SPaolo Bonzini        -Dlibnfs=$libnfs -Diconv=$iconv -Dcurses=$curses -Dlibudev=$libudev\
5047c5b36c25SPaolo Bonzini        -Drbd=$rbd -Dlzo=$lzo -Dsnappy=$snappy -Dlzfse=$lzfse -Dlibxml2=$libxml2 \
504853c22b68SPaolo Bonzini        -Dlibdaxctl=$libdaxctl -Dlibpmem=$libpmem -Dlinux_io_uring=$linux_io_uring \
504905e391aeSPaolo Bonzini        -Dgnutls=$gnutls -Dnettle=$nettle -Dgcrypt=$gcrypt -Dauth_pam=$auth_pam \
5050727c8bb8SPaolo Bonzini        -Dzstd=$zstd -Dseccomp=$seccomp -Dvirtfs=$virtfs -Dcap_ng=$cap_ng \
5051587d59d6SPaolo Bonzini        -Dattr=$attr -Ddefault_devices=$default_devices -Dvirglrenderer=$virglrenderer \
5052c8d5450bSPaolo Bonzini        -Ddocs=$docs -Dsphinx_build=$sphinx_build -Dinstall_blobs=$blobs \
5053106ad1f9SPaolo Bonzini        -Dvhost_user_blk_server=$vhost_user_blk_server -Dmultiprocess=$multiprocess \
505446627f41SAndrew Melnychenko        -Dfuse=$fuse -Dfuse_lseek=$fuse_lseek -Dguest_agent_msi=$guest_agent_msi -Dbpf=$bpf\
5055332008e0SThomas Huth        $(if test "$default_feature" = no; then echo "-Dauto_features=disabled"; fi) \
5056*ca50e523SPaolo Bonzini        -Dalsa=$alsa -Dcoreaudio=$coreaudio -Ddsound=$dsound -Djack=$jack -Doss=$oss \
5057*ca50e523SPaolo Bonzini        -Dpa=$pa -Daudio_drv_list=$audio_drv_list -Dtcg_interpreter=$tcg_interpreter \
5058fc929892SMarc-André Lureau        $cross_arg \
5059a5665051SPaolo Bonzini        "$PWD" "$source_path"
5060a5665051SPaolo Bonzini
5061a5665051SPaolo Bonzini  if test "$?" -ne 0 ; then
5062a5665051SPaolo Bonzini      error_exit "meson setup failed"
5063a5665051SPaolo Bonzini  fi
5064699d3884SPaolo Bonzinielse
5065699d3884SPaolo Bonzini  if test -f meson-private/cmd_line.txt; then
5066699d3884SPaolo Bonzini    # Adjust old command line options whose type was changed
5067699d3884SPaolo Bonzini    # Avoids having to use "setup --wipe" when Meson is upgraded
5068699d3884SPaolo Bonzini    perl -i -ne '
5069699d3884SPaolo Bonzini      s/^gettext = true$/gettext = auto/;
5070699d3884SPaolo Bonzini      s/^gettext = false$/gettext = disabled/;
5071654d6b04SPaolo Bonzini      /^b_staticpic/ && next;
5072699d3884SPaolo Bonzini      print;' meson-private/cmd_line.txt
5073699d3884SPaolo Bonzini  fi
5074a5665051SPaolo Bonzinifi
5075a5665051SPaolo Bonzini
50762d838d9bSAlex Bennéeif test -n "${deprecated_features}"; then
50772d838d9bSAlex Bennée    echo "Warning, deprecated features enabled."
5078a476b216SMao Zhongyi    echo "Please see docs/about/deprecated.rst"
50792d838d9bSAlex Bennée    echo "  features: ${deprecated_features}"
50802d838d9bSAlex Bennéefi
50812d838d9bSAlex Bennée
5082e0447a83SThomas Huth# Create list of config switches that should be poisoned in common code...
5083e0447a83SThomas Huth# but filter out CONFIG_TCG and CONFIG_USER_ONLY which are special.
508454b0306eSThomas Huthtarget_configs_h=$(ls *-config-devices.h *-config-target.h 2>/dev/null)
508554b0306eSThomas Huthif test -n "$target_configs_h" ; then
5086e0447a83SThomas Huth    sed -n -e '/CONFIG_TCG/d' -e '/CONFIG_USER_ONLY/d' \
5087e0447a83SThomas Huth        -e '/^#define / { s///; s/ .*//; s/^/#pragma GCC poison /p; }' \
508854b0306eSThomas Huth        $target_configs_h | sort -u > config-poison.h
508954b0306eSThomas Huthelse
509054b0306eSThomas Huth    :> config-poison.h
509154b0306eSThomas Huthfi
5092e0447a83SThomas Huth
5093dc655404SMichael S. Tsirkin# Save the configure command line for later reuse.
5094dc655404SMichael S. Tsirkincat <<EOD >config.status
5095dc655404SMichael S. Tsirkin#!/bin/sh
5096dc655404SMichael S. Tsirkin# Generated by configure.
5097dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration.
5098dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging
5099dc655404SMichael S. Tsirkin# configure, is in config.log if it exists.
5100dc655404SMichael S. TsirkinEOD
5101e811da7fSDaniel P. Berrangé
5102e811da7fSDaniel P. Berrangépreserve_env() {
5103e811da7fSDaniel P. Berrangé    envname=$1
5104e811da7fSDaniel P. Berrangé
5105e811da7fSDaniel P. Berrangé    eval envval=\$$envname
5106e811da7fSDaniel P. Berrangé
5107e811da7fSDaniel P. Berrangé    if test -n "$envval"
5108e811da7fSDaniel P. Berrangé    then
5109e811da7fSDaniel P. Berrangé	echo "$envname='$envval'" >> config.status
5110e811da7fSDaniel P. Berrangé	echo "export $envname" >> config.status
5111e811da7fSDaniel P. Berrangé    else
5112e811da7fSDaniel P. Berrangé	echo "unset $envname" >> config.status
5113e811da7fSDaniel P. Berrangé    fi
5114e811da7fSDaniel P. Berrangé}
5115e811da7fSDaniel P. Berrangé
5116e811da7fSDaniel P. Berrangé# Preserve various env variables that influence what
5117e811da7fSDaniel P. Berrangé# features/build target configure will detect
5118e811da7fSDaniel P. Berrangépreserve_env AR
5119e811da7fSDaniel P. Berrangépreserve_env AS
5120e811da7fSDaniel P. Berrangépreserve_env CC
5121e811da7fSDaniel P. Berrangépreserve_env CPP
5122e811da7fSDaniel P. Berrangépreserve_env CXX
5123e811da7fSDaniel P. Berrangépreserve_env INSTALL
5124e811da7fSDaniel P. Berrangépreserve_env LD
5125e811da7fSDaniel P. Berrangépreserve_env LD_LIBRARY_PATH
5126e811da7fSDaniel P. Berrangépreserve_env LIBTOOL
5127e811da7fSDaniel P. Berrangépreserve_env MAKE
5128e811da7fSDaniel P. Berrangépreserve_env NM
5129e811da7fSDaniel P. Berrangépreserve_env OBJCOPY
5130e811da7fSDaniel P. Berrangépreserve_env PATH
5131e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG
5132e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_LIBDIR
5133e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_PATH
5134e811da7fSDaniel P. Berrangépreserve_env PYTHON
5135e811da7fSDaniel P. Berrangépreserve_env SDL2_CONFIG
5136e811da7fSDaniel P. Berrangépreserve_env SMBD
5137e811da7fSDaniel P. Berrangépreserve_env STRIP
5138e811da7fSDaniel P. Berrangépreserve_env WINDRES
5139e811da7fSDaniel P. Berrangé
5140dc655404SMichael S. Tsirkinprintf "exec" >>config.status
5141a5665051SPaolo Bonzinifor i in "$0" "$@"; do
5142835af899SPaolo Bonzini  test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status
5143a5665051SPaolo Bonzinidone
5144cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status
5145dc655404SMichael S. Tsirkinchmod +x config.status
5146dc655404SMichael S. Tsirkin
51478cd05ab6SPeter Maydellrm -r "$TMPDIR1"
5148