tests/lcitool: Install libibumad to cover RDMA on Debian based distros
[qemu/rayw.git] / configure
blobdfb9019b24f27bd801b6001568d23a1fcda687ef
1 #!/bin/sh
3 # qemu configure script (c) 2003 Fabrice Bellard
6 # Unset some variables known to interfere with behavior of common tools,
7 # just as autoconf does.
8 CLICOLOR_FORCE= GREP_OPTIONS=
9 unset CLICOLOR_FORCE GREP_OPTIONS
11 # Don't allow CCACHE, if present, to use cached results of compile tests!
12 export CCACHE_RECACHE=yes
14 # make source path absolute
15 source_path=$(cd "$(dirname -- "$0")"; pwd)
17 if test "$PWD" = "$source_path"
18 then
19 echo "Using './build' as the directory for build output"
21 MARKER=build/auto-created-by-configure
23 if test -e build
24 then
25 if test -f $MARKER
26 then
27 rm -rf build
28 else
29 echo "ERROR: ./build dir already exists and was not previously created by configure"
30 exit 1
34 mkdir build
35 touch $MARKER
37 cat > GNUmakefile <<'EOF'
38 # This file is auto-generated by configure to support in-source tree
39 # 'make' command invocation
41 ifeq ($(MAKECMDGOALS),)
42 recurse: all
43 endif
45 .NOTPARALLEL: %
46 %: force
47 @echo 'changing dir to build for $(MAKE) "$(MAKECMDGOALS)"...'
48 @$(MAKE) -C build -f Makefile $(MAKECMDGOALS)
49 @if test "$(MAKECMDGOALS)" = "distclean" && \
50 test -e build/auto-created-by-configure ; \
51 then \
52 rm -rf build GNUmakefile ; \
54 force: ;
55 .PHONY: force
56 GNUmakefile: ;
58 EOF
59 cd build
60 exec $source_path/configure "$@"
63 # Temporary directory used for files created while
64 # configure runs. Since it is in the build directory
65 # we can safely blow away any previous version of it
66 # (and we need not jump through hoops to try to delete
67 # it when configure exits.)
68 TMPDIR1="config-temp"
69 rm -rf "${TMPDIR1}"
70 mkdir -p "${TMPDIR1}"
71 if [ $? -ne 0 ]; then
72 echo "ERROR: failed to create temporary directory"
73 exit 1
76 TMPB="qemu-conf"
77 TMPC="${TMPDIR1}/${TMPB}.c"
78 TMPO="${TMPDIR1}/${TMPB}.o"
79 TMPCXX="${TMPDIR1}/${TMPB}.cxx"
80 TMPE="${TMPDIR1}/${TMPB}.exe"
82 rm -f config.log
84 # Print a helpful header at the top of config.log
85 echo "# QEMU configure log $(date)" >> config.log
86 printf "# Configured with:" >> config.log
87 printf " '%s'" "$0" "$@" >> config.log
88 echo >> config.log
89 echo "#" >> config.log
91 quote_sh() {
92 printf "%s" "$1" | sed "s,','\\\\'',g; s,.*,'&',"
95 print_error() {
96 (echo
97 echo "ERROR: $1"
98 while test -n "$2"; do
99 echo " $2"
100 shift
101 done
102 echo) >&2
105 error_exit() {
106 print_error "$@"
107 exit 1
110 do_compiler() {
111 # Run the compiler, capturing its output to the log. First argument
112 # is compiler binary to execute.
113 compiler="$1"
114 shift
115 if test -n "$BASH_VERSION"; then eval '
116 echo >>config.log "
117 funcs: ${FUNCNAME[*]}
118 lines: ${BASH_LINENO[*]}"
119 '; fi
120 echo $compiler "$@" >> config.log
121 $compiler "$@" >> config.log 2>&1 || return $?
122 # Test passed. If this is an --enable-werror build, rerun
123 # the test with -Werror and bail out if it fails. This
124 # makes warning-generating-errors in configure test code
125 # obvious to developers.
126 if test "$werror" != "yes"; then
127 return 0
129 # Don't bother rerunning the compile if we were already using -Werror
130 case "$*" in
131 *-Werror*)
132 return 0
134 esac
135 echo $compiler -Werror "$@" >> config.log
136 $compiler -Werror "$@" >> config.log 2>&1 && return $?
137 error_exit "configure test passed without -Werror but failed with -Werror." \
138 "This is probably a bug in the configure script. The failing command" \
139 "will be at the bottom of config.log." \
140 "You can run configure with --disable-werror to bypass this check."
143 do_cc() {
144 do_compiler "$cc" $CPU_CFLAGS "$@"
147 do_cxx() {
148 do_compiler "$cxx" $CPU_CFLAGS "$@"
151 # Append $2 to the variable named $1, with space separation
152 add_to() {
153 eval $1=\${$1:+\"\$$1 \"}\$2
156 update_cxxflags() {
157 # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
158 # options which some versions of GCC's C++ compiler complain about
159 # because they only make sense for C programs.
160 QEMU_CXXFLAGS="-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS"
161 CONFIGURE_CXXFLAGS=$(echo "$CONFIGURE_CFLAGS" | sed s/-std=gnu11/-std=gnu++11/)
162 for arg in $QEMU_CFLAGS; do
163 case $arg in
164 -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
165 -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
168 QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
170 esac
171 done
174 compile_object() {
175 local_cflags="$1"
176 do_cc $CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
179 compile_prog() {
180 local_cflags="$1"
181 local_ldflags="$2"
182 do_cc $CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC \
183 $LDFLAGS $EXTRA_LDFLAGS $CONFIGURE_LDFLAGS $QEMU_LDFLAGS $local_ldflags
186 # symbolically link $1 to $2. Portable version of "ln -sf".
187 symlink() {
188 rm -rf "$2"
189 mkdir -p "$(dirname "$2")"
190 ln -s "$1" "$2"
193 # check whether a command is available to this shell (may be either an
194 # executable or a builtin)
195 has() {
196 type "$1" >/dev/null 2>&1
199 version_ge () {
200 local_ver1=$(expr "$1" : '\([0-9.]*\)' | tr . ' ')
201 local_ver2=$(echo "$2" | tr . ' ')
202 while true; do
203 set x $local_ver1
204 local_first=${2-0}
205 # 'shift 2' if $2 is set, or 'shift' if $2 is not set
206 shift ${2:+2}
207 local_ver1=$*
208 set x $local_ver2
209 # the second argument finished, the first must be greater or equal
210 test $# = 1 && return 0
211 test $local_first -lt $2 && return 1
212 test $local_first -gt $2 && return 0
213 shift ${2:+2}
214 local_ver2=$*
215 done
218 glob() {
219 eval test -z '"${1#'"$2"'}"'
222 ld_has() {
223 $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
226 if printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]";
227 then
228 error_exit "main directory cannot contain spaces nor colons"
231 # default parameters
232 cpu=""
233 iasl="iasl"
234 interp_prefix="/usr/gnemul/qemu-%M"
235 static="no"
236 cross_compile="no"
237 cross_prefix=""
238 audio_drv_list="default"
239 block_drv_rw_whitelist=""
240 block_drv_ro_whitelist=""
241 block_drv_whitelist_tools="no"
242 host_cc="cc"
243 libs_qga=""
244 debug_info="yes"
245 lto="false"
246 stack_protector=""
247 safe_stack=""
248 use_containers="yes"
249 gdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
251 if test -e "$source_path/.git"
252 then
253 git_submodules_action="update"
254 else
255 git_submodules_action="ignore"
258 git_submodules="ui/keycodemapdb"
259 git="git"
261 # Don't accept a target_list environment variable.
262 unset target_list
263 unset target_list_exclude
265 # Default value for a variable defining feature "foo".
266 # * foo="no" feature will only be used if --enable-foo arg is given
267 # * foo="" feature will be searched for, and if found, will be used
268 # unless --disable-foo is given
269 # * foo="yes" this value will only be set by --enable-foo flag.
270 # feature will searched for,
271 # if not found, configure exits with error
273 # Always add --enable-foo and --disable-foo command line args.
274 # Distributions want to ensure that several features are compiled in, and it
275 # is impossible without a --enable-foo that exits if a feature is not found.
277 default_feature=""
278 # parse CC options second
279 for opt do
280 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
281 case "$opt" in
282 --without-default-features)
283 default_feature="no"
285 esac
286 done
288 EXTRA_CFLAGS=""
289 EXTRA_CXXFLAGS=""
290 EXTRA_LDFLAGS=""
292 xen_ctrl_version="$default_feature"
293 membarrier="$default_feature"
294 vhost_kernel="$default_feature"
295 vhost_net="$default_feature"
296 vhost_crypto="$default_feature"
297 vhost_scsi="$default_feature"
298 vhost_vsock="$default_feature"
299 vhost_user="no"
300 vhost_user_fs="$default_feature"
301 vhost_vdpa="$default_feature"
302 rdma="$default_feature"
303 pvrdma="$default_feature"
304 gprof="no"
305 debug_tcg="no"
306 debug="no"
307 sanitizers="no"
308 tsan="no"
309 fortify_source="$default_feature"
310 gcov="no"
311 EXESUF=""
312 modules="no"
313 module_upgrades="no"
314 prefix="/usr/local"
315 qemu_suffix="qemu"
316 profiler="no"
317 softmmu="yes"
318 linux_user=""
319 bsd_user=""
320 pkgversion=""
321 pie=""
322 qom_cast_debug="yes"
323 trace_backends="log"
324 trace_file="trace"
325 opengl="$default_feature"
326 cpuid_h="no"
327 avx2_opt="$default_feature"
328 guest_agent="$default_feature"
329 vss_win32_sdk="$default_feature"
330 win_sdk="no"
331 want_tools="$default_feature"
332 coroutine=""
333 coroutine_pool="$default_feature"
334 debug_stack_usage="no"
335 crypto_afalg="no"
336 tls_priority="NORMAL"
337 tpm="$default_feature"
338 live_block_migration=${default_feature:-yes}
339 numa="$default_feature"
340 replication=${default_feature:-yes}
341 bochs=${default_feature:-yes}
342 cloop=${default_feature:-yes}
343 dmg=${default_feature:-yes}
344 qcow1=${default_feature:-yes}
345 vdi=${default_feature:-yes}
346 vvfat=${default_feature:-yes}
347 qed=${default_feature:-yes}
348 parallels=${default_feature:-yes}
349 debug_mutex="no"
350 plugins="$default_feature"
351 rng_none="no"
352 secret_keyring="$default_feature"
353 meson=""
354 meson_args=""
355 ninja=""
356 gio="$default_feature"
357 skip_meson=no
358 slirp_smbd="$default_feature"
360 # The following Meson options are handled manually (still they
361 # are included in the automatically generated help message)
363 # 1. Track which submodules are needed
364 capstone="auto"
365 fdt="auto"
366 slirp="auto"
368 # 2. Support --with/--without option
369 default_devices="true"
371 # 3. Automatically enable/disable other options
372 tcg="enabled"
373 cfi="false"
375 # 4. Detection partly done in configure
376 xen=${default_feature:+disabled}
378 # parse CC options second
379 for opt do
380 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
381 case "$opt" in
382 --cross-prefix=*) cross_prefix="$optarg"
383 cross_compile="yes"
385 --cc=*) CC="$optarg"
387 --cxx=*) CXX="$optarg"
389 --cpu=*) cpu="$optarg"
391 --extra-cflags=*)
392 EXTRA_CFLAGS="$EXTRA_CFLAGS $optarg"
393 EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg"
395 --extra-cxxflags=*) EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg"
397 --extra-ldflags=*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS $optarg"
399 --enable-debug-info) debug_info="yes"
401 --disable-debug-info) debug_info="no"
403 --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
405 --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-cflags-}; cc_arch=${cc_arch%%=*}
406 eval "cross_cc_cflags_${cc_arch}=\$optarg"
407 cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}"
409 --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
410 cc_archs="$cc_archs $cc_arch"
411 eval "cross_cc_${cc_arch}=\$optarg"
412 cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}"
414 esac
415 done
416 # OS specific
417 # Using uname is really, really broken. Once we have the right set of checks
418 # we can eliminate its usage altogether.
420 # Preferred compiler:
421 # ${CC} (if set)
422 # ${cross_prefix}gcc (if cross-prefix specified)
423 # system compiler
424 if test -z "${CC}${cross_prefix}"; then
425 cc="$host_cc"
426 else
427 cc="${CC-${cross_prefix}gcc}"
430 if test -z "${CXX}${cross_prefix}"; then
431 cxx="c++"
432 else
433 cxx="${CXX-${cross_prefix}g++}"
436 ar="${AR-${cross_prefix}ar}"
437 as="${AS-${cross_prefix}as}"
438 ccas="${CCAS-$cc}"
439 cpp="${CPP-$cc -E}"
440 objcopy="${OBJCOPY-${cross_prefix}objcopy}"
441 ld="${LD-${cross_prefix}ld}"
442 ranlib="${RANLIB-${cross_prefix}ranlib}"
443 nm="${NM-${cross_prefix}nm}"
444 strip="${STRIP-${cross_prefix}strip}"
445 windres="${WINDRES-${cross_prefix}windres}"
446 pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
447 query_pkg_config() {
448 "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
450 pkg_config=query_pkg_config
451 sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
453 # default flags for all hosts
454 # We use -fwrapv to tell the compiler that we require a C dialect where
455 # left shift of signed integers is well defined and has the expected
456 # 2s-complement style results. (Both clang and gcc agree that it
457 # provides these semantics.)
458 QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv"
459 QEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
460 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
461 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
463 QEMU_LDFLAGS=
465 # Flags that are needed during configure but later taken care of by Meson
466 CONFIGURE_CFLAGS="-std=gnu11 -Wall"
467 CONFIGURE_LDFLAGS=
470 check_define() {
471 cat > $TMPC <<EOF
472 #if !defined($1)
473 #error $1 not defined
474 #endif
475 int main(void) { return 0; }
477 compile_object
480 check_include() {
481 cat > $TMPC <<EOF
482 #include <$1>
483 int main(void) { return 0; }
485 compile_object
488 write_c_skeleton() {
489 cat > $TMPC <<EOF
490 int main(void) { return 0; }
494 if check_define __linux__ ; then
495 targetos=linux
496 elif check_define _WIN32 ; then
497 targetos=windows
498 elif check_define __OpenBSD__ ; then
499 targetos=openbsd
500 elif check_define __sun__ ; then
501 targetos=sunos
502 elif check_define __HAIKU__ ; then
503 targetos=haiku
504 elif check_define __FreeBSD__ ; then
505 targetos=freebsd
506 elif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
507 targetos=gnu/kfreebsd
508 elif check_define __DragonFly__ ; then
509 targetos=dragonfly
510 elif check_define __NetBSD__; then
511 targetos=netbsd
512 elif check_define __APPLE__; then
513 targetos=darwin
514 else
515 # This is a fatal error, but don't report it yet, because we
516 # might be going to just print the --help text, or it might
517 # be the result of a missing compiler.
518 targetos=bogus
521 # OS specific
523 mingw32="no"
524 bsd="no"
525 linux="no"
526 solaris="no"
527 case $targetos in
528 windows)
529 mingw32="yes"
530 plugins="no"
531 pie="no"
533 gnu/kfreebsd)
534 bsd="yes"
536 freebsd)
537 bsd="yes"
538 make="${MAKE-gmake}"
539 # needed for kinfo_getvmmap(3) in libutil.h
541 dragonfly)
542 bsd="yes"
543 make="${MAKE-gmake}"
545 netbsd)
546 bsd="yes"
547 make="${MAKE-gmake}"
549 openbsd)
550 bsd="yes"
551 make="${MAKE-gmake}"
553 darwin)
554 bsd="yes"
555 darwin="yes"
556 # Disable attempts to use ObjectiveC features in os/object.h since they
557 # won't work when we're compiling with gcc as a C compiler.
558 QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
560 sunos)
561 solaris="yes"
562 make="${MAKE-gmake}"
563 smbd="${SMBD-/usr/sfw/sbin/smbd}"
564 # needed for CMSG_ macros in sys/socket.h
565 QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
566 # needed for TIOCWIN* defines in termios.h
567 QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
568 # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
569 # Note that this check is broken for cross-compilation: if you're
570 # cross-compiling to one of these OSes then you'll need to specify
571 # the correct CPU with the --cpu option.
572 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
573 cpu="x86_64"
576 haiku)
577 pie="no"
578 QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE -fPIC $QEMU_CFLAGS"
580 linux)
581 linux="yes"
582 vhost_user=${default_feature:-yes}
584 esac
586 if test ! -z "$cpu" ; then
587 # command line argument
589 elif check_define __i386__ ; then
590 cpu="i386"
591 elif check_define __x86_64__ ; then
592 if check_define __ILP32__ ; then
593 cpu="x32"
594 else
595 cpu="x86_64"
597 elif check_define __sparc__ ; then
598 if check_define __arch64__ ; then
599 cpu="sparc64"
600 else
601 cpu="sparc"
603 elif check_define _ARCH_PPC ; then
604 if check_define _ARCH_PPC64 ; then
605 if check_define _LITTLE_ENDIAN ; then
606 cpu="ppc64le"
607 else
608 cpu="ppc64"
610 else
611 cpu="ppc"
613 elif check_define __mips__ ; then
614 cpu="mips"
615 elif check_define __s390__ ; then
616 if check_define __s390x__ ; then
617 cpu="s390x"
618 else
619 cpu="s390"
621 elif check_define __riscv ; then
622 cpu="riscv"
623 elif check_define __arm__ ; then
624 cpu="arm"
625 elif check_define __aarch64__ ; then
626 cpu="aarch64"
627 elif check_define __loongarch64 ; then
628 cpu="loongarch64"
629 else
630 cpu=$(uname -m)
633 # Normalise host CPU name, set multilib cflags
634 # Note that this case should only have supported host CPUs, not guests.
635 case "$cpu" in
636 armv*b|armv*l|arm)
637 cpu="arm" ;;
639 i386|i486|i586|i686|i86pc|BePC)
640 cpu="i386"
641 CPU_CFLAGS="-m32" ;;
642 x32)
643 cpu="x86_64"
644 CPU_CFLAGS="-mx32" ;;
645 x86_64|amd64)
646 cpu="x86_64"
647 # ??? Only extremely old AMD cpus do not have cmpxchg16b.
648 # If we truly care, we should simply detect this case at
649 # runtime and generate the fallback to serial emulation.
650 CPU_CFLAGS="-m64 -mcx16" ;;
652 mips*)
653 cpu="mips" ;;
655 ppc)
656 CPU_CFLAGS="-m32" ;;
657 ppc64)
658 CPU_CFLAGS="-m64 -mbig" ;;
659 ppc64le)
660 cpu="ppc64"
661 CPU_CFLAGS="-m64 -mlittle" ;;
663 s390)
664 CPU_CFLAGS="-m31" ;;
665 s390x)
666 CPU_CFLAGS="-m64" ;;
668 sparc|sun4[cdmuv])
669 cpu="sparc"
670 CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc" ;;
671 sparc64)
672 CPU_CFLAGS="-m64 -mcpu=ultrasparc" ;;
673 esac
675 : ${make=${MAKE-make}}
677 # We prefer python 3.x. A bare 'python' is traditionally
678 # python 2.x, but some distros have it as python 3.x, so
679 # we check that too
680 python=
681 explicit_python=no
682 for binary in "${PYTHON-python3}" python
684 if has "$binary"
685 then
686 python=$(command -v "$binary")
687 break
689 done
692 # Check for ancillary tools used in testing
693 genisoimage=
694 for binary in genisoimage mkisofs
696 if has $binary
697 then
698 genisoimage=$(command -v "$binary")
699 break
701 done
703 # Default objcc to clang if available, otherwise use CC
704 if has clang; then
705 objcc=clang
706 else
707 objcc="$cc"
710 if test "$mingw32" = "yes" ; then
711 EXESUF=".exe"
712 # MinGW needs -mthreads for TLS and macro _MT.
713 CONFIGURE_CFLAGS="-mthreads $CONFIGURE_CFLAGS"
714 write_c_skeleton;
715 prefix="/qemu"
716 qemu_suffix=""
717 libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
720 werror=""
722 . $source_path/scripts/meson-buildoptions.sh
724 meson_options=
725 meson_option_parse() {
726 meson_options="$meson_options $(_meson_option_parse "$@")"
727 if test $? -eq 1; then
728 echo "ERROR: unknown option $1"
729 echo "Try '$0 --help' for more information"
730 exit 1
734 for opt do
735 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
736 case "$opt" in
737 --help|-h) show_help=yes
739 --version|-V) exec cat $source_path/VERSION
741 --prefix=*) prefix="$optarg"
743 --interp-prefix=*) interp_prefix="$optarg"
745 --cross-prefix=*)
747 --cc=*)
749 --host-cc=*) host_cc="$optarg"
751 --cxx=*)
753 --iasl=*) iasl="$optarg"
755 --objcc=*) objcc="$optarg"
757 --make=*) make="$optarg"
759 --install=*)
761 --python=*) python="$optarg" ; explicit_python=yes
763 --sphinx-build=*) sphinx_build="$optarg"
765 --skip-meson) skip_meson=yes
767 --meson=*) meson="$optarg"
769 --ninja=*) ninja="$optarg"
771 --smbd=*) smbd="$optarg"
773 --extra-cflags=*)
775 --extra-cxxflags=*)
777 --extra-ldflags=*)
779 --enable-debug-info)
781 --disable-debug-info)
783 --cross-cc-*)
785 --enable-modules)
786 modules="yes"
788 --disable-modules)
789 modules="no"
791 --disable-module-upgrades) module_upgrades="no"
793 --enable-module-upgrades) module_upgrades="yes"
795 --cpu=*)
797 --target-list=*) target_list="$optarg"
798 if test "$target_list_exclude"; then
799 error_exit "Can't mix --target-list with --target-list-exclude"
802 --target-list-exclude=*) target_list_exclude="$optarg"
803 if test "$target_list"; then
804 error_exit "Can't mix --target-list-exclude with --target-list"
807 --with-trace-file=*) trace_file="$optarg"
809 --with-default-devices) default_devices="true"
811 --without-default-devices) default_devices="false"
813 --with-devices-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --with-devices-FOO option"
815 --with-devices-*) device_arch=${opt#--with-devices-};
816 device_arch=${device_arch%%=*}
817 cf=$source_path/configs/devices/$device_arch-softmmu/$optarg.mak
818 if test -f "$cf"; then
819 device_archs="$device_archs $device_arch"
820 eval "devices_${device_arch}=\$optarg"
821 else
822 error_exit "File $cf does not exist"
825 --without-default-features) # processed above
827 --enable-gprof) gprof="yes"
829 --enable-gcov) gcov="yes"
831 --static)
832 static="yes"
833 QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
835 --mandir=*) mandir="$optarg"
837 --bindir=*) bindir="$optarg"
839 --libdir=*) libdir="$optarg"
841 --libexecdir=*) libexecdir="$optarg"
843 --includedir=*) includedir="$optarg"
845 --datadir=*) datadir="$optarg"
847 --with-suffix=*) qemu_suffix="$optarg"
849 --docdir=*) docdir="$optarg"
851 --localedir=*) localedir="$optarg"
853 --sysconfdir=*) sysconfdir="$optarg"
855 --localstatedir=*) local_statedir="$optarg"
857 --firmwarepath=*) firmwarepath="$optarg"
859 --host=*|--build=*|\
860 --disable-dependency-tracking|\
861 --sbindir=*|--sharedstatedir=*|\
862 --oldincludedir=*|--datarootdir=*|--infodir=*|\
863 --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
864 # These switches are silently ignored, for compatibility with
865 # autoconf-generated configure scripts. This allows QEMU's
866 # configure to be used by RPM and similar macros that set
867 # lots of directory switches by default.
869 --disable-qom-cast-debug) qom_cast_debug="no"
871 --enable-qom-cast-debug) qom_cast_debug="yes"
873 --audio-drv-list=*) audio_drv_list="$optarg"
875 --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
877 --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
879 --enable-block-drv-whitelist-in-tools) block_drv_whitelist_tools="yes"
881 --disable-block-drv-whitelist-in-tools) block_drv_whitelist_tools="no"
883 --enable-debug-tcg) debug_tcg="yes"
885 --disable-debug-tcg) debug_tcg="no"
887 --enable-debug)
888 # Enable debugging options that aren't excessively noisy
889 debug_tcg="yes"
890 debug_mutex="yes"
891 debug="yes"
892 fortify_source="no"
894 --enable-sanitizers) sanitizers="yes"
896 --disable-sanitizers) sanitizers="no"
898 --enable-tsan) tsan="yes"
900 --disable-tsan) tsan="no"
902 --disable-slirp) slirp="disabled"
904 --enable-slirp) slirp="enabled"
906 --enable-slirp=git) slirp="internal"
908 --enable-slirp=*) slirp="$optarg"
910 --disable-xen) xen="disabled"
912 --enable-xen) xen="enabled"
914 --disable-tcg) tcg="disabled"
915 plugins="no"
917 --enable-tcg) tcg="enabled"
919 --enable-profiler) profiler="yes"
921 --disable-system) softmmu="no"
923 --enable-system) softmmu="yes"
925 --disable-user)
926 linux_user="no" ;
927 bsd_user="no" ;
929 --enable-user) ;;
930 --disable-linux-user) linux_user="no"
932 --enable-linux-user) linux_user="yes"
934 --disable-bsd-user) bsd_user="no"
936 --enable-bsd-user) bsd_user="yes"
938 --enable-pie) pie="yes"
940 --disable-pie) pie="no"
942 --enable-werror) werror="yes"
944 --disable-werror) werror="no"
946 --enable-lto) lto="true"
948 --disable-lto) lto="false"
950 --enable-stack-protector) stack_protector="yes"
952 --disable-stack-protector) stack_protector="no"
954 --enable-safe-stack) safe_stack="yes"
956 --disable-safe-stack) safe_stack="no"
958 --enable-cfi)
959 cfi="true";
960 lto="true";
962 --disable-cfi) cfi="false"
964 --disable-fdt) fdt="disabled"
966 --enable-fdt) fdt="enabled"
968 --enable-fdt=git) fdt="internal"
970 --enable-fdt=*) fdt="$optarg"
972 --disable-membarrier) membarrier="no"
974 --enable-membarrier) membarrier="yes"
976 --with-pkgversion=*) pkgversion="$optarg"
978 --with-coroutine=*) coroutine="$optarg"
980 --disable-coroutine-pool) coroutine_pool="no"
982 --enable-coroutine-pool) coroutine_pool="yes"
984 --enable-debug-stack-usage) debug_stack_usage="yes"
986 --enable-crypto-afalg) crypto_afalg="yes"
988 --disable-crypto-afalg) crypto_afalg="no"
990 --disable-vhost-net) vhost_net="no"
992 --enable-vhost-net) vhost_net="yes"
994 --disable-vhost-crypto) vhost_crypto="no"
996 --enable-vhost-crypto) vhost_crypto="yes"
998 --disable-vhost-scsi) vhost_scsi="no"
1000 --enable-vhost-scsi) vhost_scsi="yes"
1002 --disable-vhost-vsock) vhost_vsock="no"
1004 --enable-vhost-vsock) vhost_vsock="yes"
1006 --disable-vhost-user-fs) vhost_user_fs="no"
1008 --enable-vhost-user-fs) vhost_user_fs="yes"
1010 --disable-opengl) opengl="no"
1012 --enable-opengl) opengl="yes"
1014 --disable-zlib-test)
1016 --enable-guest-agent) guest_agent="yes"
1018 --disable-guest-agent) guest_agent="no"
1020 --with-vss-sdk) vss_win32_sdk=""
1022 --with-vss-sdk=*) vss_win32_sdk="$optarg"
1024 --without-vss-sdk) vss_win32_sdk="no"
1026 --with-win-sdk) win_sdk=""
1028 --with-win-sdk=*) win_sdk="$optarg"
1030 --without-win-sdk) win_sdk="no"
1032 --enable-tools) want_tools="yes"
1034 --disable-tools) want_tools="no"
1036 --disable-avx2) avx2_opt="no"
1038 --enable-avx2) avx2_opt="yes"
1040 --disable-avx512f) avx512f_opt="no"
1042 --enable-avx512f) avx512f_opt="yes"
1044 --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
1045 echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1047 --enable-vhdx|--disable-vhdx)
1048 echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1050 --enable-uuid|--disable-uuid)
1051 echo "$0: $opt is obsolete, UUID support is always built" >&2
1053 --tls-priority=*) tls_priority="$optarg"
1055 --enable-rdma) rdma="yes"
1057 --disable-rdma) rdma="no"
1059 --enable-pvrdma) pvrdma="yes"
1061 --disable-pvrdma) pvrdma="no"
1063 --disable-tpm) tpm="no"
1065 --enable-tpm) tpm="yes"
1067 --disable-live-block-migration) live_block_migration="no"
1069 --enable-live-block-migration) live_block_migration="yes"
1071 --disable-numa) numa="no"
1073 --enable-numa) numa="yes"
1075 --disable-replication) replication="no"
1077 --enable-replication) replication="yes"
1079 --disable-bochs) bochs="no"
1081 --enable-bochs) bochs="yes"
1083 --disable-cloop) cloop="no"
1085 --enable-cloop) cloop="yes"
1087 --disable-dmg) dmg="no"
1089 --enable-dmg) dmg="yes"
1091 --disable-qcow1) qcow1="no"
1093 --enable-qcow1) qcow1="yes"
1095 --disable-vdi) vdi="no"
1097 --enable-vdi) vdi="yes"
1099 --disable-vvfat) vvfat="no"
1101 --enable-vvfat) vvfat="yes"
1103 --disable-qed) qed="no"
1105 --enable-qed) qed="yes"
1107 --disable-parallels) parallels="no"
1109 --enable-parallels) parallels="yes"
1111 --disable-vhost-user) vhost_user="no"
1113 --enable-vhost-user) vhost_user="yes"
1115 --disable-vhost-vdpa) vhost_vdpa="no"
1117 --enable-vhost-vdpa) vhost_vdpa="yes"
1119 --disable-vhost-kernel) vhost_kernel="no"
1121 --enable-vhost-kernel) vhost_kernel="yes"
1123 --disable-capstone) capstone="disabled"
1125 --enable-capstone) capstone="enabled"
1127 --enable-capstone=git) capstone="internal"
1129 --enable-capstone=*) capstone="$optarg"
1131 --with-git=*) git="$optarg"
1133 --with-git-submodules=*)
1134 git_submodules_action="$optarg"
1136 --enable-debug-mutex) debug_mutex=yes
1138 --disable-debug-mutex) debug_mutex=no
1140 --enable-plugins) if test "$mingw32" = "yes"; then
1141 error_exit "TCG plugins not currently supported on Windows platforms"
1142 else
1143 plugins="yes"
1146 --disable-plugins) plugins="no"
1148 --enable-containers) use_containers="yes"
1150 --disable-containers) use_containers="no"
1152 --gdb=*) gdb_bin="$optarg"
1154 --enable-rng-none) rng_none=yes
1156 --disable-rng-none) rng_none=no
1158 --enable-keyring) secret_keyring="yes"
1160 --disable-keyring) secret_keyring="no"
1162 --enable-gio) gio=yes
1164 --disable-gio) gio=no
1166 --enable-slirp-smbd) slirp_smbd=yes
1168 --disable-slirp-smbd) slirp_smbd=no
1170 # backwards compatibility options
1171 --enable-trace-backend=*) meson_option_parse "--enable-trace-backends=$optarg" "$optarg"
1173 --disable-blobs) meson_option_parse --disable-install-blobs ""
1175 --enable-tcmalloc) meson_option_parse --enable-malloc=tcmalloc tcmalloc
1177 --enable-jemalloc) meson_option_parse --enable-malloc=jemalloc jemalloc
1179 # everything else has the same name in configure and meson
1180 --enable-* | --disable-*) meson_option_parse "$opt" "$optarg"
1183 echo "ERROR: unknown option $opt"
1184 echo "Try '$0 --help' for more information"
1185 exit 1
1187 esac
1188 done
1190 # test for any invalid configuration combinations
1191 if test "$plugins" = "yes" -a "$tcg" = "disabled"; then
1192 error_exit "Can't enable plugins on non-TCG builds"
1195 case $git_submodules_action in
1196 update|validate)
1197 if test ! -e "$source_path/.git"; then
1198 echo "ERROR: cannot $git_submodules_action git submodules without .git"
1199 exit 1
1202 ignore)
1203 if ! test -f "$source_path/ui/keycodemapdb/README"
1204 then
1205 echo
1206 echo "ERROR: missing GIT submodules"
1207 echo
1208 if test -e "$source_path/.git"; then
1209 echo "--with-git-submodules=ignore specified but submodules were not"
1210 echo "checked out. Please initialize and update submodules."
1211 else
1212 echo "This is not a GIT checkout but module content appears to"
1213 echo "be missing. Do not use 'git archive' or GitHub download links"
1214 echo "to acquire QEMU source archives. Non-GIT builds are only"
1215 echo "supported with source archives linked from:"
1216 echo
1217 echo " https://www.qemu.org/download/#source"
1218 echo
1219 echo "Developers working with GIT can use scripts/archive-source.sh"
1220 echo "if they need to create valid source archives."
1222 echo
1223 exit 1
1227 echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'"
1228 exit 1
1230 esac
1232 libdir="${libdir:-$prefix/lib}"
1233 libexecdir="${libexecdir:-$prefix/libexec}"
1234 includedir="${includedir:-$prefix/include}"
1236 if test "$mingw32" = "yes" ; then
1237 bindir="${bindir:-$prefix}"
1238 else
1239 bindir="${bindir:-$prefix/bin}"
1241 mandir="${mandir:-$prefix/share/man}"
1242 datadir="${datadir:-$prefix/share}"
1243 docdir="${docdir:-$prefix/share/doc}"
1244 sysconfdir="${sysconfdir:-$prefix/etc}"
1245 local_statedir="${local_statedir:-$prefix/var}"
1246 firmwarepath="${firmwarepath:-$datadir/qemu-firmware}"
1247 localedir="${localedir:-$datadir/locale}"
1249 if eval test -z "\${cross_cc_$cpu}"; then
1250 eval "cross_cc_${cpu}=\$cc"
1251 cross_cc_vars="$cross_cc_vars cross_cc_${cpu}"
1254 default_target_list=""
1255 deprecated_targets_list=ppc64abi32-linux-user
1256 deprecated_features=""
1257 mak_wilds=""
1259 if [ "$linux_user" != no ]; then
1260 if [ "$targetos" = linux ] && [ -d $source_path/linux-user/include/host/$cpu ]; then
1261 linux_user=yes
1262 elif [ "$linux_user" = yes ]; then
1263 error_exit "linux-user not supported on this architecture"
1266 if [ "$bsd_user" != no ]; then
1267 if [ "$bsd_user" = "" ]; then
1268 test $targetos = freebsd && bsd_user=yes
1270 if [ "$bsd_user" = yes ] && ! [ -d $source_path/bsd-user/$targetos ]; then
1271 error_exit "bsd-user not supported on this host OS"
1274 if [ "$softmmu" = "yes" ]; then
1275 mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak"
1277 if [ "$linux_user" = "yes" ]; then
1278 mak_wilds="${mak_wilds} $source_path/configs/targets/*-linux-user.mak"
1280 if [ "$bsd_user" = "yes" ]; then
1281 mak_wilds="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak"
1284 # If the user doesn't explicitly specify a deprecated target we will
1285 # skip it.
1286 if test -z "$target_list"; then
1287 if test -z "$target_list_exclude"; then
1288 target_list_exclude="$deprecated_targets_list"
1289 else
1290 target_list_exclude="$target_list_exclude,$deprecated_targets_list"
1294 for config in $mak_wilds; do
1295 target="$(basename "$config" .mak)"
1296 if echo "$target_list_exclude" | grep -vq "$target"; then
1297 default_target_list="${default_target_list} $target"
1299 done
1301 if test x"$show_help" = x"yes" ; then
1302 cat << EOF
1304 Usage: configure [options]
1305 Options: [defaults in brackets after descriptions]
1307 Standard options:
1308 --help print this message
1309 --prefix=PREFIX install in PREFIX [$prefix]
1310 --interp-prefix=PREFIX where to find shared libraries, etc.
1311 use %M for cpu name [$interp_prefix]
1312 --target-list=LIST set target list (default: build all non-deprecated)
1313 $(echo Available targets: $default_target_list | \
1314 fold -s -w 53 | sed -e 's/^/ /')
1315 $(echo Deprecated targets: $deprecated_targets_list | \
1316 fold -s -w 53 | sed -e 's/^/ /')
1317 --target-list-exclude=LIST exclude a set of targets from the default target-list
1319 Advanced options (experts only):
1320 --cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix]
1321 --cc=CC use C compiler CC [$cc]
1322 --iasl=IASL use ACPI compiler IASL [$iasl]
1323 --host-cc=CC use C compiler CC [$host_cc] for code run at
1324 build time
1325 --cxx=CXX use C++ compiler CXX [$cxx]
1326 --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
1327 --extra-cflags=CFLAGS append extra C compiler flags CFLAGS
1328 --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS
1329 --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS
1330 --cross-cc-ARCH=CC use compiler when building ARCH guest test cases
1331 --cross-cc-cflags-ARCH= use compiler flags when building ARCH guest tests
1332 --make=MAKE use specified make [$make]
1333 --python=PYTHON use specified python [$python]
1334 --sphinx-build=SPHINX use specified sphinx-build [$sphinx_build]
1335 --meson=MESON use specified meson [$meson]
1336 --ninja=NINJA use specified ninja [$ninja]
1337 --smbd=SMBD use specified smbd [$smbd]
1338 --with-git=GIT use specified git [$git]
1339 --with-git-submodules=update update git submodules (default if .git dir exists)
1340 --with-git-submodules=validate fail if git submodules are not up to date
1341 --with-git-submodules=ignore do not update or check git submodules (default if no .git dir)
1342 --static enable static build [$static]
1343 --mandir=PATH install man pages in PATH
1344 --datadir=PATH install firmware in PATH/$qemu_suffix
1345 --localedir=PATH install translation in PATH/$qemu_suffix
1346 --docdir=PATH install documentation in PATH/$qemu_suffix
1347 --bindir=PATH install binaries in PATH
1348 --libdir=PATH install libraries in PATH
1349 --libexecdir=PATH install helper binaries in PATH
1350 --sysconfdir=PATH install config in PATH/$qemu_suffix
1351 --localstatedir=PATH install local state in PATH (set at runtime on win32)
1352 --firmwarepath=PATH search PATH for firmware files
1353 --efi-aarch64=PATH PATH of efi file to use for aarch64 VMs.
1354 --with-suffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix]
1355 --with-pkgversion=VERS use specified string as sub-version of the package
1356 --without-default-features default all --enable-* options to "disabled"
1357 --without-default-devices do not include any device that is not needed to
1358 start the emulator (only use if you are including
1359 desired devices in configs/devices/)
1360 --with-devices-ARCH=NAME override default configs/devices
1361 --enable-debug enable common debug build options
1362 --enable-sanitizers enable default sanitizers
1363 --enable-tsan enable thread sanitizer
1364 --disable-werror disable compilation abort on warning
1365 --disable-stack-protector disable compiler-provided stack protection
1366 --audio-drv-list=LIST set audio drivers to try if -audiodev is not used
1367 --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L
1368 --block-drv-rw-whitelist=L
1369 set block driver read-write whitelist
1370 (by default affects only QEMU, not tools like qemu-img)
1371 --block-drv-ro-whitelist=L
1372 set block driver read-only whitelist
1373 (by default affects only QEMU, not tools like qemu-img)
1374 --enable-block-drv-whitelist-in-tools
1375 use block whitelist also in tools instead of only QEMU
1376 --with-trace-file=NAME Full PATH,NAME of file to store traces
1377 Default:trace-<pid>
1378 --cpu=CPU Build for host CPU [$cpu]
1379 --with-coroutine=BACKEND coroutine backend. Supported options:
1380 ucontext, sigaltstack, windows
1381 --enable-gcov enable test coverage analysis with gcov
1382 --with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent
1383 --with-win-sdk=SDK-path path to Windows Platform SDK (to build VSS .tlb)
1384 --tls-priority default TLS protocol/cipher priority string
1385 --enable-gprof QEMU profiling with gprof
1386 --enable-profiler profiler support
1387 --enable-debug-stack-usage
1388 track the maximum stack usage of stacks created by qemu_alloc_stack
1389 --enable-plugins
1390 enable plugins via shared library loading
1391 --disable-containers don't use containers for cross-building
1392 --gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin]
1394 meson_options_help
1395 cat << EOF
1396 system all system emulation targets
1397 user supported user emulation targets
1398 linux-user all linux usermode emulation targets
1399 bsd-user all BSD usermode emulation targets
1400 guest-agent build the QEMU Guest Agent
1401 pie Position Independent Executables
1402 modules modules support (non-Windows)
1403 module-upgrades try to load modules from alternate paths for upgrades
1404 debug-tcg TCG debugging (default is disabled)
1405 debug-info debugging information
1406 lto Enable Link-Time Optimization.
1407 safe-stack SafeStack Stack Smash Protection. Depends on
1408 clang/llvm >= 3.7 and requires coroutine backend ucontext.
1409 membarrier membarrier system call (for Linux 4.14+ or Windows)
1410 rdma Enable RDMA-based migration
1411 pvrdma Enable PVRDMA support
1412 vhost-net vhost-net kernel acceleration support
1413 vhost-vsock virtio sockets device support
1414 vhost-scsi vhost-scsi kernel target support
1415 vhost-crypto vhost-user-crypto backend support
1416 vhost-kernel vhost kernel backend support
1417 vhost-user vhost-user backend support
1418 vhost-vdpa vhost-vdpa kernel backend support
1419 live-block-migration Block migration in the main migration stream
1420 coroutine-pool coroutine freelist (better performance)
1421 tpm TPM support
1422 numa libnuma support
1423 avx2 AVX2 optimization support
1424 avx512f AVX512F optimization support
1425 replication replication support
1426 opengl opengl support
1427 qom-cast-debug cast debugging support
1428 tools build qemu-io, qemu-nbd and qemu-img tools
1429 bochs bochs image format support
1430 cloop cloop image format support
1431 dmg dmg image format support
1432 qcow1 qcow v1 image format support
1433 vdi vdi image format support
1434 vvfat vvfat image format support
1435 qed qed image format support
1436 parallels parallels image format support
1437 crypto-afalg Linux AF_ALG crypto backend driver
1438 debug-mutex mutex debugging support
1439 rng-none dummy RNG, avoid using /dev/(u)random and getrandom()
1440 gio libgio support
1441 slirp-smbd use smbd (at path --smbd=*) in slirp networking
1443 NOTE: The object files are built at the place where configure is launched
1445 exit 0
1448 # Remove old dependency files to make sure that they get properly regenerated
1449 rm -f */config-devices.mak.d
1451 if test -z "$python"
1452 then
1453 error_exit "Python not found. Use --python=/path/to/python"
1455 if ! has "$make"
1456 then
1457 error_exit "GNU make ($make) not found"
1460 # Note that if the Python conditional here evaluates True we will exit
1461 # with status 1 which is a shell 'false' value.
1462 if ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then
1463 error_exit "Cannot use '$python', Python >= 3.6 is required." \
1464 "Use --python=/path/to/python to specify a supported Python."
1467 # Preserve python version since some functionality is dependent on it
1468 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)
1470 # Suppress writing compiled files
1471 python="$python -B"
1473 if test -z "$meson"; then
1474 if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.59.3; then
1475 meson=meson
1476 elif test $git_submodules_action != 'ignore' ; then
1477 meson=git
1478 elif test -e "${source_path}/meson/meson.py" ; then
1479 meson=internal
1480 else
1481 if test "$explicit_python" = yes; then
1482 error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found."
1483 else
1484 error_exit "Meson not found. Use --meson=/path/to/meson"
1487 else
1488 # Meson uses its own Python interpreter to invoke other Python scripts,
1489 # but the user wants to use the one they specified with --python.
1491 # We do not want to override the distro Python interpreter (and sometimes
1492 # cannot: for example in Homebrew /usr/bin/meson is a bash script), so
1493 # just require --meson=git|internal together with --python.
1494 if test "$explicit_python" = yes; then
1495 case "$meson" in
1496 git | internal) ;;
1497 *) error_exit "--python requires using QEMU's embedded Meson distribution." ;;
1498 esac
1502 if test "$meson" = git; then
1503 git_submodules="${git_submodules} meson"
1506 case "$meson" in
1507 git | internal)
1508 meson="$python ${source_path}/meson/meson.py"
1510 *) meson=$(command -v "$meson") ;;
1511 esac
1513 # Probe for ninja
1515 if test -z "$ninja"; then
1516 for c in ninja ninja-build samu; do
1517 if has $c; then
1518 ninja=$(command -v "$c")
1519 break
1521 done
1522 if test -z "$ninja"; then
1523 error_exit "Cannot find Ninja"
1527 # Check that the C compiler works. Doing this here before testing
1528 # the host CPU ensures that we had a valid CC to autodetect the
1529 # $cpu var (and we should bail right here if that's not the case).
1530 # It also allows the help message to be printed without a CC.
1531 write_c_skeleton;
1532 if compile_object ; then
1533 : C compiler works ok
1534 else
1535 error_exit "\"$cc\" either does not exist or does not work"
1537 if ! compile_prog ; then
1538 error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
1541 # Consult white-list to determine whether to enable werror
1542 # by default. Only enable by default for git builds
1543 if test -z "$werror" ; then
1544 if test "$git_submodules_action" != "ignore" && \
1545 { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
1546 werror="yes"
1547 else
1548 werror="no"
1552 if test "$targetos" = "bogus"; then
1553 # Now that we know that we're not printing the help and that
1554 # the compiler works (so the results of the check_defines we used
1555 # to identify the OS are reliable), if we didn't recognize the
1556 # host OS we should stop now.
1557 error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
1560 # Check whether the compiler matches our minimum requirements:
1561 cat > $TMPC << EOF
1562 #if defined(__clang_major__) && defined(__clang_minor__)
1563 # ifdef __apple_build_version__
1564 # if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0)
1565 # error You need at least XCode Clang v10.0 to compile QEMU
1566 # endif
1567 # else
1568 # if __clang_major__ < 6 || (__clang_major__ == 6 && __clang_minor__ < 0)
1569 # error You need at least Clang v6.0 to compile QEMU
1570 # endif
1571 # endif
1572 #elif defined(__GNUC__) && defined(__GNUC_MINOR__)
1573 # if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4)
1574 # error You need at least GCC v7.4.0 to compile QEMU
1575 # endif
1576 #else
1577 # error You either need GCC or Clang to compiler QEMU
1578 #endif
1579 int main (void) { return 0; }
1581 if ! compile_prog "" "" ; then
1582 error_exit "You need at least GCC v7.4 or Clang v6.0 (or XCode Clang v10.0)"
1585 # Accumulate -Wfoo and -Wno-bar separately.
1586 # We will list all of the enable flags first, and the disable flags second.
1587 # Note that we do not add -Werror, because that would enable it for all
1588 # configure tests. If a configure test failed due to -Werror this would
1589 # just silently disable some features, so it's too error prone.
1591 warn_flags=
1592 add_to warn_flags -Wold-style-declaration
1593 add_to warn_flags -Wold-style-definition
1594 add_to warn_flags -Wtype-limits
1595 add_to warn_flags -Wformat-security
1596 add_to warn_flags -Wformat-y2k
1597 add_to warn_flags -Winit-self
1598 add_to warn_flags -Wignored-qualifiers
1599 add_to warn_flags -Wempty-body
1600 add_to warn_flags -Wnested-externs
1601 add_to warn_flags -Wendif-labels
1602 add_to warn_flags -Wexpansion-to-defined
1603 add_to warn_flags -Wimplicit-fallthrough=2
1605 nowarn_flags=
1606 add_to nowarn_flags -Wno-initializer-overrides
1607 add_to nowarn_flags -Wno-missing-include-dirs
1608 add_to nowarn_flags -Wno-shift-negative-value
1609 add_to nowarn_flags -Wno-string-plus-int
1610 add_to nowarn_flags -Wno-typedef-redefinition
1611 add_to nowarn_flags -Wno-tautological-type-limit-compare
1612 add_to nowarn_flags -Wno-psabi
1614 gcc_flags="$warn_flags $nowarn_flags"
1616 cc_has_warning_flag() {
1617 write_c_skeleton;
1619 # Use the positive sense of the flag when testing for -Wno-wombat
1620 # support (gcc will happily accept the -Wno- form of unknown
1621 # warning options).
1622 optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
1623 compile_prog "-Werror $optflag" ""
1626 for flag in $gcc_flags; do
1627 if cc_has_warning_flag $flag ; then
1628 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1630 done
1632 if test "$stack_protector" != "no"; then
1633 cat > $TMPC << EOF
1634 int main(int argc, char *argv[])
1636 char arr[64], *p = arr, *c = argv[0];
1637 while (*c) {
1638 *p++ = *c++;
1640 return 0;
1643 gcc_flags="-fstack-protector-strong -fstack-protector-all"
1644 sp_on=0
1645 for flag in $gcc_flags; do
1646 # We need to check both a compile and a link, since some compiler
1647 # setups fail only on a .c->.o compile and some only at link time
1648 if compile_object "-Werror $flag" &&
1649 compile_prog "-Werror $flag" ""; then
1650 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1651 QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
1652 sp_on=1
1653 break
1655 done
1656 if test "$stack_protector" = yes; then
1657 if test $sp_on = 0; then
1658 error_exit "Stack protector not supported"
1663 # Disable -Wmissing-braces on older compilers that warn even for
1664 # the "universal" C zero initializer {0}.
1665 cat > $TMPC << EOF
1666 struct {
1667 int a[2];
1668 } x = {0};
1670 if compile_object "-Werror" "" ; then
1672 else
1673 QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
1676 # Our module code doesn't support Windows
1677 if test "$modules" = "yes" && test "$mingw32" = "yes" ; then
1678 error_exit "Modules are not available for Windows"
1681 # module_upgrades is only reasonable if modules are enabled
1682 if test "$modules" = "no" && test "$module_upgrades" = "yes" ; then
1683 error_exit "Can't enable module-upgrades as Modules are not enabled"
1686 # Static linking is not possible with plugins, modules or PIE
1687 if test "$static" = "yes" ; then
1688 if test "$modules" = "yes" ; then
1689 error_exit "static and modules are mutually incompatible"
1691 if test "$plugins" = "yes"; then
1692 error_exit "static and plugins are mutually incompatible"
1693 else
1694 plugins="no"
1697 test "$plugins" = "" && plugins=yes
1699 cat > $TMPC << EOF
1701 #ifdef __linux__
1702 # define THREAD __thread
1703 #else
1704 # define THREAD
1705 #endif
1706 static THREAD int tls_var;
1707 int main(void) { return tls_var; }
1710 # Check we support -fno-pie and -no-pie first; we will need the former for
1711 # building ROMs, and both for everything if --disable-pie is passed.
1712 if compile_prog "-Werror -fno-pie" "-no-pie"; then
1713 CFLAGS_NOPIE="-fno-pie"
1714 LDFLAGS_NOPIE="-no-pie"
1717 if test "$static" = "yes"; then
1718 if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then
1719 CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
1720 QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS"
1721 pie="yes"
1722 elif test "$pie" = "yes"; then
1723 error_exit "-static-pie not available due to missing toolchain support"
1724 else
1725 QEMU_LDFLAGS="-static $QEMU_LDFLAGS"
1726 pie="no"
1728 elif test "$pie" = "no"; then
1729 CONFIGURE_CFLAGS="$CFLAGS_NOPIE $CONFIGURE_CFLAGS"
1730 CONFIGURE_LDFLAGS="$LDFLAGS_NOPIE $CONFIGURE_LDFLAGS"
1731 elif compile_prog "-Werror -fPIE -DPIE" "-pie"; then
1732 CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
1733 CONFIGURE_LDFLAGS="-pie $CONFIGURE_LDFLAGS"
1734 pie="yes"
1735 elif test "$pie" = "yes"; then
1736 error_exit "PIE not available due to missing toolchain support"
1737 else
1738 echo "Disabling PIE due to missing toolchain support"
1739 pie="no"
1742 # Detect support for PT_GNU_RELRO + DT_BIND_NOW.
1743 # The combination is known as "full relro", because .got.plt is read-only too.
1744 if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
1745 QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS"
1748 ##########################################
1749 # __sync_fetch_and_and requires at least -march=i486. Many toolchains
1750 # use i686 as default anyway, but for those that don't, an explicit
1751 # specification is necessary
1753 if test "$cpu" = "i386"; then
1754 cat > $TMPC << EOF
1755 static int sfaa(int *ptr)
1757 return __sync_fetch_and_and(ptr, 0);
1760 int main(void)
1762 int val = 42;
1763 val = __sync_val_compare_and_swap(&val, 0, 1);
1764 sfaa(&val);
1765 return val;
1768 if ! compile_prog "" "" ; then
1769 QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
1773 if test "$tcg" = "enabled"; then
1774 git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
1775 git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
1778 if test -z "${target_list+xxx}" ; then
1779 default_targets=yes
1780 for target in $default_target_list; do
1781 target_list="$target_list $target"
1782 done
1783 target_list="${target_list# }"
1784 else
1785 default_targets=no
1786 target_list=$(echo "$target_list" | sed -e 's/,/ /g')
1787 for target in $target_list; do
1788 # Check that we recognised the target name; this allows a more
1789 # friendly error message than if we let it fall through.
1790 case " $default_target_list " in
1791 *" $target "*)
1794 error_exit "Unknown target name '$target'"
1796 esac
1797 done
1800 for target in $target_list; do
1801 # if a deprecated target is enabled we note it here
1802 if echo "$deprecated_targets_list" | grep -q "$target"; then
1803 add_to deprecated_features $target
1805 done
1807 # see if system emulation was really requested
1808 case " $target_list " in
1809 *"-softmmu "*) softmmu=yes
1811 *) softmmu=no
1813 esac
1815 feature_not_found() {
1816 feature=$1
1817 remedy=$2
1819 error_exit "User requested feature $feature" \
1820 "configure was not able to find it." \
1821 "$remedy"
1824 # ---
1825 # big/little endian test
1826 cat > $TMPC << EOF
1827 #include <stdio.h>
1828 short big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
1829 short little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
1830 int main(int argc, char *argv[])
1832 return printf("%s %s\n", (char *)big_endian, (char *)little_endian);
1836 if compile_prog ; then
1837 if strings -a $TMPE | grep -q BiGeNdIaN ; then
1838 bigendian="yes"
1839 elif strings -a $TMPE | grep -q LiTtLeEnDiAn ; then
1840 bigendian="no"
1841 else
1842 echo big/little test failed
1843 exit 1
1845 else
1846 echo big/little test failed
1847 exit 1
1850 ##########################################
1851 # system tools
1852 if test -z "$want_tools"; then
1853 if test "$softmmu" = "no"; then
1854 want_tools=no
1855 else
1856 want_tools=yes
1860 #########################################
1861 # vhost interdependencies and host support
1863 # vhost backends
1864 if test "$vhost_user" = "yes" && test "$linux" != "yes"; then
1865 error_exit "vhost-user is only available on Linux"
1867 test "$vhost_vdpa" = "" && vhost_vdpa=$linux
1868 if test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then
1869 error_exit "vhost-vdpa is only available on Linux"
1871 test "$vhost_kernel" = "" && vhost_kernel=$linux
1872 if test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then
1873 error_exit "vhost-kernel is only available on Linux"
1876 # vhost-kernel devices
1877 test "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel
1878 if test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then
1879 error_exit "--enable-vhost-scsi requires --enable-vhost-kernel"
1881 test "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel
1882 if test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then
1883 error_exit "--enable-vhost-vsock requires --enable-vhost-kernel"
1886 # vhost-user backends
1887 test "$vhost_net_user" = "" && vhost_net_user=$vhost_user
1888 if test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then
1889 error_exit "--enable-vhost-net-user requires --enable-vhost-user"
1891 test "$vhost_crypto" = "" && vhost_crypto=$vhost_user
1892 if test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then
1893 error_exit "--enable-vhost-crypto requires --enable-vhost-user"
1895 test "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user
1896 if test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then
1897 error_exit "--enable-vhost-user-fs requires --enable-vhost-user"
1899 #vhost-vdpa backends
1900 test "$vhost_net_vdpa" = "" && vhost_net_vdpa=$vhost_vdpa
1901 if test "$vhost_net_vdpa" = "yes" && test "$vhost_vdpa" = "no"; then
1902 error_exit "--enable-vhost-net-vdpa requires --enable-vhost-vdpa"
1905 # OR the vhost-kernel, vhost-vdpa and vhost-user values for simplicity
1906 if test "$vhost_net" = ""; then
1907 test "$vhost_net_user" = "yes" && vhost_net=yes
1908 test "$vhost_net_vdpa" = "yes" && vhost_net=yes
1909 test "$vhost_kernel" = "yes" && vhost_net=yes
1912 ##########################################
1913 # pkg-config probe
1915 if ! has "$pkg_config_exe"; then
1916 error_exit "pkg-config binary '$pkg_config_exe' not found"
1919 ##########################################
1920 # xen probe
1922 if test "$xen" != "disabled" ; then
1923 # Check whether Xen library path is specified via --extra-ldflags to avoid
1924 # overriding this setting with pkg-config output. If not, try pkg-config
1925 # to obtain all needed flags.
1927 if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
1928 $pkg_config --exists xencontrol ; then
1929 xen_ctrl_version="$(printf '%d%02d%02d' \
1930 $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
1931 xen=enabled
1932 xen_pc="xencontrol xenstore xenforeignmemory xengnttab"
1933 xen_pc="$xen_pc xenevtchn xendevicemodel"
1934 if $pkg_config --exists xentoolcore; then
1935 xen_pc="$xen_pc xentoolcore"
1937 xen_cflags="$($pkg_config --cflags $xen_pc)"
1938 xen_libs="$($pkg_config --libs $xen_pc)"
1939 else
1941 xen_libs="-lxenstore -lxenctrl"
1942 xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
1944 # First we test whether Xen headers and libraries are available.
1945 # If no, we are done and there is no Xen support.
1946 # If yes, more tests are run to detect the Xen version.
1948 # Xen (any)
1949 cat > $TMPC <<EOF
1950 #include <xenctrl.h>
1951 int main(void) {
1952 return 0;
1955 if ! compile_prog "" "$xen_libs" ; then
1956 # Xen not found
1957 if test "$xen" = "enabled" ; then
1958 feature_not_found "xen" "Install xen devel"
1960 xen=disabled
1962 # Xen unstable
1963 elif
1964 cat > $TMPC <<EOF &&
1965 #undef XC_WANT_COMPAT_DEVICEMODEL_API
1966 #define __XEN_TOOLS__
1967 #include <xendevicemodel.h>
1968 #include <xenforeignmemory.h>
1969 int main(void) {
1970 xendevicemodel_handle *xd;
1971 xenforeignmemory_handle *xfmem;
1973 xd = xendevicemodel_open(0, 0);
1974 xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
1976 xfmem = xenforeignmemory_open(0, 0);
1977 xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
1979 return 0;
1982 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
1983 then
1984 xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
1985 xen_ctrl_version=41100
1986 xen=enabled
1987 elif
1988 cat > $TMPC <<EOF &&
1989 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
1990 #include <xenforeignmemory.h>
1991 #include <xentoolcore.h>
1992 int main(void) {
1993 xenforeignmemory_handle *xfmem;
1995 xfmem = xenforeignmemory_open(0, 0);
1996 xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
1997 xentoolcore_restrict_all(0);
1999 return 0;
2002 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
2003 then
2004 xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
2005 xen_ctrl_version=41000
2006 xen=enabled
2007 elif
2008 cat > $TMPC <<EOF &&
2009 #undef XC_WANT_COMPAT_DEVICEMODEL_API
2010 #define __XEN_TOOLS__
2011 #include <xendevicemodel.h>
2012 int main(void) {
2013 xendevicemodel_handle *xd;
2015 xd = xendevicemodel_open(0, 0);
2016 xendevicemodel_close(xd);
2018 return 0;
2021 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2022 then
2023 xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2024 xen_ctrl_version=40900
2025 xen=enabled
2026 elif
2027 cat > $TMPC <<EOF &&
2029 * If we have stable libs the we don't want the libxc compat
2030 * layers, regardless of what CFLAGS we may have been given.
2032 * Also, check if xengnttab_grant_copy_segment_t is defined and
2033 * grant copy operation is implemented.
2035 #undef XC_WANT_COMPAT_EVTCHN_API
2036 #undef XC_WANT_COMPAT_GNTTAB_API
2037 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2038 #include <xenctrl.h>
2039 #include <xenstore.h>
2040 #include <xenevtchn.h>
2041 #include <xengnttab.h>
2042 #include <xenforeignmemory.h>
2043 #include <stdint.h>
2044 #include <xen/hvm/hvm_info_table.h>
2045 #if !defined(HVM_MAX_VCPUS)
2046 # error HVM_MAX_VCPUS not defined
2047 #endif
2048 int main(void) {
2049 xc_interface *xc = NULL;
2050 xenforeignmemory_handle *xfmem;
2051 xenevtchn_handle *xe;
2052 xengnttab_handle *xg;
2053 xengnttab_grant_copy_segment_t* seg = NULL;
2055 xs_daemon_open();
2057 xc = xc_interface_open(0, 0, 0);
2058 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2059 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2060 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2061 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2063 xfmem = xenforeignmemory_open(0, 0);
2064 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2066 xe = xenevtchn_open(0, 0);
2067 xenevtchn_fd(xe);
2069 xg = xengnttab_open(0, 0);
2070 xengnttab_grant_copy(xg, 0, seg);
2072 return 0;
2075 compile_prog "" "$xen_libs $xen_stable_libs"
2076 then
2077 xen_ctrl_version=40800
2078 xen=enabled
2079 elif
2080 cat > $TMPC <<EOF &&
2082 * If we have stable libs the we don't want the libxc compat
2083 * layers, regardless of what CFLAGS we may have been given.
2085 #undef XC_WANT_COMPAT_EVTCHN_API
2086 #undef XC_WANT_COMPAT_GNTTAB_API
2087 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2088 #include <xenctrl.h>
2089 #include <xenstore.h>
2090 #include <xenevtchn.h>
2091 #include <xengnttab.h>
2092 #include <xenforeignmemory.h>
2093 #include <stdint.h>
2094 #include <xen/hvm/hvm_info_table.h>
2095 #if !defined(HVM_MAX_VCPUS)
2096 # error HVM_MAX_VCPUS not defined
2097 #endif
2098 int main(void) {
2099 xc_interface *xc = NULL;
2100 xenforeignmemory_handle *xfmem;
2101 xenevtchn_handle *xe;
2102 xengnttab_handle *xg;
2104 xs_daemon_open();
2106 xc = xc_interface_open(0, 0, 0);
2107 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2108 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2109 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2110 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2112 xfmem = xenforeignmemory_open(0, 0);
2113 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2115 xe = xenevtchn_open(0, 0);
2116 xenevtchn_fd(xe);
2118 xg = xengnttab_open(0, 0);
2119 xengnttab_map_grant_ref(xg, 0, 0, 0);
2121 return 0;
2124 compile_prog "" "$xen_libs $xen_stable_libs"
2125 then
2126 xen_ctrl_version=40701
2127 xen=enabled
2129 # Xen 4.6
2130 elif
2131 cat > $TMPC <<EOF &&
2132 #include <xenctrl.h>
2133 #include <xenstore.h>
2134 #include <stdint.h>
2135 #include <xen/hvm/hvm_info_table.h>
2136 #if !defined(HVM_MAX_VCPUS)
2137 # error HVM_MAX_VCPUS not defined
2138 #endif
2139 int main(void) {
2140 xc_interface *xc;
2141 xs_daemon_open();
2142 xc = xc_interface_open(0, 0, 0);
2143 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2144 xc_gnttab_open(NULL, 0);
2145 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2146 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2147 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2148 xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2149 return 0;
2152 compile_prog "" "$xen_libs"
2153 then
2154 xen_ctrl_version=40600
2155 xen=enabled
2157 # Xen 4.5
2158 elif
2159 cat > $TMPC <<EOF &&
2160 #include <xenctrl.h>
2161 #include <xenstore.h>
2162 #include <stdint.h>
2163 #include <xen/hvm/hvm_info_table.h>
2164 #if !defined(HVM_MAX_VCPUS)
2165 # error HVM_MAX_VCPUS not defined
2166 #endif
2167 int main(void) {
2168 xc_interface *xc;
2169 xs_daemon_open();
2170 xc = xc_interface_open(0, 0, 0);
2171 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2172 xc_gnttab_open(NULL, 0);
2173 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2174 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2175 xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
2176 return 0;
2179 compile_prog "" "$xen_libs"
2180 then
2181 xen_ctrl_version=40500
2182 xen=enabled
2184 elif
2185 cat > $TMPC <<EOF &&
2186 #include <xenctrl.h>
2187 #include <xenstore.h>
2188 #include <stdint.h>
2189 #include <xen/hvm/hvm_info_table.h>
2190 #if !defined(HVM_MAX_VCPUS)
2191 # error HVM_MAX_VCPUS not defined
2192 #endif
2193 int main(void) {
2194 xc_interface *xc;
2195 xs_daemon_open();
2196 xc = xc_interface_open(0, 0, 0);
2197 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2198 xc_gnttab_open(NULL, 0);
2199 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2200 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2201 return 0;
2204 compile_prog "" "$xen_libs"
2205 then
2206 xen_ctrl_version=40200
2207 xen=enabled
2209 else
2210 if test "$xen" = "enabled" ; then
2211 feature_not_found "xen (unsupported version)" \
2212 "Install a supported xen (xen 4.2 or newer)"
2214 xen=disabled
2217 if test "$xen" = enabled; then
2218 if test $xen_ctrl_version -ge 40701 ; then
2219 xen_libs="$xen_libs $xen_stable_libs "
2225 ##########################################
2226 # RDMA needs OpenFabrics libraries
2227 if test "$rdma" != "no" ; then
2228 cat > $TMPC <<EOF
2229 #include <rdma/rdma_cma.h>
2230 int main(void) { return 0; }
2232 rdma_libs="-lrdmacm -libverbs -libumad"
2233 if compile_prog "" "$rdma_libs" ; then
2234 rdma="yes"
2235 else
2236 if test "$rdma" = "yes" ; then
2237 error_exit \
2238 " OpenFabrics librdmacm/libibverbs/libibumad not present." \
2239 " Your options:" \
2240 " (1) Fast: Install infiniband packages (devel) from your distro." \
2241 " (2) Cleanest: Install libraries from www.openfabrics.org" \
2242 " (3) Also: Install softiwarp if you don't have RDMA hardware"
2244 rdma="no"
2248 ##########################################
2249 # PVRDMA detection
2251 cat > $TMPC <<EOF &&
2252 #include <sys/mman.h>
2255 main(void)
2257 char buf = 0;
2258 void *addr = &buf;
2259 addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED);
2261 return 0;
2265 if test "$rdma" = "yes" ; then
2266 case "$pvrdma" in
2268 if compile_prog "" ""; then
2269 pvrdma="yes"
2270 else
2271 pvrdma="no"
2274 "yes")
2275 if ! compile_prog "" ""; then
2276 error_exit "PVRDMA is not supported since mremap is not implemented"
2278 pvrdma="yes"
2280 "no")
2281 pvrdma="no"
2283 esac
2284 else
2285 if test "$pvrdma" = "yes" ; then
2286 error_exit "PVRDMA requires rdma suppport"
2288 pvrdma="no"
2291 # Let's see if enhanced reg_mr is supported
2292 if test "$pvrdma" = "yes" ; then
2294 cat > $TMPC <<EOF &&
2295 #include <infiniband/verbs.h>
2298 main(void)
2300 struct ibv_mr *mr;
2301 struct ibv_pd *pd = NULL;
2302 size_t length = 10;
2303 uint64_t iova = 0;
2304 int access = 0;
2305 void *addr = NULL;
2307 mr = ibv_reg_mr_iova(pd, addr, length, iova, access);
2309 ibv_dereg_mr(mr);
2311 return 0;
2314 if ! compile_prog "" "-libverbs"; then
2315 QEMU_CFLAGS="$QEMU_CFLAGS -DLEGACY_RDMA_REG_MR"
2319 ##########################################
2320 # glib support probe
2322 glib_req_ver=2.56
2323 glib_modules=gthread-2.0
2324 if test "$modules" = yes; then
2325 glib_modules="$glib_modules gmodule-export-2.0"
2326 elif test "$plugins" = "yes"; then
2327 glib_modules="$glib_modules gmodule-no-export-2.0"
2330 for i in $glib_modules; do
2331 if $pkg_config --atleast-version=$glib_req_ver $i; then
2332 glib_cflags=$($pkg_config --cflags $i)
2333 glib_libs=$($pkg_config --libs $i)
2334 else
2335 error_exit "glib-$glib_req_ver $i is required to compile QEMU"
2337 done
2339 # This workaround is required due to a bug in pkg-config file for glib as it
2340 # doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
2342 if test "$static" = yes && test "$mingw32" = yes; then
2343 glib_cflags="-DGLIB_STATIC_COMPILATION $glib_cflags"
2346 if ! test "$gio" = "no"; then
2347 pass=no
2348 if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
2349 gio_cflags=$($pkg_config --cflags gio-2.0)
2350 gio_libs=$($pkg_config --libs gio-2.0)
2351 gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0)
2352 if ! has "$gdbus_codegen"; then
2353 gdbus_codegen=
2355 # Check that the libraries actually work -- Ubuntu 18.04 ships
2356 # with pkg-config --static --libs data for gio-2.0 that is missing
2357 # -lblkid and will give a link error.
2358 cat > $TMPC <<EOF
2359 #include <gio/gio.h>
2360 int main(void)
2362 g_dbus_proxy_new_sync(0, 0, 0, 0, 0, 0, 0, 0);
2363 return 0;
2366 if compile_prog "$gio_cflags" "$gio_libs" ; then
2367 pass=yes
2368 else
2369 pass=no
2372 if test "$pass" = "yes" &&
2373 $pkg_config --atleast-version=$glib_req_ver gio-unix-2.0; then
2374 gio_cflags="$gio_cflags $($pkg_config --cflags gio-unix-2.0)"
2375 gio_libs="$gio_libs $($pkg_config --libs gio-unix-2.0)"
2379 if test "$pass" = "no"; then
2380 if test "$gio" = "yes"; then
2381 feature_not_found "gio" "Install libgio >= 2.0"
2382 else
2383 gio=no
2385 else
2386 gio=yes
2390 # Sanity check that the current size_t matches the
2391 # size that glib thinks it should be. This catches
2392 # problems on multi-arch where people try to build
2393 # 32-bit QEMU while pointing at 64-bit glib headers
2394 cat > $TMPC <<EOF
2395 #include <glib.h>
2396 #include <unistd.h>
2398 #define QEMU_BUILD_BUG_ON(x) \
2399 typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
2401 int main(void) {
2402 QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
2403 return 0;
2407 if ! compile_prog "$glib_cflags" "$glib_libs" ; then
2408 error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
2409 "You probably need to set PKG_CONFIG_LIBDIR"\
2410 "to point to the right pkg-config files for your"\
2411 "build target"
2414 # Silence clang warnings triggered by glib < 2.57.2
2415 cat > $TMPC << EOF
2416 #include <glib.h>
2417 typedef struct Foo {
2418 int i;
2419 } Foo;
2420 static void foo_free(Foo *f)
2422 g_free(f);
2424 G_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free);
2425 int main(void) { return 0; }
2427 if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
2428 if cc_has_warning_flag "-Wno-unused-function"; then
2429 glib_cflags="$glib_cflags -Wno-unused-function"
2430 CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -Wno-unused-function"
2434 ##########################################
2435 # SHA command probe for modules
2436 if test "$modules" = yes; then
2437 shacmd_probe="sha1sum sha1 shasum"
2438 for c in $shacmd_probe; do
2439 if has $c; then
2440 shacmd="$c"
2441 break
2443 done
2444 if test "$shacmd" = ""; then
2445 error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
2449 ##########################################
2450 # TPM emulation is only on POSIX
2452 if test "$tpm" = ""; then
2453 if test "$mingw32" = "yes"; then
2454 tpm=no
2455 else
2456 tpm=yes
2458 elif test "$tpm" = "yes"; then
2459 if test "$mingw32" = "yes" ; then
2460 error_exit "TPM emulation only available on POSIX systems"
2464 ##########################################
2465 # fdt probe
2467 case "$fdt" in
2468 auto | enabled | internal)
2469 # Simpler to always update submodule, even if not needed.
2470 git_submodules="${git_submodules} dtc"
2472 esac
2474 ##########################################
2475 # opengl probe (for sdl2, gtk)
2477 if test "$opengl" != "no" ; then
2478 epoxy=no
2479 if $pkg_config epoxy; then
2480 cat > $TMPC << EOF
2481 #include <epoxy/egl.h>
2482 int main(void) { return 0; }
2484 if compile_prog "" "" ; then
2485 epoxy=yes
2489 if test "$epoxy" = "yes" ; then
2490 opengl_cflags="$($pkg_config --cflags epoxy)"
2491 opengl_libs="$($pkg_config --libs epoxy)"
2492 opengl=yes
2493 else
2494 if test "$opengl" = "yes" ; then
2495 feature_not_found "opengl" "Please install epoxy with EGL"
2497 opengl_cflags=""
2498 opengl_libs=""
2499 opengl=no
2503 ##########################################
2504 # libnuma probe
2506 if test "$numa" != "no" ; then
2507 cat > $TMPC << EOF
2508 #include <numa.h>
2509 int main(void) { return numa_available(); }
2512 if compile_prog "" "-lnuma" ; then
2513 numa=yes
2514 numa_libs="-lnuma"
2515 else
2516 if test "$numa" = "yes" ; then
2517 feature_not_found "numa" "install numactl devel"
2519 numa=no
2523 # check for usbfs
2524 have_usbfs=no
2525 if test "$linux_user" = "yes"; then
2526 cat > $TMPC << EOF
2527 #include <linux/usbdevice_fs.h>
2529 #ifndef USBDEVFS_GET_CAPABILITIES
2530 #error "USBDEVFS_GET_CAPABILITIES undefined"
2531 #endif
2533 #ifndef USBDEVFS_DISCONNECT_CLAIM
2534 #error "USBDEVFS_DISCONNECT_CLAIM undefined"
2535 #endif
2537 int main(void)
2539 return 0;
2542 if compile_prog "" ""; then
2543 have_usbfs=yes
2547 ##########################################
2548 # check if we have VSS SDK headers for win
2550 guest_agent_with_vss="no"
2551 if test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
2552 test "$vss_win32_sdk" != "no" ; then
2553 case "$vss_win32_sdk" in
2554 "") vss_win32_include="-isystem $source_path" ;;
2555 *\ *) # The SDK is installed in "Program Files" by default, but we cannot
2556 # handle path with spaces. So we symlink the headers into ".sdk/vss".
2557 vss_win32_include="-isystem $source_path/.sdk/vss"
2558 symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
2560 *) vss_win32_include="-isystem $vss_win32_sdk"
2561 esac
2562 cat > $TMPC << EOF
2563 #define __MIDL_user_allocate_free_DEFINED__
2564 #include <inc/win2003/vss.h>
2565 int main(void) { return VSS_CTX_BACKUP; }
2567 if compile_prog "$vss_win32_include" "" ; then
2568 guest_agent_with_vss="yes"
2569 QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
2570 libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
2571 qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
2572 else
2573 if test "$vss_win32_sdk" != "" ; then
2574 echo "ERROR: Please download and install Microsoft VSS SDK:"
2575 echo "ERROR: http://www.microsoft.com/en-us/download/details.aspx?id=23490"
2576 echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
2577 echo "ERROR: scripts/extract-vsssdk-headers setup.exe"
2578 echo "ERROR: The headers are extracted in the directory \`inc'."
2579 feature_not_found "VSS support"
2584 ##########################################
2585 # lookup Windows platform SDK (if not specified)
2586 # The SDK is needed only to build .tlb (type library) file of guest agent
2587 # VSS provider from the source. It is usually unnecessary because the
2588 # pre-compiled .tlb file is included.
2590 if test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
2591 test "$guest_agent_with_vss" = "yes" ; then
2592 if test -z "$win_sdk"; then
2593 programfiles="$PROGRAMFILES"
2594 test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
2595 if test -n "$programfiles"; then
2596 win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
2597 else
2598 feature_not_found "Windows SDK"
2600 elif test "$win_sdk" = "no"; then
2601 win_sdk=""
2605 ##########################################
2606 # check if mingw environment provides a recent ntddscsi.h
2607 guest_agent_ntddscsi="no"
2608 if test "$mingw32" = "yes" && test "$guest_agent" != "no"; then
2609 cat > $TMPC << EOF
2610 #include <windows.h>
2611 #include <ntddscsi.h>
2612 int main(void) {
2613 #if !defined(IOCTL_SCSI_GET_ADDRESS)
2614 #error Missing required ioctl definitions
2615 #endif
2616 SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
2617 return addr.Lun;
2620 if compile_prog "" "" ; then
2621 guest_agent_ntddscsi=yes
2622 libs_qga="-lsetupapi -lcfgmgr32 $libs_qga"
2626 ##########################################
2627 # capstone
2629 case "$capstone" in
2630 auto | enabled | internal)
2631 # Simpler to always update submodule, even if not needed.
2632 git_submodules="${git_submodules} capstone"
2634 esac
2636 ##########################################
2637 # check and set a backend for coroutine
2639 # We prefer ucontext, but it's not always possible. The fallback
2640 # is sigcontext. On Windows the only valid backend is the Windows
2641 # specific one.
2643 ucontext_works=no
2644 if test "$darwin" != "yes"; then
2645 cat > $TMPC << EOF
2646 #include <ucontext.h>
2647 #ifdef __stub_makecontext
2648 #error Ignoring glibc stub makecontext which will always fail
2649 #endif
2650 int main(void) { makecontext(0, 0, 0); return 0; }
2652 if compile_prog "" "" ; then
2653 ucontext_works=yes
2657 if test "$coroutine" = ""; then
2658 if test "$mingw32" = "yes"; then
2659 coroutine=win32
2660 elif test "$ucontext_works" = "yes"; then
2661 coroutine=ucontext
2662 else
2663 coroutine=sigaltstack
2665 else
2666 case $coroutine in
2667 windows)
2668 if test "$mingw32" != "yes"; then
2669 error_exit "'windows' coroutine backend only valid for Windows"
2671 # Unfortunately the user visible backend name doesn't match the
2672 # coroutine-*.c filename for this case, so we have to adjust it here.
2673 coroutine=win32
2675 ucontext)
2676 if test "$ucontext_works" != "yes"; then
2677 feature_not_found "ucontext"
2680 sigaltstack)
2681 if test "$mingw32" = "yes"; then
2682 error_exit "only the 'windows' coroutine backend is valid for Windows"
2686 error_exit "unknown coroutine backend $coroutine"
2688 esac
2691 if test "$coroutine_pool" = ""; then
2692 coroutine_pool=yes
2695 if test "$debug_stack_usage" = "yes"; then
2696 if test "$coroutine_pool" = "yes"; then
2697 echo "WARN: disabling coroutine pool for stack usage debugging"
2698 coroutine_pool=no
2702 ##################################################
2703 # SafeStack
2706 if test "$safe_stack" = "yes"; then
2707 cat > $TMPC << EOF
2708 int main(int argc, char *argv[])
2710 #if ! __has_feature(safe_stack)
2711 #error SafeStack Disabled
2712 #endif
2713 return 0;
2716 flag="-fsanitize=safe-stack"
2717 # Check that safe-stack is supported and enabled.
2718 if compile_prog "-Werror $flag" "$flag"; then
2719 # Flag needed both at compilation and at linking
2720 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
2721 QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
2722 else
2723 error_exit "SafeStack not supported by your compiler"
2725 if test "$coroutine" != "ucontext"; then
2726 error_exit "SafeStack is only supported by the coroutine backend ucontext"
2728 else
2729 cat > $TMPC << EOF
2730 int main(int argc, char *argv[])
2732 #if defined(__has_feature)
2733 #if __has_feature(safe_stack)
2734 #error SafeStack Enabled
2735 #endif
2736 #endif
2737 return 0;
2740 if test "$safe_stack" = "no"; then
2741 # Make sure that safe-stack is disabled
2742 if ! compile_prog "-Werror" ""; then
2743 # SafeStack was already enabled, try to explicitly remove the feature
2744 flag="-fno-sanitize=safe-stack"
2745 if ! compile_prog "-Werror $flag" "$flag"; then
2746 error_exit "Configure cannot disable SafeStack"
2748 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
2749 QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
2751 else # "$safe_stack" = ""
2752 # Set safe_stack to yes or no based on pre-existing flags
2753 if compile_prog "-Werror" ""; then
2754 safe_stack="no"
2755 else
2756 safe_stack="yes"
2757 if test "$coroutine" != "ucontext"; then
2758 error_exit "SafeStack is only supported by the coroutine backend ucontext"
2764 ########################################
2765 # check if cpuid.h is usable.
2767 cat > $TMPC << EOF
2768 #include <cpuid.h>
2769 int main(void) {
2770 unsigned a, b, c, d;
2771 unsigned max = __get_cpuid_max(0, 0);
2773 if (max >= 1) {
2774 __cpuid(1, a, b, c, d);
2777 if (max >= 7) {
2778 __cpuid_count(7, 0, a, b, c, d);
2781 return 0;
2784 if compile_prog "" "" ; then
2785 cpuid_h=yes
2788 ##########################################
2789 # avx2 optimization requirement check
2791 # There is no point enabling this if cpuid.h is not usable,
2792 # since we won't be able to select the new routines.
2794 if test "$cpuid_h" = "yes" && test "$avx2_opt" != "no"; then
2795 cat > $TMPC << EOF
2796 #pragma GCC push_options
2797 #pragma GCC target("avx2")
2798 #include <cpuid.h>
2799 #include <immintrin.h>
2800 static int bar(void *a) {
2801 __m256i x = *(__m256i *)a;
2802 return _mm256_testz_si256(x, x);
2804 int main(int argc, char *argv[]) { return bar(argv[0]); }
2806 if compile_object "-Werror" ; then
2807 avx2_opt="yes"
2808 else
2809 avx2_opt="no"
2813 ##########################################
2814 # avx512f optimization requirement check
2816 # There is no point enabling this if cpuid.h is not usable,
2817 # since we won't be able to select the new routines.
2818 # by default, it is turned off.
2819 # if user explicitly want to enable it, check environment
2821 if test "$cpuid_h" = "yes" && test "$avx512f_opt" = "yes"; then
2822 cat > $TMPC << EOF
2823 #pragma GCC push_options
2824 #pragma GCC target("avx512f")
2825 #include <cpuid.h>
2826 #include <immintrin.h>
2827 static int bar(void *a) {
2828 __m512i x = *(__m512i *)a;
2829 return _mm512_test_epi64_mask(x, x);
2831 int main(int argc, char *argv[])
2833 return bar(argv[0]);
2836 if ! compile_object "-Werror" ; then
2837 avx512f_opt="no"
2839 else
2840 avx512f_opt="no"
2843 ########################################
2844 # check if __[u]int128_t is usable.
2846 int128=no
2847 cat > $TMPC << EOF
2848 __int128_t a;
2849 __uint128_t b;
2850 int main (void) {
2851 a = a + b;
2852 b = a * b;
2853 a = a * a;
2854 return 0;
2857 if compile_prog "" "" ; then
2858 int128=yes
2861 #########################################
2862 # See if 128-bit atomic operations are supported.
2864 atomic128=no
2865 if test "$int128" = "yes"; then
2866 cat > $TMPC << EOF
2867 int main(void)
2869 unsigned __int128 x = 0, y = 0;
2870 y = __atomic_load(&x, 0);
2871 __atomic_store(&x, y, 0);
2872 __atomic_compare_exchange(&x, &y, x, 0, 0, 0);
2873 return 0;
2876 if compile_prog "" "" ; then
2877 atomic128=yes
2881 cmpxchg128=no
2882 if test "$int128" = yes && test "$atomic128" = no; then
2883 cat > $TMPC << EOF
2884 int main(void)
2886 unsigned __int128 x = 0, y = 0;
2887 __sync_val_compare_and_swap_16(&x, y, x);
2888 return 0;
2891 if compile_prog "" "" ; then
2892 cmpxchg128=yes
2896 ########################################
2897 # check if ccache is interfering with
2898 # semantic analysis of macros
2900 unset CCACHE_CPP2
2901 ccache_cpp2=no
2902 cat > $TMPC << EOF
2903 static const int Z = 1;
2904 #define fn() ({ Z; })
2905 #define TAUT(X) ((X) == Z)
2906 #define PAREN(X, Y) (X == Y)
2907 #define ID(X) (X)
2908 int main(int argc, char *argv[])
2910 int x = 0, y = 0;
2911 x = ID(x);
2912 x = fn();
2913 fn();
2914 if (PAREN(x, y)) return 0;
2915 if (TAUT(Z)) return 0;
2916 return 0;
2920 if ! compile_object "-Werror"; then
2921 ccache_cpp2=yes
2924 #################################################
2925 # clang does not support glibc + FORTIFY_SOURCE.
2927 if test "$fortify_source" != "no"; then
2928 if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
2929 fortify_source="no";
2930 elif test -n "$cxx" && has $cxx &&
2931 echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
2932 fortify_source="no";
2933 else
2934 fortify_source="yes"
2938 ##########################################
2939 # check for usable membarrier system call
2940 if test "$membarrier" = "yes"; then
2941 have_membarrier=no
2942 if test "$mingw32" = "yes" ; then
2943 have_membarrier=yes
2944 elif test "$linux" = "yes" ; then
2945 cat > $TMPC << EOF
2946 #include <linux/membarrier.h>
2947 #include <sys/syscall.h>
2948 #include <unistd.h>
2949 #include <stdlib.h>
2950 int main(void) {
2951 syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
2952 syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0);
2953 exit(0);
2956 if compile_prog "" "" ; then
2957 have_membarrier=yes
2960 if test "$have_membarrier" = "no"; then
2961 feature_not_found "membarrier" "membarrier system call not available"
2963 else
2964 # Do not enable it by default even for Mingw32, because it doesn't
2965 # work on Wine.
2966 membarrier=no
2969 ##########################################
2970 # check for usable AF_ALG environment
2971 have_afalg=no
2972 cat > $TMPC << EOF
2973 #include <errno.h>
2974 #include <sys/types.h>
2975 #include <sys/socket.h>
2976 #include <linux/if_alg.h>
2977 int main(void) {
2978 int sock;
2979 sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
2980 return sock;
2983 if compile_prog "" "" ; then
2984 have_afalg=yes
2986 if test "$crypto_afalg" = "yes"
2987 then
2988 if test "$have_afalg" != "yes"
2989 then
2990 error_exit "AF_ALG requested but could not be detected"
2995 ##########################################
2996 # checks for sanitizers
2998 have_asan=no
2999 have_ubsan=no
3000 have_asan_iface_h=no
3001 have_asan_iface_fiber=no
3003 if test "$sanitizers" = "yes" ; then
3004 write_c_skeleton
3005 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
3006 have_asan=yes
3009 # we could use a simple skeleton for flags checks, but this also
3010 # detect the static linking issue of ubsan, see also:
3011 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
3012 cat > $TMPC << EOF
3013 #include <stdlib.h>
3014 int main(void) {
3015 void *tmp = malloc(10);
3016 if (tmp != NULL) {
3017 return *(int *)(tmp + 2);
3019 return 1;
3022 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
3023 have_ubsan=yes
3026 if check_include "sanitizer/asan_interface.h" ; then
3027 have_asan_iface_h=yes
3030 cat > $TMPC << EOF
3031 #include <sanitizer/asan_interface.h>
3032 int main(void) {
3033 __sanitizer_start_switch_fiber(0, 0, 0);
3034 return 0;
3037 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
3038 have_asan_iface_fiber=yes
3042 # Thread sanitizer is, for now, much noisier than the other sanitizers;
3043 # keep it separate until that is not the case.
3044 if test "$tsan" = "yes" && test "$sanitizers" = "yes"; then
3045 error_exit "TSAN is not supported with other sanitiziers."
3047 have_tsan=no
3048 have_tsan_iface_fiber=no
3049 if test "$tsan" = "yes" ; then
3050 write_c_skeleton
3051 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
3052 have_tsan=yes
3054 cat > $TMPC << EOF
3055 #include <sanitizer/tsan_interface.h>
3056 int main(void) {
3057 __tsan_create_fiber(0);
3058 return 0;
3061 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
3062 have_tsan_iface_fiber=yes
3066 ##########################################
3067 # check for slirp
3069 case "$slirp" in
3070 auto | enabled | internal)
3071 # Simpler to always update submodule, even if not needed.
3072 git_submodules="${git_submodules} slirp"
3074 esac
3076 # Check for slirp smbd dupport
3077 : ${smbd=${SMBD-/usr/sbin/smbd}}
3078 if test "$slirp_smbd" != "no" ; then
3079 if test "$mingw32" = "yes" ; then
3080 if test "$slirp_smbd" = "yes" ; then
3081 error_exit "Host smbd not supported on this platform."
3083 slirp_smbd=no
3084 else
3085 slirp_smbd=yes
3089 ##########################################
3090 # check for usable __NR_keyctl syscall
3092 if test "$linux" = "yes" ; then
3094 have_keyring=no
3095 cat > $TMPC << EOF
3096 #include <errno.h>
3097 #include <asm/unistd.h>
3098 #include <linux/keyctl.h>
3099 #include <unistd.h>
3100 int main(void) {
3101 return syscall(__NR_keyctl, KEYCTL_READ, 0, NULL, NULL, 0);
3104 if compile_prog "" "" ; then
3105 have_keyring=yes
3108 if test "$secret_keyring" != "no"
3109 then
3110 if test "$have_keyring" = "yes"
3111 then
3112 secret_keyring=yes
3113 else
3114 if test "$secret_keyring" = "yes"
3115 then
3116 error_exit "syscall __NR_keyctl requested, \
3117 but not implemented on your system"
3118 else
3119 secret_keyring=no
3124 ##########################################
3125 # End of CC checks
3126 # After here, no more $cc or $ld runs
3128 write_c_skeleton
3130 if test "$gcov" = "yes" ; then
3132 elif test "$fortify_source" = "yes" ; then
3133 QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
3134 debug=no
3137 case "$ARCH" in
3138 alpha)
3139 # Ensure there's only a single GP
3140 QEMU_CFLAGS="-msmall-data $QEMU_CFLAGS"
3142 esac
3144 if test "$gprof" = "yes" ; then
3145 QEMU_CFLAGS="-p $QEMU_CFLAGS"
3146 QEMU_LDFLAGS="-p $QEMU_LDFLAGS"
3149 if test "$have_asan" = "yes"; then
3150 QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS"
3151 QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS"
3152 if test "$have_asan_iface_h" = "no" ; then
3153 echo "ASAN build enabled, but ASAN header missing." \
3154 "Without code annotation, the report may be inferior."
3155 elif test "$have_asan_iface_fiber" = "no" ; then
3156 echo "ASAN build enabled, but ASAN header is too old." \
3157 "Without code annotation, the report may be inferior."
3160 if test "$have_tsan" = "yes" ; then
3161 if test "$have_tsan_iface_fiber" = "yes" ; then
3162 QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS"
3163 QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS"
3164 else
3165 error_exit "Cannot enable TSAN due to missing fiber annotation interface."
3167 elif test "$tsan" = "yes" ; then
3168 error_exit "Cannot enable TSAN due to missing sanitize thread interface."
3170 if test "$have_ubsan" = "yes"; then
3171 QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS"
3172 QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS"
3175 ##########################################
3177 # Exclude --warn-common with TSan to suppress warnings from the TSan libraries.
3178 if test "$solaris" = "no" && test "$tsan" = "no"; then
3179 if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
3180 QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS"
3184 # Use ASLR, no-SEH and DEP if available
3185 if test "$mingw32" = "yes" ; then
3186 flags="--no-seh --nxcompat"
3188 # Disable ASLR for debug builds to allow debugging with gdb
3189 if test "$debug" = "no" ; then
3190 flags="--dynamicbase $flags"
3193 for flag in $flags; do
3194 if ld_has $flag ; then
3195 QEMU_LDFLAGS="-Wl,$flag $QEMU_LDFLAGS"
3197 done
3200 # Probe for guest agent support/options
3202 if [ "$guest_agent" != "no" ]; then
3203 if [ "$softmmu" = no -a "$want_tools" = no ] ; then
3204 guest_agent=no
3205 elif [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
3206 guest_agent=yes
3207 elif [ "$guest_agent" != yes ]; then
3208 guest_agent=no
3209 else
3210 error_exit "Guest agent is not supported on this platform"
3214 # Guest agent Windows MSI package
3216 if test "$QEMU_GA_MANUFACTURER" = ""; then
3217 QEMU_GA_MANUFACTURER=QEMU
3219 if test "$QEMU_GA_DISTRO" = ""; then
3220 QEMU_GA_DISTRO=Linux
3222 if test "$QEMU_GA_VERSION" = ""; then
3223 QEMU_GA_VERSION=$(cat $source_path/VERSION)
3226 QEMU_GA_MSI_MINGW_DLL_PATH="$($pkg_config --variable=prefix glib-2.0)/bin"
3228 # Mac OS X ships with a broken assembler
3229 roms=
3230 if { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \
3231 test "$targetos" != "darwin" && test "$targetos" != "sunos" && \
3232 test "$targetos" != "haiku" && test "$softmmu" = yes ; then
3233 # Different host OS linkers have different ideas about the name of the ELF
3234 # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
3235 # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
3236 for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
3237 if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
3238 ld_i386_emulation="$emu"
3239 roms="optionrom"
3240 break
3242 done
3245 # Only build s390-ccw bios if we're on s390x and the compiler has -march=z900
3246 # or -march=z10 (which is the lowest architecture level that Clang supports)
3247 if test "$cpu" = "s390x" ; then
3248 write_c_skeleton
3249 compile_prog "-march=z900" ""
3250 has_z900=$?
3251 if [ $has_z900 = 0 ] || compile_object "-march=z10 -msoft-float -Werror"; then
3252 if [ $has_z900 != 0 ]; then
3253 echo "WARNING: Your compiler does not support the z900!"
3254 echo " The s390-ccw bios will only work with guest CPUs >= z10."
3256 roms="$roms s390-ccw"
3257 # SLOF is required for building the s390-ccw firmware on s390x,
3258 # since it is using the libnet code from SLOF for network booting.
3259 git_submodules="${git_submodules} roms/SLOF"
3263 # Check that the C++ compiler exists and works with the C compiler.
3264 # All the QEMU_CXXFLAGS are based on QEMU_CFLAGS. Keep this at the end to don't miss any other that could be added.
3265 if has $cxx; then
3266 cat > $TMPC <<EOF
3267 int c_function(void);
3268 int main(void) { return c_function(); }
3271 compile_object
3273 cat > $TMPCXX <<EOF
3274 extern "C" {
3275 int c_function(void);
3277 int c_function(void) { return 42; }
3280 update_cxxflags
3282 if do_cxx $CXXFLAGS $EXTRA_CXXFLAGS $CONFIGURE_CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then
3283 # C++ compiler $cxx works ok with C compiler $cc
3285 else
3286 echo "C++ compiler $cxx does not work with C compiler $cc"
3287 echo "Disabling C++ specific optional code"
3288 cxx=
3290 else
3291 echo "No C++ compiler available; disabling C++ specific optional code"
3292 cxx=
3295 if !(GIT="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then
3296 exit 1
3299 config_host_mak="config-host.mak"
3301 echo "# Automatically generated by configure - do not modify" > $config_host_mak
3302 echo >> $config_host_mak
3304 echo all: >> $config_host_mak
3305 echo "GIT=$git" >> $config_host_mak
3306 echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
3307 echo "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak
3309 if test "$debug_tcg" = "yes" ; then
3310 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
3312 if test "$mingw32" = "yes" ; then
3313 echo "CONFIG_WIN32=y" >> $config_host_mak
3314 if test "$guest_agent_with_vss" = "yes" ; then
3315 echo "CONFIG_QGA_VSS=y" >> $config_host_mak
3316 echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
3317 echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
3319 if test "$guest_agent_ntddscsi" = "yes" ; then
3320 echo "CONFIG_QGA_NTDDSCSI=y" >> $config_host_mak
3322 echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
3323 echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
3324 echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
3325 echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
3326 else
3327 echo "CONFIG_POSIX=y" >> $config_host_mak
3330 if test "$linux" = "yes" ; then
3331 echo "CONFIG_LINUX=y" >> $config_host_mak
3334 if test "$darwin" = "yes" ; then
3335 echo "CONFIG_DARWIN=y" >> $config_host_mak
3338 if test "$solaris" = "yes" ; then
3339 echo "CONFIG_SOLARIS=y" >> $config_host_mak
3341 if test "$static" = "yes" ; then
3342 echo "CONFIG_STATIC=y" >> $config_host_mak
3344 if test "$profiler" = "yes" ; then
3345 echo "CONFIG_PROFILER=y" >> $config_host_mak
3347 if test "$want_tools" = "yes" ; then
3348 echo "CONFIG_TOOLS=y" >> $config_host_mak
3350 if test "$guest_agent" = "yes" ; then
3351 echo "CONFIG_GUEST_AGENT=y" >> $config_host_mak
3353 if test "$slirp_smbd" = "yes" ; then
3354 echo "CONFIG_SLIRP_SMBD=y" >> $config_host_mak
3355 echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
3357 if test "$gprof" = "yes" ; then
3358 echo "CONFIG_GPROF=y" >> $config_host_mak
3360 echo "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
3361 echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
3362 if test "$block_drv_whitelist_tools" = "yes" ; then
3363 echo "CONFIG_BDRV_WHITELIST_TOOLS=y" >> $config_host_mak
3365 qemu_version=$(head $source_path/VERSION)
3366 echo "PKGVERSION=$pkgversion" >>$config_host_mak
3367 echo "SRC_PATH=$source_path" >> $config_host_mak
3368 echo "TARGET_DIRS=$target_list" >> $config_host_mak
3369 if test "$modules" = "yes"; then
3370 # $shacmd can generate a hash started with digit, which the compiler doesn't
3371 # like as an symbol. So prefix it with an underscore
3372 echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
3373 echo "CONFIG_MODULES=y" >> $config_host_mak
3375 if test "$module_upgrades" = "yes"; then
3376 echo "CONFIG_MODULE_UPGRADES=y" >> $config_host_mak
3378 if test "$have_usbfs" = "yes" ; then
3379 echo "CONFIG_USBFS=y" >> $config_host_mak
3381 if test "$gio" = "yes" ; then
3382 echo "CONFIG_GIO=y" >> $config_host_mak
3383 echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak
3384 echo "GIO_LIBS=$gio_libs" >> $config_host_mak
3386 if test "$gdbus_codegen" != "" ; then
3387 echo "GDBUS_CODEGEN=$gdbus_codegen" >> $config_host_mak
3389 echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
3391 if test "$xen" = "enabled" ; then
3392 echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
3393 echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
3394 echo "XEN_CFLAGS=$xen_cflags" >> $config_host_mak
3395 echo "XEN_LIBS=$xen_libs" >> $config_host_mak
3397 if test "$vhost_scsi" = "yes" ; then
3398 echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
3400 if test "$vhost_net" = "yes" ; then
3401 echo "CONFIG_VHOST_NET=y" >> $config_host_mak
3403 if test "$vhost_net_user" = "yes" ; then
3404 echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak
3406 if test "$vhost_net_vdpa" = "yes" ; then
3407 echo "CONFIG_VHOST_NET_VDPA=y" >> $config_host_mak
3409 if test "$vhost_crypto" = "yes" ; then
3410 echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
3412 if test "$vhost_vsock" = "yes" ; then
3413 echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
3414 if test "$vhost_user" = "yes" ; then
3415 echo "CONFIG_VHOST_USER_VSOCK=y" >> $config_host_mak
3418 if test "$vhost_kernel" = "yes" ; then
3419 echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak
3421 if test "$vhost_user" = "yes" ; then
3422 echo "CONFIG_VHOST_USER=y" >> $config_host_mak
3424 if test "$vhost_vdpa" = "yes" ; then
3425 echo "CONFIG_VHOST_VDPA=y" >> $config_host_mak
3427 if test "$vhost_user_fs" = "yes" ; then
3428 echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak
3430 if test "$membarrier" = "yes" ; then
3431 echo "CONFIG_MEMBARRIER=y" >> $config_host_mak
3433 if test "$tcg" = "enabled" -a "$tcg_interpreter" = "true" ; then
3434 echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
3437 if test "$opengl" = "yes" ; then
3438 echo "CONFIG_OPENGL=y" >> $config_host_mak
3439 echo "OPENGL_CFLAGS=$opengl_cflags" >> $config_host_mak
3440 echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
3443 if test "$avx2_opt" = "yes" ; then
3444 echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
3447 if test "$avx512f_opt" = "yes" ; then
3448 echo "CONFIG_AVX512F_OPT=y" >> $config_host_mak
3451 # XXX: suppress that
3452 if [ "$bsd" = "yes" ] ; then
3453 echo "CONFIG_BSD=y" >> $config_host_mak
3456 if test "$qom_cast_debug" = "yes" ; then
3457 echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
3460 echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
3461 if test "$coroutine_pool" = "yes" ; then
3462 echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
3463 else
3464 echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
3467 if test "$debug_stack_usage" = "yes" ; then
3468 echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
3471 if test "$crypto_afalg" = "yes" ; then
3472 echo "CONFIG_AF_ALG=y" >> $config_host_mak
3475 if test "$have_asan_iface_fiber" = "yes" ; then
3476 echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
3479 if test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then
3480 echo "CONFIG_TSAN=y" >> $config_host_mak
3483 if test "$cpuid_h" = "yes" ; then
3484 echo "CONFIG_CPUID_H=y" >> $config_host_mak
3487 if test "$int128" = "yes" ; then
3488 echo "CONFIG_INT128=y" >> $config_host_mak
3491 if test "$atomic128" = "yes" ; then
3492 echo "CONFIG_ATOMIC128=y" >> $config_host_mak
3495 if test "$cmpxchg128" = "yes" ; then
3496 echo "CONFIG_CMPXCHG128=y" >> $config_host_mak
3499 if test "$live_block_migration" = "yes" ; then
3500 echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
3503 if test "$tpm" = "yes"; then
3504 echo 'CONFIG_TPM=y' >> $config_host_mak
3507 if test "$rdma" = "yes" ; then
3508 echo "CONFIG_RDMA=y" >> $config_host_mak
3509 echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
3512 if test "$pvrdma" = "yes" ; then
3513 echo "CONFIG_PVRDMA=y" >> $config_host_mak
3516 if test "$replication" = "yes" ; then
3517 echo "CONFIG_REPLICATION=y" >> $config_host_mak
3520 if test "$debug_mutex" = "yes" ; then
3521 echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak
3524 if test "$bochs" = "yes" ; then
3525 echo "CONFIG_BOCHS=y" >> $config_host_mak
3527 if test "$cloop" = "yes" ; then
3528 echo "CONFIG_CLOOP=y" >> $config_host_mak
3530 if test "$dmg" = "yes" ; then
3531 echo "CONFIG_DMG=y" >> $config_host_mak
3533 if test "$qcow1" = "yes" ; then
3534 echo "CONFIG_QCOW1=y" >> $config_host_mak
3536 if test "$vdi" = "yes" ; then
3537 echo "CONFIG_VDI=y" >> $config_host_mak
3539 if test "$vvfat" = "yes" ; then
3540 echo "CONFIG_VVFAT=y" >> $config_host_mak
3542 if test "$qed" = "yes" ; then
3543 echo "CONFIG_QED=y" >> $config_host_mak
3545 if test "$parallels" = "yes" ; then
3546 echo "CONFIG_PARALLELS=y" >> $config_host_mak
3549 if test "$plugins" = "yes" ; then
3550 echo "CONFIG_PLUGIN=y" >> $config_host_mak
3553 if test -n "$gdb_bin"; then
3554 gdb_version=$($gdb_bin --version | head -n 1)
3555 if version_ge ${gdb_version##* } 9.1; then
3556 echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
3560 if test "$secret_keyring" = "yes" ; then
3561 echo "CONFIG_SECRET_KEYRING=y" >> $config_host_mak
3564 echo "ROMS=$roms" >> $config_host_mak
3565 echo "MAKE=$make" >> $config_host_mak
3566 echo "PYTHON=$python" >> $config_host_mak
3567 echo "GENISOIMAGE=$genisoimage" >> $config_host_mak
3568 echo "MESON=$meson" >> $config_host_mak
3569 echo "NINJA=$ninja" >> $config_host_mak
3570 echo "CC=$cc" >> $config_host_mak
3571 echo "HOST_CC=$host_cc" >> $config_host_mak
3572 if $iasl -h > /dev/null 2>&1; then
3573 echo "CONFIG_IASL=$iasl" >> $config_host_mak
3575 echo "AR=$ar" >> $config_host_mak
3576 echo "AS=$as" >> $config_host_mak
3577 echo "CCAS=$ccas" >> $config_host_mak
3578 echo "CPP=$cpp" >> $config_host_mak
3579 echo "OBJCOPY=$objcopy" >> $config_host_mak
3580 echo "LD=$ld" >> $config_host_mak
3581 echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
3582 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
3583 echo "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
3584 echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
3585 echo "GLIB_LIBS=$glib_libs" >> $config_host_mak
3586 echo "GLIB_VERSION=$(pkg-config --modversion glib-2.0)" >> $config_host_mak
3587 echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
3588 echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
3589 echo "STRIP=$strip" >> $config_host_mak
3590 echo "EXESUF=$EXESUF" >> $config_host_mak
3591 echo "LIBS_QGA=$libs_qga" >> $config_host_mak
3593 if test "$rng_none" = "yes"; then
3594 echo "CONFIG_RNG_NONE=y" >> $config_host_mak
3597 # use included Linux headers
3598 if test "$linux" = "yes" ; then
3599 mkdir -p linux-headers
3600 case "$cpu" in
3601 i386|x86_64)
3602 linux_arch=x86
3604 ppc|ppc64)
3605 linux_arch=powerpc
3607 s390x)
3608 linux_arch=s390
3610 aarch64)
3611 linux_arch=arm64
3613 loongarch*)
3614 linux_arch=loongarch
3616 mips64)
3617 linux_arch=mips
3620 # For most CPUs the kernel architecture name and QEMU CPU name match.
3621 linux_arch="$cpu"
3623 esac
3624 # For non-KVM architectures we will not have asm headers
3625 if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
3626 symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
3630 for target in $target_list; do
3631 target_dir="$target"
3632 target_name=$(echo $target | cut -d '-' -f 1)$EXESUF
3633 mkdir -p $target_dir
3634 case $target in
3635 *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;;
3636 *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;;
3637 esac
3638 done
3640 echo "CONFIG_QEMU_INTERP_PREFIX=$interp_prefix" | sed 's/%M/@0@/' >> $config_host_mak
3641 if test "$default_targets" = "yes"; then
3642 echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak
3645 if test "$numa" = "yes"; then
3646 echo "CONFIG_NUMA=y" >> $config_host_mak
3647 echo "NUMA_LIBS=$numa_libs" >> $config_host_mak
3650 if test "$ccache_cpp2" = "yes"; then
3651 echo "export CCACHE_CPP2=y" >> $config_host_mak
3654 if test "$safe_stack" = "yes"; then
3655 echo "CONFIG_SAFESTACK=y" >> $config_host_mak
3658 # If we're using a separate build tree, set it up now.
3659 # LINKS are things to symlink back into the source tree
3660 # (these can be both files and directories).
3661 # Caution: do not add files or directories here using wildcards. This
3662 # will result in problems later if a new file matching the wildcard is
3663 # added to the source tree -- nothing will cause configure to be rerun
3664 # so the build tree will be missing the link back to the new file, and
3665 # tests might fail. Prefer to keep the relevant files in their own
3666 # directory and symlink the directory instead.
3667 LINKS="Makefile"
3668 LINKS="$LINKS tests/tcg/Makefile.target"
3669 LINKS="$LINKS pc-bios/optionrom/Makefile"
3670 LINKS="$LINKS pc-bios/s390-ccw/Makefile"
3671 LINKS="$LINKS roms/seabios/Makefile"
3672 LINKS="$LINKS pc-bios/qemu-icon.bmp"
3673 LINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
3674 LINKS="$LINKS tests/avocado tests/data"
3675 LINKS="$LINKS tests/qemu-iotests/check"
3676 LINKS="$LINKS python"
3677 LINKS="$LINKS contrib/plugins/Makefile "
3678 for bios_file in \
3679 $source_path/pc-bios/*.bin \
3680 $source_path/pc-bios/*.elf \
3681 $source_path/pc-bios/*.lid \
3682 $source_path/pc-bios/*.rom \
3683 $source_path/pc-bios/*.dtb \
3684 $source_path/pc-bios/*.img \
3685 $source_path/pc-bios/openbios-* \
3686 $source_path/pc-bios/u-boot.* \
3687 $source_path/pc-bios/palcode-* \
3688 $source_path/pc-bios/qemu_vga.ndrv
3691 LINKS="$LINKS pc-bios/$(basename $bios_file)"
3692 done
3693 for f in $LINKS ; do
3694 if [ -e "$source_path/$f" ]; then
3695 mkdir -p `dirname ./$f`
3696 symlink "$source_path/$f" "$f"
3698 done
3700 (for i in $cross_cc_vars; do
3701 export $i
3702 done
3703 export target_list source_path use_containers cpu
3704 $source_path/tests/tcg/configure.sh)
3706 # temporary config to build submodules
3707 if test -f $source_path/roms/seabios/Makefile; then
3708 for rom in seabios; do
3709 config_mak=roms/$rom/config.mak
3710 echo "# Automatically generated by configure - do not modify" > $config_mak
3711 echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
3712 echo "AS=$as" >> $config_mak
3713 echo "CCAS=$ccas" >> $config_mak
3714 echo "CC=$cc" >> $config_mak
3715 echo "BCC=bcc" >> $config_mak
3716 echo "CPP=$cpp" >> $config_mak
3717 echo "OBJCOPY=objcopy" >> $config_mak
3718 echo "IASL=$iasl" >> $config_mak
3719 echo "LD=$ld" >> $config_mak
3720 echo "RANLIB=$ranlib" >> $config_mak
3721 done
3724 config_mak=pc-bios/optionrom/config.mak
3725 echo "# Automatically generated by configure - do not modify" > $config_mak
3726 echo "TOPSRC_DIR=$source_path" >> $config_mak
3728 if test "$skip_meson" = no; then
3729 cross="config-meson.cross.new"
3730 meson_quote() {
3731 test $# = 0 && return
3732 echo "'$(echo $* | sed "s/ /','/g")'"
3735 echo "# Automatically generated by configure - do not modify" > $cross
3736 echo "[properties]" >> $cross
3738 # unroll any custom device configs
3739 for a in $device_archs; do
3740 eval "c=\$devices_${a}"
3741 echo "${a}-softmmu = '$c'" >> $cross
3742 done
3744 test -z "$cxx" && echo "link_language = 'c'" >> $cross
3745 echo "[built-in options]" >> $cross
3746 echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross
3747 echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross
3748 echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross
3749 echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross
3750 echo "[binaries]" >> $cross
3751 echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross
3752 test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross
3753 test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross
3754 echo "ar = [$(meson_quote $ar)]" >> $cross
3755 echo "nm = [$(meson_quote $nm)]" >> $cross
3756 echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross
3757 echo "ranlib = [$(meson_quote $ranlib)]" >> $cross
3758 if has $sdl2_config; then
3759 echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross
3761 echo "strip = [$(meson_quote $strip)]" >> $cross
3762 echo "windres = [$(meson_quote $windres)]" >> $cross
3763 if test "$cross_compile" = "yes"; then
3764 cross_arg="--cross-file config-meson.cross"
3765 echo "[host_machine]" >> $cross
3766 echo "system = '$targetos'" >> $cross
3767 case "$cpu" in
3768 i386)
3769 echo "cpu_family = 'x86'" >> $cross
3772 echo "cpu_family = '$cpu'" >> $cross
3774 esac
3775 echo "cpu = '$cpu'" >> $cross
3776 if test "$bigendian" = "yes" ; then
3777 echo "endian = 'big'" >> $cross
3778 else
3779 echo "endian = 'little'" >> $cross
3781 else
3782 cross_arg="--native-file config-meson.cross"
3784 mv $cross config-meson.cross
3786 rm -rf meson-private meson-info meson-logs
3787 run_meson() {
3788 NINJA=$ninja $meson setup \
3789 --prefix "$prefix" \
3790 --libdir "$libdir" \
3791 --libexecdir "$libexecdir" \
3792 --bindir "$bindir" \
3793 --includedir "$includedir" \
3794 --datadir "$datadir" \
3795 --mandir "$mandir" \
3796 --sysconfdir "$sysconfdir" \
3797 --localedir "$localedir" \
3798 --localstatedir "$local_statedir" \
3799 -Daudio_drv_list=$audio_drv_list \
3800 -Ddefault_devices=$default_devices \
3801 -Ddocdir="$docdir" \
3802 -Dqemu_firmwarepath="$firmwarepath" \
3803 -Dqemu_suffix="$qemu_suffix" \
3804 -Dsphinx_build="$sphinx_build" \
3805 -Dtrace_file="$trace_file" \
3806 -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) \
3807 -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo false; fi) \
3808 -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \
3809 -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \
3810 -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \
3811 -Db_lto=$lto -Dcfi=$cfi -Dtcg=$tcg -Dxen=$xen \
3812 -Dcapstone=$capstone -Dfdt=$fdt -Dslirp=$slirp \
3813 $(test -n "${LIB_FUZZING_ENGINE+xxx}" && echo "-Dfuzzing_engine=$LIB_FUZZING_ENGINE") \
3814 $(if test "$default_feature" = no; then echo "-Dauto_features=disabled"; fi) \
3815 "$@" $cross_arg "$PWD" "$source_path"
3817 eval run_meson $meson_options
3818 if test "$?" -ne 0 ; then
3819 error_exit "meson setup failed"
3821 else
3822 if test -f meson-private/cmd_line.txt; then
3823 # Adjust old command line options whose type was changed
3824 # Avoids having to use "setup --wipe" when Meson is upgraded
3825 perl -i -ne '
3826 s/^gettext = true$/gettext = auto/;
3827 s/^gettext = false$/gettext = disabled/;
3828 /^b_staticpic/ && next;
3829 print;' meson-private/cmd_line.txt
3833 if test -n "${deprecated_features}"; then
3834 echo "Warning, deprecated features enabled."
3835 echo "Please see docs/about/deprecated.rst"
3836 echo " features: ${deprecated_features}"
3839 # Save the configure command line for later reuse.
3840 cat <<EOD >config.status
3841 #!/bin/sh
3842 # Generated by configure.
3843 # Run this file to recreate the current configuration.
3844 # Compiler output produced by configure, useful for debugging
3845 # configure, is in config.log if it exists.
3848 preserve_env() {
3849 envname=$1
3851 eval envval=\$$envname
3853 if test -n "$envval"
3854 then
3855 echo "$envname='$envval'" >> config.status
3856 echo "export $envname" >> config.status
3857 else
3858 echo "unset $envname" >> config.status
3862 # Preserve various env variables that influence what
3863 # features/build target configure will detect
3864 preserve_env AR
3865 preserve_env AS
3866 preserve_env CC
3867 preserve_env CPP
3868 preserve_env CFLAGS
3869 preserve_env CXX
3870 preserve_env CXXFLAGS
3871 preserve_env INSTALL
3872 preserve_env LD
3873 preserve_env LDFLAGS
3874 preserve_env LD_LIBRARY_PATH
3875 preserve_env LIBTOOL
3876 preserve_env MAKE
3877 preserve_env NM
3878 preserve_env OBJCOPY
3879 preserve_env PATH
3880 preserve_env PKG_CONFIG
3881 preserve_env PKG_CONFIG_LIBDIR
3882 preserve_env PKG_CONFIG_PATH
3883 preserve_env PYTHON
3884 preserve_env SDL2_CONFIG
3885 preserve_env SMBD
3886 preserve_env STRIP
3887 preserve_env WINDRES
3889 printf "exec" >>config.status
3890 for i in "$0" "$@"; do
3891 test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status
3892 done
3893 echo ' "$@"' >>config.status
3894 chmod +x config.status
3896 rm -r "$TMPDIR1"