Merge branch 'qemu-cvs'
[qemu-kvm/fedora.git] / configure
blob4e67a39b0588be8dfd54f1c581657cff1bb8b6d5
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=""
31 host_cc="gcc"
32 ar="ar"
33 make="make"
34 install="install"
35 strip="strip"
37 # parse CC options first
38 for opt do
39 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
40 case "$opt" in
41 --cross-prefix=*) cross_prefix="$optarg"
43 --cc=*) cc="$optarg"
45 esac
46 done
48 # OS specific
49 # Using uname is really, really broken. Once we have the right set of checks
50 # we can eliminate it's usage altogether
52 cc="${cross_prefix}${cc}"
53 ar="${cross_prefix}${ar}"
54 strip="${cross_prefix}${strip}"
56 # check that the C compiler works.
57 cat > $TMPC <<EOF
58 int main(void) {}
59 EOF
61 if $cc $ARCH_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null ; then
62 : C compiler works ok
63 else
64 echo "ERROR: \"$cc\" either does not exist or does not work"
65 exit 1
68 check_define() {
69 cat > $TMPC <<EOF
70 #if !defined($1)
71 #error Not defined
72 #endif
73 int main(void) { return 0; }
74 EOF
75 $cc $ARCH_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null
78 if check_define __i386__ ; then
79 cpu="i386"
80 elif check_define __x86_64__ ; then
81 cpu="x86_64"
82 elif check_define __sparc__ ; then
83 # We can't check for 64 bit (when gcc is biarch) or V8PLUSA
84 # They must be specified using --sparc_cpu
85 if check_define __arch64__ ; then
86 cpu="sparc64"
87 else
88 cpu="sparc"
90 else
91 cpu=`test $(uname -s) = AIX && uname -p || uname -m`
94 target_list=""
95 case "$cpu" in
96 i386|i486|i586|i686|i86pc|BePC)
97 cpu="i386"
99 x86_64|amd64)
100 cpu="x86_64"
102 alpha)
103 cpu="alpha"
105 armv*b)
106 cpu="armv4b"
108 armv*l)
109 cpu="armv4l"
111 cris)
112 cpu="cris"
114 parisc|parisc64)
115 cpu="hppa"
117 ia64)
118 cpu="ia64"
120 m68k)
121 cpu="m68k"
123 mips)
124 cpu="mips"
126 mips64)
127 cpu="mips64"
129 "Power Macintosh"|ppc|ppc64|powerpc)
130 cpu="powerpc"
132 s390*)
133 cpu="s390"
135 sparc|sun4[cdmuv])
136 cpu="sparc"
138 sparc64)
139 cpu="sparc64"
142 cpu="unknown"
144 esac
145 gprof="no"
146 sparse="no"
147 bigendian="no"
148 mingw32="no"
149 EXESUF=""
150 gdbstub="yes"
151 slirp="yes"
152 vde="yes"
153 fmod_lib=""
154 fmod_inc=""
155 oss_lib=""
156 vnc_tls="yes"
157 bsd="no"
158 linux="no"
159 solaris="no"
160 kqemu="no"
161 profiler="no"
162 cocoa="no"
163 check_gfx="yes"
164 softmmu="yes"
165 linux_user="no"
166 darwin_user="no"
167 bsd_user="no"
168 build_docs="no"
169 uname_release=""
170 curses="yes"
171 aio="yes"
172 nptl="yes"
173 mixemu="no"
174 bluez="yes"
175 kvm="yes"
176 kvm_cap_pit="no"
177 kvm_cap_device_assignment="no"
178 kerneldir=""
179 aix="no"
180 blobs="yes"
181 fdt="yes"
182 signalfd="no"
183 eventfd="no"
184 cpu_emulation="yes"
186 # OS specific
187 if check_define __linux__ ; then
188 targetos="Linux"
189 elif check_define _WIN32 ; then
190 targetos='MINGW32'
191 else
192 targetos=`uname -s`
194 case $targetos in
195 CYGWIN*)
196 mingw32="yes"
197 OS_CFLAGS="-mno-cygwin"
198 if [ "$cpu" = "i386" ] ; then
199 kqemu="yes"
201 audio_possible_drivers="sdl"
203 MINGW32*)
204 mingw32="yes"
205 if [ "$cpu" = "i386" ] ; then
206 kqemu="yes"
208 audio_possible_drivers="dsound sdl fmod"
210 GNU/kFreeBSD)
211 audio_drv_list="oss"
212 audio_possible_drivers="oss sdl esd pa"
213 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
214 kqemu="yes"
217 FreeBSD)
218 bsd="yes"
219 audio_drv_list="oss"
220 audio_possible_drivers="oss sdl esd pa"
221 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
222 kqemu="yes"
223 kvm="yes"
226 NetBSD)
227 bsd="yes"
228 audio_drv_list="oss"
229 audio_possible_drivers="oss sdl esd"
230 oss_lib="-lossaudio"
232 OpenBSD)
233 bsd="yes"
234 openbsd="yes"
235 audio_drv_list="oss"
236 audio_possible_drivers="oss sdl esd"
237 oss_lib="-lossaudio"
239 Darwin)
240 bsd="yes"
241 darwin="yes"
242 darwin_user="yes"
243 cocoa="yes"
244 audio_drv_list="coreaudio"
245 audio_possible_drivers="coreaudio sdl fmod"
246 OS_CFLAGS="-mdynamic-no-pic"
247 OS_LDFLAGS="-framework CoreFoundation -framework IOKit"
249 SunOS)
250 solaris="yes"
251 make="gmake"
252 install="ginstall"
253 needs_libsunmath="no"
254 solarisrev=`uname -r | cut -f2 -d.`
255 # have to select again, because `uname -m` returns i86pc
256 # even on an x86_64 box.
257 solariscpu=`isainfo -k`
258 if test "${solariscpu}" = "amd64" ; then
259 cpu="x86_64"
261 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
262 if test "$solarisrev" -le 9 ; then
263 if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
264 needs_libsunmath="yes"
265 else
266 echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
267 echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
268 echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
269 echo "Studio 11 can be downloaded from www.sun.com."
270 exit 1
273 if test "$solarisrev" -ge 9 ; then
274 kqemu="yes"
277 if test -f /usr/include/sys/soundcard.h ; then
278 audio_drv_list="oss"
280 audio_possible_drivers="oss sdl"
282 AIX)
283 aix="yes"
284 make="gmake"
287 audio_drv_list="oss"
288 audio_possible_drivers="oss alsa sdl esd pa"
289 linux="yes"
290 linux_user="yes"
291 usb="linux"
292 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
293 kqemu="yes"
294 audio_possible_drivers="$audio_possible_drivers fmod"
295 kvm="yes"
297 if [ "$cpu" = "ia64" ] ; then
298 kvm="yes"
299 cpu_emulation="no"
300 gdbstub="no"
301 slirp="no"
303 if [ "$cpu" = "powerpc" ]; then
304 kvm="yes"
307 esac
309 if [ "$bsd" = "yes" ] ; then
310 if [ "$darwin" != "yes" ] ; then
311 make="gmake"
312 usb="bsd"
314 bsd_user="yes"
317 # find source path
318 source_path=`dirname "$0"`
319 source_path_used="no"
320 workdir=`pwd`
321 if [ -z "$source_path" ]; then
322 source_path=$workdir
323 else
324 source_path=`cd "$source_path"; pwd`
326 [ -f "$workdir/vl.c" ] || source_path_used="yes"
328 werror="no"
329 # generate compile errors on warnings for development builds
330 #if grep cvs $source_path/VERSION > /dev/null 2>&1 ; then
331 #werror="yes";
334 for opt do
335 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
336 case "$opt" in
337 --help|-h) show_help=yes
339 --prefix=*) prefix="$optarg"
341 --interp-prefix=*) interp_prefix="$optarg"
343 --source-path=*) source_path="$optarg"
344 source_path_used="yes"
346 --cross-prefix=*)
348 --cc=*)
350 --host-cc=*) host_cc="$optarg"
352 --make=*) make="$optarg"
354 --install=*) install="$optarg"
356 --extra-cflags=*) CFLAGS="$optarg"
358 --extra-ldflags=*) LDFLAGS="$optarg"
360 --cpu=*) cpu="$optarg"
362 --target-list=*) target_list="$optarg"
364 --enable-gprof) gprof="yes"
366 --static) static="yes"
368 --disable-sdl) sdl="no"
370 --fmod-lib=*) fmod_lib="$optarg"
372 --fmod-inc=*) fmod_inc="$optarg"
374 --oss-lib=*) oss_lib="$optarg"
376 --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
378 --audio-drv-list=*) audio_drv_list="$optarg"
380 --enable-sparse) sparse="yes"
382 --disable-sparse) sparse="no"
384 --disable-vnc-tls) vnc_tls="no"
386 --disable-slirp) slirp="no"
388 --disable-vde) vde="no"
390 --disable-kqemu) kqemu="no"
392 --disable-brlapi) brlapi="no"
394 --disable-bluez) bluez="no"
396 --disable-kvm) kvm="no"
398 --enable-profiler) profiler="yes"
400 --enable-cocoa)
401 cocoa="yes" ;
402 sdl="no" ;
403 audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
405 --disable-gfx-check) check_gfx="no"
407 --disable-system) softmmu="no"
409 --enable-system) softmmu="yes"
411 --disable-linux-user) linux_user="no"
413 --enable-linux-user) linux_user="yes"
415 --disable-darwin-user) darwin_user="no"
417 --enable-darwin-user) darwin_user="yes"
419 --disable-bsd-user) bsd_user="no"
421 --enable-bsd-user) bsd_user="yes"
423 --enable-uname-release=*) uname_release="$optarg"
425 --sparc_cpu=*)
426 sparc_cpu="$optarg"
427 case $sparc_cpu in
428 v7|v8) SP_CFLAGS="-m32 -mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__"; SP_LDFLAGS="-m32"
429 target_cpu="sparc"; cpu="sparc" ;;
430 v8plus|v8plusa) SP_CFLAGS="-m32 -mcpu=ultrasparc -D__sparc_${sparc_cpu}__"; SP_LDFLAGS="-m32"
431 target_cpu="sparc"; cpu="sparc" ;;
432 v9) SP_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_${sparc_cpu}__"; SP_LDFLAGS="-m64"
433 target_cpu="sparc64"; cpu="sparc64" ;;
434 *) echo "undefined SPARC architecture. Exiting";exit 1;;
435 esac
437 --enable-werror) werror="yes"
439 --disable-werror) werror="no"
441 --disable-curses) curses="no"
443 --disable-nptl) nptl="no"
445 --enable-mixemu) mixemu="yes"
447 --disable-aio) aio="no"
449 --disable-blobs) blobs="no"
451 --kerneldir=*) kerneldir="$optarg"
453 --disable-cpu-emulation) cpu_emulation="no"
455 *) echo "ERROR: unknown option $opt"; exit 1
457 esac
458 done
460 # default flags for all hosts
461 CFLAGS="$CFLAGS -O2 -g -fno-strict-aliasing"
462 CFLAGS="$CFLAGS -Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls"
463 LDFLAGS="$LDFLAGS -g"
464 if test "$werror" = "yes" ; then
465 CFLAGS="$CFLAGS -Werror"
468 if test "$solaris" = "no" ; then
469 if ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
470 LDFLAGS="$LDFLAGS -Wl,--warn-common"
475 # If cpu ~= sparc and sparc_cpu hasn't been defined, plug in the right
476 # ARCH_CFLAGS/ARCH_LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
478 case "$cpu" in
479 sparc) if test -z "$sparc_cpu" ; then
480 ARCH_CFLAGS="-m32 -mcpu=ultrasparc -D__sparc_v8plus__"
481 ARCH_LDFLAGS="-m32"
482 else
483 ARCH_CFLAGS="${SP_CFLAGS}"
484 ARCH_LDFLAGS="${SP_LDFLAGS}"
487 sparc64) if test -z "$sparc_cpu" ; then
488 ARCH_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__"
489 ARCH_LDFLAGS="-m64"
490 else
491 ARCH_CFLAGS="${SP_CFLAGS}"
492 ARCH_LDFLAGS="${SP_LDFLAGS}"
495 s390)
496 ARCH_CFLAGS="-march=z900"
498 i386)
499 ARCH_CFLAGS="-m32"
500 ARCH_LDFLAGS="-m32"
502 x86_64)
503 ARCH_CFLAGS="-m64"
504 ARCH_LDFLAGS="-m64"
506 esac
508 if test x"$show_help" = x"yes" ; then
509 cat << EOF
511 Usage: configure [options]
512 Options: [defaults in brackets after descriptions]
515 echo "Standard options:"
516 echo " --help print this message"
517 echo " --prefix=PREFIX install in PREFIX [$prefix]"
518 echo " --interp-prefix=PREFIX where to find shared libraries, etc."
519 echo " use %M for cpu name [$interp_prefix]"
520 echo " --target-list=LIST set target list [$target_list]"
521 echo ""
522 echo "kqemu kernel acceleration support:"
523 echo " --disable-kqemu disable kqemu support"
524 echo ""
525 echo "Advanced options (experts only):"
526 echo " --source-path=PATH path of source code [$source_path]"
527 echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
528 echo " --cc=CC use C compiler CC [$cc]"
529 echo " --host-cc=CC use C compiler CC [$host_cc] for dyngen etc."
530 echo " --make=MAKE use specified make [$make]"
531 echo " --install=INSTALL use specified install [$install]"
532 echo " --static enable static build [$static]"
533 echo " --enable-sparse enable sparse checker"
534 echo " --disable-sparse disable sparse checker (default)"
535 echo " --disable-werror disable compilation abort on warning"
536 echo " --disable-sdl disable SDL"
537 echo " --enable-cocoa enable COCOA (Mac OS X only)"
538 echo " --audio-drv-list=LIST set audio drivers list:"
539 echo " Available drivers: $audio_possible_drivers"
540 echo " --audio-card-list=LIST set list of additional emulated audio cards"
541 echo " Available cards: ac97 adlib cs4231a gus"
542 echo " --enable-mixemu enable mixer emulation"
543 echo " --disable-brlapi disable BrlAPI"
544 echo " --disable-vnc-tls disable TLS encryption for VNC server"
545 echo " --disable-curses disable curses output"
546 echo " --disable-bluez disable bluez stack connectivity"
547 echo " --disable-kvm disable KVM acceleration support"
548 echo " --disable-nptl disable usermode NPTL support"
549 echo " --enable-system enable all system emulation targets"
550 echo " --disable-system disable all system emulation targets"
551 echo " --enable-linux-user enable all linux usermode emulation targets"
552 echo " --disable-linux-user disable all linux usermode emulation targets"
553 echo " --enable-darwin-user enable all darwin usermode emulation targets"
554 echo " --disable-darwin-user disable all darwin usermode emulation targets"
555 echo " --enable-bsd-user enable all BSD usermode emulation targets"
556 echo " --disable-bsd-user disable all BSD usermode emulation targets"
557 echo " --fmod-lib path to FMOD library"
558 echo " --fmod-inc path to FMOD includes"
559 echo " --oss-lib path to OSS library"
560 echo " --enable-uname-release=R Return R for uname -r in usermode emulation"
561 echo " --sparc_cpu=V Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
562 echo " --disable-vde disable support for vde network"
563 echo " --disable-aio disable AIO support"
564 echo " --disable-blobs disable installing provided firmware blobs"
565 echo " --kerneldir=PATH look for kernel includes in PATH"
566 echo " --disable-cpu-emulation disables use of qemu cpu emulation code"
567 echo ""
568 echo "NOTE: The object files are built at the place where configure is launched"
569 exit 1
572 if test "$mingw32" = "yes" ; then
573 linux="no"
574 EXESUF=".exe"
575 oss="no"
576 linux_user="no"
577 bsd_user="no"
580 if test ! -x "$(which cgcc 2>/dev/null)"; then
581 sparse="no"
585 # Solaris specific configure tool chain decisions
587 if test "$solaris" = "yes" ; then
588 solinst=`which $install 2> /dev/null | /usr/bin/grep -v "no $install in"`
589 if test -z "$solinst" ; then
590 echo "Solaris install program not found. Use --install=/usr/ucb/install or"
591 echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
592 echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
593 exit 1
595 if test "$solinst" = "/usr/sbin/install" ; then
596 echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
597 echo "try ginstall from the GNU fileutils available from www.blastwave.org"
598 echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
599 exit 1
601 sol_ar=`which ar 2> /dev/null | /usr/bin/grep -v "no ar in"`
602 if test -z "$sol_ar" ; then
603 echo "Error: No path includes ar"
604 if test -f /usr/ccs/bin/ar ; then
605 echo "Add /usr/ccs/bin to your path and rerun configure"
607 exit 1
612 if test -z "$target_list" ; then
613 # these targets are portable
614 if [ "$softmmu" = "yes" ] ; then
615 target_list="\
616 i386-softmmu \
617 x86_64-softmmu \
618 arm-softmmu \
619 cris-softmmu \
620 m68k-softmmu \
621 mips-softmmu \
622 mipsel-softmmu \
623 mips64-softmmu \
624 mips64el-softmmu \
625 ppc-softmmu \
626 ppcemb-softmmu \
627 ppc64-softmmu \
628 sh4-softmmu \
629 sh4eb-softmmu \
630 sparc-softmmu \
633 # the following are Linux specific
634 if [ "$linux_user" = "yes" ] ; then
635 target_list="${target_list}\
636 i386-linux-user \
637 x86_64-linux-user \
638 alpha-linux-user \
639 arm-linux-user \
640 armeb-linux-user \
641 cris-linux-user \
642 m68k-linux-user \
643 mips-linux-user \
644 mipsel-linux-user \
645 ppc-linux-user \
646 ppc64-linux-user \
647 ppc64abi32-linux-user \
648 sh4-linux-user \
649 sh4eb-linux-user \
650 sparc-linux-user \
651 sparc64-linux-user \
652 sparc32plus-linux-user \
655 # the following are Darwin specific
656 if [ "$darwin_user" = "yes" ] ; then
657 target_list="$target_list i386-darwin-user ppc-darwin-user "
659 # the following are BSD specific
660 if [ "$bsd_user" = "yes" ] ; then
661 target_list="${target_list}\
662 sparc64-bsd-user \
665 else
666 target_list=`echo "$target_list" | sed -e 's/,/ /g'`
668 if test -z "$target_list" ; then
669 echo "No targets enabled"
670 exit 1
673 if test -z "$cross_prefix" ; then
675 # ---
676 # big/little endian test
677 cat > $TMPC << EOF
678 #include <inttypes.h>
679 int main(int argc, char ** argv){
680 volatile uint32_t i=0x01234567;
681 return (*((uint8_t*)(&i))) == 0x67;
685 if $cc $ARCH_CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
686 $TMPE && bigendian="yes"
687 else
688 echo big/little test failed
691 else
693 # if cross compiling, cannot launch a program, so make a static guess
694 if test "$cpu" = "armv4b" \
695 -o "$cpu" = "hppa" \
696 -o "$cpu" = "m68k" \
697 -o "$cpu" = "mips" \
698 -o "$cpu" = "mips64" \
699 -o "$cpu" = "powerpc" \
700 -o "$cpu" = "s390" \
701 -o "$cpu" = "sparc" \
702 -o "$cpu" = "sparc64"; then
703 bigendian="yes"
708 # host long bits test
709 hostlongbits="32"
710 if test "$cpu" = "x86_64" \
711 -o "$cpu" = "alpha" \
712 -o "$cpu" = "ia64" \
713 -o "$cpu" = "sparc64"; then
714 hostlongbits="64"
717 # ppc specific hostlongbits selection
718 if test "$cpu" = "powerpc" ; then
719 if $cc $ARCH_CFLAGS -dM -E - -o $TMPI 2>/dev/null </dev/null; then
720 grep -q __powerpc64__ $TMPI && hostlongbits=64
721 else
722 echo hostlongbits test failed
723 exit 1
727 # check gcc options support
728 cat > $TMPC <<EOF
729 int main(void) {
733 # Check host NPTL support
734 cat > $TMPC <<EOF
735 #include <sched.h>
736 #include <linux/futex.h>
737 void foo()
739 #if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
740 #error bork
741 #endif
745 if $cc $ARCH_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null ; then
747 else
748 nptl="no"
751 ##########################################
752 # KVM probe
754 if test "$kvm" = "yes" ; then
756 # test for KVM_CAP_PIT
758 cat > $TMPC <<EOF
759 #include <libkvm.h>
760 #ifndef KVM_CAP_PIT
761 #error "kvm no pit capability"
762 #endif
763 int main(void) { return 0; }
765 if $cc $ARCH_CFLAGS $CFLAGS -I"$kerneldir"/include -o $TMPE ${OS_CFLAGS} $TMPC 2> /dev/null ; then
766 kvm_cap_pit="yes"
769 # test for KVM_CAP_DEVICE_ASSIGNMENT
771 cat > $TMPC <<EOF
772 #include <libkvm.h>
773 #ifndef KVM_CAP_DEVICE_ASSIGNMENT
774 #error "kvm no device assignment capability"
775 #endif
776 int main(void) { return 0; }
778 if $cc $ARCH_CFLAGS $CFLAGS -I"$kerneldir"/include -o $TMPE ${OS_CFLAGS} $TMPC 2> /dev/null ; then
779 kvm_cap_device_assignment="yes"
783 ##########################################
784 # zlib check
786 cat > $TMPC << EOF
787 #include <zlib.h>
788 int main(void) { zlibVersion(); return 0; }
790 if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $TMPC -lz > /dev/null 2> /dev/null ; then
792 else
793 echo
794 echo "Error: zlib check failed"
795 echo "Make sure to have the zlib libs and headers installed."
796 echo
797 exit 1
800 ##########################################
801 # SDL probe
803 sdl_too_old=no
805 if test -z "$sdl" ; then
806 sdl_config="sdl-config"
807 sdl=no
808 sdl_static=no
810 cat > $TMPC << EOF
811 #include <SDL.h>
812 #undef main /* We don't want SDL to override our main() */
813 int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
815 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
816 _sdlversion=`$sdl_config --version | sed 's/[^0-9]//g'`
817 if test "$_sdlversion" -lt 121 ; then
818 sdl_too_old=yes
819 else
820 if test "$cocoa" = "no" ; then
821 sdl=yes
825 # static link with sdl ?
826 if test "$sdl" = "yes" ; then
827 aa="no"
828 `$sdl_config --static-libs 2>/dev/null | grep \\\-laa > /dev/null` && aa="yes"
829 sdl_static_libs=`$sdl_config --static-libs 2>/dev/null`
830 if [ "$aa" = "yes" ] ; then
831 sdl_static_libs="$sdl_static_libs `aalib-config --static-libs`"
834 if $cc -o $TMPE ${OS_CFLAGS} `$sdl_config --cflags 2> /dev/null` $TMPC $sdl_static_libs > /dev/null 2> /dev/null; then
835 sdl_static=yes
837 fi # static link
838 fi # sdl compile test
839 else
840 # Make sure to disable cocoa if sdl was set
841 if test "$sdl" = "yes" ; then
842 cocoa="no"
843 audio_drv_list="`echo $audio_drv_list | sed s,coreaudio,,g`"
845 fi # -z $sdl
847 ##########################################
848 # VNC TLS detection
849 if test "$vnc_tls" = "yes" ; then
850 cat > $TMPC <<EOF
851 #include <gnutls/gnutls.h>
852 int main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
854 vnc_tls_cflags=`pkg-config --cflags gnutls 2> /dev/null`
855 vnc_tls_libs=`pkg-config --libs gnutls 2> /dev/null`
856 if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $vnc_tls_cflags $TMPC \
857 $vnc_tls_libs > /dev/null 2> /dev/null ; then
859 else
860 vnc_tls="no"
864 ##########################################
865 # vde libraries probe
866 if test "$vde" = "yes" ; then
867 cat > $TMPC << EOF
868 #include <libvdeplug.h>
869 int main(void)
871 struct vde_open_args a = {0, 0, 0};
872 vde_open("", "", &a);
873 return 0;
876 if $cc $ARCH_CFLAGS -o $TMPE $TMPC -lvdeplug > /dev/null 2> /dev/null ; then
878 else
879 vde="no"
883 ##########################################
884 # Sound support libraries probe
886 audio_drv_probe()
888 drv=$1
889 hdr=$2
890 lib=$3
891 exp=$4
892 cfl=$5
893 cat > $TMPC << EOF
894 #include <$hdr>
895 int main(void) { $exp }
897 if $cc $ARCH_CFLAGS $cfl -o $TMPE $TMPC $lib > /dev/null 2> /dev/null ; then
899 else
900 echo
901 echo "Error: $drv check failed"
902 echo "Make sure to have the $drv libs and headers installed."
903 echo
904 exit 1
908 audio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
909 for drv in $audio_drv_list; do
910 case $drv in
911 alsa)
912 audio_drv_probe $drv alsa/asoundlib.h -lasound \
913 "snd_pcm_t **handle; return snd_pcm_close(*handle);"
916 fmod)
917 if test -z $fmod_lib || test -z $fmod_inc; then
918 echo
919 echo "Error: You must specify path to FMOD library and headers"
920 echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
921 echo
922 exit 1
924 audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
927 esd)
928 audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
932 audio_drv_probe $drv pulse/simple.h -lpulse-simple \
933 "pa_simple *s = NULL; pa_simple_free(s); return 0;"
936 oss|sdl|core|wav|dsound)
937 # XXX: Probes for CoreAudio, DirectSound, SDL(?)
941 echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
942 echo
943 echo "Error: Unknown driver '$drv' selected"
944 echo "Possible drivers are: $audio_possible_drivers"
945 echo
946 exit 1
949 esac
950 done
952 ##########################################
953 # BrlAPI probe
955 if test -z "$brlapi" ; then
956 brlapi=no
957 cat > $TMPC << EOF
958 #include <brlapi.h>
959 int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
961 if $cc ${ARCH_CFLAGS} -o $TMPE ${OS_CFLAGS} $TMPC -lbrlapi > /dev/null 2> /dev/null ; then
962 brlapi=yes
963 fi # brlapi compile test
964 fi # -z $brlapi
966 ##########################################
967 # curses probe
969 if test "$curses" = "yes" ; then
970 curses=no
971 cat > $TMPC << EOF
972 #include <curses.h>
973 int main(void) { return curses_version(); }
975 if $cc $ARCH_CFLAGS -o $TMPE $TMPC -lcurses > /dev/null 2> /dev/null ; then
976 curses=yes
978 fi # test "$curses"
980 ##########################################
981 # bluez support probe
982 if test "$bluez" = "yes" ; then
983 `pkg-config bluez` || bluez="no"
985 if test "$bluez" = "yes" ; then
986 cat > $TMPC << EOF
987 #include <bluetooth/bluetooth.h>
988 int main(void) { return bt_error(0); }
990 bluez_cflags=`pkg-config --cflags bluez`
991 bluez_libs=`pkg-config --libs bluez`
992 if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $bluez_cflags $TMPC \
993 $bluez_libs > /dev/null 2> /dev/null ; then
995 else
996 bluez="no"
1000 ##########################################
1001 # kvm probe
1002 if test "$kvm" = "yes" ; then
1003 cat > $TMPC <<EOF
1004 #include <linux/kvm.h>
1005 #if !defined(KVM_API_VERSION) || \
1006 KVM_API_VERSION < 12 || \
1007 KVM_API_VERSION > 12 || \
1008 !defined(KVM_CAP_USER_MEMORY) || \
1009 !defined(KVM_CAP_SET_TSS_ADDR) || \
1010 !defined(KVM_CAP_DESTROY_MEMORY_REGION_WORKS)
1011 #error Invalid KVM version
1012 #endif
1013 int main(void) { return 0; }
1015 if test "$kerneldir" != "" ; then
1016 kvm_cflags=-I"$kerneldir"/include
1017 else
1018 kvm_cflags=""
1020 if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $kvm_cflags $TMPC \
1021 > /dev/null 2>/dev/null ; then
1023 else
1024 kvm="no"
1028 ##########################################
1029 # AIO probe
1030 AIOLIBS=""
1032 if test "$aio" = "yes" ; then
1033 aio=no
1034 cat > $TMPC << EOF
1035 #include <pthread.h>
1036 int main(void) { pthread_mutex_t lock; return 0; }
1038 if $cc $ARCH_CFLAGS -o $TMPE $AIOLIBS $TMPC 2> /dev/null ; then
1039 aio=yes
1040 AIOLIBS="-lpthread"
1044 ##########################################
1045 # iovec probe
1046 cat > $TMPC <<EOF
1047 #include <sys/uio.h>
1048 int main(void) { struct iovec iov; return 0; }
1050 iovec=no
1051 if $cc $ARCH_CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
1052 iovec=yes
1055 ##########################################
1056 # fdt probe
1057 if test "$fdt" = "yes" ; then
1058 fdt=no
1059 cat > $TMPC << EOF
1060 int main(void) { return 0; }
1062 if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $TMPC -lfdt 2> /dev/null ; then
1063 fdt=yes
1067 ##########################################
1068 # signalfd probe
1069 cat > $TMPC << EOF
1070 #define _GNU_SOURCE
1071 #include <unistd.h>
1072 #include <sys/syscall.h>
1073 #include <signal.h>
1074 int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
1077 if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
1078 signalfd=yes
1081 ##########################################
1082 # eventfd probe
1083 cat > $TMPC << EOF
1084 #define _GNU_SOURCE
1085 #include <unistd.h>
1086 #include <sys/syscall.h>
1087 int main(void) { return syscall(SYS_eventfd, 0); }
1090 if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
1091 eventfd=yes
1094 # Check if tools are available to build documentation.
1095 if [ -x "`which texi2html 2>/dev/null`" ] && \
1096 [ -x "`which pod2man 2>/dev/null`" ]; then
1097 build_docs="yes"
1100 ##########################################
1101 # Do we need librt
1102 cat > $TMPC <<EOF
1103 #include <signal.h>
1104 #include <time.h>
1105 int main(void) { clockid_t id; return clock_gettime(id, NULL); }
1108 rt=no
1109 if $cc $ARCH_CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
1111 elif $cc $ARCH_CFLAGS -o $TMPE $TMPC -lrt > /dev/null 2> /dev/null ; then
1112 rt=yes
1115 if test "$rt" = "yes" ; then
1116 # Hack, we should have a general purpose LIBS for this sort of thing
1117 AIOLIBS="$AIOLIBS -lrt"
1120 if test "$mingw32" = "yes" ; then
1121 if test -z "$prefix" ; then
1122 prefix="c:\\\\Program Files\\\\Qemu"
1124 mansuffix=""
1125 datasuffix=""
1126 docsuffix=""
1127 binsuffix=""
1128 else
1129 if test -z "$prefix" ; then
1130 prefix="/usr/local"
1132 mansuffix="/share/man"
1133 datasuffix="/share/qemu"
1134 docsuffix="/share/doc/qemu"
1135 binsuffix="/bin"
1138 echo "Install prefix $prefix"
1139 echo "BIOS directory $prefix$datasuffix"
1140 echo "binary directory $prefix$binsuffix"
1141 if test "$mingw32" = "no" ; then
1142 echo "Manual directory $prefix$mansuffix"
1143 echo "ELF interp prefix $interp_prefix"
1145 echo "Source path $source_path"
1146 echo "C compiler $cc"
1147 echo "Host C compiler $host_cc"
1148 echo "ARCH_CFLAGS $ARCH_CFLAGS"
1149 echo "make $make"
1150 echo "install $install"
1151 echo "host CPU $cpu"
1152 echo "host big endian $bigendian"
1153 echo "target list $target_list"
1154 echo "gprof enabled $gprof"
1155 echo "sparse enabled $sparse"
1156 echo "profiler $profiler"
1157 echo "static build $static"
1158 echo "-Werror enabled $werror"
1159 if test "$darwin" = "yes" ; then
1160 echo "Cocoa support $cocoa"
1162 echo "SDL support $sdl"
1163 if test "$sdl" != "no" ; then
1164 echo "SDL static link $sdl_static"
1166 echo "curses support $curses"
1167 echo "mingw32 support $mingw32"
1168 echo "Audio drivers $audio_drv_list"
1169 echo "Extra audio cards $audio_card_list"
1170 echo "Mixer emulation $mixemu"
1171 echo "VNC TLS support $vnc_tls"
1172 if test "$vnc_tls" = "yes" ; then
1173 echo " TLS CFLAGS $vnc_tls_cflags"
1174 echo " TLS LIBS $vnc_tls_libs"
1176 if test -n "$sparc_cpu"; then
1177 echo "Target Sparc Arch $sparc_cpu"
1179 echo "kqemu support $kqemu"
1180 echo "kvm support $kvm"
1181 echo "CPU emulation $cpu_emulation"
1182 echo "brlapi support $brlapi"
1183 echo "Documentation $build_docs"
1184 [ ! -z "$uname_release" ] && \
1185 echo "uname -r $uname_release"
1186 echo "NPTL support $nptl"
1187 echo "vde support $vde"
1188 echo "AIO support $aio"
1189 echo "Install blobs $blobs"
1190 echo "KVM support $kvm"
1191 echo "fdt support $fdt"
1193 if test $sdl_too_old = "yes"; then
1194 echo "-> Your SDL version is too old - please upgrade to have SDL support"
1196 if [ -s $TMPSDLLOG ]; then
1197 echo "The error log from compiling the libSDL test is: "
1198 cat $TMPSDLLOG
1200 #if test "$sdl_static" = "no"; then
1201 # echo "WARNING: cannot compile statically with SDL - qemu-fast won't have a graphical output"
1203 config_mak="config-host.mak"
1204 config_h="config-host.h"
1206 #echo "Creating $config_mak and $config_h"
1208 test -f $config_h && mv $config_h ${config_h}~
1210 echo "# Automatically generated by configure - do not modify" > $config_mak
1211 printf "# Configured with:" >> $config_mak
1212 printf " '%s'" "$0" "$@" >> $config_mak
1213 echo >> $config_mak
1214 echo "/* Automatically generated by configure - do not modify */" > $config_h
1216 echo "prefix=$prefix" >> $config_mak
1217 echo "bindir=\${prefix}$binsuffix" >> $config_mak
1218 echo "mandir=\${prefix}$mansuffix" >> $config_mak
1219 echo "datadir=\${prefix}$datasuffix" >> $config_mak
1220 echo "docdir=\${prefix}$docsuffix" >> $config_mak
1221 echo "#define CONFIG_QEMU_SHAREDIR \"$prefix$datasuffix\"" >> $config_h
1222 echo "MAKE=$make" >> $config_mak
1223 echo "INSTALL=$install" >> $config_mak
1224 echo "CC=$cc" >> $config_mak
1225 echo "HOST_CC=$host_cc" >> $config_mak
1226 echo "AR=$ar" >> $config_mak
1227 echo "STRIP=$strip -s -R .comment -R .note" >> $config_mak
1228 # XXX: only use CFLAGS and LDFLAGS ?
1229 # XXX: should export HOST_CFLAGS and HOST_LDFLAGS for cross
1230 # compilation of dyngen tool (useful for win32 build on Linux host)
1231 echo "OS_CFLAGS=$OS_CFLAGS" >> $config_mak
1232 echo "OS_LDFLAGS=$OS_LDFLAGS" >> $config_mak
1233 echo "ARCH_CFLAGS=$ARCH_CFLAGS" >> $config_mak
1234 echo "ARCH_LDFLAGS=$ARCH_LDFLAGS" >> $config_mak
1235 echo "CFLAGS=$CFLAGS" >> $config_mak
1236 echo "LDFLAGS=$LDFLAGS" >> $config_mak
1237 echo "EXESUF=$EXESUF" >> $config_mak
1238 echo "AIOLIBS=$AIOLIBS" >> $config_mak
1239 case "$cpu" in
1240 i386)
1241 echo "ARCH=i386" >> $config_mak
1242 echo "#define HOST_I386 1" >> $config_h
1244 x86_64)
1245 echo "ARCH=x86_64" >> $config_mak
1246 echo "#define HOST_X86_64 1" >> $config_h
1248 alpha)
1249 echo "ARCH=alpha" >> $config_mak
1250 echo "#define HOST_ALPHA 1" >> $config_h
1252 armv4b)
1253 echo "ARCH=arm" >> $config_mak
1254 echo "#define HOST_ARM 1" >> $config_h
1256 armv4l)
1257 echo "ARCH=arm" >> $config_mak
1258 echo "#define HOST_ARM 1" >> $config_h
1260 cris)
1261 echo "ARCH=cris" >> $config_mak
1262 echo "#define HOST_CRIS 1" >> $config_h
1264 hppa)
1265 echo "ARCH=hppa" >> $config_mak
1266 echo "#define HOST_HPPA 1" >> $config_h
1268 ia64)
1269 echo "ARCH=ia64" >> $config_mak
1270 echo "#define HOST_IA64 1" >> $config_h
1272 m68k)
1273 echo "ARCH=m68k" >> $config_mak
1274 echo "#define HOST_M68K 1" >> $config_h
1276 mips)
1277 echo "ARCH=mips" >> $config_mak
1278 echo "#define HOST_MIPS 1" >> $config_h
1280 mips64)
1281 echo "ARCH=mips64" >> $config_mak
1282 echo "#define HOST_MIPS64 1" >> $config_h
1284 powerpc)
1285 if test "$hostlongbits" = "32"; then
1286 echo "ARCH=ppc" >> $config_mak
1287 echo "#define HOST_PPC 1" >> $config_h
1288 else
1289 echo "ARCH=ppc64" >> $config_mak
1290 echo "#define HOST_PPC64 1" >> $config_h
1293 s390)
1294 echo "ARCH=s390" >> $config_mak
1295 echo "#define HOST_S390 1" >> $config_h
1297 sparc)
1298 echo "ARCH=sparc" >> $config_mak
1299 echo "#define HOST_SPARC 1" >> $config_h
1301 sparc64)
1302 echo "ARCH=sparc64" >> $config_mak
1303 echo "#define HOST_SPARC64 1" >> $config_h
1306 echo "Unsupported CPU = $cpu"
1307 exit 1
1309 esac
1310 if test "$sparse" = "yes" ; then
1311 echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_mak
1312 echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_mak
1313 echo "CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_mak
1315 if test "$bigendian" = "yes" ; then
1316 echo "WORDS_BIGENDIAN=yes" >> $config_mak
1317 echo "#define WORDS_BIGENDIAN 1" >> $config_h
1319 echo "#define HOST_LONG_BITS $hostlongbits" >> $config_h
1320 if test "$mingw32" = "yes" ; then
1321 echo "CONFIG_WIN32=yes" >> $config_mak
1322 echo "#define CONFIG_WIN32 1" >> $config_h
1323 else
1324 cat > $TMPC << EOF
1325 #include <byteswap.h>
1326 int main(void) { return bswap_32(0); }
1328 if $cc $ARCH_CFLAGS -o $TMPE $TMPC >/dev/null 2> /dev/null ; then
1329 echo "#define HAVE_BYTESWAP_H 1" >> $config_h
1331 cat > $TMPC << EOF
1332 #include <sys/endian.h>
1333 #include <sys/types.h>
1334 #include <machine/bswap.h>
1335 int main(void) { return bswap32(0); }
1337 if $cc $ARCH_CFLAGS -o $TMPE $TMPC >/dev/null 2> /dev/null ; then
1338 echo "#define HAVE_MACHINE_BSWAP_H 1" >> $config_h
1342 if [ "$openbsd" = "yes" ] ; then
1343 echo "#define ENOTSUP 4096" >> $config_h
1346 if test "$darwin" = "yes" ; then
1347 echo "CONFIG_DARWIN=yes" >> $config_mak
1348 echo "#define CONFIG_DARWIN 1" >> $config_h
1351 if test "$aix" = "yes" ; then
1352 echo "CONFIG_AIX=yes" >> $config_mak
1353 echo "#define CONFIG_AIX 1" >> $config_h
1356 if test "$solaris" = "yes" ; then
1357 echo "CONFIG_SOLARIS=yes" >> $config_mak
1358 echo "#define HOST_SOLARIS $solarisrev" >> $config_h
1359 if test "$needs_libsunmath" = "yes" ; then
1360 echo "NEEDS_LIBSUNMATH=yes" >> $config_mak
1361 echo "#define NEEDS_LIBSUNMATH 1" >> $config_h
1364 if test -n "$sparc_cpu"; then
1365 echo "CONFIG__sparc_${sparc_cpu}__=yes" >> $config_mak
1366 echo "#define __sparc_${sparc_cpu}__ 1" >> $config_h
1368 if test "$gdbstub" = "yes" ; then
1369 echo "CONFIG_GDBSTUB=yes" >> $config_mak
1370 echo "#define CONFIG_GDBSTUB 1" >> $config_h
1372 if test "$gprof" = "yes" ; then
1373 echo "TARGET_GPROF=yes" >> $config_mak
1374 echo "#define HAVE_GPROF 1" >> $config_h
1376 if test "$static" = "yes" ; then
1377 echo "CONFIG_STATIC=yes" >> $config_mak
1378 echo "#define CONFIG_STATIC 1" >> $config_h
1380 if test $profiler = "yes" ; then
1381 echo "#define CONFIG_PROFILER 1" >> $config_h
1383 if test "$slirp" = "yes" ; then
1384 echo "CONFIG_SLIRP=yes" >> $config_mak
1385 echo "#define CONFIG_SLIRP 1" >> $config_h
1387 if test "$vde" = "yes" ; then
1388 echo "CONFIG_VDE=yes" >> $config_mak
1389 echo "#define CONFIG_VDE 1" >> $config_h
1390 echo "VDE_LIBS=-lvdeplug" >> $config_mak
1392 for card in $audio_card_list; do
1393 def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
1394 echo "$def=yes" >> $config_mak
1395 echo "#define $def 1" >> $config_h
1396 done
1397 echo "#define AUDIO_DRIVERS \\" >> $config_h
1398 for drv in $audio_drv_list; do
1399 echo " &${drv}_audio_driver, \\" >>$config_h
1400 def=CONFIG_`echo $drv | tr '[:lower:]' '[:upper:]'`
1401 echo "$def=yes" >> $config_mak
1402 if test "$drv" = "fmod"; then
1403 echo "CONFIG_FMOD_LIB=$fmod_lib" >> $config_mak
1404 echo "CONFIG_FMOD_INC=$fmod_inc" >> $config_mak
1405 elif test "$drv" = "oss"; then
1406 echo "CONFIG_OSS_LIB=$oss_lib" >> $config_mak
1408 done
1409 echo "" >>$config_h
1410 if test "$mixemu" = "yes" ; then
1411 echo "CONFIG_MIXEMU=yes" >> $config_mak
1412 echo "#define CONFIG_MIXEMU 1" >> $config_h
1414 if test "$vnc_tls" = "yes" ; then
1415 echo "CONFIG_VNC_TLS=yes" >> $config_mak
1416 echo "CONFIG_VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_mak
1417 echo "CONFIG_VNC_TLS_LIBS=$vnc_tls_libs" >> $config_mak
1418 echo "#define CONFIG_VNC_TLS 1" >> $config_h
1420 qemu_version=`head $source_path/VERSION`
1421 echo "VERSION=$qemu_version" >>$config_mak
1422 echo "#define QEMU_VERSION \"$qemu_version\"" >> $config_h
1423 echo "#define KVM_VERSION \"kvm-devel\"" >> $config_h
1425 echo "SRC_PATH=$source_path" >> $config_mak
1426 if [ "$source_path_used" = "yes" ]; then
1427 echo "VPATH=$source_path" >> $config_mak
1429 echo "TARGET_DIRS=$target_list" >> $config_mak
1430 if [ "$build_docs" = "yes" ] ; then
1431 echo "BUILD_DOCS=yes" >> $config_mak
1433 if test "$static" = "yes"; then
1434 sdl1=$sdl_static
1435 else
1436 sdl1=$sdl
1438 if test "$sdl1" = "yes" ; then
1439 echo "#define CONFIG_SDL 1" >> $config_h
1440 echo "CONFIG_SDL=yes" >> $config_mak
1441 if test "$target_softmmu" = "no" -o "$static" = "yes"; then
1442 echo "SDL_LIBS=$sdl_static_libs" >> $config_mak
1443 else
1444 echo "SDL_LIBS=`$sdl_config --libs`" >> $config_mak
1446 if [ "${aa}" = "yes" ] ; then
1447 echo "SDL_CFLAGS=`$sdl_config --cflags` `aalib-config --cflags`" >> $config_mak
1448 else
1449 echo "SDL_CFLAGS=`$sdl_config --cflags`" >> $config_mak
1452 if test "$cocoa" = "yes" ; then
1453 echo "#define CONFIG_COCOA 1" >> $config_h
1454 echo "CONFIG_COCOA=yes" >> $config_mak
1456 if test "$curses" = "yes" ; then
1457 echo "#define CONFIG_CURSES 1" >> $config_h
1458 echo "CONFIG_CURSES=yes" >> $config_mak
1459 echo "CURSES_LIBS=-lcurses" >> $config_mak
1461 if test "$brlapi" = "yes" ; then
1462 echo "CONFIG_BRLAPI=yes" >> $config_mak
1463 echo "#define CONFIG_BRLAPI 1" >> $config_h
1464 echo "BRLAPI_LIBS=-lbrlapi" >> $config_mak
1466 if test "$bluez" = "yes" ; then
1467 echo "CONFIG_BLUEZ=yes" >> $config_mak
1468 echo "CONFIG_BLUEZ_CFLAGS=$bluez_cflags" >> $config_mak
1469 echo "CONFIG_BLUEZ_LIBS=$bluez_libs" >> $config_mak
1470 echo "#define CONFIG_BLUEZ 1" >> $config_h
1472 if test "$aio" = "yes" ; then
1473 echo "#define CONFIG_AIO 1" >> $config_h
1474 echo "CONFIG_AIO=yes" >> $config_mak
1476 if test "$blobs" = "yes" ; then
1477 echo "INSTALL_BLOBS=yes" >> $config_mak
1479 if test "$iovec" = "yes" ; then
1480 echo "#define HAVE_IOVEC 1" >> $config_h
1482 if test "$fdt" = "yes" ; then
1483 echo "#define HAVE_FDT 1" >> $config_h
1484 echo "FDT_LIBS=-lfdt" >> $config_mak
1486 if test "$signalfd" = "yes" ; then
1487 echo "#define CONFIG_signalfd 1" >> $config_h
1489 if test "$eventfd" = "yes" ; then
1490 echo "#define CONFIG_eventfd 1" >> $config_h
1493 # XXX: suppress that
1494 if [ "$bsd" = "yes" ] ; then
1495 echo "#define O_LARGEFILE 0" >> $config_h
1496 echo "#define MAP_ANONYMOUS MAP_ANON" >> $config_h
1497 echo "#define _BSD 1" >> $config_h
1500 echo "#define CONFIG_UNAME_RELEASE \"$uname_release\"" >> $config_h
1502 # USB host support
1503 case "$usb" in
1504 linux)
1505 echo "HOST_USB=linux" >> $config_mak
1507 bsd)
1508 echo "HOST_USB=bsd" >> $config_mak
1511 echo "HOST_USB=stub" >> $config_mak
1513 esac
1515 tools=
1516 if test `expr "$target_list" : ".*softmmu.*"` != 0 ; then
1517 tools="qemu-img\$(EXESUF) $tools"
1518 if [ "$linux" = "yes" ] ; then
1519 tools="qemu-nbd\$(EXESUF) $tools"
1522 echo "TOOLS=$tools" >> $config_mak
1524 test -f ${config_h}~ && cmp -s $config_h ${config_h}~ && mv ${config_h}~ $config_h
1526 for target in $target_list; do
1527 target_dir="$target"
1528 config_mak=$target_dir/config.mak
1529 config_h=$target_dir/config.h
1530 target_cpu=`echo $target | cut -d '-' -f 1`
1531 target_bigendian="no"
1532 [ "$target_cpu" = "armeb" ] && target_bigendian=yes
1533 [ "$target_cpu" = "m68k" ] && target_bigendian=yes
1534 [ "$target_cpu" = "mips" ] && target_bigendian=yes
1535 [ "$target_cpu" = "mipsn32" ] && target_bigendian=yes
1536 [ "$target_cpu" = "mips64" ] && target_bigendian=yes
1537 [ "$target_cpu" = "ppc" ] && target_bigendian=yes
1538 [ "$target_cpu" = "ppcemb" ] && target_bigendian=yes
1539 [ "$target_cpu" = "ppc64" ] && target_bigendian=yes
1540 [ "$target_cpu" = "ppc64abi32" ] && target_bigendian=yes
1541 [ "$target_cpu" = "sh4eb" ] && target_bigendian=yes
1542 [ "$target_cpu" = "sparc" ] && target_bigendian=yes
1543 [ "$target_cpu" = "sparc64" ] && target_bigendian=yes
1544 [ "$target_cpu" = "sparc32plus" ] && target_bigendian=yes
1545 target_softmmu="no"
1546 target_user_only="no"
1547 target_linux_user="no"
1548 target_darwin_user="no"
1549 target_bsd_user="no"
1550 case "$target" in
1551 ${target_cpu}-softmmu)
1552 target_softmmu="yes"
1554 ${target_cpu}-linux-user)
1555 target_user_only="yes"
1556 target_linux_user="yes"
1558 ${target_cpu}-darwin-user)
1559 target_user_only="yes"
1560 target_darwin_user="yes"
1562 ${target_cpu}-bsd-user)
1563 target_user_only="yes"
1564 target_bsd_user="yes"
1567 echo "ERROR: Target '$target' not recognised"
1568 exit 1
1570 esac
1572 if test "$target_user_only" = "no" -a "$check_gfx" = "yes" \
1573 -a "$sdl" = "no" -a "$cocoa" = "no" ; then
1574 echo "ERROR: QEMU requires SDL or Cocoa for graphical output"
1575 echo "To build QEMU without graphical output configure with --disable-gfx-check"
1576 echo "Note that this will disable all output from the virtual graphics card"
1577 echo "except through VNC or curses."
1578 exit 1;
1581 #echo "Creating $config_mak, $config_h and $target_dir/Makefile"
1583 test -f $config_h && mv $config_h ${config_h}~
1585 mkdir -p $target_dir
1586 mkdir -p $target_dir/fpu
1587 mkdir -p $target_dir/tcg
1588 if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
1589 mkdir -p $target_dir/nwfpe
1593 # don't use ln -sf as not all "ln -sf" over write the file/link
1595 rm -f $target_dir/Makefile
1596 ln -s $source_path/Makefile.target $target_dir/Makefile
1599 echo "# Automatically generated by configure - do not modify" > $config_mak
1600 echo "/* Automatically generated by configure - do not modify */" > $config_h
1603 echo "include ../config-host.mak" >> $config_mak
1604 echo "#include \"../config-host.h\"" >> $config_h
1606 bflt="no"
1607 elfload32="no"
1608 target_nptl="no"
1609 interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_cpu/g"`
1610 echo "#define CONFIG_QEMU_PREFIX \"$interp_prefix1\"" >> $config_h
1611 gdb_xml_files=""
1613 disable_cpu_emulation() {
1614 if test $cpu_emulation = "no"; then
1615 echo "#define NO_CPU_EMULATION 1" >> $config_h
1616 echo "NO_CPU_EMULATION=1" >> $config_mak
1620 configure_kvm() {
1621 if test $kvm = "yes" -a "$target_softmmu" = "yes" -a \
1622 \( "$cpu" = "i386" -o "$cpu" = "x86_64" -o "$cpu" = "ia64" -o "$cpu" = "powerpc" \); then
1623 echo "#define USE_KVM 1" >> $config_h
1624 echo "USE_KVM=1" >> $config_mak
1625 echo "CONFIG_KVM_KERNEL_INC=$kerneldir/include" >> $config_mak
1626 if test $kvm_cap_pit = "yes" ; then
1627 echo "USE_KVM_PIT=1" >> $config_mak
1628 echo "#define USE_KVM_PIT 1" >> $config_h
1630 if test $kvm_cap_device_assignment = "yes" ; then
1631 echo "USE_KVM_DEVICE_ASSIGNMENT=1" >> $config_mak
1632 echo "#define USE_KVM_DEVICE_ASSIGNMENT 1" >> $config_h
1634 disable_cpu_emulation
1638 if [ use_upstream_kvm = yes ]; then
1640 # Make sure the target and host cpus are compatible
1641 if test "$kvm" = "yes" -a ! \( "$target_cpu" = "$cpu" -o \
1642 \( "$target_cpu" = "ppcemb" -a "$cpu" = "powerpc" \) -o \
1643 \( "$target_cpu" = "x86_64" -a "$cpu" = "i386" \) -o \
1644 \( "$target_cpu" = "i386" -a "$cpu" = "x86_64" \) \) ; then
1645 kvm="no"
1647 # Disable KVM for linux-user
1648 if test "$kvm" = "yes" -a "$target_softmmu" = "no" ; then
1649 kvm="no"
1654 case "$target_cpu" in
1655 i386)
1656 echo "TARGET_ARCH=i386" >> $config_mak
1657 echo "#define TARGET_ARCH \"i386\"" >> $config_h
1658 echo "#define TARGET_I386 1" >> $config_h
1659 if test $kqemu = "yes" -a "$target_softmmu" = "yes"
1660 then
1661 echo "#define USE_KQEMU 1" >> $config_h
1663 if test "$kvm" = "yes" ; then
1664 echo "CONFIG_KVM=yes" >> $config_mak
1665 echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak
1666 echo "#define CONFIG_KVM 1" >> $config_h
1668 configure_kvm
1670 x86_64)
1671 echo "TARGET_ARCH=x86_64" >> $config_mak
1672 echo "#define TARGET_ARCH \"x86_64\"" >> $config_h
1673 echo "#define TARGET_I386 1" >> $config_h
1674 echo "#define TARGET_X86_64 1" >> $config_h
1675 if test $kqemu = "yes" -a "$target_softmmu" = "yes" -a $cpu = "x86_64"
1676 then
1677 echo "#define USE_KQEMU 1" >> $config_h
1679 configure_kvm
1681 ia64)
1682 echo "TARGET_ARCH=ia64" >> $config_mak
1683 echo "#define TARGET_ARCH \"ia64\"" >> $config_h
1684 echo "#define TARGET_IA64 1" >> $config_h
1685 configure_kvm
1686 if [ use_upstream_kvm = yes ]; then
1687 if test "$kvm" = "yes" ; then
1688 echo "CONFIG_KVM=yes" >> $config_mak
1689 echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak
1690 echo "#define CONFIG_KVM 1" >> $config_h
1694 alpha)
1695 echo "TARGET_ARCH=alpha" >> $config_mak
1696 echo "#define TARGET_ARCH \"alpha\"" >> $config_h
1697 echo "#define TARGET_ALPHA 1" >> $config_h
1699 arm|armeb)
1700 echo "TARGET_ARCH=arm" >> $config_mak
1701 echo "#define TARGET_ARCH \"arm\"" >> $config_h
1702 echo "#define TARGET_ARM 1" >> $config_h
1703 bflt="yes"
1704 target_nptl="yes"
1705 gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
1707 cris)
1708 echo "TARGET_ARCH=cris" >> $config_mak
1709 echo "#define TARGET_ARCH \"cris\"" >> $config_h
1710 echo "#define TARGET_CRIS 1" >> $config_h
1711 target_nptl="yes"
1713 m68k)
1714 echo "TARGET_ARCH=m68k" >> $config_mak
1715 echo "#define TARGET_ARCH \"m68k\"" >> $config_h
1716 echo "#define TARGET_M68K 1" >> $config_h
1717 bflt="yes"
1718 gdb_xml_files="cf-core.xml cf-fp.xml"
1720 mips|mipsel)
1721 echo "TARGET_ARCH=mips" >> $config_mak
1722 echo "#define TARGET_ARCH \"mips\"" >> $config_h
1723 echo "#define TARGET_MIPS 1" >> $config_h
1724 echo "#define TARGET_ABI_MIPSO32 1" >> $config_h
1726 mipsn32|mipsn32el)
1727 echo "TARGET_ARCH=mipsn32" >> $config_mak
1728 echo "#define TARGET_ARCH \"mipsn32\"" >> $config_h
1729 echo "#define TARGET_MIPS 1" >> $config_h
1730 echo "#define TARGET_ABI_MIPSN32 1" >> $config_h
1732 mips64|mips64el)
1733 echo "TARGET_ARCH=mips64" >> $config_mak
1734 echo "#define TARGET_ARCH \"mips64\"" >> $config_h
1735 echo "#define TARGET_MIPS 1" >> $config_h
1736 echo "#define TARGET_MIPS64 1" >> $config_h
1737 echo "#define TARGET_ABI_MIPSN64 1" >> $config_h
1739 ppc)
1740 echo "TARGET_ARCH=ppc" >> $config_mak
1741 echo "#define TARGET_ARCH \"ppc\"" >> $config_h
1742 echo "#define TARGET_PPC 1" >> $config_h
1744 ppcemb)
1745 echo "TARGET_ARCH=ppcemb" >> $config_mak
1746 echo "TARGET_ABI_DIR=ppc" >> $config_mak
1747 echo "#define TARGET_ARCH \"ppcemb\"" >> $config_h
1748 echo "#define TARGET_PPC 1" >> $config_h
1749 echo "#define TARGET_PPCEMB 1" >> $config_h
1750 if test "$kvm" = "yes" ; then
1751 echo "CONFIG_KVM=yes" >> $config_mak
1752 echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak
1753 echo "#define CONFIG_KVM 1" >> $config_h
1756 ppc64)
1757 echo "TARGET_ARCH=ppc64" >> $config_mak
1758 echo "TARGET_ABI_DIR=ppc" >> $config_mak
1759 echo "#define TARGET_ARCH \"ppc64\"" >> $config_h
1760 echo "#define TARGET_PPC 1" >> $config_h
1761 echo "#define TARGET_PPC64 1" >> $config_h
1763 ppc64abi32)
1764 echo "TARGET_ARCH=ppc64" >> $config_mak
1765 echo "TARGET_ABI_DIR=ppc" >> $config_mak
1766 echo "TARGET_ARCH2=ppc64abi32" >> $config_mak
1767 echo "#define TARGET_ARCH \"ppc64\"" >> $config_h
1768 echo "#define TARGET_PPC 1" >> $config_h
1769 echo "#define TARGET_PPC64 1" >> $config_h
1770 echo "#define TARGET_ABI32 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" = "ppc" \
1843 -o "$target_cpu" = "ppc64" \
1844 -o "$target_cpu" = "ppc64abi32" \
1845 -o "$target_cpu" = "ppcemb" \
1846 -o "$target_cpu" = "sparc" \
1847 -o "$target_cpu" = "sparc64" \
1848 -o "$target_cpu" = "sparc32plus"; then
1849 echo "CONFIG_SOFTFLOAT=yes" >> $config_mak
1850 echo "#define CONFIG_SOFTFLOAT 1" >> $config_h
1852 if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
1853 echo "TARGET_HAS_BFLT=yes" >> $config_mak
1854 echo "#define TARGET_HAS_BFLT 1" >> $config_h
1856 if test "$target_user_only" = "yes" \
1857 -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
1858 echo "#define USE_NPTL 1" >> $config_h
1860 # 32 bit ELF loader in addition to native 64 bit loader?
1861 if test "$target_user_only" = "yes" -a "$elfload32" = "yes"; then
1862 echo "TARGET_HAS_ELFLOAD32=yes" >> $config_mak
1863 echo "#define TARGET_HAS_ELFLOAD32 1" >> $config_h
1865 if test "$target_bsd_user" = "yes" ; then
1866 echo "CONFIG_BSD_USER=yes" >> $config_mak
1867 echo "#define CONFIG_BSD_USER 1" >> $config_h
1870 test -f ${config_h}~ && cmp -s $config_h ${config_h}~ && mv ${config_h}~ $config_h
1872 done # for target in $targets
1874 # build tree in object directory if source path is different from current one
1875 if test "$source_path_used" = "yes" ; then
1876 DIRS="tests tests/cris slirp audio"
1877 FILES="Makefile tests/Makefile"
1878 FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
1879 FILES="$FILES tests/test-mmap.c"
1880 for dir in $DIRS ; do
1881 mkdir -p $dir
1882 done
1883 # remove the link and recreate it, as not all "ln -sf" overwrite the link
1884 for f in $FILES ; do
1885 rm -f $f
1886 ln -s $source_path/$f $f
1887 done