Merge commit '731c54f86988d3f28268f184fabfe9b2a32fb5d3' into upstream-merge
[qemu-kvm/amd-iommu.git] / configure
blob3153cc6701b78f0ec06beeb742df5631191e0cf9
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=""
232 kvm_cap_device_assignment=""
233 kerneldir=""
234 aix="no"
235 blobs="yes"
236 pkgversion=" ($(kvm_version))"
237 cpu_emulation="yes"
238 kvm_kmod="no"
239 check_utests="no"
240 user_pie="no"
242 # OS specific
243 if check_define __linux__ ; then
244 targetos="Linux"
245 elif check_define _WIN32 ; then
246 targetos='MINGW32'
247 elif check_define __OpenBSD__ ; then
248 targetos='OpenBSD'
249 elif check_define __sun__ ; then
250 targetos='SunOS'
251 else
252 targetos=`uname -s`
255 case $targetos in
256 CYGWIN*)
257 mingw32="yes"
258 QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
259 audio_possible_drivers="sdl"
261 MINGW32*)
262 mingw32="yes"
263 audio_possible_drivers="dsound sdl fmod"
265 GNU/kFreeBSD)
266 audio_drv_list="oss"
267 audio_possible_drivers="oss sdl esd pa"
269 FreeBSD)
270 bsd="yes"
271 audio_drv_list="oss"
272 audio_possible_drivers="oss sdl esd pa"
274 DragonFly)
275 bsd="yes"
276 audio_drv_list="oss"
277 audio_possible_drivers="oss sdl esd pa"
279 NetBSD)
280 bsd="yes"
281 audio_drv_list="oss"
282 audio_possible_drivers="oss sdl esd"
283 oss_lib="-lossaudio"
285 OpenBSD)
286 bsd="yes"
287 audio_drv_list="oss"
288 audio_possible_drivers="oss sdl esd"
289 oss_lib="-lossaudio"
291 Darwin)
292 bsd="yes"
293 darwin="yes"
294 # on Leopard most of the system is 32-bit, so we have to ask the kernel it if we can
295 # run 64-bit userspace code
296 if [ "$cpu" = "i386" ] ; then
297 is_x86_64=`sysctl -n hw.optional.x86_64`
298 [ "$is_x86_64" = "1" ] && cpu=x86_64
300 if [ "$cpu" = "x86_64" ] ; then
301 QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
302 LDFLAGS="-arch x86_64 $LDFLAGS"
303 else
304 QEMU_CFLAGS="-mdynamic-no-pic $QEMU_CFLAGS"
306 darwin_user="yes"
307 cocoa="yes"
308 audio_drv_list="coreaudio"
309 audio_possible_drivers="coreaudio sdl fmod"
310 LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
311 libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
313 SunOS)
314 solaris="yes"
315 make="gmake"
316 install="ginstall"
317 needs_libsunmath="no"
318 solarisrev=`uname -r | cut -f2 -d.`
319 # have to select again, because `uname -m` returns i86pc
320 # even on an x86_64 box.
321 solariscpu=`isainfo -k`
322 if test "${solariscpu}" = "amd64" ; then
323 cpu="x86_64"
325 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
326 if test "$solarisrev" -le 9 ; then
327 if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
328 needs_libsunmath="yes"
329 QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
330 LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
331 LIBS="-lsunmath $LIBS"
332 else
333 echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
334 echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
335 echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
336 echo "Studio 11 can be downloaded from www.sun.com."
337 exit 1
341 if test -f /usr/include/sys/soundcard.h ; then
342 audio_drv_list="oss"
344 audio_possible_drivers="oss sdl"
345 # needed for CMSG_ macros in sys/socket.h
346 QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
347 # needed for TIOCWIN* defines in termios.h
348 QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
349 QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
350 LIBS="-lsocket -lnsl -lresolv $LIBS"
352 AIX)
353 aix="yes"
354 make="gmake"
357 audio_drv_list="oss"
358 audio_possible_drivers="oss alsa sdl esd pa"
359 linux="yes"
360 linux_user="yes"
361 usb="linux"
362 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
363 audio_possible_drivers="$audio_possible_drivers fmod"
365 if [ "$cpu" = "ia64" ] ; then
366 xen="no"
367 target_list="ia64-softmmu"
368 cpu_emulation="no"
369 gdbstub="no"
370 slirp="no"
373 esac
375 if [ "$bsd" = "yes" ] ; then
376 if [ "$darwin" != "yes" ] ; then
377 make="gmake"
378 usb="bsd"
380 bsd_user="yes"
383 if test "$mingw32" = "yes" ; then
384 EXESUF=".exe"
385 QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
386 LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
389 # find source path
390 source_path=`dirname "$0"`
391 source_path_used="no"
392 workdir=`pwd`
393 if [ -z "$source_path" ]; then
394 source_path=$workdir
395 else
396 source_path=`cd "$source_path"; pwd`
398 [ -f "$workdir/vl.c" ] || source_path_used="yes"
400 werror=""
402 for opt do
403 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
404 case "$opt" in
405 --help|-h) show_help=yes
407 --prefix=*) prefix="$optarg"
409 --interp-prefix=*) interp_prefix="$optarg"
411 --source-path=*) source_path="$optarg"
412 source_path_used="yes"
414 --cross-prefix=*)
416 --cc=*)
418 --host-cc=*) host_cc="$optarg"
420 --make=*) make="$optarg"
422 --install=*) install="$optarg"
424 --extra-cflags=*)
426 --extra-ldflags=*)
428 --cpu=*)
430 --target-list=*) target_list="$optarg"
432 --enable-gprof) gprof="yes"
434 --static) static="yes"
436 --disable-sdl) sdl="no"
438 --enable-sdl) sdl="yes"
440 --fmod-lib=*) fmod_lib="$optarg"
442 --fmod-inc=*) fmod_inc="$optarg"
444 --oss-lib=*) oss_lib="$optarg"
446 --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
448 --audio-drv-list=*) audio_drv_list="$optarg"
450 --enable-debug-tcg) debug_tcg="yes"
452 --disable-debug-tcg) debug_tcg="no"
454 --enable-debug)
455 # Enable debugging options that aren't excessively noisy
456 debug_tcg="yes"
457 debug="yes"
458 strip_opt="no"
460 --enable-sparse) sparse="yes"
462 --disable-sparse) sparse="no"
464 --disable-strip) strip_opt="no"
466 --disable-vnc-tls) vnc_tls="no"
468 --enable-vnc-tls) vnc_tls="yes"
470 --disable-vnc-sasl) vnc_sasl="no"
472 --enable-vnc-sasl) vnc_sasl="yes"
474 --disable-slirp) slirp="no"
476 --disable-vde) vde="no"
478 --enable-vde) vde="yes"
480 --disable-xen) xen="no"
482 --enable-xen) xen="yes"
484 --disable-brlapi) brlapi="no"
486 --enable-brlapi) brlapi="yes"
488 --disable-bluez) bluez="no"
490 --enable-bluez) bluez="yes"
492 --disable-kvm) kvm="no"
494 --enable-kvm) kvm="yes"
496 --disable-kvm-cap-pit) kvm_cap_pit="no"
498 --enable-kvm-cap-pit) kvm_cap_pit="yes"
500 --disable-kvm-cap-device-assignment) kvm_cap_device_assignment="no"
502 --enable-kvm-cap-device-assignment) kvm_cap_device_assignment="yes"
504 --enable-profiler) profiler="yes"
506 --enable-cocoa)
507 cocoa="yes" ;
508 sdl="no" ;
509 audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
511 --disable-system) softmmu="no"
513 --enable-system) softmmu="yes"
515 --disable-user)
516 linux_user="no" ;
517 bsd_user="no" ;
518 darwin_user="no"
520 --enable-user) ;;
521 --disable-linux-user) linux_user="no"
523 --enable-linux-user) linux_user="yes"
525 --disable-darwin-user) darwin_user="no"
527 --enable-darwin-user) darwin_user="yes"
529 --disable-bsd-user) bsd_user="no"
531 --enable-bsd-user) bsd_user="yes"
533 --enable-guest-base) guest_base="yes"
535 --disable-guest-base) guest_base="no"
537 --enable-user-pie) user_pie="yes"
539 --disable-user-pie) user_pie="no"
541 --enable-uname-release=*) uname_release="$optarg"
543 --sparc_cpu=*)
545 --enable-werror) werror="yes"
547 --disable-werror) werror="no"
549 --disable-curses) curses="no"
551 --enable-curses) curses="yes"
553 --disable-curl) curl="no"
555 --enable-curl) curl="yes"
557 --disable-fdt) fdt="no"
559 --enable-fdt) fdt="yes"
561 --disable-check-utests) check_utests="no"
563 --enable-check-utests) check_utests="yes"
565 --disable-nptl) nptl="no"
567 --enable-nptl) nptl="yes"
569 --enable-mixemu) mixemu="yes"
571 --disable-linux-aio) linux_aio="no"
573 --enable-linux-aio) linux_aio="yes"
575 --enable-io-thread) io_thread="yes"
577 --disable-blobs) blobs="no"
579 --kerneldir=*) kerneldir="$optarg"
581 --with-kvm-trace) kvm_trace="yes"
583 --with-pkgversion=*) pkgversion=" ($optarg)"
585 --disable-docs) docs="no"
587 --enable-docs) docs="yes"
589 --disable-cpu-emulation) cpu_emulation="no"
591 *) echo "ERROR: unknown option $opt"; show_help="yes"
593 esac
594 done
597 # If cpu ~= sparc and sparc_cpu hasn't been defined, plug in the right
598 # QEMU_CFLAGS/LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
600 host_guest_base="no"
601 case "$cpu" in
602 sparc) case $sparc_cpu in
603 v7|v8)
604 QEMU_CFLAGS="-mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
606 v8plus|v8plusa)
607 QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
609 *) # sparc_cpu not defined in the command line
610 QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_v8plus__ $QEMU_CFLAGS"
611 esac
612 LDFLAGS="-m32 $LDFLAGS"
613 QEMU_CFLAGS="-m32 -ffixed-g2 -ffixed-g3 $QEMU_CFLAGS"
614 if test "$solaris" = "no" ; then
615 QEMU_CFLAGS="-ffixed-g1 -ffixed-g6 $QEMU_CFLAGS"
616 helper_cflags="-ffixed-i0"
619 sparc64)
620 QEMU_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__ $QEMU_CFLAGS"
621 LDFLAGS="-m64 $LDFLAGS"
622 QEMU_CFLAGS="-ffixed-g5 -ffixed-g6 -ffixed-g7 $QEMU_CFLAGS"
623 if test "$solaris" != "no" ; then
624 QEMU_CFLAGS="-ffixed-g1 $QEMU_CFLAGS"
627 s390)
628 QEMU_CFLAGS="-march=z900 $QEMU_CFLAGS"
630 i386)
631 QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
632 LDFLAGS="-m32 $LDFLAGS"
633 helper_cflags="-fomit-frame-pointer"
634 host_guest_base="yes"
636 x86_64)
637 QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
638 LDFLAGS="-m64 $LDFLAGS"
639 host_guest_base="yes"
641 arm*)
642 host_guest_base="yes"
644 ppc*)
645 host_guest_base="yes"
647 esac
649 [ -z "$guest_base" ] && guest_base="$host_guest_base"
651 if test x"$show_help" = x"yes" ; then
652 cat << EOF
654 Usage: configure [options]
655 Options: [defaults in brackets after descriptions]
658 echo "Standard options:"
659 echo " --help print this message"
660 echo " --prefix=PREFIX install in PREFIX [$prefix]"
661 echo " --interp-prefix=PREFIX where to find shared libraries, etc."
662 echo " use %M for cpu name [$interp_prefix]"
663 echo " --target-list=LIST set target list [$target_list]"
664 echo ""
665 echo "Advanced options (experts only):"
666 echo " --source-path=PATH path of source code [$source_path]"
667 echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
668 echo " --cc=CC use C compiler CC [$cc]"
669 echo " --host-cc=CC use C compiler CC [$host_cc] for dyngen etc."
670 echo " --extra-cflags=CFLAGS append extra C compiler flags QEMU_CFLAGS"
671 echo " --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS"
672 echo " --make=MAKE use specified make [$make]"
673 echo " --install=INSTALL use specified install [$install]"
674 echo " --static enable static build [$static]"
675 echo " --enable-debug-tcg enable TCG debugging"
676 echo " --disable-debug-tcg disable TCG debugging (default)"
677 echo " --enable-debug enable common debug build options"
678 echo " --enable-sparse enable sparse checker"
679 echo " --disable-sparse disable sparse checker (default)"
680 echo " --disable-strip disable stripping binaries"
681 echo " --disable-werror disable compilation abort on warning"
682 echo " --disable-sdl disable SDL"
683 echo " --enable-sdl enable SDL"
684 echo " --enable-cocoa enable COCOA (Mac OS X only)"
685 echo " --audio-drv-list=LIST set audio drivers list:"
686 echo " Available drivers: $audio_possible_drivers"
687 echo " --audio-card-list=LIST set list of emulated audio cards [$audio_card_list]"
688 echo " Available cards: $audio_possible_cards"
689 echo " --enable-mixemu enable mixer emulation"
690 echo " --disable-xen disable xen backend driver support"
691 echo " --enable-xen enable xen backend driver support"
692 echo " --disable-brlapi disable BrlAPI"
693 echo " --enable-brlapi enable BrlAPI"
694 echo " --disable-vnc-tls disable TLS encryption for VNC server"
695 echo " --enable-vnc-tls enable TLS encryption for VNC server"
696 echo " --disable-vnc-sasl disable SASL encryption for VNC server"
697 echo " --enable-vnc-sasl enable SASL encryption for VNC server"
698 echo " --disable-curses disable curses output"
699 echo " --enable-curses enable curses output"
700 echo " --disable-curl disable curl connectivity"
701 echo " --enable-curl enable curl connectivity"
702 echo " --disable-fdt disable fdt device tree"
703 echo " --enable-fdt enable fdt device tree"
704 echo " --disable-check-utests disable check unit-tests"
705 echo " --enable-check-utests enable check unit-tests"
706 echo " --disable-bluez disable bluez stack connectivity"
707 echo " --enable-bluez enable bluez stack connectivity"
708 echo " --disable-kvm disable KVM acceleration support"
709 echo " --enable-kvm enable KVM acceleration support"
710 echo " --disable-cap-kvm-pit disable KVM pit support"
711 echo " --enable-cap-kvm-pit enable KVM pit support"
712 echo " --disable-cap-device-assignment disable KVM device assignment support"
713 echo " --enable-cap-device-assignment enable KVM device assignment support"
714 echo " --disable-nptl disable usermode NPTL support"
715 echo " --enable-nptl enable usermode NPTL support"
716 echo " --enable-system enable all system emulation targets"
717 echo " --disable-system disable all system emulation targets"
718 echo " --enable-user enable supported user emulation targets"
719 echo " --disable-user disable all user emulation targets"
720 echo " --enable-linux-user enable all linux usermode emulation targets"
721 echo " --disable-linux-user disable all linux usermode emulation targets"
722 echo " --enable-darwin-user enable all darwin usermode emulation targets"
723 echo " --disable-darwin-user disable all darwin usermode emulation targets"
724 echo " --enable-bsd-user enable all BSD usermode emulation targets"
725 echo " --disable-bsd-user disable all BSD usermode emulation targets"
726 echo " --enable-guest-base enable GUEST_BASE support for usermode"
727 echo " emulation targets"
728 echo " --disable-guest-base disable GUEST_BASE support"
729 echo " --enable-user-pie build usermode emulation targets as PIE"
730 echo " --disable-user-pie do not build usermode emulation targets as PIE"
731 echo " --fmod-lib path to FMOD library"
732 echo " --fmod-inc path to FMOD includes"
733 echo " --oss-lib path to OSS library"
734 echo " --enable-uname-release=R Return R for uname -r in usermode emulation"
735 echo " --sparc_cpu=V Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
736 echo " --disable-vde disable support for vde network"
737 echo " --enable-vde enable support for vde network"
738 echo " --disable-linux-aio disable Linux AIO support"
739 echo " --enable-linux-aio enable Linux AIO support"
740 echo " --enable-io-thread enable IO thread"
741 echo " --disable-blobs disable installing provided firmware blobs"
742 echo " --kerneldir=PATH look for kernel includes in PATH"
743 echo " --with-kvm-trace enable building the KVM module with the kvm trace option"
744 echo " --disable-cpu-emulation disables use of qemu cpu emulation code"
745 echo ""
746 echo "NOTE: The object files are built at the place where configure is launched"
747 exit 1
751 # Solaris specific configure tool chain decisions
753 if test "$solaris" = "yes" ; then
754 solinst=`which $install 2> /dev/null | /usr/bin/grep -v "no $install in"`
755 if test -z "$solinst" ; then
756 echo "Solaris install program not found. Use --install=/usr/ucb/install or"
757 echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
758 echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
759 exit 1
761 if test "$solinst" = "/usr/sbin/install" ; then
762 echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
763 echo "try ginstall from the GNU fileutils available from www.blastwave.org"
764 echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
765 exit 1
767 sol_ar=`which ar 2> /dev/null | /usr/bin/grep -v "no ar in"`
768 if test -z "$sol_ar" ; then
769 echo "Error: No path includes ar"
770 if test -f /usr/ccs/bin/ar ; then
771 echo "Add /usr/ccs/bin to your path and rerun configure"
773 exit 1
778 if test -z "$target_list" ; then
779 # these targets are portable
780 if [ "$softmmu" = "yes" ] ; then
781 target_list="\
782 i386-softmmu \
783 x86_64-softmmu \
784 arm-softmmu \
785 cris-softmmu \
786 m68k-softmmu \
787 microblaze-softmmu \
788 mips-softmmu \
789 mipsel-softmmu \
790 mips64-softmmu \
791 mips64el-softmmu \
792 ppc-softmmu \
793 ppcemb-softmmu \
794 ppc64-softmmu \
795 sh4-softmmu \
796 sh4eb-softmmu \
797 sparc-softmmu \
798 sparc64-softmmu \
801 # the following are Linux specific
802 if [ "$linux_user" = "yes" ] ; then
803 target_list="${target_list}\
804 i386-linux-user \
805 x86_64-linux-user \
806 alpha-linux-user \
807 arm-linux-user \
808 armeb-linux-user \
809 cris-linux-user \
810 m68k-linux-user \
811 microblaze-linux-user \
812 mips-linux-user \
813 mipsel-linux-user \
814 ppc-linux-user \
815 ppc64-linux-user \
816 ppc64abi32-linux-user \
817 sh4-linux-user \
818 sh4eb-linux-user \
819 sparc-linux-user \
820 sparc64-linux-user \
821 sparc32plus-linux-user \
824 # the following are Darwin specific
825 if [ "$darwin_user" = "yes" ] ; then
826 target_list="$target_list i386-darwin-user ppc-darwin-user "
828 # the following are BSD specific
829 if [ "$bsd_user" = "yes" ] ; then
830 target_list="${target_list}\
831 i386-bsd-user \
832 x86_64-bsd-user \
833 sparc-bsd-user \
834 sparc64-bsd-user \
837 else
838 target_list=`echo "$target_list" | sed -e 's/,/ /g'`
840 if test -z "$target_list" ; then
841 echo "No targets enabled"
842 exit 1
845 feature_not_found() {
846 feature=$1
848 echo "ERROR"
849 echo "ERROR: User requested feature $feature"
850 echo "ERROR: configure was not able to find it"
851 echo "ERROR"
852 exit 1;
855 if test -z "$cross_prefix" ; then
857 # ---
858 # big/little endian test
859 cat > $TMPC << EOF
860 #include <inttypes.h>
861 int main(int argc, char ** argv){
862 volatile uint32_t i=0x01234567;
863 return (*((uint8_t*)(&i))) == 0x67;
867 if compile_prog "" "" ; then
868 $TMPE && bigendian="yes"
869 else
870 echo big/little test failed
873 else
875 # if cross compiling, cannot launch a program, so make a static guess
876 case "$cpu" in
877 armv4b|hppa|m68k|mips|mips64|ppc|ppc64|s390|sparc|sparc64)
878 bigendian=yes
880 esac
884 # host long bits test
885 hostlongbits="32"
886 case "$cpu" in
887 x86_64|alpha|ia64|sparc64|ppc64)
888 hostlongbits=64
890 esac
893 ##########################################
894 # NPTL probe
896 if test "$nptl" != "no" ; then
897 cat > $TMPC <<EOF
898 #include <sched.h>
899 #include <linux/futex.h>
900 void foo()
902 #if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
903 #error bork
904 #endif
908 if compile_object ; then
909 nptl=yes
910 else
911 if test "$nptl" = "yes" ; then
912 feature_not_found "nptl"
914 nptl=no
918 ##########################################
919 # zlib check
921 cat > $TMPC << EOF
922 #include <zlib.h>
923 int main(void) { zlibVersion(); return 0; }
925 if compile_prog "" "-lz" ; then
927 else
928 echo
929 echo "Error: zlib check failed"
930 echo "Make sure to have the zlib libs and headers installed."
931 echo
932 exit 1
935 ##########################################
936 # xen probe
938 if test "$xen" != "no" ; then
939 xen_libs="-lxenstore -lxenctrl -lxenguest"
940 cat > $TMPC <<EOF
941 #include <xenctrl.h>
942 #include <xs.h>
943 int main(void) { xs_daemon_open(); xc_interface_open(); return 0; }
945 if compile_prog "" "$xen_libs" ; then
946 xen=yes
947 libs_softmmu="$xen_libs $libs_softmmu"
948 else
949 if test "$xen" = "yes" ; then
950 feature_not_found "xen"
952 xen=no
956 ##########################################
957 # Sparse probe
958 if test "$sparse" != "no" ; then
959 if test -x "$(which cgcc 2>/dev/null)"; then
960 sparse=yes
961 else
962 if test "$sparse" = "yes" ; then
963 feature_not_found "sparse"
965 sparse=no
969 ##########################################
970 # SDL probe
972 sdl_too_old=no
974 if test "$sdl" != "no" ; then
975 cat > $TMPC << EOF
976 #include <SDL.h>
977 #undef main /* We don't want SDL to override our main() */
978 int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
980 sdl_cflags=`sdl-config --cflags 2> /dev/null`
981 sdl_libs=`sdl-config --libs 2> /dev/null`
982 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
983 _sdlversion=`sdl-config --version | sed 's/[^0-9]//g'`
984 if test "$_sdlversion" -lt 121 ; then
985 sdl_too_old=yes
986 else
987 if test "$cocoa" = "no" ; then
988 sdl=yes
992 # static link with sdl ?
993 if test "$sdl" = "yes" -a "$static" = "yes" ; then
994 sdl_libs=`sdl-config --static-libs 2>/dev/null`
995 if test `sdl-config --static-libs 2>/dev/null | grep \\\-laa > /dev/null` ; then
996 sdl_libs="$sdl_libs `aalib-config --static-libs >2 /dev/null`"
997 sdl_cflags="$sd_cflags `aalib-config --cflags >2 /dev/null`"
999 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1001 else
1002 sdl=no
1004 fi # static link
1005 else # sdl not found
1006 if test "$sdl" = "yes" ; then
1007 feature_not_found "sdl"
1009 sdl=no
1010 fi # sdl compile test
1013 if test "$sdl" = "yes" ; then
1014 cat > $TMPC <<EOF
1015 #include <SDL.h>
1016 #if defined(SDL_VIDEO_DRIVER_X11)
1017 #include <X11/XKBlib.h>
1018 #else
1019 #error No x11 support
1020 #endif
1021 int main(void) { return 0; }
1023 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1024 sdl_libs="$sdl_libs -lX11"
1026 if test "$mingw32" = "yes" ; then
1027 sdl_libs="`echo $sdl_libs | sed s/-mwindows//g` -mconsole"
1029 libs_softmmu="$sdl_libs $libs_softmmu"
1032 ##########################################
1033 # VNC TLS detection
1034 if test "$vnc_tls" != "no" ; then
1035 cat > $TMPC <<EOF
1036 #include <gnutls/gnutls.h>
1037 int main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
1039 vnc_tls_cflags=`pkg-config --cflags gnutls 2> /dev/null`
1040 vnc_tls_libs=`pkg-config --libs gnutls 2> /dev/null`
1041 if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
1042 vnc_tls=yes
1043 libs_softmmu="$vnc_tls_libs $libs_softmmu"
1044 else
1045 if test "$vnc_tls" = "yes" ; then
1046 feature_not_found "vnc-tls"
1048 vnc_tls=no
1052 ##########################################
1053 # VNC SASL detection
1054 if test "$vnc_sasl" != "no" ; then
1055 cat > $TMPC <<EOF
1056 #include <sasl/sasl.h>
1057 #include <stdio.h>
1058 int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
1060 # Assuming Cyrus-SASL installed in /usr prefix
1061 vnc_sasl_cflags=""
1062 vnc_sasl_libs="-lsasl2"
1063 if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1064 vnc_sasl=yes
1065 libs_softmmu="$vnc_sasl_libs $libs_softmmu"
1066 else
1067 if test "$vnc_sasl" = "yes" ; then
1068 feature_not_found "vnc-sasl"
1070 vnc_sasl=no
1074 ##########################################
1075 # fnmatch() probe, used for ACL routines
1076 fnmatch="no"
1077 cat > $TMPC << EOF
1078 #include <fnmatch.h>
1079 int main(void)
1081 fnmatch("foo", "foo", 0);
1082 return 0;
1085 if compile_prog "" "" ; then
1086 fnmatch="yes"
1089 ##########################################
1090 # vde libraries probe
1091 if test "$vde" != "no" ; then
1092 vde_libs="-lvdeplug"
1093 cat > $TMPC << EOF
1094 #include <libvdeplug.h>
1095 int main(void)
1097 struct vde_open_args a = {0, 0, 0};
1098 vde_open("", "", &a);
1099 return 0;
1102 if compile_prog "" "$vde_libs" ; then
1103 vde=yes
1104 libs_softmmu="$vde_libs $libs_softmmu"
1105 libs_tools="$vde_libs $libs_tools"
1106 else
1107 if test "$vde" = "yes" ; then
1108 feature_not_found "vde"
1110 vde=no
1114 ##########################################
1115 # Sound support libraries probe
1117 audio_drv_probe()
1119 drv=$1
1120 hdr=$2
1121 lib=$3
1122 exp=$4
1123 cfl=$5
1124 cat > $TMPC << EOF
1125 #include <$hdr>
1126 int main(void) { $exp }
1128 if compile_prog "$cfl" "$lib" ; then
1130 else
1131 echo
1132 echo "Error: $drv check failed"
1133 echo "Make sure to have the $drv libs and headers installed."
1134 echo
1135 exit 1
1139 audio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
1140 for drv in $audio_drv_list; do
1141 case $drv in
1142 alsa)
1143 audio_drv_probe $drv alsa/asoundlib.h -lasound \
1144 "snd_pcm_t **handle; return snd_pcm_close(*handle);"
1145 libs_softmmu="-lasound $libs_softmmu"
1148 fmod)
1149 if test -z $fmod_lib || test -z $fmod_inc; then
1150 echo
1151 echo "Error: You must specify path to FMOD library and headers"
1152 echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
1153 echo
1154 exit 1
1156 audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
1157 libs_softmmu="$fmod_lib $libs_softmmu"
1160 esd)
1161 audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
1162 libs_softmmu="-lesd $libs_softmmu"
1163 audio_pt_int="yes"
1167 audio_drv_probe $drv pulse/simple.h -lpulse-simple \
1168 "pa_simple *s = NULL; pa_simple_free(s); return 0;"
1169 libs_softmmu="-lpulse-simple $libs_softmmu"
1170 audio_pt_int="yes"
1173 coreaudio)
1174 libs_softmmu="-framework CoreAudio $libs_softmmu"
1177 dsound)
1178 libs_softmmu="-lole32 -ldxguid $libs_softmmu"
1181 oss)
1182 libs_softmmu="$oss_lib $libs_softmmu"
1185 sdl|wav)
1186 # XXX: Probes for CoreAudio, DirectSound, SDL(?)
1190 echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
1191 echo
1192 echo "Error: Unknown driver '$drv' selected"
1193 echo "Possible drivers are: $audio_possible_drivers"
1194 echo
1195 exit 1
1198 esac
1199 done
1201 ##########################################
1202 # BrlAPI probe
1204 if test "$brlapi" != "no" ; then
1205 brlapi_libs="-lbrlapi"
1206 cat > $TMPC << EOF
1207 #include <brlapi.h>
1208 int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
1210 if compile_prog "" "$brlapi_libs" ; then
1211 brlapi=yes
1212 libs_softmmu="$brlapi_libs $libs_softmmu"
1213 else
1214 if test "$brlapi" = "yes" ; then
1215 feature_not_found "brlapi"
1217 brlapi=no
1221 ##########################################
1222 # curses probe
1223 curses_list="-lncurses -lcurses"
1225 if test "$curses" != "no" ; then
1226 curses_found=no
1227 cat > $TMPC << EOF
1228 #include <curses.h>
1229 #ifdef __OpenBSD__
1230 #define resize_term resizeterm
1231 #endif
1232 int main(void) { resize_term(0, 0); return curses_version(); }
1234 for curses_lib in $curses_list; do
1235 if compile_prog "" "$curses_lib" ; then
1236 curses_found=yes
1237 libs_softmmu="$curses_lib $libs_softmmu"
1238 break
1240 done
1241 if test "$curses_found" = "yes" ; then
1242 curses=yes
1243 else
1244 if test "$curses" = "yes" ; then
1245 feature_not_found "curses"
1247 curses=no
1251 ##########################################
1252 # curl probe
1254 if test "$curl" != "no" ; then
1255 cat > $TMPC << EOF
1256 #include <curl/curl.h>
1257 int main(void) { return curl_easy_init(); }
1259 curl_cflags=`curl-config --cflags 2>/dev/null`
1260 curl_libs=`curl-config --libs 2>/dev/null`
1261 if compile_prog "$curl_cflags" "$curl_libs" ; then
1262 curl=yes
1263 libs_tools="$curl_libs $libs_tools"
1264 libs_softmmu="$curl_libs $libs_softmmu"
1265 else
1266 if test "$curl" = "yes" ; then
1267 feature_not_found "curl"
1269 curl=no
1271 fi # test "$curl"
1273 ##########################################
1274 # check framework probe
1276 if test "$check_utests" != "no" ; then
1277 cat > $TMPC << EOF
1278 #include <check.h>
1279 int main(void) { suite_create("qemu test"); return 0; }
1281 check_libs=`pkg-config --libs check`
1282 if compile_prog "" $check_libs ; then
1283 check_utests=yes
1284 libs_tools="$check_libs $libs_tools"
1285 else
1286 if test "$check_utests" = "yes" ; then
1287 feature_not_found "check"
1289 check_utests=no
1291 fi # test "$check_utests"
1293 ##########################################
1294 # bluez support probe
1295 if test "$bluez" != "no" ; then
1296 cat > $TMPC << EOF
1297 #include <bluetooth/bluetooth.h>
1298 int main(void) { return bt_error(0); }
1300 bluez_cflags=`pkg-config --cflags bluez 2> /dev/null`
1301 bluez_libs=`pkg-config --libs bluez 2> /dev/null`
1302 if compile_prog "$bluez_cflags" "$bluez_libs" ; then
1303 bluez=yes
1304 libs_softmmu="$bluez_libs $libs_softmmu"
1305 else
1306 if test "$bluez" = "yes" ; then
1307 feature_not_found "bluez"
1309 bluez="no"
1313 ##########################################
1314 # kvm probe
1315 if test "$kvm" != "no" ; then
1316 case "$cpu" in
1317 i386 | x86_64)
1318 kvm_arch="x86"
1320 ppc)
1321 kvm_arch="powerpc"
1324 kvm_arch="$cpu"
1326 esac
1328 kvm_cflags="-I$source_path/kvm/include"
1329 kvm_cflags="$kvm_cflags -I$source_path/kvm/include/$kvm_arch"
1330 kvm_cflags="$kvm_cflags -idirafter $source_path/compat"
1332 cat > $TMPC <<EOF
1333 #include <linux/kvm.h>
1334 #if !defined(KVM_API_VERSION) || KVM_API_VERSION < 12 || KVM_API_VERSION > 12
1335 #error Invalid KVM version
1336 #endif
1337 #if !defined(KVM_CAP_USER_MEMORY)
1338 #error Missing KVM capability KVM_CAP_USER_MEMORY
1339 #endif
1340 #if !defined(KVM_CAP_SET_TSS_ADDR)
1341 #error Missing KVM capability KVM_CAP_SET_TSS_ADDR
1342 #endif
1343 #if !defined(KVM_CAP_DESTROY_MEMORY_REGION_WORKS)
1344 #error Missing KVM capability KVM_CAP_DESTROY_MEMORY_REGION_WORKS
1345 #endif
1346 int main(void) { return 0; }
1348 if compile_prog "$kvm_cflags" "" ; then
1349 kvm=yes
1350 else
1351 if test "$kvm" = "yes" ; then
1352 if [ -x "`which awk 2>/dev/null`" ] && \
1353 [ -x "`which grep 2>/dev/null`" ]; then
1354 kvmerr=`LANG=C $cc $QEMU_CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&1 \
1355 | grep "error: " \
1356 | awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'`
1357 if test "$kvmerr" != "" ; then
1358 echo -e "${kvmerr}\n\
1359 NOTE: To enable KVM support, update your kernel to 2.6.29+ or install \
1360 recent kvm-kmod from http://sourceforge.net/projects/kvm."
1363 feature_not_found "kvm"
1365 kvm=no
1369 ##########################################
1370 # test for KVM_CAP_PIT
1372 if test "$kvm_cap_pit" != "no" ; then
1373 if test "$kvm" = "no" -a "$kvm_cap_pit" = "yes" ; then
1374 feature_not_found "kvm_cap_pit (kvm is not enabled)"
1376 cat > $TMPC <<EOF
1377 #include <linux/kvm.h>
1378 #ifndef KVM_CAP_PIT
1379 #error "kvm no pit capability"
1380 #endif
1381 int main(void) { return 0; }
1383 if compile_prog $kvm_cflags ""; then
1384 kvm_cap_pit=yes
1385 else
1386 if test "$kvm_cap_pit" = "yes" ; then
1387 feature_not_found "kvm_cap_pit"
1389 kvm_cap_pit=no
1393 ##########################################
1394 # test for KVM_CAP_DEVICE_ASSIGNMENT
1396 if test "$kvm_cap_device_assignment" != "no" ; then
1397 if test "$kvm" = "no" -a "$kvm_cap_device_assignment" = "yes" ; then
1398 feature_not_found "kvm_cap_device_assignment (kvm is not enabled)"
1400 cat > $TMPC <<EOF
1401 #include <linux/kvm.h>
1402 #ifndef KVM_CAP_DEVICE_ASSIGNMENT
1403 #error "kvm no device assignment capability"
1404 #endif
1405 int main(void) { return 0; }
1407 if compile_prog $kvm_cflags "" ; then
1408 kvm_cap_device_assignment=yes
1409 else
1410 if test "$kvm_cap_device_assignment" = "yes" ; then
1411 feature_not_found "kvm_cap_device_assigment"
1413 kvm_cap_device_assignment=no
1417 ##########################################
1418 # libpci probe for kvm_cap_device_assignment
1419 if test $kvm_cap_device_assignment = "yes" ; then
1420 cat > $TMPC << EOF
1421 #include <pci/pci.h>
1422 #ifndef PCI_VENDOR_ID
1423 #error NO LIBPCI
1424 #endif
1425 int main(void) { struct pci_access a; pci_init(&a); return 0; }
1427 if compile_prog "" "-lpci" ; then
1428 libs_softmmu="-lpci $libs_softmmu"
1429 else
1430 echo
1431 echo "Error: libpci check failed"
1432 echo "Disable KVM Device Assignment capability."
1433 echo
1434 kvm_cap_device_assignment=no
1438 ##########################################
1439 # pthread probe
1440 PTHREADLIBS_LIST="-lpthread -lpthreadGC2"
1442 pthread=no
1443 cat > $TMPC << EOF
1444 #include <pthread.h>
1445 int main(void) { pthread_create(0,0,0,0); return 0; }
1447 for pthread_lib in $PTHREADLIBS_LIST; do
1448 if compile_prog "" "$pthread_lib" ; then
1449 pthread=yes
1450 LIBS="$pthread_lib $LIBS"
1451 break
1453 done
1455 if test "$mingw32" != yes -a "$pthread" = no; then
1456 echo
1457 echo "Error: pthread check failed"
1458 echo "Make sure to have the pthread libs and headers installed."
1459 echo
1460 exit 1
1463 ##########################################
1464 # linux-aio probe
1465 AIOLIBS=""
1467 if test "$linux_aio" != "no" ; then
1468 cat > $TMPC <<EOF
1469 #include <libaio.h>
1470 #include <sys/eventfd.h>
1471 int main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
1473 if compile_prog "" "-laio" ; then
1474 linux_aio=yes
1475 LIBS="$LIBS -laio"
1476 else
1477 if test "$linux_aio" = "yes" ; then
1478 feature_not_found "linux AIO"
1480 linux_aio=no
1484 ##########################################
1485 # iovec probe
1486 cat > $TMPC <<EOF
1487 #include <sys/types.h>
1488 #include <sys/uio.h>
1489 #include <unistd.h>
1490 int main(void) { struct iovec iov; return 0; }
1492 iovec=no
1493 if compile_prog "" "" ; then
1494 iovec=yes
1497 ##########################################
1498 # preadv probe
1499 cat > $TMPC <<EOF
1500 #include <sys/types.h>
1501 #include <sys/uio.h>
1502 #include <unistd.h>
1503 int main(void) { preadv; }
1505 preadv=no
1506 if compile_prog "" "" ; then
1507 preadv=yes
1510 ##########################################
1511 # fdt probe
1512 if test "$fdt" != "no" ; then
1513 fdt_libs="-lfdt"
1514 cat > $TMPC << EOF
1515 int main(void) { return 0; }
1517 if compile_prog "" "$fdt_libs" ; then
1518 fdt=yes
1519 libs_softmmu="$fdt_libs $libs_softmmu"
1520 else
1521 if test "$fdt" = "yes" ; then
1522 feature_not_found "fdt"
1524 fdt=no
1529 # Check for xxxat() functions when we are building linux-user
1530 # emulator. This is done because older glibc versions don't
1531 # have syscall stubs for these implemented.
1533 atfile=no
1534 cat > $TMPC << EOF
1535 #define _ATFILE_SOURCE
1536 #include <sys/types.h>
1537 #include <fcntl.h>
1538 #include <unistd.h>
1541 main(void)
1543 /* try to unlink nonexisting file */
1544 return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
1547 if compile_prog "" "" ; then
1548 atfile=yes
1551 # Check for inotify functions when we are building linux-user
1552 # emulator. This is done because older glibc versions don't
1553 # have syscall stubs for these implemented. In that case we
1554 # don't provide them even if kernel supports them.
1556 inotify=no
1557 cat > $TMPC << EOF
1558 #include <sys/inotify.h>
1561 main(void)
1563 /* try to start inotify */
1564 return inotify_init();
1567 if compile_prog "" "" ; then
1568 inotify=yes
1571 # check if utimensat and futimens are supported
1572 utimens=no
1573 cat > $TMPC << EOF
1574 #define _ATFILE_SOURCE
1575 #define _GNU_SOURCE
1576 #include <stddef.h>
1577 #include <fcntl.h>
1579 int main(void)
1581 utimensat(AT_FDCWD, "foo", NULL, 0);
1582 futimens(0, NULL);
1583 return 0;
1586 if compile_prog "" "" ; then
1587 utimens=yes
1590 # check if pipe2 is there
1591 pipe2=no
1592 cat > $TMPC << EOF
1593 #define _GNU_SOURCE
1594 #include <unistd.h>
1595 #include <fcntl.h>
1597 int main(void)
1599 int pipefd[2];
1600 pipe2(pipefd, O_CLOEXEC);
1601 return 0;
1604 if compile_prog "" "" ; then
1605 pipe2=yes
1608 # check if tee/splice is there. vmsplice was added same time.
1609 splice=no
1610 cat > $TMPC << EOF
1611 #define _GNU_SOURCE
1612 #include <unistd.h>
1613 #include <fcntl.h>
1614 #include <limits.h>
1616 int main(void)
1618 int len, fd;
1619 len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
1620 splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
1621 return 0;
1624 if compile_prog "" "" ; then
1625 splice=yes
1628 ##########################################
1629 # signalfd probe
1630 signalfd="no"
1631 cat > $TMPC << EOF
1632 #define _GNU_SOURCE
1633 #include <unistd.h>
1634 #include <sys/syscall.h>
1635 #include <signal.h>
1636 int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
1639 if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
1640 signalfd=yes
1643 # check if eventfd is supported
1644 eventfd=no
1645 cat > $TMPC << EOF
1646 #include <sys/eventfd.h>
1648 int main(void)
1650 int efd = eventfd(0, 0);
1651 return 0;
1654 if compile_prog "" "" ; then
1655 eventfd=yes
1658 # Check if tools are available to build documentation.
1659 if test "$docs" != "no" ; then
1660 if test -x "`which texi2html 2>/dev/null`" -a \
1661 -x "`which pod2man 2>/dev/null`" ; then
1662 docs=yes
1663 else
1664 if test "$docs" = "yes" ; then
1665 feature_not_found "docs"
1667 docs=no
1671 # Search for bsawp_32 function
1672 byteswap_h=no
1673 cat > $TMPC << EOF
1674 #include <byteswap.h>
1675 int main(void) { return bswap_32(0); }
1677 if compile_prog "" "" ; then
1678 byteswap_h=yes
1681 # Search for bsawp_32 function
1682 bswap_h=no
1683 cat > $TMPC << EOF
1684 #include <sys/endian.h>
1685 #include <sys/types.h>
1686 #include <machine/bswap.h>
1687 int main(void) { return bswap32(0); }
1689 if compile_prog "" "" ; then
1690 bswap_h=yes
1693 ##########################################
1694 # Do we need librt
1695 cat > $TMPC <<EOF
1696 #include <signal.h>
1697 #include <time.h>
1698 int main(void) { clockid_t id; return clock_gettime(id, NULL); }
1701 if compile_prog "" "" ; then
1703 elif compile_prog "" "-lrt" ; then
1704 LIBS="-lrt $LIBS"
1707 # Determine what linker flags to use to force archive inclusion
1708 check_linker_flags()
1711 if test "$2" ; then
1712 w2=-Wl,$2
1714 compile_prog "" "-Wl,$1 ${w2}"
1717 cat > $TMPC << EOF
1718 int main(void) { }
1720 if check_linker_flags --whole-archive --no-whole-archive ; then
1721 # GNU ld
1722 arlibs_begin="-Wl,--whole-archive"
1723 arlibs_end="-Wl,--no-whole-archive"
1724 elif check_linker_flags -z,allextract -z,defaultextract ; then
1725 # Solaris ld
1726 arlibs_begin="-Wl,-z,allextract"
1727 arlibs_end="-Wl,-z,defaultextract"
1728 elif check_linker_flags -all_load ; then
1729 # Mac OS X
1730 arlibs_begin="-all_load"
1731 arlibs_end=""
1732 else
1733 echo "Error: your linker does not support --whole-archive or -z."
1734 echo "Please report to qemu-devel@nongnu.org"
1735 exit 1
1738 if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
1739 "$aix" != "yes" ; then
1740 libs_softmmu="-lutil $libs_softmmu"
1743 ##########################################
1744 # check if the compiler defines offsetof
1746 need_offsetof=yes
1747 cat > $TMPC << EOF
1748 #include <stddef.h>
1749 int main(void) { struct s { int f; }; return offsetof(struct s, f); }
1751 if compile_prog "" "" ; then
1752 need_offsetof=no
1755 ##########################################
1756 # check if we have fdatasync
1758 fdatasync=no
1759 cat > $TMPC << EOF
1760 #include <unistd.h>
1761 int main(void) { return fdatasync(0); }
1763 if compile_prog "" "" ; then
1764 fdatasync=yes
1767 # End of CC checks
1768 # After here, no more $cc or $ld runs
1770 # default flags for all hosts
1771 QEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
1772 CFLAGS="-g $CFLAGS"
1773 if test "$debug" = "no" ; then
1774 CFLAGS="-O2 $CFLAGS"
1776 QEMU_CFLAGS="-Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
1777 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
1778 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
1779 QEMU_CFLAGS="-U_FORTIFY_SOURCE $QEMU_CFLAGS"
1780 QEMU_CFLAGS="-I. -I\$(SRC_PATH) -MMD -MP -MT \$@ $QEMU_CFLAGS"
1781 LDFLAGS="-g $LDFLAGS"
1783 # Consult white-list to determine whether to enable werror
1784 # by default. Only enable by default for git builds
1785 if test -z "$werror" ; then
1786 z_version=`cut -f3 -d. $source_path/VERSION`
1787 if test "$z_version" = "50" -a \
1788 "$linux" = "yes" ; then
1789 werror="yes"
1790 else
1791 werror="no"
1793 # disable default werror for kvm
1794 werror="no"
1797 if test "$werror" = "yes" ; then
1798 QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
1801 if test "$solaris" = "no" ; then
1802 if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
1803 LDFLAGS="-Wl,--warn-common $LDFLAGS"
1807 if test "$mingw32" = "yes" ; then
1808 if test -z "$prefix" ; then
1809 prefix="c:/Program Files/Qemu"
1811 mansuffix=""
1812 datasuffix=""
1813 docsuffix=""
1814 binsuffix=""
1815 else
1816 if test -z "$prefix" ; then
1817 prefix="/usr/local"
1819 mansuffix="/share/man"
1820 datasuffix="/share/qemu"
1821 docsuffix="/share/doc/qemu"
1822 binsuffix="/bin"
1825 if test -f kvm/kernel/configure; then
1826 kvm_kmod="yes"
1827 kmod_args=""
1828 if test -n "$kerneldir"; then
1829 kmod_args="--kerneldir=$kerneldir"
1831 if test "$kvm_trace" = "yes"; then
1832 kmod_args="$kmod_args --with-kvm-trace"
1834 # hope there are no spaces in kmod_args; can't use arrays because of
1835 # dash.
1836 (cd kvm/kernel; ./configure $kmod_args)
1839 echo "Install prefix $prefix"
1840 echo "BIOS directory $prefix$datasuffix"
1841 echo "binary directory $prefix$binsuffix"
1842 if test "$mingw32" = "no" ; then
1843 echo "Manual directory $prefix$mansuffix"
1844 echo "ELF interp prefix $interp_prefix"
1846 echo "Source path $source_path"
1847 echo "C compiler $cc"
1848 echo "Host C compiler $host_cc"
1849 echo "CFLAGS $CFLAGS"
1850 echo "QEMU_CFLAGS $QEMU_CFLAGS"
1851 echo "LDFLAGS $LDFLAGS"
1852 echo "make $make"
1853 echo "install $install"
1854 echo "host CPU $cpu"
1855 echo "host big endian $bigendian"
1856 echo "target list $target_list"
1857 echo "tcg debug enabled $debug_tcg"
1858 echo "gprof enabled $gprof"
1859 echo "sparse enabled $sparse"
1860 echo "strip binaries $strip_opt"
1861 echo "profiler $profiler"
1862 echo "static build $static"
1863 echo "-Werror enabled $werror"
1864 if test "$darwin" = "yes" ; then
1865 echo "Cocoa support $cocoa"
1867 echo "SDL support $sdl"
1868 echo "curses support $curses"
1869 echo "curl support $curl"
1870 echo "check support $check_utests"
1871 echo "mingw32 support $mingw32"
1872 echo "Audio drivers $audio_drv_list"
1873 echo "Extra audio cards $audio_card_list"
1874 echo "Mixer emulation $mixemu"
1875 echo "VNC TLS support $vnc_tls"
1876 echo "VNC SASL support $vnc_sasl"
1877 if test -n "$sparc_cpu"; then
1878 echo "Target Sparc Arch $sparc_cpu"
1880 echo "xen support $xen"
1881 echo "CPU emulation $cpu_emulation"
1882 echo "brlapi support $brlapi"
1883 echo "bluez support $bluez"
1884 echo "Documentation $docs"
1885 [ ! -z "$uname_release" ] && \
1886 echo "uname -r $uname_release"
1887 echo "NPTL support $nptl"
1888 echo "GUEST_BASE $guest_base"
1889 echo "PIE user targets $user_pie"
1890 echo "vde support $vde"
1891 echo "IO thread $io_thread"
1892 echo "Linux AIO support $linux_aio"
1893 echo "Install blobs $blobs"
1894 echo "KVM support $kvm"
1895 echo "KVM PIT support $kvm_cap_pit"
1896 echo "KVM device assig. $kvm_cap_device_assignment"
1897 echo "KVM trace support $kvm_trace"
1898 echo "fdt support $fdt"
1899 echo "preadv support $preadv"
1900 echo "fdatasync $fdatasync"
1902 if test $sdl_too_old = "yes"; then
1903 echo "-> Your SDL version is too old - please upgrade to have SDL support"
1906 config_host_mak="config-host.mak"
1907 config_host_h="config-host.h"
1908 config_host_ld="config-host.ld"
1910 #echo "Creating $config_host_mak and $config_host_h"
1912 test -f $config_host_h && mv $config_host_h ${config_host_h}~
1914 echo "# Automatically generated by configure - do not modify" > $config_host_mak
1915 printf "# Configured with:" >> $config_host_mak
1916 printf " '%s'" "$0" "$@" >> $config_host_mak
1917 echo >> $config_host_mak
1919 echo "CONFIG_QEMU_SHAREDIR=\"$prefix$datasuffix\"" >> $config_host_mak
1921 case "$cpu" in
1922 i386|x86_64|alpha|cris|hppa|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|s390|sparc|sparc64)
1923 ARCH=$cpu
1925 armv4b|armv4l)
1926 ARCH=arm
1929 echo "Unsupported CPU = $cpu"
1930 exit 1
1932 esac
1933 echo "ARCH=$ARCH" >> $config_host_mak
1934 if test "$debug_tcg" = "yes" ; then
1935 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
1937 if test "$debug" = "yes" ; then
1938 echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
1940 if test "$strip_opt" = "yes" ; then
1941 echo "STRIP_OPT=-s" >> $config_host_mak
1943 if test "$bigendian" = "yes" ; then
1944 echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
1946 echo "HOST_LONG_BITS=$hostlongbits" >> $config_host_mak
1947 if test "$mingw32" = "yes" ; then
1948 echo "CONFIG_WIN32=y" >> $config_host_mak
1949 else
1950 echo "CONFIG_POSIX=y" >> $config_host_mak
1953 if test "$darwin" = "yes" ; then
1954 echo "CONFIG_DARWIN=y" >> $config_host_mak
1957 if test "$aix" = "yes" ; then
1958 echo "CONFIG_AIX=y" >> $config_host_mak
1961 if test "$solaris" = "yes" ; then
1962 echo "CONFIG_SOLARIS=y" >> $config_host_mak
1963 echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
1964 if test "$needs_libsunmath" = "yes" ; then
1965 echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
1968 if test "$static" = "yes" ; then
1969 echo "CONFIG_STATIC=y" >> $config_host_mak
1970 LDFLAGS="-static $LDFLAGS"
1972 if test $profiler = "yes" ; then
1973 echo "CONFIG_PROFILER=y" >> $config_host_mak
1975 if test "$slirp" = "yes" ; then
1976 echo "CONFIG_SLIRP=y" >> $config_host_mak
1977 CFLAGS="-I\$(SRC_PATH)/slirp $CFLAGS"
1979 if test "$vde" = "yes" ; then
1980 echo "CONFIG_VDE=y" >> $config_host_mak
1982 for card in $audio_card_list; do
1983 def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
1984 echo "$def=y" >> $config_host_mak
1985 done
1986 echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
1987 for drv in $audio_drv_list; do
1988 def=CONFIG_`echo $drv | tr '[:lower:]' '[:upper:]'`
1989 echo "$def=y" >> $config_host_mak
1990 if test "$drv" = "fmod"; then
1991 echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
1993 done
1994 if test "$audio_pt_int" = "yes" ; then
1995 echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
1997 if test "$mixemu" = "yes" ; then
1998 echo "CONFIG_MIXEMU=y" >> $config_host_mak
2000 if test "$vnc_tls" = "yes" ; then
2001 echo "CONFIG_VNC_TLS=y" >> $config_host_mak
2002 echo "VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_host_mak
2004 if test "$vnc_sasl" = "yes" ; then
2005 echo "CONFIG_VNC_SASL=y" >> $config_host_mak
2006 echo "VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak
2008 if test "$fnmatch" = "yes" ; then
2009 echo "CONFIG_FNMATCH=y" >> $config_host_mak
2011 qemu_version=`head $source_path/VERSION`
2012 echo "VERSION=$qemu_version" >>$config_host_mak
2013 echo "PKGVERSION=$pkgversion" >>$config_host_mak
2014 echo "SRC_PATH=$source_path" >> $config_host_mak
2015 if [ "$source_path_used" = "yes" ]; then
2016 echo "VPATH=$source_path" >> $config_host_mak
2018 echo "TARGET_DIRS=$target_list" >> $config_host_mak
2019 if [ "$docs" = "yes" ] ; then
2020 echo "BUILD_DOCS=yes" >> $config_host_mak
2022 if test "$sdl" = "yes" ; then
2023 echo "CONFIG_SDL=y" >> $config_host_mak
2024 echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
2026 if test "$cocoa" = "yes" ; then
2027 echo "CONFIG_COCOA=y" >> $config_host_mak
2029 if test "$curses" = "yes" ; then
2030 echo "CONFIG_CURSES=y" >> $config_host_mak
2032 if test "$atfile" = "yes" ; then
2033 echo "CONFIG_ATFILE=y" >> $config_host_mak
2035 if test "$utimens" = "yes" ; then
2036 echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
2038 if test "$pipe2" = "yes" ; then
2039 echo "CONFIG_PIPE2=y" >> $config_host_mak
2041 if test "$splice" = "yes" ; then
2042 echo "CONFIG_SPLICE=y" >> $config_host_mak
2044 if test "$eventfd" = "yes" ; then
2045 echo "CONFIG_EVENTFD=y" >> $config_host_mak
2047 if test "$inotify" = "yes" ; then
2048 echo "CONFIG_INOTIFY=y" >> $config_host_mak
2050 if test "$byteswap_h" = "yes" ; then
2051 echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
2053 if test "$bswap_h" = "yes" ; then
2054 echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
2056 if test "$curl" = "yes" ; then
2057 echo "CONFIG_CURL=y" >> $config_host_mak
2058 echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
2060 if test "$brlapi" = "yes" ; then
2061 echo "CONFIG_BRLAPI=y" >> $config_host_mak
2063 if test "$bluez" = "yes" ; then
2064 echo "CONFIG_BLUEZ=y" >> $config_host_mak
2065 echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
2067 if test "$xen" = "yes" ; then
2068 echo "CONFIG_XEN=y" >> $config_host_mak
2070 if test "$io_thread" = "yes" ; then
2071 echo "CONFIG_IOTHREAD=y" >> $config_host_mak
2073 if test "$linux_aio" = "yes" ; then
2074 echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
2076 if test "$blobs" = "yes" ; then
2077 echo "INSTALL_BLOBS=yes" >> $config_host_mak
2079 if test "$iovec" = "yes" ; then
2080 echo "CONFIG_IOVEC=y" >> $config_host_mak
2082 if test "$preadv" = "yes" ; then
2083 echo "CONFIG_PREADV=y" >> $config_host_mak
2085 if test "$fdt" = "yes" ; then
2086 echo "CONFIG_FDT=y" >> $config_host_mak
2088 if test "$signalfd" = "yes" ; then
2089 echo "CONFIG_SIGNALFD=y" >> $config_host_mak
2091 if test "$need_offsetof" = "yes" ; then
2092 echo "CONFIG_NEED_OFFSETOF=y" >> $config_host_mak
2094 if test "$fdatasync" = "yes" ; then
2095 echo "CONFIG_FDATASYNC=y" >> $config_host_mak
2097 if test $cpu_emulation = "yes"; then
2098 echo "CONFIG_CPU_EMULATION=y" >> $config_host_mak
2099 else
2100 echo "CONFIG_NO_CPU_EMULATION=y" >> $config_host_mak
2103 # XXX: suppress that
2104 if [ "$bsd" = "yes" ] ; then
2105 echo "CONFIG_BSD=y" >> $config_host_mak
2108 echo "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
2110 # USB host support
2111 case "$usb" in
2112 linux)
2113 echo "HOST_USB=linux" >> $config_host_mak
2115 bsd)
2116 echo "HOST_USB=bsd" >> $config_host_mak
2119 echo "HOST_USB=stub" >> $config_host_mak
2121 esac
2123 echo "KVM_KMOD=$kvm_kmod" >> $config_host_mak
2125 tools=
2126 if test `expr "$target_list" : ".*softmmu.*"` != 0 ; then
2127 tools="qemu-img\$(EXESUF) $tools"
2128 if [ "$linux" = "yes" ] ; then
2129 tools="qemu-nbd\$(EXESUF) qemu-io\$(EXESUF) $tools"
2130 if [ "$check_utests" = "yes" ]; then
2131 tools="check-qint check-qstring check-qdict $tools"
2133 elif test "$mingw32" = "yes" ; then
2134 tools="qemu-io\$(EXESUF) $tools"
2137 echo "TOOLS=$tools" >> $config_host_mak
2139 # Mac OS X ships with a broken assembler
2140 roms=
2141 if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
2142 "$targetos" != "Darwin" -a \
2143 `expr "$target_list" : ".*softmmu.*"` != 0 ; then
2144 roms="optionrom"
2146 echo "ROMS=$roms" >> $config_host_mak
2148 echo "prefix=$prefix" >> $config_host_mak
2149 echo "bindir=\${prefix}$binsuffix" >> $config_host_mak
2150 echo "mandir=\${prefix}$mansuffix" >> $config_host_mak
2151 echo "datadir=\${prefix}$datasuffix" >> $config_host_mak
2152 echo "docdir=\${prefix}$docsuffix" >> $config_host_mak
2153 echo "MAKE=$make" >> $config_host_mak
2154 echo "INSTALL=$install" >> $config_host_mak
2155 echo "INSTALL_DIR=$install -d -m0755 -p" >> $config_host_mak
2156 echo "INSTALL_DATA=$install -m0644 -p" >> $config_host_mak
2157 echo "INSTALL_PROG=$install -m0755 -p" >> $config_host_mak
2158 echo "CC=$cc" >> $config_host_mak
2159 echo "HOST_CC=$host_cc" >> $config_host_mak
2160 if test "$sparse" = "yes" ; then
2161 echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_host_mak
2162 echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_host_mak
2163 echo "QEMU_CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
2165 echo "AR=$ar" >> $config_host_mak
2166 echo "OBJCOPY=$objcopy" >> $config_host_mak
2167 echo "LD=$ld" >> $config_host_mak
2168 echo "CFLAGS=$CFLAGS" >> $config_host_mak
2169 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
2170 echo "HELPER_CFLAGS=$helper_cflags" >> $config_host_mak
2171 echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
2172 echo "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak
2173 echo "ARLIBS_END=$arlibs_end" >> $config_host_mak
2174 echo "LIBS+=$LIBS" >> $config_host_mak
2175 echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
2176 echo "EXESUF=$EXESUF" >> $config_host_mak
2178 echo "/* Automatically generated by configure - do not modify */" > $config_host_h
2180 /bin/sh $source_path/create_config < $config_host_mak >> $config_host_h
2182 if test -f ${config_host_h}~ ; then
2183 if cmp -s $config_host_h ${config_host_h}~ ; then
2184 mv ${config_host_h}~ $config_host_h
2185 else
2186 rm ${config_host_h}~
2190 # generate list of library paths for linker script
2192 $ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
2194 if test -f ${config_host_ld}~ ; then
2195 if cmp -s $config_host_ld ${config_host_ld}~ ; then
2196 mv ${config_host_ld}~ $config_host_ld
2197 else
2198 rm ${config_host_ld}~
2202 for target in $target_list; do
2203 target_dir="$target"
2204 config_mak=$target_dir/config.mak
2205 config_h=$target_dir/config.h
2206 target_arch2=`echo $target | cut -d '-' -f 1`
2207 target_bigendian="no"
2208 case "$target_arch2" in
2209 armeb|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|sh4eb|sparc|sparc64|sparc32plus)
2210 target_bigendian=yes
2212 esac
2213 target_softmmu="no"
2214 target_user_only="no"
2215 target_linux_user="no"
2216 target_darwin_user="no"
2217 target_bsd_user="no"
2218 case "$target" in
2219 ${target_arch2}-softmmu)
2220 target_softmmu="yes"
2222 ${target_arch2}-linux-user)
2223 target_user_only="yes"
2224 target_linux_user="yes"
2226 ${target_arch2}-darwin-user)
2227 target_user_only="yes"
2228 target_darwin_user="yes"
2230 ${target_arch2}-bsd-user)
2231 target_user_only="yes"
2232 target_bsd_user="yes"
2235 echo "ERROR: Target '$target' not recognised"
2236 exit 1
2238 esac
2240 #echo "Creating $config_mak, $config_h and $target_dir/Makefile"
2242 test -f $config_h && mv $config_h ${config_h}~
2244 mkdir -p $target_dir
2245 mkdir -p $target_dir/fpu
2246 mkdir -p $target_dir/tcg
2247 mkdir -p $target_dir/ide
2248 if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
2249 mkdir -p $target_dir/nwfpe
2253 # don't use ln -sf as not all "ln -sf" over write the file/link
2255 rm -f $target_dir/Makefile
2256 ln -s $source_path/Makefile.target $target_dir/Makefile
2259 echo "# Automatically generated by configure - do not modify" > $config_mak
2261 echo "include ../config-host.mak" >> $config_mak
2263 bflt="no"
2264 elfload32="no"
2265 target_nptl="no"
2266 interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
2267 echo "CONFIG_QEMU_PREFIX=\"$interp_prefix1\"" >> $config_mak
2268 gdb_xml_files=""
2270 TARGET_ARCH="$target_arch2"
2271 TARGET_BASE_ARCH=""
2272 TARGET_ABI_DIR=""
2274 case "$target_arch2" in
2275 i386)
2276 target_phys_bits=32
2278 x86_64)
2279 TARGET_BASE_ARCH=i386
2280 target_phys_bits=64
2282 ia64)
2283 target_phys_bits=64
2285 alpha)
2286 target_phys_bits=64
2288 arm|armeb)
2289 TARGET_ARCH=arm
2290 bflt="yes"
2291 target_nptl="yes"
2292 gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
2293 target_phys_bits=32
2295 cris)
2296 target_nptl="yes"
2297 target_phys_bits=32
2299 m68k)
2300 bflt="yes"
2301 gdb_xml_files="cf-core.xml cf-fp.xml"
2302 target_phys_bits=32
2304 microblaze)
2305 bflt="yes"
2306 target_nptl="yes"
2307 target_phys_bits=32
2309 mips|mipsel)
2310 TARGET_ARCH=mips
2311 echo "TARGET_ABI_MIPSO32=y" >> $config_mak
2312 target_nptl="yes"
2313 target_phys_bits=64
2315 mipsn32|mipsn32el)
2316 TARGET_ARCH=mipsn32
2317 TARGET_BASE_ARCH=mips
2318 echo "TARGET_ABI_MIPSN32=y" >> $config_mak
2319 target_phys_bits=64
2321 mips64|mips64el)
2322 TARGET_ARCH=mips64
2323 TARGET_BASE_ARCH=mips
2324 echo "TARGET_ABI_MIPSN64=y" >> $config_mak
2325 target_phys_bits=64
2327 ppc)
2328 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2329 target_phys_bits=32
2330 target_nptl="yes"
2332 ppcemb)
2333 TARGET_BASE_ARCH=ppc
2334 TARGET_ABI_DIR=ppc
2335 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2336 target_phys_bits=64
2337 target_nptl="yes"
2339 ppc64)
2340 TARGET_BASE_ARCH=ppc
2341 TARGET_ABI_DIR=ppc
2342 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2343 target_phys_bits=64
2345 ppc64abi32)
2346 TARGET_ARCH=ppc64
2347 TARGET_BASE_ARCH=ppc
2348 TARGET_ABI_DIR=ppc
2349 echo "TARGET_ABI32=y" >> $config_mak
2350 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2351 target_phys_bits=64
2353 sh4|sh4eb)
2354 TARGET_ARCH=sh4
2355 bflt="yes"
2356 target_nptl="yes"
2357 target_phys_bits=32
2359 sparc)
2360 target_phys_bits=64
2362 sparc64)
2363 TARGET_BASE_ARCH=sparc
2364 elfload32="yes"
2365 target_phys_bits=64
2367 sparc32plus)
2368 TARGET_ARCH=sparc64
2369 TARGET_BASE_ARCH=sparc
2370 TARGET_ABI_DIR=sparc
2371 echo "TARGET_ABI32=y" >> $config_mak
2372 target_phys_bits=64
2375 echo "Unsupported target CPU"
2376 exit 1
2378 esac
2379 echo "TARGET_ARCH=$TARGET_ARCH" >> $config_mak
2380 target_arch_name="`echo $TARGET_ARCH | tr '[:lower:]' '[:upper:]'`"
2381 echo "TARGET_$target_arch_name=y" >> $config_mak
2382 echo "TARGET_ARCH2=$target_arch2" >> $config_mak
2383 # TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
2384 if [ "$TARGET_BASE_ARCH" = "" ]; then
2385 TARGET_BASE_ARCH=$TARGET_ARCH
2387 echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_mak
2388 if [ "$TARGET_ABI_DIR" = "" ]; then
2389 TARGET_ABI_DIR=$TARGET_ARCH
2391 echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_mak
2392 if [ $target_phys_bits -lt $hostlongbits ] ; then
2393 target_phys_bits=$hostlongbits
2395 case "$target_arch2" in
2396 i386|x86_64)
2397 if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
2398 echo "CONFIG_XEN=y" >> $config_mak
2400 esac
2401 case "$target_arch2" in
2402 i386|x86_64|ppcemb|ppc|ppc64)
2403 # Make sure the target and host cpus are compatible
2404 if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
2405 \( "$target_arch2" = "$cpu" -o \
2406 \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
2407 \( "$target_arch2" = "ppc64" -a "$cpu" = "ppc" \) -o \
2408 \( "$target_arch2" = "x86_64" -a "$cpu" = "i386" \) -o \
2409 \( "$target_arch2" = "i386" -a "$cpu" = "x86_64" \) \) ; then
2410 echo "CONFIG_KVM=y" >> $config_mak
2411 echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak
2412 if test $kvm_cap_pit = "yes" ; then
2413 echo "CONFIG_KVM_PIT=y" >> $config_mak
2415 if test $kvm_cap_device_assignment = "yes" ; then
2416 echo "CONFIG_KVM_DEVICE_ASSIGNMENT=y" >> $config_mak
2419 esac
2420 echo "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_mak
2421 if test "$target_bigendian" = "yes" ; then
2422 echo "TARGET_WORDS_BIGENDIAN=y" >> $config_mak
2424 if test "$target_softmmu" = "yes" ; then
2425 echo "CONFIG_SOFTMMU=y" >> $config_mak
2426 echo "LIBS+=$libs_softmmu" >> $config_mak
2427 echo "HWLIB=../libhw$target_phys_bits/libqemuhw$target_phys_bits.a" >> $config_mak
2428 echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
2430 if test "$target_user_only" = "yes" ; then
2431 echo "CONFIG_USER_ONLY=y" >> $config_mak
2433 if test "$target_linux_user" = "yes" ; then
2434 echo "CONFIG_LINUX_USER=y" >> $config_mak
2436 if test "$target_darwin_user" = "yes" ; then
2437 echo "CONFIG_DARWIN_USER=y" >> $config_mak
2439 list=""
2440 if test ! -z "$gdb_xml_files" ; then
2441 for x in $gdb_xml_files; do
2442 list="$list $source_path/gdb-xml/$x"
2443 done
2445 echo "TARGET_XML_FILES=$list" >> $config_mak
2447 case "$target_arch2" in
2448 arm|armeb|m68k|microblaze|mips|mipsel|mipsn32|mipsn32el|mips64|mips64el|ppc|ppc64|ppc64abi32|ppcemb|sparc|sparc64|sparc32plus)
2449 echo "CONFIG_SOFTFLOAT=y" >> $config_mak
2452 echo "CONFIG_NOSOFTFLOAT=y" >> $config_mak
2454 esac
2456 if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
2457 echo "TARGET_HAS_BFLT=y" >> $config_mak
2459 if test "$target_user_only" = "yes" \
2460 -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
2461 echo "CONFIG_USE_NPTL=y" >> $config_mak
2463 # 32 bit ELF loader in addition to native 64 bit loader?
2464 if test "$target_user_only" = "yes" -a "$elfload32" = "yes"; then
2465 echo "TARGET_HAS_ELFLOAD32=y" >> $config_mak
2467 if test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
2468 echo "CONFIG_USE_GUEST_BASE=y" >> $config_mak
2470 if test "$target_bsd_user" = "yes" ; then
2471 echo "CONFIG_BSD_USER=y" >> $config_mak
2474 # generate QEMU_CFLAGS/LDFLAGS for targets
2476 cflags=""
2477 ldflags=""
2479 if test "$ARCH" = "sparc64" ; then
2480 cflags="-I\$(SRC_PATH)/tcg/sparc $cflags"
2481 else
2482 cflags="-I\$(SRC_PATH)/tcg/\$(ARCH) $cflags"
2484 cflags="-I\$(SRC_PATH)/tcg $cflags"
2485 cflags="-I\$(SRC_PATH)/fpu $cflags"
2487 for i in $ARCH $TARGET_BASE_ARCH ; do
2488 case "$i" in
2489 alpha)
2490 echo "CONFIG_ALPHA_DIS=y" >> $config_mak
2492 arm)
2493 echo "CONFIG_ARM_DIS=y" >> $config_mak
2495 cris)
2496 echo "CONFIG_CRIS_DIS=y" >> $config_mak
2498 hppa)
2499 echo "CONFIG_HPPA_DIS=y" >> $config_mak
2501 i386|x86_64)
2502 echo "CONFIG_I386_DIS=y" >> $config_mak
2504 m68k)
2505 echo "CONFIG_M68K_DIS=y" >> $config_mak
2507 microblaze)
2508 echo "CONFIG_MICROBLAZE_DIS=y" >> $config_mak
2510 mips*)
2511 echo "CONFIG_MIPS_DIS=y" >> $config_mak
2513 ppc*)
2514 echo "CONFIG_PPC_DIS=y" >> $config_mak
2516 s390)
2517 echo "CONFIG_S390_DIS=y" >> $config_mak
2519 sh4)
2520 echo "CONFIG_SH4_DIS=y" >> $config_mak
2522 sparc*)
2523 echo "CONFIG_SPARC_DIS=y" >> $config_mak
2525 esac
2526 done
2528 case "$ARCH" in
2529 alpha)
2530 # Ensure there's only a single GP
2531 cflags="-msmall-data $cflags"
2533 ia64)
2534 cflags="-mno-sdata $cflags"
2536 esac
2538 if test "$target_softmmu" = "yes" ; then
2539 case "$TARGET_BASE_ARCH" in
2540 arm)
2541 cflags="-DHAS_AUDIO $cflags"
2543 i386|mips|ppc)
2544 cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags"
2546 esac
2549 if test "$target_user_only" = "yes" -a "$static" = "no" -a \
2550 "$user_pie" = "yes" ; then
2551 cflags="-fpie $cflags"
2552 ldflags="-pie $ldflags"
2555 if test "$target_softmmu" = "yes" -a \( \
2556 "$TARGET_ARCH" = "microblaze" -o \
2557 "$TARGET_ARCH" = "cris" \) ; then
2558 echo "CONFIG_NEED_MMU=y" >> $config_mak
2561 if test "$gprof" = "yes" ; then
2562 echo "TARGET_GPROF=yes" >> $config_mak
2563 if test "$target_linux_user" = "yes" ; then
2564 cflags="-p $cflags"
2565 ldflags="-p $ldflags"
2567 if test "$target_softmmu" = "yes" ; then
2568 ldflags="-p $ldflags"
2569 echo "GPROF_CFLAGS=-p" >> $config_mak
2573 linker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/\$(ARCH).ld"
2574 if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
2575 case "$ARCH" in
2576 sparc)
2577 # -static is used to avoid g1/g3 usage by the dynamic linker
2578 ldflags="$linker_script -static $ldflags"
2580 ia64)
2581 ldflags="-Wl,-G0 $linker_script -static $ldflags"
2583 i386|x86_64|ppc|ppc64|s390|sparc64|alpha|arm|m68k|mips|mips64)
2584 ldflags="$linker_script $ldflags"
2586 esac
2588 if test "$target_softmmu" = "yes" ; then
2589 case "$ARCH" in
2590 ia64)
2591 ldflags="-Wl,-G0 $linker_script -static $ldflags"
2593 esac
2596 echo "LDFLAGS+=$ldflags" >> $config_mak
2597 echo "QEMU_CFLAGS+=$cflags" >> $config_mak
2599 echo "/* Automatically generated by configure - do not modify */" > $config_h
2600 echo "#include \"../config-host.h\"" >> $config_h
2602 /bin/sh $source_path/create_config < $config_mak >> $config_h
2604 if test -f ${config_h}~ ; then
2605 if cmp -s $config_h ${config_h}~ ; then
2606 mv ${config_h}~ $config_h
2607 else
2608 rm ${config_h}~
2612 done # for target in $targets
2614 # build tree in object directory if source path is different from current one
2615 if test "$source_path_used" = "yes" ; then
2616 DIRS="tests tests/cris slirp audio block pc-bios/optionrom"
2617 DIRS="$DIRS roms/pcbios roms/seabios roms/vgabios"
2618 FILES="Makefile tests/Makefile"
2619 FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
2620 FILES="$FILES tests/test-mmap.c"
2621 FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps pc-bios/video.x"
2622 FILES="$FILES roms/pcbios/Makefile roms/seabios/Makefile roms/vgabios/Makefile"
2623 for bios_file in $source_path/pc-bios/*.bin $source_path/pc-bios/*.dtb $source_path/pc-bios/openbios-*; do
2624 FILES="$FILES pc-bios/`basename $bios_file`"
2625 done
2626 for dir in $DIRS ; do
2627 mkdir -p $dir
2628 done
2629 # remove the link and recreate it, as not all "ln -sf" overwrite the link
2630 for f in $FILES ; do
2631 rm -f $f
2632 ln -s $source_path/$f $f
2633 done
2636 # temporary config to build submodules
2637 for rom in seabios vgabios pcbios; do
2638 config_mak=roms/$rom/config.mak
2639 echo "# Automatically generated by configure - do not modify" >> $config_mak
2640 echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
2641 echo "CC=$cc" >> $config_mak
2642 echo "BCC=bcc" >> $config_mak
2643 echo "CPP=${cross_prefix}cpp" >> $config_mak
2644 echo "OBJCOPY=objcopy" >> $config_mak
2645 echo "IASL=iasl" >> $config_mak
2646 echo "HOST_CC=$host_cc" >> $config_mak
2647 echo "LD=$ld" >> $config_mak
2648 done
2650 for hwlib in 32 64; do
2651 d=libhw$hwlib
2652 mkdir -p $d
2653 rm -f $d/Makefile
2654 ln -s $source_path/Makefile.hw $d/Makefile
2655 echo "HWLIB=libqemuhw$hwlib.a" > $d/config.mak
2656 echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" >> $d/config.mak
2657 done
2659 d=libuser
2660 mkdir -p $d
2661 rm -f $d/Makefile
2662 ln -s $source_path/Makefile.user $d/Makefile