Kill redundant declarion of perror()
[qemu-kvm/fedora.git] / configure
blobe2c83fdf61b58a3707a8e815b5bbb3df1805bd98
1 #!/bin/sh
3 # qemu configure script (c) 2003 Fabrice Bellard
5 # set temporary file name
6 if test ! -z "$TMPDIR" ; then
7 TMPDIR1="${TMPDIR}"
8 elif test ! -z "$TEMPDIR" ; then
9 TMPDIR1="${TEMPDIR}"
10 else
11 TMPDIR1="/tmp"
14 TMPC="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.c"
15 TMPO="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.o"
16 TMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}"
17 TMPS="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.S"
18 TMPI="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.i"
19 TMPSDLLOG="${TMPDIR1}/qemu-conf-sdl-$$-${RANDOM}.log"
21 trap "rm -f $TMPC $TMPO $TMPE $TMPS $TMPI $TMPSDLLOG; exit" 0 2 3 15
23 # default parameters
24 prefix=""
25 interp_prefix="/usr/gnemul/qemu-%M"
26 static="no"
27 cross_prefix=""
28 cc="gcc"
29 audio_drv_list=""
30 audio_card_list="ac97 es1370 sb16"
31 audio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus"
32 host_cc="gcc"
33 ar="ar"
34 make="make"
35 install="install"
36 strip="strip"
38 # parse CC options first
39 for opt do
40 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
41 case "$opt" in
42 --cross-prefix=*) cross_prefix="$optarg"
44 --cc=*) cc="$optarg"
46 esac
47 done
49 # OS specific
50 # Using uname is really, really broken. Once we have the right set of checks
51 # we can eliminate it's usage altogether
53 cc="${cross_prefix}${cc}"
54 ar="${cross_prefix}${ar}"
55 strip="${cross_prefix}${strip}"
57 # check that the C compiler works.
58 cat > $TMPC <<EOF
59 int main(void) {}
60 EOF
62 if $cc $ARCH_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null ; then
63 : C compiler works ok
64 else
65 echo "ERROR: \"$cc\" either does not exist or does not work"
66 exit 1
69 check_define() {
70 cat > $TMPC <<EOF
71 #if !defined($1)
72 #error Not defined
73 #endif
74 int main(void) { return 0; }
75 EOF
76 $cc $ARCH_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null
79 if check_define __i386__ ; then
80 cpu="i386"
81 elif check_define __x86_64__ ; then
82 cpu="x86_64"
83 elif check_define __sparc__ ; then
84 # We can't check for 64 bit (when gcc is biarch) or V8PLUSA
85 # They must be specified using --sparc_cpu
86 if check_define __arch64__ ; then
87 cpu="sparc64"
88 else
89 cpu="sparc"
91 else
92 cpu=`test $(uname -s) = AIX && uname -p || uname -m`
95 target_list=""
96 case "$cpu" in
97 i386|i486|i586|i686|i86pc|BePC)
98 cpu="i386"
100 x86_64|amd64)
101 cpu="x86_64"
103 alpha)
104 cpu="alpha"
106 armv*b)
107 cpu="armv4b"
109 armv*l)
110 cpu="armv4l"
112 cris)
113 cpu="cris"
115 parisc|parisc64)
116 cpu="hppa"
118 ia64)
119 cpu="ia64"
121 m68k)
122 cpu="m68k"
124 mips)
125 cpu="mips"
127 mips64)
128 cpu="mips64"
130 "Power Macintosh"|ppc|ppc64|powerpc)
131 cpu="powerpc"
133 s390*)
134 cpu="s390"
136 sparc|sun4[cdmuv])
137 cpu="sparc"
139 sparc64)
140 cpu="sparc64"
143 cpu="unknown"
145 esac
146 gprof="no"
147 sparse="no"
148 bigendian="no"
149 mingw32="no"
150 EXESUF=""
151 gdbstub="yes"
152 slirp="yes"
153 vde="yes"
154 fmod_lib=""
155 fmod_inc=""
156 oss_lib=""
157 vnc_tls="yes"
158 bsd="no"
159 linux="no"
160 solaris="no"
161 kqemu="no"
162 profiler="no"
163 cocoa="no"
164 check_gfx="yes"
165 softmmu="yes"
166 linux_user="no"
167 darwin_user="no"
168 bsd_user="no"
169 build_docs="no"
170 uname_release=""
171 curses="yes"
172 aio="yes"
173 nptl="yes"
174 mixemu="no"
175 bluez="yes"
176 kvm="yes"
177 kvm_cap_pit="no"
178 kvm_cap_device_assignment="no"
179 kerneldir=""
180 aix="no"
181 blobs="yes"
182 fdt="yes"
183 signalfd="no"
184 eventfd="no"
185 cpu_emulation="yes"
187 # OS specific
188 if check_define __linux__ ; then
189 targetos="Linux"
190 elif check_define _WIN32 ; then
191 targetos='MINGW32'
192 else
193 targetos=`uname -s`
195 case $targetos in
196 CYGWIN*)
197 mingw32="yes"
198 OS_CFLAGS="-mno-cygwin"
199 if [ "$cpu" = "i386" ] ; then
200 kqemu="yes"
202 audio_possible_drivers="sdl"
204 MINGW32*)
205 mingw32="yes"
206 if [ "$cpu" = "i386" ] ; then
207 kqemu="yes"
209 audio_possible_drivers="dsound sdl fmod"
211 GNU/kFreeBSD)
212 audio_drv_list="oss"
213 audio_possible_drivers="oss sdl esd pa"
214 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
215 kqemu="yes"
218 FreeBSD)
219 bsd="yes"
220 audio_drv_list="oss"
221 audio_possible_drivers="oss sdl esd pa"
222 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
223 kqemu="yes"
224 kvm="yes"
227 NetBSD)
228 bsd="yes"
229 audio_drv_list="oss"
230 audio_possible_drivers="oss sdl esd"
231 oss_lib="-lossaudio"
233 OpenBSD)
234 bsd="yes"
235 openbsd="yes"
236 audio_drv_list="oss"
237 audio_possible_drivers="oss sdl esd"
238 oss_lib="-lossaudio"
240 Darwin)
241 bsd="yes"
242 darwin="yes"
243 darwin_user="yes"
244 cocoa="yes"
245 audio_drv_list="coreaudio"
246 audio_possible_drivers="coreaudio sdl fmod"
247 OS_CFLAGS="-mdynamic-no-pic"
248 OS_LDFLAGS="-framework CoreFoundation -framework IOKit"
250 SunOS)
251 solaris="yes"
252 make="gmake"
253 install="ginstall"
254 needs_libsunmath="no"
255 solarisrev=`uname -r | cut -f2 -d.`
256 # have to select again, because `uname -m` returns i86pc
257 # even on an x86_64 box.
258 solariscpu=`isainfo -k`
259 if test "${solariscpu}" = "amd64" ; then
260 cpu="x86_64"
262 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
263 if test "$solarisrev" -le 9 ; then
264 if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
265 needs_libsunmath="yes"
266 else
267 echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
268 echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
269 echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
270 echo "Studio 11 can be downloaded from www.sun.com."
271 exit 1
274 if test "$solarisrev" -ge 9 ; then
275 kqemu="yes"
278 if test -f /usr/include/sys/soundcard.h ; then
279 audio_drv_list="oss"
281 audio_possible_drivers="oss sdl"
283 AIX)
284 aix="yes"
285 make="gmake"
288 audio_drv_list="oss"
289 audio_possible_drivers="oss alsa sdl esd pa"
290 linux="yes"
291 linux_user="yes"
292 usb="linux"
293 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
294 kqemu="yes"
295 audio_possible_drivers="$audio_possible_drivers fmod"
296 kvm="yes"
298 if [ "$cpu" = "ia64" ] ; then
299 kvm="yes"
300 cpu_emulation="no"
301 gdbstub="no"
302 slirp="no"
304 if [ "$cpu" = "powerpc" ]; then
305 kvm="yes"
308 esac
310 if [ "$bsd" = "yes" ] ; then
311 if [ "$darwin" != "yes" ] ; then
312 make="gmake"
313 usb="bsd"
315 bsd_user="yes"
318 # find source path
319 source_path=`dirname "$0"`
320 source_path_used="no"
321 workdir=`pwd`
322 if [ -z "$source_path" ]; then
323 source_path=$workdir
324 else
325 source_path=`cd "$source_path"; pwd`
327 [ -f "$workdir/vl.c" ] || source_path_used="yes"
329 werror="no"
330 # generate compile errors on warnings for development builds
331 #if grep cvs $source_path/VERSION > /dev/null 2>&1 ; then
332 #werror="yes";
335 for opt do
336 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
337 case "$opt" in
338 --help|-h) show_help=yes
340 --prefix=*) prefix="$optarg"
342 --interp-prefix=*) interp_prefix="$optarg"
344 --source-path=*) source_path="$optarg"
345 source_path_used="yes"
347 --cross-prefix=*)
349 --cc=*)
351 --host-cc=*) host_cc="$optarg"
353 --make=*) make="$optarg"
355 --install=*) install="$optarg"
357 --extra-cflags=*) CFLAGS="$optarg"
359 --extra-ldflags=*) LDFLAGS="$optarg"
361 --cpu=*) cpu="$optarg"
363 --target-list=*) target_list="$optarg"
365 --enable-gprof) gprof="yes"
367 --static) static="yes"
369 --disable-sdl) sdl="no"
371 --fmod-lib=*) fmod_lib="$optarg"
373 --fmod-inc=*) fmod_inc="$optarg"
375 --oss-lib=*) oss_lib="$optarg"
377 --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
379 --audio-drv-list=*) audio_drv_list="$optarg"
381 --enable-sparse) sparse="yes"
383 --disable-sparse) sparse="no"
385 --disable-vnc-tls) vnc_tls="no"
387 --disable-slirp) slirp="no"
389 --disable-vde) vde="no"
391 --disable-kqemu) kqemu="no"
393 --disable-brlapi) brlapi="no"
395 --disable-bluez) bluez="no"
397 --disable-kvm) kvm="no"
399 --enable-profiler) profiler="yes"
401 --enable-cocoa)
402 cocoa="yes" ;
403 sdl="no" ;
404 audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
406 --disable-gfx-check) check_gfx="no"
408 --disable-system) softmmu="no"
410 --enable-system) softmmu="yes"
412 --disable-linux-user) linux_user="no"
414 --enable-linux-user) linux_user="yes"
416 --disable-darwin-user) darwin_user="no"
418 --enable-darwin-user) darwin_user="yes"
420 --disable-bsd-user) bsd_user="no"
422 --enable-bsd-user) bsd_user="yes"
424 --enable-uname-release=*) uname_release="$optarg"
426 --sparc_cpu=*)
427 sparc_cpu="$optarg"
428 case $sparc_cpu in
429 v7|v8) SP_CFLAGS="-m32 -mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__"; SP_LDFLAGS="-m32"
430 target_cpu="sparc"; cpu="sparc" ;;
431 v8plus|v8plusa) SP_CFLAGS="-m32 -mcpu=ultrasparc -D__sparc_${sparc_cpu}__"; SP_LDFLAGS="-m32"
432 target_cpu="sparc"; cpu="sparc" ;;
433 v9) SP_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_${sparc_cpu}__"; SP_LDFLAGS="-m64"
434 target_cpu="sparc64"; cpu="sparc64" ;;
435 *) echo "undefined SPARC architecture. Exiting";exit 1;;
436 esac
438 --enable-werror) werror="yes"
440 --disable-werror) werror="no"
442 --disable-curses) curses="no"
444 --disable-nptl) nptl="no"
446 --enable-mixemu) mixemu="yes"
448 --disable-aio) aio="no"
450 --disable-blobs) blobs="no"
452 --kerneldir=*) kerneldir="$optarg"
454 --disable-cpu-emulation) cpu_emulation="no"
456 *) echo "ERROR: unknown option $opt"; exit 1
458 esac
459 done
461 # default flags for all hosts
462 CFLAGS="$CFLAGS -O2 -g -fno-strict-aliasing"
463 CFLAGS="$CFLAGS -Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls"
464 LDFLAGS="$LDFLAGS -g"
465 if test "$werror" = "yes" ; then
466 CFLAGS="$CFLAGS -Werror"
469 if test "$solaris" = "no" ; then
470 if ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
471 LDFLAGS="$LDFLAGS -Wl,--warn-common"
476 # If cpu ~= sparc and sparc_cpu hasn't been defined, plug in the right
477 # ARCH_CFLAGS/ARCH_LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
479 case "$cpu" in
480 sparc) if test -z "$sparc_cpu" ; then
481 ARCH_CFLAGS="-m32 -mcpu=ultrasparc -D__sparc_v8plus__"
482 ARCH_LDFLAGS="-m32"
483 else
484 ARCH_CFLAGS="${SP_CFLAGS}"
485 ARCH_LDFLAGS="${SP_LDFLAGS}"
488 sparc64) if test -z "$sparc_cpu" ; then
489 ARCH_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__"
490 ARCH_LDFLAGS="-m64"
491 else
492 ARCH_CFLAGS="${SP_CFLAGS}"
493 ARCH_LDFLAGS="${SP_LDFLAGS}"
496 s390)
497 ARCH_CFLAGS="-march=z900"
499 i386)
500 ARCH_CFLAGS="-m32"
501 ARCH_LDFLAGS="-m32"
503 x86_64)
504 ARCH_CFLAGS="-m64"
505 ARCH_LDFLAGS="-m64"
507 esac
509 if test x"$show_help" = x"yes" ; then
510 cat << EOF
512 Usage: configure [options]
513 Options: [defaults in brackets after descriptions]
516 echo "Standard options:"
517 echo " --help print this message"
518 echo " --prefix=PREFIX install in PREFIX [$prefix]"
519 echo " --interp-prefix=PREFIX where to find shared libraries, etc."
520 echo " use %M for cpu name [$interp_prefix]"
521 echo " --target-list=LIST set target list [$target_list]"
522 echo ""
523 echo "kqemu kernel acceleration support:"
524 echo " --disable-kqemu disable kqemu support"
525 echo ""
526 echo "Advanced options (experts only):"
527 echo " --source-path=PATH path of source code [$source_path]"
528 echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
529 echo " --cc=CC use C compiler CC [$cc]"
530 echo " --host-cc=CC use C compiler CC [$host_cc] for dyngen etc."
531 echo " --make=MAKE use specified make [$make]"
532 echo " --install=INSTALL use specified install [$install]"
533 echo " --static enable static build [$static]"
534 echo " --enable-sparse enable sparse checker"
535 echo " --disable-sparse disable sparse checker (default)"
536 echo " --disable-werror disable compilation abort on warning"
537 echo " --disable-sdl disable SDL"
538 echo " --enable-cocoa enable COCOA (Mac OS X only)"
539 echo " --audio-drv-list=LIST set audio drivers list:"
540 echo " Available drivers: $audio_possible_drivers"
541 echo " --audio-card-list=LIST set list of emulated audio cards [$audio_card_list]"
542 echo " Available cards: $audio_possible_cards"
543 echo " --enable-mixemu enable mixer emulation"
544 echo " --disable-brlapi disable BrlAPI"
545 echo " --disable-vnc-tls disable TLS encryption for VNC server"
546 echo " --disable-curses disable curses output"
547 echo " --disable-bluez disable bluez stack connectivity"
548 echo " --disable-kvm disable KVM acceleration support"
549 echo " --disable-nptl disable usermode NPTL support"
550 echo " --enable-system enable all system emulation targets"
551 echo " --disable-system disable all system emulation targets"
552 echo " --enable-linux-user enable all linux usermode emulation targets"
553 echo " --disable-linux-user disable all linux usermode emulation targets"
554 echo " --enable-darwin-user enable all darwin usermode emulation targets"
555 echo " --disable-darwin-user disable all darwin usermode emulation targets"
556 echo " --enable-bsd-user enable all BSD usermode emulation targets"
557 echo " --disable-bsd-user disable all BSD usermode emulation targets"
558 echo " --fmod-lib path to FMOD library"
559 echo " --fmod-inc path to FMOD includes"
560 echo " --oss-lib path to OSS library"
561 echo " --enable-uname-release=R Return R for uname -r in usermode emulation"
562 echo " --sparc_cpu=V Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
563 echo " --disable-vde disable support for vde network"
564 echo " --disable-aio disable AIO support"
565 echo " --disable-blobs disable installing provided firmware blobs"
566 echo " --kerneldir=PATH look for kernel includes in PATH"
567 echo " --disable-cpu-emulation disables use of qemu cpu emulation code"
568 echo ""
569 echo "NOTE: The object files are built at the place where configure is launched"
570 exit 1
573 if test "$mingw32" = "yes" ; then
574 linux="no"
575 EXESUF=".exe"
576 oss="no"
577 linux_user="no"
578 bsd_user="no"
581 if test ! -x "$(which cgcc 2>/dev/null)"; then
582 sparse="no"
586 # Solaris specific configure tool chain decisions
588 if test "$solaris" = "yes" ; then
589 solinst=`which $install 2> /dev/null | /usr/bin/grep -v "no $install in"`
590 if test -z "$solinst" ; then
591 echo "Solaris install program not found. Use --install=/usr/ucb/install or"
592 echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
593 echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
594 exit 1
596 if test "$solinst" = "/usr/sbin/install" ; then
597 echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
598 echo "try ginstall from the GNU fileutils available from www.blastwave.org"
599 echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
600 exit 1
602 sol_ar=`which ar 2> /dev/null | /usr/bin/grep -v "no ar in"`
603 if test -z "$sol_ar" ; then
604 echo "Error: No path includes ar"
605 if test -f /usr/ccs/bin/ar ; then
606 echo "Add /usr/ccs/bin to your path and rerun configure"
608 exit 1
613 if test -z "$target_list" ; then
614 # these targets are portable
615 if [ "$softmmu" = "yes" ] ; then
616 target_list="\
617 i386-softmmu \
618 x86_64-softmmu \
619 arm-softmmu \
620 cris-softmmu \
621 m68k-softmmu \
622 mips-softmmu \
623 mipsel-softmmu \
624 mips64-softmmu \
625 mips64el-softmmu \
626 ppc-softmmu \
627 ppcemb-softmmu \
628 ppc64-softmmu \
629 sh4-softmmu \
630 sh4eb-softmmu \
631 sparc-softmmu \
634 # the following are Linux specific
635 if [ "$linux_user" = "yes" ] ; then
636 target_list="${target_list}\
637 i386-linux-user \
638 x86_64-linux-user \
639 alpha-linux-user \
640 arm-linux-user \
641 armeb-linux-user \
642 cris-linux-user \
643 m68k-linux-user \
644 mips-linux-user \
645 mipsel-linux-user \
646 ppc-linux-user \
647 ppc64-linux-user \
648 ppc64abi32-linux-user \
649 sh4-linux-user \
650 sh4eb-linux-user \
651 sparc-linux-user \
652 sparc64-linux-user \
653 sparc32plus-linux-user \
656 # the following are Darwin specific
657 if [ "$darwin_user" = "yes" ] ; then
658 target_list="$target_list i386-darwin-user ppc-darwin-user "
660 # the following are BSD specific
661 if [ "$bsd_user" = "yes" ] ; then
662 target_list="${target_list}\
663 sparc64-bsd-user \
666 else
667 target_list=`echo "$target_list" | sed -e 's/,/ /g'`
669 if test -z "$target_list" ; then
670 echo "No targets enabled"
671 exit 1
674 if test -z "$cross_prefix" ; then
676 # ---
677 # big/little endian test
678 cat > $TMPC << EOF
679 #include <inttypes.h>
680 int main(int argc, char ** argv){
681 volatile uint32_t i=0x01234567;
682 return (*((uint8_t*)(&i))) == 0x67;
686 if $cc $ARCH_CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
687 $TMPE && bigendian="yes"
688 else
689 echo big/little test failed
692 else
694 # if cross compiling, cannot launch a program, so make a static guess
695 if test "$cpu" = "armv4b" \
696 -o "$cpu" = "hppa" \
697 -o "$cpu" = "m68k" \
698 -o "$cpu" = "mips" \
699 -o "$cpu" = "mips64" \
700 -o "$cpu" = "powerpc" \
701 -o "$cpu" = "s390" \
702 -o "$cpu" = "sparc" \
703 -o "$cpu" = "sparc64"; then
704 bigendian="yes"
709 # host long bits test
710 hostlongbits="32"
711 if test "$cpu" = "x86_64" \
712 -o "$cpu" = "alpha" \
713 -o "$cpu" = "ia64" \
714 -o "$cpu" = "sparc64"; then
715 hostlongbits="64"
718 # ppc specific hostlongbits selection
719 if test "$cpu" = "powerpc" ; then
720 if $cc $ARCH_CFLAGS -dM -E - -o $TMPI 2>/dev/null </dev/null; then
721 grep -q __powerpc64__ $TMPI && hostlongbits=64
722 else
723 echo hostlongbits test failed
724 exit 1
728 # check gcc options support
729 cat > $TMPC <<EOF
730 int main(void) {
734 # Check host NPTL support
735 cat > $TMPC <<EOF
736 #include <sched.h>
737 #include <linux/futex.h>
738 void foo()
740 #if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
741 #error bork
742 #endif
746 if $cc $ARCH_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null ; then
748 else
749 nptl="no"
752 ##########################################
753 # KVM probe
755 if test "$kvm" = "yes" ; then
757 # test for KVM_CAP_PIT
759 cat > $TMPC <<EOF
760 #include <libkvm.h>
761 #ifndef KVM_CAP_PIT
762 #error "kvm no pit capability"
763 #endif
764 int main(void) { return 0; }
766 if $cc $ARCH_CFLAGS $CFLAGS -I"$kerneldir"/include -o $TMPE ${OS_CFLAGS} $TMPC 2> /dev/null ; then
767 kvm_cap_pit="yes"
770 # test for KVM_CAP_DEVICE_ASSIGNMENT
772 cat > $TMPC <<EOF
773 #include <libkvm.h>
774 #ifndef KVM_CAP_DEVICE_ASSIGNMENT
775 #error "kvm no device assignment capability"
776 #endif
777 int main(void) { return 0; }
779 if $cc $ARCH_CFLAGS $CFLAGS -I"$kerneldir"/include -o $TMPE ${OS_CFLAGS} $TMPC 2> /dev/null ; then
780 kvm_cap_device_assignment="yes"
784 ##########################################
785 # zlib check
787 cat > $TMPC << EOF
788 #include <zlib.h>
789 int main(void) { zlibVersion(); return 0; }
791 if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $TMPC -lz > /dev/null 2> /dev/null ; then
793 else
794 echo
795 echo "Error: zlib check failed"
796 echo "Make sure to have the zlib libs and headers installed."
797 echo
798 exit 1
801 ##########################################
802 # SDL probe
804 sdl_too_old=no
806 if test -z "$sdl" ; then
807 sdl_config="sdl-config"
808 sdl=no
809 sdl_static=no
811 cat > $TMPC << EOF
812 #include <SDL.h>
813 #undef main /* We don't want SDL to override our main() */
814 int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
816 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
817 _sdlversion=`$sdl_config --version | sed 's/[^0-9]//g'`
818 if test "$_sdlversion" -lt 121 ; then
819 sdl_too_old=yes
820 else
821 if test "$cocoa" = "no" ; then
822 sdl=yes
826 # static link with sdl ?
827 if test "$sdl" = "yes" ; then
828 aa="no"
829 `$sdl_config --static-libs 2>/dev/null | grep \\\-laa > /dev/null` && aa="yes"
830 sdl_static_libs=`$sdl_config --static-libs 2>/dev/null`
831 if [ "$aa" = "yes" ] ; then
832 sdl_static_libs="$sdl_static_libs `aalib-config --static-libs`"
835 if $cc -o $TMPE ${OS_CFLAGS} `$sdl_config --cflags 2> /dev/null` $TMPC $sdl_static_libs > /dev/null 2> /dev/null; then
836 sdl_static=yes
838 fi # static link
839 fi # sdl compile test
840 else
841 # Make sure to disable cocoa if sdl was set
842 if test "$sdl" = "yes" ; then
843 cocoa="no"
844 audio_drv_list="`echo $audio_drv_list | sed s,coreaudio,,g`"
846 fi # -z $sdl
848 ##########################################
849 # VNC TLS detection
850 if test "$vnc_tls" = "yes" ; then
851 cat > $TMPC <<EOF
852 #include <gnutls/gnutls.h>
853 int main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
855 vnc_tls_cflags=`pkg-config --cflags gnutls 2> /dev/null`
856 vnc_tls_libs=`pkg-config --libs gnutls 2> /dev/null`
857 if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $vnc_tls_cflags $TMPC \
858 $vnc_tls_libs > /dev/null 2> /dev/null ; then
860 else
861 vnc_tls="no"
865 ##########################################
866 # vde libraries probe
867 if test "$vde" = "yes" ; then
868 cat > $TMPC << EOF
869 #include <libvdeplug.h>
870 int main(void)
872 struct vde_open_args a = {0, 0, 0};
873 vde_open("", "", &a);
874 return 0;
877 if $cc $ARCH_CFLAGS -o $TMPE $TMPC -lvdeplug > /dev/null 2> /dev/null ; then
879 else
880 vde="no"
884 ##########################################
885 # Sound support libraries probe
887 audio_drv_probe()
889 drv=$1
890 hdr=$2
891 lib=$3
892 exp=$4
893 cfl=$5
894 cat > $TMPC << EOF
895 #include <$hdr>
896 int main(void) { $exp }
898 if $cc $ARCH_CFLAGS $cfl -o $TMPE $TMPC $lib > /dev/null 2> /dev/null ; then
900 else
901 echo
902 echo "Error: $drv check failed"
903 echo "Make sure to have the $drv libs and headers installed."
904 echo
905 exit 1
909 audio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
910 for drv in $audio_drv_list; do
911 case $drv in
912 alsa)
913 audio_drv_probe $drv alsa/asoundlib.h -lasound \
914 "snd_pcm_t **handle; return snd_pcm_close(*handle);"
917 fmod)
918 if test -z $fmod_lib || test -z $fmod_inc; then
919 echo
920 echo "Error: You must specify path to FMOD library and headers"
921 echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
922 echo
923 exit 1
925 audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
928 esd)
929 audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
933 audio_drv_probe $drv pulse/simple.h -lpulse-simple \
934 "pa_simple *s = NULL; pa_simple_free(s); return 0;"
937 oss|sdl|core|wav|dsound)
938 # XXX: Probes for CoreAudio, DirectSound, SDL(?)
942 echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
943 echo
944 echo "Error: Unknown driver '$drv' selected"
945 echo "Possible drivers are: $audio_possible_drivers"
946 echo
947 exit 1
950 esac
951 done
953 ##########################################
954 # BrlAPI probe
956 if test -z "$brlapi" ; then
957 brlapi=no
958 cat > $TMPC << EOF
959 #include <brlapi.h>
960 int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
962 if $cc ${ARCH_CFLAGS} -o $TMPE ${OS_CFLAGS} $TMPC -lbrlapi > /dev/null 2> /dev/null ; then
963 brlapi=yes
964 fi # brlapi compile test
965 fi # -z $brlapi
967 ##########################################
968 # curses probe
970 if test "$curses" = "yes" ; then
971 curses=no
972 cat > $TMPC << EOF
973 #include <curses.h>
974 int main(void) { return curses_version(); }
976 if $cc $ARCH_CFLAGS -o $TMPE $TMPC -lcurses > /dev/null 2> /dev/null ; then
977 curses=yes
979 fi # test "$curses"
981 ##########################################
982 # bluez support probe
983 if test "$bluez" = "yes" ; then
984 `pkg-config bluez` || bluez="no"
986 if test "$bluez" = "yes" ; then
987 cat > $TMPC << EOF
988 #include <bluetooth/bluetooth.h>
989 int main(void) { return bt_error(0); }
991 bluez_cflags=`pkg-config --cflags bluez`
992 bluez_libs=`pkg-config --libs bluez`
993 if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $bluez_cflags $TMPC \
994 $bluez_libs > /dev/null 2> /dev/null ; then
996 else
997 bluez="no"
1001 ##########################################
1002 # kvm probe
1003 if test "$kvm" = "yes" ; then
1004 cat > $TMPC <<EOF
1005 #include <linux/kvm.h>
1006 #if !defined(KVM_API_VERSION) || \
1007 KVM_API_VERSION < 12 || \
1008 KVM_API_VERSION > 12 || \
1009 !defined(KVM_CAP_USER_MEMORY) || \
1010 !defined(KVM_CAP_SET_TSS_ADDR) || \
1011 !defined(KVM_CAP_DESTROY_MEMORY_REGION_WORKS)
1012 #error Invalid KVM version
1013 #endif
1014 int main(void) { return 0; }
1016 if test "$kerneldir" != "" ; then
1017 kvm_cflags=-I"$kerneldir"/include
1018 if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) \
1019 -a -d "$kerneldir/arch/x86/include" ; then
1020 kvm_cflags="$kvm_cflags -I$kerneldir/arch/x86/include"
1021 elif test -d "$kerneldir/arch/$cpu/include" ; then
1022 kvm_cflags="$kvm_cflags -I$kerneldir/arch/$cpu/include"
1024 else
1025 kvm_cflags=""
1027 if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $kvm_cflags $TMPC \
1028 > /dev/null 2>/dev/null ; then
1030 else
1031 kvm="no"
1035 ##########################################
1036 # AIO probe
1037 AIOLIBS=""
1039 if test "$aio" = "yes" ; then
1040 aio=no
1041 cat > $TMPC << EOF
1042 #include <pthread.h>
1043 int main(void) { pthread_mutex_t lock; return 0; }
1045 if $cc $ARCH_CFLAGS -o $TMPE $AIOLIBS $TMPC 2> /dev/null ; then
1046 aio=yes
1047 AIOLIBS="-lpthread"
1051 ##########################################
1052 # iovec probe
1053 cat > $TMPC <<EOF
1054 #include <sys/uio.h>
1055 int main(void) { struct iovec iov; return 0; }
1057 iovec=no
1058 if $cc $ARCH_CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
1059 iovec=yes
1062 ##########################################
1063 # fdt probe
1064 if test "$fdt" = "yes" ; then
1065 fdt=no
1066 cat > $TMPC << EOF
1067 int main(void) { return 0; }
1069 if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $TMPC -lfdt 2> /dev/null ; then
1070 fdt=yes
1074 ##########################################
1075 # signalfd probe
1076 cat > $TMPC << EOF
1077 #define _GNU_SOURCE
1078 #include <unistd.h>
1079 #include <sys/syscall.h>
1080 #include <signal.h>
1081 int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
1084 if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
1085 signalfd=yes
1088 ##########################################
1089 # eventfd probe
1090 cat > $TMPC << EOF
1091 #define _GNU_SOURCE
1092 #include <unistd.h>
1093 #include <sys/syscall.h>
1094 int main(void) { return syscall(SYS_eventfd, 0); }
1097 if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
1098 eventfd=yes
1101 # Check if tools are available to build documentation.
1102 if [ -x "`which texi2html 2>/dev/null`" ] && \
1103 [ -x "`which pod2man 2>/dev/null`" ]; then
1104 build_docs="yes"
1107 ##########################################
1108 # Do we need librt
1109 cat > $TMPC <<EOF
1110 #include <signal.h>
1111 #include <time.h>
1112 int main(void) { clockid_t id; return clock_gettime(id, NULL); }
1115 rt=no
1116 if $cc $ARCH_CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
1118 elif $cc $ARCH_CFLAGS -o $TMPE $TMPC -lrt > /dev/null 2> /dev/null ; then
1119 rt=yes
1122 if test "$rt" = "yes" ; then
1123 # Hack, we should have a general purpose LIBS for this sort of thing
1124 AIOLIBS="$AIOLIBS -lrt"
1127 if test "$mingw32" = "yes" ; then
1128 if test -z "$prefix" ; then
1129 prefix="c:\\\\Program Files\\\\Qemu"
1131 mansuffix=""
1132 datasuffix=""
1133 docsuffix=""
1134 binsuffix=""
1135 else
1136 if test -z "$prefix" ; then
1137 prefix="/usr/local"
1139 mansuffix="/share/man"
1140 datasuffix="/share/qemu"
1141 docsuffix="/share/doc/qemu"
1142 binsuffix="/bin"
1145 echo "Install prefix $prefix"
1146 echo "BIOS directory $prefix$datasuffix"
1147 echo "binary directory $prefix$binsuffix"
1148 if test "$mingw32" = "no" ; then
1149 echo "Manual directory $prefix$mansuffix"
1150 echo "ELF interp prefix $interp_prefix"
1152 echo "Source path $source_path"
1153 echo "C compiler $cc"
1154 echo "Host C compiler $host_cc"
1155 echo "ARCH_CFLAGS $ARCH_CFLAGS"
1156 echo "make $make"
1157 echo "install $install"
1158 echo "host CPU $cpu"
1159 echo "host big endian $bigendian"
1160 echo "target list $target_list"
1161 echo "gprof enabled $gprof"
1162 echo "sparse enabled $sparse"
1163 echo "profiler $profiler"
1164 echo "static build $static"
1165 echo "-Werror enabled $werror"
1166 if test "$darwin" = "yes" ; then
1167 echo "Cocoa support $cocoa"
1169 echo "SDL support $sdl"
1170 if test "$sdl" != "no" ; then
1171 echo "SDL static link $sdl_static"
1173 echo "curses support $curses"
1174 echo "mingw32 support $mingw32"
1175 echo "Audio drivers $audio_drv_list"
1176 echo "Extra audio cards $audio_card_list"
1177 echo "Mixer emulation $mixemu"
1178 echo "VNC TLS support $vnc_tls"
1179 if test "$vnc_tls" = "yes" ; then
1180 echo " TLS CFLAGS $vnc_tls_cflags"
1181 echo " TLS LIBS $vnc_tls_libs"
1183 if test -n "$sparc_cpu"; then
1184 echo "Target Sparc Arch $sparc_cpu"
1186 echo "kqemu support $kqemu"
1187 echo "kvm support $kvm"
1188 echo "CPU emulation $cpu_emulation"
1189 echo "brlapi support $brlapi"
1190 echo "Documentation $build_docs"
1191 [ ! -z "$uname_release" ] && \
1192 echo "uname -r $uname_release"
1193 echo "NPTL support $nptl"
1194 echo "vde support $vde"
1195 echo "AIO support $aio"
1196 echo "Install blobs $blobs"
1197 echo "KVM support $kvm"
1198 echo "fdt support $fdt"
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 $TMPSDLLOG ]; then
1204 echo "The error log from compiling the libSDL test is: "
1205 cat $TMPSDLLOG
1207 #if test "$sdl_static" = "no"; then
1208 # echo "WARNING: cannot compile statically with SDL - qemu-fast won't have a graphical output"
1210 config_mak="config-host.mak"
1211 config_h="config-host.h"
1213 #echo "Creating $config_mak and $config_h"
1215 test -f $config_h && mv $config_h ${config_h}~
1217 echo "# Automatically generated by configure - do not modify" > $config_mak
1218 printf "# Configured with:" >> $config_mak
1219 printf " '%s'" "$0" "$@" >> $config_mak
1220 echo >> $config_mak
1221 echo "/* Automatically generated by configure - do not modify */" > $config_h
1223 echo "prefix=$prefix" >> $config_mak
1224 echo "bindir=\${prefix}$binsuffix" >> $config_mak
1225 echo "mandir=\${prefix}$mansuffix" >> $config_mak
1226 echo "datadir=\${prefix}$datasuffix" >> $config_mak
1227 echo "docdir=\${prefix}$docsuffix" >> $config_mak
1228 echo "#define CONFIG_QEMU_SHAREDIR \"$prefix$datasuffix\"" >> $config_h
1229 echo "MAKE=$make" >> $config_mak
1230 echo "INSTALL=$install" >> $config_mak
1231 echo "CC=$cc" >> $config_mak
1232 echo "HOST_CC=$host_cc" >> $config_mak
1233 echo "AR=$ar" >> $config_mak
1234 echo "STRIP=$strip -s -R .comment -R .note" >> $config_mak
1235 # XXX: only use CFLAGS and LDFLAGS ?
1236 # XXX: should export HOST_CFLAGS and HOST_LDFLAGS for cross
1237 # compilation of dyngen tool (useful for win32 build on Linux host)
1238 echo "OS_CFLAGS=$OS_CFLAGS" >> $config_mak
1239 echo "OS_LDFLAGS=$OS_LDFLAGS" >> $config_mak
1240 echo "ARCH_CFLAGS=$ARCH_CFLAGS" >> $config_mak
1241 echo "ARCH_LDFLAGS=$ARCH_LDFLAGS" >> $config_mak
1242 echo "CFLAGS=$CFLAGS" >> $config_mak
1243 echo "LDFLAGS=$LDFLAGS" >> $config_mak
1244 echo "EXESUF=$EXESUF" >> $config_mak
1245 echo "AIOLIBS=$AIOLIBS" >> $config_mak
1246 case "$cpu" in
1247 i386)
1248 echo "ARCH=i386" >> $config_mak
1249 echo "#define HOST_I386 1" >> $config_h
1251 x86_64)
1252 echo "ARCH=x86_64" >> $config_mak
1253 echo "#define HOST_X86_64 1" >> $config_h
1255 alpha)
1256 echo "ARCH=alpha" >> $config_mak
1257 echo "#define HOST_ALPHA 1" >> $config_h
1259 armv4b)
1260 echo "ARCH=arm" >> $config_mak
1261 echo "#define HOST_ARM 1" >> $config_h
1263 armv4l)
1264 echo "ARCH=arm" >> $config_mak
1265 echo "#define HOST_ARM 1" >> $config_h
1267 cris)
1268 echo "ARCH=cris" >> $config_mak
1269 echo "#define HOST_CRIS 1" >> $config_h
1271 hppa)
1272 echo "ARCH=hppa" >> $config_mak
1273 echo "#define HOST_HPPA 1" >> $config_h
1275 ia64)
1276 echo "ARCH=ia64" >> $config_mak
1277 echo "#define HOST_IA64 1" >> $config_h
1279 m68k)
1280 echo "ARCH=m68k" >> $config_mak
1281 echo "#define HOST_M68K 1" >> $config_h
1283 mips)
1284 echo "ARCH=mips" >> $config_mak
1285 echo "#define HOST_MIPS 1" >> $config_h
1287 mips64)
1288 echo "ARCH=mips64" >> $config_mak
1289 echo "#define HOST_MIPS64 1" >> $config_h
1291 powerpc)
1292 if test "$hostlongbits" = "32"; then
1293 echo "ARCH=ppc" >> $config_mak
1294 echo "#define HOST_PPC 1" >> $config_h
1295 else
1296 echo "ARCH=ppc64" >> $config_mak
1297 echo "#define HOST_PPC64 1" >> $config_h
1300 s390)
1301 echo "ARCH=s390" >> $config_mak
1302 echo "#define HOST_S390 1" >> $config_h
1304 sparc)
1305 echo "ARCH=sparc" >> $config_mak
1306 echo "#define HOST_SPARC 1" >> $config_h
1308 sparc64)
1309 echo "ARCH=sparc64" >> $config_mak
1310 echo "#define HOST_SPARC64 1" >> $config_h
1313 echo "Unsupported CPU = $cpu"
1314 exit 1
1316 esac
1317 if test "$sparse" = "yes" ; then
1318 echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_mak
1319 echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_mak
1320 echo "CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_mak
1322 if test "$bigendian" = "yes" ; then
1323 echo "WORDS_BIGENDIAN=yes" >> $config_mak
1324 echo "#define WORDS_BIGENDIAN 1" >> $config_h
1326 echo "#define HOST_LONG_BITS $hostlongbits" >> $config_h
1327 if test "$mingw32" = "yes" ; then
1328 echo "CONFIG_WIN32=yes" >> $config_mak
1329 echo "#define CONFIG_WIN32 1" >> $config_h
1330 else
1331 cat > $TMPC << EOF
1332 #include <byteswap.h>
1333 int main(void) { return bswap_32(0); }
1335 if $cc $ARCH_CFLAGS -o $TMPE $TMPC >/dev/null 2> /dev/null ; then
1336 echo "#define HAVE_BYTESWAP_H 1" >> $config_h
1338 cat > $TMPC << EOF
1339 #include <sys/endian.h>
1340 #include <sys/types.h>
1341 #include <machine/bswap.h>
1342 int main(void) { return bswap32(0); }
1344 if $cc $ARCH_CFLAGS -o $TMPE $TMPC >/dev/null 2> /dev/null ; then
1345 echo "#define HAVE_MACHINE_BSWAP_H 1" >> $config_h
1349 if [ "$openbsd" = "yes" ] ; then
1350 echo "#define ENOTSUP 4096" >> $config_h
1353 if test "$darwin" = "yes" ; then
1354 echo "CONFIG_DARWIN=yes" >> $config_mak
1355 echo "#define CONFIG_DARWIN 1" >> $config_h
1358 if test "$aix" = "yes" ; then
1359 echo "CONFIG_AIX=yes" >> $config_mak
1360 echo "#define CONFIG_AIX 1" >> $config_h
1363 if test "$solaris" = "yes" ; then
1364 echo "CONFIG_SOLARIS=yes" >> $config_mak
1365 echo "#define HOST_SOLARIS $solarisrev" >> $config_h
1366 if test "$needs_libsunmath" = "yes" ; then
1367 echo "NEEDS_LIBSUNMATH=yes" >> $config_mak
1368 echo "#define NEEDS_LIBSUNMATH 1" >> $config_h
1371 if test -n "$sparc_cpu"; then
1372 echo "CONFIG__sparc_${sparc_cpu}__=yes" >> $config_mak
1373 echo "#define __sparc_${sparc_cpu}__ 1" >> $config_h
1375 if test "$gdbstub" = "yes" ; then
1376 echo "CONFIG_GDBSTUB=yes" >> $config_mak
1377 echo "#define CONFIG_GDBSTUB 1" >> $config_h
1379 if test "$gprof" = "yes" ; then
1380 echo "TARGET_GPROF=yes" >> $config_mak
1381 echo "#define HAVE_GPROF 1" >> $config_h
1383 if test "$static" = "yes" ; then
1384 echo "CONFIG_STATIC=yes" >> $config_mak
1385 echo "#define CONFIG_STATIC 1" >> $config_h
1387 if test $profiler = "yes" ; then
1388 echo "#define CONFIG_PROFILER 1" >> $config_h
1390 if test "$slirp" = "yes" ; then
1391 echo "CONFIG_SLIRP=yes" >> $config_mak
1392 echo "#define CONFIG_SLIRP 1" >> $config_h
1394 if test "$vde" = "yes" ; then
1395 echo "CONFIG_VDE=yes" >> $config_mak
1396 echo "#define CONFIG_VDE 1" >> $config_h
1397 echo "VDE_LIBS=-lvdeplug" >> $config_mak
1399 for card in $audio_card_list; do
1400 def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
1401 echo "$def=yes" >> $config_mak
1402 echo "#define $def 1" >> $config_h
1403 done
1404 echo "#define AUDIO_DRIVERS \\" >> $config_h
1405 for drv in $audio_drv_list; do
1406 echo " &${drv}_audio_driver, \\" >>$config_h
1407 def=CONFIG_`echo $drv | tr '[:lower:]' '[:upper:]'`
1408 echo "$def=yes" >> $config_mak
1409 if test "$drv" = "fmod"; then
1410 echo "CONFIG_FMOD_LIB=$fmod_lib" >> $config_mak
1411 echo "CONFIG_FMOD_INC=$fmod_inc" >> $config_mak
1412 elif test "$drv" = "oss"; then
1413 echo "CONFIG_OSS_LIB=$oss_lib" >> $config_mak
1415 done
1416 echo "" >>$config_h
1417 if test "$mixemu" = "yes" ; then
1418 echo "CONFIG_MIXEMU=yes" >> $config_mak
1419 echo "#define CONFIG_MIXEMU 1" >> $config_h
1421 if test "$vnc_tls" = "yes" ; then
1422 echo "CONFIG_VNC_TLS=yes" >> $config_mak
1423 echo "CONFIG_VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_mak
1424 echo "CONFIG_VNC_TLS_LIBS=$vnc_tls_libs" >> $config_mak
1425 echo "#define CONFIG_VNC_TLS 1" >> $config_h
1427 qemu_version=`head $source_path/VERSION`
1428 echo "VERSION=$qemu_version" >>$config_mak
1429 echo "#define QEMU_VERSION \"$qemu_version\"" >> $config_h
1430 echo "#define KVM_VERSION \"kvm-devel\"" >> $config_h
1432 echo "SRC_PATH=$source_path" >> $config_mak
1433 if [ "$source_path_used" = "yes" ]; then
1434 echo "VPATH=$source_path" >> $config_mak
1436 echo "TARGET_DIRS=$target_list" >> $config_mak
1437 if [ "$build_docs" = "yes" ] ; then
1438 echo "BUILD_DOCS=yes" >> $config_mak
1440 if test "$static" = "yes"; then
1441 sdl1=$sdl_static
1442 else
1443 sdl1=$sdl
1445 if test "$sdl1" = "yes" ; then
1446 echo "#define CONFIG_SDL 1" >> $config_h
1447 echo "CONFIG_SDL=yes" >> $config_mak
1448 if test "$target_softmmu" = "no" -o "$static" = "yes"; then
1449 echo "SDL_LIBS=$sdl_static_libs" >> $config_mak
1450 else
1451 echo "SDL_LIBS=`$sdl_config --libs`" >> $config_mak
1453 if [ "${aa}" = "yes" ] ; then
1454 echo "SDL_CFLAGS=`$sdl_config --cflags` `aalib-config --cflags`" >> $config_mak
1455 else
1456 echo "SDL_CFLAGS=`$sdl_config --cflags`" >> $config_mak
1459 if test "$cocoa" = "yes" ; then
1460 echo "#define CONFIG_COCOA 1" >> $config_h
1461 echo "CONFIG_COCOA=yes" >> $config_mak
1463 if test "$curses" = "yes" ; then
1464 echo "#define CONFIG_CURSES 1" >> $config_h
1465 echo "CONFIG_CURSES=yes" >> $config_mak
1466 echo "CURSES_LIBS=-lcurses" >> $config_mak
1468 if test "$brlapi" = "yes" ; then
1469 echo "CONFIG_BRLAPI=yes" >> $config_mak
1470 echo "#define CONFIG_BRLAPI 1" >> $config_h
1471 echo "BRLAPI_LIBS=-lbrlapi" >> $config_mak
1473 if test "$bluez" = "yes" ; then
1474 echo "CONFIG_BLUEZ=yes" >> $config_mak
1475 echo "CONFIG_BLUEZ_CFLAGS=$bluez_cflags" >> $config_mak
1476 echo "CONFIG_BLUEZ_LIBS=$bluez_libs" >> $config_mak
1477 echo "#define CONFIG_BLUEZ 1" >> $config_h
1479 if test "$aio" = "yes" ; then
1480 echo "#define CONFIG_AIO 1" >> $config_h
1481 echo "CONFIG_AIO=yes" >> $config_mak
1483 if test "$blobs" = "yes" ; then
1484 echo "INSTALL_BLOBS=yes" >> $config_mak
1486 if test "$iovec" = "yes" ; then
1487 echo "#define HAVE_IOVEC 1" >> $config_h
1489 if test "$fdt" = "yes" ; then
1490 echo "#define HAVE_FDT 1" >> $config_h
1491 echo "FDT_LIBS=-lfdt" >> $config_mak
1493 if test "$signalfd" = "yes" ; then
1494 echo "#define CONFIG_signalfd 1" >> $config_h
1496 if test "$eventfd" = "yes" ; then
1497 echo "#define CONFIG_eventfd 1" >> $config_h
1500 # XXX: suppress that
1501 if [ "$bsd" = "yes" ] ; then
1502 echo "#define O_LARGEFILE 0" >> $config_h
1503 echo "#define MAP_ANONYMOUS MAP_ANON" >> $config_h
1504 echo "#define _BSD 1" >> $config_h
1507 echo "#define CONFIG_UNAME_RELEASE \"$uname_release\"" >> $config_h
1509 # USB host support
1510 case "$usb" in
1511 linux)
1512 echo "HOST_USB=linux" >> $config_mak
1514 bsd)
1515 echo "HOST_USB=bsd" >> $config_mak
1518 echo "HOST_USB=stub" >> $config_mak
1520 esac
1522 tools=
1523 if test `expr "$target_list" : ".*softmmu.*"` != 0 ; then
1524 tools="qemu-img\$(EXESUF) $tools"
1525 if [ "$linux" = "yes" ] ; then
1526 tools="qemu-nbd\$(EXESUF) $tools"
1529 echo "TOOLS=$tools" >> $config_mak
1531 test -f ${config_h}~ && cmp -s $config_h ${config_h}~ && mv ${config_h}~ $config_h
1533 for target in $target_list; do
1534 target_dir="$target"
1535 config_mak=$target_dir/config.mak
1536 config_h=$target_dir/config.h
1537 target_cpu=`echo $target | cut -d '-' -f 1`
1538 target_bigendian="no"
1539 [ "$target_cpu" = "armeb" ] && target_bigendian=yes
1540 [ "$target_cpu" = "m68k" ] && target_bigendian=yes
1541 [ "$target_cpu" = "mips" ] && target_bigendian=yes
1542 [ "$target_cpu" = "mipsn32" ] && target_bigendian=yes
1543 [ "$target_cpu" = "mips64" ] && target_bigendian=yes
1544 [ "$target_cpu" = "ppc" ] && target_bigendian=yes
1545 [ "$target_cpu" = "ppcemb" ] && target_bigendian=yes
1546 [ "$target_cpu" = "ppc64" ] && target_bigendian=yes
1547 [ "$target_cpu" = "ppc64abi32" ] && target_bigendian=yes
1548 [ "$target_cpu" = "sh4eb" ] && target_bigendian=yes
1549 [ "$target_cpu" = "sparc" ] && target_bigendian=yes
1550 [ "$target_cpu" = "sparc64" ] && target_bigendian=yes
1551 [ "$target_cpu" = "sparc32plus" ] && target_bigendian=yes
1552 target_softmmu="no"
1553 target_user_only="no"
1554 target_linux_user="no"
1555 target_darwin_user="no"
1556 target_bsd_user="no"
1557 case "$target" in
1558 ${target_cpu}-softmmu)
1559 target_softmmu="yes"
1561 ${target_cpu}-linux-user)
1562 target_user_only="yes"
1563 target_linux_user="yes"
1565 ${target_cpu}-darwin-user)
1566 target_user_only="yes"
1567 target_darwin_user="yes"
1569 ${target_cpu}-bsd-user)
1570 target_user_only="yes"
1571 target_bsd_user="yes"
1574 echo "ERROR: Target '$target' not recognised"
1575 exit 1
1577 esac
1579 if test "$target_user_only" = "no" -a "$check_gfx" = "yes" \
1580 -a "$sdl" = "no" -a "$cocoa" = "no" ; then
1581 echo "ERROR: QEMU requires SDL or Cocoa for graphical output"
1582 echo "To build QEMU without graphical output configure with --disable-gfx-check"
1583 echo "Note that this will disable all output from the virtual graphics card"
1584 echo "except through VNC or curses."
1585 exit 1;
1588 #echo "Creating $config_mak, $config_h and $target_dir/Makefile"
1590 test -f $config_h && mv $config_h ${config_h}~
1592 mkdir -p $target_dir
1593 mkdir -p $target_dir/fpu
1594 mkdir -p $target_dir/tcg
1595 if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
1596 mkdir -p $target_dir/nwfpe
1600 # don't use ln -sf as not all "ln -sf" over write the file/link
1602 rm -f $target_dir/Makefile
1603 ln -s $source_path/Makefile.target $target_dir/Makefile
1606 echo "# Automatically generated by configure - do not modify" > $config_mak
1607 echo "/* Automatically generated by configure - do not modify */" > $config_h
1610 echo "include ../config-host.mak" >> $config_mak
1611 echo "#include \"../config-host.h\"" >> $config_h
1613 bflt="no"
1614 elfload32="no"
1615 target_nptl="no"
1616 interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_cpu/g"`
1617 echo "#define CONFIG_QEMU_PREFIX \"$interp_prefix1\"" >> $config_h
1618 gdb_xml_files=""
1620 disable_cpu_emulation() {
1621 if test $cpu_emulation = "no"; then
1622 echo "#define NO_CPU_EMULATION 1" >> $config_h
1623 echo "NO_CPU_EMULATION=1" >> $config_mak
1627 configure_kvm() {
1628 if test $kvm = "yes" -a "$target_softmmu" = "yes" -a \
1629 \( "$cpu" = "i386" -o "$cpu" = "x86_64" -o "$cpu" = "ia64" -o "$cpu" = "powerpc" \); then
1630 echo "#define USE_KVM 1" >> $config_h
1631 echo "USE_KVM=1" >> $config_mak
1632 echo "CONFIG_KVM_KERNEL_INC=$kerneldir/include" >> $config_mak
1633 if test $kvm_cap_pit = "yes" ; then
1634 echo "USE_KVM_PIT=1" >> $config_mak
1635 echo "#define USE_KVM_PIT 1" >> $config_h
1637 if test $kvm_cap_device_assignment = "yes" ; then
1638 echo "USE_KVM_DEVICE_ASSIGNMENT=1" >> $config_mak
1639 echo "#define USE_KVM_DEVICE_ASSIGNMENT 1" >> $config_h
1641 disable_cpu_emulation
1645 if [ use_upstream_kvm = yes ]; then
1647 # Make sure the target and host cpus are compatible
1648 if test "$kvm" = "yes" -a ! \( "$target_cpu" = "$cpu" -o \
1649 \( "$target_cpu" = "ppcemb" -a "$cpu" = "powerpc" \) -o \
1650 \( "$target_cpu" = "x86_64" -a "$cpu" = "i386" \) -o \
1651 \( "$target_cpu" = "i386" -a "$cpu" = "x86_64" \) \) ; then
1652 kvm="no"
1654 # Disable KVM for linux-user
1655 if test "$kvm" = "yes" -a "$target_softmmu" = "no" ; then
1656 kvm="no"
1661 case "$target_cpu" in
1662 i386)
1663 echo "TARGET_ARCH=i386" >> $config_mak
1664 echo "#define TARGET_ARCH \"i386\"" >> $config_h
1665 echo "#define TARGET_I386 1" >> $config_h
1666 if test $kqemu = "yes" -a "$target_softmmu" = "yes"
1667 then
1668 echo "#define USE_KQEMU 1" >> $config_h
1670 if test "$kvm" = "yes" ; then
1671 echo "CONFIG_KVM=yes" >> $config_mak
1672 echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak
1673 echo "#define CONFIG_KVM 1" >> $config_h
1675 configure_kvm
1677 x86_64)
1678 echo "TARGET_ARCH=x86_64" >> $config_mak
1679 echo "#define TARGET_ARCH \"x86_64\"" >> $config_h
1680 echo "#define TARGET_I386 1" >> $config_h
1681 echo "#define TARGET_X86_64 1" >> $config_h
1682 if test $kqemu = "yes" -a "$target_softmmu" = "yes" -a $cpu = "x86_64"
1683 then
1684 echo "#define USE_KQEMU 1" >> $config_h
1686 configure_kvm
1688 ia64)
1689 echo "TARGET_ARCH=ia64" >> $config_mak
1690 echo "#define TARGET_ARCH \"ia64\"" >> $config_h
1691 echo "#define TARGET_IA64 1" >> $config_h
1692 configure_kvm
1693 if [ use_upstream_kvm = yes ]; then
1694 if test "$kvm" = "yes" ; then
1695 echo "CONFIG_KVM=yes" >> $config_mak
1696 echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak
1697 echo "#define CONFIG_KVM 1" >> $config_h
1701 alpha)
1702 echo "TARGET_ARCH=alpha" >> $config_mak
1703 echo "#define TARGET_ARCH \"alpha\"" >> $config_h
1704 echo "#define TARGET_ALPHA 1" >> $config_h
1706 arm|armeb)
1707 echo "TARGET_ARCH=arm" >> $config_mak
1708 echo "#define TARGET_ARCH \"arm\"" >> $config_h
1709 echo "#define TARGET_ARM 1" >> $config_h
1710 bflt="yes"
1711 target_nptl="yes"
1712 gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
1714 cris)
1715 echo "TARGET_ARCH=cris" >> $config_mak
1716 echo "#define TARGET_ARCH \"cris\"" >> $config_h
1717 echo "#define TARGET_CRIS 1" >> $config_h
1718 target_nptl="yes"
1720 m68k)
1721 echo "TARGET_ARCH=m68k" >> $config_mak
1722 echo "#define TARGET_ARCH \"m68k\"" >> $config_h
1723 echo "#define TARGET_M68K 1" >> $config_h
1724 bflt="yes"
1725 gdb_xml_files="cf-core.xml cf-fp.xml"
1727 mips|mipsel)
1728 echo "TARGET_ARCH=mips" >> $config_mak
1729 echo "#define TARGET_ARCH \"mips\"" >> $config_h
1730 echo "#define TARGET_MIPS 1" >> $config_h
1731 echo "#define TARGET_ABI_MIPSO32 1" >> $config_h
1733 mipsn32|mipsn32el)
1734 echo "TARGET_ARCH=mipsn32" >> $config_mak
1735 echo "#define TARGET_ARCH \"mipsn32\"" >> $config_h
1736 echo "#define TARGET_MIPS 1" >> $config_h
1737 echo "#define TARGET_ABI_MIPSN32 1" >> $config_h
1739 mips64|mips64el)
1740 echo "TARGET_ARCH=mips64" >> $config_mak
1741 echo "#define TARGET_ARCH \"mips64\"" >> $config_h
1742 echo "#define TARGET_MIPS 1" >> $config_h
1743 echo "#define TARGET_MIPS64 1" >> $config_h
1744 echo "#define TARGET_ABI_MIPSN64 1" >> $config_h
1746 ppc)
1747 echo "TARGET_ARCH=ppc" >> $config_mak
1748 echo "#define TARGET_ARCH \"ppc\"" >> $config_h
1749 echo "#define TARGET_PPC 1" >> $config_h
1751 ppcemb)
1752 echo "TARGET_ARCH=ppcemb" >> $config_mak
1753 echo "TARGET_ABI_DIR=ppc" >> $config_mak
1754 echo "#define TARGET_ARCH \"ppcemb\"" >> $config_h
1755 echo "#define TARGET_PPC 1" >> $config_h
1756 echo "#define TARGET_PPCEMB 1" >> $config_h
1757 if test "$kvm" = "yes" ; then
1758 echo "CONFIG_KVM=yes" >> $config_mak
1759 echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak
1760 echo "#define CONFIG_KVM 1" >> $config_h
1763 ppc64)
1764 echo "TARGET_ARCH=ppc64" >> $config_mak
1765 echo "TARGET_ABI_DIR=ppc" >> $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
1770 ppc64abi32)
1771 echo "TARGET_ARCH=ppc64" >> $config_mak
1772 echo "TARGET_ABI_DIR=ppc" >> $config_mak
1773 echo "TARGET_ARCH2=ppc64abi32" >> $config_mak
1774 echo "#define TARGET_ARCH \"ppc64\"" >> $config_h
1775 echo "#define TARGET_PPC 1" >> $config_h
1776 echo "#define TARGET_PPC64 1" >> $config_h
1777 echo "#define TARGET_ABI32 1" >> $config_h
1779 sh4|sh4eb)
1780 echo "TARGET_ARCH=sh4" >> $config_mak
1781 echo "#define TARGET_ARCH \"sh4\"" >> $config_h
1782 echo "#define TARGET_SH4 1" >> $config_h
1783 bflt="yes"
1784 target_nptl="yes"
1786 sparc)
1787 echo "TARGET_ARCH=sparc" >> $config_mak
1788 echo "#define TARGET_ARCH \"sparc\"" >> $config_h
1789 echo "#define TARGET_SPARC 1" >> $config_h
1791 sparc64)
1792 echo "TARGET_ARCH=sparc64" >> $config_mak
1793 echo "#define TARGET_ARCH \"sparc64\"" >> $config_h
1794 echo "#define TARGET_SPARC 1" >> $config_h
1795 echo "#define TARGET_SPARC64 1" >> $config_h
1796 elfload32="yes"
1798 sparc32plus)
1799 echo "TARGET_ARCH=sparc64" >> $config_mak
1800 echo "TARGET_ABI_DIR=sparc" >> $config_mak
1801 echo "TARGET_ARCH2=sparc32plus" >> $config_mak
1802 echo "#define TARGET_ARCH \"sparc64\"" >> $config_h
1803 echo "#define TARGET_SPARC 1" >> $config_h
1804 echo "#define TARGET_SPARC64 1" >> $config_h
1805 echo "#define TARGET_ABI32 1" >> $config_h
1808 echo "Unsupported target CPU"
1809 exit 1
1811 esac
1812 if test "$target_bigendian" = "yes" ; then
1813 echo "TARGET_WORDS_BIGENDIAN=yes" >> $config_mak
1814 echo "#define TARGET_WORDS_BIGENDIAN 1" >> $config_h
1816 if test "$target_softmmu" = "yes" ; then
1817 echo "CONFIG_SOFTMMU=yes" >> $config_mak
1818 echo "#define CONFIG_SOFTMMU 1" >> $config_h
1820 if test "$target_user_only" = "yes" ; then
1821 echo "CONFIG_USER_ONLY=yes" >> $config_mak
1822 echo "#define CONFIG_USER_ONLY 1" >> $config_h
1824 if test "$target_linux_user" = "yes" ; then
1825 echo "CONFIG_LINUX_USER=yes" >> $config_mak
1826 echo "#define CONFIG_LINUX_USER 1" >> $config_h
1828 if test "$target_darwin_user" = "yes" ; then
1829 echo "CONFIG_DARWIN_USER=yes" >> $config_mak
1830 echo "#define CONFIG_DARWIN_USER 1" >> $config_h
1832 list=""
1833 if test ! -z "$gdb_xml_files" ; then
1834 for x in $gdb_xml_files; do
1835 list="$list $source_path/gdb-xml/$x"
1836 done
1838 echo "TARGET_XML_FILES=$list" >> $config_mak
1840 if test "$target_cpu" = "arm" \
1841 -o "$target_cpu" = "armeb" \
1842 -o "$target_cpu" = "m68k" \
1843 -o "$target_cpu" = "mips" \
1844 -o "$target_cpu" = "mipsel" \
1845 -o "$target_cpu" = "mipsn32" \
1846 -o "$target_cpu" = "mipsn32el" \
1847 -o "$target_cpu" = "mips64" \
1848 -o "$target_cpu" = "mips64el" \
1849 -o "$target_cpu" = "ppc" \
1850 -o "$target_cpu" = "ppc64" \
1851 -o "$target_cpu" = "ppc64abi32" \
1852 -o "$target_cpu" = "ppcemb" \
1853 -o "$target_cpu" = "sparc" \
1854 -o "$target_cpu" = "sparc64" \
1855 -o "$target_cpu" = "sparc32plus"; then
1856 echo "CONFIG_SOFTFLOAT=yes" >> $config_mak
1857 echo "#define CONFIG_SOFTFLOAT 1" >> $config_h
1859 if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
1860 echo "TARGET_HAS_BFLT=yes" >> $config_mak
1861 echo "#define TARGET_HAS_BFLT 1" >> $config_h
1863 if test "$target_user_only" = "yes" \
1864 -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
1865 echo "#define USE_NPTL 1" >> $config_h
1867 # 32 bit ELF loader in addition to native 64 bit loader?
1868 if test "$target_user_only" = "yes" -a "$elfload32" = "yes"; then
1869 echo "TARGET_HAS_ELFLOAD32=yes" >> $config_mak
1870 echo "#define TARGET_HAS_ELFLOAD32 1" >> $config_h
1872 if test "$target_bsd_user" = "yes" ; then
1873 echo "CONFIG_BSD_USER=yes" >> $config_mak
1874 echo "#define CONFIG_BSD_USER 1" >> $config_h
1877 test -f ${config_h}~ && cmp -s $config_h ${config_h}~ && mv ${config_h}~ $config_h
1879 done # for target in $targets
1881 # build tree in object directory if source path is different from current one
1882 if test "$source_path_used" = "yes" ; then
1883 DIRS="tests tests/cris slirp audio"
1884 FILES="Makefile tests/Makefile"
1885 FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
1886 FILES="$FILES tests/test-mmap.c"
1887 for dir in $DIRS ; do
1888 mkdir -p $dir
1889 done
1890 # remove the link and recreate it, as not all "ln -sf" overwrite the link
1891 for f in $FILES ; do
1892 rm -f $f
1893 ln -s $source_path/$f $f
1894 done