minor refactoring
[qemu/malc.git] / configure
blobf4d6e103063709e06bfc28404614b111083f9211
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=""
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 # Default value for a variable defining feature "foo"
171 # * foo="no", feature will only be used if --enable-foo arg is given
172 # * foo="", feature will be searched for, and if found, will be used
173 # * foo="yes", this value vill only be set by --enable-foo flag.
174 # feature will searched for, if not found, configure exits with error
176 # Always add --enable-foo and --disable-foo command line args. Distributions want
177 # to ensure that several features are compiled in, and it is impossible without a
178 # --enable-foo that exits if feature is not found
180 bluez=""
181 brlapi=""
182 curl=""
183 curses=""
184 docs=""
185 fdt=""
186 kvm=""
187 nptl=""
188 sdl=""
189 sparse="no"
190 vde=""
191 vnc_tls=""
192 vnc_sasl=""
193 xen=""
194 linux_aio=""
196 gprof="no"
197 debug_tcg="no"
198 debug="no"
199 strip_opt="yes"
200 bigendian="no"
201 mingw32="no"
202 EXESUF=""
203 slirp="yes"
204 fmod_lib=""
205 fmod_inc=""
206 oss_lib=""
207 bsd="no"
208 linux="no"
209 solaris="no"
210 profiler="no"
211 cocoa="no"
212 softmmu="yes"
213 linux_user="no"
214 darwin_user="no"
215 bsd_user="no"
216 guest_base=""
217 uname_release=""
218 mixemu="no"
219 kerneldir=""
220 aix="no"
221 blobs="yes"
222 pkgversion=""
223 check_utests="no"
224 user_pie="no"
226 # OS specific
227 if check_define __linux__ ; then
228 targetos="Linux"
229 elif check_define _WIN32 ; then
230 targetos='MINGW32'
231 elif check_define __OpenBSD__ ; then
232 targetos='OpenBSD'
233 elif check_define __sun__ ; then
234 targetos='SunOS'
235 else
236 targetos=`uname -s`
239 case $targetos in
240 CYGWIN*)
241 mingw32="yes"
242 QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
243 audio_possible_drivers="sdl"
245 MINGW32*)
246 mingw32="yes"
247 audio_possible_drivers="dsound sdl fmod"
249 GNU/kFreeBSD)
250 audio_drv_list="oss"
251 audio_possible_drivers="oss sdl esd pa"
253 FreeBSD)
254 bsd="yes"
255 audio_drv_list="oss"
256 audio_possible_drivers="oss sdl esd pa"
258 DragonFly)
259 bsd="yes"
260 audio_drv_list="oss"
261 audio_possible_drivers="oss sdl esd pa"
263 NetBSD)
264 bsd="yes"
265 audio_drv_list="oss"
266 audio_possible_drivers="oss sdl esd"
267 oss_lib="-lossaudio"
269 OpenBSD)
270 bsd="yes"
271 audio_drv_list="oss"
272 audio_possible_drivers="oss sdl esd"
273 oss_lib="-lossaudio"
275 Darwin)
276 bsd="yes"
277 darwin="yes"
278 # on Leopard most of the system is 32-bit, so we have to ask the kernel it if we can
279 # run 64-bit userspace code
280 if [ "$cpu" = "i386" ] ; then
281 is_x86_64=`sysctl -n hw.optional.x86_64`
282 [ "$is_x86_64" = "1" ] && cpu=x86_64
284 if [ "$cpu" = "x86_64" ] ; then
285 QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
286 LDFLAGS="-arch x86_64 $LDFLAGS"
287 else
288 QEMU_CFLAGS="-mdynamic-no-pic $QEMU_CFLAGS"
290 darwin_user="yes"
291 cocoa="yes"
292 audio_drv_list="coreaudio"
293 audio_possible_drivers="coreaudio sdl fmod"
294 LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
295 libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
297 SunOS)
298 solaris="yes"
299 make="gmake"
300 install="ginstall"
301 needs_libsunmath="no"
302 solarisrev=`uname -r | cut -f2 -d.`
303 # have to select again, because `uname -m` returns i86pc
304 # even on an x86_64 box.
305 solariscpu=`isainfo -k`
306 if test "${solariscpu}" = "amd64" ; then
307 cpu="x86_64"
309 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
310 if test "$solarisrev" -le 9 ; then
311 if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
312 needs_libsunmath="yes"
313 QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
314 LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
315 LIBS="-lsunmath $LIBS"
316 else
317 echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
318 echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
319 echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
320 echo "Studio 11 can be downloaded from www.sun.com."
321 exit 1
325 if test -f /usr/include/sys/soundcard.h ; then
326 audio_drv_list="oss"
328 audio_possible_drivers="oss sdl"
329 # needed for CMSG_ macros in sys/socket.h
330 QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
331 # needed for TIOCWIN* defines in termios.h
332 QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
333 QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
334 LIBS="-lsocket -lnsl -lresolv $LIBS"
336 AIX)
337 aix="yes"
338 make="gmake"
341 audio_drv_list="oss"
342 audio_possible_drivers="oss alsa sdl esd pa"
343 linux="yes"
344 linux_user="yes"
345 usb="linux"
346 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
347 audio_possible_drivers="$audio_possible_drivers fmod"
350 esac
352 if [ "$bsd" = "yes" ] ; then
353 if [ "$darwin" != "yes" ] ; then
354 make="gmake"
355 usb="bsd"
357 bsd_user="yes"
360 if test "$mingw32" = "yes" ; then
361 EXESUF=".exe"
362 QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
363 LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
366 # find source path
367 source_path=`dirname "$0"`
368 source_path_used="no"
369 workdir=`pwd`
370 if [ -z "$source_path" ]; then
371 source_path=$workdir
372 else
373 source_path=`cd "$source_path"; pwd`
375 [ -f "$workdir/vl.c" ] || source_path_used="yes"
377 werror=""
379 for opt do
380 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
381 case "$opt" in
382 --help|-h) show_help=yes
384 --prefix=*) prefix="$optarg"
386 --interp-prefix=*) interp_prefix="$optarg"
388 --source-path=*) source_path="$optarg"
389 source_path_used="yes"
391 --cross-prefix=*)
393 --cc=*)
395 --host-cc=*) host_cc="$optarg"
397 --make=*) make="$optarg"
399 --install=*) install="$optarg"
401 --extra-cflags=*)
403 --extra-ldflags=*)
405 --cpu=*)
407 --target-list=*) target_list="$optarg"
409 --enable-gprof) gprof="yes"
411 --static) static="yes"
413 --disable-sdl) sdl="no"
415 --enable-sdl) sdl="yes"
417 --fmod-lib=*) fmod_lib="$optarg"
419 --fmod-inc=*) fmod_inc="$optarg"
421 --oss-lib=*) oss_lib="$optarg"
423 --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
425 --audio-drv-list=*) audio_drv_list="$optarg"
427 --enable-debug-tcg) debug_tcg="yes"
429 --disable-debug-tcg) debug_tcg="no"
431 --enable-debug)
432 # Enable debugging options that aren't excessively noisy
433 debug_tcg="yes"
434 debug="yes"
435 strip_opt="no"
437 --enable-sparse) sparse="yes"
439 --disable-sparse) sparse="no"
441 --disable-strip) strip_opt="no"
443 --disable-vnc-tls) vnc_tls="no"
445 --enable-vnc-tls) vnc_tls="yes"
447 --disable-vnc-sasl) vnc_sasl="no"
449 --enable-vnc-sasl) vnc_sasl="yes"
451 --disable-slirp) slirp="no"
453 --disable-vde) vde="no"
455 --enable-vde) vde="yes"
457 --disable-xen) xen="no"
459 --enable-xen) xen="yes"
461 --disable-brlapi) brlapi="no"
463 --enable-brlapi) brlapi="yes"
465 --disable-bluez) bluez="no"
467 --enable-bluez) bluez="yes"
469 --disable-kvm) kvm="no"
471 --enable-kvm) kvm="yes"
473 --enable-profiler) profiler="yes"
475 --enable-cocoa)
476 cocoa="yes" ;
477 sdl="no" ;
478 audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
480 --disable-system) softmmu="no"
482 --enable-system) softmmu="yes"
484 --disable-user)
485 linux_user="no" ;
486 bsd_user="no" ;
487 darwin_user="no"
489 --enable-user) ;;
490 --disable-linux-user) linux_user="no"
492 --enable-linux-user) linux_user="yes"
494 --disable-darwin-user) darwin_user="no"
496 --enable-darwin-user) darwin_user="yes"
498 --disable-bsd-user) bsd_user="no"
500 --enable-bsd-user) bsd_user="yes"
502 --enable-guest-base) guest_base="yes"
504 --disable-guest-base) guest_base="no"
506 --enable-user-pie) user_pie="yes"
508 --disable-user-pie) user_pie="no"
510 --enable-uname-release=*) uname_release="$optarg"
512 --sparc_cpu=*)
514 --enable-werror) werror="yes"
516 --disable-werror) werror="no"
518 --disable-curses) curses="no"
520 --enable-curses) curses="yes"
522 --disable-curl) curl="no"
524 --enable-curl) curl="yes"
526 --disable-fdt) fdt="no"
528 --enable-fdt) fdt="yes"
530 --disable-check-utests) check_utests="no"
532 --enable-check-utests) check_utests="yes"
534 --disable-nptl) nptl="no"
536 --enable-nptl) nptl="yes"
538 --enable-mixemu) mixemu="yes"
540 --disable-linux-aio) linux_aio="no"
542 --enable-linux-aio) linux_aio="yes"
544 --disable-blobs) blobs="no"
546 --kerneldir=*) kerneldir="$optarg"
548 --with-pkgversion=*) pkgversion=" ($optarg)"
550 --disable-docs) docs="no"
552 --enable-docs) docs="yes"
554 *) echo "ERROR: unknown option $opt"; show_help="yes"
556 esac
557 done
560 # If cpu ~= sparc and sparc_cpu hasn't been defined, plug in the right
561 # QEMU_CFLAGS/LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
563 host_guest_base="no"
564 case "$cpu" in
565 sparc) case $sparc_cpu in
566 v7|v8)
567 QEMU_CFLAGS="-mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
569 v8plus|v8plusa)
570 QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
572 *) # sparc_cpu not defined in the command line
573 QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_v8plus__ $QEMU_CFLAGS"
574 esac
575 LDFLAGS="-m32 $LDFLAGS"
576 QEMU_CFLAGS="-m32 -ffixed-g2 -ffixed-g3 $QEMU_CFLAGS"
577 if test "$solaris" = "no" ; then
578 QEMU_CFLAGS="-ffixed-g1 -ffixed-g6 $QEMU_CFLAGS"
579 helper_cflags="-ffixed-i0"
582 sparc64)
583 QEMU_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__ $QEMU_CFLAGS"
584 LDFLAGS="-m64 $LDFLAGS"
585 QEMU_CFLAGS="-ffixed-g5 -ffixed-g6 -ffixed-g7 $QEMU_CFLAGS"
586 if test "$solaris" != "no" ; then
587 QEMU_CFLAGS="-ffixed-g1 $QEMU_CFLAGS"
590 s390)
591 QEMU_CFLAGS="-march=z900 $QEMU_CFLAGS"
593 i386)
594 QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
595 LDFLAGS="-m32 $LDFLAGS"
596 helper_cflags="-fomit-frame-pointer"
597 host_guest_base="yes"
599 x86_64)
600 QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
601 LDFLAGS="-m64 $LDFLAGS"
602 host_guest_base="yes"
604 arm*)
605 host_guest_base="yes"
607 ppc*)
608 host_guest_base="yes"
610 esac
612 [ -z "$guest_base" ] && guest_base="$host_guest_base"
614 if test x"$show_help" = x"yes" ; then
615 cat << EOF
617 Usage: configure [options]
618 Options: [defaults in brackets after descriptions]
621 echo "Standard options:"
622 echo " --help print this message"
623 echo " --prefix=PREFIX install in PREFIX [$prefix]"
624 echo " --interp-prefix=PREFIX where to find shared libraries, etc."
625 echo " use %M for cpu name [$interp_prefix]"
626 echo " --target-list=LIST set target list [$target_list]"
627 echo ""
628 echo "Advanced options (experts only):"
629 echo " --source-path=PATH path of source code [$source_path]"
630 echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
631 echo " --cc=CC use C compiler CC [$cc]"
632 echo " --host-cc=CC use C compiler CC [$host_cc] for dyngen etc."
633 echo " --extra-cflags=CFLAGS append extra C compiler flags QEMU_CFLAGS"
634 echo " --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS"
635 echo " --make=MAKE use specified make [$make]"
636 echo " --install=INSTALL use specified install [$install]"
637 echo " --static enable static build [$static]"
638 echo " --enable-debug-tcg enable TCG debugging"
639 echo " --disable-debug-tcg disable TCG debugging (default)"
640 echo " --enable-debug enable common debug build options"
641 echo " --enable-sparse enable sparse checker"
642 echo " --disable-sparse disable sparse checker (default)"
643 echo " --disable-strip disable stripping binaries"
644 echo " --disable-werror disable compilation abort on warning"
645 echo " --disable-sdl disable SDL"
646 echo " --enable-sdl enable SDL"
647 echo " --enable-cocoa enable COCOA (Mac OS X only)"
648 echo " --audio-drv-list=LIST set audio drivers list:"
649 echo " Available drivers: $audio_possible_drivers"
650 echo " --audio-card-list=LIST set list of emulated audio cards [$audio_card_list]"
651 echo " Available cards: $audio_possible_cards"
652 echo " --enable-mixemu enable mixer emulation"
653 echo " --disable-xen disable xen backend driver support"
654 echo " --enable-xen enable xen backend driver support"
655 echo " --disable-brlapi disable BrlAPI"
656 echo " --enable-brlapi enable BrlAPI"
657 echo " --disable-vnc-tls disable TLS encryption for VNC server"
658 echo " --enable-vnc-tls enable TLS encryption for VNC server"
659 echo " --disable-vnc-sasl disable SASL encryption for VNC server"
660 echo " --enable-vnc-sasl enable SASL encryption for VNC server"
661 echo " --disable-curses disable curses output"
662 echo " --enable-curses enable curses output"
663 echo " --disable-curl disable curl connectivity"
664 echo " --enable-curl enable curl connectivity"
665 echo " --disable-fdt disable fdt device tree"
666 echo " --enable-fdt enable fdt device tree"
667 echo " --disable-check-utests disable check unit-tests"
668 echo " --enable-check-utests enable check unit-tests"
669 echo " --disable-bluez disable bluez stack connectivity"
670 echo " --enable-bluez enable bluez stack connectivity"
671 echo " --disable-kvm disable KVM acceleration support"
672 echo " --enable-kvm enable KVM acceleration support"
673 echo " --disable-nptl disable usermode NPTL support"
674 echo " --enable-nptl enable usermode NPTL support"
675 echo " --enable-system enable all system emulation targets"
676 echo " --disable-system disable all system emulation targets"
677 echo " --enable-user enable supported user emulation targets"
678 echo " --disable-user disable all user emulation targets"
679 echo " --enable-linux-user enable all linux usermode emulation targets"
680 echo " --disable-linux-user disable all linux usermode emulation targets"
681 echo " --enable-darwin-user enable all darwin usermode emulation targets"
682 echo " --disable-darwin-user disable all darwin usermode emulation targets"
683 echo " --enable-bsd-user enable all BSD usermode emulation targets"
684 echo " --disable-bsd-user disable all BSD usermode emulation targets"
685 echo " --enable-guest-base enable GUEST_BASE support for usermode"
686 echo " emulation targets"
687 echo " --disable-guest-base disable GUEST_BASE support"
688 echo " --enable-user-pie build usermode emulation targets as PIE"
689 echo " --disable-user-pie do not build usermode emulation targets as PIE"
690 echo " --fmod-lib path to FMOD library"
691 echo " --fmod-inc path to FMOD includes"
692 echo " --oss-lib path to OSS library"
693 echo " --enable-uname-release=R Return R for uname -r in usermode emulation"
694 echo " --sparc_cpu=V Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
695 echo " --disable-vde disable support for vde network"
696 echo " --enable-vde enable support for vde network"
697 echo " --disable-linux-aio disable Linux AIO support"
698 echo " --enable-linux-aio enable Linux AIO support"
699 echo " --disable-blobs disable installing provided firmware blobs"
700 echo " --kerneldir=PATH look for kernel includes in PATH"
701 echo ""
702 echo "NOTE: The object files are built at the place where configure is launched"
703 exit 1
707 # Solaris specific configure tool chain decisions
709 if test "$solaris" = "yes" ; then
710 solinst=`which $install 2> /dev/null | /usr/bin/grep -v "no $install in"`
711 if test -z "$solinst" ; then
712 echo "Solaris install program not found. Use --install=/usr/ucb/install or"
713 echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
714 echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
715 exit 1
717 if test "$solinst" = "/usr/sbin/install" ; then
718 echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
719 echo "try ginstall from the GNU fileutils available from www.blastwave.org"
720 echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
721 exit 1
723 sol_ar=`which ar 2> /dev/null | /usr/bin/grep -v "no ar in"`
724 if test -z "$sol_ar" ; then
725 echo "Error: No path includes ar"
726 if test -f /usr/ccs/bin/ar ; then
727 echo "Add /usr/ccs/bin to your path and rerun configure"
729 exit 1
734 if test -z "$target_list" ; then
735 # these targets are portable
736 if [ "$softmmu" = "yes" ] ; then
737 target_list="\
738 i386-softmmu \
739 x86_64-softmmu \
740 arm-softmmu \
741 cris-softmmu \
742 m68k-softmmu \
743 microblaze-softmmu \
744 mips-softmmu \
745 mipsel-softmmu \
746 mips64-softmmu \
747 mips64el-softmmu \
748 ppc-softmmu \
749 ppcemb-softmmu \
750 ppc64-softmmu \
751 sh4-softmmu \
752 sh4eb-softmmu \
753 sparc-softmmu \
754 sparc64-softmmu \
757 # the following are Linux specific
758 if [ "$linux_user" = "yes" ] ; then
759 target_list="${target_list}\
760 i386-linux-user \
761 x86_64-linux-user \
762 alpha-linux-user \
763 arm-linux-user \
764 armeb-linux-user \
765 cris-linux-user \
766 m68k-linux-user \
767 microblaze-linux-user \
768 mips-linux-user \
769 mipsel-linux-user \
770 ppc-linux-user \
771 ppc64-linux-user \
772 ppc64abi32-linux-user \
773 sh4-linux-user \
774 sh4eb-linux-user \
775 sparc-linux-user \
776 sparc64-linux-user \
777 sparc32plus-linux-user \
780 # the following are Darwin specific
781 if [ "$darwin_user" = "yes" ] ; then
782 target_list="$target_list i386-darwin-user ppc-darwin-user "
784 # the following are BSD specific
785 if [ "$bsd_user" = "yes" ] ; then
786 target_list="${target_list}\
787 i386-bsd-user \
788 x86_64-bsd-user \
789 sparc-bsd-user \
790 sparc64-bsd-user \
793 else
794 target_list=`echo "$target_list" | sed -e 's/,/ /g'`
796 if test -z "$target_list" ; then
797 echo "No targets enabled"
798 exit 1
801 feature_not_found() {
802 feature=$1
804 echo "ERROR"
805 echo "ERROR: User requested feature $feature"
806 echo "ERROR: configure was not able to find it"
807 echo "ERROR"
808 exit 1;
811 if test -z "$cross_prefix" ; then
813 # ---
814 # big/little endian test
815 cat > $TMPC << EOF
816 #include <inttypes.h>
817 int main(int argc, char ** argv){
818 volatile uint32_t i=0x01234567;
819 return (*((uint8_t*)(&i))) == 0x67;
823 if compile_prog "" "" ; then
824 $TMPE && bigendian="yes"
825 else
826 echo big/little test failed
829 else
831 # if cross compiling, cannot launch a program, so make a static guess
832 case "$cpu" in
833 armv4b|hppa|m68k|mips|mips64|ppc|ppc64|s390|sparc|sparc64)
834 bigendian=yes
836 esac
840 # host long bits test
841 hostlongbits="32"
842 case "$cpu" in
843 x86_64|alpha|ia64|sparc64|ppc64)
844 hostlongbits=64
846 esac
849 ##########################################
850 # NPTL probe
852 if test "$nptl" != "no" ; then
853 cat > $TMPC <<EOF
854 #include <sched.h>
855 #include <linux/futex.h>
856 void foo()
858 #if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
859 #error bork
860 #endif
864 if compile_object ; then
865 nptl=yes
866 else
867 if test "$nptl" = "yes" ; then
868 feature_not_found "nptl"
870 nptl=no
874 ##########################################
875 # zlib check
877 cat > $TMPC << EOF
878 #include <zlib.h>
879 int main(void) { zlibVersion(); return 0; }
881 if compile_prog "" "-lz" ; then
883 else
884 echo
885 echo "Error: zlib check failed"
886 echo "Make sure to have the zlib libs and headers installed."
887 echo
888 exit 1
891 ##########################################
892 # xen probe
894 if test "$xen" != "no" ; then
895 xen_libs="-lxenstore -lxenctrl -lxenguest"
896 cat > $TMPC <<EOF
897 #include <xenctrl.h>
898 #include <xs.h>
899 int main(void) { xs_daemon_open(); xc_interface_open(); return 0; }
901 if compile_prog "" "$xen_libs" ; then
902 xen=yes
903 libs_softmmu="$xen_libs $libs_softmmu"
904 else
905 if test "$xen" = "yes" ; then
906 feature_not_found "xen"
908 xen=no
912 ##########################################
913 # Sparse probe
914 if test "$sparse" != "no" ; then
915 if test -x "$(which cgcc 2>/dev/null)"; then
916 sparse=yes
917 else
918 if test "$sparse" = "yes" ; then
919 feature_not_found "sparse"
921 sparse=no
925 ##########################################
926 # SDL probe
928 sdl_too_old=no
930 if test "$sdl" != "no" ; then
931 cat > $TMPC << EOF
932 #include <SDL.h>
933 #undef main /* We don't want SDL to override our main() */
934 int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
936 sdl_cflags=`sdl-config --cflags 2> /dev/null`
937 sdl_libs=`sdl-config --libs 2> /dev/null`
938 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
939 _sdlversion=`sdl-config --version | sed 's/[^0-9]//g'`
940 if test "$_sdlversion" -lt 121 ; then
941 sdl_too_old=yes
942 else
943 if test "$cocoa" = "no" ; then
944 sdl=yes
948 # static link with sdl ?
949 if test "$sdl" = "yes" -a "$static" = "yes" ; then
950 sdl_libs=`sdl-config --static-libs 2>/dev/null`
951 if test `sdl-config --static-libs 2>/dev/null | grep \\\-laa > /dev/null` ; then
952 sdl_libs="$sdl_libs `aalib-config --static-libs >2 /dev/null`"
953 sdl_cflags="$sd_cflags `aalib-config --cflags >2 /dev/null`"
955 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
957 else
958 sdl=no
960 fi # static link
961 else # sdl not found
962 if test "$sdl" = "yes" ; then
963 feature_not_found "sdl"
965 sdl=no
966 fi # sdl compile test
969 if test "$sdl" = "yes" ; then
970 cat > $TMPC <<EOF
971 #include <SDL.h>
972 #if defined(SDL_VIDEO_DRIVER_X11)
973 #include <X11/XKBlib.h>
974 #else
975 #error No x11 support
976 #endif
977 int main(void) { return 0; }
979 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
980 sdl_libs="$sdl_libs -lX11"
982 if test "$mingw32" = "yes" ; then
983 sdl_libs="`echo $sdl_libs | sed s/-mwindows//g` -mconsole"
985 libs_softmmu="$sdl_libs $libs_softmmu"
988 ##########################################
989 # VNC TLS detection
990 if test "$vnc_tls" != "no" ; then
991 cat > $TMPC <<EOF
992 #include <gnutls/gnutls.h>
993 int main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
995 vnc_tls_cflags=`pkg-config --cflags gnutls 2> /dev/null`
996 vnc_tls_libs=`pkg-config --libs gnutls 2> /dev/null`
997 if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
998 vnc_tls=yes
999 libs_softmmu="$vnc_tls_libs $libs_softmmu"
1000 else
1001 if test "$vnc_tls" = "yes" ; then
1002 feature_not_found "vnc-tls"
1004 vnc_tls=no
1008 ##########################################
1009 # VNC SASL detection
1010 if test "$vnc_sasl" != "no" ; then
1011 cat > $TMPC <<EOF
1012 #include <sasl/sasl.h>
1013 #include <stdio.h>
1014 int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
1016 # Assuming Cyrus-SASL installed in /usr prefix
1017 vnc_sasl_cflags=""
1018 vnc_sasl_libs="-lsasl2"
1019 if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1020 vnc_sasl=yes
1021 libs_softmmu="$vnc_sasl_libs $libs_softmmu"
1022 else
1023 if test "$vnc_sasl" = "yes" ; then
1024 feature_not_found "vnc-sasl"
1026 vnc_sasl=no
1030 ##########################################
1031 # fnmatch() probe, used for ACL routines
1032 fnmatch="no"
1033 cat > $TMPC << EOF
1034 #include <fnmatch.h>
1035 int main(void)
1037 fnmatch("foo", "foo", 0);
1038 return 0;
1041 if compile_prog "" "" ; then
1042 fnmatch="yes"
1045 ##########################################
1046 # vde libraries probe
1047 if test "$vde" != "no" ; then
1048 vde_libs="-lvdeplug"
1049 cat > $TMPC << EOF
1050 #include <libvdeplug.h>
1051 int main(void)
1053 struct vde_open_args a = {0, 0, 0};
1054 vde_open("", "", &a);
1055 return 0;
1058 if compile_prog "" "$vde_libs" ; then
1059 vde=yes
1060 libs_softmmu="$vde_libs $libs_softmmu"
1061 libs_tools="$vde_libs $libs_tools"
1062 else
1063 if test "$vde" = "yes" ; then
1064 feature_not_found "vde"
1066 vde=no
1070 ##########################################
1071 # Sound support libraries probe
1073 audio_drv_probe()
1075 drv=$1
1076 hdr=$2
1077 lib=$3
1078 exp=$4
1079 cfl=$5
1080 cat > $TMPC << EOF
1081 #include <$hdr>
1082 int main(void) { $exp }
1084 if compile_prog "$cfl" "$lib" ; then
1086 else
1087 echo
1088 echo "Error: $drv check failed"
1089 echo "Make sure to have the $drv libs and headers installed."
1090 echo
1091 exit 1
1095 audio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
1096 for drv in $audio_drv_list; do
1097 case $drv in
1098 alsa)
1099 audio_drv_probe $drv alsa/asoundlib.h -lasound \
1100 "snd_pcm_t **handle; return snd_pcm_close(*handle);"
1101 libs_softmmu="-lasound $libs_softmmu"
1104 fmod)
1105 if test -z $fmod_lib || test -z $fmod_inc; then
1106 echo
1107 echo "Error: You must specify path to FMOD library and headers"
1108 echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
1109 echo
1110 exit 1
1112 audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
1113 libs_softmmu="$fmod_lib $libs_softmmu"
1116 esd)
1117 audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
1118 libs_softmmu="-lesd $libs_softmmu"
1119 audio_pt_int="yes"
1123 audio_drv_probe $drv pulse/simple.h -lpulse-simple \
1124 "pa_simple *s = NULL; pa_simple_free(s); return 0;"
1125 libs_softmmu="-lpulse-simple $libs_softmmu"
1126 audio_pt_int="yes"
1129 coreaudio)
1130 libs_softmmu="-framework CoreAudio $libs_softmmu"
1133 dsound)
1134 libs_softmmu="-lole32 -ldxguid $libs_softmmu"
1137 oss)
1138 libs_softmmu="$oss_lib $libs_softmmu"
1141 sdl|wav)
1142 # XXX: Probes for CoreAudio, DirectSound, SDL(?)
1146 echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
1147 echo
1148 echo "Error: Unknown driver '$drv' selected"
1149 echo "Possible drivers are: $audio_possible_drivers"
1150 echo
1151 exit 1
1154 esac
1155 done
1157 ##########################################
1158 # BrlAPI probe
1160 if test "$brlapi" != "no" ; then
1161 brlapi_libs="-lbrlapi"
1162 cat > $TMPC << EOF
1163 #include <brlapi.h>
1164 int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
1166 if compile_prog "" "$brlapi_libs" ; then
1167 brlapi=yes
1168 libs_softmmu="$brlapi_libs $libs_softmmu"
1169 else
1170 if test "$brlapi" = "yes" ; then
1171 feature_not_found "brlapi"
1173 brlapi=no
1177 ##########################################
1178 # curses probe
1179 curses_list="-lncurses -lcurses"
1181 if test "$curses" != "no" ; then
1182 curses_found=no
1183 cat > $TMPC << EOF
1184 #include <curses.h>
1185 #ifdef __OpenBSD__
1186 #define resize_term resizeterm
1187 #endif
1188 int main(void) { resize_term(0, 0); return curses_version(); }
1190 for curses_lib in $curses_list; do
1191 if compile_prog "" "$curses_lib" ; then
1192 curses_found=yes
1193 libs_softmmu="$curses_lib $libs_softmmu"
1194 break
1196 done
1197 if test "$curses_found" = "yes" ; then
1198 curses=yes
1199 else
1200 if test "$curses" = "yes" ; then
1201 feature_not_found "curses"
1203 curses=no
1207 ##########################################
1208 # curl probe
1210 if test "$curl" != "no" ; then
1211 cat > $TMPC << EOF
1212 #include <curl/curl.h>
1213 int main(void) { return curl_easy_init(); }
1215 curl_cflags=`curl-config --cflags 2>/dev/null`
1216 curl_libs=`curl-config --libs 2>/dev/null`
1217 if compile_prog "$curl_cflags" "$curl_libs" ; then
1218 curl=yes
1219 libs_tools="$curl_libs $libs_tools"
1220 libs_softmmu="$curl_libs $libs_softmmu"
1221 else
1222 if test "$curl" = "yes" ; then
1223 feature_not_found "curl"
1225 curl=no
1227 fi # test "$curl"
1229 ##########################################
1230 # check framework probe
1232 if test "$check_utests" != "no" ; then
1233 cat > $TMPC << EOF
1234 #include <check.h>
1235 int main(void) { suite_create("qemu test"); return 0; }
1237 check_libs=`pkg-config --libs check`
1238 if compile_prog "" $check_libs ; then
1239 check_utests=yes
1240 libs_tools="$check_libs $libs_tools"
1241 else
1242 if test "$check_utests" = "yes" ; then
1243 feature_not_found "check"
1245 check_utests=no
1247 fi # test "$check_utests"
1249 ##########################################
1250 # bluez support probe
1251 if test "$bluez" != "no" ; then
1252 cat > $TMPC << EOF
1253 #include <bluetooth/bluetooth.h>
1254 int main(void) { return bt_error(0); }
1256 bluez_cflags=`pkg-config --cflags bluez 2> /dev/null`
1257 bluez_libs=`pkg-config --libs bluez 2> /dev/null`
1258 if compile_prog "$bluez_cflags" "$bluez_libs" ; then
1259 bluez=yes
1260 libs_softmmu="$bluez_libs $libs_softmmu"
1261 else
1262 if test "$bluez" = "yes" ; then
1263 feature_not_found "bluez"
1265 bluez="no"
1269 ##########################################
1270 # kvm probe
1271 if test "$kvm" != "no" ; then
1272 cat > $TMPC <<EOF
1273 #include <linux/kvm.h>
1274 #if !defined(KVM_API_VERSION) || KVM_API_VERSION < 12 || KVM_API_VERSION > 12
1275 #error Invalid KVM version
1276 #endif
1277 #if !defined(KVM_CAP_USER_MEMORY)
1278 #error Missing KVM capability KVM_CAP_USER_MEMORY
1279 #endif
1280 #if !defined(KVM_CAP_SET_TSS_ADDR)
1281 #error Missing KVM capability KVM_CAP_SET_TSS_ADDR
1282 #endif
1283 #if !defined(KVM_CAP_DESTROY_MEMORY_REGION_WORKS)
1284 #error Missing KVM capability KVM_CAP_DESTROY_MEMORY_REGION_WORKS
1285 #endif
1286 int main(void) { return 0; }
1288 if test "$kerneldir" != "" ; then
1289 kvm_cflags=-I"$kerneldir"/include
1290 if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) \
1291 -a -d "$kerneldir/arch/x86/include" ; then
1292 kvm_cflags="$kvm_cflags -I$kerneldir/arch/x86/include"
1293 elif test "$cpu" = "ppc" -a -d "$kerneldir/arch/powerpc/include" ; then
1294 kvm_cflags="$kvm_cflags -I$kerneldir/arch/powerpc/include"
1295 elif test -d "$kerneldir/arch/$cpu/include" ; then
1296 kvm_cflags="$kvm_cflags -I$kerneldir/arch/$cpu/include"
1298 else
1299 kvm_cflags=""
1301 if compile_prog "$kvm_cflags" "" ; then
1302 kvm=yes
1303 else
1304 if test "$kvm" = "yes" ; then
1305 if [ -x "`which awk 2>/dev/null`" ] && \
1306 [ -x "`which grep 2>/dev/null`" ]; then
1307 kvmerr=`LANG=C $cc $QEMU_CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&1 \
1308 | grep "error: " \
1309 | awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'`
1310 if test "$kvmerr" != "" ; then
1311 echo -e "${kvmerr}\n\
1312 NOTE: To enable KVM support, update your kernel to 2.6.29+ or install \
1313 recent kvm-kmod from http://sourceforge.net/projects/kvm."
1316 feature_not_found "kvm"
1318 kvm=no
1322 ##########################################
1323 # pthread probe
1324 PTHREADLIBS_LIST="-lpthread -lpthreadGC2"
1326 pthread=no
1327 cat > $TMPC << EOF
1328 #include <pthread.h>
1329 int main(void) { pthread_create(0,0,0,0); return 0; }
1331 for pthread_lib in $PTHREADLIBS_LIST; do
1332 if compile_prog "" "$pthread_lib" ; then
1333 pthread=yes
1334 LIBS="$pthread_lib $LIBS"
1335 break
1337 done
1339 if test "$mingw32" != yes -a "$pthread" = no; then
1340 echo
1341 echo "Error: pthread check failed"
1342 echo "Make sure to have the pthread libs and headers installed."
1343 echo
1344 exit 1
1347 ##########################################
1348 # linux-aio probe
1349 AIOLIBS=""
1351 if test "$linux_aio" != "no" ; then
1352 cat > $TMPC <<EOF
1353 #include <libaio.h>
1354 #include <sys/eventfd.h>
1355 int main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
1357 if compile_prog "" "-laio" ; then
1358 linux_aio=yes
1359 LIBS="$LIBS -laio"
1360 else
1361 if test "$linux_aio" = "yes" ; then
1362 feature_not_found "linux AIO"
1364 linux_aio=no
1368 ##########################################
1369 # iovec probe
1370 cat > $TMPC <<EOF
1371 #include <sys/types.h>
1372 #include <sys/uio.h>
1373 #include <unistd.h>
1374 int main(void) { struct iovec iov; return 0; }
1376 iovec=no
1377 if compile_prog "" "" ; then
1378 iovec=yes
1381 ##########################################
1382 # preadv probe
1383 cat > $TMPC <<EOF
1384 #include <sys/types.h>
1385 #include <sys/uio.h>
1386 #include <unistd.h>
1387 int main(void) { preadv; }
1389 preadv=no
1390 if compile_prog "" "" ; then
1391 preadv=yes
1394 ##########################################
1395 # fdt probe
1396 if test "$fdt" != "no" ; then
1397 fdt_libs="-lfdt"
1398 cat > $TMPC << EOF
1399 int main(void) { return 0; }
1401 if compile_prog "" "$fdt_libs" ; then
1402 fdt=yes
1403 libs_softmmu="$fdt_libs $libs_softmmu"
1404 else
1405 if test "$fdt" = "yes" ; then
1406 feature_not_found "fdt"
1408 fdt=no
1413 # Check for xxxat() functions when we are building linux-user
1414 # emulator. This is done because older glibc versions don't
1415 # have syscall stubs for these implemented.
1417 atfile=no
1418 cat > $TMPC << EOF
1419 #define _ATFILE_SOURCE
1420 #include <sys/types.h>
1421 #include <fcntl.h>
1422 #include <unistd.h>
1425 main(void)
1427 /* try to unlink nonexisting file */
1428 return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
1431 if compile_prog "" "" ; then
1432 atfile=yes
1435 # Check for inotify functions when we are building linux-user
1436 # emulator. This is done because older glibc versions don't
1437 # have syscall stubs for these implemented. In that case we
1438 # don't provide them even if kernel supports them.
1440 inotify=no
1441 cat > $TMPC << EOF
1442 #include <sys/inotify.h>
1445 main(void)
1447 /* try to start inotify */
1448 return inotify_init();
1451 if compile_prog "" "" ; then
1452 inotify=yes
1455 # check if utimensat and futimens are supported
1456 utimens=no
1457 cat > $TMPC << EOF
1458 #define _ATFILE_SOURCE
1459 #define _GNU_SOURCE
1460 #include <stddef.h>
1461 #include <fcntl.h>
1463 int main(void)
1465 utimensat(AT_FDCWD, "foo", NULL, 0);
1466 futimens(0, NULL);
1467 return 0;
1470 if compile_prog "" "" ; then
1471 utimens=yes
1474 # check if pipe2 is there
1475 pipe2=no
1476 cat > $TMPC << EOF
1477 #define _GNU_SOURCE
1478 #include <unistd.h>
1479 #include <fcntl.h>
1481 int main(void)
1483 int pipefd[2];
1484 pipe2(pipefd, O_CLOEXEC);
1485 return 0;
1488 if compile_prog "" "" ; then
1489 pipe2=yes
1492 # check if tee/splice is there. vmsplice was added same time.
1493 splice=no
1494 cat > $TMPC << EOF
1495 #define _GNU_SOURCE
1496 #include <unistd.h>
1497 #include <fcntl.h>
1498 #include <limits.h>
1500 int main(void)
1502 int len, fd;
1503 len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
1504 splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
1505 return 0;
1508 if compile_prog "" "" ; then
1509 splice=yes
1512 # check if eventfd is supported
1513 eventfd=no
1514 cat > $TMPC << EOF
1515 #include <sys/eventfd.h>
1517 int main(void)
1519 int efd = eventfd(0, 0);
1520 return 0;
1523 if compile_prog "" "" ; then
1524 eventfd=yes
1527 # Check if tools are available to build documentation.
1528 if test "$docs" != "no" ; then
1529 if test -x "`which texi2html 2>/dev/null`" -a \
1530 -x "`which pod2man 2>/dev/null`" ; then
1531 docs=yes
1532 else
1533 if test "$docs" = "yes" ; then
1534 feature_not_found "docs"
1536 docs=no
1540 # Search for bsawp_32 function
1541 byteswap_h=no
1542 cat > $TMPC << EOF
1543 #include <byteswap.h>
1544 int main(void) { return bswap_32(0); }
1546 if compile_prog "" "" ; then
1547 byteswap_h=yes
1550 # Search for bsawp_32 function
1551 bswap_h=no
1552 cat > $TMPC << EOF
1553 #include <sys/endian.h>
1554 #include <sys/types.h>
1555 #include <machine/bswap.h>
1556 int main(void) { return bswap32(0); }
1558 if compile_prog "" "" ; then
1559 bswap_h=yes
1562 ##########################################
1563 # Do we need librt
1564 cat > $TMPC <<EOF
1565 #include <signal.h>
1566 #include <time.h>
1567 int main(void) { clockid_t id; return clock_gettime(id, NULL); }
1570 if compile_prog "" "" ; then
1572 elif compile_prog "" "-lrt" ; then
1573 LIBS="-lrt $LIBS"
1576 # Determine what linker flags to use to force archive inclusion
1577 check_linker_flags()
1580 if test "$2" ; then
1581 w2=-Wl,$2
1583 compile_prog "" "-Wl,$1 ${w2}"
1586 cat > $TMPC << EOF
1587 int main(void) { }
1589 if check_linker_flags --whole-archive --no-whole-archive ; then
1590 # GNU ld
1591 arlibs_begin="-Wl,--whole-archive"
1592 arlibs_end="-Wl,--no-whole-archive"
1593 elif check_linker_flags -z,allextract -z,defaultextract ; then
1594 # Solaris ld
1595 arlibs_begin="-Wl,-z,allextract"
1596 arlibs_end="-Wl,-z,defaultextract"
1597 elif check_linker_flags -all_load ; then
1598 # Mac OS X
1599 arlibs_begin="-all_load"
1600 arlibs_end=""
1601 else
1602 echo "Error: your linker does not support --whole-archive or -z."
1603 echo "Please report to qemu-devel@nongnu.org"
1604 exit 1
1607 if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
1608 "$aix" != "yes" ; then
1609 libs_softmmu="-lutil $libs_softmmu"
1612 ##########################################
1613 # check if the compiler defines offsetof
1615 need_offsetof=yes
1616 cat > $TMPC << EOF
1617 #include <stddef.h>
1618 int main(void) { struct s { int f; }; return offsetof(struct s, f); }
1620 if compile_prog "" "" ; then
1621 need_offsetof=no
1624 ##########################################
1625 # check if we have fdatasync
1627 fdatasync=no
1628 cat > $TMPC << EOF
1629 #include <unistd.h>
1630 int main(void) { return fdatasync(0); }
1632 if compile_prog "" "" ; then
1633 fdatasync=yes
1636 # End of CC checks
1637 # After here, no more $cc or $ld runs
1639 # default flags for all hosts
1640 QEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
1641 CFLAGS="-g $CFLAGS"
1642 if test "$debug" = "no" ; then
1643 CFLAGS="-O2 $CFLAGS"
1645 QEMU_CFLAGS="-Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
1646 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
1647 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
1648 QEMU_CFLAGS="-U_FORTIFY_SOURCE $QEMU_CFLAGS"
1649 QEMU_CFLAGS="-I. -I\$(SRC_PATH) -MMD -MP -MT \$@ $QEMU_CFLAGS"
1650 LDFLAGS="-g $LDFLAGS"
1652 # Consult white-list to determine whether to enable werror
1653 # by default. Only enable by default for git builds
1654 if test -z "$werror" ; then
1655 z_version=`cut -f3 -d. $source_path/VERSION`
1656 if test "$z_version" = "50" -a \
1657 "$linux" = "yes" ; then
1658 werror="yes"
1659 else
1660 werror="no"
1664 if test "$werror" = "yes" ; then
1665 QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
1668 if test "$solaris" = "no" ; then
1669 if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
1670 LDFLAGS="-Wl,--warn-common $LDFLAGS"
1674 if test "$mingw32" = "yes" ; then
1675 if test -z "$prefix" ; then
1676 prefix="c:/Program Files/Qemu"
1678 mansuffix=""
1679 datasuffix=""
1680 docsuffix=""
1681 binsuffix=""
1682 else
1683 if test -z "$prefix" ; then
1684 prefix="/usr/local"
1686 mansuffix="/share/man"
1687 datasuffix="/share/qemu"
1688 docsuffix="/share/doc/qemu"
1689 binsuffix="/bin"
1692 echo "Install prefix $prefix"
1693 echo "BIOS directory $prefix$datasuffix"
1694 echo "binary directory $prefix$binsuffix"
1695 if test "$mingw32" = "no" ; then
1696 echo "Manual directory $prefix$mansuffix"
1697 echo "ELF interp prefix $interp_prefix"
1699 echo "Source path $source_path"
1700 echo "C compiler $cc"
1701 echo "Host C compiler $host_cc"
1702 echo "CFLAGS $CFLAGS"
1703 echo "QEMU_CFLAGS $QEMU_CFLAGS"
1704 echo "LDFLAGS $LDFLAGS"
1705 echo "make $make"
1706 echo "install $install"
1707 echo "host CPU $cpu"
1708 echo "host big endian $bigendian"
1709 echo "target list $target_list"
1710 echo "tcg debug enabled $debug_tcg"
1711 echo "gprof enabled $gprof"
1712 echo "sparse enabled $sparse"
1713 echo "strip binaries $strip_opt"
1714 echo "profiler $profiler"
1715 echo "static build $static"
1716 echo "-Werror enabled $werror"
1717 if test "$darwin" = "yes" ; then
1718 echo "Cocoa support $cocoa"
1720 echo "SDL support $sdl"
1721 echo "curses support $curses"
1722 echo "curl support $curl"
1723 echo "check support $check_utests"
1724 echo "mingw32 support $mingw32"
1725 echo "Audio drivers $audio_drv_list"
1726 echo "Extra audio cards $audio_card_list"
1727 echo "Mixer emulation $mixemu"
1728 echo "VNC TLS support $vnc_tls"
1729 echo "VNC SASL support $vnc_sasl"
1730 if test -n "$sparc_cpu"; then
1731 echo "Target Sparc Arch $sparc_cpu"
1733 echo "xen support $xen"
1734 echo "brlapi support $brlapi"
1735 echo "bluez support $bluez"
1736 echo "Documentation $docs"
1737 [ ! -z "$uname_release" ] && \
1738 echo "uname -r $uname_release"
1739 echo "NPTL support $nptl"
1740 echo "GUEST_BASE $guest_base"
1741 echo "PIE user targets $user_pie"
1742 echo "vde support $vde"
1743 echo "Linux AIO support $linux_aio"
1744 echo "Install blobs $blobs"
1745 echo "KVM support $kvm"
1746 echo "fdt support $fdt"
1747 echo "preadv support $preadv"
1748 echo "fdatasync $fdatasync"
1750 if test $sdl_too_old = "yes"; then
1751 echo "-> Your SDL version is too old - please upgrade to have SDL support"
1754 config_host_mak="config-host.mak"
1755 config_host_h="config-host.h"
1756 config_host_ld="config-host.ld"
1758 #echo "Creating $config_host_mak and $config_host_h"
1760 test -f $config_host_h && mv $config_host_h ${config_host_h}~
1762 echo "# Automatically generated by configure - do not modify" > $config_host_mak
1763 printf "# Configured with:" >> $config_host_mak
1764 printf " '%s'" "$0" "$@" >> $config_host_mak
1765 echo >> $config_host_mak
1767 echo "CONFIG_QEMU_SHAREDIR=\"$prefix$datasuffix\"" >> $config_host_mak
1769 case "$cpu" in
1770 i386|x86_64|alpha|cris|hppa|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|s390|sparc|sparc64)
1771 ARCH=$cpu
1773 armv4b|armv4l)
1774 ARCH=arm
1777 echo "Unsupported CPU = $cpu"
1778 exit 1
1780 esac
1781 echo "ARCH=$ARCH" >> $config_host_mak
1782 if test "$debug_tcg" = "yes" ; then
1783 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
1785 if test "$debug" = "yes" ; then
1786 echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
1788 if test "$strip_opt" = "yes" ; then
1789 echo "STRIP_OPT=-s" >> $config_host_mak
1791 if test "$bigendian" = "yes" ; then
1792 echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
1794 echo "HOST_LONG_BITS=$hostlongbits" >> $config_host_mak
1795 if test "$mingw32" = "yes" ; then
1796 echo "CONFIG_WIN32=y" >> $config_host_mak
1797 else
1798 echo "CONFIG_POSIX=y" >> $config_host_mak
1801 if test "$darwin" = "yes" ; then
1802 echo "CONFIG_DARWIN=y" >> $config_host_mak
1805 if test "$aix" = "yes" ; then
1806 echo "CONFIG_AIX=y" >> $config_host_mak
1809 if test "$solaris" = "yes" ; then
1810 echo "CONFIG_SOLARIS=y" >> $config_host_mak
1811 echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
1812 if test "$needs_libsunmath" = "yes" ; then
1813 echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
1816 if test "$static" = "yes" ; then
1817 echo "CONFIG_STATIC=y" >> $config_host_mak
1818 LDFLAGS="-static $LDFLAGS"
1820 if test $profiler = "yes" ; then
1821 echo "CONFIG_PROFILER=y" >> $config_host_mak
1823 if test "$slirp" = "yes" ; then
1824 echo "CONFIG_SLIRP=y" >> $config_host_mak
1825 CFLAGS="-I\$(SRC_PATH)/slirp $CFLAGS"
1827 if test "$vde" = "yes" ; then
1828 echo "CONFIG_VDE=y" >> $config_host_mak
1830 for card in $audio_card_list; do
1831 def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
1832 echo "$def=y" >> $config_host_mak
1833 done
1834 echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
1835 for drv in $audio_drv_list; do
1836 def=CONFIG_`echo $drv | tr '[:lower:]' '[:upper:]'`
1837 echo "$def=y" >> $config_host_mak
1838 if test "$drv" = "fmod"; then
1839 echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
1841 done
1842 if test "$audio_pt_int" = "yes" ; then
1843 echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
1845 if test "$mixemu" = "yes" ; then
1846 echo "CONFIG_MIXEMU=y" >> $config_host_mak
1848 if test "$vnc_tls" = "yes" ; then
1849 echo "CONFIG_VNC_TLS=y" >> $config_host_mak
1850 echo "VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_host_mak
1852 if test "$vnc_sasl" = "yes" ; then
1853 echo "CONFIG_VNC_SASL=y" >> $config_host_mak
1854 echo "VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak
1856 if test "$fnmatch" = "yes" ; then
1857 echo "CONFIG_FNMATCH=y" >> $config_host_mak
1859 qemu_version=`head $source_path/VERSION`
1860 echo "VERSION=$qemu_version" >>$config_host_mak
1861 echo "PKGVERSION=$pkgversion" >>$config_host_mak
1862 echo "SRC_PATH=$source_path" >> $config_host_mak
1863 if [ "$source_path_used" = "yes" ]; then
1864 echo "VPATH=$source_path" >> $config_host_mak
1866 echo "TARGET_DIRS=$target_list" >> $config_host_mak
1867 if [ "$docs" = "yes" ] ; then
1868 echo "BUILD_DOCS=yes" >> $config_host_mak
1870 if test "$sdl" = "yes" ; then
1871 echo "CONFIG_SDL=y" >> $config_host_mak
1872 echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
1874 if test "$cocoa" = "yes" ; then
1875 echo "CONFIG_COCOA=y" >> $config_host_mak
1877 if test "$curses" = "yes" ; then
1878 echo "CONFIG_CURSES=y" >> $config_host_mak
1880 if test "$atfile" = "yes" ; then
1881 echo "CONFIG_ATFILE=y" >> $config_host_mak
1883 if test "$utimens" = "yes" ; then
1884 echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
1886 if test "$pipe2" = "yes" ; then
1887 echo "CONFIG_PIPE2=y" >> $config_host_mak
1889 if test "$splice" = "yes" ; then
1890 echo "CONFIG_SPLICE=y" >> $config_host_mak
1892 if test "$eventfd" = "yes" ; then
1893 echo "CONFIG_EVENTFD=y" >> $config_host_mak
1895 if test "$inotify" = "yes" ; then
1896 echo "CONFIG_INOTIFY=y" >> $config_host_mak
1898 if test "$byteswap_h" = "yes" ; then
1899 echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
1901 if test "$bswap_h" = "yes" ; then
1902 echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
1904 if test "$curl" = "yes" ; then
1905 echo "CONFIG_CURL=y" >> $config_host_mak
1906 echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
1908 if test "$brlapi" = "yes" ; then
1909 echo "CONFIG_BRLAPI=y" >> $config_host_mak
1911 if test "$bluez" = "yes" ; then
1912 echo "CONFIG_BLUEZ=y" >> $config_host_mak
1913 echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
1915 if test "$xen" = "yes" ; then
1916 echo "CONFIG_XEN=y" >> $config_host_mak
1918 if test "$linux_aio" = "yes" ; then
1919 echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
1921 if test "$blobs" = "yes" ; then
1922 echo "INSTALL_BLOBS=yes" >> $config_host_mak
1924 if test "$iovec" = "yes" ; then
1925 echo "CONFIG_IOVEC=y" >> $config_host_mak
1927 if test "$preadv" = "yes" ; then
1928 echo "CONFIG_PREADV=y" >> $config_host_mak
1930 if test "$fdt" = "yes" ; then
1931 echo "CONFIG_FDT=y" >> $config_host_mak
1933 if test "$need_offsetof" = "yes" ; then
1934 echo "CONFIG_NEED_OFFSETOF=y" >> $config_host_mak
1936 if test "$fdatasync" = "yes" ; then
1937 echo "CONFIG_FDATASYNC=y" >> $config_host_mak
1940 # XXX: suppress that
1941 if [ "$bsd" = "yes" ] ; then
1942 echo "CONFIG_BSD=y" >> $config_host_mak
1945 echo "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
1947 # USB host support
1948 case "$usb" in
1949 linux)
1950 echo "HOST_USB=linux" >> $config_host_mak
1952 bsd)
1953 echo "HOST_USB=bsd" >> $config_host_mak
1956 echo "HOST_USB=stub" >> $config_host_mak
1958 esac
1960 tools=
1961 if test `expr "$target_list" : ".*softmmu.*"` != 0 ; then
1962 tools="qemu-img\$(EXESUF) $tools"
1963 if [ "$linux" = "yes" ] ; then
1964 tools="qemu-nbd\$(EXESUF) qemu-io\$(EXESUF) $tools"
1965 if [ "$check_utests" = "yes" ]; then
1966 tools="check-qint check-qstring check-qdict $tools"
1968 elif test "$mingw32" = "yes" ; then
1969 tools="qemu-io\$(EXESUF) $tools"
1972 echo "TOOLS=$tools" >> $config_host_mak
1974 # Mac OS X ships with a broken assembler
1975 roms=
1976 if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
1977 "$targetos" != "Darwin" ; then
1978 roms="optionrom"
1980 echo "ROMS=$roms" >> $config_host_mak
1982 echo "prefix=$prefix" >> $config_host_mak
1983 echo "bindir=\${prefix}$binsuffix" >> $config_host_mak
1984 echo "mandir=\${prefix}$mansuffix" >> $config_host_mak
1985 echo "datadir=\${prefix}$datasuffix" >> $config_host_mak
1986 echo "docdir=\${prefix}$docsuffix" >> $config_host_mak
1987 echo "MAKE=$make" >> $config_host_mak
1988 echo "INSTALL=$install" >> $config_host_mak
1989 echo "INSTALL_DIR=$install -d -m0755 -p" >> $config_host_mak
1990 echo "INSTALL_DATA=$install -m0644 -p" >> $config_host_mak
1991 echo "INSTALL_PROG=$install -m0755 -p" >> $config_host_mak
1992 echo "CC=$cc" >> $config_host_mak
1993 echo "HOST_CC=$host_cc" >> $config_host_mak
1994 if test "$sparse" = "yes" ; then
1995 echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_host_mak
1996 echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_host_mak
1997 echo "QEMU_CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
1999 echo "AR=$ar" >> $config_host_mak
2000 echo "OBJCOPY=$objcopy" >> $config_host_mak
2001 echo "LD=$ld" >> $config_host_mak
2002 echo "CFLAGS=$CFLAGS" >> $config_host_mak
2003 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
2004 echo "HELPER_CFLAGS=$helper_cflags" >> $config_host_mak
2005 echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
2006 echo "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak
2007 echo "ARLIBS_END=$arlibs_end" >> $config_host_mak
2008 echo "LIBS+=$LIBS" >> $config_host_mak
2009 echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
2010 echo "EXESUF=$EXESUF" >> $config_host_mak
2012 echo "/* Automatically generated by configure - do not modify */" > $config_host_h
2014 /bin/sh $source_path/create_config < $config_host_mak >> $config_host_h
2016 if test -f ${config_host_h}~ ; then
2017 if cmp -s $config_host_h ${config_host_h}~ ; then
2018 mv ${config_host_h}~ $config_host_h
2019 else
2020 rm ${config_host_h}~
2024 # generate list of library paths for linker script
2026 $ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
2028 if test -f ${config_host_ld}~ ; then
2029 if cmp -s $config_host_ld ${config_host_ld}~ ; then
2030 mv ${config_host_ld}~ $config_host_ld
2031 else
2032 rm ${config_host_ld}~
2036 for target in $target_list; do
2037 target_dir="$target"
2038 config_mak=$target_dir/config.mak
2039 config_h=$target_dir/config.h
2040 target_arch2=`echo $target | cut -d '-' -f 1`
2041 target_bigendian="no"
2042 case "$target_arch2" in
2043 armeb|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|sh4eb|sparc|sparc64|sparc32plus)
2044 target_bigendian=yes
2046 esac
2047 target_softmmu="no"
2048 target_user_only="no"
2049 target_linux_user="no"
2050 target_darwin_user="no"
2051 target_bsd_user="no"
2052 case "$target" in
2053 ${target_arch2}-softmmu)
2054 target_softmmu="yes"
2056 ${target_arch2}-linux-user)
2057 target_user_only="yes"
2058 target_linux_user="yes"
2060 ${target_arch2}-darwin-user)
2061 target_user_only="yes"
2062 target_darwin_user="yes"
2064 ${target_arch2}-bsd-user)
2065 target_user_only="yes"
2066 target_bsd_user="yes"
2069 echo "ERROR: Target '$target' not recognised"
2070 exit 1
2072 esac
2074 #echo "Creating $config_mak, $config_h and $target_dir/Makefile"
2076 test -f $config_h && mv $config_h ${config_h}~
2078 mkdir -p $target_dir
2079 mkdir -p $target_dir/fpu
2080 mkdir -p $target_dir/tcg
2081 mkdir -p $target_dir/ide
2082 if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
2083 mkdir -p $target_dir/nwfpe
2087 # don't use ln -sf as not all "ln -sf" over write the file/link
2089 rm -f $target_dir/Makefile
2090 ln -s $source_path/Makefile.target $target_dir/Makefile
2093 echo "# Automatically generated by configure - do not modify" > $config_mak
2095 echo "include ../config-host.mak" >> $config_mak
2097 bflt="no"
2098 elfload32="no"
2099 target_nptl="no"
2100 interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
2101 echo "CONFIG_QEMU_PREFIX=\"$interp_prefix1\"" >> $config_mak
2102 gdb_xml_files=""
2104 TARGET_ARCH="$target_arch2"
2105 TARGET_BASE_ARCH=""
2106 TARGET_ABI_DIR=""
2108 case "$target_arch2" in
2109 i386)
2110 target_phys_bits=32
2112 x86_64)
2113 TARGET_BASE_ARCH=i386
2114 target_phys_bits=64
2116 alpha)
2117 target_phys_bits=64
2119 arm|armeb)
2120 TARGET_ARCH=arm
2121 bflt="yes"
2122 target_nptl="yes"
2123 gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
2124 target_phys_bits=32
2126 cris)
2127 target_nptl="yes"
2128 target_phys_bits=32
2130 m68k)
2131 bflt="yes"
2132 gdb_xml_files="cf-core.xml cf-fp.xml"
2133 target_phys_bits=32
2135 microblaze)
2136 bflt="yes"
2137 target_nptl="yes"
2138 target_phys_bits=32
2140 mips|mipsel)
2141 TARGET_ARCH=mips
2142 echo "TARGET_ABI_MIPSO32=y" >> $config_mak
2143 target_nptl="yes"
2144 target_phys_bits=64
2146 mipsn32|mipsn32el)
2147 TARGET_ARCH=mipsn32
2148 TARGET_BASE_ARCH=mips
2149 echo "TARGET_ABI_MIPSN32=y" >> $config_mak
2150 target_phys_bits=64
2152 mips64|mips64el)
2153 TARGET_ARCH=mips64
2154 TARGET_BASE_ARCH=mips
2155 echo "TARGET_ABI_MIPSN64=y" >> $config_mak
2156 target_phys_bits=64
2158 ppc)
2159 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2160 target_phys_bits=32
2161 target_nptl="yes"
2163 ppcemb)
2164 TARGET_BASE_ARCH=ppc
2165 TARGET_ABI_DIR=ppc
2166 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2167 target_phys_bits=64
2168 target_nptl="yes"
2170 ppc64)
2171 TARGET_BASE_ARCH=ppc
2172 TARGET_ABI_DIR=ppc
2173 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2174 target_phys_bits=64
2176 ppc64abi32)
2177 TARGET_ARCH=ppc64
2178 TARGET_BASE_ARCH=ppc
2179 TARGET_ABI_DIR=ppc
2180 echo "TARGET_ABI32=y" >> $config_mak
2181 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2182 target_phys_bits=64
2184 sh4|sh4eb)
2185 TARGET_ARCH=sh4
2186 bflt="yes"
2187 target_nptl="yes"
2188 target_phys_bits=32
2190 sparc)
2191 target_phys_bits=64
2193 sparc64)
2194 TARGET_BASE_ARCH=sparc
2195 elfload32="yes"
2196 target_phys_bits=64
2198 sparc32plus)
2199 TARGET_ARCH=sparc64
2200 TARGET_BASE_ARCH=sparc
2201 TARGET_ABI_DIR=sparc
2202 echo "TARGET_ABI32=y" >> $config_mak
2203 target_phys_bits=64
2206 echo "Unsupported target CPU"
2207 exit 1
2209 esac
2210 echo "TARGET_ARCH=$TARGET_ARCH" >> $config_mak
2211 target_arch_name="`echo $TARGET_ARCH | tr '[:lower:]' '[:upper:]'`"
2212 echo "TARGET_$target_arch_name=y" >> $config_mak
2213 echo "TARGET_ARCH2=$target_arch2" >> $config_mak
2214 # TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
2215 if [ "$TARGET_BASE_ARCH" = "" ]; then
2216 TARGET_BASE_ARCH=$TARGET_ARCH
2218 echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_mak
2219 if [ "$TARGET_ABI_DIR" = "" ]; then
2220 TARGET_ABI_DIR=$TARGET_ARCH
2222 echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_mak
2223 if [ $target_phys_bits -lt $hostlongbits ] ; then
2224 target_phys_bits=$hostlongbits
2226 case "$target_arch2" in
2227 i386|x86_64)
2228 if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
2229 echo "CONFIG_XEN=y" >> $config_mak
2231 esac
2232 case "$target_arch2" in
2233 i386|x86_64|ppcemb|ppc|ppc64)
2234 # Make sure the target and host cpus are compatible
2235 if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
2236 \( "$target_arch2" = "$cpu" -o \
2237 \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
2238 \( "$target_arch2" = "ppc64" -a "$cpu" = "ppc" \) -o \
2239 \( "$target_arch2" = "x86_64" -a "$cpu" = "i386" \) -o \
2240 \( "$target_arch2" = "i386" -a "$cpu" = "x86_64" \) \) ; then
2241 echo "CONFIG_KVM=y" >> $config_mak
2242 echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak
2244 esac
2245 echo "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_mak
2246 if test "$target_bigendian" = "yes" ; then
2247 echo "TARGET_WORDS_BIGENDIAN=y" >> $config_mak
2249 if test "$target_softmmu" = "yes" ; then
2250 echo "CONFIG_SOFTMMU=y" >> $config_mak
2251 echo "LIBS+=$libs_softmmu" >> $config_mak
2252 echo "HWLIB=../libhw$target_phys_bits/libqemuhw$target_phys_bits.a" >> $config_mak
2253 echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
2255 if test "$target_user_only" = "yes" ; then
2256 echo "CONFIG_USER_ONLY=y" >> $config_mak
2258 if test "$target_linux_user" = "yes" ; then
2259 echo "CONFIG_LINUX_USER=y" >> $config_mak
2261 if test "$target_darwin_user" = "yes" ; then
2262 echo "CONFIG_DARWIN_USER=y" >> $config_mak
2264 list=""
2265 if test ! -z "$gdb_xml_files" ; then
2266 for x in $gdb_xml_files; do
2267 list="$list $source_path/gdb-xml/$x"
2268 done
2270 echo "TARGET_XML_FILES=$list" >> $config_mak
2272 case "$target_arch2" in
2273 arm|armeb|m68k|microblaze|mips|mipsel|mipsn32|mipsn32el|mips64|mips64el|ppc|ppc64|ppc64abi32|ppcemb|sparc|sparc64|sparc32plus)
2274 echo "CONFIG_SOFTFLOAT=y" >> $config_mak
2277 echo "CONFIG_NOSOFTFLOAT=y" >> $config_mak
2279 esac
2281 if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
2282 echo "TARGET_HAS_BFLT=y" >> $config_mak
2284 if test "$target_user_only" = "yes" \
2285 -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
2286 echo "CONFIG_USE_NPTL=y" >> $config_mak
2288 # 32 bit ELF loader in addition to native 64 bit loader?
2289 if test "$target_user_only" = "yes" -a "$elfload32" = "yes"; then
2290 echo "TARGET_HAS_ELFLOAD32=y" >> $config_mak
2292 if test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
2293 echo "CONFIG_USE_GUEST_BASE=y" >> $config_mak
2295 if test "$target_bsd_user" = "yes" ; then
2296 echo "CONFIG_BSD_USER=y" >> $config_mak
2299 # generate QEMU_CFLAGS/LDFLAGS for targets
2301 cflags=""
2302 ldflags=""
2304 if test "$ARCH" = "sparc64" ; then
2305 cflags="-I\$(SRC_PATH)/tcg/sparc $cflags"
2306 else
2307 cflags="-I\$(SRC_PATH)/tcg/\$(ARCH) $cflags"
2309 cflags="-I\$(SRC_PATH)/tcg $cflags"
2310 cflags="-I\$(SRC_PATH)/fpu $cflags"
2312 for i in $ARCH $TARGET_BASE_ARCH ; do
2313 case "$i" in
2314 alpha)
2315 echo "CONFIG_ALPHA_DIS=y" >> $config_mak
2317 arm)
2318 echo "CONFIG_ARM_DIS=y" >> $config_mak
2320 cris)
2321 echo "CONFIG_CRIS_DIS=y" >> $config_mak
2323 hppa)
2324 echo "CONFIG_HPPA_DIS=y" >> $config_mak
2326 i386|x86_64)
2327 echo "CONFIG_I386_DIS=y" >> $config_mak
2329 m68k)
2330 echo "CONFIG_M68K_DIS=y" >> $config_mak
2332 microblaze)
2333 echo "CONFIG_MICROBLAZE_DIS=y" >> $config_mak
2335 mips*)
2336 echo "CONFIG_MIPS_DIS=y" >> $config_mak
2338 ppc*)
2339 echo "CONFIG_PPC_DIS=y" >> $config_mak
2341 s390)
2342 echo "CONFIG_S390_DIS=y" >> $config_mak
2344 sh4)
2345 echo "CONFIG_SH4_DIS=y" >> $config_mak
2347 sparc*)
2348 echo "CONFIG_SPARC_DIS=y" >> $config_mak
2350 esac
2351 done
2353 case "$ARCH" in
2354 alpha)
2355 # Ensure there's only a single GP
2356 cflags="-msmall-data $cflags"
2358 ia64)
2359 cflags="-mno-sdata $cflags"
2361 esac
2363 if test "$target_softmmu" = "yes" ; then
2364 case "$TARGET_BASE_ARCH" in
2365 arm)
2366 cflags="-DHAS_AUDIO $cflags"
2368 i386|mips|ppc)
2369 cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags"
2371 esac
2374 if test "$target_user_only" = "yes" -a "$static" = "no" -a \
2375 "$user_pie" = "yes" ; then
2376 cflags="-fpie $cflags"
2377 ldflags="-pie $ldflags"
2380 if test "$target_softmmu" = "yes" -a \( \
2381 "$TARGET_ARCH" = "microblaze" -o \
2382 "$TARGET_ARCH" = "cris" \) ; then
2383 echo "CONFIG_NEED_MMU=y" >> $config_mak
2386 if test "$gprof" = "yes" ; then
2387 echo "TARGET_GPROF=yes" >> $config_mak
2388 if test "$target_linux_user" = "yes" ; then
2389 cflags="-p $cflags"
2390 ldflags="-p $ldflags"
2392 if test "$target_softmmu" = "yes" ; then
2393 ldflags="-p $ldflags"
2394 echo "GPROF_CFLAGS=-p" >> $config_mak
2398 linker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/\$(ARCH).ld"
2399 if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
2400 case "$ARCH" in
2401 sparc)
2402 # -static is used to avoid g1/g3 usage by the dynamic linker
2403 ldflags="$linker_script -static $ldflags"
2405 ia64)
2406 ldflags="-Wl,-G0 $linker_script -static $ldflags"
2408 i386|x86_64|ppc|ppc64|s390|sparc64|alpha|arm|m68k|mips|mips64)
2409 ldflags="$linker_script $ldflags"
2411 esac
2413 if test "$target_softmmu" = "yes" ; then
2414 case "$ARCH" in
2415 ia64)
2416 ldflags="-Wl,-G0 $linker_script -static $ldflags"
2418 esac
2421 echo "LDFLAGS+=$ldflags" >> $config_mak
2422 echo "QEMU_CFLAGS+=$cflags" >> $config_mak
2424 echo "/* Automatically generated by configure - do not modify */" > $config_h
2425 echo "#include \"../config-host.h\"" >> $config_h
2427 /bin/sh $source_path/create_config < $config_mak >> $config_h
2429 if test -f ${config_h}~ ; then
2430 if cmp -s $config_h ${config_h}~ ; then
2431 mv ${config_h}~ $config_h
2432 else
2433 rm ${config_h}~
2437 done # for target in $targets
2439 # build tree in object directory if source path is different from current one
2440 if test "$source_path_used" = "yes" ; then
2441 DIRS="tests tests/cris slirp audio block pc-bios/optionrom"
2442 DIRS="$DIRS roms/pcbios roms/seabios roms/vgabios"
2443 FILES="Makefile tests/Makefile"
2444 FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
2445 FILES="$FILES tests/test-mmap.c"
2446 FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps pc-bios/video.x"
2447 FILES="$FILES roms/pcbios/Makefile roms/seabios/Makefile roms/vgabios/Makefile"
2448 for bios_file in $source_path/pc-bios/*.bin $source_path/pc-bios/*.dtb $source_path/pc-bios/openbios-*; do
2449 FILES="$FILES pc-bios/`basename $bios_file`"
2450 done
2451 for dir in $DIRS ; do
2452 mkdir -p $dir
2453 done
2454 # remove the link and recreate it, as not all "ln -sf" overwrite the link
2455 for f in $FILES ; do
2456 rm -f $f
2457 ln -s $source_path/$f $f
2458 done
2461 # temporary config to build submodules
2462 for rom in seabios vgabios pcbios; do
2463 config_mak=roms/$rom/config.mak
2464 echo "# Automatically generated by configure - do not modify" >> $config_mak
2465 echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
2466 echo "CC=$cc" >> $config_mak
2467 echo "BCC=bcc" >> $config_mak
2468 echo "CPP=${cross_prefix}cpp" >> $config_mak
2469 echo "OBJCOPY=objcopy" >> $config_mak
2470 echo "IASL=iasl" >> $config_mak
2471 echo "HOST_CC=$host_cc" >> $config_mak
2472 echo "LD=$ld" >> $config_mak
2473 done
2475 for hwlib in 32 64; do
2476 d=libhw$hwlib
2477 mkdir -p $d
2478 rm -f $d/Makefile
2479 ln -s $source_path/Makefile.hw $d/Makefile
2480 echo "HWLIB=libqemuhw$hwlib.a" > $d/config.mak
2481 echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" >> $d/config.mak
2482 done