xref: /openbmc/qemu/configure (revision e37548ef)
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    if ! mkdir build || ! touch $MARKER
35    then
36        echo "ERROR: Could not create ./build directory. Check the permissions on"
37        echo "your source directory, or try doing an out-of-tree build."
38        exit 1
39    fi
40
41    cat > GNUmakefile <<'EOF'
42# This file is auto-generated by configure to support in-source tree
43# 'make' command invocation
44
45ifeq ($(MAKECMDGOALS),)
46recurse: all
47endif
48
49.NOTPARALLEL: %
50%: force
51	@echo 'changing dir to build for $(MAKE) "$(MAKECMDGOALS)"...'
52	@$(MAKE) -C build -f Makefile $(MAKECMDGOALS)
53	@if test "$(MAKECMDGOALS)" = "distclean" && \
54	    test -e build/auto-created-by-configure ; \
55	then \
56	    rm -rf build GNUmakefile ; \
57	fi
58force: ;
59.PHONY: force
60GNUmakefile: ;
61
62EOF
63    cd build
64    exec "$source_path/configure" "$@"
65fi
66
67# Temporary directory used for files created while
68# configure runs. Since it is in the build directory
69# we can safely blow away any previous version of it
70# (and we need not jump through hoops to try to delete
71# it when configure exits.)
72TMPDIR1="config-temp"
73rm -rf "${TMPDIR1}"
74if ! mkdir -p "${TMPDIR1}"; then
75    echo "ERROR: failed to create temporary directory"
76    exit 1
77fi
78
79TMPB="qemu-conf"
80TMPC="${TMPDIR1}/${TMPB}.c"
81TMPO="${TMPDIR1}/${TMPB}.o"
82TMPE="${TMPDIR1}/${TMPB}.exe"
83
84rm -f config.log
85
86# Print a helpful header at the top of config.log
87echo "# QEMU configure log $(date)" >> config.log
88printf "# Configured with:" >> config.log
89# repeat the invocation to log and stdout for CI
90invoke=$(printf " '%s'" "$0" "$@")
91test -n "$GITLAB_CI" && echo "configuring with: $invoke"
92{ echo "$invoke"; echo; echo "#"; } >> config.log
93
94quote_sh() {
95    printf "%s" "$1" | sed "s,','\\\\'',g; s,.*,'&',"
96}
97
98print_error() {
99    (echo
100    echo "ERROR: $1"
101    while test -n "$2"; do
102        echo "       $2"
103        shift
104    done
105    echo) >&2
106}
107
108error_exit() {
109    print_error "$@"
110    exit 1
111}
112
113do_compiler() {
114  # Run the compiler, capturing its output to the log. First argument
115  # is compiler binary to execute.
116  compiler="$1"
117  shift
118  if test -n "$BASH_VERSION"; then eval '
119      echo >>config.log "
120funcs: ${FUNCNAME[*]}
121lines: ${BASH_LINENO[*]}"
122  '; fi
123  echo $compiler "$@" >> config.log
124  $compiler "$@" >> config.log 2>&1 || return $?
125}
126
127do_cc() {
128    do_compiler "$cc" $CPU_CFLAGS "$@"
129}
130
131compile_object() {
132  local_cflags="$1"
133  do_cc $CFLAGS $EXTRA_CFLAGS $local_cflags -c -o $TMPO $TMPC
134}
135
136compile_prog() {
137  local_cflags="$1"
138  local_ldflags="$2"
139  do_cc $CFLAGS $EXTRA_CFLAGS $local_cflags -o $TMPE $TMPC \
140      $LDFLAGS $EXTRA_LDFLAGS $local_ldflags
141}
142
143# symbolically link $1 to $2.  Portable version of "ln -sf".
144symlink() {
145  rm -rf "$2"
146  mkdir -p "$(dirname "$2")"
147  ln -s "$1" "$2"
148}
149
150# check whether a command is available to this shell (may be either an
151# executable or a builtin)
152has() {
153    type "$1" >/dev/null 2>&1
154}
155
156version_ge () {
157    local_ver1=$(expr "$1" : '\([0-9.]*\)' | tr . ' ')
158    local_ver2=$(echo "$2" | tr . ' ')
159    while true; do
160        set x $local_ver1
161        local_first=${2-0}
162        # 'shift 2' if $2 is set, or 'shift' if $2 is not set
163        shift ${2:+2}
164        local_ver1=$*
165        set x $local_ver2
166        # the second argument finished, the first must be greater or equal
167        test $# = 1 && return 0
168        test $local_first -lt $2 && return 1
169        test $local_first -gt $2 && return 0
170        shift ${2:+2}
171        local_ver2=$*
172    done
173}
174
175if printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]";
176then
177  error_exit "main directory cannot contain spaces nor colons"
178fi
179
180# parse CC options first; some compiler tests are used to establish
181# some defaults, based on the host environment
182
183# default parameters
184cpu=""
185cross_compile="no"
186cross_prefix=""
187host_cc="cc"
188EXTRA_CFLAGS=""
189EXTRA_CXXFLAGS=""
190EXTRA_OBJCFLAGS=""
191EXTRA_LDFLAGS=""
192
193# Default value for a variable defining feature "foo".
194#  * foo="no"  feature will only be used if --enable-foo arg is given
195#  * foo=""    feature will be searched for, and if found, will be used
196#              unless --disable-foo is given
197#  * foo="yes" this value will only be set by --enable-foo flag.
198#              feature will searched for,
199#              if not found, configure exits with error
200#
201# Always add --enable-foo and --disable-foo command line args.
202# Distributions want to ensure that several features are compiled in, and it
203# is impossible without a --enable-foo that exits if a feature is not found.
204default_feature=""
205
206for opt do
207  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
208  case "$opt" in
209  --cross-prefix=*) cross_prefix="$optarg"
210                    cross_compile="yes"
211  ;;
212  --cc=*) CC="$optarg"
213  ;;
214  --cxx=*) CXX="$optarg"
215  ;;
216  --objcc=*) objcc="$optarg"
217  ;;
218  --cpu=*) cpu="$optarg"
219  ;;
220  --extra-cflags=*)
221    EXTRA_CFLAGS="$EXTRA_CFLAGS $optarg"
222    EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg"
223    EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg"
224    ;;
225  --extra-cxxflags=*) EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg"
226  ;;
227  --extra-objcflags=*) EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg"
228  ;;
229  --extra-ldflags=*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS $optarg"
230  ;;
231  --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
232  ;;
233  --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-cflags-}; cc_arch=${cc_arch%%=*}
234                      eval "cross_cc_cflags_${cc_arch}=\$optarg"
235  ;;
236  --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
237                eval "cross_cc_${cc_arch}=\$optarg"
238  ;;
239  --cross-prefix-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-prefix-FOO option"
240  ;;
241  --cross-prefix-*) cc_arch=${opt#--cross-prefix-}; cc_arch=${cc_arch%%=*}
242                    eval "cross_prefix_${cc_arch}=\$optarg"
243  ;;
244  --without-default-features) default_feature="no"
245  ;;
246  esac
247done
248
249
250if test -e "$source_path/.git"
251then
252    git_submodules_action="update"
253else
254    git_submodules_action="ignore"
255fi
256
257git_submodules="ui/keycodemapdb"
258git="git"
259debug_tcg="no"
260docs="auto"
261EXESUF=""
262prefix="/usr/local"
263qemu_suffix="qemu"
264softmmu="yes"
265linux_user=""
266bsd_user=""
267plugins="$default_feature"
268ninja=""
269python=
270pypi="enabled"
271bindir="bin"
272skip_meson=no
273vfio_user_server="disabled"
274use_containers="yes"
275gdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
276gdb_arches=""
277werror=""
278
279# Don't accept a target_list environment variable.
280unset target_list
281unset target_list_exclude
282
283# The following Meson options are handled manually (still they
284# are included in the automatically generated help message)
285
286# 1. Track which submodules are needed
287fdt="auto"
288
289# 2. Automatically enable/disable other options
290tcg="auto"
291cfi="false"
292
293# 3. Need to check for -static-pie before Meson runs.  Also,
294# Meson has PIE as a boolean rather than enabled/disabled/auto.
295pie=""
296static="no"
297
298# Preferred compiler:
299#  ${CC} (if set)
300#  ${cross_prefix}gcc (if cross-prefix specified)
301#  system compiler
302if test -z "${CC}${cross_prefix}"; then
303  cc="$host_cc"
304else
305  cc="${CC-${cross_prefix}gcc}"
306fi
307
308if test -z "${CXX}${cross_prefix}"; then
309  cxx="c++"
310else
311  cxx="${CXX-${cross_prefix}g++}"
312fi
313
314# Preferred ObjC compiler:
315# $objcc (if set, i.e. via --objcc option)
316# ${cross_prefix}clang (if cross-prefix specified)
317# clang (if available)
318# $cc
319if test -z "${objcc}${cross_prefix}"; then
320  if has clang; then
321    objcc=clang
322  else
323    objcc="$cc"
324  fi
325else
326  objcc="${objcc-${cross_prefix}clang}"
327fi
328
329ar="${AR-${cross_prefix}ar}"
330as="${AS-${cross_prefix}as}"
331ccas="${CCAS-$cc}"
332objcopy="${OBJCOPY-${cross_prefix}objcopy}"
333ld="${LD-${cross_prefix}ld}"
334ranlib="${RANLIB-${cross_prefix}ranlib}"
335nm="${NM-${cross_prefix}nm}"
336smbd="$SMBD"
337strip="${STRIP-${cross_prefix}strip}"
338widl="${WIDL-${cross_prefix}widl}"
339windres="${WINDRES-${cross_prefix}windres}"
340windmc="${WINDMC-${cross_prefix}windmc}"
341pkg_config="${PKG_CONFIG-${cross_prefix}pkg-config}"
342sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
343
344check_define() {
345cat > $TMPC <<EOF
346#if !defined($1)
347#error $1 not defined
348#endif
349int main(void) { return 0; }
350EOF
351  compile_object
352}
353
354write_c_skeleton() {
355    cat > $TMPC <<EOF
356int main(void) { return 0; }
357EOF
358}
359
360if check_define __linux__ ; then
361  targetos=linux
362elif check_define _WIN32 ; then
363  targetos=windows
364elif check_define __OpenBSD__ ; then
365  targetos=openbsd
366elif check_define __sun__ ; then
367  targetos=sunos
368elif check_define __HAIKU__ ; then
369  targetos=haiku
370elif check_define __FreeBSD__ ; then
371  targetos=freebsd
372elif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
373  targetos=gnu/kfreebsd
374elif check_define __DragonFly__ ; then
375  targetos=dragonfly
376elif check_define __NetBSD__; then
377  targetos=netbsd
378elif check_define __APPLE__; then
379  targetos=darwin
380else
381  # This is a fatal error, but don't report it yet, because we
382  # might be going to just print the --help text, or it might
383  # be the result of a missing compiler.
384  targetos=bogus
385fi
386
387# OS specific
388
389mingw32="no"
390bsd="no"
391linux="no"
392solaris="no"
393case $targetos in
394windows)
395  mingw32="yes"
396  plugins="no"
397  pie="no"
398;;
399gnu/kfreebsd)
400  bsd="yes"
401;;
402freebsd)
403  bsd="yes"
404  make="${MAKE-gmake}"
405  # needed for kinfo_getvmmap(3) in libutil.h
406;;
407dragonfly)
408  bsd="yes"
409  make="${MAKE-gmake}"
410;;
411netbsd)
412  bsd="yes"
413  make="${MAKE-gmake}"
414;;
415openbsd)
416  bsd="yes"
417  make="${MAKE-gmake}"
418;;
419darwin)
420  bsd="yes"
421  darwin="yes"
422;;
423sunos)
424  solaris="yes"
425  make="${MAKE-gmake}"
426;;
427haiku)
428  pie="no"
429;;
430linux)
431  linux="yes"
432;;
433esac
434
435if test ! -z "$cpu" ; then
436  # command line argument
437  :
438elif check_define __i386__ ; then
439  cpu="i386"
440elif check_define __x86_64__ ; then
441  if check_define __ILP32__ ; then
442    cpu="x32"
443  else
444    cpu="x86_64"
445  fi
446elif check_define __sparc__ ; then
447  if check_define __arch64__ ; then
448    cpu="sparc64"
449  else
450    cpu="sparc"
451  fi
452elif check_define _ARCH_PPC ; then
453  if check_define _ARCH_PPC64 ; then
454    if check_define _LITTLE_ENDIAN ; then
455      cpu="ppc64le"
456    else
457      cpu="ppc64"
458    fi
459  else
460    cpu="ppc"
461  fi
462elif check_define __mips__ ; then
463  cpu="mips"
464elif check_define __s390__ ; then
465  if check_define __s390x__ ; then
466    cpu="s390x"
467  else
468    cpu="s390"
469  fi
470elif check_define __riscv ; then
471  cpu="riscv"
472elif check_define __arm__ ; then
473  cpu="arm"
474elif check_define __aarch64__ ; then
475  cpu="aarch64"
476elif check_define __loongarch64 ; then
477  cpu="loongarch64"
478else
479  # Using uname is really broken, but it is just a fallback for architectures
480  # that are going to use TCI anyway
481  cpu=$(uname -m)
482  echo "WARNING: unrecognized host CPU, proceeding with 'uname -m' output '$cpu'"
483fi
484
485# Normalise host CPU name and set multilib cflags.  The canonicalization
486# isn't really necessary, because the architectures that we check for
487# should not hit the 'uname -m' case, but better safe than sorry.
488# Note that this case should only have supported host CPUs, not guests.
489case "$cpu" in
490  armv*b|armv*l|arm)
491    cpu="arm" ;;
492
493  i386|i486|i586|i686)
494    cpu="i386"
495    CPU_CFLAGS="-m32" ;;
496  x32)
497    cpu="x86_64"
498    CPU_CFLAGS="-mx32" ;;
499  x86_64|amd64)
500    cpu="x86_64"
501    # ??? Only extremely old AMD cpus do not have cmpxchg16b.
502    # If we truly care, we should simply detect this case at
503    # runtime and generate the fallback to serial emulation.
504    CPU_CFLAGS="-m64 -mcx16" ;;
505
506  mips*)
507    cpu="mips" ;;
508
509  ppc)
510    CPU_CFLAGS="-m32" ;;
511  ppc64)
512    CPU_CFLAGS="-m64 -mbig-endian" ;;
513  ppc64le)
514    cpu="ppc64"
515    CPU_CFLAGS="-m64 -mlittle-endian" ;;
516
517  s390)
518    CPU_CFLAGS="-m31" ;;
519  s390x)
520    CPU_CFLAGS="-m64" ;;
521
522  sparc|sun4[cdmuv])
523    cpu="sparc"
524    CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc" ;;
525  sparc64)
526    CPU_CFLAGS="-m64 -mcpu=ultrasparc" ;;
527esac
528
529: ${make=${MAKE-make}}
530
531
532check_py_version() {
533    # We require python >= 3.7.
534    # NB: a True python conditional creates a non-zero return code (Failure)
535    "$1" -c 'import sys; sys.exit(sys.version_info < (3,7))'
536}
537
538first_python=
539if test -z "${PYTHON}"; then
540    # A bare 'python' is traditionally python 2.x, but some distros
541    # have it as python 3.x, so check in both places.
542    for binary in python3 python python3.11 python3.10 python3.9 python3.8 python3.7; do
543        if has "$binary"; then
544            python=$(command -v "$binary")
545            if check_py_version "$python"; then
546                # This one is good.
547                first_python=
548                break
549            else
550                first_python=$python
551            fi
552        fi
553    done
554else
555    # Same as above, but only check the environment variable.
556    has "${PYTHON}" || error_exit "The PYTHON environment variable does not point to an executable"
557    python=$(command -v "$PYTHON")
558    if check_py_version "$python"; then
559        # This one is good.
560        first_python=
561    else
562        first_python=$first_python
563    fi
564fi
565
566# Check for ancillary tools used in testing
567genisoimage=
568for binary in genisoimage mkisofs
569do
570    if has $binary
571    then
572        genisoimage=$(command -v "$binary")
573        break
574    fi
575done
576
577if test "$mingw32" = "yes" ; then
578  EXESUF=".exe"
579  prefix="/qemu"
580  bindir=""
581  qemu_suffix=""
582fi
583
584meson_option_build_array() {
585  printf '['
586  (if test "$targetos" = windows; then
587    IFS=\;
588  else
589    IFS=:
590  fi
591  for e in $1; do
592    printf '"""'
593    # backslash escape any '\' and '"' characters
594    printf "%s" "$e" | sed -e 's/\([\"]\)/\\\1/g'
595    printf '""",'
596  done)
597  printf ']\n'
598}
599
600. "$source_path/scripts/meson-buildoptions.sh"
601
602meson_options=
603meson_option_add() {
604  meson_options="$meson_options $(quote_sh "$1")"
605}
606meson_option_parse() {
607  meson_options="$meson_options $(_meson_option_parse "$@")"
608  if test $? -eq 1; then
609    echo "ERROR: unknown option $1"
610    echo "Try '$0 --help' for more information"
611    exit 1
612  fi
613}
614
615for opt do
616  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
617  case "$opt" in
618  --help|-h) show_help=yes
619  ;;
620  --version|-V) exec cat "$source_path/VERSION"
621  ;;
622  --prefix=*) prefix="$optarg"
623  ;;
624  --cross-prefix=*)
625  ;;
626  --cc=*)
627  ;;
628  --host-cc=*) host_cc="$optarg"
629  ;;
630  --cxx=*)
631  ;;
632  --objcc=*)
633  ;;
634  --make=*) make="$optarg"
635  ;;
636  --install=*)
637  ;;
638  --python=*) python="$optarg"
639  ;;
640  --skip-meson) skip_meson=yes
641  ;;
642  --ninja=*) ninja="$optarg"
643  ;;
644  --smbd=*) smbd="$optarg"
645  ;;
646  --extra-cflags=*)
647  ;;
648  --extra-cxxflags=*)
649  ;;
650  --extra-objcflags=*)
651  ;;
652  --extra-ldflags=*)
653  ;;
654  --cross-cc-*)
655  ;;
656  --cross-prefix-*)
657  ;;
658  --enable-docs) docs=enabled
659  ;;
660  --disable-docs) docs=disabled
661  ;;
662  --cpu=*)
663  ;;
664  --target-list=*) target_list="$optarg"
665                   if test "$target_list_exclude"; then
666                       error_exit "Can't mix --target-list with --target-list-exclude"
667                   fi
668  ;;
669  --target-list-exclude=*) target_list_exclude="$optarg"
670                   if test "$target_list"; then
671                       error_exit "Can't mix --target-list-exclude with --target-list"
672                   fi
673  ;;
674  --with-default-devices) meson_option_add -Ddefault_devices=true
675  ;;
676  --without-default-devices) meson_option_add -Ddefault_devices=false
677  ;;
678  --with-devices-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --with-devices-FOO option"
679  ;;
680  --with-devices-*) device_arch=${opt#--with-devices-};
681                    device_arch=${device_arch%%=*}
682                    cf=$source_path/configs/devices/$device_arch-softmmu/$optarg.mak
683                    if test -f "$cf"; then
684                        device_archs="$device_archs $device_arch"
685                        eval "devices_${device_arch}=\$optarg"
686                    else
687                        error_exit "File $cf does not exist"
688                    fi
689  ;;
690  --without-default-features) # processed above
691  ;;
692  --static) static="yes"
693  ;;
694  --bindir=*) bindir="$optarg"
695  ;;
696  --with-suffix=*) qemu_suffix="$optarg"
697  ;;
698  --host=*|--build=*|\
699  --disable-dependency-tracking|\
700  --sbindir=*|--sharedstatedir=*|\
701  --oldincludedir=*|--datarootdir=*|--infodir=*|\
702  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
703    # These switches are silently ignored, for compatibility with
704    # autoconf-generated configure scripts. This allows QEMU's
705    # configure to be used by RPM and similar macros that set
706    # lots of directory switches by default.
707  ;;
708  --enable-debug-tcg) debug_tcg="yes"
709  ;;
710  --disable-debug-tcg) debug_tcg="no"
711  ;;
712  --enable-debug)
713      # Enable debugging options that aren't excessively noisy
714      debug_tcg="yes"
715      meson_option_parse --enable-debug-graph-lock ""
716      meson_option_parse --enable-debug-mutex ""
717      meson_option_add -Doptimization=0
718  ;;
719  --disable-tcg) tcg="disabled"
720                 plugins="no"
721  ;;
722  --enable-tcg) tcg="enabled"
723  ;;
724  --disable-system) softmmu="no"
725  ;;
726  --enable-system) softmmu="yes"
727  ;;
728  --disable-user)
729      linux_user="no" ;
730      bsd_user="no" ;
731  ;;
732  --enable-user) ;;
733  --disable-linux-user) linux_user="no"
734  ;;
735  --enable-linux-user) linux_user="yes"
736  ;;
737  --disable-bsd-user) bsd_user="no"
738  ;;
739  --enable-bsd-user) bsd_user="yes"
740  ;;
741  --enable-pie) pie="yes"
742  ;;
743  --disable-pie) pie="no"
744  ;;
745  --enable-werror) werror="yes"
746  ;;
747  --disable-werror) werror="no"
748  ;;
749  --enable-cfi)
750      cfi="true";
751      meson_option_add -Db_lto=true
752  ;;
753  --disable-cfi) cfi="false"
754  ;;
755  --disable-fdt) fdt="disabled"
756  ;;
757  --enable-fdt) fdt="enabled"
758  ;;
759  --enable-fdt=git) fdt="internal"
760  ;;
761  --enable-fdt=*) fdt="$optarg"
762  ;;
763  --with-git=*) git="$optarg"
764  ;;
765  --with-git-submodules=*)
766      git_submodules_action="$optarg"
767  ;;
768  --disable-pypi) pypi="disabled"
769  ;;
770  --enable-pypi) pypi="enabled"
771  ;;
772  --enable-plugins) if test "$mingw32" = "yes"; then
773                        error_exit "TCG plugins not currently supported on Windows platforms"
774                    else
775                        plugins="yes"
776                    fi
777  ;;
778  --disable-plugins) plugins="no"
779  ;;
780  --enable-containers) use_containers="yes"
781  ;;
782  --disable-containers) use_containers="no"
783  ;;
784  --gdb=*) gdb_bin="$optarg"
785  ;;
786  --enable-vfio-user-server) vfio_user_server="enabled"
787  ;;
788  --disable-vfio-user-server) vfio_user_server="disabled"
789  ;;
790  # everything else has the same name in configure and meson
791  --*) meson_option_parse "$opt" "$optarg"
792  ;;
793  esac
794done
795
796# test for any invalid configuration combinations
797if test "$plugins" = "yes" -a "$tcg" = "disabled"; then
798    error_exit "Can't enable plugins on non-TCG builds"
799fi
800
801case $git_submodules_action in
802    update|validate)
803        if test ! -e "$source_path/.git"; then
804            echo "ERROR: cannot $git_submodules_action git submodules without .git"
805            exit 1
806        fi
807    ;;
808    ignore)
809        if ! test -f "$source_path/ui/keycodemapdb/README"
810        then
811            echo
812            echo "ERROR: missing GIT submodules"
813            echo
814            if test -e "$source_path/.git"; then
815                echo "--with-git-submodules=ignore specified but submodules were not"
816                echo "checked out.  Please initialize and update submodules."
817            else
818                echo "This is not a GIT checkout but module content appears to"
819                echo "be missing. Do not use 'git archive' or GitHub download links"
820                echo "to acquire QEMU source archives. Non-GIT builds are only"
821                echo "supported with source archives linked from:"
822                echo
823                echo "  https://www.qemu.org/download/#source"
824                echo
825                echo "Developers working with GIT can use scripts/archive-source.sh"
826                echo "if they need to create valid source archives."
827            fi
828            echo
829            exit 1
830        fi
831    ;;
832    *)
833        echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'"
834        exit 1
835    ;;
836esac
837
838default_target_list=""
839mak_wilds=""
840
841if [ "$linux_user" != no ]; then
842    if [ "$targetos" = linux ] && [ -d "$source_path/linux-user/include/host/$cpu" ]; then
843        linux_user=yes
844    elif [ "$linux_user" = yes ]; then
845        error_exit "linux-user not supported on this architecture"
846    fi
847fi
848if [ "$bsd_user" != no ]; then
849    if [ "$bsd_user" = "" ]; then
850        test $targetos = freebsd && bsd_user=yes
851    fi
852    if [ "$bsd_user" = yes ] && ! [ -d "$source_path/bsd-user/$targetos" ]; then
853        error_exit "bsd-user not supported on this host OS"
854    fi
855fi
856if [ "$softmmu" = "yes" ]; then
857    mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak"
858fi
859if [ "$linux_user" = "yes" ]; then
860    mak_wilds="${mak_wilds} $source_path/configs/targets/*-linux-user.mak"
861fi
862if [ "$bsd_user" = "yes" ]; then
863    mak_wilds="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak"
864fi
865
866for config in $mak_wilds; do
867    target="$(basename "$config" .mak)"
868    if echo "$target_list_exclude" | grep -vq "$target"; then
869        default_target_list="${default_target_list} $target"
870    fi
871done
872
873if test x"$show_help" = x"yes" ; then
874cat << EOF
875
876Usage: configure [options]
877Options: [defaults in brackets after descriptions]
878
879Standard options:
880  --help                   print this message
881  --prefix=PREFIX          install in PREFIX [$prefix]
882  --target-list=LIST       set target list (default: build all)
883$(echo Available targets: $default_target_list | \
884  fold -s -w 53 | sed -e 's/^/                           /')
885  --target-list-exclude=LIST exclude a set of targets from the default target-list
886
887Advanced options (experts only):
888  --cross-prefix=PREFIX    use PREFIX for compile tools, PREFIX can be blank [$cross_prefix]
889  --cc=CC                  use C compiler CC [$cc]
890  --host-cc=CC             use C compiler CC [$host_cc] for code run at
891                           build time
892  --cxx=CXX                use C++ compiler CXX [$cxx]
893  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]
894  --extra-cflags=CFLAGS    append extra C compiler flags CFLAGS
895  --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS
896  --extra-objcflags=OBJCFLAGS append extra Objective C compiler flags OBJCFLAGS
897  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
898  --cross-cc-ARCH=CC       use compiler when building ARCH guest test cases
899  --cross-cc-cflags-ARCH=  use compiler flags when building ARCH guest tests
900  --cross-prefix-ARCH=PREFIX cross compiler prefix when building ARCH guest test cases
901  --make=MAKE              use specified make [$make]
902  --python=PYTHON          use specified python [$python]
903  --ninja=NINJA            use specified ninja [$ninja]
904  --smbd=SMBD              use specified smbd [$smbd]
905  --with-git=GIT           use specified git [$git]
906  --with-git-submodules=update   update git submodules (default if .git dir exists)
907  --with-git-submodules=validate fail if git submodules are not up to date
908  --with-git-submodules=ignore   do not update or check git submodules (default if no .git dir)
909  --static                 enable static build [$static]
910  --bindir=PATH            install binaries in PATH
911  --with-suffix=SUFFIX     suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix]
912  --without-default-features default all --enable-* options to "disabled"
913  --without-default-devices  do not include any device that is not needed to
914                           start the emulator (only use if you are including
915                           desired devices in configs/devices/)
916  --with-devices-ARCH=NAME override default configs/devices
917  --enable-debug           enable common debug build options
918  --disable-werror         disable compilation abort on warning
919  --cpu=CPU                Build for host CPU [$cpu]
920  --enable-plugins
921                           enable plugins via shared library loading
922  --disable-containers     don't use containers for cross-building
923  --gdb=GDB-path           gdb to use for gdbstub tests [$gdb_bin]
924EOF
925  meson_options_help
926cat << EOF
927  system          all system emulation targets
928  user            supported user emulation targets
929  linux-user      all linux usermode emulation targets
930  bsd-user        all BSD usermode emulation targets
931  pie             Position Independent Executables
932  debug-tcg       TCG debugging (default is disabled)
933
934NOTE: The object files are built at the place where configure is launched
935EOF
936exit 0
937fi
938
939# Remove old dependency files to make sure that they get properly regenerated
940rm -f ./*/config-devices.mak.d
941
942if test -z "$python"
943then
944    # If first_python is set, there was a binary somewhere even though
945    # it was not suitable.  Use it for the error message.
946    if test -n "$first_python"; then
947        error_exit "Cannot use '$first_python', Python >= 3.7 is required." \
948            "Use --python=/path/to/python to specify a supported Python."
949    else
950        error_exit "Python not found. Use --python=/path/to/python"
951    fi
952fi
953
954if ! has "$make"
955then
956    error_exit "GNU make ($make) not found"
957fi
958
959if ! check_py_version "$python"; then
960  error_exit "Cannot use '$python', Python >= 3.7 is required." \
961             "Use --python=/path/to/python to specify a supported Python." \
962             "Maybe try:" \
963             "  openSUSE Leap 15.3+: zypper install python39" \
964             "  CentOS 8: dnf install python38"
965fi
966
967# Resolve PATH
968python="$(command -v "$python")"
969
970# Create a Python virtual environment using our configured python.
971# The stdout of this script will be the location of a symlink that
972# points to the configured Python.
973# Entry point scripts for pip, meson, and sphinx are generated if those
974# packages are present.
975
976# Defaults assumed for now:
977# - venv is cleared if it exists already;
978# - venv is allowed to use system packages;
979# - all setup can be performed offline;
980# - missing packages may be fetched from PyPI,
981#   unless --disable-pypi is passed.
982# - pip is not installed into the venv when possible,
983#   but ensurepip is called as a fallback when necessary.
984
985echo "python determined to be '$python'"
986echo "python version: $($python --version)"
987
988python="$($python -B "${source_path}/python/scripts/mkvenv.py" create pyvenv)"
989if test "$?" -ne 0 ; then
990    error_exit "python venv creation failed"
991fi
992
993# Suppress writing compiled files
994python="$python -B"
995mkvenv="$python ${source_path}/python/scripts/mkvenv.py"
996
997mkvenv_flags=""
998if test "$pypi" = "enabled" ; then
999    mkvenv_flags="--online"
1000fi
1001
1002if ! $mkvenv ensure \
1003     $mkvenv_flags \
1004     --dir "${source_path}/python/wheels" \
1005     --diagnose "meson" \
1006     "meson>=0.63.0" ;
1007then
1008    exit 1
1009fi
1010
1011# At this point, we expect Meson to be installed and available.
1012# We expect mkvenv or pip to have created pyvenv/bin/meson for us.
1013# We ignore PATH completely here: we want to use the venv's Meson
1014# *exclusively*.
1015
1016meson="$(cd pyvenv/bin; pwd)/meson"
1017
1018# Conditionally ensure Sphinx is installed.
1019
1020mkvenv_flags=""
1021if test "$pypi" = "enabled" -a "$docs" = "enabled" ; then
1022    mkvenv_flags="--online"
1023fi
1024
1025if test "$docs" != "disabled" ; then
1026    if ! $mkvenv ensure \
1027         $mkvenv_flags \
1028         --diagnose "sphinx-build" \
1029         "sphinx>=1.6.0" "sphinx-rtd-theme>=0.5.0";
1030    then
1031        if test "$docs" = "enabled" ; then
1032            exit 1
1033        fi
1034        echo "Sphinx not found/usable, disabling docs."
1035        docs=disabled
1036    else
1037        docs=enabled
1038    fi
1039fi
1040
1041# Probe for ninja
1042
1043if test -z "$ninja"; then
1044    for c in ninja ninja-build samu; do
1045        if has $c; then
1046            ninja=$(command -v "$c")
1047            break
1048        fi
1049    done
1050    if test -z "$ninja"; then
1051      error_exit "Cannot find Ninja"
1052    fi
1053fi
1054
1055# Consult white-list to determine whether to enable werror
1056# by default.  Only enable by default for git builds
1057if test -z "$werror" ; then
1058    if test "$git_submodules_action" != "ignore" && \
1059        { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
1060        werror="yes"
1061    else
1062        werror="no"
1063    fi
1064fi
1065
1066if test "$targetos" = "bogus"; then
1067    # Now that we know that we're not printing the help and that
1068    # the compiler works (so the results of the check_defines we used
1069    # to identify the OS are reliable), if we didn't recognize the
1070    # host OS we should stop now.
1071    error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
1072fi
1073
1074if test "$static" = "yes" ; then
1075  if test "$plugins" = "yes"; then
1076    error_exit "static and plugins are mutually incompatible"
1077  else
1078    plugins="no"
1079  fi
1080fi
1081test "$plugins" = "" && plugins=yes
1082
1083cat > $TMPC << EOF
1084
1085#ifdef __linux__
1086#  define THREAD __thread
1087#else
1088#  define THREAD
1089#endif
1090static THREAD int tls_var;
1091int main(void) { return tls_var; }
1092EOF
1093
1094if test "$static" = "yes"; then
1095  if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then
1096    pie="yes"
1097  elif test "$pie" = "yes"; then
1098    error_exit "-static-pie not available due to missing toolchain support"
1099  else
1100    pie="no"
1101  fi
1102elif test "$pie" != "no"; then
1103  if compile_prog "-Werror -fPIE -DPIE" "-pie"; then
1104    pie="yes"
1105  elif test "$pie" = "yes"; then
1106    error_exit "PIE not available due to missing toolchain support"
1107  else
1108    echo "Disabling PIE due to missing toolchain support"
1109    pie="no"
1110  fi
1111fi
1112
1113##########################################
1114
1115if test -z "${target_list+xxx}" ; then
1116    default_targets=yes
1117    for target in $default_target_list; do
1118        target_list="$target_list $target"
1119    done
1120    target_list="${target_list# }"
1121else
1122    default_targets=no
1123    target_list=$(echo "$target_list" | sed -e 's/,/ /g')
1124    for target in $target_list; do
1125        # Check that we recognised the target name; this allows a more
1126        # friendly error message than if we let it fall through.
1127        case " $default_target_list " in
1128            *" $target "*)
1129                ;;
1130            *)
1131                error_exit "Unknown target name '$target'"
1132                ;;
1133        esac
1134    done
1135fi
1136
1137# see if system emulation was really requested
1138case " $target_list " in
1139  *"-softmmu "*) softmmu=yes
1140  ;;
1141  *) softmmu=no
1142  ;;
1143esac
1144
1145if test "$tcg" = "auto"; then
1146  if test -z "$target_list"; then
1147    tcg="disabled"
1148  else
1149    tcg="enabled"
1150  fi
1151fi
1152
1153if test "$tcg" = "enabled"; then
1154    git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
1155    git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
1156fi
1157
1158##########################################
1159# big/little endian test
1160cat > $TMPC << EOF
1161#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
1162# error LITTLE
1163#endif
1164int main(void) { return 0; }
1165EOF
1166
1167if ! compile_prog ; then
1168  bigendian="no"
1169else
1170  cat > $TMPC << EOF
1171#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
1172# error BIG
1173#endif
1174int main(void) { return 0; }
1175EOF
1176
1177  if ! compile_prog ; then
1178    bigendian="yes"
1179  else
1180    echo big/little test failed
1181    exit 1
1182  fi
1183fi
1184
1185##########################################
1186# fdt probe
1187
1188case "$fdt" in
1189  auto | enabled | internal)
1190    # Simpler to always update submodule, even if not needed.
1191    git_submodules="${git_submodules} dtc"
1192    ;;
1193esac
1194
1195########################################
1196# check if ccache is interfering with
1197# semantic analysis of macros
1198
1199unset CCACHE_CPP2
1200ccache_cpp2=no
1201cat > $TMPC << EOF
1202static const int Z = 1;
1203#define fn() ({ Z; })
1204#define TAUT(X) ((X) == Z)
1205#define PAREN(X, Y) (X == Y)
1206#define ID(X) (X)
1207int main(void)
1208{
1209    int x = 0, y = 0;
1210    x = ID(x);
1211    x = fn();
1212    fn();
1213    if (PAREN(x, y)) return 0;
1214    if (TAUT(Z)) return 0;
1215    return 0;
1216}
1217EOF
1218
1219if ! compile_object "-Werror"; then
1220    ccache_cpp2=yes
1221fi
1222
1223##########################################
1224# functions to probe cross compilers
1225
1226container="no"
1227runc=""
1228if test $use_containers = "yes" && (has "docker" || has "podman"); then
1229    case $($python "$source_path"/tests/docker/docker.py probe) in
1230        *docker) container=docker ;;
1231        podman) container=podman ;;
1232        no) container=no ;;
1233    esac
1234    if test "$container" != "no"; then
1235        docker_py="$python $source_path/tests/docker/docker.py --engine $container"
1236        runc=$($python "$source_path"/tests/docker/docker.py probe)
1237    fi
1238fi
1239
1240# cross compilers defaults, can be overridden with --cross-cc-ARCH
1241: ${cross_prefix_aarch64="aarch64-linux-gnu-"}
1242: ${cross_prefix_aarch64_be="$cross_prefix_aarch64"}
1243: ${cross_prefix_alpha="alpha-linux-gnu-"}
1244: ${cross_prefix_arm="arm-linux-gnueabihf-"}
1245: ${cross_prefix_armeb="$cross_prefix_arm"}
1246: ${cross_prefix_hexagon="hexagon-unknown-linux-musl-"}
1247: ${cross_prefix_loongarch64="loongarch64-unknown-linux-gnu-"}
1248: ${cross_prefix_hppa="hppa-linux-gnu-"}
1249: ${cross_prefix_i386="i686-linux-gnu-"}
1250: ${cross_prefix_m68k="m68k-linux-gnu-"}
1251: ${cross_prefix_microblaze="microblaze-linux-musl-"}
1252: ${cross_prefix_mips64el="mips64el-linux-gnuabi64-"}
1253: ${cross_prefix_mips64="mips64-linux-gnuabi64-"}
1254: ${cross_prefix_mipsel="mipsel-linux-gnu-"}
1255: ${cross_prefix_mips="mips-linux-gnu-"}
1256: ${cross_prefix_nios2="nios2-linux-gnu-"}
1257: ${cross_prefix_ppc="powerpc-linux-gnu-"}
1258: ${cross_prefix_ppc64="powerpc64-linux-gnu-"}
1259: ${cross_prefix_ppc64le="$cross_prefix_ppc64"}
1260: ${cross_prefix_riscv64="riscv64-linux-gnu-"}
1261: ${cross_prefix_s390x="s390x-linux-gnu-"}
1262: ${cross_prefix_sh4="sh4-linux-gnu-"}
1263: ${cross_prefix_sparc64="sparc64-linux-gnu-"}
1264: ${cross_prefix_sparc="$cross_prefix_sparc64"}
1265: ${cross_prefix_x86_64="x86_64-linux-gnu-"}
1266
1267: ${cross_cc_aarch64_be="$cross_cc_aarch64"}
1268: ${cross_cc_cflags_aarch64_be="-mbig-endian"}
1269: ${cross_cc_armeb="$cross_cc_arm"}
1270: ${cross_cc_cflags_armeb="-mbig-endian"}
1271: ${cross_cc_hexagon="hexagon-unknown-linux-musl-clang"}
1272: ${cross_cc_cflags_hexagon="-mv73 -O2 -static"}
1273: ${cross_cc_cflags_i386="-m32"}
1274: ${cross_cc_cflags_ppc="-m32 -mbig-endian"}
1275: ${cross_cc_cflags_ppc64="-m64 -mbig-endian"}
1276: ${cross_cc_ppc64le="$cross_cc_ppc64"}
1277: ${cross_cc_cflags_ppc64le="-m64 -mlittle-endian"}
1278: ${cross_cc_cflags_sparc64="-m64 -mcpu=ultrasparc"}
1279: ${cross_cc_sparc="$cross_cc_sparc64"}
1280: ${cross_cc_cflags_sparc="-m32 -mcpu=supersparc"}
1281: ${cross_cc_cflags_x86_64="-m64"}
1282
1283compute_target_variable() {
1284  eval "$2="
1285  if eval test -n "\"\${cross_prefix_$1}\""; then
1286    if eval has "\"\${cross_prefix_$1}\$3\""; then
1287      eval "$2=\"\${cross_prefix_$1}\$3\""
1288    fi
1289  fi
1290}
1291
1292have_target() {
1293  for i; do
1294    case " $target_list " in
1295      *" $i "*) return 0;;
1296      *) ;;
1297    esac
1298  done
1299  return 1
1300}
1301
1302# probe_target_compiler TARGET
1303#
1304# Look for a compiler for the given target, either native or cross.
1305# Set variables target_* if a compiler is found, and container_cross_*
1306# if a Docker-based cross-compiler image is known for the target.
1307# Set got_cross_cc to yes/no depending on whether a non-container-based
1308# compiler was found.
1309#
1310# If TARGET is a user-mode emulation target, also set build_static to
1311# "y" if static linking is possible.
1312#
1313probe_target_compiler() {
1314  # reset all output variables
1315  got_cross_cc=no
1316  container_image=
1317  container_hosts=
1318  container_cross_cc=
1319  container_cross_ar=
1320  container_cross_as=
1321  container_cross_ld=
1322  container_cross_nm=
1323  container_cross_objcopy=
1324  container_cross_ranlib=
1325  container_cross_strip=
1326
1327  target_arch=${1%%-*}
1328  case $target_arch in
1329    aarch64) container_hosts="x86_64 aarch64" ;;
1330    alpha) container_hosts=x86_64 ;;
1331    arm) container_hosts="x86_64 aarch64" ;;
1332    cris) container_hosts=x86_64 ;;
1333    hexagon) container_hosts=x86_64 ;;
1334    hppa) container_hosts=x86_64 ;;
1335    i386) container_hosts=x86_64 ;;
1336    loongarch64) container_hosts=x86_64 ;;
1337    m68k) container_hosts=x86_64 ;;
1338    microblaze) container_hosts=x86_64 ;;
1339    mips64el) container_hosts=x86_64 ;;
1340    mips64) container_hosts=x86_64 ;;
1341    mipsel) container_hosts=x86_64 ;;
1342    mips) container_hosts=x86_64 ;;
1343    nios2) container_hosts=x86_64 ;;
1344    ppc) container_hosts=x86_64 ;;
1345    ppc64|ppc64le) container_hosts=x86_64 ;;
1346    riscv64) container_hosts=x86_64 ;;
1347    s390x) container_hosts=x86_64 ;;
1348    sh4) container_hosts=x86_64 ;;
1349    sparc64) container_hosts=x86_64 ;;
1350    tricore) container_hosts=x86_64 ;;
1351    x86_64) container_hosts="aarch64 ppc64el x86_64" ;;
1352    xtensa*) container_hosts=x86_64 ;;
1353  esac
1354
1355  for host in $container_hosts; do
1356    test "$container" != no || continue
1357    test "$host" = "$cpu" || continue
1358    case $target_arch in
1359      aarch64)
1360        # We don't have any bigendian build tools so we only use this for AArch64
1361        container_image=debian-arm64-cross
1362        container_cross_prefix=aarch64-linux-gnu-
1363        container_cross_cc=${container_cross_prefix}gcc-10
1364        ;;
1365      alpha)
1366        container_image=debian-alpha-cross
1367        container_cross_prefix=alpha-linux-gnu-
1368        ;;
1369      arm)
1370        # We don't have any bigendian build tools so we only use this for ARM
1371        container_image=debian-armhf-cross
1372        container_cross_prefix=arm-linux-gnueabihf-
1373        ;;
1374      cris)
1375        container_image=fedora-cris-cross
1376        container_cross_prefix=cris-linux-gnu-
1377        ;;
1378      hexagon)
1379        container_image=debian-hexagon-cross
1380        container_cross_prefix=hexagon-unknown-linux-musl-
1381        container_cross_cc=${container_cross_prefix}clang
1382        ;;
1383      hppa)
1384        container_image=debian-hppa-cross
1385        container_cross_prefix=hppa-linux-gnu-
1386        ;;
1387      i386)
1388        container_image=fedora-i386-cross
1389        container_cross_prefix=
1390        ;;
1391      loongarch64)
1392        container_image=debian-loongarch-cross
1393        container_cross_prefix=loongarch64-unknown-linux-gnu-
1394        ;;
1395      m68k)
1396        container_image=debian-m68k-cross
1397        container_cross_prefix=m68k-linux-gnu-
1398        ;;
1399      microblaze)
1400        container_image=debian-microblaze-cross
1401        container_cross_prefix=microblaze-linux-musl-
1402        ;;
1403      mips64el)
1404        container_image=debian-mips64el-cross
1405        container_cross_prefix=mips64el-linux-gnuabi64-
1406        ;;
1407      mips64)
1408        container_image=debian-mips64-cross
1409        container_cross_prefix=mips64-linux-gnuabi64-
1410        ;;
1411      mipsel)
1412        container_image=debian-mipsel-cross
1413        container_cross_prefix=mipsel-linux-gnu-
1414        ;;
1415      mips)
1416        container_image=debian-mips-cross
1417        container_cross_prefix=mips-linux-gnu-
1418        ;;
1419      nios2)
1420        container_image=debian-nios2-cross
1421        container_cross_prefix=nios2-linux-gnu-
1422        ;;
1423      ppc)
1424        container_image=debian-powerpc-test-cross
1425        container_cross_prefix=powerpc-linux-gnu-
1426        container_cross_cc=${container_cross_prefix}gcc-10
1427        ;;
1428      ppc64|ppc64le)
1429        container_image=debian-powerpc-test-cross
1430        container_cross_prefix=powerpc${target_arch#ppc}-linux-gnu-
1431        container_cross_cc=${container_cross_prefix}gcc-10
1432        ;;
1433      riscv64)
1434        container_image=debian-riscv64-test-cross
1435        container_cross_prefix=riscv64-linux-gnu-
1436        ;;
1437      s390x)
1438        container_image=debian-s390x-cross
1439        container_cross_prefix=s390x-linux-gnu-
1440        ;;
1441      sh4)
1442        container_image=debian-sh4-cross
1443        container_cross_prefix=sh4-linux-gnu-
1444        ;;
1445      sparc64)
1446        container_image=debian-sparc64-cross
1447        container_cross_prefix=sparc64-linux-gnu-
1448        ;;
1449      tricore)
1450        container_image=debian-tricore-cross
1451        container_cross_prefix=tricore-
1452        container_cross_as=tricore-as
1453        container_cross_ld=tricore-ld
1454        break
1455        ;;
1456      x86_64)
1457        container_image=debian-amd64-cross
1458        container_cross_prefix=x86_64-linux-gnu-
1459        ;;
1460      xtensa*)
1461        container_hosts=x86_64
1462        container_image=debian-xtensa-cross
1463
1464        # default to the dc232b cpu
1465        container_cross_prefix=/opt/2020.07/xtensa-dc232b-elf/bin/xtensa-dc232b-elf-
1466        ;;
1467    esac
1468    : ${container_cross_cc:=${container_cross_prefix}gcc}
1469    : ${container_cross_ar:=${container_cross_prefix}ar}
1470    : ${container_cross_as:=${container_cross_prefix}as}
1471    : ${container_cross_ld:=${container_cross_prefix}ld}
1472    : ${container_cross_nm:=${container_cross_prefix}nm}
1473    : ${container_cross_objcopy:=${container_cross_prefix}objcopy}
1474    : ${container_cross_ranlib:=${container_cross_prefix}ranlib}
1475    : ${container_cross_strip:=${container_cross_prefix}strip}
1476  done
1477
1478  try=cross
1479  case "$target_arch:$cpu" in
1480    aarch64_be:aarch64 | \
1481    armeb:arm | \
1482    i386:x86_64 | \
1483    mips*:mips64 | \
1484    ppc*:ppc64 | \
1485    sparc:sparc64 | \
1486    "$cpu:$cpu")
1487      try='native cross' ;;
1488  esac
1489  eval "target_cflags=\${cross_cc_cflags_$target_arch}"
1490  for thistry in $try; do
1491    case $thistry in
1492    native)
1493      target_cc=$cc
1494      target_ccas=$ccas
1495      target_ar=$ar
1496      target_as=$as
1497      target_ld=$ld
1498      target_nm=$nm
1499      target_objcopy=$objcopy
1500      target_ranlib=$ranlib
1501      target_strip=$strip
1502      ;;
1503    cross)
1504      target_cc=
1505      if eval test -n "\"\${cross_cc_$target_arch}\""; then
1506        if eval has "\"\${cross_cc_$target_arch}\""; then
1507          eval "target_cc=\"\${cross_cc_$target_arch}\""
1508        fi
1509      else
1510        compute_target_variable $target_arch target_cc gcc
1511      fi
1512      target_ccas=$target_cc
1513      compute_target_variable $target_arch target_ar ar
1514      compute_target_variable $target_arch target_as as
1515      compute_target_variable $target_arch target_ld ld
1516      compute_target_variable $target_arch target_nm nm
1517      compute_target_variable $target_arch target_objcopy objcopy
1518      compute_target_variable $target_arch target_ranlib ranlib
1519      compute_target_variable $target_arch target_strip strip
1520      ;;
1521    esac
1522
1523    if test -n "$target_cc"; then
1524      case $target_arch in
1525        i386|x86_64)
1526          if $target_cc --version | grep -qi "clang"; then
1527            continue
1528          fi
1529          ;;
1530      esac
1531    elif test -n "$target_as" && test -n "$target_ld"; then
1532      # Special handling for assembler only targets
1533      case $target in
1534        tricore-softmmu)
1535          build_static=
1536          got_cross_cc=yes
1537          break
1538          ;;
1539        *)
1540          continue
1541          ;;
1542      esac
1543    else
1544      continue
1545    fi
1546
1547    write_c_skeleton
1548    case $1 in
1549      *-softmmu)
1550        if do_compiler "$target_cc" $target_cflags -o $TMPO -c $TMPC &&
1551          do_compiler "$target_cc" $target_cflags -r -nostdlib -o "${TMPDIR1}/${TMPB}2.o" "$TMPO" -lgcc; then
1552          got_cross_cc=yes
1553          break
1554        fi
1555        ;;
1556      *)
1557        if do_compiler "$target_cc" $target_cflags -o $TMPE $TMPC -static ; then
1558          build_static=y
1559          got_cross_cc=yes
1560          break
1561        fi
1562        if do_compiler "$target_cc" $target_cflags -o $TMPE $TMPC ; then
1563          build_static=
1564          got_cross_cc=yes
1565          break
1566        fi
1567        ;;
1568    esac
1569  done
1570  if test $got_cross_cc != yes; then
1571    build_static=
1572    target_cc=
1573    target_ccas=
1574    target_ar=
1575    target_as=
1576    target_ld=
1577    target_nm=
1578    target_objcopy=
1579    target_ranlib=
1580    target_strip=
1581  fi
1582  test -n "$target_cc"
1583}
1584
1585write_target_makefile() {
1586  echo "EXTRA_CFLAGS=$target_cflags"
1587  if test -z "$target_cc" && test -z "$target_as"; then
1588    test -z "$container_image" && error_exit "Internal error: could not find cross compiler for $1?"
1589    echo "$1: docker-image-$container_image" >> Makefile.prereqs
1590    if test -n "$container_cross_cc"; then
1591      echo "CC=$docker_py cc --cc $container_cross_cc -i qemu/$container_image -s $source_path --"
1592      echo "CCAS=$docker_py cc --cc $container_cross_cc -i qemu/$container_image -s $source_path --"
1593    fi
1594    echo "AR=$docker_py cc --cc $container_cross_ar -i qemu/$container_image -s $source_path --"
1595    echo "AS=$docker_py cc --cc $container_cross_as -i qemu/$container_image -s $source_path --"
1596    echo "LD=$docker_py cc --cc $container_cross_ld -i qemu/$container_image -s $source_path --"
1597    echo "NM=$docker_py cc --cc $container_cross_nm -i qemu/$container_image -s $source_path --"
1598    echo "OBJCOPY=$docker_py cc --cc $container_cross_objcopy -i qemu/$container_image -s $source_path --"
1599    echo "RANLIB=$docker_py cc --cc $container_cross_ranlib -i qemu/$container_image -s $source_path --"
1600    echo "STRIP=$docker_py cc --cc $container_cross_strip -i qemu/$container_image -s $source_path --"
1601  else
1602    if test -n "$target_cc"; then
1603      echo "CC=$target_cc"
1604      echo "CCAS=$target_ccas"
1605    fi
1606    if test -n "$target_ar"; then
1607      echo "AR=$target_ar"
1608    fi
1609    if test -n "$target_as"; then
1610      echo "AS=$target_as"
1611    fi
1612    if test -n "$target_ld"; then
1613      echo "LD=$target_ld"
1614    fi
1615    if test -n "$target_nm"; then
1616      echo "NM=$target_nm"
1617    fi
1618    if test -n "$target_objcopy"; then
1619      echo "OBJCOPY=$target_objcopy"
1620    fi
1621    if test -n "$target_ranlib"; then
1622      echo "RANLIB=$target_ranlib"
1623    fi
1624    if test -n "$target_strip"; then
1625      echo "STRIP=$target_strip"
1626    fi
1627  fi
1628}
1629
1630##########################################
1631# check for vfio_user_server
1632
1633case "$vfio_user_server" in
1634  enabled )
1635    if test "$git_submodules_action" != "ignore"; then
1636      git_submodules="${git_submodules} subprojects/libvfio-user"
1637    fi
1638    ;;
1639esac
1640
1641#######################################
1642# cross-compiled firmware targets
1643
1644# Set up build tree symlinks that point back into the source tree
1645# (these can be both files and directories).
1646# Caution: avoid adding files or directories here using wildcards. This
1647# will result in problems later if a new file matching the wildcard is
1648# added to the source tree -- nothing will cause configure to be rerun
1649# so the build tree will be missing the link back to the new file, and
1650# tests might fail. Prefer to keep the relevant files in their own
1651# directory and symlink the directory instead.
1652LINKS="Makefile"
1653LINKS="$LINKS docs/config"
1654LINKS="$LINKS pc-bios/optionrom/Makefile"
1655LINKS="$LINKS pc-bios/s390-ccw/Makefile"
1656LINKS="$LINKS pc-bios/vof/Makefile"
1657LINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
1658LINKS="$LINKS tests/avocado tests/data"
1659LINKS="$LINKS tests/qemu-iotests/check"
1660LINKS="$LINKS python"
1661LINKS="$LINKS contrib/plugins/Makefile "
1662for f in $LINKS ; do
1663    if [ -e "$source_path/$f" ]; then
1664        symlink "$source_path/$f" "$f"
1665    fi
1666done
1667
1668echo "# Automatically generated by configure - do not modify" > Makefile.prereqs
1669
1670# Mac OS X ships with a broken assembler
1671roms=
1672if have_target i386-softmmu x86_64-softmmu && \
1673        test "$targetos" != "darwin" && test "$targetos" != "sunos" && \
1674        test "$targetos" != "haiku" && \
1675        probe_target_compiler i386-softmmu; then
1676    roms="pc-bios/optionrom"
1677    config_mak=pc-bios/optionrom/config.mak
1678    echo "# Automatically generated by configure - do not modify" > $config_mak
1679    echo "TOPSRC_DIR=$source_path" >> $config_mak
1680    write_target_makefile >> $config_mak
1681fi
1682
1683if have_target ppc-softmmu ppc64-softmmu && \
1684        probe_target_compiler ppc-softmmu; then
1685    roms="$roms pc-bios/vof"
1686    config_mak=pc-bios/vof/config.mak
1687    echo "# Automatically generated by configure - do not modify" > $config_mak
1688    echo "SRC_DIR=$source_path/pc-bios/vof" >> $config_mak
1689    write_target_makefile >> $config_mak
1690fi
1691
1692# Only build s390-ccw bios if the compiler has -march=z900 or -march=z10
1693# (which is the lowest architecture level that Clang supports)
1694if have_target s390x-softmmu && probe_target_compiler s390x-softmmu; then
1695  write_c_skeleton
1696  do_compiler "$target_cc" $target_cc_cflags -march=z900 -o $TMPO -c $TMPC
1697  has_z900=$?
1698  if [ $has_z900 = 0 ] || do_compiler "$target_cc" $target_cc_cflags -march=z10 -msoft-float -Werror -o $TMPO -c $TMPC; then
1699    if [ $has_z900 != 0 ]; then
1700      echo "WARNING: Your compiler does not support the z900!"
1701      echo "         The s390-ccw bios will only work with guest CPUs >= z10."
1702    fi
1703    roms="$roms pc-bios/s390-ccw"
1704    config_mak=pc-bios/s390-ccw/config-host.mak
1705    echo "# Automatically generated by configure - do not modify" > $config_mak
1706    echo "SRC_PATH=$source_path/pc-bios/s390-ccw" >> $config_mak
1707    write_target_makefile >> $config_mak
1708    # SLOF is required for building the s390-ccw firmware on s390x,
1709    # since it is using the libnet code from SLOF for network booting.
1710    git_submodules="${git_submodules} roms/SLOF"
1711  fi
1712fi
1713
1714#######################################
1715# generate config-host.mak
1716
1717if ! (GIT="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then
1718    exit 1
1719fi
1720
1721config_host_mak="config-host.mak"
1722
1723echo "# Automatically generated by configure - do not modify" > $config_host_mak
1724echo >> $config_host_mak
1725
1726echo all: >> $config_host_mak
1727echo "GIT=$git" >> $config_host_mak
1728echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
1729echo "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak
1730
1731if test "$debug_tcg" = "yes" ; then
1732  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
1733fi
1734if test "$mingw32" = "yes" ; then
1735  echo "CONFIG_WIN32=y" >> $config_host_mak
1736  echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER-QEMU}" >> $config_host_mak
1737  echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO-Linux}" >> $config_host_mak
1738  echo "QEMU_GA_VERSION=${QEMU_GA_VERSION-$(cat "$source_path"/VERSION)}" >> $config_host_mak
1739else
1740  echo "CONFIG_POSIX=y" >> $config_host_mak
1741fi
1742
1743if test "$linux" = "yes" ; then
1744  echo "CONFIG_LINUX=y" >> $config_host_mak
1745fi
1746
1747if test "$darwin" = "yes" ; then
1748  echo "CONFIG_DARWIN=y" >> $config_host_mak
1749fi
1750
1751if test "$solaris" = "yes" ; then
1752  echo "CONFIG_SOLARIS=y" >> $config_host_mak
1753fi
1754echo "SRC_PATH=$source_path" >> $config_host_mak
1755echo "TARGET_DIRS=$target_list" >> $config_host_mak
1756
1757# XXX: suppress that
1758if [ "$bsd" = "yes" ] ; then
1759  echo "CONFIG_BSD=y" >> $config_host_mak
1760fi
1761
1762if test "$plugins" = "yes" ; then
1763    echo "CONFIG_PLUGIN=y" >> $config_host_mak
1764fi
1765
1766if test -n "$gdb_bin"; then
1767    gdb_version=$($gdb_bin --version | head -n 1)
1768    if version_ge ${gdb_version##* } 9.1; then
1769        echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
1770        gdb_arches=$($python "$source_path/scripts/probe-gdb-support.py" $gdb_bin)
1771    else
1772        gdb_bin=""
1773    fi
1774fi
1775
1776if test "$container" != no; then
1777    echo "ENGINE=$container" >> $config_host_mak
1778    echo "RUNC=$runc" >> $config_host_mak
1779fi
1780echo "ROMS=$roms" >> $config_host_mak
1781echo "MAKE=$make" >> $config_host_mak
1782echo "PYTHON=$python" >> $config_host_mak
1783echo "GENISOIMAGE=$genisoimage" >> $config_host_mak
1784echo "MESON=$meson" >> $config_host_mak
1785echo "NINJA=$ninja" >> $config_host_mak
1786echo "PKG_CONFIG=${pkg_config}" >> $config_host_mak
1787echo "CC=$cc" >> $config_host_mak
1788echo "EXESUF=$EXESUF" >> $config_host_mak
1789
1790# use included Linux headers
1791if test "$linux" = "yes" ; then
1792  mkdir -p linux-headers
1793  case "$cpu" in
1794  i386|x86_64)
1795    linux_arch=x86
1796    ;;
1797  ppc|ppc64)
1798    linux_arch=powerpc
1799    ;;
1800  s390x)
1801    linux_arch=s390
1802    ;;
1803  aarch64)
1804    linux_arch=arm64
1805    ;;
1806  loongarch*)
1807    linux_arch=loongarch
1808    ;;
1809  mips64)
1810    linux_arch=mips
1811    ;;
1812  *)
1813    # For most CPUs the kernel architecture name and QEMU CPU name match.
1814    linux_arch="$cpu"
1815    ;;
1816  esac
1817    # For non-KVM architectures we will not have asm headers
1818    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
1819      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
1820    fi
1821fi
1822
1823for target in $target_list; do
1824    target_dir="$target"
1825    target_name=$(echo $target | cut -d '-' -f 1)$EXESUF
1826    mkdir -p "$target_dir"
1827    case $target in
1828        *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;;
1829        *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;;
1830    esac
1831done
1832
1833if test "$default_targets" = "yes"; then
1834  echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak
1835fi
1836
1837if test "$ccache_cpp2" = "yes"; then
1838  echo "export CCACHE_CPP2=y" >> $config_host_mak
1839fi
1840
1841# tests/tcg configuration
1842(config_host_mak=tests/tcg/config-host.mak
1843mkdir -p tests/tcg
1844echo "# Automatically generated by configure - do not modify" > $config_host_mak
1845echo "SRC_PATH=$source_path" >> $config_host_mak
1846echo "HOST_CC=$host_cc" >> $config_host_mak
1847
1848# versioned checked in the main config_host.mak above
1849if test -n "$gdb_bin"; then
1850    echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
1851fi
1852if test "$plugins" = "yes" ; then
1853    echo "CONFIG_PLUGIN=y" >> $config_host_mak
1854fi
1855
1856tcg_tests_targets=
1857for target in $target_list; do
1858  arch=${target%%-*}
1859
1860  case $target in
1861    xtensa*-linux-user)
1862      # the toolchain is not complete with headers, only build softmmu tests
1863      continue
1864      ;;
1865    *-softmmu)
1866      test -f "$source_path/tests/tcg/$arch/Makefile.softmmu-target" || continue
1867      qemu="qemu-system-$arch"
1868      ;;
1869    *-linux-user|*-bsd-user)
1870      qemu="qemu-$arch"
1871      ;;
1872  esac
1873
1874  if probe_target_compiler $target || test -n "$container_image"; then
1875      test -n "$container_image" && build_static=y
1876      mkdir -p "tests/tcg/$target"
1877      config_target_mak=tests/tcg/$target/config-target.mak
1878      ln -sf "$source_path/tests/tcg/Makefile.target" "tests/tcg/$target/Makefile"
1879      echo "# Automatically generated by configure - do not modify" > "$config_target_mak"
1880      echo "TARGET_NAME=$arch" >> "$config_target_mak"
1881      echo "TARGET=$target" >> "$config_target_mak"
1882      write_target_makefile "build-tcg-tests-$target" >> "$config_target_mak"
1883      echo "BUILD_STATIC=$build_static" >> "$config_target_mak"
1884      echo "QEMU=$PWD/$qemu" >> "$config_target_mak"
1885
1886      # will GDB work with these binaries?
1887      if test "${gdb_arches#*$arch}" != "$gdb_arches"; then
1888          echo "HOST_GDB_SUPPORTS_ARCH=y" >> "$config_target_mak"
1889      fi
1890
1891      echo "run-tcg-tests-$target: $qemu\$(EXESUF)" >> Makefile.prereqs
1892      tcg_tests_targets="$tcg_tests_targets $target"
1893  fi
1894done
1895
1896if test "$tcg" = "enabled"; then
1897    echo "TCG_TESTS_TARGETS=$tcg_tests_targets" >> config-host.mak
1898fi
1899)
1900
1901if test "$skip_meson" = no; then
1902  cross="config-meson.cross.new"
1903  meson_quote() {
1904    test $# = 0 && return
1905    echo "'$(echo $* | sed "s/ /','/g")'"
1906  }
1907
1908  echo "# Automatically generated by configure - do not modify" > $cross
1909  echo "[properties]" >> $cross
1910
1911  # unroll any custom device configs
1912  for a in $device_archs; do
1913      eval "c=\$devices_${a}"
1914      echo "${a}-softmmu = '$c'" >> $cross
1915  done
1916
1917  echo "[built-in options]" >> $cross
1918  echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross
1919  echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross
1920  test -n "$objcc" && echo "objc_args = [$(meson_quote $OBJCFLAGS $EXTRA_OBJCFLAGS)]" >> $cross
1921  echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross
1922  echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross
1923  echo "[binaries]" >> $cross
1924  echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross
1925  test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross
1926  test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross
1927  echo "ar = [$(meson_quote $ar)]" >> $cross
1928  echo "nm = [$(meson_quote $nm)]" >> $cross
1929  echo "pkgconfig = [$(meson_quote $pkg_config)]" >> $cross
1930  echo "ranlib = [$(meson_quote $ranlib)]" >> $cross
1931  if has $sdl2_config; then
1932    echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross
1933  fi
1934  echo "strip = [$(meson_quote $strip)]" >> $cross
1935  echo "widl = [$(meson_quote $widl)]" >> $cross
1936  echo "windres = [$(meson_quote $windres)]" >> $cross
1937  echo "windmc = [$(meson_quote $windmc)]" >> $cross
1938  if test "$cross_compile" = "yes"; then
1939    cross_arg="--cross-file config-meson.cross"
1940    echo "[host_machine]" >> $cross
1941    echo "system = '$targetos'" >> $cross
1942    case "$cpu" in
1943        i386)
1944            echo "cpu_family = 'x86'" >> $cross
1945            ;;
1946        *)
1947            echo "cpu_family = '$cpu'" >> $cross
1948            ;;
1949    esac
1950    echo "cpu = '$cpu'" >> $cross
1951    if test "$bigendian" = "yes" ; then
1952        echo "endian = 'big'" >> $cross
1953    else
1954        echo "endian = 'little'" >> $cross
1955    fi
1956  else
1957    cross_arg="--native-file config-meson.cross"
1958  fi
1959  mv $cross config-meson.cross
1960
1961  rm -rf meson-private meson-info meson-logs
1962
1963  # Prevent meson from automatically downloading wrapped subprojects when missing.
1964  # You can use 'meson subprojects download' before running configure.
1965  meson_option_add "--wrap-mode=nodownload"
1966
1967  # Built-in options
1968  test "$bindir" != "bin" && meson_option_add "-Dbindir=$bindir"
1969  test "$default_feature" = no && meson_option_add -Dauto_features=disabled
1970  test "$static" = yes && meson_option_add -Dprefer_static=true
1971  test "$pie" = no && meson_option_add -Db_pie=false
1972  test "$werror" = yes && meson_option_add -Dwerror=true
1973
1974  # QEMU options
1975  test "$cfi" != false && meson_option_add "-Dcfi=$cfi"
1976  test "$docs" != auto && meson_option_add "-Ddocs=$docs"
1977  test "$fdt" != auto && meson_option_add "-Dfdt=$fdt"
1978  test -n "${LIB_FUZZING_ENGINE+xxx}" && meson_option_add "-Dfuzzing_engine=$LIB_FUZZING_ENGINE"
1979  test "$qemu_suffix" != qemu && meson_option_add "-Dqemu_suffix=$qemu_suffix"
1980  test "$smbd" != '' && meson_option_add "-Dsmbd=$smbd"
1981  test "$tcg" != enabled && meson_option_add "-Dtcg=$tcg"
1982  test "$vfio_user_server" != auto && meson_option_add "-Dvfio_user_server=$vfio_user_server"
1983  run_meson() {
1984    NINJA=$ninja $meson setup --prefix "$prefix" "$@" $cross_arg "$PWD" "$source_path"
1985  }
1986  eval run_meson $meson_options
1987  if test "$?" -ne 0 ; then
1988      error_exit "meson setup failed"
1989  fi
1990else
1991  if test -f meson-private/cmd_line.txt; then
1992    # Adjust old command line options that were removed
1993    # sed -i is not portable
1994    perl -i -ne '
1995      /^sphinx_build/ && next;
1996      print;' meson-private/cmd_line.txt
1997  fi
1998fi
1999
2000# Save the configure command line for later reuse.
2001cat <<EOD >config.status
2002#!/bin/sh
2003# Generated by configure.
2004# Run this file to recreate the current configuration.
2005# Compiler output produced by configure, useful for debugging
2006# configure, is in config.log if it exists.
2007EOD
2008
2009preserve_env() {
2010    envname=$1
2011
2012    eval envval=\$$envname
2013
2014    if test -n "$envval"
2015    then
2016	echo "$envname='$envval'" >> config.status
2017	echo "export $envname" >> config.status
2018    else
2019	echo "unset $envname" >> config.status
2020    fi
2021}
2022
2023# Preserve various env variables that influence what
2024# features/build target configure will detect
2025preserve_env AR
2026preserve_env AS
2027preserve_env CC
2028preserve_env CFLAGS
2029preserve_env CXX
2030preserve_env CXXFLAGS
2031preserve_env LD
2032preserve_env LDFLAGS
2033preserve_env LD_LIBRARY_PATH
2034preserve_env MAKE
2035preserve_env NM
2036preserve_env OBJCFLAGS
2037preserve_env OBJCOPY
2038preserve_env PATH
2039preserve_env PKG_CONFIG
2040preserve_env PKG_CONFIG_LIBDIR
2041preserve_env PKG_CONFIG_PATH
2042preserve_env PYTHON
2043preserve_env QEMU_GA_MANUFACTURER
2044preserve_env QEMU_GA_DISTRO
2045preserve_env QEMU_GA_VERSION
2046preserve_env SDL2_CONFIG
2047preserve_env SMBD
2048preserve_env STRIP
2049preserve_env WIDL
2050preserve_env WINDRES
2051preserve_env WINDMC
2052
2053printf "exec" >>config.status
2054for i in "$0" "$@"; do
2055  test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status
2056done
2057echo ' "$@"' >>config.status
2058chmod +x config.status
2059
2060rm -r "$TMPDIR1"
2061