ui/vdagent: add serial capability support
[qemu/ar7.git] / configure
blob8ccfe51673eb0792994d17f50ca2c48743a117f6
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"
81 TMPTXT="${TMPDIR1}/${TMPB}.txt"
83 rm -f config.log
85 # Print a helpful header at the top of config.log
86 echo "# QEMU configure log $(date)" >> config.log
87 printf "# Configured with:" >> config.log
88 printf " '%s'" "$0" "$@" >> config.log
89 echo >> config.log
90 echo "#" >> config.log
92 quote_sh() {
93 printf "%s" "$1" | sed "s,','\\\\'',g; s,.*,'&',"
96 print_error() {
97 (echo
98 echo "ERROR: $1"
99 while test -n "$2"; do
100 echo " $2"
101 shift
102 done
103 echo) >&2
106 error_exit() {
107 print_error "$@"
108 exit 1
111 do_compiler() {
112 # Run the compiler, capturing its output to the log. First argument
113 # is compiler binary to execute.
114 compiler="$1"
115 shift
116 if test -n "$BASH_VERSION"; then eval '
117 echo >>config.log "
118 funcs: ${FUNCNAME[*]}
119 lines: ${BASH_LINENO[*]}"
120 '; fi
121 echo $compiler "$@" >> config.log
122 $compiler "$@" >> config.log 2>&1 || return $?
123 # Test passed. If this is an --enable-werror build, rerun
124 # the test with -Werror and bail out if it fails. This
125 # makes warning-generating-errors in configure test code
126 # obvious to developers.
127 if test "$werror" != "yes"; then
128 return 0
130 # Don't bother rerunning the compile if we were already using -Werror
131 case "$*" in
132 *-Werror*)
133 return 0
135 esac
136 echo $compiler -Werror "$@" >> config.log
137 $compiler -Werror "$@" >> config.log 2>&1 && return $?
138 error_exit "configure test passed without -Werror but failed with -Werror." \
139 "This is probably a bug in the configure script. The failing command" \
140 "will be at the bottom of config.log." \
141 "You can run configure with --disable-werror to bypass this check."
144 do_cc() {
145 do_compiler "$cc" $CPU_CFLAGS "$@"
148 do_cxx() {
149 do_compiler "$cxx" $CPU_CFLAGS "$@"
152 # Append $2 to the variable named $1, with space separation
153 add_to() {
154 eval $1=\${$1:+\"\$$1 \"}\$2
157 update_cxxflags() {
158 # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
159 # options which some versions of GCC's C++ compiler complain about
160 # because they only make sense for C programs.
161 QEMU_CXXFLAGS="-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS"
162 CONFIGURE_CXXFLAGS=$(echo "$CONFIGURE_CFLAGS" | sed s/-std=gnu11/-std=gnu++11/)
163 for arg in $QEMU_CFLAGS; do
164 case $arg in
165 -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
166 -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
169 QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
171 esac
172 done
175 compile_object() {
176 local_cflags="$1"
177 do_cc $CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
180 compile_prog() {
181 local_cflags="$1"
182 local_ldflags="$2"
183 do_cc $CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC \
184 $LDFLAGS $EXTRA_LDFLAGS $CONFIGURE_LDFLAGS $QEMU_LDFLAGS $local_ldflags
187 # symbolically link $1 to $2. Portable version of "ln -sf".
188 symlink() {
189 rm -rf "$2"
190 mkdir -p "$(dirname "$2")"
191 ln -s "$1" "$2"
194 # check whether a command is available to this shell (may be either an
195 # executable or a builtin)
196 has() {
197 type "$1" >/dev/null 2>&1
200 version_ge () {
201 local_ver1=$(expr "$1" : '\([0-9.]*\)' | tr . ' ')
202 local_ver2=$(echo "$2" | tr . ' ')
203 while true; do
204 set x $local_ver1
205 local_first=${2-0}
206 # 'shift 2' if $2 is set, or 'shift' if $2 is not set
207 shift ${2:+2}
208 local_ver1=$*
209 set x $local_ver2
210 # the second argument finished, the first must be greater or equal
211 test $# = 1 && return 0
212 test $local_first -lt $2 && return 1
213 test $local_first -gt $2 && return 0
214 shift ${2:+2}
215 local_ver2=$*
216 done
219 glob() {
220 eval test -z '"${1#'"$2"'}"'
223 ld_has() {
224 $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
227 if printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]";
228 then
229 error_exit "main directory cannot contain spaces nor colons"
232 # default parameters
233 cpu=""
234 iasl="iasl"
235 interp_prefix="/usr/gnemul/qemu-%M"
236 static="no"
237 cross_compile="no"
238 cross_prefix=""
239 audio_drv_list="default"
240 block_drv_rw_whitelist=""
241 block_drv_ro_whitelist=""
242 block_drv_whitelist_tools="no"
243 host_cc="cc"
244 libs_qga=""
245 debug_info="yes"
246 lto="false"
247 stack_protector=""
248 safe_stack=""
249 use_containers="yes"
250 gdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
252 if test -e "$source_path/.git"
253 then
254 git_submodules_action="update"
255 else
256 git_submodules_action="ignore"
259 git_submodules="ui/keycodemapdb"
260 git="git"
262 # Don't accept a target_list environment variable.
263 unset target_list
264 unset target_list_exclude
266 # Default value for a variable defining feature "foo".
267 # * foo="no" feature will only be used if --enable-foo arg is given
268 # * foo="" feature will be searched for, and if found, will be used
269 # unless --disable-foo is given
270 # * foo="yes" this value will only be set by --enable-foo flag.
271 # feature will searched for,
272 # if not found, configure exits with error
274 # Always add --enable-foo and --disable-foo command line args.
275 # Distributions want to ensure that several features are compiled in, and it
276 # is impossible without a --enable-foo that exits if a feature is not found.
278 default_feature=""
279 # parse CC options second
280 for opt do
281 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
282 case "$opt" in
283 --without-default-features)
284 default_feature="no"
286 esac
287 done
289 EXTRA_CFLAGS=""
290 EXTRA_CXXFLAGS=""
291 EXTRA_LDFLAGS=""
293 xen_ctrl_version="$default_feature"
294 xfs="$default_feature"
295 membarrier="$default_feature"
296 vhost_kernel="$default_feature"
297 vhost_net="$default_feature"
298 vhost_crypto="$default_feature"
299 vhost_scsi="$default_feature"
300 vhost_vsock="$default_feature"
301 vhost_user="no"
302 vhost_user_fs="$default_feature"
303 vhost_vdpa="$default_feature"
304 rdma="$default_feature"
305 pvrdma="$default_feature"
306 gprof="no"
307 debug_tcg="no"
308 debug="no"
309 sanitizers="no"
310 tsan="no"
311 fortify_source="$default_feature"
312 strip_opt="yes"
313 mingw32="no"
314 gcov="no"
315 EXESUF=""
316 modules="no"
317 module_upgrades="no"
318 prefix="/usr/local"
319 qemu_suffix="qemu"
320 bsd="no"
321 linux="no"
322 solaris="no"
323 profiler="no"
324 softmmu="yes"
325 linux_user="no"
326 bsd_user="no"
327 pkgversion=""
328 pie=""
329 qom_cast_debug="yes"
330 trace_backends="log"
331 trace_file="trace"
332 opengl="$default_feature"
333 cpuid_h="no"
334 avx2_opt="$default_feature"
335 guest_agent="$default_feature"
336 guest_agent_with_vss="no"
337 guest_agent_ntddscsi="no"
338 vss_win32_sdk="$default_feature"
339 win_sdk="no"
340 want_tools="$default_feature"
341 coroutine=""
342 coroutine_pool="$default_feature"
343 debug_stack_usage="no"
344 crypto_afalg="no"
345 tls_priority="NORMAL"
346 tpm="$default_feature"
347 live_block_migration=${default_feature:-yes}
348 numa="$default_feature"
349 replication=${default_feature:-yes}
350 bochs=${default_feature:-yes}
351 cloop=${default_feature:-yes}
352 dmg=${default_feature:-yes}
353 qcow1=${default_feature:-yes}
354 vdi=${default_feature:-yes}
355 vvfat=${default_feature:-yes}
356 qed=${default_feature:-yes}
357 parallels=${default_feature:-yes}
358 debug_mutex="no"
359 plugins="$default_feature"
360 rng_none="no"
361 secret_keyring="$default_feature"
362 meson=""
363 meson_args=""
364 ninja=""
365 gio="$default_feature"
366 skip_meson=no
367 slirp_smbd="$default_feature"
369 # The following Meson options are handled manually (still they
370 # are included in the automatically generated help message)
372 # 1. Track which submodules are needed
373 capstone="auto"
374 fdt="auto"
375 slirp="auto"
377 # 2. Support --with/--without option
378 default_devices="true"
380 # 3. Automatically enable/disable other options
381 tcg="enabled"
382 cfi="false"
384 # 4. Detection partly done in configure
385 xen=${default_feature:+disabled}
387 # parse CC options second
388 for opt do
389 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
390 case "$opt" in
391 --cross-prefix=*) cross_prefix="$optarg"
392 cross_compile="yes"
394 --cc=*) CC="$optarg"
396 --cxx=*) CXX="$optarg"
398 --cpu=*) cpu="$optarg"
400 --extra-cflags=*)
401 EXTRA_CFLAGS="$EXTRA_CFLAGS $optarg"
402 EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg"
404 --extra-cxxflags=*) EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg"
406 --extra-ldflags=*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS $optarg"
408 --enable-debug-info) debug_info="yes"
410 --disable-debug-info) debug_info="no"
412 --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
414 --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-flags-}; cc_arch=${cc_arch%%=*}
415 eval "cross_cc_cflags_${cc_arch}=\$optarg"
416 cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}"
418 --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
419 cc_archs="$cc_archs $cc_arch"
420 eval "cross_cc_${cc_arch}=\$optarg"
421 cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}"
423 esac
424 done
425 # OS specific
426 # Using uname is really, really broken. Once we have the right set of checks
427 # we can eliminate its usage altogether.
429 # Preferred compiler:
430 # ${CC} (if set)
431 # ${cross_prefix}gcc (if cross-prefix specified)
432 # system compiler
433 if test -z "${CC}${cross_prefix}"; then
434 cc="$host_cc"
435 else
436 cc="${CC-${cross_prefix}gcc}"
439 if test -z "${CXX}${cross_prefix}"; then
440 cxx="c++"
441 else
442 cxx="${CXX-${cross_prefix}g++}"
445 ar="${AR-${cross_prefix}ar}"
446 as="${AS-${cross_prefix}as}"
447 ccas="${CCAS-$cc}"
448 cpp="${CPP-$cc -E}"
449 objcopy="${OBJCOPY-${cross_prefix}objcopy}"
450 ld="${LD-${cross_prefix}ld}"
451 ranlib="${RANLIB-${cross_prefix}ranlib}"
452 nm="${NM-${cross_prefix}nm}"
453 strip="${STRIP-${cross_prefix}strip}"
454 windres="${WINDRES-${cross_prefix}windres}"
455 pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
456 query_pkg_config() {
457 "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
459 pkg_config=query_pkg_config
460 sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
462 # default flags for all hosts
463 # We use -fwrapv to tell the compiler that we require a C dialect where
464 # left shift of signed integers is well defined and has the expected
465 # 2s-complement style results. (Both clang and gcc agree that it
466 # provides these semantics.)
467 QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv"
468 QEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
469 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
470 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
472 QEMU_LDFLAGS=
474 # Flags that are needed during configure but later taken care of by Meson
475 CONFIGURE_CFLAGS="-std=gnu11 -Wall"
476 CONFIGURE_LDFLAGS=
479 check_define() {
480 cat > $TMPC <<EOF
481 #if !defined($1)
482 #error $1 not defined
483 #endif
484 int main(void) { return 0; }
486 compile_object
489 check_include() {
490 cat > $TMPC <<EOF
491 #include <$1>
492 int main(void) { return 0; }
494 compile_object
497 write_c_skeleton() {
498 cat > $TMPC <<EOF
499 int main(void) { return 0; }
503 if check_define __linux__ ; then
504 targetos=linux
505 elif check_define _WIN32 ; then
506 targetos=windows
507 elif check_define __OpenBSD__ ; then
508 targetos=openbsd
509 elif check_define __sun__ ; then
510 targetos=sunos
511 elif check_define __HAIKU__ ; then
512 targetos=haiku
513 elif check_define __FreeBSD__ ; then
514 targetos=freebsd
515 elif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
516 targetos=gnu/kfreebsd
517 elif check_define __DragonFly__ ; then
518 targetos=dragonfly
519 elif check_define __NetBSD__; then
520 targetos=netbsd
521 elif check_define __APPLE__; then
522 targetos=darwin
523 else
524 # This is a fatal error, but don't report it yet, because we
525 # might be going to just print the --help text, or it might
526 # be the result of a missing compiler.
527 targetos=bogus
530 # OS specific
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 bsd_user="yes"
544 make="${MAKE-gmake}"
545 # needed for kinfo_getvmmap(3) in libutil.h
547 dragonfly)
548 bsd="yes"
549 make="${MAKE-gmake}"
551 netbsd)
552 bsd="yes"
553 make="${MAKE-gmake}"
555 openbsd)
556 bsd="yes"
557 make="${MAKE-gmake}"
559 darwin)
560 bsd="yes"
561 darwin="yes"
562 # Disable attempts to use ObjectiveC features in os/object.h since they
563 # won't work when we're compiling with gcc as a C compiler.
564 QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
566 sunos)
567 solaris="yes"
568 make="${MAKE-gmake}"
569 smbd="${SMBD-/usr/sfw/sbin/smbd}"
570 # needed for CMSG_ macros in sys/socket.h
571 QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
572 # needed for TIOCWIN* defines in termios.h
573 QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
574 # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
575 # Note that this check is broken for cross-compilation: if you're
576 # cross-compiling to one of these OSes then you'll need to specify
577 # the correct CPU with the --cpu option.
578 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
579 cpu="x86_64"
582 haiku)
583 pie="no"
584 QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE -fPIC $QEMU_CFLAGS"
586 linux)
587 linux="yes"
588 linux_user="yes"
589 vhost_user=${default_feature:-yes}
591 esac
593 if test ! -z "$cpu" ; then
594 # command line argument
596 elif check_define __i386__ ; then
597 cpu="i386"
598 elif check_define __x86_64__ ; then
599 if check_define __ILP32__ ; then
600 cpu="x32"
601 else
602 cpu="x86_64"
604 elif check_define __sparc__ ; then
605 if check_define __arch64__ ; then
606 cpu="sparc64"
607 else
608 cpu="sparc"
610 elif check_define _ARCH_PPC ; then
611 if check_define _ARCH_PPC64 ; then
612 if check_define _LITTLE_ENDIAN ; then
613 cpu="ppc64le"
614 else
615 cpu="ppc64"
617 else
618 cpu="ppc"
620 elif check_define __mips__ ; then
621 cpu="mips"
622 elif check_define __s390__ ; then
623 if check_define __s390x__ ; then
624 cpu="s390x"
625 else
626 cpu="s390"
628 elif check_define __riscv ; then
629 cpu="riscv"
630 elif check_define __arm__ ; then
631 cpu="arm"
632 elif check_define __aarch64__ ; then
633 cpu="aarch64"
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 strip_opt="no"
898 fortify_source="no"
900 --enable-sanitizers) sanitizers="yes"
902 --disable-sanitizers) sanitizers="no"
904 --enable-tsan) tsan="yes"
906 --disable-tsan) tsan="no"
908 --disable-strip) strip_opt="no"
910 --disable-slirp) slirp="disabled"
912 --enable-slirp) slirp="enabled"
914 --enable-slirp=git) slirp="internal"
916 --enable-slirp=*) slirp="$optarg"
918 --disable-xen) xen="disabled"
920 --enable-xen) xen="enabled"
922 --disable-tcg) tcg="disabled"
923 plugins="no"
925 --enable-tcg) tcg="enabled"
927 --enable-profiler) profiler="yes"
929 --disable-system) softmmu="no"
931 --enable-system) softmmu="yes"
933 --disable-user)
934 linux_user="no" ;
935 bsd_user="no" ;
937 --enable-user) ;;
938 --disable-linux-user) linux_user="no"
940 --enable-linux-user) linux_user="yes"
942 --disable-bsd-user) bsd_user="no"
944 --enable-bsd-user) bsd_user="yes"
946 --enable-pie) pie="yes"
948 --disable-pie) pie="no"
950 --enable-werror) werror="yes"
952 --disable-werror) werror="no"
954 --enable-lto) lto="true"
956 --disable-lto) lto="false"
958 --enable-stack-protector) stack_protector="yes"
960 --disable-stack-protector) stack_protector="no"
962 --enable-safe-stack) safe_stack="yes"
964 --disable-safe-stack) safe_stack="no"
966 --enable-cfi)
967 cfi="true";
968 lto="true";
970 --disable-cfi) cfi="false"
972 --disable-fdt) fdt="disabled"
974 --enable-fdt) fdt="enabled"
976 --enable-fdt=git) fdt="internal"
978 --enable-fdt=*) fdt="$optarg"
980 --disable-membarrier) membarrier="no"
982 --enable-membarrier) membarrier="yes"
984 --with-pkgversion=*) pkgversion="$optarg"
986 --with-coroutine=*) coroutine="$optarg"
988 --disable-coroutine-pool) coroutine_pool="no"
990 --enable-coroutine-pool) coroutine_pool="yes"
992 --enable-debug-stack-usage) debug_stack_usage="yes"
994 --enable-crypto-afalg) crypto_afalg="yes"
996 --disable-crypto-afalg) crypto_afalg="no"
998 --disable-vhost-net) vhost_net="no"
1000 --enable-vhost-net) vhost_net="yes"
1002 --disable-vhost-crypto) vhost_crypto="no"
1004 --enable-vhost-crypto) vhost_crypto="yes"
1006 --disable-vhost-scsi) vhost_scsi="no"
1008 --enable-vhost-scsi) vhost_scsi="yes"
1010 --disable-vhost-vsock) vhost_vsock="no"
1012 --enable-vhost-vsock) vhost_vsock="yes"
1014 --disable-vhost-user-fs) vhost_user_fs="no"
1016 --enable-vhost-user-fs) vhost_user_fs="yes"
1018 --disable-opengl) opengl="no"
1020 --enable-opengl) opengl="yes"
1022 --disable-xfsctl) xfs="no"
1024 --enable-xfsctl) xfs="yes"
1026 --disable-zlib-test)
1028 --enable-guest-agent) guest_agent="yes"
1030 --disable-guest-agent) guest_agent="no"
1032 --with-vss-sdk) vss_win32_sdk=""
1034 --with-vss-sdk=*) vss_win32_sdk="$optarg"
1036 --without-vss-sdk) vss_win32_sdk="no"
1038 --with-win-sdk) win_sdk=""
1040 --with-win-sdk=*) win_sdk="$optarg"
1042 --without-win-sdk) win_sdk="no"
1044 --enable-tools) want_tools="yes"
1046 --disable-tools) want_tools="no"
1048 --disable-avx2) avx2_opt="no"
1050 --enable-avx2) avx2_opt="yes"
1052 --disable-avx512f) avx512f_opt="no"
1054 --enable-avx512f) avx512f_opt="yes"
1056 --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
1057 echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1059 --enable-vhdx|--disable-vhdx)
1060 echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1062 --enable-uuid|--disable-uuid)
1063 echo "$0: $opt is obsolete, UUID support is always built" >&2
1065 --tls-priority=*) tls_priority="$optarg"
1067 --enable-rdma) rdma="yes"
1069 --disable-rdma) rdma="no"
1071 --enable-pvrdma) pvrdma="yes"
1073 --disable-pvrdma) pvrdma="no"
1075 --disable-tpm) tpm="no"
1077 --enable-tpm) tpm="yes"
1079 --disable-live-block-migration) live_block_migration="no"
1081 --enable-live-block-migration) live_block_migration="yes"
1083 --disable-numa) numa="no"
1085 --enable-numa) numa="yes"
1087 --disable-replication) replication="no"
1089 --enable-replication) replication="yes"
1091 --disable-bochs) bochs="no"
1093 --enable-bochs) bochs="yes"
1095 --disable-cloop) cloop="no"
1097 --enable-cloop) cloop="yes"
1099 --disable-dmg) dmg="no"
1101 --enable-dmg) dmg="yes"
1103 --disable-qcow1) qcow1="no"
1105 --enable-qcow1) qcow1="yes"
1107 --disable-vdi) vdi="no"
1109 --enable-vdi) vdi="yes"
1111 --disable-vvfat) vvfat="no"
1113 --enable-vvfat) vvfat="yes"
1115 --disable-qed) qed="no"
1117 --enable-qed) qed="yes"
1119 --disable-parallels) parallels="no"
1121 --enable-parallels) parallels="yes"
1123 --disable-vhost-user) vhost_user="no"
1125 --enable-vhost-user) vhost_user="yes"
1127 --disable-vhost-vdpa) vhost_vdpa="no"
1129 --enable-vhost-vdpa) vhost_vdpa="yes"
1131 --disable-vhost-kernel) vhost_kernel="no"
1133 --enable-vhost-kernel) vhost_kernel="yes"
1135 --disable-capstone) capstone="disabled"
1137 --enable-capstone) capstone="enabled"
1139 --enable-capstone=git) capstone="internal"
1141 --enable-capstone=*) capstone="$optarg"
1143 --with-git=*) git="$optarg"
1145 --with-git-submodules=*)
1146 git_submodules_action="$optarg"
1148 --enable-debug-mutex) debug_mutex=yes
1150 --disable-debug-mutex) debug_mutex=no
1152 --enable-plugins) if test "$mingw32" = "yes"; then
1153 error_exit "TCG plugins not currently supported on Windows platforms"
1154 else
1155 plugins="yes"
1158 --disable-plugins) plugins="no"
1160 --enable-containers) use_containers="yes"
1162 --disable-containers) use_containers="no"
1164 --gdb=*) gdb_bin="$optarg"
1166 --enable-rng-none) rng_none=yes
1168 --disable-rng-none) rng_none=no
1170 --enable-keyring) secret_keyring="yes"
1172 --disable-keyring) secret_keyring="no"
1174 --enable-gio) gio=yes
1176 --disable-gio) gio=no
1178 --enable-slirp-smbd) slirp_smbd=yes
1180 --disable-slirp-smbd) slirp_smbd=no
1182 # backwards compatibility options
1183 --enable-trace-backend=*) meson_option_parse "--enable-trace-backends=$optarg" "$optarg"
1185 --disable-blobs) meson_option_parse --disable-install-blobs ""
1187 --enable-tcmalloc) meson_option_parse --enable-malloc=tcmalloc tcmalloc
1189 --enable-jemalloc) meson_option_parse --enable-malloc=jemalloc jemalloc
1191 # everything else has the same name in configure and meson
1192 --enable-* | --disable-*) meson_option_parse "$opt" "$optarg"
1195 echo "ERROR: unknown option $opt"
1196 echo "Try '$0 --help' for more information"
1197 exit 1
1199 esac
1200 done
1202 # test for any invalid configuration combinations
1203 if test "$plugins" = "yes" -a "$tcg" = "disabled"; then
1204 error_exit "Can't enable plugins on non-TCG builds"
1207 case $git_submodules_action in
1208 update|validate)
1209 if test ! -e "$source_path/.git"; then
1210 echo "ERROR: cannot $git_submodules_action git submodules without .git"
1211 exit 1
1214 ignore)
1215 if ! test -f "$source_path/ui/keycodemapdb/README"
1216 then
1217 echo
1218 echo "ERROR: missing GIT submodules"
1219 echo
1220 if test -e "$source_path/.git"; then
1221 echo "--with-git-submodules=ignore specified but submodules were not"
1222 echo "checked out. Please initialize and update submodules."
1223 else
1224 echo "This is not a GIT checkout but module content appears to"
1225 echo "be missing. Do not use 'git archive' or GitHub download links"
1226 echo "to acquire QEMU source archives. Non-GIT builds are only"
1227 echo "supported with source archives linked from:"
1228 echo
1229 echo " https://www.qemu.org/download/#source"
1230 echo
1231 echo "Developers working with GIT can use scripts/archive-source.sh"
1232 echo "if they need to create valid source archives."
1234 echo
1235 exit 1
1239 echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'"
1240 exit 1
1242 esac
1244 libdir="${libdir:-$prefix/lib}"
1245 libexecdir="${libexecdir:-$prefix/libexec}"
1246 includedir="${includedir:-$prefix/include}"
1248 if test "$mingw32" = "yes" ; then
1249 bindir="${bindir:-$prefix}"
1250 else
1251 bindir="${bindir:-$prefix/bin}"
1253 mandir="${mandir:-$prefix/share/man}"
1254 datadir="${datadir:-$prefix/share}"
1255 docdir="${docdir:-$prefix/share/doc}"
1256 sysconfdir="${sysconfdir:-$prefix/etc}"
1257 local_statedir="${local_statedir:-$prefix/var}"
1258 firmwarepath="${firmwarepath:-$datadir/qemu-firmware}"
1259 localedir="${localedir:-$datadir/locale}"
1261 if eval test -z "\${cross_cc_$cpu}"; then
1262 eval "cross_cc_${cpu}=\$cc"
1263 cross_cc_vars="$cross_cc_vars cross_cc_${cpu}"
1266 # For user-mode emulation the host arch has to be one we explicitly
1267 # support, even if we're using TCI.
1268 if [ "$ARCH" = "unknown" ]; then
1269 bsd_user="no"
1270 linux_user="no"
1273 default_target_list=""
1274 deprecated_targets_list=ppc64abi32-linux-user
1275 deprecated_features=""
1276 mak_wilds=""
1278 if [ "$softmmu" = "yes" ]; then
1279 mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak"
1281 if [ "$linux_user" = "yes" ]; then
1282 mak_wilds="${mak_wilds} $source_path/configs/targets/*-linux-user.mak"
1284 if [ "$bsd_user" = "yes" ]; then
1285 mak_wilds="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak"
1288 # If the user doesn't explicitly specify a deprecated target we will
1289 # skip it.
1290 if test -z "$target_list"; then
1291 if test -z "$target_list_exclude"; then
1292 target_list_exclude="$deprecated_targets_list"
1293 else
1294 target_list_exclude="$target_list_exclude,$deprecated_targets_list"
1298 for config in $mak_wilds; do
1299 target="$(basename "$config" .mak)"
1300 if echo "$target_list_exclude" | grep -vq "$target"; then
1301 default_target_list="${default_target_list} $target"
1303 done
1305 if test x"$show_help" = x"yes" ; then
1306 cat << EOF
1308 Usage: configure [options]
1309 Options: [defaults in brackets after descriptions]
1311 Standard options:
1312 --help print this message
1313 --prefix=PREFIX install in PREFIX [$prefix]
1314 --interp-prefix=PREFIX where to find shared libraries, etc.
1315 use %M for cpu name [$interp_prefix]
1316 --target-list=LIST set target list (default: build all non-deprecated)
1317 $(echo Available targets: $default_target_list | \
1318 fold -s -w 53 | sed -e 's/^/ /')
1319 $(echo Deprecated targets: $deprecated_targets_list | \
1320 fold -s -w 53 | sed -e 's/^/ /')
1321 --target-list-exclude=LIST exclude a set of targets from the default target-list
1323 Advanced options (experts only):
1324 --cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix]
1325 --cc=CC use C compiler CC [$cc]
1326 --iasl=IASL use ACPI compiler IASL [$iasl]
1327 --host-cc=CC use C compiler CC [$host_cc] for code run at
1328 build time
1329 --cxx=CXX use C++ compiler CXX [$cxx]
1330 --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
1331 --extra-cflags=CFLAGS append extra C compiler flags CFLAGS
1332 --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS
1333 --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS
1334 --cross-cc-ARCH=CC use compiler when building ARCH guest test cases
1335 --cross-cc-flags-ARCH= use compiler flags when building ARCH guest tests
1336 --make=MAKE use specified make [$make]
1337 --python=PYTHON use specified python [$python]
1338 --sphinx-build=SPHINX use specified sphinx-build [$sphinx_build]
1339 --meson=MESON use specified meson [$meson]
1340 --ninja=NINJA use specified ninja [$ninja]
1341 --smbd=SMBD use specified smbd [$smbd]
1342 --with-git=GIT use specified git [$git]
1343 --with-git-submodules=update update git submodules (default if .git dir exists)
1344 --with-git-submodules=validate fail if git submodules are not up to date
1345 --with-git-submodules=ignore do not update or check git submodules (default if no .git dir)
1346 --static enable static build [$static]
1347 --mandir=PATH install man pages in PATH
1348 --datadir=PATH install firmware in PATH/$qemu_suffix
1349 --localedir=PATH install translation in PATH/$qemu_suffix
1350 --docdir=PATH install documentation in PATH/$qemu_suffix
1351 --bindir=PATH install binaries in PATH
1352 --libdir=PATH install libraries in PATH
1353 --libexecdir=PATH install helper binaries in PATH
1354 --sysconfdir=PATH install config in PATH/$qemu_suffix
1355 --localstatedir=PATH install local state in PATH (set at runtime on win32)
1356 --firmwarepath=PATH search PATH for firmware files
1357 --efi-aarch64=PATH PATH of efi file to use for aarch64 VMs.
1358 --with-suffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix]
1359 --with-pkgversion=VERS use specified string as sub-version of the package
1360 --without-default-features default all --enable-* options to "disabled"
1361 --without-default-devices do not include any device that is not needed to
1362 start the emulator (only use if you are including
1363 desired devices in configs/devices/)
1364 --with-devices-ARCH=NAME override default configs/devices
1365 --enable-debug enable common debug build options
1366 --enable-sanitizers enable default sanitizers
1367 --enable-tsan enable thread sanitizer
1368 --disable-strip disable stripping binaries
1369 --disable-werror disable compilation abort on warning
1370 --disable-stack-protector disable compiler-provided stack protection
1371 --audio-drv-list=LIST set audio drivers to try if -audiodev is not used
1372 --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L
1373 --block-drv-rw-whitelist=L
1374 set block driver read-write whitelist
1375 (by default affects only QEMU, not tools like qemu-img)
1376 --block-drv-ro-whitelist=L
1377 set block driver read-only whitelist
1378 (by default affects only QEMU, not tools like qemu-img)
1379 --enable-block-drv-whitelist-in-tools
1380 use block whitelist also in tools instead of only QEMU
1381 --with-trace-file=NAME Full PATH,NAME of file to store traces
1382 Default:trace-<pid>
1383 --cpu=CPU Build for host CPU [$cpu]
1384 --with-coroutine=BACKEND coroutine backend. Supported options:
1385 ucontext, sigaltstack, windows
1386 --enable-gcov enable test coverage analysis with gcov
1387 --with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent
1388 --with-win-sdk=SDK-path path to Windows Platform SDK (to build VSS .tlb)
1389 --tls-priority default TLS protocol/cipher priority string
1390 --enable-gprof QEMU profiling with gprof
1391 --enable-profiler profiler support
1392 --enable-debug-stack-usage
1393 track the maximum stack usage of stacks created by qemu_alloc_stack
1394 --enable-plugins
1395 enable plugins via shared library loading
1396 --disable-containers don't use containers for cross-building
1397 --gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin]
1399 meson_options_help
1400 cat << EOF
1401 system all system emulation targets
1402 user supported user emulation targets
1403 linux-user all linux usermode emulation targets
1404 bsd-user all BSD usermode emulation targets
1405 guest-agent build the QEMU Guest Agent
1406 pie Position Independent Executables
1407 modules modules support (non-Windows)
1408 module-upgrades try to load modules from alternate paths for upgrades
1409 debug-tcg TCG debugging (default is disabled)
1410 debug-info debugging information
1411 lto Enable Link-Time Optimization.
1412 safe-stack SafeStack Stack Smash Protection. Depends on
1413 clang/llvm >= 3.7 and requires coroutine backend ucontext.
1414 membarrier membarrier system call (for Linux 4.14+ or Windows)
1415 rdma Enable RDMA-based migration
1416 pvrdma Enable PVRDMA support
1417 vhost-net vhost-net kernel acceleration support
1418 vhost-vsock virtio sockets device support
1419 vhost-scsi vhost-scsi kernel target support
1420 vhost-crypto vhost-user-crypto backend support
1421 vhost-kernel vhost kernel backend support
1422 vhost-user vhost-user backend support
1423 vhost-vdpa vhost-vdpa kernel backend support
1424 live-block-migration Block migration in the main migration stream
1425 coroutine-pool coroutine freelist (better performance)
1426 tpm TPM support
1427 numa libnuma support
1428 avx2 AVX2 optimization support
1429 avx512f AVX512F optimization support
1430 replication replication support
1431 opengl opengl support
1432 xfsctl xfsctl support
1433 qom-cast-debug cast debugging support
1434 tools build qemu-io, qemu-nbd and qemu-img tools
1435 bochs bochs image format support
1436 cloop cloop image format support
1437 dmg dmg image format support
1438 qcow1 qcow v1 image format support
1439 vdi vdi image format support
1440 vvfat vvfat image format support
1441 qed qed image format support
1442 parallels parallels image format support
1443 crypto-afalg Linux AF_ALG crypto backend driver
1444 debug-mutex mutex debugging support
1445 rng-none dummy RNG, avoid using /dev/(u)random and getrandom()
1446 gio libgio support
1447 slirp-smbd use smbd (at path --smbd=*) in slirp networking
1449 NOTE: The object files are built at the place where configure is launched
1451 exit 0
1454 # Remove old dependency files to make sure that they get properly regenerated
1455 rm -f */config-devices.mak.d
1457 if test -z "$python"
1458 then
1459 error_exit "Python not found. Use --python=/path/to/python"
1461 if ! has "$make"
1462 then
1463 error_exit "GNU make ($make) not found"
1466 # Note that if the Python conditional here evaluates True we will exit
1467 # with status 1 which is a shell 'false' value.
1468 if ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then
1469 error_exit "Cannot use '$python', Python >= 3.6 is required." \
1470 "Use --python=/path/to/python to specify a supported Python."
1473 # Preserve python version since some functionality is dependent on it
1474 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)
1476 # Suppress writing compiled files
1477 python="$python -B"
1479 if test -z "$meson"; then
1480 if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.59.3; then
1481 meson=meson
1482 elif test $git_submodules_action != 'ignore' ; then
1483 meson=git
1484 elif test -e "${source_path}/meson/meson.py" ; then
1485 meson=internal
1486 else
1487 if test "$explicit_python" = yes; then
1488 error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found."
1489 else
1490 error_exit "Meson not found. Use --meson=/path/to/meson"
1493 else
1494 # Meson uses its own Python interpreter to invoke other Python scripts,
1495 # but the user wants to use the one they specified with --python.
1497 # We do not want to override the distro Python interpreter (and sometimes
1498 # cannot: for example in Homebrew /usr/bin/meson is a bash script), so
1499 # just require --meson=git|internal together with --python.
1500 if test "$explicit_python" = yes; then
1501 case "$meson" in
1502 git | internal) ;;
1503 *) error_exit "--python requires using QEMU's embedded Meson distribution." ;;
1504 esac
1508 if test "$meson" = git; then
1509 git_submodules="${git_submodules} meson"
1512 case "$meson" in
1513 git | internal)
1514 meson="$python ${source_path}/meson/meson.py"
1516 *) meson=$(command -v "$meson") ;;
1517 esac
1519 # Probe for ninja
1521 if test -z "$ninja"; then
1522 for c in ninja ninja-build samu; do
1523 if has $c; then
1524 ninja=$(command -v "$c")
1525 break
1527 done
1528 if test -z "$ninja"; then
1529 error_exit "Cannot find Ninja"
1533 # Check that the C compiler works. Doing this here before testing
1534 # the host CPU ensures that we had a valid CC to autodetect the
1535 # $cpu var (and we should bail right here if that's not the case).
1536 # It also allows the help message to be printed without a CC.
1537 write_c_skeleton;
1538 if compile_object ; then
1539 : C compiler works ok
1540 else
1541 error_exit "\"$cc\" either does not exist or does not work"
1543 if ! compile_prog ; then
1544 error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
1547 # Consult white-list to determine whether to enable werror
1548 # by default. Only enable by default for git builds
1549 if test -z "$werror" ; then
1550 if test "$git_submodules_action" != "ignore" && \
1551 { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
1552 werror="yes"
1553 else
1554 werror="no"
1558 if test "$targetos" = "bogus"; then
1559 # Now that we know that we're not printing the help and that
1560 # the compiler works (so the results of the check_defines we used
1561 # to identify the OS are reliable), if we didn't recognize the
1562 # host OS we should stop now.
1563 error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
1566 # Check whether the compiler matches our minimum requirements:
1567 cat > $TMPC << EOF
1568 #if defined(__clang_major__) && defined(__clang_minor__)
1569 # ifdef __apple_build_version__
1570 # if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0)
1571 # error You need at least XCode Clang v10.0 to compile QEMU
1572 # endif
1573 # else
1574 # if __clang_major__ < 6 || (__clang_major__ == 6 && __clang_minor__ < 0)
1575 # error You need at least Clang v6.0 to compile QEMU
1576 # endif
1577 # endif
1578 #elif defined(__GNUC__) && defined(__GNUC_MINOR__)
1579 # if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4)
1580 # error You need at least GCC v7.4.0 to compile QEMU
1581 # endif
1582 #else
1583 # error You either need GCC or Clang to compiler QEMU
1584 #endif
1585 int main (void) { return 0; }
1587 if ! compile_prog "" "" ; then
1588 error_exit "You need at least GCC v7.4 or Clang v6.0 (or XCode Clang v10.0)"
1591 # Accumulate -Wfoo and -Wno-bar separately.
1592 # We will list all of the enable flags first, and the disable flags second.
1593 # Note that we do not add -Werror, because that would enable it for all
1594 # configure tests. If a configure test failed due to -Werror this would
1595 # just silently disable some features, so it's too error prone.
1597 warn_flags=
1598 add_to warn_flags -Wold-style-declaration
1599 add_to warn_flags -Wold-style-definition
1600 add_to warn_flags -Wtype-limits
1601 add_to warn_flags -Wformat-security
1602 add_to warn_flags -Wformat-y2k
1603 add_to warn_flags -Winit-self
1604 add_to warn_flags -Wignored-qualifiers
1605 add_to warn_flags -Wempty-body
1606 add_to warn_flags -Wnested-externs
1607 add_to warn_flags -Wendif-labels
1608 add_to warn_flags -Wexpansion-to-defined
1609 add_to warn_flags -Wimplicit-fallthrough=2
1611 nowarn_flags=
1612 add_to nowarn_flags -Wno-initializer-overrides
1613 add_to nowarn_flags -Wno-missing-include-dirs
1614 add_to nowarn_flags -Wno-shift-negative-value
1615 add_to nowarn_flags -Wno-string-plus-int
1616 add_to nowarn_flags -Wno-typedef-redefinition
1617 add_to nowarn_flags -Wno-tautological-type-limit-compare
1618 add_to nowarn_flags -Wno-psabi
1620 gcc_flags="$warn_flags $nowarn_flags"
1622 cc_has_warning_flag() {
1623 write_c_skeleton;
1625 # Use the positive sense of the flag when testing for -Wno-wombat
1626 # support (gcc will happily accept the -Wno- form of unknown
1627 # warning options).
1628 optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
1629 compile_prog "-Werror $optflag" ""
1632 for flag in $gcc_flags; do
1633 if cc_has_warning_flag $flag ; then
1634 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1636 done
1638 if test "$stack_protector" != "no"; then
1639 cat > $TMPC << EOF
1640 int main(int argc, char *argv[])
1642 char arr[64], *p = arr, *c = argv[0];
1643 while (*c) {
1644 *p++ = *c++;
1646 return 0;
1649 gcc_flags="-fstack-protector-strong -fstack-protector-all"
1650 sp_on=0
1651 for flag in $gcc_flags; do
1652 # We need to check both a compile and a link, since some compiler
1653 # setups fail only on a .c->.o compile and some only at link time
1654 if compile_object "-Werror $flag" &&
1655 compile_prog "-Werror $flag" ""; then
1656 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1657 QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
1658 sp_on=1
1659 break
1661 done
1662 if test "$stack_protector" = yes; then
1663 if test $sp_on = 0; then
1664 error_exit "Stack protector not supported"
1669 # Disable -Wmissing-braces on older compilers that warn even for
1670 # the "universal" C zero initializer {0}.
1671 cat > $TMPC << EOF
1672 struct {
1673 int a[2];
1674 } x = {0};
1676 if compile_object "-Werror" "" ; then
1678 else
1679 QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
1682 # Our module code doesn't support Windows
1683 if test "$modules" = "yes" && test "$mingw32" = "yes" ; then
1684 error_exit "Modules are not available for Windows"
1687 # module_upgrades is only reasonable if modules are enabled
1688 if test "$modules" = "no" && test "$module_upgrades" = "yes" ; then
1689 error_exit "Can't enable module-upgrades as Modules are not enabled"
1692 # Static linking is not possible with plugins, modules or PIE
1693 if test "$static" = "yes" ; then
1694 if test "$modules" = "yes" ; then
1695 error_exit "static and modules are mutually incompatible"
1697 if test "$plugins" = "yes"; then
1698 error_exit "static and plugins are mutually incompatible"
1699 else
1700 plugins="no"
1704 cat > $TMPC << EOF
1706 #ifdef __linux__
1707 # define THREAD __thread
1708 #else
1709 # define THREAD
1710 #endif
1711 static THREAD int tls_var;
1712 int main(void) { return tls_var; }
1715 # Check we support -fno-pie and -no-pie first; we will need the former for
1716 # building ROMs, and both for everything if --disable-pie is passed.
1717 if compile_prog "-Werror -fno-pie" "-no-pie"; then
1718 CFLAGS_NOPIE="-fno-pie"
1719 LDFLAGS_NOPIE="-no-pie"
1722 if test "$static" = "yes"; then
1723 if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then
1724 CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
1725 QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS"
1726 pie="yes"
1727 elif test "$pie" = "yes"; then
1728 error_exit "-static-pie not available due to missing toolchain support"
1729 else
1730 QEMU_LDFLAGS="-static $QEMU_LDFLAGS"
1731 pie="no"
1733 elif test "$pie" = "no"; then
1734 CONFIGURE_CFLAGS="$CFLAGS_NOPIE $CONFIGURE_CFLAGS"
1735 CONFIGURE_LDFLAGS="$LDFLAGS_NOPIE $CONFIGURE_LDFLAGS"
1736 elif compile_prog "-Werror -fPIE -DPIE" "-pie"; then
1737 CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
1738 CONFIGURE_LDFLAGS="-pie $CONFIGURE_LDFLAGS"
1739 pie="yes"
1740 elif test "$pie" = "yes"; then
1741 error_exit "PIE not available due to missing toolchain support"
1742 else
1743 echo "Disabling PIE due to missing toolchain support"
1744 pie="no"
1747 # Detect support for PT_GNU_RELRO + DT_BIND_NOW.
1748 # The combination is known as "full relro", because .got.plt is read-only too.
1749 if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
1750 QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS"
1753 ##########################################
1754 # __sync_fetch_and_and requires at least -march=i486. Many toolchains
1755 # use i686 as default anyway, but for those that don't, an explicit
1756 # specification is necessary
1758 if test "$cpu" = "i386"; then
1759 cat > $TMPC << EOF
1760 static int sfaa(int *ptr)
1762 return __sync_fetch_and_and(ptr, 0);
1765 int main(void)
1767 int val = 42;
1768 val = __sync_val_compare_and_swap(&val, 0, 1);
1769 sfaa(&val);
1770 return val;
1773 if ! compile_prog "" "" ; then
1774 QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
1778 if test "$tcg" = "enabled"; then
1779 git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
1780 git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
1783 if test -z "${target_list+xxx}" ; then
1784 default_targets=yes
1785 for target in $default_target_list; do
1786 target_list="$target_list $target"
1787 done
1788 target_list="${target_list# }"
1789 else
1790 default_targets=no
1791 target_list=$(echo "$target_list" | sed -e 's/,/ /g')
1792 for target in $target_list; do
1793 # Check that we recognised the target name; this allows a more
1794 # friendly error message than if we let it fall through.
1795 case " $default_target_list " in
1796 *" $target "*)
1799 error_exit "Unknown target name '$target'"
1801 esac
1802 done
1805 for target in $target_list; do
1806 # if a deprecated target is enabled we note it here
1807 if echo "$deprecated_targets_list" | grep -q "$target"; then
1808 add_to deprecated_features $target
1810 done
1812 # see if system emulation was really requested
1813 case " $target_list " in
1814 *"-softmmu "*) softmmu=yes
1816 *) softmmu=no
1818 esac
1820 feature_not_found() {
1821 feature=$1
1822 remedy=$2
1824 error_exit "User requested feature $feature" \
1825 "configure was not able to find it." \
1826 "$remedy"
1829 # ---
1830 # big/little endian test
1831 cat > $TMPC << EOF
1832 #include <stdio.h>
1833 short big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
1834 short little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
1835 int main(int argc, char *argv[])
1837 return printf("%s %s\n", (char *)big_endian, (char *)little_endian);
1841 if compile_prog ; then
1842 if strings -a $TMPE | grep -q BiGeNdIaN ; then
1843 bigendian="yes"
1844 elif strings -a $TMPE | grep -q LiTtLeEnDiAn ; then
1845 bigendian="no"
1846 else
1847 echo big/little test failed
1848 exit 1
1850 else
1851 echo big/little test failed
1852 exit 1
1855 ##########################################
1856 # system tools
1857 if test -z "$want_tools"; then
1858 if test "$softmmu" = "no"; then
1859 want_tools=no
1860 else
1861 want_tools=yes
1865 #########################################
1866 # vhost interdependencies and host support
1868 # vhost backends
1869 if test "$vhost_user" = "yes" && test "$linux" != "yes"; then
1870 error_exit "vhost-user is only available on Linux"
1872 test "$vhost_vdpa" = "" && vhost_vdpa=$linux
1873 if test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then
1874 error_exit "vhost-vdpa is only available on Linux"
1876 test "$vhost_kernel" = "" && vhost_kernel=$linux
1877 if test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then
1878 error_exit "vhost-kernel is only available on Linux"
1881 # vhost-kernel devices
1882 test "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel
1883 if test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then
1884 error_exit "--enable-vhost-scsi requires --enable-vhost-kernel"
1886 test "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel
1887 if test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then
1888 error_exit "--enable-vhost-vsock requires --enable-vhost-kernel"
1891 # vhost-user backends
1892 test "$vhost_net_user" = "" && vhost_net_user=$vhost_user
1893 if test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then
1894 error_exit "--enable-vhost-net-user requires --enable-vhost-user"
1896 test "$vhost_crypto" = "" && vhost_crypto=$vhost_user
1897 if test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then
1898 error_exit "--enable-vhost-crypto requires --enable-vhost-user"
1900 test "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user
1901 if test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then
1902 error_exit "--enable-vhost-user-fs requires --enable-vhost-user"
1904 #vhost-vdpa backends
1905 test "$vhost_net_vdpa" = "" && vhost_net_vdpa=$vhost_vdpa
1906 if test "$vhost_net_vdpa" = "yes" && test "$vhost_vdpa" = "no"; then
1907 error_exit "--enable-vhost-net-vdpa requires --enable-vhost-vdpa"
1910 # OR the vhost-kernel, vhost-vdpa and vhost-user values for simplicity
1911 if test "$vhost_net" = ""; then
1912 test "$vhost_net_user" = "yes" && vhost_net=yes
1913 test "$vhost_net_vdpa" = "yes" && vhost_net=yes
1914 test "$vhost_kernel" = "yes" && vhost_net=yes
1917 ##########################################
1918 # pkg-config probe
1920 if ! has "$pkg_config_exe"; then
1921 error_exit "pkg-config binary '$pkg_config_exe' not found"
1924 ##########################################
1925 # xen probe
1927 if test "$xen" != "disabled" ; then
1928 # Check whether Xen library path is specified via --extra-ldflags to avoid
1929 # overriding this setting with pkg-config output. If not, try pkg-config
1930 # to obtain all needed flags.
1932 if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
1933 $pkg_config --exists xencontrol ; then
1934 xen_ctrl_version="$(printf '%d%02d%02d' \
1935 $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
1936 xen=enabled
1937 xen_pc="xencontrol xenstore xenforeignmemory xengnttab"
1938 xen_pc="$xen_pc xenevtchn xendevicemodel"
1939 if $pkg_config --exists xentoolcore; then
1940 xen_pc="$xen_pc xentoolcore"
1942 xen_cflags="$($pkg_config --cflags $xen_pc)"
1943 xen_libs="$($pkg_config --libs $xen_pc)"
1944 else
1946 xen_libs="-lxenstore -lxenctrl"
1947 xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
1949 # First we test whether Xen headers and libraries are available.
1950 # If no, we are done and there is no Xen support.
1951 # If yes, more tests are run to detect the Xen version.
1953 # Xen (any)
1954 cat > $TMPC <<EOF
1955 #include <xenctrl.h>
1956 int main(void) {
1957 return 0;
1960 if ! compile_prog "" "$xen_libs" ; then
1961 # Xen not found
1962 if test "$xen" = "enabled" ; then
1963 feature_not_found "xen" "Install xen devel"
1965 xen=disabled
1967 # Xen unstable
1968 elif
1969 cat > $TMPC <<EOF &&
1970 #undef XC_WANT_COMPAT_DEVICEMODEL_API
1971 #define __XEN_TOOLS__
1972 #include <xendevicemodel.h>
1973 #include <xenforeignmemory.h>
1974 int main(void) {
1975 xendevicemodel_handle *xd;
1976 xenforeignmemory_handle *xfmem;
1978 xd = xendevicemodel_open(0, 0);
1979 xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
1981 xfmem = xenforeignmemory_open(0, 0);
1982 xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
1984 return 0;
1987 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
1988 then
1989 xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
1990 xen_ctrl_version=41100
1991 xen=enabled
1992 elif
1993 cat > $TMPC <<EOF &&
1994 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
1995 #include <xenforeignmemory.h>
1996 #include <xentoolcore.h>
1997 int main(void) {
1998 xenforeignmemory_handle *xfmem;
2000 xfmem = xenforeignmemory_open(0, 0);
2001 xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
2002 xentoolcore_restrict_all(0);
2004 return 0;
2007 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
2008 then
2009 xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
2010 xen_ctrl_version=41000
2011 xen=enabled
2012 elif
2013 cat > $TMPC <<EOF &&
2014 #undef XC_WANT_COMPAT_DEVICEMODEL_API
2015 #define __XEN_TOOLS__
2016 #include <xendevicemodel.h>
2017 int main(void) {
2018 xendevicemodel_handle *xd;
2020 xd = xendevicemodel_open(0, 0);
2021 xendevicemodel_close(xd);
2023 return 0;
2026 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2027 then
2028 xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2029 xen_ctrl_version=40900
2030 xen=enabled
2031 elif
2032 cat > $TMPC <<EOF &&
2034 * If we have stable libs the we don't want the libxc compat
2035 * layers, regardless of what CFLAGS we may have been given.
2037 * Also, check if xengnttab_grant_copy_segment_t is defined and
2038 * grant copy operation is implemented.
2040 #undef XC_WANT_COMPAT_EVTCHN_API
2041 #undef XC_WANT_COMPAT_GNTTAB_API
2042 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2043 #include <xenctrl.h>
2044 #include <xenstore.h>
2045 #include <xenevtchn.h>
2046 #include <xengnttab.h>
2047 #include <xenforeignmemory.h>
2048 #include <stdint.h>
2049 #include <xen/hvm/hvm_info_table.h>
2050 #if !defined(HVM_MAX_VCPUS)
2051 # error HVM_MAX_VCPUS not defined
2052 #endif
2053 int main(void) {
2054 xc_interface *xc = NULL;
2055 xenforeignmemory_handle *xfmem;
2056 xenevtchn_handle *xe;
2057 xengnttab_handle *xg;
2058 xengnttab_grant_copy_segment_t* seg = NULL;
2060 xs_daemon_open();
2062 xc = xc_interface_open(0, 0, 0);
2063 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2064 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2065 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2066 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2068 xfmem = xenforeignmemory_open(0, 0);
2069 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2071 xe = xenevtchn_open(0, 0);
2072 xenevtchn_fd(xe);
2074 xg = xengnttab_open(0, 0);
2075 xengnttab_grant_copy(xg, 0, seg);
2077 return 0;
2080 compile_prog "" "$xen_libs $xen_stable_libs"
2081 then
2082 xen_ctrl_version=40800
2083 xen=enabled
2084 elif
2085 cat > $TMPC <<EOF &&
2087 * If we have stable libs the we don't want the libxc compat
2088 * layers, regardless of what CFLAGS we may have been given.
2090 #undef XC_WANT_COMPAT_EVTCHN_API
2091 #undef XC_WANT_COMPAT_GNTTAB_API
2092 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2093 #include <xenctrl.h>
2094 #include <xenstore.h>
2095 #include <xenevtchn.h>
2096 #include <xengnttab.h>
2097 #include <xenforeignmemory.h>
2098 #include <stdint.h>
2099 #include <xen/hvm/hvm_info_table.h>
2100 #if !defined(HVM_MAX_VCPUS)
2101 # error HVM_MAX_VCPUS not defined
2102 #endif
2103 int main(void) {
2104 xc_interface *xc = NULL;
2105 xenforeignmemory_handle *xfmem;
2106 xenevtchn_handle *xe;
2107 xengnttab_handle *xg;
2109 xs_daemon_open();
2111 xc = xc_interface_open(0, 0, 0);
2112 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2113 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2114 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2115 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2117 xfmem = xenforeignmemory_open(0, 0);
2118 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2120 xe = xenevtchn_open(0, 0);
2121 xenevtchn_fd(xe);
2123 xg = xengnttab_open(0, 0);
2124 xengnttab_map_grant_ref(xg, 0, 0, 0);
2126 return 0;
2129 compile_prog "" "$xen_libs $xen_stable_libs"
2130 then
2131 xen_ctrl_version=40701
2132 xen=enabled
2134 # Xen 4.6
2135 elif
2136 cat > $TMPC <<EOF &&
2137 #include <xenctrl.h>
2138 #include <xenstore.h>
2139 #include <stdint.h>
2140 #include <xen/hvm/hvm_info_table.h>
2141 #if !defined(HVM_MAX_VCPUS)
2142 # error HVM_MAX_VCPUS not defined
2143 #endif
2144 int main(void) {
2145 xc_interface *xc;
2146 xs_daemon_open();
2147 xc = xc_interface_open(0, 0, 0);
2148 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2149 xc_gnttab_open(NULL, 0);
2150 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2151 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2152 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2153 xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2154 return 0;
2157 compile_prog "" "$xen_libs"
2158 then
2159 xen_ctrl_version=40600
2160 xen=enabled
2162 # Xen 4.5
2163 elif
2164 cat > $TMPC <<EOF &&
2165 #include <xenctrl.h>
2166 #include <xenstore.h>
2167 #include <stdint.h>
2168 #include <xen/hvm/hvm_info_table.h>
2169 #if !defined(HVM_MAX_VCPUS)
2170 # error HVM_MAX_VCPUS not defined
2171 #endif
2172 int main(void) {
2173 xc_interface *xc;
2174 xs_daemon_open();
2175 xc = xc_interface_open(0, 0, 0);
2176 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2177 xc_gnttab_open(NULL, 0);
2178 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2179 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2180 xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
2181 return 0;
2184 compile_prog "" "$xen_libs"
2185 then
2186 xen_ctrl_version=40500
2187 xen=enabled
2189 elif
2190 cat > $TMPC <<EOF &&
2191 #include <xenctrl.h>
2192 #include <xenstore.h>
2193 #include <stdint.h>
2194 #include <xen/hvm/hvm_info_table.h>
2195 #if !defined(HVM_MAX_VCPUS)
2196 # error HVM_MAX_VCPUS not defined
2197 #endif
2198 int main(void) {
2199 xc_interface *xc;
2200 xs_daemon_open();
2201 xc = xc_interface_open(0, 0, 0);
2202 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2203 xc_gnttab_open(NULL, 0);
2204 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2205 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2206 return 0;
2209 compile_prog "" "$xen_libs"
2210 then
2211 xen_ctrl_version=40200
2212 xen=enabled
2214 else
2215 if test "$xen" = "enabled" ; then
2216 feature_not_found "xen (unsupported version)" \
2217 "Install a supported xen (xen 4.2 or newer)"
2219 xen=disabled
2222 if test "$xen" = enabled; then
2223 if test $xen_ctrl_version -ge 40701 ; then
2224 xen_libs="$xen_libs $xen_stable_libs "
2230 ##########################################
2231 # RDMA needs OpenFabrics libraries
2232 if test "$rdma" != "no" ; then
2233 cat > $TMPC <<EOF
2234 #include <rdma/rdma_cma.h>
2235 int main(void) { return 0; }
2237 rdma_libs="-lrdmacm -libverbs -libumad"
2238 if compile_prog "" "$rdma_libs" ; then
2239 rdma="yes"
2240 else
2241 if test "$rdma" = "yes" ; then
2242 error_exit \
2243 " OpenFabrics librdmacm/libibverbs/libibumad not present." \
2244 " Your options:" \
2245 " (1) Fast: Install infiniband packages (devel) from your distro." \
2246 " (2) Cleanest: Install libraries from www.openfabrics.org" \
2247 " (3) Also: Install softiwarp if you don't have RDMA hardware"
2249 rdma="no"
2253 ##########################################
2254 # PVRDMA detection
2256 cat > $TMPC <<EOF &&
2257 #include <sys/mman.h>
2260 main(void)
2262 char buf = 0;
2263 void *addr = &buf;
2264 addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED);
2266 return 0;
2270 if test "$rdma" = "yes" ; then
2271 case "$pvrdma" in
2273 if compile_prog "" ""; then
2274 pvrdma="yes"
2275 else
2276 pvrdma="no"
2279 "yes")
2280 if ! compile_prog "" ""; then
2281 error_exit "PVRDMA is not supported since mremap is not implemented"
2283 pvrdma="yes"
2285 "no")
2286 pvrdma="no"
2288 esac
2289 else
2290 if test "$pvrdma" = "yes" ; then
2291 error_exit "PVRDMA requires rdma suppport"
2293 pvrdma="no"
2296 # Let's see if enhanced reg_mr is supported
2297 if test "$pvrdma" = "yes" ; then
2299 cat > $TMPC <<EOF &&
2300 #include <infiniband/verbs.h>
2303 main(void)
2305 struct ibv_mr *mr;
2306 struct ibv_pd *pd = NULL;
2307 size_t length = 10;
2308 uint64_t iova = 0;
2309 int access = 0;
2310 void *addr = NULL;
2312 mr = ibv_reg_mr_iova(pd, addr, length, iova, access);
2314 ibv_dereg_mr(mr);
2316 return 0;
2319 if ! compile_prog "" "-libverbs"; then
2320 QEMU_CFLAGS="$QEMU_CFLAGS -DLEGACY_RDMA_REG_MR"
2324 ##########################################
2325 # xfsctl() probe, used for file-posix.c
2326 if test "$xfs" != "no" ; then
2327 cat > $TMPC << EOF
2328 #include <stddef.h> /* NULL */
2329 #include <xfs/xfs.h>
2330 int main(void)
2332 xfsctl(NULL, 0, 0, NULL);
2333 return 0;
2336 if compile_prog "" "" ; then
2337 xfs="yes"
2338 else
2339 if test "$xfs" = "yes" ; then
2340 feature_not_found "xfs" "Install xfsprogs/xfslibs devel"
2342 xfs=no
2346 ##########################################
2347 # plugin linker support probe
2349 if test "$plugins" != "no"; then
2351 #########################################
2352 # See if --dynamic-list is supported by the linker
2354 ld_dynamic_list="no"
2355 cat > $TMPTXT <<EOF
2357 foo;
2361 cat > $TMPC <<EOF
2362 #include <stdio.h>
2363 void foo(void);
2365 void foo(void)
2367 printf("foo\n");
2370 int main(void)
2372 foo();
2373 return 0;
2377 if compile_prog "" "-Wl,--dynamic-list=$TMPTXT" ; then
2378 ld_dynamic_list="yes"
2381 #########################################
2382 # See if -exported_symbols_list is supported by the linker
2384 ld_exported_symbols_list="no"
2385 cat > $TMPTXT <<EOF
2386 _foo
2389 if compile_prog "" "-Wl,-exported_symbols_list,$TMPTXT" ; then
2390 ld_exported_symbols_list="yes"
2393 if test "$ld_dynamic_list" = "no" &&
2394 test "$ld_exported_symbols_list" = "no" ; then
2395 if test "$plugins" = "yes"; then
2396 error_exit \
2397 "Plugin support requires dynamic linking and specifying a set of symbols " \
2398 "that are exported to plugins. Unfortunately your linker doesn't " \
2399 "support the flag (--dynamic-list or -exported_symbols_list) used " \
2400 "for this purpose."
2401 else
2402 plugins="no"
2404 else
2405 plugins="yes"
2409 ##########################################
2410 # glib support probe
2412 glib_req_ver=2.56
2413 glib_modules=gthread-2.0
2414 if test "$modules" = yes; then
2415 glib_modules="$glib_modules gmodule-export-2.0"
2416 elif test "$plugins" = "yes"; then
2417 glib_modules="$glib_modules gmodule-no-export-2.0"
2420 for i in $glib_modules; do
2421 if $pkg_config --atleast-version=$glib_req_ver $i; then
2422 glib_cflags=$($pkg_config --cflags $i)
2423 glib_libs=$($pkg_config --libs $i)
2424 else
2425 error_exit "glib-$glib_req_ver $i is required to compile QEMU"
2427 done
2429 # This workaround is required due to a bug in pkg-config file for glib as it
2430 # doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
2432 if test "$static" = yes && test "$mingw32" = yes; then
2433 glib_cflags="-DGLIB_STATIC_COMPILATION $glib_cflags"
2436 if ! test "$gio" = "no"; then
2437 pass=no
2438 if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
2439 gio_cflags=$($pkg_config --cflags gio-2.0)
2440 gio_libs=$($pkg_config --libs gio-2.0)
2441 gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0)
2442 if ! has "$gdbus_codegen"; then
2443 gdbus_codegen=
2445 # Check that the libraries actually work -- Ubuntu 18.04 ships
2446 # with pkg-config --static --libs data for gio-2.0 that is missing
2447 # -lblkid and will give a link error.
2448 cat > $TMPC <<EOF
2449 #include <gio/gio.h>
2450 int main(void)
2452 g_dbus_proxy_new_sync(0, 0, 0, 0, 0, 0, 0, 0);
2453 return 0;
2456 if compile_prog "$gio_cflags" "$gio_libs" ; then
2457 pass=yes
2458 else
2459 pass=no
2462 if test "$pass" = "yes" &&
2463 $pkg_config --atleast-version=$glib_req_ver gio-unix-2.0; then
2464 gio_cflags="$gio_cflags $($pkg_config --cflags gio-unix-2.0)"
2465 gio_libs="$gio_libs $($pkg_config --libs gio-unix-2.0)"
2469 if test "$pass" = "no"; then
2470 if test "$gio" = "yes"; then
2471 feature_not_found "gio" "Install libgio >= 2.0"
2472 else
2473 gio=no
2475 else
2476 gio=yes
2480 # Sanity check that the current size_t matches the
2481 # size that glib thinks it should be. This catches
2482 # problems on multi-arch where people try to build
2483 # 32-bit QEMU while pointing at 64-bit glib headers
2484 cat > $TMPC <<EOF
2485 #include <glib.h>
2486 #include <unistd.h>
2488 #define QEMU_BUILD_BUG_ON(x) \
2489 typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
2491 int main(void) {
2492 QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
2493 return 0;
2497 if ! compile_prog "$glib_cflags" "$glib_libs" ; then
2498 error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
2499 "You probably need to set PKG_CONFIG_LIBDIR"\
2500 "to point to the right pkg-config files for your"\
2501 "build target"
2504 # Silence clang warnings triggered by glib < 2.57.2
2505 cat > $TMPC << EOF
2506 #include <glib.h>
2507 typedef struct Foo {
2508 int i;
2509 } Foo;
2510 static void foo_free(Foo *f)
2512 g_free(f);
2514 G_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free);
2515 int main(void) { return 0; }
2517 if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
2518 if cc_has_warning_flag "-Wno-unused-function"; then
2519 glib_cflags="$glib_cflags -Wno-unused-function"
2520 CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -Wno-unused-function"
2524 ##########################################
2525 # SHA command probe for modules
2526 if test "$modules" = yes; then
2527 shacmd_probe="sha1sum sha1 shasum"
2528 for c in $shacmd_probe; do
2529 if has $c; then
2530 shacmd="$c"
2531 break
2533 done
2534 if test "$shacmd" = ""; then
2535 error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
2539 ##########################################
2540 # TPM emulation is only on POSIX
2542 if test "$tpm" = ""; then
2543 if test "$mingw32" = "yes"; then
2544 tpm=no
2545 else
2546 tpm=yes
2548 elif test "$tpm" = "yes"; then
2549 if test "$mingw32" = "yes" ; then
2550 error_exit "TPM emulation only available on POSIX systems"
2554 ##########################################
2555 # fdt probe
2557 case "$fdt" in
2558 auto | enabled | internal)
2559 # Simpler to always update submodule, even if not needed.
2560 git_submodules="${git_submodules} dtc"
2562 esac
2564 ##########################################
2565 # opengl probe (for sdl2, gtk)
2567 if test "$opengl" != "no" ; then
2568 epoxy=no
2569 if $pkg_config epoxy; then
2570 cat > $TMPC << EOF
2571 #include <epoxy/egl.h>
2572 int main(void) { return 0; }
2574 if compile_prog "" "" ; then
2575 epoxy=yes
2579 if test "$epoxy" = "yes" ; then
2580 opengl_cflags="$($pkg_config --cflags epoxy)"
2581 opengl_libs="$($pkg_config --libs epoxy)"
2582 opengl=yes
2583 else
2584 if test "$opengl" = "yes" ; then
2585 feature_not_found "opengl" "Please install epoxy with EGL"
2587 opengl_cflags=""
2588 opengl_libs=""
2589 opengl=no
2593 ##########################################
2594 # libnuma probe
2596 if test "$numa" != "no" ; then
2597 cat > $TMPC << EOF
2598 #include <numa.h>
2599 int main(void) { return numa_available(); }
2602 if compile_prog "" "-lnuma" ; then
2603 numa=yes
2604 numa_libs="-lnuma"
2605 else
2606 if test "$numa" = "yes" ; then
2607 feature_not_found "numa" "install numactl devel"
2609 numa=no
2613 # check for usbfs
2614 have_usbfs=no
2615 if test "$linux_user" = "yes"; then
2616 cat > $TMPC << EOF
2617 #include <linux/usbdevice_fs.h>
2619 #ifndef USBDEVFS_GET_CAPABILITIES
2620 #error "USBDEVFS_GET_CAPABILITIES undefined"
2621 #endif
2623 #ifndef USBDEVFS_DISCONNECT_CLAIM
2624 #error "USBDEVFS_DISCONNECT_CLAIM undefined"
2625 #endif
2627 int main(void)
2629 return 0;
2632 if compile_prog "" ""; then
2633 have_usbfs=yes
2637 ##########################################
2638 # check if we have VSS SDK headers for win
2640 if test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
2641 test "$vss_win32_sdk" != "no" ; then
2642 case "$vss_win32_sdk" in
2643 "") vss_win32_include="-isystem $source_path" ;;
2644 *\ *) # The SDK is installed in "Program Files" by default, but we cannot
2645 # handle path with spaces. So we symlink the headers into ".sdk/vss".
2646 vss_win32_include="-isystem $source_path/.sdk/vss"
2647 symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
2649 *) vss_win32_include="-isystem $vss_win32_sdk"
2650 esac
2651 cat > $TMPC << EOF
2652 #define __MIDL_user_allocate_free_DEFINED__
2653 #include <inc/win2003/vss.h>
2654 int main(void) { return VSS_CTX_BACKUP; }
2656 if compile_prog "$vss_win32_include" "" ; then
2657 guest_agent_with_vss="yes"
2658 QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
2659 libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
2660 qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
2661 else
2662 if test "$vss_win32_sdk" != "" ; then
2663 echo "ERROR: Please download and install Microsoft VSS SDK:"
2664 echo "ERROR: http://www.microsoft.com/en-us/download/details.aspx?id=23490"
2665 echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
2666 echo "ERROR: scripts/extract-vsssdk-headers setup.exe"
2667 echo "ERROR: The headers are extracted in the directory \`inc'."
2668 feature_not_found "VSS support"
2670 guest_agent_with_vss="no"
2674 ##########################################
2675 # lookup Windows platform SDK (if not specified)
2676 # The SDK is needed only to build .tlb (type library) file of guest agent
2677 # VSS provider from the source. It is usually unnecessary because the
2678 # pre-compiled .tlb file is included.
2680 if test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
2681 test "$guest_agent_with_vss" = "yes" ; then
2682 if test -z "$win_sdk"; then
2683 programfiles="$PROGRAMFILES"
2684 test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
2685 if test -n "$programfiles"; then
2686 win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
2687 else
2688 feature_not_found "Windows SDK"
2690 elif test "$win_sdk" = "no"; then
2691 win_sdk=""
2695 ##########################################
2696 # check if mingw environment provides a recent ntddscsi.h
2697 if test "$mingw32" = "yes" && test "$guest_agent" != "no"; then
2698 cat > $TMPC << EOF
2699 #include <windows.h>
2700 #include <ntddscsi.h>
2701 int main(void) {
2702 #if !defined(IOCTL_SCSI_GET_ADDRESS)
2703 #error Missing required ioctl definitions
2704 #endif
2705 SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
2706 return addr.Lun;
2709 if compile_prog "" "" ; then
2710 guest_agent_ntddscsi=yes
2711 libs_qga="-lsetupapi -lcfgmgr32 $libs_qga"
2715 ##########################################
2716 # capstone
2718 case "$capstone" in
2719 auto | enabled | internal)
2720 # Simpler to always update submodule, even if not needed.
2721 git_submodules="${git_submodules} capstone"
2723 esac
2725 ##########################################
2726 # check and set a backend for coroutine
2728 # We prefer ucontext, but it's not always possible. The fallback
2729 # is sigcontext. On Windows the only valid backend is the Windows
2730 # specific one.
2732 ucontext_works=no
2733 if test "$darwin" != "yes"; then
2734 cat > $TMPC << EOF
2735 #include <ucontext.h>
2736 #ifdef __stub_makecontext
2737 #error Ignoring glibc stub makecontext which will always fail
2738 #endif
2739 int main(void) { makecontext(0, 0, 0); return 0; }
2741 if compile_prog "" "" ; then
2742 ucontext_works=yes
2746 if test "$coroutine" = ""; then
2747 if test "$mingw32" = "yes"; then
2748 coroutine=win32
2749 elif test "$ucontext_works" = "yes"; then
2750 coroutine=ucontext
2751 else
2752 coroutine=sigaltstack
2754 else
2755 case $coroutine in
2756 windows)
2757 if test "$mingw32" != "yes"; then
2758 error_exit "'windows' coroutine backend only valid for Windows"
2760 # Unfortunately the user visible backend name doesn't match the
2761 # coroutine-*.c filename for this case, so we have to adjust it here.
2762 coroutine=win32
2764 ucontext)
2765 if test "$ucontext_works" != "yes"; then
2766 feature_not_found "ucontext"
2769 sigaltstack)
2770 if test "$mingw32" = "yes"; then
2771 error_exit "only the 'windows' coroutine backend is valid for Windows"
2775 error_exit "unknown coroutine backend $coroutine"
2777 esac
2780 if test "$coroutine_pool" = ""; then
2781 coroutine_pool=yes
2784 if test "$debug_stack_usage" = "yes"; then
2785 if test "$coroutine_pool" = "yes"; then
2786 echo "WARN: disabling coroutine pool for stack usage debugging"
2787 coroutine_pool=no
2791 ##################################################
2792 # SafeStack
2795 if test "$safe_stack" = "yes"; then
2796 cat > $TMPC << EOF
2797 int main(int argc, char *argv[])
2799 #if ! __has_feature(safe_stack)
2800 #error SafeStack Disabled
2801 #endif
2802 return 0;
2805 flag="-fsanitize=safe-stack"
2806 # Check that safe-stack is supported and enabled.
2807 if compile_prog "-Werror $flag" "$flag"; then
2808 # Flag needed both at compilation and at linking
2809 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
2810 QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
2811 else
2812 error_exit "SafeStack not supported by your compiler"
2814 if test "$coroutine" != "ucontext"; then
2815 error_exit "SafeStack is only supported by the coroutine backend ucontext"
2817 else
2818 cat > $TMPC << EOF
2819 int main(int argc, char *argv[])
2821 #if defined(__has_feature)
2822 #if __has_feature(safe_stack)
2823 #error SafeStack Enabled
2824 #endif
2825 #endif
2826 return 0;
2829 if test "$safe_stack" = "no"; then
2830 # Make sure that safe-stack is disabled
2831 if ! compile_prog "-Werror" ""; then
2832 # SafeStack was already enabled, try to explicitly remove the feature
2833 flag="-fno-sanitize=safe-stack"
2834 if ! compile_prog "-Werror $flag" "$flag"; then
2835 error_exit "Configure cannot disable SafeStack"
2837 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
2838 QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
2840 else # "$safe_stack" = ""
2841 # Set safe_stack to yes or no based on pre-existing flags
2842 if compile_prog "-Werror" ""; then
2843 safe_stack="no"
2844 else
2845 safe_stack="yes"
2846 if test "$coroutine" != "ucontext"; then
2847 error_exit "SafeStack is only supported by the coroutine backend ucontext"
2853 ########################################
2854 # check if cpuid.h is usable.
2856 cat > $TMPC << EOF
2857 #include <cpuid.h>
2858 int main(void) {
2859 unsigned a, b, c, d;
2860 int max = __get_cpuid_max(0, 0);
2862 if (max >= 1) {
2863 __cpuid(1, a, b, c, d);
2866 if (max >= 7) {
2867 __cpuid_count(7, 0, a, b, c, d);
2870 return 0;
2873 if compile_prog "" "" ; then
2874 cpuid_h=yes
2877 ##########################################
2878 # avx2 optimization requirement check
2880 # There is no point enabling this if cpuid.h is not usable,
2881 # since we won't be able to select the new routines.
2883 if test "$cpuid_h" = "yes" && test "$avx2_opt" != "no"; then
2884 cat > $TMPC << EOF
2885 #pragma GCC push_options
2886 #pragma GCC target("avx2")
2887 #include <cpuid.h>
2888 #include <immintrin.h>
2889 static int bar(void *a) {
2890 __m256i x = *(__m256i *)a;
2891 return _mm256_testz_si256(x, x);
2893 int main(int argc, char *argv[]) { return bar(argv[0]); }
2895 if compile_object "-Werror" ; then
2896 avx2_opt="yes"
2897 else
2898 avx2_opt="no"
2902 ##########################################
2903 # avx512f optimization requirement check
2905 # There is no point enabling this if cpuid.h is not usable,
2906 # since we won't be able to select the new routines.
2907 # by default, it is turned off.
2908 # if user explicitly want to enable it, check environment
2910 if test "$cpuid_h" = "yes" && test "$avx512f_opt" = "yes"; then
2911 cat > $TMPC << EOF
2912 #pragma GCC push_options
2913 #pragma GCC target("avx512f")
2914 #include <cpuid.h>
2915 #include <immintrin.h>
2916 static int bar(void *a) {
2917 __m512i x = *(__m512i *)a;
2918 return _mm512_test_epi64_mask(x, x);
2920 int main(int argc, char *argv[])
2922 return bar(argv[0]);
2925 if ! compile_object "-Werror" ; then
2926 avx512f_opt="no"
2928 else
2929 avx512f_opt="no"
2932 ########################################
2933 # check if __[u]int128_t is usable.
2935 int128=no
2936 cat > $TMPC << EOF
2937 __int128_t a;
2938 __uint128_t b;
2939 int main (void) {
2940 a = a + b;
2941 b = a * b;
2942 a = a * a;
2943 return 0;
2946 if compile_prog "" "" ; then
2947 int128=yes
2950 #########################################
2951 # See if 128-bit atomic operations are supported.
2953 atomic128=no
2954 if test "$int128" = "yes"; then
2955 cat > $TMPC << EOF
2956 int main(void)
2958 unsigned __int128 x = 0, y = 0;
2959 y = __atomic_load(&x, 0);
2960 __atomic_store(&x, y, 0);
2961 __atomic_compare_exchange(&x, &y, x, 0, 0, 0);
2962 return 0;
2965 if compile_prog "" "" ; then
2966 atomic128=yes
2970 cmpxchg128=no
2971 if test "$int128" = yes && test "$atomic128" = no; then
2972 cat > $TMPC << EOF
2973 int main(void)
2975 unsigned __int128 x = 0, y = 0;
2976 __sync_val_compare_and_swap_16(&x, y, x);
2977 return 0;
2980 if compile_prog "" "" ; then
2981 cmpxchg128=yes
2985 ########################################
2986 # check if ccache is interfering with
2987 # semantic analysis of macros
2989 unset CCACHE_CPP2
2990 ccache_cpp2=no
2991 cat > $TMPC << EOF
2992 static const int Z = 1;
2993 #define fn() ({ Z; })
2994 #define TAUT(X) ((X) == Z)
2995 #define PAREN(X, Y) (X == Y)
2996 #define ID(X) (X)
2997 int main(int argc, char *argv[])
2999 int x = 0, y = 0;
3000 x = ID(x);
3001 x = fn();
3002 fn();
3003 if (PAREN(x, y)) return 0;
3004 if (TAUT(Z)) return 0;
3005 return 0;
3009 if ! compile_object "-Werror"; then
3010 ccache_cpp2=yes
3013 #################################################
3014 # clang does not support glibc + FORTIFY_SOURCE.
3016 if test "$fortify_source" != "no"; then
3017 if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
3018 fortify_source="no";
3019 elif test -n "$cxx" && has $cxx &&
3020 echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
3021 fortify_source="no";
3022 else
3023 fortify_source="yes"
3027 ##########################################
3028 # check for usable membarrier system call
3029 if test "$membarrier" = "yes"; then
3030 have_membarrier=no
3031 if test "$mingw32" = "yes" ; then
3032 have_membarrier=yes
3033 elif test "$linux" = "yes" ; then
3034 cat > $TMPC << EOF
3035 #include <linux/membarrier.h>
3036 #include <sys/syscall.h>
3037 #include <unistd.h>
3038 #include <stdlib.h>
3039 int main(void) {
3040 syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
3041 syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0);
3042 exit(0);
3045 if compile_prog "" "" ; then
3046 have_membarrier=yes
3049 if test "$have_membarrier" = "no"; then
3050 feature_not_found "membarrier" "membarrier system call not available"
3052 else
3053 # Do not enable it by default even for Mingw32, because it doesn't
3054 # work on Wine.
3055 membarrier=no
3058 ##########################################
3059 # check for usable AF_ALG environment
3060 have_afalg=no
3061 cat > $TMPC << EOF
3062 #include <errno.h>
3063 #include <sys/types.h>
3064 #include <sys/socket.h>
3065 #include <linux/if_alg.h>
3066 int main(void) {
3067 int sock;
3068 sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
3069 return sock;
3072 if compile_prog "" "" ; then
3073 have_afalg=yes
3075 if test "$crypto_afalg" = "yes"
3076 then
3077 if test "$have_afalg" != "yes"
3078 then
3079 error_exit "AF_ALG requested but could not be detected"
3084 ##########################################
3085 # checks for sanitizers
3087 have_asan=no
3088 have_ubsan=no
3089 have_asan_iface_h=no
3090 have_asan_iface_fiber=no
3092 if test "$sanitizers" = "yes" ; then
3093 write_c_skeleton
3094 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
3095 have_asan=yes
3098 # we could use a simple skeleton for flags checks, but this also
3099 # detect the static linking issue of ubsan, see also:
3100 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
3101 cat > $TMPC << EOF
3102 #include <stdlib.h>
3103 int main(void) {
3104 void *tmp = malloc(10);
3105 if (tmp != NULL) {
3106 return *(int *)(tmp + 2);
3108 return 1;
3111 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
3112 have_ubsan=yes
3115 if check_include "sanitizer/asan_interface.h" ; then
3116 have_asan_iface_h=yes
3119 cat > $TMPC << EOF
3120 #include <sanitizer/asan_interface.h>
3121 int main(void) {
3122 __sanitizer_start_switch_fiber(0, 0, 0);
3123 return 0;
3126 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
3127 have_asan_iface_fiber=yes
3131 # Thread sanitizer is, for now, much noisier than the other sanitizers;
3132 # keep it separate until that is not the case.
3133 if test "$tsan" = "yes" && test "$sanitizers" = "yes"; then
3134 error_exit "TSAN is not supported with other sanitiziers."
3136 have_tsan=no
3137 have_tsan_iface_fiber=no
3138 if test "$tsan" = "yes" ; then
3139 write_c_skeleton
3140 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
3141 have_tsan=yes
3143 cat > $TMPC << EOF
3144 #include <sanitizer/tsan_interface.h>
3145 int main(void) {
3146 __tsan_create_fiber(0);
3147 return 0;
3150 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
3151 have_tsan_iface_fiber=yes
3155 ##########################################
3156 # check for slirp
3158 case "$slirp" in
3159 auto | enabled | internal)
3160 # Simpler to always update submodule, even if not needed.
3161 git_submodules="${git_submodules} slirp"
3163 esac
3165 # Check for slirp smbd dupport
3166 : ${smbd=${SMBD-/usr/sbin/smbd}}
3167 if test "$slirp_smbd" != "no" ; then
3168 if test "$mingw32" = "yes" ; then
3169 if test "$slirp_smbd" = "yes" ; then
3170 error_exit "Host smbd not supported on this platform."
3172 slirp_smbd=no
3173 else
3174 slirp_smbd=yes
3178 ##########################################
3179 # check for usable __NR_keyctl syscall
3181 if test "$linux" = "yes" ; then
3183 have_keyring=no
3184 cat > $TMPC << EOF
3185 #include <errno.h>
3186 #include <asm/unistd.h>
3187 #include <linux/keyctl.h>
3188 #include <unistd.h>
3189 int main(void) {
3190 return syscall(__NR_keyctl, KEYCTL_READ, 0, NULL, NULL, 0);
3193 if compile_prog "" "" ; then
3194 have_keyring=yes
3197 if test "$secret_keyring" != "no"
3198 then
3199 if test "$have_keyring" = "yes"
3200 then
3201 secret_keyring=yes
3202 else
3203 if test "$secret_keyring" = "yes"
3204 then
3205 error_exit "syscall __NR_keyctl requested, \
3206 but not implemented on your system"
3207 else
3208 secret_keyring=no
3213 ##########################################
3214 # End of CC checks
3215 # After here, no more $cc or $ld runs
3217 write_c_skeleton
3219 if test "$gcov" = "yes" ; then
3221 elif test "$fortify_source" = "yes" ; then
3222 QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
3223 debug=no
3226 case "$ARCH" in
3227 alpha)
3228 # Ensure there's only a single GP
3229 QEMU_CFLAGS="-msmall-data $QEMU_CFLAGS"
3231 esac
3233 if test "$gprof" = "yes" ; then
3234 QEMU_CFLAGS="-p $QEMU_CFLAGS"
3235 QEMU_LDFLAGS="-p $QEMU_LDFLAGS"
3238 if test "$have_asan" = "yes"; then
3239 QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS"
3240 QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS"
3241 if test "$have_asan_iface_h" = "no" ; then
3242 echo "ASAN build enabled, but ASAN header missing." \
3243 "Without code annotation, the report may be inferior."
3244 elif test "$have_asan_iface_fiber" = "no" ; then
3245 echo "ASAN build enabled, but ASAN header is too old." \
3246 "Without code annotation, the report may be inferior."
3249 if test "$have_tsan" = "yes" ; then
3250 if test "$have_tsan_iface_fiber" = "yes" ; then
3251 QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS"
3252 QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS"
3253 else
3254 error_exit "Cannot enable TSAN due to missing fiber annotation interface."
3256 elif test "$tsan" = "yes" ; then
3257 error_exit "Cannot enable TSAN due to missing sanitize thread interface."
3259 if test "$have_ubsan" = "yes"; then
3260 QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS"
3261 QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS"
3264 ##########################################
3266 # Exclude --warn-common with TSan to suppress warnings from the TSan libraries.
3267 if test "$solaris" = "no" && test "$tsan" = "no"; then
3268 if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
3269 QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS"
3273 # Use ASLR, no-SEH and DEP if available
3274 if test "$mingw32" = "yes" ; then
3275 flags="--no-seh --nxcompat"
3277 # Disable ASLR for debug builds to allow debugging with gdb
3278 if test "$debug" = "no" ; then
3279 flags="--dynamicbase $flags"
3282 for flag in $flags; do
3283 if ld_has $flag ; then
3284 QEMU_LDFLAGS="-Wl,$flag $QEMU_LDFLAGS"
3286 done
3289 # Probe for guest agent support/options
3291 if [ "$guest_agent" != "no" ]; then
3292 if [ "$softmmu" = no -a "$want_tools" = no ] ; then
3293 guest_agent=no
3294 elif [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
3295 guest_agent=yes
3296 elif [ "$guest_agent" != yes ]; then
3297 guest_agent=no
3298 else
3299 error_exit "Guest agent is not supported on this platform"
3303 # Guest agent Windows MSI package
3305 if test "$QEMU_GA_MANUFACTURER" = ""; then
3306 QEMU_GA_MANUFACTURER=QEMU
3308 if test "$QEMU_GA_DISTRO" = ""; then
3309 QEMU_GA_DISTRO=Linux
3311 if test "$QEMU_GA_VERSION" = ""; then
3312 QEMU_GA_VERSION=$(cat $source_path/VERSION)
3315 QEMU_GA_MSI_MINGW_DLL_PATH="$($pkg_config --variable=prefix glib-2.0)/bin"
3317 # Mac OS X ships with a broken assembler
3318 roms=
3319 if { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \
3320 test "$targetos" != "darwin" && test "$targetos" != "sunos" && \
3321 test "$targetos" != "haiku" && test "$softmmu" = yes ; then
3322 # Different host OS linkers have different ideas about the name of the ELF
3323 # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
3324 # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
3325 for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
3326 if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
3327 ld_i386_emulation="$emu"
3328 roms="optionrom"
3329 break
3331 done
3334 # Only build s390-ccw bios if we're on s390x and the compiler has -march=z900
3335 # or -march=z10 (which is the lowest architecture level that Clang supports)
3336 if test "$cpu" = "s390x" ; then
3337 write_c_skeleton
3338 compile_prog "-march=z900" ""
3339 has_z900=$?
3340 if [ $has_z900 = 0 ] || compile_object "-march=z10 -msoft-float -Werror"; then
3341 if [ $has_z900 != 0 ]; then
3342 echo "WARNING: Your compiler does not support the z900!"
3343 echo " The s390-ccw bios will only work with guest CPUs >= z10."
3345 roms="$roms s390-ccw"
3346 # SLOF is required for building the s390-ccw firmware on s390x,
3347 # since it is using the libnet code from SLOF for network booting.
3348 git_submodules="${git_submodules} roms/SLOF"
3352 # Check that the C++ compiler exists and works with the C compiler.
3353 # All the QEMU_CXXFLAGS are based on QEMU_CFLAGS. Keep this at the end to don't miss any other that could be added.
3354 if has $cxx; then
3355 cat > $TMPC <<EOF
3356 int c_function(void);
3357 int main(void) { return c_function(); }
3360 compile_object
3362 cat > $TMPCXX <<EOF
3363 extern "C" {
3364 int c_function(void);
3366 int c_function(void) { return 42; }
3369 update_cxxflags
3371 if do_cxx $CXXFLAGS $EXTRA_CXXFLAGS $CONFIGURE_CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then
3372 # C++ compiler $cxx works ok with C compiler $cc
3374 else
3375 echo "C++ compiler $cxx does not work with C compiler $cc"
3376 echo "Disabling C++ specific optional code"
3377 cxx=
3379 else
3380 echo "No C++ compiler available; disabling C++ specific optional code"
3381 cxx=
3384 if !(GIT="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then
3385 exit 1
3388 config_host_mak="config-host.mak"
3390 echo "# Automatically generated by configure - do not modify" > $config_host_mak
3391 echo >> $config_host_mak
3393 echo all: >> $config_host_mak
3394 echo "GIT=$git" >> $config_host_mak
3395 echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
3396 echo "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak
3398 if test "$debug_tcg" = "yes" ; then
3399 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
3401 if test "$strip_opt" = "yes" ; then
3402 echo "STRIP=${strip}" >> $config_host_mak
3404 if test "$mingw32" = "yes" ; then
3405 echo "CONFIG_WIN32=y" >> $config_host_mak
3406 if test "$guest_agent_with_vss" = "yes" ; then
3407 echo "CONFIG_QGA_VSS=y" >> $config_host_mak
3408 echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
3409 echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
3411 if test "$guest_agent_ntddscsi" = "yes" ; then
3412 echo "CONFIG_QGA_NTDDSCSI=y" >> $config_host_mak
3414 echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
3415 echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
3416 echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
3417 echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
3418 else
3419 echo "CONFIG_POSIX=y" >> $config_host_mak
3422 if test "$linux" = "yes" ; then
3423 echo "CONFIG_LINUX=y" >> $config_host_mak
3426 if test "$darwin" = "yes" ; then
3427 echo "CONFIG_DARWIN=y" >> $config_host_mak
3430 if test "$solaris" = "yes" ; then
3431 echo "CONFIG_SOLARIS=y" >> $config_host_mak
3433 if test "$static" = "yes" ; then
3434 echo "CONFIG_STATIC=y" >> $config_host_mak
3436 if test "$profiler" = "yes" ; then
3437 echo "CONFIG_PROFILER=y" >> $config_host_mak
3439 if test "$want_tools" = "yes" ; then
3440 echo "CONFIG_TOOLS=y" >> $config_host_mak
3442 if test "$guest_agent" = "yes" ; then
3443 echo "CONFIG_GUEST_AGENT=y" >> $config_host_mak
3445 if test "$slirp_smbd" = "yes" ; then
3446 echo "CONFIG_SLIRP_SMBD=y" >> $config_host_mak
3447 echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
3449 if test "$gprof" = "yes" ; then
3450 echo "CONFIG_GPROF=y" >> $config_host_mak
3452 echo "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
3453 echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
3454 if test "$block_drv_whitelist_tools" = "yes" ; then
3455 echo "CONFIG_BDRV_WHITELIST_TOOLS=y" >> $config_host_mak
3457 if test "$xfs" = "yes" ; then
3458 echo "CONFIG_XFS=y" >> $config_host_mak
3460 qemu_version=$(head $source_path/VERSION)
3461 echo "PKGVERSION=$pkgversion" >>$config_host_mak
3462 echo "SRC_PATH=$source_path" >> $config_host_mak
3463 echo "TARGET_DIRS=$target_list" >> $config_host_mak
3464 if test "$modules" = "yes"; then
3465 # $shacmd can generate a hash started with digit, which the compiler doesn't
3466 # like as an symbol. So prefix it with an underscore
3467 echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
3468 echo "CONFIG_MODULES=y" >> $config_host_mak
3470 if test "$module_upgrades" = "yes"; then
3471 echo "CONFIG_MODULE_UPGRADES=y" >> $config_host_mak
3473 if test "$have_usbfs" = "yes" ; then
3474 echo "CONFIG_USBFS=y" >> $config_host_mak
3476 if test "$gio" = "yes" ; then
3477 echo "CONFIG_GIO=y" >> $config_host_mak
3478 echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak
3479 echo "GIO_LIBS=$gio_libs" >> $config_host_mak
3481 if test "$gdbus_codegen" != "" ; then
3482 echo "GDBUS_CODEGEN=$gdbus_codegen" >> $config_host_mak
3484 echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
3486 if test "$xen" = "enabled" ; then
3487 echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
3488 echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
3489 echo "XEN_CFLAGS=$xen_cflags" >> $config_host_mak
3490 echo "XEN_LIBS=$xen_libs" >> $config_host_mak
3492 if test "$vhost_scsi" = "yes" ; then
3493 echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
3495 if test "$vhost_net" = "yes" ; then
3496 echo "CONFIG_VHOST_NET=y" >> $config_host_mak
3498 if test "$vhost_net_user" = "yes" ; then
3499 echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak
3501 if test "$vhost_net_vdpa" = "yes" ; then
3502 echo "CONFIG_VHOST_NET_VDPA=y" >> $config_host_mak
3504 if test "$vhost_crypto" = "yes" ; then
3505 echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
3507 if test "$vhost_vsock" = "yes" ; then
3508 echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
3509 if test "$vhost_user" = "yes" ; then
3510 echo "CONFIG_VHOST_USER_VSOCK=y" >> $config_host_mak
3513 if test "$vhost_kernel" = "yes" ; then
3514 echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak
3516 if test "$vhost_user" = "yes" ; then
3517 echo "CONFIG_VHOST_USER=y" >> $config_host_mak
3519 if test "$vhost_vdpa" = "yes" ; then
3520 echo "CONFIG_VHOST_VDPA=y" >> $config_host_mak
3522 if test "$vhost_user_fs" = "yes" ; then
3523 echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak
3525 if test "$membarrier" = "yes" ; then
3526 echo "CONFIG_MEMBARRIER=y" >> $config_host_mak
3528 if test "$tcg" = "enabled" -a "$tcg_interpreter" = "true" ; then
3529 echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
3532 if test "$opengl" = "yes" ; then
3533 echo "CONFIG_OPENGL=y" >> $config_host_mak
3534 echo "OPENGL_CFLAGS=$opengl_cflags" >> $config_host_mak
3535 echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
3538 if test "$avx2_opt" = "yes" ; then
3539 echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
3542 if test "$avx512f_opt" = "yes" ; then
3543 echo "CONFIG_AVX512F_OPT=y" >> $config_host_mak
3546 # XXX: suppress that
3547 if [ "$bsd" = "yes" ] ; then
3548 echo "CONFIG_BSD=y" >> $config_host_mak
3551 if test "$qom_cast_debug" = "yes" ; then
3552 echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
3555 echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
3556 if test "$coroutine_pool" = "yes" ; then
3557 echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
3558 else
3559 echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
3562 if test "$debug_stack_usage" = "yes" ; then
3563 echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
3566 if test "$crypto_afalg" = "yes" ; then
3567 echo "CONFIG_AF_ALG=y" >> $config_host_mak
3570 if test "$have_asan_iface_fiber" = "yes" ; then
3571 echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
3574 if test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then
3575 echo "CONFIG_TSAN=y" >> $config_host_mak
3578 if test "$cpuid_h" = "yes" ; then
3579 echo "CONFIG_CPUID_H=y" >> $config_host_mak
3582 if test "$int128" = "yes" ; then
3583 echo "CONFIG_INT128=y" >> $config_host_mak
3586 if test "$atomic128" = "yes" ; then
3587 echo "CONFIG_ATOMIC128=y" >> $config_host_mak
3590 if test "$cmpxchg128" = "yes" ; then
3591 echo "CONFIG_CMPXCHG128=y" >> $config_host_mak
3594 if test "$live_block_migration" = "yes" ; then
3595 echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
3598 if test "$tpm" = "yes"; then
3599 echo 'CONFIG_TPM=y' >> $config_host_mak
3602 if test "$rdma" = "yes" ; then
3603 echo "CONFIG_RDMA=y" >> $config_host_mak
3604 echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
3607 if test "$pvrdma" = "yes" ; then
3608 echo "CONFIG_PVRDMA=y" >> $config_host_mak
3611 if test "$replication" = "yes" ; then
3612 echo "CONFIG_REPLICATION=y" >> $config_host_mak
3615 if test "$debug_mutex" = "yes" ; then
3616 echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak
3619 if test "$bochs" = "yes" ; then
3620 echo "CONFIG_BOCHS=y" >> $config_host_mak
3622 if test "$cloop" = "yes" ; then
3623 echo "CONFIG_CLOOP=y" >> $config_host_mak
3625 if test "$dmg" = "yes" ; then
3626 echo "CONFIG_DMG=y" >> $config_host_mak
3628 if test "$qcow1" = "yes" ; then
3629 echo "CONFIG_QCOW1=y" >> $config_host_mak
3631 if test "$vdi" = "yes" ; then
3632 echo "CONFIG_VDI=y" >> $config_host_mak
3634 if test "$vvfat" = "yes" ; then
3635 echo "CONFIG_VVFAT=y" >> $config_host_mak
3637 if test "$qed" = "yes" ; then
3638 echo "CONFIG_QED=y" >> $config_host_mak
3640 if test "$parallels" = "yes" ; then
3641 echo "CONFIG_PARALLELS=y" >> $config_host_mak
3644 if test "$plugins" = "yes" ; then
3645 echo "CONFIG_PLUGIN=y" >> $config_host_mak
3646 # Copy the export object list to the build dir
3647 if test "$ld_dynamic_list" = "yes" ; then
3648 echo "CONFIG_HAS_LD_DYNAMIC_LIST=yes" >> $config_host_mak
3649 ld_symbols=qemu-plugins-ld.symbols
3650 cp "$source_path/plugins/qemu-plugins.symbols" $ld_symbols
3651 elif test "$ld_exported_symbols_list" = "yes" ; then
3652 echo "CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST=yes" >> $config_host_mak
3653 ld64_symbols=qemu-plugins-ld64.symbols
3654 echo "# Automatically generated by configure - do not modify" > $ld64_symbols
3655 grep 'qemu_' "$source_path/plugins/qemu-plugins.symbols" | sed 's/;//g' | \
3656 sed -E 's/^[[:space:]]*(.*)/_\1/' >> $ld64_symbols
3657 else
3658 error_exit \
3659 "If \$plugins=yes, either \$ld_dynamic_list or " \
3660 "\$ld_exported_symbols_list should have been set to 'yes'."
3664 if test -n "$gdb_bin"; then
3665 gdb_version=$($gdb_bin --version | head -n 1)
3666 if version_ge ${gdb_version##* } 9.1; then
3667 echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
3671 if test "$secret_keyring" = "yes" ; then
3672 echo "CONFIG_SECRET_KEYRING=y" >> $config_host_mak
3675 echo "ROMS=$roms" >> $config_host_mak
3676 echo "MAKE=$make" >> $config_host_mak
3677 echo "PYTHON=$python" >> $config_host_mak
3678 echo "GENISOIMAGE=$genisoimage" >> $config_host_mak
3679 echo "MESON=$meson" >> $config_host_mak
3680 echo "NINJA=$ninja" >> $config_host_mak
3681 echo "CC=$cc" >> $config_host_mak
3682 echo "HOST_CC=$host_cc" >> $config_host_mak
3683 if $iasl -h > /dev/null 2>&1; then
3684 echo "CONFIG_IASL=$iasl" >> $config_host_mak
3686 echo "AR=$ar" >> $config_host_mak
3687 echo "AS=$as" >> $config_host_mak
3688 echo "CCAS=$ccas" >> $config_host_mak
3689 echo "CPP=$cpp" >> $config_host_mak
3690 echo "OBJCOPY=$objcopy" >> $config_host_mak
3691 echo "LD=$ld" >> $config_host_mak
3692 echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
3693 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
3694 echo "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
3695 echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
3696 echo "GLIB_LIBS=$glib_libs" >> $config_host_mak
3697 echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
3698 echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
3699 echo "EXESUF=$EXESUF" >> $config_host_mak
3700 echo "LIBS_QGA=$libs_qga" >> $config_host_mak
3702 if test "$rng_none" = "yes"; then
3703 echo "CONFIG_RNG_NONE=y" >> $config_host_mak
3706 # use included Linux headers
3707 if test "$linux" = "yes" ; then
3708 mkdir -p linux-headers
3709 case "$cpu" in
3710 i386|x86_64)
3711 linux_arch=x86
3713 ppc|ppc64)
3714 linux_arch=powerpc
3716 s390x)
3717 linux_arch=s390
3719 aarch64)
3720 linux_arch=arm64
3722 mips64)
3723 linux_arch=mips
3726 # For most CPUs the kernel architecture name and QEMU CPU name match.
3727 linux_arch="$cpu"
3729 esac
3730 # For non-KVM architectures we will not have asm headers
3731 if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
3732 symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
3736 for target in $target_list; do
3737 target_dir="$target"
3738 target_name=$(echo $target | cut -d '-' -f 1)$EXESUF
3739 mkdir -p $target_dir
3740 case $target in
3741 *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;;
3742 *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;;
3743 esac
3744 done
3746 echo "CONFIG_QEMU_INTERP_PREFIX=$interp_prefix" | sed 's/%M/@0@/' >> $config_host_mak
3747 if test "$default_targets" = "yes"; then
3748 echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak
3751 if test "$numa" = "yes"; then
3752 echo "CONFIG_NUMA=y" >> $config_host_mak
3753 echo "NUMA_LIBS=$numa_libs" >> $config_host_mak
3756 if test "$ccache_cpp2" = "yes"; then
3757 echo "export CCACHE_CPP2=y" >> $config_host_mak
3760 if test "$safe_stack" = "yes"; then
3761 echo "CONFIG_SAFESTACK=y" >> $config_host_mak
3764 # If we're using a separate build tree, set it up now.
3765 # LINKS are things to symlink back into the source tree
3766 # (these can be both files and directories).
3767 # Caution: do not add files or directories here using wildcards. This
3768 # will result in problems later if a new file matching the wildcard is
3769 # added to the source tree -- nothing will cause configure to be rerun
3770 # so the build tree will be missing the link back to the new file, and
3771 # tests might fail. Prefer to keep the relevant files in their own
3772 # directory and symlink the directory instead.
3773 # UNLINK is used to remove symlinks from older development versions
3774 # that might get into the way when doing "git update" without doing
3775 # a "make distclean" in between.
3776 LINKS="Makefile"
3777 LINKS="$LINKS tests/tcg/Makefile.target"
3778 LINKS="$LINKS pc-bios/optionrom/Makefile"
3779 LINKS="$LINKS pc-bios/s390-ccw/Makefile"
3780 LINKS="$LINKS roms/seabios/Makefile"
3781 LINKS="$LINKS pc-bios/qemu-icon.bmp"
3782 LINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
3783 LINKS="$LINKS tests/avocado tests/data"
3784 LINKS="$LINKS tests/qemu-iotests/check"
3785 LINKS="$LINKS python"
3786 LINKS="$LINKS contrib/plugins/Makefile "
3787 UNLINK="pc-bios/keymaps"
3788 for bios_file in \
3789 $source_path/pc-bios/*.bin \
3790 $source_path/pc-bios/*.elf \
3791 $source_path/pc-bios/*.lid \
3792 $source_path/pc-bios/*.rom \
3793 $source_path/pc-bios/*.dtb \
3794 $source_path/pc-bios/*.img \
3795 $source_path/pc-bios/openbios-* \
3796 $source_path/pc-bios/u-boot.* \
3797 $source_path/pc-bios/palcode-* \
3798 $source_path/pc-bios/qemu_vga.ndrv
3801 LINKS="$LINKS pc-bios/$(basename $bios_file)"
3802 done
3803 for f in $LINKS ; do
3804 if [ -e "$source_path/$f" ]; then
3805 mkdir -p `dirname ./$f`
3806 symlink "$source_path/$f" "$f"
3808 done
3809 for f in $UNLINK ; do
3810 if [ -L "$f" ]; then
3811 rm -f "$f"
3813 done
3815 (for i in $cross_cc_vars; do
3816 export $i
3817 done
3818 export target_list source_path use_containers ARCH
3819 $source_path/tests/tcg/configure.sh)
3821 # temporary config to build submodules
3822 for rom in seabios; do
3823 config_mak=roms/$rom/config.mak
3824 echo "# Automatically generated by configure - do not modify" > $config_mak
3825 echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
3826 echo "AS=$as" >> $config_mak
3827 echo "CCAS=$ccas" >> $config_mak
3828 echo "CC=$cc" >> $config_mak
3829 echo "BCC=bcc" >> $config_mak
3830 echo "CPP=$cpp" >> $config_mak
3831 echo "OBJCOPY=objcopy" >> $config_mak
3832 echo "IASL=$iasl" >> $config_mak
3833 echo "LD=$ld" >> $config_mak
3834 echo "RANLIB=$ranlib" >> $config_mak
3835 done
3837 config_mak=pc-bios/optionrom/config.mak
3838 echo "# Automatically generated by configure - do not modify" > $config_mak
3839 echo "TOPSRC_DIR=$source_path" >> $config_mak
3841 if test "$skip_meson" = no; then
3842 cross="config-meson.cross.new"
3843 meson_quote() {
3844 test $# = 0 && return
3845 echo "'$(echo $* | sed "s/ /','/g")'"
3848 echo "# Automatically generated by configure - do not modify" > $cross
3849 echo "[properties]" >> $cross
3851 # unroll any custom device configs
3852 for a in $device_archs; do
3853 eval "c=\$devices_${a}"
3854 echo "${a}-softmmu = '$c'" >> $cross
3855 done
3857 test -z "$cxx" && echo "link_language = 'c'" >> $cross
3858 echo "[built-in options]" >> $cross
3859 echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross
3860 echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross
3861 echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross
3862 echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross
3863 echo "[binaries]" >> $cross
3864 echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross
3865 test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross
3866 test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross
3867 echo "ar = [$(meson_quote $ar)]" >> $cross
3868 echo "nm = [$(meson_quote $nm)]" >> $cross
3869 echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross
3870 echo "ranlib = [$(meson_quote $ranlib)]" >> $cross
3871 if has $sdl2_config; then
3872 echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross
3874 echo "strip = [$(meson_quote $strip)]" >> $cross
3875 echo "windres = [$(meson_quote $windres)]" >> $cross
3876 if test "$cross_compile" = "yes"; then
3877 cross_arg="--cross-file config-meson.cross"
3878 echo "[host_machine]" >> $cross
3879 echo "system = '$targetos'" >> $cross
3880 case "$cpu" in
3881 i386)
3882 echo "cpu_family = 'x86'" >> $cross
3885 echo "cpu_family = '$cpu'" >> $cross
3887 esac
3888 echo "cpu = '$cpu'" >> $cross
3889 if test "$bigendian" = "yes" ; then
3890 echo "endian = 'big'" >> $cross
3891 else
3892 echo "endian = 'little'" >> $cross
3894 else
3895 cross_arg="--native-file config-meson.cross"
3897 mv $cross config-meson.cross
3899 rm -rf meson-private meson-info meson-logs
3900 run_meson() {
3901 NINJA=$ninja $meson setup \
3902 --prefix "$prefix" \
3903 --libdir "$libdir" \
3904 --libexecdir "$libexecdir" \
3905 --bindir "$bindir" \
3906 --includedir "$includedir" \
3907 --datadir "$datadir" \
3908 --mandir "$mandir" \
3909 --sysconfdir "$sysconfdir" \
3910 --localedir "$localedir" \
3911 --localstatedir "$local_statedir" \
3912 -Daudio_drv_list=$audio_drv_list \
3913 -Ddefault_devices=$default_devices \
3914 -Ddocdir="$docdir" \
3915 -Dqemu_firmwarepath="$firmwarepath" \
3916 -Dqemu_suffix="$qemu_suffix" \
3917 -Dsphinx_build="$sphinx_build" \
3918 -Dtrace_file="$trace_file" \
3919 -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) \
3920 -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo false; fi) \
3921 -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \
3922 -Dstrip=$(if test "$strip_opt" = yes; then echo true; else echo false; fi) \
3923 -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \
3924 -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \
3925 -Db_lto=$lto -Dcfi=$cfi -Dtcg=$tcg -Dxen=$xen \
3926 -Dcapstone=$capstone -Dfdt=$fdt -Dslirp=$slirp \
3927 $(test -n "${LIB_FUZZING_ENGINE+xxx}" && echo "-Dfuzzing_engine=$LIB_FUZZING_ENGINE") \
3928 $(if test "$default_feature" = no; then echo "-Dauto_features=disabled"; fi) \
3929 "$@" $cross_arg "$PWD" "$source_path"
3931 eval run_meson $meson_options
3932 if test "$?" -ne 0 ; then
3933 error_exit "meson setup failed"
3935 else
3936 if test -f meson-private/cmd_line.txt; then
3937 # Adjust old command line options whose type was changed
3938 # Avoids having to use "setup --wipe" when Meson is upgraded
3939 perl -i -ne '
3940 s/^gettext = true$/gettext = auto/;
3941 s/^gettext = false$/gettext = disabled/;
3942 /^b_staticpic/ && next;
3943 print;' meson-private/cmd_line.txt
3947 if test -n "${deprecated_features}"; then
3948 echo "Warning, deprecated features enabled."
3949 echo "Please see docs/about/deprecated.rst"
3950 echo " features: ${deprecated_features}"
3953 # Create list of config switches that should be poisoned in common code...
3954 # but filter out CONFIG_TCG and CONFIG_USER_ONLY which are special.
3955 target_configs_h=$(ls *-config-devices.h *-config-target.h 2>/dev/null)
3956 if test -n "$target_configs_h" ; then
3957 sed -n -e '/CONFIG_TCG/d' -e '/CONFIG_USER_ONLY/d' \
3958 -e '/^#define / { s///; s/ .*//; s/^/#pragma GCC poison /p; }' \
3959 $target_configs_h | sort -u > config-poison.h
3960 else
3961 :> config-poison.h
3964 # Save the configure command line for later reuse.
3965 cat <<EOD >config.status
3966 #!/bin/sh
3967 # Generated by configure.
3968 # Run this file to recreate the current configuration.
3969 # Compiler output produced by configure, useful for debugging
3970 # configure, is in config.log if it exists.
3973 preserve_env() {
3974 envname=$1
3976 eval envval=\$$envname
3978 if test -n "$envval"
3979 then
3980 echo "$envname='$envval'" >> config.status
3981 echo "export $envname" >> config.status
3982 else
3983 echo "unset $envname" >> config.status
3987 # Preserve various env variables that influence what
3988 # features/build target configure will detect
3989 preserve_env AR
3990 preserve_env AS
3991 preserve_env CC
3992 preserve_env CPP
3993 preserve_env CFLAGS
3994 preserve_env CXX
3995 preserve_env CXXFLAGS
3996 preserve_env INSTALL
3997 preserve_env LD
3998 preserve_env LDFLAGS
3999 preserve_env LD_LIBRARY_PATH
4000 preserve_env LIBTOOL
4001 preserve_env MAKE
4002 preserve_env NM
4003 preserve_env OBJCOPY
4004 preserve_env PATH
4005 preserve_env PKG_CONFIG
4006 preserve_env PKG_CONFIG_LIBDIR
4007 preserve_env PKG_CONFIG_PATH
4008 preserve_env PYTHON
4009 preserve_env SDL2_CONFIG
4010 preserve_env SMBD
4011 preserve_env STRIP
4012 preserve_env WINDRES
4014 printf "exec" >>config.status
4015 for i in "$0" "$@"; do
4016 test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status
4017 done
4018 echo ' "$@"' >>config.status
4019 chmod +x config.status
4021 rm -r "$TMPDIR1"