One CONFIG_EVENTFD should be enough
[qemu-kvm/amd-iommu.git] / configure
blobfb28e14988f6bac8b7a53904ba1fdcace876c46f
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}"
18 trap "rm -f $TMPC $TMPO $TMPE ; exit" 0 2 3 15
20 compile_object() {
21 $cc $QEMU_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null
24 compile_prog() {
25 local_cflags="$1"
26 local_ldflags="$2"
27 $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags > /dev/null 2> /dev/null
30 # default parameters
31 cpu=""
32 prefix=""
33 interp_prefix="/usr/gnemul/qemu-%M"
34 static="no"
35 sparc_cpu=""
36 cross_prefix=""
37 cc="gcc"
38 audio_drv_list=""
39 audio_card_list="ac97 es1370 sb16"
40 audio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus"
41 host_cc="gcc"
42 ar="ar"
43 make="make"
44 install="install"
45 objcopy="objcopy"
46 ld="ld"
47 helper_cflags=""
48 libs_softmmu=""
49 libs_tools=""
50 audio_pt_int=""
52 # parse CC options first
53 for opt do
54 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
55 case "$opt" in
56 --cross-prefix=*) cross_prefix="$optarg"
58 --cc=*) cc="$optarg"
60 --cpu=*) cpu="$optarg"
62 --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
64 --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
66 --sparc_cpu=*)
67 sparc_cpu="$optarg"
68 case $sparc_cpu in
69 v7|v8|v8plus|v8plusa)
70 cpu="sparc"
72 v9)
73 cpu="sparc64"
76 echo "undefined SPARC architecture. Exiting";
77 exit 1
79 esac
81 esac
82 done
83 # OS specific
84 # Using uname is really, really broken. Once we have the right set of checks
85 # we can eliminate it's usage altogether
87 cc="${cross_prefix}${cc}"
88 ar="${cross_prefix}${ar}"
89 objcopy="${cross_prefix}${objcopy}"
90 ld="${cross_prefix}${ld}"
92 # check that the C compiler works.
93 cat > $TMPC <<EOF
94 int main(void) {}
95 EOF
97 if compile_object ; then
98 : C compiler works ok
99 else
100 echo "ERROR: \"$cc\" either does not exist or does not work"
101 exit 1
104 check_define() {
105 cat > $TMPC <<EOF
106 #if !defined($1)
107 #error Not defined
108 #endif
109 int main(void) { return 0; }
111 compile_object
114 if test ! -z "$cpu" ; then
115 # command line argument
117 elif check_define __i386__ ; then
118 cpu="i386"
119 elif check_define __x86_64__ ; then
120 cpu="x86_64"
121 elif check_define __sparc__ ; then
122 # We can't check for 64 bit (when gcc is biarch) or V8PLUSA
123 # They must be specified using --sparc_cpu
124 if check_define __arch64__ ; then
125 cpu="sparc64"
126 else
127 cpu="sparc"
129 elif check_define _ARCH_PPC ; then
130 if check_define _ARCH_PPC64 ; then
131 cpu="ppc64"
132 else
133 cpu="ppc"
135 else
136 cpu=`uname -m`
139 target_list="x86_64-softmmu"
140 case "$cpu" in
141 alpha|cris|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|sparc64)
142 cpu="$cpu"
144 i386|i486|i586|i686|i86pc|BePC)
145 cpu="i386"
147 x86_64|amd64)
148 cpu="x86_64"
150 armv*b)
151 cpu="armv4b"
153 armv*l)
154 cpu="armv4l"
156 parisc|parisc64)
157 cpu="hppa"
159 s390*)
160 cpu="s390"
162 sparc|sun4[cdmuv])
163 cpu="sparc"
166 cpu="unknown"
168 esac
170 kvm_version() {
171 local fname="$(dirname "$0")/KVM_VERSION"
173 if test -f "$fname"; then
174 cat "$fname"
175 else
176 echo "qemu-kvm-devel"
180 # Default value for a variable defining feature "foo"
181 # * foo="no", feature will only be used if --enable-foo arg is given
182 # * foo="", feature will be searched for, and if found, will be used
183 # * foo="yes", this value vill only be set by --enable-foo flag.
184 # feature will searched for, if not found, configure exits with error
186 # Always add --enable-foo and --disable-foo command line args. Distributions want
187 # to ensure that several features are compiled in, and it is impossible without a
188 # --enable-foo that exits if feature is not found
190 bluez=""
191 brlapi=""
192 curl=""
193 curses=""
194 docs=""
195 fdt=""
196 kvm=""
197 nptl=""
198 sdl=""
199 sparse="no"
200 vde=""
201 vnc_tls=""
202 vnc_sasl=""
203 xen=""
204 linux_aio=""
206 gprof="no"
207 debug_tcg="no"
208 debug="no"
209 strip_opt="yes"
210 bigendian="no"
211 mingw32="no"
212 EXESUF=""
213 slirp="yes"
214 fmod_lib=""
215 fmod_inc=""
216 oss_lib=""
217 bsd="no"
218 linux="no"
219 solaris="no"
220 profiler="no"
221 cocoa="no"
222 softmmu="yes"
223 linux_user="no"
224 darwin_user="no"
225 bsd_user="no"
226 guest_base=""
227 uname_release=""
228 io_thread="no"
229 mixemu="no"
230 kvm_trace="no"
231 kvm_cap_pit="no"
232 kvm_cap_device_assignment="no"
233 kerneldir=""
234 aix="no"
235 blobs="yes"
236 pkgversion=" ($(kvm_version))"
237 cpu_emulation="yes"
238 kvm_kmod="no"
239 pkgversion=""
240 check_utests="no"
241 user_pie="no"
243 # OS specific
244 if check_define __linux__ ; then
245 targetos="Linux"
246 elif check_define _WIN32 ; then
247 targetos='MINGW32'
248 elif check_define __OpenBSD__ ; then
249 targetos='OpenBSD'
250 elif check_define __sun__ ; then
251 targetos='SunOS'
252 else
253 targetos=`uname -s`
256 case $targetos in
257 CYGWIN*)
258 mingw32="yes"
259 QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
260 audio_possible_drivers="sdl"
262 MINGW32*)
263 mingw32="yes"
264 audio_possible_drivers="dsound sdl fmod"
266 GNU/kFreeBSD)
267 audio_drv_list="oss"
268 audio_possible_drivers="oss sdl esd pa"
270 FreeBSD)
271 bsd="yes"
272 audio_drv_list="oss"
273 audio_possible_drivers="oss sdl esd pa"
275 DragonFly)
276 bsd="yes"
277 audio_drv_list="oss"
278 audio_possible_drivers="oss sdl esd pa"
280 NetBSD)
281 bsd="yes"
282 audio_drv_list="oss"
283 audio_possible_drivers="oss sdl esd"
284 oss_lib="-lossaudio"
286 OpenBSD)
287 bsd="yes"
288 audio_drv_list="oss"
289 audio_possible_drivers="oss sdl esd"
290 oss_lib="-lossaudio"
292 Darwin)
293 bsd="yes"
294 darwin="yes"
295 # on Leopard most of the system is 32-bit, so we have to ask the kernel it if we can
296 # run 64-bit userspace code
297 if [ "$cpu" = "i386" ] ; then
298 is_x86_64=`sysctl -n hw.optional.x86_64`
299 [ "$is_x86_64" = "1" ] && cpu=x86_64
301 if [ "$cpu" = "x86_64" ] ; then
302 QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
303 LDFLAGS="-arch x86_64 $LDFLAGS"
304 else
305 QEMU_CFLAGS="-mdynamic-no-pic $QEMU_CFLAGS"
307 darwin_user="yes"
308 cocoa="yes"
309 audio_drv_list="coreaudio"
310 audio_possible_drivers="coreaudio sdl fmod"
311 LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
312 libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
314 SunOS)
315 solaris="yes"
316 make="gmake"
317 install="ginstall"
318 needs_libsunmath="no"
319 solarisrev=`uname -r | cut -f2 -d.`
320 # have to select again, because `uname -m` returns i86pc
321 # even on an x86_64 box.
322 solariscpu=`isainfo -k`
323 if test "${solariscpu}" = "amd64" ; then
324 cpu="x86_64"
326 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
327 if test "$solarisrev" -le 9 ; then
328 if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
329 needs_libsunmath="yes"
330 QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
331 LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
332 LIBS="-lsunmath $LIBS"
333 else
334 echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
335 echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
336 echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
337 echo "Studio 11 can be downloaded from www.sun.com."
338 exit 1
342 if test -f /usr/include/sys/soundcard.h ; then
343 audio_drv_list="oss"
345 audio_possible_drivers="oss sdl"
346 # needed for CMSG_ macros in sys/socket.h
347 QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
348 # needed for TIOCWIN* defines in termios.h
349 QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
350 QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
351 LIBS="-lsocket -lnsl -lresolv $LIBS"
353 AIX)
354 aix="yes"
355 make="gmake"
358 audio_drv_list="oss"
359 audio_possible_drivers="oss alsa sdl esd pa"
360 linux="yes"
361 linux_user="yes"
362 usb="linux"
363 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
364 audio_possible_drivers="$audio_possible_drivers fmod"
365 kvm="yes"
367 if [ "$cpu" = "ia64" ] ; then
368 kvm="yes"
369 xen="no"
370 target_list="ia64-softmmu"
371 cpu_emulation="no"
372 gdbstub="no"
373 slirp="no"
375 if [ "$cpu" = "powerpc" ]; then
376 kvm="yes"
379 esac
381 if [ "$bsd" = "yes" ] ; then
382 if [ "$darwin" != "yes" ] ; then
383 make="gmake"
384 usb="bsd"
386 bsd_user="yes"
389 if test "$mingw32" = "yes" ; then
390 EXESUF=".exe"
391 QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
392 LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
395 # find source path
396 source_path=`dirname "$0"`
397 source_path_used="no"
398 workdir=`pwd`
399 if [ -z "$source_path" ]; then
400 source_path=$workdir
401 else
402 source_path=`cd "$source_path"; pwd`
404 [ -f "$workdir/vl.c" ] || source_path_used="yes"
406 werror=""
408 for opt do
409 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
410 case "$opt" in
411 --help|-h) show_help=yes
413 --prefix=*) prefix="$optarg"
415 --interp-prefix=*) interp_prefix="$optarg"
417 --source-path=*) source_path="$optarg"
418 source_path_used="yes"
420 --cross-prefix=*)
422 --cc=*)
424 --host-cc=*) host_cc="$optarg"
426 --make=*) make="$optarg"
428 --install=*) install="$optarg"
430 --extra-cflags=*)
432 --extra-ldflags=*)
434 --cpu=*)
436 --target-list=*) target_list="$optarg"
438 --enable-gprof) gprof="yes"
440 --static) static="yes"
442 --disable-sdl) sdl="no"
444 --enable-sdl) sdl="yes"
446 --fmod-lib=*) fmod_lib="$optarg"
448 --fmod-inc=*) fmod_inc="$optarg"
450 --oss-lib=*) oss_lib="$optarg"
452 --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
454 --audio-drv-list=*) audio_drv_list="$optarg"
456 --enable-debug-tcg) debug_tcg="yes"
458 --disable-debug-tcg) debug_tcg="no"
460 --enable-debug)
461 # Enable debugging options that aren't excessively noisy
462 debug_tcg="yes"
463 debug="yes"
464 strip_opt="no"
466 --enable-sparse) sparse="yes"
468 --disable-sparse) sparse="no"
470 --disable-strip) strip_opt="no"
472 --disable-vnc-tls) vnc_tls="no"
474 --enable-vnc-tls) vnc_tls="yes"
476 --disable-vnc-sasl) vnc_sasl="no"
478 --enable-vnc-sasl) vnc_sasl="yes"
480 --disable-slirp) slirp="no"
482 --disable-vde) vde="no"
484 --enable-vde) vde="yes"
486 --disable-xen) xen="no"
488 --enable-xen) xen="yes"
490 --disable-brlapi) brlapi="no"
492 --enable-brlapi) brlapi="yes"
494 --disable-bluez) bluez="no"
496 --enable-bluez) bluez="yes"
498 --disable-kvm) kvm="no"
500 --enable-kvm) kvm="yes"
502 --enable-profiler) profiler="yes"
504 --enable-cocoa)
505 cocoa="yes" ;
506 sdl="no" ;
507 audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
509 --disable-system) softmmu="no"
511 --enable-system) softmmu="yes"
513 --disable-user)
514 linux_user="no" ;
515 bsd_user="no" ;
516 darwin_user="no"
518 --enable-user) ;;
519 --disable-linux-user) linux_user="no"
521 --enable-linux-user) linux_user="yes"
523 --disable-darwin-user) darwin_user="no"
525 --enable-darwin-user) darwin_user="yes"
527 --disable-bsd-user) bsd_user="no"
529 --enable-bsd-user) bsd_user="yes"
531 --enable-guest-base) guest_base="yes"
533 --disable-guest-base) guest_base="no"
535 --enable-user-pie) user_pie="yes"
537 --disable-user-pie) user_pie="no"
539 --enable-uname-release=*) uname_release="$optarg"
541 --sparc_cpu=*)
543 --enable-werror) werror="yes"
545 --disable-werror) werror="no"
547 --disable-curses) curses="no"
549 --enable-curses) curses="yes"
551 --disable-curl) curl="no"
553 --enable-curl) curl="yes"
555 --disable-fdt) fdt="no"
557 --enable-fdt) fdt="yes"
559 --disable-check-utests) check_utests="no"
561 --enable-check-utests) check_utests="yes"
563 --disable-nptl) nptl="no"
565 --enable-nptl) nptl="yes"
567 --enable-mixemu) mixemu="yes"
569 --disable-linux-aio) linux_aio="no"
571 --enable-linux-aio) linux_aio="yes"
573 --enable-io-thread) io_thread="yes"
575 --disable-blobs) blobs="no"
577 --kerneldir=*) kerneldir="$optarg"
579 --with-kvm-trace) kvm_trace="yes"
581 --with-pkgversion=*) pkgversion=" ($optarg)"
583 --disable-docs) docs="no"
585 --enable-docs) docs="yes"
587 --disable-cpu-emulation) cpu_emulation="no"
589 *) echo "ERROR: unknown option $opt"; show_help="yes"
591 esac
592 done
595 # If cpu ~= sparc and sparc_cpu hasn't been defined, plug in the right
596 # QEMU_CFLAGS/LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
598 host_guest_base="no"
599 case "$cpu" in
600 sparc) case $sparc_cpu in
601 v7|v8)
602 QEMU_CFLAGS="-mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
604 v8plus|v8plusa)
605 QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
607 *) # sparc_cpu not defined in the command line
608 QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_v8plus__ $QEMU_CFLAGS"
609 esac
610 LDFLAGS="-m32 $LDFLAGS"
611 QEMU_CFLAGS="-m32 -ffixed-g2 -ffixed-g3 $QEMU_CFLAGS"
612 if test "$solaris" = "no" ; then
613 QEMU_CFLAGS="-ffixed-g1 -ffixed-g6 $QEMU_CFLAGS"
614 helper_cflags="-ffixed-i0"
617 sparc64)
618 QEMU_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__ $QEMU_CFLAGS"
619 LDFLAGS="-m64 $LDFLAGS"
620 QEMU_CFLAGS="-ffixed-g5 -ffixed-g6 -ffixed-g7 $QEMU_CFLAGS"
621 if test "$solaris" != "no" ; then
622 QEMU_CFLAGS="-ffixed-g1 $QEMU_CFLAGS"
625 s390)
626 QEMU_CFLAGS="-march=z900 $QEMU_CFLAGS"
628 i386)
629 QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
630 LDFLAGS="-m32 $LDFLAGS"
631 helper_cflags="-fomit-frame-pointer"
632 host_guest_base="yes"
634 x86_64)
635 QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
636 LDFLAGS="-m64 $LDFLAGS"
637 host_guest_base="yes"
639 arm*)
640 host_guest_base="yes"
642 ppc*)
643 host_guest_base="yes"
645 esac
647 [ -z "$guest_base" ] && guest_base="$host_guest_base"
649 if test x"$show_help" = x"yes" ; then
650 cat << EOF
652 Usage: configure [options]
653 Options: [defaults in brackets after descriptions]
656 echo "Standard options:"
657 echo " --help print this message"
658 echo " --prefix=PREFIX install in PREFIX [$prefix]"
659 echo " --interp-prefix=PREFIX where to find shared libraries, etc."
660 echo " use %M for cpu name [$interp_prefix]"
661 echo " --target-list=LIST set target list [$target_list]"
662 echo ""
663 echo "Advanced options (experts only):"
664 echo " --source-path=PATH path of source code [$source_path]"
665 echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
666 echo " --cc=CC use C compiler CC [$cc]"
667 echo " --host-cc=CC use C compiler CC [$host_cc] for dyngen etc."
668 echo " --extra-cflags=CFLAGS append extra C compiler flags QEMU_CFLAGS"
669 echo " --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS"
670 echo " --make=MAKE use specified make [$make]"
671 echo " --install=INSTALL use specified install [$install]"
672 echo " --static enable static build [$static]"
673 echo " --enable-debug-tcg enable TCG debugging"
674 echo " --disable-debug-tcg disable TCG debugging (default)"
675 echo " --enable-debug enable common debug build options"
676 echo " --enable-sparse enable sparse checker"
677 echo " --disable-sparse disable sparse checker (default)"
678 echo " --disable-strip disable stripping binaries"
679 echo " --disable-werror disable compilation abort on warning"
680 echo " --disable-sdl disable SDL"
681 echo " --enable-sdl enable SDL"
682 echo " --enable-cocoa enable COCOA (Mac OS X only)"
683 echo " --audio-drv-list=LIST set audio drivers list:"
684 echo " Available drivers: $audio_possible_drivers"
685 echo " --audio-card-list=LIST set list of emulated audio cards [$audio_card_list]"
686 echo " Available cards: $audio_possible_cards"
687 echo " --enable-mixemu enable mixer emulation"
688 echo " --disable-xen disable xen backend driver support"
689 echo " --enable-xen enable xen backend driver support"
690 echo " --disable-brlapi disable BrlAPI"
691 echo " --enable-brlapi enable BrlAPI"
692 echo " --disable-vnc-tls disable TLS encryption for VNC server"
693 echo " --enable-vnc-tls enable TLS encryption for VNC server"
694 echo " --disable-vnc-sasl disable SASL encryption for VNC server"
695 echo " --enable-vnc-sasl enable SASL encryption for VNC server"
696 echo " --disable-curses disable curses output"
697 echo " --enable-curses enable curses output"
698 echo " --disable-curl disable curl connectivity"
699 echo " --enable-curl enable curl connectivity"
700 echo " --disable-fdt disable fdt device tree"
701 echo " --enable-fdt enable fdt device tree"
702 echo " --disable-check-utests disable check unit-tests"
703 echo " --enable-check-utests enable check unit-tests"
704 echo " --disable-bluez disable bluez stack connectivity"
705 echo " --enable-bluez enable bluez stack connectivity"
706 echo " --disable-kvm disable KVM acceleration support"
707 echo " --enable-kvm enable KVM acceleration support"
708 echo " --disable-nptl disable usermode NPTL support"
709 echo " --enable-nptl disable usermode NPTL support"
710 echo " --enable-system enable all system emulation targets"
711 echo " --disable-system disable all system emulation targets"
712 echo " --enable-user enable supported user emulation targets"
713 echo " --disable-user disable all user emulation targets"
714 echo " --enable-linux-user enable all linux usermode emulation targets"
715 echo " --disable-linux-user disable all linux usermode emulation targets"
716 echo " --enable-darwin-user enable all darwin usermode emulation targets"
717 echo " --disable-darwin-user disable all darwin usermode emulation targets"
718 echo " --enable-bsd-user enable all BSD usermode emulation targets"
719 echo " --disable-bsd-user disable all BSD usermode emulation targets"
720 echo " --enable-guest-base enable GUEST_BASE support for usermode"
721 echo " emulation targets"
722 echo " --disable-guest-base disable GUEST_BASE support"
723 echo " --enable-user-pie build usermode emulation targets as PIE"
724 echo " --disable-user-pie do not build usermode emulation targets as PIE"
725 echo " --fmod-lib path to FMOD library"
726 echo " --fmod-inc path to FMOD includes"
727 echo " --oss-lib path to OSS library"
728 echo " --enable-uname-release=R Return R for uname -r in usermode emulation"
729 echo " --sparc_cpu=V Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
730 echo " --disable-vde disable support for vde network"
731 echo " --enable-vde enable support for vde network"
732 echo " --disable-linux-aio disable Linux AIO support"
733 echo " --enable-linux-aio enable Linux AIO support"
734 echo " --enable-io-thread enable IO thread"
735 echo " --disable-blobs disable installing provided firmware blobs"
736 echo " --kerneldir=PATH look for kernel includes in PATH"
737 echo " --with-kvm-trace enable building the KVM module with the kvm trace option"
738 echo " --disable-cpu-emulation disables use of qemu cpu emulation code"
739 echo ""
740 echo "NOTE: The object files are built at the place where configure is launched"
741 exit 1
745 # Solaris specific configure tool chain decisions
747 if test "$solaris" = "yes" ; then
748 solinst=`which $install 2> /dev/null | /usr/bin/grep -v "no $install in"`
749 if test -z "$solinst" ; then
750 echo "Solaris install program not found. Use --install=/usr/ucb/install or"
751 echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
752 echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
753 exit 1
755 if test "$solinst" = "/usr/sbin/install" ; then
756 echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
757 echo "try ginstall from the GNU fileutils available from www.blastwave.org"
758 echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
759 exit 1
761 sol_ar=`which ar 2> /dev/null | /usr/bin/grep -v "no ar in"`
762 if test -z "$sol_ar" ; then
763 echo "Error: No path includes ar"
764 if test -f /usr/ccs/bin/ar ; then
765 echo "Add /usr/ccs/bin to your path and rerun configure"
767 exit 1
772 if test -z "$target_list" ; then
773 # these targets are portable
774 if [ "$softmmu" = "yes" ] ; then
775 target_list="\
776 i386-softmmu \
777 x86_64-softmmu \
778 arm-softmmu \
779 cris-softmmu \
780 m68k-softmmu \
781 microblaze-softmmu \
782 mips-softmmu \
783 mipsel-softmmu \
784 mips64-softmmu \
785 mips64el-softmmu \
786 ppc-softmmu \
787 ppcemb-softmmu \
788 ppc64-softmmu \
789 sh4-softmmu \
790 sh4eb-softmmu \
791 sparc-softmmu \
792 sparc64-softmmu \
795 # the following are Linux specific
796 if [ "$linux_user" = "yes" ] ; then
797 target_list="${target_list}\
798 i386-linux-user \
799 x86_64-linux-user \
800 alpha-linux-user \
801 arm-linux-user \
802 armeb-linux-user \
803 cris-linux-user \
804 m68k-linux-user \
805 microblaze-linux-user \
806 mips-linux-user \
807 mipsel-linux-user \
808 ppc-linux-user \
809 ppc64-linux-user \
810 ppc64abi32-linux-user \
811 sh4-linux-user \
812 sh4eb-linux-user \
813 sparc-linux-user \
814 sparc64-linux-user \
815 sparc32plus-linux-user \
818 # the following are Darwin specific
819 if [ "$darwin_user" = "yes" ] ; then
820 target_list="$target_list i386-darwin-user ppc-darwin-user "
822 # the following are BSD specific
823 if [ "$bsd_user" = "yes" ] ; then
824 target_list="${target_list}\
825 i386-bsd-user \
826 x86_64-bsd-user \
827 sparc-bsd-user \
828 sparc64-bsd-user \
831 else
832 target_list=`echo "$target_list" | sed -e 's/,/ /g'`
834 if test -z "$target_list" ; then
835 echo "No targets enabled"
836 exit 1
839 feature_not_found() {
840 feature=$1
842 echo "ERROR"
843 echo "ERROR: User requested feature $feature"
844 echo "ERROR: configure was not able to find it"
845 echo "ERROR"
846 exit 1;
849 if test -z "$cross_prefix" ; then
851 # ---
852 # big/little endian test
853 cat > $TMPC << EOF
854 #include <inttypes.h>
855 int main(int argc, char ** argv){
856 volatile uint32_t i=0x01234567;
857 return (*((uint8_t*)(&i))) == 0x67;
861 if compile_prog "" "" ; then
862 $TMPE && bigendian="yes"
863 else
864 echo big/little test failed
867 else
869 # if cross compiling, cannot launch a program, so make a static guess
870 case "$cpu" in
871 armv4b|hppa|m68k|mips|mips64|ppc|ppc64|s390|sparc|sparc64)
872 bigendian=yes
874 esac
878 # host long bits test
879 hostlongbits="32"
880 case "$cpu" in
881 x86_64|alpha|ia64|sparc64|ppc64)
882 hostlongbits=64
884 esac
887 ##########################################
888 # NPTL probe
890 if test "$nptl" != "no" ; then
891 cat > $TMPC <<EOF
892 #include <sched.h>
893 #include <linux/futex.h>
894 void foo()
896 #if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
897 #error bork
898 #endif
902 if compile_object ; then
903 nptl=yes
904 else
905 if test "$nptl" = "yes" ; then
906 feature_not_found "nptl"
908 nptl=no
912 ##########################################
913 # KVM probe
915 case "$cpu" in
916 i386 | x86_64)
917 kvm_arch="x86"
919 ppc)
920 kvm_arch="powerpc"
923 kvm_arch="$cpu"
925 esac
927 kvm_cflags=""
929 if test "$kvm" = "yes" ; then
931 kvm_cflags="-I$source_path/kvm/include"
932 kvm_cflags="$kvm_cflags -I$source_path/kvm/include/$kvm_arch"
933 kvm_cflags="$kvm_cflags -idirafter $source_path/compat"
935 # test for KVM_CAP_PIT
937 cat > $TMPC <<EOF
938 #include <linux/kvm.h>
939 #ifndef KVM_CAP_PIT
940 #error "kvm no pit capability"
941 #endif
942 int main(void) { return 0; }
944 if $cc $ARCH_CFLAGS $CFLAGS $kvm_cflags -o $TMPE ${OS_CFLAGS} $TMPC 2> /dev/null ; then
945 kvm_cap_pit="yes"
948 # test for KVM_CAP_DEVICE_ASSIGNMENT
950 cat > $TMPC <<EOF
951 #include <linux/kvm.h>
952 #ifndef KVM_CAP_DEVICE_ASSIGNMENT
953 #error "kvm no device assignment capability"
954 #endif
955 int main(void) { return 0; }
957 if $cc $ARCH_CFLAGS $CFLAGS $kvm_cflags -o $TMPE ${OS_CFLAGS} $TMPC 2> /dev/null ; then
958 kvm_cap_device_assignment="yes"
962 # libpci probe for kvm_cap_device_assignment
963 if test $kvm_cap_device_assignment = "yes" ; then
964 cat > $TMPC << EOF
965 #include <pci/pci.h>
966 #ifndef PCI_VENDOR_ID
967 #error NO LIBPCI
968 #endif
969 int main(void) { return 0; }
971 if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $TMPC 2>/dev/null ; then
973 else
974 echo
975 echo "Error: libpci check failed"
976 echo "Disable KVM Device Assignment capability."
977 echo
978 kvm_cap_device_assignment="no"
982 ##########################################
983 # zlib check
985 cat > $TMPC << EOF
986 #include <zlib.h>
987 int main(void) { zlibVersion(); return 0; }
989 if compile_prog "" "-lz" ; then
991 else
992 echo
993 echo "Error: zlib check failed"
994 echo "Make sure to have the zlib libs and headers installed."
995 echo
996 exit 1
999 ##########################################
1000 # xen probe
1002 if test "$xen" != "no" ; then
1003 xen_libs="-lxenstore -lxenctrl -lxenguest"
1004 cat > $TMPC <<EOF
1005 #include <xenctrl.h>
1006 #include <xs.h>
1007 int main(void) { xs_daemon_open(); xc_interface_open(); return 0; }
1009 if compile_prog "" "$xen_libs" ; then
1010 xen=yes
1011 libs_softmmu="$xen_libs $libs_softmmu"
1012 else
1013 if test "$xen" = "yes" ; then
1014 feature_not_found "xen"
1016 xen=no
1020 ##########################################
1021 # Sparse probe
1022 if test "$sparse" != "no" ; then
1023 if test -x "$(which cgcc 2>/dev/null)"; then
1024 sparse=yes
1025 else
1026 if test "$sparse" = "yes" ; then
1027 feature_not_found "sparse"
1029 sparse=no
1033 ##########################################
1034 # SDL probe
1036 sdl_too_old=no
1038 if test "$sdl" != "no" ; then
1039 cat > $TMPC << EOF
1040 #include <SDL.h>
1041 #undef main /* We don't want SDL to override our main() */
1042 int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
1044 sdl_cflags=`sdl-config --cflags 2> /dev/null`
1045 sdl_libs=`sdl-config --libs 2> /dev/null`
1046 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1047 _sdlversion=`sdl-config --version | sed 's/[^0-9]//g'`
1048 if test "$_sdlversion" -lt 121 ; then
1049 sdl_too_old=yes
1050 else
1051 if test "$cocoa" = "no" ; then
1052 sdl=yes
1056 # static link with sdl ?
1057 if test "$sdl" = "yes" -a "$static" = "yes" ; then
1058 sdl_libs=`sdl-config --static-libs 2>/dev/null`
1059 if test `sdl-config --static-libs 2>/dev/null | grep \\\-laa > /dev/null` ; then
1060 sdl_libs="$sdl_libs `aalib-config --static-libs >2 /dev/null`"
1061 sdl_cflags="$sd_cflags `aalib-config --cflags >2 /dev/null`"
1063 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1065 else
1066 sdl=no
1068 fi # static link
1069 else # sdl not found
1070 if test "$sdl" = "yes" ; then
1071 feature_not_found "sdl"
1073 sdl=no
1074 fi # sdl compile test
1077 if test "$sdl" = "yes" ; then
1078 cat > $TMPC <<EOF
1079 #include <SDL.h>
1080 #if defined(SDL_VIDEO_DRIVER_X11)
1081 #include <X11/XKBlib.h>
1082 #else
1083 #error No x11 support
1084 #endif
1085 int main(void) { return 0; }
1087 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1088 sdl_libs="$sdl_libs -lX11"
1090 if test "$mingw32" = "yes" ; then
1091 sdl_libs="`echo $sdl_libs | sed s/-mwindows//g` -mconsole"
1093 libs_softmmu="$sdl_libs $libs_softmmu"
1096 ##########################################
1097 # VNC TLS detection
1098 if test "$vnc_tls" != "no" ; then
1099 cat > $TMPC <<EOF
1100 #include <gnutls/gnutls.h>
1101 int main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
1103 vnc_tls_cflags=`pkg-config --cflags gnutls 2> /dev/null`
1104 vnc_tls_libs=`pkg-config --libs gnutls 2> /dev/null`
1105 if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
1106 vnc_tls=yes
1107 libs_softmmu="$vnc_tls_libs $libs_softmmu"
1108 else
1109 if test "$vnc_tls" = "yes" ; then
1110 feature_not_found "vnc-tls"
1112 vnc_tls=no
1116 ##########################################
1117 # VNC SASL detection
1118 if test "$vnc_sasl" != "no" ; then
1119 cat > $TMPC <<EOF
1120 #include <sasl/sasl.h>
1121 #include <stdio.h>
1122 int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
1124 # Assuming Cyrus-SASL installed in /usr prefix
1125 vnc_sasl_cflags=""
1126 vnc_sasl_libs="-lsasl2"
1127 if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1128 vnc_sasl=yes
1129 libs_softmmu="$vnc_sasl_libs $libs_softmmu"
1130 else
1131 if test "$vnc_sasl" = "yes" ; then
1132 feature_not_found "vnc-sasl"
1134 vnc_sasl=no
1138 ##########################################
1139 # fnmatch() probe, used for ACL routines
1140 fnmatch="no"
1141 cat > $TMPC << EOF
1142 #include <fnmatch.h>
1143 int main(void)
1145 fnmatch("foo", "foo", 0);
1146 return 0;
1149 if compile_prog "" "" ; then
1150 fnmatch="yes"
1153 ##########################################
1154 # vde libraries probe
1155 if test "$vde" != "no" ; then
1156 vde_libs="-lvdeplug"
1157 cat > $TMPC << EOF
1158 #include <libvdeplug.h>
1159 int main(void)
1161 struct vde_open_args a = {0, 0, 0};
1162 vde_open("", "", &a);
1163 return 0;
1166 if compile_prog "" "$vde_libs" ; then
1167 vde=yes
1168 libs_softmmu="$vde_libs $libs_softmmu"
1169 libs_tools="$vde_libs $libs_tools"
1170 else
1171 if test "$vde" = "yes" ; then
1172 feature_not_found "vde"
1174 vde=no
1178 ##########################################
1179 # Sound support libraries probe
1181 audio_drv_probe()
1183 drv=$1
1184 hdr=$2
1185 lib=$3
1186 exp=$4
1187 cfl=$5
1188 cat > $TMPC << EOF
1189 #include <$hdr>
1190 int main(void) { $exp }
1192 if compile_prog "$cfl" "$lib" ; then
1194 else
1195 echo
1196 echo "Error: $drv check failed"
1197 echo "Make sure to have the $drv libs and headers installed."
1198 echo
1199 exit 1
1203 audio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
1204 for drv in $audio_drv_list; do
1205 case $drv in
1206 alsa)
1207 audio_drv_probe $drv alsa/asoundlib.h -lasound \
1208 "snd_pcm_t **handle; return snd_pcm_close(*handle);"
1209 libs_softmmu="-lasound $libs_softmmu"
1212 fmod)
1213 if test -z $fmod_lib || test -z $fmod_inc; then
1214 echo
1215 echo "Error: You must specify path to FMOD library and headers"
1216 echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
1217 echo
1218 exit 1
1220 audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
1221 libs_softmmu="$fmod_lib $libs_softmmu"
1224 esd)
1225 audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
1226 libs_softmmu="-lesd $libs_softmmu"
1227 audio_pt_int="yes"
1231 audio_drv_probe $drv pulse/simple.h -lpulse-simple \
1232 "pa_simple *s = NULL; pa_simple_free(s); return 0;"
1233 libs_softmmu="-lpulse-simple $libs_softmmu"
1234 audio_pt_int="yes"
1237 coreaudio)
1238 libs_softmmu="-framework CoreAudio $libs_softmmu"
1241 dsound)
1242 libs_softmmu="-lole32 -ldxguid $libs_softmmu"
1245 oss)
1246 libs_softmmu="$oss_lib $libs_softmmu"
1249 sdl|wav)
1250 # XXX: Probes for CoreAudio, DirectSound, SDL(?)
1254 echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
1255 echo
1256 echo "Error: Unknown driver '$drv' selected"
1257 echo "Possible drivers are: $audio_possible_drivers"
1258 echo
1259 exit 1
1262 esac
1263 done
1265 ##########################################
1266 # BrlAPI probe
1268 if test "$brlapi" != "no" ; then
1269 brlapi_libs="-lbrlapi"
1270 cat > $TMPC << EOF
1271 #include <brlapi.h>
1272 int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
1274 if compile_prog "" "$brlapi_libs" ; then
1275 brlapi=yes
1276 libs_softmmu="$brlapi_libs $libs_softmmu"
1277 else
1278 if test "$brlapi" = "yes" ; then
1279 feature_not_found "brlapi"
1281 brlapi=no
1285 ##########################################
1286 # curses probe
1287 curses_list="-lncurses -lcurses"
1289 if test "$curses" != "no" ; then
1290 curses_found=no
1291 cat > $TMPC << EOF
1292 #include <curses.h>
1293 #ifdef __OpenBSD__
1294 #define resize_term resizeterm
1295 #endif
1296 int main(void) { resize_term(0, 0); return curses_version(); }
1298 for curses_lib in $curses_list; do
1299 if compile_prog "" "$curses_lib" ; then
1300 curses_found=yes
1301 libs_softmmu="$curses_lib $libs_softmmu"
1302 break
1304 done
1305 if test "$curses_found" = "yes" ; then
1306 curses=yes
1307 else
1308 if test "$curses" = "yes" ; then
1309 feature_not_found "curses"
1311 curses=no
1315 ##########################################
1316 # curl probe
1318 if test "$curl" != "no" ; then
1319 cat > $TMPC << EOF
1320 #include <curl/curl.h>
1321 int main(void) { return curl_easy_init(); }
1323 curl_cflags=`curl-config --cflags 2>/dev/null`
1324 curl_libs=`curl-config --libs 2>/dev/null`
1325 if compile_prog "$curl_cflags" "$curl_libs" ; then
1326 curl=yes
1327 libs_tools="$curl_libs $libs_tools"
1328 libs_softmmu="$curl_libs $libs_softmmu"
1329 else
1330 if test "$curl" = "yes" ; then
1331 feature_not_found "curl"
1333 curl=no
1335 fi # test "$curl"
1337 ##########################################
1338 # check framework probe
1340 if test "$check_utests" != "no" ; then
1341 cat > $TMPC << EOF
1342 #include <check.h>
1343 int main(void) { suite_create("qemu test"); return 0; }
1345 check_libs=`pkg-config --libs check`
1346 if compile_prog "" $check_libs ; then
1347 check_utests=yes
1348 libs_tools="$check_libs $libs_tools"
1349 else
1350 if test "$check_utests" = "yes" ; then
1351 feature_not_found "check"
1353 check_utests=no
1355 fi # test "$check_utests"
1357 ##########################################
1358 # bluez support probe
1359 if test "$bluez" != "no" ; then
1360 cat > $TMPC << EOF
1361 #include <bluetooth/bluetooth.h>
1362 int main(void) { return bt_error(0); }
1364 bluez_cflags=`pkg-config --cflags bluez 2> /dev/null`
1365 bluez_libs=`pkg-config --libs bluez 2> /dev/null`
1366 if compile_prog "$bluez_cflags" "$bluez_libs" ; then
1367 bluez=yes
1368 libs_softmmu="$bluez_libs $libs_softmmu"
1369 else
1370 if test "$bluez" = "yes" ; then
1371 feature_not_found "bluez"
1373 bluez="no"
1377 ##########################################
1378 # kvm probe
1379 if test "$kvm" != "no" ; then
1380 cat > $TMPC <<EOF
1381 #include <linux/kvm.h>
1382 #if !defined(KVM_API_VERSION) || KVM_API_VERSION < 12 || KVM_API_VERSION > 12
1383 #error Invalid KVM version
1384 #endif
1385 #if !defined(KVM_CAP_USER_MEMORY)
1386 #error Missing KVM capability KVM_CAP_USER_MEMORY
1387 #endif
1388 #if !defined(KVM_CAP_SET_TSS_ADDR)
1389 #error Missing KVM capability KVM_CAP_SET_TSS_ADDR
1390 #endif
1391 #if !defined(KVM_CAP_DESTROY_MEMORY_REGION_WORKS)
1392 #error Missing KVM capability KVM_CAP_DESTROY_MEMORY_REGION_WORKS
1393 #endif
1394 int main(void) { return 0; }
1396 if compile_prog "$kvm_cflags" "" ; then
1397 kvm=yes
1398 else
1399 if test "$kvm" = "yes" ; then
1400 if [ -x "`which awk 2>/dev/null`" ] && \
1401 [ -x "`which grep 2>/dev/null`" ]; then
1402 kvmerr=`LANG=C $cc $QEMU_CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&1 \
1403 | grep "error: " \
1404 | awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'`
1405 if test "$kvmerr" != "" ; then
1406 echo -e "${kvmerr}\n\
1407 NOTE: To enable KVM support, update your kernel to 2.6.29+ or install \
1408 recent kvm-kmod from http://sourceforge.net/projects/kvm."
1411 feature_not_found "kvm"
1413 kvm=no
1417 ##########################################
1418 # pthread probe
1419 PTHREADLIBS_LIST="-lpthread -lpthreadGC2"
1421 pthread=no
1422 cat > $TMPC << EOF
1423 #include <pthread.h>
1424 int main(void) { pthread_create(0,0,0,0); return 0; }
1426 for pthread_lib in $PTHREADLIBS_LIST; do
1427 if compile_prog "" "$pthread_lib" ; then
1428 pthread=yes
1429 LIBS="$pthread_lib $LIBS"
1430 break
1432 done
1434 if test "$mingw32" != yes -a "$pthread" = no; then
1435 echo
1436 echo "Error: pthread check failed"
1437 echo "Make sure to have the pthread libs and headers installed."
1438 echo
1439 exit 1
1442 ##########################################
1443 # linux-aio probe
1444 AIOLIBS=""
1446 if test "$linux_aio" != "no" ; then
1447 cat > $TMPC <<EOF
1448 #include <libaio.h>
1449 #include <sys/eventfd.h>
1450 int main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
1452 if compile_prog "" "-laio" ; then
1453 linux_aio=yes
1454 LIBS="$LIBS -laio"
1455 else
1456 if test "$linux_aio" = "yes" ; then
1457 feature_not_found "linux AIO"
1459 linux_aio=no
1463 ##########################################
1464 # iovec probe
1465 cat > $TMPC <<EOF
1466 #include <sys/types.h>
1467 #include <sys/uio.h>
1468 #include <unistd.h>
1469 int main(void) { struct iovec iov; return 0; }
1471 iovec=no
1472 if compile_prog "" "" ; then
1473 iovec=yes
1476 ##########################################
1477 # preadv probe
1478 cat > $TMPC <<EOF
1479 #include <sys/types.h>
1480 #include <sys/uio.h>
1481 #include <unistd.h>
1482 int main(void) { preadv; }
1484 preadv=no
1485 if compile_prog "" "" ; then
1486 preadv=yes
1489 ##########################################
1490 # fdt probe
1491 if test "$fdt" != "no" ; then
1492 fdt_libs="-lfdt"
1493 cat > $TMPC << EOF
1494 int main(void) { return 0; }
1496 if compile_prog "" "$fdt_libs" ; then
1497 fdt=yes
1498 libs_softmmu="$fdt_libs $libs_softmmu"
1499 else
1500 if test "$fdt" = "yes" ; then
1501 feature_not_found "fdt"
1503 fdt=no
1508 # Check for xxxat() functions when we are building linux-user
1509 # emulator. This is done because older glibc versions don't
1510 # have syscall stubs for these implemented.
1512 atfile=no
1513 cat > $TMPC << EOF
1514 #define _ATFILE_SOURCE
1515 #include <sys/types.h>
1516 #include <fcntl.h>
1517 #include <unistd.h>
1520 main(void)
1522 /* try to unlink nonexisting file */
1523 return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
1526 if compile_prog "" "" ; then
1527 atfile=yes
1530 # Check for inotify functions when we are building linux-user
1531 # emulator. This is done because older glibc versions don't
1532 # have syscall stubs for these implemented. In that case we
1533 # don't provide them even if kernel supports them.
1535 inotify=no
1536 cat > $TMPC << EOF
1537 #include <sys/inotify.h>
1540 main(void)
1542 /* try to start inotify */
1543 return inotify_init();
1546 if compile_prog "" "" ; then
1547 inotify=yes
1550 # check if utimensat and futimens are supported
1551 utimens=no
1552 cat > $TMPC << EOF
1553 #define _ATFILE_SOURCE
1554 #define _GNU_SOURCE
1555 #include <stddef.h>
1556 #include <fcntl.h>
1558 int main(void)
1560 utimensat(AT_FDCWD, "foo", NULL, 0);
1561 futimens(0, NULL);
1562 return 0;
1565 if compile_prog "" "" ; then
1566 utimens=yes
1569 # check if pipe2 is there
1570 pipe2=no
1571 cat > $TMPC << EOF
1572 #define _GNU_SOURCE
1573 #include <unistd.h>
1574 #include <fcntl.h>
1576 int main(void)
1578 int pipefd[2];
1579 pipe2(pipefd, O_CLOEXEC);
1580 return 0;
1583 if compile_prog "" "" ; then
1584 pipe2=yes
1587 # check if tee/splice is there. vmsplice was added same time.
1588 splice=no
1589 cat > $TMPC << EOF
1590 #define _GNU_SOURCE
1591 #include <unistd.h>
1592 #include <fcntl.h>
1593 #include <limits.h>
1595 int main(void)
1597 int len, fd;
1598 len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
1599 splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
1600 return 0;
1603 if compile_prog "" "" ; then
1604 splice=yes
1607 ##########################################
1608 # signalfd probe
1609 signalfd="no"
1610 cat > $TMPC << EOF
1611 #define _GNU_SOURCE
1612 #include <unistd.h>
1613 #include <sys/syscall.h>
1614 #include <signal.h>
1615 int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
1618 if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
1619 signalfd=yes
1622 # check if eventfd is supported
1623 eventfd=no
1624 cat > $TMPC << EOF
1625 #include <sys/eventfd.h>
1627 int main(void)
1629 int efd = eventfd(0, 0);
1630 return 0;
1633 if compile_prog "" "" ; then
1634 eventfd=yes
1637 # Check if tools are available to build documentation.
1638 if test "$docs" != "no" ; then
1639 if test -x "`which texi2html 2>/dev/null`" -a \
1640 -x "`which pod2man 2>/dev/null`" ; then
1641 docs=yes
1642 else
1643 if test "$docs" = "yes" ; then
1644 feature_not_found "docs"
1646 docs=no
1650 # Search for bsawp_32 function
1651 byteswap_h=no
1652 cat > $TMPC << EOF
1653 #include <byteswap.h>
1654 int main(void) { return bswap_32(0); }
1656 if compile_prog "" "" ; then
1657 byteswap_h=yes
1660 # Search for bsawp_32 function
1661 bswap_h=no
1662 cat > $TMPC << EOF
1663 #include <sys/endian.h>
1664 #include <sys/types.h>
1665 #include <machine/bswap.h>
1666 int main(void) { return bswap32(0); }
1668 if compile_prog "" "" ; then
1669 bswap_h=yes
1672 ##########################################
1673 # Do we need librt
1674 cat > $TMPC <<EOF
1675 #include <signal.h>
1676 #include <time.h>
1677 int main(void) { clockid_t id; return clock_gettime(id, NULL); }
1680 if compile_prog "" "" ; then
1682 elif compile_prog "" "-lrt" ; then
1683 LIBS="-lrt $LIBS"
1686 # Determine what linker flags to use to force archive inclusion
1687 check_linker_flags()
1690 if test "$2" ; then
1691 w2=-Wl,$2
1693 compile_prog "" "-Wl,$1 ${w2}"
1696 cat > $TMPC << EOF
1697 int main(void) { }
1699 if check_linker_flags --whole-archive --no-whole-archive ; then
1700 # GNU ld
1701 arlibs_begin="-Wl,--whole-archive"
1702 arlibs_end="-Wl,--no-whole-archive"
1703 elif check_linker_flags -z,allextract -z,defaultextract ; then
1704 # Solaris ld
1705 arlibs_begin="-Wl,-z,allextract"
1706 arlibs_end="-Wl,-z,defaultextract"
1707 elif check_linker_flags -all_load ; then
1708 # Mac OS X
1709 arlibs_begin="-all_load"
1710 arlibs_end=""
1711 else
1712 echo "Error: your linker does not support --whole-archive or -z."
1713 echo "Please report to qemu-devel@nongnu.org"
1714 exit 1
1717 if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
1718 "$aix" != "yes" ; then
1719 libs_softmmu="-lutil $libs_softmmu"
1722 ##########################################
1723 # check if the compiler defines offsetof
1725 need_offsetof=yes
1726 cat > $TMPC << EOF
1727 #include <stddef.h>
1728 int main(void) { struct s { int f; }; return offsetof(struct s, f); }
1730 if compile_prog "" "" ; then
1731 need_offsetof=no
1734 # End of CC checks
1735 # After here, no more $cc or $ld runs
1737 # default flags for all hosts
1738 QEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
1739 CFLAGS="-g $CFLAGS"
1740 if test "$debug" = "no" ; then
1741 CFLAGS="-O2 $CFLAGS"
1743 QEMU_CFLAGS="-Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
1744 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
1745 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
1746 QEMU_CFLAGS="-U_FORTIFY_SOURCE $QEMU_CFLAGS"
1747 QEMU_CFLAGS="-I. -I\$(SRC_PATH) -MMD -MP -MT \$@ $QEMU_CFLAGS"
1748 LDFLAGS="-g $LDFLAGS"
1750 # Consult white-list to determine whether to enable werror
1751 # by default. Only enable by default for git builds
1752 if test -z "$werror" ; then
1753 z_version=`cut -f3 -d. $source_path/VERSION`
1754 if test "$z_version" = "50" -a \
1755 "$linux" = "yes" ; then
1756 werror="yes"
1757 else
1758 werror="no"
1760 # disable default werror for kvm
1761 werror="no"
1764 if test "$werror" = "yes" ; then
1765 QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
1768 QEMU_CFLAGS="-D__user= $QEMU_CFLAGS"
1770 if test "$solaris" = "no" ; then
1771 if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
1772 LDFLAGS="-Wl,--warn-common $LDFLAGS"
1776 if test "$mingw32" = "yes" ; then
1777 if test -z "$prefix" ; then
1778 prefix="c:/Program Files/Qemu"
1780 mansuffix=""
1781 datasuffix=""
1782 docsuffix=""
1783 binsuffix=""
1784 else
1785 if test -z "$prefix" ; then
1786 prefix="/usr/local"
1788 mansuffix="/share/man"
1789 datasuffix="/share/qemu"
1790 docsuffix="/share/doc/qemu"
1791 binsuffix="/bin"
1794 if test -f kvm/kernel/configure; then
1795 kvm_kmod="yes"
1796 kmod_args=""
1797 if test -n "$kerneldir"; then
1798 kmod_args="--kerneldir=$kerneldir"
1800 if test "$kvm_trace" = "yes"; then
1801 kmod_args="$kmod_args --with-kvm-trace"
1803 # hope there are no spaces in kmod_args; can't use arrays because of
1804 # dash.
1805 (cd kvm/kernel; ./configure $kmod_args)
1808 echo "Install prefix $prefix"
1809 echo "BIOS directory $prefix$datasuffix"
1810 echo "binary directory $prefix$binsuffix"
1811 if test "$mingw32" = "no" ; then
1812 echo "Manual directory $prefix$mansuffix"
1813 echo "ELF interp prefix $interp_prefix"
1815 echo "Source path $source_path"
1816 echo "C compiler $cc"
1817 echo "Host C compiler $host_cc"
1818 echo "CFLAGS $CFLAGS"
1819 echo "QEMU_CFLAGS $QEMU_CFLAGS"
1820 echo "LDFLAGS $LDFLAGS"
1821 echo "make $make"
1822 echo "install $install"
1823 echo "host CPU $cpu"
1824 echo "host big endian $bigendian"
1825 echo "target list $target_list"
1826 echo "tcg debug enabled $debug_tcg"
1827 echo "gprof enabled $gprof"
1828 echo "sparse enabled $sparse"
1829 echo "strip binaries $strip_opt"
1830 echo "profiler $profiler"
1831 echo "static build $static"
1832 echo "-Werror enabled $werror"
1833 if test "$darwin" = "yes" ; then
1834 echo "Cocoa support $cocoa"
1836 echo "SDL support $sdl"
1837 echo "curses support $curses"
1838 echo "curl support $curl"
1839 echo "check support $check_utests"
1840 echo "mingw32 support $mingw32"
1841 echo "Audio drivers $audio_drv_list"
1842 echo "Extra audio cards $audio_card_list"
1843 echo "Mixer emulation $mixemu"
1844 echo "VNC TLS support $vnc_tls"
1845 echo "VNC SASL support $vnc_sasl"
1846 if test -n "$sparc_cpu"; then
1847 echo "Target Sparc Arch $sparc_cpu"
1849 echo "xen support $xen"
1850 echo "CPU emulation $cpu_emulation"
1851 echo "brlapi support $brlapi"
1852 echo "bluez support $bluez"
1853 echo "Documentation $docs"
1854 [ ! -z "$uname_release" ] && \
1855 echo "uname -r $uname_release"
1856 echo "NPTL support $nptl"
1857 echo "GUEST_BASE $guest_base"
1858 echo "PIE user targets $user_pie"
1859 echo "vde support $vde"
1860 echo "IO thread $io_thread"
1861 echo "Linux AIO support $linux_aio"
1862 echo "Install blobs $blobs"
1863 echo "KVM support $kvm"
1864 echo "KVM trace support $kvm_trace"
1865 echo "fdt support $fdt"
1866 echo "preadv support $preadv"
1868 if test $sdl_too_old = "yes"; then
1869 echo "-> Your SDL version is too old - please upgrade to have SDL support"
1872 config_host_mak="config-host.mak"
1873 config_host_h="config-host.h"
1874 config_host_ld="config-host.ld"
1876 #echo "Creating $config_host_mak and $config_host_h"
1878 test -f $config_host_h && mv $config_host_h ${config_host_h}~
1880 echo "# Automatically generated by configure - do not modify" > $config_host_mak
1881 printf "# Configured with:" >> $config_host_mak
1882 printf " '%s'" "$0" "$@" >> $config_host_mak
1883 echo >> $config_host_mak
1885 echo "CONFIG_QEMU_SHAREDIR=\"$prefix$datasuffix\"" >> $config_host_mak
1887 case "$cpu" in
1888 i386|x86_64|alpha|cris|hppa|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|s390|sparc|sparc64)
1889 ARCH=$cpu
1891 armv4b|armv4l)
1892 ARCH=arm
1895 echo "Unsupported CPU = $cpu"
1896 exit 1
1898 esac
1899 echo "ARCH=$ARCH" >> $config_host_mak
1900 if test "$debug_tcg" = "yes" ; then
1901 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
1903 if test "$debug" = "yes" ; then
1904 echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
1906 if test "$strip_opt" = "yes" ; then
1907 echo "STRIP_OPT=-s" >> $config_host_mak
1909 if test "$bigendian" = "yes" ; then
1910 echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
1912 echo "HOST_LONG_BITS=$hostlongbits" >> $config_host_mak
1913 if test "$mingw32" = "yes" ; then
1914 echo "CONFIG_WIN32=y" >> $config_host_mak
1915 else
1916 echo "CONFIG_POSIX=y" >> $config_host_mak
1919 if test "$darwin" = "yes" ; then
1920 echo "CONFIG_DARWIN=y" >> $config_host_mak
1923 if test "$aix" = "yes" ; then
1924 echo "CONFIG_AIX=y" >> $config_host_mak
1927 if test "$solaris" = "yes" ; then
1928 echo "CONFIG_SOLARIS=y" >> $config_host_mak
1929 echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
1930 if test "$needs_libsunmath" = "yes" ; then
1931 echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
1934 if test "$static" = "yes" ; then
1935 echo "CONFIG_STATIC=y" >> $config_host_mak
1936 LDFLAGS="-static $LDFLAGS"
1938 if test $profiler = "yes" ; then
1939 echo "CONFIG_PROFILER=y" >> $config_host_mak
1941 if test "$slirp" = "yes" ; then
1942 echo "CONFIG_SLIRP=y" >> $config_host_mak
1943 CFLAGS="-I\$(SRC_PATH)/slirp $CFLAGS"
1945 if test "$vde" = "yes" ; then
1946 echo "CONFIG_VDE=y" >> $config_host_mak
1948 for card in $audio_card_list; do
1949 def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
1950 echo "$def=y" >> $config_host_mak
1951 done
1952 echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
1953 for drv in $audio_drv_list; do
1954 def=CONFIG_`echo $drv | tr '[:lower:]' '[:upper:]'`
1955 echo "$def=y" >> $config_host_mak
1956 if test "$drv" = "fmod"; then
1957 echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
1959 done
1960 if test "$audio_pt_int" = "yes" ; then
1961 echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
1963 if test "$mixemu" = "yes" ; then
1964 echo "CONFIG_MIXEMU=y" >> $config_host_mak
1966 if test "$vnc_tls" = "yes" ; then
1967 echo "CONFIG_VNC_TLS=y" >> $config_host_mak
1968 echo "VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_host_mak
1970 if test "$vnc_sasl" = "yes" ; then
1971 echo "CONFIG_VNC_SASL=y" >> $config_host_mak
1972 echo "VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak
1974 if test "$fnmatch" = "yes" ; then
1975 echo "CONFIG_FNMATCH=y" >> $config_host_mak
1977 qemu_version=`head $source_path/VERSION`
1978 echo "VERSION=$qemu_version" >>$config_host_mak
1979 echo "PKGVERSION=$pkgversion" >>$config_host_mak
1980 echo "SRC_PATH=$source_path" >> $config_host_mak
1981 if [ "$source_path_used" = "yes" ]; then
1982 echo "VPATH=$source_path" >> $config_host_mak
1984 echo "TARGET_DIRS=$target_list" >> $config_host_mak
1985 if [ "$docs" = "yes" ] ; then
1986 echo "BUILD_DOCS=yes" >> $config_host_mak
1988 if test "$sdl" = "yes" ; then
1989 echo "CONFIG_SDL=y" >> $config_host_mak
1990 echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
1992 if test "$cocoa" = "yes" ; then
1993 echo "CONFIG_COCOA=y" >> $config_host_mak
1995 if test "$curses" = "yes" ; then
1996 echo "CONFIG_CURSES=y" >> $config_host_mak
1998 if test "$atfile" = "yes" ; then
1999 echo "CONFIG_ATFILE=y" >> $config_host_mak
2001 if test "$utimens" = "yes" ; then
2002 echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
2004 if test "$pipe2" = "yes" ; then
2005 echo "CONFIG_PIPE2=y" >> $config_host_mak
2007 if test "$splice" = "yes" ; then
2008 echo "CONFIG_SPLICE=y" >> $config_host_mak
2010 if test "$eventfd" = "yes" ; then
2011 echo "CONFIG_EVENTFD=y" >> $config_host_mak
2013 if test "$inotify" = "yes" ; then
2014 echo "CONFIG_INOTIFY=y" >> $config_host_mak
2016 if test "$byteswap_h" = "yes" ; then
2017 echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
2019 if test "$bswap_h" = "yes" ; then
2020 echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
2022 if test "$curl" = "yes" ; then
2023 echo "CONFIG_CURL=y" >> $config_host_mak
2024 echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
2026 if test "$brlapi" = "yes" ; then
2027 echo "CONFIG_BRLAPI=y" >> $config_host_mak
2029 if test "$bluez" = "yes" ; then
2030 echo "CONFIG_BLUEZ=y" >> $config_host_mak
2031 echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
2033 if test "$xen" = "yes" ; then
2034 echo "CONFIG_XEN=y" >> $config_host_mak
2036 if test "$io_thread" = "yes" ; then
2037 echo "CONFIG_IOTHREAD=y" >> $config_host_mak
2039 if test "$linux_aio" = "yes" ; then
2040 echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
2042 if test "$blobs" = "yes" ; then
2043 echo "INSTALL_BLOBS=yes" >> $config_host_mak
2045 if test "$iovec" = "yes" ; then
2046 echo "CONFIG_IOVEC=y" >> $config_host_mak
2048 if test "$preadv" = "yes" ; then
2049 echo "CONFIG_PREADV=y" >> $config_host_mak
2051 if test "$fdt" = "yes" ; then
2052 echo "CONFIG_FDT=y" >> $config_host_mak
2054 if test "$signalfd" = "yes" ; then
2055 echo "CONFIG_SIGNALFD=y" >> $config_host_mak
2057 if test "$need_offsetof" = "yes" ; then
2058 echo "CONFIG_NEED_OFFSETOF=y" >> $config_host_mak
2061 # XXX: suppress that
2062 if [ "$bsd" = "yes" ] ; then
2063 echo "CONFIG_BSD=y" >> $config_host_mak
2066 echo "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
2068 # USB host support
2069 case "$usb" in
2070 linux)
2071 echo "HOST_USB=linux" >> $config_host_mak
2073 bsd)
2074 echo "HOST_USB=bsd" >> $config_host_mak
2077 echo "HOST_USB=stub" >> $config_host_mak
2079 esac
2081 # this is a temp hack needed for kvm
2082 if test "$kvm" = "yes" ; then
2083 echo "KVM_CFLAGS=$kvm_cflags" >> $config_host_mak
2086 echo "KVM_KMOD=$kvm_kmod" >> $config_host_mak
2088 tools=
2089 if test `expr "$target_list" : ".*softmmu.*"` != 0 ; then
2090 tools="qemu-img\$(EXESUF) $tools"
2091 if [ "$linux" = "yes" ] ; then
2092 tools="qemu-nbd\$(EXESUF) qemu-io\$(EXESUF) $tools"
2093 if [ "$check_utests" = "yes" ]; then
2094 tools="check-qint check-qstring check-qdict $tools"
2096 elif test "$mingw32" = "yes" ; then
2097 tools="qemu-io\$(EXESUF) $tools"
2100 echo "TOOLS=$tools" >> $config_host_mak
2102 # Mac OS X ships with a broken assembler
2103 roms=
2104 if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
2105 "$targetos" != "Darwin" ; then
2106 roms="optionrom"
2108 echo "ROMS=$roms" >> $config_host_mak
2110 echo "prefix=$prefix" >> $config_host_mak
2111 echo "bindir=\${prefix}$binsuffix" >> $config_host_mak
2112 echo "mandir=\${prefix}$mansuffix" >> $config_host_mak
2113 echo "datadir=\${prefix}$datasuffix" >> $config_host_mak
2114 echo "docdir=\${prefix}$docsuffix" >> $config_host_mak
2115 echo "MAKE=$make" >> $config_host_mak
2116 echo "INSTALL=$install" >> $config_host_mak
2117 echo "INSTALL_DIR=$install -d -m0755 -p" >> $config_host_mak
2118 echo "INSTALL_DATA=$install -m0644 -p" >> $config_host_mak
2119 echo "INSTALL_PROG=$install -m0755 -p" >> $config_host_mak
2120 echo "CC=$cc" >> $config_host_mak
2121 echo "HOST_CC=$host_cc" >> $config_host_mak
2122 if test "$sparse" = "yes" ; then
2123 echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_host_mak
2124 echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_host_mak
2125 echo "QEMU_CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
2127 echo "AR=$ar" >> $config_host_mak
2128 echo "OBJCOPY=$objcopy" >> $config_host_mak
2129 echo "LD=$ld" >> $config_host_mak
2130 echo "CFLAGS=$CFLAGS" >> $config_host_mak
2131 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
2132 echo "HELPER_CFLAGS=$helper_cflags" >> $config_host_mak
2133 echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
2134 echo "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak
2135 echo "ARLIBS_END=$arlibs_end" >> $config_host_mak
2136 echo "LIBS+=$LIBS" >> $config_host_mak
2137 echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
2138 echo "EXESUF=$EXESUF" >> $config_host_mak
2140 echo "/* Automatically generated by configure - do not modify */" > $config_host_h
2142 /bin/sh $source_path/create_config < $config_host_mak >> $config_host_h
2144 if test -f ${config_host_h}~ ; then
2145 if cmp -s $config_host_h ${config_host_h}~ ; then
2146 mv ${config_host_h}~ $config_host_h
2147 else
2148 rm ${config_host_h}~
2152 # generate list of library paths for linker script
2154 $ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
2156 if test -f ${config_host_ld}~ ; then
2157 if cmp -s $config_host_ld ${config_host_ld}~ ; then
2158 mv ${config_host_ld}~ $config_host_ld
2159 else
2160 rm ${config_host_ld}~
2164 for target in $target_list; do
2165 target_dir="$target"
2166 config_mak=$target_dir/config.mak
2167 config_h=$target_dir/config.h
2168 target_arch2=`echo $target | cut -d '-' -f 1`
2169 target_bigendian="no"
2170 case "$target_arch2" in
2171 armeb|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|sh4eb|sparc|sparc64|sparc32plus)
2172 target_bigendian=yes
2174 esac
2175 target_softmmu="no"
2176 target_user_only="no"
2177 target_linux_user="no"
2178 target_darwin_user="no"
2179 target_bsd_user="no"
2180 case "$target" in
2181 ${target_arch2}-softmmu)
2182 target_softmmu="yes"
2184 ${target_arch2}-linux-user)
2185 target_user_only="yes"
2186 target_linux_user="yes"
2188 ${target_arch2}-darwin-user)
2189 target_user_only="yes"
2190 target_darwin_user="yes"
2192 ${target_arch2}-bsd-user)
2193 target_user_only="yes"
2194 target_bsd_user="yes"
2197 echo "ERROR: Target '$target' not recognised"
2198 exit 1
2200 esac
2202 #echo "Creating $config_mak, $config_h and $target_dir/Makefile"
2204 test -f $config_h && mv $config_h ${config_h}~
2206 mkdir -p $target_dir
2207 mkdir -p $target_dir/fpu
2208 mkdir -p $target_dir/tcg
2209 mkdir -p $target_dir/ide
2210 if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
2211 mkdir -p $target_dir/nwfpe
2215 # don't use ln -sf as not all "ln -sf" over write the file/link
2217 rm -f $target_dir/Makefile
2218 ln -s $source_path/Makefile.target $target_dir/Makefile
2221 echo "# Automatically generated by configure - do not modify" > $config_mak
2223 echo "include ../config-host.mak" >> $config_mak
2225 bflt="no"
2226 elfload32="no"
2227 target_nptl="no"
2228 interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
2229 echo "CONFIG_QEMU_PREFIX=\"$interp_prefix1\"" >> $config_mak
2230 gdb_xml_files=""
2232 disable_cpu_emulation() {
2233 if test $cpu_emulation = "no"; then
2234 echo "#define NO_CPU_EMULATION 1" >> $config_host_h
2235 echo "NO_CPU_EMULATION=1" >> $config_host_mak
2239 configure_kvm() {
2240 if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
2241 \( "$cpu" = "i386" -o "$cpu" = "x86_64" -o "$cpu" = "ia64" -o "$cpu" = "powerpc" \); then
2242 echo "CONFIG_KVM=y" >> $config_mak
2243 echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak
2244 if test $kvm_cap_pit = "yes" ; then
2245 echo "USE_KVM_PIT=1" >> $config_mak
2247 if test $kvm_cap_device_assignment = "yes" ; then
2248 echo "USE_KVM_DEVICE_ASSIGNMENT=1" >> $config_mak
2250 disable_cpu_emulation
2254 TARGET_ARCH="$target_arch2"
2255 TARGET_BASE_ARCH=""
2256 TARGET_ABI_DIR=""
2258 case "$target_arch2" in
2259 i386)
2260 target_phys_bits=32
2262 x86_64)
2263 TARGET_BASE_ARCH=i386
2264 target_phys_bits=64
2266 ia64)
2267 echo "TARGET_ARCH=ia64" >> $config_host_mak
2268 echo "#define TARGET_ARCH \"ia64\"" >> $config_host_h
2269 echo "#define TARGET_IA64 1" >> $config_host_h
2270 target_phys_bits=64
2272 alpha)
2273 target_phys_bits=64
2275 arm|armeb)
2276 TARGET_ARCH=arm
2277 bflt="yes"
2278 target_nptl="yes"
2279 gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
2280 target_phys_bits=32
2282 cris)
2283 target_nptl="yes"
2284 target_phys_bits=32
2286 m68k)
2287 bflt="yes"
2288 gdb_xml_files="cf-core.xml cf-fp.xml"
2289 target_phys_bits=32
2291 microblaze)
2292 bflt="yes"
2293 target_nptl="yes"
2294 target_phys_bits=32
2296 mips|mipsel)
2297 TARGET_ARCH=mips
2298 echo "TARGET_ABI_MIPSO32=y" >> $config_mak
2299 target_nptl="yes"
2300 target_phys_bits=64
2302 mipsn32|mipsn32el)
2303 TARGET_ARCH=mipsn32
2304 TARGET_BASE_ARCH=mips
2305 echo "TARGET_ABI_MIPSN32=y" >> $config_mak
2306 target_phys_bits=64
2308 mips64|mips64el)
2309 TARGET_ARCH=mips64
2310 TARGET_BASE_ARCH=mips
2311 echo "TARGET_ABI_MIPSN64=y" >> $config_mak
2312 target_phys_bits=64
2314 ppc)
2315 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2316 target_phys_bits=32
2317 target_nptl="yes"
2319 ppcemb)
2320 TARGET_BASE_ARCH=ppc
2321 TARGET_ABI_DIR=ppc
2322 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2323 target_phys_bits=64
2324 target_nptl="yes"
2326 ppc64)
2327 TARGET_BASE_ARCH=ppc
2328 TARGET_ABI_DIR=ppc
2329 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2330 target_phys_bits=64
2332 ppc64abi32)
2333 TARGET_ARCH=ppc64
2334 TARGET_BASE_ARCH=ppc
2335 TARGET_ABI_DIR=ppc
2336 echo "TARGET_ABI32=y" >> $config_mak
2337 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2338 target_phys_bits=64
2340 sh4|sh4eb)
2341 TARGET_ARCH=sh4
2342 bflt="yes"
2343 target_nptl="yes"
2344 target_phys_bits=32
2346 sparc)
2347 target_phys_bits=64
2349 sparc64)
2350 TARGET_BASE_ARCH=sparc
2351 elfload32="yes"
2352 target_phys_bits=64
2354 sparc32plus)
2355 TARGET_ARCH=sparc64
2356 TARGET_BASE_ARCH=sparc
2357 TARGET_ABI_DIR=sparc
2358 echo "TARGET_ABI32=y" >> $config_mak
2359 target_phys_bits=64
2362 echo "Unsupported target CPU"
2363 exit 1
2365 esac
2366 echo "TARGET_ARCH=$TARGET_ARCH" >> $config_mak
2367 target_arch_name="`echo $TARGET_ARCH | tr '[:lower:]' '[:upper:]'`"
2368 echo "TARGET_$target_arch_name=y" >> $config_mak
2369 echo "TARGET_ARCH2=$target_arch2" >> $config_mak
2370 # TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
2371 if [ "$TARGET_BASE_ARCH" = "" ]; then
2372 TARGET_BASE_ARCH=$TARGET_ARCH
2374 echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_mak
2375 if [ "$TARGET_ABI_DIR" = "" ]; then
2376 TARGET_ABI_DIR=$TARGET_ARCH
2378 echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_mak
2379 if [ $target_phys_bits -lt $hostlongbits ] ; then
2380 target_phys_bits=$hostlongbits
2382 case "$target_arch2" in
2383 i386|x86_64)
2384 if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
2385 echo "CONFIG_XEN=y" >> $config_mak
2387 esac
2388 case "$target_arch2" in
2389 i386|x86_64|ppcemb|ppc|ppc64)
2390 # Make sure the target and host cpus are compatible
2391 if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
2392 \( "$target_arch2" = "$cpu" -o \
2393 \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
2394 \( "$target_arch2" = "ppc64" -a "$cpu" = "ppc" \) -o \
2395 \( "$target_arch2" = "x86_64" -a "$cpu" = "i386" \) -o \
2396 \( "$target_arch2" = "i386" -a "$cpu" = "x86_64" \) \) ; then
2397 echo "CONFIG_KVM=y" >> $config_mak
2398 echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak
2399 configure_kvm
2401 esac
2402 echo "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_mak
2403 if test "$target_bigendian" = "yes" ; then
2404 echo "TARGET_WORDS_BIGENDIAN=y" >> $config_mak
2406 if test "$target_softmmu" = "yes" ; then
2407 echo "CONFIG_SOFTMMU=y" >> $config_mak
2408 echo "LIBS+=$libs_softmmu" >> $config_mak
2409 echo "HWLIB=../libhw$target_phys_bits/libqemuhw$target_phys_bits.a" >> $config_mak
2410 echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
2412 if test "$target_user_only" = "yes" ; then
2413 echo "CONFIG_USER_ONLY=y" >> $config_mak
2415 if test "$target_linux_user" = "yes" ; then
2416 echo "CONFIG_LINUX_USER=y" >> $config_mak
2418 if test "$target_darwin_user" = "yes" ; then
2419 echo "CONFIG_DARWIN_USER=y" >> $config_mak
2421 list=""
2422 if test ! -z "$gdb_xml_files" ; then
2423 for x in $gdb_xml_files; do
2424 list="$list $source_path/gdb-xml/$x"
2425 done
2427 echo "TARGET_XML_FILES=$list" >> $config_mak
2429 case "$target_arch2" in
2430 arm|armeb|m68k|microblaze|mips|mipsel|mipsn32|mipsn32el|mips64|mips64el|ppc|ppc64|ppc64abi32|ppcemb|sparc|sparc64|sparc32plus)
2431 echo "CONFIG_SOFTFLOAT=y" >> $config_mak
2434 echo "CONFIG_NOSOFTFLOAT=y" >> $config_mak
2436 esac
2438 if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
2439 echo "TARGET_HAS_BFLT=y" >> $config_mak
2441 if test "$target_user_only" = "yes" \
2442 -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
2443 echo "CONFIG_USE_NPTL=y" >> $config_mak
2445 # 32 bit ELF loader in addition to native 64 bit loader?
2446 if test "$target_user_only" = "yes" -a "$elfload32" = "yes"; then
2447 echo "TARGET_HAS_ELFLOAD32=y" >> $config_mak
2449 if test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
2450 echo "CONFIG_USE_GUEST_BASE=y" >> $config_mak
2452 if test "$target_bsd_user" = "yes" ; then
2453 echo "CONFIG_BSD_USER=y" >> $config_mak
2456 # generate QEMU_CFLAGS/LDFLAGS for targets
2458 cflags=""
2459 ldflags=""
2461 if test "$ARCH" = "sparc64" ; then
2462 cflags="-I\$(SRC_PATH)/tcg/sparc $cflags"
2463 else
2464 cflags="-I\$(SRC_PATH)/tcg/\$(ARCH) $cflags"
2466 cflags="-I\$(SRC_PATH)/tcg $cflags"
2467 cflags="-I\$(SRC_PATH)/fpu $cflags"
2469 for i in $ARCH $TARGET_BASE_ARCH ; do
2470 case "$i" in
2471 alpha)
2472 echo "CONFIG_ALPHA_DIS=y" >> $config_mak
2474 arm)
2475 echo "CONFIG_ARM_DIS=y" >> $config_mak
2477 cris)
2478 echo "CONFIG_CRIS_DIS=y" >> $config_mak
2480 hppa)
2481 echo "CONFIG_HPPA_DIS=y" >> $config_mak
2483 i386|x86_64)
2484 echo "CONFIG_I386_DIS=y" >> $config_mak
2486 m68k)
2487 echo "CONFIG_M68K_DIS=y" >> $config_mak
2489 microblaze)
2490 echo "CONFIG_MICROBLAZE_DIS=y" >> $config_mak
2492 mips*)
2493 echo "CONFIG_MIPS_DIS=y" >> $config_mak
2495 ppc*)
2496 echo "CONFIG_PPC_DIS=y" >> $config_mak
2498 s390)
2499 echo "CONFIG_S390_DIS=y" >> $config_mak
2501 sh4)
2502 echo "CONFIG_SH4_DIS=y" >> $config_mak
2504 sparc*)
2505 echo "CONFIG_SPARC_DIS=y" >> $config_mak
2507 esac
2508 done
2510 case "$ARCH" in
2511 alpha)
2512 # Ensure there's only a single GP
2513 cflags="-msmall-data $cflags"
2515 ia64)
2516 cflags="-mno-sdata $cflags"
2518 esac
2520 if test "$target_softmmu" = "yes" ; then
2521 case "$TARGET_BASE_ARCH" in
2522 arm)
2523 cflags="-DHAS_AUDIO $cflags"
2525 i386|mips|ppc)
2526 cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags"
2528 esac
2531 if test "$target_user_only" = "yes" -a "$static" = "no" -a \
2532 "$user_pie" = "yes" ; then
2533 cflags="-fpie $cflags"
2534 ldflags="-pie $ldflags"
2537 if test "$target_softmmu" = "yes" -a \( \
2538 "$TARGET_ARCH" = "microblaze" -o \
2539 "$TARGET_ARCH" = "cris" \) ; then
2540 echo "CONFIG_NEED_MMU=y" >> $config_mak
2543 if test "$gprof" = "yes" ; then
2544 echo "TARGET_GPROF=yes" >> $config_mak
2545 if test "$target_linux_user" = "yes" ; then
2546 cflags="-p $cflags"
2547 ldflags="-p $ldflags"
2549 if test "$target_softmmu" = "yes" ; then
2550 ldflags="-p $ldflags"
2551 echo "GPROF_CFLAGS=-p" >> $config_mak
2555 linker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/\$(ARCH).ld"
2556 if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
2557 case "$ARCH" in
2558 sparc)
2559 # -static is used to avoid g1/g3 usage by the dynamic linker
2560 ldflags="$linker_script -static $ldflags"
2562 ia64)
2563 ldflags="-Wl,-G0 $linker_script -static $ldflags"
2565 i386|x86_64|ppc|ppc64|s390|sparc64|alpha|arm|m68k|mips|mips64)
2566 ldflags="$linker_script $ldflags"
2568 esac
2570 if test "$target_softmmu" = "yes" ; then
2571 case "$ARCH" in
2572 ia64)
2573 ldflags="-Wl,-G0 $linker_script -static $ldflags"
2575 esac
2578 echo "LDFLAGS+=$ldflags" >> $config_mak
2579 echo "QEMU_CFLAGS+=$cflags" >> $config_mak
2581 echo "/* Automatically generated by configure - do not modify */" > $config_h
2582 echo "#include \"../config-host.h\"" >> $config_h
2584 /bin/sh $source_path/create_config < $config_mak >> $config_h
2586 if test -f ${config_h}~ ; then
2587 if cmp -s $config_h ${config_h}~ ; then
2588 mv ${config_h}~ $config_h
2589 else
2590 rm ${config_h}~
2594 done # for target in $targets
2596 # build tree in object directory if source path is different from current one
2597 if test "$source_path_used" = "yes" ; then
2598 DIRS="tests tests/cris slirp audio block pc-bios/optionrom"
2599 DIRS="$DIRS roms/pcbios roms/seabios roms/vgabios"
2600 FILES="Makefile tests/Makefile"
2601 FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
2602 FILES="$FILES tests/test-mmap.c"
2603 FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps pc-bios/video.x"
2604 FILES="$FILES roms/pcbios/Makefile roms/seabios/Makefile roms/vgabios/Makefile"
2605 for bios_file in $source_path/pc-bios/*.bin $source_path/pc-bios/*.dtb $source_path/pc-bios/openbios-*; do
2606 FILES="$FILES pc-bios/`basename $bios_file`"
2607 done
2608 for dir in $DIRS ; do
2609 mkdir -p $dir
2610 done
2611 # remove the link and recreate it, as not all "ln -sf" overwrite the link
2612 for f in $FILES ; do
2613 rm -f $f
2614 ln -s $source_path/$f $f
2615 done
2618 # temporary config to build submodules
2619 for rom in seabios vgabios pcbios; do
2620 config_mak=roms/$rom/config.mak
2621 echo "# Automatically generated by configure - do not modify" >> $config_mak
2622 echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
2623 echo "CC=$cc" >> $config_mak
2624 echo "BCC=bcc" >> $config_mak
2625 echo "CPP=${cross_prefix}cpp" >> $config_mak
2626 echo "OBJCOPY=objcopy" >> $config_mak
2627 echo "IASL=iasl" >> $config_mak
2628 echo "HOST_CC=$host_cc" >> $config_mak
2629 echo "LD=$ld" >> $config_mak
2630 done
2632 for hwlib in 32 64; do
2633 d=libhw$hwlib
2634 mkdir -p $d
2635 rm -f $d/Makefile
2636 ln -s $source_path/Makefile.hw $d/Makefile
2637 echo "HWLIB=libqemuhw$hwlib.a" > $d/config.mak
2638 echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" >> $d/config.mak
2639 done