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