]> git.proxmox.com Git - mirror_qemu.git/blob - configure
linux-user/host/sparc: Populate host_signal.h
[mirror_qemu.git] / configure
1 #!/bin/sh
2 #
3 # qemu configure script (c) 2003 Fabrice Bellard
4 #
5
6 # Unset some variables known to interfere with behavior of common tools,
7 # just as autoconf does.
8 CLICOLOR_FORCE= GREP_OPTIONS=
9 unset CLICOLOR_FORCE GREP_OPTIONS
10
11 # Don't allow CCACHE, if present, to use cached results of compile tests!
12 export CCACHE_RECACHE=yes
13
14 # make source path absolute
15 source_path=$(cd "$(dirname -- "$0")"; pwd)
16
17 if test "$PWD" = "$source_path"
18 then
19 echo "Using './build' as the directory for build output"
20
21 MARKER=build/auto-created-by-configure
22
23 if test -e build
24 then
25 if test -f $MARKER
26 then
27 rm -rf build
28 else
29 echo "ERROR: ./build dir already exists and was not previously created by configure"
30 exit 1
31 fi
32 fi
33
34 mkdir build
35 touch $MARKER
36
37 cat > GNUmakefile <<'EOF'
38 # This file is auto-generated by configure to support in-source tree
39 # 'make' command invocation
40
41 ifeq ($(MAKECMDGOALS),)
42 recurse: all
43 endif
44
45 .NOTPARALLEL: %
46 %: force
47 @echo 'changing dir to build for $(MAKE) "$(MAKECMDGOALS)"...'
48 @$(MAKE) -C build -f Makefile $(MAKECMDGOALS)
49 @if test "$(MAKECMDGOALS)" = "distclean" && \
50 test -e build/auto-created-by-configure ; \
51 then \
52 rm -rf build GNUmakefile ; \
53 fi
54 force: ;
55 .PHONY: force
56 GNUmakefile: ;
57
58 EOF
59 cd build
60 exec $source_path/configure "$@"
61 fi
62
63 # Temporary directory used for files created while
64 # configure runs. Since it is in the build directory
65 # we can safely blow away any previous version of it
66 # (and we need not jump through hoops to try to delete
67 # it when configure exits.)
68 TMPDIR1="config-temp"
69 rm -rf "${TMPDIR1}"
70 mkdir -p "${TMPDIR1}"
71 if [ $? -ne 0 ]; then
72 echo "ERROR: failed to create temporary directory"
73 exit 1
74 fi
75
76 TMPB="qemu-conf"
77 TMPC="${TMPDIR1}/${TMPB}.c"
78 TMPO="${TMPDIR1}/${TMPB}.o"
79 TMPCXX="${TMPDIR1}/${TMPB}.cxx"
80 TMPE="${TMPDIR1}/${TMPB}.exe"
81 TMPTXT="${TMPDIR1}/${TMPB}.txt"
82
83 rm -f config.log
84
85 # Print a helpful header at the top of config.log
86 echo "# QEMU configure log $(date)" >> config.log
87 printf "# Configured with:" >> config.log
88 printf " '%s'" "$0" "$@" >> config.log
89 echo >> config.log
90 echo "#" >> config.log
91
92 quote_sh() {
93 printf "%s" "$1" | sed "s,','\\\\'',g; s,.*,'&',"
94 }
95
96 print_error() {
97 (echo
98 echo "ERROR: $1"
99 while test -n "$2"; do
100 echo " $2"
101 shift
102 done
103 echo) >&2
104 }
105
106 error_exit() {
107 print_error "$@"
108 exit 1
109 }
110
111 do_compiler() {
112 # Run the compiler, capturing its output to the log. First argument
113 # is compiler binary to execute.
114 compiler="$1"
115 shift
116 if test -n "$BASH_VERSION"; then eval '
117 echo >>config.log "
118 funcs: ${FUNCNAME[*]}
119 lines: ${BASH_LINENO[*]}"
120 '; fi
121 echo $compiler "$@" >> config.log
122 $compiler "$@" >> config.log 2>&1 || return $?
123 # Test passed. If this is an --enable-werror build, rerun
124 # the test with -Werror and bail out if it fails. This
125 # makes warning-generating-errors in configure test code
126 # obvious to developers.
127 if test "$werror" != "yes"; then
128 return 0
129 fi
130 # Don't bother rerunning the compile if we were already using -Werror
131 case "$*" in
132 *-Werror*)
133 return 0
134 ;;
135 esac
136 echo $compiler -Werror "$@" >> config.log
137 $compiler -Werror "$@" >> config.log 2>&1 && return $?
138 error_exit "configure test passed without -Werror but failed with -Werror." \
139 "This is probably a bug in the configure script. The failing command" \
140 "will be at the bottom of config.log." \
141 "You can run configure with --disable-werror to bypass this check."
142 }
143
144 do_cc() {
145 do_compiler "$cc" $CPU_CFLAGS "$@"
146 }
147
148 do_cxx() {
149 do_compiler "$cxx" $CPU_CFLAGS "$@"
150 }
151
152 # Append $2 to the variable named $1, with space separation
153 add_to() {
154 eval $1=\${$1:+\"\$$1 \"}\$2
155 }
156
157 update_cxxflags() {
158 # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
159 # options which some versions of GCC's C++ compiler complain about
160 # because they only make sense for C programs.
161 QEMU_CXXFLAGS="$QEMU_CXXFLAGS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS"
162 CONFIGURE_CXXFLAGS=$(echo "$CONFIGURE_CFLAGS" | sed s/-std=gnu11/-std=gnu++11/)
163 for arg in $QEMU_CFLAGS; do
164 case $arg in
165 -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
166 -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
167 ;;
168 *)
169 QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
170 ;;
171 esac
172 done
173 }
174
175 compile_object() {
176 local_cflags="$1"
177 do_cc $CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
178 }
179
180 compile_prog() {
181 local_cflags="$1"
182 local_ldflags="$2"
183 do_cc $CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC \
184 $LDFLAGS $CONFIGURE_LDFLAGS $QEMU_LDFLAGS $local_ldflags
185 }
186
187 # symbolically link $1 to $2. Portable version of "ln -sf".
188 symlink() {
189 rm -rf "$2"
190 mkdir -p "$(dirname "$2")"
191 ln -s "$1" "$2"
192 }
193
194 # check whether a command is available to this shell (may be either an
195 # executable or a builtin)
196 has() {
197 type "$1" >/dev/null 2>&1
198 }
199
200 version_ge () {
201 local_ver1=$(expr "$1" : '\([0-9.]*\)' | tr . ' ')
202 local_ver2=$(echo "$2" | tr . ' ')
203 while true; do
204 set x $local_ver1
205 local_first=${2-0}
206 # 'shift 2' if $2 is set, or 'shift' if $2 is not set
207 shift ${2:+2}
208 local_ver1=$*
209 set x $local_ver2
210 # the second argument finished, the first must be greater or equal
211 test $# = 1 && return 0
212 test $local_first -lt $2 && return 1
213 test $local_first -gt $2 && return 0
214 shift ${2:+2}
215 local_ver2=$*
216 done
217 }
218
219 glob() {
220 eval test -z '"${1#'"$2"'}"'
221 }
222
223 ld_has() {
224 $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
225 }
226
227 if printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]";
228 then
229 error_exit "main directory cannot contain spaces nor colons"
230 fi
231
232 # default parameters
233 cpu=""
234 iasl="iasl"
235 interp_prefix="/usr/gnemul/qemu-%M"
236 static="no"
237 cross_compile="no"
238 cross_prefix=""
239 audio_drv_list="default"
240 block_drv_rw_whitelist=""
241 block_drv_ro_whitelist=""
242 block_drv_whitelist_tools="no"
243 host_cc="cc"
244 libs_qga=""
245 debug_info="yes"
246 lto="false"
247 stack_protector=""
248 safe_stack=""
249 use_containers="yes"
250 gdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
251
252 if test -e "$source_path/.git"
253 then
254 git_submodules_action="update"
255 else
256 git_submodules_action="ignore"
257 fi
258
259 git_submodules="ui/keycodemapdb"
260 git="git"
261
262 # Don't accept a target_list environment variable.
263 unset target_list
264 unset target_list_exclude
265
266 # Default value for a variable defining feature "foo".
267 # * foo="no" feature will only be used if --enable-foo arg is given
268 # * foo="" feature will be searched for, and if found, will be used
269 # unless --disable-foo is given
270 # * foo="yes" this value will only be set by --enable-foo flag.
271 # feature will searched for,
272 # if not found, configure exits with error
273 #
274 # Always add --enable-foo and --disable-foo command line args.
275 # Distributions want to ensure that several features are compiled in, and it
276 # is impossible without a --enable-foo that exits if a feature is not found.
277
278 default_feature=""
279 # parse CC options second
280 for opt do
281 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
282 case "$opt" in
283 --without-default-features)
284 default_feature="no"
285 ;;
286 esac
287 done
288
289 xen_ctrl_version="$default_feature"
290 xfs="$default_feature"
291 membarrier="$default_feature"
292 vhost_kernel="$default_feature"
293 vhost_net="$default_feature"
294 vhost_crypto="$default_feature"
295 vhost_scsi="$default_feature"
296 vhost_vsock="$default_feature"
297 vhost_user="no"
298 vhost_user_fs="$default_feature"
299 vhost_vdpa="$default_feature"
300 rdma="$default_feature"
301 pvrdma="$default_feature"
302 gprof="no"
303 debug_tcg="no"
304 debug="no"
305 sanitizers="no"
306 tsan="no"
307 fortify_source="$default_feature"
308 strip_opt="yes"
309 mingw32="no"
310 gcov="no"
311 EXESUF=""
312 modules="no"
313 module_upgrades="no"
314 prefix="/usr/local"
315 qemu_suffix="qemu"
316 bsd="no"
317 linux="no"
318 solaris="no"
319 profiler="no"
320 softmmu="yes"
321 linux_user="no"
322 bsd_user="no"
323 pkgversion=""
324 pie=""
325 qom_cast_debug="yes"
326 trace_backends="log"
327 trace_file="trace"
328 opengl="$default_feature"
329 cpuid_h="no"
330 avx2_opt="$default_feature"
331 guest_agent="$default_feature"
332 guest_agent_with_vss="no"
333 guest_agent_ntddscsi="no"
334 vss_win32_sdk="$default_feature"
335 win_sdk="no"
336 want_tools="$default_feature"
337 coroutine=""
338 coroutine_pool="$default_feature"
339 debug_stack_usage="no"
340 crypto_afalg="no"
341 tls_priority="NORMAL"
342 tpm="$default_feature"
343 libssh="$default_feature"
344 live_block_migration=${default_feature:-yes}
345 numa="$default_feature"
346 replication=${default_feature:-yes}
347 bochs=${default_feature:-yes}
348 cloop=${default_feature:-yes}
349 dmg=${default_feature:-yes}
350 qcow1=${default_feature:-yes}
351 vdi=${default_feature:-yes}
352 vvfat=${default_feature:-yes}
353 qed=${default_feature:-yes}
354 parallels=${default_feature:-yes}
355 debug_mutex="no"
356 plugins="$default_feature"
357 rng_none="no"
358 secret_keyring="$default_feature"
359 meson=""
360 meson_args=""
361 ninja=""
362 gio="$default_feature"
363 skip_meson=no
364 slirp_smbd="$default_feature"
365
366 # The following Meson options are handled manually (still they
367 # are included in the automatically generated help message)
368
369 # 1. Track which submodules are needed
370 capstone="auto"
371 fdt="auto"
372 slirp="auto"
373
374 # 2. Support --with/--without option
375 default_devices="true"
376
377 # 3. Automatically enable/disable other options
378 tcg="enabled"
379 cfi="false"
380
381 # 4. Detection partly done in configure
382 xen=${default_feature:+disabled}
383
384 # parse CC options second
385 for opt do
386 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
387 case "$opt" in
388 --cross-prefix=*) cross_prefix="$optarg"
389 cross_compile="yes"
390 ;;
391 --cc=*) CC="$optarg"
392 ;;
393 --cxx=*) CXX="$optarg"
394 ;;
395 --cpu=*) cpu="$optarg"
396 ;;
397 --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
398 QEMU_LDFLAGS="$QEMU_LDFLAGS $optarg"
399 ;;
400 --extra-cxxflags=*) QEMU_CXXFLAGS="$QEMU_CXXFLAGS $optarg"
401 ;;
402 --extra-ldflags=*) QEMU_LDFLAGS="$QEMU_LDFLAGS $optarg"
403 EXTRA_LDFLAGS="$optarg"
404 ;;
405 --enable-debug-info) debug_info="yes"
406 ;;
407 --disable-debug-info) debug_info="no"
408 ;;
409 --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
410 ;;
411 --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-flags-}; cc_arch=${cc_arch%%=*}
412 eval "cross_cc_cflags_${cc_arch}=\$optarg"
413 cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}"
414 ;;
415 --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
416 cc_archs="$cc_archs $cc_arch"
417 eval "cross_cc_${cc_arch}=\$optarg"
418 cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}"
419 ;;
420 esac
421 done
422 # OS specific
423 # Using uname is really, really broken. Once we have the right set of checks
424 # we can eliminate its usage altogether.
425
426 # Preferred compiler:
427 # ${CC} (if set)
428 # ${cross_prefix}gcc (if cross-prefix specified)
429 # system compiler
430 if test -z "${CC}${cross_prefix}"; then
431 cc="$host_cc"
432 else
433 cc="${CC-${cross_prefix}gcc}"
434 fi
435
436 if test -z "${CXX}${cross_prefix}"; then
437 cxx="c++"
438 else
439 cxx="${CXX-${cross_prefix}g++}"
440 fi
441
442 ar="${AR-${cross_prefix}ar}"
443 as="${AS-${cross_prefix}as}"
444 ccas="${CCAS-$cc}"
445 cpp="${CPP-$cc -E}"
446 objcopy="${OBJCOPY-${cross_prefix}objcopy}"
447 ld="${LD-${cross_prefix}ld}"
448 ranlib="${RANLIB-${cross_prefix}ranlib}"
449 nm="${NM-${cross_prefix}nm}"
450 strip="${STRIP-${cross_prefix}strip}"
451 windres="${WINDRES-${cross_prefix}windres}"
452 pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
453 query_pkg_config() {
454 "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
455 }
456 pkg_config=query_pkg_config
457 sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
458
459 # default flags for all hosts
460 # We use -fwrapv to tell the compiler that we require a C dialect where
461 # left shift of signed integers is well defined and has the expected
462 # 2s-complement style results. (Both clang and gcc agree that it
463 # provides these semantics.)
464 QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
465 QEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
466 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
467 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
468
469 # Flags that are needed during configure but later taken care of by Meson
470 CONFIGURE_CFLAGS="-std=gnu11 -Wall"
471 CONFIGURE_LDFLAGS=
472
473
474 check_define() {
475 cat > $TMPC <<EOF
476 #if !defined($1)
477 #error $1 not defined
478 #endif
479 int main(void) { return 0; }
480 EOF
481 compile_object
482 }
483
484 check_include() {
485 cat > $TMPC <<EOF
486 #include <$1>
487 int main(void) { return 0; }
488 EOF
489 compile_object
490 }
491
492 write_c_skeleton() {
493 cat > $TMPC <<EOF
494 int main(void) { return 0; }
495 EOF
496 }
497
498 if check_define __linux__ ; then
499 targetos="Linux"
500 elif check_define _WIN32 ; then
501 targetos='MINGW32'
502 elif check_define __OpenBSD__ ; then
503 targetos='OpenBSD'
504 elif check_define __sun__ ; then
505 targetos='SunOS'
506 elif check_define __HAIKU__ ; then
507 targetos='Haiku'
508 elif check_define __FreeBSD__ ; then
509 targetos='FreeBSD'
510 elif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
511 targetos='GNU/kFreeBSD'
512 elif check_define __DragonFly__ ; then
513 targetos='DragonFly'
514 elif check_define __NetBSD__; then
515 targetos='NetBSD'
516 elif check_define __APPLE__; then
517 targetos='Darwin'
518 else
519 # This is a fatal error, but don't report it yet, because we
520 # might be going to just print the --help text, or it might
521 # be the result of a missing compiler.
522 targetos='bogus'
523 fi
524
525 # Some host OSes need non-standard checks for which CPU to use.
526 # Note that these checks are broken for cross-compilation: if you're
527 # cross-compiling to one of these OSes then you'll need to specify
528 # the correct CPU with the --cpu option.
529 case $targetos in
530 SunOS)
531 # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
532 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
533 cpu="x86_64"
534 fi
535 esac
536
537 if test ! -z "$cpu" ; then
538 # command line argument
539 :
540 elif check_define __i386__ ; then
541 cpu="i386"
542 elif check_define __x86_64__ ; then
543 if check_define __ILP32__ ; then
544 cpu="x32"
545 else
546 cpu="x86_64"
547 fi
548 elif check_define __sparc__ ; then
549 if check_define __arch64__ ; then
550 cpu="sparc64"
551 else
552 cpu="sparc"
553 fi
554 elif check_define _ARCH_PPC ; then
555 if check_define _ARCH_PPC64 ; then
556 if check_define _LITTLE_ENDIAN ; then
557 cpu="ppc64le"
558 else
559 cpu="ppc64"
560 fi
561 else
562 cpu="ppc"
563 fi
564 elif check_define __mips__ ; then
565 cpu="mips"
566 elif check_define __s390__ ; then
567 if check_define __s390x__ ; then
568 cpu="s390x"
569 else
570 cpu="s390"
571 fi
572 elif check_define __riscv ; then
573 cpu="riscv"
574 elif check_define __arm__ ; then
575 cpu="arm"
576 elif check_define __aarch64__ ; then
577 cpu="aarch64"
578 else
579 cpu=$(uname -m)
580 fi
581
582 ARCH=
583 # Normalise host CPU name and set ARCH.
584 # Note that this case should only have supported host CPUs, not guests.
585 case "$cpu" in
586 ppc|ppc64|s390x|sparc64|x32|riscv)
587 ;;
588 ppc64le)
589 ARCH="ppc64"
590 ;;
591 i386|i486|i586|i686|i86pc|BePC)
592 cpu="i386"
593 ;;
594 x86_64|amd64)
595 cpu="x86_64"
596 ;;
597 armv*b|armv*l|arm)
598 cpu="arm"
599 ;;
600 aarch64)
601 cpu="aarch64"
602 ;;
603 mips*)
604 cpu="mips"
605 ;;
606 sparc|sun4[cdmuv])
607 cpu="sparc"
608 ;;
609 *)
610 # This will result in either an error or falling back to TCI later
611 ARCH=unknown
612 ;;
613 esac
614 if test -z "$ARCH"; then
615 ARCH="$cpu"
616 fi
617
618 # OS specific
619
620 case $targetos in
621 MINGW32*)
622 mingw32="yes"
623 supported_os="yes"
624 plugins="no"
625 pie="no"
626 ;;
627 GNU/kFreeBSD)
628 bsd="yes"
629 ;;
630 FreeBSD)
631 bsd="yes"
632 bsd_user="yes"
633 make="${MAKE-gmake}"
634 # needed for kinfo_getvmmap(3) in libutil.h
635 ;;
636 DragonFly)
637 bsd="yes"
638 make="${MAKE-gmake}"
639 ;;
640 NetBSD)
641 bsd="yes"
642 make="${MAKE-gmake}"
643 ;;
644 OpenBSD)
645 bsd="yes"
646 make="${MAKE-gmake}"
647 ;;
648 Darwin)
649 bsd="yes"
650 darwin="yes"
651 # Disable attempts to use ObjectiveC features in os/object.h since they
652 # won't work when we're compiling with gcc as a C compiler.
653 QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
654 ;;
655 SunOS)
656 solaris="yes"
657 make="${MAKE-gmake}"
658 smbd="${SMBD-/usr/sfw/sbin/smbd}"
659 # needed for CMSG_ macros in sys/socket.h
660 QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
661 # needed for TIOCWIN* defines in termios.h
662 QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
663 ;;
664 Haiku)
665 haiku="yes"
666 pie="no"
667 QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE -fPIC $QEMU_CFLAGS"
668 ;;
669 Linux)
670 linux="yes"
671 linux_user="yes"
672 vhost_user=${default_feature:-yes}
673 ;;
674 esac
675
676 : ${make=${MAKE-make}}
677
678 # We prefer python 3.x. A bare 'python' is traditionally
679 # python 2.x, but some distros have it as python 3.x, so
680 # we check that too
681 python=
682 explicit_python=no
683 for binary in "${PYTHON-python3}" python
684 do
685 if has "$binary"
686 then
687 python=$(command -v "$binary")
688 break
689 fi
690 done
691
692
693 # Check for ancillary tools used in testing
694 genisoimage=
695 for binary in genisoimage mkisofs
696 do
697 if has $binary
698 then
699 genisoimage=$(command -v "$binary")
700 break
701 fi
702 done
703
704 # Default objcc to clang if available, otherwise use CC
705 if has clang; then
706 objcc=clang
707 else
708 objcc="$cc"
709 fi
710
711 if test "$mingw32" = "yes" ; then
712 EXESUF=".exe"
713 # MinGW needs -mthreads for TLS and macro _MT.
714 CONFIGURE_CFLAGS="-mthreads $CONFIGURE_CFLAGS"
715 write_c_skeleton;
716 prefix="/qemu"
717 qemu_suffix=""
718 libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
719 fi
720
721 werror=""
722
723 . $source_path/scripts/meson-buildoptions.sh
724
725 meson_options=
726 meson_option_parse() {
727 meson_options="$meson_options $(_meson_option_parse "$@")"
728 if test $? -eq 1; then
729 echo "ERROR: unknown option $1"
730 echo "Try '$0 --help' for more information"
731 exit 1
732 fi
733 }
734
735 for opt do
736 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
737 case "$opt" in
738 --help|-h) show_help=yes
739 ;;
740 --version|-V) exec cat $source_path/VERSION
741 ;;
742 --prefix=*) prefix="$optarg"
743 ;;
744 --interp-prefix=*) interp_prefix="$optarg"
745 ;;
746 --cross-prefix=*)
747 ;;
748 --cc=*)
749 ;;
750 --host-cc=*) host_cc="$optarg"
751 ;;
752 --cxx=*)
753 ;;
754 --iasl=*) iasl="$optarg"
755 ;;
756 --objcc=*) objcc="$optarg"
757 ;;
758 --make=*) make="$optarg"
759 ;;
760 --install=*)
761 ;;
762 --python=*) python="$optarg" ; explicit_python=yes
763 ;;
764 --sphinx-build=*) sphinx_build="$optarg"
765 ;;
766 --skip-meson) skip_meson=yes
767 ;;
768 --meson=*) meson="$optarg"
769 ;;
770 --ninja=*) ninja="$optarg"
771 ;;
772 --smbd=*) smbd="$optarg"
773 ;;
774 --extra-cflags=*)
775 ;;
776 --extra-cxxflags=*)
777 ;;
778 --extra-ldflags=*)
779 ;;
780 --enable-debug-info)
781 ;;
782 --disable-debug-info)
783 ;;
784 --cross-cc-*)
785 ;;
786 --enable-modules)
787 modules="yes"
788 ;;
789 --disable-modules)
790 modules="no"
791 ;;
792 --disable-module-upgrades) module_upgrades="no"
793 ;;
794 --enable-module-upgrades) module_upgrades="yes"
795 ;;
796 --cpu=*)
797 ;;
798 --target-list=*) target_list="$optarg"
799 if test "$target_list_exclude"; then
800 error_exit "Can't mix --target-list with --target-list-exclude"
801 fi
802 ;;
803 --target-list-exclude=*) target_list_exclude="$optarg"
804 if test "$target_list"; then
805 error_exit "Can't mix --target-list-exclude with --target-list"
806 fi
807 ;;
808 --with-trace-file=*) trace_file="$optarg"
809 ;;
810 --with-default-devices) default_devices="true"
811 ;;
812 --without-default-devices) default_devices="false"
813 ;;
814 --with-devices-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --with-devices-FOO option"
815 ;;
816 --with-devices-*) device_arch=${opt#--with-devices-};
817 device_arch=${device_arch%%=*}
818 cf=$source_path/configs/devices/$device_arch-softmmu/$optarg.mak
819 if test -f "$cf"; then
820 device_archs="$device_archs $device_arch"
821 eval "devices_${device_arch}=\$optarg"
822 else
823 error_exit "File $cf does not exist"
824 fi
825 ;;
826 --without-default-features) # processed above
827 ;;
828 --enable-gprof) gprof="yes"
829 ;;
830 --enable-gcov) gcov="yes"
831 ;;
832 --static)
833 static="yes"
834 QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
835 ;;
836 --mandir=*) mandir="$optarg"
837 ;;
838 --bindir=*) bindir="$optarg"
839 ;;
840 --libdir=*) libdir="$optarg"
841 ;;
842 --libexecdir=*) libexecdir="$optarg"
843 ;;
844 --includedir=*) includedir="$optarg"
845 ;;
846 --datadir=*) datadir="$optarg"
847 ;;
848 --with-suffix=*) qemu_suffix="$optarg"
849 ;;
850 --docdir=*) docdir="$optarg"
851 ;;
852 --localedir=*) localedir="$optarg"
853 ;;
854 --sysconfdir=*) sysconfdir="$optarg"
855 ;;
856 --localstatedir=*) local_statedir="$optarg"
857 ;;
858 --firmwarepath=*) firmwarepath="$optarg"
859 ;;
860 --host=*|--build=*|\
861 --disable-dependency-tracking|\
862 --sbindir=*|--sharedstatedir=*|\
863 --oldincludedir=*|--datarootdir=*|--infodir=*|\
864 --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
865 # These switches are silently ignored, for compatibility with
866 # autoconf-generated configure scripts. This allows QEMU's
867 # configure to be used by RPM and similar macros that set
868 # lots of directory switches by default.
869 ;;
870 --disable-qom-cast-debug) qom_cast_debug="no"
871 ;;
872 --enable-qom-cast-debug) qom_cast_debug="yes"
873 ;;
874 --audio-drv-list=*) audio_drv_list="$optarg"
875 ;;
876 --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
877 ;;
878 --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
879 ;;
880 --enable-block-drv-whitelist-in-tools) block_drv_whitelist_tools="yes"
881 ;;
882 --disable-block-drv-whitelist-in-tools) block_drv_whitelist_tools="no"
883 ;;
884 --enable-debug-tcg) debug_tcg="yes"
885 ;;
886 --disable-debug-tcg) debug_tcg="no"
887 ;;
888 --enable-debug)
889 # Enable debugging options that aren't excessively noisy
890 debug_tcg="yes"
891 debug_mutex="yes"
892 debug="yes"
893 strip_opt="no"
894 fortify_source="no"
895 ;;
896 --enable-sanitizers) sanitizers="yes"
897 ;;
898 --disable-sanitizers) sanitizers="no"
899 ;;
900 --enable-tsan) tsan="yes"
901 ;;
902 --disable-tsan) tsan="no"
903 ;;
904 --disable-strip) strip_opt="no"
905 ;;
906 --disable-slirp) slirp="disabled"
907 ;;
908 --enable-slirp) slirp="enabled"
909 ;;
910 --enable-slirp=git) slirp="internal"
911 ;;
912 --enable-slirp=*) slirp="$optarg"
913 ;;
914 --disable-xen) xen="disabled"
915 ;;
916 --enable-xen) xen="enabled"
917 ;;
918 --disable-tcg) tcg="disabled"
919 plugins="no"
920 ;;
921 --enable-tcg) tcg="enabled"
922 ;;
923 --enable-profiler) profiler="yes"
924 ;;
925 --disable-system) softmmu="no"
926 ;;
927 --enable-system) softmmu="yes"
928 ;;
929 --disable-user)
930 linux_user="no" ;
931 bsd_user="no" ;
932 ;;
933 --enable-user) ;;
934 --disable-linux-user) linux_user="no"
935 ;;
936 --enable-linux-user) linux_user="yes"
937 ;;
938 --disable-bsd-user) bsd_user="no"
939 ;;
940 --enable-bsd-user) bsd_user="yes"
941 ;;
942 --enable-pie) pie="yes"
943 ;;
944 --disable-pie) pie="no"
945 ;;
946 --enable-werror) werror="yes"
947 ;;
948 --disable-werror) werror="no"
949 ;;
950 --enable-lto) lto="true"
951 ;;
952 --disable-lto) lto="false"
953 ;;
954 --enable-stack-protector) stack_protector="yes"
955 ;;
956 --disable-stack-protector) stack_protector="no"
957 ;;
958 --enable-safe-stack) safe_stack="yes"
959 ;;
960 --disable-safe-stack) safe_stack="no"
961 ;;
962 --enable-cfi)
963 cfi="true";
964 lto="true";
965 ;;
966 --disable-cfi) cfi="false"
967 ;;
968 --disable-fdt) fdt="disabled"
969 ;;
970 --enable-fdt) fdt="enabled"
971 ;;
972 --enable-fdt=git) fdt="internal"
973 ;;
974 --enable-fdt=*) fdt="$optarg"
975 ;;
976 --disable-membarrier) membarrier="no"
977 ;;
978 --enable-membarrier) membarrier="yes"
979 ;;
980 --with-pkgversion=*) pkgversion="$optarg"
981 ;;
982 --with-coroutine=*) coroutine="$optarg"
983 ;;
984 --disable-coroutine-pool) coroutine_pool="no"
985 ;;
986 --enable-coroutine-pool) coroutine_pool="yes"
987 ;;
988 --enable-debug-stack-usage) debug_stack_usage="yes"
989 ;;
990 --enable-crypto-afalg) crypto_afalg="yes"
991 ;;
992 --disable-crypto-afalg) crypto_afalg="no"
993 ;;
994 --disable-vhost-net) vhost_net="no"
995 ;;
996 --enable-vhost-net) vhost_net="yes"
997 ;;
998 --disable-vhost-crypto) vhost_crypto="no"
999 ;;
1000 --enable-vhost-crypto) vhost_crypto="yes"
1001 ;;
1002 --disable-vhost-scsi) vhost_scsi="no"
1003 ;;
1004 --enable-vhost-scsi) vhost_scsi="yes"
1005 ;;
1006 --disable-vhost-vsock) vhost_vsock="no"
1007 ;;
1008 --enable-vhost-vsock) vhost_vsock="yes"
1009 ;;
1010 --disable-vhost-user-fs) vhost_user_fs="no"
1011 ;;
1012 --enable-vhost-user-fs) vhost_user_fs="yes"
1013 ;;
1014 --disable-opengl) opengl="no"
1015 ;;
1016 --enable-opengl) opengl="yes"
1017 ;;
1018 --disable-xfsctl) xfs="no"
1019 ;;
1020 --enable-xfsctl) xfs="yes"
1021 ;;
1022 --disable-zlib-test)
1023 ;;
1024 --enable-guest-agent) guest_agent="yes"
1025 ;;
1026 --disable-guest-agent) guest_agent="no"
1027 ;;
1028 --with-vss-sdk) vss_win32_sdk=""
1029 ;;
1030 --with-vss-sdk=*) vss_win32_sdk="$optarg"
1031 ;;
1032 --without-vss-sdk) vss_win32_sdk="no"
1033 ;;
1034 --with-win-sdk) win_sdk=""
1035 ;;
1036 --with-win-sdk=*) win_sdk="$optarg"
1037 ;;
1038 --without-win-sdk) win_sdk="no"
1039 ;;
1040 --enable-tools) want_tools="yes"
1041 ;;
1042 --disable-tools) want_tools="no"
1043 ;;
1044 --disable-avx2) avx2_opt="no"
1045 ;;
1046 --enable-avx2) avx2_opt="yes"
1047 ;;
1048 --disable-avx512f) avx512f_opt="no"
1049 ;;
1050 --enable-avx512f) avx512f_opt="yes"
1051 ;;
1052 --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
1053 echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1054 ;;
1055 --enable-vhdx|--disable-vhdx)
1056 echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1057 ;;
1058 --enable-uuid|--disable-uuid)
1059 echo "$0: $opt is obsolete, UUID support is always built" >&2
1060 ;;
1061 --tls-priority=*) tls_priority="$optarg"
1062 ;;
1063 --enable-rdma) rdma="yes"
1064 ;;
1065 --disable-rdma) rdma="no"
1066 ;;
1067 --enable-pvrdma) pvrdma="yes"
1068 ;;
1069 --disable-pvrdma) pvrdma="no"
1070 ;;
1071 --disable-tpm) tpm="no"
1072 ;;
1073 --enable-tpm) tpm="yes"
1074 ;;
1075 --disable-libssh) libssh="no"
1076 ;;
1077 --enable-libssh) libssh="yes"
1078 ;;
1079 --disable-live-block-migration) live_block_migration="no"
1080 ;;
1081 --enable-live-block-migration) live_block_migration="yes"
1082 ;;
1083 --disable-numa) numa="no"
1084 ;;
1085 --enable-numa) numa="yes"
1086 ;;
1087 --disable-replication) replication="no"
1088 ;;
1089 --enable-replication) replication="yes"
1090 ;;
1091 --disable-bochs) bochs="no"
1092 ;;
1093 --enable-bochs) bochs="yes"
1094 ;;
1095 --disable-cloop) cloop="no"
1096 ;;
1097 --enable-cloop) cloop="yes"
1098 ;;
1099 --disable-dmg) dmg="no"
1100 ;;
1101 --enable-dmg) dmg="yes"
1102 ;;
1103 --disable-qcow1) qcow1="no"
1104 ;;
1105 --enable-qcow1) qcow1="yes"
1106 ;;
1107 --disable-vdi) vdi="no"
1108 ;;
1109 --enable-vdi) vdi="yes"
1110 ;;
1111 --disable-vvfat) vvfat="no"
1112 ;;
1113 --enable-vvfat) vvfat="yes"
1114 ;;
1115 --disable-qed) qed="no"
1116 ;;
1117 --enable-qed) qed="yes"
1118 ;;
1119 --disable-parallels) parallels="no"
1120 ;;
1121 --enable-parallels) parallels="yes"
1122 ;;
1123 --disable-vhost-user) vhost_user="no"
1124 ;;
1125 --enable-vhost-user) vhost_user="yes"
1126 ;;
1127 --disable-vhost-vdpa) vhost_vdpa="no"
1128 ;;
1129 --enable-vhost-vdpa) vhost_vdpa="yes"
1130 ;;
1131 --disable-vhost-kernel) vhost_kernel="no"
1132 ;;
1133 --enable-vhost-kernel) vhost_kernel="yes"
1134 ;;
1135 --disable-capstone) capstone="disabled"
1136 ;;
1137 --enable-capstone) capstone="enabled"
1138 ;;
1139 --enable-capstone=git) capstone="internal"
1140 ;;
1141 --enable-capstone=*) capstone="$optarg"
1142 ;;
1143 --with-git=*) git="$optarg"
1144 ;;
1145 --with-git-submodules=*)
1146 git_submodules_action="$optarg"
1147 ;;
1148 --enable-debug-mutex) debug_mutex=yes
1149 ;;
1150 --disable-debug-mutex) debug_mutex=no
1151 ;;
1152 --enable-plugins) if test "$mingw32" = "yes"; then
1153 error_exit "TCG plugins not currently supported on Windows platforms"
1154 else
1155 plugins="yes"
1156 fi
1157 ;;
1158 --disable-plugins) plugins="no"
1159 ;;
1160 --enable-containers) use_containers="yes"
1161 ;;
1162 --disable-containers) use_containers="no"
1163 ;;
1164 --gdb=*) gdb_bin="$optarg"
1165 ;;
1166 --enable-rng-none) rng_none=yes
1167 ;;
1168 --disable-rng-none) rng_none=no
1169 ;;
1170 --enable-keyring) secret_keyring="yes"
1171 ;;
1172 --disable-keyring) secret_keyring="no"
1173 ;;
1174 --enable-gio) gio=yes
1175 ;;
1176 --disable-gio) gio=no
1177 ;;
1178 --enable-slirp-smbd) slirp_smbd=yes
1179 ;;
1180 --disable-slirp-smbd) slirp_smbd=no
1181 ;;
1182 # backwards compatibility options
1183 --enable-trace-backend=*) meson_option_parse "--enable-trace-backends=$optarg" "$optarg"
1184 ;;
1185 --disable-blobs) meson_option_parse --disable-install-blobs ""
1186 ;;
1187 --enable-tcmalloc) meson_option_parse --enable-malloc=tcmalloc tcmalloc
1188 ;;
1189 --enable-jemalloc) meson_option_parse --enable-malloc=jemalloc jemalloc
1190 ;;
1191 # everything else has the same name in configure and meson
1192 --enable-* | --disable-*) meson_option_parse "$opt" "$optarg"
1193 ;;
1194 *)
1195 echo "ERROR: unknown option $opt"
1196 echo "Try '$0 --help' for more information"
1197 exit 1
1198 ;;
1199 esac
1200 done
1201
1202 # test for any invalid configuration combinations
1203 if test "$plugins" = "yes" -a "$tcg" = "disabled"; then
1204 error_exit "Can't enable plugins on non-TCG builds"
1205 fi
1206
1207 case $git_submodules_action in
1208 update|validate)
1209 if test ! -e "$source_path/.git"; then
1210 echo "ERROR: cannot $git_submodules_action git submodules without .git"
1211 exit 1
1212 fi
1213 ;;
1214 ignore)
1215 if ! test -f "$source_path/ui/keycodemapdb/README"
1216 then
1217 echo
1218 echo "ERROR: missing GIT submodules"
1219 echo
1220 if test -e "$source_path/.git"; then
1221 echo "--with-git-submodules=ignore specified but submodules were not"
1222 echo "checked out. Please initialize and update submodules."
1223 else
1224 echo "This is not a GIT checkout but module content appears to"
1225 echo "be missing. Do not use 'git archive' or GitHub download links"
1226 echo "to acquire QEMU source archives. Non-GIT builds are only"
1227 echo "supported with source archives linked from:"
1228 echo
1229 echo " https://www.qemu.org/download/#source"
1230 echo
1231 echo "Developers working with GIT can use scripts/archive-source.sh"
1232 echo "if they need to create valid source archives."
1233 fi
1234 echo
1235 exit 1
1236 fi
1237 ;;
1238 *)
1239 echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'"
1240 exit 1
1241 ;;
1242 esac
1243
1244 libdir="${libdir:-$prefix/lib}"
1245 libexecdir="${libexecdir:-$prefix/libexec}"
1246 includedir="${includedir:-$prefix/include}"
1247
1248 if test "$mingw32" = "yes" ; then
1249 bindir="${bindir:-$prefix}"
1250 else
1251 bindir="${bindir:-$prefix/bin}"
1252 fi
1253 mandir="${mandir:-$prefix/share/man}"
1254 datadir="${datadir:-$prefix/share}"
1255 docdir="${docdir:-$prefix/share/doc}"
1256 sysconfdir="${sysconfdir:-$prefix/etc}"
1257 local_statedir="${local_statedir:-$prefix/var}"
1258 firmwarepath="${firmwarepath:-$datadir/qemu-firmware}"
1259 localedir="${localedir:-$datadir/locale}"
1260
1261 case "$cpu" in
1262 ppc)
1263 CPU_CFLAGS="-m32"
1264 QEMU_LDFLAGS="-m32 $QEMU_LDFLAGS"
1265 ;;
1266 ppc64)
1267 CPU_CFLAGS="-m64"
1268 QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
1269 ;;
1270 sparc)
1271 CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
1272 QEMU_LDFLAGS="-m32 -mv8plus $QEMU_LDFLAGS"
1273 ;;
1274 sparc64)
1275 CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1276 QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
1277 ;;
1278 s390)
1279 CPU_CFLAGS="-m31"
1280 QEMU_LDFLAGS="-m31 $QEMU_LDFLAGS"
1281 ;;
1282 s390x)
1283 CPU_CFLAGS="-m64"
1284 QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
1285 ;;
1286 i386)
1287 CPU_CFLAGS="-m32"
1288 QEMU_LDFLAGS="-m32 $QEMU_LDFLAGS"
1289 ;;
1290 x86_64)
1291 # ??? Only extremely old AMD cpus do not have cmpxchg16b.
1292 # If we truly care, we should simply detect this case at
1293 # runtime and generate the fallback to serial emulation.
1294 CPU_CFLAGS="-m64 -mcx16"
1295 QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
1296 ;;
1297 x32)
1298 CPU_CFLAGS="-mx32"
1299 QEMU_LDFLAGS="-mx32 $QEMU_LDFLAGS"
1300 ;;
1301 # No special flags required for other host CPUs
1302 esac
1303
1304 if eval test -z "\${cross_cc_$cpu}"; then
1305 eval "cross_cc_${cpu}=\$cc"
1306 cross_cc_vars="$cross_cc_vars cross_cc_${cpu}"
1307 fi
1308
1309 # For user-mode emulation the host arch has to be one we explicitly
1310 # support, even if we're using TCI.
1311 if [ "$ARCH" = "unknown" ]; then
1312 bsd_user="no"
1313 linux_user="no"
1314 fi
1315
1316 default_target_list=""
1317 deprecated_targets_list=ppc64abi32-linux-user
1318 deprecated_features=""
1319 mak_wilds=""
1320
1321 if [ "$softmmu" = "yes" ]; then
1322 mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak"
1323 fi
1324 if [ "$linux_user" = "yes" ]; then
1325 mak_wilds="${mak_wilds} $source_path/configs/targets/*-linux-user.mak"
1326 fi
1327 if [ "$bsd_user" = "yes" ]; then
1328 mak_wilds="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak"
1329 fi
1330
1331 # If the user doesn't explicitly specify a deprecated target we will
1332 # skip it.
1333 if test -z "$target_list"; then
1334 if test -z "$target_list_exclude"; then
1335 target_list_exclude="$deprecated_targets_list"
1336 else
1337 target_list_exclude="$target_list_exclude,$deprecated_targets_list"
1338 fi
1339 fi
1340
1341 for config in $mak_wilds; do
1342 target="$(basename "$config" .mak)"
1343 if echo "$target_list_exclude" | grep -vq "$target"; then
1344 default_target_list="${default_target_list} $target"
1345 fi
1346 done
1347
1348 if test x"$show_help" = x"yes" ; then
1349 cat << EOF
1350
1351 Usage: configure [options]
1352 Options: [defaults in brackets after descriptions]
1353
1354 Standard options:
1355 --help print this message
1356 --prefix=PREFIX install in PREFIX [$prefix]
1357 --interp-prefix=PREFIX where to find shared libraries, etc.
1358 use %M for cpu name [$interp_prefix]
1359 --target-list=LIST set target list (default: build all non-deprecated)
1360 $(echo Available targets: $default_target_list | \
1361 fold -s -w 53 | sed -e 's/^/ /')
1362 $(echo Deprecated targets: $deprecated_targets_list | \
1363 fold -s -w 53 | sed -e 's/^/ /')
1364 --target-list-exclude=LIST exclude a set of targets from the default target-list
1365
1366 Advanced options (experts only):
1367 --cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix]
1368 --cc=CC use C compiler CC [$cc]
1369 --iasl=IASL use ACPI compiler IASL [$iasl]
1370 --host-cc=CC use C compiler CC [$host_cc] for code run at
1371 build time
1372 --cxx=CXX use C++ compiler CXX [$cxx]
1373 --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
1374 --extra-cflags=CFLAGS append extra C compiler flags QEMU_CFLAGS
1375 --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
1376 --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS
1377 --cross-cc-ARCH=CC use compiler when building ARCH guest test cases
1378 --cross-cc-flags-ARCH= use compiler flags when building ARCH guest tests
1379 --make=MAKE use specified make [$make]
1380 --python=PYTHON use specified python [$python]
1381 --sphinx-build=SPHINX use specified sphinx-build [$sphinx_build]
1382 --meson=MESON use specified meson [$meson]
1383 --ninja=NINJA use specified ninja [$ninja]
1384 --smbd=SMBD use specified smbd [$smbd]
1385 --with-git=GIT use specified git [$git]
1386 --with-git-submodules=update update git submodules (default if .git dir exists)
1387 --with-git-submodules=validate fail if git submodules are not up to date
1388 --with-git-submodules=ignore do not update or check git submodules (default if no .git dir)
1389 --static enable static build [$static]
1390 --mandir=PATH install man pages in PATH
1391 --datadir=PATH install firmware in PATH/$qemu_suffix
1392 --localedir=PATH install translation in PATH/$qemu_suffix
1393 --docdir=PATH install documentation in PATH/$qemu_suffix
1394 --bindir=PATH install binaries in PATH
1395 --libdir=PATH install libraries in PATH
1396 --libexecdir=PATH install helper binaries in PATH
1397 --sysconfdir=PATH install config in PATH/$qemu_suffix
1398 --localstatedir=PATH install local state in PATH (set at runtime on win32)
1399 --firmwarepath=PATH search PATH for firmware files
1400 --efi-aarch64=PATH PATH of efi file to use for aarch64 VMs.
1401 --with-suffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix]
1402 --with-pkgversion=VERS use specified string as sub-version of the package
1403 --without-default-features default all --enable-* options to "disabled"
1404 --without-default-devices do not include any device that is not needed to
1405 start the emulator (only use if you are including
1406 desired devices in configs/devices/)
1407 --with-devices-ARCH=NAME override default configs/devices
1408 --enable-debug enable common debug build options
1409 --enable-sanitizers enable default sanitizers
1410 --enable-tsan enable thread sanitizer
1411 --disable-strip disable stripping binaries
1412 --disable-werror disable compilation abort on warning
1413 --disable-stack-protector disable compiler-provided stack protection
1414 --audio-drv-list=LIST set audio drivers list
1415 --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L
1416 --block-drv-rw-whitelist=L
1417 set block driver read-write whitelist
1418 (by default affects only QEMU, not tools like qemu-img)
1419 --block-drv-ro-whitelist=L
1420 set block driver read-only whitelist
1421 (by default affects only QEMU, not tools like qemu-img)
1422 --enable-block-drv-whitelist-in-tools
1423 use block whitelist also in tools instead of only QEMU
1424 --with-trace-file=NAME Full PATH,NAME of file to store traces
1425 Default:trace-<pid>
1426 --cpu=CPU Build for host CPU [$cpu]
1427 --with-coroutine=BACKEND coroutine backend. Supported options:
1428 ucontext, sigaltstack, windows
1429 --enable-gcov enable test coverage analysis with gcov
1430 --with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent
1431 --with-win-sdk=SDK-path path to Windows Platform SDK (to build VSS .tlb)
1432 --tls-priority default TLS protocol/cipher priority string
1433 --enable-gprof QEMU profiling with gprof
1434 --enable-profiler profiler support
1435 --enable-debug-stack-usage
1436 track the maximum stack usage of stacks created by qemu_alloc_stack
1437 --enable-plugins
1438 enable plugins via shared library loading
1439 --disable-containers don't use containers for cross-building
1440 --gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin]
1441 EOF
1442 meson_options_help
1443 cat << EOF
1444 system all system emulation targets
1445 user supported user emulation targets
1446 linux-user all linux usermode emulation targets
1447 bsd-user all BSD usermode emulation targets
1448 guest-agent build the QEMU Guest Agent
1449 pie Position Independent Executables
1450 modules modules support (non-Windows)
1451 module-upgrades try to load modules from alternate paths for upgrades
1452 debug-tcg TCG debugging (default is disabled)
1453 debug-info debugging information
1454 lto Enable Link-Time Optimization.
1455 safe-stack SafeStack Stack Smash Protection. Depends on
1456 clang/llvm >= 3.7 and requires coroutine backend ucontext.
1457 membarrier membarrier system call (for Linux 4.14+ or Windows)
1458 rdma Enable RDMA-based migration
1459 pvrdma Enable PVRDMA support
1460 vhost-net vhost-net kernel acceleration support
1461 vhost-vsock virtio sockets device support
1462 vhost-scsi vhost-scsi kernel target support
1463 vhost-crypto vhost-user-crypto backend support
1464 vhost-kernel vhost kernel backend support
1465 vhost-user vhost-user backend support
1466 vhost-vdpa vhost-vdpa kernel backend support
1467 live-block-migration Block migration in the main migration stream
1468 coroutine-pool coroutine freelist (better performance)
1469 tpm TPM support
1470 libssh ssh block device support
1471 numa libnuma support
1472 avx2 AVX2 optimization support
1473 avx512f AVX512F optimization support
1474 replication replication support
1475 opengl opengl support
1476 xfsctl xfsctl support
1477 qom-cast-debug cast debugging support
1478 tools build qemu-io, qemu-nbd and qemu-img tools
1479 bochs bochs image format support
1480 cloop cloop image format support
1481 dmg dmg image format support
1482 qcow1 qcow v1 image format support
1483 vdi vdi image format support
1484 vvfat vvfat image format support
1485 qed qed image format support
1486 parallels parallels image format support
1487 crypto-afalg Linux AF_ALG crypto backend driver
1488 debug-mutex mutex debugging support
1489 rng-none dummy RNG, avoid using /dev/(u)random and getrandom()
1490 gio libgio support
1491 slirp-smbd use smbd (at path --smbd=*) in slirp networking
1492
1493 NOTE: The object files are built at the place where configure is launched
1494 EOF
1495 exit 0
1496 fi
1497
1498 # Remove old dependency files to make sure that they get properly regenerated
1499 rm -f */config-devices.mak.d
1500
1501 if test -z "$python"
1502 then
1503 error_exit "Python not found. Use --python=/path/to/python"
1504 fi
1505 if ! has "$make"
1506 then
1507 error_exit "GNU make ($make) not found"
1508 fi
1509
1510 # Note that if the Python conditional here evaluates True we will exit
1511 # with status 1 which is a shell 'false' value.
1512 if ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then
1513 error_exit "Cannot use '$python', Python >= 3.6 is required." \
1514 "Use --python=/path/to/python to specify a supported Python."
1515 fi
1516
1517 # Preserve python version since some functionality is dependent on it
1518 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)
1519
1520 # Suppress writing compiled files
1521 python="$python -B"
1522
1523 if test -z "$meson"; then
1524 if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.59.2; then
1525 meson=meson
1526 elif test $git_submodules_action != 'ignore' ; then
1527 meson=git
1528 elif test -e "${source_path}/meson/meson.py" ; then
1529 meson=internal
1530 else
1531 if test "$explicit_python" = yes; then
1532 error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found."
1533 else
1534 error_exit "Meson not found. Use --meson=/path/to/meson"
1535 fi
1536 fi
1537 else
1538 # Meson uses its own Python interpreter to invoke other Python scripts,
1539 # but the user wants to use the one they specified with --python.
1540 #
1541 # We do not want to override the distro Python interpreter (and sometimes
1542 # cannot: for example in Homebrew /usr/bin/meson is a bash script), so
1543 # just require --meson=git|internal together with --python.
1544 if test "$explicit_python" = yes; then
1545 case "$meson" in
1546 git | internal) ;;
1547 *) error_exit "--python requires using QEMU's embedded Meson distribution." ;;
1548 esac
1549 fi
1550 fi
1551
1552 if test "$meson" = git; then
1553 git_submodules="${git_submodules} meson"
1554 fi
1555
1556 case "$meson" in
1557 git | internal)
1558 meson="$python ${source_path}/meson/meson.py"
1559 ;;
1560 *) meson=$(command -v "$meson") ;;
1561 esac
1562
1563 # Probe for ninja
1564
1565 if test -z "$ninja"; then
1566 for c in ninja ninja-build samu; do
1567 if has $c; then
1568 ninja=$(command -v "$c")
1569 break
1570 fi
1571 done
1572 if test -z "$ninja"; then
1573 error_exit "Cannot find Ninja"
1574 fi
1575 fi
1576
1577 # Check that the C compiler works. Doing this here before testing
1578 # the host CPU ensures that we had a valid CC to autodetect the
1579 # $cpu var (and we should bail right here if that's not the case).
1580 # It also allows the help message to be printed without a CC.
1581 write_c_skeleton;
1582 if compile_object ; then
1583 : C compiler works ok
1584 else
1585 error_exit "\"$cc\" either does not exist or does not work"
1586 fi
1587 if ! compile_prog ; then
1588 error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
1589 fi
1590
1591 # Consult white-list to determine whether to enable werror
1592 # by default. Only enable by default for git builds
1593 if test -z "$werror" ; then
1594 if test "$git_submodules_action" != "ignore" && \
1595 { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
1596 werror="yes"
1597 else
1598 werror="no"
1599 fi
1600 fi
1601
1602 if test "$targetos" = "bogus"; then
1603 # Now that we know that we're not printing the help and that
1604 # the compiler works (so the results of the check_defines we used
1605 # to identify the OS are reliable), if we didn't recognize the
1606 # host OS we should stop now.
1607 error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
1608 fi
1609
1610 # Check whether the compiler matches our minimum requirements:
1611 cat > $TMPC << EOF
1612 #if defined(__clang_major__) && defined(__clang_minor__)
1613 # ifdef __apple_build_version__
1614 # if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0)
1615 # error You need at least XCode Clang v10.0 to compile QEMU
1616 # endif
1617 # else
1618 # if __clang_major__ < 6 || (__clang_major__ == 6 && __clang_minor__ < 0)
1619 # error You need at least Clang v6.0 to compile QEMU
1620 # endif
1621 # endif
1622 #elif defined(__GNUC__) && defined(__GNUC_MINOR__)
1623 # if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4)
1624 # error You need at least GCC v7.4.0 to compile QEMU
1625 # endif
1626 #else
1627 # error You either need GCC or Clang to compiler QEMU
1628 #endif
1629 int main (void) { return 0; }
1630 EOF
1631 if ! compile_prog "" "" ; then
1632 error_exit "You need at least GCC v7.4 or Clang v6.0 (or XCode Clang v10.0)"
1633 fi
1634
1635 # Accumulate -Wfoo and -Wno-bar separately.
1636 # We will list all of the enable flags first, and the disable flags second.
1637 # Note that we do not add -Werror, because that would enable it for all
1638 # configure tests. If a configure test failed due to -Werror this would
1639 # just silently disable some features, so it's too error prone.
1640
1641 warn_flags=
1642 add_to warn_flags -Wold-style-declaration
1643 add_to warn_flags -Wold-style-definition
1644 add_to warn_flags -Wtype-limits
1645 add_to warn_flags -Wformat-security
1646 add_to warn_flags -Wformat-y2k
1647 add_to warn_flags -Winit-self
1648 add_to warn_flags -Wignored-qualifiers
1649 add_to warn_flags -Wempty-body
1650 add_to warn_flags -Wnested-externs
1651 add_to warn_flags -Wendif-labels
1652 add_to warn_flags -Wexpansion-to-defined
1653 add_to warn_flags -Wimplicit-fallthrough=2
1654
1655 nowarn_flags=
1656 add_to nowarn_flags -Wno-initializer-overrides
1657 add_to nowarn_flags -Wno-missing-include-dirs
1658 add_to nowarn_flags -Wno-shift-negative-value
1659 add_to nowarn_flags -Wno-string-plus-int
1660 add_to nowarn_flags -Wno-typedef-redefinition
1661 add_to nowarn_flags -Wno-tautological-type-limit-compare
1662 add_to nowarn_flags -Wno-psabi
1663
1664 gcc_flags="$warn_flags $nowarn_flags"
1665
1666 cc_has_warning_flag() {
1667 write_c_skeleton;
1668
1669 # Use the positive sense of the flag when testing for -Wno-wombat
1670 # support (gcc will happily accept the -Wno- form of unknown
1671 # warning options).
1672 optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
1673 compile_prog "-Werror $optflag" ""
1674 }
1675
1676 for flag in $gcc_flags; do
1677 if cc_has_warning_flag $flag ; then
1678 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1679 fi
1680 done
1681
1682 if test "$stack_protector" != "no"; then
1683 cat > $TMPC << EOF
1684 int main(int argc, char *argv[])
1685 {
1686 char arr[64], *p = arr, *c = argv[0];
1687 while (*c) {
1688 *p++ = *c++;
1689 }
1690 return 0;
1691 }
1692 EOF
1693 gcc_flags="-fstack-protector-strong -fstack-protector-all"
1694 sp_on=0
1695 for flag in $gcc_flags; do
1696 # We need to check both a compile and a link, since some compiler
1697 # setups fail only on a .c->.o compile and some only at link time
1698 if compile_object "-Werror $flag" &&
1699 compile_prog "-Werror $flag" ""; then
1700 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1701 QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
1702 sp_on=1
1703 break
1704 fi
1705 done
1706 if test "$stack_protector" = yes; then
1707 if test $sp_on = 0; then
1708 error_exit "Stack protector not supported"
1709 fi
1710 fi
1711 fi
1712
1713 # Disable -Wmissing-braces on older compilers that warn even for
1714 # the "universal" C zero initializer {0}.
1715 cat > $TMPC << EOF
1716 struct {
1717 int a[2];
1718 } x = {0};
1719 EOF
1720 if compile_object "-Werror" "" ; then
1721 :
1722 else
1723 QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
1724 fi
1725
1726 # Our module code doesn't support Windows
1727 if test "$modules" = "yes" && test "$mingw32" = "yes" ; then
1728 error_exit "Modules are not available for Windows"
1729 fi
1730
1731 # module_upgrades is only reasonable if modules are enabled
1732 if test "$modules" = "no" && test "$module_upgrades" = "yes" ; then
1733 error_exit "Can't enable module-upgrades as Modules are not enabled"
1734 fi
1735
1736 # Static linking is not possible with plugins, modules or PIE
1737 if test "$static" = "yes" ; then
1738 if test "$modules" = "yes" ; then
1739 error_exit "static and modules are mutually incompatible"
1740 fi
1741 if test "$plugins" = "yes"; then
1742 error_exit "static and plugins are mutually incompatible"
1743 else
1744 plugins="no"
1745 fi
1746 fi
1747
1748 # Unconditional check for compiler __thread support
1749 cat > $TMPC << EOF
1750 static __thread int tls_var;
1751 int main(void) { return tls_var; }
1752 EOF
1753
1754 if ! compile_prog "-Werror" "" ; then
1755 error_exit "Your compiler does not support the __thread specifier for " \
1756 "Thread-Local Storage (TLS). Please upgrade to a version that does."
1757 fi
1758
1759 cat > $TMPC << EOF
1760
1761 #ifdef __linux__
1762 # define THREAD __thread
1763 #else
1764 # define THREAD
1765 #endif
1766 static THREAD int tls_var;
1767 int main(void) { return tls_var; }
1768 EOF
1769
1770 # Check we support --no-pie first; we will need this for building ROMs.
1771 if compile_prog "-Werror -fno-pie" "-no-pie"; then
1772 CFLAGS_NOPIE="-fno-pie"
1773 fi
1774
1775 if test "$static" = "yes"; then
1776 if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then
1777 CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
1778 QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS"
1779 pie="yes"
1780 elif test "$pie" = "yes"; then
1781 error_exit "-static-pie not available due to missing toolchain support"
1782 else
1783 QEMU_LDFLAGS="-static $QEMU_LDFLAGS"
1784 pie="no"
1785 fi
1786 elif test "$pie" = "no"; then
1787 CONFIGURE_CFLAGS="$CFLAGS_NOPIE $CONFIGURE_CFLAGS"
1788 elif compile_prog "-Werror -fPIE -DPIE" "-pie"; then
1789 CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
1790 CONFIGURE_LDFLAGS="-pie $CONFIGURE_LDFLAGS"
1791 pie="yes"
1792 elif test "$pie" = "yes"; then
1793 error_exit "PIE not available due to missing toolchain support"
1794 else
1795 echo "Disabling PIE due to missing toolchain support"
1796 pie="no"
1797 fi
1798
1799 # Detect support for PT_GNU_RELRO + DT_BIND_NOW.
1800 # The combination is known as "full relro", because .got.plt is read-only too.
1801 if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
1802 QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS"
1803 fi
1804
1805 ##########################################
1806 # __sync_fetch_and_and requires at least -march=i486. Many toolchains
1807 # use i686 as default anyway, but for those that don't, an explicit
1808 # specification is necessary
1809
1810 if test "$cpu" = "i386"; then
1811 cat > $TMPC << EOF
1812 static int sfaa(int *ptr)
1813 {
1814 return __sync_fetch_and_and(ptr, 0);
1815 }
1816
1817 int main(void)
1818 {
1819 int val = 42;
1820 val = __sync_val_compare_and_swap(&val, 0, 1);
1821 sfaa(&val);
1822 return val;
1823 }
1824 EOF
1825 if ! compile_prog "" "" ; then
1826 QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
1827 fi
1828 fi
1829
1830 if test "$tcg" = "enabled"; then
1831 git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
1832 git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
1833 fi
1834
1835 if test -z "${target_list+xxx}" ; then
1836 default_targets=yes
1837 for target in $default_target_list; do
1838 target_list="$target_list $target"
1839 done
1840 target_list="${target_list# }"
1841 else
1842 default_targets=no
1843 target_list=$(echo "$target_list" | sed -e 's/,/ /g')
1844 for target in $target_list; do
1845 # Check that we recognised the target name; this allows a more
1846 # friendly error message than if we let it fall through.
1847 case " $default_target_list " in
1848 *" $target "*)
1849 ;;
1850 *)
1851 error_exit "Unknown target name '$target'"
1852 ;;
1853 esac
1854 done
1855 fi
1856
1857 for target in $target_list; do
1858 # if a deprecated target is enabled we note it here
1859 if echo "$deprecated_targets_list" | grep -q "$target"; then
1860 add_to deprecated_features $target
1861 fi
1862 done
1863
1864 # see if system emulation was really requested
1865 case " $target_list " in
1866 *"-softmmu "*) softmmu=yes
1867 ;;
1868 *) softmmu=no
1869 ;;
1870 esac
1871
1872 feature_not_found() {
1873 feature=$1
1874 remedy=$2
1875
1876 error_exit "User requested feature $feature" \
1877 "configure was not able to find it." \
1878 "$remedy"
1879 }
1880
1881 # ---
1882 # big/little endian test
1883 cat > $TMPC << EOF
1884 #include <stdio.h>
1885 short big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
1886 short little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
1887 int main(int argc, char *argv[])
1888 {
1889 return printf("%s %s\n", (char *)big_endian, (char *)little_endian);
1890 }
1891 EOF
1892
1893 if compile_prog ; then
1894 if strings -a $TMPE | grep -q BiGeNdIaN ; then
1895 bigendian="yes"
1896 elif strings -a $TMPE | grep -q LiTtLeEnDiAn ; then
1897 bigendian="no"
1898 else
1899 echo big/little test failed
1900 exit 1
1901 fi
1902 else
1903 echo big/little test failed
1904 exit 1
1905 fi
1906
1907 ##########################################
1908 # system tools
1909 if test -z "$want_tools"; then
1910 if test "$softmmu" = "no"; then
1911 want_tools=no
1912 else
1913 want_tools=yes
1914 fi
1915 fi
1916
1917 ##########################################
1918 # L2TPV3 probe
1919
1920 cat > $TMPC <<EOF
1921 #include <sys/socket.h>
1922 #include <linux/ip.h>
1923 int main(void) { return sizeof(struct mmsghdr); }
1924 EOF
1925 if compile_prog "" "" ; then
1926 l2tpv3=yes
1927 else
1928 l2tpv3=no
1929 fi
1930
1931 #########################################
1932 # vhost interdependencies and host support
1933
1934 # vhost backends
1935 if test "$vhost_user" = "yes" && test "$linux" != "yes"; then
1936 error_exit "vhost-user is only available on Linux"
1937 fi
1938 test "$vhost_vdpa" = "" && vhost_vdpa=$linux
1939 if test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then
1940 error_exit "vhost-vdpa is only available on Linux"
1941 fi
1942 test "$vhost_kernel" = "" && vhost_kernel=$linux
1943 if test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then
1944 error_exit "vhost-kernel is only available on Linux"
1945 fi
1946
1947 # vhost-kernel devices
1948 test "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel
1949 if test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then
1950 error_exit "--enable-vhost-scsi requires --enable-vhost-kernel"
1951 fi
1952 test "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel
1953 if test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then
1954 error_exit "--enable-vhost-vsock requires --enable-vhost-kernel"
1955 fi
1956
1957 # vhost-user backends
1958 test "$vhost_net_user" = "" && vhost_net_user=$vhost_user
1959 if test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then
1960 error_exit "--enable-vhost-net-user requires --enable-vhost-user"
1961 fi
1962 test "$vhost_crypto" = "" && vhost_crypto=$vhost_user
1963 if test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then
1964 error_exit "--enable-vhost-crypto requires --enable-vhost-user"
1965 fi
1966 test "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user
1967 if test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then
1968 error_exit "--enable-vhost-user-fs requires --enable-vhost-user"
1969 fi
1970 #vhost-vdpa backends
1971 test "$vhost_net_vdpa" = "" && vhost_net_vdpa=$vhost_vdpa
1972 if test "$vhost_net_vdpa" = "yes" && test "$vhost_vdpa" = "no"; then
1973 error_exit "--enable-vhost-net-vdpa requires --enable-vhost-vdpa"
1974 fi
1975
1976 # OR the vhost-kernel, vhost-vdpa and vhost-user values for simplicity
1977 if test "$vhost_net" = ""; then
1978 test "$vhost_net_user" = "yes" && vhost_net=yes
1979 test "$vhost_net_vdpa" = "yes" && vhost_net=yes
1980 test "$vhost_kernel" = "yes" && vhost_net=yes
1981 fi
1982
1983 ##########################################
1984 # pkg-config probe
1985
1986 if ! has "$pkg_config_exe"; then
1987 error_exit "pkg-config binary '$pkg_config_exe' not found"
1988 fi
1989
1990 ##########################################
1991 # NPTL probe
1992
1993 if test "$linux_user" = "yes"; then
1994 cat > $TMPC <<EOF
1995 #include <sched.h>
1996 #include <linux/futex.h>
1997 int main(void) {
1998 #if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1999 #error bork
2000 #endif
2001 return 0;
2002 }
2003 EOF
2004 if ! compile_object ; then
2005 feature_not_found "nptl" "Install glibc and linux kernel headers."
2006 fi
2007 fi
2008
2009 ##########################################
2010 # xen probe
2011
2012 if test "$xen" != "disabled" ; then
2013 # Check whether Xen library path is specified via --extra-ldflags to avoid
2014 # overriding this setting with pkg-config output. If not, try pkg-config
2015 # to obtain all needed flags.
2016
2017 if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2018 $pkg_config --exists xencontrol ; then
2019 xen_ctrl_version="$(printf '%d%02d%02d' \
2020 $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
2021 xen=enabled
2022 xen_pc="xencontrol xenstore xenforeignmemory xengnttab"
2023 xen_pc="$xen_pc xenevtchn xendevicemodel"
2024 if $pkg_config --exists xentoolcore; then
2025 xen_pc="$xen_pc xentoolcore"
2026 fi
2027 xen_cflags="$($pkg_config --cflags $xen_pc)"
2028 xen_libs="$($pkg_config --libs $xen_pc)"
2029 else
2030
2031 xen_libs="-lxenstore -lxenctrl"
2032 xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
2033
2034 # First we test whether Xen headers and libraries are available.
2035 # If no, we are done and there is no Xen support.
2036 # If yes, more tests are run to detect the Xen version.
2037
2038 # Xen (any)
2039 cat > $TMPC <<EOF
2040 #include <xenctrl.h>
2041 int main(void) {
2042 return 0;
2043 }
2044 EOF
2045 if ! compile_prog "" "$xen_libs" ; then
2046 # Xen not found
2047 if test "$xen" = "enabled" ; then
2048 feature_not_found "xen" "Install xen devel"
2049 fi
2050 xen=disabled
2051
2052 # Xen unstable
2053 elif
2054 cat > $TMPC <<EOF &&
2055 #undef XC_WANT_COMPAT_DEVICEMODEL_API
2056 #define __XEN_TOOLS__
2057 #include <xendevicemodel.h>
2058 #include <xenforeignmemory.h>
2059 int main(void) {
2060 xendevicemodel_handle *xd;
2061 xenforeignmemory_handle *xfmem;
2062
2063 xd = xendevicemodel_open(0, 0);
2064 xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
2065
2066 xfmem = xenforeignmemory_open(0, 0);
2067 xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
2068
2069 return 0;
2070 }
2071 EOF
2072 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
2073 then
2074 xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
2075 xen_ctrl_version=41100
2076 xen=enabled
2077 elif
2078 cat > $TMPC <<EOF &&
2079 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2080 #include <xenforeignmemory.h>
2081 #include <xentoolcore.h>
2082 int main(void) {
2083 xenforeignmemory_handle *xfmem;
2084
2085 xfmem = xenforeignmemory_open(0, 0);
2086 xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
2087 xentoolcore_restrict_all(0);
2088
2089 return 0;
2090 }
2091 EOF
2092 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
2093 then
2094 xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
2095 xen_ctrl_version=41000
2096 xen=enabled
2097 elif
2098 cat > $TMPC <<EOF &&
2099 #undef XC_WANT_COMPAT_DEVICEMODEL_API
2100 #define __XEN_TOOLS__
2101 #include <xendevicemodel.h>
2102 int main(void) {
2103 xendevicemodel_handle *xd;
2104
2105 xd = xendevicemodel_open(0, 0);
2106 xendevicemodel_close(xd);
2107
2108 return 0;
2109 }
2110 EOF
2111 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2112 then
2113 xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2114 xen_ctrl_version=40900
2115 xen=enabled
2116 elif
2117 cat > $TMPC <<EOF &&
2118 /*
2119 * If we have stable libs the we don't want the libxc compat
2120 * layers, regardless of what CFLAGS we may have been given.
2121 *
2122 * Also, check if xengnttab_grant_copy_segment_t is defined and
2123 * grant copy operation is implemented.
2124 */
2125 #undef XC_WANT_COMPAT_EVTCHN_API
2126 #undef XC_WANT_COMPAT_GNTTAB_API
2127 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2128 #include <xenctrl.h>
2129 #include <xenstore.h>
2130 #include <xenevtchn.h>
2131 #include <xengnttab.h>
2132 #include <xenforeignmemory.h>
2133 #include <stdint.h>
2134 #include <xen/hvm/hvm_info_table.h>
2135 #if !defined(HVM_MAX_VCPUS)
2136 # error HVM_MAX_VCPUS not defined
2137 #endif
2138 int main(void) {
2139 xc_interface *xc = NULL;
2140 xenforeignmemory_handle *xfmem;
2141 xenevtchn_handle *xe;
2142 xengnttab_handle *xg;
2143 xengnttab_grant_copy_segment_t* seg = NULL;
2144
2145 xs_daemon_open();
2146
2147 xc = xc_interface_open(0, 0, 0);
2148 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2149 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2150 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2151 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2152
2153 xfmem = xenforeignmemory_open(0, 0);
2154 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2155
2156 xe = xenevtchn_open(0, 0);
2157 xenevtchn_fd(xe);
2158
2159 xg = xengnttab_open(0, 0);
2160 xengnttab_grant_copy(xg, 0, seg);
2161
2162 return 0;
2163 }
2164 EOF
2165 compile_prog "" "$xen_libs $xen_stable_libs"
2166 then
2167 xen_ctrl_version=40800
2168 xen=enabled
2169 elif
2170 cat > $TMPC <<EOF &&
2171 /*
2172 * If we have stable libs the we don't want the libxc compat
2173 * layers, regardless of what CFLAGS we may have been given.
2174 */
2175 #undef XC_WANT_COMPAT_EVTCHN_API
2176 #undef XC_WANT_COMPAT_GNTTAB_API
2177 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2178 #include <xenctrl.h>
2179 #include <xenstore.h>
2180 #include <xenevtchn.h>
2181 #include <xengnttab.h>
2182 #include <xenforeignmemory.h>
2183 #include <stdint.h>
2184 #include <xen/hvm/hvm_info_table.h>
2185 #if !defined(HVM_MAX_VCPUS)
2186 # error HVM_MAX_VCPUS not defined
2187 #endif
2188 int main(void) {
2189 xc_interface *xc = NULL;
2190 xenforeignmemory_handle *xfmem;
2191 xenevtchn_handle *xe;
2192 xengnttab_handle *xg;
2193
2194 xs_daemon_open();
2195
2196 xc = xc_interface_open(0, 0, 0);
2197 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2198 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2199 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2200 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2201
2202 xfmem = xenforeignmemory_open(0, 0);
2203 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2204
2205 xe = xenevtchn_open(0, 0);
2206 xenevtchn_fd(xe);
2207
2208 xg = xengnttab_open(0, 0);
2209 xengnttab_map_grant_ref(xg, 0, 0, 0);
2210
2211 return 0;
2212 }
2213 EOF
2214 compile_prog "" "$xen_libs $xen_stable_libs"
2215 then
2216 xen_ctrl_version=40701
2217 xen=enabled
2218
2219 # Xen 4.6
2220 elif
2221 cat > $TMPC <<EOF &&
2222 #include <xenctrl.h>
2223 #include <xenstore.h>
2224 #include <stdint.h>
2225 #include <xen/hvm/hvm_info_table.h>
2226 #if !defined(HVM_MAX_VCPUS)
2227 # error HVM_MAX_VCPUS not defined
2228 #endif
2229 int main(void) {
2230 xc_interface *xc;
2231 xs_daemon_open();
2232 xc = xc_interface_open(0, 0, 0);
2233 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2234 xc_gnttab_open(NULL, 0);
2235 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2236 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2237 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2238 xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2239 return 0;
2240 }
2241 EOF
2242 compile_prog "" "$xen_libs"
2243 then
2244 xen_ctrl_version=40600
2245 xen=enabled
2246
2247 # Xen 4.5
2248 elif
2249 cat > $TMPC <<EOF &&
2250 #include <xenctrl.h>
2251 #include <xenstore.h>
2252 #include <stdint.h>
2253 #include <xen/hvm/hvm_info_table.h>
2254 #if !defined(HVM_MAX_VCPUS)
2255 # error HVM_MAX_VCPUS not defined
2256 #endif
2257 int main(void) {
2258 xc_interface *xc;
2259 xs_daemon_open();
2260 xc = xc_interface_open(0, 0, 0);
2261 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2262 xc_gnttab_open(NULL, 0);
2263 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2264 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2265 xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
2266 return 0;
2267 }
2268 EOF
2269 compile_prog "" "$xen_libs"
2270 then
2271 xen_ctrl_version=40500
2272 xen=enabled
2273
2274 elif
2275 cat > $TMPC <<EOF &&
2276 #include <xenctrl.h>
2277 #include <xenstore.h>
2278 #include <stdint.h>
2279 #include <xen/hvm/hvm_info_table.h>
2280 #if !defined(HVM_MAX_VCPUS)
2281 # error HVM_MAX_VCPUS not defined
2282 #endif
2283 int main(void) {
2284 xc_interface *xc;
2285 xs_daemon_open();
2286 xc = xc_interface_open(0, 0, 0);
2287 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2288 xc_gnttab_open(NULL, 0);
2289 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2290 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2291 return 0;
2292 }
2293 EOF
2294 compile_prog "" "$xen_libs"
2295 then
2296 xen_ctrl_version=40200
2297 xen=enabled
2298
2299 else
2300 if test "$xen" = "enabled" ; then
2301 feature_not_found "xen (unsupported version)" \
2302 "Install a supported xen (xen 4.2 or newer)"
2303 fi
2304 xen=disabled
2305 fi
2306
2307 if test "$xen" = enabled; then
2308 if test $xen_ctrl_version -ge 40701 ; then
2309 xen_libs="$xen_libs $xen_stable_libs "
2310 fi
2311 fi
2312 fi
2313 fi
2314
2315 ##########################################
2316 # RDMA needs OpenFabrics libraries
2317 if test "$rdma" != "no" ; then
2318 cat > $TMPC <<EOF
2319 #include <rdma/rdma_cma.h>
2320 int main(void) { return 0; }
2321 EOF
2322 rdma_libs="-lrdmacm -libverbs -libumad"
2323 if compile_prog "" "$rdma_libs" ; then
2324 rdma="yes"
2325 else
2326 if test "$rdma" = "yes" ; then
2327 error_exit \
2328 " OpenFabrics librdmacm/libibverbs/libibumad not present." \
2329 " Your options:" \
2330 " (1) Fast: Install infiniband packages (devel) from your distro." \
2331 " (2) Cleanest: Install libraries from www.openfabrics.org" \
2332 " (3) Also: Install softiwarp if you don't have RDMA hardware"
2333 fi
2334 rdma="no"
2335 fi
2336 fi
2337
2338 ##########################################
2339 # PVRDMA detection
2340
2341 cat > $TMPC <<EOF &&
2342 #include <sys/mman.h>
2343
2344 int
2345 main(void)
2346 {
2347 char buf = 0;
2348 void *addr = &buf;
2349 addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED);
2350
2351 return 0;
2352 }
2353 EOF
2354
2355 if test "$rdma" = "yes" ; then
2356 case "$pvrdma" in
2357 "")
2358 if compile_prog "" ""; then
2359 pvrdma="yes"
2360 else
2361 pvrdma="no"
2362 fi
2363 ;;
2364 "yes")
2365 if ! compile_prog "" ""; then
2366 error_exit "PVRDMA is not supported since mremap is not implemented"
2367 fi
2368 pvrdma="yes"
2369 ;;
2370 "no")
2371 pvrdma="no"
2372 ;;
2373 esac
2374 else
2375 if test "$pvrdma" = "yes" ; then
2376 error_exit "PVRDMA requires rdma suppport"
2377 fi
2378 pvrdma="no"
2379 fi
2380
2381 # Let's see if enhanced reg_mr is supported
2382 if test "$pvrdma" = "yes" ; then
2383
2384 cat > $TMPC <<EOF &&
2385 #include <infiniband/verbs.h>
2386
2387 int
2388 main(void)
2389 {
2390 struct ibv_mr *mr;
2391 struct ibv_pd *pd = NULL;
2392 size_t length = 10;
2393 uint64_t iova = 0;
2394 int access = 0;
2395 void *addr = NULL;
2396
2397 mr = ibv_reg_mr_iova(pd, addr, length, iova, access);
2398
2399 ibv_dereg_mr(mr);
2400
2401 return 0;
2402 }
2403 EOF
2404 if ! compile_prog "" "-libverbs"; then
2405 QEMU_CFLAGS="$QEMU_CFLAGS -DLEGACY_RDMA_REG_MR"
2406 fi
2407 fi
2408
2409 ##########################################
2410 # xfsctl() probe, used for file-posix.c
2411 if test "$xfs" != "no" ; then
2412 cat > $TMPC << EOF
2413 #include <stddef.h> /* NULL */
2414 #include <xfs/xfs.h>
2415 int main(void)
2416 {
2417 xfsctl(NULL, 0, 0, NULL);
2418 return 0;
2419 }
2420 EOF
2421 if compile_prog "" "" ; then
2422 xfs="yes"
2423 else
2424 if test "$xfs" = "yes" ; then
2425 feature_not_found "xfs" "Install xfsprogs/xfslibs devel"
2426 fi
2427 xfs=no
2428 fi
2429 fi
2430
2431 ##########################################
2432 # plugin linker support probe
2433
2434 if test "$plugins" != "no"; then
2435
2436 #########################################
2437 # See if --dynamic-list is supported by the linker
2438
2439 ld_dynamic_list="no"
2440 cat > $TMPTXT <<EOF
2441 {
2442 foo;
2443 };
2444 EOF
2445
2446 cat > $TMPC <<EOF
2447 #include <stdio.h>
2448 void foo(void);
2449
2450 void foo(void)
2451 {
2452 printf("foo\n");
2453 }
2454
2455 int main(void)
2456 {
2457 foo();
2458 return 0;
2459 }
2460 EOF
2461
2462 if compile_prog "" "-Wl,--dynamic-list=$TMPTXT" ; then
2463 ld_dynamic_list="yes"
2464 fi
2465
2466 #########################################
2467 # See if -exported_symbols_list is supported by the linker
2468
2469 ld_exported_symbols_list="no"
2470 cat > $TMPTXT <<EOF
2471 _foo
2472 EOF
2473
2474 if compile_prog "" "-Wl,-exported_symbols_list,$TMPTXT" ; then
2475 ld_exported_symbols_list="yes"
2476 fi
2477
2478 if test "$ld_dynamic_list" = "no" &&
2479 test "$ld_exported_symbols_list" = "no" ; then
2480 if test "$plugins" = "yes"; then
2481 error_exit \
2482 "Plugin support requires dynamic linking and specifying a set of symbols " \
2483 "that are exported to plugins. Unfortunately your linker doesn't " \
2484 "support the flag (--dynamic-list or -exported_symbols_list) used " \
2485 "for this purpose."
2486 else
2487 plugins="no"
2488 fi
2489 else
2490 plugins="yes"
2491 fi
2492 fi
2493
2494 ##########################################
2495 # glib support probe
2496
2497 glib_req_ver=2.56
2498 glib_modules=gthread-2.0
2499 if test "$modules" = yes; then
2500 glib_modules="$glib_modules gmodule-export-2.0"
2501 elif test "$plugins" = "yes"; then
2502 glib_modules="$glib_modules gmodule-no-export-2.0"
2503 fi
2504
2505 for i in $glib_modules; do
2506 if $pkg_config --atleast-version=$glib_req_ver $i; then
2507 glib_cflags=$($pkg_config --cflags $i)
2508 glib_libs=$($pkg_config --libs $i)
2509 else
2510 error_exit "glib-$glib_req_ver $i is required to compile QEMU"
2511 fi
2512 done
2513
2514 # This workaround is required due to a bug in pkg-config file for glib as it
2515 # doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
2516
2517 if test "$static" = yes && test "$mingw32" = yes; then
2518 glib_cflags="-DGLIB_STATIC_COMPILATION $glib_cflags"
2519 fi
2520
2521 if ! test "$gio" = "no"; then
2522 pass=no
2523 if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
2524 gio_cflags=$($pkg_config --cflags gio-2.0)
2525 gio_libs=$($pkg_config --libs gio-2.0)
2526 gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0)
2527 if ! has "$gdbus_codegen"; then
2528 gdbus_codegen=
2529 fi
2530 # Check that the libraries actually work -- Ubuntu 18.04 ships
2531 # with pkg-config --static --libs data for gio-2.0 that is missing
2532 # -lblkid and will give a link error.
2533 cat > $TMPC <<EOF
2534 #include <gio/gio.h>
2535 int main(void)
2536 {
2537 g_dbus_proxy_new_sync(0, 0, 0, 0, 0, 0, 0, 0);
2538 return 0;
2539 }
2540 EOF
2541 if compile_prog "$gio_cflags" "$gio_libs" ; then
2542 pass=yes
2543 else
2544 pass=no
2545 fi
2546
2547 if test "$pass" = "yes" &&
2548 $pkg_config --atleast-version=$glib_req_ver gio-unix-2.0; then
2549 gio_cflags="$gio_cflags $($pkg_config --cflags gio-unix-2.0)"
2550 gio_libs="$gio_libs $($pkg_config --libs gio-unix-2.0)"
2551 fi
2552 fi
2553
2554 if test "$pass" = "no"; then
2555 if test "$gio" = "yes"; then
2556 feature_not_found "gio" "Install libgio >= 2.0"
2557 else
2558 gio=no
2559 fi
2560 else
2561 gio=yes
2562 fi
2563 fi
2564
2565 # Sanity check that the current size_t matches the
2566 # size that glib thinks it should be. This catches
2567 # problems on multi-arch where people try to build
2568 # 32-bit QEMU while pointing at 64-bit glib headers
2569 cat > $TMPC <<EOF
2570 #include <glib.h>
2571 #include <unistd.h>
2572
2573 #define QEMU_BUILD_BUG_ON(x) \
2574 typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
2575
2576 int main(void) {
2577 QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
2578 return 0;
2579 }
2580 EOF
2581
2582 if ! compile_prog "$glib_cflags" "$glib_libs" ; then
2583 error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
2584 "You probably need to set PKG_CONFIG_LIBDIR"\
2585 "to point to the right pkg-config files for your"\
2586 "build target"
2587 fi
2588
2589 # Silence clang warnings triggered by glib < 2.57.2
2590 cat > $TMPC << EOF
2591 #include <glib.h>
2592 typedef struct Foo {
2593 int i;
2594 } Foo;
2595 static void foo_free(Foo *f)
2596 {
2597 g_free(f);
2598 }
2599 G_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free);
2600 int main(void) { return 0; }
2601 EOF
2602 if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
2603 if cc_has_warning_flag "-Wno-unused-function"; then
2604 glib_cflags="$glib_cflags -Wno-unused-function"
2605 CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -Wno-unused-function"
2606 fi
2607 fi
2608
2609 ##########################################
2610 # SHA command probe for modules
2611 if test "$modules" = yes; then
2612 shacmd_probe="sha1sum sha1 shasum"
2613 for c in $shacmd_probe; do
2614 if has $c; then
2615 shacmd="$c"
2616 break
2617 fi
2618 done
2619 if test "$shacmd" = ""; then
2620 error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
2621 fi
2622 fi
2623
2624 ##########################################
2625 # libssh probe
2626 if test "$libssh" != "no" ; then
2627 if $pkg_config --exists "libssh >= 0.8.7"; then
2628 libssh_cflags=$($pkg_config libssh --cflags)
2629 libssh_libs=$($pkg_config libssh --libs)
2630 libssh=yes
2631 else
2632 if test "$libssh" = "yes" ; then
2633 error_exit "libssh required for --enable-libssh"
2634 fi
2635 libssh=no
2636 fi
2637 fi
2638
2639 ##########################################
2640 # TPM emulation is only on POSIX
2641
2642 if test "$tpm" = ""; then
2643 if test "$mingw32" = "yes"; then
2644 tpm=no
2645 else
2646 tpm=yes
2647 fi
2648 elif test "$tpm" = "yes"; then
2649 if test "$mingw32" = "yes" ; then
2650 error_exit "TPM emulation only available on POSIX systems"
2651 fi
2652 fi
2653
2654 ##########################################
2655 # fdt probe
2656
2657 case "$fdt" in
2658 auto | enabled | internal)
2659 # Simpler to always update submodule, even if not needed.
2660 git_submodules="${git_submodules} dtc"
2661 ;;
2662 esac
2663
2664 ##########################################
2665 # opengl probe (for sdl2, gtk)
2666
2667 if test "$opengl" != "no" ; then
2668 epoxy=no
2669 if $pkg_config epoxy; then
2670 cat > $TMPC << EOF
2671 #include <epoxy/egl.h>
2672 int main(void) { return 0; }
2673 EOF
2674 if compile_prog "" "" ; then
2675 epoxy=yes
2676 fi
2677 fi
2678
2679 if test "$epoxy" = "yes" ; then
2680 opengl_cflags="$($pkg_config --cflags epoxy)"
2681 opengl_libs="$($pkg_config --libs epoxy)"
2682 opengl=yes
2683 else
2684 if test "$opengl" = "yes" ; then
2685 feature_not_found "opengl" "Please install epoxy with EGL"
2686 fi
2687 opengl_cflags=""
2688 opengl_libs=""
2689 opengl=no
2690 fi
2691 fi
2692
2693 ##########################################
2694 # libnuma probe
2695
2696 if test "$numa" != "no" ; then
2697 cat > $TMPC << EOF
2698 #include <numa.h>
2699 int main(void) { return numa_available(); }
2700 EOF
2701
2702 if compile_prog "" "-lnuma" ; then
2703 numa=yes
2704 numa_libs="-lnuma"
2705 else
2706 if test "$numa" = "yes" ; then
2707 feature_not_found "numa" "install numactl devel"
2708 fi
2709 numa=no
2710 fi
2711 fi
2712
2713 # check for usbfs
2714 have_usbfs=no
2715 if test "$linux_user" = "yes"; then
2716 cat > $TMPC << EOF
2717 #include <linux/usbdevice_fs.h>
2718
2719 #ifndef USBDEVFS_GET_CAPABILITIES
2720 #error "USBDEVFS_GET_CAPABILITIES undefined"
2721 #endif
2722
2723 #ifndef USBDEVFS_DISCONNECT_CLAIM
2724 #error "USBDEVFS_DISCONNECT_CLAIM undefined"
2725 #endif
2726
2727 int main(void)
2728 {
2729 return 0;
2730 }
2731 EOF
2732 if compile_prog "" ""; then
2733 have_usbfs=yes
2734 fi
2735 fi
2736
2737 ##########################################
2738 # check if we have VSS SDK headers for win
2739
2740 if test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
2741 test "$vss_win32_sdk" != "no" ; then
2742 case "$vss_win32_sdk" in
2743 "") vss_win32_include="-isystem $source_path" ;;
2744 *\ *) # The SDK is installed in "Program Files" by default, but we cannot
2745 # handle path with spaces. So we symlink the headers into ".sdk/vss".
2746 vss_win32_include="-isystem $source_path/.sdk/vss"
2747 symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
2748 ;;
2749 *) vss_win32_include="-isystem $vss_win32_sdk"
2750 esac
2751 cat > $TMPC << EOF
2752 #define __MIDL_user_allocate_free_DEFINED__
2753 #include <inc/win2003/vss.h>
2754 int main(void) { return VSS_CTX_BACKUP; }
2755 EOF
2756 if compile_prog "$vss_win32_include" "" ; then
2757 guest_agent_with_vss="yes"
2758 QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
2759 libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
2760 qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
2761 else
2762 if test "$vss_win32_sdk" != "" ; then
2763 echo "ERROR: Please download and install Microsoft VSS SDK:"
2764 echo "ERROR: http://www.microsoft.com/en-us/download/details.aspx?id=23490"
2765 echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
2766 echo "ERROR: scripts/extract-vsssdk-headers setup.exe"
2767 echo "ERROR: The headers are extracted in the directory \`inc'."
2768 feature_not_found "VSS support"
2769 fi
2770 guest_agent_with_vss="no"
2771 fi
2772 fi
2773
2774 ##########################################
2775 # lookup Windows platform SDK (if not specified)
2776 # The SDK is needed only to build .tlb (type library) file of guest agent
2777 # VSS provider from the source. It is usually unnecessary because the
2778 # pre-compiled .tlb file is included.
2779
2780 if test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
2781 test "$guest_agent_with_vss" = "yes" ; then
2782 if test -z "$win_sdk"; then
2783 programfiles="$PROGRAMFILES"
2784 test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
2785 if test -n "$programfiles"; then
2786 win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
2787 else
2788 feature_not_found "Windows SDK"
2789 fi
2790 elif test "$win_sdk" = "no"; then
2791 win_sdk=""
2792 fi
2793 fi
2794
2795 ##########################################
2796 # check if mingw environment provides a recent ntddscsi.h
2797 if test "$mingw32" = "yes" && test "$guest_agent" != "no"; then
2798 cat > $TMPC << EOF
2799 #include <windows.h>
2800 #include <ntddscsi.h>
2801 int main(void) {
2802 #if !defined(IOCTL_SCSI_GET_ADDRESS)
2803 #error Missing required ioctl definitions
2804 #endif
2805 SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
2806 return addr.Lun;
2807 }
2808 EOF
2809 if compile_prog "" "" ; then
2810 guest_agent_ntddscsi=yes
2811 libs_qga="-lsetupapi -lcfgmgr32 $libs_qga"
2812 fi
2813 fi
2814
2815 ##########################################
2816 # capstone
2817
2818 case "$capstone" in
2819 auto | enabled | internal)
2820 # Simpler to always update submodule, even if not needed.
2821 git_submodules="${git_submodules} capstone"
2822 ;;
2823 esac
2824
2825 ##########################################
2826 # check and set a backend for coroutine
2827
2828 # We prefer ucontext, but it's not always possible. The fallback
2829 # is sigcontext. On Windows the only valid backend is the Windows
2830 # specific one.
2831
2832 ucontext_works=no
2833 if test "$darwin" != "yes"; then
2834 cat > $TMPC << EOF
2835 #include <ucontext.h>
2836 #ifdef __stub_makecontext
2837 #error Ignoring glibc stub makecontext which will always fail
2838 #endif
2839 int main(void) { makecontext(0, 0, 0); return 0; }
2840 EOF
2841 if compile_prog "" "" ; then
2842 ucontext_works=yes
2843 fi
2844 fi
2845
2846 if test "$coroutine" = ""; then
2847 if test "$mingw32" = "yes"; then
2848 coroutine=win32
2849 elif test "$ucontext_works" = "yes"; then
2850 coroutine=ucontext
2851 else
2852 coroutine=sigaltstack
2853 fi
2854 else
2855 case $coroutine in
2856 windows)
2857 if test "$mingw32" != "yes"; then
2858 error_exit "'windows' coroutine backend only valid for Windows"
2859 fi
2860 # Unfortunately the user visible backend name doesn't match the
2861 # coroutine-*.c filename for this case, so we have to adjust it here.
2862 coroutine=win32
2863 ;;
2864 ucontext)
2865 if test "$ucontext_works" != "yes"; then
2866 feature_not_found "ucontext"
2867 fi
2868 ;;
2869 sigaltstack)
2870 if test "$mingw32" = "yes"; then
2871 error_exit "only the 'windows' coroutine backend is valid for Windows"
2872 fi
2873 ;;
2874 *)
2875 error_exit "unknown coroutine backend $coroutine"
2876 ;;
2877 esac
2878 fi
2879
2880 if test "$coroutine_pool" = ""; then
2881 coroutine_pool=yes
2882 fi
2883
2884 if test "$debug_stack_usage" = "yes"; then
2885 if test "$coroutine_pool" = "yes"; then
2886 echo "WARN: disabling coroutine pool for stack usage debugging"
2887 coroutine_pool=no
2888 fi
2889 fi
2890
2891 ##################################################
2892 # SafeStack
2893
2894
2895 if test "$safe_stack" = "yes"; then
2896 cat > $TMPC << EOF
2897 int main(int argc, char *argv[])
2898 {
2899 #if ! __has_feature(safe_stack)
2900 #error SafeStack Disabled
2901 #endif
2902 return 0;
2903 }
2904 EOF
2905 flag="-fsanitize=safe-stack"
2906 # Check that safe-stack is supported and enabled.
2907 if compile_prog "-Werror $flag" "$flag"; then
2908 # Flag needed both at compilation and at linking
2909 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
2910 QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
2911 else
2912 error_exit "SafeStack not supported by your compiler"
2913 fi
2914 if test "$coroutine" != "ucontext"; then
2915 error_exit "SafeStack is only supported by the coroutine backend ucontext"
2916 fi
2917 else
2918 cat > $TMPC << EOF
2919 int main(int argc, char *argv[])
2920 {
2921 #if defined(__has_feature)
2922 #if __has_feature(safe_stack)
2923 #error SafeStack Enabled
2924 #endif
2925 #endif
2926 return 0;
2927 }
2928 EOF
2929 if test "$safe_stack" = "no"; then
2930 # Make sure that safe-stack is disabled
2931 if ! compile_prog "-Werror" ""; then
2932 # SafeStack was already enabled, try to explicitly remove the feature
2933 flag="-fno-sanitize=safe-stack"
2934 if ! compile_prog "-Werror $flag" "$flag"; then
2935 error_exit "Configure cannot disable SafeStack"
2936 fi
2937 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
2938 QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
2939 fi
2940 else # "$safe_stack" = ""
2941 # Set safe_stack to yes or no based on pre-existing flags
2942 if compile_prog "-Werror" ""; then
2943 safe_stack="no"
2944 else
2945 safe_stack="yes"
2946 if test "$coroutine" != "ucontext"; then
2947 error_exit "SafeStack is only supported by the coroutine backend ucontext"
2948 fi
2949 fi
2950 fi
2951 fi
2952
2953 ########################################
2954 # check if cpuid.h is usable.
2955
2956 cat > $TMPC << EOF
2957 #include <cpuid.h>
2958 int main(void) {
2959 unsigned a, b, c, d;
2960 int max = __get_cpuid_max(0, 0);
2961
2962 if (max >= 1) {
2963 __cpuid(1, a, b, c, d);
2964 }
2965
2966 if (max >= 7) {
2967 __cpuid_count(7, 0, a, b, c, d);
2968 }
2969
2970 return 0;
2971 }
2972 EOF
2973 if compile_prog "" "" ; then
2974 cpuid_h=yes
2975 fi
2976
2977 ##########################################
2978 # avx2 optimization requirement check
2979 #
2980 # There is no point enabling this if cpuid.h is not usable,
2981 # since we won't be able to select the new routines.
2982
2983 if test "$cpuid_h" = "yes" && test "$avx2_opt" != "no"; then
2984 cat > $TMPC << EOF
2985 #pragma GCC push_options
2986 #pragma GCC target("avx2")
2987 #include <cpuid.h>
2988 #include <immintrin.h>
2989 static int bar(void *a) {
2990 __m256i x = *(__m256i *)a;
2991 return _mm256_testz_si256(x, x);
2992 }
2993 int main(int argc, char *argv[]) { return bar(argv[0]); }
2994 EOF
2995 if compile_object "-Werror" ; then
2996 avx2_opt="yes"
2997 else
2998 avx2_opt="no"
2999 fi
3000 fi
3001
3002 ##########################################
3003 # avx512f optimization requirement check
3004 #
3005 # There is no point enabling this if cpuid.h is not usable,
3006 # since we won't be able to select the new routines.
3007 # by default, it is turned off.
3008 # if user explicitly want to enable it, check environment
3009
3010 if test "$cpuid_h" = "yes" && test "$avx512f_opt" = "yes"; then
3011 cat > $TMPC << EOF
3012 #pragma GCC push_options
3013 #pragma GCC target("avx512f")
3014 #include <cpuid.h>
3015 #include <immintrin.h>
3016 static int bar(void *a) {
3017 __m512i x = *(__m512i *)a;
3018 return _mm512_test_epi64_mask(x, x);
3019 }
3020 int main(int argc, char *argv[])
3021 {
3022 return bar(argv[0]);
3023 }
3024 EOF
3025 if ! compile_object "-Werror" ; then
3026 avx512f_opt="no"
3027 fi
3028 else
3029 avx512f_opt="no"
3030 fi
3031
3032 ########################################
3033 # check if __[u]int128_t is usable.
3034
3035 int128=no
3036 cat > $TMPC << EOF
3037 __int128_t a;
3038 __uint128_t b;
3039 int main (void) {
3040 a = a + b;
3041 b = a * b;
3042 a = a * a;
3043 return 0;
3044 }
3045 EOF
3046 if compile_prog "" "" ; then
3047 int128=yes
3048 fi
3049
3050 #########################################
3051 # See if 128-bit atomic operations are supported.
3052
3053 atomic128=no
3054 if test "$int128" = "yes"; then
3055 cat > $TMPC << EOF
3056 int main(void)
3057 {
3058 unsigned __int128 x = 0, y = 0;
3059 y = __atomic_load(&x, 0);
3060 __atomic_store(&x, y, 0);
3061 __atomic_compare_exchange(&x, &y, x, 0, 0, 0);
3062 return 0;
3063 }
3064 EOF
3065 if compile_prog "" "" ; then
3066 atomic128=yes
3067 fi
3068 fi
3069
3070 cmpxchg128=no
3071 if test "$int128" = yes && test "$atomic128" = no; then
3072 cat > $TMPC << EOF
3073 int main(void)
3074 {
3075 unsigned __int128 x = 0, y = 0;
3076 __sync_val_compare_and_swap_16(&x, y, x);
3077 return 0;
3078 }
3079 EOF
3080 if compile_prog "" "" ; then
3081 cmpxchg128=yes
3082 fi
3083 fi
3084
3085 ########################################
3086 # check if ccache is interfering with
3087 # semantic analysis of macros
3088
3089 unset CCACHE_CPP2
3090 ccache_cpp2=no
3091 cat > $TMPC << EOF
3092 static const int Z = 1;
3093 #define fn() ({ Z; })
3094 #define TAUT(X) ((X) == Z)
3095 #define PAREN(X, Y) (X == Y)
3096 #define ID(X) (X)
3097 int main(int argc, char *argv[])
3098 {
3099 int x = 0, y = 0;
3100 x = ID(x);
3101 x = fn();
3102 fn();
3103 if (PAREN(x, y)) return 0;
3104 if (TAUT(Z)) return 0;
3105 return 0;
3106 }
3107 EOF
3108
3109 if ! compile_object "-Werror"; then
3110 ccache_cpp2=yes
3111 fi
3112
3113 #################################################
3114 # clang does not support glibc + FORTIFY_SOURCE.
3115
3116 if test "$fortify_source" != "no"; then
3117 if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
3118 fortify_source="no";
3119 elif test -n "$cxx" && has $cxx &&
3120 echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
3121 fortify_source="no";
3122 else
3123 fortify_source="yes"
3124 fi
3125 fi
3126
3127 ##########################################
3128 # check for usable membarrier system call
3129 if test "$membarrier" = "yes"; then
3130 have_membarrier=no
3131 if test "$mingw32" = "yes" ; then
3132 have_membarrier=yes
3133 elif test "$linux" = "yes" ; then
3134 cat > $TMPC << EOF
3135 #include <linux/membarrier.h>
3136 #include <sys/syscall.h>
3137 #include <unistd.h>
3138 #include <stdlib.h>
3139 int main(void) {
3140 syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
3141 syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0);
3142 exit(0);
3143 }
3144 EOF
3145 if compile_prog "" "" ; then
3146 have_membarrier=yes
3147 fi
3148 fi
3149 if test "$have_membarrier" = "no"; then
3150 feature_not_found "membarrier" "membarrier system call not available"
3151 fi
3152 else
3153 # Do not enable it by default even for Mingw32, because it doesn't
3154 # work on Wine.
3155 membarrier=no
3156 fi
3157
3158 ##########################################
3159 # check for usable AF_ALG environment
3160 have_afalg=no
3161 cat > $TMPC << EOF
3162 #include <errno.h>
3163 #include <sys/types.h>
3164 #include <sys/socket.h>
3165 #include <linux/if_alg.h>
3166 int main(void) {
3167 int sock;
3168 sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
3169 return sock;
3170 }
3171 EOF
3172 if compile_prog "" "" ; then
3173 have_afalg=yes
3174 fi
3175 if test "$crypto_afalg" = "yes"
3176 then
3177 if test "$have_afalg" != "yes"
3178 then
3179 error_exit "AF_ALG requested but could not be detected"
3180 fi
3181 fi
3182
3183
3184 ##########################################
3185 # checks for sanitizers
3186
3187 have_asan=no
3188 have_ubsan=no
3189 have_asan_iface_h=no
3190 have_asan_iface_fiber=no
3191
3192 if test "$sanitizers" = "yes" ; then
3193 write_c_skeleton
3194 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
3195 have_asan=yes
3196 fi
3197
3198 # we could use a simple skeleton for flags checks, but this also
3199 # detect the static linking issue of ubsan, see also:
3200 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
3201 cat > $TMPC << EOF
3202 #include <stdlib.h>
3203 int main(void) {
3204 void *tmp = malloc(10);
3205 if (tmp != NULL) {
3206 return *(int *)(tmp + 2);
3207 }
3208 return 1;
3209 }
3210 EOF
3211 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
3212 have_ubsan=yes
3213 fi
3214
3215 if check_include "sanitizer/asan_interface.h" ; then
3216 have_asan_iface_h=yes
3217 fi
3218
3219 cat > $TMPC << EOF
3220 #include <sanitizer/asan_interface.h>
3221 int main(void) {
3222 __sanitizer_start_switch_fiber(0, 0, 0);
3223 return 0;
3224 }
3225 EOF
3226 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
3227 have_asan_iface_fiber=yes
3228 fi
3229 fi
3230
3231 # Thread sanitizer is, for now, much noisier than the other sanitizers;
3232 # keep it separate until that is not the case.
3233 if test "$tsan" = "yes" && test "$sanitizers" = "yes"; then
3234 error_exit "TSAN is not supported with other sanitiziers."
3235 fi
3236 have_tsan=no
3237 have_tsan_iface_fiber=no
3238 if test "$tsan" = "yes" ; then
3239 write_c_skeleton
3240 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
3241 have_tsan=yes
3242 fi
3243 cat > $TMPC << EOF
3244 #include <sanitizer/tsan_interface.h>
3245 int main(void) {
3246 __tsan_create_fiber(0);
3247 return 0;
3248 }
3249 EOF
3250 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
3251 have_tsan_iface_fiber=yes
3252 fi
3253 fi
3254
3255 ##########################################
3256 # check for slirp
3257
3258 case "$slirp" in
3259 auto | enabled | internal)
3260 # Simpler to always update submodule, even if not needed.
3261 git_submodules="${git_submodules} slirp"
3262 ;;
3263 esac
3264
3265 # Check for slirp smbd dupport
3266 : ${smbd=${SMBD-/usr/sbin/smbd}}
3267 if test "$slirp_smbd" != "no" ; then
3268 if test "$mingw32" = "yes" ; then
3269 if test "$slirp_smbd" = "yes" ; then
3270 error_exit "Host smbd not supported on this platform."
3271 fi
3272 slirp_smbd=no
3273 else
3274 slirp_smbd=yes
3275 fi
3276 fi
3277
3278 ##########################################
3279 # check for usable __NR_keyctl syscall
3280
3281 if test "$linux" = "yes" ; then
3282
3283 have_keyring=no
3284 cat > $TMPC << EOF
3285 #include <errno.h>
3286 #include <asm/unistd.h>
3287 #include <linux/keyctl.h>
3288 #include <unistd.h>
3289 int main(void) {
3290 return syscall(__NR_keyctl, KEYCTL_READ, 0, NULL, NULL, 0);
3291 }
3292 EOF
3293 if compile_prog "" "" ; then
3294 have_keyring=yes
3295 fi
3296 fi
3297 if test "$secret_keyring" != "no"
3298 then
3299 if test "$have_keyring" = "yes"
3300 then
3301 secret_keyring=yes
3302 else
3303 if test "$secret_keyring" = "yes"
3304 then
3305 error_exit "syscall __NR_keyctl requested, \
3306 but not implemented on your system"
3307 else
3308 secret_keyring=no
3309 fi
3310 fi
3311 fi
3312
3313 ##########################################
3314 # End of CC checks
3315 # After here, no more $cc or $ld runs
3316
3317 write_c_skeleton
3318
3319 if test "$gcov" = "yes" ; then
3320 :
3321 elif test "$fortify_source" = "yes" ; then
3322 QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
3323 debug=no
3324 fi
3325
3326 case "$ARCH" in
3327 alpha)
3328 # Ensure there's only a single GP
3329 QEMU_CFLAGS="-msmall-data $QEMU_CFLAGS"
3330 ;;
3331 esac
3332
3333 if test "$gprof" = "yes" ; then
3334 QEMU_CFLAGS="-p $QEMU_CFLAGS"
3335 QEMU_LDFLAGS="-p $QEMU_LDFLAGS"
3336 fi
3337
3338 if test "$have_asan" = "yes"; then
3339 QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS"
3340 QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS"
3341 if test "$have_asan_iface_h" = "no" ; then
3342 echo "ASAN build enabled, but ASAN header missing." \
3343 "Without code annotation, the report may be inferior."
3344 elif test "$have_asan_iface_fiber" = "no" ; then
3345 echo "ASAN build enabled, but ASAN header is too old." \
3346 "Without code annotation, the report may be inferior."
3347 fi
3348 fi
3349 if test "$have_tsan" = "yes" ; then
3350 if test "$have_tsan_iface_fiber" = "yes" ; then
3351 QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS"
3352 QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS"
3353 else
3354 error_exit "Cannot enable TSAN due to missing fiber annotation interface."
3355 fi
3356 elif test "$tsan" = "yes" ; then
3357 error_exit "Cannot enable TSAN due to missing sanitize thread interface."
3358 fi
3359 if test "$have_ubsan" = "yes"; then
3360 QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS"
3361 QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS"
3362 fi
3363
3364 ##########################################
3365
3366 # Exclude --warn-common with TSan to suppress warnings from the TSan libraries.
3367 if test "$solaris" = "no" && test "$tsan" = "no"; then
3368 if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
3369 QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS"
3370 fi
3371 fi
3372
3373 # Use ASLR, no-SEH and DEP if available
3374 if test "$mingw32" = "yes" ; then
3375 flags="--no-seh --nxcompat"
3376
3377 # Disable ASLR for debug builds to allow debugging with gdb
3378 if test "$debug" = "no" ; then
3379 flags="--dynamicbase $flags"
3380 fi
3381
3382 for flag in $flags; do
3383 if ld_has $flag ; then
3384 QEMU_LDFLAGS="-Wl,$flag $QEMU_LDFLAGS"
3385 fi
3386 done
3387 fi
3388
3389 # Probe for guest agent support/options
3390
3391 if [ "$guest_agent" != "no" ]; then
3392 if [ "$softmmu" = no -a "$want_tools" = no ] ; then
3393 guest_agent=no
3394 elif [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
3395 guest_agent=yes
3396 elif [ "$guest_agent" != yes ]; then
3397 guest_agent=no
3398 else
3399 error_exit "Guest agent is not supported on this platform"
3400 fi
3401 fi
3402
3403 # Guest agent Windows MSI package
3404
3405 if test "$QEMU_GA_MANUFACTURER" = ""; then
3406 QEMU_GA_MANUFACTURER=QEMU
3407 fi
3408 if test "$QEMU_GA_DISTRO" = ""; then
3409 QEMU_GA_DISTRO=Linux
3410 fi
3411 if test "$QEMU_GA_VERSION" = ""; then
3412 QEMU_GA_VERSION=$(cat $source_path/VERSION)
3413 fi
3414
3415 QEMU_GA_MSI_MINGW_DLL_PATH="$($pkg_config --variable=prefix glib-2.0)/bin"
3416
3417 # Mac OS X ships with a broken assembler
3418 roms=
3419 if { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \
3420 test "$targetos" != "Darwin" && test "$targetos" != "SunOS" && \
3421 test "$targetos" != "Haiku" && test "$softmmu" = yes ; then
3422 # Different host OS linkers have different ideas about the name of the ELF
3423 # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
3424 # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
3425 for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
3426 if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
3427 ld_i386_emulation="$emu"
3428 roms="optionrom"
3429 break
3430 fi
3431 done
3432 fi
3433
3434 # Only build s390-ccw bios if we're on s390x and the compiler has -march=z900
3435 # or -march=z10 (which is the lowest architecture level that Clang supports)
3436 if test "$cpu" = "s390x" ; then
3437 write_c_skeleton
3438 compile_prog "-march=z900" ""
3439 has_z900=$?
3440 if [ $has_z900 = 0 ] || compile_object "-march=z10 -msoft-float -Werror"; then
3441 if [ $has_z900 != 0 ]; then
3442 echo "WARNING: Your compiler does not support the z900!"
3443 echo " The s390-ccw bios will only work with guest CPUs >= z10."
3444 fi
3445 roms="$roms s390-ccw"
3446 # SLOF is required for building the s390-ccw firmware on s390x,
3447 # since it is using the libnet code from SLOF for network booting.
3448 git_submodules="${git_submodules} roms/SLOF"
3449 fi
3450 fi
3451
3452 # Check that the C++ compiler exists and works with the C compiler.
3453 # All the QEMU_CXXFLAGS are based on QEMU_CFLAGS. Keep this at the end to don't miss any other that could be added.
3454 if has $cxx; then
3455 cat > $TMPC <<EOF
3456 int c_function(void);
3457 int main(void) { return c_function(); }
3458 EOF
3459
3460 compile_object
3461
3462 cat > $TMPCXX <<EOF
3463 extern "C" {
3464 int c_function(void);
3465 }
3466 int c_function(void) { return 42; }
3467 EOF
3468
3469 update_cxxflags
3470
3471 if do_cxx $CXXFLAGS $CONFIGURE_CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then
3472 # C++ compiler $cxx works ok with C compiler $cc
3473 :
3474 else
3475 echo "C++ compiler $cxx does not work with C compiler $cc"
3476 echo "Disabling C++ specific optional code"
3477 cxx=
3478 fi
3479 else
3480 echo "No C++ compiler available; disabling C++ specific optional code"
3481 cxx=
3482 fi
3483
3484 if !(GIT="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then
3485 exit 1
3486 fi
3487
3488 config_host_mak="config-host.mak"
3489
3490 echo "# Automatically generated by configure - do not modify" > $config_host_mak
3491 echo >> $config_host_mak
3492
3493 echo all: >> $config_host_mak
3494 echo "GIT=$git" >> $config_host_mak
3495 echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
3496 echo "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak
3497
3498 echo "ARCH=$ARCH" >> $config_host_mak
3499
3500 if test "$debug_tcg" = "yes" ; then
3501 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
3502 fi
3503 if test "$strip_opt" = "yes" ; then
3504 echo "STRIP=${strip}" >> $config_host_mak
3505 fi
3506 if test "$mingw32" = "yes" ; then
3507 echo "CONFIG_WIN32=y" >> $config_host_mak
3508 if test "$guest_agent_with_vss" = "yes" ; then
3509 echo "CONFIG_QGA_VSS=y" >> $config_host_mak
3510 echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
3511 echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
3512 fi
3513 if test "$guest_agent_ntddscsi" = "yes" ; then
3514 echo "CONFIG_QGA_NTDDSCSI=y" >> $config_host_mak
3515 fi
3516 echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
3517 echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
3518 echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
3519 echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
3520 else
3521 echo "CONFIG_POSIX=y" >> $config_host_mak
3522 fi
3523
3524 if test "$linux" = "yes" ; then
3525 echo "CONFIG_LINUX=y" >> $config_host_mak
3526 fi
3527
3528 if test "$darwin" = "yes" ; then
3529 echo "CONFIG_DARWIN=y" >> $config_host_mak
3530 fi
3531
3532 if test "$solaris" = "yes" ; then
3533 echo "CONFIG_SOLARIS=y" >> $config_host_mak
3534 fi
3535 if test "$haiku" = "yes" ; then
3536 echo "CONFIG_HAIKU=y" >> $config_host_mak
3537 fi
3538 if test "$static" = "yes" ; then
3539 echo "CONFIG_STATIC=y" >> $config_host_mak
3540 fi
3541 if test "$profiler" = "yes" ; then
3542 echo "CONFIG_PROFILER=y" >> $config_host_mak
3543 fi
3544 if test "$want_tools" = "yes" ; then
3545 echo "CONFIG_TOOLS=y" >> $config_host_mak
3546 fi
3547 if test "$guest_agent" = "yes" ; then
3548 echo "CONFIG_GUEST_AGENT=y" >> $config_host_mak
3549 fi
3550 if test "$slirp_smbd" = "yes" ; then
3551 echo "CONFIG_SLIRP_SMBD=y" >> $config_host_mak
3552 echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
3553 fi
3554 if test "$l2tpv3" = "yes" ; then
3555 echo "CONFIG_L2TPV3=y" >> $config_host_mak
3556 fi
3557 if test "$gprof" = "yes" ; then
3558 echo "CONFIG_GPROF=y" >> $config_host_mak
3559 fi
3560 echo "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
3561 echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
3562 if test "$block_drv_whitelist_tools" = "yes" ; then
3563 echo "CONFIG_BDRV_WHITELIST_TOOLS=y" >> $config_host_mak
3564 fi
3565 if test "$xfs" = "yes" ; then
3566 echo "CONFIG_XFS=y" >> $config_host_mak
3567 fi
3568 qemu_version=$(head $source_path/VERSION)
3569 echo "PKGVERSION=$pkgversion" >>$config_host_mak
3570 echo "SRC_PATH=$source_path" >> $config_host_mak
3571 echo "TARGET_DIRS=$target_list" >> $config_host_mak
3572 if test "$modules" = "yes"; then
3573 # $shacmd can generate a hash started with digit, which the compiler doesn't
3574 # like as an symbol. So prefix it with an underscore
3575 echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
3576 echo "CONFIG_MODULES=y" >> $config_host_mak
3577 fi
3578 if test "$module_upgrades" = "yes"; then
3579 echo "CONFIG_MODULE_UPGRADES=y" >> $config_host_mak
3580 fi
3581 if test "$have_usbfs" = "yes" ; then
3582 echo "CONFIG_USBFS=y" >> $config_host_mak
3583 fi
3584 if test "$gio" = "yes" ; then
3585 echo "CONFIG_GIO=y" >> $config_host_mak
3586 echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak
3587 echo "GIO_LIBS=$gio_libs" >> $config_host_mak
3588 fi
3589 if test "$gdbus_codegen" != "" ; then
3590 echo "GDBUS_CODEGEN=$gdbus_codegen" >> $config_host_mak
3591 fi
3592 echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
3593
3594 if test "$xen" = "enabled" ; then
3595 echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
3596 echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
3597 echo "XEN_CFLAGS=$xen_cflags" >> $config_host_mak
3598 echo "XEN_LIBS=$xen_libs" >> $config_host_mak
3599 fi
3600 if test "$vhost_scsi" = "yes" ; then
3601 echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
3602 fi
3603 if test "$vhost_net" = "yes" ; then
3604 echo "CONFIG_VHOST_NET=y" >> $config_host_mak
3605 fi
3606 if test "$vhost_net_user" = "yes" ; then
3607 echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak
3608 fi
3609 if test "$vhost_net_vdpa" = "yes" ; then
3610 echo "CONFIG_VHOST_NET_VDPA=y" >> $config_host_mak
3611 fi
3612 if test "$vhost_crypto" = "yes" ; then
3613 echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
3614 fi
3615 if test "$vhost_vsock" = "yes" ; then
3616 echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
3617 if test "$vhost_user" = "yes" ; then
3618 echo "CONFIG_VHOST_USER_VSOCK=y" >> $config_host_mak
3619 fi
3620 fi
3621 if test "$vhost_kernel" = "yes" ; then
3622 echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak
3623 fi
3624 if test "$vhost_user" = "yes" ; then
3625 echo "CONFIG_VHOST_USER=y" >> $config_host_mak
3626 fi
3627 if test "$vhost_vdpa" = "yes" ; then
3628 echo "CONFIG_VHOST_VDPA=y" >> $config_host_mak
3629 fi
3630 if test "$vhost_user_fs" = "yes" ; then
3631 echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak
3632 fi
3633 if test "$membarrier" = "yes" ; then
3634 echo "CONFIG_MEMBARRIER=y" >> $config_host_mak
3635 fi
3636 if test "$tcg" = "enabled" -a "$tcg_interpreter" = "true" ; then
3637 echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
3638 fi
3639
3640 if test "$opengl" = "yes" ; then
3641 echo "CONFIG_OPENGL=y" >> $config_host_mak
3642 echo "OPENGL_CFLAGS=$opengl_cflags" >> $config_host_mak
3643 echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
3644 fi
3645
3646 if test "$avx2_opt" = "yes" ; then
3647 echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
3648 fi
3649
3650 if test "$avx512f_opt" = "yes" ; then
3651 echo "CONFIG_AVX512F_OPT=y" >> $config_host_mak
3652 fi
3653
3654 # XXX: suppress that
3655 if [ "$bsd" = "yes" ] ; then
3656 echo "CONFIG_BSD=y" >> $config_host_mak
3657 fi
3658
3659 if test "$qom_cast_debug" = "yes" ; then
3660 echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
3661 fi
3662
3663 echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
3664 if test "$coroutine_pool" = "yes" ; then
3665 echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
3666 else
3667 echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
3668 fi
3669
3670 if test "$debug_stack_usage" = "yes" ; then
3671 echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
3672 fi
3673
3674 if test "$crypto_afalg" = "yes" ; then
3675 echo "CONFIG_AF_ALG=y" >> $config_host_mak
3676 fi
3677
3678 if test "$have_asan_iface_fiber" = "yes" ; then
3679 echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
3680 fi
3681
3682 if test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then
3683 echo "CONFIG_TSAN=y" >> $config_host_mak
3684 fi
3685
3686 if test "$cpuid_h" = "yes" ; then
3687 echo "CONFIG_CPUID_H=y" >> $config_host_mak
3688 fi
3689
3690 if test "$int128" = "yes" ; then
3691 echo "CONFIG_INT128=y" >> $config_host_mak
3692 fi
3693
3694 if test "$atomic128" = "yes" ; then
3695 echo "CONFIG_ATOMIC128=y" >> $config_host_mak
3696 fi
3697
3698 if test "$cmpxchg128" = "yes" ; then
3699 echo "CONFIG_CMPXCHG128=y" >> $config_host_mak
3700 fi
3701
3702 if test "$libssh" = "yes" ; then
3703 echo "CONFIG_LIBSSH=y" >> $config_host_mak
3704 echo "LIBSSH_CFLAGS=$libssh_cflags" >> $config_host_mak
3705 echo "LIBSSH_LIBS=$libssh_libs" >> $config_host_mak
3706 fi
3707
3708 if test "$live_block_migration" = "yes" ; then
3709 echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
3710 fi
3711
3712 if test "$tpm" = "yes"; then
3713 echo 'CONFIG_TPM=y' >> $config_host_mak
3714 fi
3715
3716 if test "$rdma" = "yes" ; then
3717 echo "CONFIG_RDMA=y" >> $config_host_mak
3718 echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
3719 fi
3720
3721 if test "$pvrdma" = "yes" ; then
3722 echo "CONFIG_PVRDMA=y" >> $config_host_mak
3723 fi
3724
3725 if test "$replication" = "yes" ; then
3726 echo "CONFIG_REPLICATION=y" >> $config_host_mak
3727 fi
3728
3729 if test "$debug_mutex" = "yes" ; then
3730 echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak
3731 fi
3732
3733 if test "$bochs" = "yes" ; then
3734 echo "CONFIG_BOCHS=y" >> $config_host_mak
3735 fi
3736 if test "$cloop" = "yes" ; then
3737 echo "CONFIG_CLOOP=y" >> $config_host_mak
3738 fi
3739 if test "$dmg" = "yes" ; then
3740 echo "CONFIG_DMG=y" >> $config_host_mak
3741 fi
3742 if test "$qcow1" = "yes" ; then
3743 echo "CONFIG_QCOW1=y" >> $config_host_mak
3744 fi
3745 if test "$vdi" = "yes" ; then
3746 echo "CONFIG_VDI=y" >> $config_host_mak
3747 fi
3748 if test "$vvfat" = "yes" ; then
3749 echo "CONFIG_VVFAT=y" >> $config_host_mak
3750 fi
3751 if test "$qed" = "yes" ; then
3752 echo "CONFIG_QED=y" >> $config_host_mak
3753 fi
3754 if test "$parallels" = "yes" ; then
3755 echo "CONFIG_PARALLELS=y" >> $config_host_mak
3756 fi
3757
3758 if test "$plugins" = "yes" ; then
3759 echo "CONFIG_PLUGIN=y" >> $config_host_mak
3760 # Copy the export object list to the build dir
3761 if test "$ld_dynamic_list" = "yes" ; then
3762 echo "CONFIG_HAS_LD_DYNAMIC_LIST=yes" >> $config_host_mak
3763 ld_symbols=qemu-plugins-ld.symbols
3764 cp "$source_path/plugins/qemu-plugins.symbols" $ld_symbols
3765 elif test "$ld_exported_symbols_list" = "yes" ; then
3766 echo "CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST=yes" >> $config_host_mak
3767 ld64_symbols=qemu-plugins-ld64.symbols
3768 echo "# Automatically generated by configure - do not modify" > $ld64_symbols
3769 grep 'qemu_' "$source_path/plugins/qemu-plugins.symbols" | sed 's/;//g' | \
3770 sed -E 's/^[[:space:]]*(.*)/_\1/' >> $ld64_symbols
3771 else
3772 error_exit \
3773 "If \$plugins=yes, either \$ld_dynamic_list or " \
3774 "\$ld_exported_symbols_list should have been set to 'yes'."
3775 fi
3776 fi
3777
3778 if test -n "$gdb_bin"; then
3779 gdb_version=$($gdb_bin --version | head -n 1)
3780 if version_ge ${gdb_version##* } 9.1; then
3781 echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
3782 fi
3783 fi
3784
3785 if test "$secret_keyring" = "yes" ; then
3786 echo "CONFIG_SECRET_KEYRING=y" >> $config_host_mak
3787 fi
3788
3789 echo "ROMS=$roms" >> $config_host_mak
3790 echo "MAKE=$make" >> $config_host_mak
3791 echo "PYTHON=$python" >> $config_host_mak
3792 echo "GENISOIMAGE=$genisoimage" >> $config_host_mak
3793 echo "MESON=$meson" >> $config_host_mak
3794 echo "NINJA=$ninja" >> $config_host_mak
3795 echo "CC=$cc" >> $config_host_mak
3796 echo "HOST_CC=$host_cc" >> $config_host_mak
3797 if $iasl -h > /dev/null 2>&1; then
3798 echo "CONFIG_IASL=$iasl" >> $config_host_mak
3799 fi
3800 echo "AR=$ar" >> $config_host_mak
3801 echo "AS=$as" >> $config_host_mak
3802 echo "CCAS=$ccas" >> $config_host_mak
3803 echo "CPP=$cpp" >> $config_host_mak
3804 echo "OBJCOPY=$objcopy" >> $config_host_mak
3805 echo "LD=$ld" >> $config_host_mak
3806 echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
3807 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
3808 echo "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
3809 echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
3810 echo "GLIB_LIBS=$glib_libs" >> $config_host_mak
3811 echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
3812 echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
3813 echo "EXESUF=$EXESUF" >> $config_host_mak
3814 echo "LIBS_QGA=$libs_qga" >> $config_host_mak
3815
3816 if test "$rng_none" = "yes"; then
3817 echo "CONFIG_RNG_NONE=y" >> $config_host_mak
3818 fi
3819
3820 # use included Linux headers
3821 if test "$linux" = "yes" ; then
3822 mkdir -p linux-headers
3823 case "$cpu" in
3824 i386|x86_64|x32)
3825 linux_arch=x86
3826 ;;
3827 ppc|ppc64|ppc64le)
3828 linux_arch=powerpc
3829 ;;
3830 s390x)
3831 linux_arch=s390
3832 ;;
3833 aarch64)
3834 linux_arch=arm64
3835 ;;
3836 mips64)
3837 linux_arch=mips
3838 ;;
3839 *)
3840 # For most CPUs the kernel architecture name and QEMU CPU name match.
3841 linux_arch="$cpu"
3842 ;;
3843 esac
3844 # For non-KVM architectures we will not have asm headers
3845 if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
3846 symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
3847 fi
3848 fi
3849
3850 for target in $target_list; do
3851 target_dir="$target"
3852 target_name=$(echo $target | cut -d '-' -f 1)
3853 mkdir -p $target_dir
3854 case $target in
3855 *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;;
3856 *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;;
3857 esac
3858 done
3859
3860 echo "CONFIG_QEMU_INTERP_PREFIX=$interp_prefix" | sed 's/%M/@0@/' >> $config_host_mak
3861 if test "$default_targets" = "yes"; then
3862 echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak
3863 fi
3864
3865 if test "$numa" = "yes"; then
3866 echo "CONFIG_NUMA=y" >> $config_host_mak
3867 echo "NUMA_LIBS=$numa_libs" >> $config_host_mak
3868 fi
3869
3870 if test "$ccache_cpp2" = "yes"; then
3871 echo "export CCACHE_CPP2=y" >> $config_host_mak
3872 fi
3873
3874 if test "$safe_stack" = "yes"; then
3875 echo "CONFIG_SAFESTACK=y" >> $config_host_mak
3876 fi
3877
3878 # If we're using a separate build tree, set it up now.
3879 # DIRS are directories which we simply mkdir in the build tree;
3880 # LINKS are things to symlink back into the source tree
3881 # (these can be both files and directories).
3882 # Caution: do not add files or directories here using wildcards. This
3883 # will result in problems later if a new file matching the wildcard is
3884 # added to the source tree -- nothing will cause configure to be rerun
3885 # so the build tree will be missing the link back to the new file, and
3886 # tests might fail. Prefer to keep the relevant files in their own
3887 # directory and symlink the directory instead.
3888 # UNLINK is used to remove symlinks from older development versions
3889 # that might get into the way when doing "git update" without doing
3890 # a "make distclean" in between.
3891 DIRS="tests tests/tcg tests/qapi-schema tests/qtest/libqos"
3892 DIRS="$DIRS tests/qtest tests/qemu-iotests tests/vm tests/fp tests/qgraph"
3893 DIRS="$DIRS docs docs/interop fsdev scsi"
3894 DIRS="$DIRS pc-bios/optionrom pc-bios/s390-ccw"
3895 DIRS="$DIRS roms/seabios"
3896 DIRS="$DIRS contrib/plugins/"
3897 LINKS="Makefile"
3898 LINKS="$LINKS tests/tcg/Makefile.target"
3899 LINKS="$LINKS pc-bios/optionrom/Makefile"
3900 LINKS="$LINKS pc-bios/s390-ccw/Makefile"
3901 LINKS="$LINKS roms/seabios/Makefile"
3902 LINKS="$LINKS pc-bios/qemu-icon.bmp"
3903 LINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
3904 LINKS="$LINKS tests/acceptance tests/data"
3905 LINKS="$LINKS tests/qemu-iotests/check"
3906 LINKS="$LINKS python"
3907 LINKS="$LINKS contrib/plugins/Makefile "
3908 UNLINK="pc-bios/keymaps"
3909 for bios_file in \
3910 $source_path/pc-bios/*.bin \
3911 $source_path/pc-bios/*.elf \
3912 $source_path/pc-bios/*.lid \
3913 $source_path/pc-bios/*.rom \
3914 $source_path/pc-bios/*.dtb \
3915 $source_path/pc-bios/*.img \
3916 $source_path/pc-bios/openbios-* \
3917 $source_path/pc-bios/u-boot.* \
3918 $source_path/pc-bios/edk2-*.fd.bz2 \
3919 $source_path/pc-bios/palcode-* \
3920 $source_path/pc-bios/qemu_vga.ndrv
3921
3922 do
3923 LINKS="$LINKS pc-bios/$(basename $bios_file)"
3924 done
3925 mkdir -p $DIRS
3926 for f in $LINKS ; do
3927 if [ -e "$source_path/$f" ]; then
3928 symlink "$source_path/$f" "$f"
3929 fi
3930 done
3931 for f in $UNLINK ; do
3932 if [ -L "$f" ]; then
3933 rm -f "$f"
3934 fi
3935 done
3936
3937 (for i in $cross_cc_vars; do
3938 export $i
3939 done
3940 export target_list source_path use_containers ARCH
3941 $source_path/tests/tcg/configure.sh)
3942
3943 # temporary config to build submodules
3944 for rom in seabios; do
3945 config_mak=roms/$rom/config.mak
3946 echo "# Automatically generated by configure - do not modify" > $config_mak
3947 echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
3948 echo "AS=$as" >> $config_mak
3949 echo "CCAS=$ccas" >> $config_mak
3950 echo "CC=$cc" >> $config_mak
3951 echo "BCC=bcc" >> $config_mak
3952 echo "CPP=$cpp" >> $config_mak
3953 echo "OBJCOPY=objcopy" >> $config_mak
3954 echo "IASL=$iasl" >> $config_mak
3955 echo "LD=$ld" >> $config_mak
3956 echo "RANLIB=$ranlib" >> $config_mak
3957 done
3958
3959 if test "$skip_meson" = no; then
3960 cross="config-meson.cross.new"
3961 meson_quote() {
3962 echo "'$(echo $* | sed "s/ /','/g")'"
3963 }
3964
3965 echo "# Automatically generated by configure - do not modify" > $cross
3966 echo "[properties]" >> $cross
3967
3968 # unroll any custom device configs
3969 for a in $device_archs; do
3970 eval "c=\$devices_${a}"
3971 echo "${a}-softmmu = '$c'" >> $cross
3972 done
3973
3974 test -z "$cxx" && echo "link_language = 'c'" >> $cross
3975 echo "[built-in options]" >> $cross
3976 echo "c_args = [${CFLAGS:+$(meson_quote $CFLAGS)}]" >> $cross
3977 echo "cpp_args = [${CXXFLAGS:+$(meson_quote $CXXFLAGS)}]" >> $cross
3978 echo "c_link_args = [${LDFLAGS:+$(meson_quote $LDFLAGS)}]" >> $cross
3979 echo "cpp_link_args = [${LDFLAGS:+$(meson_quote $LDFLAGS)}]" >> $cross
3980 echo "[binaries]" >> $cross
3981 echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross
3982 test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross
3983 test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross
3984 echo "ar = [$(meson_quote $ar)]" >> $cross
3985 echo "nm = [$(meson_quote $nm)]" >> $cross
3986 echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross
3987 echo "ranlib = [$(meson_quote $ranlib)]" >> $cross
3988 if has $sdl2_config; then
3989 echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross
3990 fi
3991 echo "strip = [$(meson_quote $strip)]" >> $cross
3992 echo "windres = [$(meson_quote $windres)]" >> $cross
3993 if test "$cross_compile" = "yes"; then
3994 cross_arg="--cross-file config-meson.cross"
3995 echo "[host_machine]" >> $cross
3996 if test "$mingw32" = "yes" ; then
3997 echo "system = 'windows'" >> $cross
3998 fi
3999 if test "$linux" = "yes" ; then
4000 echo "system = 'linux'" >> $cross
4001 fi
4002 if test "$darwin" = "yes" ; then
4003 echo "system = 'darwin'" >> $cross
4004 fi
4005 case "$ARCH" in
4006 i386)
4007 echo "cpu_family = 'x86'" >> $cross
4008 ;;
4009 x86_64|x32)
4010 echo "cpu_family = 'x86_64'" >> $cross
4011 ;;
4012 ppc64le)
4013 echo "cpu_family = 'ppc64'" >> $cross
4014 ;;
4015 *)
4016 echo "cpu_family = '$ARCH'" >> $cross
4017 ;;
4018 esac
4019 echo "cpu = '$cpu'" >> $cross
4020 if test "$bigendian" = "yes" ; then
4021 echo "endian = 'big'" >> $cross
4022 else
4023 echo "endian = 'little'" >> $cross
4024 fi
4025 else
4026 cross_arg="--native-file config-meson.cross"
4027 fi
4028 mv $cross config-meson.cross
4029
4030 rm -rf meson-private meson-info meson-logs
4031 run_meson() {
4032 NINJA=$ninja $meson setup \
4033 --prefix "$prefix" \
4034 --libdir "$libdir" \
4035 --libexecdir "$libexecdir" \
4036 --bindir "$bindir" \
4037 --includedir "$includedir" \
4038 --datadir "$datadir" \
4039 --mandir "$mandir" \
4040 --sysconfdir "$sysconfdir" \
4041 --localedir "$localedir" \
4042 --localstatedir "$local_statedir" \
4043 -Daudio_drv_list=$audio_drv_list \
4044 -Ddefault_devices=$default_devices \
4045 -Ddocdir="$docdir" \
4046 -Dqemu_firmwarepath="$firmwarepath" \
4047 -Dqemu_suffix="$qemu_suffix" \
4048 -Dsphinx_build="$sphinx_build" \
4049 -Dtrace_file="$trace_file" \
4050 -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) \
4051 -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo false; fi) \
4052 -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \
4053 -Dstrip=$(if test "$strip_opt" = yes; then echo true; else echo false; fi) \
4054 -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \
4055 -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \
4056 -Db_lto=$lto -Dcfi=$cfi -Dtcg=$tcg -Dxen=$xen \
4057 -Dcapstone=$capstone -Dfdt=$fdt -Dslirp=$slirp \
4058 $(test -n "${LIB_FUZZING_ENGINE+xxx}" && echo "-Dfuzzing_engine=$LIB_FUZZING_ENGINE") \
4059 $(if test "$default_feature" = no; then echo "-Dauto_features=disabled"; fi) \
4060 "$@" $cross_arg "$PWD" "$source_path"
4061 }
4062 eval run_meson $meson_options
4063 if test "$?" -ne 0 ; then
4064 error_exit "meson setup failed"
4065 fi
4066 else
4067 if test -f meson-private/cmd_line.txt; then
4068 # Adjust old command line options whose type was changed
4069 # Avoids having to use "setup --wipe" when Meson is upgraded
4070 perl -i -ne '
4071 s/^gettext = true$/gettext = auto/;
4072 s/^gettext = false$/gettext = disabled/;
4073 /^b_staticpic/ && next;
4074 print;' meson-private/cmd_line.txt
4075 fi
4076 fi
4077
4078 if test -n "${deprecated_features}"; then
4079 echo "Warning, deprecated features enabled."
4080 echo "Please see docs/about/deprecated.rst"
4081 echo " features: ${deprecated_features}"
4082 fi
4083
4084 # Create list of config switches that should be poisoned in common code...
4085 # but filter out CONFIG_TCG and CONFIG_USER_ONLY which are special.
4086 target_configs_h=$(ls *-config-devices.h *-config-target.h 2>/dev/null)
4087 if test -n "$target_configs_h" ; then
4088 sed -n -e '/CONFIG_TCG/d' -e '/CONFIG_USER_ONLY/d' \
4089 -e '/^#define / { s///; s/ .*//; s/^/#pragma GCC poison /p; }' \
4090 $target_configs_h | sort -u > config-poison.h
4091 else
4092 :> config-poison.h
4093 fi
4094
4095 # Save the configure command line for later reuse.
4096 cat <<EOD >config.status
4097 #!/bin/sh
4098 # Generated by configure.
4099 # Run this file to recreate the current configuration.
4100 # Compiler output produced by configure, useful for debugging
4101 # configure, is in config.log if it exists.
4102 EOD
4103
4104 preserve_env() {
4105 envname=$1
4106
4107 eval envval=\$$envname
4108
4109 if test -n "$envval"
4110 then
4111 echo "$envname='$envval'" >> config.status
4112 echo "export $envname" >> config.status
4113 else
4114 echo "unset $envname" >> config.status
4115 fi
4116 }
4117
4118 # Preserve various env variables that influence what
4119 # features/build target configure will detect
4120 preserve_env AR
4121 preserve_env AS
4122 preserve_env CC
4123 preserve_env CPP
4124 preserve_env CXX
4125 preserve_env INSTALL
4126 preserve_env LD
4127 preserve_env LD_LIBRARY_PATH
4128 preserve_env LIBTOOL
4129 preserve_env MAKE
4130 preserve_env NM
4131 preserve_env OBJCOPY
4132 preserve_env PATH
4133 preserve_env PKG_CONFIG
4134 preserve_env PKG_CONFIG_LIBDIR
4135 preserve_env PKG_CONFIG_PATH
4136 preserve_env PYTHON
4137 preserve_env SDL2_CONFIG
4138 preserve_env SMBD
4139 preserve_env STRIP
4140 preserve_env WINDRES
4141
4142 printf "exec" >>config.status
4143 for i in "$0" "$@"; do
4144 test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status
4145 done
4146 echo ' "$@"' >>config.status
4147 chmod +x config.status
4148
4149 rm -r "$TMPDIR1"