Virtio-net: add a new virtio-net receive buffer scheme
[qemu-kvm/fedora.git] / configure
blob18ef980d2117c757f76830aca21fd16c5da43526
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"
20 # default parameters
21 prefix=""
22 interp_prefix="/usr/gnemul/qemu-%M"
23 static="no"
24 cross_prefix=""
25 cc="gcc"
26 gcc3_search="yes"
27 gcc3_list="gcc-3.4.6 gcc-3.4 gcc34 gcc-3.3.6 gcc-3.3 gcc33 gcc-3.2 gcc32"
28 audio_drv_list=""
29 audio_card_list=""
30 host_cc="gcc"
31 ar="ar"
32 make="make"
33 install="install"
34 strip="strip"
35 cpu=`test $(uname -s) = AIX && uname -p || uname -m`
36 target_list=""
37 case "$cpu" in
38 i386|i486|i586|i686|i86pc|BePC)
39 cpu="i386"
41 x86_64|amd64)
42 cpu="x86_64"
44 alpha)
45 cpu="alpha"
47 armv*b)
48 cpu="armv4b"
50 armv*l)
51 cpu="armv4l"
53 cris)
54 cpu="cris"
56 parisc|parisc64)
57 cpu="hppa"
59 ia64)
60 cpu="ia64"
62 m68k)
63 cpu="m68k"
65 mips)
66 cpu="mips"
68 mips64)
69 cpu="mips64"
71 "Power Macintosh"|ppc|ppc64|powerpc)
72 cpu="powerpc"
74 s390*)
75 cpu="s390"
77 sparc|sun4[cdmuv])
78 cpu="sparc"
80 sparc64)
81 cpu="sparc64"
84 cpu="unknown"
86 esac
87 gprof="no"
88 sparse="no"
89 bigendian="no"
90 mingw32="no"
91 EXESUF=""
92 gdbstub="yes"
93 slirp="yes"
94 vde="yes"
95 fmod_lib=""
96 fmod_inc=""
97 oss_lib=""
98 vnc_tls="yes"
99 bsd="no"
100 linux="no"
101 solaris="no"
102 kqemu="no"
103 profiler="no"
104 cocoa="no"
105 check_gfx="yes"
106 check_gcc="yes"
107 softmmu="yes"
108 linux_user="no"
109 darwin_user="no"
110 bsd_user="no"
111 build_docs="no"
112 uname_release=""
113 curses="yes"
114 aio="yes"
115 nptl="yes"
116 mixemu="no"
117 bluez="yes"
118 kvm="yes"
119 kvm_cap_pit="no"
120 kvm_cap_device_assignment="no"
121 kerneldir=""
122 aix="no"
123 signalfd="no"
124 eventfd="no"
125 cpu_emulation="yes"
126 device_tree_support=""
128 # OS specific
129 targetos=`uname -s`
130 case $targetos in
131 CYGWIN*)
132 mingw32="yes"
133 OS_CFLAGS="-mno-cygwin"
134 if [ "$cpu" = "i386" ] ; then
135 kqemu="yes"
137 audio_possible_drivers="sdl"
139 MINGW32*)
140 mingw32="yes"
141 if [ "$cpu" = "i386" ] ; then
142 kqemu="yes"
144 audio_possible_drivers="dsound sdl fmod"
146 GNU/kFreeBSD)
147 audio_drv_list="oss"
148 audio_possible_drivers="oss sdl esd pa"
149 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
150 kqemu="yes"
153 FreeBSD)
154 bsd="yes"
155 audio_drv_list="oss"
156 audio_possible_drivers="oss sdl esd pa"
157 aio_lib="-lpthread"
158 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
159 kqemu="yes"
160 kvm="yes"
163 NetBSD)
164 bsd="yes"
165 audio_drv_list="oss"
166 audio_possible_drivers="oss sdl esd"
167 oss_lib="-lossaudio"
168 aio_lib="-lrt -lpthread"
170 OpenBSD)
171 bsd="yes"
172 openbsd="yes"
173 audio_drv_list="oss"
174 audio_possible_drivers="oss sdl esd"
175 oss_lib="-lossaudio"
176 aio_lib="-lpthread"
178 Darwin)
179 bsd="yes"
180 darwin="yes"
181 darwin_user="yes"
182 cocoa="yes"
183 audio_drv_list="coreaudio"
184 audio_possible_drivers="coreaudio sdl fmod"
185 OS_CFLAGS="-mdynamic-no-pic"
186 OS_LDFLAGS="-framework CoreFoundation -framework IOKit"
187 aio_lib="-lpthread"
189 SunOS)
190 solaris="yes"
191 make="gmake"
192 install="ginstall"
193 needs_libsunmath="no"
194 solarisrev=`uname -r | cut -f2 -d.`
195 # have to select again, because `uname -m` returns i86pc
196 # even on an x86_64 box.
197 solariscpu=`isainfo -k`
198 if test "${solariscpu}" = "amd64" ; then
199 cpu="x86_64"
201 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
202 if test "$solarisrev" -le 9 ; then
203 if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
204 needs_libsunmath="yes"
205 else
206 echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
207 echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
208 echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
209 echo "Studio 11 can be downloaded from www.sun.com."
210 exit 1
213 if test "$solarisrev" -ge 9 ; then
214 kqemu="yes"
217 if test -f /usr/include/sys/soundcard.h ; then
218 audio_drv_list="oss"
220 audio_possible_drivers="oss sdl"
222 AIX)
223 aix="yes"
224 make="gmake"
227 audio_drv_list="oss"
228 audio_possible_drivers="oss alsa sdl esd pa"
229 linux="yes"
230 linux_user="yes"
231 usb="linux"
232 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
233 kqemu="yes"
234 audio_possible_drivers="$audio_possible_drivers fmod"
235 kvm="yes"
237 if [ "$cpu" = "ia64" ] ; then
238 kvm="yes"
239 cpu_emulation="no"
240 gdbstub="no"
241 slirp="no"
243 if [ "$cpu" = "powerpc" ]; then
244 kvm="yes"
247 esac
249 if [ "$bsd" = "yes" ] ; then
250 if [ "$darwin" != "yes" ] ; then
251 make="gmake"
252 usb="bsd"
254 bsd_user="yes"
257 # find source path
258 source_path=`dirname "$0"`
259 source_path_used="no"
260 workdir=`pwd`
261 if [ -z "$source_path" ]; then
262 source_path=$workdir
263 else
264 source_path=`cd "$source_path"; pwd`
266 [ -f "$workdir/vl.c" ] || source_path_used="yes"
268 werror="no"
269 # generate compile errors on warnings for development builds
270 #if grep cvs $source_path/VERSION > /dev/null 2>&1 ; then
271 #werror="yes";
274 for opt do
275 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
276 case "$opt" in
277 --help|-h) show_help=yes
279 --prefix=*) prefix="$optarg"
281 --interp-prefix=*) interp_prefix="$optarg"
283 --source-path=*) source_path="$optarg"
284 source_path_used="yes"
286 --cross-prefix=*) cross_prefix="$optarg"
288 --cc=*) cc="$optarg"
289 gcc3_search="no"
291 --host-cc=*) host_cc="$optarg"
293 --make=*) make="$optarg"
295 --install=*) install="$optarg"
297 --extra-cflags=*) CFLAGS="$optarg"
299 --extra-ldflags=*) LDFLAGS="$optarg"
301 --cpu=*) cpu="$optarg"
303 --target-list=*) target_list="$optarg"
305 --enable-gprof) gprof="yes"
307 --static) static="yes"
309 --disable-sdl) sdl="no"
311 --fmod-lib=*) fmod_lib="$optarg"
313 --fmod-inc=*) fmod_inc="$optarg"
315 --oss-lib=*) oss_lib="$optarg"
317 --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
319 --audio-drv-list=*) audio_drv_list="$optarg"
321 --enable-sparse) sparse="yes"
323 --disable-sparse) sparse="no"
325 --disable-vnc-tls) vnc_tls="no"
327 --disable-slirp) slirp="no"
329 --disable-vde) vde="no"
331 --disable-kqemu) kqemu="no"
333 --disable-brlapi) brlapi="no"
335 --disable-bluez) bluez="no"
337 --disable-kvm) kvm="no"
339 --enable-profiler) profiler="yes"
341 --enable-cocoa)
342 cocoa="yes" ;
343 sdl="no" ;
344 audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
346 --disable-gfx-check) check_gfx="no"
348 --disable-gcc-check) check_gcc="no"
350 --disable-system) softmmu="no"
352 --enable-system) softmmu="yes"
354 --disable-linux-user) linux_user="no"
356 --enable-linux-user) linux_user="yes"
358 --disable-darwin-user) darwin_user="no"
360 --enable-darwin-user) darwin_user="yes"
362 --disable-bsd-user) bsd_user="no"
364 --enable-bsd-user) bsd_user="yes"
366 --enable-uname-release=*) uname_release="$optarg"
368 --sparc_cpu=*)
369 sparc_cpu="$optarg"
370 case $sparc_cpu in
371 v7|v8) SP_CFLAGS="-m32 -mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__"; SP_LDFLAGS="-m32"
372 target_cpu="sparc"; cpu="sparc" ;;
373 v8plus|v8plusa) SP_CFLAGS="-m32 -mcpu=ultrasparc -D__sparc_${sparc_cpu}__"; SP_LDFLAGS="-m32"
374 target_cpu="sparc"; cpu="sparc" ;;
375 v9) SP_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_${sparc_cpu}__"; SP_LDFLAGS="-m64"
376 target_cpu="sparc64"; cpu="sparc64" ;;
377 *) echo "undefined SPARC architecture. Exiting";exit 1;;
378 esac
380 --enable-werror) werror="yes"
382 --disable-werror) werror="no"
384 --disable-curses) curses="no"
386 --disable-nptl) nptl="no"
388 --enable-mixemu) mixemu="yes"
390 --disable-aio) aio="no"
392 --kerneldir=*) kerneldir="$optarg"
394 --disable-cpu-emulation) cpu_emulation="no"
396 --disable-libfdt) device_tree_support="no"
398 *) echo "ERROR: unknown option $opt"; exit 1
400 esac
401 done
403 # default flags for all hosts
404 CFLAGS="$CFLAGS -O2 -g -fno-strict-aliasing"
405 CFLAGS="$CFLAGS -Wall -Wundef -Wendif-labels -Wwrite-strings"
406 LDFLAGS="$LDFLAGS -g"
407 if test "$werror" = "yes" ; then
408 CFLAGS="$CFLAGS -Werror"
411 if test "$solaris" = "no" ; then
412 if ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
413 LDFLAGS="$LDFLAGS -Wl,--warn-common"
418 # If cpu ~= sparc and sparc_cpu hasn't been defined, plug in the right
419 # ARCH_CFLAGS/ARCH_LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
421 case "$cpu" in
422 sparc) if test -z "$sparc_cpu" ; then
423 ARCH_CFLAGS="-m32 -mcpu=ultrasparc -D__sparc_v8plus__"
424 ARCH_LDFLAGS="-m32"
425 else
426 ARCH_CFLAGS="${SP_CFLAGS}"
427 ARCH_LDFLAGS="${SP_LDFLAGS}"
430 sparc64) if test -z "$sparc_cpu" ; then
431 ARCH_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__"
432 ARCH_LDFLAGS="-m64"
433 else
434 ARCH_CFLAGS="${SP_CFLAGS}"
435 ARCH_LDFLAGS="${SP_LDFLAGS}"
438 s390)
439 ARCH_CFLAGS="-march=z900"
441 i386)
442 ARCH_CFLAGS="-m32"
443 ARCH_LDFLAGS="-m32"
445 x86_64)
446 ARCH_CFLAGS="-m64"
447 ARCH_LDFLAGS="-m64"
449 esac
451 if test x"$show_help" = x"yes" ; then
452 cat << EOF
454 Usage: configure [options]
455 Options: [defaults in brackets after descriptions]
458 echo "Standard options:"
459 echo " --help print this message"
460 echo " --prefix=PREFIX install in PREFIX [$prefix]"
461 echo " --interp-prefix=PREFIX where to find shared libraries, etc."
462 echo " use %M for cpu name [$interp_prefix]"
463 echo " --target-list=LIST set target list [$target_list]"
464 echo ""
465 echo "kqemu kernel acceleration support:"
466 echo " --disable-kqemu disable kqemu support"
467 echo ""
468 echo "Advanced options (experts only):"
469 echo " --source-path=PATH path of source code [$source_path]"
470 echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
471 echo " --cc=CC use C compiler CC [$cc]"
472 echo " --host-cc=CC use C compiler CC [$host_cc] for dyngen etc."
473 echo " --make=MAKE use specified make [$make]"
474 echo " --install=INSTALL use specified install [$install]"
475 echo " --static enable static build [$static]"
476 echo " --enable-sparse enable sparse checker"
477 echo " --disable-sparse disable sparse checker (default)"
478 echo " --disable-werror disable compilation abort on warning"
479 echo " --disable-sdl disable SDL"
480 echo " --enable-cocoa enable COCOA (Mac OS X only)"
481 echo " --audio-drv-list=LIST set audio drivers list:"
482 echo " Available drivers: $audio_possible_drivers"
483 echo " --audio-card-list=LIST set list of additional emulated audio cards"
484 echo " Available cards: ac97 adlib cs4231a gus"
485 echo " --enable-mixemu enable mixer emulation"
486 echo " --disable-brlapi disable BrlAPI"
487 echo " --disable-vnc-tls disable TLS encryption for VNC server"
488 echo " --disable-curses disable curses output"
489 echo " --disable-bluez disable bluez stack connectivity"
490 echo " --disable-kvm disable KVM acceleration support"
491 echo " --disable-nptl disable usermode NPTL support"
492 echo " --enable-system enable all system emulation targets"
493 echo " --disable-system disable all system emulation targets"
494 echo " --enable-linux-user enable all linux usermode emulation targets"
495 echo " --disable-linux-user disable all linux usermode emulation targets"
496 echo " --enable-darwin-user enable all darwin usermode emulation targets"
497 echo " --disable-darwin-user disable all darwin usermode emulation targets"
498 echo " --enable-bsd-user enable all BSD usermode emulation targets"
499 echo " --disable-bsd-user disable all BSD usermode emulation targets"
500 echo " --fmod-lib path to FMOD library"
501 echo " --fmod-inc path to FMOD includes"
502 echo " --oss-lib path to OSS library"
503 echo " --enable-uname-release=R Return R for uname -r in usermode emulation"
504 echo " --sparc_cpu=V Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
505 echo " --disable-vde disable support for vde network"
506 echo " --disable-aio disable AIO support"
507 echo " --kerneldir=PATH look for kernel includes in PATH"
508 echo " --disable-cpu-emulation disables use of qemu cpu emulation code"
509 echo " --disable-libfdt disables use of libfdt support for device tree"
510 echo ""
511 echo "NOTE: The object files are built at the place where configure is launched"
512 exit 1
515 cc="${cross_prefix}${cc}"
516 ar="${cross_prefix}${ar}"
517 strip="${cross_prefix}${strip}"
519 # check that the C compiler works.
520 cat > $TMPC <<EOF
521 int main(void) {}
524 if $cc $ARCH_CFLAGS -c -o $TMPO $TMPC 2> /dev/null ; then
525 : C compiler works ok
526 else
527 echo "ERROR: \"$cc\" either does not exist or does not work"
528 exit 1
531 # check compiler to see if we're on mingw32
532 cat > $TMPC <<EOF
533 #include <windows.h>
534 #ifndef _WIN32
535 #error not windows
536 #endif
537 int main(void) {}
540 if $cc $ARCH_CFLAGS -c -o $TMPO $TMPC 2> /dev/null ; then
541 mingw32="yes"
544 if test "$mingw32" = "yes" ; then
545 linux="no"
546 EXESUF=".exe"
547 oss="no"
548 linux_user="no"
549 bsd_user="no"
552 if [ "$darwin" = "yes" -o "$mingw32" = "yes" ] ; then
553 AIOLIBS=
554 elif [ "$bsd" = "yes" ]; then
555 AIOLIBS="$aio_lib"
556 else
557 # Some Linux architectures (e.g. s390) don't imply -lpthread automatically.
558 AIOLIBS="-lrt -lpthread"
561 # Check for gcc4, error if pre-gcc4
562 if test "$check_gcc" = "yes" ; then
563 cat > $TMPC <<EOF
564 #if __GNUC__ < 4
565 #error gcc3
566 #endif
567 int main(){return 0;}
569 if "$cc" $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
570 echo "WARNING: \"$cc\" looks like gcc 4.x"
571 found_compat_cc="no"
572 if test "$gcc3_search" = "yes" ; then
573 echo "Looking for gcc 3.x"
574 for compat_cc in $gcc3_list ; do
575 if "$cross_prefix$compat_cc" --version 2> /dev/null | fgrep '(GCC) 3.' > /dev/null 2>&1 ; then
576 echo "Found \"$compat_cc\""
577 cc="$cross_prefix$compat_cc"
578 found_compat_cc="yes"
579 break
581 done
582 if test "$found_compat_cc" = "no" ; then
583 echo "gcc 3.x not found!"
586 if test "$found_compat_cc" = "no" ; then
587 echo "QEMU is known to have problems when compiled with gcc 4.x"
588 echo "It is recommended that you use gcc 3.x to build QEMU"
589 echo "To use this compiler anyway, configure with --disable-gcc-check"
590 exit 1;
595 if test ! -x "$(which cgcc 2>/dev/null)"; then
596 sparse="no"
600 # Solaris specific configure tool chain decisions
602 if test "$solaris" = "yes" ; then
604 # gcc for solaris 10/fcs in /usr/sfw/bin doesn't compile qemu correctly
605 # override the check with --disable-gcc-check
607 if test "$solarisrev" -eq 10 -a "$check_gcc" = "yes" ; then
608 solgcc=`which $cc`
609 if test "$solgcc" = "/usr/sfw/bin/gcc" ; then
610 echo "Solaris 10/FCS gcc in /usr/sfw/bin will not compiled qemu correctly."
611 echo "please get gcc-3.4.3 or later, from www.blastwave.org using pkg-get -i gcc3"
612 echo "or get the latest patch from SunSolve for gcc"
613 exit 1
616 solinst=`which $install 2> /dev/null | /usr/bin/grep -v "no $install in"`
617 if test -z "$solinst" ; then
618 echo "Solaris install program not found. Use --install=/usr/ucb/install or"
619 echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
620 echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
621 exit 1
623 if test "$solinst" = "/usr/sbin/install" ; then
624 echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
625 echo "try ginstall from the GNU fileutils available from www.blastwave.org"
626 echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
627 exit 1
629 sol_ar=`which ar 2> /dev/null | /usr/bin/grep -v "no ar in"`
630 if test -z "$sol_ar" ; then
631 echo "Error: No path includes ar"
632 if test -f /usr/ccs/bin/ar ; then
633 echo "Add /usr/ccs/bin to your path and rerun configure"
635 exit 1
640 if test -z "$target_list" ; then
641 # these targets are portable
642 if [ "$softmmu" = "yes" ] ; then
643 target_list="\
644 i386-softmmu \
645 x86_64-softmmu \
646 arm-softmmu \
647 cris-softmmu \
648 m68k-softmmu \
649 mips-softmmu \
650 mipsel-softmmu \
651 mips64-softmmu \
652 mips64el-softmmu \
653 ppc-softmmu \
654 ppcemb-softmmu \
655 ppc64-softmmu \
656 sh4-softmmu \
657 sh4eb-softmmu \
658 sparc-softmmu \
661 # the following are Linux specific
662 if [ "$linux_user" = "yes" ] ; then
663 target_list="${target_list}\
664 i386-linux-user \
665 x86_64-linux-user \
666 alpha-linux-user \
667 arm-linux-user \
668 armeb-linux-user \
669 cris-linux-user \
670 m68k-linux-user \
671 mips-linux-user \
672 mipsel-linux-user \
673 ppc-linux-user \
674 ppc64-linux-user \
675 ppc64abi32-linux-user \
676 sh4-linux-user \
677 sh4eb-linux-user \
678 sparc-linux-user \
679 sparc64-linux-user \
680 sparc32plus-linux-user \
683 # the following are Darwin specific
684 if [ "$darwin_user" = "yes" ] ; then
685 target_list="$target_list i386-darwin-user ppc-darwin-user"
687 # the following are BSD specific
688 if [ "$bsd_user" = "yes" ] ; then
689 target_list="${target_list}\
690 sparc64-bsd-user \
693 else
694 target_list=`echo "$target_list" | sed -e 's/,/ /g'`
696 if test -z "$target_list" ; then
697 echo "No targets enabled"
698 exit 1
701 if test -z "$cross_prefix" ; then
703 # ---
704 # big/little endian test
705 cat > $TMPC << EOF
706 #include <inttypes.h>
707 int main(int argc, char ** argv){
708 volatile uint32_t i=0x01234567;
709 return (*((uint8_t*)(&i))) == 0x67;
713 if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
714 $TMPE && bigendian="yes"
715 else
716 echo big/little test failed
719 else
721 # if cross compiling, cannot launch a program, so make a static guess
722 if test "$cpu" = "armv4b" \
723 -o "$cpu" = "hppa" \
724 -o "$cpu" = "m68k" \
725 -o "$cpu" = "mips" \
726 -o "$cpu" = "mips64" \
727 -o "$cpu" = "powerpc" \
728 -o "$cpu" = "s390" \
729 -o "$cpu" = "sparc" \
730 -o "$cpu" = "sparc64"; then
731 bigendian="yes"
736 # host long bits test
737 hostlongbits="32"
738 if test "$cpu" = "x86_64" \
739 -o "$cpu" = "alpha" \
740 -o "$cpu" = "ia64" \
741 -o "$cpu" = "sparc64"; then
742 hostlongbits="64"
745 # ppc specific hostlongbits selection
746 if test "$cpu" = "powerpc" ; then
747 if $cc $ARCH_CFLAGS -dM -E - -o $TMPI 2>/dev/null </dev/null; then
748 grep -q __powerpc64__ $TMPI && hostlongbits=64
749 else
750 echo hostlongbits test failed
751 exit 1
755 # check gcc options support
756 cat > $TMPC <<EOF
757 int main(void) {
761 # Check host NPTL support
762 cat > $TMPC <<EOF
763 #include <sched.h>
764 #include <linux/futex.h>
765 void foo()
767 #if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
768 #error bork
769 #endif
773 if $cc $ARCH_CFLAGS -c -o $TMPO $TMPC 2> /dev/null ; then
775 else
776 nptl="no"
779 ##########################################
780 # KVM probe
782 if test "$kvm" = "yes" ; then
784 # test for KVM_CAP_PIT
786 cat > $TMPC <<EOF
787 #include <libkvm.h>
788 #ifndef KVM_CAP_PIT
789 #error "kvm no pit capability"
790 #endif
791 int main(void) { return 0; }
793 if $cc $ARCH_CFLAGS $CFLAGS -I"$kerneldir"/include -o $TMPE ${OS_CFLAGS} $TMPC 2> /dev/null ; then
794 kvm_cap_pit="yes"
797 # test for KVM_CAP_DEVICE_ASSIGNMENT
799 cat > $TMPC <<EOF
800 #include <libkvm.h>
801 #ifndef KVM_CAP_DEVICE_ASSIGNMENT
802 #error "kvm no device assignment capability"
803 #endif
804 int main(void) { return 0; }
806 if $cc $ARCH_CFLAGS $CFLAGS -I"$kerneldir"/include -o $TMPE ${OS_CFLAGS} $TMPC 2> /dev/null ; then
807 kvm_cap_device_assignment="yes"
811 ##########################################
812 # zlib check
814 cat > $TMPC << EOF
815 #include <zlib.h>
816 int main(void) { zlibVersion(); return 0; }
818 if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $TMPC -lz 2> /dev/null ; then
820 else
821 echo
822 echo "Error: zlib check failed"
823 echo "Make sure to have the zlib libs and headers installed."
824 echo
825 exit 1
828 ##########################################
829 # SDL probe
831 sdl_too_old=no
833 if test -z "$sdl" ; then
834 sdl_config="sdl-config"
835 sdl=no
836 sdl_static=no
838 cat > $TMPC << EOF
839 #include <SDL.h>
840 #undef main /* We don't want SDL to override our main() */
841 int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
843 if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} `$sdl_config --cflags 2> /dev/null` $TMPC `$sdl_config --libs 2> /dev/null` 2> /tmp/qemu-$$-sdl-config.log ; then
844 _sdlversion=`$sdl_config --version | sed 's/[^0-9]//g'`
845 if test "$_sdlversion" -lt 121 ; then
846 sdl_too_old=yes
847 else
848 if test "$cocoa" = "no" ; then
849 sdl=yes
853 # static link with sdl ?
854 if test "$sdl" = "yes" ; then
855 aa="no"
856 `$sdl_config --static-libs 2>/dev/null | grep \\\-laa > /dev/null` && aa="yes"
857 sdl_static_libs=`$sdl_config --static-libs 2>/dev/null`
858 if [ "$aa" = "yes" ] ; then
859 sdl_static_libs="$sdl_static_libs `aalib-config --static-libs`"
862 if $cc -o $TMPE ${OS_CFLAGS} `$sdl_config --cflags 2> /dev/null` $TMPC $sdl_static_libs 2> /dev/null; then
863 sdl_static=yes
865 fi # static link
866 fi # sdl compile test
867 else
868 # Make sure to disable cocoa if sdl was set
869 if test "$sdl" = "yes" ; then
870 cocoa="no"
871 audio_drv_list="`echo $audio_drv_list | sed s,coreaudio,,g`"
873 fi # -z $sdl
875 ##########################################
876 # VNC TLS detection
877 if test "$vnc_tls" = "yes" ; then
878 cat > $TMPC <<EOF
879 #include <gnutls/gnutls.h>
880 int main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
882 vnc_tls_cflags=`pkg-config --cflags gnutls 2> /dev/null`
883 vnc_tls_libs=`pkg-config --libs gnutls 2> /dev/null`
884 if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $vnc_tls_cflags $TMPC \
885 $vnc_tls_libs 2> /dev/null ; then
887 else
888 vnc_tls="no"
892 ##########################################
893 # vde libraries probe
894 if test "$vde" = "yes" ; then
895 cat > $TMPC << EOF
896 #include <libvdeplug.h>
897 int main(void)
899 struct vde_open_args a = {0, 0, 0};
900 vde_open("", "", &a);
901 return 0;
904 if $cc $ARCH_CFLAGS -o $TMPE $TMPC -lvdeplug 2> /dev/null ; then
906 else
907 vde="no"
911 ##########################################
912 # Sound support libraries probe
914 audio_drv_probe()
916 drv=$1
917 hdr=$2
918 lib=$3
919 exp=$4
920 cfl=$5
921 cat > $TMPC << EOF
922 #include <$hdr>
923 int main(void) { $exp }
925 if $cc $ARCH_CFLAGS $cfl -o $TMPE $TMPC $lib 2> /dev/null ; then
927 else
928 echo
929 echo "Error: $drv check failed"
930 echo "Make sure to have the $drv libs and headers installed."
931 echo
932 exit 1
936 audio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
937 for drv in $audio_drv_list; do
938 case $drv in
939 alsa)
940 audio_drv_probe $drv alsa/asoundlib.h -lasound \
941 "snd_pcm_t **handle; return snd_pcm_close(*handle);"
944 fmod)
945 if test -z $fmod_lib || test -z $fmod_inc; then
946 echo
947 echo "Error: You must specify path to FMOD library and headers"
948 echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
949 echo
950 exit 1
952 audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
955 esd)
956 audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
960 audio_drv_probe $drv pulse/simple.h -lpulse-simple \
961 "pa_simple *s = NULL; pa_simple_free(s); return 0;"
964 oss|sdl|core|wav|dsound)
965 # XXX: Probes for CoreAudio, DirectSound, SDL(?)
969 echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
970 echo
971 echo "Error: Unknown driver '$drv' selected"
972 echo "Possible drivers are: $audio_possible_drivers"
973 echo
974 exit 1
977 esac
978 done
980 ##########################################
981 # BrlAPI probe
983 if test -z "$brlapi" ; then
984 brlapi=no
985 cat > $TMPC << EOF
986 #include <brlapi.h>
987 int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
989 if $cc ${ARCH_CFLAGS} -o $TMPE ${OS_CFLAGS} $TMPC -lbrlapi 2> /dev/null ; then
990 brlapi=yes
991 fi # brlapi compile test
992 fi # -z $brlapi
994 ##########################################
995 # curses probe
997 if test "$curses" = "yes" ; then
998 curses=no
999 cat > $TMPC << EOF
1000 #include <curses.h>
1001 int main(void) { return curses_version(); }
1003 if $cc $ARCH_CFLAGS -o $TMPE $TMPC -lcurses 2> /dev/null ; then
1004 curses=yes
1006 fi # test "$curses"
1008 ##########################################
1009 # bluez support probe
1010 if test "$bluez" = "yes" ; then
1011 `pkg-config bluez` || bluez="no"
1013 if test "$bluez" = "yes" ; then
1014 cat > $TMPC << EOF
1015 #include <bluetooth/bluetooth.h>
1016 int main(void) { return bt_error(0); }
1018 bluez_cflags=`pkg-config --cflags bluez`
1019 bluez_libs=`pkg-config --libs bluez`
1020 if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $bluez_cflags $TMPC \
1021 $bluez_libs 2> /dev/null ; then
1023 else
1024 bluez="no"
1028 ##########################################
1029 # kvm probe
1030 if test "$kvm" = "yes" ; then
1031 cat > $TMPC <<EOF
1032 #include <linux/kvm.h>
1033 #if !defined(KVM_API_VERSION) || \
1034 KVM_API_VERSION < 12 || \
1035 KVM_API_VERSION > 12 || \
1036 !defined(KVM_CAP_USER_MEMORY) || \
1037 !defined(KVM_CAP_SET_TSS_ADDR)
1038 #error Invalid KVM version
1039 #endif
1040 int main(void) { return 0; }
1042 if test "$kerneldir" != "" ; then
1043 kvm_cflags=-I"$kerneldir"/include
1044 else
1045 kvm_cflags=""
1047 if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $kvm_cflags $TMPC \
1048 2>/dev/null ; then
1050 else
1051 kvm="no"
1055 ##########################################
1056 # AIO probe
1057 if test "$aio" = "yes" ; then
1058 aio=no
1059 cat > $TMPC << EOF
1060 #include <aio.h>
1061 int main(void) { return aio_write(NULL); }
1063 if $cc $ARCH_CFLAGS -o $TMPE $AIOLIBS $TMPC 2> /dev/null ; then
1064 aio=yes
1068 ##########################################
1069 # signalfd probe
1070 cat > $TMPC << EOF
1071 #define _GNU_SOURCE
1072 #include <unistd.h>
1073 #include <sys/syscall.h>
1074 #include <signal.h>
1075 int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
1078 if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
1079 signalfd=yes
1082 ##########################################
1083 # eventfd probe
1084 cat > $TMPC << EOF
1085 #define _GNU_SOURCE
1086 #include <unistd.h>
1087 #include <sys/syscall.h>
1088 int main(void) { return syscall(SYS_eventfd, 0); }
1091 if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
1092 eventfd=yes
1095 # Check if tools are available to build documentation.
1096 if [ -x "`which texi2html 2>/dev/null`" ] && \
1097 [ -x "`which pod2man 2>/dev/null`" ]; then
1098 build_docs="yes"
1101 if test "$mingw32" = "yes" ; then
1102 if test -z "$prefix" ; then
1103 prefix="c:\\\\Program Files\\\\Qemu"
1105 mansuffix=""
1106 datasuffix=""
1107 docsuffix=""
1108 binsuffix=""
1109 else
1110 if test -z "$prefix" ; then
1111 prefix="/usr/local"
1113 mansuffix="/share/man"
1114 datasuffix="/share/qemu"
1115 docsuffix="/share/doc/qemu"
1116 binsuffix="/bin"
1119 ######################################
1120 # libfdt probe
1122 if test -z "$device_tree_support" -a \
1123 "$cpu" = "powerpc"; then
1124 device_tree_support="no"
1125 cat > $TMPC << EOF
1126 #include <libfdt.h>
1127 /* XXX uncomment later when libfdt is built before this test */
1128 //int main(void) { void *fdt; return fdt_create(fdt, 1024); }
1129 int main (void) {return 0;}
1131 # XXX for now do not try to link to libfdt and just check for header */
1132 # if $cc $ARCH_CFLAGS $CFLAGS $LDFLAGS -o $TMPE $TMPC -lfdt 2> /dev/null ; then
1133 if $cc $ARCH_CFLAGS $CFLAGS $LDFLAGS -o $TMPE $TMPC 2> /dev/null; then
1134 device_tree_support="yes"
1135 else
1136 echo
1137 echo "Error: Could not find libfdt"
1138 echo "Make sure to have the libfdt libs and headers installed."
1139 echo
1140 exit 1
1144 echo "Install prefix $prefix"
1145 echo "BIOS directory $prefix$datasuffix"
1146 echo "binary directory $prefix$binsuffix"
1147 if test "$mingw32" = "no" ; then
1148 echo "Manual directory $prefix$mansuffix"
1149 echo "ELF interp prefix $interp_prefix"
1151 echo "Source path $source_path"
1152 echo "C compiler $cc"
1153 echo "Host C compiler $host_cc"
1154 echo "ARCH_CFLAGS $ARCH_CFLAGS"
1155 echo "make $make"
1156 echo "install $install"
1157 echo "host CPU $cpu"
1158 echo "host big endian $bigendian"
1159 echo "target list $target_list"
1160 echo "gprof enabled $gprof"
1161 echo "sparse enabled $sparse"
1162 echo "profiler $profiler"
1163 echo "static build $static"
1164 echo "-Werror enabled $werror"
1165 if test "$darwin" = "yes" ; then
1166 echo "Cocoa support $cocoa"
1168 echo "SDL support $sdl"
1169 if test "$sdl" != "no" ; then
1170 echo "SDL static link $sdl_static"
1172 echo "curses support $curses"
1173 echo "mingw32 support $mingw32"
1174 echo "Audio drivers $audio_drv_list"
1175 echo "Extra audio cards $audio_card_list"
1176 echo "Mixer emulation $mixemu"
1177 echo "VNC TLS support $vnc_tls"
1178 if test "$vnc_tls" = "yes" ; then
1179 echo " TLS CFLAGS $vnc_tls_cflags"
1180 echo " TLS LIBS $vnc_tls_libs"
1182 if test -n "$sparc_cpu"; then
1183 echo "Target Sparc Arch $sparc_cpu"
1185 echo "kqemu support $kqemu"
1186 echo "kvm support $kvm"
1187 echo "CPU emulation $cpu_emulation"
1188 if test $cpu = "powerpc"; then
1189 echo "libfdt support $device_tree_support"
1191 echo "brlapi support $brlapi"
1192 echo "Documentation $build_docs"
1193 [ ! -z "$uname_release" ] && \
1194 echo "uname -r $uname_release"
1195 echo "NPTL support $nptl"
1196 echo "vde support $vde"
1197 echo "AIO support $aio"
1198 echo "KVM support $kvm"
1200 if test $sdl_too_old = "yes"; then
1201 echo "-> Your SDL version is too old - please upgrade to have SDL support"
1203 if [ -s /tmp/qemu-$$-sdl-config.log ]; then
1204 echo "The error log from compiling the libSDL test is: "
1205 cat /tmp/qemu-$$-sdl-config.log
1207 rm -f /tmp/qemu-$$-sdl-config.log
1208 #if test "$sdl_static" = "no"; then
1209 # echo "WARNING: cannot compile statically with SDL - qemu-fast won't have a graphical output"
1211 config_mak="config-host.mak"
1212 config_h="config-host.h"
1214 #echo "Creating $config_mak and $config_h"
1216 test -f $config_h && mv $config_h ${config_h}~
1218 echo "# Automatically generated by configure - do not modify" > $config_mak
1219 echo "# Configured with: $0 $@" >> $config_mak
1220 echo "/* Automatically generated by configure - do not modify */" > $config_h
1222 echo "prefix=$prefix" >> $config_mak
1223 echo "bindir=\${prefix}$binsuffix" >> $config_mak
1224 echo "mandir=\${prefix}$mansuffix" >> $config_mak
1225 echo "datadir=\${prefix}$datasuffix" >> $config_mak
1226 echo "docdir=\${prefix}$docsuffix" >> $config_mak
1227 echo "#define CONFIG_QEMU_SHAREDIR \"$prefix$datasuffix\"" >> $config_h
1228 echo "MAKE=$make" >> $config_mak
1229 echo "INSTALL=$install" >> $config_mak
1230 echo "CC=$cc" >> $config_mak
1231 echo "HOST_CC=$host_cc" >> $config_mak
1232 echo "AR=$ar" >> $config_mak
1233 echo "STRIP=$strip -s -R .comment -R .note" >> $config_mak
1234 # XXX: only use CFLAGS and LDFLAGS ?
1235 # XXX: should export HOST_CFLAGS and HOST_LDFLAGS for cross
1236 # compilation of dyngen tool (useful for win32 build on Linux host)
1237 echo "OS_CFLAGS=$OS_CFLAGS" >> $config_mak
1238 echo "OS_LDFLAGS=$OS_LDFLAGS" >> $config_mak
1239 echo "ARCH_CFLAGS=$ARCH_CFLAGS" >> $config_mak
1240 echo "ARCH_LDFLAGS=$ARCH_LDFLAGS" >> $config_mak
1241 echo "CFLAGS=$CFLAGS" >> $config_mak
1242 echo "LDFLAGS=$LDFLAGS" >> $config_mak
1243 echo "EXESUF=$EXESUF" >> $config_mak
1244 echo "AIOLIBS=$AIOLIBS" >> $config_mak
1245 case "$cpu" in
1246 i386)
1247 echo "ARCH=i386" >> $config_mak
1248 echo "#define HOST_I386 1" >> $config_h
1250 x86_64)
1251 echo "ARCH=x86_64" >> $config_mak
1252 echo "#define HOST_X86_64 1" >> $config_h
1254 alpha)
1255 echo "ARCH=alpha" >> $config_mak
1256 echo "#define HOST_ALPHA 1" >> $config_h
1258 armv4b)
1259 echo "ARCH=arm" >> $config_mak
1260 echo "#define HOST_ARM 1" >> $config_h
1262 armv4l)
1263 echo "ARCH=arm" >> $config_mak
1264 echo "#define HOST_ARM 1" >> $config_h
1266 cris)
1267 echo "ARCH=cris" >> $config_mak
1268 echo "#define HOST_CRIS 1" >> $config_h
1270 hppa)
1271 echo "ARCH=hppa" >> $config_mak
1272 echo "#define HOST_HPPA 1" >> $config_h
1274 ia64)
1275 echo "ARCH=ia64" >> $config_mak
1276 echo "#define HOST_IA64 1" >> $config_h
1278 m68k)
1279 echo "ARCH=m68k" >> $config_mak
1280 echo "#define HOST_M68K 1" >> $config_h
1282 mips)
1283 echo "ARCH=mips" >> $config_mak
1284 echo "#define HOST_MIPS 1" >> $config_h
1286 mips64)
1287 echo "ARCH=mips64" >> $config_mak
1288 echo "#define HOST_MIPS64 1" >> $config_h
1290 powerpc)
1291 if test "$hostlongbits" = "32"; then
1292 echo "ARCH=ppc" >> $config_mak
1293 echo "#define HOST_PPC 1" >> $config_h
1294 else
1295 echo "ARCH=ppc64" >> $config_mak
1296 echo "#define HOST_PPC64 1" >> $config_h
1299 s390)
1300 echo "ARCH=s390" >> $config_mak
1301 echo "#define HOST_S390 1" >> $config_h
1303 sparc)
1304 echo "ARCH=sparc" >> $config_mak
1305 echo "#define HOST_SPARC 1" >> $config_h
1307 sparc64)
1308 echo "ARCH=sparc64" >> $config_mak
1309 echo "#define HOST_SPARC64 1" >> $config_h
1312 echo "Unsupported CPU = $cpu"
1313 exit 1
1315 esac
1316 if test "$sparse" = "yes" ; then
1317 echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_mak
1318 echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_mak
1319 echo "CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_mak
1321 if test "$bigendian" = "yes" ; then
1322 echo "WORDS_BIGENDIAN=yes" >> $config_mak
1323 echo "#define WORDS_BIGENDIAN 1" >> $config_h
1325 echo "#define HOST_LONG_BITS $hostlongbits" >> $config_h
1326 if test "$mingw32" = "yes" ; then
1327 echo "CONFIG_WIN32=yes" >> $config_mak
1328 echo "#define CONFIG_WIN32 1" >> $config_h
1329 else
1330 cat > $TMPC << EOF
1331 #include <byteswap.h>
1332 int main(void) { return bswap_32(0); }
1334 if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
1335 echo "#define HAVE_BYTESWAP_H 1" >> $config_h
1339 if [ "$openbsd" = "yes" ] ; then
1340 echo "#define ENOTSUP 4096" >> $config_h
1343 if test "$darwin" = "yes" ; then
1344 echo "CONFIG_DARWIN=yes" >> $config_mak
1345 echo "#define CONFIG_DARWIN 1" >> $config_h
1348 if test "$aix" = "yes" ; then
1349 echo "CONFIG_AIX=yes" >> $config_mak
1350 echo "#define CONFIG_AIX 1" >> $config_h
1353 if test "$solaris" = "yes" ; then
1354 echo "CONFIG_SOLARIS=yes" >> $config_mak
1355 echo "#define HOST_SOLARIS $solarisrev" >> $config_h
1356 if test "$needs_libsunmath" = "yes" ; then
1357 echo "NEEDS_LIBSUNMATH=yes" >> $config_mak
1358 echo "#define NEEDS_LIBSUNMATH 1" >> $config_h
1361 if test -n "$sparc_cpu"; then
1362 echo "CONFIG__sparc_${sparc_cpu}__=yes" >> $config_mak
1363 echo "#define __sparc_${sparc_cpu}__ 1" >> $config_h
1365 if test "$gdbstub" = "yes" ; then
1366 echo "CONFIG_GDBSTUB=yes" >> $config_mak
1367 echo "#define CONFIG_GDBSTUB 1" >> $config_h
1369 if test "$gprof" = "yes" ; then
1370 echo "TARGET_GPROF=yes" >> $config_mak
1371 echo "#define HAVE_GPROF 1" >> $config_h
1373 if test "$static" = "yes" ; then
1374 echo "CONFIG_STATIC=yes" >> $config_mak
1375 echo "#define CONFIG_STATIC 1" >> $config_h
1377 if test $profiler = "yes" ; then
1378 echo "#define CONFIG_PROFILER 1" >> $config_h
1380 if test "$slirp" = "yes" ; then
1381 echo "CONFIG_SLIRP=yes" >> $config_mak
1382 echo "#define CONFIG_SLIRP 1" >> $config_h
1384 if test "$vde" = "yes" ; then
1385 echo "CONFIG_VDE=yes" >> $config_mak
1386 echo "#define CONFIG_VDE 1" >> $config_h
1387 echo "VDE_LIBS=-lvdeplug" >> $config_mak
1389 for card in $audio_card_list; do
1390 def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
1391 echo "$def=yes" >> $config_mak
1392 echo "#define $def 1" >> $config_h
1393 done
1394 echo "#define AUDIO_DRIVERS \\" >> $config_h
1395 for drv in $audio_drv_list; do
1396 echo " &${drv}_audio_driver, \\" >>$config_h
1397 def=CONFIG_`echo $drv | tr '[:lower:]' '[:upper:]'`
1398 echo "$def=yes" >> $config_mak
1399 if test "$drv" = "fmod"; then
1400 echo "CONFIG_FMOD_LIB=$fmod_lib" >> $config_mak
1401 echo "CONFIG_FMOD_INC=$fmod_inc" >> $config_mak
1402 elif test "$drv" = "oss"; then
1403 echo "CONFIG_OSS_LIB=$oss_lib" >> $config_mak
1405 done
1406 echo "" >>$config_h
1407 if test "$mixemu" = "yes" ; then
1408 echo "CONFIG_MIXEMU=yes" >> $config_mak
1409 echo "#define CONFIG_MIXEMU 1" >> $config_h
1411 if test "$vnc_tls" = "yes" ; then
1412 echo "CONFIG_VNC_TLS=yes" >> $config_mak
1413 echo "CONFIG_VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_mak
1414 echo "CONFIG_VNC_TLS_LIBS=$vnc_tls_libs" >> $config_mak
1415 echo "#define CONFIG_VNC_TLS 1" >> $config_h
1417 qemu_version=`head $source_path/VERSION`
1418 echo "VERSION=$qemu_version" >>$config_mak
1419 echo "#define QEMU_VERSION \"$qemu_version\"" >> $config_h
1420 echo "#define KVM_VERSION \"kvm-devel\"" >> $config_h
1422 echo "SRC_PATH=$source_path" >> $config_mak
1423 if [ "$source_path_used" = "yes" ]; then
1424 echo "VPATH=$source_path" >> $config_mak
1426 echo "TARGET_DIRS=$target_list" >> $config_mak
1427 if [ "$build_docs" = "yes" ] ; then
1428 echo "BUILD_DOCS=yes" >> $config_mak
1430 if test "$static" = "yes"; then
1431 sdl1=$sdl_static
1432 else
1433 sdl1=$sdl
1435 if test "$sdl1" = "yes" ; then
1436 echo "#define CONFIG_SDL 1" >> $config_h
1437 echo "CONFIG_SDL=yes" >> $config_mak
1438 if test "$target_softmmu" = "no" -o "$static" = "yes"; then
1439 echo "SDL_LIBS=$sdl_static_libs" >> $config_mak
1440 else
1441 echo "SDL_LIBS=`$sdl_config --libs`" >> $config_mak
1443 if [ "${aa}" = "yes" ] ; then
1444 echo "SDL_CFLAGS=`$sdl_config --cflags` `aalib-config --cflags`" >> $config_mak
1445 else
1446 echo "SDL_CFLAGS=`$sdl_config --cflags`" >> $config_mak
1449 if test "$cocoa" = "yes" ; then
1450 echo "#define CONFIG_COCOA 1" >> $config_h
1451 echo "CONFIG_COCOA=yes" >> $config_mak
1453 if test "$curses" = "yes" ; then
1454 echo "#define CONFIG_CURSES 1" >> $config_h
1455 echo "CONFIG_CURSES=yes" >> $config_mak
1456 echo "CURSES_LIBS=-lcurses" >> $config_mak
1458 if test "$brlapi" = "yes" ; then
1459 echo "CONFIG_BRLAPI=yes" >> $config_mak
1460 echo "#define CONFIG_BRLAPI 1" >> $config_h
1461 echo "BRLAPI_LIBS=-lbrlapi" >> $config_mak
1463 if test "$bluez" = "yes" ; then
1464 echo "CONFIG_BLUEZ=yes" >> $config_mak
1465 echo "CONFIG_BLUEZ_CFLAGS=$bluez_cflags" >> $config_mak
1466 echo "CONFIG_BLUEZ_LIBS=$bluez_libs" >> $config_mak
1467 echo "#define CONFIG_BLUEZ 1" >> $config_h
1469 if test "$aio" = "yes" ; then
1470 echo "#define CONFIG_AIO 1" >> $config_h
1471 echo "CONFIG_AIO=yes" >> $config_mak
1473 if test "$signalfd" = "yes" ; then
1474 echo "#define CONFIG_signalfd 1" >> $config_h
1476 if test "$eventfd" = "yes" ; then
1477 echo "#define CONFIG_eventfd 1" >> $config_h
1480 # XXX: suppress that
1481 if [ "$bsd" = "yes" ] ; then
1482 echo "#define O_LARGEFILE 0" >> $config_h
1483 echo "#define MAP_ANONYMOUS MAP_ANON" >> $config_h
1484 echo "#define _BSD 1" >> $config_h
1487 echo "#define CONFIG_UNAME_RELEASE \"$uname_release\"" >> $config_h
1489 # USB host support
1490 case "$usb" in
1491 linux)
1492 echo "HOST_USB=linux" >> $config_mak
1494 bsd)
1495 echo "HOST_USB=bsd" >> $config_mak
1498 echo "HOST_USB=stub" >> $config_mak
1500 esac
1502 tools=
1503 if test `expr "$target_list" : ".*softmmu.*"` != 0 ; then
1504 tools="qemu-img\$(EXESUF) $tools"
1505 if [ "$linux" = "yes" ] ; then
1506 tools="qemu-nbd\$(EXESUF) $tools"
1509 echo "TOOLS=$tools" >> $config_mak
1511 test -f ${config_h}~ && cmp -s $config_h ${config_h}~ && mv ${config_h}~ $config_h
1513 for target in $target_list; do
1514 target_dir="$target"
1515 config_mak=$target_dir/config.mak
1516 config_h=$target_dir/config.h
1517 target_cpu=`echo $target | cut -d '-' -f 1`
1518 target_bigendian="no"
1519 [ "$target_cpu" = "armeb" ] && target_bigendian=yes
1520 [ "$target_cpu" = "m68k" ] && target_bigendian=yes
1521 [ "$target_cpu" = "mips" ] && target_bigendian=yes
1522 [ "$target_cpu" = "mipsn32" ] && target_bigendian=yes
1523 [ "$target_cpu" = "mips64" ] && target_bigendian=yes
1524 [ "$target_cpu" = "ppc" ] && target_bigendian=yes
1525 [ "$target_cpu" = "ppcemb" ] && target_bigendian=yes
1526 [ "$target_cpu" = "ppc64" ] && target_bigendian=yes
1527 [ "$target_cpu" = "ppc64abi32" ] && target_bigendian=yes
1528 [ "$target_cpu" = "sh4eb" ] && target_bigendian=yes
1529 [ "$target_cpu" = "sparc" ] && target_bigendian=yes
1530 [ "$target_cpu" = "sparc64" ] && target_bigendian=yes
1531 [ "$target_cpu" = "sparc32plus" ] && target_bigendian=yes
1532 target_softmmu="no"
1533 target_user_only="no"
1534 target_linux_user="no"
1535 target_darwin_user="no"
1536 target_bsd_user="no"
1537 case "$target" in
1538 ${target_cpu}-softmmu)
1539 target_softmmu="yes"
1541 ${target_cpu}-linux-user)
1542 target_user_only="yes"
1543 target_linux_user="yes"
1545 ${target_cpu}-darwin-user)
1546 target_user_only="yes"
1547 target_darwin_user="yes"
1549 ${target_cpu}-bsd-user)
1550 target_user_only="yes"
1551 target_bsd_user="yes"
1554 echo "ERROR: Target '$target' not recognised"
1555 exit 1
1557 esac
1559 if test "$target_user_only" = "no" -a "$check_gfx" = "yes" \
1560 -a "$sdl" = "no" -a "$cocoa" = "no" ; then
1561 echo "ERROR: QEMU requires SDL or Cocoa for graphical output"
1562 echo "To build QEMU without graphical output configure with --disable-gfx-check"
1563 echo "Note that this will disable all output from the virtual graphics card"
1564 echo "except through VNC or curses."
1565 exit 1;
1568 #echo "Creating $config_mak, $config_h and $target_dir/Makefile"
1570 test -f $config_h && mv $config_h ${config_h}~
1572 mkdir -p $target_dir
1573 mkdir -p $target_dir/fpu
1574 mkdir -p $target_dir/tcg
1575 if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
1576 mkdir -p $target_dir/nwfpe
1580 # don't use ln -sf as not all "ln -sf" over write the file/link
1582 rm -f $target_dir/Makefile
1583 ln -s $source_path/Makefile.target $target_dir/Makefile
1586 echo "# Automatically generated by configure - do not modify" > $config_mak
1587 echo "/* Automatically generated by configure - do not modify */" > $config_h
1590 echo "include ../config-host.mak" >> $config_mak
1591 echo "#include \"../config-host.h\"" >> $config_h
1593 bflt="no"
1594 elfload32="no"
1595 target_nptl="no"
1596 interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_cpu/g"`
1597 echo "#define CONFIG_QEMU_PREFIX \"$interp_prefix1\"" >> $config_h
1598 gdb_xml_files=""
1600 disable_cpu_emulation() {
1601 if test $cpu_emulation = "no"; then
1602 echo "#define NO_CPU_EMULATION 1" >> $config_h
1603 echo "NO_CPU_EMULATION=1" >> $config_mak
1607 configure_kvm() {
1608 if test $kvm = "yes" -a "$target_softmmu" = "yes" -a \
1609 \( "$cpu" = "i386" -o "$cpu" = "x86_64" -o "$cpu" = "ia64" -o "$cpu" = "powerpc" \); then
1610 echo "#define USE_KVM 1" >> $config_h
1611 echo "USE_KVM=1" >> $config_mak
1612 echo "CONFIG_KVM_KERNEL_INC=$kerneldir/include" >> $config_mak
1613 if test $kvm_cap_pit = "yes" ; then
1614 echo "USE_KVM_PIT=1" >> $config_mak
1615 echo "#define USE_KVM_PIT 1" >> $config_h
1617 if test $kvm_cap_device_assignment = "yes" ; then
1618 echo "USE_KVM_DEVICE_ASSIGNMENT=1" >> $config_mak
1619 echo "#define USE_KVM_DEVICE_ASSIGNMENT 1" >> $config_h
1621 disable_cpu_emulation
1625 if [ use_upstream_kvm = yes ]; then
1627 # Make sure the target and host cpus are compatible
1628 if test "$kvm" = "yes" -a ! \( "$target_cpu" = "$cpu" -o \
1629 \( "$target_cpu" = "x86_64" -a "$cpu" = "i386" \) -o \
1630 \( "$target_cpu" = "i386" -a "$cpu" = "x86_64" \) \) ; then
1631 kvm="no"
1633 # Disable KVM for linux-user
1634 if test "$kvm" = "yes" -a "$target_softmmu" = "no" ; then
1635 kvm="no"
1640 case "$target_cpu" in
1641 i386)
1642 echo "TARGET_ARCH=i386" >> $config_mak
1643 echo "#define TARGET_ARCH \"i386\"" >> $config_h
1644 echo "#define TARGET_I386 1" >> $config_h
1645 if test $kqemu = "yes" -a "$target_softmmu" = "yes"
1646 then
1647 echo "#define USE_KQEMU 1" >> $config_h
1649 if test "$kvm" = "yes" ; then
1650 echo "CONFIG_KVM=yes" >> $config_mak
1651 echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak
1652 echo "#define CONFIG_KVM 1" >> $config_h
1654 gcc3minver=`$cc --version 2> /dev/null| fgrep "(GCC) 3." | awk '{ print $3 }' | cut -f2 -d.`
1655 if test -n "$gcc3minver" && test $gcc3minver -gt 3
1656 then
1657 echo "HAVE_GT_GCC_3_3=true" >> $config_mak
1658 else
1659 echo "HAVE_GT_GCC_3_3=false" >> $config_mak
1661 configure_kvm
1663 x86_64)
1664 echo "TARGET_ARCH=x86_64" >> $config_mak
1665 echo "#define TARGET_ARCH \"x86_64\"" >> $config_h
1666 echo "#define TARGET_I386 1" >> $config_h
1667 echo "#define TARGET_X86_64 1" >> $config_h
1668 if test $kqemu = "yes" -a "$target_softmmu" = "yes" -a $cpu = "x86_64"
1669 then
1670 echo "#define USE_KQEMU 1" >> $config_h
1672 configure_kvm
1674 ia64)
1675 echo "TARGET_ARCH=ia64" >> $config_mak
1676 echo "#define TARGET_ARCH \"ia64\"" >> $config_h
1677 echo "#define TARGET_IA64 1" >> $config_h
1678 configure_kvm
1679 if [ use_upstream_kvm = yes ]; then
1680 if test "$kvm" = "yes" ; then
1681 echo "CONFIG_KVM=yes" >> $config_mak
1682 echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak
1683 echo "#define CONFIG_KVM 1" >> $config_h
1687 alpha)
1688 echo "TARGET_ARCH=alpha" >> $config_mak
1689 echo "#define TARGET_ARCH \"alpha\"" >> $config_h
1690 echo "#define TARGET_ALPHA 1" >> $config_h
1692 arm|armeb)
1693 echo "TARGET_ARCH=arm" >> $config_mak
1694 echo "#define TARGET_ARCH \"arm\"" >> $config_h
1695 echo "#define TARGET_ARM 1" >> $config_h
1696 bflt="yes"
1697 target_nptl="yes"
1698 gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
1700 cris)
1701 echo "TARGET_ARCH=cris" >> $config_mak
1702 echo "#define TARGET_ARCH \"cris\"" >> $config_h
1703 echo "#define TARGET_CRIS 1" >> $config_h
1705 m68k)
1706 echo "TARGET_ARCH=m68k" >> $config_mak
1707 echo "#define TARGET_ARCH \"m68k\"" >> $config_h
1708 echo "#define TARGET_M68K 1" >> $config_h
1709 bflt="yes"
1710 gdb_xml_files="cf-core.xml cf-fp.xml"
1712 mips|mipsel)
1713 echo "TARGET_ARCH=mips" >> $config_mak
1714 echo "#define TARGET_ARCH \"mips\"" >> $config_h
1715 echo "#define TARGET_MIPS 1" >> $config_h
1716 echo "#define TARGET_ABI_MIPSO32 1" >> $config_h
1718 mipsn32|mipsn32el)
1719 echo "TARGET_ARCH=mipsn32" >> $config_mak
1720 echo "#define TARGET_ARCH \"mipsn32\"" >> $config_h
1721 echo "#define TARGET_MIPS 1" >> $config_h
1722 echo "#define TARGET_ABI_MIPSN32 1" >> $config_h
1724 mips64|mips64el)
1725 echo "TARGET_ARCH=mips64" >> $config_mak
1726 echo "#define TARGET_ARCH \"mips64\"" >> $config_h
1727 echo "#define TARGET_MIPS 1" >> $config_h
1728 echo "#define TARGET_MIPS64 1" >> $config_h
1729 echo "#define TARGET_ABI_MIPSN64 1" >> $config_h
1731 ppc)
1732 echo "TARGET_ARCH=ppc" >> $config_mak
1733 echo "CONFIG_DYNGEN_OP=yes" >> $config_mak
1734 echo "#define TARGET_ARCH \"ppc\"" >> $config_h
1735 echo "#define TARGET_PPC 1" >> $config_h
1736 echo "#define CONFIG_DYNGEN_OP 1" >> $config_h
1738 ppcemb)
1739 echo "TARGET_ARCH=ppcemb" >> $config_mak
1740 echo "TARGET_ABI_DIR=ppc" >> $config_mak
1741 echo "CONFIG_DYNGEN_OP=yes" >> $config_mak
1742 echo "#define TARGET_ARCH \"ppcemb\"" >> $config_h
1743 echo "#define TARGET_PPC 1" >> $config_h
1744 echo "#define TARGET_PPCEMB 1" >> $config_h
1745 echo "#define CONFIG_DYNGEN_OP 1" >> $config_h
1746 if test "$device_tree_support" = "yes" ; then
1747 echo "#define CONFIG_LIBFDT 1" >> $config_h
1748 echo "CONFIG_LIBFDT=1" >> $config_mak
1750 configure_kvm
1752 ppc64)
1753 echo "TARGET_ARCH=ppc64" >> $config_mak
1754 echo "TARGET_ABI_DIR=ppc" >> $config_mak
1755 echo "CONFIG_DYNGEN_OP=yes" >> $config_mak
1756 echo "#define TARGET_ARCH \"ppc64\"" >> $config_h
1757 echo "#define TARGET_PPC 1" >> $config_h
1758 echo "#define TARGET_PPC64 1" >> $config_h
1759 echo "#define CONFIG_DYNGEN_OP 1" >> $config_h
1761 ppc64abi32)
1762 echo "TARGET_ARCH=ppc64" >> $config_mak
1763 echo "TARGET_ABI_DIR=ppc" >> $config_mak
1764 echo "TARGET_ARCH2=ppc64abi32" >> $config_mak
1765 echo "CONFIG_DYNGEN_OP=yes" >> $config_mak
1766 echo "#define TARGET_ARCH \"ppc64\"" >> $config_h
1767 echo "#define TARGET_PPC 1" >> $config_h
1768 echo "#define TARGET_PPC64 1" >> $config_h
1769 echo "#define TARGET_ABI32 1" >> $config_h
1770 echo "#define CONFIG_DYNGEN_OP 1" >> $config_h
1772 sh4|sh4eb)
1773 echo "TARGET_ARCH=sh4" >> $config_mak
1774 echo "#define TARGET_ARCH \"sh4\"" >> $config_h
1775 echo "#define TARGET_SH4 1" >> $config_h
1776 bflt="yes"
1777 target_nptl="yes"
1779 sparc)
1780 echo "TARGET_ARCH=sparc" >> $config_mak
1781 echo "#define TARGET_ARCH \"sparc\"" >> $config_h
1782 echo "#define TARGET_SPARC 1" >> $config_h
1784 sparc64)
1785 echo "TARGET_ARCH=sparc64" >> $config_mak
1786 echo "#define TARGET_ARCH \"sparc64\"" >> $config_h
1787 echo "#define TARGET_SPARC 1" >> $config_h
1788 echo "#define TARGET_SPARC64 1" >> $config_h
1789 elfload32="yes"
1791 sparc32plus)
1792 echo "TARGET_ARCH=sparc64" >> $config_mak
1793 echo "TARGET_ABI_DIR=sparc" >> $config_mak
1794 echo "TARGET_ARCH2=sparc32plus" >> $config_mak
1795 echo "#define TARGET_ARCH \"sparc64\"" >> $config_h
1796 echo "#define TARGET_SPARC 1" >> $config_h
1797 echo "#define TARGET_SPARC64 1" >> $config_h
1798 echo "#define TARGET_ABI32 1" >> $config_h
1801 echo "Unsupported target CPU"
1802 exit 1
1804 esac
1805 if test "$target_bigendian" = "yes" ; then
1806 echo "TARGET_WORDS_BIGENDIAN=yes" >> $config_mak
1807 echo "#define TARGET_WORDS_BIGENDIAN 1" >> $config_h
1809 if test "$target_softmmu" = "yes" ; then
1810 echo "CONFIG_SOFTMMU=yes" >> $config_mak
1811 echo "#define CONFIG_SOFTMMU 1" >> $config_h
1813 if test "$target_user_only" = "yes" ; then
1814 echo "CONFIG_USER_ONLY=yes" >> $config_mak
1815 echo "#define CONFIG_USER_ONLY 1" >> $config_h
1817 if test "$target_linux_user" = "yes" ; then
1818 echo "CONFIG_LINUX_USER=yes" >> $config_mak
1819 echo "#define CONFIG_LINUX_USER 1" >> $config_h
1821 if test "$target_darwin_user" = "yes" ; then
1822 echo "CONFIG_DARWIN_USER=yes" >> $config_mak
1823 echo "#define CONFIG_DARWIN_USER 1" >> $config_h
1825 list=""
1826 if test ! -z "$gdb_xml_files" ; then
1827 for x in $gdb_xml_files; do
1828 list="$list $source_path/gdb-xml/$x"
1829 done
1831 echo "TARGET_XML_FILES=$list" >> $config_mak
1833 if test "$target_cpu" = "arm" \
1834 -o "$target_cpu" = "armeb" \
1835 -o "$target_cpu" = "m68k" \
1836 -o "$target_cpu" = "mips" \
1837 -o "$target_cpu" = "mipsel" \
1838 -o "$target_cpu" = "mipsn32" \
1839 -o "$target_cpu" = "mipsn32el" \
1840 -o "$target_cpu" = "mips64" \
1841 -o "$target_cpu" = "mips64el" \
1842 -o "$target_cpu" = "sparc" \
1843 -o "$target_cpu" = "sparc64" \
1844 -o "$target_cpu" = "sparc32plus"; then
1845 echo "CONFIG_SOFTFLOAT=yes" >> $config_mak
1846 echo "#define CONFIG_SOFTFLOAT 1" >> $config_h
1848 if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
1849 echo "TARGET_HAS_BFLT=yes" >> $config_mak
1850 echo "#define TARGET_HAS_BFLT 1" >> $config_h
1852 if test "$target_user_only" = "yes" \
1853 -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
1854 echo "#define USE_NPTL 1" >> $config_h
1856 # 32 bit ELF loader in addition to native 64 bit loader?
1857 if test "$target_user_only" = "yes" -a "$elfload32" = "yes"; then
1858 echo "TARGET_HAS_ELFLOAD32=yes" >> $config_mak
1859 echo "#define TARGET_HAS_ELFLOAD32 1" >> $config_h
1861 if test "$target_bsd_user" = "yes" ; then
1862 echo "CONFIG_BSD_USER=yes" >> $config_mak
1863 echo "#define CONFIG_BSD_USER 1" >> $config_h
1866 test -f ${config_h}~ && cmp -s $config_h ${config_h}~ && mv ${config_h}~ $config_h
1868 done # for target in $targets
1870 # build tree in object directory if source path is different from current one
1871 if test "$source_path_used" = "yes" ; then
1872 DIRS="tests tests/cris slirp audio"
1873 FILES="Makefile tests/Makefile"
1874 FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
1875 FILES="$FILES tests/test-mmap.c"
1876 for dir in $DIRS ; do
1877 mkdir -p $dir
1878 done
1879 # remove the link and recreate it, as not all "ln -sf" overwrite the link
1880 for f in $FILES ; do
1881 rm -f $f
1882 ln -s $source_path/$f $f
1883 done
1886 rm -f $TMPO $TMPC $TMPE $TMPS $TMPI