Merge remote-tracking branch 'qemu/master'
[qemu/ar7.git] / configure
blob129f1e7cbc1701b7b35c099e5bd1a478c9c4446a
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 archipelago="no"
307 gtk=""
308 gtkabi=""
309 gtk_gl="no"
310 tls_priority="NORMAL"
311 gnutls=""
312 gnutls_rnd=""
313 nettle=""
314 nettle_kdf="no"
315 gcrypt=""
316 gcrypt_hmac="no"
317 gcrypt_kdf="no"
318 vte=""
319 virglrenderer=""
320 tpm="yes"
321 libssh2=""
322 numa=""
323 tcmalloc="no"
324 jemalloc="no"
325 replication="yes"
327 # parse CC options first
328 for opt do
329 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
330 case "$opt" in
331 --cross-prefix=*) cross_prefix="$optarg"
333 --cc=*) CC="$optarg"
335 --cxx=*) CXX="$optarg"
337 --source-path=*) source_path="$optarg"
339 --cpu=*) cpu="$optarg"
341 --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
342 EXTRA_CFLAGS="$optarg"
344 --extra-ldflags=*) LDFLAGS="$LDFLAGS $optarg"
345 EXTRA_LDFLAGS="$optarg"
347 --enable-debug-info) debug_info="yes"
349 --disable-debug-info) debug_info="no"
351 esac
352 done
353 # OS specific
354 # Using uname is really, really broken. Once we have the right set of checks
355 # we can eliminate its usage altogether.
357 # Preferred compiler:
358 # ${CC} (if set)
359 # ${cross_prefix}gcc (if cross-prefix specified)
360 # system compiler
361 if test -z "${CC}${cross_prefix}"; then
362 cc="$host_cc"
363 else
364 cc="${CC-${cross_prefix}gcc}"
367 if test -z "${CXX}${cross_prefix}"; then
368 cxx="c++"
369 else
370 cxx="${CXX-${cross_prefix}g++}"
373 ar="${AR-${cross_prefix}ar}"
374 as="${AS-${cross_prefix}as}"
375 ccas="${CCAS-$cc}"
376 cpp="${CPP-$cc -E}"
377 objcopy="${OBJCOPY-${cross_prefix}objcopy}"
378 ld="${LD-${cross_prefix}ld}"
379 nm="${NM-${cross_prefix}nm}"
380 strip="${STRIP-${cross_prefix}strip}"
381 windres="${WINDRES-${cross_prefix}windres}"
382 pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
383 query_pkg_config() {
384 "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
386 pkg_config=query_pkg_config
387 sdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
388 sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
390 # If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
391 ARFLAGS="${ARFLAGS-rv}"
393 # default flags for all hosts
394 # We use -fwrapv to tell the compiler that we require a C dialect where
395 # left shift of signed integers is well defined and has the expected
396 # 2s-complement style results. (Both clang and gcc agree that it
397 # provides these semantics.)
398 QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
399 QEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
400 QEMU_CFLAGS="-Wmissing-format-attribute $QEMU_CFLAGS"
401 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
402 QEMU_CFLAGS="-Wno-unused-parameter $QEMU_CFLAGS"
403 QEMU_CFLAGS="-Wno-missing-field-initializers $QEMU_CFLAGS"
404 QEMU_CFLAGS="-Wno-sign-compare $QEMU_CFLAGS"
405 QEMU_CFLAGS="-Wno-override-init $QEMU_CFLAGS"
406 QEMU_CFLAGS="-Wno-error=format $QEMU_CFLAGS"
407 QEMU_CFLAGS="-Wno-error=format-extra-args $QEMU_CFLAGS"
408 QEMU_CFLAGS="-Wno-error=parentheses $QEMU_CFLAGS"
409 QEMU_CFLAGS="-Wextra $QEMU_CFLAGS"
410 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
411 QEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/include"
412 if test "$debug_info" = "yes"; then
413 CFLAGS="-g $CFLAGS"
414 LDFLAGS="-g $LDFLAGS"
417 # make source path absolute
418 source_path=$(cd "$source_path"; pwd)
420 cc_macros=$($cc $QEMU_CFLAGS -E -dD - </dev/null)
422 # running configure in the source tree?
423 # we know that's the case if configure is there.
424 if test -f "./configure"; then
425 pwd_is_source_path="y"
426 else
427 pwd_is_source_path="n"
430 check_define() {
431 rm -f $TMPC
432 cat > $TMPC <<EOF
433 #if !defined($1)
434 #error $1 not defined
435 #endif
436 int main(void) { return 0; }
438 compile_object
441 check_include() {
442 cat > $TMPC <<EOF
443 #include <$1>
444 int main(void) { return 0; }
446 compile_object
449 write_c_skeleton() {
450 cat > $TMPC <<EOF
451 int main(void) { return 0; }
455 if check_define __linux__ ; then
456 targetos="Linux"
457 elif check_define _WIN32 ; then
458 targetos='MINGW32'
459 elif check_define __OpenBSD__ ; then
460 targetos='OpenBSD'
461 elif check_define __sun__ ; then
462 targetos='SunOS'
463 elif check_define __HAIKU__ ; then
464 targetos='Haiku'
465 else
466 targetos=$(uname -s)
469 # Some host OSes need non-standard checks for which CPU to use.
470 # Note that these checks are broken for cross-compilation: if you're
471 # cross-compiling to one of these OSes then you'll need to specify
472 # the correct CPU with the --cpu option.
473 case $targetos in
474 Darwin)
475 # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
476 # run 64-bit userspace code.
477 # If the user didn't specify a CPU explicitly and the kernel says this is
478 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
479 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
480 cpu="x86_64"
483 SunOS)
484 # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
485 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
486 cpu="x86_64"
488 esac
490 if test ! -z "$cpu" ; then
491 # command line argument
493 elif check_define __i386__ ; then
494 cpu="i386"
495 elif check_define __x86_64__ ; then
496 if check_define __ILP32__ ; then
497 cpu="x32"
498 else
499 cpu="x86_64"
501 elif check_define __sparc__ ; then
502 if check_define __arch64__ ; then
503 cpu="sparc64"
504 else
505 cpu="sparc"
507 elif check_define _ARCH_PPC ; then
508 if check_define _ARCH_PPC64 ; then
509 cpu="ppc64"
510 else
511 cpu="ppc"
513 elif check_define __mips__ ; then
514 if check_define __mips64 ; then
515 cpu="mips64"
516 else
517 cpu="mips"
519 elif check_define __ia64__ ; then
520 cpu="ia64"
521 elif check_define __s390__ ; then
522 if check_define __s390x__ ; then
523 cpu="s390x"
524 else
525 cpu="s390"
527 elif check_define __arm__ ; then
528 cpu="arm"
529 elif check_define __aarch64__ ; then
530 cpu="aarch64"
531 else
532 cpu=$(uname -m)
535 ARCH=
536 # Normalise host CPU name and set ARCH.
537 # Note that this case should only have supported host CPUs, not guests.
538 case "$cpu" in
539 ia64|ppc|ppc64|s390|s390x|sparc64|x32)
540 cpu="$cpu"
542 i386|i486|i586|i686|i86pc|BePC)
543 cpu="i386"
545 x86_64|amd64)
546 cpu="x86_64"
548 armv*b|armv*l|arm)
549 cpu="arm"
551 aarch64)
552 cpu="aarch64"
554 mips*)
555 cpu="mips"
556 if check_define __MIPSEL__ ; then
557 cpu="${cpu}el"
560 sparc|sun4[cdmuv])
561 cpu="sparc"
563 sh4)
564 cpu="sh4"
567 # This will result in either an error or falling back to TCI later
568 ARCH=unknown
570 esac
571 if test -z "$ARCH"; then
572 ARCH="$cpu"
575 # OS specific
577 # host *BSD for user mode
578 HOST_VARIANT_DIR=""
580 case $targetos in
581 CYGWIN*)
582 mingw32="yes"
583 QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
584 audio_possible_drivers="sdl"
585 audio_drv_list="sdl"
587 MINGW32*)
588 mingw32="yes"
589 hax="yes"
590 audio_possible_drivers="dsound sdl"
591 if check_include dsound.h; then
592 audio_drv_list="dsound"
593 else
594 audio_drv_list=""
597 GNU/kFreeBSD)
598 bsd="yes"
599 audio_drv_list="oss"
600 audio_possible_drivers="oss sdl pa"
602 FreeBSD)
603 bsd="yes"
604 make="${MAKE-gmake}"
605 audio_drv_list="oss"
606 audio_possible_drivers="oss sdl pa"
607 # needed for kinfo_getvmmap(3) in libutil.h
608 LIBS="-lutil $LIBS"
609 # needed for kinfo_getproc
610 libs_qga="-lutil $libs_qga"
611 netmap="" # enable netmap autodetect
612 HOST_VARIANT_DIR="freebsd"
614 DragonFly)
615 bsd="yes"
616 make="${MAKE-gmake}"
617 audio_drv_list="oss"
618 audio_possible_drivers="oss sdl pa"
619 HOST_VARIANT_DIR="dragonfly"
621 NetBSD)
622 bsd="yes"
623 make="${MAKE-gmake}"
624 audio_drv_list="oss"
625 audio_possible_drivers="oss sdl"
626 oss_lib="-lossaudio"
627 HOST_VARIANT_DIR="netbsd"
629 OpenBSD)
630 bsd="yes"
631 make="${MAKE-gmake}"
632 audio_drv_list="sdl"
633 audio_possible_drivers="sdl"
634 HOST_VARIANT_DIR="openbsd"
636 Darwin)
637 bsd="yes"
638 darwin="yes"
639 hax="yes"
640 LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
641 if [ "$cpu" = "x86_64" ] ; then
642 QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
643 LDFLAGS="-arch x86_64 $LDFLAGS"
645 cocoa="yes"
646 audio_drv_list="coreaudio"
647 audio_possible_drivers="coreaudio sdl"
648 LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
649 libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
650 # Disable attempts to use ObjectiveC features in os/object.h since they
651 # won't work when we're compiling with gcc as a C compiler.
652 QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
653 HOST_VARIANT_DIR="darwin"
655 SunOS)
656 solaris="yes"
657 make="${MAKE-gmake}"
658 install="${INSTALL-ginstall}"
659 ld="gld"
660 smbd="${SMBD-/usr/sfw/sbin/smbd}"
661 needs_libsunmath="no"
662 solarisrev=$(uname -r | cut -f2 -d.)
663 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
664 if test "$solarisrev" -le 9 ; then
665 if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
666 needs_libsunmath="yes"
667 QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
668 LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
669 LIBS="-lsunmath $LIBS"
670 else
671 error_exit "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without" \
672 "libsunmath from the Sun Studio compilers tools, due to a lack of" \
673 "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86" \
674 "Studio 11 can be downloaded from www.sun.com."
678 if test -f /usr/include/sys/soundcard.h ; then
679 audio_drv_list="oss"
681 audio_possible_drivers="oss sdl"
682 # needed for CMSG_ macros in sys/socket.h
683 QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
684 # needed for TIOCWIN* defines in termios.h
685 QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
686 QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
687 solarisnetlibs="-lsocket -lnsl -lresolv"
688 LIBS="$solarisnetlibs $LIBS"
689 libs_qga="$solarisnetlibs $libs_qga"
691 AIX)
692 aix="yes"
693 make="${MAKE-gmake}"
695 Haiku)
696 haiku="yes"
697 QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
698 LIBS="-lposix_error_mapper -lnetwork $LIBS"
701 audio_drv_list="oss"
702 audio_possible_drivers="oss alsa sdl pa"
703 linux="yes"
704 linux_user="yes"
705 kvm="yes"
706 vhost_net="yes"
707 vhost_scsi="yes"
708 vhost_vsock="yes"
709 QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
711 esac
713 if [ "$bsd" = "yes" ] ; then
714 if [ "$darwin" != "yes" ] ; then
715 bsd_user="yes"
719 : ${make=${MAKE-make}}
720 : ${install=${INSTALL-install}}
721 : ${python=${PYTHON-python}}
722 : ${smbd=${SMBD-/usr/sbin/smbd}}
724 # Default objcc to clang if available, otherwise use CC
725 if has clang; then
726 objcc=clang
727 else
728 objcc="$cc"
731 if test "$mingw32" = "yes" ; then
732 EXESUF=".exe"
733 DSOSUF=".dll"
734 QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
735 # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
736 QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
737 # MinGW-w64 needs _POSIX defined.
738 QEMU_CFLAGS="-D_POSIX=1 $QEMU_CFLAGS"
739 # MinGW needs -mthreads for TLS and macro _MT.
740 QEMU_CFLAGS="-mthreads $QEMU_CFLAGS"
741 QEMU_CFLAGS="-I\$(SRC_PATH)/hosts/w32/include $QEMU_CFLAGS"
742 LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
743 write_c_skeleton;
744 if compile_prog "" "-liberty" ; then
745 LIBS="-liberty $LIBS"
747 prefix="c:/Program Files/QEMU"
748 mandir="\${prefix}"
749 datadir="\${prefix}"
750 qemu_docdir="\${prefix}"
751 bindir="\${prefix}"
752 sysconfdir="\${prefix}"
753 local_statedir=
754 confsuffix=""
755 libs_qga="-lws2_32 -lwinmm -lpowrprof -liphlpapi -lnetapi32 $libs_qga"
758 werror=""
760 for opt do
761 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
762 case "$opt" in
763 --help|-h) show_help=yes
765 --version|-V) exec cat $source_path/VERSION
767 --prefix=*) prefix="$optarg"
769 --interp-prefix=*) interp_prefix="$optarg"
771 --source-path=*)
773 --cross-prefix=*)
775 --cc=*)
777 --host-cc=*) host_cc="$optarg"
779 --cxx=*)
781 --iasl=*) iasl="$optarg"
783 --objcc=*) objcc="$optarg"
785 --make=*) make="$optarg"
787 --install=*) install="$optarg"
789 --python=*) python="$optarg"
791 --gcov=*) gcov_tool="$optarg"
793 --smbd=*) smbd="$optarg"
795 --extra-cflags=*)
797 --extra-ldflags=*)
799 --enable-debug-info)
801 --disable-debug-info)
803 --enable-modules)
804 modules="yes"
806 --disable-modules)
807 modules="no"
809 --cpu=*)
811 --target-list=*) target_list="$optarg"
813 --enable-trace-backends=*) trace_backends="$optarg"
815 # XXX: backwards compatibility
816 --enable-trace-backend=*) trace_backends="$optarg"
818 --with-trace-file=*) trace_file="$optarg"
820 --enable-gprof) gprof="yes"
822 --enable-gcov) gcov="yes"
824 --static)
825 static="yes"
826 LDFLAGS="-static $LDFLAGS"
827 QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
829 --mandir=*) mandir="$optarg"
831 --bindir=*) bindir="$optarg"
833 --libdir=*) libdir="$optarg"
835 --libexecdir=*) libexecdir="$optarg"
837 --includedir=*) includedir="$optarg"
839 --datadir=*) datadir="$optarg"
841 --with-confsuffix=*) confsuffix="$optarg"
843 --docdir=*) qemu_docdir="$optarg"
845 --sysconfdir=*) sysconfdir="$optarg"
847 --localstatedir=*) local_statedir="$optarg"
849 --sbindir=*|--sharedstatedir=*|\
850 --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
851 --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
852 # These switches are silently ignored, for compatibility with
853 # autoconf-generated configure scripts. This allows QEMU's
854 # configure to be used by RPM and similar macros that set
855 # lots of directory switches by default.
857 --with-system-pixman) pixman="system"
859 --without-system-pixman) pixman="internal"
861 --without-pixman) pixman="none"
863 --disable-sdl) sdl="no"
865 --enable-sdl) sdl="yes"
867 --with-sdlabi=*) sdlabi="$optarg"
869 --disable-qom-cast-debug) qom_cast_debug="no"
871 --enable-qom-cast-debug) qom_cast_debug="yes"
873 --disable-virtfs) virtfs="no"
875 --enable-virtfs) virtfs="yes"
877 --disable-vnc) vnc="no"
879 --enable-vnc) vnc="yes"
881 --oss-lib=*) oss_lib="$optarg"
883 --audio-drv-list=*) audio_drv_list="$optarg"
885 --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
887 --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
889 --enable-debug-tcg) debug_tcg="yes"
891 --disable-debug-tcg) debug_tcg="no"
893 --enable-debug)
894 # Enable debugging options that aren't excessively noisy
895 debug_tcg="yes"
896 debug="yes"
897 strip_opt="no"
898 fortify_source="no"
900 --enable-sparse) sparse="yes"
902 --disable-sparse) sparse="no"
904 --disable-strip) strip_opt="no"
906 --disable-vnc-sasl) vnc_sasl="no"
908 --enable-vnc-sasl) vnc_sasl="yes"
910 --disable-vnc-jpeg) vnc_jpeg="no"
912 --enable-vnc-jpeg) vnc_jpeg="yes"
914 --disable-vnc-png) vnc_png="no"
916 --enable-vnc-png) vnc_png="yes"
918 --disable-slirp) slirp="no"
920 --disable-vde) vde="no"
922 --enable-vde) vde="yes"
924 --disable-netmap) netmap="no"
926 --enable-netmap) netmap="yes"
928 --disable-xen) xen="no"
930 --enable-xen) xen="yes"
932 --disable-xen-pci-passthrough) xen_pci_passthrough="no"
934 --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
936 --disable-xen-pv-domain-build) xen_pv_domain_build="no"
938 --enable-xen-pv-domain-build) xen_pv_domain_build="yes"
940 --disable-brlapi) brlapi="no"
942 --enable-brlapi) brlapi="yes"
944 --disable-bluez) bluez="no"
946 --enable-bluez) bluez="yes"
948 --disable-kvm) kvm="no"
950 --enable-kvm) kvm="yes"
952 --disable-hax) hax="no"
954 --enable-hax) hax="yes"
956 --disable-tcg-interpreter) tcg_interpreter="no"
958 --enable-tcg-interpreter) tcg_interpreter="yes"
960 --disable-cap-ng) cap_ng="no"
962 --enable-cap-ng) cap_ng="yes"
964 --disable-spice) spice="no"
966 --enable-spice) spice="yes"
968 --disable-libiscsi) libiscsi="no"
970 --enable-libiscsi) libiscsi="yes"
972 --disable-libnfs) libnfs="no"
974 --enable-libnfs) libnfs="yes"
976 --enable-profiler) profiler="yes"
978 --disable-cocoa) cocoa="no"
980 --enable-cocoa)
981 cocoa="yes" ;
982 audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
984 --disable-system) softmmu="no"
986 --enable-system) softmmu="yes"
988 --disable-user)
989 linux_user="no" ;
990 bsd_user="no" ;
992 --enable-user) ;;
993 --disable-linux-user) linux_user="no"
995 --enable-linux-user) linux_user="yes"
997 --disable-bsd-user) bsd_user="no"
999 --enable-bsd-user) bsd_user="yes"
1001 --enable-pie) pie="yes"
1003 --disable-pie) pie="no"
1005 --enable-werror) werror="yes"
1007 --disable-werror) werror="no"
1009 --enable-stack-protector) stack_protector="yes"
1011 --disable-stack-protector) stack_protector="no"
1013 --disable-curses) curses="no"
1015 --enable-curses) curses="yes"
1017 --disable-curl) curl="no"
1019 --enable-curl) curl="yes"
1021 --disable-fdt) fdt="no"
1023 --enable-fdt) fdt="yes"
1025 --disable-linux-aio) linux_aio="no"
1027 --enable-linux-aio) linux_aio="yes"
1029 --disable-attr) attr="no"
1031 --enable-attr) attr="yes"
1033 --disable-blobs) blobs="no"
1035 --with-pkgversion=*) pkgversion=" ($optarg)"
1037 --with-coroutine=*) coroutine="$optarg"
1039 --disable-coroutine-pool) coroutine_pool="no"
1041 --enable-coroutine-pool) coroutine_pool="yes"
1043 --enable-debug-stack-usage) debug_stack_usage="yes"
1045 --disable-docs) docs="no"
1047 --enable-docs) docs="yes"
1049 --disable-vhost-net) vhost_net="no"
1051 --enable-vhost-net) vhost_net="yes"
1053 --disable-vhost-scsi) vhost_scsi="no"
1055 --enable-vhost-scsi) vhost_scsi="yes"
1057 --disable-vhost-vsock) vhost_vsock="no"
1059 --enable-vhost-vsock) vhost_vsock="yes"
1061 --disable-opengl) opengl="no"
1063 --enable-opengl) opengl="yes"
1065 --disable-rbd) rbd="no"
1067 --enable-rbd) rbd="yes"
1069 --disable-xfsctl) xfs="no"
1071 --enable-xfsctl) xfs="yes"
1073 --disable-smartcard) smartcard="no"
1075 --enable-smartcard) smartcard="yes"
1077 --disable-libusb) libusb="no"
1079 --enable-libusb) libusb="yes"
1081 --disable-usb-redir) usb_redir="no"
1083 --enable-usb-redir) usb_redir="yes"
1085 --disable-zlib-test) zlib="no"
1087 --disable-lzo) lzo="no"
1089 --enable-lzo) lzo="yes"
1091 --disable-snappy) snappy="no"
1093 --enable-snappy) snappy="yes"
1095 --disable-bzip2) bzip2="no"
1097 --enable-bzip2) bzip2="yes"
1099 --enable-guest-agent) guest_agent="yes"
1101 --disable-guest-agent) guest_agent="no"
1103 --enable-guest-agent-msi) guest_agent_msi="yes"
1105 --disable-guest-agent-msi) guest_agent_msi="no"
1107 --with-vss-sdk) vss_win32_sdk=""
1109 --with-vss-sdk=*) vss_win32_sdk="$optarg"
1111 --without-vss-sdk) vss_win32_sdk="no"
1113 --with-win-sdk) win_sdk=""
1115 --with-win-sdk=*) win_sdk="$optarg"
1117 --without-win-sdk) win_sdk="no"
1119 --enable-tools) want_tools="yes"
1121 --disable-tools) want_tools="no"
1123 --enable-seccomp) seccomp="yes"
1125 --disable-seccomp) seccomp="no"
1127 --disable-glusterfs) glusterfs="no"
1129 --enable-glusterfs) glusterfs="yes"
1131 --disable-archipelago) archipelago="no"
1133 --enable-archipelago) archipelago="yes"
1135 --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
1136 echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1138 --enable-vhdx|--disable-vhdx)
1139 echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1141 --enable-uuid|--disable-uuid)
1142 echo "$0: $opt is obsolete, UUID support is always built" >&2
1144 --disable-gtk) gtk="no"
1146 --enable-gtk) gtk="yes"
1148 --tls-priority=*) tls_priority="$optarg"
1150 --disable-gnutls) gnutls="no"
1152 --enable-gnutls) gnutls="yes"
1154 --disable-nettle) nettle="no"
1156 --enable-nettle) nettle="yes"
1158 --disable-gcrypt) gcrypt="no"
1160 --enable-gcrypt) gcrypt="yes"
1162 --enable-rdma) rdma="yes"
1164 --disable-rdma) rdma="no"
1166 --with-gtkabi=*) gtkabi="$optarg"
1168 --disable-vte) vte="no"
1170 --enable-vte) vte="yes"
1172 --disable-virglrenderer) virglrenderer="no"
1174 --enable-virglrenderer) virglrenderer="yes"
1176 --disable-tpm) tpm="no"
1178 --enable-tpm) tpm="yes"
1180 --disable-libssh2) libssh2="no"
1182 --enable-libssh2) libssh2="yes"
1184 --disable-numa) numa="no"
1186 --enable-numa) numa="yes"
1188 --disable-tcmalloc) tcmalloc="no"
1190 --enable-tcmalloc) tcmalloc="yes"
1192 --disable-jemalloc) jemalloc="no"
1194 --enable-jemalloc) jemalloc="yes"
1196 --disable-replication) replication="no"
1198 --enable-replication) replication="yes"
1201 echo "ERROR: unknown option $opt"
1202 echo "Try '$0 --help' for more information"
1203 exit 1
1205 esac
1206 done
1208 if ! has $python; then
1209 error_exit "Python not found. Use --python=/path/to/python"
1212 # Note that if the Python conditional here evaluates True we will exit
1213 # with status 1 which is a shell 'false' value.
1214 if ! $python -c 'import sys; sys.exit(sys.version_info < (2,6) or sys.version_info >= (3,))'; then
1215 error_exit "Cannot use '$python', Python 2.6 or later is required." \
1216 "Note that Python 3 or later is not yet supported." \
1217 "Use --python=/path/to/python to specify a supported Python."
1220 # Suppress writing compiled files
1221 python="$python -B"
1223 case "$cpu" in
1224 ppc)
1225 CPU_CFLAGS="-m32"
1226 LDFLAGS="-m32 $LDFLAGS"
1228 ppc64)
1229 CPU_CFLAGS="-m64"
1230 LDFLAGS="-m64 $LDFLAGS"
1232 sparc)
1233 LDFLAGS="-m32 $LDFLAGS"
1234 CPU_CFLAGS="-m32 -mcpu=ultrasparc"
1236 sparc64)
1237 LDFLAGS="-m64 $LDFLAGS"
1238 CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1240 s390)
1241 CPU_CFLAGS="-m31"
1242 LDFLAGS="-m31 $LDFLAGS"
1244 s390x)
1245 CPU_CFLAGS="-m64"
1246 LDFLAGS="-m64 $LDFLAGS"
1248 i386)
1249 CPU_CFLAGS="-m32"
1250 LDFLAGS="-m32 $LDFLAGS"
1251 cc_i386='$(CC) -m32'
1253 x86_64)
1254 # ??? Only extremely old AMD cpus do not have cmpxchg16b.
1255 # If we truly care, we should simply detect this case at
1256 # runtime and generate the fallback to serial emulation.
1257 CPU_CFLAGS="-m64 -mcx16"
1258 LDFLAGS="-m64 $LDFLAGS"
1259 cc_i386='$(CC) -m32'
1261 x32)
1262 CPU_CFLAGS="-mx32"
1263 LDFLAGS="-mx32 $LDFLAGS"
1264 cc_i386='$(CC) -m32'
1266 # No special flags required for other host CPUs
1267 esac
1269 QEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
1270 EXTRA_CFLAGS="$CPU_CFLAGS $EXTRA_CFLAGS"
1272 # For user-mode emulation the host arch has to be one we explicitly
1273 # support, even if we're using TCI.
1274 if [ "$ARCH" = "unknown" ]; then
1275 bsd_user="no"
1276 linux_user="no"
1279 default_target_list=""
1281 mak_wilds=""
1283 if [ "$softmmu" = "yes" ]; then
1284 mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
1286 if [ "$linux_user" = "yes" ]; then
1287 mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
1289 if [ "$bsd_user" = "yes" ]; then
1290 mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
1293 for config in $mak_wilds; do
1294 default_target_list="${default_target_list} $(basename "$config" .mak)"
1295 done
1297 if test x"$show_help" = x"yes" ; then
1298 cat << EOF
1300 Usage: configure [options]
1301 Options: [defaults in brackets after descriptions]
1303 Standard options:
1304 --help print this message
1305 --prefix=PREFIX install in PREFIX [$prefix]
1306 --interp-prefix=PREFIX where to find shared libraries, etc.
1307 use %M for cpu name [$interp_prefix]
1308 --target-list=LIST set target list (default: build everything)
1309 $(echo Available targets: $default_target_list | \
1310 fold -s -w 53 | sed -e 's/^/ /')
1312 Advanced options (experts only):
1313 --source-path=PATH path of source code [$source_path]
1314 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
1315 --cc=CC use C compiler CC [$cc]
1316 --iasl=IASL use ACPI compiler IASL [$iasl]
1317 --host-cc=CC use C compiler CC [$host_cc] for code run at
1318 build time
1319 --cxx=CXX use C++ compiler CXX [$cxx]
1320 --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
1321 --extra-cflags=CFLAGS append extra C compiler flags QEMU_CFLAGS
1322 --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS
1323 --make=MAKE use specified make [$make]
1324 --install=INSTALL use specified install [$install]
1325 --python=PYTHON use specified python [$python]
1326 --smbd=SMBD use specified smbd [$smbd]
1327 --static enable static build [$static]
1328 --mandir=PATH install man pages in PATH
1329 --datadir=PATH install firmware in PATH$confsuffix
1330 --docdir=PATH install documentation in PATH$confsuffix
1331 --bindir=PATH install binaries in PATH
1332 --libdir=PATH install libraries in PATH
1333 --sysconfdir=PATH install config in PATH$confsuffix
1334 --localstatedir=PATH install local state in PATH (set at runtime on win32)
1335 --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
1336 --enable-debug enable common debug build options
1337 --disable-strip disable stripping binaries
1338 --disable-werror disable compilation abort on warning
1339 --disable-stack-protector disable compiler-provided stack protection
1340 --audio-drv-list=LIST set audio drivers list:
1341 Available drivers: $audio_possible_drivers
1342 --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L
1343 --block-drv-rw-whitelist=L
1344 set block driver read-write whitelist
1345 (affects only QEMU, not qemu-img)
1346 --block-drv-ro-whitelist=L
1347 set block driver read-only whitelist
1348 (affects only QEMU, not qemu-img)
1349 --enable-trace-backends=B Set trace backend
1350 Available backends: $($python $source_path/scripts/tracetool.py --list-backends)
1351 --with-trace-file=NAME Full PATH,NAME of file to store traces
1352 Default:trace-<pid>
1353 --disable-slirp disable SLIRP userspace network connectivity
1354 --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
1355 --oss-lib path to OSS library
1356 --cpu=CPU Build for host CPU [$cpu]
1357 --with-coroutine=BACKEND coroutine backend. Supported options:
1358 gthread, ucontext, sigaltstack, windows
1359 --enable-gcov enable test coverage analysis with gcov
1360 --gcov=GCOV use specified gcov [$gcov_tool]
1361 --disable-blobs disable installing provided firmware blobs
1362 --with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent
1363 --with-win-sdk=SDK-path path to Windows Platform SDK (to build VSS .tlb)
1364 --tls-priority default TLS protocol/cipher priority string
1366 Optional features, enabled with --enable-FEATURE and
1367 disabled with --disable-FEATURE, default is enabled if available:
1369 system all system emulation targets
1370 user supported user emulation targets
1371 linux-user all linux usermode emulation targets
1372 bsd-user all BSD usermode emulation targets
1373 docs build documentation
1374 guest-agent build the QEMU Guest Agent
1375 guest-agent-msi build guest agent Windows MSI installation package
1376 pie Position Independent Executables
1377 modules modules support
1378 debug-tcg TCG debugging (default is disabled)
1379 debug-info debugging information
1380 sparse sparse checker
1382 gnutls GNUTLS cryptography support
1383 nettle nettle cryptography support
1384 gcrypt libgcrypt cryptography support
1385 sdl SDL UI
1386 --with-sdlabi select preferred SDL ABI 1.2 or 2.0
1387 gtk gtk UI
1388 --with-gtkabi select preferred GTK ABI 2.0 or 3.0
1389 vte vte support for the gtk UI
1390 curses curses UI
1391 vnc VNC UI support
1392 vnc-sasl SASL encryption for VNC server
1393 vnc-jpeg JPEG lossy compression for VNC server
1394 vnc-png PNG compression for VNC server
1395 cocoa Cocoa UI (Mac OS X only)
1396 virtfs VirtFS
1397 xen xen backend driver support
1398 xen-pci-passthrough
1399 brlapi BrlAPI (Braile)
1400 curl curl connectivity
1401 fdt fdt device tree
1402 bluez bluez stack connectivity
1403 kvm KVM acceleration support
1404 hax HAX acceleration support
1405 rdma RDMA-based migration support
1406 vde support for vde network
1407 netmap support for netmap network
1408 linux-aio Linux AIO support
1409 cap-ng libcap-ng support
1410 attr attr and xattr support
1411 vhost-net vhost-net acceleration support
1412 spice spice
1413 rbd rados block device (rbd)
1414 libiscsi iscsi support
1415 libnfs nfs support
1416 smartcard smartcard support (libcacard)
1417 libusb libusb (for usb passthrough)
1418 usb-redir usb network redirection support
1419 lzo support of lzo compression library
1420 snappy support of snappy compression library
1421 bzip2 support of bzip2 compression library
1422 (for reading bzip2-compressed dmg images)
1423 seccomp seccomp support
1424 coroutine-pool coroutine freelist (better performance)
1425 glusterfs GlusterFS backend
1426 archipelago Archipelago backend
1427 tpm TPM support
1428 libssh2 ssh block device support
1429 numa libnuma support
1430 tcmalloc tcmalloc support
1431 jemalloc jemalloc support
1432 replication replication support
1434 NOTE: The object files are built at the place where configure is launched
1436 exit 0
1439 # Now we have handled --enable-tcg-interpreter and know we're not just
1440 # printing the help message, bail out if the host CPU isn't supported.
1441 if test "$ARCH" = "unknown"; then
1442 if test "$tcg_interpreter" = "yes" ; then
1443 echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1444 else
1445 error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1449 # Consult white-list to determine whether to enable werror
1450 # by default. Only enable by default for git builds
1451 if test -z "$werror" ; then
1452 if test -d "$source_path/.git" -a \
1453 \( "$linux" = "yes" -o "$mingw32" = "yes" \) ; then
1454 werror="yes"
1455 else
1456 werror="no"
1460 # check that the C compiler works.
1461 write_c_skeleton;
1462 if compile_object ; then
1463 : C compiler works ok
1464 else
1465 error_exit "\"$cc\" either does not exist or does not work"
1467 if ! compile_prog ; then
1468 error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
1471 # Check that the C++ compiler exists and works with the C compiler
1472 if has $cxx; then
1473 cat > $TMPC <<EOF
1474 int c_function(void);
1475 int main(void) { return c_function(); }
1478 compile_object
1480 cat > $TMPCXX <<EOF
1481 extern "C" {
1482 int c_function(void);
1484 int c_function(void) { return 42; }
1487 update_cxxflags
1489 if do_cxx $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $LDFLAGS; then
1490 # C++ compiler $cxx works ok with C compiler $cc
1492 else
1493 echo "C++ compiler $cxx does not work with C compiler $cc"
1494 echo "Disabling C++ specific optional code"
1495 cxx=
1497 else
1498 echo "No C++ compiler available; disabling C++ specific optional code"
1499 cxx=
1502 gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
1503 gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
1504 gcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1505 gcc_flags="-Wunused-but-set-variable $gcc_flags"
1506 gcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
1507 gcc_flags="-Wno-initializer-overrides $gcc_flags"
1508 gcc_flags="-Wno-string-plus-int $gcc_flags"
1509 # Note that we do not add -Werror to gcc_flags here, because that would
1510 # enable it for all configure tests. If a configure test failed due
1511 # to -Werror this would just silently disable some features,
1512 # so it's too error prone.
1514 cc_has_warning_flag() {
1515 write_c_skeleton;
1517 # Use the positive sense of the flag when testing for -Wno-wombat
1518 # support (gcc will happily accept the -Wno- form of unknown
1519 # warning options).
1520 optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
1521 compile_prog "-Werror $optflag" ""
1524 for flag in $gcc_flags; do
1525 if cc_has_warning_flag $flag ; then
1526 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1528 done
1530 if test "$mingw32" = "yes"; then
1531 stack_protector="no"
1533 if test "$stack_protector" != "no"; then
1534 cat > $TMPC << EOF
1535 int main(int argc, char *argv[])
1537 char arr[64], *p = arr, *c = argv[0];
1538 while (*c) {
1539 *p++ = *c++;
1541 return 0;
1544 gcc_flags="-fstack-protector-strong -fstack-protector-all"
1545 sp_on=0
1546 for flag in $gcc_flags; do
1547 # We need to check both a compile and a link, since some compiler
1548 # setups fail only on a .c->.o compile and some only at link time
1549 if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
1550 compile_prog "-Werror $flag" ""; then
1551 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1552 sp_on=1
1553 break
1555 done
1556 if test "$stack_protector" = yes; then
1557 if test $sp_on = 0; then
1558 error_exit "Stack protector not supported"
1563 # Workaround for http://gcc.gnu.org/PR55489. Happens with -fPIE/-fPIC and
1564 # large functions that use global variables. The bug is in all releases of
1565 # GCC, but it became particularly acute in 4.6.x and 4.7.x. It is fixed in
1566 # 4.7.3 and 4.8.0. We should be able to delete this at the end of 2013.
1567 cat > $TMPC << EOF
1568 #if __GNUC__ == 4 && (__GNUC_MINOR__ == 6 || (__GNUC_MINOR__ == 7 && __GNUC_PATCHLEVEL__ <= 2))
1569 int main(void) { return 0; }
1570 #else
1571 #error No bug in this compiler.
1572 #endif
1574 if compile_prog "-Werror -fno-gcse" "" ; then
1575 TRANSLATE_OPT_CFLAGS=-fno-gcse
1578 if test "$static" = "yes" ; then
1579 if test "$modules" = "yes" ; then
1580 error_exit "static and modules are mutually incompatible"
1582 if test "$pie" = "yes" ; then
1583 error_exit "static and pie are mutually incompatible"
1584 else
1585 pie="no"
1589 # Unconditional check for compiler __thread support
1590 cat > $TMPC << EOF
1591 static __thread int tls_var;
1592 int main(void) { return tls_var; }
1595 if ! compile_prog "-Werror" "" ; then
1596 error_exit "Your compiler does not support the __thread specifier for " \
1597 "Thread-Local Storage (TLS). Please upgrade to a version that does."
1600 if test "$pie" = ""; then
1601 case "$cpu-$targetos" in
1602 i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
1605 pie="no"
1607 esac
1610 if test "$pie" != "no" ; then
1611 cat > $TMPC << EOF
1613 #ifdef __linux__
1614 # define THREAD __thread
1615 #else
1616 # define THREAD
1617 #endif
1619 static THREAD int tls_var;
1621 int main(void) { return tls_var; }
1624 if compile_prog "-fPIE -DPIE" "-pie"; then
1625 QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
1626 LDFLAGS="-pie $LDFLAGS"
1627 pie="yes"
1628 if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
1629 LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
1631 else
1632 if test "$pie" = "yes"; then
1633 error_exit "PIE not available due to missing toolchain support"
1634 else
1635 echo "Disabling PIE due to missing toolchain support"
1636 pie="no"
1640 if compile_prog "-Werror -fno-pie" "-nopie"; then
1641 CFLAGS_NOPIE="-fno-pie"
1642 LDFLAGS_NOPIE="-nopie"
1646 ##########################################
1647 # __sync_fetch_and_and requires at least -march=i486. Many toolchains
1648 # use i686 as default anyway, but for those that don't, an explicit
1649 # specification is necessary
1651 if test "$cpu" = "i386"; then
1652 cat > $TMPC << EOF
1653 static int sfaa(int *ptr)
1655 return __sync_fetch_and_and(ptr, 0);
1658 int main(void)
1660 int val = 42;
1661 val = __sync_val_compare_and_swap(&val, 0, 1);
1662 sfaa(&val);
1663 return val;
1666 if ! compile_prog "" "" ; then
1667 QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
1671 #########################################
1672 # Solaris specific configure tool chain decisions
1674 if test "$solaris" = "yes" ; then
1675 if has $install; then
1677 else
1678 error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
1679 "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
1680 "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1682 if test "$(path_of $install)" = "/usr/sbin/install" ; then
1683 error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
1684 "try ginstall from the GNU fileutils available from www.blastwave.org" \
1685 "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1687 if has ar; then
1689 else
1690 if test -f /usr/ccs/bin/ar ; then
1691 error_exit "No path includes ar" \
1692 "Add /usr/ccs/bin to your path and rerun configure"
1694 error_exit "No path includes ar"
1698 if test -z "${target_list+xxx}" ; then
1699 target_list="$default_target_list"
1700 else
1701 target_list=$(echo "$target_list" | sed -e 's/,/ /g')
1704 # Check that we recognised the target name; this allows a more
1705 # friendly error message than if we let it fall through.
1706 for target in $target_list; do
1707 case " $default_target_list " in
1708 *" $target "*)
1711 error_exit "Unknown target name '$target'"
1713 esac
1714 done
1716 # see if system emulation was really requested
1717 case " $target_list " in
1718 *"-softmmu "*) softmmu=yes
1720 *) softmmu=no
1722 esac
1724 feature_not_found() {
1725 feature=$1
1726 remedy=$2
1728 error_exit "User requested feature $feature" \
1729 "configure was not able to find it." \
1730 "$remedy"
1733 # ---
1734 # big/little endian test
1735 cat > $TMPC << EOF
1736 short big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
1737 short little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
1738 extern int foo(short *, short *);
1739 int main(int argc, char *argv[]) {
1740 return foo(big_endian, little_endian);
1744 if compile_object ; then
1745 if grep -q BiGeNdIaN $TMPO ; then
1746 bigendian="yes"
1747 elif grep -q LiTtLeEnDiAn $TMPO ; then
1748 bigendian="no"
1749 else
1750 echo big/little test failed
1752 else
1753 echo big/little test failed
1756 ##########################################
1757 # cocoa implies not SDL or GTK
1758 # (the cocoa UI code currently assumes it is always the active UI
1759 # and doesn't interact well with other UI frontend code)
1760 if test "$cocoa" = "yes"; then
1761 if test "$sdl" = "yes"; then
1762 error_exit "Cocoa and SDL UIs cannot both be enabled at once"
1764 if test "$gtk" = "yes"; then
1765 error_exit "Cocoa and GTK UIs cannot both be enabled at once"
1767 gtk=no
1768 sdl=no
1771 # Some versions of Mac OS X incorrectly define SIZE_MAX
1772 cat > $TMPC << EOF
1773 #include <stdint.h>
1774 #include <stdio.h>
1775 int main(int argc, char *argv[]) {
1776 return printf("%zu", SIZE_MAX);
1779 have_broken_size_max=no
1780 if ! compile_object -Werror ; then
1781 have_broken_size_max=yes
1784 ##########################################
1785 # L2TPV3 probe
1787 cat > $TMPC <<EOF
1788 #include <sys/socket.h>
1789 #include <linux/ip.h>
1790 int main(void) { return sizeof(struct mmsghdr); }
1792 if compile_prog "" "" ; then
1793 l2tpv3=yes
1794 else
1795 l2tpv3=no
1798 ##########################################
1799 # MinGW / Mingw-w64 localtime_r/gmtime_r check
1801 if test "$mingw32" = "yes"; then
1802 # Some versions of MinGW / Mingw-w64 lack localtime_r
1803 # and gmtime_r entirely.
1805 # Some versions of Mingw-w64 define a macro for
1806 # localtime_r/gmtime_r.
1808 # Some versions of Mingw-w64 will define functions
1809 # for localtime_r/gmtime_r, but only if you have
1810 # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
1811 # though, unistd.h and pthread.h both define
1812 # that for you.
1814 # So this #undef localtime_r and #include <unistd.h>
1815 # are not in fact redundant.
1816 cat > $TMPC << EOF
1817 #include <unistd.h>
1818 #include <time.h>
1819 #undef localtime_r
1820 int main(void) { localtime_r(NULL, NULL); return 0; }
1822 if compile_prog "" "" ; then
1823 localtime_r="yes"
1824 else
1825 localtime_r="no"
1829 ##########################################
1830 # pkg-config probe
1832 if ! has "$pkg_config_exe"; then
1833 error_exit "pkg-config binary '$pkg_config_exe' not found"
1836 ##########################################
1837 # NPTL probe
1839 if test "$linux_user" = "yes"; then
1840 cat > $TMPC <<EOF
1841 #include <sched.h>
1842 #include <linux/futex.h>
1843 int main(void) {
1844 #if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1845 #error bork
1846 #endif
1847 return 0;
1850 if ! compile_object ; then
1851 feature_not_found "nptl" "Install glibc and linux kernel headers."
1855 ##########################################
1856 # avx2 optimization requirement check
1858 cat > $TMPC << EOF
1859 #pragma GCC push_options
1860 #pragma GCC target("avx2")
1861 #include <cpuid.h>
1862 #include <immintrin.h>
1863 static int bar(void *a) {
1864 __m256i x = *(__m256i *)a;
1865 return _mm256_testz_si256(x, x);
1867 int main(int argc, char *argv[]) { return bar(argv[0]); }
1869 if compile_object "" ; then
1870 avx2_opt="yes"
1873 ##########################################
1874 # lzo check
1876 if test "$lzo" != "no" ; then
1877 cat > $TMPC << EOF
1878 #include <lzo/lzo1x.h>
1879 int main(void) { lzo_version(); return 0; }
1881 if compile_prog "" "-llzo2" ; then
1882 libs_softmmu="$libs_softmmu -llzo2"
1883 lzo="yes"
1884 else
1885 if test "$lzo" = "yes"; then
1886 feature_not_found "liblzo2" "Install liblzo2 devel"
1888 lzo="no"
1892 ##########################################
1893 # snappy check
1895 if test "$snappy" != "no" ; then
1896 cat > $TMPC << EOF
1897 #include <snappy-c.h>
1898 int main(void) { snappy_max_compressed_length(4096); return 0; }
1900 if compile_prog "" "-lsnappy" ; then
1901 libs_softmmu="$libs_softmmu -lsnappy"
1902 snappy="yes"
1903 else
1904 if test "$snappy" = "yes"; then
1905 feature_not_found "libsnappy" "Install libsnappy devel"
1907 snappy="no"
1911 ##########################################
1912 # bzip2 check
1914 if test "$bzip2" != "no" ; then
1915 cat > $TMPC << EOF
1916 #include <bzlib.h>
1917 int main(void) { BZ2_bzlibVersion(); return 0; }
1919 if compile_prog "" "-lbz2" ; then
1920 bzip2="yes"
1921 else
1922 if test "$bzip2" = "yes"; then
1923 feature_not_found "libbzip2" "Install libbzip2 devel"
1925 bzip2="no"
1929 ##########################################
1930 # libseccomp check
1932 if test "$seccomp" != "no" ; then
1933 case "$cpu" in
1934 i386|x86_64)
1935 libseccomp_minver="2.1.0"
1937 mips)
1938 libseccomp_minver="2.2.0"
1940 arm|aarch64)
1941 libseccomp_minver="2.2.3"
1943 ppc|ppc64)
1944 libseccomp_minver="2.3.0"
1947 libseccomp_minver=""
1949 esac
1951 if test "$libseccomp_minver" != "" &&
1952 $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
1953 libs_softmmu="$libs_softmmu $($pkg_config --libs libseccomp)"
1954 QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags libseccomp)"
1955 seccomp="yes"
1956 else
1957 if test "$seccomp" = "yes" ; then
1958 if test "$libseccomp_minver" != "" ; then
1959 feature_not_found "libseccomp" \
1960 "Install libseccomp devel >= $libseccomp_minver"
1961 else
1962 feature_not_found "libseccomp" \
1963 "libseccomp is not supported for host cpu $cpu"
1966 seccomp="no"
1969 ##########################################
1970 # xen probe
1972 if test "$xen" != "no" ; then
1973 xen_libs="-lxenstore -lxenctrl -lxenguest"
1974 xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
1976 # First we test whether Xen headers and libraries are available.
1977 # If no, we are done and there is no Xen support.
1978 # If yes, more tests are run to detect the Xen version.
1980 # Xen (any)
1981 cat > $TMPC <<EOF
1982 #include <xenctrl.h>
1983 int main(void) {
1984 return 0;
1987 if ! compile_prog "" "$xen_libs" ; then
1988 # Xen not found
1989 if test "$xen" = "yes" ; then
1990 feature_not_found "xen" "Install xen devel"
1992 xen=no
1994 # Xen unstable
1995 elif
1996 cat > $TMPC <<EOF &&
1998 * If we have stable libs the we don't want the libxc compat
1999 * layers, regardless of what CFLAGS we may have been given.
2001 * Also, check if xengnttab_grant_copy_segment_t is defined and
2002 * grant copy operation is implemented.
2004 #undef XC_WANT_COMPAT_EVTCHN_API
2005 #undef XC_WANT_COMPAT_GNTTAB_API
2006 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2007 #include <xenctrl.h>
2008 #include <xenstore.h>
2009 #include <xenevtchn.h>
2010 #include <xengnttab.h>
2011 #include <xenforeignmemory.h>
2012 #include <stdint.h>
2013 #include <xen/hvm/hvm_info_table.h>
2014 #if !defined(HVM_MAX_VCPUS)
2015 # error HVM_MAX_VCPUS not defined
2016 #endif
2017 int main(void) {
2018 xc_interface *xc = NULL;
2019 xenforeignmemory_handle *xfmem;
2020 xenevtchn_handle *xe;
2021 xengnttab_handle *xg;
2022 xen_domain_handle_t handle;
2023 xengnttab_grant_copy_segment_t* seg = NULL;
2025 xs_daemon_open();
2027 xc = xc_interface_open(0, 0, 0);
2028 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2029 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2030 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2031 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2032 xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2034 xfmem = xenforeignmemory_open(0, 0);
2035 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2037 xe = xenevtchn_open(0, 0);
2038 xenevtchn_fd(xe);
2040 xg = xengnttab_open(0, 0);
2041 xengnttab_grant_copy(xg, 0, seg);
2043 return 0;
2046 compile_prog "" "$xen_libs $xen_stable_libs"
2047 then
2048 xen_ctrl_version=480
2049 xen=yes
2050 elif
2051 cat > $TMPC <<EOF &&
2053 * If we have stable libs the we don't want the libxc compat
2054 * layers, regardless of what CFLAGS we may have been given.
2056 #undef XC_WANT_COMPAT_EVTCHN_API
2057 #undef XC_WANT_COMPAT_GNTTAB_API
2058 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2059 #include <xenctrl.h>
2060 #include <xenstore.h>
2061 #include <xenevtchn.h>
2062 #include <xengnttab.h>
2063 #include <xenforeignmemory.h>
2064 #include <stdint.h>
2065 #include <xen/hvm/hvm_info_table.h>
2066 #if !defined(HVM_MAX_VCPUS)
2067 # error HVM_MAX_VCPUS not defined
2068 #endif
2069 int main(void) {
2070 xc_interface *xc = NULL;
2071 xenforeignmemory_handle *xfmem;
2072 xenevtchn_handle *xe;
2073 xengnttab_handle *xg;
2074 xen_domain_handle_t handle;
2076 xs_daemon_open();
2078 xc = xc_interface_open(0, 0, 0);
2079 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2080 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2081 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2082 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2083 xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2085 xfmem = xenforeignmemory_open(0, 0);
2086 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2088 xe = xenevtchn_open(0, 0);
2089 xenevtchn_fd(xe);
2091 xg = xengnttab_open(0, 0);
2092 xengnttab_map_grant_ref(xg, 0, 0, 0);
2094 return 0;
2097 compile_prog "" "$xen_libs $xen_stable_libs"
2098 then
2099 xen_ctrl_version=471
2100 xen=yes
2101 elif
2102 cat > $TMPC <<EOF &&
2103 #include <xenctrl.h>
2104 #include <stdint.h>
2105 int main(void) {
2106 xc_interface *xc = NULL;
2107 xen_domain_handle_t handle;
2108 xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2109 return 0;
2112 compile_prog "" "$xen_libs"
2113 then
2114 xen_ctrl_version=470
2115 xen=yes
2117 # Xen 4.6
2118 elif
2119 cat > $TMPC <<EOF &&
2120 #include <xenctrl.h>
2121 #include <xenstore.h>
2122 #include <stdint.h>
2123 #include <xen/hvm/hvm_info_table.h>
2124 #if !defined(HVM_MAX_VCPUS)
2125 # error HVM_MAX_VCPUS not defined
2126 #endif
2127 int main(void) {
2128 xc_interface *xc;
2129 xs_daemon_open();
2130 xc = xc_interface_open(0, 0, 0);
2131 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2132 xc_gnttab_open(NULL, 0);
2133 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2134 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2135 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2136 xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2137 return 0;
2140 compile_prog "" "$xen_libs"
2141 then
2142 xen_ctrl_version=460
2143 xen=yes
2145 # Xen 4.5
2146 elif
2147 cat > $TMPC <<EOF &&
2148 #include <xenctrl.h>
2149 #include <xenstore.h>
2150 #include <stdint.h>
2151 #include <xen/hvm/hvm_info_table.h>
2152 #if !defined(HVM_MAX_VCPUS)
2153 # error HVM_MAX_VCPUS not defined
2154 #endif
2155 int main(void) {
2156 xc_interface *xc;
2157 xs_daemon_open();
2158 xc = xc_interface_open(0, 0, 0);
2159 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2160 xc_gnttab_open(NULL, 0);
2161 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2162 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2163 xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
2164 return 0;
2167 compile_prog "" "$xen_libs"
2168 then
2169 xen_ctrl_version=450
2170 xen=yes
2172 elif
2173 cat > $TMPC <<EOF &&
2174 #include <xenctrl.h>
2175 #include <xenstore.h>
2176 #include <stdint.h>
2177 #include <xen/hvm/hvm_info_table.h>
2178 #if !defined(HVM_MAX_VCPUS)
2179 # error HVM_MAX_VCPUS not defined
2180 #endif
2181 int main(void) {
2182 xc_interface *xc;
2183 xs_daemon_open();
2184 xc = xc_interface_open(0, 0, 0);
2185 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2186 xc_gnttab_open(NULL, 0);
2187 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2188 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2189 return 0;
2192 compile_prog "" "$xen_libs"
2193 then
2194 xen_ctrl_version=420
2195 xen=yes
2197 else
2198 if test "$xen" = "yes" ; then
2199 feature_not_found "xen (unsupported version)" \
2200 "Install a supported xen (xen 4.2 or newer)"
2202 xen=no
2205 if test "$xen" = yes; then
2206 if test $xen_ctrl_version -ge 471 ; then
2207 libs_softmmu="$xen_stable_libs $libs_softmmu"
2209 libs_softmmu="$xen_libs $libs_softmmu"
2213 if test "$xen_pci_passthrough" != "no"; then
2214 if test "$xen" = "yes" && test "$linux" = "yes"; then
2215 xen_pci_passthrough=yes
2216 else
2217 if test "$xen_pci_passthrough" = "yes"; then
2218 error_exit "User requested feature Xen PCI Passthrough" \
2219 " but this feature requires /sys from Linux"
2221 xen_pci_passthrough=no
2225 if test "$xen_pv_domain_build" = "yes" &&
2226 test "$xen" != "yes"; then
2227 error_exit "User requested Xen PV domain builder support" \
2228 "which requires Xen support."
2231 ##########################################
2232 # Sparse probe
2233 if test "$sparse" != "no" ; then
2234 if has cgcc; then
2235 sparse=yes
2236 else
2237 if test "$sparse" = "yes" ; then
2238 feature_not_found "sparse" "Install sparse binary"
2240 sparse=no
2244 ##########################################
2245 # X11 probe
2246 x11_cflags=
2247 x11_libs=-lX11
2248 if $pkg_config --exists "x11"; then
2249 x11_cflags=$($pkg_config --cflags x11)
2250 x11_libs=$($pkg_config --libs x11)
2253 ##########################################
2254 # GTK probe
2256 if test "$gtkabi" = ""; then
2257 # The GTK ABI was not specified explicitly, so try whether 2.0 is available.
2258 # Use 3.0 as a fallback if that is available.
2259 if $pkg_config --exists "gtk+-2.0 >= 2.18.0"; then
2260 gtkabi=2.0
2261 elif $pkg_config --exists "gtk+-3.0 >= 3.0.0"; then
2262 gtkabi=3.0
2263 else
2264 gtkabi=2.0
2268 if test "$gtk" != "no"; then
2269 gtkpackage="gtk+-$gtkabi"
2270 gtkx11package="gtk+-x11-$gtkabi"
2271 if test "$gtkabi" = "3.0" ; then
2272 gtkversion="3.0.0"
2273 else
2274 gtkversion="2.18.0"
2276 if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
2277 gtk_cflags=$($pkg_config --cflags $gtkpackage)
2278 gtk_libs=$($pkg_config --libs $gtkpackage)
2279 gtk_version=$($pkg_config --modversion $gtkpackage)
2280 if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
2281 gtk_cflags="$gtk_cflags $x11_cflags"
2282 gtk_libs="$gtk_libs $x11_libs"
2284 libs_softmmu="$gtk_libs $libs_softmmu"
2285 gtk="yes"
2286 elif test "$gtk" = "yes"; then
2287 feature_not_found "gtk" "Install gtk2 or gtk3 devel"
2288 else
2289 gtk="no"
2294 ##########################################
2295 # GNUTLS probe
2297 gnutls_works() {
2298 # Unfortunately some distros have bad pkg-config information for gnutls
2299 # such that it claims to exist but you get a compiler error if you try
2300 # to use the options returned by --libs. Specifically, Ubuntu for --static
2301 # builds doesn't work:
2302 # https://bugs.launchpad.net/ubuntu/+source/gnutls26/+bug/1478035
2304 # So sanity check the cflags/libs before assuming gnutls can be used.
2305 if ! $pkg_config --exists "gnutls"; then
2306 return 1
2309 write_c_skeleton
2310 compile_prog "$($pkg_config --cflags gnutls)" "$($pkg_config --libs gnutls)"
2313 gnutls_gcrypt=no
2314 gnutls_nettle=no
2315 if test "$gnutls" != "no"; then
2316 if gnutls_works; then
2317 gnutls_cflags=$($pkg_config --cflags gnutls)
2318 gnutls_libs=$($pkg_config --libs gnutls)
2319 libs_softmmu="$gnutls_libs $libs_softmmu"
2320 libs_tools="$gnutls_libs $libs_tools"
2321 QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
2322 gnutls="yes"
2324 # gnutls_rnd requires >= 2.11.0
2325 if $pkg_config --exists "gnutls >= 2.11.0"; then
2326 gnutls_rnd="yes"
2327 else
2328 gnutls_rnd="no"
2331 if $pkg_config --exists 'gnutls >= 3.0'; then
2332 gnutls_gcrypt=no
2333 gnutls_nettle=yes
2334 elif $pkg_config --exists 'gnutls >= 2.12'; then
2335 case $($pkg_config --libs --static gnutls) in
2336 *gcrypt*)
2337 gnutls_gcrypt=yes
2338 gnutls_nettle=no
2340 *nettle*)
2341 gnutls_gcrypt=no
2342 gnutls_nettle=yes
2345 gnutls_gcrypt=yes
2346 gnutls_nettle=no
2348 esac
2349 else
2350 gnutls_gcrypt=yes
2351 gnutls_nettle=no
2353 elif test "$gnutls" = "yes"; then
2354 feature_not_found "gnutls" "Install gnutls devel"
2355 else
2356 gnutls="no"
2357 gnutls_rnd="no"
2359 else
2360 gnutls_rnd="no"
2364 # If user didn't give a --disable/enable-gcrypt flag,
2365 # then mark as disabled if user requested nettle
2366 # explicitly, or if gnutls links to nettle
2367 if test -z "$gcrypt"
2368 then
2369 if test "$nettle" = "yes" || test "$gnutls_nettle" = "yes"
2370 then
2371 gcrypt="no"
2375 # If user didn't give a --disable/enable-nettle flag,
2376 # then mark as disabled if user requested gcrypt
2377 # explicitly, or if gnutls links to gcrypt
2378 if test -z "$nettle"
2379 then
2380 if test "$gcrypt" = "yes" || test "$gnutls_gcrypt" = "yes"
2381 then
2382 nettle="no"
2386 has_libgcrypt_config() {
2387 if ! has "libgcrypt-config"
2388 then
2389 return 1
2392 if test -n "$cross_prefix"
2393 then
2394 host=$(libgcrypt-config --host)
2395 if test "$host-" != $cross_prefix
2396 then
2397 return 1
2401 return 0
2404 if test "$gcrypt" != "no"; then
2405 if has_libgcrypt_config; then
2406 gcrypt_cflags=$(libgcrypt-config --cflags)
2407 gcrypt_libs=$(libgcrypt-config --libs)
2408 # Debian has remove -lgpg-error from libgcrypt-config
2409 # as it "spreads unnecessary dependencies" which in
2410 # turn breaks static builds...
2411 if test "$static" = "yes"
2412 then
2413 gcrypt_libs="$gcrypt_libs -lgpg-error"
2415 libs_softmmu="$gcrypt_libs $libs_softmmu"
2416 libs_tools="$gcrypt_libs $libs_tools"
2417 QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
2418 gcrypt="yes"
2419 if test -z "$nettle"; then
2420 nettle="no"
2423 cat > $TMPC << EOF
2424 #include <gcrypt.h>
2425 int main(void) {
2426 gcry_kdf_derive(NULL, 0, GCRY_KDF_PBKDF2,
2427 GCRY_MD_SHA256,
2428 NULL, 0, 0, 0, NULL);
2429 return 0;
2432 if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
2433 gcrypt_kdf=yes
2436 cat > $TMPC << EOF
2437 #include <gcrypt.h>
2438 int main(void) {
2439 gcry_mac_hd_t handle;
2440 gcry_mac_open(&handle, GCRY_MAC_HMAC_MD5,
2441 GCRY_MAC_FLAG_SECURE, NULL);
2442 return 0;
2445 if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
2446 gcrypt_hmac=yes
2448 else
2449 if test "$gcrypt" = "yes"; then
2450 feature_not_found "gcrypt" "Install gcrypt devel"
2451 else
2452 gcrypt="no"
2458 if test "$nettle" != "no"; then
2459 if $pkg_config --exists "nettle"; then
2460 nettle_cflags=$($pkg_config --cflags nettle)
2461 nettle_libs=$($pkg_config --libs nettle)
2462 nettle_version=$($pkg_config --modversion nettle)
2463 libs_softmmu="$nettle_libs $libs_softmmu"
2464 libs_tools="$nettle_libs $libs_tools"
2465 QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
2466 nettle="yes"
2468 cat > $TMPC << EOF
2469 #include <stddef.h>
2470 #include <nettle/pbkdf2.h>
2471 int main(void) {
2472 pbkdf2_hmac_sha256(8, NULL, 1000, 8, NULL, 8, NULL);
2473 return 0;
2476 if compile_prog "$nettle_cflags" "$nettle_libs" ; then
2477 nettle_kdf=yes
2479 else
2480 if test "$nettle" = "yes"; then
2481 feature_not_found "nettle" "Install nettle devel"
2482 else
2483 nettle="no"
2488 if test "$gcrypt" = "yes" && test "$nettle" = "yes"
2489 then
2490 error_exit "Only one of gcrypt & nettle can be enabled"
2493 ##########################################
2494 # libtasn1 - only for the TLS creds/session test suite
2496 tasn1=yes
2497 tasn1_cflags=""
2498 tasn1_libs=""
2499 if $pkg_config --exists "libtasn1"; then
2500 tasn1_cflags=$($pkg_config --cflags libtasn1)
2501 tasn1_libs=$($pkg_config --libs libtasn1)
2502 else
2503 tasn1=no
2507 ##########################################
2508 # getifaddrs (for tests/test-io-channel-socket )
2510 have_ifaddrs_h=yes
2511 if ! check_include "ifaddrs.h" ; then
2512 have_ifaddrs_h=no
2515 ##########################################
2516 # VTE probe
2518 if test "$vte" != "no"; then
2519 if test "$gtkabi" = "3.0"; then
2520 vteminversion="0.32.0"
2521 if $pkg_config --exists "vte-2.91"; then
2522 vtepackage="vte-2.91"
2523 else
2524 vtepackage="vte-2.90"
2526 else
2527 vtepackage="vte"
2528 vteminversion="0.24.0"
2530 if $pkg_config --exists "$vtepackage >= $vteminversion"; then
2531 vte_cflags=$($pkg_config --cflags $vtepackage)
2532 vte_libs=$($pkg_config --libs $vtepackage)
2533 vteversion=$($pkg_config --modversion $vtepackage)
2534 libs_softmmu="$vte_libs $libs_softmmu"
2535 vte="yes"
2536 elif test "$vte" = "yes"; then
2537 if test "$gtkabi" = "3.0"; then
2538 feature_not_found "vte" "Install libvte-2.90/2.91 devel"
2539 else
2540 feature_not_found "vte" "Install libvte devel"
2542 else
2543 vte="no"
2547 ##########################################
2548 # SDL probe
2550 # Look for sdl configuration program (pkg-config or sdl-config). Try
2551 # sdl-config even without cross prefix, and favour pkg-config over sdl-config.
2553 if test "$sdlabi" = ""; then
2554 if $pkg_config --exists "sdl"; then
2555 sdlabi=1.2
2556 elif $pkg_config --exists "sdl2"; then
2557 sdlabi=2.0
2558 else
2559 sdlabi=1.2
2563 if test $sdlabi = "2.0"; then
2564 sdl_config=$sdl2_config
2565 sdlname=sdl2
2566 sdlconfigname=sdl2_config
2567 elif test $sdlabi = "1.2"; then
2568 sdlname=sdl
2569 sdlconfigname=sdl_config
2570 else
2571 error_exit "Unknown sdlabi $sdlabi, must be 1.2 or 2.0"
2574 if test "$(basename $sdl_config)" != $sdlconfigname && ! has ${sdl_config}; then
2575 sdl_config=$sdlconfigname
2578 if $pkg_config $sdlname --exists; then
2579 sdlconfig="$pkg_config $sdlname"
2580 sdlversion=$($sdlconfig --modversion 2>/dev/null)
2581 elif has ${sdl_config}; then
2582 sdlconfig="$sdl_config"
2583 sdlversion=$($sdlconfig --version)
2584 else
2585 if test "$sdl" = "yes" ; then
2586 feature_not_found "sdl" "Install SDL devel"
2588 sdl=no
2590 if test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
2591 echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
2594 sdl_too_old=no
2595 if test "$sdl" != "no" ; then
2596 cat > $TMPC << EOF
2597 #include <SDL.h>
2598 #undef main /* We don't want SDL to override our main() */
2599 int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
2601 sdl_cflags=$($sdlconfig --cflags 2>/dev/null)
2602 if test "$static" = "yes" ; then
2603 sdl_libs=$($sdlconfig --static-libs 2>/dev/null)
2604 else
2605 sdl_libs=$($sdlconfig --libs 2>/dev/null)
2607 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
2608 if test $(echo $sdlversion | sed 's/[^0-9]//g') -lt 121 ; then
2609 sdl_too_old=yes
2610 else
2611 sdl=yes
2614 # static link with sdl ? (note: sdl.pc's --static --libs is broken)
2615 if test "$sdl" = "yes" -a "$static" = "yes" ; then
2616 if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
2617 sdl_libs="$sdl_libs $(aalib-config --static-libs 2>/dev/null)"
2618 sdl_cflags="$sdl_cflags $(aalib-config --cflags 2>/dev/null)"
2620 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
2622 else
2623 sdl=no
2625 fi # static link
2626 else # sdl not found
2627 if test "$sdl" = "yes" ; then
2628 feature_not_found "sdl" "Install SDL devel"
2630 sdl=no
2631 fi # sdl compile test
2634 if test "$sdl" = "yes" ; then
2635 cat > $TMPC <<EOF
2636 #include <SDL.h>
2637 #if defined(SDL_VIDEO_DRIVER_X11)
2638 #include <X11/XKBlib.h>
2639 #else
2640 #error No x11 support
2641 #endif
2642 int main(void) { return 0; }
2644 if compile_prog "$sdl_cflags $x11_cflags" "$sdl_libs $x11_libs" ; then
2645 sdl_cflags="$sdl_cflags $x11_cflags"
2646 sdl_libs="$sdl_libs $x11_libs"
2648 libs_softmmu="$sdl_libs $libs_softmmu"
2651 ##########################################
2652 # RDMA needs OpenFabrics libraries
2653 if test "$rdma" != "no" ; then
2654 cat > $TMPC <<EOF
2655 #include <rdma/rdma_cma.h>
2656 int main(void) { return 0; }
2658 rdma_libs="-lrdmacm -libverbs"
2659 if compile_prog "" "$rdma_libs" ; then
2660 rdma="yes"
2661 libs_softmmu="$libs_softmmu $rdma_libs"
2662 else
2663 if test "$rdma" = "yes" ; then
2664 error_exit \
2665 " OpenFabrics librdmacm/libibverbs not present." \
2666 " Your options:" \
2667 " (1) Fast: Install infiniband packages from your distro." \
2668 " (2) Cleanest: Install libraries from www.openfabrics.org" \
2669 " (3) Also: Install softiwarp if you don't have RDMA hardware"
2671 rdma="no"
2675 ##########################################
2676 # VNC SASL detection
2677 if test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
2678 cat > $TMPC <<EOF
2679 #include <sasl/sasl.h>
2680 #include <stdio.h>
2681 int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
2683 # Assuming Cyrus-SASL installed in /usr prefix
2684 vnc_sasl_cflags=""
2685 vnc_sasl_libs="-lsasl2"
2686 if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
2687 vnc_sasl=yes
2688 libs_softmmu="$vnc_sasl_libs $libs_softmmu"
2689 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
2690 else
2691 if test "$vnc_sasl" = "yes" ; then
2692 feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
2694 vnc_sasl=no
2698 ##########################################
2699 # VNC JPEG detection
2700 if test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
2701 if $pkg_config --exists libjpeg; then
2702 vnc_jpeg=yes
2703 libs_softmmu="$libs_softmmu $($pkg_config --libs libjpeg)"
2704 QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags libjpeg)"
2705 else
2706 cat > $TMPC <<EOF
2707 #include <stdio.h>
2708 #include <jpeglib.h>
2709 int main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
2711 vnc_jpeg_cflags=""
2712 vnc_jpeg_libs="-ljpeg"
2713 if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
2714 vnc_jpeg=yes
2715 libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
2716 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
2717 else
2718 if test "$vnc_jpeg" = "yes" ; then
2719 feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
2721 vnc_jpeg=no
2726 ##########################################
2727 # VNC PNG detection
2728 if test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
2729 cat > $TMPC <<EOF
2730 //#include <stdio.h>
2731 #include <png.h>
2732 #include <stddef.h>
2733 int main(void) {
2734 png_structp png_ptr;
2735 png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
2736 return png_ptr != 0;
2739 if $pkg_config libpng --exists; then
2740 vnc_png_cflags=$($pkg_config libpng --cflags)
2741 vnc_png_libs=$($pkg_config libpng --libs)
2742 else
2743 vnc_png_cflags=""
2744 vnc_png_libs="-lpng"
2746 if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
2747 vnc_png=yes
2748 libs_softmmu="$vnc_png_libs $libs_softmmu"
2749 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
2750 else
2751 if test "$vnc_png" = "yes" ; then
2752 feature_not_found "vnc-png" "Install libpng devel"
2754 vnc_png=no
2758 ##########################################
2759 # fnmatch() probe, used for ACL routines
2760 fnmatch="no"
2761 cat > $TMPC << EOF
2762 #include <fnmatch.h>
2763 int main(void)
2765 fnmatch("foo", "foo", 0);
2766 return 0;
2769 if compile_prog "" "" ; then
2770 fnmatch="yes"
2773 ##########################################
2774 # xfsctl() probe, used for file-posix.c
2775 if test "$xfs" != "no" ; then
2776 cat > $TMPC << EOF
2777 #include <stddef.h> /* NULL */
2778 #include <xfs/xfs.h>
2779 int main(void)
2781 xfsctl(NULL, 0, 0, NULL);
2782 return 0;
2785 if compile_prog "" "" ; then
2786 xfs="yes"
2787 else
2788 if test "$xfs" = "yes" ; then
2789 feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
2791 xfs=no
2795 ##########################################
2796 # vde libraries probe
2797 if test "$vde" != "no" ; then
2798 vde_libs="-lvdeplug"
2799 cat > $TMPC << EOF
2800 #include <stddef.h>
2801 #include <libvdeplug.h>
2802 int main(void)
2804 struct vde_open_args a = {0, 0, 0};
2805 char s[] = "";
2806 vde_open(s, s, &a);
2807 return 0;
2810 if compile_prog "" "$vde_libs" ; then
2811 vde=yes
2812 libs_softmmu="$vde_libs $libs_softmmu"
2813 libs_tools="$vde_libs $libs_tools"
2814 else
2815 if test "$vde" = "yes" ; then
2816 feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
2818 vde=no
2822 ##########################################
2823 # netmap support probe
2824 # Apart from looking for netmap headers, we make sure that the host API version
2825 # supports the netmap backend (>=11). The upper bound (15) is meant to simulate
2826 # a minor/major version number. Minor new features will be marked with values up
2827 # to 15, and if something happens that requires a change to the backend we will
2828 # move above 15, submit the backend fixes and modify this two bounds.
2829 if test "$netmap" != "no" ; then
2830 cat > $TMPC << EOF
2831 #include <inttypes.h>
2832 #include <net/if.h>
2833 #include <net/netmap.h>
2834 #include <net/netmap_user.h>
2835 #if (NETMAP_API < 11) || (NETMAP_API > 15)
2836 #error
2837 #endif
2838 int main(void) { return 0; }
2840 if compile_prog "" "" ; then
2841 netmap=yes
2842 else
2843 if test "$netmap" = "yes" ; then
2844 feature_not_found "netmap"
2846 netmap=no
2850 ##########################################
2851 # libcap-ng library probe
2852 if test "$cap_ng" != "no" ; then
2853 cap_libs="-lcap-ng"
2854 cat > $TMPC << EOF
2855 #include <cap-ng.h>
2856 int main(void)
2858 capng_capability_to_name(CAPNG_EFFECTIVE);
2859 return 0;
2862 if compile_prog "" "$cap_libs" ; then
2863 cap_ng=yes
2864 libs_tools="$cap_libs $libs_tools"
2865 else
2866 if test "$cap_ng" = "yes" ; then
2867 feature_not_found "cap_ng" "Install libcap-ng devel"
2869 cap_ng=no
2873 ##########################################
2874 # Sound support libraries probe
2876 audio_drv_probe()
2878 drv=$1
2879 hdr=$2
2880 lib=$3
2881 exp=$4
2882 cfl=$5
2883 cat > $TMPC << EOF
2884 #include <$hdr>
2885 int main(void) { $exp }
2887 if compile_prog "$cfl" "$lib" ; then
2889 else
2890 error_exit "$drv check failed" \
2891 "Make sure to have the $drv libs and headers installed."
2895 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
2896 for drv in $audio_drv_list; do
2897 case $drv in
2898 alsa)
2899 audio_drv_probe $drv alsa/asoundlib.h -lasound \
2900 "return snd_pcm_close((snd_pcm_t *)0);"
2901 libs_softmmu="-lasound $libs_softmmu"
2905 audio_drv_probe $drv pulse/pulseaudio.h "-lpulse" \
2906 "pa_context_set_source_output_volume(NULL, 0, NULL, NULL, NULL); return 0;"
2907 libs_softmmu="-lpulse $libs_softmmu"
2908 audio_pt_int="yes"
2911 coreaudio)
2912 libs_softmmu="-framework CoreAudio $libs_softmmu"
2915 dsound)
2916 libs_softmmu="-lole32 -ldxguid $libs_softmmu"
2917 audio_win_int="yes"
2920 oss)
2921 libs_softmmu="$oss_lib $libs_softmmu"
2924 sdl|wav)
2925 # XXX: Probes for CoreAudio, DirectSound, SDL(?)
2929 echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
2930 error_exit "Unknown driver '$drv' selected" \
2931 "Possible drivers are: $audio_possible_drivers"
2934 esac
2935 done
2937 ##########################################
2938 # BrlAPI probe
2940 if test "$brlapi" != "no" ; then
2941 brlapi_libs="-lbrlapi"
2942 cat > $TMPC << EOF
2943 #include <brlapi.h>
2944 #include <stddef.h>
2945 int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
2947 if compile_prog "" "$brlapi_libs" ; then
2948 brlapi=yes
2949 libs_softmmu="$brlapi_libs $libs_softmmu"
2950 else
2951 if test "$brlapi" = "yes" ; then
2952 feature_not_found "brlapi" "Install brlapi devel"
2954 brlapi=no
2958 ##########################################
2959 # curses probe
2960 if test "$curses" != "no" ; then
2961 if test "$mingw32" = "yes" ; then
2962 curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
2963 curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
2964 else
2965 curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"
2966 curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
2968 curses_found=no
2969 cat > $TMPC << EOF
2970 #include <locale.h>
2971 #include <curses.h>
2972 #include <wchar.h>
2973 int main(void) {
2974 const char *s = curses_version();
2975 wchar_t wch = L'w';
2976 setlocale(LC_ALL, "");
2977 resize_term(0, 0);
2978 addwstr(L"wide chars\n");
2979 addnwstr(&wch, 1);
2980 add_wch(WACS_DEGREE);
2981 return s != 0;
2984 IFS=:
2985 for curses_inc in $curses_inc_list; do
2986 IFS=:
2987 for curses_lib in $curses_lib_list; do
2988 unset IFS
2989 if compile_prog "$curses_inc" "$curses_lib" ; then
2990 curses_found=yes
2991 QEMU_CFLAGS="$curses_inc $QEMU_CFLAGS"
2992 libs_softmmu="$curses_lib $libs_softmmu"
2993 break
2995 done
2996 if test "$curses_found" = yes ; then
2997 break
2999 done
3000 unset IFS
3001 if test "$curses_found" = "yes" ; then
3002 curses=yes
3003 else
3004 if test "$curses" = "yes" ; then
3005 feature_not_found "curses" "Install ncurses devel"
3007 curses=no
3011 ##########################################
3012 # curl probe
3013 if test "$curl" != "no" ; then
3014 if $pkg_config libcurl --exists; then
3015 curlconfig="$pkg_config libcurl"
3016 else
3017 curlconfig=curl-config
3019 cat > $TMPC << EOF
3020 #include <curl/curl.h>
3021 int main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
3023 curl_cflags=$($curlconfig --cflags 2>/dev/null)
3024 curl_libs=$($curlconfig --libs 2>/dev/null)
3025 if compile_prog "$curl_cflags" "$curl_libs" ; then
3026 curl=yes
3027 else
3028 if test "$curl" = "yes" ; then
3029 feature_not_found "curl" "Install libcurl devel"
3031 curl=no
3033 fi # test "$curl"
3035 ##########################################
3036 # bluez support probe
3037 if test "$bluez" != "no" ; then
3038 cat > $TMPC << EOF
3039 #include <bluetooth/bluetooth.h>
3040 int main(void) { return bt_error(0); }
3042 bluez_cflags=$($pkg_config --cflags bluez 2>/dev/null)
3043 bluez_libs=$($pkg_config --libs bluez 2>/dev/null)
3044 if compile_prog "$bluez_cflags" "$bluez_libs" ; then
3045 bluez=yes
3046 libs_softmmu="$bluez_libs $libs_softmmu"
3047 else
3048 if test "$bluez" = "yes" ; then
3049 feature_not_found "bluez" "Install bluez-libs/libbluetooth devel"
3051 bluez="no"
3055 ##########################################
3056 # glib support probe
3058 glib_req_ver=2.22
3059 glib_modules=gthread-2.0
3060 if test "$modules" = yes; then
3061 glib_modules="$glib_modules gmodule-2.0"
3064 for i in $glib_modules; do
3065 if $pkg_config --atleast-version=$glib_req_ver $i; then
3066 glib_cflags=$($pkg_config --cflags $i)
3067 glib_libs=$($pkg_config --libs $i)
3068 QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
3069 LIBS="$glib_libs $LIBS"
3070 libs_qga="$glib_libs $libs_qga"
3071 else
3072 error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3074 done
3076 # Sanity check that the current size_t matches the
3077 # size that glib thinks it should be. This catches
3078 # problems on multi-arch where people try to build
3079 # 32-bit QEMU while pointing at 64-bit glib headers
3080 cat > $TMPC <<EOF
3081 #include <glib.h>
3082 #include <unistd.h>
3084 #define QEMU_BUILD_BUG_ON(x) \
3085 typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3087 int main(void) {
3088 QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3089 return 0;
3093 if ! compile_prog "$CFLAGS" "$LIBS" ; then
3094 error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3095 "You probably need to set PKG_CONFIG_LIBDIR"\
3096 "to point to the right pkg-config files for your"\
3097 "build target"
3100 # g_test_trap_subprocess added in 2.38. Used by some tests.
3101 glib_subprocess=yes
3102 if ! $pkg_config --atleast-version=2.38 glib-2.0; then
3103 glib_subprocess=no
3106 # Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
3107 cat > $TMPC << EOF
3108 #include <glib.h>
3109 int main(void) { return 0; }
3111 if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3112 if cc_has_warning_flag "-Wno-unknown-attributes"; then
3113 glib_cflags="-Wno-unknown-attributes $glib_cflags"
3114 CFLAGS="-Wno-unknown-attributes $CFLAGS"
3118 #########################################
3119 # zlib check
3121 if test "$zlib" != "no" ; then
3122 if $pkg_config --exists zlib; then
3123 zlib_cflags=$($pkg_config --cflags zlib)
3124 zlib_libs=$($pkg_config --libs zlib)
3125 QEMU_CFLAGS="$zlib_cflags $QEMU_CFLAGS"
3126 LIBS="$zlib_libs $LIBS"
3127 else
3128 cat > $TMPC << EOF
3129 #include <zlib.h>
3130 int main(void) { zlibVersion(); return 0; }
3132 if compile_prog "" "-lz" ; then
3133 LIBS="$LIBS -lz"
3134 else
3135 error_exit "zlib check failed" \
3136 "Make sure to have the zlib libs and headers installed."
3141 ##########################################
3142 # SHA command probe for modules
3143 if test "$modules" = yes; then
3144 shacmd_probe="sha1sum sha1 shasum"
3145 for c in $shacmd_probe; do
3146 if has $c; then
3147 shacmd="$c"
3148 break
3150 done
3151 if test "$shacmd" = ""; then
3152 error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3156 ##########################################
3157 # pixman support probe
3159 if test "$pixman" = ""; then
3160 if test "$want_tools" = "no" -a "$softmmu" = "no"; then
3161 pixman="none"
3162 elif $pkg_config --atleast-version=0.21.8 pixman-1 > /dev/null 2>&1; then
3163 pixman="system"
3164 else
3165 pixman="internal"
3168 if test "$pixman" = "none"; then
3169 if test "$want_tools" != "no" -o "$softmmu" != "no"; then
3170 error_exit "pixman disabled but system emulation or tools build" \
3171 "enabled. You can turn off pixman only if you also" \
3172 "disable all system emulation targets and the tools" \
3173 "build with '--disable-tools --disable-system'."
3175 pixman_cflags=
3176 pixman_libs=
3177 elif test "$pixman" = "system"; then
3178 # pixman version has been checked above
3179 pixman_cflags=$($pkg_config --cflags pixman-1)
3180 pixman_libs=$($pkg_config --libs pixman-1)
3181 else
3182 if test ! -d ${source_path}/pixman/pixman; then
3183 error_exit "pixman >= 0.21.8 not present. Your options:" \
3184 " (1) Preferred: Install the pixman devel package (any recent" \
3185 " distro should have packages as Xorg needs pixman too)." \
3186 " (2) Fetch the pixman submodule, using:" \
3187 " git submodule update --init pixman"
3189 mkdir -p pixman/pixman
3190 pixman_cflags="-I\$(SRC_PATH)/pixman/pixman -I\$(BUILD_DIR)/pixman/pixman"
3191 pixman_libs="-L\$(BUILD_DIR)/pixman/pixman/.libs -lpixman-1"
3194 ##########################################
3195 # libcap probe
3197 if test "$cap" != "no" ; then
3198 cat > $TMPC <<EOF
3199 #include <stdio.h>
3200 #include <sys/capability.h>
3201 int main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
3203 if compile_prog "" "-lcap" ; then
3204 cap=yes
3205 else
3206 cap=no
3210 ##########################################
3211 # pthread probe
3212 PTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
3214 pthread=no
3215 cat > $TMPC << EOF
3216 #include <pthread.h>
3217 static void *f(void *p) { return NULL; }
3218 int main(void) {
3219 pthread_t thread;
3220 pthread_create(&thread, 0, f, 0);
3221 return 0;
3224 if compile_prog "" "" ; then
3225 pthread=yes
3226 else
3227 for pthread_lib in $PTHREADLIBS_LIST; do
3228 if compile_prog "" "$pthread_lib" ; then
3229 pthread=yes
3230 found=no
3231 for lib_entry in $LIBS; do
3232 if test "$lib_entry" = "$pthread_lib"; then
3233 found=yes
3234 break
3236 done
3237 if test "$found" = "no"; then
3238 LIBS="$pthread_lib $LIBS"
3240 PTHREAD_LIB="$pthread_lib"
3241 break
3243 done
3246 if test "$mingw32" != yes -a "$pthread" = no; then
3247 error_exit "pthread check failed" \
3248 "Make sure to have the pthread libs and headers installed."
3251 # check for pthread_setname_np
3252 pthread_setname_np=no
3253 cat > $TMPC << EOF
3254 #include <pthread.h>
3256 static void *f(void *p) { return NULL; }
3257 int main(void)
3259 pthread_t thread;
3260 pthread_create(&thread, 0, f, 0);
3261 pthread_setname_np(thread, "QEMU");
3262 return 0;
3265 if compile_prog "" "$pthread_lib" ; then
3266 pthread_setname_np=yes
3269 ##########################################
3270 # rbd probe
3271 if test "$rbd" != "no" ; then
3272 cat > $TMPC <<EOF
3273 #include <stdio.h>
3274 #include <rbd/librbd.h>
3275 int main(void) {
3276 rados_t cluster;
3277 rados_create(&cluster, NULL);
3278 return 0;
3281 rbd_libs="-lrbd -lrados"
3282 if compile_prog "" "$rbd_libs" ; then
3283 rbd=yes
3284 else
3285 if test "$rbd" = "yes" ; then
3286 feature_not_found "rados block device" "Install librbd/ceph devel"
3288 rbd=no
3292 ##########################################
3293 # libssh2 probe
3294 min_libssh2_version=1.2.8
3295 if test "$libssh2" != "no" ; then
3296 if $pkg_config --atleast-version=$min_libssh2_version libssh2; then
3297 libssh2_cflags=$($pkg_config libssh2 --cflags)
3298 libssh2_libs=$($pkg_config libssh2 --libs)
3299 libssh2=yes
3300 else
3301 if test "$libssh2" = "yes" ; then
3302 error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2"
3304 libssh2=no
3308 ##########################################
3309 # libssh2_sftp_fsync probe
3311 if test "$libssh2" = "yes"; then
3312 cat > $TMPC <<EOF
3313 #include <stdio.h>
3314 #include <libssh2.h>
3315 #include <libssh2_sftp.h>
3316 int main(void) {
3317 LIBSSH2_SESSION *session;
3318 LIBSSH2_SFTP *sftp;
3319 LIBSSH2_SFTP_HANDLE *sftp_handle;
3320 session = libssh2_session_init ();
3321 sftp = libssh2_sftp_init (session);
3322 sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0);
3323 libssh2_sftp_fsync (sftp_handle);
3324 return 0;
3327 # libssh2_cflags/libssh2_libs defined in previous test.
3328 if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then
3329 QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS"
3333 ##########################################
3334 # linux-aio probe
3336 if test "$linux_aio" != "no" ; then
3337 cat > $TMPC <<EOF
3338 #include <libaio.h>
3339 #include <sys/eventfd.h>
3340 #include <stddef.h>
3341 int main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
3343 if compile_prog "" "-laio" ; then
3344 linux_aio=yes
3345 else
3346 if test "$linux_aio" = "yes" ; then
3347 feature_not_found "linux AIO" "Install libaio devel"
3349 linux_aio=no
3353 ##########################################
3354 # TPM passthrough is only on x86 Linux
3356 if test "$targetos" = Linux && test "$cpu" = i386 -o "$cpu" = x86_64; then
3357 tpm_passthrough=$tpm
3358 else
3359 tpm_passthrough=no
3362 ##########################################
3363 # attr probe
3365 if test "$attr" != "no" ; then
3366 cat > $TMPC <<EOF
3367 #include <stdio.h>
3368 #include <sys/types.h>
3369 #ifdef CONFIG_LIBATTR
3370 #include <attr/xattr.h>
3371 #else
3372 #include <sys/xattr.h>
3373 #endif
3374 int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
3376 if compile_prog "" "" ; then
3377 attr=yes
3378 # Older distros have <attr/xattr.h>, and need -lattr:
3379 elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
3380 attr=yes
3381 LIBS="-lattr $LIBS"
3382 libattr=yes
3383 else
3384 if test "$attr" = "yes" ; then
3385 feature_not_found "ATTR" "Install libc6 or libattr devel"
3387 attr=no
3391 ##########################################
3392 # iovec probe
3393 cat > $TMPC <<EOF
3394 #include <sys/types.h>
3395 #include <sys/uio.h>
3396 #include <unistd.h>
3397 int main(void) { return sizeof(struct iovec); }
3399 iovec=no
3400 if compile_prog "" "" ; then
3401 iovec=yes
3404 ##########################################
3405 # preadv probe
3406 cat > $TMPC <<EOF
3407 #include <sys/types.h>
3408 #include <sys/uio.h>
3409 #include <unistd.h>
3410 int main(void) { return preadv(0, 0, 0, 0); }
3412 preadv=no
3413 if compile_prog "" "" ; then
3414 preadv=yes
3417 ##########################################
3418 # fdt probe
3419 # fdt support is mandatory for at least some target architectures,
3420 # so insist on it if we're building those system emulators.
3421 fdt_required=no
3422 for target in $target_list; do
3423 case $target in
3424 aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu)
3425 fdt_required=yes
3427 esac
3428 done
3430 if test "$fdt_required" = "yes"; then
3431 if test "$fdt" = "no"; then
3432 error_exit "fdt disabled but some requested targets require it." \
3433 "You can turn off fdt only if you also disable all the system emulation" \
3434 "targets which need it (by specifying a cut down --target-list)."
3436 fdt=yes
3439 if test "$fdt" != "no" ; then
3440 fdt_libs="-lfdt"
3441 # explicitly check for libfdt_env.h as it is missing in some stable installs
3442 # and test for required functions to make sure we are on a version >= 1.4.0
3443 cat > $TMPC << EOF
3444 #include <libfdt.h>
3445 #include <libfdt_env.h>
3446 int main(void) { fdt_get_property_by_offset(0, 0, 0); return 0; }
3448 if compile_prog "" "$fdt_libs" ; then
3449 # system DTC is good - use it
3450 fdt=yes
3451 elif test -d ${source_path}/dtc/libfdt ; then
3452 # have submodule DTC - use it
3453 fdt=yes
3454 dtc_internal="yes"
3455 mkdir -p dtc
3456 if [ "$pwd_is_source_path" != "y" ] ; then
3457 symlink "$source_path/dtc/Makefile" "dtc/Makefile"
3458 symlink "$source_path/dtc/scripts" "dtc/scripts"
3460 fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
3461 fdt_libs="-L\$(BUILD_DIR)/dtc/libfdt $fdt_libs"
3462 elif test "$fdt" = "yes" ; then
3463 # have neither and want - prompt for system/submodule install
3464 error_exit "DTC (libfdt) version >= 1.4.0 not present. Your options:" \
3465 " (1) Preferred: Install the DTC (libfdt) devel package" \
3466 " (2) Fetch the DTC submodule, using:" \
3467 " git submodule update --init dtc"
3468 else
3469 # don't have and don't want
3470 fdt_libs=
3471 fdt=no
3475 libs_softmmu="$libs_softmmu $fdt_libs"
3477 ##########################################
3478 # opengl probe (for sdl2, gtk, milkymist-tmu2)
3480 if test "$opengl" != "no" ; then
3481 opengl_pkgs="epoxy libdrm gbm"
3482 if $pkg_config $opengl_pkgs x11; then
3483 opengl_cflags="$($pkg_config --cflags $opengl_pkgs) $x11_cflags"
3484 opengl_libs="$($pkg_config --libs $opengl_pkgs) $x11_libs"
3485 opengl=yes
3486 if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
3487 gtk_gl="yes"
3489 else
3490 if test "$opengl" = "yes" ; then
3491 feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
3493 opengl_cflags=""
3494 opengl_libs=""
3495 opengl=no
3499 if test "$opengl" = "yes"; then
3500 cat > $TMPC << EOF
3501 #include <epoxy/egl.h>
3502 #ifndef EGL_MESA_image_dma_buf_export
3503 # error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
3504 #endif
3505 int main(void) { return 0; }
3507 if compile_prog "" "" ; then
3508 opengl_dmabuf=yes
3512 ##########################################
3513 # archipelago probe
3514 if test "$archipelago" != "no" ; then
3515 cat > $TMPC <<EOF
3516 #include <stdio.h>
3517 #include <xseg/xseg.h>
3518 #include <xseg/protocol.h>
3519 int main(void) {
3520 xseg_initialize();
3521 return 0;
3524 archipelago_libs=-lxseg
3525 if compile_prog "" "$archipelago_libs"; then
3526 archipelago="yes"
3527 libs_tools="$archipelago_libs $libs_tools"
3528 libs_softmmu="$archipelago_libs $libs_softmmu"
3530 echo "WARNING: Please check the licenses of QEMU and libxseg carefully."
3531 echo "GPLv3 versions of libxseg may not be compatible with QEMU's"
3532 echo "license and therefore prevent redistribution."
3533 echo
3534 echo "To disable Archipelago, use --disable-archipelago"
3535 else
3536 if test "$archipelago" = "yes" ; then
3537 feature_not_found "Archipelago backend support" "Install libxseg devel"
3539 archipelago="no"
3544 ##########################################
3545 # glusterfs probe
3546 if test "$glusterfs" != "no" ; then
3547 if $pkg_config --atleast-version=3 glusterfs-api; then
3548 glusterfs="yes"
3549 glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
3550 glusterfs_libs=$($pkg_config --libs glusterfs-api)
3551 if $pkg_config --atleast-version=4 glusterfs-api; then
3552 glusterfs_xlator_opt="yes"
3554 if $pkg_config --atleast-version=5 glusterfs-api; then
3555 glusterfs_discard="yes"
3557 if $pkg_config --atleast-version=6 glusterfs-api; then
3558 glusterfs_zerofill="yes"
3560 else
3561 if test "$glusterfs" = "yes" ; then
3562 feature_not_found "GlusterFS backend support" \
3563 "Install glusterfs-api devel >= 3"
3565 glusterfs="no"
3569 # Check for inotify functions when we are building linux-user
3570 # emulator. This is done because older glibc versions don't
3571 # have syscall stubs for these implemented. In that case we
3572 # don't provide them even if kernel supports them.
3574 inotify=no
3575 cat > $TMPC << EOF
3576 #include <sys/inotify.h>
3579 main(void)
3581 /* try to start inotify */
3582 return inotify_init();
3585 if compile_prog "" "" ; then
3586 inotify=yes
3589 inotify1=no
3590 cat > $TMPC << EOF
3591 #include <sys/inotify.h>
3594 main(void)
3596 /* try to start inotify */
3597 return inotify_init1(0);
3600 if compile_prog "" "" ; then
3601 inotify1=yes
3604 # check if utimensat and futimens are supported
3605 utimens=no
3606 cat > $TMPC << EOF
3607 #define _ATFILE_SOURCE
3608 #include <stddef.h>
3609 #include <fcntl.h>
3610 #include <sys/stat.h>
3612 int main(void)
3614 utimensat(AT_FDCWD, "foo", NULL, 0);
3615 futimens(0, NULL);
3616 return 0;
3619 if compile_prog "" "" ; then
3620 utimens=yes
3623 # check if pipe2 is there
3624 pipe2=no
3625 cat > $TMPC << EOF
3626 #include <unistd.h>
3627 #include <fcntl.h>
3629 int main(void)
3631 int pipefd[2];
3632 return pipe2(pipefd, O_CLOEXEC);
3635 if compile_prog "" "" ; then
3636 pipe2=yes
3639 # check if accept4 is there
3640 accept4=no
3641 cat > $TMPC << EOF
3642 #include <sys/socket.h>
3643 #include <stddef.h>
3645 int main(void)
3647 accept4(0, NULL, NULL, SOCK_CLOEXEC);
3648 return 0;
3651 if compile_prog "" "" ; then
3652 accept4=yes
3655 # check if tee/splice is there. vmsplice was added same time.
3656 splice=no
3657 cat > $TMPC << EOF
3658 #include <unistd.h>
3659 #include <fcntl.h>
3660 #include <limits.h>
3662 int main(void)
3664 int len, fd = 0;
3665 len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
3666 splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
3667 return 0;
3670 if compile_prog "" "" ; then
3671 splice=yes
3674 ##########################################
3675 # libnuma probe
3677 if test "$numa" != "no" ; then
3678 cat > $TMPC << EOF
3679 #include <numa.h>
3680 int main(void) { return numa_available(); }
3683 if compile_prog "" "-lnuma" ; then
3684 numa=yes
3685 libs_softmmu="-lnuma $libs_softmmu"
3686 else
3687 if test "$numa" = "yes" ; then
3688 feature_not_found "numa" "install numactl devel"
3690 numa=no
3694 if test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
3695 echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
3696 exit 1
3699 ##########################################
3700 # tcmalloc probe
3702 if test "$tcmalloc" = "yes" ; then
3703 cat > $TMPC << EOF
3704 #include <stdlib.h>
3705 int main(void) { malloc(1); return 0; }
3708 if compile_prog "" "-ltcmalloc" ; then
3709 LIBS="-ltcmalloc $LIBS"
3710 else
3711 feature_not_found "tcmalloc" "install gperftools devel"
3715 ##########################################
3716 # jemalloc probe
3718 if test "$jemalloc" = "yes" ; then
3719 cat > $TMPC << EOF
3720 #include <stdlib.h>
3721 int main(void) { malloc(1); return 0; }
3724 if compile_prog "" "-ljemalloc" ; then
3725 LIBS="-ljemalloc $LIBS"
3726 else
3727 feature_not_found "jemalloc" "install jemalloc devel"
3731 ##########################################
3732 # signalfd probe
3733 signalfd="no"
3734 cat > $TMPC << EOF
3735 #include <unistd.h>
3736 #include <sys/syscall.h>
3737 #include <signal.h>
3738 int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
3741 if compile_prog "" "" ; then
3742 signalfd=yes
3745 # check if eventfd is supported
3746 eventfd=no
3747 cat > $TMPC << EOF
3748 #include <sys/eventfd.h>
3750 int main(void)
3752 return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
3755 if compile_prog "" "" ; then
3756 eventfd=yes
3759 # check if memfd is supported
3760 memfd=no
3761 cat > $TMPC << EOF
3762 #include <sys/memfd.h>
3764 int main(void)
3766 return memfd_create("foo", MFD_ALLOW_SEALING);
3769 if compile_prog "" "" ; then
3770 memfd=yes
3775 # check for fallocate
3776 fallocate=no
3777 cat > $TMPC << EOF
3778 #include <fcntl.h>
3780 int main(void)
3782 fallocate(0, 0, 0, 0);
3783 return 0;
3786 if compile_prog "" "" ; then
3787 fallocate=yes
3790 # check for fallocate hole punching
3791 fallocate_punch_hole=no
3792 cat > $TMPC << EOF
3793 #include <fcntl.h>
3794 #include <linux/falloc.h>
3796 int main(void)
3798 fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
3799 return 0;
3802 if compile_prog "" "" ; then
3803 fallocate_punch_hole=yes
3806 # check that fallocate supports range zeroing inside the file
3807 fallocate_zero_range=no
3808 cat > $TMPC << EOF
3809 #include <fcntl.h>
3810 #include <linux/falloc.h>
3812 int main(void)
3814 fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
3815 return 0;
3818 if compile_prog "" "" ; then
3819 fallocate_zero_range=yes
3822 # check for posix_fallocate
3823 posix_fallocate=no
3824 cat > $TMPC << EOF
3825 #include <fcntl.h>
3827 int main(void)
3829 posix_fallocate(0, 0, 0);
3830 return 0;
3833 if compile_prog "" "" ; then
3834 posix_fallocate=yes
3837 # check for sync_file_range
3838 sync_file_range=no
3839 cat > $TMPC << EOF
3840 #include <fcntl.h>
3842 int main(void)
3844 sync_file_range(0, 0, 0, 0);
3845 return 0;
3848 if compile_prog "" "" ; then
3849 sync_file_range=yes
3852 # check for linux/fiemap.h and FS_IOC_FIEMAP
3853 fiemap=no
3854 cat > $TMPC << EOF
3855 #include <sys/ioctl.h>
3856 #include <linux/fs.h>
3857 #include <linux/fiemap.h>
3859 int main(void)
3861 ioctl(0, FS_IOC_FIEMAP, 0);
3862 return 0;
3865 if compile_prog "" "" ; then
3866 fiemap=yes
3869 # check for dup3
3870 dup3=no
3871 cat > $TMPC << EOF
3872 #include <unistd.h>
3874 int main(void)
3876 dup3(0, 0, 0);
3877 return 0;
3880 if compile_prog "" "" ; then
3881 dup3=yes
3884 # check for ppoll support
3885 ppoll=no
3886 cat > $TMPC << EOF
3887 #include <poll.h>
3889 int main(void)
3891 struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
3892 ppoll(&pfd, 1, 0, 0);
3893 return 0;
3896 if compile_prog "" "" ; then
3897 ppoll=yes
3900 # check for prctl(PR_SET_TIMERSLACK , ... ) support
3901 prctl_pr_set_timerslack=no
3902 cat > $TMPC << EOF
3903 #include <sys/prctl.h>
3905 int main(void)
3907 prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
3908 return 0;
3911 if compile_prog "" "" ; then
3912 prctl_pr_set_timerslack=yes
3915 # check for epoll support
3916 epoll=no
3917 cat > $TMPC << EOF
3918 #include <sys/epoll.h>
3920 int main(void)
3922 epoll_create(0);
3923 return 0;
3926 if compile_prog "" "" ; then
3927 epoll=yes
3930 # epoll_create1 is a later addition
3931 # so we must check separately for its presence
3932 epoll_create1=no
3933 cat > $TMPC << EOF
3934 #include <sys/epoll.h>
3936 int main(void)
3938 /* Note that we use epoll_create1 as a value, not as
3939 * a function being called. This is necessary so that on
3940 * old SPARC glibc versions where the function was present in
3941 * the library but not declared in the header file we will
3942 * fail the configure check. (Otherwise we will get a compiler
3943 * warning but not an error, and will proceed to fail the
3944 * qemu compile where we compile with -Werror.)
3946 return (int)(uintptr_t)&epoll_create1;
3949 if compile_prog "" "" ; then
3950 epoll_create1=yes
3953 # check for sendfile support
3954 sendfile=no
3955 cat > $TMPC << EOF
3956 #include <sys/sendfile.h>
3958 int main(void)
3960 return sendfile(0, 0, 0, 0);
3963 if compile_prog "" "" ; then
3964 sendfile=yes
3967 # check for timerfd support (glibc 2.8 and newer)
3968 timerfd=no
3969 cat > $TMPC << EOF
3970 #include <sys/timerfd.h>
3972 int main(void)
3974 return(timerfd_create(CLOCK_REALTIME, 0));
3977 if compile_prog "" "" ; then
3978 timerfd=yes
3981 # check for setns and unshare support
3982 setns=no
3983 cat > $TMPC << EOF
3984 #include <sched.h>
3986 int main(void)
3988 int ret;
3989 ret = setns(0, 0);
3990 ret = unshare(0);
3991 return ret;
3994 if compile_prog "" "" ; then
3995 setns=yes
3998 # clock_adjtime probe
3999 clock_adjtime=no
4000 cat > $TMPC <<EOF
4001 #include <time.h>
4003 int main(void)
4005 return clock_adjtime(0, 0);
4008 clock_adjtime=no
4009 if compile_prog "" "" ; then
4010 clock_adjtime=yes
4013 # syncfs probe
4014 syncfs=no
4015 cat > $TMPC <<EOF
4016 #include <unistd.h>
4018 int main(void)
4020 return syncfs(0);
4023 syncfs=no
4024 if compile_prog "" "" ; then
4025 syncfs=yes
4028 # Check if tools are available to build documentation.
4029 if test "$docs" != "no" ; then
4030 if has makeinfo && has pod2man; then
4031 docs=yes
4032 else
4033 if test "$docs" = "yes" ; then
4034 feature_not_found "docs" "Install texinfo and Perl/perl-podlators"
4036 docs=no
4040 if test "$want_tools" = ""; then
4041 if test $(expr "$target_list" : ".*softmmu.*") != 0; then
4042 want_tools=yes
4043 else
4044 want_tools=no
4048 # Search for bswap_32 function
4049 byteswap_h=no
4050 cat > $TMPC << EOF
4051 #include <byteswap.h>
4052 int main(void) { return bswap_32(0); }
4054 if compile_prog "" "" ; then
4055 byteswap_h=yes
4058 # Search for bswap32 function
4059 bswap_h=no
4060 cat > $TMPC << EOF
4061 #include <sys/endian.h>
4062 #include <sys/types.h>
4063 #include <machine/bswap.h>
4064 int main(void) { return bswap32(0); }
4066 if compile_prog "" "" ; then
4067 bswap_h=yes
4070 ##########################################
4071 # Do we have libiscsi >= 1.9.0
4072 if test "$libiscsi" != "no" ; then
4073 if $pkg_config --atleast-version=1.9.0 libiscsi; then
4074 libiscsi="yes"
4075 libiscsi_cflags=$($pkg_config --cflags libiscsi)
4076 libiscsi_libs=$($pkg_config --libs libiscsi)
4077 else
4078 if test "$libiscsi" = "yes" ; then
4079 feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
4081 libiscsi="no"
4085 ##########################################
4086 # Do we need libm
4087 cat > $TMPC << EOF
4088 #include <math.h>
4089 int main(int argc, char **argv) { return isnan(sin((double)argc)); }
4091 if compile_prog "" "" ; then
4093 elif compile_prog "" "-lm" ; then
4094 LIBS="-lm $LIBS"
4095 libs_qga="-lm $libs_qga"
4096 else
4097 error_exit "libm check failed"
4100 ##########################################
4101 # Do we need librt
4102 # uClibc provides 2 versions of clock_gettime(), one with realtime
4103 # support and one without. This means that the clock_gettime() don't
4104 # need -lrt. We still need it for timer_create() so we check for this
4105 # function in addition.
4106 cat > $TMPC <<EOF
4107 #include <signal.h>
4108 #include <time.h>
4109 int main(void) {
4110 timer_create(CLOCK_REALTIME, NULL, NULL);
4111 return clock_gettime(CLOCK_REALTIME, NULL);
4115 if compile_prog "" "" ; then
4117 # we need pthread for static linking. use previous pthread test result
4118 elif compile_prog "" "$pthread_lib -lrt" ; then
4119 LIBS="$LIBS -lrt"
4120 libs_qga="$libs_qga -lrt"
4123 if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
4124 "$aix" != "yes" -a "$haiku" != "yes" ; then
4125 libs_softmmu="-lutil $libs_softmmu"
4128 ##########################################
4129 # spice probe
4130 if test "$spice" != "no" ; then
4131 cat > $TMPC << EOF
4132 #include <spice.h>
4133 int main(void) { spice_server_new(); return 0; }
4135 spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
4136 spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
4137 if $pkg_config --atleast-version=0.12.0 spice-server && \
4138 $pkg_config --atleast-version=0.12.3 spice-protocol && \
4139 compile_prog "$spice_cflags" "$spice_libs" ; then
4140 spice="yes"
4141 libs_softmmu="$libs_softmmu $spice_libs"
4142 QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
4143 spice_protocol_version=$($pkg_config --modversion spice-protocol)
4144 spice_server_version=$($pkg_config --modversion spice-server)
4145 else
4146 if test "$spice" = "yes" ; then
4147 feature_not_found "spice" \
4148 "Install spice-server(>=0.12.0) and spice-protocol(>=0.12.3) devel"
4150 spice="no"
4154 # check for smartcard support
4155 smartcard_cflags=""
4156 if test "$smartcard" != "no"; then
4157 if $pkg_config libcacard; then
4158 libcacard_cflags=$($pkg_config --cflags libcacard)
4159 libcacard_libs=$($pkg_config --libs libcacard)
4160 QEMU_CFLAGS="$QEMU_CFLAGS $libcacard_cflags"
4161 libs_softmmu="$libs_softmmu $libcacard_libs"
4162 smartcard="yes"
4163 else
4164 if test "$smartcard" = "yes"; then
4165 feature_not_found "smartcard" "Install libcacard devel"
4167 smartcard="no"
4171 # check for libusb
4172 if test "$libusb" != "no" ; then
4173 if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
4174 libusb="yes"
4175 libusb_cflags=$($pkg_config --cflags libusb-1.0)
4176 libusb_libs=$($pkg_config --libs libusb-1.0)
4177 QEMU_CFLAGS="$QEMU_CFLAGS $libusb_cflags"
4178 libs_softmmu="$libs_softmmu $libusb_libs"
4179 else
4180 if test "$libusb" = "yes"; then
4181 feature_not_found "libusb" "Install libusb devel >= 1.0.13"
4183 libusb="no"
4187 # check for usbredirparser for usb network redirection support
4188 if test "$usb_redir" != "no" ; then
4189 if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
4190 usb_redir="yes"
4191 usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
4192 usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
4193 QEMU_CFLAGS="$QEMU_CFLAGS $usb_redir_cflags"
4194 libs_softmmu="$libs_softmmu $usb_redir_libs"
4195 else
4196 if test "$usb_redir" = "yes"; then
4197 feature_not_found "usb-redir" "Install usbredir devel"
4199 usb_redir="no"
4203 ##########################################
4204 # check if we have VSS SDK headers for win
4206 if test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$vss_win32_sdk" != "no" ; then
4207 case "$vss_win32_sdk" in
4208 "") vss_win32_include="-isystem $source_path" ;;
4209 *\ *) # The SDK is installed in "Program Files" by default, but we cannot
4210 # handle path with spaces. So we symlink the headers into ".sdk/vss".
4211 vss_win32_include="-isystem $source_path/.sdk/vss"
4212 symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
4214 *) vss_win32_include="-isystem $vss_win32_sdk"
4215 esac
4216 cat > $TMPC << EOF
4217 #define __MIDL_user_allocate_free_DEFINED__
4218 #include <inc/win2003/vss.h>
4219 int main(void) { return VSS_CTX_BACKUP; }
4221 if compile_prog "$vss_win32_include" "" ; then
4222 guest_agent_with_vss="yes"
4223 QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
4224 libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
4225 qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
4226 else
4227 if test "$vss_win32_sdk" != "" ; then
4228 echo "ERROR: Please download and install Microsoft VSS SDK:"
4229 echo "ERROR: http://www.microsoft.com/en-us/download/details.aspx?id=23490"
4230 echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
4231 echo "ERROR: scripts/extract-vsssdk-headers setup.exe"
4232 echo "ERROR: The headers are extracted in the directory \`inc'."
4233 feature_not_found "VSS support"
4235 guest_agent_with_vss="no"
4239 ##########################################
4240 # lookup Windows platform SDK (if not specified)
4241 # The SDK is needed only to build .tlb (type library) file of guest agent
4242 # VSS provider from the source. It is usually unnecessary because the
4243 # pre-compiled .tlb file is included.
4245 if test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$guest_agent_with_vss" = "yes" ; then
4246 if test -z "$win_sdk"; then
4247 programfiles="$PROGRAMFILES"
4248 test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
4249 if test -n "$programfiles"; then
4250 win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
4251 else
4252 feature_not_found "Windows SDK"
4254 elif test "$win_sdk" = "no"; then
4255 win_sdk=""
4259 ##########################################
4260 # check if mingw environment provides a recent ntddscsi.h
4261 if test "$mingw32" = "yes" -a "$guest_agent" != "no"; then
4262 cat > $TMPC << EOF
4263 #include <windows.h>
4264 #include <ntddscsi.h>
4265 int main(void) {
4266 #if !defined(IOCTL_SCSI_GET_ADDRESS)
4267 #error Missing required ioctl definitions
4268 #endif
4269 SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
4270 return addr.Lun;
4273 if compile_prog "" "" ; then
4274 guest_agent_ntddscsi=yes
4275 libs_qga="-lsetupapi $libs_qga"
4279 ##########################################
4280 # virgl renderer probe
4282 if test "$virglrenderer" != "no" ; then
4283 cat > $TMPC << EOF
4284 #include <virglrenderer.h>
4285 int main(void) { virgl_renderer_poll(); return 0; }
4287 virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
4288 virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
4289 if $pkg_config virglrenderer >/dev/null 2>&1 && \
4290 compile_prog "$virgl_cflags" "$virgl_libs" ; then
4291 virglrenderer="yes"
4292 else
4293 if test "$virglrenderer" = "yes" ; then
4294 feature_not_found "virglrenderer"
4296 virglrenderer="no"
4300 ##########################################
4301 # check if we have fdatasync
4303 fdatasync=no
4304 cat > $TMPC << EOF
4305 #include <unistd.h>
4306 int main(void) {
4307 #if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
4308 return fdatasync(0);
4309 #else
4310 #error Not supported
4311 #endif
4314 if compile_prog "" "" ; then
4315 fdatasync=yes
4318 ##########################################
4319 # check if we have madvise
4321 madvise=no
4322 cat > $TMPC << EOF
4323 #include <sys/types.h>
4324 #include <sys/mman.h>
4325 #include <stddef.h>
4326 int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
4328 if compile_prog "" "" ; then
4329 madvise=yes
4332 ##########################################
4333 # check if we have posix_madvise
4335 posix_madvise=no
4336 cat > $TMPC << EOF
4337 #include <sys/mman.h>
4338 #include <stddef.h>
4339 int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
4341 if compile_prog "" "" ; then
4342 posix_madvise=yes
4345 ##########################################
4346 # check if we have posix_syslog
4348 posix_syslog=no
4349 cat > $TMPC << EOF
4350 #include <syslog.h>
4351 int main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
4353 if compile_prog "" "" ; then
4354 posix_syslog=yes
4357 ##########################################
4358 # check if trace backend exists
4360 $python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends > /dev/null 2> /dev/null
4361 if test "$?" -ne 0 ; then
4362 error_exit "invalid trace backends" \
4363 "Please choose supported trace backends."
4366 ##########################################
4367 # For 'ust' backend, test if ust headers are present
4368 if have_backend "ust"; then
4369 cat > $TMPC << EOF
4370 #include <lttng/tracepoint.h>
4371 int main(void) { return 0; }
4373 if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
4374 if $pkg_config lttng-ust --exists; then
4375 lttng_ust_libs=$($pkg_config --libs lttng-ust)
4376 else
4377 lttng_ust_libs="-llttng-ust -ldl"
4379 if $pkg_config liburcu-bp --exists; then
4380 urcu_bp_libs=$($pkg_config --libs liburcu-bp)
4381 else
4382 urcu_bp_libs="-lurcu-bp"
4385 LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
4386 libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
4387 else
4388 error_exit "Trace backend 'ust' missing lttng-ust header files"
4392 ##########################################
4393 # For 'dtrace' backend, test if 'dtrace' command is present
4394 if have_backend "dtrace"; then
4395 if ! has 'dtrace' ; then
4396 error_exit "dtrace command is not found in PATH $PATH"
4398 trace_backend_stap="no"
4399 if has 'stap' ; then
4400 trace_backend_stap="yes"
4404 ##########################################
4405 # check and set a backend for coroutine
4407 # We prefer ucontext, but it's not always possible. The fallback
4408 # is sigcontext. gthread is not selectable except explicitly, because
4409 # it is not functional enough to run QEMU proper. (It is occasionally
4410 # useful for debugging purposes.) On Windows the only valid backend
4411 # is the Windows-specific one.
4413 ucontext_works=no
4414 if test "$darwin" != "yes"; then
4415 cat > $TMPC << EOF
4416 #include <ucontext.h>
4417 #ifdef __stub_makecontext
4418 #error Ignoring glibc stub makecontext which will always fail
4419 #endif
4420 int main(void) { makecontext(0, 0, 0); return 0; }
4422 if compile_prog "" "" ; then
4423 ucontext_works=yes
4427 if test "$coroutine" = ""; then
4428 if test "$mingw32" = "yes"; then
4429 coroutine=win32
4430 elif test "$ucontext_works" = "yes"; then
4431 coroutine=ucontext
4432 else
4433 coroutine=sigaltstack
4435 else
4436 case $coroutine in
4437 windows)
4438 if test "$mingw32" != "yes"; then
4439 error_exit "'windows' coroutine backend only valid for Windows"
4441 # Unfortunately the user visible backend name doesn't match the
4442 # coroutine-*.c filename for this case, so we have to adjust it here.
4443 coroutine=win32
4445 ucontext)
4446 if test "$ucontext_works" != "yes"; then
4447 feature_not_found "ucontext"
4450 gthread|sigaltstack)
4451 if test "$mingw32" = "yes"; then
4452 error_exit "only the 'windows' coroutine backend is valid for Windows"
4456 error_exit "unknown coroutine backend $coroutine"
4458 esac
4461 if test "$coroutine_pool" = ""; then
4462 if test "$coroutine" = "gthread" -o "$coroutine" = "win32"; then
4463 coroutine_pool=no
4464 else
4465 coroutine_pool=yes
4468 if test "$coroutine" = "gthread" -a "$coroutine_pool" = "yes"; then
4469 error_exit "'gthread' coroutine backend does not support pool (use --disable-coroutine-pool)"
4472 if test "$debug_stack_usage" = "yes"; then
4473 if test "$cpu" = "ia64" -o "$cpu" = "hppa"; then
4474 error_exit "stack usage debugging is not supported for $cpu"
4476 if test "$coroutine_pool" = "yes"; then
4477 echo "WARN: disabling coroutine pool for stack usage debugging"
4478 coroutine_pool=no
4483 ##########################################
4484 # check if we have open_by_handle_at
4486 open_by_handle_at=no
4487 cat > $TMPC << EOF
4488 #include <fcntl.h>
4489 #if !defined(AT_EMPTY_PATH)
4490 # error missing definition
4491 #else
4492 int main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
4493 #endif
4495 if compile_prog "" "" ; then
4496 open_by_handle_at=yes
4499 ########################################
4500 # check if we have linux/magic.h
4502 linux_magic_h=no
4503 cat > $TMPC << EOF
4504 #include <linux/magic.h>
4505 int main(void) {
4506 return 0;
4509 if compile_prog "" "" ; then
4510 linux_magic_h=yes
4513 ########################################
4514 # check whether we can disable warning option with a pragma (this is needed
4515 # to silence warnings in the headers of some versions of external libraries).
4516 # This test has to be compiled with -Werror as otherwise an unknown pragma is
4517 # only a warning.
4519 # If we can't selectively disable warning in the code, disable -Werror so that
4520 # the build doesn't fail anyway.
4522 pragma_disable_unused_but_set=no
4523 cat > $TMPC << EOF
4524 #pragma GCC diagnostic push
4525 #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
4526 #pragma GCC diagnostic ignored "-Wstrict-prototypes"
4527 #pragma GCC diagnostic pop
4529 int main(void) {
4530 return 0;
4533 if compile_prog "-Werror" "" ; then
4534 pragma_diagnostic_available=yes
4537 ########################################
4538 # check if we have valgrind/valgrind.h
4540 valgrind_h=no
4541 cat > $TMPC << EOF
4542 #include <valgrind/valgrind.h>
4543 int main(void) {
4544 return 0;
4547 if compile_prog "" "" ; then
4548 valgrind_h=yes
4551 ########################################
4552 # check if environ is declared
4554 has_environ=no
4555 cat > $TMPC << EOF
4556 #include <unistd.h>
4557 int main(void) {
4558 environ = 0;
4559 return 0;
4562 if compile_prog "" "" ; then
4563 has_environ=yes
4566 ########################################
4567 # check if cpuid.h is usable.
4569 cpuid_h=no
4570 cat > $TMPC << EOF
4571 #include <cpuid.h>
4572 int main(void) {
4573 unsigned a, b, c, d;
4574 int max = __get_cpuid_max(0, 0);
4576 if (max >= 1) {
4577 __cpuid(1, a, b, c, d);
4580 if (max >= 7) {
4581 __cpuid_count(7, 0, a, b, c, d);
4584 return 0;
4587 if compile_prog "" "" ; then
4588 cpuid_h=yes
4591 ########################################
4592 # check if __[u]int128_t is usable.
4594 int128=no
4595 cat > $TMPC << EOF
4596 #if defined(__clang_major__) && defined(__clang_minor__)
4597 # if ((__clang_major__ < 3) || (__clang_major__ == 3) && (__clang_minor__ < 2))
4598 # error __int128_t does not work in CLANG before 3.2
4599 # endif
4600 #endif
4601 __int128_t a;
4602 __uint128_t b;
4603 int main (void) {
4604 a = a + b;
4605 b = a * b;
4606 a = a * a;
4607 return 0;
4610 if compile_prog "" "" ; then
4611 int128=yes
4614 #########################################
4615 # See if 128-bit atomic operations are supported.
4617 atomic128=no
4618 if test "$int128" = "yes"; then
4619 cat > $TMPC << EOF
4620 int main(void)
4622 unsigned __int128 x = 0, y = 0;
4623 y = __atomic_load_16(&x, 0);
4624 __atomic_store_16(&x, y, 0);
4625 __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
4626 return 0;
4629 if compile_prog "" "" ; then
4630 atomic128=yes
4634 #########################################
4635 # See if 64-bit atomic operations are supported.
4636 # Note that without __atomic builtins, we can only
4637 # assume atomic loads/stores max at pointer size.
4639 cat > $TMPC << EOF
4640 #include <stdint.h>
4641 int main(void)
4643 uint64_t x = 0, y = 0;
4644 #ifdef __ATOMIC_RELAXED
4645 y = __atomic_load_8(&x, 0);
4646 __atomic_store_8(&x, y, 0);
4647 __atomic_compare_exchange_8(&x, &y, x, 0, 0, 0);
4648 __atomic_exchange_8(&x, y, 0);
4649 __atomic_fetch_add_8(&x, y, 0);
4650 #else
4651 typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
4652 __sync_lock_test_and_set(&x, y);
4653 __sync_val_compare_and_swap(&x, y, 0);
4654 __sync_fetch_and_add(&x, y);
4655 #endif
4656 return 0;
4659 if compile_prog "" "" ; then
4660 atomic64=yes
4663 ########################################
4664 # check if getauxval is available.
4666 getauxval=no
4667 cat > $TMPC << EOF
4668 #include <sys/auxv.h>
4669 int main(void) {
4670 return getauxval(AT_HWCAP) == 0;
4673 if compile_prog "" "" ; then
4674 getauxval=yes
4677 ########################################
4678 # check if ccache is interfering with
4679 # semantic analysis of macros
4681 unset CCACHE_CPP2
4682 ccache_cpp2=no
4683 cat > $TMPC << EOF
4684 static const int Z = 1;
4685 #define fn() ({ Z; })
4686 #define TAUT(X) ((X) == Z)
4687 #define PAREN(X, Y) (X == Y)
4688 #define ID(X) (X)
4689 int main(int argc, char *argv[])
4691 int x = 0, y = 0;
4692 x = ID(x);
4693 x = fn();
4694 fn();
4695 if (PAREN(x, y)) return 0;
4696 if (TAUT(Z)) return 0;
4697 return 0;
4701 if ! compile_object "-Werror"; then
4702 ccache_cpp2=yes
4705 #################################################
4706 # clang does not support glibc + FORTIFY_SOURCE.
4708 if test "$fortify_source" != "no"; then
4709 if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
4710 fortify_source="no";
4711 elif test -n "$cxx" &&
4712 echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
4713 fortify_source="no";
4714 else
4715 fortify_source="yes"
4719 ##########################################
4720 # check if struct fsxattr is available via linux/fs.h
4722 have_fsxattr=no
4723 cat > $TMPC << EOF
4724 #include <linux/fs.h>
4725 struct fsxattr foo;
4726 int main(void) {
4727 return 0;
4730 if compile_prog "" "" ; then
4731 have_fsxattr=yes
4734 ##########################################
4735 # check if rtnetlink.h exists and is useful
4736 have_rtnetlink=no
4737 cat > $TMPC << EOF
4738 #include <linux/rtnetlink.h>
4739 int main(void) {
4740 return IFLA_PROTO_DOWN;
4743 if compile_prog "" "" ; then
4744 have_rtnetlink=yes
4747 ##########################################
4748 # check for usable AF_VSOCK environment
4749 have_af_vsock=no
4750 cat > $TMPC << EOF
4751 #include <errno.h>
4752 #include <sys/types.h>
4753 #include <sys/socket.h>
4754 #if !defined(AF_VSOCK)
4755 # error missing AF_VSOCK flag
4756 #endif
4757 #include <linux/vm_sockets.h>
4758 int main(void) {
4759 int sock, ret;
4760 struct sockaddr_vm svm;
4761 socklen_t len = sizeof(svm);
4762 sock = socket(AF_VSOCK, SOCK_STREAM, 0);
4763 ret = getpeername(sock, (struct sockaddr *)&svm, &len);
4764 if ((ret == -1) && (errno == ENOTCONN)) {
4765 return 0;
4767 return -1;
4770 if compile_prog "" "" ; then
4771 have_af_vsock=yes
4774 #################################################
4775 # Sparc implicitly links with --relax, which is
4776 # incompatible with -r, so --no-relax should be
4777 # given. It does no harm to give it on other
4778 # platforms too.
4780 # Note: the prototype is needed since QEMU_CFLAGS
4781 # contains -Wmissing-prototypes
4782 cat > $TMPC << EOF
4783 extern int foo(void);
4784 int foo(void) { return 0; }
4786 if ! compile_object ""; then
4787 error_exit "Failed to compile object file for LD_REL_FLAGS test"
4789 for i in '-Wl,-r -Wl,--no-relax' -Wl,-r -r; do
4790 if do_cc -nostdlib $i -o $TMPMO $TMPO; then
4791 LD_REL_FLAGS=$i
4792 break
4794 done
4795 if test "$modules" = "yes" && test "$LD_REL_FLAGS" = ""; then
4796 feature_not_found "modules" "Cannot find how to build relocatable objects"
4799 ##########################################
4800 # End of CC checks
4801 # After here, no more $cc or $ld runs
4803 if test "$gcov" = "yes" ; then
4804 CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
4805 LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
4806 elif test "$fortify_source" = "yes" ; then
4807 CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
4808 elif test "$debug" = "no"; then
4809 CFLAGS="-O2 $CFLAGS"
4812 ##########################################
4813 # Do we have libnfs
4814 if test "$libnfs" != "no" ; then
4815 if $pkg_config --atleast-version=1.9.3 libnfs; then
4816 libnfs="yes"
4817 libnfs_libs=$($pkg_config --libs libnfs)
4818 else
4819 if test "$libnfs" = "yes" ; then
4820 feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
4822 libnfs="no"
4826 # Now we've finished running tests it's OK to add -Werror to the compiler flags
4827 if test "$werror" = "yes"; then
4828 QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
4831 if test "$solaris" = "no" ; then
4832 if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
4833 LDFLAGS="-Wl,--warn-common $LDFLAGS"
4837 # test if pod2man has --utf8 option
4838 if pod2man --help | grep -q utf8; then
4839 POD2MAN="pod2man --utf8"
4840 else
4841 POD2MAN="pod2man"
4844 # Use large addresses, ASLR, no-SEH and DEP if available.
4845 if test "$mingw32" = "yes" ; then
4846 if test "$cpu" = i386; then
4847 LDFLAGS="-Wl,--large-address-aware $LDFLAGS"
4849 for flag in --dynamicbase --no-seh --nxcompat; do
4850 if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
4851 LDFLAGS="-Wl,$flag $LDFLAGS"
4853 done
4856 qemu_confdir=$sysconfdir$confsuffix
4857 qemu_moddir=$libdir$confsuffix
4858 qemu_datadir=$datadir$confsuffix
4859 qemu_localedir="$datadir/locale"
4861 tools=""
4862 tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
4863 if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
4864 tools="qemu-nbd\$(EXESUF) $tools"
4865 tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools"
4867 if test "$softmmu" = yes ; then
4868 if test "$virtfs" != no ; then
4869 if test "$cap" = yes && test "$linux" = yes && test "$attr" = yes ; then
4870 virtfs=yes
4871 tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
4872 else
4873 if test "$virtfs" = yes; then
4874 error_exit "VirtFS is supported only on Linux and requires libcap devel and libattr devel"
4876 virtfs=no
4881 # Probe for guest agent support/options
4883 if [ "$guest_agent" != "no" ]; then
4884 if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
4885 tools="qemu-ga $tools"
4886 guest_agent=yes
4887 elif [ "$guest_agent" != yes ]; then
4888 guest_agent=no
4889 else
4890 error_exit "Guest agent is not supported on this platform"
4894 # Guest agent Window MSI package
4896 if test "$guest_agent" != yes; then
4897 if test "$guest_agent_msi" = yes; then
4898 error_exit "MSI guest agent package requires guest agent enabled"
4900 guest_agent_msi=no
4901 elif test "$mingw32" != "yes"; then
4902 if test "$guest_agent_msi" = "yes"; then
4903 error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
4905 guest_agent_msi=no
4906 elif ! has wixl; then
4907 if test "$guest_agent_msi" = "yes"; then
4908 error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
4910 guest_agent_msi=no
4911 else
4912 # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
4913 # disabled explicitly
4914 if test "$guest_agent_msi" != "no"; then
4915 guest_agent_msi=yes
4919 if test "$guest_agent_msi" = "yes"; then
4920 if test "$guest_agent_with_vss" = "yes"; then
4921 QEMU_GA_MSI_WITH_VSS="-D InstallVss"
4924 if test "$QEMU_GA_MANUFACTURER" = ""; then
4925 QEMU_GA_MANUFACTURER=QEMU
4928 if test "$QEMU_GA_DISTRO" = ""; then
4929 QEMU_GA_DISTRO=Linux
4932 if test "$QEMU_GA_VERSION" = ""; then
4933 QEMU_GA_VERSION=$(cat $source_path/VERSION)
4936 QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
4938 case "$cpu" in
4939 x86_64)
4940 QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
4942 i386)
4943 QEMU_GA_MSI_ARCH="-D Arch=32"
4946 error_exit "CPU $cpu not supported for building installation package"
4948 esac
4951 # Mac OS X ships with a broken assembler
4952 roms=
4953 if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
4954 "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
4955 "$softmmu" = yes ; then
4956 # Different host OS linkers have different ideas about the name of the ELF
4957 # emulation. Linux and OpenBSD use 'elf_i386'; FreeBSD uses the _fbsd
4958 # variant; and Windows uses i386pe.
4959 for emu in elf_i386 elf_i386_fbsd i386pe; do
4960 if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
4961 ld_i386_emulation="$emu"
4962 roms="optionrom"
4963 break
4965 done
4967 if test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
4968 roms="$roms spapr-rtas"
4971 if test "$cpu" = "s390x" ; then
4972 roms="$roms s390-ccw"
4975 # Probe for the need for relocating the user-only binary.
4976 if ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) && [ "$pie" = no ]; then
4977 textseg_addr=
4978 case "$cpu" in
4979 arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
4980 # ??? Rationale for choosing this address
4981 textseg_addr=0x60000000
4983 mips)
4984 # A 256M aligned address, high in the address space, with enough
4985 # room for the code_gen_buffer above it before the stack.
4986 textseg_addr=0x60000000
4988 esac
4989 if [ -n "$textseg_addr" ]; then
4990 cat > $TMPC <<EOF
4991 int main(void) { return 0; }
4993 textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
4994 if ! compile_prog "" "$textseg_ldflags"; then
4995 # In case ld does not support -Ttext-segment, edit the default linker
4996 # script via sed to set the .text start addr. This is needed on FreeBSD
4997 # at least.
4998 if ! $ld --verbose >/dev/null 2>&1; then
4999 error_exit \
5000 "We need to link the QEMU user mode binaries at a" \
5001 "specific text address. Unfortunately your linker" \
5002 "doesn't support either the -Ttext-segment option or" \
5003 "printing the default linker script with --verbose." \
5004 "If you don't want the user mode binaries, pass the" \
5005 "--disable-user option to configure."
5008 $ld --verbose | sed \
5009 -e '1,/==================================================/d' \
5010 -e '/==================================================/,$d' \
5011 -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
5012 -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
5013 textseg_ldflags="-Wl,-T../config-host.ld"
5018 echo_version() {
5019 if test "$1" = "yes" ; then
5020 echo "($2)"
5024 # prepend pixman and ftd flags after all config tests are done
5025 QEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"
5026 libs_softmmu="$pixman_libs $libs_softmmu"
5028 echo "Install prefix $prefix"
5029 echo "BIOS directory $(eval echo $qemu_datadir)"
5030 echo "binary directory $(eval echo $bindir)"
5031 echo "library directory $(eval echo $libdir)"
5032 echo "module directory $(eval echo $qemu_moddir)"
5033 echo "libexec directory $(eval echo $libexecdir)"
5034 echo "include directory $(eval echo $includedir)"
5035 echo "config directory $(eval echo $sysconfdir)"
5036 if test "$mingw32" = "no" ; then
5037 echo "local state directory $(eval echo $local_statedir)"
5038 echo "Manual directory $(eval echo $mandir)"
5039 echo "ELF interp prefix $interp_prefix"
5040 else
5041 echo "local state directory queried at runtime"
5042 echo "Windows SDK $win_sdk"
5044 echo "Source path $source_path"
5045 echo "C compiler $cc"
5046 echo "Host C compiler $host_cc"
5047 echo "C++ compiler $cxx"
5048 echo "Objective-C compiler $objcc"
5049 echo "ARFLAGS $ARFLAGS"
5050 echo "CFLAGS $CFLAGS"
5051 echo "QEMU_CFLAGS $QEMU_CFLAGS"
5052 echo "LDFLAGS $LDFLAGS"
5053 echo "make $make"
5054 echo "install $install"
5055 echo "python $python"
5056 if test "$slirp" = "yes" ; then
5057 echo "smbd $smbd"
5059 echo "module support $modules"
5060 echo "host CPU $cpu"
5061 echo "host big endian $bigendian"
5062 echo "target list $target_list"
5063 echo "tcg debug enabled $debug_tcg"
5064 echo "gprof enabled $gprof"
5065 echo "sparse enabled $sparse"
5066 echo "strip binaries $strip_opt"
5067 echo "profiler $profiler"
5068 echo "static build $static"
5069 if test "$darwin" = "yes" ; then
5070 echo "Cocoa support $cocoa"
5072 echo "pixman $pixman"
5073 echo "SDL support $sdl $(echo_version $sdl $sdlversion)"
5074 echo "GTK support $gtk $(echo_version $gtk $gtk_version)"
5075 echo "GTK GL support $gtk_gl"
5076 echo "VTE support $vte $(echo_version $vte $vteversion)"
5077 echo "TLS priority $tls_priority"
5078 echo "GNUTLS support $gnutls"
5079 echo "GNUTLS rnd $gnutls_rnd"
5080 if test "$gcrypt" = "yes"; then
5081 echo "encryption libgcrypt"
5082 echo "libgcrypt kdf $gcrypt_kdf"
5083 elif test "$nettle" = "yes"; then
5084 echo "nettle $nettle $(echo_version $nettle $nettle_version)"
5085 else
5086 echo "encryption none"
5088 echo "nettle kdf $nettle_kdf"
5089 echo "libtasn1 $tasn1"
5090 echo "curses support $curses"
5091 echo "virgl support $virglrenderer"
5092 echo "curl support $curl"
5093 echo "mingw32 support $mingw32"
5094 echo "Audio drivers $audio_drv_list"
5095 echo "Block whitelist (rw) $block_drv_rw_whitelist"
5096 echo "Block whitelist (ro) $block_drv_ro_whitelist"
5097 echo "VirtFS support $virtfs"
5098 echo "VNC support $vnc"
5099 if test "$vnc" = "yes" ; then
5100 echo "VNC SASL support $vnc_sasl"
5101 echo "VNC JPEG support $vnc_jpeg"
5102 echo "VNC PNG support $vnc_png"
5104 if test -n "$sparc_cpu"; then
5105 echo "Target Sparc Arch $sparc_cpu"
5107 echo "xen support $xen"
5108 if test "$xen" = "yes" ; then
5109 echo "xen ctrl version $xen_ctrl_version"
5110 echo "pv dom build $xen_pv_domain_build"
5112 echo "brlapi support $brlapi"
5113 echo "bluez support $bluez"
5114 echo "Documentation $docs"
5115 echo "Tools $tools"
5116 echo "PIE $pie"
5117 echo "vde support $vde"
5118 echo "netmap support $netmap"
5119 echo "Linux AIO support $linux_aio"
5120 echo "(X)ATTR support $attr"
5121 echo "Install blobs $blobs"
5122 echo "KVM support $kvm"
5123 echo "HAX support $hax"
5124 echo "RDMA support $rdma"
5125 echo "TCG interpreter $tcg_interpreter"
5126 echo "fdt support $fdt"
5127 echo "preadv support $preadv"
5128 echo "fdatasync $fdatasync"
5129 echo "madvise $madvise"
5130 echo "posix_madvise $posix_madvise"
5131 echo "libcap-ng support $cap_ng"
5132 echo "vhost-net support $vhost_net"
5133 echo "vhost-scsi support $vhost_scsi"
5134 echo "vhost-vsock support $vhost_vsock"
5135 echo "Trace backends $trace_backends"
5136 if have_backend "simple"; then
5137 echo "Trace output file $trace_file-<pid>"
5139 echo "spice support $spice $(echo_version $spice $spice_protocol_version/$spice_server_version)"
5140 echo "rbd support $rbd"
5141 echo "xfsctl support $xfs"
5142 echo "smartcard support $smartcard"
5143 echo "libusb $libusb"
5144 echo "usb net redir $usb_redir"
5145 echo "OpenGL support $opengl"
5146 echo "OpenGL dmabufs $opengl_dmabuf"
5147 echo "libiscsi support $libiscsi"
5148 echo "libnfs support $libnfs"
5149 echo "build guest agent $guest_agent"
5150 echo "QGA VSS support $guest_agent_with_vss"
5151 echo "QGA w32 disk info $guest_agent_ntddscsi"
5152 echo "QGA MSI support $guest_agent_msi"
5153 echo "seccomp support $seccomp"
5154 echo "coroutine backend $coroutine"
5155 echo "coroutine pool $coroutine_pool"
5156 echo "debug stack usage $debug_stack_usage"
5157 echo "GlusterFS support $glusterfs"
5158 echo "Archipelago support $archipelago"
5159 echo "gcov $gcov_tool"
5160 echo "gcov enabled $gcov"
5161 echo "TPM support $tpm"
5162 echo "libssh2 support $libssh2"
5163 echo "TPM passthrough $tpm_passthrough"
5164 echo "QOM debugging $qom_cast_debug"
5165 echo "lzo support $lzo"
5166 echo "snappy support $snappy"
5167 echo "bzip2 support $bzip2"
5168 echo "NUMA host support $numa"
5169 echo "tcmalloc support $tcmalloc"
5170 echo "jemalloc support $jemalloc"
5171 echo "avx2 optimization $avx2_opt"
5172 echo "replication support $replication"
5174 if test "$sdl_too_old" = "yes"; then
5175 echo "-> Your SDL version is too old - please upgrade to have SDL support"
5178 config_host_mak="config-host.mak"
5180 echo "# Automatically generated by configure - do not modify" >config-all-disas.mak
5182 echo "# Automatically generated by configure - do not modify" > $config_host_mak
5183 echo >> $config_host_mak
5185 echo all: >> $config_host_mak
5186 echo "prefix=$prefix" >> $config_host_mak
5187 echo "bindir=$bindir" >> $config_host_mak
5188 echo "libdir=$libdir" >> $config_host_mak
5189 echo "libexecdir=$libexecdir" >> $config_host_mak
5190 echo "includedir=$includedir" >> $config_host_mak
5191 echo "mandir=$mandir" >> $config_host_mak
5192 echo "sysconfdir=$sysconfdir" >> $config_host_mak
5193 echo "qemu_confdir=$qemu_confdir" >> $config_host_mak
5194 echo "qemu_datadir=$qemu_datadir" >> $config_host_mak
5195 echo "qemu_docdir=$qemu_docdir" >> $config_host_mak
5196 echo "qemu_moddir=$qemu_moddir" >> $config_host_mak
5197 if test "$mingw32" = "no" ; then
5198 echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
5200 echo "qemu_helperdir=$libexecdir" >> $config_host_mak
5201 echo "extra_cflags=$EXTRA_CFLAGS" >> $config_host_mak
5202 echo "extra_ldflags=$EXTRA_LDFLAGS" >> $config_host_mak
5203 echo "qemu_localedir=$qemu_localedir" >> $config_host_mak
5204 echo "libs_softmmu=$libs_softmmu" >> $config_host_mak
5206 echo "ARCH=$ARCH" >> $config_host_mak
5208 if test "$debug_tcg" = "yes" ; then
5209 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
5211 if test "$strip_opt" = "yes" ; then
5212 echo "STRIP=${strip}" >> $config_host_mak
5214 if test "$bigendian" = "yes" ; then
5215 echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
5217 if test "$mingw32" = "yes" ; then
5218 echo "CONFIG_WIN32=y" >> $config_host_mak
5219 echo "CONFIG_INSTALLER=y" >> $config_host_mak
5220 rc_version=$(cat $source_path/VERSION)
5221 version_major=${rc_version%%.*}
5222 rc_version=${rc_version#*.}
5223 version_minor=${rc_version%%.*}
5224 rc_version=${rc_version#*.}
5225 version_subminor=${rc_version%%.*}
5226 version_micro=0
5227 echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
5228 echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
5229 if test "$guest_agent_with_vss" = "yes" ; then
5230 echo "CONFIG_QGA_VSS=y" >> $config_host_mak
5231 echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
5232 echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
5234 if test "$guest_agent_ntddscsi" = "yes" ; then
5235 echo "CONFIG_QGA_NTDDDISK=y" >> $config_host_mak
5237 if test "$guest_agent_msi" = "yes"; then
5238 echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
5239 echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
5240 echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
5241 echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
5242 echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
5243 echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
5244 echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
5246 else
5247 echo "CONFIG_POSIX=y" >> $config_host_mak
5250 if test "$linux" = "yes" ; then
5251 echo "CONFIG_LINUX=y" >> $config_host_mak
5254 if test "$darwin" = "yes" ; then
5255 echo "CONFIG_DARWIN=y" >> $config_host_mak
5258 if test "$aix" = "yes" ; then
5259 echo "CONFIG_AIX=y" >> $config_host_mak
5262 if test "$solaris" = "yes" ; then
5263 echo "CONFIG_SOLARIS=y" >> $config_host_mak
5264 echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
5265 if test "$needs_libsunmath" = "yes" ; then
5266 echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
5269 if test "$haiku" = "yes" ; then
5270 echo "CONFIG_HAIKU=y" >> $config_host_mak
5272 if test "$static" = "yes" ; then
5273 echo "CONFIG_STATIC=y" >> $config_host_mak
5275 if test "$profiler" = "yes" ; then
5276 echo "CONFIG_PROFILER=y" >> $config_host_mak
5278 if test "$slirp" = "yes" ; then
5279 echo "CONFIG_SLIRP=y" >> $config_host_mak
5280 echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
5282 if test "$vde" = "yes" ; then
5283 echo "CONFIG_VDE=y" >> $config_host_mak
5285 if test "$netmap" = "yes" ; then
5286 echo "CONFIG_NETMAP=y" >> $config_host_mak
5288 if test "$l2tpv3" = "yes" ; then
5289 echo "CONFIG_L2TPV3=y" >> $config_host_mak
5291 if test "$cap_ng" = "yes" ; then
5292 echo "CONFIG_LIBCAP=y" >> $config_host_mak
5294 echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
5295 for drv in $audio_drv_list; do
5296 def=CONFIG_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
5297 echo "$def=y" >> $config_host_mak
5298 done
5299 if test "$audio_pt_int" = "yes" ; then
5300 echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
5302 if test "$audio_win_int" = "yes" ; then
5303 echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
5305 echo "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
5306 echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
5307 if test "$vnc" = "yes" ; then
5308 echo "CONFIG_VNC=y" >> $config_host_mak
5310 if test "$vnc_sasl" = "yes" ; then
5311 echo "CONFIG_VNC_SASL=y" >> $config_host_mak
5313 if test "$vnc_jpeg" = "yes" ; then
5314 echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
5316 if test "$vnc_png" = "yes" ; then
5317 echo "CONFIG_VNC_PNG=y" >> $config_host_mak
5319 if test "$fnmatch" = "yes" ; then
5320 echo "CONFIG_FNMATCH=y" >> $config_host_mak
5322 if test "$xfs" = "yes" ; then
5323 echo "CONFIG_XFS=y" >> $config_host_mak
5325 qemu_version=$(head $source_path/VERSION)
5326 echo "VERSION=$qemu_version" >>$config_host_mak
5327 echo "PKGVERSION=$pkgversion" >>$config_host_mak
5328 echo "SRC_PATH=$source_path" >> $config_host_mak
5329 echo "TARGET_DIRS=$target_list" >> $config_host_mak
5330 if [ "$docs" = "yes" ] ; then
5331 echo "BUILD_DOCS=yes" >> $config_host_mak
5333 if [ "$want_tools" = "yes" ] ; then
5334 echo "BUILD_TOOLS=yes" >> $config_host_mak
5336 if test "$modules" = "yes"; then
5337 # $shacmd can generate a hash started with digit, which the compiler doesn't
5338 # like as an symbol. So prefix it with an underscore
5339 echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
5340 echo "CONFIG_MODULES=y" >> $config_host_mak
5342 if test "$sdl" = "yes" ; then
5343 echo "CONFIG_SDL=y" >> $config_host_mak
5344 echo "CONFIG_SDLABI=$sdlabi" >> $config_host_mak
5345 echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
5347 if test "$cocoa" = "yes" ; then
5348 echo "CONFIG_COCOA=y" >> $config_host_mak
5350 if test "$curses" = "yes" ; then
5351 echo "CONFIG_CURSES=y" >> $config_host_mak
5353 if test "$utimens" = "yes" ; then
5354 echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
5356 if test "$pipe2" = "yes" ; then
5357 echo "CONFIG_PIPE2=y" >> $config_host_mak
5359 if test "$accept4" = "yes" ; then
5360 echo "CONFIG_ACCEPT4=y" >> $config_host_mak
5362 if test "$splice" = "yes" ; then
5363 echo "CONFIG_SPLICE=y" >> $config_host_mak
5365 if test "$eventfd" = "yes" ; then
5366 echo "CONFIG_EVENTFD=y" >> $config_host_mak
5368 if test "$memfd" = "yes" ; then
5369 echo "CONFIG_MEMFD=y" >> $config_host_mak
5371 if test "$fallocate" = "yes" ; then
5372 echo "CONFIG_FALLOCATE=y" >> $config_host_mak
5374 if test "$fallocate_punch_hole" = "yes" ; then
5375 echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
5377 if test "$fallocate_zero_range" = "yes" ; then
5378 echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
5380 if test "$posix_fallocate" = "yes" ; then
5381 echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
5383 if test "$sync_file_range" = "yes" ; then
5384 echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
5386 if test "$fiemap" = "yes" ; then
5387 echo "CONFIG_FIEMAP=y" >> $config_host_mak
5389 if test "$dup3" = "yes" ; then
5390 echo "CONFIG_DUP3=y" >> $config_host_mak
5392 if test "$ppoll" = "yes" ; then
5393 echo "CONFIG_PPOLL=y" >> $config_host_mak
5395 if test "$prctl_pr_set_timerslack" = "yes" ; then
5396 echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
5398 if test "$epoll" = "yes" ; then
5399 echo "CONFIG_EPOLL=y" >> $config_host_mak
5401 if test "$epoll_create1" = "yes" ; then
5402 echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
5404 if test "$sendfile" = "yes" ; then
5405 echo "CONFIG_SENDFILE=y" >> $config_host_mak
5407 if test "$timerfd" = "yes" ; then
5408 echo "CONFIG_TIMERFD=y" >> $config_host_mak
5410 if test "$setns" = "yes" ; then
5411 echo "CONFIG_SETNS=y" >> $config_host_mak
5413 if test "$clock_adjtime" = "yes" ; then
5414 echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
5416 if test "$syncfs" = "yes" ; then
5417 echo "CONFIG_SYNCFS=y" >> $config_host_mak
5419 if test "$inotify" = "yes" ; then
5420 echo "CONFIG_INOTIFY=y" >> $config_host_mak
5422 if test "$inotify1" = "yes" ; then
5423 echo "CONFIG_INOTIFY1=y" >> $config_host_mak
5425 if test "$byteswap_h" = "yes" ; then
5426 echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
5428 if test "$bswap_h" = "yes" ; then
5429 echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
5431 if test "$curl" = "yes" ; then
5432 echo "CONFIG_CURL=m" >> $config_host_mak
5433 echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
5434 echo "CURL_LIBS=$curl_libs" >> $config_host_mak
5436 if test "$brlapi" = "yes" ; then
5437 echo "CONFIG_BRLAPI=y" >> $config_host_mak
5439 if test "$bluez" = "yes" ; then
5440 echo "CONFIG_BLUEZ=y" >> $config_host_mak
5441 echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
5443 if test "$glib_subprocess" = "yes" ; then
5444 echo "CONFIG_HAS_GLIB_SUBPROCESS_TESTS=y" >> $config_host_mak
5446 if test "$gtk" = "yes" ; then
5447 echo "CONFIG_GTK=y" >> $config_host_mak
5448 echo "CONFIG_GTKABI=$gtkabi" >> $config_host_mak
5449 echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
5450 echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
5451 if test "$gtk_gl" = "yes" ; then
5452 echo "CONFIG_GTK_GL=y" >> $config_host_mak
5455 echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
5456 if test "$gnutls" = "yes" ; then
5457 echo "CONFIG_GNUTLS=y" >> $config_host_mak
5459 if test "$gnutls_rnd" = "yes" ; then
5460 echo "CONFIG_GNUTLS_RND=y" >> $config_host_mak
5462 if test "$gcrypt" = "yes" ; then
5463 echo "CONFIG_GCRYPT=y" >> $config_host_mak
5464 if test "$gcrypt_hmac" = "yes" ; then
5465 echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
5467 if test "$gcrypt_kdf" = "yes" ; then
5468 echo "CONFIG_GCRYPT_KDF=y" >> $config_host_mak
5471 if test "$nettle" = "yes" ; then
5472 echo "CONFIG_NETTLE=y" >> $config_host_mak
5473 echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
5474 if test "$nettle_kdf" = "yes" ; then
5475 echo "CONFIG_NETTLE_KDF=y" >> $config_host_mak
5478 if test "$tasn1" = "yes" ; then
5479 echo "CONFIG_TASN1=y" >> $config_host_mak
5481 if test "$have_ifaddrs_h" = "yes" ; then
5482 echo "HAVE_IFADDRS_H=y" >> $config_host_mak
5484 if test "$have_broken_size_max" = "yes" ; then
5485 echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
5488 # Work around a system header bug with some kernel/XFS header
5489 # versions where they both try to define 'struct fsxattr':
5490 # xfs headers will not try to redefine structs from linux headers
5491 # if this macro is set.
5492 if test "$have_fsxattr" = "yes" ; then
5493 echo "HAVE_FSXATTR=y" >> $config_host_mak
5495 if test "$vte" = "yes" ; then
5496 echo "CONFIG_VTE=y" >> $config_host_mak
5497 echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
5499 if test "$virglrenderer" = "yes" ; then
5500 echo "CONFIG_VIRGL=y" >> $config_host_mak
5501 echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
5502 echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
5504 if test "$xen" = "yes" ; then
5505 echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
5506 echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
5507 if test "$xen_pv_domain_build" = "yes" ; then
5508 echo "CONFIG_XEN_PV_DOMAIN_BUILD=y" >> $config_host_mak
5511 if test "$linux_aio" = "yes" ; then
5512 echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
5514 if test "$attr" = "yes" ; then
5515 echo "CONFIG_ATTR=y" >> $config_host_mak
5517 if test "$libattr" = "yes" ; then
5518 echo "CONFIG_LIBATTR=y" >> $config_host_mak
5520 if test "$virtfs" = "yes" ; then
5521 echo "CONFIG_VIRTFS=y" >> $config_host_mak
5523 if test "$vhost_scsi" = "yes" ; then
5524 echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
5526 if test "$vhost_net" = "yes" ; then
5527 echo "CONFIG_VHOST_NET_USED=y" >> $config_host_mak
5529 if test "$vhost_vsock" = "yes" ; then
5530 echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
5532 if test "$blobs" = "yes" ; then
5533 echo "INSTALL_BLOBS=yes" >> $config_host_mak
5535 if test "$iovec" = "yes" ; then
5536 echo "CONFIG_IOVEC=y" >> $config_host_mak
5538 if test "$preadv" = "yes" ; then
5539 echo "CONFIG_PREADV=y" >> $config_host_mak
5541 if test "$fdt" = "yes" ; then
5542 echo "CONFIG_FDT=y" >> $config_host_mak
5544 if test "$signalfd" = "yes" ; then
5545 echo "CONFIG_SIGNALFD=y" >> $config_host_mak
5547 if test "$tcg_interpreter" = "yes" ; then
5548 echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
5550 if test "$fdatasync" = "yes" ; then
5551 echo "CONFIG_FDATASYNC=y" >> $config_host_mak
5553 if test "$madvise" = "yes" ; then
5554 echo "CONFIG_MADVISE=y" >> $config_host_mak
5556 if test "$posix_madvise" = "yes" ; then
5557 echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
5560 if test "$spice" = "yes" ; then
5561 echo "CONFIG_SPICE=y" >> $config_host_mak
5564 if test "$smartcard" = "yes" ; then
5565 echo "CONFIG_SMARTCARD=y" >> $config_host_mak
5568 if test "$libusb" = "yes" ; then
5569 echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
5572 if test "$usb_redir" = "yes" ; then
5573 echo "CONFIG_USB_REDIR=y" >> $config_host_mak
5576 if test "$opengl" = "yes" ; then
5577 echo "CONFIG_OPENGL=y" >> $config_host_mak
5578 echo "OPENGL_CFLAGS=$opengl_cflags" >> $config_host_mak
5579 echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
5580 if test "$opengl_dmabuf" = "yes" ; then
5581 echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
5585 if test "$avx2_opt" = "yes" ; then
5586 echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
5589 if test "$lzo" = "yes" ; then
5590 echo "CONFIG_LZO=y" >> $config_host_mak
5593 if test "$snappy" = "yes" ; then
5594 echo "CONFIG_SNAPPY=y" >> $config_host_mak
5597 if test "$bzip2" = "yes" ; then
5598 echo "CONFIG_BZIP2=y" >> $config_host_mak
5599 echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
5602 if test "$libiscsi" = "yes" ; then
5603 echo "CONFIG_LIBISCSI=m" >> $config_host_mak
5604 echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
5605 echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
5608 if test "$libnfs" = "yes" ; then
5609 echo "CONFIG_LIBNFS=m" >> $config_host_mak
5610 echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
5613 if test "$seccomp" = "yes"; then
5614 echo "CONFIG_SECCOMP=y" >> $config_host_mak
5617 # XXX: suppress that
5618 if [ "$bsd" = "yes" ] ; then
5619 echo "CONFIG_BSD=y" >> $config_host_mak
5622 if test "$localtime_r" = "yes" ; then
5623 echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
5625 if test "$qom_cast_debug" = "yes" ; then
5626 echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
5628 if test "$rbd" = "yes" ; then
5629 echo "CONFIG_RBD=m" >> $config_host_mak
5630 echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
5631 echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
5634 echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
5635 if test "$coroutine_pool" = "yes" ; then
5636 echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
5637 else
5638 echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
5641 if test "$debug_stack_usage" = "yes" ; then
5642 echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
5645 if test "$open_by_handle_at" = "yes" ; then
5646 echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
5649 if test "$linux_magic_h" = "yes" ; then
5650 echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
5653 if test "$pragma_diagnostic_available" = "yes" ; then
5654 echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
5657 if test "$valgrind_h" = "yes" ; then
5658 echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
5661 if test "$has_environ" = "yes" ; then
5662 echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
5665 if test "$cpuid_h" = "yes" ; then
5666 echo "CONFIG_CPUID_H=y" >> $config_host_mak
5669 if test "$int128" = "yes" ; then
5670 echo "CONFIG_INT128=y" >> $config_host_mak
5673 if test "$atomic128" = "yes" ; then
5674 echo "CONFIG_ATOMIC128=y" >> $config_host_mak
5677 if test "$atomic64" = "yes" ; then
5678 echo "CONFIG_ATOMIC64=y" >> $config_host_mak
5681 if test "$getauxval" = "yes" ; then
5682 echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
5685 if test "$glusterfs" = "yes" ; then
5686 echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
5687 echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
5688 echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
5691 if test "$glusterfs_xlator_opt" = "yes" ; then
5692 echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
5695 if test "$glusterfs_discard" = "yes" ; then
5696 echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
5699 if test "$glusterfs_zerofill" = "yes" ; then
5700 echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
5703 if test "$archipelago" = "yes" ; then
5704 echo "CONFIG_ARCHIPELAGO=m" >> $config_host_mak
5705 echo "ARCHIPELAGO_LIBS=$archipelago_libs" >> $config_host_mak
5708 if test "$libssh2" = "yes" ; then
5709 echo "CONFIG_LIBSSH2=m" >> $config_host_mak
5710 echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
5711 echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak
5714 # USB host support
5715 if test "$libusb" = "yes"; then
5716 echo "HOST_USB=libusb legacy" >> $config_host_mak
5717 else
5718 echo "HOST_USB=stub" >> $config_host_mak
5721 # TPM passthrough support?
5722 if test "$tpm" = "yes"; then
5723 echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak
5724 if test "$tpm_passthrough" = "yes"; then
5725 echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
5729 echo "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
5730 if have_backend "nop"; then
5731 echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
5733 if have_backend "simple"; then
5734 echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
5735 # Set the appropriate trace file.
5736 trace_file="\"$trace_file-\" FMT_pid"
5738 if have_backend "log"; then
5739 echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
5741 if have_backend "ust"; then
5742 echo "CONFIG_TRACE_UST=y" >> $config_host_mak
5744 if have_backend "dtrace"; then
5745 echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
5746 if test "$trace_backend_stap" = "yes" ; then
5747 echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
5750 if have_backend "ftrace"; then
5751 if test "$linux" = "yes" ; then
5752 echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
5753 else
5754 feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
5757 if have_backend "syslog"; then
5758 if test "$posix_syslog" = "yes" ; then
5759 echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
5760 else
5761 feature_not_found "syslog(trace backend)" "syslog not available"
5764 echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
5766 if test "$rdma" = "yes" ; then
5767 echo "CONFIG_RDMA=y" >> $config_host_mak
5770 if test "$have_rtnetlink" = "yes" ; then
5771 echo "CONFIG_RTNETLINK=y" >> $config_host_mak
5774 if test "$replication" = "yes" ; then
5775 echo "CONFIG_REPLICATION=y" >> $config_host_mak
5778 if test "$have_af_vsock" = "yes" ; then
5779 echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
5782 # Hold two types of flag:
5783 # CONFIG_THREAD_SETNAME_BYTHREAD - we've got a way of setting the name on
5784 # a thread we have a handle to
5785 # CONFIG_PTHREAD_SETNAME_NP - A way of doing it on a particular
5786 # platform
5787 if test "$pthread_setname_np" = "yes" ; then
5788 echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
5789 echo "CONFIG_PTHREAD_SETNAME_NP=y" >> $config_host_mak
5792 if test "$tcg_interpreter" = "yes"; then
5793 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
5794 elif test "$ARCH" = "sparc64" ; then
5795 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
5796 elif test "$ARCH" = "s390x" ; then
5797 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
5798 elif test "$ARCH" = "x86_64" -o "$ARCH" = "x32" ; then
5799 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
5800 elif test "$ARCH" = "ppc64" ; then
5801 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/ppc $QEMU_INCLUDES"
5802 else
5803 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
5805 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg $QEMU_INCLUDES"
5807 echo "TOOLS=$tools" >> $config_host_mak
5808 echo "ROMS=$roms" >> $config_host_mak
5809 echo "MAKE=$make" >> $config_host_mak
5810 echo "INSTALL=$install" >> $config_host_mak
5811 echo "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
5812 echo "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
5813 echo "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
5814 echo "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
5815 echo "PYTHON=$python" >> $config_host_mak
5816 echo "CC=$cc" >> $config_host_mak
5817 if $iasl -h > /dev/null 2>&1; then
5818 echo "IASL=$iasl" >> $config_host_mak
5820 echo "CC_I386=$cc_i386" >> $config_host_mak
5821 echo "HOST_CC=$host_cc" >> $config_host_mak
5822 echo "CXX=$cxx" >> $config_host_mak
5823 echo "OBJCC=$objcc" >> $config_host_mak
5824 echo "AR=$ar" >> $config_host_mak
5825 echo "ARFLAGS=$ARFLAGS" >> $config_host_mak
5826 echo "AS=$as" >> $config_host_mak
5827 echo "CCAS=$ccas" >> $config_host_mak
5828 echo "CPP=$cpp" >> $config_host_mak
5829 echo "OBJCOPY=$objcopy" >> $config_host_mak
5830 echo "LD=$ld" >> $config_host_mak
5831 echo "NM=$nm" >> $config_host_mak
5832 echo "WINDRES=$windres" >> $config_host_mak
5833 echo "CFLAGS=$CFLAGS" >> $config_host_mak
5834 echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
5835 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
5836 echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
5837 if test "$sparse" = "yes" ; then
5838 echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_host_mak
5839 echo "CPP := REAL_CC=\"\$(CPP)\" cgcc" >> $config_host_mak
5840 echo "CXX := REAL_CC=\"\$(CXX)\" cgcc" >> $config_host_mak
5841 echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_host_mak
5842 echo "QEMU_CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
5844 if test "$cross_prefix" != ""; then
5845 echo "AUTOCONF_HOST := --host=${cross_prefix%-}" >> $config_host_mak
5846 else
5847 echo "AUTOCONF_HOST := " >> $config_host_mak
5849 echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
5850 echo "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
5851 echo "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
5852 echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
5853 echo "LIBS+=$LIBS" >> $config_host_mak
5854 echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
5855 echo "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
5856 echo "EXESUF=$EXESUF" >> $config_host_mak
5857 echo "DSOSUF=$DSOSUF" >> $config_host_mak
5858 echo "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
5859 echo "LIBS_QGA+=$libs_qga" >> $config_host_mak
5860 echo "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
5861 echo "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
5862 echo "POD2MAN=$POD2MAN" >> $config_host_mak
5863 echo "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
5864 if test "$gcov" = "yes" ; then
5865 echo "CONFIG_GCOV=y" >> $config_host_mak
5866 echo "GCOV=$gcov_tool" >> $config_host_mak
5869 # use included Linux headers
5870 if test "$linux" = "yes" ; then
5871 mkdir -p linux-headers
5872 case "$cpu" in
5873 i386|x86_64|x32)
5874 linux_arch=x86
5876 ppcemb|ppc|ppc64)
5877 linux_arch=powerpc
5879 s390x)
5880 linux_arch=s390
5882 aarch64)
5883 linux_arch=arm64
5885 mips64)
5886 linux_arch=mips
5889 # For most CPUs the kernel architecture name and QEMU CPU name match.
5890 linux_arch="$cpu"
5892 esac
5893 # For non-KVM architectures we will not have asm headers
5894 if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
5895 symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
5899 for target in $target_list; do
5900 target_dir="$target"
5901 config_target_mak=$target_dir/config-target.mak
5902 target_name=$(echo $target | cut -d '-' -f 1)
5903 target_bigendian="no"
5905 case "$target_name" in
5906 armeb|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or32|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
5907 target_bigendian=yes
5909 esac
5910 target_softmmu="no"
5911 target_user_only="no"
5912 target_linux_user="no"
5913 target_bsd_user="no"
5914 case "$target" in
5915 ${target_name}-softmmu)
5916 target_softmmu="yes"
5918 ${target_name}-linux-user)
5919 if test "$linux" != "yes" ; then
5920 error_exit "Target '$target' is only available on a Linux host"
5922 target_user_only="yes"
5923 target_linux_user="yes"
5925 ${target_name}-bsd-user)
5926 if test "$bsd" != "yes" ; then
5927 error_exit "Target '$target' is only available on a BSD host"
5929 target_user_only="yes"
5930 target_bsd_user="yes"
5933 error_exit "Target '$target' not recognised"
5934 exit 1
5936 esac
5938 mkdir -p $target_dir
5939 echo "# Automatically generated by configure - do not modify" > $config_target_mak
5941 bflt="no"
5942 interp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
5943 gdb_xml_files=""
5945 TARGET_ARCH="$target_name"
5946 TARGET_BASE_ARCH=""
5947 TARGET_ABI_DIR=""
5949 case "$target_name" in
5950 i386)
5952 x86_64)
5953 TARGET_BASE_ARCH=i386
5955 alpha)
5957 arm|armeb)
5958 TARGET_ARCH=arm
5959 bflt="yes"
5960 gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
5962 aarch64)
5963 TARGET_BASE_ARCH=arm
5964 bflt="yes"
5965 gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
5967 cris)
5969 lm32)
5971 m68k)
5972 bflt="yes"
5973 gdb_xml_files="cf-core.xml cf-fp.xml"
5975 microblaze|microblazeel)
5976 TARGET_ARCH=microblaze
5977 bflt="yes"
5979 mips|mipsel)
5980 TARGET_ARCH=mips
5981 echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
5983 mipsn32|mipsn32el)
5984 TARGET_ARCH=mips64
5985 TARGET_BASE_ARCH=mips
5986 echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
5987 echo "TARGET_ABI32=y" >> $config_target_mak
5989 mips64|mips64el)
5990 TARGET_ARCH=mips64
5991 TARGET_BASE_ARCH=mips
5992 echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
5994 moxie)
5996 or32)
5997 TARGET_ARCH=openrisc
5998 TARGET_BASE_ARCH=openrisc
6000 ppc)
6001 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
6003 ppcemb)
6004 TARGET_BASE_ARCH=ppc
6005 TARGET_ABI_DIR=ppc
6006 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
6008 ppc64)
6009 TARGET_BASE_ARCH=ppc
6010 TARGET_ABI_DIR=ppc
6011 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
6013 ppc64le)
6014 TARGET_ARCH=ppc64
6015 TARGET_BASE_ARCH=ppc
6016 TARGET_ABI_DIR=ppc
6017 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
6019 ppc64abi32)
6020 TARGET_ARCH=ppc64
6021 TARGET_BASE_ARCH=ppc
6022 TARGET_ABI_DIR=ppc
6023 echo "TARGET_ABI32=y" >> $config_target_mak
6024 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
6026 sh4|sh4eb)
6027 TARGET_ARCH=sh4
6028 bflt="yes"
6030 sparc)
6032 sparc64)
6033 TARGET_BASE_ARCH=sparc
6035 sparc32plus)
6036 TARGET_ARCH=sparc64
6037 TARGET_BASE_ARCH=sparc
6038 TARGET_ABI_DIR=sparc
6039 echo "TARGET_ABI32=y" >> $config_target_mak
6041 s390x)
6042 gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml s390-cr.xml s390-virt.xml"
6044 tilegx)
6046 tricore)
6048 unicore32)
6050 xtensa|xtensaeb)
6051 TARGET_ARCH=xtensa
6054 error_exit "Unsupported target CPU"
6056 esac
6057 # TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
6058 if [ "$TARGET_BASE_ARCH" = "" ]; then
6059 TARGET_BASE_ARCH=$TARGET_ARCH
6062 symlink "$source_path/Makefile.target" "$target_dir/Makefile"
6064 upper() {
6065 echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
6068 target_arch_name="$(upper $TARGET_ARCH)"
6069 echo "TARGET_$target_arch_name=y" >> $config_target_mak
6070 echo "TARGET_NAME=$target_name" >> $config_target_mak
6071 echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
6072 if [ "$TARGET_ABI_DIR" = "" ]; then
6073 TARGET_ABI_DIR=$TARGET_ARCH
6075 echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
6076 if [ "$HOST_VARIANT_DIR" != "" ]; then
6077 echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
6079 case "$target_name" in
6080 i386|x86_64)
6081 if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
6082 echo "CONFIG_XEN=y" >> $config_target_mak
6083 if test "$xen_pci_passthrough" = yes; then
6084 echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
6089 esac
6090 case "$target_name" in
6091 aarch64|arm|i386|x86_64|ppcemb|ppc|ppc64|s390x|mipsel|mips)
6092 # Make sure the target and host cpus are compatible
6093 if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
6094 \( "$target_name" = "$cpu" -o \
6095 \( "$target_name" = "ppcemb" -a "$cpu" = "ppc" \) -o \
6096 \( "$target_name" = "ppc64" -a "$cpu" = "ppc" \) -o \
6097 \( "$target_name" = "ppc" -a "$cpu" = "ppc64" \) -o \
6098 \( "$target_name" = "ppcemb" -a "$cpu" = "ppc64" \) -o \
6099 \( "$target_name" = "mipsel" -a "$cpu" = "mips" \) -o \
6100 \( "$target_name" = "x86_64" -a "$cpu" = "i386" \) -o \
6101 \( "$target_name" = "i386" -a "$cpu" = "x86_64" \) -o \
6102 \( "$target_name" = "x86_64" -a "$cpu" = "x32" \) -o \
6103 \( "$target_name" = "i386" -a "$cpu" = "x32" \) \) ; then
6104 echo "CONFIG_KVM=y" >> $config_target_mak
6105 if test "$vhost_net" = "yes" ; then
6106 echo "CONFIG_VHOST_NET=y" >> $config_target_mak
6107 echo "CONFIG_VHOST_NET_TEST_$target_name=y" >> $config_host_mak
6110 esac
6111 if test "$hax" = "yes" ; then
6112 if test "$target_softmmu" = "yes" ; then
6113 case "$target_name" in
6114 i386|x86_64)
6115 echo "CONFIG_HAX=y" >> $config_target_mak
6117 esac
6120 if test "$target_bigendian" = "yes" ; then
6121 echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
6123 if test "$target_softmmu" = "yes" ; then
6124 echo "CONFIG_SOFTMMU=y" >> $config_target_mak
6126 if test "$target_user_only" = "yes" ; then
6127 echo "CONFIG_USER_ONLY=y" >> $config_target_mak
6128 echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
6130 if test "$target_linux_user" = "yes" ; then
6131 echo "CONFIG_LINUX_USER=y" >> $config_target_mak
6133 list=""
6134 if test ! -z "$gdb_xml_files" ; then
6135 for x in $gdb_xml_files; do
6136 list="$list $source_path/gdb-xml/$x"
6137 done
6138 echo "TARGET_XML_FILES=$list" >> $config_target_mak
6141 if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
6142 echo "TARGET_HAS_BFLT=y" >> $config_target_mak
6144 if test "$target_bsd_user" = "yes" ; then
6145 echo "CONFIG_BSD_USER=y" >> $config_target_mak
6148 # generate QEMU_CFLAGS/LDFLAGS for targets
6150 cflags=""
6151 ldflags=""
6153 disas_config() {
6154 echo "CONFIG_${1}_DIS=y" >> $config_target_mak
6155 echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
6158 for i in $ARCH $TARGET_BASE_ARCH ; do
6159 case "$i" in
6160 alpha)
6161 disas_config "ALPHA"
6163 aarch64)
6164 if test -n "${cxx}"; then
6165 disas_config "ARM_A64"
6168 arm)
6169 disas_config "ARM"
6170 if test -n "${cxx}"; then
6171 disas_config "ARM_A64"
6174 cris)
6175 disas_config "CRIS"
6177 i386|x86_64|x32)
6178 disas_config "I386"
6180 ia64*)
6181 disas_config "IA64"
6183 lm32)
6184 disas_config "LM32"
6186 m68k)
6187 disas_config "M68K"
6189 microblaze*)
6190 disas_config "MICROBLAZE"
6192 mips*)
6193 disas_config "MIPS"
6195 moxie*)
6196 disas_config "MOXIE"
6198 or32)
6199 disas_config "OPENRISC"
6201 ppc*)
6202 disas_config "PPC"
6204 s390*)
6205 disas_config "S390"
6207 sh4)
6208 disas_config "SH4"
6210 sparc*)
6211 disas_config "SPARC"
6213 xtensa*)
6214 disas_config "XTENSA"
6216 esac
6217 done
6218 if test "$tcg_interpreter" = "yes" ; then
6219 disas_config "TCI"
6222 case "$ARCH" in
6223 alpha)
6224 # Ensure there's only a single GP
6225 cflags="-msmall-data $cflags"
6227 esac
6229 if test "$gprof" = "yes" ; then
6230 echo "TARGET_GPROF=yes" >> $config_target_mak
6231 if test "$target_linux_user" = "yes" ; then
6232 cflags="-p $cflags"
6233 ldflags="-p $ldflags"
6235 if test "$target_softmmu" = "yes" ; then
6236 ldflags="-p $ldflags"
6237 echo "GPROF_CFLAGS=-p" >> $config_target_mak
6241 if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
6242 ldflags="$ldflags $textseg_ldflags"
6245 echo "LDFLAGS+=$ldflags" >> $config_target_mak
6246 echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak
6248 done # for target in $targets
6250 if [ "$pixman" = "internal" ]; then
6251 echo "config-host.h: subdir-pixman" >> $config_host_mak
6254 if [ "$dtc_internal" = "yes" ]; then
6255 echo "config-host.h: subdir-dtc" >> $config_host_mak
6258 if test "$numa" = "yes"; then
6259 echo "CONFIG_NUMA=y" >> $config_host_mak
6262 if test "$ccache_cpp2" = "yes"; then
6263 echo "export CCACHE_CPP2=y" >> $config_host_mak
6266 # build tree in object directory in case the source is not in the current directory
6267 DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests"
6268 DIRS="$DIRS docs fsdev"
6269 DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
6270 DIRS="$DIRS roms/seabios roms/vgabios"
6271 DIRS="$DIRS qapi-generated"
6272 FILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
6273 FILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
6274 FILES="$FILES tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
6275 FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
6276 FILES="$FILES pc-bios/spapr-rtas/Makefile"
6277 FILES="$FILES pc-bios/s390-ccw/Makefile"
6278 FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
6279 FILES="$FILES pc-bios/qemu-icon.bmp"
6280 for bios_file in \
6281 $source_path/pc-bios/*.bin \
6282 $source_path/pc-bios/*.lid \
6283 $source_path/pc-bios/*.aml \
6284 $source_path/pc-bios/*.rom \
6285 $source_path/pc-bios/*.dtb \
6286 $source_path/pc-bios/*.img \
6287 $source_path/pc-bios/openbios-* \
6288 $source_path/pc-bios/u-boot.* \
6289 $source_path/pc-bios/palcode-*
6291 FILES="$FILES pc-bios/$(basename $bios_file)"
6292 done
6293 for test_file in $(find $source_path/tests/acpi-test-data -type f)
6295 FILES="$FILES tests/acpi-test-data$(echo $test_file | sed -e 's/.*acpi-test-data//')"
6296 done
6297 mkdir -p $DIRS
6298 for f in $FILES ; do
6299 if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
6300 symlink "$source_path/$f" "$f"
6302 done
6304 # temporary config to build submodules
6305 for rom in seabios vgabios ; do
6306 config_mak=roms/$rom/config.mak
6307 echo "# Automatically generated by configure - do not modify" > $config_mak
6308 echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
6309 echo "AS=$as" >> $config_mak
6310 echo "CCAS=$ccas" >> $config_mak
6311 echo "CC=$cc" >> $config_mak
6312 echo "BCC=bcc" >> $config_mak
6313 echo "CPP=$cpp" >> $config_mak
6314 echo "OBJCOPY=objcopy" >> $config_mak
6315 echo "IASL=$iasl" >> $config_mak
6316 echo "LD=$ld" >> $config_mak
6317 done
6319 # set up tests data directory
6320 if [ ! -e tests/data ]; then
6321 symlink "$source_path/tests/data" tests/data
6324 # set up qemu-iotests in this build directory
6325 iotests_common_env="tests/qemu-iotests/common.env"
6326 iotests_check="tests/qemu-iotests/check"
6328 echo "# Automatically generated by configure - do not modify" > "$iotests_common_env"
6329 echo >> "$iotests_common_env"
6330 echo "export PYTHON='$python'" >> "$iotests_common_env"
6332 if [ ! -e "$iotests_check" ]; then
6333 symlink "$source_path/$iotests_check" "$iotests_check"
6336 # Save the configure command line for later reuse.
6337 cat <<EOD >config.status
6338 #!/bin/sh
6339 # Generated by configure.
6340 # Run this file to recreate the current configuration.
6341 # Compiler output produced by configure, useful for debugging
6342 # configure, is in config.log if it exists.
6344 printf "exec" >>config.status
6345 printf " '%s'" "$0" "$@" >>config.status
6346 echo ' "$@"' >>config.status
6347 chmod +x config.status
6349 rm -r "$TMPDIR1"