target/rx: Remove unused ENV_OFFSET definition
[qemu/armbru.git] / configure
blob36d10d95bba8107f44f5a1fd4cc59dfbe5ee0179
1 #!/bin/sh
3 # qemu configure script (c) 2003 Fabrice Bellard
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
11 # Don't allow CCACHE, if present, to use cached results of compile tests!
12 export CCACHE_RECACHE=yes
14 # make source path absolute
15 source_path=$(cd "$(dirname -- "$0")"; pwd)
17 if test "$PWD" = "$source_path"
18 then
19 echo "Using './build' as the directory for build output"
21 MARKER=build/auto-created-by-configure
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
34 mkdir build
35 touch $MARKER
37 cat > GNUmakefile <<'EOF'
38 # This file is auto-generated by configure to support in-source tree
39 # 'make' command invocation
41 ifeq ($(MAKECMDGOALS),)
42 recurse: all
43 endif
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 ; \
54 force: ;
55 .PHONY: force
56 GNUmakefile: ;
58 EOF
59 cd build
60 exec $source_path/configure "$@"
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
76 TMPB="qemu-conf"
77 TMPC="${TMPDIR1}/${TMPB}.c"
78 TMPO="${TMPDIR1}/${TMPB}.o"
79 TMPCXX="${TMPDIR1}/${TMPB}.cxx"
80 TMPE="${TMPDIR1}/${TMPB}.exe"
82 rm -f config.log
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
91 quote_sh() {
92 printf "%s" "$1" | sed "s,','\\\\'',g; s,.*,'&',"
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
105 error_exit() {
106 print_error "$@"
107 exit 1
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
129 # Don't bother rerunning the compile if we were already using -Werror
130 case "$*" in
131 *-Werror*)
132 return 0
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."
143 do_cc() {
144 do_compiler "$cc" $CPU_CFLAGS "$@"
147 do_cxx() {
148 do_compiler "$cxx" $CPU_CFLAGS "$@"
151 # Append $2 to the variable named $1, with space separation
152 add_to() {
153 eval $1=\${$1:+\"\$$1 \"}\$2
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)
168 QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
170 esac
171 done
174 compile_object() {
175 local_cflags="$1"
176 do_cc $CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
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
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"
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
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
218 glob() {
219 eval test -z '"${1#'"$2"'}"'
222 ld_has() {
223 $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
226 if printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]";
227 then
228 error_exit "main directory cannot contain spaces nor colons"
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 block_drv_whitelist_tools="no"
242 host_cc="cc"
243 libs_qga=""
244 debug_info="yes"
245 lto="false"
246 stack_protector=""
247 safe_stack=""
248 use_containers="yes"
249 gdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
251 if test -e "$source_path/.git"
252 then
253 git_submodules_action="update"
254 else
255 git_submodules_action="ignore"
258 git_submodules="ui/keycodemapdb"
259 git="git"
261 # Don't accept a target_list environment variable.
262 unset target_list
263 unset target_list_exclude
265 # Default value for a variable defining feature "foo".
266 # * foo="no" feature will only be used if --enable-foo arg is given
267 # * foo="" feature will be searched for, and if found, will be used
268 # unless --disable-foo is given
269 # * foo="yes" this value will only be set by --enable-foo flag.
270 # feature will searched for,
271 # if not found, configure exits with error
273 # Always add --enable-foo and --disable-foo command line args.
274 # Distributions want to ensure that several features are compiled in, and it
275 # is impossible without a --enable-foo that exits if a feature is not found.
277 default_feature=""
278 # parse CC options second
279 for opt do
280 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
281 case "$opt" in
282 --without-default-features)
283 default_feature="no"
285 esac
286 done
288 EXTRA_CFLAGS=""
289 EXTRA_CXXFLAGS=""
290 EXTRA_LDFLAGS=""
292 xen_ctrl_version="$default_feature"
293 membarrier="$default_feature"
294 vhost_kernel="$default_feature"
295 vhost_net="$default_feature"
296 vhost_crypto="$default_feature"
297 vhost_scsi="$default_feature"
298 vhost_vsock="$default_feature"
299 vhost_user="no"
300 vhost_user_fs="$default_feature"
301 vhost_vdpa="$default_feature"
302 rdma="$default_feature"
303 pvrdma="$default_feature"
304 gprof="no"
305 debug_tcg="no"
306 debug="no"
307 sanitizers="no"
308 tsan="no"
309 fortify_source="$default_feature"
310 gcov="no"
311 EXESUF=""
312 modules="no"
313 module_upgrades="no"
314 prefix="/usr/local"
315 qemu_suffix="qemu"
316 profiler="no"
317 softmmu="yes"
318 linux_user=""
319 bsd_user=""
320 pkgversion=""
321 pie=""
322 qom_cast_debug="yes"
323 trace_backends="log"
324 trace_file="trace"
325 opengl="$default_feature"
326 cpuid_h="no"
327 avx2_opt="$default_feature"
328 guest_agent="$default_feature"
329 vss_win32_sdk="$default_feature"
330 win_sdk="no"
331 want_tools="$default_feature"
332 coroutine=""
333 coroutine_pool="$default_feature"
334 debug_stack_usage="no"
335 crypto_afalg="no"
336 tls_priority="NORMAL"
337 tpm="$default_feature"
338 live_block_migration=${default_feature:-yes}
339 numa="$default_feature"
340 replication=${default_feature:-yes}
341 bochs=${default_feature:-yes}
342 cloop=${default_feature:-yes}
343 dmg=${default_feature:-yes}
344 qcow1=${default_feature:-yes}
345 vdi=${default_feature:-yes}
346 vvfat=${default_feature:-yes}
347 qed=${default_feature:-yes}
348 parallels=${default_feature:-yes}
349 debug_mutex="no"
350 plugins="$default_feature"
351 rng_none="no"
352 secret_keyring="$default_feature"
353 meson=""
354 meson_args=""
355 ninja=""
356 gio="$default_feature"
357 skip_meson=no
358 slirp_smbd="$default_feature"
360 # The following Meson options are handled manually (still they
361 # are included in the automatically generated help message)
363 # 1. Track which submodules are needed
364 if test "$default_feature" = no ; then
365 capstone="disabled"
366 slirp="disabled"
367 else
368 capstone="auto"
369 slirp="auto"
371 fdt="auto"
373 # 2. Support --with/--without option
374 default_devices="true"
376 # 3. Automatically enable/disable other options
377 tcg="enabled"
378 cfi="false"
380 # 4. Detection partly done in configure
381 xen=${default_feature:+disabled}
383 # parse CC options second
384 for opt do
385 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
386 case "$opt" in
387 --cross-prefix=*) cross_prefix="$optarg"
388 cross_compile="yes"
390 --cc=*) CC="$optarg"
392 --cxx=*) CXX="$optarg"
394 --cpu=*) cpu="$optarg"
396 --extra-cflags=*)
397 EXTRA_CFLAGS="$EXTRA_CFLAGS $optarg"
398 EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg"
400 --extra-cxxflags=*) EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg"
402 --extra-ldflags=*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS $optarg"
404 --enable-debug-info) debug_info="yes"
406 --disable-debug-info) debug_info="no"
408 --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
410 --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-cflags-}; cc_arch=${cc_arch%%=*}
411 eval "cross_cc_cflags_${cc_arch}=\$optarg"
412 cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}"
414 --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
415 cc_archs="$cc_archs $cc_arch"
416 eval "cross_cc_${cc_arch}=\$optarg"
417 cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}"
419 esac
420 done
421 # OS specific
422 # Using uname is really, really broken. Once we have the right set of checks
423 # we can eliminate its usage altogether.
425 # Preferred compiler:
426 # ${CC} (if set)
427 # ${cross_prefix}gcc (if cross-prefix specified)
428 # system compiler
429 if test -z "${CC}${cross_prefix}"; then
430 cc="$host_cc"
431 else
432 cc="${CC-${cross_prefix}gcc}"
435 if test -z "${CXX}${cross_prefix}"; then
436 cxx="c++"
437 else
438 cxx="${CXX-${cross_prefix}g++}"
441 ar="${AR-${cross_prefix}ar}"
442 as="${AS-${cross_prefix}as}"
443 ccas="${CCAS-$cc}"
444 cpp="${CPP-$cc -E}"
445 objcopy="${OBJCOPY-${cross_prefix}objcopy}"
446 ld="${LD-${cross_prefix}ld}"
447 ranlib="${RANLIB-${cross_prefix}ranlib}"
448 nm="${NM-${cross_prefix}nm}"
449 strip="${STRIP-${cross_prefix}strip}"
450 windres="${WINDRES-${cross_prefix}windres}"
451 pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
452 query_pkg_config() {
453 "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
455 pkg_config=query_pkg_config
456 sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
458 # default flags for all hosts
459 # We use -fwrapv to tell the compiler that we require a C dialect where
460 # left shift of signed integers is well defined and has the expected
461 # 2s-complement style results. (Both clang and gcc agree that it
462 # provides these semantics.)
463 QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv"
464 QEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
465 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
466 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
468 QEMU_LDFLAGS=
470 # Flags that are needed during configure but later taken care of by Meson
471 CONFIGURE_CFLAGS="-std=gnu11 -Wall"
472 CONFIGURE_LDFLAGS=
475 check_define() {
476 cat > $TMPC <<EOF
477 #if !defined($1)
478 #error $1 not defined
479 #endif
480 int main(void) { return 0; }
482 compile_object
485 check_include() {
486 cat > $TMPC <<EOF
487 #include <$1>
488 int main(void) { return 0; }
490 compile_object
493 write_c_skeleton() {
494 cat > $TMPC <<EOF
495 int main(void) { return 0; }
499 if check_define __linux__ ; then
500 targetos=linux
501 elif check_define _WIN32 ; then
502 targetos=windows
503 elif check_define __OpenBSD__ ; then
504 targetos=openbsd
505 elif check_define __sun__ ; then
506 targetos=sunos
507 elif check_define __HAIKU__ ; then
508 targetos=haiku
509 elif check_define __FreeBSD__ ; then
510 targetos=freebsd
511 elif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
512 targetos=gnu/kfreebsd
513 elif check_define __DragonFly__ ; then
514 targetos=dragonfly
515 elif check_define __NetBSD__; then
516 targetos=netbsd
517 elif check_define __APPLE__; then
518 targetos=darwin
519 else
520 # This is a fatal error, but don't report it yet, because we
521 # might be going to just print the --help text, or it might
522 # be the result of a missing compiler.
523 targetos=bogus
526 # OS specific
528 mingw32="no"
529 bsd="no"
530 linux="no"
531 solaris="no"
532 case $targetos in
533 windows)
534 mingw32="yes"
535 plugins="no"
536 pie="no"
538 gnu/kfreebsd)
539 bsd="yes"
541 freebsd)
542 bsd="yes"
543 make="${MAKE-gmake}"
544 # needed for kinfo_getvmmap(3) in libutil.h
546 dragonfly)
547 bsd="yes"
548 make="${MAKE-gmake}"
550 netbsd)
551 bsd="yes"
552 make="${MAKE-gmake}"
554 openbsd)
555 bsd="yes"
556 make="${MAKE-gmake}"
558 darwin)
559 bsd="yes"
560 darwin="yes"
561 # Disable attempts to use ObjectiveC features in os/object.h since they
562 # won't work when we're compiling with gcc as a C compiler.
563 QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
565 sunos)
566 solaris="yes"
567 make="${MAKE-gmake}"
568 smbd="${SMBD-/usr/sfw/sbin/smbd}"
569 # needed for CMSG_ macros in sys/socket.h
570 QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
571 # needed for TIOCWIN* defines in termios.h
572 QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
573 # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
574 # Note that this check is broken for cross-compilation: if you're
575 # cross-compiling to one of these OSes then you'll need to specify
576 # the correct CPU with the --cpu option.
577 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
578 cpu="x86_64"
581 haiku)
582 pie="no"
583 QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE -fPIC $QEMU_CFLAGS"
585 linux)
586 linux="yes"
587 vhost_user=${default_feature:-yes}
589 esac
591 if test ! -z "$cpu" ; then
592 # command line argument
594 elif check_define __i386__ ; then
595 cpu="i386"
596 elif check_define __x86_64__ ; then
597 if check_define __ILP32__ ; then
598 cpu="x32"
599 else
600 cpu="x86_64"
602 elif check_define __sparc__ ; then
603 if check_define __arch64__ ; then
604 cpu="sparc64"
605 else
606 cpu="sparc"
608 elif check_define _ARCH_PPC ; then
609 if check_define _ARCH_PPC64 ; then
610 if check_define _LITTLE_ENDIAN ; then
611 cpu="ppc64le"
612 else
613 cpu="ppc64"
615 else
616 cpu="ppc"
618 elif check_define __mips__ ; then
619 cpu="mips"
620 elif check_define __s390__ ; then
621 if check_define __s390x__ ; then
622 cpu="s390x"
623 else
624 cpu="s390"
626 elif check_define __riscv ; then
627 cpu="riscv"
628 elif check_define __arm__ ; then
629 cpu="arm"
630 elif check_define __aarch64__ ; then
631 cpu="aarch64"
632 elif check_define __loongarch64 ; then
633 cpu="loongarch64"
634 else
635 cpu=$(uname -m)
638 # Normalise host CPU name, set multilib cflags
639 # Note that this case should only have supported host CPUs, not guests.
640 case "$cpu" in
641 armv*b|armv*l|arm)
642 cpu="arm" ;;
644 i386|i486|i586|i686|i86pc|BePC)
645 cpu="i386"
646 CPU_CFLAGS="-m32" ;;
647 x32)
648 cpu="x86_64"
649 CPU_CFLAGS="-mx32" ;;
650 x86_64|amd64)
651 cpu="x86_64"
652 # ??? Only extremely old AMD cpus do not have cmpxchg16b.
653 # If we truly care, we should simply detect this case at
654 # runtime and generate the fallback to serial emulation.
655 CPU_CFLAGS="-m64 -mcx16" ;;
657 mips*)
658 cpu="mips" ;;
660 ppc)
661 CPU_CFLAGS="-m32" ;;
662 ppc64)
663 CPU_CFLAGS="-m64 -mbig" ;;
664 ppc64le)
665 cpu="ppc64"
666 CPU_CFLAGS="-m64 -mlittle" ;;
668 s390)
669 CPU_CFLAGS="-m31" ;;
670 s390x)
671 CPU_CFLAGS="-m64" ;;
673 sparc|sun4[cdmuv])
674 cpu="sparc"
675 CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc" ;;
676 sparc64)
677 CPU_CFLAGS="-m64 -mcpu=ultrasparc" ;;
678 esac
680 : ${make=${MAKE-make}}
682 # We prefer python 3.x. A bare 'python' is traditionally
683 # python 2.x, but some distros have it as python 3.x, so
684 # we check that too
685 python=
686 explicit_python=no
687 for binary in "${PYTHON-python3}" python
689 if has "$binary"
690 then
691 python=$(command -v "$binary")
692 break
694 done
697 # Check for ancillary tools used in testing
698 genisoimage=
699 for binary in genisoimage mkisofs
701 if has $binary
702 then
703 genisoimage=$(command -v "$binary")
704 break
706 done
708 # Default objcc to clang if available, otherwise use CC
709 if has clang; then
710 objcc=clang
711 else
712 objcc="$cc"
715 if test "$mingw32" = "yes" ; then
716 EXESUF=".exe"
717 # MinGW needs -mthreads for TLS and macro _MT.
718 CONFIGURE_CFLAGS="-mthreads $CONFIGURE_CFLAGS"
719 write_c_skeleton;
720 prefix="/qemu"
721 qemu_suffix=""
722 libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
725 werror=""
727 . $source_path/scripts/meson-buildoptions.sh
729 meson_options=
730 meson_option_parse() {
731 meson_options="$meson_options $(_meson_option_parse "$@")"
732 if test $? -eq 1; then
733 echo "ERROR: unknown option $1"
734 echo "Try '$0 --help' for more information"
735 exit 1
739 for opt do
740 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
741 case "$opt" in
742 --help|-h) show_help=yes
744 --version|-V) exec cat $source_path/VERSION
746 --prefix=*) prefix="$optarg"
748 --interp-prefix=*) interp_prefix="$optarg"
750 --cross-prefix=*)
752 --cc=*)
754 --host-cc=*) host_cc="$optarg"
756 --cxx=*)
758 --iasl=*) iasl="$optarg"
760 --objcc=*) objcc="$optarg"
762 --make=*) make="$optarg"
764 --install=*)
766 --python=*) python="$optarg" ; explicit_python=yes
768 --sphinx-build=*) sphinx_build="$optarg"
770 --skip-meson) skip_meson=yes
772 --meson=*) meson="$optarg"
774 --ninja=*) ninja="$optarg"
776 --smbd=*) smbd="$optarg"
778 --extra-cflags=*)
780 --extra-cxxflags=*)
782 --extra-ldflags=*)
784 --enable-debug-info)
786 --disable-debug-info)
788 --cross-cc-*)
790 --enable-modules)
791 modules="yes"
793 --disable-modules)
794 modules="no"
796 --disable-module-upgrades) module_upgrades="no"
798 --enable-module-upgrades) module_upgrades="yes"
800 --cpu=*)
802 --target-list=*) target_list="$optarg"
803 if test "$target_list_exclude"; then
804 error_exit "Can't mix --target-list with --target-list-exclude"
807 --target-list-exclude=*) target_list_exclude="$optarg"
808 if test "$target_list"; then
809 error_exit "Can't mix --target-list-exclude with --target-list"
812 --with-trace-file=*) trace_file="$optarg"
814 --with-default-devices) default_devices="true"
816 --without-default-devices) default_devices="false"
818 --with-devices-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --with-devices-FOO option"
820 --with-devices-*) device_arch=${opt#--with-devices-};
821 device_arch=${device_arch%%=*}
822 cf=$source_path/configs/devices/$device_arch-softmmu/$optarg.mak
823 if test -f "$cf"; then
824 device_archs="$device_archs $device_arch"
825 eval "devices_${device_arch}=\$optarg"
826 else
827 error_exit "File $cf does not exist"
830 --without-default-features) # processed above
832 --enable-gprof) gprof="yes"
834 --enable-gcov) gcov="yes"
836 --static)
837 static="yes"
838 QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
840 --mandir=*) mandir="$optarg"
842 --bindir=*) bindir="$optarg"
844 --libdir=*) libdir="$optarg"
846 --libexecdir=*) libexecdir="$optarg"
848 --includedir=*) includedir="$optarg"
850 --datadir=*) datadir="$optarg"
852 --with-suffix=*) qemu_suffix="$optarg"
854 --docdir=*) docdir="$optarg"
856 --localedir=*) localedir="$optarg"
858 --sysconfdir=*) sysconfdir="$optarg"
860 --localstatedir=*) local_statedir="$optarg"
862 --firmwarepath=*) firmwarepath="$optarg"
864 --host=*|--build=*|\
865 --disable-dependency-tracking|\
866 --sbindir=*|--sharedstatedir=*|\
867 --oldincludedir=*|--datarootdir=*|--infodir=*|\
868 --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
869 # These switches are silently ignored, for compatibility with
870 # autoconf-generated configure scripts. This allows QEMU's
871 # configure to be used by RPM and similar macros that set
872 # lots of directory switches by default.
874 --disable-qom-cast-debug) qom_cast_debug="no"
876 --enable-qom-cast-debug) qom_cast_debug="yes"
878 --audio-drv-list=*) audio_drv_list="$optarg"
880 --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
882 --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
884 --enable-block-drv-whitelist-in-tools) block_drv_whitelist_tools="yes"
886 --disable-block-drv-whitelist-in-tools) block_drv_whitelist_tools="no"
888 --enable-debug-tcg) debug_tcg="yes"
890 --disable-debug-tcg) debug_tcg="no"
892 --enable-debug)
893 # Enable debugging options that aren't excessively noisy
894 debug_tcg="yes"
895 debug_mutex="yes"
896 debug="yes"
897 fortify_source="no"
899 --enable-sanitizers) sanitizers="yes"
901 --disable-sanitizers) sanitizers="no"
903 --enable-tsan) tsan="yes"
905 --disable-tsan) tsan="no"
907 --disable-slirp) slirp="disabled"
909 --enable-slirp) slirp="enabled"
911 --enable-slirp=git) slirp="internal"
913 --enable-slirp=*) slirp="$optarg"
915 --disable-xen) xen="disabled"
917 --enable-xen) xen="enabled"
919 --disable-tcg) tcg="disabled"
920 plugins="no"
922 --enable-tcg) tcg="enabled"
924 --enable-profiler) profiler="yes"
926 --disable-system) softmmu="no"
928 --enable-system) softmmu="yes"
930 --disable-user)
931 linux_user="no" ;
932 bsd_user="no" ;
934 --enable-user) ;;
935 --disable-linux-user) linux_user="no"
937 --enable-linux-user) linux_user="yes"
939 --disable-bsd-user) bsd_user="no"
941 --enable-bsd-user) bsd_user="yes"
943 --enable-pie) pie="yes"
945 --disable-pie) pie="no"
947 --enable-werror) werror="yes"
949 --disable-werror) werror="no"
951 --enable-lto) lto="true"
953 --disable-lto) lto="false"
955 --enable-stack-protector) stack_protector="yes"
957 --disable-stack-protector) stack_protector="no"
959 --enable-safe-stack) safe_stack="yes"
961 --disable-safe-stack) safe_stack="no"
963 --enable-cfi)
964 cfi="true";
965 lto="true";
967 --disable-cfi) cfi="false"
969 --disable-fdt) fdt="disabled"
971 --enable-fdt) fdt="enabled"
973 --enable-fdt=git) fdt="internal"
975 --enable-fdt=*) fdt="$optarg"
977 --disable-membarrier) membarrier="no"
979 --enable-membarrier) membarrier="yes"
981 --with-pkgversion=*) pkgversion="$optarg"
983 --with-coroutine=*) coroutine="$optarg"
985 --disable-coroutine-pool) coroutine_pool="no"
987 --enable-coroutine-pool) coroutine_pool="yes"
989 --enable-debug-stack-usage) debug_stack_usage="yes"
991 --enable-crypto-afalg) crypto_afalg="yes"
993 --disable-crypto-afalg) crypto_afalg="no"
995 --disable-vhost-net) vhost_net="no"
997 --enable-vhost-net) vhost_net="yes"
999 --disable-vhost-crypto) vhost_crypto="no"
1001 --enable-vhost-crypto) vhost_crypto="yes"
1003 --disable-vhost-scsi) vhost_scsi="no"
1005 --enable-vhost-scsi) vhost_scsi="yes"
1007 --disable-vhost-vsock) vhost_vsock="no"
1009 --enable-vhost-vsock) vhost_vsock="yes"
1011 --disable-vhost-user-fs) vhost_user_fs="no"
1013 --enable-vhost-user-fs) vhost_user_fs="yes"
1015 --disable-opengl) opengl="no"
1017 --enable-opengl) opengl="yes"
1019 --disable-zlib-test)
1021 --enable-guest-agent) guest_agent="yes"
1023 --disable-guest-agent) guest_agent="no"
1025 --with-vss-sdk) vss_win32_sdk=""
1027 --with-vss-sdk=*) vss_win32_sdk="$optarg"
1029 --without-vss-sdk) vss_win32_sdk="no"
1031 --with-win-sdk) win_sdk=""
1033 --with-win-sdk=*) win_sdk="$optarg"
1035 --without-win-sdk) win_sdk="no"
1037 --enable-tools) want_tools="yes"
1039 --disable-tools) want_tools="no"
1041 --disable-avx2) avx2_opt="no"
1043 --enable-avx2) avx2_opt="yes"
1045 --disable-avx512f) avx512f_opt="no"
1047 --enable-avx512f) avx512f_opt="yes"
1049 --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
1050 echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1052 --enable-vhdx|--disable-vhdx)
1053 echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1055 --enable-uuid|--disable-uuid)
1056 echo "$0: $opt is obsolete, UUID support is always built" >&2
1058 --tls-priority=*) tls_priority="$optarg"
1060 --enable-rdma) rdma="yes"
1062 --disable-rdma) rdma="no"
1064 --enable-pvrdma) pvrdma="yes"
1066 --disable-pvrdma) pvrdma="no"
1068 --disable-tpm) tpm="no"
1070 --enable-tpm) tpm="yes"
1072 --disable-live-block-migration) live_block_migration="no"
1074 --enable-live-block-migration) live_block_migration="yes"
1076 --disable-numa) numa="no"
1078 --enable-numa) numa="yes"
1080 --disable-replication) replication="no"
1082 --enable-replication) replication="yes"
1084 --disable-bochs) bochs="no"
1086 --enable-bochs) bochs="yes"
1088 --disable-cloop) cloop="no"
1090 --enable-cloop) cloop="yes"
1092 --disable-dmg) dmg="no"
1094 --enable-dmg) dmg="yes"
1096 --disable-qcow1) qcow1="no"
1098 --enable-qcow1) qcow1="yes"
1100 --disable-vdi) vdi="no"
1102 --enable-vdi) vdi="yes"
1104 --disable-vvfat) vvfat="no"
1106 --enable-vvfat) vvfat="yes"
1108 --disable-qed) qed="no"
1110 --enable-qed) qed="yes"
1112 --disable-parallels) parallels="no"
1114 --enable-parallels) parallels="yes"
1116 --disable-vhost-user) vhost_user="no"
1118 --enable-vhost-user) vhost_user="yes"
1120 --disable-vhost-vdpa) vhost_vdpa="no"
1122 --enable-vhost-vdpa) vhost_vdpa="yes"
1124 --disable-vhost-kernel) vhost_kernel="no"
1126 --enable-vhost-kernel) vhost_kernel="yes"
1128 --disable-capstone) capstone="disabled"
1130 --enable-capstone) capstone="enabled"
1132 --enable-capstone=git) capstone="internal"
1134 --enable-capstone=*) capstone="$optarg"
1136 --with-git=*) git="$optarg"
1138 --with-git-submodules=*)
1139 git_submodules_action="$optarg"
1141 --enable-debug-mutex) debug_mutex=yes
1143 --disable-debug-mutex) debug_mutex=no
1145 --enable-plugins) if test "$mingw32" = "yes"; then
1146 error_exit "TCG plugins not currently supported on Windows platforms"
1147 else
1148 plugins="yes"
1151 --disable-plugins) plugins="no"
1153 --enable-containers) use_containers="yes"
1155 --disable-containers) use_containers="no"
1157 --gdb=*) gdb_bin="$optarg"
1159 --enable-rng-none) rng_none=yes
1161 --disable-rng-none) rng_none=no
1163 --enable-keyring) secret_keyring="yes"
1165 --disable-keyring) secret_keyring="no"
1167 --enable-gio) gio=yes
1169 --disable-gio) gio=no
1171 --enable-slirp-smbd) slirp_smbd=yes
1173 --disable-slirp-smbd) slirp_smbd=no
1175 # backwards compatibility options
1176 --enable-trace-backend=*) meson_option_parse "--enable-trace-backends=$optarg" "$optarg"
1178 --disable-blobs) meson_option_parse --disable-install-blobs ""
1180 --enable-tcmalloc) meson_option_parse --enable-malloc=tcmalloc tcmalloc
1182 --enable-jemalloc) meson_option_parse --enable-malloc=jemalloc jemalloc
1184 # everything else has the same name in configure and meson
1185 --enable-* | --disable-*) meson_option_parse "$opt" "$optarg"
1188 echo "ERROR: unknown option $opt"
1189 echo "Try '$0 --help' for more information"
1190 exit 1
1192 esac
1193 done
1195 # test for any invalid configuration combinations
1196 if test "$plugins" = "yes" -a "$tcg" = "disabled"; then
1197 error_exit "Can't enable plugins on non-TCG builds"
1200 case $git_submodules_action in
1201 update|validate)
1202 if test ! -e "$source_path/.git"; then
1203 echo "ERROR: cannot $git_submodules_action git submodules without .git"
1204 exit 1
1207 ignore)
1208 if ! test -f "$source_path/ui/keycodemapdb/README"
1209 then
1210 echo
1211 echo "ERROR: missing GIT submodules"
1212 echo
1213 if test -e "$source_path/.git"; then
1214 echo "--with-git-submodules=ignore specified but submodules were not"
1215 echo "checked out. Please initialize and update submodules."
1216 else
1217 echo "This is not a GIT checkout but module content appears to"
1218 echo "be missing. Do not use 'git archive' or GitHub download links"
1219 echo "to acquire QEMU source archives. Non-GIT builds are only"
1220 echo "supported with source archives linked from:"
1221 echo
1222 echo " https://www.qemu.org/download/#source"
1223 echo
1224 echo "Developers working with GIT can use scripts/archive-source.sh"
1225 echo "if they need to create valid source archives."
1227 echo
1228 exit 1
1232 echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'"
1233 exit 1
1235 esac
1237 libdir="${libdir:-$prefix/lib}"
1238 libexecdir="${libexecdir:-$prefix/libexec}"
1239 includedir="${includedir:-$prefix/include}"
1241 if test "$mingw32" = "yes" ; then
1242 bindir="${bindir:-$prefix}"
1243 else
1244 bindir="${bindir:-$prefix/bin}"
1246 mandir="${mandir:-$prefix/share/man}"
1247 datadir="${datadir:-$prefix/share}"
1248 docdir="${docdir:-$prefix/share/doc}"
1249 sysconfdir="${sysconfdir:-$prefix/etc}"
1250 local_statedir="${local_statedir:-$prefix/var}"
1251 firmwarepath="${firmwarepath:-$datadir/qemu-firmware}"
1252 localedir="${localedir:-$datadir/locale}"
1254 if eval test -z "\${cross_cc_$cpu}"; then
1255 eval "cross_cc_${cpu}=\$cc"
1256 cross_cc_vars="$cross_cc_vars cross_cc_${cpu}"
1259 default_target_list=""
1260 mak_wilds=""
1262 if [ "$linux_user" != no ]; then
1263 if [ "$targetos" = linux ] && [ -d $source_path/linux-user/include/host/$cpu ]; then
1264 linux_user=yes
1265 elif [ "$linux_user" = yes ]; then
1266 error_exit "linux-user not supported on this architecture"
1269 if [ "$bsd_user" != no ]; then
1270 if [ "$bsd_user" = "" ]; then
1271 test $targetos = freebsd && bsd_user=yes
1273 if [ "$bsd_user" = yes ] && ! [ -d $source_path/bsd-user/$targetos ]; then
1274 error_exit "bsd-user not supported on this host OS"
1277 if [ "$softmmu" = "yes" ]; then
1278 mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak"
1280 if [ "$linux_user" = "yes" ]; then
1281 mak_wilds="${mak_wilds} $source_path/configs/targets/*-linux-user.mak"
1283 if [ "$bsd_user" = "yes" ]; then
1284 mak_wilds="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak"
1287 for config in $mak_wilds; do
1288 target="$(basename "$config" .mak)"
1289 if echo "$target_list_exclude" | grep -vq "$target"; then
1290 default_target_list="${default_target_list} $target"
1292 done
1294 if test x"$show_help" = x"yes" ; then
1295 cat << EOF
1297 Usage: configure [options]
1298 Options: [defaults in brackets after descriptions]
1300 Standard options:
1301 --help print this message
1302 --prefix=PREFIX install in PREFIX [$prefix]
1303 --interp-prefix=PREFIX where to find shared libraries, etc.
1304 use %M for cpu name [$interp_prefix]
1305 --target-list=LIST set target list (default: build all)
1306 $(echo Available targets: $default_target_list | \
1307 fold -s -w 53 | sed -e 's/^/ /')
1308 --target-list-exclude=LIST exclude a set of targets from the default target-list
1310 Advanced options (experts only):
1311 --cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix]
1312 --cc=CC use C compiler CC [$cc]
1313 --iasl=IASL use ACPI compiler IASL [$iasl]
1314 --host-cc=CC use C compiler CC [$host_cc] for code run at
1315 build time
1316 --cxx=CXX use C++ compiler CXX [$cxx]
1317 --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
1318 --extra-cflags=CFLAGS append extra C compiler flags CFLAGS
1319 --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS
1320 --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS
1321 --cross-cc-ARCH=CC use compiler when building ARCH guest test cases
1322 --cross-cc-cflags-ARCH= use compiler flags when building ARCH guest tests
1323 --make=MAKE use specified make [$make]
1324 --python=PYTHON use specified python [$python]
1325 --sphinx-build=SPHINX use specified sphinx-build [$sphinx_build]
1326 --meson=MESON use specified meson [$meson]
1327 --ninja=NINJA use specified ninja [$ninja]
1328 --smbd=SMBD use specified smbd [$smbd]
1329 --with-git=GIT use specified git [$git]
1330 --with-git-submodules=update update git submodules (default if .git dir exists)
1331 --with-git-submodules=validate fail if git submodules are not up to date
1332 --with-git-submodules=ignore do not update or check git submodules (default if no .git dir)
1333 --static enable static build [$static]
1334 --mandir=PATH install man pages in PATH
1335 --datadir=PATH install firmware in PATH/$qemu_suffix
1336 --localedir=PATH install translation in PATH/$qemu_suffix
1337 --docdir=PATH install documentation in PATH/$qemu_suffix
1338 --bindir=PATH install binaries in PATH
1339 --libdir=PATH install libraries in PATH
1340 --libexecdir=PATH install helper binaries in PATH
1341 --sysconfdir=PATH install config in PATH/$qemu_suffix
1342 --localstatedir=PATH install local state in PATH (set at runtime on win32)
1343 --firmwarepath=PATH search PATH for firmware files
1344 --efi-aarch64=PATH PATH of efi file to use for aarch64 VMs.
1345 --with-suffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix]
1346 --with-pkgversion=VERS use specified string as sub-version of the package
1347 --without-default-features default all --enable-* options to "disabled"
1348 --without-default-devices do not include any device that is not needed to
1349 start the emulator (only use if you are including
1350 desired devices in configs/devices/)
1351 --with-devices-ARCH=NAME override default configs/devices
1352 --enable-debug enable common debug build options
1353 --enable-sanitizers enable default sanitizers
1354 --enable-tsan enable thread sanitizer
1355 --disable-werror disable compilation abort on warning
1356 --disable-stack-protector disable compiler-provided stack protection
1357 --audio-drv-list=LIST set audio drivers to try if -audiodev is not used
1358 --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L
1359 --block-drv-rw-whitelist=L
1360 set block driver read-write whitelist
1361 (by default affects only QEMU, not tools like qemu-img)
1362 --block-drv-ro-whitelist=L
1363 set block driver read-only whitelist
1364 (by default affects only QEMU, not tools like qemu-img)
1365 --enable-block-drv-whitelist-in-tools
1366 use block whitelist also in tools instead of only QEMU
1367 --with-trace-file=NAME Full PATH,NAME of file to store traces
1368 Default:trace-<pid>
1369 --cpu=CPU Build for host CPU [$cpu]
1370 --with-coroutine=BACKEND coroutine backend. Supported options:
1371 ucontext, sigaltstack, windows
1372 --enable-gcov enable test coverage analysis with gcov
1373 --with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent
1374 --with-win-sdk=SDK-path path to Windows Platform SDK (to build VSS .tlb)
1375 --tls-priority default TLS protocol/cipher priority string
1376 --enable-gprof QEMU profiling with gprof
1377 --enable-profiler profiler support
1378 --enable-debug-stack-usage
1379 track the maximum stack usage of stacks created by qemu_alloc_stack
1380 --enable-plugins
1381 enable plugins via shared library loading
1382 --disable-containers don't use containers for cross-building
1383 --gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin]
1385 meson_options_help
1386 cat << EOF
1387 system all system emulation targets
1388 user supported user emulation targets
1389 linux-user all linux usermode emulation targets
1390 bsd-user all BSD usermode emulation targets
1391 guest-agent build the QEMU Guest Agent
1392 pie Position Independent Executables
1393 modules modules support (non-Windows)
1394 module-upgrades try to load modules from alternate paths for upgrades
1395 debug-tcg TCG debugging (default is disabled)
1396 debug-info debugging information
1397 lto Enable Link-Time Optimization.
1398 safe-stack SafeStack Stack Smash Protection. Depends on
1399 clang/llvm >= 3.7 and requires coroutine backend ucontext.
1400 membarrier membarrier system call (for Linux 4.14+ or Windows)
1401 rdma Enable RDMA-based migration
1402 pvrdma Enable PVRDMA support
1403 vhost-net vhost-net kernel acceleration support
1404 vhost-vsock virtio sockets device support
1405 vhost-scsi vhost-scsi kernel target support
1406 vhost-crypto vhost-user-crypto backend support
1407 vhost-kernel vhost kernel backend support
1408 vhost-user vhost-user backend support
1409 vhost-vdpa vhost-vdpa kernel backend support
1410 live-block-migration Block migration in the main migration stream
1411 coroutine-pool coroutine freelist (better performance)
1412 tpm TPM support
1413 numa libnuma support
1414 avx2 AVX2 optimization support
1415 avx512f AVX512F optimization support
1416 replication replication support
1417 opengl opengl support
1418 qom-cast-debug cast debugging support
1419 tools build qemu-io, qemu-nbd and qemu-img tools
1420 bochs bochs image format support
1421 cloop cloop image format support
1422 dmg dmg image format support
1423 qcow1 qcow v1 image format support
1424 vdi vdi image format support
1425 vvfat vvfat image format support
1426 qed qed image format support
1427 parallels parallels image format support
1428 crypto-afalg Linux AF_ALG crypto backend driver
1429 debug-mutex mutex debugging support
1430 rng-none dummy RNG, avoid using /dev/(u)random and getrandom()
1431 gio libgio support
1432 slirp-smbd use smbd (at path --smbd=*) in slirp networking
1434 NOTE: The object files are built at the place where configure is launched
1436 exit 0
1439 # Remove old dependency files to make sure that they get properly regenerated
1440 rm -f */config-devices.mak.d
1442 if test -z "$python"
1443 then
1444 error_exit "Python not found. Use --python=/path/to/python"
1446 if ! has "$make"
1447 then
1448 error_exit "GNU make ($make) not found"
1451 # Note that if the Python conditional here evaluates True we will exit
1452 # with status 1 which is a shell 'false' value.
1453 if ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then
1454 error_exit "Cannot use '$python', Python >= 3.6 is required." \
1455 "Use --python=/path/to/python to specify a supported Python."
1458 # Preserve python version since some functionality is dependent on it
1459 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)
1461 # Suppress writing compiled files
1462 python="$python -B"
1464 if test -z "$meson"; then
1465 if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.59.3; then
1466 meson=meson
1467 elif test $git_submodules_action != 'ignore' ; then
1468 meson=git
1469 elif test -e "${source_path}/meson/meson.py" ; then
1470 meson=internal
1471 else
1472 if test "$explicit_python" = yes; then
1473 error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found."
1474 else
1475 error_exit "Meson not found. Use --meson=/path/to/meson"
1478 else
1479 # Meson uses its own Python interpreter to invoke other Python scripts,
1480 # but the user wants to use the one they specified with --python.
1482 # We do not want to override the distro Python interpreter (and sometimes
1483 # cannot: for example in Homebrew /usr/bin/meson is a bash script), so
1484 # just require --meson=git|internal together with --python.
1485 if test "$explicit_python" = yes; then
1486 case "$meson" in
1487 git | internal) ;;
1488 *) error_exit "--python requires using QEMU's embedded Meson distribution." ;;
1489 esac
1493 if test "$meson" = git; then
1494 git_submodules="${git_submodules} meson"
1497 case "$meson" in
1498 git | internal)
1499 meson="$python ${source_path}/meson/meson.py"
1501 *) meson=$(command -v "$meson") ;;
1502 esac
1504 # Probe for ninja
1506 if test -z "$ninja"; then
1507 for c in ninja ninja-build samu; do
1508 if has $c; then
1509 ninja=$(command -v "$c")
1510 break
1512 done
1513 if test -z "$ninja"; then
1514 error_exit "Cannot find Ninja"
1518 # Check that the C compiler works. Doing this here before testing
1519 # the host CPU ensures that we had a valid CC to autodetect the
1520 # $cpu var (and we should bail right here if that's not the case).
1521 # It also allows the help message to be printed without a CC.
1522 write_c_skeleton;
1523 if compile_object ; then
1524 : C compiler works ok
1525 else
1526 error_exit "\"$cc\" either does not exist or does not work"
1528 if ! compile_prog ; then
1529 error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
1532 # Consult white-list to determine whether to enable werror
1533 # by default. Only enable by default for git builds
1534 if test -z "$werror" ; then
1535 if test "$git_submodules_action" != "ignore" && \
1536 { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
1537 werror="yes"
1538 else
1539 werror="no"
1543 if test "$targetos" = "bogus"; then
1544 # Now that we know that we're not printing the help and that
1545 # the compiler works (so the results of the check_defines we used
1546 # to identify the OS are reliable), if we didn't recognize the
1547 # host OS we should stop now.
1548 error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
1551 # Check whether the compiler matches our minimum requirements:
1552 cat > $TMPC << EOF
1553 #if defined(__clang_major__) && defined(__clang_minor__)
1554 # ifdef __apple_build_version__
1555 # if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0)
1556 # error You need at least XCode Clang v10.0 to compile QEMU
1557 # endif
1558 # else
1559 # if __clang_major__ < 6 || (__clang_major__ == 6 && __clang_minor__ < 0)
1560 # error You need at least Clang v6.0 to compile QEMU
1561 # endif
1562 # endif
1563 #elif defined(__GNUC__) && defined(__GNUC_MINOR__)
1564 # if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4)
1565 # error You need at least GCC v7.4.0 to compile QEMU
1566 # endif
1567 #else
1568 # error You either need GCC or Clang to compiler QEMU
1569 #endif
1570 int main (void) { return 0; }
1572 if ! compile_prog "" "" ; then
1573 error_exit "You need at least GCC v7.4 or Clang v6.0 (or XCode Clang v10.0)"
1576 # Accumulate -Wfoo and -Wno-bar separately.
1577 # We will list all of the enable flags first, and the disable flags second.
1578 # Note that we do not add -Werror, because that would enable it for all
1579 # configure tests. If a configure test failed due to -Werror this would
1580 # just silently disable some features, so it's too error prone.
1582 warn_flags=
1583 add_to warn_flags -Wold-style-declaration
1584 add_to warn_flags -Wold-style-definition
1585 add_to warn_flags -Wtype-limits
1586 add_to warn_flags -Wformat-security
1587 add_to warn_flags -Wformat-y2k
1588 add_to warn_flags -Winit-self
1589 add_to warn_flags -Wignored-qualifiers
1590 add_to warn_flags -Wempty-body
1591 add_to warn_flags -Wnested-externs
1592 add_to warn_flags -Wendif-labels
1593 add_to warn_flags -Wexpansion-to-defined
1594 add_to warn_flags -Wimplicit-fallthrough=2
1596 nowarn_flags=
1597 add_to nowarn_flags -Wno-initializer-overrides
1598 add_to nowarn_flags -Wno-missing-include-dirs
1599 add_to nowarn_flags -Wno-shift-negative-value
1600 add_to nowarn_flags -Wno-string-plus-int
1601 add_to nowarn_flags -Wno-typedef-redefinition
1602 add_to nowarn_flags -Wno-tautological-type-limit-compare
1603 add_to nowarn_flags -Wno-psabi
1605 gcc_flags="$warn_flags $nowarn_flags"
1607 cc_has_warning_flag() {
1608 write_c_skeleton;
1610 # Use the positive sense of the flag when testing for -Wno-wombat
1611 # support (gcc will happily accept the -Wno- form of unknown
1612 # warning options).
1613 optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
1614 compile_prog "-Werror $optflag" ""
1617 for flag in $gcc_flags; do
1618 if cc_has_warning_flag $flag ; then
1619 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1621 done
1623 if test "$stack_protector" != "no"; then
1624 cat > $TMPC << EOF
1625 int main(int argc, char *argv[])
1627 char arr[64], *p = arr, *c = argv[0];
1628 while (*c) {
1629 *p++ = *c++;
1631 return 0;
1634 gcc_flags="-fstack-protector-strong -fstack-protector-all"
1635 sp_on=0
1636 for flag in $gcc_flags; do
1637 # We need to check both a compile and a link, since some compiler
1638 # setups fail only on a .c->.o compile and some only at link time
1639 if compile_object "-Werror $flag" &&
1640 compile_prog "-Werror $flag" ""; then
1641 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1642 QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
1643 sp_on=1
1644 break
1646 done
1647 if test "$stack_protector" = yes; then
1648 if test $sp_on = 0; then
1649 error_exit "Stack protector not supported"
1654 # Disable -Wmissing-braces on older compilers that warn even for
1655 # the "universal" C zero initializer {0}.
1656 cat > $TMPC << EOF
1657 struct {
1658 int a[2];
1659 } x = {0};
1661 if compile_object "-Werror" "" ; then
1663 else
1664 QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
1667 # Our module code doesn't support Windows
1668 if test "$modules" = "yes" && test "$mingw32" = "yes" ; then
1669 error_exit "Modules are not available for Windows"
1672 # module_upgrades is only reasonable if modules are enabled
1673 if test "$modules" = "no" && test "$module_upgrades" = "yes" ; then
1674 error_exit "Can't enable module-upgrades as Modules are not enabled"
1677 # Static linking is not possible with plugins, modules or PIE
1678 if test "$static" = "yes" ; then
1679 if test "$modules" = "yes" ; then
1680 error_exit "static and modules are mutually incompatible"
1682 if test "$plugins" = "yes"; then
1683 error_exit "static and plugins are mutually incompatible"
1684 else
1685 plugins="no"
1688 test "$plugins" = "" && plugins=yes
1690 cat > $TMPC << EOF
1692 #ifdef __linux__
1693 # define THREAD __thread
1694 #else
1695 # define THREAD
1696 #endif
1697 static THREAD int tls_var;
1698 int main(void) { return tls_var; }
1701 # Check we support -fno-pie and -no-pie first; we will need the former for
1702 # building ROMs, and both for everything if --disable-pie is passed.
1703 if compile_prog "-Werror -fno-pie" "-no-pie"; then
1704 CFLAGS_NOPIE="-fno-pie"
1705 LDFLAGS_NOPIE="-no-pie"
1708 if test "$static" = "yes"; then
1709 if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then
1710 CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
1711 QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS"
1712 pie="yes"
1713 elif test "$pie" = "yes"; then
1714 error_exit "-static-pie not available due to missing toolchain support"
1715 else
1716 QEMU_LDFLAGS="-static $QEMU_LDFLAGS"
1717 pie="no"
1719 elif test "$pie" = "no"; then
1720 CONFIGURE_CFLAGS="$CFLAGS_NOPIE $CONFIGURE_CFLAGS"
1721 CONFIGURE_LDFLAGS="$LDFLAGS_NOPIE $CONFIGURE_LDFLAGS"
1722 elif compile_prog "-Werror -fPIE -DPIE" "-pie"; then
1723 CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
1724 CONFIGURE_LDFLAGS="-pie $CONFIGURE_LDFLAGS"
1725 pie="yes"
1726 elif test "$pie" = "yes"; then
1727 error_exit "PIE not available due to missing toolchain support"
1728 else
1729 echo "Disabling PIE due to missing toolchain support"
1730 pie="no"
1733 # Detect support for PT_GNU_RELRO + DT_BIND_NOW.
1734 # The combination is known as "full relro", because .got.plt is read-only too.
1735 if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
1736 QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS"
1739 ##########################################
1740 # __sync_fetch_and_and requires at least -march=i486. Many toolchains
1741 # use i686 as default anyway, but for those that don't, an explicit
1742 # specification is necessary
1744 if test "$cpu" = "i386"; then
1745 cat > $TMPC << EOF
1746 static int sfaa(int *ptr)
1748 return __sync_fetch_and_and(ptr, 0);
1751 int main(void)
1753 int val = 42;
1754 val = __sync_val_compare_and_swap(&val, 0, 1);
1755 sfaa(&val);
1756 return val;
1759 if ! compile_prog "" "" ; then
1760 QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
1764 if test "$tcg" = "enabled"; then
1765 git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
1766 git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
1769 if test -z "${target_list+xxx}" ; then
1770 default_targets=yes
1771 for target in $default_target_list; do
1772 target_list="$target_list $target"
1773 done
1774 target_list="${target_list# }"
1775 else
1776 default_targets=no
1777 target_list=$(echo "$target_list" | sed -e 's/,/ /g')
1778 for target in $target_list; do
1779 # Check that we recognised the target name; this allows a more
1780 # friendly error message than if we let it fall through.
1781 case " $default_target_list " in
1782 *" $target "*)
1785 error_exit "Unknown target name '$target'"
1787 esac
1788 done
1791 # see if system emulation was really requested
1792 case " $target_list " in
1793 *"-softmmu "*) softmmu=yes
1795 *) softmmu=no
1797 esac
1799 feature_not_found() {
1800 feature=$1
1801 remedy=$2
1803 error_exit "User requested feature $feature" \
1804 "configure was not able to find it." \
1805 "$remedy"
1808 # ---
1809 # big/little endian test
1810 cat > $TMPC << EOF
1811 #include <stdio.h>
1812 short big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
1813 short little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
1814 int main(int argc, char *argv[])
1816 return printf("%s %s\n", (char *)big_endian, (char *)little_endian);
1820 if compile_prog ; then
1821 if strings -a $TMPE | grep -q BiGeNdIaN ; then
1822 bigendian="yes"
1823 elif strings -a $TMPE | grep -q LiTtLeEnDiAn ; then
1824 bigendian="no"
1825 else
1826 echo big/little test failed
1827 exit 1
1829 else
1830 echo big/little test failed
1831 exit 1
1834 ##########################################
1835 # system tools
1836 if test -z "$want_tools"; then
1837 if test "$softmmu" = "no"; then
1838 want_tools=no
1839 else
1840 want_tools=yes
1844 #########################################
1845 # vhost interdependencies and host support
1847 # vhost backends
1848 if test "$vhost_user" = "yes" && test "$linux" != "yes"; then
1849 error_exit "vhost-user is only available on Linux"
1851 test "$vhost_vdpa" = "" && vhost_vdpa=$linux
1852 if test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then
1853 error_exit "vhost-vdpa is only available on Linux"
1855 test "$vhost_kernel" = "" && vhost_kernel=$linux
1856 if test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then
1857 error_exit "vhost-kernel is only available on Linux"
1860 # vhost-kernel devices
1861 test "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel
1862 if test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then
1863 error_exit "--enable-vhost-scsi requires --enable-vhost-kernel"
1865 test "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel
1866 if test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then
1867 error_exit "--enable-vhost-vsock requires --enable-vhost-kernel"
1870 # vhost-user backends
1871 test "$vhost_net_user" = "" && vhost_net_user=$vhost_user
1872 if test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then
1873 error_exit "--enable-vhost-net-user requires --enable-vhost-user"
1875 test "$vhost_crypto" = "" && vhost_crypto=$vhost_user
1876 if test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then
1877 error_exit "--enable-vhost-crypto requires --enable-vhost-user"
1879 test "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user
1880 if test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then
1881 error_exit "--enable-vhost-user-fs requires --enable-vhost-user"
1883 #vhost-vdpa backends
1884 test "$vhost_net_vdpa" = "" && vhost_net_vdpa=$vhost_vdpa
1885 if test "$vhost_net_vdpa" = "yes" && test "$vhost_vdpa" = "no"; then
1886 error_exit "--enable-vhost-net-vdpa requires --enable-vhost-vdpa"
1889 # OR the vhost-kernel, vhost-vdpa and vhost-user values for simplicity
1890 if test "$vhost_net" = ""; then
1891 test "$vhost_net_user" = "yes" && vhost_net=yes
1892 test "$vhost_net_vdpa" = "yes" && vhost_net=yes
1893 test "$vhost_kernel" = "yes" && vhost_net=yes
1896 ##########################################
1897 # pkg-config probe
1899 if ! has "$pkg_config_exe"; then
1900 error_exit "pkg-config binary '$pkg_config_exe' not found"
1903 ##########################################
1904 # xen probe
1906 if test "$xen" != "disabled" ; then
1907 # Check whether Xen library path is specified via --extra-ldflags to avoid
1908 # overriding this setting with pkg-config output. If not, try pkg-config
1909 # to obtain all needed flags.
1911 if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
1912 $pkg_config --exists xencontrol ; then
1913 xen_ctrl_version="$(printf '%d%02d%02d' \
1914 $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
1915 xen=enabled
1916 xen_pc="xencontrol xenstore xenforeignmemory xengnttab"
1917 xen_pc="$xen_pc xenevtchn xendevicemodel"
1918 if $pkg_config --exists xentoolcore; then
1919 xen_pc="$xen_pc xentoolcore"
1921 xen_cflags="$($pkg_config --cflags $xen_pc)"
1922 xen_libs="$($pkg_config --libs $xen_pc)"
1923 else
1925 xen_libs="-lxenstore -lxenctrl"
1926 xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
1928 # First we test whether Xen headers and libraries are available.
1929 # If no, we are done and there is no Xen support.
1930 # If yes, more tests are run to detect the Xen version.
1932 # Xen (any)
1933 cat > $TMPC <<EOF
1934 #include <xenctrl.h>
1935 int main(void) {
1936 return 0;
1939 if ! compile_prog "" "$xen_libs" ; then
1940 # Xen not found
1941 if test "$xen" = "enabled" ; then
1942 feature_not_found "xen" "Install xen devel"
1944 xen=disabled
1946 # Xen unstable
1947 elif
1948 cat > $TMPC <<EOF &&
1949 #undef XC_WANT_COMPAT_DEVICEMODEL_API
1950 #define __XEN_TOOLS__
1951 #include <xendevicemodel.h>
1952 #include <xenforeignmemory.h>
1953 int main(void) {
1954 xendevicemodel_handle *xd;
1955 xenforeignmemory_handle *xfmem;
1957 xd = xendevicemodel_open(0, 0);
1958 xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
1960 xfmem = xenforeignmemory_open(0, 0);
1961 xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
1963 return 0;
1966 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
1967 then
1968 xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
1969 xen_ctrl_version=41100
1970 xen=enabled
1971 elif
1972 cat > $TMPC <<EOF &&
1973 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
1974 #include <xenforeignmemory.h>
1975 #include <xentoolcore.h>
1976 int main(void) {
1977 xenforeignmemory_handle *xfmem;
1979 xfmem = xenforeignmemory_open(0, 0);
1980 xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
1981 xentoolcore_restrict_all(0);
1983 return 0;
1986 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
1987 then
1988 xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
1989 xen_ctrl_version=41000
1990 xen=enabled
1991 elif
1992 cat > $TMPC <<EOF &&
1993 #undef XC_WANT_COMPAT_DEVICEMODEL_API
1994 #define __XEN_TOOLS__
1995 #include <xendevicemodel.h>
1996 int main(void) {
1997 xendevicemodel_handle *xd;
1999 xd = xendevicemodel_open(0, 0);
2000 xendevicemodel_close(xd);
2002 return 0;
2005 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2006 then
2007 xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2008 xen_ctrl_version=40900
2009 xen=enabled
2010 elif
2011 cat > $TMPC <<EOF &&
2013 * If we have stable libs the we don't want the libxc compat
2014 * layers, regardless of what CFLAGS we may have been given.
2016 * Also, check if xengnttab_grant_copy_segment_t is defined and
2017 * grant copy operation is implemented.
2019 #undef XC_WANT_COMPAT_EVTCHN_API
2020 #undef XC_WANT_COMPAT_GNTTAB_API
2021 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2022 #include <xenctrl.h>
2023 #include <xenstore.h>
2024 #include <xenevtchn.h>
2025 #include <xengnttab.h>
2026 #include <xenforeignmemory.h>
2027 #include <stdint.h>
2028 #include <xen/hvm/hvm_info_table.h>
2029 #if !defined(HVM_MAX_VCPUS)
2030 # error HVM_MAX_VCPUS not defined
2031 #endif
2032 int main(void) {
2033 xc_interface *xc = NULL;
2034 xenforeignmemory_handle *xfmem;
2035 xenevtchn_handle *xe;
2036 xengnttab_handle *xg;
2037 xengnttab_grant_copy_segment_t* seg = NULL;
2039 xs_daemon_open();
2041 xc = xc_interface_open(0, 0, 0);
2042 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2043 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2044 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2045 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2047 xfmem = xenforeignmemory_open(0, 0);
2048 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2050 xe = xenevtchn_open(0, 0);
2051 xenevtchn_fd(xe);
2053 xg = xengnttab_open(0, 0);
2054 xengnttab_grant_copy(xg, 0, seg);
2056 return 0;
2059 compile_prog "" "$xen_libs $xen_stable_libs"
2060 then
2061 xen_ctrl_version=40800
2062 xen=enabled
2063 elif
2064 cat > $TMPC <<EOF &&
2066 * If we have stable libs the we don't want the libxc compat
2067 * layers, regardless of what CFLAGS we may have been given.
2069 #undef XC_WANT_COMPAT_EVTCHN_API
2070 #undef XC_WANT_COMPAT_GNTTAB_API
2071 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2072 #include <xenctrl.h>
2073 #include <xenstore.h>
2074 #include <xenevtchn.h>
2075 #include <xengnttab.h>
2076 #include <xenforeignmemory.h>
2077 #include <stdint.h>
2078 #include <xen/hvm/hvm_info_table.h>
2079 #if !defined(HVM_MAX_VCPUS)
2080 # error HVM_MAX_VCPUS not defined
2081 #endif
2082 int main(void) {
2083 xc_interface *xc = NULL;
2084 xenforeignmemory_handle *xfmem;
2085 xenevtchn_handle *xe;
2086 xengnttab_handle *xg;
2088 xs_daemon_open();
2090 xc = xc_interface_open(0, 0, 0);
2091 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2092 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2093 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2094 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2096 xfmem = xenforeignmemory_open(0, 0);
2097 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2099 xe = xenevtchn_open(0, 0);
2100 xenevtchn_fd(xe);
2102 xg = xengnttab_open(0, 0);
2103 xengnttab_map_grant_ref(xg, 0, 0, 0);
2105 return 0;
2108 compile_prog "" "$xen_libs $xen_stable_libs"
2109 then
2110 xen_ctrl_version=40701
2111 xen=enabled
2113 # Xen 4.6
2114 elif
2115 cat > $TMPC <<EOF &&
2116 #include <xenctrl.h>
2117 #include <xenstore.h>
2118 #include <stdint.h>
2119 #include <xen/hvm/hvm_info_table.h>
2120 #if !defined(HVM_MAX_VCPUS)
2121 # error HVM_MAX_VCPUS not defined
2122 #endif
2123 int main(void) {
2124 xc_interface *xc;
2125 xs_daemon_open();
2126 xc = xc_interface_open(0, 0, 0);
2127 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2128 xc_gnttab_open(NULL, 0);
2129 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2130 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2131 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2132 xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2133 return 0;
2136 compile_prog "" "$xen_libs"
2137 then
2138 xen_ctrl_version=40600
2139 xen=enabled
2141 # Xen 4.5
2142 elif
2143 cat > $TMPC <<EOF &&
2144 #include <xenctrl.h>
2145 #include <xenstore.h>
2146 #include <stdint.h>
2147 #include <xen/hvm/hvm_info_table.h>
2148 #if !defined(HVM_MAX_VCPUS)
2149 # error HVM_MAX_VCPUS not defined
2150 #endif
2151 int main(void) {
2152 xc_interface *xc;
2153 xs_daemon_open();
2154 xc = xc_interface_open(0, 0, 0);
2155 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2156 xc_gnttab_open(NULL, 0);
2157 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2158 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2159 xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
2160 return 0;
2163 compile_prog "" "$xen_libs"
2164 then
2165 xen_ctrl_version=40500
2166 xen=enabled
2168 elif
2169 cat > $TMPC <<EOF &&
2170 #include <xenctrl.h>
2171 #include <xenstore.h>
2172 #include <stdint.h>
2173 #include <xen/hvm/hvm_info_table.h>
2174 #if !defined(HVM_MAX_VCPUS)
2175 # error HVM_MAX_VCPUS not defined
2176 #endif
2177 int main(void) {
2178 xc_interface *xc;
2179 xs_daemon_open();
2180 xc = xc_interface_open(0, 0, 0);
2181 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2182 xc_gnttab_open(NULL, 0);
2183 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2184 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2185 return 0;
2188 compile_prog "" "$xen_libs"
2189 then
2190 xen_ctrl_version=40200
2191 xen=enabled
2193 else
2194 if test "$xen" = "enabled" ; then
2195 feature_not_found "xen (unsupported version)" \
2196 "Install a supported xen (xen 4.2 or newer)"
2198 xen=disabled
2201 if test "$xen" = enabled; then
2202 if test $xen_ctrl_version -ge 40701 ; then
2203 xen_libs="$xen_libs $xen_stable_libs "
2209 ##########################################
2210 # RDMA needs OpenFabrics libraries
2211 if test "$rdma" != "no" ; then
2212 cat > $TMPC <<EOF
2213 #include <rdma/rdma_cma.h>
2214 int main(void) { return 0; }
2216 rdma_libs="-lrdmacm -libverbs -libumad"
2217 if compile_prog "" "$rdma_libs" ; then
2218 rdma="yes"
2219 else
2220 if test "$rdma" = "yes" ; then
2221 error_exit \
2222 " OpenFabrics librdmacm/libibverbs/libibumad not present." \
2223 " Your options:" \
2224 " (1) Fast: Install infiniband packages (devel) from your distro." \
2225 " (2) Cleanest: Install libraries from www.openfabrics.org" \
2226 " (3) Also: Install softiwarp if you don't have RDMA hardware"
2228 rdma="no"
2232 ##########################################
2233 # PVRDMA detection
2235 cat > $TMPC <<EOF &&
2236 #include <sys/mman.h>
2239 main(void)
2241 char buf = 0;
2242 void *addr = &buf;
2243 addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED);
2245 return 0;
2249 if test "$rdma" = "yes" ; then
2250 case "$pvrdma" in
2252 if compile_prog "" ""; then
2253 pvrdma="yes"
2254 else
2255 pvrdma="no"
2258 "yes")
2259 if ! compile_prog "" ""; then
2260 error_exit "PVRDMA is not supported since mremap is not implemented"
2262 pvrdma="yes"
2264 "no")
2265 pvrdma="no"
2267 esac
2268 else
2269 if test "$pvrdma" = "yes" ; then
2270 error_exit "PVRDMA requires rdma suppport"
2272 pvrdma="no"
2275 # Let's see if enhanced reg_mr is supported
2276 if test "$pvrdma" = "yes" ; then
2278 cat > $TMPC <<EOF &&
2279 #include <infiniband/verbs.h>
2282 main(void)
2284 struct ibv_mr *mr;
2285 struct ibv_pd *pd = NULL;
2286 size_t length = 10;
2287 uint64_t iova = 0;
2288 int access = 0;
2289 void *addr = NULL;
2291 mr = ibv_reg_mr_iova(pd, addr, length, iova, access);
2293 ibv_dereg_mr(mr);
2295 return 0;
2298 if ! compile_prog "" "-libverbs"; then
2299 QEMU_CFLAGS="$QEMU_CFLAGS -DLEGACY_RDMA_REG_MR"
2303 ##########################################
2304 # glib support probe
2306 glib_req_ver=2.56
2307 glib_modules=gthread-2.0
2308 if test "$modules" = yes; then
2309 glib_modules="$glib_modules gmodule-export-2.0"
2310 elif test "$plugins" = "yes"; then
2311 glib_modules="$glib_modules gmodule-no-export-2.0"
2314 for i in $glib_modules; do
2315 if $pkg_config --atleast-version=$glib_req_ver $i; then
2316 glib_cflags=$($pkg_config --cflags $i)
2317 glib_libs=$($pkg_config --libs $i)
2318 else
2319 error_exit "glib-$glib_req_ver $i is required to compile QEMU"
2321 done
2323 # This workaround is required due to a bug in pkg-config file for glib as it
2324 # doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
2326 if test "$static" = yes && test "$mingw32" = yes; then
2327 glib_cflags="-DGLIB_STATIC_COMPILATION $glib_cflags"
2330 if ! test "$gio" = "no"; then
2331 pass=no
2332 if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
2333 gio_cflags=$($pkg_config --cflags gio-2.0)
2334 gio_libs=$($pkg_config --libs gio-2.0)
2335 gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0)
2336 if ! has "$gdbus_codegen"; then
2337 gdbus_codegen=
2339 # Check that the libraries actually work -- Ubuntu 18.04 ships
2340 # with pkg-config --static --libs data for gio-2.0 that is missing
2341 # -lblkid and will give a link error.
2342 cat > $TMPC <<EOF
2343 #include <gio/gio.h>
2344 int main(void)
2346 g_dbus_proxy_new_sync(0, 0, 0, 0, 0, 0, 0, 0);
2347 return 0;
2350 if compile_prog "$gio_cflags" "$gio_libs" ; then
2351 pass=yes
2352 else
2353 pass=no
2356 if test "$pass" = "yes" &&
2357 $pkg_config --atleast-version=$glib_req_ver gio-unix-2.0; then
2358 gio_cflags="$gio_cflags $($pkg_config --cflags gio-unix-2.0)"
2359 gio_libs="$gio_libs $($pkg_config --libs gio-unix-2.0)"
2363 if test "$pass" = "no"; then
2364 if test "$gio" = "yes"; then
2365 feature_not_found "gio" "Install libgio >= 2.0"
2366 else
2367 gio=no
2369 else
2370 gio=yes
2374 # Sanity check that the current size_t matches the
2375 # size that glib thinks it should be. This catches
2376 # problems on multi-arch where people try to build
2377 # 32-bit QEMU while pointing at 64-bit glib headers
2378 cat > $TMPC <<EOF
2379 #include <glib.h>
2380 #include <unistd.h>
2382 #define QEMU_BUILD_BUG_ON(x) \
2383 typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
2385 int main(void) {
2386 QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
2387 return 0;
2391 if ! compile_prog "$glib_cflags" "$glib_libs" ; then
2392 error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
2393 "You probably need to set PKG_CONFIG_LIBDIR"\
2394 "to point to the right pkg-config files for your"\
2395 "build target"
2398 # Silence clang warnings triggered by glib < 2.57.2
2399 cat > $TMPC << EOF
2400 #include <glib.h>
2401 typedef struct Foo {
2402 int i;
2403 } Foo;
2404 static void foo_free(Foo *f)
2406 g_free(f);
2408 G_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free);
2409 int main(void) { return 0; }
2411 if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
2412 if cc_has_warning_flag "-Wno-unused-function"; then
2413 glib_cflags="$glib_cflags -Wno-unused-function"
2414 CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -Wno-unused-function"
2418 ##########################################
2419 # SHA command probe for modules
2420 if test "$modules" = yes; then
2421 shacmd_probe="sha1sum sha1 shasum"
2422 for c in $shacmd_probe; do
2423 if has $c; then
2424 shacmd="$c"
2425 break
2427 done
2428 if test "$shacmd" = ""; then
2429 error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
2433 ##########################################
2434 # TPM emulation is only on POSIX
2436 if test "$tpm" = ""; then
2437 if test "$mingw32" = "yes"; then
2438 tpm=no
2439 else
2440 tpm=yes
2442 elif test "$tpm" = "yes"; then
2443 if test "$mingw32" = "yes" ; then
2444 error_exit "TPM emulation only available on POSIX systems"
2448 ##########################################
2449 # fdt probe
2451 case "$fdt" in
2452 auto | enabled | internal)
2453 # Simpler to always update submodule, even if not needed.
2454 git_submodules="${git_submodules} dtc"
2456 esac
2458 ##########################################
2459 # opengl probe (for sdl2, gtk)
2461 if test "$opengl" != "no" ; then
2462 epoxy=no
2463 if $pkg_config epoxy; then
2464 cat > $TMPC << EOF
2465 #include <epoxy/egl.h>
2466 int main(void) { return 0; }
2468 if compile_prog "" "" ; then
2469 epoxy=yes
2473 if test "$epoxy" = "yes" ; then
2474 opengl_cflags="$($pkg_config --cflags epoxy)"
2475 opengl_libs="$($pkg_config --libs epoxy)"
2476 opengl=yes
2477 else
2478 if test "$opengl" = "yes" ; then
2479 feature_not_found "opengl" "Please install epoxy with EGL"
2481 opengl_cflags=""
2482 opengl_libs=""
2483 opengl=no
2487 ##########################################
2488 # libnuma probe
2490 if test "$numa" != "no" ; then
2491 cat > $TMPC << EOF
2492 #include <numa.h>
2493 int main(void) { return numa_available(); }
2496 if compile_prog "" "-lnuma" ; then
2497 numa=yes
2498 numa_libs="-lnuma"
2499 else
2500 if test "$numa" = "yes" ; then
2501 feature_not_found "numa" "install numactl devel"
2503 numa=no
2507 # check for usbfs
2508 have_usbfs=no
2509 if test "$linux_user" = "yes"; then
2510 cat > $TMPC << EOF
2511 #include <linux/usbdevice_fs.h>
2513 #ifndef USBDEVFS_GET_CAPABILITIES
2514 #error "USBDEVFS_GET_CAPABILITIES undefined"
2515 #endif
2517 #ifndef USBDEVFS_DISCONNECT_CLAIM
2518 #error "USBDEVFS_DISCONNECT_CLAIM undefined"
2519 #endif
2521 int main(void)
2523 return 0;
2526 if compile_prog "" ""; then
2527 have_usbfs=yes
2531 ##########################################
2532 # check if we have VSS SDK headers for win
2534 guest_agent_with_vss="no"
2535 if test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
2536 test "$vss_win32_sdk" != "no" ; then
2537 case "$vss_win32_sdk" in
2538 "") vss_win32_include="-isystem $source_path" ;;
2539 *\ *) # The SDK is installed in "Program Files" by default, but we cannot
2540 # handle path with spaces. So we symlink the headers into ".sdk/vss".
2541 vss_win32_include="-isystem $source_path/.sdk/vss"
2542 symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
2544 *) vss_win32_include="-isystem $vss_win32_sdk"
2545 esac
2546 cat > $TMPC << EOF
2547 #define __MIDL_user_allocate_free_DEFINED__
2548 #include <inc/win2003/vss.h>
2549 int main(void) { return VSS_CTX_BACKUP; }
2551 if compile_prog "$vss_win32_include" "" ; then
2552 guest_agent_with_vss="yes"
2553 QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
2554 libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
2555 qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
2556 else
2557 if test "$vss_win32_sdk" != "" ; then
2558 echo "ERROR: Please download and install Microsoft VSS SDK:"
2559 echo "ERROR: http://www.microsoft.com/en-us/download/details.aspx?id=23490"
2560 echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
2561 echo "ERROR: scripts/extract-vsssdk-headers setup.exe"
2562 echo "ERROR: The headers are extracted in the directory \`inc'."
2563 feature_not_found "VSS support"
2568 ##########################################
2569 # lookup Windows platform SDK (if not specified)
2570 # The SDK is needed only to build .tlb (type library) file of guest agent
2571 # VSS provider from the source. It is usually unnecessary because the
2572 # pre-compiled .tlb file is included.
2574 if test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
2575 test "$guest_agent_with_vss" = "yes" ; then
2576 if test -z "$win_sdk"; then
2577 programfiles="$PROGRAMFILES"
2578 test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
2579 if test -n "$programfiles"; then
2580 win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
2581 else
2582 feature_not_found "Windows SDK"
2584 elif test "$win_sdk" = "no"; then
2585 win_sdk=""
2589 ##########################################
2590 # check if mingw environment provides a recent ntddscsi.h
2591 guest_agent_ntddscsi="no"
2592 if test "$mingw32" = "yes" && test "$guest_agent" != "no"; then
2593 cat > $TMPC << EOF
2594 #include <windows.h>
2595 #include <ntddscsi.h>
2596 int main(void) {
2597 #if !defined(IOCTL_SCSI_GET_ADDRESS)
2598 #error Missing required ioctl definitions
2599 #endif
2600 SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
2601 return addr.Lun;
2604 if compile_prog "" "" ; then
2605 guest_agent_ntddscsi=yes
2606 libs_qga="-lsetupapi -lcfgmgr32 $libs_qga"
2610 ##########################################
2611 # capstone
2613 case "$capstone" in
2614 auto | enabled | internal)
2615 # Simpler to always update submodule, even if not needed.
2616 git_submodules="${git_submodules} capstone"
2618 esac
2620 ##########################################
2621 # check and set a backend for coroutine
2623 # We prefer ucontext, but it's not always possible. The fallback
2624 # is sigcontext. On Windows the only valid backend is the Windows
2625 # specific one.
2627 ucontext_works=no
2628 if test "$darwin" != "yes"; then
2629 cat > $TMPC << EOF
2630 #include <ucontext.h>
2631 #ifdef __stub_makecontext
2632 #error Ignoring glibc stub makecontext which will always fail
2633 #endif
2634 int main(void) { makecontext(0, 0, 0); return 0; }
2636 if compile_prog "" "" ; then
2637 ucontext_works=yes
2641 if test "$coroutine" = ""; then
2642 if test "$mingw32" = "yes"; then
2643 coroutine=win32
2644 elif test "$ucontext_works" = "yes"; then
2645 coroutine=ucontext
2646 else
2647 coroutine=sigaltstack
2649 else
2650 case $coroutine in
2651 windows)
2652 if test "$mingw32" != "yes"; then
2653 error_exit "'windows' coroutine backend only valid for Windows"
2655 # Unfortunately the user visible backend name doesn't match the
2656 # coroutine-*.c filename for this case, so we have to adjust it here.
2657 coroutine=win32
2659 ucontext)
2660 if test "$ucontext_works" != "yes"; then
2661 feature_not_found "ucontext"
2664 sigaltstack)
2665 if test "$mingw32" = "yes"; then
2666 error_exit "only the 'windows' coroutine backend is valid for Windows"
2670 error_exit "unknown coroutine backend $coroutine"
2672 esac
2675 if test "$coroutine_pool" = ""; then
2676 coroutine_pool=yes
2679 if test "$debug_stack_usage" = "yes"; then
2680 if test "$coroutine_pool" = "yes"; then
2681 echo "WARN: disabling coroutine pool for stack usage debugging"
2682 coroutine_pool=no
2686 ##################################################
2687 # SafeStack
2690 if test "$safe_stack" = "yes"; then
2691 cat > $TMPC << EOF
2692 int main(int argc, char *argv[])
2694 #if ! __has_feature(safe_stack)
2695 #error SafeStack Disabled
2696 #endif
2697 return 0;
2700 flag="-fsanitize=safe-stack"
2701 # Check that safe-stack is supported and enabled.
2702 if compile_prog "-Werror $flag" "$flag"; then
2703 # Flag needed both at compilation and at linking
2704 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
2705 QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
2706 else
2707 error_exit "SafeStack not supported by your compiler"
2709 if test "$coroutine" != "ucontext"; then
2710 error_exit "SafeStack is only supported by the coroutine backend ucontext"
2712 else
2713 cat > $TMPC << EOF
2714 int main(int argc, char *argv[])
2716 #if defined(__has_feature)
2717 #if __has_feature(safe_stack)
2718 #error SafeStack Enabled
2719 #endif
2720 #endif
2721 return 0;
2724 if test "$safe_stack" = "no"; then
2725 # Make sure that safe-stack is disabled
2726 if ! compile_prog "-Werror" ""; then
2727 # SafeStack was already enabled, try to explicitly remove the feature
2728 flag="-fno-sanitize=safe-stack"
2729 if ! compile_prog "-Werror $flag" "$flag"; then
2730 error_exit "Configure cannot disable SafeStack"
2732 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
2733 QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
2735 else # "$safe_stack" = ""
2736 # Set safe_stack to yes or no based on pre-existing flags
2737 if compile_prog "-Werror" ""; then
2738 safe_stack="no"
2739 else
2740 safe_stack="yes"
2741 if test "$coroutine" != "ucontext"; then
2742 error_exit "SafeStack is only supported by the coroutine backend ucontext"
2748 ########################################
2749 # check if cpuid.h is usable.
2751 cat > $TMPC << EOF
2752 #include <cpuid.h>
2753 int main(void) {
2754 unsigned a, b, c, d;
2755 unsigned max = __get_cpuid_max(0, 0);
2757 if (max >= 1) {
2758 __cpuid(1, a, b, c, d);
2761 if (max >= 7) {
2762 __cpuid_count(7, 0, a, b, c, d);
2765 return 0;
2768 if compile_prog "" "" ; then
2769 cpuid_h=yes
2772 ##########################################
2773 # avx2 optimization requirement check
2775 # There is no point enabling this if cpuid.h is not usable,
2776 # since we won't be able to select the new routines.
2778 if test "$cpuid_h" = "yes" && test "$avx2_opt" != "no"; then
2779 cat > $TMPC << EOF
2780 #pragma GCC push_options
2781 #pragma GCC target("avx2")
2782 #include <cpuid.h>
2783 #include <immintrin.h>
2784 static int bar(void *a) {
2785 __m256i x = *(__m256i *)a;
2786 return _mm256_testz_si256(x, x);
2788 int main(int argc, char *argv[]) { return bar(argv[0]); }
2790 if compile_object "-Werror" ; then
2791 avx2_opt="yes"
2792 else
2793 avx2_opt="no"
2797 ##########################################
2798 # avx512f optimization requirement check
2800 # There is no point enabling this if cpuid.h is not usable,
2801 # since we won't be able to select the new routines.
2802 # by default, it is turned off.
2803 # if user explicitly want to enable it, check environment
2805 if test "$cpuid_h" = "yes" && test "$avx512f_opt" = "yes"; then
2806 cat > $TMPC << EOF
2807 #pragma GCC push_options
2808 #pragma GCC target("avx512f")
2809 #include <cpuid.h>
2810 #include <immintrin.h>
2811 static int bar(void *a) {
2812 __m512i x = *(__m512i *)a;
2813 return _mm512_test_epi64_mask(x, x);
2815 int main(int argc, char *argv[])
2817 return bar(argv[0]);
2820 if ! compile_object "-Werror" ; then
2821 avx512f_opt="no"
2823 else
2824 avx512f_opt="no"
2827 ########################################
2828 # check if __[u]int128_t is usable.
2830 int128=no
2831 cat > $TMPC << EOF
2832 __int128_t a;
2833 __uint128_t b;
2834 int main (void) {
2835 a = a + b;
2836 b = a * b;
2837 a = a * a;
2838 return 0;
2841 if compile_prog "" "" ; then
2842 int128=yes
2845 #########################################
2846 # See if 128-bit atomic operations are supported.
2848 atomic128=no
2849 if test "$int128" = "yes"; then
2850 cat > $TMPC << EOF
2851 int main(void)
2853 unsigned __int128 x = 0, y = 0;
2854 y = __atomic_load(&x, 0);
2855 __atomic_store(&x, y, 0);
2856 __atomic_compare_exchange(&x, &y, x, 0, 0, 0);
2857 return 0;
2860 if compile_prog "" "" ; then
2861 atomic128=yes
2865 cmpxchg128=no
2866 if test "$int128" = yes && test "$atomic128" = no; then
2867 cat > $TMPC << EOF
2868 int main(void)
2870 unsigned __int128 x = 0, y = 0;
2871 __sync_val_compare_and_swap_16(&x, y, x);
2872 return 0;
2875 if compile_prog "" "" ; then
2876 cmpxchg128=yes
2880 ########################################
2881 # check if ccache is interfering with
2882 # semantic analysis of macros
2884 unset CCACHE_CPP2
2885 ccache_cpp2=no
2886 cat > $TMPC << EOF
2887 static const int Z = 1;
2888 #define fn() ({ Z; })
2889 #define TAUT(X) ((X) == Z)
2890 #define PAREN(X, Y) (X == Y)
2891 #define ID(X) (X)
2892 int main(int argc, char *argv[])
2894 int x = 0, y = 0;
2895 x = ID(x);
2896 x = fn();
2897 fn();
2898 if (PAREN(x, y)) return 0;
2899 if (TAUT(Z)) return 0;
2900 return 0;
2904 if ! compile_object "-Werror"; then
2905 ccache_cpp2=yes
2908 #################################################
2909 # clang does not support glibc + FORTIFY_SOURCE.
2911 if test "$fortify_source" != "no"; then
2912 if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
2913 fortify_source="no";
2914 elif test -n "$cxx" && has $cxx &&
2915 echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
2916 fortify_source="no";
2917 else
2918 fortify_source="yes"
2922 ##########################################
2923 # check for usable membarrier system call
2924 if test "$membarrier" = "yes"; then
2925 have_membarrier=no
2926 if test "$mingw32" = "yes" ; then
2927 have_membarrier=yes
2928 elif test "$linux" = "yes" ; then
2929 cat > $TMPC << EOF
2930 #include <linux/membarrier.h>
2931 #include <sys/syscall.h>
2932 #include <unistd.h>
2933 #include <stdlib.h>
2934 int main(void) {
2935 syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
2936 syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0);
2937 exit(0);
2940 if compile_prog "" "" ; then
2941 have_membarrier=yes
2944 if test "$have_membarrier" = "no"; then
2945 feature_not_found "membarrier" "membarrier system call not available"
2947 else
2948 # Do not enable it by default even for Mingw32, because it doesn't
2949 # work on Wine.
2950 membarrier=no
2953 ##########################################
2954 # check for usable AF_ALG environment
2955 have_afalg=no
2956 cat > $TMPC << EOF
2957 #include <errno.h>
2958 #include <sys/types.h>
2959 #include <sys/socket.h>
2960 #include <linux/if_alg.h>
2961 int main(void) {
2962 int sock;
2963 sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
2964 return sock;
2967 if compile_prog "" "" ; then
2968 have_afalg=yes
2970 if test "$crypto_afalg" = "yes"
2971 then
2972 if test "$have_afalg" != "yes"
2973 then
2974 error_exit "AF_ALG requested but could not be detected"
2979 ##########################################
2980 # checks for sanitizers
2982 have_asan=no
2983 have_ubsan=no
2984 have_asan_iface_h=no
2985 have_asan_iface_fiber=no
2987 if test "$sanitizers" = "yes" ; then
2988 write_c_skeleton
2989 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
2990 have_asan=yes
2993 # we could use a simple skeleton for flags checks, but this also
2994 # detect the static linking issue of ubsan, see also:
2995 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
2996 cat > $TMPC << EOF
2997 #include <stdlib.h>
2998 int main(void) {
2999 void *tmp = malloc(10);
3000 if (tmp != NULL) {
3001 return *(int *)(tmp + 2);
3003 return 1;
3006 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
3007 have_ubsan=yes
3010 if check_include "sanitizer/asan_interface.h" ; then
3011 have_asan_iface_h=yes
3014 cat > $TMPC << EOF
3015 #include <sanitizer/asan_interface.h>
3016 int main(void) {
3017 __sanitizer_start_switch_fiber(0, 0, 0);
3018 return 0;
3021 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
3022 have_asan_iface_fiber=yes
3026 # Thread sanitizer is, for now, much noisier than the other sanitizers;
3027 # keep it separate until that is not the case.
3028 if test "$tsan" = "yes" && test "$sanitizers" = "yes"; then
3029 error_exit "TSAN is not supported with other sanitiziers."
3031 have_tsan=no
3032 have_tsan_iface_fiber=no
3033 if test "$tsan" = "yes" ; then
3034 write_c_skeleton
3035 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
3036 have_tsan=yes
3038 cat > $TMPC << EOF
3039 #include <sanitizer/tsan_interface.h>
3040 int main(void) {
3041 __tsan_create_fiber(0);
3042 return 0;
3045 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
3046 have_tsan_iface_fiber=yes
3050 ##########################################
3051 # check for slirp
3053 case "$slirp" in
3054 auto | enabled | internal)
3055 # Simpler to always update submodule, even if not needed.
3056 git_submodules="${git_submodules} slirp"
3058 esac
3060 # Check for slirp smbd dupport
3061 : ${smbd=${SMBD-/usr/sbin/smbd}}
3062 if test "$slirp_smbd" != "no" ; then
3063 if test "$mingw32" = "yes" ; then
3064 if test "$slirp_smbd" = "yes" ; then
3065 error_exit "Host smbd not supported on this platform."
3067 slirp_smbd=no
3068 else
3069 slirp_smbd=yes
3073 ##########################################
3074 # check for usable __NR_keyctl syscall
3076 if test "$linux" = "yes" ; then
3078 have_keyring=no
3079 cat > $TMPC << EOF
3080 #include <errno.h>
3081 #include <asm/unistd.h>
3082 #include <linux/keyctl.h>
3083 #include <unistd.h>
3084 int main(void) {
3085 return syscall(__NR_keyctl, KEYCTL_READ, 0, NULL, NULL, 0);
3088 if compile_prog "" "" ; then
3089 have_keyring=yes
3092 if test "$secret_keyring" != "no"
3093 then
3094 if test "$have_keyring" = "yes"
3095 then
3096 secret_keyring=yes
3097 else
3098 if test "$secret_keyring" = "yes"
3099 then
3100 error_exit "syscall __NR_keyctl requested, \
3101 but not implemented on your system"
3102 else
3103 secret_keyring=no
3108 ##########################################
3109 # End of CC checks
3110 # After here, no more $cc or $ld runs
3112 write_c_skeleton
3114 if test "$gcov" = "yes" ; then
3116 elif test "$fortify_source" = "yes" ; then
3117 QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
3118 debug=no
3121 case "$ARCH" in
3122 alpha)
3123 # Ensure there's only a single GP
3124 QEMU_CFLAGS="-msmall-data $QEMU_CFLAGS"
3126 esac
3128 if test "$gprof" = "yes" ; then
3129 QEMU_CFLAGS="-p $QEMU_CFLAGS"
3130 QEMU_LDFLAGS="-p $QEMU_LDFLAGS"
3133 if test "$have_asan" = "yes"; then
3134 QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS"
3135 QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS"
3136 if test "$have_asan_iface_h" = "no" ; then
3137 echo "ASAN build enabled, but ASAN header missing." \
3138 "Without code annotation, the report may be inferior."
3139 elif test "$have_asan_iface_fiber" = "no" ; then
3140 echo "ASAN build enabled, but ASAN header is too old." \
3141 "Without code annotation, the report may be inferior."
3144 if test "$have_tsan" = "yes" ; then
3145 if test "$have_tsan_iface_fiber" = "yes" ; then
3146 QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS"
3147 QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS"
3148 else
3149 error_exit "Cannot enable TSAN due to missing fiber annotation interface."
3151 elif test "$tsan" = "yes" ; then
3152 error_exit "Cannot enable TSAN due to missing sanitize thread interface."
3154 if test "$have_ubsan" = "yes"; then
3155 QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS"
3156 QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS"
3159 ##########################################
3161 # Exclude --warn-common with TSan to suppress warnings from the TSan libraries.
3162 if test "$solaris" = "no" && test "$tsan" = "no"; then
3163 if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
3164 QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS"
3168 # Use ASLR, no-SEH and DEP if available
3169 if test "$mingw32" = "yes" ; then
3170 flags="--no-seh --nxcompat"
3172 # Disable ASLR for debug builds to allow debugging with gdb
3173 if test "$debug" = "no" ; then
3174 flags="--dynamicbase $flags"
3177 for flag in $flags; do
3178 if ld_has $flag ; then
3179 QEMU_LDFLAGS="-Wl,$flag $QEMU_LDFLAGS"
3181 done
3184 # Probe for guest agent support/options
3186 if [ "$guest_agent" != "no" ]; then
3187 if [ "$softmmu" = no -a "$want_tools" = no ] ; then
3188 guest_agent=no
3189 elif [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
3190 guest_agent=yes
3191 elif [ "$guest_agent" != yes ]; then
3192 guest_agent=no
3193 else
3194 error_exit "Guest agent is not supported on this platform"
3198 # Guest agent Windows MSI package
3200 if test "$QEMU_GA_MANUFACTURER" = ""; then
3201 QEMU_GA_MANUFACTURER=QEMU
3203 if test "$QEMU_GA_DISTRO" = ""; then
3204 QEMU_GA_DISTRO=Linux
3206 if test "$QEMU_GA_VERSION" = ""; then
3207 QEMU_GA_VERSION=$(cat $source_path/VERSION)
3210 QEMU_GA_MSI_MINGW_DLL_PATH="$($pkg_config --variable=prefix glib-2.0)/bin"
3212 # Mac OS X ships with a broken assembler
3213 roms=
3214 if { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \
3215 test "$targetos" != "darwin" && test "$targetos" != "sunos" && \
3216 test "$targetos" != "haiku" && test "$softmmu" = yes ; then
3217 # Different host OS linkers have different ideas about the name of the ELF
3218 # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
3219 # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
3220 for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
3221 if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
3222 ld_i386_emulation="$emu"
3223 roms="optionrom"
3224 break
3226 done
3229 # Only build s390-ccw bios if we're on s390x and the compiler has -march=z900
3230 # or -march=z10 (which is the lowest architecture level that Clang supports)
3231 if test "$cpu" = "s390x" ; then
3232 write_c_skeleton
3233 compile_prog "-march=z900" ""
3234 has_z900=$?
3235 if [ $has_z900 = 0 ] || compile_object "-march=z10 -msoft-float -Werror"; then
3236 if [ $has_z900 != 0 ]; then
3237 echo "WARNING: Your compiler does not support the z900!"
3238 echo " The s390-ccw bios will only work with guest CPUs >= z10."
3240 roms="$roms s390-ccw"
3241 # SLOF is required for building the s390-ccw firmware on s390x,
3242 # since it is using the libnet code from SLOF for network booting.
3243 git_submodules="${git_submodules} roms/SLOF"
3247 # Check that the C++ compiler exists and works with the C compiler.
3248 # All the QEMU_CXXFLAGS are based on QEMU_CFLAGS. Keep this at the end to don't miss any other that could be added.
3249 if has $cxx; then
3250 cat > $TMPC <<EOF
3251 int c_function(void);
3252 int main(void) { return c_function(); }
3255 compile_object
3257 cat > $TMPCXX <<EOF
3258 extern "C" {
3259 int c_function(void);
3261 int c_function(void) { return 42; }
3264 update_cxxflags
3266 if do_cxx $CXXFLAGS $EXTRA_CXXFLAGS $CONFIGURE_CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then
3267 # C++ compiler $cxx works ok with C compiler $cc
3269 else
3270 echo "C++ compiler $cxx does not work with C compiler $cc"
3271 echo "Disabling C++ specific optional code"
3272 cxx=
3274 else
3275 echo "No C++ compiler available; disabling C++ specific optional code"
3276 cxx=
3279 if !(GIT="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then
3280 exit 1
3283 config_host_mak="config-host.mak"
3285 echo "# Automatically generated by configure - do not modify" > $config_host_mak
3286 echo >> $config_host_mak
3288 echo all: >> $config_host_mak
3289 echo "GIT=$git" >> $config_host_mak
3290 echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
3291 echo "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak
3293 if test "$debug_tcg" = "yes" ; then
3294 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
3296 if test "$mingw32" = "yes" ; then
3297 echo "CONFIG_WIN32=y" >> $config_host_mak
3298 if test "$guest_agent_with_vss" = "yes" ; then
3299 echo "CONFIG_QGA_VSS=y" >> $config_host_mak
3300 echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
3301 echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
3303 if test "$guest_agent_ntddscsi" = "yes" ; then
3304 echo "CONFIG_QGA_NTDDSCSI=y" >> $config_host_mak
3306 echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
3307 echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
3308 echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
3309 echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
3310 else
3311 echo "CONFIG_POSIX=y" >> $config_host_mak
3314 if test "$linux" = "yes" ; then
3315 echo "CONFIG_LINUX=y" >> $config_host_mak
3318 if test "$darwin" = "yes" ; then
3319 echo "CONFIG_DARWIN=y" >> $config_host_mak
3322 if test "$solaris" = "yes" ; then
3323 echo "CONFIG_SOLARIS=y" >> $config_host_mak
3325 if test "$static" = "yes" ; then
3326 echo "CONFIG_STATIC=y" >> $config_host_mak
3328 if test "$profiler" = "yes" ; then
3329 echo "CONFIG_PROFILER=y" >> $config_host_mak
3331 if test "$want_tools" = "yes" ; then
3332 echo "CONFIG_TOOLS=y" >> $config_host_mak
3334 if test "$guest_agent" = "yes" ; then
3335 echo "CONFIG_GUEST_AGENT=y" >> $config_host_mak
3337 if test "$slirp_smbd" = "yes" ; then
3338 echo "CONFIG_SLIRP_SMBD=y" >> $config_host_mak
3339 echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
3341 if test "$gprof" = "yes" ; then
3342 echo "CONFIG_GPROF=y" >> $config_host_mak
3344 echo "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
3345 echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
3346 if test "$block_drv_whitelist_tools" = "yes" ; then
3347 echo "CONFIG_BDRV_WHITELIST_TOOLS=y" >> $config_host_mak
3349 qemu_version=$(head $source_path/VERSION)
3350 echo "PKGVERSION=$pkgversion" >>$config_host_mak
3351 echo "SRC_PATH=$source_path" >> $config_host_mak
3352 echo "TARGET_DIRS=$target_list" >> $config_host_mak
3353 if test "$modules" = "yes"; then
3354 # $shacmd can generate a hash started with digit, which the compiler doesn't
3355 # like as an symbol. So prefix it with an underscore
3356 echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
3357 echo "CONFIG_MODULES=y" >> $config_host_mak
3359 if test "$module_upgrades" = "yes"; then
3360 echo "CONFIG_MODULE_UPGRADES=y" >> $config_host_mak
3362 if test "$have_usbfs" = "yes" ; then
3363 echo "CONFIG_USBFS=y" >> $config_host_mak
3365 if test "$gio" = "yes" ; then
3366 echo "CONFIG_GIO=y" >> $config_host_mak
3367 echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak
3368 echo "GIO_LIBS=$gio_libs" >> $config_host_mak
3370 if test "$gdbus_codegen" != "" ; then
3371 echo "GDBUS_CODEGEN=$gdbus_codegen" >> $config_host_mak
3373 echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
3375 if test "$xen" = "enabled" ; then
3376 echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
3377 echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
3378 echo "XEN_CFLAGS=$xen_cflags" >> $config_host_mak
3379 echo "XEN_LIBS=$xen_libs" >> $config_host_mak
3381 if test "$vhost_scsi" = "yes" ; then
3382 echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
3384 if test "$vhost_net" = "yes" ; then
3385 echo "CONFIG_VHOST_NET=y" >> $config_host_mak
3387 if test "$vhost_net_user" = "yes" ; then
3388 echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak
3390 if test "$vhost_net_vdpa" = "yes" ; then
3391 echo "CONFIG_VHOST_NET_VDPA=y" >> $config_host_mak
3393 if test "$vhost_crypto" = "yes" ; then
3394 echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
3396 if test "$vhost_vsock" = "yes" ; then
3397 echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
3398 if test "$vhost_user" = "yes" ; then
3399 echo "CONFIG_VHOST_USER_VSOCK=y" >> $config_host_mak
3402 if test "$vhost_kernel" = "yes" ; then
3403 echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak
3405 if test "$vhost_user" = "yes" ; then
3406 echo "CONFIG_VHOST_USER=y" >> $config_host_mak
3408 if test "$vhost_vdpa" = "yes" ; then
3409 echo "CONFIG_VHOST_VDPA=y" >> $config_host_mak
3411 if test "$vhost_user_fs" = "yes" ; then
3412 echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak
3414 if test "$membarrier" = "yes" ; then
3415 echo "CONFIG_MEMBARRIER=y" >> $config_host_mak
3417 if test "$tcg" = "enabled" -a "$tcg_interpreter" = "true" ; then
3418 echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
3421 if test "$opengl" = "yes" ; then
3422 echo "CONFIG_OPENGL=y" >> $config_host_mak
3423 echo "OPENGL_CFLAGS=$opengl_cflags" >> $config_host_mak
3424 echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
3427 if test "$avx2_opt" = "yes" ; then
3428 echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
3431 if test "$avx512f_opt" = "yes" ; then
3432 echo "CONFIG_AVX512F_OPT=y" >> $config_host_mak
3435 # XXX: suppress that
3436 if [ "$bsd" = "yes" ] ; then
3437 echo "CONFIG_BSD=y" >> $config_host_mak
3440 if test "$qom_cast_debug" = "yes" ; then
3441 echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
3444 echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
3445 if test "$coroutine_pool" = "yes" ; then
3446 echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
3447 else
3448 echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
3451 if test "$debug_stack_usage" = "yes" ; then
3452 echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
3455 if test "$crypto_afalg" = "yes" ; then
3456 echo "CONFIG_AF_ALG=y" >> $config_host_mak
3459 if test "$have_asan_iface_fiber" = "yes" ; then
3460 echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
3463 if test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then
3464 echo "CONFIG_TSAN=y" >> $config_host_mak
3467 if test "$cpuid_h" = "yes" ; then
3468 echo "CONFIG_CPUID_H=y" >> $config_host_mak
3471 if test "$int128" = "yes" ; then
3472 echo "CONFIG_INT128=y" >> $config_host_mak
3475 if test "$atomic128" = "yes" ; then
3476 echo "CONFIG_ATOMIC128=y" >> $config_host_mak
3479 if test "$cmpxchg128" = "yes" ; then
3480 echo "CONFIG_CMPXCHG128=y" >> $config_host_mak
3483 if test "$live_block_migration" = "yes" ; then
3484 echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
3487 if test "$tpm" = "yes"; then
3488 echo 'CONFIG_TPM=y' >> $config_host_mak
3491 if test "$rdma" = "yes" ; then
3492 echo "CONFIG_RDMA=y" >> $config_host_mak
3493 echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
3496 if test "$pvrdma" = "yes" ; then
3497 echo "CONFIG_PVRDMA=y" >> $config_host_mak
3500 if test "$replication" = "yes" ; then
3501 echo "CONFIG_REPLICATION=y" >> $config_host_mak
3504 if test "$debug_mutex" = "yes" ; then
3505 echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak
3508 if test "$bochs" = "yes" ; then
3509 echo "CONFIG_BOCHS=y" >> $config_host_mak
3511 if test "$cloop" = "yes" ; then
3512 echo "CONFIG_CLOOP=y" >> $config_host_mak
3514 if test "$dmg" = "yes" ; then
3515 echo "CONFIG_DMG=y" >> $config_host_mak
3517 if test "$qcow1" = "yes" ; then
3518 echo "CONFIG_QCOW1=y" >> $config_host_mak
3520 if test "$vdi" = "yes" ; then
3521 echo "CONFIG_VDI=y" >> $config_host_mak
3523 if test "$vvfat" = "yes" ; then
3524 echo "CONFIG_VVFAT=y" >> $config_host_mak
3526 if test "$qed" = "yes" ; then
3527 echo "CONFIG_QED=y" >> $config_host_mak
3529 if test "$parallels" = "yes" ; then
3530 echo "CONFIG_PARALLELS=y" >> $config_host_mak
3533 if test "$plugins" = "yes" ; then
3534 echo "CONFIG_PLUGIN=y" >> $config_host_mak
3537 if test -n "$gdb_bin"; then
3538 gdb_version=$($gdb_bin --version | head -n 1)
3539 if version_ge ${gdb_version##* } 9.1; then
3540 echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
3544 if test "$secret_keyring" = "yes" ; then
3545 echo "CONFIG_SECRET_KEYRING=y" >> $config_host_mak
3548 echo "ROMS=$roms" >> $config_host_mak
3549 echo "MAKE=$make" >> $config_host_mak
3550 echo "PYTHON=$python" >> $config_host_mak
3551 echo "GENISOIMAGE=$genisoimage" >> $config_host_mak
3552 echo "MESON=$meson" >> $config_host_mak
3553 echo "NINJA=$ninja" >> $config_host_mak
3554 echo "CC=$cc" >> $config_host_mak
3555 echo "HOST_CC=$host_cc" >> $config_host_mak
3556 if $iasl -h > /dev/null 2>&1; then
3557 echo "CONFIG_IASL=$iasl" >> $config_host_mak
3559 echo "AR=$ar" >> $config_host_mak
3560 echo "AS=$as" >> $config_host_mak
3561 echo "CCAS=$ccas" >> $config_host_mak
3562 echo "CPP=$cpp" >> $config_host_mak
3563 echo "OBJCOPY=$objcopy" >> $config_host_mak
3564 echo "LD=$ld" >> $config_host_mak
3565 echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
3566 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
3567 echo "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
3568 echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
3569 echo "GLIB_LIBS=$glib_libs" >> $config_host_mak
3570 echo "GLIB_VERSION=$(pkg-config --modversion glib-2.0)" >> $config_host_mak
3571 echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
3572 echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
3573 echo "STRIP=$strip" >> $config_host_mak
3574 echo "EXESUF=$EXESUF" >> $config_host_mak
3575 echo "LIBS_QGA=$libs_qga" >> $config_host_mak
3577 if test "$rng_none" = "yes"; then
3578 echo "CONFIG_RNG_NONE=y" >> $config_host_mak
3581 # use included Linux headers
3582 if test "$linux" = "yes" ; then
3583 mkdir -p linux-headers
3584 case "$cpu" in
3585 i386|x86_64)
3586 linux_arch=x86
3588 ppc|ppc64)
3589 linux_arch=powerpc
3591 s390x)
3592 linux_arch=s390
3594 aarch64)
3595 linux_arch=arm64
3597 loongarch*)
3598 linux_arch=loongarch
3600 mips64)
3601 linux_arch=mips
3604 # For most CPUs the kernel architecture name and QEMU CPU name match.
3605 linux_arch="$cpu"
3607 esac
3608 # For non-KVM architectures we will not have asm headers
3609 if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
3610 symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
3614 for target in $target_list; do
3615 target_dir="$target"
3616 target_name=$(echo $target | cut -d '-' -f 1)$EXESUF
3617 mkdir -p $target_dir
3618 case $target in
3619 *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;;
3620 *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;;
3621 esac
3622 done
3624 echo "CONFIG_QEMU_INTERP_PREFIX=$interp_prefix" | sed 's/%M/@0@/' >> $config_host_mak
3625 if test "$default_targets" = "yes"; then
3626 echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak
3629 if test "$numa" = "yes"; then
3630 echo "CONFIG_NUMA=y" >> $config_host_mak
3631 echo "NUMA_LIBS=$numa_libs" >> $config_host_mak
3634 if test "$ccache_cpp2" = "yes"; then
3635 echo "export CCACHE_CPP2=y" >> $config_host_mak
3638 if test "$safe_stack" = "yes"; then
3639 echo "CONFIG_SAFESTACK=y" >> $config_host_mak
3642 # If we're using a separate build tree, set it up now.
3643 # LINKS are things to symlink back into the source tree
3644 # (these can be both files and directories).
3645 # Caution: do not add files or directories here using wildcards. This
3646 # will result in problems later if a new file matching the wildcard is
3647 # added to the source tree -- nothing will cause configure to be rerun
3648 # so the build tree will be missing the link back to the new file, and
3649 # tests might fail. Prefer to keep the relevant files in their own
3650 # directory and symlink the directory instead.
3651 LINKS="Makefile"
3652 LINKS="$LINKS tests/tcg/Makefile.target"
3653 LINKS="$LINKS pc-bios/optionrom/Makefile"
3654 LINKS="$LINKS pc-bios/s390-ccw/Makefile"
3655 LINKS="$LINKS roms/seabios/Makefile"
3656 LINKS="$LINKS pc-bios/qemu-icon.bmp"
3657 LINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
3658 LINKS="$LINKS tests/avocado tests/data"
3659 LINKS="$LINKS tests/qemu-iotests/check"
3660 LINKS="$LINKS python"
3661 LINKS="$LINKS contrib/plugins/Makefile "
3662 for bios_file in \
3663 $source_path/pc-bios/*.bin \
3664 $source_path/pc-bios/*.elf \
3665 $source_path/pc-bios/*.lid \
3666 $source_path/pc-bios/*.rom \
3667 $source_path/pc-bios/*.dtb \
3668 $source_path/pc-bios/*.img \
3669 $source_path/pc-bios/openbios-* \
3670 $source_path/pc-bios/u-boot.* \
3671 $source_path/pc-bios/palcode-* \
3672 $source_path/pc-bios/qemu_vga.ndrv
3675 LINKS="$LINKS pc-bios/$(basename $bios_file)"
3676 done
3677 for f in $LINKS ; do
3678 if [ -e "$source_path/$f" ]; then
3679 mkdir -p `dirname ./$f`
3680 symlink "$source_path/$f" "$f"
3682 done
3684 (for i in $cross_cc_vars; do
3685 export $i
3686 done
3687 export target_list source_path use_containers cpu
3688 $source_path/tests/tcg/configure.sh)
3690 # temporary config to build submodules
3691 if test -f $source_path/roms/seabios/Makefile; then
3692 for rom in seabios; do
3693 config_mak=roms/$rom/config.mak
3694 echo "# Automatically generated by configure - do not modify" > $config_mak
3695 echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
3696 echo "AS=$as" >> $config_mak
3697 echo "CCAS=$ccas" >> $config_mak
3698 echo "CC=$cc" >> $config_mak
3699 echo "BCC=bcc" >> $config_mak
3700 echo "CPP=$cpp" >> $config_mak
3701 echo "OBJCOPY=objcopy" >> $config_mak
3702 echo "IASL=$iasl" >> $config_mak
3703 echo "LD=$ld" >> $config_mak
3704 echo "RANLIB=$ranlib" >> $config_mak
3705 done
3708 config_mak=pc-bios/optionrom/config.mak
3709 echo "# Automatically generated by configure - do not modify" > $config_mak
3710 echo "TOPSRC_DIR=$source_path" >> $config_mak
3712 if test "$skip_meson" = no; then
3713 cross="config-meson.cross.new"
3714 meson_quote() {
3715 test $# = 0 && return
3716 echo "'$(echo $* | sed "s/ /','/g")'"
3719 echo "# Automatically generated by configure - do not modify" > $cross
3720 echo "[properties]" >> $cross
3722 # unroll any custom device configs
3723 for a in $device_archs; do
3724 eval "c=\$devices_${a}"
3725 echo "${a}-softmmu = '$c'" >> $cross
3726 done
3728 test -z "$cxx" && echo "link_language = 'c'" >> $cross
3729 echo "[built-in options]" >> $cross
3730 echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross
3731 echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross
3732 echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross
3733 echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross
3734 echo "[binaries]" >> $cross
3735 echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross
3736 test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross
3737 test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross
3738 echo "ar = [$(meson_quote $ar)]" >> $cross
3739 echo "nm = [$(meson_quote $nm)]" >> $cross
3740 echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross
3741 echo "ranlib = [$(meson_quote $ranlib)]" >> $cross
3742 if has $sdl2_config; then
3743 echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross
3745 echo "strip = [$(meson_quote $strip)]" >> $cross
3746 echo "windres = [$(meson_quote $windres)]" >> $cross
3747 if test "$cross_compile" = "yes"; then
3748 cross_arg="--cross-file config-meson.cross"
3749 echo "[host_machine]" >> $cross
3750 echo "system = '$targetos'" >> $cross
3751 case "$cpu" in
3752 i386)
3753 echo "cpu_family = 'x86'" >> $cross
3756 echo "cpu_family = '$cpu'" >> $cross
3758 esac
3759 echo "cpu = '$cpu'" >> $cross
3760 if test "$bigendian" = "yes" ; then
3761 echo "endian = 'big'" >> $cross
3762 else
3763 echo "endian = 'little'" >> $cross
3765 else
3766 cross_arg="--native-file config-meson.cross"
3768 mv $cross config-meson.cross
3770 rm -rf meson-private meson-info meson-logs
3771 run_meson() {
3772 NINJA=$ninja $meson setup \
3773 --prefix "$prefix" \
3774 --libdir "$libdir" \
3775 --libexecdir "$libexecdir" \
3776 --bindir "$bindir" \
3777 --includedir "$includedir" \
3778 --datadir "$datadir" \
3779 --mandir "$mandir" \
3780 --sysconfdir "$sysconfdir" \
3781 --localedir "$localedir" \
3782 --localstatedir "$local_statedir" \
3783 -Daudio_drv_list=$audio_drv_list \
3784 -Ddefault_devices=$default_devices \
3785 -Ddocdir="$docdir" \
3786 -Dqemu_firmwarepath="$firmwarepath" \
3787 -Dqemu_suffix="$qemu_suffix" \
3788 -Dsphinx_build="$sphinx_build" \
3789 -Dtrace_file="$trace_file" \
3790 -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) \
3791 -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo false; fi) \
3792 -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \
3793 -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \
3794 -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \
3795 -Db_lto=$lto -Dcfi=$cfi -Dtcg=$tcg -Dxen=$xen \
3796 -Dcapstone=$capstone -Dfdt=$fdt -Dslirp=$slirp \
3797 $(test -n "${LIB_FUZZING_ENGINE+xxx}" && echo "-Dfuzzing_engine=$LIB_FUZZING_ENGINE") \
3798 $(if test "$default_feature" = no; then echo "-Dauto_features=disabled"; fi) \
3799 "$@" $cross_arg "$PWD" "$source_path"
3801 eval run_meson $meson_options
3802 if test "$?" -ne 0 ; then
3803 error_exit "meson setup failed"
3805 else
3806 if test -f meson-private/cmd_line.txt; then
3807 # Adjust old command line options whose type was changed
3808 # Avoids having to use "setup --wipe" when Meson is upgraded
3809 perl -i -ne '
3810 s/^gettext = true$/gettext = auto/;
3811 s/^gettext = false$/gettext = disabled/;
3812 /^b_staticpic/ && next;
3813 print;' meson-private/cmd_line.txt
3817 # Save the configure command line for later reuse.
3818 cat <<EOD >config.status
3819 #!/bin/sh
3820 # Generated by configure.
3821 # Run this file to recreate the current configuration.
3822 # Compiler output produced by configure, useful for debugging
3823 # configure, is in config.log if it exists.
3826 preserve_env() {
3827 envname=$1
3829 eval envval=\$$envname
3831 if test -n "$envval"
3832 then
3833 echo "$envname='$envval'" >> config.status
3834 echo "export $envname" >> config.status
3835 else
3836 echo "unset $envname" >> config.status
3840 # Preserve various env variables that influence what
3841 # features/build target configure will detect
3842 preserve_env AR
3843 preserve_env AS
3844 preserve_env CC
3845 preserve_env CPP
3846 preserve_env CFLAGS
3847 preserve_env CXX
3848 preserve_env CXXFLAGS
3849 preserve_env INSTALL
3850 preserve_env LD
3851 preserve_env LDFLAGS
3852 preserve_env LD_LIBRARY_PATH
3853 preserve_env LIBTOOL
3854 preserve_env MAKE
3855 preserve_env NM
3856 preserve_env OBJCOPY
3857 preserve_env PATH
3858 preserve_env PKG_CONFIG
3859 preserve_env PKG_CONFIG_LIBDIR
3860 preserve_env PKG_CONFIG_PATH
3861 preserve_env PYTHON
3862 preserve_env SDL2_CONFIG
3863 preserve_env SMBD
3864 preserve_env STRIP
3865 preserve_env WINDRES
3867 printf "exec" >>config.status
3868 for i in "$0" "$@"; do
3869 test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status
3870 done
3871 echo ' "$@"' >>config.status
3872 chmod +x config.status
3874 rm -r "$TMPDIR1"