Merge commit '1a03675db146dfc760b3b48b3448075189f142cc' into upstream-merge
[qemu/qemu-dev-zwu.git] / configure
blobb851c45c835a9fdbb1cf45b691065969ed8e469a
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}.exe"
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 block_drv_whitelist=""
42 host_cc="gcc"
43 ar="ar"
44 make="make"
45 install="install"
46 objcopy="objcopy"
47 ld="ld"
48 helper_cflags=""
49 libs_softmmu=""
50 libs_tools=""
51 audio_pt_int=""
52 audio_win_int=""
54 # parse CC options first
55 for opt do
56 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
57 case "$opt" in
58 --cross-prefix=*) cross_prefix="$optarg"
60 --cc=*) cc="$optarg"
62 --cpu=*) cpu="$optarg"
64 --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
66 --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
68 --sparc_cpu=*)
69 sparc_cpu="$optarg"
70 case $sparc_cpu in
71 v7|v8|v8plus|v8plusa)
72 cpu="sparc"
74 v9)
75 cpu="sparc64"
78 echo "undefined SPARC architecture. Exiting";
79 exit 1
81 esac
83 esac
84 done
85 # OS specific
86 # Using uname is really, really broken. Once we have the right set of checks
87 # we can eliminate it's usage altogether
89 cc="${cross_prefix}${cc}"
90 ar="${cross_prefix}${ar}"
91 objcopy="${cross_prefix}${objcopy}"
92 ld="${cross_prefix}${ld}"
94 # default flags for all hosts
95 QEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
96 CFLAGS="-g $CFLAGS"
97 QEMU_CFLAGS="-Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
98 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
99 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
100 QEMU_CFLAGS="-U_FORTIFY_SOURCE $QEMU_CFLAGS"
101 QEMU_CFLAGS="-I. -I\$(SRC_PATH) $QEMU_CFLAGS"
102 LDFLAGS="-g $LDFLAGS"
104 gcc_flags="-Wold-style-declaration -Wold-style-definition"
105 cat > $TMPC << EOF
106 int main(void) { }
108 for flag in $gcc_flags; do
109 if compile_prog "$QEMU_CFLAGS" "$flag" ; then
110 QEMU_CFLAGS="$flag $QEMU_CFLAGS"
112 done
114 # check that the C compiler works.
115 cat > $TMPC <<EOF
116 int main(void) {}
119 if compile_object ; then
120 : C compiler works ok
121 else
122 echo "ERROR: \"$cc\" either does not exist or does not work"
123 exit 1
126 check_define() {
127 cat > $TMPC <<EOF
128 #if !defined($1)
129 #error Not defined
130 #endif
131 int main(void) { return 0; }
133 compile_object
136 if test ! -z "$cpu" ; then
137 # command line argument
139 elif check_define __i386__ ; then
140 cpu="i386"
141 elif check_define __x86_64__ ; then
142 cpu="x86_64"
143 elif check_define __sparc__ ; then
144 # We can't check for 64 bit (when gcc is biarch) or V8PLUSA
145 # They must be specified using --sparc_cpu
146 if check_define __arch64__ ; then
147 cpu="sparc64"
148 else
149 cpu="sparc"
151 elif check_define _ARCH_PPC ; then
152 if check_define _ARCH_PPC64 ; then
153 cpu="ppc64"
154 else
155 cpu="ppc"
157 elif check_define __mips__ ; then
158 cpu="mips"
159 else
160 cpu=`uname -m`
163 target_list="x86_64-softmmu"
164 case "$cpu" in
165 alpha|cris|ia64|m68k|microblaze|ppc|ppc64|sparc64)
166 cpu="$cpu"
168 i386|i486|i586|i686|i86pc|BePC)
169 cpu="i386"
171 x86_64|amd64)
172 cpu="x86_64"
174 armv*b)
175 cpu="armv4b"
177 armv*l)
178 cpu="armv4l"
180 parisc|parisc64)
181 cpu="hppa"
183 mips*)
184 cpu="mips"
186 s390)
187 cpu="s390"
189 s390x)
190 cpu="s390x"
192 sparc|sun4[cdmuv])
193 cpu="sparc"
196 cpu="unknown"
198 esac
200 kvm_version() {
201 local fname="$(dirname "$0")/KVM_VERSION"
203 if test -f "$fname"; then
204 cat "$fname"
205 else
206 echo "qemu-kvm-devel"
210 # Default value for a variable defining feature "foo".
211 # * foo="no" feature will only be used if --enable-foo arg is given
212 # * foo="" feature will be searched for, and if found, will be used
213 # unless --disable-foo is given
214 # * foo="yes" this value will only be set by --enable-foo flag.
215 # feature will searched for,
216 # if not found, configure exits with error
218 # Always add --enable-foo and --disable-foo command line args.
219 # Distributions want to ensure that several features are compiled in, and it
220 # is impossible without a --enable-foo that exits if a feature is not found.
222 bluez=""
223 brlapi=""
224 curl=""
225 curses=""
226 docs=""
227 fdt=""
228 kvm=""
229 nptl=""
230 sdl=""
231 sparse="no"
232 uuid=""
233 vde=""
234 vnc_tls=""
235 vnc_sasl=""
236 xen=""
237 linux_aio=""
239 gprof="no"
240 debug_tcg="no"
241 debug="no"
242 strip_opt="yes"
243 bigendian="no"
244 mingw32="no"
245 EXESUF=""
246 slirp="yes"
247 fmod_lib=""
248 fmod_inc=""
249 oss_lib=""
250 bsd="no"
251 linux="no"
252 solaris="no"
253 profiler="no"
254 cocoa="no"
255 softmmu="yes"
256 linux_user="no"
257 darwin_user="no"
258 bsd_user="no"
259 guest_base=""
260 uname_release=""
261 io_thread="no"
262 mixemu="no"
263 kvm_trace="no"
264 kvm_cap_pit=""
265 kvm_cap_device_assignment=""
266 kerneldir=""
267 aix="no"
268 blobs="yes"
269 pkgversion=" ($(kvm_version))"
270 cpu_emulation="yes"
271 kvm_kmod="no"
272 check_utests="no"
273 user_pie="no"
274 zero_malloc=""
276 # OS specific
277 if check_define __linux__ ; then
278 targetos="Linux"
279 elif check_define _WIN32 ; then
280 targetos='MINGW32'
281 elif check_define __OpenBSD__ ; then
282 targetos='OpenBSD'
283 elif check_define __sun__ ; then
284 targetos='SunOS'
285 else
286 targetos=`uname -s`
289 case $targetos in
290 CYGWIN*)
291 mingw32="yes"
292 QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
293 audio_possible_drivers="winwave sdl"
294 audio_drv_list="winwave"
296 MINGW32*)
297 mingw32="yes"
298 audio_possible_drivers="winwave dsound sdl fmod"
299 audio_drv_list="winwave"
301 GNU/kFreeBSD)
302 bsd="yes"
303 audio_drv_list="oss"
304 audio_possible_drivers="oss sdl esd pa"
306 FreeBSD)
307 bsd="yes"
308 make="gmake"
309 audio_drv_list="oss"
310 audio_possible_drivers="oss sdl esd pa"
312 DragonFly)
313 bsd="yes"
314 make="gmake"
315 audio_drv_list="oss"
316 audio_possible_drivers="oss sdl esd pa"
318 NetBSD)
319 bsd="yes"
320 make="gmake"
321 audio_drv_list="oss"
322 audio_possible_drivers="oss sdl esd"
323 oss_lib="-lossaudio"
325 OpenBSD)
326 bsd="yes"
327 make="gmake"
328 audio_drv_list="oss"
329 audio_possible_drivers="oss sdl esd"
330 oss_lib="-lossaudio"
332 Darwin)
333 bsd="yes"
334 darwin="yes"
335 # on Leopard most of the system is 32-bit, so we have to ask the kernel it if we can
336 # run 64-bit userspace code
337 if [ "$cpu" = "i386" ] ; then
338 is_x86_64=`sysctl -n hw.optional.x86_64`
339 [ "$is_x86_64" = "1" ] && cpu=x86_64
341 if [ "$cpu" = "x86_64" ] ; then
342 QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
343 LDFLAGS="-arch x86_64 $LDFLAGS"
344 else
345 QEMU_CFLAGS="-mdynamic-no-pic $QEMU_CFLAGS"
347 darwin_user="yes"
348 cocoa="yes"
349 audio_drv_list="coreaudio"
350 audio_possible_drivers="coreaudio sdl fmod"
351 LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
352 libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
354 SunOS)
355 solaris="yes"
356 make="gmake"
357 install="ginstall"
358 ld="gld"
359 needs_libsunmath="no"
360 solarisrev=`uname -r | cut -f2 -d.`
361 # have to select again, because `uname -m` returns i86pc
362 # even on an x86_64 box.
363 solariscpu=`isainfo -k`
364 if test "${solariscpu}" = "amd64" ; then
365 cpu="x86_64"
367 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
368 if test "$solarisrev" -le 9 ; then
369 if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
370 needs_libsunmath="yes"
371 QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
372 LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
373 LIBS="-lsunmath $LIBS"
374 else
375 echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
376 echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
377 echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
378 echo "Studio 11 can be downloaded from www.sun.com."
379 exit 1
383 if test -f /usr/include/sys/soundcard.h ; then
384 audio_drv_list="oss"
386 audio_possible_drivers="oss sdl"
387 # needed for CMSG_ macros in sys/socket.h
388 QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
389 # needed for TIOCWIN* defines in termios.h
390 QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
391 QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
392 LIBS="-lsocket -lnsl -lresolv $LIBS"
394 AIX)
395 aix="yes"
396 make="gmake"
399 audio_drv_list="oss"
400 audio_possible_drivers="oss alsa sdl esd pa"
401 linux="yes"
402 linux_user="yes"
403 usb="linux"
404 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
405 audio_possible_drivers="$audio_possible_drivers fmod"
407 if [ "$cpu" = "ia64" ] ; then
408 xen="no"
409 target_list="ia64-softmmu"
410 cpu_emulation="no"
411 gdbstub="no"
412 slirp="no"
415 esac
417 if [ "$bsd" = "yes" ] ; then
418 if [ "$darwin" != "yes" ] ; then
419 usb="bsd"
421 bsd_user="yes"
424 if test "$mingw32" = "yes" ; then
425 EXESUF=".exe"
426 QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
427 LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
430 # find source path
431 source_path=`dirname "$0"`
432 source_path_used="no"
433 workdir=`pwd`
434 if [ -z "$source_path" ]; then
435 source_path=$workdir
436 else
437 source_path=`cd "$source_path"; pwd`
439 [ -f "$workdir/vl.c" ] || source_path_used="yes"
441 werror=""
443 for opt do
444 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
445 case "$opt" in
446 --help|-h) show_help=yes
448 --prefix=*) prefix="$optarg"
450 --interp-prefix=*) interp_prefix="$optarg"
452 --source-path=*) source_path="$optarg"
453 source_path_used="yes"
455 --cross-prefix=*)
457 --cc=*)
459 --host-cc=*) host_cc="$optarg"
461 --make=*) make="$optarg"
463 --install=*) install="$optarg"
465 --extra-cflags=*)
467 --extra-ldflags=*)
469 --cpu=*)
471 --target-list=*) target_list="$optarg"
473 --enable-gprof) gprof="yes"
475 --static) static="yes"
477 --disable-sdl) sdl="no"
479 --enable-sdl) sdl="yes"
481 --fmod-lib=*) fmod_lib="$optarg"
483 --fmod-inc=*) fmod_inc="$optarg"
485 --oss-lib=*) oss_lib="$optarg"
487 --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
489 --audio-drv-list=*) audio_drv_list="$optarg"
491 --block-drv-whitelist=*) block_drv_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
493 --enable-debug-tcg) debug_tcg="yes"
495 --disable-debug-tcg) debug_tcg="no"
497 --enable-debug)
498 # Enable debugging options that aren't excessively noisy
499 debug_tcg="yes"
500 debug="yes"
501 strip_opt="no"
503 --enable-sparse) sparse="yes"
505 --disable-sparse) sparse="no"
507 --disable-strip) strip_opt="no"
509 --disable-vnc-tls) vnc_tls="no"
511 --enable-vnc-tls) vnc_tls="yes"
513 --disable-vnc-sasl) vnc_sasl="no"
515 --enable-vnc-sasl) vnc_sasl="yes"
517 --disable-slirp) slirp="no"
519 --disable-uuid) uuid="no"
521 --enable-uuid) uuid="yes"
523 --disable-vde) vde="no"
525 --enable-vde) vde="yes"
527 --disable-xen) xen="no"
529 --enable-xen) xen="yes"
531 --disable-brlapi) brlapi="no"
533 --enable-brlapi) brlapi="yes"
535 --disable-bluez) bluez="no"
537 --enable-bluez) bluez="yes"
539 --disable-kvm) kvm="no"
541 --enable-kvm) kvm="yes"
543 --disable-kvm-cap-pit) kvm_cap_pit="no"
545 --enable-kvm-cap-pit) kvm_cap_pit="yes"
547 --disable-kvm-cap-device-assignment) kvm_cap_device_assignment="no"
549 --enable-kvm-cap-device-assignment) kvm_cap_device_assignment="yes"
551 --enable-profiler) profiler="yes"
553 --enable-cocoa)
554 cocoa="yes" ;
555 sdl="no" ;
556 audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
558 --disable-system) softmmu="no"
560 --enable-system) softmmu="yes"
562 --disable-user)
563 linux_user="no" ;
564 bsd_user="no" ;
565 darwin_user="no"
567 --enable-user) ;;
568 --disable-linux-user) linux_user="no"
570 --enable-linux-user) linux_user="yes"
572 --disable-darwin-user) darwin_user="no"
574 --enable-darwin-user) darwin_user="yes"
576 --disable-bsd-user) bsd_user="no"
578 --enable-bsd-user) bsd_user="yes"
580 --enable-guest-base) guest_base="yes"
582 --disable-guest-base) guest_base="no"
584 --enable-user-pie) user_pie="yes"
586 --disable-user-pie) user_pie="no"
588 --enable-uname-release=*) uname_release="$optarg"
590 --sparc_cpu=*)
592 --enable-werror) werror="yes"
594 --disable-werror) werror="no"
596 --disable-curses) curses="no"
598 --enable-curses) curses="yes"
600 --disable-curl) curl="no"
602 --enable-curl) curl="yes"
604 --disable-fdt) fdt="no"
606 --enable-fdt) fdt="yes"
608 --disable-check-utests) check_utests="no"
610 --enable-check-utests) check_utests="yes"
612 --disable-nptl) nptl="no"
614 --enable-nptl) nptl="yes"
616 --enable-mixemu) mixemu="yes"
618 --disable-linux-aio) linux_aio="no"
620 --enable-linux-aio) linux_aio="yes"
622 --enable-io-thread) io_thread="yes"
624 --disable-blobs) blobs="no"
626 --kerneldir=*) kerneldir="$optarg"
628 --with-kvm-trace) kvm_trace="yes"
630 --with-pkgversion=*) pkgversion=" ($optarg)"
632 --disable-docs) docs="no"
634 --enable-docs) docs="yes"
636 --disable-cpu-emulation) cpu_emulation="no"
638 *) echo "ERROR: unknown option $opt"; show_help="yes"
640 esac
641 done
644 # If cpu ~= sparc and sparc_cpu hasn't been defined, plug in the right
645 # QEMU_CFLAGS/LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
647 host_guest_base="no"
648 case "$cpu" in
649 sparc) case $sparc_cpu in
650 v7|v8)
651 QEMU_CFLAGS="-mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
653 v8plus|v8plusa)
654 QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
656 *) # sparc_cpu not defined in the command line
657 QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_v8plus__ $QEMU_CFLAGS"
658 esac
659 LDFLAGS="-m32 $LDFLAGS"
660 QEMU_CFLAGS="-m32 -ffixed-g2 -ffixed-g3 $QEMU_CFLAGS"
661 if test "$solaris" = "no" ; then
662 QEMU_CFLAGS="-ffixed-g1 -ffixed-g6 $QEMU_CFLAGS"
663 helper_cflags="-ffixed-i0"
666 sparc64)
667 QEMU_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__ $QEMU_CFLAGS"
668 LDFLAGS="-m64 $LDFLAGS"
669 QEMU_CFLAGS="-ffixed-g5 -ffixed-g6 -ffixed-g7 $QEMU_CFLAGS"
670 if test "$solaris" != "no" ; then
671 QEMU_CFLAGS="-ffixed-g1 $QEMU_CFLAGS"
674 s390)
675 QEMU_CFLAGS="-march=z900 $QEMU_CFLAGS"
677 i386)
678 QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
679 LDFLAGS="-m32 $LDFLAGS"
680 helper_cflags="-fomit-frame-pointer"
681 host_guest_base="yes"
683 x86_64)
684 QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
685 LDFLAGS="-m64 $LDFLAGS"
686 host_guest_base="yes"
688 arm*)
689 host_guest_base="yes"
691 ppc*)
692 host_guest_base="yes"
694 esac
696 [ -z "$guest_base" ] && guest_base="$host_guest_base"
698 if test x"$show_help" = x"yes" ; then
699 cat << EOF
701 Usage: configure [options]
702 Options: [defaults in brackets after descriptions]
705 echo "Standard options:"
706 echo " --help print this message"
707 echo " --prefix=PREFIX install in PREFIX [$prefix]"
708 echo " --interp-prefix=PREFIX where to find shared libraries, etc."
709 echo " use %M for cpu name [$interp_prefix]"
710 echo " --target-list=LIST set target list [$target_list]"
711 echo ""
712 echo "Advanced options (experts only):"
713 echo " --source-path=PATH path of source code [$source_path]"
714 echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
715 echo " --cc=CC use C compiler CC [$cc]"
716 echo " --host-cc=CC use C compiler CC [$host_cc] for dyngen etc."
717 echo " --extra-cflags=CFLAGS append extra C compiler flags QEMU_CFLAGS"
718 echo " --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS"
719 echo " --make=MAKE use specified make [$make]"
720 echo " --install=INSTALL use specified install [$install]"
721 echo " --static enable static build [$static]"
722 echo " --enable-debug-tcg enable TCG debugging"
723 echo " --disable-debug-tcg disable TCG debugging (default)"
724 echo " --enable-debug enable common debug build options"
725 echo " --enable-sparse enable sparse checker"
726 echo " --disable-sparse disable sparse checker (default)"
727 echo " --disable-strip disable stripping binaries"
728 echo " --disable-werror disable compilation abort on warning"
729 echo " --disable-sdl disable SDL"
730 echo " --enable-sdl enable SDL"
731 echo " --enable-cocoa enable COCOA (Mac OS X only)"
732 echo " --audio-drv-list=LIST set audio drivers list:"
733 echo " Available drivers: $audio_possible_drivers"
734 echo " --audio-card-list=LIST set list of emulated audio cards [$audio_card_list]"
735 echo " Available cards: $audio_possible_cards"
736 echo " --block-drv-whitelist=L set block driver whitelist"
737 echo " (affects only QEMU, not qemu-img)"
738 echo " --enable-mixemu enable mixer emulation"
739 echo " --disable-xen disable xen backend driver support"
740 echo " --enable-xen enable xen backend driver support"
741 echo " --disable-brlapi disable BrlAPI"
742 echo " --enable-brlapi enable BrlAPI"
743 echo " --disable-vnc-tls disable TLS encryption for VNC server"
744 echo " --enable-vnc-tls enable TLS encryption for VNC server"
745 echo " --disable-vnc-sasl disable SASL encryption for VNC server"
746 echo " --enable-vnc-sasl enable SASL encryption for VNC server"
747 echo " --disable-curses disable curses output"
748 echo " --enable-curses enable curses output"
749 echo " --disable-curl disable curl connectivity"
750 echo " --enable-curl enable curl connectivity"
751 echo " --disable-fdt disable fdt device tree"
752 echo " --enable-fdt enable fdt device tree"
753 echo " --disable-check-utests disable check unit-tests"
754 echo " --enable-check-utests enable check unit-tests"
755 echo " --disable-bluez disable bluez stack connectivity"
756 echo " --enable-bluez enable bluez stack connectivity"
757 echo " --disable-kvm disable KVM acceleration support"
758 echo " --enable-kvm enable KVM acceleration support"
759 echo " --disable-cap-kvm-pit disable KVM pit support"
760 echo " --enable-cap-kvm-pit enable KVM pit support"
761 echo " --disable-cap-device-assignment disable KVM device assignment support"
762 echo " --enable-cap-device-assignment enable KVM device assignment support"
763 echo " --disable-nptl disable usermode NPTL support"
764 echo " --enable-nptl enable usermode NPTL support"
765 echo " --enable-system enable all system emulation targets"
766 echo " --disable-system disable all system emulation targets"
767 echo " --enable-user enable supported user emulation targets"
768 echo " --disable-user disable all user emulation targets"
769 echo " --enable-linux-user enable all linux usermode emulation targets"
770 echo " --disable-linux-user disable all linux usermode emulation targets"
771 echo " --enable-darwin-user enable all darwin usermode emulation targets"
772 echo " --disable-darwin-user disable all darwin usermode emulation targets"
773 echo " --enable-bsd-user enable all BSD usermode emulation targets"
774 echo " --disable-bsd-user disable all BSD usermode emulation targets"
775 echo " --enable-guest-base enable GUEST_BASE support for usermode"
776 echo " emulation targets"
777 echo " --disable-guest-base disable GUEST_BASE support"
778 echo " --enable-user-pie build usermode emulation targets as PIE"
779 echo " --disable-user-pie do not build usermode emulation targets as PIE"
780 echo " --fmod-lib path to FMOD library"
781 echo " --fmod-inc path to FMOD includes"
782 echo " --oss-lib path to OSS library"
783 echo " --enable-uname-release=R Return R for uname -r in usermode emulation"
784 echo " --sparc_cpu=V Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
785 echo " --disable-uuid disable uuid support"
786 echo " --enable-uuid enable uuid support"
787 echo " --disable-vde disable support for vde network"
788 echo " --enable-vde enable support for vde network"
789 echo " --disable-linux-aio disable Linux AIO support"
790 echo " --enable-linux-aio enable Linux AIO support"
791 echo " --enable-io-thread enable IO thread"
792 echo " --disable-blobs disable installing provided firmware blobs"
793 echo " --kerneldir=PATH look for kernel includes in PATH"
794 echo " --with-kvm-trace enable building the KVM module with the kvm trace option"
795 echo " --disable-cpu-emulation disables use of qemu cpu emulation code"
796 echo ""
797 echo "NOTE: The object files are built at the place where configure is launched"
798 exit 1
802 # Solaris specific configure tool chain decisions
804 if test "$solaris" = "yes" ; then
805 solinst=`which $install 2> /dev/null | /usr/bin/grep -v "no $install in"`
806 if test -z "$solinst" ; then
807 echo "Solaris install program not found. Use --install=/usr/ucb/install or"
808 echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
809 echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
810 exit 1
812 if test "$solinst" = "/usr/sbin/install" ; then
813 echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
814 echo "try ginstall from the GNU fileutils available from www.blastwave.org"
815 echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
816 exit 1
818 sol_ar=`which ar 2> /dev/null | /usr/bin/grep -v "no ar in"`
819 if test -z "$sol_ar" ; then
820 echo "Error: No path includes ar"
821 if test -f /usr/ccs/bin/ar ; then
822 echo "Add /usr/ccs/bin to your path and rerun configure"
824 exit 1
829 if test -z "$target_list" ; then
830 # these targets are portable
831 if [ "$softmmu" = "yes" ] ; then
832 target_list="\
833 i386-softmmu \
834 x86_64-softmmu \
835 arm-softmmu \
836 cris-softmmu \
837 m68k-softmmu \
838 microblaze-softmmu \
839 mips-softmmu \
840 mipsel-softmmu \
841 mips64-softmmu \
842 mips64el-softmmu \
843 ppc-softmmu \
844 ppcemb-softmmu \
845 ppc64-softmmu \
846 sh4-softmmu \
847 sh4eb-softmmu \
848 sparc-softmmu \
849 sparc64-softmmu \
852 # the following are Linux specific
853 if [ "$linux_user" = "yes" ] ; then
854 target_list="${target_list}\
855 i386-linux-user \
856 x86_64-linux-user \
857 alpha-linux-user \
858 arm-linux-user \
859 armeb-linux-user \
860 cris-linux-user \
861 m68k-linux-user \
862 microblaze-linux-user \
863 mips-linux-user \
864 mipsel-linux-user \
865 ppc-linux-user \
866 ppc64-linux-user \
867 ppc64abi32-linux-user \
868 sh4-linux-user \
869 sh4eb-linux-user \
870 sparc-linux-user \
871 sparc64-linux-user \
872 sparc32plus-linux-user \
875 # the following are Darwin specific
876 if [ "$darwin_user" = "yes" ] ; then
877 target_list="$target_list i386-darwin-user ppc-darwin-user "
879 # the following are BSD specific
880 if [ "$bsd_user" = "yes" ] ; then
881 target_list="${target_list}\
882 i386-bsd-user \
883 x86_64-bsd-user \
884 sparc-bsd-user \
885 sparc64-bsd-user \
888 else
889 target_list=`echo "$target_list" | sed -e 's/,/ /g'`
891 if test -z "$target_list" ; then
892 echo "No targets enabled"
893 exit 1
896 feature_not_found() {
897 feature=$1
899 echo "ERROR"
900 echo "ERROR: User requested feature $feature"
901 echo "ERROR: configure was not able to find it"
902 echo "ERROR"
903 exit 1;
906 if test -z "$cross_prefix" ; then
908 # ---
909 # big/little endian test
910 cat > $TMPC << EOF
911 #include <inttypes.h>
912 int main(int argc, char ** argv){
913 volatile uint32_t i=0x01234567;
914 return (*((uint8_t*)(&i))) == 0x67;
918 if compile_prog "" "" ; then
919 $TMPE && bigendian="yes"
920 else
921 echo big/little test failed
924 else
926 # if cross compiling, cannot launch a program, so make a static guess
927 case "$cpu" in
928 armv4b|hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
929 bigendian=yes
931 esac
935 # host long bits test
936 hostlongbits="32"
937 case "$cpu" in
938 x86_64|alpha|ia64|sparc64|ppc64|s390x)
939 hostlongbits=64
941 esac
944 ##########################################
945 # NPTL probe
947 if test "$nptl" != "no" ; then
948 cat > $TMPC <<EOF
949 #include <sched.h>
950 #include <linux/futex.h>
951 void foo()
953 #if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
954 #error bork
955 #endif
959 if compile_object ; then
960 nptl=yes
961 else
962 if test "$nptl" = "yes" ; then
963 feature_not_found "nptl"
965 nptl=no
969 ##########################################
970 # zlib check
972 cat > $TMPC << EOF
973 #include <zlib.h>
974 int main(void) { zlibVersion(); return 0; }
976 if compile_prog "" "-lz" ; then
978 else
979 echo
980 echo "Error: zlib check failed"
981 echo "Make sure to have the zlib libs and headers installed."
982 echo
983 exit 1
986 ##########################################
987 # xen probe
989 if test "$xen" != "no" ; then
990 xen_libs="-lxenstore -lxenctrl -lxenguest"
991 cat > $TMPC <<EOF
992 #include <xenctrl.h>
993 #include <xs.h>
994 int main(void) { xs_daemon_open(); xc_interface_open(); return 0; }
996 if compile_prog "" "$xen_libs" ; then
997 xen=yes
998 libs_softmmu="$xen_libs $libs_softmmu"
999 else
1000 if test "$xen" = "yes" ; then
1001 feature_not_found "xen"
1003 xen=no
1007 ##########################################
1008 # Sparse probe
1009 if test "$sparse" != "no" ; then
1010 if test -x "$(which cgcc 2>/dev/null)"; then
1011 sparse=yes
1012 else
1013 if test "$sparse" = "yes" ; then
1014 feature_not_found "sparse"
1016 sparse=no
1020 ##########################################
1021 # SDL probe
1023 sdl_too_old=no
1025 if test "$sdl" != "no" ; then
1026 cat > $TMPC << EOF
1027 #include <SDL.h>
1028 #undef main /* We don't want SDL to override our main() */
1029 int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
1031 sdl_cflags=`sdl-config --cflags 2> /dev/null`
1032 sdl_libs=`sdl-config --libs 2> /dev/null`
1033 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1034 _sdlversion=`sdl-config --version | sed 's/[^0-9]//g'`
1035 if test "$_sdlversion" -lt 121 ; then
1036 sdl_too_old=yes
1037 else
1038 if test "$cocoa" = "no" ; then
1039 sdl=yes
1043 # static link with sdl ?
1044 if test "$sdl" = "yes" -a "$static" = "yes" ; then
1045 sdl_libs=`sdl-config --static-libs 2>/dev/null`
1046 if test `sdl-config --static-libs 2>/dev/null | grep \\\-laa > /dev/null` ; then
1047 sdl_libs="$sdl_libs `aalib-config --static-libs >2 /dev/null`"
1048 sdl_cflags="$sd_cflags `aalib-config --cflags >2 /dev/null`"
1050 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1052 else
1053 sdl=no
1055 fi # static link
1056 else # sdl not found
1057 if test "$sdl" = "yes" ; then
1058 feature_not_found "sdl"
1060 sdl=no
1061 fi # sdl compile test
1064 if test "$sdl" = "yes" ; then
1065 cat > $TMPC <<EOF
1066 #include <SDL.h>
1067 #if defined(SDL_VIDEO_DRIVER_X11)
1068 #include <X11/XKBlib.h>
1069 #else
1070 #error No x11 support
1071 #endif
1072 int main(void) { return 0; }
1074 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1075 sdl_libs="$sdl_libs -lX11"
1077 if test "$mingw32" = "yes" ; then
1078 sdl_libs="`echo $sdl_libs | sed s/-mwindows//g` -mconsole"
1080 libs_softmmu="$sdl_libs $libs_softmmu"
1083 ##########################################
1084 # VNC TLS detection
1085 if test "$vnc_tls" != "no" ; then
1086 cat > $TMPC <<EOF
1087 #include <gnutls/gnutls.h>
1088 int main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
1090 vnc_tls_cflags=`pkg-config --cflags gnutls 2> /dev/null`
1091 vnc_tls_libs=`pkg-config --libs gnutls 2> /dev/null`
1092 if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
1093 vnc_tls=yes
1094 libs_softmmu="$vnc_tls_libs $libs_softmmu"
1095 else
1096 if test "$vnc_tls" = "yes" ; then
1097 feature_not_found "vnc-tls"
1099 vnc_tls=no
1103 ##########################################
1104 # VNC SASL detection
1105 if test "$vnc_sasl" != "no" ; then
1106 cat > $TMPC <<EOF
1107 #include <sasl/sasl.h>
1108 #include <stdio.h>
1109 int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
1111 # Assuming Cyrus-SASL installed in /usr prefix
1112 vnc_sasl_cflags=""
1113 vnc_sasl_libs="-lsasl2"
1114 if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1115 vnc_sasl=yes
1116 libs_softmmu="$vnc_sasl_libs $libs_softmmu"
1117 else
1118 if test "$vnc_sasl" = "yes" ; then
1119 feature_not_found "vnc-sasl"
1121 vnc_sasl=no
1125 ##########################################
1126 # fnmatch() probe, used for ACL routines
1127 fnmatch="no"
1128 cat > $TMPC << EOF
1129 #include <fnmatch.h>
1130 int main(void)
1132 fnmatch("foo", "foo", 0);
1133 return 0;
1136 if compile_prog "" "" ; then
1137 fnmatch="yes"
1140 ##########################################
1141 # uuid_generate() probe, used for vdi block driver
1142 if test "$uuid" != "no" ; then
1143 uuid_libs="-luuid"
1144 cat > $TMPC << EOF
1145 #include <uuid/uuid.h>
1146 int main(void)
1148 uuid_t my_uuid;
1149 uuid_generate(my_uuid);
1150 return 0;
1153 if compile_prog "" "$uuid_libs" ; then
1154 uuid="yes"
1155 libs_softmmu="$uuid_libs $libs_softmmu"
1156 libs_tools="$uuid_libs $libs_tools"
1157 else
1158 if test "$uuid" = "yes" ; then
1159 feature_not_found "uuid"
1161 uuid=no
1165 ##########################################
1166 # vde libraries probe
1167 if test "$vde" != "no" ; then
1168 vde_libs="-lvdeplug"
1169 cat > $TMPC << EOF
1170 #include <libvdeplug.h>
1171 int main(void)
1173 struct vde_open_args a = {0, 0, 0};
1174 vde_open("", "", &a);
1175 return 0;
1178 if compile_prog "" "$vde_libs" ; then
1179 vde=yes
1180 libs_softmmu="$vde_libs $libs_softmmu"
1181 libs_tools="$vde_libs $libs_tools"
1182 else
1183 if test "$vde" = "yes" ; then
1184 feature_not_found "vde"
1186 vde=no
1190 ##########################################
1191 # Sound support libraries probe
1193 audio_drv_probe()
1195 drv=$1
1196 hdr=$2
1197 lib=$3
1198 exp=$4
1199 cfl=$5
1200 cat > $TMPC << EOF
1201 #include <$hdr>
1202 int main(void) { $exp }
1204 if compile_prog "$cfl" "$lib" ; then
1206 else
1207 echo
1208 echo "Error: $drv check failed"
1209 echo "Make sure to have the $drv libs and headers installed."
1210 echo
1211 exit 1
1215 audio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
1216 for drv in $audio_drv_list; do
1217 case $drv in
1218 alsa)
1219 audio_drv_probe $drv alsa/asoundlib.h -lasound \
1220 "snd_pcm_t **handle; return snd_pcm_close(*handle);"
1221 libs_softmmu="-lasound $libs_softmmu"
1224 fmod)
1225 if test -z $fmod_lib || test -z $fmod_inc; then
1226 echo
1227 echo "Error: You must specify path to FMOD library and headers"
1228 echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
1229 echo
1230 exit 1
1232 audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
1233 libs_softmmu="$fmod_lib $libs_softmmu"
1236 esd)
1237 audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
1238 libs_softmmu="-lesd $libs_softmmu"
1239 audio_pt_int="yes"
1243 audio_drv_probe $drv pulse/simple.h "-lpulse-simple -lpulse" \
1244 "pa_simple *s = NULL; pa_simple_free(s); return 0;"
1245 libs_softmmu="-lpulse -lpulse-simple $libs_softmmu"
1246 audio_pt_int="yes"
1249 coreaudio)
1250 libs_softmmu="-framework CoreAudio $libs_softmmu"
1253 dsound)
1254 libs_softmmu="-lole32 -ldxguid $libs_softmmu"
1255 audio_win_int="yes"
1258 oss)
1259 libs_softmmu="$oss_lib $libs_softmmu"
1262 sdl|wav)
1263 # XXX: Probes for CoreAudio, DirectSound, SDL(?)
1266 winwave)
1267 libs_softmmu="-lwinmm $libs_softmmu"
1268 audio_win_int="yes"
1272 echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
1273 echo
1274 echo "Error: Unknown driver '$drv' selected"
1275 echo "Possible drivers are: $audio_possible_drivers"
1276 echo
1277 exit 1
1280 esac
1281 done
1283 ##########################################
1284 # BrlAPI probe
1286 if test "$brlapi" != "no" ; then
1287 brlapi_libs="-lbrlapi"
1288 cat > $TMPC << EOF
1289 #include <brlapi.h>
1290 int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
1292 if compile_prog "" "$brlapi_libs" ; then
1293 brlapi=yes
1294 libs_softmmu="$brlapi_libs $libs_softmmu"
1295 else
1296 if test "$brlapi" = "yes" ; then
1297 feature_not_found "brlapi"
1299 brlapi=no
1303 ##########################################
1304 # curses probe
1305 curses_list="-lncurses -lcurses"
1307 if test "$curses" != "no" ; then
1308 curses_found=no
1309 cat > $TMPC << EOF
1310 #include <curses.h>
1311 #ifdef __OpenBSD__
1312 #define resize_term resizeterm
1313 #endif
1314 int main(void) { resize_term(0, 0); return curses_version(); }
1316 for curses_lib in $curses_list; do
1317 if compile_prog "" "$curses_lib" ; then
1318 curses_found=yes
1319 libs_softmmu="$curses_lib $libs_softmmu"
1320 break
1322 done
1323 if test "$curses_found" = "yes" ; then
1324 curses=yes
1325 else
1326 if test "$curses" = "yes" ; then
1327 feature_not_found "curses"
1329 curses=no
1333 ##########################################
1334 # curl probe
1336 if test "$curl" != "no" ; then
1337 cat > $TMPC << EOF
1338 #include <curl/curl.h>
1339 int main(void) { return curl_easy_init(); }
1341 curl_cflags=`curl-config --cflags 2>/dev/null`
1342 curl_libs=`curl-config --libs 2>/dev/null`
1343 if compile_prog "$curl_cflags" "$curl_libs" ; then
1344 curl=yes
1345 libs_tools="$curl_libs $libs_tools"
1346 libs_softmmu="$curl_libs $libs_softmmu"
1347 else
1348 if test "$curl" = "yes" ; then
1349 feature_not_found "curl"
1351 curl=no
1353 fi # test "$curl"
1355 ##########################################
1356 # check framework probe
1358 if test "$check_utests" != "no" ; then
1359 cat > $TMPC << EOF
1360 #include <check.h>
1361 int main(void) { suite_create("qemu test"); return 0; }
1363 check_libs=`pkg-config --libs check`
1364 if compile_prog "" $check_libs ; then
1365 check_utests=yes
1366 libs_tools="$check_libs $libs_tools"
1367 else
1368 if test "$check_utests" = "yes" ; then
1369 feature_not_found "check"
1371 check_utests=no
1373 fi # test "$check_utests"
1375 ##########################################
1376 # bluez support probe
1377 if test "$bluez" != "no" ; then
1378 cat > $TMPC << EOF
1379 #include <bluetooth/bluetooth.h>
1380 int main(void) { return bt_error(0); }
1382 bluez_cflags=`pkg-config --cflags bluez 2> /dev/null`
1383 bluez_libs=`pkg-config --libs bluez 2> /dev/null`
1384 if compile_prog "$bluez_cflags" "$bluez_libs" ; then
1385 bluez=yes
1386 libs_softmmu="$bluez_libs $libs_softmmu"
1387 else
1388 if test "$bluez" = "yes" ; then
1389 feature_not_found "bluez"
1391 bluez="no"
1395 ##########################################
1396 # kvm probe
1397 if test "$kvm" != "no" ; then
1398 cat > $TMPC <<EOF
1399 #include <linux/kvm.h>
1400 #if !defined(KVM_API_VERSION) || KVM_API_VERSION < 12 || KVM_API_VERSION > 12
1401 #error Invalid KVM version
1402 #endif
1403 #if !defined(KVM_CAP_USER_MEMORY)
1404 #error Missing KVM capability KVM_CAP_USER_MEMORY
1405 #endif
1406 #if !defined(KVM_CAP_SET_TSS_ADDR)
1407 #error Missing KVM capability KVM_CAP_SET_TSS_ADDR
1408 #endif
1409 #if !defined(KVM_CAP_DESTROY_MEMORY_REGION_WORKS)
1410 #error Missing KVM capability KVM_CAP_DESTROY_MEMORY_REGION_WORKS
1411 #endif
1412 int main(void) { return 0; }
1414 if test "$kerneldir" != "" ; then
1415 kvm_cflags=-I"$kerneldir"/include
1416 if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) \
1417 -a -d "$kerneldir/arch/x86/include" ; then
1418 kvm_cflags="$kvm_cflags -I$kerneldir/arch/x86/include"
1419 elif test "$cpu" = "ppc" -a -d "$kerneldir/arch/powerpc/include" ; then
1420 kvm_cflags="$kvm_cflags -I$kerneldir/arch/powerpc/include"
1421 elif test "$cpu" = "s390x" -a -d "$kerneldir/arch/s390/include" ; then
1422 kvm_cflags="$kvm_cflags -I$kerneldir/arch/s390/include"
1423 elif test -d "$kerneldir/arch/$cpu/include" ; then
1424 kvm_cflags="$kvm_cflags -I$kerneldir/arch/$cpu/include"
1426 else
1427 case "$cpu" in
1428 i386 | x86_64)
1429 kvm_arch="x86"
1431 ppc)
1432 kvm_arch="powerpc"
1435 kvm_arch="$cpu"
1437 esac
1438 kvm_cflags="-I$source_path/kvm/include"
1439 kvm_cflags="$kvm_cflags -include $source_path/kvm/include/linux/config.h"
1440 kvm_cflags="$kvm_cflags -I$source_path/kvm/include/$kvm_arch"
1442 kvm_cflags="$kvm_cflags -idirafter $source_path/compat"
1443 if compile_prog "$kvm_cflags" "" ; then
1444 kvm=yes
1445 else
1446 if test "$kvm" = "yes" ; then
1447 if [ -x "`which awk 2>/dev/null`" ] && \
1448 [ -x "`which grep 2>/dev/null`" ]; then
1449 kvmerr=`LANG=C $cc $QEMU_CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&1 \
1450 | grep "error: " \
1451 | awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'`
1452 if test "$kvmerr" != "" ; then
1453 echo -e "${kvmerr}\n\
1454 NOTE: To enable KVM support, update your kernel to 2.6.29+ or install \
1455 recent kvm-kmod from http://sourceforge.net/projects/kvm."
1458 feature_not_found "kvm"
1460 kvm=no
1464 ##########################################
1465 # test for KVM_CAP_PIT
1467 if test "$kvm_cap_pit" != "no" ; then
1468 if test "$kvm" = "no" -a "$kvm_cap_pit" = "yes" ; then
1469 feature_not_found "kvm_cap_pit (kvm is not enabled)"
1471 cat > $TMPC <<EOF
1472 #include <linux/kvm.h>
1473 #ifndef KVM_CAP_PIT
1474 #error "kvm no pit capability"
1475 #endif
1476 int main(void) { return 0; }
1478 if compile_prog "$kvm_cflags" ""; then
1479 kvm_cap_pit=yes
1480 else
1481 if test "$kvm_cap_pit" = "yes" ; then
1482 feature_not_found "kvm_cap_pit"
1484 kvm_cap_pit=no
1488 ##########################################
1489 # test for KVM_CAP_DEVICE_ASSIGNMENT
1491 if test "$kvm_cap_device_assignment" != "no" ; then
1492 if test "$kvm" = "no" -a "$kvm_cap_device_assignment" = "yes" ; then
1493 feature_not_found "kvm_cap_device_assignment (kvm is not enabled)"
1495 cat > $TMPC <<EOF
1496 #include <linux/kvm.h>
1497 #ifndef KVM_CAP_DEVICE_ASSIGNMENT
1498 #error "kvm no device assignment capability"
1499 #endif
1500 int main(void) { return 0; }
1502 if compile_prog "$kvm_cflags" "" ; then
1503 kvm_cap_device_assignment=yes
1504 else
1505 if test "$kvm_cap_device_assignment" = "yes" ; then
1506 feature_not_found "kvm_cap_device_assigment"
1508 kvm_cap_device_assignment=no
1512 ##########################################
1513 # libpci probe for kvm_cap_device_assignment
1514 if test $kvm_cap_device_assignment = "yes" ; then
1515 cat > $TMPC << EOF
1516 #include <pci/pci.h>
1517 #ifndef PCI_VENDOR_ID
1518 #error NO LIBPCI
1519 #endif
1520 int main(void) { struct pci_access a; pci_init(&a); return 0; }
1522 if compile_prog "" "-lpci -lz" ; then
1523 libs_softmmu="-lpci -lz $libs_softmmu"
1524 else
1525 echo
1526 echo "Error: libpci check failed"
1527 echo "Disable KVM Device Assignment capability."
1528 echo
1529 kvm_cap_device_assignment=no
1533 ##########################################
1534 # pthread probe
1535 PTHREADLIBS_LIST="-lpthread -lpthreadGC2"
1537 pthread=no
1538 cat > $TMPC << EOF
1539 #include <pthread.h>
1540 int main(void) { pthread_create(0,0,0,0); return 0; }
1542 for pthread_lib in $PTHREADLIBS_LIST; do
1543 if compile_prog "" "$pthread_lib" ; then
1544 pthread=yes
1545 LIBS="$pthread_lib $LIBS"
1546 break
1548 done
1550 if test "$mingw32" != yes -a "$pthread" = no; then
1551 echo
1552 echo "Error: pthread check failed"
1553 echo "Make sure to have the pthread libs and headers installed."
1554 echo
1555 exit 1
1558 ##########################################
1559 # linux-aio probe
1561 if test "$linux_aio" != "no" ; then
1562 cat > $TMPC <<EOF
1563 #include <libaio.h>
1564 #include <sys/eventfd.h>
1565 int main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
1567 if compile_prog "" "-laio" ; then
1568 linux_aio=yes
1569 LIBS="$LIBS -laio"
1570 else
1571 if test "$linux_aio" = "yes" ; then
1572 feature_not_found "linux AIO"
1574 linux_aio=no
1578 ##########################################
1579 # iovec probe
1580 cat > $TMPC <<EOF
1581 #include <sys/types.h>
1582 #include <sys/uio.h>
1583 #include <unistd.h>
1584 int main(void) { struct iovec iov; return 0; }
1586 iovec=no
1587 if compile_prog "" "" ; then
1588 iovec=yes
1591 ##########################################
1592 # preadv probe
1593 cat > $TMPC <<EOF
1594 #include <sys/types.h>
1595 #include <sys/uio.h>
1596 #include <unistd.h>
1597 int main(void) { preadv; }
1599 preadv=no
1600 if compile_prog "" "" ; then
1601 preadv=yes
1604 ##########################################
1605 # fdt probe
1606 if test "$fdt" != "no" ; then
1607 fdt_libs="-lfdt"
1608 cat > $TMPC << EOF
1609 int main(void) { return 0; }
1611 if compile_prog "" "$fdt_libs" ; then
1612 fdt=yes
1613 libs_softmmu="$fdt_libs $libs_softmmu"
1614 else
1615 if test "$fdt" = "yes" ; then
1616 feature_not_found "fdt"
1618 fdt=no
1623 # Check for xxxat() functions when we are building linux-user
1624 # emulator. This is done because older glibc versions don't
1625 # have syscall stubs for these implemented.
1627 atfile=no
1628 cat > $TMPC << EOF
1629 #define _ATFILE_SOURCE
1630 #include <sys/types.h>
1631 #include <fcntl.h>
1632 #include <unistd.h>
1635 main(void)
1637 /* try to unlink nonexisting file */
1638 return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
1641 if compile_prog "" "" ; then
1642 atfile=yes
1645 # Check for inotify functions when we are building linux-user
1646 # emulator. This is done because older glibc versions don't
1647 # have syscall stubs for these implemented. In that case we
1648 # don't provide them even if kernel supports them.
1650 inotify=no
1651 cat > $TMPC << EOF
1652 #include <sys/inotify.h>
1655 main(void)
1657 /* try to start inotify */
1658 return inotify_init();
1661 if compile_prog "" "" ; then
1662 inotify=yes
1665 # check if utimensat and futimens are supported
1666 utimens=no
1667 cat > $TMPC << EOF
1668 #define _ATFILE_SOURCE
1669 #define _GNU_SOURCE
1670 #include <stddef.h>
1671 #include <fcntl.h>
1673 int main(void)
1675 utimensat(AT_FDCWD, "foo", NULL, 0);
1676 futimens(0, NULL);
1677 return 0;
1680 if compile_prog "" "" ; then
1681 utimens=yes
1684 # check if pipe2 is there
1685 pipe2=no
1686 cat > $TMPC << EOF
1687 #define _GNU_SOURCE
1688 #include <unistd.h>
1689 #include <fcntl.h>
1691 int main(void)
1693 int pipefd[2];
1694 pipe2(pipefd, O_CLOEXEC);
1695 return 0;
1698 if compile_prog "" "" ; then
1699 pipe2=yes
1702 # check if accept4 is there
1703 accept4=no
1704 cat > $TMPC << EOF
1705 #define _GNU_SOURCE
1706 #include <sys/socket.h>
1707 #include <stddef.h>
1709 int main(void)
1711 accept4(0, NULL, NULL, SOCK_CLOEXEC);
1712 return 0;
1715 if compile_prog "" "" ; then
1716 accept4=yes
1719 # check if tee/splice is there. vmsplice was added same time.
1720 splice=no
1721 cat > $TMPC << EOF
1722 #define _GNU_SOURCE
1723 #include <unistd.h>
1724 #include <fcntl.h>
1725 #include <limits.h>
1727 int main(void)
1729 int len, fd;
1730 len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
1731 splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
1732 return 0;
1735 if compile_prog "" "" ; then
1736 splice=yes
1739 ##########################################
1740 # signalfd probe
1741 signalfd="no"
1742 cat > $TMPC << EOF
1743 #define _GNU_SOURCE
1744 #include <unistd.h>
1745 #include <sys/syscall.h>
1746 #include <signal.h>
1747 int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
1750 if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
1751 signalfd=yes
1754 # check if eventfd is supported
1755 eventfd=no
1756 cat > $TMPC << EOF
1757 #include <sys/eventfd.h>
1759 int main(void)
1761 int efd = eventfd(0, 0);
1762 return 0;
1765 if compile_prog "" "" ; then
1766 eventfd=yes
1769 # check for fallocate
1770 fallocate=no
1771 cat > $TMPC << EOF
1772 #include <fcntl.h>
1774 int main(void)
1776 fallocate(0, 0, 0, 0);
1777 return 0;
1780 if compile_prog "$ARCH_CFLAGS" "" ; then
1781 fallocate=yes
1784 # check for dup3
1785 dup3=no
1786 cat > $TMPC << EOF
1787 #include <unistd.h>
1789 int main(void)
1791 dup3(0, 0, 0);
1792 return 0;
1795 if compile_prog "" "" ; then
1796 dup3=yes
1799 # Check if tools are available to build documentation.
1800 if test "$docs" != "no" ; then
1801 if test -x "`which texi2html 2>/dev/null`" -a \
1802 -x "`which pod2man 2>/dev/null`" ; then
1803 docs=yes
1804 else
1805 if test "$docs" = "yes" ; then
1806 feature_not_found "docs"
1808 docs=no
1812 # Search for bswap_32 function
1813 byteswap_h=no
1814 cat > $TMPC << EOF
1815 #include <byteswap.h>
1816 int main(void) { return bswap_32(0); }
1818 if compile_prog "" "" ; then
1819 byteswap_h=yes
1822 # Search for bswap_32 function
1823 bswap_h=no
1824 cat > $TMPC << EOF
1825 #include <sys/endian.h>
1826 #include <sys/types.h>
1827 #include <machine/bswap.h>
1828 int main(void) { return bswap32(0); }
1830 if compile_prog "" "" ; then
1831 bswap_h=yes
1834 ##########################################
1835 # Do we need librt
1836 cat > $TMPC <<EOF
1837 #include <signal.h>
1838 #include <time.h>
1839 int main(void) { clockid_t id; return clock_gettime(id, NULL); }
1842 if compile_prog "" "" ; then
1844 elif compile_prog "" "-lrt" ; then
1845 LIBS="-lrt $LIBS"
1848 # Determine what linker flags to use to force archive inclusion
1849 check_linker_flags()
1852 if test "$2" ; then
1853 w2=-Wl,$2
1855 compile_prog "" "-Wl,$1 ${w2}"
1858 cat > $TMPC << EOF
1859 int main(void) { }
1861 if check_linker_flags --whole-archive --no-whole-archive ; then
1862 # GNU ld
1863 arlibs_begin="-Wl,--whole-archive"
1864 arlibs_end="-Wl,--no-whole-archive"
1865 elif check_linker_flags -z,allextract -z,defaultextract ; then
1866 # Solaris ld
1867 arlibs_begin="-Wl,-z,allextract"
1868 arlibs_end="-Wl,-z,defaultextract"
1869 elif check_linker_flags -all_load ; then
1870 # Mac OS X
1871 arlibs_begin="-all_load"
1872 arlibs_end=""
1873 else
1874 echo "Error: your linker does not support --whole-archive or -z."
1875 echo "Please report to qemu-devel@nongnu.org"
1876 exit 1
1879 if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
1880 "$aix" != "yes" ; then
1881 libs_softmmu="-lutil $libs_softmmu"
1884 ##########################################
1885 # check if the compiler defines offsetof
1887 need_offsetof=yes
1888 cat > $TMPC << EOF
1889 #include <stddef.h>
1890 int main(void) { struct s { int f; }; return offsetof(struct s, f); }
1892 if compile_prog "" "" ; then
1893 need_offsetof=no
1896 ##########################################
1897 # check if the compiler understands attribute warn_unused_result
1899 # This could be smarter, but gcc -Werror does not error out even when warning
1900 # about attribute warn_unused_result
1902 gcc_attribute_warn_unused_result=no
1903 cat > $TMPC << EOF
1904 #if defined(__GNUC__) && (__GNUC__ < 4) && defined(__GNUC_MINOR__) && (__GNUC__ < 4)
1905 #error gcc 3.3 or older
1906 #endif
1907 int main(void) { return 0;}
1909 if compile_prog "" ""; then
1910 gcc_attribute_warn_unused_result=yes
1913 ##########################################
1914 # check if we have fdatasync
1916 fdatasync=no
1917 cat > $TMPC << EOF
1918 #include <unistd.h>
1919 int main(void) { return fdatasync(0); }
1921 if compile_prog "" "" ; then
1922 fdatasync=yes
1925 # End of CC checks
1926 # After here, no more $cc or $ld runs
1928 if test "$debug" = "no" ; then
1929 CFLAGS="-O2 $CFLAGS"
1932 # Consult white-list to determine whether to enable werror
1933 # by default. Only enable by default for git builds
1934 z_version=`cut -f3 -d. $source_path/VERSION`
1936 if test -z "$werror" ; then
1937 if test "$z_version" = "50" -a \
1938 "$linux" = "yes" ; then
1939 werror="yes"
1940 else
1941 werror="no"
1945 # Disable zero malloc errors for official releases unless explicitly told to
1946 # enable/disable
1947 if test -z "$zero_malloc" ; then
1948 if test "$z_version" = "50" ; then
1949 zero_malloc="no"
1950 else
1951 zero_malloc="yes"
1955 if test "$werror" = "yes" ; then
1956 QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
1959 if test "$solaris" = "no" ; then
1960 if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
1961 LDFLAGS="-Wl,--warn-common $LDFLAGS"
1965 if test "$mingw32" = "yes" ; then
1966 if test -z "$prefix" ; then
1967 prefix="c:/Program Files/Qemu"
1969 mansuffix=""
1970 datasuffix=""
1971 docsuffix=""
1972 binsuffix=""
1973 else
1974 if test -z "$prefix" ; then
1975 prefix="/usr/local"
1977 mansuffix="/share/man"
1978 datasuffix="/share/qemu"
1979 docsuffix="/share/doc/qemu"
1980 binsuffix="/bin"
1983 if test -f kvm/kernel/configure; then
1984 kvm_kmod="yes"
1985 kmod_args=""
1986 if test -n "$kerneldir"; then
1987 kmod_args="--kerneldir=$kerneldir"
1989 if test "$kvm_trace" = "yes"; then
1990 kmod_args="$kmod_args --with-kvm-trace"
1992 # hope there are no spaces in kmod_args; can't use arrays because of
1993 # dash.
1994 (cd kvm/kernel; ./configure $kmod_args)
1997 echo "Install prefix $prefix"
1998 echo "BIOS directory $prefix$datasuffix"
1999 echo "binary directory $prefix$binsuffix"
2000 if test "$mingw32" = "no" ; then
2001 echo "Manual directory $prefix$mansuffix"
2002 echo "ELF interp prefix $interp_prefix"
2004 echo "Source path $source_path"
2005 echo "C compiler $cc"
2006 echo "Host C compiler $host_cc"
2007 echo "CFLAGS $CFLAGS"
2008 echo "QEMU_CFLAGS $QEMU_CFLAGS"
2009 echo "LDFLAGS $LDFLAGS"
2010 echo "make $make"
2011 echo "install $install"
2012 echo "host CPU $cpu"
2013 echo "host big endian $bigendian"
2014 echo "target list $target_list"
2015 echo "tcg debug enabled $debug_tcg"
2016 echo "gprof enabled $gprof"
2017 echo "sparse enabled $sparse"
2018 echo "strip binaries $strip_opt"
2019 echo "profiler $profiler"
2020 echo "static build $static"
2021 echo "-Werror enabled $werror"
2022 if test "$darwin" = "yes" ; then
2023 echo "Cocoa support $cocoa"
2025 echo "SDL support $sdl"
2026 echo "curses support $curses"
2027 echo "curl support $curl"
2028 echo "check support $check_utests"
2029 echo "mingw32 support $mingw32"
2030 echo "Audio drivers $audio_drv_list"
2031 echo "Extra audio cards $audio_card_list"
2032 echo "Block whitelist $block_drv_whitelist"
2033 echo "Mixer emulation $mixemu"
2034 echo "VNC TLS support $vnc_tls"
2035 echo "VNC SASL support $vnc_sasl"
2036 if test -n "$sparc_cpu"; then
2037 echo "Target Sparc Arch $sparc_cpu"
2039 echo "xen support $xen"
2040 echo "CPU emulation $cpu_emulation"
2041 echo "brlapi support $brlapi"
2042 echo "bluez support $bluez"
2043 echo "Documentation $docs"
2044 [ ! -z "$uname_release" ] && \
2045 echo "uname -r $uname_release"
2046 echo "NPTL support $nptl"
2047 echo "GUEST_BASE $guest_base"
2048 echo "PIE user targets $user_pie"
2049 echo "vde support $vde"
2050 echo "IO thread $io_thread"
2051 echo "Linux AIO support $linux_aio"
2052 echo "Install blobs $blobs"
2053 echo "KVM support $kvm"
2054 echo "KVM PIT support $kvm_cap_pit"
2055 echo "KVM device assig. $kvm_cap_device_assignment"
2056 echo "KVM trace support $kvm_trace"
2057 echo "fdt support $fdt"
2058 echo "preadv support $preadv"
2059 echo "fdatasync $fdatasync"
2060 echo "uuid support $uuid"
2062 if test $sdl_too_old = "yes"; then
2063 echo "-> Your SDL version is too old - please upgrade to have SDL support"
2066 config_host_mak="config-host.mak"
2067 config_host_ld="config-host.ld"
2069 echo "# Automatically generated by configure - do not modify" > $config_host_mak
2070 printf "# Configured with:" >> $config_host_mak
2071 printf " '%s'" "$0" "$@" >> $config_host_mak
2072 echo >> $config_host_mak
2074 echo "CONFIG_QEMU_SHAREDIR=\"$prefix$datasuffix\"" >> $config_host_mak
2076 case "$cpu" in
2077 i386|x86_64|alpha|cris|hppa|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
2078 ARCH=$cpu
2080 armv4b|armv4l)
2081 ARCH=arm
2084 echo "Unsupported CPU = $cpu"
2085 exit 1
2087 esac
2088 echo "ARCH=$ARCH" >> $config_host_mak
2089 if test "$debug_tcg" = "yes" ; then
2090 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
2092 if test "$debug" = "yes" ; then
2093 echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
2095 if test "$strip_opt" = "yes" ; then
2096 echo "STRIP_OPT=-s" >> $config_host_mak
2098 if test "$bigendian" = "yes" ; then
2099 echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
2101 echo "HOST_LONG_BITS=$hostlongbits" >> $config_host_mak
2102 if test "$mingw32" = "yes" ; then
2103 echo "CONFIG_WIN32=y" >> $config_host_mak
2104 else
2105 echo "CONFIG_POSIX=y" >> $config_host_mak
2108 if test "$linux" = "yes" ; then
2109 echo "CONFIG_LINUX=y" >> $config_host_mak
2112 if test "$darwin" = "yes" ; then
2113 echo "CONFIG_DARWIN=y" >> $config_host_mak
2116 if test "$aix" = "yes" ; then
2117 echo "CONFIG_AIX=y" >> $config_host_mak
2120 if test "$solaris" = "yes" ; then
2121 echo "CONFIG_SOLARIS=y" >> $config_host_mak
2122 echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
2123 if test "$needs_libsunmath" = "yes" ; then
2124 echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
2127 if test "$static" = "yes" ; then
2128 echo "CONFIG_STATIC=y" >> $config_host_mak
2129 LDFLAGS="-static $LDFLAGS"
2131 if test $profiler = "yes" ; then
2132 echo "CONFIG_PROFILER=y" >> $config_host_mak
2134 if test "$slirp" = "yes" ; then
2135 echo "CONFIG_SLIRP=y" >> $config_host_mak
2136 QEMU_CFLAGS="-I\$(SRC_PATH)/slirp $QEMU_CFLAGS"
2138 if test "$vde" = "yes" ; then
2139 echo "CONFIG_VDE=y" >> $config_host_mak
2141 for card in $audio_card_list; do
2142 def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
2143 echo "$def=y" >> $config_host_mak
2144 done
2145 echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
2146 for drv in $audio_drv_list; do
2147 def=CONFIG_`echo $drv | tr '[:lower:]' '[:upper:]'`
2148 echo "$def=y" >> $config_host_mak
2149 if test "$drv" = "fmod"; then
2150 echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
2152 done
2153 if test "$audio_pt_int" = "yes" ; then
2154 echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
2156 if test "$audio_win_int" = "yes" ; then
2157 echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
2159 echo "CONFIG_BDRV_WHITELIST=$block_drv_whitelist" >> $config_host_mak
2160 if test "$mixemu" = "yes" ; then
2161 echo "CONFIG_MIXEMU=y" >> $config_host_mak
2163 if test "$vnc_tls" = "yes" ; then
2164 echo "CONFIG_VNC_TLS=y" >> $config_host_mak
2165 echo "VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_host_mak
2167 if test "$vnc_sasl" = "yes" ; then
2168 echo "CONFIG_VNC_SASL=y" >> $config_host_mak
2169 echo "VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak
2171 if test "$fnmatch" = "yes" ; then
2172 echo "CONFIG_FNMATCH=y" >> $config_host_mak
2174 if test "$uuid" = "yes" ; then
2175 echo "CONFIG_UUID=y" >> $config_host_mak
2177 qemu_version=`head $source_path/VERSION`
2178 echo "VERSION=$qemu_version" >>$config_host_mak
2179 echo "PKGVERSION=$pkgversion" >>$config_host_mak
2180 echo "SRC_PATH=$source_path" >> $config_host_mak
2181 if [ "$source_path_used" = "yes" ]; then
2182 echo "VPATH=$source_path" >> $config_host_mak
2184 echo "TARGET_DIRS=$target_list" >> $config_host_mak
2185 if [ "$docs" = "yes" ] ; then
2186 echo "BUILD_DOCS=yes" >> $config_host_mak
2188 if test "$sdl" = "yes" ; then
2189 echo "CONFIG_SDL=y" >> $config_host_mak
2190 echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
2192 if test "$cocoa" = "yes" ; then
2193 echo "CONFIG_COCOA=y" >> $config_host_mak
2195 if test "$curses" = "yes" ; then
2196 echo "CONFIG_CURSES=y" >> $config_host_mak
2198 if test "$atfile" = "yes" ; then
2199 echo "CONFIG_ATFILE=y" >> $config_host_mak
2201 if test "$utimens" = "yes" ; then
2202 echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
2204 if test "$pipe2" = "yes" ; then
2205 echo "CONFIG_PIPE2=y" >> $config_host_mak
2207 if test "$accept4" = "yes" ; then
2208 echo "CONFIG_ACCEPT4=y" >> $config_host_mak
2210 if test "$splice" = "yes" ; then
2211 echo "CONFIG_SPLICE=y" >> $config_host_mak
2213 if test "$eventfd" = "yes" ; then
2214 echo "CONFIG_EVENTFD=y" >> $config_host_mak
2216 if test "$fallocate" = "yes" ; then
2217 echo "CONFIG_FALLOCATE=y" >> $config_host_mak
2219 if test "$dup3" = "yes" ; then
2220 echo "CONFIG_DUP3=y" >> $config_host_mak
2222 if test "$inotify" = "yes" ; then
2223 echo "CONFIG_INOTIFY=y" >> $config_host_mak
2225 if test "$byteswap_h" = "yes" ; then
2226 echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
2228 if test "$bswap_h" = "yes" ; then
2229 echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
2231 if test "$curl" = "yes" ; then
2232 echo "CONFIG_CURL=y" >> $config_host_mak
2233 echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
2235 if test "$brlapi" = "yes" ; then
2236 echo "CONFIG_BRLAPI=y" >> $config_host_mak
2238 if test "$bluez" = "yes" ; then
2239 echo "CONFIG_BLUEZ=y" >> $config_host_mak
2240 echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
2242 if test "$xen" = "yes" ; then
2243 echo "CONFIG_XEN=y" >> $config_host_mak
2245 if test "$io_thread" = "yes" ; then
2246 echo "CONFIG_IOTHREAD=y" >> $config_host_mak
2248 if test "$linux_aio" = "yes" ; then
2249 echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
2251 if test "$blobs" = "yes" ; then
2252 echo "INSTALL_BLOBS=yes" >> $config_host_mak
2254 if test "$iovec" = "yes" ; then
2255 echo "CONFIG_IOVEC=y" >> $config_host_mak
2257 if test "$preadv" = "yes" ; then
2258 echo "CONFIG_PREADV=y" >> $config_host_mak
2260 if test "$fdt" = "yes" ; then
2261 echo "CONFIG_FDT=y" >> $config_host_mak
2263 if test "$signalfd" = "yes" ; then
2264 echo "CONFIG_SIGNALFD=y" >> $config_host_mak
2266 if test "$need_offsetof" = "yes" ; then
2267 echo "CONFIG_NEED_OFFSETOF=y" >> $config_host_mak
2269 if test "$gcc_attribute_warn_unused_result" = "yes" ; then
2270 echo "CONFIG_GCC_ATTRIBUTE_WARN_UNUSED_RESULT=y" >> $config_host_mak
2272 if test "$fdatasync" = "yes" ; then
2273 echo "CONFIG_FDATASYNC=y" >> $config_host_mak
2275 if test $cpu_emulation = "yes"; then
2276 echo "CONFIG_CPU_EMULATION=y" >> $config_host_mak
2277 else
2278 echo "CONFIG_NO_CPU_EMULATION=y" >> $config_host_mak
2281 # XXX: suppress that
2282 if [ "$bsd" = "yes" ] ; then
2283 echo "CONFIG_BSD=y" >> $config_host_mak
2286 echo "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
2288 if test "$zero_malloc" = "yes" ; then
2289 echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
2292 # USB host support
2293 case "$usb" in
2294 linux)
2295 echo "HOST_USB=linux" >> $config_host_mak
2297 bsd)
2298 echo "HOST_USB=bsd" >> $config_host_mak
2301 echo "HOST_USB=stub" >> $config_host_mak
2303 esac
2305 echo "KVM_KMOD=$kvm_kmod" >> $config_host_mak
2307 tools=
2308 if test `expr "$target_list" : ".*softmmu.*"` != 0 ; then
2309 tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
2310 if [ "$linux" = "yes" ] ; then
2311 tools="qemu-nbd\$(EXESUF) $tools"
2312 if [ "$check_utests" = "yes" ]; then
2313 tools="check-qint check-qstring check-qdict check-qlist $tools"
2314 tools="check-qfloat check-qjson $tools"
2318 echo "TOOLS=$tools" >> $config_host_mak
2320 # Mac OS X ships with a broken assembler
2321 roms=
2322 if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
2323 "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
2324 `expr "$target_list" : ".*softmmu.*"` != 0 ; then
2325 roms="optionrom"
2327 echo "ROMS=$roms" >> $config_host_mak
2329 echo "prefix=$prefix" >> $config_host_mak
2330 echo "bindir=\${prefix}$binsuffix" >> $config_host_mak
2331 echo "mandir=\${prefix}$mansuffix" >> $config_host_mak
2332 echo "datadir=\${prefix}$datasuffix" >> $config_host_mak
2333 echo "docdir=\${prefix}$docsuffix" >> $config_host_mak
2334 echo "MAKE=$make" >> $config_host_mak
2335 echo "INSTALL=$install" >> $config_host_mak
2336 echo "INSTALL_DIR=$install -d -m0755 -p" >> $config_host_mak
2337 echo "INSTALL_DATA=$install -m0644 -p" >> $config_host_mak
2338 echo "INSTALL_PROG=$install -m0755 -p" >> $config_host_mak
2339 echo "CC=$cc" >> $config_host_mak
2340 echo "HOST_CC=$host_cc" >> $config_host_mak
2341 if test "$sparse" = "yes" ; then
2342 echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_host_mak
2343 echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_host_mak
2344 echo "QEMU_CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
2346 echo "AR=$ar" >> $config_host_mak
2347 echo "OBJCOPY=$objcopy" >> $config_host_mak
2348 echo "LD=$ld" >> $config_host_mak
2349 echo "CFLAGS=$CFLAGS" >> $config_host_mak
2350 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
2351 echo "HELPER_CFLAGS=$helper_cflags" >> $config_host_mak
2352 echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
2353 echo "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak
2354 echo "ARLIBS_END=$arlibs_end" >> $config_host_mak
2355 echo "LIBS+=$LIBS" >> $config_host_mak
2356 echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
2357 echo "EXESUF=$EXESUF" >> $config_host_mak
2359 # generate list of library paths for linker script
2361 $ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
2363 if test -f ${config_host_ld}~ ; then
2364 if cmp -s $config_host_ld ${config_host_ld}~ ; then
2365 mv ${config_host_ld}~ $config_host_ld
2366 else
2367 rm ${config_host_ld}~
2371 for target in $target_list; do
2372 target_dir="$target"
2373 config_target_mak=$target_dir/config-target.mak
2374 target_arch2=`echo $target | cut -d '-' -f 1`
2375 target_bigendian="no"
2377 case "$target_arch2" in
2378 armeb|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus)
2379 target_bigendian=yes
2381 esac
2382 target_softmmu="no"
2383 target_user_only="no"
2384 target_linux_user="no"
2385 target_darwin_user="no"
2386 target_bsd_user="no"
2387 case "$target" in
2388 ${target_arch2}-softmmu)
2389 target_softmmu="yes"
2391 ${target_arch2}-linux-user)
2392 if test "$linux" != "yes" ; then
2393 echo "ERROR: Target '$target' is only available on a Linux host"
2394 exit 1
2396 target_user_only="yes"
2397 target_linux_user="yes"
2399 ${target_arch2}-darwin-user)
2400 if test "$darwin" != "yes" ; then
2401 echo "ERROR: Target '$target' is only available on a Darwin host"
2402 exit 1
2404 target_user_only="yes"
2405 target_darwin_user="yes"
2407 ${target_arch2}-bsd-user)
2408 if test "$bsd" != "yes" ; then
2409 echo "ERROR: Target '$target' is only available on a BSD host"
2410 exit 1
2412 target_user_only="yes"
2413 target_bsd_user="yes"
2416 echo "ERROR: Target '$target' not recognised"
2417 exit 1
2419 esac
2421 mkdir -p $target_dir
2422 mkdir -p $target_dir/fpu
2423 mkdir -p $target_dir/tcg
2424 mkdir -p $target_dir/ide
2425 if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
2426 mkdir -p $target_dir/nwfpe
2430 # don't use ln -sf as not all "ln -sf" over write the file/link
2432 rm -f $target_dir/Makefile
2433 ln -s $source_path/Makefile.target $target_dir/Makefile
2436 echo "# Automatically generated by configure - do not modify" > $config_target_mak
2438 bflt="no"
2439 elfload32="no"
2440 target_nptl="no"
2441 interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
2442 echo "CONFIG_QEMU_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
2443 gdb_xml_files=""
2445 TARGET_ARCH="$target_arch2"
2446 TARGET_BASE_ARCH=""
2447 TARGET_ABI_DIR=""
2449 case "$target_arch2" in
2450 i386)
2451 target_phys_bits=32
2453 x86_64)
2454 TARGET_BASE_ARCH=i386
2455 target_phys_bits=64
2457 ia64)
2458 target_phys_bits=64
2460 alpha)
2461 target_phys_bits=64
2463 arm|armeb)
2464 TARGET_ARCH=arm
2465 bflt="yes"
2466 target_nptl="yes"
2467 gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
2468 target_phys_bits=32
2470 cris)
2471 target_nptl="yes"
2472 target_phys_bits=32
2474 m68k)
2475 bflt="yes"
2476 gdb_xml_files="cf-core.xml cf-fp.xml"
2477 target_phys_bits=32
2479 microblaze)
2480 bflt="yes"
2481 target_nptl="yes"
2482 target_phys_bits=32
2484 mips|mipsel)
2485 TARGET_ARCH=mips
2486 echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
2487 target_nptl="yes"
2488 target_phys_bits=64
2490 mipsn32|mipsn32el)
2491 TARGET_ARCH=mipsn32
2492 TARGET_BASE_ARCH=mips
2493 echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
2494 target_phys_bits=64
2496 mips64|mips64el)
2497 TARGET_ARCH=mips64
2498 TARGET_BASE_ARCH=mips
2499 echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
2500 target_phys_bits=64
2502 ppc)
2503 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2504 target_phys_bits=32
2505 target_nptl="yes"
2507 ppcemb)
2508 TARGET_BASE_ARCH=ppc
2509 TARGET_ABI_DIR=ppc
2510 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2511 target_phys_bits=64
2512 target_nptl="yes"
2514 ppc64)
2515 TARGET_BASE_ARCH=ppc
2516 TARGET_ABI_DIR=ppc
2517 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2518 target_phys_bits=64
2520 ppc64abi32)
2521 TARGET_ARCH=ppc64
2522 TARGET_BASE_ARCH=ppc
2523 TARGET_ABI_DIR=ppc
2524 echo "TARGET_ABI32=y" >> $config_target_mak
2525 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2526 target_phys_bits=64
2528 sh4|sh4eb)
2529 TARGET_ARCH=sh4
2530 bflt="yes"
2531 target_nptl="yes"
2532 target_phys_bits=32
2534 sparc)
2535 target_phys_bits=64
2537 sparc64)
2538 TARGET_BASE_ARCH=sparc
2539 elfload32="yes"
2540 target_phys_bits=64
2542 sparc32plus)
2543 TARGET_ARCH=sparc64
2544 TARGET_BASE_ARCH=sparc
2545 TARGET_ABI_DIR=sparc
2546 echo "TARGET_ABI32=y" >> $config_target_mak
2547 target_phys_bits=64
2549 s390x)
2550 target_phys_bits=64
2553 echo "Unsupported target CPU"
2554 exit 1
2556 esac
2557 echo "TARGET_ARCH=$TARGET_ARCH" >> $config_target_mak
2558 target_arch_name="`echo $TARGET_ARCH | tr '[:lower:]' '[:upper:]'`"
2559 echo "TARGET_$target_arch_name=y" >> $config_target_mak
2560 echo "TARGET_ARCH2=$target_arch2" >> $config_target_mak
2561 # TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
2562 if [ "$TARGET_BASE_ARCH" = "" ]; then
2563 TARGET_BASE_ARCH=$TARGET_ARCH
2565 echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
2566 if [ "$TARGET_ABI_DIR" = "" ]; then
2567 TARGET_ABI_DIR=$TARGET_ARCH
2569 echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
2570 if [ $target_phys_bits -lt $hostlongbits ] ; then
2571 target_phys_bits=$hostlongbits
2573 case "$target_arch2" in
2574 i386|x86_64)
2575 if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
2576 echo "CONFIG_XEN=y" >> $config_target_mak
2578 esac
2579 case "$target_arch2" in
2580 i386|x86_64|ppcemb|ppc|ppc64|s390x)
2581 # Make sure the target and host cpus are compatible
2582 if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
2583 \( "$target_arch2" = "$cpu" -o \
2584 \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
2585 \( "$target_arch2" = "ppc64" -a "$cpu" = "ppc" \) -o \
2586 \( "$target_arch2" = "x86_64" -a "$cpu" = "i386" \) -o \
2587 \( "$target_arch2" = "i386" -a "$cpu" = "x86_64" \) \) ; then
2588 echo "CONFIG_KVM=y" >> $config_target_mak
2589 echo "KVM_CFLAGS=$kvm_cflags" >> $config_target_mak
2590 if test $kvm_cap_pit = "yes" ; then
2591 echo "CONFIG_KVM_PIT=y" >> $config_target_mak
2593 if test $kvm_cap_device_assignment = "yes" ; then
2594 echo "CONFIG_KVM_DEVICE_ASSIGNMENT=y" >> $config_target_mak
2597 esac
2598 echo "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_target_mak
2599 if test "$target_bigendian" = "yes" ; then
2600 echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
2602 if test "$target_softmmu" = "yes" ; then
2603 echo "CONFIG_SOFTMMU=y" >> $config_target_mak
2604 echo "LIBS+=$libs_softmmu" >> $config_target_mak
2605 echo "HWLIB=../libhw$target_phys_bits/libqemuhw$target_phys_bits.a" >> $config_target_mak
2606 echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
2608 if test "$target_user_only" = "yes" ; then
2609 echo "CONFIG_USER_ONLY=y" >> $config_target_mak
2611 if test "$target_linux_user" = "yes" ; then
2612 echo "CONFIG_LINUX_USER=y" >> $config_target_mak
2614 if test "$target_darwin_user" = "yes" ; then
2615 echo "CONFIG_DARWIN_USER=y" >> $config_target_mak
2617 list=""
2618 if test ! -z "$gdb_xml_files" ; then
2619 for x in $gdb_xml_files; do
2620 list="$list $source_path/gdb-xml/$x"
2621 done
2622 echo "TARGET_XML_FILES=$list" >> $config_target_mak
2625 case "$target_arch2" in
2626 arm|armeb|m68k|microblaze|mips|mipsel|mipsn32|mipsn32el|mips64|mips64el|ppc|ppc64|ppc64abi32|ppcemb|s390x|sparc|sparc64|sparc32plus)
2627 echo "CONFIG_SOFTFLOAT=y" >> $config_target_mak
2630 echo "CONFIG_NOSOFTFLOAT=y" >> $config_target_mak
2632 esac
2634 if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
2635 echo "TARGET_HAS_BFLT=y" >> $config_target_mak
2637 if test "$target_user_only" = "yes" \
2638 -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
2639 echo "CONFIG_USE_NPTL=y" >> $config_target_mak
2641 # 32 bit ELF loader in addition to native 64 bit loader?
2642 if test "$target_user_only" = "yes" -a "$elfload32" = "yes"; then
2643 echo "TARGET_HAS_ELFLOAD32=y" >> $config_target_mak
2645 if test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
2646 echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
2648 if test "$target_bsd_user" = "yes" ; then
2649 echo "CONFIG_BSD_USER=y" >> $config_target_mak
2652 # generate QEMU_CFLAGS/LDFLAGS for targets
2654 cflags=""
2655 ldflags=""
2657 if test "$ARCH" = "sparc64" ; then
2658 cflags="-I\$(SRC_PATH)/tcg/sparc $cflags"
2659 elif test "$ARCH" = "s390x" ; then
2660 cflags="-I\$(SRC_PATH)/tcg/s390 $cflags"
2661 else
2662 cflags="-I\$(SRC_PATH)/tcg/\$(ARCH) $cflags"
2664 cflags="-I\$(SRC_PATH)/tcg $cflags"
2665 cflags="-I\$(SRC_PATH)/fpu $cflags"
2667 for i in $ARCH $TARGET_BASE_ARCH ; do
2668 case "$i" in
2669 alpha)
2670 echo "CONFIG_ALPHA_DIS=y" >> $config_target_mak
2672 arm)
2673 echo "CONFIG_ARM_DIS=y" >> $config_target_mak
2675 cris)
2676 echo "CONFIG_CRIS_DIS=y" >> $config_target_mak
2678 hppa)
2679 echo "CONFIG_HPPA_DIS=y" >> $config_target_mak
2681 i386|x86_64)
2682 echo "CONFIG_I386_DIS=y" >> $config_target_mak
2684 m68k)
2685 echo "CONFIG_M68K_DIS=y" >> $config_target_mak
2687 microblaze)
2688 echo "CONFIG_MICROBLAZE_DIS=y" >> $config_target_mak
2690 mips*)
2691 echo "CONFIG_MIPS_DIS=y" >> $config_target_mak
2693 ppc*)
2694 echo "CONFIG_PPC_DIS=y" >> $config_target_mak
2696 s390*)
2697 echo "CONFIG_S390_DIS=y" >> $config_target_mak
2699 sh4)
2700 echo "CONFIG_SH4_DIS=y" >> $config_target_mak
2702 sparc*)
2703 echo "CONFIG_SPARC_DIS=y" >> $config_target_mak
2705 esac
2706 done
2708 case "$ARCH" in
2709 alpha)
2710 # Ensure there's only a single GP
2711 cflags="-msmall-data $cflags"
2713 ia64)
2714 cflags="-mno-sdata $cflags"
2716 esac
2718 if test "$target_softmmu" = "yes" ; then
2719 case "$TARGET_BASE_ARCH" in
2720 arm)
2721 cflags="-DHAS_AUDIO $cflags"
2723 i386|mips|ppc)
2724 cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags"
2726 esac
2729 if test "$target_user_only" = "yes" -a "$static" = "no" -a \
2730 "$user_pie" = "yes" ; then
2731 cflags="-fpie $cflags"
2732 ldflags="-pie $ldflags"
2735 if test "$target_softmmu" = "yes" -a \( \
2736 "$TARGET_ARCH" = "microblaze" -o \
2737 "$TARGET_ARCH" = "cris" \) ; then
2738 echo "CONFIG_NEED_MMU=y" >> $config_target_mak
2741 if test "$gprof" = "yes" ; then
2742 echo "TARGET_GPROF=yes" >> $config_target_mak
2743 if test "$target_linux_user" = "yes" ; then
2744 cflags="-p $cflags"
2745 ldflags="-p $ldflags"
2747 if test "$target_softmmu" = "yes" ; then
2748 ldflags="-p $ldflags"
2749 echo "GPROF_CFLAGS=-p" >> $config_target_mak
2753 linker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/\$(ARCH).ld"
2754 if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
2755 case "$ARCH" in
2756 sparc)
2757 # -static is used to avoid g1/g3 usage by the dynamic linker
2758 ldflags="$linker_script -static $ldflags"
2760 ia64)
2761 ldflags="-Wl,-G0 $linker_script -static $ldflags"
2763 i386|x86_64|ppc|ppc64|s390|sparc64|alpha|arm|m68k|mips|mips64)
2764 ldflags="$linker_script $ldflags"
2766 esac
2768 if test "$target_softmmu" = "yes" ; then
2769 case "$ARCH" in
2770 ia64)
2771 ldflags="-Wl,-G0 $linker_script -static $ldflags"
2773 esac
2776 echo "LDFLAGS+=$ldflags" >> $config_target_mak
2777 echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak
2779 done # for target in $targets
2781 # build tree in object directory if source path is different from current one
2782 if test "$source_path_used" = "yes" ; then
2783 DIRS="tests tests/cris slirp audio block net pc-bios/optionrom"
2784 DIRS="$DIRS roms/pcbios roms/seabios roms/vgabios"
2785 FILES="Makefile tests/Makefile"
2786 FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
2787 FILES="$FILES tests/test-mmap.c"
2788 FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps pc-bios/video.x"
2789 FILES="$FILES roms/pcbios/Makefile roms/seabios/Makefile roms/vgabios/Makefile"
2790 for bios_file in $source_path/pc-bios/*.bin $source_path/pc-bios/*.dtb $source_path/pc-bios/openbios-*; do
2791 FILES="$FILES pc-bios/`basename $bios_file`"
2792 done
2793 for dir in $DIRS ; do
2794 mkdir -p $dir
2795 done
2796 # remove the link and recreate it, as not all "ln -sf" overwrite the link
2797 for f in $FILES ; do
2798 rm -f $f
2799 ln -s $source_path/$f $f
2800 done
2803 # temporary config to build submodules
2804 for rom in seabios vgabios pcbios; do
2805 config_mak=roms/$rom/config.mak
2806 echo "# Automatically generated by configure - do not modify" >> $config_mak
2807 echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
2808 echo "CC=$cc" >> $config_mak
2809 echo "BCC=bcc" >> $config_mak
2810 echo "CPP=${cross_prefix}cpp" >> $config_mak
2811 echo "OBJCOPY=objcopy" >> $config_mak
2812 echo "IASL=iasl" >> $config_mak
2813 echo "HOST_CC=$host_cc" >> $config_mak
2814 echo "LD=$ld" >> $config_mak
2815 done
2817 for hwlib in 32 64; do
2818 d=libhw$hwlib
2819 mkdir -p $d
2820 rm -f $d/Makefile
2821 ln -s $source_path/Makefile.hw $d/Makefile
2822 echo "HWLIB=libqemuhw$hwlib.a" > $d/config.mak
2823 echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" >> $d/config.mak
2824 done
2826 d=libuser
2827 mkdir -p $d
2828 rm -f $d/Makefile
2829 ln -s $source_path/Makefile.user $d/Makefile