kvm: libkvm: Compile with correct kernel include directory
[qemu-kvm/fedora.git] / configure
blobdf4d686cb18e99b4a1c7fec67d54d02a6c0631bd
1 #!/bin/sh
3 # qemu configure script (c) 2003 Fabrice Bellard
5 # set temporary file name
6 if test ! -z "$TMPDIR" ; then
7 TMPDIR1="${TMPDIR}"
8 elif test ! -z "$TEMPDIR" ; then
9 TMPDIR1="${TEMPDIR}"
10 else
11 TMPDIR1="/tmp"
14 TMPC="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.c"
15 TMPO="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.o"
16 TMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}"
17 TMPS="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.S"
18 TMPI="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.i"
19 TMPSDLLOG="${TMPDIR1}/qemu-conf-sdl-$$-${RANDOM}.log"
21 trap "rm -f $TMPC $TMPO $TMPE $TMPS $TMPI $TMPSDLLOG; exit" 0 2 3 15
23 # default parameters
24 prefix=""
25 interp_prefix="/usr/gnemul/qemu-%M"
26 static="no"
27 cross_prefix=""
28 cc="gcc"
29 audio_drv_list=""
30 audio_card_list="ac97 es1370 sb16"
31 audio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus"
32 host_cc="gcc"
33 ar="ar"
34 make="make"
35 install="install"
36 strip="strip"
38 # parse CC options first
39 for opt do
40 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
41 case "$opt" in
42 --cross-prefix=*) cross_prefix="$optarg"
44 --cc=*) cc="$optarg"
46 esac
47 done
49 # OS specific
50 # Using uname is really, really broken. Once we have the right set of checks
51 # we can eliminate it's usage altogether
53 cc="${cross_prefix}${cc}"
54 ar="${cross_prefix}${ar}"
55 strip="${cross_prefix}${strip}"
57 # check that the C compiler works.
58 cat > $TMPC <<EOF
59 int main(void) {}
60 EOF
62 if $cc $ARCH_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null ; then
63 : C compiler works ok
64 else
65 echo "ERROR: \"$cc\" either does not exist or does not work"
66 exit 1
69 check_define() {
70 cat > $TMPC <<EOF
71 #if !defined($1)
72 #error Not defined
73 #endif
74 int main(void) { return 0; }
75 EOF
76 $cc $ARCH_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null
79 if check_define __i386__ ; then
80 cpu="i386"
81 elif check_define __x86_64__ ; then
82 cpu="x86_64"
83 elif check_define __sparc__ ; then
84 # We can't check for 64 bit (when gcc is biarch) or V8PLUSA
85 # They must be specified using --sparc_cpu
86 if check_define __arch64__ ; then
87 cpu="sparc64"
88 else
89 cpu="sparc"
91 elif check_define _ARCH_PPC ; then
92 if check_define _ARCH_PPC64 ; then
93 cpu="ppc64"
94 else
95 cpu="ppc"
97 else
98 cpu=`uname -m`
101 target_list="x86_64-softmmu"
102 case "$cpu" in
103 i386|i486|i586|i686|i86pc|BePC)
104 cpu="i386"
106 x86_64|amd64)
107 cpu="x86_64"
109 alpha)
110 cpu="alpha"
112 armv*b)
113 cpu="armv4b"
115 armv*l)
116 cpu="armv4l"
118 cris)
119 cpu="cris"
121 parisc|parisc64)
122 cpu="hppa"
124 ia64)
125 cpu="ia64"
127 m68k)
128 cpu="m68k"
130 mips)
131 cpu="mips"
133 mips64)
134 cpu="mips64"
136 ppc)
137 cpu="ppc"
139 ppc64)
140 cpu="ppc64"
142 s390*)
143 cpu="s390"
145 sparc|sun4[cdmuv])
146 cpu="sparc"
148 sparc64)
149 cpu="sparc64"
152 cpu="unknown"
154 esac
155 gprof="no"
156 sparse="no"
157 bigendian="no"
158 mingw32="no"
159 EXESUF=""
160 gdbstub="yes"
161 slirp="yes"
162 vde="yes"
163 fmod_lib=""
164 fmod_inc=""
165 oss_lib=""
166 vnc_tls="yes"
167 bsd="no"
168 linux="no"
169 solaris="no"
170 kqemu="no"
171 profiler="no"
172 cocoa="no"
173 check_gfx="yes"
174 softmmu="yes"
175 linux_user="no"
176 darwin_user="no"
177 bsd_user="no"
178 build_docs="no"
179 uname_release=""
180 curses="yes"
181 aio="yes"
182 nptl="yes"
183 mixemu="no"
184 bluez="yes"
185 kvm="yes"
186 kvm_cap_pit="no"
187 kvm_cap_device_assignment="no"
188 kerneldir=""
189 aix="no"
190 blobs="yes"
191 fdt="yes"
192 sdl_x11="no"
193 signalfd="no"
194 eventfd="no"
195 cpu_emulation="yes"
197 # qemu-kvm: use local kerneldir
198 kerneldir="$(readlink -f kvm/kernel)"
200 # OS specific
201 if check_define __linux__ ; then
202 targetos="Linux"
203 elif check_define _WIN32 ; then
204 targetos='MINGW32'
205 else
206 targetos=`uname -s`
208 case $targetos in
209 CYGWIN*)
210 mingw32="yes"
211 OS_CFLAGS="-mno-cygwin"
212 if [ "$cpu" = "i386" ] ; then
213 kqemu="yes"
215 audio_possible_drivers="sdl"
217 MINGW32*)
218 mingw32="yes"
219 if [ "$cpu" = "i386" ] ; then
220 kqemu="yes"
222 audio_possible_drivers="dsound sdl fmod"
224 GNU/kFreeBSD)
225 audio_drv_list="oss"
226 audio_possible_drivers="oss sdl esd pa"
227 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
228 kqemu="yes"
231 FreeBSD)
232 bsd="yes"
233 audio_drv_list="oss"
234 audio_possible_drivers="oss sdl esd pa"
235 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
236 kqemu="yes"
237 kvm="yes"
240 NetBSD)
241 bsd="yes"
242 audio_drv_list="oss"
243 audio_possible_drivers="oss sdl esd"
244 oss_lib="-lossaudio"
246 OpenBSD)
247 bsd="yes"
248 openbsd="yes"
249 audio_drv_list="oss"
250 audio_possible_drivers="oss sdl esd"
251 oss_lib="-lossaudio"
253 Darwin)
254 bsd="yes"
255 darwin="yes"
256 # on Leopard most of the system is 32-bit, so we have to ask the kernel it if we can run 64-bit userspace code
257 if [ "$cpu" = "i386" ] ; then
258 is_x86_64=`sysctl -n hw.optional.x86_64`
259 [ "$is_x86_64" = "1" ] && cpu=x86_64
261 if [ "$cpu" = "x86_64" ] ; then
262 OS_CFLAGS="-arch x86_64"
263 LDFLAGS="-arch x86_64"
264 else
265 OS_CFLAGS="-mdynamic-no-pic"
267 darwin_user="yes"
268 cocoa="yes"
269 audio_drv_list="coreaudio"
270 audio_possible_drivers="coreaudio sdl fmod"
271 OS_LDFLAGS="-framework CoreFoundation -framework IOKit"
273 SunOS)
274 solaris="yes"
275 make="gmake"
276 install="ginstall"
277 needs_libsunmath="no"
278 solarisrev=`uname -r | cut -f2 -d.`
279 # have to select again, because `uname -m` returns i86pc
280 # even on an x86_64 box.
281 solariscpu=`isainfo -k`
282 if test "${solariscpu}" = "amd64" ; then
283 cpu="x86_64"
285 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
286 if test "$solarisrev" -le 9 ; then
287 if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
288 needs_libsunmath="yes"
289 else
290 echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
291 echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
292 echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
293 echo "Studio 11 can be downloaded from www.sun.com."
294 exit 1
297 if test "$solarisrev" -ge 9 ; then
298 kqemu="yes"
301 if test -f /usr/include/sys/soundcard.h ; then
302 audio_drv_list="oss"
304 audio_possible_drivers="oss sdl"
306 AIX)
307 aix="yes"
308 make="gmake"
311 audio_drv_list="oss"
312 audio_possible_drivers="oss alsa sdl esd pa"
313 linux="yes"
314 linux_user="yes"
315 usb="linux"
316 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
317 kqemu="yes"
318 audio_possible_drivers="$audio_possible_drivers fmod"
319 kvm="yes"
321 if [ "$cpu" = "ia64" ] ; then
322 kvm="yes"
323 cpu_emulation="no"
324 gdbstub="no"
325 slirp="no"
327 if [ "$cpu" = "powerpc" ]; then
328 kvm="yes"
331 esac
333 if [ "$bsd" = "yes" ] ; then
334 if [ "$darwin" != "yes" ] ; then
335 make="gmake"
336 usb="bsd"
338 bsd_user="yes"
341 # find source path
342 source_path=`dirname "$0"`
343 source_path_used="no"
344 workdir=`pwd`
345 if [ -z "$source_path" ]; then
346 source_path=$workdir
347 else
348 source_path=`cd "$source_path"; pwd`
350 [ -f "$workdir/vl.c" ] || source_path_used="yes"
352 werror="no"
353 # generate compile errors on warnings for development builds
354 #if grep cvs $source_path/VERSION > /dev/null 2>&1 ; then
355 #werror="yes";
358 for opt do
359 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
360 case "$opt" in
361 --help|-h) show_help=yes
363 --prefix=*) prefix="$optarg"
365 --interp-prefix=*) interp_prefix="$optarg"
367 --source-path=*) source_path="$optarg"
368 source_path_used="yes"
370 --cross-prefix=*)
372 --cc=*)
374 --host-cc=*) host_cc="$optarg"
376 --make=*) make="$optarg"
378 --install=*) install="$optarg"
380 --extra-cflags=*) CFLAGS="$optarg"
382 --extra-ldflags=*) LDFLAGS="$optarg"
384 --cpu=*) cpu="$optarg"
386 --target-list=*) target_list="$optarg"
388 --enable-gprof) gprof="yes"
390 --static) static="yes"
392 --disable-sdl) sdl="no"
394 --fmod-lib=*) fmod_lib="$optarg"
396 --fmod-inc=*) fmod_inc="$optarg"
398 --oss-lib=*) oss_lib="$optarg"
400 --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
402 --audio-drv-list=*) audio_drv_list="$optarg"
404 --enable-sparse) sparse="yes"
406 --disable-sparse) sparse="no"
408 --disable-vnc-tls) vnc_tls="no"
410 --disable-slirp) slirp="no"
412 --disable-vde) vde="no"
414 --disable-kqemu) kqemu="no"
416 --disable-brlapi) brlapi="no"
418 --disable-bluez) bluez="no"
420 --disable-kvm) kvm="no"
422 --enable-profiler) profiler="yes"
424 --enable-cocoa)
425 cocoa="yes" ;
426 sdl="no" ;
427 audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
429 --disable-gfx-check) check_gfx="no"
431 --disable-system) softmmu="no"
433 --enable-system) softmmu="yes"
435 --disable-linux-user) linux_user="no"
437 --enable-linux-user) linux_user="yes"
439 --disable-darwin-user) darwin_user="no"
441 --enable-darwin-user) darwin_user="yes"
443 --disable-bsd-user) bsd_user="no"
445 --enable-bsd-user) bsd_user="yes"
447 --enable-uname-release=*) uname_release="$optarg"
449 --sparc_cpu=*)
450 sparc_cpu="$optarg"
451 case $sparc_cpu in
452 v7|v8) SP_CFLAGS="-m32 -mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__"; SP_LDFLAGS="-m32"
453 target_cpu="sparc"; cpu="sparc" ;;
454 v8plus|v8plusa) SP_CFLAGS="-m32 -mcpu=ultrasparc -D__sparc_${sparc_cpu}__"; SP_LDFLAGS="-m32"
455 target_cpu="sparc"; cpu="sparc" ;;
456 v9) SP_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_${sparc_cpu}__"; SP_LDFLAGS="-m64"
457 target_cpu="sparc64"; cpu="sparc64" ;;
458 *) echo "undefined SPARC architecture. Exiting";exit 1;;
459 esac
461 --enable-werror) werror="yes"
463 --disable-werror) werror="no"
465 --disable-curses) curses="no"
467 --disable-nptl) nptl="no"
469 --enable-mixemu) mixemu="yes"
471 --disable-aio) aio="no"
473 --disable-blobs) blobs="no"
475 --kerneldir=*) kerneldir="$optarg"
477 --disable-cpu-emulation) cpu_emulation="no"
479 *) echo "ERROR: unknown option $opt"; exit 1
481 esac
482 done
484 # default flags for all hosts
485 CFLAGS="$CFLAGS -O2 -g -fno-strict-aliasing"
486 CFLAGS="$CFLAGS -Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls"
487 LDFLAGS="$LDFLAGS -g"
488 if test "$werror" = "yes" ; then
489 CFLAGS="$CFLAGS -Werror"
492 CFLAGS="$CFLAGS -I$(readlink -f "kvm/libkvm")"
494 if test "$solaris" = "no" ; then
495 if ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
496 LDFLAGS="$LDFLAGS -Wl,--warn-common"
501 # If cpu ~= sparc and sparc_cpu hasn't been defined, plug in the right
502 # ARCH_CFLAGS/ARCH_LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
504 case "$cpu" in
505 sparc) if test -z "$sparc_cpu" ; then
506 ARCH_CFLAGS="-m32 -mcpu=ultrasparc -D__sparc_v8plus__"
507 ARCH_LDFLAGS="-m32"
508 else
509 ARCH_CFLAGS="${SP_CFLAGS}"
510 ARCH_LDFLAGS="${SP_LDFLAGS}"
513 sparc64) if test -z "$sparc_cpu" ; then
514 ARCH_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__"
515 ARCH_LDFLAGS="-m64"
516 else
517 ARCH_CFLAGS="${SP_CFLAGS}"
518 ARCH_LDFLAGS="${SP_LDFLAGS}"
521 s390)
522 ARCH_CFLAGS="-march=z900"
524 i386)
525 ARCH_CFLAGS="-m32"
526 ARCH_LDFLAGS="-m32"
528 x86_64)
529 ARCH_CFLAGS="-m64"
530 ARCH_LDFLAGS="-m64"
532 esac
534 if test x"$show_help" = x"yes" ; then
535 cat << EOF
537 Usage: configure [options]
538 Options: [defaults in brackets after descriptions]
541 echo "Standard options:"
542 echo " --help print this message"
543 echo " --prefix=PREFIX install in PREFIX [$prefix]"
544 echo " --interp-prefix=PREFIX where to find shared libraries, etc."
545 echo " use %M for cpu name [$interp_prefix]"
546 echo " --target-list=LIST set target list [$target_list]"
547 echo ""
548 echo "kqemu kernel acceleration support:"
549 echo " --disable-kqemu disable kqemu support"
550 echo ""
551 echo "Advanced options (experts only):"
552 echo " --source-path=PATH path of source code [$source_path]"
553 echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
554 echo " --cc=CC use C compiler CC [$cc]"
555 echo " --host-cc=CC use C compiler CC [$host_cc] for dyngen etc."
556 echo " --make=MAKE use specified make [$make]"
557 echo " --install=INSTALL use specified install [$install]"
558 echo " --static enable static build [$static]"
559 echo " --enable-sparse enable sparse checker"
560 echo " --disable-sparse disable sparse checker (default)"
561 echo " --disable-werror disable compilation abort on warning"
562 echo " --disable-sdl disable SDL"
563 echo " --enable-cocoa enable COCOA (Mac OS X only)"
564 echo " --audio-drv-list=LIST set audio drivers list:"
565 echo " Available drivers: $audio_possible_drivers"
566 echo " --audio-card-list=LIST set list of emulated audio cards [$audio_card_list]"
567 echo " Available cards: $audio_possible_cards"
568 echo " --enable-mixemu enable mixer emulation"
569 echo " --disable-brlapi disable BrlAPI"
570 echo " --disable-vnc-tls disable TLS encryption for VNC server"
571 echo " --disable-curses disable curses output"
572 echo " --disable-bluez disable bluez stack connectivity"
573 echo " --disable-kvm disable KVM acceleration support"
574 echo " --disable-nptl disable usermode NPTL support"
575 echo " --enable-system enable all system emulation targets"
576 echo " --disable-system disable all system emulation targets"
577 echo " --enable-linux-user enable all linux usermode emulation targets"
578 echo " --disable-linux-user disable all linux usermode emulation targets"
579 echo " --enable-darwin-user enable all darwin usermode emulation targets"
580 echo " --disable-darwin-user disable all darwin usermode emulation targets"
581 echo " --enable-bsd-user enable all BSD usermode emulation targets"
582 echo " --disable-bsd-user disable all BSD usermode emulation targets"
583 echo " --fmod-lib path to FMOD library"
584 echo " --fmod-inc path to FMOD includes"
585 echo " --oss-lib path to OSS library"
586 echo " --enable-uname-release=R Return R for uname -r in usermode emulation"
587 echo " --sparc_cpu=V Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
588 echo " --disable-vde disable support for vde network"
589 echo " --disable-aio disable AIO support"
590 echo " --disable-blobs disable installing provided firmware blobs"
591 echo " --kerneldir=PATH look for kernel includes in PATH"
592 echo " --disable-cpu-emulation disables use of qemu cpu emulation code"
593 echo ""
594 echo "NOTE: The object files are built at the place where configure is launched"
595 exit 1
598 if test "$mingw32" = "yes" ; then
599 linux="no"
600 EXESUF=".exe"
601 oss="no"
602 linux_user="no"
603 bsd_user="no"
606 if test ! -x "$(which cgcc 2>/dev/null)"; then
607 sparse="no"
611 # Solaris specific configure tool chain decisions
613 if test "$solaris" = "yes" ; then
614 solinst=`which $install 2> /dev/null | /usr/bin/grep -v "no $install in"`
615 if test -z "$solinst" ; then
616 echo "Solaris install program not found. Use --install=/usr/ucb/install or"
617 echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
618 echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
619 exit 1
621 if test "$solinst" = "/usr/sbin/install" ; then
622 echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
623 echo "try ginstall from the GNU fileutils available from www.blastwave.org"
624 echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
625 exit 1
627 sol_ar=`which ar 2> /dev/null | /usr/bin/grep -v "no ar in"`
628 if test -z "$sol_ar" ; then
629 echo "Error: No path includes ar"
630 if test -f /usr/ccs/bin/ar ; then
631 echo "Add /usr/ccs/bin to your path and rerun configure"
633 exit 1
638 if test -z "$target_list" ; then
639 # these targets are portable
640 if [ "$softmmu" = "yes" ] ; then
641 target_list="\
642 i386-softmmu \
643 x86_64-softmmu \
644 arm-softmmu \
645 cris-softmmu \
646 m68k-softmmu \
647 mips-softmmu \
648 mipsel-softmmu \
649 mips64-softmmu \
650 mips64el-softmmu \
651 ppc-softmmu \
652 ppcemb-softmmu \
653 ppc64-softmmu \
654 sh4-softmmu \
655 sh4eb-softmmu \
656 sparc-softmmu \
659 # the following are Linux specific
660 if [ "$linux_user" = "yes" ] ; then
661 target_list="${target_list}\
662 i386-linux-user \
663 x86_64-linux-user \
664 alpha-linux-user \
665 arm-linux-user \
666 armeb-linux-user \
667 cris-linux-user \
668 m68k-linux-user \
669 mips-linux-user \
670 mipsel-linux-user \
671 ppc-linux-user \
672 ppc64-linux-user \
673 ppc64abi32-linux-user \
674 sh4-linux-user \
675 sh4eb-linux-user \
676 sparc-linux-user \
677 sparc64-linux-user \
678 sparc32plus-linux-user \
681 # the following are Darwin specific
682 if [ "$darwin_user" = "yes" ] ; then
683 target_list="$target_list i386-darwin-user ppc-darwin-user "
685 # the following are BSD specific
686 if [ "$bsd_user" = "yes" ] ; then
687 target_list="${target_list}\
688 sparc64-bsd-user \
691 else
692 target_list=`echo "$target_list" | sed -e 's/,/ /g'`
694 if test -z "$target_list" ; then
695 echo "No targets enabled"
696 exit 1
699 if test -z "$cross_prefix" ; then
701 # ---
702 # big/little endian test
703 cat > $TMPC << EOF
704 #include <inttypes.h>
705 int main(int argc, char ** argv){
706 volatile uint32_t i=0x01234567;
707 return (*((uint8_t*)(&i))) == 0x67;
711 if $cc $ARCH_CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
712 $TMPE && bigendian="yes"
713 else
714 echo big/little test failed
717 else
719 # if cross compiling, cannot launch a program, so make a static guess
720 if test "$cpu" = "armv4b" \
721 -o "$cpu" = "hppa" \
722 -o "$cpu" = "m68k" \
723 -o "$cpu" = "mips" \
724 -o "$cpu" = "mips64" \
725 -o "$cpu" = "ppc" \
726 -o "$cpu" = "ppc64" \
727 -o "$cpu" = "s390" \
728 -o "$cpu" = "sparc" \
729 -o "$cpu" = "sparc64"; then
730 bigendian="yes"
735 # host long bits test
736 hostlongbits="32"
737 if test "$cpu" = "x86_64" \
738 -o "$cpu" = "alpha" \
739 -o "$cpu" = "ia64" \
740 -o "$cpu" = "sparc64" \
741 -o "$cpu" = "ppc64"; then
742 hostlongbits="64"
745 # check gcc options support
746 cat > $TMPC <<EOF
747 int main(void) {
751 # Check host NPTL support
752 cat > $TMPC <<EOF
753 #include <sched.h>
754 #include <linux/futex.h>
755 void foo()
757 #if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
758 #error bork
759 #endif
763 if $cc $ARCH_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null ; then
765 else
766 nptl="no"
769 ##########################################
770 # KVM probe
772 if test "$kvm" = "yes" ; then
774 # test for KVM_CAP_PIT
776 cat > $TMPC <<EOF
777 #include <libkvm.h>
778 #ifndef KVM_CAP_PIT
779 #error "kvm no pit capability"
780 #endif
781 int main(void) { return 0; }
783 if $cc $ARCH_CFLAGS $CFLAGS -I"$kerneldir"/include -o $TMPE ${OS_CFLAGS} $TMPC 2> /dev/null ; then
784 kvm_cap_pit="yes"
787 # test for KVM_CAP_DEVICE_ASSIGNMENT
789 cat > $TMPC <<EOF
790 #include <libkvm.h>
791 #ifndef KVM_CAP_DEVICE_ASSIGNMENT
792 #error "kvm no device assignment capability"
793 #endif
794 int main(void) { return 0; }
796 if $cc $ARCH_CFLAGS $CFLAGS -I"$kerneldir"/include -o $TMPE ${OS_CFLAGS} $TMPC 2> /dev/null ; then
797 kvm_cap_device_assignment="yes"
801 ##########################################
802 # zlib check
804 cat > $TMPC << EOF
805 #include <zlib.h>
806 int main(void) { zlibVersion(); return 0; }
808 if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $TMPC -lz > /dev/null 2> /dev/null ; then
810 else
811 echo
812 echo "Error: zlib check failed"
813 echo "Make sure to have the zlib libs and headers installed."
814 echo
815 exit 1
818 ##########################################
819 # SDL probe
821 sdl_too_old=no
823 if test -z "$sdl" ; then
824 sdl_config="sdl-config"
825 sdl=no
826 sdl_static=no
828 cat > $TMPC << EOF
829 #include <SDL.h>
830 #undef main /* We don't want SDL to override our main() */
831 int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
833 if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} `$sdl_config --cflags 2> /dev/null` $TMPC `$sdl_config --libs 2> /dev/null` > $TMPSDLLOG 2>&1 ; then
834 _sdlversion=`$sdl_config --version | sed 's/[^0-9]//g'`
835 if test "$_sdlversion" -lt 121 ; then
836 sdl_too_old=yes
837 else
838 if test "$cocoa" = "no" ; then
839 sdl=yes
843 # static link with sdl ?
844 if test "$sdl" = "yes" ; then
845 aa="no"
846 `$sdl_config --static-libs 2>/dev/null | grep \\\-laa > /dev/null` && aa="yes"
847 sdl_static_libs=`$sdl_config --static-libs 2>/dev/null`
848 if [ "$aa" = "yes" ] ; then
849 sdl_static_libs="$sdl_static_libs `aalib-config --static-libs`"
852 if $cc -o $TMPE ${OS_CFLAGS} `$sdl_config --cflags 2> /dev/null` $TMPC $sdl_static_libs > /dev/null 2> /dev/null; then
853 sdl_static=yes
855 fi # static link
856 fi # sdl compile test
857 else
858 # Make sure to disable cocoa if sdl was set
859 if test "$sdl" = "yes" ; then
860 cocoa="no"
861 audio_drv_list="`echo $audio_drv_list | sed s,coreaudio,,g`"
863 fi # -z $sdl
865 if test "$sdl" = "yes" ; then
866 cat > $TMPC <<EOF
867 #include <SDL.h>
868 #if defined(SDL_VIDEO_DRIVER_X11)
869 #include <X11/XKBlib.h>
870 #else
871 #error No x11 support
872 #endif
873 int main(void) { return 0; }
875 if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} `$sdl_config --cflags 2> /dev/null` $TMPC `$sdl_config --libs 2> /dev/null` > /dev/null 2>&1 ; then
876 sdl_x11="yes"
880 ##########################################
881 # VNC TLS detection
882 if test "$vnc_tls" = "yes" ; then
883 cat > $TMPC <<EOF
884 #include <gnutls/gnutls.h>
885 int main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
887 vnc_tls_cflags=`pkg-config --cflags gnutls 2> /dev/null`
888 vnc_tls_libs=`pkg-config --libs gnutls 2> /dev/null`
889 if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $vnc_tls_cflags $TMPC \
890 $vnc_tls_libs > /dev/null 2> /dev/null ; then
892 else
893 vnc_tls="no"
897 ##########################################
898 # vde libraries probe
899 if test "$vde" = "yes" ; then
900 cat > $TMPC << EOF
901 #include <libvdeplug.h>
902 int main(void)
904 struct vde_open_args a = {0, 0, 0};
905 vde_open("", "", &a);
906 return 0;
909 if $cc $ARCH_CFLAGS -o $TMPE $TMPC -lvdeplug > /dev/null 2> /dev/null ; then
911 else
912 vde="no"
916 ##########################################
917 # Sound support libraries probe
919 audio_drv_probe()
921 drv=$1
922 hdr=$2
923 lib=$3
924 exp=$4
925 cfl=$5
926 cat > $TMPC << EOF
927 #include <$hdr>
928 int main(void) { $exp }
930 if $cc $ARCH_CFLAGS $cfl -o $TMPE $TMPC $lib > /dev/null 2> /dev/null ; then
932 else
933 echo
934 echo "Error: $drv check failed"
935 echo "Make sure to have the $drv libs and headers installed."
936 echo
937 exit 1
941 audio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
942 for drv in $audio_drv_list; do
943 case $drv in
944 alsa)
945 audio_drv_probe $drv alsa/asoundlib.h -lasound \
946 "snd_pcm_t **handle; return snd_pcm_close(*handle);"
949 fmod)
950 if test -z $fmod_lib || test -z $fmod_inc; then
951 echo
952 echo "Error: You must specify path to FMOD library and headers"
953 echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
954 echo
955 exit 1
957 audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
960 esd)
961 audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
965 audio_drv_probe $drv pulse/simple.h -lpulse-simple \
966 "pa_simple *s = NULL; pa_simple_free(s); return 0;"
969 oss|sdl|core|wav|dsound)
970 # XXX: Probes for CoreAudio, DirectSound, SDL(?)
974 echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
975 echo
976 echo "Error: Unknown driver '$drv' selected"
977 echo "Possible drivers are: $audio_possible_drivers"
978 echo
979 exit 1
982 esac
983 done
985 ##########################################
986 # BrlAPI probe
988 if test -z "$brlapi" ; then
989 brlapi=no
990 cat > $TMPC << EOF
991 #include <brlapi.h>
992 int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
994 if $cc ${ARCH_CFLAGS} -o $TMPE ${OS_CFLAGS} $TMPC -lbrlapi > /dev/null 2> /dev/null ; then
995 brlapi=yes
996 fi # brlapi compile test
997 fi # -z $brlapi
999 ##########################################
1000 # curses probe
1002 if test "$curses" = "yes" ; then
1003 curses=no
1004 cat > $TMPC << EOF
1005 #include <curses.h>
1006 int main(void) { return curses_version(); }
1008 if $cc $ARCH_CFLAGS -o $TMPE $TMPC -lcurses > /dev/null 2> /dev/null ; then
1009 curses=yes
1011 fi # test "$curses"
1013 ##########################################
1014 # bluez support probe
1015 if test "$bluez" = "yes" ; then
1016 `pkg-config bluez` || bluez="no"
1018 if test "$bluez" = "yes" ; then
1019 cat > $TMPC << EOF
1020 #include <bluetooth/bluetooth.h>
1021 int main(void) { return bt_error(0); }
1023 bluez_cflags=`pkg-config --cflags bluez`
1024 bluez_libs=`pkg-config --libs bluez`
1025 if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $bluez_cflags $TMPC \
1026 $bluez_libs > /dev/null 2> /dev/null ; then
1028 else
1029 bluez="no"
1033 ##########################################
1034 # kvm probe
1035 if test "$kvm" = "yes" ; then
1036 cat > $TMPC <<EOF
1037 #include <linux/kvm.h>
1038 #if !defined(KVM_API_VERSION) || KVM_API_VERSION < 12 || KVM_API_VERSION > 12
1039 #error Invalid KVM version
1040 #endif
1041 #if !defined(KVM_CAP_USER_MEMORY)
1042 #error Missing KVM capability KVM_CAP_USER_MEMORY
1043 #endif
1044 #if !defined(KVM_CAP_SET_TSS_ADDR)
1045 #error Missing KVM capability KVM_CAP_SET_TSS_ADDR
1046 #endif
1047 #if !defined(KVM_CAP_DESTROY_MEMORY_REGION_WORKS)
1048 #error Missing KVM capability KVM_CAP_DESTROY_MEMORY_REGION_WORKS
1049 #endif
1050 int main(void) { return 0; }
1052 if test "$kerneldir" != "" ; then
1053 kvm_cflags=-I"$kerneldir"/include
1054 if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) \
1055 -a -d "$kerneldir/arch/x86/include" ; then
1056 kvm_cflags="$kvm_cflags -I$kerneldir/arch/x86/include"
1057 elif test "$cpu" = "ppc" -a -d "$kerneldir/arch/powerpc/include" ; then
1058 kvm_cflags="$kvm_cflags -I$kerneldir/arch/powerpc/include"
1059 elif test -d "$kerneldir/arch/$cpu/include" ; then
1060 kvm_cflags="$kvm_cflags -I$kerneldir/arch/$cpu/include"
1062 else
1063 kvm_cflags=""
1065 if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $kvm_cflags $TMPC \
1066 > /dev/null 2>/dev/null ; then
1068 else
1069 kvm="no";
1070 if [ -x "`which awk 2>/dev/null`" ] && \
1071 [ -x "`which grep 2>/dev/null`" ]; then
1072 kvmerr=`LANG=C $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $kvm_cflags $TMPC 2>&1 \
1073 | grep "error: " \
1074 | awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'`
1075 if test "$kvmerr" != "" ; then
1076 kvm="no - (${kvmerr})"
1082 ##########################################
1083 # AIO probe
1084 AIOLIBS=""
1086 if test "$aio" = "yes" ; then
1087 aio=no
1088 cat > $TMPC << EOF
1089 #include <pthread.h>
1090 int main(void) { pthread_mutex_t lock; return 0; }
1092 if $cc $ARCH_CFLAGS -o $TMPE $AIOLIBS $TMPC 2> /dev/null ; then
1093 aio=yes
1094 AIOLIBS="-lpthread"
1098 ##########################################
1099 # iovec probe
1100 cat > $TMPC <<EOF
1101 #include <sys/types.h>
1102 #include <sys/uio.h>
1103 #include <unistd.h>
1104 int main(void) { struct iovec iov; return 0; }
1106 iovec=no
1107 if $cc $ARCH_CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
1108 iovec=yes
1111 ##########################################
1112 # fdt probe
1113 if test "$fdt" = "yes" ; then
1114 fdt=no
1115 cat > $TMPC << EOF
1116 int main(void) { return 0; }
1118 if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $TMPC -lfdt 2> /dev/null ; then
1119 fdt=yes
1123 ##########################################
1124 # signalfd probe
1125 cat > $TMPC << EOF
1126 #define _GNU_SOURCE
1127 #include <unistd.h>
1128 #include <sys/syscall.h>
1129 #include <signal.h>
1130 int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
1133 if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
1134 signalfd=yes
1137 ##########################################
1138 # eventfd probe
1139 cat > $TMPC << EOF
1140 #define _GNU_SOURCE
1141 #include <unistd.h>
1142 #include <sys/syscall.h>
1143 int main(void) { return syscall(SYS_eventfd, 0); }
1146 if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
1147 eventfd=yes
1150 # Check if tools are available to build documentation.
1151 if [ -x "`which texi2html 2>/dev/null`" ] && \
1152 [ -x "`which pod2man 2>/dev/null`" ]; then
1153 build_docs="yes"
1156 ##########################################
1157 # Do we need librt
1158 cat > $TMPC <<EOF
1159 #include <signal.h>
1160 #include <time.h>
1161 int main(void) { clockid_t id; return clock_gettime(id, NULL); }
1164 rt=no
1165 if $cc $ARCH_CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
1167 elif $cc $ARCH_CFLAGS -o $TMPE $TMPC -lrt > /dev/null 2> /dev/null ; then
1168 rt=yes
1171 if test "$rt" = "yes" ; then
1172 # Hack, we should have a general purpose LIBS for this sort of thing
1173 AIOLIBS="$AIOLIBS -lrt"
1176 if test "$mingw32" = "yes" ; then
1177 if test -z "$prefix" ; then
1178 prefix="c:\\\\Program Files\\\\Qemu"
1180 mansuffix=""
1181 datasuffix=""
1182 docsuffix=""
1183 binsuffix=""
1184 else
1185 if test -z "$prefix" ; then
1186 prefix="/usr/local"
1188 mansuffix="/share/man"
1189 datasuffix="/share/qemu"
1190 docsuffix="/share/doc/qemu"
1191 binsuffix="/bin"
1194 echo "Install prefix $prefix"
1195 echo "BIOS directory $prefix$datasuffix"
1196 echo "binary directory $prefix$binsuffix"
1197 if test "$mingw32" = "no" ; then
1198 echo "Manual directory $prefix$mansuffix"
1199 echo "ELF interp prefix $interp_prefix"
1201 echo "Source path $source_path"
1202 echo "C compiler $cc"
1203 echo "Host C compiler $host_cc"
1204 echo "ARCH_CFLAGS $ARCH_CFLAGS"
1205 echo "make $make"
1206 echo "install $install"
1207 echo "host CPU $cpu"
1208 echo "host big endian $bigendian"
1209 echo "target list $target_list"
1210 echo "gprof enabled $gprof"
1211 echo "sparse enabled $sparse"
1212 echo "profiler $profiler"
1213 echo "static build $static"
1214 echo "-Werror enabled $werror"
1215 if test "$darwin" = "yes" ; then
1216 echo "Cocoa support $cocoa"
1218 echo "SDL support $sdl"
1219 if test "$sdl" != "no" ; then
1220 echo "SDL static link $sdl_static"
1222 echo "curses support $curses"
1223 echo "mingw32 support $mingw32"
1224 echo "Audio drivers $audio_drv_list"
1225 echo "Extra audio cards $audio_card_list"
1226 echo "Mixer emulation $mixemu"
1227 echo "VNC TLS support $vnc_tls"
1228 if test "$vnc_tls" = "yes" ; then
1229 echo " TLS CFLAGS $vnc_tls_cflags"
1230 echo " TLS LIBS $vnc_tls_libs"
1232 if test -n "$sparc_cpu"; then
1233 echo "Target Sparc Arch $sparc_cpu"
1235 echo "kqemu support $kqemu"
1236 echo "kvm support $kvm"
1237 echo "CPU emulation $cpu_emulation"
1238 echo "brlapi support $brlapi"
1239 echo "Documentation $build_docs"
1240 [ ! -z "$uname_release" ] && \
1241 echo "uname -r $uname_release"
1242 echo "NPTL support $nptl"
1243 echo "vde support $vde"
1244 echo "AIO support $aio"
1245 echo "Install blobs $blobs"
1246 echo "KVM support $kvm"
1247 echo "fdt support $fdt"
1249 if test $sdl_too_old = "yes"; then
1250 echo "-> Your SDL version is too old - please upgrade to have SDL support"
1252 if [ -s $TMPSDLLOG ]; then
1253 echo "The error log from compiling the libSDL test is: "
1254 cat $TMPSDLLOG
1256 #if test "$sdl_static" = "no"; then
1257 # echo "WARNING: cannot compile statically with SDL - qemu-fast won't have a graphical output"
1259 config_mak="config-host.mak"
1260 config_h="config-host.h"
1262 #echo "Creating $config_mak and $config_h"
1264 test -f $config_h && mv $config_h ${config_h}~
1266 echo "# Automatically generated by configure - do not modify" > $config_mak
1267 printf "# Configured with:" >> $config_mak
1268 printf " '%s'" "$0" "$@" >> $config_mak
1269 echo >> $config_mak
1270 echo "/* Automatically generated by configure - do not modify */" > $config_h
1272 echo "prefix=$prefix" >> $config_mak
1273 echo "bindir=\${prefix}$binsuffix" >> $config_mak
1274 echo "mandir=\${prefix}$mansuffix" >> $config_mak
1275 echo "datadir=\${prefix}$datasuffix" >> $config_mak
1276 echo "docdir=\${prefix}$docsuffix" >> $config_mak
1277 echo "#define CONFIG_QEMU_SHAREDIR \"$prefix$datasuffix\"" >> $config_h
1278 echo "MAKE=$make" >> $config_mak
1279 echo "INSTALL=$install" >> $config_mak
1280 echo "CC=$cc" >> $config_mak
1281 echo "HOST_CC=$host_cc" >> $config_mak
1282 echo "AR=$ar" >> $config_mak
1283 echo "STRIP=$strip -s -R .comment -R .note" >> $config_mak
1284 # XXX: only use CFLAGS and LDFLAGS ?
1285 # XXX: should export HOST_CFLAGS and HOST_LDFLAGS for cross
1286 # compilation of dyngen tool (useful for win32 build on Linux host)
1287 echo "OS_CFLAGS=$OS_CFLAGS" >> $config_mak
1288 echo "OS_LDFLAGS=$OS_LDFLAGS" >> $config_mak
1289 echo "ARCH_CFLAGS=$ARCH_CFLAGS" >> $config_mak
1290 echo "ARCH_LDFLAGS=$ARCH_LDFLAGS" >> $config_mak
1291 echo "CFLAGS=$CFLAGS" >> $config_mak
1292 echo "LDFLAGS=$LDFLAGS" >> $config_mak
1293 echo "EXESUF=$EXESUF" >> $config_mak
1294 echo "AIOLIBS=$AIOLIBS" >> $config_mak
1295 case "$cpu" in
1296 i386)
1297 echo "ARCH=i386" >> $config_mak
1298 echo "#define HOST_I386 1" >> $config_h
1300 x86_64)
1301 echo "ARCH=x86_64" >> $config_mak
1302 echo "#define HOST_X86_64 1" >> $config_h
1304 alpha)
1305 echo "ARCH=alpha" >> $config_mak
1306 echo "#define HOST_ALPHA 1" >> $config_h
1308 armv4b)
1309 echo "ARCH=arm" >> $config_mak
1310 echo "#define HOST_ARM 1" >> $config_h
1312 armv4l)
1313 echo "ARCH=arm" >> $config_mak
1314 echo "#define HOST_ARM 1" >> $config_h
1316 cris)
1317 echo "ARCH=cris" >> $config_mak
1318 echo "#define HOST_CRIS 1" >> $config_h
1320 hppa)
1321 echo "ARCH=hppa" >> $config_mak
1322 echo "#define HOST_HPPA 1" >> $config_h
1324 ia64)
1325 echo "ARCH=ia64" >> $config_mak
1326 echo "#define HOST_IA64 1" >> $config_h
1328 m68k)
1329 echo "ARCH=m68k" >> $config_mak
1330 echo "#define HOST_M68K 1" >> $config_h
1332 mips)
1333 echo "ARCH=mips" >> $config_mak
1334 echo "#define HOST_MIPS 1" >> $config_h
1336 mips64)
1337 echo "ARCH=mips64" >> $config_mak
1338 echo "#define HOST_MIPS64 1" >> $config_h
1340 ppc)
1341 echo "ARCH=ppc" >> $config_mak
1342 echo "#define HOST_PPC 1" >> $config_h
1344 ppc64)
1345 echo "ARCH=ppc64" >> $config_mak
1346 echo "#define HOST_PPC64 1" >> $config_h
1348 s390)
1349 echo "ARCH=s390" >> $config_mak
1350 echo "#define HOST_S390 1" >> $config_h
1352 sparc)
1353 echo "ARCH=sparc" >> $config_mak
1354 echo "#define HOST_SPARC 1" >> $config_h
1356 sparc64)
1357 echo "ARCH=sparc64" >> $config_mak
1358 echo "#define HOST_SPARC64 1" >> $config_h
1361 echo "Unsupported CPU = $cpu"
1362 exit 1
1364 esac
1365 if test "$sparse" = "yes" ; then
1366 echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_mak
1367 echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_mak
1368 echo "CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_mak
1370 if test "$bigendian" = "yes" ; then
1371 echo "WORDS_BIGENDIAN=yes" >> $config_mak
1372 echo "#define WORDS_BIGENDIAN 1" >> $config_h
1374 echo "#define HOST_LONG_BITS $hostlongbits" >> $config_h
1375 if test "$mingw32" = "yes" ; then
1376 echo "CONFIG_WIN32=yes" >> $config_mak
1377 echo "#define CONFIG_WIN32 1" >> $config_h
1378 else
1379 cat > $TMPC << EOF
1380 #include <byteswap.h>
1381 int main(void) { return bswap_32(0); }
1383 if $cc $ARCH_CFLAGS -o $TMPE $TMPC >/dev/null 2> /dev/null ; then
1384 echo "#define HAVE_BYTESWAP_H 1" >> $config_h
1386 cat > $TMPC << EOF
1387 #include <sys/endian.h>
1388 #include <sys/types.h>
1389 #include <machine/bswap.h>
1390 int main(void) { return bswap32(0); }
1392 if $cc $ARCH_CFLAGS -o $TMPE $TMPC >/dev/null 2> /dev/null ; then
1393 echo "#define HAVE_MACHINE_BSWAP_H 1" >> $config_h
1397 if [ "$openbsd" = "yes" ] ; then
1398 echo "#define ENOTSUP 4096" >> $config_h
1401 if test "$darwin" = "yes" ; then
1402 echo "CONFIG_DARWIN=yes" >> $config_mak
1403 echo "#define CONFIG_DARWIN 1" >> $config_h
1406 if test "$aix" = "yes" ; then
1407 echo "CONFIG_AIX=yes" >> $config_mak
1408 echo "#define CONFIG_AIX 1" >> $config_h
1411 if test "$solaris" = "yes" ; then
1412 echo "CONFIG_SOLARIS=yes" >> $config_mak
1413 echo "#define HOST_SOLARIS $solarisrev" >> $config_h
1414 if test "$needs_libsunmath" = "yes" ; then
1415 echo "NEEDS_LIBSUNMATH=yes" >> $config_mak
1416 echo "#define NEEDS_LIBSUNMATH 1" >> $config_h
1419 if test -n "$sparc_cpu"; then
1420 echo "CONFIG__sparc_${sparc_cpu}__=yes" >> $config_mak
1421 echo "#define __sparc_${sparc_cpu}__ 1" >> $config_h
1423 if test "$gdbstub" = "yes" ; then
1424 echo "CONFIG_GDBSTUB=yes" >> $config_mak
1425 echo "#define CONFIG_GDBSTUB 1" >> $config_h
1427 if test "$gprof" = "yes" ; then
1428 echo "TARGET_GPROF=yes" >> $config_mak
1429 echo "#define HAVE_GPROF 1" >> $config_h
1431 if test "$static" = "yes" ; then
1432 echo "CONFIG_STATIC=yes" >> $config_mak
1433 echo "#define CONFIG_STATIC 1" >> $config_h
1435 if test $profiler = "yes" ; then
1436 echo "#define CONFIG_PROFILER 1" >> $config_h
1438 if test "$slirp" = "yes" ; then
1439 echo "CONFIG_SLIRP=yes" >> $config_mak
1440 echo "#define CONFIG_SLIRP 1" >> $config_h
1442 if test "$vde" = "yes" ; then
1443 echo "CONFIG_VDE=yes" >> $config_mak
1444 echo "#define CONFIG_VDE 1" >> $config_h
1445 echo "VDE_LIBS=-lvdeplug" >> $config_mak
1447 for card in $audio_card_list; do
1448 def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
1449 echo "$def=yes" >> $config_mak
1450 echo "#define $def 1" >> $config_h
1451 done
1452 echo "#define AUDIO_DRIVERS \\" >> $config_h
1453 for drv in $audio_drv_list; do
1454 echo " &${drv}_audio_driver, \\" >>$config_h
1455 def=CONFIG_`echo $drv | tr '[:lower:]' '[:upper:]'`
1456 echo "$def=yes" >> $config_mak
1457 if test "$drv" = "fmod"; then
1458 echo "CONFIG_FMOD_LIB=$fmod_lib" >> $config_mak
1459 echo "CONFIG_FMOD_INC=$fmod_inc" >> $config_mak
1460 elif test "$drv" = "oss"; then
1461 echo "CONFIG_OSS_LIB=$oss_lib" >> $config_mak
1463 done
1464 echo "" >>$config_h
1465 if test "$mixemu" = "yes" ; then
1466 echo "CONFIG_MIXEMU=yes" >> $config_mak
1467 echo "#define CONFIG_MIXEMU 1" >> $config_h
1469 if test "$vnc_tls" = "yes" ; then
1470 echo "CONFIG_VNC_TLS=yes" >> $config_mak
1471 echo "CONFIG_VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_mak
1472 echo "CONFIG_VNC_TLS_LIBS=$vnc_tls_libs" >> $config_mak
1473 echo "#define CONFIG_VNC_TLS 1" >> $config_h
1475 qemu_version=`head $source_path/VERSION`
1476 echo "VERSION=$qemu_version" >>$config_mak
1477 echo "#define QEMU_VERSION \"$qemu_version\"" >> $config_h
1478 echo "#define KVM_VERSION \"kvm-devel\"" >> $config_h
1480 echo "SRC_PATH=$source_path" >> $config_mak
1481 if [ "$source_path_used" = "yes" ]; then
1482 echo "VPATH=$source_path" >> $config_mak
1484 echo "TARGET_DIRS=$target_list" >> $config_mak
1485 if [ "$build_docs" = "yes" ] ; then
1486 echo "BUILD_DOCS=yes" >> $config_mak
1488 if test "$static" = "yes"; then
1489 sdl1=$sdl_static
1490 else
1491 sdl1=$sdl
1493 if test "$sdl1" = "yes" ; then
1494 echo "#define CONFIG_SDL 1" >> $config_h
1495 echo "CONFIG_SDL=yes" >> $config_mak
1496 if test "$target_softmmu" = "no" -o "$static" = "yes"; then
1497 echo "SDL_LIBS=$sdl_static_libs" >> $config_mak
1498 elif test "$sdl_x11" = "yes" ; then
1499 echo "SDL_LIBS=`$sdl_config --libs` -lX11" >> $config_mak
1500 else
1501 echo "SDL_LIBS=`$sdl_config --libs`" >> $config_mak
1503 if [ "${aa}" = "yes" ] ; then
1504 echo "SDL_CFLAGS=`$sdl_config --cflags` `aalib-config --cflags`" >> $config_mak
1505 else
1506 echo "SDL_CFLAGS=`$sdl_config --cflags`" >> $config_mak
1509 if test "$cocoa" = "yes" ; then
1510 echo "#define CONFIG_COCOA 1" >> $config_h
1511 echo "CONFIG_COCOA=yes" >> $config_mak
1513 if test "$curses" = "yes" ; then
1514 echo "#define CONFIG_CURSES 1" >> $config_h
1515 echo "CONFIG_CURSES=yes" >> $config_mak
1516 echo "CURSES_LIBS=-lcurses" >> $config_mak
1518 if test "$brlapi" = "yes" ; then
1519 echo "CONFIG_BRLAPI=yes" >> $config_mak
1520 echo "#define CONFIG_BRLAPI 1" >> $config_h
1521 echo "BRLAPI_LIBS=-lbrlapi" >> $config_mak
1523 if test "$bluez" = "yes" ; then
1524 echo "CONFIG_BLUEZ=yes" >> $config_mak
1525 echo "CONFIG_BLUEZ_CFLAGS=$bluez_cflags" >> $config_mak
1526 echo "CONFIG_BLUEZ_LIBS=$bluez_libs" >> $config_mak
1527 echo "#define CONFIG_BLUEZ 1" >> $config_h
1529 if test "$aio" = "yes" ; then
1530 echo "#define CONFIG_AIO 1" >> $config_h
1531 echo "CONFIG_AIO=yes" >> $config_mak
1533 if test "$blobs" = "yes" ; then
1534 echo "INSTALL_BLOBS=yes" >> $config_mak
1536 if test "$iovec" = "yes" ; then
1537 echo "#define HAVE_IOVEC 1" >> $config_h
1539 if test "$fdt" = "yes" ; then
1540 echo "#define HAVE_FDT 1" >> $config_h
1541 echo "FDT_LIBS=-lfdt" >> $config_mak
1543 if test "$signalfd" = "yes" ; then
1544 echo "#define CONFIG_signalfd 1" >> $config_h
1546 if test "$eventfd" = "yes" ; then
1547 echo "#define CONFIG_eventfd 1" >> $config_h
1550 # XXX: suppress that
1551 if [ "$bsd" = "yes" ] ; then
1552 echo "#define O_LARGEFILE 0" >> $config_h
1553 echo "#define MAP_ANONYMOUS MAP_ANON" >> $config_h
1554 echo "#define _BSD 1" >> $config_h
1557 echo "#define CONFIG_UNAME_RELEASE \"$uname_release\"" >> $config_h
1559 # USB host support
1560 case "$usb" in
1561 linux)
1562 echo "HOST_USB=linux" >> $config_mak
1564 bsd)
1565 echo "HOST_USB=bsd" >> $config_mak
1568 echo "HOST_USB=stub" >> $config_mak
1570 esac
1572 tools=
1573 if test `expr "$target_list" : ".*softmmu.*"` != 0 ; then
1574 tools="qemu-img\$(EXESUF) $tools"
1575 if [ "$linux" = "yes" ] ; then
1576 tools="qemu-nbd\$(EXESUF) $tools"
1579 echo "TOOLS=$tools" >> $config_mak
1581 test -f ${config_h}~ && cmp -s $config_h ${config_h}~ && mv ${config_h}~ $config_h
1583 for target in $target_list; do
1584 target_dir="$target"
1585 config_mak=$target_dir/config.mak
1586 config_h=$target_dir/config.h
1587 target_cpu=`echo $target | cut -d '-' -f 1`
1588 target_bigendian="no"
1589 [ "$target_cpu" = "armeb" ] && target_bigendian=yes
1590 [ "$target_cpu" = "m68k" ] && target_bigendian=yes
1591 [ "$target_cpu" = "mips" ] && target_bigendian=yes
1592 [ "$target_cpu" = "mipsn32" ] && target_bigendian=yes
1593 [ "$target_cpu" = "mips64" ] && target_bigendian=yes
1594 [ "$target_cpu" = "ppc" ] && target_bigendian=yes
1595 [ "$target_cpu" = "ppcemb" ] && target_bigendian=yes
1596 [ "$target_cpu" = "ppc64" ] && target_bigendian=yes
1597 [ "$target_cpu" = "ppc64abi32" ] && target_bigendian=yes
1598 [ "$target_cpu" = "sh4eb" ] && target_bigendian=yes
1599 [ "$target_cpu" = "sparc" ] && target_bigendian=yes
1600 [ "$target_cpu" = "sparc64" ] && target_bigendian=yes
1601 [ "$target_cpu" = "sparc32plus" ] && target_bigendian=yes
1602 target_softmmu="no"
1603 target_user_only="no"
1604 target_linux_user="no"
1605 target_darwin_user="no"
1606 target_bsd_user="no"
1607 case "$target" in
1608 ${target_cpu}-softmmu)
1609 target_softmmu="yes"
1611 ${target_cpu}-linux-user)
1612 target_user_only="yes"
1613 target_linux_user="yes"
1615 ${target_cpu}-darwin-user)
1616 target_user_only="yes"
1617 target_darwin_user="yes"
1619 ${target_cpu}-bsd-user)
1620 target_user_only="yes"
1621 target_bsd_user="yes"
1624 echo "ERROR: Target '$target' not recognised"
1625 exit 1
1627 esac
1629 if test "$target_user_only" = "no" -a "$check_gfx" = "yes" \
1630 -a "$sdl" = "no" -a "$cocoa" = "no" ; then
1631 echo "ERROR: QEMU requires SDL or Cocoa for graphical output"
1632 echo "To build QEMU without graphical output configure with --disable-gfx-check"
1633 echo "Note that this will disable all output from the virtual graphics card"
1634 echo "except through VNC or curses."
1635 exit 1;
1638 #echo "Creating $config_mak, $config_h and $target_dir/Makefile"
1640 test -f $config_h && mv $config_h ${config_h}~
1642 mkdir -p $target_dir
1643 mkdir -p $target_dir/fpu
1644 mkdir -p $target_dir/tcg
1645 if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
1646 mkdir -p $target_dir/nwfpe
1650 # don't use ln -sf as not all "ln -sf" over write the file/link
1652 rm -f $target_dir/Makefile
1653 ln -s $source_path/Makefile.target $target_dir/Makefile
1656 echo "# Automatically generated by configure - do not modify" > $config_mak
1657 echo "/* Automatically generated by configure - do not modify */" > $config_h
1660 echo "include ../config-host.mak" >> $config_mak
1661 echo "#include \"../config-host.h\"" >> $config_h
1663 bflt="no"
1664 elfload32="no"
1665 target_nptl="no"
1666 interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_cpu/g"`
1667 echo "#define CONFIG_QEMU_PREFIX \"$interp_prefix1\"" >> $config_h
1668 gdb_xml_files=""
1670 disable_cpu_emulation() {
1671 if test $cpu_emulation = "no"; then
1672 echo "#define NO_CPU_EMULATION 1" >> $config_h
1673 echo "NO_CPU_EMULATION=1" >> $config_mak
1677 configure_kvm() {
1678 if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
1679 \( "$cpu" = "i386" -o "$cpu" = "x86_64" -o "$cpu" = "ia64" -o "$cpu" = "powerpc" \); then
1680 echo "#define USE_KVM 1" >> $config_h
1681 echo "USE_KVM=1" >> $config_mak
1682 echo "CONFIG_KVM_KERNEL_INC=$kerneldir/include" >> "config-host.mak"
1683 if test $kvm_cap_pit = "yes" ; then
1684 echo "USE_KVM_PIT=1" >> $config_mak
1685 echo "#define USE_KVM_PIT 1" >> $config_h
1687 if test $kvm_cap_device_assignment = "yes" ; then
1688 echo "USE_KVM_DEVICE_ASSIGNMENT=1" >> $config_mak
1689 echo "#define USE_KVM_DEVICE_ASSIGNMENT 1" >> $config_h
1691 disable_cpu_emulation
1695 if [ use_upstream_kvm = yes ]; then
1697 # Make sure the target and host cpus are compatible
1698 if test "$kvm" = "yes" -a ! \( "$target_cpu" = "$cpu" -o \
1699 \( "$target_cpu" = "ppcemb" -a "$cpu" = "ppc" \) -o \
1700 \( "$target_cpu" = "x86_64" -a "$cpu" = "i386" \) -o \
1701 \( "$target_cpu" = "i386" -a "$cpu" = "x86_64" \) \) ; then
1702 kvm="no"
1704 # Disable KVM for linux-user
1705 if test "$kvm" = "yes" -a "$target_softmmu" = "no" ; then
1706 kvm="no"
1711 case "$target_cpu" in
1712 i386)
1713 echo "TARGET_ARCH=i386" >> $config_mak
1714 echo "#define TARGET_ARCH \"i386\"" >> $config_h
1715 echo "#define TARGET_I386 1" >> $config_h
1716 if test $kqemu = "yes" -a "$target_softmmu" = "yes"
1717 then
1718 echo "#define USE_KQEMU 1" >> $config_h
1720 if test "$kvm" = "yes" ; then
1721 echo "USE_KVM=yes" >> $config_mak
1722 echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak
1723 echo "#define USE_KVM 1" >> $config_h
1725 configure_kvm
1727 x86_64)
1728 echo "TARGET_ARCH=x86_64" >> $config_mak
1729 echo "#define TARGET_ARCH \"x86_64\"" >> $config_h
1730 echo "#define TARGET_I386 1" >> $config_h
1731 echo "#define TARGET_X86_64 1" >> $config_h
1732 if test $kqemu = "yes" -a "$target_softmmu" = "yes" -a $cpu = "x86_64"
1733 then
1734 echo "#define USE_KQEMU 1" >> $config_h
1736 configure_kvm
1738 ia64)
1739 echo "TARGET_ARCH=ia64" >> $config_mak
1740 echo "#define TARGET_ARCH \"ia64\"" >> $config_h
1741 echo "#define TARGET_IA64 1" >> $config_h
1742 configure_kvm
1743 if [ use_upstream_kvm = yes ]; then
1744 if test "$kvm" = "yes" ; then
1745 echo "USE_KVM=yes" >> $config_mak
1746 echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak
1747 echo "#define USE_KVM 1" >> $config_h
1751 alpha)
1752 echo "TARGET_ARCH=alpha" >> $config_mak
1753 echo "#define TARGET_ARCH \"alpha\"" >> $config_h
1754 echo "#define TARGET_ALPHA 1" >> $config_h
1756 arm|armeb)
1757 echo "TARGET_ARCH=arm" >> $config_mak
1758 echo "#define TARGET_ARCH \"arm\"" >> $config_h
1759 echo "#define TARGET_ARM 1" >> $config_h
1760 bflt="yes"
1761 target_nptl="yes"
1762 gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
1764 cris)
1765 echo "TARGET_ARCH=cris" >> $config_mak
1766 echo "#define TARGET_ARCH \"cris\"" >> $config_h
1767 echo "#define TARGET_CRIS 1" >> $config_h
1768 target_nptl="yes"
1770 m68k)
1771 echo "TARGET_ARCH=m68k" >> $config_mak
1772 echo "#define TARGET_ARCH \"m68k\"" >> $config_h
1773 echo "#define TARGET_M68K 1" >> $config_h
1774 bflt="yes"
1775 gdb_xml_files="cf-core.xml cf-fp.xml"
1777 mips|mipsel)
1778 echo "TARGET_ARCH=mips" >> $config_mak
1779 echo "#define TARGET_ARCH \"mips\"" >> $config_h
1780 echo "#define TARGET_MIPS 1" >> $config_h
1781 echo "#define TARGET_ABI_MIPSO32 1" >> $config_h
1783 mipsn32|mipsn32el)
1784 echo "TARGET_ARCH=mipsn32" >> $config_mak
1785 echo "#define TARGET_ARCH \"mipsn32\"" >> $config_h
1786 echo "#define TARGET_MIPS 1" >> $config_h
1787 echo "#define TARGET_ABI_MIPSN32 1" >> $config_h
1789 mips64|mips64el)
1790 echo "TARGET_ARCH=mips64" >> $config_mak
1791 echo "#define TARGET_ARCH \"mips64\"" >> $config_h
1792 echo "#define TARGET_MIPS 1" >> $config_h
1793 echo "#define TARGET_MIPS64 1" >> $config_h
1794 echo "#define TARGET_ABI_MIPSN64 1" >> $config_h
1796 ppc)
1797 echo "TARGET_ARCH=ppc" >> $config_mak
1798 echo "#define TARGET_ARCH \"ppc\"" >> $config_h
1799 echo "#define TARGET_PPC 1" >> $config_h
1800 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
1802 ppcemb)
1803 echo "TARGET_ARCH=ppcemb" >> $config_mak
1804 echo "TARGET_ABI_DIR=ppc" >> $config_mak
1805 echo "#define TARGET_ARCH \"ppcemb\"" >> $config_h
1806 echo "#define TARGET_PPC 1" >> $config_h
1807 echo "#define TARGET_PPCEMB 1" >> $config_h
1808 if test "$kvm" = "yes" ; then
1809 echo "USE_KVM=yes" >> $config_mak
1810 echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak
1811 echo "#define USE_KVM 1" >> $config_h
1813 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
1815 ppc64)
1816 echo "TARGET_ARCH=ppc64" >> $config_mak
1817 echo "TARGET_ABI_DIR=ppc" >> $config_mak
1818 echo "#define TARGET_ARCH \"ppc64\"" >> $config_h
1819 echo "#define TARGET_PPC 1" >> $config_h
1820 echo "#define TARGET_PPC64 1" >> $config_h
1821 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
1823 ppc64abi32)
1824 echo "TARGET_ARCH=ppc64" >> $config_mak
1825 echo "TARGET_ABI_DIR=ppc" >> $config_mak
1826 echo "TARGET_ARCH2=ppc64abi32" >> $config_mak
1827 echo "#define TARGET_ARCH \"ppc64\"" >> $config_h
1828 echo "#define TARGET_PPC 1" >> $config_h
1829 echo "#define TARGET_PPC64 1" >> $config_h
1830 echo "#define TARGET_ABI32 1" >> $config_h
1831 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
1833 sh4|sh4eb)
1834 echo "TARGET_ARCH=sh4" >> $config_mak
1835 echo "#define TARGET_ARCH \"sh4\"" >> $config_h
1836 echo "#define TARGET_SH4 1" >> $config_h
1837 bflt="yes"
1838 target_nptl="yes"
1840 sparc)
1841 echo "TARGET_ARCH=sparc" >> $config_mak
1842 echo "#define TARGET_ARCH \"sparc\"" >> $config_h
1843 echo "#define TARGET_SPARC 1" >> $config_h
1845 sparc64)
1846 echo "TARGET_ARCH=sparc64" >> $config_mak
1847 echo "#define TARGET_ARCH \"sparc64\"" >> $config_h
1848 echo "#define TARGET_SPARC 1" >> $config_h
1849 echo "#define TARGET_SPARC64 1" >> $config_h
1850 elfload32="yes"
1852 sparc32plus)
1853 echo "TARGET_ARCH=sparc64" >> $config_mak
1854 echo "TARGET_ABI_DIR=sparc" >> $config_mak
1855 echo "TARGET_ARCH2=sparc32plus" >> $config_mak
1856 echo "#define TARGET_ARCH \"sparc64\"" >> $config_h
1857 echo "#define TARGET_SPARC 1" >> $config_h
1858 echo "#define TARGET_SPARC64 1" >> $config_h
1859 echo "#define TARGET_ABI32 1" >> $config_h
1862 echo "Unsupported target CPU"
1863 exit 1
1865 esac
1866 if test "$target_bigendian" = "yes" ; then
1867 echo "TARGET_WORDS_BIGENDIAN=yes" >> $config_mak
1868 echo "#define TARGET_WORDS_BIGENDIAN 1" >> $config_h
1870 if test "$target_softmmu" = "yes" ; then
1871 echo "CONFIG_SOFTMMU=yes" >> $config_mak
1872 echo "#define CONFIG_SOFTMMU 1" >> $config_h
1874 if test "$target_user_only" = "yes" ; then
1875 echo "CONFIG_USER_ONLY=yes" >> $config_mak
1876 echo "#define CONFIG_USER_ONLY 1" >> $config_h
1878 if test "$target_linux_user" = "yes" ; then
1879 echo "CONFIG_LINUX_USER=yes" >> $config_mak
1880 echo "#define CONFIG_LINUX_USER 1" >> $config_h
1882 if test "$target_darwin_user" = "yes" ; then
1883 echo "CONFIG_DARWIN_USER=yes" >> $config_mak
1884 echo "#define CONFIG_DARWIN_USER 1" >> $config_h
1886 list=""
1887 if test ! -z "$gdb_xml_files" ; then
1888 for x in $gdb_xml_files; do
1889 list="$list $source_path/gdb-xml/$x"
1890 done
1892 echo "TARGET_XML_FILES=$list" >> $config_mak
1894 if test "$target_cpu" = "arm" \
1895 -o "$target_cpu" = "armeb" \
1896 -o "$target_cpu" = "m68k" \
1897 -o "$target_cpu" = "mips" \
1898 -o "$target_cpu" = "mipsel" \
1899 -o "$target_cpu" = "mipsn32" \
1900 -o "$target_cpu" = "mipsn32el" \
1901 -o "$target_cpu" = "mips64" \
1902 -o "$target_cpu" = "mips64el" \
1903 -o "$target_cpu" = "ppc" \
1904 -o "$target_cpu" = "ppc64" \
1905 -o "$target_cpu" = "ppc64abi32" \
1906 -o "$target_cpu" = "ppcemb" \
1907 -o "$target_cpu" = "sparc" \
1908 -o "$target_cpu" = "sparc64" \
1909 -o "$target_cpu" = "sparc32plus"; then
1910 echo "CONFIG_SOFTFLOAT=yes" >> $config_mak
1911 echo "#define CONFIG_SOFTFLOAT 1" >> $config_h
1913 if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
1914 echo "TARGET_HAS_BFLT=yes" >> $config_mak
1915 echo "#define TARGET_HAS_BFLT 1" >> $config_h
1917 if test "$target_user_only" = "yes" \
1918 -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
1919 echo "#define USE_NPTL 1" >> $config_h
1921 # 32 bit ELF loader in addition to native 64 bit loader?
1922 if test "$target_user_only" = "yes" -a "$elfload32" = "yes"; then
1923 echo "TARGET_HAS_ELFLOAD32=yes" >> $config_mak
1924 echo "#define TARGET_HAS_ELFLOAD32 1" >> $config_h
1926 if test "$target_bsd_user" = "yes" ; then
1927 echo "CONFIG_BSD_USER=yes" >> $config_mak
1928 echo "#define CONFIG_BSD_USER 1" >> $config_h
1931 test -f ${config_h}~ && cmp -s $config_h ${config_h}~ && mv ${config_h}~ $config_h
1933 done # for target in $targets
1935 # build tree in object directory if source path is different from current one
1936 if test "$source_path_used" = "yes" ; then
1937 DIRS="tests tests/cris slirp audio"
1938 FILES="Makefile tests/Makefile"
1939 FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
1940 FILES="$FILES tests/test-mmap.c"
1941 for dir in $DIRS ; do
1942 mkdir -p $dir
1943 done
1944 # remove the link and recreate it, as not all "ln -sf" overwrite the link
1945 for f in $FILES ; do
1946 rm -f $f
1947 ln -s $source_path/$f $f
1948 done