Merge remote-tracking branch 'qemu/master'
[qemu/ar7.git] / configure
blobc9e48b9435b91d4b576c329f7b3ba3a38f85f627
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"
328 bogus_os="no"
330 # parse CC options first
331 for opt do
332 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
333 case "$opt" in
334 --cross-prefix=*) cross_prefix="$optarg"
336 --cc=*) CC="$optarg"
338 --cxx=*) CXX="$optarg"
340 --source-path=*) source_path="$optarg"
342 --cpu=*) cpu="$optarg"
344 --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
345 EXTRA_CFLAGS="$optarg"
347 --extra-ldflags=*) LDFLAGS="$LDFLAGS $optarg"
348 EXTRA_LDFLAGS="$optarg"
350 --enable-debug-info) debug_info="yes"
352 --disable-debug-info) debug_info="no"
354 esac
355 done
356 # OS specific
357 # Using uname is really, really broken. Once we have the right set of checks
358 # we can eliminate its usage altogether.
360 # Preferred compiler:
361 # ${CC} (if set)
362 # ${cross_prefix}gcc (if cross-prefix specified)
363 # system compiler
364 if test -z "${CC}${cross_prefix}"; then
365 cc="$host_cc"
366 else
367 cc="${CC-${cross_prefix}gcc}"
370 if test -z "${CXX}${cross_prefix}"; then
371 cxx="c++"
372 else
373 cxx="${CXX-${cross_prefix}g++}"
376 ar="${AR-${cross_prefix}ar}"
377 as="${AS-${cross_prefix}as}"
378 ccas="${CCAS-$cc}"
379 cpp="${CPP-$cc -E}"
380 objcopy="${OBJCOPY-${cross_prefix}objcopy}"
381 ld="${LD-${cross_prefix}ld}"
382 nm="${NM-${cross_prefix}nm}"
383 strip="${STRIP-${cross_prefix}strip}"
384 windres="${WINDRES-${cross_prefix}windres}"
385 pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
386 query_pkg_config() {
387 "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
389 pkg_config=query_pkg_config
390 sdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
391 sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
393 # If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
394 ARFLAGS="${ARFLAGS-rv}"
396 # default flags for all hosts
397 # We use -fwrapv to tell the compiler that we require a C dialect where
398 # left shift of signed integers is well defined and has the expected
399 # 2s-complement style results. (Both clang and gcc agree that it
400 # provides these semantics.)
401 QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
402 QEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
403 QEMU_CFLAGS="-Wmissing-format-attribute $QEMU_CFLAGS"
404 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
405 QEMU_CFLAGS="-Wno-unused-parameter $QEMU_CFLAGS"
406 QEMU_CFLAGS="-Wno-missing-field-initializers $QEMU_CFLAGS"
407 QEMU_CFLAGS="-Wno-sign-compare $QEMU_CFLAGS"
408 QEMU_CFLAGS="-Wno-override-init $QEMU_CFLAGS"
409 QEMU_CFLAGS="-Wno-error=format $QEMU_CFLAGS"
410 QEMU_CFLAGS="-Wno-error=format-extra-args $QEMU_CFLAGS"
411 QEMU_CFLAGS="-Wno-error=parentheses $QEMU_CFLAGS"
412 QEMU_CFLAGS="-Wextra $QEMU_CFLAGS"
413 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
414 QEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/include"
415 if test "$debug_info" = "yes"; then
416 CFLAGS="-g $CFLAGS"
417 LDFLAGS="-g $LDFLAGS"
420 # make source path absolute
421 source_path=$(cd "$source_path"; pwd)
423 cc_macros=$($cc $QEMU_CFLAGS -E -dD - </dev/null)
425 # running configure in the source tree?
426 # we know that's the case if configure is there.
427 if test -f "./configure"; then
428 pwd_is_source_path="y"
429 else
430 pwd_is_source_path="n"
433 check_define() {
434 rm -f $TMPC
435 cat > $TMPC <<EOF
436 #if !defined($1)
437 #error $1 not defined
438 #endif
439 int main(void) { return 0; }
441 compile_object
444 check_include() {
445 cat > $TMPC <<EOF
446 #include <$1>
447 int main(void) { return 0; }
449 compile_object
452 write_c_skeleton() {
453 cat > $TMPC <<EOF
454 int main(void) { return 0; }
458 if check_define __linux__ ; then
459 targetos="Linux"
460 elif check_define _WIN32 ; then
461 targetos='MINGW32'
462 elif check_define __OpenBSD__ ; then
463 targetos='OpenBSD'
464 elif check_define __sun__ ; then
465 targetos='SunOS'
466 elif check_define __HAIKU__ ; then
467 targetos='Haiku'
468 else
469 targetos=$(uname -s)
472 # Some host OSes need non-standard checks for which CPU to use.
473 # Note that these checks are broken for cross-compilation: if you're
474 # cross-compiling to one of these OSes then you'll need to specify
475 # the correct CPU with the --cpu option.
476 case $targetos in
477 Darwin)
478 # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
479 # run 64-bit userspace code.
480 # If the user didn't specify a CPU explicitly and the kernel says this is
481 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
482 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
483 cpu="x86_64"
486 SunOS)
487 # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
488 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
489 cpu="x86_64"
491 esac
493 if test ! -z "$cpu" ; then
494 # command line argument
496 elif check_define __i386__ ; then
497 cpu="i386"
498 elif check_define __x86_64__ ; then
499 if check_define __ILP32__ ; then
500 cpu="x32"
501 else
502 cpu="x86_64"
504 elif check_define __sparc__ ; then
505 if check_define __arch64__ ; then
506 cpu="sparc64"
507 else
508 cpu="sparc"
510 elif check_define _ARCH_PPC ; then
511 if check_define _ARCH_PPC64 ; then
512 cpu="ppc64"
513 else
514 cpu="ppc"
516 elif check_define __mips__ ; then
517 if check_define __mips64 ; then
518 cpu="mips64"
519 else
520 cpu="mips"
522 elif check_define __ia64__ ; then
523 cpu="ia64"
524 elif check_define __s390__ ; then
525 if check_define __s390x__ ; then
526 cpu="s390x"
527 else
528 cpu="s390"
530 elif check_define __arm__ ; then
531 cpu="arm"
532 elif check_define __aarch64__ ; then
533 cpu="aarch64"
534 else
535 cpu=$(uname -m)
538 ARCH=
539 # Normalise host CPU name and set ARCH.
540 # Note that this case should only have supported host CPUs, not guests.
541 case "$cpu" in
542 ppc|ppc64|s390|s390x|x32)
543 cpu="$cpu"
544 supported_cpu="yes"
546 ia64|sparc64)
547 cpu="$cpu"
549 i386|i486|i586|i686|i86pc|BePC)
550 cpu="i386"
551 supported_cpu="yes"
553 x86_64|amd64)
554 cpu="x86_64"
555 supported_cpu="yes"
557 armv*b|armv*l|arm)
558 cpu="arm"
559 supported_cpu="yes"
561 aarch64)
562 cpu="aarch64"
563 supported_cpu="yes"
565 mips*)
566 cpu="mips"
567 if check_define __MIPSEL__ ; then
568 cpu="${cpu}el"
570 supported_cpu="yes"
572 sparc|sun4[cdmuv])
573 cpu="sparc"
575 sh4)
576 cpu="sh4"
579 # This will result in either an error or falling back to TCI later
580 ARCH=unknown
582 esac
583 if test -z "$ARCH"; then
584 ARCH="$cpu"
587 # OS specific
589 # host *BSD for user mode
590 HOST_VARIANT_DIR=""
592 case $targetos in
593 MINGW32*)
594 mingw32="yes"
595 hax="yes"
596 audio_possible_drivers="dsound sdl"
597 if check_include dsound.h; then
598 audio_drv_list="dsound"
599 else
600 audio_drv_list=""
602 supported_os="yes"
604 GNU/kFreeBSD)
605 bsd="yes"
606 audio_drv_list="oss"
607 audio_possible_drivers="oss sdl pa"
609 FreeBSD)
610 bsd="yes"
611 make="${MAKE-gmake}"
612 audio_drv_list="oss"
613 audio_possible_drivers="oss sdl pa"
614 # needed for kinfo_getvmmap(3) in libutil.h
615 LIBS="-lutil $LIBS"
616 # needed for kinfo_getproc
617 libs_qga="-lutil $libs_qga"
618 netmap="" # enable netmap autodetect
619 HOST_VARIANT_DIR="freebsd"
620 supported_os="yes"
622 DragonFly)
623 bsd="yes"
624 make="${MAKE-gmake}"
625 audio_drv_list="oss"
626 audio_possible_drivers="oss sdl pa"
627 HOST_VARIANT_DIR="dragonfly"
629 NetBSD)
630 bsd="yes"
631 make="${MAKE-gmake}"
632 audio_drv_list="oss"
633 audio_possible_drivers="oss sdl"
634 oss_lib="-lossaudio"
635 HOST_VARIANT_DIR="netbsd"
637 OpenBSD)
638 bsd="yes"
639 make="${MAKE-gmake}"
640 audio_drv_list="sdl"
641 audio_possible_drivers="sdl"
642 HOST_VARIANT_DIR="openbsd"
644 Darwin)
645 bsd="yes"
646 darwin="yes"
647 hax="yes"
648 LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
649 if [ "$cpu" = "x86_64" ] ; then
650 QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
651 LDFLAGS="-arch x86_64 $LDFLAGS"
653 cocoa="yes"
654 audio_drv_list="coreaudio"
655 audio_possible_drivers="coreaudio sdl"
656 LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
657 libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
658 # Disable attempts to use ObjectiveC features in os/object.h since they
659 # won't work when we're compiling with gcc as a C compiler.
660 QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
661 HOST_VARIANT_DIR="darwin"
662 supported_os="yes"
664 SunOS)
665 solaris="yes"
666 make="${MAKE-gmake}"
667 install="${INSTALL-ginstall}"
668 ld="gld"
669 smbd="${SMBD-/usr/sfw/sbin/smbd}"
670 needs_libsunmath="no"
671 solarisrev=$(uname -r | cut -f2 -d.)
672 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
673 if test "$solarisrev" -le 9 ; then
674 if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
675 needs_libsunmath="yes"
676 QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
677 LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
678 LIBS="-lsunmath $LIBS"
679 else
680 error_exit "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without" \
681 "libsunmath from the Sun Studio compilers tools, due to a lack of" \
682 "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86" \
683 "Studio 11 can be downloaded from www.sun.com."
687 if test -f /usr/include/sys/soundcard.h ; then
688 audio_drv_list="oss"
690 audio_possible_drivers="oss sdl"
691 # needed for CMSG_ macros in sys/socket.h
692 QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
693 # needed for TIOCWIN* defines in termios.h
694 QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
695 QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
696 solarisnetlibs="-lsocket -lnsl -lresolv"
697 LIBS="$solarisnetlibs $LIBS"
698 libs_qga="$solarisnetlibs $libs_qga"
700 AIX)
701 aix="yes"
702 make="${MAKE-gmake}"
704 Haiku)
705 haiku="yes"
706 QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
707 LIBS="-lposix_error_mapper -lnetwork $LIBS"
709 Linux)
710 audio_drv_list="oss"
711 audio_possible_drivers="oss alsa sdl pa"
712 linux="yes"
713 linux_user="yes"
714 kvm="yes"
715 vhost_net="yes"
716 vhost_scsi="yes"
717 vhost_vsock="yes"
718 QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
719 supported_os="yes"
722 # This is a fatal error, but don't report it yet, because we
723 # might be going to just print the --help text, or it might
724 # be the result of a missing compiler.
725 bogus_os="yes"
727 esac
729 if [ "$bsd" = "yes" ] ; then
730 if [ "$darwin" != "yes" ] ; then
731 bsd_user="yes"
735 : ${make=${MAKE-make}}
736 : ${install=${INSTALL-install}}
737 : ${python=${PYTHON-python}}
738 : ${smbd=${SMBD-/usr/sbin/smbd}}
740 # Default objcc to clang if available, otherwise use CC
741 if has clang; then
742 objcc=clang
743 else
744 objcc="$cc"
747 if test "$mingw32" = "yes" ; then
748 EXESUF=".exe"
749 DSOSUF=".dll"
750 QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
751 # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
752 QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
753 # MinGW-w64 needs _POSIX defined.
754 QEMU_CFLAGS="-D_POSIX=1 $QEMU_CFLAGS"
755 # MinGW needs -mthreads for TLS and macro _MT.
756 QEMU_CFLAGS="-mthreads $QEMU_CFLAGS"
757 QEMU_CFLAGS="-I\$(SRC_PATH)/hosts/w32/include $QEMU_CFLAGS"
758 LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
759 write_c_skeleton;
760 if compile_prog "" "-liberty" ; then
761 LIBS="-liberty $LIBS"
763 prefix="c:/Program Files/QEMU"
764 mandir="\${prefix}"
765 datadir="\${prefix}"
766 qemu_docdir="\${prefix}"
767 bindir="\${prefix}"
768 sysconfdir="\${prefix}"
769 local_statedir=
770 confsuffix=""
771 libs_qga="-lws2_32 -lwinmm -lpowrprof -liphlpapi -lnetapi32 $libs_qga"
774 werror=""
776 for opt do
777 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
778 case "$opt" in
779 --help|-h) show_help=yes
781 --version|-V) exec cat $source_path/VERSION
783 --prefix=*) prefix="$optarg"
785 --interp-prefix=*) interp_prefix="$optarg"
787 --source-path=*)
789 --cross-prefix=*)
791 --cc=*)
793 --host-cc=*) host_cc="$optarg"
795 --cxx=*)
797 --iasl=*) iasl="$optarg"
799 --objcc=*) objcc="$optarg"
801 --make=*) make="$optarg"
803 --install=*) install="$optarg"
805 --python=*) python="$optarg"
807 --gcov=*) gcov_tool="$optarg"
809 --smbd=*) smbd="$optarg"
811 --extra-cflags=*)
813 --extra-ldflags=*)
815 --enable-debug-info)
817 --disable-debug-info)
819 --enable-modules)
820 modules="yes"
822 --disable-modules)
823 modules="no"
825 --cpu=*)
827 --target-list=*) target_list="$optarg"
829 --enable-trace-backends=*) trace_backends="$optarg"
831 # XXX: backwards compatibility
832 --enable-trace-backend=*) trace_backends="$optarg"
834 --with-trace-file=*) trace_file="$optarg"
836 --enable-gprof) gprof="yes"
838 --enable-gcov) gcov="yes"
840 --static)
841 static="yes"
842 LDFLAGS="-static $LDFLAGS"
843 QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
845 --mandir=*) mandir="$optarg"
847 --bindir=*) bindir="$optarg"
849 --libdir=*) libdir="$optarg"
851 --libexecdir=*) libexecdir="$optarg"
853 --includedir=*) includedir="$optarg"
855 --datadir=*) datadir="$optarg"
857 --with-confsuffix=*) confsuffix="$optarg"
859 --docdir=*) qemu_docdir="$optarg"
861 --sysconfdir=*) sysconfdir="$optarg"
863 --localstatedir=*) local_statedir="$optarg"
865 --sbindir=*|--sharedstatedir=*|\
866 --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
867 --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
868 # These switches are silently ignored, for compatibility with
869 # autoconf-generated configure scripts. This allows QEMU's
870 # configure to be used by RPM and similar macros that set
871 # lots of directory switches by default.
873 --with-system-pixman) pixman="system"
875 --without-system-pixman) pixman="internal"
877 --without-pixman) pixman="none"
879 --disable-sdl) sdl="no"
881 --enable-sdl) sdl="yes"
883 --with-sdlabi=*) sdlabi="$optarg"
885 --disable-qom-cast-debug) qom_cast_debug="no"
887 --enable-qom-cast-debug) qom_cast_debug="yes"
889 --disable-virtfs) virtfs="no"
891 --enable-virtfs) virtfs="yes"
893 --disable-vnc) vnc="no"
895 --enable-vnc) vnc="yes"
897 --oss-lib=*) oss_lib="$optarg"
899 --audio-drv-list=*) audio_drv_list="$optarg"
901 --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
903 --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
905 --enable-debug-tcg) debug_tcg="yes"
907 --disable-debug-tcg) debug_tcg="no"
909 --enable-debug)
910 # Enable debugging options that aren't excessively noisy
911 debug_tcg="yes"
912 debug="yes"
913 strip_opt="no"
914 fortify_source="no"
916 --enable-sparse) sparse="yes"
918 --disable-sparse) sparse="no"
920 --disable-strip) strip_opt="no"
922 --disable-vnc-sasl) vnc_sasl="no"
924 --enable-vnc-sasl) vnc_sasl="yes"
926 --disable-vnc-jpeg) vnc_jpeg="no"
928 --enable-vnc-jpeg) vnc_jpeg="yes"
930 --disable-vnc-png) vnc_png="no"
932 --enable-vnc-png) vnc_png="yes"
934 --disable-slirp) slirp="no"
936 --disable-vde) vde="no"
938 --enable-vde) vde="yes"
940 --disable-netmap) netmap="no"
942 --enable-netmap) netmap="yes"
944 --disable-xen) xen="no"
946 --enable-xen) xen="yes"
948 --disable-xen-pci-passthrough) xen_pci_passthrough="no"
950 --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
952 --disable-xen-pv-domain-build) xen_pv_domain_build="no"
954 --enable-xen-pv-domain-build) xen_pv_domain_build="yes"
956 --disable-brlapi) brlapi="no"
958 --enable-brlapi) brlapi="yes"
960 --disable-bluez) bluez="no"
962 --enable-bluez) bluez="yes"
964 --disable-kvm) kvm="no"
966 --enable-kvm) kvm="yes"
968 --disable-hax) hax="no"
970 --enable-hax) hax="yes"
972 --disable-tcg-interpreter) tcg_interpreter="no"
974 --enable-tcg-interpreter) tcg_interpreter="yes"
976 --disable-cap-ng) cap_ng="no"
978 --enable-cap-ng) cap_ng="yes"
980 --disable-spice) spice="no"
982 --enable-spice) spice="yes"
984 --disable-libiscsi) libiscsi="no"
986 --enable-libiscsi) libiscsi="yes"
988 --disable-libnfs) libnfs="no"
990 --enable-libnfs) libnfs="yes"
992 --enable-profiler) profiler="yes"
994 --disable-cocoa) cocoa="no"
996 --enable-cocoa)
997 cocoa="yes" ;
998 audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
1000 --disable-system) softmmu="no"
1002 --enable-system) softmmu="yes"
1004 --disable-user)
1005 linux_user="no" ;
1006 bsd_user="no" ;
1008 --enable-user) ;;
1009 --disable-linux-user) linux_user="no"
1011 --enable-linux-user) linux_user="yes"
1013 --disable-bsd-user) bsd_user="no"
1015 --enable-bsd-user) bsd_user="yes"
1017 --enable-pie) pie="yes"
1019 --disable-pie) pie="no"
1021 --enable-werror) werror="yes"
1023 --disable-werror) werror="no"
1025 --enable-stack-protector) stack_protector="yes"
1027 --disable-stack-protector) stack_protector="no"
1029 --disable-curses) curses="no"
1031 --enable-curses) curses="yes"
1033 --disable-curl) curl="no"
1035 --enable-curl) curl="yes"
1037 --disable-fdt) fdt="no"
1039 --enable-fdt) fdt="yes"
1041 --disable-linux-aio) linux_aio="no"
1043 --enable-linux-aio) linux_aio="yes"
1045 --disable-attr) attr="no"
1047 --enable-attr) attr="yes"
1049 --disable-blobs) blobs="no"
1051 --with-pkgversion=*) pkgversion=" ($optarg)"
1053 --with-coroutine=*) coroutine="$optarg"
1055 --disable-coroutine-pool) coroutine_pool="no"
1057 --enable-coroutine-pool) coroutine_pool="yes"
1059 --enable-debug-stack-usage) debug_stack_usage="yes"
1061 --disable-docs) docs="no"
1063 --enable-docs) docs="yes"
1065 --disable-vhost-net) vhost_net="no"
1067 --enable-vhost-net) vhost_net="yes"
1069 --disable-vhost-scsi) vhost_scsi="no"
1071 --enable-vhost-scsi) vhost_scsi="yes"
1073 --disable-vhost-vsock) vhost_vsock="no"
1075 --enable-vhost-vsock) vhost_vsock="yes"
1077 --disable-opengl) opengl="no"
1079 --enable-opengl) opengl="yes"
1081 --disable-rbd) rbd="no"
1083 --enable-rbd) rbd="yes"
1085 --disable-xfsctl) xfs="no"
1087 --enable-xfsctl) xfs="yes"
1089 --disable-smartcard) smartcard="no"
1091 --enable-smartcard) smartcard="yes"
1093 --disable-libusb) libusb="no"
1095 --enable-libusb) libusb="yes"
1097 --disable-usb-redir) usb_redir="no"
1099 --enable-usb-redir) usb_redir="yes"
1101 --disable-zlib-test) zlib="no"
1103 --disable-lzo) lzo="no"
1105 --enable-lzo) lzo="yes"
1107 --disable-snappy) snappy="no"
1109 --enable-snappy) snappy="yes"
1111 --disable-bzip2) bzip2="no"
1113 --enable-bzip2) bzip2="yes"
1115 --enable-guest-agent) guest_agent="yes"
1117 --disable-guest-agent) guest_agent="no"
1119 --enable-guest-agent-msi) guest_agent_msi="yes"
1121 --disable-guest-agent-msi) guest_agent_msi="no"
1123 --with-vss-sdk) vss_win32_sdk=""
1125 --with-vss-sdk=*) vss_win32_sdk="$optarg"
1127 --without-vss-sdk) vss_win32_sdk="no"
1129 --with-win-sdk) win_sdk=""
1131 --with-win-sdk=*) win_sdk="$optarg"
1133 --without-win-sdk) win_sdk="no"
1135 --enable-tools) want_tools="yes"
1137 --disable-tools) want_tools="no"
1139 --enable-seccomp) seccomp="yes"
1141 --disable-seccomp) seccomp="no"
1143 --disable-glusterfs) glusterfs="no"
1145 --enable-glusterfs) glusterfs="yes"
1147 --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
1148 echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1150 --enable-vhdx|--disable-vhdx)
1151 echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1153 --enable-uuid|--disable-uuid)
1154 echo "$0: $opt is obsolete, UUID support is always built" >&2
1156 --disable-gtk) gtk="no"
1158 --enable-gtk) gtk="yes"
1160 --tls-priority=*) tls_priority="$optarg"
1162 --disable-gnutls) gnutls="no"
1164 --enable-gnutls) gnutls="yes"
1166 --disable-nettle) nettle="no"
1168 --enable-nettle) nettle="yes"
1170 --disable-gcrypt) gcrypt="no"
1172 --enable-gcrypt) gcrypt="yes"
1174 --enable-rdma) rdma="yes"
1176 --disable-rdma) rdma="no"
1178 --with-gtkabi=*) gtkabi="$optarg"
1180 --disable-vte) vte="no"
1182 --enable-vte) vte="yes"
1184 --disable-virglrenderer) virglrenderer="no"
1186 --enable-virglrenderer) virglrenderer="yes"
1188 --disable-tpm) tpm="no"
1190 --enable-tpm) tpm="yes"
1192 --disable-libssh2) libssh2="no"
1194 --enable-libssh2) libssh2="yes"
1196 --disable-numa) numa="no"
1198 --enable-numa) numa="yes"
1200 --disable-tcmalloc) tcmalloc="no"
1202 --enable-tcmalloc) tcmalloc="yes"
1204 --disable-jemalloc) jemalloc="no"
1206 --enable-jemalloc) jemalloc="yes"
1208 --disable-replication) replication="no"
1210 --enable-replication) replication="yes"
1213 echo "ERROR: unknown option $opt"
1214 echo "Try '$0 --help' for more information"
1215 exit 1
1217 esac
1218 done
1220 if ! has $python; then
1221 error_exit "Python not found. Use --python=/path/to/python"
1224 # Note that if the Python conditional here evaluates True we will exit
1225 # with status 1 which is a shell 'false' value.
1226 if ! $python -c 'import sys; sys.exit(sys.version_info < (2,6) or sys.version_info >= (3,))'; then
1227 error_exit "Cannot use '$python', Python 2.6 or later is required." \
1228 "Note that Python 3 or later is not yet supported." \
1229 "Use --python=/path/to/python to specify a supported Python."
1232 # Suppress writing compiled files
1233 python="$python -B"
1235 case "$cpu" in
1236 ppc)
1237 CPU_CFLAGS="-m32"
1238 LDFLAGS="-m32 $LDFLAGS"
1240 ppc64)
1241 CPU_CFLAGS="-m64"
1242 LDFLAGS="-m64 $LDFLAGS"
1244 sparc)
1245 LDFLAGS="-m32 $LDFLAGS"
1246 CPU_CFLAGS="-m32 -mcpu=ultrasparc"
1248 sparc64)
1249 LDFLAGS="-m64 $LDFLAGS"
1250 CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1252 s390)
1253 CPU_CFLAGS="-m31"
1254 LDFLAGS="-m31 $LDFLAGS"
1256 s390x)
1257 CPU_CFLAGS="-m64"
1258 LDFLAGS="-m64 $LDFLAGS"
1260 i386)
1261 CPU_CFLAGS="-m32"
1262 LDFLAGS="-m32 $LDFLAGS"
1263 cc_i386='$(CC) -m32'
1265 x86_64)
1266 # ??? Only extremely old AMD cpus do not have cmpxchg16b.
1267 # If we truly care, we should simply detect this case at
1268 # runtime and generate the fallback to serial emulation.
1269 CPU_CFLAGS="-m64 -mcx16"
1270 LDFLAGS="-m64 $LDFLAGS"
1271 cc_i386='$(CC) -m32'
1273 x32)
1274 CPU_CFLAGS="-mx32"
1275 LDFLAGS="-mx32 $LDFLAGS"
1276 cc_i386='$(CC) -m32'
1278 # No special flags required for other host CPUs
1279 esac
1281 QEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
1282 EXTRA_CFLAGS="$CPU_CFLAGS $EXTRA_CFLAGS"
1284 # For user-mode emulation the host arch has to be one we explicitly
1285 # support, even if we're using TCI.
1286 if [ "$ARCH" = "unknown" ]; then
1287 bsd_user="no"
1288 linux_user="no"
1291 default_target_list=""
1293 mak_wilds=""
1295 if [ "$softmmu" = "yes" ]; then
1296 mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
1298 if [ "$linux_user" = "yes" ]; then
1299 mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
1301 if [ "$bsd_user" = "yes" ]; then
1302 mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
1305 for config in $mak_wilds; do
1306 default_target_list="${default_target_list} $(basename "$config" .mak)"
1307 done
1309 if test x"$show_help" = x"yes" ; then
1310 cat << EOF
1312 Usage: configure [options]
1313 Options: [defaults in brackets after descriptions]
1315 Standard options:
1316 --help print this message
1317 --prefix=PREFIX install in PREFIX [$prefix]
1318 --interp-prefix=PREFIX where to find shared libraries, etc.
1319 use %M for cpu name [$interp_prefix]
1320 --target-list=LIST set target list (default: build everything)
1321 $(echo Available targets: $default_target_list | \
1322 fold -s -w 53 | sed -e 's/^/ /')
1324 Advanced options (experts only):
1325 --source-path=PATH path of source code [$source_path]
1326 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
1327 --cc=CC use C compiler CC [$cc]
1328 --iasl=IASL use ACPI compiler IASL [$iasl]
1329 --host-cc=CC use C compiler CC [$host_cc] for code run at
1330 build time
1331 --cxx=CXX use C++ compiler CXX [$cxx]
1332 --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
1333 --extra-cflags=CFLAGS append extra C compiler flags QEMU_CFLAGS
1334 --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS
1335 --make=MAKE use specified make [$make]
1336 --install=INSTALL use specified install [$install]
1337 --python=PYTHON use specified python [$python]
1338 --smbd=SMBD use specified smbd [$smbd]
1339 --static enable static build [$static]
1340 --mandir=PATH install man pages in PATH
1341 --datadir=PATH install firmware in PATH$confsuffix
1342 --docdir=PATH install documentation in PATH$confsuffix
1343 --bindir=PATH install binaries in PATH
1344 --libdir=PATH install libraries in PATH
1345 --sysconfdir=PATH install config in PATH$confsuffix
1346 --localstatedir=PATH install local state in PATH (set at runtime on win32)
1347 --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
1348 --enable-debug enable common debug build options
1349 --disable-strip disable stripping binaries
1350 --disable-werror disable compilation abort on warning
1351 --disable-stack-protector disable compiler-provided stack protection
1352 --audio-drv-list=LIST set audio drivers list:
1353 Available drivers: $audio_possible_drivers
1354 --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L
1355 --block-drv-rw-whitelist=L
1356 set block driver read-write whitelist
1357 (affects only QEMU, not qemu-img)
1358 --block-drv-ro-whitelist=L
1359 set block driver read-only whitelist
1360 (affects only QEMU, not qemu-img)
1361 --enable-trace-backends=B Set trace backend
1362 Available backends: $($python $source_path/scripts/tracetool.py --list-backends)
1363 --with-trace-file=NAME Full PATH,NAME of file to store traces
1364 Default:trace-<pid>
1365 --disable-slirp disable SLIRP userspace network connectivity
1366 --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
1367 --oss-lib path to OSS library
1368 --cpu=CPU Build for host CPU [$cpu]
1369 --with-coroutine=BACKEND coroutine backend. Supported options:
1370 gthread, ucontext, sigaltstack, windows
1371 --enable-gcov enable test coverage analysis with gcov
1372 --gcov=GCOV use specified gcov [$gcov_tool]
1373 --disable-blobs disable installing provided firmware blobs
1374 --with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent
1375 --with-win-sdk=SDK-path path to Windows Platform SDK (to build VSS .tlb)
1376 --tls-priority default TLS protocol/cipher priority string
1377 --enable-gprof QEMU profiling with gprof
1378 --enable-profiler profiler support
1379 --enable-xen-pv-domain-build
1380 xen pv domain builder
1381 --enable-debug-stack-usage
1382 track the maximum stack usage of stacks created by qemu_alloc_stack
1384 Optional features, enabled with --enable-FEATURE and
1385 disabled with --disable-FEATURE, default is enabled if available:
1387 system all system emulation targets
1388 user supported user emulation targets
1389 linux-user all linux usermode emulation targets
1390 bsd-user all BSD usermode emulation targets
1391 docs build documentation
1392 guest-agent build the QEMU Guest Agent
1393 guest-agent-msi build guest agent Windows MSI installation package
1394 pie Position Independent Executables
1395 modules modules support
1396 debug-tcg TCG debugging (default is disabled)
1397 debug-info debugging information
1398 sparse sparse checker
1400 gnutls GNUTLS cryptography support
1401 nettle nettle cryptography support
1402 gcrypt libgcrypt cryptography support
1403 sdl SDL UI
1404 --with-sdlabi select preferred SDL ABI 1.2 or 2.0
1405 gtk gtk UI
1406 --with-gtkabi select preferred GTK ABI 2.0 or 3.0
1407 vte vte support for the gtk UI
1408 curses curses UI
1409 vnc VNC UI support
1410 vnc-sasl SASL encryption for VNC server
1411 vnc-jpeg JPEG lossy compression for VNC server
1412 vnc-png PNG compression for VNC server
1413 cocoa Cocoa UI (Mac OS X only)
1414 virtfs VirtFS
1415 xen xen backend driver support
1416 xen-pci-passthrough
1417 brlapi BrlAPI (Braile)
1418 curl curl connectivity
1419 fdt fdt device tree
1420 bluez bluez stack connectivity
1421 kvm KVM acceleration support
1422 hax HAX acceleration support
1423 rdma RDMA-based migration support
1424 vde support for vde network
1425 netmap support for netmap network
1426 linux-aio Linux AIO support
1427 cap-ng libcap-ng support
1428 attr attr and xattr support
1429 vhost-net vhost-net acceleration support
1430 spice spice
1431 rbd rados block device (rbd)
1432 libiscsi iscsi support
1433 libnfs nfs support
1434 smartcard smartcard support (libcacard)
1435 libusb libusb (for usb passthrough)
1436 usb-redir usb network redirection support
1437 lzo support of lzo compression library
1438 snappy support of snappy compression library
1439 bzip2 support of bzip2 compression library
1440 (for reading bzip2-compressed dmg images)
1441 seccomp seccomp support
1442 coroutine-pool coroutine freelist (better performance)
1443 glusterfs GlusterFS backend
1444 tpm TPM support
1445 libssh2 ssh block device support
1446 numa libnuma support
1447 tcmalloc tcmalloc support
1448 jemalloc jemalloc support
1449 replication replication support
1450 vhost-vsock virtio sockets device support
1451 opengl opengl support
1452 virglrenderer virgl rendering support
1453 xfsctl xfsctl support
1454 qom-cast-debug cast debugging support
1455 tools build qemu-io, qemu-nbd and qemu-image tools
1457 NOTE: The object files are built at the place where configure is launched
1459 exit 0
1462 # Now we have handled --enable-tcg-interpreter and know we're not just
1463 # printing the help message, bail out if the host CPU isn't supported.
1464 if test "$ARCH" = "unknown"; then
1465 if test "$tcg_interpreter" = "yes" ; then
1466 echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1467 else
1468 error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1472 # Consult white-list to determine whether to enable werror
1473 # by default. Only enable by default for git builds
1474 if test -z "$werror" ; then
1475 if test -d "$source_path/.git" -a \
1476 \( "$linux" = "yes" -o "$mingw32" = "yes" \) ; then
1477 werror="yes"
1478 else
1479 werror="no"
1483 # check that the C compiler works.
1484 write_c_skeleton;
1485 if compile_object ; then
1486 : C compiler works ok
1487 else
1488 error_exit "\"$cc\" either does not exist or does not work"
1490 if ! compile_prog ; then
1491 error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
1494 if test "$bogus_os" = "yes"; then
1495 # Now that we know that we're not printing the help and that
1496 # the compiler works (so the results of the check_defines we used
1497 # to identify the OS are reliable), if we didn't recognize the
1498 # host OS we should stop now.
1499 error_exit "Unrecognized host OS $targetos"
1502 # Check that the C++ compiler exists and works with the C compiler
1503 if has $cxx; then
1504 cat > $TMPC <<EOF
1505 int c_function(void);
1506 int main(void) { return c_function(); }
1509 compile_object
1511 cat > $TMPCXX <<EOF
1512 extern "C" {
1513 int c_function(void);
1515 int c_function(void) { return 42; }
1518 update_cxxflags
1520 if do_cxx $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $LDFLAGS; then
1521 # C++ compiler $cxx works ok with C compiler $cc
1523 else
1524 echo "C++ compiler $cxx does not work with C compiler $cc"
1525 echo "Disabling C++ specific optional code"
1526 cxx=
1528 else
1529 echo "No C++ compiler available; disabling C++ specific optional code"
1530 cxx=
1533 gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
1534 gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
1535 gcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1536 gcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
1537 gcc_flags="-Wno-initializer-overrides $gcc_flags"
1538 gcc_flags="-Wno-string-plus-int $gcc_flags"
1539 # Note that we do not add -Werror to gcc_flags here, because that would
1540 # enable it for all configure tests. If a configure test failed due
1541 # to -Werror this would just silently disable some features,
1542 # so it's too error prone.
1544 cc_has_warning_flag() {
1545 write_c_skeleton;
1547 # Use the positive sense of the flag when testing for -Wno-wombat
1548 # support (gcc will happily accept the -Wno- form of unknown
1549 # warning options).
1550 optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
1551 compile_prog "-Werror $optflag" ""
1554 for flag in $gcc_flags; do
1555 if cc_has_warning_flag $flag ; then
1556 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1558 done
1560 if test "$mingw32" = "yes"; then
1561 stack_protector="no"
1563 if test "$stack_protector" != "no"; then
1564 cat > $TMPC << EOF
1565 int main(int argc, char *argv[])
1567 char arr[64], *p = arr, *c = argv[0];
1568 while (*c) {
1569 *p++ = *c++;
1571 return 0;
1574 gcc_flags="-fstack-protector-strong -fstack-protector-all"
1575 sp_on=0
1576 for flag in $gcc_flags; do
1577 # We need to check both a compile and a link, since some compiler
1578 # setups fail only on a .c->.o compile and some only at link time
1579 if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
1580 compile_prog "-Werror $flag" ""; then
1581 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1582 sp_on=1
1583 break
1585 done
1586 if test "$stack_protector" = yes; then
1587 if test $sp_on = 0; then
1588 error_exit "Stack protector not supported"
1593 # Workaround for http://gcc.gnu.org/PR55489. Happens with -fPIE/-fPIC and
1594 # large functions that use global variables. The bug is in all releases of
1595 # GCC, but it became particularly acute in 4.6.x and 4.7.x. It is fixed in
1596 # 4.7.3 and 4.8.0. We should be able to delete this at the end of 2013.
1597 cat > $TMPC << EOF
1598 #if __GNUC__ == 4 && (__GNUC_MINOR__ == 6 || (__GNUC_MINOR__ == 7 && __GNUC_PATCHLEVEL__ <= 2))
1599 int main(void) { return 0; }
1600 #else
1601 #error No bug in this compiler.
1602 #endif
1604 if compile_prog "-Werror -fno-gcse" "" ; then
1605 TRANSLATE_OPT_CFLAGS=-fno-gcse
1608 if test "$static" = "yes" ; then
1609 if test "$modules" = "yes" ; then
1610 error_exit "static and modules are mutually incompatible"
1612 if test "$pie" = "yes" ; then
1613 error_exit "static and pie are mutually incompatible"
1614 else
1615 pie="no"
1619 # Unconditional check for compiler __thread support
1620 cat > $TMPC << EOF
1621 static __thread int tls_var;
1622 int main(void) { return tls_var; }
1625 if ! compile_prog "-Werror" "" ; then
1626 error_exit "Your compiler does not support the __thread specifier for " \
1627 "Thread-Local Storage (TLS). Please upgrade to a version that does."
1630 if test "$pie" = ""; then
1631 case "$cpu-$targetos" in
1632 i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
1635 pie="no"
1637 esac
1640 if test "$pie" != "no" ; then
1641 cat > $TMPC << EOF
1643 #ifdef __linux__
1644 # define THREAD __thread
1645 #else
1646 # define THREAD
1647 #endif
1649 static THREAD int tls_var;
1651 int main(void) { return tls_var; }
1654 if compile_prog "-fPIE -DPIE" "-pie"; then
1655 QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
1656 LDFLAGS="-pie $LDFLAGS"
1657 pie="yes"
1658 if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
1659 LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
1661 else
1662 if test "$pie" = "yes"; then
1663 error_exit "PIE not available due to missing toolchain support"
1664 else
1665 echo "Disabling PIE due to missing toolchain support"
1666 pie="no"
1670 if compile_prog "-Werror -fno-pie" "-nopie"; then
1671 CFLAGS_NOPIE="-fno-pie"
1672 LDFLAGS_NOPIE="-nopie"
1676 ##########################################
1677 # __sync_fetch_and_and requires at least -march=i486. Many toolchains
1678 # use i686 as default anyway, but for those that don't, an explicit
1679 # specification is necessary
1681 if test "$cpu" = "i386"; then
1682 cat > $TMPC << EOF
1683 static int sfaa(int *ptr)
1685 return __sync_fetch_and_and(ptr, 0);
1688 int main(void)
1690 int val = 42;
1691 val = __sync_val_compare_and_swap(&val, 0, 1);
1692 sfaa(&val);
1693 return val;
1696 if ! compile_prog "" "" ; then
1697 QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
1701 #########################################
1702 # Solaris specific configure tool chain decisions
1704 if test "$solaris" = "yes" ; then
1705 if has $install; then
1707 else
1708 error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
1709 "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
1710 "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1712 if test "$(path_of $install)" = "/usr/sbin/install" ; then
1713 error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
1714 "try ginstall from the GNU fileutils available from www.blastwave.org" \
1715 "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1717 if has ar; then
1719 else
1720 if test -f /usr/ccs/bin/ar ; then
1721 error_exit "No path includes ar" \
1722 "Add /usr/ccs/bin to your path and rerun configure"
1724 error_exit "No path includes ar"
1728 if test -z "${target_list+xxx}" ; then
1729 target_list="$default_target_list"
1730 else
1731 target_list=$(echo "$target_list" | sed -e 's/,/ /g')
1734 # Check that we recognised the target name; this allows a more
1735 # friendly error message than if we let it fall through.
1736 for target in $target_list; do
1737 case " $default_target_list " in
1738 *" $target "*)
1741 error_exit "Unknown target name '$target'"
1743 esac
1744 done
1746 # see if system emulation was really requested
1747 case " $target_list " in
1748 *"-softmmu "*) softmmu=yes
1750 *) softmmu=no
1752 esac
1754 feature_not_found() {
1755 feature=$1
1756 remedy=$2
1758 error_exit "User requested feature $feature" \
1759 "configure was not able to find it." \
1760 "$remedy"
1763 # ---
1764 # big/little endian test
1765 cat > $TMPC << EOF
1766 short big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
1767 short little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
1768 extern int foo(short *, short *);
1769 int main(int argc, char *argv[]) {
1770 return foo(big_endian, little_endian);
1774 if compile_object ; then
1775 if grep -q BiGeNdIaN $TMPO ; then
1776 bigendian="yes"
1777 elif grep -q LiTtLeEnDiAn $TMPO ; then
1778 bigendian="no"
1779 else
1780 echo big/little test failed
1782 else
1783 echo big/little test failed
1786 ##########################################
1787 # cocoa implies not SDL or GTK
1788 # (the cocoa UI code currently assumes it is always the active UI
1789 # and doesn't interact well with other UI frontend code)
1790 if test "$cocoa" = "yes"; then
1791 if test "$sdl" = "yes"; then
1792 error_exit "Cocoa and SDL UIs cannot both be enabled at once"
1794 if test "$gtk" = "yes"; then
1795 error_exit "Cocoa and GTK UIs cannot both be enabled at once"
1797 gtk=no
1798 sdl=no
1801 # Some versions of Mac OS X incorrectly define SIZE_MAX
1802 cat > $TMPC << EOF
1803 #include <stdint.h>
1804 #include <stdio.h>
1805 int main(int argc, char *argv[]) {
1806 return printf("%zu", SIZE_MAX);
1809 have_broken_size_max=no
1810 if ! compile_object -Werror ; then
1811 have_broken_size_max=yes
1814 ##########################################
1815 # L2TPV3 probe
1817 cat > $TMPC <<EOF
1818 #include <sys/socket.h>
1819 #include <linux/ip.h>
1820 int main(void) { return sizeof(struct mmsghdr); }
1822 if compile_prog "" "" ; then
1823 l2tpv3=yes
1824 else
1825 l2tpv3=no
1828 ##########################################
1829 # MinGW / Mingw-w64 localtime_r/gmtime_r check
1831 if test "$mingw32" = "yes"; then
1832 # Some versions of MinGW / Mingw-w64 lack localtime_r
1833 # and gmtime_r entirely.
1835 # Some versions of Mingw-w64 define a macro for
1836 # localtime_r/gmtime_r.
1838 # Some versions of Mingw-w64 will define functions
1839 # for localtime_r/gmtime_r, but only if you have
1840 # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
1841 # though, unistd.h and pthread.h both define
1842 # that for you.
1844 # So this #undef localtime_r and #include <unistd.h>
1845 # are not in fact redundant.
1846 cat > $TMPC << EOF
1847 #include <unistd.h>
1848 #include <time.h>
1849 #undef localtime_r
1850 int main(void) { localtime_r(NULL, NULL); return 0; }
1852 if compile_prog "" "" ; then
1853 localtime_r="yes"
1854 else
1855 localtime_r="no"
1859 ##########################################
1860 # pkg-config probe
1862 if ! has "$pkg_config_exe"; then
1863 error_exit "pkg-config binary '$pkg_config_exe' not found"
1866 ##########################################
1867 # NPTL probe
1869 if test "$linux_user" = "yes"; then
1870 cat > $TMPC <<EOF
1871 #include <sched.h>
1872 #include <linux/futex.h>
1873 int main(void) {
1874 #if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1875 #error bork
1876 #endif
1877 return 0;
1880 if ! compile_object ; then
1881 feature_not_found "nptl" "Install glibc and linux kernel headers."
1885 ##########################################
1886 # avx2 optimization requirement check
1888 cat > $TMPC << EOF
1889 #pragma GCC push_options
1890 #pragma GCC target("avx2")
1891 #include <cpuid.h>
1892 #include <immintrin.h>
1893 static int bar(void *a) {
1894 __m256i x = *(__m256i *)a;
1895 return _mm256_testz_si256(x, x);
1897 int main(int argc, char *argv[]) { return bar(argv[0]); }
1899 if compile_object "" ; then
1900 avx2_opt="yes"
1903 ##########################################
1904 # lzo check
1906 if test "$lzo" != "no" ; then
1907 cat > $TMPC << EOF
1908 #include <lzo/lzo1x.h>
1909 int main(void) { lzo_version(); return 0; }
1911 if compile_prog "" "-llzo2" ; then
1912 libs_softmmu="$libs_softmmu -llzo2"
1913 lzo="yes"
1914 else
1915 if test "$lzo" = "yes"; then
1916 feature_not_found "liblzo2" "Install liblzo2 devel"
1918 lzo="no"
1922 ##########################################
1923 # snappy check
1925 if test "$snappy" != "no" ; then
1926 cat > $TMPC << EOF
1927 #include <snappy-c.h>
1928 int main(void) { snappy_max_compressed_length(4096); return 0; }
1930 if compile_prog "" "-lsnappy" ; then
1931 libs_softmmu="$libs_softmmu -lsnappy"
1932 snappy="yes"
1933 else
1934 if test "$snappy" = "yes"; then
1935 feature_not_found "libsnappy" "Install libsnappy devel"
1937 snappy="no"
1941 ##########################################
1942 # bzip2 check
1944 if test "$bzip2" != "no" ; then
1945 cat > $TMPC << EOF
1946 #include <bzlib.h>
1947 int main(void) { BZ2_bzlibVersion(); return 0; }
1949 if compile_prog "" "-lbz2" ; then
1950 bzip2="yes"
1951 else
1952 if test "$bzip2" = "yes"; then
1953 feature_not_found "libbzip2" "Install libbzip2 devel"
1955 bzip2="no"
1959 ##########################################
1960 # libseccomp check
1962 if test "$seccomp" != "no" ; then
1963 case "$cpu" in
1964 i386|x86_64)
1965 libseccomp_minver="2.1.0"
1967 mips)
1968 libseccomp_minver="2.2.0"
1970 arm|aarch64)
1971 libseccomp_minver="2.2.3"
1973 ppc|ppc64)
1974 libseccomp_minver="2.3.0"
1977 libseccomp_minver=""
1979 esac
1981 if test "$libseccomp_minver" != "" &&
1982 $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
1983 libs_softmmu="$libs_softmmu $($pkg_config --libs libseccomp)"
1984 QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags libseccomp)"
1985 seccomp="yes"
1986 else
1987 if test "$seccomp" = "yes" ; then
1988 if test "$libseccomp_minver" != "" ; then
1989 feature_not_found "libseccomp" \
1990 "Install libseccomp devel >= $libseccomp_minver"
1991 else
1992 feature_not_found "libseccomp" \
1993 "libseccomp is not supported for host cpu $cpu"
1996 seccomp="no"
1999 ##########################################
2000 # xen probe
2002 if test "$xen" != "no" ; then
2003 xen_libs="-lxenstore -lxenctrl -lxenguest"
2004 xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
2006 # First we test whether Xen headers and libraries are available.
2007 # If no, we are done and there is no Xen support.
2008 # If yes, more tests are run to detect the Xen version.
2010 # Xen (any)
2011 cat > $TMPC <<EOF
2012 #include <xenctrl.h>
2013 int main(void) {
2014 return 0;
2017 if ! compile_prog "" "$xen_libs" ; then
2018 # Xen not found
2019 if test "$xen" = "yes" ; then
2020 feature_not_found "xen" "Install xen devel"
2022 xen=no
2024 # Xen unstable
2025 elif
2026 cat > $TMPC <<EOF &&
2028 * If we have stable libs the we don't want the libxc compat
2029 * layers, regardless of what CFLAGS we may have been given.
2031 * Also, check if xengnttab_grant_copy_segment_t is defined and
2032 * grant copy operation is implemented.
2034 #undef XC_WANT_COMPAT_EVTCHN_API
2035 #undef XC_WANT_COMPAT_GNTTAB_API
2036 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2037 #include <xenctrl.h>
2038 #include <xenstore.h>
2039 #include <xenevtchn.h>
2040 #include <xengnttab.h>
2041 #include <xenforeignmemory.h>
2042 #include <stdint.h>
2043 #include <xen/hvm/hvm_info_table.h>
2044 #if !defined(HVM_MAX_VCPUS)
2045 # error HVM_MAX_VCPUS not defined
2046 #endif
2047 int main(void) {
2048 xc_interface *xc = NULL;
2049 xenforeignmemory_handle *xfmem;
2050 xenevtchn_handle *xe;
2051 xengnttab_handle *xg;
2052 xen_domain_handle_t handle;
2053 xengnttab_grant_copy_segment_t* seg = NULL;
2055 xs_daemon_open();
2057 xc = xc_interface_open(0, 0, 0);
2058 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2059 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2060 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2061 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2062 xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2064 xfmem = xenforeignmemory_open(0, 0);
2065 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2067 xe = xenevtchn_open(0, 0);
2068 xenevtchn_fd(xe);
2070 xg = xengnttab_open(0, 0);
2071 xengnttab_grant_copy(xg, 0, seg);
2073 return 0;
2076 compile_prog "" "$xen_libs $xen_stable_libs"
2077 then
2078 xen_ctrl_version=480
2079 xen=yes
2080 elif
2081 cat > $TMPC <<EOF &&
2083 * If we have stable libs the we don't want the libxc compat
2084 * layers, regardless of what CFLAGS we may have been given.
2086 #undef XC_WANT_COMPAT_EVTCHN_API
2087 #undef XC_WANT_COMPAT_GNTTAB_API
2088 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2089 #include <xenctrl.h>
2090 #include <xenstore.h>
2091 #include <xenevtchn.h>
2092 #include <xengnttab.h>
2093 #include <xenforeignmemory.h>
2094 #include <stdint.h>
2095 #include <xen/hvm/hvm_info_table.h>
2096 #if !defined(HVM_MAX_VCPUS)
2097 # error HVM_MAX_VCPUS not defined
2098 #endif
2099 int main(void) {
2100 xc_interface *xc = NULL;
2101 xenforeignmemory_handle *xfmem;
2102 xenevtchn_handle *xe;
2103 xengnttab_handle *xg;
2104 xen_domain_handle_t handle;
2106 xs_daemon_open();
2108 xc = xc_interface_open(0, 0, 0);
2109 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2110 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2111 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2112 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2113 xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2115 xfmem = xenforeignmemory_open(0, 0);
2116 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2118 xe = xenevtchn_open(0, 0);
2119 xenevtchn_fd(xe);
2121 xg = xengnttab_open(0, 0);
2122 xengnttab_map_grant_ref(xg, 0, 0, 0);
2124 return 0;
2127 compile_prog "" "$xen_libs $xen_stable_libs"
2128 then
2129 xen_ctrl_version=471
2130 xen=yes
2131 elif
2132 cat > $TMPC <<EOF &&
2133 #include <xenctrl.h>
2134 #include <stdint.h>
2135 int main(void) {
2136 xc_interface *xc = NULL;
2137 xen_domain_handle_t handle;
2138 xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2139 return 0;
2142 compile_prog "" "$xen_libs"
2143 then
2144 xen_ctrl_version=470
2145 xen=yes
2147 # Xen 4.6
2148 elif
2149 cat > $TMPC <<EOF &&
2150 #include <xenctrl.h>
2151 #include <xenstore.h>
2152 #include <stdint.h>
2153 #include <xen/hvm/hvm_info_table.h>
2154 #if !defined(HVM_MAX_VCPUS)
2155 # error HVM_MAX_VCPUS not defined
2156 #endif
2157 int main(void) {
2158 xc_interface *xc;
2159 xs_daemon_open();
2160 xc = xc_interface_open(0, 0, 0);
2161 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2162 xc_gnttab_open(NULL, 0);
2163 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2164 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2165 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2166 xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2167 return 0;
2170 compile_prog "" "$xen_libs"
2171 then
2172 xen_ctrl_version=460
2173 xen=yes
2175 # Xen 4.5
2176 elif
2177 cat > $TMPC <<EOF &&
2178 #include <xenctrl.h>
2179 #include <xenstore.h>
2180 #include <stdint.h>
2181 #include <xen/hvm/hvm_info_table.h>
2182 #if !defined(HVM_MAX_VCPUS)
2183 # error HVM_MAX_VCPUS not defined
2184 #endif
2185 int main(void) {
2186 xc_interface *xc;
2187 xs_daemon_open();
2188 xc = xc_interface_open(0, 0, 0);
2189 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2190 xc_gnttab_open(NULL, 0);
2191 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2192 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2193 xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
2194 return 0;
2197 compile_prog "" "$xen_libs"
2198 then
2199 xen_ctrl_version=450
2200 xen=yes
2202 elif
2203 cat > $TMPC <<EOF &&
2204 #include <xenctrl.h>
2205 #include <xenstore.h>
2206 #include <stdint.h>
2207 #include <xen/hvm/hvm_info_table.h>
2208 #if !defined(HVM_MAX_VCPUS)
2209 # error HVM_MAX_VCPUS not defined
2210 #endif
2211 int main(void) {
2212 xc_interface *xc;
2213 xs_daemon_open();
2214 xc = xc_interface_open(0, 0, 0);
2215 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2216 xc_gnttab_open(NULL, 0);
2217 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2218 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2219 return 0;
2222 compile_prog "" "$xen_libs"
2223 then
2224 xen_ctrl_version=420
2225 xen=yes
2227 else
2228 if test "$xen" = "yes" ; then
2229 feature_not_found "xen (unsupported version)" \
2230 "Install a supported xen (xen 4.2 or newer)"
2232 xen=no
2235 if test "$xen" = yes; then
2236 if test $xen_ctrl_version -ge 471 ; then
2237 libs_softmmu="$xen_stable_libs $libs_softmmu"
2239 libs_softmmu="$xen_libs $libs_softmmu"
2243 if test "$xen_pci_passthrough" != "no"; then
2244 if test "$xen" = "yes" && test "$linux" = "yes"; then
2245 xen_pci_passthrough=yes
2246 else
2247 if test "$xen_pci_passthrough" = "yes"; then
2248 error_exit "User requested feature Xen PCI Passthrough" \
2249 " but this feature requires /sys from Linux"
2251 xen_pci_passthrough=no
2255 if test "$xen_pv_domain_build" = "yes" &&
2256 test "$xen" != "yes"; then
2257 error_exit "User requested Xen PV domain builder support" \
2258 "which requires Xen support."
2261 ##########################################
2262 # Sparse probe
2263 if test "$sparse" != "no" ; then
2264 if has cgcc; then
2265 sparse=yes
2266 else
2267 if test "$sparse" = "yes" ; then
2268 feature_not_found "sparse" "Install sparse binary"
2270 sparse=no
2274 ##########################################
2275 # X11 probe
2276 x11_cflags=
2277 x11_libs=-lX11
2278 if $pkg_config --exists "x11"; then
2279 x11_cflags=$($pkg_config --cflags x11)
2280 x11_libs=$($pkg_config --libs x11)
2283 ##########################################
2284 # GTK probe
2286 if test "$gtkabi" = ""; then
2287 # The GTK ABI was not specified explicitly, so try whether 2.0 is available.
2288 # Use 3.0 as a fallback if that is available.
2289 if $pkg_config --exists "gtk+-2.0 >= 2.18.0"; then
2290 gtkabi=2.0
2291 elif $pkg_config --exists "gtk+-3.0 >= 3.0.0"; then
2292 gtkabi=3.0
2293 else
2294 gtkabi=2.0
2298 if test "$gtk" != "no"; then
2299 gtkpackage="gtk+-$gtkabi"
2300 gtkx11package="gtk+-x11-$gtkabi"
2301 if test "$gtkabi" = "3.0" ; then
2302 gtkversion="3.0.0"
2303 else
2304 gtkversion="2.18.0"
2306 if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
2307 gtk_cflags=$($pkg_config --cflags $gtkpackage)
2308 gtk_libs=$($pkg_config --libs $gtkpackage)
2309 gtk_version=$($pkg_config --modversion $gtkpackage)
2310 if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
2311 gtk_cflags="$gtk_cflags $x11_cflags"
2312 gtk_libs="$gtk_libs $x11_libs"
2314 libs_softmmu="$gtk_libs $libs_softmmu"
2315 gtk="yes"
2316 elif test "$gtk" = "yes"; then
2317 feature_not_found "gtk" "Install gtk2 or gtk3 devel"
2318 else
2319 gtk="no"
2324 ##########################################
2325 # GNUTLS probe
2327 gnutls_works() {
2328 # Unfortunately some distros have bad pkg-config information for gnutls
2329 # such that it claims to exist but you get a compiler error if you try
2330 # to use the options returned by --libs. Specifically, Ubuntu for --static
2331 # builds doesn't work:
2332 # https://bugs.launchpad.net/ubuntu/+source/gnutls26/+bug/1478035
2334 # So sanity check the cflags/libs before assuming gnutls can be used.
2335 if ! $pkg_config --exists "gnutls"; then
2336 return 1
2339 write_c_skeleton
2340 compile_prog "$($pkg_config --cflags gnutls)" "$($pkg_config --libs gnutls)"
2343 gnutls_gcrypt=no
2344 gnutls_nettle=no
2345 if test "$gnutls" != "no"; then
2346 if gnutls_works; then
2347 gnutls_cflags=$($pkg_config --cflags gnutls)
2348 gnutls_libs=$($pkg_config --libs gnutls)
2349 libs_softmmu="$gnutls_libs $libs_softmmu"
2350 libs_tools="$gnutls_libs $libs_tools"
2351 QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
2352 gnutls="yes"
2354 # gnutls_rnd requires >= 2.11.0
2355 if $pkg_config --exists "gnutls >= 2.11.0"; then
2356 gnutls_rnd="yes"
2357 else
2358 gnutls_rnd="no"
2361 if $pkg_config --exists 'gnutls >= 3.0'; then
2362 gnutls_gcrypt=no
2363 gnutls_nettle=yes
2364 elif $pkg_config --exists 'gnutls >= 2.12'; then
2365 case $($pkg_config --libs --static gnutls) in
2366 *gcrypt*)
2367 gnutls_gcrypt=yes
2368 gnutls_nettle=no
2370 *nettle*)
2371 gnutls_gcrypt=no
2372 gnutls_nettle=yes
2375 gnutls_gcrypt=yes
2376 gnutls_nettle=no
2378 esac
2379 else
2380 gnutls_gcrypt=yes
2381 gnutls_nettle=no
2383 elif test "$gnutls" = "yes"; then
2384 feature_not_found "gnutls" "Install gnutls devel"
2385 else
2386 gnutls="no"
2387 gnutls_rnd="no"
2389 else
2390 gnutls_rnd="no"
2394 # If user didn't give a --disable/enable-gcrypt flag,
2395 # then mark as disabled if user requested nettle
2396 # explicitly, or if gnutls links to nettle
2397 if test -z "$gcrypt"
2398 then
2399 if test "$nettle" = "yes" || test "$gnutls_nettle" = "yes"
2400 then
2401 gcrypt="no"
2405 # If user didn't give a --disable/enable-nettle flag,
2406 # then mark as disabled if user requested gcrypt
2407 # explicitly, or if gnutls links to gcrypt
2408 if test -z "$nettle"
2409 then
2410 if test "$gcrypt" = "yes" || test "$gnutls_gcrypt" = "yes"
2411 then
2412 nettle="no"
2416 has_libgcrypt_config() {
2417 if ! has "libgcrypt-config"
2418 then
2419 return 1
2422 if test -n "$cross_prefix"
2423 then
2424 host=$(libgcrypt-config --host)
2425 if test "$host-" != $cross_prefix
2426 then
2427 return 1
2431 return 0
2434 if test "$gcrypt" != "no"; then
2435 if has_libgcrypt_config; then
2436 gcrypt_cflags=$(libgcrypt-config --cflags)
2437 gcrypt_libs=$(libgcrypt-config --libs)
2438 # Debian has remove -lgpg-error from libgcrypt-config
2439 # as it "spreads unnecessary dependencies" which in
2440 # turn breaks static builds...
2441 if test "$static" = "yes"
2442 then
2443 gcrypt_libs="$gcrypt_libs -lgpg-error"
2445 libs_softmmu="$gcrypt_libs $libs_softmmu"
2446 libs_tools="$gcrypt_libs $libs_tools"
2447 QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
2448 gcrypt="yes"
2449 if test -z "$nettle"; then
2450 nettle="no"
2453 cat > $TMPC << EOF
2454 #include <gcrypt.h>
2455 int main(void) {
2456 gcry_kdf_derive(NULL, 0, GCRY_KDF_PBKDF2,
2457 GCRY_MD_SHA256,
2458 NULL, 0, 0, 0, NULL);
2459 return 0;
2462 if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
2463 gcrypt_kdf=yes
2466 cat > $TMPC << EOF
2467 #include <gcrypt.h>
2468 int main(void) {
2469 gcry_mac_hd_t handle;
2470 gcry_mac_open(&handle, GCRY_MAC_HMAC_MD5,
2471 GCRY_MAC_FLAG_SECURE, NULL);
2472 return 0;
2475 if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
2476 gcrypt_hmac=yes
2478 else
2479 if test "$gcrypt" = "yes"; then
2480 feature_not_found "gcrypt" "Install gcrypt devel"
2481 else
2482 gcrypt="no"
2488 if test "$nettle" != "no"; then
2489 if $pkg_config --exists "nettle"; then
2490 nettle_cflags=$($pkg_config --cflags nettle)
2491 nettle_libs=$($pkg_config --libs nettle)
2492 nettle_version=$($pkg_config --modversion nettle)
2493 libs_softmmu="$nettle_libs $libs_softmmu"
2494 libs_tools="$nettle_libs $libs_tools"
2495 QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
2496 nettle="yes"
2498 cat > $TMPC << EOF
2499 #include <stddef.h>
2500 #include <nettle/pbkdf2.h>
2501 int main(void) {
2502 pbkdf2_hmac_sha256(8, NULL, 1000, 8, NULL, 8, NULL);
2503 return 0;
2506 if compile_prog "$nettle_cflags" "$nettle_libs" ; then
2507 nettle_kdf=yes
2509 else
2510 if test "$nettle" = "yes"; then
2511 feature_not_found "nettle" "Install nettle devel"
2512 else
2513 nettle="no"
2518 if test "$gcrypt" = "yes" && test "$nettle" = "yes"
2519 then
2520 error_exit "Only one of gcrypt & nettle can be enabled"
2523 ##########################################
2524 # libtasn1 - only for the TLS creds/session test suite
2526 tasn1=yes
2527 tasn1_cflags=""
2528 tasn1_libs=""
2529 if $pkg_config --exists "libtasn1"; then
2530 tasn1_cflags=$($pkg_config --cflags libtasn1)
2531 tasn1_libs=$($pkg_config --libs libtasn1)
2532 else
2533 tasn1=no
2537 ##########################################
2538 # getifaddrs (for tests/test-io-channel-socket )
2540 have_ifaddrs_h=yes
2541 if ! check_include "ifaddrs.h" ; then
2542 have_ifaddrs_h=no
2545 ##########################################
2546 # VTE probe
2548 if test "$vte" != "no"; then
2549 if test "$gtkabi" = "3.0"; then
2550 vteminversion="0.32.0"
2551 if $pkg_config --exists "vte-2.91"; then
2552 vtepackage="vte-2.91"
2553 else
2554 vtepackage="vte-2.90"
2556 else
2557 vtepackage="vte"
2558 vteminversion="0.24.0"
2560 if $pkg_config --exists "$vtepackage >= $vteminversion"; then
2561 vte_cflags=$($pkg_config --cflags $vtepackage)
2562 vte_libs=$($pkg_config --libs $vtepackage)
2563 vteversion=$($pkg_config --modversion $vtepackage)
2564 libs_softmmu="$vte_libs $libs_softmmu"
2565 vte="yes"
2566 elif test "$vte" = "yes"; then
2567 if test "$gtkabi" = "3.0"; then
2568 feature_not_found "vte" "Install libvte-2.90/2.91 devel"
2569 else
2570 feature_not_found "vte" "Install libvte devel"
2572 else
2573 vte="no"
2577 ##########################################
2578 # SDL probe
2580 # Look for sdl configuration program (pkg-config or sdl-config). Try
2581 # sdl-config even without cross prefix, and favour pkg-config over sdl-config.
2583 if test "$sdlabi" = ""; then
2584 if $pkg_config --exists "sdl"; then
2585 sdlabi=1.2
2586 elif $pkg_config --exists "sdl2"; then
2587 sdlabi=2.0
2588 else
2589 sdlabi=1.2
2593 if test $sdlabi = "2.0"; then
2594 sdl_config=$sdl2_config
2595 sdlname=sdl2
2596 sdlconfigname=sdl2_config
2597 elif test $sdlabi = "1.2"; then
2598 sdlname=sdl
2599 sdlconfigname=sdl_config
2600 else
2601 error_exit "Unknown sdlabi $sdlabi, must be 1.2 or 2.0"
2604 if test "$(basename $sdl_config)" != $sdlconfigname && ! has ${sdl_config}; then
2605 sdl_config=$sdlconfigname
2608 if $pkg_config $sdlname --exists; then
2609 sdlconfig="$pkg_config $sdlname"
2610 sdlversion=$($sdlconfig --modversion 2>/dev/null)
2611 elif has ${sdl_config}; then
2612 sdlconfig="$sdl_config"
2613 sdlversion=$($sdlconfig --version)
2614 else
2615 if test "$sdl" = "yes" ; then
2616 feature_not_found "sdl" "Install SDL devel"
2618 sdl=no
2620 if test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
2621 echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
2624 sdl_too_old=no
2625 if test "$sdl" != "no" ; then
2626 cat > $TMPC << EOF
2627 #include <SDL.h>
2628 #undef main /* We don't want SDL to override our main() */
2629 int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
2631 sdl_cflags=$($sdlconfig --cflags 2>/dev/null)
2632 if test "$static" = "yes" ; then
2633 sdl_libs=$($sdlconfig --static-libs 2>/dev/null)
2634 else
2635 sdl_libs=$($sdlconfig --libs 2>/dev/null)
2637 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
2638 if test $(echo $sdlversion | sed 's/[^0-9]//g') -lt 121 ; then
2639 sdl_too_old=yes
2640 else
2641 sdl=yes
2644 # static link with sdl ? (note: sdl.pc's --static --libs is broken)
2645 if test "$sdl" = "yes" -a "$static" = "yes" ; then
2646 if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
2647 sdl_libs="$sdl_libs $(aalib-config --static-libs 2>/dev/null)"
2648 sdl_cflags="$sdl_cflags $(aalib-config --cflags 2>/dev/null)"
2650 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
2652 else
2653 sdl=no
2655 fi # static link
2656 else # sdl not found
2657 if test "$sdl" = "yes" ; then
2658 feature_not_found "sdl" "Install SDL devel"
2660 sdl=no
2661 fi # sdl compile test
2664 if test "$sdl" = "yes" ; then
2665 cat > $TMPC <<EOF
2666 #include <SDL.h>
2667 #if defined(SDL_VIDEO_DRIVER_X11)
2668 #include <X11/XKBlib.h>
2669 #else
2670 #error No x11 support
2671 #endif
2672 int main(void) { return 0; }
2674 if compile_prog "$sdl_cflags $x11_cflags" "$sdl_libs $x11_libs" ; then
2675 sdl_cflags="$sdl_cflags $x11_cflags"
2676 sdl_libs="$sdl_libs $x11_libs"
2678 libs_softmmu="$sdl_libs $libs_softmmu"
2681 ##########################################
2682 # RDMA needs OpenFabrics libraries
2683 if test "$rdma" != "no" ; then
2684 cat > $TMPC <<EOF
2685 #include <rdma/rdma_cma.h>
2686 int main(void) { return 0; }
2688 rdma_libs="-lrdmacm -libverbs"
2689 if compile_prog "" "$rdma_libs" ; then
2690 rdma="yes"
2691 libs_softmmu="$libs_softmmu $rdma_libs"
2692 else
2693 if test "$rdma" = "yes" ; then
2694 error_exit \
2695 " OpenFabrics librdmacm/libibverbs not present." \
2696 " Your options:" \
2697 " (1) Fast: Install infiniband packages from your distro." \
2698 " (2) Cleanest: Install libraries from www.openfabrics.org" \
2699 " (3) Also: Install softiwarp if you don't have RDMA hardware"
2701 rdma="no"
2705 ##########################################
2706 # VNC SASL detection
2707 if test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
2708 cat > $TMPC <<EOF
2709 #include <sasl/sasl.h>
2710 #include <stdio.h>
2711 int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
2713 # Assuming Cyrus-SASL installed in /usr prefix
2714 vnc_sasl_cflags=""
2715 vnc_sasl_libs="-lsasl2"
2716 if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
2717 vnc_sasl=yes
2718 libs_softmmu="$vnc_sasl_libs $libs_softmmu"
2719 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
2720 else
2721 if test "$vnc_sasl" = "yes" ; then
2722 feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
2724 vnc_sasl=no
2728 ##########################################
2729 # VNC JPEG detection
2730 if test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
2731 if $pkg_config --exists libjpeg; then
2732 vnc_jpeg=yes
2733 libs_softmmu="$libs_softmmu $($pkg_config --libs libjpeg)"
2734 QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags libjpeg)"
2735 else
2736 cat > $TMPC <<EOF
2737 #include <stdio.h>
2738 #include <jpeglib.h>
2739 int main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
2741 vnc_jpeg_cflags=""
2742 vnc_jpeg_libs="-ljpeg"
2743 if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
2744 vnc_jpeg=yes
2745 libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
2746 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
2747 else
2748 if test "$vnc_jpeg" = "yes" ; then
2749 feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
2751 vnc_jpeg=no
2756 ##########################################
2757 # VNC PNG detection
2758 if test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
2759 cat > $TMPC <<EOF
2760 //#include <stdio.h>
2761 #include <png.h>
2762 #include <stddef.h>
2763 int main(void) {
2764 png_structp png_ptr;
2765 png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
2766 return png_ptr != 0;
2769 if $pkg_config libpng --exists; then
2770 vnc_png_cflags=$($pkg_config libpng --cflags)
2771 vnc_png_libs=$($pkg_config libpng --libs)
2772 else
2773 vnc_png_cflags=""
2774 vnc_png_libs="-lpng"
2776 if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
2777 vnc_png=yes
2778 libs_softmmu="$vnc_png_libs $libs_softmmu"
2779 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
2780 else
2781 if test "$vnc_png" = "yes" ; then
2782 feature_not_found "vnc-png" "Install libpng devel"
2784 vnc_png=no
2788 ##########################################
2789 # fnmatch() probe, used for ACL routines
2790 fnmatch="no"
2791 cat > $TMPC << EOF
2792 #include <fnmatch.h>
2793 int main(void)
2795 fnmatch("foo", "foo", 0);
2796 return 0;
2799 if compile_prog "" "" ; then
2800 fnmatch="yes"
2803 ##########################################
2804 # xfsctl() probe, used for file-posix.c
2805 if test "$xfs" != "no" ; then
2806 cat > $TMPC << EOF
2807 #include <stddef.h> /* NULL */
2808 #include <xfs/xfs.h>
2809 int main(void)
2811 xfsctl(NULL, 0, 0, NULL);
2812 return 0;
2815 if compile_prog "" "" ; then
2816 xfs="yes"
2817 else
2818 if test "$xfs" = "yes" ; then
2819 feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
2821 xfs=no
2825 ##########################################
2826 # vde libraries probe
2827 if test "$vde" != "no" ; then
2828 vde_libs="-lvdeplug"
2829 cat > $TMPC << EOF
2830 #include <stddef.h>
2831 #include <libvdeplug.h>
2832 int main(void)
2834 struct vde_open_args a = {0, 0, 0};
2835 char s[] = "";
2836 vde_open(s, s, &a);
2837 return 0;
2840 if compile_prog "" "$vde_libs" ; then
2841 vde=yes
2842 libs_softmmu="$vde_libs $libs_softmmu"
2843 libs_tools="$vde_libs $libs_tools"
2844 else
2845 if test "$vde" = "yes" ; then
2846 feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
2848 vde=no
2852 ##########################################
2853 # netmap support probe
2854 # Apart from looking for netmap headers, we make sure that the host API version
2855 # supports the netmap backend (>=11). The upper bound (15) is meant to simulate
2856 # a minor/major version number. Minor new features will be marked with values up
2857 # to 15, and if something happens that requires a change to the backend we will
2858 # move above 15, submit the backend fixes and modify this two bounds.
2859 if test "$netmap" != "no" ; then
2860 cat > $TMPC << EOF
2861 #include <inttypes.h>
2862 #include <net/if.h>
2863 #include <net/netmap.h>
2864 #include <net/netmap_user.h>
2865 #if (NETMAP_API < 11) || (NETMAP_API > 15)
2866 #error
2867 #endif
2868 int main(void) { return 0; }
2870 if compile_prog "" "" ; then
2871 netmap=yes
2872 else
2873 if test "$netmap" = "yes" ; then
2874 feature_not_found "netmap"
2876 netmap=no
2880 ##########################################
2881 # libcap-ng library probe
2882 if test "$cap_ng" != "no" ; then
2883 cap_libs="-lcap-ng"
2884 cat > $TMPC << EOF
2885 #include <cap-ng.h>
2886 int main(void)
2888 capng_capability_to_name(CAPNG_EFFECTIVE);
2889 return 0;
2892 if compile_prog "" "$cap_libs" ; then
2893 cap_ng=yes
2894 libs_tools="$cap_libs $libs_tools"
2895 else
2896 if test "$cap_ng" = "yes" ; then
2897 feature_not_found "cap_ng" "Install libcap-ng devel"
2899 cap_ng=no
2903 ##########################################
2904 # Sound support libraries probe
2906 audio_drv_probe()
2908 drv=$1
2909 hdr=$2
2910 lib=$3
2911 exp=$4
2912 cfl=$5
2913 cat > $TMPC << EOF
2914 #include <$hdr>
2915 int main(void) { $exp }
2917 if compile_prog "$cfl" "$lib" ; then
2919 else
2920 error_exit "$drv check failed" \
2921 "Make sure to have the $drv libs and headers installed."
2925 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
2926 for drv in $audio_drv_list; do
2927 case $drv in
2928 alsa)
2929 audio_drv_probe $drv alsa/asoundlib.h -lasound \
2930 "return snd_pcm_close((snd_pcm_t *)0);"
2931 libs_softmmu="-lasound $libs_softmmu"
2935 audio_drv_probe $drv pulse/pulseaudio.h "-lpulse" \
2936 "pa_context_set_source_output_volume(NULL, 0, NULL, NULL, NULL); return 0;"
2937 libs_softmmu="-lpulse $libs_softmmu"
2938 audio_pt_int="yes"
2941 sdl)
2942 if test "$sdl" = "no"; then
2943 error_exit "sdl not found or disabled, can not use sdl audio driver"
2947 coreaudio)
2948 libs_softmmu="-framework CoreAudio $libs_softmmu"
2951 dsound)
2952 libs_softmmu="-lole32 -ldxguid $libs_softmmu"
2953 audio_win_int="yes"
2956 oss)
2957 libs_softmmu="$oss_lib $libs_softmmu"
2960 wav)
2961 # XXX: Probes for CoreAudio, DirectSound
2965 echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
2966 error_exit "Unknown driver '$drv' selected" \
2967 "Possible drivers are: $audio_possible_drivers"
2970 esac
2971 done
2973 ##########################################
2974 # BrlAPI probe
2976 if test "$brlapi" != "no" ; then
2977 brlapi_libs="-lbrlapi"
2978 cat > $TMPC << EOF
2979 #include <brlapi.h>
2980 #include <stddef.h>
2981 int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
2983 if compile_prog "" "$brlapi_libs" ; then
2984 brlapi=yes
2985 libs_softmmu="$brlapi_libs $libs_softmmu"
2986 else
2987 if test "$brlapi" = "yes" ; then
2988 feature_not_found "brlapi" "Install brlapi devel"
2990 brlapi=no
2994 ##########################################
2995 # curses probe
2996 if test "$curses" != "no" ; then
2997 if test "$mingw32" = "yes" ; then
2998 curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
2999 curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
3000 else
3001 curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"
3002 curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
3004 curses_found=no
3005 cat > $TMPC << EOF
3006 #include <locale.h>
3007 #include <curses.h>
3008 #include <wchar.h>
3009 int main(void) {
3010 const char *s = curses_version();
3011 wchar_t wch = L'w';
3012 setlocale(LC_ALL, "");
3013 resize_term(0, 0);
3014 addwstr(L"wide chars\n");
3015 addnwstr(&wch, 1);
3016 add_wch(WACS_DEGREE);
3017 return s != 0;
3020 IFS=:
3021 for curses_inc in $curses_inc_list; do
3022 IFS=:
3023 for curses_lib in $curses_lib_list; do
3024 unset IFS
3025 if compile_prog "$curses_inc" "$curses_lib" ; then
3026 curses_found=yes
3027 QEMU_CFLAGS="$curses_inc $QEMU_CFLAGS"
3028 libs_softmmu="$curses_lib $libs_softmmu"
3029 break
3031 done
3032 if test "$curses_found" = yes ; then
3033 break
3035 done
3036 unset IFS
3037 if test "$curses_found" = "yes" ; then
3038 curses=yes
3039 else
3040 if test "$curses" = "yes" ; then
3041 feature_not_found "curses" "Install ncurses devel"
3043 curses=no
3047 ##########################################
3048 # curl probe
3049 if test "$curl" != "no" ; then
3050 if $pkg_config libcurl --exists; then
3051 curlconfig="$pkg_config libcurl"
3052 else
3053 curlconfig=curl-config
3055 cat > $TMPC << EOF
3056 #include <curl/curl.h>
3057 int main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
3059 curl_cflags=$($curlconfig --cflags 2>/dev/null)
3060 curl_libs=$($curlconfig --libs 2>/dev/null)
3061 if compile_prog "$curl_cflags" "$curl_libs" ; then
3062 curl=yes
3063 else
3064 if test "$curl" = "yes" ; then
3065 feature_not_found "curl" "Install libcurl devel"
3067 curl=no
3069 fi # test "$curl"
3071 ##########################################
3072 # bluez support probe
3073 if test "$bluez" != "no" ; then
3074 cat > $TMPC << EOF
3075 #include <bluetooth/bluetooth.h>
3076 int main(void) { return bt_error(0); }
3078 bluez_cflags=$($pkg_config --cflags bluez 2>/dev/null)
3079 bluez_libs=$($pkg_config --libs bluez 2>/dev/null)
3080 if compile_prog "$bluez_cflags" "$bluez_libs" ; then
3081 bluez=yes
3082 libs_softmmu="$bluez_libs $libs_softmmu"
3083 else
3084 if test "$bluez" = "yes" ; then
3085 feature_not_found "bluez" "Install bluez-libs/libbluetooth devel"
3087 bluez="no"
3091 ##########################################
3092 # glib support probe
3094 glib_req_ver=2.22
3095 glib_modules=gthread-2.0
3096 if test "$modules" = yes; then
3097 glib_modules="$glib_modules gmodule-2.0"
3100 for i in $glib_modules; do
3101 if $pkg_config --atleast-version=$glib_req_ver $i; then
3102 glib_cflags=$($pkg_config --cflags $i)
3103 glib_libs=$($pkg_config --libs $i)
3104 QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
3105 LIBS="$glib_libs $LIBS"
3106 libs_qga="$glib_libs $libs_qga"
3107 else
3108 error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3110 done
3112 # Sanity check that the current size_t matches the
3113 # size that glib thinks it should be. This catches
3114 # problems on multi-arch where people try to build
3115 # 32-bit QEMU while pointing at 64-bit glib headers
3116 cat > $TMPC <<EOF
3117 #include <glib.h>
3118 #include <unistd.h>
3120 #define QEMU_BUILD_BUG_ON(x) \
3121 typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3123 int main(void) {
3124 QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3125 return 0;
3129 if ! compile_prog "$CFLAGS" "$LIBS" ; then
3130 error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3131 "You probably need to set PKG_CONFIG_LIBDIR"\
3132 "to point to the right pkg-config files for your"\
3133 "build target"
3136 # g_test_trap_subprocess added in 2.38. Used by some tests.
3137 glib_subprocess=yes
3138 if ! $pkg_config --atleast-version=2.38 glib-2.0; then
3139 glib_subprocess=no
3142 # Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
3143 cat > $TMPC << EOF
3144 #include <glib.h>
3145 int main(void) { return 0; }
3147 if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3148 if cc_has_warning_flag "-Wno-unknown-attributes"; then
3149 glib_cflags="-Wno-unknown-attributes $glib_cflags"
3150 CFLAGS="-Wno-unknown-attributes $CFLAGS"
3154 #########################################
3155 # zlib check
3157 if test "$zlib" != "no" ; then
3158 if $pkg_config --exists zlib; then
3159 zlib_cflags=$($pkg_config --cflags zlib)
3160 zlib_libs=$($pkg_config --libs zlib)
3161 QEMU_CFLAGS="$zlib_cflags $QEMU_CFLAGS"
3162 LIBS="$zlib_libs $LIBS"
3163 else
3164 cat > $TMPC << EOF
3165 #include <zlib.h>
3166 int main(void) { zlibVersion(); return 0; }
3168 if compile_prog "" "-lz" ; then
3169 LIBS="$LIBS -lz"
3170 else
3171 error_exit "zlib check failed" \
3172 "Make sure to have the zlib libs and headers installed."
3177 ##########################################
3178 # SHA command probe for modules
3179 if test "$modules" = yes; then
3180 shacmd_probe="sha1sum sha1 shasum"
3181 for c in $shacmd_probe; do
3182 if has $c; then
3183 shacmd="$c"
3184 break
3186 done
3187 if test "$shacmd" = ""; then
3188 error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3192 ##########################################
3193 # pixman support probe
3195 if test "$pixman" = ""; then
3196 if test "$want_tools" = "no" -a "$softmmu" = "no"; then
3197 pixman="none"
3198 elif $pkg_config --atleast-version=0.21.8 pixman-1 > /dev/null 2>&1; then
3199 pixman="system"
3200 else
3201 pixman="internal"
3204 if test "$pixman" = "none"; then
3205 if test "$want_tools" != "no" -o "$softmmu" != "no"; then
3206 error_exit "pixman disabled but system emulation or tools build" \
3207 "enabled. You can turn off pixman only if you also" \
3208 "disable all system emulation targets and the tools" \
3209 "build with '--disable-tools --disable-system'."
3211 pixman_cflags=
3212 pixman_libs=
3213 elif test "$pixman" = "system"; then
3214 # pixman version has been checked above
3215 pixman_cflags=$($pkg_config --cflags pixman-1)
3216 pixman_libs=$($pkg_config --libs pixman-1)
3217 else
3218 if test ! -d ${source_path}/pixman/pixman; then
3219 error_exit "pixman >= 0.21.8 not present. Your options:" \
3220 " (1) Preferred: Install the pixman devel package (any recent" \
3221 " distro should have packages as Xorg needs pixman too)." \
3222 " (2) Fetch the pixman submodule, using:" \
3223 " git submodule update --init pixman"
3225 mkdir -p pixman/pixman
3226 pixman_cflags="-I\$(SRC_PATH)/pixman/pixman -I\$(BUILD_DIR)/pixman/pixman"
3227 pixman_libs="-L\$(BUILD_DIR)/pixman/pixman/.libs -lpixman-1"
3230 ##########################################
3231 # libcap probe
3233 if test "$cap" != "no" ; then
3234 cat > $TMPC <<EOF
3235 #include <stdio.h>
3236 #include <sys/capability.h>
3237 int main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
3239 if compile_prog "" "-lcap" ; then
3240 cap=yes
3241 else
3242 cap=no
3246 ##########################################
3247 # pthread probe
3248 PTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
3250 pthread=no
3251 cat > $TMPC << EOF
3252 #include <pthread.h>
3253 static void *f(void *p) { return NULL; }
3254 int main(void) {
3255 pthread_t thread;
3256 pthread_create(&thread, 0, f, 0);
3257 return 0;
3260 if compile_prog "" "" ; then
3261 pthread=yes
3262 else
3263 for pthread_lib in $PTHREADLIBS_LIST; do
3264 if compile_prog "" "$pthread_lib" ; then
3265 pthread=yes
3266 found=no
3267 for lib_entry in $LIBS; do
3268 if test "$lib_entry" = "$pthread_lib"; then
3269 found=yes
3270 break
3272 done
3273 if test "$found" = "no"; then
3274 LIBS="$pthread_lib $LIBS"
3276 PTHREAD_LIB="$pthread_lib"
3277 break
3279 done
3282 if test "$mingw32" != yes -a "$pthread" = no; then
3283 error_exit "pthread check failed" \
3284 "Make sure to have the pthread libs and headers installed."
3287 # check for pthread_setname_np
3288 pthread_setname_np=no
3289 cat > $TMPC << EOF
3290 #include <pthread.h>
3292 static void *f(void *p) { return NULL; }
3293 int main(void)
3295 pthread_t thread;
3296 pthread_create(&thread, 0, f, 0);
3297 pthread_setname_np(thread, "QEMU");
3298 return 0;
3301 if compile_prog "" "$pthread_lib" ; then
3302 pthread_setname_np=yes
3305 ##########################################
3306 # rbd probe
3307 if test "$rbd" != "no" ; then
3308 cat > $TMPC <<EOF
3309 #include <stdio.h>
3310 #include <rbd/librbd.h>
3311 int main(void) {
3312 rados_t cluster;
3313 rados_create(&cluster, NULL);
3314 return 0;
3317 rbd_libs="-lrbd -lrados"
3318 if compile_prog "" "$rbd_libs" ; then
3319 rbd=yes
3320 else
3321 if test "$rbd" = "yes" ; then
3322 feature_not_found "rados block device" "Install librbd/ceph devel"
3324 rbd=no
3328 ##########################################
3329 # libssh2 probe
3330 min_libssh2_version=1.2.8
3331 if test "$libssh2" != "no" ; then
3332 if $pkg_config --atleast-version=$min_libssh2_version libssh2; then
3333 libssh2_cflags=$($pkg_config libssh2 --cflags)
3334 libssh2_libs=$($pkg_config libssh2 --libs)
3335 libssh2=yes
3336 else
3337 if test "$libssh2" = "yes" ; then
3338 error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2"
3340 libssh2=no
3344 ##########################################
3345 # libssh2_sftp_fsync probe
3347 if test "$libssh2" = "yes"; then
3348 cat > $TMPC <<EOF
3349 #include <stdio.h>
3350 #include <libssh2.h>
3351 #include <libssh2_sftp.h>
3352 int main(void) {
3353 LIBSSH2_SESSION *session;
3354 LIBSSH2_SFTP *sftp;
3355 LIBSSH2_SFTP_HANDLE *sftp_handle;
3356 session = libssh2_session_init ();
3357 sftp = libssh2_sftp_init (session);
3358 sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0);
3359 libssh2_sftp_fsync (sftp_handle);
3360 return 0;
3363 # libssh2_cflags/libssh2_libs defined in previous test.
3364 if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then
3365 QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS"
3369 ##########################################
3370 # linux-aio probe
3372 if test "$linux_aio" != "no" ; then
3373 cat > $TMPC <<EOF
3374 #include <libaio.h>
3375 #include <sys/eventfd.h>
3376 #include <stddef.h>
3377 int main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
3379 if compile_prog "" "-laio" ; then
3380 linux_aio=yes
3381 else
3382 if test "$linux_aio" = "yes" ; then
3383 feature_not_found "linux AIO" "Install libaio devel"
3385 linux_aio=no
3389 ##########################################
3390 # TPM passthrough is only on x86 Linux
3392 if test "$targetos" = Linux && test "$cpu" = i386 -o "$cpu" = x86_64; then
3393 tpm_passthrough=$tpm
3394 else
3395 tpm_passthrough=no
3398 ##########################################
3399 # attr probe
3401 if test "$attr" != "no" ; then
3402 cat > $TMPC <<EOF
3403 #include <stdio.h>
3404 #include <sys/types.h>
3405 #ifdef CONFIG_LIBATTR
3406 #include <attr/xattr.h>
3407 #else
3408 #include <sys/xattr.h>
3409 #endif
3410 int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
3412 if compile_prog "" "" ; then
3413 attr=yes
3414 # Older distros have <attr/xattr.h>, and need -lattr:
3415 elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
3416 attr=yes
3417 LIBS="-lattr $LIBS"
3418 libattr=yes
3419 else
3420 if test "$attr" = "yes" ; then
3421 feature_not_found "ATTR" "Install libc6 or libattr devel"
3423 attr=no
3427 ##########################################
3428 # iovec probe
3429 cat > $TMPC <<EOF
3430 #include <sys/types.h>
3431 #include <sys/uio.h>
3432 #include <unistd.h>
3433 int main(void) { return sizeof(struct iovec); }
3435 iovec=no
3436 if compile_prog "" "" ; then
3437 iovec=yes
3440 ##########################################
3441 # preadv probe
3442 cat > $TMPC <<EOF
3443 #include <sys/types.h>
3444 #include <sys/uio.h>
3445 #include <unistd.h>
3446 int main(void) { return preadv(0, 0, 0, 0); }
3448 preadv=no
3449 if compile_prog "" "" ; then
3450 preadv=yes
3453 ##########################################
3454 # fdt probe
3455 # fdt support is mandatory for at least some target architectures,
3456 # so insist on it if we're building those system emulators.
3457 fdt_required=no
3458 for target in $target_list; do
3459 case $target in
3460 aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu)
3461 fdt_required=yes
3463 esac
3464 done
3466 if test "$fdt_required" = "yes"; then
3467 if test "$fdt" = "no"; then
3468 error_exit "fdt disabled but some requested targets require it." \
3469 "You can turn off fdt only if you also disable all the system emulation" \
3470 "targets which need it (by specifying a cut down --target-list)."
3472 fdt=yes
3475 if test "$fdt" != "no" ; then
3476 fdt_libs="-lfdt"
3477 # explicitly check for libfdt_env.h as it is missing in some stable installs
3478 # and test for required functions to make sure we are on a version >= 1.4.2
3479 cat > $TMPC << EOF
3480 #include <libfdt.h>
3481 #include <libfdt_env.h>
3482 int main(void) { fdt_first_subnode(0, 0); return 0; }
3484 if compile_prog "" "$fdt_libs" ; then
3485 # system DTC is good - use it
3486 fdt=yes
3487 elif test -d ${source_path}/dtc/libfdt ; then
3488 # have submodule DTC - use it
3489 fdt=yes
3490 dtc_internal="yes"
3491 mkdir -p dtc
3492 if [ "$pwd_is_source_path" != "y" ] ; then
3493 symlink "$source_path/dtc/Makefile" "dtc/Makefile"
3494 symlink "$source_path/dtc/scripts" "dtc/scripts"
3496 fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
3497 fdt_libs="-L\$(BUILD_DIR)/dtc/libfdt $fdt_libs"
3498 elif test "$fdt" = "yes" ; then
3499 # have neither and want - prompt for system/submodule install
3500 error_exit "DTC (libfdt) version >= 1.4.2 not present. Your options:" \
3501 " (1) Preferred: Install the DTC (libfdt) devel package" \
3502 " (2) Fetch the DTC submodule, using:" \
3503 " git submodule update --init dtc"
3504 else
3505 # don't have and don't want
3506 fdt_libs=
3507 fdt=no
3511 libs_softmmu="$libs_softmmu $fdt_libs"
3513 ##########################################
3514 # opengl probe (for sdl2, gtk, milkymist-tmu2)
3516 if test "$opengl" != "no" ; then
3517 opengl_pkgs="epoxy libdrm gbm"
3518 if $pkg_config $opengl_pkgs x11; then
3519 opengl_cflags="$($pkg_config --cflags $opengl_pkgs) $x11_cflags"
3520 opengl_libs="$($pkg_config --libs $opengl_pkgs) $x11_libs"
3521 opengl=yes
3522 if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
3523 gtk_gl="yes"
3525 QEMU_CFLAGS="$QEMU_CFLAGS $opengl_cflags"
3526 else
3527 if test "$opengl" = "yes" ; then
3528 feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
3530 opengl_cflags=""
3531 opengl_libs=""
3532 opengl=no
3536 if test "$opengl" = "yes"; then
3537 cat > $TMPC << EOF
3538 #include <epoxy/egl.h>
3539 #ifndef EGL_MESA_image_dma_buf_export
3540 # error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
3541 #endif
3542 int main(void) { return 0; }
3544 if compile_prog "" "" ; then
3545 opengl_dmabuf=yes
3550 ##########################################
3551 # glusterfs probe
3552 if test "$glusterfs" != "no" ; then
3553 if $pkg_config --atleast-version=3 glusterfs-api; then
3554 glusterfs="yes"
3555 glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
3556 glusterfs_libs=$($pkg_config --libs glusterfs-api)
3557 if $pkg_config --atleast-version=4 glusterfs-api; then
3558 glusterfs_xlator_opt="yes"
3560 if $pkg_config --atleast-version=5 glusterfs-api; then
3561 glusterfs_discard="yes"
3563 if $pkg_config --atleast-version=6 glusterfs-api; then
3564 glusterfs_zerofill="yes"
3566 else
3567 if test "$glusterfs" = "yes" ; then
3568 feature_not_found "GlusterFS backend support" \
3569 "Install glusterfs-api devel >= 3"
3571 glusterfs="no"
3575 # Check for inotify functions when we are building linux-user
3576 # emulator. This is done because older glibc versions don't
3577 # have syscall stubs for these implemented. In that case we
3578 # don't provide them even if kernel supports them.
3580 inotify=no
3581 cat > $TMPC << EOF
3582 #include <sys/inotify.h>
3585 main(void)
3587 /* try to start inotify */
3588 return inotify_init();
3591 if compile_prog "" "" ; then
3592 inotify=yes
3595 inotify1=no
3596 cat > $TMPC << EOF
3597 #include <sys/inotify.h>
3600 main(void)
3602 /* try to start inotify */
3603 return inotify_init1(0);
3606 if compile_prog "" "" ; then
3607 inotify1=yes
3610 # check if utimensat and futimens are supported
3611 utimens=no
3612 cat > $TMPC << EOF
3613 #define _ATFILE_SOURCE
3614 #include <stddef.h>
3615 #include <fcntl.h>
3616 #include <sys/stat.h>
3618 int main(void)
3620 utimensat(AT_FDCWD, "foo", NULL, 0);
3621 futimens(0, NULL);
3622 return 0;
3625 if compile_prog "" "" ; then
3626 utimens=yes
3629 # check if pipe2 is there
3630 pipe2=no
3631 cat > $TMPC << EOF
3632 #include <unistd.h>
3633 #include <fcntl.h>
3635 int main(void)
3637 int pipefd[2];
3638 return pipe2(pipefd, O_CLOEXEC);
3641 if compile_prog "" "" ; then
3642 pipe2=yes
3645 # check if accept4 is there
3646 accept4=no
3647 cat > $TMPC << EOF
3648 #include <sys/socket.h>
3649 #include <stddef.h>
3651 int main(void)
3653 accept4(0, NULL, NULL, SOCK_CLOEXEC);
3654 return 0;
3657 if compile_prog "" "" ; then
3658 accept4=yes
3661 # check if tee/splice is there. vmsplice was added same time.
3662 splice=no
3663 cat > $TMPC << EOF
3664 #include <unistd.h>
3665 #include <fcntl.h>
3666 #include <limits.h>
3668 int main(void)
3670 int len, fd = 0;
3671 len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
3672 splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
3673 return 0;
3676 if compile_prog "" "" ; then
3677 splice=yes
3680 ##########################################
3681 # libnuma probe
3683 if test "$numa" != "no" ; then
3684 cat > $TMPC << EOF
3685 #include <numa.h>
3686 int main(void) { return numa_available(); }
3689 if compile_prog "" "-lnuma" ; then
3690 numa=yes
3691 libs_softmmu="-lnuma $libs_softmmu"
3692 else
3693 if test "$numa" = "yes" ; then
3694 feature_not_found "numa" "install numactl devel"
3696 numa=no
3700 if test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
3701 echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
3702 exit 1
3705 ##########################################
3706 # tcmalloc probe
3708 if test "$tcmalloc" = "yes" ; then
3709 cat > $TMPC << EOF
3710 #include <stdlib.h>
3711 int main(void) { malloc(1); return 0; }
3714 if compile_prog "" "-ltcmalloc" ; then
3715 LIBS="-ltcmalloc $LIBS"
3716 else
3717 feature_not_found "tcmalloc" "install gperftools devel"
3721 ##########################################
3722 # jemalloc probe
3724 if test "$jemalloc" = "yes" ; then
3725 cat > $TMPC << EOF
3726 #include <stdlib.h>
3727 int main(void) { malloc(1); return 0; }
3730 if compile_prog "" "-ljemalloc" ; then
3731 LIBS="-ljemalloc $LIBS"
3732 else
3733 feature_not_found "jemalloc" "install jemalloc devel"
3737 ##########################################
3738 # signalfd probe
3739 signalfd="no"
3740 cat > $TMPC << EOF
3741 #include <unistd.h>
3742 #include <sys/syscall.h>
3743 #include <signal.h>
3744 int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
3747 if compile_prog "" "" ; then
3748 signalfd=yes
3751 # check if eventfd is supported
3752 eventfd=no
3753 cat > $TMPC << EOF
3754 #include <sys/eventfd.h>
3756 int main(void)
3758 return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
3761 if compile_prog "" "" ; then
3762 eventfd=yes
3765 # check if memfd is supported
3766 memfd=no
3767 cat > $TMPC << EOF
3768 #include <sys/memfd.h>
3770 int main(void)
3772 return memfd_create("foo", MFD_ALLOW_SEALING);
3775 if compile_prog "" "" ; then
3776 memfd=yes
3781 # check for fallocate
3782 fallocate=no
3783 cat > $TMPC << EOF
3784 #include <fcntl.h>
3786 int main(void)
3788 fallocate(0, 0, 0, 0);
3789 return 0;
3792 if compile_prog "" "" ; then
3793 fallocate=yes
3796 # check for fallocate hole punching
3797 fallocate_punch_hole=no
3798 cat > $TMPC << EOF
3799 #include <fcntl.h>
3800 #include <linux/falloc.h>
3802 int main(void)
3804 fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
3805 return 0;
3808 if compile_prog "" "" ; then
3809 fallocate_punch_hole=yes
3812 # check that fallocate supports range zeroing inside the file
3813 fallocate_zero_range=no
3814 cat > $TMPC << EOF
3815 #include <fcntl.h>
3816 #include <linux/falloc.h>
3818 int main(void)
3820 fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
3821 return 0;
3824 if compile_prog "" "" ; then
3825 fallocate_zero_range=yes
3828 # check for posix_fallocate
3829 posix_fallocate=no
3830 cat > $TMPC << EOF
3831 #include <fcntl.h>
3833 int main(void)
3835 posix_fallocate(0, 0, 0);
3836 return 0;
3839 if compile_prog "" "" ; then
3840 posix_fallocate=yes
3843 # check for sync_file_range
3844 sync_file_range=no
3845 cat > $TMPC << EOF
3846 #include <fcntl.h>
3848 int main(void)
3850 sync_file_range(0, 0, 0, 0);
3851 return 0;
3854 if compile_prog "" "" ; then
3855 sync_file_range=yes
3858 # check for linux/fiemap.h and FS_IOC_FIEMAP
3859 fiemap=no
3860 cat > $TMPC << EOF
3861 #include <sys/ioctl.h>
3862 #include <linux/fs.h>
3863 #include <linux/fiemap.h>
3865 int main(void)
3867 ioctl(0, FS_IOC_FIEMAP, 0);
3868 return 0;
3871 if compile_prog "" "" ; then
3872 fiemap=yes
3875 # check for dup3
3876 dup3=no
3877 cat > $TMPC << EOF
3878 #include <unistd.h>
3880 int main(void)
3882 dup3(0, 0, 0);
3883 return 0;
3886 if compile_prog "" "" ; then
3887 dup3=yes
3890 # check for ppoll support
3891 ppoll=no
3892 cat > $TMPC << EOF
3893 #include <poll.h>
3895 int main(void)
3897 struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
3898 ppoll(&pfd, 1, 0, 0);
3899 return 0;
3902 if compile_prog "" "" ; then
3903 ppoll=yes
3906 # check for prctl(PR_SET_TIMERSLACK , ... ) support
3907 prctl_pr_set_timerslack=no
3908 cat > $TMPC << EOF
3909 #include <sys/prctl.h>
3911 int main(void)
3913 prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
3914 return 0;
3917 if compile_prog "" "" ; then
3918 prctl_pr_set_timerslack=yes
3921 # check for epoll support
3922 epoll=no
3923 cat > $TMPC << EOF
3924 #include <sys/epoll.h>
3926 int main(void)
3928 epoll_create(0);
3929 return 0;
3932 if compile_prog "" "" ; then
3933 epoll=yes
3936 # epoll_create1 is a later addition
3937 # so we must check separately for its presence
3938 epoll_create1=no
3939 cat > $TMPC << EOF
3940 #include <sys/epoll.h>
3942 int main(void)
3944 /* Note that we use epoll_create1 as a value, not as
3945 * a function being called. This is necessary so that on
3946 * old SPARC glibc versions where the function was present in
3947 * the library but not declared in the header file we will
3948 * fail the configure check. (Otherwise we will get a compiler
3949 * warning but not an error, and will proceed to fail the
3950 * qemu compile where we compile with -Werror.)
3952 return (int)(uintptr_t)&epoll_create1;
3955 if compile_prog "" "" ; then
3956 epoll_create1=yes
3959 # check for sendfile support
3960 sendfile=no
3961 cat > $TMPC << EOF
3962 #include <sys/sendfile.h>
3964 int main(void)
3966 return sendfile(0, 0, 0, 0);
3969 if compile_prog "" "" ; then
3970 sendfile=yes
3973 # check for timerfd support (glibc 2.8 and newer)
3974 timerfd=no
3975 cat > $TMPC << EOF
3976 #include <sys/timerfd.h>
3978 int main(void)
3980 return(timerfd_create(CLOCK_REALTIME, 0));
3983 if compile_prog "" "" ; then
3984 timerfd=yes
3987 # check for setns and unshare support
3988 setns=no
3989 cat > $TMPC << EOF
3990 #include <sched.h>
3992 int main(void)
3994 int ret;
3995 ret = setns(0, 0);
3996 ret = unshare(0);
3997 return ret;
4000 if compile_prog "" "" ; then
4001 setns=yes
4004 # clock_adjtime probe
4005 clock_adjtime=no
4006 cat > $TMPC <<EOF
4007 #include <time.h>
4009 int main(void)
4011 return clock_adjtime(0, 0);
4014 clock_adjtime=no
4015 if compile_prog "" "" ; then
4016 clock_adjtime=yes
4019 # syncfs probe
4020 syncfs=no
4021 cat > $TMPC <<EOF
4022 #include <unistd.h>
4024 int main(void)
4026 return syncfs(0);
4029 syncfs=no
4030 if compile_prog "" "" ; then
4031 syncfs=yes
4034 # Check if tools are available to build documentation.
4035 if test "$docs" != "no" ; then
4036 if has makeinfo && has pod2man; then
4037 docs=yes
4038 else
4039 if test "$docs" = "yes" ; then
4040 feature_not_found "docs" "Install texinfo and Perl/perl-podlators"
4042 docs=no
4046 if test "$want_tools" = ""; then
4047 if test $(expr "$target_list" : ".*softmmu.*") != 0; then
4048 want_tools=yes
4049 else
4050 want_tools=no
4054 # Search for bswap_32 function
4055 byteswap_h=no
4056 cat > $TMPC << EOF
4057 #include <byteswap.h>
4058 int main(void) { return bswap_32(0); }
4060 if compile_prog "" "" ; then
4061 byteswap_h=yes
4064 # Search for bswap32 function
4065 bswap_h=no
4066 cat > $TMPC << EOF
4067 #include <sys/endian.h>
4068 #include <sys/types.h>
4069 #include <machine/bswap.h>
4070 int main(void) { return bswap32(0); }
4072 if compile_prog "" "" ; then
4073 bswap_h=yes
4076 ##########################################
4077 # Do we have libiscsi >= 1.9.0
4078 if test "$libiscsi" != "no" ; then
4079 if $pkg_config --atleast-version=1.9.0 libiscsi; then
4080 libiscsi="yes"
4081 libiscsi_cflags=$($pkg_config --cflags libiscsi)
4082 libiscsi_libs=$($pkg_config --libs libiscsi)
4083 else
4084 if test "$libiscsi" = "yes" ; then
4085 feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
4087 libiscsi="no"
4091 ##########################################
4092 # Do we need libm
4093 cat > $TMPC << EOF
4094 #include <math.h>
4095 int main(int argc, char **argv) { return isnan(sin((double)argc)); }
4097 if compile_prog "" "" ; then
4099 elif compile_prog "" "-lm" ; then
4100 LIBS="-lm $LIBS"
4101 libs_qga="-lm $libs_qga"
4102 else
4103 error_exit "libm check failed"
4106 ##########################################
4107 # Do we need librt
4108 # uClibc provides 2 versions of clock_gettime(), one with realtime
4109 # support and one without. This means that the clock_gettime() don't
4110 # need -lrt. We still need it for timer_create() so we check for this
4111 # function in addition.
4112 cat > $TMPC <<EOF
4113 #include <signal.h>
4114 #include <time.h>
4115 int main(void) {
4116 timer_create(CLOCK_REALTIME, NULL, NULL);
4117 return clock_gettime(CLOCK_REALTIME, NULL);
4121 if compile_prog "" "" ; then
4123 # we need pthread for static linking. use previous pthread test result
4124 elif compile_prog "" "$pthread_lib -lrt" ; then
4125 LIBS="$LIBS -lrt"
4126 libs_qga="$libs_qga -lrt"
4129 if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
4130 "$aix" != "yes" -a "$haiku" != "yes" ; then
4131 libs_softmmu="-lutil $libs_softmmu"
4134 ##########################################
4135 # spice probe
4136 if test "$spice" != "no" ; then
4137 cat > $TMPC << EOF
4138 #include <spice.h>
4139 int main(void) { spice_server_new(); return 0; }
4141 spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
4142 spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
4143 if $pkg_config --atleast-version=0.12.0 spice-server && \
4144 $pkg_config --atleast-version=0.12.3 spice-protocol && \
4145 compile_prog "$spice_cflags" "$spice_libs" ; then
4146 spice="yes"
4147 libs_softmmu="$libs_softmmu $spice_libs"
4148 QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
4149 spice_protocol_version=$($pkg_config --modversion spice-protocol)
4150 spice_server_version=$($pkg_config --modversion spice-server)
4151 else
4152 if test "$spice" = "yes" ; then
4153 feature_not_found "spice" \
4154 "Install spice-server(>=0.12.0) and spice-protocol(>=0.12.3) devel"
4156 spice="no"
4160 # check for smartcard support
4161 smartcard_cflags=""
4162 if test "$smartcard" != "no"; then
4163 if $pkg_config libcacard; then
4164 libcacard_cflags=$($pkg_config --cflags libcacard)
4165 libcacard_libs=$($pkg_config --libs libcacard)
4166 QEMU_CFLAGS="$QEMU_CFLAGS $libcacard_cflags"
4167 libs_softmmu="$libs_softmmu $libcacard_libs"
4168 smartcard="yes"
4169 else
4170 if test "$smartcard" = "yes"; then
4171 feature_not_found "smartcard" "Install libcacard devel"
4173 smartcard="no"
4177 # check for libusb
4178 if test "$libusb" != "no" ; then
4179 if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
4180 libusb="yes"
4181 libusb_cflags=$($pkg_config --cflags libusb-1.0)
4182 libusb_libs=$($pkg_config --libs libusb-1.0)
4183 QEMU_CFLAGS="$QEMU_CFLAGS $libusb_cflags"
4184 libs_softmmu="$libs_softmmu $libusb_libs"
4185 else
4186 if test "$libusb" = "yes"; then
4187 feature_not_found "libusb" "Install libusb devel >= 1.0.13"
4189 libusb="no"
4193 # check for usbredirparser for usb network redirection support
4194 if test "$usb_redir" != "no" ; then
4195 if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
4196 usb_redir="yes"
4197 usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
4198 usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
4199 QEMU_CFLAGS="$QEMU_CFLAGS $usb_redir_cflags"
4200 libs_softmmu="$libs_softmmu $usb_redir_libs"
4201 else
4202 if test "$usb_redir" = "yes"; then
4203 feature_not_found "usb-redir" "Install usbredir devel"
4205 usb_redir="no"
4209 ##########################################
4210 # check if we have VSS SDK headers for win
4212 if test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$vss_win32_sdk" != "no" ; then
4213 case "$vss_win32_sdk" in
4214 "") vss_win32_include="-isystem $source_path" ;;
4215 *\ *) # The SDK is installed in "Program Files" by default, but we cannot
4216 # handle path with spaces. So we symlink the headers into ".sdk/vss".
4217 vss_win32_include="-isystem $source_path/.sdk/vss"
4218 symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
4220 *) vss_win32_include="-isystem $vss_win32_sdk"
4221 esac
4222 cat > $TMPC << EOF
4223 #define __MIDL_user_allocate_free_DEFINED__
4224 #include <inc/win2003/vss.h>
4225 int main(void) { return VSS_CTX_BACKUP; }
4227 if compile_prog "$vss_win32_include" "" ; then
4228 guest_agent_with_vss="yes"
4229 QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
4230 libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
4231 qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
4232 else
4233 if test "$vss_win32_sdk" != "" ; then
4234 echo "ERROR: Please download and install Microsoft VSS SDK:"
4235 echo "ERROR: http://www.microsoft.com/en-us/download/details.aspx?id=23490"
4236 echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
4237 echo "ERROR: scripts/extract-vsssdk-headers setup.exe"
4238 echo "ERROR: The headers are extracted in the directory \`inc'."
4239 feature_not_found "VSS support"
4241 guest_agent_with_vss="no"
4245 ##########################################
4246 # lookup Windows platform SDK (if not specified)
4247 # The SDK is needed only to build .tlb (type library) file of guest agent
4248 # VSS provider from the source. It is usually unnecessary because the
4249 # pre-compiled .tlb file is included.
4251 if test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$guest_agent_with_vss" = "yes" ; then
4252 if test -z "$win_sdk"; then
4253 programfiles="$PROGRAMFILES"
4254 test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
4255 if test -n "$programfiles"; then
4256 win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
4257 else
4258 feature_not_found "Windows SDK"
4260 elif test "$win_sdk" = "no"; then
4261 win_sdk=""
4265 ##########################################
4266 # check if mingw environment provides a recent ntddscsi.h
4267 if test "$mingw32" = "yes" -a "$guest_agent" != "no"; then
4268 cat > $TMPC << EOF
4269 #include <windows.h>
4270 #include <ntddscsi.h>
4271 int main(void) {
4272 #if !defined(IOCTL_SCSI_GET_ADDRESS)
4273 #error Missing required ioctl definitions
4274 #endif
4275 SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
4276 return addr.Lun;
4279 if compile_prog "" "" ; then
4280 guest_agent_ntddscsi=yes
4281 libs_qga="-lsetupapi $libs_qga"
4285 ##########################################
4286 # virgl renderer probe
4288 if test "$virglrenderer" != "no" ; then
4289 cat > $TMPC << EOF
4290 #include <virglrenderer.h>
4291 int main(void) { virgl_renderer_poll(); return 0; }
4293 virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
4294 virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
4295 if $pkg_config virglrenderer >/dev/null 2>&1 && \
4296 compile_prog "$virgl_cflags" "$virgl_libs" ; then
4297 virglrenderer="yes"
4298 else
4299 if test "$virglrenderer" = "yes" ; then
4300 feature_not_found "virglrenderer"
4302 virglrenderer="no"
4306 ##########################################
4307 # check if we have fdatasync
4309 fdatasync=no
4310 cat > $TMPC << EOF
4311 #include <unistd.h>
4312 int main(void) {
4313 #if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
4314 return fdatasync(0);
4315 #else
4316 #error Not supported
4317 #endif
4320 if compile_prog "" "" ; then
4321 fdatasync=yes
4324 ##########################################
4325 # check if we have madvise
4327 madvise=no
4328 cat > $TMPC << EOF
4329 #include <sys/types.h>
4330 #include <sys/mman.h>
4331 #include <stddef.h>
4332 int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
4334 if compile_prog "" "" ; then
4335 madvise=yes
4338 ##########################################
4339 # check if we have posix_madvise
4341 posix_madvise=no
4342 cat > $TMPC << EOF
4343 #include <sys/mman.h>
4344 #include <stddef.h>
4345 int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
4347 if compile_prog "" "" ; then
4348 posix_madvise=yes
4351 ##########################################
4352 # check if we have posix_syslog
4354 posix_syslog=no
4355 cat > $TMPC << EOF
4356 #include <syslog.h>
4357 int main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
4359 if compile_prog "" "" ; then
4360 posix_syslog=yes
4363 ##########################################
4364 # check if trace backend exists
4366 $python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends > /dev/null 2> /dev/null
4367 if test "$?" -ne 0 ; then
4368 error_exit "invalid trace backends" \
4369 "Please choose supported trace backends."
4372 ##########################################
4373 # For 'ust' backend, test if ust headers are present
4374 if have_backend "ust"; then
4375 cat > $TMPC << EOF
4376 #include <lttng/tracepoint.h>
4377 int main(void) { return 0; }
4379 if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
4380 if $pkg_config lttng-ust --exists; then
4381 lttng_ust_libs=$($pkg_config --libs lttng-ust)
4382 else
4383 lttng_ust_libs="-llttng-ust -ldl"
4385 if $pkg_config liburcu-bp --exists; then
4386 urcu_bp_libs=$($pkg_config --libs liburcu-bp)
4387 else
4388 urcu_bp_libs="-lurcu-bp"
4391 LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
4392 libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
4393 else
4394 error_exit "Trace backend 'ust' missing lttng-ust header files"
4398 ##########################################
4399 # For 'dtrace' backend, test if 'dtrace' command is present
4400 if have_backend "dtrace"; then
4401 if ! has 'dtrace' ; then
4402 error_exit "dtrace command is not found in PATH $PATH"
4404 trace_backend_stap="no"
4405 if has 'stap' ; then
4406 trace_backend_stap="yes"
4410 ##########################################
4411 # check and set a backend for coroutine
4413 # We prefer ucontext, but it's not always possible. The fallback
4414 # is sigcontext. gthread is not selectable except explicitly, because
4415 # it is not functional enough to run QEMU proper. (It is occasionally
4416 # useful for debugging purposes.) On Windows the only valid backend
4417 # is the Windows-specific one.
4419 ucontext_works=no
4420 if test "$darwin" != "yes"; then
4421 cat > $TMPC << EOF
4422 #include <ucontext.h>
4423 #ifdef __stub_makecontext
4424 #error Ignoring glibc stub makecontext which will always fail
4425 #endif
4426 int main(void) { makecontext(0, 0, 0); return 0; }
4428 if compile_prog "" "" ; then
4429 ucontext_works=yes
4433 if test "$coroutine" = ""; then
4434 if test "$mingw32" = "yes"; then
4435 coroutine=win32
4436 elif test "$ucontext_works" = "yes"; then
4437 coroutine=ucontext
4438 else
4439 coroutine=sigaltstack
4441 else
4442 case $coroutine in
4443 windows)
4444 if test "$mingw32" != "yes"; then
4445 error_exit "'windows' coroutine backend only valid for Windows"
4447 # Unfortunately the user visible backend name doesn't match the
4448 # coroutine-*.c filename for this case, so we have to adjust it here.
4449 coroutine=win32
4451 ucontext)
4452 if test "$ucontext_works" != "yes"; then
4453 feature_not_found "ucontext"
4456 gthread|sigaltstack)
4457 if test "$mingw32" = "yes"; then
4458 error_exit "only the 'windows' coroutine backend is valid for Windows"
4462 error_exit "unknown coroutine backend $coroutine"
4464 esac
4467 if test "$coroutine_pool" = ""; then
4468 if test "$coroutine" = "gthread" -o "$coroutine" = "win32"; then
4469 coroutine_pool=no
4470 else
4471 coroutine_pool=yes
4474 if test "$coroutine" = "gthread" -a "$coroutine_pool" = "yes"; then
4475 error_exit "'gthread' coroutine backend does not support pool (use --disable-coroutine-pool)"
4478 if test "$debug_stack_usage" = "yes"; then
4479 if test "$cpu" = "ia64" -o "$cpu" = "hppa"; then
4480 error_exit "stack usage debugging is not supported for $cpu"
4482 if test "$coroutine_pool" = "yes"; then
4483 echo "WARN: disabling coroutine pool for stack usage debugging"
4484 coroutine_pool=no
4489 ##########################################
4490 # check if we have open_by_handle_at
4492 open_by_handle_at=no
4493 cat > $TMPC << EOF
4494 #include <fcntl.h>
4495 #if !defined(AT_EMPTY_PATH)
4496 # error missing definition
4497 #else
4498 int main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
4499 #endif
4501 if compile_prog "" "" ; then
4502 open_by_handle_at=yes
4505 ########################################
4506 # check if we have linux/magic.h
4508 linux_magic_h=no
4509 cat > $TMPC << EOF
4510 #include <linux/magic.h>
4511 int main(void) {
4512 return 0;
4515 if compile_prog "" "" ; then
4516 linux_magic_h=yes
4519 ########################################
4520 # check whether we can disable warning option with a pragma (this is needed
4521 # to silence warnings in the headers of some versions of external libraries).
4522 # This test has to be compiled with -Werror as otherwise an unknown pragma is
4523 # only a warning.
4525 # If we can't selectively disable warning in the code, disable -Werror so that
4526 # the build doesn't fail anyway.
4528 pragma_disable_unused_but_set=no
4529 cat > $TMPC << EOF
4530 #pragma GCC diagnostic push
4531 #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
4532 #pragma GCC diagnostic ignored "-Wstrict-prototypes"
4533 #pragma GCC diagnostic pop
4535 int main(void) {
4536 return 0;
4539 if compile_prog "-Werror" "" ; then
4540 pragma_diagnostic_available=yes
4543 ########################################
4544 # check if we have valgrind/valgrind.h
4546 valgrind_h=no
4547 cat > $TMPC << EOF
4548 #include <valgrind/valgrind.h>
4549 int main(void) {
4550 return 0;
4553 if compile_prog "" "" ; then
4554 valgrind_h=yes
4557 ########################################
4558 # check if environ is declared
4560 has_environ=no
4561 cat > $TMPC << EOF
4562 #include <unistd.h>
4563 int main(void) {
4564 environ = 0;
4565 return 0;
4568 if compile_prog "" "" ; then
4569 has_environ=yes
4572 ########################################
4573 # check if cpuid.h is usable.
4575 cpuid_h=no
4576 cat > $TMPC << EOF
4577 #include <cpuid.h>
4578 int main(void) {
4579 unsigned a, b, c, d;
4580 int max = __get_cpuid_max(0, 0);
4582 if (max >= 1) {
4583 __cpuid(1, a, b, c, d);
4586 if (max >= 7) {
4587 __cpuid_count(7, 0, a, b, c, d);
4590 return 0;
4593 if compile_prog "" "" ; then
4594 cpuid_h=yes
4597 ########################################
4598 # check if __[u]int128_t is usable.
4600 int128=no
4601 cat > $TMPC << EOF
4602 #if defined(__clang_major__) && defined(__clang_minor__)
4603 # if ((__clang_major__ < 3) || (__clang_major__ == 3) && (__clang_minor__ < 2))
4604 # error __int128_t does not work in CLANG before 3.2
4605 # endif
4606 #endif
4607 __int128_t a;
4608 __uint128_t b;
4609 int main (void) {
4610 a = a + b;
4611 b = a * b;
4612 a = a * a;
4613 return 0;
4616 if compile_prog "" "" ; then
4617 int128=yes
4620 #########################################
4621 # See if 128-bit atomic operations are supported.
4623 atomic128=no
4624 if test "$int128" = "yes"; then
4625 cat > $TMPC << EOF
4626 int main(void)
4628 unsigned __int128 x = 0, y = 0;
4629 y = __atomic_load_16(&x, 0);
4630 __atomic_store_16(&x, y, 0);
4631 __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
4632 return 0;
4635 if compile_prog "" "" ; then
4636 atomic128=yes
4640 #########################################
4641 # See if 64-bit atomic operations are supported.
4642 # Note that without __atomic builtins, we can only
4643 # assume atomic loads/stores max at pointer size.
4645 cat > $TMPC << EOF
4646 #include <stdint.h>
4647 int main(void)
4649 uint64_t x = 0, y = 0;
4650 #ifdef __ATOMIC_RELAXED
4651 y = __atomic_load_8(&x, 0);
4652 __atomic_store_8(&x, y, 0);
4653 __atomic_compare_exchange_8(&x, &y, x, 0, 0, 0);
4654 __atomic_exchange_8(&x, y, 0);
4655 __atomic_fetch_add_8(&x, y, 0);
4656 #else
4657 typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
4658 __sync_lock_test_and_set(&x, y);
4659 __sync_val_compare_and_swap(&x, y, 0);
4660 __sync_fetch_and_add(&x, y);
4661 #endif
4662 return 0;
4665 if compile_prog "" "" ; then
4666 atomic64=yes
4669 ########################################
4670 # check if getauxval is available.
4672 getauxval=no
4673 cat > $TMPC << EOF
4674 #include <sys/auxv.h>
4675 int main(void) {
4676 return getauxval(AT_HWCAP) == 0;
4679 if compile_prog "" "" ; then
4680 getauxval=yes
4683 ########################################
4684 # check if ccache is interfering with
4685 # semantic analysis of macros
4687 unset CCACHE_CPP2
4688 ccache_cpp2=no
4689 cat > $TMPC << EOF
4690 static const int Z = 1;
4691 #define fn() ({ Z; })
4692 #define TAUT(X) ((X) == Z)
4693 #define PAREN(X, Y) (X == Y)
4694 #define ID(X) (X)
4695 int main(int argc, char *argv[])
4697 int x = 0, y = 0;
4698 x = ID(x);
4699 x = fn();
4700 fn();
4701 if (PAREN(x, y)) return 0;
4702 if (TAUT(Z)) return 0;
4703 return 0;
4707 if ! compile_object "-Werror"; then
4708 ccache_cpp2=yes
4711 #################################################
4712 # clang does not support glibc + FORTIFY_SOURCE.
4714 if test "$fortify_source" != "no"; then
4715 if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
4716 fortify_source="no";
4717 elif test -n "$cxx" &&
4718 echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
4719 fortify_source="no";
4720 else
4721 fortify_source="yes"
4725 ##########################################
4726 # check if struct fsxattr is available via linux/fs.h
4728 have_fsxattr=no
4729 cat > $TMPC << EOF
4730 #include <linux/fs.h>
4731 struct fsxattr foo;
4732 int main(void) {
4733 return 0;
4736 if compile_prog "" "" ; then
4737 have_fsxattr=yes
4740 ##########################################
4741 # check if rtnetlink.h exists and is useful
4742 have_rtnetlink=no
4743 cat > $TMPC << EOF
4744 #include <linux/rtnetlink.h>
4745 int main(void) {
4746 return IFLA_PROTO_DOWN;
4749 if compile_prog "" "" ; then
4750 have_rtnetlink=yes
4753 ##########################################
4754 # check for usable AF_VSOCK environment
4755 have_af_vsock=no
4756 cat > $TMPC << EOF
4757 #include <errno.h>
4758 #include <sys/types.h>
4759 #include <sys/socket.h>
4760 #if !defined(AF_VSOCK)
4761 # error missing AF_VSOCK flag
4762 #endif
4763 #include <linux/vm_sockets.h>
4764 int main(void) {
4765 int sock, ret;
4766 struct sockaddr_vm svm;
4767 socklen_t len = sizeof(svm);
4768 sock = socket(AF_VSOCK, SOCK_STREAM, 0);
4769 ret = getpeername(sock, (struct sockaddr *)&svm, &len);
4770 if ((ret == -1) && (errno == ENOTCONN)) {
4771 return 0;
4773 return -1;
4776 if compile_prog "" "" ; then
4777 have_af_vsock=yes
4780 #################################################
4781 # Sparc implicitly links with --relax, which is
4782 # incompatible with -r, so --no-relax should be
4783 # given. It does no harm to give it on other
4784 # platforms too.
4786 # Note: the prototype is needed since QEMU_CFLAGS
4787 # contains -Wmissing-prototypes
4788 cat > $TMPC << EOF
4789 extern int foo(void);
4790 int foo(void) { return 0; }
4792 if ! compile_object ""; then
4793 error_exit "Failed to compile object file for LD_REL_FLAGS test"
4795 for i in '-Wl,-r -Wl,--no-relax' -Wl,-r -r; do
4796 if do_cc -nostdlib $i -o $TMPMO $TMPO; then
4797 LD_REL_FLAGS=$i
4798 break
4800 done
4801 if test "$modules" = "yes" && test "$LD_REL_FLAGS" = ""; then
4802 feature_not_found "modules" "Cannot find how to build relocatable objects"
4805 ##########################################
4806 # check for sysmacros.h
4808 have_sysmacros=no
4809 cat > $TMPC << EOF
4810 #include <sys/sysmacros.h>
4811 int main(void) {
4812 return makedev(0, 0);
4815 if compile_prog "" "" ; then
4816 have_sysmacros=yes
4819 ##########################################
4820 # End of CC checks
4821 # After here, no more $cc or $ld runs
4823 if test "$gcov" = "yes" ; then
4824 CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
4825 LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
4826 elif test "$fortify_source" = "yes" ; then
4827 CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
4828 elif test "$debug" = "no"; then
4829 CFLAGS="-O2 $CFLAGS"
4832 ##########################################
4833 # Do we have libnfs
4834 if test "$libnfs" != "no" ; then
4835 if $pkg_config --atleast-version=1.9.3 libnfs; then
4836 libnfs="yes"
4837 libnfs_libs=$($pkg_config --libs libnfs)
4838 else
4839 if test "$libnfs" = "yes" ; then
4840 feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
4842 libnfs="no"
4846 # Now we've finished running tests it's OK to add -Werror to the compiler flags
4847 if test "$werror" = "yes"; then
4848 QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
4851 if test "$solaris" = "no" ; then
4852 if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
4853 LDFLAGS="-Wl,--warn-common $LDFLAGS"
4857 # test if pod2man has --utf8 option
4858 if pod2man --help | grep -q utf8; then
4859 POD2MAN="pod2man --utf8"
4860 else
4861 POD2MAN="pod2man"
4864 # Use large addresses, ASLR, no-SEH and DEP if available.
4865 if test "$mingw32" = "yes" ; then
4866 if test "$cpu" = i386; then
4867 LDFLAGS="-Wl,--large-address-aware $LDFLAGS"
4869 for flag in --dynamicbase --no-seh --nxcompat; do
4870 if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
4871 LDFLAGS="-Wl,$flag $LDFLAGS"
4873 done
4876 qemu_confdir=$sysconfdir$confsuffix
4877 qemu_moddir=$libdir$confsuffix
4878 qemu_datadir=$datadir$confsuffix
4879 qemu_localedir="$datadir/locale"
4881 tools=""
4882 tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
4883 if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
4884 tools="qemu-nbd\$(EXESUF) $tools"
4885 tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools"
4887 if test "$softmmu" = yes ; then
4888 if test "$virtfs" != no ; then
4889 if test "$cap" = yes && test "$linux" = yes && test "$attr" = yes ; then
4890 virtfs=yes
4891 tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
4892 else
4893 if test "$virtfs" = yes; then
4894 error_exit "VirtFS is supported only on Linux and requires libcap devel and libattr devel"
4896 virtfs=no
4901 # Probe for guest agent support/options
4903 if [ "$guest_agent" != "no" ]; then
4904 if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
4905 tools="qemu-ga $tools"
4906 guest_agent=yes
4907 elif [ "$guest_agent" != yes ]; then
4908 guest_agent=no
4909 else
4910 error_exit "Guest agent is not supported on this platform"
4914 # Guest agent Window MSI package
4916 if test "$guest_agent" != yes; then
4917 if test "$guest_agent_msi" = yes; then
4918 error_exit "MSI guest agent package requires guest agent enabled"
4920 guest_agent_msi=no
4921 elif test "$mingw32" != "yes"; then
4922 if test "$guest_agent_msi" = "yes"; then
4923 error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
4925 guest_agent_msi=no
4926 elif ! has wixl; then
4927 if test "$guest_agent_msi" = "yes"; then
4928 error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
4930 guest_agent_msi=no
4931 else
4932 # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
4933 # disabled explicitly
4934 if test "$guest_agent_msi" != "no"; then
4935 guest_agent_msi=yes
4939 if test "$guest_agent_msi" = "yes"; then
4940 if test "$guest_agent_with_vss" = "yes"; then
4941 QEMU_GA_MSI_WITH_VSS="-D InstallVss"
4944 if test "$QEMU_GA_MANUFACTURER" = ""; then
4945 QEMU_GA_MANUFACTURER=QEMU
4948 if test "$QEMU_GA_DISTRO" = ""; then
4949 QEMU_GA_DISTRO=Linux
4952 if test "$QEMU_GA_VERSION" = ""; then
4953 QEMU_GA_VERSION=$(cat $source_path/VERSION)
4956 QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
4958 case "$cpu" in
4959 x86_64)
4960 QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
4962 i386)
4963 QEMU_GA_MSI_ARCH="-D Arch=32"
4966 error_exit "CPU $cpu not supported for building installation package"
4968 esac
4971 # Mac OS X ships with a broken assembler
4972 roms=
4973 if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
4974 "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
4975 "$softmmu" = yes ; then
4976 # Different host OS linkers have different ideas about the name of the ELF
4977 # emulation. Linux and OpenBSD use 'elf_i386'; FreeBSD uses the _fbsd
4978 # variant; and Windows uses i386pe.
4979 for emu in elf_i386 elf_i386_fbsd i386pe; do
4980 if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
4981 ld_i386_emulation="$emu"
4982 roms="optionrom"
4983 break
4985 done
4987 if test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
4988 roms="$roms spapr-rtas"
4991 if test "$cpu" = "s390x" ; then
4992 roms="$roms s390-ccw"
4995 # Probe for the need for relocating the user-only binary.
4996 if ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) && [ "$pie" = no ]; then
4997 textseg_addr=
4998 case "$cpu" in
4999 arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
5000 # ??? Rationale for choosing this address
5001 textseg_addr=0x60000000
5003 mips)
5004 # A 256M aligned address, high in the address space, with enough
5005 # room for the code_gen_buffer above it before the stack.
5006 textseg_addr=0x60000000
5008 esac
5009 if [ -n "$textseg_addr" ]; then
5010 cat > $TMPC <<EOF
5011 int main(void) { return 0; }
5013 textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
5014 if ! compile_prog "" "$textseg_ldflags"; then
5015 # In case ld does not support -Ttext-segment, edit the default linker
5016 # script via sed to set the .text start addr. This is needed on FreeBSD
5017 # at least.
5018 if ! $ld --verbose >/dev/null 2>&1; then
5019 error_exit \
5020 "We need to link the QEMU user mode binaries at a" \
5021 "specific text address. Unfortunately your linker" \
5022 "doesn't support either the -Ttext-segment option or" \
5023 "printing the default linker script with --verbose." \
5024 "If you don't want the user mode binaries, pass the" \
5025 "--disable-user option to configure."
5028 $ld --verbose | sed \
5029 -e '1,/==================================================/d' \
5030 -e '/==================================================/,$d' \
5031 -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
5032 -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
5033 textseg_ldflags="-Wl,-T../config-host.ld"
5038 echo_version() {
5039 if test "$1" = "yes" ; then
5040 echo "($2)"
5044 # prepend pixman and ftd flags after all config tests are done
5045 QEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"
5046 libs_softmmu="$pixman_libs $libs_softmmu"
5048 echo "Install prefix $prefix"
5049 echo "BIOS directory $(eval echo $qemu_datadir)"
5050 echo "binary directory $(eval echo $bindir)"
5051 echo "library directory $(eval echo $libdir)"
5052 echo "module directory $(eval echo $qemu_moddir)"
5053 echo "libexec directory $(eval echo $libexecdir)"
5054 echo "include directory $(eval echo $includedir)"
5055 echo "config directory $(eval echo $sysconfdir)"
5056 if test "$mingw32" = "no" ; then
5057 echo "local state directory $(eval echo $local_statedir)"
5058 echo "Manual directory $(eval echo $mandir)"
5059 echo "ELF interp prefix $interp_prefix"
5060 else
5061 echo "local state directory queried at runtime"
5062 echo "Windows SDK $win_sdk"
5064 echo "Source path $source_path"
5065 echo "C compiler $cc"
5066 echo "Host C compiler $host_cc"
5067 echo "C++ compiler $cxx"
5068 echo "Objective-C compiler $objcc"
5069 echo "ARFLAGS $ARFLAGS"
5070 echo "CFLAGS $CFLAGS"
5071 echo "QEMU_CFLAGS $QEMU_CFLAGS"
5072 echo "LDFLAGS $LDFLAGS"
5073 echo "make $make"
5074 echo "install $install"
5075 echo "python $python"
5076 if test "$slirp" = "yes" ; then
5077 echo "smbd $smbd"
5079 echo "module support $modules"
5080 echo "host CPU $cpu"
5081 echo "host big endian $bigendian"
5082 echo "target list $target_list"
5083 echo "tcg debug enabled $debug_tcg"
5084 echo "gprof enabled $gprof"
5085 echo "sparse enabled $sparse"
5086 echo "strip binaries $strip_opt"
5087 echo "profiler $profiler"
5088 echo "static build $static"
5089 if test "$darwin" = "yes" ; then
5090 echo "Cocoa support $cocoa"
5092 echo "pixman $pixman"
5093 echo "SDL support $sdl $(echo_version $sdl $sdlversion)"
5094 echo "GTK support $gtk $(echo_version $gtk $gtk_version)"
5095 echo "GTK GL support $gtk_gl"
5096 echo "VTE support $vte $(echo_version $vte $vteversion)"
5097 echo "TLS priority $tls_priority"
5098 echo "GNUTLS support $gnutls"
5099 echo "GNUTLS rnd $gnutls_rnd"
5100 if test "$gcrypt" = "yes"; then
5101 echo "encryption libgcrypt"
5102 echo "libgcrypt kdf $gcrypt_kdf"
5103 elif test "$nettle" = "yes"; then
5104 echo "nettle $nettle $(echo_version $nettle $nettle_version)"
5105 else
5106 echo "encryption none"
5108 echo "nettle kdf $nettle_kdf"
5109 echo "libtasn1 $tasn1"
5110 echo "curses support $curses"
5111 echo "virgl support $virglrenderer"
5112 echo "curl support $curl"
5113 echo "mingw32 support $mingw32"
5114 echo "Audio drivers $audio_drv_list"
5115 echo "Block whitelist (rw) $block_drv_rw_whitelist"
5116 echo "Block whitelist (ro) $block_drv_ro_whitelist"
5117 echo "VirtFS support $virtfs"
5118 echo "VNC support $vnc"
5119 if test "$vnc" = "yes" ; then
5120 echo "VNC SASL support $vnc_sasl"
5121 echo "VNC JPEG support $vnc_jpeg"
5122 echo "VNC PNG support $vnc_png"
5124 if test -n "$sparc_cpu"; then
5125 echo "Target Sparc Arch $sparc_cpu"
5127 echo "xen support $xen"
5128 if test "$xen" = "yes" ; then
5129 echo "xen ctrl version $xen_ctrl_version"
5130 echo "pv dom build $xen_pv_domain_build"
5132 echo "brlapi support $brlapi"
5133 echo "bluez support $bluez"
5134 echo "Documentation $docs"
5135 echo "Tools $tools"
5136 echo "PIE $pie"
5137 echo "vde support $vde"
5138 echo "netmap support $netmap"
5139 echo "Linux AIO support $linux_aio"
5140 echo "(X)ATTR support $attr"
5141 echo "Install blobs $blobs"
5142 echo "KVM support $kvm"
5143 echo "HAX support $hax"
5144 echo "RDMA support $rdma"
5145 echo "TCG interpreter $tcg_interpreter"
5146 echo "fdt support $fdt"
5147 echo "preadv support $preadv"
5148 echo "fdatasync $fdatasync"
5149 echo "madvise $madvise"
5150 echo "posix_madvise $posix_madvise"
5151 echo "libcap-ng support $cap_ng"
5152 echo "vhost-net support $vhost_net"
5153 echo "vhost-scsi support $vhost_scsi"
5154 echo "vhost-vsock support $vhost_vsock"
5155 echo "Trace backends $trace_backends"
5156 if have_backend "simple"; then
5157 echo "Trace output file $trace_file-<pid>"
5159 echo "spice support $spice $(echo_version $spice $spice_protocol_version/$spice_server_version)"
5160 echo "rbd support $rbd"
5161 echo "xfsctl support $xfs"
5162 echo "smartcard support $smartcard"
5163 echo "libusb $libusb"
5164 echo "usb net redir $usb_redir"
5165 echo "OpenGL support $opengl"
5166 echo "OpenGL dmabufs $opengl_dmabuf"
5167 echo "libiscsi support $libiscsi"
5168 echo "libnfs support $libnfs"
5169 echo "build guest agent $guest_agent"
5170 echo "QGA VSS support $guest_agent_with_vss"
5171 echo "QGA w32 disk info $guest_agent_ntddscsi"
5172 echo "QGA MSI support $guest_agent_msi"
5173 echo "seccomp support $seccomp"
5174 echo "coroutine backend $coroutine"
5175 echo "coroutine pool $coroutine_pool"
5176 echo "debug stack usage $debug_stack_usage"
5177 echo "GlusterFS support $glusterfs"
5178 echo "gcov $gcov_tool"
5179 echo "gcov enabled $gcov"
5180 echo "TPM support $tpm"
5181 echo "libssh2 support $libssh2"
5182 echo "TPM passthrough $tpm_passthrough"
5183 echo "QOM debugging $qom_cast_debug"
5184 echo "lzo support $lzo"
5185 echo "snappy support $snappy"
5186 echo "bzip2 support $bzip2"
5187 echo "NUMA host support $numa"
5188 echo "tcmalloc support $tcmalloc"
5189 echo "jemalloc support $jemalloc"
5190 echo "avx2 optimization $avx2_opt"
5191 echo "replication support $replication"
5193 if test "$sdl_too_old" = "yes"; then
5194 echo "-> Your SDL version is too old - please upgrade to have SDL support"
5197 if test "$supported_cpu" = "no"; then
5198 echo
5199 echo "WARNING: SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!"
5200 echo
5201 echo "CPU host architecture $cpu support is not currently maintained."
5202 echo "The QEMU project intends to remove support for this host CPU in"
5203 echo "a future release if nobody volunteers to maintain it and to"
5204 echo "provide a build host for our continuous integration setup."
5205 echo "configure has succeeded and you can continue to build, but"
5206 echo "if you care about QEMU on this platform you should contact"
5207 echo "us upstream at qemu-devel@nongnu.org."
5210 if test "$supported_os" = "no"; then
5211 echo
5212 echo "WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!"
5213 echo
5214 echo "Host OS $targetos support is not currently maintained."
5215 echo "The QEMU project intends to remove support for this host OS in"
5216 echo "a future release if nobody volunteers to maintain it and to"
5217 echo "provide a build host for our continuous integration setup."
5218 echo "configure has succeeded and you can continue to build, but"
5219 echo "if you care about QEMU on this platform you should contact"
5220 echo "us upstream at qemu-devel@nongnu.org."
5223 config_host_mak="config-host.mak"
5225 echo "# Automatically generated by configure - do not modify" >config-all-disas.mak
5227 echo "# Automatically generated by configure - do not modify" > $config_host_mak
5228 echo >> $config_host_mak
5230 echo all: >> $config_host_mak
5231 echo "prefix=$prefix" >> $config_host_mak
5232 echo "bindir=$bindir" >> $config_host_mak
5233 echo "libdir=$libdir" >> $config_host_mak
5234 echo "libexecdir=$libexecdir" >> $config_host_mak
5235 echo "includedir=$includedir" >> $config_host_mak
5236 echo "mandir=$mandir" >> $config_host_mak
5237 echo "sysconfdir=$sysconfdir" >> $config_host_mak
5238 echo "qemu_confdir=$qemu_confdir" >> $config_host_mak
5239 echo "qemu_datadir=$qemu_datadir" >> $config_host_mak
5240 echo "qemu_docdir=$qemu_docdir" >> $config_host_mak
5241 echo "qemu_moddir=$qemu_moddir" >> $config_host_mak
5242 if test "$mingw32" = "no" ; then
5243 echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
5245 echo "qemu_helperdir=$libexecdir" >> $config_host_mak
5246 echo "extra_cflags=$EXTRA_CFLAGS" >> $config_host_mak
5247 echo "extra_ldflags=$EXTRA_LDFLAGS" >> $config_host_mak
5248 echo "qemu_localedir=$qemu_localedir" >> $config_host_mak
5249 echo "libs_softmmu=$libs_softmmu" >> $config_host_mak
5251 echo "ARCH=$ARCH" >> $config_host_mak
5253 if test "$debug_tcg" = "yes" ; then
5254 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
5256 if test "$strip_opt" = "yes" ; then
5257 echo "STRIP=${strip}" >> $config_host_mak
5259 if test "$bigendian" = "yes" ; then
5260 echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
5262 if test "$mingw32" = "yes" ; then
5263 echo "CONFIG_WIN32=y" >> $config_host_mak
5264 echo "CONFIG_INSTALLER=y" >> $config_host_mak
5265 rc_version=$(cat $source_path/VERSION)
5266 version_major=${rc_version%%.*}
5267 rc_version=${rc_version#*.}
5268 version_minor=${rc_version%%.*}
5269 rc_version=${rc_version#*.}
5270 version_subminor=${rc_version%%.*}
5271 version_micro=0
5272 echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
5273 echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
5274 if test "$guest_agent_with_vss" = "yes" ; then
5275 echo "CONFIG_QGA_VSS=y" >> $config_host_mak
5276 echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
5277 echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
5279 if test "$guest_agent_ntddscsi" = "yes" ; then
5280 echo "CONFIG_QGA_NTDDDISK=y" >> $config_host_mak
5282 if test "$guest_agent_msi" = "yes"; then
5283 echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
5284 echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
5285 echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
5286 echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
5287 echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
5288 echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
5289 echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
5291 else
5292 echo "CONFIG_POSIX=y" >> $config_host_mak
5295 if test "$linux" = "yes" ; then
5296 echo "CONFIG_LINUX=y" >> $config_host_mak
5299 if test "$darwin" = "yes" ; then
5300 echo "CONFIG_DARWIN=y" >> $config_host_mak
5303 if test "$aix" = "yes" ; then
5304 echo "CONFIG_AIX=y" >> $config_host_mak
5307 if test "$solaris" = "yes" ; then
5308 echo "CONFIG_SOLARIS=y" >> $config_host_mak
5309 echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
5310 if test "$needs_libsunmath" = "yes" ; then
5311 echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
5314 if test "$haiku" = "yes" ; then
5315 echo "CONFIG_HAIKU=y" >> $config_host_mak
5317 if test "$static" = "yes" ; then
5318 echo "CONFIG_STATIC=y" >> $config_host_mak
5320 if test "$profiler" = "yes" ; then
5321 echo "CONFIG_PROFILER=y" >> $config_host_mak
5323 if test "$slirp" = "yes" ; then
5324 echo "CONFIG_SLIRP=y" >> $config_host_mak
5325 echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
5327 if test "$vde" = "yes" ; then
5328 echo "CONFIG_VDE=y" >> $config_host_mak
5330 if test "$netmap" = "yes" ; then
5331 echo "CONFIG_NETMAP=y" >> $config_host_mak
5333 if test "$l2tpv3" = "yes" ; then
5334 echo "CONFIG_L2TPV3=y" >> $config_host_mak
5336 if test "$cap_ng" = "yes" ; then
5337 echo "CONFIG_LIBCAP=y" >> $config_host_mak
5339 echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
5340 for drv in $audio_drv_list; do
5341 def=CONFIG_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
5342 echo "$def=y" >> $config_host_mak
5343 done
5344 if test "$audio_pt_int" = "yes" ; then
5345 echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
5347 if test "$audio_win_int" = "yes" ; then
5348 echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
5350 echo "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
5351 echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
5352 if test "$vnc" = "yes" ; then
5353 echo "CONFIG_VNC=y" >> $config_host_mak
5355 if test "$vnc_sasl" = "yes" ; then
5356 echo "CONFIG_VNC_SASL=y" >> $config_host_mak
5358 if test "$vnc_jpeg" = "yes" ; then
5359 echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
5361 if test "$vnc_png" = "yes" ; then
5362 echo "CONFIG_VNC_PNG=y" >> $config_host_mak
5364 if test "$fnmatch" = "yes" ; then
5365 echo "CONFIG_FNMATCH=y" >> $config_host_mak
5367 if test "$xfs" = "yes" ; then
5368 echo "CONFIG_XFS=y" >> $config_host_mak
5370 qemu_version=$(head $source_path/VERSION)
5371 echo "VERSION=$qemu_version" >>$config_host_mak
5372 echo "PKGVERSION=$pkgversion" >>$config_host_mak
5373 echo "SRC_PATH=$source_path" >> $config_host_mak
5374 echo "TARGET_DIRS=$target_list" >> $config_host_mak
5375 if [ "$docs" = "yes" ] ; then
5376 echo "BUILD_DOCS=yes" >> $config_host_mak
5378 if [ "$want_tools" = "yes" ] ; then
5379 echo "BUILD_TOOLS=yes" >> $config_host_mak
5381 if test "$modules" = "yes"; then
5382 # $shacmd can generate a hash started with digit, which the compiler doesn't
5383 # like as an symbol. So prefix it with an underscore
5384 echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
5385 echo "CONFIG_MODULES=y" >> $config_host_mak
5387 if test "$sdl" = "yes" ; then
5388 echo "CONFIG_SDL=y" >> $config_host_mak
5389 echo "CONFIG_SDLABI=$sdlabi" >> $config_host_mak
5390 echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
5392 if test "$cocoa" = "yes" ; then
5393 echo "CONFIG_COCOA=y" >> $config_host_mak
5395 if test "$curses" = "yes" ; then
5396 echo "CONFIG_CURSES=y" >> $config_host_mak
5398 if test "$utimens" = "yes" ; then
5399 echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
5401 if test "$pipe2" = "yes" ; then
5402 echo "CONFIG_PIPE2=y" >> $config_host_mak
5404 if test "$accept4" = "yes" ; then
5405 echo "CONFIG_ACCEPT4=y" >> $config_host_mak
5407 if test "$splice" = "yes" ; then
5408 echo "CONFIG_SPLICE=y" >> $config_host_mak
5410 if test "$eventfd" = "yes" ; then
5411 echo "CONFIG_EVENTFD=y" >> $config_host_mak
5413 if test "$memfd" = "yes" ; then
5414 echo "CONFIG_MEMFD=y" >> $config_host_mak
5416 if test "$fallocate" = "yes" ; then
5417 echo "CONFIG_FALLOCATE=y" >> $config_host_mak
5419 if test "$fallocate_punch_hole" = "yes" ; then
5420 echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
5422 if test "$fallocate_zero_range" = "yes" ; then
5423 echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
5425 if test "$posix_fallocate" = "yes" ; then
5426 echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
5428 if test "$sync_file_range" = "yes" ; then
5429 echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
5431 if test "$fiemap" = "yes" ; then
5432 echo "CONFIG_FIEMAP=y" >> $config_host_mak
5434 if test "$dup3" = "yes" ; then
5435 echo "CONFIG_DUP3=y" >> $config_host_mak
5437 if test "$ppoll" = "yes" ; then
5438 echo "CONFIG_PPOLL=y" >> $config_host_mak
5440 if test "$prctl_pr_set_timerslack" = "yes" ; then
5441 echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
5443 if test "$epoll" = "yes" ; then
5444 echo "CONFIG_EPOLL=y" >> $config_host_mak
5446 if test "$epoll_create1" = "yes" ; then
5447 echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
5449 if test "$sendfile" = "yes" ; then
5450 echo "CONFIG_SENDFILE=y" >> $config_host_mak
5452 if test "$timerfd" = "yes" ; then
5453 echo "CONFIG_TIMERFD=y" >> $config_host_mak
5455 if test "$setns" = "yes" ; then
5456 echo "CONFIG_SETNS=y" >> $config_host_mak
5458 if test "$clock_adjtime" = "yes" ; then
5459 echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
5461 if test "$syncfs" = "yes" ; then
5462 echo "CONFIG_SYNCFS=y" >> $config_host_mak
5464 if test "$inotify" = "yes" ; then
5465 echo "CONFIG_INOTIFY=y" >> $config_host_mak
5467 if test "$inotify1" = "yes" ; then
5468 echo "CONFIG_INOTIFY1=y" >> $config_host_mak
5470 if test "$byteswap_h" = "yes" ; then
5471 echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
5473 if test "$bswap_h" = "yes" ; then
5474 echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
5476 if test "$curl" = "yes" ; then
5477 echo "CONFIG_CURL=m" >> $config_host_mak
5478 echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
5479 echo "CURL_LIBS=$curl_libs" >> $config_host_mak
5481 if test "$brlapi" = "yes" ; then
5482 echo "CONFIG_BRLAPI=y" >> $config_host_mak
5484 if test "$bluez" = "yes" ; then
5485 echo "CONFIG_BLUEZ=y" >> $config_host_mak
5486 echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
5488 if test "$glib_subprocess" = "yes" ; then
5489 echo "CONFIG_HAS_GLIB_SUBPROCESS_TESTS=y" >> $config_host_mak
5491 if test "$gtk" = "yes" ; then
5492 echo "CONFIG_GTK=y" >> $config_host_mak
5493 echo "CONFIG_GTKABI=$gtkabi" >> $config_host_mak
5494 echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
5495 echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
5496 if test "$gtk_gl" = "yes" ; then
5497 echo "CONFIG_GTK_GL=y" >> $config_host_mak
5500 echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
5501 if test "$gnutls" = "yes" ; then
5502 echo "CONFIG_GNUTLS=y" >> $config_host_mak
5504 if test "$gnutls_rnd" = "yes" ; then
5505 echo "CONFIG_GNUTLS_RND=y" >> $config_host_mak
5507 if test "$gcrypt" = "yes" ; then
5508 echo "CONFIG_GCRYPT=y" >> $config_host_mak
5509 if test "$gcrypt_hmac" = "yes" ; then
5510 echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
5512 if test "$gcrypt_kdf" = "yes" ; then
5513 echo "CONFIG_GCRYPT_KDF=y" >> $config_host_mak
5516 if test "$nettle" = "yes" ; then
5517 echo "CONFIG_NETTLE=y" >> $config_host_mak
5518 echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
5519 if test "$nettle_kdf" = "yes" ; then
5520 echo "CONFIG_NETTLE_KDF=y" >> $config_host_mak
5523 if test "$tasn1" = "yes" ; then
5524 echo "CONFIG_TASN1=y" >> $config_host_mak
5526 if test "$have_ifaddrs_h" = "yes" ; then
5527 echo "HAVE_IFADDRS_H=y" >> $config_host_mak
5529 if test "$have_broken_size_max" = "yes" ; then
5530 echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
5533 # Work around a system header bug with some kernel/XFS header
5534 # versions where they both try to define 'struct fsxattr':
5535 # xfs headers will not try to redefine structs from linux headers
5536 # if this macro is set.
5537 if test "$have_fsxattr" = "yes" ; then
5538 echo "HAVE_FSXATTR=y" >> $config_host_mak
5540 if test "$vte" = "yes" ; then
5541 echo "CONFIG_VTE=y" >> $config_host_mak
5542 echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
5544 if test "$virglrenderer" = "yes" ; then
5545 echo "CONFIG_VIRGL=y" >> $config_host_mak
5546 echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
5547 echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
5549 if test "$xen" = "yes" ; then
5550 echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
5551 echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
5552 if test "$xen_pv_domain_build" = "yes" ; then
5553 echo "CONFIG_XEN_PV_DOMAIN_BUILD=y" >> $config_host_mak
5556 if test "$linux_aio" = "yes" ; then
5557 echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
5559 if test "$attr" = "yes" ; then
5560 echo "CONFIG_ATTR=y" >> $config_host_mak
5562 if test "$libattr" = "yes" ; then
5563 echo "CONFIG_LIBATTR=y" >> $config_host_mak
5565 if test "$virtfs" = "yes" ; then
5566 echo "CONFIG_VIRTFS=y" >> $config_host_mak
5568 if test "$vhost_scsi" = "yes" ; then
5569 echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
5571 if test "$vhost_net" = "yes" ; then
5572 echo "CONFIG_VHOST_NET_USED=y" >> $config_host_mak
5574 if test "$vhost_vsock" = "yes" ; then
5575 echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
5577 if test "$blobs" = "yes" ; then
5578 echo "INSTALL_BLOBS=yes" >> $config_host_mak
5580 if test "$iovec" = "yes" ; then
5581 echo "CONFIG_IOVEC=y" >> $config_host_mak
5583 if test "$preadv" = "yes" ; then
5584 echo "CONFIG_PREADV=y" >> $config_host_mak
5586 if test "$fdt" = "yes" ; then
5587 echo "CONFIG_FDT=y" >> $config_host_mak
5589 if test "$signalfd" = "yes" ; then
5590 echo "CONFIG_SIGNALFD=y" >> $config_host_mak
5592 if test "$tcg_interpreter" = "yes" ; then
5593 echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
5595 if test "$fdatasync" = "yes" ; then
5596 echo "CONFIG_FDATASYNC=y" >> $config_host_mak
5598 if test "$madvise" = "yes" ; then
5599 echo "CONFIG_MADVISE=y" >> $config_host_mak
5601 if test "$posix_madvise" = "yes" ; then
5602 echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
5605 if test "$spice" = "yes" ; then
5606 echo "CONFIG_SPICE=y" >> $config_host_mak
5609 if test "$smartcard" = "yes" ; then
5610 echo "CONFIG_SMARTCARD=y" >> $config_host_mak
5613 if test "$libusb" = "yes" ; then
5614 echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
5617 if test "$usb_redir" = "yes" ; then
5618 echo "CONFIG_USB_REDIR=y" >> $config_host_mak
5621 if test "$opengl" = "yes" ; then
5622 echo "CONFIG_OPENGL=y" >> $config_host_mak
5623 echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
5624 if test "$opengl_dmabuf" = "yes" ; then
5625 echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
5629 if test "$avx2_opt" = "yes" ; then
5630 echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
5633 if test "$lzo" = "yes" ; then
5634 echo "CONFIG_LZO=y" >> $config_host_mak
5637 if test "$snappy" = "yes" ; then
5638 echo "CONFIG_SNAPPY=y" >> $config_host_mak
5641 if test "$bzip2" = "yes" ; then
5642 echo "CONFIG_BZIP2=y" >> $config_host_mak
5643 echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
5646 if test "$libiscsi" = "yes" ; then
5647 echo "CONFIG_LIBISCSI=m" >> $config_host_mak
5648 echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
5649 echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
5652 if test "$libnfs" = "yes" ; then
5653 echo "CONFIG_LIBNFS=m" >> $config_host_mak
5654 echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
5657 if test "$seccomp" = "yes"; then
5658 echo "CONFIG_SECCOMP=y" >> $config_host_mak
5661 # XXX: suppress that
5662 if [ "$bsd" = "yes" ] ; then
5663 echo "CONFIG_BSD=y" >> $config_host_mak
5666 if test "$localtime_r" = "yes" ; then
5667 echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
5669 if test "$qom_cast_debug" = "yes" ; then
5670 echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
5672 if test "$rbd" = "yes" ; then
5673 echo "CONFIG_RBD=m" >> $config_host_mak
5674 echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
5675 echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
5678 echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
5679 if test "$coroutine_pool" = "yes" ; then
5680 echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
5681 else
5682 echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
5685 if test "$debug_stack_usage" = "yes" ; then
5686 echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
5689 if test "$open_by_handle_at" = "yes" ; then
5690 echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
5693 if test "$linux_magic_h" = "yes" ; then
5694 echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
5697 if test "$pragma_diagnostic_available" = "yes" ; then
5698 echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
5701 if test "$valgrind_h" = "yes" ; then
5702 echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
5705 if test "$has_environ" = "yes" ; then
5706 echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
5709 if test "$cpuid_h" = "yes" ; then
5710 echo "CONFIG_CPUID_H=y" >> $config_host_mak
5713 if test "$int128" = "yes" ; then
5714 echo "CONFIG_INT128=y" >> $config_host_mak
5717 if test "$atomic128" = "yes" ; then
5718 echo "CONFIG_ATOMIC128=y" >> $config_host_mak
5721 if test "$atomic64" = "yes" ; then
5722 echo "CONFIG_ATOMIC64=y" >> $config_host_mak
5725 if test "$getauxval" = "yes" ; then
5726 echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
5729 if test "$glusterfs" = "yes" ; then
5730 echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
5731 echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
5732 echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
5735 if test "$glusterfs_xlator_opt" = "yes" ; then
5736 echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
5739 if test "$glusterfs_discard" = "yes" ; then
5740 echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
5743 if test "$glusterfs_zerofill" = "yes" ; then
5744 echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
5747 if test "$libssh2" = "yes" ; then
5748 echo "CONFIG_LIBSSH2=m" >> $config_host_mak
5749 echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
5750 echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak
5753 # USB host support
5754 if test "$libusb" = "yes"; then
5755 echo "HOST_USB=libusb legacy" >> $config_host_mak
5756 else
5757 echo "HOST_USB=stub" >> $config_host_mak
5760 # TPM passthrough support?
5761 if test "$tpm" = "yes"; then
5762 echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak
5763 if test "$tpm_passthrough" = "yes"; then
5764 echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
5768 echo "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
5769 if have_backend "nop"; then
5770 echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
5772 if have_backend "simple"; then
5773 echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
5774 # Set the appropriate trace file.
5775 trace_file="\"$trace_file-\" FMT_pid"
5777 if have_backend "log"; then
5778 echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
5780 if have_backend "ust"; then
5781 echo "CONFIG_TRACE_UST=y" >> $config_host_mak
5783 if have_backend "dtrace"; then
5784 echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
5785 if test "$trace_backend_stap" = "yes" ; then
5786 echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
5789 if have_backend "ftrace"; then
5790 if test "$linux" = "yes" ; then
5791 echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
5792 else
5793 feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
5796 if have_backend "syslog"; then
5797 if test "$posix_syslog" = "yes" ; then
5798 echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
5799 else
5800 feature_not_found "syslog(trace backend)" "syslog not available"
5803 echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
5805 if test "$rdma" = "yes" ; then
5806 echo "CONFIG_RDMA=y" >> $config_host_mak
5809 if test "$have_rtnetlink" = "yes" ; then
5810 echo "CONFIG_RTNETLINK=y" >> $config_host_mak
5813 if test "$replication" = "yes" ; then
5814 echo "CONFIG_REPLICATION=y" >> $config_host_mak
5817 if test "$have_af_vsock" = "yes" ; then
5818 echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
5821 if test "$have_sysmacros" = "yes" ; then
5822 echo "CONFIG_SYSMACROS=y" >> $config_host_mak
5825 # Hold two types of flag:
5826 # CONFIG_THREAD_SETNAME_BYTHREAD - we've got a way of setting the name on
5827 # a thread we have a handle to
5828 # CONFIG_PTHREAD_SETNAME_NP - A way of doing it on a particular
5829 # platform
5830 if test "$pthread_setname_np" = "yes" ; then
5831 echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
5832 echo "CONFIG_PTHREAD_SETNAME_NP=y" >> $config_host_mak
5835 if test "$tcg_interpreter" = "yes"; then
5836 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
5837 elif test "$ARCH" = "sparc64" ; then
5838 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
5839 elif test "$ARCH" = "s390x" ; then
5840 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
5841 elif test "$ARCH" = "x86_64" -o "$ARCH" = "x32" ; then
5842 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
5843 elif test "$ARCH" = "ppc64" ; then
5844 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/ppc $QEMU_INCLUDES"
5845 else
5846 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
5848 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg $QEMU_INCLUDES"
5850 echo "TOOLS=$tools" >> $config_host_mak
5851 echo "ROMS=$roms" >> $config_host_mak
5852 echo "MAKE=$make" >> $config_host_mak
5853 echo "INSTALL=$install" >> $config_host_mak
5854 echo "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
5855 echo "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
5856 echo "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
5857 echo "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
5858 echo "PYTHON=$python" >> $config_host_mak
5859 echo "CC=$cc" >> $config_host_mak
5860 if $iasl -h > /dev/null 2>&1; then
5861 echo "IASL=$iasl" >> $config_host_mak
5863 echo "CC_I386=$cc_i386" >> $config_host_mak
5864 echo "HOST_CC=$host_cc" >> $config_host_mak
5865 echo "CXX=$cxx" >> $config_host_mak
5866 echo "OBJCC=$objcc" >> $config_host_mak
5867 echo "AR=$ar" >> $config_host_mak
5868 echo "ARFLAGS=$ARFLAGS" >> $config_host_mak
5869 echo "AS=$as" >> $config_host_mak
5870 echo "CCAS=$ccas" >> $config_host_mak
5871 echo "CPP=$cpp" >> $config_host_mak
5872 echo "OBJCOPY=$objcopy" >> $config_host_mak
5873 echo "LD=$ld" >> $config_host_mak
5874 echo "NM=$nm" >> $config_host_mak
5875 echo "WINDRES=$windres" >> $config_host_mak
5876 echo "CFLAGS=$CFLAGS" >> $config_host_mak
5877 echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
5878 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
5879 echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
5880 if test "$sparse" = "yes" ; then
5881 echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_host_mak
5882 echo "CPP := REAL_CC=\"\$(CPP)\" cgcc" >> $config_host_mak
5883 echo "CXX := REAL_CC=\"\$(CXX)\" cgcc" >> $config_host_mak
5884 echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_host_mak
5885 echo "QEMU_CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
5887 if test "$cross_prefix" != ""; then
5888 echo "AUTOCONF_HOST := --host=${cross_prefix%-}" >> $config_host_mak
5889 else
5890 echo "AUTOCONF_HOST := " >> $config_host_mak
5892 echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
5893 echo "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
5894 echo "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
5895 echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
5896 echo "LIBS+=$LIBS" >> $config_host_mak
5897 echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
5898 echo "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
5899 echo "EXESUF=$EXESUF" >> $config_host_mak
5900 echo "DSOSUF=$DSOSUF" >> $config_host_mak
5901 echo "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
5902 echo "LIBS_QGA+=$libs_qga" >> $config_host_mak
5903 echo "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
5904 echo "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
5905 echo "POD2MAN=$POD2MAN" >> $config_host_mak
5906 echo "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
5907 if test "$gcov" = "yes" ; then
5908 echo "CONFIG_GCOV=y" >> $config_host_mak
5909 echo "GCOV=$gcov_tool" >> $config_host_mak
5912 # use included Linux headers
5913 if test "$linux" = "yes" ; then
5914 mkdir -p linux-headers
5915 case "$cpu" in
5916 i386|x86_64|x32)
5917 linux_arch=x86
5919 ppcemb|ppc|ppc64)
5920 linux_arch=powerpc
5922 s390x)
5923 linux_arch=s390
5925 aarch64)
5926 linux_arch=arm64
5928 mips64)
5929 linux_arch=mips
5932 # For most CPUs the kernel architecture name and QEMU CPU name match.
5933 linux_arch="$cpu"
5935 esac
5936 # For non-KVM architectures we will not have asm headers
5937 if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
5938 symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
5942 for target in $target_list; do
5943 target_dir="$target"
5944 config_target_mak=$target_dir/config-target.mak
5945 target_name=$(echo $target | cut -d '-' -f 1)
5946 target_bigendian="no"
5948 case "$target_name" in
5949 armeb|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
5950 target_bigendian=yes
5952 esac
5953 target_softmmu="no"
5954 target_user_only="no"
5955 target_linux_user="no"
5956 target_bsd_user="no"
5957 case "$target" in
5958 ${target_name}-softmmu)
5959 target_softmmu="yes"
5961 ${target_name}-linux-user)
5962 if test "$linux" != "yes" ; then
5963 error_exit "Target '$target' is only available on a Linux host"
5965 target_user_only="yes"
5966 target_linux_user="yes"
5968 ${target_name}-bsd-user)
5969 if test "$bsd" != "yes" ; then
5970 error_exit "Target '$target' is only available on a BSD host"
5972 target_user_only="yes"
5973 target_bsd_user="yes"
5976 error_exit "Target '$target' not recognised"
5977 exit 1
5979 esac
5981 mkdir -p $target_dir
5982 echo "# Automatically generated by configure - do not modify" > $config_target_mak
5984 bflt="no"
5985 mttcg="no"
5986 interp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
5987 gdb_xml_files=""
5989 TARGET_ARCH="$target_name"
5990 TARGET_BASE_ARCH=""
5991 TARGET_ABI_DIR=""
5993 case "$target_name" in
5994 i386)
5996 x86_64)
5997 TARGET_BASE_ARCH=i386
5999 alpha)
6000 mttcg="yes"
6002 arm|armeb)
6003 TARGET_ARCH=arm
6004 bflt="yes"
6005 mttcg="yes"
6006 gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
6008 aarch64)
6009 TARGET_BASE_ARCH=arm
6010 bflt="yes"
6011 mttcg="yes"
6012 gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
6014 cris)
6016 hppa)
6018 lm32)
6020 m68k)
6021 bflt="yes"
6022 gdb_xml_files="cf-core.xml cf-fp.xml"
6024 microblaze|microblazeel)
6025 TARGET_ARCH=microblaze
6026 bflt="yes"
6028 mips|mipsel)
6029 TARGET_ARCH=mips
6030 echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
6032 mipsn32|mipsn32el)
6033 TARGET_ARCH=mips64
6034 TARGET_BASE_ARCH=mips
6035 echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
6036 echo "TARGET_ABI32=y" >> $config_target_mak
6038 mips64|mips64el)
6039 TARGET_ARCH=mips64
6040 TARGET_BASE_ARCH=mips
6041 echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
6043 moxie)
6045 nios2)
6047 or1k)
6048 TARGET_ARCH=openrisc
6049 TARGET_BASE_ARCH=openrisc
6051 ppc)
6052 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
6054 ppcemb)
6055 TARGET_BASE_ARCH=ppc
6056 TARGET_ABI_DIR=ppc
6057 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
6059 ppc64)
6060 TARGET_BASE_ARCH=ppc
6061 TARGET_ABI_DIR=ppc
6062 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
6064 ppc64le)
6065 TARGET_ARCH=ppc64
6066 TARGET_BASE_ARCH=ppc
6067 TARGET_ABI_DIR=ppc
6068 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
6070 ppc64abi32)
6071 TARGET_ARCH=ppc64
6072 TARGET_BASE_ARCH=ppc
6073 TARGET_ABI_DIR=ppc
6074 echo "TARGET_ABI32=y" >> $config_target_mak
6075 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
6077 sh4|sh4eb)
6078 TARGET_ARCH=sh4
6079 bflt="yes"
6081 sparc)
6083 sparc64)
6084 TARGET_BASE_ARCH=sparc
6086 sparc32plus)
6087 TARGET_ARCH=sparc64
6088 TARGET_BASE_ARCH=sparc
6089 TARGET_ABI_DIR=sparc
6090 echo "TARGET_ABI32=y" >> $config_target_mak
6092 s390x)
6093 gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml s390-cr.xml s390-virt.xml"
6095 tilegx)
6097 tricore)
6099 unicore32)
6101 xtensa|xtensaeb)
6102 TARGET_ARCH=xtensa
6105 error_exit "Unsupported target CPU"
6107 esac
6108 # TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
6109 if [ "$TARGET_BASE_ARCH" = "" ]; then
6110 TARGET_BASE_ARCH=$TARGET_ARCH
6113 symlink "$source_path/Makefile.target" "$target_dir/Makefile"
6115 upper() {
6116 echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
6119 target_arch_name="$(upper $TARGET_ARCH)"
6120 echo "TARGET_$target_arch_name=y" >> $config_target_mak
6121 echo "TARGET_NAME=$target_name" >> $config_target_mak
6122 echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
6123 if [ "$TARGET_ABI_DIR" = "" ]; then
6124 TARGET_ABI_DIR=$TARGET_ARCH
6126 echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
6127 if [ "$HOST_VARIANT_DIR" != "" ]; then
6128 echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
6130 case "$target_name" in
6131 i386|x86_64)
6132 if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
6133 echo "CONFIG_XEN=y" >> $config_target_mak
6134 if test "$xen_pci_passthrough" = yes; then
6135 echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
6140 esac
6141 case "$target_name" in
6142 aarch64|arm|i386|x86_64|ppcemb|ppc|ppc64|s390x|mipsel|mips)
6143 # Make sure the target and host cpus are compatible
6144 if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
6145 \( "$target_name" = "$cpu" -o \
6146 \( "$target_name" = "ppcemb" -a "$cpu" = "ppc" \) -o \
6147 \( "$target_name" = "ppc64" -a "$cpu" = "ppc" \) -o \
6148 \( "$target_name" = "ppc" -a "$cpu" = "ppc64" \) -o \
6149 \( "$target_name" = "ppcemb" -a "$cpu" = "ppc64" \) -o \
6150 \( "$target_name" = "mipsel" -a "$cpu" = "mips" \) -o \
6151 \( "$target_name" = "x86_64" -a "$cpu" = "i386" \) -o \
6152 \( "$target_name" = "i386" -a "$cpu" = "x86_64" \) -o \
6153 \( "$target_name" = "x86_64" -a "$cpu" = "x32" \) -o \
6154 \( "$target_name" = "i386" -a "$cpu" = "x32" \) \) ; then
6155 echo "CONFIG_KVM=y" >> $config_target_mak
6156 if test "$vhost_net" = "yes" ; then
6157 echo "CONFIG_VHOST_NET=y" >> $config_target_mak
6158 echo "CONFIG_VHOST_NET_TEST_$target_name=y" >> $config_host_mak
6161 esac
6162 if test "$hax" = "yes" ; then
6163 if test "$target_softmmu" = "yes" ; then
6164 case "$target_name" in
6165 i386|x86_64)
6166 echo "CONFIG_HAX=y" >> $config_target_mak
6168 esac
6171 if test "$target_bigendian" = "yes" ; then
6172 echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
6174 if test "$target_softmmu" = "yes" ; then
6175 echo "CONFIG_SOFTMMU=y" >> $config_target_mak
6176 if test "$mttcg" = "yes" ; then
6177 echo "TARGET_SUPPORTS_MTTCG=y" >> $config_target_mak
6180 if test "$target_user_only" = "yes" ; then
6181 echo "CONFIG_USER_ONLY=y" >> $config_target_mak
6182 echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
6184 if test "$target_linux_user" = "yes" ; then
6185 echo "CONFIG_LINUX_USER=y" >> $config_target_mak
6187 list=""
6188 if test ! -z "$gdb_xml_files" ; then
6189 for x in $gdb_xml_files; do
6190 list="$list $source_path/gdb-xml/$x"
6191 done
6192 echo "TARGET_XML_FILES=$list" >> $config_target_mak
6195 if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
6196 echo "TARGET_HAS_BFLT=y" >> $config_target_mak
6198 if test "$target_bsd_user" = "yes" ; then
6199 echo "CONFIG_BSD_USER=y" >> $config_target_mak
6202 # generate QEMU_CFLAGS/LDFLAGS for targets
6204 cflags=""
6205 ldflags=""
6207 disas_config() {
6208 echo "CONFIG_${1}_DIS=y" >> $config_target_mak
6209 echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
6212 for i in $ARCH $TARGET_BASE_ARCH ; do
6213 case "$i" in
6214 alpha)
6215 disas_config "ALPHA"
6217 aarch64)
6218 if test -n "${cxx}"; then
6219 disas_config "ARM_A64"
6222 arm)
6223 disas_config "ARM"
6224 if test -n "${cxx}"; then
6225 disas_config "ARM_A64"
6228 cris)
6229 disas_config "CRIS"
6231 hppa)
6232 disas_config "HPPA"
6234 i386|x86_64|x32)
6235 disas_config "I386"
6237 ia64*)
6238 disas_config "IA64"
6240 lm32)
6241 disas_config "LM32"
6243 m68k)
6244 disas_config "M68K"
6246 microblaze*)
6247 disas_config "MICROBLAZE"
6249 mips*)
6250 disas_config "MIPS"
6252 moxie*)
6253 disas_config "MOXIE"
6255 nios2)
6256 disas_config "NIOS2"
6258 or1k)
6259 disas_config "OPENRISC"
6261 ppc*)
6262 disas_config "PPC"
6264 s390*)
6265 disas_config "S390"
6267 sh4)
6268 disas_config "SH4"
6270 sparc*)
6271 disas_config "SPARC"
6273 xtensa*)
6274 disas_config "XTENSA"
6276 esac
6277 done
6278 if test "$tcg_interpreter" = "yes" ; then
6279 disas_config "TCI"
6282 case "$ARCH" in
6283 alpha)
6284 # Ensure there's only a single GP
6285 cflags="-msmall-data $cflags"
6287 esac
6289 if test "$gprof" = "yes" ; then
6290 echo "TARGET_GPROF=yes" >> $config_target_mak
6291 if test "$target_linux_user" = "yes" ; then
6292 cflags="-p $cflags"
6293 ldflags="-p $ldflags"
6295 if test "$target_softmmu" = "yes" ; then
6296 ldflags="-p $ldflags"
6297 echo "GPROF_CFLAGS=-p" >> $config_target_mak
6301 if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
6302 ldflags="$ldflags $textseg_ldflags"
6305 echo "LDFLAGS+=$ldflags" >> $config_target_mak
6306 echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak
6308 done # for target in $targets
6310 if [ "$pixman" = "internal" ]; then
6311 echo "config-host.h: subdir-pixman" >> $config_host_mak
6314 if [ "$dtc_internal" = "yes" ]; then
6315 echo "config-host.h: subdir-dtc" >> $config_host_mak
6318 if test "$numa" = "yes"; then
6319 echo "CONFIG_NUMA=y" >> $config_host_mak
6322 if test "$ccache_cpp2" = "yes"; then
6323 echo "export CCACHE_CPP2=y" >> $config_host_mak
6326 # build tree in object directory in case the source is not in the current directory
6327 DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests"
6328 DIRS="$DIRS docs fsdev"
6329 DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
6330 DIRS="$DIRS roms/seabios roms/vgabios"
6331 DIRS="$DIRS qapi-generated"
6332 FILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
6333 FILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
6334 FILES="$FILES tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
6335 FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
6336 FILES="$FILES pc-bios/spapr-rtas/Makefile"
6337 FILES="$FILES pc-bios/s390-ccw/Makefile"
6338 FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
6339 FILES="$FILES pc-bios/qemu-icon.bmp"
6340 for bios_file in \
6341 $source_path/pc-bios/*.bin \
6342 $source_path/pc-bios/*.lid \
6343 $source_path/pc-bios/*.aml \
6344 $source_path/pc-bios/*.rom \
6345 $source_path/pc-bios/*.dtb \
6346 $source_path/pc-bios/*.img \
6347 $source_path/pc-bios/openbios-* \
6348 $source_path/pc-bios/u-boot.* \
6349 $source_path/pc-bios/palcode-*
6351 FILES="$FILES pc-bios/$(basename $bios_file)"
6352 done
6353 for test_file in $(find $source_path/tests/acpi-test-data -type f)
6355 FILES="$FILES tests/acpi-test-data$(echo $test_file | sed -e 's/.*acpi-test-data//')"
6356 done
6357 mkdir -p $DIRS
6358 for f in $FILES ; do
6359 if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
6360 symlink "$source_path/$f" "$f"
6362 done
6364 # temporary config to build submodules
6365 for rom in seabios vgabios ; do
6366 config_mak=roms/$rom/config.mak
6367 echo "# Automatically generated by configure - do not modify" > $config_mak
6368 echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
6369 echo "AS=$as" >> $config_mak
6370 echo "CCAS=$ccas" >> $config_mak
6371 echo "CC=$cc" >> $config_mak
6372 echo "BCC=bcc" >> $config_mak
6373 echo "CPP=$cpp" >> $config_mak
6374 echo "OBJCOPY=objcopy" >> $config_mak
6375 echo "IASL=$iasl" >> $config_mak
6376 echo "LD=$ld" >> $config_mak
6377 done
6379 # set up tests data directory
6380 if [ ! -e tests/data ]; then
6381 symlink "$source_path/tests/data" tests/data
6384 # set up qemu-iotests in this build directory
6385 iotests_common_env="tests/qemu-iotests/common.env"
6386 iotests_check="tests/qemu-iotests/check"
6388 echo "# Automatically generated by configure - do not modify" > "$iotests_common_env"
6389 echo >> "$iotests_common_env"
6390 echo "export PYTHON='$python'" >> "$iotests_common_env"
6392 if [ ! -e "$iotests_check" ]; then
6393 symlink "$source_path/$iotests_check" "$iotests_check"
6396 # Save the configure command line for later reuse.
6397 cat <<EOD >config.status
6398 #!/bin/sh
6399 # Generated by configure.
6400 # Run this file to recreate the current configuration.
6401 # Compiler output produced by configure, useful for debugging
6402 # configure, is in config.log if it exists.
6404 printf "exec" >>config.status
6405 printf " '%s'" "$0" "$@" >>config.status
6406 echo ' "$@"' >>config.status
6407 chmod +x config.status
6409 rm -r "$TMPDIR1"