crypto: add support for TLS priority string override
[qemu/ar7.git] / configure
blob65bd1ff86cdcb085f01839e6c91aa2b273672080
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 TMPL="${TMPDIR1}/${TMPB}.lo"
32 TMPA="${TMPDIR1}/lib${TMPB}.la"
33 TMPE="${TMPDIR1}/${TMPB}.exe"
34 TMPMO="${TMPDIR1}/${TMPB}.mo"
36 rm -f config.log
38 # Print a helpful header at the top of config.log
39 echo "# QEMU configure log $(date)" >> config.log
40 printf "# Configured with:" >> config.log
41 printf " '%s'" "$0" "$@" >> config.log
42 echo >> config.log
43 echo "#" >> config.log
45 error_exit() {
46 echo
47 echo "ERROR: $1"
48 while test -n "$2"; do
49 echo " $2"
50 shift
51 done
52 echo
53 exit 1
56 do_compiler() {
57 # Run the compiler, capturing its output to the log. First argument
58 # is compiler binary to execute.
59 local compiler="$1"
60 shift
61 echo $compiler "$@" >> config.log
62 $compiler "$@" >> config.log 2>&1 || return $?
63 # Test passed. If this is an --enable-werror build, rerun
64 # the test with -Werror and bail out if it fails. This
65 # makes warning-generating-errors in configure test code
66 # obvious to developers.
67 if test "$werror" != "yes"; then
68 return 0
70 # Don't bother rerunning the compile if we were already using -Werror
71 case "$*" in
72 *-Werror*)
73 return 0
75 esac
76 echo $compiler -Werror "$@" >> config.log
77 $compiler -Werror "$@" >> config.log 2>&1 && return $?
78 error_exit "configure test passed without -Werror but failed with -Werror." \
79 "This is probably a bug in the configure script. The failing command" \
80 "will be at the bottom of config.log." \
81 "You can run configure with --disable-werror to bypass this check."
84 do_cc() {
85 do_compiler "$cc" "$@"
88 do_cxx() {
89 do_compiler "$cxx" "$@"
92 update_cxxflags() {
93 # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
94 # options which some versions of GCC's C++ compiler complain about
95 # because they only make sense for C programs.
96 QEMU_CXXFLAGS=
97 for arg in $QEMU_CFLAGS; do
98 case $arg in
99 -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
100 -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
103 QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
105 esac
106 done
109 compile_object() {
110 local_cflags="$1"
111 do_cc $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
114 compile_prog() {
115 local_cflags="$1"
116 local_ldflags="$2"
117 do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
120 # symbolically link $1 to $2. Portable version of "ln -sf".
121 symlink() {
122 rm -rf "$2"
123 mkdir -p "$(dirname "$2")"
124 ln -s "$1" "$2"
127 # check whether a command is available to this shell (may be either an
128 # executable or a builtin)
129 has() {
130 type "$1" >/dev/null 2>&1
133 # search for an executable in PATH
134 path_of() {
135 local_command="$1"
136 local_ifs="$IFS"
137 local_dir=""
139 # pathname has a dir component?
140 if [ "${local_command#*/}" != "$local_command" ]; then
141 if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
142 echo "$local_command"
143 return 0
146 if [ -z "$local_command" ]; then
147 return 1
150 IFS=:
151 for local_dir in $PATH; do
152 if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
153 echo "$local_dir/$local_command"
154 IFS="${local_ifs:-$(printf ' \t\n')}"
155 return 0
157 done
158 # not found
159 IFS="${local_ifs:-$(printf ' \t\n')}"
160 return 1
163 have_backend () {
164 echo "$trace_backends" | grep "$1" >/dev/null
167 # default parameters
168 source_path=$(dirname "$0")
169 cpu=""
170 iasl="iasl"
171 interp_prefix="/usr/gnemul/qemu-%M"
172 static="no"
173 cross_prefix=""
174 audio_drv_list=""
175 block_drv_rw_whitelist=""
176 block_drv_ro_whitelist=""
177 host_cc="cc"
178 libs_softmmu=""
179 libs_tools=""
180 audio_pt_int=""
181 audio_win_int=""
182 cc_i386=i386-pc-linux-gnu-gcc
183 libs_qga=""
184 debug_info="yes"
185 stack_protector=""
187 # Don't accept a target_list environment variable.
188 unset target_list
190 # Default value for a variable defining feature "foo".
191 # * foo="no" feature will only be used if --enable-foo arg is given
192 # * foo="" feature will be searched for, and if found, will be used
193 # unless --disable-foo is given
194 # * foo="yes" this value will only be set by --enable-foo flag.
195 # feature will searched for,
196 # if not found, configure exits with error
198 # Always add --enable-foo and --disable-foo command line args.
199 # Distributions want to ensure that several features are compiled in, and it
200 # is impossible without a --enable-foo that exits if a feature is not found.
202 bluez=""
203 brlapi=""
204 curl=""
205 curses=""
206 docs=""
207 fdt=""
208 netmap="no"
209 pixman=""
210 sdl=""
211 sdlabi=""
212 virtfs=""
213 vnc="yes"
214 sparse="no"
215 uuid=""
216 vde=""
217 vnc_sasl=""
218 vnc_jpeg=""
219 vnc_png=""
220 xen=""
221 xen_ctrl_version=""
222 xen_pv_domain_build="no"
223 xen_pci_passthrough=""
224 linux_aio=""
225 cap_ng=""
226 attr=""
227 libattr=""
228 xfs=""
230 vhost_net="no"
231 vhost_scsi="no"
232 kvm="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 linux="no"
263 solaris="no"
264 profiler="no"
265 cocoa="no"
266 softmmu="yes"
267 linux_user="no"
268 bsd_user="no"
269 aix="no"
270 blobs="yes"
271 pkgversion=""
272 pie=""
273 qom_cast_debug="yes"
274 trace_backends="log"
275 trace_file="trace"
276 spice=""
277 rbd=""
278 smartcard=""
279 libusb=""
280 usb_redir=""
281 opengl=""
282 opengl_dmabuf="no"
283 avx2_opt="no"
284 zlib="yes"
285 lzo=""
286 snappy=""
287 bzip2=""
288 guest_agent=""
289 guest_agent_with_vss="no"
290 guest_agent_ntddscsi="no"
291 guest_agent_msi=""
292 vss_win32_sdk=""
293 win_sdk="no"
294 want_tools="yes"
295 libiscsi=""
296 libnfs=""
297 coroutine=""
298 coroutine_pool=""
299 seccomp=""
300 glusterfs=""
301 glusterfs_xlator_opt="no"
302 glusterfs_discard="no"
303 glusterfs_zerofill="no"
304 archipelago="no"
305 gtk=""
306 gtkabi=""
307 gtk_gl="no"
308 gnutls=""
309 gnutls_rnd=""
310 nettle=""
311 nettle_kdf="no"
312 gcrypt=""
313 gcrypt_kdf="no"
314 vte=""
315 virglrenderer=""
316 tpm="yes"
317 libssh2=""
318 vhdx=""
319 numa=""
320 tcmalloc="no"
321 jemalloc="no"
323 # parse CC options first
324 for opt do
325 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
326 case "$opt" in
327 --cross-prefix=*) cross_prefix="$optarg"
329 --cc=*) CC="$optarg"
331 --cxx=*) CXX="$optarg"
333 --source-path=*) source_path="$optarg"
335 --cpu=*) cpu="$optarg"
337 --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
338 EXTRA_CFLAGS="$optarg"
340 --extra-ldflags=*) LDFLAGS="$LDFLAGS $optarg"
341 EXTRA_LDFLAGS="$optarg"
343 --enable-debug-info) debug_info="yes"
345 --disable-debug-info) debug_info="no"
347 esac
348 done
349 # OS specific
350 # Using uname is really, really broken. Once we have the right set of checks
351 # we can eliminate its usage altogether.
353 # Preferred compiler:
354 # ${CC} (if set)
355 # ${cross_prefix}gcc (if cross-prefix specified)
356 # system compiler
357 if test -z "${CC}${cross_prefix}"; then
358 cc="$host_cc"
359 else
360 cc="${CC-${cross_prefix}gcc}"
363 if test -z "${CXX}${cross_prefix}"; then
364 cxx="c++"
365 else
366 cxx="${CXX-${cross_prefix}g++}"
369 ar="${AR-${cross_prefix}ar}"
370 as="${AS-${cross_prefix}as}"
371 cpp="${CPP-$cc -E}"
372 objcopy="${OBJCOPY-${cross_prefix}objcopy}"
373 ld="${LD-${cross_prefix}ld}"
374 nm="${NM-${cross_prefix}nm}"
375 strip="${STRIP-${cross_prefix}strip}"
376 windres="${WINDRES-${cross_prefix}windres}"
377 pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
378 query_pkg_config() {
379 "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
381 pkg_config=query_pkg_config
382 sdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
383 sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
385 # If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
386 ARFLAGS="${ARFLAGS-rv}"
388 # default flags for all hosts
389 QEMU_CFLAGS="-fno-strict-aliasing -fno-common $QEMU_CFLAGS"
390 QEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
391 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
392 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
393 QEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/include"
394 if test "$debug_info" = "yes"; then
395 CFLAGS="-g $CFLAGS"
396 LDFLAGS="-g $LDFLAGS"
399 # make source path absolute
400 source_path=$(cd "$source_path"; pwd)
402 # running configure in the source tree?
403 # we know that's the case if configure is there.
404 if test -f "./configure"; then
405 pwd_is_source_path="y"
406 else
407 pwd_is_source_path="n"
410 check_define() {
411 cat > $TMPC <<EOF
412 #if !defined($1)
413 #error $1 not defined
414 #endif
415 int main(void) { return 0; }
417 compile_object
420 check_include() {
421 cat > $TMPC <<EOF
422 #include <$1>
423 int main(void) { return 0; }
425 compile_object
428 write_c_skeleton() {
429 cat > $TMPC <<EOF
430 int main(void) { return 0; }
434 if check_define __linux__ ; then
435 targetos="Linux"
436 elif check_define _WIN32 ; then
437 targetos='MINGW32'
438 elif check_define __OpenBSD__ ; then
439 targetos='OpenBSD'
440 elif check_define __sun__ ; then
441 targetos='SunOS'
442 elif check_define __HAIKU__ ; then
443 targetos='Haiku'
444 else
445 targetos=$(uname -s)
448 # Some host OSes need non-standard checks for which CPU to use.
449 # Note that these checks are broken for cross-compilation: if you're
450 # cross-compiling to one of these OSes then you'll need to specify
451 # the correct CPU with the --cpu option.
452 case $targetos in
453 Darwin)
454 # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
455 # run 64-bit userspace code.
456 # If the user didn't specify a CPU explicitly and the kernel says this is
457 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
458 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
459 cpu="x86_64"
462 SunOS)
463 # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
464 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
465 cpu="x86_64"
467 esac
469 if test ! -z "$cpu" ; then
470 # command line argument
472 elif check_define __i386__ ; then
473 cpu="i386"
474 elif check_define __x86_64__ ; then
475 if check_define __ILP32__ ; then
476 cpu="x32"
477 else
478 cpu="x86_64"
480 elif check_define __sparc__ ; then
481 if check_define __arch64__ ; then
482 cpu="sparc64"
483 else
484 cpu="sparc"
486 elif check_define _ARCH_PPC ; then
487 if check_define _ARCH_PPC64 ; then
488 cpu="ppc64"
489 else
490 cpu="ppc"
492 elif check_define __mips__ ; then
493 cpu="mips"
494 elif check_define __ia64__ ; then
495 cpu="ia64"
496 elif check_define __s390__ ; then
497 if check_define __s390x__ ; then
498 cpu="s390x"
499 else
500 cpu="s390"
502 elif check_define __arm__ ; then
503 cpu="arm"
504 elif check_define __aarch64__ ; then
505 cpu="aarch64"
506 elif check_define __hppa__ ; then
507 cpu="hppa"
508 else
509 cpu=$(uname -m)
512 ARCH=
513 # Normalise host CPU name and set ARCH.
514 # Note that this case should only have supported host CPUs, not guests.
515 case "$cpu" in
516 ia64|ppc|ppc64|s390|s390x|sparc64|x32)
517 cpu="$cpu"
519 i386|i486|i586|i686|i86pc|BePC)
520 cpu="i386"
522 x86_64|amd64)
523 cpu="x86_64"
525 armv*b|armv*l|arm)
526 cpu="arm"
528 aarch64)
529 cpu="aarch64"
531 mips*)
532 cpu="mips"
534 sparc|sun4[cdmuv])
535 cpu="sparc"
538 # This will result in either an error or falling back to TCI later
539 ARCH=unknown
541 esac
542 if test -z "$ARCH"; then
543 ARCH="$cpu"
546 # OS specific
548 # host *BSD for user mode
549 HOST_VARIANT_DIR=""
551 case $targetos in
552 CYGWIN*)
553 mingw32="yes"
554 QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
555 audio_possible_drivers="sdl"
556 audio_drv_list="sdl"
558 MINGW32*)
559 mingw32="yes"
560 audio_possible_drivers="dsound sdl"
561 if check_include dsound.h; then
562 audio_drv_list="dsound"
563 else
564 audio_drv_list=""
567 GNU/kFreeBSD)
568 bsd="yes"
569 audio_drv_list="oss"
570 audio_possible_drivers="oss sdl pa"
572 FreeBSD)
573 bsd="yes"
574 make="${MAKE-gmake}"
575 audio_drv_list="oss"
576 audio_possible_drivers="oss sdl pa"
577 # needed for kinfo_getvmmap(3) in libutil.h
578 LIBS="-lutil $LIBS"
579 netmap="" # enable netmap autodetect
580 HOST_VARIANT_DIR="freebsd"
582 DragonFly)
583 bsd="yes"
584 make="${MAKE-gmake}"
585 audio_drv_list="oss"
586 audio_possible_drivers="oss sdl pa"
587 HOST_VARIANT_DIR="dragonfly"
589 NetBSD)
590 bsd="yes"
591 make="${MAKE-gmake}"
592 audio_drv_list="oss"
593 audio_possible_drivers="oss sdl"
594 oss_lib="-lossaudio"
595 HOST_VARIANT_DIR="netbsd"
597 OpenBSD)
598 bsd="yes"
599 make="${MAKE-gmake}"
600 audio_drv_list="sdl"
601 audio_possible_drivers="sdl"
602 HOST_VARIANT_DIR="openbsd"
604 Darwin)
605 bsd="yes"
606 darwin="yes"
607 LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
608 if [ "$cpu" = "x86_64" ] ; then
609 QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
610 LDFLAGS="-arch x86_64 $LDFLAGS"
612 cocoa="yes"
613 audio_drv_list="coreaudio"
614 audio_possible_drivers="coreaudio sdl"
615 LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
616 libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
617 # Disable attempts to use ObjectiveC features in os/object.h since they
618 # won't work when we're compiling with gcc as a C compiler.
619 QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
620 HOST_VARIANT_DIR="darwin"
622 SunOS)
623 solaris="yes"
624 make="${MAKE-gmake}"
625 install="${INSTALL-ginstall}"
626 ld="gld"
627 smbd="${SMBD-/usr/sfw/sbin/smbd}"
628 needs_libsunmath="no"
629 solarisrev=$(uname -r | cut -f2 -d.)
630 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
631 if test "$solarisrev" -le 9 ; then
632 if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
633 needs_libsunmath="yes"
634 QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
635 LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
636 LIBS="-lsunmath $LIBS"
637 else
638 error_exit "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without" \
639 "libsunmath from the Sun Studio compilers tools, due to a lack of" \
640 "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86" \
641 "Studio 11 can be downloaded from www.sun.com."
645 if test -f /usr/include/sys/soundcard.h ; then
646 audio_drv_list="oss"
648 audio_possible_drivers="oss sdl"
649 # needed for CMSG_ macros in sys/socket.h
650 QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
651 # needed for TIOCWIN* defines in termios.h
652 QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
653 QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
654 solarisnetlibs="-lsocket -lnsl -lresolv"
655 LIBS="$solarisnetlibs $LIBS"
656 libs_qga="$solarisnetlibs $libs_qga"
658 AIX)
659 aix="yes"
660 make="${MAKE-gmake}"
662 Haiku)
663 haiku="yes"
664 QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
665 LIBS="-lposix_error_mapper -lnetwork $LIBS"
668 audio_drv_list="oss"
669 audio_possible_drivers="oss alsa sdl pa"
670 linux="yes"
671 linux_user="yes"
672 kvm="yes"
673 vhost_net="yes"
674 vhost_scsi="yes"
675 QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
677 esac
679 if [ "$bsd" = "yes" ] ; then
680 if [ "$darwin" != "yes" ] ; then
681 bsd_user="yes"
685 : ${make=${MAKE-make}}
686 : ${install=${INSTALL-install}}
687 : ${python=${PYTHON-python}}
688 : ${smbd=${SMBD-/usr/sbin/smbd}}
690 # Default objcc to clang if available, otherwise use CC
691 if has clang; then
692 objcc=clang
693 else
694 objcc="$cc"
697 if test "$mingw32" = "yes" ; then
698 EXESUF=".exe"
699 DSOSUF=".dll"
700 QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
701 # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
702 QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
703 # MinGW needs -mthreads for TLS and macro _MT.
704 QEMU_CFLAGS="-mthreads $QEMU_CFLAGS"
705 LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
706 write_c_skeleton;
707 if compile_prog "" "-liberty" ; then
708 LIBS="-liberty $LIBS"
710 prefix="c:/Program Files/QEMU"
711 mandir="\${prefix}"
712 datadir="\${prefix}"
713 qemu_docdir="\${prefix}"
714 bindir="\${prefix}"
715 sysconfdir="\${prefix}"
716 local_statedir=
717 confsuffix=""
718 libs_qga="-lws2_32 -lwinmm -lpowrprof -liphlpapi -lnetapi32 $libs_qga"
721 werror=""
723 for opt do
724 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
725 case "$opt" in
726 --help|-h) show_help=yes
728 --version|-V) exec cat $source_path/VERSION
730 --prefix=*) prefix="$optarg"
732 --interp-prefix=*) interp_prefix="$optarg"
734 --source-path=*)
736 --cross-prefix=*)
738 --cc=*)
740 --host-cc=*) host_cc="$optarg"
742 --cxx=*)
744 --iasl=*) iasl="$optarg"
746 --objcc=*) objcc="$optarg"
748 --make=*) make="$optarg"
750 --install=*) install="$optarg"
752 --python=*) python="$optarg"
754 --gcov=*) gcov_tool="$optarg"
756 --smbd=*) smbd="$optarg"
758 --extra-cflags=*)
760 --extra-ldflags=*)
762 --enable-debug-info)
764 --disable-debug-info)
766 --enable-modules)
767 modules="yes"
769 --disable-modules)
770 modules="no"
772 --cpu=*)
774 --target-list=*) target_list="$optarg"
776 --enable-trace-backends=*) trace_backends="$optarg"
778 # XXX: backwards compatibility
779 --enable-trace-backend=*) trace_backends="$optarg"
781 --with-trace-file=*) trace_file="$optarg"
783 --enable-gprof) gprof="yes"
785 --enable-gcov) gcov="yes"
787 --static)
788 static="yes"
789 LDFLAGS="-static $LDFLAGS"
790 QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
792 --mandir=*) mandir="$optarg"
794 --bindir=*) bindir="$optarg"
796 --libdir=*) libdir="$optarg"
798 --libexecdir=*) libexecdir="$optarg"
800 --includedir=*) includedir="$optarg"
802 --datadir=*) datadir="$optarg"
804 --with-confsuffix=*) confsuffix="$optarg"
806 --docdir=*) qemu_docdir="$optarg"
808 --sysconfdir=*) sysconfdir="$optarg"
810 --localstatedir=*) local_statedir="$optarg"
812 --sbindir=*|--sharedstatedir=*|\
813 --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
814 --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
815 # These switches are silently ignored, for compatibility with
816 # autoconf-generated configure scripts. This allows QEMU's
817 # configure to be used by RPM and similar macros that set
818 # lots of directory switches by default.
820 --with-system-pixman) pixman="system"
822 --without-system-pixman) pixman="internal"
824 --without-pixman) pixman="none"
826 --disable-sdl) sdl="no"
828 --enable-sdl) sdl="yes"
830 --with-sdlabi=*) sdlabi="$optarg"
832 --disable-qom-cast-debug) qom_cast_debug="no"
834 --enable-qom-cast-debug) qom_cast_debug="yes"
836 --disable-virtfs) virtfs="no"
838 --enable-virtfs) virtfs="yes"
840 --disable-vnc) vnc="no"
842 --enable-vnc) vnc="yes"
844 --oss-lib=*) oss_lib="$optarg"
846 --audio-drv-list=*) audio_drv_list="$optarg"
848 --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
850 --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
852 --enable-debug-tcg) debug_tcg="yes"
854 --disable-debug-tcg) debug_tcg="no"
856 --enable-debug)
857 # Enable debugging options that aren't excessively noisy
858 debug_tcg="yes"
859 debug="yes"
860 strip_opt="no"
861 fortify_source="no"
863 --enable-sparse) sparse="yes"
865 --disable-sparse) sparse="no"
867 --disable-strip) strip_opt="no"
869 --disable-vnc-sasl) vnc_sasl="no"
871 --enable-vnc-sasl) vnc_sasl="yes"
873 --disable-vnc-jpeg) vnc_jpeg="no"
875 --enable-vnc-jpeg) vnc_jpeg="yes"
877 --disable-vnc-png) vnc_png="no"
879 --enable-vnc-png) vnc_png="yes"
881 --disable-slirp) slirp="no"
883 --disable-uuid) uuid="no"
885 --enable-uuid) uuid="yes"
887 --disable-vde) vde="no"
889 --enable-vde) vde="yes"
891 --disable-netmap) netmap="no"
893 --enable-netmap) netmap="yes"
895 --disable-xen) xen="no"
897 --enable-xen) xen="yes"
899 --disable-xen-pci-passthrough) xen_pci_passthrough="no"
901 --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
903 --disable-xen-pv-domain-build) xen_pv_domain_build="no"
905 --enable-xen-pv-domain-build) xen_pv_domain_build="yes"
907 --disable-brlapi) brlapi="no"
909 --enable-brlapi) brlapi="yes"
911 --disable-bluez) bluez="no"
913 --enable-bluez) bluez="yes"
915 --disable-kvm) kvm="no"
917 --enable-kvm) kvm="yes"
919 --disable-tcg-interpreter) tcg_interpreter="no"
921 --enable-tcg-interpreter) tcg_interpreter="yes"
923 --disable-cap-ng) cap_ng="no"
925 --enable-cap-ng) cap_ng="yes"
927 --disable-spice) spice="no"
929 --enable-spice) spice="yes"
931 --disable-libiscsi) libiscsi="no"
933 --enable-libiscsi) libiscsi="yes"
935 --disable-libnfs) libnfs="no"
937 --enable-libnfs) libnfs="yes"
939 --enable-profiler) profiler="yes"
941 --disable-cocoa) cocoa="no"
943 --enable-cocoa)
944 cocoa="yes" ;
945 audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
947 --disable-system) softmmu="no"
949 --enable-system) softmmu="yes"
951 --disable-user)
952 linux_user="no" ;
953 bsd_user="no" ;
955 --enable-user) ;;
956 --disable-linux-user) linux_user="no"
958 --enable-linux-user) linux_user="yes"
960 --disable-bsd-user) bsd_user="no"
962 --enable-bsd-user) bsd_user="yes"
964 --enable-pie) pie="yes"
966 --disable-pie) pie="no"
968 --enable-werror) werror="yes"
970 --disable-werror) werror="no"
972 --enable-stack-protector) stack_protector="yes"
974 --disable-stack-protector) stack_protector="no"
976 --disable-curses) curses="no"
978 --enable-curses) curses="yes"
980 --disable-curl) curl="no"
982 --enable-curl) curl="yes"
984 --disable-fdt) fdt="no"
986 --enable-fdt) fdt="yes"
988 --disable-linux-aio) linux_aio="no"
990 --enable-linux-aio) linux_aio="yes"
992 --disable-attr) attr="no"
994 --enable-attr) attr="yes"
996 --disable-blobs) blobs="no"
998 --with-pkgversion=*) pkgversion=" ($optarg)"
1000 --with-coroutine=*) coroutine="$optarg"
1002 --disable-coroutine-pool) coroutine_pool="no"
1004 --enable-coroutine-pool) coroutine_pool="yes"
1006 --disable-docs) docs="no"
1008 --enable-docs) docs="yes"
1010 --disable-vhost-net) vhost_net="no"
1012 --enable-vhost-net) vhost_net="yes"
1014 --disable-vhost-scsi) vhost_scsi="no"
1016 --enable-vhost-scsi) vhost_scsi="yes"
1018 --disable-opengl) opengl="no"
1020 --enable-opengl) opengl="yes"
1022 --disable-rbd) rbd="no"
1024 --enable-rbd) rbd="yes"
1026 --disable-xfsctl) xfs="no"
1028 --enable-xfsctl) xfs="yes"
1030 --disable-smartcard) smartcard="no"
1032 --enable-smartcard) smartcard="yes"
1034 --disable-libusb) libusb="no"
1036 --enable-libusb) libusb="yes"
1038 --disable-usb-redir) usb_redir="no"
1040 --enable-usb-redir) usb_redir="yes"
1042 --disable-zlib-test) zlib="no"
1044 --disable-lzo) lzo="no"
1046 --enable-lzo) lzo="yes"
1048 --disable-snappy) snappy="no"
1050 --enable-snappy) snappy="yes"
1052 --disable-bzip2) bzip2="no"
1054 --enable-bzip2) bzip2="yes"
1056 --enable-guest-agent) guest_agent="yes"
1058 --disable-guest-agent) guest_agent="no"
1060 --enable-guest-agent-msi) guest_agent_msi="yes"
1062 --disable-guest-agent-msi) guest_agent_msi="no"
1064 --with-vss-sdk) vss_win32_sdk=""
1066 --with-vss-sdk=*) vss_win32_sdk="$optarg"
1068 --without-vss-sdk) vss_win32_sdk="no"
1070 --with-win-sdk) win_sdk=""
1072 --with-win-sdk=*) win_sdk="$optarg"
1074 --without-win-sdk) win_sdk="no"
1076 --enable-tools) want_tools="yes"
1078 --disable-tools) want_tools="no"
1080 --enable-seccomp) seccomp="yes"
1082 --disable-seccomp) seccomp="no"
1084 --disable-glusterfs) glusterfs="no"
1086 --enable-glusterfs) glusterfs="yes"
1088 --disable-archipelago) archipelago="no"
1090 --enable-archipelago) archipelago="yes"
1092 --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
1093 echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1095 --disable-gtk) gtk="no"
1097 --enable-gtk) gtk="yes"
1099 --disable-gnutls) gnutls="no"
1101 --enable-gnutls) gnutls="yes"
1103 --disable-nettle) nettle="no"
1105 --enable-nettle) nettle="yes"
1107 --disable-gcrypt) gcrypt="no"
1109 --enable-gcrypt) gcrypt="yes"
1111 --enable-rdma) rdma="yes"
1113 --disable-rdma) rdma="no"
1115 --with-gtkabi=*) gtkabi="$optarg"
1117 --disable-vte) vte="no"
1119 --enable-vte) vte="yes"
1121 --disable-virglrenderer) virglrenderer="no"
1123 --enable-virglrenderer) virglrenderer="yes"
1125 --disable-tpm) tpm="no"
1127 --enable-tpm) tpm="yes"
1129 --disable-libssh2) libssh2="no"
1131 --enable-libssh2) libssh2="yes"
1133 --enable-vhdx) vhdx="yes"
1135 --disable-vhdx) vhdx="no"
1137 --disable-numa) numa="no"
1139 --enable-numa) numa="yes"
1141 --disable-tcmalloc) tcmalloc="no"
1143 --enable-tcmalloc) tcmalloc="yes"
1145 --disable-jemalloc) jemalloc="no"
1147 --enable-jemalloc) jemalloc="yes"
1150 echo "ERROR: unknown option $opt"
1151 echo "Try '$0 --help' for more information"
1152 exit 1
1154 esac
1155 done
1157 if ! has $python; then
1158 error_exit "Python not found. Use --python=/path/to/python"
1161 # Note that if the Python conditional here evaluates True we will exit
1162 # with status 1 which is a shell 'false' value.
1163 if ! $python -c 'import sys; sys.exit(sys.version_info < (2,6) or sys.version_info >= (3,))'; then
1164 error_exit "Cannot use '$python', Python 2.6 or later is required." \
1165 "Note that Python 3 or later is not yet supported." \
1166 "Use --python=/path/to/python to specify a supported Python."
1169 # Suppress writing compiled files
1170 python="$python -B"
1172 case "$cpu" in
1173 ppc)
1174 CPU_CFLAGS="-m32"
1175 LDFLAGS="-m32 $LDFLAGS"
1177 ppc64)
1178 CPU_CFLAGS="-m64"
1179 LDFLAGS="-m64 $LDFLAGS"
1181 sparc)
1182 LDFLAGS="-m32 $LDFLAGS"
1183 CPU_CFLAGS="-m32 -mcpu=ultrasparc"
1185 sparc64)
1186 LDFLAGS="-m64 $LDFLAGS"
1187 CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1189 s390)
1190 CPU_CFLAGS="-m31"
1191 LDFLAGS="-m31 $LDFLAGS"
1193 s390x)
1194 CPU_CFLAGS="-m64"
1195 LDFLAGS="-m64 $LDFLAGS"
1197 i386)
1198 CPU_CFLAGS="-m32"
1199 LDFLAGS="-m32 $LDFLAGS"
1200 cc_i386='$(CC) -m32'
1202 x86_64)
1203 CPU_CFLAGS="-m64"
1204 LDFLAGS="-m64 $LDFLAGS"
1205 cc_i386='$(CC) -m32'
1207 x32)
1208 CPU_CFLAGS="-mx32"
1209 LDFLAGS="-mx32 $LDFLAGS"
1210 cc_i386='$(CC) -m32'
1212 # No special flags required for other host CPUs
1213 esac
1215 QEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
1216 EXTRA_CFLAGS="$CPU_CFLAGS $EXTRA_CFLAGS"
1218 # For user-mode emulation the host arch has to be one we explicitly
1219 # support, even if we're using TCI.
1220 if [ "$ARCH" = "unknown" ]; then
1221 bsd_user="no"
1222 linux_user="no"
1225 default_target_list=""
1227 mak_wilds=""
1229 if [ "$softmmu" = "yes" ]; then
1230 mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
1232 if [ "$linux_user" = "yes" ]; then
1233 mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
1235 if [ "$bsd_user" = "yes" ]; then
1236 mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
1239 for config in $mak_wilds; do
1240 default_target_list="${default_target_list} $(basename "$config" .mak)"
1241 done
1243 if test x"$show_help" = x"yes" ; then
1244 cat << EOF
1246 Usage: configure [options]
1247 Options: [defaults in brackets after descriptions]
1249 Standard options:
1250 --help print this message
1251 --prefix=PREFIX install in PREFIX [$prefix]
1252 --interp-prefix=PREFIX where to find shared libraries, etc.
1253 use %M for cpu name [$interp_prefix]
1254 --target-list=LIST set target list (default: build everything)
1255 $(echo Available targets: $default_target_list | \
1256 fold -s -w 53 | sed -e 's/^/ /')
1258 Advanced options (experts only):
1259 --source-path=PATH path of source code [$source_path]
1260 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
1261 --cc=CC use C compiler CC [$cc]
1262 --iasl=IASL use ACPI compiler IASL [$iasl]
1263 --host-cc=CC use C compiler CC [$host_cc] for code run at
1264 build time
1265 --cxx=CXX use C++ compiler CXX [$cxx]
1266 --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
1267 --extra-cflags=CFLAGS append extra C compiler flags QEMU_CFLAGS
1268 --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS
1269 --make=MAKE use specified make [$make]
1270 --install=INSTALL use specified install [$install]
1271 --python=PYTHON use specified python [$python]
1272 --smbd=SMBD use specified smbd [$smbd]
1273 --static enable static build [$static]
1274 --mandir=PATH install man pages in PATH
1275 --datadir=PATH install firmware in PATH$confsuffix
1276 --docdir=PATH install documentation in PATH$confsuffix
1277 --bindir=PATH install binaries in PATH
1278 --libdir=PATH install libraries in PATH
1279 --sysconfdir=PATH install config in PATH$confsuffix
1280 --localstatedir=PATH install local state in PATH (set at runtime on win32)
1281 --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
1282 --enable-debug enable common debug build options
1283 --disable-strip disable stripping binaries
1284 --disable-werror disable compilation abort on warning
1285 --disable-stack-protector disable compiler-provided stack protection
1286 --audio-drv-list=LIST set audio drivers list:
1287 Available drivers: $audio_possible_drivers
1288 --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L
1289 --block-drv-rw-whitelist=L
1290 set block driver read-write whitelist
1291 (affects only QEMU, not qemu-img)
1292 --block-drv-ro-whitelist=L
1293 set block driver read-only whitelist
1294 (affects only QEMU, not qemu-img)
1295 --enable-trace-backends=B Set trace backend
1296 Available backends: $($python $source_path/scripts/tracetool.py --list-backends)
1297 --with-trace-file=NAME Full PATH,NAME of file to store traces
1298 Default:trace-<pid>
1299 --disable-slirp disable SLIRP userspace network connectivity
1300 --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
1301 --oss-lib path to OSS library
1302 --cpu=CPU Build for host CPU [$cpu]
1303 --with-coroutine=BACKEND coroutine backend. Supported options:
1304 gthread, ucontext, sigaltstack, windows
1305 --enable-gcov enable test coverage analysis with gcov
1306 --gcov=GCOV use specified gcov [$gcov_tool]
1307 --disable-blobs disable installing provided firmware blobs
1308 --with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent
1309 --with-win-sdk=SDK-path path to Windows Platform SDK (to build VSS .tlb)
1311 Optional features, enabled with --enable-FEATURE and
1312 disabled with --disable-FEATURE, default is enabled if available:
1314 system all system emulation targets
1315 user supported user emulation targets
1316 linux-user all linux usermode emulation targets
1317 bsd-user all BSD usermode emulation targets
1318 docs build documentation
1319 guest-agent build the QEMU Guest Agent
1320 guest-agent-msi build guest agent Windows MSI installation package
1321 pie Position Independent Executables
1322 modules modules support
1323 debug-tcg TCG debugging (default is disabled)
1324 debug-info debugging information
1325 sparse sparse checker
1327 gnutls GNUTLS cryptography support
1328 nettle nettle cryptography support
1329 gcrypt libgcrypt cryptography support
1330 sdl SDL UI
1331 --with-sdlabi select preferred SDL ABI 1.2 or 2.0
1332 gtk gtk UI
1333 --with-gtkabi select preferred GTK ABI 2.0 or 3.0
1334 vte vte support for the gtk UI
1335 curses curses UI
1336 vnc VNC UI support
1337 vnc-sasl SASL encryption for VNC server
1338 vnc-jpeg JPEG lossy compression for VNC server
1339 vnc-png PNG compression for VNC server
1340 cocoa Cocoa UI (Mac OS X only)
1341 virtfs VirtFS
1342 xen xen backend driver support
1343 xen-pci-passthrough
1344 brlapi BrlAPI (Braile)
1345 curl curl connectivity
1346 fdt fdt device tree
1347 bluez bluez stack connectivity
1348 kvm KVM acceleration support
1349 rdma RDMA-based migration support
1350 uuid uuid support
1351 vde support for vde network
1352 netmap support for netmap network
1353 linux-aio Linux AIO support
1354 cap-ng libcap-ng support
1355 attr attr and xattr support
1356 vhost-net vhost-net acceleration support
1357 spice spice
1358 rbd rados block device (rbd)
1359 libiscsi iscsi support
1360 libnfs nfs support
1361 smartcard smartcard support (libcacard)
1362 libusb libusb (for usb passthrough)
1363 usb-redir usb network redirection support
1364 lzo support of lzo compression library
1365 snappy support of snappy compression library
1366 bzip2 support of bzip2 compression library
1367 (for reading bzip2-compressed dmg images)
1368 seccomp seccomp support
1369 coroutine-pool coroutine freelist (better performance)
1370 glusterfs GlusterFS backend
1371 archipelago Archipelago backend
1372 tpm TPM support
1373 libssh2 ssh block device support
1374 vhdx support for the Microsoft VHDX image format
1375 numa libnuma support
1376 tcmalloc tcmalloc support
1377 jemalloc jemalloc support
1379 NOTE: The object files are built at the place where configure is launched
1381 exit 0
1384 # Now we have handled --enable-tcg-interpreter and know we're not just
1385 # printing the help message, bail out if the host CPU isn't supported.
1386 if test "$ARCH" = "unknown"; then
1387 if test "$tcg_interpreter" = "yes" ; then
1388 echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1389 else
1390 error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1394 # Consult white-list to determine whether to enable werror
1395 # by default. Only enable by default for git builds
1396 if test -z "$werror" ; then
1397 if test -d "$source_path/.git" -a \
1398 \( "$linux" = "yes" -o "$mingw32" = "yes" \) ; then
1399 werror="yes"
1400 else
1401 werror="no"
1405 # check that the C compiler works.
1406 write_c_skeleton;
1407 if compile_object ; then
1408 : C compiler works ok
1409 else
1410 error_exit "\"$cc\" either does not exist or does not work"
1412 if ! compile_prog ; then
1413 error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
1416 # Check that the C++ compiler exists and works with the C compiler
1417 if has $cxx; then
1418 cat > $TMPC <<EOF
1419 int c_function(void);
1420 int main(void) { return c_function(); }
1423 compile_object
1425 cat > $TMPCXX <<EOF
1426 extern "C" {
1427 int c_function(void);
1429 int c_function(void) { return 42; }
1432 update_cxxflags
1434 if do_cxx $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $LDFLAGS; then
1435 # C++ compiler $cxx works ok with C compiler $cc
1437 else
1438 echo "C++ compiler $cxx does not work with C compiler $cc"
1439 echo "Disabling C++ specific optional code"
1440 cxx=
1442 else
1443 echo "No C++ compiler available; disabling C++ specific optional code"
1444 cxx=
1447 gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
1448 gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
1449 gcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1450 gcc_flags="-Wendif-labels $gcc_flags"
1451 gcc_flags="-Wno-initializer-overrides $gcc_flags"
1452 gcc_flags="-Wno-string-plus-int $gcc_flags"
1453 # Note that we do not add -Werror to gcc_flags here, because that would
1454 # enable it for all configure tests. If a configure test failed due
1455 # to -Werror this would just silently disable some features,
1456 # so it's too error prone.
1458 cc_has_warning_flag() {
1459 write_c_skeleton;
1461 # Use the positive sense of the flag when testing for -Wno-wombat
1462 # support (gcc will happily accept the -Wno- form of unknown
1463 # warning options).
1464 optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
1465 compile_prog "-Werror $optflag" ""
1468 for flag in $gcc_flags; do
1469 if cc_has_warning_flag $flag ; then
1470 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1472 done
1474 if test "$stack_protector" != "no"; then
1475 cat > $TMPC << EOF
1476 int main(int argc, char *argv[])
1478 char arr[64], *p = arr, *c = argv[0];
1479 while (*c) {
1480 *p++ = *c++;
1482 return 0;
1485 gcc_flags="-fstack-protector-strong -fstack-protector-all"
1486 sp_on=0
1487 for flag in $gcc_flags; do
1488 # We need to check both a compile and a link, since some compiler
1489 # setups fail only on a .c->.o compile and some only at link time
1490 if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
1491 compile_prog "-Werror $flag" ""; then
1492 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1493 sp_on=1
1494 break
1496 done
1497 if test "$stack_protector" = yes; then
1498 if test $sp_on = 0; then
1499 error_exit "Stack protector not supported"
1504 # Workaround for http://gcc.gnu.org/PR55489. Happens with -fPIE/-fPIC and
1505 # large functions that use global variables. The bug is in all releases of
1506 # GCC, but it became particularly acute in 4.6.x and 4.7.x. It is fixed in
1507 # 4.7.3 and 4.8.0. We should be able to delete this at the end of 2013.
1508 cat > $TMPC << EOF
1509 #if __GNUC__ == 4 && (__GNUC_MINOR__ == 6 || (__GNUC_MINOR__ == 7 && __GNUC_PATCHLEVEL__ <= 2))
1510 int main(void) { return 0; }
1511 #else
1512 #error No bug in this compiler.
1513 #endif
1515 if compile_prog "-Werror -fno-gcse" "" ; then
1516 TRANSLATE_OPT_CFLAGS=-fno-gcse
1519 if test "$static" = "yes" ; then
1520 if test "$modules" = "yes" ; then
1521 error_exit "static and modules are mutually incompatible"
1523 if test "$pie" = "yes" ; then
1524 error_exit "static and pie are mutually incompatible"
1525 else
1526 pie="no"
1530 # Unconditional check for compiler __thread support
1531 cat > $TMPC << EOF
1532 static __thread int tls_var;
1533 int main(void) { return tls_var; }
1536 if ! compile_prog "-Werror" "" ; then
1537 error_exit "Your compiler does not support the __thread specifier for " \
1538 "Thread-Local Storage (TLS). Please upgrade to a version that does."
1541 if test "$pie" = ""; then
1542 case "$cpu-$targetos" in
1543 i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
1546 pie="no"
1548 esac
1551 if test "$pie" != "no" ; then
1552 cat > $TMPC << EOF
1554 #ifdef __linux__
1555 # define THREAD __thread
1556 #else
1557 # define THREAD
1558 #endif
1560 static THREAD int tls_var;
1562 int main(void) { return tls_var; }
1565 if compile_prog "-fPIE -DPIE" "-pie"; then
1566 QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
1567 LDFLAGS="-pie $LDFLAGS"
1568 pie="yes"
1569 if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
1570 LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
1572 else
1573 if test "$pie" = "yes"; then
1574 error_exit "PIE not available due to missing toolchain support"
1575 else
1576 echo "Disabling PIE due to missing toolchain support"
1577 pie="no"
1581 if compile_prog "-Werror -fno-pie" "-nopie"; then
1582 CFLAGS_NOPIE="-fno-pie"
1583 LDFLAGS_NOPIE="-nopie"
1587 ##########################################
1588 # __sync_fetch_and_and requires at least -march=i486. Many toolchains
1589 # use i686 as default anyway, but for those that don't, an explicit
1590 # specification is necessary
1592 if test "$cpu" = "i386"; then
1593 cat > $TMPC << EOF
1594 static int sfaa(int *ptr)
1596 return __sync_fetch_and_and(ptr, 0);
1599 int main(void)
1601 int val = 42;
1602 val = __sync_val_compare_and_swap(&val, 0, 1);
1603 sfaa(&val);
1604 return val;
1607 if ! compile_prog "" "" ; then
1608 QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
1612 #########################################
1613 # Solaris specific configure tool chain decisions
1615 if test "$solaris" = "yes" ; then
1616 if has $install; then
1618 else
1619 error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
1620 "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
1621 "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1623 if test "$(path_of $install)" = "/usr/sbin/install" ; then
1624 error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
1625 "try ginstall from the GNU fileutils available from www.blastwave.org" \
1626 "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1628 if has ar; then
1630 else
1631 if test -f /usr/ccs/bin/ar ; then
1632 error_exit "No path includes ar" \
1633 "Add /usr/ccs/bin to your path and rerun configure"
1635 error_exit "No path includes ar"
1639 if test -z "${target_list+xxx}" ; then
1640 target_list="$default_target_list"
1641 else
1642 target_list=$(echo "$target_list" | sed -e 's/,/ /g')
1645 # Check that we recognised the target name; this allows a more
1646 # friendly error message than if we let it fall through.
1647 for target in $target_list; do
1648 case " $default_target_list " in
1649 *" $target "*)
1652 error_exit "Unknown target name '$target'"
1654 esac
1655 done
1657 # see if system emulation was really requested
1658 case " $target_list " in
1659 *"-softmmu "*) softmmu=yes
1661 *) softmmu=no
1663 esac
1665 feature_not_found() {
1666 feature=$1
1667 remedy=$2
1669 error_exit "User requested feature $feature" \
1670 "configure was not able to find it." \
1671 "$remedy"
1674 # ---
1675 # big/little endian test
1676 cat > $TMPC << EOF
1677 short big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
1678 short little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
1679 extern int foo(short *, short *);
1680 int main(int argc, char *argv[]) {
1681 return foo(big_endian, little_endian);
1685 if compile_object ; then
1686 if grep -q BiGeNdIaN $TMPO ; then
1687 bigendian="yes"
1688 elif grep -q LiTtLeEnDiAn $TMPO ; then
1689 bigendian="no"
1690 else
1691 echo big/little test failed
1693 else
1694 echo big/little test failed
1697 ##########################################
1698 # cocoa implies not SDL or GTK
1699 # (the cocoa UI code currently assumes it is always the active UI
1700 # and doesn't interact well with other UI frontend code)
1701 if test "$cocoa" = "yes"; then
1702 if test "$sdl" = "yes"; then
1703 error_exit "Cocoa and SDL UIs cannot both be enabled at once"
1705 if test "$gtk" = "yes"; then
1706 error_exit "Cocoa and GTK UIs cannot both be enabled at once"
1708 gtk=no
1709 sdl=no
1712 ##########################################
1713 # L2TPV3 probe
1715 cat > $TMPC <<EOF
1716 #include <sys/socket.h>
1717 #include <linux/ip.h>
1718 int main(void) { return sizeof(struct mmsghdr); }
1720 if compile_prog "" "" ; then
1721 l2tpv3=yes
1722 else
1723 l2tpv3=no
1726 ##########################################
1727 # MinGW / Mingw-w64 localtime_r/gmtime_r check
1729 if test "$mingw32" = "yes"; then
1730 # Some versions of MinGW / Mingw-w64 lack localtime_r
1731 # and gmtime_r entirely.
1733 # Some versions of Mingw-w64 define a macro for
1734 # localtime_r/gmtime_r.
1736 # Some versions of Mingw-w64 will define functions
1737 # for localtime_r/gmtime_r, but only if you have
1738 # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
1739 # though, unistd.h and pthread.h both define
1740 # that for you.
1742 # So this #undef localtime_r and #include <unistd.h>
1743 # are not in fact redundant.
1744 cat > $TMPC << EOF
1745 #include <unistd.h>
1746 #include <time.h>
1747 #undef localtime_r
1748 int main(void) { localtime_r(NULL, NULL); return 0; }
1750 if compile_prog "" "" ; then
1751 localtime_r="yes"
1752 else
1753 localtime_r="no"
1757 ##########################################
1758 # pkg-config probe
1760 if ! has "$pkg_config_exe"; then
1761 error_exit "pkg-config binary '$pkg_config_exe' not found"
1764 ##########################################
1765 # NPTL probe
1767 if test "$linux_user" = "yes"; then
1768 cat > $TMPC <<EOF
1769 #include <sched.h>
1770 #include <linux/futex.h>
1771 int main(void) {
1772 #if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1773 #error bork
1774 #endif
1775 return 0;
1778 if ! compile_object ; then
1779 feature_not_found "nptl" "Install glibc and linux kernel headers."
1783 ##########################################
1784 # avx2 optimization requirement check
1786 cat > $TMPC << EOF
1787 #pragma GCC push_options
1788 #pragma GCC target("avx2")
1789 #include <cpuid.h>
1790 #include <immintrin.h>
1792 static int bar(void *a) {
1793 return _mm256_movemask_epi8(_mm256_cmpeq_epi8(*(__m256i *)a, (__m256i){0}));
1795 static void *bar_ifunc(void) {return (void*) bar;}
1796 int foo(void *a) __attribute__((ifunc("bar_ifunc")));
1797 int main(int argc, char *argv[]) { return foo(argv[0]);}
1799 if compile_object "" ; then
1800 if has readelf; then
1801 if readelf --syms $TMPO 2>/dev/null |grep -q "IFUNC.*foo"; then
1802 avx2_opt="yes"
1807 #########################################
1808 # zlib check
1810 if test "$zlib" != "no" ; then
1811 cat > $TMPC << EOF
1812 #include <zlib.h>
1813 int main(void) { zlibVersion(); return 0; }
1815 if compile_prog "" "-lz" ; then
1817 else
1818 error_exit "zlib check failed" \
1819 "Make sure to have the zlib libs and headers installed."
1822 LIBS="$LIBS -lz"
1824 ##########################################
1825 # lzo check
1827 if test "$lzo" != "no" ; then
1828 cat > $TMPC << EOF
1829 #include <lzo/lzo1x.h>
1830 int main(void) { lzo_version(); return 0; }
1832 if compile_prog "" "-llzo2" ; then
1833 libs_softmmu="$libs_softmmu -llzo2"
1834 lzo="yes"
1835 else
1836 if test "$lzo" = "yes"; then
1837 feature_not_found "liblzo2" "Install liblzo2 devel"
1839 lzo="no"
1843 ##########################################
1844 # snappy check
1846 if test "$snappy" != "no" ; then
1847 cat > $TMPC << EOF
1848 #include <snappy-c.h>
1849 int main(void) { snappy_max_compressed_length(4096); return 0; }
1851 if compile_prog "" "-lsnappy" ; then
1852 libs_softmmu="$libs_softmmu -lsnappy"
1853 snappy="yes"
1854 else
1855 if test "$snappy" = "yes"; then
1856 feature_not_found "libsnappy" "Install libsnappy devel"
1858 snappy="no"
1862 ##########################################
1863 # bzip2 check
1865 if test "$bzip2" != "no" ; then
1866 cat > $TMPC << EOF
1867 #include <bzlib.h>
1868 int main(void) { BZ2_bzlibVersion(); return 0; }
1870 if compile_prog "" "-lbz2" ; then
1871 bzip2="yes"
1872 else
1873 if test "$bzip2" = "yes"; then
1874 feature_not_found "libbzip2" "Install libbzip2 devel"
1876 bzip2="no"
1880 ##########################################
1881 # libseccomp check
1883 if test "$seccomp" != "no" ; then
1884 case "$cpu" in
1885 i386|x86_64)
1886 libseccomp_minver="2.1.0"
1888 mips)
1889 libseccomp_minver="2.2.0"
1891 arm|aarch64)
1892 libseccomp_minver="2.2.3"
1894 ppc|ppc64)
1895 libseccomp_minver="2.3.0"
1898 libseccomp_minver=""
1900 esac
1902 if test "$libseccomp_minver" != "" &&
1903 $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
1904 libs_softmmu="$libs_softmmu $($pkg_config --libs libseccomp)"
1905 QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags libseccomp)"
1906 seccomp="yes"
1907 else
1908 if test "$seccomp" = "yes" ; then
1909 if test "$libseccomp_minver" != "" ; then
1910 feature_not_found "libseccomp" \
1911 "Install libseccomp devel >= $libseccomp_minver"
1912 else
1913 feature_not_found "libseccomp" \
1914 "libseccomp is not supported for host cpu $cpu"
1917 seccomp="no"
1920 ##########################################
1921 # xen probe
1923 if test "$xen" != "no" ; then
1924 xen_libs="-lxenstore -lxenctrl -lxenguest"
1925 xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
1927 # First we test whether Xen headers and libraries are available.
1928 # If no, we are done and there is no Xen support.
1929 # If yes, more tests are run to detect the Xen version.
1931 # Xen (any)
1932 cat > $TMPC <<EOF
1933 #include <xenctrl.h>
1934 int main(void) {
1935 return 0;
1938 if ! compile_prog "" "$xen_libs" ; then
1939 # Xen not found
1940 if test "$xen" = "yes" ; then
1941 feature_not_found "xen" "Install xen devel"
1943 xen=no
1945 # Xen unstable
1946 elif
1947 cat > $TMPC <<EOF &&
1949 * If we have stable libs the we don't want the libxc compat
1950 * layers, regardless of what CFLAGS we may have been given.
1952 #undef XC_WANT_COMPAT_EVTCHN_API
1953 #undef XC_WANT_COMPAT_GNTTAB_API
1954 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
1955 #include <xenctrl.h>
1956 #include <xenstore.h>
1957 #include <xenevtchn.h>
1958 #include <xengnttab.h>
1959 #include <xenforeignmemory.h>
1960 #include <stdint.h>
1961 #include <xen/hvm/hvm_info_table.h>
1962 #if !defined(HVM_MAX_VCPUS)
1963 # error HVM_MAX_VCPUS not defined
1964 #endif
1965 int main(void) {
1966 xc_interface *xc = NULL;
1967 xenforeignmemory_handle *xfmem;
1968 xenevtchn_handle *xe;
1969 xengnttab_handle *xg;
1970 xen_domain_handle_t handle;
1972 xs_daemon_open();
1974 xc = xc_interface_open(0, 0, 0);
1975 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1976 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1977 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
1978 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
1979 xc_domain_create(xc, 0, handle, 0, NULL, NULL);
1981 xfmem = xenforeignmemory_open(0, 0);
1982 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
1984 xe = xenevtchn_open(0, 0);
1985 xenevtchn_fd(xe);
1987 xg = xengnttab_open(0, 0);
1988 xengnttab_map_grant_ref(xg, 0, 0, 0);
1990 return 0;
1993 compile_prog "" "$xen_libs $xen_stable_libs"
1994 then
1995 xen_ctrl_version=471
1996 xen=yes
1997 elif
1998 cat > $TMPC <<EOF &&
1999 #include <xenctrl.h>
2000 #include <stdint.h>
2001 int main(void) {
2002 xc_interface *xc = NULL;
2003 xen_domain_handle_t handle;
2004 xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2005 return 0;
2008 compile_prog "" "$xen_libs"
2009 then
2010 xen_ctrl_version=470
2011 xen=yes
2013 # Xen 4.6
2014 elif
2015 cat > $TMPC <<EOF &&
2016 #include <xenctrl.h>
2017 #include <xenstore.h>
2018 #include <stdint.h>
2019 #include <xen/hvm/hvm_info_table.h>
2020 #if !defined(HVM_MAX_VCPUS)
2021 # error HVM_MAX_VCPUS not defined
2022 #endif
2023 int main(void) {
2024 xc_interface *xc;
2025 xs_daemon_open();
2026 xc = xc_interface_open(0, 0, 0);
2027 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2028 xc_gnttab_open(NULL, 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_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2033 return 0;
2036 compile_prog "" "$xen_libs"
2037 then
2038 xen_ctrl_version=460
2039 xen=yes
2041 # Xen 4.5
2042 elif
2043 cat > $TMPC <<EOF &&
2044 #include <xenctrl.h>
2045 #include <xenstore.h>
2046 #include <stdint.h>
2047 #include <xen/hvm/hvm_info_table.h>
2048 #if !defined(HVM_MAX_VCPUS)
2049 # error HVM_MAX_VCPUS not defined
2050 #endif
2051 int main(void) {
2052 xc_interface *xc;
2053 xs_daemon_open();
2054 xc = xc_interface_open(0, 0, 0);
2055 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2056 xc_gnttab_open(NULL, 0);
2057 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2058 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2059 xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
2060 return 0;
2063 compile_prog "" "$xen_libs"
2064 then
2065 xen_ctrl_version=450
2066 xen=yes
2068 elif
2069 cat > $TMPC <<EOF &&
2070 #include <xenctrl.h>
2071 #include <xenstore.h>
2072 #include <stdint.h>
2073 #include <xen/hvm/hvm_info_table.h>
2074 #if !defined(HVM_MAX_VCPUS)
2075 # error HVM_MAX_VCPUS not defined
2076 #endif
2077 int main(void) {
2078 xc_interface *xc;
2079 xs_daemon_open();
2080 xc = xc_interface_open(0, 0, 0);
2081 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2082 xc_gnttab_open(NULL, 0);
2083 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2084 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2085 return 0;
2088 compile_prog "" "$xen_libs"
2089 then
2090 xen_ctrl_version=420
2091 xen=yes
2093 else
2094 if test "$xen" = "yes" ; then
2095 feature_not_found "xen (unsupported version)" \
2096 "Install a supported xen (xen 4.2 or newer)"
2098 xen=no
2101 if test "$xen" = yes; then
2102 if test $xen_ctrl_version -ge 471 ; then
2103 libs_softmmu="$xen_stable_libs $libs_softmmu"
2105 libs_softmmu="$xen_libs $libs_softmmu"
2109 if test "$xen_pci_passthrough" != "no"; then
2110 if test "$xen" = "yes" && test "$linux" = "yes"; then
2111 xen_pci_passthrough=yes
2112 else
2113 if test "$xen_pci_passthrough" = "yes"; then
2114 error_exit "User requested feature Xen PCI Passthrough" \
2115 " but this feature requires /sys from Linux"
2117 xen_pci_passthrough=no
2121 if test "$xen_pv_domain_build" = "yes" &&
2122 test "$xen" != "yes"; then
2123 error_exit "User requested Xen PV domain builder support" \
2124 "which requires Xen support."
2127 ##########################################
2128 # Sparse probe
2129 if test "$sparse" != "no" ; then
2130 if has cgcc; then
2131 sparse=yes
2132 else
2133 if test "$sparse" = "yes" ; then
2134 feature_not_found "sparse" "Install sparse binary"
2136 sparse=no
2140 ##########################################
2141 # X11 probe
2142 x11_cflags=
2143 x11_libs=-lX11
2144 if $pkg_config --exists "x11"; then
2145 x11_cflags=$($pkg_config --cflags x11)
2146 x11_libs=$($pkg_config --libs x11)
2149 ##########################################
2150 # GTK probe
2152 if test "$gtkabi" = ""; then
2153 # The GTK ABI was not specified explicitly, so try whether 2.0 is available.
2154 # Use 3.0 as a fallback if that is available.
2155 if $pkg_config --exists "gtk+-2.0 >= 2.18.0"; then
2156 gtkabi=2.0
2157 elif $pkg_config --exists "gtk+-3.0 >= 3.0.0"; then
2158 gtkabi=3.0
2159 else
2160 gtkabi=2.0
2164 if test "$gtk" != "no"; then
2165 gtkpackage="gtk+-$gtkabi"
2166 gtkx11package="gtk+-x11-$gtkabi"
2167 if test "$gtkabi" = "3.0" ; then
2168 gtkversion="3.0.0"
2169 else
2170 gtkversion="2.18.0"
2172 if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
2173 gtk_cflags=$($pkg_config --cflags $gtkpackage)
2174 gtk_libs=$($pkg_config --libs $gtkpackage)
2175 gtk_version=$($pkg_config --modversion $gtkpackage)
2176 if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
2177 gtk_cflags="$gtk_cflags $x11_cflags"
2178 gtk_libs="$gtk_libs $x11_libs"
2180 libs_softmmu="$gtk_libs $libs_softmmu"
2181 gtk="yes"
2182 elif test "$gtk" = "yes"; then
2183 feature_not_found "gtk" "Install gtk2 or gtk3 devel"
2184 else
2185 gtk="no"
2190 ##########################################
2191 # GNUTLS probe
2193 gnutls_works() {
2194 # Unfortunately some distros have bad pkg-config information for gnutls
2195 # such that it claims to exist but you get a compiler error if you try
2196 # to use the options returned by --libs. Specifically, Ubuntu for --static
2197 # builds doesn't work:
2198 # https://bugs.launchpad.net/ubuntu/+source/gnutls26/+bug/1478035
2200 # So sanity check the cflags/libs before assuming gnutls can be used.
2201 if ! $pkg_config --exists "gnutls"; then
2202 return 1
2205 write_c_skeleton
2206 compile_prog "$($pkg_config --cflags gnutls)" "$($pkg_config --libs gnutls)"
2209 gnutls_gcrypt=no
2210 gnutls_nettle=no
2211 if test "$gnutls" != "no"; then
2212 if gnutls_works; then
2213 gnutls_cflags=$($pkg_config --cflags gnutls)
2214 gnutls_libs=$($pkg_config --libs gnutls)
2215 libs_softmmu="$gnutls_libs $libs_softmmu"
2216 libs_tools="$gnutls_libs $libs_tools"
2217 QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
2218 gnutls="yes"
2220 # gnutls_rnd requires >= 2.11.0
2221 if $pkg_config --exists "gnutls >= 2.11.0"; then
2222 gnutls_rnd="yes"
2223 else
2224 gnutls_rnd="no"
2227 if $pkg_config --exists 'gnutls >= 3.0'; then
2228 gnutls_gcrypt=no
2229 gnutls_nettle=yes
2230 elif $pkg_config --exists 'gnutls >= 2.12'; then
2231 case $($pkg_config --libs --static gnutls) in
2232 *gcrypt*)
2233 gnutls_gcrypt=yes
2234 gnutls_nettle=no
2236 *nettle*)
2237 gnutls_gcrypt=no
2238 gnutls_nettle=yes
2241 gnutls_gcrypt=yes
2242 gnutls_nettle=no
2244 esac
2245 else
2246 gnutls_gcrypt=yes
2247 gnutls_nettle=no
2249 elif test "$gnutls" = "yes"; then
2250 feature_not_found "gnutls" "Install gnutls devel"
2251 else
2252 gnutls="no"
2253 gnutls_rnd="no"
2255 else
2256 gnutls_rnd="no"
2260 # If user didn't give a --disable/enable-gcrypt flag,
2261 # then mark as disabled if user requested nettle
2262 # explicitly, or if gnutls links to nettle
2263 if test -z "$gcrypt"
2264 then
2265 if test "$nettle" = "yes" || test "$gnutls_nettle" = "yes"
2266 then
2267 gcrypt="no"
2271 # If user didn't give a --disable/enable-nettle flag,
2272 # then mark as disabled if user requested gcrypt
2273 # explicitly, or if gnutls links to gcrypt
2274 if test -z "$nettle"
2275 then
2276 if test "$gcrypt" = "yes" || test "$gnutls_gcrypt" = "yes"
2277 then
2278 nettle="no"
2282 has_libgcrypt_config() {
2283 if ! has "libgcrypt-config"
2284 then
2285 return 1
2288 if test -n "$cross_prefix"
2289 then
2290 host=$(libgcrypt-config --host)
2291 if test "$host-" != $cross_prefix
2292 then
2293 return 1
2297 return 0
2300 if test "$gcrypt" != "no"; then
2301 if has_libgcrypt_config; then
2302 gcrypt_cflags=$(libgcrypt-config --cflags)
2303 gcrypt_libs=$(libgcrypt-config --libs)
2304 # Debian has remove -lgpg-error from libgcrypt-config
2305 # as it "spreads unnecessary dependencies" which in
2306 # turn breaks static builds...
2307 if test "$static" = "yes"
2308 then
2309 gcrypt_libs="$gcrypt_libs -lgpg-error"
2311 libs_softmmu="$gcrypt_libs $libs_softmmu"
2312 libs_tools="$gcrypt_libs $libs_tools"
2313 QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
2314 gcrypt="yes"
2315 if test -z "$nettle"; then
2316 nettle="no"
2319 cat > $TMPC << EOF
2320 #include <gcrypt.h>
2321 int main(void) {
2322 gcry_kdf_derive(NULL, 0, GCRY_KDF_PBKDF2,
2323 GCRY_MD_SHA256,
2324 NULL, 0, 0, 0, NULL);
2325 return 0;
2328 if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
2329 gcrypt_kdf=yes
2331 else
2332 if test "$gcrypt" = "yes"; then
2333 feature_not_found "gcrypt" "Install gcrypt devel"
2334 else
2335 gcrypt="no"
2341 if test "$nettle" != "no"; then
2342 if $pkg_config --exists "nettle"; then
2343 nettle_cflags=$($pkg_config --cflags nettle)
2344 nettle_libs=$($pkg_config --libs nettle)
2345 nettle_version=$($pkg_config --modversion nettle)
2346 libs_softmmu="$nettle_libs $libs_softmmu"
2347 libs_tools="$nettle_libs $libs_tools"
2348 QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
2349 nettle="yes"
2351 cat > $TMPC << EOF
2352 #include <stddef.h>
2353 #include <nettle/pbkdf2.h>
2354 int main(void) {
2355 pbkdf2_hmac_sha256(8, NULL, 1000, 8, NULL, 8, NULL);
2356 return 0;
2359 if compile_prog "$nettle_cflags" "$nettle_libs" ; then
2360 nettle_kdf=yes
2362 else
2363 if test "$nettle" = "yes"; then
2364 feature_not_found "nettle" "Install nettle devel"
2365 else
2366 nettle="no"
2371 if test "$gcrypt" = "yes" && test "$nettle" = "yes"
2372 then
2373 error_exit "Only one of gcrypt & nettle can be enabled"
2376 ##########################################
2377 # libtasn1 - only for the TLS creds/session test suite
2379 tasn1=yes
2380 tasn1_cflags=""
2381 tasn1_libs=""
2382 if $pkg_config --exists "libtasn1"; then
2383 tasn1_cflags=$($pkg_config --cflags libtasn1)
2384 tasn1_libs=$($pkg_config --libs libtasn1)
2385 else
2386 tasn1=no
2390 ##########################################
2391 # getifaddrs (for tests/test-io-channel-socket )
2393 have_ifaddrs_h=yes
2394 if ! check_include "ifaddrs.h" ; then
2395 have_ifaddrs_h=no
2398 ##########################################
2399 # VTE probe
2401 if test "$vte" != "no"; then
2402 if test "$gtkabi" = "3.0"; then
2403 vteminversion="0.32.0"
2404 if $pkg_config --exists "vte-2.91"; then
2405 vtepackage="vte-2.91"
2406 else
2407 vtepackage="vte-2.90"
2409 else
2410 vtepackage="vte"
2411 vteminversion="0.24.0"
2413 if $pkg_config --exists "$vtepackage >= $vteminversion"; then
2414 vte_cflags=$($pkg_config --cflags $vtepackage)
2415 vte_libs=$($pkg_config --libs $vtepackage)
2416 vteversion=$($pkg_config --modversion $vtepackage)
2417 libs_softmmu="$vte_libs $libs_softmmu"
2418 vte="yes"
2419 elif test "$vte" = "yes"; then
2420 if test "$gtkabi" = "3.0"; then
2421 feature_not_found "vte" "Install libvte-2.90/2.91 devel"
2422 else
2423 feature_not_found "vte" "Install libvte devel"
2425 else
2426 vte="no"
2430 ##########################################
2431 # SDL probe
2433 # Look for sdl configuration program (pkg-config or sdl-config). Try
2434 # sdl-config even without cross prefix, and favour pkg-config over sdl-config.
2436 if test "$sdlabi" = ""; then
2437 if $pkg_config --exists "sdl"; then
2438 sdlabi=1.2
2439 elif $pkg_config --exists "sdl2"; then
2440 sdlabi=2.0
2441 else
2442 sdlabi=1.2
2446 if test $sdlabi = "2.0"; then
2447 sdl_config=$sdl2_config
2448 sdlname=sdl2
2449 sdlconfigname=sdl2_config
2450 elif test $sdlabi = "1.2"; then
2451 sdlname=sdl
2452 sdlconfigname=sdl_config
2453 else
2454 error_exit "Unknown sdlabi $sdlabi, must be 1.2 or 2.0"
2457 if test "$(basename $sdl_config)" != $sdlconfigname && ! has ${sdl_config}; then
2458 sdl_config=$sdlconfigname
2461 if $pkg_config $sdlname --exists; then
2462 sdlconfig="$pkg_config $sdlname"
2463 sdlversion=$($sdlconfig --modversion 2>/dev/null)
2464 elif has ${sdl_config}; then
2465 sdlconfig="$sdl_config"
2466 sdlversion=$($sdlconfig --version)
2467 else
2468 if test "$sdl" = "yes" ; then
2469 feature_not_found "sdl" "Install SDL devel"
2471 sdl=no
2473 if test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
2474 echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
2477 sdl_too_old=no
2478 if test "$sdl" != "no" ; then
2479 cat > $TMPC << EOF
2480 #include <SDL.h>
2481 #undef main /* We don't want SDL to override our main() */
2482 int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
2484 sdl_cflags=$($sdlconfig --cflags 2>/dev/null)
2485 if test "$static" = "yes" ; then
2486 sdl_libs=$($sdlconfig --static-libs 2>/dev/null)
2487 else
2488 sdl_libs=$($sdlconfig --libs 2>/dev/null)
2490 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
2491 if test $(echo $sdlversion | sed 's/[^0-9]//g') -lt 121 ; then
2492 sdl_too_old=yes
2493 else
2494 sdl=yes
2497 # static link with sdl ? (note: sdl.pc's --static --libs is broken)
2498 if test "$sdl" = "yes" -a "$static" = "yes" ; then
2499 if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
2500 sdl_libs="$sdl_libs $(aalib-config --static-libs 2>/dev/null)"
2501 sdl_cflags="$sdl_cflags $(aalib-config --cflags 2>/dev/null)"
2503 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
2505 else
2506 sdl=no
2508 fi # static link
2509 else # sdl not found
2510 if test "$sdl" = "yes" ; then
2511 feature_not_found "sdl" "Install SDL devel"
2513 sdl=no
2514 fi # sdl compile test
2517 if test "$sdl" = "yes" ; then
2518 cat > $TMPC <<EOF
2519 #include <SDL.h>
2520 #if defined(SDL_VIDEO_DRIVER_X11)
2521 #include <X11/XKBlib.h>
2522 #else
2523 #error No x11 support
2524 #endif
2525 int main(void) { return 0; }
2527 if compile_prog "$sdl_cflags $x11_cflags" "$sdl_libs $x11_libs" ; then
2528 sdl_cflags="$sdl_cflags $x11_cflags"
2529 sdl_libs="$sdl_libs $x11_libs"
2531 libs_softmmu="$sdl_libs $libs_softmmu"
2534 ##########################################
2535 # RDMA needs OpenFabrics libraries
2536 if test "$rdma" != "no" ; then
2537 cat > $TMPC <<EOF
2538 #include <rdma/rdma_cma.h>
2539 int main(void) { return 0; }
2541 rdma_libs="-lrdmacm -libverbs"
2542 if compile_prog "" "$rdma_libs" ; then
2543 rdma="yes"
2544 libs_softmmu="$libs_softmmu $rdma_libs"
2545 else
2546 if test "$rdma" = "yes" ; then
2547 error_exit \
2548 " OpenFabrics librdmacm/libibverbs not present." \
2549 " Your options:" \
2550 " (1) Fast: Install infiniband packages from your distro." \
2551 " (2) Cleanest: Install libraries from www.openfabrics.org" \
2552 " (3) Also: Install softiwarp if you don't have RDMA hardware"
2554 rdma="no"
2559 ##########################################
2560 # VNC SASL detection
2561 if test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
2562 cat > $TMPC <<EOF
2563 #include <sasl/sasl.h>
2564 #include <stdio.h>
2565 int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
2567 # Assuming Cyrus-SASL installed in /usr prefix
2568 vnc_sasl_cflags=""
2569 vnc_sasl_libs="-lsasl2"
2570 if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
2571 vnc_sasl=yes
2572 libs_softmmu="$vnc_sasl_libs $libs_softmmu"
2573 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
2574 else
2575 if test "$vnc_sasl" = "yes" ; then
2576 feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
2578 vnc_sasl=no
2582 ##########################################
2583 # VNC JPEG detection
2584 if test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
2585 cat > $TMPC <<EOF
2586 #include <stdio.h>
2587 #include <jpeglib.h>
2588 int main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
2590 vnc_jpeg_cflags=""
2591 vnc_jpeg_libs="-ljpeg"
2592 if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
2593 vnc_jpeg=yes
2594 libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
2595 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
2596 else
2597 if test "$vnc_jpeg" = "yes" ; then
2598 feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
2600 vnc_jpeg=no
2604 ##########################################
2605 # VNC PNG detection
2606 if test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
2607 cat > $TMPC <<EOF
2608 //#include <stdio.h>
2609 #include <png.h>
2610 #include <stddef.h>
2611 int main(void) {
2612 png_structp png_ptr;
2613 png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
2614 return png_ptr != 0;
2617 if $pkg_config libpng --exists; then
2618 vnc_png_cflags=$($pkg_config libpng --cflags)
2619 vnc_png_libs=$($pkg_config libpng --libs)
2620 else
2621 vnc_png_cflags=""
2622 vnc_png_libs="-lpng"
2624 if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
2625 vnc_png=yes
2626 libs_softmmu="$vnc_png_libs $libs_softmmu"
2627 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
2628 else
2629 if test "$vnc_png" = "yes" ; then
2630 feature_not_found "vnc-png" "Install libpng devel"
2632 vnc_png=no
2636 ##########################################
2637 # fnmatch() probe, used for ACL routines
2638 fnmatch="no"
2639 cat > $TMPC << EOF
2640 #include <fnmatch.h>
2641 int main(void)
2643 fnmatch("foo", "foo", 0);
2644 return 0;
2647 if compile_prog "" "" ; then
2648 fnmatch="yes"
2651 ##########################################
2652 # uuid_generate() probe, used for vdi block driver
2653 # Note that on some systems (notably MacOSX) no extra library
2654 # need be linked to get the uuid functions.
2655 if test "$uuid" != "no" ; then
2656 uuid_libs="-luuid"
2657 cat > $TMPC << EOF
2658 #include <uuid/uuid.h>
2659 int main(void)
2661 uuid_t my_uuid;
2662 uuid_generate(my_uuid);
2663 return 0;
2666 if compile_prog "" "" ; then
2667 uuid="yes"
2668 elif compile_prog "" "$uuid_libs" ; then
2669 uuid="yes"
2670 libs_softmmu="$uuid_libs $libs_softmmu"
2671 libs_tools="$uuid_libs $libs_tools"
2672 else
2673 if test "$uuid" = "yes" ; then
2674 feature_not_found "uuid" "Install libuuid devel"
2676 uuid=no
2680 if test "$vhdx" = "yes" ; then
2681 if test "$uuid" = "no" ; then
2682 error_exit "uuid required for VHDX support"
2684 elif test "$vhdx" != "no" ; then
2685 if test "$uuid" = "yes" ; then
2686 vhdx=yes
2687 else
2688 vhdx=no
2692 ##########################################
2693 # xfsctl() probe, used for raw-posix
2694 if test "$xfs" != "no" ; then
2695 cat > $TMPC << EOF
2696 #include <stddef.h> /* NULL */
2697 #include <xfs/xfs.h>
2698 int main(void)
2700 xfsctl(NULL, 0, 0, NULL);
2701 return 0;
2704 if compile_prog "" "" ; then
2705 xfs="yes"
2706 else
2707 if test "$xfs" = "yes" ; then
2708 feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
2710 xfs=no
2714 ##########################################
2715 # vde libraries probe
2716 if test "$vde" != "no" ; then
2717 vde_libs="-lvdeplug"
2718 cat > $TMPC << EOF
2719 #include <libvdeplug.h>
2720 int main(void)
2722 struct vde_open_args a = {0, 0, 0};
2723 char s[] = "";
2724 vde_open(s, s, &a);
2725 return 0;
2728 if compile_prog "" "$vde_libs" ; then
2729 vde=yes
2730 libs_softmmu="$vde_libs $libs_softmmu"
2731 libs_tools="$vde_libs $libs_tools"
2732 else
2733 if test "$vde" = "yes" ; then
2734 feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
2736 vde=no
2740 ##########################################
2741 # netmap support probe
2742 # Apart from looking for netmap headers, we make sure that the host API version
2743 # supports the netmap backend (>=11). The upper bound (15) is meant to simulate
2744 # a minor/major version number. Minor new features will be marked with values up
2745 # to 15, and if something happens that requires a change to the backend we will
2746 # move above 15, submit the backend fixes and modify this two bounds.
2747 if test "$netmap" != "no" ; then
2748 cat > $TMPC << EOF
2749 #include <inttypes.h>
2750 #include <net/if.h>
2751 #include <net/netmap.h>
2752 #include <net/netmap_user.h>
2753 #if (NETMAP_API < 11) || (NETMAP_API > 15)
2754 #error
2755 #endif
2756 int main(void) { return 0; }
2758 if compile_prog "" "" ; then
2759 netmap=yes
2760 else
2761 if test "$netmap" = "yes" ; then
2762 feature_not_found "netmap"
2764 netmap=no
2768 ##########################################
2769 # libcap-ng library probe
2770 if test "$cap_ng" != "no" ; then
2771 cap_libs="-lcap-ng"
2772 cat > $TMPC << EOF
2773 #include <cap-ng.h>
2774 int main(void)
2776 capng_capability_to_name(CAPNG_EFFECTIVE);
2777 return 0;
2780 if compile_prog "" "$cap_libs" ; then
2781 cap_ng=yes
2782 libs_tools="$cap_libs $libs_tools"
2783 else
2784 if test "$cap_ng" = "yes" ; then
2785 feature_not_found "cap_ng" "Install libcap-ng devel"
2787 cap_ng=no
2791 ##########################################
2792 # Sound support libraries probe
2794 audio_drv_probe()
2796 drv=$1
2797 hdr=$2
2798 lib=$3
2799 exp=$4
2800 cfl=$5
2801 cat > $TMPC << EOF
2802 #include <$hdr>
2803 int main(void) { $exp }
2805 if compile_prog "$cfl" "$lib" ; then
2807 else
2808 error_exit "$drv check failed" \
2809 "Make sure to have the $drv libs and headers installed."
2813 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
2814 for drv in $audio_drv_list; do
2815 case $drv in
2816 alsa)
2817 audio_drv_probe $drv alsa/asoundlib.h -lasound \
2818 "return snd_pcm_close((snd_pcm_t *)0);"
2819 libs_softmmu="-lasound $libs_softmmu"
2823 audio_drv_probe $drv pulse/pulseaudio.h "-lpulse" \
2824 "pa_context_set_source_output_volume(NULL, 0, NULL, NULL, NULL); return 0;"
2825 libs_softmmu="-lpulse $libs_softmmu"
2826 audio_pt_int="yes"
2829 coreaudio)
2830 libs_softmmu="-framework CoreAudio $libs_softmmu"
2833 dsound)
2834 libs_softmmu="-lole32 -ldxguid $libs_softmmu"
2835 audio_win_int="yes"
2838 oss)
2839 libs_softmmu="$oss_lib $libs_softmmu"
2842 sdl|wav)
2843 # XXX: Probes for CoreAudio, DirectSound, SDL(?)
2847 echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
2848 error_exit "Unknown driver '$drv' selected" \
2849 "Possible drivers are: $audio_possible_drivers"
2852 esac
2853 done
2855 ##########################################
2856 # BrlAPI probe
2858 if test "$brlapi" != "no" ; then
2859 brlapi_libs="-lbrlapi"
2860 cat > $TMPC << EOF
2861 #include <brlapi.h>
2862 #include <stddef.h>
2863 int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
2865 if compile_prog "" "$brlapi_libs" ; then
2866 brlapi=yes
2867 libs_softmmu="$brlapi_libs $libs_softmmu"
2868 else
2869 if test "$brlapi" = "yes" ; then
2870 feature_not_found "brlapi" "Install brlapi devel"
2872 brlapi=no
2876 ##########################################
2877 # curses probe
2878 if test "$curses" != "no" ; then
2879 if test "$mingw32" = "yes" ; then
2880 curses_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
2881 else
2882 curses_list="$($pkg_config --libs ncurses 2>/dev/null):-lncurses:-lcurses"
2884 curses_found=no
2885 cat > $TMPC << EOF
2886 #include <curses.h>
2887 int main(void) {
2888 const char *s = curses_version();
2889 resize_term(0, 0);
2890 return s != 0;
2893 IFS=:
2894 for curses_lib in $curses_list; do
2895 unset IFS
2896 if compile_prog "" "$curses_lib" ; then
2897 curses_found=yes
2898 libs_softmmu="$curses_lib $libs_softmmu"
2899 break
2901 done
2902 unset IFS
2903 if test "$curses_found" = "yes" ; then
2904 curses=yes
2905 else
2906 if test "$curses" = "yes" ; then
2907 feature_not_found "curses" "Install ncurses devel"
2909 curses=no
2913 ##########################################
2914 # curl probe
2915 if test "$curl" != "no" ; then
2916 if $pkg_config libcurl --exists; then
2917 curlconfig="$pkg_config libcurl"
2918 else
2919 curlconfig=curl-config
2921 cat > $TMPC << EOF
2922 #include <curl/curl.h>
2923 int main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
2925 curl_cflags=$($curlconfig --cflags 2>/dev/null)
2926 curl_libs=$($curlconfig --libs 2>/dev/null)
2927 if compile_prog "$curl_cflags" "$curl_libs" ; then
2928 curl=yes
2929 else
2930 if test "$curl" = "yes" ; then
2931 feature_not_found "curl" "Install libcurl devel"
2933 curl=no
2935 fi # test "$curl"
2937 ##########################################
2938 # bluez support probe
2939 if test "$bluez" != "no" ; then
2940 cat > $TMPC << EOF
2941 #include <bluetooth/bluetooth.h>
2942 int main(void) { return bt_error(0); }
2944 bluez_cflags=$($pkg_config --cflags bluez 2>/dev/null)
2945 bluez_libs=$($pkg_config --libs bluez 2>/dev/null)
2946 if compile_prog "$bluez_cflags" "$bluez_libs" ; then
2947 bluez=yes
2948 libs_softmmu="$bluez_libs $libs_softmmu"
2949 else
2950 if test "$bluez" = "yes" ; then
2951 feature_not_found "bluez" "Install bluez-libs/libbluetooth devel"
2953 bluez="no"
2957 ##########################################
2958 # glib support probe
2960 glib_req_ver=2.22
2961 glib_modules=gthread-2.0
2962 if test "$modules" = yes; then
2963 glib_modules="$glib_modules gmodule-2.0"
2966 for i in $glib_modules; do
2967 if $pkg_config --atleast-version=$glib_req_ver $i; then
2968 glib_cflags=$($pkg_config --cflags $i)
2969 glib_libs=$($pkg_config --libs $i)
2970 CFLAGS="$glib_cflags $CFLAGS"
2971 LIBS="$glib_libs $LIBS"
2972 libs_qga="$glib_libs $libs_qga"
2973 else
2974 error_exit "glib-$glib_req_ver $i is required to compile QEMU"
2976 done
2978 # Sanity check that the current size_t matches the
2979 # size that glib thinks it should be. This catches
2980 # problems on multi-arch where people try to build
2981 # 32-bit QEMU while pointing at 64-bit glib headers
2982 cat > $TMPC <<EOF
2983 #include <glib.h>
2984 #include <unistd.h>
2986 #define QEMU_BUILD_BUG_ON(x) \
2987 typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
2989 int main(void) {
2990 QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
2991 return 0;
2995 if ! compile_prog "$CFLAGS" "$LIBS" ; then
2996 error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
2997 "You probably need to set PKG_CONFIG_LIBDIR"\
2998 "to point to the right pkg-config files for your"\
2999 "build target"
3002 # g_test_trap_subprocess added in 2.38. Used by some tests.
3003 glib_subprocess=yes
3004 if ! $pkg_config --atleast-version=2.38 glib-2.0; then
3005 glib_subprocess=no
3008 # Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
3009 cat > $TMPC << EOF
3010 #include <glib.h>
3011 int main(void) { return 0; }
3013 if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3014 if cc_has_warning_flag "-Wno-unknown-attributes"; then
3015 glib_cflags="-Wno-unknown-attributes $glib_cflags"
3016 CFLAGS="-Wno-unknown-attributes $CFLAGS"
3020 ##########################################
3021 # SHA command probe for modules
3022 if test "$modules" = yes; then
3023 shacmd_probe="sha1sum sha1 shasum"
3024 for c in $shacmd_probe; do
3025 if has $c; then
3026 shacmd="$c"
3027 break
3029 done
3030 if test "$shacmd" = ""; then
3031 error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3035 ##########################################
3036 # pixman support probe
3038 if test "$pixman" = ""; then
3039 if test "$want_tools" = "no" -a "$softmmu" = "no"; then
3040 pixman="none"
3041 elif $pkg_config --atleast-version=0.21.8 pixman-1 > /dev/null 2>&1; then
3042 pixman="system"
3043 else
3044 pixman="internal"
3047 if test "$pixman" = "none"; then
3048 if test "$want_tools" != "no" -o "$softmmu" != "no"; then
3049 error_exit "pixman disabled but system emulation or tools build" \
3050 "enabled. You can turn off pixman only if you also" \
3051 "disable all system emulation targets and the tools" \
3052 "build with '--disable-tools --disable-system'."
3054 pixman_cflags=
3055 pixman_libs=
3056 elif test "$pixman" = "system"; then
3057 # pixman version has been checked above
3058 pixman_cflags=$($pkg_config --cflags pixman-1)
3059 pixman_libs=$($pkg_config --libs pixman-1)
3060 else
3061 if test ! -d ${source_path}/pixman/pixman; then
3062 error_exit "pixman >= 0.21.8 not present. Your options:" \
3063 " (1) Preferred: Install the pixman devel package (any recent" \
3064 " distro should have packages as Xorg needs pixman too)." \
3065 " (2) Fetch the pixman submodule, using:" \
3066 " git submodule update --init pixman"
3068 mkdir -p pixman/pixman
3069 pixman_cflags="-I\$(SRC_PATH)/pixman/pixman -I\$(BUILD_DIR)/pixman/pixman"
3070 pixman_libs="-L\$(BUILD_DIR)/pixman/pixman/.libs -lpixman-1"
3073 ##########################################
3074 # libcap probe
3076 if test "$cap" != "no" ; then
3077 cat > $TMPC <<EOF
3078 #include <stdio.h>
3079 #include <sys/capability.h>
3080 int main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
3082 if compile_prog "" "-lcap" ; then
3083 cap=yes
3084 else
3085 cap=no
3089 ##########################################
3090 # pthread probe
3091 PTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
3093 pthread=no
3094 cat > $TMPC << EOF
3095 #include <pthread.h>
3096 static void *f(void *p) { return NULL; }
3097 int main(void) {
3098 pthread_t thread;
3099 pthread_create(&thread, 0, f, 0);
3100 return 0;
3103 if compile_prog "" "" ; then
3104 pthread=yes
3105 else
3106 for pthread_lib in $PTHREADLIBS_LIST; do
3107 if compile_prog "" "$pthread_lib" ; then
3108 pthread=yes
3109 found=no
3110 for lib_entry in $LIBS; do
3111 if test "$lib_entry" = "$pthread_lib"; then
3112 found=yes
3113 break
3115 done
3116 if test "$found" = "no"; then
3117 LIBS="$pthread_lib $LIBS"
3119 break
3121 done
3124 if test "$mingw32" != yes -a "$pthread" = no; then
3125 error_exit "pthread check failed" \
3126 "Make sure to have the pthread libs and headers installed."
3129 # check for pthread_setname_np
3130 pthread_setname_np=no
3131 cat > $TMPC << EOF
3132 #include <pthread.h>
3134 static void *f(void *p) { return NULL; }
3135 int main(void)
3137 pthread_t thread;
3138 pthread_create(&thread, 0, f, 0);
3139 pthread_setname_np(thread, "QEMU");
3140 return 0;
3143 if compile_prog "" "$pthread_lib" ; then
3144 pthread_setname_np=yes
3147 ##########################################
3148 # rbd probe
3149 if test "$rbd" != "no" ; then
3150 cat > $TMPC <<EOF
3151 #include <stdio.h>
3152 #include <rbd/librbd.h>
3153 int main(void) {
3154 rados_t cluster;
3155 rados_create(&cluster, NULL);
3156 return 0;
3159 rbd_libs="-lrbd -lrados"
3160 if compile_prog "" "$rbd_libs" ; then
3161 rbd=yes
3162 else
3163 if test "$rbd" = "yes" ; then
3164 feature_not_found "rados block device" "Install librbd/ceph devel"
3166 rbd=no
3170 ##########################################
3171 # libssh2 probe
3172 min_libssh2_version=1.2.8
3173 if test "$libssh2" != "no" ; then
3174 if $pkg_config --atleast-version=$min_libssh2_version libssh2; then
3175 libssh2_cflags=$($pkg_config libssh2 --cflags)
3176 libssh2_libs=$($pkg_config libssh2 --libs)
3177 libssh2=yes
3178 else
3179 if test "$libssh2" = "yes" ; then
3180 error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2"
3182 libssh2=no
3186 ##########################################
3187 # libssh2_sftp_fsync probe
3189 if test "$libssh2" = "yes"; then
3190 cat > $TMPC <<EOF
3191 #include <stdio.h>
3192 #include <libssh2.h>
3193 #include <libssh2_sftp.h>
3194 int main(void) {
3195 LIBSSH2_SESSION *session;
3196 LIBSSH2_SFTP *sftp;
3197 LIBSSH2_SFTP_HANDLE *sftp_handle;
3198 session = libssh2_session_init ();
3199 sftp = libssh2_sftp_init (session);
3200 sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0);
3201 libssh2_sftp_fsync (sftp_handle);
3202 return 0;
3205 # libssh2_cflags/libssh2_libs defined in previous test.
3206 if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then
3207 QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS"
3211 ##########################################
3212 # linux-aio probe
3214 if test "$linux_aio" != "no" ; then
3215 cat > $TMPC <<EOF
3216 #include <libaio.h>
3217 #include <sys/eventfd.h>
3218 #include <stddef.h>
3219 int main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
3221 if compile_prog "" "-laio" ; then
3222 linux_aio=yes
3223 else
3224 if test "$linux_aio" = "yes" ; then
3225 feature_not_found "linux AIO" "Install libaio devel"
3227 linux_aio=no
3231 ##########################################
3232 # TPM passthrough is only on x86 Linux
3234 if test "$targetos" = Linux && test "$cpu" = i386 -o "$cpu" = x86_64; then
3235 tpm_passthrough=$tpm
3236 else
3237 tpm_passthrough=no
3240 ##########################################
3241 # attr probe
3243 if test "$attr" != "no" ; then
3244 cat > $TMPC <<EOF
3245 #include <stdio.h>
3246 #include <sys/types.h>
3247 #ifdef CONFIG_LIBATTR
3248 #include <attr/xattr.h>
3249 #else
3250 #include <sys/xattr.h>
3251 #endif
3252 int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
3254 if compile_prog "" "" ; then
3255 attr=yes
3256 # Older distros have <attr/xattr.h>, and need -lattr:
3257 elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
3258 attr=yes
3259 LIBS="-lattr $LIBS"
3260 libattr=yes
3261 else
3262 if test "$attr" = "yes" ; then
3263 feature_not_found "ATTR" "Install libc6 or libattr devel"
3265 attr=no
3269 ##########################################
3270 # iovec probe
3271 cat > $TMPC <<EOF
3272 #include <sys/types.h>
3273 #include <sys/uio.h>
3274 #include <unistd.h>
3275 int main(void) { return sizeof(struct iovec); }
3277 iovec=no
3278 if compile_prog "" "" ; then
3279 iovec=yes
3282 ##########################################
3283 # preadv probe
3284 cat > $TMPC <<EOF
3285 #include <sys/types.h>
3286 #include <sys/uio.h>
3287 #include <unistd.h>
3288 int main(void) { return preadv(0, 0, 0, 0); }
3290 preadv=no
3291 if compile_prog "" "" ; then
3292 preadv=yes
3295 ##########################################
3296 # fdt probe
3297 # fdt support is mandatory for at least some target architectures,
3298 # so insist on it if we're building those system emulators.
3299 fdt_required=no
3300 for target in $target_list; do
3301 case $target in
3302 aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu)
3303 fdt_required=yes
3305 esac
3306 done
3308 if test "$fdt_required" = "yes"; then
3309 if test "$fdt" = "no"; then
3310 error_exit "fdt disabled but some requested targets require it." \
3311 "You can turn off fdt only if you also disable all the system emulation" \
3312 "targets which need it (by specifying a cut down --target-list)."
3314 fdt=yes
3317 if test "$fdt" != "no" ; then
3318 fdt_libs="-lfdt"
3319 # explicitly check for libfdt_env.h as it is missing in some stable installs
3320 # and test for required functions to make sure we are on a version >= 1.4.0
3321 cat > $TMPC << EOF
3322 #include <libfdt.h>
3323 #include <libfdt_env.h>
3324 int main(void) { fdt_get_property_by_offset(0, 0, 0); return 0; }
3326 if compile_prog "" "$fdt_libs" ; then
3327 # system DTC is good - use it
3328 fdt=yes
3329 elif test -d ${source_path}/dtc/libfdt ; then
3330 # have submodule DTC - use it
3331 fdt=yes
3332 dtc_internal="yes"
3333 mkdir -p dtc
3334 if [ "$pwd_is_source_path" != "y" ] ; then
3335 symlink "$source_path/dtc/Makefile" "dtc/Makefile"
3336 symlink "$source_path/dtc/scripts" "dtc/scripts"
3338 fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
3339 fdt_libs="-L\$(BUILD_DIR)/dtc/libfdt $fdt_libs"
3340 elif test "$fdt" = "yes" ; then
3341 # have neither and want - prompt for system/submodule install
3342 error_exit "DTC (libfdt) version >= 1.4.0 not present. Your options:" \
3343 " (1) Preferred: Install the DTC (libfdt) devel package" \
3344 " (2) Fetch the DTC submodule, using:" \
3345 " git submodule update --init dtc"
3346 else
3347 # don't have and don't want
3348 fdt_libs=
3349 fdt=no
3353 libs_softmmu="$libs_softmmu $fdt_libs"
3355 ##########################################
3356 # opengl probe (for sdl2, gtk, milkymist-tmu2)
3358 if test "$opengl" != "no" ; then
3359 opengl_pkgs="epoxy libdrm gbm"
3360 if $pkg_config $opengl_pkgs x11; then
3361 opengl_cflags="$($pkg_config --cflags $opengl_pkgs) $x11_cflags"
3362 opengl_libs="$($pkg_config --libs $opengl_pkgs) $x11_libs"
3363 opengl=yes
3364 if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
3365 gtk_gl="yes"
3367 else
3368 if test "$opengl" = "yes" ; then
3369 feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
3371 opengl_cflags=""
3372 opengl_libs=""
3373 opengl=no
3377 if test "$opengl" = "yes"; then
3378 cat > $TMPC << EOF
3379 #include <epoxy/egl.h>
3380 #ifndef EGL_MESA_image_dma_buf_export
3381 # error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
3382 #endif
3383 int main(void) { return 0; }
3385 if compile_prog "" "" ; then
3386 opengl_dmabuf=yes
3390 ##########################################
3391 # archipelago probe
3392 if test "$archipelago" != "no" ; then
3393 cat > $TMPC <<EOF
3394 #include <stdio.h>
3395 #include <xseg/xseg.h>
3396 #include <xseg/protocol.h>
3397 int main(void) {
3398 xseg_initialize();
3399 return 0;
3402 archipelago_libs=-lxseg
3403 if compile_prog "" "$archipelago_libs"; then
3404 archipelago="yes"
3405 libs_tools="$archipelago_libs $libs_tools"
3406 libs_softmmu="$archipelago_libs $libs_softmmu"
3408 echo "WARNING: Please check the licenses of QEMU and libxseg carefully."
3409 echo "GPLv3 versions of libxseg may not be compatible with QEMU's"
3410 echo "license and therefore prevent redistribution."
3411 echo
3412 echo "To disable Archipelago, use --disable-archipelago"
3413 else
3414 if test "$archipelago" = "yes" ; then
3415 feature_not_found "Archipelago backend support" "Install libxseg devel"
3417 archipelago="no"
3422 ##########################################
3423 # glusterfs probe
3424 if test "$glusterfs" != "no" ; then
3425 if $pkg_config --atleast-version=3 glusterfs-api; then
3426 glusterfs="yes"
3427 glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
3428 glusterfs_libs=$($pkg_config --libs glusterfs-api)
3429 if $pkg_config --atleast-version=4 glusterfs-api; then
3430 glusterfs_xlator_opt="yes"
3432 if $pkg_config --atleast-version=5 glusterfs-api; then
3433 glusterfs_discard="yes"
3435 if $pkg_config --atleast-version=6 glusterfs-api; then
3436 glusterfs_zerofill="yes"
3438 else
3439 if test "$glusterfs" = "yes" ; then
3440 feature_not_found "GlusterFS backend support" \
3441 "Install glusterfs-api devel >= 3"
3443 glusterfs="no"
3447 # Check for inotify functions when we are building linux-user
3448 # emulator. This is done because older glibc versions don't
3449 # have syscall stubs for these implemented. In that case we
3450 # don't provide them even if kernel supports them.
3452 inotify=no
3453 cat > $TMPC << EOF
3454 #include <sys/inotify.h>
3457 main(void)
3459 /* try to start inotify */
3460 return inotify_init();
3463 if compile_prog "" "" ; then
3464 inotify=yes
3467 inotify1=no
3468 cat > $TMPC << EOF
3469 #include <sys/inotify.h>
3472 main(void)
3474 /* try to start inotify */
3475 return inotify_init1(0);
3478 if compile_prog "" "" ; then
3479 inotify1=yes
3482 # check if utimensat and futimens are supported
3483 utimens=no
3484 cat > $TMPC << EOF
3485 #define _ATFILE_SOURCE
3486 #include <stddef.h>
3487 #include <fcntl.h>
3488 #include <sys/stat.h>
3490 int main(void)
3492 utimensat(AT_FDCWD, "foo", NULL, 0);
3493 futimens(0, NULL);
3494 return 0;
3497 if compile_prog "" "" ; then
3498 utimens=yes
3501 # check if pipe2 is there
3502 pipe2=no
3503 cat > $TMPC << EOF
3504 #include <unistd.h>
3505 #include <fcntl.h>
3507 int main(void)
3509 int pipefd[2];
3510 return pipe2(pipefd, O_CLOEXEC);
3513 if compile_prog "" "" ; then
3514 pipe2=yes
3517 # check if accept4 is there
3518 accept4=no
3519 cat > $TMPC << EOF
3520 #include <sys/socket.h>
3521 #include <stddef.h>
3523 int main(void)
3525 accept4(0, NULL, NULL, SOCK_CLOEXEC);
3526 return 0;
3529 if compile_prog "" "" ; then
3530 accept4=yes
3533 # check if tee/splice is there. vmsplice was added same time.
3534 splice=no
3535 cat > $TMPC << EOF
3536 #include <unistd.h>
3537 #include <fcntl.h>
3538 #include <limits.h>
3540 int main(void)
3542 int len, fd = 0;
3543 len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
3544 splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
3545 return 0;
3548 if compile_prog "" "" ; then
3549 splice=yes
3552 ##########################################
3553 # libnuma probe
3555 if test "$numa" != "no" ; then
3556 cat > $TMPC << EOF
3557 #include <numa.h>
3558 int main(void) { return numa_available(); }
3561 if compile_prog "" "-lnuma" ; then
3562 numa=yes
3563 libs_softmmu="-lnuma $libs_softmmu"
3564 else
3565 if test "$numa" = "yes" ; then
3566 feature_not_found "numa" "install numactl devel"
3568 numa=no
3572 if test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
3573 echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
3574 exit 1
3577 ##########################################
3578 # tcmalloc probe
3580 if test "$tcmalloc" = "yes" ; then
3581 cat > $TMPC << EOF
3582 #include <stdlib.h>
3583 int main(void) { malloc(1); return 0; }
3586 if compile_prog "" "-ltcmalloc" ; then
3587 LIBS="-ltcmalloc $LIBS"
3588 else
3589 feature_not_found "tcmalloc" "install gperftools devel"
3593 ##########################################
3594 # jemalloc probe
3596 if test "$jemalloc" = "yes" ; then
3597 cat > $TMPC << EOF
3598 #include <stdlib.h>
3599 int main(void) { malloc(1); return 0; }
3602 if compile_prog "" "-ljemalloc" ; then
3603 LIBS="-ljemalloc $LIBS"
3604 else
3605 feature_not_found "jemalloc" "install jemalloc devel"
3609 ##########################################
3610 # signalfd probe
3611 signalfd="no"
3612 cat > $TMPC << EOF
3613 #include <unistd.h>
3614 #include <sys/syscall.h>
3615 #include <signal.h>
3616 int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
3619 if compile_prog "" "" ; then
3620 signalfd=yes
3623 # check if eventfd is supported
3624 eventfd=no
3625 cat > $TMPC << EOF
3626 #include <sys/eventfd.h>
3628 int main(void)
3630 return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
3633 if compile_prog "" "" ; then
3634 eventfd=yes
3637 # check if memfd is supported
3638 memfd=no
3639 cat > $TMPC << EOF
3640 #include <sys/memfd.h>
3642 int main(void)
3644 return memfd_create("foo", MFD_ALLOW_SEALING);
3647 if compile_prog "" "" ; then
3648 memfd=yes
3653 # check for fallocate
3654 fallocate=no
3655 cat > $TMPC << EOF
3656 #include <fcntl.h>
3658 int main(void)
3660 fallocate(0, 0, 0, 0);
3661 return 0;
3664 if compile_prog "" "" ; then
3665 fallocate=yes
3668 # check for fallocate hole punching
3669 fallocate_punch_hole=no
3670 cat > $TMPC << EOF
3671 #include <fcntl.h>
3672 #include <linux/falloc.h>
3674 int main(void)
3676 fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
3677 return 0;
3680 if compile_prog "" "" ; then
3681 fallocate_punch_hole=yes
3684 # check that fallocate supports range zeroing inside the file
3685 fallocate_zero_range=no
3686 cat > $TMPC << EOF
3687 #include <fcntl.h>
3688 #include <linux/falloc.h>
3690 int main(void)
3692 fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
3693 return 0;
3696 if compile_prog "" "" ; then
3697 fallocate_zero_range=yes
3700 # check for posix_fallocate
3701 posix_fallocate=no
3702 cat > $TMPC << EOF
3703 #include <fcntl.h>
3705 int main(void)
3707 posix_fallocate(0, 0, 0);
3708 return 0;
3711 if compile_prog "" "" ; then
3712 posix_fallocate=yes
3715 # check for sync_file_range
3716 sync_file_range=no
3717 cat > $TMPC << EOF
3718 #include <fcntl.h>
3720 int main(void)
3722 sync_file_range(0, 0, 0, 0);
3723 return 0;
3726 if compile_prog "" "" ; then
3727 sync_file_range=yes
3730 # check for linux/fiemap.h and FS_IOC_FIEMAP
3731 fiemap=no
3732 cat > $TMPC << EOF
3733 #include <sys/ioctl.h>
3734 #include <linux/fs.h>
3735 #include <linux/fiemap.h>
3737 int main(void)
3739 ioctl(0, FS_IOC_FIEMAP, 0);
3740 return 0;
3743 if compile_prog "" "" ; then
3744 fiemap=yes
3747 # check for dup3
3748 dup3=no
3749 cat > $TMPC << EOF
3750 #include <unistd.h>
3752 int main(void)
3754 dup3(0, 0, 0);
3755 return 0;
3758 if compile_prog "" "" ; then
3759 dup3=yes
3762 # check for ppoll support
3763 ppoll=no
3764 cat > $TMPC << EOF
3765 #include <poll.h>
3767 int main(void)
3769 struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
3770 ppoll(&pfd, 1, 0, 0);
3771 return 0;
3774 if compile_prog "" "" ; then
3775 ppoll=yes
3778 # check for prctl(PR_SET_TIMERSLACK , ... ) support
3779 prctl_pr_set_timerslack=no
3780 cat > $TMPC << EOF
3781 #include <sys/prctl.h>
3783 int main(void)
3785 prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
3786 return 0;
3789 if compile_prog "" "" ; then
3790 prctl_pr_set_timerslack=yes
3793 # check for epoll support
3794 epoll=no
3795 cat > $TMPC << EOF
3796 #include <sys/epoll.h>
3798 int main(void)
3800 epoll_create(0);
3801 return 0;
3804 if compile_prog "" "" ; then
3805 epoll=yes
3808 # epoll_create1 is a later addition
3809 # so we must check separately for its presence
3810 epoll_create1=no
3811 cat > $TMPC << EOF
3812 #include <sys/epoll.h>
3814 int main(void)
3816 /* Note that we use epoll_create1 as a value, not as
3817 * a function being called. This is necessary so that on
3818 * old SPARC glibc versions where the function was present in
3819 * the library but not declared in the header file we will
3820 * fail the configure check. (Otherwise we will get a compiler
3821 * warning but not an error, and will proceed to fail the
3822 * qemu compile where we compile with -Werror.)
3824 return (int)(uintptr_t)&epoll_create1;
3827 if compile_prog "" "" ; then
3828 epoll_create1=yes
3831 # check for sendfile support
3832 sendfile=no
3833 cat > $TMPC << EOF
3834 #include <sys/sendfile.h>
3836 int main(void)
3838 return sendfile(0, 0, 0, 0);
3841 if compile_prog "" "" ; then
3842 sendfile=yes
3845 # check for timerfd support (glibc 2.8 and newer)
3846 timerfd=no
3847 cat > $TMPC << EOF
3848 #include <sys/timerfd.h>
3850 int main(void)
3852 return(timerfd_create(CLOCK_REALTIME, 0));
3855 if compile_prog "" "" ; then
3856 timerfd=yes
3859 # check for setns and unshare support
3860 setns=no
3861 cat > $TMPC << EOF
3862 #include <sched.h>
3864 int main(void)
3866 int ret;
3867 ret = setns(0, 0);
3868 ret = unshare(0);
3869 return ret;
3872 if compile_prog "" "" ; then
3873 setns=yes
3876 # Check if tools are available to build documentation.
3877 if test "$docs" != "no" ; then
3878 if has makeinfo && has pod2man; then
3879 docs=yes
3880 else
3881 if test "$docs" = "yes" ; then
3882 feature_not_found "docs" "Install texinfo and Perl/perl-podlators"
3884 docs=no
3888 # Search for bswap_32 function
3889 byteswap_h=no
3890 cat > $TMPC << EOF
3891 #include <byteswap.h>
3892 int main(void) { return bswap_32(0); }
3894 if compile_prog "" "" ; then
3895 byteswap_h=yes
3898 # Search for bswap32 function
3899 bswap_h=no
3900 cat > $TMPC << EOF
3901 #include <sys/endian.h>
3902 #include <sys/types.h>
3903 #include <machine/bswap.h>
3904 int main(void) { return bswap32(0); }
3906 if compile_prog "" "" ; then
3907 bswap_h=yes
3910 ##########################################
3911 # Do we have libiscsi >= 1.9.0
3912 if test "$libiscsi" != "no" ; then
3913 if $pkg_config --atleast-version=1.9.0 libiscsi; then
3914 libiscsi="yes"
3915 libiscsi_cflags=$($pkg_config --cflags libiscsi)
3916 libiscsi_libs=$($pkg_config --libs libiscsi)
3917 else
3918 if test "$libiscsi" = "yes" ; then
3919 feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
3921 libiscsi="no"
3925 ##########################################
3926 # Do we need libm
3927 cat > $TMPC << EOF
3928 #include <math.h>
3929 int main(int argc, char **argv) { return isnan(sin((double)argc)); }
3931 if compile_prog "" "" ; then
3933 elif compile_prog "" "-lm" ; then
3934 LIBS="-lm $LIBS"
3935 libs_qga="-lm $libs_qga"
3936 else
3937 error_exit "libm check failed"
3940 ##########################################
3941 # Do we need librt
3942 # uClibc provides 2 versions of clock_gettime(), one with realtime
3943 # support and one without. This means that the clock_gettime() don't
3944 # need -lrt. We still need it for timer_create() so we check for this
3945 # function in addition.
3946 cat > $TMPC <<EOF
3947 #include <signal.h>
3948 #include <time.h>
3949 int main(void) {
3950 timer_create(CLOCK_REALTIME, NULL, NULL);
3951 return clock_gettime(CLOCK_REALTIME, NULL);
3955 if compile_prog "" "" ; then
3957 # we need pthread for static linking. use previous pthread test result
3958 elif compile_prog "" "$pthread_lib -lrt" ; then
3959 LIBS="$LIBS -lrt"
3960 libs_qga="$libs_qga -lrt"
3963 if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
3964 "$aix" != "yes" -a "$haiku" != "yes" ; then
3965 libs_softmmu="-lutil $libs_softmmu"
3968 ##########################################
3969 # spice probe
3970 if test "$spice" != "no" ; then
3971 cat > $TMPC << EOF
3972 #include <spice.h>
3973 int main(void) { spice_server_new(); return 0; }
3975 spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
3976 spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
3977 if $pkg_config --atleast-version=0.12.0 spice-server && \
3978 $pkg_config --atleast-version=0.12.3 spice-protocol && \
3979 compile_prog "$spice_cflags" "$spice_libs" ; then
3980 spice="yes"
3981 libs_softmmu="$libs_softmmu $spice_libs"
3982 QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
3983 spice_protocol_version=$($pkg_config --modversion spice-protocol)
3984 spice_server_version=$($pkg_config --modversion spice-server)
3985 else
3986 if test "$spice" = "yes" ; then
3987 feature_not_found "spice" \
3988 "Install spice-server(>=0.12.0) and spice-protocol(>=0.12.3) devel"
3990 spice="no"
3994 # check for smartcard support
3995 smartcard_cflags=""
3996 if test "$smartcard" != "no"; then
3997 if $pkg_config libcacard; then
3998 libcacard_cflags=$($pkg_config --cflags libcacard)
3999 libcacard_libs=$($pkg_config --libs libcacard)
4000 QEMU_CFLAGS="$QEMU_CFLAGS $libcacard_cflags"
4001 libs_softmmu="$libs_softmmu $libcacard_libs"
4002 smartcard="yes"
4003 else
4004 if test "$smartcard" = "yes"; then
4005 feature_not_found "smartcard" "Install libcacard devel"
4007 smartcard="no"
4011 # check for libusb
4012 if test "$libusb" != "no" ; then
4013 if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
4014 libusb="yes"
4015 libusb_cflags=$($pkg_config --cflags libusb-1.0)
4016 libusb_libs=$($pkg_config --libs libusb-1.0)
4017 QEMU_CFLAGS="$QEMU_CFLAGS $libusb_cflags"
4018 libs_softmmu="$libs_softmmu $libusb_libs"
4019 else
4020 if test "$libusb" = "yes"; then
4021 feature_not_found "libusb" "Install libusb devel >= 1.0.13"
4023 libusb="no"
4027 # check for usbredirparser for usb network redirection support
4028 if test "$usb_redir" != "no" ; then
4029 if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
4030 usb_redir="yes"
4031 usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
4032 usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
4033 QEMU_CFLAGS="$QEMU_CFLAGS $usb_redir_cflags"
4034 libs_softmmu="$libs_softmmu $usb_redir_libs"
4035 else
4036 if test "$usb_redir" = "yes"; then
4037 feature_not_found "usb-redir" "Install usbredir devel"
4039 usb_redir="no"
4043 ##########################################
4044 # check if we have VSS SDK headers for win
4046 if test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$vss_win32_sdk" != "no" ; then
4047 case "$vss_win32_sdk" in
4048 "") vss_win32_include="-I$source_path" ;;
4049 *\ *) # The SDK is installed in "Program Files" by default, but we cannot
4050 # handle path with spaces. So we symlink the headers into ".sdk/vss".
4051 vss_win32_include="-I$source_path/.sdk/vss"
4052 symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
4054 *) vss_win32_include="-I$vss_win32_sdk"
4055 esac
4056 cat > $TMPC << EOF
4057 #define __MIDL_user_allocate_free_DEFINED__
4058 #include <inc/win2003/vss.h>
4059 int main(void) { return VSS_CTX_BACKUP; }
4061 if compile_prog "$vss_win32_include" "" ; then
4062 guest_agent_with_vss="yes"
4063 QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
4064 libs_qga="-lole32 -loleaut32 -lshlwapi -luuid -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
4065 qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
4066 else
4067 if test "$vss_win32_sdk" != "" ; then
4068 echo "ERROR: Please download and install Microsoft VSS SDK:"
4069 echo "ERROR: http://www.microsoft.com/en-us/download/details.aspx?id=23490"
4070 echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
4071 echo "ERROR: scripts/extract-vsssdk-headers setup.exe"
4072 echo "ERROR: The headers are extracted in the directory \`inc'."
4073 feature_not_found "VSS support"
4075 guest_agent_with_vss="no"
4079 ##########################################
4080 # lookup Windows platform SDK (if not specified)
4081 # The SDK is needed only to build .tlb (type library) file of guest agent
4082 # VSS provider from the source. It is usually unnecessary because the
4083 # pre-compiled .tlb file is included.
4085 if test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$guest_agent_with_vss" = "yes" ; then
4086 if test -z "$win_sdk"; then
4087 programfiles="$PROGRAMFILES"
4088 test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
4089 if test -n "$programfiles"; then
4090 win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
4091 else
4092 feature_not_found "Windows SDK"
4094 elif test "$win_sdk" = "no"; then
4095 win_sdk=""
4099 ##########################################
4100 # check if mingw environment provides a recent ntddscsi.h
4101 if test "$mingw32" = "yes" -a "$guest_agent" != "no"; then
4102 cat > $TMPC << EOF
4103 #include <windows.h>
4104 #include <ntddscsi.h>
4105 int main(void) {
4106 #if !defined(IOCTL_SCSI_GET_ADDRESS)
4107 #error Missing required ioctl definitions
4108 #endif
4109 SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
4110 return addr.Lun;
4113 if compile_prog "" "" ; then
4114 guest_agent_ntddscsi=yes
4115 libs_qga="-lsetupapi $libs_qga"
4119 ##########################################
4120 # virgl renderer probe
4122 if test "$virglrenderer" != "no" ; then
4123 cat > $TMPC << EOF
4124 #include <virglrenderer.h>
4125 int main(void) { virgl_renderer_poll(); return 0; }
4127 virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
4128 virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
4129 if $pkg_config virglrenderer >/dev/null 2>&1 && \
4130 compile_prog "$virgl_cflags" "$virgl_libs" ; then
4131 virglrenderer="yes"
4132 else
4133 if test "$virglrenderer" = "yes" ; then
4134 feature_not_found "virglrenderer"
4136 virglrenderer="no"
4140 ##########################################
4141 # check if we have fdatasync
4143 fdatasync=no
4144 cat > $TMPC << EOF
4145 #include <unistd.h>
4146 int main(void) {
4147 #if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
4148 return fdatasync(0);
4149 #else
4150 #error Not supported
4151 #endif
4154 if compile_prog "" "" ; then
4155 fdatasync=yes
4158 ##########################################
4159 # check if we have madvise
4161 madvise=no
4162 cat > $TMPC << EOF
4163 #include <sys/types.h>
4164 #include <sys/mman.h>
4165 #include <stddef.h>
4166 int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
4168 if compile_prog "" "" ; then
4169 madvise=yes
4172 ##########################################
4173 # check if we have posix_madvise
4175 posix_madvise=no
4176 cat > $TMPC << EOF
4177 #include <sys/mman.h>
4178 #include <stddef.h>
4179 int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
4181 if compile_prog "" "" ; then
4182 posix_madvise=yes
4185 ##########################################
4186 # check if trace backend exists
4188 $python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends > /dev/null 2> /dev/null
4189 if test "$?" -ne 0 ; then
4190 error_exit "invalid trace backends" \
4191 "Please choose supported trace backends."
4194 ##########################################
4195 # For 'ust' backend, test if ust headers are present
4196 if have_backend "ust"; then
4197 cat > $TMPC << EOF
4198 #include <lttng/tracepoint.h>
4199 int main(void) { return 0; }
4201 if compile_prog "" "" ; then
4202 if $pkg_config lttng-ust --exists; then
4203 lttng_ust_libs=$($pkg_config --libs lttng-ust)
4204 else
4205 lttng_ust_libs="-llttng-ust"
4207 if $pkg_config liburcu-bp --exists; then
4208 urcu_bp_libs=$($pkg_config --libs liburcu-bp)
4209 else
4210 urcu_bp_libs="-lurcu-bp"
4213 LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
4214 libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
4215 else
4216 error_exit "Trace backend 'ust' missing lttng-ust header files"
4220 ##########################################
4221 # For 'dtrace' backend, test if 'dtrace' command is present
4222 if have_backend "dtrace"; then
4223 if ! has 'dtrace' ; then
4224 error_exit "dtrace command is not found in PATH $PATH"
4226 trace_backend_stap="no"
4227 if has 'stap' ; then
4228 trace_backend_stap="yes"
4232 ##########################################
4233 # check and set a backend for coroutine
4235 # We prefer ucontext, but it's not always possible. The fallback
4236 # is sigcontext. gthread is not selectable except explicitly, because
4237 # it is not functional enough to run QEMU proper. (It is occasionally
4238 # useful for debugging purposes.) On Windows the only valid backend
4239 # is the Windows-specific one.
4241 ucontext_works=no
4242 if test "$darwin" != "yes"; then
4243 cat > $TMPC << EOF
4244 #include <ucontext.h>
4245 #ifdef __stub_makecontext
4246 #error Ignoring glibc stub makecontext which will always fail
4247 #endif
4248 int main(void) { makecontext(0, 0, 0); return 0; }
4250 if compile_prog "" "" ; then
4251 ucontext_works=yes
4255 if test "$coroutine" = ""; then
4256 if test "$mingw32" = "yes"; then
4257 coroutine=win32
4258 elif test "$ucontext_works" = "yes"; then
4259 coroutine=ucontext
4260 else
4261 coroutine=sigaltstack
4263 else
4264 case $coroutine in
4265 windows)
4266 if test "$mingw32" != "yes"; then
4267 error_exit "'windows' coroutine backend only valid for Windows"
4269 # Unfortunately the user visible backend name doesn't match the
4270 # coroutine-*.c filename for this case, so we have to adjust it here.
4271 coroutine=win32
4273 ucontext)
4274 if test "$ucontext_works" != "yes"; then
4275 feature_not_found "ucontext"
4278 gthread|sigaltstack)
4279 if test "$mingw32" = "yes"; then
4280 error_exit "only the 'windows' coroutine backend is valid for Windows"
4284 error_exit "unknown coroutine backend $coroutine"
4286 esac
4289 if test "$coroutine_pool" = ""; then
4290 if test "$coroutine" = "gthread"; then
4291 coroutine_pool=no
4292 else
4293 coroutine_pool=yes
4296 if test "$coroutine" = "gthread" -a "$coroutine_pool" = "yes"; then
4297 error_exit "'gthread' coroutine backend does not support pool (use --disable-coroutine-pool)"
4300 ##########################################
4301 # check if we have open_by_handle_at
4303 open_by_handle_at=no
4304 cat > $TMPC << EOF
4305 #include <fcntl.h>
4306 #if !defined(AT_EMPTY_PATH)
4307 # error missing definition
4308 #else
4309 int main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
4310 #endif
4312 if compile_prog "" "" ; then
4313 open_by_handle_at=yes
4316 ########################################
4317 # check if we have linux/magic.h
4319 linux_magic_h=no
4320 cat > $TMPC << EOF
4321 #include <linux/magic.h>
4322 int main(void) {
4323 return 0;
4326 if compile_prog "" "" ; then
4327 linux_magic_h=yes
4330 ########################################
4331 # check whether we can disable warning option with a pragma (this is needed
4332 # to silence warnings in the headers of some versions of external libraries).
4333 # This test has to be compiled with -Werror as otherwise an unknown pragma is
4334 # only a warning.
4336 # If we can't selectively disable warning in the code, disable -Werror so that
4337 # the build doesn't fail anyway.
4339 pragma_disable_unused_but_set=no
4340 cat > $TMPC << EOF
4341 #pragma GCC diagnostic push
4342 #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
4343 #pragma GCC diagnostic ignored "-Wstrict-prototypes"
4344 #pragma GCC diagnostic pop
4346 int main(void) {
4347 return 0;
4350 if compile_prog "-Werror" "" ; then
4351 pragma_diagnostic_available=yes
4352 else
4353 werror=no
4356 ########################################
4357 # check if we have valgrind/valgrind.h
4359 valgrind_h=no
4360 cat > $TMPC << EOF
4361 #include <valgrind/valgrind.h>
4362 int main(void) {
4363 return 0;
4366 if compile_prog "" "" ; then
4367 valgrind_h=yes
4370 ########################################
4371 # check if environ is declared
4373 has_environ=no
4374 cat > $TMPC << EOF
4375 #include <unistd.h>
4376 int main(void) {
4377 environ = 0;
4378 return 0;
4381 if compile_prog "" "" ; then
4382 has_environ=yes
4385 ########################################
4386 # check if cpuid.h is usable.
4388 cpuid_h=no
4389 cat > $TMPC << EOF
4390 #include <cpuid.h>
4391 int main(void) {
4392 unsigned a, b, c, d;
4393 int max = __get_cpuid_max(0, 0);
4395 if (max >= 1) {
4396 __cpuid(1, a, b, c, d);
4399 if (max >= 7) {
4400 __cpuid_count(7, 0, a, b, c, d);
4403 return 0;
4406 if compile_prog "" "" ; then
4407 cpuid_h=yes
4410 ########################################
4411 # check if __[u]int128_t is usable.
4413 int128=no
4414 cat > $TMPC << EOF
4415 #if defined(__clang_major__) && defined(__clang_minor__)
4416 # if ((__clang_major__ < 3) || (__clang_major__ == 3) && (__clang_minor__ < 2))
4417 # error __int128_t does not work in CLANG before 3.2
4418 # endif
4419 #endif
4420 __int128_t a;
4421 __uint128_t b;
4422 int main (void) {
4423 a = a + b;
4424 b = a * b;
4425 a = a * a;
4426 return 0;
4429 if compile_prog "" "" ; then
4430 int128=yes
4433 ########################################
4434 # check if getauxval is available.
4436 getauxval=no
4437 cat > $TMPC << EOF
4438 #include <sys/auxv.h>
4439 int main(void) {
4440 return getauxval(AT_HWCAP) == 0;
4443 if compile_prog "" "" ; then
4444 getauxval=yes
4447 ########################################
4448 # check if ccache is interfering with
4449 # semantic analysis of macros
4451 unset CCACHE_CPP2
4452 ccache_cpp2=no
4453 cat > $TMPC << EOF
4454 static const int Z = 1;
4455 #define fn() ({ Z; })
4456 #define TAUT(X) ((X) == Z)
4457 #define PAREN(X, Y) (X == Y)
4458 #define ID(X) (X)
4459 int main(int argc, char *argv[])
4461 int x = 0, y = 0;
4462 x = ID(x);
4463 x = fn();
4464 fn();
4465 if (PAREN(x, y)) return 0;
4466 if (TAUT(Z)) return 0;
4467 return 0;
4471 if ! compile_object "-Werror"; then
4472 ccache_cpp2=yes
4475 #################################################
4476 # clang does not support glibc + FORTIFY_SOURCE.
4478 if test "$fortify_source" != "no"; then
4479 if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
4480 fortify_source="no";
4481 elif test -n "$cxx" &&
4482 echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
4483 fortify_source="no";
4484 else
4485 fortify_source="yes"
4489 ##########################################
4490 # check if struct fsxattr is available via linux/fs.h
4492 have_fsxattr=no
4493 cat > $TMPC << EOF
4494 #include <linux/fs.h>
4495 struct fsxattr foo;
4496 int main(void) {
4497 return 0;
4500 if compile_prog "" "" ; then
4501 have_fsxattr=yes
4504 ##########################################
4505 # check if rtnetlink.h exists and is useful
4506 have_rtnetlink=no
4507 cat > $TMPC << EOF
4508 #include <linux/rtnetlink.h>
4509 int main(void) {
4510 return IFLA_PROTO_DOWN;
4513 if compile_prog "" "" ; then
4514 have_rtnetlink=yes
4517 #################################################
4518 # Sparc implicitly links with --relax, which is
4519 # incompatible with -r, so --no-relax should be
4520 # given. It does no harm to give it on other
4521 # platforms too.
4523 # Note: the prototype is needed since QEMU_CFLAGS
4524 # contains -Wmissing-prototypes
4525 cat > $TMPC << EOF
4526 extern int foo(void);
4527 int foo(void) { return 0; }
4529 if ! compile_object ""; then
4530 error_exit "Failed to compile object file for LD_REL_FLAGS test"
4532 if do_cc -nostdlib -Wl,-r -Wl,--no-relax -o $TMPMO $TMPO; then
4533 LD_REL_FLAGS="-Wl,--no-relax"
4536 ##########################################
4537 # End of CC checks
4538 # After here, no more $cc or $ld runs
4540 if test "$gcov" = "yes" ; then
4541 CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
4542 LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
4543 elif test "$fortify_source" = "yes" ; then
4544 CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
4545 elif test "$debug" = "no"; then
4546 CFLAGS="-O2 $CFLAGS"
4549 ##########################################
4550 # Do we have libnfs
4551 if test "$libnfs" != "no" ; then
4552 if $pkg_config --atleast-version=1.9.3 libnfs; then
4553 libnfs="yes"
4554 libnfs_libs=$($pkg_config --libs libnfs)
4555 LIBS="$LIBS $libnfs_libs"
4556 else
4557 if test "$libnfs" = "yes" ; then
4558 feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
4560 libnfs="no"
4564 # Now we've finished running tests it's OK to add -Werror to the compiler flags
4565 if test "$werror" = "yes"; then
4566 QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
4569 if test "$solaris" = "no" ; then
4570 if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
4571 LDFLAGS="-Wl,--warn-common $LDFLAGS"
4575 # test if pod2man has --utf8 option
4576 if pod2man --help | grep -q utf8; then
4577 POD2MAN="pod2man --utf8"
4578 else
4579 POD2MAN="pod2man"
4582 # Use ASLR, no-SEH and DEP if available
4583 if test "$mingw32" = "yes" ; then
4584 for flag in --dynamicbase --no-seh --nxcompat; do
4585 if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
4586 LDFLAGS="-Wl,$flag $LDFLAGS"
4588 done
4591 qemu_confdir=$sysconfdir$confsuffix
4592 qemu_moddir=$libdir$confsuffix
4593 qemu_datadir=$datadir$confsuffix
4594 qemu_localedir="$datadir/locale"
4596 tools=""
4597 if test "$want_tools" = "yes" ; then
4598 tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
4599 if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
4600 tools="qemu-nbd\$(EXESUF) $tools"
4601 tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools"
4604 if test "$softmmu" = yes ; then
4605 if test "$virtfs" != no ; then
4606 if test "$cap" = yes && test "$linux" = yes && test "$attr" = yes ; then
4607 virtfs=yes
4608 tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
4609 else
4610 if test "$virtfs" = yes; then
4611 error_exit "VirtFS is supported only on Linux and requires libcap devel and libattr devel"
4613 virtfs=no
4618 # Probe for guest agent support/options
4620 if [ "$guest_agent" != "no" ]; then
4621 if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
4622 tools="qemu-ga $tools"
4623 guest_agent=yes
4624 elif [ "$guest_agent" != yes ]; then
4625 guest_agent=no
4626 else
4627 error_exit "Guest agent is not supported on this platform"
4631 # Guest agent Window MSI package
4633 if test "$guest_agent" != yes; then
4634 if test "$guest_agent_msi" = yes; then
4635 error_exit "MSI guest agent package requires guest agent enabled"
4637 guest_agent_msi=no
4638 elif test "$mingw32" != "yes"; then
4639 if test "$guest_agent_msi" = "yes"; then
4640 error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
4642 guest_agent_msi=no
4643 elif ! has wixl; then
4644 if test "$guest_agent_msi" = "yes"; then
4645 error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
4647 guest_agent_msi=no
4648 else
4649 # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
4650 # disabled explicitly
4651 if test "$guest_agent_msi" != "no"; then
4652 guest_agent_msi=yes
4656 if test "$guest_agent_msi" = "yes"; then
4657 if test "$guest_agent_with_vss" = "yes"; then
4658 QEMU_GA_MSI_WITH_VSS="-D InstallVss"
4661 if test "$QEMU_GA_MANUFACTURER" = ""; then
4662 QEMU_GA_MANUFACTURER=QEMU
4665 if test "$QEMU_GA_DISTRO" = ""; then
4666 QEMU_GA_DISTRO=Linux
4669 if test "$QEMU_GA_VERSION" = ""; then
4670 QEMU_GA_VERSION=$(cat $source_path/VERSION)
4673 QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
4675 case "$cpu" in
4676 x86_64)
4677 QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
4679 i386)
4680 QEMU_GA_MSI_ARCH="-D Arch=32"
4683 error_exit "CPU $cpu not supported for building installation package"
4685 esac
4688 # Mac OS X ships with a broken assembler
4689 roms=
4690 if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
4691 "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
4692 "$softmmu" = yes ; then
4693 roms="optionrom"
4695 if test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
4696 roms="$roms spapr-rtas"
4699 if test "$cpu" = "s390x" ; then
4700 roms="$roms s390-ccw"
4703 # Probe for the need for relocating the user-only binary.
4704 if ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) && [ "$pie" = no ]; then
4705 textseg_addr=
4706 case "$cpu" in
4707 arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
4708 # ??? Rationale for choosing this address
4709 textseg_addr=0x60000000
4711 mips)
4712 # A 256M aligned address, high in the address space, with enough
4713 # room for the code_gen_buffer above it before the stack.
4714 textseg_addr=0x60000000
4716 esac
4717 if [ -n "$textseg_addr" ]; then
4718 cat > $TMPC <<EOF
4719 int main(void) { return 0; }
4721 textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
4722 if ! compile_prog "" "$textseg_ldflags"; then
4723 # In case ld does not support -Ttext-segment, edit the default linker
4724 # script via sed to set the .text start addr. This is needed on FreeBSD
4725 # at least.
4726 if ! $ld --verbose >/dev/null 2>&1; then
4727 error_exit \
4728 "We need to link the QEMU user mode binaries at a" \
4729 "specific text address. Unfortunately your linker" \
4730 "doesn't support either the -Ttext-segment option or" \
4731 "printing the default linker script with --verbose." \
4732 "If you don't want the user mode binaries, pass the" \
4733 "--disable-user option to configure."
4736 $ld --verbose | sed \
4737 -e '1,/==================================================/d' \
4738 -e '/==================================================/,$d' \
4739 -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
4740 -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
4741 textseg_ldflags="-Wl,-T../config-host.ld"
4746 echo_version() {
4747 if test "$1" = "yes" ; then
4748 echo "($2)"
4752 # prepend pixman and ftd flags after all config tests are done
4753 QEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"
4754 libs_softmmu="$pixman_libs $libs_softmmu"
4756 echo "Install prefix $prefix"
4757 echo "BIOS directory $(eval echo $qemu_datadir)"
4758 echo "binary directory $(eval echo $bindir)"
4759 echo "library directory $(eval echo $libdir)"
4760 echo "module directory $(eval echo $qemu_moddir)"
4761 echo "libexec directory $(eval echo $libexecdir)"
4762 echo "include directory $(eval echo $includedir)"
4763 echo "config directory $(eval echo $sysconfdir)"
4764 if test "$mingw32" = "no" ; then
4765 echo "local state directory $(eval echo $local_statedir)"
4766 echo "Manual directory $(eval echo $mandir)"
4767 echo "ELF interp prefix $interp_prefix"
4768 else
4769 echo "local state directory queried at runtime"
4770 echo "Windows SDK $win_sdk"
4772 echo "Source path $source_path"
4773 echo "C compiler $cc"
4774 echo "Host C compiler $host_cc"
4775 echo "C++ compiler $cxx"
4776 echo "Objective-C compiler $objcc"
4777 echo "ARFLAGS $ARFLAGS"
4778 echo "CFLAGS $CFLAGS"
4779 echo "QEMU_CFLAGS $QEMU_CFLAGS"
4780 echo "LDFLAGS $LDFLAGS"
4781 echo "make $make"
4782 echo "install $install"
4783 echo "python $python"
4784 if test "$slirp" = "yes" ; then
4785 echo "smbd $smbd"
4787 echo "module support $modules"
4788 echo "host CPU $cpu"
4789 echo "host big endian $bigendian"
4790 echo "target list $target_list"
4791 echo "tcg debug enabled $debug_tcg"
4792 echo "gprof enabled $gprof"
4793 echo "sparse enabled $sparse"
4794 echo "strip binaries $strip_opt"
4795 echo "profiler $profiler"
4796 echo "static build $static"
4797 if test "$darwin" = "yes" ; then
4798 echo "Cocoa support $cocoa"
4800 echo "pixman $pixman"
4801 echo "SDL support $sdl $(echo_version $sdl $sdlversion)"
4802 echo "GTK support $gtk $(echo_version $gtk $gtk_version)"
4803 echo "GTK GL support $gtk_gl"
4804 echo "VTE support $vte $(echo_version $vte $vteversion)"
4805 echo "GNUTLS support $gnutls"
4806 echo "GNUTLS rnd $gnutls_rnd"
4807 echo "libgcrypt $gcrypt"
4808 echo "libgcrypt kdf $gcrypt_kdf"
4809 echo "nettle $nettle $(echo_version $nettle $nettle_version)"
4810 echo "nettle kdf $nettle_kdf"
4811 echo "libtasn1 $tasn1"
4812 echo "curses support $curses"
4813 echo "virgl support $virglrenderer"
4814 echo "curl support $curl"
4815 echo "mingw32 support $mingw32"
4816 echo "Audio drivers $audio_drv_list"
4817 echo "Block whitelist (rw) $block_drv_rw_whitelist"
4818 echo "Block whitelist (ro) $block_drv_ro_whitelist"
4819 echo "VirtFS support $virtfs"
4820 echo "VNC support $vnc"
4821 if test "$vnc" = "yes" ; then
4822 echo "VNC SASL support $vnc_sasl"
4823 echo "VNC JPEG support $vnc_jpeg"
4824 echo "VNC PNG support $vnc_png"
4826 if test -n "$sparc_cpu"; then
4827 echo "Target Sparc Arch $sparc_cpu"
4829 echo "xen support $xen"
4830 if test "$xen" = "yes" ; then
4831 echo "xen ctrl version $xen_ctrl_version"
4832 echo "pv dom build $xen_pv_domain_build"
4834 echo "brlapi support $brlapi"
4835 echo "bluez support $bluez"
4836 echo "Documentation $docs"
4837 echo "PIE $pie"
4838 echo "vde support $vde"
4839 echo "netmap support $netmap"
4840 echo "Linux AIO support $linux_aio"
4841 echo "ATTR/XATTR support $attr"
4842 echo "Install blobs $blobs"
4843 echo "KVM support $kvm"
4844 echo "RDMA support $rdma"
4845 echo "TCG interpreter $tcg_interpreter"
4846 echo "fdt support $fdt"
4847 echo "preadv support $preadv"
4848 echo "fdatasync $fdatasync"
4849 echo "madvise $madvise"
4850 echo "posix_madvise $posix_madvise"
4851 echo "uuid support $uuid"
4852 echo "libcap-ng support $cap_ng"
4853 echo "vhost-net support $vhost_net"
4854 echo "vhost-scsi support $vhost_scsi"
4855 echo "Trace backends $trace_backends"
4856 if have_backend "simple"; then
4857 echo "Trace output file $trace_file-<pid>"
4859 echo "spice support $spice $(echo_version $spice $spice_protocol_version/$spice_server_version)"
4860 echo "rbd support $rbd"
4861 echo "xfsctl support $xfs"
4862 echo "smartcard support $smartcard"
4863 echo "libusb $libusb"
4864 echo "usb net redir $usb_redir"
4865 echo "OpenGL support $opengl"
4866 echo "OpenGL dmabufs $opengl_dmabuf"
4867 echo "libiscsi support $libiscsi"
4868 echo "libnfs support $libnfs"
4869 echo "build guest agent $guest_agent"
4870 echo "QGA VSS support $guest_agent_with_vss"
4871 echo "QGA w32 disk info $guest_agent_ntddscsi"
4872 echo "QGA MSI support $guest_agent_msi"
4873 echo "seccomp support $seccomp"
4874 echo "coroutine backend $coroutine"
4875 echo "coroutine pool $coroutine_pool"
4876 echo "GlusterFS support $glusterfs"
4877 echo "Archipelago support $archipelago"
4878 echo "gcov $gcov_tool"
4879 echo "gcov enabled $gcov"
4880 echo "TPM support $tpm"
4881 echo "libssh2 support $libssh2"
4882 echo "TPM passthrough $tpm_passthrough"
4883 echo "QOM debugging $qom_cast_debug"
4884 echo "vhdx $vhdx"
4885 echo "lzo support $lzo"
4886 echo "snappy support $snappy"
4887 echo "bzip2 support $bzip2"
4888 echo "NUMA host support $numa"
4889 echo "tcmalloc support $tcmalloc"
4890 echo "jemalloc support $jemalloc"
4891 echo "avx2 optimization $avx2_opt"
4893 if test "$sdl_too_old" = "yes"; then
4894 echo "-> Your SDL version is too old - please upgrade to have SDL support"
4897 config_host_mak="config-host.mak"
4899 echo "# Automatically generated by configure - do not modify" >config-all-disas.mak
4901 echo "# Automatically generated by configure - do not modify" > $config_host_mak
4902 echo >> $config_host_mak
4904 echo all: >> $config_host_mak
4905 echo "prefix=$prefix" >> $config_host_mak
4906 echo "bindir=$bindir" >> $config_host_mak
4907 echo "libdir=$libdir" >> $config_host_mak
4908 echo "libexecdir=$libexecdir" >> $config_host_mak
4909 echo "includedir=$includedir" >> $config_host_mak
4910 echo "mandir=$mandir" >> $config_host_mak
4911 echo "sysconfdir=$sysconfdir" >> $config_host_mak
4912 echo "qemu_confdir=$qemu_confdir" >> $config_host_mak
4913 echo "qemu_datadir=$qemu_datadir" >> $config_host_mak
4914 echo "qemu_docdir=$qemu_docdir" >> $config_host_mak
4915 echo "qemu_moddir=$qemu_moddir" >> $config_host_mak
4916 if test "$mingw32" = "no" ; then
4917 echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
4919 echo "qemu_helperdir=$libexecdir" >> $config_host_mak
4920 echo "extra_cflags=$EXTRA_CFLAGS" >> $config_host_mak
4921 echo "extra_ldflags=$EXTRA_LDFLAGS" >> $config_host_mak
4922 echo "qemu_localedir=$qemu_localedir" >> $config_host_mak
4923 echo "libs_softmmu=$libs_softmmu" >> $config_host_mak
4925 echo "ARCH=$ARCH" >> $config_host_mak
4927 if test "$debug_tcg" = "yes" ; then
4928 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
4930 if test "$strip_opt" = "yes" ; then
4931 echo "STRIP=${strip}" >> $config_host_mak
4933 if test "$bigendian" = "yes" ; then
4934 echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
4936 if test "$mingw32" = "yes" ; then
4937 echo "CONFIG_WIN32=y" >> $config_host_mak
4938 rc_version=$(cat $source_path/VERSION)
4939 version_major=${rc_version%%.*}
4940 rc_version=${rc_version#*.}
4941 version_minor=${rc_version%%.*}
4942 rc_version=${rc_version#*.}
4943 version_subminor=${rc_version%%.*}
4944 version_micro=0
4945 echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
4946 echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
4947 if test "$guest_agent_with_vss" = "yes" ; then
4948 echo "CONFIG_QGA_VSS=y" >> $config_host_mak
4949 echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
4950 echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
4952 if test "$guest_agent_ntddscsi" = "yes" ; then
4953 echo "CONFIG_QGA_NTDDDISK=y" >> $config_host_mak
4955 if test "$guest_agent_msi" = "yes"; then
4956 echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
4957 echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
4958 echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
4959 echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
4960 echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
4961 echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
4962 echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
4964 else
4965 echo "CONFIG_POSIX=y" >> $config_host_mak
4968 if test "$linux" = "yes" ; then
4969 echo "CONFIG_LINUX=y" >> $config_host_mak
4972 if test "$darwin" = "yes" ; then
4973 echo "CONFIG_DARWIN=y" >> $config_host_mak
4976 if test "$aix" = "yes" ; then
4977 echo "CONFIG_AIX=y" >> $config_host_mak
4980 if test "$solaris" = "yes" ; then
4981 echo "CONFIG_SOLARIS=y" >> $config_host_mak
4982 echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
4983 if test "$needs_libsunmath" = "yes" ; then
4984 echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
4987 if test "$haiku" = "yes" ; then
4988 echo "CONFIG_HAIKU=y" >> $config_host_mak
4990 if test "$static" = "yes" ; then
4991 echo "CONFIG_STATIC=y" >> $config_host_mak
4993 if test "$profiler" = "yes" ; then
4994 echo "CONFIG_PROFILER=y" >> $config_host_mak
4996 if test "$slirp" = "yes" ; then
4997 echo "CONFIG_SLIRP=y" >> $config_host_mak
4998 echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
5000 if test "$vde" = "yes" ; then
5001 echo "CONFIG_VDE=y" >> $config_host_mak
5003 if test "$netmap" = "yes" ; then
5004 echo "CONFIG_NETMAP=y" >> $config_host_mak
5006 if test "$l2tpv3" = "yes" ; then
5007 echo "CONFIG_L2TPV3=y" >> $config_host_mak
5009 if test "$cap_ng" = "yes" ; then
5010 echo "CONFIG_LIBCAP=y" >> $config_host_mak
5012 echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
5013 for drv in $audio_drv_list; do
5014 def=CONFIG_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
5015 echo "$def=y" >> $config_host_mak
5016 done
5017 if test "$audio_pt_int" = "yes" ; then
5018 echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
5020 if test "$audio_win_int" = "yes" ; then
5021 echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
5023 echo "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
5024 echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
5025 if test "$vnc" = "yes" ; then
5026 echo "CONFIG_VNC=y" >> $config_host_mak
5028 if test "$vnc_sasl" = "yes" ; then
5029 echo "CONFIG_VNC_SASL=y" >> $config_host_mak
5031 if test "$vnc_jpeg" = "yes" ; then
5032 echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
5034 if test "$vnc_png" = "yes" ; then
5035 echo "CONFIG_VNC_PNG=y" >> $config_host_mak
5037 if test "$fnmatch" = "yes" ; then
5038 echo "CONFIG_FNMATCH=y" >> $config_host_mak
5040 if test "$uuid" = "yes" ; then
5041 echo "CONFIG_UUID=y" >> $config_host_mak
5043 if test "$xfs" = "yes" ; then
5044 echo "CONFIG_XFS=y" >> $config_host_mak
5046 qemu_version=$(head $source_path/VERSION)
5047 echo "VERSION=$qemu_version" >>$config_host_mak
5048 echo "PKGVERSION=$pkgversion" >>$config_host_mak
5049 echo "SRC_PATH=$source_path" >> $config_host_mak
5050 echo "TARGET_DIRS=$target_list" >> $config_host_mak
5051 if [ "$docs" = "yes" ] ; then
5052 echo "BUILD_DOCS=yes" >> $config_host_mak
5054 if test "$modules" = "yes"; then
5055 # $shacmd can generate a hash started with digit, which the compiler doesn't
5056 # like as an symbol. So prefix it with an underscore
5057 echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
5058 echo "CONFIG_MODULES=y" >> $config_host_mak
5060 if test "$sdl" = "yes" ; then
5061 echo "CONFIG_SDL=y" >> $config_host_mak
5062 echo "CONFIG_SDLABI=$sdlabi" >> $config_host_mak
5063 echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
5065 if test "$cocoa" = "yes" ; then
5066 echo "CONFIG_COCOA=y" >> $config_host_mak
5068 if test "$curses" = "yes" ; then
5069 echo "CONFIG_CURSES=y" >> $config_host_mak
5071 if test "$utimens" = "yes" ; then
5072 echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
5074 if test "$pipe2" = "yes" ; then
5075 echo "CONFIG_PIPE2=y" >> $config_host_mak
5077 if test "$accept4" = "yes" ; then
5078 echo "CONFIG_ACCEPT4=y" >> $config_host_mak
5080 if test "$splice" = "yes" ; then
5081 echo "CONFIG_SPLICE=y" >> $config_host_mak
5083 if test "$eventfd" = "yes" ; then
5084 echo "CONFIG_EVENTFD=y" >> $config_host_mak
5086 if test "$memfd" = "yes" ; then
5087 echo "CONFIG_MEMFD=y" >> $config_host_mak
5089 if test "$fallocate" = "yes" ; then
5090 echo "CONFIG_FALLOCATE=y" >> $config_host_mak
5092 if test "$fallocate_punch_hole" = "yes" ; then
5093 echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
5095 if test "$fallocate_zero_range" = "yes" ; then
5096 echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
5098 if test "$posix_fallocate" = "yes" ; then
5099 echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
5101 if test "$sync_file_range" = "yes" ; then
5102 echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
5104 if test "$fiemap" = "yes" ; then
5105 echo "CONFIG_FIEMAP=y" >> $config_host_mak
5107 if test "$dup3" = "yes" ; then
5108 echo "CONFIG_DUP3=y" >> $config_host_mak
5110 if test "$ppoll" = "yes" ; then
5111 echo "CONFIG_PPOLL=y" >> $config_host_mak
5113 if test "$prctl_pr_set_timerslack" = "yes" ; then
5114 echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
5116 if test "$epoll" = "yes" ; then
5117 echo "CONFIG_EPOLL=y" >> $config_host_mak
5119 if test "$epoll_create1" = "yes" ; then
5120 echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
5122 if test "$sendfile" = "yes" ; then
5123 echo "CONFIG_SENDFILE=y" >> $config_host_mak
5125 if test "$timerfd" = "yes" ; then
5126 echo "CONFIG_TIMERFD=y" >> $config_host_mak
5128 if test "$setns" = "yes" ; then
5129 echo "CONFIG_SETNS=y" >> $config_host_mak
5131 if test "$inotify" = "yes" ; then
5132 echo "CONFIG_INOTIFY=y" >> $config_host_mak
5134 if test "$inotify1" = "yes" ; then
5135 echo "CONFIG_INOTIFY1=y" >> $config_host_mak
5137 if test "$byteswap_h" = "yes" ; then
5138 echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
5140 if test "$bswap_h" = "yes" ; then
5141 echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
5143 if test "$curl" = "yes" ; then
5144 echo "CONFIG_CURL=m" >> $config_host_mak
5145 echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
5146 echo "CURL_LIBS=$curl_libs" >> $config_host_mak
5148 if test "$brlapi" = "yes" ; then
5149 echo "CONFIG_BRLAPI=y" >> $config_host_mak
5151 if test "$bluez" = "yes" ; then
5152 echo "CONFIG_BLUEZ=y" >> $config_host_mak
5153 echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
5155 if test "$glib_subprocess" = "yes" ; then
5156 echo "CONFIG_HAS_GLIB_SUBPROCESS_TESTS=y" >> $config_host_mak
5158 echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
5159 if test "$gtk" = "yes" ; then
5160 echo "CONFIG_GTK=y" >> $config_host_mak
5161 echo "CONFIG_GTKABI=$gtkabi" >> $config_host_mak
5162 echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
5163 echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
5164 if test "$gtk_gl" = "yes" ; then
5165 echo "CONFIG_GTK_GL=y" >> $config_host_mak
5168 if test "$gnutls" = "yes" ; then
5169 echo "CONFIG_GNUTLS=y" >> $config_host_mak
5171 if test "$gnutls_rnd" = "yes" ; then
5172 echo "CONFIG_GNUTLS_RND=y" >> $config_host_mak
5174 if test "$gcrypt" = "yes" ; then
5175 echo "CONFIG_GCRYPT=y" >> $config_host_mak
5176 if test "$gcrypt_kdf" = "yes" ; then
5177 echo "CONFIG_GCRYPT_KDF=y" >> $config_host_mak
5180 if test "$nettle" = "yes" ; then
5181 echo "CONFIG_NETTLE=y" >> $config_host_mak
5182 echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
5183 if test "$nettle_kdf" = "yes" ; then
5184 echo "CONFIG_NETTLE_KDF=y" >> $config_host_mak
5187 if test "$tasn1" = "yes" ; then
5188 echo "CONFIG_TASN1=y" >> $config_host_mak
5190 if test "$have_ifaddrs_h" = "yes" ; then
5191 echo "HAVE_IFADDRS_H=y" >> $config_host_mak
5194 # Work around a system header bug with some kernel/XFS header
5195 # versions where they both try to define 'struct fsxattr':
5196 # xfs headers will not try to redefine structs from linux headers
5197 # if this macro is set.
5198 if test "$have_fsxattr" = "yes" ; then
5199 echo "HAVE_FSXATTR=y" >> $config_host_mak
5201 if test "$vte" = "yes" ; then
5202 echo "CONFIG_VTE=y" >> $config_host_mak
5203 echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
5205 if test "$virglrenderer" = "yes" ; then
5206 echo "CONFIG_VIRGL=y" >> $config_host_mak
5207 echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
5208 echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
5210 if test "$xen" = "yes" ; then
5211 echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
5212 echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
5213 if test "$xen_pv_domain_build" = "yes" ; then
5214 echo "CONFIG_XEN_PV_DOMAIN_BUILD=y" >> $config_host_mak
5217 if test "$linux_aio" = "yes" ; then
5218 echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
5220 if test "$attr" = "yes" ; then
5221 echo "CONFIG_ATTR=y" >> $config_host_mak
5223 if test "$libattr" = "yes" ; then
5224 echo "CONFIG_LIBATTR=y" >> $config_host_mak
5226 if test "$virtfs" = "yes" ; then
5227 echo "CONFIG_VIRTFS=y" >> $config_host_mak
5229 if test "$vhost_scsi" = "yes" ; then
5230 echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
5232 if test "$vhost_net" = "yes" ; then
5233 echo "CONFIG_VHOST_NET_USED=y" >> $config_host_mak
5235 if test "$blobs" = "yes" ; then
5236 echo "INSTALL_BLOBS=yes" >> $config_host_mak
5238 if test "$iovec" = "yes" ; then
5239 echo "CONFIG_IOVEC=y" >> $config_host_mak
5241 if test "$preadv" = "yes" ; then
5242 echo "CONFIG_PREADV=y" >> $config_host_mak
5244 if test "$fdt" = "yes" ; then
5245 echo "CONFIG_FDT=y" >> $config_host_mak
5247 if test "$signalfd" = "yes" ; then
5248 echo "CONFIG_SIGNALFD=y" >> $config_host_mak
5250 if test "$tcg_interpreter" = "yes" ; then
5251 echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
5253 if test "$fdatasync" = "yes" ; then
5254 echo "CONFIG_FDATASYNC=y" >> $config_host_mak
5256 if test "$madvise" = "yes" ; then
5257 echo "CONFIG_MADVISE=y" >> $config_host_mak
5259 if test "$posix_madvise" = "yes" ; then
5260 echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
5263 if test "$spice" = "yes" ; then
5264 echo "CONFIG_SPICE=y" >> $config_host_mak
5267 if test "$smartcard" = "yes" ; then
5268 echo "CONFIG_SMARTCARD=y" >> $config_host_mak
5271 if test "$libusb" = "yes" ; then
5272 echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
5275 if test "$usb_redir" = "yes" ; then
5276 echo "CONFIG_USB_REDIR=y" >> $config_host_mak
5279 if test "$opengl" = "yes" ; then
5280 echo "CONFIG_OPENGL=y" >> $config_host_mak
5281 echo "OPENGL_CFLAGS=$opengl_cflags" >> $config_host_mak
5282 echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
5283 if test "$opengl_dmabuf" = "yes" ; then
5284 echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
5288 if test "$avx2_opt" = "yes" ; then
5289 echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
5292 if test "$lzo" = "yes" ; then
5293 echo "CONFIG_LZO=y" >> $config_host_mak
5296 if test "$snappy" = "yes" ; then
5297 echo "CONFIG_SNAPPY=y" >> $config_host_mak
5300 if test "$bzip2" = "yes" ; then
5301 echo "CONFIG_BZIP2=y" >> $config_host_mak
5302 echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
5305 if test "$libiscsi" = "yes" ; then
5306 echo "CONFIG_LIBISCSI=m" >> $config_host_mak
5307 echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
5308 echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
5311 if test "$libnfs" = "yes" ; then
5312 echo "CONFIG_LIBNFS=y" >> $config_host_mak
5315 if test "$seccomp" = "yes"; then
5316 echo "CONFIG_SECCOMP=y" >> $config_host_mak
5319 # XXX: suppress that
5320 if [ "$bsd" = "yes" ] ; then
5321 echo "CONFIG_BSD=y" >> $config_host_mak
5324 if test "$localtime_r" = "yes" ; then
5325 echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
5327 if test "$qom_cast_debug" = "yes" ; then
5328 echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
5330 if test "$rbd" = "yes" ; then
5331 echo "CONFIG_RBD=m" >> $config_host_mak
5332 echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
5333 echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
5336 echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
5337 if test "$coroutine_pool" = "yes" ; then
5338 echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
5339 else
5340 echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
5343 if test "$open_by_handle_at" = "yes" ; then
5344 echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
5347 if test "$linux_magic_h" = "yes" ; then
5348 echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
5351 if test "$pragma_diagnostic_available" = "yes" ; then
5352 echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
5355 if test "$valgrind_h" = "yes" ; then
5356 echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
5359 if test "$has_environ" = "yes" ; then
5360 echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
5363 if test "$cpuid_h" = "yes" ; then
5364 echo "CONFIG_CPUID_H=y" >> $config_host_mak
5367 if test "$int128" = "yes" ; then
5368 echo "CONFIG_INT128=y" >> $config_host_mak
5371 if test "$getauxval" = "yes" ; then
5372 echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
5375 if test "$glusterfs" = "yes" ; then
5376 echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
5377 echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
5378 echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
5381 if test "$glusterfs_xlator_opt" = "yes" ; then
5382 echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
5385 if test "$glusterfs_discard" = "yes" ; then
5386 echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
5389 if test "$glusterfs_zerofill" = "yes" ; then
5390 echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
5393 if test "$archipelago" = "yes" ; then
5394 echo "CONFIG_ARCHIPELAGO=m" >> $config_host_mak
5395 echo "ARCHIPELAGO_LIBS=$archipelago_libs" >> $config_host_mak
5398 if test "$libssh2" = "yes" ; then
5399 echo "CONFIG_LIBSSH2=m" >> $config_host_mak
5400 echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
5401 echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak
5404 if test "$vhdx" = "yes" ; then
5405 echo "CONFIG_VHDX=y" >> $config_host_mak
5408 # USB host support
5409 if test "$libusb" = "yes"; then
5410 echo "HOST_USB=libusb legacy" >> $config_host_mak
5411 else
5412 echo "HOST_USB=stub" >> $config_host_mak
5415 # TPM passthrough support?
5416 if test "$tpm" = "yes"; then
5417 echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak
5418 if test "$tpm_passthrough" = "yes"; then
5419 echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
5423 echo "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
5424 if have_backend "nop"; then
5425 echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
5427 if have_backend "simple"; then
5428 echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
5429 # Set the appropriate trace file.
5430 trace_file="\"$trace_file-\" FMT_pid"
5432 if have_backend "log"; then
5433 echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
5435 if have_backend "ust"; then
5436 echo "CONFIG_TRACE_UST=y" >> $config_host_mak
5438 if have_backend "dtrace"; then
5439 echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
5440 if test "$trace_backend_stap" = "yes" ; then
5441 echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
5444 if have_backend "ftrace"; then
5445 if test "$linux" = "yes" ; then
5446 echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
5447 else
5448 feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
5451 echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
5453 if test "$rdma" = "yes" ; then
5454 echo "CONFIG_RDMA=y" >> $config_host_mak
5457 if test "$have_rtnetlink" = "yes" ; then
5458 echo "CONFIG_RTNETLINK=y" >> $config_host_mak
5461 # Hold two types of flag:
5462 # CONFIG_THREAD_SETNAME_BYTHREAD - we've got a way of setting the name on
5463 # a thread we have a handle to
5464 # CONFIG_PTHREAD_SETNAME_NP - A way of doing it on a particular
5465 # platform
5466 if test "$pthread_setname_np" = "yes" ; then
5467 echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
5468 echo "CONFIG_PTHREAD_SETNAME_NP=y" >> $config_host_mak
5471 if test "$tcg_interpreter" = "yes"; then
5472 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
5473 elif test "$ARCH" = "sparc64" ; then
5474 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
5475 elif test "$ARCH" = "s390x" ; then
5476 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
5477 elif test "$ARCH" = "x86_64" -o "$ARCH" = "x32" ; then
5478 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
5479 elif test "$ARCH" = "ppc64" ; then
5480 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/ppc $QEMU_INCLUDES"
5481 else
5482 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
5484 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg $QEMU_INCLUDES"
5486 echo "TOOLS=$tools" >> $config_host_mak
5487 echo "ROMS=$roms" >> $config_host_mak
5488 echo "MAKE=$make" >> $config_host_mak
5489 echo "INSTALL=$install" >> $config_host_mak
5490 echo "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
5491 echo "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
5492 echo "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
5493 echo "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
5494 echo "PYTHON=$python" >> $config_host_mak
5495 echo "CC=$cc" >> $config_host_mak
5496 if $iasl -h > /dev/null 2>&1; then
5497 echo "IASL=$iasl" >> $config_host_mak
5499 echo "CC_I386=$cc_i386" >> $config_host_mak
5500 echo "HOST_CC=$host_cc" >> $config_host_mak
5501 echo "CXX=$cxx" >> $config_host_mak
5502 echo "OBJCC=$objcc" >> $config_host_mak
5503 echo "AR=$ar" >> $config_host_mak
5504 echo "ARFLAGS=$ARFLAGS" >> $config_host_mak
5505 echo "AS=$as" >> $config_host_mak
5506 echo "CPP=$cpp" >> $config_host_mak
5507 echo "OBJCOPY=$objcopy" >> $config_host_mak
5508 echo "LD=$ld" >> $config_host_mak
5509 echo "NM=$nm" >> $config_host_mak
5510 echo "WINDRES=$windres" >> $config_host_mak
5511 echo "CFLAGS=$CFLAGS" >> $config_host_mak
5512 echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
5513 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
5514 echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
5515 if test "$sparse" = "yes" ; then
5516 echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_host_mak
5517 echo "CPP := REAL_CC=\"\$(CPP)\" cgcc" >> $config_host_mak
5518 echo "CXX := REAL_CC=\"\$(CXX)\" cgcc" >> $config_host_mak
5519 echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_host_mak
5520 echo "QEMU_CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
5522 if test "$cross_prefix" != ""; then
5523 echo "AUTOCONF_HOST := --host=${cross_prefix%-}" >> $config_host_mak
5524 else
5525 echo "AUTOCONF_HOST := " >> $config_host_mak
5527 echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
5528 echo "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
5529 echo "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
5530 echo "LIBS+=$LIBS" >> $config_host_mak
5531 echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
5532 echo "EXESUF=$EXESUF" >> $config_host_mak
5533 echo "DSOSUF=$DSOSUF" >> $config_host_mak
5534 echo "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
5535 echo "LIBS_QGA+=$libs_qga" >> $config_host_mak
5536 echo "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
5537 echo "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
5538 echo "POD2MAN=$POD2MAN" >> $config_host_mak
5539 echo "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
5540 if test "$gcov" = "yes" ; then
5541 echo "CONFIG_GCOV=y" >> $config_host_mak
5542 echo "GCOV=$gcov_tool" >> $config_host_mak
5545 # use included Linux headers
5546 if test "$linux" = "yes" ; then
5547 mkdir -p linux-headers
5548 case "$cpu" in
5549 i386|x86_64|x32)
5550 linux_arch=x86
5552 ppcemb|ppc|ppc64)
5553 linux_arch=powerpc
5555 s390x)
5556 linux_arch=s390
5558 aarch64)
5559 linux_arch=arm64
5561 mips64)
5562 linux_arch=mips
5565 # For most CPUs the kernel architecture name and QEMU CPU name match.
5566 linux_arch="$cpu"
5568 esac
5569 # For non-KVM architectures we will not have asm headers
5570 if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
5571 symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
5575 for target in $target_list; do
5576 target_dir="$target"
5577 config_target_mak=$target_dir/config-target.mak
5578 target_name=$(echo $target | cut -d '-' -f 1)
5579 target_bigendian="no"
5581 case "$target_name" in
5582 armeb|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or32|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
5583 target_bigendian=yes
5585 esac
5586 target_softmmu="no"
5587 target_user_only="no"
5588 target_linux_user="no"
5589 target_bsd_user="no"
5590 case "$target" in
5591 ${target_name}-softmmu)
5592 target_softmmu="yes"
5594 ${target_name}-linux-user)
5595 if test "$linux" != "yes" ; then
5596 error_exit "Target '$target' is only available on a Linux host"
5598 target_user_only="yes"
5599 target_linux_user="yes"
5601 ${target_name}-bsd-user)
5602 if test "$bsd" != "yes" ; then
5603 error_exit "Target '$target' is only available on a BSD host"
5605 target_user_only="yes"
5606 target_bsd_user="yes"
5609 error_exit "Target '$target' not recognised"
5610 exit 1
5612 esac
5614 mkdir -p $target_dir
5615 echo "# Automatically generated by configure - do not modify" > $config_target_mak
5617 bflt="no"
5618 interp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
5619 gdb_xml_files=""
5621 TARGET_ARCH="$target_name"
5622 TARGET_BASE_ARCH=""
5623 TARGET_ABI_DIR=""
5625 case "$target_name" in
5626 i386)
5628 x86_64)
5629 TARGET_BASE_ARCH=i386
5631 alpha)
5633 arm|armeb)
5634 TARGET_ARCH=arm
5635 bflt="yes"
5636 gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
5638 aarch64)
5639 TARGET_BASE_ARCH=arm
5640 bflt="yes"
5641 gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
5643 cris)
5645 lm32)
5647 m68k)
5648 bflt="yes"
5649 gdb_xml_files="cf-core.xml cf-fp.xml"
5651 microblaze|microblazeel)
5652 TARGET_ARCH=microblaze
5653 bflt="yes"
5655 mips|mipsel)
5656 TARGET_ARCH=mips
5657 echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
5659 mipsn32|mipsn32el)
5660 TARGET_ARCH=mips64
5661 TARGET_BASE_ARCH=mips
5662 echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
5663 echo "TARGET_ABI32=y" >> $config_target_mak
5665 mips64|mips64el)
5666 TARGET_ARCH=mips64
5667 TARGET_BASE_ARCH=mips
5668 echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
5670 moxie)
5672 or32)
5673 TARGET_ARCH=openrisc
5674 TARGET_BASE_ARCH=openrisc
5676 ppc)
5677 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
5679 ppcemb)
5680 TARGET_BASE_ARCH=ppc
5681 TARGET_ABI_DIR=ppc
5682 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
5684 ppc64)
5685 TARGET_BASE_ARCH=ppc
5686 TARGET_ABI_DIR=ppc
5687 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
5689 ppc64le)
5690 TARGET_ARCH=ppc64
5691 TARGET_BASE_ARCH=ppc
5692 TARGET_ABI_DIR=ppc
5693 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
5695 ppc64abi32)
5696 TARGET_ARCH=ppc64
5697 TARGET_BASE_ARCH=ppc
5698 TARGET_ABI_DIR=ppc
5699 echo "TARGET_ABI32=y" >> $config_target_mak
5700 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
5702 sh4|sh4eb)
5703 TARGET_ARCH=sh4
5704 bflt="yes"
5706 sparc)
5708 sparc64)
5709 TARGET_BASE_ARCH=sparc
5711 sparc32plus)
5712 TARGET_ARCH=sparc64
5713 TARGET_BASE_ARCH=sparc
5714 TARGET_ABI_DIR=sparc
5715 echo "TARGET_ABI32=y" >> $config_target_mak
5717 s390x)
5718 gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml s390-cr.xml s390-virt.xml"
5720 tilegx)
5722 tricore)
5724 unicore32)
5726 xtensa|xtensaeb)
5727 TARGET_ARCH=xtensa
5730 error_exit "Unsupported target CPU"
5732 esac
5733 # TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
5734 if [ "$TARGET_BASE_ARCH" = "" ]; then
5735 TARGET_BASE_ARCH=$TARGET_ARCH
5738 symlink "$source_path/Makefile.target" "$target_dir/Makefile"
5740 upper() {
5741 echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
5744 target_arch_name="$(upper $TARGET_ARCH)"
5745 echo "TARGET_$target_arch_name=y" >> $config_target_mak
5746 echo "TARGET_NAME=$target_name" >> $config_target_mak
5747 echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
5748 if [ "$TARGET_ABI_DIR" = "" ]; then
5749 TARGET_ABI_DIR=$TARGET_ARCH
5751 echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
5752 if [ "$HOST_VARIANT_DIR" != "" ]; then
5753 echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
5755 case "$target_name" in
5756 i386|x86_64)
5757 if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
5758 echo "CONFIG_XEN=y" >> $config_target_mak
5759 if test "$xen_pci_passthrough" = yes; then
5760 echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
5765 esac
5766 case "$target_name" in
5767 aarch64|arm|i386|x86_64|ppcemb|ppc|ppc64|s390x|mipsel|mips)
5768 # Make sure the target and host cpus are compatible
5769 if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
5770 \( "$target_name" = "$cpu" -o \
5771 \( "$target_name" = "ppcemb" -a "$cpu" = "ppc" \) -o \
5772 \( "$target_name" = "ppc64" -a "$cpu" = "ppc" \) -o \
5773 \( "$target_name" = "ppc" -a "$cpu" = "ppc64" \) -o \
5774 \( "$target_name" = "ppcemb" -a "$cpu" = "ppc64" \) -o \
5775 \( "$target_name" = "mipsel" -a "$cpu" = "mips" \) -o \
5776 \( "$target_name" = "x86_64" -a "$cpu" = "i386" \) -o \
5777 \( "$target_name" = "i386" -a "$cpu" = "x86_64" \) -o \
5778 \( "$target_name" = "x86_64" -a "$cpu" = "x32" \) -o \
5779 \( "$target_name" = "i386" -a "$cpu" = "x32" \) \) ; then
5780 echo "CONFIG_KVM=y" >> $config_target_mak
5781 if test "$vhost_net" = "yes" ; then
5782 echo "CONFIG_VHOST_NET=y" >> $config_target_mak
5783 echo "CONFIG_VHOST_NET_TEST_$target_name=y" >> $config_host_mak
5786 esac
5787 if test "$target_bigendian" = "yes" ; then
5788 echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
5790 if test "$target_softmmu" = "yes" ; then
5791 echo "CONFIG_SOFTMMU=y" >> $config_target_mak
5793 if test "$target_user_only" = "yes" ; then
5794 echo "CONFIG_USER_ONLY=y" >> $config_target_mak
5795 echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
5797 if test "$target_linux_user" = "yes" ; then
5798 echo "CONFIG_LINUX_USER=y" >> $config_target_mak
5800 list=""
5801 if test ! -z "$gdb_xml_files" ; then
5802 for x in $gdb_xml_files; do
5803 list="$list $source_path/gdb-xml/$x"
5804 done
5805 echo "TARGET_XML_FILES=$list" >> $config_target_mak
5808 if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
5809 echo "TARGET_HAS_BFLT=y" >> $config_target_mak
5811 if test "$target_bsd_user" = "yes" ; then
5812 echo "CONFIG_BSD_USER=y" >> $config_target_mak
5815 # generate QEMU_CFLAGS/LDFLAGS for targets
5817 cflags=""
5818 ldflags=""
5820 disas_config() {
5821 echo "CONFIG_${1}_DIS=y" >> $config_target_mak
5822 echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
5825 for i in $ARCH $TARGET_BASE_ARCH ; do
5826 case "$i" in
5827 alpha)
5828 disas_config "ALPHA"
5830 aarch64)
5831 if test -n "${cxx}"; then
5832 disas_config "ARM_A64"
5835 arm)
5836 disas_config "ARM"
5837 if test -n "${cxx}"; then
5838 disas_config "ARM_A64"
5841 cris)
5842 disas_config "CRIS"
5844 hppa)
5845 disas_config "HPPA"
5847 i386|x86_64|x32)
5848 disas_config "I386"
5850 ia64*)
5851 disas_config "IA64"
5853 lm32)
5854 disas_config "LM32"
5856 m68k)
5857 disas_config "M68K"
5859 microblaze*)
5860 disas_config "MICROBLAZE"
5862 mips*)
5863 disas_config "MIPS"
5865 moxie*)
5866 disas_config "MOXIE"
5868 or32)
5869 disas_config "OPENRISC"
5871 ppc*)
5872 disas_config "PPC"
5874 s390*)
5875 disas_config "S390"
5877 sh4)
5878 disas_config "SH4"
5880 sparc*)
5881 disas_config "SPARC"
5883 xtensa*)
5884 disas_config "XTENSA"
5886 esac
5887 done
5888 if test "$tcg_interpreter" = "yes" ; then
5889 disas_config "TCI"
5892 case "$ARCH" in
5893 alpha)
5894 # Ensure there's only a single GP
5895 cflags="-msmall-data $cflags"
5897 esac
5899 if test "$gprof" = "yes" ; then
5900 echo "TARGET_GPROF=yes" >> $config_target_mak
5901 if test "$target_linux_user" = "yes" ; then
5902 cflags="-p $cflags"
5903 ldflags="-p $ldflags"
5905 if test "$target_softmmu" = "yes" ; then
5906 ldflags="-p $ldflags"
5907 echo "GPROF_CFLAGS=-p" >> $config_target_mak
5911 if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
5912 ldflags="$ldflags $textseg_ldflags"
5915 echo "LDFLAGS+=$ldflags" >> $config_target_mak
5916 echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak
5918 done # for target in $targets
5920 if [ "$pixman" = "internal" ]; then
5921 echo "config-host.h: subdir-pixman" >> $config_host_mak
5924 if [ "$dtc_internal" = "yes" ]; then
5925 echo "config-host.h: subdir-dtc" >> $config_host_mak
5928 if test "$numa" = "yes"; then
5929 echo "CONFIG_NUMA=y" >> $config_host_mak
5932 if test "$ccache_cpp2" = "yes"; then
5933 echo "export CCACHE_CPP2=y" >> $config_host_mak
5936 # build tree in object directory in case the source is not in the current directory
5937 DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests"
5938 DIRS="$DIRS fsdev"
5939 DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
5940 DIRS="$DIRS roms/seabios roms/vgabios"
5941 DIRS="$DIRS qapi-generated"
5942 FILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
5943 FILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
5944 FILES="$FILES tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
5945 FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
5946 FILES="$FILES pc-bios/spapr-rtas/Makefile"
5947 FILES="$FILES pc-bios/s390-ccw/Makefile"
5948 FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
5949 FILES="$FILES pc-bios/qemu-icon.bmp"
5950 for bios_file in \
5951 $source_path/pc-bios/*.bin \
5952 $source_path/pc-bios/*.aml \
5953 $source_path/pc-bios/*.rom \
5954 $source_path/pc-bios/*.dtb \
5955 $source_path/pc-bios/*.img \
5956 $source_path/pc-bios/openbios-* \
5957 $source_path/pc-bios/u-boot.* \
5958 $source_path/pc-bios/palcode-*
5960 FILES="$FILES pc-bios/$(basename $bios_file)"
5961 done
5962 for test_file in $(find $source_path/tests/acpi-test-data -type f)
5964 FILES="$FILES tests/acpi-test-data$(echo $test_file | sed -e 's/.*acpi-test-data//')"
5965 done
5966 mkdir -p $DIRS
5967 for f in $FILES ; do
5968 if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
5969 symlink "$source_path/$f" "$f"
5971 done
5973 # temporary config to build submodules
5974 for rom in seabios vgabios ; do
5975 config_mak=roms/$rom/config.mak
5976 echo "# Automatically generated by configure - do not modify" > $config_mak
5977 echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
5978 echo "AS=$as" >> $config_mak
5979 echo "CC=$cc" >> $config_mak
5980 echo "BCC=bcc" >> $config_mak
5981 echo "CPP=$cpp" >> $config_mak
5982 echo "OBJCOPY=objcopy" >> $config_mak
5983 echo "IASL=$iasl" >> $config_mak
5984 echo "LD=$ld" >> $config_mak
5985 done
5987 # set up qemu-iotests in this build directory
5988 iotests_common_env="tests/qemu-iotests/common.env"
5989 iotests_check="tests/qemu-iotests/check"
5991 echo "# Automatically generated by configure - do not modify" > "$iotests_common_env"
5992 echo >> "$iotests_common_env"
5993 echo "export PYTHON='$python'" >> "$iotests_common_env"
5995 if [ ! -e "$iotests_check" ]; then
5996 symlink "$source_path/$iotests_check" "$iotests_check"
5999 # Save the configure command line for later reuse.
6000 cat <<EOD >config.status
6001 #!/bin/sh
6002 # Generated by configure.
6003 # Run this file to recreate the current configuration.
6004 # Compiler output produced by configure, useful for debugging
6005 # configure, is in config.log if it exists.
6007 printf "exec" >>config.status
6008 printf " '%s'" "$0" "$@" >>config.status
6009 echo ' "$@"' >>config.status
6010 chmod +x config.status
6012 rm -r "$TMPDIR1"