xref: /openbmc/qemu/configure (revision 922268067fe4181d6edcfccd689e908e4d1243ad)
1#!/bin/sh
2#
3# qemu configure script (c) 2003 Fabrice Bellard
4#
5
6# Unset some variables known to interfere with behavior of common tools,
7# just as autoconf does.
8CLICOLOR_FORCE= GREP_OPTIONS=
9unset CLICOLOR_FORCE GREP_OPTIONS
10
11# Don't allow CCACHE, if present, to use cached results of compile tests!
12export CCACHE_RECACHE=yes
13
14# make source path absolute
15source_path=$(cd "$(dirname -- "$0")"; pwd)
16
17if test "$PWD" = "$source_path"
18then
19    echo "Using './build' as the directory for build output"
20
21    MARKER=build/auto-created-by-configure
22
23    if test -e build
24    then
25        if test -f $MARKER
26        then
27           rm -rf build
28        else
29            echo "ERROR: ./build dir already exists and was not previously created by configure"
30            exit 1
31        fi
32    fi
33
34    mkdir build
35    touch $MARKER
36
37    cat > GNUmakefile <<'EOF'
38# This file is auto-generated by configure to support in-source tree
39# 'make' command invocation
40
41ifeq ($(MAKECMDGOALS),)
42recurse: all
43endif
44
45.NOTPARALLEL: %
46%: force
47	@echo 'changing dir to build for $(MAKE) "$(MAKECMDGOALS)"...'
48	@$(MAKE) -C build -f Makefile $(MAKECMDGOALS)
49	@if test "$(MAKECMDGOALS)" = "distclean" && \
50	    test -e build/auto-created-by-configure ; \
51	then \
52	    rm -rf build GNUmakefile ; \
53	fi
54force: ;
55.PHONY: force
56GNUmakefile: ;
57
58EOF
59    cd build
60    exec $source_path/configure "$@"
61fi
62
63# Temporary directory used for files created while
64# configure runs. Since it is in the build directory
65# we can safely blow away any previous version of it
66# (and we need not jump through hoops to try to delete
67# it when configure exits.)
68TMPDIR1="config-temp"
69rm -rf "${TMPDIR1}"
70mkdir -p "${TMPDIR1}"
71if [ $? -ne 0 ]; then
72    echo "ERROR: failed to create temporary directory"
73    exit 1
74fi
75
76TMPB="qemu-conf"
77TMPC="${TMPDIR1}/${TMPB}.c"
78TMPO="${TMPDIR1}/${TMPB}.o"
79TMPCXX="${TMPDIR1}/${TMPB}.cxx"
80TMPE="${TMPDIR1}/${TMPB}.exe"
81
82rm -f config.log
83
84# Print a helpful header at the top of config.log
85echo "# QEMU configure log $(date)" >> config.log
86printf "# Configured with:" >> config.log
87printf " '%s'" "$0" "$@" >> config.log
88echo >> config.log
89echo "#" >> config.log
90
91quote_sh() {
92    printf "%s" "$1" | sed "s,','\\\\'',g; s,.*,'&',"
93}
94
95print_error() {
96    (echo
97    echo "ERROR: $1"
98    while test -n "$2"; do
99        echo "       $2"
100        shift
101    done
102    echo) >&2
103}
104
105error_exit() {
106    print_error "$@"
107    exit 1
108}
109
110do_compiler() {
111    # Run the compiler, capturing its output to the log. First argument
112    # is compiler binary to execute.
113    compiler="$1"
114    shift
115    if test -n "$BASH_VERSION"; then eval '
116        echo >>config.log "
117funcs: ${FUNCNAME[*]}
118lines: ${BASH_LINENO[*]}"
119    '; fi
120    echo $compiler "$@" >> config.log
121    $compiler "$@" >> config.log 2>&1 || return $?
122    # Test passed. If this is an --enable-werror build, rerun
123    # the test with -Werror and bail out if it fails. This
124    # makes warning-generating-errors in configure test code
125    # obvious to developers.
126    if test "$werror" != "yes"; then
127        return 0
128    fi
129    # Don't bother rerunning the compile if we were already using -Werror
130    case "$*" in
131        *-Werror*)
132           return 0
133        ;;
134    esac
135    echo $compiler -Werror "$@" >> config.log
136    $compiler -Werror "$@" >> config.log 2>&1 && return $?
137    error_exit "configure test passed without -Werror but failed with -Werror." \
138        "This is probably a bug in the configure script. The failing command" \
139        "will be at the bottom of config.log." \
140        "You can run configure with --disable-werror to bypass this check."
141}
142
143do_cc() {
144    do_compiler "$cc" $CPU_CFLAGS "$@"
145}
146
147do_cxx() {
148    do_compiler "$cxx" $CPU_CFLAGS "$@"
149}
150
151# Append $2 to the variable named $1, with space separation
152add_to() {
153    eval $1=\${$1:+\"\$$1 \"}\$2
154}
155
156update_cxxflags() {
157    # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
158    # options which some versions of GCC's C++ compiler complain about
159    # because they only make sense for C programs.
160    QEMU_CXXFLAGS="-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS"
161    CONFIGURE_CXXFLAGS=$(echo "$CONFIGURE_CFLAGS" | sed s/-std=gnu11/-std=gnu++11/)
162    for arg in $QEMU_CFLAGS; do
163        case $arg in
164            -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
165            -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
166                ;;
167            *)
168                QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
169                ;;
170        esac
171    done
172}
173
174compile_object() {
175  local_cflags="$1"
176  do_cc $CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
177}
178
179compile_prog() {
180  local_cflags="$1"
181  local_ldflags="$2"
182  do_cc $CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC \
183      $LDFLAGS $EXTRA_LDFLAGS $CONFIGURE_LDFLAGS $QEMU_LDFLAGS $local_ldflags
184}
185
186# symbolically link $1 to $2.  Portable version of "ln -sf".
187symlink() {
188  rm -rf "$2"
189  mkdir -p "$(dirname "$2")"
190  ln -s "$1" "$2"
191}
192
193# check whether a command is available to this shell (may be either an
194# executable or a builtin)
195has() {
196    type "$1" >/dev/null 2>&1
197}
198
199version_ge () {
200    local_ver1=$(expr "$1" : '\([0-9.]*\)' | tr . ' ')
201    local_ver2=$(echo "$2" | tr . ' ')
202    while true; do
203        set x $local_ver1
204        local_first=${2-0}
205        # 'shift 2' if $2 is set, or 'shift' if $2 is not set
206        shift ${2:+2}
207        local_ver1=$*
208        set x $local_ver2
209        # the second argument finished, the first must be greater or equal
210        test $# = 1 && return 0
211        test $local_first -lt $2 && return 1
212        test $local_first -gt $2 && return 0
213        shift ${2:+2}
214        local_ver2=$*
215    done
216}
217
218glob() {
219    eval test -z '"${1#'"$2"'}"'
220}
221
222ld_has() {
223    $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
224}
225
226if printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]";
227then
228  error_exit "main directory cannot contain spaces nor colons"
229fi
230
231# default parameters
232cpu=""
233iasl="iasl"
234interp_prefix="/usr/gnemul/qemu-%M"
235static="no"
236cross_compile="no"
237cross_prefix=""
238audio_drv_list="default"
239block_drv_rw_whitelist=""
240block_drv_ro_whitelist=""
241host_cc="cc"
242debug_info="yes"
243lto="false"
244stack_protector=""
245safe_stack=""
246use_containers="yes"
247gdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
248
249if test -e "$source_path/.git"
250then
251    git_submodules_action="update"
252else
253    git_submodules_action="ignore"
254fi
255
256git_submodules="ui/keycodemapdb"
257git="git"
258
259# Don't accept a target_list environment variable.
260unset target_list
261unset target_list_exclude
262
263# Default value for a variable defining feature "foo".
264#  * foo="no"  feature will only be used if --enable-foo arg is given
265#  * foo=""    feature will be searched for, and if found, will be used
266#              unless --disable-foo is given
267#  * foo="yes" this value will only be set by --enable-foo flag.
268#              feature will searched for,
269#              if not found, configure exits with error
270#
271# Always add --enable-foo and --disable-foo command line args.
272# Distributions want to ensure that several features are compiled in, and it
273# is impossible without a --enable-foo that exits if a feature is not found.
274
275default_feature=""
276# parse CC options second
277for opt do
278  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
279  case "$opt" in
280      --without-default-features)
281          default_feature="no"
282  ;;
283  esac
284done
285
286EXTRA_CFLAGS=""
287EXTRA_CXXFLAGS=""
288EXTRA_LDFLAGS=""
289
290xen_ctrl_version="$default_feature"
291vhost_kernel="$default_feature"
292vhost_net="$default_feature"
293vhost_crypto="$default_feature"
294vhost_scsi="$default_feature"
295vhost_vsock="$default_feature"
296vhost_user="no"
297vhost_user_fs="$default_feature"
298vhost_vdpa="$default_feature"
299rdma="$default_feature"
300pvrdma="$default_feature"
301debug_tcg="no"
302debug="no"
303sanitizers="no"
304tsan="no"
305fortify_source="$default_feature"
306gcov="no"
307EXESUF=""
308modules="no"
309module_upgrades="no"
310prefix="/usr/local"
311qemu_suffix="qemu"
312softmmu="yes"
313linux_user=""
314bsd_user=""
315pkgversion=""
316pie=""
317trace_backends="log"
318trace_file="trace"
319opengl="$default_feature"
320coroutine=""
321tls_priority="NORMAL"
322plugins="$default_feature"
323secret_keyring="$default_feature"
324meson=""
325meson_args=""
326ninja=""
327gio="$default_feature"
328skip_meson=no
329
330# The following Meson options are handled manually (still they
331# are included in the automatically generated help message)
332
333# 1. Track which submodules are needed
334capstone="auto"
335fdt="auto"
336slirp="auto"
337
338# 2. Support --with/--without option
339default_devices="true"
340
341# 3. Automatically enable/disable other options
342tcg="enabled"
343cfi="false"
344
345# 4. Detection partly done in configure
346xen=${default_feature:+disabled}
347
348# parse CC options second
349for opt do
350  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
351  case "$opt" in
352  --cross-prefix=*) cross_prefix="$optarg"
353                    cross_compile="yes"
354  ;;
355  --cc=*) CC="$optarg"
356  ;;
357  --cxx=*) CXX="$optarg"
358  ;;
359  --cpu=*) cpu="$optarg"
360  ;;
361  --extra-cflags=*)
362    EXTRA_CFLAGS="$EXTRA_CFLAGS $optarg"
363    EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg"
364    ;;
365  --extra-cxxflags=*) EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg"
366  ;;
367  --extra-ldflags=*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS $optarg"
368  ;;
369  --enable-debug-info) debug_info="yes"
370  ;;
371  --disable-debug-info) debug_info="no"
372  ;;
373  --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
374  ;;
375  --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-cflags-}; cc_arch=${cc_arch%%=*}
376                      eval "cross_cc_cflags_${cc_arch}=\$optarg"
377                      cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}"
378  ;;
379  --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
380                cc_archs="$cc_archs $cc_arch"
381                eval "cross_cc_${cc_arch}=\$optarg"
382                cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}"
383  ;;
384  esac
385done
386# OS specific
387# Using uname is really, really broken.  Once we have the right set of checks
388# we can eliminate its usage altogether.
389
390# Preferred compiler:
391#  ${CC} (if set)
392#  ${cross_prefix}gcc (if cross-prefix specified)
393#  system compiler
394if test -z "${CC}${cross_prefix}"; then
395  cc="$host_cc"
396else
397  cc="${CC-${cross_prefix}gcc}"
398fi
399
400if test -z "${CXX}${cross_prefix}"; then
401  cxx="c++"
402else
403  cxx="${CXX-${cross_prefix}g++}"
404fi
405
406ar="${AR-${cross_prefix}ar}"
407as="${AS-${cross_prefix}as}"
408ccas="${CCAS-$cc}"
409cpp="${CPP-$cc -E}"
410objcopy="${OBJCOPY-${cross_prefix}objcopy}"
411ld="${LD-${cross_prefix}ld}"
412ranlib="${RANLIB-${cross_prefix}ranlib}"
413nm="${NM-${cross_prefix}nm}"
414smbd="$SMBD"
415strip="${STRIP-${cross_prefix}strip}"
416windres="${WINDRES-${cross_prefix}windres}"
417pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
418query_pkg_config() {
419    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
420}
421pkg_config=query_pkg_config
422sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
423
424# default flags for all hosts
425# We use -fwrapv to tell the compiler that we require a C dialect where
426# left shift of signed integers is well defined and has the expected
427# 2s-complement style results. (Both clang and gcc agree that it
428# provides these semantics.)
429QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv"
430QEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
431QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
432QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
433
434QEMU_LDFLAGS=
435
436# Flags that are needed during configure but later taken care of by Meson
437CONFIGURE_CFLAGS="-std=gnu11 -Wall"
438CONFIGURE_LDFLAGS=
439
440
441check_define() {
442cat > $TMPC <<EOF
443#if !defined($1)
444#error $1 not defined
445#endif
446int main(void) { return 0; }
447EOF
448  compile_object
449}
450
451check_include() {
452cat > $TMPC <<EOF
453#include <$1>
454int main(void) { return 0; }
455EOF
456  compile_object
457}
458
459write_c_skeleton() {
460    cat > $TMPC <<EOF
461int main(void) { return 0; }
462EOF
463}
464
465if check_define __linux__ ; then
466  targetos=linux
467elif check_define _WIN32 ; then
468  targetos=windows
469elif check_define __OpenBSD__ ; then
470  targetos=openbsd
471elif check_define __sun__ ; then
472  targetos=sunos
473elif check_define __HAIKU__ ; then
474  targetos=haiku
475elif check_define __FreeBSD__ ; then
476  targetos=freebsd
477elif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
478  targetos=gnu/kfreebsd
479elif check_define __DragonFly__ ; then
480  targetos=dragonfly
481elif check_define __NetBSD__; then
482  targetos=netbsd
483elif check_define __APPLE__; then
484  targetos=darwin
485else
486  # This is a fatal error, but don't report it yet, because we
487  # might be going to just print the --help text, or it might
488  # be the result of a missing compiler.
489  targetos=bogus
490fi
491
492# OS specific
493
494mingw32="no"
495bsd="no"
496linux="no"
497solaris="no"
498case $targetos in
499windows)
500  mingw32="yes"
501  plugins="no"
502  pie="no"
503;;
504gnu/kfreebsd)
505  bsd="yes"
506;;
507freebsd)
508  bsd="yes"
509  make="${MAKE-gmake}"
510  # needed for kinfo_getvmmap(3) in libutil.h
511;;
512dragonfly)
513  bsd="yes"
514  make="${MAKE-gmake}"
515;;
516netbsd)
517  bsd="yes"
518  make="${MAKE-gmake}"
519;;
520openbsd)
521  bsd="yes"
522  make="${MAKE-gmake}"
523;;
524darwin)
525  bsd="yes"
526  darwin="yes"
527  # Disable attempts to use ObjectiveC features in os/object.h since they
528  # won't work when we're compiling with gcc as a C compiler.
529  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
530;;
531sunos)
532  solaris="yes"
533  make="${MAKE-gmake}"
534# needed for CMSG_ macros in sys/socket.h
535  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
536# needed for TIOCWIN* defines in termios.h
537  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
538  # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
539  # Note that this check is broken for cross-compilation: if you're
540  # cross-compiling to one of these OSes then you'll need to specify
541  # the correct CPU with the --cpu option.
542  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
543    cpu="x86_64"
544  fi
545;;
546haiku)
547  pie="no"
548  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE -fPIC $QEMU_CFLAGS"
549;;
550linux)
551  linux="yes"
552  vhost_user=${default_feature:-yes}
553;;
554esac
555
556if test ! -z "$cpu" ; then
557  # command line argument
558  :
559elif check_define __i386__ ; then
560  cpu="i386"
561elif check_define __x86_64__ ; then
562  if check_define __ILP32__ ; then
563    cpu="x32"
564  else
565    cpu="x86_64"
566  fi
567elif check_define __sparc__ ; then
568  if check_define __arch64__ ; then
569    cpu="sparc64"
570  else
571    cpu="sparc"
572  fi
573elif check_define _ARCH_PPC ; then
574  if check_define _ARCH_PPC64 ; then
575    if check_define _LITTLE_ENDIAN ; then
576      cpu="ppc64le"
577    else
578      cpu="ppc64"
579    fi
580  else
581    cpu="ppc"
582  fi
583elif check_define __mips__ ; then
584  cpu="mips"
585elif check_define __s390__ ; then
586  if check_define __s390x__ ; then
587    cpu="s390x"
588  else
589    cpu="s390"
590  fi
591elif check_define __riscv ; then
592  cpu="riscv"
593elif check_define __arm__ ; then
594  cpu="arm"
595elif check_define __aarch64__ ; then
596  cpu="aarch64"
597elif check_define __loongarch64 ; then
598  cpu="loongarch64"
599else
600  cpu=$(uname -m)
601fi
602
603# Normalise host CPU name, set multilib cflags
604# Note that this case should only have supported host CPUs, not guests.
605case "$cpu" in
606  armv*b|armv*l|arm)
607    cpu="arm" ;;
608
609  i386|i486|i586|i686|i86pc|BePC)
610    cpu="i386"
611    CPU_CFLAGS="-m32" ;;
612  x32)
613    cpu="x86_64"
614    CPU_CFLAGS="-mx32" ;;
615  x86_64|amd64)
616    cpu="x86_64"
617    # ??? Only extremely old AMD cpus do not have cmpxchg16b.
618    # If we truly care, we should simply detect this case at
619    # runtime and generate the fallback to serial emulation.
620    CPU_CFLAGS="-m64 -mcx16" ;;
621
622  mips*)
623    cpu="mips" ;;
624
625  ppc)
626    CPU_CFLAGS="-m32" ;;
627  ppc64)
628    CPU_CFLAGS="-m64 -mbig" ;;
629  ppc64le)
630    cpu="ppc64"
631    CPU_CFLAGS="-m64 -mlittle" ;;
632
633  s390)
634    CPU_CFLAGS="-m31" ;;
635  s390x)
636    CPU_CFLAGS="-m64" ;;
637
638  sparc|sun4[cdmuv])
639    cpu="sparc"
640    CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc" ;;
641  sparc64)
642    CPU_CFLAGS="-m64 -mcpu=ultrasparc" ;;
643esac
644
645: ${make=${MAKE-make}}
646
647# We prefer python 3.x. A bare 'python' is traditionally
648# python 2.x, but some distros have it as python 3.x, so
649# we check that too
650python=
651explicit_python=no
652for binary in "${PYTHON-python3}" python
653do
654    if has "$binary"
655    then
656        python=$(command -v "$binary")
657        break
658    fi
659done
660
661
662# Check for ancillary tools used in testing
663genisoimage=
664for binary in genisoimage mkisofs
665do
666    if has $binary
667    then
668        genisoimage=$(command -v "$binary")
669        break
670    fi
671done
672
673# Default objcc to clang if available, otherwise use CC
674if has clang; then
675  objcc=clang
676else
677  objcc="$cc"
678fi
679
680if test "$mingw32" = "yes" ; then
681  EXESUF=".exe"
682  # MinGW needs -mthreads for TLS and macro _MT.
683  CONFIGURE_CFLAGS="-mthreads $CONFIGURE_CFLAGS"
684  write_c_skeleton;
685  prefix="/qemu"
686  qemu_suffix=""
687fi
688
689werror=""
690
691. $source_path/scripts/meson-buildoptions.sh
692
693meson_options=
694meson_option_parse() {
695  meson_options="$meson_options $(_meson_option_parse "$@")"
696  if test $? -eq 1; then
697    echo "ERROR: unknown option $1"
698    echo "Try '$0 --help' for more information"
699    exit 1
700  fi
701}
702
703for opt do
704  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
705  case "$opt" in
706  --help|-h) show_help=yes
707  ;;
708  --version|-V) exec cat $source_path/VERSION
709  ;;
710  --prefix=*) prefix="$optarg"
711  ;;
712  --interp-prefix=*) interp_prefix="$optarg"
713  ;;
714  --cross-prefix=*)
715  ;;
716  --cc=*)
717  ;;
718  --host-cc=*) host_cc="$optarg"
719  ;;
720  --cxx=*)
721  ;;
722  --iasl=*) iasl="$optarg"
723  ;;
724  --objcc=*) objcc="$optarg"
725  ;;
726  --make=*) make="$optarg"
727  ;;
728  --install=*)
729  ;;
730  --python=*) python="$optarg" ; explicit_python=yes
731  ;;
732  --sphinx-build=*) sphinx_build="$optarg"
733  ;;
734  --skip-meson) skip_meson=yes
735  ;;
736  --meson=*) meson="$optarg"
737  ;;
738  --ninja=*) ninja="$optarg"
739  ;;
740  --smbd=*) smbd="$optarg"
741  ;;
742  --extra-cflags=*)
743  ;;
744  --extra-cxxflags=*)
745  ;;
746  --extra-ldflags=*)
747  ;;
748  --enable-debug-info)
749  ;;
750  --disable-debug-info)
751  ;;
752  --cross-cc-*)
753  ;;
754  --enable-modules)
755      modules="yes"
756  ;;
757  --disable-modules)
758      modules="no"
759  ;;
760  --disable-module-upgrades) module_upgrades="no"
761  ;;
762  --enable-module-upgrades) module_upgrades="yes"
763  ;;
764  --cpu=*)
765  ;;
766  --target-list=*) target_list="$optarg"
767                   if test "$target_list_exclude"; then
768                       error_exit "Can't mix --target-list with --target-list-exclude"
769                   fi
770  ;;
771  --target-list-exclude=*) target_list_exclude="$optarg"
772                   if test "$target_list"; then
773                       error_exit "Can't mix --target-list-exclude with --target-list"
774                   fi
775  ;;
776  --with-trace-file=*) trace_file="$optarg"
777  ;;
778  --with-default-devices) default_devices="true"
779  ;;
780  --without-default-devices) default_devices="false"
781  ;;
782  --with-devices-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --with-devices-FOO option"
783  ;;
784  --with-devices-*) device_arch=${opt#--with-devices-};
785                    device_arch=${device_arch%%=*}
786                    cf=$source_path/configs/devices/$device_arch-softmmu/$optarg.mak
787                    if test -f "$cf"; then
788                        device_archs="$device_archs $device_arch"
789                        eval "devices_${device_arch}=\$optarg"
790                    else
791                        error_exit "File $cf does not exist"
792                    fi
793  ;;
794  --without-default-features) # processed above
795  ;;
796  --enable-gcov) gcov="yes"
797  ;;
798  --static)
799    static="yes"
800    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
801  ;;
802  --mandir=*) mandir="$optarg"
803  ;;
804  --bindir=*) bindir="$optarg"
805  ;;
806  --libdir=*) libdir="$optarg"
807  ;;
808  --libexecdir=*) libexecdir="$optarg"
809  ;;
810  --includedir=*) includedir="$optarg"
811  ;;
812  --datadir=*) datadir="$optarg"
813  ;;
814  --with-suffix=*) qemu_suffix="$optarg"
815  ;;
816  --docdir=*) docdir="$optarg"
817  ;;
818  --localedir=*) localedir="$optarg"
819  ;;
820  --sysconfdir=*) sysconfdir="$optarg"
821  ;;
822  --localstatedir=*) local_statedir="$optarg"
823  ;;
824  --firmwarepath=*) firmwarepath="$optarg"
825  ;;
826  --host=*|--build=*|\
827  --disable-dependency-tracking|\
828  --sbindir=*|--sharedstatedir=*|\
829  --oldincludedir=*|--datarootdir=*|--infodir=*|\
830  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
831    # These switches are silently ignored, for compatibility with
832    # autoconf-generated configure scripts. This allows QEMU's
833    # configure to be used by RPM and similar macros that set
834    # lots of directory switches by default.
835  ;;
836  --audio-drv-list=*) audio_drv_list="$optarg"
837  ;;
838  --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
839  ;;
840  --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
841  ;;
842  --enable-debug-tcg) debug_tcg="yes"
843  ;;
844  --disable-debug-tcg) debug_tcg="no"
845  ;;
846  --enable-debug)
847      # Enable debugging options that aren't excessively noisy
848      debug_tcg="yes"
849      meson_option_parse --enable-debug-mutex ""
850      debug="yes"
851      fortify_source="no"
852  ;;
853  --enable-sanitizers) sanitizers="yes"
854  ;;
855  --disable-sanitizers) sanitizers="no"
856  ;;
857  --enable-tsan) tsan="yes"
858  ;;
859  --disable-tsan) tsan="no"
860  ;;
861  --disable-slirp) slirp="disabled"
862  ;;
863  --enable-slirp) slirp="enabled"
864  ;;
865  --enable-slirp=git) slirp="internal"
866  ;;
867  --enable-slirp=*) slirp="$optarg"
868  ;;
869  --disable-xen) xen="disabled"
870  ;;
871  --enable-xen) xen="enabled"
872  ;;
873  --disable-tcg) tcg="disabled"
874                 plugins="no"
875  ;;
876  --enable-tcg) tcg="enabled"
877  ;;
878  --disable-system) softmmu="no"
879  ;;
880  --enable-system) softmmu="yes"
881  ;;
882  --disable-user)
883      linux_user="no" ;
884      bsd_user="no" ;
885  ;;
886  --enable-user) ;;
887  --disable-linux-user) linux_user="no"
888  ;;
889  --enable-linux-user) linux_user="yes"
890  ;;
891  --disable-bsd-user) bsd_user="no"
892  ;;
893  --enable-bsd-user) bsd_user="yes"
894  ;;
895  --enable-pie) pie="yes"
896  ;;
897  --disable-pie) pie="no"
898  ;;
899  --enable-werror) werror="yes"
900  ;;
901  --disable-werror) werror="no"
902  ;;
903  --enable-lto) lto="true"
904  ;;
905  --disable-lto) lto="false"
906  ;;
907  --enable-stack-protector) stack_protector="yes"
908  ;;
909  --disable-stack-protector) stack_protector="no"
910  ;;
911  --enable-safe-stack) safe_stack="yes"
912  ;;
913  --disable-safe-stack) safe_stack="no"
914  ;;
915  --enable-cfi)
916      cfi="true";
917      lto="true";
918  ;;
919  --disable-cfi) cfi="false"
920  ;;
921  --disable-fdt) fdt="disabled"
922  ;;
923  --enable-fdt) fdt="enabled"
924  ;;
925  --enable-fdt=git) fdt="internal"
926  ;;
927  --enable-fdt=*) fdt="$optarg"
928  ;;
929  --with-pkgversion=*) pkgversion="$optarg"
930  ;;
931  --with-coroutine=*) coroutine="$optarg"
932  ;;
933  --disable-vhost-net) vhost_net="no"
934  ;;
935  --enable-vhost-net) vhost_net="yes"
936  ;;
937  --disable-vhost-crypto) vhost_crypto="no"
938  ;;
939  --enable-vhost-crypto) vhost_crypto="yes"
940  ;;
941  --disable-vhost-scsi) vhost_scsi="no"
942  ;;
943  --enable-vhost-scsi) vhost_scsi="yes"
944  ;;
945  --disable-vhost-vsock) vhost_vsock="no"
946  ;;
947  --enable-vhost-vsock) vhost_vsock="yes"
948  ;;
949  --disable-vhost-user-fs) vhost_user_fs="no"
950  ;;
951  --enable-vhost-user-fs) vhost_user_fs="yes"
952  ;;
953  --disable-opengl) opengl="no"
954  ;;
955  --enable-opengl) opengl="yes"
956  ;;
957  --disable-zlib-test)
958  ;;
959  --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
960      echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
961  ;;
962  --enable-vhdx|--disable-vhdx)
963      echo "$0: $opt is obsolete, VHDX driver is always built" >&2
964  ;;
965  --enable-uuid|--disable-uuid)
966      echo "$0: $opt is obsolete, UUID support is always built" >&2
967  ;;
968  --tls-priority=*) tls_priority="$optarg"
969  ;;
970  --enable-rdma) rdma="yes"
971  ;;
972  --disable-rdma) rdma="no"
973  ;;
974  --enable-pvrdma) pvrdma="yes"
975  ;;
976  --disable-pvrdma) pvrdma="no"
977  ;;
978  --disable-vhost-user) vhost_user="no"
979  ;;
980  --enable-vhost-user) vhost_user="yes"
981  ;;
982  --disable-vhost-vdpa) vhost_vdpa="no"
983  ;;
984  --enable-vhost-vdpa) vhost_vdpa="yes"
985  ;;
986  --disable-vhost-kernel) vhost_kernel="no"
987  ;;
988  --enable-vhost-kernel) vhost_kernel="yes"
989  ;;
990  --disable-capstone) capstone="disabled"
991  ;;
992  --enable-capstone) capstone="enabled"
993  ;;
994  --enable-capstone=git) capstone="internal"
995  ;;
996  --enable-capstone=*) capstone="$optarg"
997  ;;
998  --with-git=*) git="$optarg"
999  ;;
1000  --with-git-submodules=*)
1001      git_submodules_action="$optarg"
1002  ;;
1003  --enable-plugins) if test "$mingw32" = "yes"; then
1004                        error_exit "TCG plugins not currently supported on Windows platforms"
1005                    else
1006                        plugins="yes"
1007                    fi
1008  ;;
1009  --disable-plugins) plugins="no"
1010  ;;
1011  --enable-containers) use_containers="yes"
1012  ;;
1013  --disable-containers) use_containers="no"
1014  ;;
1015  --gdb=*) gdb_bin="$optarg"
1016  ;;
1017  --enable-keyring) secret_keyring="yes"
1018  ;;
1019  --disable-keyring) secret_keyring="no"
1020  ;;
1021  --enable-gio) gio=yes
1022  ;;
1023  --disable-gio) gio=no
1024  ;;
1025  # backwards compatibility options
1026  --enable-trace-backend=*) meson_option_parse "--enable-trace-backends=$optarg" "$optarg"
1027  ;;
1028  --disable-blobs) meson_option_parse --disable-install-blobs ""
1029  ;;
1030  --enable-tcmalloc) meson_option_parse --enable-malloc=tcmalloc tcmalloc
1031  ;;
1032  --enable-jemalloc) meson_option_parse --enable-malloc=jemalloc jemalloc
1033  ;;
1034  # everything else has the same name in configure and meson
1035  --enable-* | --disable-*) meson_option_parse "$opt" "$optarg"
1036  ;;
1037  *)
1038      echo "ERROR: unknown option $opt"
1039      echo "Try '$0 --help' for more information"
1040      exit 1
1041  ;;
1042  esac
1043done
1044
1045# test for any invalid configuration combinations
1046if test "$plugins" = "yes" -a "$tcg" = "disabled"; then
1047    error_exit "Can't enable plugins on non-TCG builds"
1048fi
1049
1050case $git_submodules_action in
1051    update|validate)
1052        if test ! -e "$source_path/.git"; then
1053            echo "ERROR: cannot $git_submodules_action git submodules without .git"
1054            exit 1
1055        fi
1056    ;;
1057    ignore)
1058        if ! test -f "$source_path/ui/keycodemapdb/README"
1059        then
1060            echo
1061            echo "ERROR: missing GIT submodules"
1062            echo
1063            if test -e "$source_path/.git"; then
1064                echo "--with-git-submodules=ignore specified but submodules were not"
1065                echo "checked out.  Please initialize and update submodules."
1066            else
1067                echo "This is not a GIT checkout but module content appears to"
1068                echo "be missing. Do not use 'git archive' or GitHub download links"
1069                echo "to acquire QEMU source archives. Non-GIT builds are only"
1070                echo "supported with source archives linked from:"
1071                echo
1072                echo "  https://www.qemu.org/download/#source"
1073                echo
1074                echo "Developers working with GIT can use scripts/archive-source.sh"
1075                echo "if they need to create valid source archives."
1076            fi
1077            echo
1078            exit 1
1079        fi
1080    ;;
1081    *)
1082        echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'"
1083        exit 1
1084    ;;
1085esac
1086
1087libdir="${libdir:-$prefix/lib}"
1088libexecdir="${libexecdir:-$prefix/libexec}"
1089includedir="${includedir:-$prefix/include}"
1090
1091if test "$mingw32" = "yes" ; then
1092    bindir="${bindir:-$prefix}"
1093else
1094    bindir="${bindir:-$prefix/bin}"
1095fi
1096mandir="${mandir:-$prefix/share/man}"
1097datadir="${datadir:-$prefix/share}"
1098docdir="${docdir:-$prefix/share/doc}"
1099sysconfdir="${sysconfdir:-$prefix/etc}"
1100local_statedir="${local_statedir:-$prefix/var}"
1101firmwarepath="${firmwarepath:-$datadir/qemu-firmware}"
1102localedir="${localedir:-$datadir/locale}"
1103
1104if eval test -z "\${cross_cc_$cpu}"; then
1105    eval "cross_cc_${cpu}=\$cc"
1106    cross_cc_vars="$cross_cc_vars cross_cc_${cpu}"
1107fi
1108
1109default_target_list=""
1110mak_wilds=""
1111
1112if [ "$linux_user" != no ]; then
1113    if [ "$targetos" = linux ] && [ -d $source_path/linux-user/include/host/$cpu ]; then
1114        linux_user=yes
1115    elif [ "$linux_user" = yes ]; then
1116        error_exit "linux-user not supported on this architecture"
1117    fi
1118fi
1119if [ "$bsd_user" != no ]; then
1120    if [ "$bsd_user" = "" ]; then
1121        test $targetos = freebsd && bsd_user=yes
1122    fi
1123    if [ "$bsd_user" = yes ] && ! [ -d $source_path/bsd-user/$targetos ]; then
1124        error_exit "bsd-user not supported on this host OS"
1125    fi
1126fi
1127if [ "$softmmu" = "yes" ]; then
1128    mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak"
1129fi
1130if [ "$linux_user" = "yes" ]; then
1131    mak_wilds="${mak_wilds} $source_path/configs/targets/*-linux-user.mak"
1132fi
1133if [ "$bsd_user" = "yes" ]; then
1134    mak_wilds="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak"
1135fi
1136
1137for config in $mak_wilds; do
1138    target="$(basename "$config" .mak)"
1139    if echo "$target_list_exclude" | grep -vq "$target"; then
1140        default_target_list="${default_target_list} $target"
1141    fi
1142done
1143
1144if test x"$show_help" = x"yes" ; then
1145cat << EOF
1146
1147Usage: configure [options]
1148Options: [defaults in brackets after descriptions]
1149
1150Standard options:
1151  --help                   print this message
1152  --prefix=PREFIX          install in PREFIX [$prefix]
1153  --interp-prefix=PREFIX   where to find shared libraries, etc.
1154                           use %M for cpu name [$interp_prefix]
1155  --target-list=LIST       set target list (default: build all)
1156$(echo Available targets: $default_target_list | \
1157  fold -s -w 53 | sed -e 's/^/                           /')
1158  --target-list-exclude=LIST exclude a set of targets from the default target-list
1159
1160Advanced options (experts only):
1161  --cross-prefix=PREFIX    use PREFIX for compile tools, PREFIX can be blank [$cross_prefix]
1162  --cc=CC                  use C compiler CC [$cc]
1163  --iasl=IASL              use ACPI compiler IASL [$iasl]
1164  --host-cc=CC             use C compiler CC [$host_cc] for code run at
1165                           build time
1166  --cxx=CXX                use C++ compiler CXX [$cxx]
1167  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]
1168  --extra-cflags=CFLAGS    append extra C compiler flags CFLAGS
1169  --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS
1170  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
1171  --cross-cc-ARCH=CC       use compiler when building ARCH guest test cases
1172  --cross-cc-cflags-ARCH=  use compiler flags when building ARCH guest tests
1173  --make=MAKE              use specified make [$make]
1174  --python=PYTHON          use specified python [$python]
1175  --sphinx-build=SPHINX    use specified sphinx-build [$sphinx_build]
1176  --meson=MESON            use specified meson [$meson]
1177  --ninja=NINJA            use specified ninja [$ninja]
1178  --smbd=SMBD              use specified smbd [$smbd]
1179  --with-git=GIT           use specified git [$git]
1180  --with-git-submodules=update   update git submodules (default if .git dir exists)
1181  --with-git-submodules=validate fail if git submodules are not up to date
1182  --with-git-submodules=ignore   do not update or check git submodules (default if no .git dir)
1183  --static                 enable static build [$static]
1184  --mandir=PATH            install man pages in PATH
1185  --datadir=PATH           install firmware in PATH/$qemu_suffix
1186  --localedir=PATH         install translation in PATH/$qemu_suffix
1187  --docdir=PATH            install documentation in PATH/$qemu_suffix
1188  --bindir=PATH            install binaries in PATH
1189  --libdir=PATH            install libraries in PATH
1190  --libexecdir=PATH        install helper binaries in PATH
1191  --sysconfdir=PATH        install config in PATH/$qemu_suffix
1192  --localstatedir=PATH     install local state in PATH (set at runtime on win32)
1193  --firmwarepath=PATH      search PATH for firmware files
1194  --efi-aarch64=PATH       PATH of efi file to use for aarch64 VMs.
1195  --with-suffix=SUFFIX     suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix]
1196  --with-pkgversion=VERS   use specified string as sub-version of the package
1197  --without-default-features default all --enable-* options to "disabled"
1198  --without-default-devices  do not include any device that is not needed to
1199                           start the emulator (only use if you are including
1200                           desired devices in configs/devices/)
1201  --with-devices-ARCH=NAME override default configs/devices
1202  --enable-debug           enable common debug build options
1203  --enable-sanitizers      enable default sanitizers
1204  --enable-tsan            enable thread sanitizer
1205  --disable-werror         disable compilation abort on warning
1206  --disable-stack-protector disable compiler-provided stack protection
1207  --audio-drv-list=LIST    set audio drivers to try if -audiodev is not used
1208  --block-drv-whitelist=L  Same as --block-drv-rw-whitelist=L
1209  --block-drv-rw-whitelist=L
1210                           set block driver read-write whitelist
1211                           (by default affects only QEMU, not tools like qemu-img)
1212  --block-drv-ro-whitelist=L
1213                           set block driver read-only whitelist
1214                           (by default affects only QEMU, not tools like qemu-img)
1215  --with-trace-file=NAME   Full PATH,NAME of file to store traces
1216                           Default:trace-<pid>
1217  --cpu=CPU                Build for host CPU [$cpu]
1218  --with-coroutine=BACKEND coroutine backend. Supported options:
1219                           ucontext, sigaltstack, windows
1220  --enable-gcov            enable test coverage analysis with gcov
1221  --tls-priority           default TLS protocol/cipher priority string
1222  --enable-plugins
1223                           enable plugins via shared library loading
1224  --disable-containers     don't use containers for cross-building
1225  --gdb=GDB-path           gdb to use for gdbstub tests [$gdb_bin]
1226EOF
1227  meson_options_help
1228cat << EOF
1229  system          all system emulation targets
1230  user            supported user emulation targets
1231  linux-user      all linux usermode emulation targets
1232  bsd-user        all BSD usermode emulation targets
1233  pie             Position Independent Executables
1234  modules         modules support (non-Windows)
1235  module-upgrades try to load modules from alternate paths for upgrades
1236  debug-tcg       TCG debugging (default is disabled)
1237  debug-info      debugging information
1238  lto             Enable Link-Time Optimization.
1239  safe-stack      SafeStack Stack Smash Protection. Depends on
1240                  clang/llvm >= 3.7 and requires coroutine backend ucontext.
1241  rdma            Enable RDMA-based migration
1242  pvrdma          Enable PVRDMA support
1243  vhost-net       vhost-net kernel acceleration support
1244  vhost-vsock     virtio sockets device support
1245  vhost-scsi      vhost-scsi kernel target support
1246  vhost-crypto    vhost-user-crypto backend support
1247  vhost-kernel    vhost kernel backend support
1248  vhost-user      vhost-user backend support
1249  vhost-vdpa      vhost-vdpa kernel backend support
1250  opengl          opengl support
1251  gio             libgio support
1252
1253NOTE: The object files are built at the place where configure is launched
1254EOF
1255exit 0
1256fi
1257
1258# Remove old dependency files to make sure that they get properly regenerated
1259rm -f */config-devices.mak.d
1260
1261if test -z "$python"
1262then
1263    error_exit "Python not found. Use --python=/path/to/python"
1264fi
1265if ! has "$make"
1266then
1267    error_exit "GNU make ($make) not found"
1268fi
1269
1270# Note that if the Python conditional here evaluates True we will exit
1271# with status 1 which is a shell 'false' value.
1272if ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then
1273  error_exit "Cannot use '$python', Python >= 3.6 is required." \
1274      "Use --python=/path/to/python to specify a supported Python."
1275fi
1276
1277# Preserve python version since some functionality is dependent on it
1278python_version=$($python -c 'import sys; print("%d.%d.%d" % (sys.version_info[0], sys.version_info[1], sys.version_info[2]))' 2>/dev/null)
1279
1280# Suppress writing compiled files
1281python="$python -B"
1282
1283if test -z "$meson"; then
1284    if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.59.3; then
1285        meson=meson
1286    elif test $git_submodules_action != 'ignore' ; then
1287        meson=git
1288    elif test -e "${source_path}/meson/meson.py" ; then
1289        meson=internal
1290    else
1291        if test "$explicit_python" = yes; then
1292            error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found."
1293        else
1294            error_exit "Meson not found.  Use --meson=/path/to/meson"
1295        fi
1296    fi
1297else
1298    # Meson uses its own Python interpreter to invoke other Python scripts,
1299    # but the user wants to use the one they specified with --python.
1300    #
1301    # We do not want to override the distro Python interpreter (and sometimes
1302    # cannot: for example in Homebrew /usr/bin/meson is a bash script), so
1303    # just require --meson=git|internal together with --python.
1304    if test "$explicit_python" = yes; then
1305        case "$meson" in
1306            git | internal) ;;
1307            *) error_exit "--python requires using QEMU's embedded Meson distribution." ;;
1308        esac
1309    fi
1310fi
1311
1312if test "$meson" = git; then
1313    git_submodules="${git_submodules} meson"
1314fi
1315
1316case "$meson" in
1317    git | internal)
1318        meson="$python ${source_path}/meson/meson.py"
1319        ;;
1320    *) meson=$(command -v "$meson") ;;
1321esac
1322
1323# Probe for ninja
1324
1325if test -z "$ninja"; then
1326    for c in ninja ninja-build samu; do
1327        if has $c; then
1328            ninja=$(command -v "$c")
1329            break
1330        fi
1331    done
1332    if test -z "$ninja"; then
1333      error_exit "Cannot find Ninja"
1334    fi
1335fi
1336
1337# Check that the C compiler works. Doing this here before testing
1338# the host CPU ensures that we had a valid CC to autodetect the
1339# $cpu var (and we should bail right here if that's not the case).
1340# It also allows the help message to be printed without a CC.
1341write_c_skeleton;
1342if compile_object ; then
1343  : C compiler works ok
1344else
1345    error_exit "\"$cc\" either does not exist or does not work"
1346fi
1347if ! compile_prog ; then
1348    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
1349fi
1350
1351# Consult white-list to determine whether to enable werror
1352# by default.  Only enable by default for git builds
1353if test -z "$werror" ; then
1354    if test "$git_submodules_action" != "ignore" && \
1355        { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
1356        werror="yes"
1357    else
1358        werror="no"
1359    fi
1360fi
1361
1362if test "$targetos" = "bogus"; then
1363    # Now that we know that we're not printing the help and that
1364    # the compiler works (so the results of the check_defines we used
1365    # to identify the OS are reliable), if we didn't recognize the
1366    # host OS we should stop now.
1367    error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
1368fi
1369
1370# Check whether the compiler matches our minimum requirements:
1371cat > $TMPC << EOF
1372#if defined(__clang_major__) && defined(__clang_minor__)
1373# ifdef __apple_build_version__
1374#  if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0)
1375#   error You need at least XCode Clang v10.0 to compile QEMU
1376#  endif
1377# else
1378#  if __clang_major__ < 6 || (__clang_major__ == 6 && __clang_minor__ < 0)
1379#   error You need at least Clang v6.0 to compile QEMU
1380#  endif
1381# endif
1382#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
1383# if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4)
1384#  error You need at least GCC v7.4.0 to compile QEMU
1385# endif
1386#else
1387# error You either need GCC or Clang to compiler QEMU
1388#endif
1389int main (void) { return 0; }
1390EOF
1391if ! compile_prog "" "" ; then
1392    error_exit "You need at least GCC v7.4 or Clang v6.0 (or XCode Clang v10.0)"
1393fi
1394
1395# Accumulate -Wfoo and -Wno-bar separately.
1396# We will list all of the enable flags first, and the disable flags second.
1397# Note that we do not add -Werror, because that would enable it for all
1398# configure tests. If a configure test failed due to -Werror this would
1399# just silently disable some features, so it's too error prone.
1400
1401warn_flags=
1402add_to warn_flags -Wold-style-declaration
1403add_to warn_flags -Wold-style-definition
1404add_to warn_flags -Wtype-limits
1405add_to warn_flags -Wformat-security
1406add_to warn_flags -Wformat-y2k
1407add_to warn_flags -Winit-self
1408add_to warn_flags -Wignored-qualifiers
1409add_to warn_flags -Wempty-body
1410add_to warn_flags -Wnested-externs
1411add_to warn_flags -Wendif-labels
1412add_to warn_flags -Wexpansion-to-defined
1413add_to warn_flags -Wimplicit-fallthrough=2
1414
1415nowarn_flags=
1416add_to nowarn_flags -Wno-initializer-overrides
1417add_to nowarn_flags -Wno-missing-include-dirs
1418add_to nowarn_flags -Wno-shift-negative-value
1419add_to nowarn_flags -Wno-string-plus-int
1420add_to nowarn_flags -Wno-typedef-redefinition
1421add_to nowarn_flags -Wno-tautological-type-limit-compare
1422add_to nowarn_flags -Wno-psabi
1423
1424gcc_flags="$warn_flags $nowarn_flags"
1425
1426cc_has_warning_flag() {
1427    write_c_skeleton;
1428
1429    # Use the positive sense of the flag when testing for -Wno-wombat
1430    # support (gcc will happily accept the -Wno- form of unknown
1431    # warning options).
1432    optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
1433    compile_prog "-Werror $optflag" ""
1434}
1435
1436for flag in $gcc_flags; do
1437    if cc_has_warning_flag $flag ; then
1438        QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1439    fi
1440done
1441
1442if test "$stack_protector" != "no"; then
1443  cat > $TMPC << EOF
1444int main(int argc, char *argv[])
1445{
1446    char arr[64], *p = arr, *c = argv[0];
1447    while (*c) {
1448        *p++ = *c++;
1449    }
1450    return 0;
1451}
1452EOF
1453  gcc_flags="-fstack-protector-strong -fstack-protector-all"
1454  sp_on=0
1455  for flag in $gcc_flags; do
1456    # We need to check both a compile and a link, since some compiler
1457    # setups fail only on a .c->.o compile and some only at link time
1458    if compile_object "-Werror $flag" &&
1459       compile_prog "-Werror $flag" ""; then
1460      QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1461      QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
1462      sp_on=1
1463      break
1464    fi
1465  done
1466  if test "$stack_protector" = yes; then
1467    if test $sp_on = 0; then
1468      error_exit "Stack protector not supported"
1469    fi
1470  fi
1471fi
1472
1473# Disable -Wmissing-braces on older compilers that warn even for
1474# the "universal" C zero initializer {0}.
1475cat > $TMPC << EOF
1476struct {
1477  int a[2];
1478} x = {0};
1479EOF
1480if compile_object "-Werror" "" ; then
1481  :
1482else
1483  QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
1484fi
1485
1486# Our module code doesn't support Windows
1487if test "$modules" = "yes" && test "$mingw32" = "yes" ; then
1488  error_exit "Modules are not available for Windows"
1489fi
1490
1491# module_upgrades is only reasonable if modules are enabled
1492if test "$modules" = "no" && test "$module_upgrades" = "yes" ; then
1493  error_exit "Can't enable module-upgrades as Modules are not enabled"
1494fi
1495
1496# Static linking is not possible with plugins, modules or PIE
1497if test "$static" = "yes" ; then
1498  if test "$modules" = "yes" ; then
1499    error_exit "static and modules are mutually incompatible"
1500  fi
1501  if test "$plugins" = "yes"; then
1502    error_exit "static and plugins are mutually incompatible"
1503  else
1504    plugins="no"
1505  fi
1506fi
1507test "$plugins" = "" && plugins=yes
1508
1509cat > $TMPC << EOF
1510
1511#ifdef __linux__
1512#  define THREAD __thread
1513#else
1514#  define THREAD
1515#endif
1516static THREAD int tls_var;
1517int main(void) { return tls_var; }
1518EOF
1519
1520# Check we support -fno-pie and -no-pie first; we will need the former for
1521# building ROMs, and both for everything if --disable-pie is passed.
1522if compile_prog "-Werror -fno-pie" "-no-pie"; then
1523  CFLAGS_NOPIE="-fno-pie"
1524  LDFLAGS_NOPIE="-no-pie"
1525fi
1526
1527if test "$static" = "yes"; then
1528  if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then
1529    CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
1530    QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS"
1531    pie="yes"
1532  elif test "$pie" = "yes"; then
1533    error_exit "-static-pie not available due to missing toolchain support"
1534  else
1535    QEMU_LDFLAGS="-static $QEMU_LDFLAGS"
1536    pie="no"
1537  fi
1538elif test "$pie" = "no"; then
1539  CONFIGURE_CFLAGS="$CFLAGS_NOPIE $CONFIGURE_CFLAGS"
1540  CONFIGURE_LDFLAGS="$LDFLAGS_NOPIE $CONFIGURE_LDFLAGS"
1541elif compile_prog "-Werror -fPIE -DPIE" "-pie"; then
1542  CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
1543  CONFIGURE_LDFLAGS="-pie $CONFIGURE_LDFLAGS"
1544  pie="yes"
1545elif test "$pie" = "yes"; then
1546  error_exit "PIE not available due to missing toolchain support"
1547else
1548  echo "Disabling PIE due to missing toolchain support"
1549  pie="no"
1550fi
1551
1552# Detect support for PT_GNU_RELRO + DT_BIND_NOW.
1553# The combination is known as "full relro", because .got.plt is read-only too.
1554if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
1555  QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS"
1556fi
1557
1558##########################################
1559# __sync_fetch_and_and requires at least -march=i486. Many toolchains
1560# use i686 as default anyway, but for those that don't, an explicit
1561# specification is necessary
1562
1563if test "$cpu" = "i386"; then
1564  cat > $TMPC << EOF
1565static int sfaa(int *ptr)
1566{
1567  return __sync_fetch_and_and(ptr, 0);
1568}
1569
1570int main(void)
1571{
1572  int val = 42;
1573  val = __sync_val_compare_and_swap(&val, 0, 1);
1574  sfaa(&val);
1575  return val;
1576}
1577EOF
1578  if ! compile_prog "" "" ; then
1579    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
1580  fi
1581fi
1582
1583if test "$tcg" = "enabled"; then
1584    git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
1585    git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
1586fi
1587
1588if test -z "${target_list+xxx}" ; then
1589    default_targets=yes
1590    for target in $default_target_list; do
1591        target_list="$target_list $target"
1592    done
1593    target_list="${target_list# }"
1594else
1595    default_targets=no
1596    target_list=$(echo "$target_list" | sed -e 's/,/ /g')
1597    for target in $target_list; do
1598        # Check that we recognised the target name; this allows a more
1599        # friendly error message than if we let it fall through.
1600        case " $default_target_list " in
1601            *" $target "*)
1602                ;;
1603            *)
1604                error_exit "Unknown target name '$target'"
1605                ;;
1606        esac
1607    done
1608fi
1609
1610# see if system emulation was really requested
1611case " $target_list " in
1612  *"-softmmu "*) softmmu=yes
1613  ;;
1614  *) softmmu=no
1615  ;;
1616esac
1617
1618feature_not_found() {
1619  feature=$1
1620  remedy=$2
1621
1622  error_exit "User requested feature $feature" \
1623      "configure was not able to find it." \
1624      "$remedy"
1625}
1626
1627# ---
1628# big/little endian test
1629cat > $TMPC << EOF
1630#include <stdio.h>
1631short big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
1632short little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
1633int main(int argc, char *argv[])
1634{
1635    return printf("%s %s\n", (char *)big_endian, (char *)little_endian);
1636}
1637EOF
1638
1639if compile_prog ; then
1640    if strings -a $TMPE | grep -q BiGeNdIaN ; then
1641        bigendian="yes"
1642    elif strings -a $TMPE | grep -q LiTtLeEnDiAn ; then
1643        bigendian="no"
1644    else
1645        echo big/little test failed
1646        exit 1
1647    fi
1648else
1649    echo big/little test failed
1650    exit 1
1651fi
1652
1653#########################################
1654# vhost interdependencies and host support
1655
1656# vhost backends
1657if test "$vhost_user" = "yes" && test "$linux" != "yes"; then
1658  error_exit "vhost-user is only available on Linux"
1659fi
1660test "$vhost_vdpa" = "" && vhost_vdpa=$linux
1661if test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then
1662  error_exit "vhost-vdpa is only available on Linux"
1663fi
1664test "$vhost_kernel" = "" && vhost_kernel=$linux
1665if test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then
1666  error_exit "vhost-kernel is only available on Linux"
1667fi
1668
1669# vhost-kernel devices
1670test "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel
1671if test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then
1672  error_exit "--enable-vhost-scsi requires --enable-vhost-kernel"
1673fi
1674test "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel
1675if test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then
1676  error_exit "--enable-vhost-vsock requires --enable-vhost-kernel"
1677fi
1678
1679# vhost-user backends
1680test "$vhost_net_user" = "" && vhost_net_user=$vhost_user
1681if test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then
1682  error_exit "--enable-vhost-net-user requires --enable-vhost-user"
1683fi
1684test "$vhost_crypto" = "" && vhost_crypto=$vhost_user
1685if test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then
1686  error_exit "--enable-vhost-crypto requires --enable-vhost-user"
1687fi
1688test "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user
1689if test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then
1690  error_exit "--enable-vhost-user-fs requires --enable-vhost-user"
1691fi
1692#vhost-vdpa backends
1693test "$vhost_net_vdpa" = "" && vhost_net_vdpa=$vhost_vdpa
1694if test "$vhost_net_vdpa" = "yes" && test "$vhost_vdpa" = "no"; then
1695  error_exit "--enable-vhost-net-vdpa requires --enable-vhost-vdpa"
1696fi
1697
1698# OR the vhost-kernel, vhost-vdpa and vhost-user values for simplicity
1699if test "$vhost_net" = ""; then
1700  test "$vhost_net_user" = "yes" && vhost_net=yes
1701  test "$vhost_net_vdpa" = "yes" && vhost_net=yes
1702  test "$vhost_kernel" = "yes" && vhost_net=yes
1703fi
1704
1705##########################################
1706# pkg-config probe
1707
1708if ! has "$pkg_config_exe"; then
1709  error_exit "pkg-config binary '$pkg_config_exe' not found"
1710fi
1711
1712##########################################
1713# xen probe
1714
1715if test "$xen" != "disabled" ; then
1716  # Check whether Xen library path is specified via --extra-ldflags to avoid
1717  # overriding this setting with pkg-config output. If not, try pkg-config
1718  # to obtain all needed flags.
1719
1720  if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
1721     $pkg_config --exists xencontrol ; then
1722    xen_ctrl_version="$(printf '%d%02d%02d' \
1723      $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
1724    xen=enabled
1725    xen_pc="xencontrol xenstore xenforeignmemory xengnttab"
1726    xen_pc="$xen_pc xenevtchn xendevicemodel"
1727    if $pkg_config --exists xentoolcore; then
1728      xen_pc="$xen_pc xentoolcore"
1729    fi
1730    xen_cflags="$($pkg_config --cflags $xen_pc)"
1731    xen_libs="$($pkg_config --libs $xen_pc)"
1732  else
1733
1734    xen_libs="-lxenstore -lxenctrl"
1735    xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
1736
1737    # First we test whether Xen headers and libraries are available.
1738    # If no, we are done and there is no Xen support.
1739    # If yes, more tests are run to detect the Xen version.
1740
1741    # Xen (any)
1742    cat > $TMPC <<EOF
1743#include <xenctrl.h>
1744int main(void) {
1745  return 0;
1746}
1747EOF
1748    if ! compile_prog "" "$xen_libs" ; then
1749      # Xen not found
1750      if test "$xen" = "enabled" ; then
1751        feature_not_found "xen" "Install xen devel"
1752      fi
1753      xen=disabled
1754
1755    # Xen unstable
1756    elif
1757        cat > $TMPC <<EOF &&
1758#undef XC_WANT_COMPAT_DEVICEMODEL_API
1759#define __XEN_TOOLS__
1760#include <xendevicemodel.h>
1761#include <xenforeignmemory.h>
1762int main(void) {
1763  xendevicemodel_handle *xd;
1764  xenforeignmemory_handle *xfmem;
1765
1766  xd = xendevicemodel_open(0, 0);
1767  xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
1768
1769  xfmem = xenforeignmemory_open(0, 0);
1770  xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
1771
1772  return 0;
1773}
1774EOF
1775        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
1776      then
1777      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
1778      xen_ctrl_version=41100
1779      xen=enabled
1780    elif
1781        cat > $TMPC <<EOF &&
1782#undef XC_WANT_COMPAT_MAP_FOREIGN_API
1783#include <xenforeignmemory.h>
1784#include <xentoolcore.h>
1785int main(void) {
1786  xenforeignmemory_handle *xfmem;
1787
1788  xfmem = xenforeignmemory_open(0, 0);
1789  xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
1790  xentoolcore_restrict_all(0);
1791
1792  return 0;
1793}
1794EOF
1795        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
1796      then
1797      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
1798      xen_ctrl_version=41000
1799      xen=enabled
1800    elif
1801        cat > $TMPC <<EOF &&
1802#undef XC_WANT_COMPAT_DEVICEMODEL_API
1803#define __XEN_TOOLS__
1804#include <xendevicemodel.h>
1805int main(void) {
1806  xendevicemodel_handle *xd;
1807
1808  xd = xendevicemodel_open(0, 0);
1809  xendevicemodel_close(xd);
1810
1811  return 0;
1812}
1813EOF
1814        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
1815      then
1816      xen_stable_libs="-lxendevicemodel $xen_stable_libs"
1817      xen_ctrl_version=40900
1818      xen=enabled
1819    elif
1820        cat > $TMPC <<EOF &&
1821/*
1822 * If we have stable libs the we don't want the libxc compat
1823 * layers, regardless of what CFLAGS we may have been given.
1824 *
1825 * Also, check if xengnttab_grant_copy_segment_t is defined and
1826 * grant copy operation is implemented.
1827 */
1828#undef XC_WANT_COMPAT_EVTCHN_API
1829#undef XC_WANT_COMPAT_GNTTAB_API
1830#undef XC_WANT_COMPAT_MAP_FOREIGN_API
1831#include <xenctrl.h>
1832#include <xenstore.h>
1833#include <xenevtchn.h>
1834#include <xengnttab.h>
1835#include <xenforeignmemory.h>
1836#include <stdint.h>
1837#include <xen/hvm/hvm_info_table.h>
1838#if !defined(HVM_MAX_VCPUS)
1839# error HVM_MAX_VCPUS not defined
1840#endif
1841int main(void) {
1842  xc_interface *xc = NULL;
1843  xenforeignmemory_handle *xfmem;
1844  xenevtchn_handle *xe;
1845  xengnttab_handle *xg;
1846  xengnttab_grant_copy_segment_t* seg = NULL;
1847
1848  xs_daemon_open();
1849
1850  xc = xc_interface_open(0, 0, 0);
1851  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1852  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1853  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
1854  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
1855
1856  xfmem = xenforeignmemory_open(0, 0);
1857  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
1858
1859  xe = xenevtchn_open(0, 0);
1860  xenevtchn_fd(xe);
1861
1862  xg = xengnttab_open(0, 0);
1863  xengnttab_grant_copy(xg, 0, seg);
1864
1865  return 0;
1866}
1867EOF
1868        compile_prog "" "$xen_libs $xen_stable_libs"
1869      then
1870      xen_ctrl_version=40800
1871      xen=enabled
1872    elif
1873        cat > $TMPC <<EOF &&
1874/*
1875 * If we have stable libs the we don't want the libxc compat
1876 * layers, regardless of what CFLAGS we may have been given.
1877 */
1878#undef XC_WANT_COMPAT_EVTCHN_API
1879#undef XC_WANT_COMPAT_GNTTAB_API
1880#undef XC_WANT_COMPAT_MAP_FOREIGN_API
1881#include <xenctrl.h>
1882#include <xenstore.h>
1883#include <xenevtchn.h>
1884#include <xengnttab.h>
1885#include <xenforeignmemory.h>
1886#include <stdint.h>
1887#include <xen/hvm/hvm_info_table.h>
1888#if !defined(HVM_MAX_VCPUS)
1889# error HVM_MAX_VCPUS not defined
1890#endif
1891int main(void) {
1892  xc_interface *xc = NULL;
1893  xenforeignmemory_handle *xfmem;
1894  xenevtchn_handle *xe;
1895  xengnttab_handle *xg;
1896
1897  xs_daemon_open();
1898
1899  xc = xc_interface_open(0, 0, 0);
1900  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1901  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1902  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
1903  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
1904
1905  xfmem = xenforeignmemory_open(0, 0);
1906  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
1907
1908  xe = xenevtchn_open(0, 0);
1909  xenevtchn_fd(xe);
1910
1911  xg = xengnttab_open(0, 0);
1912  xengnttab_map_grant_ref(xg, 0, 0, 0);
1913
1914  return 0;
1915}
1916EOF
1917        compile_prog "" "$xen_libs $xen_stable_libs"
1918      then
1919      xen_ctrl_version=40701
1920      xen=enabled
1921
1922    # Xen 4.6
1923    elif
1924        cat > $TMPC <<EOF &&
1925#include <xenctrl.h>
1926#include <xenstore.h>
1927#include <stdint.h>
1928#include <xen/hvm/hvm_info_table.h>
1929#if !defined(HVM_MAX_VCPUS)
1930# error HVM_MAX_VCPUS not defined
1931#endif
1932int main(void) {
1933  xc_interface *xc;
1934  xs_daemon_open();
1935  xc = xc_interface_open(0, 0, 0);
1936  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1937  xc_gnttab_open(NULL, 0);
1938  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1939  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
1940  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
1941  xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
1942  return 0;
1943}
1944EOF
1945        compile_prog "" "$xen_libs"
1946      then
1947      xen_ctrl_version=40600
1948      xen=enabled
1949
1950    # Xen 4.5
1951    elif
1952        cat > $TMPC <<EOF &&
1953#include <xenctrl.h>
1954#include <xenstore.h>
1955#include <stdint.h>
1956#include <xen/hvm/hvm_info_table.h>
1957#if !defined(HVM_MAX_VCPUS)
1958# error HVM_MAX_VCPUS not defined
1959#endif
1960int main(void) {
1961  xc_interface *xc;
1962  xs_daemon_open();
1963  xc = xc_interface_open(0, 0, 0);
1964  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1965  xc_gnttab_open(NULL, 0);
1966  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1967  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
1968  xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
1969  return 0;
1970}
1971EOF
1972        compile_prog "" "$xen_libs"
1973      then
1974      xen_ctrl_version=40500
1975      xen=enabled
1976
1977    elif
1978        cat > $TMPC <<EOF &&
1979#include <xenctrl.h>
1980#include <xenstore.h>
1981#include <stdint.h>
1982#include <xen/hvm/hvm_info_table.h>
1983#if !defined(HVM_MAX_VCPUS)
1984# error HVM_MAX_VCPUS not defined
1985#endif
1986int main(void) {
1987  xc_interface *xc;
1988  xs_daemon_open();
1989  xc = xc_interface_open(0, 0, 0);
1990  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1991  xc_gnttab_open(NULL, 0);
1992  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1993  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
1994  return 0;
1995}
1996EOF
1997        compile_prog "" "$xen_libs"
1998      then
1999      xen_ctrl_version=40200
2000      xen=enabled
2001
2002    else
2003      if test "$xen" = "enabled" ; then
2004        feature_not_found "xen (unsupported version)" \
2005                          "Install a supported xen (xen 4.2 or newer)"
2006      fi
2007      xen=disabled
2008    fi
2009
2010    if test "$xen" = enabled; then
2011      if test $xen_ctrl_version -ge 40701  ; then
2012        xen_libs="$xen_libs $xen_stable_libs "
2013      fi
2014    fi
2015  fi
2016fi
2017
2018##########################################
2019# RDMA needs OpenFabrics libraries
2020if test "$rdma" != "no" ; then
2021  cat > $TMPC <<EOF
2022#include <rdma/rdma_cma.h>
2023int main(void) { return 0; }
2024EOF
2025  rdma_libs="-lrdmacm -libverbs -libumad"
2026  if compile_prog "" "$rdma_libs" ; then
2027    rdma="yes"
2028  else
2029    if test "$rdma" = "yes" ; then
2030        error_exit \
2031            " OpenFabrics librdmacm/libibverbs/libibumad not present." \
2032            " Your options:" \
2033            "  (1) Fast: Install infiniband packages (devel) from your distro." \
2034            "  (2) Cleanest: Install libraries from www.openfabrics.org" \
2035            "  (3) Also: Install softiwarp if you don't have RDMA hardware"
2036    fi
2037    rdma="no"
2038  fi
2039fi
2040
2041##########################################
2042# PVRDMA detection
2043
2044cat > $TMPC <<EOF &&
2045#include <sys/mman.h>
2046
2047int
2048main(void)
2049{
2050    char buf = 0;
2051    void *addr = &buf;
2052    addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED);
2053
2054    return 0;
2055}
2056EOF
2057
2058if test "$rdma" = "yes" ; then
2059    case "$pvrdma" in
2060    "")
2061        if compile_prog "" ""; then
2062            pvrdma="yes"
2063        else
2064            pvrdma="no"
2065        fi
2066        ;;
2067    "yes")
2068        if ! compile_prog "" ""; then
2069            error_exit "PVRDMA is not supported since mremap is not implemented"
2070        fi
2071        pvrdma="yes"
2072        ;;
2073    "no")
2074        pvrdma="no"
2075        ;;
2076    esac
2077else
2078    if test "$pvrdma" = "yes" ; then
2079        error_exit "PVRDMA requires rdma suppport"
2080    fi
2081    pvrdma="no"
2082fi
2083
2084# Let's see if enhanced reg_mr is supported
2085if test "$pvrdma" = "yes" ; then
2086
2087cat > $TMPC <<EOF &&
2088#include <infiniband/verbs.h>
2089
2090int
2091main(void)
2092{
2093    struct ibv_mr *mr;
2094    struct ibv_pd *pd = NULL;
2095    size_t length = 10;
2096    uint64_t iova = 0;
2097    int access = 0;
2098    void *addr = NULL;
2099
2100    mr = ibv_reg_mr_iova(pd, addr, length, iova, access);
2101
2102    ibv_dereg_mr(mr);
2103
2104    return 0;
2105}
2106EOF
2107    if ! compile_prog "" "-libverbs"; then
2108        QEMU_CFLAGS="$QEMU_CFLAGS -DLEGACY_RDMA_REG_MR"
2109    fi
2110fi
2111
2112##########################################
2113# glib support probe
2114
2115glib_req_ver=2.56
2116glib_modules=gthread-2.0
2117if test "$modules" = yes; then
2118    glib_modules="$glib_modules gmodule-export-2.0"
2119elif test "$plugins" = "yes"; then
2120    glib_modules="$glib_modules gmodule-no-export-2.0"
2121fi
2122
2123for i in $glib_modules; do
2124    if $pkg_config --atleast-version=$glib_req_ver $i; then
2125        glib_cflags=$($pkg_config --cflags $i)
2126        glib_libs=$($pkg_config --libs $i)
2127    else
2128        error_exit "glib-$glib_req_ver $i is required to compile QEMU"
2129    fi
2130done
2131
2132# This workaround is required due to a bug in pkg-config file for glib as it
2133# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
2134
2135if test "$static" = yes && test "$mingw32" = yes; then
2136    glib_cflags="-DGLIB_STATIC_COMPILATION $glib_cflags"
2137fi
2138
2139if ! test "$gio" = "no"; then
2140    pass=no
2141    if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
2142        gio_cflags=$($pkg_config --cflags gio-2.0)
2143        gio_libs=$($pkg_config --libs gio-2.0)
2144        gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0)
2145        if ! has "$gdbus_codegen"; then
2146            gdbus_codegen=
2147        fi
2148        # Check that the libraries actually work -- Ubuntu 18.04 ships
2149        # with pkg-config --static --libs data for gio-2.0 that is missing
2150        # -lblkid and will give a link error.
2151        cat > $TMPC <<EOF
2152#include <gio/gio.h>
2153int main(void)
2154{
2155    g_dbus_proxy_new_sync(0, 0, 0, 0, 0, 0, 0, 0);
2156    return 0;
2157}
2158EOF
2159        if compile_prog "$gio_cflags" "$gio_libs" ; then
2160            pass=yes
2161        else
2162            pass=no
2163        fi
2164
2165        if test "$pass" = "yes" &&
2166            $pkg_config --atleast-version=$glib_req_ver gio-unix-2.0; then
2167            gio_cflags="$gio_cflags $($pkg_config --cflags gio-unix-2.0)"
2168            gio_libs="$gio_libs $($pkg_config --libs gio-unix-2.0)"
2169        fi
2170    fi
2171
2172    if test "$pass" = "no"; then
2173        if test "$gio" = "yes"; then
2174            feature_not_found "gio" "Install libgio >= 2.0"
2175        else
2176            gio=no
2177        fi
2178    else
2179        gio=yes
2180    fi
2181fi
2182
2183# Sanity check that the current size_t matches the
2184# size that glib thinks it should be. This catches
2185# problems on multi-arch where people try to build
2186# 32-bit QEMU while pointing at 64-bit glib headers
2187cat > $TMPC <<EOF
2188#include <glib.h>
2189#include <unistd.h>
2190
2191#define QEMU_BUILD_BUG_ON(x) \
2192  typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
2193
2194int main(void) {
2195   QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
2196   return 0;
2197}
2198EOF
2199
2200if ! compile_prog "$glib_cflags" "$glib_libs" ; then
2201    error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
2202               "You probably need to set PKG_CONFIG_LIBDIR"\
2203	       "to point to the right pkg-config files for your"\
2204	       "build target"
2205fi
2206
2207# Silence clang warnings triggered by glib < 2.57.2
2208cat > $TMPC << EOF
2209#include <glib.h>
2210typedef struct Foo {
2211    int i;
2212} Foo;
2213static void foo_free(Foo *f)
2214{
2215    g_free(f);
2216}
2217G_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free);
2218int main(void) { return 0; }
2219EOF
2220if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
2221    if cc_has_warning_flag "-Wno-unused-function"; then
2222        glib_cflags="$glib_cflags -Wno-unused-function"
2223        CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -Wno-unused-function"
2224    fi
2225fi
2226
2227##########################################
2228# SHA command probe for modules
2229if test "$modules" = yes; then
2230    shacmd_probe="sha1sum sha1 shasum"
2231    for c in $shacmd_probe; do
2232        if has $c; then
2233            shacmd="$c"
2234            break
2235        fi
2236    done
2237    if test "$shacmd" = ""; then
2238        error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
2239    fi
2240fi
2241
2242##########################################
2243# fdt probe
2244
2245case "$fdt" in
2246  auto | enabled | internal)
2247    # Simpler to always update submodule, even if not needed.
2248    git_submodules="${git_submodules} dtc"
2249    ;;
2250esac
2251
2252##########################################
2253# opengl probe (for sdl2, gtk)
2254
2255if test "$opengl" != "no" ; then
2256  epoxy=no
2257  if $pkg_config epoxy; then
2258    cat > $TMPC << EOF
2259#include <epoxy/egl.h>
2260int main(void) { return 0; }
2261EOF
2262    if compile_prog "" "" ; then
2263      epoxy=yes
2264    fi
2265  fi
2266
2267  if test "$epoxy" = "yes" ; then
2268    opengl_cflags="$($pkg_config --cflags epoxy)"
2269    opengl_libs="$($pkg_config --libs epoxy)"
2270    opengl=yes
2271  else
2272    if test "$opengl" = "yes" ; then
2273      feature_not_found "opengl" "Please install epoxy with EGL"
2274    fi
2275    opengl_cflags=""
2276    opengl_libs=""
2277    opengl=no
2278  fi
2279fi
2280
2281# check for usbfs
2282have_usbfs=no
2283if test "$linux_user" = "yes"; then
2284  cat > $TMPC << EOF
2285#include <linux/usbdevice_fs.h>
2286
2287#ifndef USBDEVFS_GET_CAPABILITIES
2288#error "USBDEVFS_GET_CAPABILITIES undefined"
2289#endif
2290
2291#ifndef USBDEVFS_DISCONNECT_CLAIM
2292#error "USBDEVFS_DISCONNECT_CLAIM undefined"
2293#endif
2294
2295int main(void)
2296{
2297    return 0;
2298}
2299EOF
2300  if compile_prog "" ""; then
2301    have_usbfs=yes
2302  fi
2303fi
2304
2305##########################################
2306# capstone
2307
2308case "$capstone" in
2309  auto | enabled | internal)
2310    # Simpler to always update submodule, even if not needed.
2311    git_submodules="${git_submodules} capstone"
2312    ;;
2313esac
2314
2315##########################################
2316# check and set a backend for coroutine
2317
2318# We prefer ucontext, but it's not always possible. The fallback
2319# is sigcontext. On Windows the only valid backend is the Windows
2320# specific one.
2321
2322ucontext_works=no
2323if test "$darwin" != "yes"; then
2324  cat > $TMPC << EOF
2325#include <ucontext.h>
2326#ifdef __stub_makecontext
2327#error Ignoring glibc stub makecontext which will always fail
2328#endif
2329int main(void) { makecontext(0, 0, 0); return 0; }
2330EOF
2331  if compile_prog "" "" ; then
2332    ucontext_works=yes
2333  fi
2334fi
2335
2336if test "$coroutine" = ""; then
2337  if test "$mingw32" = "yes"; then
2338    coroutine=win32
2339  elif test "$ucontext_works" = "yes"; then
2340    coroutine=ucontext
2341  else
2342    coroutine=sigaltstack
2343  fi
2344else
2345  case $coroutine in
2346  windows)
2347    if test "$mingw32" != "yes"; then
2348      error_exit "'windows' coroutine backend only valid for Windows"
2349    fi
2350    # Unfortunately the user visible backend name doesn't match the
2351    # coroutine-*.c filename for this case, so we have to adjust it here.
2352    coroutine=win32
2353    ;;
2354  ucontext)
2355    if test "$ucontext_works" != "yes"; then
2356      feature_not_found "ucontext"
2357    fi
2358    ;;
2359  sigaltstack)
2360    if test "$mingw32" = "yes"; then
2361      error_exit "only the 'windows' coroutine backend is valid for Windows"
2362    fi
2363    ;;
2364  *)
2365    error_exit "unknown coroutine backend $coroutine"
2366    ;;
2367  esac
2368fi
2369
2370##################################################
2371# SafeStack
2372
2373
2374if test "$safe_stack" = "yes"; then
2375cat > $TMPC << EOF
2376int main(int argc, char *argv[])
2377{
2378#if ! __has_feature(safe_stack)
2379#error SafeStack Disabled
2380#endif
2381    return 0;
2382}
2383EOF
2384  flag="-fsanitize=safe-stack"
2385  # Check that safe-stack is supported and enabled.
2386  if compile_prog "-Werror $flag" "$flag"; then
2387    # Flag needed both at compilation and at linking
2388    QEMU_CFLAGS="$QEMU_CFLAGS $flag"
2389    QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
2390  else
2391    error_exit "SafeStack not supported by your compiler"
2392  fi
2393  if test "$coroutine" != "ucontext"; then
2394    error_exit "SafeStack is only supported by the coroutine backend ucontext"
2395  fi
2396else
2397cat > $TMPC << EOF
2398int main(int argc, char *argv[])
2399{
2400#if defined(__has_feature)
2401#if __has_feature(safe_stack)
2402#error SafeStack Enabled
2403#endif
2404#endif
2405    return 0;
2406}
2407EOF
2408if test "$safe_stack" = "no"; then
2409  # Make sure that safe-stack is disabled
2410  if ! compile_prog "-Werror" ""; then
2411    # SafeStack was already enabled, try to explicitly remove the feature
2412    flag="-fno-sanitize=safe-stack"
2413    if ! compile_prog "-Werror $flag" "$flag"; then
2414      error_exit "Configure cannot disable SafeStack"
2415    fi
2416    QEMU_CFLAGS="$QEMU_CFLAGS $flag"
2417    QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
2418  fi
2419else # "$safe_stack" = ""
2420  # Set safe_stack to yes or no based on pre-existing flags
2421  if compile_prog "-Werror" ""; then
2422    safe_stack="no"
2423  else
2424    safe_stack="yes"
2425    if test "$coroutine" != "ucontext"; then
2426      error_exit "SafeStack is only supported by the coroutine backend ucontext"
2427    fi
2428  fi
2429fi
2430fi
2431
2432########################################
2433# check if __[u]int128_t is usable.
2434
2435int128=no
2436cat > $TMPC << EOF
2437__int128_t a;
2438__uint128_t b;
2439int main (void) {
2440  a = a + b;
2441  b = a * b;
2442  a = a * a;
2443  return 0;
2444}
2445EOF
2446if compile_prog "" "" ; then
2447    int128=yes
2448fi
2449
2450#########################################
2451# See if 128-bit atomic operations are supported.
2452
2453atomic128=no
2454if test "$int128" = "yes"; then
2455  cat > $TMPC << EOF
2456int main(void)
2457{
2458  unsigned __int128 x = 0, y = 0;
2459  y = __atomic_load(&x, 0);
2460  __atomic_store(&x, y, 0);
2461  __atomic_compare_exchange(&x, &y, x, 0, 0, 0);
2462  return 0;
2463}
2464EOF
2465  if compile_prog "" "" ; then
2466    atomic128=yes
2467  fi
2468fi
2469
2470cmpxchg128=no
2471if test "$int128" = yes && test "$atomic128" = no; then
2472  cat > $TMPC << EOF
2473int main(void)
2474{
2475  unsigned __int128 x = 0, y = 0;
2476  __sync_val_compare_and_swap_16(&x, y, x);
2477  return 0;
2478}
2479EOF
2480  if compile_prog "" "" ; then
2481    cmpxchg128=yes
2482  fi
2483fi
2484
2485########################################
2486# check if ccache is interfering with
2487# semantic analysis of macros
2488
2489unset CCACHE_CPP2
2490ccache_cpp2=no
2491cat > $TMPC << EOF
2492static const int Z = 1;
2493#define fn() ({ Z; })
2494#define TAUT(X) ((X) == Z)
2495#define PAREN(X, Y) (X == Y)
2496#define ID(X) (X)
2497int main(int argc, char *argv[])
2498{
2499    int x = 0, y = 0;
2500    x = ID(x);
2501    x = fn();
2502    fn();
2503    if (PAREN(x, y)) return 0;
2504    if (TAUT(Z)) return 0;
2505    return 0;
2506}
2507EOF
2508
2509if ! compile_object "-Werror"; then
2510    ccache_cpp2=yes
2511fi
2512
2513#################################################
2514# clang does not support glibc + FORTIFY_SOURCE.
2515
2516if test "$fortify_source" != "no"; then
2517  if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
2518    fortify_source="no";
2519  elif test -n "$cxx" && has $cxx &&
2520       echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
2521    fortify_source="no";
2522  else
2523    fortify_source="yes"
2524  fi
2525fi
2526
2527##########################################
2528# checks for sanitizers
2529
2530have_asan=no
2531have_ubsan=no
2532have_asan_iface_h=no
2533have_asan_iface_fiber=no
2534
2535if test "$sanitizers" = "yes" ; then
2536  write_c_skeleton
2537  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
2538      have_asan=yes
2539  fi
2540
2541  # we could use a simple skeleton for flags checks, but this also
2542  # detect the static linking issue of ubsan, see also:
2543  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
2544  cat > $TMPC << EOF
2545#include <stdlib.h>
2546int main(void) {
2547    void *tmp = malloc(10);
2548    if (tmp != NULL) {
2549        return *(int *)(tmp + 2);
2550    }
2551    return 1;
2552}
2553EOF
2554  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
2555      have_ubsan=yes
2556  fi
2557
2558  if check_include "sanitizer/asan_interface.h" ; then
2559      have_asan_iface_h=yes
2560  fi
2561
2562  cat > $TMPC << EOF
2563#include <sanitizer/asan_interface.h>
2564int main(void) {
2565  __sanitizer_start_switch_fiber(0, 0, 0);
2566  return 0;
2567}
2568EOF
2569  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
2570      have_asan_iface_fiber=yes
2571  fi
2572fi
2573
2574# Thread sanitizer is, for now, much noisier than the other sanitizers;
2575# keep it separate until that is not the case.
2576if test "$tsan" = "yes" && test "$sanitizers" = "yes"; then
2577  error_exit "TSAN is not supported with other sanitiziers."
2578fi
2579have_tsan=no
2580have_tsan_iface_fiber=no
2581if test "$tsan" = "yes" ; then
2582  write_c_skeleton
2583  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
2584      have_tsan=yes
2585  fi
2586  cat > $TMPC << EOF
2587#include <sanitizer/tsan_interface.h>
2588int main(void) {
2589  __tsan_create_fiber(0);
2590  return 0;
2591}
2592EOF
2593  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
2594      have_tsan_iface_fiber=yes
2595  fi
2596fi
2597
2598##########################################
2599# check for slirp
2600
2601case "$slirp" in
2602  auto | enabled | internal)
2603    # Simpler to always update submodule, even if not needed.
2604    git_submodules="${git_submodules} slirp"
2605    ;;
2606esac
2607
2608##########################################
2609# check for usable __NR_keyctl syscall
2610
2611if test "$linux" = "yes" ; then
2612
2613    have_keyring=no
2614    cat > $TMPC << EOF
2615#include <errno.h>
2616#include <asm/unistd.h>
2617#include <linux/keyctl.h>
2618#include <unistd.h>
2619int main(void) {
2620    return syscall(__NR_keyctl, KEYCTL_READ, 0, NULL, NULL, 0);
2621}
2622EOF
2623    if compile_prog "" "" ; then
2624        have_keyring=yes
2625    fi
2626fi
2627if test "$secret_keyring" != "no"
2628then
2629    if test "$have_keyring" = "yes"
2630    then
2631	secret_keyring=yes
2632    else
2633	if test "$secret_keyring" = "yes"
2634	then
2635	    error_exit "syscall __NR_keyctl requested, \
2636but not implemented on your system"
2637	else
2638	    secret_keyring=no
2639	fi
2640    fi
2641fi
2642
2643##########################################
2644# End of CC checks
2645# After here, no more $cc or $ld runs
2646
2647write_c_skeleton
2648
2649if test "$gcov" = "yes" ; then
2650  :
2651elif test "$fortify_source" = "yes" ; then
2652  QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
2653  debug=no
2654fi
2655
2656case "$ARCH" in
2657alpha)
2658  # Ensure there's only a single GP
2659  QEMU_CFLAGS="-msmall-data $QEMU_CFLAGS"
2660;;
2661esac
2662
2663if test "$have_asan" = "yes"; then
2664  QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS"
2665  QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS"
2666  if test "$have_asan_iface_h" = "no" ; then
2667      echo "ASAN build enabled, but ASAN header missing." \
2668           "Without code annotation, the report may be inferior."
2669  elif test "$have_asan_iface_fiber" = "no" ; then
2670      echo "ASAN build enabled, but ASAN header is too old." \
2671           "Without code annotation, the report may be inferior."
2672  fi
2673fi
2674if test "$have_tsan" = "yes" ; then
2675  if test "$have_tsan_iface_fiber" = "yes" ; then
2676    QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS"
2677    QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS"
2678  else
2679    error_exit "Cannot enable TSAN due to missing fiber annotation interface."
2680  fi
2681elif test "$tsan" = "yes" ; then
2682  error_exit "Cannot enable TSAN due to missing sanitize thread interface."
2683fi
2684if test "$have_ubsan" = "yes"; then
2685  QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS"
2686  QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS"
2687fi
2688
2689##########################################
2690
2691# Exclude --warn-common with TSan to suppress warnings from the TSan libraries.
2692if test "$solaris" = "no" && test "$tsan" = "no"; then
2693    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
2694        QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS"
2695    fi
2696fi
2697
2698# Use ASLR, no-SEH and DEP if available
2699if test "$mingw32" = "yes" ; then
2700    flags="--no-seh --nxcompat"
2701
2702    # Disable ASLR for debug builds to allow debugging with gdb
2703    if test "$debug" = "no" ; then
2704        flags="--dynamicbase $flags"
2705    fi
2706
2707    for flag in $flags; do
2708        if ld_has $flag ; then
2709            QEMU_LDFLAGS="-Wl,$flag $QEMU_LDFLAGS"
2710        fi
2711    done
2712fi
2713
2714# Guest agent Windows MSI package
2715
2716if test "$QEMU_GA_MANUFACTURER" = ""; then
2717  QEMU_GA_MANUFACTURER=QEMU
2718fi
2719if test "$QEMU_GA_DISTRO" = ""; then
2720  QEMU_GA_DISTRO=Linux
2721fi
2722if test "$QEMU_GA_VERSION" = ""; then
2723    QEMU_GA_VERSION=$(cat $source_path/VERSION)
2724fi
2725
2726QEMU_GA_MSI_MINGW_DLL_PATH="$($pkg_config --variable=prefix glib-2.0)/bin"
2727
2728# Mac OS X ships with a broken assembler
2729roms=
2730if { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \
2731        test "$targetos" != "darwin" && test "$targetos" != "sunos" && \
2732        test "$targetos" != "haiku" && test "$softmmu" = yes ; then
2733    # Different host OS linkers have different ideas about the name of the ELF
2734    # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
2735    # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
2736    for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
2737        if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
2738            ld_i386_emulation="$emu"
2739            roms="optionrom"
2740            break
2741        fi
2742    done
2743fi
2744
2745# Only build s390-ccw bios if we're on s390x and the compiler has -march=z900
2746# or -march=z10 (which is the lowest architecture level that Clang supports)
2747if test "$cpu" = "s390x" ; then
2748  write_c_skeleton
2749  compile_prog "-march=z900" ""
2750  has_z900=$?
2751  if [ $has_z900 = 0 ] || compile_object "-march=z10 -msoft-float -Werror"; then
2752    if [ $has_z900 != 0 ]; then
2753      echo "WARNING: Your compiler does not support the z900!"
2754      echo "         The s390-ccw bios will only work with guest CPUs >= z10."
2755    fi
2756    roms="$roms s390-ccw"
2757    # SLOF is required for building the s390-ccw firmware on s390x,
2758    # since it is using the libnet code from SLOF for network booting.
2759    git_submodules="${git_submodules} roms/SLOF"
2760  fi
2761fi
2762
2763# Check that the C++ compiler exists and works with the C compiler.
2764# All the QEMU_CXXFLAGS are based on QEMU_CFLAGS. Keep this at the end to don't miss any other that could be added.
2765if has $cxx; then
2766    cat > $TMPC <<EOF
2767int c_function(void);
2768int main(void) { return c_function(); }
2769EOF
2770
2771    compile_object
2772
2773    cat > $TMPCXX <<EOF
2774extern "C" {
2775   int c_function(void);
2776}
2777int c_function(void) { return 42; }
2778EOF
2779
2780    update_cxxflags
2781
2782    if do_cxx $CXXFLAGS $EXTRA_CXXFLAGS $CONFIGURE_CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then
2783        # C++ compiler $cxx works ok with C compiler $cc
2784        :
2785    else
2786        echo "C++ compiler $cxx does not work with C compiler $cc"
2787        echo "Disabling C++ specific optional code"
2788        cxx=
2789    fi
2790else
2791    echo "No C++ compiler available; disabling C++ specific optional code"
2792    cxx=
2793fi
2794
2795if !(GIT="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then
2796    exit 1
2797fi
2798
2799config_host_mak="config-host.mak"
2800
2801echo "# Automatically generated by configure - do not modify" > $config_host_mak
2802echo >> $config_host_mak
2803
2804echo all: >> $config_host_mak
2805echo "GIT=$git" >> $config_host_mak
2806echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
2807echo "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak
2808
2809if test "$debug_tcg" = "yes" ; then
2810  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
2811fi
2812if test "$mingw32" = "yes" ; then
2813  echo "CONFIG_WIN32=y" >> $config_host_mak
2814  echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
2815  echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
2816  echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
2817  echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
2818else
2819  echo "CONFIG_POSIX=y" >> $config_host_mak
2820fi
2821
2822if test "$linux" = "yes" ; then
2823  echo "CONFIG_LINUX=y" >> $config_host_mak
2824fi
2825
2826if test "$darwin" = "yes" ; then
2827  echo "CONFIG_DARWIN=y" >> $config_host_mak
2828fi
2829
2830if test "$solaris" = "yes" ; then
2831  echo "CONFIG_SOLARIS=y" >> $config_host_mak
2832fi
2833if test "$static" = "yes" ; then
2834  echo "CONFIG_STATIC=y" >> $config_host_mak
2835fi
2836echo "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
2837echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
2838qemu_version=$(head $source_path/VERSION)
2839echo "PKGVERSION=$pkgversion" >>$config_host_mak
2840echo "SRC_PATH=$source_path" >> $config_host_mak
2841echo "TARGET_DIRS=$target_list" >> $config_host_mak
2842if test "$modules" = "yes"; then
2843  # $shacmd can generate a hash started with digit, which the compiler doesn't
2844  # like as an symbol. So prefix it with an underscore
2845  echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
2846  echo "CONFIG_MODULES=y" >> $config_host_mak
2847fi
2848if test "$module_upgrades" = "yes"; then
2849  echo "CONFIG_MODULE_UPGRADES=y" >> $config_host_mak
2850fi
2851if test "$have_usbfs" = "yes" ; then
2852  echo "CONFIG_USBFS=y" >> $config_host_mak
2853fi
2854if test "$gio" = "yes" ; then
2855    echo "CONFIG_GIO=y" >> $config_host_mak
2856    echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak
2857    echo "GIO_LIBS=$gio_libs" >> $config_host_mak
2858fi
2859if test "$gdbus_codegen" != "" ; then
2860    echo "GDBUS_CODEGEN=$gdbus_codegen" >> $config_host_mak
2861fi
2862echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
2863
2864if test "$xen" = "enabled" ; then
2865  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
2866  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
2867  echo "XEN_CFLAGS=$xen_cflags" >> $config_host_mak
2868  echo "XEN_LIBS=$xen_libs" >> $config_host_mak
2869fi
2870if test "$vhost_scsi" = "yes" ; then
2871  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
2872fi
2873if test "$vhost_net" = "yes" ; then
2874  echo "CONFIG_VHOST_NET=y" >> $config_host_mak
2875fi
2876if test "$vhost_net_user" = "yes" ; then
2877  echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak
2878fi
2879if test "$vhost_net_vdpa" = "yes" ; then
2880  echo "CONFIG_VHOST_NET_VDPA=y" >> $config_host_mak
2881fi
2882if test "$vhost_crypto" = "yes" ; then
2883  echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
2884fi
2885if test "$vhost_vsock" = "yes" ; then
2886  echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
2887  if test "$vhost_user" = "yes" ; then
2888    echo "CONFIG_VHOST_USER_VSOCK=y" >> $config_host_mak
2889  fi
2890fi
2891if test "$vhost_kernel" = "yes" ; then
2892  echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak
2893fi
2894if test "$vhost_user" = "yes" ; then
2895  echo "CONFIG_VHOST_USER=y" >> $config_host_mak
2896fi
2897if test "$vhost_vdpa" = "yes" ; then
2898  echo "CONFIG_VHOST_VDPA=y" >> $config_host_mak
2899fi
2900if test "$vhost_user_fs" = "yes" ; then
2901  echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak
2902fi
2903if test "$tcg" = "enabled" -a "$tcg_interpreter" = "true" ; then
2904  echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
2905fi
2906
2907if test "$opengl" = "yes" ; then
2908  echo "CONFIG_OPENGL=y" >> $config_host_mak
2909  echo "OPENGL_CFLAGS=$opengl_cflags" >> $config_host_mak
2910  echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
2911fi
2912
2913# XXX: suppress that
2914if [ "$bsd" = "yes" ] ; then
2915  echo "CONFIG_BSD=y" >> $config_host_mak
2916fi
2917
2918echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
2919
2920if test "$have_asan_iface_fiber" = "yes" ; then
2921    echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
2922fi
2923
2924if test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then
2925    echo "CONFIG_TSAN=y" >> $config_host_mak
2926fi
2927
2928if test "$int128" = "yes" ; then
2929  echo "CONFIG_INT128=y" >> $config_host_mak
2930fi
2931
2932if test "$atomic128" = "yes" ; then
2933  echo "CONFIG_ATOMIC128=y" >> $config_host_mak
2934fi
2935
2936if test "$cmpxchg128" = "yes" ; then
2937  echo "CONFIG_CMPXCHG128=y" >> $config_host_mak
2938fi
2939
2940if test "$rdma" = "yes" ; then
2941  echo "CONFIG_RDMA=y" >> $config_host_mak
2942  echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
2943fi
2944
2945if test "$pvrdma" = "yes" ; then
2946  echo "CONFIG_PVRDMA=y" >> $config_host_mak
2947fi
2948
2949if test "$plugins" = "yes" ; then
2950    echo "CONFIG_PLUGIN=y" >> $config_host_mak
2951fi
2952
2953if test -n "$gdb_bin"; then
2954    gdb_version=$($gdb_bin --version | head -n 1)
2955    if version_ge ${gdb_version##* } 9.1; then
2956        echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
2957    fi
2958fi
2959
2960if test "$secret_keyring" = "yes" ; then
2961  echo "CONFIG_SECRET_KEYRING=y" >> $config_host_mak
2962fi
2963
2964echo "ROMS=$roms" >> $config_host_mak
2965echo "MAKE=$make" >> $config_host_mak
2966echo "PYTHON=$python" >> $config_host_mak
2967echo "GENISOIMAGE=$genisoimage" >> $config_host_mak
2968echo "MESON=$meson" >> $config_host_mak
2969echo "NINJA=$ninja" >> $config_host_mak
2970echo "CC=$cc" >> $config_host_mak
2971echo "HOST_CC=$host_cc" >> $config_host_mak
2972echo "AR=$ar" >> $config_host_mak
2973echo "AS=$as" >> $config_host_mak
2974echo "CCAS=$ccas" >> $config_host_mak
2975echo "CPP=$cpp" >> $config_host_mak
2976echo "OBJCOPY=$objcopy" >> $config_host_mak
2977echo "LD=$ld" >> $config_host_mak
2978echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
2979echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
2980echo "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
2981echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
2982echo "GLIB_LIBS=$glib_libs" >> $config_host_mak
2983echo "GLIB_VERSION=$(pkg-config --modversion glib-2.0)" >> $config_host_mak
2984echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
2985echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
2986echo "STRIP=$strip" >> $config_host_mak
2987echo "EXESUF=$EXESUF" >> $config_host_mak
2988
2989# use included Linux headers
2990if test "$linux" = "yes" ; then
2991  mkdir -p linux-headers
2992  case "$cpu" in
2993  i386|x86_64)
2994    linux_arch=x86
2995    ;;
2996  ppc|ppc64)
2997    linux_arch=powerpc
2998    ;;
2999  s390x)
3000    linux_arch=s390
3001    ;;
3002  aarch64)
3003    linux_arch=arm64
3004    ;;
3005  loongarch*)
3006    linux_arch=loongarch
3007    ;;
3008  mips64)
3009    linux_arch=mips
3010    ;;
3011  *)
3012    # For most CPUs the kernel architecture name and QEMU CPU name match.
3013    linux_arch="$cpu"
3014    ;;
3015  esac
3016    # For non-KVM architectures we will not have asm headers
3017    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
3018      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
3019    fi
3020fi
3021
3022for target in $target_list; do
3023    target_dir="$target"
3024    target_name=$(echo $target | cut -d '-' -f 1)$EXESUF
3025    mkdir -p $target_dir
3026    case $target in
3027        *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;;
3028        *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;;
3029    esac
3030done
3031
3032echo "CONFIG_QEMU_INTERP_PREFIX=$interp_prefix" | sed 's/%M/@0@/' >> $config_host_mak
3033if test "$default_targets" = "yes"; then
3034  echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak
3035fi
3036
3037if test "$ccache_cpp2" = "yes"; then
3038  echo "export CCACHE_CPP2=y" >> $config_host_mak
3039fi
3040
3041if test "$safe_stack" = "yes"; then
3042  echo "CONFIG_SAFESTACK=y" >> $config_host_mak
3043fi
3044
3045# If we're using a separate build tree, set it up now.
3046# LINKS are things to symlink back into the source tree
3047# (these can be both files and directories).
3048# Caution: do not add files or directories here using wildcards. This
3049# will result in problems later if a new file matching the wildcard is
3050# added to the source tree -- nothing will cause configure to be rerun
3051# so the build tree will be missing the link back to the new file, and
3052# tests might fail. Prefer to keep the relevant files in their own
3053# directory and symlink the directory instead.
3054LINKS="Makefile"
3055LINKS="$LINKS tests/tcg/Makefile.target"
3056LINKS="$LINKS pc-bios/optionrom/Makefile"
3057LINKS="$LINKS pc-bios/s390-ccw/Makefile"
3058LINKS="$LINKS roms/seabios/Makefile"
3059LINKS="$LINKS pc-bios/qemu-icon.bmp"
3060LINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
3061LINKS="$LINKS tests/avocado tests/data"
3062LINKS="$LINKS tests/qemu-iotests/check"
3063LINKS="$LINKS python"
3064LINKS="$LINKS contrib/plugins/Makefile "
3065for bios_file in \
3066    $source_path/pc-bios/*.bin \
3067    $source_path/pc-bios/*.elf \
3068    $source_path/pc-bios/*.lid \
3069    $source_path/pc-bios/*.rom \
3070    $source_path/pc-bios/*.dtb \
3071    $source_path/pc-bios/*.img \
3072    $source_path/pc-bios/openbios-* \
3073    $source_path/pc-bios/u-boot.* \
3074    $source_path/pc-bios/palcode-* \
3075    $source_path/pc-bios/qemu_vga.ndrv
3076
3077do
3078    LINKS="$LINKS pc-bios/$(basename $bios_file)"
3079done
3080for f in $LINKS ; do
3081    if [ -e "$source_path/$f" ]; then
3082        mkdir -p `dirname ./$f`
3083        symlink "$source_path/$f" "$f"
3084    fi
3085done
3086
3087(for i in $cross_cc_vars; do
3088  export $i
3089done
3090export target_list source_path use_containers cpu
3091$source_path/tests/tcg/configure.sh)
3092
3093# temporary config to build submodules
3094if test -f $source_path/roms/seabios/Makefile; then
3095  for rom in seabios; do
3096    config_mak=roms/$rom/config.mak
3097    echo "# Automatically generated by configure - do not modify" > $config_mak
3098    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
3099    echo "AS=$as" >> $config_mak
3100    echo "CCAS=$ccas" >> $config_mak
3101    echo "CC=$cc" >> $config_mak
3102    echo "BCC=bcc" >> $config_mak
3103    echo "CPP=$cpp" >> $config_mak
3104    echo "OBJCOPY=objcopy" >> $config_mak
3105    echo "IASL=$iasl" >> $config_mak
3106    echo "LD=$ld" >> $config_mak
3107    echo "RANLIB=$ranlib" >> $config_mak
3108  done
3109fi
3110
3111config_mak=pc-bios/optionrom/config.mak
3112echo "# Automatically generated by configure - do not modify" > $config_mak
3113echo "TOPSRC_DIR=$source_path" >> $config_mak
3114
3115if test "$skip_meson" = no; then
3116  cross="config-meson.cross.new"
3117  meson_quote() {
3118    test $# = 0 && return
3119    echo "'$(echo $* | sed "s/ /','/g")'"
3120  }
3121
3122  echo "# Automatically generated by configure - do not modify" > $cross
3123  echo "[properties]" >> $cross
3124
3125  # unroll any custom device configs
3126  for a in $device_archs; do
3127      eval "c=\$devices_${a}"
3128      echo "${a}-softmmu = '$c'" >> $cross
3129  done
3130
3131  test -z "$cxx" && echo "link_language = 'c'" >> $cross
3132  echo "[built-in options]" >> $cross
3133  echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross
3134  echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross
3135  echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross
3136  echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross
3137  echo "[binaries]" >> $cross
3138  echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross
3139  test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross
3140  test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross
3141  echo "ar = [$(meson_quote $ar)]" >> $cross
3142  echo "nm = [$(meson_quote $nm)]" >> $cross
3143  echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross
3144  echo "ranlib = [$(meson_quote $ranlib)]" >> $cross
3145  if has $sdl2_config; then
3146    echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross
3147  fi
3148  echo "strip = [$(meson_quote $strip)]" >> $cross
3149  echo "windres = [$(meson_quote $windres)]" >> $cross
3150  if test "$cross_compile" = "yes"; then
3151    cross_arg="--cross-file config-meson.cross"
3152    echo "[host_machine]" >> $cross
3153    echo "system = '$targetos'" >> $cross
3154    case "$cpu" in
3155        i386)
3156            echo "cpu_family = 'x86'" >> $cross
3157            ;;
3158        *)
3159            echo "cpu_family = '$cpu'" >> $cross
3160            ;;
3161    esac
3162    echo "cpu = '$cpu'" >> $cross
3163    if test "$bigendian" = "yes" ; then
3164        echo "endian = 'big'" >> $cross
3165    else
3166        echo "endian = 'little'" >> $cross
3167    fi
3168  else
3169    cross_arg="--native-file config-meson.cross"
3170  fi
3171  mv $cross config-meson.cross
3172
3173  rm -rf meson-private meson-info meson-logs
3174  run_meson() {
3175    NINJA=$ninja $meson setup \
3176        --prefix "$prefix" \
3177        --libdir "$libdir" \
3178        --libexecdir "$libexecdir" \
3179        --bindir "$bindir" \
3180        --includedir "$includedir" \
3181        --datadir "$datadir" \
3182        --mandir "$mandir" \
3183        --sysconfdir "$sysconfdir" \
3184        --localedir "$localedir" \
3185        --localstatedir "$local_statedir" \
3186        -Daudio_drv_list=$audio_drv_list \
3187        -Ddefault_devices=$default_devices \
3188        -Ddocdir="$docdir" \
3189        -Diasl="$($iasl -h >/dev/null 2>&1 && printf %s "$iasl")" \
3190        -Dqemu_firmwarepath="$firmwarepath" \
3191        -Dqemu_suffix="$qemu_suffix" \
3192        -Dsmbd="$smbd" \
3193        -Dsphinx_build="$sphinx_build" \
3194        -Dtrace_file="$trace_file" \
3195        -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) \
3196        -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo false; fi) \
3197        -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \
3198        -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \
3199        -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \
3200        -Db_lto=$lto -Dcfi=$cfi -Dtcg=$tcg -Dxen=$xen \
3201        -Dcapstone=$capstone -Dfdt=$fdt -Dslirp=$slirp \
3202        $(test -n "${LIB_FUZZING_ENGINE+xxx}" && echo "-Dfuzzing_engine=$LIB_FUZZING_ENGINE") \
3203        $(if test "$default_feature" = no; then echo "-Dauto_features=disabled"; fi) \
3204        "$@" $cross_arg "$PWD" "$source_path"
3205  }
3206  eval run_meson $meson_options
3207  if test "$?" -ne 0 ; then
3208      error_exit "meson setup failed"
3209  fi
3210else
3211  if test -f meson-private/cmd_line.txt; then
3212    # Adjust old command line options whose type was changed
3213    # Avoids having to use "setup --wipe" when Meson is upgraded
3214    perl -i -ne '
3215      s/^gettext = true$/gettext = auto/;
3216      s/^gettext = false$/gettext = disabled/;
3217      /^b_staticpic/ && next;
3218      print;' meson-private/cmd_line.txt
3219  fi
3220fi
3221
3222# Save the configure command line for later reuse.
3223cat <<EOD >config.status
3224#!/bin/sh
3225# Generated by configure.
3226# Run this file to recreate the current configuration.
3227# Compiler output produced by configure, useful for debugging
3228# configure, is in config.log if it exists.
3229EOD
3230
3231preserve_env() {
3232    envname=$1
3233
3234    eval envval=\$$envname
3235
3236    if test -n "$envval"
3237    then
3238	echo "$envname='$envval'" >> config.status
3239	echo "export $envname" >> config.status
3240    else
3241	echo "unset $envname" >> config.status
3242    fi
3243}
3244
3245# Preserve various env variables that influence what
3246# features/build target configure will detect
3247preserve_env AR
3248preserve_env AS
3249preserve_env CC
3250preserve_env CPP
3251preserve_env CFLAGS
3252preserve_env CXX
3253preserve_env CXXFLAGS
3254preserve_env INSTALL
3255preserve_env LD
3256preserve_env LDFLAGS
3257preserve_env LD_LIBRARY_PATH
3258preserve_env LIBTOOL
3259preserve_env MAKE
3260preserve_env NM
3261preserve_env OBJCOPY
3262preserve_env PATH
3263preserve_env PKG_CONFIG
3264preserve_env PKG_CONFIG_LIBDIR
3265preserve_env PKG_CONFIG_PATH
3266preserve_env PYTHON
3267preserve_env SDL2_CONFIG
3268preserve_env SMBD
3269preserve_env STRIP
3270preserve_env WINDRES
3271
3272printf "exec" >>config.status
3273for i in "$0" "$@"; do
3274  test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status
3275done
3276echo ' "$@"' >>config.status
3277chmod +x config.status
3278
3279rm -r "$TMPDIR1"
3280