]> git.proxmox.com Git - qemu.git/blame_incremental - configure
tcg: Add TCGV_IS_UNUSED_*
[qemu.git] / configure
... / ...
CommitLineData
1#!/bin/sh
2#
3# qemu configure script (c) 2003 Fabrice Bellard
4#
5# set temporary file name
6if test ! -z "$TMPDIR" ; then
7 TMPDIR1="${TMPDIR}"
8elif test ! -z "$TEMPDIR" ; then
9 TMPDIR1="${TEMPDIR}"
10else
11 TMPDIR1="/tmp"
12fi
13
14TMPC="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.c"
15TMPO="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.o"
16TMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.exe"
17
18# NB: do not call "exit" in the trap handler; this is buggy with some shells;
19# see <1285349658-3122-1-git-send-email-loic.minier@linaro.org>
20trap "rm -f $TMPC $TMPO $TMPE" EXIT INT QUIT TERM
21rm -f config.log
22
23# Print a helpful header at the top of config.log
24echo "# QEMU configure log $(date)" >> config.log
25printf "# Configured with:" >> config.log
26printf " '%s'" "$0" "$@" >> config.log
27echo >> config.log
28echo "#" >> config.log
29
30do_cc() {
31 # Run the compiler, capturing its output to the log.
32 echo $cc "$@" >> config.log
33 $cc "$@" >> config.log 2>&1 || return $?
34 # Test passed. If this is an --enable-werror build, rerun
35 # the test with -Werror and bail out if it fails. This
36 # makes warning-generating-errors in configure test code
37 # obvious to developers.
38 if test "$werror" != "yes"; then
39 return 0
40 fi
41 # Don't bother rerunning the compile if we were already using -Werror
42 case "$*" in
43 *-Werror*)
44 return 0
45 ;;
46 esac
47 echo $cc -Werror "$@" >> config.log
48 $cc -Werror "$@" >> config.log 2>&1 && return $?
49 echo "ERROR: configure test passed without -Werror but failed with -Werror."
50 echo "This is probably a bug in the configure script. The failing command"
51 echo "will be at the bottom of config.log."
52 echo "You can run configure with --disable-werror to bypass this check."
53 exit 1
54}
55
56compile_object() {
57 do_cc $QEMU_CFLAGS -c -o $TMPO $TMPC
58}
59
60compile_prog() {
61 local_cflags="$1"
62 local_ldflags="$2"
63 do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
64}
65
66# symbolically link $1 to $2. Portable version of "ln -sf".
67symlink() {
68 rm -rf "$2"
69 mkdir -p "$(dirname "$2")"
70 ln -s "$1" "$2"
71}
72
73# check whether a command is available to this shell (may be either an
74# executable or a builtin)
75has() {
76 type "$1" >/dev/null 2>&1
77}
78
79# search for an executable in PATH
80path_of() {
81 local_command="$1"
82 local_ifs="$IFS"
83 local_dir=""
84
85 # pathname has a dir component?
86 if [ "${local_command#*/}" != "$local_command" ]; then
87 if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
88 echo "$local_command"
89 return 0
90 fi
91 fi
92 if [ -z "$local_command" ]; then
93 return 1
94 fi
95
96 IFS=:
97 for local_dir in $PATH; do
98 if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
99 echo "$local_dir/$local_command"
100 IFS="${local_ifs:-$(printf ' \t\n')}"
101 return 0
102 fi
103 done
104 # not found
105 IFS="${local_ifs:-$(printf ' \t\n')}"
106 return 1
107}
108
109# default parameters
110source_path=`dirname "$0"`
111cpu=""
112interp_prefix="/usr/gnemul/qemu-%M"
113static="no"
114cross_prefix=""
115audio_drv_list=""
116audio_card_list="ac97 es1370 sb16 hda"
117audio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus hda"
118block_drv_whitelist=""
119host_cc="cc"
120libs_softmmu=""
121libs_tools=""
122audio_pt_int=""
123audio_win_int=""
124cc_i386=i386-pc-linux-gnu-gcc
125libs_qga=""
126debug_info="yes"
127
128# Don't accept a target_list environment variable.
129unset target_list
130
131# Default value for a variable defining feature "foo".
132# * foo="no" feature will only be used if --enable-foo arg is given
133# * foo="" feature will be searched for, and if found, will be used
134# unless --disable-foo is given
135# * foo="yes" this value will only be set by --enable-foo flag.
136# feature will searched for,
137# if not found, configure exits with error
138#
139# Always add --enable-foo and --disable-foo command line args.
140# Distributions want to ensure that several features are compiled in, and it
141# is impossible without a --enable-foo that exits if a feature is not found.
142
143bluez=""
144brlapi=""
145curl=""
146curses=""
147docs=""
148fdt=""
149nptl=""
150pixman=""
151sdl=""
152virtfs=""
153vnc="yes"
154sparse="no"
155uuid=""
156vde=""
157vnc_tls=""
158vnc_sasl=""
159vnc_jpeg=""
160vnc_png=""
161xen=""
162xen_ctrl_version=""
163xen_pci_passthrough=""
164linux_aio=""
165cap_ng=""
166attr=""
167libattr=""
168xfs=""
169
170vhost_net="no"
171kvm="no"
172gprof="no"
173debug_tcg="no"
174debug="no"
175strip_opt="yes"
176tcg_interpreter="no"
177bigendian="no"
178mingw32="no"
179EXESUF=""
180prefix="/usr/local"
181mandir="\${prefix}/share/man"
182datadir="\${prefix}/share"
183qemu_docdir="\${prefix}/share/doc/qemu"
184bindir="\${prefix}/bin"
185libdir="\${prefix}/lib"
186libexecdir="\${prefix}/libexec"
187includedir="\${prefix}/include"
188sysconfdir="\${prefix}/etc"
189local_statedir="\${prefix}/var"
190confsuffix="/qemu"
191slirp="yes"
192fmod_lib=""
193fmod_inc=""
194oss_lib=""
195bsd="no"
196linux="no"
197solaris="no"
198profiler="no"
199cocoa="no"
200softmmu="yes"
201linux_user="no"
202bsd_user="no"
203guest_base="yes"
204uname_release=""
205mixemu="no"
206aix="no"
207blobs="yes"
208pkgversion=""
209pie=""
210zero_malloc=""
211trace_backend="nop"
212trace_file="trace"
213spice=""
214rbd=""
215smartcard=""
216smartcard_nss=""
217usb_redir=""
218opengl=""
219zlib="yes"
220guest_agent="yes"
221want_tools="yes"
222libiscsi=""
223coroutine=""
224seccomp=""
225glusterfs=""
226
227# parse CC options first
228for opt do
229 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
230 case "$opt" in
231 --cross-prefix=*) cross_prefix="$optarg"
232 ;;
233 --cc=*) CC="$optarg"
234 ;;
235 --source-path=*) source_path="$optarg"
236 ;;
237 --cpu=*) cpu="$optarg"
238 ;;
239 --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
240 ;;
241 --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
242 ;;
243 --enable-debug-info) debug_info="yes"
244 ;;
245 --disable-debug-info) debug_info="no"
246 ;;
247 esac
248done
249# OS specific
250# Using uname is really, really broken. Once we have the right set of checks
251# we can eliminate its usage altogether.
252
253# Preferred compiler:
254# ${CC} (if set)
255# ${cross_prefix}gcc (if cross-prefix specified)
256# system compiler
257if test -z "${CC}${cross_prefix}"; then
258 cc="$host_cc"
259else
260 cc="${CC-${cross_prefix}gcc}"
261fi
262
263ar="${AR-${cross_prefix}ar}"
264objcopy="${OBJCOPY-${cross_prefix}objcopy}"
265ld="${LD-${cross_prefix}ld}"
266libtool="${LIBTOOL-${cross_prefix}libtool}"
267strip="${STRIP-${cross_prefix}strip}"
268windres="${WINDRES-${cross_prefix}windres}"
269pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
270query_pkg_config() {
271 "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
272}
273pkg_config=query_pkg_config
274sdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
275
276# default flags for all hosts
277QEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
278QEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
279QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
280QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
281QEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/include"
282if test "$debug_info" = "yes"; then
283 CFLAGS="-g $CFLAGS"
284 LDFLAGS="-g $LDFLAGS"
285fi
286
287# make source path absolute
288source_path=`cd "$source_path"; pwd`
289
290check_define() {
291cat > $TMPC <<EOF
292#if !defined($1)
293#error $1 not defined
294#endif
295int main(void) { return 0; }
296EOF
297 compile_object
298}
299
300if check_define __linux__ ; then
301 targetos="Linux"
302elif check_define _WIN32 ; then
303 targetos='MINGW32'
304elif check_define __OpenBSD__ ; then
305 targetos='OpenBSD'
306elif check_define __sun__ ; then
307 targetos='SunOS'
308elif check_define __HAIKU__ ; then
309 targetos='Haiku'
310else
311 targetos=`uname -s`
312fi
313
314# Some host OSes need non-standard checks for which CPU to use.
315# Note that these checks are broken for cross-compilation: if you're
316# cross-compiling to one of these OSes then you'll need to specify
317# the correct CPU with the --cpu option.
318case $targetos in
319Darwin)
320 # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
321 # run 64-bit userspace code.
322 # If the user didn't specify a CPU explicitly and the kernel says this is
323 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
324 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
325 cpu="x86_64"
326 fi
327 ;;
328SunOS)
329 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
330 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
331 cpu="x86_64"
332 fi
333esac
334
335if test ! -z "$cpu" ; then
336 # command line argument
337 :
338elif check_define __i386__ ; then
339 cpu="i386"
340elif check_define __x86_64__ ; then
341 cpu="x86_64"
342elif check_define __sparc__ ; then
343 if check_define __arch64__ ; then
344 cpu="sparc64"
345 else
346 cpu="sparc"
347 fi
348elif check_define _ARCH_PPC ; then
349 if check_define _ARCH_PPC64 ; then
350 cpu="ppc64"
351 else
352 cpu="ppc"
353 fi
354elif check_define __mips__ ; then
355 cpu="mips"
356elif check_define __ia64__ ; then
357 cpu="ia64"
358elif check_define __s390__ ; then
359 if check_define __s390x__ ; then
360 cpu="s390x"
361 else
362 cpu="s390"
363 fi
364elif check_define __arm__ ; then
365 cpu="arm"
366elif check_define __hppa__ ; then
367 cpu="hppa"
368else
369 cpu=`uname -m`
370fi
371
372ARCH=
373# Normalise host CPU name and set ARCH.
374# Note that this case should only have supported host CPUs, not guests.
375case "$cpu" in
376 ia64|ppc|ppc64|s390|s390x|sparc64)
377 cpu="$cpu"
378 ;;
379 i386|i486|i586|i686|i86pc|BePC)
380 cpu="i386"
381 ;;
382 x86_64|amd64)
383 cpu="x86_64"
384 ;;
385 armv*b|armv*l|arm)
386 cpu="arm"
387 ;;
388 hppa|parisc|parisc64)
389 cpu="hppa"
390 ;;
391 mips*)
392 cpu="mips"
393 ;;
394 sparc|sun4[cdmuv])
395 cpu="sparc"
396 ;;
397 *)
398 # This will result in either an error or falling back to TCI later
399 ARCH=unknown
400 ;;
401esac
402if test -z "$ARCH"; then
403 ARCH="$cpu"
404fi
405
406# OS specific
407
408case $targetos in
409CYGWIN*)
410 mingw32="yes"
411 QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
412 audio_possible_drivers="winwave sdl"
413 audio_drv_list="winwave"
414;;
415MINGW32*)
416 mingw32="yes"
417 audio_possible_drivers="winwave dsound sdl fmod"
418 audio_drv_list="winwave"
419;;
420GNU/kFreeBSD)
421 bsd="yes"
422 audio_drv_list="oss"
423 audio_possible_drivers="oss sdl esd pa"
424;;
425FreeBSD)
426 bsd="yes"
427 make="${MAKE-gmake}"
428 audio_drv_list="oss"
429 audio_possible_drivers="oss sdl esd pa"
430 # needed for kinfo_getvmmap(3) in libutil.h
431 LIBS="-lutil $LIBS"
432;;
433DragonFly)
434 bsd="yes"
435 make="${MAKE-gmake}"
436 audio_drv_list="oss"
437 audio_possible_drivers="oss sdl esd pa"
438;;
439NetBSD)
440 bsd="yes"
441 make="${MAKE-gmake}"
442 audio_drv_list="oss"
443 audio_possible_drivers="oss sdl esd"
444 oss_lib="-lossaudio"
445;;
446OpenBSD)
447 bsd="yes"
448 make="${MAKE-gmake}"
449 audio_drv_list="oss"
450 audio_possible_drivers="oss sdl esd"
451 oss_lib="-lossaudio"
452;;
453Darwin)
454 bsd="yes"
455 darwin="yes"
456 if [ "$cpu" = "x86_64" ] ; then
457 QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
458 LDFLAGS="-arch x86_64 $LDFLAGS"
459 else
460 QEMU_CFLAGS="-mdynamic-no-pic $QEMU_CFLAGS"
461 fi
462 cocoa="yes"
463 audio_drv_list="coreaudio"
464 audio_possible_drivers="coreaudio sdl fmod"
465 LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
466 libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
467 # Disable attempts to use ObjectiveC features in os/object.h since they
468 # won't work when we're compiling with gcc as a C compiler.
469 QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
470;;
471SunOS)
472 solaris="yes"
473 make="${MAKE-gmake}"
474 install="${INSTALL-ginstall}"
475 ld="gld"
476 smbd="${SMBD-/usr/sfw/sbin/smbd}"
477 needs_libsunmath="no"
478 solarisrev=`uname -r | cut -f2 -d.`
479 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
480 if test "$solarisrev" -le 9 ; then
481 if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
482 needs_libsunmath="yes"
483 QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
484 LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
485 LIBS="-lsunmath $LIBS"
486 else
487 echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
488 echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
489 echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
490 echo "Studio 11 can be downloaded from www.sun.com."
491 exit 1
492 fi
493 fi
494 fi
495 if test -f /usr/include/sys/soundcard.h ; then
496 audio_drv_list="oss"
497 fi
498 audio_possible_drivers="oss sdl"
499# needed for CMSG_ macros in sys/socket.h
500 QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
501# needed for TIOCWIN* defines in termios.h
502 QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
503 QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
504 solarisnetlibs="-lsocket -lnsl -lresolv"
505 LIBS="$solarisnetlibs $LIBS"
506 libs_qga="$solarisnetlibs $libs_qga"
507;;
508AIX)
509 aix="yes"
510 make="${MAKE-gmake}"
511;;
512Haiku)
513 haiku="yes"
514 QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
515 LIBS="-lposix_error_mapper -lnetwork $LIBS"
516;;
517*)
518 audio_drv_list="oss"
519 audio_possible_drivers="oss alsa sdl esd pa"
520 linux="yes"
521 linux_user="yes"
522 usb="linux"
523 kvm="yes"
524 vhost_net="yes"
525 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
526 audio_possible_drivers="$audio_possible_drivers fmod"
527 fi
528;;
529esac
530
531if [ "$bsd" = "yes" ] ; then
532 if [ "$darwin" != "yes" ] ; then
533 usb="bsd"
534 bsd_user="yes"
535 fi
536fi
537
538: ${make=${MAKE-make}}
539: ${install=${INSTALL-install}}
540: ${python=${PYTHON-python}}
541: ${smbd=${SMBD-/usr/sbin/smbd}}
542
543# Default objcc to clang if available, otherwise use CC
544if has clang; then
545 objcc=clang
546else
547 objcc="$cc"
548fi
549
550if test "$mingw32" = "yes" ; then
551 EXESUF=".exe"
552 QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
553 # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
554 QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
555 LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
556cat > $TMPC << EOF
557int main(void) { return 0; }
558EOF
559 if compile_prog "" "-liberty" ; then
560 LIBS="-liberty $LIBS"
561 fi
562 prefix="c:/Program Files/QEMU"
563 mandir="\${prefix}"
564 datadir="\${prefix}"
565 qemu_docdir="\${prefix}"
566 bindir="\${prefix}"
567 sysconfdir="\${prefix}"
568 local_statedir="\${prefix}"
569 confsuffix=""
570 libs_qga="-lws2_32 -lwinmm -lpowrprof $libs_qga"
571fi
572
573werror=""
574
575for opt do
576 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
577 case "$opt" in
578 --help|-h) show_help=yes
579 ;;
580 --version|-V) exec cat $source_path/VERSION
581 ;;
582 --prefix=*) prefix="$optarg"
583 ;;
584 --interp-prefix=*) interp_prefix="$optarg"
585 ;;
586 --source-path=*)
587 ;;
588 --cross-prefix=*)
589 ;;
590 --cc=*)
591 ;;
592 --host-cc=*) host_cc="$optarg"
593 ;;
594 --objcc=*) objcc="$optarg"
595 ;;
596 --make=*) make="$optarg"
597 ;;
598 --install=*) install="$optarg"
599 ;;
600 --python=*) python="$optarg"
601 ;;
602 --smbd=*) smbd="$optarg"
603 ;;
604 --extra-cflags=*)
605 ;;
606 --extra-ldflags=*)
607 ;;
608 --enable-debug-info)
609 ;;
610 --disable-debug-info)
611 ;;
612 --cpu=*)
613 ;;
614 --target-list=*) target_list="$optarg"
615 ;;
616 --enable-trace-backend=*) trace_backend="$optarg"
617 ;;
618 --with-trace-file=*) trace_file="$optarg"
619 ;;
620 --enable-gprof) gprof="yes"
621 ;;
622 --static)
623 static="yes"
624 LDFLAGS="-static $LDFLAGS"
625 QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
626 ;;
627 --mandir=*) mandir="$optarg"
628 ;;
629 --bindir=*) bindir="$optarg"
630 ;;
631 --libdir=*) libdir="$optarg"
632 ;;
633 --libexecdir=*) libexecdir="$optarg"
634 ;;
635 --includedir=*) includedir="$optarg"
636 ;;
637 --datadir=*) datadir="$optarg"
638 ;;
639 --with-confsuffix=*) confsuffix="$optarg"
640 ;;
641 --docdir=*) qemu_docdir="$optarg"
642 ;;
643 --sysconfdir=*) sysconfdir="$optarg"
644 ;;
645 --localstatedir=*) local_statedir="$optarg"
646 ;;
647 --sbindir=*|--sharedstatedir=*|\
648 --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
649 --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
650 # These switches are silently ignored, for compatibility with
651 # autoconf-generated configure scripts. This allows QEMU's
652 # configure to be used by RPM and similar macros that set
653 # lots of directory switches by default.
654 ;;
655 --with-system-pixman) pixman="system"
656 ;;
657 --without-system-pixman) pixman="internal"
658 ;;
659 --without-pixman) pixman="none"
660 ;;
661 --disable-sdl) sdl="no"
662 ;;
663 --enable-sdl) sdl="yes"
664 ;;
665 --disable-virtfs) virtfs="no"
666 ;;
667 --enable-virtfs) virtfs="yes"
668 ;;
669 --disable-vnc) vnc="no"
670 ;;
671 --enable-vnc) vnc="yes"
672 ;;
673 --fmod-lib=*) fmod_lib="$optarg"
674 ;;
675 --fmod-inc=*) fmod_inc="$optarg"
676 ;;
677 --oss-lib=*) oss_lib="$optarg"
678 ;;
679 --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
680 ;;
681 --audio-drv-list=*) audio_drv_list="$optarg"
682 ;;
683 --block-drv-whitelist=*) block_drv_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
684 ;;
685 --enable-debug-tcg) debug_tcg="yes"
686 ;;
687 --disable-debug-tcg) debug_tcg="no"
688 ;;
689 --enable-debug)
690 # Enable debugging options that aren't excessively noisy
691 debug_tcg="yes"
692 debug="yes"
693 strip_opt="no"
694 ;;
695 --enable-sparse) sparse="yes"
696 ;;
697 --disable-sparse) sparse="no"
698 ;;
699 --disable-strip) strip_opt="no"
700 ;;
701 --disable-vnc-tls) vnc_tls="no"
702 ;;
703 --enable-vnc-tls) vnc_tls="yes"
704 ;;
705 --disable-vnc-sasl) vnc_sasl="no"
706 ;;
707 --enable-vnc-sasl) vnc_sasl="yes"
708 ;;
709 --disable-vnc-jpeg) vnc_jpeg="no"
710 ;;
711 --enable-vnc-jpeg) vnc_jpeg="yes"
712 ;;
713 --disable-vnc-png) vnc_png="no"
714 ;;
715 --enable-vnc-png) vnc_png="yes"
716 ;;
717 --disable-slirp) slirp="no"
718 ;;
719 --disable-uuid) uuid="no"
720 ;;
721 --enable-uuid) uuid="yes"
722 ;;
723 --disable-vde) vde="no"
724 ;;
725 --enable-vde) vde="yes"
726 ;;
727 --disable-xen) xen="no"
728 ;;
729 --enable-xen) xen="yes"
730 ;;
731 --disable-xen-pci-passthrough) xen_pci_passthrough="no"
732 ;;
733 --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
734 ;;
735 --disable-brlapi) brlapi="no"
736 ;;
737 --enable-brlapi) brlapi="yes"
738 ;;
739 --disable-bluez) bluez="no"
740 ;;
741 --enable-bluez) bluez="yes"
742 ;;
743 --disable-kvm) kvm="no"
744 ;;
745 --enable-kvm) kvm="yes"
746 ;;
747 --disable-tcg-interpreter) tcg_interpreter="no"
748 ;;
749 --enable-tcg-interpreter) tcg_interpreter="yes"
750 ;;
751 --disable-cap-ng) cap_ng="no"
752 ;;
753 --enable-cap-ng) cap_ng="yes"
754 ;;
755 --disable-spice) spice="no"
756 ;;
757 --enable-spice) spice="yes"
758 ;;
759 --disable-libiscsi) libiscsi="no"
760 ;;
761 --enable-libiscsi) libiscsi="yes"
762 ;;
763 --enable-profiler) profiler="yes"
764 ;;
765 --disable-cocoa) cocoa="no"
766 ;;
767 --enable-cocoa)
768 cocoa="yes" ;
769 sdl="no" ;
770 audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
771 ;;
772 --disable-system) softmmu="no"
773 ;;
774 --enable-system) softmmu="yes"
775 ;;
776 --disable-user)
777 linux_user="no" ;
778 bsd_user="no" ;
779 ;;
780 --enable-user) ;;
781 --disable-linux-user) linux_user="no"
782 ;;
783 --enable-linux-user) linux_user="yes"
784 ;;
785 --disable-bsd-user) bsd_user="no"
786 ;;
787 --enable-bsd-user) bsd_user="yes"
788 ;;
789 --enable-guest-base) guest_base="yes"
790 ;;
791 --disable-guest-base) guest_base="no"
792 ;;
793 --enable-pie) pie="yes"
794 ;;
795 --disable-pie) pie="no"
796 ;;
797 --enable-uname-release=*) uname_release="$optarg"
798 ;;
799 --enable-werror) werror="yes"
800 ;;
801 --disable-werror) werror="no"
802 ;;
803 --disable-curses) curses="no"
804 ;;
805 --enable-curses) curses="yes"
806 ;;
807 --disable-curl) curl="no"
808 ;;
809 --enable-curl) curl="yes"
810 ;;
811 --disable-fdt) fdt="no"
812 ;;
813 --enable-fdt) fdt="yes"
814 ;;
815 --disable-nptl) nptl="no"
816 ;;
817 --enable-nptl) nptl="yes"
818 ;;
819 --enable-mixemu) mixemu="yes"
820 ;;
821 --disable-linux-aio) linux_aio="no"
822 ;;
823 --enable-linux-aio) linux_aio="yes"
824 ;;
825 --disable-attr) attr="no"
826 ;;
827 --enable-attr) attr="yes"
828 ;;
829 --disable-blobs) blobs="no"
830 ;;
831 --with-pkgversion=*) pkgversion=" ($optarg)"
832 ;;
833 --with-coroutine=*) coroutine="$optarg"
834 ;;
835 --disable-docs) docs="no"
836 ;;
837 --enable-docs) docs="yes"
838 ;;
839 --disable-vhost-net) vhost_net="no"
840 ;;
841 --enable-vhost-net) vhost_net="yes"
842 ;;
843 --disable-opengl) opengl="no"
844 ;;
845 --enable-opengl) opengl="yes"
846 ;;
847 --disable-rbd) rbd="no"
848 ;;
849 --enable-rbd) rbd="yes"
850 ;;
851 --disable-xfsctl) xfs="no"
852 ;;
853 --enable-xfsctl) xfs="yes"
854 ;;
855 --disable-smartcard) smartcard="no"
856 ;;
857 --enable-smartcard) smartcard="yes"
858 ;;
859 --disable-smartcard-nss) smartcard_nss="no"
860 ;;
861 --enable-smartcard-nss) smartcard_nss="yes"
862 ;;
863 --disable-usb-redir) usb_redir="no"
864 ;;
865 --enable-usb-redir) usb_redir="yes"
866 ;;
867 --disable-zlib-test) zlib="no"
868 ;;
869 --enable-guest-agent) guest_agent="yes"
870 ;;
871 --disable-guest-agent) guest_agent="no"
872 ;;
873 --enable-tools) want_tools="yes"
874 ;;
875 --disable-tools) want_tools="no"
876 ;;
877 --enable-seccomp) seccomp="yes"
878 ;;
879 --disable-seccomp) seccomp="no"
880 ;;
881 --disable-glusterfs) glusterfs="no"
882 ;;
883 --enable-glusterfs) glusterfs="yes"
884 ;;
885 *) echo "ERROR: unknown option $opt"; show_help="yes"
886 ;;
887 esac
888done
889
890case "$cpu" in
891 sparc)
892 LDFLAGS="-m32 $LDFLAGS"
893 QEMU_CFLAGS="-m32 -mcpu=ultrasparc $QEMU_CFLAGS"
894 ;;
895 sparc64)
896 LDFLAGS="-m64 $LDFLAGS"
897 QEMU_CFLAGS="-m64 -mcpu=ultrasparc $QEMU_CFLAGS"
898 ;;
899 s390)
900 QEMU_CFLAGS="-m31 -march=z990 $QEMU_CFLAGS"
901 LDFLAGS="-m31 $LDFLAGS"
902 ;;
903 s390x)
904 QEMU_CFLAGS="-m64 -march=z990 $QEMU_CFLAGS"
905 LDFLAGS="-m64 $LDFLAGS"
906 ;;
907 i386)
908 QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
909 LDFLAGS="-m32 $LDFLAGS"
910 cc_i386='$(CC) -m32'
911 ;;
912 x86_64)
913 QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
914 LDFLAGS="-m64 $LDFLAGS"
915 cc_i386='$(CC) -m32'
916 ;;
917 # No special flags required for other host CPUs
918esac
919
920default_target_list=""
921
922# these targets are portable
923if [ "$softmmu" = "yes" ] ; then
924 default_target_list="\
925i386-softmmu \
926x86_64-softmmu \
927alpha-softmmu \
928arm-softmmu \
929cris-softmmu \
930lm32-softmmu \
931m68k-softmmu \
932microblaze-softmmu \
933microblazeel-softmmu \
934mips-softmmu \
935mipsel-softmmu \
936mips64-softmmu \
937mips64el-softmmu \
938or32-softmmu \
939ppc-softmmu \
940ppcemb-softmmu \
941ppc64-softmmu \
942sh4-softmmu \
943sh4eb-softmmu \
944sparc-softmmu \
945sparc64-softmmu \
946s390x-softmmu \
947xtensa-softmmu \
948xtensaeb-softmmu \
949unicore32-softmmu \
950"
951fi
952# the following are Linux specific
953if [ "$linux_user" = "yes" ] ; then
954 default_target_list="${default_target_list}\
955i386-linux-user \
956x86_64-linux-user \
957alpha-linux-user \
958arm-linux-user \
959armeb-linux-user \
960cris-linux-user \
961m68k-linux-user \
962microblaze-linux-user \
963microblazeel-linux-user \
964mips-linux-user \
965mipsel-linux-user \
966or32-linux-user \
967ppc-linux-user \
968ppc64-linux-user \
969ppc64abi32-linux-user \
970sh4-linux-user \
971sh4eb-linux-user \
972sparc-linux-user \
973sparc64-linux-user \
974sparc32plus-linux-user \
975unicore32-linux-user \
976s390x-linux-user \
977"
978fi
979# the following are BSD specific
980if [ "$bsd_user" = "yes" ] ; then
981 default_target_list="${default_target_list}\
982i386-bsd-user \
983x86_64-bsd-user \
984sparc-bsd-user \
985sparc64-bsd-user \
986"
987fi
988
989if test x"$show_help" = x"yes" ; then
990cat << EOF
991
992Usage: configure [options]
993Options: [defaults in brackets after descriptions]
994
995EOF
996echo "Standard options:"
997echo " --help print this message"
998echo " --prefix=PREFIX install in PREFIX [$prefix]"
999echo " --interp-prefix=PREFIX where to find shared libraries, etc."
1000echo " use %M for cpu name [$interp_prefix]"
1001echo " --target-list=LIST set target list (default: build everything)"
1002echo "Available targets: $default_target_list" | \
1003 fold -s -w 53 | sed -e 's/^/ /'
1004echo ""
1005echo "Advanced options (experts only):"
1006echo " --source-path=PATH path of source code [$source_path]"
1007echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
1008echo " --cc=CC use C compiler CC [$cc]"
1009echo " --host-cc=CC use C compiler CC [$host_cc] for code run at"
1010echo " build time"
1011echo " --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]"
1012echo " --extra-cflags=CFLAGS append extra C compiler flags QEMU_CFLAGS"
1013echo " --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS"
1014echo " --make=MAKE use specified make [$make]"
1015echo " --install=INSTALL use specified install [$install]"
1016echo " --python=PYTHON use specified python [$python]"
1017echo " --smbd=SMBD use specified smbd [$smbd]"
1018echo " --static enable static build [$static]"
1019echo " --mandir=PATH install man pages in PATH"
1020echo " --datadir=PATH install firmware in PATH$confsuffix"
1021echo " --docdir=PATH install documentation in PATH$confsuffix"
1022echo " --bindir=PATH install binaries in PATH"
1023echo " --sysconfdir=PATH install config in PATH$confsuffix"
1024echo " --localstatedir=PATH install local state in PATH"
1025echo " --with-confsuffix=SUFFIX suffix for QEMU data inside datadir and sysconfdir [$confsuffix]"
1026echo " --enable-debug-tcg enable TCG debugging"
1027echo " --disable-debug-tcg disable TCG debugging (default)"
1028echo " --enable-debug enable common debug build options"
1029echo " --enable-sparse enable sparse checker"
1030echo " --disable-sparse disable sparse checker (default)"
1031echo " --disable-strip disable stripping binaries"
1032echo " --disable-werror disable compilation abort on warning"
1033echo " --disable-sdl disable SDL"
1034echo " --enable-sdl enable SDL"
1035echo " --disable-virtfs disable VirtFS"
1036echo " --enable-virtfs enable VirtFS"
1037echo " --disable-vnc disable VNC"
1038echo " --enable-vnc enable VNC"
1039echo " --disable-cocoa disable Cocoa (Mac OS X only)"
1040echo " --enable-cocoa enable Cocoa (default on Mac OS X)"
1041echo " --audio-drv-list=LIST set audio drivers list:"
1042echo " Available drivers: $audio_possible_drivers"
1043echo " --audio-card-list=LIST set list of emulated audio cards [$audio_card_list]"
1044echo " Available cards: $audio_possible_cards"
1045echo " --block-drv-whitelist=L set block driver whitelist"
1046echo " (affects only QEMU, not qemu-img)"
1047echo " --enable-mixemu enable mixer emulation"
1048echo " --disable-xen disable xen backend driver support"
1049echo " --enable-xen enable xen backend driver support"
1050echo " --disable-xen-pci-passthrough"
1051echo " --enable-xen-pci-passthrough"
1052echo " --disable-brlapi disable BrlAPI"
1053echo " --enable-brlapi enable BrlAPI"
1054echo " --disable-vnc-tls disable TLS encryption for VNC server"
1055echo " --enable-vnc-tls enable TLS encryption for VNC server"
1056echo " --disable-vnc-sasl disable SASL encryption for VNC server"
1057echo " --enable-vnc-sasl enable SASL encryption for VNC server"
1058echo " --disable-vnc-jpeg disable JPEG lossy compression for VNC server"
1059echo " --enable-vnc-jpeg enable JPEG lossy compression for VNC server"
1060echo " --disable-vnc-png disable PNG compression for VNC server (default)"
1061echo " --enable-vnc-png enable PNG compression for VNC server"
1062echo " --disable-curses disable curses output"
1063echo " --enable-curses enable curses output"
1064echo " --disable-curl disable curl connectivity"
1065echo " --enable-curl enable curl connectivity"
1066echo " --disable-fdt disable fdt device tree"
1067echo " --enable-fdt enable fdt device tree"
1068echo " --disable-bluez disable bluez stack connectivity"
1069echo " --enable-bluez enable bluez stack connectivity"
1070echo " --disable-slirp disable SLIRP userspace network connectivity"
1071echo " --disable-kvm disable KVM acceleration support"
1072echo " --enable-kvm enable KVM acceleration support"
1073echo " --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)"
1074echo " --disable-nptl disable usermode NPTL support"
1075echo " --enable-nptl enable usermode NPTL support"
1076echo " --enable-system enable all system emulation targets"
1077echo " --disable-system disable all system emulation targets"
1078echo " --enable-user enable supported user emulation targets"
1079echo " --disable-user disable all user emulation targets"
1080echo " --enable-linux-user enable all linux usermode emulation targets"
1081echo " --disable-linux-user disable all linux usermode emulation targets"
1082echo " --enable-bsd-user enable all BSD usermode emulation targets"
1083echo " --disable-bsd-user disable all BSD usermode emulation targets"
1084echo " --enable-guest-base enable GUEST_BASE support for usermode"
1085echo " emulation targets"
1086echo " --disable-guest-base disable GUEST_BASE support"
1087echo " --enable-pie build Position Independent Executables"
1088echo " --disable-pie do not build Position Independent Executables"
1089echo " --fmod-lib path to FMOD library"
1090echo " --fmod-inc path to FMOD includes"
1091echo " --oss-lib path to OSS library"
1092echo " --enable-uname-release=R Return R for uname -r in usermode emulation"
1093echo " --cpu=CPU Build for host CPU [$cpu]"
1094echo " --sparc_cpu=V Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
1095echo " --disable-uuid disable uuid support"
1096echo " --enable-uuid enable uuid support"
1097echo " --disable-vde disable support for vde network"
1098echo " --enable-vde enable support for vde network"
1099echo " --disable-linux-aio disable Linux AIO support"
1100echo " --enable-linux-aio enable Linux AIO support"
1101echo " --disable-cap-ng disable libcap-ng support"
1102echo " --enable-cap-ng enable libcap-ng support"
1103echo " --disable-attr disables attr and xattr support"
1104echo " --enable-attr enable attr and xattr support"
1105echo " --disable-blobs disable installing provided firmware blobs"
1106echo " --enable-docs enable documentation build"
1107echo " --disable-docs disable documentation build"
1108echo " --disable-vhost-net disable vhost-net acceleration support"
1109echo " --enable-vhost-net enable vhost-net acceleration support"
1110echo " --enable-trace-backend=B Set trace backend"
1111echo " Available backends:" $($python "$source_path"/scripts/tracetool.py --list-backends)
1112echo " --with-trace-file=NAME Full PATH,NAME of file to store traces"
1113echo " Default:trace-<pid>"
1114echo " --disable-spice disable spice"
1115echo " --enable-spice enable spice"
1116echo " --enable-rbd enable building the rados block device (rbd)"
1117echo " --disable-libiscsi disable iscsi support"
1118echo " --enable-libiscsi enable iscsi support"
1119echo " --disable-smartcard disable smartcard support"
1120echo " --enable-smartcard enable smartcard support"
1121echo " --disable-smartcard-nss disable smartcard nss support"
1122echo " --enable-smartcard-nss enable smartcard nss support"
1123echo " --disable-usb-redir disable usb network redirection support"
1124echo " --enable-usb-redir enable usb network redirection support"
1125echo " --disable-guest-agent disable building of the QEMU Guest Agent"
1126echo " --enable-guest-agent enable building of the QEMU Guest Agent"
1127echo " --disable-seccomp disable seccomp support"
1128echo " --enable-seccomp enables seccomp support"
1129echo " --with-coroutine=BACKEND coroutine backend. Supported options:"
1130echo " gthread, ucontext, sigaltstack, windows"
1131echo " --enable-glusterfs enable GlusterFS backend"
1132echo " --disable-glusterfs disable GlusterFS backend"
1133echo ""
1134echo "NOTE: The object files are built at the place where configure is launched"
1135exit 1
1136fi
1137
1138# Now we have handled --enable-tcg-interpreter and know we're not just
1139# printing the help message, bail out if the host CPU isn't supported.
1140if test "$ARCH" = "unknown"; then
1141 if test "$tcg_interpreter" = "yes" ; then
1142 echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1143 ARCH=tci
1144 else
1145 echo "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1146 exit 1
1147 fi
1148fi
1149
1150# check that the C compiler works.
1151cat > $TMPC <<EOF
1152int main(void) { return 0; }
1153EOF
1154
1155if compile_object ; then
1156 : C compiler works ok
1157else
1158 echo "ERROR: \"$cc\" either does not exist or does not work"
1159 exit 1
1160fi
1161
1162# Consult white-list to determine whether to enable werror
1163# by default. Only enable by default for git builds
1164z_version=`cut -f3 -d. $source_path/VERSION`
1165
1166if test -z "$werror" ; then
1167 if test "$z_version" = "50" -a \
1168 "$linux" = "yes" ; then
1169 werror="yes"
1170 else
1171 werror="no"
1172 fi
1173fi
1174
1175gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
1176gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
1177gcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1178gcc_flags="-fstack-protector-all -Wendif-labels $gcc_flags"
1179gcc_flags="-Wno-initializer-overrides $gcc_flags"
1180# Note that we do not add -Werror to gcc_flags here, because that would
1181# enable it for all configure tests. If a configure test failed due
1182# to -Werror this would just silently disable some features,
1183# so it's too error prone.
1184cat > $TMPC << EOF
1185int main(void) { return 0; }
1186EOF
1187for flag in $gcc_flags; do
1188 # Use the positive sense of the flag when testing for -Wno-wombat
1189 # support (gcc will happily accept the -Wno- form of unknown
1190 # warning options).
1191 optflag="$(echo $flag | sed -e 's/^-Wno-/-W/')"
1192 if compile_prog "-Werror $optflag" "" ; then
1193 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1194 fi
1195done
1196
1197# Workaround for http://gcc.gnu.org/PR55489. Happens with -fPIE/-fPIC and
1198# large functions that use global variables. The bug is in all releases of
1199# GCC, but it became particularly acute in 4.6.x and 4.7.x. It is fixed in
1200# 4.7.3 and 4.8.0. We should be able to delete this at the end of 2013.
1201cat > $TMPC << EOF
1202#if __GNUC__ == 4 && (__GNUC_MINOR__ == 6 || (__GNUC_MINOR__ == 7 && __GNUC_PATCHLEVEL__ <= 2))
1203int main(void) { return 0; }
1204#else
1205#error No bug in this compiler.
1206#endif
1207EOF
1208if compile_prog "-Werror -fno-gcse" "" ; then
1209 TRANSLATE_OPT_CFLAGS=-fno-gcse
1210fi
1211
1212if test "$static" = "yes" ; then
1213 if test "$pie" = "yes" ; then
1214 echo "static and pie are mutually incompatible"
1215 exit 1
1216 else
1217 pie="no"
1218 fi
1219fi
1220
1221if test "$pie" = ""; then
1222 case "$cpu-$targetos" in
1223 i386-Linux|x86_64-Linux|i386-OpenBSD|x86_64-OpenBSD)
1224 ;;
1225 *)
1226 pie="no"
1227 ;;
1228 esac
1229fi
1230
1231if test "$pie" != "no" ; then
1232 cat > $TMPC << EOF
1233
1234#ifdef __linux__
1235# define THREAD __thread
1236#else
1237# define THREAD
1238#endif
1239
1240static THREAD int tls_var;
1241
1242int main(void) { return tls_var; }
1243
1244EOF
1245 if compile_prog "-fPIE -DPIE" "-pie"; then
1246 QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
1247 LDFLAGS="-pie $LDFLAGS"
1248 pie="yes"
1249 if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
1250 LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
1251 fi
1252 else
1253 if test "$pie" = "yes"; then
1254 echo "PIE not available due to missing toolchain support"
1255 exit 1
1256 else
1257 echo "Disabling PIE due to missing toolchain support"
1258 pie="no"
1259 fi
1260 fi
1261fi
1262
1263#
1264# Solaris specific configure tool chain decisions
1265#
1266if test "$solaris" = "yes" ; then
1267 if has $install; then
1268 :
1269 else
1270 echo "Solaris install program not found. Use --install=/usr/ucb/install or"
1271 echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
1272 echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1273 exit 1
1274 fi
1275 if test "`path_of $install`" = "/usr/sbin/install" ; then
1276 echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
1277 echo "try ginstall from the GNU fileutils available from www.blastwave.org"
1278 echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1279 exit 1
1280 fi
1281 if has ar; then
1282 :
1283 else
1284 echo "Error: No path includes ar"
1285 if test -f /usr/ccs/bin/ar ; then
1286 echo "Add /usr/ccs/bin to your path and rerun configure"
1287 fi
1288 exit 1
1289 fi
1290fi
1291
1292if ! has $python; then
1293 echo "Python not found. Use --python=/path/to/python"
1294 exit 1
1295fi
1296
1297# Note that if the Python conditional here evaluates True we will exit
1298# with status 1 which is a shell 'false' value.
1299if ! "$python" -c 'import sys; sys.exit(sys.version_info < (2,4) or sys.version_info >= (3,))'; then
1300 echo "Cannot use '$python', Python 2.4 or later is required."
1301 echo "Note that Python 3 or later is not yet supported."
1302 echo "Use --python=/path/to/python to specify a supported Python."
1303 exit 1
1304fi
1305
1306if test -z "${target_list+xxx}" ; then
1307 target_list="$default_target_list"
1308else
1309 target_list=`echo "$target_list" | sed -e 's/,/ /g'`
1310fi
1311# see if system emulation was really requested
1312case " $target_list " in
1313 *"-softmmu "*) softmmu=yes
1314 ;;
1315 *) softmmu=no
1316 ;;
1317esac
1318
1319feature_not_found() {
1320 feature=$1
1321
1322 echo "ERROR"
1323 echo "ERROR: User requested feature $feature"
1324 echo "ERROR: configure was not able to find it"
1325 echo "ERROR"
1326 exit 1;
1327}
1328
1329if test -z "$cross_prefix" ; then
1330
1331# ---
1332# big/little endian test
1333cat > $TMPC << EOF
1334#include <inttypes.h>
1335int main(void) {
1336 volatile uint32_t i=0x01234567;
1337 return (*((uint8_t*)(&i))) == 0x67;
1338}
1339EOF
1340
1341if compile_prog "" "" ; then
1342$TMPE && bigendian="yes"
1343else
1344echo big/little test failed
1345fi
1346
1347else
1348
1349# if cross compiling, cannot launch a program, so make a static guess
1350case "$cpu" in
1351 arm)
1352 # ARM can be either way; ask the compiler which one we are
1353 if check_define __ARMEB__; then
1354 bigendian=yes
1355 fi
1356 ;;
1357 hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
1358 bigendian=yes
1359 ;;
1360esac
1361
1362fi
1363
1364##########################################
1365# pkg-config probe
1366
1367if ! has "$pkg_config_exe"; then
1368 echo "Error: pkg-config binary '$pkg_config_exe' not found"
1369 exit 1
1370fi
1371
1372##########################################
1373# NPTL probe
1374
1375if test "$nptl" != "no" ; then
1376 cat > $TMPC <<EOF
1377#include <sched.h>
1378#include <linux/futex.h>
1379int main(void) {
1380#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1381#error bork
1382#endif
1383 return 0;
1384}
1385EOF
1386
1387 if compile_object ; then
1388 nptl=yes
1389 else
1390 if test "$nptl" = "yes" ; then
1391 feature_not_found "nptl"
1392 fi
1393 nptl=no
1394 fi
1395fi
1396
1397##########################################
1398# zlib check
1399
1400if test "$zlib" != "no" ; then
1401 cat > $TMPC << EOF
1402#include <zlib.h>
1403int main(void) { zlibVersion(); return 0; }
1404EOF
1405 if compile_prog "" "-lz" ; then
1406 :
1407 else
1408 echo
1409 echo "Error: zlib check failed"
1410 echo "Make sure to have the zlib libs and headers installed."
1411 echo
1412 exit 1
1413 fi
1414fi
1415
1416##########################################
1417# libseccomp check
1418
1419if test "$seccomp" != "no" ; then
1420 if $pkg_config --atleast-version=1.0.0 libseccomp --modversion >/dev/null 2>&1; then
1421 LIBS=`$pkg_config --libs libseccomp`
1422 seccomp="yes"
1423 else
1424 if test "$seccomp" = "yes"; then
1425 feature_not_found "libseccomp"
1426 fi
1427 seccomp="no"
1428 fi
1429fi
1430##########################################
1431# xen probe
1432
1433if test "$xen" != "no" ; then
1434 xen_libs="-lxenstore -lxenctrl -lxenguest"
1435
1436 # First we test whether Xen headers and libraries are available.
1437 # If no, we are done and there is no Xen support.
1438 # If yes, more tests are run to detect the Xen version.
1439
1440 # Xen (any)
1441 cat > $TMPC <<EOF
1442#include <xenctrl.h>
1443int main(void) {
1444 return 0;
1445}
1446EOF
1447 if ! compile_prog "" "$xen_libs" ; then
1448 # Xen not found
1449 if test "$xen" = "yes" ; then
1450 feature_not_found "xen"
1451 fi
1452 xen=no
1453
1454 # Xen unstable
1455 elif
1456 cat > $TMPC <<EOF &&
1457#include <xenctrl.h>
1458#include <xenstore.h>
1459#include <stdint.h>
1460#include <xen/hvm/hvm_info_table.h>
1461#if !defined(HVM_MAX_VCPUS)
1462# error HVM_MAX_VCPUS not defined
1463#endif
1464int main(void) {
1465 xc_interface *xc;
1466 xs_daemon_open();
1467 xc = xc_interface_open(0, 0, 0);
1468 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1469 xc_gnttab_open(NULL, 0);
1470 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1471 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
1472 return 0;
1473}
1474EOF
1475 compile_prog "" "$xen_libs"
1476 then
1477 xen_ctrl_version=420
1478 xen=yes
1479
1480 elif
1481 cat > $TMPC <<EOF &&
1482#include <xenctrl.h>
1483#include <xs.h>
1484#include <stdint.h>
1485#include <xen/hvm/hvm_info_table.h>
1486#if !defined(HVM_MAX_VCPUS)
1487# error HVM_MAX_VCPUS not defined
1488#endif
1489int main(void) {
1490 xs_daemon_open();
1491 xc_interface_open(0, 0, 0);
1492 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1493 xc_gnttab_open(NULL, 0);
1494 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1495 return 0;
1496}
1497EOF
1498 compile_prog "" "$xen_libs"
1499 then
1500 xen_ctrl_version=410
1501 xen=yes
1502
1503 # Xen 4.0.0
1504 elif
1505 cat > $TMPC <<EOF &&
1506#include <xenctrl.h>
1507#include <xs.h>
1508#include <stdint.h>
1509#include <xen/hvm/hvm_info_table.h>
1510#if !defined(HVM_MAX_VCPUS)
1511# error HVM_MAX_VCPUS not defined
1512#endif
1513int main(void) {
1514 struct xen_add_to_physmap xatp = {
1515 .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1516 };
1517 xs_daemon_open();
1518 xc_interface_open();
1519 xc_gnttab_open();
1520 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1521 xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1522 return 0;
1523}
1524EOF
1525 compile_prog "" "$xen_libs"
1526 then
1527 xen_ctrl_version=400
1528 xen=yes
1529
1530 # Xen 3.4.0
1531 elif
1532 cat > $TMPC <<EOF &&
1533#include <xenctrl.h>
1534#include <xs.h>
1535int main(void) {
1536 struct xen_add_to_physmap xatp = {
1537 .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1538 };
1539 xs_daemon_open();
1540 xc_interface_open();
1541 xc_gnttab_open();
1542 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1543 xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1544 return 0;
1545}
1546EOF
1547 compile_prog "" "$xen_libs"
1548 then
1549 xen_ctrl_version=340
1550 xen=yes
1551
1552 # Xen 3.3.0
1553 elif
1554 cat > $TMPC <<EOF &&
1555#include <xenctrl.h>
1556#include <xs.h>
1557int main(void) {
1558 xs_daemon_open();
1559 xc_interface_open();
1560 xc_gnttab_open();
1561 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1562 return 0;
1563}
1564EOF
1565 compile_prog "" "$xen_libs"
1566 then
1567 xen_ctrl_version=330
1568 xen=yes
1569
1570 # Xen version unsupported
1571 else
1572 if test "$xen" = "yes" ; then
1573 feature_not_found "xen (unsupported version)"
1574 fi
1575 xen=no
1576 fi
1577
1578 if test "$xen" = yes; then
1579 libs_softmmu="$xen_libs $libs_softmmu"
1580 fi
1581fi
1582
1583if test "$xen_pci_passthrough" != "no"; then
1584 if test "$xen" = "yes" && test "$linux" = "yes" &&
1585 test "$xen_ctrl_version" -ge 340; then
1586 xen_pci_passthrough=yes
1587 else
1588 if test "$xen_pci_passthrough" = "yes"; then
1589 echo "ERROR"
1590 echo "ERROR: User requested feature Xen PCI Passthrough"
1591 echo "ERROR: but this feature require /sys from Linux"
1592 if test "$xen_ctrl_version" -lt 340; then
1593 echo "ERROR: This feature does not work with Xen 3.3"
1594 fi
1595 echo "ERROR"
1596 exit 1;
1597 fi
1598 xen_pci_passthrough=no
1599 fi
1600fi
1601
1602##########################################
1603# libtool probe
1604
1605if ! has $libtool; then
1606 libtool=
1607fi
1608
1609##########################################
1610# Sparse probe
1611if test "$sparse" != "no" ; then
1612 if has cgcc; then
1613 sparse=yes
1614 else
1615 if test "$sparse" = "yes" ; then
1616 feature_not_found "sparse"
1617 fi
1618 sparse=no
1619 fi
1620fi
1621
1622##########################################
1623# SDL probe
1624
1625# Look for sdl configuration program (pkg-config or sdl-config). Try
1626# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
1627if test "`basename $sdl_config`" != sdl-config && ! has ${sdl_config}; then
1628 sdl_config=sdl-config
1629fi
1630
1631if $pkg_config sdl --modversion >/dev/null 2>&1; then
1632 sdlconfig="$pkg_config sdl"
1633 _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
1634elif has ${sdl_config}; then
1635 sdlconfig="$sdl_config"
1636 _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
1637else
1638 if test "$sdl" = "yes" ; then
1639 feature_not_found "sdl"
1640 fi
1641 sdl=no
1642fi
1643if test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
1644 echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
1645fi
1646
1647sdl_too_old=no
1648if test "$sdl" != "no" ; then
1649 cat > $TMPC << EOF
1650#include <SDL.h>
1651#undef main /* We don't want SDL to override our main() */
1652int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
1653EOF
1654 sdl_cflags=`$sdlconfig --cflags 2> /dev/null`
1655 if test "$static" = "yes" ; then
1656 sdl_libs=`$sdlconfig --static-libs 2>/dev/null`
1657 else
1658 sdl_libs=`$sdlconfig --libs 2> /dev/null`
1659 fi
1660 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1661 if test "$_sdlversion" -lt 121 ; then
1662 sdl_too_old=yes
1663 else
1664 if test "$cocoa" = "no" ; then
1665 sdl=yes
1666 fi
1667 fi
1668
1669 # static link with sdl ? (note: sdl.pc's --static --libs is broken)
1670 if test "$sdl" = "yes" -a "$static" = "yes" ; then
1671 if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
1672 sdl_libs="$sdl_libs `aalib-config --static-libs 2>/dev/null`"
1673 sdl_cflags="$sdl_cflags `aalib-config --cflags 2>/dev/null`"
1674 fi
1675 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1676 :
1677 else
1678 sdl=no
1679 fi
1680 fi # static link
1681 else # sdl not found
1682 if test "$sdl" = "yes" ; then
1683 feature_not_found "sdl"
1684 fi
1685 sdl=no
1686 fi # sdl compile test
1687fi
1688
1689if test "$sdl" = "yes" ; then
1690 cat > $TMPC <<EOF
1691#include <SDL.h>
1692#if defined(SDL_VIDEO_DRIVER_X11)
1693#include <X11/XKBlib.h>
1694#else
1695#error No x11 support
1696#endif
1697int main(void) { return 0; }
1698EOF
1699 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1700 sdl_libs="$sdl_libs -lX11"
1701 fi
1702 libs_softmmu="$sdl_libs $libs_softmmu"
1703fi
1704
1705##########################################
1706# VNC TLS detection
1707if test "$vnc" = "yes" -a "$vnc_tls" != "no" ; then
1708 cat > $TMPC <<EOF
1709#include <gnutls/gnutls.h>
1710int main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
1711EOF
1712 vnc_tls_cflags=`$pkg_config --cflags gnutls 2> /dev/null`
1713 vnc_tls_libs=`$pkg_config --libs gnutls 2> /dev/null`
1714 if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
1715 vnc_tls=yes
1716 libs_softmmu="$vnc_tls_libs $libs_softmmu"
1717 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_tls_cflags"
1718 else
1719 if test "$vnc_tls" = "yes" ; then
1720 feature_not_found "vnc-tls"
1721 fi
1722 vnc_tls=no
1723 fi
1724fi
1725
1726##########################################
1727# VNC SASL detection
1728if test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
1729 cat > $TMPC <<EOF
1730#include <sasl/sasl.h>
1731#include <stdio.h>
1732int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
1733EOF
1734 # Assuming Cyrus-SASL installed in /usr prefix
1735 vnc_sasl_cflags=""
1736 vnc_sasl_libs="-lsasl2"
1737 if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1738 vnc_sasl=yes
1739 libs_softmmu="$vnc_sasl_libs $libs_softmmu"
1740 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
1741 else
1742 if test "$vnc_sasl" = "yes" ; then
1743 feature_not_found "vnc-sasl"
1744 fi
1745 vnc_sasl=no
1746 fi
1747fi
1748
1749##########################################
1750# VNC JPEG detection
1751if test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
1752cat > $TMPC <<EOF
1753#include <stdio.h>
1754#include <jpeglib.h>
1755int main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
1756EOF
1757 vnc_jpeg_cflags=""
1758 vnc_jpeg_libs="-ljpeg"
1759 if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
1760 vnc_jpeg=yes
1761 libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
1762 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
1763 else
1764 if test "$vnc_jpeg" = "yes" ; then
1765 feature_not_found "vnc-jpeg"
1766 fi
1767 vnc_jpeg=no
1768 fi
1769fi
1770
1771##########################################
1772# VNC PNG detection
1773if test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
1774cat > $TMPC <<EOF
1775//#include <stdio.h>
1776#include <png.h>
1777#include <stddef.h>
1778int main(void) {
1779 png_structp png_ptr;
1780 png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
1781 return png_ptr != 0;
1782}
1783EOF
1784 if $pkg_config libpng --modversion >/dev/null 2>&1; then
1785 vnc_png_cflags=`$pkg_config libpng --cflags 2> /dev/null`
1786 vnc_png_libs=`$pkg_config libpng --libs 2> /dev/null`
1787 else
1788 vnc_png_cflags=""
1789 vnc_png_libs="-lpng"
1790 fi
1791 if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
1792 vnc_png=yes
1793 libs_softmmu="$vnc_png_libs $libs_softmmu"
1794 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
1795 else
1796 if test "$vnc_png" = "yes" ; then
1797 feature_not_found "vnc-png"
1798 fi
1799 vnc_png=no
1800 fi
1801fi
1802
1803##########################################
1804# fnmatch() probe, used for ACL routines
1805fnmatch="no"
1806cat > $TMPC << EOF
1807#include <fnmatch.h>
1808int main(void)
1809{
1810 fnmatch("foo", "foo", 0);
1811 return 0;
1812}
1813EOF
1814if compile_prog "" "" ; then
1815 fnmatch="yes"
1816fi
1817
1818##########################################
1819# uuid_generate() probe, used for vdi block driver
1820if test "$uuid" != "no" ; then
1821 uuid_libs="-luuid"
1822 cat > $TMPC << EOF
1823#include <uuid/uuid.h>
1824int main(void)
1825{
1826 uuid_t my_uuid;
1827 uuid_generate(my_uuid);
1828 return 0;
1829}
1830EOF
1831 if compile_prog "" "$uuid_libs" ; then
1832 uuid="yes"
1833 libs_softmmu="$uuid_libs $libs_softmmu"
1834 libs_tools="$uuid_libs $libs_tools"
1835 else
1836 if test "$uuid" = "yes" ; then
1837 feature_not_found "uuid"
1838 fi
1839 uuid=no
1840 fi
1841fi
1842
1843##########################################
1844# xfsctl() probe, used for raw-posix
1845if test "$xfs" != "no" ; then
1846 cat > $TMPC << EOF
1847#include <stddef.h> /* NULL */
1848#include <xfs/xfs.h>
1849int main(void)
1850{
1851 xfsctl(NULL, 0, 0, NULL);
1852 return 0;
1853}
1854EOF
1855 if compile_prog "" "" ; then
1856 xfs="yes"
1857 else
1858 if test "$xfs" = "yes" ; then
1859 feature_not_found "xfs"
1860 fi
1861 xfs=no
1862 fi
1863fi
1864
1865##########################################
1866# vde libraries probe
1867if test "$vde" != "no" ; then
1868 vde_libs="-lvdeplug"
1869 cat > $TMPC << EOF
1870#include <libvdeplug.h>
1871int main(void)
1872{
1873 struct vde_open_args a = {0, 0, 0};
1874 char s[] = "";
1875 vde_open(s, s, &a);
1876 return 0;
1877}
1878EOF
1879 if compile_prog "" "$vde_libs" ; then
1880 vde=yes
1881 libs_softmmu="$vde_libs $libs_softmmu"
1882 libs_tools="$vde_libs $libs_tools"
1883 else
1884 if test "$vde" = "yes" ; then
1885 feature_not_found "vde"
1886 fi
1887 vde=no
1888 fi
1889fi
1890
1891##########################################
1892# libcap-ng library probe
1893if test "$cap_ng" != "no" ; then
1894 cap_libs="-lcap-ng"
1895 cat > $TMPC << EOF
1896#include <cap-ng.h>
1897int main(void)
1898{
1899 capng_capability_to_name(CAPNG_EFFECTIVE);
1900 return 0;
1901}
1902EOF
1903 if compile_prog "" "$cap_libs" ; then
1904 cap_ng=yes
1905 libs_tools="$cap_libs $libs_tools"
1906 else
1907 if test "$cap_ng" = "yes" ; then
1908 feature_not_found "cap_ng"
1909 fi
1910 cap_ng=no
1911 fi
1912fi
1913
1914##########################################
1915# Sound support libraries probe
1916
1917audio_drv_probe()
1918{
1919 drv=$1
1920 hdr=$2
1921 lib=$3
1922 exp=$4
1923 cfl=$5
1924 cat > $TMPC << EOF
1925#include <$hdr>
1926int main(void) { $exp }
1927EOF
1928 if compile_prog "$cfl" "$lib" ; then
1929 :
1930 else
1931 echo
1932 echo "Error: $drv check failed"
1933 echo "Make sure to have the $drv libs and headers installed."
1934 echo
1935 exit 1
1936 fi
1937}
1938
1939audio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
1940for drv in $audio_drv_list; do
1941 case $drv in
1942 alsa)
1943 audio_drv_probe $drv alsa/asoundlib.h -lasound \
1944 "return snd_pcm_close((snd_pcm_t *)0);"
1945 libs_softmmu="-lasound $libs_softmmu"
1946 ;;
1947
1948 fmod)
1949 if test -z $fmod_lib || test -z $fmod_inc; then
1950 echo
1951 echo "Error: You must specify path to FMOD library and headers"
1952 echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
1953 echo
1954 exit 1
1955 fi
1956 audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
1957 libs_softmmu="$fmod_lib $libs_softmmu"
1958 ;;
1959
1960 esd)
1961 audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
1962 libs_softmmu="-lesd $libs_softmmu"
1963 audio_pt_int="yes"
1964 ;;
1965
1966 pa)
1967 audio_drv_probe $drv pulse/mainloop.h "-lpulse" \
1968 "pa_mainloop *m = 0; pa_mainloop_free (m); return 0;"
1969 libs_softmmu="-lpulse $libs_softmmu"
1970 audio_pt_int="yes"
1971 ;;
1972
1973 coreaudio)
1974 libs_softmmu="-framework CoreAudio $libs_softmmu"
1975 ;;
1976
1977 dsound)
1978 libs_softmmu="-lole32 -ldxguid $libs_softmmu"
1979 audio_win_int="yes"
1980 ;;
1981
1982 oss)
1983 libs_softmmu="$oss_lib $libs_softmmu"
1984 ;;
1985
1986 sdl|wav)
1987 # XXX: Probes for CoreAudio, DirectSound, SDL(?)
1988 ;;
1989
1990 winwave)
1991 libs_softmmu="-lwinmm $libs_softmmu"
1992 audio_win_int="yes"
1993 ;;
1994
1995 *)
1996 echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
1997 echo
1998 echo "Error: Unknown driver '$drv' selected"
1999 echo "Possible drivers are: $audio_possible_drivers"
2000 echo
2001 exit 1
2002 }
2003 ;;
2004 esac
2005done
2006
2007##########################################
2008# BrlAPI probe
2009
2010if test "$brlapi" != "no" ; then
2011 brlapi_libs="-lbrlapi"
2012 cat > $TMPC << EOF
2013#include <brlapi.h>
2014#include <stddef.h>
2015int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
2016EOF
2017 if compile_prog "" "$brlapi_libs" ; then
2018 brlapi=yes
2019 libs_softmmu="$brlapi_libs $libs_softmmu"
2020 else
2021 if test "$brlapi" = "yes" ; then
2022 feature_not_found "brlapi"
2023 fi
2024 brlapi=no
2025 fi
2026fi
2027
2028##########################################
2029# curses probe
2030if test "$mingw32" = "yes" ; then
2031 curses_list="-lpdcurses"
2032else
2033 curses_list="-lncurses -lcurses"
2034fi
2035
2036if test "$curses" != "no" ; then
2037 curses_found=no
2038 cat > $TMPC << EOF
2039#include <curses.h>
2040int main(void) {
2041 const char *s = curses_version();
2042 resize_term(0, 0);
2043 return s != 0;
2044}
2045EOF
2046 for curses_lib in $curses_list; do
2047 if compile_prog "" "$curses_lib" ; then
2048 curses_found=yes
2049 libs_softmmu="$curses_lib $libs_softmmu"
2050 break
2051 fi
2052 done
2053 if test "$curses_found" = "yes" ; then
2054 curses=yes
2055 else
2056 if test "$curses" = "yes" ; then
2057 feature_not_found "curses"
2058 fi
2059 curses=no
2060 fi
2061fi
2062
2063##########################################
2064# curl probe
2065
2066if $pkg_config libcurl --modversion >/dev/null 2>&1; then
2067 curlconfig="$pkg_config libcurl"
2068else
2069 curlconfig=curl-config
2070fi
2071
2072if test "$curl" != "no" ; then
2073 cat > $TMPC << EOF
2074#include <curl/curl.h>
2075int main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
2076EOF
2077 curl_cflags=`$curlconfig --cflags 2>/dev/null`
2078 curl_libs=`$curlconfig --libs 2>/dev/null`
2079 if compile_prog "$curl_cflags" "$curl_libs" ; then
2080 curl=yes
2081 libs_tools="$curl_libs $libs_tools"
2082 libs_softmmu="$curl_libs $libs_softmmu"
2083 else
2084 if test "$curl" = "yes" ; then
2085 feature_not_found "curl"
2086 fi
2087 curl=no
2088 fi
2089fi # test "$curl"
2090
2091##########################################
2092# bluez support probe
2093if test "$bluez" != "no" ; then
2094 cat > $TMPC << EOF
2095#include <bluetooth/bluetooth.h>
2096int main(void) { return bt_error(0); }
2097EOF
2098 bluez_cflags=`$pkg_config --cflags bluez 2> /dev/null`
2099 bluez_libs=`$pkg_config --libs bluez 2> /dev/null`
2100 if compile_prog "$bluez_cflags" "$bluez_libs" ; then
2101 bluez=yes
2102 libs_softmmu="$bluez_libs $libs_softmmu"
2103 else
2104 if test "$bluez" = "yes" ; then
2105 feature_not_found "bluez"
2106 fi
2107 bluez="no"
2108 fi
2109fi
2110
2111##########################################
2112# glib support probe
2113
2114if test "$mingw32" = yes; then
2115 # g_poll is required in order to integrate with the glib main loop.
2116 glib_req_ver=2.20
2117else
2118 glib_req_ver=2.12
2119fi
2120if $pkg_config --atleast-version=$glib_req_ver gthread-2.0 > /dev/null 2>&1
2121then
2122 glib_cflags=`$pkg_config --cflags gthread-2.0 2>/dev/null`
2123 glib_libs=`$pkg_config --libs gthread-2.0 2>/dev/null`
2124 LIBS="$glib_libs $LIBS"
2125 libs_qga="$glib_libs $libs_qga"
2126else
2127 echo "glib-$glib_req_ver required to compile QEMU"
2128 exit 1
2129fi
2130
2131##########################################
2132# pixman support probe
2133
2134if test "$pixman" = ""; then
2135 if test "$want_tools" = "no" -a "$softmmu" = "no"; then
2136 pixman="none"
2137 elif $pkg_config pixman-1 > /dev/null 2>&1; then
2138 pixman="system"
2139 else
2140 pixman="internal"
2141 fi
2142fi
2143if test "$pixman" = "none"; then
2144 if test "$want_tools" != "no" -o "$softmmu" != "no"; then
2145 echo "ERROR: pixman disabled but system emulation or tools build"
2146 echo " enabled. You can turn off pixman only if you also"
2147 echo " disable all system emulation targets and the tools"
2148 echo " build with '--disable-tools --disable-system'."
2149 exit 1
2150 fi
2151 pixman_cflags=
2152 pixman_libs=
2153elif test "$pixman" = "system"; then
2154 pixman_cflags=`$pkg_config --cflags pixman-1 2>/dev/null`
2155 pixman_libs=`$pkg_config --libs pixman-1 2>/dev/null`
2156else
2157 if test ! -d ${source_path}/pixman/pixman; then
2158 echo "ERROR: pixman not present. Your options:"
2159 echo " (1) Preferred: Install the pixman devel package (any recent"
2160 echo " distro should have packages as Xorg needs pixman too)."
2161 echo " (2) Fetch the pixman submodule, using:"
2162 echo " git submodule update --init pixman"
2163 exit 1
2164 fi
2165 mkdir -p pixman/pixman
2166 pixman_cflags="-I\$(SRC_PATH)/pixman/pixman -I\$(BUILD_DIR)/pixman/pixman"
2167 pixman_libs="-L\$(BUILD_DIR)/pixman/pixman/.libs -lpixman-1"
2168fi
2169
2170##########################################
2171# libcap probe
2172
2173if test "$cap" != "no" ; then
2174 cat > $TMPC <<EOF
2175#include <stdio.h>
2176#include <sys/capability.h>
2177int main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
2178EOF
2179 if compile_prog "" "-lcap" ; then
2180 cap=yes
2181 else
2182 cap=no
2183 fi
2184fi
2185
2186##########################################
2187# pthread probe
2188PTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
2189
2190pthread=no
2191cat > $TMPC << EOF
2192#include <pthread.h>
2193static void *f(void *p) { return NULL; }
2194int main(void) {
2195 pthread_t thread;
2196 pthread_create(&thread, 0, f, 0);
2197 return 0;
2198}
2199EOF
2200if compile_prog "" "" ; then
2201 pthread=yes
2202else
2203 for pthread_lib in $PTHREADLIBS_LIST; do
2204 if compile_prog "" "$pthread_lib" ; then
2205 pthread=yes
2206 found=no
2207 for lib_entry in $LIBS; do
2208 if test "$lib_entry" = "$pthread_lib"; then
2209 found=yes
2210 break
2211 fi
2212 done
2213 if test "$found" = "no"; then
2214 LIBS="$pthread_lib $LIBS"
2215 fi
2216 break
2217 fi
2218 done
2219fi
2220
2221if test "$mingw32" != yes -a "$pthread" = no; then
2222 echo
2223 echo "Error: pthread check failed"
2224 echo "Make sure to have the pthread libs and headers installed."
2225 echo
2226 exit 1
2227fi
2228
2229##########################################
2230# rbd probe
2231if test "$rbd" != "no" ; then
2232 cat > $TMPC <<EOF
2233#include <stdio.h>
2234#include <rbd/librbd.h>
2235int main(void) {
2236 rados_t cluster;
2237 rados_create(&cluster, NULL);
2238 return 0;
2239}
2240EOF
2241 rbd_libs="-lrbd -lrados"
2242 if compile_prog "" "$rbd_libs" ; then
2243 rbd=yes
2244 libs_tools="$rbd_libs $libs_tools"
2245 libs_softmmu="$rbd_libs $libs_softmmu"
2246 else
2247 if test "$rbd" = "yes" ; then
2248 feature_not_found "rados block device"
2249 fi
2250 rbd=no
2251 fi
2252fi
2253
2254##########################################
2255# linux-aio probe
2256
2257if test "$linux_aio" != "no" ; then
2258 cat > $TMPC <<EOF
2259#include <libaio.h>
2260#include <sys/eventfd.h>
2261#include <stddef.h>
2262int main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
2263EOF
2264 if compile_prog "" "-laio" ; then
2265 linux_aio=yes
2266 libs_softmmu="$libs_softmmu -laio"
2267 libs_tools="$libs_tools -laio"
2268 else
2269 if test "$linux_aio" = "yes" ; then
2270 feature_not_found "linux AIO"
2271 fi
2272 linux_aio=no
2273 fi
2274fi
2275
2276##########################################
2277# attr probe
2278
2279if test "$attr" != "no" ; then
2280 cat > $TMPC <<EOF
2281#include <stdio.h>
2282#include <sys/types.h>
2283#ifdef CONFIG_LIBATTR
2284#include <attr/xattr.h>
2285#else
2286#include <sys/xattr.h>
2287#endif
2288int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
2289EOF
2290 if compile_prog "" "" ; then
2291 attr=yes
2292 # Older distros have <attr/xattr.h>, and need -lattr:
2293 elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
2294 attr=yes
2295 LIBS="-lattr $LIBS"
2296 libattr=yes
2297 else
2298 if test "$attr" = "yes" ; then
2299 feature_not_found "ATTR"
2300 fi
2301 attr=no
2302 fi
2303fi
2304
2305##########################################
2306# iovec probe
2307cat > $TMPC <<EOF
2308#include <sys/types.h>
2309#include <sys/uio.h>
2310#include <unistd.h>
2311int main(void) { return sizeof(struct iovec); }
2312EOF
2313iovec=no
2314if compile_prog "" "" ; then
2315 iovec=yes
2316fi
2317
2318##########################################
2319# preadv probe
2320cat > $TMPC <<EOF
2321#include <sys/types.h>
2322#include <sys/uio.h>
2323#include <unistd.h>
2324int main(void) { return preadv(0, 0, 0, 0); }
2325EOF
2326preadv=no
2327if compile_prog "" "" ; then
2328 preadv=yes
2329fi
2330
2331##########################################
2332# fdt probe
2333if test "$fdt" != "no" ; then
2334 fdt_libs="-lfdt"
2335 cat > $TMPC << EOF
2336int main(void) { return 0; }
2337EOF
2338 if compile_prog "" "$fdt_libs" ; then
2339 fdt=yes
2340 else
2341 if test "$fdt" = "yes" ; then
2342 feature_not_found "fdt"
2343 fi
2344 fdt_libs=
2345 fdt=no
2346 fi
2347fi
2348
2349##########################################
2350# opengl probe, used by milkymist-tmu2
2351if test "$opengl" != "no" ; then
2352 opengl_libs="-lGL"
2353 cat > $TMPC << EOF
2354#include <X11/Xlib.h>
2355#include <GL/gl.h>
2356#include <GL/glx.h>
2357int main(void) { return GL_VERSION != 0; }
2358EOF
2359 if compile_prog "" "-lGL" ; then
2360 opengl=yes
2361 else
2362 if test "$opengl" = "yes" ; then
2363 feature_not_found "opengl"
2364 fi
2365 opengl_libs=
2366 opengl=no
2367 fi
2368fi
2369
2370##########################################
2371# glusterfs probe
2372if test "$glusterfs" != "no" ; then
2373 cat > $TMPC <<EOF
2374#include <glusterfs/api/glfs.h>
2375int main(void) {
2376 (void) glfs_new("volume");
2377 return 0;
2378}
2379EOF
2380 glusterfs_libs="-lgfapi -lgfrpc -lgfxdr"
2381 if compile_prog "" "$glusterfs_libs" ; then
2382 glusterfs=yes
2383 libs_tools="$glusterfs_libs $libs_tools"
2384 libs_softmmu="$glusterfs_libs $libs_softmmu"
2385 else
2386 if test "$glusterfs" = "yes" ; then
2387 feature_not_found "GlusterFS backend support"
2388 fi
2389 glusterfs=no
2390 fi
2391fi
2392
2393#
2394# Check for xxxat() functions when we are building linux-user
2395# emulator. This is done because older glibc versions don't
2396# have syscall stubs for these implemented.
2397#
2398atfile=no
2399cat > $TMPC << EOF
2400#define _ATFILE_SOURCE
2401#include <sys/types.h>
2402#include <fcntl.h>
2403#include <unistd.h>
2404
2405int
2406main(void)
2407{
2408 /* try to unlink nonexisting file */
2409 return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
2410}
2411EOF
2412if compile_prog "" "" ; then
2413 atfile=yes
2414fi
2415
2416# Check for inotify functions when we are building linux-user
2417# emulator. This is done because older glibc versions don't
2418# have syscall stubs for these implemented. In that case we
2419# don't provide them even if kernel supports them.
2420#
2421inotify=no
2422cat > $TMPC << EOF
2423#include <sys/inotify.h>
2424
2425int
2426main(void)
2427{
2428 /* try to start inotify */
2429 return inotify_init();
2430}
2431EOF
2432if compile_prog "" "" ; then
2433 inotify=yes
2434fi
2435
2436inotify1=no
2437cat > $TMPC << EOF
2438#include <sys/inotify.h>
2439
2440int
2441main(void)
2442{
2443 /* try to start inotify */
2444 return inotify_init1(0);
2445}
2446EOF
2447if compile_prog "" "" ; then
2448 inotify1=yes
2449fi
2450
2451# check if utimensat and futimens are supported
2452utimens=no
2453cat > $TMPC << EOF
2454#define _ATFILE_SOURCE
2455#include <stddef.h>
2456#include <fcntl.h>
2457#include <sys/stat.h>
2458
2459int main(void)
2460{
2461 utimensat(AT_FDCWD, "foo", NULL, 0);
2462 futimens(0, NULL);
2463 return 0;
2464}
2465EOF
2466if compile_prog "" "" ; then
2467 utimens=yes
2468fi
2469
2470# check if pipe2 is there
2471pipe2=no
2472cat > $TMPC << EOF
2473#include <unistd.h>
2474#include <fcntl.h>
2475
2476int main(void)
2477{
2478 int pipefd[2];
2479 return pipe2(pipefd, O_CLOEXEC);
2480}
2481EOF
2482if compile_prog "" "" ; then
2483 pipe2=yes
2484fi
2485
2486# check if accept4 is there
2487accept4=no
2488cat > $TMPC << EOF
2489#include <sys/socket.h>
2490#include <stddef.h>
2491
2492int main(void)
2493{
2494 accept4(0, NULL, NULL, SOCK_CLOEXEC);
2495 return 0;
2496}
2497EOF
2498if compile_prog "" "" ; then
2499 accept4=yes
2500fi
2501
2502# check if tee/splice is there. vmsplice was added same time.
2503splice=no
2504cat > $TMPC << EOF
2505#include <unistd.h>
2506#include <fcntl.h>
2507#include <limits.h>
2508
2509int main(void)
2510{
2511 int len, fd = 0;
2512 len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
2513 splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
2514 return 0;
2515}
2516EOF
2517if compile_prog "" "" ; then
2518 splice=yes
2519fi
2520
2521##########################################
2522# signalfd probe
2523signalfd="no"
2524cat > $TMPC << EOF
2525#include <unistd.h>
2526#include <sys/syscall.h>
2527#include <signal.h>
2528int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
2529EOF
2530
2531if compile_prog "" "" ; then
2532 signalfd=yes
2533fi
2534
2535# check if eventfd is supported
2536eventfd=no
2537cat > $TMPC << EOF
2538#include <sys/eventfd.h>
2539
2540int main(void)
2541{
2542 return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
2543}
2544EOF
2545if compile_prog "" "" ; then
2546 eventfd=yes
2547fi
2548
2549# check for fallocate
2550fallocate=no
2551cat > $TMPC << EOF
2552#include <fcntl.h>
2553
2554int main(void)
2555{
2556 fallocate(0, 0, 0, 0);
2557 return 0;
2558}
2559EOF
2560if compile_prog "" "" ; then
2561 fallocate=yes
2562fi
2563
2564# check for sync_file_range
2565sync_file_range=no
2566cat > $TMPC << EOF
2567#include <fcntl.h>
2568
2569int main(void)
2570{
2571 sync_file_range(0, 0, 0, 0);
2572 return 0;
2573}
2574EOF
2575if compile_prog "" "" ; then
2576 sync_file_range=yes
2577fi
2578
2579# check for linux/fiemap.h and FS_IOC_FIEMAP
2580fiemap=no
2581cat > $TMPC << EOF
2582#include <sys/ioctl.h>
2583#include <linux/fs.h>
2584#include <linux/fiemap.h>
2585
2586int main(void)
2587{
2588 ioctl(0, FS_IOC_FIEMAP, 0);
2589 return 0;
2590}
2591EOF
2592if compile_prog "" "" ; then
2593 fiemap=yes
2594fi
2595
2596# check for dup3
2597dup3=no
2598cat > $TMPC << EOF
2599#include <unistd.h>
2600
2601int main(void)
2602{
2603 dup3(0, 0, 0);
2604 return 0;
2605}
2606EOF
2607if compile_prog "" "" ; then
2608 dup3=yes
2609fi
2610
2611# check for epoll support
2612epoll=no
2613cat > $TMPC << EOF
2614#include <sys/epoll.h>
2615
2616int main(void)
2617{
2618 epoll_create(0);
2619 return 0;
2620}
2621EOF
2622if compile_prog "" "" ; then
2623 epoll=yes
2624fi
2625
2626# epoll_create1 and epoll_pwait are later additions
2627# so we must check separately for their presence
2628epoll_create1=no
2629cat > $TMPC << EOF
2630#include <sys/epoll.h>
2631
2632int main(void)
2633{
2634 /* Note that we use epoll_create1 as a value, not as
2635 * a function being called. This is necessary so that on
2636 * old SPARC glibc versions where the function was present in
2637 * the library but not declared in the header file we will
2638 * fail the configure check. (Otherwise we will get a compiler
2639 * warning but not an error, and will proceed to fail the
2640 * qemu compile where we compile with -Werror.)
2641 */
2642 return (int)(uintptr_t)&epoll_create1;
2643}
2644EOF
2645if compile_prog "" "" ; then
2646 epoll_create1=yes
2647fi
2648
2649epoll_pwait=no
2650cat > $TMPC << EOF
2651#include <sys/epoll.h>
2652
2653int main(void)
2654{
2655 epoll_pwait(0, 0, 0, 0, 0);
2656 return 0;
2657}
2658EOF
2659if compile_prog "" "" ; then
2660 epoll_pwait=yes
2661fi
2662
2663# Check if tools are available to build documentation.
2664if test "$docs" != "no" ; then
2665 if has makeinfo && has pod2man; then
2666 docs=yes
2667 else
2668 if test "$docs" = "yes" ; then
2669 feature_not_found "docs"
2670 fi
2671 docs=no
2672 fi
2673fi
2674
2675# Search for bswap_32 function
2676byteswap_h=no
2677cat > $TMPC << EOF
2678#include <byteswap.h>
2679int main(void) { return bswap_32(0); }
2680EOF
2681if compile_prog "" "" ; then
2682 byteswap_h=yes
2683fi
2684
2685# Search for bswap_32 function
2686bswap_h=no
2687cat > $TMPC << EOF
2688#include <sys/endian.h>
2689#include <sys/types.h>
2690#include <machine/bswap.h>
2691int main(void) { return bswap32(0); }
2692EOF
2693if compile_prog "" "" ; then
2694 bswap_h=yes
2695fi
2696
2697##########################################
2698# Do we have libiscsi
2699# We check for iscsi_unmap_sync() to make sure we have a
2700# recent enough version of libiscsi.
2701if test "$libiscsi" != "no" ; then
2702 cat > $TMPC << EOF
2703#include <stdio.h>
2704#include <iscsi/iscsi.h>
2705int main(void) { iscsi_unmap_sync(NULL,0,0,0,NULL,0); return 0; }
2706EOF
2707 if compile_prog "" "-liscsi" ; then
2708 libiscsi="yes"
2709 LIBS="$LIBS -liscsi"
2710 else
2711 if test "$libiscsi" = "yes" ; then
2712 feature_not_found "libiscsi"
2713 fi
2714 libiscsi="no"
2715 fi
2716fi
2717
2718
2719##########################################
2720# Do we need libm
2721cat > $TMPC << EOF
2722#include <math.h>
2723int main(void) { return isnan(sin(0.0)); }
2724EOF
2725if compile_prog "" "" ; then
2726 :
2727elif compile_prog "" "-lm" ; then
2728 LIBS="-lm $LIBS"
2729 libs_qga="-lm $libs_qga"
2730else
2731 echo
2732 echo "Error: libm check failed"
2733 echo
2734 exit 1
2735fi
2736
2737##########################################
2738# Do we need librt
2739# uClibc provides 2 versions of clock_gettime(), one with realtime
2740# support and one without. This means that the clock_gettime() don't
2741# need -lrt. We still need it for timer_create() so we check for this
2742# function in addition.
2743cat > $TMPC <<EOF
2744#include <signal.h>
2745#include <time.h>
2746int main(void) {
2747 timer_create(CLOCK_REALTIME, NULL, NULL);
2748 return clock_gettime(CLOCK_REALTIME, NULL);
2749}
2750EOF
2751
2752if compile_prog "" "" ; then
2753 :
2754# we need pthread for static linking. use previous pthread test result
2755elif compile_prog "" "-lrt $pthread_lib" ; then
2756 LIBS="-lrt $LIBS"
2757 libs_qga="-lrt $libs_qga"
2758fi
2759
2760if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
2761 "$aix" != "yes" -a "$haiku" != "yes" ; then
2762 libs_softmmu="-lutil $libs_softmmu"
2763fi
2764
2765##########################################
2766# spice probe
2767if test "$spice" != "no" ; then
2768 cat > $TMPC << EOF
2769#include <spice.h>
2770int main(void) { spice_server_new(); return 0; }
2771EOF
2772 spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
2773 spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
2774 if $pkg_config --atleast-version=0.12.0 spice-server >/dev/null 2>&1 && \
2775 $pkg_config --atleast-version=0.12.2 spice-protocol > /dev/null 2>&1 && \
2776 compile_prog "$spice_cflags" "$spice_libs" ; then
2777 spice="yes"
2778 libs_softmmu="$libs_softmmu $spice_libs"
2779 QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
2780 spice_protocol_version=$($pkg_config --modversion spice-protocol)
2781 spice_server_version=$($pkg_config --modversion spice-server)
2782 else
2783 if test "$spice" = "yes" ; then
2784 feature_not_found "spice"
2785 fi
2786 spice="no"
2787 fi
2788fi
2789
2790# check for libcacard for smartcard support
2791if test "$smartcard" != "no" ; then
2792 smartcard="yes"
2793 smartcard_cflags=""
2794 # TODO - what's the minimal nss version we support?
2795 if test "$smartcard_nss" != "no"; then
2796 cat > $TMPC << EOF
2797#include <pk11pub.h>
2798int main(void) { PK11_FreeSlot(0); return 0; }
2799EOF
2800 smartcard_includes="-I\$(SRC_PATH)/libcacard"
2801 libcacard_libs="$($pkg_config --libs nss 2>/dev/null) $glib_libs"
2802 libcacard_cflags="$($pkg_config --cflags nss 2>/dev/null) $glib_cflags"
2803 test_cflags="$libcacard_cflags"
2804 # The header files in nss < 3.13.3 have a bug which causes them to
2805 # emit a warning. If we're going to compile QEMU with -Werror, then
2806 # test that the headers don't have this bug. Otherwise we would pass
2807 # the configure test but fail to compile QEMU later.
2808 if test "$werror" = "yes"; then
2809 test_cflags="-Werror $test_cflags"
2810 fi
2811 if $pkg_config --atleast-version=3.12.8 nss >/dev/null 2>&1 && \
2812 compile_prog "$test_cflags" "$libcacard_libs"; then
2813 smartcard_nss="yes"
2814 QEMU_CFLAGS="$QEMU_CFLAGS $libcacard_cflags"
2815 QEMU_INCLUDES="$QEMU_INCLUDES $smartcard_includes"
2816 libs_softmmu="$libcacard_libs $libs_softmmu"
2817 else
2818 if test "$smartcard_nss" = "yes"; then
2819 feature_not_found "nss"
2820 fi
2821 smartcard_nss="no"
2822 fi
2823 fi
2824fi
2825if test "$smartcard" = "no" ; then
2826 smartcard_nss="no"
2827fi
2828
2829# check for usbredirparser for usb network redirection support
2830if test "$usb_redir" != "no" ; then
2831 if $pkg_config --atleast-version=0.5.3 libusbredirparser-0.5 >/dev/null 2>&1 ; then
2832 usb_redir="yes"
2833 usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5 2>/dev/null)
2834 usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5 2>/dev/null)
2835 QEMU_CFLAGS="$QEMU_CFLAGS $usb_redir_cflags"
2836 libs_softmmu="$libs_softmmu $usb_redir_libs"
2837 else
2838 if test "$usb_redir" = "yes"; then
2839 feature_not_found "usb-redir"
2840 fi
2841 usb_redir="no"
2842 fi
2843fi
2844
2845##########################################
2846
2847##########################################
2848# check if we have fdatasync
2849
2850fdatasync=no
2851cat > $TMPC << EOF
2852#include <unistd.h>
2853int main(void) {
2854#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
2855return fdatasync(0);
2856#else
2857#error Not supported
2858#endif
2859}
2860EOF
2861if compile_prog "" "" ; then
2862 fdatasync=yes
2863fi
2864
2865##########################################
2866# check if we have madvise
2867
2868madvise=no
2869cat > $TMPC << EOF
2870#include <sys/types.h>
2871#include <sys/mman.h>
2872#include <stddef.h>
2873int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
2874EOF
2875if compile_prog "" "" ; then
2876 madvise=yes
2877fi
2878
2879##########################################
2880# check if we have posix_madvise
2881
2882posix_madvise=no
2883cat > $TMPC << EOF
2884#include <sys/mman.h>
2885#include <stddef.h>
2886int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
2887EOF
2888if compile_prog "" "" ; then
2889 posix_madvise=yes
2890fi
2891
2892##########################################
2893# check if we have usable SIGEV_THREAD_ID
2894
2895sigev_thread_id=no
2896cat > $TMPC << EOF
2897#include <signal.h>
2898int main(void) {
2899 struct sigevent ev;
2900 ev.sigev_notify = SIGEV_THREAD_ID;
2901 ev._sigev_un._tid = 0;
2902 asm volatile("" : : "g"(&ev));
2903 return 0;
2904}
2905EOF
2906if compile_prog "" "" ; then
2907 sigev_thread_id=yes
2908fi
2909
2910##########################################
2911# check if trace backend exists
2912
2913$python "$source_path/scripts/tracetool.py" "--backend=$trace_backend" --check-backend > /dev/null 2> /dev/null
2914if test "$?" -ne 0 ; then
2915 echo
2916 echo "Error: invalid trace backend"
2917 echo "Please choose a supported trace backend."
2918 echo
2919 exit 1
2920fi
2921
2922##########################################
2923# For 'ust' backend, test if ust headers are present
2924if test "$trace_backend" = "ust"; then
2925 cat > $TMPC << EOF
2926#include <ust/tracepoint.h>
2927#include <ust/marker.h>
2928int main(void) { return 0; }
2929EOF
2930 if compile_prog "" "" ; then
2931 LIBS="-lust -lurcu-bp $LIBS"
2932 libs_qga="-lust -lurcu-bp $libs_qga"
2933 else
2934 echo
2935 echo "Error: Trace backend 'ust' missing libust header files"
2936 echo
2937 exit 1
2938 fi
2939fi
2940
2941##########################################
2942# For 'dtrace' backend, test if 'dtrace' command is present
2943if test "$trace_backend" = "dtrace"; then
2944 if ! has 'dtrace' ; then
2945 echo
2946 echo "Error: dtrace command is not found in PATH $PATH"
2947 echo
2948 exit 1
2949 fi
2950 trace_backend_stap="no"
2951 if has 'stap' ; then
2952 trace_backend_stap="yes"
2953 fi
2954fi
2955
2956##########################################
2957# __sync_fetch_and_and requires at least -march=i486. Many toolchains
2958# use i686 as default anyway, but for those that don't, an explicit
2959# specification is necessary
2960if test "$vhost_net" = "yes" && test "$cpu" = "i386"; then
2961 cat > $TMPC << EOF
2962static int sfaa(int *ptr)
2963{
2964 return __sync_fetch_and_and(ptr, 0);
2965}
2966
2967int main(void)
2968{
2969 int val = 42;
2970 sfaa(&val);
2971 return val;
2972}
2973EOF
2974 if ! compile_prog "" "" ; then
2975 QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
2976 fi
2977fi
2978
2979##########################################
2980# check and set a backend for coroutine
2981
2982# default is ucontext, but always fallback to gthread
2983# windows autodetected by make
2984if test "$coroutine" = "" -o "$coroutine" = "ucontext"; then
2985 if test "$darwin" != "yes"; then
2986 cat > $TMPC << EOF
2987#include <ucontext.h>
2988#ifdef __stub_makecontext
2989#error Ignoring glibc stub makecontext which will always fail
2990#endif
2991int main(void) { makecontext(0, 0, 0); return 0; }
2992EOF
2993 if compile_prog "" "" ; then
2994 coroutine_backend=ucontext
2995 else
2996 coroutine_backend=gthread
2997 fi
2998 fi
2999elif test "$coroutine" = "gthread" ; then
3000 coroutine_backend=gthread
3001elif test "$coroutine" = "windows" ; then
3002 coroutine_backend=windows
3003elif test "$coroutine" = "sigaltstack" ; then
3004 coroutine_backend=sigaltstack
3005else
3006 echo
3007 echo "Error: unknown coroutine backend $coroutine"
3008 echo
3009 exit 1
3010fi
3011
3012##########################################
3013# check if we have open_by_handle_at
3014
3015open_by_handle_at=no
3016cat > $TMPC << EOF
3017#include <fcntl.h>
3018#if !defined(AT_EMPTY_PATH)
3019# error missing definition
3020#else
3021int main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
3022#endif
3023EOF
3024if compile_prog "" "" ; then
3025 open_by_handle_at=yes
3026fi
3027
3028########################################
3029# check if we have linux/magic.h
3030
3031linux_magic_h=no
3032cat > $TMPC << EOF
3033#include <linux/magic.h>
3034int main(void) {
3035 return 0;
3036}
3037EOF
3038if compile_prog "" "" ; then
3039 linux_magic_h=yes
3040fi
3041
3042########################################
3043# check whether we can disable the -Wunused-but-set-variable
3044# option with a pragma (this is needed to silence a warning in
3045# some versions of the valgrind VALGRIND_STACK_DEREGISTER macro.)
3046# This test has to be compiled with -Werror as otherwise an
3047# unknown pragma is only a warning.
3048pragma_disable_unused_but_set=no
3049cat > $TMPC << EOF
3050#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
3051int main(void) {
3052 return 0;
3053}
3054EOF
3055if compile_prog "-Werror" "" ; then
3056 pragma_disable_unused_but_set=yes
3057fi
3058
3059########################################
3060# check if we have valgrind/valgrind.h and valgrind/memcheck.h
3061
3062valgrind_h=no
3063cat > $TMPC << EOF
3064#include <valgrind/valgrind.h>
3065#include <valgrind/memcheck.h>
3066int main(void) {
3067 return 0;
3068}
3069EOF
3070if compile_prog "" "" ; then
3071 valgrind_h=yes
3072fi
3073
3074########################################
3075# check if environ is declared
3076
3077has_environ=no
3078cat > $TMPC << EOF
3079#include <unistd.h>
3080int main(void) {
3081 environ = 0;
3082 return 0;
3083}
3084EOF
3085if compile_prog "" "" ; then
3086 has_environ=yes
3087fi
3088
3089##########################################
3090# End of CC checks
3091# After here, no more $cc or $ld runs
3092
3093if test "$debug" = "no" ; then
3094 CFLAGS="-O2 -D_FORTIFY_SOURCE=2 $CFLAGS"
3095fi
3096
3097# Disable zero malloc errors for official releases unless explicitly told to
3098# enable/disable
3099if test -z "$zero_malloc" ; then
3100 if test "$z_version" = "50" ; then
3101 zero_malloc="no"
3102 else
3103 zero_malloc="yes"
3104 fi
3105fi
3106
3107# Now we've finished running tests it's OK to add -Werror to the compiler flags
3108if test "$werror" = "yes"; then
3109 QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
3110fi
3111
3112if test "$solaris" = "no" ; then
3113 if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
3114 LDFLAGS="-Wl,--warn-common $LDFLAGS"
3115 fi
3116fi
3117
3118# test if pod2man has --utf8 option
3119if pod2man --help | grep -q utf8; then
3120 POD2MAN="pod2man --utf8"
3121else
3122 POD2MAN="pod2man"
3123fi
3124
3125# Use ASLR, no-SEH and DEP if available
3126if test "$mingw32" = "yes" ; then
3127 for flag in --dynamicbase --no-seh --nxcompat; do
3128 if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
3129 LDFLAGS="-Wl,$flag $LDFLAGS"
3130 fi
3131 done
3132fi
3133
3134qemu_confdir=$sysconfdir$confsuffix
3135qemu_datadir=$datadir$confsuffix
3136
3137tools=""
3138if test "$want_tools" = "yes" ; then
3139 tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
3140 if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
3141 tools="qemu-nbd\$(EXESUF) $tools"
3142 fi
3143fi
3144if test "$softmmu" = yes ; then
3145 if test "$virtfs" != no ; then
3146 if test "$cap" = yes && test "$linux" = yes && test "$attr" = yes ; then
3147 virtfs=yes
3148 tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
3149 else
3150 if test "$virtfs" = yes; then
3151 echo "VirtFS is supported only on Linux and requires libcap-devel and libattr-devel"
3152 exit 1
3153 fi
3154 virtfs=no
3155 fi
3156 fi
3157 if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
3158 if [ "$guest_agent" = "yes" ]; then
3159 tools="qemu-ga\$(EXESUF) $tools"
3160 fi
3161 fi
3162 if test "$smartcard_nss" = "yes" ; then
3163 tools="vscclient\$(EXESUF) $tools"
3164 fi
3165fi
3166
3167# Mac OS X ships with a broken assembler
3168roms=
3169if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
3170 "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
3171 "$softmmu" = yes ; then
3172 roms="optionrom"
3173fi
3174if test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
3175 roms="$roms spapr-rtas"
3176fi
3177
3178# add pixman flags after all config tests are done
3179QEMU_CFLAGS="$QEMU_CFLAGS $pixman_cflags"
3180libs_softmmu="$libs_softmmu $pixman_libs"
3181
3182echo "Install prefix $prefix"
3183echo "BIOS directory `eval echo $qemu_datadir`"
3184echo "binary directory `eval echo $bindir`"
3185echo "library directory `eval echo $libdir`"
3186echo "libexec directory `eval echo $libexecdir`"
3187echo "include directory `eval echo $includedir`"
3188echo "config directory `eval echo $sysconfdir`"
3189echo "local state directory `eval echo $local_statedir`"
3190if test "$mingw32" = "no" ; then
3191echo "Manual directory `eval echo $mandir`"
3192echo "ELF interp prefix $interp_prefix"
3193fi
3194echo "Source path $source_path"
3195echo "C compiler $cc"
3196echo "Host C compiler $host_cc"
3197echo "Objective-C compiler $objcc"
3198echo "CFLAGS $CFLAGS"
3199echo "QEMU_CFLAGS $QEMU_CFLAGS"
3200echo "LDFLAGS $LDFLAGS"
3201echo "make $make"
3202echo "install $install"
3203echo "python $python"
3204if test "$slirp" = "yes" ; then
3205 echo "smbd $smbd"
3206fi
3207echo "host CPU $cpu"
3208echo "host big endian $bigendian"
3209echo "target list $target_list"
3210echo "tcg debug enabled $debug_tcg"
3211echo "gprof enabled $gprof"
3212echo "sparse enabled $sparse"
3213echo "strip binaries $strip_opt"
3214echo "profiler $profiler"
3215echo "static build $static"
3216echo "-Werror enabled $werror"
3217if test "$darwin" = "yes" ; then
3218 echo "Cocoa support $cocoa"
3219fi
3220echo "pixman $pixman"
3221echo "SDL support $sdl"
3222echo "curses support $curses"
3223echo "curl support $curl"
3224echo "mingw32 support $mingw32"
3225echo "Audio drivers $audio_drv_list"
3226echo "Extra audio cards $audio_card_list"
3227echo "Block whitelist $block_drv_whitelist"
3228echo "Mixer emulation $mixemu"
3229echo "VirtFS support $virtfs"
3230echo "VNC support $vnc"
3231if test "$vnc" = "yes" ; then
3232 echo "VNC TLS support $vnc_tls"
3233 echo "VNC SASL support $vnc_sasl"
3234 echo "VNC JPEG support $vnc_jpeg"
3235 echo "VNC PNG support $vnc_png"
3236fi
3237if test -n "$sparc_cpu"; then
3238 echo "Target Sparc Arch $sparc_cpu"
3239fi
3240echo "xen support $xen"
3241echo "brlapi support $brlapi"
3242echo "bluez support $bluez"
3243echo "Documentation $docs"
3244[ ! -z "$uname_release" ] && \
3245echo "uname -r $uname_release"
3246echo "NPTL support $nptl"
3247echo "GUEST_BASE $guest_base"
3248echo "PIE $pie"
3249echo "vde support $vde"
3250echo "Linux AIO support $linux_aio"
3251echo "ATTR/XATTR support $attr"
3252echo "Install blobs $blobs"
3253echo "KVM support $kvm"
3254echo "TCG interpreter $tcg_interpreter"
3255echo "fdt support $fdt"
3256echo "preadv support $preadv"
3257echo "fdatasync $fdatasync"
3258echo "madvise $madvise"
3259echo "posix_madvise $posix_madvise"
3260echo "sigev_thread_id $sigev_thread_id"
3261echo "uuid support $uuid"
3262echo "libcap-ng support $cap_ng"
3263echo "vhost-net support $vhost_net"
3264echo "Trace backend $trace_backend"
3265echo "Trace output file $trace_file-<pid>"
3266echo "spice support $spice ($spice_protocol_version/$spice_server_version)"
3267echo "rbd support $rbd"
3268echo "xfsctl support $xfs"
3269echo "nss used $smartcard_nss"
3270echo "usb net redir $usb_redir"
3271echo "OpenGL support $opengl"
3272echo "libiscsi support $libiscsi"
3273echo "build guest agent $guest_agent"
3274echo "seccomp support $seccomp"
3275echo "coroutine backend $coroutine_backend"
3276echo "GlusterFS support $glusterfs"
3277
3278if test "$sdl_too_old" = "yes"; then
3279echo "-> Your SDL version is too old - please upgrade to have SDL support"
3280fi
3281
3282config_host_mak="config-host.mak"
3283config_host_ld="config-host.ld"
3284
3285echo "# Automatically generated by configure - do not modify" > $config_host_mak
3286printf "# Configured with:" >> $config_host_mak
3287printf " '%s'" "$0" "$@" >> $config_host_mak
3288echo >> $config_host_mak
3289
3290echo all: >> $config_host_mak
3291echo "prefix=$prefix" >> $config_host_mak
3292echo "bindir=$bindir" >> $config_host_mak
3293echo "libdir=$libdir" >> $config_host_mak
3294echo "libexecdir=$libexecdir" >> $config_host_mak
3295echo "includedir=$includedir" >> $config_host_mak
3296echo "mandir=$mandir" >> $config_host_mak
3297echo "sysconfdir=$sysconfdir" >> $config_host_mak
3298echo "qemu_confdir=$qemu_confdir" >> $config_host_mak
3299echo "qemu_datadir=$qemu_datadir" >> $config_host_mak
3300echo "qemu_docdir=$qemu_docdir" >> $config_host_mak
3301echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
3302echo "qemu_helperdir=$libexecdir" >> $config_host_mak
3303
3304echo "ARCH=$ARCH" >> $config_host_mak
3305if test "$debug_tcg" = "yes" ; then
3306 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
3307fi
3308if test "$debug" = "yes" ; then
3309 echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
3310fi
3311if test "$strip_opt" = "yes" ; then
3312 echo "STRIP=${strip}" >> $config_host_mak
3313fi
3314if test "$bigendian" = "yes" ; then
3315 echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
3316fi
3317if test "$mingw32" = "yes" ; then
3318 echo "CONFIG_WIN32=y" >> $config_host_mak
3319 rc_version=`cat $source_path/VERSION`
3320 version_major=${rc_version%%.*}
3321 rc_version=${rc_version#*.}
3322 version_minor=${rc_version%%.*}
3323 rc_version=${rc_version#*.}
3324 version_subminor=${rc_version%%.*}
3325 version_micro=0
3326 echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
3327 echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
3328else
3329 echo "CONFIG_POSIX=y" >> $config_host_mak
3330fi
3331
3332if test "$linux" = "yes" ; then
3333 echo "CONFIG_LINUX=y" >> $config_host_mak
3334fi
3335
3336if test "$darwin" = "yes" ; then
3337 echo "CONFIG_DARWIN=y" >> $config_host_mak
3338fi
3339
3340if test "$aix" = "yes" ; then
3341 echo "CONFIG_AIX=y" >> $config_host_mak
3342fi
3343
3344if test "$solaris" = "yes" ; then
3345 echo "CONFIG_SOLARIS=y" >> $config_host_mak
3346 echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
3347 if test "$needs_libsunmath" = "yes" ; then
3348 echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
3349 fi
3350fi
3351if test "$haiku" = "yes" ; then
3352 echo "CONFIG_HAIKU=y" >> $config_host_mak
3353fi
3354if test "$static" = "yes" ; then
3355 echo "CONFIG_STATIC=y" >> $config_host_mak
3356fi
3357if test "$profiler" = "yes" ; then
3358 echo "CONFIG_PROFILER=y" >> $config_host_mak
3359fi
3360if test "$slirp" = "yes" ; then
3361 echo "CONFIG_SLIRP=y" >> $config_host_mak
3362 echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
3363fi
3364if test "$vde" = "yes" ; then
3365 echo "CONFIG_VDE=y" >> $config_host_mak
3366fi
3367if test "$cap_ng" = "yes" ; then
3368 echo "CONFIG_LIBCAP=y" >> $config_host_mak
3369fi
3370for card in $audio_card_list; do
3371 def=CONFIG_`echo $card | LC_ALL=C tr '[a-z]' '[A-Z]'`
3372 echo "$def=y" >> $config_host_mak
3373done
3374echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
3375for drv in $audio_drv_list; do
3376 def=CONFIG_`echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]'`
3377 echo "$def=y" >> $config_host_mak
3378 if test "$drv" = "fmod"; then
3379 echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
3380 fi
3381done
3382if test "$audio_pt_int" = "yes" ; then
3383 echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
3384fi
3385if test "$audio_win_int" = "yes" ; then
3386 echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
3387fi
3388echo "CONFIG_BDRV_WHITELIST=$block_drv_whitelist" >> $config_host_mak
3389if test "$mixemu" = "yes" ; then
3390 echo "CONFIG_MIXEMU=y" >> $config_host_mak
3391fi
3392if test "$vnc" = "yes" ; then
3393 echo "CONFIG_VNC=y" >> $config_host_mak
3394fi
3395if test "$vnc_tls" = "yes" ; then
3396 echo "CONFIG_VNC_TLS=y" >> $config_host_mak
3397fi
3398if test "$vnc_sasl" = "yes" ; then
3399 echo "CONFIG_VNC_SASL=y" >> $config_host_mak
3400fi
3401if test "$vnc_jpeg" = "yes" ; then
3402 echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
3403fi
3404if test "$vnc_png" = "yes" ; then
3405 echo "CONFIG_VNC_PNG=y" >> $config_host_mak
3406fi
3407if test "$fnmatch" = "yes" ; then
3408 echo "CONFIG_FNMATCH=y" >> $config_host_mak
3409fi
3410if test "$uuid" = "yes" ; then
3411 echo "CONFIG_UUID=y" >> $config_host_mak
3412fi
3413if test "$xfs" = "yes" ; then
3414 echo "CONFIG_XFS=y" >> $config_host_mak
3415fi
3416qemu_version=`head $source_path/VERSION`
3417echo "VERSION=$qemu_version" >>$config_host_mak
3418echo "PKGVERSION=$pkgversion" >>$config_host_mak
3419echo "SRC_PATH=$source_path" >> $config_host_mak
3420echo "TARGET_DIRS=$target_list" >> $config_host_mak
3421if [ "$docs" = "yes" ] ; then
3422 echo "BUILD_DOCS=yes" >> $config_host_mak
3423fi
3424if test "$sdl" = "yes" ; then
3425 echo "CONFIG_SDL=y" >> $config_host_mak
3426 echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
3427fi
3428if test "$cocoa" = "yes" ; then
3429 echo "CONFIG_COCOA=y" >> $config_host_mak
3430fi
3431if test "$curses" = "yes" ; then
3432 echo "CONFIG_CURSES=y" >> $config_host_mak
3433fi
3434if test "$atfile" = "yes" ; then
3435 echo "CONFIG_ATFILE=y" >> $config_host_mak
3436fi
3437if test "$utimens" = "yes" ; then
3438 echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
3439fi
3440if test "$pipe2" = "yes" ; then
3441 echo "CONFIG_PIPE2=y" >> $config_host_mak
3442fi
3443if test "$accept4" = "yes" ; then
3444 echo "CONFIG_ACCEPT4=y" >> $config_host_mak
3445fi
3446if test "$splice" = "yes" ; then
3447 echo "CONFIG_SPLICE=y" >> $config_host_mak
3448fi
3449if test "$eventfd" = "yes" ; then
3450 echo "CONFIG_EVENTFD=y" >> $config_host_mak
3451fi
3452if test "$fallocate" = "yes" ; then
3453 echo "CONFIG_FALLOCATE=y" >> $config_host_mak
3454fi
3455if test "$sync_file_range" = "yes" ; then
3456 echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
3457fi
3458if test "$fiemap" = "yes" ; then
3459 echo "CONFIG_FIEMAP=y" >> $config_host_mak
3460fi
3461if test "$dup3" = "yes" ; then
3462 echo "CONFIG_DUP3=y" >> $config_host_mak
3463fi
3464if test "$epoll" = "yes" ; then
3465 echo "CONFIG_EPOLL=y" >> $config_host_mak
3466fi
3467if test "$epoll_create1" = "yes" ; then
3468 echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
3469fi
3470if test "$epoll_pwait" = "yes" ; then
3471 echo "CONFIG_EPOLL_PWAIT=y" >> $config_host_mak
3472fi
3473if test "$inotify" = "yes" ; then
3474 echo "CONFIG_INOTIFY=y" >> $config_host_mak
3475fi
3476if test "$inotify1" = "yes" ; then
3477 echo "CONFIG_INOTIFY1=y" >> $config_host_mak
3478fi
3479if test "$byteswap_h" = "yes" ; then
3480 echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
3481fi
3482if test "$bswap_h" = "yes" ; then
3483 echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
3484fi
3485if test "$curl" = "yes" ; then
3486 echo "CONFIG_CURL=y" >> $config_host_mak
3487 echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
3488fi
3489if test "$brlapi" = "yes" ; then
3490 echo "CONFIG_BRLAPI=y" >> $config_host_mak
3491fi
3492if test "$bluez" = "yes" ; then
3493 echo "CONFIG_BLUEZ=y" >> $config_host_mak
3494 echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
3495fi
3496echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
3497if test "$xen" = "yes" ; then
3498 echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
3499 echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
3500fi
3501if test "$linux_aio" = "yes" ; then
3502 echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
3503fi
3504if test "$attr" = "yes" ; then
3505 echo "CONFIG_ATTR=y" >> $config_host_mak
3506fi
3507if test "$libattr" = "yes" ; then
3508 echo "CONFIG_LIBATTR=y" >> $config_host_mak
3509fi
3510if test "$virtfs" = "yes" ; then
3511 echo "CONFIG_VIRTFS=y" >> $config_host_mak
3512fi
3513if test "$blobs" = "yes" ; then
3514 echo "INSTALL_BLOBS=yes" >> $config_host_mak
3515fi
3516if test "$iovec" = "yes" ; then
3517 echo "CONFIG_IOVEC=y" >> $config_host_mak
3518fi
3519if test "$preadv" = "yes" ; then
3520 echo "CONFIG_PREADV=y" >> $config_host_mak
3521fi
3522if test "$fdt" = "yes" ; then
3523 echo "CONFIG_FDT=y" >> $config_host_mak
3524fi
3525if test "$signalfd" = "yes" ; then
3526 echo "CONFIG_SIGNALFD=y" >> $config_host_mak
3527fi
3528if test "$tcg_interpreter" = "yes" ; then
3529 echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
3530fi
3531if test "$fdatasync" = "yes" ; then
3532 echo "CONFIG_FDATASYNC=y" >> $config_host_mak
3533fi
3534if test "$madvise" = "yes" ; then
3535 echo "CONFIG_MADVISE=y" >> $config_host_mak
3536fi
3537if test "$posix_madvise" = "yes" ; then
3538 echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
3539fi
3540if test "$sigev_thread_id" = "yes" ; then
3541 echo "CONFIG_SIGEV_THREAD_ID=y" >> $config_host_mak
3542fi
3543
3544if test "$spice" = "yes" ; then
3545 echo "CONFIG_SPICE=y" >> $config_host_mak
3546fi
3547
3548if test "$smartcard" = "yes" ; then
3549 echo "CONFIG_SMARTCARD=y" >> $config_host_mak
3550fi
3551
3552if test "$smartcard_nss" = "yes" ; then
3553 echo "CONFIG_SMARTCARD_NSS=y" >> $config_host_mak
3554 echo "libcacard_libs=$libcacard_libs" >> $config_host_mak
3555 echo "libcacard_cflags=$libcacard_cflags" >> $config_host_mak
3556fi
3557
3558if test "$usb_redir" = "yes" ; then
3559 echo "CONFIG_USB_REDIR=y" >> $config_host_mak
3560fi
3561
3562if test "$opengl" = "yes" ; then
3563 echo "CONFIG_OPENGL=y" >> $config_host_mak
3564fi
3565
3566if test "$libiscsi" = "yes" ; then
3567 echo "CONFIG_LIBISCSI=y" >> $config_host_mak
3568fi
3569
3570if test "$seccomp" = "yes"; then
3571 echo "CONFIG_SECCOMP=y" >> $config_host_mak
3572fi
3573
3574# XXX: suppress that
3575if [ "$bsd" = "yes" ] ; then
3576 echo "CONFIG_BSD=y" >> $config_host_mak
3577fi
3578
3579echo "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
3580
3581if test "$zero_malloc" = "yes" ; then
3582 echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
3583fi
3584if test "$rbd" = "yes" ; then
3585 echo "CONFIG_RBD=y" >> $config_host_mak
3586fi
3587
3588if test "$coroutine_backend" = "ucontext" ; then
3589 echo "CONFIG_UCONTEXT_COROUTINE=y" >> $config_host_mak
3590elif test "$coroutine_backend" = "sigaltstack" ; then
3591 echo "CONFIG_SIGALTSTACK_COROUTINE=y" >> $config_host_mak
3592fi
3593
3594if test "$open_by_handle_at" = "yes" ; then
3595 echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
3596fi
3597
3598if test "$linux_magic_h" = "yes" ; then
3599 echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
3600fi
3601
3602if test "$pragma_disable_unused_but_set" = "yes" ; then
3603 echo "CONFIG_PRAGMA_DISABLE_UNUSED_BUT_SET=y" >> $config_host_mak
3604fi
3605
3606if test "$valgrind_h" = "yes" ; then
3607 echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
3608fi
3609
3610if test "$has_environ" = "yes" ; then
3611 echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
3612fi
3613
3614if test "$glusterfs" = "yes" ; then
3615 echo "CONFIG_GLUSTERFS=y" >> $config_host_mak
3616fi
3617
3618# USB host support
3619case "$usb" in
3620linux)
3621 echo "HOST_USB=linux" >> $config_host_mak
3622;;
3623bsd)
3624 echo "HOST_USB=bsd" >> $config_host_mak
3625;;
3626*)
3627 echo "HOST_USB=stub" >> $config_host_mak
3628;;
3629esac
3630
3631# use default implementation for tracing backend-specific routines
3632trace_default=yes
3633echo "TRACE_BACKEND=$trace_backend" >> $config_host_mak
3634if test "$trace_backend" = "nop"; then
3635 echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
3636fi
3637if test "$trace_backend" = "simple"; then
3638 echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
3639 trace_default=no
3640 # Set the appropriate trace file.
3641 trace_file="\"$trace_file-\" FMT_pid"
3642fi
3643if test "$trace_backend" = "stderr"; then
3644 echo "CONFIG_TRACE_STDERR=y" >> $config_host_mak
3645 trace_default=no
3646fi
3647if test "$trace_backend" = "ust"; then
3648 echo "CONFIG_TRACE_UST=y" >> $config_host_mak
3649fi
3650if test "$trace_backend" = "dtrace"; then
3651 echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
3652 if test "$trace_backend_stap" = "yes" ; then
3653 echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
3654 fi
3655fi
3656echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
3657if test "$trace_default" = "yes"; then
3658 echo "CONFIG_TRACE_DEFAULT=y" >> $config_host_mak
3659fi
3660
3661echo "TOOLS=$tools" >> $config_host_mak
3662echo "ROMS=$roms" >> $config_host_mak
3663echo "MAKE=$make" >> $config_host_mak
3664echo "INSTALL=$install" >> $config_host_mak
3665echo "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
3666echo "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
3667echo "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
3668echo "PYTHON=$python" >> $config_host_mak
3669echo "CC=$cc" >> $config_host_mak
3670echo "CC_I386=$cc_i386" >> $config_host_mak
3671echo "HOST_CC=$host_cc" >> $config_host_mak
3672echo "OBJCC=$objcc" >> $config_host_mak
3673echo "AR=$ar" >> $config_host_mak
3674echo "OBJCOPY=$objcopy" >> $config_host_mak
3675echo "LD=$ld" >> $config_host_mak
3676echo "WINDRES=$windres" >> $config_host_mak
3677echo "LIBTOOL=$libtool" >> $config_host_mak
3678echo "CFLAGS=$CFLAGS" >> $config_host_mak
3679echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
3680echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
3681if test "$sparse" = "yes" ; then
3682 echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_host_mak
3683 echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_host_mak
3684 echo "QEMU_CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
3685fi
3686if test "$cross_prefix" != ""; then
3687 echo "AUTOCONF_HOST := --host=${cross_prefix%-}" >> $config_host_mak
3688else
3689 echo "AUTOCONF_HOST := " >> $config_host_mak
3690fi
3691echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
3692echo "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak
3693echo "ARLIBS_END=$arlibs_end" >> $config_host_mak
3694echo "LIBS+=$LIBS" >> $config_host_mak
3695echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
3696echo "EXESUF=$EXESUF" >> $config_host_mak
3697echo "LIBS_QGA+=$libs_qga" >> $config_host_mak
3698echo "POD2MAN=$POD2MAN" >> $config_host_mak
3699echo "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
3700
3701# generate list of library paths for linker script
3702
3703$ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
3704
3705if test -f ${config_host_ld}~ ; then
3706 if cmp -s $config_host_ld ${config_host_ld}~ ; then
3707 mv ${config_host_ld}~ $config_host_ld
3708 else
3709 rm ${config_host_ld}~
3710 fi
3711fi
3712
3713# use included Linux headers
3714if test "$linux" = "yes" ; then
3715 mkdir -p linux-headers
3716 case "$cpu" in
3717 i386|x86_64)
3718 linux_arch=x86
3719 ;;
3720 ppcemb|ppc|ppc64)
3721 linux_arch=powerpc
3722 ;;
3723 s390x)
3724 linux_arch=s390
3725 ;;
3726 *)
3727 # For most CPUs the kernel architecture name and QEMU CPU name match.
3728 linux_arch="$cpu"
3729 ;;
3730 esac
3731 # For non-KVM architectures we will not have asm headers
3732 if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
3733 symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
3734 fi
3735fi
3736
3737for target in $target_list; do
3738target_dir="$target"
3739config_target_mak=$target_dir/config-target.mak
3740target_arch2=`echo $target | cut -d '-' -f 1`
3741target_bigendian="no"
3742
3743case "$target_arch2" in
3744 armeb|lm32|m68k|microblaze|mips|mipsn32|mips64|or32|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
3745 target_bigendian=yes
3746 ;;
3747esac
3748target_softmmu="no"
3749target_user_only="no"
3750target_linux_user="no"
3751target_bsd_user="no"
3752case "$target" in
3753 ${target_arch2}-softmmu)
3754 target_softmmu="yes"
3755 ;;
3756 ${target_arch2}-linux-user)
3757 if test "$linux" != "yes" ; then
3758 echo "ERROR: Target '$target' is only available on a Linux host"
3759 exit 1
3760 fi
3761 target_user_only="yes"
3762 target_linux_user="yes"
3763 ;;
3764 ${target_arch2}-bsd-user)
3765 if test "$bsd" != "yes" ; then
3766 echo "ERROR: Target '$target' is only available on a BSD host"
3767 exit 1
3768 fi
3769 target_user_only="yes"
3770 target_bsd_user="yes"
3771 ;;
3772 *)
3773 echo "ERROR: Target '$target' not recognised"
3774 exit 1
3775 ;;
3776esac
3777
3778mkdir -p $target_dir
3779echo "# Automatically generated by configure - do not modify" > $config_target_mak
3780
3781bflt="no"
3782target_nptl="no"
3783interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
3784gdb_xml_files=""
3785target_short_alignment=2
3786target_int_alignment=4
3787target_long_alignment=4
3788target_llong_alignment=8
3789target_libs_softmmu=
3790
3791TARGET_ARCH="$target_arch2"
3792TARGET_BASE_ARCH=""
3793TARGET_ABI_DIR=""
3794
3795case "$target_arch2" in
3796 i386)
3797 ;;
3798 x86_64)
3799 TARGET_BASE_ARCH=i386
3800 target_long_alignment=8
3801 ;;
3802 alpha)
3803 target_long_alignment=8
3804 target_nptl="yes"
3805 ;;
3806 arm|armeb)
3807 TARGET_ARCH=arm
3808 bflt="yes"
3809 target_nptl="yes"
3810 gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
3811 target_llong_alignment=4
3812 target_libs_softmmu="$fdt_libs"
3813 ;;
3814 cris)
3815 target_nptl="yes"
3816 ;;
3817 lm32)
3818 target_libs_softmmu="$opengl_libs"
3819 ;;
3820 m68k)
3821 bflt="yes"
3822 gdb_xml_files="cf-core.xml cf-fp.xml"
3823 target_int_alignment=2
3824 target_long_alignment=2
3825 target_llong_alignment=2
3826 ;;
3827 microblaze|microblazeel)
3828 TARGET_ARCH=microblaze
3829 bflt="yes"
3830 target_nptl="yes"
3831 target_libs_softmmu="$fdt_libs"
3832 ;;
3833 mips|mipsel)
3834 TARGET_ARCH=mips
3835 echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
3836 target_nptl="yes"
3837 ;;
3838 mipsn32|mipsn32el)
3839 TARGET_ARCH=mipsn32
3840 TARGET_BASE_ARCH=mips
3841 echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
3842 ;;
3843 mips64|mips64el)
3844 TARGET_ARCH=mips64
3845 TARGET_BASE_ARCH=mips
3846 echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
3847 target_long_alignment=8
3848 ;;
3849 or32)
3850 TARGET_ARCH=openrisc
3851 TARGET_BASE_ARCH=openrisc
3852 ;;
3853 ppc)
3854 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
3855 target_nptl="yes"
3856 target_libs_softmmu="$fdt_libs"
3857 ;;
3858 ppcemb)
3859 TARGET_BASE_ARCH=ppc
3860 TARGET_ABI_DIR=ppc
3861 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
3862 target_nptl="yes"
3863 target_libs_softmmu="$fdt_libs"
3864 ;;
3865 ppc64)
3866 TARGET_BASE_ARCH=ppc
3867 TARGET_ABI_DIR=ppc
3868 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
3869 target_long_alignment=8
3870 target_libs_softmmu="$fdt_libs"
3871 ;;
3872 ppc64abi32)
3873 TARGET_ARCH=ppc64
3874 TARGET_BASE_ARCH=ppc
3875 TARGET_ABI_DIR=ppc
3876 echo "TARGET_ABI32=y" >> $config_target_mak
3877 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
3878 target_libs_softmmu="$fdt_libs"
3879 ;;
3880 sh4|sh4eb)
3881 TARGET_ARCH=sh4
3882 bflt="yes"
3883 target_nptl="yes"
3884 ;;
3885 sparc)
3886 ;;
3887 sparc64)
3888 TARGET_BASE_ARCH=sparc
3889 target_long_alignment=8
3890 ;;
3891 sparc32plus)
3892 TARGET_ARCH=sparc64
3893 TARGET_BASE_ARCH=sparc
3894 TARGET_ABI_DIR=sparc
3895 echo "TARGET_ABI32=y" >> $config_target_mak
3896 ;;
3897 s390x)
3898 target_nptl="yes"
3899 target_long_alignment=8
3900 ;;
3901 unicore32)
3902 ;;
3903 xtensa|xtensaeb)
3904 TARGET_ARCH=xtensa
3905 ;;
3906 *)
3907 echo "Unsupported target CPU"
3908 exit 1
3909 ;;
3910esac
3911# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
3912if [ "$TARGET_BASE_ARCH" = "" ]; then
3913 TARGET_BASE_ARCH=$TARGET_ARCH
3914fi
3915
3916symlink "$source_path/Makefile.target" "$target_dir/Makefile"
3917
3918upper() {
3919 echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
3920}
3921
3922case "$cpu" in
3923 i386|x86_64|ppc)
3924 # The TCG interpreter currently does not support ld/st optimization.
3925 if test "$tcg_interpreter" = "no" ; then
3926 echo "CONFIG_QEMU_LDST_OPTIMIZATION=y" >> $config_target_mak
3927 fi
3928 ;;
3929esac
3930
3931echo "TARGET_SHORT_ALIGNMENT=$target_short_alignment" >> $config_target_mak
3932echo "TARGET_INT_ALIGNMENT=$target_int_alignment" >> $config_target_mak
3933echo "TARGET_LONG_ALIGNMENT=$target_long_alignment" >> $config_target_mak
3934echo "TARGET_LLONG_ALIGNMENT=$target_llong_alignment" >> $config_target_mak
3935echo "TARGET_ARCH=$TARGET_ARCH" >> $config_target_mak
3936target_arch_name="`upper $TARGET_ARCH`"
3937echo "TARGET_$target_arch_name=y" >> $config_target_mak
3938echo "TARGET_ARCH2=$target_arch2" >> $config_target_mak
3939echo "TARGET_TYPE=TARGET_TYPE_`upper $target_arch2`" >> $config_target_mak
3940echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
3941if [ "$TARGET_ABI_DIR" = "" ]; then
3942 TARGET_ABI_DIR=$TARGET_ARCH
3943fi
3944echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
3945case "$target_arch2" in
3946 i386|x86_64)
3947 if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
3948 echo "CONFIG_XEN=y" >> $config_target_mak
3949 if test "$xen_pci_passthrough" = yes; then
3950 echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
3951 fi
3952 else
3953 echo "CONFIG_NO_XEN=y" >> $config_target_mak
3954 fi
3955 ;;
3956 *)
3957 echo "CONFIG_NO_XEN=y" >> $config_target_mak
3958esac
3959case "$target_arch2" in
3960 i386|x86_64|ppcemb|ppc|ppc64|s390x)
3961 # Make sure the target and host cpus are compatible
3962 if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
3963 \( "$target_arch2" = "$cpu" -o \
3964 \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
3965 \( "$target_arch2" = "ppc64" -a "$cpu" = "ppc" \) -o \
3966 \( "$target_arch2" = "ppc" -a "$cpu" = "ppc64" \) -o \
3967 \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc64" \) -o \
3968 \( "$target_arch2" = "x86_64" -a "$cpu" = "i386" \) -o \
3969 \( "$target_arch2" = "i386" -a "$cpu" = "x86_64" \) \) ; then
3970 echo "CONFIG_KVM=y" >> $config_target_mak
3971 if test "$vhost_net" = "yes" ; then
3972 echo "CONFIG_VHOST_NET=y" >> $config_target_mak
3973 fi
3974 fi
3975esac
3976case "$target_arch2" in
3977 i386|x86_64)
3978 echo "CONFIG_HAVE_GET_MEMORY_MAPPING=y" >> $config_target_mak
3979esac
3980if test "$target_arch2" = "ppc64" -a "$fdt" = "yes"; then
3981 echo "CONFIG_PSERIES=y" >> $config_target_mak
3982fi
3983if test "$target_bigendian" = "yes" ; then
3984 echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
3985fi
3986if test "$target_softmmu" = "yes" ; then
3987 echo "CONFIG_SOFTMMU=y" >> $config_target_mak
3988 echo "LIBS+=$libs_softmmu $target_libs_softmmu" >> $config_target_mak
3989 if test "$smartcard_nss" = "yes" ; then
3990 echo "subdir-$target: subdir-libcacard" >> $config_host_mak
3991 fi
3992 case "$target_arch2" in
3993 i386|x86_64)
3994 echo "CONFIG_HAVE_CORE_DUMP=y" >> $config_target_mak
3995 esac
3996fi
3997if test "$target_user_only" = "yes" ; then
3998 echo "CONFIG_USER_ONLY=y" >> $config_target_mak
3999 echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
4000fi
4001if test "$target_linux_user" = "yes" ; then
4002 echo "CONFIG_LINUX_USER=y" >> $config_target_mak
4003fi
4004list=""
4005if test ! -z "$gdb_xml_files" ; then
4006 for x in $gdb_xml_files; do
4007 list="$list $source_path/gdb-xml/$x"
4008 done
4009 echo "TARGET_XML_FILES=$list" >> $config_target_mak
4010fi
4011
4012if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
4013 echo "TARGET_HAS_BFLT=y" >> $config_target_mak
4014fi
4015if test "$target_user_only" = "yes" \
4016 -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
4017 echo "CONFIG_USE_NPTL=y" >> $config_target_mak
4018fi
4019if test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
4020 echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
4021fi
4022if test "$target_bsd_user" = "yes" ; then
4023 echo "CONFIG_BSD_USER=y" >> $config_target_mak
4024fi
4025
4026# the static way of configuring available audio cards requires this workaround
4027if test "$target_user_only" != "yes" && grep -q CONFIG_PCSPK $source_path/default-configs/$target.mak; then
4028 echo "CONFIG_PCSPK=y" >> $config_target_mak
4029fi
4030
4031# generate QEMU_CFLAGS/LDFLAGS for targets
4032
4033cflags=""
4034includes=""
4035ldflags=""
4036
4037if test "$tcg_interpreter" = "yes"; then
4038 includes="-I\$(SRC_PATH)/tcg/tci $includes"
4039elif test "$ARCH" = "sparc64" ; then
4040 includes="-I\$(SRC_PATH)/tcg/sparc $includes"
4041elif test "$ARCH" = "s390x" ; then
4042 includes="-I\$(SRC_PATH)/tcg/s390 $includes"
4043elif test "$ARCH" = "x86_64" ; then
4044 includes="-I\$(SRC_PATH)/tcg/i386 $includes"
4045else
4046 includes="-I\$(SRC_PATH)/tcg/\$(ARCH) $includes"
4047fi
4048includes="-I\$(SRC_PATH)/tcg $includes"
4049
4050if test "$linux" = "yes" ; then
4051 includes="-I\$(SRC_PATH)/linux-headers $includes"
4052fi
4053
4054for i in $ARCH $TARGET_BASE_ARCH ; do
4055 case "$i" in
4056 alpha)
4057 echo "CONFIG_ALPHA_DIS=y" >> $config_target_mak
4058 echo "CONFIG_ALPHA_DIS=y" >> config-all-disas.mak
4059 ;;
4060 arm)
4061 echo "CONFIG_ARM_DIS=y" >> $config_target_mak
4062 echo "CONFIG_ARM_DIS=y" >> config-all-disas.mak
4063 ;;
4064 cris)
4065 echo "CONFIG_CRIS_DIS=y" >> $config_target_mak
4066 echo "CONFIG_CRIS_DIS=y" >> config-all-disas.mak
4067 ;;
4068 hppa)
4069 echo "CONFIG_HPPA_DIS=y" >> $config_target_mak
4070 echo "CONFIG_HPPA_DIS=y" >> config-all-disas.mak
4071 ;;
4072 i386|x86_64)
4073 echo "CONFIG_I386_DIS=y" >> $config_target_mak
4074 echo "CONFIG_I386_DIS=y" >> config-all-disas.mak
4075 ;;
4076 ia64*)
4077 echo "CONFIG_IA64_DIS=y" >> $config_target_mak
4078 echo "CONFIG_IA64_DIS=y" >> config-all-disas.mak
4079 ;;
4080 lm32)
4081 echo "CONFIG_LM32_DIS=y" >> $config_target_mak
4082 echo "CONFIG_LM32_DIS=y" >> config-all-disas.mak
4083 ;;
4084 m68k)
4085 echo "CONFIG_M68K_DIS=y" >> $config_target_mak
4086 echo "CONFIG_M68K_DIS=y" >> config-all-disas.mak
4087 ;;
4088 microblaze*)
4089 echo "CONFIG_MICROBLAZE_DIS=y" >> $config_target_mak
4090 echo "CONFIG_MICROBLAZE_DIS=y" >> config-all-disas.mak
4091 ;;
4092 mips*)
4093 echo "CONFIG_MIPS_DIS=y" >> $config_target_mak
4094 echo "CONFIG_MIPS_DIS=y" >> config-all-disas.mak
4095 ;;
4096 or32)
4097 echo "CONFIG_OPENRISC_DIS=y" >> $config_target_mak
4098 echo "CONFIG_OPENRISC_DIS=y" >> config-all-disas.mak
4099 ;;
4100 ppc*)
4101 echo "CONFIG_PPC_DIS=y" >> $config_target_mak
4102 echo "CONFIG_PPC_DIS=y" >> config-all-disas.mak
4103 ;;
4104 s390*)
4105 echo "CONFIG_S390_DIS=y" >> $config_target_mak
4106 echo "CONFIG_S390_DIS=y" >> config-all-disas.mak
4107 ;;
4108 sh4)
4109 echo "CONFIG_SH4_DIS=y" >> $config_target_mak
4110 echo "CONFIG_SH4_DIS=y" >> config-all-disas.mak
4111 ;;
4112 sparc*)
4113 echo "CONFIG_SPARC_DIS=y" >> $config_target_mak
4114 echo "CONFIG_SPARC_DIS=y" >> config-all-disas.mak
4115 ;;
4116 xtensa*)
4117 echo "CONFIG_XTENSA_DIS=y" >> $config_target_mak
4118 echo "CONFIG_XTENSA_DIS=y" >> config-all-disas.mak
4119 ;;
4120 esac
4121done
4122if test "$tcg_interpreter" = "yes" ; then
4123 echo "CONFIG_TCI_DIS=y" >> $config_target_mak
4124 echo "CONFIG_TCI_DIS=y" >> config-all-disas.mak
4125fi
4126
4127case "$ARCH" in
4128alpha)
4129 # Ensure there's only a single GP
4130 cflags="-msmall-data $cflags"
4131;;
4132esac
4133
4134if test "$target_softmmu" = "yes" ; then
4135 case "$TARGET_BASE_ARCH" in
4136 arm)
4137 cflags="-DHAS_AUDIO $cflags"
4138 ;;
4139 lm32)
4140 cflags="-DHAS_AUDIO $cflags"
4141 ;;
4142 i386|mips|ppc)
4143 cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags"
4144 ;;
4145 esac
4146fi
4147
4148if test "$gprof" = "yes" ; then
4149 echo "TARGET_GPROF=yes" >> $config_target_mak
4150 if test "$target_linux_user" = "yes" ; then
4151 cflags="-p $cflags"
4152 ldflags="-p $ldflags"
4153 fi
4154 if test "$target_softmmu" = "yes" ; then
4155 ldflags="-p $ldflags"
4156 echo "GPROF_CFLAGS=-p" >> $config_target_mak
4157 fi
4158fi
4159
4160if test "$ARCH" = "tci"; then
4161 linker_script=""
4162else
4163 linker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/ldscripts/\$(ARCH).ld"
4164fi
4165
4166if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
4167 case "$ARCH" in
4168 alpha | s390x)
4169 # The default placement of the application is fine.
4170 ;;
4171 *)
4172 ldflags="$linker_script $ldflags"
4173 ;;
4174 esac
4175fi
4176
4177echo "LDFLAGS+=$ldflags" >> $config_target_mak
4178echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak
4179echo "QEMU_INCLUDES+=$includes" >> $config_target_mak
4180
4181done # for target in $targets
4182
4183if [ "$pixman" = "internal" ]; then
4184 echo "config-host.h: subdir-pixman" >> $config_host_mak
4185fi
4186
4187# build tree in object directory in case the source is not in the current directory
4188DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32"
4189DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas"
4190DIRS="$DIRS roms/seabios roms/vgabios"
4191DIRS="$DIRS qapi-generated"
4192DIRS="$DIRS libcacard libcacard/libcacard libcacard/trace"
4193FILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
4194FILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
4195FILES="$FILES tests/tcg/lm32/Makefile libcacard/Makefile"
4196FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
4197FILES="$FILES pc-bios/spapr-rtas/Makefile"
4198FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
4199for bios_file in \
4200 $source_path/pc-bios/*.bin \
4201 $source_path/pc-bios/*.rom \
4202 $source_path/pc-bios/*.dtb \
4203 $source_path/pc-bios/openbios-* \
4204 $source_path/pc-bios/palcode-*
4205do
4206 FILES="$FILES pc-bios/`basename $bios_file`"
4207done
4208mkdir -p $DIRS
4209for f in $FILES ; do
4210 if [ -e "$source_path/$f" ] && [ "$source_path" != `pwd` ]; then
4211 symlink "$source_path/$f" "$f"
4212 fi
4213done
4214
4215# temporary config to build submodules
4216for rom in seabios vgabios ; do
4217 config_mak=roms/$rom/config.mak
4218 echo "# Automatically generated by configure - do not modify" > $config_mak
4219 echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
4220 echo "CC=$cc" >> $config_mak
4221 echo "BCC=bcc" >> $config_mak
4222 echo "CPP=${cross_prefix}cpp" >> $config_mak
4223 echo "OBJCOPY=objcopy" >> $config_mak
4224 echo "IASL=iasl" >> $config_mak
4225 echo "LD=$ld" >> $config_mak
4226done
4227
4228if test "$docs" = "yes" ; then
4229 mkdir -p QMP
4230fi