xref: /openbmc/qemu/configure (revision e36e8c70f6d3ed844f4606f3f019d2ae808f0af1)
17d13299dSbellard#!/bin/sh
27d13299dSbellard#
33ef693a0Sbellard# qemu configure script (c) 2003 Fabrice Bellard
47d13299dSbellard#
58cd05ab6SPeter Maydell
699519e67SCornelia Huck# Unset some variables known to interfere with behavior of common tools,
799519e67SCornelia Huck# just as autoconf does.
899519e67SCornelia HuckCLICOLOR_FORCE= GREP_OPTIONS=
999519e67SCornelia Huckunset CLICOLOR_FORCE GREP_OPTIONS
1099519e67SCornelia Huck
115e4dfd3dSJohn Snow# Don't allow CCACHE, if present, to use cached results of compile tests!
125e4dfd3dSJohn Snowexport CCACHE_RECACHE=yes
135e4dfd3dSJohn Snow
14dedad027SDaniel P. Berrangé# make source path absolute
15dedad027SDaniel P. Berrangésource_path=$(cd "$(dirname -- "$0")"; pwd)
16dedad027SDaniel P. Berrangé
17dedad027SDaniel P. Berrangéif test "$PWD" = "$source_path"
18dedad027SDaniel P. Berrangéthen
19dedad027SDaniel P. Berrangé    echo "Using './build' as the directory for build output"
20dedad027SDaniel P. Berrangé
21dedad027SDaniel P. Berrangé    MARKER=build/auto-created-by-configure
22dedad027SDaniel P. Berrangé
23dedad027SDaniel P. Berrangé    if test -e build
24dedad027SDaniel P. Berrangé    then
25dedad027SDaniel P. Berrangé        if test -f $MARKER
26dedad027SDaniel P. Berrangé        then
27dedad027SDaniel P. Berrangé           rm -rf build
28dedad027SDaniel P. Berrangé        else
29dedad027SDaniel P. Berrangé            echo "ERROR: ./build dir already exists and was not previously created by configure"
30dedad027SDaniel P. Berrangé            exit 1
31dedad027SDaniel P. Berrangé        fi
32dedad027SDaniel P. Berrangé    fi
33dedad027SDaniel P. Berrangé
34dedad027SDaniel P. Berrangé    mkdir build
35dedad027SDaniel P. Berrangé    touch $MARKER
36dedad027SDaniel P. Berrangé
37dedad027SDaniel P. Berrangé    cat > GNUmakefile <<'EOF'
38dedad027SDaniel P. Berrangé# This file is auto-generated by configure to support in-source tree
39dedad027SDaniel P. Berrangé# 'make' command invocation
40dedad027SDaniel P. Berrangé
41dedad027SDaniel P. Berrangéifeq ($(MAKECMDGOALS),)
42dedad027SDaniel P. Berrangérecurse: all
43dedad027SDaniel P. Berrangéendif
44dedad027SDaniel P. Berrangé
45dedad027SDaniel P. Berrangé.NOTPARALLEL: %
46dedad027SDaniel P. Berrangé%: force
47dedad027SDaniel P. Berrangé	@echo 'changing dir to build for $(MAKE) "$(MAKECMDGOALS)"...'
48dedad027SDaniel P. Berrangé	@$(MAKE) -C build -f Makefile $(MAKECMDGOALS)
49dedad027SDaniel P. Berrangé	@if test "$(MAKECMDGOALS)" = "distclean" && \
50dedad027SDaniel P. Berrangé	    test -e build/auto-created-by-configure ; \
51dedad027SDaniel P. Berrangé	then \
52dedad027SDaniel P. Berrangé	    rm -rf build GNUmakefile ; \
53dedad027SDaniel P. Berrangé	fi
54dedad027SDaniel P. Berrangéforce: ;
55dedad027SDaniel P. Berrangé.PHONY: force
56dedad027SDaniel P. BerrangéGNUmakefile: ;
57dedad027SDaniel P. Berrangé
58dedad027SDaniel P. BerrangéEOF
59dedad027SDaniel P. Berrangé    cd build
60dedad027SDaniel P. Berrangé    exec $source_path/configure "$@"
61dedad027SDaniel P. Berrangéfi
62dedad027SDaniel P. Berrangé
638cd05ab6SPeter Maydell# Temporary directory used for files created while
648cd05ab6SPeter Maydell# configure runs. Since it is in the build directory
658cd05ab6SPeter Maydell# we can safely blow away any previous version of it
668cd05ab6SPeter Maydell# (and we need not jump through hoops to try to delete
678cd05ab6SPeter Maydell# it when configure exits.)
688cd05ab6SPeter MaydellTMPDIR1="config-temp"
698cd05ab6SPeter Maydellrm -rf "${TMPDIR1}"
708cd05ab6SPeter Maydellmkdir -p "${TMPDIR1}"
718cd05ab6SPeter Maydellif [ $? -ne 0 ]; then
728cd05ab6SPeter Maydell    echo "ERROR: failed to create temporary directory"
738cd05ab6SPeter Maydell    exit 1
747d13299dSbellardfi
757d13299dSbellard
768cd05ab6SPeter MaydellTMPB="qemu-conf"
778cd05ab6SPeter MaydellTMPC="${TMPDIR1}/${TMPB}.c"
7866518bf6SDon SlutzTMPO="${TMPDIR1}/${TMPB}.o"
799c83ffd8SPeter MaydellTMPCXX="${TMPDIR1}/${TMPB}.cxx"
808cd05ab6SPeter MaydellTMPE="${TMPDIR1}/${TMPB}.exe"
8126fffe29SEmilio G. CotaTMPTXT="${TMPDIR1}/${TMPB}.txt"
827d13299dSbellard
83da1d85e3SGerd Hoffmannrm -f config.log
849ac81bbbSmalc
85b48e3611SPeter Maydell# Print a helpful header at the top of config.log
86b48e3611SPeter Maydellecho "# QEMU configure log $(date)" >> config.log
87979ae168SPeter Maydellprintf "# Configured with:" >> config.log
88979ae168SPeter Maydellprintf " '%s'" "$0" "$@" >> config.log
89979ae168SPeter Maydellecho >> config.log
90b48e3611SPeter Maydellecho "#" >> config.log
91b48e3611SPeter Maydell
92835af899SPaolo Bonziniquote_sh() {
93835af899SPaolo Bonzini    printf "%s" "$1" | sed "s,','\\\\'',g; s,.*,'&',"
94835af899SPaolo Bonzini}
95835af899SPaolo Bonzini
96d880a3baSPaolo Bonziniprint_error() {
97d880a3baSPaolo Bonzini    (echo
9876ad07a4SPeter Maydell    echo "ERROR: $1"
9976ad07a4SPeter Maydell    while test -n "$2"; do
10076ad07a4SPeter Maydell        echo "       $2"
10176ad07a4SPeter Maydell        shift
10276ad07a4SPeter Maydell    done
103d880a3baSPaolo Bonzini    echo) >&2
104d880a3baSPaolo Bonzini}
105d880a3baSPaolo Bonzini
106d880a3baSPaolo Bonzinierror_exit() {
107d880a3baSPaolo Bonzini    print_error "$@"
10876ad07a4SPeter Maydell    exit 1
10976ad07a4SPeter Maydell}
11076ad07a4SPeter Maydell
1119c83ffd8SPeter Maydelldo_compiler() {
1129c83ffd8SPeter Maydell    # Run the compiler, capturing its output to the log. First argument
1139c83ffd8SPeter Maydell    # is compiler binary to execute.
114630d86b7SDavid CARLIER    compiler="$1"
1159c83ffd8SPeter Maydell    shift
1168bbe05d7SIan Jackson    if test -n "$BASH_VERSION"; then eval '
1178bbe05d7SIan Jackson        echo >>config.log "
1188bbe05d7SIan Jacksonfuncs: ${FUNCNAME[*]}
1198bbe05d7SIan Jacksonlines: ${BASH_LINENO[*]}"
1208bbe05d7SIan Jackson    '; fi
1219c83ffd8SPeter Maydell    echo $compiler "$@" >> config.log
1229c83ffd8SPeter Maydell    $compiler "$@" >> config.log 2>&1 || return $?
1238dc38a78SPeter Maydell    # Test passed. If this is an --enable-werror build, rerun
1248dc38a78SPeter Maydell    # the test with -Werror and bail out if it fails. This
1258dc38a78SPeter Maydell    # makes warning-generating-errors in configure test code
1268dc38a78SPeter Maydell    # obvious to developers.
1278dc38a78SPeter Maydell    if test "$werror" != "yes"; then
1288dc38a78SPeter Maydell        return 0
1298dc38a78SPeter Maydell    fi
1308dc38a78SPeter Maydell    # Don't bother rerunning the compile if we were already using -Werror
1318dc38a78SPeter Maydell    case "$*" in
1328dc38a78SPeter Maydell        *-Werror*)
1338dc38a78SPeter Maydell           return 0
1348dc38a78SPeter Maydell        ;;
1358dc38a78SPeter Maydell    esac
1369c83ffd8SPeter Maydell    echo $compiler -Werror "$@" >> config.log
1379c83ffd8SPeter Maydell    $compiler -Werror "$@" >> config.log 2>&1 && return $?
13876ad07a4SPeter Maydell    error_exit "configure test passed without -Werror but failed with -Werror." \
13976ad07a4SPeter Maydell        "This is probably a bug in the configure script. The failing command" \
14076ad07a4SPeter Maydell        "will be at the bottom of config.log." \
14176ad07a4SPeter Maydell        "You can run configure with --disable-werror to bypass this check."
1428dc38a78SPeter Maydell}
1438dc38a78SPeter Maydell
1449c83ffd8SPeter Maydelldo_cc() {
1459c83ffd8SPeter Maydell    do_compiler "$cc" "$@"
1469c83ffd8SPeter Maydell}
1479c83ffd8SPeter Maydell
1489c83ffd8SPeter Maydelldo_cxx() {
1499c83ffd8SPeter Maydell    do_compiler "$cxx" "$@"
1509c83ffd8SPeter Maydell}
1519c83ffd8SPeter Maydell
15200849b92SRichard Henderson# Append $2 to the variable named $1, with space separation
15300849b92SRichard Hendersonadd_to() {
15400849b92SRichard Henderson    eval $1=\${$1:+\"\$$1 \"}\$2
15500849b92SRichard Henderson}
15600849b92SRichard Henderson
1579c83ffd8SPeter Maydellupdate_cxxflags() {
1589c83ffd8SPeter Maydell    # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
1599c83ffd8SPeter Maydell    # options which some versions of GCC's C++ compiler complain about
1609c83ffd8SPeter Maydell    # because they only make sense for C programs.
16153422040SPaolo Bonzini    QEMU_CXXFLAGS="$QEMU_CXXFLAGS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS"
1628a9d3d56SRichard Henderson    CONFIGURE_CXXFLAGS=$(echo "$CONFIGURE_CFLAGS" | sed s/-std=gnu11/-std=gnu++11/)
1639c83ffd8SPeter Maydell    for arg in $QEMU_CFLAGS; do
1649c83ffd8SPeter Maydell        case $arg in
1659c83ffd8SPeter Maydell            -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
1669c83ffd8SPeter Maydell            -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
1679c83ffd8SPeter Maydell                ;;
1689c83ffd8SPeter Maydell            *)
1699c83ffd8SPeter Maydell                QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
1709c83ffd8SPeter Maydell                ;;
1719c83ffd8SPeter Maydell        esac
1729c83ffd8SPeter Maydell    done
1739c83ffd8SPeter Maydell}
1749c83ffd8SPeter Maydell
17552166aa0SJuan Quintelacompile_object() {
176fd0e6053SJohn Snow  local_cflags="$1"
1775770e8afSPaolo Bonzini  do_cc $CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
17852166aa0SJuan Quintela}
17952166aa0SJuan Quintela
18052166aa0SJuan Quintelacompile_prog() {
18152166aa0SJuan Quintela  local_cflags="$1"
18252166aa0SJuan Quintela  local_ldflags="$2"
1835770e8afSPaolo Bonzini  do_cc $CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC \
1845770e8afSPaolo Bonzini      $LDFLAGS $CONFIGURE_LDFLAGS $QEMU_LDFLAGS $local_ldflags
18552166aa0SJuan Quintela}
18652166aa0SJuan Quintela
18711568d6dSPaolo Bonzini# symbolically link $1 to $2.  Portable version of "ln -sf".
18811568d6dSPaolo Bonzinisymlink() {
18972b8b5a1SStefan Weil  rm -rf "$2"
190ec5b06d7SAnthony Liguori  mkdir -p "$(dirname "$2")"
19172b8b5a1SStefan Weil  ln -s "$1" "$2"
19211568d6dSPaolo Bonzini}
19311568d6dSPaolo Bonzini
1940dba6195SLoïc Minier# check whether a command is available to this shell (may be either an
1950dba6195SLoïc Minier# executable or a builtin)
1960dba6195SLoïc Minierhas() {
1970dba6195SLoïc Minier    type "$1" >/dev/null 2>&1
1980dba6195SLoïc Minier}
1990dba6195SLoïc Minier
2000a01d76fSMarc-André Lureauversion_ge () {
2012df52b9bSAlex Bennée    local_ver1=$(expr "$1" : '\([0-9.]*\)' | tr . ' ')
2022df52b9bSAlex Bennée    local_ver2=$(echo "$2" | tr . ' ')
2030a01d76fSMarc-André Lureau    while true; do
2040a01d76fSMarc-André Lureau        set x $local_ver1
2050a01d76fSMarc-André Lureau        local_first=${2-0}
206c44a33e2SStefano Garzarella        # 'shift 2' if $2 is set, or 'shift' if $2 is not set
207c44a33e2SStefano Garzarella        shift ${2:+2}
2080a01d76fSMarc-André Lureau        local_ver1=$*
2090a01d76fSMarc-André Lureau        set x $local_ver2
2100a01d76fSMarc-André Lureau        # the second argument finished, the first must be greater or equal
2110a01d76fSMarc-André Lureau        test $# = 1 && return 0
2120a01d76fSMarc-André Lureau        test $local_first -lt $2 && return 1
2130a01d76fSMarc-André Lureau        test $local_first -gt $2 && return 0
214c44a33e2SStefano Garzarella        shift ${2:+2}
2150a01d76fSMarc-André Lureau        local_ver2=$*
2160a01d76fSMarc-André Lureau    done
2170a01d76fSMarc-André Lureau}
2180a01d76fSMarc-André Lureau
2195b808275SLluís Vilanovahave_backend () {
2205b808275SLluís Vilanova    echo "$trace_backends" | grep "$1" >/dev/null
2215b808275SLluís Vilanova}
2225b808275SLluís Vilanova
2233b6b7550SPaolo Bonziniglob() {
2243b6b7550SPaolo Bonzini    eval test -z '"${1#'"$2"'}"'
2253b6b7550SPaolo Bonzini}
2263b6b7550SPaolo Bonzini
227e9a3591fSChristian Borntraegerld_has() {
228e9a3591fSChristian Borntraeger    $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
229e9a3591fSChristian Borntraeger}
230e9a3591fSChristian Borntraeger
2314ace32e2SAntonio Ospiteif printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]";
2324ace32e2SAntonio Ospitethen
2334ace32e2SAntonio Ospite  error_exit "main directory cannot contain spaces nor colons"
2344ace32e2SAntonio Ospitefi
2354ace32e2SAntonio Ospite
23614211825SAntonio Ospite# default parameters
2372ff6b91eSJuan Quintelacpu=""
238a31a8642SMichael S. Tsirkiniasl="iasl"
2391e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
24043ce4dfeSbellardstatic="no"
2413812c0c4SJoelle van Dynecross_compile="no"
2427d13299dSbellardcross_prefix=""
2430c58ac1cSmalcaudio_drv_list=""
244b64ec4e4SFam Zhengblock_drv_rw_whitelist=""
245b64ec4e4SFam Zhengblock_drv_ro_whitelist=""
246e49d021eSPeter Maydellhost_cc="cc"
247d5631638Smalcaudio_win_int=""
248957f1f99SMichael Rothlibs_qga=""
2495bc62e01SGerd Hoffmanndebug_info="yes"
250cdad781dSDaniele Buonolto="false"
25163678e17SSteven Noonanstack_protector=""
2521e4f6065SDaniele Buonosafe_stack=""
253afc3a8f9SAlex Bennéeuse_containers="yes"
254f2385398SAlex Bennéegdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
255ac0df51dSaliguori
25692712822SDaniel P. Berrangeif test -e "$source_path/.git"
25792712822SDaniel P. Berrangethen
2587d7dbf9dSDan Streetman    git_submodules_action="update"
25992712822SDaniel P. Berrangeelse
2607d7dbf9dSDan Streetman    git_submodules_action="ignore"
26192712822SDaniel P. Berrangefi
2622d652f24SPaolo Bonzini
2632d652f24SPaolo Bonzinigit_submodules="ui/keycodemapdb"
264cc84d63aSDaniel P. Berrangegit="git"
265ac0df51dSaliguori
266afb63ebdSStefan Weil# Don't accept a target_list environment variable.
267afb63ebdSStefan Weilunset target_list
268447e133fSAlex Bennéeunset target_list_exclude
269377529c0SPaolo Bonzini
270377529c0SPaolo Bonzini# Default value for a variable defining feature "foo".
271377529c0SPaolo Bonzini#  * foo="no"  feature will only be used if --enable-foo arg is given
272377529c0SPaolo Bonzini#  * foo=""    feature will be searched for, and if found, will be used
273377529c0SPaolo Bonzini#              unless --disable-foo is given
274377529c0SPaolo Bonzini#  * foo="yes" this value will only be set by --enable-foo flag.
275377529c0SPaolo Bonzini#              feature will searched for,
276377529c0SPaolo Bonzini#              if not found, configure exits with error
277377529c0SPaolo Bonzini#
278377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args.
279377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it
280377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found.
281377529c0SPaolo Bonzini
282c87ea116SAlex Bennéedefault_feature=""
283c87ea116SAlex Bennée# parse CC options second
284c87ea116SAlex Bennéefor opt do
285c87ea116SAlex Bennée  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
286c87ea116SAlex Bennée  case "$opt" in
287c87ea116SAlex Bennée      --without-default-features)
288c87ea116SAlex Bennée          default_feature="no"
289c87ea116SAlex Bennée  ;;
290c87ea116SAlex Bennée  esac
291c87ea116SAlex Bennéedone
292c87ea116SAlex Bennée
2938c6d4ff4SPaolo Bonzinibrlapi="auto"
294f9cd86feSPaolo Bonzinicurl="auto"
2955285e593SYonggang Luoiconv="auto"
2965285e593SYonggang Luocurses="auto"
297e3667660SYonggang Luodocs="auto"
298fbb4121dSPaolo Bonzinifdt="auto"
29958952137SVincenzo Maffionenetmap="no"
30035be72baSPaolo Bonzinisdl="auto"
30135be72baSPaolo Bonzinisdl_image="auto"
302422a5fd0SJoelle van Dynecoreaudio="auto"
303cece116cSMisono Tomohirovirtiofsd="auto"
30469202b40SPaolo Bonzinivirtfs="auto"
3055c53015aSPaolo Bonzinilibudev="auto"
3066ec0e15dSPaolo Bonzinimpath="auto"
307a0b93237SPaolo Bonzinivnc="enabled"
308deb62371SPaolo Bonzinisparse="auto"
309c87ea116SAlex Bennéevde="$default_feature"
310a0b93237SPaolo Bonzinivnc_sasl="auto"
311a0b93237SPaolo Bonzinivnc_jpeg="auto"
312a0b93237SPaolo Bonzinivnc_png="auto"
3134113f4cfSLaurent Vivierxkbcommon="auto"
314c87ea116SAlex Bennéexen="$default_feature"
315c87ea116SAlex Bennéexen_ctrl_version="$default_feature"
3161badb709SPaolo Bonzinixen_pci_passthrough="auto"
317c87ea116SAlex Bennéelinux_aio="$default_feature"
318c87ea116SAlex Bennéelinux_io_uring="$default_feature"
319727c8bb8SPaolo Bonzinicap_ng="auto"
320f7f2d651SPaolo Bonziniattr="auto"
321c87ea116SAlex Bennéexfs="$default_feature"
3221badb709SPaolo Bonzinitcg="enabled"
323c87ea116SAlex Bennéemembarrier="$default_feature"
324c87ea116SAlex Bennéevhost_net="$default_feature"
325c87ea116SAlex Bennéevhost_crypto="$default_feature"
326c87ea116SAlex Bennéevhost_scsi="$default_feature"
327c87ea116SAlex Bennéevhost_vsock="$default_feature"
328d88618f7SStefan Hajnoczivhost_user="no"
329e5e856c1SStefan Hajnoczivhost_user_blk_server="auto"
330c87ea116SAlex Bennéevhost_user_fs="$default_feature"
33146627f41SAndrew Melnychenkobpf="auto"
3323bd40ec7SPaolo Bonzinikvm="auto"
3333bd40ec7SPaolo Bonzinihax="auto"
3343bd40ec7SPaolo Bonzinihvf="auto"
3353bd40ec7SPaolo Bonziniwhpx="auto"
33674a414a1SReinoud Zandijknvmm="auto"
337c87ea116SAlex Bennéerdma="$default_feature"
338c87ea116SAlex Bennéepvrdma="$default_feature"
339377529c0SPaolo Bonzinigprof="no"
340377529c0SPaolo Bonzinidebug_tcg="no"
341377529c0SPaolo Bonzinidebug="no"
342247724cbSMarc-André Lureausanitizers="no"
3430aebab04SLingfeng Yangtsan="no"
344c87ea116SAlex Bennéefortify_source="$default_feature"
345377529c0SPaolo Bonzinistrip_opt="yes"
34623a77b2dSPaolo Bonzinitcg_interpreter="false"
347377529c0SPaolo Bonzinibigendian="no"
348377529c0SPaolo Bonzinimingw32="no"
3491d728c39SBlue Swirlgcov="no"
350c7328271SMiroslav RezaninaEXESUF=""
351484e2cc7SPaolo BonziniHOST_DSOSUF=".so"
35217969268SFam Zhengmodules="no"
353bd83c861SChristian Ehrhardtmodule_upgrades="no"
354377529c0SPaolo Bonziniprefix="/usr/local"
35510ff82d1SMarc-André Lureauqemu_suffix="qemu"
3564d34a86bSPaolo Bonzinislirp="auto"
357377529c0SPaolo Bonzinioss_lib=""
358377529c0SPaolo Bonzinibsd="no"
359377529c0SPaolo Bonzinilinux="no"
360377529c0SPaolo Bonzinisolaris="no"
361377529c0SPaolo Bonziniprofiler="no"
362b4e312e9SPaolo Bonzinicocoa="auto"
363377529c0SPaolo Bonzinisoftmmu="yes"
364377529c0SPaolo Bonzinilinux_user="no"
365377529c0SPaolo Bonzinibsd_user="no"
366c8d5450bSPaolo Bonziniblobs="true"
367377529c0SPaolo Bonzinipkgversion=""
36840d6444eSAvi Kivitypie=""
3693556c233SPaolo Bonziniqom_cast_debug="yes"
370baf86d6bSPaolo Bonzinitrace_backends="log"
371377529c0SPaolo Bonzinitrace_file="trace"
372c87ea116SAlex Bennéespice="$default_feature"
37358d3f3ffSGerd Hoffmannspice_protocol="auto"
374fabd1e93SPaolo Bonzinirbd="auto"
3755f364c57SPaolo Bonzinismartcard="auto"
3760a40bcb7SCésar Belleyu2f="auto"
37790540f32SPaolo Bonzinilibusb="auto"
37818f31e60SPaolo Bonziniusb_redir="auto"
379c87ea116SAlex Bennéeopengl="$default_feature"
3805dd89908SRichard Hendersoncpuid_h="no"
381c87ea116SAlex Bennéeavx2_opt="$default_feature"
3828b18cdbfSRichard Hendersoncapstone="auto"
3830c32a0aeSPaolo Bonzinilzo="auto"
384241611eaSPaolo Bonzinisnappy="auto"
38529ba6116SPaolo Bonzinibzip2="auto"
386ecea3696SPaolo Bonzinilzfse="auto"
387b1def33dSPaolo Bonzinizstd="auto"
388c87ea116SAlex Bennéeguest_agent="$default_feature"
389d9840e25STomoki Sekiyamaguest_agent_with_vss="no"
39050cbebb9SMichael Rothguest_agent_ntddscsi="no"
391b846ab7cSPaolo Bonziniguest_agent_msi="auto"
392c87ea116SAlex Bennéevss_win32_sdk="$default_feature"
393d9840e25STomoki Sekiyamawin_sdk="no"
394c87ea116SAlex Bennéewant_tools="$default_feature"
3959db405a3SPaolo Bonzinilibiscsi="auto"
39630045c05SPaolo Bonzinilibnfs="auto"
397519175a2SAlex Barcelocoroutine=""
398c87ea116SAlex Bennéecoroutine_pool="$default_feature"
3997d992e4dSPeter Lievendebug_stack_usage="no"
400f0d92b56SLongpeng(Mike)crypto_afalg="no"
4019e62ba48SDaniele Buonocfi="false"
4029e62ba48SDaniele Buonocfi_debug="false"
40390835c2bSPaolo Bonziniseccomp="auto"
40408821ca2SPaolo Bonziniglusterfs="auto"
4051b695471SPaolo Bonzinigtk="auto"
406a1c5e949SDaniel P. Berrangetls_priority="NORMAL"
40757612511SPaolo Bonzinignutls="auto"
40857612511SPaolo Bonzininettle="auto"
40957612511SPaolo Bonzinigcrypt="auto"
41005e391aeSPaolo Bonziniauth_pam="auto"
411c23d7b4eSPaolo Bonzinivte="auto"
412587d59d6SPaolo Bonzinivirglrenderer="auto"
413c87ea116SAlex Bennéetpm="$default_feature"
414c87ea116SAlex Bennéelibssh="$default_feature"
415c87ea116SAlex Bennéelive_block_migration=${default_feature:-yes}
416c87ea116SAlex Bennéenuma="$default_feature"
4172847b469SFam Zhengtcmalloc="no"
4187b01cb97SAlexandre Derumierjemalloc="no"
419c87ea116SAlex Bennéereplication=${default_feature:-yes}
420c87ea116SAlex Bennéebochs=${default_feature:-yes}
421c87ea116SAlex Bennéecloop=${default_feature:-yes}
422c87ea116SAlex Bennéedmg=${default_feature:-yes}
423c87ea116SAlex Bennéeqcow1=${default_feature:-yes}
424c87ea116SAlex Bennéevdi=${default_feature:-yes}
425c87ea116SAlex Bennéevvfat=${default_feature:-yes}
426c87ea116SAlex Bennéeqed=${default_feature:-yes}
427c87ea116SAlex Bennéeparallels=${default_feature:-yes}
428c87ea116SAlex Bennéelibxml2="$default_feature"
429ba59fb77SPaolo Bonzinidebug_mutex="no"
430*e36e8c70SPaolo Bonzinilibpmem="auto"
4317bc3ca7fSPaolo Bonzinidefault_devices="true"
43240e8c6f4SAlex Bennéeplugins="no"
433adc28027SAlexander Bulekovfuzzing="no"
434b767d257SMarek Marczykowski-Góreckirng_none="no"
435c87ea116SAlex Bennéesecret_keyring="$default_feature"
43683ef1682SPaolo Bonzinilibdaxctl="auto"
437a5665051SPaolo Bonzinimeson=""
43848328880SPaolo Bonzinininja=""
439a5665051SPaolo Bonziniskip_meson=no
4400e8e77d4SAlex Bennéegettext="auto"
441a484a719SMax Reitzfuse="auto"
442df4ea709SMax Reitzfuse_lseek="auto"
443106ad1f9SPaolo Bonzinimultiprocess="auto"
444b8e0c493SJoelle van Dyneslirp_smbd="$default_feature"
445377529c0SPaolo Bonzini
446aa087962SPaolo Bonzinimalloc_trim="auto"
44720cf7b8eSDenis Plotnikovgio="$default_feature"
448898be3e0SPeter Maydell
449c87ea116SAlex Bennée# parse CC options second
450ac0df51dSaliguorifor opt do
45189138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
452ac0df51dSaliguori  case "$opt" in
453ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
4543812c0c4SJoelle van Dyne                    cross_compile="yes"
455ac0df51dSaliguori  ;;
4563d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
457ac0df51dSaliguori  ;;
45883f73fceSTomoki Sekiyama  --cxx=*) CXX="$optarg"
45983f73fceSTomoki Sekiyama  ;;
4602ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
4612ff6b91eSJuan Quintela  ;;
462de385287SAlex Bennée  --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
463db5adeaaSPaolo Bonzini                    QEMU_LDFLAGS="$QEMU_LDFLAGS $optarg"
464e2a2ed06SJuan Quintela  ;;
46511cde1c8SBruno Dominguez  --extra-cxxflags=*) QEMU_CXXFLAGS="$QEMU_CXXFLAGS $optarg"
46611cde1c8SBruno Dominguez  ;;
467db5adeaaSPaolo Bonzini  --extra-ldflags=*) QEMU_LDFLAGS="$QEMU_LDFLAGS $optarg"
468f9943cd5SGerd Hoffmann                     EXTRA_LDFLAGS="$optarg"
469e2a2ed06SJuan Quintela  ;;
4705bc62e01SGerd Hoffmann  --enable-debug-info) debug_info="yes"
4715bc62e01SGerd Hoffmann  ;;
4725bc62e01SGerd Hoffmann  --disable-debug-info) debug_info="no"
4735bc62e01SGerd Hoffmann  ;;
474d75402b5SAlex Bennée  --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
475d75402b5SAlex Bennée  ;;
476d422b2bcSAlex Bennée  --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-flags-}; cc_arch=${cc_arch%%=*}
477d422b2bcSAlex Bennée                      eval "cross_cc_cflags_${cc_arch}=\$optarg"
4782038f8c8SPaolo Bonzini                      cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}"
479d422b2bcSAlex Bennée  ;;
480d75402b5SAlex Bennée  --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
4812038f8c8SPaolo Bonzini                cc_archs="$cc_archs $cc_arch"
482d75402b5SAlex Bennée                eval "cross_cc_${cc_arch}=\$optarg"
4832038f8c8SPaolo Bonzini                cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}"
484d75402b5SAlex Bennée  ;;
485ac0df51dSaliguori  esac
486ac0df51dSaliguoridone
487ac0df51dSaliguori# OS specific
488ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
48993148aa5SStefan Weil# we can eliminate its usage altogether.
490ac0df51dSaliguori
491e49d021eSPeter Maydell# Preferred compiler:
492e49d021eSPeter Maydell#  ${CC} (if set)
493e49d021eSPeter Maydell#  ${cross_prefix}gcc (if cross-prefix specified)
494e49d021eSPeter Maydell#  system compiler
495e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then
496e49d021eSPeter Maydell  cc="$host_cc"
497e49d021eSPeter Maydellelse
498b3198cc2SStuart Yoder  cc="${CC-${cross_prefix}gcc}"
499e49d021eSPeter Maydellfi
500e49d021eSPeter Maydell
50183f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then
50283f73fceSTomoki Sekiyama  cxx="c++"
50383f73fceSTomoki Sekiyamaelse
50483f73fceSTomoki Sekiyama  cxx="${CXX-${cross_prefix}g++}"
50583f73fceSTomoki Sekiyamafi
50683f73fceSTomoki Sekiyama
507b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
508cdbd727cSRichard Hendersonas="${AS-${cross_prefix}as}"
5095f6f0e27SRichard Hendersonccas="${CCAS-$cc}"
5103dd46c78SBlue Swirlcpp="${CPP-$cc -E}"
511b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
512b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
5139f81aeb5SAlistair Francisranlib="${RANLIB-${cross_prefix}ranlib}"
5144852ee95SStefan Weilnm="${NM-${cross_prefix}nm}"
515b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
516b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
51717884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
51817884d7bSSergei Trofimovichquery_pkg_config() {
51917884d7bSSergei Trofimovich    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
52017884d7bSSergei Trofimovich}
52117884d7bSSergei Trofimovichpkg_config=query_pkg_config
52247c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
523ac0df51dSaliguori
52445d285abSPeter Maydell# If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
52545d285abSPeter MaydellARFLAGS="${ARFLAGS-rv}"
52645d285abSPeter Maydell
527be17dc90SMichael S. Tsirkin# default flags for all hosts
5282d31515bSPeter Maydell# We use -fwrapv to tell the compiler that we require a C dialect where
5292d31515bSPeter Maydell# left shift of signed integers is well defined and has the expected
5302d31515bSPeter Maydell# 2s-complement style results. (Both clang and gcc agree that it
5312d31515bSPeter Maydell# provides these semantics.)
532086d5f75SPaolo BonziniQEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
533086d5f75SPaolo BonziniQEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
534c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
535be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
5365770e8afSPaolo Bonzini
5375770e8afSPaolo Bonzini# Flags that are needed during configure but later taken care of by Meson
5388a9d3d56SRichard HendersonCONFIGURE_CFLAGS="-std=gnu11 -Wall"
5395770e8afSPaolo BonziniCONFIGURE_LDFLAGS=
540086d5f75SPaolo Bonzini
541be17dc90SMichael S. Tsirkin
542ac0df51dSaliguoricheck_define() {
543ac0df51dSaliguoricat > $TMPC <<EOF
544ac0df51dSaliguori#if !defined($1)
545fd786e1aSPeter Maydell#error $1 not defined
546ac0df51dSaliguori#endif
547ac0df51dSaliguoriint main(void) { return 0; }
548ac0df51dSaliguoriEOF
54952166aa0SJuan Quintela  compile_object
550ac0df51dSaliguori}
551ac0df51dSaliguori
552307119e7SGerd Hoffmanncheck_include() {
553307119e7SGerd Hoffmanncat > $TMPC <<EOF
554307119e7SGerd Hoffmann#include <$1>
555307119e7SGerd Hoffmannint main(void) { return 0; }
556307119e7SGerd HoffmannEOF
557307119e7SGerd Hoffmann  compile_object
558307119e7SGerd Hoffmann}
559307119e7SGerd Hoffmann
56093b25869SJohn Snowwrite_c_skeleton() {
56193b25869SJohn Snow    cat > $TMPC <<EOF
56293b25869SJohn Snowint main(void) { return 0; }
56393b25869SJohn SnowEOF
56493b25869SJohn Snow}
56593b25869SJohn Snow
566adc28027SAlexander Bulekovwrite_c_fuzzer_skeleton() {
567adc28027SAlexander Bulekov    cat > $TMPC <<EOF
568adc28027SAlexander Bulekov#include <stdint.h>
569adc28027SAlexander Bulekov#include <sys/types.h>
570adc28027SAlexander Bulekovint LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
571adc28027SAlexander Bulekovint LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { return 0; }
572adc28027SAlexander BulekovEOF
573adc28027SAlexander Bulekov}
574adc28027SAlexander Bulekov
575bbea4050SPeter Maydellif check_define __linux__ ; then
576bbea4050SPeter Maydell  targetos="Linux"
577bbea4050SPeter Maydellelif check_define _WIN32 ; then
578bbea4050SPeter Maydell  targetos='MINGW32'
579bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
580bbea4050SPeter Maydell  targetos='OpenBSD'
581bbea4050SPeter Maydellelif check_define __sun__ ; then
582bbea4050SPeter Maydell  targetos='SunOS'
583bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
584bbea4050SPeter Maydell  targetos='Haiku'
585951fedfcSPeter Maydellelif check_define __FreeBSD__ ; then
586951fedfcSPeter Maydell  targetos='FreeBSD'
587951fedfcSPeter Maydellelif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
588951fedfcSPeter Maydell  targetos='GNU/kFreeBSD'
589951fedfcSPeter Maydellelif check_define __DragonFly__ ; then
590951fedfcSPeter Maydell  targetos='DragonFly'
591951fedfcSPeter Maydellelif check_define __NetBSD__; then
592951fedfcSPeter Maydell  targetos='NetBSD'
593951fedfcSPeter Maydellelif check_define __APPLE__; then
594951fedfcSPeter Maydell  targetos='Darwin'
595bbea4050SPeter Maydellelse
596951fedfcSPeter Maydell  # This is a fatal error, but don't report it yet, because we
597951fedfcSPeter Maydell  # might be going to just print the --help text, or it might
598951fedfcSPeter Maydell  # be the result of a missing compiler.
599951fedfcSPeter Maydell  targetos='bogus'
600bbea4050SPeter Maydellfi
601bbea4050SPeter Maydell
602bbea4050SPeter Maydell# Some host OSes need non-standard checks for which CPU to use.
603bbea4050SPeter Maydell# Note that these checks are broken for cross-compilation: if you're
604bbea4050SPeter Maydell# cross-compiling to one of these OSes then you'll need to specify
605bbea4050SPeter Maydell# the correct CPU with the --cpu option.
606bbea4050SPeter Maydellcase $targetos in
607bbea4050SPeter MaydellDarwin)
6085869f8ddSGerd Hoffmann  HOST_DSOSUF=".dylib"
609bbea4050SPeter Maydell  ;;
610bbea4050SPeter MaydellSunOS)
61189138857SStefan Weil  # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
612bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
613bbea4050SPeter Maydell    cpu="x86_64"
614bbea4050SPeter Maydell  fi
615bbea4050SPeter Maydellesac
616bbea4050SPeter Maydell
6172ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
6182ff6b91eSJuan Quintela  # command line argument
6192ff6b91eSJuan Quintela  :
6202ff6b91eSJuan Quintelaelif check_define __i386__ ; then
621ac0df51dSaliguori  cpu="i386"
622ac0df51dSaliguorielif check_define __x86_64__ ; then
623c72b26ecSRichard Henderson  if check_define __ILP32__ ; then
624c72b26ecSRichard Henderson    cpu="x32"
625c72b26ecSRichard Henderson  else
626ac0df51dSaliguori    cpu="x86_64"
627c72b26ecSRichard Henderson  fi
6283aa9bd6cSblueswir1elif check_define __sparc__ ; then
6293aa9bd6cSblueswir1  if check_define __arch64__ ; then
6303aa9bd6cSblueswir1    cpu="sparc64"
6313aa9bd6cSblueswir1  else
6323aa9bd6cSblueswir1    cpu="sparc"
6333aa9bd6cSblueswir1  fi
634fdf7ed96Smalcelif check_define _ARCH_PPC ; then
635fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
636f8378accSRichard Henderson    if check_define _LITTLE_ENDIAN ; then
637f8378accSRichard Henderson      cpu="ppc64le"
638f8378accSRichard Henderson    else
639fdf7ed96Smalc      cpu="ppc64"
640f8378accSRichard Henderson    fi
641ac0df51dSaliguori  else
642fdf7ed96Smalc    cpu="ppc"
643fdf7ed96Smalc  fi
644afa05235SAurelien Jarnoelif check_define __mips__ ; then
645afa05235SAurelien Jarno  cpu="mips"
646d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
647d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
648d66ed0eaSAurelien Jarno    cpu="s390x"
649d66ed0eaSAurelien Jarno  else
650d66ed0eaSAurelien Jarno    cpu="s390"
651d66ed0eaSAurelien Jarno  fi
652c4f80543SAlistair Franciselif check_define __riscv ; then
653c4f80543SAlistair Francis  if check_define _LP64 ; then
654c4f80543SAlistair Francis    cpu="riscv64"
655c4f80543SAlistair Francis  else
656c4f80543SAlistair Francis    cpu="riscv32"
657c4f80543SAlistair Francis  fi
65821d89f84SPeter Maydellelif check_define __arm__ ; then
65921d89f84SPeter Maydell  cpu="arm"
6601f080313SClaudio Fontanaelif check_define __aarch64__ ; then
6611f080313SClaudio Fontana  cpu="aarch64"
662fdf7ed96Smalcelse
66389138857SStefan Weil  cpu=$(uname -m)
664ac0df51dSaliguorifi
665ac0df51dSaliguori
666359bc95dSPeter MaydellARCH=
667359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
668359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
6697d13299dSbellardcase "$cpu" in
670ee35e968SThomas Huth  ppc|ppc64|s390x|sparc64|x32|riscv32|riscv64)
671898be3e0SPeter Maydell  ;;
672f8378accSRichard Henderson  ppc64le)
673f8378accSRichard Henderson    ARCH="ppc64"
674f8378accSRichard Henderson  ;;
6757d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
67697a847bcSbellard    cpu="i386"
6777d13299dSbellard  ;;
678aaa5fa14Saurel32  x86_64|amd64)
679aaa5fa14Saurel32    cpu="x86_64"
680aaa5fa14Saurel32  ;;
68121d89f84SPeter Maydell  armv*b|armv*l|arm)
68221d89f84SPeter Maydell    cpu="arm"
6837d13299dSbellard  ;;
6841f080313SClaudio Fontana  aarch64)
6851f080313SClaudio Fontana    cpu="aarch64"
6861f080313SClaudio Fontana  ;;
687afa05235SAurelien Jarno  mips*)
688afa05235SAurelien Jarno    cpu="mips"
689afa05235SAurelien Jarno  ;;
6903142255cSblueswir1  sparc|sun4[cdmuv])
691ae228531Sbellard    cpu="sparc"
692ae228531Sbellard  ;;
6937d13299dSbellard  *)
694359bc95dSPeter Maydell    # This will result in either an error or falling back to TCI later
695359bc95dSPeter Maydell    ARCH=unknown
6967d13299dSbellard  ;;
6977d13299dSbellardesac
698359bc95dSPeter Maydellif test -z "$ARCH"; then
699359bc95dSPeter Maydell  ARCH="$cpu"
700359bc95dSPeter Maydellfi
701e2d52ad3SJuan Quintela
7027d13299dSbellard# OS specific
7030dbfc675SJuan Quintela
7047d13299dSbellardcase $targetos in
70567b915a5SbellardMINGW32*)
70667b915a5Sbellard  mingw32="yes"
7073cec7cc2SKővágó, Zoltán  audio_possible_drivers="dsound sdl"
708307119e7SGerd Hoffmann  if check_include dsound.h; then
7093cec7cc2SKővágó, Zoltán    audio_drv_list="dsound"
710307119e7SGerd Hoffmann  else
711307119e7SGerd Hoffmann    audio_drv_list=""
712307119e7SGerd Hoffmann  fi
713898be3e0SPeter Maydell  supported_os="yes"
714fb648e9cSDaniel P. Berrangé  pie="no"
71567b915a5Sbellard;;
7165c40d2bdSthsGNU/kFreeBSD)
717a167ba50SAurelien Jarno  bsd="yes"
7186a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
7190bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
7205c40d2bdSths;;
7217d3505c5SbellardFreeBSD)
7227d3505c5Sbellard  bsd="yes"
7230db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7246a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
7250bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
726f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
72758952137SVincenzo Maffione  netmap=""  # enable netmap autodetect
7287d3505c5Sbellard;;
729c5e97233Sblueswir1DragonFly)
730c5e97233Sblueswir1  bsd="yes"
7310db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7326a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
7330bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
734c5e97233Sblueswir1;;
7357d3505c5SbellardNetBSD)
7367d3505c5Sbellard  bsd="yes"
7370db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7386a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
7390bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl"
7408ef92a88Sblueswir1  oss_lib="-lossaudio"
7417d3505c5Sbellard;;
7427d3505c5SbellardOpenBSD)
7437d3505c5Sbellard  bsd="yes"
7440db4a067SPaolo Bonzini  make="${MAKE-gmake}"
745f92c7168SGerd Hoffmann  audio_drv_list="try-sdl"
7460bac1111SKővágó, Zoltán  audio_possible_drivers="sdl"
7477d3505c5Sbellard;;
74883fb7adfSbellardDarwin)
74983fb7adfSbellard  bsd="yes"
75083fb7adfSbellard  darwin="yes"
751422a5fd0SJoelle van Dyne  audio_drv_list="try-coreaudio try-sdl"
75214382605SKővágó, Zoltán  audio_possible_drivers="coreaudio sdl"
753a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
754a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
755a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
75683fb7adfSbellard;;
757ec530c81SbellardSunOS)
758ec530c81Sbellard  solaris="yes"
7590db4a067SPaolo Bonzini  make="${MAKE-gmake}"
760e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
7616b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
7626a485418SGerd Hoffmann    audio_drv_list="oss try-sdl"
7636b4d2ba1Sths  fi
764c2de5c91Smalc  audio_possible_drivers="oss sdl"
765d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
766d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
767d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
768d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
769ec530c81Sbellard;;
770179cf400SAndreas FärberHaiku)
771179cf400SAndreas Färber  haiku="yes"
772cde99253SThomas Huth  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE $QEMU_CFLAGS"
773179cf400SAndreas Färber;;
774898be3e0SPeter MaydellLinux)
7757183834aSGerd Hoffmann  audio_drv_list="try-pa oss"
7760bac1111SKővágó, Zoltán  audio_possible_drivers="oss alsa sdl pa"
7775327cf48Sbellard  linux="yes"
778831b7825Sths  linux_user="yes"
779c87ea116SAlex Bennée  vhost_user=${default_feature:-yes}
780898be3e0SPeter Maydell;;
7817d13299dSbellardesac
7827d13299dSbellard
7837d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
784b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
78584778508Sblueswir1    bsd_user="yes"
7867d3505c5Sbellard  fi
78708de3949SAndreas Färberfi
7887d3505c5Sbellard
7890db4a067SPaolo Bonzini: ${make=${MAKE-make}}
790b6daf4d3SPaolo Bonzini
791faf44142SDaniel P. Berrangé# We prefer python 3.x. A bare 'python' is traditionally
792faf44142SDaniel P. Berrangé# python 2.x, but some distros have it as python 3.x, so
793ddf90699SEduardo Habkost# we check that too
794faf44142SDaniel P. Berrangépython=
7950a01d76fSMarc-André Lureauexplicit_python=no
796ddf90699SEduardo Habkostfor binary in "${PYTHON-python3}" python
797faf44142SDaniel P. Berrangédo
798faf44142SDaniel P. Berrangé    if has "$binary"
799faf44142SDaniel P. Berrangé    then
80095c5f2deSPaolo Bonzini        python=$(command -v "$binary")
801faf44142SDaniel P. Berrangé        break
802faf44142SDaniel P. Berrangé    fi
803faf44142SDaniel P. Berrangédone
804903458c8SMarkus Armbruster
805903458c8SMarkus Armbruster
80639d87c8cSAlex Bennée# Check for ancillary tools used in testing
80739d87c8cSAlex Bennéegenisoimage=
8083df437c7SAlex Bennéefor binary in genisoimage mkisofs
80939d87c8cSAlex Bennéedo
81039d87c8cSAlex Bennée    if has $binary
81139d87c8cSAlex Bennée    then
81239d87c8cSAlex Bennée        genisoimage=$(command -v "$binary")
81339d87c8cSAlex Bennée        break
81439d87c8cSAlex Bennée    fi
81539d87c8cSAlex Bennéedone
81639d87c8cSAlex Bennée
8173c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
8183c4a4d0dSPeter Maydellif has clang; then
8193c4a4d0dSPeter Maydell  objcc=clang
8203c4a4d0dSPeter Maydellelse
8213c4a4d0dSPeter Maydell  objcc="$cc"
8223c4a4d0dSPeter Maydellfi
8233c4a4d0dSPeter Maydell
8243457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
8253457a3f8SJuan Quintela  EXESUF=".exe"
826484e2cc7SPaolo Bonzini  HOST_DSOSUF=".dll"
82778e9d4adSStefan Weil  # MinGW needs -mthreads for TLS and macro _MT.
8285770e8afSPaolo Bonzini  CONFIGURE_CFLAGS="-mthreads $CONFIGURE_CFLAGS"
82993b25869SJohn Snow  write_c_skeleton;
830d17f305aSPaolo Bonzini  prefix="/qemu"
83177433a5fSMarc-André Lureau  qemu_suffix=""
832105fad6bSBishara AbuHattoum  libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
8333457a3f8SJuan Quintelafi
8343457a3f8SJuan Quintela
835487fefdbSAnthony Liguoriwerror=""
83685aa5189Sbellard
8377d13299dSbellardfor opt do
83889138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
8397d13299dSbellard  case "$opt" in
8402efc3265Sbellard  --help|-h) show_help=yes
8412efc3265Sbellard  ;;
84299123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
84399123e13SMike Frysinger  ;;
844b1a550a0Spbrook  --prefix=*) prefix="$optarg"
8457d13299dSbellard  ;;
846b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
84732ce6337Sbellard  ;;
848ac0df51dSaliguori  --cross-prefix=*)
8497d13299dSbellard  ;;
850ac0df51dSaliguori  --cc=*)
8517d13299dSbellard  ;;
852b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
85383469015Sbellard  ;;
85483f73fceSTomoki Sekiyama  --cxx=*)
85583f73fceSTomoki Sekiyama  ;;
856e007dbecSMichael S. Tsirkin  --iasl=*) iasl="$optarg"
857e007dbecSMichael S. Tsirkin  ;;
8583c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
8593c4a4d0dSPeter Maydell  ;;
860b1a550a0Spbrook  --make=*) make="$optarg"
8617d13299dSbellard  ;;
862b6daf4d3SPaolo Bonzini  --install=*)
8636a882643Spbrook  ;;
8640a01d76fSMarc-André Lureau  --python=*) python="$optarg" ; explicit_python=yes
865c886edfbSBlue Swirl  ;;
8662eb054c2SPeter Maydell  --sphinx-build=*) sphinx_build="$optarg"
8672eb054c2SPeter Maydell  ;;
868a5665051SPaolo Bonzini  --skip-meson) skip_meson=yes
869a5665051SPaolo Bonzini  ;;
870a5665051SPaolo Bonzini  --meson=*) meson="$optarg"
871a5665051SPaolo Bonzini  ;;
87248328880SPaolo Bonzini  --ninja=*) ninja="$optarg"
87348328880SPaolo Bonzini  ;;
874e2d8830eSBrad  --smbd=*) smbd="$optarg"
875e2d8830eSBrad  ;;
876e2a2ed06SJuan Quintela  --extra-cflags=*)
8777d13299dSbellard  ;;
87811cde1c8SBruno Dominguez  --extra-cxxflags=*)
87911cde1c8SBruno Dominguez  ;;
880e2a2ed06SJuan Quintela  --extra-ldflags=*)
8817d13299dSbellard  ;;
8825bc62e01SGerd Hoffmann  --enable-debug-info)
8835bc62e01SGerd Hoffmann  ;;
8845bc62e01SGerd Hoffmann  --disable-debug-info)
8855bc62e01SGerd Hoffmann  ;;
886d75402b5SAlex Bennée  --cross-cc-*)
887d75402b5SAlex Bennée  ;;
88817969268SFam Zheng  --enable-modules)
88917969268SFam Zheng      modules="yes"
89017969268SFam Zheng  ;;
8913aa88b31SStefan Hajnoczi  --disable-modules)
8923aa88b31SStefan Hajnoczi      modules="no"
8933aa88b31SStefan Hajnoczi  ;;
894bd83c861SChristian Ehrhardt  --disable-module-upgrades) module_upgrades="no"
895bd83c861SChristian Ehrhardt  ;;
896bd83c861SChristian Ehrhardt  --enable-module-upgrades) module_upgrades="yes"
897bd83c861SChristian Ehrhardt  ;;
8982ff6b91eSJuan Quintela  --cpu=*)
8997d13299dSbellard  ;;
900b1a550a0Spbrook  --target-list=*) target_list="$optarg"
901447e133fSAlex Bennée                   if test "$target_list_exclude"; then
902447e133fSAlex Bennée                       error_exit "Can't mix --target-list with --target-list-exclude"
903447e133fSAlex Bennée                   fi
904447e133fSAlex Bennée  ;;
905447e133fSAlex Bennée  --target-list-exclude=*) target_list_exclude="$optarg"
906447e133fSAlex Bennée                   if test "$target_list"; then
907447e133fSAlex Bennée                       error_exit "Can't mix --target-list-exclude with --target-list"
908447e133fSAlex Bennée                   fi
909de83cd02Sbellard  ;;
9105b808275SLluís Vilanova  --enable-trace-backends=*) trace_backends="$optarg"
9115b808275SLluís Vilanova  ;;
9125b808275SLluís Vilanova  # XXX: backwards compatibility
9135b808275SLluís Vilanova  --enable-trace-backend=*) trace_backends="$optarg"
91494a420b1SStefan Hajnoczi  ;;
91574242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
9169410b56cSPrerna Saxena  ;;
9177bc3ca7fSPaolo Bonzini  --with-default-devices) default_devices="true"
918f3494749SPaolo Bonzini  ;;
9197bc3ca7fSPaolo Bonzini  --without-default-devices) default_devices="false"
920f3494749SPaolo Bonzini  ;;
921c87ea116SAlex Bennée  --without-default-features) # processed above
922c87ea116SAlex Bennée  ;;
9237d13299dSbellard  --enable-gprof) gprof="yes"
9247d13299dSbellard  ;;
9251d728c39SBlue Swirl  --enable-gcov) gcov="yes"
9261d728c39SBlue Swirl  ;;
92779427693SLoïc Minier  --static)
92879427693SLoïc Minier    static="yes"
92917884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
93043ce4dfeSbellard  ;;
9310b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
9320b24e75fSPaolo Bonzini  ;;
9330b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
9340b24e75fSPaolo Bonzini  ;;
9353aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
9363aa5d2beSAlon Levy  ;;
9378bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
9388bf188aaSMichael Tokarev  ;;
9390f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
9400f94d6daSAlon Levy  ;;
941528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
9420b24e75fSPaolo Bonzini  ;;
94377433a5fSMarc-André Lureau  --with-suffix=*) qemu_suffix="$optarg"
944023d3d67SEduardo Habkost  ;;
945c6502638SBruce Rogers  --docdir=*) docdir="$optarg"
9460b24e75fSPaolo Bonzini  ;;
947fe0038beSPaolo Bonzini  --localedir=*) localedir="$optarg"
948fe0038beSPaolo Bonzini  ;;
949ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
95007381cc1SAnthony Liguori  ;;
951785c23aeSLuiz Capitulino  --localstatedir=*) local_statedir="$optarg"
952785c23aeSLuiz Capitulino  ;;
9533d5eecabSGerd Hoffmann  --firmwarepath=*) firmwarepath="$optarg"
9543d5eecabSGerd Hoffmann  ;;
955181ce1d0SOlaf Hering  --host=*|--build=*|\
956181ce1d0SOlaf Hering  --disable-dependency-tracking|\
957785c23aeSLuiz Capitulino  --sbindir=*|--sharedstatedir=*|\
958fe0038beSPaolo Bonzini  --oldincludedir=*|--datarootdir=*|--infodir=*|\
959023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
960023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
961023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
962023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
963023ddd74SMax Filippov    # lots of directory switches by default.
964023ddd74SMax Filippov  ;;
96535be72baSPaolo Bonzini  --disable-sdl) sdl="disabled"
96697a847bcSbellard  ;;
96735be72baSPaolo Bonzini  --enable-sdl) sdl="enabled"
968c4198157SJuan Quintela  ;;
96935be72baSPaolo Bonzini  --disable-sdl-image) sdl_image="disabled"
970a442fe2fSDaniel P. Berrangé  ;;
97135be72baSPaolo Bonzini  --enable-sdl-image) sdl_image="enabled"
972a442fe2fSDaniel P. Berrangé  ;;
9733556c233SPaolo Bonzini  --disable-qom-cast-debug) qom_cast_debug="no"
9743556c233SPaolo Bonzini  ;;
9753556c233SPaolo Bonzini  --enable-qom-cast-debug) qom_cast_debug="yes"
9763556c233SPaolo Bonzini  ;;
97769202b40SPaolo Bonzini  --disable-virtfs) virtfs="disabled"
978983eef5aSMeador Inge  ;;
97969202b40SPaolo Bonzini  --enable-virtfs) virtfs="enabled"
980983eef5aSMeador Inge  ;;
9815c53015aSPaolo Bonzini  --disable-libudev) libudev="disabled"
9825c53015aSPaolo Bonzini  ;;
9835c53015aSPaolo Bonzini  --enable-libudev) libudev="enabled"
9845c53015aSPaolo Bonzini  ;;
985cece116cSMisono Tomohiro  --disable-virtiofsd) virtiofsd="disabled"
986cece116cSMisono Tomohiro  ;;
987cece116cSMisono Tomohiro  --enable-virtiofsd) virtiofsd="enabled"
988cece116cSMisono Tomohiro  ;;
9896ec0e15dSPaolo Bonzini  --disable-mpath) mpath="disabled"
990fe8fc5aeSPaolo Bonzini  ;;
9916ec0e15dSPaolo Bonzini  --enable-mpath) mpath="enabled"
992fe8fc5aeSPaolo Bonzini  ;;
993a0b93237SPaolo Bonzini  --disable-vnc) vnc="disabled"
994821601eaSJes Sorensen  ;;
995a0b93237SPaolo Bonzini  --enable-vnc) vnc="enabled"
996821601eaSJes Sorensen  ;;
9970e8e77d4SAlex Bennée  --disable-gettext) gettext="disabled"
998e8f3bd71SMarc-André Lureau  ;;
9990e8e77d4SAlex Bennée  --enable-gettext) gettext="enabled"
1000e8f3bd71SMarc-André Lureau  ;;
10012f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
10022f6a1ab0Sblueswir1  ;;
10030c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
10040c58ac1cSmalc  ;;
100589138857SStefan Weil  --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1006b64ec4e4SFam Zheng  ;;
100789138857SStefan Weil  --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1008eb852011SMarkus Armbruster  ;;
1009f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
1010f8393946Saurel32  ;;
1011f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
1012f8393946Saurel32  ;;
1013f3d08ee6SPaul Brook  --enable-debug)
1014f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
1015f3d08ee6SPaul Brook      debug_tcg="yes"
10161fcc6d42SPeter Xu      debug_mutex="yes"
1017f3d08ee6SPaul Brook      debug="yes"
1018f3d08ee6SPaul Brook      strip_opt="no"
1019b553a042SJohn Snow      fortify_source="no"
1020f3d08ee6SPaul Brook  ;;
1021247724cbSMarc-André Lureau  --enable-sanitizers) sanitizers="yes"
1022247724cbSMarc-André Lureau  ;;
1023247724cbSMarc-André Lureau  --disable-sanitizers) sanitizers="no"
1024247724cbSMarc-André Lureau  ;;
10250aebab04SLingfeng Yang  --enable-tsan) tsan="yes"
10260aebab04SLingfeng Yang  ;;
10270aebab04SLingfeng Yang  --disable-tsan) tsan="no"
10280aebab04SLingfeng Yang  ;;
1029deb62371SPaolo Bonzini  --enable-sparse) sparse="enabled"
103003b4fe7dSaliguori  ;;
1031deb62371SPaolo Bonzini  --disable-sparse) sparse="disabled"
103203b4fe7dSaliguori  ;;
10331625af87Saliguori  --disable-strip) strip_opt="no"
10341625af87Saliguori  ;;
1035a0b93237SPaolo Bonzini  --disable-vnc-sasl) vnc_sasl="disabled"
10362f9606b3Saliguori  ;;
1037a0b93237SPaolo Bonzini  --enable-vnc-sasl) vnc_sasl="enabled"
1038ea784e3bSJuan Quintela  ;;
1039a0b93237SPaolo Bonzini  --disable-vnc-jpeg) vnc_jpeg="disabled"
10402f6f5c7aSCorentin Chary  ;;
1041a0b93237SPaolo Bonzini  --enable-vnc-jpeg) vnc_jpeg="enabled"
10422f6f5c7aSCorentin Chary  ;;
1043a0b93237SPaolo Bonzini  --disable-vnc-png) vnc_png="disabled"
1044efe556adSCorentin Chary  ;;
1045a0b93237SPaolo Bonzini  --enable-vnc-png) vnc_png="enabled"
1046efe556adSCorentin Chary  ;;
10474d34a86bSPaolo Bonzini  --disable-slirp) slirp="disabled"
1048c20709aaSbellard  ;;
1049fd6fc214SPaolo Bonzini  --enable-slirp) slirp="enabled"
1050fd6fc214SPaolo Bonzini  ;;
10514d34a86bSPaolo Bonzini  --enable-slirp=git) slirp="internal"
10527c57bdd8SMarc-André Lureau  ;;
1053675b9b53SMarc-André Lureau  --enable-slirp=system) slirp="system"
1054675b9b53SMarc-André Lureau  ;;
1055e0e6c8c0Saliguori  --disable-vde) vde="no"
10568a16d273Sths  ;;
1057dfb278bdSJuan Quintela  --enable-vde) vde="yes"
1058dfb278bdSJuan Quintela  ;;
105958952137SVincenzo Maffione  --disable-netmap) netmap="no"
106058952137SVincenzo Maffione  ;;
106158952137SVincenzo Maffione  --enable-netmap) netmap="yes"
106258952137SVincenzo Maffione  ;;
10631badb709SPaolo Bonzini  --disable-xen) xen="disabled"
1064e37630caSaliguori  ;;
10651badb709SPaolo Bonzini  --enable-xen) xen="enabled"
1066fc321b4bSJuan Quintela  ;;
10671badb709SPaolo Bonzini  --disable-xen-pci-passthrough) xen_pci_passthrough="disabled"
1068eb6fda0fSAnthony PERARD  ;;
10691badb709SPaolo Bonzini  --enable-xen-pci-passthrough) xen_pci_passthrough="enabled"
1070eb6fda0fSAnthony PERARD  ;;
10718c6d4ff4SPaolo Bonzini  --disable-brlapi) brlapi="disabled"
10722e4d9fb1Saurel32  ;;
10738c6d4ff4SPaolo Bonzini  --enable-brlapi) brlapi="enabled"
10744ffcedb6SJuan Quintela  ;;
10751badb709SPaolo Bonzini  --disable-kvm) kvm="disabled"
10767ba1e619Saliguori  ;;
10771badb709SPaolo Bonzini  --enable-kvm) kvm="enabled"
1078b31a0277SJuan Quintela  ;;
10791badb709SPaolo Bonzini  --disable-hax) hax="disabled"
1080180fb750Szhanghailiang  ;;
10811badb709SPaolo Bonzini  --enable-hax) hax="enabled"
1082180fb750Szhanghailiang  ;;
10831badb709SPaolo Bonzini  --disable-hvf) hvf="disabled"
1084c97d6d2cSSergio Andres Gomez Del Real  ;;
10851badb709SPaolo Bonzini  --enable-hvf) hvf="enabled"
1086c97d6d2cSSergio Andres Gomez Del Real  ;;
108774a414a1SReinoud Zandijk  --disable-nvmm) nvmm="disabled"
108874a414a1SReinoud Zandijk  ;;
108974a414a1SReinoud Zandijk  --enable-nvmm) nvmm="enabled"
109074a414a1SReinoud Zandijk  ;;
10911badb709SPaolo Bonzini  --disable-whpx) whpx="disabled"
1092d661d9a4SJustin Terry (VM)  ;;
10931badb709SPaolo Bonzini  --enable-whpx) whpx="enabled"
1094d661d9a4SJustin Terry (VM)  ;;
1095c6fbea47SRichard Henderson  --disable-tcg-interpreter) tcg_interpreter="false"
10969195b2c2SStefan Weil  ;;
1097c6fbea47SRichard Henderson  --enable-tcg-interpreter) tcg_interpreter="true"
10989195b2c2SStefan Weil  ;;
1099727c8bb8SPaolo Bonzini  --disable-cap-ng)  cap_ng="disabled"
110047e98658SCorey Bryant  ;;
1101727c8bb8SPaolo Bonzini  --enable-cap-ng) cap_ng="enabled"
110247e98658SCorey Bryant  ;;
11031badb709SPaolo Bonzini  --disable-tcg) tcg="disabled"
1104b3f6ea7eSPaolo Bonzini  ;;
11051badb709SPaolo Bonzini  --enable-tcg) tcg="enabled"
1106b3f6ea7eSPaolo Bonzini  ;;
1107aa087962SPaolo Bonzini  --disable-malloc-trim) malloc_trim="disabled"
11085a22ab71SYang Zhong  ;;
1109aa087962SPaolo Bonzini  --enable-malloc-trim) malloc_trim="enabled"
11105a22ab71SYang Zhong  ;;
1111cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
1112cd4ec0b4SGerd Hoffmann  ;;
111358d3f3ffSGerd Hoffmann  --enable-spice)
111458d3f3ffSGerd Hoffmann      spice_protocol="yes"
111558d3f3ffSGerd Hoffmann      spice="yes"
111658d3f3ffSGerd Hoffmann  ;;
111758d3f3ffSGerd Hoffmann  --disable-spice-protocol)
111858d3f3ffSGerd Hoffmann      spice_protocol="no"
111958d3f3ffSGerd Hoffmann      spice="no"
112058d3f3ffSGerd Hoffmann  ;;
112158d3f3ffSGerd Hoffmann  --enable-spice-protocol) spice_protocol="yes"
1122cd4ec0b4SGerd Hoffmann  ;;
11239db405a3SPaolo Bonzini  --disable-libiscsi) libiscsi="disabled"
1124c589b249SRonnie Sahlberg  ;;
11259db405a3SPaolo Bonzini  --enable-libiscsi) libiscsi="enabled"
1126c589b249SRonnie Sahlberg  ;;
112730045c05SPaolo Bonzini  --disable-libnfs) libnfs="disabled"
11286542aa9cSPeter Lieven  ;;
112930045c05SPaolo Bonzini  --enable-libnfs) libnfs="enabled"
11306542aa9cSPeter Lieven  ;;
113105c2a3e7Sbellard  --enable-profiler) profiler="yes"
113205c2a3e7Sbellard  ;;
1133b4e312e9SPaolo Bonzini  --disable-cocoa) cocoa="disabled"
113414821030SPavel Borzenkov  ;;
1135a23a6789SPaolo Bonzini  --enable-cocoa) cocoa="enabled"
11365b0753e0Sbellard  ;;
1137cad25d69Spbrook  --disable-system) softmmu="no"
11380a8e90f4Spbrook  ;;
1139cad25d69Spbrook  --enable-system) softmmu="yes"
11400a8e90f4Spbrook  ;;
11410953a80fSZachary Amsden  --disable-user)
11420953a80fSZachary Amsden      linux_user="no" ;
11430953a80fSZachary Amsden      bsd_user="no" ;
11440953a80fSZachary Amsden  ;;
11450953a80fSZachary Amsden  --enable-user) ;;
1146831b7825Sths  --disable-linux-user) linux_user="no"
11470a8e90f4Spbrook  ;;
1148831b7825Sths  --enable-linux-user) linux_user="yes"
1149831b7825Sths  ;;
115084778508Sblueswir1  --disable-bsd-user) bsd_user="no"
115184778508Sblueswir1  ;;
115284778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
115384778508Sblueswir1  ;;
115440d6444eSAvi Kivity  --enable-pie) pie="yes"
115534005a00SKirill A. Shutemov  ;;
115640d6444eSAvi Kivity  --disable-pie) pie="no"
115734005a00SKirill A. Shutemov  ;;
115885aa5189Sbellard  --enable-werror) werror="yes"
115985aa5189Sbellard  ;;
116085aa5189Sbellard  --disable-werror) werror="no"
116185aa5189Sbellard  ;;
1162cdad781dSDaniele Buono  --enable-lto) lto="true"
1163cdad781dSDaniele Buono  ;;
1164cdad781dSDaniele Buono  --disable-lto) lto="false"
1165cdad781dSDaniele Buono  ;;
116663678e17SSteven Noonan  --enable-stack-protector) stack_protector="yes"
116763678e17SSteven Noonan  ;;
116863678e17SSteven Noonan  --disable-stack-protector) stack_protector="no"
116963678e17SSteven Noonan  ;;
11701e4f6065SDaniele Buono  --enable-safe-stack) safe_stack="yes"
11711e4f6065SDaniele Buono  ;;
11721e4f6065SDaniele Buono  --disable-safe-stack) safe_stack="no"
11731e4f6065SDaniele Buono  ;;
11749e62ba48SDaniele Buono  --enable-cfi)
11759e62ba48SDaniele Buono      cfi="true";
11769e62ba48SDaniele Buono      lto="true";
11779e62ba48SDaniele Buono  ;;
11789e62ba48SDaniele Buono  --disable-cfi) cfi="false"
11799e62ba48SDaniele Buono  ;;
11809e62ba48SDaniele Buono  --enable-cfi-debug) cfi_debug="true"
11819e62ba48SDaniele Buono  ;;
11829e62ba48SDaniele Buono  --disable-cfi-debug) cfi_debug="false"
11839e62ba48SDaniele Buono  ;;
11845285e593SYonggang Luo  --disable-curses) curses="disabled"
11854d3b6f6eSbalrog  ;;
11865285e593SYonggang Luo  --enable-curses) curses="enabled"
1187c584a6d0SJuan Quintela  ;;
11885285e593SYonggang Luo  --disable-iconv) iconv="disabled"
1189e08bb301SSamuel Thibault  ;;
11905285e593SYonggang Luo  --enable-iconv) iconv="enabled"
1191e08bb301SSamuel Thibault  ;;
1192f9cd86feSPaolo Bonzini  --disable-curl) curl="disabled"
1193769ce76dSAlexander Graf  ;;
1194f9cd86feSPaolo Bonzini  --enable-curl) curl="enabled"
1195788c8196SJuan Quintela  ;;
1196fbb4121dSPaolo Bonzini  --disable-fdt) fdt="disabled"
11972df87df7SJuan Quintela  ;;
1198fbb4121dSPaolo Bonzini  --enable-fdt) fdt="enabled"
1199fbb4121dSPaolo Bonzini  ;;
1200fbb4121dSPaolo Bonzini  --enable-fdt=git) fdt="internal"
1201fbb4121dSPaolo Bonzini  ;;
1202fbb4121dSPaolo Bonzini  --enable-fdt=system) fdt="system"
12032df87df7SJuan Quintela  ;;
12045c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
12055c6c3a6cSChristoph Hellwig  ;;
12065c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
12075c6c3a6cSChristoph Hellwig  ;;
1208c10dd856SAarushi Mehta  --disable-linux-io-uring) linux_io_uring="no"
1209c10dd856SAarushi Mehta  ;;
1210c10dd856SAarushi Mehta  --enable-linux-io-uring) linux_io_uring="yes"
1211c10dd856SAarushi Mehta  ;;
1212f7f2d651SPaolo Bonzini  --disable-attr) attr="disabled"
1213758e8e38SVenkateswararao Jujjuri (JV)  ;;
1214f7f2d651SPaolo Bonzini  --enable-attr) attr="enabled"
1215758e8e38SVenkateswararao Jujjuri (JV)  ;;
1216a40161cbSPaolo Bonzini  --disable-membarrier) membarrier="no"
1217a40161cbSPaolo Bonzini  ;;
1218a40161cbSPaolo Bonzini  --enable-membarrier) membarrier="yes"
1219a40161cbSPaolo Bonzini  ;;
122046627f41SAndrew Melnychenko  --disable-bpf) bpf="disabled"
122146627f41SAndrew Melnychenko  ;;
122246627f41SAndrew Melnychenko  --enable-bpf) bpf="enabled"
122346627f41SAndrew Melnychenko  ;;
1224c8d5450bSPaolo Bonzini  --disable-blobs) blobs="false"
122577755340Sths  ;;
12267e563bfbSThomas Huth  --with-pkgversion=*) pkgversion="$optarg"
12274a19f1ecSpbrook  ;;
1228519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
1229519175a2SAlex Barcelo  ;;
123070c60c08SStefan Hajnoczi  --disable-coroutine-pool) coroutine_pool="no"
123170c60c08SStefan Hajnoczi  ;;
123270c60c08SStefan Hajnoczi  --enable-coroutine-pool) coroutine_pool="yes"
123370c60c08SStefan Hajnoczi  ;;
12347d992e4dSPeter Lieven  --enable-debug-stack-usage) debug_stack_usage="yes"
12357d992e4dSPeter Lieven  ;;
1236f0d92b56SLongpeng(Mike)  --enable-crypto-afalg) crypto_afalg="yes"
1237f0d92b56SLongpeng(Mike)  ;;
1238f0d92b56SLongpeng(Mike)  --disable-crypto-afalg) crypto_afalg="no"
1239f0d92b56SLongpeng(Mike)  ;;
1240e3667660SYonggang Luo  --disable-docs) docs="disabled"
124170ec5dc0SAnthony Liguori  ;;
1242e3667660SYonggang Luo  --enable-docs) docs="enabled"
124383a3ab8bSJuan Quintela  ;;
1244d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
1245d5970055SMichael S. Tsirkin  ;;
1246d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
1247d5970055SMichael S. Tsirkin  ;;
1248042cea27SGonglei  --disable-vhost-crypto) vhost_crypto="no"
1249042cea27SGonglei  ;;
1250299e6f19SPaolo Bonzini  --enable-vhost-crypto) vhost_crypto="yes"
1251042cea27SGonglei  ;;
12525e9be92dSNicholas Bellinger  --disable-vhost-scsi) vhost_scsi="no"
12535e9be92dSNicholas Bellinger  ;;
12545e9be92dSNicholas Bellinger  --enable-vhost-scsi) vhost_scsi="yes"
12555e9be92dSNicholas Bellinger  ;;
1256fc0b9b0eSStefan Hajnoczi  --disable-vhost-vsock) vhost_vsock="no"
1257fc0b9b0eSStefan Hajnoczi  ;;
1258fc0b9b0eSStefan Hajnoczi  --enable-vhost-vsock) vhost_vsock="yes"
1259fc0b9b0eSStefan Hajnoczi  ;;
1260e5e856c1SStefan Hajnoczi  --disable-vhost-user-blk-server) vhost_user_blk_server="disabled"
1261bc15e44cSStefan Hajnoczi  ;;
1262e5e856c1SStefan Hajnoczi  --enable-vhost-user-blk-server) vhost_user_blk_server="enabled"
1263bc15e44cSStefan Hajnoczi  ;;
126498fc1adaSDr. David Alan Gilbert  --disable-vhost-user-fs) vhost_user_fs="no"
126598fc1adaSDr. David Alan Gilbert  ;;
126698fc1adaSDr. David Alan Gilbert  --enable-vhost-user-fs) vhost_user_fs="yes"
126798fc1adaSDr. David Alan Gilbert  ;;
1268da076ffeSGerd Hoffmann  --disable-opengl) opengl="no"
126920ff075bSMichael Walle  ;;
1270da076ffeSGerd Hoffmann  --enable-opengl) opengl="yes"
127120ff075bSMichael Walle  ;;
1272fabd1e93SPaolo Bonzini  --disable-rbd) rbd="disabled"
1273f27aaf4bSChristian Brunner  ;;
1274fabd1e93SPaolo Bonzini  --enable-rbd) rbd="enabled"
1275f27aaf4bSChristian Brunner  ;;
12768c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
12778c84cf11SSergei Trofimovich  ;;
12788c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
12798c84cf11SSergei Trofimovich  ;;
12805f364c57SPaolo Bonzini  --disable-smartcard) smartcard="disabled"
1281111a38b0SRobert Relyea  ;;
12825f364c57SPaolo Bonzini  --enable-smartcard) smartcard="enabled"
1283111a38b0SRobert Relyea  ;;
12840a40bcb7SCésar Belley  --disable-u2f) u2f="disabled"
12850a40bcb7SCésar Belley  ;;
12860a40bcb7SCésar Belley  --enable-u2f) u2f="enabled"
12870a40bcb7SCésar Belley  ;;
128890540f32SPaolo Bonzini  --disable-libusb) libusb="disabled"
12892b2325ffSGerd Hoffmann  ;;
129090540f32SPaolo Bonzini  --enable-libusb) libusb="enabled"
12912b2325ffSGerd Hoffmann  ;;
129218f31e60SPaolo Bonzini  --disable-usb-redir) usb_redir="disabled"
129369354a83SHans de Goede  ;;
129418f31e60SPaolo Bonzini  --enable-usb-redir) usb_redir="enabled"
129569354a83SHans de Goede  ;;
12961ffb3bbbSPaolo Bonzini  --disable-zlib-test)
12971ece9905SAlon Levy  ;;
12980c32a0aeSPaolo Bonzini  --disable-lzo) lzo="disabled"
1299b25c9dffSStefan Weil  ;;
13000c32a0aeSPaolo Bonzini  --enable-lzo) lzo="enabled"
1301607dacd0Sqiaonuohan  ;;
1302241611eaSPaolo Bonzini  --disable-snappy) snappy="disabled"
1303b25c9dffSStefan Weil  ;;
1304241611eaSPaolo Bonzini  --enable-snappy) snappy="enabled"
1305607dacd0Sqiaonuohan  ;;
130629ba6116SPaolo Bonzini  --disable-bzip2) bzip2="disabled"
13076b383c08SPeter Wu  ;;
130829ba6116SPaolo Bonzini  --enable-bzip2) bzip2="enabled"
13096b383c08SPeter Wu  ;;
1310ecea3696SPaolo Bonzini  --enable-lzfse) lzfse="enabled"
131183bc1f97SJulio Faracco  ;;
1312ecea3696SPaolo Bonzini  --disable-lzfse) lzfse="disabled"
131383bc1f97SJulio Faracco  ;;
1314b1def33dSPaolo Bonzini  --disable-zstd) zstd="disabled"
13153a678481SJuan Quintela  ;;
1316b1def33dSPaolo Bonzini  --enable-zstd) zstd="enabled"
13173a678481SJuan Quintela  ;;
1318d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
1319d138cee9SMichael Roth  ;;
1320d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
1321d138cee9SMichael Roth  ;;
1322b846ab7cSPaolo Bonzini  --enable-guest-agent-msi) guest_agent_msi="enabled"
13239dacf32dSYossi Hindin  ;;
1324b846ab7cSPaolo Bonzini  --disable-guest-agent-msi) guest_agent_msi="disabled"
13259dacf32dSYossi Hindin  ;;
1326d9840e25STomoki Sekiyama  --with-vss-sdk) vss_win32_sdk=""
1327d9840e25STomoki Sekiyama  ;;
1328d9840e25STomoki Sekiyama  --with-vss-sdk=*) vss_win32_sdk="$optarg"
1329d9840e25STomoki Sekiyama  ;;
1330d9840e25STomoki Sekiyama  --without-vss-sdk) vss_win32_sdk="no"
1331d9840e25STomoki Sekiyama  ;;
1332d9840e25STomoki Sekiyama  --with-win-sdk) win_sdk=""
1333d9840e25STomoki Sekiyama  ;;
1334d9840e25STomoki Sekiyama  --with-win-sdk=*) win_sdk="$optarg"
1335d9840e25STomoki Sekiyama  ;;
1336d9840e25STomoki Sekiyama  --without-win-sdk) win_sdk="no"
1337d9840e25STomoki Sekiyama  ;;
13384b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
13394b1c11fdSDaniel P. Berrange  ;;
13404b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
13414b1c11fdSDaniel P. Berrange  ;;
134290835c2bSPaolo Bonzini  --enable-seccomp) seccomp="enabled"
1343f794573eSEduardo Otubo  ;;
134490835c2bSPaolo Bonzini  --disable-seccomp) seccomp="disabled"
1345f794573eSEduardo Otubo  ;;
134608821ca2SPaolo Bonzini  --disable-glusterfs) glusterfs="disabled"
1347eb100396SBharata B Rao  ;;
134886583a07SLiam Merwick  --disable-avx2) avx2_opt="no"
134986583a07SLiam Merwick  ;;
135086583a07SLiam Merwick  --enable-avx2) avx2_opt="yes"
135186583a07SLiam Merwick  ;;
13526b8cd447SRobert Hoo  --disable-avx512f) avx512f_opt="no"
13536b8cd447SRobert Hoo  ;;
13546b8cd447SRobert Hoo  --enable-avx512f) avx512f_opt="yes"
13556b8cd447SRobert Hoo  ;;
13566b8cd447SRobert Hoo
135708821ca2SPaolo Bonzini  --enable-glusterfs) glusterfs="enabled"
1358eb100396SBharata B Rao  ;;
135952b53c04SFam Zheng  --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
136052b53c04SFam Zheng      echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1361583f6e7bSStefan Hajnoczi  ;;
1362cb6414dfSFam Zheng  --enable-vhdx|--disable-vhdx)
1363cb6414dfSFam Zheng      echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1364cb6414dfSFam Zheng  ;;
1365315d3184SFam Zheng  --enable-uuid|--disable-uuid)
1366315d3184SFam Zheng      echo "$0: $opt is obsolete, UUID support is always built" >&2
1367315d3184SFam Zheng  ;;
13681b695471SPaolo Bonzini  --disable-gtk) gtk="disabled"
1369a4ccabcfSAnthony Liguori  ;;
13701b695471SPaolo Bonzini  --enable-gtk) gtk="enabled"
1371a4ccabcfSAnthony Liguori  ;;
1372a1c5e949SDaniel P. Berrange  --tls-priority=*) tls_priority="$optarg"
1373a1c5e949SDaniel P. Berrange  ;;
137457612511SPaolo Bonzini  --disable-gnutls) gnutls="disabled"
1375ddbb0d09SDaniel P. Berrange  ;;
137657612511SPaolo Bonzini  --enable-gnutls) gnutls="enabled"
1377ddbb0d09SDaniel P. Berrange  ;;
137857612511SPaolo Bonzini  --disable-nettle) nettle="disabled"
137991bfcdb0SDaniel P. Berrange  ;;
138057612511SPaolo Bonzini  --enable-nettle) nettle="enabled"
138191bfcdb0SDaniel P. Berrange  ;;
138257612511SPaolo Bonzini  --disable-gcrypt) gcrypt="disabled"
138391bfcdb0SDaniel P. Berrange  ;;
138457612511SPaolo Bonzini  --enable-gcrypt) gcrypt="enabled"
138591bfcdb0SDaniel P. Berrange  ;;
138605e391aeSPaolo Bonzini  --disable-auth-pam) auth_pam="disabled"
13878953caf3SDaniel P. Berrange  ;;
138805e391aeSPaolo Bonzini  --enable-auth-pam) auth_pam="enabled"
13898953caf3SDaniel P. Berrange  ;;
13902da776dbSMichael R. Hines  --enable-rdma) rdma="yes"
13912da776dbSMichael R. Hines  ;;
13922da776dbSMichael R. Hines  --disable-rdma) rdma="no"
13932da776dbSMichael R. Hines  ;;
139421ab34c9SMarcel Apfelbaum  --enable-pvrdma) pvrdma="yes"
139521ab34c9SMarcel Apfelbaum  ;;
139621ab34c9SMarcel Apfelbaum  --disable-pvrdma) pvrdma="no"
139721ab34c9SMarcel Apfelbaum  ;;
1398c23d7b4eSPaolo Bonzini  --disable-vte) vte="disabled"
1399bbbf9bfbSStefan Weil  ;;
1400c23d7b4eSPaolo Bonzini  --enable-vte) vte="enabled"
1401bbbf9bfbSStefan Weil  ;;
1402587d59d6SPaolo Bonzini  --disable-virglrenderer) virglrenderer="disabled"
14039d9e1521SGerd Hoffmann  ;;
1404587d59d6SPaolo Bonzini  --enable-virglrenderer) virglrenderer="enabled"
14059d9e1521SGerd Hoffmann  ;;
1406e91c793cSCole Robinson  --disable-tpm) tpm="no"
1407e91c793cSCole Robinson  ;;
1408ab214c29SStefan Berger  --enable-tpm) tpm="yes"
1409ab214c29SStefan Berger  ;;
1410b10d49d7SPino Toscano  --disable-libssh) libssh="no"
14110a12ec87SRichard W.M. Jones  ;;
1412b10d49d7SPino Toscano  --enable-libssh) libssh="yes"
14130a12ec87SRichard W.M. Jones  ;;
1414ed1701c6SDr. David Alan Gilbert  --disable-live-block-migration) live_block_migration="no"
1415ed1701c6SDr. David Alan Gilbert  ;;
1416ed1701c6SDr. David Alan Gilbert  --enable-live-block-migration) live_block_migration="yes"
1417ed1701c6SDr. David Alan Gilbert  ;;
1418a99d57bbSWanlong Gao  --disable-numa) numa="no"
1419a99d57bbSWanlong Gao  ;;
1420a99d57bbSWanlong Gao  --enable-numa) numa="yes"
1421a99d57bbSWanlong Gao  ;;
1422ed279a06SKlim Kireev  --disable-libxml2) libxml2="no"
1423ed279a06SKlim Kireev  ;;
1424ed279a06SKlim Kireev  --enable-libxml2) libxml2="yes"
1425ed279a06SKlim Kireev  ;;
14262847b469SFam Zheng  --disable-tcmalloc) tcmalloc="no"
14272847b469SFam Zheng  ;;
14282847b469SFam Zheng  --enable-tcmalloc) tcmalloc="yes"
14292847b469SFam Zheng  ;;
14307b01cb97SAlexandre Derumier  --disable-jemalloc) jemalloc="no"
14317b01cb97SAlexandre Derumier  ;;
14327b01cb97SAlexandre Derumier  --enable-jemalloc) jemalloc="yes"
14337b01cb97SAlexandre Derumier  ;;
1434a6b1d4c0SChanglong Xie  --disable-replication) replication="no"
1435a6b1d4c0SChanglong Xie  ;;
1436a6b1d4c0SChanglong Xie  --enable-replication) replication="yes"
1437a6b1d4c0SChanglong Xie  ;;
14382f740136SJeff Cody  --disable-bochs) bochs="no"
14392f740136SJeff Cody  ;;
14402f740136SJeff Cody  --enable-bochs) bochs="yes"
14412f740136SJeff Cody  ;;
14422f740136SJeff Cody  --disable-cloop) cloop="no"
14432f740136SJeff Cody  ;;
14442f740136SJeff Cody  --enable-cloop) cloop="yes"
14452f740136SJeff Cody  ;;
14462f740136SJeff Cody  --disable-dmg) dmg="no"
14472f740136SJeff Cody  ;;
14482f740136SJeff Cody  --enable-dmg) dmg="yes"
14492f740136SJeff Cody  ;;
14502f740136SJeff Cody  --disable-qcow1) qcow1="no"
14512f740136SJeff Cody  ;;
14522f740136SJeff Cody  --enable-qcow1) qcow1="yes"
14532f740136SJeff Cody  ;;
14542f740136SJeff Cody  --disable-vdi) vdi="no"
14552f740136SJeff Cody  ;;
14562f740136SJeff Cody  --enable-vdi) vdi="yes"
14572f740136SJeff Cody  ;;
14582f740136SJeff Cody  --disable-vvfat) vvfat="no"
14592f740136SJeff Cody  ;;
14602f740136SJeff Cody  --enable-vvfat) vvfat="yes"
14612f740136SJeff Cody  ;;
14622f740136SJeff Cody  --disable-qed) qed="no"
14632f740136SJeff Cody  ;;
14642f740136SJeff Cody  --enable-qed) qed="yes"
14652f740136SJeff Cody  ;;
14662f740136SJeff Cody  --disable-parallels) parallels="no"
14672f740136SJeff Cody  ;;
14682f740136SJeff Cody  --enable-parallels) parallels="yes"
14692f740136SJeff Cody  ;;
1470e6a74868SMarc-André Lureau  --disable-vhost-user) vhost_user="no"
1471e6a74868SMarc-André Lureau  ;;
1472299e6f19SPaolo Bonzini  --enable-vhost-user) vhost_user="yes"
1473299e6f19SPaolo Bonzini  ;;
1474108a6481SCindy Lu  --disable-vhost-vdpa) vhost_vdpa="no"
1475108a6481SCindy Lu  ;;
1476108a6481SCindy Lu  --enable-vhost-vdpa) vhost_vdpa="yes"
1477108a6481SCindy Lu  ;;
1478299e6f19SPaolo Bonzini  --disable-vhost-kernel) vhost_kernel="no"
1479299e6f19SPaolo Bonzini  ;;
1480299e6f19SPaolo Bonzini  --enable-vhost-kernel) vhost_kernel="yes"
1481e6a74868SMarc-André Lureau  ;;
14828b18cdbfSRichard Henderson  --disable-capstone) capstone="disabled"
14838ca80760SRichard Henderson  ;;
14848b18cdbfSRichard Henderson  --enable-capstone) capstone="enabled"
14858ca80760SRichard Henderson  ;;
14868b18cdbfSRichard Henderson  --enable-capstone=git) capstone="internal"
1487e219c499SRichard Henderson  ;;
1488e219c499SRichard Henderson  --enable-capstone=system) capstone="system"
1489e219c499SRichard Henderson  ;;
1490cc84d63aSDaniel P. Berrange  --with-git=*) git="$optarg"
1491cc84d63aSDaniel P. Berrange  ;;
14927d7dbf9dSDan Streetman  --enable-git-update)
14937d7dbf9dSDan Streetman      git_submodules_action="update"
14947d7dbf9dSDan Streetman      echo "--enable-git-update deprecated, use --with-git-submodules=update"
1495f62bbee5SDaniel P. Berrange  ;;
14967d7dbf9dSDan Streetman  --disable-git-update)
14977d7dbf9dSDan Streetman      git_submodules_action="validate"
14987d7dbf9dSDan Streetman      echo "--disable-git-update deprecated, use --with-git-submodules=validate"
14997d7dbf9dSDan Streetman  ;;
15007d7dbf9dSDan Streetman  --with-git-submodules=*)
15017d7dbf9dSDan Streetman      git_submodules_action="$optarg"
1502f62bbee5SDaniel P. Berrange  ;;
1503ba59fb77SPaolo Bonzini  --enable-debug-mutex) debug_mutex=yes
1504ba59fb77SPaolo Bonzini  ;;
1505ba59fb77SPaolo Bonzini  --disable-debug-mutex) debug_mutex=no
1506ba59fb77SPaolo Bonzini  ;;
1507*e36e8c70SPaolo Bonzini  --enable-libpmem) libpmem=disabled
150817824406SJunyan He  ;;
1509*e36e8c70SPaolo Bonzini  --disable-libpmem) libpmem=enabled
151017824406SJunyan He  ;;
15114113f4cfSLaurent Vivier  --enable-xkbcommon) xkbcommon="enabled"
151275411919SJames Le Cuirot  ;;
15134113f4cfSLaurent Vivier  --disable-xkbcommon) xkbcommon="disabled"
151475411919SJames Le Cuirot  ;;
151540e8c6f4SAlex Bennée  --enable-plugins) plugins="yes"
151640e8c6f4SAlex Bennée  ;;
151740e8c6f4SAlex Bennée  --disable-plugins) plugins="no"
151840e8c6f4SAlex Bennée  ;;
1519afc3a8f9SAlex Bennée  --enable-containers) use_containers="yes"
1520afc3a8f9SAlex Bennée  ;;
1521afc3a8f9SAlex Bennée  --disable-containers) use_containers="no"
1522afc3a8f9SAlex Bennée  ;;
1523adc28027SAlexander Bulekov  --enable-fuzzing) fuzzing=yes
1524adc28027SAlexander Bulekov  ;;
1525adc28027SAlexander Bulekov  --disable-fuzzing) fuzzing=no
1526adc28027SAlexander Bulekov  ;;
1527f48e590aSAlex Bennée  --gdb=*) gdb_bin="$optarg"
1528f48e590aSAlex Bennée  ;;
1529b767d257SMarek Marczykowski-Górecki  --enable-rng-none) rng_none=yes
1530b767d257SMarek Marczykowski-Górecki  ;;
1531b767d257SMarek Marczykowski-Górecki  --disable-rng-none) rng_none=no
1532b767d257SMarek Marczykowski-Górecki  ;;
153354e7aac0SAlexey Krasikov  --enable-keyring) secret_keyring="yes"
153454e7aac0SAlexey Krasikov  ;;
153554e7aac0SAlexey Krasikov  --disable-keyring) secret_keyring="no"
153654e7aac0SAlexey Krasikov  ;;
153783ef1682SPaolo Bonzini  --enable-libdaxctl) libdaxctl=disabled
153821b2eca6SJingqi Liu  ;;
153983ef1682SPaolo Bonzini  --disable-libdaxctl) libdaxctl=enabled
154021b2eca6SJingqi Liu  ;;
1541a484a719SMax Reitz  --enable-fuse) fuse="enabled"
1542a484a719SMax Reitz  ;;
1543a484a719SMax Reitz  --disable-fuse) fuse="disabled"
1544a484a719SMax Reitz  ;;
1545df4ea709SMax Reitz  --enable-fuse-lseek) fuse_lseek="enabled"
1546df4ea709SMax Reitz  ;;
1547df4ea709SMax Reitz  --disable-fuse-lseek) fuse_lseek="disabled"
1548df4ea709SMax Reitz  ;;
1549106ad1f9SPaolo Bonzini  --enable-multiprocess) multiprocess="enabled"
15503090de69SJagannathan Raman  ;;
1551106ad1f9SPaolo Bonzini  --disable-multiprocess) multiprocess="disabled"
15523090de69SJagannathan Raman  ;;
155320cf7b8eSDenis Plotnikov  --enable-gio) gio=yes
155420cf7b8eSDenis Plotnikov  ;;
155520cf7b8eSDenis Plotnikov  --disable-gio) gio=no
155620cf7b8eSDenis Plotnikov  ;;
1557b8e0c493SJoelle van Dyne  --enable-slirp-smbd) slirp_smbd=yes
1558b8e0c493SJoelle van Dyne  ;;
1559b8e0c493SJoelle van Dyne  --disable-slirp-smbd) slirp_smbd=no
1560b8e0c493SJoelle van Dyne  ;;
15612d2ad6d0SFam Zheng  *)
15622d2ad6d0SFam Zheng      echo "ERROR: unknown option $opt"
15632d2ad6d0SFam Zheng      echo "Try '$0 --help' for more information"
15642d2ad6d0SFam Zheng      exit 1
15657f1559c6Sbalrog  ;;
15667d13299dSbellard  esac
15677d13299dSbellarddone
15687d13299dSbellard
15697d7dbf9dSDan Streetmancase $git_submodules_action in
15707d7dbf9dSDan Streetman    update|validate)
15717d7dbf9dSDan Streetman        if test ! -e "$source_path/.git"; then
15727d7dbf9dSDan Streetman            echo "ERROR: cannot $git_submodules_action git submodules without .git"
15737d7dbf9dSDan Streetman            exit 1
15747d7dbf9dSDan Streetman        fi
15757d7dbf9dSDan Streetman    ;;
15767d7dbf9dSDan Streetman    ignore)
1577b80fd281SPaolo Bonzini        if ! test -f "$source_path/ui/keycodemapdb/README"
1578b80fd281SPaolo Bonzini        then
1579b80fd281SPaolo Bonzini            echo
1580b80fd281SPaolo Bonzini            echo "ERROR: missing GIT submodules"
1581b80fd281SPaolo Bonzini            echo
1582b80fd281SPaolo Bonzini            if test -e "$source_path/.git"; then
1583b80fd281SPaolo Bonzini                echo "--with-git-submodules=ignore specified but submodules were not"
1584b80fd281SPaolo Bonzini                echo "checked out.  Please initialize and update submodules."
1585b80fd281SPaolo Bonzini            else
1586b80fd281SPaolo Bonzini                echo "This is not a GIT checkout but module content appears to"
1587b80fd281SPaolo Bonzini                echo "be missing. Do not use 'git archive' or GitHub download links"
1588b80fd281SPaolo Bonzini                echo "to acquire QEMU source archives. Non-GIT builds are only"
1589b80fd281SPaolo Bonzini                echo "supported with source archives linked from:"
1590b80fd281SPaolo Bonzini                echo
1591b80fd281SPaolo Bonzini                echo "  https://www.qemu.org/download/#source"
1592b80fd281SPaolo Bonzini                echo
1593b80fd281SPaolo Bonzini                echo "Developers working with GIT can use scripts/archive-source.sh"
1594b80fd281SPaolo Bonzini                echo "if they need to create valid source archives."
1595b80fd281SPaolo Bonzini            fi
1596b80fd281SPaolo Bonzini            echo
1597b80fd281SPaolo Bonzini            exit 1
1598b80fd281SPaolo Bonzini        fi
15997d7dbf9dSDan Streetman    ;;
16007d7dbf9dSDan Streetman    *)
16017d7dbf9dSDan Streetman        echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'"
16027d7dbf9dSDan Streetman        exit 1
16037d7dbf9dSDan Streetman    ;;
16047d7dbf9dSDan Streetmanesac
16057d7dbf9dSDan Streetman
160622a87800SMarc-André Lureaulibdir="${libdir:-$prefix/lib}"
160722a87800SMarc-André Lureaulibexecdir="${libexecdir:-$prefix/libexec}"
160822a87800SMarc-André Lureauincludedir="${includedir:-$prefix/include}"
160922a87800SMarc-André Lureau
161022a87800SMarc-André Lureauif test "$mingw32" = "yes" ; then
161115588a62SJoshua Watt    bindir="${bindir:-$prefix}"
161222a87800SMarc-André Lureauelse
161315588a62SJoshua Watt    bindir="${bindir:-$prefix/bin}"
161415588a62SJoshua Wattfi
161522a87800SMarc-André Lureaumandir="${mandir:-$prefix/share/man}"
161622a87800SMarc-André Lureaudatadir="${datadir:-$prefix/share}"
1617ca8c0909SMarc-André Lureaudocdir="${docdir:-$prefix/share/doc}"
161822a87800SMarc-André Lureausysconfdir="${sysconfdir:-$prefix/etc}"
161922a87800SMarc-André Lureaulocal_statedir="${local_statedir:-$prefix/var}"
162016bf7a33SPaolo Bonzinifirmwarepath="${firmwarepath:-$datadir/qemu-firmware}"
162116bf7a33SPaolo Bonzinilocaledir="${localedir:-$datadir/locale}"
162222a87800SMarc-André Lureau
162340293e58Sbellardcase "$cpu" in
1624e3608d66SRichard Henderson    ppc)
1625e3608d66SRichard Henderson           CPU_CFLAGS="-m32"
1626db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m32 $QEMU_LDFLAGS"
1627e3608d66SRichard Henderson           ;;
1628e3608d66SRichard Henderson    ppc64)
1629e3608d66SRichard Henderson           CPU_CFLAGS="-m64"
1630db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
1631e3608d66SRichard Henderson           ;;
16329b9c37c3SRichard Henderson    sparc)
1633f1079bb8SRichard Henderson           CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
1634db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m32 -mv8plus $QEMU_LDFLAGS"
16353142255cSblueswir1           ;;
1636ed968ff1SJuan Quintela    sparc64)
163779f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1638db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
16393142255cSblueswir1           ;;
164076d83bdeSths    s390)
1641061cdd81SRichard Henderson           CPU_CFLAGS="-m31"
1642db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m31 $QEMU_LDFLAGS"
164328d7cc49SRichard Henderson           ;;
164428d7cc49SRichard Henderson    s390x)
1645061cdd81SRichard Henderson           CPU_CFLAGS="-m64"
1646db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
164776d83bdeSths           ;;
164840293e58Sbellard    i386)
164979f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32"
1650db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m32 $QEMU_LDFLAGS"
165140293e58Sbellard           ;;
165240293e58Sbellard    x86_64)
16537ebee43eSRichard Henderson           # ??? Only extremely old AMD cpus do not have cmpxchg16b.
16547ebee43eSRichard Henderson           # If we truly care, we should simply detect this case at
16557ebee43eSRichard Henderson           # runtime and generate the fallback to serial emulation.
16567ebee43eSRichard Henderson           CPU_CFLAGS="-m64 -mcx16"
1657db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
1658379f6698SPaul Brook           ;;
1659c72b26ecSRichard Henderson    x32)
1660c72b26ecSRichard Henderson           CPU_CFLAGS="-mx32"
1661db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-mx32 $QEMU_LDFLAGS"
1662c72b26ecSRichard Henderson           ;;
166330163d89SPeter Maydell    # No special flags required for other host CPUs
16643142255cSblueswir1esac
16653142255cSblueswir1
1666b1aa4de1SAlex Bennéeeval "cross_cc_${cpu}=\$cc"
16672038f8c8SPaolo Bonzinicross_cc_vars="$cross_cc_vars cross_cc_${cpu}"
166879f3b12fSPeter CrosthwaiteQEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
166979f3b12fSPeter Crosthwaite
1670affc88ccSPeter Maydell# For user-mode emulation the host arch has to be one we explicitly
1671affc88ccSPeter Maydell# support, even if we're using TCI.
1672affc88ccSPeter Maydellif [ "$ARCH" = "unknown" ]; then
1673affc88ccSPeter Maydell  bsd_user="no"
1674affc88ccSPeter Maydell  linux_user="no"
1675affc88ccSPeter Maydellfi
1676affc88ccSPeter Maydell
167760e0df25SPeter Maydelldefault_target_list=""
167843692239SMarkus Armbrusterdeprecated_targets_list=ppc64abi32-linux-user
1679fdb75aefSPaolo Bonzinideprecated_features=""
16806e92f823SPeter Maydellmak_wilds=""
16816e92f823SPeter Maydell
168260e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then
168373362fc0SPaolo Bonzini    mak_wilds="${mak_wilds} $source_path/default-configs/targets/*-softmmu.mak"
168460e0df25SPeter Maydellfi
168560e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then
168673362fc0SPaolo Bonzini    mak_wilds="${mak_wilds} $source_path/default-configs/targets/*-linux-user.mak"
168760e0df25SPeter Maydellfi
168860e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then
168973362fc0SPaolo Bonzini    mak_wilds="${mak_wilds} $source_path/default-configs/targets/*-bsd-user.mak"
169060e0df25SPeter Maydellfi
169160e0df25SPeter Maydell
16923a5ae4a9SAlex Bennée# If the user doesn't explicitly specify a deprecated target we will
16933a5ae4a9SAlex Bennée# skip it.
16943a5ae4a9SAlex Bennéeif test -z "$target_list"; then
16953a5ae4a9SAlex Bennée    if test -z "$target_list_exclude"; then
16963a5ae4a9SAlex Bennée        target_list_exclude="$deprecated_targets_list"
16973a5ae4a9SAlex Bennée    else
16983a5ae4a9SAlex Bennée        target_list_exclude="$target_list_exclude,$deprecated_targets_list"
16993a5ae4a9SAlex Bennée    fi
17002d838d9bSAlex Bennéefi
17012d838d9bSAlex Bennée
1702447e133fSAlex Bennéefor config in $mak_wilds; do
1703447e133fSAlex Bennée    target="$(basename "$config" .mak)"
170498db9a06SAlex Bennée    if echo "$target_list_exclude" | grep -vq "$target"; then
1705447e133fSAlex Bennée        default_target_list="${default_target_list} $target"
1706447e133fSAlex Bennée    fi
1707447e133fSAlex Bennéedone
17086e92f823SPeter Maydell
1709c53eeaf7SStefan Hajnoczi# Enumerate public trace backends for --help output
171064a6047dSGreg Kurztrace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
1711c53eeaf7SStefan Hajnoczi
1712af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1713af5db58eSpbrookcat << EOF
1714af5db58eSpbrook
1715af5db58eSpbrookUsage: configure [options]
1716af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1717af5db58eSpbrook
171808fb77edSStefan WeilStandard options:
171908fb77edSStefan Weil  --help                   print this message
172008fb77edSStefan Weil  --prefix=PREFIX          install in PREFIX [$prefix]
172108fb77edSStefan Weil  --interp-prefix=PREFIX   where to find shared libraries, etc.
172208fb77edSStefan Weil                           use %M for cpu name [$interp_prefix]
17232deca810SAlex Bennée  --target-list=LIST       set target list (default: build all non-deprecated)
172408fb77edSStefan Weil$(echo Available targets: $default_target_list | \
172508fb77edSStefan Weil  fold -s -w 53 | sed -e 's/^/                           /')
17262deca810SAlex Bennée$(echo Deprecated targets: $deprecated_targets_list | \
17272deca810SAlex Bennée  fold -s -w 53 | sed -e 's/^/                           /')
1728447e133fSAlex Bennée  --target-list-exclude=LIST exclude a set of targets from the default target-list
172908fb77edSStefan Weil
173008fb77edSStefan WeilAdvanced options (experts only):
17313812c0c4SJoelle van Dyne  --cross-prefix=PREFIX    use PREFIX for compile tools, PREFIX can be blank [$cross_prefix]
173208fb77edSStefan Weil  --cc=CC                  use C compiler CC [$cc]
173308fb77edSStefan Weil  --iasl=IASL              use ACPI compiler IASL [$iasl]
173408fb77edSStefan Weil  --host-cc=CC             use C compiler CC [$host_cc] for code run at
173508fb77edSStefan Weil                           build time
173608fb77edSStefan Weil  --cxx=CXX                use C++ compiler CXX [$cxx]
173708fb77edSStefan Weil  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]
173808fb77edSStefan Weil  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS
173911cde1c8SBruno Dominguez  --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
174008fb77edSStefan Weil  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
1741d75402b5SAlex Bennée  --cross-cc-ARCH=CC       use compiler when building ARCH guest test cases
1742d422b2bcSAlex Bennée  --cross-cc-flags-ARCH=   use compiler flags when building ARCH guest tests
174308fb77edSStefan Weil  --make=MAKE              use specified make [$make]
174408fb77edSStefan Weil  --python=PYTHON          use specified python [$python]
17452eb054c2SPeter Maydell  --sphinx-build=SPHINX    use specified sphinx-build [$sphinx_build]
1746a5665051SPaolo Bonzini  --meson=MESON            use specified meson [$meson]
174748328880SPaolo Bonzini  --ninja=NINJA            use specified ninja [$ninja]
174808fb77edSStefan Weil  --smbd=SMBD              use specified smbd [$smbd]
1749db1b5f13SThomas Huth  --with-git=GIT           use specified git [$git]
17507d7dbf9dSDan Streetman  --with-git-submodules=update   update git submodules (default if .git dir exists)
17517d7dbf9dSDan Streetman  --with-git-submodules=validate fail if git submodules are not up to date
17527d7dbf9dSDan Streetman  --with-git-submodules=ignore   do not update or check git submodules (default if no .git dir)
175308fb77edSStefan Weil  --static                 enable static build [$static]
175408fb77edSStefan Weil  --mandir=PATH            install man pages in PATH
175510ff82d1SMarc-André Lureau  --datadir=PATH           install firmware in PATH/$qemu_suffix
1756fe0038beSPaolo Bonzini  --localedir=PATH         install translation in PATH/$qemu_suffix
175710ff82d1SMarc-André Lureau  --docdir=PATH            install documentation in PATH/$qemu_suffix
175808fb77edSStefan Weil  --bindir=PATH            install binaries in PATH
175908fb77edSStefan Weil  --libdir=PATH            install libraries in PATH
1760db1b5f13SThomas Huth  --libexecdir=PATH        install helper binaries in PATH
176110ff82d1SMarc-André Lureau  --sysconfdir=PATH        install config in PATH/$qemu_suffix
176208fb77edSStefan Weil  --localstatedir=PATH     install local state in PATH (set at runtime on win32)
17633d5eecabSGerd Hoffmann  --firmwarepath=PATH      search PATH for firmware files
176413336606SRobert Foley  --efi-aarch64=PATH       PATH of efi file to use for aarch64 VMs.
1765ca8c0909SMarc-André Lureau  --with-suffix=SUFFIX     suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix]
1766db1b5f13SThomas Huth  --with-pkgversion=VERS   use specified string as sub-version of the package
1767c035c8d6SPaolo Bonzini  --without-default-features default all --enable-* options to "disabled"
1768c035c8d6SPaolo Bonzini  --without-default-devices  do not include any device that is not needed to
1769c035c8d6SPaolo Bonzini                           start the emulator (only use if you are including
1770c035c8d6SPaolo Bonzini                           desired devices in default-configs/devices/)
177108fb77edSStefan Weil  --enable-debug           enable common debug build options
1772247724cbSMarc-André Lureau  --enable-sanitizers      enable default sanitizers
17730aebab04SLingfeng Yang  --enable-tsan            enable thread sanitizer
177408fb77edSStefan Weil  --disable-strip          disable stripping binaries
177508fb77edSStefan Weil  --disable-werror         disable compilation abort on warning
177663678e17SSteven Noonan  --disable-stack-protector disable compiler-provided stack protection
177708fb77edSStefan Weil  --audio-drv-list=LIST    set audio drivers list:
177808fb77edSStefan Weil                           Available drivers: $audio_possible_drivers
177908fb77edSStefan Weil  --block-drv-whitelist=L  Same as --block-drv-rw-whitelist=L
178008fb77edSStefan Weil  --block-drv-rw-whitelist=L
178108fb77edSStefan Weil                           set block driver read-write whitelist
178208fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
178308fb77edSStefan Weil  --block-drv-ro-whitelist=L
178408fb77edSStefan Weil                           set block driver read-only whitelist
178508fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
17865b808275SLluís Vilanova  --enable-trace-backends=B Set trace backend
1787c53eeaf7SStefan Hajnoczi                           Available backends: $trace_backend_list
178808fb77edSStefan Weil  --with-trace-file=NAME   Full PATH,NAME of file to store traces
178908fb77edSStefan Weil                           Default:trace-<pid>
1790c23f23b9SMichael Tokarev  --disable-slirp          disable SLIRP userspace network connectivity
1791e9a16e38SPhilippe Mathieu-Daudé  --enable-tcg-interpreter enable TCI (TCG with bytecode interpreter, experimental and slow)
17925a22ab71SYang Zhong  --enable-malloc-trim     enable libc malloc_trim() for memory optimization
1793c23f23b9SMichael Tokarev  --oss-lib                path to OSS library
1794c23f23b9SMichael Tokarev  --cpu=CPU                Build for host CPU [$cpu]
179508fb77edSStefan Weil  --with-coroutine=BACKEND coroutine backend. Supported options:
179633c53c54SDaniel P. Berrange                           ucontext, sigaltstack, windows
179708fb77edSStefan Weil  --enable-gcov            enable test coverage analysis with gcov
1798c23f23b9SMichael Tokarev  --disable-blobs          disable installing provided firmware blobs
1799c23f23b9SMichael Tokarev  --with-vss-sdk=SDK-path  enable Windows VSS support in QEMU Guest Agent
1800c23f23b9SMichael Tokarev  --with-win-sdk=SDK-path  path to Windows Platform SDK (to build VSS .tlb)
1801a1c5e949SDaniel P. Berrange  --tls-priority           default TLS protocol/cipher priority string
1802c12d66aaSLin Ma  --enable-gprof           QEMU profiling with gprof
1803c12d66aaSLin Ma  --enable-profiler        profiler support
1804c12d66aaSLin Ma  --enable-debug-stack-usage
1805c12d66aaSLin Ma                           track the maximum stack usage of stacks created by qemu_alloc_stack
180640e8c6f4SAlex Bennée  --enable-plugins
180740e8c6f4SAlex Bennée                           enable plugins via shared library loading
1808afc3a8f9SAlex Bennée  --disable-containers     don't use containers for cross-building
1809f48e590aSAlex Bennée  --gdb=GDB-path           gdb to use for gdbstub tests [$gdb_bin]
1810c23f23b9SMichael Tokarev
1811c23f23b9SMichael TokarevOptional features, enabled with --enable-FEATURE and
1812c87ea116SAlex Bennéedisabled with --disable-FEATURE, default is enabled if available
1813c87ea116SAlex Bennée(unless built with --without-default-features):
1814c23f23b9SMichael Tokarev
1815c23f23b9SMichael Tokarev  system          all system emulation targets
1816c23f23b9SMichael Tokarev  user            supported user emulation targets
1817c23f23b9SMichael Tokarev  linux-user      all linux usermode emulation targets
1818c23f23b9SMichael Tokarev  bsd-user        all BSD usermode emulation targets
1819c23f23b9SMichael Tokarev  docs            build documentation
1820c23f23b9SMichael Tokarev  guest-agent     build the QEMU Guest Agent
1821c23f23b9SMichael Tokarev  guest-agent-msi build guest agent Windows MSI installation package
1822c23f23b9SMichael Tokarev  pie             Position Independent Executables
182321e709aaSMarc-André Lureau  modules         modules support (non-Windows)
1824bd83c861SChristian Ehrhardt  module-upgrades try to load modules from alternate paths for upgrades
1825c23f23b9SMichael Tokarev  debug-tcg       TCG debugging (default is disabled)
1826c23f23b9SMichael Tokarev  debug-info      debugging information
1827cdad781dSDaniele Buono  lto             Enable Link-Time Optimization.
1828c23f23b9SMichael Tokarev  sparse          sparse checker
18291e4f6065SDaniele Buono  safe-stack      SafeStack Stack Smash Protection. Depends on
18301e4f6065SDaniele Buono                  clang/llvm >= 3.7 and requires coroutine backend ucontext.
18319e62ba48SDaniele Buono  cfi             Enable Control-Flow Integrity for indirect function calls.
18329e62ba48SDaniele Buono                  In case of a cfi violation, QEMU is terminated with SIGILL
18339e62ba48SDaniele Buono                  Depends on lto and is incompatible with modules
18349e62ba48SDaniele Buono                  Automatically enables Link-Time Optimization (lto)
18359e62ba48SDaniele Buono  cfi-debug       In case of a cfi violation, a message containing the line that
18369e62ba48SDaniele Buono                  triggered the error is written to stderr. After the error,
18379e62ba48SDaniele Buono                  QEMU is still terminated with SIGILL
1838ddbb0d09SDaniel P. Berrange  gnutls          GNUTLS cryptography support
183991bfcdb0SDaniel P. Berrange  nettle          nettle cryptography support
184091bfcdb0SDaniel P. Berrange  gcrypt          libgcrypt cryptography support
18418953caf3SDaniel P. Berrange  auth-pam        PAM access control
1842c23f23b9SMichael Tokarev  sdl             SDL UI
184304c6e16fSMarkus Armbruster  sdl-image       SDL Image support for icons
1844c23f23b9SMichael Tokarev  gtk             gtk UI
1845c23f23b9SMichael Tokarev  vte             vte support for the gtk UI
1846c23f23b9SMichael Tokarev  curses          curses UI
1847e08bb301SSamuel Thibault  iconv           font glyph conversion support
1848c23f23b9SMichael Tokarev  vnc             VNC UI support
1849c23f23b9SMichael Tokarev  vnc-sasl        SASL encryption for VNC server
1850c23f23b9SMichael Tokarev  vnc-jpeg        JPEG lossy compression for VNC server
1851c23f23b9SMichael Tokarev  vnc-png         PNG compression for VNC server
1852c23f23b9SMichael Tokarev  cocoa           Cocoa UI (Mac OS X only)
1853c23f23b9SMichael Tokarev  virtfs          VirtFS
1854cece116cSMisono Tomohiro  virtiofsd       build virtiofs daemon (virtiofsd)
18555c53015aSPaolo Bonzini  libudev         Use libudev to enumerate host devices
1856fe8fc5aeSPaolo Bonzini  mpath           Multipath persistent reservation passthrough
1857c23f23b9SMichael Tokarev  xen             xen backend driver support
185870c292afSAnthony PERARD  xen-pci-passthrough    PCI passthrough support for Xen
1859c23f23b9SMichael Tokarev  brlapi          BrlAPI (Braile)
1860c23f23b9SMichael Tokarev  curl            curl connectivity
1861a40161cbSPaolo Bonzini  membarrier      membarrier system call (for Linux 4.14+ or Windows)
1862c23f23b9SMichael Tokarev  fdt             fdt device tree
1863c23f23b9SMichael Tokarev  kvm             KVM acceleration support
1864b0cb0a66SVincent Palatin  hax             HAX acceleration support
1865c97d6d2cSSergio Andres Gomez Del Real  hvf             Hypervisor.framework acceleration support
186674a414a1SReinoud Zandijk  nvmm            NVMM acceleration support
1867d661d9a4SJustin Terry (VM)  whpx            Windows Hypervisor Platform acceleration support
186821ab34c9SMarcel Apfelbaum  rdma            Enable RDMA-based migration
186921ab34c9SMarcel Apfelbaum  pvrdma          Enable PVRDMA support
1870c23f23b9SMichael Tokarev  vde             support for vde network
1871c23f23b9SMichael Tokarev  netmap          support for netmap network
1872c23f23b9SMichael Tokarev  linux-aio       Linux AIO support
1873c10dd856SAarushi Mehta  linux-io-uring  Linux io_uring support
1874c23f23b9SMichael Tokarev  cap-ng          libcap-ng support
1875c23f23b9SMichael Tokarev  attr            attr and xattr support
1876299e6f19SPaolo Bonzini  vhost-net       vhost-net kernel acceleration support
1877299e6f19SPaolo Bonzini  vhost-vsock     virtio sockets device support
1878299e6f19SPaolo Bonzini  vhost-scsi      vhost-scsi kernel target support
1879299e6f19SPaolo Bonzini  vhost-crypto    vhost-user-crypto backend support
1880299e6f19SPaolo Bonzini  vhost-kernel    vhost kernel backend support
1881299e6f19SPaolo Bonzini  vhost-user      vhost-user backend support
1882bc15e44cSStefan Hajnoczi  vhost-user-blk-server    vhost-user-blk server support
1883108a6481SCindy Lu  vhost-vdpa      vhost-vdpa kernel backend support
188446627f41SAndrew Melnychenko  bpf             BPF kernel support
1885c23f23b9SMichael Tokarev  spice           spice
188658d3f3ffSGerd Hoffmann  spice-protocol  spice-protocol
1887c23f23b9SMichael Tokarev  rbd             rados block device (rbd)
1888c23f23b9SMichael Tokarev  libiscsi        iscsi support
1889c23f23b9SMichael Tokarev  libnfs          nfs support
18907b02f544SMarc-André Lureau  smartcard       smartcard support (libcacard)
18910a40bcb7SCésar Belley  u2f             U2F support (u2f-emu)
1892c23f23b9SMichael Tokarev  libusb          libusb (for usb passthrough)
1893ed1701c6SDr. David Alan Gilbert  live-block-migration   Block migration in the main migration stream
1894c23f23b9SMichael Tokarev  usb-redir       usb network redirection support
1895c23f23b9SMichael Tokarev  lzo             support of lzo compression library
1896c23f23b9SMichael Tokarev  snappy          support of snappy compression library
1897c23f23b9SMichael Tokarev  bzip2           support of bzip2 compression library
1898c23f23b9SMichael Tokarev                  (for reading bzip2-compressed dmg images)
189983bc1f97SJulio Faracco  lzfse           support of lzfse compression library
190083bc1f97SJulio Faracco                  (for reading lzfse-compressed dmg images)
19013a678481SJuan Quintela  zstd            support for zstd compression library
1902d298ac10SDenis Plotnikov                  (for migration compression and qcow2 cluster compression)
1903c23f23b9SMichael Tokarev  seccomp         seccomp support
1904c23f23b9SMichael Tokarev  coroutine-pool  coroutine freelist (better performance)
1905c23f23b9SMichael Tokarev  glusterfs       GlusterFS backend
1906c23f23b9SMichael Tokarev  tpm             TPM support
1907b10d49d7SPino Toscano  libssh          ssh block device support
1908c23f23b9SMichael Tokarev  numa            libnuma support
1909ed279a06SKlim Kireev  libxml2         for Parallels image format
1910c23f23b9SMichael Tokarev  tcmalloc        tcmalloc support
19117b01cb97SAlexandre Derumier  jemalloc        jemalloc support
191286583a07SLiam Merwick  avx2            AVX2 optimization support
19136b8cd447SRobert Hoo  avx512f         AVX512F optimization support
1914a6b1d4c0SChanglong Xie  replication     replication support
1915c12d66aaSLin Ma  opengl          opengl support
1916c12d66aaSLin Ma  virglrenderer   virgl rendering support
1917c12d66aaSLin Ma  xfsctl          xfsctl support
1918c12d66aaSLin Ma  qom-cast-debug  cast debugging support
19198de73fa8SCleber Rosa  tools           build qemu-io, qemu-nbd and qemu-img tools
19202f740136SJeff Cody  bochs           bochs image format support
19212f740136SJeff Cody  cloop           cloop image format support
19222f740136SJeff Cody  dmg             dmg image format support
19232f740136SJeff Cody  qcow1           qcow v1 image format support
19242f740136SJeff Cody  vdi             vdi image format support
19252f740136SJeff Cody  vvfat           vvfat image format support
19262f740136SJeff Cody  qed             qed image format support
19272f740136SJeff Cody  parallels       parallels image format support
1928f0d92b56SLongpeng(Mike)  crypto-afalg    Linux AF_ALG crypto backend driver
19298ca80760SRichard Henderson  capstone        capstone disassembler support
1930ba59fb77SPaolo Bonzini  debug-mutex     mutex debugging support
193117824406SJunyan He  libpmem         libpmem support
193275411919SJames Le Cuirot  xkbcommon       xkbcommon support
1933b767d257SMarek Marczykowski-Górecki  rng-none        dummy RNG, avoid using /dev/(u)random and getrandom()
193421b2eca6SJingqi Liu  libdaxctl       libdaxctl support
1935a484a719SMax Reitz  fuse            FUSE block device export
1936df4ea709SMax Reitz  fuse-lseek      SEEK_HOLE/SEEK_DATA support for FUSE exports
1937106ad1f9SPaolo Bonzini  multiprocess    Out of process device emulation support
193820cf7b8eSDenis Plotnikov  gio             libgio support
1939b8e0c493SJoelle van Dyne  slirp-smbd      use smbd (at path --smbd=*) in slirp networking
194008fb77edSStefan Weil
194108fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched
1942af5db58eSpbrookEOF
19432d2ad6d0SFam Zhengexit 0
1944af5db58eSpbrookfi
1945af5db58eSpbrook
19469c790242SThomas Huth# Remove old dependency files to make sure that they get properly regenerated
1947bb768f71SThomas Huthrm -f */config-devices.mak.d
19489c790242SThomas Huth
1949faf44142SDaniel P. Berrangéif test -z "$python"
1950faf44142SDaniel P. Berrangéthen
1951c53eeaf7SStefan Hajnoczi    error_exit "Python not found. Use --python=/path/to/python"
1952c53eeaf7SStefan Hajnoczifi
19538e2c76bdSRoman Bolshakovif ! has "$make"
19548e2c76bdSRoman Bolshakovthen
19558e2c76bdSRoman Bolshakov    error_exit "GNU make ($make) not found"
19568e2c76bdSRoman Bolshakovfi
1957c53eeaf7SStefan Hajnoczi
1958c53eeaf7SStefan Hajnoczi# Note that if the Python conditional here evaluates True we will exit
1959c53eeaf7SStefan Hajnoczi# with status 1 which is a shell 'false' value.
19601b11f28dSThomas Huthif ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then
19611b11f28dSThomas Huth  error_exit "Cannot use '$python', Python >= 3.6 is required." \
1962c53eeaf7SStefan Hajnoczi      "Use --python=/path/to/python to specify a supported Python."
1963c53eeaf7SStefan Hajnoczifi
1964c53eeaf7SStefan Hajnoczi
1965755ee70fSCleber Rosa# Preserve python version since some functionality is dependent on it
1966406ab2f3SCleber 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)
1967755ee70fSCleber Rosa
1968c53eeaf7SStefan Hajnoczi# Suppress writing compiled files
1969c53eeaf7SStefan Hajnoczipython="$python -B"
1970c53eeaf7SStefan Hajnoczi
19710a01d76fSMarc-André Lureauif test -z "$meson"; then
19726ebd89cfSPaolo Bonzini    if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.55.3; then
19730a01d76fSMarc-André Lureau        meson=meson
19747d7dbf9dSDan Streetman    elif test $git_submodules_action != 'ignore' ; then
19750a01d76fSMarc-André Lureau        meson=git
19760a01d76fSMarc-André Lureau    elif test -e "${source_path}/meson/meson.py" ; then
19770a01d76fSMarc-André Lureau        meson=internal
19780a01d76fSMarc-André Lureau    else
19790a01d76fSMarc-André Lureau        if test "$explicit_python" = yes; then
19800a01d76fSMarc-André Lureau            error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found."
19810a01d76fSMarc-André Lureau        else
1982a5665051SPaolo Bonzini            error_exit "Meson not found.  Use --meson=/path/to/meson"
1983a5665051SPaolo Bonzini        fi
19840a01d76fSMarc-André Lureau    fi
19850a01d76fSMarc-André Lureauelse
19860a01d76fSMarc-André Lureau    # Meson uses its own Python interpreter to invoke other Python scripts,
19870a01d76fSMarc-André Lureau    # but the user wants to use the one they specified with --python.
19880a01d76fSMarc-André Lureau    #
19890a01d76fSMarc-André Lureau    # We do not want to override the distro Python interpreter (and sometimes
19900a01d76fSMarc-André Lureau    # cannot: for example in Homebrew /usr/bin/meson is a bash script), so
19910a01d76fSMarc-André Lureau    # just require --meson=git|internal together with --python.
19920a01d76fSMarc-André Lureau    if test "$explicit_python" = yes; then
19930a01d76fSMarc-André Lureau        case "$meson" in
19940a01d76fSMarc-André Lureau            git | internal) ;;
19950a01d76fSMarc-André Lureau            *) error_exit "--python requires using QEMU's embedded Meson distribution." ;;
19960a01d76fSMarc-André Lureau        esac
19970a01d76fSMarc-André Lureau    fi
19980a01d76fSMarc-André Lureaufi
1999a5665051SPaolo Bonzini
20000a01d76fSMarc-André Lureauif test "$meson" = git; then
20010a01d76fSMarc-André Lureau    git_submodules="${git_submodules} meson"
20020a01d76fSMarc-André Lureaufi
20030a01d76fSMarc-André Lureau
20040a01d76fSMarc-André Lureaucase "$meson" in
20050a01d76fSMarc-André Lureau    git | internal)
20060a01d76fSMarc-André Lureau        meson="$python ${source_path}/meson/meson.py"
20070a01d76fSMarc-André Lureau        ;;
200884ec0c24SPaolo Bonzini    *) meson=$(command -v "$meson") ;;
20090a01d76fSMarc-André Lureauesac
20100a01d76fSMarc-André Lureau
201109e93326SPaolo Bonzini# Probe for ninja
201248328880SPaolo Bonzini
201348328880SPaolo Bonziniif test -z "$ninja"; then
201448328880SPaolo Bonzini    for c in ninja ninja-build samu; do
201548328880SPaolo Bonzini        if has $c; then
201648328880SPaolo Bonzini            ninja=$(command -v "$c")
201748328880SPaolo Bonzini            break
201848328880SPaolo Bonzini        fi
201948328880SPaolo Bonzini    done
202009e93326SPaolo Bonzini    if test -z "$ninja"; then
202109e93326SPaolo Bonzini      error_exit "Cannot find Ninja"
202209e93326SPaolo Bonzini    fi
202348328880SPaolo Bonzinifi
2024a5665051SPaolo Bonzini
20259aae6e54SDaniel Henrique Barboza# Check that the C compiler works. Doing this here before testing
20269aae6e54SDaniel Henrique Barboza# the host CPU ensures that we had a valid CC to autodetect the
20279aae6e54SDaniel Henrique Barboza# $cpu var (and we should bail right here if that's not the case).
20289aae6e54SDaniel Henrique Barboza# It also allows the help message to be printed without a CC.
20299aae6e54SDaniel Henrique Barbozawrite_c_skeleton;
20309aae6e54SDaniel Henrique Barbozaif compile_object ; then
20319aae6e54SDaniel Henrique Barboza  : C compiler works ok
20329aae6e54SDaniel Henrique Barbozaelse
20339aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" either does not exist or does not work"
20349aae6e54SDaniel Henrique Barbozafi
20359aae6e54SDaniel Henrique Barbozaif ! compile_prog ; then
20369aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
20379aae6e54SDaniel Henrique Barbozafi
20389aae6e54SDaniel Henrique Barboza
20399c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror
20409c83ffd8SPeter Maydell# by default.  Only enable by default for git builds
20419c83ffd8SPeter Maydellif test -z "$werror" ; then
20427d7dbf9dSDan Streetman    if test "$git_submodules_action" != "ignore" && \
2043e633a5c6SEric Blake        { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
20449c83ffd8SPeter Maydell        werror="yes"
20459c83ffd8SPeter Maydell    else
20469c83ffd8SPeter Maydell        werror="no"
20479c83ffd8SPeter Maydell    fi
20489c83ffd8SPeter Maydellfi
20499c83ffd8SPeter Maydell
2050975ff037SPaolo Bonziniif test "$targetos" = "bogus"; then
2051fb59dabdSPeter Maydell    # Now that we know that we're not printing the help and that
2052fb59dabdSPeter Maydell    # the compiler works (so the results of the check_defines we used
2053fb59dabdSPeter Maydell    # to identify the OS are reliable), if we didn't recognize the
2054fb59dabdSPeter Maydell    # host OS we should stop now.
2055951fedfcSPeter Maydell    error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
2056fb59dabdSPeter Maydellfi
2057fb59dabdSPeter Maydell
2058efc6c070SThomas Huth# Check whether the compiler matches our minimum requirements:
2059efc6c070SThomas Huthcat > $TMPC << EOF
2060efc6c070SThomas Huth#if defined(__clang_major__) && defined(__clang_minor__)
2061efc6c070SThomas Huth# ifdef __apple_build_version__
20622a85a08cSDaniel P. Berrangé#  if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0)
20632a85a08cSDaniel P. Berrangé#   error You need at least XCode Clang v10.0 to compile QEMU
2064efc6c070SThomas Huth#  endif
2065efc6c070SThomas Huth# else
20662a85a08cSDaniel P. Berrangé#  if __clang_major__ < 6 || (__clang_major__ == 6 && __clang_minor__ < 0)
20672a85a08cSDaniel P. Berrangé#   error You need at least Clang v6.0 to compile QEMU
2068efc6c070SThomas Huth#  endif
2069efc6c070SThomas Huth# endif
2070efc6c070SThomas Huth#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
207156208a0dSDaniel P. Berrangé# if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 5)
207256208a0dSDaniel P. Berrangé#  error You need at least GCC v7.5.0 to compile QEMU
2073efc6c070SThomas Huth# endif
2074efc6c070SThomas Huth#else
2075efc6c070SThomas Huth# error You either need GCC or Clang to compiler QEMU
2076efc6c070SThomas Huth#endif
2077efc6c070SThomas Huthint main (void) { return 0; }
2078efc6c070SThomas HuthEOF
2079efc6c070SThomas Huthif ! compile_prog "" "" ; then
20802a85a08cSDaniel P. Berrangé    error_exit "You need at least GCC v7.5 or Clang v6.0 (or XCode Clang v10.0)"
2081efc6c070SThomas Huthfi
2082efc6c070SThomas Huth
208300849b92SRichard Henderson# Accumulate -Wfoo and -Wno-bar separately.
208400849b92SRichard Henderson# We will list all of the enable flags first, and the disable flags second.
208500849b92SRichard Henderson# Note that we do not add -Werror, because that would enable it for all
208600849b92SRichard Henderson# configure tests. If a configure test failed due to -Werror this would
208700849b92SRichard Henderson# just silently disable some features, so it's too error prone.
208800849b92SRichard Henderson
208900849b92SRichard Hendersonwarn_flags=
209000849b92SRichard Hendersonadd_to warn_flags -Wold-style-declaration
209100849b92SRichard Hendersonadd_to warn_flags -Wold-style-definition
209200849b92SRichard Hendersonadd_to warn_flags -Wtype-limits
209300849b92SRichard Hendersonadd_to warn_flags -Wformat-security
209400849b92SRichard Hendersonadd_to warn_flags -Wformat-y2k
209500849b92SRichard Hendersonadd_to warn_flags -Winit-self
209600849b92SRichard Hendersonadd_to warn_flags -Wignored-qualifiers
209700849b92SRichard Hendersonadd_to warn_flags -Wempty-body
209800849b92SRichard Hendersonadd_to warn_flags -Wnested-externs
209900849b92SRichard Hendersonadd_to warn_flags -Wendif-labels
210000849b92SRichard Hendersonadd_to warn_flags -Wexpansion-to-defined
21010a2ebce9SThomas Huthadd_to warn_flags -Wimplicit-fallthrough=2
210200849b92SRichard Henderson
210300849b92SRichard Hendersonnowarn_flags=
210400849b92SRichard Hendersonadd_to nowarn_flags -Wno-initializer-overrides
210500849b92SRichard Hendersonadd_to nowarn_flags -Wno-missing-include-dirs
210600849b92SRichard Hendersonadd_to nowarn_flags -Wno-shift-negative-value
210700849b92SRichard Hendersonadd_to nowarn_flags -Wno-string-plus-int
210800849b92SRichard Hendersonadd_to nowarn_flags -Wno-typedef-redefinition
2109aabab967SRichard Hendersonadd_to nowarn_flags -Wno-tautological-type-limit-compare
2110bac8d222SRichard Hendersonadd_to nowarn_flags -Wno-psabi
211100849b92SRichard Henderson
211200849b92SRichard Hendersongcc_flags="$warn_flags $nowarn_flags"
211393b25869SJohn Snow
211493b25869SJohn Snowcc_has_warning_flag() {
211593b25869SJohn Snow    write_c_skeleton;
211693b25869SJohn Snow
2117a1d29d6cSPeter Maydell    # Use the positive sense of the flag when testing for -Wno-wombat
2118a1d29d6cSPeter Maydell    # support (gcc will happily accept the -Wno- form of unknown
2119a1d29d6cSPeter Maydell    # warning options).
212093b25869SJohn Snow    optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
212193b25869SJohn Snow    compile_prog "-Werror $optflag" ""
212293b25869SJohn Snow}
212393b25869SJohn Snow
212493b25869SJohn Snowfor flag in $gcc_flags; do
212593b25869SJohn Snow    if cc_has_warning_flag $flag ; then
21268d05095cSPaolo Bonzini        QEMU_CFLAGS="$QEMU_CFLAGS $flag"
21278d05095cSPaolo Bonzini    fi
21288d05095cSPaolo Bonzinidone
21298d05095cSPaolo Bonzini
213063678e17SSteven Noonanif test "$stack_protector" != "no"; then
2131fccd35a0SRodrigo Rebello  cat > $TMPC << EOF
2132fccd35a0SRodrigo Rebelloint main(int argc, char *argv[])
2133fccd35a0SRodrigo Rebello{
2134fccd35a0SRodrigo Rebello    char arr[64], *p = arr, *c = argv[0];
2135fccd35a0SRodrigo Rebello    while (*c) {
2136fccd35a0SRodrigo Rebello        *p++ = *c++;
2137fccd35a0SRodrigo Rebello    }
2138fccd35a0SRodrigo Rebello    return 0;
2139fccd35a0SRodrigo Rebello}
2140fccd35a0SRodrigo RebelloEOF
214163678e17SSteven Noonan  gcc_flags="-fstack-protector-strong -fstack-protector-all"
21423b463a3fSMiroslav Rezanina  sp_on=0
214363678e17SSteven Noonan  for flag in $gcc_flags; do
2144590e5dd9SPeter Maydell    # We need to check both a compile and a link, since some compiler
2145590e5dd9SPeter Maydell    # setups fail only on a .c->.o compile and some only at link time
2146086d5f75SPaolo Bonzini    if compile_object "-Werror $flag" &&
2147590e5dd9SPeter Maydell       compile_prog "-Werror $flag" ""; then
214863678e17SSteven Noonan      QEMU_CFLAGS="$QEMU_CFLAGS $flag"
2149db5adeaaSPaolo Bonzini      QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
21503b463a3fSMiroslav Rezanina      sp_on=1
215163678e17SSteven Noonan      break
215263678e17SSteven Noonan    fi
215363678e17SSteven Noonan  done
21543b463a3fSMiroslav Rezanina  if test "$stack_protector" = yes; then
21553b463a3fSMiroslav Rezanina    if test $sp_on = 0; then
21563b463a3fSMiroslav Rezanina      error_exit "Stack protector not supported"
21573b463a3fSMiroslav Rezanina    fi
21583b463a3fSMiroslav Rezanina  fi
215937746c5eSMarc-André Lureaufi
216037746c5eSMarc-André Lureau
216120bc94a2SPaolo Bonzini# Disable -Wmissing-braces on older compilers that warn even for
216220bc94a2SPaolo Bonzini# the "universal" C zero initializer {0}.
216320bc94a2SPaolo Bonzinicat > $TMPC << EOF
216420bc94a2SPaolo Bonzinistruct {
216520bc94a2SPaolo Bonzini  int a[2];
216620bc94a2SPaolo Bonzini} x = {0};
216720bc94a2SPaolo BonziniEOF
216820bc94a2SPaolo Bonziniif compile_object "-Werror" "" ; then
216920bc94a2SPaolo Bonzini  :
217020bc94a2SPaolo Bonzinielse
217120bc94a2SPaolo Bonzini  QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
217220bc94a2SPaolo Bonzinifi
217320bc94a2SPaolo Bonzini
217421e709aaSMarc-André Lureau# Our module code doesn't support Windows
217521e709aaSMarc-André Lureauif test "$modules" = "yes" && test "$mingw32" = "yes" ; then
217621e709aaSMarc-André Lureau  error_exit "Modules are not available for Windows"
217721e709aaSMarc-André Lureaufi
217821e709aaSMarc-André Lureau
2179bd83c861SChristian Ehrhardt# module_upgrades is only reasonable if modules are enabled
2180bd83c861SChristian Ehrhardtif test "$modules" = "no" && test "$module_upgrades" = "yes" ; then
2181bd83c861SChristian Ehrhardt  error_exit "Can't enable module-upgrades as Modules are not enabled"
2182bd83c861SChristian Ehrhardtfi
2183bd83c861SChristian Ehrhardt
2184d376e9deSThomas Huth# Static linking is not possible with modules or PIE
218540d6444eSAvi Kivityif test "$static" = "yes" ; then
2186aa0d1f44SPaolo Bonzini  if test "$modules" = "yes" ; then
2187aa0d1f44SPaolo Bonzini    error_exit "static and modules are mutually incompatible"
2188aa0d1f44SPaolo Bonzini  fi
218940d6444eSAvi Kivityfi
219040d6444eSAvi Kivity
2191768b7855SEmilio G. Cota# Unconditional check for compiler __thread support
2192768b7855SEmilio G. Cota  cat > $TMPC << EOF
2193768b7855SEmilio G. Cotastatic __thread int tls_var;
2194768b7855SEmilio G. Cotaint main(void) { return tls_var; }
2195768b7855SEmilio G. CotaEOF
2196768b7855SEmilio G. Cota
2197768b7855SEmilio G. Cotaif ! compile_prog "-Werror" "" ; then
2198768b7855SEmilio G. Cota    error_exit "Your compiler does not support the __thread specifier for " \
2199768b7855SEmilio G. Cota	"Thread-Local Storage (TLS). Please upgrade to a version that does."
2200768b7855SEmilio G. Cotafi
2201768b7855SEmilio G. Cota
220240d6444eSAvi Kivitycat > $TMPC << EOF
220321d4a791SAvi Kivity
220421d4a791SAvi Kivity#ifdef __linux__
220521d4a791SAvi Kivity#  define THREAD __thread
220621d4a791SAvi Kivity#else
220721d4a791SAvi Kivity#  define THREAD
220821d4a791SAvi Kivity#endif
220921d4a791SAvi Kivitystatic THREAD int tls_var;
221021d4a791SAvi Kivityint main(void) { return tls_var; }
221140d6444eSAvi KivityEOF
2212b2634124SRichard Henderson
2213b2634124SRichard Henderson# Check we support --no-pie first; we will need this for building ROMs.
2214412aeacdSAlex Bennéeif compile_prog "-Werror -fno-pie" "-no-pie"; then
2215412aeacdSAlex Bennée  CFLAGS_NOPIE="-fno-pie"
2216412aeacdSAlex Bennéefi
2217412aeacdSAlex Bennée
221812781462SRichard Hendersonif test "$static" = "yes"; then
2219eca7a8e6SRichard Henderson  if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then
22205770e8afSPaolo Bonzini    CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
222112781462SRichard Henderson    QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS"
222212781462SRichard Henderson    pie="yes"
222312781462SRichard Henderson  elif test "$pie" = "yes"; then
222412781462SRichard Henderson    error_exit "-static-pie not available due to missing toolchain support"
222512781462SRichard Henderson  else
222612781462SRichard Henderson    QEMU_LDFLAGS="-static $QEMU_LDFLAGS"
222712781462SRichard Henderson    pie="no"
222812781462SRichard Henderson  fi
222912781462SRichard Hendersonelif test "$pie" = "no"; then
22305770e8afSPaolo Bonzini  CONFIGURE_CFLAGS="$CFLAGS_NOPIE $CONFIGURE_CFLAGS"
2231eca7a8e6SRichard Hendersonelif compile_prog "-Werror -fPIE -DPIE" "-pie"; then
22325770e8afSPaolo Bonzini  CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
22335770e8afSPaolo Bonzini  CONFIGURE_LDFLAGS="-pie $CONFIGURE_LDFLAGS"
223440d6444eSAvi Kivity  pie="yes"
22352c674109SRichard Hendersonelif test "$pie" = "yes"; then
223676ad07a4SPeter Maydell  error_exit "PIE not available due to missing toolchain support"
223740d6444eSAvi Kivityelse
223840d6444eSAvi Kivity  echo "Disabling PIE due to missing toolchain support"
223940d6444eSAvi Kivity  pie="no"
224040d6444eSAvi Kivityfi
224140d6444eSAvi Kivity
2242e6cbd751SRichard Henderson# Detect support for PT_GNU_RELRO + DT_BIND_NOW.
2243e6cbd751SRichard Henderson# The combination is known as "full relro", because .got.plt is read-only too.
2244e6cbd751SRichard Hendersonif compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
2245e6cbd751SRichard Henderson  QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS"
2246e6cbd751SRichard Hendersonfi
2247e6cbd751SRichard Henderson
224809dada40SPaolo Bonzini##########################################
224909dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains
225009dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit
225109dada40SPaolo Bonzini# specification is necessary
225209dada40SPaolo Bonzini
225309dada40SPaolo Bonziniif test "$cpu" = "i386"; then
225409dada40SPaolo Bonzini  cat > $TMPC << EOF
225509dada40SPaolo Bonzinistatic int sfaa(int *ptr)
225609dada40SPaolo Bonzini{
225709dada40SPaolo Bonzini  return __sync_fetch_and_and(ptr, 0);
225809dada40SPaolo Bonzini}
225909dada40SPaolo Bonzini
226009dada40SPaolo Bonziniint main(void)
226109dada40SPaolo Bonzini{
226209dada40SPaolo Bonzini  int val = 42;
22631405b629SStefan Weil  val = __sync_val_compare_and_swap(&val, 0, 1);
226409dada40SPaolo Bonzini  sfaa(&val);
226509dada40SPaolo Bonzini  return val;
226609dada40SPaolo Bonzini}
226709dada40SPaolo BonziniEOF
226809dada40SPaolo Bonzini  if ! compile_prog "" "" ; then
226909dada40SPaolo Bonzini    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
227009dada40SPaolo Bonzini  fi
227109dada40SPaolo Bonzinifi
227209dada40SPaolo Bonzini
227309dada40SPaolo Bonzini#########################################
2274ec530c81Sbellard# Solaris specific configure tool chain decisions
227509dada40SPaolo Bonzini
2276ec530c81Sbellardif test "$solaris" = "yes" ; then
22776792aa11SLoïc Minier  if has ar; then
22786792aa11SLoïc Minier    :
22796792aa11SLoïc Minier  else
2280ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
228176ad07a4SPeter Maydell      error_exit "No path includes ar" \
228276ad07a4SPeter Maydell          "Add /usr/ccs/bin to your path and rerun configure"
2283ec530c81Sbellard    fi
228476ad07a4SPeter Maydell    error_exit "No path includes ar"
2285ec530c81Sbellard  fi
2286ec530c81Sbellardfi
2287ec530c81Sbellard
228856267b62SPhilippe Mathieu-Daudéif test "$tcg" = "enabled"; then
228956267b62SPhilippe Mathieu-Daudé    git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
229056267b62SPhilippe Mathieu-Daudé    git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
229156267b62SPhilippe Mathieu-Daudéfi
229256267b62SPhilippe Mathieu-Daudé
2293afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then
2294fdb75aefSPaolo Bonzini    default_targets=yes
2295d880a3baSPaolo Bonzini    for target in $default_target_list; do
2296d880a3baSPaolo Bonzini        target_list="$target_list $target"
2297d880a3baSPaolo Bonzini    done
2298d880a3baSPaolo Bonzini    target_list="${target_list# }"
2299121afa9eSAnthony Liguorielse
2300fdb75aefSPaolo Bonzini    default_targets=no
230189138857SStefan Weil    target_list=$(echo "$target_list" | sed -e 's/,/ /g')
2302d880a3baSPaolo Bonzini    for target in $target_list; do
230325b48338SPeter Maydell        # Check that we recognised the target name; this allows a more
230425b48338SPeter Maydell        # friendly error message than if we let it fall through.
230525b48338SPeter Maydell        case " $default_target_list " in
230625b48338SPeter Maydell            *" $target "*)
230725b48338SPeter Maydell                ;;
230825b48338SPeter Maydell            *)
230925b48338SPeter Maydell                error_exit "Unknown target name '$target'"
231025b48338SPeter Maydell                ;;
231125b48338SPeter Maydell        esac
231225b48338SPeter Maydell    done
2313d880a3baSPaolo Bonzinifi
231425b48338SPeter Maydell
2315fdb75aefSPaolo Bonzinifor target in $target_list; do
2316fdb75aefSPaolo Bonzini    # if a deprecated target is enabled we note it here
2317fdb75aefSPaolo Bonzini    if echo "$deprecated_targets_list" | grep -q "$target"; then
2318fdb75aefSPaolo Bonzini        add_to deprecated_features $target
2319fdb75aefSPaolo Bonzini    fi
2320fdb75aefSPaolo Bonzinidone
2321fdb75aefSPaolo Bonzini
2322f55fe278SPaolo Bonzini# see if system emulation was really requested
2323f55fe278SPaolo Bonzinicase " $target_list " in
2324f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
2325f55fe278SPaolo Bonzini  ;;
2326f55fe278SPaolo Bonzini  *) softmmu=no
2327f55fe278SPaolo Bonzini  ;;
2328f55fe278SPaolo Bonziniesac
23295327cf48Sbellard
2330249247c9SJuan Quintelafeature_not_found() {
2331249247c9SJuan Quintela  feature=$1
233221684af0SStewart Smith  remedy=$2
2333249247c9SJuan Quintela
233476ad07a4SPeter Maydell  error_exit "User requested feature $feature" \
233521684af0SStewart Smith      "configure was not able to find it." \
233621684af0SStewart Smith      "$remedy"
2337249247c9SJuan Quintela}
2338249247c9SJuan Quintela
23397d13299dSbellard# ---
23407d13299dSbellard# big/little endian test
23417d13299dSbellardcat > $TMPC << EOF
234261cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
234361cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
234461cc919fSMike Frysingerextern int foo(short *, short *);
234561cc919fSMike Frysingerint main(int argc, char *argv[]) {
234661cc919fSMike Frysinger    return foo(big_endian, little_endian);
23477d13299dSbellard}
23487d13299dSbellardEOF
23497d13299dSbellard
235061cc919fSMike Frysingerif compile_object ; then
235112f15c91SAlice Frosi    if strings -a $TMPO | grep -q BiGeNdIaN ; then
235261cc919fSMike Frysinger        bigendian="yes"
235312f15c91SAlice Frosi    elif strings -a $TMPO | grep -q LiTtLeEnDiAn ; then
235461cc919fSMike Frysinger        bigendian="no"
23557d13299dSbellard    else
23567d13299dSbellard        echo big/little test failed
23577d13299dSbellard    fi
23587d13299dSbellardelse
235961cc919fSMike Frysinger    echo big/little test failed
23607d13299dSbellardfi
23617d13299dSbellard
2362b0a47e79SJuan Quintela##########################################
2363e10ee3f5SPhilippe Mathieu-Daudé# system tools
2364e10ee3f5SPhilippe Mathieu-Daudéif test -z "$want_tools"; then
2365e10ee3f5SPhilippe Mathieu-Daudé    if test "$softmmu" = "no"; then
2366e10ee3f5SPhilippe Mathieu-Daudé        want_tools=no
2367e10ee3f5SPhilippe Mathieu-Daudé    else
2368e10ee3f5SPhilippe Mathieu-Daudé        want_tools=yes
2369e10ee3f5SPhilippe Mathieu-Daudé    fi
2370e10ee3f5SPhilippe Mathieu-Daudéfi
2371e10ee3f5SPhilippe Mathieu-Daudé
2372e10ee3f5SPhilippe Mathieu-Daudé##########################################
237390520ee4SPhilippe Mathieu-Daudé# Disable features only meaningful for system-mode emulation
237490520ee4SPhilippe Mathieu-Daudéif test "$softmmu" = "no"; then
237590520ee4SPhilippe Mathieu-Daudé    audio_drv_list=""
237690520ee4SPhilippe Mathieu-Daudéfi
237790520ee4SPhilippe Mathieu-Daudé
237890520ee4SPhilippe Mathieu-Daudé##########################################
23796b39b063SEric Blake# Some versions of Mac OS X incorrectly define SIZE_MAX
23806b39b063SEric Blakecat > $TMPC << EOF
23816b39b063SEric Blake#include <stdint.h>
23826b39b063SEric Blake#include <stdio.h>
23836b39b063SEric Blakeint main(int argc, char *argv[]) {
23846b39b063SEric Blake    return printf("%zu", SIZE_MAX);
23856b39b063SEric Blake}
23866b39b063SEric BlakeEOF
23876b39b063SEric Blakehave_broken_size_max=no
23886b39b063SEric Blakeif ! compile_object -Werror ; then
23896b39b063SEric Blake    have_broken_size_max=yes
23906b39b063SEric Blakefi
23916b39b063SEric Blake
2392a30878e7SPeter Maydell##########################################
2393015a33bdSGonglei# L2TPV3 probe
2394015a33bdSGonglei
2395015a33bdSGongleicat > $TMPC <<EOF
2396015a33bdSGonglei#include <sys/socket.h>
2397bff6cb72SMichael Tokarev#include <linux/ip.h>
2398015a33bdSGongleiint main(void) { return sizeof(struct mmsghdr); }
2399015a33bdSGongleiEOF
2400015a33bdSGongleiif compile_prog "" "" ; then
2401015a33bdSGonglei  l2tpv3=yes
2402015a33bdSGongleielse
2403015a33bdSGonglei  l2tpv3=no
2404015a33bdSGongleifi
2405015a33bdSGonglei
2406195588ccSDavid CARLIERcat > $TMPC <<EOF
2407195588ccSDavid CARLIER#include <sys/mman.h>
2408195588ccSDavid CARLIERint main(int argc, char *argv[]) {
2409195588ccSDavid CARLIER    return mlockall(MCL_FUTURE);
2410195588ccSDavid CARLIER}
2411195588ccSDavid CARLIEREOF
2412195588ccSDavid CARLIERif compile_prog "" "" ; then
2413195588ccSDavid CARLIER  have_mlockall=yes
2414195588ccSDavid CARLIERelse
2415195588ccSDavid CARLIER  have_mlockall=no
2416195588ccSDavid CARLIERfi
2417195588ccSDavid CARLIER
2418299e6f19SPaolo Bonzini#########################################
2419299e6f19SPaolo Bonzini# vhost interdependencies and host support
2420299e6f19SPaolo Bonzini
2421299e6f19SPaolo Bonzini# vhost backends
2422d88618f7SStefan Hajnocziif test "$vhost_user" = "yes" && test "$linux" != "yes"; then
2423d88618f7SStefan Hajnoczi  error_exit "vhost-user is only available on Linux"
2424299e6f19SPaolo Bonzinifi
2425108a6481SCindy Lutest "$vhost_vdpa" = "" && vhost_vdpa=$linux
2426108a6481SCindy Luif test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then
2427108a6481SCindy Lu  error_exit "vhost-vdpa is only available on Linux"
2428108a6481SCindy Lufi
2429299e6f19SPaolo Bonzinitest "$vhost_kernel" = "" && vhost_kernel=$linux
2430299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then
2431299e6f19SPaolo Bonzini  error_exit "vhost-kernel is only available on Linux"
2432299e6f19SPaolo Bonzinifi
2433299e6f19SPaolo Bonzini
2434299e6f19SPaolo Bonzini# vhost-kernel devices
2435299e6f19SPaolo Bonzinitest "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel
2436299e6f19SPaolo Bonziniif test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then
2437299e6f19SPaolo Bonzini  error_exit "--enable-vhost-scsi requires --enable-vhost-kernel"
2438299e6f19SPaolo Bonzinifi
2439299e6f19SPaolo Bonzinitest "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel
2440299e6f19SPaolo Bonziniif test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then
2441299e6f19SPaolo Bonzini  error_exit "--enable-vhost-vsock requires --enable-vhost-kernel"
2442299e6f19SPaolo Bonzinifi
2443299e6f19SPaolo Bonzini
2444299e6f19SPaolo Bonzini# vhost-user backends
2445299e6f19SPaolo Bonzinitest "$vhost_net_user" = "" && vhost_net_user=$vhost_user
2446299e6f19SPaolo Bonziniif test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then
2447299e6f19SPaolo Bonzini  error_exit "--enable-vhost-net-user requires --enable-vhost-user"
2448299e6f19SPaolo Bonzinifi
2449299e6f19SPaolo Bonzinitest "$vhost_crypto" = "" && vhost_crypto=$vhost_user
2450299e6f19SPaolo Bonziniif test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then
2451299e6f19SPaolo Bonzini  error_exit "--enable-vhost-crypto requires --enable-vhost-user"
2452299e6f19SPaolo Bonzinifi
245398fc1adaSDr. David Alan Gilberttest "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user
245498fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then
245598fc1adaSDr. David Alan Gilbert  error_exit "--enable-vhost-user-fs requires --enable-vhost-user"
245698fc1adaSDr. David Alan Gilbertfi
2457108a6481SCindy Lu#vhost-vdpa backends
2458108a6481SCindy Lutest "$vhost_net_vdpa" = "" && vhost_net_vdpa=$vhost_vdpa
2459108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" && test "$vhost_vdpa" = "no"; then
2460108a6481SCindy Lu  error_exit "--enable-vhost-net-vdpa requires --enable-vhost-vdpa"
2461108a6481SCindy Lufi
2462299e6f19SPaolo Bonzini
246340bc0ca9SLaurent Vivier# OR the vhost-kernel, vhost-vdpa and vhost-user values for simplicity
2464299e6f19SPaolo Bonziniif test "$vhost_net" = ""; then
2465299e6f19SPaolo Bonzini  test "$vhost_net_user" = "yes" && vhost_net=yes
246640bc0ca9SLaurent Vivier  test "$vhost_net_vdpa" = "yes" && vhost_net=yes
2467299e6f19SPaolo Bonzini  test "$vhost_kernel" = "yes" && vhost_net=yes
2468299e6f19SPaolo Bonzinifi
2469299e6f19SPaolo Bonzini
2470015a33bdSGonglei##########################################
2471779ab5e3SStefan Weil# pkg-config probe
2472779ab5e3SStefan Weil
2473779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then
247476ad07a4SPeter Maydell  error_exit "pkg-config binary '$pkg_config_exe' not found"
2475779ab5e3SStefan Weilfi
2476779ab5e3SStefan Weil
2477779ab5e3SStefan Weil##########################################
2478b0a47e79SJuan Quintela# NPTL probe
2479b0a47e79SJuan Quintela
248024cb36a6SPeter Maydellif test "$linux_user" = "yes"; then
2481bd0c5661Spbrook  cat > $TMPC <<EOF
2482bd0c5661Spbrook#include <sched.h>
248330813ceaSpbrook#include <linux/futex.h>
2484182eacc0SStefan Weilint main(void) {
2485bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
2486bd0c5661Spbrook#error bork
2487bd0c5661Spbrook#endif
2488182eacc0SStefan Weil  return 0;
2489bd0c5661Spbrook}
2490bd0c5661SpbrookEOF
249124cb36a6SPeter Maydell  if ! compile_object ; then
249221684af0SStewart Smith    feature_not_found "nptl" "Install glibc and linux kernel headers."
2493b0a47e79SJuan Quintela  fi
2494bd0c5661Spbrookfi
2495bd0c5661Spbrook
2496ac62922eSbalrog##########################################
2497e37630caSaliguori# xen probe
2498e37630caSaliguori
24991badb709SPaolo Bonziniif test "$xen" != "disabled" ; then
2500c1cdd9d5SJuergen Gross  # Check whether Xen library path is specified via --extra-ldflags to avoid
2501c1cdd9d5SJuergen Gross  # overriding this setting with pkg-config output. If not, try pkg-config
2502c1cdd9d5SJuergen Gross  # to obtain all needed flags.
2503c1cdd9d5SJuergen Gross
2504c1cdd9d5SJuergen Gross  if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2505c1cdd9d5SJuergen Gross     $pkg_config --exists xencontrol ; then
2506c1cdd9d5SJuergen Gross    xen_ctrl_version="$(printf '%d%02d%02d' \
2507c1cdd9d5SJuergen Gross      $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
25081badb709SPaolo Bonzini    xen=enabled
25095b6a8f43SMichael Tokarev    xen_pc="xencontrol xenstore xenforeignmemory xengnttab"
2510c1cdd9d5SJuergen Gross    xen_pc="$xen_pc xenevtchn xendevicemodel"
251158ea9a7aSAnthony PERARD    if $pkg_config --exists xentoolcore; then
251258ea9a7aSAnthony PERARD      xen_pc="$xen_pc xentoolcore"
251358ea9a7aSAnthony PERARD    fi
2514582ea95fSMarc-André Lureau    xen_cflags="$($pkg_config --cflags $xen_pc)"
2515582ea95fSMarc-André Lureau    xen_libs="$($pkg_config --libs $xen_pc)"
2516c1cdd9d5SJuergen Gross  else
2517c1cdd9d5SJuergen Gross
25185b6a8f43SMichael Tokarev    xen_libs="-lxenstore -lxenctrl"
2519d9506cabSAnthony PERARD    xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
2520d5b93ddfSAnthony PERARD
252150ced5b3SStefan Weil    # First we test whether Xen headers and libraries are available.
252250ced5b3SStefan Weil    # If no, we are done and there is no Xen support.
252350ced5b3SStefan Weil    # If yes, more tests are run to detect the Xen version.
252450ced5b3SStefan Weil
252550ced5b3SStefan Weil    # Xen (any)
252650ced5b3SStefan Weil    cat > $TMPC <<EOF
252750ced5b3SStefan Weil#include <xenctrl.h>
252850ced5b3SStefan Weilint main(void) {
252950ced5b3SStefan Weil  return 0;
253050ced5b3SStefan Weil}
253150ced5b3SStefan WeilEOF
253250ced5b3SStefan Weil    if ! compile_prog "" "$xen_libs" ; then
253350ced5b3SStefan Weil      # Xen not found
25341badb709SPaolo Bonzini      if test "$xen" = "enabled" ; then
253521684af0SStewart Smith        feature_not_found "xen" "Install xen devel"
253650ced5b3SStefan Weil      fi
25371badb709SPaolo Bonzini      xen=disabled
253850ced5b3SStefan Weil
2539d5b93ddfSAnthony PERARD    # Xen unstable
254069deef08SPeter Maydell    elif
254169deef08SPeter Maydell        cat > $TMPC <<EOF &&
25422cbf8903SRoss Lagerwall#undef XC_WANT_COMPAT_DEVICEMODEL_API
25432cbf8903SRoss Lagerwall#define __XEN_TOOLS__
25442cbf8903SRoss Lagerwall#include <xendevicemodel.h>
2545d3c49ebbSPaul Durrant#include <xenforeignmemory.h>
25462cbf8903SRoss Lagerwallint main(void) {
25472cbf8903SRoss Lagerwall  xendevicemodel_handle *xd;
2548d3c49ebbSPaul Durrant  xenforeignmemory_handle *xfmem;
25492cbf8903SRoss Lagerwall
25502cbf8903SRoss Lagerwall  xd = xendevicemodel_open(0, 0);
25512cbf8903SRoss Lagerwall  xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
25522cbf8903SRoss Lagerwall
2553d3c49ebbSPaul Durrant  xfmem = xenforeignmemory_open(0, 0);
2554d3c49ebbSPaul Durrant  xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
2555d3c49ebbSPaul Durrant
25562cbf8903SRoss Lagerwall  return 0;
25572cbf8903SRoss Lagerwall}
25582cbf8903SRoss LagerwallEOF
25592cbf8903SRoss Lagerwall        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
25602cbf8903SRoss Lagerwall      then
25612cbf8903SRoss Lagerwall      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
25622cbf8903SRoss Lagerwall      xen_ctrl_version=41100
25631badb709SPaolo Bonzini      xen=enabled
25642cbf8903SRoss Lagerwall    elif
25652cbf8903SRoss Lagerwall        cat > $TMPC <<EOF &&
25665ba3d756SIgor Druzhinin#undef XC_WANT_COMPAT_MAP_FOREIGN_API
25675ba3d756SIgor Druzhinin#include <xenforeignmemory.h>
256858ea9a7aSAnthony PERARD#include <xentoolcore.h>
25695ba3d756SIgor Druzhininint main(void) {
25705ba3d756SIgor Druzhinin  xenforeignmemory_handle *xfmem;
25715ba3d756SIgor Druzhinin
25725ba3d756SIgor Druzhinin  xfmem = xenforeignmemory_open(0, 0);
25735ba3d756SIgor Druzhinin  xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
257458ea9a7aSAnthony PERARD  xentoolcore_restrict_all(0);
25755ba3d756SIgor Druzhinin
25765ba3d756SIgor Druzhinin  return 0;
25775ba3d756SIgor Druzhinin}
25785ba3d756SIgor DruzhininEOF
257958ea9a7aSAnthony PERARD        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
25805ba3d756SIgor Druzhinin      then
258158ea9a7aSAnthony PERARD      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
25825ba3d756SIgor Druzhinin      xen_ctrl_version=41000
25831badb709SPaolo Bonzini      xen=enabled
25845ba3d756SIgor Druzhinin    elif
25855ba3d756SIgor Druzhinin        cat > $TMPC <<EOF &&
2586da8090ccSPaul Durrant#undef XC_WANT_COMPAT_DEVICEMODEL_API
2587da8090ccSPaul Durrant#define __XEN_TOOLS__
2588da8090ccSPaul Durrant#include <xendevicemodel.h>
2589da8090ccSPaul Durrantint main(void) {
2590da8090ccSPaul Durrant  xendevicemodel_handle *xd;
2591da8090ccSPaul Durrant
2592da8090ccSPaul Durrant  xd = xendevicemodel_open(0, 0);
2593da8090ccSPaul Durrant  xendevicemodel_close(xd);
2594da8090ccSPaul Durrant
2595da8090ccSPaul Durrant  return 0;
2596da8090ccSPaul Durrant}
2597da8090ccSPaul DurrantEOF
2598da8090ccSPaul Durrant        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2599da8090ccSPaul Durrant      then
2600da8090ccSPaul Durrant      xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2601f1167ee6SJuergen Gross      xen_ctrl_version=40900
26021badb709SPaolo Bonzini      xen=enabled
2603da8090ccSPaul Durrant    elif
2604da8090ccSPaul Durrant        cat > $TMPC <<EOF &&
26055eeb39c2SIan Campbell/*
26065eeb39c2SIan Campbell * If we have stable libs the we don't want the libxc compat
26075eeb39c2SIan Campbell * layers, regardless of what CFLAGS we may have been given.
2608b6eb9b45SPaulina Szubarczyk *
2609b6eb9b45SPaulina Szubarczyk * Also, check if xengnttab_grant_copy_segment_t is defined and
2610b6eb9b45SPaulina Szubarczyk * grant copy operation is implemented.
2611b6eb9b45SPaulina Szubarczyk */
2612b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_EVTCHN_API
2613b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_GNTTAB_API
2614b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2615b6eb9b45SPaulina Szubarczyk#include <xenctrl.h>
2616b6eb9b45SPaulina Szubarczyk#include <xenstore.h>
2617b6eb9b45SPaulina Szubarczyk#include <xenevtchn.h>
2618b6eb9b45SPaulina Szubarczyk#include <xengnttab.h>
2619b6eb9b45SPaulina Szubarczyk#include <xenforeignmemory.h>
2620b6eb9b45SPaulina Szubarczyk#include <stdint.h>
2621b6eb9b45SPaulina Szubarczyk#include <xen/hvm/hvm_info_table.h>
2622b6eb9b45SPaulina Szubarczyk#if !defined(HVM_MAX_VCPUS)
2623b6eb9b45SPaulina Szubarczyk# error HVM_MAX_VCPUS not defined
2624b6eb9b45SPaulina Szubarczyk#endif
2625b6eb9b45SPaulina Szubarczykint main(void) {
2626b6eb9b45SPaulina Szubarczyk  xc_interface *xc = NULL;
2627b6eb9b45SPaulina Szubarczyk  xenforeignmemory_handle *xfmem;
2628b6eb9b45SPaulina Szubarczyk  xenevtchn_handle *xe;
2629b6eb9b45SPaulina Szubarczyk  xengnttab_handle *xg;
2630b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy_segment_t* seg = NULL;
2631b6eb9b45SPaulina Szubarczyk
2632b6eb9b45SPaulina Szubarczyk  xs_daemon_open();
2633b6eb9b45SPaulina Szubarczyk
2634b6eb9b45SPaulina Szubarczyk  xc = xc_interface_open(0, 0, 0);
2635b6eb9b45SPaulina Szubarczyk  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2636b6eb9b45SPaulina Szubarczyk  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2637b6eb9b45SPaulina Szubarczyk  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2638b6eb9b45SPaulina Szubarczyk  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2639b6eb9b45SPaulina Szubarczyk
2640b6eb9b45SPaulina Szubarczyk  xfmem = xenforeignmemory_open(0, 0);
2641b6eb9b45SPaulina Szubarczyk  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2642b6eb9b45SPaulina Szubarczyk
2643b6eb9b45SPaulina Szubarczyk  xe = xenevtchn_open(0, 0);
2644b6eb9b45SPaulina Szubarczyk  xenevtchn_fd(xe);
2645b6eb9b45SPaulina Szubarczyk
2646b6eb9b45SPaulina Szubarczyk  xg = xengnttab_open(0, 0);
2647b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy(xg, 0, seg);
2648b6eb9b45SPaulina Szubarczyk
2649b6eb9b45SPaulina Szubarczyk  return 0;
2650b6eb9b45SPaulina Szubarczyk}
2651b6eb9b45SPaulina SzubarczykEOF
2652b6eb9b45SPaulina Szubarczyk        compile_prog "" "$xen_libs $xen_stable_libs"
2653b6eb9b45SPaulina Szubarczyk      then
2654f1167ee6SJuergen Gross      xen_ctrl_version=40800
26551badb709SPaolo Bonzini      xen=enabled
2656b6eb9b45SPaulina Szubarczyk    elif
2657b6eb9b45SPaulina Szubarczyk        cat > $TMPC <<EOF &&
2658b6eb9b45SPaulina Szubarczyk/*
2659b6eb9b45SPaulina Szubarczyk * If we have stable libs the we don't want the libxc compat
2660b6eb9b45SPaulina Szubarczyk * layers, regardless of what CFLAGS we may have been given.
26615eeb39c2SIan Campbell */
26625eeb39c2SIan Campbell#undef XC_WANT_COMPAT_EVTCHN_API
26635eeb39c2SIan Campbell#undef XC_WANT_COMPAT_GNTTAB_API
26645eeb39c2SIan Campbell#undef XC_WANT_COMPAT_MAP_FOREIGN_API
26655eeb39c2SIan Campbell#include <xenctrl.h>
26665eeb39c2SIan Campbell#include <xenstore.h>
26675eeb39c2SIan Campbell#include <xenevtchn.h>
26685eeb39c2SIan Campbell#include <xengnttab.h>
26695eeb39c2SIan Campbell#include <xenforeignmemory.h>
26705eeb39c2SIan Campbell#include <stdint.h>
26715eeb39c2SIan Campbell#include <xen/hvm/hvm_info_table.h>
26725eeb39c2SIan Campbell#if !defined(HVM_MAX_VCPUS)
26735eeb39c2SIan Campbell# error HVM_MAX_VCPUS not defined
26745eeb39c2SIan Campbell#endif
26755eeb39c2SIan Campbellint main(void) {
26765eeb39c2SIan Campbell  xc_interface *xc = NULL;
26775eeb39c2SIan Campbell  xenforeignmemory_handle *xfmem;
26785eeb39c2SIan Campbell  xenevtchn_handle *xe;
26795eeb39c2SIan Campbell  xengnttab_handle *xg;
26805eeb39c2SIan Campbell
26815eeb39c2SIan Campbell  xs_daemon_open();
26825eeb39c2SIan Campbell
26835eeb39c2SIan Campbell  xc = xc_interface_open(0, 0, 0);
26845eeb39c2SIan Campbell  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
26855eeb39c2SIan Campbell  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
26865eeb39c2SIan Campbell  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
26875eeb39c2SIan Campbell  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
26885eeb39c2SIan Campbell
26895eeb39c2SIan Campbell  xfmem = xenforeignmemory_open(0, 0);
26905eeb39c2SIan Campbell  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
26915eeb39c2SIan Campbell
26925eeb39c2SIan Campbell  xe = xenevtchn_open(0, 0);
26935eeb39c2SIan Campbell  xenevtchn_fd(xe);
26945eeb39c2SIan Campbell
26955eeb39c2SIan Campbell  xg = xengnttab_open(0, 0);
26965eeb39c2SIan Campbell  xengnttab_map_grant_ref(xg, 0, 0, 0);
26975eeb39c2SIan Campbell
26985eeb39c2SIan Campbell  return 0;
26995eeb39c2SIan Campbell}
27005eeb39c2SIan CampbellEOF
27015eeb39c2SIan Campbell        compile_prog "" "$xen_libs $xen_stable_libs"
27025eeb39c2SIan Campbell      then
2703f1167ee6SJuergen Gross      xen_ctrl_version=40701
27041badb709SPaolo Bonzini      xen=enabled
2705cdadde39SRoger Pau Monne
2706cdadde39SRoger Pau Monne    # Xen 4.6
2707cdadde39SRoger Pau Monne    elif
2708cdadde39SRoger Pau Monne        cat > $TMPC <<EOF &&
2709cdadde39SRoger Pau Monne#include <xenctrl.h>
2710e108a3c1SAnthony PERARD#include <xenstore.h>
2711d5b93ddfSAnthony PERARD#include <stdint.h>
2712d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
2713d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
2714d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
2715d5b93ddfSAnthony PERARD#endif
2716d5b93ddfSAnthony PERARDint main(void) {
2717d5b93ddfSAnthony PERARD  xc_interface *xc;
2718d5b93ddfSAnthony PERARD  xs_daemon_open();
2719d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
2720d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2721d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
2722b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
27238688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2724d8b441a3SJan Beulich  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
272520a544c7SKonrad Rzeszutek Wilk  xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2726d8b441a3SJan Beulich  return 0;
2727d8b441a3SJan Beulich}
2728d8b441a3SJan BeulichEOF
2729d8b441a3SJan Beulich        compile_prog "" "$xen_libs"
2730d8b441a3SJan Beulich      then
2731f1167ee6SJuergen Gross      xen_ctrl_version=40600
27321badb709SPaolo Bonzini      xen=enabled
2733d8b441a3SJan Beulich
2734d8b441a3SJan Beulich    # Xen 4.5
2735d8b441a3SJan Beulich    elif
2736d8b441a3SJan Beulich        cat > $TMPC <<EOF &&
2737d8b441a3SJan Beulich#include <xenctrl.h>
2738d8b441a3SJan Beulich#include <xenstore.h>
2739d8b441a3SJan Beulich#include <stdint.h>
2740d8b441a3SJan Beulich#include <xen/hvm/hvm_info_table.h>
2741d8b441a3SJan Beulich#if !defined(HVM_MAX_VCPUS)
2742d8b441a3SJan Beulich# error HVM_MAX_VCPUS not defined
2743d8b441a3SJan Beulich#endif
2744d8b441a3SJan Beulichint main(void) {
2745d8b441a3SJan Beulich  xc_interface *xc;
2746d8b441a3SJan Beulich  xs_daemon_open();
2747d8b441a3SJan Beulich  xc = xc_interface_open(0, 0, 0);
2748d8b441a3SJan Beulich  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2749d8b441a3SJan Beulich  xc_gnttab_open(NULL, 0);
2750d8b441a3SJan Beulich  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2751d8b441a3SJan Beulich  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
27523996e85cSPaul Durrant  xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
27533996e85cSPaul Durrant  return 0;
27543996e85cSPaul Durrant}
27553996e85cSPaul DurrantEOF
27563996e85cSPaul Durrant        compile_prog "" "$xen_libs"
27573996e85cSPaul Durrant      then
2758f1167ee6SJuergen Gross      xen_ctrl_version=40500
27591badb709SPaolo Bonzini      xen=enabled
27603996e85cSPaul Durrant
27613996e85cSPaul Durrant    elif
27623996e85cSPaul Durrant        cat > $TMPC <<EOF &&
27633996e85cSPaul Durrant#include <xenctrl.h>
27643996e85cSPaul Durrant#include <xenstore.h>
27653996e85cSPaul Durrant#include <stdint.h>
27663996e85cSPaul Durrant#include <xen/hvm/hvm_info_table.h>
27673996e85cSPaul Durrant#if !defined(HVM_MAX_VCPUS)
27683996e85cSPaul Durrant# error HVM_MAX_VCPUS not defined
27693996e85cSPaul Durrant#endif
27703996e85cSPaul Durrantint main(void) {
27713996e85cSPaul Durrant  xc_interface *xc;
27723996e85cSPaul Durrant  xs_daemon_open();
27733996e85cSPaul Durrant  xc = xc_interface_open(0, 0, 0);
27743996e85cSPaul Durrant  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
27753996e85cSPaul Durrant  xc_gnttab_open(NULL, 0);
27763996e85cSPaul Durrant  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
27773996e85cSPaul Durrant  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
27788688e065SStefano Stabellini  return 0;
27798688e065SStefano Stabellini}
27808688e065SStefano StabelliniEOF
27818688e065SStefano Stabellini        compile_prog "" "$xen_libs"
278269deef08SPeter Maydell      then
2783f1167ee6SJuergen Gross      xen_ctrl_version=40200
27841badb709SPaolo Bonzini      xen=enabled
27858688e065SStefano Stabellini
2786e37630caSaliguori    else
27871badb709SPaolo Bonzini      if test "$xen" = "enabled" ; then
2788edfb07edSIan Campbell        feature_not_found "xen (unsupported version)" \
2789edfb07edSIan Campbell                          "Install a supported xen (xen 4.2 or newer)"
2790fc321b4bSJuan Quintela      fi
27911badb709SPaolo Bonzini      xen=disabled
2792e37630caSaliguori    fi
2793d5b93ddfSAnthony PERARD
27941badb709SPaolo Bonzini    if test "$xen" = enabled; then
2795f1167ee6SJuergen Gross      if test $xen_ctrl_version -ge 40701  ; then
2796582ea95fSMarc-André Lureau        xen_libs="$xen_libs $xen_stable_libs "
27975eeb39c2SIan Campbell      fi
2798d5b93ddfSAnthony PERARD    fi
2799e37630caSaliguori  fi
2800c1cdd9d5SJuergen Grossfi
2801e37630caSaliguori
2802d661d9a4SJustin Terry (VM)##########################################
28032da776dbSMichael R. Hines# RDMA needs OpenFabrics libraries
28042da776dbSMichael R. Hinesif test "$rdma" != "no" ; then
28052da776dbSMichael R. Hines  cat > $TMPC <<EOF
28062da776dbSMichael R. Hines#include <rdma/rdma_cma.h>
28072da776dbSMichael R. Hinesint main(void) { return 0; }
28082da776dbSMichael R. HinesEOF
2809ef6d4ccdSYuval Shaia  rdma_libs="-lrdmacm -libverbs -libumad"
28102da776dbSMichael R. Hines  if compile_prog "" "$rdma_libs" ; then
28112da776dbSMichael R. Hines    rdma="yes"
28122da776dbSMichael R. Hines  else
28132da776dbSMichael R. Hines    if test "$rdma" = "yes" ; then
28142da776dbSMichael R. Hines        error_exit \
2815ef6d4ccdSYuval Shaia            " OpenFabrics librdmacm/libibverbs/libibumad not present." \
28162da776dbSMichael R. Hines            " Your options:" \
2817ef6d4ccdSYuval Shaia            "  (1) Fast: Install infiniband packages (devel) from your distro." \
28182da776dbSMichael R. Hines            "  (2) Cleanest: Install libraries from www.openfabrics.org" \
28192da776dbSMichael R. Hines            "  (3) Also: Install softiwarp if you don't have RDMA hardware"
28202da776dbSMichael R. Hines    fi
28212da776dbSMichael R. Hines    rdma="no"
28222da776dbSMichael R. Hines  fi
28232da776dbSMichael R. Hinesfi
28242da776dbSMichael R. Hines
282521ab34c9SMarcel Apfelbaum##########################################
282621ab34c9SMarcel Apfelbaum# PVRDMA detection
282721ab34c9SMarcel Apfelbaum
282821ab34c9SMarcel Apfelbaumcat > $TMPC <<EOF &&
282921ab34c9SMarcel Apfelbaum#include <sys/mman.h>
283021ab34c9SMarcel Apfelbaum
283121ab34c9SMarcel Apfelbaumint
283221ab34c9SMarcel Apfelbaummain(void)
283321ab34c9SMarcel Apfelbaum{
283421ab34c9SMarcel Apfelbaum    char buf = 0;
283521ab34c9SMarcel Apfelbaum    void *addr = &buf;
283621ab34c9SMarcel Apfelbaum    addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED);
283721ab34c9SMarcel Apfelbaum
283821ab34c9SMarcel Apfelbaum    return 0;
283921ab34c9SMarcel Apfelbaum}
284021ab34c9SMarcel ApfelbaumEOF
284121ab34c9SMarcel Apfelbaum
284221ab34c9SMarcel Apfelbaumif test "$rdma" = "yes" ; then
284321ab34c9SMarcel Apfelbaum    case "$pvrdma" in
284421ab34c9SMarcel Apfelbaum    "")
284521ab34c9SMarcel Apfelbaum        if compile_prog "" ""; then
284621ab34c9SMarcel Apfelbaum            pvrdma="yes"
284721ab34c9SMarcel Apfelbaum        else
284821ab34c9SMarcel Apfelbaum            pvrdma="no"
284921ab34c9SMarcel Apfelbaum        fi
285021ab34c9SMarcel Apfelbaum        ;;
285121ab34c9SMarcel Apfelbaum    "yes")
285221ab34c9SMarcel Apfelbaum        if ! compile_prog "" ""; then
285321ab34c9SMarcel Apfelbaum            error_exit "PVRDMA is not supported since mremap is not implemented"
285421ab34c9SMarcel Apfelbaum        fi
285521ab34c9SMarcel Apfelbaum        pvrdma="yes"
285621ab34c9SMarcel Apfelbaum        ;;
285721ab34c9SMarcel Apfelbaum    "no")
285821ab34c9SMarcel Apfelbaum        pvrdma="no"
285921ab34c9SMarcel Apfelbaum        ;;
286021ab34c9SMarcel Apfelbaum    esac
286121ab34c9SMarcel Apfelbaumelse
286221ab34c9SMarcel Apfelbaum    if test "$pvrdma" = "yes" ; then
286321ab34c9SMarcel Apfelbaum        error_exit "PVRDMA requires rdma suppport"
286421ab34c9SMarcel Apfelbaum    fi
286521ab34c9SMarcel Apfelbaum    pvrdma="no"
286621ab34c9SMarcel Apfelbaumfi
286795c6bff3SBenoît Canet
2868ee108585SYuval Shaia# Let's see if enhanced reg_mr is supported
2869ee108585SYuval Shaiaif test "$pvrdma" = "yes" ; then
2870ee108585SYuval Shaia
2871ee108585SYuval Shaiacat > $TMPC <<EOF &&
2872ee108585SYuval Shaia#include <infiniband/verbs.h>
2873ee108585SYuval Shaia
2874ee108585SYuval Shaiaint
2875ee108585SYuval Shaiamain(void)
2876ee108585SYuval Shaia{
2877ee108585SYuval Shaia    struct ibv_mr *mr;
2878ee108585SYuval Shaia    struct ibv_pd *pd = NULL;
2879ee108585SYuval Shaia    size_t length = 10;
2880ee108585SYuval Shaia    uint64_t iova = 0;
2881ee108585SYuval Shaia    int access = 0;
2882ee108585SYuval Shaia    void *addr = NULL;
2883ee108585SYuval Shaia
2884ee108585SYuval Shaia    mr = ibv_reg_mr_iova(pd, addr, length, iova, access);
2885ee108585SYuval Shaia
2886ee108585SYuval Shaia    ibv_dereg_mr(mr);
2887ee108585SYuval Shaia
2888ee108585SYuval Shaia    return 0;
2889ee108585SYuval Shaia}
2890ee108585SYuval ShaiaEOF
2891ee108585SYuval Shaia    if ! compile_prog "" "-libverbs"; then
2892ee108585SYuval Shaia        QEMU_CFLAGS="$QEMU_CFLAGS -DLEGACY_RDMA_REG_MR"
2893ee108585SYuval Shaia    fi
2894ee108585SYuval Shaiafi
2895ee108585SYuval Shaia
289695c6bff3SBenoît Canet##########################################
2897c1bb86cdSEric Blake# xfsctl() probe, used for file-posix.c
2898dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
2899dce512deSChristoph Hellwig  cat > $TMPC << EOF
2900ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
2901dce512deSChristoph Hellwig#include <xfs/xfs.h>
2902dce512deSChristoph Hellwigint main(void)
2903dce512deSChristoph Hellwig{
2904dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
2905dce512deSChristoph Hellwig    return 0;
2906dce512deSChristoph Hellwig}
2907dce512deSChristoph HellwigEOF
2908dce512deSChristoph Hellwig  if compile_prog "" "" ; then
2909dce512deSChristoph Hellwig    xfs="yes"
2910dce512deSChristoph Hellwig  else
2911dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
2912e3a6e0daSzhaolichang      feature_not_found "xfs" "Install xfsprogs/xfslibs devel"
2913dce512deSChristoph Hellwig    fi
2914dce512deSChristoph Hellwig    xfs=no
2915dce512deSChristoph Hellwig  fi
2916dce512deSChristoph Hellwigfi
2917dce512deSChristoph Hellwig
2918dce512deSChristoph Hellwig##########################################
29198a16d273Sths# vde libraries probe
2920dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
29214baae0acSJuan Quintela  vde_libs="-lvdeplug"
29228a16d273Sths  cat > $TMPC << EOF
29238a16d273Sths#include <libvdeplug.h>
29244a7f0e06Spbrookint main(void)
29254a7f0e06Spbrook{
29264a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
2927fea08e08SPeter Maydell    char s[] = "";
2928fea08e08SPeter Maydell    vde_open(s, s, &a);
29294a7f0e06Spbrook    return 0;
29304a7f0e06Spbrook}
29318a16d273SthsEOF
293252166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
29334baae0acSJuan Quintela    vde=yes
2934dfb278bdSJuan Quintela  else
2935dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
293621684af0SStewart Smith      feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
2937dfb278bdSJuan Quintela    fi
2938dfb278bdSJuan Quintela    vde=no
29398a16d273Sths  fi
29408a16d273Sthsfi
29418a16d273Sths
29428a16d273Sths##########################################
29430a985b37SVincenzo Maffione# netmap support probe
29440a985b37SVincenzo Maffione# Apart from looking for netmap headers, we make sure that the host API version
29450a985b37SVincenzo Maffione# supports the netmap backend (>=11). The upper bound (15) is meant to simulate
29460a985b37SVincenzo Maffione# a minor/major version number. Minor new features will be marked with values up
29470a985b37SVincenzo Maffione# to 15, and if something happens that requires a change to the backend we will
29480a985b37SVincenzo Maffione# move above 15, submit the backend fixes and modify this two bounds.
294958952137SVincenzo Maffioneif test "$netmap" != "no" ; then
295058952137SVincenzo Maffione  cat > $TMPC << EOF
295158952137SVincenzo Maffione#include <inttypes.h>
295258952137SVincenzo Maffione#include <net/if.h>
295358952137SVincenzo Maffione#include <net/netmap.h>
295458952137SVincenzo Maffione#include <net/netmap_user.h>
29550a985b37SVincenzo Maffione#if (NETMAP_API < 11) || (NETMAP_API > 15)
29560a985b37SVincenzo Maffione#error
29570a985b37SVincenzo Maffione#endif
295858952137SVincenzo Maffioneint main(void) { return 0; }
295958952137SVincenzo MaffioneEOF
296058952137SVincenzo Maffione  if compile_prog "" "" ; then
296158952137SVincenzo Maffione    netmap=yes
296258952137SVincenzo Maffione  else
296358952137SVincenzo Maffione    if test "$netmap" = "yes" ; then
296458952137SVincenzo Maffione      feature_not_found "netmap"
296558952137SVincenzo Maffione    fi
296658952137SVincenzo Maffione    netmap=no
296758952137SVincenzo Maffione  fi
296858952137SVincenzo Maffionefi
296958952137SVincenzo Maffione
297058952137SVincenzo Maffione##########################################
2971422a5fd0SJoelle van Dyne# detect CoreAudio
2972422a5fd0SJoelle van Dyneif test "$coreaudio" != "no" ; then
2973422a5fd0SJoelle van Dyne  coreaudio_libs="-framework CoreAudio"
2974422a5fd0SJoelle van Dyne  cat > $TMPC << EOF
2975422a5fd0SJoelle van Dyne#include <CoreAudio/CoreAudio.h>
2976422a5fd0SJoelle van Dyneint main(void)
2977422a5fd0SJoelle van Dyne{
2978422a5fd0SJoelle van Dyne  return (int)AudioGetCurrentHostTime();
2979422a5fd0SJoelle van Dyne}
2980422a5fd0SJoelle van DyneEOF
2981422a5fd0SJoelle van Dyne  if compile_prog "" "$coreaudio_libs" ; then
2982422a5fd0SJoelle van Dyne    coreaudio=yes
2983422a5fd0SJoelle van Dyne  else
2984422a5fd0SJoelle van Dyne    coreaudio=no
2985422a5fd0SJoelle van Dyne  fi
2986422a5fd0SJoelle van Dynefi
2987422a5fd0SJoelle van Dyne
2988422a5fd0SJoelle van Dyne##########################################
2989c2de5c91Smalc# Sound support libraries probe
29908f28f3fbSths
299189138857SStefan Weilaudio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
2992c2de5c91Smalcfor drv in $audio_drv_list; do
2993c2de5c91Smalc    case $drv in
2994e42975a1SGerd Hoffmann    alsa | try-alsa)
2995c80a867fSGerd Hoffmann    if $pkg_config alsa --exists; then
2996c80a867fSGerd Hoffmann        alsa_libs=$($pkg_config alsa --libs)
2997478e943fSPaolo Bonzini        alsa_cflags=$($pkg_config alsa --cflags)
2998478e943fSPaolo Bonzini        alsa=yes
2999e42975a1SGerd Hoffmann        if test "$drv" = "try-alsa"; then
3000e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa/alsa/')
3001e42975a1SGerd Hoffmann        fi
3002e42975a1SGerd Hoffmann    else
3003e42975a1SGerd Hoffmann        if test "$drv" = "try-alsa"; then
3004e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa//')
3005c80a867fSGerd Hoffmann        else
3006c80a867fSGerd Hoffmann            error_exit "$drv check failed" \
3007c80a867fSGerd Hoffmann                "Make sure to have the $drv libs and headers installed."
3008c80a867fSGerd Hoffmann        fi
3009e42975a1SGerd Hoffmann    fi
3010c2de5c91Smalc    ;;
3011c2de5c91Smalc
3012e42975a1SGerd Hoffmann    pa | try-pa)
3013c80a867fSGerd Hoffmann    if $pkg_config libpulse --exists; then
3014478e943fSPaolo Bonzini        libpulse=yes
3015c80a867fSGerd Hoffmann        pulse_libs=$($pkg_config libpulse --libs)
3016478e943fSPaolo Bonzini        pulse_cflags=$($pkg_config libpulse --cflags)
3017e42975a1SGerd Hoffmann        if test "$drv" = "try-pa"; then
3018e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa/pa/')
3019e42975a1SGerd Hoffmann        fi
3020e42975a1SGerd Hoffmann    else
3021e42975a1SGerd Hoffmann        if test "$drv" = "try-pa"; then
3022e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa//')
3023c80a867fSGerd Hoffmann        else
3024c80a867fSGerd Hoffmann            error_exit "$drv check failed" \
3025c80a867fSGerd Hoffmann                "Make sure to have the $drv libs and headers installed."
3026c80a867fSGerd Hoffmann        fi
3027e42975a1SGerd Hoffmann    fi
3028b8e59f18Smalc    ;;
3029b8e59f18Smalc
3030373967b2SGerd Hoffmann    sdl)
3031373967b2SGerd Hoffmann    if test "$sdl" = "no"; then
3032373967b2SGerd Hoffmann        error_exit "sdl not found or disabled, can not use sdl audio driver"
3033373967b2SGerd Hoffmann    fi
3034373967b2SGerd Hoffmann    ;;
3035373967b2SGerd Hoffmann
3036e42975a1SGerd Hoffmann    try-sdl)
3037e42975a1SGerd Hoffmann    if test "$sdl" = "no"; then
3038e42975a1SGerd Hoffmann        audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl//')
3039e42975a1SGerd Hoffmann    else
3040e42975a1SGerd Hoffmann        audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl/sdl/')
3041e42975a1SGerd Hoffmann    fi
3042e42975a1SGerd Hoffmann    ;;
3043e42975a1SGerd Hoffmann
3044422a5fd0SJoelle van Dyne    coreaudio | try-coreaudio)
3045422a5fd0SJoelle van Dyne    if test "$coreaudio" = "no"; then
3046422a5fd0SJoelle van Dyne      if test "$drv" = "try-coreaudio"; then
3047422a5fd0SJoelle van Dyne        audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-coreaudio//')
3048422a5fd0SJoelle van Dyne      else
3049422a5fd0SJoelle van Dyne        error_exit "$drv check failed" \
3050422a5fd0SJoelle van Dyne                "Make sure to have the $drv is available."
3051422a5fd0SJoelle van Dyne      fi
3052422a5fd0SJoelle van Dyne    else
3053b1149911SFam Zheng      coreaudio_libs="-framework CoreAudio"
3054422a5fd0SJoelle van Dyne      if test "$drv" = "try-coreaudio"; then
3055422a5fd0SJoelle van Dyne        audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-coreaudio/coreaudio/')
3056422a5fd0SJoelle van Dyne      fi
3057422a5fd0SJoelle van Dyne    fi
3058997e690aSJuan Quintela    ;;
3059997e690aSJuan Quintela
3060a4bf6780SJuan Quintela    dsound)
3061b1149911SFam Zheng      dsound_libs="-lole32 -ldxguid"
3062d5631638Smalc      audio_win_int="yes"
3063a4bf6780SJuan Quintela    ;;
3064a4bf6780SJuan Quintela
3065a4bf6780SJuan Quintela    oss)
3066b1149911SFam Zheng      oss_libs="$oss_lib"
3067a4bf6780SJuan Quintela    ;;
3068a4bf6780SJuan Quintela
30692e445703SGeoffrey McRae    jack | try-jack)
30702e445703SGeoffrey McRae    if $pkg_config jack --exists; then
3071478e943fSPaolo Bonzini        libjack=yes
30722e445703SGeoffrey McRae        jack_libs=$($pkg_config jack --libs)
30732e445703SGeoffrey McRae        if test "$drv" = "try-jack"; then
30742e445703SGeoffrey McRae            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-jack/jack/')
30752e445703SGeoffrey McRae        fi
30762e445703SGeoffrey McRae    else
30772e445703SGeoffrey McRae        if test "$drv" = "try-jack"; then
30782e445703SGeoffrey McRae            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-jack//')
30792e445703SGeoffrey McRae        else
30802e445703SGeoffrey McRae            error_exit "$drv check failed" \
30812e445703SGeoffrey McRae                "Make sure to have the $drv libs and headers installed."
30822e445703SGeoffrey McRae        fi
30832e445703SGeoffrey McRae    fi
30842e445703SGeoffrey McRae    ;;
30852e445703SGeoffrey McRae
3086e4c63a6aSmalc    *)
30871c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
308876ad07a4SPeter Maydell        error_exit "Unknown driver '$drv' selected" \
308976ad07a4SPeter Maydell            "Possible drivers are: $audio_possible_drivers"
3090e4c63a6aSmalc    }
3091e4c63a6aSmalc    ;;
3092c2de5c91Smalc    esac
3093c2de5c91Smalcdone
30948f28f3fbSths
30954d3b6f6eSbalrog##########################################
3096e18df141SAnthony Liguori# glib support probe
3097a52d28afSPaolo Bonzini
3098b4c6036fSDaniel P. Berrangéglib_req_ver=2.56
3099aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0
3100aa0d1f44SPaolo Bonziniif test "$modules" = yes; then
3101a88afc64SGerd Hoffmann    glib_modules="$glib_modules gmodule-export-2.0"
3102aa0d1f44SPaolo Bonzinifi
310354cb65d8SEmilio G. Cotaif test "$plugins" = yes; then
310454cb65d8SEmilio G. Cota    glib_modules="$glib_modules gmodule-2.0"
310554cb65d8SEmilio G. Cotafi
3106e26110cfSFam Zheng
3107aa0d1f44SPaolo Bonzinifor i in $glib_modules; do
3108e26110cfSFam Zheng    if $pkg_config --atleast-version=$glib_req_ver $i; then
310989138857SStefan Weil        glib_cflags=$($pkg_config --cflags $i)
311089138857SStefan Weil        glib_libs=$($pkg_config --libs $i)
3111e18df141SAnthony Liguori    else
3112e26110cfSFam Zheng        error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3113e26110cfSFam Zheng    fi
3114e26110cfSFam Zhengdone
3115e26110cfSFam Zheng
3116215b0c2fSPaolo Bonzini# This workaround is required due to a bug in pkg-config file for glib as it
3117215b0c2fSPaolo Bonzini# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
3118215b0c2fSPaolo Bonzini
3119215b0c2fSPaolo Bonziniif test "$static" = yes && test "$mingw32" = yes; then
3120215b0c2fSPaolo Bonzini    glib_cflags="-DGLIB_STATIC_COMPILATION $glib_cflags"
3121215b0c2fSPaolo Bonzinifi
3122215b0c2fSPaolo Bonzini
312320cf7b8eSDenis Plotnikovif ! test "$gio" = "no"; then
312420cf7b8eSDenis Plotnikov    pass=no
3125f876b765SMarc-André Lureau    if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
3126f876b765SMarc-André Lureau        gio_cflags=$($pkg_config --cflags gio-2.0)
3127f876b765SMarc-André Lureau        gio_libs=$($pkg_config --libs gio-2.0)
312825a97a56SMarc-André Lureau        gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0)
31295ecfb76cSPaolo Bonzini        if ! has "$gdbus_codegen"; then
31300dba4897SMarc-André Lureau            gdbus_codegen=
31310dba4897SMarc-André Lureau        fi
313276346b62SPeter Maydell        # Check that the libraries actually work -- Ubuntu 18.04 ships
313376346b62SPeter Maydell        # with pkg-config --static --libs data for gio-2.0 that is missing
313476346b62SPeter Maydell        # -lblkid and will give a link error.
313513ceae66SPeter Maydell        cat > $TMPC <<EOF
313613ceae66SPeter Maydell#include <gio/gio.h>
313713ceae66SPeter Maydellint main(void)
313813ceae66SPeter Maydell{
313913ceae66SPeter Maydell    g_dbus_proxy_new_sync(0, 0, 0, 0, 0, 0, 0, 0);
314013ceae66SPeter Maydell    return 0;
314113ceae66SPeter Maydell}
314213ceae66SPeter MaydellEOF
314313ceae66SPeter Maydell        if compile_prog "$gio_cflags" "$gio_libs" ; then
314420cf7b8eSDenis Plotnikov            pass=yes
314576346b62SPeter Maydell        else
314620cf7b8eSDenis Plotnikov            pass=no
3147f876b765SMarc-André Lureau        fi
3148f876b765SMarc-André Lureau
314920cf7b8eSDenis Plotnikov        if test "$pass" = "yes" &&
315020cf7b8eSDenis Plotnikov            $pkg_config --atleast-version=$glib_req_ver gio-unix-2.0; then
315125a97a56SMarc-André Lureau            gio_cflags="$gio_cflags $($pkg_config --cflags gio-unix-2.0)"
315225a97a56SMarc-André Lureau            gio_libs="$gio_libs $($pkg_config --libs gio-unix-2.0)"
315325a97a56SMarc-André Lureau        fi
315420cf7b8eSDenis Plotnikov    fi
315520cf7b8eSDenis Plotnikov
315620cf7b8eSDenis Plotnikov    if test "$pass" = "no"; then
315720cf7b8eSDenis Plotnikov        if test "$gio" = "yes"; then
315820cf7b8eSDenis Plotnikov            feature_not_found "gio" "Install libgio >= 2.0"
315920cf7b8eSDenis Plotnikov        else
316020cf7b8eSDenis Plotnikov            gio=no
316120cf7b8eSDenis Plotnikov        fi
316220cf7b8eSDenis Plotnikov    else
316320cf7b8eSDenis Plotnikov        gio=yes
316420cf7b8eSDenis Plotnikov    fi
316520cf7b8eSDenis Plotnikovfi
316625a97a56SMarc-André Lureau
3167977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the
3168977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches
3169977a82abSDaniel P. Berrange# problems on multi-arch where people try to build
3170977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers
3171977a82abSDaniel P. Berrangecat > $TMPC <<EOF
3172977a82abSDaniel P. Berrange#include <glib.h>
3173977a82abSDaniel P. Berrange#include <unistd.h>
3174977a82abSDaniel P. Berrange
3175977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \
3176977a82abSDaniel P. Berrange  typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3177977a82abSDaniel P. Berrange
3178977a82abSDaniel P. Berrangeint main(void) {
3179977a82abSDaniel P. Berrange   QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3180977a82abSDaniel P. Berrange   return 0;
3181977a82abSDaniel P. Berrange}
3182977a82abSDaniel P. BerrangeEOF
3183977a82abSDaniel P. Berrange
3184215b0c2fSPaolo Bonziniif ! compile_prog "$glib_cflags" "$glib_libs" ; then
3185977a82abSDaniel P. Berrange    error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3186977a82abSDaniel P. Berrange               "You probably need to set PKG_CONFIG_LIBDIR"\
3187977a82abSDaniel P. Berrange	       "to point to the right pkg-config files for your"\
3188977a82abSDaniel P. Berrange	       "build target"
3189977a82abSDaniel P. Berrangefi
3190977a82abSDaniel P. Berrange
3191bbbf2e04SJohn Snow# Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
3192bbbf2e04SJohn Snowcat > $TMPC << EOF
3193bbbf2e04SJohn Snow#include <glib.h>
3194bbbf2e04SJohn Snowint main(void) { return 0; }
3195bbbf2e04SJohn SnowEOF
3196bbbf2e04SJohn Snowif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3197bbbf2e04SJohn Snow    if cc_has_warning_flag "-Wno-unknown-attributes"; then
3198bbbf2e04SJohn Snow        glib_cflags="-Wno-unknown-attributes $glib_cflags"
31995770e8afSPaolo Bonzini        CONFIGURE_CFLAGS="-Wno-unknown-attributes $CONFIGURE_CFLAGS"
3200bbbf2e04SJohn Snow    fi
3201bbbf2e04SJohn Snowfi
3202bbbf2e04SJohn Snow
32039bda600bSEric Blake# Silence clang warnings triggered by glib < 2.57.2
32049bda600bSEric Blakecat > $TMPC << EOF
32059bda600bSEric Blake#include <glib.h>
32069bda600bSEric Blaketypedef struct Foo {
32079bda600bSEric Blake    int i;
32089bda600bSEric Blake} Foo;
32099bda600bSEric Blakestatic void foo_free(Foo *f)
32109bda600bSEric Blake{
32119bda600bSEric Blake    g_free(f);
32129bda600bSEric Blake}
32139bda600bSEric BlakeG_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free);
32149bda600bSEric Blakeint main(void) { return 0; }
32159bda600bSEric BlakeEOF
32169bda600bSEric Blakeif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
32179bda600bSEric Blake    if cc_has_warning_flag "-Wno-unused-function"; then
32189bda600bSEric Blake        glib_cflags="$glib_cflags -Wno-unused-function"
32195770e8afSPaolo Bonzini        CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -Wno-unused-function"
32209bda600bSEric Blake    fi
32219bda600bSEric Blakefi
32229bda600bSEric Blake
3223e26110cfSFam Zheng##########################################
3224e26110cfSFam Zheng# SHA command probe for modules
3225e26110cfSFam Zhengif test "$modules" = yes; then
3226e26110cfSFam Zheng    shacmd_probe="sha1sum sha1 shasum"
3227e26110cfSFam Zheng    for c in $shacmd_probe; do
32288ccefb91SFam Zheng        if has $c; then
3229e26110cfSFam Zheng            shacmd="$c"
3230e26110cfSFam Zheng            break
3231e26110cfSFam Zheng        fi
3232e26110cfSFam Zheng    done
3233e26110cfSFam Zheng    if test "$shacmd" = ""; then
3234e26110cfSFam Zheng        error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3235e26110cfSFam Zheng    fi
3236e18df141SAnthony Liguorifi
3237e18df141SAnthony Liguori
3238e18df141SAnthony Liguori##########################################
3239e5d355d1Saliguori# pthread probe
32404b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
32413c529d93Saliguori
3242e5d355d1Saliguoripthread=no
3243414f0dabSblueswir1cat > $TMPC << EOF
32443c529d93Saliguori#include <pthread.h>
32457a42bbe4SStefan Weilstatic void *f(void *p) { return NULL; }
32467a42bbe4SStefan Weilint main(void) {
32477a42bbe4SStefan Weil  pthread_t thread;
32487a42bbe4SStefan Weil  pthread_create(&thread, 0, f, 0);
32497a42bbe4SStefan Weil  return 0;
32507a42bbe4SStefan Weil}
3251414f0dabSblueswir1EOF
3252bd00d539SAndreas Färberif compile_prog "" "" ; then
3253bd00d539SAndreas Färber  pthread=yes
3254bd00d539SAndreas Färberelse
3255de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
325652166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
3257e5d355d1Saliguori      pthread=yes
3258de65fe0fSSebastian Herbszt      break
3259414f0dabSblueswir1    fi
3260de65fe0fSSebastian Herbszt  done
3261bd00d539SAndreas Färberfi
3262414f0dabSblueswir1
3263e633a5c6SEric Blakeif test "$mingw32" != yes && test "$pthread" = no; then
326476ad07a4SPeter Maydell  error_exit "pthread check failed" \
326576ad07a4SPeter Maydell      "Make sure to have the pthread libs and headers installed."
3266e5d355d1Saliguorifi
3267e5d355d1Saliguori
3268479a5747SRoman Bolshakov# check for pthread_setname_np with thread id
3269479a5747SRoman Bolshakovpthread_setname_np_w_tid=no
32705c312079SDr. David Alan Gilbertcat > $TMPC << EOF
32715c312079SDr. David Alan Gilbert#include <pthread.h>
32725c312079SDr. David Alan Gilbert
32735c312079SDr. David Alan Gilbertstatic void *f(void *p) { return NULL; }
32745c312079SDr. David Alan Gilbertint main(void)
32755c312079SDr. David Alan Gilbert{
32765c312079SDr. David Alan Gilbert    pthread_t thread;
32775c312079SDr. David Alan Gilbert    pthread_create(&thread, 0, f, 0);
32785c312079SDr. David Alan Gilbert    pthread_setname_np(thread, "QEMU");
32795c312079SDr. David Alan Gilbert    return 0;
32805c312079SDr. David Alan Gilbert}
32815c312079SDr. David Alan GilbertEOF
32825c312079SDr. David Alan Gilbertif compile_prog "" "$pthread_lib" ; then
3283479a5747SRoman Bolshakov  pthread_setname_np_w_tid=yes
3284479a5747SRoman Bolshakovfi
3285479a5747SRoman Bolshakov
3286479a5747SRoman Bolshakov# check for pthread_setname_np without thread id
3287479a5747SRoman Bolshakovpthread_setname_np_wo_tid=no
3288479a5747SRoman Bolshakovcat > $TMPC << EOF
3289479a5747SRoman Bolshakov#include <pthread.h>
3290479a5747SRoman Bolshakov
329112a9b8d8SThomas Huthstatic void *f(void *p) { pthread_setname_np("QEMU"); return NULL; }
3292479a5747SRoman Bolshakovint main(void)
3293479a5747SRoman Bolshakov{
3294479a5747SRoman Bolshakov    pthread_t thread;
3295479a5747SRoman Bolshakov    pthread_create(&thread, 0, f, 0);
3296479a5747SRoman Bolshakov    return 0;
3297479a5747SRoman Bolshakov}
3298479a5747SRoman BolshakovEOF
3299479a5747SRoman Bolshakovif compile_prog "" "$pthread_lib" ; then
3300479a5747SRoman Bolshakov  pthread_setname_np_wo_tid=yes
33015c312079SDr. David Alan Gilbertfi
33025c312079SDr. David Alan Gilbert
3303bf9298b9Saliguori##########################################
3304b10d49d7SPino Toscano# libssh probe
3305b10d49d7SPino Toscanoif test "$libssh" != "no" ; then
3306b4c10fc6SThomas Huth  if $pkg_config --exists "libssh >= 0.8.7"; then
3307b10d49d7SPino Toscano    libssh_cflags=$($pkg_config libssh --cflags)
3308b10d49d7SPino Toscano    libssh_libs=$($pkg_config libssh --libs)
3309b10d49d7SPino Toscano    libssh=yes
33100a12ec87SRichard W.M. Jones  else
3311b10d49d7SPino Toscano    if test "$libssh" = "yes" ; then
3312b10d49d7SPino Toscano      error_exit "libssh required for --enable-libssh"
33130a12ec87SRichard W.M. Jones    fi
3314b10d49d7SPino Toscano    libssh=no
33150a12ec87SRichard W.M. Jones  fi
33160a12ec87SRichard W.M. Jonesfi
33170a12ec87SRichard W.M. Jones
33180a12ec87SRichard W.M. Jones##########################################
33195c6c3a6cSChristoph Hellwig# linux-aio probe
33205c6c3a6cSChristoph Hellwig
33215c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
33225c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
33235c6c3a6cSChristoph Hellwig#include <libaio.h>
33245c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
3325832ce9c2SScott Wood#include <stddef.h>
33265c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
33275c6c3a6cSChristoph HellwigEOF
33285c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
33295c6c3a6cSChristoph Hellwig    linux_aio=yes
33305c6c3a6cSChristoph Hellwig  else
33315c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
333221684af0SStewart Smith      feature_not_found "linux AIO" "Install libaio devel"
33335c6c3a6cSChristoph Hellwig    fi
33343cfcae3cSLuiz Capitulino    linux_aio=no
33355c6c3a6cSChristoph Hellwig  fi
33365c6c3a6cSChristoph Hellwigfi
3337c10dd856SAarushi Mehta##########################################
3338c10dd856SAarushi Mehta# linux-io-uring probe
3339c10dd856SAarushi Mehta
3340c10dd856SAarushi Mehtaif test "$linux_io_uring" != "no" ; then
3341c10dd856SAarushi Mehta  if $pkg_config liburing; then
3342c10dd856SAarushi Mehta    linux_io_uring_cflags=$($pkg_config --cflags liburing)
3343c10dd856SAarushi Mehta    linux_io_uring_libs=$($pkg_config --libs liburing)
3344c10dd856SAarushi Mehta    linux_io_uring=yes
3345c10dd856SAarushi Mehta  else
3346c10dd856SAarushi Mehta    if test "$linux_io_uring" = "yes" ; then
3347c10dd856SAarushi Mehta      feature_not_found "linux io_uring" "Install liburing devel"
3348c10dd856SAarushi Mehta    fi
3349c10dd856SAarushi Mehta    linux_io_uring=no
3350c10dd856SAarushi Mehta  fi
3351c10dd856SAarushi Mehtafi
33525c6c3a6cSChristoph Hellwig
33535c6c3a6cSChristoph Hellwig##########################################
33547aaa6a16SPaolo Bonzini# TPM emulation is only on POSIX
33553b8acc11SPaolo Bonzini
33567aaa6a16SPaolo Bonziniif test "$tpm" = ""; then
33577aaa6a16SPaolo Bonzini  if test "$mingw32" = "yes"; then
33587aaa6a16SPaolo Bonzini    tpm=no
33593b8acc11SPaolo Bonzini  else
33607aaa6a16SPaolo Bonzini    tpm=yes
33617aaa6a16SPaolo Bonzini  fi
33627aaa6a16SPaolo Bonzinielif test "$tpm" = "yes"; then
33637aaa6a16SPaolo Bonzini  if test "$mingw32" = "yes" ; then
33647aaa6a16SPaolo Bonzini    error_exit "TPM emulation only available on POSIX systems"
33657aaa6a16SPaolo Bonzini  fi
33663b8acc11SPaolo Bonzinifi
33673b8acc11SPaolo Bonzini
33683b8acc11SPaolo Bonzini##########################################
3369bf9298b9Saliguori# iovec probe
3370bf9298b9Saliguoricat > $TMPC <<EOF
3371db34f0b3Sblueswir1#include <sys/types.h>
3372bf9298b9Saliguori#include <sys/uio.h>
3373db34f0b3Sblueswir1#include <unistd.h>
3374f91f9beeSStefan Weilint main(void) { return sizeof(struct iovec); }
3375bf9298b9SaliguoriEOF
3376bf9298b9Saliguoriiovec=no
337752166aa0SJuan Quintelaif compile_prog "" "" ; then
3378bf9298b9Saliguori  iovec=yes
3379bf9298b9Saliguorifi
3380bf9298b9Saliguori
3381f652e6afSaurel32##########################################
3382f652e6afSaurel32# fdt probe
3383e169e1e1SPeter Maydell
3384fbb4121dSPaolo Bonzinicase "$fdt" in
3385fbb4121dSPaolo Bonzini  auto | enabled | internal)
3386fbb4121dSPaolo Bonzini    # Simpler to always update submodule, even if not needed.
3387aef45d51SDaniel P. Berrange    git_submodules="${git_submodules} dtc"
3388fbb4121dSPaolo Bonzini    ;;
3389fbb4121dSPaolo Bonziniesac
3390f652e6afSaurel32
339120ff075bSMichael Walle##########################################
33929d49bcf6SMarkus Armbruster# opengl probe (for sdl2, gtk)
3393b1546f32SGerd Hoffmann
3394d52c454aSMarc-André Lureaugbm="no"
3395d52c454aSMarc-André Lureauif $pkg_config gbm; then
3396d52c454aSMarc-André Lureau    gbm_cflags="$($pkg_config --cflags gbm)"
3397d52c454aSMarc-André Lureau    gbm_libs="$($pkg_config --libs gbm)"
3398d52c454aSMarc-André Lureau    gbm="yes"
3399d52c454aSMarc-André Lureaufi
3400d52c454aSMarc-André Lureau
3401da076ffeSGerd Hoffmannif test "$opengl" != "no" ; then
3402bc6a3565SAkihiko Odaki  epoxy=no
3403bc6a3565SAkihiko Odaki  if $pkg_config epoxy; then
3404bc6a3565SAkihiko Odaki    cat > $TMPC << EOF
3405bc6a3565SAkihiko Odaki#include <epoxy/egl.h>
3406bc6a3565SAkihiko Odakiint main(void) { return 0; }
3407bc6a3565SAkihiko OdakiEOF
3408bc6a3565SAkihiko Odaki    if compile_prog "" "" ; then
3409bc6a3565SAkihiko Odaki      epoxy=yes
3410bc6a3565SAkihiko Odaki    fi
3411bc6a3565SAkihiko Odaki  fi
3412bc6a3565SAkihiko Odaki
3413bc6a3565SAkihiko Odaki  if test "$epoxy" = "yes" ; then
3414bc6a3565SAkihiko Odaki    opengl_cflags="$($pkg_config --cflags epoxy)"
3415bc6a3565SAkihiko Odaki    opengl_libs="$($pkg_config --libs epoxy)"
3416da076ffeSGerd Hoffmann    opengl=yes
341720ff075bSMichael Walle  else
3418da076ffeSGerd Hoffmann    if test "$opengl" = "yes" ; then
3419bc6a3565SAkihiko Odaki      feature_not_found "opengl" "Please install epoxy with EGL"
342020ff075bSMichael Walle    fi
3421f676c67eSJeremy White    opengl_cflags=""
3422da076ffeSGerd Hoffmann    opengl_libs=""
3423da076ffeSGerd Hoffmann    opengl=no
342420ff075bSMichael Walle  fi
342520ff075bSMichael Wallefi
342620ff075bSMichael Walle
3427ed279a06SKlim Kireev##########################################
3428ed279a06SKlim Kireev# libxml2 probe
3429ed279a06SKlim Kireevif test "$libxml2" != "no" ; then
3430ed279a06SKlim Kireev    if $pkg_config --exists libxml-2.0; then
3431ed279a06SKlim Kireev        libxml2="yes"
3432ed279a06SKlim Kireev        libxml2_cflags=$($pkg_config --cflags libxml-2.0)
3433ed279a06SKlim Kireev        libxml2_libs=$($pkg_config --libs libxml-2.0)
3434ed279a06SKlim Kireev    else
3435ed279a06SKlim Kireev        if test "$libxml2" = "yes"; then
3436ed279a06SKlim Kireev            feature_not_found "libxml2" "Install libxml2 devel"
3437ed279a06SKlim Kireev        fi
3438ed279a06SKlim Kireev        libxml2="no"
3439ed279a06SKlim Kireev    fi
3440ed279a06SKlim Kireevfi
3441c9a12e75SChrysostomos Nanakos
344239386ac7Saurel32# Check for inotify functions when we are building linux-user
34433b3f24adSaurel32# emulator.  This is done because older glibc versions don't
34443b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
34453b3f24adSaurel32# don't provide them even if kernel supports them.
34463b3f24adSaurel32#
34473b3f24adSaurel32inotify=no
34483b3f24adSaurel32cat > $TMPC << EOF
34493b3f24adSaurel32#include <sys/inotify.h>
34503b3f24adSaurel32
34513b3f24adSaurel32int
34523b3f24adSaurel32main(void)
34533b3f24adSaurel32{
34543b3f24adSaurel32	/* try to start inotify */
34558690e420Saurel32	return inotify_init();
34563b3f24adSaurel32}
34573b3f24adSaurel32EOF
345852166aa0SJuan Quintelaif compile_prog "" "" ; then
34593b3f24adSaurel32  inotify=yes
34603b3f24adSaurel32fi
34613b3f24adSaurel32
3462c05c7a73SRiku Voipioinotify1=no
3463c05c7a73SRiku Voipiocat > $TMPC << EOF
3464c05c7a73SRiku Voipio#include <sys/inotify.h>
3465c05c7a73SRiku Voipio
3466c05c7a73SRiku Voipioint
3467c05c7a73SRiku Voipiomain(void)
3468c05c7a73SRiku Voipio{
3469c05c7a73SRiku Voipio    /* try to start inotify */
3470c05c7a73SRiku Voipio    return inotify_init1(0);
3471c05c7a73SRiku Voipio}
3472c05c7a73SRiku VoipioEOF
3473c05c7a73SRiku Voipioif compile_prog "" "" ; then
3474c05c7a73SRiku Voipio  inotify1=yes
3475c05c7a73SRiku Voipiofi
3476c05c7a73SRiku Voipio
3477099d6b0fSRiku Voipio# check if pipe2 is there
3478099d6b0fSRiku Voipiopipe2=no
3479099d6b0fSRiku Voipiocat > $TMPC << EOF
3480099d6b0fSRiku Voipio#include <unistd.h>
3481099d6b0fSRiku Voipio#include <fcntl.h>
3482099d6b0fSRiku Voipio
3483099d6b0fSRiku Voipioint main(void)
3484099d6b0fSRiku Voipio{
3485099d6b0fSRiku Voipio    int pipefd[2];
34869bca8162SBruce Rogers    return pipe2(pipefd, O_CLOEXEC);
3487099d6b0fSRiku Voipio}
3488099d6b0fSRiku VoipioEOF
348952166aa0SJuan Quintelaif compile_prog "" "" ; then
3490099d6b0fSRiku Voipio  pipe2=yes
3491099d6b0fSRiku Voipiofi
3492099d6b0fSRiku Voipio
349340ff6d7eSKevin Wolf# check if accept4 is there
349440ff6d7eSKevin Wolfaccept4=no
349540ff6d7eSKevin Wolfcat > $TMPC << EOF
349640ff6d7eSKevin Wolf#include <sys/socket.h>
349740ff6d7eSKevin Wolf#include <stddef.h>
349840ff6d7eSKevin Wolf
349940ff6d7eSKevin Wolfint main(void)
350040ff6d7eSKevin Wolf{
350140ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
350240ff6d7eSKevin Wolf    return 0;
350340ff6d7eSKevin Wolf}
350440ff6d7eSKevin WolfEOF
350540ff6d7eSKevin Wolfif compile_prog "" "" ; then
350640ff6d7eSKevin Wolf  accept4=yes
350740ff6d7eSKevin Wolffi
350840ff6d7eSKevin Wolf
35093ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
35103ce34dfbSvibisreenivasansplice=no
35113ce34dfbSvibisreenivasancat > $TMPC << EOF
35123ce34dfbSvibisreenivasan#include <unistd.h>
35133ce34dfbSvibisreenivasan#include <fcntl.h>
35143ce34dfbSvibisreenivasan#include <limits.h>
35153ce34dfbSvibisreenivasan
35163ce34dfbSvibisreenivasanint main(void)
35173ce34dfbSvibisreenivasan{
351866ea0f22SStefan Weil    int len, fd = 0;
35193ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
35203ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
35213ce34dfbSvibisreenivasan    return 0;
35223ce34dfbSvibisreenivasan}
35233ce34dfbSvibisreenivasanEOF
352452166aa0SJuan Quintelaif compile_prog "" "" ; then
35253ce34dfbSvibisreenivasan  splice=yes
35263ce34dfbSvibisreenivasanfi
35273ce34dfbSvibisreenivasan
3528dcc38d1cSMarcelo Tosatti##########################################
3529a99d57bbSWanlong Gao# libnuma probe
3530a99d57bbSWanlong Gao
3531a99d57bbSWanlong Gaoif test "$numa" != "no" ; then
3532a99d57bbSWanlong Gao  cat > $TMPC << EOF
3533a99d57bbSWanlong Gao#include <numa.h>
3534a99d57bbSWanlong Gaoint main(void) { return numa_available(); }
3535a99d57bbSWanlong GaoEOF
3536a99d57bbSWanlong Gao
3537a99d57bbSWanlong Gao  if compile_prog "" "-lnuma" ; then
3538a99d57bbSWanlong Gao    numa=yes
3539ab318051SMarc-André Lureau    numa_libs="-lnuma"
3540a99d57bbSWanlong Gao  else
3541a99d57bbSWanlong Gao    if test "$numa" = "yes" ; then
3542a99d57bbSWanlong Gao      feature_not_found "numa" "install numactl devel"
3543a99d57bbSWanlong Gao    fi
3544a99d57bbSWanlong Gao    numa=no
3545a99d57bbSWanlong Gao  fi
3546a99d57bbSWanlong Gaofi
3547a99d57bbSWanlong Gao
3548aa087962SPaolo Bonzinimalloc=system
35497b01cb97SAlexandre Derumierif test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
35507b01cb97SAlexandre Derumier    echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
35517b01cb97SAlexandre Derumier    exit 1
3552aa087962SPaolo Bonzinielif test "$tcmalloc" = "yes" ; then
3553aa087962SPaolo Bonzini    malloc=tcmalloc
3554aa087962SPaolo Bonzinielif test "$jemalloc" = "yes" ; then
3555aa087962SPaolo Bonzini    malloc=jemalloc
35567b01cb97SAlexandre Derumierfi
35577b01cb97SAlexandre Derumier
35587b01cb97SAlexandre Derumier##########################################
3559dcc38d1cSMarcelo Tosatti# signalfd probe
3560dcc38d1cSMarcelo Tosattisignalfd="no"
3561dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
3562dcc38d1cSMarcelo Tosatti#include <unistd.h>
3563dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
3564dcc38d1cSMarcelo Tosatti#include <signal.h>
3565dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
3566dcc38d1cSMarcelo TosattiEOF
3567dcc38d1cSMarcelo Tosatti
3568dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
3569dcc38d1cSMarcelo Tosatti  signalfd=yes
3570dcc38d1cSMarcelo Tosattifi
3571dcc38d1cSMarcelo Tosatti
3572d339d766SRichard W.M. Jones# check if optreset global is declared by <getopt.h>
3573d339d766SRichard W.M. Jonesoptreset="no"
3574d339d766SRichard W.M. Jonescat > $TMPC << EOF
3575d339d766SRichard W.M. Jones#include <getopt.h>
3576d339d766SRichard W.M. Jonesint main(void) { return optreset; }
3577d339d766SRichard W.M. JonesEOF
3578d339d766SRichard W.M. Jones
3579d339d766SRichard W.M. Jonesif compile_prog "" "" ; then
3580d339d766SRichard W.M. Jones  optreset=yes
3581d339d766SRichard W.M. Jonesfi
3582d339d766SRichard W.M. Jones
3583c2882b96SRiku Voipio# check if eventfd is supported
3584c2882b96SRiku Voipioeventfd=no
3585c2882b96SRiku Voipiocat > $TMPC << EOF
3586c2882b96SRiku Voipio#include <sys/eventfd.h>
3587c2882b96SRiku Voipio
3588c2882b96SRiku Voipioint main(void)
3589c2882b96SRiku Voipio{
359055cc7f3eSStefan Weil    return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
3591c2882b96SRiku Voipio}
3592c2882b96SRiku VoipioEOF
3593c2882b96SRiku Voipioif compile_prog "" "" ; then
3594c2882b96SRiku Voipio  eventfd=yes
3595c2882b96SRiku Voipiofi
3596c2882b96SRiku Voipio
3597751bcc39SMarc-André Lureau# check if memfd is supported
3598751bcc39SMarc-André Lureaumemfd=no
3599751bcc39SMarc-André Lureaucat > $TMPC << EOF
360075e5b70eSPaolo Bonzini#include <sys/mman.h>
3601751bcc39SMarc-André Lureau
3602751bcc39SMarc-André Lureauint main(void)
3603751bcc39SMarc-André Lureau{
3604751bcc39SMarc-André Lureau    return memfd_create("foo", MFD_ALLOW_SEALING);
3605751bcc39SMarc-André Lureau}
3606751bcc39SMarc-André LureauEOF
3607751bcc39SMarc-André Lureauif compile_prog "" "" ; then
3608751bcc39SMarc-André Lureau  memfd=yes
3609751bcc39SMarc-André Lureaufi
3610751bcc39SMarc-André Lureau
3611955727d2SCortland Tölva# check for usbfs
3612955727d2SCortland Tölvahave_usbfs=no
3613955727d2SCortland Tölvaif test "$linux_user" = "yes"; then
361496566d09SThomas Petazzoni  cat > $TMPC << EOF
361596566d09SThomas Petazzoni#include <linux/usbdevice_fs.h>
361696566d09SThomas Petazzoni
361796566d09SThomas Petazzoni#ifndef USBDEVFS_GET_CAPABILITIES
361896566d09SThomas Petazzoni#error "USBDEVFS_GET_CAPABILITIES undefined"
361996566d09SThomas Petazzoni#endif
362096566d09SThomas Petazzoni
362196566d09SThomas Petazzoni#ifndef USBDEVFS_DISCONNECT_CLAIM
362296566d09SThomas Petazzoni#error "USBDEVFS_DISCONNECT_CLAIM undefined"
362396566d09SThomas Petazzoni#endif
362496566d09SThomas Petazzoni
362596566d09SThomas Petazzoniint main(void)
362696566d09SThomas Petazzoni{
362796566d09SThomas Petazzoni    return 0;
362896566d09SThomas Petazzoni}
362996566d09SThomas PetazzoniEOF
363096566d09SThomas Petazzoni  if compile_prog "" ""; then
3631955727d2SCortland Tölva    have_usbfs=yes
3632955727d2SCortland Tölva  fi
3633955727d2SCortland Tölvafi
3634751bcc39SMarc-André Lureau
3635d0927938SUlrich Hecht# check for fallocate
3636d0927938SUlrich Hechtfallocate=no
3637d0927938SUlrich Hechtcat > $TMPC << EOF
3638d0927938SUlrich Hecht#include <fcntl.h>
3639d0927938SUlrich Hecht
3640d0927938SUlrich Hechtint main(void)
3641d0927938SUlrich Hecht{
3642d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
3643d0927938SUlrich Hecht    return 0;
3644d0927938SUlrich Hecht}
3645d0927938SUlrich HechtEOF
36468fb03151SPeter Maydellif compile_prog "" "" ; then
3647d0927938SUlrich Hecht  fallocate=yes
3648d0927938SUlrich Hechtfi
3649d0927938SUlrich Hecht
36503d4fa43eSKusanagi Kouichi# check for fallocate hole punching
36513d4fa43eSKusanagi Kouichifallocate_punch_hole=no
36523d4fa43eSKusanagi Kouichicat > $TMPC << EOF
36533d4fa43eSKusanagi Kouichi#include <fcntl.h>
36543d4fa43eSKusanagi Kouichi#include <linux/falloc.h>
36553d4fa43eSKusanagi Kouichi
36563d4fa43eSKusanagi Kouichiint main(void)
36573d4fa43eSKusanagi Kouichi{
36583d4fa43eSKusanagi Kouichi    fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
36593d4fa43eSKusanagi Kouichi    return 0;
36603d4fa43eSKusanagi Kouichi}
36613d4fa43eSKusanagi KouichiEOF
36623d4fa43eSKusanagi Kouichiif compile_prog "" "" ; then
36633d4fa43eSKusanagi Kouichi  fallocate_punch_hole=yes
36643d4fa43eSKusanagi Kouichifi
36653d4fa43eSKusanagi Kouichi
3666b953f075SDenis V. Lunev# check that fallocate supports range zeroing inside the file
3667b953f075SDenis V. Lunevfallocate_zero_range=no
3668b953f075SDenis V. Lunevcat > $TMPC << EOF
3669b953f075SDenis V. Lunev#include <fcntl.h>
3670b953f075SDenis V. Lunev#include <linux/falloc.h>
3671b953f075SDenis V. Lunev
3672b953f075SDenis V. Lunevint main(void)
3673b953f075SDenis V. Lunev{
3674b953f075SDenis V. Lunev    fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
3675b953f075SDenis V. Lunev    return 0;
3676b953f075SDenis V. Lunev}
3677b953f075SDenis V. LunevEOF
3678b953f075SDenis V. Lunevif compile_prog "" "" ; then
3679b953f075SDenis V. Lunev  fallocate_zero_range=yes
3680b953f075SDenis V. Lunevfi
3681b953f075SDenis V. Lunev
3682ed911435SKevin Wolf# check for posix_fallocate
3683ed911435SKevin Wolfposix_fallocate=no
3684ed911435SKevin Wolfcat > $TMPC << EOF
3685ed911435SKevin Wolf#include <fcntl.h>
3686ed911435SKevin Wolf
3687ed911435SKevin Wolfint main(void)
3688ed911435SKevin Wolf{
3689ed911435SKevin Wolf    posix_fallocate(0, 0, 0);
3690ed911435SKevin Wolf    return 0;
3691ed911435SKevin Wolf}
3692ed911435SKevin WolfEOF
3693ed911435SKevin Wolfif compile_prog "" "" ; then
3694ed911435SKevin Wolf    posix_fallocate=yes
3695ed911435SKevin Wolffi
3696ed911435SKevin Wolf
3697c727f47dSPeter Maydell# check for sync_file_range
3698c727f47dSPeter Maydellsync_file_range=no
3699c727f47dSPeter Maydellcat > $TMPC << EOF
3700c727f47dSPeter Maydell#include <fcntl.h>
3701c727f47dSPeter Maydell
3702c727f47dSPeter Maydellint main(void)
3703c727f47dSPeter Maydell{
3704c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
3705c727f47dSPeter Maydell    return 0;
3706c727f47dSPeter Maydell}
3707c727f47dSPeter MaydellEOF
37088fb03151SPeter Maydellif compile_prog "" "" ; then
3709c727f47dSPeter Maydell  sync_file_range=yes
3710c727f47dSPeter Maydellfi
3711c727f47dSPeter Maydell
3712dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
3713dace20dcSPeter Maydellfiemap=no
3714dace20dcSPeter Maydellcat > $TMPC << EOF
3715dace20dcSPeter Maydell#include <sys/ioctl.h>
3716dace20dcSPeter Maydell#include <linux/fs.h>
3717dace20dcSPeter Maydell#include <linux/fiemap.h>
3718dace20dcSPeter Maydell
3719dace20dcSPeter Maydellint main(void)
3720dace20dcSPeter Maydell{
3721dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
3722dace20dcSPeter Maydell    return 0;
3723dace20dcSPeter Maydell}
3724dace20dcSPeter MaydellEOF
37258fb03151SPeter Maydellif compile_prog "" "" ; then
3726dace20dcSPeter Maydell  fiemap=yes
3727dace20dcSPeter Maydellfi
3728dace20dcSPeter Maydell
3729d0927938SUlrich Hecht# check for dup3
3730d0927938SUlrich Hechtdup3=no
3731d0927938SUlrich Hechtcat > $TMPC << EOF
3732d0927938SUlrich Hecht#include <unistd.h>
3733d0927938SUlrich Hecht
3734d0927938SUlrich Hechtint main(void)
3735d0927938SUlrich Hecht{
3736d0927938SUlrich Hecht    dup3(0, 0, 0);
3737d0927938SUlrich Hecht    return 0;
3738d0927938SUlrich Hecht}
3739d0927938SUlrich HechtEOF
374078f5d726SJan Kiszkaif compile_prog "" "" ; then
3741d0927938SUlrich Hecht  dup3=yes
3742d0927938SUlrich Hechtfi
3743d0927938SUlrich Hecht
37444e0c6529SAlex Bligh# check for ppoll support
37454e0c6529SAlex Blighppoll=no
37464e0c6529SAlex Blighcat > $TMPC << EOF
37474e0c6529SAlex Bligh#include <poll.h>
37484e0c6529SAlex Bligh
37494e0c6529SAlex Blighint main(void)
37504e0c6529SAlex Bligh{
37514e0c6529SAlex Bligh    struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
37524e0c6529SAlex Bligh    ppoll(&pfd, 1, 0, 0);
37534e0c6529SAlex Bligh    return 0;
37544e0c6529SAlex Bligh}
37554e0c6529SAlex BlighEOF
37564e0c6529SAlex Blighif compile_prog "" "" ; then
37574e0c6529SAlex Bligh  ppoll=yes
37584e0c6529SAlex Blighfi
37594e0c6529SAlex Bligh
3760cd758dd0SAlex Bligh# check for prctl(PR_SET_TIMERSLACK , ... ) support
3761cd758dd0SAlex Blighprctl_pr_set_timerslack=no
3762cd758dd0SAlex Blighcat > $TMPC << EOF
3763cd758dd0SAlex Bligh#include <sys/prctl.h>
3764cd758dd0SAlex Bligh
3765cd758dd0SAlex Blighint main(void)
3766cd758dd0SAlex Bligh{
3767cd758dd0SAlex Bligh    prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
3768cd758dd0SAlex Bligh    return 0;
3769cd758dd0SAlex Bligh}
3770cd758dd0SAlex BlighEOF
3771cd758dd0SAlex Blighif compile_prog "" "" ; then
3772cd758dd0SAlex Bligh  prctl_pr_set_timerslack=yes
3773cd758dd0SAlex Blighfi
3774cd758dd0SAlex Bligh
37753b6edd16SPeter Maydell# check for epoll support
37763b6edd16SPeter Maydellepoll=no
37773b6edd16SPeter Maydellcat > $TMPC << EOF
37783b6edd16SPeter Maydell#include <sys/epoll.h>
37793b6edd16SPeter Maydell
37803b6edd16SPeter Maydellint main(void)
37813b6edd16SPeter Maydell{
37823b6edd16SPeter Maydell    epoll_create(0);
37833b6edd16SPeter Maydell    return 0;
37843b6edd16SPeter Maydell}
37853b6edd16SPeter MaydellEOF
37868fb03151SPeter Maydellif compile_prog "" "" ; then
37873b6edd16SPeter Maydell  epoll=yes
37883b6edd16SPeter Maydellfi
37893b6edd16SPeter Maydell
3790227f0214SPeter Maydell# epoll_create1 is a later addition
3791227f0214SPeter Maydell# so we must check separately for its presence
37923b6edd16SPeter Maydellepoll_create1=no
37933b6edd16SPeter Maydellcat > $TMPC << EOF
37943b6edd16SPeter Maydell#include <sys/epoll.h>
37953b6edd16SPeter Maydell
37963b6edd16SPeter Maydellint main(void)
37973b6edd16SPeter Maydell{
379819e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
379919e83f6bSPeter Maydell     * a function being called. This is necessary so that on
380019e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
380119e83f6bSPeter Maydell     * the library but not declared in the header file we will
380219e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
380319e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
380419e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
380519e83f6bSPeter Maydell     */
3806c075a723SBlue Swirl    return (int)(uintptr_t)&epoll_create1;
38073b6edd16SPeter Maydell}
38083b6edd16SPeter MaydellEOF
38098fb03151SPeter Maydellif compile_prog "" "" ; then
38103b6edd16SPeter Maydell  epoll_create1=yes
38113b6edd16SPeter Maydellfi
38123b6edd16SPeter Maydell
3813a8fd1abaSPeter Maydell# check for sendfile support
3814a8fd1abaSPeter Maydellsendfile=no
3815a8fd1abaSPeter Maydellcat > $TMPC << EOF
3816a8fd1abaSPeter Maydell#include <sys/sendfile.h>
3817a8fd1abaSPeter Maydell
3818a8fd1abaSPeter Maydellint main(void)
3819a8fd1abaSPeter Maydell{
3820a8fd1abaSPeter Maydell    return sendfile(0, 0, 0, 0);
3821a8fd1abaSPeter Maydell}
3822a8fd1abaSPeter MaydellEOF
3823a8fd1abaSPeter Maydellif compile_prog "" "" ; then
3824a8fd1abaSPeter Maydell  sendfile=yes
3825a8fd1abaSPeter Maydellfi
3826a8fd1abaSPeter Maydell
382751834341SRiku Voipio# check for timerfd support (glibc 2.8 and newer)
382851834341SRiku Voipiotimerfd=no
382951834341SRiku Voipiocat > $TMPC << EOF
383051834341SRiku Voipio#include <sys/timerfd.h>
383151834341SRiku Voipio
383251834341SRiku Voipioint main(void)
383351834341SRiku Voipio{
383451834341SRiku Voipio    return(timerfd_create(CLOCK_REALTIME, 0));
383551834341SRiku Voipio}
383651834341SRiku VoipioEOF
383751834341SRiku Voipioif compile_prog "" "" ; then
383851834341SRiku Voipio  timerfd=yes
383951834341SRiku Voipiofi
384051834341SRiku Voipio
38419af5c906SRiku Voipio# check for setns and unshare support
38429af5c906SRiku Voipiosetns=no
38439af5c906SRiku Voipiocat > $TMPC << EOF
38449af5c906SRiku Voipio#include <sched.h>
38459af5c906SRiku Voipio
38469af5c906SRiku Voipioint main(void)
38479af5c906SRiku Voipio{
38489af5c906SRiku Voipio    int ret;
38499af5c906SRiku Voipio    ret = setns(0, 0);
38509af5c906SRiku Voipio    ret = unshare(0);
38519af5c906SRiku Voipio    return ret;
38529af5c906SRiku Voipio}
38539af5c906SRiku VoipioEOF
38549af5c906SRiku Voipioif compile_prog "" "" ; then
38559af5c906SRiku Voipio  setns=yes
38569af5c906SRiku Voipiofi
38579af5c906SRiku Voipio
385838860a03SAleksandar Markovic# clock_adjtime probe
385938860a03SAleksandar Markovicclock_adjtime=no
386038860a03SAleksandar Markoviccat > $TMPC <<EOF
386138860a03SAleksandar Markovic#include <time.h>
3862cd5d20efSJiaxun Yang#include <sys/timex.h>
386338860a03SAleksandar Markovic
386438860a03SAleksandar Markovicint main(void)
386538860a03SAleksandar Markovic{
386638860a03SAleksandar Markovic    return clock_adjtime(0, 0);
386738860a03SAleksandar Markovic}
386838860a03SAleksandar MarkovicEOF
386938860a03SAleksandar Markovicclock_adjtime=no
387038860a03SAleksandar Markovicif compile_prog "" "" ; then
387138860a03SAleksandar Markovic  clock_adjtime=yes
387238860a03SAleksandar Markovicfi
387338860a03SAleksandar Markovic
38745a03cd00SAleksandar Markovic# syncfs probe
38755a03cd00SAleksandar Markovicsyncfs=no
38765a03cd00SAleksandar Markoviccat > $TMPC <<EOF
38775a03cd00SAleksandar Markovic#include <unistd.h>
38785a03cd00SAleksandar Markovic
38795a03cd00SAleksandar Markovicint main(void)
38805a03cd00SAleksandar Markovic{
38815a03cd00SAleksandar Markovic    return syncfs(0);
38825a03cd00SAleksandar Markovic}
38835a03cd00SAleksandar MarkovicEOF
38845a03cd00SAleksandar Markovicsyncfs=no
38855a03cd00SAleksandar Markovicif compile_prog "" "" ; then
38865a03cd00SAleksandar Markovic  syncfs=yes
38875a03cd00SAleksandar Markovicfi
38885a03cd00SAleksandar Markovic
3889f514f41cSStefan Weil# Search for bswap_32 function
38906ae9a1f4SJuan Quintelabyteswap_h=no
38916ae9a1f4SJuan Quintelacat > $TMPC << EOF
38926ae9a1f4SJuan Quintela#include <byteswap.h>
38936ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
38946ae9a1f4SJuan QuintelaEOF
389552166aa0SJuan Quintelaif compile_prog "" "" ; then
38966ae9a1f4SJuan Quintela  byteswap_h=yes
38976ae9a1f4SJuan Quintelafi
38986ae9a1f4SJuan Quintela
389975f13596SStefan Weil# Search for bswap32 function
39006ae9a1f4SJuan Quintelabswap_h=no
39016ae9a1f4SJuan Quintelacat > $TMPC << EOF
39026ae9a1f4SJuan Quintela#include <sys/endian.h>
39036ae9a1f4SJuan Quintela#include <sys/types.h>
39046ae9a1f4SJuan Quintela#include <machine/bswap.h>
39056ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
39066ae9a1f4SJuan QuintelaEOF
390752166aa0SJuan Quintelaif compile_prog "" "" ; then
39086ae9a1f4SJuan Quintela  bswap_h=yes
39096ae9a1f4SJuan Quintelafi
39106ae9a1f4SJuan Quintela
3911f2995ee4SPaolo Bonzini# Check whether we have openpty() in either libc or libutil
3912d99e97e6SThomas Huthcat > $TMPC << EOF
3913d99e97e6SThomas Huthextern int openpty(int *am, int *as, char *name, void *termp, void *winp);
3914d99e97e6SThomas Huthint main(void) { return openpty(0, 0, 0, 0, 0); }
3915d99e97e6SThomas HuthEOF
3916d99e97e6SThomas Huth
39179df8b20dSThomas Huthhave_openpty="no"
39189df8b20dSThomas Huthif compile_prog "" "" ; then
39199df8b20dSThomas Huth  have_openpty="yes"
39209df8b20dSThomas Huthelse
3921d99e97e6SThomas Huth  if compile_prog "" "-lutil" ; then
39229df8b20dSThomas Huth    have_openpty="yes"
3923d99e97e6SThomas Huth  fi
39246362a53fSJuan Quintelafi
39256362a53fSJuan Quintela
3926de5071c5SBlue Swirl##########################################
3927cd4ec0b4SGerd Hoffmann# spice probe
392858d3f3ffSGerd Hoffmannif test "$spice_protocol" != "no" ; then
392958d3f3ffSGerd Hoffmann  spice_protocol_cflags=$($pkg_config --cflags spice-protocol 2>/dev/null)
393058d3f3ffSGerd Hoffmann  if $pkg_config --atleast-version=0.12.3 spice-protocol; then
393158d3f3ffSGerd Hoffmann    spice_protocol="yes"
393258d3f3ffSGerd Hoffmann  else
393358d3f3ffSGerd Hoffmann    if test "$spice_protocol" = "yes" ; then
393458d3f3ffSGerd Hoffmann      feature_not_found "spice_protocol" \
393558d3f3ffSGerd Hoffmann          "Install spice-protocol(>=0.12.3) devel"
393658d3f3ffSGerd Hoffmann    fi
393758d3f3ffSGerd Hoffmann    spice_protocol="no"
393858d3f3ffSGerd Hoffmann  fi
393958d3f3ffSGerd Hoffmannfi
394058d3f3ffSGerd Hoffmann
3941cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
3942cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
3943cd4ec0b4SGerd Hoffmann#include <spice.h>
3944cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
3945cd4ec0b4SGerd HoffmannEOF
3946710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
3947710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
39481b63665cSMarc-André Lureau  if $pkg_config --atleast-version=0.12.5 spice-server && \
394958d3f3ffSGerd Hoffmann     test "$spice_protocol" = "yes" && \
3950cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
3951cd4ec0b4SGerd Hoffmann    spice="yes"
3952cd4ec0b4SGerd Hoffmann  else
3953cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
39548efc9363SHu Tao      feature_not_found "spice" \
395558d3f3ffSGerd Hoffmann          "Install spice-server(>=0.12.5) devel"
3956cd4ec0b4SGerd Hoffmann    fi
3957cd4ec0b4SGerd Hoffmann    spice="no"
3958cd4ec0b4SGerd Hoffmann  fi
3959cd4ec0b4SGerd Hoffmannfi
3960cd4ec0b4SGerd Hoffmann
3961cd4ec0b4SGerd Hoffmann##########################################
3962d9840e25STomoki Sekiyama# check if we have VSS SDK headers for win
3963d9840e25STomoki Sekiyama
3964e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
3965e633a5c6SEric Blake        test "$vss_win32_sdk" != "no" ; then
3966d9840e25STomoki Sekiyama  case "$vss_win32_sdk" in
3967690604f6SMichael Roth    "")   vss_win32_include="-isystem $source_path" ;;
3968d9840e25STomoki Sekiyama    *\ *) # The SDK is installed in "Program Files" by default, but we cannot
3969d9840e25STomoki Sekiyama          # handle path with spaces. So we symlink the headers into ".sdk/vss".
3970690604f6SMichael Roth          vss_win32_include="-isystem $source_path/.sdk/vss"
3971d9840e25STomoki Sekiyama	  symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
3972d9840e25STomoki Sekiyama	  ;;
3973690604f6SMichael Roth    *)    vss_win32_include="-isystem $vss_win32_sdk"
3974d9840e25STomoki Sekiyama  esac
3975d9840e25STomoki Sekiyama  cat > $TMPC << EOF
3976d9840e25STomoki Sekiyama#define __MIDL_user_allocate_free_DEFINED__
3977d9840e25STomoki Sekiyama#include <inc/win2003/vss.h>
3978d9840e25STomoki Sekiyamaint main(void) { return VSS_CTX_BACKUP; }
3979d9840e25STomoki SekiyamaEOF
3980d9840e25STomoki Sekiyama  if compile_prog "$vss_win32_include" "" ; then
3981d9840e25STomoki Sekiyama    guest_agent_with_vss="yes"
3982d9840e25STomoki Sekiyama    QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
3983315d3184SFam Zheng    libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
3984f33ca81fSMichael Roth    qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
3985d9840e25STomoki Sekiyama  else
3986d9840e25STomoki Sekiyama    if test "$vss_win32_sdk" != "" ; then
3987d9840e25STomoki Sekiyama      echo "ERROR: Please download and install Microsoft VSS SDK:"
3988d9840e25STomoki Sekiyama      echo "ERROR:   http://www.microsoft.com/en-us/download/details.aspx?id=23490"
3989d9840e25STomoki Sekiyama      echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
3990d9840e25STomoki Sekiyama      echo "ERROR:   scripts/extract-vsssdk-headers setup.exe"
3991d9840e25STomoki Sekiyama      echo "ERROR: The headers are extracted in the directory \`inc'."
3992d9840e25STomoki Sekiyama      feature_not_found "VSS support"
3993d9840e25STomoki Sekiyama    fi
3994d9840e25STomoki Sekiyama    guest_agent_with_vss="no"
3995d9840e25STomoki Sekiyama  fi
3996d9840e25STomoki Sekiyamafi
3997d9840e25STomoki Sekiyama
3998d9840e25STomoki Sekiyama##########################################
3999d9840e25STomoki Sekiyama# lookup Windows platform SDK (if not specified)
4000d9840e25STomoki Sekiyama# The SDK is needed only to build .tlb (type library) file of guest agent
4001d9840e25STomoki Sekiyama# VSS provider from the source. It is usually unnecessary because the
4002d9840e25STomoki Sekiyama# pre-compiled .tlb file is included.
4003d9840e25STomoki Sekiyama
4004e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
4005e633a5c6SEric Blake        test "$guest_agent_with_vss" = "yes" ; then
4006d9840e25STomoki Sekiyama  if test -z "$win_sdk"; then
4007d9840e25STomoki Sekiyama    programfiles="$PROGRAMFILES"
4008d9840e25STomoki Sekiyama    test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
4009d9840e25STomoki Sekiyama    if test -n "$programfiles"; then
4010d9840e25STomoki Sekiyama      win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
4011d9840e25STomoki Sekiyama    else
4012d9840e25STomoki Sekiyama      feature_not_found "Windows SDK"
4013d9840e25STomoki Sekiyama    fi
4014d9840e25STomoki Sekiyama  elif test "$win_sdk" = "no"; then
4015d9840e25STomoki Sekiyama    win_sdk=""
4016d9840e25STomoki Sekiyama  fi
4017d9840e25STomoki Sekiyamafi
4018d9840e25STomoki Sekiyama
4019d9840e25STomoki Sekiyama##########################################
402050cbebb9SMichael Roth# check if mingw environment provides a recent ntddscsi.h
4021e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no"; then
402250cbebb9SMichael Roth  cat > $TMPC << EOF
402350cbebb9SMichael Roth#include <windows.h>
402450cbebb9SMichael Roth#include <ntddscsi.h>
402550cbebb9SMichael Rothint main(void) {
402650cbebb9SMichael Roth#if !defined(IOCTL_SCSI_GET_ADDRESS)
402750cbebb9SMichael Roth#error Missing required ioctl definitions
402850cbebb9SMichael Roth#endif
402950cbebb9SMichael Roth  SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
403050cbebb9SMichael Roth  return addr.Lun;
403150cbebb9SMichael Roth}
403250cbebb9SMichael RothEOF
403350cbebb9SMichael Roth  if compile_prog "" "" ; then
403450cbebb9SMichael Roth    guest_agent_ntddscsi=yes
4035996b9cdcSMatt Hines    libs_qga="-lsetupapi -lcfgmgr32 $libs_qga"
403650cbebb9SMichael Roth  fi
403750cbebb9SMichael Rothfi
403850cbebb9SMichael Roth
403950cbebb9SMichael Roth##########################################
40408ca80760SRichard Henderson# capstone
40418ca80760SRichard Henderson
4042e219c499SRichard Hendersoncase "$capstone" in
40438b18cdbfSRichard Henderson  auto | enabled | internal)
40448b18cdbfSRichard Henderson    # Simpler to always update submodule, even if not needed.
4045e219c499SRichard Henderson    git_submodules="${git_submodules} capstone"
4046e219c499SRichard Henderson    ;;
4047e219c499SRichard Hendersonesac
40488ca80760SRichard Henderson
40498ca80760SRichard Henderson##########################################
40505f6b9e8fSBlue Swirl# check if we have fdatasync
40515f6b9e8fSBlue Swirl
40525f6b9e8fSBlue Swirlfdatasync=no
40535f6b9e8fSBlue Swirlcat > $TMPC << EOF
40545f6b9e8fSBlue Swirl#include <unistd.h>
4055d1722a27SAlexandre Raymondint main(void) {
4056d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
4057d1722a27SAlexandre Raymondreturn fdatasync(0);
4058d1722a27SAlexandre Raymond#else
4059e172fe11SStefan Weil#error Not supported
4060d1722a27SAlexandre Raymond#endif
4061d1722a27SAlexandre Raymond}
40625f6b9e8fSBlue SwirlEOF
40635f6b9e8fSBlue Swirlif compile_prog "" "" ; then
40645f6b9e8fSBlue Swirl    fdatasync=yes
40655f6b9e8fSBlue Swirlfi
40665f6b9e8fSBlue Swirl
406794a420b1SStefan Hajnoczi##########################################
4068e78815a5SAndreas Färber# check if we have madvise
4069e78815a5SAndreas Färber
4070e78815a5SAndreas Färbermadvise=no
4071e78815a5SAndreas Färbercat > $TMPC << EOF
4072e78815a5SAndreas Färber#include <sys/types.h>
4073e78815a5SAndreas Färber#include <sys/mman.h>
4074832ce9c2SScott Wood#include <stddef.h>
4075e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
4076e78815a5SAndreas FärberEOF
4077e78815a5SAndreas Färberif compile_prog "" "" ; then
4078e78815a5SAndreas Färber    madvise=yes
4079e78815a5SAndreas Färberfi
4080e78815a5SAndreas Färber
4081e78815a5SAndreas Färber##########################################
4082e78815a5SAndreas Färber# check if we have posix_madvise
4083e78815a5SAndreas Färber
4084e78815a5SAndreas Färberposix_madvise=no
4085e78815a5SAndreas Färbercat > $TMPC << EOF
4086e78815a5SAndreas Färber#include <sys/mman.h>
4087832ce9c2SScott Wood#include <stddef.h>
4088e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
4089e78815a5SAndreas FärberEOF
4090e78815a5SAndreas Färberif compile_prog "" "" ; then
4091e78815a5SAndreas Färber    posix_madvise=yes
4092e78815a5SAndreas Färberfi
4093e78815a5SAndreas Färber
4094e78815a5SAndreas Färber##########################################
40959bc5a719SAndreas Gustafsson# check if we have posix_memalign()
40969bc5a719SAndreas Gustafsson
40979bc5a719SAndreas Gustafssonposix_memalign=no
40989bc5a719SAndreas Gustafssoncat > $TMPC << EOF
40999bc5a719SAndreas Gustafsson#include <stdlib.h>
41009bc5a719SAndreas Gustafssonint main(void) {
41019bc5a719SAndreas Gustafsson    void *p;
41029bc5a719SAndreas Gustafsson    return posix_memalign(&p, 8, 8);
41039bc5a719SAndreas Gustafsson}
41049bc5a719SAndreas GustafssonEOF
41059bc5a719SAndreas Gustafssonif compile_prog "" "" ; then
41069bc5a719SAndreas Gustafsson    posix_memalign=yes
41079bc5a719SAndreas Gustafssonfi
41089bc5a719SAndreas Gustafsson
41099bc5a719SAndreas Gustafsson##########################################
41100a852417SPaul Durrant# check if we have posix_syslog
41110a852417SPaul Durrant
41120a852417SPaul Durrantposix_syslog=no
41130a852417SPaul Durrantcat > $TMPC << EOF
41140a852417SPaul Durrant#include <syslog.h>
41150a852417SPaul Durrantint main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
41160a852417SPaul DurrantEOF
41170a852417SPaul Durrantif compile_prog "" "" ; then
41180a852417SPaul Durrant    posix_syslog=yes
41190a852417SPaul Durrantfi
41200a852417SPaul Durrant
41210a852417SPaul Durrant##########################################
4122401bc051SPeter Maydell# check if we have sem_timedwait
4123401bc051SPeter Maydell
4124401bc051SPeter Maydellsem_timedwait=no
4125401bc051SPeter Maydellcat > $TMPC << EOF
4126401bc051SPeter Maydell#include <semaphore.h>
4127811294b7SDaniel P. Berrangéint main(void) { sem_t s; struct timespec t = {0}; return sem_timedwait(&s, &t); }
4128401bc051SPeter MaydellEOF
4129401bc051SPeter Maydellif compile_prog "" "" ; then
4130401bc051SPeter Maydell    sem_timedwait=yes
4131401bc051SPeter Maydellfi
4132401bc051SPeter Maydell
4133401bc051SPeter Maydell##########################################
41345c99fa37SKeno Fischer# check if we have strchrnul
41355c99fa37SKeno Fischer
41365c99fa37SKeno Fischerstrchrnul=no
41375c99fa37SKeno Fischercat > $TMPC << EOF
41385c99fa37SKeno Fischer#include <string.h>
41395c99fa37SKeno Fischerint main(void);
41405c99fa37SKeno Fischer// Use a haystack that the compiler shouldn't be able to constant fold
41415c99fa37SKeno Fischerchar *haystack = (char*)&main;
41425c99fa37SKeno Fischerint main(void) { return strchrnul(haystack, 'x') != &haystack[6]; }
41435c99fa37SKeno FischerEOF
41445c99fa37SKeno Fischerif compile_prog "" "" ; then
41455c99fa37SKeno Fischer    strchrnul=yes
41465c99fa37SKeno Fischerfi
41475c99fa37SKeno Fischer
41488a792b03SJiufei Xue#########################################
41498a792b03SJiufei Xue# check if we have st_atim
41508a792b03SJiufei Xue
41518a792b03SJiufei Xuest_atim=no
41528a792b03SJiufei Xuecat > $TMPC << EOF
41538a792b03SJiufei Xue#include <sys/stat.h>
41548a792b03SJiufei Xue#include <stddef.h>
41558a792b03SJiufei Xueint main(void) { return offsetof(struct stat, st_atim); }
41568a792b03SJiufei XueEOF
41578a792b03SJiufei Xueif compile_prog "" "" ; then
41588a792b03SJiufei Xue    st_atim=yes
41598a792b03SJiufei Xuefi
41608a792b03SJiufei Xue
41615c99fa37SKeno Fischer##########################################
416296ff758cSMichael Forney# check if we have sigev_notify_thread_id
416396ff758cSMichael Forney
416496ff758cSMichael Forneysigev_notify_thread_id=no
416596ff758cSMichael Forneycat > $TMPC << EOF
416696ff758cSMichael Forney#include <stddef.h>
416796ff758cSMichael Forney#include <signal.h>
416896ff758cSMichael Forneyint main(void) { return offsetof(struct sigevent, sigev_notify_thread_id); }
416996ff758cSMichael ForneyEOF
417096ff758cSMichael Forneyif compile_prog "" "" ; then
417196ff758cSMichael Forney    sigev_notify_thread_id=yes
417296ff758cSMichael Forneyfi
417396ff758cSMichael Forney
417496ff758cSMichael Forney##########################################
417594a420b1SStefan Hajnoczi# check if trace backend exists
417694a420b1SStefan Hajnoczi
41775b808275SLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends  > /dev/null 2> /dev/null
417894a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
41795b808275SLluís Vilanova  error_exit "invalid trace backends" \
41805b808275SLluís Vilanova      "Please choose supported trace backends."
418194a420b1SStefan Hajnoczifi
418294a420b1SStefan Hajnoczi
41837e24e92aSStefan Hajnoczi##########################################
41847e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
41855b808275SLluís Vilanovaif have_backend "ust"; then
41867e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
4187bf15f63cSMohamad Gebai#include <lttng/tracepoint.h>
41887e24e92aSStefan Hajnocziint main(void) { return 0; }
41897e24e92aSStefan HajnocziEOF
4190c79ed23dSFrancis Deslauriers  if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
4191bf15f63cSMohamad Gebai    if $pkg_config lttng-ust --exists; then
419289138857SStefan Weil      lttng_ust_libs=$($pkg_config --libs lttng-ust)
41937e24e92aSStefan Hajnoczi    else
4194c79ed23dSFrancis Deslauriers      lttng_ust_libs="-llttng-ust -ldl"
4195bf15f63cSMohamad Gebai    fi
4196bf15f63cSMohamad Gebai    if $pkg_config liburcu-bp --exists; then
419789138857SStefan Weil      urcu_bp_libs=$($pkg_config --libs liburcu-bp)
4198bf15f63cSMohamad Gebai    else
4199bf15f63cSMohamad Gebai      urcu_bp_libs="-lurcu-bp"
4200bf15f63cSMohamad Gebai    fi
4201bf15f63cSMohamad Gebai  else
4202bf15f63cSMohamad Gebai    error_exit "Trace backend 'ust' missing lttng-ust header files"
42037e24e92aSStefan Hajnoczi  fi
42047e24e92aSStefan Hajnoczifi
4205b3d08c02SDaniel P. Berrange
4206b3d08c02SDaniel P. Berrange##########################################
4207b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
42085b808275SLluís Vilanovaif have_backend "dtrace"; then
4209b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
421076ad07a4SPeter Maydell    error_exit "dtrace command is not found in PATH $PATH"
4211b3d08c02SDaniel P. Berrange  fi
4212c276b17dSDaniel P. Berrange  trace_backend_stap="no"
4213c276b17dSDaniel P. Berrange  if has 'stap' ; then
4214c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
42154b265c79SStefan Hajnoczi
42164b265c79SStefan Hajnoczi    # Workaround to avoid dtrace(1) producing a file with 'hidden' symbol
42174b265c79SStefan Hajnoczi    # visibility. Define STAP_SDT_V2 to produce 'default' symbol visibility
42184b265c79SStefan Hajnoczi    # instead. QEMU --enable-modules depends on this because the SystemTap
42194b265c79SStefan Hajnoczi    # semaphores are linked into the main binary and not the module's shared
42204b265c79SStefan Hajnoczi    # object.
42214b265c79SStefan Hajnoczi    QEMU_CFLAGS="$QEMU_CFLAGS -DSTAP_SDT_V2"
4222c276b17dSDaniel P. Berrange  fi
4223b3d08c02SDaniel P. Berrangefi
4224b3d08c02SDaniel P. Berrange
42257e24e92aSStefan Hajnoczi##########################################
4226519175a2SAlex Barcelo# check and set a backend for coroutine
4227d0e2fce5SAneesh Kumar K.V
42287c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback
422933c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows
423033c53c54SDaniel P. Berrange# specific one.
42317c2acc70SPeter Maydell
42327c2acc70SPeter Maydellucontext_works=no
4233d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
4234d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
4235d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
4236cdf84806SPeter Maydell#ifdef __stub_makecontext
4237cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
4238cdf84806SPeter Maydell#endif
423975cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
4240d0e2fce5SAneesh Kumar K.VEOF
4241d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
42427c2acc70SPeter Maydell    ucontext_works=yes
4243d0e2fce5SAneesh Kumar K.V  fi
4244519175a2SAlex Barcelofi
42457c2acc70SPeter Maydell
42467c2acc70SPeter Maydellif test "$coroutine" = ""; then
42477c2acc70SPeter Maydell  if test "$mingw32" = "yes"; then
42487c2acc70SPeter Maydell    coroutine=win32
42497c2acc70SPeter Maydell  elif test "$ucontext_works" = "yes"; then
42507c2acc70SPeter Maydell    coroutine=ucontext
4251519175a2SAlex Barcelo  else
42527c2acc70SPeter Maydell    coroutine=sigaltstack
42537c2acc70SPeter Maydell  fi
42547c2acc70SPeter Maydellelse
42557c2acc70SPeter Maydell  case $coroutine in
42567c2acc70SPeter Maydell  windows)
42577c2acc70SPeter Maydell    if test "$mingw32" != "yes"; then
42587c2acc70SPeter Maydell      error_exit "'windows' coroutine backend only valid for Windows"
42597c2acc70SPeter Maydell    fi
42607c2acc70SPeter Maydell    # Unfortunately the user visible backend name doesn't match the
42617c2acc70SPeter Maydell    # coroutine-*.c filename for this case, so we have to adjust it here.
42627c2acc70SPeter Maydell    coroutine=win32
42637c2acc70SPeter Maydell    ;;
42647c2acc70SPeter Maydell  ucontext)
42657c2acc70SPeter Maydell    if test "$ucontext_works" != "yes"; then
42667c2acc70SPeter Maydell      feature_not_found "ucontext"
42677c2acc70SPeter Maydell    fi
42687c2acc70SPeter Maydell    ;;
426933c53c54SDaniel P. Berrange  sigaltstack)
42707c2acc70SPeter Maydell    if test "$mingw32" = "yes"; then
42717c2acc70SPeter Maydell      error_exit "only the 'windows' coroutine backend is valid for Windows"
42727c2acc70SPeter Maydell    fi
42737c2acc70SPeter Maydell    ;;
42747c2acc70SPeter Maydell  *)
427576ad07a4SPeter Maydell    error_exit "unknown coroutine backend $coroutine"
42767c2acc70SPeter Maydell    ;;
42777c2acc70SPeter Maydell  esac
4278d0e2fce5SAneesh Kumar K.Vfi
4279d0e2fce5SAneesh Kumar K.V
428070c60c08SStefan Hajnocziif test "$coroutine_pool" = ""; then
428170c60c08SStefan Hajnoczi  coroutine_pool=yes
428270c60c08SStefan Hajnoczifi
428370c60c08SStefan Hajnoczi
42847d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes"; then
42857d992e4dSPeter Lieven  if test "$coroutine_pool" = "yes"; then
42867d992e4dSPeter Lieven    echo "WARN: disabling coroutine pool for stack usage debugging"
42877d992e4dSPeter Lieven    coroutine_pool=no
42887d992e4dSPeter Lieven  fi
42897d992e4dSPeter Lievenfi
42907d992e4dSPeter Lieven
42911e4f6065SDaniele Buono##################################################
42921e4f6065SDaniele Buono# SafeStack
42931e4f6065SDaniele Buono
42941e4f6065SDaniele Buono
42951e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then
42961e4f6065SDaniele Buonocat > $TMPC << EOF
42971e4f6065SDaniele Buonoint main(int argc, char *argv[])
42981e4f6065SDaniele Buono{
42991e4f6065SDaniele Buono#if ! __has_feature(safe_stack)
43001e4f6065SDaniele Buono#error SafeStack Disabled
43011e4f6065SDaniele Buono#endif
43021e4f6065SDaniele Buono    return 0;
43031e4f6065SDaniele Buono}
43041e4f6065SDaniele BuonoEOF
43051e4f6065SDaniele Buono  flag="-fsanitize=safe-stack"
43061e4f6065SDaniele Buono  # Check that safe-stack is supported and enabled.
43071e4f6065SDaniele Buono  if compile_prog "-Werror $flag" "$flag"; then
43081e4f6065SDaniele Buono    # Flag needed both at compilation and at linking
43091e4f6065SDaniele Buono    QEMU_CFLAGS="$QEMU_CFLAGS $flag"
43101e4f6065SDaniele Buono    QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
43111e4f6065SDaniele Buono  else
43121e4f6065SDaniele Buono    error_exit "SafeStack not supported by your compiler"
43131e4f6065SDaniele Buono  fi
43141e4f6065SDaniele Buono  if test "$coroutine" != "ucontext"; then
43151e4f6065SDaniele Buono    error_exit "SafeStack is only supported by the coroutine backend ucontext"
43161e4f6065SDaniele Buono  fi
43171e4f6065SDaniele Buonoelse
43181e4f6065SDaniele Buonocat > $TMPC << EOF
43191e4f6065SDaniele Buonoint main(int argc, char *argv[])
43201e4f6065SDaniele Buono{
43211e4f6065SDaniele Buono#if defined(__has_feature)
43221e4f6065SDaniele Buono#if __has_feature(safe_stack)
43231e4f6065SDaniele Buono#error SafeStack Enabled
43241e4f6065SDaniele Buono#endif
43251e4f6065SDaniele Buono#endif
43261e4f6065SDaniele Buono    return 0;
43271e4f6065SDaniele Buono}
43281e4f6065SDaniele BuonoEOF
43291e4f6065SDaniele Buonoif test "$safe_stack" = "no"; then
43301e4f6065SDaniele Buono  # Make sure that safe-stack is disabled
43311e4f6065SDaniele Buono  if ! compile_prog "-Werror" ""; then
43321e4f6065SDaniele Buono    # SafeStack was already enabled, try to explicitly remove the feature
43331e4f6065SDaniele Buono    flag="-fno-sanitize=safe-stack"
43341e4f6065SDaniele Buono    if ! compile_prog "-Werror $flag" "$flag"; then
43351e4f6065SDaniele Buono      error_exit "Configure cannot disable SafeStack"
43361e4f6065SDaniele Buono    fi
43371e4f6065SDaniele Buono    QEMU_CFLAGS="$QEMU_CFLAGS $flag"
43381e4f6065SDaniele Buono    QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
43391e4f6065SDaniele Buono  fi
43401e4f6065SDaniele Buonoelse # "$safe_stack" = ""
43411e4f6065SDaniele Buono  # Set safe_stack to yes or no based on pre-existing flags
43421e4f6065SDaniele Buono  if compile_prog "-Werror" ""; then
43431e4f6065SDaniele Buono    safe_stack="no"
43441e4f6065SDaniele Buono  else
43451e4f6065SDaniele Buono    safe_stack="yes"
43461e4f6065SDaniele Buono    if test "$coroutine" != "ucontext"; then
43471e4f6065SDaniele Buono      error_exit "SafeStack is only supported by the coroutine backend ucontext"
43481e4f6065SDaniele Buono    fi
43491e4f6065SDaniele Buono  fi
43501e4f6065SDaniele Buonofi
43511e4f6065SDaniele Buonofi
43527d992e4dSPeter Lieven
4353d0e2fce5SAneesh Kumar K.V##########################################
4354d2042378SAneesh Kumar K.V# check if we have open_by_handle_at
4355d2042378SAneesh Kumar K.V
43564e1797f9SStefan Weilopen_by_handle_at=no
4357d2042378SAneesh Kumar K.Vcat > $TMPC << EOF
4358d2042378SAneesh Kumar K.V#include <fcntl.h>
4359acc55ba8SStefan Weil#if !defined(AT_EMPTY_PATH)
4360acc55ba8SStefan Weil# error missing definition
4361acc55ba8SStefan Weil#else
436275cafad7SStefan Weilint main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
4363acc55ba8SStefan Weil#endif
4364d2042378SAneesh Kumar K.VEOF
4365d2042378SAneesh Kumar K.Vif compile_prog "" "" ; then
4366d2042378SAneesh Kumar K.V    open_by_handle_at=yes
4367d2042378SAneesh Kumar K.Vfi
4368d2042378SAneesh Kumar K.V
4369e06a765eSHarsh Prateek Bora########################################
4370e06a765eSHarsh Prateek Bora# check if we have linux/magic.h
4371e06a765eSHarsh Prateek Bora
4372e06a765eSHarsh Prateek Boralinux_magic_h=no
4373e06a765eSHarsh Prateek Boracat > $TMPC << EOF
4374e06a765eSHarsh Prateek Bora#include <linux/magic.h>
4375e06a765eSHarsh Prateek Boraint main(void) {
437675cafad7SStefan Weil  return 0;
4377e06a765eSHarsh Prateek Bora}
4378e06a765eSHarsh Prateek BoraEOF
4379e06a765eSHarsh Prateek Boraif compile_prog "" "" ; then
4380e06a765eSHarsh Prateek Bora    linux_magic_h=yes
4381e06a765eSHarsh Prateek Borafi
4382e06a765eSHarsh Prateek Bora
43838ab1bf12SLuiz Capitulino########################################
4384541be927SChristian Borntraeger# check if we have valgrind/valgrind.h
43853f4349dcSKevin Wolf
43863f4349dcSKevin Wolfvalgrind_h=no
43873f4349dcSKevin Wolfcat > $TMPC << EOF
43883f4349dcSKevin Wolf#include <valgrind/valgrind.h>
43893f4349dcSKevin Wolfint main(void) {
43903f4349dcSKevin Wolf  return 0;
43913f4349dcSKevin Wolf}
43923f4349dcSKevin WolfEOF
43933f4349dcSKevin Wolfif compile_prog "" "" ; then
43943f4349dcSKevin Wolf    valgrind_h=yes
43953f4349dcSKevin Wolffi
43963f4349dcSKevin Wolf
43973f4349dcSKevin Wolf########################################
43988ab1bf12SLuiz Capitulino# check if environ is declared
43998ab1bf12SLuiz Capitulino
44008ab1bf12SLuiz Capitulinohas_environ=no
44018ab1bf12SLuiz Capitulinocat > $TMPC << EOF
44028ab1bf12SLuiz Capitulino#include <unistd.h>
44038ab1bf12SLuiz Capitulinoint main(void) {
4404c075a723SBlue Swirl    environ = 0;
44058ab1bf12SLuiz Capitulino    return 0;
44068ab1bf12SLuiz Capitulino}
44078ab1bf12SLuiz CapitulinoEOF
44088ab1bf12SLuiz Capitulinoif compile_prog "" "" ; then
44098ab1bf12SLuiz Capitulino    has_environ=yes
44108ab1bf12SLuiz Capitulinofi
44118ab1bf12SLuiz Capitulino
441276a347e1SRichard Henderson########################################
441376a347e1SRichard Henderson# check if cpuid.h is usable.
441476a347e1SRichard Henderson
441576a347e1SRichard Hendersoncat > $TMPC << EOF
441676a347e1SRichard Henderson#include <cpuid.h>
441776a347e1SRichard Hendersonint main(void) {
4418774d566cSPeter Maydell    unsigned a, b, c, d;
4419774d566cSPeter Maydell    int max = __get_cpuid_max(0, 0);
4420774d566cSPeter Maydell
4421774d566cSPeter Maydell    if (max >= 1) {
4422774d566cSPeter Maydell        __cpuid(1, a, b, c, d);
4423774d566cSPeter Maydell    }
4424774d566cSPeter Maydell
4425774d566cSPeter Maydell    if (max >= 7) {
4426774d566cSPeter Maydell        __cpuid_count(7, 0, a, b, c, d);
4427774d566cSPeter Maydell    }
4428774d566cSPeter Maydell
442976a347e1SRichard Henderson    return 0;
443076a347e1SRichard Henderson}
443176a347e1SRichard HendersonEOF
443276a347e1SRichard Hendersonif compile_prog "" "" ; then
443376a347e1SRichard Henderson    cpuid_h=yes
443476a347e1SRichard Hendersonfi
443576a347e1SRichard Henderson
44365dd89908SRichard Henderson##########################################
44375dd89908SRichard Henderson# avx2 optimization requirement check
44385dd89908SRichard Henderson#
44395dd89908SRichard Henderson# There is no point enabling this if cpuid.h is not usable,
44405dd89908SRichard Henderson# since we won't be able to select the new routines.
44415dd89908SRichard Henderson
4442e633a5c6SEric Blakeif test "$cpuid_h" = "yes" && test "$avx2_opt" != "no"; then
44435dd89908SRichard Henderson  cat > $TMPC << EOF
44445dd89908SRichard Henderson#pragma GCC push_options
44455dd89908SRichard Henderson#pragma GCC target("avx2")
44465dd89908SRichard Henderson#include <cpuid.h>
44475dd89908SRichard Henderson#include <immintrin.h>
44485dd89908SRichard Hendersonstatic int bar(void *a) {
44495dd89908SRichard Henderson    __m256i x = *(__m256i *)a;
44505dd89908SRichard Henderson    return _mm256_testz_si256(x, x);
44515dd89908SRichard Henderson}
44525dd89908SRichard Hendersonint main(int argc, char *argv[]) { return bar(argv[0]); }
44535dd89908SRichard HendersonEOF
44545dd89908SRichard Henderson  if compile_object "" ; then
44555dd89908SRichard Henderson    avx2_opt="yes"
445686583a07SLiam Merwick  else
445786583a07SLiam Merwick    avx2_opt="no"
44585dd89908SRichard Henderson  fi
44595dd89908SRichard Hendersonfi
44605dd89908SRichard Henderson
44616b8cd447SRobert Hoo##########################################
44626b8cd447SRobert Hoo# avx512f optimization requirement check
44636b8cd447SRobert Hoo#
44646b8cd447SRobert Hoo# There is no point enabling this if cpuid.h is not usable,
44656b8cd447SRobert Hoo# since we won't be able to select the new routines.
44666b8cd447SRobert Hoo# by default, it is turned off.
44676b8cd447SRobert Hoo# if user explicitly want to enable it, check environment
44686b8cd447SRobert Hoo
44696b8cd447SRobert Hooif test "$cpuid_h" = "yes" && test "$avx512f_opt" = "yes"; then
44706b8cd447SRobert Hoo  cat > $TMPC << EOF
44716b8cd447SRobert Hoo#pragma GCC push_options
44726b8cd447SRobert Hoo#pragma GCC target("avx512f")
44736b8cd447SRobert Hoo#include <cpuid.h>
44746b8cd447SRobert Hoo#include <immintrin.h>
44756b8cd447SRobert Hoostatic int bar(void *a) {
44766b8cd447SRobert Hoo    __m512i x = *(__m512i *)a;
44776b8cd447SRobert Hoo    return _mm512_test_epi64_mask(x, x);
44786b8cd447SRobert Hoo}
44796b8cd447SRobert Hooint main(int argc, char *argv[])
44806b8cd447SRobert Hoo{
44816b8cd447SRobert Hoo	return bar(argv[0]);
44826b8cd447SRobert Hoo}
44836b8cd447SRobert HooEOF
44846b8cd447SRobert Hoo  if ! compile_object "" ; then
44856b8cd447SRobert Hoo    avx512f_opt="no"
44866b8cd447SRobert Hoo  fi
44876b8cd447SRobert Hooelse
44886b8cd447SRobert Hoo  avx512f_opt="no"
44896b8cd447SRobert Hoofi
44906b8cd447SRobert Hoo
4491f540166bSRichard Henderson########################################
4492f540166bSRichard Henderson# check if __[u]int128_t is usable.
4493f540166bSRichard Henderson
4494f540166bSRichard Hendersonint128=no
4495f540166bSRichard Hendersoncat > $TMPC << EOF
4496f540166bSRichard Henderson__int128_t a;
4497f540166bSRichard Henderson__uint128_t b;
4498f540166bSRichard Hendersonint main (void) {
4499f540166bSRichard Henderson  a = a + b;
4500f540166bSRichard Henderson  b = a * b;
4501464e3671SPeter Maydell  a = a * a;
4502f540166bSRichard Henderson  return 0;
4503f540166bSRichard Henderson}
4504f540166bSRichard HendersonEOF
4505f540166bSRichard Hendersonif compile_prog "" "" ; then
4506f540166bSRichard Henderson    int128=yes
4507f540166bSRichard Hendersonfi
450876a347e1SRichard Henderson
45097ebee43eSRichard Henderson#########################################
45107ebee43eSRichard Henderson# See if 128-bit atomic operations are supported.
45117ebee43eSRichard Henderson
45127ebee43eSRichard Hendersonatomic128=no
45137ebee43eSRichard Hendersonif test "$int128" = "yes"; then
45147ebee43eSRichard Henderson  cat > $TMPC << EOF
45157ebee43eSRichard Hendersonint main(void)
45167ebee43eSRichard Henderson{
45177ebee43eSRichard Henderson  unsigned __int128 x = 0, y = 0;
4518bceac547SThomas Huth  y = __atomic_load(&x, 0);
4519bceac547SThomas Huth  __atomic_store(&x, y, 0);
4520bceac547SThomas Huth  __atomic_compare_exchange(&x, &y, x, 0, 0, 0);
45217ebee43eSRichard Henderson  return 0;
45227ebee43eSRichard Henderson}
45237ebee43eSRichard HendersonEOF
45247ebee43eSRichard Henderson  if compile_prog "" "" ; then
45257ebee43eSRichard Henderson    atomic128=yes
45267ebee43eSRichard Henderson  fi
45277ebee43eSRichard Hendersonfi
45287ebee43eSRichard Henderson
4529e6cd4bb5SRichard Hendersoncmpxchg128=no
4530e633a5c6SEric Blakeif test "$int128" = yes && test "$atomic128" = no; then
4531e6cd4bb5SRichard Henderson  cat > $TMPC << EOF
4532e6cd4bb5SRichard Hendersonint main(void)
4533e6cd4bb5SRichard Henderson{
4534e6cd4bb5SRichard Henderson  unsigned __int128 x = 0, y = 0;
4535e6cd4bb5SRichard Henderson  __sync_val_compare_and_swap_16(&x, y, x);
4536e6cd4bb5SRichard Henderson  return 0;
4537e6cd4bb5SRichard Henderson}
4538e6cd4bb5SRichard HendersonEOF
4539e6cd4bb5SRichard Henderson  if compile_prog "" "" ; then
4540e6cd4bb5SRichard Henderson    cmpxchg128=yes
4541e6cd4bb5SRichard Henderson  fi
4542e6cd4bb5SRichard Hendersonfi
4543e6cd4bb5SRichard Henderson
4544df79b996SRichard Henderson#########################################
4545df79b996SRichard Henderson# See if 64-bit atomic operations are supported.
4546df79b996SRichard Henderson# Note that without __atomic builtins, we can only
4547df79b996SRichard Henderson# assume atomic loads/stores max at pointer size.
4548df79b996SRichard Henderson
4549df79b996SRichard Hendersoncat > $TMPC << EOF
4550df79b996SRichard Henderson#include <stdint.h>
4551df79b996SRichard Hendersonint main(void)
4552df79b996SRichard Henderson{
4553df79b996SRichard Henderson  uint64_t x = 0, y = 0;
4554df79b996SRichard Henderson#ifdef __ATOMIC_RELAXED
45555fe40765SThomas Huth  y = __atomic_load_n(&x, __ATOMIC_RELAXED);
45565fe40765SThomas Huth  __atomic_store_n(&x, y, __ATOMIC_RELAXED);
45575fe40765SThomas Huth  __atomic_compare_exchange_n(&x, &y, x, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
45585fe40765SThomas Huth  __atomic_exchange_n(&x, y, __ATOMIC_RELAXED);
45595fe40765SThomas Huth  __atomic_fetch_add(&x, y, __ATOMIC_RELAXED);
4560df79b996SRichard Henderson#else
4561df79b996SRichard Henderson  typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
4562df79b996SRichard Henderson  __sync_lock_test_and_set(&x, y);
4563df79b996SRichard Henderson  __sync_val_compare_and_swap(&x, y, 0);
4564df79b996SRichard Henderson  __sync_fetch_and_add(&x, y);
4565df79b996SRichard Henderson#endif
4566df79b996SRichard Henderson  return 0;
4567df79b996SRichard Henderson}
4568df79b996SRichard HendersonEOF
4569df79b996SRichard Hendersonif compile_prog "" "" ; then
4570df79b996SRichard Henderson  atomic64=yes
4571df79b996SRichard Hendersonfi
4572df79b996SRichard Henderson
457326fffe29SEmilio G. Cota#########################################
457426fffe29SEmilio G. Cota# See if --dynamic-list is supported by the linker
457526fffe29SEmilio G. Cotald_dynamic_list="no"
457626fffe29SEmilio G. Cotaif test "$static" = "no" ; then
457726fffe29SEmilio G. Cota    cat > $TMPTXT <<EOF
457826fffe29SEmilio G. Cota{
457926fffe29SEmilio G. Cota  foo;
458026fffe29SEmilio G. Cota};
458126fffe29SEmilio G. CotaEOF
458226fffe29SEmilio G. Cota
458326fffe29SEmilio G. Cota    cat > $TMPC <<EOF
458426fffe29SEmilio G. Cota#include <stdio.h>
458526fffe29SEmilio G. Cotavoid foo(void);
458626fffe29SEmilio G. Cota
458726fffe29SEmilio G. Cotavoid foo(void)
458826fffe29SEmilio G. Cota{
458926fffe29SEmilio G. Cota  printf("foo\n");
459026fffe29SEmilio G. Cota}
459126fffe29SEmilio G. Cota
459226fffe29SEmilio G. Cotaint main(void)
459326fffe29SEmilio G. Cota{
459426fffe29SEmilio G. Cota  foo();
459526fffe29SEmilio G. Cota  return 0;
459626fffe29SEmilio G. Cota}
459726fffe29SEmilio G. CotaEOF
459826fffe29SEmilio G. Cota
459926fffe29SEmilio G. Cota    if compile_prog "" "-Wl,--dynamic-list=$TMPTXT" ; then
460026fffe29SEmilio G. Cota        ld_dynamic_list="yes"
460126fffe29SEmilio G. Cota    fi
460226fffe29SEmilio G. Cotafi
460326fffe29SEmilio G. Cota
460426fffe29SEmilio G. Cota#########################################
460526fffe29SEmilio G. Cota# See if -exported_symbols_list is supported by the linker
460626fffe29SEmilio G. Cota
460726fffe29SEmilio G. Cotald_exported_symbols_list="no"
460826fffe29SEmilio G. Cotaif test "$static" = "no" ; then
460926fffe29SEmilio G. Cota    cat > $TMPTXT <<EOF
461026fffe29SEmilio G. Cota  _foo
461126fffe29SEmilio G. CotaEOF
461226fffe29SEmilio G. Cota
461326fffe29SEmilio G. Cota    if compile_prog "" "-Wl,-exported_symbols_list,$TMPTXT" ; then
461426fffe29SEmilio G. Cota        ld_exported_symbols_list="yes"
461526fffe29SEmilio G. Cota    fi
461626fffe29SEmilio G. Cotafi
461726fffe29SEmilio G. Cota
461826fffe29SEmilio G. Cotaif  test "$plugins" = "yes" &&
461926fffe29SEmilio G. Cota    test "$ld_dynamic_list" = "no" &&
462026fffe29SEmilio G. Cota    test "$ld_exported_symbols_list" = "no" ; then
462126fffe29SEmilio G. Cota  error_exit \
462226fffe29SEmilio G. Cota      "Plugin support requires dynamic linking and specifying a set of symbols " \
462326fffe29SEmilio G. Cota      "that are exported to plugins. Unfortunately your linker doesn't " \
462426fffe29SEmilio G. Cota      "support the flag (--dynamic-list or -exported_symbols_list) used " \
462526fffe29SEmilio G. Cota      "for this purpose. You can't build with --static."
462626fffe29SEmilio G. Cotafi
462726fffe29SEmilio G. Cota
46281e6e9acaSRichard Henderson########################################
46291e6e9acaSRichard Henderson# check if getauxval is available.
46301e6e9acaSRichard Henderson
46311e6e9acaSRichard Hendersongetauxval=no
46321e6e9acaSRichard Hendersoncat > $TMPC << EOF
46331e6e9acaSRichard Henderson#include <sys/auxv.h>
46341e6e9acaSRichard Hendersonint main(void) {
46351e6e9acaSRichard Henderson  return getauxval(AT_HWCAP) == 0;
46361e6e9acaSRichard Henderson}
46371e6e9acaSRichard HendersonEOF
46381e6e9acaSRichard Hendersonif compile_prog "" "" ; then
46391e6e9acaSRichard Henderson    getauxval=yes
46401e6e9acaSRichard Hendersonfi
46411e6e9acaSRichard Henderson
4642fd0e6053SJohn Snow########################################
4643fd0e6053SJohn Snow# check if ccache is interfering with
4644fd0e6053SJohn Snow# semantic analysis of macros
4645fd0e6053SJohn Snow
46465e4dfd3dSJohn Snowunset CCACHE_CPP2
4647fd0e6053SJohn Snowccache_cpp2=no
4648fd0e6053SJohn Snowcat > $TMPC << EOF
4649fd0e6053SJohn Snowstatic const int Z = 1;
4650fd0e6053SJohn Snow#define fn() ({ Z; })
4651fd0e6053SJohn Snow#define TAUT(X) ((X) == Z)
4652fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y)
4653fd0e6053SJohn Snow#define ID(X) (X)
4654fd0e6053SJohn Snowint main(int argc, char *argv[])
4655fd0e6053SJohn Snow{
4656fd0e6053SJohn Snow    int x = 0, y = 0;
4657fd0e6053SJohn Snow    x = ID(x);
4658fd0e6053SJohn Snow    x = fn();
4659fd0e6053SJohn Snow    fn();
4660fd0e6053SJohn Snow    if (PAREN(x, y)) return 0;
4661fd0e6053SJohn Snow    if (TAUT(Z)) return 0;
4662fd0e6053SJohn Snow    return 0;
4663fd0e6053SJohn Snow}
4664fd0e6053SJohn SnowEOF
4665fd0e6053SJohn Snow
4666fd0e6053SJohn Snowif ! compile_object "-Werror"; then
4667fd0e6053SJohn Snow    ccache_cpp2=yes
4668fd0e6053SJohn Snowfi
4669fd0e6053SJohn Snow
4670b553a042SJohn Snow#################################################
4671b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE.
4672b553a042SJohn Snow
4673b553a042SJohn Snowif test "$fortify_source" != "no"; then
4674b553a042SJohn Snow  if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
4675b553a042SJohn Snow    fortify_source="no";
4676e189091fSPeter Maydell  elif test -n "$cxx" && has $cxx &&
4677cfcc7c14SJohn Snow       echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
4678b553a042SJohn Snow    fortify_source="no";
4679b553a042SJohn Snow  else
4680b553a042SJohn Snow    fortify_source="yes"
4681b553a042SJohn Snow  fi
4682b553a042SJohn Snowfi
4683b553a042SJohn Snow
46841efad060SFam Zheng###############################################
46851efad060SFam Zheng# Check if copy_file_range is provided by glibc
46861efad060SFam Zhenghave_copy_file_range=no
46871efad060SFam Zhengcat > $TMPC << EOF
46881efad060SFam Zheng#include <unistd.h>
46891efad060SFam Zhengint main(void) {
46901efad060SFam Zheng  copy_file_range(0, NULL, 0, NULL, 0, 0);
46911efad060SFam Zheng  return 0;
46921efad060SFam Zheng}
46931efad060SFam ZhengEOF
46941efad060SFam Zhengif compile_prog "" "" ; then
46951efad060SFam Zheng    have_copy_file_range=yes
46961efad060SFam Zhengfi
46971efad060SFam Zheng
4698d2042378SAneesh Kumar K.V##########################################
4699277abf15SJan Vesely# check if struct fsxattr is available via linux/fs.h
4700277abf15SJan Vesely
4701277abf15SJan Veselyhave_fsxattr=no
4702277abf15SJan Veselycat > $TMPC << EOF
4703277abf15SJan Vesely#include <linux/fs.h>
4704277abf15SJan Veselystruct fsxattr foo;
4705277abf15SJan Veselyint main(void) {
4706277abf15SJan Vesely  return 0;
4707277abf15SJan Vesely}
4708277abf15SJan VeselyEOF
4709277abf15SJan Veselyif compile_prog "" "" ; then
4710277abf15SJan Vesely    have_fsxattr=yes
4711277abf15SJan Veselyfi
4712277abf15SJan Vesely
4713b66e10e4SPeter Maydell##########################################
4714a40161cbSPaolo Bonzini# check for usable membarrier system call
4715a40161cbSPaolo Bonziniif test "$membarrier" = "yes"; then
4716a40161cbSPaolo Bonzini    have_membarrier=no
4717a40161cbSPaolo Bonzini    if test "$mingw32" = "yes" ; then
4718a40161cbSPaolo Bonzini        have_membarrier=yes
4719a40161cbSPaolo Bonzini    elif test "$linux" = "yes" ; then
4720a40161cbSPaolo Bonzini        cat > $TMPC << EOF
4721a40161cbSPaolo Bonzini    #include <linux/membarrier.h>
4722a40161cbSPaolo Bonzini    #include <sys/syscall.h>
4723a40161cbSPaolo Bonzini    #include <unistd.h>
4724a40161cbSPaolo Bonzini    #include <stdlib.h>
4725a40161cbSPaolo Bonzini    int main(void) {
4726a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
4727a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0);
4728a40161cbSPaolo Bonzini	exit(0);
4729a40161cbSPaolo Bonzini    }
4730a40161cbSPaolo BonziniEOF
4731a40161cbSPaolo Bonzini        if compile_prog "" "" ; then
4732a40161cbSPaolo Bonzini            have_membarrier=yes
4733a40161cbSPaolo Bonzini        fi
4734a40161cbSPaolo Bonzini    fi
4735a40161cbSPaolo Bonzini    if test "$have_membarrier" = "no"; then
4736a40161cbSPaolo Bonzini      feature_not_found "membarrier" "membarrier system call not available"
4737a40161cbSPaolo Bonzini    fi
4738a40161cbSPaolo Bonzinielse
4739a40161cbSPaolo Bonzini    # Do not enable it by default even for Mingw32, because it doesn't
4740a40161cbSPaolo Bonzini    # work on Wine.
4741a40161cbSPaolo Bonzini    membarrier=no
4742a40161cbSPaolo Bonzinifi
4743a40161cbSPaolo Bonzini
4744a40161cbSPaolo Bonzini##########################################
4745b66e10e4SPeter Maydell# check if rtnetlink.h exists and is useful
4746575b22b1SLaurent Vivierhave_rtnetlink=no
4747575b22b1SLaurent Viviercat > $TMPC << EOF
4748575b22b1SLaurent Vivier#include <linux/rtnetlink.h>
4749575b22b1SLaurent Vivierint main(void) {
4750575b22b1SLaurent Vivier  return IFLA_PROTO_DOWN;
4751575b22b1SLaurent Vivier}
4752575b22b1SLaurent VivierEOF
4753575b22b1SLaurent Vivierif compile_prog "" "" ; then
4754575b22b1SLaurent Vivier    have_rtnetlink=yes
4755575b22b1SLaurent Vivierfi
4756575b22b1SLaurent Vivier
47576a02c806SStefan Hajnoczi##########################################
47586a02c806SStefan Hajnoczi# check for usable AF_VSOCK environment
47596a02c806SStefan Hajnoczihave_af_vsock=no
47606a02c806SStefan Hajnoczicat > $TMPC << EOF
47616a02c806SStefan Hajnoczi#include <errno.h>
47626a02c806SStefan Hajnoczi#include <sys/types.h>
47636a02c806SStefan Hajnoczi#include <sys/socket.h>
47646a02c806SStefan Hajnoczi#if !defined(AF_VSOCK)
47656a02c806SStefan Hajnoczi# error missing AF_VSOCK flag
47666a02c806SStefan Hajnoczi#endif
47676a02c806SStefan Hajnoczi#include <linux/vm_sockets.h>
47686a02c806SStefan Hajnocziint main(void) {
47696a02c806SStefan Hajnoczi    int sock, ret;
47706a02c806SStefan Hajnoczi    struct sockaddr_vm svm;
47716a02c806SStefan Hajnoczi    socklen_t len = sizeof(svm);
47726a02c806SStefan Hajnoczi    sock = socket(AF_VSOCK, SOCK_STREAM, 0);
47736a02c806SStefan Hajnoczi    ret = getpeername(sock, (struct sockaddr *)&svm, &len);
47746a02c806SStefan Hajnoczi    if ((ret == -1) && (errno == ENOTCONN)) {
47756a02c806SStefan Hajnoczi        return 0;
47766a02c806SStefan Hajnoczi    }
47776a02c806SStefan Hajnoczi    return -1;
47786a02c806SStefan Hajnoczi}
47796a02c806SStefan HajnocziEOF
47806a02c806SStefan Hajnocziif compile_prog "" "" ; then
47816a02c806SStefan Hajnoczi    have_af_vsock=yes
47826a02c806SStefan Hajnoczifi
47836a02c806SStefan Hajnoczi
4784f0d92b56SLongpeng(Mike)##########################################
4785f0d92b56SLongpeng(Mike)# check for usable AF_ALG environment
47864f67366eSThomas Huthhave_afalg=no
4787f0d92b56SLongpeng(Mike)cat > $TMPC << EOF
4788f0d92b56SLongpeng(Mike)#include <errno.h>
4789f0d92b56SLongpeng(Mike)#include <sys/types.h>
4790f0d92b56SLongpeng(Mike)#include <sys/socket.h>
4791f0d92b56SLongpeng(Mike)#include <linux/if_alg.h>
4792f0d92b56SLongpeng(Mike)int main(void) {
4793f0d92b56SLongpeng(Mike)    int sock;
4794f0d92b56SLongpeng(Mike)    sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
4795f0d92b56SLongpeng(Mike)    return sock;
4796f0d92b56SLongpeng(Mike)}
4797f0d92b56SLongpeng(Mike)EOF
4798f0d92b56SLongpeng(Mike)if compile_prog "" "" ; then
4799f0d92b56SLongpeng(Mike)    have_afalg=yes
4800f0d92b56SLongpeng(Mike)fi
4801f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes"
4802f0d92b56SLongpeng(Mike)then
4803f0d92b56SLongpeng(Mike)    if test "$have_afalg" != "yes"
4804f0d92b56SLongpeng(Mike)    then
4805f0d92b56SLongpeng(Mike)	error_exit "AF_ALG requested but could not be detected"
4806f0d92b56SLongpeng(Mike)    fi
4807f0d92b56SLongpeng(Mike)fi
4808f0d92b56SLongpeng(Mike)
4809f0d92b56SLongpeng(Mike)
48106969ec6cSJames Clarke#################################################
48114d04351fSChristopher Covington# check for sysmacros.h
48124d04351fSChristopher Covington
48134d04351fSChristopher Covingtonhave_sysmacros=no
48144d04351fSChristopher Covingtoncat > $TMPC << EOF
48154d04351fSChristopher Covington#include <sys/sysmacros.h>
48164d04351fSChristopher Covingtonint main(void) {
48174d04351fSChristopher Covington    return makedev(0, 0);
48184d04351fSChristopher Covington}
48194d04351fSChristopher CovingtonEOF
48204d04351fSChristopher Covingtonif compile_prog "" "" ; then
48214d04351fSChristopher Covington    have_sysmacros=yes
48224d04351fSChristopher Covingtonfi
48234d04351fSChristopher Covington
48244d04351fSChristopher Covington##########################################
4825e674605fSTomáš Golembiovský# check for utmpx.h, it is missing e.g. on OpenBSD
4826e674605fSTomáš Golembiovský
4827e674605fSTomáš Golembiovskýhave_utmpx=no
4828e674605fSTomáš Golembiovskýcat > $TMPC << EOF
4829e674605fSTomáš Golembiovský#include <utmpx.h>
4830e674605fSTomáš Golembiovskýstruct utmpx user_info;
4831e674605fSTomáš Golembiovskýint main(void) {
4832e674605fSTomáš Golembiovský    return 0;
4833e674605fSTomáš Golembiovský}
4834e674605fSTomáš GolembiovskýEOF
4835e674605fSTomáš Golembiovskýif compile_prog "" "" ; then
4836e674605fSTomáš Golembiovský    have_utmpx=yes
4837e674605fSTomáš Golembiovskýfi
4838e674605fSTomáš Golembiovský
4839e674605fSTomáš Golembiovský##########################################
4840db1ed1abSRichard Henderson# check for getrandom()
4841db1ed1abSRichard Henderson
4842db1ed1abSRichard Hendersonhave_getrandom=no
4843db1ed1abSRichard Hendersoncat > $TMPC << EOF
4844db1ed1abSRichard Henderson#include <sys/random.h>
4845db1ed1abSRichard Hendersonint main(void) {
4846db1ed1abSRichard Henderson    return getrandom(0, 0, GRND_NONBLOCK);
4847db1ed1abSRichard Henderson}
4848db1ed1abSRichard HendersonEOF
4849db1ed1abSRichard Hendersonif compile_prog "" "" ; then
4850db1ed1abSRichard Henderson    have_getrandom=yes
4851db1ed1abSRichard Hendersonfi
4852db1ed1abSRichard Henderson
4853db1ed1abSRichard Henderson##########################################
4854247724cbSMarc-André Lureau# checks for sanitizers
4855247724cbSMarc-André Lureau
4856247724cbSMarc-André Lureauhave_asan=no
4857247724cbSMarc-André Lureauhave_ubsan=no
4858d83414e1SMarc-André Lureauhave_asan_iface_h=no
4859d83414e1SMarc-André Lureauhave_asan_iface_fiber=no
4860247724cbSMarc-André Lureau
4861247724cbSMarc-André Lureauif test "$sanitizers" = "yes" ; then
4862b9f44da2SMarc-André Lureau  write_c_skeleton
4863247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
4864247724cbSMarc-André Lureau      have_asan=yes
4865247724cbSMarc-André Lureau  fi
4866b9f44da2SMarc-André Lureau
4867b9f44da2SMarc-André Lureau  # we could use a simple skeleton for flags checks, but this also
4868b9f44da2SMarc-André Lureau  # detect the static linking issue of ubsan, see also:
4869b9f44da2SMarc-André Lureau  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
4870b9f44da2SMarc-André Lureau  cat > $TMPC << EOF
4871b9f44da2SMarc-André Lureau#include <stdlib.h>
4872b9f44da2SMarc-André Lureauint main(void) {
4873b9f44da2SMarc-André Lureau    void *tmp = malloc(10);
4874f2dfe54cSLeonid Bloch    if (tmp != NULL) {
4875b9f44da2SMarc-André Lureau        return *(int *)(tmp + 2);
4876b9f44da2SMarc-André Lureau    }
4877d1abf3fcSOlaf Hering    return 1;
4878f2dfe54cSLeonid Bloch}
4879b9f44da2SMarc-André LureauEOF
4880247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
4881247724cbSMarc-André Lureau      have_ubsan=yes
4882247724cbSMarc-André Lureau  fi
4883d83414e1SMarc-André Lureau
4884d83414e1SMarc-André Lureau  if check_include "sanitizer/asan_interface.h" ; then
4885d83414e1SMarc-André Lureau      have_asan_iface_h=yes
4886d83414e1SMarc-André Lureau  fi
4887d83414e1SMarc-André Lureau
4888d83414e1SMarc-André Lureau  cat > $TMPC << EOF
4889d83414e1SMarc-André Lureau#include <sanitizer/asan_interface.h>
4890d83414e1SMarc-André Lureauint main(void) {
4891d83414e1SMarc-André Lureau  __sanitizer_start_switch_fiber(0, 0, 0);
4892d83414e1SMarc-André Lureau  return 0;
4893d83414e1SMarc-André Lureau}
4894d83414e1SMarc-André LureauEOF
4895d83414e1SMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
4896d83414e1SMarc-André Lureau      have_asan_iface_fiber=yes
4897d83414e1SMarc-André Lureau  fi
4898247724cbSMarc-André Lureaufi
4899247724cbSMarc-André Lureau
4900247724cbSMarc-André Lureau##########################################
4901adc28027SAlexander Bulekov# checks for fuzzer
490254c9e41dSAlexander Bulekovif test "$fuzzing" = "yes" && test -z "${LIB_FUZZING_ENGINE+xxx}"; then
4903adc28027SAlexander Bulekov  write_c_fuzzer_skeleton
4904dd016265SAlexander Bulekov  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=fuzzer" ""; then
4905adc28027SAlexander Bulekov    have_fuzzer=yes
490664ed6f92SPaolo Bonzini  else
490764ed6f92SPaolo Bonzini    error_exit "Your compiler doesn't support -fsanitize=fuzzer"
490864ed6f92SPaolo Bonzini    exit 1
4909adc28027SAlexander Bulekov  fi
4910adc28027SAlexander Bulekovfi
4911adc28027SAlexander Bulekov
49120aebab04SLingfeng Yang# Thread sanitizer is, for now, much noisier than the other sanitizers;
49130aebab04SLingfeng Yang# keep it separate until that is not the case.
49140aebab04SLingfeng Yangif test "$tsan" = "yes" && test "$sanitizers" = "yes"; then
49150aebab04SLingfeng Yang  error_exit "TSAN is not supported with other sanitiziers."
49160aebab04SLingfeng Yangfi
49170aebab04SLingfeng Yanghave_tsan=no
49180aebab04SLingfeng Yanghave_tsan_iface_fiber=no
49190aebab04SLingfeng Yangif test "$tsan" = "yes" ; then
49200aebab04SLingfeng Yang  write_c_skeleton
49210aebab04SLingfeng Yang  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
49220aebab04SLingfeng Yang      have_tsan=yes
49230aebab04SLingfeng Yang  fi
49240aebab04SLingfeng Yang  cat > $TMPC << EOF
49250aebab04SLingfeng Yang#include <sanitizer/tsan_interface.h>
49260aebab04SLingfeng Yangint main(void) {
49270aebab04SLingfeng Yang  __tsan_create_fiber(0);
49280aebab04SLingfeng Yang  return 0;
49290aebab04SLingfeng Yang}
49300aebab04SLingfeng YangEOF
49310aebab04SLingfeng Yang  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
49320aebab04SLingfeng Yang      have_tsan_iface_fiber=yes
49330aebab04SLingfeng Yang  fi
49340aebab04SLingfeng Yangfi
49350aebab04SLingfeng Yang
4936adc28027SAlexander Bulekov##########################################
4937675b9b53SMarc-André Lureau# check for slirp
4938675b9b53SMarc-André Lureau
4939675b9b53SMarc-André Lureaucase "$slirp" in
49404d34a86bSPaolo Bonzini  auto | enabled | internal)
49414d34a86bSPaolo Bonzini    # Simpler to always update submodule, even if not needed.
49427c57bdd8SMarc-André Lureau    git_submodules="${git_submodules} slirp"
4943675b9b53SMarc-André Lureau    ;;
4944675b9b53SMarc-André Lureauesac
4945675b9b53SMarc-André Lureau
4946b8e0c493SJoelle van Dyne# Check for slirp smbd dupport
4947b8e0c493SJoelle van Dyne: ${smbd=${SMBD-/usr/sbin/smbd}}
4948b8e0c493SJoelle van Dyneif test "$slirp_smbd" != "no" ; then
4949b8e0c493SJoelle van Dyne  if test "$mingw32" = "yes" ; then
4950b8e0c493SJoelle van Dyne    if test "$slirp_smbd" = "yes" ; then
4951b8e0c493SJoelle van Dyne      error_exit "Host smbd not supported on this platform."
4952b8e0c493SJoelle van Dyne    fi
4953b8e0c493SJoelle van Dyne    slirp_smbd=no
4954b8e0c493SJoelle van Dyne  else
4955b8e0c493SJoelle van Dyne    slirp_smbd=yes
4956b8e0c493SJoelle van Dyne  fi
4957b8e0c493SJoelle van Dynefi
4958b8e0c493SJoelle van Dyne
495954e7aac0SAlexey Krasikov##########################################
496054e7aac0SAlexey Krasikov# check for usable __NR_keyctl syscall
496154e7aac0SAlexey Krasikov
496254e7aac0SAlexey Krasikovif test "$linux" = "yes" ; then
496354e7aac0SAlexey Krasikov
496454e7aac0SAlexey Krasikov    have_keyring=no
496554e7aac0SAlexey Krasikov    cat > $TMPC << EOF
496654e7aac0SAlexey Krasikov#include <errno.h>
496754e7aac0SAlexey Krasikov#include <asm/unistd.h>
496854e7aac0SAlexey Krasikov#include <linux/keyctl.h>
496954e7aac0SAlexey Krasikov#include <unistd.h>
497054e7aac0SAlexey Krasikovint main(void) {
497154e7aac0SAlexey Krasikov    return syscall(__NR_keyctl, KEYCTL_READ, 0, NULL, NULL, 0);
497254e7aac0SAlexey Krasikov}
497354e7aac0SAlexey KrasikovEOF
497454e7aac0SAlexey Krasikov    if compile_prog "" "" ; then
497554e7aac0SAlexey Krasikov        have_keyring=yes
497654e7aac0SAlexey Krasikov    fi
497754e7aac0SAlexey Krasikovfi
497854e7aac0SAlexey Krasikovif test "$secret_keyring" != "no"
497954e7aac0SAlexey Krasikovthen
4980b418d265SDavid Edmondson    if test "$have_keyring" = "yes"
498154e7aac0SAlexey Krasikov    then
498254e7aac0SAlexey Krasikov	secret_keyring=yes
498354e7aac0SAlexey Krasikov    else
498454e7aac0SAlexey Krasikov	if test "$secret_keyring" = "yes"
498554e7aac0SAlexey Krasikov	then
498654e7aac0SAlexey Krasikov	    error_exit "syscall __NR_keyctl requested, \
498754e7aac0SAlexey Krasikovbut not implemented on your system"
498854e7aac0SAlexey Krasikov	else
498954e7aac0SAlexey Krasikov	    secret_keyring=no
499054e7aac0SAlexey Krasikov	fi
499154e7aac0SAlexey Krasikov    fi
499254e7aac0SAlexey Krasikovfi
499354e7aac0SAlexey Krasikov
499492500362SAlexey Krasikov##########################################
4995e86ecd4bSJuan Quintela# End of CC checks
4996e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
4997e86ecd4bSJuan Quintela
4998d83414e1SMarc-André Lureauwrite_c_skeleton
4999d83414e1SMarc-André Lureau
50001d728c39SBlue Swirlif test "$gcov" = "yes" ; then
5001bf0e56a3SMarc-André Lureau  :
5002b553a042SJohn Snowelif test "$fortify_source" = "yes" ; then
5003086d5f75SPaolo Bonzini  QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
5004086d5f75SPaolo Bonzini  debug=no
5005086d5f75SPaolo Bonzinifi
5006086d5f75SPaolo Bonzini
5007086d5f75SPaolo Bonzinicase "$ARCH" in
5008086d5f75SPaolo Bonzinialpha)
5009086d5f75SPaolo Bonzini  # Ensure there's only a single GP
5010086d5f75SPaolo Bonzini  QEMU_CFLAGS="-msmall-data $QEMU_CFLAGS"
5011086d5f75SPaolo Bonzini;;
5012086d5f75SPaolo Bonziniesac
5013086d5f75SPaolo Bonzini
5014086d5f75SPaolo Bonziniif test "$gprof" = "yes" ; then
5015086d5f75SPaolo Bonzini  QEMU_CFLAGS="-p $QEMU_CFLAGS"
5016086d5f75SPaolo Bonzini  QEMU_LDFLAGS="-p $QEMU_LDFLAGS"
5017086d5f75SPaolo Bonzinifi
5018a316e378SJuan Quintela
5019247724cbSMarc-André Lureauif test "$have_asan" = "yes"; then
5020db5adeaaSPaolo Bonzini  QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS"
5021db5adeaaSPaolo Bonzini  QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS"
5022d83414e1SMarc-André Lureau  if test "$have_asan_iface_h" = "no" ; then
5023d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header missing." \
5024d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
5025d83414e1SMarc-André Lureau  elif test "$have_asan_iface_fiber" = "no" ; then
5026d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header is too old." \
5027d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
5028d83414e1SMarc-André Lureau  fi
5029247724cbSMarc-André Lureaufi
50300aebab04SLingfeng Yangif test "$have_tsan" = "yes" ; then
50310aebab04SLingfeng Yang  if test "$have_tsan_iface_fiber" = "yes" ; then
50320aebab04SLingfeng Yang    QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS"
50330aebab04SLingfeng Yang    QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS"
50340aebab04SLingfeng Yang  else
50350aebab04SLingfeng Yang    error_exit "Cannot enable TSAN due to missing fiber annotation interface."
50360aebab04SLingfeng Yang  fi
50370aebab04SLingfeng Yangelif test "$tsan" = "yes" ; then
50380aebab04SLingfeng Yang  error_exit "Cannot enable TSAN due to missing sanitize thread interface."
50390aebab04SLingfeng Yangfi
5040247724cbSMarc-André Lureauif test "$have_ubsan" = "yes"; then
5041db5adeaaSPaolo Bonzini  QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS"
5042db5adeaaSPaolo Bonzini  QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS"
5043247724cbSMarc-André Lureaufi
5044247724cbSMarc-André Lureau
50456542aa9cSPeter Lieven##########################################
50463efac6ebSTomáš Golembiovský
50470aebab04SLingfeng Yang# Exclude --warn-common with TSan to suppress warnings from the TSan libraries.
50480aebab04SLingfeng Yangif test "$solaris" = "no" && test "$tsan" = "no"; then
5049e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
5050db5adeaaSPaolo Bonzini        QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS"
5051e86ecd4bSJuan Quintela    fi
5052e86ecd4bSJuan Quintelafi
5053e86ecd4bSJuan Quintela
5054952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
5055952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
5056cb8baa77SMark Cave-Ayland    flags="--no-seh --nxcompat"
5057cb8baa77SMark Cave-Ayland
5058cb8baa77SMark Cave-Ayland    # Disable ASLR for debug builds to allow debugging with gdb
5059cb8baa77SMark Cave-Ayland    if test "$debug" = "no" ; then
5060cb8baa77SMark Cave-Ayland        flags="--dynamicbase $flags"
5061cb8baa77SMark Cave-Ayland    fi
5062cb8baa77SMark Cave-Ayland
5063cb8baa77SMark Cave-Ayland    for flag in $flags; do
5064e9a3591fSChristian Borntraeger        if ld_has $flag ; then
5065db5adeaaSPaolo Bonzini            QEMU_LDFLAGS="-Wl,$flag $QEMU_LDFLAGS"
5066952afb71SBlue Swirl        fi
5067952afb71SBlue Swirl    done
5068952afb71SBlue Swirlfi
5069952afb71SBlue Swirl
5070e0580342SKamil Rytarowski# We can only support ivshmem if we have eventfd
5071e0580342SKamil Rytarowskiif [ "$eventfd" = "yes" ]; then
5072e0580342SKamil Rytarowski  ivshmem=yes
5073e0580342SKamil Rytarowskifi
5074e0580342SKamil Rytarowski
50759d6bc27bSMichael Roth# Probe for guest agent support/options
50769d6bc27bSMichael Roth
5077e8ef31a3SMichael Tokarevif [ "$guest_agent" != "no" ]; then
5078a5125905SLaurent Vivier  if [ "$softmmu" = no -a "$want_tools" = no ] ; then
5079a5125905SLaurent Vivier      guest_agent=no
5080a5125905SLaurent Vivier  elif [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
5081e8ef31a3SMichael Tokarev      guest_agent=yes
5082e8ef31a3SMichael Tokarev  elif [ "$guest_agent" != yes ]; then
5083e8ef31a3SMichael Tokarev      guest_agent=no
5084e8ef31a3SMichael Tokarev  else
5085e8ef31a3SMichael Tokarev      error_exit "Guest agent is not supported on this platform"
5086ca35f780SPaolo Bonzini  fi
50874b1c11fdSDaniel P. Berrangefi
5088ca35f780SPaolo Bonzini
5089b846ab7cSPaolo Bonzini# Guest agent Windows MSI package
50909d6bc27bSMichael Roth
50919d6bc27bSMichael Rothif test "$QEMU_GA_MANUFACTURER" = ""; then
50929d6bc27bSMichael Roth  QEMU_GA_MANUFACTURER=QEMU
50939d6bc27bSMichael Rothfi
50949d6bc27bSMichael Rothif test "$QEMU_GA_DISTRO" = ""; then
50959d6bc27bSMichael Roth  QEMU_GA_DISTRO=Linux
50969d6bc27bSMichael Rothfi
50979d6bc27bSMichael Rothif test "$QEMU_GA_VERSION" = ""; then
509889138857SStefan Weil    QEMU_GA_VERSION=$(cat $source_path/VERSION)
50999d6bc27bSMichael Rothfi
51009d6bc27bSMichael Roth
5101b846ab7cSPaolo BonziniQEMU_GA_MSI_MINGW_DLL_PATH="$($pkg_config --variable=prefix glib-2.0)/bin"
51029d6bc27bSMichael Roth
5103ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
5104ca35f780SPaolo Bonziniroms=
5105e633a5c6SEric Blakeif { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \
5106e633a5c6SEric Blake        test "$targetos" != "Darwin" && test "$targetos" != "SunOS" && \
51077000a12eSThomas Huth        test "$targetos" != "Haiku" && test "$softmmu" = yes ; then
5108e57218b6SPeter Maydell    # Different host OS linkers have different ideas about the name of the ELF
5109c65d5e4eSBrad Smith    # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
5110c65d5e4eSBrad Smith    # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
5111c65d5e4eSBrad Smith    for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
5112e57218b6SPeter Maydell        if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
5113e57218b6SPeter Maydell            ld_i386_emulation="$emu"
5114ca35f780SPaolo Bonzini            roms="optionrom"
5115e57218b6SPeter Maydell            break
5116e57218b6SPeter Maydell        fi
5117e57218b6SPeter Maydell    done
5118ca35f780SPaolo Bonzinifi
5119ca35f780SPaolo Bonzini
51202e33c3f8SThomas Huth# Only build s390-ccw bios if we're on s390x and the compiler has -march=z900
5121a5b2afd5SThomas Huth# or -march=z10 (which is the lowest architecture level that Clang supports)
51229933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then
51232e33c3f8SThomas Huth  write_c_skeleton
5124a5b2afd5SThomas Huth  compile_prog "-march=z900" ""
5125a5b2afd5SThomas Huth  has_z900=$?
51263af448b3SThomas Huth  if [ $has_z900 = 0 ] || compile_object "-march=z10 -msoft-float -Werror"; then
5127a5b2afd5SThomas Huth    if [ $has_z900 != 0 ]; then
5128a5b2afd5SThomas Huth      echo "WARNING: Your compiler does not support the z900!"
5129a5b2afd5SThomas Huth      echo "         The s390-ccw bios will only work with guest CPUs >= z10."
5130a5b2afd5SThomas Huth    fi
51319933c305SChristian Borntraeger    roms="$roms s390-ccw"
51321ef6bfc2SPhilippe Mathieu-Daudé    # SLOF is required for building the s390-ccw firmware on s390x,
51331ef6bfc2SPhilippe Mathieu-Daudé    # since it is using the libnet code from SLOF for network booting.
51341ef6bfc2SPhilippe Mathieu-Daudé    git_submodules="${git_submodules} roms/SLOF"
51351ef6bfc2SPhilippe Mathieu-Daudé  fi
51369933c305SChristian Borntraegerfi
51379933c305SChristian Borntraeger
513811cde1c8SBruno Dominguez# Check that the C++ compiler exists and works with the C compiler.
513911cde1c8SBruno 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.
514011cde1c8SBruno Dominguezif has $cxx; then
514111cde1c8SBruno Dominguez    cat > $TMPC <<EOF
514211cde1c8SBruno Dominguezint c_function(void);
514311cde1c8SBruno Dominguezint main(void) { return c_function(); }
514411cde1c8SBruno DominguezEOF
514511cde1c8SBruno Dominguez
514611cde1c8SBruno Dominguez    compile_object
514711cde1c8SBruno Dominguez
514811cde1c8SBruno Dominguez    cat > $TMPCXX <<EOF
514911cde1c8SBruno Dominguezextern "C" {
515011cde1c8SBruno Dominguez   int c_function(void);
515111cde1c8SBruno Dominguez}
515211cde1c8SBruno Dominguezint c_function(void) { return 42; }
515311cde1c8SBruno DominguezEOF
515411cde1c8SBruno Dominguez
515511cde1c8SBruno Dominguez    update_cxxflags
515611cde1c8SBruno Dominguez
51575770e8afSPaolo Bonzini    if do_cxx $CXXFLAGS $CONFIGURE_CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then
515811cde1c8SBruno Dominguez        # C++ compiler $cxx works ok with C compiler $cc
515911cde1c8SBruno Dominguez        :
516011cde1c8SBruno Dominguez    else
516111cde1c8SBruno Dominguez        echo "C++ compiler $cxx does not work with C compiler $cc"
516211cde1c8SBruno Dominguez        echo "Disabling C++ specific optional code"
516311cde1c8SBruno Dominguez        cxx=
516411cde1c8SBruno Dominguez    fi
516511cde1c8SBruno Dominguezelse
516611cde1c8SBruno Dominguez    echo "No C++ compiler available; disabling C++ specific optional code"
516711cde1c8SBruno Dominguez    cxx=
516811cde1c8SBruno Dominguezfi
516911cde1c8SBruno Dominguez
51707d7dbf9dSDan Streetmanif !(GIT="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then
51717d7dbf9dSDan Streetman    exit 1
51725d91a2edSYonggang Luofi
51735d91a2edSYonggang Luo
517498ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
517597a847bcSbellard
517698ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
517798ec69acSJuan Quintelaecho >> $config_host_mak
517898ec69acSJuan Quintela
5179e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
5180cc84d63aSDaniel P. Berrangeecho "GIT=$git" >> $config_host_mak
5181aef45d51SDaniel P. Berrangeecho "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
51827d7dbf9dSDan Streetmanecho "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak
5183804edf29SJuan Quintela
518498ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
5185727e5283SPaolo Bonzini
5186f8393946Saurel32if test "$debug_tcg" = "yes" ; then
51872358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
5188f8393946Saurel32fi
51891625af87Saliguoriif test "$strip_opt" = "yes" ; then
519052ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
51911625af87Saliguorifi
51927d13299dSbellardif test "$bigendian" = "yes" ; then
5193e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
519497a847bcSbellardfi
519567b915a5Sbellardif test "$mingw32" = "yes" ; then
519698ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
5197d9840e25STomoki Sekiyama  if test "$guest_agent_with_vss" = "yes" ; then
5198d9840e25STomoki Sekiyama    echo "CONFIG_QGA_VSS=y" >> $config_host_mak
5199f33ca81fSMichael Roth    echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
5200d9840e25STomoki Sekiyama    echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
5201d9840e25STomoki Sekiyama  fi
520250cbebb9SMichael Roth  if test "$guest_agent_ntddscsi" = "yes" ; then
520376dc75caSTomáš Golembiovský    echo "CONFIG_QGA_NTDDSCSI=y" >> $config_host_mak
520450cbebb9SMichael Roth  fi
52059dacf32dSYossi Hindin  echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
52069dacf32dSYossi Hindin  echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
52079dacf32dSYossi Hindin  echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
52089dacf32dSYossi Hindin  echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
5209210fa556Spbrookelse
521035f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
5211210fa556Spbrookfi
5212128ab2ffSblueswir1
5213dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
5214dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
5215dffcb71cSMark McLoughlinfi
5216dffcb71cSMark McLoughlin
521783fb7adfSbellardif test "$darwin" = "yes" ; then
521898ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
521983fb7adfSbellardfi
5220b29fe3edSmalc
5221ec530c81Sbellardif test "$solaris" = "yes" ; then
522298ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
5223ec530c81Sbellardfi
5224179cf400SAndreas Färberif test "$haiku" = "yes" ; then
5225179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
5226179cf400SAndreas Färberfi
522797a847bcSbellardif test "$static" = "yes" ; then
522898ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
522997a847bcSbellardfi
52301ba16968SStefan Weilif test "$profiler" = "yes" ; then
52312358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
523205c2a3e7Sbellardfi
5233c932ce31SPaolo Bonziniif test "$want_tools" = "yes" ; then
5234c932ce31SPaolo Bonzini  echo "CONFIG_TOOLS=y" >> $config_host_mak
5235c932ce31SPaolo Bonzinifi
5236f15bff25SPaolo Bonziniif test "$guest_agent" = "yes" ; then
5237f15bff25SPaolo Bonzini  echo "CONFIG_GUEST_AGENT=y" >> $config_host_mak
5238f15bff25SPaolo Bonzinifi
5239b8e0c493SJoelle van Dyneif test "$slirp_smbd" = "yes" ; then
5240b8e0c493SJoelle van Dyne  echo "CONFIG_SLIRP_SMBD=y" >> $config_host_mak
5241e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
5242b8e0c493SJoelle van Dynefi
52438a16d273Sthsif test "$vde" = "yes" ; then
524498ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
5245e2ad6f16SFam Zheng  echo "VDE_LIBS=$vde_libs" >> $config_host_mak
52468a16d273Sthsfi
524758952137SVincenzo Maffioneif test "$netmap" = "yes" ; then
524858952137SVincenzo Maffione  echo "CONFIG_NETMAP=y" >> $config_host_mak
524958952137SVincenzo Maffionefi
5250015a33bdSGongleiif test "$l2tpv3" = "yes" ; then
5251015a33bdSGonglei  echo "CONFIG_L2TPV3=y" >> $config_host_mak
5252015a33bdSGongleifi
52534cc600d2SPaolo Bonziniif test "$gprof" = "yes" ; then
52544cc600d2SPaolo Bonzini  echo "CONFIG_GPROF=y" >> $config_host_mak
52554cc600d2SPaolo Bonzinifi
52562358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
52570c58ac1cSmalcfor drv in $audio_drv_list; do
52581ef1ec2aSGerd Hoffmann    def=CONFIG_AUDIO_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
5259484e2cc7SPaolo Bonzini    echo "$def=y" >> $config_host_mak
52600c58ac1cSmalcdone
5261478e943fSPaolo Bonziniif test "$alsa" = "yes" ; then
5262478e943fSPaolo Bonzini    echo "CONFIG_ALSA=y" >> $config_host_mak
5263478e943fSPaolo Bonzinifi
5264b1149911SFam Zhengecho "ALSA_LIBS=$alsa_libs" >> $config_host_mak
5265478e943fSPaolo Bonziniecho "ALSA_CFLAGS=$alsa_cflags" >> $config_host_mak
5266478e943fSPaolo Bonziniif test "$libpulse" = "yes" ; then
5267478e943fSPaolo Bonzini    echo "CONFIG_LIBPULSE=y" >> $config_host_mak
5268478e943fSPaolo Bonzinifi
5269b1149911SFam Zhengecho "PULSE_LIBS=$pulse_libs" >> $config_host_mak
5270478e943fSPaolo Bonziniecho "PULSE_CFLAGS=$pulse_cflags" >> $config_host_mak
5271b1149911SFam Zhengecho "COREAUDIO_LIBS=$coreaudio_libs" >> $config_host_mak
5272b1149911SFam Zhengecho "DSOUND_LIBS=$dsound_libs" >> $config_host_mak
5273b1149911SFam Zhengecho "OSS_LIBS=$oss_libs" >> $config_host_mak
5274478e943fSPaolo Bonziniif test "$libjack" = "yes" ; then
5275478e943fSPaolo Bonzini    echo "CONFIG_LIBJACK=y" >> $config_host_mak
5276478e943fSPaolo Bonzinifi
52772e445703SGeoffrey McRaeecho "JACK_LIBS=$jack_libs" >> $config_host_mak
5278d5631638Smalcif test "$audio_win_int" = "yes" ; then
5279d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
5280d5631638Smalcfi
5281b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
5282b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
5283dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
5284dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
5285dce512deSChristoph Hellwigfi
528689138857SStefan Weilqemu_version=$(head $source_path/VERSION)
52872358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
528898ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
52892b1f35b9SAlex Bennéeecho "TARGET_DIRS=$target_list" >> $config_host_mak
529017969268SFam Zhengif test "$modules" = "yes"; then
5291e26110cfSFam Zheng  # $shacmd can generate a hash started with digit, which the compiler doesn't
5292e26110cfSFam Zheng  # like as an symbol. So prefix it with an underscore
529389138857SStefan Weil  echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
529417969268SFam Zheng  echo "CONFIG_MODULES=y" >> $config_host_mak
529517969268SFam Zhengfi
5296bd83c861SChristian Ehrhardtif test "$module_upgrades" = "yes"; then
5297bd83c861SChristian Ehrhardt  echo "CONFIG_MODULE_UPGRADES=y" >> $config_host_mak
5298bd83c861SChristian Ehrhardtfi
5299099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
53002358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
5301099d6b0fSRiku Voipiofi
530240ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
530340ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
530440ff6d7eSKevin Wolffi
53053ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
53062358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
53073ce34dfbSvibisreenivasanfi
5308c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
5309c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
5310c2882b96SRiku Voipiofi
5311751bcc39SMarc-André Lureauif test "$memfd" = "yes" ; then
5312751bcc39SMarc-André Lureau  echo "CONFIG_MEMFD=y" >> $config_host_mak
5313751bcc39SMarc-André Lureaufi
5314955727d2SCortland Tölvaif test "$have_usbfs" = "yes" ; then
5315955727d2SCortland Tölva  echo "CONFIG_USBFS=y" >> $config_host_mak
5316955727d2SCortland Tölvafi
5317d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
5318d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
5319d0927938SUlrich Hechtfi
53203d4fa43eSKusanagi Kouichiif test "$fallocate_punch_hole" = "yes" ; then
53213d4fa43eSKusanagi Kouichi  echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
53223d4fa43eSKusanagi Kouichifi
5323b953f075SDenis V. Lunevif test "$fallocate_zero_range" = "yes" ; then
5324b953f075SDenis V. Lunev  echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
5325b953f075SDenis V. Lunevfi
5326ed911435SKevin Wolfif test "$posix_fallocate" = "yes" ; then
5327ed911435SKevin Wolf  echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
5328ed911435SKevin Wolffi
5329c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
5330c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
5331c727f47dSPeter Maydellfi
5332dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
5333dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
5334dace20dcSPeter Maydellfi
5335d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
5336d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
5337d0927938SUlrich Hechtfi
53384e0c6529SAlex Blighif test "$ppoll" = "yes" ; then
53394e0c6529SAlex Bligh  echo "CONFIG_PPOLL=y" >> $config_host_mak
53404e0c6529SAlex Blighfi
5341cd758dd0SAlex Blighif test "$prctl_pr_set_timerslack" = "yes" ; then
5342cd758dd0SAlex Bligh  echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
5343cd758dd0SAlex Blighfi
53443b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
53453b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
53463b6edd16SPeter Maydellfi
53473b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
53483b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
53493b6edd16SPeter Maydellfi
5350a8fd1abaSPeter Maydellif test "$sendfile" = "yes" ; then
5351a8fd1abaSPeter Maydell  echo "CONFIG_SENDFILE=y" >> $config_host_mak
5352a8fd1abaSPeter Maydellfi
535351834341SRiku Voipioif test "$timerfd" = "yes" ; then
535451834341SRiku Voipio  echo "CONFIG_TIMERFD=y" >> $config_host_mak
535551834341SRiku Voipiofi
53569af5c906SRiku Voipioif test "$setns" = "yes" ; then
53579af5c906SRiku Voipio  echo "CONFIG_SETNS=y" >> $config_host_mak
53589af5c906SRiku Voipiofi
535938860a03SAleksandar Markovicif test "$clock_adjtime" = "yes" ; then
536038860a03SAleksandar Markovic  echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
536138860a03SAleksandar Markovicfi
53625a03cd00SAleksandar Markovicif test "$syncfs" = "yes" ; then
53635a03cd00SAleksandar Markovic  echo "CONFIG_SYNCFS=y" >> $config_host_mak
53645a03cd00SAleksandar Markovicfi
53653b3f24adSaurel32if test "$inotify" = "yes" ; then
53662358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
53673b3f24adSaurel32fi
5368c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
5369c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
5370c05c7a73SRiku Voipiofi
5371401bc051SPeter Maydellif test "$sem_timedwait" = "yes" ; then
5372401bc051SPeter Maydell  echo "CONFIG_SEM_TIMEDWAIT=y" >> $config_host_mak
5373401bc051SPeter Maydellfi
53745c99fa37SKeno Fischerif test "$strchrnul" = "yes" ; then
53755c99fa37SKeno Fischer  echo "HAVE_STRCHRNUL=y" >> $config_host_mak
53765c99fa37SKeno Fischerfi
53778a792b03SJiufei Xueif test "$st_atim" = "yes" ; then
53788a792b03SJiufei Xue  echo "HAVE_STRUCT_STAT_ST_ATIM=y" >> $config_host_mak
53798a792b03SJiufei Xuefi
538096ff758cSMichael Forneyif test "$sigev_notify_thread_id" = "yes" ; then
538196ff758cSMichael Forney  echo "HAVE_SIGEV_NOTIFY_THREAD_ID=y" >> $config_host_mak
538296ff758cSMichael Forneyfi
53836ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
53846ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
53856ae9a1f4SJuan Quintelafi
53866ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
53876ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
53886ae9a1f4SJuan Quintelafi
5389f876b765SMarc-André Lureauif test "$gio" = "yes" ; then
5390f876b765SMarc-André Lureau    echo "CONFIG_GIO=y" >> $config_host_mak
5391f876b765SMarc-André Lureau    echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak
5392f876b765SMarc-André Lureau    echo "GIO_LIBS=$gio_libs" >> $config_host_mak
53935ecfb76cSPaolo Bonzinifi
53945ecfb76cSPaolo Bonziniif test "$gdbus_codegen" != "" ; then
539525a97a56SMarc-André Lureau    echo "GDBUS_CODEGEN=$gdbus_codegen" >> $config_host_mak
5396f876b765SMarc-André Lureaufi
5397a1c5e949SDaniel P. Berrangeecho "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
53986b39b063SEric Blakeif test "$have_broken_size_max" = "yes" ; then
53996b39b063SEric Blake    echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
54006b39b063SEric Blakefi
54019df8b20dSThomas Huthif test "$have_openpty" = "yes" ; then
54029df8b20dSThomas Huth    echo "HAVE_OPENPTY=y" >> $config_host_mak
54039df8b20dSThomas Huthfi
5404277abf15SJan Vesely
5405277abf15SJan Vesely# Work around a system header bug with some kernel/XFS header
5406277abf15SJan Vesely# versions where they both try to define 'struct fsxattr':
5407277abf15SJan Vesely# xfs headers will not try to redefine structs from linux headers
5408277abf15SJan Vesely# if this macro is set.
5409277abf15SJan Veselyif test "$have_fsxattr" = "yes" ; then
5410277abf15SJan Vesely    echo "HAVE_FSXATTR=y" >> $config_host_mak
5411277abf15SJan Veselyfi
54121efad060SFam Zhengif test "$have_copy_file_range" = "yes" ; then
54131efad060SFam Zheng    echo "HAVE_COPY_FILE_RANGE=y" >> $config_host_mak
54141efad060SFam Zhengfi
54151badb709SPaolo Bonziniif test "$xen" = "enabled" ; then
54166dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
5417d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
5418582ea95fSMarc-André Lureau  echo "XEN_CFLAGS=$xen_cflags" >> $config_host_mak
5419582ea95fSMarc-André Lureau  echo "XEN_LIBS=$xen_libs" >> $config_host_mak
5420e37630caSaliguorifi
54215c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
54225c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
54235c6c3a6cSChristoph Hellwigfi
5424c10dd856SAarushi Mehtaif test "$linux_io_uring" = "yes" ; then
5425c10dd856SAarushi Mehta  echo "CONFIG_LINUX_IO_URING=y" >> $config_host_mak
5426c10dd856SAarushi Mehta  echo "LINUX_IO_URING_CFLAGS=$linux_io_uring_cflags" >> $config_host_mak
5427c10dd856SAarushi Mehta  echo "LINUX_IO_URING_LIBS=$linux_io_uring_libs" >> $config_host_mak
5428c10dd856SAarushi Mehtafi
54295e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then
54305e9be92dSNicholas Bellinger  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
54315e9be92dSNicholas Bellingerfi
5432af3bba76SPaolo Bonziniif test "$vhost_net" = "yes" ; then
5433af3bba76SPaolo Bonzini  echo "CONFIG_VHOST_NET=y" >> $config_host_mak
5434af3bba76SPaolo Bonzinifi
5435af3bba76SPaolo Bonziniif test "$vhost_net_user" = "yes" ; then
543656f41de7SPaolo Bonzini  echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak
543703ce5744SNikolay Nikolaevfi
5438108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" ; then
5439108a6481SCindy Lu  echo "CONFIG_VHOST_NET_VDPA=y" >> $config_host_mak
5440108a6481SCindy Lufi
5441042cea27SGongleiif test "$vhost_crypto" = "yes" ; then
5442042cea27SGonglei  echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
5443042cea27SGongleifi
5444fc0b9b0eSStefan Hajnocziif test "$vhost_vsock" = "yes" ; then
5445fc0b9b0eSStefan Hajnoczi  echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
54465fe97d88SStefano Garzarella  if test "$vhost_user" = "yes" ; then
54475fe97d88SStefano Garzarella    echo "CONFIG_VHOST_USER_VSOCK=y" >> $config_host_mak
54485fe97d88SStefano Garzarella  fi
5449fc0b9b0eSStefan Hajnoczifi
5450299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" ; then
5451299e6f19SPaolo Bonzini  echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak
5452299e6f19SPaolo Bonzinifi
5453e6a74868SMarc-André Lureauif test "$vhost_user" = "yes" ; then
5454e6a74868SMarc-André Lureau  echo "CONFIG_VHOST_USER=y" >> $config_host_mak
5455e6a74868SMarc-André Lureaufi
5456108a6481SCindy Luif test "$vhost_vdpa" = "yes" ; then
5457108a6481SCindy Lu  echo "CONFIG_VHOST_VDPA=y" >> $config_host_mak
5458108a6481SCindy Lufi
545998fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" ; then
546098fc1adaSDr. David Alan Gilbert  echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak
546198fc1adaSDr. David Alan Gilbertfi
5462bf9298b9Saliguoriif test "$iovec" = "yes" ; then
54632358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
5464bf9298b9Saliguorifi
5465a40161cbSPaolo Bonziniif test "$membarrier" = "yes" ; then
5466a40161cbSPaolo Bonzini  echo "CONFIG_MEMBARRIER=y" >> $config_host_mak
5467a40161cbSPaolo Bonzinifi
5468dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
5469dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
5470dcc38d1cSMarcelo Tosattifi
5471d339d766SRichard W.M. Jonesif test "$optreset" = "yes" ; then
5472d339d766SRichard W.M. Jones  echo "HAVE_OPTRESET=y" >> $config_host_mak
5473d339d766SRichard W.M. Jonesfi
5474e5b46549SRichard Hendersonif test "$tcg" = "enabled" -a "$tcg_interpreter" = "true" ; then
5475e5b46549SRichard Henderson  echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
5476e5b46549SRichard Hendersonfi
54775f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
54785f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
54795f6b9e8fSBlue Swirlfi
5480e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
5481e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
5482e78815a5SAndreas Färberfi
5483e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
5484e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
5485e78815a5SAndreas Färberfi
54869bc5a719SAndreas Gustafssonif test "$posix_memalign" = "yes" ; then
54879bc5a719SAndreas Gustafsson  echo "CONFIG_POSIX_MEMALIGN=y" >> $config_host_mak
54889bc5a719SAndreas Gustafssonfi
548958d3f3ffSGerd Hoffmann
549058d3f3ffSGerd Hoffmannif test "$spice_protocol" = "yes" ; then
549158d3f3ffSGerd Hoffmann  echo "CONFIG_SPICE_PROTOCOL=y" >> $config_host_mak
549258d3f3ffSGerd Hoffmann  echo "SPICE_PROTOCOL_CFLAGS=$spice_protocol_cflags" >> $config_host_mak
549358d3f3ffSGerd Hoffmannfi
5494cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
5495cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
549658d3f3ffSGerd Hoffmann  echo "SPICE_CFLAGS=$spice_cflags $spice_protocol_cflags" >> $config_host_mak
54972634733cSPaolo Bonzini  echo "SPICE_LIBS=$spice_libs" >> $config_host_mak
5498cd4ec0b4SGerd Hoffmannfi
5499cd4ec0b4SGerd Hoffmann
5500da076ffeSGerd Hoffmannif test "$opengl" = "yes" ; then
5501da076ffeSGerd Hoffmann  echo "CONFIG_OPENGL=y" >> $config_host_mak
5502de2d3005SPaolo Bonzini  echo "OPENGL_CFLAGS=$opengl_cflags" >> $config_host_mak
5503da076ffeSGerd Hoffmann  echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
550420ff075bSMichael Wallefi
550520ff075bSMichael Walle
5506d52c454aSMarc-André Lureauif test "$gbm" = "yes" ; then
5507d52c454aSMarc-André Lureau    echo "CONFIG_GBM=y" >> $config_host_mak
5508d52c454aSMarc-André Lureau    echo "GBM_LIBS=$gbm_libs" >> $config_host_mak
5509d52c454aSMarc-André Lureau    echo "GBM_CFLAGS=$gbm_cflags" >> $config_host_mak
5510d52c454aSMarc-André Lureaufi
5511d52c454aSMarc-André Lureau
5512d52c454aSMarc-André Lureau
551399f2dbd3SLiang Liif test "$avx2_opt" = "yes" ; then
551499f2dbd3SLiang Li  echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
551599f2dbd3SLiang Lifi
551699f2dbd3SLiang Li
55176b8cd447SRobert Hooif test "$avx512f_opt" = "yes" ; then
55186b8cd447SRobert Hoo  echo "CONFIG_AVX512F_OPT=y" >> $config_host_mak
55196b8cd447SRobert Hoofi
55206b8cd447SRobert Hoo
552183fb7adfSbellard# XXX: suppress that
55227d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
55232358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
55247d3505c5Sbellardfi
55257d3505c5Sbellard
55263556c233SPaolo Bonziniif test "$qom_cast_debug" = "yes" ; then
55273556c233SPaolo Bonzini  echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
55283556c233SPaolo Bonzinifi
552920ff6c80SAnthony Liguori
55307c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
553170c60c08SStefan Hajnocziif test "$coroutine_pool" = "yes" ; then
553270c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
553370c60c08SStefan Hajnoczielse
553470c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
553570c60c08SStefan Hajnoczifi
5536d0e2fce5SAneesh Kumar K.V
55377d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes" ; then
55387d992e4dSPeter Lieven  echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
55397d992e4dSPeter Lievenfi
55407d992e4dSPeter Lieven
5541f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes" ; then
5542f0d92b56SLongpeng(Mike)  echo "CONFIG_AF_ALG=y" >> $config_host_mak
5543f0d92b56SLongpeng(Mike)fi
5544f0d92b56SLongpeng(Mike)
5545d2042378SAneesh Kumar K.Vif test "$open_by_handle_at" = "yes" ; then
5546d2042378SAneesh Kumar K.V  echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
5547d2042378SAneesh Kumar K.Vfi
5548d2042378SAneesh Kumar K.V
5549e06a765eSHarsh Prateek Boraif test "$linux_magic_h" = "yes" ; then
5550e06a765eSHarsh Prateek Bora  echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
5551e06a765eSHarsh Prateek Borafi
5552e06a765eSHarsh Prateek Bora
55533f4349dcSKevin Wolfif test "$valgrind_h" = "yes" ; then
55543f4349dcSKevin Wolf  echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
55553f4349dcSKevin Wolffi
55563f4349dcSKevin Wolf
5557d83414e1SMarc-André Lureauif test "$have_asan_iface_fiber" = "yes" ; then
5558d83414e1SMarc-André Lureau    echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
5559d83414e1SMarc-André Lureaufi
5560d83414e1SMarc-André Lureau
55610aebab04SLingfeng Yangif test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then
55620aebab04SLingfeng Yang    echo "CONFIG_TSAN=y" >> $config_host_mak
55630aebab04SLingfeng Yangfi
55640aebab04SLingfeng Yang
55658ab1bf12SLuiz Capitulinoif test "$has_environ" = "yes" ; then
55668ab1bf12SLuiz Capitulino  echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
55678ab1bf12SLuiz Capitulinofi
55688ab1bf12SLuiz Capitulino
556976a347e1SRichard Hendersonif test "$cpuid_h" = "yes" ; then
557076a347e1SRichard Henderson  echo "CONFIG_CPUID_H=y" >> $config_host_mak
557176a347e1SRichard Hendersonfi
557276a347e1SRichard Henderson
5573f540166bSRichard Hendersonif test "$int128" = "yes" ; then
5574f540166bSRichard Henderson  echo "CONFIG_INT128=y" >> $config_host_mak
5575f540166bSRichard Hendersonfi
5576f540166bSRichard Henderson
55777ebee43eSRichard Hendersonif test "$atomic128" = "yes" ; then
55787ebee43eSRichard Henderson  echo "CONFIG_ATOMIC128=y" >> $config_host_mak
55797ebee43eSRichard Hendersonfi
55807ebee43eSRichard Henderson
5581e6cd4bb5SRichard Hendersonif test "$cmpxchg128" = "yes" ; then
5582e6cd4bb5SRichard Henderson  echo "CONFIG_CMPXCHG128=y" >> $config_host_mak
5583e6cd4bb5SRichard Hendersonfi
5584e6cd4bb5SRichard Henderson
5585df79b996SRichard Hendersonif test "$atomic64" = "yes" ; then
5586df79b996SRichard Henderson  echo "CONFIG_ATOMIC64=y" >> $config_host_mak
5587df79b996SRichard Hendersonfi
5588df79b996SRichard Henderson
55891e6e9acaSRichard Hendersonif test "$getauxval" = "yes" ; then
55901e6e9acaSRichard Henderson  echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
55911e6e9acaSRichard Hendersonfi
55921e6e9acaSRichard Henderson
5593b10d49d7SPino Toscanoif test "$libssh" = "yes" ; then
5594484e2cc7SPaolo Bonzini  echo "CONFIG_LIBSSH=y" >> $config_host_mak
5595b10d49d7SPino Toscano  echo "LIBSSH_CFLAGS=$libssh_cflags" >> $config_host_mak
5596b10d49d7SPino Toscano  echo "LIBSSH_LIBS=$libssh_libs" >> $config_host_mak
55970a12ec87SRichard W.M. Jonesfi
55980a12ec87SRichard W.M. Jones
5599ed1701c6SDr. David Alan Gilbertif test "$live_block_migration" = "yes" ; then
5600ed1701c6SDr. David Alan Gilbert  echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
5601ed1701c6SDr. David Alan Gilbertfi
5602ed1701c6SDr. David Alan Gilbert
56033b8acc11SPaolo Bonziniif test "$tpm" = "yes"; then
56043cae16dbSPaolo Bonzini  echo 'CONFIG_TPM=y' >> $config_host_mak
56053b8acc11SPaolo Bonzinifi
56063b8acc11SPaolo Bonzini
56075b808275SLluís Vilanovaecho "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
56085b808275SLluís Vilanovaif have_backend "nop"; then
56096d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
561022890ab5SPrerna Saxenafi
56115b808275SLluís Vilanovaif have_backend "simple"; then
56126d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
56136d8a764eSLluís  # Set the appropriate trace file.
5614953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
56159410b56cSPrerna Saxenafi
5616ed7f5f1dSPaolo Bonziniif have_backend "log"; then
5617ed7f5f1dSPaolo Bonzini  echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
56186d8a764eSLluísfi
56195b808275SLluís Vilanovaif have_backend "ust"; then
56206d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
5621a81df1b6SPaolo Bonzini  echo "LTTNG_UST_LIBS=$lttng_ust_libs" >> $config_host_mak
5622a81df1b6SPaolo Bonzini  echo "URCU_BP_LIBS=$urcu_bp_libs" >> $config_host_mak
56236d8a764eSLluísfi
56245b808275SLluís Vilanovaif have_backend "dtrace"; then
56256d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
56266d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
56276d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
56286d8a764eSLluís  fi
5629c276b17dSDaniel P. Berrangefi
56305b808275SLluís Vilanovaif have_backend "ftrace"; then
5631781e9545SEiichi Tsukata  if test "$linux" = "yes" ; then
5632781e9545SEiichi Tsukata    echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
5633781e9545SEiichi Tsukata  else
563421684af0SStewart Smith    feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
5635781e9545SEiichi Tsukata  fi
5636781e9545SEiichi Tsukatafi
56370a852417SPaul Durrantif have_backend "syslog"; then
56380a852417SPaul Durrant  if test "$posix_syslog" = "yes" ; then
56390a852417SPaul Durrant    echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
56400a852417SPaul Durrant  else
56410a852417SPaul Durrant    feature_not_found "syslog(trace backend)" "syslog not available"
56420a852417SPaul Durrant  fi
56430a852417SPaul Durrantfi
56449410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
56459410b56cSPrerna Saxena
56462da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then
56472da776dbSMichael R. Hines  echo "CONFIG_RDMA=y" >> $config_host_mak
5648392fb643SFam Zheng  echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
56492da776dbSMichael R. Hinesfi
56502da776dbSMichael R. Hines
565121ab34c9SMarcel Apfelbaumif test "$pvrdma" = "yes" ; then
565221ab34c9SMarcel Apfelbaum  echo "CONFIG_PVRDMA=y" >> $config_host_mak
565321ab34c9SMarcel Apfelbaumfi
565421ab34c9SMarcel Apfelbaum
5655575b22b1SLaurent Vivierif test "$have_rtnetlink" = "yes" ; then
5656575b22b1SLaurent Vivier  echo "CONFIG_RTNETLINK=y" >> $config_host_mak
5657575b22b1SLaurent Vivierfi
5658575b22b1SLaurent Vivier
5659ed279a06SKlim Kireevif test "$libxml2" = "yes" ; then
5660ed279a06SKlim Kireev  echo "CONFIG_LIBXML2=y" >> $config_host_mak
5661ed279a06SKlim Kireev  echo "LIBXML2_CFLAGS=$libxml2_cflags" >> $config_host_mak
5662ed279a06SKlim Kireev  echo "LIBXML2_LIBS=$libxml2_libs" >> $config_host_mak
5663ed279a06SKlim Kireevfi
5664ed279a06SKlim Kireev
5665a6b1d4c0SChanglong Xieif test "$replication" = "yes" ; then
5666a6b1d4c0SChanglong Xie  echo "CONFIG_REPLICATION=y" >> $config_host_mak
5667a6b1d4c0SChanglong Xiefi
5668a6b1d4c0SChanglong Xie
56696a02c806SStefan Hajnocziif test "$have_af_vsock" = "yes" ; then
56706a02c806SStefan Hajnoczi  echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
56716a02c806SStefan Hajnoczifi
56726a02c806SStefan Hajnoczi
56734d04351fSChristopher Covingtonif test "$have_sysmacros" = "yes" ; then
56744d04351fSChristopher Covington  echo "CONFIG_SYSMACROS=y" >> $config_host_mak
56754d04351fSChristopher Covingtonfi
56764d04351fSChristopher Covington
5677e674605fSTomáš Golembiovskýif test "$have_utmpx" = "yes" ; then
5678e674605fSTomáš Golembiovský  echo "HAVE_UTMPX=y" >> $config_host_mak
5679e674605fSTomáš Golembiovskýfi
5680db1ed1abSRichard Hendersonif test "$have_getrandom" = "yes" ; then
5681db1ed1abSRichard Henderson  echo "CONFIG_GETRANDOM=y" >> $config_host_mak
5682db1ed1abSRichard Hendersonfi
5683e0580342SKamil Rytarowskiif test "$ivshmem" = "yes" ; then
5684e0580342SKamil Rytarowski  echo "CONFIG_IVSHMEM=y" >> $config_host_mak
5685e0580342SKamil Rytarowskifi
5686ba59fb77SPaolo Bonziniif test "$debug_mutex" = "yes" ; then
5687ba59fb77SPaolo Bonzini  echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak
5688ba59fb77SPaolo Bonzinifi
5689e0580342SKamil Rytarowski
56905c312079SDr. David Alan Gilbert# Hold two types of flag:
56915c312079SDr. David Alan Gilbert#   CONFIG_THREAD_SETNAME_BYTHREAD  - we've got a way of setting the name on
56925c312079SDr. David Alan Gilbert#                                     a thread we have a handle to
5693479a5747SRoman Bolshakov#   CONFIG_PTHREAD_SETNAME_NP_W_TID - A way of doing it on a particular
56945c312079SDr. David Alan Gilbert#                                     platform
5695479a5747SRoman Bolshakovif test "$pthread_setname_np_w_tid" = "yes" ; then
56965c312079SDr. David Alan Gilbert  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
5697479a5747SRoman Bolshakov  echo "CONFIG_PTHREAD_SETNAME_NP_W_TID=y" >> $config_host_mak
5698479a5747SRoman Bolshakovelif test "$pthread_setname_np_wo_tid" = "yes" ; then
5699479a5747SRoman Bolshakov  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
5700479a5747SRoman Bolshakov  echo "CONFIG_PTHREAD_SETNAME_NP_WO_TID=y" >> $config_host_mak
57015c312079SDr. David Alan Gilbertfi
57025c312079SDr. David Alan Gilbert
570317824406SJunyan Heif test "$libpmem" = "yes" ; then
570417824406SJunyan He  echo "CONFIG_LIBPMEM=y" >> $config_host_mak
5705c9322ab5SMarc-André Lureau  echo "LIBPMEM_LIBS=$libpmem_libs" >> $config_host_mak
5706c9322ab5SMarc-André Lureau  echo "LIBPMEM_CFLAGS=$libpmem_cflags" >> $config_host_mak
570717824406SJunyan Hefi
570817824406SJunyan He
57092f740136SJeff Codyif test "$bochs" = "yes" ; then
57102f740136SJeff Cody  echo "CONFIG_BOCHS=y" >> $config_host_mak
57112f740136SJeff Codyfi
57122f740136SJeff Codyif test "$cloop" = "yes" ; then
57132f740136SJeff Cody  echo "CONFIG_CLOOP=y" >> $config_host_mak
57142f740136SJeff Codyfi
57152f740136SJeff Codyif test "$dmg" = "yes" ; then
57162f740136SJeff Cody  echo "CONFIG_DMG=y" >> $config_host_mak
57172f740136SJeff Codyfi
57182f740136SJeff Codyif test "$qcow1" = "yes" ; then
57192f740136SJeff Cody  echo "CONFIG_QCOW1=y" >> $config_host_mak
57202f740136SJeff Codyfi
57212f740136SJeff Codyif test "$vdi" = "yes" ; then
57222f740136SJeff Cody  echo "CONFIG_VDI=y" >> $config_host_mak
57232f740136SJeff Codyfi
57242f740136SJeff Codyif test "$vvfat" = "yes" ; then
57252f740136SJeff Cody  echo "CONFIG_VVFAT=y" >> $config_host_mak
57262f740136SJeff Codyfi
57272f740136SJeff Codyif test "$qed" = "yes" ; then
57282f740136SJeff Cody  echo "CONFIG_QED=y" >> $config_host_mak
57292f740136SJeff Codyfi
57302f740136SJeff Codyif test "$parallels" = "yes" ; then
57312f740136SJeff Cody  echo "CONFIG_PARALLELS=y" >> $config_host_mak
57322f740136SJeff Codyfi
5733195588ccSDavid CARLIERif test "$have_mlockall" = "yes" ; then
5734195588ccSDavid CARLIER  echo "HAVE_MLOCKALL=y" >> $config_host_mak
5735195588ccSDavid CARLIERfi
5736adc28027SAlexander Bulekovif test "$fuzzing" = "yes" ; then
573754c9e41dSAlexander Bulekov  # If LIB_FUZZING_ENGINE is set, assume we are running on OSS-Fuzz, and the
573854c9e41dSAlexander Bulekov  # needed CFLAGS have already been provided
573954c9e41dSAlexander Bulekov  if test -z "${LIB_FUZZING_ENGINE+xxx}" ; then
5740efce01bcSAlexander Bulekov    # Add CFLAGS to tell clang to add fuzzer-related instrumentation to all the
5741efce01bcSAlexander Bulekov    # compiled code.
5742086d5f75SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS -fsanitize=fuzzer-no-link"
5743efce01bcSAlexander Bulekov    # To build non-fuzzer binaries with --enable-fuzzing, link everything with
5744efce01bcSAlexander Bulekov    # fsanitize=fuzzer-no-link. Otherwise, the linker will be unable to bind
5745efce01bcSAlexander Bulekov    # the fuzzer-related callbacks added by instrumentation.
5746efce01bcSAlexander Bulekov    QEMU_LDFLAGS="$QEMU_LDFLAGS -fsanitize=fuzzer-no-link"
5747efce01bcSAlexander Bulekov    # For the actual fuzzer binaries, we need to link against the libfuzzer
5748efce01bcSAlexander Bulekov    # library. Provide the flags for doing this in FUZZ_EXE_LDFLAGS. The meson
5749efce01bcSAlexander Bulekov    # rule for the fuzzer adds these to the link_args. They need to be
5750efce01bcSAlexander Bulekov    # configurable, to support OSS-Fuzz
575154c9e41dSAlexander Bulekov    FUZZ_EXE_LDFLAGS="-fsanitize=fuzzer"
575254c9e41dSAlexander Bulekov  else
575354c9e41dSAlexander Bulekov    FUZZ_EXE_LDFLAGS="$LIB_FUZZING_ENGINE"
575454c9e41dSAlexander Bulekov  fi
5755adc28027SAlexander Bulekovfi
57562f740136SJeff Cody
575740e8c6f4SAlex Bennéeif test "$plugins" = "yes" ; then
575840e8c6f4SAlex Bennée    echo "CONFIG_PLUGIN=y" >> $config_host_mak
575926fffe29SEmilio G. Cota    # Copy the export object list to the build dir
576026fffe29SEmilio G. Cota    if test "$ld_dynamic_list" = "yes" ; then
576126fffe29SEmilio G. Cota	echo "CONFIG_HAS_LD_DYNAMIC_LIST=yes" >> $config_host_mak
576226fffe29SEmilio G. Cota	ld_symbols=qemu-plugins-ld.symbols
576326fffe29SEmilio G. Cota	cp "$source_path/plugins/qemu-plugins.symbols" $ld_symbols
576426fffe29SEmilio G. Cota    elif test "$ld_exported_symbols_list" = "yes" ; then
576526fffe29SEmilio G. Cota	echo "CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST=yes" >> $config_host_mak
576626fffe29SEmilio G. Cota	ld64_symbols=qemu-plugins-ld64.symbols
576726fffe29SEmilio G. Cota	echo "# Automatically generated by configure - do not modify" > $ld64_symbols
576826fffe29SEmilio G. Cota	grep 'qemu_' "$source_path/plugins/qemu-plugins.symbols" | sed 's/;//g' | \
576926fffe29SEmilio G. Cota	    sed -E 's/^[[:space:]]*(.*)/_\1/' >> $ld64_symbols
577026fffe29SEmilio G. Cota    else
577126fffe29SEmilio G. Cota	error_exit \
577226fffe29SEmilio G. Cota	    "If \$plugins=yes, either \$ld_dynamic_list or " \
577326fffe29SEmilio G. Cota	    "\$ld_exported_symbols_list should have been set to 'yes'."
577426fffe29SEmilio G. Cota    fi
577540e8c6f4SAlex Bennéefi
577640e8c6f4SAlex Bennée
5777f48e590aSAlex Bennéeif test -n "$gdb_bin"; then
5778b1863cccSAlex Bennée    gdb_version=$($gdb_bin --version | head -n 1)
5779d6a66c81SAlex Bennée    if version_ge ${gdb_version##* } 9.1; then
5780f48e590aSAlex Bennée        echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
5781f48e590aSAlex Bennée    fi
5782b1863cccSAlex Bennéefi
5783f48e590aSAlex Bennée
578454e7aac0SAlexey Krasikovif test "$secret_keyring" = "yes" ; then
578554e7aac0SAlexey Krasikov  echo "CONFIG_SECRET_KEYRING=y" >> $config_host_mak
578654e7aac0SAlexey Krasikovfi
578754e7aac0SAlexey Krasikov
578898ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
5789804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
5790c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
579139d87c8cSAlex Bennéeecho "GENISOIMAGE=$genisoimage" >> $config_host_mak
5792a5665051SPaolo Bonziniecho "MESON=$meson" >> $config_host_mak
579309e93326SPaolo Bonziniecho "NINJA=$ninja" >> $config_host_mak
5794804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
5795433de74cSBastian Koppelmannecho "HOST_CC=$host_cc" >> $config_host_mak
5796a31a8642SMichael S. Tsirkinif $iasl -h > /dev/null 2>&1; then
5797859aef02SPaolo Bonzini  echo "CONFIG_IASL=$iasl" >> $config_host_mak
5798a31a8642SMichael S. Tsirkinfi
579983f73fceSTomoki Sekiyamaecho "CXX=$cxx" >> $config_host_mak
58003c4a4d0dSPeter Maydellecho "OBJCC=$objcc" >> $config_host_mak
5801804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
580245d285abSPeter Maydellecho "ARFLAGS=$ARFLAGS" >> $config_host_mak
5803cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak
58045f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak
58053dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak
5806804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
5807804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
58089f81aeb5SAlistair Francisecho "RANLIB=$ranlib" >> $config_host_mak
58094852ee95SStefan Weilecho "NM=$nm" >> $config_host_mak
5810daa79d9aSAlex Bennéeecho "PKG_CONFIG=$pkg_config_exe" >> $config_host_mak
58119fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
581246eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
5813a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
581411cde1c8SBruno Dominguezecho "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
5815a81df1b6SPaolo Bonziniecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
5816a81df1b6SPaolo Bonziniecho "GLIB_LIBS=$glib_libs" >> $config_host_mak
58178a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
5818e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
5819804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
5820484e2cc7SPaolo Bonziniecho "HOST_DSOSUF=$HOST_DSOSUF" >> $config_host_mak
5821f15bff25SPaolo Bonziniecho "LIBS_QGA=$libs_qga" >> $config_host_mak
58221d728c39SBlue Swirlif test "$gcov" = "yes" ; then
58231d728c39SBlue Swirl  echo "CONFIG_GCOV=y" >> $config_host_mak
58241d728c39SBlue Swirlfi
5825804edf29SJuan Quintela
5826adc28027SAlexander Bulekovif test "$fuzzing" != "no"; then
5827adc28027SAlexander Bulekov    echo "CONFIG_FUZZ=y" >> $config_host_mak
5828adc28027SAlexander Bulekovfi
582954c9e41dSAlexander Bulekovecho "FUZZ_EXE_LDFLAGS=$FUZZ_EXE_LDFLAGS" >> $config_host_mak
58303efac6ebSTomáš Golembiovský
5831b767d257SMarek Marczykowski-Góreckiif test "$rng_none" = "yes"; then
5832b767d257SMarek Marczykowski-Górecki  echo "CONFIG_RNG_NONE=y" >> $config_host_mak
5833b767d257SMarek Marczykowski-Góreckifi
5834b767d257SMarek Marczykowski-Górecki
58356efd7517SPeter Maydell# use included Linux headers
58366efd7517SPeter Maydellif test "$linux" = "yes" ; then
5837a307beb6SAndreas Färber  mkdir -p linux-headers
58386efd7517SPeter Maydell  case "$cpu" in
5839c72b26ecSRichard Henderson  i386|x86_64|x32)
584008312a63SPeter Maydell    linux_arch=x86
58416efd7517SPeter Maydell    ;;
5842f8378accSRichard Henderson  ppc|ppc64|ppc64le)
584308312a63SPeter Maydell    linux_arch=powerpc
58446efd7517SPeter Maydell    ;;
58456efd7517SPeter Maydell  s390x)
584608312a63SPeter Maydell    linux_arch=s390
584708312a63SPeter Maydell    ;;
58481f080313SClaudio Fontana  aarch64)
58491f080313SClaudio Fontana    linux_arch=arm64
58501f080313SClaudio Fontana    ;;
5851222e7d11SSanjay Lal  mips64)
5852222e7d11SSanjay Lal    linux_arch=mips
5853222e7d11SSanjay Lal    ;;
585408312a63SPeter Maydell  *)
585508312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
585608312a63SPeter Maydell    linux_arch="$cpu"
58576efd7517SPeter Maydell    ;;
58586efd7517SPeter Maydell  esac
585908312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
586008312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
586108312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
586208312a63SPeter Maydell    fi
58636efd7517SPeter Maydellfi
58646efd7517SPeter Maydell
586597a847bcSbellardfor target in $target_list; do
586697a847bcSbellard    target_dir="$target"
586789138857SStefan Weil    target_name=$(echo $target | cut -d '-' -f 1)
586897a847bcSbellard    mkdir -p $target_dir
5869fdb75aefSPaolo Bonzini    case $target in
5870fdb75aefSPaolo Bonzini        *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;;
5871fdb75aefSPaolo Bonzini        *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;;
58722408a527Saurel32    esac
587356aebc89Spbrookdone
58747d13299dSbellard
5875765686d6SPaolo Bonziniecho "CONFIG_QEMU_INTERP_PREFIX=$interp_prefix" | sed 's/%M/@0@/' >> $config_host_mak
5876fdb75aefSPaolo Bonziniif test "$default_targets" = "yes"; then
5877fdb75aefSPaolo Bonzini  echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak
5878fdb75aefSPaolo Bonzinifi
5879a540f158SPeter Crosthwaite
5880a99d57bbSWanlong Gaoif test "$numa" = "yes"; then
5881a99d57bbSWanlong Gao  echo "CONFIG_NUMA=y" >> $config_host_mak
5882ab318051SMarc-André Lureau  echo "NUMA_LIBS=$numa_libs" >> $config_host_mak
5883a99d57bbSWanlong Gaofi
5884a99d57bbSWanlong Gao
5885fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then
5886fd0e6053SJohn Snow  echo "export CCACHE_CPP2=y" >> $config_host_mak
5887fd0e6053SJohn Snowfi
5888fd0e6053SJohn Snow
58891e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then
58901e4f6065SDaniele Buono  echo "CONFIG_SAFESTACK=y" >> $config_host_mak
58911e4f6065SDaniele Buonofi
58921e4f6065SDaniele Buono
5893e29e5c6eSPeter Maydell# If we're using a separate build tree, set it up now.
5894e29e5c6eSPeter Maydell# DIRS are directories which we simply mkdir in the build tree;
5895e29e5c6eSPeter Maydell# LINKS are things to symlink back into the source tree
5896e29e5c6eSPeter Maydell# (these can be both files and directories).
5897e29e5c6eSPeter Maydell# Caution: do not add files or directories here using wildcards. This
5898e29e5c6eSPeter Maydell# will result in problems later if a new file matching the wildcard is
5899e29e5c6eSPeter Maydell# added to the source tree -- nothing will cause configure to be rerun
5900e29e5c6eSPeter Maydell# so the build tree will be missing the link back to the new file, and
5901e29e5c6eSPeter Maydell# tests might fail. Prefer to keep the relevant files in their own
5902e29e5c6eSPeter Maydell# directory and symlink the directory instead.
590309db9b9dSGerd Hoffmann# UNLINK is used to remove symlinks from older development versions
590409db9b9dSGerd Hoffmann# that might get into the way when doing "git update" without doing
590509db9b9dSGerd Hoffmann# a "make distclean" in between.
59069d49bcf6SMarkus ArmbrusterDIRS="tests tests/tcg tests/qapi-schema tests/qtest/libqos"
59071cf4323eSThomas HuthDIRS="$DIRS tests/qtest tests/qemu-iotests tests/vm tests/fp tests/qgraph"
5908b855f8d1SPaolo BonziniDIRS="$DIRS docs docs/interop fsdev scsi"
5909744a928cSAlexey KardashevskiyDIRS="$DIRS pc-bios/optionrom pc-bios/s390-ccw"
59108db2a4fdSGerd HoffmannDIRS="$DIRS roms/seabios"
5911c17a386bSAlex BennéeDIRS="$DIRS contrib/plugins/"
59122038f8c8SPaolo BonziniLINKS="Makefile"
59133941996bSPaolo BonziniLINKS="$LINKS tests/tcg/Makefile.target"
5914ddcf607fSGerd HoffmannLINKS="$LINKS pc-bios/optionrom/Makefile"
5915e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/s390-ccw/Makefile"
59168db2a4fdSGerd HoffmannLINKS="$LINKS roms/seabios/Makefile"
5917e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/qemu-icon.bmp"
5918e29e5c6eSPeter MaydellLINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
591939950353SPeter MaydellLINKS="$LINKS tests/acceptance tests/data"
592039950353SPeter MaydellLINKS="$LINKS tests/qemu-iotests/check"
59218f8fd9edSCleber RosaLINKS="$LINKS python"
5922c17a386bSAlex BennéeLINKS="$LINKS contrib/plugins/Makefile "
592309db9b9dSGerd HoffmannUNLINK="pc-bios/keymaps"
5924753d11f2SRichard Hendersonfor bios_file in \
5925753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
59263a631b8eSBin Meng    $source_path/pc-bios/*.elf \
5927225a9ab8SAlexey Kardashevskiy    $source_path/pc-bios/*.lid \
5928753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
5929753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
5930e89e33e1SDominik Dingel    $source_path/pc-bios/*.img \
5931753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
59324e73c781SAlexander Graf    $source_path/pc-bios/u-boot.* \
593326ce90fdSLaszlo Ersek    $source_path/pc-bios/edk2-*.fd.bz2 \
5934753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
5935753d11f2SRichard Hendersondo
5936e29e5c6eSPeter Maydell    LINKS="$LINKS pc-bios/$(basename $bios_file)"
59377ea78b74SJan Kiszkadone
5938d1807a4fSPaolo Bonzinimkdir -p $DIRS
5939e29e5c6eSPeter Maydellfor f in $LINKS ; do
59400f4d8894SPaolo Bonzini    if [ -e "$source_path/$f" ]; then
5941f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
5942f9245e10SPeter Maydell    fi
59437d13299dSbellarddone
594409db9b9dSGerd Hoffmannfor f in $UNLINK ; do
594509db9b9dSGerd Hoffmann    if [ -L "$f" ]; then
594609db9b9dSGerd Hoffmann        rm -f "$f"
594709db9b9dSGerd Hoffmann    fi
594809db9b9dSGerd Hoffmanndone
59491ad2134fSPaul Brook
59502038f8c8SPaolo Bonzini(for i in $cross_cc_vars; do
59512038f8c8SPaolo Bonzini  export $i
59522038f8c8SPaolo Bonzinidone
5953de6d7e6bSAlex Bennéeexport target_list source_path use_containers ARCH
59542038f8c8SPaolo Bonzini$source_path/tests/tcg/configure.sh)
59552038f8c8SPaolo Bonzini
5956c34ebfdcSAnthony Liguori# temporary config to build submodules
59578db2a4fdSGerd Hoffmannfor rom in seabios; do
5958c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
595937116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
5960c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
5961cdbd727cSRichard Henderson    echo "AS=$as" >> $config_mak
59625f6f0e27SRichard Henderson    echo "CCAS=$ccas" >> $config_mak
5963c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
5964c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
59653dd46c78SBlue Swirl    echo "CPP=$cpp" >> $config_mak
5966c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
5967a31a8642SMichael S. Tsirkin    echo "IASL=$iasl" >> $config_mak
5968c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
59699f81aeb5SAlistair Francis    echo "RANLIB=$ranlib" >> $config_mak
5970c34ebfdcSAnthony Liguoridone
5971c34ebfdcSAnthony Liguori
5972a5665051SPaolo Bonziniif test "$skip_meson" = no; then
5973fc929892SMarc-André Lureau  cross="config-meson.cross.new"
5974fc929892SMarc-André Lureau  meson_quote() {
597547b30835SPaolo Bonzini    echo "'$(echo $* | sed "s/ /','/g")'"
5976fc929892SMarc-André Lureau  }
5977fc929892SMarc-André Lureau
5978fc929892SMarc-André Lureau  echo "# Automatically generated by configure - do not modify" > $cross
5979fc929892SMarc-André Lureau  echo "[properties]" >> $cross
5980fc929892SMarc-André Lureau  test -z "$cxx" && echo "link_language = 'c'" >> $cross
598147b30835SPaolo Bonzini  echo "[built-in options]" >> $cross
598247b30835SPaolo Bonzini  echo "c_args = [${CFLAGS:+$(meson_quote $CFLAGS)}]" >> $cross
598347b30835SPaolo Bonzini  echo "cpp_args = [${CXXFLAGS:+$(meson_quote $CXXFLAGS)}]" >> $cross
598447b30835SPaolo Bonzini  echo "c_link_args = [${LDFLAGS:+$(meson_quote $LDFLAGS)}]" >> $cross
598547b30835SPaolo Bonzini  echo "cpp_link_args = [${LDFLAGS:+$(meson_quote $LDFLAGS)}]" >> $cross
5986fc929892SMarc-André Lureau  echo "[binaries]" >> $cross
598747b30835SPaolo Bonzini  echo "c = [$(meson_quote $cc)]" >> $cross
598847b30835SPaolo Bonzini  test -n "$cxx" && echo "cpp = [$(meson_quote $cxx)]" >> $cross
59890ca321eaSJoelle van Dyne  test -n "$objcc" && echo "objc = [$(meson_quote $objcc)]" >> $cross
599047b30835SPaolo Bonzini  echo "ar = [$(meson_quote $ar)]" >> $cross
599147b30835SPaolo Bonzini  echo "nm = [$(meson_quote $nm)]" >> $cross
599247b30835SPaolo Bonzini  echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross
599347b30835SPaolo Bonzini  echo "ranlib = [$(meson_quote $ranlib)]" >> $cross
5994e8178514SPaolo Bonzini  if has $sdl2_config; then
599547b30835SPaolo Bonzini    echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross
5996e8178514SPaolo Bonzini  fi
599747b30835SPaolo Bonzini  echo "strip = [$(meson_quote $strip)]" >> $cross
599847b30835SPaolo Bonzini  echo "windres = [$(meson_quote $windres)]" >> $cross
59993812c0c4SJoelle van Dyne  if test "$cross_compile" = "yes"; then
6000fc929892SMarc-André Lureau    cross_arg="--cross-file config-meson.cross"
6001fc929892SMarc-André Lureau    echo "[host_machine]" >> $cross
6002fc929892SMarc-André Lureau    if test "$mingw32" = "yes" ; then
6003fc929892SMarc-André Lureau        echo "system = 'windows'" >> $cross
6004fc929892SMarc-André Lureau    fi
6005853b4bafSThomas Huth    if test "$linux" = "yes" ; then
6006853b4bafSThomas Huth        echo "system = 'linux'" >> $cross
6007853b4bafSThomas Huth    fi
60080ca321eaSJoelle van Dyne    if test "$darwin" = "yes" ; then
60090ca321eaSJoelle van Dyne        echo "system = 'darwin'" >> $cross
60100ca321eaSJoelle van Dyne    fi
6011fc929892SMarc-André Lureau    case "$ARCH" in
6012f6bca9dfSJoelle van Dyne        i386)
6013fc929892SMarc-André Lureau            echo "cpu_family = 'x86'" >> $cross
6014fc929892SMarc-André Lureau            ;;
6015f8bb7e1cSDavid Michael        x86_64|x32)
6016f6bca9dfSJoelle van Dyne            echo "cpu_family = 'x86_64'" >> $cross
6017f6bca9dfSJoelle van Dyne            ;;
6018fc929892SMarc-André Lureau        ppc64le)
6019fc929892SMarc-André Lureau            echo "cpu_family = 'ppc64'" >> $cross
6020fc929892SMarc-André Lureau            ;;
6021fc929892SMarc-André Lureau        *)
6022fc929892SMarc-André Lureau            echo "cpu_family = '$ARCH'" >> $cross
6023fc929892SMarc-André Lureau            ;;
6024fc929892SMarc-André Lureau    esac
6025fc929892SMarc-André Lureau    echo "cpu = '$cpu'" >> $cross
6026fc929892SMarc-André Lureau    if test "$bigendian" = "yes" ; then
6027fc929892SMarc-André Lureau        echo "endian = 'big'" >> $cross
6028fc929892SMarc-André Lureau    else
6029fc929892SMarc-André Lureau        echo "endian = 'little'" >> $cross
6030fc929892SMarc-André Lureau    fi
6031fc929892SMarc-André Lureau  else
6032fc929892SMarc-André Lureau    cross_arg="--native-file config-meson.cross"
6033fc929892SMarc-André Lureau  fi
6034fc929892SMarc-André Lureau  mv $cross config-meson.cross
6035fc929892SMarc-André Lureau
6036a5665051SPaolo Bonzini  rm -rf meson-private meson-info meson-logs
6037a5cb7c5aSPaolo Bonzini  unset staticpic
6038a5cb7c5aSPaolo Bonzini  if ! version_ge "$($meson --version)" 0.56.0; then
6039a5cb7c5aSPaolo Bonzini    staticpic=$(if test "$pie" = yes; then echo true; else echo false; fi)
6040a5cb7c5aSPaolo Bonzini  fi
604109e93326SPaolo Bonzini  NINJA=$ninja $meson setup \
6042d17f305aSPaolo Bonzini        --prefix "$prefix" \
6043d17f305aSPaolo Bonzini        --libdir "$libdir" \
6044d17f305aSPaolo Bonzini        --libexecdir "$libexecdir" \
6045d17f305aSPaolo Bonzini        --bindir "$bindir" \
6046d17f305aSPaolo Bonzini        --includedir "$includedir" \
6047d17f305aSPaolo Bonzini        --datadir "$datadir" \
6048d17f305aSPaolo Bonzini        --mandir "$mandir" \
6049d17f305aSPaolo Bonzini        --sysconfdir "$sysconfdir" \
605016bf7a33SPaolo Bonzini        --localedir "$localedir" \
6051d17f305aSPaolo Bonzini        --localstatedir "$local_statedir" \
6052d17f305aSPaolo Bonzini        -Ddocdir="$docdir" \
605316bf7a33SPaolo Bonzini        -Dqemu_firmwarepath="$firmwarepath" \
605473f3aa37SMarc-André Lureau        -Dqemu_suffix="$qemu_suffix" \
6055a5665051SPaolo Bonzini        -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) \
6056a5665051SPaolo Bonzini        -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo false; fi) \
6057a5665051SPaolo Bonzini        -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \
6058a5665051SPaolo Bonzini        -Dstrip=$(if test "$strip_opt" = yes; then echo true; else echo false; fi) \
6059da6d48b9SMarc-André Lureau        -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \
6060a5cb7c5aSPaolo Bonzini        ${staticpic:+-Db_staticpic=$staticpic} \
6061bf0e56a3SMarc-André Lureau        -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \
60629e62ba48SDaniele Buono        -Db_lto=$lto -Dcfi=$cfi -Dcfi_debug=$cfi_debug \
6063deb62371SPaolo Bonzini        -Dmalloc=$malloc -Dmalloc_trim=$malloc_trim -Dsparse=$sparse \
606474a414a1SReinoud Zandijk        -Dkvm=$kvm -Dhax=$hax -Dwhpx=$whpx -Dhvf=$hvf -Dnvmm=$nvmm \
60651badb709SPaolo Bonzini        -Dxen=$xen -Dxen_pci_passthrough=$xen_pci_passthrough -Dtcg=$tcg \
60661b695471SPaolo Bonzini        -Dcocoa=$cocoa -Dgtk=$gtk -Dmpath=$mpath -Dsdl=$sdl -Dsdl_image=$sdl_image \
6067c23d7b4eSPaolo Bonzini        -Dlibusb=$libusb -Dsmartcard=$smartcard -Dusb_redir=$usb_redir -Dvte=$vte \
6068a0b93237SPaolo Bonzini        -Dvnc=$vnc -Dvnc_sasl=$vnc_sasl -Dvnc_jpeg=$vnc_jpeg -Dvnc_png=$vnc_png \
6069cece116cSMisono Tomohiro        -Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f -Dvirtiofsd=$virtiofsd \
60708c6d4ff4SPaolo Bonzini        -Dcapstone=$capstone -Dslirp=$slirp -Dfdt=$fdt -Dbrlapi=$brlapi \
60719db405a3SPaolo Bonzini        -Dcurl=$curl -Dglusterfs=$glusterfs -Dbzip2=$bzip2 -Dlibiscsi=$libiscsi \
607230045c05SPaolo Bonzini        -Dlibnfs=$libnfs -Diconv=$iconv -Dcurses=$curses -Dlibudev=$libudev\
6073ecea3696SPaolo Bonzini        -Drbd=$rbd -Dlzo=$lzo -Dsnappy=$snappy -Dlzfse=$lzfse \
6074*e36e8c70SPaolo Bonzini        -Dlibdaxctl=$libdaxctl -Dlibpmem=$libpmem \
607505e391aeSPaolo Bonzini        -Dgnutls=$gnutls -Dnettle=$nettle -Dgcrypt=$gcrypt -Dauth_pam=$auth_pam \
6076727c8bb8SPaolo Bonzini        -Dzstd=$zstd -Dseccomp=$seccomp -Dvirtfs=$virtfs -Dcap_ng=$cap_ng \
6077587d59d6SPaolo Bonzini        -Dattr=$attr -Ddefault_devices=$default_devices -Dvirglrenderer=$virglrenderer \
6078c8d5450bSPaolo Bonzini        -Ddocs=$docs -Dsphinx_build=$sphinx_build -Dinstall_blobs=$blobs \
6079106ad1f9SPaolo Bonzini        -Dvhost_user_blk_server=$vhost_user_blk_server -Dmultiprocess=$multiprocess \
608046627f41SAndrew Melnychenko        -Dfuse=$fuse -Dfuse_lseek=$fuse_lseek -Dguest_agent_msi=$guest_agent_msi -Dbpf=$bpf\
6081c87ea116SAlex Bennée        $(if test "$default_features" = no; then echo "-Dauto_features=disabled"; fi) \
6082c6fbea47SRichard Henderson	-Dtcg_interpreter=$tcg_interpreter \
6083fc929892SMarc-André Lureau        $cross_arg \
6084a5665051SPaolo Bonzini        "$PWD" "$source_path"
6085a5665051SPaolo Bonzini
6086a5665051SPaolo Bonzini  if test "$?" -ne 0 ; then
6087a5665051SPaolo Bonzini      error_exit "meson setup failed"
6088a5665051SPaolo Bonzini  fi
6089699d3884SPaolo Bonzinielse
6090699d3884SPaolo Bonzini  if test -f meson-private/cmd_line.txt; then
6091699d3884SPaolo Bonzini    # Adjust old command line options whose type was changed
6092699d3884SPaolo Bonzini    # Avoids having to use "setup --wipe" when Meson is upgraded
6093699d3884SPaolo Bonzini    perl -i -ne '
6094699d3884SPaolo Bonzini      s/^gettext = true$/gettext = auto/;
6095699d3884SPaolo Bonzini      s/^gettext = false$/gettext = disabled/;
6096699d3884SPaolo Bonzini      print;' meson-private/cmd_line.txt
6097699d3884SPaolo Bonzini  fi
6098a5665051SPaolo Bonzinifi
6099a5665051SPaolo Bonzini
61002d838d9bSAlex Bennéeif test -n "${deprecated_features}"; then
61012d838d9bSAlex Bennée    echo "Warning, deprecated features enabled."
61022d838d9bSAlex Bennée    echo "Please see docs/system/deprecated.rst"
61032d838d9bSAlex Bennée    echo "  features: ${deprecated_features}"
61042d838d9bSAlex Bennéefi
61052d838d9bSAlex Bennée
6106e0447a83SThomas Huth# Create list of config switches that should be poisoned in common code...
6107e0447a83SThomas Huth# but filter out CONFIG_TCG and CONFIG_USER_ONLY which are special.
610854b0306eSThomas Huthtarget_configs_h=$(ls *-config-devices.h *-config-target.h 2>/dev/null)
610954b0306eSThomas Huthif test -n "$target_configs_h" ; then
6110e0447a83SThomas Huth    sed -n -e '/CONFIG_TCG/d' -e '/CONFIG_USER_ONLY/d' \
6111e0447a83SThomas Huth        -e '/^#define / { s///; s/ .*//; s/^/#pragma GCC poison /p; }' \
611254b0306eSThomas Huth        $target_configs_h | sort -u > config-poison.h
611354b0306eSThomas Huthelse
611454b0306eSThomas Huth    :> config-poison.h
611554b0306eSThomas Huthfi
6116e0447a83SThomas Huth
6117dc655404SMichael S. Tsirkin# Save the configure command line for later reuse.
6118dc655404SMichael S. Tsirkincat <<EOD >config.status
6119dc655404SMichael S. Tsirkin#!/bin/sh
6120dc655404SMichael S. Tsirkin# Generated by configure.
6121dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration.
6122dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging
6123dc655404SMichael S. Tsirkin# configure, is in config.log if it exists.
6124dc655404SMichael S. TsirkinEOD
6125e811da7fSDaniel P. Berrangé
6126e811da7fSDaniel P. Berrangépreserve_env() {
6127e811da7fSDaniel P. Berrangé    envname=$1
6128e811da7fSDaniel P. Berrangé
6129e811da7fSDaniel P. Berrangé    eval envval=\$$envname
6130e811da7fSDaniel P. Berrangé
6131e811da7fSDaniel P. Berrangé    if test -n "$envval"
6132e811da7fSDaniel P. Berrangé    then
6133e811da7fSDaniel P. Berrangé	echo "$envname='$envval'" >> config.status
6134e811da7fSDaniel P. Berrangé	echo "export $envname" >> config.status
6135e811da7fSDaniel P. Berrangé    else
6136e811da7fSDaniel P. Berrangé	echo "unset $envname" >> config.status
6137e811da7fSDaniel P. Berrangé    fi
6138e811da7fSDaniel P. Berrangé}
6139e811da7fSDaniel P. Berrangé
6140e811da7fSDaniel P. Berrangé# Preserve various env variables that influence what
6141e811da7fSDaniel P. Berrangé# features/build target configure will detect
6142e811da7fSDaniel P. Berrangépreserve_env AR
6143e811da7fSDaniel P. Berrangépreserve_env AS
6144e811da7fSDaniel P. Berrangépreserve_env CC
6145e811da7fSDaniel P. Berrangépreserve_env CPP
6146e811da7fSDaniel P. Berrangépreserve_env CXX
6147e811da7fSDaniel P. Berrangépreserve_env INSTALL
6148e811da7fSDaniel P. Berrangépreserve_env LD
6149e811da7fSDaniel P. Berrangépreserve_env LD_LIBRARY_PATH
6150e811da7fSDaniel P. Berrangépreserve_env LIBTOOL
6151e811da7fSDaniel P. Berrangépreserve_env MAKE
6152e811da7fSDaniel P. Berrangépreserve_env NM
6153e811da7fSDaniel P. Berrangépreserve_env OBJCOPY
6154e811da7fSDaniel P. Berrangépreserve_env PATH
6155e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG
6156e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_LIBDIR
6157e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_PATH
6158e811da7fSDaniel P. Berrangépreserve_env PYTHON
6159e811da7fSDaniel P. Berrangépreserve_env SDL2_CONFIG
6160e811da7fSDaniel P. Berrangépreserve_env SMBD
6161e811da7fSDaniel P. Berrangépreserve_env STRIP
6162e811da7fSDaniel P. Berrangépreserve_env WINDRES
6163e811da7fSDaniel P. Berrangé
6164dc655404SMichael S. Tsirkinprintf "exec" >>config.status
6165a5665051SPaolo Bonzinifor i in "$0" "$@"; do
6166835af899SPaolo Bonzini  test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status
6167a5665051SPaolo Bonzinidone
6168cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status
6169dc655404SMichael S. Tsirkinchmod +x config.status
6170dc655404SMichael S. Tsirkin
61718cd05ab6SPeter Maydellrm -r "$TMPDIR1"
6172