]> git.proxmox.com Git - mirror_qemu.git/blob - configure
configure: integrate Meson in the build system
[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 TMPMO="${TMPDIR1}/${TMPB}.mo"
82 TMPTXT="${TMPDIR1}/${TMPB}.txt"
83
84 rm -f config.log
85
86 # Print a helpful header at the top of config.log
87 echo "# QEMU configure log $(date)" >> config.log
88 printf "# Configured with:" >> config.log
89 printf " '%s'" "$0" "$@" >> config.log
90 echo >> config.log
91 echo "#" >> config.log
92
93 print_error() {
94 (echo
95 echo "ERROR: $1"
96 while test -n "$2"; do
97 echo " $2"
98 shift
99 done
100 echo) >&2
101 }
102
103 error_exit() {
104 print_error "$@"
105 exit 1
106 }
107
108 do_compiler() {
109 # Run the compiler, capturing its output to the log. First argument
110 # is compiler binary to execute.
111 local compiler="$1"
112 shift
113 if test -n "$BASH_VERSION"; then eval '
114 echo >>config.log "
115 funcs: ${FUNCNAME[*]}
116 lines: ${BASH_LINENO[*]}"
117 '; fi
118 echo $compiler "$@" >> config.log
119 $compiler "$@" >> config.log 2>&1 || return $?
120 # Test passed. If this is an --enable-werror build, rerun
121 # the test with -Werror and bail out if it fails. This
122 # makes warning-generating-errors in configure test code
123 # obvious to developers.
124 if test "$werror" != "yes"; then
125 return 0
126 fi
127 # Don't bother rerunning the compile if we were already using -Werror
128 case "$*" in
129 *-Werror*)
130 return 0
131 ;;
132 esac
133 echo $compiler -Werror "$@" >> config.log
134 $compiler -Werror "$@" >> config.log 2>&1 && return $?
135 error_exit "configure test passed without -Werror but failed with -Werror." \
136 "This is probably a bug in the configure script. The failing command" \
137 "will be at the bottom of config.log." \
138 "You can run configure with --disable-werror to bypass this check."
139 }
140
141 do_cc() {
142 do_compiler "$cc" "$@"
143 }
144
145 do_cxx() {
146 do_compiler "$cxx" "$@"
147 }
148
149 # Append $2 to the variable named $1, with space separation
150 add_to() {
151 eval $1=\${$1:+\"\$$1 \"}\$2
152 }
153
154 update_cxxflags() {
155 # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
156 # options which some versions of GCC's C++ compiler complain about
157 # because they only make sense for C programs.
158 QEMU_CXXFLAGS="$QEMU_CXXFLAGS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS"
159 CXXFLAGS=$(echo "$CFLAGS" | sed s/-std=gnu99/-std=gnu++11/)
160 for arg in $QEMU_CFLAGS; do
161 case $arg in
162 -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
163 -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
164 ;;
165 *)
166 QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
167 ;;
168 esac
169 done
170 }
171
172 compile_object() {
173 local_cflags="$1"
174 do_cc $CFLAGS $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
175 }
176
177 compile_prog() {
178 local_cflags="$1"
179 local_ldflags="$2"
180 do_cc $CFLAGS $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $QEMU_LDFLAGS $local_ldflags
181 }
182
183 # symbolically link $1 to $2. Portable version of "ln -sf".
184 symlink() {
185 rm -rf "$2"
186 mkdir -p "$(dirname "$2")"
187 ln -s "$1" "$2"
188 }
189
190 # check whether a command is available to this shell (may be either an
191 # executable or a builtin)
192 has() {
193 type "$1" >/dev/null 2>&1
194 }
195
196 # search for an executable in PATH
197 path_of() {
198 local_command="$1"
199 local_ifs="$IFS"
200 local_dir=""
201
202 # pathname has a dir component?
203 if [ "${local_command#*/}" != "$local_command" ]; then
204 if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
205 echo "$local_command"
206 return 0
207 fi
208 fi
209 if [ -z "$local_command" ]; then
210 return 1
211 fi
212
213 IFS=:
214 for local_dir in $PATH; do
215 if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
216 echo "$local_dir/$local_command"
217 IFS="${local_ifs:-$(printf ' \t\n')}"
218 return 0
219 fi
220 done
221 # not found
222 IFS="${local_ifs:-$(printf ' \t\n')}"
223 return 1
224 }
225
226 have_backend () {
227 echo "$trace_backends" | grep "$1" >/dev/null
228 }
229
230 glob() {
231 eval test -z '"${1#'"$2"'}"'
232 }
233
234 supported_hax_target() {
235 test "$hax" = "yes" || return 1
236 glob "$1" "*-softmmu" || return 1
237 case "${1%-softmmu}" in
238 i386|x86_64)
239 return 0
240 ;;
241 esac
242 return 1
243 }
244
245 supported_kvm_target() {
246 test "$kvm" = "yes" || return 1
247 glob "$1" "*-softmmu" || return 1
248 case "${1%-softmmu}:$cpu" in
249 arm:arm | aarch64:aarch64 | \
250 i386:i386 | i386:x86_64 | i386:x32 | \
251 x86_64:i386 | x86_64:x86_64 | x86_64:x32 | \
252 mips:mips | mipsel:mips | mips64:mips | mips64el:mips | \
253 ppc:ppc | ppc64:ppc | ppc:ppc64 | ppc64:ppc64 | ppc64:ppc64le | \
254 s390x:s390x)
255 return 0
256 ;;
257 esac
258 return 1
259 }
260
261 supported_xen_target() {
262 test "$xen" = "yes" || return 1
263 glob "$1" "*-softmmu" || return 1
264 # Only i386 and x86_64 provide the xenpv machine.
265 case "${1%-softmmu}" in
266 i386|x86_64)
267 return 0
268 ;;
269 esac
270 return 1
271 }
272
273 supported_hvf_target() {
274 test "$hvf" = "yes" || return 1
275 glob "$1" "*-softmmu" || return 1
276 case "${1%-softmmu}" in
277 x86_64)
278 return 0
279 ;;
280 esac
281 return 1
282 }
283
284 supported_whpx_target() {
285 test "$whpx" = "yes" || return 1
286 glob "$1" "*-softmmu" || return 1
287 case "${1%-softmmu}" in
288 i386|x86_64)
289 return 0
290 ;;
291 esac
292 return 1
293 }
294
295 supported_target() {
296 case "$1" in
297 *-softmmu)
298 ;;
299 *-linux-user)
300 if test "$linux" != "yes"; then
301 print_error "Target '$target' is only available on a Linux host"
302 return 1
303 fi
304 ;;
305 *-bsd-user)
306 if test "$bsd" != "yes"; then
307 print_error "Target '$target' is only available on a BSD host"
308 return 1
309 fi
310 ;;
311 *)
312 print_error "Invalid target name '$target'"
313 return 1
314 ;;
315 esac
316 test "$tcg" = "yes" && return 0
317 supported_kvm_target "$1" && return 0
318 supported_xen_target "$1" && return 0
319 supported_hax_target "$1" && return 0
320 supported_hvf_target "$1" && return 0
321 supported_whpx_target "$1" && return 0
322 print_error "TCG disabled, but hardware accelerator not available for '$target'"
323 return 1
324 }
325
326
327 ld_has() {
328 $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
329 }
330
331 if printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]";
332 then
333 error_exit "main directory cannot contain spaces nor colons"
334 fi
335
336 # default parameters
337 cpu=""
338 iasl="iasl"
339 interp_prefix="/usr/gnemul/qemu-%M"
340 static="no"
341 cross_prefix=""
342 audio_drv_list=""
343 block_drv_rw_whitelist=""
344 block_drv_ro_whitelist=""
345 host_cc="cc"
346 libs_cpu=""
347 libs_softmmu=""
348 libs_tools=""
349 audio_win_int=""
350 libs_qga=""
351 debug_info="yes"
352 stack_protector=""
353 safe_stack=""
354 use_containers="yes"
355 gdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
356
357 if test -e "$source_path/.git"
358 then
359 git_update=yes
360 git_submodules="ui/keycodemapdb"
361 git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
362 git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
363 else
364 git_update=no
365 git_submodules=""
366
367 if ! test -f "$source_path/ui/keycodemapdb/README"
368 then
369 echo
370 echo "ERROR: missing file $source_path/ui/keycodemapdb/README"
371 echo
372 echo "This is not a GIT checkout but module content appears to"
373 echo "be missing. Do not use 'git archive' or GitHub download links"
374 echo "to acquire QEMU source archives. Non-GIT builds are only"
375 echo "supported with source archives linked from:"
376 echo
377 echo " https://www.qemu.org/download/#source"
378 echo
379 echo "Developers working with GIT can use scripts/archive-source.sh"
380 echo "if they need to create valid source archives."
381 echo
382 exit 1
383 fi
384 fi
385 git="git"
386
387 # Don't accept a target_list environment variable.
388 unset target_list
389 unset target_list_exclude
390
391 # Default value for a variable defining feature "foo".
392 # * foo="no" feature will only be used if --enable-foo arg is given
393 # * foo="" feature will be searched for, and if found, will be used
394 # unless --disable-foo is given
395 # * foo="yes" this value will only be set by --enable-foo flag.
396 # feature will searched for,
397 # if not found, configure exits with error
398 #
399 # Always add --enable-foo and --disable-foo command line args.
400 # Distributions want to ensure that several features are compiled in, and it
401 # is impossible without a --enable-foo that exits if a feature is not found.
402
403 brlapi=""
404 curl=""
405 curses=""
406 docs=""
407 fdt=""
408 netmap="no"
409 sdl=""
410 sdl_image=""
411 virtfs=""
412 mpath=""
413 vnc="yes"
414 sparse="no"
415 vde=""
416 vnc_sasl=""
417 vnc_jpeg=""
418 vnc_png=""
419 xkbcommon=""
420 xen=""
421 xen_ctrl_version=""
422 xen_pci_passthrough=""
423 linux_aio=""
424 linux_io_uring=""
425 cap_ng=""
426 attr=""
427 libattr=""
428 xfs=""
429 tcg="yes"
430 membarrier=""
431 vhost_net=""
432 vhost_crypto=""
433 vhost_scsi=""
434 vhost_vsock=""
435 vhost_user=""
436 vhost_user_fs=""
437 kvm="no"
438 hax="no"
439 hvf="no"
440 whpx="no"
441 rdma=""
442 pvrdma=""
443 gprof="no"
444 debug_tcg="no"
445 debug="no"
446 sanitizers="no"
447 tsan="no"
448 fortify_source=""
449 strip_opt="yes"
450 tcg_interpreter="no"
451 bigendian="no"
452 mingw32="no"
453 gcov="no"
454 gcov_tool="gcov"
455 EXESUF=""
456 DSOSUF=".so"
457 LDFLAGS_SHARED="-shared"
458 modules="no"
459 module_upgrades="no"
460 prefix="/usr/local"
461 firmwarepath="\${prefix}/share/qemu-firmware"
462 confsuffix="/qemu"
463 slirp=""
464 oss_lib=""
465 bsd="no"
466 linux="no"
467 solaris="no"
468 profiler="no"
469 cocoa="no"
470 softmmu="yes"
471 linux_user="no"
472 bsd_user="no"
473 blobs="yes"
474 edk2_blobs="no"
475 pkgversion=""
476 pie=""
477 qom_cast_debug="yes"
478 trace_backends="log"
479 trace_file="trace"
480 spice=""
481 rbd=""
482 smartcard=""
483 libusb=""
484 usb_redir=""
485 opengl=""
486 opengl_dmabuf="no"
487 cpuid_h="no"
488 avx2_opt=""
489 zlib="yes"
490 capstone=""
491 lzo=""
492 snappy=""
493 bzip2=""
494 lzfse=""
495 zstd=""
496 guest_agent=""
497 guest_agent_with_vss="no"
498 guest_agent_ntddscsi="no"
499 guest_agent_msi=""
500 vss_win32_sdk=""
501 win_sdk="no"
502 want_tools=""
503 libiscsi=""
504 libnfs=""
505 coroutine=""
506 coroutine_pool=""
507 debug_stack_usage="no"
508 crypto_afalg="no"
509 seccomp=""
510 glusterfs=""
511 glusterfs_xlator_opt="no"
512 glusterfs_discard="no"
513 glusterfs_fallocate="no"
514 glusterfs_zerofill="no"
515 glusterfs_ftruncate_has_stat="no"
516 glusterfs_iocb_has_stat="no"
517 gtk=""
518 gtk_gl="no"
519 tls_priority="NORMAL"
520 gnutls=""
521 nettle=""
522 nettle_xts="no"
523 gcrypt=""
524 gcrypt_hmac="no"
525 gcrypt_xts="no"
526 qemu_private_xts="yes"
527 auth_pam=""
528 vte=""
529 virglrenderer=""
530 tpm=""
531 libssh=""
532 live_block_migration="yes"
533 numa=""
534 tcmalloc="no"
535 jemalloc="no"
536 replication="yes"
537 bochs="yes"
538 cloop="yes"
539 dmg="yes"
540 qcow1="yes"
541 vdi="yes"
542 vvfat="yes"
543 qed="yes"
544 parallels="yes"
545 sheepdog="yes"
546 libxml2=""
547 debug_mutex="no"
548 libpmem=""
549 default_devices="yes"
550 plugins="no"
551 fuzzing="no"
552 rng_none="no"
553 secret_keyring=""
554 libdaxctl=""
555 meson=""
556 skip_meson=no
557
558 supported_cpu="no"
559 supported_os="no"
560 bogus_os="no"
561 malloc_trim=""
562
563 # parse CC options first
564 for opt do
565 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
566 case "$opt" in
567 --cross-prefix=*) cross_prefix="$optarg"
568 ;;
569 --cc=*) CC="$optarg"
570 ;;
571 --cxx=*) CXX="$optarg"
572 ;;
573 --cpu=*) cpu="$optarg"
574 ;;
575 --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
576 QEMU_LDFLAGS="$QEMU_LDFLAGS $optarg"
577 ;;
578 --extra-cxxflags=*) QEMU_CXXFLAGS="$QEMU_CXXFLAGS $optarg"
579 ;;
580 --extra-ldflags=*) QEMU_LDFLAGS="$QEMU_LDFLAGS $optarg"
581 EXTRA_LDFLAGS="$optarg"
582 ;;
583 --enable-debug-info) debug_info="yes"
584 ;;
585 --disable-debug-info) debug_info="no"
586 ;;
587 --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
588 ;;
589 --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-flags-}; cc_arch=${cc_arch%%=*}
590 eval "cross_cc_cflags_${cc_arch}=\$optarg"
591 cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}"
592 ;;
593 --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
594 cc_archs="$cc_archs $cc_arch"
595 eval "cross_cc_${cc_arch}=\$optarg"
596 cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}"
597 ;;
598 esac
599 done
600 # OS specific
601 # Using uname is really, really broken. Once we have the right set of checks
602 # we can eliminate its usage altogether.
603
604 # Preferred compiler:
605 # ${CC} (if set)
606 # ${cross_prefix}gcc (if cross-prefix specified)
607 # system compiler
608 if test -z "${CC}${cross_prefix}"; then
609 cc="$host_cc"
610 else
611 cc="${CC-${cross_prefix}gcc}"
612 fi
613
614 if test -z "${CXX}${cross_prefix}"; then
615 cxx="c++"
616 else
617 cxx="${CXX-${cross_prefix}g++}"
618 fi
619
620 ar="${AR-${cross_prefix}ar}"
621 as="${AS-${cross_prefix}as}"
622 ccas="${CCAS-$cc}"
623 cpp="${CPP-$cc -E}"
624 objcopy="${OBJCOPY-${cross_prefix}objcopy}"
625 ld="${LD-${cross_prefix}ld}"
626 ranlib="${RANLIB-${cross_prefix}ranlib}"
627 nm="${NM-${cross_prefix}nm}"
628 strip="${STRIP-${cross_prefix}strip}"
629 windres="${WINDRES-${cross_prefix}windres}"
630 pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
631 query_pkg_config() {
632 "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
633 }
634 pkg_config=query_pkg_config
635 sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
636
637 # If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
638 ARFLAGS="${ARFLAGS-rv}"
639
640 # default flags for all hosts
641 # We use -fwrapv to tell the compiler that we require a C dialect where
642 # left shift of signed integers is well defined and has the expected
643 # 2s-complement style results. (Both clang and gcc agree that it
644 # provides these semantics.)
645 QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
646 QEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
647 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
648 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
649 QEMU_INCLUDES="-iquote . -iquote ${source_path} -iquote ${source_path}/accel/tcg -iquote ${source_path}/include"
650 QEMU_INCLUDES="$QEMU_INCLUDES -iquote ${source_path}/disas/libvixl"
651 CFLAGS="-std=gnu99 -Wall"
652
653
654 # running configure in the source tree?
655 # we know that's the case if configure is there.
656 if test -f "./configure"; then
657 pwd_is_source_path="y"
658 else
659 pwd_is_source_path="n"
660 fi
661
662 check_define() {
663 cat > $TMPC <<EOF
664 #if !defined($1)
665 #error $1 not defined
666 #endif
667 int main(void) { return 0; }
668 EOF
669 compile_object
670 }
671
672 check_include() {
673 cat > $TMPC <<EOF
674 #include <$1>
675 int main(void) { return 0; }
676 EOF
677 compile_object
678 }
679
680 write_c_skeleton() {
681 cat > $TMPC <<EOF
682 int main(void) { return 0; }
683 EOF
684 }
685
686 write_c_fuzzer_skeleton() {
687 cat > $TMPC <<EOF
688 #include <stdint.h>
689 #include <sys/types.h>
690 int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
691 int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { return 0; }
692 EOF
693 }
694
695 if check_define __linux__ ; then
696 targetos="Linux"
697 elif check_define _WIN32 ; then
698 targetos='MINGW32'
699 elif check_define __OpenBSD__ ; then
700 targetos='OpenBSD'
701 elif check_define __sun__ ; then
702 targetos='SunOS'
703 elif check_define __HAIKU__ ; then
704 targetos='Haiku'
705 elif check_define __FreeBSD__ ; then
706 targetos='FreeBSD'
707 elif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
708 targetos='GNU/kFreeBSD'
709 elif check_define __DragonFly__ ; then
710 targetos='DragonFly'
711 elif check_define __NetBSD__; then
712 targetos='NetBSD'
713 elif check_define __APPLE__; then
714 targetos='Darwin'
715 else
716 # This is a fatal error, but don't report it yet, because we
717 # might be going to just print the --help text, or it might
718 # be the result of a missing compiler.
719 targetos='bogus'
720 bogus_os='yes'
721 fi
722
723 # Some host OSes need non-standard checks for which CPU to use.
724 # Note that these checks are broken for cross-compilation: if you're
725 # cross-compiling to one of these OSes then you'll need to specify
726 # the correct CPU with the --cpu option.
727 case $targetos in
728 Darwin)
729 # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
730 # run 64-bit userspace code.
731 # If the user didn't specify a CPU explicitly and the kernel says this is
732 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
733 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
734 cpu="x86_64"
735 fi
736 ;;
737 SunOS)
738 # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
739 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
740 cpu="x86_64"
741 fi
742 esac
743
744 if test ! -z "$cpu" ; then
745 # command line argument
746 :
747 elif check_define __i386__ ; then
748 cpu="i386"
749 elif check_define __x86_64__ ; then
750 if check_define __ILP32__ ; then
751 cpu="x32"
752 else
753 cpu="x86_64"
754 fi
755 elif check_define __sparc__ ; then
756 if check_define __arch64__ ; then
757 cpu="sparc64"
758 else
759 cpu="sparc"
760 fi
761 elif check_define _ARCH_PPC ; then
762 if check_define _ARCH_PPC64 ; then
763 if check_define _LITTLE_ENDIAN ; then
764 cpu="ppc64le"
765 else
766 cpu="ppc64"
767 fi
768 else
769 cpu="ppc"
770 fi
771 elif check_define __mips__ ; then
772 cpu="mips"
773 elif check_define __s390__ ; then
774 if check_define __s390x__ ; then
775 cpu="s390x"
776 else
777 cpu="s390"
778 fi
779 elif check_define __riscv ; then
780 if check_define _LP64 ; then
781 cpu="riscv64"
782 else
783 cpu="riscv32"
784 fi
785 elif check_define __arm__ ; then
786 cpu="arm"
787 elif check_define __aarch64__ ; then
788 cpu="aarch64"
789 else
790 cpu=$(uname -m)
791 fi
792
793 ARCH=
794 # Normalise host CPU name and set ARCH.
795 # Note that this case should only have supported host CPUs, not guests.
796 case "$cpu" in
797 ppc|ppc64|s390x|sparc64|x32|riscv32|riscv64)
798 supported_cpu="yes"
799 ;;
800 ppc64le)
801 ARCH="ppc64"
802 supported_cpu="yes"
803 ;;
804 i386|i486|i586|i686|i86pc|BePC)
805 cpu="i386"
806 supported_cpu="yes"
807 ;;
808 x86_64|amd64)
809 cpu="x86_64"
810 supported_cpu="yes"
811 ;;
812 armv*b|armv*l|arm)
813 cpu="arm"
814 supported_cpu="yes"
815 ;;
816 aarch64)
817 cpu="aarch64"
818 supported_cpu="yes"
819 ;;
820 mips*)
821 cpu="mips"
822 supported_cpu="yes"
823 ;;
824 sparc|sun4[cdmuv])
825 cpu="sparc"
826 supported_cpu="yes"
827 ;;
828 *)
829 # This will result in either an error or falling back to TCI later
830 ARCH=unknown
831 ;;
832 esac
833 if test -z "$ARCH"; then
834 ARCH="$cpu"
835 fi
836
837 # OS specific
838
839 # host *BSD for user mode
840 HOST_VARIANT_DIR=""
841
842 case $targetos in
843 MINGW32*)
844 mingw32="yes"
845 hax="yes"
846 vhost_user="no"
847 audio_possible_drivers="dsound sdl"
848 if check_include dsound.h; then
849 audio_drv_list="dsound"
850 else
851 audio_drv_list=""
852 fi
853 supported_os="yes"
854 pie="no"
855 ;;
856 GNU/kFreeBSD)
857 bsd="yes"
858 audio_drv_list="oss try-sdl"
859 audio_possible_drivers="oss sdl pa"
860 ;;
861 FreeBSD)
862 bsd="yes"
863 make="${MAKE-gmake}"
864 audio_drv_list="oss try-sdl"
865 audio_possible_drivers="oss sdl pa"
866 # needed for kinfo_getvmmap(3) in libutil.h
867 LIBS="-lutil $LIBS"
868 # needed for kinfo_getproc
869 libs_qga="-lutil $libs_qga"
870 netmap="" # enable netmap autodetect
871 HOST_VARIANT_DIR="freebsd"
872 supported_os="yes"
873 ;;
874 DragonFly)
875 bsd="yes"
876 make="${MAKE-gmake}"
877 audio_drv_list="oss try-sdl"
878 audio_possible_drivers="oss sdl pa"
879 HOST_VARIANT_DIR="dragonfly"
880 ;;
881 NetBSD)
882 bsd="yes"
883 hax="yes"
884 make="${MAKE-gmake}"
885 audio_drv_list="oss try-sdl"
886 audio_possible_drivers="oss sdl"
887 oss_lib="-lossaudio"
888 HOST_VARIANT_DIR="netbsd"
889 supported_os="yes"
890 ;;
891 OpenBSD)
892 bsd="yes"
893 make="${MAKE-gmake}"
894 audio_drv_list="try-sdl"
895 audio_possible_drivers="sdl"
896 HOST_VARIANT_DIR="openbsd"
897 supported_os="yes"
898 ;;
899 Darwin)
900 bsd="yes"
901 darwin="yes"
902 hax="yes"
903 hvf="yes"
904 LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
905 if [ "$cpu" = "x86_64" ] ; then
906 QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
907 QEMU_LDFLAGS="-arch x86_64 $QEMU_LDFLAGS"
908 fi
909 cocoa="yes"
910 audio_drv_list="coreaudio try-sdl"
911 audio_possible_drivers="coreaudio sdl"
912 QEMU_LDFLAGS="-framework CoreFoundation -framework IOKit $QEMU_LDFLAGS"
913 libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
914 # Disable attempts to use ObjectiveC features in os/object.h since they
915 # won't work when we're compiling with gcc as a C compiler.
916 QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
917 HOST_VARIANT_DIR="darwin"
918 supported_os="yes"
919 ;;
920 SunOS)
921 solaris="yes"
922 make="${MAKE-gmake}"
923 install="${INSTALL-ginstall}"
924 smbd="${SMBD-/usr/sfw/sbin/smbd}"
925 if test -f /usr/include/sys/soundcard.h ; then
926 audio_drv_list="oss try-sdl"
927 fi
928 audio_possible_drivers="oss sdl"
929 # needed for CMSG_ macros in sys/socket.h
930 QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
931 # needed for TIOCWIN* defines in termios.h
932 QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
933 solarisnetlibs="-lsocket -lnsl -lresolv"
934 LIBS="$solarisnetlibs $LIBS"
935 libs_qga="$solarisnetlibs $libs_qga"
936 ;;
937 Haiku)
938 haiku="yes"
939 QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -DBSD_SOURCE $QEMU_CFLAGS"
940 LIBS="-lposix_error_mapper -lnetwork -lbsd $LIBS"
941 ;;
942 Linux)
943 audio_drv_list="try-pa oss"
944 audio_possible_drivers="oss alsa sdl pa"
945 linux="yes"
946 linux_user="yes"
947 kvm="yes"
948 QEMU_INCLUDES="-isystem ${source_path}/linux-headers -I$PWD/linux-headers $QEMU_INCLUDES"
949 supported_os="yes"
950 libudev="yes"
951 ;;
952 esac
953
954 if [ "$bsd" = "yes" ] ; then
955 if [ "$darwin" != "yes" ] ; then
956 bsd_user="yes"
957 fi
958 fi
959
960 : ${make=${MAKE-make}}
961 : ${install=${INSTALL-install}}
962 # We prefer python 3.x. A bare 'python' is traditionally
963 # python 2.x, but some distros have it as python 3.x, so
964 # we check that too
965 python=
966 for binary in "${PYTHON-python3}" python
967 do
968 if has "$binary"
969 then
970 python=$(command -v "$binary")
971 break
972 fi
973 done
974
975 sphinx_build=
976 for binary in sphinx-build-3 sphinx-build
977 do
978 if has "$binary"
979 then
980 sphinx_build=$(command -v "$binary")
981 break
982 fi
983 done
984
985 # Check for ancillary tools used in testing
986 genisoimage=
987 for binary in genisoimage mkisofs
988 do
989 if has $binary
990 then
991 genisoimage=$(command -v "$binary")
992 break
993 fi
994 done
995
996 : ${smbd=${SMBD-/usr/sbin/smbd}}
997
998 # Default objcc to clang if available, otherwise use CC
999 if has clang; then
1000 objcc=clang
1001 else
1002 objcc="$cc"
1003 fi
1004
1005 if test "$mingw32" = "yes" ; then
1006 EXESUF=".exe"
1007 DSOSUF=".dll"
1008 # MinGW needs -mthreads for TLS and macro _MT.
1009 CFLAGS="-mthreads $CFLAGS"
1010 LIBS="-lwinmm -lws2_32 $LIBS"
1011 write_c_skeleton;
1012 if compile_prog "" "-liberty" ; then
1013 LIBS="-liberty $LIBS"
1014 fi
1015 prefix="c:/Program Files/QEMU"
1016 confsuffix=""
1017 libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
1018 fi
1019
1020 werror=""
1021
1022 for opt do
1023 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
1024 case "$opt" in
1025 --help|-h) show_help=yes
1026 ;;
1027 --version|-V) exec cat $source_path/VERSION
1028 ;;
1029 --prefix=*) prefix="$optarg"
1030 ;;
1031 --interp-prefix=*) interp_prefix="$optarg"
1032 ;;
1033 --cross-prefix=*)
1034 ;;
1035 --cc=*)
1036 ;;
1037 --host-cc=*) host_cc="$optarg"
1038 ;;
1039 --cxx=*)
1040 ;;
1041 --iasl=*) iasl="$optarg"
1042 ;;
1043 --objcc=*) objcc="$optarg"
1044 ;;
1045 --make=*) make="$optarg"
1046 ;;
1047 --install=*) install="$optarg"
1048 ;;
1049 --python=*) python="$optarg"
1050 ;;
1051 --sphinx-build=*) sphinx_build="$optarg"
1052 ;;
1053 --skip-meson) skip_meson=yes
1054 ;;
1055 --meson=*) meson="$optarg"
1056 ;;
1057 --gcov=*) gcov_tool="$optarg"
1058 ;;
1059 --smbd=*) smbd="$optarg"
1060 ;;
1061 --extra-cflags=*)
1062 ;;
1063 --extra-cxxflags=*)
1064 ;;
1065 --extra-ldflags=*)
1066 ;;
1067 --enable-debug-info)
1068 ;;
1069 --disable-debug-info)
1070 ;;
1071 --cross-cc-*)
1072 ;;
1073 --enable-modules)
1074 modules="yes"
1075 ;;
1076 --disable-modules)
1077 modules="no"
1078 ;;
1079 --disable-module-upgrades) module_upgrades="no"
1080 ;;
1081 --enable-module-upgrades) module_upgrades="yes"
1082 ;;
1083 --cpu=*)
1084 ;;
1085 --target-list=*) target_list="$optarg"
1086 if test "$target_list_exclude"; then
1087 error_exit "Can't mix --target-list with --target-list-exclude"
1088 fi
1089 ;;
1090 --target-list-exclude=*) target_list_exclude="$optarg"
1091 if test "$target_list"; then
1092 error_exit "Can't mix --target-list-exclude with --target-list"
1093 fi
1094 ;;
1095 --enable-trace-backends=*) trace_backends="$optarg"
1096 ;;
1097 # XXX: backwards compatibility
1098 --enable-trace-backend=*) trace_backends="$optarg"
1099 ;;
1100 --with-trace-file=*) trace_file="$optarg"
1101 ;;
1102 --with-default-devices) default_devices="yes"
1103 ;;
1104 --without-default-devices) default_devices="no"
1105 ;;
1106 --enable-gprof) gprof="yes"
1107 ;;
1108 --enable-gcov) gcov="yes"
1109 ;;
1110 --static)
1111 static="yes"
1112 QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
1113 ;;
1114 --mandir=*) mandir="$optarg"
1115 ;;
1116 --bindir=*) bindir="$optarg"
1117 ;;
1118 --libdir=*) libdir="$optarg"
1119 ;;
1120 --libexecdir=*) libexecdir="$optarg"
1121 ;;
1122 --includedir=*) includedir="$optarg"
1123 ;;
1124 --datadir=*) datadir="$optarg"
1125 ;;
1126 --with-confsuffix=*) confsuffix="$optarg"
1127 ;;
1128 --docdir=*) qemu_docdir="$optarg"
1129 ;;
1130 --sysconfdir=*) sysconfdir="$optarg"
1131 ;;
1132 --localstatedir=*) local_statedir="$optarg"
1133 ;;
1134 --firmwarepath=*) firmwarepath="$optarg"
1135 ;;
1136 --host=*|--build=*|\
1137 --disable-dependency-tracking|\
1138 --sbindir=*|--sharedstatedir=*|\
1139 --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
1140 --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
1141 # These switches are silently ignored, for compatibility with
1142 # autoconf-generated configure scripts. This allows QEMU's
1143 # configure to be used by RPM and similar macros that set
1144 # lots of directory switches by default.
1145 ;;
1146 --disable-sdl) sdl="no"
1147 ;;
1148 --enable-sdl) sdl="yes"
1149 ;;
1150 --disable-sdl-image) sdl_image="no"
1151 ;;
1152 --enable-sdl-image) sdl_image="yes"
1153 ;;
1154 --disable-qom-cast-debug) qom_cast_debug="no"
1155 ;;
1156 --enable-qom-cast-debug) qom_cast_debug="yes"
1157 ;;
1158 --disable-virtfs) virtfs="no"
1159 ;;
1160 --enable-virtfs) virtfs="yes"
1161 ;;
1162 --disable-mpath) mpath="no"
1163 ;;
1164 --enable-mpath) mpath="yes"
1165 ;;
1166 --disable-vnc) vnc="no"
1167 ;;
1168 --enable-vnc) vnc="yes"
1169 ;;
1170 --oss-lib=*) oss_lib="$optarg"
1171 ;;
1172 --audio-drv-list=*) audio_drv_list="$optarg"
1173 ;;
1174 --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1175 ;;
1176 --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1177 ;;
1178 --enable-debug-tcg) debug_tcg="yes"
1179 ;;
1180 --disable-debug-tcg) debug_tcg="no"
1181 ;;
1182 --enable-debug)
1183 # Enable debugging options that aren't excessively noisy
1184 debug_tcg="yes"
1185 debug_mutex="yes"
1186 debug="yes"
1187 strip_opt="no"
1188 fortify_source="no"
1189 ;;
1190 --enable-sanitizers) sanitizers="yes"
1191 ;;
1192 --disable-sanitizers) sanitizers="no"
1193 ;;
1194 --enable-tsan) tsan="yes"
1195 ;;
1196 --disable-tsan) tsan="no"
1197 ;;
1198 --enable-sparse) sparse="yes"
1199 ;;
1200 --disable-sparse) sparse="no"
1201 ;;
1202 --disable-strip) strip_opt="no"
1203 ;;
1204 --disable-vnc-sasl) vnc_sasl="no"
1205 ;;
1206 --enable-vnc-sasl) vnc_sasl="yes"
1207 ;;
1208 --disable-vnc-jpeg) vnc_jpeg="no"
1209 ;;
1210 --enable-vnc-jpeg) vnc_jpeg="yes"
1211 ;;
1212 --disable-vnc-png) vnc_png="no"
1213 ;;
1214 --enable-vnc-png) vnc_png="yes"
1215 ;;
1216 --disable-slirp) slirp="no"
1217 ;;
1218 --enable-slirp=git) slirp="git"
1219 ;;
1220 --enable-slirp=system) slirp="system"
1221 ;;
1222 --disable-vde) vde="no"
1223 ;;
1224 --enable-vde) vde="yes"
1225 ;;
1226 --disable-netmap) netmap="no"
1227 ;;
1228 --enable-netmap) netmap="yes"
1229 ;;
1230 --disable-xen) xen="no"
1231 ;;
1232 --enable-xen) xen="yes"
1233 ;;
1234 --disable-xen-pci-passthrough) xen_pci_passthrough="no"
1235 ;;
1236 --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
1237 ;;
1238 --disable-brlapi) brlapi="no"
1239 ;;
1240 --enable-brlapi) brlapi="yes"
1241 ;;
1242 --disable-kvm) kvm="no"
1243 ;;
1244 --enable-kvm) kvm="yes"
1245 ;;
1246 --disable-hax) hax="no"
1247 ;;
1248 --enable-hax) hax="yes"
1249 ;;
1250 --disable-hvf) hvf="no"
1251 ;;
1252 --enable-hvf) hvf="yes"
1253 ;;
1254 --disable-whpx) whpx="no"
1255 ;;
1256 --enable-whpx) whpx="yes"
1257 ;;
1258 --disable-tcg-interpreter) tcg_interpreter="no"
1259 ;;
1260 --enable-tcg-interpreter) tcg_interpreter="yes"
1261 ;;
1262 --disable-cap-ng) cap_ng="no"
1263 ;;
1264 --enable-cap-ng) cap_ng="yes"
1265 ;;
1266 --disable-tcg) tcg="no"
1267 ;;
1268 --enable-tcg) tcg="yes"
1269 ;;
1270 --disable-malloc-trim) malloc_trim="no"
1271 ;;
1272 --enable-malloc-trim) malloc_trim="yes"
1273 ;;
1274 --disable-spice) spice="no"
1275 ;;
1276 --enable-spice) spice="yes"
1277 ;;
1278 --disable-libiscsi) libiscsi="no"
1279 ;;
1280 --enable-libiscsi) libiscsi="yes"
1281 ;;
1282 --disable-libnfs) libnfs="no"
1283 ;;
1284 --enable-libnfs) libnfs="yes"
1285 ;;
1286 --enable-profiler) profiler="yes"
1287 ;;
1288 --disable-cocoa) cocoa="no"
1289 ;;
1290 --enable-cocoa)
1291 cocoa="yes" ;
1292 audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
1293 ;;
1294 --disable-system) softmmu="no"
1295 ;;
1296 --enable-system) softmmu="yes"
1297 ;;
1298 --disable-user)
1299 linux_user="no" ;
1300 bsd_user="no" ;
1301 ;;
1302 --enable-user) ;;
1303 --disable-linux-user) linux_user="no"
1304 ;;
1305 --enable-linux-user) linux_user="yes"
1306 ;;
1307 --disable-bsd-user) bsd_user="no"
1308 ;;
1309 --enable-bsd-user) bsd_user="yes"
1310 ;;
1311 --enable-pie) pie="yes"
1312 ;;
1313 --disable-pie) pie="no"
1314 ;;
1315 --enable-werror) werror="yes"
1316 ;;
1317 --disable-werror) werror="no"
1318 ;;
1319 --enable-stack-protector) stack_protector="yes"
1320 ;;
1321 --disable-stack-protector) stack_protector="no"
1322 ;;
1323 --enable-safe-stack) safe_stack="yes"
1324 ;;
1325 --disable-safe-stack) safe_stack="no"
1326 ;;
1327 --disable-curses) curses="no"
1328 ;;
1329 --enable-curses) curses="yes"
1330 ;;
1331 --disable-iconv) iconv="no"
1332 ;;
1333 --enable-iconv) iconv="yes"
1334 ;;
1335 --disable-curl) curl="no"
1336 ;;
1337 --enable-curl) curl="yes"
1338 ;;
1339 --disable-fdt) fdt="no"
1340 ;;
1341 --enable-fdt) fdt="yes"
1342 ;;
1343 --disable-linux-aio) linux_aio="no"
1344 ;;
1345 --enable-linux-aio) linux_aio="yes"
1346 ;;
1347 --disable-linux-io-uring) linux_io_uring="no"
1348 ;;
1349 --enable-linux-io-uring) linux_io_uring="yes"
1350 ;;
1351 --disable-attr) attr="no"
1352 ;;
1353 --enable-attr) attr="yes"
1354 ;;
1355 --disable-membarrier) membarrier="no"
1356 ;;
1357 --enable-membarrier) membarrier="yes"
1358 ;;
1359 --disable-blobs) blobs="no"
1360 ;;
1361 --with-pkgversion=*) pkgversion="$optarg"
1362 ;;
1363 --with-coroutine=*) coroutine="$optarg"
1364 ;;
1365 --disable-coroutine-pool) coroutine_pool="no"
1366 ;;
1367 --enable-coroutine-pool) coroutine_pool="yes"
1368 ;;
1369 --enable-debug-stack-usage) debug_stack_usage="yes"
1370 ;;
1371 --enable-crypto-afalg) crypto_afalg="yes"
1372 ;;
1373 --disable-crypto-afalg) crypto_afalg="no"
1374 ;;
1375 --disable-docs) docs="no"
1376 ;;
1377 --enable-docs) docs="yes"
1378 ;;
1379 --disable-vhost-net) vhost_net="no"
1380 ;;
1381 --enable-vhost-net) vhost_net="yes"
1382 ;;
1383 --disable-vhost-crypto) vhost_crypto="no"
1384 ;;
1385 --enable-vhost-crypto) vhost_crypto="yes"
1386 ;;
1387 --disable-vhost-scsi) vhost_scsi="no"
1388 ;;
1389 --enable-vhost-scsi) vhost_scsi="yes"
1390 ;;
1391 --disable-vhost-vsock) vhost_vsock="no"
1392 ;;
1393 --enable-vhost-vsock) vhost_vsock="yes"
1394 ;;
1395 --disable-vhost-user-fs) vhost_user_fs="no"
1396 ;;
1397 --enable-vhost-user-fs) vhost_user_fs="yes"
1398 ;;
1399 --disable-opengl) opengl="no"
1400 ;;
1401 --enable-opengl) opengl="yes"
1402 ;;
1403 --disable-rbd) rbd="no"
1404 ;;
1405 --enable-rbd) rbd="yes"
1406 ;;
1407 --disable-xfsctl) xfs="no"
1408 ;;
1409 --enable-xfsctl) xfs="yes"
1410 ;;
1411 --disable-smartcard) smartcard="no"
1412 ;;
1413 --enable-smartcard) smartcard="yes"
1414 ;;
1415 --disable-libusb) libusb="no"
1416 ;;
1417 --enable-libusb) libusb="yes"
1418 ;;
1419 --disable-usb-redir) usb_redir="no"
1420 ;;
1421 --enable-usb-redir) usb_redir="yes"
1422 ;;
1423 --disable-zlib-test) zlib="no"
1424 ;;
1425 --disable-lzo) lzo="no"
1426 ;;
1427 --enable-lzo) lzo="yes"
1428 ;;
1429 --disable-snappy) snappy="no"
1430 ;;
1431 --enable-snappy) snappy="yes"
1432 ;;
1433 --disable-bzip2) bzip2="no"
1434 ;;
1435 --enable-bzip2) bzip2="yes"
1436 ;;
1437 --enable-lzfse) lzfse="yes"
1438 ;;
1439 --disable-lzfse) lzfse="no"
1440 ;;
1441 --disable-zstd) zstd="no"
1442 ;;
1443 --enable-zstd) zstd="yes"
1444 ;;
1445 --enable-guest-agent) guest_agent="yes"
1446 ;;
1447 --disable-guest-agent) guest_agent="no"
1448 ;;
1449 --enable-guest-agent-msi) guest_agent_msi="yes"
1450 ;;
1451 --disable-guest-agent-msi) guest_agent_msi="no"
1452 ;;
1453 --with-vss-sdk) vss_win32_sdk=""
1454 ;;
1455 --with-vss-sdk=*) vss_win32_sdk="$optarg"
1456 ;;
1457 --without-vss-sdk) vss_win32_sdk="no"
1458 ;;
1459 --with-win-sdk) win_sdk=""
1460 ;;
1461 --with-win-sdk=*) win_sdk="$optarg"
1462 ;;
1463 --without-win-sdk) win_sdk="no"
1464 ;;
1465 --enable-tools) want_tools="yes"
1466 ;;
1467 --disable-tools) want_tools="no"
1468 ;;
1469 --enable-seccomp) seccomp="yes"
1470 ;;
1471 --disable-seccomp) seccomp="no"
1472 ;;
1473 --disable-glusterfs) glusterfs="no"
1474 ;;
1475 --disable-avx2) avx2_opt="no"
1476 ;;
1477 --enable-avx2) avx2_opt="yes"
1478 ;;
1479 --disable-avx512f) avx512f_opt="no"
1480 ;;
1481 --enable-avx512f) avx512f_opt="yes"
1482 ;;
1483
1484 --enable-glusterfs) glusterfs="yes"
1485 ;;
1486 --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
1487 echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1488 ;;
1489 --enable-vhdx|--disable-vhdx)
1490 echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1491 ;;
1492 --enable-uuid|--disable-uuid)
1493 echo "$0: $opt is obsolete, UUID support is always built" >&2
1494 ;;
1495 --disable-gtk) gtk="no"
1496 ;;
1497 --enable-gtk) gtk="yes"
1498 ;;
1499 --tls-priority=*) tls_priority="$optarg"
1500 ;;
1501 --disable-gnutls) gnutls="no"
1502 ;;
1503 --enable-gnutls) gnutls="yes"
1504 ;;
1505 --disable-nettle) nettle="no"
1506 ;;
1507 --enable-nettle) nettle="yes"
1508 ;;
1509 --disable-gcrypt) gcrypt="no"
1510 ;;
1511 --enable-gcrypt) gcrypt="yes"
1512 ;;
1513 --disable-auth-pam) auth_pam="no"
1514 ;;
1515 --enable-auth-pam) auth_pam="yes"
1516 ;;
1517 --enable-rdma) rdma="yes"
1518 ;;
1519 --disable-rdma) rdma="no"
1520 ;;
1521 --enable-pvrdma) pvrdma="yes"
1522 ;;
1523 --disable-pvrdma) pvrdma="no"
1524 ;;
1525 --disable-vte) vte="no"
1526 ;;
1527 --enable-vte) vte="yes"
1528 ;;
1529 --disable-virglrenderer) virglrenderer="no"
1530 ;;
1531 --enable-virglrenderer) virglrenderer="yes"
1532 ;;
1533 --disable-tpm) tpm="no"
1534 ;;
1535 --enable-tpm) tpm="yes"
1536 ;;
1537 --disable-libssh) libssh="no"
1538 ;;
1539 --enable-libssh) libssh="yes"
1540 ;;
1541 --disable-live-block-migration) live_block_migration="no"
1542 ;;
1543 --enable-live-block-migration) live_block_migration="yes"
1544 ;;
1545 --disable-numa) numa="no"
1546 ;;
1547 --enable-numa) numa="yes"
1548 ;;
1549 --disable-libxml2) libxml2="no"
1550 ;;
1551 --enable-libxml2) libxml2="yes"
1552 ;;
1553 --disable-tcmalloc) tcmalloc="no"
1554 ;;
1555 --enable-tcmalloc) tcmalloc="yes"
1556 ;;
1557 --disable-jemalloc) jemalloc="no"
1558 ;;
1559 --enable-jemalloc) jemalloc="yes"
1560 ;;
1561 --disable-replication) replication="no"
1562 ;;
1563 --enable-replication) replication="yes"
1564 ;;
1565 --disable-bochs) bochs="no"
1566 ;;
1567 --enable-bochs) bochs="yes"
1568 ;;
1569 --disable-cloop) cloop="no"
1570 ;;
1571 --enable-cloop) cloop="yes"
1572 ;;
1573 --disable-dmg) dmg="no"
1574 ;;
1575 --enable-dmg) dmg="yes"
1576 ;;
1577 --disable-qcow1) qcow1="no"
1578 ;;
1579 --enable-qcow1) qcow1="yes"
1580 ;;
1581 --disable-vdi) vdi="no"
1582 ;;
1583 --enable-vdi) vdi="yes"
1584 ;;
1585 --disable-vvfat) vvfat="no"
1586 ;;
1587 --enable-vvfat) vvfat="yes"
1588 ;;
1589 --disable-qed) qed="no"
1590 ;;
1591 --enable-qed) qed="yes"
1592 ;;
1593 --disable-parallels) parallels="no"
1594 ;;
1595 --enable-parallels) parallels="yes"
1596 ;;
1597 --disable-sheepdog) sheepdog="no"
1598 ;;
1599 --enable-sheepdog) sheepdog="yes"
1600 ;;
1601 --disable-vhost-user) vhost_user="no"
1602 ;;
1603 --enable-vhost-user) vhost_user="yes"
1604 ;;
1605 --disable-vhost-vdpa) vhost_vdpa="no"
1606 ;;
1607 --enable-vhost-vdpa) vhost_vdpa="yes"
1608 ;;
1609 --disable-vhost-kernel) vhost_kernel="no"
1610 ;;
1611 --enable-vhost-kernel) vhost_kernel="yes"
1612 ;;
1613 --disable-capstone) capstone="no"
1614 ;;
1615 --enable-capstone) capstone="yes"
1616 ;;
1617 --enable-capstone=git) capstone="git"
1618 ;;
1619 --enable-capstone=system) capstone="system"
1620 ;;
1621 --with-git=*) git="$optarg"
1622 ;;
1623 --enable-git-update) git_update=yes
1624 ;;
1625 --disable-git-update) git_update=no
1626 ;;
1627 --enable-debug-mutex) debug_mutex=yes
1628 ;;
1629 --disable-debug-mutex) debug_mutex=no
1630 ;;
1631 --enable-libpmem) libpmem=yes
1632 ;;
1633 --disable-libpmem) libpmem=no
1634 ;;
1635 --enable-xkbcommon) xkbcommon=yes
1636 ;;
1637 --disable-xkbcommon) xkbcommon=no
1638 ;;
1639 --enable-plugins) plugins="yes"
1640 ;;
1641 --disable-plugins) plugins="no"
1642 ;;
1643 --enable-containers) use_containers="yes"
1644 ;;
1645 --disable-containers) use_containers="no"
1646 ;;
1647 --enable-fuzzing) fuzzing=yes
1648 ;;
1649 --disable-fuzzing) fuzzing=no
1650 ;;
1651 --gdb=*) gdb_bin="$optarg"
1652 ;;
1653 --enable-rng-none) rng_none=yes
1654 ;;
1655 --disable-rng-none) rng_none=no
1656 ;;
1657 --enable-keyring) secret_keyring="yes"
1658 ;;
1659 --disable-keyring) secret_keyring="no"
1660 ;;
1661 --enable-libdaxctl) libdaxctl=yes
1662 ;;
1663 --disable-libdaxctl) libdaxctl=no
1664 ;;
1665 *)
1666 echo "ERROR: unknown option $opt"
1667 echo "Try '$0 --help' for more information"
1668 exit 1
1669 ;;
1670 esac
1671 done
1672
1673 libdir="${libdir:-$prefix/lib}"
1674 libexecdir="${libexecdir:-$prefix/libexec}"
1675 includedir="${includedir:-$prefix/include}"
1676
1677 if test "$mingw32" = "yes" ; then
1678 mandir="$prefix"
1679 datadir="$prefix"
1680 qemu_docdir="$prefix"
1681 bindir="$prefix"
1682 sysconfdir="$prefix"
1683 local_statedir=
1684 else
1685 mandir="${mandir:-$prefix/share/man}"
1686 datadir="${datadir:-$prefix/share}"
1687 qemu_docdir="${qemu_docdir:-$prefix/share/doc/qemu}"
1688 bindir="${bindir:-$prefix/bin}"
1689 sysconfdir="${sysconfdir:-$prefix/etc}"
1690 local_statedir="${local_statedir:-$prefix/var}"
1691 fi
1692
1693 case "$cpu" in
1694 ppc)
1695 CPU_CFLAGS="-m32"
1696 QEMU_LDFLAGS="-m32 $QEMU_LDFLAGS"
1697 ;;
1698 ppc64)
1699 CPU_CFLAGS="-m64"
1700 QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
1701 ;;
1702 sparc)
1703 CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
1704 QEMU_LDFLAGS="-m32 -mv8plus $QEMU_LDFLAGS"
1705 ;;
1706 sparc64)
1707 CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1708 QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
1709 ;;
1710 s390)
1711 CPU_CFLAGS="-m31"
1712 QEMU_LDFLAGS="-m31 $QEMU_LDFLAGS"
1713 ;;
1714 s390x)
1715 CPU_CFLAGS="-m64"
1716 QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
1717 ;;
1718 i386)
1719 CPU_CFLAGS="-m32"
1720 QEMU_LDFLAGS="-m32 $QEMU_LDFLAGS"
1721 ;;
1722 x86_64)
1723 # ??? Only extremely old AMD cpus do not have cmpxchg16b.
1724 # If we truly care, we should simply detect this case at
1725 # runtime and generate the fallback to serial emulation.
1726 CPU_CFLAGS="-m64 -mcx16"
1727 QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
1728 ;;
1729 x32)
1730 CPU_CFLAGS="-mx32"
1731 QEMU_LDFLAGS="-mx32 $QEMU_LDFLAGS"
1732 ;;
1733 # No special flags required for other host CPUs
1734 esac
1735
1736 eval "cross_cc_${cpu}=\$host_cc"
1737 cross_cc_vars="$cross_cc_vars cross_cc_${cpu}"
1738 QEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
1739
1740 # For user-mode emulation the host arch has to be one we explicitly
1741 # support, even if we're using TCI.
1742 if [ "$ARCH" = "unknown" ]; then
1743 bsd_user="no"
1744 linux_user="no"
1745 fi
1746
1747 if [ "$bsd_user" = "no" -a "$linux_user" = "no" -a "$softmmu" = "no" ] ; then
1748 tcg="no"
1749 fi
1750
1751 default_target_list=""
1752
1753 mak_wilds=""
1754
1755 if [ "$softmmu" = "yes" ]; then
1756 mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
1757 fi
1758 if [ "$linux_user" = "yes" ]; then
1759 mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
1760 fi
1761 if [ "$bsd_user" = "yes" ]; then
1762 mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
1763 fi
1764
1765 if test -z "$target_list_exclude"; then
1766 for config in $mak_wilds; do
1767 default_target_list="${default_target_list} $(basename "$config" .mak)"
1768 done
1769 else
1770 exclude_list=$(echo "$target_list_exclude" | sed -e 's/,/ /g')
1771 for config in $mak_wilds; do
1772 target="$(basename "$config" .mak)"
1773 exclude="no"
1774 for excl in $exclude_list; do
1775 if test "$excl" = "$target"; then
1776 exclude="yes"
1777 break;
1778 fi
1779 done
1780 if test "$exclude" = "no"; then
1781 default_target_list="${default_target_list} $target"
1782 fi
1783 done
1784 fi
1785
1786 # Enumerate public trace backends for --help output
1787 trace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
1788
1789 if test x"$show_help" = x"yes" ; then
1790 cat << EOF
1791
1792 Usage: configure [options]
1793 Options: [defaults in brackets after descriptions]
1794
1795 Standard options:
1796 --help print this message
1797 --prefix=PREFIX install in PREFIX [$prefix]
1798 --interp-prefix=PREFIX where to find shared libraries, etc.
1799 use %M for cpu name [$interp_prefix]
1800 --target-list=LIST set target list (default: build everything)
1801 $(echo Available targets: $default_target_list | \
1802 fold -s -w 53 | sed -e 's/^/ /')
1803 --target-list-exclude=LIST exclude a set of targets from the default target-list
1804
1805 Advanced options (experts only):
1806 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
1807 --cc=CC use C compiler CC [$cc]
1808 --iasl=IASL use ACPI compiler IASL [$iasl]
1809 --host-cc=CC use C compiler CC [$host_cc] for code run at
1810 build time
1811 --cxx=CXX use C++ compiler CXX [$cxx]
1812 --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
1813 --extra-cflags=CFLAGS append extra C compiler flags QEMU_CFLAGS
1814 --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
1815 --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS
1816 --cross-cc-ARCH=CC use compiler when building ARCH guest test cases
1817 --cross-cc-flags-ARCH= use compiler flags when building ARCH guest tests
1818 --make=MAKE use specified make [$make]
1819 --install=INSTALL use specified install [$install]
1820 --python=PYTHON use specified python [$python]
1821 --sphinx-build=SPHINX use specified sphinx-build [$sphinx_build]
1822 --meson=MESON use specified meson [$meson]
1823 --smbd=SMBD use specified smbd [$smbd]
1824 --with-git=GIT use specified git [$git]
1825 --static enable static build [$static]
1826 --mandir=PATH install man pages in PATH
1827 --datadir=PATH install firmware in PATH$confsuffix
1828 --docdir=PATH install documentation in PATH$confsuffix
1829 --bindir=PATH install binaries in PATH
1830 --libdir=PATH install libraries in PATH
1831 --libexecdir=PATH install helper binaries in PATH
1832 --sysconfdir=PATH install config in PATH$confsuffix
1833 --localstatedir=PATH install local state in PATH (set at runtime on win32)
1834 --firmwarepath=PATH search PATH for firmware files
1835 --efi-aarch64=PATH PATH of efi file to use for aarch64 VMs.
1836 --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
1837 --with-pkgversion=VERS use specified string as sub-version of the package
1838 --enable-debug enable common debug build options
1839 --enable-sanitizers enable default sanitizers
1840 --enable-tsan enable thread sanitizer
1841 --disable-strip disable stripping binaries
1842 --disable-werror disable compilation abort on warning
1843 --disable-stack-protector disable compiler-provided stack protection
1844 --audio-drv-list=LIST set audio drivers list:
1845 Available drivers: $audio_possible_drivers
1846 --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L
1847 --block-drv-rw-whitelist=L
1848 set block driver read-write whitelist
1849 (affects only QEMU, not qemu-img)
1850 --block-drv-ro-whitelist=L
1851 set block driver read-only whitelist
1852 (affects only QEMU, not qemu-img)
1853 --enable-trace-backends=B Set trace backend
1854 Available backends: $trace_backend_list
1855 --with-trace-file=NAME Full PATH,NAME of file to store traces
1856 Default:trace-<pid>
1857 --disable-slirp disable SLIRP userspace network connectivity
1858 --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
1859 --enable-malloc-trim enable libc malloc_trim() for memory optimization
1860 --oss-lib path to OSS library
1861 --cpu=CPU Build for host CPU [$cpu]
1862 --with-coroutine=BACKEND coroutine backend. Supported options:
1863 ucontext, sigaltstack, windows
1864 --enable-gcov enable test coverage analysis with gcov
1865 --gcov=GCOV use specified gcov [$gcov_tool]
1866 --disable-blobs disable installing provided firmware blobs
1867 --with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent
1868 --with-win-sdk=SDK-path path to Windows Platform SDK (to build VSS .tlb)
1869 --tls-priority default TLS protocol/cipher priority string
1870 --enable-gprof QEMU profiling with gprof
1871 --enable-profiler profiler support
1872 --enable-debug-stack-usage
1873 track the maximum stack usage of stacks created by qemu_alloc_stack
1874 --enable-plugins
1875 enable plugins via shared library loading
1876 --disable-containers don't use containers for cross-building
1877 --gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin]
1878
1879 Optional features, enabled with --enable-FEATURE and
1880 disabled with --disable-FEATURE, default is enabled if available:
1881
1882 system all system emulation targets
1883 user supported user emulation targets
1884 linux-user all linux usermode emulation targets
1885 bsd-user all BSD usermode emulation targets
1886 docs build documentation
1887 guest-agent build the QEMU Guest Agent
1888 guest-agent-msi build guest agent Windows MSI installation package
1889 pie Position Independent Executables
1890 modules modules support (non-Windows)
1891 module-upgrades try to load modules from alternate paths for upgrades
1892 debug-tcg TCG debugging (default is disabled)
1893 debug-info debugging information
1894 sparse sparse checker
1895 safe-stack SafeStack Stack Smash Protection. Depends on
1896 clang/llvm >= 3.7 and requires coroutine backend ucontext.
1897
1898 gnutls GNUTLS cryptography support
1899 nettle nettle cryptography support
1900 gcrypt libgcrypt cryptography support
1901 auth-pam PAM access control
1902 sdl SDL UI
1903 sdl-image SDL Image support for icons
1904 gtk gtk UI
1905 vte vte support for the gtk UI
1906 curses curses UI
1907 iconv font glyph conversion support
1908 vnc VNC UI support
1909 vnc-sasl SASL encryption for VNC server
1910 vnc-jpeg JPEG lossy compression for VNC server
1911 vnc-png PNG compression for VNC server
1912 cocoa Cocoa UI (Mac OS X only)
1913 virtfs VirtFS
1914 mpath Multipath persistent reservation passthrough
1915 xen xen backend driver support
1916 xen-pci-passthrough PCI passthrough support for Xen
1917 brlapi BrlAPI (Braile)
1918 curl curl connectivity
1919 membarrier membarrier system call (for Linux 4.14+ or Windows)
1920 fdt fdt device tree
1921 kvm KVM acceleration support
1922 hax HAX acceleration support
1923 hvf Hypervisor.framework acceleration support
1924 whpx Windows Hypervisor Platform acceleration support
1925 rdma Enable RDMA-based migration
1926 pvrdma Enable PVRDMA support
1927 vde support for vde network
1928 netmap support for netmap network
1929 linux-aio Linux AIO support
1930 linux-io-uring Linux io_uring support
1931 cap-ng libcap-ng support
1932 attr attr and xattr support
1933 vhost-net vhost-net kernel acceleration support
1934 vhost-vsock virtio sockets device support
1935 vhost-scsi vhost-scsi kernel target support
1936 vhost-crypto vhost-user-crypto backend support
1937 vhost-kernel vhost kernel backend support
1938 vhost-user vhost-user backend support
1939 vhost-vdpa vhost-vdpa kernel backend support
1940 spice spice
1941 rbd rados block device (rbd)
1942 libiscsi iscsi support
1943 libnfs nfs support
1944 smartcard smartcard support (libcacard)
1945 libusb libusb (for usb passthrough)
1946 live-block-migration Block migration in the main migration stream
1947 usb-redir usb network redirection support
1948 lzo support of lzo compression library
1949 snappy support of snappy compression library
1950 bzip2 support of bzip2 compression library
1951 (for reading bzip2-compressed dmg images)
1952 lzfse support of lzfse compression library
1953 (for reading lzfse-compressed dmg images)
1954 zstd support for zstd compression library
1955 (for migration compression and qcow2 cluster compression)
1956 seccomp seccomp support
1957 coroutine-pool coroutine freelist (better performance)
1958 glusterfs GlusterFS backend
1959 tpm TPM support
1960 libssh ssh block device support
1961 numa libnuma support
1962 libxml2 for Parallels image format
1963 tcmalloc tcmalloc support
1964 jemalloc jemalloc support
1965 avx2 AVX2 optimization support
1966 avx512f AVX512F optimization support
1967 replication replication support
1968 opengl opengl support
1969 virglrenderer virgl rendering support
1970 xfsctl xfsctl support
1971 qom-cast-debug cast debugging support
1972 tools build qemu-io, qemu-nbd and qemu-img tools
1973 bochs bochs image format support
1974 cloop cloop image format support
1975 dmg dmg image format support
1976 qcow1 qcow v1 image format support
1977 vdi vdi image format support
1978 vvfat vvfat image format support
1979 qed qed image format support
1980 parallels parallels image format support
1981 sheepdog sheepdog block driver support
1982 crypto-afalg Linux AF_ALG crypto backend driver
1983 capstone capstone disassembler support
1984 debug-mutex mutex debugging support
1985 libpmem libpmem support
1986 xkbcommon xkbcommon support
1987 rng-none dummy RNG, avoid using /dev/(u)random and getrandom()
1988 libdaxctl libdaxctl support
1989
1990 NOTE: The object files are built at the place where configure is launched
1991 EOF
1992 exit 0
1993 fi
1994
1995 # Remove old dependency files to make sure that they get properly regenerated
1996 rm -f */config-devices.mak.d
1997
1998 # Remove syscall_nr.h to be sure they will be regenerated in the build
1999 # directory, not in the source directory
2000 for arch in alpha hppa m68k xtensa sh4 microblaze arm ppc s390x sparc sparc64 \
2001 i386 x86_64 mips mips64 ; do
2002 # remove the file if it has been generated in the source directory
2003 rm -f "${source_path}/linux-user/${arch}/syscall_nr.h"
2004 # remove the dependency files
2005 for target in ${arch}*-linux-user ; do
2006 test -d "${target}" && find "${target}" -type f -name "*.d" \
2007 -exec grep -q "${source_path}/linux-user/${arch}/syscall_nr.h" {} \; \
2008 -print | while read file ; do rm "${file}" "${file%.d}.o" ; done
2009 done
2010 done
2011
2012 if test -z "$python"
2013 then
2014 error_exit "Python not found. Use --python=/path/to/python"
2015 fi
2016
2017 # Note that if the Python conditional here evaluates True we will exit
2018 # with status 1 which is a shell 'false' value.
2019 if ! $python -c 'import sys; sys.exit(sys.version_info < (3,5))'; then
2020 error_exit "Cannot use '$python', Python >= 3.5 is required." \
2021 "Use --python=/path/to/python to specify a supported Python."
2022 fi
2023
2024 # Preserve python version since some functionality is dependent on it
2025 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)
2026
2027 # Suppress writing compiled files
2028 python="$python -B"
2029
2030 if ! has "$meson"
2031 then
2032 error_exit "Meson not found. Use --meson=/path/to/meson"
2033 fi
2034 meson=$(command -v $meson)
2035
2036 if ! $python -c 'import pkg_resources' > /dev/null 2>&1; then
2037 error_exit "Python setuptools not found"
2038 fi
2039
2040 # Check that the C compiler works. Doing this here before testing
2041 # the host CPU ensures that we had a valid CC to autodetect the
2042 # $cpu var (and we should bail right here if that's not the case).
2043 # It also allows the help message to be printed without a CC.
2044 write_c_skeleton;
2045 if compile_object ; then
2046 : C compiler works ok
2047 else
2048 error_exit "\"$cc\" either does not exist or does not work"
2049 fi
2050 if ! compile_prog ; then
2051 error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
2052 fi
2053
2054 # Now we have handled --enable-tcg-interpreter and know we're not just
2055 # printing the help message, bail out if the host CPU isn't supported.
2056 if test "$ARCH" = "unknown"; then
2057 if test "$tcg_interpreter" = "yes" ; then
2058 echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
2059 else
2060 error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
2061 fi
2062 fi
2063
2064 # Consult white-list to determine whether to enable werror
2065 # by default. Only enable by default for git builds
2066 if test -z "$werror" ; then
2067 if test -e "$source_path/.git" && \
2068 { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
2069 werror="yes"
2070 else
2071 werror="no"
2072 fi
2073 fi
2074
2075 if test "$bogus_os" = "yes"; then
2076 # Now that we know that we're not printing the help and that
2077 # the compiler works (so the results of the check_defines we used
2078 # to identify the OS are reliable), if we didn't recognize the
2079 # host OS we should stop now.
2080 error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
2081 fi
2082
2083 # Check whether the compiler matches our minimum requirements:
2084 cat > $TMPC << EOF
2085 #if defined(__clang_major__) && defined(__clang_minor__)
2086 # ifdef __apple_build_version__
2087 # if __clang_major__ < 5 || (__clang_major__ == 5 && __clang_minor__ < 1)
2088 # error You need at least XCode Clang v5.1 to compile QEMU
2089 # endif
2090 # else
2091 # if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 4)
2092 # error You need at least Clang v3.4 to compile QEMU
2093 # endif
2094 # endif
2095 #elif defined(__GNUC__) && defined(__GNUC_MINOR__)
2096 # if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8)
2097 # error You need at least GCC v4.8 to compile QEMU
2098 # endif
2099 #else
2100 # error You either need GCC or Clang to compiler QEMU
2101 #endif
2102 int main (void) { return 0; }
2103 EOF
2104 if ! compile_prog "" "" ; then
2105 error_exit "You need at least GCC v4.8 or Clang v3.4 (or XCode Clang v5.1)"
2106 fi
2107
2108 # Accumulate -Wfoo and -Wno-bar separately.
2109 # We will list all of the enable flags first, and the disable flags second.
2110 # Note that we do not add -Werror, because that would enable it for all
2111 # configure tests. If a configure test failed due to -Werror this would
2112 # just silently disable some features, so it's too error prone.
2113
2114 warn_flags=
2115 add_to warn_flags -Wold-style-declaration
2116 add_to warn_flags -Wold-style-definition
2117 add_to warn_flags -Wtype-limits
2118 add_to warn_flags -Wformat-security
2119 add_to warn_flags -Wformat-y2k
2120 add_to warn_flags -Winit-self
2121 add_to warn_flags -Wignored-qualifiers
2122 add_to warn_flags -Wempty-body
2123 add_to warn_flags -Wnested-externs
2124 add_to warn_flags -Wendif-labels
2125 add_to warn_flags -Wexpansion-to-defined
2126
2127 nowarn_flags=
2128 add_to nowarn_flags -Wno-initializer-overrides
2129 add_to nowarn_flags -Wno-missing-include-dirs
2130 add_to nowarn_flags -Wno-shift-negative-value
2131 add_to nowarn_flags -Wno-string-plus-int
2132 add_to nowarn_flags -Wno-typedef-redefinition
2133 add_to nowarn_flags -Wno-tautological-type-limit-compare
2134 add_to nowarn_flags -Wno-psabi
2135
2136 gcc_flags="$warn_flags $nowarn_flags"
2137
2138 cc_has_warning_flag() {
2139 write_c_skeleton;
2140
2141 # Use the positive sense of the flag when testing for -Wno-wombat
2142 # support (gcc will happily accept the -Wno- form of unknown
2143 # warning options).
2144 optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
2145 compile_prog "-Werror $optflag" ""
2146 }
2147
2148 for flag in $gcc_flags; do
2149 if cc_has_warning_flag $flag ; then
2150 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
2151 fi
2152 done
2153
2154 if test "$stack_protector" != "no"; then
2155 cat > $TMPC << EOF
2156 int main(int argc, char *argv[])
2157 {
2158 char arr[64], *p = arr, *c = argv[0];
2159 while (*c) {
2160 *p++ = *c++;
2161 }
2162 return 0;
2163 }
2164 EOF
2165 gcc_flags="-fstack-protector-strong -fstack-protector-all"
2166 sp_on=0
2167 for flag in $gcc_flags; do
2168 # We need to check both a compile and a link, since some compiler
2169 # setups fail only on a .c->.o compile and some only at link time
2170 if compile_object "-Werror $flag" &&
2171 compile_prog "-Werror $flag" ""; then
2172 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
2173 QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
2174 sp_on=1
2175 break
2176 fi
2177 done
2178 if test "$stack_protector" = yes; then
2179 if test $sp_on = 0; then
2180 error_exit "Stack protector not supported"
2181 fi
2182 fi
2183 fi
2184
2185 # Disable -Wmissing-braces on older compilers that warn even for
2186 # the "universal" C zero initializer {0}.
2187 cat > $TMPC << EOF
2188 struct {
2189 int a[2];
2190 } x = {0};
2191 EOF
2192 if compile_object "-Werror" "" ; then
2193 :
2194 else
2195 QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
2196 fi
2197
2198 # Our module code doesn't support Windows
2199 if test "$modules" = "yes" && test "$mingw32" = "yes" ; then
2200 error_exit "Modules are not available for Windows"
2201 fi
2202
2203 # module_upgrades is only reasonable if modules are enabled
2204 if test "$modules" = "no" && test "$module_upgrades" = "yes" ; then
2205 error_exit "Can't enable module-upgrades as Modules are not enabled"
2206 fi
2207
2208 # Static linking is not possible with modules or PIE
2209 if test "$static" = "yes" ; then
2210 if test "$modules" = "yes" ; then
2211 error_exit "static and modules are mutually incompatible"
2212 fi
2213 fi
2214
2215 # Unconditional check for compiler __thread support
2216 cat > $TMPC << EOF
2217 static __thread int tls_var;
2218 int main(void) { return tls_var; }
2219 EOF
2220
2221 if ! compile_prog "-Werror" "" ; then
2222 error_exit "Your compiler does not support the __thread specifier for " \
2223 "Thread-Local Storage (TLS). Please upgrade to a version that does."
2224 fi
2225
2226 cat > $TMPC << EOF
2227
2228 #ifdef __linux__
2229 # define THREAD __thread
2230 #else
2231 # define THREAD
2232 #endif
2233 static THREAD int tls_var;
2234 int main(void) { return tls_var; }
2235 EOF
2236
2237 # Check we support --no-pie first; we will need this for building ROMs.
2238 if compile_prog "-Werror -fno-pie" "-no-pie"; then
2239 CFLAGS_NOPIE="-fno-pie"
2240 LDFLAGS_NOPIE="-no-pie"
2241 fi
2242
2243 if test "$static" = "yes"; then
2244 if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then
2245 CFLAGS="-fPIE -DPIE $CFLAGS"
2246 QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS"
2247 pie="yes"
2248 elif test "$pie" = "yes"; then
2249 error_exit "-static-pie not available due to missing toolchain support"
2250 else
2251 QEMU_LDFLAGS="-static $QEMU_LDFLAGS"
2252 pie="no"
2253 fi
2254 elif test "$pie" = "no"; then
2255 CFLAGS="$CFLAGS_NOPIE $CFLAGS"
2256 LDFLAGS="$LDFLAGS_NOPIE $LDFLAGS"
2257 elif compile_prog "-Werror -fPIE -DPIE" "-pie"; then
2258 CFLAGS="-fPIE -DPIE $CFLAGS"
2259 LDFLAGS="-pie $LDFLAGS"
2260 pie="yes"
2261 elif test "$pie" = "yes"; then
2262 error_exit "PIE not available due to missing toolchain support"
2263 else
2264 echo "Disabling PIE due to missing toolchain support"
2265 pie="no"
2266 fi
2267
2268 # Detect support for PT_GNU_RELRO + DT_BIND_NOW.
2269 # The combination is known as "full relro", because .got.plt is read-only too.
2270 if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
2271 QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS"
2272 fi
2273
2274 ##########################################
2275 # __sync_fetch_and_and requires at least -march=i486. Many toolchains
2276 # use i686 as default anyway, but for those that don't, an explicit
2277 # specification is necessary
2278
2279 if test "$cpu" = "i386"; then
2280 cat > $TMPC << EOF
2281 static int sfaa(int *ptr)
2282 {
2283 return __sync_fetch_and_and(ptr, 0);
2284 }
2285
2286 int main(void)
2287 {
2288 int val = 42;
2289 val = __sync_val_compare_and_swap(&val, 0, 1);
2290 sfaa(&val);
2291 return val;
2292 }
2293 EOF
2294 if ! compile_prog "" "" ; then
2295 QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
2296 fi
2297 fi
2298
2299 #########################################
2300 # Solaris specific configure tool chain decisions
2301
2302 if test "$solaris" = "yes" ; then
2303 if has $install; then
2304 :
2305 else
2306 error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
2307 "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
2308 "to get ginstall which is used by default (which lives in /opt/csw/bin)"
2309 fi
2310 if test "$(path_of $install)" = "/usr/sbin/install" ; then
2311 error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
2312 "try ginstall from the GNU fileutils available from www.blastwave.org" \
2313 "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
2314 fi
2315 if has ar; then
2316 :
2317 else
2318 if test -f /usr/ccs/bin/ar ; then
2319 error_exit "No path includes ar" \
2320 "Add /usr/ccs/bin to your path and rerun configure"
2321 fi
2322 error_exit "No path includes ar"
2323 fi
2324 fi
2325
2326 if test -z "${target_list+xxx}" ; then
2327 for target in $default_target_list; do
2328 supported_target $target 2>/dev/null && \
2329 target_list="$target_list $target"
2330 done
2331 target_list="${target_list# }"
2332 else
2333 target_list=$(echo "$target_list" | sed -e 's/,/ /g')
2334 for target in $target_list; do
2335 # Check that we recognised the target name; this allows a more
2336 # friendly error message than if we let it fall through.
2337 case " $default_target_list " in
2338 *" $target "*)
2339 ;;
2340 *)
2341 error_exit "Unknown target name '$target'"
2342 ;;
2343 esac
2344 supported_target $target || exit 1
2345 done
2346 fi
2347
2348 # see if system emulation was really requested
2349 case " $target_list " in
2350 *"-softmmu "*) softmmu=yes
2351 ;;
2352 *) softmmu=no
2353 ;;
2354 esac
2355
2356 for target in $target_list; do
2357 case "$target" in
2358 arm-softmmu | aarch64-softmmu | i386-softmmu | x86_64-softmmu)
2359 edk2_blobs="yes"
2360 ;;
2361 esac
2362 done
2363 # The EDK2 binaries are compressed with bzip2
2364 if test "$edk2_blobs" = "yes" && ! has bzip2; then
2365 error_exit "The bzip2 program is required for building QEMU"
2366 fi
2367
2368 feature_not_found() {
2369 feature=$1
2370 remedy=$2
2371
2372 error_exit "User requested feature $feature" \
2373 "configure was not able to find it." \
2374 "$remedy"
2375 }
2376
2377 # ---
2378 # big/little endian test
2379 cat > $TMPC << EOF
2380 short big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
2381 short little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
2382 extern int foo(short *, short *);
2383 int main(int argc, char *argv[]) {
2384 return foo(big_endian, little_endian);
2385 }
2386 EOF
2387
2388 if compile_object ; then
2389 if strings -a $TMPO | grep -q BiGeNdIaN ; then
2390 bigendian="yes"
2391 elif strings -a $TMPO | grep -q LiTtLeEnDiAn ; then
2392 bigendian="no"
2393 else
2394 echo big/little test failed
2395 fi
2396 else
2397 echo big/little test failed
2398 fi
2399
2400 ##########################################
2401 # system tools
2402 if test -z "$want_tools"; then
2403 if test "$softmmu" = "no"; then
2404 want_tools=no
2405 else
2406 want_tools=yes
2407 fi
2408 fi
2409
2410 ##########################################
2411 # cocoa implies not SDL or GTK
2412 # (the cocoa UI code currently assumes it is always the active UI
2413 # and doesn't interact well with other UI frontend code)
2414 if test "$cocoa" = "yes"; then
2415 if test "$sdl" = "yes"; then
2416 error_exit "Cocoa and SDL UIs cannot both be enabled at once"
2417 fi
2418 if test "$gtk" = "yes"; then
2419 error_exit "Cocoa and GTK UIs cannot both be enabled at once"
2420 fi
2421 gtk=no
2422 sdl=no
2423 fi
2424
2425 # Some versions of Mac OS X incorrectly define SIZE_MAX
2426 cat > $TMPC << EOF
2427 #include <stdint.h>
2428 #include <stdio.h>
2429 int main(int argc, char *argv[]) {
2430 return printf("%zu", SIZE_MAX);
2431 }
2432 EOF
2433 have_broken_size_max=no
2434 if ! compile_object -Werror ; then
2435 have_broken_size_max=yes
2436 fi
2437
2438 ##########################################
2439 # L2TPV3 probe
2440
2441 cat > $TMPC <<EOF
2442 #include <sys/socket.h>
2443 #include <linux/ip.h>
2444 int main(void) { return sizeof(struct mmsghdr); }
2445 EOF
2446 if compile_prog "" "" ; then
2447 l2tpv3=yes
2448 else
2449 l2tpv3=no
2450 fi
2451
2452 if check_include "pty.h" ; then
2453 pty_h=yes
2454 else
2455 pty_h=no
2456 fi
2457
2458 cat > $TMPC <<EOF
2459 #include <sys/mman.h>
2460 int main(int argc, char *argv[]) {
2461 return mlockall(MCL_FUTURE);
2462 }
2463 EOF
2464 if compile_prog "" "" ; then
2465 have_mlockall=yes
2466 else
2467 have_mlockall=no
2468 fi
2469
2470 #########################################
2471 # vhost interdependencies and host support
2472
2473 # vhost backends
2474 test "$vhost_user" = "" && vhost_user=yes
2475 if test "$vhost_user" = "yes" && test "$mingw32" = "yes"; then
2476 error_exit "vhost-user isn't available on win32"
2477 fi
2478 test "$vhost_vdpa" = "" && vhost_vdpa=$linux
2479 if test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then
2480 error_exit "vhost-vdpa is only available on Linux"
2481 fi
2482 test "$vhost_kernel" = "" && vhost_kernel=$linux
2483 if test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then
2484 error_exit "vhost-kernel is only available on Linux"
2485 fi
2486
2487 # vhost-kernel devices
2488 test "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel
2489 if test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then
2490 error_exit "--enable-vhost-scsi requires --enable-vhost-kernel"
2491 fi
2492 test "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel
2493 if test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then
2494 error_exit "--enable-vhost-vsock requires --enable-vhost-kernel"
2495 fi
2496
2497 # vhost-user backends
2498 test "$vhost_net_user" = "" && vhost_net_user=$vhost_user
2499 if test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then
2500 error_exit "--enable-vhost-net-user requires --enable-vhost-user"
2501 fi
2502 test "$vhost_crypto" = "" && vhost_crypto=$vhost_user
2503 if test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then
2504 error_exit "--enable-vhost-crypto requires --enable-vhost-user"
2505 fi
2506 test "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user
2507 if test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then
2508 error_exit "--enable-vhost-user-fs requires --enable-vhost-user"
2509 fi
2510 #vhost-vdpa backends
2511 test "$vhost_net_vdpa" = "" && vhost_net_vdpa=$vhost_vdpa
2512 if test "$vhost_net_vdpa" = "yes" && test "$vhost_vdpa" = "no"; then
2513 error_exit "--enable-vhost-net-vdpa requires --enable-vhost-vdpa"
2514 fi
2515
2516 # OR the vhost-kernel and vhost-user values for simplicity
2517 if test "$vhost_net" = ""; then
2518 test "$vhost_net_user" = "yes" && vhost_net=yes
2519 test "$vhost_kernel" = "yes" && vhost_net=yes
2520 fi
2521
2522 ##########################################
2523 # MinGW / Mingw-w64 localtime_r/gmtime_r check
2524
2525 if test "$mingw32" = "yes"; then
2526 # Some versions of MinGW / Mingw-w64 lack localtime_r
2527 # and gmtime_r entirely.
2528 #
2529 # Some versions of Mingw-w64 define a macro for
2530 # localtime_r/gmtime_r.
2531 #
2532 # Some versions of Mingw-w64 will define functions
2533 # for localtime_r/gmtime_r, but only if you have
2534 # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
2535 # though, unistd.h and pthread.h both define
2536 # that for you.
2537 #
2538 # So this #undef localtime_r and #include <unistd.h>
2539 # are not in fact redundant.
2540 cat > $TMPC << EOF
2541 #include <unistd.h>
2542 #include <time.h>
2543 #undef localtime_r
2544 int main(void) { localtime_r(NULL, NULL); return 0; }
2545 EOF
2546 if compile_prog "" "" ; then
2547 localtime_r="yes"
2548 else
2549 localtime_r="no"
2550 fi
2551 fi
2552
2553 ##########################################
2554 # pkg-config probe
2555
2556 if ! has "$pkg_config_exe"; then
2557 error_exit "pkg-config binary '$pkg_config_exe' not found"
2558 fi
2559
2560 ##########################################
2561 # NPTL probe
2562
2563 if test "$linux_user" = "yes"; then
2564 cat > $TMPC <<EOF
2565 #include <sched.h>
2566 #include <linux/futex.h>
2567 int main(void) {
2568 #if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
2569 #error bork
2570 #endif
2571 return 0;
2572 }
2573 EOF
2574 if ! compile_object ; then
2575 feature_not_found "nptl" "Install glibc and linux kernel headers."
2576 fi
2577 fi
2578
2579 ##########################################
2580 # lzo check
2581
2582 if test "$lzo" != "no" ; then
2583 cat > $TMPC << EOF
2584 #include <lzo/lzo1x.h>
2585 int main(void) { lzo_version(); return 0; }
2586 EOF
2587 if compile_prog "" "-llzo2" ; then
2588 libs_softmmu="$libs_softmmu -llzo2"
2589 lzo="yes"
2590 else
2591 if test "$lzo" = "yes"; then
2592 feature_not_found "liblzo2" "Install liblzo2 devel"
2593 fi
2594 lzo="no"
2595 fi
2596 fi
2597
2598 ##########################################
2599 # snappy check
2600
2601 if test "$snappy" != "no" ; then
2602 cat > $TMPC << EOF
2603 #include <snappy-c.h>
2604 int main(void) { snappy_max_compressed_length(4096); return 0; }
2605 EOF
2606 if compile_prog "" "-lsnappy" ; then
2607 libs_softmmu="$libs_softmmu -lsnappy"
2608 snappy="yes"
2609 else
2610 if test "$snappy" = "yes"; then
2611 feature_not_found "libsnappy" "Install libsnappy devel"
2612 fi
2613 snappy="no"
2614 fi
2615 fi
2616
2617 ##########################################
2618 # bzip2 check
2619
2620 if test "$bzip2" != "no" ; then
2621 cat > $TMPC << EOF
2622 #include <bzlib.h>
2623 int main(void) { BZ2_bzlibVersion(); return 0; }
2624 EOF
2625 if compile_prog "" "-lbz2" ; then
2626 bzip2="yes"
2627 else
2628 if test "$bzip2" = "yes"; then
2629 feature_not_found "libbzip2" "Install libbzip2 devel"
2630 fi
2631 bzip2="no"
2632 fi
2633 fi
2634
2635 ##########################################
2636 # lzfse check
2637
2638 if test "$lzfse" != "no" ; then
2639 cat > $TMPC << EOF
2640 #include <lzfse.h>
2641 int main(void) { lzfse_decode_scratch_size(); return 0; }
2642 EOF
2643 if compile_prog "" "-llzfse" ; then
2644 lzfse="yes"
2645 else
2646 if test "$lzfse" = "yes"; then
2647 feature_not_found "lzfse" "Install lzfse devel"
2648 fi
2649 lzfse="no"
2650 fi
2651 fi
2652
2653 ##########################################
2654 # zstd check
2655
2656 if test "$zstd" != "no" ; then
2657 libzstd_minver="1.4.0"
2658 if $pkg_config --atleast-version=$libzstd_minver libzstd ; then
2659 zstd_cflags="$($pkg_config --cflags libzstd)"
2660 zstd_libs="$($pkg_config --libs libzstd)"
2661 LIBS="$zstd_libs $LIBS"
2662 QEMU_CFLAGS="$QEMU_CFLAGS $zstd_cflags"
2663 zstd="yes"
2664 else
2665 if test "$zstd" = "yes" ; then
2666 feature_not_found "libzstd" "Install libzstd devel"
2667 fi
2668 zstd="no"
2669 fi
2670 fi
2671
2672 ##########################################
2673 # libseccomp check
2674
2675 if test "$seccomp" != "no" ; then
2676 libseccomp_minver="2.3.0"
2677 if $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
2678 seccomp_cflags="$($pkg_config --cflags libseccomp)"
2679 seccomp_libs="$($pkg_config --libs libseccomp)"
2680 seccomp="yes"
2681 else
2682 if test "$seccomp" = "yes" ; then
2683 feature_not_found "libseccomp" \
2684 "Install libseccomp devel >= $libseccomp_minver"
2685 fi
2686 seccomp="no"
2687 fi
2688 fi
2689 ##########################################
2690 # xen probe
2691
2692 if test "$xen" != "no" ; then
2693 # Check whether Xen library path is specified via --extra-ldflags to avoid
2694 # overriding this setting with pkg-config output. If not, try pkg-config
2695 # to obtain all needed flags.
2696
2697 if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2698 $pkg_config --exists xencontrol ; then
2699 xen_ctrl_version="$(printf '%d%02d%02d' \
2700 $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
2701 xen=yes
2702 xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab"
2703 xen_pc="$xen_pc xenevtchn xendevicemodel"
2704 if $pkg_config --exists xentoolcore; then
2705 xen_pc="$xen_pc xentoolcore"
2706 fi
2707 QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags $xen_pc)"
2708 libs_softmmu="$($pkg_config --libs $xen_pc) $libs_softmmu"
2709 else
2710
2711 xen_libs="-lxenstore -lxenctrl -lxenguest"
2712 xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
2713
2714 # First we test whether Xen headers and libraries are available.
2715 # If no, we are done and there is no Xen support.
2716 # If yes, more tests are run to detect the Xen version.
2717
2718 # Xen (any)
2719 cat > $TMPC <<EOF
2720 #include <xenctrl.h>
2721 int main(void) {
2722 return 0;
2723 }
2724 EOF
2725 if ! compile_prog "" "$xen_libs" ; then
2726 # Xen not found
2727 if test "$xen" = "yes" ; then
2728 feature_not_found "xen" "Install xen devel"
2729 fi
2730 xen=no
2731
2732 # Xen unstable
2733 elif
2734 cat > $TMPC <<EOF &&
2735 #undef XC_WANT_COMPAT_DEVICEMODEL_API
2736 #define __XEN_TOOLS__
2737 #include <xendevicemodel.h>
2738 #include <xenforeignmemory.h>
2739 int main(void) {
2740 xendevicemodel_handle *xd;
2741 xenforeignmemory_handle *xfmem;
2742
2743 xd = xendevicemodel_open(0, 0);
2744 xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
2745
2746 xfmem = xenforeignmemory_open(0, 0);
2747 xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
2748
2749 return 0;
2750 }
2751 EOF
2752 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
2753 then
2754 xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
2755 xen_ctrl_version=41100
2756 xen=yes
2757 elif
2758 cat > $TMPC <<EOF &&
2759 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2760 #include <xenforeignmemory.h>
2761 #include <xentoolcore.h>
2762 int main(void) {
2763 xenforeignmemory_handle *xfmem;
2764
2765 xfmem = xenforeignmemory_open(0, 0);
2766 xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
2767 xentoolcore_restrict_all(0);
2768
2769 return 0;
2770 }
2771 EOF
2772 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
2773 then
2774 xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
2775 xen_ctrl_version=41000
2776 xen=yes
2777 elif
2778 cat > $TMPC <<EOF &&
2779 #undef XC_WANT_COMPAT_DEVICEMODEL_API
2780 #define __XEN_TOOLS__
2781 #include <xendevicemodel.h>
2782 int main(void) {
2783 xendevicemodel_handle *xd;
2784
2785 xd = xendevicemodel_open(0, 0);
2786 xendevicemodel_close(xd);
2787
2788 return 0;
2789 }
2790 EOF
2791 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2792 then
2793 xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2794 xen_ctrl_version=40900
2795 xen=yes
2796 elif
2797 cat > $TMPC <<EOF &&
2798 /*
2799 * If we have stable libs the we don't want the libxc compat
2800 * layers, regardless of what CFLAGS we may have been given.
2801 *
2802 * Also, check if xengnttab_grant_copy_segment_t is defined and
2803 * grant copy operation is implemented.
2804 */
2805 #undef XC_WANT_COMPAT_EVTCHN_API
2806 #undef XC_WANT_COMPAT_GNTTAB_API
2807 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2808 #include <xenctrl.h>
2809 #include <xenstore.h>
2810 #include <xenevtchn.h>
2811 #include <xengnttab.h>
2812 #include <xenforeignmemory.h>
2813 #include <stdint.h>
2814 #include <xen/hvm/hvm_info_table.h>
2815 #if !defined(HVM_MAX_VCPUS)
2816 # error HVM_MAX_VCPUS not defined
2817 #endif
2818 int main(void) {
2819 xc_interface *xc = NULL;
2820 xenforeignmemory_handle *xfmem;
2821 xenevtchn_handle *xe;
2822 xengnttab_handle *xg;
2823 xengnttab_grant_copy_segment_t* seg = NULL;
2824
2825 xs_daemon_open();
2826
2827 xc = xc_interface_open(0, 0, 0);
2828 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2829 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2830 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2831 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2832
2833 xfmem = xenforeignmemory_open(0, 0);
2834 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2835
2836 xe = xenevtchn_open(0, 0);
2837 xenevtchn_fd(xe);
2838
2839 xg = xengnttab_open(0, 0);
2840 xengnttab_grant_copy(xg, 0, seg);
2841
2842 return 0;
2843 }
2844 EOF
2845 compile_prog "" "$xen_libs $xen_stable_libs"
2846 then
2847 xen_ctrl_version=40800
2848 xen=yes
2849 elif
2850 cat > $TMPC <<EOF &&
2851 /*
2852 * If we have stable libs the we don't want the libxc compat
2853 * layers, regardless of what CFLAGS we may have been given.
2854 */
2855 #undef XC_WANT_COMPAT_EVTCHN_API
2856 #undef XC_WANT_COMPAT_GNTTAB_API
2857 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2858 #include <xenctrl.h>
2859 #include <xenstore.h>
2860 #include <xenevtchn.h>
2861 #include <xengnttab.h>
2862 #include <xenforeignmemory.h>
2863 #include <stdint.h>
2864 #include <xen/hvm/hvm_info_table.h>
2865 #if !defined(HVM_MAX_VCPUS)
2866 # error HVM_MAX_VCPUS not defined
2867 #endif
2868 int main(void) {
2869 xc_interface *xc = NULL;
2870 xenforeignmemory_handle *xfmem;
2871 xenevtchn_handle *xe;
2872 xengnttab_handle *xg;
2873
2874 xs_daemon_open();
2875
2876 xc = xc_interface_open(0, 0, 0);
2877 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2878 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2879 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2880 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2881
2882 xfmem = xenforeignmemory_open(0, 0);
2883 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2884
2885 xe = xenevtchn_open(0, 0);
2886 xenevtchn_fd(xe);
2887
2888 xg = xengnttab_open(0, 0);
2889 xengnttab_map_grant_ref(xg, 0, 0, 0);
2890
2891 return 0;
2892 }
2893 EOF
2894 compile_prog "" "$xen_libs $xen_stable_libs"
2895 then
2896 xen_ctrl_version=40701
2897 xen=yes
2898
2899 # Xen 4.6
2900 elif
2901 cat > $TMPC <<EOF &&
2902 #include <xenctrl.h>
2903 #include <xenstore.h>
2904 #include <stdint.h>
2905 #include <xen/hvm/hvm_info_table.h>
2906 #if !defined(HVM_MAX_VCPUS)
2907 # error HVM_MAX_VCPUS not defined
2908 #endif
2909 int main(void) {
2910 xc_interface *xc;
2911 xs_daemon_open();
2912 xc = xc_interface_open(0, 0, 0);
2913 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2914 xc_gnttab_open(NULL, 0);
2915 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2916 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2917 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2918 xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2919 return 0;
2920 }
2921 EOF
2922 compile_prog "" "$xen_libs"
2923 then
2924 xen_ctrl_version=40600
2925 xen=yes
2926
2927 # Xen 4.5
2928 elif
2929 cat > $TMPC <<EOF &&
2930 #include <xenctrl.h>
2931 #include <xenstore.h>
2932 #include <stdint.h>
2933 #include <xen/hvm/hvm_info_table.h>
2934 #if !defined(HVM_MAX_VCPUS)
2935 # error HVM_MAX_VCPUS not defined
2936 #endif
2937 int main(void) {
2938 xc_interface *xc;
2939 xs_daemon_open();
2940 xc = xc_interface_open(0, 0, 0);
2941 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2942 xc_gnttab_open(NULL, 0);
2943 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2944 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2945 xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
2946 return 0;
2947 }
2948 EOF
2949 compile_prog "" "$xen_libs"
2950 then
2951 xen_ctrl_version=40500
2952 xen=yes
2953
2954 elif
2955 cat > $TMPC <<EOF &&
2956 #include <xenctrl.h>
2957 #include <xenstore.h>
2958 #include <stdint.h>
2959 #include <xen/hvm/hvm_info_table.h>
2960 #if !defined(HVM_MAX_VCPUS)
2961 # error HVM_MAX_VCPUS not defined
2962 #endif
2963 int main(void) {
2964 xc_interface *xc;
2965 xs_daemon_open();
2966 xc = xc_interface_open(0, 0, 0);
2967 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2968 xc_gnttab_open(NULL, 0);
2969 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2970 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2971 return 0;
2972 }
2973 EOF
2974 compile_prog "" "$xen_libs"
2975 then
2976 xen_ctrl_version=40200
2977 xen=yes
2978
2979 else
2980 if test "$xen" = "yes" ; then
2981 feature_not_found "xen (unsupported version)" \
2982 "Install a supported xen (xen 4.2 or newer)"
2983 fi
2984 xen=no
2985 fi
2986
2987 if test "$xen" = yes; then
2988 if test $xen_ctrl_version -ge 40701 ; then
2989 libs_softmmu="$xen_stable_libs $libs_softmmu"
2990 fi
2991 libs_softmmu="$xen_libs $libs_softmmu"
2992 fi
2993 fi
2994 fi
2995
2996 if test "$xen_pci_passthrough" != "no"; then
2997 if test "$xen" = "yes" && test "$linux" = "yes"; then
2998 xen_pci_passthrough=yes
2999 else
3000 if test "$xen_pci_passthrough" = "yes"; then
3001 error_exit "User requested feature Xen PCI Passthrough" \
3002 " but this feature requires /sys from Linux"
3003 fi
3004 xen_pci_passthrough=no
3005 fi
3006 fi
3007
3008 ##########################################
3009 # Windows Hypervisor Platform accelerator (WHPX) check
3010 if test "$whpx" != "no" ; then
3011 if check_include "WinHvPlatform.h" && check_include "WinHvEmulation.h"; then
3012 whpx="yes"
3013 else
3014 if test "$whpx" = "yes"; then
3015 feature_not_found "WinHvPlatform" "WinHvEmulation is not installed"
3016 fi
3017 whpx="no"
3018 fi
3019 fi
3020
3021 ##########################################
3022 # Sparse probe
3023 if test "$sparse" != "no" ; then
3024 if has cgcc; then
3025 sparse=yes
3026 else
3027 if test "$sparse" = "yes" ; then
3028 feature_not_found "sparse" "Install sparse binary"
3029 fi
3030 sparse=no
3031 fi
3032 fi
3033
3034 ##########################################
3035 # X11 probe
3036 if $pkg_config --exists "x11"; then
3037 have_x11=yes
3038 x11_cflags=$($pkg_config --cflags x11)
3039 x11_libs=$($pkg_config --libs x11)
3040 fi
3041
3042 ##########################################
3043 # GTK probe
3044
3045 if test "$gtk" != "no"; then
3046 gtkpackage="gtk+-3.0"
3047 gtkx11package="gtk+-x11-3.0"
3048 gtkversion="3.22.0"
3049 if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
3050 gtk_cflags=$($pkg_config --cflags $gtkpackage)
3051 gtk_libs=$($pkg_config --libs $gtkpackage)
3052 gtk_version=$($pkg_config --modversion $gtkpackage)
3053 if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
3054 need_x11=yes
3055 gtk_cflags="$gtk_cflags $x11_cflags"
3056 gtk_libs="$gtk_libs $x11_libs"
3057 fi
3058 gtk="yes"
3059 elif test "$gtk" = "yes"; then
3060 feature_not_found "gtk" "Install gtk3-devel"
3061 else
3062 gtk="no"
3063 fi
3064 fi
3065
3066
3067 ##########################################
3068 # GNUTLS probe
3069
3070 if test "$gnutls" != "no"; then
3071 pass="no"
3072 if $pkg_config --exists "gnutls >= 3.1.18"; then
3073 gnutls_cflags=$($pkg_config --cflags gnutls)
3074 gnutls_libs=$($pkg_config --libs gnutls)
3075 # Packaging for the static libraries is not always correct.
3076 # At least ubuntu 18.04 ships only shared libraries.
3077 write_c_skeleton
3078 if compile_prog "" "$gnutls_libs" ; then
3079 LIBS="$gnutls_libs $LIBS"
3080 QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
3081 pass="yes"
3082 fi
3083 fi
3084 if test "$pass" = "no" && test "$gnutls" = "yes"; then
3085 feature_not_found "gnutls" "Install gnutls devel >= 3.1.18"
3086 else
3087 gnutls="$pass"
3088 fi
3089 fi
3090
3091
3092 # If user didn't give a --disable/enable-gcrypt flag,
3093 # then mark as disabled if user requested nettle
3094 # explicitly
3095 if test -z "$gcrypt"
3096 then
3097 if test "$nettle" = "yes"
3098 then
3099 gcrypt="no"
3100 fi
3101 fi
3102
3103 # If user didn't give a --disable/enable-nettle flag,
3104 # then mark as disabled if user requested gcrypt
3105 # explicitly
3106 if test -z "$nettle"
3107 then
3108 if test "$gcrypt" = "yes"
3109 then
3110 nettle="no"
3111 fi
3112 fi
3113
3114 has_libgcrypt() {
3115 if ! has "libgcrypt-config"
3116 then
3117 return 1
3118 fi
3119
3120 if test -n "$cross_prefix"
3121 then
3122 host=$(libgcrypt-config --host)
3123 if test "$host-" != $cross_prefix
3124 then
3125 return 1
3126 fi
3127 fi
3128
3129 maj=`libgcrypt-config --version | awk -F . '{print $1}'`
3130 min=`libgcrypt-config --version | awk -F . '{print $2}'`
3131
3132 if test $maj != 1 || test $min -lt 5
3133 then
3134 return 1
3135 fi
3136
3137 return 0
3138 }
3139
3140
3141 if test "$nettle" != "no"; then
3142 pass="no"
3143 if $pkg_config --exists "nettle >= 2.7.1"; then
3144 nettle_cflags=$($pkg_config --cflags nettle)
3145 nettle_libs=$($pkg_config --libs nettle)
3146 nettle_version=$($pkg_config --modversion nettle)
3147 # Link test to make sure the given libraries work (e.g for static).
3148 write_c_skeleton
3149 if compile_prog "" "$nettle_libs" ; then
3150 LIBS="$nettle_libs $LIBS"
3151 QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
3152 if test -z "$gcrypt"; then
3153 gcrypt="no"
3154 fi
3155 pass="yes"
3156 fi
3157 fi
3158 if test "$pass" = "yes"
3159 then
3160 cat > $TMPC << EOF
3161 #include <nettle/xts.h>
3162 int main(void) {
3163 return 0;
3164 }
3165 EOF
3166 if compile_prog "$nettle_cflags" "$nettle_libs" ; then
3167 nettle_xts=yes
3168 qemu_private_xts=no
3169 fi
3170 fi
3171 if test "$pass" = "no" && test "$nettle" = "yes"; then
3172 feature_not_found "nettle" "Install nettle devel >= 2.7.1"
3173 else
3174 nettle="$pass"
3175 fi
3176 fi
3177
3178 if test "$gcrypt" != "no"; then
3179 pass="no"
3180 if has_libgcrypt; then
3181 gcrypt_cflags=$(libgcrypt-config --cflags)
3182 gcrypt_libs=$(libgcrypt-config --libs)
3183 # Debian has removed -lgpg-error from libgcrypt-config
3184 # as it "spreads unnecessary dependencies" which in
3185 # turn breaks static builds...
3186 if test "$static" = "yes"
3187 then
3188 gcrypt_libs="$gcrypt_libs -lgpg-error"
3189 fi
3190
3191 # Link test to make sure the given libraries work (e.g for static).
3192 write_c_skeleton
3193 if compile_prog "" "$gcrypt_libs" ; then
3194 LIBS="$gcrypt_libs $LIBS"
3195 QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
3196 pass="yes"
3197 fi
3198 fi
3199 if test "$pass" = "yes"; then
3200 gcrypt="yes"
3201 cat > $TMPC << EOF
3202 #include <gcrypt.h>
3203 int main(void) {
3204 gcry_mac_hd_t handle;
3205 gcry_mac_open(&handle, GCRY_MAC_HMAC_MD5,
3206 GCRY_MAC_FLAG_SECURE, NULL);
3207 return 0;
3208 }
3209 EOF
3210 if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
3211 gcrypt_hmac=yes
3212 fi
3213 cat > $TMPC << EOF
3214 #include <gcrypt.h>
3215 int main(void) {
3216 gcry_cipher_hd_t handle;
3217 gcry_cipher_open(&handle, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_XTS, 0);
3218 return 0;
3219 }
3220 EOF
3221 if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
3222 gcrypt_xts=yes
3223 qemu_private_xts=no
3224 fi
3225 elif test "$gcrypt" = "yes"; then
3226 feature_not_found "gcrypt" "Install gcrypt devel >= 1.5.0"
3227 else
3228 gcrypt="no"
3229 fi
3230 fi
3231
3232
3233 if test "$gcrypt" = "yes" && test "$nettle" = "yes"
3234 then
3235 error_exit "Only one of gcrypt & nettle can be enabled"
3236 fi
3237
3238 ##########################################
3239 # libtasn1 - only for the TLS creds/session test suite
3240
3241 tasn1=yes
3242 tasn1_cflags=""
3243 tasn1_libs=""
3244 if $pkg_config --exists "libtasn1"; then
3245 tasn1_cflags=$($pkg_config --cflags libtasn1)
3246 tasn1_libs=$($pkg_config --libs libtasn1)
3247 else
3248 tasn1=no
3249 fi
3250
3251
3252 ##########################################
3253 # PAM probe
3254
3255 if test "$auth_pam" != "no"; then
3256 cat > $TMPC <<EOF
3257 #include <security/pam_appl.h>
3258 #include <stdio.h>
3259 int main(void) {
3260 const char *service_name = "qemu";
3261 const char *user = "frank";
3262 const struct pam_conv pam_conv = { 0 };
3263 pam_handle_t *pamh = NULL;
3264 pam_start(service_name, user, &pam_conv, &pamh);
3265 return 0;
3266 }
3267 EOF
3268 if compile_prog "" "-lpam" ; then
3269 auth_pam=yes
3270 else
3271 if test "$auth_pam" = "yes"; then
3272 feature_not_found "PAM" "Install PAM development package"
3273 else
3274 auth_pam=no
3275 fi
3276 fi
3277 fi
3278
3279 ##########################################
3280 # getifaddrs (for tests/test-io-channel-socket )
3281
3282 have_ifaddrs_h=yes
3283 if ! check_include "ifaddrs.h" ; then
3284 have_ifaddrs_h=no
3285 fi
3286
3287 #########################################
3288 # libdrm check
3289 have_drm_h=no
3290 if check_include "libdrm/drm.h" ; then
3291 have_drm_h=yes
3292 fi
3293
3294 #########################################
3295 # sys/signal.h check
3296 have_sys_signal_h=no
3297 if check_include "sys/signal.h" ; then
3298 have_sys_signal_h=yes
3299 fi
3300
3301 ##########################################
3302 # VTE probe
3303
3304 if test "$vte" != "no"; then
3305 vteminversion="0.32.0"
3306 if $pkg_config --exists "vte-2.91"; then
3307 vtepackage="vte-2.91"
3308 else
3309 vtepackage="vte-2.90"
3310 fi
3311 if $pkg_config --exists "$vtepackage >= $vteminversion"; then
3312 vte_cflags=$($pkg_config --cflags $vtepackage)
3313 vte_libs=$($pkg_config --libs $vtepackage)
3314 vteversion=$($pkg_config --modversion $vtepackage)
3315 vte="yes"
3316 elif test "$vte" = "yes"; then
3317 feature_not_found "vte" "Install libvte-2.90/2.91 devel"
3318 else
3319 vte="no"
3320 fi
3321 fi
3322
3323 ##########################################
3324 # SDL probe
3325
3326 # Look for sdl configuration program (pkg-config or sdl2-config). Try
3327 # sdl2-config even without cross prefix, and favour pkg-config over sdl2-config.
3328
3329 sdl_probe ()
3330 {
3331 if $pkg_config sdl2 --exists; then
3332 sdlconfig="$pkg_config sdl2"
3333 sdlversion=$($sdlconfig --modversion 2>/dev/null)
3334 elif has "$sdl2_config"; then
3335 sdlconfig="$sdl2_config"
3336 sdlversion=$($sdlconfig --version)
3337 else
3338 if test "$sdl" = "yes" ; then
3339 feature_not_found "sdl" "Install SDL2-devel"
3340 fi
3341 sdl=no
3342 # no need to do the rest
3343 return
3344 fi
3345 if test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl2-config; then
3346 echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
3347 fi
3348
3349 cat > $TMPC << EOF
3350 #include <SDL.h>
3351 #undef main /* We don't want SDL to override our main() */
3352 int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
3353 EOF
3354 sdl_cflags=$($sdlconfig --cflags 2>/dev/null)
3355 sdl_cflags="$sdl_cflags -Wno-undef" # workaround 2.0.8 bug
3356 if test "$static" = "yes" ; then
3357 if $pkg_config sdl2 --exists; then
3358 sdl_libs=$($pkg_config sdl2 --static --libs 2>/dev/null)
3359 else
3360 sdl_libs=$($sdlconfig --static-libs 2>/dev/null)
3361 fi
3362 else
3363 sdl_libs=$($sdlconfig --libs 2>/dev/null)
3364 fi
3365 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
3366 sdl=yes
3367
3368 # static link with sdl ? (note: sdl.pc's --static --libs is broken)
3369 if test "$sdl" = "yes" && test "$static" = "yes" ; then
3370 if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
3371 sdl_libs="$sdl_libs $(aalib-config --static-libs 2>/dev/null)"
3372 sdl_cflags="$sdl_cflags $(aalib-config --cflags 2>/dev/null)"
3373 fi
3374 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
3375 :
3376 else
3377 sdl=no
3378 fi
3379 fi # static link
3380 else # sdl not found
3381 if test "$sdl" = "yes" ; then
3382 feature_not_found "sdl" "Install SDL2 devel"
3383 fi
3384 sdl=no
3385 fi # sdl compile test
3386 }
3387
3388 sdl_image_probe ()
3389 {
3390 if test "$sdl_image" != "no" ; then
3391 if $pkg_config SDL2_image --exists; then
3392 if test "$static" = "yes"; then
3393 sdl_image_libs=$($pkg_config SDL2_image --libs --static 2>/dev/null)
3394 else
3395 sdl_image_libs=$($pkg_config SDL2_image --libs 2>/dev/null)
3396 fi
3397 sdl_image_cflags=$($pkg_config SDL2_image --cflags 2>/dev/null)
3398 sdl_image=yes
3399
3400 sdl_cflags="$sdl_cflags $sdl_image_cflags"
3401 sdl_libs="$sdl_libs $sdl_image_libs"
3402 else
3403 if test "$sdl_image" = "yes" ; then
3404 feature_not_found "sdl_image" "Install SDL Image devel"
3405 else
3406 sdl_image=no
3407 fi
3408 fi
3409 fi
3410 }
3411
3412 if test "$sdl" != "no" ; then
3413 sdl_probe
3414 fi
3415
3416 if test "$sdl" = "yes" ; then
3417 sdl_image_probe
3418 else
3419 if test "$sdl_image" = "yes"; then
3420 echo "warning: SDL Image requested, but SDL is not available, disabling"
3421 fi
3422 sdl_image=no
3423 fi
3424
3425 if test "$sdl" = "yes" ; then
3426 cat > $TMPC <<EOF
3427 #include <SDL.h>
3428 #if defined(SDL_VIDEO_DRIVER_X11)
3429 #include <X11/XKBlib.h>
3430 #else
3431 #error No x11 support
3432 #endif
3433 int main(void) { return 0; }
3434 EOF
3435 if compile_prog "$sdl_cflags $x11_cflags" "$sdl_libs $x11_libs" ; then
3436 need_x11=yes
3437 sdl_cflags="$sdl_cflags $x11_cflags"
3438 sdl_libs="$sdl_libs $x11_libs"
3439 fi
3440 fi
3441
3442 ##########################################
3443 # RDMA needs OpenFabrics libraries
3444 if test "$rdma" != "no" ; then
3445 cat > $TMPC <<EOF
3446 #include <rdma/rdma_cma.h>
3447 int main(void) { return 0; }
3448 EOF
3449 rdma_libs="-lrdmacm -libverbs -libumad"
3450 if compile_prog "" "$rdma_libs" ; then
3451 rdma="yes"
3452 libs_softmmu="$libs_softmmu $rdma_libs"
3453 else
3454 if test "$rdma" = "yes" ; then
3455 error_exit \
3456 " OpenFabrics librdmacm/libibverbs/libibumad not present." \
3457 " Your options:" \
3458 " (1) Fast: Install infiniband packages (devel) from your distro." \
3459 " (2) Cleanest: Install libraries from www.openfabrics.org" \
3460 " (3) Also: Install softiwarp if you don't have RDMA hardware"
3461 fi
3462 rdma="no"
3463 fi
3464 fi
3465
3466 ##########################################
3467 # PVRDMA detection
3468
3469 cat > $TMPC <<EOF &&
3470 #include <sys/mman.h>
3471
3472 int
3473 main(void)
3474 {
3475 char buf = 0;
3476 void *addr = &buf;
3477 addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED);
3478
3479 return 0;
3480 }
3481 EOF
3482
3483 if test "$rdma" = "yes" ; then
3484 case "$pvrdma" in
3485 "")
3486 if compile_prog "" ""; then
3487 pvrdma="yes"
3488 else
3489 pvrdma="no"
3490 fi
3491 ;;
3492 "yes")
3493 if ! compile_prog "" ""; then
3494 error_exit "PVRDMA is not supported since mremap is not implemented"
3495 fi
3496 pvrdma="yes"
3497 ;;
3498 "no")
3499 pvrdma="no"
3500 ;;
3501 esac
3502 else
3503 if test "$pvrdma" = "yes" ; then
3504 error_exit "PVRDMA requires rdma suppport"
3505 fi
3506 pvrdma="no"
3507 fi
3508
3509 # Let's see if enhanced reg_mr is supported
3510 if test "$pvrdma" = "yes" ; then
3511
3512 cat > $TMPC <<EOF &&
3513 #include <infiniband/verbs.h>
3514
3515 int
3516 main(void)
3517 {
3518 struct ibv_mr *mr;
3519 struct ibv_pd *pd = NULL;
3520 size_t length = 10;
3521 uint64_t iova = 0;
3522 int access = 0;
3523 void *addr = NULL;
3524
3525 mr = ibv_reg_mr_iova(pd, addr, length, iova, access);
3526
3527 ibv_dereg_mr(mr);
3528
3529 return 0;
3530 }
3531 EOF
3532 if ! compile_prog "" "-libverbs"; then
3533 QEMU_CFLAGS="$QEMU_CFLAGS -DLEGACY_RDMA_REG_MR"
3534 fi
3535 fi
3536
3537 ##########################################
3538 # VNC SASL detection
3539 if test "$vnc" = "yes" && test "$vnc_sasl" != "no" ; then
3540 cat > $TMPC <<EOF
3541 #include <sasl/sasl.h>
3542 #include <stdio.h>
3543 int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
3544 EOF
3545 # Assuming Cyrus-SASL installed in /usr prefix
3546 # QEMU defines struct iovec in "qemu/osdep.h",
3547 # we don't want libsasl to redefine it in <sasl/sasl.h>.
3548 vnc_sasl_cflags="-DSTRUCT_IOVEC_DEFINED"
3549 vnc_sasl_libs="-lsasl2"
3550 if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
3551 vnc_sasl=yes
3552 libs_softmmu="$vnc_sasl_libs $libs_softmmu"
3553 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
3554 else
3555 if test "$vnc_sasl" = "yes" ; then
3556 feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
3557 fi
3558 vnc_sasl=no
3559 fi
3560 fi
3561
3562 ##########################################
3563 # VNC JPEG detection
3564 if test "$vnc" = "yes" && test "$vnc_jpeg" != "no" ; then
3565 cat > $TMPC <<EOF
3566 #include <stdio.h>
3567 #include <jpeglib.h>
3568 int main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
3569 EOF
3570 vnc_jpeg_cflags=""
3571 vnc_jpeg_libs="-ljpeg"
3572 if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
3573 vnc_jpeg=yes
3574 libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
3575 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
3576 else
3577 if test "$vnc_jpeg" = "yes" ; then
3578 feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
3579 fi
3580 vnc_jpeg=no
3581 fi
3582 fi
3583
3584 ##########################################
3585 # VNC PNG detection
3586 if test "$vnc" = "yes" && test "$vnc_png" != "no" ; then
3587 cat > $TMPC <<EOF
3588 //#include <stdio.h>
3589 #include <png.h>
3590 #include <stddef.h>
3591 int main(void) {
3592 png_structp png_ptr;
3593 png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
3594 return png_ptr != 0;
3595 }
3596 EOF
3597 if $pkg_config libpng --exists; then
3598 vnc_png_cflags=$($pkg_config libpng --cflags)
3599 vnc_png_libs=$($pkg_config libpng --libs)
3600 else
3601 vnc_png_cflags=""
3602 vnc_png_libs="-lpng"
3603 fi
3604 if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
3605 vnc_png=yes
3606 libs_softmmu="$vnc_png_libs $libs_softmmu"
3607 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
3608 else
3609 if test "$vnc_png" = "yes" ; then
3610 feature_not_found "vnc-png" "Install libpng devel"
3611 fi
3612 vnc_png=no
3613 fi
3614 fi
3615
3616 ##########################################
3617 # xkbcommon probe
3618 if test "$xkbcommon" != "no" ; then
3619 if $pkg_config xkbcommon --exists; then
3620 xkbcommon_cflags=$($pkg_config xkbcommon --cflags)
3621 xkbcommon_libs=$($pkg_config xkbcommon --libs)
3622 xkbcommon=yes
3623 else
3624 if test "$xkbcommon" = "yes" ; then
3625 feature_not_found "xkbcommon" "Install libxkbcommon-devel"
3626 fi
3627 xkbcommon=no
3628 fi
3629 fi
3630
3631
3632 ##########################################
3633 # xfsctl() probe, used for file-posix.c
3634 if test "$xfs" != "no" ; then
3635 cat > $TMPC << EOF
3636 #include <stddef.h> /* NULL */
3637 #include <xfs/xfs.h>
3638 int main(void)
3639 {
3640 xfsctl(NULL, 0, 0, NULL);
3641 return 0;
3642 }
3643 EOF
3644 if compile_prog "" "" ; then
3645 xfs="yes"
3646 else
3647 if test "$xfs" = "yes" ; then
3648 feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
3649 fi
3650 xfs=no
3651 fi
3652 fi
3653
3654 ##########################################
3655 # vde libraries probe
3656 if test "$vde" != "no" ; then
3657 vde_libs="-lvdeplug"
3658 cat > $TMPC << EOF
3659 #include <libvdeplug.h>
3660 int main(void)
3661 {
3662 struct vde_open_args a = {0, 0, 0};
3663 char s[] = "";
3664 vde_open(s, s, &a);
3665 return 0;
3666 }
3667 EOF
3668 if compile_prog "" "$vde_libs" ; then
3669 vde=yes
3670 else
3671 if test "$vde" = "yes" ; then
3672 feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
3673 fi
3674 vde=no
3675 fi
3676 fi
3677
3678 ##########################################
3679 # netmap support probe
3680 # Apart from looking for netmap headers, we make sure that the host API version
3681 # supports the netmap backend (>=11). The upper bound (15) is meant to simulate
3682 # a minor/major version number. Minor new features will be marked with values up
3683 # to 15, and if something happens that requires a change to the backend we will
3684 # move above 15, submit the backend fixes and modify this two bounds.
3685 if test "$netmap" != "no" ; then
3686 cat > $TMPC << EOF
3687 #include <inttypes.h>
3688 #include <net/if.h>
3689 #include <net/netmap.h>
3690 #include <net/netmap_user.h>
3691 #if (NETMAP_API < 11) || (NETMAP_API > 15)
3692 #error
3693 #endif
3694 int main(void) { return 0; }
3695 EOF
3696 if compile_prog "" "" ; then
3697 netmap=yes
3698 else
3699 if test "$netmap" = "yes" ; then
3700 feature_not_found "netmap"
3701 fi
3702 netmap=no
3703 fi
3704 fi
3705
3706 ##########################################
3707 # libcap-ng library probe
3708 if test "$cap_ng" != "no" ; then
3709 cap_libs="-lcap-ng"
3710 cat > $TMPC << EOF
3711 #include <cap-ng.h>
3712 int main(void)
3713 {
3714 capng_capability_to_name(CAPNG_EFFECTIVE);
3715 return 0;
3716 }
3717 EOF
3718 if compile_prog "" "$cap_libs" ; then
3719 cap_ng=yes
3720 libs_tools="$cap_libs $libs_tools"
3721 else
3722 if test "$cap_ng" = "yes" ; then
3723 feature_not_found "cap_ng" "Install libcap-ng devel"
3724 fi
3725 cap_ng=no
3726 fi
3727 fi
3728
3729 ##########################################
3730 # Sound support libraries probe
3731
3732 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
3733 for drv in $audio_drv_list; do
3734 case $drv in
3735 alsa | try-alsa)
3736 if $pkg_config alsa --exists; then
3737 alsa_libs=$($pkg_config alsa --libs)
3738 if test "$drv" = "try-alsa"; then
3739 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa/alsa/')
3740 fi
3741 else
3742 if test "$drv" = "try-alsa"; then
3743 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa//')
3744 else
3745 error_exit "$drv check failed" \
3746 "Make sure to have the $drv libs and headers installed."
3747 fi
3748 fi
3749 ;;
3750
3751 pa | try-pa)
3752 if $pkg_config libpulse --exists; then
3753 pulse_libs=$($pkg_config libpulse --libs)
3754 if test "$drv" = "try-pa"; then
3755 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa/pa/')
3756 fi
3757 else
3758 if test "$drv" = "try-pa"; then
3759 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa//')
3760 else
3761 error_exit "$drv check failed" \
3762 "Make sure to have the $drv libs and headers installed."
3763 fi
3764 fi
3765 ;;
3766
3767 sdl)
3768 if test "$sdl" = "no"; then
3769 error_exit "sdl not found or disabled, can not use sdl audio driver"
3770 fi
3771 ;;
3772
3773 try-sdl)
3774 if test "$sdl" = "no"; then
3775 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl//')
3776 else
3777 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl/sdl/')
3778 fi
3779 ;;
3780
3781 coreaudio)
3782 coreaudio_libs="-framework CoreAudio"
3783 ;;
3784
3785 dsound)
3786 dsound_libs="-lole32 -ldxguid"
3787 audio_win_int="yes"
3788 ;;
3789
3790 oss)
3791 oss_libs="$oss_lib"
3792 ;;
3793
3794 jack | try-jack)
3795 if $pkg_config jack --exists; then
3796 jack_libs=$($pkg_config jack --libs)
3797 if test "$drv" = "try-jack"; then
3798 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-jack/jack/')
3799 fi
3800 else
3801 if test "$drv" = "try-jack"; then
3802 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-jack//')
3803 else
3804 error_exit "$drv check failed" \
3805 "Make sure to have the $drv libs and headers installed."
3806 fi
3807 fi
3808 ;;
3809
3810 *)
3811 echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
3812 error_exit "Unknown driver '$drv' selected" \
3813 "Possible drivers are: $audio_possible_drivers"
3814 }
3815 ;;
3816 esac
3817 done
3818
3819 ##########################################
3820 # BrlAPI probe
3821
3822 if test "$brlapi" != "no" ; then
3823 brlapi_libs="-lbrlapi"
3824 cat > $TMPC << EOF
3825 #include <brlapi.h>
3826 #include <stddef.h>
3827 int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
3828 EOF
3829 if compile_prog "" "$brlapi_libs" ; then
3830 brlapi=yes
3831 else
3832 if test "$brlapi" = "yes" ; then
3833 feature_not_found "brlapi" "Install brlapi devel"
3834 fi
3835 brlapi=no
3836 fi
3837 fi
3838
3839 ##########################################
3840 # iconv probe
3841 if test "$iconv" != "no" ; then
3842 cat > $TMPC << EOF
3843 #include <iconv.h>
3844 int main(void) {
3845 iconv_t conv = iconv_open("WCHAR_T", "UCS-2");
3846 return conv != (iconv_t) -1;
3847 }
3848 EOF
3849 iconv_prefix_list="/usr/local:/usr"
3850 iconv_lib_list=":-liconv"
3851 IFS=:
3852 for iconv_prefix in $iconv_prefix_list; do
3853 IFS=:
3854 iconv_cflags="-I$iconv_prefix/include"
3855 iconv_ldflags="-L$iconv_prefix/lib"
3856 for iconv_link in $iconv_lib_list; do
3857 unset IFS
3858 iconv_lib="$iconv_ldflags $iconv_link"
3859 echo "looking at iconv in '$iconv_cflags' '$iconv_lib'" >> config.log
3860 if compile_prog "$iconv_cflags" "$iconv_lib" ; then
3861 iconv_found=yes
3862 break
3863 fi
3864 done
3865 if test "$iconv_found" = yes ; then
3866 break
3867 fi
3868 done
3869 if test "$iconv_found" = "yes" ; then
3870 iconv=yes
3871 else
3872 if test "$iconv" = "yes" ; then
3873 feature_not_found "iconv" "Install iconv devel"
3874 fi
3875 iconv=no
3876 fi
3877 fi
3878
3879 ##########################################
3880 # curses probe
3881 if test "$iconv" = "no" ; then
3882 # curses will need iconv
3883 curses=no
3884 fi
3885 if test "$curses" != "no" ; then
3886 if test "$mingw32" = "yes" ; then
3887 curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
3888 curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
3889 else
3890 curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"
3891 curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
3892 fi
3893 curses_found=no
3894 cat > $TMPC << EOF
3895 #include <locale.h>
3896 #include <curses.h>
3897 #include <wchar.h>
3898 #include <langinfo.h>
3899 int main(void) {
3900 const char *codeset;
3901 wchar_t wch = L'w';
3902 setlocale(LC_ALL, "");
3903 resize_term(0, 0);
3904 addwstr(L"wide chars\n");
3905 addnwstr(&wch, 1);
3906 add_wch(WACS_DEGREE);
3907 codeset = nl_langinfo(CODESET);
3908 return codeset != 0;
3909 }
3910 EOF
3911 IFS=:
3912 for curses_inc in $curses_inc_list; do
3913 # Make sure we get the wide character prototypes
3914 curses_inc="-DNCURSES_WIDECHAR $curses_inc"
3915 IFS=:
3916 for curses_lib in $curses_lib_list; do
3917 unset IFS
3918 if compile_prog "$curses_inc" "$curses_lib" ; then
3919 curses_found=yes
3920 break
3921 fi
3922 done
3923 if test "$curses_found" = yes ; then
3924 break
3925 fi
3926 done
3927 unset IFS
3928 if test "$curses_found" = "yes" ; then
3929 curses=yes
3930 else
3931 if test "$curses" = "yes" ; then
3932 feature_not_found "curses" "Install ncurses devel"
3933 fi
3934 curses=no
3935 fi
3936 fi
3937
3938 ##########################################
3939 # curl probe
3940 if test "$curl" != "no" ; then
3941 if $pkg_config libcurl --exists; then
3942 curlconfig="$pkg_config libcurl"
3943 else
3944 curlconfig=curl-config
3945 fi
3946 cat > $TMPC << EOF
3947 #include <curl/curl.h>
3948 int main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
3949 EOF
3950 curl_cflags=$($curlconfig --cflags 2>/dev/null)
3951 curl_libs=$($curlconfig --libs 2>/dev/null)
3952 if compile_prog "$curl_cflags" "$curl_libs" ; then
3953 curl=yes
3954 else
3955 if test "$curl" = "yes" ; then
3956 feature_not_found "curl" "Install libcurl devel"
3957 fi
3958 curl=no
3959 fi
3960 fi # test "$curl"
3961
3962 ##########################################
3963 # glib support probe
3964
3965 glib_req_ver=2.48
3966 glib_modules=gthread-2.0
3967 if test "$modules" = yes; then
3968 glib_modules="$glib_modules gmodule-export-2.0"
3969 fi
3970 if test "$plugins" = yes; then
3971 glib_modules="$glib_modules gmodule-2.0"
3972 fi
3973
3974 # This workaround is required due to a bug in pkg-config file for glib as it
3975 # doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
3976
3977 if test "$static" = yes && test "$mingw32" = yes; then
3978 QEMU_CFLAGS="-DGLIB_STATIC_COMPILATION $QEMU_CFLAGS"
3979 fi
3980
3981 for i in $glib_modules; do
3982 if $pkg_config --atleast-version=$glib_req_ver $i; then
3983 glib_cflags=$($pkg_config --cflags $i)
3984 glib_libs=$($pkg_config --libs $i)
3985 QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
3986 LIBS="$glib_libs $LIBS"
3987 libs_qga="$glib_libs $libs_qga"
3988 else
3989 error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3990 fi
3991 done
3992
3993 if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
3994 gio=yes
3995 gio_cflags=$($pkg_config --cflags gio-2.0)
3996 gio_libs=$($pkg_config --libs gio-2.0)
3997 gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0)
3998 if [ ! -x "$gdbus_codegen" ]; then
3999 gdbus_codegen=
4000 fi
4001 else
4002 gio=no
4003 fi
4004
4005 if $pkg_config --atleast-version=$glib_req_ver gio-unix-2.0; then
4006 gio_cflags="$gio_cflags $($pkg_config --cflags gio-unix-2.0)"
4007 gio_libs="$gio_libs $($pkg_config --libs gio-unix-2.0)"
4008 fi
4009
4010 # Sanity check that the current size_t matches the
4011 # size that glib thinks it should be. This catches
4012 # problems on multi-arch where people try to build
4013 # 32-bit QEMU while pointing at 64-bit glib headers
4014 cat > $TMPC <<EOF
4015 #include <glib.h>
4016 #include <unistd.h>
4017
4018 #define QEMU_BUILD_BUG_ON(x) \
4019 typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
4020
4021 int main(void) {
4022 QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
4023 return 0;
4024 }
4025 EOF
4026
4027 if ! compile_prog "$CFLAGS" "$LIBS" ; then
4028 error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
4029 "You probably need to set PKG_CONFIG_LIBDIR"\
4030 "to point to the right pkg-config files for your"\
4031 "build target"
4032 fi
4033
4034 # Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
4035 cat > $TMPC << EOF
4036 #include <glib.h>
4037 int main(void) { return 0; }
4038 EOF
4039 if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
4040 if cc_has_warning_flag "-Wno-unknown-attributes"; then
4041 glib_cflags="-Wno-unknown-attributes $glib_cflags"
4042 QEMU_CFLAGS="-Wno-unknown-attributes $CFLAGS"
4043 fi
4044 fi
4045
4046 # Silence clang warnings triggered by glib < 2.57.2
4047 cat > $TMPC << EOF
4048 #include <glib.h>
4049 typedef struct Foo {
4050 int i;
4051 } Foo;
4052 static void foo_free(Foo *f)
4053 {
4054 g_free(f);
4055 }
4056 G_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free);
4057 int main(void) { return 0; }
4058 EOF
4059 if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
4060 if cc_has_warning_flag "-Wno-unused-function"; then
4061 glib_cflags="$glib_cflags -Wno-unused-function"
4062 CFLAGS="$CFLAGS -Wno-unused-function"
4063 fi
4064 fi
4065
4066 #########################################
4067 # zlib check
4068
4069 if test "$zlib" != "no" ; then
4070 if $pkg_config --exists zlib; then
4071 zlib_cflags=$($pkg_config --cflags zlib)
4072 zlib_libs=$($pkg_config --libs zlib)
4073 QEMU_CFLAGS="$zlib_cflags $QEMU_CFLAGS"
4074 LIBS="$zlib_libs $LIBS"
4075 else
4076 cat > $TMPC << EOF
4077 #include <zlib.h>
4078 int main(void) { zlibVersion(); return 0; }
4079 EOF
4080 if compile_prog "" "-lz" ; then
4081 LIBS="$LIBS -lz"
4082 else
4083 error_exit "zlib check failed" \
4084 "Make sure to have the zlib libs and headers installed."
4085 fi
4086 fi
4087 fi
4088
4089 ##########################################
4090 # SHA command probe for modules
4091 if test "$modules" = yes; then
4092 shacmd_probe="sha1sum sha1 shasum"
4093 for c in $shacmd_probe; do
4094 if has $c; then
4095 shacmd="$c"
4096 break
4097 fi
4098 done
4099 if test "$shacmd" = ""; then
4100 error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
4101 fi
4102 fi
4103
4104 ##########################################
4105 # pixman support probe
4106
4107 if test "$softmmu" = "no"; then
4108 pixman_cflags=
4109 pixman_libs=
4110 elif $pkg_config --atleast-version=0.21.8 pixman-1 > /dev/null 2>&1; then
4111 pixman_cflags=$($pkg_config --cflags pixman-1)
4112 pixman_libs=$($pkg_config --libs pixman-1)
4113 else
4114 error_exit "pixman >= 0.21.8 not present." \
4115 "Please install the pixman devel package."
4116 fi
4117
4118 ##########################################
4119 # libmpathpersist probe
4120
4121 if test "$mpath" != "no" ; then
4122 # probe for the new API
4123 cat > $TMPC <<EOF
4124 #include <libudev.h>
4125 #include <mpath_persist.h>
4126 unsigned mpath_mx_alloc_len = 1024;
4127 int logsink;
4128 static struct config *multipath_conf;
4129 extern struct udev *udev;
4130 extern struct config *get_multipath_config(void);
4131 extern void put_multipath_config(struct config *conf);
4132 struct udev *udev;
4133 struct config *get_multipath_config(void) { return multipath_conf; }
4134 void put_multipath_config(struct config *conf) { }
4135
4136 int main(void) {
4137 udev = udev_new();
4138 multipath_conf = mpath_lib_init();
4139 return 0;
4140 }
4141 EOF
4142 if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
4143 mpathpersist=yes
4144 mpathpersist_new_api=yes
4145 else
4146 # probe for the old API
4147 cat > $TMPC <<EOF
4148 #include <libudev.h>
4149 #include <mpath_persist.h>
4150 unsigned mpath_mx_alloc_len = 1024;
4151 int logsink;
4152 int main(void) {
4153 struct udev *udev = udev_new();
4154 mpath_lib_init(udev);
4155 return 0;
4156 }
4157 EOF
4158 if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
4159 mpathpersist=yes
4160 mpathpersist_new_api=no
4161 else
4162 mpathpersist=no
4163 fi
4164 fi
4165 else
4166 mpathpersist=no
4167 fi
4168
4169 ##########################################
4170 # pthread probe
4171 PTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
4172
4173 pthread=no
4174 cat > $TMPC << EOF
4175 #include <pthread.h>
4176 static void *f(void *p) { return NULL; }
4177 int main(void) {
4178 pthread_t thread;
4179 pthread_create(&thread, 0, f, 0);
4180 return 0;
4181 }
4182 EOF
4183 if compile_prog "" "" ; then
4184 pthread=yes
4185 else
4186 for pthread_lib in $PTHREADLIBS_LIST; do
4187 if compile_prog "" "$pthread_lib" ; then
4188 pthread=yes
4189 found=no
4190 for lib_entry in $LIBS; do
4191 if test "$lib_entry" = "$pthread_lib"; then
4192 found=yes
4193 break
4194 fi
4195 done
4196 if test "$found" = "no"; then
4197 LIBS="$pthread_lib $LIBS"
4198 libs_qga="$pthread_lib $libs_qga"
4199 fi
4200 PTHREAD_LIB="$pthread_lib"
4201 break
4202 fi
4203 done
4204 fi
4205
4206 if test "$mingw32" != yes && test "$pthread" = no; then
4207 error_exit "pthread check failed" \
4208 "Make sure to have the pthread libs and headers installed."
4209 fi
4210
4211 # check for pthread_setname_np with thread id
4212 pthread_setname_np_w_tid=no
4213 cat > $TMPC << EOF
4214 #include <pthread.h>
4215
4216 static void *f(void *p) { return NULL; }
4217 int main(void)
4218 {
4219 pthread_t thread;
4220 pthread_create(&thread, 0, f, 0);
4221 pthread_setname_np(thread, "QEMU");
4222 return 0;
4223 }
4224 EOF
4225 if compile_prog "" "$pthread_lib" ; then
4226 pthread_setname_np_w_tid=yes
4227 fi
4228
4229 # check for pthread_setname_np without thread id
4230 pthread_setname_np_wo_tid=no
4231 cat > $TMPC << EOF
4232 #include <pthread.h>
4233
4234 static void *f(void *p) { pthread_setname_np("QEMU"); return NULL; }
4235 int main(void)
4236 {
4237 pthread_t thread;
4238 pthread_create(&thread, 0, f, 0);
4239 return 0;
4240 }
4241 EOF
4242 if compile_prog "" "$pthread_lib" ; then
4243 pthread_setname_np_wo_tid=yes
4244 fi
4245
4246 ##########################################
4247 # rbd probe
4248 if test "$rbd" != "no" ; then
4249 cat > $TMPC <<EOF
4250 #include <stdio.h>
4251 #include <rbd/librbd.h>
4252 int main(void) {
4253 rados_t cluster;
4254 rados_create(&cluster, NULL);
4255 return 0;
4256 }
4257 EOF
4258 rbd_libs="-lrbd -lrados"
4259 if compile_prog "" "$rbd_libs" ; then
4260 rbd=yes
4261 else
4262 if test "$rbd" = "yes" ; then
4263 feature_not_found "rados block device" "Install librbd/ceph devel"
4264 fi
4265 rbd=no
4266 fi
4267 fi
4268
4269 ##########################################
4270 # libssh probe
4271 if test "$libssh" != "no" ; then
4272 if $pkg_config --exists libssh; then
4273 libssh_cflags=$($pkg_config libssh --cflags)
4274 libssh_libs=$($pkg_config libssh --libs)
4275 libssh=yes
4276 else
4277 if test "$libssh" = "yes" ; then
4278 error_exit "libssh required for --enable-libssh"
4279 fi
4280 libssh=no
4281 fi
4282 fi
4283
4284 ##########################################
4285 # Check for libssh 0.8
4286 # This is done like this instead of using the LIBSSH_VERSION_* and
4287 # SSH_VERSION_* macros because some distributions in the past shipped
4288 # snapshots of the future 0.8 from Git, and those snapshots did not
4289 # have updated version numbers (still referring to 0.7.0).
4290
4291 if test "$libssh" = "yes"; then
4292 cat > $TMPC <<EOF
4293 #include <libssh/libssh.h>
4294 int main(void) { return ssh_get_server_publickey(NULL, NULL); }
4295 EOF
4296 if compile_prog "$libssh_cflags" "$libssh_libs"; then
4297 libssh_cflags="-DHAVE_LIBSSH_0_8 $libssh_cflags"
4298 fi
4299 fi
4300
4301 ##########################################
4302 # linux-aio probe
4303
4304 if test "$linux_aio" != "no" ; then
4305 cat > $TMPC <<EOF
4306 #include <libaio.h>
4307 #include <sys/eventfd.h>
4308 #include <stddef.h>
4309 int main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
4310 EOF
4311 if compile_prog "" "-laio" ; then
4312 linux_aio=yes
4313 else
4314 if test "$linux_aio" = "yes" ; then
4315 feature_not_found "linux AIO" "Install libaio devel"
4316 fi
4317 linux_aio=no
4318 fi
4319 fi
4320 ##########################################
4321 # linux-io-uring probe
4322
4323 if test "$linux_io_uring" != "no" ; then
4324 if $pkg_config liburing; then
4325 linux_io_uring_cflags=$($pkg_config --cflags liburing)
4326 linux_io_uring_libs=$($pkg_config --libs liburing)
4327 linux_io_uring=yes
4328
4329 # io_uring is used in libqemuutil.a where per-file -libs variables are not
4330 # seen by programs linking the archive. It's not ideal, but just add the
4331 # library dependency globally.
4332 LIBS="$linux_io_uring_libs $LIBS"
4333 else
4334 if test "$linux_io_uring" = "yes" ; then
4335 feature_not_found "linux io_uring" "Install liburing devel"
4336 fi
4337 linux_io_uring=no
4338 fi
4339 fi
4340
4341 ##########################################
4342 # TPM emulation is only on POSIX
4343
4344 if test "$tpm" = ""; then
4345 if test "$mingw32" = "yes"; then
4346 tpm=no
4347 else
4348 tpm=yes
4349 fi
4350 elif test "$tpm" = "yes"; then
4351 if test "$mingw32" = "yes" ; then
4352 error_exit "TPM emulation only available on POSIX systems"
4353 fi
4354 fi
4355
4356 ##########################################
4357 # attr probe
4358
4359 if test "$attr" != "no" ; then
4360 cat > $TMPC <<EOF
4361 #include <stdio.h>
4362 #include <sys/types.h>
4363 #ifdef CONFIG_LIBATTR
4364 #include <attr/xattr.h>
4365 #else
4366 #include <sys/xattr.h>
4367 #endif
4368 int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
4369 EOF
4370 if compile_prog "" "" ; then
4371 attr=yes
4372 # Older distros have <attr/xattr.h>, and need -lattr:
4373 elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
4374 attr=yes
4375 LIBS="-lattr $LIBS"
4376 libattr=yes
4377 else
4378 if test "$attr" = "yes" ; then
4379 feature_not_found "ATTR" "Install libc6 or libattr devel"
4380 fi
4381 attr=no
4382 fi
4383 fi
4384
4385 ##########################################
4386 # iovec probe
4387 cat > $TMPC <<EOF
4388 #include <sys/types.h>
4389 #include <sys/uio.h>
4390 #include <unistd.h>
4391 int main(void) { return sizeof(struct iovec); }
4392 EOF
4393 iovec=no
4394 if compile_prog "" "" ; then
4395 iovec=yes
4396 fi
4397
4398 ##########################################
4399 # preadv probe
4400 cat > $TMPC <<EOF
4401 #include <sys/types.h>
4402 #include <sys/uio.h>
4403 #include <unistd.h>
4404 int main(void) { return preadv(0, 0, 0, 0); }
4405 EOF
4406 preadv=no
4407 if compile_prog "" "" ; then
4408 preadv=yes
4409 fi
4410
4411 ##########################################
4412 # fdt probe
4413 # fdt support is mandatory for at least some target architectures,
4414 # so insist on it if we're building those system emulators.
4415 fdt_required=no
4416 for target in $target_list; do
4417 case $target in
4418 aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu|riscv*-softmmu|rx-softmmu)
4419 fdt_required=yes
4420 ;;
4421 esac
4422 done
4423
4424 if test "$fdt_required" = "yes"; then
4425 if test "$fdt" = "no"; then
4426 error_exit "fdt disabled but some requested targets require it." \
4427 "You can turn off fdt only if you also disable all the system emulation" \
4428 "targets which need it (by specifying a cut down --target-list)."
4429 fi
4430 fdt=yes
4431 elif test "$fdt" != "yes" ; then
4432 fdt=no
4433 fi
4434
4435 # fdt is only required when building softmmu targets
4436 if test -z "$fdt" -a "$softmmu" != "yes" ; then
4437 fdt="no"
4438 fi
4439
4440 if test "$fdt" != "no" ; then
4441 fdt_libs="-lfdt"
4442 # explicitly check for libfdt_env.h as it is missing in some stable installs
4443 # and test for required functions to make sure we are on a version >= 1.4.2
4444 cat > $TMPC << EOF
4445 #include <libfdt.h>
4446 #include <libfdt_env.h>
4447 int main(void) { fdt_check_full(NULL, 0); return 0; }
4448 EOF
4449 if compile_prog "" "$fdt_libs" ; then
4450 # system DTC is good - use it
4451 fdt=system
4452 else
4453 # have GIT checkout, so activate dtc submodule
4454 if test -e "${source_path}/.git" ; then
4455 git_submodules="${git_submodules} dtc"
4456 fi
4457 if test -d "${source_path}/dtc/libfdt" || test -e "${source_path}/.git" ; then
4458 fdt=git
4459 mkdir -p dtc
4460 if [ "$pwd_is_source_path" != "y" ] ; then
4461 symlink "$source_path/dtc/Makefile" "dtc/Makefile"
4462 fi
4463 fdt_cflags="-I${source_path}/dtc/libfdt"
4464 fdt_ldflags="-L$PWD/dtc/libfdt"
4465 fdt_libs="$fdt_libs"
4466 elif test "$fdt" = "yes" ; then
4467 # Not a git build & no libfdt found, prompt for system install
4468 error_exit "DTC (libfdt) version >= 1.4.2 not present." \
4469 "Please install the DTC (libfdt) devel package"
4470 else
4471 # don't have and don't want
4472 fdt_libs=
4473 fdt=no
4474 fi
4475 fi
4476 fi
4477
4478 libs_softmmu="$libs_softmmu $fdt_libs"
4479
4480 ##########################################
4481 # opengl probe (for sdl2, gtk, milkymist-tmu2)
4482
4483 gbm="no"
4484 if $pkg_config gbm; then
4485 gbm_cflags="$($pkg_config --cflags gbm)"
4486 gbm_libs="$($pkg_config --libs gbm)"
4487 gbm="yes"
4488 fi
4489
4490 if test "$opengl" != "no" ; then
4491 opengl_pkgs="epoxy gbm"
4492 if $pkg_config $opengl_pkgs; then
4493 opengl_cflags="$($pkg_config --cflags $opengl_pkgs)"
4494 opengl_libs="$($pkg_config --libs $opengl_pkgs)"
4495 opengl=yes
4496 if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
4497 gtk_gl="yes"
4498 fi
4499 QEMU_CFLAGS="$QEMU_CFLAGS $opengl_cflags"
4500 else
4501 if test "$opengl" = "yes" ; then
4502 feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
4503 fi
4504 opengl_cflags=""
4505 opengl_libs=""
4506 opengl=no
4507 fi
4508 fi
4509
4510 if test "$opengl" = "yes"; then
4511 cat > $TMPC << EOF
4512 #include <epoxy/egl.h>
4513 #ifndef EGL_MESA_image_dma_buf_export
4514 # error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
4515 #endif
4516 int main(void) { return 0; }
4517 EOF
4518 if compile_prog "" "" ; then
4519 opengl_dmabuf=yes
4520 fi
4521 fi
4522
4523 if test "$opengl" = "yes" && test "$have_x11" = "yes"; then
4524 for target in $target_list; do
4525 case $target in
4526 lm32-softmmu) # milkymist-tmu2 requires X11 and OpenGL
4527 need_x11=yes
4528 ;;
4529 esac
4530 done
4531 fi
4532
4533 ##########################################
4534 # libxml2 probe
4535 if test "$libxml2" != "no" ; then
4536 if $pkg_config --exists libxml-2.0; then
4537 libxml2="yes"
4538 libxml2_cflags=$($pkg_config --cflags libxml-2.0)
4539 libxml2_libs=$($pkg_config --libs libxml-2.0)
4540 else
4541 if test "$libxml2" = "yes"; then
4542 feature_not_found "libxml2" "Install libxml2 devel"
4543 fi
4544 libxml2="no"
4545 fi
4546 fi
4547
4548 ##########################################
4549 # glusterfs probe
4550 if test "$glusterfs" != "no" ; then
4551 if $pkg_config --atleast-version=3 glusterfs-api; then
4552 glusterfs="yes"
4553 glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
4554 glusterfs_libs=$($pkg_config --libs glusterfs-api)
4555 if $pkg_config --atleast-version=4 glusterfs-api; then
4556 glusterfs_xlator_opt="yes"
4557 fi
4558 if $pkg_config --atleast-version=5 glusterfs-api; then
4559 glusterfs_discard="yes"
4560 fi
4561 if $pkg_config --atleast-version=6 glusterfs-api; then
4562 glusterfs_fallocate="yes"
4563 glusterfs_zerofill="yes"
4564 fi
4565 cat > $TMPC << EOF
4566 #include <glusterfs/api/glfs.h>
4567
4568 int
4569 main(void)
4570 {
4571 /* new glfs_ftruncate() passes two additional args */
4572 return glfs_ftruncate(NULL, 0, NULL, NULL);
4573 }
4574 EOF
4575 if compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then
4576 glusterfs_ftruncate_has_stat="yes"
4577 fi
4578 cat > $TMPC << EOF
4579 #include <glusterfs/api/glfs.h>
4580
4581 /* new glfs_io_cbk() passes two additional glfs_stat structs */
4582 static void
4583 glusterfs_iocb(glfs_fd_t *fd, ssize_t ret, struct glfs_stat *prestat, struct glfs_stat *poststat, void *data)
4584 {}
4585
4586 int
4587 main(void)
4588 {
4589 glfs_io_cbk iocb = &glusterfs_iocb;
4590 iocb(NULL, 0 , NULL, NULL, NULL);
4591 return 0;
4592 }
4593 EOF
4594 if compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then
4595 glusterfs_iocb_has_stat="yes"
4596 fi
4597 else
4598 if test "$glusterfs" = "yes" ; then
4599 feature_not_found "GlusterFS backend support" \
4600 "Install glusterfs-api devel >= 3"
4601 fi
4602 glusterfs="no"
4603 fi
4604 fi
4605
4606 # Check for inotify functions when we are building linux-user
4607 # emulator. This is done because older glibc versions don't
4608 # have syscall stubs for these implemented. In that case we
4609 # don't provide them even if kernel supports them.
4610 #
4611 inotify=no
4612 cat > $TMPC << EOF
4613 #include <sys/inotify.h>
4614
4615 int
4616 main(void)
4617 {
4618 /* try to start inotify */
4619 return inotify_init();
4620 }
4621 EOF
4622 if compile_prog "" "" ; then
4623 inotify=yes
4624 fi
4625
4626 inotify1=no
4627 cat > $TMPC << EOF
4628 #include <sys/inotify.h>
4629
4630 int
4631 main(void)
4632 {
4633 /* try to start inotify */
4634 return inotify_init1(0);
4635 }
4636 EOF
4637 if compile_prog "" "" ; then
4638 inotify1=yes
4639 fi
4640
4641 # check if pipe2 is there
4642 pipe2=no
4643 cat > $TMPC << EOF
4644 #include <unistd.h>
4645 #include <fcntl.h>
4646
4647 int main(void)
4648 {
4649 int pipefd[2];
4650 return pipe2(pipefd, O_CLOEXEC);
4651 }
4652 EOF
4653 if compile_prog "" "" ; then
4654 pipe2=yes
4655 fi
4656
4657 # check if accept4 is there
4658 accept4=no
4659 cat > $TMPC << EOF
4660 #include <sys/socket.h>
4661 #include <stddef.h>
4662
4663 int main(void)
4664 {
4665 accept4(0, NULL, NULL, SOCK_CLOEXEC);
4666 return 0;
4667 }
4668 EOF
4669 if compile_prog "" "" ; then
4670 accept4=yes
4671 fi
4672
4673 # check if tee/splice is there. vmsplice was added same time.
4674 splice=no
4675 cat > $TMPC << EOF
4676 #include <unistd.h>
4677 #include <fcntl.h>
4678 #include <limits.h>
4679
4680 int main(void)
4681 {
4682 int len, fd = 0;
4683 len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
4684 splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
4685 return 0;
4686 }
4687 EOF
4688 if compile_prog "" "" ; then
4689 splice=yes
4690 fi
4691
4692 ##########################################
4693 # libnuma probe
4694
4695 if test "$numa" != "no" ; then
4696 cat > $TMPC << EOF
4697 #include <numa.h>
4698 int main(void) { return numa_available(); }
4699 EOF
4700
4701 if compile_prog "" "-lnuma" ; then
4702 numa=yes
4703 libs_softmmu="-lnuma $libs_softmmu"
4704 else
4705 if test "$numa" = "yes" ; then
4706 feature_not_found "numa" "install numactl devel"
4707 fi
4708 numa=no
4709 fi
4710 fi
4711
4712 if test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
4713 echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
4714 exit 1
4715 fi
4716
4717 # Even if malloc_trim() is available, these non-libc memory allocators
4718 # do not support it.
4719 if test "$tcmalloc" = "yes" || test "$jemalloc" = "yes" ; then
4720 if test "$malloc_trim" = "yes" ; then
4721 echo "Disabling malloc_trim with non-libc memory allocator"
4722 fi
4723 malloc_trim="no"
4724 fi
4725
4726 #######################################
4727 # malloc_trim
4728
4729 if test "$malloc_trim" != "no" ; then
4730 cat > $TMPC << EOF
4731 #include <malloc.h>
4732 int main(void) { malloc_trim(0); return 0; }
4733 EOF
4734 if compile_prog "" "" ; then
4735 malloc_trim="yes"
4736 else
4737 malloc_trim="no"
4738 fi
4739 fi
4740
4741 ##########################################
4742 # tcmalloc probe
4743
4744 if test "$tcmalloc" = "yes" ; then
4745 cat > $TMPC << EOF
4746 #include <stdlib.h>
4747 int main(void) {
4748 void *tmp = malloc(1);
4749 if (tmp != NULL) {
4750 return 0;
4751 }
4752 return 1;
4753 }
4754 EOF
4755
4756 if compile_prog "" "-ltcmalloc" ; then
4757 LIBS="-ltcmalloc $LIBS"
4758 else
4759 feature_not_found "tcmalloc" "install gperftools devel"
4760 fi
4761 fi
4762
4763 ##########################################
4764 # jemalloc probe
4765
4766 if test "$jemalloc" = "yes" ; then
4767 cat > $TMPC << EOF
4768 #include <stdlib.h>
4769 int main(void) {
4770 void *tmp = malloc(1);
4771 if (tmp != NULL) {
4772 return 0;
4773 }
4774 return 1;
4775 }
4776 EOF
4777
4778 if compile_prog "" "-ljemalloc" ; then
4779 LIBS="-ljemalloc $LIBS"
4780 else
4781 feature_not_found "jemalloc" "install jemalloc devel"
4782 fi
4783 fi
4784
4785 ##########################################
4786 # signalfd probe
4787 signalfd="no"
4788 cat > $TMPC << EOF
4789 #include <unistd.h>
4790 #include <sys/syscall.h>
4791 #include <signal.h>
4792 int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
4793 EOF
4794
4795 if compile_prog "" "" ; then
4796 signalfd=yes
4797 fi
4798
4799 # check if optreset global is declared by <getopt.h>
4800 optreset="no"
4801 cat > $TMPC << EOF
4802 #include <getopt.h>
4803 int main(void) { return optreset; }
4804 EOF
4805
4806 if compile_prog "" "" ; then
4807 optreset=yes
4808 fi
4809
4810 # check if eventfd is supported
4811 eventfd=no
4812 cat > $TMPC << EOF
4813 #include <sys/eventfd.h>
4814
4815 int main(void)
4816 {
4817 return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
4818 }
4819 EOF
4820 if compile_prog "" "" ; then
4821 eventfd=yes
4822 fi
4823
4824 # check if memfd is supported
4825 memfd=no
4826 cat > $TMPC << EOF
4827 #include <sys/mman.h>
4828
4829 int main(void)
4830 {
4831 return memfd_create("foo", MFD_ALLOW_SEALING);
4832 }
4833 EOF
4834 if compile_prog "" "" ; then
4835 memfd=yes
4836 fi
4837
4838 # check for usbfs
4839 have_usbfs=no
4840 if test "$linux_user" = "yes"; then
4841 cat > $TMPC << EOF
4842 #include <linux/usbdevice_fs.h>
4843
4844 #ifndef USBDEVFS_GET_CAPABILITIES
4845 #error "USBDEVFS_GET_CAPABILITIES undefined"
4846 #endif
4847
4848 #ifndef USBDEVFS_DISCONNECT_CLAIM
4849 #error "USBDEVFS_DISCONNECT_CLAIM undefined"
4850 #endif
4851
4852 int main(void)
4853 {
4854 return 0;
4855 }
4856 EOF
4857 if compile_prog "" ""; then
4858 have_usbfs=yes
4859 fi
4860 fi
4861
4862 # check for fallocate
4863 fallocate=no
4864 cat > $TMPC << EOF
4865 #include <fcntl.h>
4866
4867 int main(void)
4868 {
4869 fallocate(0, 0, 0, 0);
4870 return 0;
4871 }
4872 EOF
4873 if compile_prog "" "" ; then
4874 fallocate=yes
4875 fi
4876
4877 # check for fallocate hole punching
4878 fallocate_punch_hole=no
4879 cat > $TMPC << EOF
4880 #include <fcntl.h>
4881 #include <linux/falloc.h>
4882
4883 int main(void)
4884 {
4885 fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
4886 return 0;
4887 }
4888 EOF
4889 if compile_prog "" "" ; then
4890 fallocate_punch_hole=yes
4891 fi
4892
4893 # check that fallocate supports range zeroing inside the file
4894 fallocate_zero_range=no
4895 cat > $TMPC << EOF
4896 #include <fcntl.h>
4897 #include <linux/falloc.h>
4898
4899 int main(void)
4900 {
4901 fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
4902 return 0;
4903 }
4904 EOF
4905 if compile_prog "" "" ; then
4906 fallocate_zero_range=yes
4907 fi
4908
4909 # check for posix_fallocate
4910 posix_fallocate=no
4911 cat > $TMPC << EOF
4912 #include <fcntl.h>
4913
4914 int main(void)
4915 {
4916 posix_fallocate(0, 0, 0);
4917 return 0;
4918 }
4919 EOF
4920 if compile_prog "" "" ; then
4921 posix_fallocate=yes
4922 fi
4923
4924 # check for sync_file_range
4925 sync_file_range=no
4926 cat > $TMPC << EOF
4927 #include <fcntl.h>
4928
4929 int main(void)
4930 {
4931 sync_file_range(0, 0, 0, 0);
4932 return 0;
4933 }
4934 EOF
4935 if compile_prog "" "" ; then
4936 sync_file_range=yes
4937 fi
4938
4939 # check for linux/fiemap.h and FS_IOC_FIEMAP
4940 fiemap=no
4941 cat > $TMPC << EOF
4942 #include <sys/ioctl.h>
4943 #include <linux/fs.h>
4944 #include <linux/fiemap.h>
4945
4946 int main(void)
4947 {
4948 ioctl(0, FS_IOC_FIEMAP, 0);
4949 return 0;
4950 }
4951 EOF
4952 if compile_prog "" "" ; then
4953 fiemap=yes
4954 fi
4955
4956 # check for dup3
4957 dup3=no
4958 cat > $TMPC << EOF
4959 #include <unistd.h>
4960
4961 int main(void)
4962 {
4963 dup3(0, 0, 0);
4964 return 0;
4965 }
4966 EOF
4967 if compile_prog "" "" ; then
4968 dup3=yes
4969 fi
4970
4971 # check for ppoll support
4972 ppoll=no
4973 cat > $TMPC << EOF
4974 #include <poll.h>
4975
4976 int main(void)
4977 {
4978 struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
4979 ppoll(&pfd, 1, 0, 0);
4980 return 0;
4981 }
4982 EOF
4983 if compile_prog "" "" ; then
4984 ppoll=yes
4985 fi
4986
4987 # check for prctl(PR_SET_TIMERSLACK , ... ) support
4988 prctl_pr_set_timerslack=no
4989 cat > $TMPC << EOF
4990 #include <sys/prctl.h>
4991
4992 int main(void)
4993 {
4994 prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
4995 return 0;
4996 }
4997 EOF
4998 if compile_prog "" "" ; then
4999 prctl_pr_set_timerslack=yes
5000 fi
5001
5002 # check for epoll support
5003 epoll=no
5004 cat > $TMPC << EOF
5005 #include <sys/epoll.h>
5006
5007 int main(void)
5008 {
5009 epoll_create(0);
5010 return 0;
5011 }
5012 EOF
5013 if compile_prog "" "" ; then
5014 epoll=yes
5015 fi
5016
5017 # epoll_create1 is a later addition
5018 # so we must check separately for its presence
5019 epoll_create1=no
5020 cat > $TMPC << EOF
5021 #include <sys/epoll.h>
5022
5023 int main(void)
5024 {
5025 /* Note that we use epoll_create1 as a value, not as
5026 * a function being called. This is necessary so that on
5027 * old SPARC glibc versions where the function was present in
5028 * the library but not declared in the header file we will
5029 * fail the configure check. (Otherwise we will get a compiler
5030 * warning but not an error, and will proceed to fail the
5031 * qemu compile where we compile with -Werror.)
5032 */
5033 return (int)(uintptr_t)&epoll_create1;
5034 }
5035 EOF
5036 if compile_prog "" "" ; then
5037 epoll_create1=yes
5038 fi
5039
5040 # check for sendfile support
5041 sendfile=no
5042 cat > $TMPC << EOF
5043 #include <sys/sendfile.h>
5044
5045 int main(void)
5046 {
5047 return sendfile(0, 0, 0, 0);
5048 }
5049 EOF
5050 if compile_prog "" "" ; then
5051 sendfile=yes
5052 fi
5053
5054 # check for timerfd support (glibc 2.8 and newer)
5055 timerfd=no
5056 cat > $TMPC << EOF
5057 #include <sys/timerfd.h>
5058
5059 int main(void)
5060 {
5061 return(timerfd_create(CLOCK_REALTIME, 0));
5062 }
5063 EOF
5064 if compile_prog "" "" ; then
5065 timerfd=yes
5066 fi
5067
5068 # check for setns and unshare support
5069 setns=no
5070 cat > $TMPC << EOF
5071 #include <sched.h>
5072
5073 int main(void)
5074 {
5075 int ret;
5076 ret = setns(0, 0);
5077 ret = unshare(0);
5078 return ret;
5079 }
5080 EOF
5081 if compile_prog "" "" ; then
5082 setns=yes
5083 fi
5084
5085 # clock_adjtime probe
5086 clock_adjtime=no
5087 cat > $TMPC <<EOF
5088 #include <time.h>
5089
5090 int main(void)
5091 {
5092 return clock_adjtime(0, 0);
5093 }
5094 EOF
5095 clock_adjtime=no
5096 if compile_prog "" "" ; then
5097 clock_adjtime=yes
5098 fi
5099
5100 # syncfs probe
5101 syncfs=no
5102 cat > $TMPC <<EOF
5103 #include <unistd.h>
5104
5105 int main(void)
5106 {
5107 return syncfs(0);
5108 }
5109 EOF
5110 syncfs=no
5111 if compile_prog "" "" ; then
5112 syncfs=yes
5113 fi
5114
5115 # check for kcov support (kernel must be 4.4+, compiled with certain options)
5116 kcov=no
5117 if check_include sys/kcov.h ; then
5118 kcov=yes
5119 fi
5120
5121 # If we're making warnings fatal, apply this to Sphinx runs as well
5122 sphinx_werror=""
5123 if test "$werror" = "yes"; then
5124 sphinx_werror="-W"
5125 fi
5126
5127 # Check we have a new enough version of sphinx-build
5128 has_sphinx_build() {
5129 # This is a bit awkward but works: create a trivial document and
5130 # try to run it with our configuration file (which enforces a
5131 # version requirement). This will fail if either
5132 # sphinx-build doesn't exist at all or if it is too old.
5133 mkdir -p "$TMPDIR1/sphinx"
5134 touch "$TMPDIR1/sphinx/index.rst"
5135 "$sphinx_build" $sphinx_werror -c "$source_path/docs" \
5136 -b html "$TMPDIR1/sphinx" \
5137 "$TMPDIR1/sphinx/out" >> config.log 2>&1
5138 }
5139
5140 # Check if tools are available to build documentation.
5141 if test "$docs" != "no" ; then
5142 if has_sphinx_build; then
5143 sphinx_ok=yes
5144 else
5145 sphinx_ok=no
5146 fi
5147 if has makeinfo && has pod2man && test "$sphinx_ok" = "yes"; then
5148 docs=yes
5149 else
5150 if test "$docs" = "yes" ; then
5151 if has $sphinx_build && test "$sphinx_ok" != "yes"; then
5152 echo "Warning: $sphinx_build exists but it is either too old or uses too old a Python version" >&2
5153 fi
5154 feature_not_found "docs" "Install texinfo, Perl/perl-podlators and a Python 3 version of python-sphinx"
5155 fi
5156 docs=no
5157 fi
5158 fi
5159
5160 # Search for bswap_32 function
5161 byteswap_h=no
5162 cat > $TMPC << EOF
5163 #include <byteswap.h>
5164 int main(void) { return bswap_32(0); }
5165 EOF
5166 if compile_prog "" "" ; then
5167 byteswap_h=yes
5168 fi
5169
5170 # Search for bswap32 function
5171 bswap_h=no
5172 cat > $TMPC << EOF
5173 #include <sys/endian.h>
5174 #include <sys/types.h>
5175 #include <machine/bswap.h>
5176 int main(void) { return bswap32(0); }
5177 EOF
5178 if compile_prog "" "" ; then
5179 bswap_h=yes
5180 fi
5181
5182 ##########################################
5183 # Do we have libiscsi >= 1.9.0
5184 if test "$libiscsi" != "no" ; then
5185 if $pkg_config --atleast-version=1.9.0 libiscsi; then
5186 libiscsi="yes"
5187 libiscsi_cflags=$($pkg_config --cflags libiscsi)
5188 libiscsi_libs=$($pkg_config --libs libiscsi)
5189 else
5190 if test "$libiscsi" = "yes" ; then
5191 feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
5192 fi
5193 libiscsi="no"
5194 fi
5195 fi
5196
5197 ##########################################
5198 # Do we need libm
5199 cat > $TMPC << EOF
5200 #include <math.h>
5201 int main(int argc, char **argv) { return isnan(sin((double)argc)); }
5202 EOF
5203 if compile_prog "" "" ; then
5204 :
5205 elif compile_prog "" "-lm" ; then
5206 LIBS="-lm $LIBS"
5207 libs_qga="-lm $libs_qga"
5208 else
5209 error_exit "libm check failed"
5210 fi
5211
5212 ##########################################
5213 # Do we need librt
5214 # uClibc provides 2 versions of clock_gettime(), one with realtime
5215 # support and one without. This means that the clock_gettime() don't
5216 # need -lrt. We still need it for timer_create() so we check for this
5217 # function in addition.
5218 cat > $TMPC <<EOF
5219 #include <signal.h>
5220 #include <time.h>
5221 int main(void) {
5222 timer_create(CLOCK_REALTIME, NULL, NULL);
5223 return clock_gettime(CLOCK_REALTIME, NULL);
5224 }
5225 EOF
5226
5227 if compile_prog "" "" ; then
5228 :
5229 # we need pthread for static linking. use previous pthread test result
5230 elif compile_prog "" "$pthread_lib -lrt" ; then
5231 LIBS="$LIBS -lrt"
5232 libs_qga="$libs_qga -lrt"
5233 fi
5234
5235 # Check whether we need to link libutil for openpty()
5236 cat > $TMPC << EOF
5237 extern int openpty(int *am, int *as, char *name, void *termp, void *winp);
5238 int main(void) { return openpty(0, 0, 0, 0, 0); }
5239 EOF
5240
5241 have_openpty="no"
5242 if compile_prog "" "" ; then
5243 have_openpty="yes"
5244 else
5245 if compile_prog "" "-lutil" ; then
5246 libs_softmmu="-lutil $libs_softmmu"
5247 libs_tools="-lutil $libs_tools"
5248 have_openpty="yes"
5249 fi
5250 fi
5251
5252 ##########################################
5253 # spice probe
5254 if test "$spice" != "no" ; then
5255 cat > $TMPC << EOF
5256 #include <spice.h>
5257 int main(void) { spice_server_new(); return 0; }
5258 EOF
5259 spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
5260 spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
5261 if $pkg_config --atleast-version=0.12.5 spice-server && \
5262 $pkg_config --atleast-version=0.12.3 spice-protocol && \
5263 compile_prog "$spice_cflags" "$spice_libs" ; then
5264 spice="yes"
5265 libs_softmmu="$libs_softmmu $spice_libs"
5266 QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
5267 spice_protocol_version=$($pkg_config --modversion spice-protocol)
5268 spice_server_version=$($pkg_config --modversion spice-server)
5269 else
5270 if test "$spice" = "yes" ; then
5271 feature_not_found "spice" \
5272 "Install spice-server(>=0.12.5) and spice-protocol(>=0.12.3) devel"
5273 fi
5274 spice="no"
5275 fi
5276 fi
5277
5278 # check for smartcard support
5279 if test "$smartcard" != "no"; then
5280 if $pkg_config --atleast-version=2.5.1 libcacard; then
5281 libcacard_cflags=$($pkg_config --cflags libcacard)
5282 libcacard_libs=$($pkg_config --libs libcacard)
5283 smartcard="yes"
5284 else
5285 if test "$smartcard" = "yes"; then
5286 feature_not_found "smartcard" "Install libcacard devel"
5287 fi
5288 smartcard="no"
5289 fi
5290 fi
5291
5292 # check for libusb
5293 if test "$libusb" != "no" ; then
5294 if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
5295 libusb="yes"
5296 libusb_cflags=$($pkg_config --cflags libusb-1.0)
5297 libusb_libs=$($pkg_config --libs libusb-1.0)
5298 else
5299 if test "$libusb" = "yes"; then
5300 feature_not_found "libusb" "Install libusb devel >= 1.0.13"
5301 fi
5302 libusb="no"
5303 fi
5304 fi
5305
5306 # check for usbredirparser for usb network redirection support
5307 if test "$usb_redir" != "no" ; then
5308 if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
5309 usb_redir="yes"
5310 usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
5311 usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
5312 else
5313 if test "$usb_redir" = "yes"; then
5314 feature_not_found "usb-redir" "Install usbredir devel"
5315 fi
5316 usb_redir="no"
5317 fi
5318 fi
5319
5320 ##########################################
5321 # check if we have VSS SDK headers for win
5322
5323 if test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
5324 test "$vss_win32_sdk" != "no" ; then
5325 case "$vss_win32_sdk" in
5326 "") vss_win32_include="-isystem $source_path" ;;
5327 *\ *) # The SDK is installed in "Program Files" by default, but we cannot
5328 # handle path with spaces. So we symlink the headers into ".sdk/vss".
5329 vss_win32_include="-isystem $source_path/.sdk/vss"
5330 symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
5331 ;;
5332 *) vss_win32_include="-isystem $vss_win32_sdk"
5333 esac
5334 cat > $TMPC << EOF
5335 #define __MIDL_user_allocate_free_DEFINED__
5336 #include <inc/win2003/vss.h>
5337 int main(void) { return VSS_CTX_BACKUP; }
5338 EOF
5339 if compile_prog "$vss_win32_include" "" ; then
5340 guest_agent_with_vss="yes"
5341 QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
5342 libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
5343 qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
5344 else
5345 if test "$vss_win32_sdk" != "" ; then
5346 echo "ERROR: Please download and install Microsoft VSS SDK:"
5347 echo "ERROR: http://www.microsoft.com/en-us/download/details.aspx?id=23490"
5348 echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
5349 echo "ERROR: scripts/extract-vsssdk-headers setup.exe"
5350 echo "ERROR: The headers are extracted in the directory \`inc'."
5351 feature_not_found "VSS support"
5352 fi
5353 guest_agent_with_vss="no"
5354 fi
5355 fi
5356
5357 ##########################################
5358 # lookup Windows platform SDK (if not specified)
5359 # The SDK is needed only to build .tlb (type library) file of guest agent
5360 # VSS provider from the source. It is usually unnecessary because the
5361 # pre-compiled .tlb file is included.
5362
5363 if test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
5364 test "$guest_agent_with_vss" = "yes" ; then
5365 if test -z "$win_sdk"; then
5366 programfiles="$PROGRAMFILES"
5367 test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
5368 if test -n "$programfiles"; then
5369 win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
5370 else
5371 feature_not_found "Windows SDK"
5372 fi
5373 elif test "$win_sdk" = "no"; then
5374 win_sdk=""
5375 fi
5376 fi
5377
5378 ##########################################
5379 # check if mingw environment provides a recent ntddscsi.h
5380 if test "$mingw32" = "yes" && test "$guest_agent" != "no"; then
5381 cat > $TMPC << EOF
5382 #include <windows.h>
5383 #include <ntddscsi.h>
5384 int main(void) {
5385 #if !defined(IOCTL_SCSI_GET_ADDRESS)
5386 #error Missing required ioctl definitions
5387 #endif
5388 SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
5389 return addr.Lun;
5390 }
5391 EOF
5392 if compile_prog "" "" ; then
5393 guest_agent_ntddscsi=yes
5394 libs_qga="-lsetupapi -lcfgmgr32 $libs_qga"
5395 fi
5396 fi
5397
5398 ##########################################
5399 # virgl renderer probe
5400
5401 if test "$virglrenderer" != "no" ; then
5402 cat > $TMPC << EOF
5403 #include <virglrenderer.h>
5404 int main(void) { virgl_renderer_poll(); return 0; }
5405 EOF
5406 virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
5407 virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
5408 virgl_version=$($pkg_config --modversion virglrenderer 2>/dev/null)
5409 if $pkg_config virglrenderer >/dev/null 2>&1 && \
5410 compile_prog "$virgl_cflags" "$virgl_libs" ; then
5411 virglrenderer="yes"
5412 else
5413 if test "$virglrenderer" = "yes" ; then
5414 feature_not_found "virglrenderer"
5415 fi
5416 virglrenderer="no"
5417 fi
5418 fi
5419
5420 ##########################################
5421 # capstone
5422
5423 case "$capstone" in
5424 "" | yes)
5425 if $pkg_config capstone; then
5426 capstone=system
5427 elif test -e "${source_path}/.git" && test $git_update = 'yes' ; then
5428 capstone=git
5429 elif test -e "${source_path}/capstone/Makefile" ; then
5430 capstone=internal
5431 elif test -z "$capstone" ; then
5432 capstone=no
5433 else
5434 feature_not_found "capstone" "Install capstone devel or git submodule"
5435 fi
5436 ;;
5437
5438 system)
5439 if ! $pkg_config capstone; then
5440 feature_not_found "capstone" "Install capstone devel"
5441 fi
5442 ;;
5443 esac
5444
5445 case "$capstone" in
5446 git | internal)
5447 if test "$capstone" = git; then
5448 git_submodules="${git_submodules} capstone"
5449 fi
5450 mkdir -p capstone
5451 QEMU_CFLAGS="$QEMU_CFLAGS -I${source_path}/capstone/include"
5452 if test "$mingw32" = "yes"; then
5453 LIBCAPSTONE=capstone.lib
5454 else
5455 LIBCAPSTONE=libcapstone.a
5456 fi
5457 libs_cpu="-L$PWD/capstone -lcapstone $libs_cpu"
5458 ;;
5459
5460 system)
5461 QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags capstone)"
5462 libs_cpu="$($pkg_config --libs capstone) $libs_cpu"
5463 ;;
5464
5465 no)
5466 ;;
5467 *)
5468 error_exit "Unknown state for capstone: $capstone"
5469 ;;
5470 esac
5471
5472 ##########################################
5473 # check if we have fdatasync
5474
5475 fdatasync=no
5476 cat > $TMPC << EOF
5477 #include <unistd.h>
5478 int main(void) {
5479 #if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
5480 return fdatasync(0);
5481 #else
5482 #error Not supported
5483 #endif
5484 }
5485 EOF
5486 if compile_prog "" "" ; then
5487 fdatasync=yes
5488 fi
5489
5490 ##########################################
5491 # check if we have madvise
5492
5493 madvise=no
5494 cat > $TMPC << EOF
5495 #include <sys/types.h>
5496 #include <sys/mman.h>
5497 #include <stddef.h>
5498 int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
5499 EOF
5500 if compile_prog "" "" ; then
5501 madvise=yes
5502 fi
5503
5504 ##########################################
5505 # check if we have posix_madvise
5506
5507 posix_madvise=no
5508 cat > $TMPC << EOF
5509 #include <sys/mman.h>
5510 #include <stddef.h>
5511 int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
5512 EOF
5513 if compile_prog "" "" ; then
5514 posix_madvise=yes
5515 fi
5516
5517 ##########################################
5518 # check if we have posix_memalign()
5519
5520 posix_memalign=no
5521 cat > $TMPC << EOF
5522 #include <stdlib.h>
5523 int main(void) {
5524 void *p;
5525 return posix_memalign(&p, 8, 8);
5526 }
5527 EOF
5528 if compile_prog "" "" ; then
5529 posix_memalign=yes
5530 fi
5531
5532 ##########################################
5533 # check if we have posix_syslog
5534
5535 posix_syslog=no
5536 cat > $TMPC << EOF
5537 #include <syslog.h>
5538 int main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
5539 EOF
5540 if compile_prog "" "" ; then
5541 posix_syslog=yes
5542 fi
5543
5544 ##########################################
5545 # check if we have sem_timedwait
5546
5547 sem_timedwait=no
5548 cat > $TMPC << EOF
5549 #include <semaphore.h>
5550 int main(void) { sem_t s; struct timespec t = {0}; return sem_timedwait(&s, &t); }
5551 EOF
5552 if compile_prog "" "" ; then
5553 sem_timedwait=yes
5554 fi
5555
5556 ##########################################
5557 # check if we have strchrnul
5558
5559 strchrnul=no
5560 cat > $TMPC << EOF
5561 #include <string.h>
5562 int main(void);
5563 // Use a haystack that the compiler shouldn't be able to constant fold
5564 char *haystack = (char*)&main;
5565 int main(void) { return strchrnul(haystack, 'x') != &haystack[6]; }
5566 EOF
5567 if compile_prog "" "" ; then
5568 strchrnul=yes
5569 fi
5570
5571 #########################################
5572 # check if we have st_atim
5573
5574 st_atim=no
5575 cat > $TMPC << EOF
5576 #include <sys/stat.h>
5577 #include <stddef.h>
5578 int main(void) { return offsetof(struct stat, st_atim); }
5579 EOF
5580 if compile_prog "" "" ; then
5581 st_atim=yes
5582 fi
5583
5584 ##########################################
5585 # check if trace backend exists
5586
5587 $python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends > /dev/null 2> /dev/null
5588 if test "$?" -ne 0 ; then
5589 error_exit "invalid trace backends" \
5590 "Please choose supported trace backends."
5591 fi
5592
5593 ##########################################
5594 # For 'ust' backend, test if ust headers are present
5595 if have_backend "ust"; then
5596 cat > $TMPC << EOF
5597 #include <lttng/tracepoint.h>
5598 int main(void) { return 0; }
5599 EOF
5600 if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
5601 if $pkg_config lttng-ust --exists; then
5602 lttng_ust_libs=$($pkg_config --libs lttng-ust)
5603 else
5604 lttng_ust_libs="-llttng-ust -ldl"
5605 fi
5606 if $pkg_config liburcu-bp --exists; then
5607 urcu_bp_libs=$($pkg_config --libs liburcu-bp)
5608 else
5609 urcu_bp_libs="-lurcu-bp"
5610 fi
5611
5612 LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
5613 libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
5614 else
5615 error_exit "Trace backend 'ust' missing lttng-ust header files"
5616 fi
5617 fi
5618
5619 ##########################################
5620 # For 'dtrace' backend, test if 'dtrace' command is present
5621 if have_backend "dtrace"; then
5622 if ! has 'dtrace' ; then
5623 error_exit "dtrace command is not found in PATH $PATH"
5624 fi
5625 trace_backend_stap="no"
5626 if has 'stap' ; then
5627 trace_backend_stap="yes"
5628 fi
5629 fi
5630
5631 ##########################################
5632 # check and set a backend for coroutine
5633
5634 # We prefer ucontext, but it's not always possible. The fallback
5635 # is sigcontext. On Windows the only valid backend is the Windows
5636 # specific one.
5637
5638 ucontext_works=no
5639 if test "$darwin" != "yes"; then
5640 cat > $TMPC << EOF
5641 #include <ucontext.h>
5642 #ifdef __stub_makecontext
5643 #error Ignoring glibc stub makecontext which will always fail
5644 #endif
5645 int main(void) { makecontext(0, 0, 0); return 0; }
5646 EOF
5647 if compile_prog "" "" ; then
5648 ucontext_works=yes
5649 fi
5650 fi
5651
5652 if test "$coroutine" = ""; then
5653 if test "$mingw32" = "yes"; then
5654 coroutine=win32
5655 elif test "$ucontext_works" = "yes"; then
5656 coroutine=ucontext
5657 else
5658 coroutine=sigaltstack
5659 fi
5660 else
5661 case $coroutine in
5662 windows)
5663 if test "$mingw32" != "yes"; then
5664 error_exit "'windows' coroutine backend only valid for Windows"
5665 fi
5666 # Unfortunately the user visible backend name doesn't match the
5667 # coroutine-*.c filename for this case, so we have to adjust it here.
5668 coroutine=win32
5669 ;;
5670 ucontext)
5671 if test "$ucontext_works" != "yes"; then
5672 feature_not_found "ucontext"
5673 fi
5674 ;;
5675 sigaltstack)
5676 if test "$mingw32" = "yes"; then
5677 error_exit "only the 'windows' coroutine backend is valid for Windows"
5678 fi
5679 ;;
5680 *)
5681 error_exit "unknown coroutine backend $coroutine"
5682 ;;
5683 esac
5684 fi
5685
5686 if test "$coroutine_pool" = ""; then
5687 coroutine_pool=yes
5688 fi
5689
5690 if test "$debug_stack_usage" = "yes"; then
5691 if test "$coroutine_pool" = "yes"; then
5692 echo "WARN: disabling coroutine pool for stack usage debugging"
5693 coroutine_pool=no
5694 fi
5695 fi
5696
5697 ##################################################
5698 # SafeStack
5699
5700
5701 if test "$safe_stack" = "yes"; then
5702 cat > $TMPC << EOF
5703 int main(int argc, char *argv[])
5704 {
5705 #if ! __has_feature(safe_stack)
5706 #error SafeStack Disabled
5707 #endif
5708 return 0;
5709 }
5710 EOF
5711 flag="-fsanitize=safe-stack"
5712 # Check that safe-stack is supported and enabled.
5713 if compile_prog "-Werror $flag" "$flag"; then
5714 # Flag needed both at compilation and at linking
5715 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
5716 QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
5717 else
5718 error_exit "SafeStack not supported by your compiler"
5719 fi
5720 if test "$coroutine" != "ucontext"; then
5721 error_exit "SafeStack is only supported by the coroutine backend ucontext"
5722 fi
5723 else
5724 cat > $TMPC << EOF
5725 int main(int argc, char *argv[])
5726 {
5727 #if defined(__has_feature)
5728 #if __has_feature(safe_stack)
5729 #error SafeStack Enabled
5730 #endif
5731 #endif
5732 return 0;
5733 }
5734 EOF
5735 if test "$safe_stack" = "no"; then
5736 # Make sure that safe-stack is disabled
5737 if ! compile_prog "-Werror" ""; then
5738 # SafeStack was already enabled, try to explicitly remove the feature
5739 flag="-fno-sanitize=safe-stack"
5740 if ! compile_prog "-Werror $flag" "$flag"; then
5741 error_exit "Configure cannot disable SafeStack"
5742 fi
5743 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
5744 QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
5745 fi
5746 else # "$safe_stack" = ""
5747 # Set safe_stack to yes or no based on pre-existing flags
5748 if compile_prog "-Werror" ""; then
5749 safe_stack="no"
5750 else
5751 safe_stack="yes"
5752 if test "$coroutine" != "ucontext"; then
5753 error_exit "SafeStack is only supported by the coroutine backend ucontext"
5754 fi
5755 fi
5756 fi
5757 fi
5758
5759 ##########################################
5760 # check if we have open_by_handle_at
5761
5762 open_by_handle_at=no
5763 cat > $TMPC << EOF
5764 #include <fcntl.h>
5765 #if !defined(AT_EMPTY_PATH)
5766 # error missing definition
5767 #else
5768 int main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
5769 #endif
5770 EOF
5771 if compile_prog "" "" ; then
5772 open_by_handle_at=yes
5773 fi
5774
5775 ########################################
5776 # check if we have linux/magic.h
5777
5778 linux_magic_h=no
5779 cat > $TMPC << EOF
5780 #include <linux/magic.h>
5781 int main(void) {
5782 return 0;
5783 }
5784 EOF
5785 if compile_prog "" "" ; then
5786 linux_magic_h=yes
5787 fi
5788
5789 ########################################
5790 # check if we have valgrind/valgrind.h
5791
5792 valgrind_h=no
5793 cat > $TMPC << EOF
5794 #include <valgrind/valgrind.h>
5795 int main(void) {
5796 return 0;
5797 }
5798 EOF
5799 if compile_prog "" "" ; then
5800 valgrind_h=yes
5801 fi
5802
5803 ########################################
5804 # check if environ is declared
5805
5806 has_environ=no
5807 cat > $TMPC << EOF
5808 #include <unistd.h>
5809 int main(void) {
5810 environ = 0;
5811 return 0;
5812 }
5813 EOF
5814 if compile_prog "" "" ; then
5815 has_environ=yes
5816 fi
5817
5818 ########################################
5819 # check if cpuid.h is usable.
5820
5821 cat > $TMPC << EOF
5822 #include <cpuid.h>
5823 int main(void) {
5824 unsigned a, b, c, d;
5825 int max = __get_cpuid_max(0, 0);
5826
5827 if (max >= 1) {
5828 __cpuid(1, a, b, c, d);
5829 }
5830
5831 if (max >= 7) {
5832 __cpuid_count(7, 0, a, b, c, d);
5833 }
5834
5835 return 0;
5836 }
5837 EOF
5838 if compile_prog "" "" ; then
5839 cpuid_h=yes
5840 fi
5841
5842 ##########################################
5843 # avx2 optimization requirement check
5844 #
5845 # There is no point enabling this if cpuid.h is not usable,
5846 # since we won't be able to select the new routines.
5847
5848 if test "$cpuid_h" = "yes" && test "$avx2_opt" != "no"; then
5849 cat > $TMPC << EOF
5850 #pragma GCC push_options
5851 #pragma GCC target("avx2")
5852 #include <cpuid.h>
5853 #include <immintrin.h>
5854 static int bar(void *a) {
5855 __m256i x = *(__m256i *)a;
5856 return _mm256_testz_si256(x, x);
5857 }
5858 int main(int argc, char *argv[]) { return bar(argv[0]); }
5859 EOF
5860 if compile_object "" ; then
5861 avx2_opt="yes"
5862 else
5863 avx2_opt="no"
5864 fi
5865 fi
5866
5867 ##########################################
5868 # avx512f optimization requirement check
5869 #
5870 # There is no point enabling this if cpuid.h is not usable,
5871 # since we won't be able to select the new routines.
5872 # by default, it is turned off.
5873 # if user explicitly want to enable it, check environment
5874
5875 if test "$cpuid_h" = "yes" && test "$avx512f_opt" = "yes"; then
5876 cat > $TMPC << EOF
5877 #pragma GCC push_options
5878 #pragma GCC target("avx512f")
5879 #include <cpuid.h>
5880 #include <immintrin.h>
5881 static int bar(void *a) {
5882 __m512i x = *(__m512i *)a;
5883 return _mm512_test_epi64_mask(x, x);
5884 }
5885 int main(int argc, char *argv[])
5886 {
5887 return bar(argv[0]);
5888 }
5889 EOF
5890 if ! compile_object "" ; then
5891 avx512f_opt="no"
5892 fi
5893 else
5894 avx512f_opt="no"
5895 fi
5896
5897 ########################################
5898 # check if __[u]int128_t is usable.
5899
5900 int128=no
5901 cat > $TMPC << EOF
5902 __int128_t a;
5903 __uint128_t b;
5904 int main (void) {
5905 a = a + b;
5906 b = a * b;
5907 a = a * a;
5908 return 0;
5909 }
5910 EOF
5911 if compile_prog "" "" ; then
5912 int128=yes
5913 fi
5914
5915 #########################################
5916 # See if 128-bit atomic operations are supported.
5917
5918 atomic128=no
5919 if test "$int128" = "yes"; then
5920 cat > $TMPC << EOF
5921 int main(void)
5922 {
5923 unsigned __int128 x = 0, y = 0;
5924 y = __atomic_load_16(&x, 0);
5925 __atomic_store_16(&x, y, 0);
5926 __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
5927 return 0;
5928 }
5929 EOF
5930 if compile_prog "" "" ; then
5931 atomic128=yes
5932 fi
5933 fi
5934
5935 cmpxchg128=no
5936 if test "$int128" = yes && test "$atomic128" = no; then
5937 cat > $TMPC << EOF
5938 int main(void)
5939 {
5940 unsigned __int128 x = 0, y = 0;
5941 __sync_val_compare_and_swap_16(&x, y, x);
5942 return 0;
5943 }
5944 EOF
5945 if compile_prog "" "" ; then
5946 cmpxchg128=yes
5947 fi
5948 fi
5949
5950 #########################################
5951 # See if 64-bit atomic operations are supported.
5952 # Note that without __atomic builtins, we can only
5953 # assume atomic loads/stores max at pointer size.
5954
5955 cat > $TMPC << EOF
5956 #include <stdint.h>
5957 int main(void)
5958 {
5959 uint64_t x = 0, y = 0;
5960 #ifdef __ATOMIC_RELAXED
5961 y = __atomic_load_8(&x, 0);
5962 __atomic_store_8(&x, y, 0);
5963 __atomic_compare_exchange_8(&x, &y, x, 0, 0, 0);
5964 __atomic_exchange_8(&x, y, 0);
5965 __atomic_fetch_add_8(&x, y, 0);
5966 #else
5967 typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
5968 __sync_lock_test_and_set(&x, y);
5969 __sync_val_compare_and_swap(&x, y, 0);
5970 __sync_fetch_and_add(&x, y);
5971 #endif
5972 return 0;
5973 }
5974 EOF
5975 if compile_prog "" "" ; then
5976 atomic64=yes
5977 fi
5978
5979 #########################################
5980 # See if --dynamic-list is supported by the linker
5981 ld_dynamic_list="no"
5982 if test "$static" = "no" ; then
5983 cat > $TMPTXT <<EOF
5984 {
5985 foo;
5986 };
5987 EOF
5988
5989 cat > $TMPC <<EOF
5990 #include <stdio.h>
5991 void foo(void);
5992
5993 void foo(void)
5994 {
5995 printf("foo\n");
5996 }
5997
5998 int main(void)
5999 {
6000 foo();
6001 return 0;
6002 }
6003 EOF
6004
6005 if compile_prog "" "-Wl,--dynamic-list=$TMPTXT" ; then
6006 ld_dynamic_list="yes"
6007 fi
6008 fi
6009
6010 #########################################
6011 # See if -exported_symbols_list is supported by the linker
6012
6013 ld_exported_symbols_list="no"
6014 if test "$static" = "no" ; then
6015 cat > $TMPTXT <<EOF
6016 _foo
6017 EOF
6018
6019 if compile_prog "" "-Wl,-exported_symbols_list,$TMPTXT" ; then
6020 ld_exported_symbols_list="yes"
6021 fi
6022 fi
6023
6024 if test "$plugins" = "yes" &&
6025 test "$ld_dynamic_list" = "no" &&
6026 test "$ld_exported_symbols_list" = "no" ; then
6027 error_exit \
6028 "Plugin support requires dynamic linking and specifying a set of symbols " \
6029 "that are exported to plugins. Unfortunately your linker doesn't " \
6030 "support the flag (--dynamic-list or -exported_symbols_list) used " \
6031 "for this purpose. You can't build with --static."
6032 fi
6033
6034 ########################################
6035 # See if __attribute__((alias)) is supported.
6036 # This false for Xcode 9, but has been remedied for Xcode 10.
6037 # Unfortunately, travis uses Xcode 9 by default.
6038
6039 attralias=no
6040 cat > $TMPC << EOF
6041 int x = 1;
6042 extern const int y __attribute__((alias("x")));
6043 int main(void) { return 0; }
6044 EOF
6045 if compile_prog "" "" ; then
6046 attralias=yes
6047 fi
6048
6049 ########################################
6050 # check if getauxval is available.
6051
6052 getauxval=no
6053 cat > $TMPC << EOF
6054 #include <sys/auxv.h>
6055 int main(void) {
6056 return getauxval(AT_HWCAP) == 0;
6057 }
6058 EOF
6059 if compile_prog "" "" ; then
6060 getauxval=yes
6061 fi
6062
6063 ########################################
6064 # check if ccache is interfering with
6065 # semantic analysis of macros
6066
6067 unset CCACHE_CPP2
6068 ccache_cpp2=no
6069 cat > $TMPC << EOF
6070 static const int Z = 1;
6071 #define fn() ({ Z; })
6072 #define TAUT(X) ((X) == Z)
6073 #define PAREN(X, Y) (X == Y)
6074 #define ID(X) (X)
6075 int main(int argc, char *argv[])
6076 {
6077 int x = 0, y = 0;
6078 x = ID(x);
6079 x = fn();
6080 fn();
6081 if (PAREN(x, y)) return 0;
6082 if (TAUT(Z)) return 0;
6083 return 0;
6084 }
6085 EOF
6086
6087 if ! compile_object "-Werror"; then
6088 ccache_cpp2=yes
6089 fi
6090
6091 #################################################
6092 # clang does not support glibc + FORTIFY_SOURCE.
6093
6094 if test "$fortify_source" != "no"; then
6095 if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
6096 fortify_source="no";
6097 elif test -n "$cxx" && has $cxx &&
6098 echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
6099 fortify_source="no";
6100 else
6101 fortify_source="yes"
6102 fi
6103 fi
6104
6105 ###############################################
6106 # Check if copy_file_range is provided by glibc
6107 have_copy_file_range=no
6108 cat > $TMPC << EOF
6109 #include <unistd.h>
6110 int main(void) {
6111 copy_file_range(0, NULL, 0, NULL, 0, 0);
6112 return 0;
6113 }
6114 EOF
6115 if compile_prog "" "" ; then
6116 have_copy_file_range=yes
6117 fi
6118
6119 ##########################################
6120 # check if struct fsxattr is available via linux/fs.h
6121
6122 have_fsxattr=no
6123 cat > $TMPC << EOF
6124 #include <linux/fs.h>
6125 struct fsxattr foo;
6126 int main(void) {
6127 return 0;
6128 }
6129 EOF
6130 if compile_prog "" "" ; then
6131 have_fsxattr=yes
6132 fi
6133
6134 ##########################################
6135 # check for usable membarrier system call
6136 if test "$membarrier" = "yes"; then
6137 have_membarrier=no
6138 if test "$mingw32" = "yes" ; then
6139 have_membarrier=yes
6140 elif test "$linux" = "yes" ; then
6141 cat > $TMPC << EOF
6142 #include <linux/membarrier.h>
6143 #include <sys/syscall.h>
6144 #include <unistd.h>
6145 #include <stdlib.h>
6146 int main(void) {
6147 syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
6148 syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0);
6149 exit(0);
6150 }
6151 EOF
6152 if compile_prog "" "" ; then
6153 have_membarrier=yes
6154 fi
6155 fi
6156 if test "$have_membarrier" = "no"; then
6157 feature_not_found "membarrier" "membarrier system call not available"
6158 fi
6159 else
6160 # Do not enable it by default even for Mingw32, because it doesn't
6161 # work on Wine.
6162 membarrier=no
6163 fi
6164
6165 ##########################################
6166 # check if rtnetlink.h exists and is useful
6167 have_rtnetlink=no
6168 cat > $TMPC << EOF
6169 #include <linux/rtnetlink.h>
6170 int main(void) {
6171 return IFLA_PROTO_DOWN;
6172 }
6173 EOF
6174 if compile_prog "" "" ; then
6175 have_rtnetlink=yes
6176 fi
6177
6178 ##########################################
6179 # check for usable AF_VSOCK environment
6180 have_af_vsock=no
6181 cat > $TMPC << EOF
6182 #include <errno.h>
6183 #include <sys/types.h>
6184 #include <sys/socket.h>
6185 #if !defined(AF_VSOCK)
6186 # error missing AF_VSOCK flag
6187 #endif
6188 #include <linux/vm_sockets.h>
6189 int main(void) {
6190 int sock, ret;
6191 struct sockaddr_vm svm;
6192 socklen_t len = sizeof(svm);
6193 sock = socket(AF_VSOCK, SOCK_STREAM, 0);
6194 ret = getpeername(sock, (struct sockaddr *)&svm, &len);
6195 if ((ret == -1) && (errno == ENOTCONN)) {
6196 return 0;
6197 }
6198 return -1;
6199 }
6200 EOF
6201 if compile_prog "" "" ; then
6202 have_af_vsock=yes
6203 fi
6204
6205 ##########################################
6206 # check for usable AF_ALG environment
6207 have_afalg=no
6208 cat > $TMPC << EOF
6209 #include <errno.h>
6210 #include <sys/types.h>
6211 #include <sys/socket.h>
6212 #include <linux/if_alg.h>
6213 int main(void) {
6214 int sock;
6215 sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
6216 return sock;
6217 }
6218 EOF
6219 if compile_prog "" "" ; then
6220 have_afalg=yes
6221 fi
6222 if test "$crypto_afalg" = "yes"
6223 then
6224 if test "$have_afalg" != "yes"
6225 then
6226 error_exit "AF_ALG requested but could not be detected"
6227 fi
6228 fi
6229
6230
6231 #################################################
6232 # Check to see if we have the Hypervisor framework
6233 if [ "$darwin" = "yes" ] ; then
6234 cat > $TMPC << EOF
6235 #include <Hypervisor/hv.h>
6236 int main() { return 0;}
6237 EOF
6238 if ! compile_object ""; then
6239 hvf='no'
6240 else
6241 hvf='yes'
6242 QEMU_LDFLAGS="-framework Hypervisor $QEMU_LDFLAGS"
6243 fi
6244 fi
6245
6246 #################################################
6247 # Sparc implicitly links with --relax, which is
6248 # incompatible with -r, so --no-relax should be
6249 # given. It does no harm to give it on other
6250 # platforms too.
6251
6252 # Note: the prototype is needed since QEMU_CFLAGS
6253 # contains -Wmissing-prototypes
6254 cat > $TMPC << EOF
6255 extern int foo(void);
6256 int foo(void) { return 0; }
6257 EOF
6258 if ! compile_object ""; then
6259 error_exit "Failed to compile object file for LD_REL_FLAGS test"
6260 fi
6261 for i in '-Wl,-r -Wl,--no-relax' -Wl,-r -r; do
6262 if do_cc -nostdlib $i -o $TMPMO $TMPO; then
6263 LD_REL_FLAGS=$i
6264 break
6265 fi
6266 done
6267 if test "$modules" = "yes" && test "$LD_REL_FLAGS" = ""; then
6268 feature_not_found "modules" "Cannot find how to build relocatable objects"
6269 fi
6270
6271 ##########################################
6272 # check for sysmacros.h
6273
6274 have_sysmacros=no
6275 cat > $TMPC << EOF
6276 #include <sys/sysmacros.h>
6277 int main(void) {
6278 return makedev(0, 0);
6279 }
6280 EOF
6281 if compile_prog "" "" ; then
6282 have_sysmacros=yes
6283 fi
6284
6285 ##########################################
6286 # check for _Static_assert()
6287
6288 have_static_assert=no
6289 cat > $TMPC << EOF
6290 _Static_assert(1, "success");
6291 int main(void) {
6292 return 0;
6293 }
6294 EOF
6295 if compile_prog "" "" ; then
6296 have_static_assert=yes
6297 fi
6298
6299 ##########################################
6300 # check for utmpx.h, it is missing e.g. on OpenBSD
6301
6302 have_utmpx=no
6303 cat > $TMPC << EOF
6304 #include <utmpx.h>
6305 struct utmpx user_info;
6306 int main(void) {
6307 return 0;
6308 }
6309 EOF
6310 if compile_prog "" "" ; then
6311 have_utmpx=yes
6312 fi
6313
6314 ##########################################
6315 # check for getrandom()
6316
6317 have_getrandom=no
6318 cat > $TMPC << EOF
6319 #include <sys/random.h>
6320 int main(void) {
6321 return getrandom(0, 0, GRND_NONBLOCK);
6322 }
6323 EOF
6324 if compile_prog "" "" ; then
6325 have_getrandom=yes
6326 fi
6327
6328 ##########################################
6329 # checks for sanitizers
6330
6331 have_asan=no
6332 have_ubsan=no
6333 have_asan_iface_h=no
6334 have_asan_iface_fiber=no
6335
6336 if test "$sanitizers" = "yes" ; then
6337 write_c_skeleton
6338 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
6339 have_asan=yes
6340 fi
6341
6342 # we could use a simple skeleton for flags checks, but this also
6343 # detect the static linking issue of ubsan, see also:
6344 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
6345 cat > $TMPC << EOF
6346 #include <stdlib.h>
6347 int main(void) {
6348 void *tmp = malloc(10);
6349 if (tmp != NULL) {
6350 return *(int *)(tmp + 2);
6351 }
6352 return 1;
6353 }
6354 EOF
6355 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
6356 have_ubsan=yes
6357 fi
6358
6359 if check_include "sanitizer/asan_interface.h" ; then
6360 have_asan_iface_h=yes
6361 fi
6362
6363 cat > $TMPC << EOF
6364 #include <sanitizer/asan_interface.h>
6365 int main(void) {
6366 __sanitizer_start_switch_fiber(0, 0, 0);
6367 return 0;
6368 }
6369 EOF
6370 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
6371 have_asan_iface_fiber=yes
6372 fi
6373 fi
6374
6375 ##########################################
6376 # checks for fuzzer
6377 if test "$fuzzing" = "yes" ; then
6378 write_c_fuzzer_skeleton
6379 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=fuzzer" ""; then
6380 have_fuzzer=yes
6381 fi
6382 fi
6383
6384 # Thread sanitizer is, for now, much noisier than the other sanitizers;
6385 # keep it separate until that is not the case.
6386 if test "$tsan" = "yes" && test "$sanitizers" = "yes"; then
6387 error_exit "TSAN is not supported with other sanitiziers."
6388 fi
6389 have_tsan=no
6390 have_tsan_iface_fiber=no
6391 if test "$tsan" = "yes" ; then
6392 write_c_skeleton
6393 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
6394 have_tsan=yes
6395 fi
6396 cat > $TMPC << EOF
6397 #include <sanitizer/tsan_interface.h>
6398 int main(void) {
6399 __tsan_create_fiber(0);
6400 return 0;
6401 }
6402 EOF
6403 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
6404 have_tsan_iface_fiber=yes
6405 fi
6406 fi
6407
6408 ##########################################
6409 # check for libpmem
6410
6411 if test "$libpmem" != "no"; then
6412 if $pkg_config --exists "libpmem"; then
6413 libpmem="yes"
6414 libpmem_libs=$($pkg_config --libs libpmem)
6415 libpmem_cflags=$($pkg_config --cflags libpmem)
6416 libs_softmmu="$libs_softmmu $libpmem_libs"
6417 QEMU_CFLAGS="$QEMU_CFLAGS $libpmem_cflags"
6418 else
6419 if test "$libpmem" = "yes" ; then
6420 feature_not_found "libpmem" "Install nvml or pmdk"
6421 fi
6422 libpmem="no"
6423 fi
6424 fi
6425
6426 ##########################################
6427 # check for libdaxctl
6428
6429 if test "$libdaxctl" != "no"; then
6430 if $pkg_config --atleast-version=57 "libdaxctl"; then
6431 libdaxctl="yes"
6432 libdaxctl_libs=$($pkg_config --libs libdaxctl)
6433 libdaxctl_cflags=$($pkg_config --cflags libdaxctl)
6434 libs_softmmu="$libs_softmmu $libdaxctl_libs"
6435 QEMU_CFLAGS="$QEMU_CFLAGS $libdaxctl_cflags"
6436 else
6437 if test "$libdaxctl" = "yes" ; then
6438 feature_not_found "libdaxctl" "Install libdaxctl"
6439 fi
6440 libdaxctl="no"
6441 fi
6442 fi
6443
6444 ##########################################
6445 # check for slirp
6446
6447 # slirp is only required when building softmmu targets
6448 if test -z "$slirp" -a "$softmmu" != "yes" ; then
6449 slirp="no"
6450 fi
6451
6452 case "$slirp" in
6453 "" | yes)
6454 if $pkg_config slirp; then
6455 slirp=system
6456 elif test -e "${source_path}/.git" && test $git_update = 'yes' ; then
6457 slirp=git
6458 elif test -e "${source_path}/slirp/Makefile" ; then
6459 slirp=internal
6460 elif test -z "$slirp" ; then
6461 slirp=no
6462 else
6463 feature_not_found "slirp" "Install slirp devel or git submodule"
6464 fi
6465 ;;
6466
6467 system)
6468 if ! $pkg_config slirp; then
6469 feature_not_found "slirp" "Install slirp devel"
6470 fi
6471 ;;
6472 esac
6473
6474 case "$slirp" in
6475 git | internal)
6476 if test "$slirp" = git; then
6477 git_submodules="${git_submodules} slirp"
6478 fi
6479 mkdir -p slirp
6480 slirp_cflags="-I${source_path}/slirp/src -I$PWD/slirp/src"
6481 slirp_libs="-L$PWD/slirp -lslirp"
6482 if test "$mingw32" = "yes" ; then
6483 slirp_libs="$slirp_libs -lws2_32 -liphlpapi"
6484 fi
6485 ;;
6486
6487 system)
6488 slirp_version=$($pkg_config --modversion slirp 2>/dev/null)
6489 slirp_cflags=$($pkg_config --cflags slirp 2>/dev/null)
6490 slirp_libs=$($pkg_config --libs slirp 2>/dev/null)
6491 ;;
6492
6493 no)
6494 ;;
6495 *)
6496 error_exit "Unknown state for slirp: $slirp"
6497 ;;
6498 esac
6499
6500 ##########################################
6501 # check for usable __NR_keyctl syscall
6502
6503 if test "$linux" = "yes" ; then
6504
6505 have_keyring=no
6506 cat > $TMPC << EOF
6507 #include <errno.h>
6508 #include <asm/unistd.h>
6509 #include <linux/keyctl.h>
6510 #include <unistd.h>
6511 int main(void) {
6512 return syscall(__NR_keyctl, KEYCTL_READ, 0, NULL, NULL, 0);
6513 }
6514 EOF
6515 if compile_prog "" "" ; then
6516 have_keyring=yes
6517 fi
6518 fi
6519 if test "$secret_keyring" != "no"
6520 then
6521 if test "$have_keyring" = "yes"
6522 then
6523 secret_keyring=yes
6524 else
6525 if test "$secret_keyring" = "yes"
6526 then
6527 error_exit "syscall __NR_keyctl requested, \
6528 but not implemented on your system"
6529 else
6530 secret_keyring=no
6531 fi
6532 fi
6533 fi
6534
6535 ##########################################
6536 # check for usable keyutils.h
6537
6538 if test "$linux" = "yes" ; then
6539
6540 have_keyutils=no
6541 cat > $TMPC << EOF
6542 #include <errno.h>
6543 #include <asm/unistd.h>
6544 #include <unistd.h>
6545 #include <sys/types.h>
6546 #include <keyutils.h>
6547 int main(void) {
6548 return request_key("user", NULL, NULL, 0);
6549 }
6550 EOF
6551 if compile_prog "" "-lkeyutils"; then
6552 have_keyutils=yes
6553 fi
6554 fi
6555
6556
6557 ##########################################
6558 # End of CC checks
6559 # After here, no more $cc or $ld runs
6560
6561 write_c_skeleton
6562
6563 if test "$gcov" = "yes" ; then
6564 QEMU_CFLAGS="-fprofile-arcs -ftest-coverage -g $QEMU_CFLAGS"
6565 QEMU_LDFLAGS="-fprofile-arcs -ftest-coverage $QEMU_LDFLAGS"
6566 elif test "$fortify_source" = "yes" ; then
6567 QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
6568 debug=no
6569 fi
6570 if test "$debug_info" = "yes"; then
6571 CFLAGS="-g $CFLAGS"
6572 LDFLAGS="-g $LDFLAGS"
6573 fi
6574 if test "$debug" = "no"; then
6575 CFLAGS="-O2 $CFLAGS"
6576 fi
6577
6578 case "$ARCH" in
6579 alpha)
6580 # Ensure there's only a single GP
6581 QEMU_CFLAGS="-msmall-data $QEMU_CFLAGS"
6582 ;;
6583 esac
6584
6585 if test "$gprof" = "yes" ; then
6586 QEMU_CFLAGS="-p $QEMU_CFLAGS"
6587 QEMU_LDFLAGS="-p $QEMU_LDFLAGS"
6588 fi
6589
6590 if test "$have_asan" = "yes"; then
6591 QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS"
6592 QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS"
6593 if test "$have_asan_iface_h" = "no" ; then
6594 echo "ASAN build enabled, but ASAN header missing." \
6595 "Without code annotation, the report may be inferior."
6596 elif test "$have_asan_iface_fiber" = "no" ; then
6597 echo "ASAN build enabled, but ASAN header is too old." \
6598 "Without code annotation, the report may be inferior."
6599 fi
6600 fi
6601 if test "$have_tsan" = "yes" ; then
6602 if test "$have_tsan_iface_fiber" = "yes" ; then
6603 QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS"
6604 QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS"
6605 else
6606 error_exit "Cannot enable TSAN due to missing fiber annotation interface."
6607 fi
6608 elif test "$tsan" = "yes" ; then
6609 error_exit "Cannot enable TSAN due to missing sanitize thread interface."
6610 fi
6611 if test "$have_ubsan" = "yes"; then
6612 QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS"
6613 QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS"
6614 fi
6615
6616 ##########################################
6617 # Do we have libnfs
6618 if test "$libnfs" != "no" ; then
6619 if $pkg_config --atleast-version=1.9.3 libnfs; then
6620 libnfs="yes"
6621 libnfs_libs=$($pkg_config --libs libnfs)
6622 else
6623 if test "$libnfs" = "yes" ; then
6624 feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
6625 fi
6626 libnfs="no"
6627 fi
6628 fi
6629
6630 ##########################################
6631 # Do we have libudev
6632 if test "$libudev" != "no" ; then
6633 if $pkg_config libudev && test "$static" != "yes"; then
6634 libudev="yes"
6635 libudev_libs=$($pkg_config --libs libudev)
6636 else
6637 libudev="no"
6638 fi
6639 fi
6640
6641 # Now we've finished running tests it's OK to add -Werror to the compiler flags
6642 if test "$werror" = "yes"; then
6643 QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
6644 fi
6645
6646 # Exclude --warn-common with TSan to suppress warnings from the TSan libraries.
6647 if test "$solaris" = "no" && test "$tsan" = "no"; then
6648 if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
6649 QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS"
6650 fi
6651 fi
6652
6653 # test if pod2man has --utf8 option
6654 if pod2man --help | grep -q utf8; then
6655 POD2MAN="pod2man --utf8"
6656 else
6657 POD2MAN="pod2man"
6658 fi
6659
6660 # Use ASLR, no-SEH and DEP if available
6661 if test "$mingw32" = "yes" ; then
6662 for flag in --dynamicbase --no-seh --nxcompat; do
6663 if ld_has $flag ; then
6664 QEMU_LDFLAGS="-Wl,$flag $QEMU_LDFLAGS"
6665 fi
6666 done
6667 fi
6668
6669 # Disable OpenBSD W^X if available
6670 if test "$tcg" = "yes" && test "$targetos" = "OpenBSD"; then
6671 cat > $TMPC <<EOF
6672 int main(void) { return 0; }
6673 EOF
6674 wx_ldflags="-Wl,-z,wxneeded"
6675 if compile_prog "" "$wx_ldflags"; then
6676 QEMU_LDFLAGS="$QEMU_LDFLAGS $wx_ldflags"
6677 fi
6678 fi
6679
6680 qemu_confdir=$sysconfdir$confsuffix
6681 qemu_moddir=$libdir$confsuffix
6682 qemu_datadir=$datadir$confsuffix
6683 qemu_localedir="$datadir/locale"
6684 qemu_icondir="$datadir/icons"
6685 qemu_desktopdir="$datadir/applications"
6686
6687 # We can only support ivshmem if we have eventfd
6688 if [ "$eventfd" = "yes" ]; then
6689 ivshmem=yes
6690 fi
6691
6692 tools=""
6693 if test "$want_tools" = "yes" ; then
6694 tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) qemu-edid\$(EXESUF) $tools"
6695 if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
6696 tools="qemu-nbd\$(EXESUF) qemu-storage-daemon\$(EXESUF) $tools"
6697 fi
6698 if [ "$ivshmem" = "yes" ]; then
6699 tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools"
6700 fi
6701 if [ "$curl" = "yes" ]; then
6702 tools="elf2dmp\$(EXESUF) $tools"
6703 fi
6704 fi
6705 if test "$softmmu" = yes ; then
6706 if test "$linux" = yes; then
6707 if test "$virtfs" != no && test "$cap_ng" = yes && test "$attr" = yes ; then
6708 virtfs=yes
6709 helpers="$helpers fsdev/virtfs-proxy-helper\$(EXESUF)"
6710 else
6711 if test "$virtfs" = yes; then
6712 error_exit "VirtFS requires libcap-ng devel and libattr devel"
6713 fi
6714 virtfs=no
6715 fi
6716 if test "$mpath" != no && test "$mpathpersist" = yes ; then
6717 mpath=yes
6718 else
6719 if test "$mpath" = yes; then
6720 error_exit "Multipath requires libmpathpersist devel"
6721 fi
6722 mpath=no
6723 fi
6724 helpers="$helpers scsi/qemu-pr-helper\$(EXESUF)"
6725 else
6726 if test "$virtfs" = yes; then
6727 error_exit "VirtFS is supported only on Linux"
6728 fi
6729 virtfs=no
6730 if test "$mpath" = yes; then
6731 error_exit "Multipath is supported only on Linux"
6732 fi
6733 mpath=no
6734 fi
6735 if test "$xkbcommon" = "yes"; then
6736 tools="qemu-keymap\$(EXESUF) $tools"
6737 fi
6738 fi
6739
6740 # Probe for guest agent support/options
6741
6742 if [ "$guest_agent" != "no" ]; then
6743 if [ "$softmmu" = no -a "$want_tools" = no ] ; then
6744 guest_agent=no
6745 elif [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
6746 tools="qemu-ga\$(EXESUF) $tools"
6747 guest_agent=yes
6748 elif [ "$guest_agent" != yes ]; then
6749 guest_agent=no
6750 else
6751 error_exit "Guest agent is not supported on this platform"
6752 fi
6753 fi
6754
6755 # Guest agent Window MSI package
6756
6757 if test "$guest_agent" != yes; then
6758 if test "$guest_agent_msi" = yes; then
6759 error_exit "MSI guest agent package requires guest agent enabled"
6760 fi
6761 guest_agent_msi=no
6762 elif test "$mingw32" != "yes"; then
6763 if test "$guest_agent_msi" = "yes"; then
6764 error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
6765 fi
6766 guest_agent_msi=no
6767 elif ! has wixl; then
6768 if test "$guest_agent_msi" = "yes"; then
6769 error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
6770 fi
6771 guest_agent_msi=no
6772 else
6773 # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
6774 # disabled explicitly
6775 if test "$guest_agent_msi" != "no"; then
6776 guest_agent_msi=yes
6777 fi
6778 fi
6779
6780 if test "$guest_agent_msi" = "yes"; then
6781 if test "$guest_agent_with_vss" = "yes"; then
6782 QEMU_GA_MSI_WITH_VSS="-D InstallVss"
6783 fi
6784
6785 if test "$QEMU_GA_MANUFACTURER" = ""; then
6786 QEMU_GA_MANUFACTURER=QEMU
6787 fi
6788
6789 if test "$QEMU_GA_DISTRO" = ""; then
6790 QEMU_GA_DISTRO=Linux
6791 fi
6792
6793 if test "$QEMU_GA_VERSION" = ""; then
6794 QEMU_GA_VERSION=$(cat $source_path/VERSION)
6795 fi
6796
6797 QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
6798
6799 case "$cpu" in
6800 x86_64)
6801 QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
6802 ;;
6803 i386)
6804 QEMU_GA_MSI_ARCH="-D Arch=32"
6805 ;;
6806 *)
6807 error_exit "CPU $cpu not supported for building installation package"
6808 ;;
6809 esac
6810 fi
6811
6812 # Mac OS X ships with a broken assembler
6813 roms=
6814 if { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \
6815 test "$targetos" != "Darwin" && test "$targetos" != "SunOS" && \
6816 test "$softmmu" = yes ; then
6817 # Different host OS linkers have different ideas about the name of the ELF
6818 # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
6819 # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
6820 for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
6821 if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
6822 ld_i386_emulation="$emu"
6823 roms="optionrom"
6824 break
6825 fi
6826 done
6827 fi
6828
6829 # Only build s390-ccw bios if we're on s390x and the compiler has -march=z900
6830 if test "$cpu" = "s390x" ; then
6831 write_c_skeleton
6832 if compile_prog "-march=z900" ""; then
6833 roms="$roms s390-ccw"
6834 # SLOF is required for building the s390-ccw firmware on s390x,
6835 # since it is using the libnet code from SLOF for network booting.
6836 if test -e "${source_path}/.git" ; then
6837 git_submodules="${git_submodules} roms/SLOF"
6838 fi
6839 fi
6840 fi
6841
6842 # Check that the C++ compiler exists and works with the C compiler.
6843 # All the QEMU_CXXFLAGS are based on QEMU_CFLAGS. Keep this at the end to don't miss any other that could be added.
6844 if has $cxx; then
6845 cat > $TMPC <<EOF
6846 int c_function(void);
6847 int main(void) { return c_function(); }
6848 EOF
6849
6850 compile_object
6851
6852 cat > $TMPCXX <<EOF
6853 extern "C" {
6854 int c_function(void);
6855 }
6856 int c_function(void) { return 42; }
6857 EOF
6858
6859 update_cxxflags
6860
6861 if do_cxx $CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then
6862 # C++ compiler $cxx works ok with C compiler $cc
6863 :
6864 else
6865 echo "C++ compiler $cxx does not work with C compiler $cc"
6866 echo "Disabling C++ specific optional code"
6867 cxx=
6868 fi
6869 else
6870 echo "No C++ compiler available; disabling C++ specific optional code"
6871 cxx=
6872 fi
6873
6874 echo_version() {
6875 if test "$1" = "yes" ; then
6876 echo "($2)"
6877 fi
6878 }
6879
6880 # prepend pixman and ftd flags after all config tests are done
6881 QEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"
6882 QEMU_LDFLAGS="$fdt_ldflags $QEMU_LDFLAGS"
6883 libs_softmmu="$pixman_libs $libs_softmmu"
6884
6885 echo "Install prefix $prefix"
6886 echo "BIOS directory $(eval echo $qemu_datadir)"
6887 echo "firmware path $(eval echo $firmwarepath)"
6888 echo "binary directory $(eval echo $bindir)"
6889 echo "library directory $(eval echo $libdir)"
6890 echo "module directory $(eval echo $qemu_moddir)"
6891 echo "libexec directory $(eval echo $libexecdir)"
6892 echo "include directory $(eval echo $includedir)"
6893 echo "config directory $(eval echo $sysconfdir)"
6894 if test "$mingw32" = "no" ; then
6895 echo "local state directory $(eval echo $local_statedir)"
6896 echo "Manual directory $(eval echo $mandir)"
6897 echo "ELF interp prefix $interp_prefix"
6898 else
6899 echo "local state directory queried at runtime"
6900 echo "Windows SDK $win_sdk"
6901 fi
6902 echo "Build directory $(pwd)"
6903 echo "Source path $source_path"
6904 echo "GIT binary $git"
6905 echo "GIT submodules $git_submodules"
6906 echo "C compiler $cc"
6907 echo "Host C compiler $host_cc"
6908 echo "C++ compiler $cxx"
6909 echo "Objective-C compiler $objcc"
6910 echo "ARFLAGS $ARFLAGS"
6911 echo "CFLAGS $CFLAGS"
6912 echo "QEMU_CFLAGS $QEMU_CFLAGS"
6913 echo "QEMU_LDFLAGS $QEMU_LDFLAGS"
6914 echo "make $make"
6915 echo "install $install"
6916 echo "python $python ($python_version)"
6917 if test "$docs" != "no"; then
6918 echo "sphinx-build $sphinx_build"
6919 fi
6920 echo "genisoimage $genisoimage"
6921 echo "slirp support $slirp $(echo_version $slirp $slirp_version)"
6922 if test "$slirp" != "no" ; then
6923 echo "smbd $smbd"
6924 fi
6925 echo "module support $modules"
6926 echo "alt path mod load $module_upgrades"
6927 echo "host CPU $cpu"
6928 echo "host big endian $bigendian"
6929 echo "target list $target_list"
6930 echo "gprof enabled $gprof"
6931 echo "sparse enabled $sparse"
6932 echo "strip binaries $strip_opt"
6933 echo "profiler $profiler"
6934 echo "static build $static"
6935 echo "safe stack $safe_stack"
6936 if test "$darwin" = "yes" ; then
6937 echo "Cocoa support $cocoa"
6938 fi
6939 echo "SDL support $sdl $(echo_version $sdl $sdlversion)"
6940 echo "SDL image support $sdl_image"
6941 echo "GTK support $gtk $(echo_version $gtk $gtk_version)"
6942 echo "GTK GL support $gtk_gl"
6943 echo "VTE support $vte $(echo_version $vte $vteversion)"
6944 echo "TLS priority $tls_priority"
6945 echo "GNUTLS support $gnutls"
6946 echo "libgcrypt $gcrypt"
6947 if test "$gcrypt" = "yes"
6948 then
6949 echo " hmac $gcrypt_hmac"
6950 echo " XTS $gcrypt_xts"
6951 fi
6952 echo "nettle $nettle $(echo_version $nettle $nettle_version)"
6953 if test "$nettle" = "yes"
6954 then
6955 echo " XTS $nettle_xts"
6956 fi
6957 echo "libtasn1 $tasn1"
6958 echo "PAM $auth_pam"
6959 echo "iconv support $iconv"
6960 echo "curses support $curses"
6961 echo "virgl support $virglrenderer $(echo_version $virglrenderer $virgl_version)"
6962 echo "curl support $curl"
6963 echo "mingw32 support $mingw32"
6964 echo "Audio drivers $audio_drv_list"
6965 echo "Block whitelist (rw) $block_drv_rw_whitelist"
6966 echo "Block whitelist (ro) $block_drv_ro_whitelist"
6967 echo "VirtFS support $virtfs"
6968 echo "Multipath support $mpath"
6969 echo "VNC support $vnc"
6970 if test "$vnc" = "yes" ; then
6971 echo "VNC SASL support $vnc_sasl"
6972 echo "VNC JPEG support $vnc_jpeg"
6973 echo "VNC PNG support $vnc_png"
6974 fi
6975 echo "xen support $xen"
6976 if test "$xen" = "yes" ; then
6977 echo "xen ctrl version $xen_ctrl_version"
6978 fi
6979 echo "brlapi support $brlapi"
6980 echo "Documentation $docs"
6981 echo "PIE $pie"
6982 echo "vde support $vde"
6983 echo "netmap support $netmap"
6984 echo "Linux AIO support $linux_aio"
6985 echo "Linux io_uring support $linux_io_uring"
6986 echo "ATTR/XATTR support $attr"
6987 echo "Install blobs $blobs"
6988 echo "KVM support $kvm"
6989 echo "HAX support $hax"
6990 echo "HVF support $hvf"
6991 echo "WHPX support $whpx"
6992 echo "TCG support $tcg"
6993 if test "$tcg" = "yes" ; then
6994 echo "TCG debug enabled $debug_tcg"
6995 echo "TCG interpreter $tcg_interpreter"
6996 fi
6997 echo "malloc trim support $malloc_trim"
6998 echo "RDMA support $rdma"
6999 echo "PVRDMA support $pvrdma"
7000 echo "fdt support $fdt"
7001 echo "membarrier $membarrier"
7002 echo "preadv support $preadv"
7003 echo "fdatasync $fdatasync"
7004 echo "madvise $madvise"
7005 echo "posix_madvise $posix_madvise"
7006 echo "posix_memalign $posix_memalign"
7007 echo "libcap-ng support $cap_ng"
7008 echo "vhost-net support $vhost_net"
7009 echo "vhost-crypto support $vhost_crypto"
7010 echo "vhost-scsi support $vhost_scsi"
7011 echo "vhost-vsock support $vhost_vsock"
7012 echo "vhost-user support $vhost_user"
7013 echo "vhost-user-fs support $vhost_user_fs"
7014 echo "vhost-vdpa support $vhost_vdpa"
7015 echo "Trace backends $trace_backends"
7016 if have_backend "simple"; then
7017 echo "Trace output file $trace_file-<pid>"
7018 fi
7019 echo "spice support $spice $(echo_version $spice $spice_protocol_version/$spice_server_version)"
7020 echo "rbd support $rbd"
7021 echo "xfsctl support $xfs"
7022 echo "smartcard support $smartcard"
7023 echo "libusb $libusb"
7024 echo "usb net redir $usb_redir"
7025 echo "OpenGL support $opengl"
7026 echo "OpenGL dmabufs $opengl_dmabuf"
7027 echo "libiscsi support $libiscsi"
7028 echo "libnfs support $libnfs"
7029 echo "build guest agent $guest_agent"
7030 echo "QGA VSS support $guest_agent_with_vss"
7031 echo "QGA w32 disk info $guest_agent_ntddscsi"
7032 echo "QGA MSI support $guest_agent_msi"
7033 echo "seccomp support $seccomp"
7034 echo "coroutine backend $coroutine"
7035 echo "coroutine pool $coroutine_pool"
7036 echo "debug stack usage $debug_stack_usage"
7037 echo "mutex debugging $debug_mutex"
7038 echo "crypto afalg $crypto_afalg"
7039 echo "GlusterFS support $glusterfs"
7040 echo "gcov $gcov_tool"
7041 echo "gcov enabled $gcov"
7042 echo "TPM support $tpm"
7043 echo "libssh support $libssh"
7044 echo "QOM debugging $qom_cast_debug"
7045 echo "Live block migration $live_block_migration"
7046 echo "lzo support $lzo"
7047 echo "snappy support $snappy"
7048 echo "bzip2 support $bzip2"
7049 echo "lzfse support $lzfse"
7050 echo "zstd support $zstd"
7051 echo "NUMA host support $numa"
7052 echo "libxml2 $libxml2"
7053 echo "tcmalloc support $tcmalloc"
7054 echo "jemalloc support $jemalloc"
7055 echo "avx2 optimization $avx2_opt"
7056 echo "avx512f optimization $avx512f_opt"
7057 echo "replication support $replication"
7058 echo "bochs support $bochs"
7059 echo "cloop support $cloop"
7060 echo "dmg support $dmg"
7061 echo "qcow v1 support $qcow1"
7062 echo "vdi support $vdi"
7063 echo "vvfat support $vvfat"
7064 echo "qed support $qed"
7065 echo "parallels support $parallels"
7066 echo "sheepdog support $sheepdog"
7067 echo "capstone $capstone"
7068 echo "libpmem support $libpmem"
7069 echo "libdaxctl support $libdaxctl"
7070 echo "libudev $libudev"
7071 echo "default devices $default_devices"
7072 echo "plugin support $plugins"
7073 echo "fuzzing support $fuzzing"
7074 echo "gdb $gdb_bin"
7075 echo "rng-none $rng_none"
7076 echo "Linux keyring $secret_keyring"
7077
7078 if test "$supported_cpu" = "no"; then
7079 echo
7080 echo "WARNING: SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!"
7081 echo
7082 echo "CPU host architecture $cpu support is not currently maintained."
7083 echo "The QEMU project intends to remove support for this host CPU in"
7084 echo "a future release if nobody volunteers to maintain it and to"
7085 echo "provide a build host for our continuous integration setup."
7086 echo "configure has succeeded and you can continue to build, but"
7087 echo "if you care about QEMU on this platform you should contact"
7088 echo "us upstream at qemu-devel@nongnu.org."
7089 fi
7090
7091 if test "$supported_os" = "no"; then
7092 echo
7093 echo "WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!"
7094 echo
7095 echo "Host OS $targetos support is not currently maintained."
7096 echo "The QEMU project intends to remove support for this host OS in"
7097 echo "a future release if nobody volunteers to maintain it and to"
7098 echo "provide a build host for our continuous integration setup."
7099 echo "configure has succeeded and you can continue to build, but"
7100 echo "if you care about QEMU on this platform you should contact"
7101 echo "us upstream at qemu-devel@nongnu.org."
7102 fi
7103
7104 config_host_mak="config-host.mak"
7105
7106 echo "# Automatically generated by configure - do not modify" >config-all-disas.mak
7107
7108 echo "# Automatically generated by configure - do not modify" > $config_host_mak
7109 echo >> $config_host_mak
7110
7111 echo all: >> $config_host_mak
7112 echo "prefix=$prefix" >> $config_host_mak
7113 echo "bindir=$bindir" >> $config_host_mak
7114 echo "libdir=$libdir" >> $config_host_mak
7115 echo "libexecdir=$libexecdir" >> $config_host_mak
7116 echo "includedir=$includedir" >> $config_host_mak
7117 echo "mandir=$mandir" >> $config_host_mak
7118 echo "sysconfdir=$sysconfdir" >> $config_host_mak
7119 echo "qemu_confdir=$qemu_confdir" >> $config_host_mak
7120 echo "qemu_datadir=$qemu_datadir" >> $config_host_mak
7121 echo "qemu_firmwarepath=$firmwarepath" >> $config_host_mak
7122 echo "qemu_docdir=$qemu_docdir" >> $config_host_mak
7123 echo "qemu_moddir=$qemu_moddir" >> $config_host_mak
7124 if test "$mingw32" = "no" ; then
7125 echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
7126 fi
7127 echo "qemu_helperdir=$libexecdir" >> $config_host_mak
7128 echo "qemu_localedir=$qemu_localedir" >> $config_host_mak
7129 echo "qemu_icondir=$qemu_icondir" >> $config_host_mak
7130 echo "qemu_desktopdir=$qemu_desktopdir" >> $config_host_mak
7131 echo "libs_cpu=$libs_cpu" >> $config_host_mak
7132 echo "libs_softmmu=$libs_softmmu" >> $config_host_mak
7133 echo "GIT=$git" >> $config_host_mak
7134 echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
7135 echo "GIT_UPDATE=$git_update" >> $config_host_mak
7136
7137 echo "ARCH=$ARCH" >> $config_host_mak
7138
7139 echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
7140 echo "GLIB_LDFLAGS=$glib_ldflags" >> $config_host_mak
7141
7142 if test "$default_devices" = "yes" ; then
7143 echo "CONFIG_MINIKCONF_MODE=--defconfig" >> $config_host_mak
7144 else
7145 echo "CONFIG_MINIKCONF_MODE=--allnoconfig" >> $config_host_mak
7146 fi
7147 if test "$debug_tcg" = "yes" ; then
7148 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
7149 fi
7150 if test "$strip_opt" = "yes" ; then
7151 echo "STRIP=${strip}" >> $config_host_mak
7152 fi
7153 if test "$bigendian" = "yes" ; then
7154 echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
7155 fi
7156 if test "$mingw32" = "yes" ; then
7157 echo "CONFIG_WIN32=y" >> $config_host_mak
7158 rc_version=$(cat $source_path/VERSION)
7159 version_major=${rc_version%%.*}
7160 rc_version=${rc_version#*.}
7161 version_minor=${rc_version%%.*}
7162 rc_version=${rc_version#*.}
7163 version_subminor=${rc_version%%.*}
7164 version_micro=0
7165 echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
7166 echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
7167 if test "$guest_agent_with_vss" = "yes" ; then
7168 echo "CONFIG_QGA_VSS=y" >> $config_host_mak
7169 echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
7170 echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
7171 fi
7172 if test "$guest_agent_ntddscsi" = "yes" ; then
7173 echo "CONFIG_QGA_NTDDSCSI=y" >> $config_host_mak
7174 fi
7175 if test "$guest_agent_msi" = "yes"; then
7176 echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
7177 echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
7178 echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
7179 echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
7180 echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
7181 echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
7182 echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
7183 fi
7184 else
7185 echo "CONFIG_POSIX=y" >> $config_host_mak
7186 fi
7187
7188 if test "$linux" = "yes" ; then
7189 echo "CONFIG_LINUX=y" >> $config_host_mak
7190 fi
7191
7192 if test "$darwin" = "yes" ; then
7193 echo "CONFIG_DARWIN=y" >> $config_host_mak
7194 fi
7195
7196 if test "$solaris" = "yes" ; then
7197 echo "CONFIG_SOLARIS=y" >> $config_host_mak
7198 fi
7199 if test "$haiku" = "yes" ; then
7200 echo "CONFIG_HAIKU=y" >> $config_host_mak
7201 fi
7202 if test "$static" = "yes" ; then
7203 echo "CONFIG_STATIC=y" >> $config_host_mak
7204 fi
7205 if test "$profiler" = "yes" ; then
7206 echo "CONFIG_PROFILER=y" >> $config_host_mak
7207 fi
7208 if test "$want_tools" = "yes" ; then
7209 echo "CONFIG_TOOLS=y" >> $config_host_mak
7210 fi
7211 if test "$slirp" != "no"; then
7212 echo "CONFIG_SLIRP=y" >> $config_host_mak
7213 echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
7214 echo "SLIRP_CFLAGS=$slirp_cflags" >> $config_host_mak
7215 echo "SLIRP_LIBS=$slirp_libs" >> $config_host_mak
7216 fi
7217 if [ "$slirp" = "git" -o "$slirp" = "internal" ]; then
7218 echo "config-host.h: slirp/all" >> $config_host_mak
7219 fi
7220 if test "$vde" = "yes" ; then
7221 echo "CONFIG_VDE=y" >> $config_host_mak
7222 echo "VDE_LIBS=$vde_libs" >> $config_host_mak
7223 fi
7224 if test "$netmap" = "yes" ; then
7225 echo "CONFIG_NETMAP=y" >> $config_host_mak
7226 fi
7227 if test "$l2tpv3" = "yes" ; then
7228 echo "CONFIG_L2TPV3=y" >> $config_host_mak
7229 fi
7230 if test "$gprof" = "yes" ; then
7231 echo "CONFIG_GPROF=y" >> $config_host_mak
7232 fi
7233 if test "$cap_ng" = "yes" ; then
7234 echo "CONFIG_LIBCAP_NG=y" >> $config_host_mak
7235 fi
7236 echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
7237 for drv in $audio_drv_list; do
7238 def=CONFIG_AUDIO_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
7239 case "$drv" in
7240 alsa | oss | pa | sdl)
7241 echo "$def=m" >> $config_host_mak ;;
7242 *)
7243 echo "$def=y" >> $config_host_mak ;;
7244 esac
7245 done
7246 echo "ALSA_LIBS=$alsa_libs" >> $config_host_mak
7247 echo "PULSE_LIBS=$pulse_libs" >> $config_host_mak
7248 echo "COREAUDIO_LIBS=$coreaudio_libs" >> $config_host_mak
7249 echo "DSOUND_LIBS=$dsound_libs" >> $config_host_mak
7250 echo "OSS_LIBS=$oss_libs" >> $config_host_mak
7251 echo "JACK_LIBS=$jack_libs" >> $config_host_mak
7252 if test "$audio_win_int" = "yes" ; then
7253 echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
7254 fi
7255 echo "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
7256 echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
7257 if test "$vnc" = "yes" ; then
7258 echo "CONFIG_VNC=y" >> $config_host_mak
7259 fi
7260 if test "$vnc_sasl" = "yes" ; then
7261 echo "CONFIG_VNC_SASL=y" >> $config_host_mak
7262 fi
7263 if test "$vnc_jpeg" = "yes" ; then
7264 echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
7265 fi
7266 if test "$vnc_png" = "yes" ; then
7267 echo "CONFIG_VNC_PNG=y" >> $config_host_mak
7268 fi
7269 if test "$xkbcommon" = "yes" ; then
7270 echo "XKBCOMMON_CFLAGS=$xkbcommon_cflags" >> $config_host_mak
7271 echo "XKBCOMMON_LIBS=$xkbcommon_libs" >> $config_host_mak
7272 fi
7273 if test "$xfs" = "yes" ; then
7274 echo "CONFIG_XFS=y" >> $config_host_mak
7275 fi
7276 qemu_version=$(head $source_path/VERSION)
7277 echo "VERSION=$qemu_version" >>$config_host_mak
7278 echo "PKGVERSION=$pkgversion" >>$config_host_mak
7279 echo "SRC_PATH=$source_path" >> $config_host_mak
7280 echo "TARGET_DIRS=$target_list" >> $config_host_mak
7281 if [ "$docs" = "yes" ] ; then
7282 echo "BUILD_DOCS=yes" >> $config_host_mak
7283 fi
7284 if test "$modules" = "yes"; then
7285 # $shacmd can generate a hash started with digit, which the compiler doesn't
7286 # like as an symbol. So prefix it with an underscore
7287 echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
7288 echo "CONFIG_MODULES=y" >> $config_host_mak
7289 fi
7290 if test "$module_upgrades" = "yes"; then
7291 echo "CONFIG_MODULE_UPGRADES=y" >> $config_host_mak
7292 fi
7293 if test "$have_x11" = "yes" && test "$need_x11" = "yes"; then
7294 echo "CONFIG_X11=y" >> $config_host_mak
7295 echo "X11_CFLAGS=$x11_cflags" >> $config_host_mak
7296 echo "X11_LIBS=$x11_libs" >> $config_host_mak
7297 fi
7298 if test "$sdl" = "yes" ; then
7299 echo "CONFIG_SDL=m" >> $config_host_mak
7300 echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
7301 echo "SDL_LIBS=$sdl_libs" >> $config_host_mak
7302 if test "$sdl_image" = "yes" ; then
7303 echo "CONFIG_SDL_IMAGE=y" >> $config_host_mak
7304 fi
7305 fi
7306 if test "$cocoa" = "yes" ; then
7307 echo "CONFIG_COCOA=y" >> $config_host_mak
7308 fi
7309 if test "$iconv" = "yes" ; then
7310 echo "CONFIG_ICONV=y" >> $config_host_mak
7311 echo "ICONV_CFLAGS=$iconv_cflags" >> $config_host_mak
7312 echo "ICONV_LIBS=$iconv_lib" >> $config_host_mak
7313 fi
7314 if test "$curses" = "yes" ; then
7315 echo "CONFIG_CURSES=m" >> $config_host_mak
7316 echo "CURSES_CFLAGS=$curses_inc" >> $config_host_mak
7317 echo "CURSES_LIBS=$curses_lib" >> $config_host_mak
7318 fi
7319 if test "$pipe2" = "yes" ; then
7320 echo "CONFIG_PIPE2=y" >> $config_host_mak
7321 fi
7322 if test "$accept4" = "yes" ; then
7323 echo "CONFIG_ACCEPT4=y" >> $config_host_mak
7324 fi
7325 if test "$splice" = "yes" ; then
7326 echo "CONFIG_SPLICE=y" >> $config_host_mak
7327 fi
7328 if test "$eventfd" = "yes" ; then
7329 echo "CONFIG_EVENTFD=y" >> $config_host_mak
7330 fi
7331 if test "$memfd" = "yes" ; then
7332 echo "CONFIG_MEMFD=y" >> $config_host_mak
7333 fi
7334 if test "$have_usbfs" = "yes" ; then
7335 echo "CONFIG_USBFS=y" >> $config_host_mak
7336 fi
7337 if test "$fallocate" = "yes" ; then
7338 echo "CONFIG_FALLOCATE=y" >> $config_host_mak
7339 fi
7340 if test "$fallocate_punch_hole" = "yes" ; then
7341 echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
7342 fi
7343 if test "$fallocate_zero_range" = "yes" ; then
7344 echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
7345 fi
7346 if test "$posix_fallocate" = "yes" ; then
7347 echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
7348 fi
7349 if test "$sync_file_range" = "yes" ; then
7350 echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
7351 fi
7352 if test "$fiemap" = "yes" ; then
7353 echo "CONFIG_FIEMAP=y" >> $config_host_mak
7354 fi
7355 if test "$dup3" = "yes" ; then
7356 echo "CONFIG_DUP3=y" >> $config_host_mak
7357 fi
7358 if test "$ppoll" = "yes" ; then
7359 echo "CONFIG_PPOLL=y" >> $config_host_mak
7360 fi
7361 if test "$prctl_pr_set_timerslack" = "yes" ; then
7362 echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
7363 fi
7364 if test "$epoll" = "yes" ; then
7365 echo "CONFIG_EPOLL=y" >> $config_host_mak
7366 fi
7367 if test "$epoll_create1" = "yes" ; then
7368 echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
7369 fi
7370 if test "$sendfile" = "yes" ; then
7371 echo "CONFIG_SENDFILE=y" >> $config_host_mak
7372 fi
7373 if test "$timerfd" = "yes" ; then
7374 echo "CONFIG_TIMERFD=y" >> $config_host_mak
7375 fi
7376 if test "$setns" = "yes" ; then
7377 echo "CONFIG_SETNS=y" >> $config_host_mak
7378 fi
7379 if test "$clock_adjtime" = "yes" ; then
7380 echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
7381 fi
7382 if test "$syncfs" = "yes" ; then
7383 echo "CONFIG_SYNCFS=y" >> $config_host_mak
7384 fi
7385 if test "$kcov" = "yes" ; then
7386 echo "CONFIG_KCOV=y" >> $config_host_mak
7387 fi
7388 if test "$inotify" = "yes" ; then
7389 echo "CONFIG_INOTIFY=y" >> $config_host_mak
7390 fi
7391 if test "$inotify1" = "yes" ; then
7392 echo "CONFIG_INOTIFY1=y" >> $config_host_mak
7393 fi
7394 if test "$sem_timedwait" = "yes" ; then
7395 echo "CONFIG_SEM_TIMEDWAIT=y" >> $config_host_mak
7396 fi
7397 if test "$strchrnul" = "yes" ; then
7398 echo "HAVE_STRCHRNUL=y" >> $config_host_mak
7399 fi
7400 if test "$st_atim" = "yes" ; then
7401 echo "HAVE_STRUCT_STAT_ST_ATIM=y" >> $config_host_mak
7402 fi
7403 if test "$byteswap_h" = "yes" ; then
7404 echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
7405 fi
7406 if test "$bswap_h" = "yes" ; then
7407 echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
7408 fi
7409 if test "$curl" = "yes" ; then
7410 echo "CONFIG_CURL=m" >> $config_host_mak
7411 echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
7412 echo "CURL_LIBS=$curl_libs" >> $config_host_mak
7413 fi
7414 if test "$brlapi" = "yes" ; then
7415 echo "CONFIG_BRLAPI=y" >> $config_host_mak
7416 echo "BRLAPI_LIBS=$brlapi_libs" >> $config_host_mak
7417 fi
7418 if test "$gtk" = "yes" ; then
7419 echo "CONFIG_GTK=m" >> $config_host_mak
7420 echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
7421 echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
7422 if test "$gtk_gl" = "yes" ; then
7423 echo "CONFIG_GTK_GL=y" >> $config_host_mak
7424 fi
7425 fi
7426 if test "$gio" = "yes" ; then
7427 echo "CONFIG_GIO=y" >> $config_host_mak
7428 echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak
7429 echo "GIO_LIBS=$gio_libs" >> $config_host_mak
7430 echo "GDBUS_CODEGEN=$gdbus_codegen" >> $config_host_mak
7431 fi
7432 echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
7433 if test "$gnutls" = "yes" ; then
7434 echo "CONFIG_GNUTLS=y" >> $config_host_mak
7435 fi
7436 if test "$gcrypt" = "yes" ; then
7437 echo "CONFIG_GCRYPT=y" >> $config_host_mak
7438 if test "$gcrypt_hmac" = "yes" ; then
7439 echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
7440 fi
7441 fi
7442 if test "$nettle" = "yes" ; then
7443 echo "CONFIG_NETTLE=y" >> $config_host_mak
7444 echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
7445 fi
7446 if test "$qemu_private_xts" = "yes" ; then
7447 echo "CONFIG_QEMU_PRIVATE_XTS=y" >> $config_host_mak
7448 fi
7449 if test "$tasn1" = "yes" ; then
7450 echo "CONFIG_TASN1=y" >> $config_host_mak
7451 fi
7452 if test "$auth_pam" = "yes" ; then
7453 echo "CONFIG_AUTH_PAM=y" >> $config_host_mak
7454 fi
7455 if test "$have_ifaddrs_h" = "yes" ; then
7456 echo "HAVE_IFADDRS_H=y" >> $config_host_mak
7457 fi
7458 if test "$have_drm_h" = "yes" ; then
7459 echo "HAVE_DRM_H=y" >> $config_host_mak
7460 fi
7461 if test "$have_broken_size_max" = "yes" ; then
7462 echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
7463 fi
7464 if test "$have_openpty" = "yes" ; then
7465 echo "HAVE_OPENPTY=y" >> $config_host_mak
7466 fi
7467 if test "$have_sys_signal_h" = "yes" ; then
7468 echo "HAVE_SYS_SIGNAL_H=y" >> $config_host_mak
7469 fi
7470
7471 # Work around a system header bug with some kernel/XFS header
7472 # versions where they both try to define 'struct fsxattr':
7473 # xfs headers will not try to redefine structs from linux headers
7474 # if this macro is set.
7475 if test "$have_fsxattr" = "yes" ; then
7476 echo "HAVE_FSXATTR=y" >> $config_host_mak
7477 fi
7478 if test "$have_copy_file_range" = "yes" ; then
7479 echo "HAVE_COPY_FILE_RANGE=y" >> $config_host_mak
7480 fi
7481 if test "$vte" = "yes" ; then
7482 echo "CONFIG_VTE=y" >> $config_host_mak
7483 echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
7484 echo "VTE_LIBS=$vte_libs" >> $config_host_mak
7485 fi
7486 if test "$virglrenderer" = "yes" ; then
7487 echo "CONFIG_VIRGL=y" >> $config_host_mak
7488 echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
7489 echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
7490 fi
7491 if test "$xen" = "yes" ; then
7492 echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
7493 echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
7494 fi
7495 if test "$linux_aio" = "yes" ; then
7496 echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
7497 fi
7498 if test "$linux_io_uring" = "yes" ; then
7499 echo "CONFIG_LINUX_IO_URING=y" >> $config_host_mak
7500 echo "LINUX_IO_URING_CFLAGS=$linux_io_uring_cflags" >> $config_host_mak
7501 echo "LINUX_IO_URING_LIBS=$linux_io_uring_libs" >> $config_host_mak
7502 fi
7503 if test "$attr" = "yes" ; then
7504 echo "CONFIG_ATTR=y" >> $config_host_mak
7505 fi
7506 if test "$libattr" = "yes" ; then
7507 echo "CONFIG_LIBATTR=y" >> $config_host_mak
7508 fi
7509 if test "$virtfs" = "yes" ; then
7510 echo "CONFIG_VIRTFS=y" >> $config_host_mak
7511 fi
7512 if test "$mpath" = "yes" ; then
7513 echo "CONFIG_MPATH=y" >> $config_host_mak
7514 if test "$mpathpersist_new_api" = "yes"; then
7515 echo "CONFIG_MPATH_NEW_API=y" >> $config_host_mak
7516 fi
7517 fi
7518 if test "$vhost_scsi" = "yes" ; then
7519 echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
7520 fi
7521 if test "$vhost_net" = "yes" ; then
7522 echo "CONFIG_VHOST_NET=y" >> $config_host_mak
7523 fi
7524 if test "$vhost_net_user" = "yes" ; then
7525 echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak
7526 fi
7527 if test "$vhost_net_vdpa" = "yes" ; then
7528 echo "CONFIG_VHOST_NET_VDPA=y" >> $config_host_mak
7529 fi
7530 if test "$vhost_crypto" = "yes" ; then
7531 echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
7532 fi
7533 if test "$vhost_vsock" = "yes" ; then
7534 echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
7535 if test "$vhost_user" = "yes" ; then
7536 echo "CONFIG_VHOST_USER_VSOCK=y" >> $config_host_mak
7537 fi
7538 fi
7539 if test "$vhost_kernel" = "yes" ; then
7540 echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak
7541 fi
7542 if test "$vhost_user" = "yes" ; then
7543 echo "CONFIG_VHOST_USER=y" >> $config_host_mak
7544 fi
7545 if test "$vhost_vdpa" = "yes" ; then
7546 echo "CONFIG_VHOST_VDPA=y" >> $config_host_mak
7547 fi
7548 if test "$vhost_user_fs" = "yes" ; then
7549 echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak
7550 fi
7551 if test "$blobs" = "yes" ; then
7552 echo "INSTALL_BLOBS=yes" >> $config_host_mak
7553 fi
7554 if test "$iovec" = "yes" ; then
7555 echo "CONFIG_IOVEC=y" >> $config_host_mak
7556 fi
7557 if test "$preadv" = "yes" ; then
7558 echo "CONFIG_PREADV=y" >> $config_host_mak
7559 fi
7560 if test "$fdt" != "no" ; then
7561 echo "CONFIG_FDT=y" >> $config_host_mak
7562 fi
7563 if test "$membarrier" = "yes" ; then
7564 echo "CONFIG_MEMBARRIER=y" >> $config_host_mak
7565 fi
7566 if test "$signalfd" = "yes" ; then
7567 echo "CONFIG_SIGNALFD=y" >> $config_host_mak
7568 fi
7569 if test "$optreset" = "yes" ; then
7570 echo "HAVE_OPTRESET=y" >> $config_host_mak
7571 fi
7572 if test "$tcg" = "yes"; then
7573 echo "CONFIG_TCG=y" >> $config_host_mak
7574 if test "$tcg_interpreter" = "yes" ; then
7575 echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
7576 fi
7577 fi
7578 if test "$fdatasync" = "yes" ; then
7579 echo "CONFIG_FDATASYNC=y" >> $config_host_mak
7580 fi
7581 if test "$madvise" = "yes" ; then
7582 echo "CONFIG_MADVISE=y" >> $config_host_mak
7583 fi
7584 if test "$posix_madvise" = "yes" ; then
7585 echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
7586 fi
7587 if test "$posix_memalign" = "yes" ; then
7588 echo "CONFIG_POSIX_MEMALIGN=y" >> $config_host_mak
7589 fi
7590
7591 if test "$spice" = "yes" ; then
7592 echo "CONFIG_SPICE=y" >> $config_host_mak
7593 fi
7594
7595 if test "$smartcard" = "yes" ; then
7596 echo "CONFIG_SMARTCARD=y" >> $config_host_mak
7597 echo "SMARTCARD_CFLAGS=$libcacard_cflags" >> $config_host_mak
7598 echo "SMARTCARD_LIBS=$libcacard_libs" >> $config_host_mak
7599 fi
7600
7601 if test "$libusb" = "yes" ; then
7602 echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
7603 echo "LIBUSB_CFLAGS=$libusb_cflags" >> $config_host_mak
7604 echo "LIBUSB_LIBS=$libusb_libs" >> $config_host_mak
7605 fi
7606
7607 if test "$usb_redir" = "yes" ; then
7608 echo "CONFIG_USB_REDIR=y" >> $config_host_mak
7609 echo "USB_REDIR_CFLAGS=$usb_redir_cflags" >> $config_host_mak
7610 echo "USB_REDIR_LIBS=$usb_redir_libs" >> $config_host_mak
7611 fi
7612
7613 if test "$opengl" = "yes" ; then
7614 echo "CONFIG_OPENGL=y" >> $config_host_mak
7615 echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
7616 if test "$opengl_dmabuf" = "yes" ; then
7617 echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
7618 fi
7619 fi
7620
7621 if test "$gbm" = "yes" ; then
7622 echo "CONFIG_GBM=y" >> $config_host_mak
7623 echo "GBM_LIBS=$gbm_libs" >> $config_host_mak
7624 echo "GBM_CFLAGS=$gbm_cflags" >> $config_host_mak
7625 fi
7626
7627
7628 if test "$malloc_trim" = "yes" ; then
7629 echo "CONFIG_MALLOC_TRIM=y" >> $config_host_mak
7630 fi
7631
7632 if test "$avx2_opt" = "yes" ; then
7633 echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
7634 fi
7635
7636 if test "$avx512f_opt" = "yes" ; then
7637 echo "CONFIG_AVX512F_OPT=y" >> $config_host_mak
7638 fi
7639
7640 if test "$lzo" = "yes" ; then
7641 echo "CONFIG_LZO=y" >> $config_host_mak
7642 fi
7643
7644 if test "$snappy" = "yes" ; then
7645 echo "CONFIG_SNAPPY=y" >> $config_host_mak
7646 fi
7647
7648 if test "$bzip2" = "yes" ; then
7649 echo "CONFIG_BZIP2=y" >> $config_host_mak
7650 echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
7651 fi
7652
7653 if test "$lzfse" = "yes" ; then
7654 echo "CONFIG_LZFSE=y" >> $config_host_mak
7655 echo "LZFSE_LIBS=-llzfse" >> $config_host_mak
7656 fi
7657
7658 if test "$zstd" = "yes" ; then
7659 echo "CONFIG_ZSTD=y" >> $config_host_mak
7660 fi
7661
7662 if test "$libiscsi" = "yes" ; then
7663 echo "CONFIG_LIBISCSI=m" >> $config_host_mak
7664 echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
7665 echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
7666 fi
7667
7668 if test "$libnfs" = "yes" ; then
7669 echo "CONFIG_LIBNFS=m" >> $config_host_mak
7670 echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
7671 fi
7672
7673 if test "$seccomp" = "yes"; then
7674 echo "CONFIG_SECCOMP=y" >> $config_host_mak
7675 echo "SECCOMP_CFLAGS=$seccomp_cflags" >> $config_host_mak
7676 echo "SECCOMP_LIBS=$seccomp_libs" >> $config_host_mak
7677 fi
7678
7679 # XXX: suppress that
7680 if [ "$bsd" = "yes" ] ; then
7681 echo "CONFIG_BSD=y" >> $config_host_mak
7682 fi
7683
7684 if test "$localtime_r" = "yes" ; then
7685 echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
7686 fi
7687 if test "$qom_cast_debug" = "yes" ; then
7688 echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
7689 fi
7690 if test "$rbd" = "yes" ; then
7691 echo "CONFIG_RBD=m" >> $config_host_mak
7692 echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
7693 echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
7694 fi
7695
7696 echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
7697 if test "$coroutine_pool" = "yes" ; then
7698 echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
7699 else
7700 echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
7701 fi
7702
7703 if test "$debug_stack_usage" = "yes" ; then
7704 echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
7705 fi
7706
7707 if test "$crypto_afalg" = "yes" ; then
7708 echo "CONFIG_AF_ALG=y" >> $config_host_mak
7709 fi
7710
7711 if test "$open_by_handle_at" = "yes" ; then
7712 echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
7713 fi
7714
7715 if test "$linux_magic_h" = "yes" ; then
7716 echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
7717 fi
7718
7719 if test "$valgrind_h" = "yes" ; then
7720 echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
7721 fi
7722
7723 if test "$have_asan_iface_fiber" = "yes" ; then
7724 echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
7725 fi
7726
7727 if test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then
7728 echo "CONFIG_TSAN=y" >> $config_host_mak
7729 fi
7730
7731 if test "$has_environ" = "yes" ; then
7732 echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
7733 fi
7734
7735 if test "$cpuid_h" = "yes" ; then
7736 echo "CONFIG_CPUID_H=y" >> $config_host_mak
7737 fi
7738
7739 if test "$int128" = "yes" ; then
7740 echo "CONFIG_INT128=y" >> $config_host_mak
7741 fi
7742
7743 if test "$atomic128" = "yes" ; then
7744 echo "CONFIG_ATOMIC128=y" >> $config_host_mak
7745 fi
7746
7747 if test "$cmpxchg128" = "yes" ; then
7748 echo "CONFIG_CMPXCHG128=y" >> $config_host_mak
7749 fi
7750
7751 if test "$atomic64" = "yes" ; then
7752 echo "CONFIG_ATOMIC64=y" >> $config_host_mak
7753 fi
7754
7755 if test "$attralias" = "yes" ; then
7756 echo "CONFIG_ATTRIBUTE_ALIAS=y" >> $config_host_mak
7757 fi
7758
7759 if test "$getauxval" = "yes" ; then
7760 echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
7761 fi
7762
7763 if test "$glusterfs" = "yes" ; then
7764 echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
7765 echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
7766 echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
7767 fi
7768
7769 if test "$glusterfs_xlator_opt" = "yes" ; then
7770 echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
7771 fi
7772
7773 if test "$glusterfs_discard" = "yes" ; then
7774 echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
7775 fi
7776
7777 if test "$glusterfs_fallocate" = "yes" ; then
7778 echo "CONFIG_GLUSTERFS_FALLOCATE=y" >> $config_host_mak
7779 fi
7780
7781 if test "$glusterfs_zerofill" = "yes" ; then
7782 echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
7783 fi
7784
7785 if test "$glusterfs_ftruncate_has_stat" = "yes" ; then
7786 echo "CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT=y" >> $config_host_mak
7787 fi
7788
7789 if test "$glusterfs_iocb_has_stat" = "yes" ; then
7790 echo "CONFIG_GLUSTERFS_IOCB_HAS_STAT=y" >> $config_host_mak
7791 fi
7792
7793 if test "$libssh" = "yes" ; then
7794 echo "CONFIG_LIBSSH=m" >> $config_host_mak
7795 echo "LIBSSH_CFLAGS=$libssh_cflags" >> $config_host_mak
7796 echo "LIBSSH_LIBS=$libssh_libs" >> $config_host_mak
7797 fi
7798
7799 if test "$live_block_migration" = "yes" ; then
7800 echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
7801 fi
7802
7803 if test "$tpm" = "yes"; then
7804 echo 'CONFIG_TPM=y' >> $config_host_mak
7805 fi
7806
7807 echo "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
7808 if have_backend "nop"; then
7809 echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
7810 fi
7811 if have_backend "simple"; then
7812 echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
7813 # Set the appropriate trace file.
7814 trace_file="\"$trace_file-\" FMT_pid"
7815 fi
7816 if have_backend "log"; then
7817 echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
7818 fi
7819 if have_backend "ust"; then
7820 echo "CONFIG_TRACE_UST=y" >> $config_host_mak
7821 fi
7822 if have_backend "dtrace"; then
7823 echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
7824 if test "$trace_backend_stap" = "yes" ; then
7825 echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
7826 fi
7827 fi
7828 if have_backend "ftrace"; then
7829 if test "$linux" = "yes" ; then
7830 echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
7831 else
7832 feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
7833 fi
7834 fi
7835 if have_backend "syslog"; then
7836 if test "$posix_syslog" = "yes" ; then
7837 echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
7838 else
7839 feature_not_found "syslog(trace backend)" "syslog not available"
7840 fi
7841 fi
7842 echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
7843
7844 if test "$rdma" = "yes" ; then
7845 echo "CONFIG_RDMA=y" >> $config_host_mak
7846 echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
7847 fi
7848
7849 if test "$pvrdma" = "yes" ; then
7850 echo "CONFIG_PVRDMA=y" >> $config_host_mak
7851 fi
7852
7853 if test "$have_rtnetlink" = "yes" ; then
7854 echo "CONFIG_RTNETLINK=y" >> $config_host_mak
7855 fi
7856
7857 if test "$libxml2" = "yes" ; then
7858 echo "CONFIG_LIBXML2=y" >> $config_host_mak
7859 echo "LIBXML2_CFLAGS=$libxml2_cflags" >> $config_host_mak
7860 echo "LIBXML2_LIBS=$libxml2_libs" >> $config_host_mak
7861 fi
7862
7863 if test "$replication" = "yes" ; then
7864 echo "CONFIG_REPLICATION=y" >> $config_host_mak
7865 fi
7866
7867 if test "$have_af_vsock" = "yes" ; then
7868 echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
7869 fi
7870
7871 if test "$have_sysmacros" = "yes" ; then
7872 echo "CONFIG_SYSMACROS=y" >> $config_host_mak
7873 fi
7874
7875 if test "$have_static_assert" = "yes" ; then
7876 echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
7877 fi
7878
7879 if test "$have_utmpx" = "yes" ; then
7880 echo "HAVE_UTMPX=y" >> $config_host_mak
7881 fi
7882 if test "$have_getrandom" = "yes" ; then
7883 echo "CONFIG_GETRANDOM=y" >> $config_host_mak
7884 fi
7885 if test "$ivshmem" = "yes" ; then
7886 echo "CONFIG_IVSHMEM=y" >> $config_host_mak
7887 fi
7888 if test "$capstone" != "no" ; then
7889 echo "CONFIG_CAPSTONE=y" >> $config_host_mak
7890 fi
7891 if test "$debug_mutex" = "yes" ; then
7892 echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak
7893 fi
7894
7895 # Hold two types of flag:
7896 # CONFIG_THREAD_SETNAME_BYTHREAD - we've got a way of setting the name on
7897 # a thread we have a handle to
7898 # CONFIG_PTHREAD_SETNAME_NP_W_TID - A way of doing it on a particular
7899 # platform
7900 if test "$pthread_setname_np_w_tid" = "yes" ; then
7901 echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
7902 echo "CONFIG_PTHREAD_SETNAME_NP_W_TID=y" >> $config_host_mak
7903 elif test "$pthread_setname_np_wo_tid" = "yes" ; then
7904 echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
7905 echo "CONFIG_PTHREAD_SETNAME_NP_WO_TID=y" >> $config_host_mak
7906 fi
7907
7908 if test "$libpmem" = "yes" ; then
7909 echo "CONFIG_LIBPMEM=y" >> $config_host_mak
7910 fi
7911
7912 if test "$libdaxctl" = "yes" ; then
7913 echo "CONFIG_LIBDAXCTL=y" >> $config_host_mak
7914 fi
7915
7916 if test "$bochs" = "yes" ; then
7917 echo "CONFIG_BOCHS=y" >> $config_host_mak
7918 fi
7919 if test "$cloop" = "yes" ; then
7920 echo "CONFIG_CLOOP=y" >> $config_host_mak
7921 fi
7922 if test "$dmg" = "yes" ; then
7923 echo "CONFIG_DMG=y" >> $config_host_mak
7924 fi
7925 if test "$qcow1" = "yes" ; then
7926 echo "CONFIG_QCOW1=y" >> $config_host_mak
7927 fi
7928 if test "$vdi" = "yes" ; then
7929 echo "CONFIG_VDI=y" >> $config_host_mak
7930 fi
7931 if test "$vvfat" = "yes" ; then
7932 echo "CONFIG_VVFAT=y" >> $config_host_mak
7933 fi
7934 if test "$qed" = "yes" ; then
7935 echo "CONFIG_QED=y" >> $config_host_mak
7936 fi
7937 if test "$parallels" = "yes" ; then
7938 echo "CONFIG_PARALLELS=y" >> $config_host_mak
7939 fi
7940 if test "$sheepdog" = "yes" ; then
7941 echo "CONFIG_SHEEPDOG=y" >> $config_host_mak
7942 fi
7943 if test "$pty_h" = "yes" ; then
7944 echo "HAVE_PTY_H=y" >> $config_host_mak
7945 fi
7946 if test "$have_mlockall" = "yes" ; then
7947 echo "HAVE_MLOCKALL=y" >> $config_host_mak
7948 fi
7949 if test "$fuzzing" = "yes" ; then
7950 if test "$have_fuzzer" = "yes"; then
7951 FUZZ_LDFLAGS=" -fsanitize=fuzzer"
7952 FUZZ_CFLAGS=" -fsanitize=fuzzer"
7953 QEMU_CFLAGS="$QEMU_CFLAGS -fsanitize=fuzzer-no-link"
7954 else
7955 error_exit "Your compiler doesn't support -fsanitize=fuzzer"
7956 exit 1
7957 fi
7958 fi
7959
7960 if test "$plugins" = "yes" ; then
7961 echo "CONFIG_PLUGIN=y" >> $config_host_mak
7962 LIBS="-ldl $LIBS"
7963 # Copy the export object list to the build dir
7964 if test "$ld_dynamic_list" = "yes" ; then
7965 echo "CONFIG_HAS_LD_DYNAMIC_LIST=yes" >> $config_host_mak
7966 ld_symbols=qemu-plugins-ld.symbols
7967 cp "$source_path/plugins/qemu-plugins.symbols" $ld_symbols
7968 elif test "$ld_exported_symbols_list" = "yes" ; then
7969 echo "CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST=yes" >> $config_host_mak
7970 ld64_symbols=qemu-plugins-ld64.symbols
7971 echo "# Automatically generated by configure - do not modify" > $ld64_symbols
7972 grep 'qemu_' "$source_path/plugins/qemu-plugins.symbols" | sed 's/;//g' | \
7973 sed -E 's/^[[:space:]]*(.*)/_\1/' >> $ld64_symbols
7974 else
7975 error_exit \
7976 "If \$plugins=yes, either \$ld_dynamic_list or " \
7977 "\$ld_exported_symbols_list should have been set to 'yes'."
7978 fi
7979 fi
7980
7981 if test -n "$gdb_bin" ; then
7982 echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
7983 fi
7984
7985 if test "$secret_keyring" = "yes" ; then
7986 echo "CONFIG_SECRET_KEYRING=y" >> $config_host_mak
7987 if test "$have_keyutils" = "yes" ; then
7988 echo "CONFIG_TEST_SECRET_KEYRING=y" >> $config_host_mak
7989 fi
7990 fi
7991
7992 if test "$tcg_interpreter" = "yes"; then
7993 QEMU_INCLUDES="-iquote ${source_path}/tcg/tci $QEMU_INCLUDES"
7994 elif test "$ARCH" = "sparc64" ; then
7995 QEMU_INCLUDES="-iquote ${source_path}/tcg/sparc $QEMU_INCLUDES"
7996 elif test "$ARCH" = "s390x" ; then
7997 QEMU_INCLUDES="-iquote ${source_path}/tcg/s390 $QEMU_INCLUDES"
7998 elif test "$ARCH" = "x86_64" || test "$ARCH" = "x32" ; then
7999 QEMU_INCLUDES="-iquote ${source_path}/tcg/i386 $QEMU_INCLUDES"
8000 elif test "$ARCH" = "ppc64" ; then
8001 QEMU_INCLUDES="-iquote ${source_path}/tcg/ppc $QEMU_INCLUDES"
8002 elif test "$ARCH" = "riscv32" || test "$ARCH" = "riscv64" ; then
8003 QEMU_INCLUDES="-I${source_path}/tcg/riscv $QEMU_INCLUDES"
8004 else
8005 QEMU_INCLUDES="-iquote ${source_path}/tcg/${ARCH} $QEMU_INCLUDES"
8006 fi
8007
8008 echo "HELPERS=$helpers" >> $config_host_mak
8009 echo "TOOLS=$tools" >> $config_host_mak
8010 echo "ROMS=$roms" >> $config_host_mak
8011 echo "MAKE=$make" >> $config_host_mak
8012 echo "INSTALL=$install" >> $config_host_mak
8013 echo "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
8014 echo "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
8015 echo "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
8016 echo "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
8017 echo "PYTHON=$python" >> $config_host_mak
8018 echo "SPHINX_BUILD=$sphinx_build" >> $config_host_mak
8019 echo "SPHINX_WERROR=$sphinx_werror" >> $config_host_mak
8020 echo "GENISOIMAGE=$genisoimage" >> $config_host_mak
8021 echo "MESON=$meson" >> $config_host_mak
8022 echo "CC=$cc" >> $config_host_mak
8023 if $iasl -h > /dev/null 2>&1; then
8024 echo "IASL=$iasl" >> $config_host_mak
8025 fi
8026 echo "HOST_CC=$host_cc" >> $config_host_mak
8027 echo "CXX=$cxx" >> $config_host_mak
8028 echo "OBJCC=$objcc" >> $config_host_mak
8029 echo "AR=$ar" >> $config_host_mak
8030 echo "ARFLAGS=$ARFLAGS" >> $config_host_mak
8031 echo "AS=$as" >> $config_host_mak
8032 echo "CCAS=$ccas" >> $config_host_mak
8033 echo "CPP=$cpp" >> $config_host_mak
8034 echo "OBJCOPY=$objcopy" >> $config_host_mak
8035 echo "LD=$ld" >> $config_host_mak
8036 echo "RANLIB=$ranlib" >> $config_host_mak
8037 echo "NM=$nm" >> $config_host_mak
8038 echo "PKG_CONFIG=$pkg_config_exe" >> $config_host_mak
8039 echo "WINDRES=$windres" >> $config_host_mak
8040 echo "CFLAGS=$CFLAGS" >> $config_host_mak
8041 echo "CXXFLAGS=$CXXFLAGS" >> $config_host_mak
8042 echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
8043 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
8044 echo "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
8045 echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
8046 if test "$sparse" = "yes" ; then
8047 echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_host_mak
8048 echo "CPP := REAL_CC=\"\$(CPP)\" cgcc" >> $config_host_mak
8049 echo "CXX := REAL_CC=\"\$(CXX)\" cgcc" >> $config_host_mak
8050 echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_host_mak
8051 echo "QEMU_CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
8052 fi
8053 echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
8054 echo "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
8055 echo "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
8056 echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
8057 echo "LIBS+=$LIBS" >> $config_host_mak
8058 echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
8059 echo "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
8060 echo "EXESUF=$EXESUF" >> $config_host_mak
8061 echo "DSOSUF=$DSOSUF" >> $config_host_mak
8062 echo "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
8063 echo "LIBS_QGA+=$libs_qga" >> $config_host_mak
8064 echo "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
8065 echo "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
8066 echo "POD2MAN=$POD2MAN" >> $config_host_mak
8067 if test "$gcov" = "yes" ; then
8068 echo "CONFIG_GCOV=y" >> $config_host_mak
8069 echo "GCOV=$gcov_tool" >> $config_host_mak
8070 fi
8071
8072 if test "$libudev" != "no"; then
8073 echo "CONFIG_LIBUDEV=y" >> $config_host_mak
8074 echo "LIBUDEV_LIBS=$libudev_libs" >> $config_host_mak
8075 fi
8076 if test "$fuzzing" != "no"; then
8077 echo "CONFIG_FUZZ=y" >> $config_host_mak
8078 echo "FUZZ_CFLAGS=$FUZZ_CFLAGS" >> $config_host_mak
8079 echo "FUZZ_LDFLAGS=$FUZZ_LDFLAGS" >> $config_host_mak
8080 fi
8081
8082 if test "$edk2_blobs" = "yes" ; then
8083 echo "DECOMPRESS_EDK2_BLOBS=y" >> $config_host_mak
8084 fi
8085
8086 if test "$rng_none" = "yes"; then
8087 echo "CONFIG_RNG_NONE=y" >> $config_host_mak
8088 fi
8089
8090 # use included Linux headers
8091 if test "$linux" = "yes" ; then
8092 mkdir -p linux-headers
8093 case "$cpu" in
8094 i386|x86_64|x32)
8095 linux_arch=x86
8096 ;;
8097 ppc|ppc64|ppc64le)
8098 linux_arch=powerpc
8099 ;;
8100 s390x)
8101 linux_arch=s390
8102 ;;
8103 aarch64)
8104 linux_arch=arm64
8105 ;;
8106 mips64)
8107 linux_arch=mips
8108 ;;
8109 *)
8110 # For most CPUs the kernel architecture name and QEMU CPU name match.
8111 linux_arch="$cpu"
8112 ;;
8113 esac
8114 # For non-KVM architectures we will not have asm headers
8115 if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
8116 symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
8117 fi
8118 fi
8119
8120 for target in $target_list; do
8121 target_dir="$target"
8122 config_target_mak=$target_dir/config-target.mak
8123 target_name=$(echo $target | cut -d '-' -f 1)
8124 target_aligned_only="no"
8125 case "$target_name" in
8126 alpha|hppa|mips64el|mips64|mipsel|mips|mipsn32|mipsn32el|sh4|sh4eb|sparc|sparc64|sparc32plus|xtensa|xtensaeb)
8127 target_aligned_only="yes"
8128 ;;
8129 esac
8130 target_bigendian="no"
8131 case "$target_name" in
8132 armeb|aarch64_be|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
8133 target_bigendian="yes"
8134 ;;
8135 esac
8136 target_softmmu="no"
8137 target_user_only="no"
8138 target_linux_user="no"
8139 target_bsd_user="no"
8140 case "$target" in
8141 ${target_name}-softmmu)
8142 target_softmmu="yes"
8143 ;;
8144 ${target_name}-linux-user)
8145 target_user_only="yes"
8146 target_linux_user="yes"
8147 ;;
8148 ${target_name}-bsd-user)
8149 target_user_only="yes"
8150 target_bsd_user="yes"
8151 ;;
8152 *)
8153 error_exit "Target '$target' not recognised"
8154 exit 1
8155 ;;
8156 esac
8157
8158 mkdir -p $target_dir
8159 echo "# Automatically generated by configure - do not modify" > $config_target_mak
8160
8161 bflt="no"
8162 mttcg="no"
8163 interp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
8164 gdb_xml_files=""
8165
8166 TARGET_ARCH="$target_name"
8167 TARGET_BASE_ARCH=""
8168 TARGET_ABI_DIR=""
8169
8170 case "$target_name" in
8171 i386)
8172 mttcg="yes"
8173 gdb_xml_files="i386-32bit.xml"
8174 TARGET_SYSTBL_ABI=i386
8175 ;;
8176 x86_64)
8177 TARGET_BASE_ARCH=i386
8178 TARGET_SYSTBL_ABI=common,64
8179 mttcg="yes"
8180 gdb_xml_files="i386-64bit.xml"
8181 ;;
8182 alpha)
8183 mttcg="yes"
8184 TARGET_SYSTBL_ABI=common
8185 ;;
8186 arm|armeb)
8187 TARGET_ARCH=arm
8188 TARGET_SYSTBL_ABI=common,oabi
8189 bflt="yes"
8190 mttcg="yes"
8191 gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml arm-m-profile.xml"
8192 ;;
8193 aarch64|aarch64_be)
8194 TARGET_ARCH=aarch64
8195 TARGET_BASE_ARCH=arm
8196 bflt="yes"
8197 mttcg="yes"
8198 gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml arm-m-profile.xml"
8199 ;;
8200 avr)
8201 gdb_xml_files="avr-cpu.xml"
8202 target_compiler=$cross_cc_avr
8203 ;;
8204 cris)
8205 ;;
8206 hppa)
8207 mttcg="yes"
8208 TARGET_SYSTBL_ABI=common,32
8209 ;;
8210 lm32)
8211 ;;
8212 m68k)
8213 bflt="yes"
8214 gdb_xml_files="cf-core.xml cf-fp.xml m68k-core.xml m68k-fp.xml"
8215 TARGET_SYSTBL_ABI=common
8216 ;;
8217 microblaze|microblazeel)
8218 TARGET_ARCH=microblaze
8219 TARGET_SYSTBL_ABI=common
8220 bflt="yes"
8221 echo "TARGET_ABI32=y" >> $config_target_mak
8222 ;;
8223 mips|mipsel)
8224 mttcg="yes"
8225 TARGET_ARCH=mips
8226 echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
8227 TARGET_SYSTBL_ABI=o32
8228 ;;
8229 mipsn32|mipsn32el)
8230 mttcg="yes"
8231 TARGET_ARCH=mips64
8232 TARGET_BASE_ARCH=mips
8233 echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
8234 echo "TARGET_ABI32=y" >> $config_target_mak
8235 TARGET_SYSTBL_ABI=n32
8236 ;;
8237 mips64|mips64el)
8238 mttcg="no"
8239 TARGET_ARCH=mips64
8240 TARGET_BASE_ARCH=mips
8241 echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
8242 TARGET_SYSTBL_ABI=n64
8243 ;;
8244 moxie)
8245 ;;
8246 nios2)
8247 ;;
8248 or1k)
8249 TARGET_ARCH=openrisc
8250 TARGET_BASE_ARCH=openrisc
8251 ;;
8252 ppc)
8253 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
8254 TARGET_SYSTBL_ABI=common,nospu,32
8255 ;;
8256 ppc64)
8257 TARGET_BASE_ARCH=ppc
8258 TARGET_ABI_DIR=ppc
8259 TARGET_SYSTBL_ABI=common,nospu,64
8260 mttcg=yes
8261 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
8262 ;;
8263 ppc64le)
8264 TARGET_ARCH=ppc64
8265 TARGET_BASE_ARCH=ppc
8266 TARGET_ABI_DIR=ppc
8267 TARGET_SYSTBL_ABI=common,nospu,64
8268 mttcg=yes
8269 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
8270 ;;
8271 ppc64abi32)
8272 TARGET_ARCH=ppc64
8273 TARGET_BASE_ARCH=ppc
8274 TARGET_ABI_DIR=ppc
8275 TARGET_SYSTBL_ABI=common,nospu,32
8276 echo "TARGET_ABI32=y" >> $config_target_mak
8277 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
8278 ;;
8279 riscv32)
8280 TARGET_BASE_ARCH=riscv
8281 TARGET_ABI_DIR=riscv
8282 mttcg=yes
8283 gdb_xml_files="riscv-32bit-cpu.xml riscv-32bit-fpu.xml riscv-64bit-fpu.xml riscv-32bit-csr.xml riscv-32bit-virtual.xml"
8284 ;;
8285 riscv64)
8286 TARGET_BASE_ARCH=riscv
8287 TARGET_ABI_DIR=riscv
8288 mttcg=yes
8289 gdb_xml_files="riscv-64bit-cpu.xml riscv-32bit-fpu.xml riscv-64bit-fpu.xml riscv-64bit-csr.xml riscv-64bit-virtual.xml"
8290 ;;
8291 rx)
8292 TARGET_ARCH=rx
8293 bflt="yes"
8294 target_compiler=$cross_cc_rx
8295 gdb_xml_files="rx-core.xml"
8296 ;;
8297 sh4|sh4eb)
8298 TARGET_ARCH=sh4
8299 TARGET_SYSTBL_ABI=common
8300 bflt="yes"
8301 ;;
8302 sparc)
8303 TARGET_SYSTBL_ABI=common,32
8304 ;;
8305 sparc64)
8306 TARGET_BASE_ARCH=sparc
8307 TARGET_SYSTBL_ABI=common,64
8308 ;;
8309 sparc32plus)
8310 TARGET_ARCH=sparc64
8311 TARGET_BASE_ARCH=sparc
8312 TARGET_ABI_DIR=sparc
8313 TARGET_SYSTBL_ABI=common,32
8314 echo "TARGET_ABI32=y" >> $config_target_mak
8315 ;;
8316 s390x)
8317 TARGET_SYSTBL_ABI=common,64
8318 mttcg=yes
8319 gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml s390-cr.xml s390-virt.xml s390-gs.xml"
8320 ;;
8321 tilegx)
8322 ;;
8323 tricore)
8324 ;;
8325 unicore32)
8326 ;;
8327 xtensa|xtensaeb)
8328 TARGET_ARCH=xtensa
8329 TARGET_SYSTBL_ABI=common
8330 bflt="yes"
8331 mttcg="yes"
8332 ;;
8333 *)
8334 error_exit "Unsupported target CPU"
8335 ;;
8336 esac
8337 # TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
8338 if [ "$TARGET_BASE_ARCH" = "" ]; then
8339 TARGET_BASE_ARCH=$TARGET_ARCH
8340 fi
8341
8342 symlink "$source_path/Makefile.target" "$target_dir/Makefile"
8343
8344 upper() {
8345 echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
8346 }
8347
8348 target_arch_name="$(upper $TARGET_ARCH)"
8349 echo "TARGET_$target_arch_name=y" >> $config_target_mak
8350 echo "TARGET_NAME=$target_name" >> $config_target_mak
8351 echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
8352 if [ "$TARGET_ABI_DIR" = "" ]; then
8353 TARGET_ABI_DIR=$TARGET_ARCH
8354 fi
8355 echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
8356 if [ "$HOST_VARIANT_DIR" != "" ]; then
8357 echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
8358 fi
8359 if [ "$TARGET_SYSTBL_ABI" != "" ]; then
8360 echo "TARGET_SYSTBL_ABI=$TARGET_SYSTBL_ABI" >> $config_target_mak
8361 fi
8362
8363 if supported_xen_target $target; then
8364 echo "CONFIG_XEN=y" >> $config_target_mak
8365 echo "$target/config-devices.mak: CONFIG_XEN=y" >> $config_host_mak
8366 if test "$xen_pci_passthrough" = yes; then
8367 echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
8368 fi
8369 else
8370 echo "$target/config-devices.mak: CONFIG_XEN=n" >> $config_host_mak
8371 fi
8372 if supported_kvm_target $target; then
8373 echo "CONFIG_KVM=y" >> $config_target_mak
8374 echo "$target/config-devices.mak: CONFIG_KVM=y" >> $config_host_mak
8375 else
8376 echo "$target/config-devices.mak: CONFIG_KVM=n" >> $config_host_mak
8377 fi
8378 if supported_hax_target $target; then
8379 echo "CONFIG_HAX=y" >> $config_target_mak
8380 fi
8381 if supported_hvf_target $target; then
8382 echo "CONFIG_HVF=y" >> $config_target_mak
8383 fi
8384 if supported_whpx_target $target; then
8385 echo "CONFIG_WHPX=y" >> $config_target_mak
8386 fi
8387 if test "$target_aligned_only" = "yes" ; then
8388 echo "TARGET_ALIGNED_ONLY=y" >> $config_target_mak
8389 fi
8390 if test "$target_bigendian" = "yes" ; then
8391 echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
8392 fi
8393 if test "$target_softmmu" = "yes" ; then
8394 echo "CONFIG_SOFTMMU=y" >> $config_target_mak
8395 if test "$mttcg" = "yes" ; then
8396 echo "TARGET_SUPPORTS_MTTCG=y" >> $config_target_mak
8397 fi
8398 fi
8399 if test "$target_user_only" = "yes" ; then
8400 echo "CONFIG_USER_ONLY=y" >> $config_target_mak
8401 echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
8402 fi
8403 if test "$target_linux_user" = "yes" ; then
8404 echo "CONFIG_LINUX_USER=y" >> $config_target_mak
8405 fi
8406 list=""
8407 if test ! -z "$gdb_xml_files" ; then
8408 for x in $gdb_xml_files; do
8409 list="$list $source_path/gdb-xml/$x"
8410 done
8411 echo "TARGET_XML_FILES=$list" >> $config_target_mak
8412 fi
8413
8414 if test "$target_user_only" = "yes" && test "$bflt" = "yes"; then
8415 echo "TARGET_HAS_BFLT=y" >> $config_target_mak
8416 fi
8417 if test "$target_bsd_user" = "yes" ; then
8418 echo "CONFIG_BSD_USER=y" >> $config_target_mak
8419 fi
8420
8421
8422 # generate QEMU_CFLAGS/QEMU_LDFLAGS for targets
8423
8424 cflags=""
8425 ldflags=""
8426
8427 disas_config() {
8428 echo "CONFIG_${1}_DIS=y" >> $config_target_mak
8429 echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
8430 }
8431
8432 for i in $ARCH $TARGET_BASE_ARCH ; do
8433 case "$i" in
8434 alpha)
8435 disas_config "ALPHA"
8436 ;;
8437 aarch64)
8438 if test -n "${cxx}"; then
8439 disas_config "ARM_A64"
8440 fi
8441 ;;
8442 arm)
8443 disas_config "ARM"
8444 if test -n "${cxx}"; then
8445 disas_config "ARM_A64"
8446 fi
8447 ;;
8448 avr)
8449 disas_config "AVR"
8450 ;;
8451 cris)
8452 disas_config "CRIS"
8453 ;;
8454 hppa)
8455 disas_config "HPPA"
8456 ;;
8457 i386|x86_64|x32)
8458 disas_config "I386"
8459 ;;
8460 lm32)
8461 disas_config "LM32"
8462 ;;
8463 m68k)
8464 disas_config "M68K"
8465 ;;
8466 microblaze*)
8467 disas_config "MICROBLAZE"
8468 ;;
8469 mips*)
8470 disas_config "MIPS"
8471 if test -n "${cxx}"; then
8472 disas_config "NANOMIPS"
8473 fi
8474 ;;
8475 moxie*)
8476 disas_config "MOXIE"
8477 ;;
8478 nios2)
8479 disas_config "NIOS2"
8480 ;;
8481 or1k)
8482 disas_config "OPENRISC"
8483 ;;
8484 ppc*)
8485 disas_config "PPC"
8486 ;;
8487 riscv*)
8488 disas_config "RISCV"
8489 ;;
8490 rx)
8491 disas_config "RX"
8492 ;;
8493 s390*)
8494 disas_config "S390"
8495 ;;
8496 sh4)
8497 disas_config "SH4"
8498 ;;
8499 sparc*)
8500 disas_config "SPARC"
8501 ;;
8502 xtensa*)
8503 disas_config "XTENSA"
8504 ;;
8505 esac
8506 done
8507 if test "$tcg_interpreter" = "yes" ; then
8508 disas_config "TCI"
8509 fi
8510
8511 # Newer kernels on s390 check for an S390_PGSTE program header and
8512 # enable the pgste page table extensions in that case. This makes
8513 # the vm.allocate_pgste sysctl unnecessary. We enable this program
8514 # header if
8515 # - we build on s390x
8516 # - we build the system emulation for s390x (qemu-system-s390x)
8517 # - KVM is enabled
8518 # - the linker supports --s390-pgste
8519 if test "$TARGET_ARCH" = "s390x" && test "$target_softmmu" = "yes" && \
8520 test "$ARCH" = "s390x" && test "$kvm" = "yes"; then
8521 if ld_has --s390-pgste ; then
8522 ldflags="-Wl,--s390-pgste $ldflags"
8523 fi
8524 fi
8525
8526 echo "QEMU_LDFLAGS+=$ldflags" >> $config_target_mak
8527 echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak
8528
8529 done # for target in $targets
8530
8531 echo "PIXMAN_CFLAGS=$pixman_cflags" >> $config_host_mak
8532 echo "PIXMAN_LIBS=$pixman_libs" >> $config_host_mak
8533
8534 if [ "$fdt" = "git" ]; then
8535 echo "config-host.h: dtc/all" >> $config_host_mak
8536 fi
8537 if [ "$capstone" = "git" -o "$capstone" = "internal" ]; then
8538 echo "config-host.h: capstone/all" >> $config_host_mak
8539 fi
8540 if test -n "$LIBCAPSTONE"; then
8541 echo "LIBCAPSTONE=$LIBCAPSTONE" >> $config_host_mak
8542 fi
8543
8544 if test "$numa" = "yes"; then
8545 echo "CONFIG_NUMA=y" >> $config_host_mak
8546 fi
8547
8548 if test "$ccache_cpp2" = "yes"; then
8549 echo "export CCACHE_CPP2=y" >> $config_host_mak
8550 fi
8551
8552 if test "$safe_stack" = "yes"; then
8553 echo "CONFIG_SAFESTACK=y" >> $config_host_mak
8554 fi
8555
8556 # If we're using a separate build tree, set it up now.
8557 # DIRS are directories which we simply mkdir in the build tree;
8558 # LINKS are things to symlink back into the source tree
8559 # (these can be both files and directories).
8560 # Caution: do not add files or directories here using wildcards. This
8561 # will result in problems later if a new file matching the wildcard is
8562 # added to the source tree -- nothing will cause configure to be rerun
8563 # so the build tree will be missing the link back to the new file, and
8564 # tests might fail. Prefer to keep the relevant files in their own
8565 # directory and symlink the directory instead.
8566 DIRS="tests tests/tcg tests/tcg/lm32 tests/qapi-schema tests/qtest/libqos"
8567 DIRS="$DIRS tests/qtest tests/qemu-iotests tests/vm tests/fp tests/qgraph"
8568 DIRS="$DIRS docs docs/interop fsdev scsi"
8569 DIRS="$DIRS pc-bios/optionrom pc-bios/s390-ccw"
8570 DIRS="$DIRS roms/seabios"
8571 LINKS="Makefile"
8572 LINKS="$LINKS tests/tcg/lm32/Makefile po/Makefile"
8573 LINKS="$LINKS tests/tcg/Makefile.target tests/fp/Makefile"
8574 LINKS="$LINKS tests/plugin/Makefile"
8575 LINKS="$LINKS pc-bios/optionrom/Makefile pc-bios/keymaps"
8576 LINKS="$LINKS pc-bios/s390-ccw/Makefile"
8577 LINKS="$LINKS roms/seabios/Makefile"
8578 LINKS="$LINKS pc-bios/qemu-icon.bmp"
8579 LINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
8580 LINKS="$LINKS tests/acceptance tests/data"
8581 LINKS="$LINKS tests/qemu-iotests/check"
8582 LINKS="$LINKS python"
8583 for bios_file in \
8584 $source_path/pc-bios/*.bin \
8585 $source_path/pc-bios/*.lid \
8586 $source_path/pc-bios/*.rom \
8587 $source_path/pc-bios/*.dtb \
8588 $source_path/pc-bios/*.img \
8589 $source_path/pc-bios/openbios-* \
8590 $source_path/pc-bios/u-boot.* \
8591 $source_path/pc-bios/edk2-*.fd.bz2 \
8592 $source_path/pc-bios/palcode-*
8593 do
8594 LINKS="$LINKS pc-bios/$(basename $bios_file)"
8595 done
8596 mkdir -p $DIRS
8597 for f in $LINKS ; do
8598 if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
8599 symlink "$source_path/$f" "$f"
8600 fi
8601 done
8602
8603 (for i in $cross_cc_vars; do
8604 export $i
8605 done
8606 export target_list source_path use_containers
8607 $source_path/tests/tcg/configure.sh)
8608
8609 # temporary config to build submodules
8610 for rom in seabios; do
8611 config_mak=roms/$rom/config.mak
8612 echo "# Automatically generated by configure - do not modify" > $config_mak
8613 echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
8614 echo "AS=$as" >> $config_mak
8615 echo "CCAS=$ccas" >> $config_mak
8616 echo "CC=$cc" >> $config_mak
8617 echo "BCC=bcc" >> $config_mak
8618 echo "CPP=$cpp" >> $config_mak
8619 echo "OBJCOPY=objcopy" >> $config_mak
8620 echo "IASL=$iasl" >> $config_mak
8621 echo "LD=$ld" >> $config_mak
8622 echo "RANLIB=$ranlib" >> $config_mak
8623 done
8624
8625 # set up qemu-iotests in this build directory
8626 iotests_common_env="tests/qemu-iotests/common.env"
8627
8628 echo "# Automatically generated by configure - do not modify" > "$iotests_common_env"
8629 echo >> "$iotests_common_env"
8630 echo "export PYTHON='$python'" >> "$iotests_common_env"
8631
8632 if test "$skip_meson" = no; then
8633 rm -rf meson-private meson-info meson-logs
8634 NINJA=$PWD/ninjatool $meson setup \
8635 --prefix "$prefix" \
8636 --libdir "$libdir" \
8637 --libexecdir "$libexecdir" \
8638 --bindir "$bindir" \
8639 --includedir "$includedir" \
8640 --datadir "$datadir" \
8641 --mandir "$mandir" \
8642 --sysconfdir "$sysconfdir" \
8643 --localstatedir "$local_statedir" \
8644 -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) \
8645 -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo false; fi) \
8646 -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \
8647 -Dstrip=$(if test "$strip_opt" = yes; then echo true; else echo false; fi) \
8648 "$PWD" "$source_path"
8649
8650 if test "$?" -ne 0 ; then
8651 error_exit "meson setup failed"
8652 fi
8653 touch ninjatool.stamp
8654 fi
8655
8656 # Save the configure command line for later reuse.
8657 cat <<EOD >config.status
8658 #!/bin/sh
8659 # Generated by configure.
8660 # Run this file to recreate the current configuration.
8661 # Compiler output produced by configure, useful for debugging
8662 # configure, is in config.log if it exists.
8663 EOD
8664
8665 preserve_env() {
8666 envname=$1
8667
8668 eval envval=\$$envname
8669
8670 if test -n "$envval"
8671 then
8672 echo "$envname='$envval'" >> config.status
8673 echo "export $envname" >> config.status
8674 else
8675 echo "unset $envname" >> config.status
8676 fi
8677 }
8678
8679 # Preserve various env variables that influence what
8680 # features/build target configure will detect
8681 preserve_env AR
8682 preserve_env AS
8683 preserve_env CC
8684 preserve_env CPP
8685 preserve_env CXX
8686 preserve_env INSTALL
8687 preserve_env LD
8688 preserve_env LD_LIBRARY_PATH
8689 preserve_env LIBTOOL
8690 preserve_env MAKE
8691 preserve_env NM
8692 preserve_env OBJCOPY
8693 preserve_env PATH
8694 preserve_env PKG_CONFIG
8695 preserve_env PKG_CONFIG_LIBDIR
8696 preserve_env PKG_CONFIG_PATH
8697 preserve_env PYTHON
8698 preserve_env SDL2_CONFIG
8699 preserve_env SMBD
8700 preserve_env STRIP
8701 preserve_env WINDRES
8702
8703 printf "exec" >>config.status
8704 for i in "$0" "$@"; do
8705 test "$i" = --skip-meson || printf " '%s'" "$i" >>config.status
8706 done
8707 echo ' "$@"' >>config.status
8708 chmod +x config.status
8709
8710 rm -r "$TMPDIR1"