xref: /openbmc/qemu/configure (revision c09c1ce7)
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"
804cb37d11SPhilippe Mathieu-DaudéTMPM="${TMPDIR1}/${TMPB}.m"
818cd05ab6SPeter MaydellTMPE="${TMPDIR1}/${TMPB}.exe"
827d13299dSbellard
83da1d85e3SGerd Hoffmannrm -f config.log
849ac81bbbSmalc
85b48e3611SPeter Maydell# Print a helpful header at the top of config.log
86b48e3611SPeter Maydellecho "# QEMU configure log $(date)" >> config.log
87979ae168SPeter Maydellprintf "# Configured with:" >> config.log
88979ae168SPeter Maydellprintf " '%s'" "$0" "$@" >> config.log
89979ae168SPeter Maydellecho >> config.log
90b48e3611SPeter Maydellecho "#" >> config.log
91b48e3611SPeter Maydell
92835af899SPaolo Bonziniquote_sh() {
93835af899SPaolo Bonzini    printf "%s" "$1" | sed "s,','\\\\'',g; s,.*,'&',"
94835af899SPaolo Bonzini}
95835af899SPaolo Bonzini
96d880a3baSPaolo Bonziniprint_error() {
97d880a3baSPaolo Bonzini    (echo
9876ad07a4SPeter Maydell    echo "ERROR: $1"
9976ad07a4SPeter Maydell    while test -n "$2"; do
10076ad07a4SPeter Maydell        echo "       $2"
10176ad07a4SPeter Maydell        shift
10276ad07a4SPeter Maydell    done
103d880a3baSPaolo Bonzini    echo) >&2
104d880a3baSPaolo Bonzini}
105d880a3baSPaolo Bonzini
106d880a3baSPaolo Bonzinierror_exit() {
107d880a3baSPaolo Bonzini    print_error "$@"
10876ad07a4SPeter Maydell    exit 1
10976ad07a4SPeter Maydell}
11076ad07a4SPeter Maydell
1119c83ffd8SPeter Maydelldo_compiler() {
1129c83ffd8SPeter Maydell    # Run the compiler, capturing its output to the log. First argument
1139c83ffd8SPeter Maydell    # is compiler binary to execute.
114630d86b7SDavid CARLIER    compiler="$1"
1159c83ffd8SPeter Maydell    shift
1168bbe05d7SIan Jackson    if test -n "$BASH_VERSION"; then eval '
1178bbe05d7SIan Jackson        echo >>config.log "
1188bbe05d7SIan Jacksonfuncs: ${FUNCNAME[*]}
1198bbe05d7SIan Jacksonlines: ${BASH_LINENO[*]}"
1208bbe05d7SIan Jackson    '; fi
1219c83ffd8SPeter Maydell    echo $compiler "$@" >> config.log
1229c83ffd8SPeter Maydell    $compiler "$@" >> config.log 2>&1 || return $?
1238dc38a78SPeter Maydell    # Test passed. If this is an --enable-werror build, rerun
1248dc38a78SPeter Maydell    # the test with -Werror and bail out if it fails. This
1258dc38a78SPeter Maydell    # makes warning-generating-errors in configure test code
1268dc38a78SPeter Maydell    # obvious to developers.
1278dc38a78SPeter Maydell    if test "$werror" != "yes"; then
1288dc38a78SPeter Maydell        return 0
1298dc38a78SPeter Maydell    fi
1308dc38a78SPeter Maydell    # Don't bother rerunning the compile if we were already using -Werror
1318dc38a78SPeter Maydell    case "$*" in
1328dc38a78SPeter Maydell        *-Werror*)
1338dc38a78SPeter Maydell           return 0
1348dc38a78SPeter Maydell        ;;
1358dc38a78SPeter Maydell    esac
1369c83ffd8SPeter Maydell    echo $compiler -Werror "$@" >> config.log
1379c83ffd8SPeter Maydell    $compiler -Werror "$@" >> config.log 2>&1 && return $?
13876ad07a4SPeter Maydell    error_exit "configure test passed without -Werror but failed with -Werror." \
13976ad07a4SPeter Maydell        "This is probably a bug in the configure script. The failing command" \
14076ad07a4SPeter Maydell        "will be at the bottom of config.log." \
14176ad07a4SPeter Maydell        "You can run configure with --disable-werror to bypass this check."
1428dc38a78SPeter Maydell}
1438dc38a78SPeter Maydell
1449c83ffd8SPeter Maydelldo_cc() {
1454dba2789SPaolo Bonzini    do_compiler "$cc" $CPU_CFLAGS "$@"
1469c83ffd8SPeter Maydell}
1479c83ffd8SPeter Maydell
1489c83ffd8SPeter Maydelldo_cxx() {
1494dba2789SPaolo Bonzini    do_compiler "$cxx" $CPU_CFLAGS "$@"
1509c83ffd8SPeter Maydell}
1519c83ffd8SPeter Maydell
1524cb37d11SPhilippe Mathieu-Daudédo_objc() {
1534cb37d11SPhilippe Mathieu-Daudé    do_compiler "$objcc" $CPU_CFLAGS "$@"
1544cb37d11SPhilippe Mathieu-Daudé}
1554cb37d11SPhilippe Mathieu-Daudé
15600849b92SRichard Henderson# Append $2 to the variable named $1, with space separation
15700849b92SRichard Hendersonadd_to() {
15800849b92SRichard Henderson    eval $1=\${$1:+\"\$$1 \"}\$2
15900849b92SRichard Henderson}
16000849b92SRichard Henderson
1619c83ffd8SPeter Maydellupdate_cxxflags() {
1629c83ffd8SPeter Maydell    # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
1639c83ffd8SPeter Maydell    # options which some versions of GCC's C++ compiler complain about
1649c83ffd8SPeter Maydell    # because they only make sense for C programs.
165de38c0ccSPaolo Bonzini    QEMU_CXXFLAGS="-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS"
1668a9d3d56SRichard Henderson    CONFIGURE_CXXFLAGS=$(echo "$CONFIGURE_CFLAGS" | sed s/-std=gnu11/-std=gnu++11/)
1679c83ffd8SPeter Maydell    for arg in $QEMU_CFLAGS; do
1689c83ffd8SPeter Maydell        case $arg in
1699c83ffd8SPeter Maydell            -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
1709c83ffd8SPeter Maydell            -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
1719c83ffd8SPeter Maydell                ;;
1729c83ffd8SPeter Maydell            *)
1739c83ffd8SPeter Maydell                QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
1749c83ffd8SPeter Maydell                ;;
1759c83ffd8SPeter Maydell        esac
1769c83ffd8SPeter Maydell    done
1779c83ffd8SPeter Maydell}
1789c83ffd8SPeter Maydell
17952166aa0SJuan Quintelacompile_object() {
180fd0e6053SJohn Snow  local_cflags="$1"
181a2866660SPaolo Bonzini  do_cc $CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
18252166aa0SJuan Quintela}
18352166aa0SJuan Quintela
18452166aa0SJuan Quintelacompile_prog() {
18552166aa0SJuan Quintela  local_cflags="$1"
18652166aa0SJuan Quintela  local_ldflags="$2"
187a2866660SPaolo Bonzini  do_cc $CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC \
188a2866660SPaolo Bonzini      $LDFLAGS $EXTRA_LDFLAGS $CONFIGURE_LDFLAGS $QEMU_LDFLAGS $local_ldflags
18952166aa0SJuan Quintela}
19052166aa0SJuan Quintela
19111568d6dSPaolo Bonzini# symbolically link $1 to $2.  Portable version of "ln -sf".
19211568d6dSPaolo Bonzinisymlink() {
19372b8b5a1SStefan Weil  rm -rf "$2"
194ec5b06d7SAnthony Liguori  mkdir -p "$(dirname "$2")"
19572b8b5a1SStefan Weil  ln -s "$1" "$2"
19611568d6dSPaolo Bonzini}
19711568d6dSPaolo Bonzini
1980dba6195SLoïc Minier# check whether a command is available to this shell (may be either an
1990dba6195SLoïc Minier# executable or a builtin)
2000dba6195SLoïc Minierhas() {
2010dba6195SLoïc Minier    type "$1" >/dev/null 2>&1
2020dba6195SLoïc Minier}
2030dba6195SLoïc Minier
2040a01d76fSMarc-André Lureauversion_ge () {
2052df52b9bSAlex Bennée    local_ver1=$(expr "$1" : '\([0-9.]*\)' | tr . ' ')
2062df52b9bSAlex Bennée    local_ver2=$(echo "$2" | tr . ' ')
2070a01d76fSMarc-André Lureau    while true; do
2080a01d76fSMarc-André Lureau        set x $local_ver1
2090a01d76fSMarc-André Lureau        local_first=${2-0}
210c44a33e2SStefano Garzarella        # 'shift 2' if $2 is set, or 'shift' if $2 is not set
211c44a33e2SStefano Garzarella        shift ${2:+2}
2120a01d76fSMarc-André Lureau        local_ver1=$*
2130a01d76fSMarc-André Lureau        set x $local_ver2
2140a01d76fSMarc-André Lureau        # the second argument finished, the first must be greater or equal
2150a01d76fSMarc-André Lureau        test $# = 1 && return 0
2160a01d76fSMarc-André Lureau        test $local_first -lt $2 && return 1
2170a01d76fSMarc-André Lureau        test $local_first -gt $2 && return 0
218c44a33e2SStefano Garzarella        shift ${2:+2}
2190a01d76fSMarc-André Lureau        local_ver2=$*
2200a01d76fSMarc-André Lureau    done
2210a01d76fSMarc-André Lureau}
2220a01d76fSMarc-André Lureau
2233b6b7550SPaolo Bonziniglob() {
2243b6b7550SPaolo Bonzini    eval test -z '"${1#'"$2"'}"'
2253b6b7550SPaolo Bonzini}
2263b6b7550SPaolo Bonzini
2274ace32e2SAntonio Ospiteif printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]";
2284ace32e2SAntonio Ospitethen
2294ace32e2SAntonio Ospite  error_exit "main directory cannot contain spaces nor colons"
2304ace32e2SAntonio Ospitefi
2314ace32e2SAntonio Ospite
23214211825SAntonio Ospite# default parameters
2332ff6b91eSJuan Quintelacpu=""
23443ce4dfeSbellardstatic="no"
2353812c0c4SJoelle van Dynecross_compile="no"
2367d13299dSbellardcross_prefix=""
237e49d021eSPeter Maydellhost_cc="cc"
238cdad781dSDaniele Buonolto="false"
23963678e17SSteven Noonanstack_protector=""
2401e4f6065SDaniele Buonosafe_stack=""
241afc3a8f9SAlex Bennéeuse_containers="yes"
242f2385398SAlex Bennéegdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
243ac0df51dSaliguori
24492712822SDaniel P. Berrangeif test -e "$source_path/.git"
24592712822SDaniel P. Berrangethen
2467d7dbf9dSDan Streetman    git_submodules_action="update"
24792712822SDaniel P. Berrangeelse
2487d7dbf9dSDan Streetman    git_submodules_action="ignore"
24992712822SDaniel P. Berrangefi
2502d652f24SPaolo Bonzini
2512d652f24SPaolo Bonzinigit_submodules="ui/keycodemapdb"
252cc84d63aSDaniel P. Berrangegit="git"
253ac0df51dSaliguori
254afb63ebdSStefan Weil# Don't accept a target_list environment variable.
255afb63ebdSStefan Weilunset target_list
256447e133fSAlex Bennéeunset target_list_exclude
257377529c0SPaolo Bonzini
258377529c0SPaolo Bonzini# Default value for a variable defining feature "foo".
259377529c0SPaolo Bonzini#  * foo="no"  feature will only be used if --enable-foo arg is given
260377529c0SPaolo Bonzini#  * foo=""    feature will be searched for, and if found, will be used
261377529c0SPaolo Bonzini#              unless --disable-foo is given
262377529c0SPaolo Bonzini#  * foo="yes" this value will only be set by --enable-foo flag.
263377529c0SPaolo Bonzini#              feature will searched for,
264377529c0SPaolo Bonzini#              if not found, configure exits with error
265377529c0SPaolo Bonzini#
266377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args.
267377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it
268377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found.
269377529c0SPaolo Bonzini
270c87ea116SAlex Bennéedefault_feature=""
271c87ea116SAlex Bennée# parse CC options second
272c87ea116SAlex Bennéefor opt do
273c87ea116SAlex Bennée  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
274c87ea116SAlex Bennée  case "$opt" in
275c87ea116SAlex Bennée      --without-default-features)
276c87ea116SAlex Bennée          default_feature="no"
277c87ea116SAlex Bennée  ;;
278c87ea116SAlex Bennée  esac
279c87ea116SAlex Bennéedone
280c87ea116SAlex Bennée
281a2866660SPaolo BonziniEXTRA_CFLAGS=""
282a2866660SPaolo BonziniEXTRA_CXXFLAGS=""
283e910c7d9SPhilippe Mathieu-DaudéEXTRA_OBJCFLAGS=""
284a2866660SPaolo BonziniEXTRA_LDFLAGS=""
285a2866660SPaolo Bonzini
2860848f8acSThomas Huthvhost_kernel="$default_feature"
287c87ea116SAlex Bennéevhost_net="$default_feature"
288c87ea116SAlex Bennéevhost_crypto="$default_feature"
289c87ea116SAlex Bennéevhost_scsi="$default_feature"
290c87ea116SAlex Bennéevhost_vsock="$default_feature"
291d88618f7SStefan Hajnoczivhost_user="no"
292c87ea116SAlex Bennéevhost_user_fs="$default_feature"
2930848f8acSThomas Huthvhost_vdpa="$default_feature"
29428609749SPaolo Bonzinidebug_info="yes"
295377529c0SPaolo Bonzinidebug_tcg="no"
296377529c0SPaolo Bonzinidebug="no"
297247724cbSMarc-André Lureausanitizers="no"
2980aebab04SLingfeng Yangtsan="no"
2991f3f2bfeSMichael Tokarevfortify_source="yes"
3001d728c39SBlue Swirlgcov="no"
301c7328271SMiroslav RezaninaEXESUF=""
30217969268SFam Zhengmodules="no"
303377529c0SPaolo Bonziniprefix="/usr/local"
30410ff82d1SMarc-André Lureauqemu_suffix="qemu"
305377529c0SPaolo Bonzinisoftmmu="yes"
306b915a2f1SPaolo Bonzinilinux_user=""
307b915a2f1SPaolo Bonzinibsd_user=""
30840d6444eSAvi Kivitypie=""
309519175a2SAlex Barcelocoroutine=""
310ba4dd2aaSAlex Bennéeplugins="$default_feature"
311a5665051SPaolo Bonzinimeson=""
3123b4da132SPaolo Bonzinimeson_args=""
31348328880SPaolo Bonzinininja=""
314*c09c1ce7SPaolo Bonzinibindir="bin"
315a5665051SPaolo Bonziniskip_meson=no
316377529c0SPaolo Bonzini
3173b4da132SPaolo Bonzini# The following Meson options are handled manually (still they
3183b4da132SPaolo Bonzini# are included in the automatically generated help message)
3193b4da132SPaolo Bonzini
3203b4da132SPaolo Bonzini# 1. Track which submodules are needed
3210577e84dSThomas Huthif test "$default_feature" = no ; then
3220577e84dSThomas Huth  capstone="disabled"
3230577e84dSThomas Huth  slirp="disabled"
3240577e84dSThomas Huthelse
3253b4da132SPaolo Bonzini  capstone="auto"
3263b4da132SPaolo Bonzini  slirp="auto"
3270577e84dSThomas Huthfi
3280577e84dSThomas Huthfdt="auto"
3293b4da132SPaolo Bonzini
3303b4da132SPaolo Bonzini# 2. Support --with/--without option
3313b4da132SPaolo Bonzinidefault_devices="true"
3323b4da132SPaolo Bonzini
3333b4da132SPaolo Bonzini# 3. Automatically enable/disable other options
3343b4da132SPaolo Bonzinitcg="enabled"
3353b4da132SPaolo Bonzinicfi="false"
3363b4da132SPaolo Bonzini
337c87ea116SAlex Bennée# parse CC options second
338ac0df51dSaliguorifor opt do
33989138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
340ac0df51dSaliguori  case "$opt" in
341ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
3423812c0c4SJoelle van Dyne                    cross_compile="yes"
343ac0df51dSaliguori  ;;
3443d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
345ac0df51dSaliguori  ;;
34683f73fceSTomoki Sekiyama  --cxx=*) CXX="$optarg"
34783f73fceSTomoki Sekiyama  ;;
3482ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
3492ff6b91eSJuan Quintela  ;;
350a2866660SPaolo Bonzini  --extra-cflags=*)
351a2866660SPaolo Bonzini    EXTRA_CFLAGS="$EXTRA_CFLAGS $optarg"
352a2866660SPaolo Bonzini    EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg"
353e910c7d9SPhilippe Mathieu-Daudé    EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg"
354e2a2ed06SJuan Quintela    ;;
355a2866660SPaolo Bonzini  --extra-cxxflags=*) EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg"
35611cde1c8SBruno Dominguez  ;;
357e910c7d9SPhilippe Mathieu-Daudé  --extra-objcflags=*) EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg"
358e910c7d9SPhilippe Mathieu-Daudé  ;;
359a2866660SPaolo Bonzini  --extra-ldflags=*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS $optarg"
360e2a2ed06SJuan Quintela  ;;
361d75402b5SAlex Bennée  --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
362d75402b5SAlex Bennée  ;;
363479ca4ccSMatheus Ferst  --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-cflags-}; cc_arch=${cc_arch%%=*}
364d422b2bcSAlex Bennée                      eval "cross_cc_cflags_${cc_arch}=\$optarg"
3652038f8c8SPaolo Bonzini                      cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}"
366d422b2bcSAlex Bennée  ;;
367d75402b5SAlex Bennée  --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
368d75402b5SAlex Bennée                eval "cross_cc_${cc_arch}=\$optarg"
3692038f8c8SPaolo Bonzini                cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}"
370d75402b5SAlex Bennée  ;;
371ac0df51dSaliguori  esac
372ac0df51dSaliguoridone
373ac0df51dSaliguori# OS specific
374ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
37593148aa5SStefan Weil# we can eliminate its usage altogether.
376ac0df51dSaliguori
377e49d021eSPeter Maydell# Preferred compiler:
378e49d021eSPeter Maydell#  ${CC} (if set)
379e49d021eSPeter Maydell#  ${cross_prefix}gcc (if cross-prefix specified)
380e49d021eSPeter Maydell#  system compiler
381e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then
382e49d021eSPeter Maydell  cc="$host_cc"
383e49d021eSPeter Maydellelse
384b3198cc2SStuart Yoder  cc="${CC-${cross_prefix}gcc}"
385e49d021eSPeter Maydellfi
386e49d021eSPeter Maydell
38783f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then
38883f73fceSTomoki Sekiyama  cxx="c++"
38983f73fceSTomoki Sekiyamaelse
39083f73fceSTomoki Sekiyama  cxx="${CXX-${cross_prefix}g++}"
39183f73fceSTomoki Sekiyamafi
39283f73fceSTomoki Sekiyama
393b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
394cdbd727cSRichard Hendersonas="${AS-${cross_prefix}as}"
3955f6f0e27SRichard Hendersonccas="${CCAS-$cc}"
3963dd46c78SBlue Swirlcpp="${CPP-$cc -E}"
397b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
398b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
3999f81aeb5SAlistair Francisranlib="${RANLIB-${cross_prefix}ranlib}"
4004852ee95SStefan Weilnm="${NM-${cross_prefix}nm}"
40135acbb30SPaolo Bonzinismbd="$SMBD"
402b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
403158bb224SKonstantin Kostiukwidl="${WIDL-${cross_prefix}widl}"
404b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
40517884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
40617884d7bSSergei Trofimovichquery_pkg_config() {
40717884d7bSSergei Trofimovich    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
40817884d7bSSergei Trofimovich}
40917884d7bSSergei Trofimovichpkg_config=query_pkg_config
41047c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
411ac0df51dSaliguori
412be17dc90SMichael S. Tsirkin# default flags for all hosts
4132d31515bSPeter Maydell# We use -fwrapv to tell the compiler that we require a C dialect where
4142d31515bSPeter Maydell# left shift of signed integers is well defined and has the expected
4152d31515bSPeter Maydell# 2s-complement style results. (Both clang and gcc agree that it
4162d31515bSPeter Maydell# provides these semantics.)
417de38c0ccSPaolo BonziniQEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv"
418086d5f75SPaolo BonziniQEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
419c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
420be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
4215770e8afSPaolo Bonzini
422de38c0ccSPaolo BonziniQEMU_LDFLAGS=
423de38c0ccSPaolo Bonzini
4245770e8afSPaolo Bonzini# Flags that are needed during configure but later taken care of by Meson
4258a9d3d56SRichard HendersonCONFIGURE_CFLAGS="-std=gnu11 -Wall"
4265770e8afSPaolo BonziniCONFIGURE_LDFLAGS=
427086d5f75SPaolo Bonzini
428be17dc90SMichael S. Tsirkin
429ac0df51dSaliguoricheck_define() {
430ac0df51dSaliguoricat > $TMPC <<EOF
431ac0df51dSaliguori#if !defined($1)
432fd786e1aSPeter Maydell#error $1 not defined
433ac0df51dSaliguori#endif
434ac0df51dSaliguoriint main(void) { return 0; }
435ac0df51dSaliguoriEOF
43652166aa0SJuan Quintela  compile_object
437ac0df51dSaliguori}
438ac0df51dSaliguori
439307119e7SGerd Hoffmanncheck_include() {
440307119e7SGerd Hoffmanncat > $TMPC <<EOF
441307119e7SGerd Hoffmann#include <$1>
442307119e7SGerd Hoffmannint main(void) { return 0; }
443307119e7SGerd HoffmannEOF
444307119e7SGerd Hoffmann  compile_object
445307119e7SGerd Hoffmann}
446307119e7SGerd Hoffmann
44793b25869SJohn Snowwrite_c_skeleton() {
44893b25869SJohn Snow    cat > $TMPC <<EOF
44993b25869SJohn Snowint main(void) { return 0; }
45093b25869SJohn SnowEOF
45193b25869SJohn Snow}
45293b25869SJohn Snow
453bbea4050SPeter Maydellif check_define __linux__ ; then
454ba7c60c2SPaolo Bonzini  targetos=linux
455bbea4050SPeter Maydellelif check_define _WIN32 ; then
456ba7c60c2SPaolo Bonzini  targetos=windows
457bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
458ba7c60c2SPaolo Bonzini  targetos=openbsd
459bbea4050SPeter Maydellelif check_define __sun__ ; then
460ba7c60c2SPaolo Bonzini  targetos=sunos
461bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
462ba7c60c2SPaolo Bonzini  targetos=haiku
463951fedfcSPeter Maydellelif check_define __FreeBSD__ ; then
464ba7c60c2SPaolo Bonzini  targetos=freebsd
465951fedfcSPeter Maydellelif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
466ba7c60c2SPaolo Bonzini  targetos=gnu/kfreebsd
467951fedfcSPeter Maydellelif check_define __DragonFly__ ; then
468ba7c60c2SPaolo Bonzini  targetos=dragonfly
469951fedfcSPeter Maydellelif check_define __NetBSD__; then
470ba7c60c2SPaolo Bonzini  targetos=netbsd
471951fedfcSPeter Maydellelif check_define __APPLE__; then
472ba7c60c2SPaolo Bonzini  targetos=darwin
473bbea4050SPeter Maydellelse
474951fedfcSPeter Maydell  # This is a fatal error, but don't report it yet, because we
475951fedfcSPeter Maydell  # might be going to just print the --help text, or it might
476951fedfcSPeter Maydell  # be the result of a missing compiler.
477ba7c60c2SPaolo Bonzini  targetos=bogus
478bbea4050SPeter Maydellfi
479bbea4050SPeter Maydell
48065eff01bSPaolo Bonzini# OS specific
48165eff01bSPaolo Bonzini
4823b0d8643SPaolo Bonzinimingw32="no"
4833b0d8643SPaolo Bonzinibsd="no"
4843b0d8643SPaolo Bonzinilinux="no"
4853b0d8643SPaolo Bonzinisolaris="no"
48665eff01bSPaolo Bonzinicase $targetos in
48765eff01bSPaolo Bonziniwindows)
48865eff01bSPaolo Bonzini  mingw32="yes"
48965eff01bSPaolo Bonzini  plugins="no"
49065eff01bSPaolo Bonzini  pie="no"
49165eff01bSPaolo Bonzini;;
49265eff01bSPaolo Bonzinignu/kfreebsd)
49365eff01bSPaolo Bonzini  bsd="yes"
49465eff01bSPaolo Bonzini;;
49565eff01bSPaolo Bonzinifreebsd)
49665eff01bSPaolo Bonzini  bsd="yes"
49765eff01bSPaolo Bonzini  make="${MAKE-gmake}"
49865eff01bSPaolo Bonzini  # needed for kinfo_getvmmap(3) in libutil.h
49965eff01bSPaolo Bonzini;;
50065eff01bSPaolo Bonzinidragonfly)
50165eff01bSPaolo Bonzini  bsd="yes"
50265eff01bSPaolo Bonzini  make="${MAKE-gmake}"
50365eff01bSPaolo Bonzini;;
50465eff01bSPaolo Bonzininetbsd)
50565eff01bSPaolo Bonzini  bsd="yes"
50665eff01bSPaolo Bonzini  make="${MAKE-gmake}"
50765eff01bSPaolo Bonzini;;
50865eff01bSPaolo Bonziniopenbsd)
50965eff01bSPaolo Bonzini  bsd="yes"
51065eff01bSPaolo Bonzini  make="${MAKE-gmake}"
51165eff01bSPaolo Bonzini;;
51265eff01bSPaolo Bonzinidarwin)
51365eff01bSPaolo Bonzini  bsd="yes"
51465eff01bSPaolo Bonzini  darwin="yes"
51565eff01bSPaolo Bonzini  # Disable attempts to use ObjectiveC features in os/object.h since they
51665eff01bSPaolo Bonzini  # won't work when we're compiling with gcc as a C compiler.
51765eff01bSPaolo Bonzini  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
51865eff01bSPaolo Bonzini;;
51965eff01bSPaolo Bonzinisunos)
52065eff01bSPaolo Bonzini  solaris="yes"
52165eff01bSPaolo Bonzini  make="${MAKE-gmake}"
52265eff01bSPaolo Bonzini# needed for CMSG_ macros in sys/socket.h
52365eff01bSPaolo Bonzini  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
52465eff01bSPaolo Bonzini# needed for TIOCWIN* defines in termios.h
52565eff01bSPaolo Bonzini  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
52665eff01bSPaolo Bonzini  # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
52765eff01bSPaolo Bonzini  # Note that this check is broken for cross-compilation: if you're
528bbea4050SPeter Maydell  # cross-compiling to one of these OSes then you'll need to specify
529bbea4050SPeter Maydell  # the correct CPU with the --cpu option.
530bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
531bbea4050SPeter Maydell    cpu="x86_64"
532bbea4050SPeter Maydell  fi
53365eff01bSPaolo Bonzini;;
53465eff01bSPaolo Bonzinihaiku)
53565eff01bSPaolo Bonzini  pie="no"
53665eff01bSPaolo Bonzini  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE -fPIC $QEMU_CFLAGS"
53765eff01bSPaolo Bonzini;;
53865eff01bSPaolo Bonzinilinux)
53965eff01bSPaolo Bonzini  linux="yes"
54065eff01bSPaolo Bonzini  vhost_user=${default_feature:-yes}
54165eff01bSPaolo Bonzini;;
542bbea4050SPeter Maydellesac
543bbea4050SPeter Maydell
5442ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
5452ff6b91eSJuan Quintela  # command line argument
5462ff6b91eSJuan Quintela  :
5472ff6b91eSJuan Quintelaelif check_define __i386__ ; then
548ac0df51dSaliguori  cpu="i386"
549ac0df51dSaliguorielif check_define __x86_64__ ; then
550c72b26ecSRichard Henderson  if check_define __ILP32__ ; then
551c72b26ecSRichard Henderson    cpu="x32"
552c72b26ecSRichard Henderson  else
553ac0df51dSaliguori    cpu="x86_64"
554c72b26ecSRichard Henderson  fi
5553aa9bd6cSblueswir1elif check_define __sparc__ ; then
5563aa9bd6cSblueswir1  if check_define __arch64__ ; then
5573aa9bd6cSblueswir1    cpu="sparc64"
5583aa9bd6cSblueswir1  else
5593aa9bd6cSblueswir1    cpu="sparc"
5603aa9bd6cSblueswir1  fi
561fdf7ed96Smalcelif check_define _ARCH_PPC ; then
562fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
563f8378accSRichard Henderson    if check_define _LITTLE_ENDIAN ; then
564f8378accSRichard Henderson      cpu="ppc64le"
565f8378accSRichard Henderson    else
566fdf7ed96Smalc      cpu="ppc64"
567f8378accSRichard Henderson    fi
568ac0df51dSaliguori  else
569fdf7ed96Smalc    cpu="ppc"
570fdf7ed96Smalc  fi
571afa05235SAurelien Jarnoelif check_define __mips__ ; then
572afa05235SAurelien Jarno  cpu="mips"
573d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
574d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
575d66ed0eaSAurelien Jarno    cpu="s390x"
576d66ed0eaSAurelien Jarno  else
577d66ed0eaSAurelien Jarno    cpu="s390"
578d66ed0eaSAurelien Jarno  fi
579c4f80543SAlistair Franciselif check_define __riscv ; then
580ba0e7333SRichard Henderson  cpu="riscv"
58121d89f84SPeter Maydellelif check_define __arm__ ; then
58221d89f84SPeter Maydell  cpu="arm"
5831f080313SClaudio Fontanaelif check_define __aarch64__ ; then
5841f080313SClaudio Fontana  cpu="aarch64"
585dfcf900bSWANG Xueruielif check_define __loongarch64 ; then
586dfcf900bSWANG Xuerui  cpu="loongarch64"
587fdf7ed96Smalcelse
58889138857SStefan Weil  cpu=$(uname -m)
589ac0df51dSaliguorifi
590ac0df51dSaliguori
591823eb013SPaolo Bonzini# Normalise host CPU name, set multilib cflags
592359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
5937d13299dSbellardcase "$cpu" in
594e4da0e39SPaolo Bonzini  armv*b|armv*l|arm)
595e4da0e39SPaolo Bonzini    cpu="arm" ;;
596e4da0e39SPaolo Bonzini
5977d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
59897a847bcSbellard    cpu="i386"
599e4da0e39SPaolo Bonzini    CPU_CFLAGS="-m32" ;;
600e4da0e39SPaolo Bonzini  x32)
6014da270beSPaolo Bonzini    cpu="x86_64"
602e4da0e39SPaolo Bonzini    CPU_CFLAGS="-mx32" ;;
603aaa5fa14Saurel32  x86_64|amd64)
604aaa5fa14Saurel32    cpu="x86_64"
605e4da0e39SPaolo Bonzini    # ??? Only extremely old AMD cpus do not have cmpxchg16b.
606e4da0e39SPaolo Bonzini    # If we truly care, we should simply detect this case at
607e4da0e39SPaolo Bonzini    # runtime and generate the fallback to serial emulation.
608e4da0e39SPaolo Bonzini    CPU_CFLAGS="-m64 -mcx16" ;;
609e4da0e39SPaolo Bonzini
610afa05235SAurelien Jarno  mips*)
611e4da0e39SPaolo Bonzini    cpu="mips" ;;
612e4da0e39SPaolo Bonzini
613e4da0e39SPaolo Bonzini  ppc)
614e4da0e39SPaolo Bonzini    CPU_CFLAGS="-m32" ;;
615e4da0e39SPaolo Bonzini  ppc64)
616ced5cfffSMiroslav Rezanina    CPU_CFLAGS="-m64 -mbig-endian" ;;
617e4da0e39SPaolo Bonzini  ppc64le)
618d8ff892dSPaolo Bonzini    cpu="ppc64"
619ced5cfffSMiroslav Rezanina    CPU_CFLAGS="-m64 -mlittle-endian" ;;
620e4da0e39SPaolo Bonzini
621e4da0e39SPaolo Bonzini  s390)
622823eb013SPaolo Bonzini    CPU_CFLAGS="-m31" ;;
623e4da0e39SPaolo Bonzini  s390x)
624e4da0e39SPaolo Bonzini    CPU_CFLAGS="-m64" ;;
625e4da0e39SPaolo Bonzini
6263142255cSblueswir1  sparc|sun4[cdmuv])
627ae228531Sbellard    cpu="sparc"
628e4da0e39SPaolo Bonzini    CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc" ;;
629e4da0e39SPaolo Bonzini  sparc64)
630e4da0e39SPaolo Bonzini    CPU_CFLAGS="-m64 -mcpu=ultrasparc" ;;
6317d13299dSbellardesac
632e2d52ad3SJuan Quintela
6330db4a067SPaolo Bonzini: ${make=${MAKE-make}}
634b6daf4d3SPaolo Bonzini
635faf44142SDaniel P. Berrangé# We prefer python 3.x. A bare 'python' is traditionally
636faf44142SDaniel P. Berrangé# python 2.x, but some distros have it as python 3.x, so
637ddf90699SEduardo Habkost# we check that too
638faf44142SDaniel P. Berrangépython=
6390a01d76fSMarc-André Lureauexplicit_python=no
640ddf90699SEduardo Habkostfor binary in "${PYTHON-python3}" python
641faf44142SDaniel P. Berrangédo
642faf44142SDaniel P. Berrangé    if has "$binary"
643faf44142SDaniel P. Berrangé    then
64495c5f2deSPaolo Bonzini        python=$(command -v "$binary")
645faf44142SDaniel P. Berrangé        break
646faf44142SDaniel P. Berrangé    fi
647faf44142SDaniel P. Berrangédone
648903458c8SMarkus Armbruster
649903458c8SMarkus Armbruster
65039d87c8cSAlex Bennée# Check for ancillary tools used in testing
65139d87c8cSAlex Bennéegenisoimage=
6523df437c7SAlex Bennéefor binary in genisoimage mkisofs
65339d87c8cSAlex Bennéedo
65439d87c8cSAlex Bennée    if has $binary
65539d87c8cSAlex Bennée    then
65639d87c8cSAlex Bennée        genisoimage=$(command -v "$binary")
65739d87c8cSAlex Bennée        break
65839d87c8cSAlex Bennée    fi
65939d87c8cSAlex Bennéedone
66039d87c8cSAlex Bennée
6613c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
6623c4a4d0dSPeter Maydellif has clang; then
6633c4a4d0dSPeter Maydell  objcc=clang
6643c4a4d0dSPeter Maydellelse
6653c4a4d0dSPeter Maydell  objcc="$cc"
6663c4a4d0dSPeter Maydellfi
6673c4a4d0dSPeter Maydell
6683457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
6693457a3f8SJuan Quintela  EXESUF=".exe"
67078e9d4adSStefan Weil  # MinGW needs -mthreads for TLS and macro _MT.
6715770e8afSPaolo Bonzini  CONFIGURE_CFLAGS="-mthreads $CONFIGURE_CFLAGS"
67293b25869SJohn Snow  write_c_skeleton;
673d17f305aSPaolo Bonzini  prefix="/qemu"
674*c09c1ce7SPaolo Bonzini  bindir=""
67577433a5fSMarc-André Lureau  qemu_suffix=""
6763457a3f8SJuan Quintelafi
6773457a3f8SJuan Quintela
678487fefdbSAnthony Liguoriwerror=""
67985aa5189Sbellard
68061d63097SPaolo Bonzini. $source_path/scripts/meson-buildoptions.sh
68161d63097SPaolo Bonzini
68261d63097SPaolo Bonzinimeson_options=
68361d63097SPaolo Bonzinimeson_option_parse() {
68461d63097SPaolo Bonzini  meson_options="$meson_options $(_meson_option_parse "$@")"
68561d63097SPaolo Bonzini  if test $? -eq 1; then
68661d63097SPaolo Bonzini    echo "ERROR: unknown option $1"
68761d63097SPaolo Bonzini    echo "Try '$0 --help' for more information"
68861d63097SPaolo Bonzini    exit 1
68961d63097SPaolo Bonzini  fi
69061d63097SPaolo Bonzini}
69161d63097SPaolo Bonzini
6927d13299dSbellardfor opt do
69389138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
6947d13299dSbellard  case "$opt" in
6952efc3265Sbellard  --help|-h) show_help=yes
6962efc3265Sbellard  ;;
69799123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
69899123e13SMike Frysinger  ;;
699b1a550a0Spbrook  --prefix=*) prefix="$optarg"
7007d13299dSbellard  ;;
701ac0df51dSaliguori  --cross-prefix=*)
7027d13299dSbellard  ;;
703ac0df51dSaliguori  --cc=*)
7047d13299dSbellard  ;;
705b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
70683469015Sbellard  ;;
70783f73fceSTomoki Sekiyama  --cxx=*)
70883f73fceSTomoki Sekiyama  ;;
7093c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
7103c4a4d0dSPeter Maydell  ;;
711b1a550a0Spbrook  --make=*) make="$optarg"
7127d13299dSbellard  ;;
713b6daf4d3SPaolo Bonzini  --install=*)
7146a882643Spbrook  ;;
7150a01d76fSMarc-André Lureau  --python=*) python="$optarg" ; explicit_python=yes
716c886edfbSBlue Swirl  ;;
717a5665051SPaolo Bonzini  --skip-meson) skip_meson=yes
718a5665051SPaolo Bonzini  ;;
719a5665051SPaolo Bonzini  --meson=*) meson="$optarg"
720a5665051SPaolo Bonzini  ;;
72148328880SPaolo Bonzini  --ninja=*) ninja="$optarg"
72248328880SPaolo Bonzini  ;;
723e2d8830eSBrad  --smbd=*) smbd="$optarg"
724e2d8830eSBrad  ;;
725e2a2ed06SJuan Quintela  --extra-cflags=*)
7267d13299dSbellard  ;;
72711cde1c8SBruno Dominguez  --extra-cxxflags=*)
72811cde1c8SBruno Dominguez  ;;
729e910c7d9SPhilippe Mathieu-Daudé  --extra-objcflags=*)
730e910c7d9SPhilippe Mathieu-Daudé  ;;
731e2a2ed06SJuan Quintela  --extra-ldflags=*)
7327d13299dSbellard  ;;
733d75402b5SAlex Bennée  --cross-cc-*)
734d75402b5SAlex Bennée  ;;
73528609749SPaolo Bonzini  --enable-debug-info) debug_info="yes"
73628609749SPaolo Bonzini  ;;
73728609749SPaolo Bonzini  --disable-debug-info) debug_info="no"
73828609749SPaolo Bonzini  ;;
73917969268SFam Zheng  --enable-modules)
74017969268SFam Zheng      modules="yes"
74117969268SFam Zheng  ;;
7423aa88b31SStefan Hajnoczi  --disable-modules)
7433aa88b31SStefan Hajnoczi      modules="no"
7443aa88b31SStefan Hajnoczi  ;;
7452ff6b91eSJuan Quintela  --cpu=*)
7467d13299dSbellard  ;;
747b1a550a0Spbrook  --target-list=*) target_list="$optarg"
748447e133fSAlex Bennée                   if test "$target_list_exclude"; then
749447e133fSAlex Bennée                       error_exit "Can't mix --target-list with --target-list-exclude"
750447e133fSAlex Bennée                   fi
751447e133fSAlex Bennée  ;;
752447e133fSAlex Bennée  --target-list-exclude=*) target_list_exclude="$optarg"
753447e133fSAlex Bennée                   if test "$target_list"; then
754447e133fSAlex Bennée                       error_exit "Can't mix --target-list-exclude with --target-list"
755447e133fSAlex Bennée                   fi
756de83cd02Sbellard  ;;
7577bc3ca7fSPaolo Bonzini  --with-default-devices) default_devices="true"
758f3494749SPaolo Bonzini  ;;
7597bc3ca7fSPaolo Bonzini  --without-default-devices) default_devices="false"
760f3494749SPaolo Bonzini  ;;
761d1d5e9eeSAlex Bennée  --with-devices-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --with-devices-FOO option"
762d1d5e9eeSAlex Bennée  ;;
763d1d5e9eeSAlex Bennée  --with-devices-*) device_arch=${opt#--with-devices-};
764d1d5e9eeSAlex Bennée                    device_arch=${device_arch%%=*}
765d1d5e9eeSAlex Bennée                    cf=$source_path/configs/devices/$device_arch-softmmu/$optarg.mak
766d1d5e9eeSAlex Bennée                    if test -f "$cf"; then
767d1d5e9eeSAlex Bennée                        device_archs="$device_archs $device_arch"
768d1d5e9eeSAlex Bennée                        eval "devices_${device_arch}=\$optarg"
769d1d5e9eeSAlex Bennée                    else
770d1d5e9eeSAlex Bennée                        error_exit "File $cf does not exist"
771d1d5e9eeSAlex Bennée                    fi
772d1d5e9eeSAlex Bennée  ;;
773c87ea116SAlex Bennée  --without-default-features) # processed above
774c87ea116SAlex Bennée  ;;
7751d728c39SBlue Swirl  --enable-gcov) gcov="yes"
7761d728c39SBlue Swirl  ;;
77779427693SLoïc Minier  --static)
77879427693SLoïc Minier    static="yes"
77917884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
78043ce4dfeSbellard  ;;
7810b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
7820b24e75fSPaolo Bonzini  ;;
78377433a5fSMarc-André Lureau  --with-suffix=*) qemu_suffix="$optarg"
784023d3d67SEduardo Habkost  ;;
785181ce1d0SOlaf Hering  --host=*|--build=*|\
786181ce1d0SOlaf Hering  --disable-dependency-tracking|\
787785c23aeSLuiz Capitulino  --sbindir=*|--sharedstatedir=*|\
788fe0038beSPaolo Bonzini  --oldincludedir=*|--datarootdir=*|--infodir=*|\
789023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
790023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
791023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
792023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
793023ddd74SMax Filippov    # lots of directory switches by default.
794023ddd74SMax Filippov  ;;
795f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
796f8393946Saurel32  ;;
797f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
798f8393946Saurel32  ;;
799f3d08ee6SPaul Brook  --enable-debug)
800f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
801f3d08ee6SPaul Brook      debug_tcg="yes"
802c55cf6abSPaolo Bonzini      meson_option_parse --enable-debug-mutex ""
803f3d08ee6SPaul Brook      debug="yes"
804b553a042SJohn Snow      fortify_source="no"
805f3d08ee6SPaul Brook  ;;
806247724cbSMarc-André Lureau  --enable-sanitizers) sanitizers="yes"
807247724cbSMarc-André Lureau  ;;
808247724cbSMarc-André Lureau  --disable-sanitizers) sanitizers="no"
809247724cbSMarc-André Lureau  ;;
8100aebab04SLingfeng Yang  --enable-tsan) tsan="yes"
8110aebab04SLingfeng Yang  ;;
8120aebab04SLingfeng Yang  --disable-tsan) tsan="no"
8130aebab04SLingfeng Yang  ;;
8144d34a86bSPaolo Bonzini  --disable-slirp) slirp="disabled"
815c20709aaSbellard  ;;
816fd6fc214SPaolo Bonzini  --enable-slirp) slirp="enabled"
817fd6fc214SPaolo Bonzini  ;;
8184d34a86bSPaolo Bonzini  --enable-slirp=git) slirp="internal"
8197c57bdd8SMarc-André Lureau  ;;
82003a3c0b3SPaolo Bonzini  --enable-slirp=*) slirp="$optarg"
821675b9b53SMarc-André Lureau  ;;
8221badb709SPaolo Bonzini  --disable-tcg) tcg="disabled"
823d1a14257SAlex Bennée                 plugins="no"
824b3f6ea7eSPaolo Bonzini  ;;
8251badb709SPaolo Bonzini  --enable-tcg) tcg="enabled"
826b3f6ea7eSPaolo Bonzini  ;;
827cad25d69Spbrook  --disable-system) softmmu="no"
8280a8e90f4Spbrook  ;;
829cad25d69Spbrook  --enable-system) softmmu="yes"
8300a8e90f4Spbrook  ;;
8310953a80fSZachary Amsden  --disable-user)
8320953a80fSZachary Amsden      linux_user="no" ;
8330953a80fSZachary Amsden      bsd_user="no" ;
8340953a80fSZachary Amsden  ;;
8350953a80fSZachary Amsden  --enable-user) ;;
836831b7825Sths  --disable-linux-user) linux_user="no"
8370a8e90f4Spbrook  ;;
838831b7825Sths  --enable-linux-user) linux_user="yes"
839831b7825Sths  ;;
84084778508Sblueswir1  --disable-bsd-user) bsd_user="no"
84184778508Sblueswir1  ;;
84284778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
84384778508Sblueswir1  ;;
84440d6444eSAvi Kivity  --enable-pie) pie="yes"
84534005a00SKirill A. Shutemov  ;;
84640d6444eSAvi Kivity  --disable-pie) pie="no"
84734005a00SKirill A. Shutemov  ;;
84885aa5189Sbellard  --enable-werror) werror="yes"
84985aa5189Sbellard  ;;
85085aa5189Sbellard  --disable-werror) werror="no"
85185aa5189Sbellard  ;;
852cdad781dSDaniele Buono  --enable-lto) lto="true"
853cdad781dSDaniele Buono  ;;
854cdad781dSDaniele Buono  --disable-lto) lto="false"
855cdad781dSDaniele Buono  ;;
85663678e17SSteven Noonan  --enable-stack-protector) stack_protector="yes"
85763678e17SSteven Noonan  ;;
85863678e17SSteven Noonan  --disable-stack-protector) stack_protector="no"
85963678e17SSteven Noonan  ;;
8601e4f6065SDaniele Buono  --enable-safe-stack) safe_stack="yes"
8611e4f6065SDaniele Buono  ;;
8621e4f6065SDaniele Buono  --disable-safe-stack) safe_stack="no"
8631e4f6065SDaniele Buono  ;;
8649e62ba48SDaniele Buono  --enable-cfi)
8659e62ba48SDaniele Buono      cfi="true";
8669e62ba48SDaniele Buono      lto="true";
8679e62ba48SDaniele Buono  ;;
8689e62ba48SDaniele Buono  --disable-cfi) cfi="false"
8699e62ba48SDaniele Buono  ;;
870fbb4121dSPaolo Bonzini  --disable-fdt) fdt="disabled"
8712df87df7SJuan Quintela  ;;
872fbb4121dSPaolo Bonzini  --enable-fdt) fdt="enabled"
873fbb4121dSPaolo Bonzini  ;;
874fbb4121dSPaolo Bonzini  --enable-fdt=git) fdt="internal"
875fbb4121dSPaolo Bonzini  ;;
87603a3c0b3SPaolo Bonzini  --enable-fdt=*) fdt="$optarg"
8772df87df7SJuan Quintela  ;;
878519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
879519175a2SAlex Barcelo  ;;
880d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
881d5970055SMichael S. Tsirkin  ;;
882d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
883d5970055SMichael S. Tsirkin  ;;
884042cea27SGonglei  --disable-vhost-crypto) vhost_crypto="no"
885042cea27SGonglei  ;;
886299e6f19SPaolo Bonzini  --enable-vhost-crypto) vhost_crypto="yes"
887042cea27SGonglei  ;;
8885e9be92dSNicholas Bellinger  --disable-vhost-scsi) vhost_scsi="no"
8895e9be92dSNicholas Bellinger  ;;
8905e9be92dSNicholas Bellinger  --enable-vhost-scsi) vhost_scsi="yes"
8915e9be92dSNicholas Bellinger  ;;
892fc0b9b0eSStefan Hajnoczi  --disable-vhost-vsock) vhost_vsock="no"
893fc0b9b0eSStefan Hajnoczi  ;;
894fc0b9b0eSStefan Hajnoczi  --enable-vhost-vsock) vhost_vsock="yes"
895fc0b9b0eSStefan Hajnoczi  ;;
89698fc1adaSDr. David Alan Gilbert  --disable-vhost-user-fs) vhost_user_fs="no"
89798fc1adaSDr. David Alan Gilbert  ;;
89898fc1adaSDr. David Alan Gilbert  --enable-vhost-user-fs) vhost_user_fs="yes"
89998fc1adaSDr. David Alan Gilbert  ;;
9001ffb3bbbSPaolo Bonzini  --disable-zlib-test)
9011ece9905SAlon Levy  ;;
90252b53c04SFam Zheng  --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
90352b53c04SFam Zheng      echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
904583f6e7bSStefan Hajnoczi  ;;
905cb6414dfSFam Zheng  --enable-vhdx|--disable-vhdx)
906cb6414dfSFam Zheng      echo "$0: $opt is obsolete, VHDX driver is always built" >&2
907cb6414dfSFam Zheng  ;;
908315d3184SFam Zheng  --enable-uuid|--disable-uuid)
909315d3184SFam Zheng      echo "$0: $opt is obsolete, UUID support is always built" >&2
910315d3184SFam Zheng  ;;
911e6a74868SMarc-André Lureau  --disable-vhost-user) vhost_user="no"
912e6a74868SMarc-André Lureau  ;;
913299e6f19SPaolo Bonzini  --enable-vhost-user) vhost_user="yes"
914299e6f19SPaolo Bonzini  ;;
915108a6481SCindy Lu  --disable-vhost-vdpa) vhost_vdpa="no"
916108a6481SCindy Lu  ;;
917108a6481SCindy Lu  --enable-vhost-vdpa) vhost_vdpa="yes"
918108a6481SCindy Lu  ;;
919299e6f19SPaolo Bonzini  --disable-vhost-kernel) vhost_kernel="no"
920299e6f19SPaolo Bonzini  ;;
921299e6f19SPaolo Bonzini  --enable-vhost-kernel) vhost_kernel="yes"
922e6a74868SMarc-André Lureau  ;;
9238b18cdbfSRichard Henderson  --disable-capstone) capstone="disabled"
9248ca80760SRichard Henderson  ;;
9258b18cdbfSRichard Henderson  --enable-capstone) capstone="enabled"
9268ca80760SRichard Henderson  ;;
9278b18cdbfSRichard Henderson  --enable-capstone=git) capstone="internal"
928e219c499SRichard Henderson  ;;
92903a3c0b3SPaolo Bonzini  --enable-capstone=*) capstone="$optarg"
930e219c499SRichard Henderson  ;;
931cc84d63aSDaniel P. Berrange  --with-git=*) git="$optarg"
932cc84d63aSDaniel P. Berrange  ;;
9337d7dbf9dSDan Streetman  --with-git-submodules=*)
9347d7dbf9dSDan Streetman      git_submodules_action="$optarg"
935f62bbee5SDaniel P. Berrange  ;;
9369b8e4298SAlex Bennée  --enable-plugins) if test "$mingw32" = "yes"; then
9379b8e4298SAlex Bennée                        error_exit "TCG plugins not currently supported on Windows platforms"
9389b8e4298SAlex Bennée                    else
9399b8e4298SAlex Bennée                        plugins="yes"
9409b8e4298SAlex Bennée                    fi
94140e8c6f4SAlex Bennée  ;;
94240e8c6f4SAlex Bennée  --disable-plugins) plugins="no"
94340e8c6f4SAlex Bennée  ;;
944afc3a8f9SAlex Bennée  --enable-containers) use_containers="yes"
945afc3a8f9SAlex Bennée  ;;
946afc3a8f9SAlex Bennée  --disable-containers) use_containers="no"
947afc3a8f9SAlex Bennée  ;;
948f48e590aSAlex Bennée  --gdb=*) gdb_bin="$optarg"
949f48e590aSAlex Bennée  ;;
9503b4da132SPaolo Bonzini  # backwards compatibility options
9513b4da132SPaolo Bonzini  --enable-trace-backend=*) meson_option_parse "--enable-trace-backends=$optarg" "$optarg"
9523b4da132SPaolo Bonzini  ;;
9533b4da132SPaolo Bonzini  --disable-blobs) meson_option_parse --disable-install-blobs ""
9543b4da132SPaolo Bonzini  ;;
9553b4da132SPaolo Bonzini  --enable-tcmalloc) meson_option_parse --enable-malloc=tcmalloc tcmalloc
9563b4da132SPaolo Bonzini  ;;
9573b4da132SPaolo Bonzini  --enable-jemalloc) meson_option_parse --enable-malloc=jemalloc jemalloc
9583b4da132SPaolo Bonzini  ;;
9593b4da132SPaolo Bonzini  # everything else has the same name in configure and meson
9604fda6011SPaolo Bonzini  --*) meson_option_parse "$opt" "$optarg"
9617f1559c6Sbalrog  ;;
9627d13299dSbellard  esac
9637d13299dSbellarddone
9647d13299dSbellard
965d1a14257SAlex Bennée# test for any invalid configuration combinations
966d1a14257SAlex Bennéeif test "$plugins" = "yes" -a "$tcg" = "disabled"; then
967d1a14257SAlex Bennée    error_exit "Can't enable plugins on non-TCG builds"
968d1a14257SAlex Bennéefi
969d1a14257SAlex Bennée
9707d7dbf9dSDan Streetmancase $git_submodules_action in
9717d7dbf9dSDan Streetman    update|validate)
9727d7dbf9dSDan Streetman        if test ! -e "$source_path/.git"; then
9737d7dbf9dSDan Streetman            echo "ERROR: cannot $git_submodules_action git submodules without .git"
9747d7dbf9dSDan Streetman            exit 1
9757d7dbf9dSDan Streetman        fi
9767d7dbf9dSDan Streetman    ;;
9777d7dbf9dSDan Streetman    ignore)
978b80fd281SPaolo Bonzini        if ! test -f "$source_path/ui/keycodemapdb/README"
979b80fd281SPaolo Bonzini        then
980b80fd281SPaolo Bonzini            echo
981b80fd281SPaolo Bonzini            echo "ERROR: missing GIT submodules"
982b80fd281SPaolo Bonzini            echo
983b80fd281SPaolo Bonzini            if test -e "$source_path/.git"; then
984b80fd281SPaolo Bonzini                echo "--with-git-submodules=ignore specified but submodules were not"
985b80fd281SPaolo Bonzini                echo "checked out.  Please initialize and update submodules."
986b80fd281SPaolo Bonzini            else
987b80fd281SPaolo Bonzini                echo "This is not a GIT checkout but module content appears to"
988b80fd281SPaolo Bonzini                echo "be missing. Do not use 'git archive' or GitHub download links"
989b80fd281SPaolo Bonzini                echo "to acquire QEMU source archives. Non-GIT builds are only"
990b80fd281SPaolo Bonzini                echo "supported with source archives linked from:"
991b80fd281SPaolo Bonzini                echo
992b80fd281SPaolo Bonzini                echo "  https://www.qemu.org/download/#source"
993b80fd281SPaolo Bonzini                echo
994b80fd281SPaolo Bonzini                echo "Developers working with GIT can use scripts/archive-source.sh"
995b80fd281SPaolo Bonzini                echo "if they need to create valid source archives."
996b80fd281SPaolo Bonzini            fi
997b80fd281SPaolo Bonzini            echo
998b80fd281SPaolo Bonzini            exit 1
999b80fd281SPaolo Bonzini        fi
10007d7dbf9dSDan Streetman    ;;
10017d7dbf9dSDan Streetman    *)
10027d7dbf9dSDan Streetman        echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'"
10037d7dbf9dSDan Streetman        exit 1
10047d7dbf9dSDan Streetman    ;;
10057d7dbf9dSDan Streetmanesac
10067d7dbf9dSDan Streetman
10079557af9cSAlex Bennéeif eval test -z "\${cross_cc_$cpu}"; then
1008b1aa4de1SAlex Bennée    eval "cross_cc_${cpu}=\$cc"
10092038f8c8SPaolo Bonzini    cross_cc_vars="$cross_cc_vars cross_cc_${cpu}"
10109557af9cSAlex Bennéefi
101179f3b12fSPeter Crosthwaite
101260e0df25SPeter Maydelldefault_target_list=""
10136e92f823SPeter Maydellmak_wilds=""
10146e92f823SPeter Maydell
1015b915a2f1SPaolo Bonziniif [ "$linux_user" != no ]; then
1016b915a2f1SPaolo Bonzini    if [ "$targetos" = linux ] && [ -d $source_path/linux-user/include/host/$cpu ]; then
1017b915a2f1SPaolo Bonzini        linux_user=yes
1018b915a2f1SPaolo Bonzini    elif [ "$linux_user" = yes ]; then
1019b915a2f1SPaolo Bonzini        error_exit "linux-user not supported on this architecture"
1020b915a2f1SPaolo Bonzini    fi
1021b915a2f1SPaolo Bonzinifi
1022b915a2f1SPaolo Bonziniif [ "$bsd_user" != no ]; then
1023b915a2f1SPaolo Bonzini    if [ "$bsd_user" = "" ]; then
1024b915a2f1SPaolo Bonzini        test $targetos = freebsd && bsd_user=yes
1025b915a2f1SPaolo Bonzini    fi
1026b915a2f1SPaolo Bonzini    if [ "$bsd_user" = yes ] && ! [ -d $source_path/bsd-user/$targetos ]; then
1027b915a2f1SPaolo Bonzini        error_exit "bsd-user not supported on this host OS"
1028b915a2f1SPaolo Bonzini    fi
1029b915a2f1SPaolo Bonzinifi
103060e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then
1031812b31d3SAlex Bennée    mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak"
103260e0df25SPeter Maydellfi
103360e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then
1034812b31d3SAlex Bennée    mak_wilds="${mak_wilds} $source_path/configs/targets/*-linux-user.mak"
103560e0df25SPeter Maydellfi
103660e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then
1037812b31d3SAlex Bennée    mak_wilds="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak"
103860e0df25SPeter Maydellfi
103960e0df25SPeter Maydell
1040447e133fSAlex Bennéefor config in $mak_wilds; do
1041447e133fSAlex Bennée    target="$(basename "$config" .mak)"
104298db9a06SAlex Bennée    if echo "$target_list_exclude" | grep -vq "$target"; then
1043447e133fSAlex Bennée        default_target_list="${default_target_list} $target"
1044447e133fSAlex Bennée    fi
1045447e133fSAlex Bennéedone
10466e92f823SPeter Maydell
1047af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1048af5db58eSpbrookcat << EOF
1049af5db58eSpbrook
1050af5db58eSpbrookUsage: configure [options]
1051af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1052af5db58eSpbrook
105308fb77edSStefan WeilStandard options:
105408fb77edSStefan Weil  --help                   print this message
105508fb77edSStefan Weil  --prefix=PREFIX          install in PREFIX [$prefix]
105674154d7eSThomas Huth  --target-list=LIST       set target list (default: build all)
105708fb77edSStefan Weil$(echo Available targets: $default_target_list | \
105808fb77edSStefan Weil  fold -s -w 53 | sed -e 's/^/                           /')
1059447e133fSAlex Bennée  --target-list-exclude=LIST exclude a set of targets from the default target-list
106008fb77edSStefan Weil
106108fb77edSStefan WeilAdvanced options (experts only):
10623812c0c4SJoelle van Dyne  --cross-prefix=PREFIX    use PREFIX for compile tools, PREFIX can be blank [$cross_prefix]
106308fb77edSStefan Weil  --cc=CC                  use C compiler CC [$cc]
106408fb77edSStefan Weil  --host-cc=CC             use C compiler CC [$host_cc] for code run at
106508fb77edSStefan Weil                           build time
106608fb77edSStefan Weil  --cxx=CXX                use C++ compiler CXX [$cxx]
106708fb77edSStefan Weil  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]
1068a2866660SPaolo Bonzini  --extra-cflags=CFLAGS    append extra C compiler flags CFLAGS
1069a2866660SPaolo Bonzini  --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS
1070e910c7d9SPhilippe Mathieu-Daudé  --extra-objcflags=OBJCFLAGS append extra Objective C compiler flags OBJCFLAGS
107108fb77edSStefan Weil  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
1072d75402b5SAlex Bennée  --cross-cc-ARCH=CC       use compiler when building ARCH guest test cases
1073479ca4ccSMatheus Ferst  --cross-cc-cflags-ARCH=  use compiler flags when building ARCH guest tests
107408fb77edSStefan Weil  --make=MAKE              use specified make [$make]
107508fb77edSStefan Weil  --python=PYTHON          use specified python [$python]
1076a5665051SPaolo Bonzini  --meson=MESON            use specified meson [$meson]
107748328880SPaolo Bonzini  --ninja=NINJA            use specified ninja [$ninja]
107808fb77edSStefan Weil  --smbd=SMBD              use specified smbd [$smbd]
1079db1b5f13SThomas Huth  --with-git=GIT           use specified git [$git]
10807d7dbf9dSDan Streetman  --with-git-submodules=update   update git submodules (default if .git dir exists)
10817d7dbf9dSDan Streetman  --with-git-submodules=validate fail if git submodules are not up to date
10827d7dbf9dSDan Streetman  --with-git-submodules=ignore   do not update or check git submodules (default if no .git dir)
108308fb77edSStefan Weil  --static                 enable static build [$static]
108408fb77edSStefan Weil  --bindir=PATH            install binaries in PATH
108513336606SRobert Foley  --efi-aarch64=PATH       PATH of efi file to use for aarch64 VMs.
1086ca8c0909SMarc-André Lureau  --with-suffix=SUFFIX     suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix]
1087c035c8d6SPaolo Bonzini  --without-default-features default all --enable-* options to "disabled"
1088c035c8d6SPaolo Bonzini  --without-default-devices  do not include any device that is not needed to
1089c035c8d6SPaolo Bonzini                           start the emulator (only use if you are including
1090d1d5e9eeSAlex Bennée                           desired devices in configs/devices/)
1091d1d5e9eeSAlex Bennée  --with-devices-ARCH=NAME override default configs/devices
109208fb77edSStefan Weil  --enable-debug           enable common debug build options
1093247724cbSMarc-André Lureau  --enable-sanitizers      enable default sanitizers
10940aebab04SLingfeng Yang  --enable-tsan            enable thread sanitizer
109508fb77edSStefan Weil  --disable-werror         disable compilation abort on warning
109663678e17SSteven Noonan  --disable-stack-protector disable compiler-provided stack protection
109716bfbc70SPaolo Bonzini  --audio-drv-list=LIST    set audio drivers to try if -audiodev is not used
109808fb77edSStefan Weil  --block-drv-whitelist=L  Same as --block-drv-rw-whitelist=L
109908fb77edSStefan Weil  --with-trace-file=NAME   Full PATH,NAME of file to store traces
110008fb77edSStefan Weil                           Default:trace-<pid>
1101c23f23b9SMichael Tokarev  --cpu=CPU                Build for host CPU [$cpu]
110208fb77edSStefan Weil  --with-coroutine=BACKEND coroutine backend. Supported options:
110333c53c54SDaniel P. Berrange                           ucontext, sigaltstack, windows
110408fb77edSStefan Weil  --enable-gcov            enable test coverage analysis with gcov
110540e8c6f4SAlex Bennée  --enable-plugins
110640e8c6f4SAlex Bennée                           enable plugins via shared library loading
1107afc3a8f9SAlex Bennée  --disable-containers     don't use containers for cross-building
1108f48e590aSAlex Bennée  --gdb=GDB-path           gdb to use for gdbstub tests [$gdb_bin]
110961d63097SPaolo BonziniEOF
111061d63097SPaolo Bonzini  meson_options_help
111161d63097SPaolo Bonzinicat << EOF
1112c23f23b9SMichael Tokarev  system          all system emulation targets
1113c23f23b9SMichael Tokarev  user            supported user emulation targets
1114c23f23b9SMichael Tokarev  linux-user      all linux usermode emulation targets
1115c23f23b9SMichael Tokarev  bsd-user        all BSD usermode emulation targets
1116c23f23b9SMichael Tokarev  pie             Position Independent Executables
111721e709aaSMarc-André Lureau  modules         modules support (non-Windows)
1118c23f23b9SMichael Tokarev  debug-tcg       TCG debugging (default is disabled)
1119c23f23b9SMichael Tokarev  debug-info      debugging information
1120cdad781dSDaniele Buono  lto             Enable Link-Time Optimization.
11211e4f6065SDaniele Buono  safe-stack      SafeStack Stack Smash Protection. Depends on
11221e4f6065SDaniele Buono                  clang/llvm >= 3.7 and requires coroutine backend ucontext.
1123299e6f19SPaolo Bonzini  vhost-net       vhost-net kernel acceleration support
1124299e6f19SPaolo Bonzini  vhost-vsock     virtio sockets device support
1125299e6f19SPaolo Bonzini  vhost-scsi      vhost-scsi kernel target support
1126299e6f19SPaolo Bonzini  vhost-crypto    vhost-user-crypto backend support
1127299e6f19SPaolo Bonzini  vhost-kernel    vhost kernel backend support
1128299e6f19SPaolo Bonzini  vhost-user      vhost-user backend support
1129108a6481SCindy Lu  vhost-vdpa      vhost-vdpa kernel backend support
113008fb77edSStefan Weil
113108fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched
1132af5db58eSpbrookEOF
11332d2ad6d0SFam Zhengexit 0
1134af5db58eSpbrookfi
1135af5db58eSpbrook
11369c790242SThomas Huth# Remove old dependency files to make sure that they get properly regenerated
1137bb768f71SThomas Huthrm -f */config-devices.mak.d
11389c790242SThomas Huth
1139faf44142SDaniel P. Berrangéif test -z "$python"
1140faf44142SDaniel P. Berrangéthen
1141c53eeaf7SStefan Hajnoczi    error_exit "Python not found. Use --python=/path/to/python"
1142c53eeaf7SStefan Hajnoczifi
11438e2c76bdSRoman Bolshakovif ! has "$make"
11448e2c76bdSRoman Bolshakovthen
11458e2c76bdSRoman Bolshakov    error_exit "GNU make ($make) not found"
11468e2c76bdSRoman Bolshakovfi
1147c53eeaf7SStefan Hajnoczi
1148c53eeaf7SStefan Hajnoczi# Note that if the Python conditional here evaluates True we will exit
1149c53eeaf7SStefan Hajnoczi# with status 1 which is a shell 'false' value.
11501b11f28dSThomas Huthif ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then
11511b11f28dSThomas Huth  error_exit "Cannot use '$python', Python >= 3.6 is required." \
1152c53eeaf7SStefan Hajnoczi      "Use --python=/path/to/python to specify a supported Python."
1153c53eeaf7SStefan Hajnoczifi
1154c53eeaf7SStefan Hajnoczi
1155755ee70fSCleber Rosa# Preserve python version since some functionality is dependent on it
1156406ab2f3SCleber 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)
1157755ee70fSCleber Rosa
1158c53eeaf7SStefan Hajnoczi# Suppress writing compiled files
1159c53eeaf7SStefan Hajnoczipython="$python -B"
1160c53eeaf7SStefan Hajnoczi
11610a01d76fSMarc-André Lureauif test -z "$meson"; then
11626638cae5SPaolo Bonzini    if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.59.3; then
11630a01d76fSMarc-André Lureau        meson=meson
11647d7dbf9dSDan Streetman    elif test $git_submodules_action != 'ignore' ; then
11650a01d76fSMarc-André Lureau        meson=git
11660a01d76fSMarc-André Lureau    elif test -e "${source_path}/meson/meson.py" ; then
11670a01d76fSMarc-André Lureau        meson=internal
11680a01d76fSMarc-André Lureau    else
11690a01d76fSMarc-André Lureau        if test "$explicit_python" = yes; then
11700a01d76fSMarc-André Lureau            error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found."
11710a01d76fSMarc-André Lureau        else
1172a5665051SPaolo Bonzini            error_exit "Meson not found.  Use --meson=/path/to/meson"
1173a5665051SPaolo Bonzini        fi
11740a01d76fSMarc-André Lureau    fi
11750a01d76fSMarc-André Lureauelse
11760a01d76fSMarc-André Lureau    # Meson uses its own Python interpreter to invoke other Python scripts,
11770a01d76fSMarc-André Lureau    # but the user wants to use the one they specified with --python.
11780a01d76fSMarc-André Lureau    #
11790a01d76fSMarc-André Lureau    # We do not want to override the distro Python interpreter (and sometimes
11800a01d76fSMarc-André Lureau    # cannot: for example in Homebrew /usr/bin/meson is a bash script), so
11810a01d76fSMarc-André Lureau    # just require --meson=git|internal together with --python.
11820a01d76fSMarc-André Lureau    if test "$explicit_python" = yes; then
11830a01d76fSMarc-André Lureau        case "$meson" in
11840a01d76fSMarc-André Lureau            git | internal) ;;
11850a01d76fSMarc-André Lureau            *) error_exit "--python requires using QEMU's embedded Meson distribution." ;;
11860a01d76fSMarc-André Lureau        esac
11870a01d76fSMarc-André Lureau    fi
11880a01d76fSMarc-André Lureaufi
1189a5665051SPaolo Bonzini
11900a01d76fSMarc-André Lureauif test "$meson" = git; then
11910a01d76fSMarc-André Lureau    git_submodules="${git_submodules} meson"
11920a01d76fSMarc-André Lureaufi
11930a01d76fSMarc-André Lureau
11940a01d76fSMarc-André Lureaucase "$meson" in
11950a01d76fSMarc-André Lureau    git | internal)
11960a01d76fSMarc-André Lureau        meson="$python ${source_path}/meson/meson.py"
11970a01d76fSMarc-André Lureau        ;;
119884ec0c24SPaolo Bonzini    *) meson=$(command -v "$meson") ;;
11990a01d76fSMarc-André Lureauesac
12000a01d76fSMarc-André Lureau
120109e93326SPaolo Bonzini# Probe for ninja
120248328880SPaolo Bonzini
120348328880SPaolo Bonziniif test -z "$ninja"; then
120448328880SPaolo Bonzini    for c in ninja ninja-build samu; do
120548328880SPaolo Bonzini        if has $c; then
120648328880SPaolo Bonzini            ninja=$(command -v "$c")
120748328880SPaolo Bonzini            break
120848328880SPaolo Bonzini        fi
120948328880SPaolo Bonzini    done
121009e93326SPaolo Bonzini    if test -z "$ninja"; then
121109e93326SPaolo Bonzini      error_exit "Cannot find Ninja"
121209e93326SPaolo Bonzini    fi
121348328880SPaolo Bonzinifi
1214a5665051SPaolo Bonzini
12159aae6e54SDaniel Henrique Barboza# Check that the C compiler works. Doing this here before testing
12169aae6e54SDaniel Henrique Barboza# the host CPU ensures that we had a valid CC to autodetect the
12179aae6e54SDaniel Henrique Barboza# $cpu var (and we should bail right here if that's not the case).
12189aae6e54SDaniel Henrique Barboza# It also allows the help message to be printed without a CC.
12199aae6e54SDaniel Henrique Barbozawrite_c_skeleton;
12209aae6e54SDaniel Henrique Barbozaif compile_object ; then
12219aae6e54SDaniel Henrique Barboza  : C compiler works ok
12229aae6e54SDaniel Henrique Barbozaelse
12239aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" either does not exist or does not work"
12249aae6e54SDaniel Henrique Barbozafi
12259aae6e54SDaniel Henrique Barbozaif ! compile_prog ; then
12269aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
12279aae6e54SDaniel Henrique Barbozafi
12289aae6e54SDaniel Henrique Barboza
12299c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror
12309c83ffd8SPeter Maydell# by default.  Only enable by default for git builds
12319c83ffd8SPeter Maydellif test -z "$werror" ; then
12327d7dbf9dSDan Streetman    if test "$git_submodules_action" != "ignore" && \
1233e633a5c6SEric Blake        { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
12349c83ffd8SPeter Maydell        werror="yes"
12359c83ffd8SPeter Maydell    else
12369c83ffd8SPeter Maydell        werror="no"
12379c83ffd8SPeter Maydell    fi
12389c83ffd8SPeter Maydellfi
12399c83ffd8SPeter Maydell
1240975ff037SPaolo Bonziniif test "$targetos" = "bogus"; then
1241fb59dabdSPeter Maydell    # Now that we know that we're not printing the help and that
1242fb59dabdSPeter Maydell    # the compiler works (so the results of the check_defines we used
1243fb59dabdSPeter Maydell    # to identify the OS are reliable), if we didn't recognize the
1244fb59dabdSPeter Maydell    # host OS we should stop now.
1245951fedfcSPeter Maydell    error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
1246fb59dabdSPeter Maydellfi
1247fb59dabdSPeter Maydell
1248efc6c070SThomas Huth# Check whether the compiler matches our minimum requirements:
1249efc6c070SThomas Huthcat > $TMPC << EOF
1250efc6c070SThomas Huth#if defined(__clang_major__) && defined(__clang_minor__)
1251efc6c070SThomas Huth# ifdef __apple_build_version__
12522a85a08cSDaniel P. Berrangé#  if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0)
12532a85a08cSDaniel P. Berrangé#   error You need at least XCode Clang v10.0 to compile QEMU
1254efc6c070SThomas Huth#  endif
1255efc6c070SThomas Huth# else
12562a85a08cSDaniel P. Berrangé#  if __clang_major__ < 6 || (__clang_major__ == 6 && __clang_minor__ < 0)
12572a85a08cSDaniel P. Berrangé#   error You need at least Clang v6.0 to compile QEMU
1258efc6c070SThomas Huth#  endif
1259efc6c070SThomas Huth# endif
1260efc6c070SThomas Huth#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
12613830df5fSnia# if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4)
12623830df5fSnia#  error You need at least GCC v7.4.0 to compile QEMU
1263efc6c070SThomas Huth# endif
1264efc6c070SThomas Huth#else
1265efc6c070SThomas Huth# error You either need GCC or Clang to compiler QEMU
1266efc6c070SThomas Huth#endif
1267efc6c070SThomas Huthint main (void) { return 0; }
1268efc6c070SThomas HuthEOF
1269efc6c070SThomas Huthif ! compile_prog "" "" ; then
12703830df5fSnia    error_exit "You need at least GCC v7.4 or Clang v6.0 (or XCode Clang v10.0)"
1271efc6c070SThomas Huthfi
1272efc6c070SThomas Huth
127300849b92SRichard Henderson# Accumulate -Wfoo and -Wno-bar separately.
127400849b92SRichard Henderson# We will list all of the enable flags first, and the disable flags second.
127500849b92SRichard Henderson# Note that we do not add -Werror, because that would enable it for all
127600849b92SRichard Henderson# configure tests. If a configure test failed due to -Werror this would
127700849b92SRichard Henderson# just silently disable some features, so it's too error prone.
127800849b92SRichard Henderson
127900849b92SRichard Hendersonwarn_flags=
128000849b92SRichard Hendersonadd_to warn_flags -Wold-style-declaration
128100849b92SRichard Hendersonadd_to warn_flags -Wold-style-definition
128200849b92SRichard Hendersonadd_to warn_flags -Wtype-limits
128300849b92SRichard Hendersonadd_to warn_flags -Wformat-security
128400849b92SRichard Hendersonadd_to warn_flags -Wformat-y2k
128500849b92SRichard Hendersonadd_to warn_flags -Winit-self
128600849b92SRichard Hendersonadd_to warn_flags -Wignored-qualifiers
128700849b92SRichard Hendersonadd_to warn_flags -Wempty-body
128800849b92SRichard Hendersonadd_to warn_flags -Wnested-externs
128900849b92SRichard Hendersonadd_to warn_flags -Wendif-labels
129000849b92SRichard Hendersonadd_to warn_flags -Wexpansion-to-defined
12910a2ebce9SThomas Huthadd_to warn_flags -Wimplicit-fallthrough=2
129200849b92SRichard Henderson
129300849b92SRichard Hendersonnowarn_flags=
129400849b92SRichard Hendersonadd_to nowarn_flags -Wno-initializer-overrides
129500849b92SRichard Hendersonadd_to nowarn_flags -Wno-missing-include-dirs
129600849b92SRichard Hendersonadd_to nowarn_flags -Wno-shift-negative-value
129700849b92SRichard Hendersonadd_to nowarn_flags -Wno-string-plus-int
129800849b92SRichard Hendersonadd_to nowarn_flags -Wno-typedef-redefinition
1299aabab967SRichard Hendersonadd_to nowarn_flags -Wno-tautological-type-limit-compare
1300bac8d222SRichard Hendersonadd_to nowarn_flags -Wno-psabi
130100849b92SRichard Henderson
130200849b92SRichard Hendersongcc_flags="$warn_flags $nowarn_flags"
130393b25869SJohn Snow
130493b25869SJohn Snowcc_has_warning_flag() {
130593b25869SJohn Snow    write_c_skeleton;
130693b25869SJohn Snow
1307a1d29d6cSPeter Maydell    # Use the positive sense of the flag when testing for -Wno-wombat
1308a1d29d6cSPeter Maydell    # support (gcc will happily accept the -Wno- form of unknown
1309a1d29d6cSPeter Maydell    # warning options).
131093b25869SJohn Snow    optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
131193b25869SJohn Snow    compile_prog "-Werror $optflag" ""
131293b25869SJohn Snow}
131393b25869SJohn Snow
13144cb37d11SPhilippe Mathieu-Daudéobjcc_has_warning_flag() {
13154cb37d11SPhilippe Mathieu-Daudé    cat > $TMPM <<EOF
13164cb37d11SPhilippe Mathieu-Daudéint main(void) { return 0; }
13174cb37d11SPhilippe Mathieu-DaudéEOF
13184cb37d11SPhilippe Mathieu-Daudé
13194cb37d11SPhilippe Mathieu-Daudé    # Use the positive sense of the flag when testing for -Wno-wombat
13204cb37d11SPhilippe Mathieu-Daudé    # support (gcc will happily accept the -Wno- form of unknown
13214cb37d11SPhilippe Mathieu-Daudé    # warning options).
13224cb37d11SPhilippe Mathieu-Daudé    optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
13234cb37d11SPhilippe Mathieu-Daudé    do_objc -Werror $optflag \
13244cb37d11SPhilippe Mathieu-Daudé      $OBJCFLAGS $EXTRA_OBJCFLAGS $CONFIGURE_OBJCFLAGS $QEMU_OBJCFLAGS \
13254cb37d11SPhilippe Mathieu-Daudé      -o $TMPE $TMPM $QEMU_LDFLAGS
13264cb37d11SPhilippe Mathieu-Daudé}
13274cb37d11SPhilippe Mathieu-Daudé
132893b25869SJohn Snowfor flag in $gcc_flags; do
132993b25869SJohn Snow    if cc_has_warning_flag $flag ; then
13308d05095cSPaolo Bonzini        QEMU_CFLAGS="$QEMU_CFLAGS $flag"
13318d05095cSPaolo Bonzini    fi
13324cb37d11SPhilippe Mathieu-Daudé    if objcc_has_warning_flag $flag ; then
13334cb37d11SPhilippe Mathieu-Daudé        QEMU_OBJCFLAGS="$QEMU_OBJCFLAGS $flag"
13344cb37d11SPhilippe Mathieu-Daudé    fi
13358d05095cSPaolo Bonzinidone
13368d05095cSPaolo Bonzini
133763678e17SSteven Noonanif test "$stack_protector" != "no"; then
1338fccd35a0SRodrigo Rebello  cat > $TMPC << EOF
1339fccd35a0SRodrigo Rebelloint main(int argc, char *argv[])
1340fccd35a0SRodrigo Rebello{
1341fccd35a0SRodrigo Rebello    char arr[64], *p = arr, *c = argv[0];
1342fccd35a0SRodrigo Rebello    while (*c) {
1343fccd35a0SRodrigo Rebello        *p++ = *c++;
1344fccd35a0SRodrigo Rebello    }
1345fccd35a0SRodrigo Rebello    return 0;
1346fccd35a0SRodrigo Rebello}
1347fccd35a0SRodrigo RebelloEOF
134863678e17SSteven Noonan  gcc_flags="-fstack-protector-strong -fstack-protector-all"
13493b463a3fSMiroslav Rezanina  sp_on=0
135063678e17SSteven Noonan  for flag in $gcc_flags; do
1351590e5dd9SPeter Maydell    # We need to check both a compile and a link, since some compiler
1352590e5dd9SPeter Maydell    # setups fail only on a .c->.o compile and some only at link time
1353086d5f75SPaolo Bonzini    if compile_object "-Werror $flag" &&
1354590e5dd9SPeter Maydell       compile_prog "-Werror $flag" ""; then
135563678e17SSteven Noonan      QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1356db5adeaaSPaolo Bonzini      QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
13573b463a3fSMiroslav Rezanina      sp_on=1
135863678e17SSteven Noonan      break
135963678e17SSteven Noonan    fi
136063678e17SSteven Noonan  done
13613b463a3fSMiroslav Rezanina  if test "$stack_protector" = yes; then
13623b463a3fSMiroslav Rezanina    if test $sp_on = 0; then
13633b463a3fSMiroslav Rezanina      error_exit "Stack protector not supported"
13643b463a3fSMiroslav Rezanina    fi
13653b463a3fSMiroslav Rezanina  fi
136637746c5eSMarc-André Lureaufi
136737746c5eSMarc-André Lureau
136820bc94a2SPaolo Bonzini# Disable -Wmissing-braces on older compilers that warn even for
136920bc94a2SPaolo Bonzini# the "universal" C zero initializer {0}.
137020bc94a2SPaolo Bonzinicat > $TMPC << EOF
137120bc94a2SPaolo Bonzinistruct {
137220bc94a2SPaolo Bonzini  int a[2];
137320bc94a2SPaolo Bonzini} x = {0};
137420bc94a2SPaolo BonziniEOF
137520bc94a2SPaolo Bonziniif compile_object "-Werror" "" ; then
137620bc94a2SPaolo Bonzini  :
137720bc94a2SPaolo Bonzinielse
137820bc94a2SPaolo Bonzini  QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
137920bc94a2SPaolo Bonzinifi
138020bc94a2SPaolo Bonzini
138121e709aaSMarc-André Lureau# Our module code doesn't support Windows
138221e709aaSMarc-André Lureauif test "$modules" = "yes" && test "$mingw32" = "yes" ; then
138321e709aaSMarc-André Lureau  error_exit "Modules are not available for Windows"
138421e709aaSMarc-André Lureaufi
138521e709aaSMarc-André Lureau
13865f2453acSAlex Bennée# Static linking is not possible with plugins, modules or PIE
138740d6444eSAvi Kivityif test "$static" = "yes" ; then
1388aa0d1f44SPaolo Bonzini  if test "$modules" = "yes" ; then
1389aa0d1f44SPaolo Bonzini    error_exit "static and modules are mutually incompatible"
1390aa0d1f44SPaolo Bonzini  fi
13915f2453acSAlex Bennée  if test "$plugins" = "yes"; then
13925f2453acSAlex Bennée    error_exit "static and plugins are mutually incompatible"
1393ba4dd2aaSAlex Bennée  else
1394ba4dd2aaSAlex Bennée    plugins="no"
13955f2453acSAlex Bennée  fi
139640d6444eSAvi Kivityfi
139737650689SPaolo Bonzinitest "$plugins" = "" && plugins=yes
139840d6444eSAvi Kivity
139940d6444eSAvi Kivitycat > $TMPC << EOF
140021d4a791SAvi Kivity
140121d4a791SAvi Kivity#ifdef __linux__
140221d4a791SAvi Kivity#  define THREAD __thread
140321d4a791SAvi Kivity#else
140421d4a791SAvi Kivity#  define THREAD
140521d4a791SAvi Kivity#endif
140621d4a791SAvi Kivitystatic THREAD int tls_var;
140721d4a791SAvi Kivityint main(void) { return tls_var; }
140840d6444eSAvi KivityEOF
1409b2634124SRichard Henderson
1410ffd205efSJessica Clarke# Check we support -fno-pie and -no-pie first; we will need the former for
1411ffd205efSJessica Clarke# building ROMs, and both for everything if --disable-pie is passed.
1412412aeacdSAlex Bennéeif compile_prog "-Werror -fno-pie" "-no-pie"; then
1413412aeacdSAlex Bennée  CFLAGS_NOPIE="-fno-pie"
1414ffd205efSJessica Clarke  LDFLAGS_NOPIE="-no-pie"
1415412aeacdSAlex Bennéefi
1416412aeacdSAlex Bennée
141712781462SRichard Hendersonif test "$static" = "yes"; then
1418eca7a8e6SRichard Henderson  if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then
14195770e8afSPaolo Bonzini    CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
142012781462SRichard Henderson    QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS"
142112781462SRichard Henderson    pie="yes"
142212781462SRichard Henderson  elif test "$pie" = "yes"; then
142312781462SRichard Henderson    error_exit "-static-pie not available due to missing toolchain support"
142412781462SRichard Henderson  else
142512781462SRichard Henderson    QEMU_LDFLAGS="-static $QEMU_LDFLAGS"
142612781462SRichard Henderson    pie="no"
142712781462SRichard Henderson  fi
142812781462SRichard Hendersonelif test "$pie" = "no"; then
14295770e8afSPaolo Bonzini  CONFIGURE_CFLAGS="$CFLAGS_NOPIE $CONFIGURE_CFLAGS"
1430ffd205efSJessica Clarke  CONFIGURE_LDFLAGS="$LDFLAGS_NOPIE $CONFIGURE_LDFLAGS"
1431eca7a8e6SRichard Hendersonelif compile_prog "-Werror -fPIE -DPIE" "-pie"; then
14325770e8afSPaolo Bonzini  CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
14335770e8afSPaolo Bonzini  CONFIGURE_LDFLAGS="-pie $CONFIGURE_LDFLAGS"
143440d6444eSAvi Kivity  pie="yes"
14352c674109SRichard Hendersonelif test "$pie" = "yes"; then
143676ad07a4SPeter Maydell  error_exit "PIE not available due to missing toolchain support"
143740d6444eSAvi Kivityelse
143840d6444eSAvi Kivity  echo "Disabling PIE due to missing toolchain support"
143940d6444eSAvi Kivity  pie="no"
144040d6444eSAvi Kivityfi
144140d6444eSAvi Kivity
1442e6cbd751SRichard Henderson# Detect support for PT_GNU_RELRO + DT_BIND_NOW.
1443e6cbd751SRichard Henderson# The combination is known as "full relro", because .got.plt is read-only too.
1444e6cbd751SRichard Hendersonif compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
1445e6cbd751SRichard Henderson  QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS"
1446e6cbd751SRichard Hendersonfi
1447e6cbd751SRichard Henderson
144809dada40SPaolo Bonzini##########################################
144909dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains
145009dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit
145109dada40SPaolo Bonzini# specification is necessary
145209dada40SPaolo Bonzini
145309dada40SPaolo Bonziniif test "$cpu" = "i386"; then
145409dada40SPaolo Bonzini  cat > $TMPC << EOF
145509dada40SPaolo Bonzinistatic int sfaa(int *ptr)
145609dada40SPaolo Bonzini{
145709dada40SPaolo Bonzini  return __sync_fetch_and_and(ptr, 0);
145809dada40SPaolo Bonzini}
145909dada40SPaolo Bonzini
146009dada40SPaolo Bonziniint main(void)
146109dada40SPaolo Bonzini{
146209dada40SPaolo Bonzini  int val = 42;
14631405b629SStefan Weil  val = __sync_val_compare_and_swap(&val, 0, 1);
146409dada40SPaolo Bonzini  sfaa(&val);
146509dada40SPaolo Bonzini  return val;
146609dada40SPaolo Bonzini}
146709dada40SPaolo BonziniEOF
146809dada40SPaolo Bonzini  if ! compile_prog "" "" ; then
146909dada40SPaolo Bonzini    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
147009dada40SPaolo Bonzini  fi
147109dada40SPaolo Bonzinifi
147209dada40SPaolo Bonzini
147356267b62SPhilippe Mathieu-Daudéif test "$tcg" = "enabled"; then
147456267b62SPhilippe Mathieu-Daudé    git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
147556267b62SPhilippe Mathieu-Daudé    git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
147656267b62SPhilippe Mathieu-Daudéfi
147756267b62SPhilippe Mathieu-Daudé
1478afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then
1479fdb75aefSPaolo Bonzini    default_targets=yes
1480d880a3baSPaolo Bonzini    for target in $default_target_list; do
1481d880a3baSPaolo Bonzini        target_list="$target_list $target"
1482d880a3baSPaolo Bonzini    done
1483d880a3baSPaolo Bonzini    target_list="${target_list# }"
1484121afa9eSAnthony Liguorielse
1485fdb75aefSPaolo Bonzini    default_targets=no
148689138857SStefan Weil    target_list=$(echo "$target_list" | sed -e 's/,/ /g')
1487d880a3baSPaolo Bonzini    for target in $target_list; do
148825b48338SPeter Maydell        # Check that we recognised the target name; this allows a more
148925b48338SPeter Maydell        # friendly error message than if we let it fall through.
149025b48338SPeter Maydell        case " $default_target_list " in
149125b48338SPeter Maydell            *" $target "*)
149225b48338SPeter Maydell                ;;
149325b48338SPeter Maydell            *)
149425b48338SPeter Maydell                error_exit "Unknown target name '$target'"
149525b48338SPeter Maydell                ;;
149625b48338SPeter Maydell        esac
149725b48338SPeter Maydell    done
1498d880a3baSPaolo Bonzinifi
149925b48338SPeter Maydell
1500f55fe278SPaolo Bonzini# see if system emulation was really requested
1501f55fe278SPaolo Bonzinicase " $target_list " in
1502f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
1503f55fe278SPaolo Bonzini  ;;
1504f55fe278SPaolo Bonzini  *) softmmu=no
1505f55fe278SPaolo Bonzini  ;;
1506f55fe278SPaolo Bonziniesac
15075327cf48Sbellard
1508249247c9SJuan Quintelafeature_not_found() {
1509249247c9SJuan Quintela  feature=$1
151021684af0SStewart Smith  remedy=$2
1511249247c9SJuan Quintela
151276ad07a4SPeter Maydell  error_exit "User requested feature $feature" \
151321684af0SStewart Smith      "configure was not able to find it." \
151421684af0SStewart Smith      "$remedy"
1515249247c9SJuan Quintela}
1516249247c9SJuan Quintela
15177d13299dSbellard# ---
15187d13299dSbellard# big/little endian test
15197d13299dSbellardcat > $TMPC << EOF
1520659eb157SThomas Huth#include <stdio.h>
152161cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
152261cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
1523659eb157SThomas Huthint main(int argc, char *argv[])
1524659eb157SThomas Huth{
1525659eb157SThomas Huth    return printf("%s %s\n", (char *)big_endian, (char *)little_endian);
15267d13299dSbellard}
15277d13299dSbellardEOF
15287d13299dSbellard
1529659eb157SThomas Huthif compile_prog ; then
1530659eb157SThomas Huth    if strings -a $TMPE | grep -q BiGeNdIaN ; then
153161cc919fSMike Frysinger        bigendian="yes"
1532659eb157SThomas Huth    elif strings -a $TMPE | grep -q LiTtLeEnDiAn ; then
153361cc919fSMike Frysinger        bigendian="no"
15347d13299dSbellard    else
15357d13299dSbellard        echo big/little test failed
1536659eb157SThomas Huth        exit 1
15377d13299dSbellard    fi
15387d13299dSbellardelse
153961cc919fSMike Frysinger    echo big/little test failed
1540659eb157SThomas Huth    exit 1
15417d13299dSbellardfi
15427d13299dSbellard
1543299e6f19SPaolo Bonzini#########################################
1544299e6f19SPaolo Bonzini# vhost interdependencies and host support
1545299e6f19SPaolo Bonzini
1546299e6f19SPaolo Bonzini# vhost backends
1547eb9baecdSSergio Lopezif test "$vhost_user" = "yes" && test "$mingw32" = "yes"; then
1548eb9baecdSSergio Lopez  error_exit "vhost-user is not available on Windows"
1549299e6f19SPaolo Bonzinifi
1550108a6481SCindy Lutest "$vhost_vdpa" = "" && vhost_vdpa=$linux
1551108a6481SCindy Luif test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then
1552108a6481SCindy Lu  error_exit "vhost-vdpa is only available on Linux"
1553108a6481SCindy Lufi
1554299e6f19SPaolo Bonzinitest "$vhost_kernel" = "" && vhost_kernel=$linux
1555299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then
1556299e6f19SPaolo Bonzini  error_exit "vhost-kernel is only available on Linux"
1557299e6f19SPaolo Bonzinifi
1558299e6f19SPaolo Bonzini
1559299e6f19SPaolo Bonzini# vhost-kernel devices
1560299e6f19SPaolo Bonzinitest "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel
1561299e6f19SPaolo Bonziniif test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then
1562299e6f19SPaolo Bonzini  error_exit "--enable-vhost-scsi requires --enable-vhost-kernel"
1563299e6f19SPaolo Bonzinifi
1564299e6f19SPaolo Bonzinitest "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel
1565299e6f19SPaolo Bonziniif test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then
1566299e6f19SPaolo Bonzini  error_exit "--enable-vhost-vsock requires --enable-vhost-kernel"
1567299e6f19SPaolo Bonzinifi
1568299e6f19SPaolo Bonzini
1569299e6f19SPaolo Bonzini# vhost-user backends
1570299e6f19SPaolo Bonzinitest "$vhost_net_user" = "" && vhost_net_user=$vhost_user
1571299e6f19SPaolo Bonziniif test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then
1572299e6f19SPaolo Bonzini  error_exit "--enable-vhost-net-user requires --enable-vhost-user"
1573299e6f19SPaolo Bonzinifi
1574299e6f19SPaolo Bonzinitest "$vhost_crypto" = "" && vhost_crypto=$vhost_user
1575299e6f19SPaolo Bonziniif test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then
1576299e6f19SPaolo Bonzini  error_exit "--enable-vhost-crypto requires --enable-vhost-user"
1577299e6f19SPaolo Bonzinifi
157898fc1adaSDr. David Alan Gilberttest "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user
157998fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then
158098fc1adaSDr. David Alan Gilbert  error_exit "--enable-vhost-user-fs requires --enable-vhost-user"
158198fc1adaSDr. David Alan Gilbertfi
1582108a6481SCindy Lu#vhost-vdpa backends
1583108a6481SCindy Lutest "$vhost_net_vdpa" = "" && vhost_net_vdpa=$vhost_vdpa
1584108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" && test "$vhost_vdpa" = "no"; then
1585108a6481SCindy Lu  error_exit "--enable-vhost-net-vdpa requires --enable-vhost-vdpa"
1586108a6481SCindy Lufi
1587299e6f19SPaolo Bonzini
158840bc0ca9SLaurent Vivier# OR the vhost-kernel, vhost-vdpa and vhost-user values for simplicity
1589299e6f19SPaolo Bonziniif test "$vhost_net" = ""; then
1590299e6f19SPaolo Bonzini  test "$vhost_net_user" = "yes" && vhost_net=yes
159140bc0ca9SLaurent Vivier  test "$vhost_net_vdpa" = "yes" && vhost_net=yes
1592299e6f19SPaolo Bonzini  test "$vhost_kernel" = "yes" && vhost_net=yes
1593299e6f19SPaolo Bonzinifi
1594299e6f19SPaolo Bonzini
1595015a33bdSGonglei##########################################
1596779ab5e3SStefan Weil# pkg-config probe
1597779ab5e3SStefan Weil
1598779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then
159976ad07a4SPeter Maydell  error_exit "pkg-config binary '$pkg_config_exe' not found"
1600779ab5e3SStefan Weilfi
1601779ab5e3SStefan Weil
1602779ab5e3SStefan Weil##########################################
1603e18df141SAnthony Liguori# glib support probe
1604a52d28afSPaolo Bonzini
1605b4c6036fSDaniel P. Berrangéglib_req_ver=2.56
1606aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0
1607aa0d1f44SPaolo Bonziniif test "$modules" = yes; then
1608a88afc64SGerd Hoffmann    glib_modules="$glib_modules gmodule-export-2.0"
1609b906acacSPaolo Bonzinielif test "$plugins" = "yes"; then
1610b906acacSPaolo Bonzini    glib_modules="$glib_modules gmodule-no-export-2.0"
161154cb65d8SEmilio G. Cotafi
1612e26110cfSFam Zheng
1613aa0d1f44SPaolo Bonzinifor i in $glib_modules; do
1614e26110cfSFam Zheng    if $pkg_config --atleast-version=$glib_req_ver $i; then
161589138857SStefan Weil        glib_cflags=$($pkg_config --cflags $i)
161689138857SStefan Weil        glib_libs=$($pkg_config --libs $i)
1617e18df141SAnthony Liguori    else
1618e26110cfSFam Zheng        error_exit "glib-$glib_req_ver $i is required to compile QEMU"
1619e26110cfSFam Zheng    fi
1620e26110cfSFam Zhengdone
1621e26110cfSFam Zheng
1622215b0c2fSPaolo Bonzini# This workaround is required due to a bug in pkg-config file for glib as it
1623215b0c2fSPaolo Bonzini# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
1624215b0c2fSPaolo Bonzini
1625215b0c2fSPaolo Bonziniif test "$static" = yes && test "$mingw32" = yes; then
1626215b0c2fSPaolo Bonzini    glib_cflags="-DGLIB_STATIC_COMPILATION $glib_cflags"
1627215b0c2fSPaolo Bonzinifi
1628215b0c2fSPaolo Bonzini
1629977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the
1630977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches
1631977a82abSDaniel P. Berrange# problems on multi-arch where people try to build
1632977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers
1633977a82abSDaniel P. Berrangecat > $TMPC <<EOF
1634977a82abSDaniel P. Berrange#include <glib.h>
1635977a82abSDaniel P. Berrange#include <unistd.h>
1636977a82abSDaniel P. Berrange
1637977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \
1638977a82abSDaniel P. Berrange  typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
1639977a82abSDaniel P. Berrange
1640977a82abSDaniel P. Berrangeint main(void) {
1641977a82abSDaniel P. Berrange   QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
1642977a82abSDaniel P. Berrange   return 0;
1643977a82abSDaniel P. Berrange}
1644977a82abSDaniel P. BerrangeEOF
1645977a82abSDaniel P. Berrange
1646215b0c2fSPaolo Bonziniif ! compile_prog "$glib_cflags" "$glib_libs" ; then
1647977a82abSDaniel P. Berrange    error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
1648977a82abSDaniel P. Berrange               "You probably need to set PKG_CONFIG_LIBDIR"\
1649977a82abSDaniel P. Berrange	       "to point to the right pkg-config files for your"\
1650977a82abSDaniel P. Berrange	       "build target"
1651977a82abSDaniel P. Berrangefi
1652977a82abSDaniel P. Berrange
16539bda600bSEric Blake# Silence clang warnings triggered by glib < 2.57.2
16549bda600bSEric Blakecat > $TMPC << EOF
16559bda600bSEric Blake#include <glib.h>
16569bda600bSEric Blaketypedef struct Foo {
16579bda600bSEric Blake    int i;
16589bda600bSEric Blake} Foo;
16599bda600bSEric Blakestatic void foo_free(Foo *f)
16609bda600bSEric Blake{
16619bda600bSEric Blake    g_free(f);
16629bda600bSEric Blake}
1663e0e7fe07SMarc-André LureauG_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free)
16649bda600bSEric Blakeint main(void) { return 0; }
16659bda600bSEric BlakeEOF
16669bda600bSEric Blakeif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
16679bda600bSEric Blake    if cc_has_warning_flag "-Wno-unused-function"; then
16689bda600bSEric Blake        glib_cflags="$glib_cflags -Wno-unused-function"
16695770e8afSPaolo Bonzini        CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -Wno-unused-function"
16709bda600bSEric Blake    fi
16719bda600bSEric Blakefi
16729bda600bSEric Blake
1673e26110cfSFam Zheng##########################################
1674f652e6afSaurel32# fdt probe
1675e169e1e1SPeter Maydell
1676fbb4121dSPaolo Bonzinicase "$fdt" in
1677fbb4121dSPaolo Bonzini  auto | enabled | internal)
1678fbb4121dSPaolo Bonzini    # Simpler to always update submodule, even if not needed.
1679aef45d51SDaniel P. Berrange    git_submodules="${git_submodules} dtc"
1680fbb4121dSPaolo Bonzini    ;;
1681fbb4121dSPaolo Bonziniesac
1682f652e6afSaurel32
168320ff075bSMichael Walle##########################################
16848ca80760SRichard Henderson# capstone
16858ca80760SRichard Henderson
1686e219c499SRichard Hendersoncase "$capstone" in
16878b18cdbfSRichard Henderson  auto | enabled | internal)
16888b18cdbfSRichard Henderson    # Simpler to always update submodule, even if not needed.
1689e219c499SRichard Henderson    git_submodules="${git_submodules} capstone"
1690e219c499SRichard Henderson    ;;
1691e219c499SRichard Hendersonesac
16928ca80760SRichard Henderson
16938ca80760SRichard Henderson##########################################
1694519175a2SAlex Barcelo# check and set a backend for coroutine
1695d0e2fce5SAneesh Kumar K.V
16967c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback
169733c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows
169833c53c54SDaniel P. Berrange# specific one.
16997c2acc70SPeter Maydell
17007c2acc70SPeter Maydellucontext_works=no
1701d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
1702d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
1703d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
1704cdf84806SPeter Maydell#ifdef __stub_makecontext
1705cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
1706cdf84806SPeter Maydell#endif
170775cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
1708d0e2fce5SAneesh Kumar K.VEOF
1709d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
17107c2acc70SPeter Maydell    ucontext_works=yes
1711d0e2fce5SAneesh Kumar K.V  fi
1712519175a2SAlex Barcelofi
17137c2acc70SPeter Maydell
17147c2acc70SPeter Maydellif test "$coroutine" = ""; then
17157c2acc70SPeter Maydell  if test "$mingw32" = "yes"; then
17167c2acc70SPeter Maydell    coroutine=win32
17177c2acc70SPeter Maydell  elif test "$ucontext_works" = "yes"; then
17187c2acc70SPeter Maydell    coroutine=ucontext
1719519175a2SAlex Barcelo  else
17207c2acc70SPeter Maydell    coroutine=sigaltstack
17217c2acc70SPeter Maydell  fi
17227c2acc70SPeter Maydellelse
17237c2acc70SPeter Maydell  case $coroutine in
17247c2acc70SPeter Maydell  windows)
17257c2acc70SPeter Maydell    if test "$mingw32" != "yes"; then
17267c2acc70SPeter Maydell      error_exit "'windows' coroutine backend only valid for Windows"
17277c2acc70SPeter Maydell    fi
17287c2acc70SPeter Maydell    # Unfortunately the user visible backend name doesn't match the
17297c2acc70SPeter Maydell    # coroutine-*.c filename for this case, so we have to adjust it here.
17307c2acc70SPeter Maydell    coroutine=win32
17317c2acc70SPeter Maydell    ;;
17327c2acc70SPeter Maydell  ucontext)
17337c2acc70SPeter Maydell    if test "$ucontext_works" != "yes"; then
17347c2acc70SPeter Maydell      feature_not_found "ucontext"
17357c2acc70SPeter Maydell    fi
17367c2acc70SPeter Maydell    ;;
173733c53c54SDaniel P. Berrange  sigaltstack)
17387c2acc70SPeter Maydell    if test "$mingw32" = "yes"; then
17397c2acc70SPeter Maydell      error_exit "only the 'windows' coroutine backend is valid for Windows"
17407c2acc70SPeter Maydell    fi
17417c2acc70SPeter Maydell    ;;
17427c2acc70SPeter Maydell  *)
174376ad07a4SPeter Maydell    error_exit "unknown coroutine backend $coroutine"
17447c2acc70SPeter Maydell    ;;
17457c2acc70SPeter Maydell  esac
1746d0e2fce5SAneesh Kumar K.Vfi
1747d0e2fce5SAneesh Kumar K.V
17481e4f6065SDaniele Buono##################################################
17491e4f6065SDaniele Buono# SafeStack
17501e4f6065SDaniele Buono
17511e4f6065SDaniele Buono
17521e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then
17531e4f6065SDaniele Buonocat > $TMPC << EOF
17541e4f6065SDaniele Buonoint main(int argc, char *argv[])
17551e4f6065SDaniele Buono{
17561e4f6065SDaniele Buono#if ! __has_feature(safe_stack)
17571e4f6065SDaniele Buono#error SafeStack Disabled
17581e4f6065SDaniele Buono#endif
17591e4f6065SDaniele Buono    return 0;
17601e4f6065SDaniele Buono}
17611e4f6065SDaniele BuonoEOF
17621e4f6065SDaniele Buono  flag="-fsanitize=safe-stack"
17631e4f6065SDaniele Buono  # Check that safe-stack is supported and enabled.
17641e4f6065SDaniele Buono  if compile_prog "-Werror $flag" "$flag"; then
17651e4f6065SDaniele Buono    # Flag needed both at compilation and at linking
17661e4f6065SDaniele Buono    QEMU_CFLAGS="$QEMU_CFLAGS $flag"
17671e4f6065SDaniele Buono    QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
17681e4f6065SDaniele Buono  else
17691e4f6065SDaniele Buono    error_exit "SafeStack not supported by your compiler"
17701e4f6065SDaniele Buono  fi
17711e4f6065SDaniele Buono  if test "$coroutine" != "ucontext"; then
17721e4f6065SDaniele Buono    error_exit "SafeStack is only supported by the coroutine backend ucontext"
17731e4f6065SDaniele Buono  fi
17741e4f6065SDaniele Buonoelse
17751e4f6065SDaniele Buonocat > $TMPC << EOF
17761e4f6065SDaniele Buonoint main(int argc, char *argv[])
17771e4f6065SDaniele Buono{
17781e4f6065SDaniele Buono#if defined(__has_feature)
17791e4f6065SDaniele Buono#if __has_feature(safe_stack)
17801e4f6065SDaniele Buono#error SafeStack Enabled
17811e4f6065SDaniele Buono#endif
17821e4f6065SDaniele Buono#endif
17831e4f6065SDaniele Buono    return 0;
17841e4f6065SDaniele Buono}
17851e4f6065SDaniele BuonoEOF
17861e4f6065SDaniele Buonoif test "$safe_stack" = "no"; then
17871e4f6065SDaniele Buono  # Make sure that safe-stack is disabled
17881e4f6065SDaniele Buono  if ! compile_prog "-Werror" ""; then
17891e4f6065SDaniele Buono    # SafeStack was already enabled, try to explicitly remove the feature
17901e4f6065SDaniele Buono    flag="-fno-sanitize=safe-stack"
17911e4f6065SDaniele Buono    if ! compile_prog "-Werror $flag" "$flag"; then
17921e4f6065SDaniele Buono      error_exit "Configure cannot disable SafeStack"
17931e4f6065SDaniele Buono    fi
17941e4f6065SDaniele Buono    QEMU_CFLAGS="$QEMU_CFLAGS $flag"
17951e4f6065SDaniele Buono    QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
17961e4f6065SDaniele Buono  fi
17971e4f6065SDaniele Buonoelse # "$safe_stack" = ""
17981e4f6065SDaniele Buono  # Set safe_stack to yes or no based on pre-existing flags
17991e4f6065SDaniele Buono  if compile_prog "-Werror" ""; then
18001e4f6065SDaniele Buono    safe_stack="no"
18011e4f6065SDaniele Buono  else
18021e4f6065SDaniele Buono    safe_stack="yes"
18031e4f6065SDaniele Buono    if test "$coroutine" != "ucontext"; then
18041e4f6065SDaniele Buono      error_exit "SafeStack is only supported by the coroutine backend ucontext"
18051e4f6065SDaniele Buono    fi
18061e4f6065SDaniele Buono  fi
18071e4f6065SDaniele Buonofi
18081e4f6065SDaniele Buonofi
18097d992e4dSPeter Lieven
181076a347e1SRichard Henderson########################################
1811fd0e6053SJohn Snow# check if ccache is interfering with
1812fd0e6053SJohn Snow# semantic analysis of macros
1813fd0e6053SJohn Snow
18145e4dfd3dSJohn Snowunset CCACHE_CPP2
1815fd0e6053SJohn Snowccache_cpp2=no
1816fd0e6053SJohn Snowcat > $TMPC << EOF
1817fd0e6053SJohn Snowstatic const int Z = 1;
1818fd0e6053SJohn Snow#define fn() ({ Z; })
1819fd0e6053SJohn Snow#define TAUT(X) ((X) == Z)
1820fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y)
1821fd0e6053SJohn Snow#define ID(X) (X)
1822fd0e6053SJohn Snowint main(int argc, char *argv[])
1823fd0e6053SJohn Snow{
1824fd0e6053SJohn Snow    int x = 0, y = 0;
1825fd0e6053SJohn Snow    x = ID(x);
1826fd0e6053SJohn Snow    x = fn();
1827fd0e6053SJohn Snow    fn();
1828fd0e6053SJohn Snow    if (PAREN(x, y)) return 0;
1829fd0e6053SJohn Snow    if (TAUT(Z)) return 0;
1830fd0e6053SJohn Snow    return 0;
1831fd0e6053SJohn Snow}
1832fd0e6053SJohn SnowEOF
1833fd0e6053SJohn Snow
1834fd0e6053SJohn Snowif ! compile_object "-Werror"; then
1835fd0e6053SJohn Snow    ccache_cpp2=yes
1836fd0e6053SJohn Snowfi
1837fd0e6053SJohn Snow
1838b553a042SJohn Snow#################################################
1839b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE.
1840b553a042SJohn Snow
1841b553a042SJohn Snowif test "$fortify_source" != "no"; then
1842b553a042SJohn Snow  if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
1843b553a042SJohn Snow    fortify_source="no";
1844e189091fSPeter Maydell  elif test -n "$cxx" && has $cxx &&
1845cfcc7c14SJohn Snow       echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
1846b553a042SJohn Snow    fortify_source="no";
1847b553a042SJohn Snow  else
1848b553a042SJohn Snow    fortify_source="yes"
1849b553a042SJohn Snow  fi
1850b553a042SJohn Snowfi
1851b553a042SJohn Snow
1852d2042378SAneesh Kumar K.V##########################################
1853247724cbSMarc-André Lureau# checks for sanitizers
1854247724cbSMarc-André Lureau
1855247724cbSMarc-André Lureauhave_asan=no
1856247724cbSMarc-André Lureauhave_ubsan=no
1857d83414e1SMarc-André Lureauhave_asan_iface_h=no
1858d83414e1SMarc-André Lureauhave_asan_iface_fiber=no
1859247724cbSMarc-André Lureau
1860247724cbSMarc-André Lureauif test "$sanitizers" = "yes" ; then
1861b9f44da2SMarc-André Lureau  write_c_skeleton
1862247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
1863247724cbSMarc-André Lureau      have_asan=yes
1864247724cbSMarc-André Lureau  fi
1865b9f44da2SMarc-André Lureau
1866b9f44da2SMarc-André Lureau  # we could use a simple skeleton for flags checks, but this also
1867b9f44da2SMarc-André Lureau  # detect the static linking issue of ubsan, see also:
1868b9f44da2SMarc-André Lureau  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
1869b9f44da2SMarc-André Lureau  cat > $TMPC << EOF
1870b9f44da2SMarc-André Lureau#include <stdlib.h>
1871b9f44da2SMarc-André Lureauint main(void) {
1872b9f44da2SMarc-André Lureau    void *tmp = malloc(10);
1873f2dfe54cSLeonid Bloch    if (tmp != NULL) {
1874b9f44da2SMarc-André Lureau        return *(int *)(tmp + 2);
1875b9f44da2SMarc-André Lureau    }
1876d1abf3fcSOlaf Hering    return 1;
1877f2dfe54cSLeonid Bloch}
1878b9f44da2SMarc-André LureauEOF
1879247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
1880247724cbSMarc-André Lureau      have_ubsan=yes
1881247724cbSMarc-André Lureau  fi
1882d83414e1SMarc-André Lureau
1883d83414e1SMarc-André Lureau  if check_include "sanitizer/asan_interface.h" ; then
1884d83414e1SMarc-André Lureau      have_asan_iface_h=yes
1885d83414e1SMarc-André Lureau  fi
1886d83414e1SMarc-André Lureau
1887d83414e1SMarc-André Lureau  cat > $TMPC << EOF
1888d83414e1SMarc-André Lureau#include <sanitizer/asan_interface.h>
1889d83414e1SMarc-André Lureauint main(void) {
1890d83414e1SMarc-André Lureau  __sanitizer_start_switch_fiber(0, 0, 0);
1891d83414e1SMarc-André Lureau  return 0;
1892d83414e1SMarc-André Lureau}
1893d83414e1SMarc-André LureauEOF
1894d83414e1SMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
1895d83414e1SMarc-André Lureau      have_asan_iface_fiber=yes
1896d83414e1SMarc-André Lureau  fi
1897247724cbSMarc-André Lureaufi
1898247724cbSMarc-André Lureau
18990aebab04SLingfeng Yang# Thread sanitizer is, for now, much noisier than the other sanitizers;
19000aebab04SLingfeng Yang# keep it separate until that is not the case.
19010aebab04SLingfeng Yangif test "$tsan" = "yes" && test "$sanitizers" = "yes"; then
19020aebab04SLingfeng Yang  error_exit "TSAN is not supported with other sanitiziers."
19030aebab04SLingfeng Yangfi
19040aebab04SLingfeng Yanghave_tsan=no
19050aebab04SLingfeng Yanghave_tsan_iface_fiber=no
19060aebab04SLingfeng Yangif test "$tsan" = "yes" ; then
19070aebab04SLingfeng Yang  write_c_skeleton
19080aebab04SLingfeng Yang  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
19090aebab04SLingfeng Yang      have_tsan=yes
19100aebab04SLingfeng Yang  fi
19110aebab04SLingfeng Yang  cat > $TMPC << EOF
19120aebab04SLingfeng Yang#include <sanitizer/tsan_interface.h>
19130aebab04SLingfeng Yangint main(void) {
19140aebab04SLingfeng Yang  __tsan_create_fiber(0);
19150aebab04SLingfeng Yang  return 0;
19160aebab04SLingfeng Yang}
19170aebab04SLingfeng YangEOF
19180aebab04SLingfeng Yang  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
19190aebab04SLingfeng Yang      have_tsan_iface_fiber=yes
19200aebab04SLingfeng Yang  fi
19210aebab04SLingfeng Yangfi
19220aebab04SLingfeng Yang
1923adc28027SAlexander Bulekov##########################################
1924675b9b53SMarc-André Lureau# check for slirp
1925675b9b53SMarc-André Lureau
1926675b9b53SMarc-André Lureaucase "$slirp" in
19274d34a86bSPaolo Bonzini  auto | enabled | internal)
19284d34a86bSPaolo Bonzini    # Simpler to always update submodule, even if not needed.
19297c57bdd8SMarc-André Lureau    git_submodules="${git_submodules} slirp"
1930675b9b53SMarc-André Lureau    ;;
1931675b9b53SMarc-André Lureauesac
1932675b9b53SMarc-André Lureau
193354e7aac0SAlexey Krasikov##########################################
1934e86ecd4bSJuan Quintela# End of CC checks
1935e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
1936e86ecd4bSJuan Quintela
1937d83414e1SMarc-André Lureauwrite_c_skeleton
1938d83414e1SMarc-André Lureau
1939df42fa7dSPaolo Bonziniif test "$fortify_source" = "yes" ; then
1940086d5f75SPaolo Bonzini  QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
1941086d5f75SPaolo Bonzini  debug=no
1942086d5f75SPaolo Bonzinifi
1943086d5f75SPaolo Bonzini
1944086d5f75SPaolo Bonzinicase "$ARCH" in
1945086d5f75SPaolo Bonzinialpha)
1946086d5f75SPaolo Bonzini  # Ensure there's only a single GP
1947086d5f75SPaolo Bonzini  QEMU_CFLAGS="-msmall-data $QEMU_CFLAGS"
1948086d5f75SPaolo Bonzini;;
1949086d5f75SPaolo Bonziniesac
1950086d5f75SPaolo Bonzini
1951247724cbSMarc-André Lureauif test "$have_asan" = "yes"; then
1952db5adeaaSPaolo Bonzini  QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS"
1953db5adeaaSPaolo Bonzini  QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS"
1954d83414e1SMarc-André Lureau  if test "$have_asan_iface_h" = "no" ; then
1955d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header missing." \
1956d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
1957d83414e1SMarc-André Lureau  elif test "$have_asan_iface_fiber" = "no" ; then
1958d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header is too old." \
1959d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
1960d83414e1SMarc-André Lureau  fi
1961247724cbSMarc-André Lureaufi
19620aebab04SLingfeng Yangif test "$have_tsan" = "yes" ; then
19630aebab04SLingfeng Yang  if test "$have_tsan_iface_fiber" = "yes" ; then
19640aebab04SLingfeng Yang    QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS"
19650aebab04SLingfeng Yang    QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS"
19660aebab04SLingfeng Yang  else
19670aebab04SLingfeng Yang    error_exit "Cannot enable TSAN due to missing fiber annotation interface."
19680aebab04SLingfeng Yang  fi
19690aebab04SLingfeng Yangelif test "$tsan" = "yes" ; then
19700aebab04SLingfeng Yang  error_exit "Cannot enable TSAN due to missing sanitize thread interface."
19710aebab04SLingfeng Yangfi
1972247724cbSMarc-André Lureauif test "$have_ubsan" = "yes"; then
1973db5adeaaSPaolo Bonzini  QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS"
1974db5adeaaSPaolo Bonzini  QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS"
1975247724cbSMarc-André Lureaufi
1976247724cbSMarc-André Lureau
19776542aa9cSPeter Lieven##########################################
19783efac6ebSTomáš Golembiovský
19790aebab04SLingfeng Yang# Exclude --warn-common with TSan to suppress warnings from the TSan libraries.
19800aebab04SLingfeng Yangif test "$solaris" = "no" && test "$tsan" = "no"; then
1981e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
1982db5adeaaSPaolo Bonzini        QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS"
1983e86ecd4bSJuan Quintela    fi
1984e86ecd4bSJuan Quintelafi
1985e86ecd4bSJuan Quintela
1986b846ab7cSPaolo Bonzini# Guest agent Windows MSI package
19879d6bc27bSMichael Roth
19889d6bc27bSMichael Rothif test "$QEMU_GA_MANUFACTURER" = ""; then
19899d6bc27bSMichael Roth  QEMU_GA_MANUFACTURER=QEMU
19909d6bc27bSMichael Rothfi
19919d6bc27bSMichael Rothif test "$QEMU_GA_DISTRO" = ""; then
19929d6bc27bSMichael Roth  QEMU_GA_DISTRO=Linux
19939d6bc27bSMichael Rothfi
19949d6bc27bSMichael Rothif test "$QEMU_GA_VERSION" = ""; then
199589138857SStefan Weil    QEMU_GA_VERSION=$(cat $source_path/VERSION)
19969d6bc27bSMichael Rothfi
19979d6bc27bSMichael Roth
19986e444209SPaolo BonziniQEMU_GA_MSI_MINGW_BIN_PATH="$($pkg_config --variable=prefix glib-2.0)/bin"
19999d6bc27bSMichael Roth
2000ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
2001ca35f780SPaolo Bonziniroms=
2002e633a5c6SEric Blakeif { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \
2003ba7c60c2SPaolo Bonzini        test "$targetos" != "darwin" && test "$targetos" != "sunos" && \
2004ba7c60c2SPaolo Bonzini        test "$targetos" != "haiku" && test "$softmmu" = yes ; then
2005e57218b6SPeter Maydell    # Different host OS linkers have different ideas about the name of the ELF
2006c65d5e4eSBrad Smith    # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
2007c65d5e4eSBrad Smith    # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
2008c65d5e4eSBrad Smith    for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
2009e57218b6SPeter Maydell        if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
2010e57218b6SPeter Maydell            ld_i386_emulation="$emu"
2011ca35f780SPaolo Bonzini            roms="optionrom"
2012e57218b6SPeter Maydell            break
2013e57218b6SPeter Maydell        fi
2014e57218b6SPeter Maydell    done
2015ca35f780SPaolo Bonzinifi
2016ca35f780SPaolo Bonzini
20172e33c3f8SThomas Huth# Only build s390-ccw bios if we're on s390x and the compiler has -march=z900
2018a5b2afd5SThomas Huth# or -march=z10 (which is the lowest architecture level that Clang supports)
20199933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then
20202e33c3f8SThomas Huth  write_c_skeleton
2021a5b2afd5SThomas Huth  compile_prog "-march=z900" ""
2022a5b2afd5SThomas Huth  has_z900=$?
20233af448b3SThomas Huth  if [ $has_z900 = 0 ] || compile_object "-march=z10 -msoft-float -Werror"; then
2024a5b2afd5SThomas Huth    if [ $has_z900 != 0 ]; then
2025a5b2afd5SThomas Huth      echo "WARNING: Your compiler does not support the z900!"
2026a5b2afd5SThomas Huth      echo "         The s390-ccw bios will only work with guest CPUs >= z10."
2027a5b2afd5SThomas Huth    fi
20289933c305SChristian Borntraeger    roms="$roms s390-ccw"
20291ef6bfc2SPhilippe Mathieu-Daudé    # SLOF is required for building the s390-ccw firmware on s390x,
20301ef6bfc2SPhilippe Mathieu-Daudé    # since it is using the libnet code from SLOF for network booting.
20311ef6bfc2SPhilippe Mathieu-Daudé    git_submodules="${git_submodules} roms/SLOF"
20321ef6bfc2SPhilippe Mathieu-Daudé  fi
20339933c305SChristian Borntraegerfi
20349933c305SChristian Borntraeger
203511cde1c8SBruno Dominguez# Check that the C++ compiler exists and works with the C compiler.
203611cde1c8SBruno 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.
203711cde1c8SBruno Dominguezif has $cxx; then
203811cde1c8SBruno Dominguez    cat > $TMPC <<EOF
203911cde1c8SBruno Dominguezint c_function(void);
204011cde1c8SBruno Dominguezint main(void) { return c_function(); }
204111cde1c8SBruno DominguezEOF
204211cde1c8SBruno Dominguez
204311cde1c8SBruno Dominguez    compile_object
204411cde1c8SBruno Dominguez
204511cde1c8SBruno Dominguez    cat > $TMPCXX <<EOF
204611cde1c8SBruno Dominguezextern "C" {
204711cde1c8SBruno Dominguez   int c_function(void);
204811cde1c8SBruno Dominguez}
204911cde1c8SBruno Dominguezint c_function(void) { return 42; }
205011cde1c8SBruno DominguezEOF
205111cde1c8SBruno Dominguez
205211cde1c8SBruno Dominguez    update_cxxflags
205311cde1c8SBruno Dominguez
2054a2866660SPaolo Bonzini    if do_cxx $CXXFLAGS $EXTRA_CXXFLAGS $CONFIGURE_CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then
205511cde1c8SBruno Dominguez        # C++ compiler $cxx works ok with C compiler $cc
205611cde1c8SBruno Dominguez        :
205711cde1c8SBruno Dominguez    else
205811cde1c8SBruno Dominguez        echo "C++ compiler $cxx does not work with C compiler $cc"
205911cde1c8SBruno Dominguez        echo "Disabling C++ specific optional code"
206011cde1c8SBruno Dominguez        cxx=
206111cde1c8SBruno Dominguez    fi
206211cde1c8SBruno Dominguezelse
206311cde1c8SBruno Dominguez    echo "No C++ compiler available; disabling C++ specific optional code"
206411cde1c8SBruno Dominguez    cxx=
206511cde1c8SBruno Dominguezfi
206611cde1c8SBruno Dominguez
20677d7dbf9dSDan Streetmanif !(GIT="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then
20687d7dbf9dSDan Streetman    exit 1
20695d91a2edSYonggang Luofi
20705d91a2edSYonggang Luo
207198ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
207297a847bcSbellard
207398ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
207498ec69acSJuan Quintelaecho >> $config_host_mak
207598ec69acSJuan Quintela
2076e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
2077cc84d63aSDaniel P. Berrangeecho "GIT=$git" >> $config_host_mak
2078aef45d51SDaniel P. Berrangeecho "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
20797d7dbf9dSDan Streetmanecho "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak
2080804edf29SJuan Quintela
2081f8393946Saurel32if test "$debug_tcg" = "yes" ; then
20822358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
2083f8393946Saurel32fi
208467b915a5Sbellardif test "$mingw32" = "yes" ; then
208598ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
20866e444209SPaolo Bonzini  echo "QEMU_GA_MSI_MINGW_BIN_PATH=${QEMU_GA_MSI_MINGW_BIN_PATH}" >> $config_host_mak
20879dacf32dSYossi Hindin  echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
20889dacf32dSYossi Hindin  echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
20899dacf32dSYossi Hindin  echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
2090210fa556Spbrookelse
209135f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
2092210fa556Spbrookfi
2093128ab2ffSblueswir1
2094dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
2095dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
2096dffcb71cSMark McLoughlinfi
2097dffcb71cSMark McLoughlin
209883fb7adfSbellardif test "$darwin" = "yes" ; then
209998ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
210083fb7adfSbellardfi
2101b29fe3edSmalc
2102ec530c81Sbellardif test "$solaris" = "yes" ; then
210398ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
2104ec530c81Sbellardfi
210597a847bcSbellardif test "$static" = "yes" ; then
210698ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
210797a847bcSbellardfi
210889138857SStefan Weilqemu_version=$(head $source_path/VERSION)
210998ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
21102b1f35b9SAlex Bennéeecho "TARGET_DIRS=$target_list" >> $config_host_mak
211117969268SFam Zhengif test "$modules" = "yes"; then
211217969268SFam Zheng  echo "CONFIG_MODULES=y" >> $config_host_mak
211317969268SFam Zhengfi
2114277abf15SJan Vesely
21155e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then
21165e9be92dSNicholas Bellinger  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
21175e9be92dSNicholas Bellingerfi
2118af3bba76SPaolo Bonziniif test "$vhost_net" = "yes" ; then
2119af3bba76SPaolo Bonzini  echo "CONFIG_VHOST_NET=y" >> $config_host_mak
2120af3bba76SPaolo Bonzinifi
2121af3bba76SPaolo Bonziniif test "$vhost_net_user" = "yes" ; then
212256f41de7SPaolo Bonzini  echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak
212303ce5744SNikolay Nikolaevfi
2124108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" ; then
2125108a6481SCindy Lu  echo "CONFIG_VHOST_NET_VDPA=y" >> $config_host_mak
2126108a6481SCindy Lufi
2127042cea27SGongleiif test "$vhost_crypto" = "yes" ; then
2128042cea27SGonglei  echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
2129042cea27SGongleifi
2130fc0b9b0eSStefan Hajnocziif test "$vhost_vsock" = "yes" ; then
2131fc0b9b0eSStefan Hajnoczi  echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
21325fe97d88SStefano Garzarella  if test "$vhost_user" = "yes" ; then
21335fe97d88SStefano Garzarella    echo "CONFIG_VHOST_USER_VSOCK=y" >> $config_host_mak
21345fe97d88SStefano Garzarella  fi
2135fc0b9b0eSStefan Hajnoczifi
2136299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" ; then
2137299e6f19SPaolo Bonzini  echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak
2138299e6f19SPaolo Bonzinifi
2139e6a74868SMarc-André Lureauif test "$vhost_user" = "yes" ; then
2140e6a74868SMarc-André Lureau  echo "CONFIG_VHOST_USER=y" >> $config_host_mak
2141e6a74868SMarc-André Lureaufi
2142108a6481SCindy Luif test "$vhost_vdpa" = "yes" ; then
2143108a6481SCindy Lu  echo "CONFIG_VHOST_VDPA=y" >> $config_host_mak
2144108a6481SCindy Lufi
214598fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" ; then
214698fc1adaSDr. David Alan Gilbert  echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak
214798fc1adaSDr. David Alan Gilbertfi
214858d3f3ffSGerd Hoffmann
214983fb7adfSbellard# XXX: suppress that
21507d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
21512358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
21527d3505c5Sbellardfi
21537d3505c5Sbellard
21547c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
21557d992e4dSPeter Lieven
2156d83414e1SMarc-André Lureauif test "$have_asan_iface_fiber" = "yes" ; then
2157d83414e1SMarc-André Lureau    echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
2158d83414e1SMarc-André Lureaufi
2159d83414e1SMarc-André Lureau
21600aebab04SLingfeng Yangif test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then
21610aebab04SLingfeng Yang    echo "CONFIG_TSAN=y" >> $config_host_mak
21620aebab04SLingfeng Yangfi
21630aebab04SLingfeng Yang
216440e8c6f4SAlex Bennéeif test "$plugins" = "yes" ; then
216540e8c6f4SAlex Bennée    echo "CONFIG_PLUGIN=y" >> $config_host_mak
216640e8c6f4SAlex Bennéefi
216740e8c6f4SAlex Bennée
2168f48e590aSAlex Bennéeif test -n "$gdb_bin"; then
2169b1863cccSAlex Bennée    gdb_version=$($gdb_bin --version | head -n 1)
2170d6a66c81SAlex Bennée    if version_ge ${gdb_version##* } 9.1; then
2171f48e590aSAlex Bennée        echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
2172f48e590aSAlex Bennée    fi
2173b1863cccSAlex Bennéefi
2174f48e590aSAlex Bennée
217598ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
2176804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
2177c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
217839d87c8cSAlex Bennéeecho "GENISOIMAGE=$genisoimage" >> $config_host_mak
2179a5665051SPaolo Bonziniecho "MESON=$meson" >> $config_host_mak
218009e93326SPaolo Bonziniecho "NINJA=$ninja" >> $config_host_mak
2181804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
2182804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
2183cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak
21845f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak
21853dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak
2186804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
2187804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
218846eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
2189a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
219011cde1c8SBruno Dominguezecho "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
21914cb37d11SPhilippe Mathieu-Daudéecho "QEMU_OBJCFLAGS=$QEMU_OBJCFLAGS" >> $config_host_mak
2192a81df1b6SPaolo Bonziniecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
2193a81df1b6SPaolo Bonziniecho "GLIB_LIBS=$glib_libs" >> $config_host_mak
2194d83acfd0SMarc-André Lureauecho "GLIB_VERSION=$(pkg-config --modversion glib-2.0)" >> $config_host_mak
21958a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
2196e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
2197a70248dbSPaolo Bonziniecho "STRIP=$strip" >> $config_host_mak
2198804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
2199804edf29SJuan Quintela
22006efd7517SPeter Maydell# use included Linux headers
22016efd7517SPeter Maydellif test "$linux" = "yes" ; then
2202a307beb6SAndreas Färber  mkdir -p linux-headers
22036efd7517SPeter Maydell  case "$cpu" in
22044da270beSPaolo Bonzini  i386|x86_64)
220508312a63SPeter Maydell    linux_arch=x86
22066efd7517SPeter Maydell    ;;
2207d8ff892dSPaolo Bonzini  ppc|ppc64)
220808312a63SPeter Maydell    linux_arch=powerpc
22096efd7517SPeter Maydell    ;;
22106efd7517SPeter Maydell  s390x)
221108312a63SPeter Maydell    linux_arch=s390
221208312a63SPeter Maydell    ;;
22131f080313SClaudio Fontana  aarch64)
22141f080313SClaudio Fontana    linux_arch=arm64
22151f080313SClaudio Fontana    ;;
2216dfcf900bSWANG Xuerui  loongarch*)
2217dfcf900bSWANG Xuerui    linux_arch=loongarch
2218dfcf900bSWANG Xuerui    ;;
2219222e7d11SSanjay Lal  mips64)
2220222e7d11SSanjay Lal    linux_arch=mips
2221222e7d11SSanjay Lal    ;;
222208312a63SPeter Maydell  *)
222308312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
222408312a63SPeter Maydell    linux_arch="$cpu"
22256efd7517SPeter Maydell    ;;
22266efd7517SPeter Maydell  esac
222708312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
222808312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
222908312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
223008312a63SPeter Maydell    fi
22316efd7517SPeter Maydellfi
22326efd7517SPeter Maydell
223397a847bcSbellardfor target in $target_list; do
223497a847bcSbellard    target_dir="$target"
223557a93f16SPhilippe Mathieu-Daudé    target_name=$(echo $target | cut -d '-' -f 1)$EXESUF
223697a847bcSbellard    mkdir -p $target_dir
2237fdb75aefSPaolo Bonzini    case $target in
2238fdb75aefSPaolo Bonzini        *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;;
2239fdb75aefSPaolo Bonzini        *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;;
22402408a527Saurel32    esac
224156aebc89Spbrookdone
22427d13299dSbellard
2243fdb75aefSPaolo Bonziniif test "$default_targets" = "yes"; then
2244fdb75aefSPaolo Bonzini  echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak
2245fdb75aefSPaolo Bonzinifi
2246a540f158SPeter Crosthwaite
2247fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then
2248fd0e6053SJohn Snow  echo "export CCACHE_CPP2=y" >> $config_host_mak
2249fd0e6053SJohn Snowfi
2250fd0e6053SJohn Snow
22511e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then
22521e4f6065SDaniele Buono  echo "CONFIG_SAFESTACK=y" >> $config_host_mak
22531e4f6065SDaniele Buonofi
22541e4f6065SDaniele Buono
2255e29e5c6eSPeter Maydell# If we're using a separate build tree, set it up now.
2256e29e5c6eSPeter Maydell# LINKS are things to symlink back into the source tree
2257e29e5c6eSPeter Maydell# (these can be both files and directories).
2258e29e5c6eSPeter Maydell# Caution: do not add files or directories here using wildcards. This
2259e29e5c6eSPeter Maydell# will result in problems later if a new file matching the wildcard is
2260e29e5c6eSPeter Maydell# added to the source tree -- nothing will cause configure to be rerun
2261e29e5c6eSPeter Maydell# so the build tree will be missing the link back to the new file, and
2262e29e5c6eSPeter Maydell# tests might fail. Prefer to keep the relevant files in their own
2263e29e5c6eSPeter Maydell# directory and symlink the directory instead.
22642038f8c8SPaolo BonziniLINKS="Makefile"
22653941996bSPaolo BonziniLINKS="$LINKS tests/tcg/Makefile.target"
2266ddcf607fSGerd HoffmannLINKS="$LINKS pc-bios/optionrom/Makefile"
2267e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/s390-ccw/Makefile"
2268e29e5c6eSPeter MaydellLINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
2269bbbd9b6eSWillian RampazzoLINKS="$LINKS tests/avocado tests/data"
227039950353SPeter MaydellLINKS="$LINKS tests/qemu-iotests/check"
22718f8fd9edSCleber RosaLINKS="$LINKS python"
2272c17a386bSAlex BennéeLINKS="$LINKS contrib/plugins/Makefile "
2273753d11f2SRichard Hendersonfor bios_file in \
2274753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
22753a631b8eSBin Meng    $source_path/pc-bios/*.elf \
2276225a9ab8SAlexey Kardashevskiy    $source_path/pc-bios/*.lid \
2277753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
2278753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
2279e89e33e1SDominik Dingel    $source_path/pc-bios/*.img \
2280753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
22814e73c781SAlexander Graf    $source_path/pc-bios/u-boot.* \
2282cd946e5cSJohn Arbuckle    $source_path/pc-bios/palcode-* \
2283cd946e5cSJohn Arbuckle    $source_path/pc-bios/qemu_vga.ndrv
2284cd946e5cSJohn Arbuckle
2285753d11f2SRichard Hendersondo
2286e29e5c6eSPeter Maydell    LINKS="$LINKS pc-bios/$(basename $bios_file)"
22877ea78b74SJan Kiszkadone
2288e29e5c6eSPeter Maydellfor f in $LINKS ; do
22890f4d8894SPaolo Bonzini    if [ -e "$source_path/$f" ]; then
22905dce7b8dSPaolo Bonzini        mkdir -p `dirname ./$f`
2291f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
2292f9245e10SPeter Maydell    fi
22937d13299dSbellarddone
22941ad2134fSPaul Brook
22952038f8c8SPaolo Bonzini(for i in $cross_cc_vars; do
22962038f8c8SPaolo Bonzini  export $i
22972038f8c8SPaolo Bonzinidone
2298544f4a25SPaolo Bonziniexport target_list source_path use_containers cpu host_cc
22992038f8c8SPaolo Bonzini$source_path/tests/tcg/configure.sh)
23002038f8c8SPaolo Bonzini
230198409991SHelge Konetzkaconfig_mak=pc-bios/optionrom/config.mak
230298409991SHelge Konetzkaecho "# Automatically generated by configure - do not modify" > $config_mak
230398409991SHelge Konetzkaecho "TOPSRC_DIR=$source_path" >> $config_mak
230498409991SHelge Konetzka
2305a5665051SPaolo Bonziniif test "$skip_meson" = no; then
2306fc929892SMarc-André Lureau  cross="config-meson.cross.new"
2307fc929892SMarc-André Lureau  meson_quote() {
2308ac7ebcc5SPaolo Bonzini    test $# = 0 && return
230947b30835SPaolo Bonzini    echo "'$(echo $* | sed "s/ /','/g")'"
2310fc929892SMarc-André Lureau  }
2311fc929892SMarc-André Lureau
2312fc929892SMarc-André Lureau  echo "# Automatically generated by configure - do not modify" > $cross
2313fc929892SMarc-André Lureau  echo "[properties]" >> $cross
2314d1d5e9eeSAlex Bennée
2315d1d5e9eeSAlex Bennée  # unroll any custom device configs
2316d1d5e9eeSAlex Bennée  for a in $device_archs; do
2317d1d5e9eeSAlex Bennée      eval "c=\$devices_${a}"
2318d1d5e9eeSAlex Bennée      echo "${a}-softmmu = '$c'" >> $cross
2319d1d5e9eeSAlex Bennée  done
2320d1d5e9eeSAlex Bennée
2321fc929892SMarc-André Lureau  test -z "$cxx" && echo "link_language = 'c'" >> $cross
232247b30835SPaolo Bonzini  echo "[built-in options]" >> $cross
2323a2866660SPaolo Bonzini  echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross
2324a2866660SPaolo Bonzini  echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross
2325e910c7d9SPhilippe Mathieu-Daudé  test -n "$objcc" && echo "objc_args = [$(meson_quote $OBJCFLAGS $EXTRA_OBJCFLAGS)]" >> $cross
2326a2866660SPaolo Bonzini  echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross
2327a2866660SPaolo Bonzini  echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross
2328fc929892SMarc-André Lureau  echo "[binaries]" >> $cross
23294dba2789SPaolo Bonzini  echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross
23304dba2789SPaolo Bonzini  test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross
23314dba2789SPaolo Bonzini  test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross
233247b30835SPaolo Bonzini  echo "ar = [$(meson_quote $ar)]" >> $cross
233347b30835SPaolo Bonzini  echo "nm = [$(meson_quote $nm)]" >> $cross
233447b30835SPaolo Bonzini  echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross
233547b30835SPaolo Bonzini  echo "ranlib = [$(meson_quote $ranlib)]" >> $cross
2336e8178514SPaolo Bonzini  if has $sdl2_config; then
233747b30835SPaolo Bonzini    echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross
2338e8178514SPaolo Bonzini  fi
233947b30835SPaolo Bonzini  echo "strip = [$(meson_quote $strip)]" >> $cross
2340158bb224SKonstantin Kostiuk  echo "widl = [$(meson_quote $widl)]" >> $cross
234147b30835SPaolo Bonzini  echo "windres = [$(meson_quote $windres)]" >> $cross
23423812c0c4SJoelle van Dyne  if test "$cross_compile" = "yes"; then
2343fc929892SMarc-André Lureau    cross_arg="--cross-file config-meson.cross"
2344fc929892SMarc-André Lureau    echo "[host_machine]" >> $cross
2345ba7c60c2SPaolo Bonzini    echo "system = '$targetos'" >> $cross
2346823eb013SPaolo Bonzini    case "$cpu" in
2347f6bca9dfSJoelle van Dyne        i386)
2348fc929892SMarc-André Lureau            echo "cpu_family = 'x86'" >> $cross
2349fc929892SMarc-André Lureau            ;;
2350fc929892SMarc-André Lureau        *)
2351823eb013SPaolo Bonzini            echo "cpu_family = '$cpu'" >> $cross
2352fc929892SMarc-André Lureau            ;;
2353fc929892SMarc-André Lureau    esac
2354fc929892SMarc-André Lureau    echo "cpu = '$cpu'" >> $cross
2355fc929892SMarc-André Lureau    if test "$bigendian" = "yes" ; then
2356fc929892SMarc-André Lureau        echo "endian = 'big'" >> $cross
2357fc929892SMarc-André Lureau    else
2358fc929892SMarc-André Lureau        echo "endian = 'little'" >> $cross
2359fc929892SMarc-André Lureau    fi
2360fc929892SMarc-André Lureau  else
2361fc929892SMarc-André Lureau    cross_arg="--native-file config-meson.cross"
2362fc929892SMarc-André Lureau  fi
2363fc929892SMarc-André Lureau  mv $cross config-meson.cross
2364fc929892SMarc-André Lureau
2365a5665051SPaolo Bonzini  rm -rf meson-private meson-info meson-logs
236661d63097SPaolo Bonzini  run_meson() {
236709e93326SPaolo Bonzini    NINJA=$ninja $meson setup \
2368d17f305aSPaolo Bonzini        --prefix "$prefix" \
2369d17f305aSPaolo Bonzini        --bindir "$bindir" \
23703b4da132SPaolo Bonzini        -Ddefault_devices=$default_devices \
237173f3aa37SMarc-André Lureau        -Dqemu_suffix="$qemu_suffix" \
237235acbb30SPaolo Bonzini        -Dsmbd="$smbd" \
2373a5665051SPaolo Bonzini        -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) \
2374a5665051SPaolo Bonzini        -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo false; fi) \
2375a5665051SPaolo Bonzini        -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \
2376da6d48b9SMarc-André Lureau        -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \
2377bf0e56a3SMarc-André Lureau        -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \
237814efd8d3SPaolo Bonzini        -Db_lto=$lto -Dcfi=$cfi -Dtcg=$tcg \
23793b4da132SPaolo Bonzini        -Dcapstone=$capstone -Dfdt=$fdt -Dslirp=$slirp \
2380537b7248SPaolo Bonzini        $(test -n "${LIB_FUZZING_ENGINE+xxx}" && echo "-Dfuzzing_engine=$LIB_FUZZING_ENGINE") \
2381332008e0SThomas Huth        $(if test "$default_feature" = no; then echo "-Dauto_features=disabled"; fi) \
238261d63097SPaolo Bonzini        "$@" $cross_arg "$PWD" "$source_path"
238361d63097SPaolo Bonzini  }
238461d63097SPaolo Bonzini  eval run_meson $meson_options
2385a5665051SPaolo Bonzini  if test "$?" -ne 0 ; then
2386a5665051SPaolo Bonzini      error_exit "meson setup failed"
2387a5665051SPaolo Bonzini  fi
2388699d3884SPaolo Bonzinielse
2389699d3884SPaolo Bonzini  if test -f meson-private/cmd_line.txt; then
2390699d3884SPaolo Bonzini    # Adjust old command line options whose type was changed
2391699d3884SPaolo Bonzini    # Avoids having to use "setup --wipe" when Meson is upgraded
2392699d3884SPaolo Bonzini    perl -i -ne '
2393699d3884SPaolo Bonzini      s/^gettext = true$/gettext = auto/;
2394699d3884SPaolo Bonzini      s/^gettext = false$/gettext = disabled/;
2395654d6b04SPaolo Bonzini      /^b_staticpic/ && next;
2396699d3884SPaolo Bonzini      print;' meson-private/cmd_line.txt
2397699d3884SPaolo Bonzini  fi
2398a5665051SPaolo Bonzinifi
2399a5665051SPaolo Bonzini
2400dc655404SMichael S. Tsirkin# Save the configure command line for later reuse.
2401dc655404SMichael S. Tsirkincat <<EOD >config.status
2402dc655404SMichael S. Tsirkin#!/bin/sh
2403dc655404SMichael S. Tsirkin# Generated by configure.
2404dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration.
2405dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging
2406dc655404SMichael S. Tsirkin# configure, is in config.log if it exists.
2407dc655404SMichael S. TsirkinEOD
2408e811da7fSDaniel P. Berrangé
2409e811da7fSDaniel P. Berrangépreserve_env() {
2410e811da7fSDaniel P. Berrangé    envname=$1
2411e811da7fSDaniel P. Berrangé
2412e811da7fSDaniel P. Berrangé    eval envval=\$$envname
2413e811da7fSDaniel P. Berrangé
2414e811da7fSDaniel P. Berrangé    if test -n "$envval"
2415e811da7fSDaniel P. Berrangé    then
2416e811da7fSDaniel P. Berrangé	echo "$envname='$envval'" >> config.status
2417e811da7fSDaniel P. Berrangé	echo "export $envname" >> config.status
2418e811da7fSDaniel P. Berrangé    else
2419e811da7fSDaniel P. Berrangé	echo "unset $envname" >> config.status
2420e811da7fSDaniel P. Berrangé    fi
2421e811da7fSDaniel P. Berrangé}
2422e811da7fSDaniel P. Berrangé
2423e811da7fSDaniel P. Berrangé# Preserve various env variables that influence what
2424e811da7fSDaniel P. Berrangé# features/build target configure will detect
2425e811da7fSDaniel P. Berrangépreserve_env AR
2426e811da7fSDaniel P. Berrangépreserve_env AS
2427e811da7fSDaniel P. Berrangépreserve_env CC
2428e811da7fSDaniel P. Berrangépreserve_env CPP
24298009da03SPaolo Bonzinipreserve_env CFLAGS
2430e811da7fSDaniel P. Berrangépreserve_env CXX
24318009da03SPaolo Bonzinipreserve_env CXXFLAGS
2432e811da7fSDaniel P. Berrangépreserve_env INSTALL
2433e811da7fSDaniel P. Berrangépreserve_env LD
24348009da03SPaolo Bonzinipreserve_env LDFLAGS
2435e811da7fSDaniel P. Berrangépreserve_env LD_LIBRARY_PATH
2436e811da7fSDaniel P. Berrangépreserve_env LIBTOOL
2437e811da7fSDaniel P. Berrangépreserve_env MAKE
2438e811da7fSDaniel P. Berrangépreserve_env NM
2439e811da7fSDaniel P. Berrangépreserve_env OBJCOPY
2440e811da7fSDaniel P. Berrangépreserve_env PATH
2441e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG
2442e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_LIBDIR
2443e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_PATH
2444e811da7fSDaniel P. Berrangépreserve_env PYTHON
2445e811da7fSDaniel P. Berrangépreserve_env SDL2_CONFIG
2446e811da7fSDaniel P. Berrangépreserve_env SMBD
2447e811da7fSDaniel P. Berrangépreserve_env STRIP
2448158bb224SKonstantin Kostiukpreserve_env WIDL
2449e811da7fSDaniel P. Berrangépreserve_env WINDRES
2450e811da7fSDaniel P. Berrangé
2451dc655404SMichael S. Tsirkinprintf "exec" >>config.status
2452a5665051SPaolo Bonzinifor i in "$0" "$@"; do
2453835af899SPaolo Bonzini  test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status
2454a5665051SPaolo Bonzinidone
2455cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status
2456dc655404SMichael S. Tsirkinchmod +x config.status
2457dc655404SMichael S. Tsirkin
24588cd05ab6SPeter Maydellrm -r "$TMPDIR1"
2459