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