Merge tag 'v2.9.0-rc1'
[qemu/ar7.git] / configure
blob293dbf97eb56074667f42fced61d40fedb816b84
1 #!/bin/sh
3 # qemu configure script (c) 2003 Fabrice Bellard
6 # Unset some variables known to interfere with behavior of common tools,
7 # just as autoconf does.
8 CLICOLOR_FORCE= GREP_OPTIONS=
9 unset CLICOLOR_FORCE GREP_OPTIONS
11 # Don't allow CCACHE, if present, to use cached results of compile tests!
12 export CCACHE_RECACHE=yes
14 # Temporary directory used for files created while
15 # configure runs. Since it is in the build directory
16 # we can safely blow away any previous version of it
17 # (and we need not jump through hoops to try to delete
18 # it when configure exits.)
19 TMPDIR1="config-temp"
20 rm -rf "${TMPDIR1}"
21 mkdir -p "${TMPDIR1}"
22 if [ $? -ne 0 ]; then
23 echo "ERROR: failed to create temporary directory"
24 exit 1
27 TMPB="qemu-conf"
28 TMPC="${TMPDIR1}/${TMPB}.c"
29 TMPO="${TMPDIR1}/${TMPB}.o"
30 TMPCXX="${TMPDIR1}/${TMPB}.cxx"
31 TMPE="${TMPDIR1}/${TMPB}.exe"
32 TMPMO="${TMPDIR1}/${TMPB}.mo"
34 rm -f config.log
36 # Print a helpful header at the top of config.log
37 echo "# QEMU configure log $(date)" >> config.log
38 printf "# Configured with:" >> config.log
39 printf " '%s'" "$0" "$@" >> config.log
40 echo >> config.log
41 echo "#" >> config.log
43 error_exit() {
44 echo
45 echo "ERROR: $1"
46 while test -n "$2"; do
47 echo " $2"
48 shift
49 done
50 echo
51 exit 1
54 do_compiler() {
55 # Run the compiler, capturing its output to the log. First argument
56 # is compiler binary to execute.
57 local compiler="$1"
58 shift
59 echo $compiler "$@" >> config.log
60 $compiler "$@" >> config.log 2>&1 || return $?
61 # Test passed. If this is an --enable-werror build, rerun
62 # the test with -Werror and bail out if it fails. This
63 # makes warning-generating-errors in configure test code
64 # obvious to developers.
65 if test "$werror" != "yes"; then
66 return 0
68 # Don't bother rerunning the compile if we were already using -Werror
69 case "$*" in
70 *-Werror*)
71 return 0
73 esac
74 echo $compiler -Werror "$@" >> config.log
75 $compiler -Werror "$@" >> config.log 2>&1 && return $?
76 error_exit "configure test passed without -Werror but failed with -Werror." \
77 "This is probably a bug in the configure script. The failing command" \
78 "will be at the bottom of config.log." \
79 "You can run configure with --disable-werror to bypass this check."
82 do_cc() {
83 do_compiler "$cc" "$@"
86 do_cxx() {
87 do_compiler "$cxx" "$@"
90 update_cxxflags() {
91 # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
92 # options which some versions of GCC's C++ compiler complain about
93 # because they only make sense for C programs.
94 QEMU_CXXFLAGS=
95 for arg in $QEMU_CFLAGS; do
96 case $arg in
97 -Wno-override-init|\
98 -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
99 -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
102 QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
104 esac
105 done
108 compile_object() {
109 local_cflags="$1"
110 do_cc $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
113 compile_prog() {
114 local_cflags="$1"
115 local_ldflags="$2"
116 do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
119 # symbolically link $1 to $2. Portable version of "ln -sf".
120 symlink() {
121 rm -rf "$2"
122 mkdir -p "$(dirname "$2")"
123 ln -s "$1" "$2"
126 # check whether a command is available to this shell (may be either an
127 # executable or a builtin)
128 has() {
129 type "$1" >/dev/null 2>&1
132 # search for an executable in PATH
133 path_of() {
134 local_command="$1"
135 local_ifs="$IFS"
136 local_dir=""
138 # pathname has a dir component?
139 if [ "${local_command#*/}" != "$local_command" ]; then
140 if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
141 echo "$local_command"
142 return 0
145 if [ -z "$local_command" ]; then
146 return 1
149 IFS=:
150 for local_dir in $PATH; do
151 if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
152 echo "$local_dir/$local_command"
153 IFS="${local_ifs:-$(printf ' \t\n')}"
154 return 0
156 done
157 # not found
158 IFS="${local_ifs:-$(printf ' \t\n')}"
159 return 1
162 have_backend () {
163 echo "$trace_backends" | grep "$1" >/dev/null
166 # default parameters
167 source_path=$(dirname "$0")
168 cpu=""
169 iasl="iasl"
170 interp_prefix="/usr/gnemul/qemu-%M"
171 static="no"
172 cross_prefix=""
173 audio_drv_list=""
174 block_drv_rw_whitelist=""
175 block_drv_ro_whitelist=""
176 host_cc="cc"
177 libs_softmmu=""
178 libs_tools=""
179 audio_pt_int=""
180 audio_win_int=""
181 cc_i386=i386-pc-linux-gnu-gcc
182 libs_qga=""
183 debug_info="yes"
184 stack_protector=""
186 # Don't accept a target_list environment variable.
187 unset target_list
189 # Default value for a variable defining feature "foo".
190 # * foo="no" feature will only be used if --enable-foo arg is given
191 # * foo="" feature will be searched for, and if found, will be used
192 # unless --disable-foo is given
193 # * foo="yes" this value will only be set by --enable-foo flag.
194 # feature will searched for,
195 # if not found, configure exits with error
197 # Always add --enable-foo and --disable-foo command line args.
198 # Distributions want to ensure that several features are compiled in, and it
199 # is impossible without a --enable-foo that exits if a feature is not found.
201 bluez=""
202 brlapi=""
203 curl=""
204 curses=""
205 docs=""
206 fdt=""
207 netmap="no"
208 pixman=""
209 sdl=""
210 sdlabi=""
211 virtfs=""
212 vnc="yes"
213 sparse="no"
214 vde=""
215 vnc_sasl=""
216 vnc_jpeg=""
217 vnc_png=""
218 xen=""
219 xen_ctrl_version=""
220 xen_pv_domain_build="no"
221 xen_pci_passthrough=""
222 linux_aio=""
223 cap_ng=""
224 attr=""
225 libattr=""
226 xfs=""
228 vhost_net="no"
229 vhost_scsi="no"
230 vhost_vsock="no"
231 kvm="no"
232 hax="no"
233 rdma=""
234 gprof="no"
235 debug_tcg="no"
236 debug="no"
237 fortify_source=""
238 strip_opt="yes"
239 tcg_interpreter="no"
240 bigendian="no"
241 mingw32="no"
242 gcov="no"
243 gcov_tool="gcov"
244 EXESUF=""
245 DSOSUF=".so"
246 LDFLAGS_SHARED="-shared"
247 modules="no"
248 prefix="/usr/local"
249 mandir="\${prefix}/share/man"
250 datadir="\${prefix}/share"
251 qemu_docdir="\${prefix}/share/doc/qemu"
252 bindir="\${prefix}/bin"
253 libdir="\${prefix}/lib"
254 libexecdir="\${prefix}/libexec"
255 includedir="\${prefix}/include"
256 sysconfdir="\${prefix}/etc"
257 local_statedir="\${prefix}/var"
258 confsuffix="/qemu"
259 slirp="yes"
260 oss_lib=""
261 bsd="no"
262 haiku="no"
263 linux="no"
264 solaris="no"
265 profiler="no"
266 cocoa="no"
267 softmmu="yes"
268 linux_user="no"
269 bsd_user="no"
270 aix="no"
271 blobs="yes"
272 pkgversion=""
273 pie=""
274 qom_cast_debug="yes"
275 trace_backends="log"
276 trace_file="trace"
277 spice=""
278 rbd=""
279 smartcard=""
280 libusb=""
281 usb_redir=""
282 opengl=""
283 opengl_dmabuf="no"
284 avx2_opt="no"
285 zlib="yes"
286 lzo=""
287 snappy=""
288 bzip2=""
289 guest_agent=""
290 guest_agent_with_vss="no"
291 guest_agent_ntddscsi="no"
292 guest_agent_msi=""
293 vss_win32_sdk=""
294 win_sdk="no"
295 want_tools="yes"
296 libiscsi=""
297 libnfs=""
298 coroutine=""
299 coroutine_pool=""
300 debug_stack_usage="no"
301 seccomp=""
302 glusterfs=""
303 glusterfs_xlator_opt="no"
304 glusterfs_discard="no"
305 glusterfs_zerofill="no"
306 gtk=""
307 gtkabi=""
308 gtk_gl="no"
309 tls_priority="NORMAL"
310 gnutls=""
311 gnutls_rnd=""
312 nettle=""
313 nettle_kdf="no"
314 gcrypt=""
315 gcrypt_hmac="no"
316 gcrypt_kdf="no"
317 vte=""
318 virglrenderer=""
319 tpm="yes"
320 libssh2=""
321 numa=""
322 tcmalloc="no"
323 jemalloc="no"
324 replication="yes"
326 supported_cpu="no"
327 supported_os="no"
329 # parse CC options first
330 for opt do
331 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
332 case "$opt" in
333 --cross-prefix=*) cross_prefix="$optarg"
335 --cc=*) CC="$optarg"
337 --cxx=*) CXX="$optarg"
339 --source-path=*) source_path="$optarg"
341 --cpu=*) cpu="$optarg"
343 --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
344 EXTRA_CFLAGS="$optarg"
346 --extra-ldflags=*) LDFLAGS="$LDFLAGS $optarg"
347 EXTRA_LDFLAGS="$optarg"
349 --enable-debug-info) debug_info="yes"
351 --disable-debug-info) debug_info="no"
353 esac
354 done
355 # OS specific
356 # Using uname is really, really broken. Once we have the right set of checks
357 # we can eliminate its usage altogether.
359 # Preferred compiler:
360 # ${CC} (if set)
361 # ${cross_prefix}gcc (if cross-prefix specified)
362 # system compiler
363 if test -z "${CC}${cross_prefix}"; then
364 cc="$host_cc"
365 else
366 cc="${CC-${cross_prefix}gcc}"
369 if test -z "${CXX}${cross_prefix}"; then
370 cxx="c++"
371 else
372 cxx="${CXX-${cross_prefix}g++}"
375 ar="${AR-${cross_prefix}ar}"
376 as="${AS-${cross_prefix}as}"
377 ccas="${CCAS-$cc}"
378 cpp="${CPP-$cc -E}"
379 objcopy="${OBJCOPY-${cross_prefix}objcopy}"
380 ld="${LD-${cross_prefix}ld}"
381 nm="${NM-${cross_prefix}nm}"
382 strip="${STRIP-${cross_prefix}strip}"
383 windres="${WINDRES-${cross_prefix}windres}"
384 pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
385 query_pkg_config() {
386 "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
388 pkg_config=query_pkg_config
389 sdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
390 sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
392 # If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
393 ARFLAGS="${ARFLAGS-rv}"
395 # default flags for all hosts
396 # We use -fwrapv to tell the compiler that we require a C dialect where
397 # left shift of signed integers is well defined and has the expected
398 # 2s-complement style results. (Both clang and gcc agree that it
399 # provides these semantics.)
400 QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
401 QEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
402 QEMU_CFLAGS="-Wmissing-format-attribute $QEMU_CFLAGS"
403 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
404 QEMU_CFLAGS="-Wno-unused-parameter $QEMU_CFLAGS"
405 QEMU_CFLAGS="-Wno-missing-field-initializers $QEMU_CFLAGS"
406 QEMU_CFLAGS="-Wno-sign-compare $QEMU_CFLAGS"
407 QEMU_CFLAGS="-Wno-override-init $QEMU_CFLAGS"
408 QEMU_CFLAGS="-Wno-error=format $QEMU_CFLAGS"
409 QEMU_CFLAGS="-Wno-error=format-extra-args $QEMU_CFLAGS"
410 QEMU_CFLAGS="-Wno-error=parentheses $QEMU_CFLAGS"
411 QEMU_CFLAGS="-Wextra $QEMU_CFLAGS"
412 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
413 QEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/include"
414 if test "$debug_info" = "yes"; then
415 CFLAGS="-g $CFLAGS"
416 LDFLAGS="-g $LDFLAGS"
419 # make source path absolute
420 source_path=$(cd "$source_path"; pwd)
422 cc_macros=$($cc $QEMU_CFLAGS -E -dD - </dev/null)
424 # running configure in the source tree?
425 # we know that's the case if configure is there.
426 if test -f "./configure"; then
427 pwd_is_source_path="y"
428 else
429 pwd_is_source_path="n"
432 check_define() {
433 rm -f $TMPC
434 cat > $TMPC <<EOF
435 #if !defined($1)
436 #error $1 not defined
437 #endif
438 int main(void) { return 0; }
440 compile_object
443 check_include() {
444 cat > $TMPC <<EOF
445 #include <$1>
446 int main(void) { return 0; }
448 compile_object
451 write_c_skeleton() {
452 cat > $TMPC <<EOF
453 int main(void) { return 0; }
457 if check_define __linux__ ; then
458 targetos="Linux"
459 elif check_define _WIN32 ; then
460 targetos='MINGW32'
461 elif check_define __OpenBSD__ ; then
462 targetos='OpenBSD'
463 elif check_define __sun__ ; then
464 targetos='SunOS'
465 elif check_define __HAIKU__ ; then
466 targetos='Haiku'
467 else
468 targetos=$(uname -s)
471 # Some host OSes need non-standard checks for which CPU to use.
472 # Note that these checks are broken for cross-compilation: if you're
473 # cross-compiling to one of these OSes then you'll need to specify
474 # the correct CPU with the --cpu option.
475 case $targetos in
476 Darwin)
477 # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
478 # run 64-bit userspace code.
479 # If the user didn't specify a CPU explicitly and the kernel says this is
480 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
481 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
482 cpu="x86_64"
485 SunOS)
486 # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
487 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
488 cpu="x86_64"
490 esac
492 if test ! -z "$cpu" ; then
493 # command line argument
495 elif check_define __i386__ ; then
496 cpu="i386"
497 elif check_define __x86_64__ ; then
498 if check_define __ILP32__ ; then
499 cpu="x32"
500 else
501 cpu="x86_64"
503 elif check_define __sparc__ ; then
504 if check_define __arch64__ ; then
505 cpu="sparc64"
506 else
507 cpu="sparc"
509 elif check_define _ARCH_PPC ; then
510 if check_define _ARCH_PPC64 ; then
511 cpu="ppc64"
512 else
513 cpu="ppc"
515 elif check_define __mips__ ; then
516 if check_define __mips64 ; then
517 cpu="mips64"
518 else
519 cpu="mips"
521 elif check_define __ia64__ ; then
522 cpu="ia64"
523 elif check_define __s390__ ; then
524 if check_define __s390x__ ; then
525 cpu="s390x"
526 else
527 cpu="s390"
529 elif check_define __arm__ ; then
530 cpu="arm"
531 elif check_define __aarch64__ ; then
532 cpu="aarch64"
533 else
534 cpu=$(uname -m)
537 ARCH=
538 # Normalise host CPU name and set ARCH.
539 # Note that this case should only have supported host CPUs, not guests.
540 case "$cpu" in
541 ppc|ppc64|s390|s390x|x32)
542 cpu="$cpu"
543 supported_cpu="yes"
545 ia64|sparc64)
546 cpu="$cpu"
548 i386|i486|i586|i686|i86pc|BePC)
549 cpu="i386"
550 supported_cpu="yes"
552 x86_64|amd64)
553 cpu="x86_64"
554 supported_cpu="yes"
556 armv*b|armv*l|arm)
557 cpu="arm"
558 supported_cpu="yes"
560 aarch64)
561 cpu="aarch64"
562 supported_cpu="yes"
564 mips*)
565 cpu="mips"
566 if check_define __MIPSEL__ ; then
567 cpu="${cpu}el"
569 supported_cpu="yes"
571 sparc|sun4[cdmuv])
572 cpu="sparc"
574 sh4)
575 cpu="sh4"
578 # This will result in either an error or falling back to TCI later
579 ARCH=unknown
581 esac
582 if test -z "$ARCH"; then
583 ARCH="$cpu"
586 # OS specific
588 # host *BSD for user mode
589 HOST_VARIANT_DIR=""
591 case $targetos in
592 MINGW32*)
593 mingw32="yes"
594 hax="yes"
595 audio_possible_drivers="dsound sdl"
596 if check_include dsound.h; then
597 audio_drv_list="dsound"
598 else
599 audio_drv_list=""
601 supported_os="yes"
603 GNU/kFreeBSD)
604 bsd="yes"
605 audio_drv_list="oss"
606 audio_possible_drivers="oss sdl pa"
608 FreeBSD)
609 bsd="yes"
610 make="${MAKE-gmake}"
611 audio_drv_list="oss"
612 audio_possible_drivers="oss sdl pa"
613 # needed for kinfo_getvmmap(3) in libutil.h
614 LIBS="-lutil $LIBS"
615 # needed for kinfo_getproc
616 libs_qga="-lutil $libs_qga"
617 netmap="" # enable netmap autodetect
618 HOST_VARIANT_DIR="freebsd"
619 supported_os="yes"
621 DragonFly)
622 bsd="yes"
623 make="${MAKE-gmake}"
624 audio_drv_list="oss"
625 audio_possible_drivers="oss sdl pa"
626 HOST_VARIANT_DIR="dragonfly"
628 NetBSD)
629 bsd="yes"
630 make="${MAKE-gmake}"
631 audio_drv_list="oss"
632 audio_possible_drivers="oss sdl"
633 oss_lib="-lossaudio"
634 HOST_VARIANT_DIR="netbsd"
636 OpenBSD)
637 bsd="yes"
638 make="${MAKE-gmake}"
639 audio_drv_list="sdl"
640 audio_possible_drivers="sdl"
641 HOST_VARIANT_DIR="openbsd"
643 Darwin)
644 bsd="yes"
645 darwin="yes"
646 hax="yes"
647 LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
648 if [ "$cpu" = "x86_64" ] ; then
649 QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
650 LDFLAGS="-arch x86_64 $LDFLAGS"
652 cocoa="yes"
653 audio_drv_list="coreaudio"
654 audio_possible_drivers="coreaudio sdl"
655 LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
656 libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
657 # Disable attempts to use ObjectiveC features in os/object.h since they
658 # won't work when we're compiling with gcc as a C compiler.
659 QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
660 HOST_VARIANT_DIR="darwin"
661 supported_os="yes"
663 SunOS)
664 solaris="yes"
665 make="${MAKE-gmake}"
666 install="${INSTALL-ginstall}"
667 ld="gld"
668 smbd="${SMBD-/usr/sfw/sbin/smbd}"
669 needs_libsunmath="no"
670 solarisrev=$(uname -r | cut -f2 -d.)
671 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
672 if test "$solarisrev" -le 9 ; then
673 if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
674 needs_libsunmath="yes"
675 QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
676 LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
677 LIBS="-lsunmath $LIBS"
678 else
679 error_exit "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without" \
680 "libsunmath from the Sun Studio compilers tools, due to a lack of" \
681 "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86" \
682 "Studio 11 can be downloaded from www.sun.com."
686 if test -f /usr/include/sys/soundcard.h ; then
687 audio_drv_list="oss"
689 audio_possible_drivers="oss sdl"
690 # needed for CMSG_ macros in sys/socket.h
691 QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
692 # needed for TIOCWIN* defines in termios.h
693 QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
694 QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
695 solarisnetlibs="-lsocket -lnsl -lresolv"
696 LIBS="$solarisnetlibs $LIBS"
697 libs_qga="$solarisnetlibs $libs_qga"
699 AIX)
700 aix="yes"
701 make="${MAKE-gmake}"
703 Haiku)
704 haiku="yes"
705 QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
706 LIBS="-lposix_error_mapper -lnetwork $LIBS"
708 Linux)
709 audio_drv_list="oss"
710 audio_possible_drivers="oss alsa sdl pa"
711 linux="yes"
712 linux_user="yes"
713 kvm="yes"
714 vhost_net="yes"
715 vhost_scsi="yes"
716 vhost_vsock="yes"
717 QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
718 supported_os="yes"
721 error_exit "Unsupported host OS $targetos"
723 esac
725 if [ "$bsd" = "yes" ] ; then
726 if [ "$darwin" != "yes" ] ; then
727 bsd_user="yes"
731 : ${make=${MAKE-make}}
732 : ${install=${INSTALL-install}}
733 : ${python=${PYTHON-python}}
734 : ${smbd=${SMBD-/usr/sbin/smbd}}
736 # Default objcc to clang if available, otherwise use CC
737 if has clang; then
738 objcc=clang
739 else
740 objcc="$cc"
743 if test "$mingw32" = "yes" ; then
744 EXESUF=".exe"
745 DSOSUF=".dll"
746 QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
747 # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
748 QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
749 # MinGW-w64 needs _POSIX defined.
750 QEMU_CFLAGS="-D_POSIX=1 $QEMU_CFLAGS"
751 # MinGW needs -mthreads for TLS and macro _MT.
752 QEMU_CFLAGS="-mthreads $QEMU_CFLAGS"
753 QEMU_CFLAGS="-I\$(SRC_PATH)/hosts/w32/include $QEMU_CFLAGS"
754 LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
755 write_c_skeleton;
756 if compile_prog "" "-liberty" ; then
757 LIBS="-liberty $LIBS"
759 prefix="c:/Program Files/QEMU"
760 mandir="\${prefix}"
761 datadir="\${prefix}"
762 qemu_docdir="\${prefix}"
763 bindir="\${prefix}"
764 sysconfdir="\${prefix}"
765 local_statedir=
766 confsuffix=""
767 libs_qga="-lws2_32 -lwinmm -lpowrprof -liphlpapi -lnetapi32 $libs_qga"
770 werror=""
772 for opt do
773 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
774 case "$opt" in
775 --help|-h) show_help=yes
777 --version|-V) exec cat $source_path/VERSION
779 --prefix=*) prefix="$optarg"
781 --interp-prefix=*) interp_prefix="$optarg"
783 --source-path=*)
785 --cross-prefix=*)
787 --cc=*)
789 --host-cc=*) host_cc="$optarg"
791 --cxx=*)
793 --iasl=*) iasl="$optarg"
795 --objcc=*) objcc="$optarg"
797 --make=*) make="$optarg"
799 --install=*) install="$optarg"
801 --python=*) python="$optarg"
803 --gcov=*) gcov_tool="$optarg"
805 --smbd=*) smbd="$optarg"
807 --extra-cflags=*)
809 --extra-ldflags=*)
811 --enable-debug-info)
813 --disable-debug-info)
815 --enable-modules)
816 modules="yes"
818 --disable-modules)
819 modules="no"
821 --cpu=*)
823 --target-list=*) target_list="$optarg"
825 --enable-trace-backends=*) trace_backends="$optarg"
827 # XXX: backwards compatibility
828 --enable-trace-backend=*) trace_backends="$optarg"
830 --with-trace-file=*) trace_file="$optarg"
832 --enable-gprof) gprof="yes"
834 --enable-gcov) gcov="yes"
836 --static)
837 static="yes"
838 LDFLAGS="-static $LDFLAGS"
839 QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
841 --mandir=*) mandir="$optarg"
843 --bindir=*) bindir="$optarg"
845 --libdir=*) libdir="$optarg"
847 --libexecdir=*) libexecdir="$optarg"
849 --includedir=*) includedir="$optarg"
851 --datadir=*) datadir="$optarg"
853 --with-confsuffix=*) confsuffix="$optarg"
855 --docdir=*) qemu_docdir="$optarg"
857 --sysconfdir=*) sysconfdir="$optarg"
859 --localstatedir=*) local_statedir="$optarg"
861 --sbindir=*|--sharedstatedir=*|\
862 --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
863 --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
864 # These switches are silently ignored, for compatibility with
865 # autoconf-generated configure scripts. This allows QEMU's
866 # configure to be used by RPM and similar macros that set
867 # lots of directory switches by default.
869 --with-system-pixman) pixman="system"
871 --without-system-pixman) pixman="internal"
873 --without-pixman) pixman="none"
875 --disable-sdl) sdl="no"
877 --enable-sdl) sdl="yes"
879 --with-sdlabi=*) sdlabi="$optarg"
881 --disable-qom-cast-debug) qom_cast_debug="no"
883 --enable-qom-cast-debug) qom_cast_debug="yes"
885 --disable-virtfs) virtfs="no"
887 --enable-virtfs) virtfs="yes"
889 --disable-vnc) vnc="no"
891 --enable-vnc) vnc="yes"
893 --oss-lib=*) oss_lib="$optarg"
895 --audio-drv-list=*) audio_drv_list="$optarg"
897 --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
899 --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
901 --enable-debug-tcg) debug_tcg="yes"
903 --disable-debug-tcg) debug_tcg="no"
905 --enable-debug)
906 # Enable debugging options that aren't excessively noisy
907 debug_tcg="yes"
908 debug="yes"
909 strip_opt="no"
910 fortify_source="no"
912 --enable-sparse) sparse="yes"
914 --disable-sparse) sparse="no"
916 --disable-strip) strip_opt="no"
918 --disable-vnc-sasl) vnc_sasl="no"
920 --enable-vnc-sasl) vnc_sasl="yes"
922 --disable-vnc-jpeg) vnc_jpeg="no"
924 --enable-vnc-jpeg) vnc_jpeg="yes"
926 --disable-vnc-png) vnc_png="no"
928 --enable-vnc-png) vnc_png="yes"
930 --disable-slirp) slirp="no"
932 --disable-vde) vde="no"
934 --enable-vde) vde="yes"
936 --disable-netmap) netmap="no"
938 --enable-netmap) netmap="yes"
940 --disable-xen) xen="no"
942 --enable-xen) xen="yes"
944 --disable-xen-pci-passthrough) xen_pci_passthrough="no"
946 --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
948 --disable-xen-pv-domain-build) xen_pv_domain_build="no"
950 --enable-xen-pv-domain-build) xen_pv_domain_build="yes"
952 --disable-brlapi) brlapi="no"
954 --enable-brlapi) brlapi="yes"
956 --disable-bluez) bluez="no"
958 --enable-bluez) bluez="yes"
960 --disable-kvm) kvm="no"
962 --enable-kvm) kvm="yes"
964 --disable-hax) hax="no"
966 --enable-hax) hax="yes"
968 --disable-tcg-interpreter) tcg_interpreter="no"
970 --enable-tcg-interpreter) tcg_interpreter="yes"
972 --disable-cap-ng) cap_ng="no"
974 --enable-cap-ng) cap_ng="yes"
976 --disable-spice) spice="no"
978 --enable-spice) spice="yes"
980 --disable-libiscsi) libiscsi="no"
982 --enable-libiscsi) libiscsi="yes"
984 --disable-libnfs) libnfs="no"
986 --enable-libnfs) libnfs="yes"
988 --enable-profiler) profiler="yes"
990 --disable-cocoa) cocoa="no"
992 --enable-cocoa)
993 cocoa="yes" ;
994 audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
996 --disable-system) softmmu="no"
998 --enable-system) softmmu="yes"
1000 --disable-user)
1001 linux_user="no" ;
1002 bsd_user="no" ;
1004 --enable-user) ;;
1005 --disable-linux-user) linux_user="no"
1007 --enable-linux-user) linux_user="yes"
1009 --disable-bsd-user) bsd_user="no"
1011 --enable-bsd-user) bsd_user="yes"
1013 --enable-pie) pie="yes"
1015 --disable-pie) pie="no"
1017 --enable-werror) werror="yes"
1019 --disable-werror) werror="no"
1021 --enable-stack-protector) stack_protector="yes"
1023 --disable-stack-protector) stack_protector="no"
1025 --disable-curses) curses="no"
1027 --enable-curses) curses="yes"
1029 --disable-curl) curl="no"
1031 --enable-curl) curl="yes"
1033 --disable-fdt) fdt="no"
1035 --enable-fdt) fdt="yes"
1037 --disable-linux-aio) linux_aio="no"
1039 --enable-linux-aio) linux_aio="yes"
1041 --disable-attr) attr="no"
1043 --enable-attr) attr="yes"
1045 --disable-blobs) blobs="no"
1047 --with-pkgversion=*) pkgversion=" ($optarg)"
1049 --with-coroutine=*) coroutine="$optarg"
1051 --disable-coroutine-pool) coroutine_pool="no"
1053 --enable-coroutine-pool) coroutine_pool="yes"
1055 --enable-debug-stack-usage) debug_stack_usage="yes"
1057 --disable-docs) docs="no"
1059 --enable-docs) docs="yes"
1061 --disable-vhost-net) vhost_net="no"
1063 --enable-vhost-net) vhost_net="yes"
1065 --disable-vhost-scsi) vhost_scsi="no"
1067 --enable-vhost-scsi) vhost_scsi="yes"
1069 --disable-vhost-vsock) vhost_vsock="no"
1071 --enable-vhost-vsock) vhost_vsock="yes"
1073 --disable-opengl) opengl="no"
1075 --enable-opengl) opengl="yes"
1077 --disable-rbd) rbd="no"
1079 --enable-rbd) rbd="yes"
1081 --disable-xfsctl) xfs="no"
1083 --enable-xfsctl) xfs="yes"
1085 --disable-smartcard) smartcard="no"
1087 --enable-smartcard) smartcard="yes"
1089 --disable-libusb) libusb="no"
1091 --enable-libusb) libusb="yes"
1093 --disable-usb-redir) usb_redir="no"
1095 --enable-usb-redir) usb_redir="yes"
1097 --disable-zlib-test) zlib="no"
1099 --disable-lzo) lzo="no"
1101 --enable-lzo) lzo="yes"
1103 --disable-snappy) snappy="no"
1105 --enable-snappy) snappy="yes"
1107 --disable-bzip2) bzip2="no"
1109 --enable-bzip2) bzip2="yes"
1111 --enable-guest-agent) guest_agent="yes"
1113 --disable-guest-agent) guest_agent="no"
1115 --enable-guest-agent-msi) guest_agent_msi="yes"
1117 --disable-guest-agent-msi) guest_agent_msi="no"
1119 --with-vss-sdk) vss_win32_sdk=""
1121 --with-vss-sdk=*) vss_win32_sdk="$optarg"
1123 --without-vss-sdk) vss_win32_sdk="no"
1125 --with-win-sdk) win_sdk=""
1127 --with-win-sdk=*) win_sdk="$optarg"
1129 --without-win-sdk) win_sdk="no"
1131 --enable-tools) want_tools="yes"
1133 --disable-tools) want_tools="no"
1135 --enable-seccomp) seccomp="yes"
1137 --disable-seccomp) seccomp="no"
1139 --disable-glusterfs) glusterfs="no"
1141 --enable-glusterfs) glusterfs="yes"
1143 --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
1144 echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1146 --enable-vhdx|--disable-vhdx)
1147 echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1149 --enable-uuid|--disable-uuid)
1150 echo "$0: $opt is obsolete, UUID support is always built" >&2
1152 --disable-gtk) gtk="no"
1154 --enable-gtk) gtk="yes"
1156 --tls-priority=*) tls_priority="$optarg"
1158 --disable-gnutls) gnutls="no"
1160 --enable-gnutls) gnutls="yes"
1162 --disable-nettle) nettle="no"
1164 --enable-nettle) nettle="yes"
1166 --disable-gcrypt) gcrypt="no"
1168 --enable-gcrypt) gcrypt="yes"
1170 --enable-rdma) rdma="yes"
1172 --disable-rdma) rdma="no"
1174 --with-gtkabi=*) gtkabi="$optarg"
1176 --disable-vte) vte="no"
1178 --enable-vte) vte="yes"
1180 --disable-virglrenderer) virglrenderer="no"
1182 --enable-virglrenderer) virglrenderer="yes"
1184 --disable-tpm) tpm="no"
1186 --enable-tpm) tpm="yes"
1188 --disable-libssh2) libssh2="no"
1190 --enable-libssh2) libssh2="yes"
1192 --disable-numa) numa="no"
1194 --enable-numa) numa="yes"
1196 --disable-tcmalloc) tcmalloc="no"
1198 --enable-tcmalloc) tcmalloc="yes"
1200 --disable-jemalloc) jemalloc="no"
1202 --enable-jemalloc) jemalloc="yes"
1204 --disable-replication) replication="no"
1206 --enable-replication) replication="yes"
1209 echo "ERROR: unknown option $opt"
1210 echo "Try '$0 --help' for more information"
1211 exit 1
1213 esac
1214 done
1216 if ! has $python; then
1217 error_exit "Python not found. Use --python=/path/to/python"
1220 # Note that if the Python conditional here evaluates True we will exit
1221 # with status 1 which is a shell 'false' value.
1222 if ! $python -c 'import sys; sys.exit(sys.version_info < (2,6) or sys.version_info >= (3,))'; then
1223 error_exit "Cannot use '$python', Python 2.6 or later is required." \
1224 "Note that Python 3 or later is not yet supported." \
1225 "Use --python=/path/to/python to specify a supported Python."
1228 # Suppress writing compiled files
1229 python="$python -B"
1231 case "$cpu" in
1232 ppc)
1233 CPU_CFLAGS="-m32"
1234 LDFLAGS="-m32 $LDFLAGS"
1236 ppc64)
1237 CPU_CFLAGS="-m64"
1238 LDFLAGS="-m64 $LDFLAGS"
1240 sparc)
1241 LDFLAGS="-m32 $LDFLAGS"
1242 CPU_CFLAGS="-m32 -mcpu=ultrasparc"
1244 sparc64)
1245 LDFLAGS="-m64 $LDFLAGS"
1246 CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1248 s390)
1249 CPU_CFLAGS="-m31"
1250 LDFLAGS="-m31 $LDFLAGS"
1252 s390x)
1253 CPU_CFLAGS="-m64"
1254 LDFLAGS="-m64 $LDFLAGS"
1256 i386)
1257 CPU_CFLAGS="-m32"
1258 LDFLAGS="-m32 $LDFLAGS"
1259 cc_i386='$(CC) -m32'
1261 x86_64)
1262 # ??? Only extremely old AMD cpus do not have cmpxchg16b.
1263 # If we truly care, we should simply detect this case at
1264 # runtime and generate the fallback to serial emulation.
1265 CPU_CFLAGS="-m64 -mcx16"
1266 LDFLAGS="-m64 $LDFLAGS"
1267 cc_i386='$(CC) -m32'
1269 x32)
1270 CPU_CFLAGS="-mx32"
1271 LDFLAGS="-mx32 $LDFLAGS"
1272 cc_i386='$(CC) -m32'
1274 # No special flags required for other host CPUs
1275 esac
1277 QEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
1278 EXTRA_CFLAGS="$CPU_CFLAGS $EXTRA_CFLAGS"
1280 # For user-mode emulation the host arch has to be one we explicitly
1281 # support, even if we're using TCI.
1282 if [ "$ARCH" = "unknown" ]; then
1283 bsd_user="no"
1284 linux_user="no"
1287 default_target_list=""
1289 mak_wilds=""
1291 if [ "$softmmu" = "yes" ]; then
1292 mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
1294 if [ "$linux_user" = "yes" ]; then
1295 mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
1297 if [ "$bsd_user" = "yes" ]; then
1298 mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
1301 for config in $mak_wilds; do
1302 default_target_list="${default_target_list} $(basename "$config" .mak)"
1303 done
1305 if test x"$show_help" = x"yes" ; then
1306 cat << EOF
1308 Usage: configure [options]
1309 Options: [defaults in brackets after descriptions]
1311 Standard options:
1312 --help print this message
1313 --prefix=PREFIX install in PREFIX [$prefix]
1314 --interp-prefix=PREFIX where to find shared libraries, etc.
1315 use %M for cpu name [$interp_prefix]
1316 --target-list=LIST set target list (default: build everything)
1317 $(echo Available targets: $default_target_list | \
1318 fold -s -w 53 | sed -e 's/^/ /')
1320 Advanced options (experts only):
1321 --source-path=PATH path of source code [$source_path]
1322 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
1323 --cc=CC use C compiler CC [$cc]
1324 --iasl=IASL use ACPI compiler IASL [$iasl]
1325 --host-cc=CC use C compiler CC [$host_cc] for code run at
1326 build time
1327 --cxx=CXX use C++ compiler CXX [$cxx]
1328 --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
1329 --extra-cflags=CFLAGS append extra C compiler flags QEMU_CFLAGS
1330 --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS
1331 --make=MAKE use specified make [$make]
1332 --install=INSTALL use specified install [$install]
1333 --python=PYTHON use specified python [$python]
1334 --smbd=SMBD use specified smbd [$smbd]
1335 --static enable static build [$static]
1336 --mandir=PATH install man pages in PATH
1337 --datadir=PATH install firmware in PATH$confsuffix
1338 --docdir=PATH install documentation in PATH$confsuffix
1339 --bindir=PATH install binaries in PATH
1340 --libdir=PATH install libraries in PATH
1341 --sysconfdir=PATH install config in PATH$confsuffix
1342 --localstatedir=PATH install local state in PATH (set at runtime on win32)
1343 --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
1344 --enable-debug enable common debug build options
1345 --disable-strip disable stripping binaries
1346 --disable-werror disable compilation abort on warning
1347 --disable-stack-protector disable compiler-provided stack protection
1348 --audio-drv-list=LIST set audio drivers list:
1349 Available drivers: $audio_possible_drivers
1350 --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L
1351 --block-drv-rw-whitelist=L
1352 set block driver read-write whitelist
1353 (affects only QEMU, not qemu-img)
1354 --block-drv-ro-whitelist=L
1355 set block driver read-only whitelist
1356 (affects only QEMU, not qemu-img)
1357 --enable-trace-backends=B Set trace backend
1358 Available backends: $($python $source_path/scripts/tracetool.py --list-backends)
1359 --with-trace-file=NAME Full PATH,NAME of file to store traces
1360 Default:trace-<pid>
1361 --disable-slirp disable SLIRP userspace network connectivity
1362 --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
1363 --oss-lib path to OSS library
1364 --cpu=CPU Build for host CPU [$cpu]
1365 --with-coroutine=BACKEND coroutine backend. Supported options:
1366 gthread, ucontext, sigaltstack, windows
1367 --enable-gcov enable test coverage analysis with gcov
1368 --gcov=GCOV use specified gcov [$gcov_tool]
1369 --disable-blobs disable installing provided firmware blobs
1370 --with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent
1371 --with-win-sdk=SDK-path path to Windows Platform SDK (to build VSS .tlb)
1372 --tls-priority default TLS protocol/cipher priority string
1373 --enable-gprof QEMU profiling with gprof
1374 --enable-profiler profiler support
1375 --enable-xen-pv-domain-build
1376 xen pv domain builder
1377 --enable-debug-stack-usage
1378 track the maximum stack usage of stacks created by qemu_alloc_stack
1380 Optional features, enabled with --enable-FEATURE and
1381 disabled with --disable-FEATURE, default is enabled if available:
1383 system all system emulation targets
1384 user supported user emulation targets
1385 linux-user all linux usermode emulation targets
1386 bsd-user all BSD usermode emulation targets
1387 docs build documentation
1388 guest-agent build the QEMU Guest Agent
1389 guest-agent-msi build guest agent Windows MSI installation package
1390 pie Position Independent Executables
1391 modules modules support
1392 debug-tcg TCG debugging (default is disabled)
1393 debug-info debugging information
1394 sparse sparse checker
1396 gnutls GNUTLS cryptography support
1397 nettle nettle cryptography support
1398 gcrypt libgcrypt cryptography support
1399 sdl SDL UI
1400 --with-sdlabi select preferred SDL ABI 1.2 or 2.0
1401 gtk gtk UI
1402 --with-gtkabi select preferred GTK ABI 2.0 or 3.0
1403 vte vte support for the gtk UI
1404 curses curses UI
1405 vnc VNC UI support
1406 vnc-sasl SASL encryption for VNC server
1407 vnc-jpeg JPEG lossy compression for VNC server
1408 vnc-png PNG compression for VNC server
1409 cocoa Cocoa UI (Mac OS X only)
1410 virtfs VirtFS
1411 xen xen backend driver support
1412 xen-pci-passthrough
1413 brlapi BrlAPI (Braile)
1414 curl curl connectivity
1415 fdt fdt device tree
1416 bluez bluez stack connectivity
1417 kvm KVM acceleration support
1418 hax HAX acceleration support
1419 rdma RDMA-based migration support
1420 vde support for vde network
1421 netmap support for netmap network
1422 linux-aio Linux AIO support
1423 cap-ng libcap-ng support
1424 attr attr and xattr support
1425 vhost-net vhost-net acceleration support
1426 spice spice
1427 rbd rados block device (rbd)
1428 libiscsi iscsi support
1429 libnfs nfs support
1430 smartcard smartcard support (libcacard)
1431 libusb libusb (for usb passthrough)
1432 usb-redir usb network redirection support
1433 lzo support of lzo compression library
1434 snappy support of snappy compression library
1435 bzip2 support of bzip2 compression library
1436 (for reading bzip2-compressed dmg images)
1437 seccomp seccomp support
1438 coroutine-pool coroutine freelist (better performance)
1439 glusterfs GlusterFS backend
1440 tpm TPM support
1441 libssh2 ssh block device support
1442 numa libnuma support
1443 tcmalloc tcmalloc support
1444 jemalloc jemalloc support
1445 replication replication support
1446 vhost-vsock virtio sockets device support
1447 opengl opengl support
1448 virglrenderer virgl rendering support
1449 xfsctl xfsctl support
1450 qom-cast-debug cast debugging support
1451 tools build qemu-io, qemu-nbd and qemu-image tools
1453 NOTE: The object files are built at the place where configure is launched
1455 exit 0
1458 # Now we have handled --enable-tcg-interpreter and know we're not just
1459 # printing the help message, bail out if the host CPU isn't supported.
1460 if test "$ARCH" = "unknown"; then
1461 if test "$tcg_interpreter" = "yes" ; then
1462 echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1463 else
1464 error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1468 # Consult white-list to determine whether to enable werror
1469 # by default. Only enable by default for git builds
1470 if test -z "$werror" ; then
1471 if test -d "$source_path/.git" -a \
1472 \( "$linux" = "yes" -o "$mingw32" = "yes" \) ; then
1473 werror="yes"
1474 else
1475 werror="no"
1479 # check that the C compiler works.
1480 write_c_skeleton;
1481 if compile_object ; then
1482 : C compiler works ok
1483 else
1484 error_exit "\"$cc\" either does not exist or does not work"
1486 if ! compile_prog ; then
1487 error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
1490 # Check that the C++ compiler exists and works with the C compiler
1491 if has $cxx; then
1492 cat > $TMPC <<EOF
1493 int c_function(void);
1494 int main(void) { return c_function(); }
1497 compile_object
1499 cat > $TMPCXX <<EOF
1500 extern "C" {
1501 int c_function(void);
1503 int c_function(void) { return 42; }
1506 update_cxxflags
1508 if do_cxx $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $LDFLAGS; then
1509 # C++ compiler $cxx works ok with C compiler $cc
1511 else
1512 echo "C++ compiler $cxx does not work with C compiler $cc"
1513 echo "Disabling C++ specific optional code"
1514 cxx=
1516 else
1517 echo "No C++ compiler available; disabling C++ specific optional code"
1518 cxx=
1521 gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
1522 gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
1523 gcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1524 gcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
1525 gcc_flags="-Wno-initializer-overrides $gcc_flags"
1526 gcc_flags="-Wno-string-plus-int $gcc_flags"
1527 # Note that we do not add -Werror to gcc_flags here, because that would
1528 # enable it for all configure tests. If a configure test failed due
1529 # to -Werror this would just silently disable some features,
1530 # so it's too error prone.
1532 cc_has_warning_flag() {
1533 write_c_skeleton;
1535 # Use the positive sense of the flag when testing for -Wno-wombat
1536 # support (gcc will happily accept the -Wno- form of unknown
1537 # warning options).
1538 optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
1539 compile_prog "-Werror $optflag" ""
1542 for flag in $gcc_flags; do
1543 if cc_has_warning_flag $flag ; then
1544 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1546 done
1548 if test "$mingw32" = "yes"; then
1549 stack_protector="no"
1551 if test "$stack_protector" != "no"; then
1552 cat > $TMPC << EOF
1553 int main(int argc, char *argv[])
1555 char arr[64], *p = arr, *c = argv[0];
1556 while (*c) {
1557 *p++ = *c++;
1559 return 0;
1562 gcc_flags="-fstack-protector-strong -fstack-protector-all"
1563 sp_on=0
1564 for flag in $gcc_flags; do
1565 # We need to check both a compile and a link, since some compiler
1566 # setups fail only on a .c->.o compile and some only at link time
1567 if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
1568 compile_prog "-Werror $flag" ""; then
1569 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1570 sp_on=1
1571 break
1573 done
1574 if test "$stack_protector" = yes; then
1575 if test $sp_on = 0; then
1576 error_exit "Stack protector not supported"
1581 # Workaround for http://gcc.gnu.org/PR55489. Happens with -fPIE/-fPIC and
1582 # large functions that use global variables. The bug is in all releases of
1583 # GCC, but it became particularly acute in 4.6.x and 4.7.x. It is fixed in
1584 # 4.7.3 and 4.8.0. We should be able to delete this at the end of 2013.
1585 cat > $TMPC << EOF
1586 #if __GNUC__ == 4 && (__GNUC_MINOR__ == 6 || (__GNUC_MINOR__ == 7 && __GNUC_PATCHLEVEL__ <= 2))
1587 int main(void) { return 0; }
1588 #else
1589 #error No bug in this compiler.
1590 #endif
1592 if compile_prog "-Werror -fno-gcse" "" ; then
1593 TRANSLATE_OPT_CFLAGS=-fno-gcse
1596 if test "$static" = "yes" ; then
1597 if test "$modules" = "yes" ; then
1598 error_exit "static and modules are mutually incompatible"
1600 if test "$pie" = "yes" ; then
1601 error_exit "static and pie are mutually incompatible"
1602 else
1603 pie="no"
1607 # Unconditional check for compiler __thread support
1608 cat > $TMPC << EOF
1609 static __thread int tls_var;
1610 int main(void) { return tls_var; }
1613 if ! compile_prog "-Werror" "" ; then
1614 error_exit "Your compiler does not support the __thread specifier for " \
1615 "Thread-Local Storage (TLS). Please upgrade to a version that does."
1618 if test "$pie" = ""; then
1619 case "$cpu-$targetos" in
1620 i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
1623 pie="no"
1625 esac
1628 if test "$pie" != "no" ; then
1629 cat > $TMPC << EOF
1631 #ifdef __linux__
1632 # define THREAD __thread
1633 #else
1634 # define THREAD
1635 #endif
1637 static THREAD int tls_var;
1639 int main(void) { return tls_var; }
1642 if compile_prog "-fPIE -DPIE" "-pie"; then
1643 QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
1644 LDFLAGS="-pie $LDFLAGS"
1645 pie="yes"
1646 if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
1647 LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
1649 else
1650 if test "$pie" = "yes"; then
1651 error_exit "PIE not available due to missing toolchain support"
1652 else
1653 echo "Disabling PIE due to missing toolchain support"
1654 pie="no"
1658 if compile_prog "-Werror -fno-pie" "-nopie"; then
1659 CFLAGS_NOPIE="-fno-pie"
1660 LDFLAGS_NOPIE="-nopie"
1664 ##########################################
1665 # __sync_fetch_and_and requires at least -march=i486. Many toolchains
1666 # use i686 as default anyway, but for those that don't, an explicit
1667 # specification is necessary
1669 if test "$cpu" = "i386"; then
1670 cat > $TMPC << EOF
1671 static int sfaa(int *ptr)
1673 return __sync_fetch_and_and(ptr, 0);
1676 int main(void)
1678 int val = 42;
1679 val = __sync_val_compare_and_swap(&val, 0, 1);
1680 sfaa(&val);
1681 return val;
1684 if ! compile_prog "" "" ; then
1685 QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
1689 #########################################
1690 # Solaris specific configure tool chain decisions
1692 if test "$solaris" = "yes" ; then
1693 if has $install; then
1695 else
1696 error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
1697 "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
1698 "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1700 if test "$(path_of $install)" = "/usr/sbin/install" ; then
1701 error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
1702 "try ginstall from the GNU fileutils available from www.blastwave.org" \
1703 "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1705 if has ar; then
1707 else
1708 if test -f /usr/ccs/bin/ar ; then
1709 error_exit "No path includes ar" \
1710 "Add /usr/ccs/bin to your path and rerun configure"
1712 error_exit "No path includes ar"
1716 if test -z "${target_list+xxx}" ; then
1717 target_list="$default_target_list"
1718 else
1719 target_list=$(echo "$target_list" | sed -e 's/,/ /g')
1722 # Check that we recognised the target name; this allows a more
1723 # friendly error message than if we let it fall through.
1724 for target in $target_list; do
1725 case " $default_target_list " in
1726 *" $target "*)
1729 error_exit "Unknown target name '$target'"
1731 esac
1732 done
1734 # see if system emulation was really requested
1735 case " $target_list " in
1736 *"-softmmu "*) softmmu=yes
1738 *) softmmu=no
1740 esac
1742 feature_not_found() {
1743 feature=$1
1744 remedy=$2
1746 error_exit "User requested feature $feature" \
1747 "configure was not able to find it." \
1748 "$remedy"
1751 # ---
1752 # big/little endian test
1753 cat > $TMPC << EOF
1754 short big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
1755 short little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
1756 extern int foo(short *, short *);
1757 int main(int argc, char *argv[]) {
1758 return foo(big_endian, little_endian);
1762 if compile_object ; then
1763 if grep -q BiGeNdIaN $TMPO ; then
1764 bigendian="yes"
1765 elif grep -q LiTtLeEnDiAn $TMPO ; then
1766 bigendian="no"
1767 else
1768 echo big/little test failed
1770 else
1771 echo big/little test failed
1774 ##########################################
1775 # cocoa implies not SDL or GTK
1776 # (the cocoa UI code currently assumes it is always the active UI
1777 # and doesn't interact well with other UI frontend code)
1778 if test "$cocoa" = "yes"; then
1779 if test "$sdl" = "yes"; then
1780 error_exit "Cocoa and SDL UIs cannot both be enabled at once"
1782 if test "$gtk" = "yes"; then
1783 error_exit "Cocoa and GTK UIs cannot both be enabled at once"
1785 gtk=no
1786 sdl=no
1789 # Some versions of Mac OS X incorrectly define SIZE_MAX
1790 cat > $TMPC << EOF
1791 #include <stdint.h>
1792 #include <stdio.h>
1793 int main(int argc, char *argv[]) {
1794 return printf("%zu", SIZE_MAX);
1797 have_broken_size_max=no
1798 if ! compile_object -Werror ; then
1799 have_broken_size_max=yes
1802 ##########################################
1803 # L2TPV3 probe
1805 cat > $TMPC <<EOF
1806 #include <sys/socket.h>
1807 #include <linux/ip.h>
1808 int main(void) { return sizeof(struct mmsghdr); }
1810 if compile_prog "" "" ; then
1811 l2tpv3=yes
1812 else
1813 l2tpv3=no
1816 ##########################################
1817 # MinGW / Mingw-w64 localtime_r/gmtime_r check
1819 if test "$mingw32" = "yes"; then
1820 # Some versions of MinGW / Mingw-w64 lack localtime_r
1821 # and gmtime_r entirely.
1823 # Some versions of Mingw-w64 define a macro for
1824 # localtime_r/gmtime_r.
1826 # Some versions of Mingw-w64 will define functions
1827 # for localtime_r/gmtime_r, but only if you have
1828 # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
1829 # though, unistd.h and pthread.h both define
1830 # that for you.
1832 # So this #undef localtime_r and #include <unistd.h>
1833 # are not in fact redundant.
1834 cat > $TMPC << EOF
1835 #include <unistd.h>
1836 #include <time.h>
1837 #undef localtime_r
1838 int main(void) { localtime_r(NULL, NULL); return 0; }
1840 if compile_prog "" "" ; then
1841 localtime_r="yes"
1842 else
1843 localtime_r="no"
1847 ##########################################
1848 # pkg-config probe
1850 if ! has "$pkg_config_exe"; then
1851 error_exit "pkg-config binary '$pkg_config_exe' not found"
1854 ##########################################
1855 # NPTL probe
1857 if test "$linux_user" = "yes"; then
1858 cat > $TMPC <<EOF
1859 #include <sched.h>
1860 #include <linux/futex.h>
1861 int main(void) {
1862 #if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1863 #error bork
1864 #endif
1865 return 0;
1868 if ! compile_object ; then
1869 feature_not_found "nptl" "Install glibc and linux kernel headers."
1873 ##########################################
1874 # avx2 optimization requirement check
1876 cat > $TMPC << EOF
1877 #pragma GCC push_options
1878 #pragma GCC target("avx2")
1879 #include <cpuid.h>
1880 #include <immintrin.h>
1881 static int bar(void *a) {
1882 __m256i x = *(__m256i *)a;
1883 return _mm256_testz_si256(x, x);
1885 int main(int argc, char *argv[]) { return bar(argv[0]); }
1887 if compile_object "" ; then
1888 avx2_opt="yes"
1891 ##########################################
1892 # lzo check
1894 if test "$lzo" != "no" ; then
1895 cat > $TMPC << EOF
1896 #include <lzo/lzo1x.h>
1897 int main(void) { lzo_version(); return 0; }
1899 if compile_prog "" "-llzo2" ; then
1900 libs_softmmu="$libs_softmmu -llzo2"
1901 lzo="yes"
1902 else
1903 if test "$lzo" = "yes"; then
1904 feature_not_found "liblzo2" "Install liblzo2 devel"
1906 lzo="no"
1910 ##########################################
1911 # snappy check
1913 if test "$snappy" != "no" ; then
1914 cat > $TMPC << EOF
1915 #include <snappy-c.h>
1916 int main(void) { snappy_max_compressed_length(4096); return 0; }
1918 if compile_prog "" "-lsnappy" ; then
1919 libs_softmmu="$libs_softmmu -lsnappy"
1920 snappy="yes"
1921 else
1922 if test "$snappy" = "yes"; then
1923 feature_not_found "libsnappy" "Install libsnappy devel"
1925 snappy="no"
1929 ##########################################
1930 # bzip2 check
1932 if test "$bzip2" != "no" ; then
1933 cat > $TMPC << EOF
1934 #include <bzlib.h>
1935 int main(void) { BZ2_bzlibVersion(); return 0; }
1937 if compile_prog "" "-lbz2" ; then
1938 bzip2="yes"
1939 else
1940 if test "$bzip2" = "yes"; then
1941 feature_not_found "libbzip2" "Install libbzip2 devel"
1943 bzip2="no"
1947 ##########################################
1948 # libseccomp check
1950 if test "$seccomp" != "no" ; then
1951 case "$cpu" in
1952 i386|x86_64)
1953 libseccomp_minver="2.1.0"
1955 mips)
1956 libseccomp_minver="2.2.0"
1958 arm|aarch64)
1959 libseccomp_minver="2.2.3"
1961 ppc|ppc64)
1962 libseccomp_minver="2.3.0"
1965 libseccomp_minver=""
1967 esac
1969 if test "$libseccomp_minver" != "" &&
1970 $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
1971 libs_softmmu="$libs_softmmu $($pkg_config --libs libseccomp)"
1972 QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags libseccomp)"
1973 seccomp="yes"
1974 else
1975 if test "$seccomp" = "yes" ; then
1976 if test "$libseccomp_minver" != "" ; then
1977 feature_not_found "libseccomp" \
1978 "Install libseccomp devel >= $libseccomp_minver"
1979 else
1980 feature_not_found "libseccomp" \
1981 "libseccomp is not supported for host cpu $cpu"
1984 seccomp="no"
1987 ##########################################
1988 # xen probe
1990 if test "$xen" != "no" ; then
1991 xen_libs="-lxenstore -lxenctrl -lxenguest"
1992 xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
1994 # First we test whether Xen headers and libraries are available.
1995 # If no, we are done and there is no Xen support.
1996 # If yes, more tests are run to detect the Xen version.
1998 # Xen (any)
1999 cat > $TMPC <<EOF
2000 #include <xenctrl.h>
2001 int main(void) {
2002 return 0;
2005 if ! compile_prog "" "$xen_libs" ; then
2006 # Xen not found
2007 if test "$xen" = "yes" ; then
2008 feature_not_found "xen" "Install xen devel"
2010 xen=no
2012 # Xen unstable
2013 elif
2014 cat > $TMPC <<EOF &&
2016 * If we have stable libs the we don't want the libxc compat
2017 * layers, regardless of what CFLAGS we may have been given.
2019 * Also, check if xengnttab_grant_copy_segment_t is defined and
2020 * grant copy operation is implemented.
2022 #undef XC_WANT_COMPAT_EVTCHN_API
2023 #undef XC_WANT_COMPAT_GNTTAB_API
2024 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2025 #include <xenctrl.h>
2026 #include <xenstore.h>
2027 #include <xenevtchn.h>
2028 #include <xengnttab.h>
2029 #include <xenforeignmemory.h>
2030 #include <stdint.h>
2031 #include <xen/hvm/hvm_info_table.h>
2032 #if !defined(HVM_MAX_VCPUS)
2033 # error HVM_MAX_VCPUS not defined
2034 #endif
2035 int main(void) {
2036 xc_interface *xc = NULL;
2037 xenforeignmemory_handle *xfmem;
2038 xenevtchn_handle *xe;
2039 xengnttab_handle *xg;
2040 xen_domain_handle_t handle;
2041 xengnttab_grant_copy_segment_t* seg = NULL;
2043 xs_daemon_open();
2045 xc = xc_interface_open(0, 0, 0);
2046 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2047 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2048 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2049 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2050 xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2052 xfmem = xenforeignmemory_open(0, 0);
2053 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2055 xe = xenevtchn_open(0, 0);
2056 xenevtchn_fd(xe);
2058 xg = xengnttab_open(0, 0);
2059 xengnttab_grant_copy(xg, 0, seg);
2061 return 0;
2064 compile_prog "" "$xen_libs $xen_stable_libs"
2065 then
2066 xen_ctrl_version=480
2067 xen=yes
2068 elif
2069 cat > $TMPC <<EOF &&
2071 * If we have stable libs the we don't want the libxc compat
2072 * layers, regardless of what CFLAGS we may have been given.
2074 #undef XC_WANT_COMPAT_EVTCHN_API
2075 #undef XC_WANT_COMPAT_GNTTAB_API
2076 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2077 #include <xenctrl.h>
2078 #include <xenstore.h>
2079 #include <xenevtchn.h>
2080 #include <xengnttab.h>
2081 #include <xenforeignmemory.h>
2082 #include <stdint.h>
2083 #include <xen/hvm/hvm_info_table.h>
2084 #if !defined(HVM_MAX_VCPUS)
2085 # error HVM_MAX_VCPUS not defined
2086 #endif
2087 int main(void) {
2088 xc_interface *xc = NULL;
2089 xenforeignmemory_handle *xfmem;
2090 xenevtchn_handle *xe;
2091 xengnttab_handle *xg;
2092 xen_domain_handle_t handle;
2094 xs_daemon_open();
2096 xc = xc_interface_open(0, 0, 0);
2097 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2098 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2099 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2100 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2101 xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2103 xfmem = xenforeignmemory_open(0, 0);
2104 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2106 xe = xenevtchn_open(0, 0);
2107 xenevtchn_fd(xe);
2109 xg = xengnttab_open(0, 0);
2110 xengnttab_map_grant_ref(xg, 0, 0, 0);
2112 return 0;
2115 compile_prog "" "$xen_libs $xen_stable_libs"
2116 then
2117 xen_ctrl_version=471
2118 xen=yes
2119 elif
2120 cat > $TMPC <<EOF &&
2121 #include <xenctrl.h>
2122 #include <stdint.h>
2123 int main(void) {
2124 xc_interface *xc = NULL;
2125 xen_domain_handle_t handle;
2126 xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2127 return 0;
2130 compile_prog "" "$xen_libs"
2131 then
2132 xen_ctrl_version=470
2133 xen=yes
2135 # Xen 4.6
2136 elif
2137 cat > $TMPC <<EOF &&
2138 #include <xenctrl.h>
2139 #include <xenstore.h>
2140 #include <stdint.h>
2141 #include <xen/hvm/hvm_info_table.h>
2142 #if !defined(HVM_MAX_VCPUS)
2143 # error HVM_MAX_VCPUS not defined
2144 #endif
2145 int main(void) {
2146 xc_interface *xc;
2147 xs_daemon_open();
2148 xc = xc_interface_open(0, 0, 0);
2149 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2150 xc_gnttab_open(NULL, 0);
2151 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2152 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2153 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2154 xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2155 return 0;
2158 compile_prog "" "$xen_libs"
2159 then
2160 xen_ctrl_version=460
2161 xen=yes
2163 # Xen 4.5
2164 elif
2165 cat > $TMPC <<EOF &&
2166 #include <xenctrl.h>
2167 #include <xenstore.h>
2168 #include <stdint.h>
2169 #include <xen/hvm/hvm_info_table.h>
2170 #if !defined(HVM_MAX_VCPUS)
2171 # error HVM_MAX_VCPUS not defined
2172 #endif
2173 int main(void) {
2174 xc_interface *xc;
2175 xs_daemon_open();
2176 xc = xc_interface_open(0, 0, 0);
2177 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2178 xc_gnttab_open(NULL, 0);
2179 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2180 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2181 xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
2182 return 0;
2185 compile_prog "" "$xen_libs"
2186 then
2187 xen_ctrl_version=450
2188 xen=yes
2190 elif
2191 cat > $TMPC <<EOF &&
2192 #include <xenctrl.h>
2193 #include <xenstore.h>
2194 #include <stdint.h>
2195 #include <xen/hvm/hvm_info_table.h>
2196 #if !defined(HVM_MAX_VCPUS)
2197 # error HVM_MAX_VCPUS not defined
2198 #endif
2199 int main(void) {
2200 xc_interface *xc;
2201 xs_daemon_open();
2202 xc = xc_interface_open(0, 0, 0);
2203 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2204 xc_gnttab_open(NULL, 0);
2205 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2206 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2207 return 0;
2210 compile_prog "" "$xen_libs"
2211 then
2212 xen_ctrl_version=420
2213 xen=yes
2215 else
2216 if test "$xen" = "yes" ; then
2217 feature_not_found "xen (unsupported version)" \
2218 "Install a supported xen (xen 4.2 or newer)"
2220 xen=no
2223 if test "$xen" = yes; then
2224 if test $xen_ctrl_version -ge 471 ; then
2225 libs_softmmu="$xen_stable_libs $libs_softmmu"
2227 libs_softmmu="$xen_libs $libs_softmmu"
2231 if test "$xen_pci_passthrough" != "no"; then
2232 if test "$xen" = "yes" && test "$linux" = "yes"; then
2233 xen_pci_passthrough=yes
2234 else
2235 if test "$xen_pci_passthrough" = "yes"; then
2236 error_exit "User requested feature Xen PCI Passthrough" \
2237 " but this feature requires /sys from Linux"
2239 xen_pci_passthrough=no
2243 if test "$xen_pv_domain_build" = "yes" &&
2244 test "$xen" != "yes"; then
2245 error_exit "User requested Xen PV domain builder support" \
2246 "which requires Xen support."
2249 ##########################################
2250 # Sparse probe
2251 if test "$sparse" != "no" ; then
2252 if has cgcc; then
2253 sparse=yes
2254 else
2255 if test "$sparse" = "yes" ; then
2256 feature_not_found "sparse" "Install sparse binary"
2258 sparse=no
2262 ##########################################
2263 # X11 probe
2264 x11_cflags=
2265 x11_libs=-lX11
2266 if $pkg_config --exists "x11"; then
2267 x11_cflags=$($pkg_config --cflags x11)
2268 x11_libs=$($pkg_config --libs x11)
2271 ##########################################
2272 # GTK probe
2274 if test "$gtkabi" = ""; then
2275 # The GTK ABI was not specified explicitly, so try whether 2.0 is available.
2276 # Use 3.0 as a fallback if that is available.
2277 if $pkg_config --exists "gtk+-2.0 >= 2.18.0"; then
2278 gtkabi=2.0
2279 elif $pkg_config --exists "gtk+-3.0 >= 3.0.0"; then
2280 gtkabi=3.0
2281 else
2282 gtkabi=2.0
2286 if test "$gtk" != "no"; then
2287 gtkpackage="gtk+-$gtkabi"
2288 gtkx11package="gtk+-x11-$gtkabi"
2289 if test "$gtkabi" = "3.0" ; then
2290 gtkversion="3.0.0"
2291 else
2292 gtkversion="2.18.0"
2294 if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
2295 gtk_cflags=$($pkg_config --cflags $gtkpackage)
2296 gtk_libs=$($pkg_config --libs $gtkpackage)
2297 gtk_version=$($pkg_config --modversion $gtkpackage)
2298 if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
2299 gtk_cflags="$gtk_cflags $x11_cflags"
2300 gtk_libs="$gtk_libs $x11_libs"
2302 libs_softmmu="$gtk_libs $libs_softmmu"
2303 gtk="yes"
2304 elif test "$gtk" = "yes"; then
2305 feature_not_found "gtk" "Install gtk2 or gtk3 devel"
2306 else
2307 gtk="no"
2312 ##########################################
2313 # GNUTLS probe
2315 gnutls_works() {
2316 # Unfortunately some distros have bad pkg-config information for gnutls
2317 # such that it claims to exist but you get a compiler error if you try
2318 # to use the options returned by --libs. Specifically, Ubuntu for --static
2319 # builds doesn't work:
2320 # https://bugs.launchpad.net/ubuntu/+source/gnutls26/+bug/1478035
2322 # So sanity check the cflags/libs before assuming gnutls can be used.
2323 if ! $pkg_config --exists "gnutls"; then
2324 return 1
2327 write_c_skeleton
2328 compile_prog "$($pkg_config --cflags gnutls)" "$($pkg_config --libs gnutls)"
2331 gnutls_gcrypt=no
2332 gnutls_nettle=no
2333 if test "$gnutls" != "no"; then
2334 if gnutls_works; then
2335 gnutls_cflags=$($pkg_config --cflags gnutls)
2336 gnutls_libs=$($pkg_config --libs gnutls)
2337 libs_softmmu="$gnutls_libs $libs_softmmu"
2338 libs_tools="$gnutls_libs $libs_tools"
2339 QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
2340 gnutls="yes"
2342 # gnutls_rnd requires >= 2.11.0
2343 if $pkg_config --exists "gnutls >= 2.11.0"; then
2344 gnutls_rnd="yes"
2345 else
2346 gnutls_rnd="no"
2349 if $pkg_config --exists 'gnutls >= 3.0'; then
2350 gnutls_gcrypt=no
2351 gnutls_nettle=yes
2352 elif $pkg_config --exists 'gnutls >= 2.12'; then
2353 case $($pkg_config --libs --static gnutls) in
2354 *gcrypt*)
2355 gnutls_gcrypt=yes
2356 gnutls_nettle=no
2358 *nettle*)
2359 gnutls_gcrypt=no
2360 gnutls_nettle=yes
2363 gnutls_gcrypt=yes
2364 gnutls_nettle=no
2366 esac
2367 else
2368 gnutls_gcrypt=yes
2369 gnutls_nettle=no
2371 elif test "$gnutls" = "yes"; then
2372 feature_not_found "gnutls" "Install gnutls devel"
2373 else
2374 gnutls="no"
2375 gnutls_rnd="no"
2377 else
2378 gnutls_rnd="no"
2382 # If user didn't give a --disable/enable-gcrypt flag,
2383 # then mark as disabled if user requested nettle
2384 # explicitly, or if gnutls links to nettle
2385 if test -z "$gcrypt"
2386 then
2387 if test "$nettle" = "yes" || test "$gnutls_nettle" = "yes"
2388 then
2389 gcrypt="no"
2393 # If user didn't give a --disable/enable-nettle flag,
2394 # then mark as disabled if user requested gcrypt
2395 # explicitly, or if gnutls links to gcrypt
2396 if test -z "$nettle"
2397 then
2398 if test "$gcrypt" = "yes" || test "$gnutls_gcrypt" = "yes"
2399 then
2400 nettle="no"
2404 has_libgcrypt_config() {
2405 if ! has "libgcrypt-config"
2406 then
2407 return 1
2410 if test -n "$cross_prefix"
2411 then
2412 host=$(libgcrypt-config --host)
2413 if test "$host-" != $cross_prefix
2414 then
2415 return 1
2419 return 0
2422 if test "$gcrypt" != "no"; then
2423 if has_libgcrypt_config; then
2424 gcrypt_cflags=$(libgcrypt-config --cflags)
2425 gcrypt_libs=$(libgcrypt-config --libs)
2426 # Debian has remove -lgpg-error from libgcrypt-config
2427 # as it "spreads unnecessary dependencies" which in
2428 # turn breaks static builds...
2429 if test "$static" = "yes"
2430 then
2431 gcrypt_libs="$gcrypt_libs -lgpg-error"
2433 libs_softmmu="$gcrypt_libs $libs_softmmu"
2434 libs_tools="$gcrypt_libs $libs_tools"
2435 QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
2436 gcrypt="yes"
2437 if test -z "$nettle"; then
2438 nettle="no"
2441 cat > $TMPC << EOF
2442 #include <gcrypt.h>
2443 int main(void) {
2444 gcry_kdf_derive(NULL, 0, GCRY_KDF_PBKDF2,
2445 GCRY_MD_SHA256,
2446 NULL, 0, 0, 0, NULL);
2447 return 0;
2450 if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
2451 gcrypt_kdf=yes
2454 cat > $TMPC << EOF
2455 #include <gcrypt.h>
2456 int main(void) {
2457 gcry_mac_hd_t handle;
2458 gcry_mac_open(&handle, GCRY_MAC_HMAC_MD5,
2459 GCRY_MAC_FLAG_SECURE, NULL);
2460 return 0;
2463 if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
2464 gcrypt_hmac=yes
2466 else
2467 if test "$gcrypt" = "yes"; then
2468 feature_not_found "gcrypt" "Install gcrypt devel"
2469 else
2470 gcrypt="no"
2476 if test "$nettle" != "no"; then
2477 if $pkg_config --exists "nettle"; then
2478 nettle_cflags=$($pkg_config --cflags nettle)
2479 nettle_libs=$($pkg_config --libs nettle)
2480 nettle_version=$($pkg_config --modversion nettle)
2481 libs_softmmu="$nettle_libs $libs_softmmu"
2482 libs_tools="$nettle_libs $libs_tools"
2483 QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
2484 nettle="yes"
2486 cat > $TMPC << EOF
2487 #include <stddef.h>
2488 #include <nettle/pbkdf2.h>
2489 int main(void) {
2490 pbkdf2_hmac_sha256(8, NULL, 1000, 8, NULL, 8, NULL);
2491 return 0;
2494 if compile_prog "$nettle_cflags" "$nettle_libs" ; then
2495 nettle_kdf=yes
2497 else
2498 if test "$nettle" = "yes"; then
2499 feature_not_found "nettle" "Install nettle devel"
2500 else
2501 nettle="no"
2506 if test "$gcrypt" = "yes" && test "$nettle" = "yes"
2507 then
2508 error_exit "Only one of gcrypt & nettle can be enabled"
2511 ##########################################
2512 # libtasn1 - only for the TLS creds/session test suite
2514 tasn1=yes
2515 tasn1_cflags=""
2516 tasn1_libs=""
2517 if $pkg_config --exists "libtasn1"; then
2518 tasn1_cflags=$($pkg_config --cflags libtasn1)
2519 tasn1_libs=$($pkg_config --libs libtasn1)
2520 else
2521 tasn1=no
2525 ##########################################
2526 # getifaddrs (for tests/test-io-channel-socket )
2528 have_ifaddrs_h=yes
2529 if ! check_include "ifaddrs.h" ; then
2530 have_ifaddrs_h=no
2533 ##########################################
2534 # VTE probe
2536 if test "$vte" != "no"; then
2537 if test "$gtkabi" = "3.0"; then
2538 vteminversion="0.32.0"
2539 if $pkg_config --exists "vte-2.91"; then
2540 vtepackage="vte-2.91"
2541 else
2542 vtepackage="vte-2.90"
2544 else
2545 vtepackage="vte"
2546 vteminversion="0.24.0"
2548 if $pkg_config --exists "$vtepackage >= $vteminversion"; then
2549 vte_cflags=$($pkg_config --cflags $vtepackage)
2550 vte_libs=$($pkg_config --libs $vtepackage)
2551 vteversion=$($pkg_config --modversion $vtepackage)
2552 libs_softmmu="$vte_libs $libs_softmmu"
2553 vte="yes"
2554 elif test "$vte" = "yes"; then
2555 if test "$gtkabi" = "3.0"; then
2556 feature_not_found "vte" "Install libvte-2.90/2.91 devel"
2557 else
2558 feature_not_found "vte" "Install libvte devel"
2560 else
2561 vte="no"
2565 ##########################################
2566 # SDL probe
2568 # Look for sdl configuration program (pkg-config or sdl-config). Try
2569 # sdl-config even without cross prefix, and favour pkg-config over sdl-config.
2571 if test "$sdlabi" = ""; then
2572 if $pkg_config --exists "sdl"; then
2573 sdlabi=1.2
2574 elif $pkg_config --exists "sdl2"; then
2575 sdlabi=2.0
2576 else
2577 sdlabi=1.2
2581 if test $sdlabi = "2.0"; then
2582 sdl_config=$sdl2_config
2583 sdlname=sdl2
2584 sdlconfigname=sdl2_config
2585 elif test $sdlabi = "1.2"; then
2586 sdlname=sdl
2587 sdlconfigname=sdl_config
2588 else
2589 error_exit "Unknown sdlabi $sdlabi, must be 1.2 or 2.0"
2592 if test "$(basename $sdl_config)" != $sdlconfigname && ! has ${sdl_config}; then
2593 sdl_config=$sdlconfigname
2596 if $pkg_config $sdlname --exists; then
2597 sdlconfig="$pkg_config $sdlname"
2598 sdlversion=$($sdlconfig --modversion 2>/dev/null)
2599 elif has ${sdl_config}; then
2600 sdlconfig="$sdl_config"
2601 sdlversion=$($sdlconfig --version)
2602 else
2603 if test "$sdl" = "yes" ; then
2604 feature_not_found "sdl" "Install SDL devel"
2606 sdl=no
2608 if test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
2609 echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
2612 sdl_too_old=no
2613 if test "$sdl" != "no" ; then
2614 cat > $TMPC << EOF
2615 #include <SDL.h>
2616 #undef main /* We don't want SDL to override our main() */
2617 int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
2619 sdl_cflags=$($sdlconfig --cflags 2>/dev/null)
2620 if test "$static" = "yes" ; then
2621 sdl_libs=$($sdlconfig --static-libs 2>/dev/null)
2622 else
2623 sdl_libs=$($sdlconfig --libs 2>/dev/null)
2625 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
2626 if test $(echo $sdlversion | sed 's/[^0-9]//g') -lt 121 ; then
2627 sdl_too_old=yes
2628 else
2629 sdl=yes
2632 # static link with sdl ? (note: sdl.pc's --static --libs is broken)
2633 if test "$sdl" = "yes" -a "$static" = "yes" ; then
2634 if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
2635 sdl_libs="$sdl_libs $(aalib-config --static-libs 2>/dev/null)"
2636 sdl_cflags="$sdl_cflags $(aalib-config --cflags 2>/dev/null)"
2638 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
2640 else
2641 sdl=no
2643 fi # static link
2644 else # sdl not found
2645 if test "$sdl" = "yes" ; then
2646 feature_not_found "sdl" "Install SDL devel"
2648 sdl=no
2649 fi # sdl compile test
2652 if test "$sdl" = "yes" ; then
2653 cat > $TMPC <<EOF
2654 #include <SDL.h>
2655 #if defined(SDL_VIDEO_DRIVER_X11)
2656 #include <X11/XKBlib.h>
2657 #else
2658 #error No x11 support
2659 #endif
2660 int main(void) { return 0; }
2662 if compile_prog "$sdl_cflags $x11_cflags" "$sdl_libs $x11_libs" ; then
2663 sdl_cflags="$sdl_cflags $x11_cflags"
2664 sdl_libs="$sdl_libs $x11_libs"
2666 libs_softmmu="$sdl_libs $libs_softmmu"
2669 ##########################################
2670 # RDMA needs OpenFabrics libraries
2671 if test "$rdma" != "no" ; then
2672 cat > $TMPC <<EOF
2673 #include <rdma/rdma_cma.h>
2674 int main(void) { return 0; }
2676 rdma_libs="-lrdmacm -libverbs"
2677 if compile_prog "" "$rdma_libs" ; then
2678 rdma="yes"
2679 libs_softmmu="$libs_softmmu $rdma_libs"
2680 else
2681 if test "$rdma" = "yes" ; then
2682 error_exit \
2683 " OpenFabrics librdmacm/libibverbs not present." \
2684 " Your options:" \
2685 " (1) Fast: Install infiniband packages from your distro." \
2686 " (2) Cleanest: Install libraries from www.openfabrics.org" \
2687 " (3) Also: Install softiwarp if you don't have RDMA hardware"
2689 rdma="no"
2693 ##########################################
2694 # VNC SASL detection
2695 if test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
2696 cat > $TMPC <<EOF
2697 #include <sasl/sasl.h>
2698 #include <stdio.h>
2699 int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
2701 # Assuming Cyrus-SASL installed in /usr prefix
2702 vnc_sasl_cflags=""
2703 vnc_sasl_libs="-lsasl2"
2704 if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
2705 vnc_sasl=yes
2706 libs_softmmu="$vnc_sasl_libs $libs_softmmu"
2707 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
2708 else
2709 if test "$vnc_sasl" = "yes" ; then
2710 feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
2712 vnc_sasl=no
2716 ##########################################
2717 # VNC JPEG detection
2718 if test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
2719 if $pkg_config --exists libjpeg; then
2720 vnc_jpeg=yes
2721 libs_softmmu="$libs_softmmu $($pkg_config --libs libjpeg)"
2722 QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags libjpeg)"
2723 else
2724 cat > $TMPC <<EOF
2725 #include <stdio.h>
2726 #include <jpeglib.h>
2727 int main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
2729 vnc_jpeg_cflags=""
2730 vnc_jpeg_libs="-ljpeg"
2731 if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
2732 vnc_jpeg=yes
2733 libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
2734 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
2735 else
2736 if test "$vnc_jpeg" = "yes" ; then
2737 feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
2739 vnc_jpeg=no
2744 ##########################################
2745 # VNC PNG detection
2746 if test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
2747 cat > $TMPC <<EOF
2748 //#include <stdio.h>
2749 #include <png.h>
2750 #include <stddef.h>
2751 int main(void) {
2752 png_structp png_ptr;
2753 png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
2754 return png_ptr != 0;
2757 if $pkg_config libpng --exists; then
2758 vnc_png_cflags=$($pkg_config libpng --cflags)
2759 vnc_png_libs=$($pkg_config libpng --libs)
2760 else
2761 vnc_png_cflags=""
2762 vnc_png_libs="-lpng"
2764 if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
2765 vnc_png=yes
2766 libs_softmmu="$vnc_png_libs $libs_softmmu"
2767 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
2768 else
2769 if test "$vnc_png" = "yes" ; then
2770 feature_not_found "vnc-png" "Install libpng devel"
2772 vnc_png=no
2776 ##########################################
2777 # fnmatch() probe, used for ACL routines
2778 fnmatch="no"
2779 cat > $TMPC << EOF
2780 #include <fnmatch.h>
2781 int main(void)
2783 fnmatch("foo", "foo", 0);
2784 return 0;
2787 if compile_prog "" "" ; then
2788 fnmatch="yes"
2791 ##########################################
2792 # xfsctl() probe, used for file-posix.c
2793 if test "$xfs" != "no" ; then
2794 cat > $TMPC << EOF
2795 #include <stddef.h> /* NULL */
2796 #include <xfs/xfs.h>
2797 int main(void)
2799 xfsctl(NULL, 0, 0, NULL);
2800 return 0;
2803 if compile_prog "" "" ; then
2804 xfs="yes"
2805 else
2806 if test "$xfs" = "yes" ; then
2807 feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
2809 xfs=no
2813 ##########################################
2814 # vde libraries probe
2815 if test "$vde" != "no" ; then
2816 vde_libs="-lvdeplug"
2817 cat > $TMPC << EOF
2818 #include <stddef.h>
2819 #include <libvdeplug.h>
2820 int main(void)
2822 struct vde_open_args a = {0, 0, 0};
2823 char s[] = "";
2824 vde_open(s, s, &a);
2825 return 0;
2828 if compile_prog "" "$vde_libs" ; then
2829 vde=yes
2830 libs_softmmu="$vde_libs $libs_softmmu"
2831 libs_tools="$vde_libs $libs_tools"
2832 else
2833 if test "$vde" = "yes" ; then
2834 feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
2836 vde=no
2840 ##########################################
2841 # netmap support probe
2842 # Apart from looking for netmap headers, we make sure that the host API version
2843 # supports the netmap backend (>=11). The upper bound (15) is meant to simulate
2844 # a minor/major version number. Minor new features will be marked with values up
2845 # to 15, and if something happens that requires a change to the backend we will
2846 # move above 15, submit the backend fixes and modify this two bounds.
2847 if test "$netmap" != "no" ; then
2848 cat > $TMPC << EOF
2849 #include <inttypes.h>
2850 #include <net/if.h>
2851 #include <net/netmap.h>
2852 #include <net/netmap_user.h>
2853 #if (NETMAP_API < 11) || (NETMAP_API > 15)
2854 #error
2855 #endif
2856 int main(void) { return 0; }
2858 if compile_prog "" "" ; then
2859 netmap=yes
2860 else
2861 if test "$netmap" = "yes" ; then
2862 feature_not_found "netmap"
2864 netmap=no
2868 ##########################################
2869 # libcap-ng library probe
2870 if test "$cap_ng" != "no" ; then
2871 cap_libs="-lcap-ng"
2872 cat > $TMPC << EOF
2873 #include <cap-ng.h>
2874 int main(void)
2876 capng_capability_to_name(CAPNG_EFFECTIVE);
2877 return 0;
2880 if compile_prog "" "$cap_libs" ; then
2881 cap_ng=yes
2882 libs_tools="$cap_libs $libs_tools"
2883 else
2884 if test "$cap_ng" = "yes" ; then
2885 feature_not_found "cap_ng" "Install libcap-ng devel"
2887 cap_ng=no
2891 ##########################################
2892 # Sound support libraries probe
2894 audio_drv_probe()
2896 drv=$1
2897 hdr=$2
2898 lib=$3
2899 exp=$4
2900 cfl=$5
2901 cat > $TMPC << EOF
2902 #include <$hdr>
2903 int main(void) { $exp }
2905 if compile_prog "$cfl" "$lib" ; then
2907 else
2908 error_exit "$drv check failed" \
2909 "Make sure to have the $drv libs and headers installed."
2913 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
2914 for drv in $audio_drv_list; do
2915 case $drv in
2916 alsa)
2917 audio_drv_probe $drv alsa/asoundlib.h -lasound \
2918 "return snd_pcm_close((snd_pcm_t *)0);"
2919 libs_softmmu="-lasound $libs_softmmu"
2923 audio_drv_probe $drv pulse/pulseaudio.h "-lpulse" \
2924 "pa_context_set_source_output_volume(NULL, 0, NULL, NULL, NULL); return 0;"
2925 libs_softmmu="-lpulse $libs_softmmu"
2926 audio_pt_int="yes"
2929 sdl)
2930 if test "$sdl" = "no"; then
2931 error_exit "sdl not found or disabled, can not use sdl audio driver"
2935 coreaudio)
2936 libs_softmmu="-framework CoreAudio $libs_softmmu"
2939 dsound)
2940 libs_softmmu="-lole32 -ldxguid $libs_softmmu"
2941 audio_win_int="yes"
2944 oss)
2945 libs_softmmu="$oss_lib $libs_softmmu"
2948 wav)
2949 # XXX: Probes for CoreAudio, DirectSound
2953 echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
2954 error_exit "Unknown driver '$drv' selected" \
2955 "Possible drivers are: $audio_possible_drivers"
2958 esac
2959 done
2961 ##########################################
2962 # BrlAPI probe
2964 if test "$brlapi" != "no" ; then
2965 brlapi_libs="-lbrlapi"
2966 cat > $TMPC << EOF
2967 #include <brlapi.h>
2968 #include <stddef.h>
2969 int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
2971 if compile_prog "" "$brlapi_libs" ; then
2972 brlapi=yes
2973 libs_softmmu="$brlapi_libs $libs_softmmu"
2974 else
2975 if test "$brlapi" = "yes" ; then
2976 feature_not_found "brlapi" "Install brlapi devel"
2978 brlapi=no
2982 ##########################################
2983 # curses probe
2984 if test "$curses" != "no" ; then
2985 if test "$mingw32" = "yes" ; then
2986 curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
2987 curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
2988 else
2989 curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"
2990 curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
2992 curses_found=no
2993 cat > $TMPC << EOF
2994 #include <locale.h>
2995 #include <curses.h>
2996 #include <wchar.h>
2997 int main(void) {
2998 const char *s = curses_version();
2999 wchar_t wch = L'w';
3000 setlocale(LC_ALL, "");
3001 resize_term(0, 0);
3002 addwstr(L"wide chars\n");
3003 addnwstr(&wch, 1);
3004 add_wch(WACS_DEGREE);
3005 return s != 0;
3008 IFS=:
3009 for curses_inc in $curses_inc_list; do
3010 IFS=:
3011 for curses_lib in $curses_lib_list; do
3012 unset IFS
3013 if compile_prog "$curses_inc" "$curses_lib" ; then
3014 curses_found=yes
3015 QEMU_CFLAGS="$curses_inc $QEMU_CFLAGS"
3016 libs_softmmu="$curses_lib $libs_softmmu"
3017 break
3019 done
3020 if test "$curses_found" = yes ; then
3021 break
3023 done
3024 unset IFS
3025 if test "$curses_found" = "yes" ; then
3026 curses=yes
3027 else
3028 if test "$curses" = "yes" ; then
3029 feature_not_found "curses" "Install ncurses devel"
3031 curses=no
3035 ##########################################
3036 # curl probe
3037 if test "$curl" != "no" ; then
3038 if $pkg_config libcurl --exists; then
3039 curlconfig="$pkg_config libcurl"
3040 else
3041 curlconfig=curl-config
3043 cat > $TMPC << EOF
3044 #include <curl/curl.h>
3045 int main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
3047 curl_cflags=$($curlconfig --cflags 2>/dev/null)
3048 curl_libs=$($curlconfig --libs 2>/dev/null)
3049 if compile_prog "$curl_cflags" "$curl_libs" ; then
3050 curl=yes
3051 else
3052 if test "$curl" = "yes" ; then
3053 feature_not_found "curl" "Install libcurl devel"
3055 curl=no
3057 fi # test "$curl"
3059 ##########################################
3060 # bluez support probe
3061 if test "$bluez" != "no" ; then
3062 cat > $TMPC << EOF
3063 #include <bluetooth/bluetooth.h>
3064 int main(void) { return bt_error(0); }
3066 bluez_cflags=$($pkg_config --cflags bluez 2>/dev/null)
3067 bluez_libs=$($pkg_config --libs bluez 2>/dev/null)
3068 if compile_prog "$bluez_cflags" "$bluez_libs" ; then
3069 bluez=yes
3070 libs_softmmu="$bluez_libs $libs_softmmu"
3071 else
3072 if test "$bluez" = "yes" ; then
3073 feature_not_found "bluez" "Install bluez-libs/libbluetooth devel"
3075 bluez="no"
3079 ##########################################
3080 # glib support probe
3082 glib_req_ver=2.22
3083 glib_modules=gthread-2.0
3084 if test "$modules" = yes; then
3085 glib_modules="$glib_modules gmodule-2.0"
3088 for i in $glib_modules; do
3089 if $pkg_config --atleast-version=$glib_req_ver $i; then
3090 glib_cflags=$($pkg_config --cflags $i)
3091 glib_libs=$($pkg_config --libs $i)
3092 QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
3093 LIBS="$glib_libs $LIBS"
3094 libs_qga="$glib_libs $libs_qga"
3095 else
3096 error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3098 done
3100 # Sanity check that the current size_t matches the
3101 # size that glib thinks it should be. This catches
3102 # problems on multi-arch where people try to build
3103 # 32-bit QEMU while pointing at 64-bit glib headers
3104 cat > $TMPC <<EOF
3105 #include <glib.h>
3106 #include <unistd.h>
3108 #define QEMU_BUILD_BUG_ON(x) \
3109 typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3111 int main(void) {
3112 QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3113 return 0;
3117 if ! compile_prog "$CFLAGS" "$LIBS" ; then
3118 error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3119 "You probably need to set PKG_CONFIG_LIBDIR"\
3120 "to point to the right pkg-config files for your"\
3121 "build target"
3124 # g_test_trap_subprocess added in 2.38. Used by some tests.
3125 glib_subprocess=yes
3126 if ! $pkg_config --atleast-version=2.38 glib-2.0; then
3127 glib_subprocess=no
3130 # Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
3131 cat > $TMPC << EOF
3132 #include <glib.h>
3133 int main(void) { return 0; }
3135 if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3136 if cc_has_warning_flag "-Wno-unknown-attributes"; then
3137 glib_cflags="-Wno-unknown-attributes $glib_cflags"
3138 CFLAGS="-Wno-unknown-attributes $CFLAGS"
3142 #########################################
3143 # zlib check
3145 if test "$zlib" != "no" ; then
3146 if $pkg_config --exists zlib; then
3147 zlib_cflags=$($pkg_config --cflags zlib)
3148 zlib_libs=$($pkg_config --libs zlib)
3149 QEMU_CFLAGS="$zlib_cflags $QEMU_CFLAGS"
3150 LIBS="$zlib_libs $LIBS"
3151 else
3152 cat > $TMPC << EOF
3153 #include <zlib.h>
3154 int main(void) { zlibVersion(); return 0; }
3156 if compile_prog "" "-lz" ; then
3157 LIBS="$LIBS -lz"
3158 else
3159 error_exit "zlib check failed" \
3160 "Make sure to have the zlib libs and headers installed."
3165 ##########################################
3166 # SHA command probe for modules
3167 if test "$modules" = yes; then
3168 shacmd_probe="sha1sum sha1 shasum"
3169 for c in $shacmd_probe; do
3170 if has $c; then
3171 shacmd="$c"
3172 break
3174 done
3175 if test "$shacmd" = ""; then
3176 error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3180 ##########################################
3181 # pixman support probe
3183 if test "$pixman" = ""; then
3184 if test "$want_tools" = "no" -a "$softmmu" = "no"; then
3185 pixman="none"
3186 elif $pkg_config --atleast-version=0.21.8 pixman-1 > /dev/null 2>&1; then
3187 pixman="system"
3188 else
3189 pixman="internal"
3192 if test "$pixman" = "none"; then
3193 if test "$want_tools" != "no" -o "$softmmu" != "no"; then
3194 error_exit "pixman disabled but system emulation or tools build" \
3195 "enabled. You can turn off pixman only if you also" \
3196 "disable all system emulation targets and the tools" \
3197 "build with '--disable-tools --disable-system'."
3199 pixman_cflags=
3200 pixman_libs=
3201 elif test "$pixman" = "system"; then
3202 # pixman version has been checked above
3203 pixman_cflags=$($pkg_config --cflags pixman-1)
3204 pixman_libs=$($pkg_config --libs pixman-1)
3205 else
3206 if test ! -d ${source_path}/pixman/pixman; then
3207 error_exit "pixman >= 0.21.8 not present. Your options:" \
3208 " (1) Preferred: Install the pixman devel package (any recent" \
3209 " distro should have packages as Xorg needs pixman too)." \
3210 " (2) Fetch the pixman submodule, using:" \
3211 " git submodule update --init pixman"
3213 mkdir -p pixman/pixman
3214 pixman_cflags="-I\$(SRC_PATH)/pixman/pixman -I\$(BUILD_DIR)/pixman/pixman"
3215 pixman_libs="-L\$(BUILD_DIR)/pixman/pixman/.libs -lpixman-1"
3218 ##########################################
3219 # libcap probe
3221 if test "$cap" != "no" ; then
3222 cat > $TMPC <<EOF
3223 #include <stdio.h>
3224 #include <sys/capability.h>
3225 int main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
3227 if compile_prog "" "-lcap" ; then
3228 cap=yes
3229 else
3230 cap=no
3234 ##########################################
3235 # pthread probe
3236 PTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
3238 pthread=no
3239 cat > $TMPC << EOF
3240 #include <pthread.h>
3241 static void *f(void *p) { return NULL; }
3242 int main(void) {
3243 pthread_t thread;
3244 pthread_create(&thread, 0, f, 0);
3245 return 0;
3248 if compile_prog "" "" ; then
3249 pthread=yes
3250 else
3251 for pthread_lib in $PTHREADLIBS_LIST; do
3252 if compile_prog "" "$pthread_lib" ; then
3253 pthread=yes
3254 found=no
3255 for lib_entry in $LIBS; do
3256 if test "$lib_entry" = "$pthread_lib"; then
3257 found=yes
3258 break
3260 done
3261 if test "$found" = "no"; then
3262 LIBS="$pthread_lib $LIBS"
3264 PTHREAD_LIB="$pthread_lib"
3265 break
3267 done
3270 if test "$mingw32" != yes -a "$pthread" = no; then
3271 error_exit "pthread check failed" \
3272 "Make sure to have the pthread libs and headers installed."
3275 # check for pthread_setname_np
3276 pthread_setname_np=no
3277 cat > $TMPC << EOF
3278 #include <pthread.h>
3280 static void *f(void *p) { return NULL; }
3281 int main(void)
3283 pthread_t thread;
3284 pthread_create(&thread, 0, f, 0);
3285 pthread_setname_np(thread, "QEMU");
3286 return 0;
3289 if compile_prog "" "$pthread_lib" ; then
3290 pthread_setname_np=yes
3293 ##########################################
3294 # rbd probe
3295 if test "$rbd" != "no" ; then
3296 cat > $TMPC <<EOF
3297 #include <stdio.h>
3298 #include <rbd/librbd.h>
3299 int main(void) {
3300 rados_t cluster;
3301 rados_create(&cluster, NULL);
3302 return 0;
3305 rbd_libs="-lrbd -lrados"
3306 if compile_prog "" "$rbd_libs" ; then
3307 rbd=yes
3308 else
3309 if test "$rbd" = "yes" ; then
3310 feature_not_found "rados block device" "Install librbd/ceph devel"
3312 rbd=no
3316 ##########################################
3317 # libssh2 probe
3318 min_libssh2_version=1.2.8
3319 if test "$libssh2" != "no" ; then
3320 if $pkg_config --atleast-version=$min_libssh2_version libssh2; then
3321 libssh2_cflags=$($pkg_config libssh2 --cflags)
3322 libssh2_libs=$($pkg_config libssh2 --libs)
3323 libssh2=yes
3324 else
3325 if test "$libssh2" = "yes" ; then
3326 error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2"
3328 libssh2=no
3332 ##########################################
3333 # libssh2_sftp_fsync probe
3335 if test "$libssh2" = "yes"; then
3336 cat > $TMPC <<EOF
3337 #include <stdio.h>
3338 #include <libssh2.h>
3339 #include <libssh2_sftp.h>
3340 int main(void) {
3341 LIBSSH2_SESSION *session;
3342 LIBSSH2_SFTP *sftp;
3343 LIBSSH2_SFTP_HANDLE *sftp_handle;
3344 session = libssh2_session_init ();
3345 sftp = libssh2_sftp_init (session);
3346 sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0);
3347 libssh2_sftp_fsync (sftp_handle);
3348 return 0;
3351 # libssh2_cflags/libssh2_libs defined in previous test.
3352 if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then
3353 QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS"
3357 ##########################################
3358 # linux-aio probe
3360 if test "$linux_aio" != "no" ; then
3361 cat > $TMPC <<EOF
3362 #include <libaio.h>
3363 #include <sys/eventfd.h>
3364 #include <stddef.h>
3365 int main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
3367 if compile_prog "" "-laio" ; then
3368 linux_aio=yes
3369 else
3370 if test "$linux_aio" = "yes" ; then
3371 feature_not_found "linux AIO" "Install libaio devel"
3373 linux_aio=no
3377 ##########################################
3378 # TPM passthrough is only on x86 Linux
3380 if test "$targetos" = Linux && test "$cpu" = i386 -o "$cpu" = x86_64; then
3381 tpm_passthrough=$tpm
3382 else
3383 tpm_passthrough=no
3386 ##########################################
3387 # attr probe
3389 if test "$attr" != "no" ; then
3390 cat > $TMPC <<EOF
3391 #include <stdio.h>
3392 #include <sys/types.h>
3393 #ifdef CONFIG_LIBATTR
3394 #include <attr/xattr.h>
3395 #else
3396 #include <sys/xattr.h>
3397 #endif
3398 int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
3400 if compile_prog "" "" ; then
3401 attr=yes
3402 # Older distros have <attr/xattr.h>, and need -lattr:
3403 elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
3404 attr=yes
3405 LIBS="-lattr $LIBS"
3406 libattr=yes
3407 else
3408 if test "$attr" = "yes" ; then
3409 feature_not_found "ATTR" "Install libc6 or libattr devel"
3411 attr=no
3415 ##########################################
3416 # iovec probe
3417 cat > $TMPC <<EOF
3418 #include <sys/types.h>
3419 #include <sys/uio.h>
3420 #include <unistd.h>
3421 int main(void) { return sizeof(struct iovec); }
3423 iovec=no
3424 if compile_prog "" "" ; then
3425 iovec=yes
3428 ##########################################
3429 # preadv probe
3430 cat > $TMPC <<EOF
3431 #include <sys/types.h>
3432 #include <sys/uio.h>
3433 #include <unistd.h>
3434 int main(void) { return preadv(0, 0, 0, 0); }
3436 preadv=no
3437 if compile_prog "" "" ; then
3438 preadv=yes
3441 ##########################################
3442 # fdt probe
3443 # fdt support is mandatory for at least some target architectures,
3444 # so insist on it if we're building those system emulators.
3445 fdt_required=no
3446 for target in $target_list; do
3447 case $target in
3448 aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu)
3449 fdt_required=yes
3451 esac
3452 done
3454 if test "$fdt_required" = "yes"; then
3455 if test "$fdt" = "no"; then
3456 error_exit "fdt disabled but some requested targets require it." \
3457 "You can turn off fdt only if you also disable all the system emulation" \
3458 "targets which need it (by specifying a cut down --target-list)."
3460 fdt=yes
3463 if test "$fdt" != "no" ; then
3464 fdt_libs="-lfdt"
3465 # explicitly check for libfdt_env.h as it is missing in some stable installs
3466 # and test for required functions to make sure we are on a version >= 1.4.2
3467 cat > $TMPC << EOF
3468 #include <libfdt.h>
3469 #include <libfdt_env.h>
3470 int main(void) { fdt_first_subnode(0, 0); return 0; }
3472 if compile_prog "" "$fdt_libs" ; then
3473 # system DTC is good - use it
3474 fdt=yes
3475 elif test -d ${source_path}/dtc/libfdt ; then
3476 # have submodule DTC - use it
3477 fdt=yes
3478 dtc_internal="yes"
3479 mkdir -p dtc
3480 if [ "$pwd_is_source_path" != "y" ] ; then
3481 symlink "$source_path/dtc/Makefile" "dtc/Makefile"
3482 symlink "$source_path/dtc/scripts" "dtc/scripts"
3484 fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
3485 fdt_libs="-L\$(BUILD_DIR)/dtc/libfdt $fdt_libs"
3486 elif test "$fdt" = "yes" ; then
3487 # have neither and want - prompt for system/submodule install
3488 error_exit "DTC (libfdt) version >= 1.4.2 not present. Your options:" \
3489 " (1) Preferred: Install the DTC (libfdt) devel package" \
3490 " (2) Fetch the DTC submodule, using:" \
3491 " git submodule update --init dtc"
3492 else
3493 # don't have and don't want
3494 fdt_libs=
3495 fdt=no
3499 libs_softmmu="$libs_softmmu $fdt_libs"
3501 ##########################################
3502 # opengl probe (for sdl2, gtk, milkymist-tmu2)
3504 if test "$opengl" != "no" ; then
3505 opengl_pkgs="epoxy libdrm gbm"
3506 if $pkg_config $opengl_pkgs x11; then
3507 opengl_cflags="$($pkg_config --cflags $opengl_pkgs) $x11_cflags"
3508 opengl_libs="$($pkg_config --libs $opengl_pkgs) $x11_libs"
3509 opengl=yes
3510 if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
3511 gtk_gl="yes"
3513 QEMU_CFLAGS="$QEMU_CFLAGS $opengl_cflags"
3514 else
3515 if test "$opengl" = "yes" ; then
3516 feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
3518 opengl_cflags=""
3519 opengl_libs=""
3520 opengl=no
3524 if test "$opengl" = "yes"; then
3525 cat > $TMPC << EOF
3526 #include <epoxy/egl.h>
3527 #ifndef EGL_MESA_image_dma_buf_export
3528 # error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
3529 #endif
3530 int main(void) { return 0; }
3532 if compile_prog "" "" ; then
3533 opengl_dmabuf=yes
3538 ##########################################
3539 # glusterfs probe
3540 if test "$glusterfs" != "no" ; then
3541 if $pkg_config --atleast-version=3 glusterfs-api; then
3542 glusterfs="yes"
3543 glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
3544 glusterfs_libs=$($pkg_config --libs glusterfs-api)
3545 if $pkg_config --atleast-version=4 glusterfs-api; then
3546 glusterfs_xlator_opt="yes"
3548 if $pkg_config --atleast-version=5 glusterfs-api; then
3549 glusterfs_discard="yes"
3551 if $pkg_config --atleast-version=6 glusterfs-api; then
3552 glusterfs_zerofill="yes"
3554 else
3555 if test "$glusterfs" = "yes" ; then
3556 feature_not_found "GlusterFS backend support" \
3557 "Install glusterfs-api devel >= 3"
3559 glusterfs="no"
3563 # Check for inotify functions when we are building linux-user
3564 # emulator. This is done because older glibc versions don't
3565 # have syscall stubs for these implemented. In that case we
3566 # don't provide them even if kernel supports them.
3568 inotify=no
3569 cat > $TMPC << EOF
3570 #include <sys/inotify.h>
3573 main(void)
3575 /* try to start inotify */
3576 return inotify_init();
3579 if compile_prog "" "" ; then
3580 inotify=yes
3583 inotify1=no
3584 cat > $TMPC << EOF
3585 #include <sys/inotify.h>
3588 main(void)
3590 /* try to start inotify */
3591 return inotify_init1(0);
3594 if compile_prog "" "" ; then
3595 inotify1=yes
3598 # check if utimensat and futimens are supported
3599 utimens=no
3600 cat > $TMPC << EOF
3601 #define _ATFILE_SOURCE
3602 #include <stddef.h>
3603 #include <fcntl.h>
3604 #include <sys/stat.h>
3606 int main(void)
3608 utimensat(AT_FDCWD, "foo", NULL, 0);
3609 futimens(0, NULL);
3610 return 0;
3613 if compile_prog "" "" ; then
3614 utimens=yes
3617 # check if pipe2 is there
3618 pipe2=no
3619 cat > $TMPC << EOF
3620 #include <unistd.h>
3621 #include <fcntl.h>
3623 int main(void)
3625 int pipefd[2];
3626 return pipe2(pipefd, O_CLOEXEC);
3629 if compile_prog "" "" ; then
3630 pipe2=yes
3633 # check if accept4 is there
3634 accept4=no
3635 cat > $TMPC << EOF
3636 #include <sys/socket.h>
3637 #include <stddef.h>
3639 int main(void)
3641 accept4(0, NULL, NULL, SOCK_CLOEXEC);
3642 return 0;
3645 if compile_prog "" "" ; then
3646 accept4=yes
3649 # check if tee/splice is there. vmsplice was added same time.
3650 splice=no
3651 cat > $TMPC << EOF
3652 #include <unistd.h>
3653 #include <fcntl.h>
3654 #include <limits.h>
3656 int main(void)
3658 int len, fd = 0;
3659 len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
3660 splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
3661 return 0;
3664 if compile_prog "" "" ; then
3665 splice=yes
3668 ##########################################
3669 # libnuma probe
3671 if test "$numa" != "no" ; then
3672 cat > $TMPC << EOF
3673 #include <numa.h>
3674 int main(void) { return numa_available(); }
3677 if compile_prog "" "-lnuma" ; then
3678 numa=yes
3679 libs_softmmu="-lnuma $libs_softmmu"
3680 else
3681 if test "$numa" = "yes" ; then
3682 feature_not_found "numa" "install numactl devel"
3684 numa=no
3688 if test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
3689 echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
3690 exit 1
3693 ##########################################
3694 # tcmalloc probe
3696 if test "$tcmalloc" = "yes" ; then
3697 cat > $TMPC << EOF
3698 #include <stdlib.h>
3699 int main(void) { malloc(1); return 0; }
3702 if compile_prog "" "-ltcmalloc" ; then
3703 LIBS="-ltcmalloc $LIBS"
3704 else
3705 feature_not_found "tcmalloc" "install gperftools devel"
3709 ##########################################
3710 # jemalloc probe
3712 if test "$jemalloc" = "yes" ; then
3713 cat > $TMPC << EOF
3714 #include <stdlib.h>
3715 int main(void) { malloc(1); return 0; }
3718 if compile_prog "" "-ljemalloc" ; then
3719 LIBS="-ljemalloc $LIBS"
3720 else
3721 feature_not_found "jemalloc" "install jemalloc devel"
3725 ##########################################
3726 # signalfd probe
3727 signalfd="no"
3728 cat > $TMPC << EOF
3729 #include <unistd.h>
3730 #include <sys/syscall.h>
3731 #include <signal.h>
3732 int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
3735 if compile_prog "" "" ; then
3736 signalfd=yes
3739 # check if eventfd is supported
3740 eventfd=no
3741 cat > $TMPC << EOF
3742 #include <sys/eventfd.h>
3744 int main(void)
3746 return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
3749 if compile_prog "" "" ; then
3750 eventfd=yes
3753 # check if memfd is supported
3754 memfd=no
3755 cat > $TMPC << EOF
3756 #include <sys/memfd.h>
3758 int main(void)
3760 return memfd_create("foo", MFD_ALLOW_SEALING);
3763 if compile_prog "" "" ; then
3764 memfd=yes
3769 # check for fallocate
3770 fallocate=no
3771 cat > $TMPC << EOF
3772 #include <fcntl.h>
3774 int main(void)
3776 fallocate(0, 0, 0, 0);
3777 return 0;
3780 if compile_prog "" "" ; then
3781 fallocate=yes
3784 # check for fallocate hole punching
3785 fallocate_punch_hole=no
3786 cat > $TMPC << EOF
3787 #include <fcntl.h>
3788 #include <linux/falloc.h>
3790 int main(void)
3792 fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
3793 return 0;
3796 if compile_prog "" "" ; then
3797 fallocate_punch_hole=yes
3800 # check that fallocate supports range zeroing inside the file
3801 fallocate_zero_range=no
3802 cat > $TMPC << EOF
3803 #include <fcntl.h>
3804 #include <linux/falloc.h>
3806 int main(void)
3808 fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
3809 return 0;
3812 if compile_prog "" "" ; then
3813 fallocate_zero_range=yes
3816 # check for posix_fallocate
3817 posix_fallocate=no
3818 cat > $TMPC << EOF
3819 #include <fcntl.h>
3821 int main(void)
3823 posix_fallocate(0, 0, 0);
3824 return 0;
3827 if compile_prog "" "" ; then
3828 posix_fallocate=yes
3831 # check for sync_file_range
3832 sync_file_range=no
3833 cat > $TMPC << EOF
3834 #include <fcntl.h>
3836 int main(void)
3838 sync_file_range(0, 0, 0, 0);
3839 return 0;
3842 if compile_prog "" "" ; then
3843 sync_file_range=yes
3846 # check for linux/fiemap.h and FS_IOC_FIEMAP
3847 fiemap=no
3848 cat > $TMPC << EOF
3849 #include <sys/ioctl.h>
3850 #include <linux/fs.h>
3851 #include <linux/fiemap.h>
3853 int main(void)
3855 ioctl(0, FS_IOC_FIEMAP, 0);
3856 return 0;
3859 if compile_prog "" "" ; then
3860 fiemap=yes
3863 # check for dup3
3864 dup3=no
3865 cat > $TMPC << EOF
3866 #include <unistd.h>
3868 int main(void)
3870 dup3(0, 0, 0);
3871 return 0;
3874 if compile_prog "" "" ; then
3875 dup3=yes
3878 # check for ppoll support
3879 ppoll=no
3880 cat > $TMPC << EOF
3881 #include <poll.h>
3883 int main(void)
3885 struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
3886 ppoll(&pfd, 1, 0, 0);
3887 return 0;
3890 if compile_prog "" "" ; then
3891 ppoll=yes
3894 # check for prctl(PR_SET_TIMERSLACK , ... ) support
3895 prctl_pr_set_timerslack=no
3896 cat > $TMPC << EOF
3897 #include <sys/prctl.h>
3899 int main(void)
3901 prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
3902 return 0;
3905 if compile_prog "" "" ; then
3906 prctl_pr_set_timerslack=yes
3909 # check for epoll support
3910 epoll=no
3911 cat > $TMPC << EOF
3912 #include <sys/epoll.h>
3914 int main(void)
3916 epoll_create(0);
3917 return 0;
3920 if compile_prog "" "" ; then
3921 epoll=yes
3924 # epoll_create1 is a later addition
3925 # so we must check separately for its presence
3926 epoll_create1=no
3927 cat > $TMPC << EOF
3928 #include <sys/epoll.h>
3930 int main(void)
3932 /* Note that we use epoll_create1 as a value, not as
3933 * a function being called. This is necessary so that on
3934 * old SPARC glibc versions where the function was present in
3935 * the library but not declared in the header file we will
3936 * fail the configure check. (Otherwise we will get a compiler
3937 * warning but not an error, and will proceed to fail the
3938 * qemu compile where we compile with -Werror.)
3940 return (int)(uintptr_t)&epoll_create1;
3943 if compile_prog "" "" ; then
3944 epoll_create1=yes
3947 # check for sendfile support
3948 sendfile=no
3949 cat > $TMPC << EOF
3950 #include <sys/sendfile.h>
3952 int main(void)
3954 return sendfile(0, 0, 0, 0);
3957 if compile_prog "" "" ; then
3958 sendfile=yes
3961 # check for timerfd support (glibc 2.8 and newer)
3962 timerfd=no
3963 cat > $TMPC << EOF
3964 #include <sys/timerfd.h>
3966 int main(void)
3968 return(timerfd_create(CLOCK_REALTIME, 0));
3971 if compile_prog "" "" ; then
3972 timerfd=yes
3975 # check for setns and unshare support
3976 setns=no
3977 cat > $TMPC << EOF
3978 #include <sched.h>
3980 int main(void)
3982 int ret;
3983 ret = setns(0, 0);
3984 ret = unshare(0);
3985 return ret;
3988 if compile_prog "" "" ; then
3989 setns=yes
3992 # clock_adjtime probe
3993 clock_adjtime=no
3994 cat > $TMPC <<EOF
3995 #include <time.h>
3997 int main(void)
3999 return clock_adjtime(0, 0);
4002 clock_adjtime=no
4003 if compile_prog "" "" ; then
4004 clock_adjtime=yes
4007 # syncfs probe
4008 syncfs=no
4009 cat > $TMPC <<EOF
4010 #include <unistd.h>
4012 int main(void)
4014 return syncfs(0);
4017 syncfs=no
4018 if compile_prog "" "" ; then
4019 syncfs=yes
4022 # Check if tools are available to build documentation.
4023 if test "$docs" != "no" ; then
4024 if has makeinfo && has pod2man; then
4025 docs=yes
4026 else
4027 if test "$docs" = "yes" ; then
4028 feature_not_found "docs" "Install texinfo and Perl/perl-podlators"
4030 docs=no
4034 if test "$want_tools" = ""; then
4035 if test $(expr "$target_list" : ".*softmmu.*") != 0; then
4036 want_tools=yes
4037 else
4038 want_tools=no
4042 # Search for bswap_32 function
4043 byteswap_h=no
4044 cat > $TMPC << EOF
4045 #include <byteswap.h>
4046 int main(void) { return bswap_32(0); }
4048 if compile_prog "" "" ; then
4049 byteswap_h=yes
4052 # Search for bswap32 function
4053 bswap_h=no
4054 cat > $TMPC << EOF
4055 #include <sys/endian.h>
4056 #include <sys/types.h>
4057 #include <machine/bswap.h>
4058 int main(void) { return bswap32(0); }
4060 if compile_prog "" "" ; then
4061 bswap_h=yes
4064 ##########################################
4065 # Do we have libiscsi >= 1.9.0
4066 if test "$libiscsi" != "no" ; then
4067 if $pkg_config --atleast-version=1.9.0 libiscsi; then
4068 libiscsi="yes"
4069 libiscsi_cflags=$($pkg_config --cflags libiscsi)
4070 libiscsi_libs=$($pkg_config --libs libiscsi)
4071 else
4072 if test "$libiscsi" = "yes" ; then
4073 feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
4075 libiscsi="no"
4079 ##########################################
4080 # Do we need libm
4081 cat > $TMPC << EOF
4082 #include <math.h>
4083 int main(int argc, char **argv) { return isnan(sin((double)argc)); }
4085 if compile_prog "" "" ; then
4087 elif compile_prog "" "-lm" ; then
4088 LIBS="-lm $LIBS"
4089 libs_qga="-lm $libs_qga"
4090 else
4091 error_exit "libm check failed"
4094 ##########################################
4095 # Do we need librt
4096 # uClibc provides 2 versions of clock_gettime(), one with realtime
4097 # support and one without. This means that the clock_gettime() don't
4098 # need -lrt. We still need it for timer_create() so we check for this
4099 # function in addition.
4100 cat > $TMPC <<EOF
4101 #include <signal.h>
4102 #include <time.h>
4103 int main(void) {
4104 timer_create(CLOCK_REALTIME, NULL, NULL);
4105 return clock_gettime(CLOCK_REALTIME, NULL);
4109 if compile_prog "" "" ; then
4111 # we need pthread for static linking. use previous pthread test result
4112 elif compile_prog "" "$pthread_lib -lrt" ; then
4113 LIBS="$LIBS -lrt"
4114 libs_qga="$libs_qga -lrt"
4117 if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
4118 "$aix" != "yes" -a "$haiku" != "yes" ; then
4119 libs_softmmu="-lutil $libs_softmmu"
4122 ##########################################
4123 # spice probe
4124 if test "$spice" != "no" ; then
4125 cat > $TMPC << EOF
4126 #include <spice.h>
4127 int main(void) { spice_server_new(); return 0; }
4129 spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
4130 spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
4131 if $pkg_config --atleast-version=0.12.0 spice-server && \
4132 $pkg_config --atleast-version=0.12.3 spice-protocol && \
4133 compile_prog "$spice_cflags" "$spice_libs" ; then
4134 spice="yes"
4135 libs_softmmu="$libs_softmmu $spice_libs"
4136 QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
4137 spice_protocol_version=$($pkg_config --modversion spice-protocol)
4138 spice_server_version=$($pkg_config --modversion spice-server)
4139 else
4140 if test "$spice" = "yes" ; then
4141 feature_not_found "spice" \
4142 "Install spice-server(>=0.12.0) and spice-protocol(>=0.12.3) devel"
4144 spice="no"
4148 # check for smartcard support
4149 smartcard_cflags=""
4150 if test "$smartcard" != "no"; then
4151 if $pkg_config libcacard; then
4152 libcacard_cflags=$($pkg_config --cflags libcacard)
4153 libcacard_libs=$($pkg_config --libs libcacard)
4154 QEMU_CFLAGS="$QEMU_CFLAGS $libcacard_cflags"
4155 libs_softmmu="$libs_softmmu $libcacard_libs"
4156 smartcard="yes"
4157 else
4158 if test "$smartcard" = "yes"; then
4159 feature_not_found "smartcard" "Install libcacard devel"
4161 smartcard="no"
4165 # check for libusb
4166 if test "$libusb" != "no" ; then
4167 if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
4168 libusb="yes"
4169 libusb_cflags=$($pkg_config --cflags libusb-1.0)
4170 libusb_libs=$($pkg_config --libs libusb-1.0)
4171 QEMU_CFLAGS="$QEMU_CFLAGS $libusb_cflags"
4172 libs_softmmu="$libs_softmmu $libusb_libs"
4173 else
4174 if test "$libusb" = "yes"; then
4175 feature_not_found "libusb" "Install libusb devel >= 1.0.13"
4177 libusb="no"
4181 # check for usbredirparser for usb network redirection support
4182 if test "$usb_redir" != "no" ; then
4183 if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
4184 usb_redir="yes"
4185 usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
4186 usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
4187 QEMU_CFLAGS="$QEMU_CFLAGS $usb_redir_cflags"
4188 libs_softmmu="$libs_softmmu $usb_redir_libs"
4189 else
4190 if test "$usb_redir" = "yes"; then
4191 feature_not_found "usb-redir" "Install usbredir devel"
4193 usb_redir="no"
4197 ##########################################
4198 # check if we have VSS SDK headers for win
4200 if test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$vss_win32_sdk" != "no" ; then
4201 case "$vss_win32_sdk" in
4202 "") vss_win32_include="-isystem $source_path" ;;
4203 *\ *) # The SDK is installed in "Program Files" by default, but we cannot
4204 # handle path with spaces. So we symlink the headers into ".sdk/vss".
4205 vss_win32_include="-isystem $source_path/.sdk/vss"
4206 symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
4208 *) vss_win32_include="-isystem $vss_win32_sdk"
4209 esac
4210 cat > $TMPC << EOF
4211 #define __MIDL_user_allocate_free_DEFINED__
4212 #include <inc/win2003/vss.h>
4213 int main(void) { return VSS_CTX_BACKUP; }
4215 if compile_prog "$vss_win32_include" "" ; then
4216 guest_agent_with_vss="yes"
4217 QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
4218 libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
4219 qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
4220 else
4221 if test "$vss_win32_sdk" != "" ; then
4222 echo "ERROR: Please download and install Microsoft VSS SDK:"
4223 echo "ERROR: http://www.microsoft.com/en-us/download/details.aspx?id=23490"
4224 echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
4225 echo "ERROR: scripts/extract-vsssdk-headers setup.exe"
4226 echo "ERROR: The headers are extracted in the directory \`inc'."
4227 feature_not_found "VSS support"
4229 guest_agent_with_vss="no"
4233 ##########################################
4234 # lookup Windows platform SDK (if not specified)
4235 # The SDK is needed only to build .tlb (type library) file of guest agent
4236 # VSS provider from the source. It is usually unnecessary because the
4237 # pre-compiled .tlb file is included.
4239 if test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$guest_agent_with_vss" = "yes" ; then
4240 if test -z "$win_sdk"; then
4241 programfiles="$PROGRAMFILES"
4242 test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
4243 if test -n "$programfiles"; then
4244 win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
4245 else
4246 feature_not_found "Windows SDK"
4248 elif test "$win_sdk" = "no"; then
4249 win_sdk=""
4253 ##########################################
4254 # check if mingw environment provides a recent ntddscsi.h
4255 if test "$mingw32" = "yes" -a "$guest_agent" != "no"; then
4256 cat > $TMPC << EOF
4257 #include <windows.h>
4258 #include <ntddscsi.h>
4259 int main(void) {
4260 #if !defined(IOCTL_SCSI_GET_ADDRESS)
4261 #error Missing required ioctl definitions
4262 #endif
4263 SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
4264 return addr.Lun;
4267 if compile_prog "" "" ; then
4268 guest_agent_ntddscsi=yes
4269 libs_qga="-lsetupapi $libs_qga"
4273 ##########################################
4274 # virgl renderer probe
4276 if test "$virglrenderer" != "no" ; then
4277 cat > $TMPC << EOF
4278 #include <virglrenderer.h>
4279 int main(void) { virgl_renderer_poll(); return 0; }
4281 virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
4282 virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
4283 if $pkg_config virglrenderer >/dev/null 2>&1 && \
4284 compile_prog "$virgl_cflags" "$virgl_libs" ; then
4285 virglrenderer="yes"
4286 else
4287 if test "$virglrenderer" = "yes" ; then
4288 feature_not_found "virglrenderer"
4290 virglrenderer="no"
4294 ##########################################
4295 # check if we have fdatasync
4297 fdatasync=no
4298 cat > $TMPC << EOF
4299 #include <unistd.h>
4300 int main(void) {
4301 #if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
4302 return fdatasync(0);
4303 #else
4304 #error Not supported
4305 #endif
4308 if compile_prog "" "" ; then
4309 fdatasync=yes
4312 ##########################################
4313 # check if we have madvise
4315 madvise=no
4316 cat > $TMPC << EOF
4317 #include <sys/types.h>
4318 #include <sys/mman.h>
4319 #include <stddef.h>
4320 int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
4322 if compile_prog "" "" ; then
4323 madvise=yes
4326 ##########################################
4327 # check if we have posix_madvise
4329 posix_madvise=no
4330 cat > $TMPC << EOF
4331 #include <sys/mman.h>
4332 #include <stddef.h>
4333 int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
4335 if compile_prog "" "" ; then
4336 posix_madvise=yes
4339 ##########################################
4340 # check if we have posix_syslog
4342 posix_syslog=no
4343 cat > $TMPC << EOF
4344 #include <syslog.h>
4345 int main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
4347 if compile_prog "" "" ; then
4348 posix_syslog=yes
4351 ##########################################
4352 # check if trace backend exists
4354 $python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends > /dev/null 2> /dev/null
4355 if test "$?" -ne 0 ; then
4356 error_exit "invalid trace backends" \
4357 "Please choose supported trace backends."
4360 ##########################################
4361 # For 'ust' backend, test if ust headers are present
4362 if have_backend "ust"; then
4363 cat > $TMPC << EOF
4364 #include <lttng/tracepoint.h>
4365 int main(void) { return 0; }
4367 if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
4368 if $pkg_config lttng-ust --exists; then
4369 lttng_ust_libs=$($pkg_config --libs lttng-ust)
4370 else
4371 lttng_ust_libs="-llttng-ust -ldl"
4373 if $pkg_config liburcu-bp --exists; then
4374 urcu_bp_libs=$($pkg_config --libs liburcu-bp)
4375 else
4376 urcu_bp_libs="-lurcu-bp"
4379 LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
4380 libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
4381 else
4382 error_exit "Trace backend 'ust' missing lttng-ust header files"
4386 ##########################################
4387 # For 'dtrace' backend, test if 'dtrace' command is present
4388 if have_backend "dtrace"; then
4389 if ! has 'dtrace' ; then
4390 error_exit "dtrace command is not found in PATH $PATH"
4392 trace_backend_stap="no"
4393 if has 'stap' ; then
4394 trace_backend_stap="yes"
4398 ##########################################
4399 # check and set a backend for coroutine
4401 # We prefer ucontext, but it's not always possible. The fallback
4402 # is sigcontext. gthread is not selectable except explicitly, because
4403 # it is not functional enough to run QEMU proper. (It is occasionally
4404 # useful for debugging purposes.) On Windows the only valid backend
4405 # is the Windows-specific one.
4407 ucontext_works=no
4408 if test "$darwin" != "yes"; then
4409 cat > $TMPC << EOF
4410 #include <ucontext.h>
4411 #ifdef __stub_makecontext
4412 #error Ignoring glibc stub makecontext which will always fail
4413 #endif
4414 int main(void) { makecontext(0, 0, 0); return 0; }
4416 if compile_prog "" "" ; then
4417 ucontext_works=yes
4421 if test "$coroutine" = ""; then
4422 if test "$mingw32" = "yes"; then
4423 coroutine=win32
4424 elif test "$ucontext_works" = "yes"; then
4425 coroutine=ucontext
4426 else
4427 coroutine=sigaltstack
4429 else
4430 case $coroutine in
4431 windows)
4432 if test "$mingw32" != "yes"; then
4433 error_exit "'windows' coroutine backend only valid for Windows"
4435 # Unfortunately the user visible backend name doesn't match the
4436 # coroutine-*.c filename for this case, so we have to adjust it here.
4437 coroutine=win32
4439 ucontext)
4440 if test "$ucontext_works" != "yes"; then
4441 feature_not_found "ucontext"
4444 gthread|sigaltstack)
4445 if test "$mingw32" = "yes"; then
4446 error_exit "only the 'windows' coroutine backend is valid for Windows"
4450 error_exit "unknown coroutine backend $coroutine"
4452 esac
4455 if test "$coroutine_pool" = ""; then
4456 if test "$coroutine" = "gthread" -o "$coroutine" = "win32"; then
4457 coroutine_pool=no
4458 else
4459 coroutine_pool=yes
4462 if test "$coroutine" = "gthread" -a "$coroutine_pool" = "yes"; then
4463 error_exit "'gthread' coroutine backend does not support pool (use --disable-coroutine-pool)"
4466 if test "$debug_stack_usage" = "yes"; then
4467 if test "$cpu" = "ia64" -o "$cpu" = "hppa"; then
4468 error_exit "stack usage debugging is not supported for $cpu"
4470 if test "$coroutine_pool" = "yes"; then
4471 echo "WARN: disabling coroutine pool for stack usage debugging"
4472 coroutine_pool=no
4477 ##########################################
4478 # check if we have open_by_handle_at
4480 open_by_handle_at=no
4481 cat > $TMPC << EOF
4482 #include <fcntl.h>
4483 #if !defined(AT_EMPTY_PATH)
4484 # error missing definition
4485 #else
4486 int main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
4487 #endif
4489 if compile_prog "" "" ; then
4490 open_by_handle_at=yes
4493 ########################################
4494 # check if we have linux/magic.h
4496 linux_magic_h=no
4497 cat > $TMPC << EOF
4498 #include <linux/magic.h>
4499 int main(void) {
4500 return 0;
4503 if compile_prog "" "" ; then
4504 linux_magic_h=yes
4507 ########################################
4508 # check whether we can disable warning option with a pragma (this is needed
4509 # to silence warnings in the headers of some versions of external libraries).
4510 # This test has to be compiled with -Werror as otherwise an unknown pragma is
4511 # only a warning.
4513 # If we can't selectively disable warning in the code, disable -Werror so that
4514 # the build doesn't fail anyway.
4516 pragma_disable_unused_but_set=no
4517 cat > $TMPC << EOF
4518 #pragma GCC diagnostic push
4519 #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
4520 #pragma GCC diagnostic ignored "-Wstrict-prototypes"
4521 #pragma GCC diagnostic pop
4523 int main(void) {
4524 return 0;
4527 if compile_prog "-Werror" "" ; then
4528 pragma_diagnostic_available=yes
4531 ########################################
4532 # check if we have valgrind/valgrind.h
4534 valgrind_h=no
4535 cat > $TMPC << EOF
4536 #include <valgrind/valgrind.h>
4537 int main(void) {
4538 return 0;
4541 if compile_prog "" "" ; then
4542 valgrind_h=yes
4545 ########################################
4546 # check if environ is declared
4548 has_environ=no
4549 cat > $TMPC << EOF
4550 #include <unistd.h>
4551 int main(void) {
4552 environ = 0;
4553 return 0;
4556 if compile_prog "" "" ; then
4557 has_environ=yes
4560 ########################################
4561 # check if cpuid.h is usable.
4563 cpuid_h=no
4564 cat > $TMPC << EOF
4565 #include <cpuid.h>
4566 int main(void) {
4567 unsigned a, b, c, d;
4568 int max = __get_cpuid_max(0, 0);
4570 if (max >= 1) {
4571 __cpuid(1, a, b, c, d);
4574 if (max >= 7) {
4575 __cpuid_count(7, 0, a, b, c, d);
4578 return 0;
4581 if compile_prog "" "" ; then
4582 cpuid_h=yes
4585 ########################################
4586 # check if __[u]int128_t is usable.
4588 int128=no
4589 cat > $TMPC << EOF
4590 #if defined(__clang_major__) && defined(__clang_minor__)
4591 # if ((__clang_major__ < 3) || (__clang_major__ == 3) && (__clang_minor__ < 2))
4592 # error __int128_t does not work in CLANG before 3.2
4593 # endif
4594 #endif
4595 __int128_t a;
4596 __uint128_t b;
4597 int main (void) {
4598 a = a + b;
4599 b = a * b;
4600 a = a * a;
4601 return 0;
4604 if compile_prog "" "" ; then
4605 int128=yes
4608 #########################################
4609 # See if 128-bit atomic operations are supported.
4611 atomic128=no
4612 if test "$int128" = "yes"; then
4613 cat > $TMPC << EOF
4614 int main(void)
4616 unsigned __int128 x = 0, y = 0;
4617 y = __atomic_load_16(&x, 0);
4618 __atomic_store_16(&x, y, 0);
4619 __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
4620 return 0;
4623 if compile_prog "" "" ; then
4624 atomic128=yes
4628 #########################################
4629 # See if 64-bit atomic operations are supported.
4630 # Note that without __atomic builtins, we can only
4631 # assume atomic loads/stores max at pointer size.
4633 cat > $TMPC << EOF
4634 #include <stdint.h>
4635 int main(void)
4637 uint64_t x = 0, y = 0;
4638 #ifdef __ATOMIC_RELAXED
4639 y = __atomic_load_8(&x, 0);
4640 __atomic_store_8(&x, y, 0);
4641 __atomic_compare_exchange_8(&x, &y, x, 0, 0, 0);
4642 __atomic_exchange_8(&x, y, 0);
4643 __atomic_fetch_add_8(&x, y, 0);
4644 #else
4645 typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
4646 __sync_lock_test_and_set(&x, y);
4647 __sync_val_compare_and_swap(&x, y, 0);
4648 __sync_fetch_and_add(&x, y);
4649 #endif
4650 return 0;
4653 if compile_prog "" "" ; then
4654 atomic64=yes
4657 ########################################
4658 # check if getauxval is available.
4660 getauxval=no
4661 cat > $TMPC << EOF
4662 #include <sys/auxv.h>
4663 int main(void) {
4664 return getauxval(AT_HWCAP) == 0;
4667 if compile_prog "" "" ; then
4668 getauxval=yes
4671 ########################################
4672 # check if ccache is interfering with
4673 # semantic analysis of macros
4675 unset CCACHE_CPP2
4676 ccache_cpp2=no
4677 cat > $TMPC << EOF
4678 static const int Z = 1;
4679 #define fn() ({ Z; })
4680 #define TAUT(X) ((X) == Z)
4681 #define PAREN(X, Y) (X == Y)
4682 #define ID(X) (X)
4683 int main(int argc, char *argv[])
4685 int x = 0, y = 0;
4686 x = ID(x);
4687 x = fn();
4688 fn();
4689 if (PAREN(x, y)) return 0;
4690 if (TAUT(Z)) return 0;
4691 return 0;
4695 if ! compile_object "-Werror"; then
4696 ccache_cpp2=yes
4699 #################################################
4700 # clang does not support glibc + FORTIFY_SOURCE.
4702 if test "$fortify_source" != "no"; then
4703 if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
4704 fortify_source="no";
4705 elif test -n "$cxx" &&
4706 echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
4707 fortify_source="no";
4708 else
4709 fortify_source="yes"
4713 ##########################################
4714 # check if struct fsxattr is available via linux/fs.h
4716 have_fsxattr=no
4717 cat > $TMPC << EOF
4718 #include <linux/fs.h>
4719 struct fsxattr foo;
4720 int main(void) {
4721 return 0;
4724 if compile_prog "" "" ; then
4725 have_fsxattr=yes
4728 ##########################################
4729 # check if rtnetlink.h exists and is useful
4730 have_rtnetlink=no
4731 cat > $TMPC << EOF
4732 #include <linux/rtnetlink.h>
4733 int main(void) {
4734 return IFLA_PROTO_DOWN;
4737 if compile_prog "" "" ; then
4738 have_rtnetlink=yes
4741 ##########################################
4742 # check for usable AF_VSOCK environment
4743 have_af_vsock=no
4744 cat > $TMPC << EOF
4745 #include <errno.h>
4746 #include <sys/types.h>
4747 #include <sys/socket.h>
4748 #if !defined(AF_VSOCK)
4749 # error missing AF_VSOCK flag
4750 #endif
4751 #include <linux/vm_sockets.h>
4752 int main(void) {
4753 int sock, ret;
4754 struct sockaddr_vm svm;
4755 socklen_t len = sizeof(svm);
4756 sock = socket(AF_VSOCK, SOCK_STREAM, 0);
4757 ret = getpeername(sock, (struct sockaddr *)&svm, &len);
4758 if ((ret == -1) && (errno == ENOTCONN)) {
4759 return 0;
4761 return -1;
4764 if compile_prog "" "" ; then
4765 have_af_vsock=yes
4768 #################################################
4769 # Sparc implicitly links with --relax, which is
4770 # incompatible with -r, so --no-relax should be
4771 # given. It does no harm to give it on other
4772 # platforms too.
4774 # Note: the prototype is needed since QEMU_CFLAGS
4775 # contains -Wmissing-prototypes
4776 cat > $TMPC << EOF
4777 extern int foo(void);
4778 int foo(void) { return 0; }
4780 if ! compile_object ""; then
4781 error_exit "Failed to compile object file for LD_REL_FLAGS test"
4783 for i in '-Wl,-r -Wl,--no-relax' -Wl,-r -r; do
4784 if do_cc -nostdlib $i -o $TMPMO $TMPO; then
4785 LD_REL_FLAGS=$i
4786 break
4788 done
4789 if test "$modules" = "yes" && test "$LD_REL_FLAGS" = ""; then
4790 feature_not_found "modules" "Cannot find how to build relocatable objects"
4793 ##########################################
4794 # check for sysmacros.h
4796 have_sysmacros=no
4797 cat > $TMPC << EOF
4798 #include <sys/sysmacros.h>
4799 int main(void) {
4800 return makedev(0, 0);
4803 if compile_prog "" "" ; then
4804 have_sysmacros=yes
4807 ##########################################
4808 # End of CC checks
4809 # After here, no more $cc or $ld runs
4811 if test "$gcov" = "yes" ; then
4812 CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
4813 LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
4814 elif test "$fortify_source" = "yes" ; then
4815 CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
4816 elif test "$debug" = "no"; then
4817 CFLAGS="-O2 $CFLAGS"
4820 ##########################################
4821 # Do we have libnfs
4822 if test "$libnfs" != "no" ; then
4823 if $pkg_config --atleast-version=1.9.3 libnfs; then
4824 libnfs="yes"
4825 libnfs_libs=$($pkg_config --libs libnfs)
4826 else
4827 if test "$libnfs" = "yes" ; then
4828 feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
4830 libnfs="no"
4834 # Now we've finished running tests it's OK to add -Werror to the compiler flags
4835 if test "$werror" = "yes"; then
4836 QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
4839 if test "$solaris" = "no" ; then
4840 if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
4841 LDFLAGS="-Wl,--warn-common $LDFLAGS"
4845 # test if pod2man has --utf8 option
4846 if pod2man --help | grep -q utf8; then
4847 POD2MAN="pod2man --utf8"
4848 else
4849 POD2MAN="pod2man"
4852 # Use large addresses, ASLR, no-SEH and DEP if available.
4853 if test "$mingw32" = "yes" ; then
4854 if test "$cpu" = i386; then
4855 LDFLAGS="-Wl,--large-address-aware $LDFLAGS"
4857 for flag in --dynamicbase --no-seh --nxcompat; do
4858 if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
4859 LDFLAGS="-Wl,$flag $LDFLAGS"
4861 done
4864 qemu_confdir=$sysconfdir$confsuffix
4865 qemu_moddir=$libdir$confsuffix
4866 qemu_datadir=$datadir$confsuffix
4867 qemu_localedir="$datadir/locale"
4869 tools=""
4870 tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
4871 if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
4872 tools="qemu-nbd\$(EXESUF) $tools"
4873 tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools"
4875 if test "$softmmu" = yes ; then
4876 if test "$virtfs" != no ; then
4877 if test "$cap" = yes && test "$linux" = yes && test "$attr" = yes ; then
4878 virtfs=yes
4879 tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
4880 else
4881 if test "$virtfs" = yes; then
4882 error_exit "VirtFS is supported only on Linux and requires libcap devel and libattr devel"
4884 virtfs=no
4889 # Probe for guest agent support/options
4891 if [ "$guest_agent" != "no" ]; then
4892 if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
4893 tools="qemu-ga $tools"
4894 guest_agent=yes
4895 elif [ "$guest_agent" != yes ]; then
4896 guest_agent=no
4897 else
4898 error_exit "Guest agent is not supported on this platform"
4902 # Guest agent Window MSI package
4904 if test "$guest_agent" != yes; then
4905 if test "$guest_agent_msi" = yes; then
4906 error_exit "MSI guest agent package requires guest agent enabled"
4908 guest_agent_msi=no
4909 elif test "$mingw32" != "yes"; then
4910 if test "$guest_agent_msi" = "yes"; then
4911 error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
4913 guest_agent_msi=no
4914 elif ! has wixl; then
4915 if test "$guest_agent_msi" = "yes"; then
4916 error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
4918 guest_agent_msi=no
4919 else
4920 # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
4921 # disabled explicitly
4922 if test "$guest_agent_msi" != "no"; then
4923 guest_agent_msi=yes
4927 if test "$guest_agent_msi" = "yes"; then
4928 if test "$guest_agent_with_vss" = "yes"; then
4929 QEMU_GA_MSI_WITH_VSS="-D InstallVss"
4932 if test "$QEMU_GA_MANUFACTURER" = ""; then
4933 QEMU_GA_MANUFACTURER=QEMU
4936 if test "$QEMU_GA_DISTRO" = ""; then
4937 QEMU_GA_DISTRO=Linux
4940 if test "$QEMU_GA_VERSION" = ""; then
4941 QEMU_GA_VERSION=$(cat $source_path/VERSION)
4944 QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
4946 case "$cpu" in
4947 x86_64)
4948 QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
4950 i386)
4951 QEMU_GA_MSI_ARCH="-D Arch=32"
4954 error_exit "CPU $cpu not supported for building installation package"
4956 esac
4959 # Mac OS X ships with a broken assembler
4960 roms=
4961 if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
4962 "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
4963 "$softmmu" = yes ; then
4964 # Different host OS linkers have different ideas about the name of the ELF
4965 # emulation. Linux and OpenBSD use 'elf_i386'; FreeBSD uses the _fbsd
4966 # variant; and Windows uses i386pe.
4967 for emu in elf_i386 elf_i386_fbsd i386pe; do
4968 if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
4969 ld_i386_emulation="$emu"
4970 roms="optionrom"
4971 break
4973 done
4975 if test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
4976 roms="$roms spapr-rtas"
4979 if test "$cpu" = "s390x" ; then
4980 roms="$roms s390-ccw"
4983 # Probe for the need for relocating the user-only binary.
4984 if ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) && [ "$pie" = no ]; then
4985 textseg_addr=
4986 case "$cpu" in
4987 arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
4988 # ??? Rationale for choosing this address
4989 textseg_addr=0x60000000
4991 mips)
4992 # A 256M aligned address, high in the address space, with enough
4993 # room for the code_gen_buffer above it before the stack.
4994 textseg_addr=0x60000000
4996 esac
4997 if [ -n "$textseg_addr" ]; then
4998 cat > $TMPC <<EOF
4999 int main(void) { return 0; }
5001 textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
5002 if ! compile_prog "" "$textseg_ldflags"; then
5003 # In case ld does not support -Ttext-segment, edit the default linker
5004 # script via sed to set the .text start addr. This is needed on FreeBSD
5005 # at least.
5006 if ! $ld --verbose >/dev/null 2>&1; then
5007 error_exit \
5008 "We need to link the QEMU user mode binaries at a" \
5009 "specific text address. Unfortunately your linker" \
5010 "doesn't support either the -Ttext-segment option or" \
5011 "printing the default linker script with --verbose." \
5012 "If you don't want the user mode binaries, pass the" \
5013 "--disable-user option to configure."
5016 $ld --verbose | sed \
5017 -e '1,/==================================================/d' \
5018 -e '/==================================================/,$d' \
5019 -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
5020 -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
5021 textseg_ldflags="-Wl,-T../config-host.ld"
5026 echo_version() {
5027 if test "$1" = "yes" ; then
5028 echo "($2)"
5032 # prepend pixman and ftd flags after all config tests are done
5033 QEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"
5034 libs_softmmu="$pixman_libs $libs_softmmu"
5036 echo "Install prefix $prefix"
5037 echo "BIOS directory $(eval echo $qemu_datadir)"
5038 echo "binary directory $(eval echo $bindir)"
5039 echo "library directory $(eval echo $libdir)"
5040 echo "module directory $(eval echo $qemu_moddir)"
5041 echo "libexec directory $(eval echo $libexecdir)"
5042 echo "include directory $(eval echo $includedir)"
5043 echo "config directory $(eval echo $sysconfdir)"
5044 if test "$mingw32" = "no" ; then
5045 echo "local state directory $(eval echo $local_statedir)"
5046 echo "Manual directory $(eval echo $mandir)"
5047 echo "ELF interp prefix $interp_prefix"
5048 else
5049 echo "local state directory queried at runtime"
5050 echo "Windows SDK $win_sdk"
5052 echo "Source path $source_path"
5053 echo "C compiler $cc"
5054 echo "Host C compiler $host_cc"
5055 echo "C++ compiler $cxx"
5056 echo "Objective-C compiler $objcc"
5057 echo "ARFLAGS $ARFLAGS"
5058 echo "CFLAGS $CFLAGS"
5059 echo "QEMU_CFLAGS $QEMU_CFLAGS"
5060 echo "LDFLAGS $LDFLAGS"
5061 echo "make $make"
5062 echo "install $install"
5063 echo "python $python"
5064 if test "$slirp" = "yes" ; then
5065 echo "smbd $smbd"
5067 echo "module support $modules"
5068 echo "host CPU $cpu"
5069 echo "host big endian $bigendian"
5070 echo "target list $target_list"
5071 echo "tcg debug enabled $debug_tcg"
5072 echo "gprof enabled $gprof"
5073 echo "sparse enabled $sparse"
5074 echo "strip binaries $strip_opt"
5075 echo "profiler $profiler"
5076 echo "static build $static"
5077 if test "$darwin" = "yes" ; then
5078 echo "Cocoa support $cocoa"
5080 echo "pixman $pixman"
5081 echo "SDL support $sdl $(echo_version $sdl $sdlversion)"
5082 echo "GTK support $gtk $(echo_version $gtk $gtk_version)"
5083 echo "GTK GL support $gtk_gl"
5084 echo "VTE support $vte $(echo_version $vte $vteversion)"
5085 echo "TLS priority $tls_priority"
5086 echo "GNUTLS support $gnutls"
5087 echo "GNUTLS rnd $gnutls_rnd"
5088 if test "$gcrypt" = "yes"; then
5089 echo "encryption libgcrypt"
5090 echo "libgcrypt kdf $gcrypt_kdf"
5091 elif test "$nettle" = "yes"; then
5092 echo "nettle $nettle $(echo_version $nettle $nettle_version)"
5093 else
5094 echo "encryption none"
5096 echo "nettle kdf $nettle_kdf"
5097 echo "libtasn1 $tasn1"
5098 echo "curses support $curses"
5099 echo "virgl support $virglrenderer"
5100 echo "curl support $curl"
5101 echo "mingw32 support $mingw32"
5102 echo "Audio drivers $audio_drv_list"
5103 echo "Block whitelist (rw) $block_drv_rw_whitelist"
5104 echo "Block whitelist (ro) $block_drv_ro_whitelist"
5105 echo "VirtFS support $virtfs"
5106 echo "VNC support $vnc"
5107 if test "$vnc" = "yes" ; then
5108 echo "VNC SASL support $vnc_sasl"
5109 echo "VNC JPEG support $vnc_jpeg"
5110 echo "VNC PNG support $vnc_png"
5112 if test -n "$sparc_cpu"; then
5113 echo "Target Sparc Arch $sparc_cpu"
5115 echo "xen support $xen"
5116 if test "$xen" = "yes" ; then
5117 echo "xen ctrl version $xen_ctrl_version"
5118 echo "pv dom build $xen_pv_domain_build"
5120 echo "brlapi support $brlapi"
5121 echo "bluez support $bluez"
5122 echo "Documentation $docs"
5123 echo "Tools $tools"
5124 echo "PIE $pie"
5125 echo "vde support $vde"
5126 echo "netmap support $netmap"
5127 echo "Linux AIO support $linux_aio"
5128 echo "(X)ATTR support $attr"
5129 echo "Install blobs $blobs"
5130 echo "KVM support $kvm"
5131 echo "HAX support $hax"
5132 echo "RDMA support $rdma"
5133 echo "TCG interpreter $tcg_interpreter"
5134 echo "fdt support $fdt"
5135 echo "preadv support $preadv"
5136 echo "fdatasync $fdatasync"
5137 echo "madvise $madvise"
5138 echo "posix_madvise $posix_madvise"
5139 echo "libcap-ng support $cap_ng"
5140 echo "vhost-net support $vhost_net"
5141 echo "vhost-scsi support $vhost_scsi"
5142 echo "vhost-vsock support $vhost_vsock"
5143 echo "Trace backends $trace_backends"
5144 if have_backend "simple"; then
5145 echo "Trace output file $trace_file-<pid>"
5147 echo "spice support $spice $(echo_version $spice $spice_protocol_version/$spice_server_version)"
5148 echo "rbd support $rbd"
5149 echo "xfsctl support $xfs"
5150 echo "smartcard support $smartcard"
5151 echo "libusb $libusb"
5152 echo "usb net redir $usb_redir"
5153 echo "OpenGL support $opengl"
5154 echo "OpenGL dmabufs $opengl_dmabuf"
5155 echo "libiscsi support $libiscsi"
5156 echo "libnfs support $libnfs"
5157 echo "build guest agent $guest_agent"
5158 echo "QGA VSS support $guest_agent_with_vss"
5159 echo "QGA w32 disk info $guest_agent_ntddscsi"
5160 echo "QGA MSI support $guest_agent_msi"
5161 echo "seccomp support $seccomp"
5162 echo "coroutine backend $coroutine"
5163 echo "coroutine pool $coroutine_pool"
5164 echo "debug stack usage $debug_stack_usage"
5165 echo "GlusterFS support $glusterfs"
5166 echo "gcov $gcov_tool"
5167 echo "gcov enabled $gcov"
5168 echo "TPM support $tpm"
5169 echo "libssh2 support $libssh2"
5170 echo "TPM passthrough $tpm_passthrough"
5171 echo "QOM debugging $qom_cast_debug"
5172 echo "lzo support $lzo"
5173 echo "snappy support $snappy"
5174 echo "bzip2 support $bzip2"
5175 echo "NUMA host support $numa"
5176 echo "tcmalloc support $tcmalloc"
5177 echo "jemalloc support $jemalloc"
5178 echo "avx2 optimization $avx2_opt"
5179 echo "replication support $replication"
5181 if test "$sdl_too_old" = "yes"; then
5182 echo "-> Your SDL version is too old - please upgrade to have SDL support"
5185 if test "$supported_cpu" = "no"; then
5186 echo
5187 echo "WARNING: SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!"
5188 echo
5189 echo "CPU host architecture $cpu support is not currently maintained."
5190 echo "The QEMU project intends to remove support for this host CPU in"
5191 echo "a future release if nobody volunteers to maintain it and to"
5192 echo "provide a build host for our continuous integration setup."
5193 echo "configure has succeeded and you can continue to build, but"
5194 echo "if you care about QEMU on this platform you should contact"
5195 echo "us upstream at qemu-devel@nongnu.org."
5198 if test "$supported_os" = "no"; then
5199 echo
5200 echo "WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!"
5201 echo
5202 echo "CPU host OS $targetos support is not currently maintained."
5203 echo "The QEMU project intends to remove support for this host CPU in"
5204 echo "a future release if nobody volunteers to maintain it and to"
5205 echo "provide a build host for our continuous integration setup."
5206 echo "configure has succeeded and you can continue to build, but"
5207 echo "if you care about QEMU on this platform you should contact"
5208 echo "us upstream at qemu-devel@nongnu.org."
5211 config_host_mak="config-host.mak"
5213 echo "# Automatically generated by configure - do not modify" >config-all-disas.mak
5215 echo "# Automatically generated by configure - do not modify" > $config_host_mak
5216 echo >> $config_host_mak
5218 echo all: >> $config_host_mak
5219 echo "prefix=$prefix" >> $config_host_mak
5220 echo "bindir=$bindir" >> $config_host_mak
5221 echo "libdir=$libdir" >> $config_host_mak
5222 echo "libexecdir=$libexecdir" >> $config_host_mak
5223 echo "includedir=$includedir" >> $config_host_mak
5224 echo "mandir=$mandir" >> $config_host_mak
5225 echo "sysconfdir=$sysconfdir" >> $config_host_mak
5226 echo "qemu_confdir=$qemu_confdir" >> $config_host_mak
5227 echo "qemu_datadir=$qemu_datadir" >> $config_host_mak
5228 echo "qemu_docdir=$qemu_docdir" >> $config_host_mak
5229 echo "qemu_moddir=$qemu_moddir" >> $config_host_mak
5230 if test "$mingw32" = "no" ; then
5231 echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
5233 echo "qemu_helperdir=$libexecdir" >> $config_host_mak
5234 echo "extra_cflags=$EXTRA_CFLAGS" >> $config_host_mak
5235 echo "extra_ldflags=$EXTRA_LDFLAGS" >> $config_host_mak
5236 echo "qemu_localedir=$qemu_localedir" >> $config_host_mak
5237 echo "libs_softmmu=$libs_softmmu" >> $config_host_mak
5239 echo "ARCH=$ARCH" >> $config_host_mak
5241 if test "$debug_tcg" = "yes" ; then
5242 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
5244 if test "$strip_opt" = "yes" ; then
5245 echo "STRIP=${strip}" >> $config_host_mak
5247 if test "$bigendian" = "yes" ; then
5248 echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
5250 if test "$mingw32" = "yes" ; then
5251 echo "CONFIG_WIN32=y" >> $config_host_mak
5252 echo "CONFIG_INSTALLER=y" >> $config_host_mak
5253 rc_version=$(cat $source_path/VERSION)
5254 version_major=${rc_version%%.*}
5255 rc_version=${rc_version#*.}
5256 version_minor=${rc_version%%.*}
5257 rc_version=${rc_version#*.}
5258 version_subminor=${rc_version%%.*}
5259 version_micro=0
5260 echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
5261 echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
5262 if test "$guest_agent_with_vss" = "yes" ; then
5263 echo "CONFIG_QGA_VSS=y" >> $config_host_mak
5264 echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
5265 echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
5267 if test "$guest_agent_ntddscsi" = "yes" ; then
5268 echo "CONFIG_QGA_NTDDDISK=y" >> $config_host_mak
5270 if test "$guest_agent_msi" = "yes"; then
5271 echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
5272 echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
5273 echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
5274 echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
5275 echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
5276 echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
5277 echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
5279 else
5280 echo "CONFIG_POSIX=y" >> $config_host_mak
5283 if test "$linux" = "yes" ; then
5284 echo "CONFIG_LINUX=y" >> $config_host_mak
5287 if test "$darwin" = "yes" ; then
5288 echo "CONFIG_DARWIN=y" >> $config_host_mak
5291 if test "$aix" = "yes" ; then
5292 echo "CONFIG_AIX=y" >> $config_host_mak
5295 if test "$solaris" = "yes" ; then
5296 echo "CONFIG_SOLARIS=y" >> $config_host_mak
5297 echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
5298 if test "$needs_libsunmath" = "yes" ; then
5299 echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
5302 if test "$haiku" = "yes" ; then
5303 echo "CONFIG_HAIKU=y" >> $config_host_mak
5305 if test "$static" = "yes" ; then
5306 echo "CONFIG_STATIC=y" >> $config_host_mak
5308 if test "$profiler" = "yes" ; then
5309 echo "CONFIG_PROFILER=y" >> $config_host_mak
5311 if test "$slirp" = "yes" ; then
5312 echo "CONFIG_SLIRP=y" >> $config_host_mak
5313 echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
5315 if test "$vde" = "yes" ; then
5316 echo "CONFIG_VDE=y" >> $config_host_mak
5318 if test "$netmap" = "yes" ; then
5319 echo "CONFIG_NETMAP=y" >> $config_host_mak
5321 if test "$l2tpv3" = "yes" ; then
5322 echo "CONFIG_L2TPV3=y" >> $config_host_mak
5324 if test "$cap_ng" = "yes" ; then
5325 echo "CONFIG_LIBCAP=y" >> $config_host_mak
5327 echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
5328 for drv in $audio_drv_list; do
5329 def=CONFIG_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
5330 echo "$def=y" >> $config_host_mak
5331 done
5332 if test "$audio_pt_int" = "yes" ; then
5333 echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
5335 if test "$audio_win_int" = "yes" ; then
5336 echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
5338 echo "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
5339 echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
5340 if test "$vnc" = "yes" ; then
5341 echo "CONFIG_VNC=y" >> $config_host_mak
5343 if test "$vnc_sasl" = "yes" ; then
5344 echo "CONFIG_VNC_SASL=y" >> $config_host_mak
5346 if test "$vnc_jpeg" = "yes" ; then
5347 echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
5349 if test "$vnc_png" = "yes" ; then
5350 echo "CONFIG_VNC_PNG=y" >> $config_host_mak
5352 if test "$fnmatch" = "yes" ; then
5353 echo "CONFIG_FNMATCH=y" >> $config_host_mak
5355 if test "$xfs" = "yes" ; then
5356 echo "CONFIG_XFS=y" >> $config_host_mak
5358 qemu_version=$(head $source_path/VERSION)
5359 echo "VERSION=$qemu_version" >>$config_host_mak
5360 echo "PKGVERSION=$pkgversion" >>$config_host_mak
5361 echo "SRC_PATH=$source_path" >> $config_host_mak
5362 echo "TARGET_DIRS=$target_list" >> $config_host_mak
5363 if [ "$docs" = "yes" ] ; then
5364 echo "BUILD_DOCS=yes" >> $config_host_mak
5366 if [ "$want_tools" = "yes" ] ; then
5367 echo "BUILD_TOOLS=yes" >> $config_host_mak
5369 if test "$modules" = "yes"; then
5370 # $shacmd can generate a hash started with digit, which the compiler doesn't
5371 # like as an symbol. So prefix it with an underscore
5372 echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
5373 echo "CONFIG_MODULES=y" >> $config_host_mak
5375 if test "$sdl" = "yes" ; then
5376 echo "CONFIG_SDL=y" >> $config_host_mak
5377 echo "CONFIG_SDLABI=$sdlabi" >> $config_host_mak
5378 echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
5380 if test "$cocoa" = "yes" ; then
5381 echo "CONFIG_COCOA=y" >> $config_host_mak
5383 if test "$curses" = "yes" ; then
5384 echo "CONFIG_CURSES=y" >> $config_host_mak
5386 if test "$utimens" = "yes" ; then
5387 echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
5389 if test "$pipe2" = "yes" ; then
5390 echo "CONFIG_PIPE2=y" >> $config_host_mak
5392 if test "$accept4" = "yes" ; then
5393 echo "CONFIG_ACCEPT4=y" >> $config_host_mak
5395 if test "$splice" = "yes" ; then
5396 echo "CONFIG_SPLICE=y" >> $config_host_mak
5398 if test "$eventfd" = "yes" ; then
5399 echo "CONFIG_EVENTFD=y" >> $config_host_mak
5401 if test "$memfd" = "yes" ; then
5402 echo "CONFIG_MEMFD=y" >> $config_host_mak
5404 if test "$fallocate" = "yes" ; then
5405 echo "CONFIG_FALLOCATE=y" >> $config_host_mak
5407 if test "$fallocate_punch_hole" = "yes" ; then
5408 echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
5410 if test "$fallocate_zero_range" = "yes" ; then
5411 echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
5413 if test "$posix_fallocate" = "yes" ; then
5414 echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
5416 if test "$sync_file_range" = "yes" ; then
5417 echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
5419 if test "$fiemap" = "yes" ; then
5420 echo "CONFIG_FIEMAP=y" >> $config_host_mak
5422 if test "$dup3" = "yes" ; then
5423 echo "CONFIG_DUP3=y" >> $config_host_mak
5425 if test "$ppoll" = "yes" ; then
5426 echo "CONFIG_PPOLL=y" >> $config_host_mak
5428 if test "$prctl_pr_set_timerslack" = "yes" ; then
5429 echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
5431 if test "$epoll" = "yes" ; then
5432 echo "CONFIG_EPOLL=y" >> $config_host_mak
5434 if test "$epoll_create1" = "yes" ; then
5435 echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
5437 if test "$sendfile" = "yes" ; then
5438 echo "CONFIG_SENDFILE=y" >> $config_host_mak
5440 if test "$timerfd" = "yes" ; then
5441 echo "CONFIG_TIMERFD=y" >> $config_host_mak
5443 if test "$setns" = "yes" ; then
5444 echo "CONFIG_SETNS=y" >> $config_host_mak
5446 if test "$clock_adjtime" = "yes" ; then
5447 echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
5449 if test "$syncfs" = "yes" ; then
5450 echo "CONFIG_SYNCFS=y" >> $config_host_mak
5452 if test "$inotify" = "yes" ; then
5453 echo "CONFIG_INOTIFY=y" >> $config_host_mak
5455 if test "$inotify1" = "yes" ; then
5456 echo "CONFIG_INOTIFY1=y" >> $config_host_mak
5458 if test "$byteswap_h" = "yes" ; then
5459 echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
5461 if test "$bswap_h" = "yes" ; then
5462 echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
5464 if test "$curl" = "yes" ; then
5465 echo "CONFIG_CURL=m" >> $config_host_mak
5466 echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
5467 echo "CURL_LIBS=$curl_libs" >> $config_host_mak
5469 if test "$brlapi" = "yes" ; then
5470 echo "CONFIG_BRLAPI=y" >> $config_host_mak
5472 if test "$bluez" = "yes" ; then
5473 echo "CONFIG_BLUEZ=y" >> $config_host_mak
5474 echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
5476 if test "$glib_subprocess" = "yes" ; then
5477 echo "CONFIG_HAS_GLIB_SUBPROCESS_TESTS=y" >> $config_host_mak
5479 if test "$gtk" = "yes" ; then
5480 echo "CONFIG_GTK=y" >> $config_host_mak
5481 echo "CONFIG_GTKABI=$gtkabi" >> $config_host_mak
5482 echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
5483 echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
5484 if test "$gtk_gl" = "yes" ; then
5485 echo "CONFIG_GTK_GL=y" >> $config_host_mak
5488 echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
5489 if test "$gnutls" = "yes" ; then
5490 echo "CONFIG_GNUTLS=y" >> $config_host_mak
5492 if test "$gnutls_rnd" = "yes" ; then
5493 echo "CONFIG_GNUTLS_RND=y" >> $config_host_mak
5495 if test "$gcrypt" = "yes" ; then
5496 echo "CONFIG_GCRYPT=y" >> $config_host_mak
5497 if test "$gcrypt_hmac" = "yes" ; then
5498 echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
5500 if test "$gcrypt_kdf" = "yes" ; then
5501 echo "CONFIG_GCRYPT_KDF=y" >> $config_host_mak
5504 if test "$nettle" = "yes" ; then
5505 echo "CONFIG_NETTLE=y" >> $config_host_mak
5506 echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
5507 if test "$nettle_kdf" = "yes" ; then
5508 echo "CONFIG_NETTLE_KDF=y" >> $config_host_mak
5511 if test "$tasn1" = "yes" ; then
5512 echo "CONFIG_TASN1=y" >> $config_host_mak
5514 if test "$have_ifaddrs_h" = "yes" ; then
5515 echo "HAVE_IFADDRS_H=y" >> $config_host_mak
5517 if test "$have_broken_size_max" = "yes" ; then
5518 echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
5521 # Work around a system header bug with some kernel/XFS header
5522 # versions where they both try to define 'struct fsxattr':
5523 # xfs headers will not try to redefine structs from linux headers
5524 # if this macro is set.
5525 if test "$have_fsxattr" = "yes" ; then
5526 echo "HAVE_FSXATTR=y" >> $config_host_mak
5528 if test "$vte" = "yes" ; then
5529 echo "CONFIG_VTE=y" >> $config_host_mak
5530 echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
5532 if test "$virglrenderer" = "yes" ; then
5533 echo "CONFIG_VIRGL=y" >> $config_host_mak
5534 echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
5535 echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
5537 if test "$xen" = "yes" ; then
5538 echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
5539 echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
5540 if test "$xen_pv_domain_build" = "yes" ; then
5541 echo "CONFIG_XEN_PV_DOMAIN_BUILD=y" >> $config_host_mak
5544 if test "$linux_aio" = "yes" ; then
5545 echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
5547 if test "$attr" = "yes" ; then
5548 echo "CONFIG_ATTR=y" >> $config_host_mak
5550 if test "$libattr" = "yes" ; then
5551 echo "CONFIG_LIBATTR=y" >> $config_host_mak
5553 if test "$virtfs" = "yes" ; then
5554 echo "CONFIG_VIRTFS=y" >> $config_host_mak
5556 if test "$vhost_scsi" = "yes" ; then
5557 echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
5559 if test "$vhost_net" = "yes" ; then
5560 echo "CONFIG_VHOST_NET_USED=y" >> $config_host_mak
5562 if test "$vhost_vsock" = "yes" ; then
5563 echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
5565 if test "$blobs" = "yes" ; then
5566 echo "INSTALL_BLOBS=yes" >> $config_host_mak
5568 if test "$iovec" = "yes" ; then
5569 echo "CONFIG_IOVEC=y" >> $config_host_mak
5571 if test "$preadv" = "yes" ; then
5572 echo "CONFIG_PREADV=y" >> $config_host_mak
5574 if test "$fdt" = "yes" ; then
5575 echo "CONFIG_FDT=y" >> $config_host_mak
5577 if test "$signalfd" = "yes" ; then
5578 echo "CONFIG_SIGNALFD=y" >> $config_host_mak
5580 if test "$tcg_interpreter" = "yes" ; then
5581 echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
5583 if test "$fdatasync" = "yes" ; then
5584 echo "CONFIG_FDATASYNC=y" >> $config_host_mak
5586 if test "$madvise" = "yes" ; then
5587 echo "CONFIG_MADVISE=y" >> $config_host_mak
5589 if test "$posix_madvise" = "yes" ; then
5590 echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
5593 if test "$spice" = "yes" ; then
5594 echo "CONFIG_SPICE=y" >> $config_host_mak
5597 if test "$smartcard" = "yes" ; then
5598 echo "CONFIG_SMARTCARD=y" >> $config_host_mak
5601 if test "$libusb" = "yes" ; then
5602 echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
5605 if test "$usb_redir" = "yes" ; then
5606 echo "CONFIG_USB_REDIR=y" >> $config_host_mak
5609 if test "$opengl" = "yes" ; then
5610 echo "CONFIG_OPENGL=y" >> $config_host_mak
5611 echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
5612 if test "$opengl_dmabuf" = "yes" ; then
5613 echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
5617 if test "$avx2_opt" = "yes" ; then
5618 echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
5621 if test "$lzo" = "yes" ; then
5622 echo "CONFIG_LZO=y" >> $config_host_mak
5625 if test "$snappy" = "yes" ; then
5626 echo "CONFIG_SNAPPY=y" >> $config_host_mak
5629 if test "$bzip2" = "yes" ; then
5630 echo "CONFIG_BZIP2=y" >> $config_host_mak
5631 echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
5634 if test "$libiscsi" = "yes" ; then
5635 echo "CONFIG_LIBISCSI=m" >> $config_host_mak
5636 echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
5637 echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
5640 if test "$libnfs" = "yes" ; then
5641 echo "CONFIG_LIBNFS=m" >> $config_host_mak
5642 echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
5645 if test "$seccomp" = "yes"; then
5646 echo "CONFIG_SECCOMP=y" >> $config_host_mak
5649 # XXX: suppress that
5650 if [ "$bsd" = "yes" ] ; then
5651 echo "CONFIG_BSD=y" >> $config_host_mak
5654 if test "$localtime_r" = "yes" ; then
5655 echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
5657 if test "$qom_cast_debug" = "yes" ; then
5658 echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
5660 if test "$rbd" = "yes" ; then
5661 echo "CONFIG_RBD=m" >> $config_host_mak
5662 echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
5663 echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
5666 echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
5667 if test "$coroutine_pool" = "yes" ; then
5668 echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
5669 else
5670 echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
5673 if test "$debug_stack_usage" = "yes" ; then
5674 echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
5677 if test "$open_by_handle_at" = "yes" ; then
5678 echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
5681 if test "$linux_magic_h" = "yes" ; then
5682 echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
5685 if test "$pragma_diagnostic_available" = "yes" ; then
5686 echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
5689 if test "$valgrind_h" = "yes" ; then
5690 echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
5693 if test "$has_environ" = "yes" ; then
5694 echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
5697 if test "$cpuid_h" = "yes" ; then
5698 echo "CONFIG_CPUID_H=y" >> $config_host_mak
5701 if test "$int128" = "yes" ; then
5702 echo "CONFIG_INT128=y" >> $config_host_mak
5705 if test "$atomic128" = "yes" ; then
5706 echo "CONFIG_ATOMIC128=y" >> $config_host_mak
5709 if test "$atomic64" = "yes" ; then
5710 echo "CONFIG_ATOMIC64=y" >> $config_host_mak
5713 if test "$getauxval" = "yes" ; then
5714 echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
5717 if test "$glusterfs" = "yes" ; then
5718 echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
5719 echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
5720 echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
5723 if test "$glusterfs_xlator_opt" = "yes" ; then
5724 echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
5727 if test "$glusterfs_discard" = "yes" ; then
5728 echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
5731 if test "$glusterfs_zerofill" = "yes" ; then
5732 echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
5735 if test "$libssh2" = "yes" ; then
5736 echo "CONFIG_LIBSSH2=m" >> $config_host_mak
5737 echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
5738 echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak
5741 # USB host support
5742 if test "$libusb" = "yes"; then
5743 echo "HOST_USB=libusb legacy" >> $config_host_mak
5744 else
5745 echo "HOST_USB=stub" >> $config_host_mak
5748 # TPM passthrough support?
5749 if test "$tpm" = "yes"; then
5750 echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak
5751 if test "$tpm_passthrough" = "yes"; then
5752 echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
5756 echo "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
5757 if have_backend "nop"; then
5758 echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
5760 if have_backend "simple"; then
5761 echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
5762 # Set the appropriate trace file.
5763 trace_file="\"$trace_file-\" FMT_pid"
5765 if have_backend "log"; then
5766 echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
5768 if have_backend "ust"; then
5769 echo "CONFIG_TRACE_UST=y" >> $config_host_mak
5771 if have_backend "dtrace"; then
5772 echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
5773 if test "$trace_backend_stap" = "yes" ; then
5774 echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
5777 if have_backend "ftrace"; then
5778 if test "$linux" = "yes" ; then
5779 echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
5780 else
5781 feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
5784 if have_backend "syslog"; then
5785 if test "$posix_syslog" = "yes" ; then
5786 echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
5787 else
5788 feature_not_found "syslog(trace backend)" "syslog not available"
5791 echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
5793 if test "$rdma" = "yes" ; then
5794 echo "CONFIG_RDMA=y" >> $config_host_mak
5797 if test "$have_rtnetlink" = "yes" ; then
5798 echo "CONFIG_RTNETLINK=y" >> $config_host_mak
5801 if test "$replication" = "yes" ; then
5802 echo "CONFIG_REPLICATION=y" >> $config_host_mak
5805 if test "$have_af_vsock" = "yes" ; then
5806 echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
5809 if test "$have_sysmacros" = "yes" ; then
5810 echo "CONFIG_SYSMACROS=y" >> $config_host_mak
5813 # Hold two types of flag:
5814 # CONFIG_THREAD_SETNAME_BYTHREAD - we've got a way of setting the name on
5815 # a thread we have a handle to
5816 # CONFIG_PTHREAD_SETNAME_NP - A way of doing it on a particular
5817 # platform
5818 if test "$pthread_setname_np" = "yes" ; then
5819 echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
5820 echo "CONFIG_PTHREAD_SETNAME_NP=y" >> $config_host_mak
5823 if test "$tcg_interpreter" = "yes"; then
5824 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
5825 elif test "$ARCH" = "sparc64" ; then
5826 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
5827 elif test "$ARCH" = "s390x" ; then
5828 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
5829 elif test "$ARCH" = "x86_64" -o "$ARCH" = "x32" ; then
5830 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
5831 elif test "$ARCH" = "ppc64" ; then
5832 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/ppc $QEMU_INCLUDES"
5833 else
5834 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
5836 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg $QEMU_INCLUDES"
5838 echo "TOOLS=$tools" >> $config_host_mak
5839 echo "ROMS=$roms" >> $config_host_mak
5840 echo "MAKE=$make" >> $config_host_mak
5841 echo "INSTALL=$install" >> $config_host_mak
5842 echo "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
5843 echo "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
5844 echo "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
5845 echo "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
5846 echo "PYTHON=$python" >> $config_host_mak
5847 echo "CC=$cc" >> $config_host_mak
5848 if $iasl -h > /dev/null 2>&1; then
5849 echo "IASL=$iasl" >> $config_host_mak
5851 echo "CC_I386=$cc_i386" >> $config_host_mak
5852 echo "HOST_CC=$host_cc" >> $config_host_mak
5853 echo "CXX=$cxx" >> $config_host_mak
5854 echo "OBJCC=$objcc" >> $config_host_mak
5855 echo "AR=$ar" >> $config_host_mak
5856 echo "ARFLAGS=$ARFLAGS" >> $config_host_mak
5857 echo "AS=$as" >> $config_host_mak
5858 echo "CCAS=$ccas" >> $config_host_mak
5859 echo "CPP=$cpp" >> $config_host_mak
5860 echo "OBJCOPY=$objcopy" >> $config_host_mak
5861 echo "LD=$ld" >> $config_host_mak
5862 echo "NM=$nm" >> $config_host_mak
5863 echo "WINDRES=$windres" >> $config_host_mak
5864 echo "CFLAGS=$CFLAGS" >> $config_host_mak
5865 echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
5866 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
5867 echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
5868 if test "$sparse" = "yes" ; then
5869 echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_host_mak
5870 echo "CPP := REAL_CC=\"\$(CPP)\" cgcc" >> $config_host_mak
5871 echo "CXX := REAL_CC=\"\$(CXX)\" cgcc" >> $config_host_mak
5872 echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_host_mak
5873 echo "QEMU_CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
5875 if test "$cross_prefix" != ""; then
5876 echo "AUTOCONF_HOST := --host=${cross_prefix%-}" >> $config_host_mak
5877 else
5878 echo "AUTOCONF_HOST := " >> $config_host_mak
5880 echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
5881 echo "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
5882 echo "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
5883 echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
5884 echo "LIBS+=$LIBS" >> $config_host_mak
5885 echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
5886 echo "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
5887 echo "EXESUF=$EXESUF" >> $config_host_mak
5888 echo "DSOSUF=$DSOSUF" >> $config_host_mak
5889 echo "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
5890 echo "LIBS_QGA+=$libs_qga" >> $config_host_mak
5891 echo "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
5892 echo "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
5893 echo "POD2MAN=$POD2MAN" >> $config_host_mak
5894 echo "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
5895 if test "$gcov" = "yes" ; then
5896 echo "CONFIG_GCOV=y" >> $config_host_mak
5897 echo "GCOV=$gcov_tool" >> $config_host_mak
5900 # use included Linux headers
5901 if test "$linux" = "yes" ; then
5902 mkdir -p linux-headers
5903 case "$cpu" in
5904 i386|x86_64|x32)
5905 linux_arch=x86
5907 ppcemb|ppc|ppc64)
5908 linux_arch=powerpc
5910 s390x)
5911 linux_arch=s390
5913 aarch64)
5914 linux_arch=arm64
5916 mips64)
5917 linux_arch=mips
5920 # For most CPUs the kernel architecture name and QEMU CPU name match.
5921 linux_arch="$cpu"
5923 esac
5924 # For non-KVM architectures we will not have asm headers
5925 if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
5926 symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
5930 for target in $target_list; do
5931 target_dir="$target"
5932 config_target_mak=$target_dir/config-target.mak
5933 target_name=$(echo $target | cut -d '-' -f 1)
5934 target_bigendian="no"
5936 case "$target_name" in
5937 armeb|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
5938 target_bigendian=yes
5940 esac
5941 target_softmmu="no"
5942 target_user_only="no"
5943 target_linux_user="no"
5944 target_bsd_user="no"
5945 case "$target" in
5946 ${target_name}-softmmu)
5947 target_softmmu="yes"
5949 ${target_name}-linux-user)
5950 if test "$linux" != "yes" ; then
5951 error_exit "Target '$target' is only available on a Linux host"
5953 target_user_only="yes"
5954 target_linux_user="yes"
5956 ${target_name}-bsd-user)
5957 if test "$bsd" != "yes" ; then
5958 error_exit "Target '$target' is only available on a BSD host"
5960 target_user_only="yes"
5961 target_bsd_user="yes"
5964 error_exit "Target '$target' not recognised"
5965 exit 1
5967 esac
5969 mkdir -p $target_dir
5970 echo "# Automatically generated by configure - do not modify" > $config_target_mak
5972 bflt="no"
5973 mttcg="no"
5974 interp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
5975 gdb_xml_files=""
5977 TARGET_ARCH="$target_name"
5978 TARGET_BASE_ARCH=""
5979 TARGET_ABI_DIR=""
5981 case "$target_name" in
5982 i386)
5984 x86_64)
5985 TARGET_BASE_ARCH=i386
5987 alpha)
5988 mttcg="yes"
5990 arm|armeb)
5991 TARGET_ARCH=arm
5992 bflt="yes"
5993 mttcg="yes"
5994 gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
5996 aarch64)
5997 TARGET_BASE_ARCH=arm
5998 bflt="yes"
5999 mttcg="yes"
6000 gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
6002 cris)
6004 hppa)
6006 lm32)
6008 m68k)
6009 bflt="yes"
6010 gdb_xml_files="cf-core.xml cf-fp.xml"
6012 microblaze|microblazeel)
6013 TARGET_ARCH=microblaze
6014 bflt="yes"
6016 mips|mipsel)
6017 TARGET_ARCH=mips
6018 echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
6020 mipsn32|mipsn32el)
6021 TARGET_ARCH=mips64
6022 TARGET_BASE_ARCH=mips
6023 echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
6024 echo "TARGET_ABI32=y" >> $config_target_mak
6026 mips64|mips64el)
6027 TARGET_ARCH=mips64
6028 TARGET_BASE_ARCH=mips
6029 echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
6031 moxie)
6033 nios2)
6035 or1k)
6036 TARGET_ARCH=openrisc
6037 TARGET_BASE_ARCH=openrisc
6039 ppc)
6040 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
6042 ppcemb)
6043 TARGET_BASE_ARCH=ppc
6044 TARGET_ABI_DIR=ppc
6045 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
6047 ppc64)
6048 TARGET_BASE_ARCH=ppc
6049 TARGET_ABI_DIR=ppc
6050 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
6052 ppc64le)
6053 TARGET_ARCH=ppc64
6054 TARGET_BASE_ARCH=ppc
6055 TARGET_ABI_DIR=ppc
6056 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
6058 ppc64abi32)
6059 TARGET_ARCH=ppc64
6060 TARGET_BASE_ARCH=ppc
6061 TARGET_ABI_DIR=ppc
6062 echo "TARGET_ABI32=y" >> $config_target_mak
6063 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
6065 sh4|sh4eb)
6066 TARGET_ARCH=sh4
6067 bflt="yes"
6069 sparc)
6071 sparc64)
6072 TARGET_BASE_ARCH=sparc
6074 sparc32plus)
6075 TARGET_ARCH=sparc64
6076 TARGET_BASE_ARCH=sparc
6077 TARGET_ABI_DIR=sparc
6078 echo "TARGET_ABI32=y" >> $config_target_mak
6080 s390x)
6081 gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml s390-cr.xml s390-virt.xml"
6083 tilegx)
6085 tricore)
6087 unicore32)
6089 xtensa|xtensaeb)
6090 TARGET_ARCH=xtensa
6093 error_exit "Unsupported target CPU"
6095 esac
6096 # TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
6097 if [ "$TARGET_BASE_ARCH" = "" ]; then
6098 TARGET_BASE_ARCH=$TARGET_ARCH
6101 symlink "$source_path/Makefile.target" "$target_dir/Makefile"
6103 upper() {
6104 echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
6107 target_arch_name="$(upper $TARGET_ARCH)"
6108 echo "TARGET_$target_arch_name=y" >> $config_target_mak
6109 echo "TARGET_NAME=$target_name" >> $config_target_mak
6110 echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
6111 if [ "$TARGET_ABI_DIR" = "" ]; then
6112 TARGET_ABI_DIR=$TARGET_ARCH
6114 echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
6115 if [ "$HOST_VARIANT_DIR" != "" ]; then
6116 echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
6118 case "$target_name" in
6119 i386|x86_64)
6120 if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
6121 echo "CONFIG_XEN=y" >> $config_target_mak
6122 if test "$xen_pci_passthrough" = yes; then
6123 echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
6128 esac
6129 case "$target_name" in
6130 aarch64|arm|i386|x86_64|ppcemb|ppc|ppc64|s390x|mipsel|mips)
6131 # Make sure the target and host cpus are compatible
6132 if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
6133 \( "$target_name" = "$cpu" -o \
6134 \( "$target_name" = "ppcemb" -a "$cpu" = "ppc" \) -o \
6135 \( "$target_name" = "ppc64" -a "$cpu" = "ppc" \) -o \
6136 \( "$target_name" = "ppc" -a "$cpu" = "ppc64" \) -o \
6137 \( "$target_name" = "ppcemb" -a "$cpu" = "ppc64" \) -o \
6138 \( "$target_name" = "mipsel" -a "$cpu" = "mips" \) -o \
6139 \( "$target_name" = "x86_64" -a "$cpu" = "i386" \) -o \
6140 \( "$target_name" = "i386" -a "$cpu" = "x86_64" \) -o \
6141 \( "$target_name" = "x86_64" -a "$cpu" = "x32" \) -o \
6142 \( "$target_name" = "i386" -a "$cpu" = "x32" \) \) ; then
6143 echo "CONFIG_KVM=y" >> $config_target_mak
6144 if test "$vhost_net" = "yes" ; then
6145 echo "CONFIG_VHOST_NET=y" >> $config_target_mak
6146 echo "CONFIG_VHOST_NET_TEST_$target_name=y" >> $config_host_mak
6149 esac
6150 if test "$hax" = "yes" ; then
6151 if test "$target_softmmu" = "yes" ; then
6152 case "$target_name" in
6153 i386|x86_64)
6154 echo "CONFIG_HAX=y" >> $config_target_mak
6156 esac
6159 if test "$target_bigendian" = "yes" ; then
6160 echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
6162 if test "$target_softmmu" = "yes" ; then
6163 echo "CONFIG_SOFTMMU=y" >> $config_target_mak
6164 if test "$mttcg" = "yes" ; then
6165 echo "TARGET_SUPPORTS_MTTCG=y" >> $config_target_mak
6168 if test "$target_user_only" = "yes" ; then
6169 echo "CONFIG_USER_ONLY=y" >> $config_target_mak
6170 echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
6172 if test "$target_linux_user" = "yes" ; then
6173 echo "CONFIG_LINUX_USER=y" >> $config_target_mak
6175 list=""
6176 if test ! -z "$gdb_xml_files" ; then
6177 for x in $gdb_xml_files; do
6178 list="$list $source_path/gdb-xml/$x"
6179 done
6180 echo "TARGET_XML_FILES=$list" >> $config_target_mak
6183 if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
6184 echo "TARGET_HAS_BFLT=y" >> $config_target_mak
6186 if test "$target_bsd_user" = "yes" ; then
6187 echo "CONFIG_BSD_USER=y" >> $config_target_mak
6190 # generate QEMU_CFLAGS/LDFLAGS for targets
6192 cflags=""
6193 ldflags=""
6195 disas_config() {
6196 echo "CONFIG_${1}_DIS=y" >> $config_target_mak
6197 echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
6200 for i in $ARCH $TARGET_BASE_ARCH ; do
6201 case "$i" in
6202 alpha)
6203 disas_config "ALPHA"
6205 aarch64)
6206 if test -n "${cxx}"; then
6207 disas_config "ARM_A64"
6210 arm)
6211 disas_config "ARM"
6212 if test -n "${cxx}"; then
6213 disas_config "ARM_A64"
6216 cris)
6217 disas_config "CRIS"
6219 hppa)
6220 disas_config "HPPA"
6222 i386|x86_64|x32)
6223 disas_config "I386"
6225 ia64*)
6226 disas_config "IA64"
6228 lm32)
6229 disas_config "LM32"
6231 m68k)
6232 disas_config "M68K"
6234 microblaze*)
6235 disas_config "MICROBLAZE"
6237 mips*)
6238 disas_config "MIPS"
6240 moxie*)
6241 disas_config "MOXIE"
6243 nios2)
6244 disas_config "NIOS2"
6246 or1k)
6247 disas_config "OPENRISC"
6249 ppc*)
6250 disas_config "PPC"
6252 s390*)
6253 disas_config "S390"
6255 sh4)
6256 disas_config "SH4"
6258 sparc*)
6259 disas_config "SPARC"
6261 xtensa*)
6262 disas_config "XTENSA"
6264 esac
6265 done
6266 if test "$tcg_interpreter" = "yes" ; then
6267 disas_config "TCI"
6270 case "$ARCH" in
6271 alpha)
6272 # Ensure there's only a single GP
6273 cflags="-msmall-data $cflags"
6275 esac
6277 if test "$gprof" = "yes" ; then
6278 echo "TARGET_GPROF=yes" >> $config_target_mak
6279 if test "$target_linux_user" = "yes" ; then
6280 cflags="-p $cflags"
6281 ldflags="-p $ldflags"
6283 if test "$target_softmmu" = "yes" ; then
6284 ldflags="-p $ldflags"
6285 echo "GPROF_CFLAGS=-p" >> $config_target_mak
6289 if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
6290 ldflags="$ldflags $textseg_ldflags"
6293 echo "LDFLAGS+=$ldflags" >> $config_target_mak
6294 echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak
6296 done # for target in $targets
6298 if [ "$pixman" = "internal" ]; then
6299 echo "config-host.h: subdir-pixman" >> $config_host_mak
6302 if [ "$dtc_internal" = "yes" ]; then
6303 echo "config-host.h: subdir-dtc" >> $config_host_mak
6306 if test "$numa" = "yes"; then
6307 echo "CONFIG_NUMA=y" >> $config_host_mak
6310 if test "$ccache_cpp2" = "yes"; then
6311 echo "export CCACHE_CPP2=y" >> $config_host_mak
6314 # build tree in object directory in case the source is not in the current directory
6315 DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests"
6316 DIRS="$DIRS docs fsdev"
6317 DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
6318 DIRS="$DIRS roms/seabios roms/vgabios"
6319 DIRS="$DIRS qapi-generated"
6320 FILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
6321 FILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
6322 FILES="$FILES tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
6323 FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
6324 FILES="$FILES pc-bios/spapr-rtas/Makefile"
6325 FILES="$FILES pc-bios/s390-ccw/Makefile"
6326 FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
6327 FILES="$FILES pc-bios/qemu-icon.bmp"
6328 for bios_file in \
6329 $source_path/pc-bios/*.bin \
6330 $source_path/pc-bios/*.lid \
6331 $source_path/pc-bios/*.aml \
6332 $source_path/pc-bios/*.rom \
6333 $source_path/pc-bios/*.dtb \
6334 $source_path/pc-bios/*.img \
6335 $source_path/pc-bios/openbios-* \
6336 $source_path/pc-bios/u-boot.* \
6337 $source_path/pc-bios/palcode-*
6339 FILES="$FILES pc-bios/$(basename $bios_file)"
6340 done
6341 for test_file in $(find $source_path/tests/acpi-test-data -type f)
6343 FILES="$FILES tests/acpi-test-data$(echo $test_file | sed -e 's/.*acpi-test-data//')"
6344 done
6345 mkdir -p $DIRS
6346 for f in $FILES ; do
6347 if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
6348 symlink "$source_path/$f" "$f"
6350 done
6352 # temporary config to build submodules
6353 for rom in seabios vgabios ; do
6354 config_mak=roms/$rom/config.mak
6355 echo "# Automatically generated by configure - do not modify" > $config_mak
6356 echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
6357 echo "AS=$as" >> $config_mak
6358 echo "CCAS=$ccas" >> $config_mak
6359 echo "CC=$cc" >> $config_mak
6360 echo "BCC=bcc" >> $config_mak
6361 echo "CPP=$cpp" >> $config_mak
6362 echo "OBJCOPY=objcopy" >> $config_mak
6363 echo "IASL=$iasl" >> $config_mak
6364 echo "LD=$ld" >> $config_mak
6365 done
6367 # set up tests data directory
6368 if [ ! -e tests/data ]; then
6369 symlink "$source_path/tests/data" tests/data
6372 # set up qemu-iotests in this build directory
6373 iotests_common_env="tests/qemu-iotests/common.env"
6374 iotests_check="tests/qemu-iotests/check"
6376 echo "# Automatically generated by configure - do not modify" > "$iotests_common_env"
6377 echo >> "$iotests_common_env"
6378 echo "export PYTHON='$python'" >> "$iotests_common_env"
6380 if [ ! -e "$iotests_check" ]; then
6381 symlink "$source_path/$iotests_check" "$iotests_check"
6384 # Save the configure command line for later reuse.
6385 cat <<EOD >config.status
6386 #!/bin/sh
6387 # Generated by configure.
6388 # Run this file to recreate the current configuration.
6389 # Compiler output produced by configure, useful for debugging
6390 # configure, is in config.log if it exists.
6392 printf "exec" >>config.status
6393 printf " '%s'" "$0" "$@" >>config.status
6394 echo ' "$@"' >>config.status
6395 chmod +x config.status
6397 rm -r "$TMPDIR1"