3 # qemu configure script (c) 2003 Fabrice Bellard
5 # set temporary file name
6 if test ! -z "$TMPDIR" ; then
8 elif test ! -z "$TEMPDIR" ; then
14 TMPC="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.c"
15 TMPO="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.o"
16 TMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}"
17 TMPS="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.S"
18 TMPI="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.i"
19 TMPSDLLOG="${TMPDIR1}/qemu-conf-sdl-$$-${RANDOM}.log"
21 trap "rm -f $TMPC $TMPO $TMPE $TMPS $TMPI $TMPSDLLOG; exit" 0 2 3 15
26 interp_prefix="/usr/gnemul/qemu-%M"
31 audio_card_list="ac97 es1370 sb16"
32 audio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus"
40 # parse CC options first
42 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
44 --cross-prefix=*) cross_prefix="$optarg"
48 --cpu=*) cpu="$optarg"
50 --extra-cflags=*) CFLAGS="$optarg $CFLAGS"
52 --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
58 # Using uname is really, really broken. Once we have the right set of checks
59 # we can eliminate it's usage altogether
61 cc="${cross_prefix}${cc}"
62 ar="${cross_prefix}${ar}"
63 objcopy="${cross_prefix}${objcopy}"
64 ld="${cross_prefix}${ld}"
66 # check that the C compiler works.
71 if $cc $CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null ; then
74 echo "ERROR: \"$cc\" either does not exist or does not work"
83 int main(void) { return 0; }
85 $cc $CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null
88 if test ! -z "$cpu" ; then
89 # command line argument
91 elif check_define __i386__ ; then
93 elif check_define __x86_64__ ; then
95 elif check_define __sparc__ ; then
96 # We can't check for 64 bit (when gcc is biarch) or V8PLUSA
97 # They must be specified using --sparc_cpu
98 if check_define __arch64__ ; then
103 elif check_define _ARCH_PPC ; then
104 if check_define _ARCH_PPC64 ; then
115 i386|i486|i586|i686|i86pc|BePC)
217 if check_define __linux__ ; then
219 elif check_define _WIN32 ; then
221 elif check_define __OpenBSD__ ; then
223 elif check_define __sun__ ; then
231 CFLAGS="-mno-cygwin $CFLAGS"
232 if [ "$cpu" = "i386" ] ; then
235 audio_possible_drivers="sdl"
239 if [ "$cpu" = "i386" ] ; then
242 audio_possible_drivers="dsound sdl fmod"
246 audio_possible_drivers="oss sdl esd pa"
247 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
254 audio_possible_drivers="oss sdl esd pa"
255 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
262 audio_possible_drivers="oss sdl esd pa"
263 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
271 audio_possible_drivers="oss sdl esd"
277 audio_possible_drivers="oss sdl esd"
283 # on Leopard most of the system is 32-bit, so we have to ask the kernel it if we can run 64-bit userspace code
284 if [ "$cpu" = "i386" ] ; then
285 is_x86_64=`sysctl -n hw.optional.x86_64`
286 [ "$is_x86_64" = "1" ] && cpu=x86_64
288 if [ "$cpu" = "x86_64" ] ; then
289 CFLAGS="-arch x86_64 $CFLAGS"
290 LDFLAGS="-arch x86_64 $LDFLAGS"
292 CFLAGS="-mdynamic-no-pic $CFLAGS"
296 audio_drv_list="coreaudio"
297 audio_possible_drivers="coreaudio sdl fmod"
298 LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
304 needs_libsunmath="no"
305 solarisrev=`uname -r | cut -f2 -d.`
306 # have to select again, because `uname -m` returns i86pc
307 # even on an x86_64 box.
308 solariscpu=`isainfo -k`
309 if test "${solariscpu}" = "amd64" ; then
312 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
313 if test "$solarisrev" -le 9 ; then
314 if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
315 needs_libsunmath="yes"
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."
324 if test "$solarisrev" -ge 9 ; then
328 if test -f /usr/include/sys/soundcard.h ; then
331 audio_possible_drivers="oss sdl"
332 CFLAGS="-std=gnu99 $CFLAGS"
340 audio_possible_drivers="oss alsa sdl esd pa"
345 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
347 audio_possible_drivers="$audio_possible_drivers fmod"
352 if [ "$bsd" = "yes" ] ; then
353 if [ "$darwin" != "yes" ] ; then
361 source_path=`dirname "$0"`
362 source_path_used="no"
364 if [ -z "$source_path" ]; then
367 source_path=`cd "$source_path"; pwd`
369 [ -f "$workdir/vl.c" ] || source_path_used="yes"
374 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
376 --help|-h) show_help=yes
378 --prefix=*) prefix="$optarg"
380 --interp-prefix=*) interp_prefix="$optarg"
382 --source-path=*) source_path="$optarg"
383 source_path_used="yes"
389 --host-cc=*) host_cc="$optarg"
391 --make=*) make="$optarg"
393 --install=*) install="$optarg"
401 --target-list=*) target_list="$optarg"
403 --enable-gprof) gprof="yes"
405 --static) static="yes"
407 --disable-sdl) sdl="no"
409 --fmod-lib=*) fmod_lib="$optarg"
411 --fmod-inc=*) fmod_inc="$optarg"
413 --oss-lib=*) oss_lib="$optarg"
415 --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
417 --audio-drv-list=*) audio_drv_list="$optarg"
419 --enable-debug-tcg) debug_tcg="yes"
421 --disable-debug-tcg) debug_tcg="no"
424 # Enable debugging options that aren't excessively noisy
429 --enable-sparse) sparse="yes"
431 --disable-sparse) sparse="no"
433 --disable-strip) strip_opt="no"
435 --disable-vnc-tls) vnc_tls="no"
437 --disable-vnc-sasl) vnc_sasl="no"
439 --disable-slirp) slirp="no"
441 --disable-vde) vde="no"
443 --disable-kqemu) kqemu="no"
445 --disable-xen) xen="no"
447 --disable-brlapi) brlapi="no"
449 --disable-bluez) bluez="no"
451 --disable-kvm) kvm="no"
453 --enable-profiler) profiler="yes"
458 audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
460 --disable-system) softmmu="no"
462 --enable-system) softmmu="yes"
464 --disable-linux-user) linux_user="no"
466 --enable-linux-user) linux_user="yes"
468 --disable-darwin-user) darwin_user="no"
470 --enable-darwin-user) darwin_user="yes"
472 --disable-bsd-user) bsd_user="no"
474 --enable-bsd-user) bsd_user="yes"
476 --enable-guest-base) guest_base="yes"
478 --disable-guest-base) guest_base="no"
480 --enable-uname-release=*) uname_release="$optarg"
486 CFLAGS="-m32 -mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__ $CFLAGS"
487 LDFLAGS="-m32 $LDFLAGS"
491 CFLAGS="-m32 -mcpu=ultrasparc -D__sparc_${sparc_cpu}__ $CFLAGS"
492 LDFLAGS="-m32 $LDFLAGS"
496 CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_${sparc_cpu}__ $CFLAGS"
497 LDFLAGS="-m64 $LDFLAGS"
501 echo "undefined SPARC architecture. Exiting";
506 --enable-werror) werror="yes"
508 --disable-werror) werror="no"
510 --disable-curses) curses="no"
512 --disable-curl) curl="no"
514 --disable-nptl) nptl="no"
516 --enable-mixemu) mixemu="yes"
518 --disable-pthread) pthread="no"
520 --disable-aio) aio="no"
522 --enable-io-thread) io_thread="yes"
524 --disable-blobs) blobs="no"
526 --kerneldir=*) kerneldir="$optarg"
528 --with-pkgversion=*) pkgversion=" ($optarg)"
530 --disable-docs) build_docs="no"
532 *) echo "ERROR: unknown option $opt"; show_help="yes"
538 # If cpu ~= sparc and sparc_cpu hasn't been defined, plug in the right
539 # CFLAGS/LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
543 sparc) if test -z "$sparc_cpu" ; then
544 CFLAGS="-m32 -mcpu=ultrasparc -D__sparc_v8plus__ $CFLAGS"
545 LDFLAGS="-m32 $LDFLAGS"
547 CFLAGS="-ffixed-g2 -ffixed-g3 $CFLAGS"
548 if test "$solaris" = "no" ; then
549 CFLAGS="-ffixed-g1 -ffixed-g6 $CFLAGS"
552 sparc64) if test -z "$sparc_cpu" ; then
553 CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__ $CFLAGS"
554 LDFLAGS="-m64 $LDFLAGS"
556 if test "$solaris" = "no" ; then
557 CFLAGS="-ffixed-g5 -ffixed-g6 -ffixed-g7 $CFLAGS"
559 CFLAGS="-ffixed-g1 -ffixed-g5 -ffixed-g6 -ffixed-g7 $CFLAGS"
563 CFLAGS="-march=z900 $CFLAGS"
566 CFLAGS="-m32 $CFLAGS"
567 LDFLAGS="-m32 $LDFLAGS"
568 host_guest_base="yes"
571 CFLAGS="-m64 $CFLAGS"
572 LDFLAGS="-m64 $LDFLAGS"
573 host_guest_base="yes"
576 host_guest_base="yes"
579 host_guest_base="yes"
583 [ -z "$guest_base" ] && guest_base="$host_guest_base"
585 if test x"$show_help" = x"yes" ; then
588 Usage: configure [options]
589 Options: [defaults in brackets after descriptions]
592 echo "Standard options:"
593 echo " --help print this message"
594 echo " --prefix=PREFIX install in PREFIX [$prefix]"
595 echo " --interp-prefix=PREFIX where to find shared libraries, etc."
596 echo " use %M for cpu name [$interp_prefix]"
597 echo " --target-list=LIST set target list [$target_list]"
599 echo "kqemu kernel acceleration support:"
600 echo " --disable-kqemu disable kqemu support"
602 echo "Advanced options (experts only):"
603 echo " --source-path=PATH path of source code [$source_path]"
604 echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
605 echo " --cc=CC use C compiler CC [$cc]"
606 echo " --host-cc=CC use C compiler CC [$host_cc] for dyngen etc."
607 echo " --extra-cflags=CFLAGS append extra C compiler flags CFLAGS"
608 echo " --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS"
609 echo " --make=MAKE use specified make [$make]"
610 echo " --install=INSTALL use specified install [$install]"
611 echo " --static enable static build [$static]"
612 echo " --enable-debug-tcg enable TCG debugging"
613 echo " --disable-debug-tcg disable TCG debugging (default)"
614 echo " --enable-debug enable common debug build options"
615 echo " --enable-sparse enable sparse checker"
616 echo " --disable-sparse disable sparse checker (default)"
617 echo " --disable-strip disable stripping binaries"
618 echo " --disable-werror disable compilation abort on warning"
619 echo " --disable-sdl disable SDL"
620 echo " --enable-cocoa enable COCOA (Mac OS X only)"
621 echo " --audio-drv-list=LIST set audio drivers list:"
622 echo " Available drivers: $audio_possible_drivers"
623 echo " --audio-card-list=LIST set list of emulated audio cards [$audio_card_list]"
624 echo " Available cards: $audio_possible_cards"
625 echo " --enable-mixemu enable mixer emulation"
626 echo " --disable-xen disable xen backend driver support"
627 echo " --disable-brlapi disable BrlAPI"
628 echo " --disable-vnc-tls disable TLS encryption for VNC server"
629 echo " --disable-vnc-sasl disable SASL encryption for VNC server"
630 echo " --disable-curses disable curses output"
631 echo " --disable-curl disable curl connectivity"
632 echo " --disable-bluez disable bluez stack connectivity"
633 echo " --disable-kvm disable KVM acceleration support"
634 echo " --disable-nptl disable usermode NPTL support"
635 echo " --enable-system enable all system emulation targets"
636 echo " --disable-system disable all system emulation targets"
637 echo " --enable-linux-user enable all linux usermode emulation targets"
638 echo " --disable-linux-user disable all linux usermode emulation targets"
639 echo " --enable-darwin-user enable all darwin usermode emulation targets"
640 echo " --disable-darwin-user disable all darwin usermode emulation targets"
641 echo " --enable-bsd-user enable all BSD usermode emulation targets"
642 echo " --disable-bsd-user disable all BSD usermode emulation targets"
643 echo " --enable-guest-base enable GUEST_BASE support for usermode"
644 echo " emulation targets"
645 echo " --disable-guest-base disable GUEST_BASE support"
646 echo " --fmod-lib path to FMOD library"
647 echo " --fmod-inc path to FMOD includes"
648 echo " --oss-lib path to OSS library"
649 echo " --enable-uname-release=R Return R for uname -r in usermode emulation"
650 echo " --sparc_cpu=V Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
651 echo " --disable-vde disable support for vde network"
652 echo " --disable-pthread disable pthread support"
653 echo " --disable-aio disable AIO support"
654 echo " --enable-io-thread enable IO thread"
655 echo " --disable-blobs disable installing provided firmware blobs"
656 echo " --kerneldir=PATH look for kernel includes in PATH"
658 echo "NOTE: The object files are built at the place where configure is launched"
662 if test "$mingw32" = "yes" ; then
667 CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $CFLAGS"
670 if test ! -x "$(which cgcc 2>/dev/null)"; then
675 # Solaris specific configure tool chain decisions
677 if test "$solaris" = "yes" ; then
678 solinst=`which $install 2> /dev/null | /usr/bin/grep -v "no $install in"`
679 if test -z "$solinst" ; then
680 echo "Solaris install program not found. Use --install=/usr/ucb/install or"
681 echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
682 echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
685 if test "$solinst" = "/usr/sbin/install" ; then
686 echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
687 echo "try ginstall from the GNU fileutils available from www.blastwave.org"
688 echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
691 sol_ar=`which ar 2> /dev/null | /usr/bin/grep -v "no ar in"`
692 if test -z "$sol_ar" ; then
693 echo "Error: No path includes ar"
694 if test -f /usr/ccs/bin/ar ; then
695 echo "Add /usr/ccs/bin to your path and rerun configure"
702 if test -z "$target_list" ; then
703 # these targets are portable
704 if [ "$softmmu" = "yes" ] ; then
725 # the following are Linux specific
726 if [ "$linux_user" = "yes" ] ; then
727 target_list="${target_list}\
735 microblaze-linux-user \
740 ppc64abi32-linux-user \
745 sparc32plus-linux-user \
748 # the following are Darwin specific
749 if [ "$darwin_user" = "yes" ] ; then
750 target_list="$target_list i386-darwin-user ppc-darwin-user "
752 # the following are BSD specific
753 if [ "$bsd_user" = "yes" ] ; then
754 target_list="${target_list}\
762 target_list=`echo "$target_list" | sed -e 's/,/ /g'`
764 if test -z "$target_list" ; then
765 echo "No targets enabled"
769 if test -z "$cross_prefix" ; then
772 # big/little endian test
774 #include <inttypes.h>
775 int main(int argc, char ** argv){
776 volatile uint32_t i=0x01234567;
777 return (*((uint8_t*)(&i))) == 0x67;
781 if $cc $CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
782 $TMPE && bigendian="yes"
784 echo big/little test failed
789 # if cross compiling, cannot launch a program, so make a static guess
790 if test "$cpu" = "armv4b" \
794 -o "$cpu" = "mips64" \
796 -o "$cpu" = "ppc64" \
798 -o "$cpu" = "sparc" \
799 -o "$cpu" = "sparc64"; then
805 # host long bits test
807 if test "$cpu" = "x86_64" \
808 -o "$cpu" = "alpha" \
810 -o "$cpu" = "sparc64" \
811 -o "$cpu" = "ppc64"; then
815 # Check host NPTL support
818 #include <linux/futex.h>
821 #if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
827 if $cc $CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null ; then
833 ##########################################
838 int main(void) { zlibVersion(); return 0; }
840 if $cc $CFLAGS -o $TMPE $TMPC -lz > /dev/null 2> /dev/null ; then
844 echo "Error: zlib check failed"
845 echo "Make sure to have the zlib libs and headers installed."
850 ##########################################
853 if test "$xen" = "yes" ; then
854 xen_libs="-lxenstore -lxenctrl -lxenguest"
858 int main(void) { xs_daemon_open(); xc_interface_open(); return 0; }
860 if $cc $CFLAGS -c -o $TMPO $TMPC $LDFLAGS $xen_libs 2> /dev/null > /dev/null ; then
867 ##########################################
872 if test "$sdl" = "yes" ; then
876 #undef main /* We don't want SDL to override our main() */
877 int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
879 sdl_cflags=`sdl-config --cflags 2> /dev/null`
880 sdl_libs=`sdl-config --libs 2> /dev/null`
881 if $cc $CFLAGS -o $TMPE $sdl_cflags $TMPC $sdl_libs > $TMPSDLLOG 2>&1 ; then
882 _sdlversion=`sdl-config --version | sed 's/[^0-9]//g'`
883 if test "$_sdlversion" -lt 121 ; then
886 if test "$cocoa" = "no" ; then
891 # static link with sdl ?
892 if test "$sdl" = "yes" -a "$static" = "yes" ; then
893 sdl_libs=`sdl-config --static-libs 2>/dev/null`
894 if test `sdl-config --static-libs 2>/dev/null | grep \\\-laa > /dev/null` ; then
895 sdl_libs="$sdl_libs `aalib-config --static-libs >2 /dev/null`"
896 sdl_cflags="$sd_cflags `aalib-config --cflags >2 /dev/null`"
898 if $cc -o $TMPE $CFLAGS $sdl_cflags $TMPC $sdl_libs > /dev/null 2> /dev/null; then
904 fi # sdl compile test
907 if test "$sdl" = "yes" ; then
910 #if defined(SDL_VIDEO_DRIVER_X11)
911 #include <X11/XKBlib.h>
913 #error No x11 support
915 int main(void) { return 0; }
917 if $cc $CFLAGS -o $TMPE $sdl_cflags $TMPC $sdl_libs > /dev/null 2>&1 ; then
918 sdl_libs="$sdl_libs -lX11"
922 ##########################################
924 if test "$vnc_tls" = "yes" ; then
926 #include <gnutls/gnutls.h>
927 int main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
929 vnc_tls_cflags=`pkg-config --cflags gnutls 2> /dev/null`
930 vnc_tls_libs=`pkg-config --libs gnutls 2> /dev/null`
931 if $cc $CFLAGS -o $TMPE $vnc_tls_cflags $TMPC \
932 $vnc_tls_libs > /dev/null 2> /dev/null ; then
939 ##########################################
941 if test "$vnc_sasl" = "yes" ; then
943 #include <sasl/sasl.h>
945 int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
947 # Assuming Cyrus-SASL installed in /usr prefix
949 vnc_sasl_libs="-lsasl2"
950 if $cc $CFLAGS -o $TMPE $vnc_sasl_cflags $TMPC \
951 $vnc_sasl_libs 2> /dev/null > /dev/null ; then
958 ##########################################
959 # fnmatch() probe, used for ACL routines
965 fnmatch("foo", "foo", 0);
969 if $cc $CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
973 ##########################################
974 # vde libraries probe
975 if test "$vde" = "yes" ; then
979 #include <libvdeplug.h>
982 struct vde_open_args a = {0, 0, 0};
983 vde_open("", "", &a);
987 if $cc $CFLAGS -o $TMPE $TMPC $vde_libs > /dev/null 2> /dev/null ; then
992 ##########################################
993 # Sound support libraries probe
1004 int main(void) { $exp }
1006 if $cc $CFLAGS $cfl -o $TMPE $TMPC $lib > /dev/null 2> /dev/null ; then
1010 echo "Error: $drv check failed"
1011 echo "Make sure to have the $drv libs and headers installed."
1017 audio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
1018 for drv in $audio_drv_list; do
1021 audio_drv_probe $drv alsa/asoundlib.h -lasound \
1022 "snd_pcm_t **handle; return snd_pcm_close(*handle);"
1026 if test -z $fmod_lib || test -z $fmod_inc; then
1028 echo "Error: You must specify path to FMOD library and headers"
1029 echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
1033 audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
1037 audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
1041 audio_drv_probe $drv pulse/simple.h -lpulse-simple \
1042 "pa_simple *s = NULL; pa_simple_free(s); return 0;"
1045 oss|sdl|core|wav|dsound)
1046 # XXX: Probes for CoreAudio, DirectSound, SDL(?)
1050 echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
1052 echo "Error: Unknown driver '$drv' selected"
1053 echo "Possible drivers are: $audio_possible_drivers"
1061 ##########################################
1064 if test "$brlapi" = "yes" ; then
1066 brlapi_libs="-lbrlapi"
1069 int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
1071 if $cc $CFLAGS -o $TMPE $TMPC $brlapi_libs > /dev/null 2> /dev/null ; then
1076 ##########################################
1079 if test "$curses" = "yes" ; then
1083 #define resize_term resizeterm
1085 int main(void) { resize_term(0, 0); return curses_version(); }
1087 if $cc $CFLAGS -o $TMPE $TMPC -lncurses > /dev/null 2> /dev/null ; then
1088 curses_libs="-lncurses"
1089 elif $cc $CFLAGS -o $TMPE $TMPC -lcurses > /dev/null 2> /dev/null ; then
1090 curses_libs="-lcurses"
1096 ##########################################
1099 if test "$curl" = "yes" ; then
1102 #include <curl/curl.h>
1103 int main(void) { return curl_easy_init(); }
1105 curl_libs=`curl-config --libs 2>/dev/null`
1106 if $cc $CFLAGS $curl_libs -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
1111 ##########################################
1112 # bluez support probe
1113 if test "$bluez" = "yes" ; then
1114 `pkg-config bluez 2> /dev/null` || bluez="no"
1116 if test "$bluez" = "yes" ; then
1118 #include <bluetooth/bluetooth.h>
1119 int main(void) { return bt_error(0); }
1121 bluez_cflags=`pkg-config --cflags bluez 2> /dev/null`
1122 bluez_libs=`pkg-config --libs bluez 2> /dev/null`
1123 if $cc $CFLAGS -o $TMPE $bluez_cflags $TMPC \
1124 $bluez_libs > /dev/null 2> /dev/null ; then
1131 ##########################################
1133 if test "$kvm" = "yes" ; then
1135 #include <linux/kvm.h>
1136 #if !defined(KVM_API_VERSION) || KVM_API_VERSION < 12 || KVM_API_VERSION > 12
1137 #error Invalid KVM version
1139 #if !defined(KVM_CAP_USER_MEMORY)
1140 #error Missing KVM capability KVM_CAP_USER_MEMORY
1142 #if !defined(KVM_CAP_SET_TSS_ADDR)
1143 #error Missing KVM capability KVM_CAP_SET_TSS_ADDR
1145 #if !defined(KVM_CAP_DESTROY_MEMORY_REGION_WORKS)
1146 #error Missing KVM capability KVM_CAP_DESTROY_MEMORY_REGION_WORKS
1148 int main(void) { return 0; }
1150 if test "$kerneldir" != "" ; then
1151 kvm_cflags=-I"$kerneldir"/include
1152 if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) \
1153 -a -d "$kerneldir/arch/x86/include" ; then
1154 kvm_cflags="$kvm_cflags -I$kerneldir/arch/x86/include"
1155 elif test "$cpu" = "ppc" -a -d "$kerneldir/arch/powerpc/include" ; then
1156 kvm_cflags="$kvm_cflags -I$kerneldir/arch/powerpc/include"
1157 elif test -d "$kerneldir/arch/$cpu/include" ; then
1158 kvm_cflags="$kvm_cflags -I$kerneldir/arch/$cpu/include"
1163 if $cc $CFLAGS -o $TMPE $kvm_cflags $TMPC \
1164 > /dev/null 2>/dev/null ; then
1168 if [ -x "`which awk 2>/dev/null`" ] && \
1169 [ -x "`which grep 2>/dev/null`" ]; then
1170 kvmerr=`LANG=C $cc $CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&1 \
1172 | awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'`
1173 if test "$kvmerr" != "" ; then
1174 kvm="no - (${kvmerr})\n\
1175 NOTE: To enable KVM support, update your kernel to 2.6.29+ or install \
1176 recent kvm-kmod from http://sourceforge.net/projects/kvm."
1182 ##########################################
1184 PTHREADLIBS_LIST="-lpthread -lpthreadGC2"
1187 if test "$pthread" = yes; then
1190 #include <pthread.h>
1191 int main(void) { pthread_create(0,0,0,0); return 0; }
1193 for pthread_lib in $PTHREADLIBS_LIST; do
1194 if $cc $CFLAGS -o $TMPE $TMPC $pthread_lib 2> /dev/null > /dev/null ; then
1196 PTHREADLIBS="$pthread_lib"
1202 if test "$pthread" = no; then
1207 ##########################################
1210 #include <sys/types.h>
1211 #include <sys/uio.h>
1213 int main(void) { struct iovec iov; return 0; }
1216 if $cc $CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
1220 ##########################################
1223 #include <sys/types.h>
1224 #include <sys/uio.h>
1226 int main(void) { preadv; }
1229 if $cc $CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
1233 ##########################################
1235 if test "$fdt" = "yes" ; then
1239 int main(void) { return 0; }
1241 if $cc $CFLAGS -o $TMPE $TMPC $fdt_libs 2> /dev/null > /dev/null ; then
1247 # Check for xxxat() functions when we are building linux-user
1248 # emulator. This is done because older glibc versions don't
1249 # have syscall stubs for these implemented.
1253 #define _ATFILE_SOURCE
1254 #include <sys/types.h>
1261 /* try to unlink nonexisting file */
1262 return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
1265 if $cc $CFLAGS -o $TMPE $TMPC 2> /dev/null > /dev/null ; then
1269 # Check for inotify functions when we are building linux-user
1270 # emulator. This is done because older glibc versions don't
1271 # have syscall stubs for these implemented. In that case we
1272 # don't provide them even if kernel supports them.
1276 #include <sys/inotify.h>
1281 /* try to start inotify */
1282 return inotify_init();
1285 if $cc $CFLAGS -o $TMPE $TMPC 2> /dev/null > /dev/null ; then
1289 # check if utimensat and futimens are supported
1292 #define _ATFILE_SOURCE
1299 utimensat(AT_FDCWD, "foo", NULL, 0);
1304 if $cc $CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
1308 # check if pipe2 is there
1318 pipe2(pipefd, O_CLOEXEC);
1322 if $cc $CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
1326 # check if tee/splice is there. vmsplice was added same time.
1337 len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
1338 splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
1342 if $cc $CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
1346 # Check if tools are available to build documentation.
1347 if test "$build_docs" = "yes" -a \( ! -x "`which texi2html 2>/dev/null`" -o ! -x "`which pod2man 2>/dev/null`" \) ; then
1351 # Search for bsawp_32 function
1354 #include <byteswap.h>
1355 int main(void) { return bswap_32(0); }
1357 if $cc $CFLAGS -o $TMPE $TMPC >/dev/null 2> /dev/null ; then
1361 # Search for bsawp_32 function
1364 #include <sys/endian.h>
1365 #include <sys/types.h>
1366 #include <machine/bswap.h>
1367 int main(void) { return bswap32(0); }
1369 if $cc $CFLAGS -o $TMPE $TMPC >/dev/null 2> /dev/null ; then
1373 ##########################################
1378 int main(void) { clockid_t id; return clock_gettime(id, NULL); }
1381 if $cc $CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
1383 elif $cc $CFLAGS -o $TMPE $TMPC -lrt > /dev/null 2> /dev/null ; then
1387 # Determine what linker flags to use to force archive inclusion
1388 check_linker_flags()
1394 $cc $CFLAGS -o $TMPE $TMPC -Wl,$1 ${w2} >/dev/null 2>/dev/null
1400 if check_linker_flags --whole-archive --no-whole-archive ; then
1402 arlibs_begin="-Wl,--whole-archive"
1403 arlibs_end="-Wl,--no-whole-archive"
1404 elif check_linker_flags -z,allextract -z,defaultextract ; then
1406 arlibs_begin"=-Wl,-z,allextract"
1407 arlibs_end="-Wl,-z,defaultextract"
1408 elif check_linker_flags -all_load ; then
1410 arlibs_begin="-all_load"
1413 echo "Error: your linker does not support --whole-archive or -z."
1419 # After here, no more $cc or $ld runs
1421 # default flags for all hosts
1422 CFLAGS="-g -fno-strict-aliasing $CFLAGS"
1423 if test "$debug" = "no" ; then
1424 CFLAGS="-O2 $CFLAGS"
1426 CFLAGS="-Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls $CFLAGS"
1427 LDFLAGS="-g $LDFLAGS"
1429 # Consult white-list to determine whether to enable werror
1430 # by default. Only enable by default for git builds
1431 if test -z "$werror" ; then
1432 z_version=`cut -f3 -d. $source_path/VERSION`
1433 if test "$z_version" = "50" -a \
1434 "$linux" = "yes" ; then
1441 if test "$werror" = "yes" ; then
1442 CFLAGS="-Werror $CFLAGS"
1445 if test "$solaris" = "no" ; then
1446 if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
1447 LDFLAGS="-Wl,--warn-common $LDFLAGS"
1451 if test "$mingw32" = "yes" ; then
1452 if test -z "$prefix" ; then
1453 prefix="c:/Program Files/Qemu"
1460 if test -z "$prefix" ; then
1463 mansuffix="/share/man"
1464 datasuffix="/share/qemu"
1465 docsuffix="/share/doc/qemu"
1469 echo "Install prefix $prefix"
1470 echo "BIOS directory $prefix$datasuffix"
1471 echo "binary directory $prefix$binsuffix"
1472 if test "$mingw32" = "no" ; then
1473 echo "Manual directory $prefix$mansuffix"
1474 echo "ELF interp prefix $interp_prefix"
1476 echo "Source path $source_path"
1477 echo "C compiler $cc"
1478 echo "Host C compiler $host_cc"
1479 echo "CFLAGS $CFLAGS"
1480 echo "LDFLAGS $LDFLAGS"
1482 echo "install $install"
1483 echo "host CPU $cpu"
1484 echo "host big endian $bigendian"
1485 echo "target list $target_list"
1486 echo "tcg debug enabled $debug_tcg"
1487 echo "gprof enabled $gprof"
1488 echo "sparse enabled $sparse"
1489 echo "strip binaries $strip_opt"
1490 echo "profiler $profiler"
1491 echo "static build $static"
1492 echo "-Werror enabled $werror"
1493 if test "$darwin" = "yes" ; then
1494 echo "Cocoa support $cocoa"
1496 echo "SDL support $sdl"
1497 echo "curses support $curses"
1498 echo "curl support $curl"
1499 echo "mingw32 support $mingw32"
1500 echo "Audio drivers $audio_drv_list"
1501 echo "Extra audio cards $audio_card_list"
1502 echo "Mixer emulation $mixemu"
1503 echo "VNC TLS support $vnc_tls"
1504 if test "$vnc_tls" = "yes" ; then
1505 echo " TLS CFLAGS $vnc_tls_cflags"
1506 echo " TLS LIBS $vnc_tls_libs"
1508 echo "VNC SASL support $vnc_sasl"
1509 if test "$vnc_sasl" = "yes" ; then
1510 echo " SASL CFLAGS $vnc_sasl_cflags"
1511 echo " SASL LIBS $vnc_sasl_libs"
1513 if test -n "$sparc_cpu"; then
1514 echo "Target Sparc Arch $sparc_cpu"
1516 echo "kqemu support $kqemu"
1517 echo "xen support $xen"
1518 echo "brlapi support $brlapi"
1519 echo "Documentation $build_docs"
1520 [ ! -z "$uname_release" ] && \
1521 echo "uname -r $uname_release"
1522 echo "NPTL support $nptl"
1523 echo "GUEST_BASE $guest_base"
1524 echo "vde support $vde"
1525 echo "AIO support $aio"
1526 echo "IO thread $io_thread"
1527 echo "Install blobs $blobs"
1528 echo -e "KVM support $kvm"
1529 echo "fdt support $fdt"
1530 echo "preadv support $preadv"
1532 if test $sdl_too_old = "yes"; then
1533 echo "-> Your SDL version is too old - please upgrade to have SDL support"
1536 config_host_mak="config-host.mak"
1537 config_host_h="config-host.h"
1538 config_host_ld="config-host.ld"
1540 #echo "Creating $config_host_mak and $config_host_h"
1542 test -f $config_host_h && mv $config_host_h ${config_host_h}~
1544 echo "# Automatically generated by configure - do not modify" > $config_host_mak
1545 printf "# Configured with:" >> $config_host_mak
1546 printf " '%s'" "$0" "$@" >> $config_host_mak
1547 echo >> $config_host_mak
1549 echo "CONFIG_QEMU_SHAREDIR=\"$prefix$datasuffix\"" >> $config_host_mak
1552 i386|x86_64|alpha|cris|hppa|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|s390|sparc|sparc64)
1559 echo "Unsupported CPU = $cpu"
1563 echo "ARCH=$ARCH" >> $config_host_mak
1564 if test "$debug_tcg" = "yes" ; then
1565 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
1567 if test "$debug" = "yes" ; then
1568 echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
1570 if test "$strip_opt" = "yes" ; then
1571 echo "STRIP_OPT=-s" >> $config_host_mak
1573 if test "$bigendian" = "yes" ; then
1574 echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
1576 echo "HOST_LONG_BITS=$hostlongbits" >> $config_host_mak
1577 if test "$mingw32" = "yes" ; then
1578 echo "CONFIG_WIN32=y" >> $config_host_mak
1580 echo "CONFIG_POSIX=y" >> $config_host_mak
1583 if test "$darwin" = "yes" ; then
1584 echo "CONFIG_DARWIN=y" >> $config_host_mak
1587 if test "$aix" = "yes" ; then
1588 echo "CONFIG_AIX=y" >> $config_host_mak
1591 if test "$solaris" = "yes" ; then
1592 echo "CONFIG_SOLARIS=y" >> $config_host_mak
1593 echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
1594 if test "$needs_libsunmath" = "yes" ; then
1595 echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
1598 if test -n "$sparc_cpu"; then
1599 echo "CONFIG__sparc_${sparc_cpu}__=y" >> $config_host_mak
1601 if test "$gprof" = "yes" ; then
1602 echo "TARGET_GPROF=yes" >> $config_host_mak
1604 if test "$static" = "yes" ; then
1605 echo "CONFIG_STATIC=y" >> $config_host_mak
1606 LDFLAGS="-static $LDFLAGS"
1608 if test $profiler = "yes" ; then
1609 echo "CONFIG_PROFILER=y" >> $config_host_mak
1611 if test "$slirp" = "yes" ; then
1612 echo "CONFIG_SLIRP=y" >> $config_host_mak
1614 if test "$vde" = "yes" ; then
1615 echo "CONFIG_VDE=y" >> $config_host_mak
1616 echo "VDE_LIBS=$vde_libs" >> $config_host_mak
1618 for card in $audio_card_list; do
1619 def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
1620 echo "$def=y" >> $config_host_mak
1622 echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
1623 for drv in $audio_drv_list; do
1624 def=CONFIG_`echo $drv | tr '[:lower:]' '[:upper:]'`
1625 echo "$def=y" >> $config_host_mak
1626 if test "$drv" = "fmod"; then
1627 echo "FMOD_LIBS=$fmod_lib" >> $config_host_mak
1628 echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
1629 elif test "$drv" = "oss"; then
1630 echo "OSS_LIBS=$oss_lib" >> $config_host_mak
1633 if test "$mixemu" = "yes" ; then
1634 echo "CONFIG_MIXEMU=y" >> $config_host_mak
1636 if test "$vnc_tls" = "yes" ; then
1637 echo "CONFIG_VNC_TLS=y" >> $config_host_mak
1638 echo "VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_host_mak
1639 echo "VNC_TLS_LIBS=$vnc_tls_libs" >> $config_host_mak
1641 if test "$vnc_sasl" = "yes" ; then
1642 echo "CONFIG_VNC_SASL=y" >> $config_host_mak
1643 echo "VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak
1644 echo "VNC_SASL_LIBS=$vnc_sasl_libs" >> $config_host_mak
1646 if test "$fnmatch" = "yes" ; then
1647 echo "CONFIG_FNMATCH=y" >> $config_host_mak
1649 qemu_version=`head $source_path/VERSION`
1650 echo "VERSION=$qemu_version" >>$config_host_mak
1651 echo "PKGVERSION=$pkgversion" >>$config_host_mak
1652 echo "SRC_PATH=$source_path" >> $config_host_mak
1653 if [ "$source_path_used" = "yes" ]; then
1654 echo "VPATH=$source_path" >> $config_host_mak
1656 echo "TARGET_DIRS=$target_list" >> $config_host_mak
1657 if [ "$build_docs" = "yes" ] ; then
1658 echo "BUILD_DOCS=yes" >> $config_host_mak
1660 if test "$sdl" = "yes" ; then
1661 echo "CONFIG_SDL=y" >> $config_host_mak
1662 echo "SDL_LIBS=$sdl_libs" >> $config_host_mak
1663 echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
1665 if test "$cocoa" = "yes" ; then
1666 echo "CONFIG_COCOA=y" >> $config_host_mak
1668 if test "$curses" = "yes" ; then
1669 echo "CONFIG_CURSES=y" >> $config_host_mak
1670 echo "CURSES_LIBS=$curses_libs" >> $config_host_mak
1672 if test "$atfile" = "yes" ; then
1673 echo "CONFIG_ATFILE=y" >> $config_host_mak
1675 if test "$utimens" = "yes" ; then
1676 echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
1678 if test "$pipe2" = "yes" ; then
1679 echo "CONFIG_PIPE2=y" >> $config_host_mak
1681 if test "$splice" = "yes" ; then
1682 echo "CONFIG_SPLICE=y" >> $config_host_mak
1684 if test "$inotify" = "yes" ; then
1685 echo "CONFIG_INOTIFY=y" >> $config_host_mak
1687 if test "$byteswap_h" = "yes" ; then
1688 echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
1690 if test "$bswap_h" = "yes" ; then
1691 echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
1693 if test "$curl" = "yes" ; then
1694 echo "CONFIG_CURL=y" >> $config_host_mak
1695 echo "CURL_LIBS=$curl_libs" >> $config_host_mak
1697 if test "$brlapi" = "yes" ; then
1698 echo "CONFIG_BRLAPI=y" >> $config_host_mak
1699 echo "BRLAPI_LIBS=$brlapi_libs" >> $config_host_mak
1701 if test "$bluez" = "yes" ; then
1702 echo "CONFIG_BLUEZ=y" >> $config_host_mak
1703 echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
1704 echo "BLUEZ_LIBS=$bluez_libs" >> $config_host_mak
1706 if test "$xen" = "yes" ; then
1707 echo "CONFIG_XEN=y" >> $config_host_mak
1708 echo "XEN_LIBS=$xen_libs" >> $config_host_mak
1710 if test "$aio" = "yes" ; then
1711 echo "CONFIG_AIO=y" >> $config_host_mak
1713 if test "$io_thread" = "yes" ; then
1714 echo "CONFIG_IOTHREAD=y" >> $config_host_mak
1716 if test "$blobs" = "yes" ; then
1717 echo "INSTALL_BLOBS=yes" >> $config_host_mak
1719 if test "$iovec" = "yes" ; then
1720 echo "CONFIG_IOVEC=y" >> $config_host_mak
1722 if test "$preadv" = "yes" ; then
1723 echo "CONFIG_PREADV=y" >> $config_host_mak
1725 if test "$fdt" = "yes" ; then
1726 echo "CONFIG_FDT=y" >> $config_host_mak
1727 echo "FDT_LIBS=$fdt_libs" >> $config_host_mak
1730 # XXX: suppress that
1731 if [ "$bsd" = "yes" ] ; then
1732 echo "CONFIG_BSD=y" >> $config_host_mak
1735 echo "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
1740 echo "HOST_USB=linux" >> $config_host_mak
1743 echo "HOST_USB=bsd" >> $config_host_mak
1746 echo "HOST_USB=stub" >> $config_host_mak
1751 if test `expr "$target_list" : ".*softmmu.*"` != 0 ; then
1752 tools="qemu-img\$(EXESUF) $tools"
1753 if [ "$linux" = "yes" ] ; then
1754 tools="qemu-nbd\$(EXESUF) qemu-io\$(EXESUF) $tools"
1757 echo "TOOLS=$tools" >> $config_host_mak
1759 # Mac OS X ships with a broken assembler
1761 if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
1762 "$targetos" != "Darwin" ; then
1765 echo "ROMS=$roms" >> $config_host_mak
1767 echo "prefix=$prefix" >> $config_host_mak
1768 echo "bindir=\${prefix}$binsuffix" >> $config_host_mak
1769 echo "mandir=\${prefix}$mansuffix" >> $config_host_mak
1770 echo "datadir=\${prefix}$datasuffix" >> $config_host_mak
1771 echo "docdir=\${prefix}$docsuffix" >> $config_host_mak
1772 echo "MAKE=$make" >> $config_host_mak
1773 echo "INSTALL=$install" >> $config_host_mak
1774 echo "INSTALL_DIR=$install -d -m0755 -p" >> $config_host_mak
1775 echo "INSTALL_DATA=$install -m0644 -p" >> $config_host_mak
1776 echo "INSTALL_PROG=$install -m0755 -p" >> $config_host_mak
1777 echo "CC=$cc" >> $config_host_mak
1778 echo "HOST_CC=$host_cc" >> $config_host_mak
1779 if test "$sparse" = "yes" ; then
1780 echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_host_mak
1781 echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_host_mak
1782 echo "CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
1784 echo "AR=$ar" >> $config_host_mak
1785 echo "OBJCOPY=$objcopy" >> $config_host_mak
1786 echo "LD=$ld" >> $config_host_mak
1787 echo "CFLAGS=$CFLAGS" >> $config_host_mak
1788 echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
1789 echo "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak
1790 echo "ARLIBS_END=$arlibs_end" >> $config_host_mak
1791 echo "EXESUF=$EXESUF" >> $config_host_mak
1792 echo "PTHREADLIBS=$PTHREADLIBS" >> $config_host_mak
1793 echo "CLOCKLIBS=$CLOCKLIBS" >> $config_host_mak
1795 echo "/* Automatically generated by configure - do not modify */" > $config_host_h
1797 $SHELL $source_path/create_config < $config_host_mak >> $config_host_h
1799 if test -f ${config_host_h}~ ; then
1800 if cmp -s $config_host_h ${config_host_h}~ ; then
1801 mv ${config_host_h}~ $config_host_h
1803 rm ${config_host_h}~
1807 # generate list of library paths for linker script
1809 $ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
1811 if test -f ${config_host_ld}~ ; then
1812 if cmp -s $config_host_ld ${config_host_ld}~ ; then
1813 mv ${config_host_ld}~ $config_host_ld
1815 rm ${config_host_ld}~
1819 for target in $target_list; do
1820 target_dir="$target"
1821 config_mak=$target_dir/config.mak
1822 config_h=$target_dir/config.h
1823 target_arch2=`echo $target | cut -d '-' -f 1`
1824 target_bigendian="no"
1825 case "$target_arch2" in
1826 armeb|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|sh4eb|sparc|sparc64|sparc32plus)
1827 target_bigendian=yes
1831 target_user_only="no"
1832 target_linux_user="no"
1833 target_darwin_user="no"
1834 target_bsd_user="no"
1836 ${target_arch2}-softmmu)
1837 target_softmmu="yes"
1839 ${target_arch2}-linux-user)
1840 target_user_only="yes"
1841 target_linux_user="yes"
1843 ${target_arch2}-darwin-user)
1844 target_user_only="yes"
1845 target_darwin_user="yes"
1847 ${target_arch2}-bsd-user)
1848 target_user_only="yes"
1849 target_bsd_user="yes"
1852 echo "ERROR: Target '$target' not recognised"
1857 #echo "Creating $config_mak, $config_h and $target_dir/Makefile"
1859 test -f $config_h && mv $config_h ${config_h}~
1861 mkdir -p $target_dir
1862 mkdir -p $target_dir/fpu
1863 mkdir -p $target_dir/tcg
1864 if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
1865 mkdir -p $target_dir/nwfpe
1869 # don't use ln -sf as not all "ln -sf" over write the file/link
1871 rm -f $target_dir/Makefile
1872 ln -s $source_path/Makefile.target $target_dir/Makefile
1875 echo "# Automatically generated by configure - do not modify" > $config_mak
1877 echo "include ../config-host.mak" >> $config_mak
1882 interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
1883 echo "CONFIG_QEMU_PREFIX=\"$interp_prefix1\"" >> $config_mak
1886 TARGET_ARCH="$target_arch2"
1890 case "$target_arch2" in
1895 TARGET_BASE_ARCH=i386
1905 gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
1914 gdb_xml_files="cf-core.xml cf-fp.xml"
1924 echo "TARGET_ABI_MIPSO32=y" >> $config_mak
1930 TARGET_BASE_ARCH=mips
1931 echo "TARGET_ABI_MIPSN32=y" >> $config_mak
1936 TARGET_BASE_ARCH=mips
1937 echo "TARGET_ABI_MIPSN64=y" >> $config_mak
1941 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
1946 TARGET_BASE_ARCH=ppc
1948 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
1953 TARGET_BASE_ARCH=ppc
1955 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
1960 TARGET_BASE_ARCH=ppc
1962 echo "TARGET_ABI32=y" >> $config_mak
1963 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
1976 TARGET_BASE_ARCH=sparc
1982 TARGET_BASE_ARCH=sparc
1983 TARGET_ABI_DIR=sparc
1984 echo "TARGET_ABI32=y" >> $config_mak
1988 echo "Unsupported target CPU"
1992 echo "TARGET_ARCH=$TARGET_ARCH" >> $config_mak
1993 echo "TARGET_ARCH2=$target_arch2" >> $config_mak
1994 # TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
1995 if [ "$TARGET_BASE_ARCH" = "" ]; then
1996 TARGET_BASE_ARCH=$TARGET_ARCH
1998 echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_mak
1999 if [ "$TARGET_ABI_DIR" = "" ]; then
2000 TARGET_ABI_DIR=$TARGET_ARCH
2002 echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_mak
2003 if [ $target_phys_bits -lt $hostlongbits ] ; then
2004 target_phys_bits=$hostlongbits
2006 case "$target_arch2" in
2008 if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
2009 echo "CONFIG_XEN=y" >> $config_mak
2011 if test $kqemu = "yes" -a "$target_softmmu" = "yes"
2013 echo "CONFIG_KQEMU=y" >> $config_mak
2016 case "$target_arch2" in
2017 i386|x86_64|ppcemb|ppc|ppc64)
2018 # Make sure the target and host cpus are compatible
2019 if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
2020 \( "$target_arch2" = "$cpu" -o \
2021 \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
2022 \( "$target_arch2" = "ppc64" -a "$cpu" = "ppc" \) -o \
2023 \( "$target_arch2" = "x86_64" -a "$cpu" = "i386" \) -o \
2024 \( "$target_arch2" = "i386" -a "$cpu" = "x86_64" \) \) ; then
2025 echo "CONFIG_KVM=y" >> $config_mak
2026 echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak
2029 echo "HWLIB=../libhw$target_phys_bits/libqemuhw$target_phys_bits.a" >> $config_mak
2030 echo "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_mak
2031 echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
2032 if test "$target_bigendian" = "yes" ; then
2033 echo "TARGET_WORDS_BIGENDIAN=y" >> $config_mak
2035 if test "$target_softmmu" = "yes" ; then
2036 echo "CONFIG_SOFTMMU=y" >> $config_mak
2038 if test "$target_user_only" = "yes" ; then
2039 echo "CONFIG_USER_ONLY=y" >> $config_mak
2041 if test "$target_linux_user" = "yes" ; then
2042 echo "CONFIG_LINUX_USER=y" >> $config_mak
2044 if test "$target_darwin_user" = "yes" ; then
2045 echo "CONFIG_DARWIN_USER=y" >> $config_mak
2048 if test ! -z "$gdb_xml_files" ; then
2049 for x in $gdb_xml_files; do
2050 list="$list $source_path/gdb-xml/$x"
2053 echo "TARGET_XML_FILES=$list" >> $config_mak
2055 case "$target_arch2" in
2056 arm|armeb|m68k|microblaze|mips|mipsel|mipsn32|mipsn32el|mips64|mips64el|ppc|ppc64|ppc64abi32|ppcemb|sparc|sparc64|sparc32plus)
2057 echo "CONFIG_SOFTFLOAT=y" >> $config_mak
2061 if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
2062 echo "TARGET_HAS_BFLT=y" >> $config_mak
2064 if test "$target_user_only" = "yes" \
2065 -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
2066 echo "CONFIG_USE_NPTL=y" >> $config_mak
2068 # 32 bit ELF loader in addition to native 64 bit loader?
2069 if test "$target_user_only" = "yes" -a "$elfload32" = "yes"; then
2070 echo "TARGET_HAS_ELFLOAD32=y" >> $config_mak
2072 if test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
2073 echo "CONFIG_USE_GUEST_BASE=y" >> $config_mak
2075 if test "$target_bsd_user" = "yes" ; then
2076 echo "CONFIG_BSD_USER=y" >> $config_mak
2079 # generate LDFLAGS for targets
2082 if test "$target_linux_user" = "yes" -o "$target_linux_user" = "yes" ; then
2085 if test "$gprof" = "yes" -o "$static" = "yes" ; then
2086 ldflags='-Wl,-T../config-host.ld -Wl,-T,$(SRC_PATH)/$(ARCH).ld'
2088 # WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
2089 # that the kernel ELF loader considers as an executable. I think this
2090 # is the simplest way to make it self virtualizable!
2091 ldflags='-Wl,-shared'
2095 # -static is used to avoid g1/g3 usage by the dynamic linker
2096 ldflags='-Wl,-T../config-host.ld -Wl,-T,$(SRC_PATH)/$(ARCH).ld -static'
2099 ldflags='-Wl,-G0 -Wl,-T../config-host.ld -Wl,-T,$(SRC_PATH)/$(ARCH).ld -static'
2101 x86_64|ppc|ppc64|s390|sparc64|alpha|arm|m68k|mips|mips64)
2102 ldflags='-Wl,-T../config-host.ld -Wl,-T,$(SRC_PATH)/$(ARCH).ld'
2106 if test "$target_softmmu" = "yes" ; then
2109 ldflags='-Wl,-G0 -Wl,-T../config-host.ld -Wl,-T,$(SRC_PATH)/$(ARCH).ld -static'
2114 if test "$ldflags" != "" ; then
2115 echo "LDFLAGS+=$ldflags" >> $config_mak
2118 echo "/* Automatically generated by configure - do not modify */" > $config_h
2119 echo "#include \"../config-host.h\"" >> $config_h
2121 $SHELL $source_path/create_config < $config_mak >> $config_h
2123 if test -f ${config_h}~ ; then
2124 if cmp -s $config_h ${config_h}~ ; then
2125 mv ${config_h}~ $config_h
2131 done # for target in $targets
2133 # build tree in object directory if source path is different from current one
2134 if test "$source_path_used" = "yes" ; then
2135 DIRS="tests tests/cris slirp audio block pc-bios/optionrom"
2136 FILES="Makefile tests/Makefile"
2137 FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
2138 FILES="$FILES tests/test-mmap.c"
2139 FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps pc-bios/video.x"
2140 for bios_file in $source_path/pc-bios/*.bin $source_path/pc-bios/*.dtb $source_path/pc-bios/openbios-*; do
2141 FILES="$FILES pc-bios/`basename $bios_file`"
2143 for dir in $DIRS ; do
2146 # remove the link and recreate it, as not all "ln -sf" overwrite the link
2147 for f in $FILES ; do
2149 ln -s $source_path/$f $f
2153 for hwlib in 32 64; do
2157 ln -s $source_path/Makefile.hw $d/Makefile
2158 echo "HWLIB=libqemuhw$hwlib.a" > $d/config.mak
2159 echo "CPPFLAGS=-DTARGET_PHYS_ADDR_BITS=$hwlib" >> $d/config.mak