oss variable don't exist anymore
[qemu] / configure
1 #!/bin/sh
2 #
3 # qemu configure script (c) 2003 Fabrice Bellard
4 #
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"
12 fi
13
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"
20
21 trap "rm -f $TMPC $TMPO $TMPE $TMPS $TMPI $TMPSDLLOG; exit" 0 2 3 15
22
23 # default parameters
24 prefix=""
25 interp_prefix="/usr/gnemul/qemu-%M"
26 static="no"
27 cross_prefix=""
28 cc="gcc"
29 audio_drv_list=""
30 audio_card_list="ac97 es1370 sb16"
31 audio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus"
32 host_cc="gcc"
33 ar="ar"
34 make="make"
35 install="install"
36 objcopy="objcopy"
37 ld="ld"
38
39 # parse CC options first
40 for opt do
41   optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
42   case "$opt" in
43   --cross-prefix=*) cross_prefix="$optarg"
44   ;;
45   --cc=*) cc="$optarg"
46   ;;
47   esac
48 done
49
50 # OS specific
51 # Using uname is really, really broken.  Once we have the right set of checks
52 # we can eliminate it's usage altogether
53
54 cc="${cross_prefix}${cc}"
55 ar="${cross_prefix}${ar}"
56 objcopy="${cross_prefix}${objcopy}"
57 ld="${cross_prefix}${ld}"
58
59 # check that the C compiler works.
60 cat > $TMPC <<EOF
61 int main(void) {}
62 EOF
63
64 if $cc $ARCH_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null ; then
65   : C compiler works ok
66 else
67     echo "ERROR: \"$cc\" either does not exist or does not work"
68     exit 1
69 fi
70
71 check_define() {
72 cat > $TMPC <<EOF
73 #if !defined($1)
74 #error Not defined
75 #endif
76 int main(void) { return 0; }
77 EOF
78   $cc $ARCH_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null
79 }
80
81 if check_define __i386__ ; then
82   cpu="i386"
83 elif check_define __x86_64__ ; then
84   cpu="x86_64"
85 elif check_define __sparc__ ; then
86   # We can't check for 64 bit (when gcc is biarch) or V8PLUSA
87   # They must be specified using --sparc_cpu
88   if check_define __arch64__ ; then
89     cpu="sparc64"
90   else
91     cpu="sparc"
92   fi
93 elif check_define _ARCH_PPC ; then
94   if check_define _ARCH_PPC64 ; then
95     cpu="ppc64"
96   else
97     cpu="ppc"
98   fi
99 else
100   cpu=`uname -m`
101 fi
102
103 target_list=""
104 case "$cpu" in
105   i386|i486|i586|i686|i86pc|BePC)
106     cpu="i386"
107   ;;
108   x86_64|amd64)
109     cpu="x86_64"
110   ;;
111   alpha)
112     cpu="alpha"
113   ;;
114   armv*b)
115     cpu="armv4b"
116   ;;
117   armv*l)
118     cpu="armv4l"
119   ;;
120   cris)
121     cpu="cris"
122   ;;
123   parisc|parisc64)
124     cpu="hppa"
125   ;;
126   ia64)
127     cpu="ia64"
128   ;;
129   m68k)
130     cpu="m68k"
131   ;;
132   microblaze)
133     cpu="microblaze"
134   ;;
135   mips)
136     cpu="mips"
137   ;;
138   mips64)
139     cpu="mips64"
140   ;;
141   ppc)
142     cpu="ppc"
143   ;;
144   ppc64)
145     cpu="ppc64"
146   ;;
147   s390*)
148     cpu="s390"
149   ;;
150   sparc|sun4[cdmuv])
151     cpu="sparc"
152   ;;
153   sparc64)
154     cpu="sparc64"
155   ;;
156   *)
157     cpu="unknown"
158   ;;
159 esac
160 brlapi="yes"
161 gprof="no"
162 debug_tcg="no"
163 debug="no"
164 sparse="no"
165 strip_opt="yes"
166 bigendian="no"
167 mingw32="no"
168 EXESUF=""
169 slirp="yes"
170 vde="yes"
171 fmod_lib=""
172 fmod_inc=""
173 oss_lib=""
174 vnc_tls="yes"
175 vnc_sasl="yes"
176 bsd="no"
177 linux="no"
178 solaris="no"
179 kqemu="no"
180 profiler="no"
181 cocoa="no"
182 softmmu="yes"
183 linux_user="no"
184 darwin_user="no"
185 bsd_user="no"
186 guest_base=""
187 build_docs="yes"
188 uname_release=""
189 curses="yes"
190 curl="yes"
191 pthread="yes"
192 aio="yes"
193 io_thread="no"
194 nptl="yes"
195 mixemu="no"
196 bluez="yes"
197 kvm="no"
198 kerneldir=""
199 aix="no"
200 blobs="yes"
201 fdt="yes"
202 sdl="yes"
203 xen="yes"
204 pkgversion=""
205
206 # OS specific
207 if check_define __linux__ ; then
208   targetos="Linux"
209 elif check_define _WIN32 ; then
210   targetos='MINGW32'
211 elif check_define __OpenBSD__ ; then
212   targetos='OpenBSD'
213 elif check_define __sun__ ; then
214   targetos='SunOS'
215 else
216   targetos=`uname -s`
217 fi
218 case $targetos in
219 CYGWIN*)
220 mingw32="yes"
221 OS_CFLAGS="-mno-cygwin"
222 if [ "$cpu" = "i386" ] ; then
223     kqemu="yes"
224 fi
225 audio_possible_drivers="sdl"
226 ;;
227 MINGW32*)
228 mingw32="yes"
229 if [ "$cpu" = "i386" ] ; then
230     kqemu="yes"
231 fi
232 audio_possible_drivers="dsound sdl fmod"
233 ;;
234 GNU/kFreeBSD)
235 audio_drv_list="oss"
236 audio_possible_drivers="oss sdl esd pa"
237 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
238     kqemu="yes"
239 fi
240 ;;
241 FreeBSD)
242 bsd="yes"
243 audio_drv_list="oss"
244 audio_possible_drivers="oss sdl esd pa"
245 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
246     kqemu="yes"
247 fi
248 ;;
249 DragonFly)
250 bsd="yes"
251 audio_drv_list="oss"
252 audio_possible_drivers="oss sdl esd pa"
253 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
254     kqemu="yes"
255 fi
256 aio="no"
257 ;;
258 NetBSD)
259 bsd="yes"
260 audio_drv_list="oss"
261 audio_possible_drivers="oss sdl esd"
262 oss_lib="-lossaudio"
263 ;;
264 OpenBSD)
265 bsd="yes"
266 audio_drv_list="oss"
267 audio_possible_drivers="oss sdl esd"
268 oss_lib="-lossaudio"
269 ;;
270 Darwin)
271 bsd="yes"
272 darwin="yes"
273 # 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
274 if [ "$cpu" = "i386" ] ; then
275     is_x86_64=`sysctl -n hw.optional.x86_64`
276     [ "$is_x86_64" = "1" ] && cpu=x86_64
277 fi
278 if [ "$cpu" = "x86_64" ] ; then
279     OS_CFLAGS="-arch x86_64"
280     LDFLAGS="-arch x86_64"
281 else
282     OS_CFLAGS="-mdynamic-no-pic"
283 fi
284 darwin_user="yes"
285 cocoa="yes"
286 audio_drv_list="coreaudio"
287 audio_possible_drivers="coreaudio sdl fmod"
288 OS_LDFLAGS="-framework CoreFoundation -framework IOKit"
289 ;;
290 SunOS)
291     solaris="yes"
292     make="gmake"
293     install="ginstall"
294     needs_libsunmath="no"
295     solarisrev=`uname -r | cut -f2 -d.`
296     # have to select again, because `uname -m` returns i86pc
297     # even on an x86_64 box.
298     solariscpu=`isainfo -k`
299     if test "${solariscpu}" = "amd64" ; then
300         cpu="x86_64"
301     fi
302     if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
303         if test "$solarisrev" -le 9 ; then
304             if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
305                 needs_libsunmath="yes"
306             else
307                 echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
308                 echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
309                 echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
310                 echo "Studio 11 can be downloaded from www.sun.com."
311                 exit 1
312             fi
313         fi
314         if test "$solarisrev" -ge 9 ; then
315             kqemu="yes"
316         fi
317     fi
318     if test -f /usr/include/sys/soundcard.h ; then
319         audio_drv_list="oss"
320     fi
321     audio_possible_drivers="oss sdl"
322     OS_CFLAGS=-std=gnu99
323 ;;
324 AIX)
325 aix="yes"
326 make="gmake"
327 ;;
328 *)
329 audio_drv_list="oss"
330 audio_possible_drivers="oss alsa sdl esd pa"
331 linux="yes"
332 linux_user="yes"
333 usb="linux"
334 kvm="yes"
335 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
336     kqemu="yes"
337     audio_possible_drivers="$audio_possible_drivers fmod"
338 fi
339 ;;
340 esac
341
342 if [ "$bsd" = "yes" ] ; then
343   if [ "$darwin" != "yes" ] ; then
344     make="gmake"
345     usb="bsd"
346   fi
347   bsd_user="yes"
348 fi
349
350 # find source path
351 source_path=`dirname "$0"`
352 source_path_used="no"
353 workdir=`pwd`
354 if [ -z "$source_path" ]; then
355     source_path=$workdir
356 else
357     source_path=`cd "$source_path"; pwd`
358 fi
359 [ -f "$workdir/vl.c" ] || source_path_used="yes"
360
361 werror=""
362
363 for opt do
364   optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
365   case "$opt" in
366   --help|-h) show_help=yes
367   ;;
368   --prefix=*) prefix="$optarg"
369   ;;
370   --interp-prefix=*) interp_prefix="$optarg"
371   ;;
372   --source-path=*) source_path="$optarg"
373   source_path_used="yes"
374   ;;
375   --cross-prefix=*)
376   ;;
377   --cc=*)
378   ;;
379   --host-cc=*) host_cc="$optarg"
380   ;;
381   --make=*) make="$optarg"
382   ;;
383   --install=*) install="$optarg"
384   ;;
385   --extra-cflags=*) EXTRA_CFLAGS="$optarg"
386   ;;
387   --extra-ldflags=*) EXTRA_LDFLAGS="$optarg"
388   ;;
389   --cpu=*) cpu="$optarg"
390   ;;
391   --target-list=*) target_list="$optarg"
392   ;;
393   --enable-gprof) gprof="yes"
394   ;;
395   --static) static="yes"
396   ;;
397   --disable-sdl) sdl="no"
398   ;;
399   --fmod-lib=*) fmod_lib="$optarg"
400   ;;
401   --fmod-inc=*) fmod_inc="$optarg"
402   ;;
403   --oss-lib=*) oss_lib="$optarg"
404   ;;
405   --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
406   ;;
407   --audio-drv-list=*) audio_drv_list="$optarg"
408   ;;
409   --enable-debug-tcg) debug_tcg="yes"
410   ;;
411   --disable-debug-tcg) debug_tcg="no"
412   ;;
413   --enable-debug)
414       # Enable debugging options that aren't excessively noisy
415       debug_tcg="yes"
416       debug="yes"
417       strip_opt="no"
418   ;;
419   --enable-sparse) sparse="yes"
420   ;;
421   --disable-sparse) sparse="no"
422   ;;
423   --disable-strip) strip_opt="no"
424   ;;
425   --disable-vnc-tls) vnc_tls="no"
426   ;;
427   --disable-vnc-sasl) vnc_sasl="no"
428   ;;
429   --disable-slirp) slirp="no"
430   ;;
431   --disable-vde) vde="no"
432   ;;
433   --disable-kqemu) kqemu="no"
434   ;;
435   --disable-xen) xen="no"
436   ;;
437   --disable-brlapi) brlapi="no"
438   ;;
439   --disable-bluez) bluez="no"
440   ;;
441   --disable-kvm) kvm="no"
442   ;;
443   --enable-profiler) profiler="yes"
444   ;;
445   --enable-cocoa)
446       cocoa="yes" ;
447       sdl="no" ;
448       audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
449   ;;
450   --disable-system) softmmu="no"
451   ;;
452   --enable-system) softmmu="yes"
453   ;;
454   --disable-linux-user) linux_user="no"
455   ;;
456   --enable-linux-user) linux_user="yes"
457   ;;
458   --disable-darwin-user) darwin_user="no"
459   ;;
460   --enable-darwin-user) darwin_user="yes"
461   ;;
462   --disable-bsd-user) bsd_user="no"
463   ;;
464   --enable-bsd-user) bsd_user="yes"
465   ;;
466   --enable-guest-base) guest_base="yes"
467   ;;
468   --disable-guest-base) guest_base="no"
469   ;;
470   --enable-uname-release=*) uname_release="$optarg"
471   ;;
472   --sparc_cpu=*)
473       sparc_cpu="$optarg"
474       case $sparc_cpu in
475         v7|v8)
476           ARCH_CFLAGS="-m32 -mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__"
477           ARCH_LDFLAGS="-m32"
478           cpu="sparc"
479         ;;
480         v8plus|v8plusa)
481           ARCH_CFLAGS="-m32 -mcpu=ultrasparc -D__sparc_${sparc_cpu}__"
482           ARCH_LDFLAGS="-m32"
483           cpu="sparc"
484         ;;
485         v9)
486           ARCH_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_${sparc_cpu}__"
487           ARCH_LDFLAGS="-m64"
488           cpu="sparc64"
489         ;;
490         *)
491           echo "undefined SPARC architecture. Exiting";
492           exit 1
493         ;;
494       esac
495   ;;
496   --enable-werror) werror="yes"
497   ;;
498   --disable-werror) werror="no"
499   ;;
500   --disable-curses) curses="no"
501   ;;
502   --disable-curl) curl="no"
503   ;;
504   --disable-nptl) nptl="no"
505   ;;
506   --enable-mixemu) mixemu="yes"
507   ;;
508   --disable-pthread) pthread="no"
509   ;;
510   --disable-aio) aio="no"
511   ;;
512   --enable-io-thread) io_thread="yes"
513   ;;
514   --disable-blobs) blobs="no"
515   ;;
516   --kerneldir=*) kerneldir="$optarg"
517   ;;
518   --with-pkgversion=*) pkgversion=" ($optarg)"
519   ;;
520   --disable-docs) build_docs="no"
521   ;;
522   *) echo "ERROR: unknown option $opt"; show_help="yes"
523   ;;
524   esac
525 done
526
527 # default flags for all hosts
528 CFLAGS="$CFLAGS -g -fno-strict-aliasing"
529 if test "$debug" = "no" ; then
530   CFLAGS="$CFLAGS -O2"
531 fi
532 CFLAGS="$CFLAGS -Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls"
533 LDFLAGS="$LDFLAGS -g"
534
535 # Consult white-list to determine whether to enable werror
536 # by default.  Only enable by default for git builds
537 if test -z "$werror" ; then
538     z_version=`cut -f3 -d. $source_path/VERSION`
539     if test "$z_version" = "50" -a \
540         "$linux" = "yes" ; then
541         werror="yes"
542     else
543         werror="no"
544     fi
545 fi
546
547 if test "$werror" = "yes" ; then
548     CFLAGS="$CFLAGS -Werror"
549 fi
550
551 if test "$solaris" = "no" ; then
552     if ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
553         LDFLAGS="$LDFLAGS -Wl,--warn-common"
554     fi
555 fi
556
557 #
558 # If cpu ~= sparc and  sparc_cpu hasn't been defined, plug in the right
559 # ARCH_CFLAGS/ARCH_LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
560 #
561 host_guest_base="no"
562 case "$cpu" in
563     sparc) if test -z "$sparc_cpu" ; then
564                ARCH_CFLAGS="-m32 -mcpu=ultrasparc -D__sparc_v8plus__"
565                ARCH_LDFLAGS="-m32"
566            fi
567            ARCH_CFLAGS="$ARCH_CFLAGS -ffixed-g2 -ffixed-g3"
568            if test "$solaris" = "no" ; then
569                ARCH_CFLAGS="$ARCH_CFLAGS -ffixed-g1 -ffixed-g6"
570            fi
571            ;;
572     sparc64) if test -z "$sparc_cpu" ; then
573                ARCH_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__"
574                ARCH_LDFLAGS="-m64"
575            fi
576            if test "$solaris" = "no" ; then
577                ARCH_CFLAGS="$ARCH_CFLAGS -ffixed-g5 -ffixed-g6 -ffixed-g7"
578            else
579                ARCH_CFLAGS="$ARCH_CFLAGS -ffixed-g1 -ffixed-g5 -ffixed-g6 -ffixed-g7"
580            fi
581            ;;
582     s390)
583            ARCH_CFLAGS="-march=z900"
584            ;;
585     i386)
586            ARCH_CFLAGS="-m32"
587            ARCH_LDFLAGS="-m32"
588            host_guest_base="yes"
589            ;;
590     x86_64)
591            ARCH_CFLAGS="-m64"
592            ARCH_LDFLAGS="-m64"
593            host_guest_base="yes"
594            ;;
595     arm*)
596            host_guest_base="yes"
597            ;;
598     ppc*)
599            host_guest_base="yes"
600            ;;
601 esac
602
603 [ -z "$guest_base" ] && guest_base="$host_guest_base"
604
605 if test x"$show_help" = x"yes" ; then
606 cat << EOF
607
608 Usage: configure [options]
609 Options: [defaults in brackets after descriptions]
610
611 EOF
612 echo "Standard options:"
613 echo "  --help                   print this message"
614 echo "  --prefix=PREFIX          install in PREFIX [$prefix]"
615 echo "  --interp-prefix=PREFIX   where to find shared libraries, etc."
616 echo "                           use %M for cpu name [$interp_prefix]"
617 echo "  --target-list=LIST       set target list [$target_list]"
618 echo ""
619 echo "kqemu kernel acceleration support:"
620 echo "  --disable-kqemu          disable kqemu support"
621 echo ""
622 echo "Advanced options (experts only):"
623 echo "  --source-path=PATH       path of source code [$source_path]"
624 echo "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
625 echo "  --cc=CC                  use C compiler CC [$cc]"
626 echo "  --host-cc=CC             use C compiler CC [$host_cc] for dyngen etc."
627 echo "  --extra-cflags=CFLAGS    append extra C compiler flags CFLAGS"
628 echo "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
629 echo "  --make=MAKE              use specified make [$make]"
630 echo "  --install=INSTALL        use specified install [$install]"
631 echo "  --static                 enable static build [$static]"
632 echo "  --enable-debug-tcg       enable TCG debugging"
633 echo "  --disable-debug-tcg      disable TCG debugging (default)"
634 echo "  --enable-debug           enable common debug build options"
635 echo "  --enable-sparse          enable sparse checker"
636 echo "  --disable-sparse         disable sparse checker (default)"
637 echo "  --disable-strip          disable stripping binaries"
638 echo "  --disable-werror         disable compilation abort on warning"
639 echo "  --disable-sdl            disable SDL"
640 echo "  --enable-cocoa           enable COCOA (Mac OS X only)"
641 echo "  --audio-drv-list=LIST    set audio drivers list:"
642 echo "                           Available drivers: $audio_possible_drivers"
643 echo "  --audio-card-list=LIST   set list of emulated audio cards [$audio_card_list]"
644 echo "                           Available cards: $audio_possible_cards"
645 echo "  --enable-mixemu          enable mixer emulation"
646 echo "  --disable-xen            disable xen backend driver support"
647 echo "  --disable-brlapi         disable BrlAPI"
648 echo "  --disable-vnc-tls        disable TLS encryption for VNC server"
649 echo "  --disable-vnc-sasl       disable SASL encryption for VNC server"
650 echo "  --disable-curses         disable curses output"
651 echo "  --disable-curl           disable curl connectivity"
652 echo "  --disable-bluez          disable bluez stack connectivity"
653 echo "  --disable-kvm            disable KVM acceleration support"
654 echo "  --disable-nptl           disable usermode NPTL support"
655 echo "  --enable-system          enable all system emulation targets"
656 echo "  --disable-system         disable all system emulation targets"
657 echo "  --enable-linux-user      enable all linux usermode emulation targets"
658 echo "  --disable-linux-user     disable all linux usermode emulation targets"
659 echo "  --enable-darwin-user     enable all darwin usermode emulation targets"
660 echo "  --disable-darwin-user    disable all darwin usermode emulation targets"
661 echo "  --enable-bsd-user        enable all BSD usermode emulation targets"
662 echo "  --disable-bsd-user       disable all BSD usermode emulation targets"
663 echo "  --enable-guest-base      enable GUEST_BASE support for usermode"
664 echo "                           emulation targets"
665 echo "  --disable-guest-base     disable GUEST_BASE support"
666 echo "  --fmod-lib               path to FMOD library"
667 echo "  --fmod-inc               path to FMOD includes"
668 echo "  --oss-lib                path to OSS library"
669 echo "  --enable-uname-release=R Return R for uname -r in usermode emulation"
670 echo "  --sparc_cpu=V            Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
671 echo "  --disable-vde            disable support for vde network"
672 echo "  --disable-pthread        disable pthread support"
673 echo "  --disable-aio            disable AIO support"
674 echo "  --enable-io-thread       enable IO thread"
675 echo "  --disable-blobs          disable installing provided firmware blobs"
676 echo "  --kerneldir=PATH         look for kernel includes in PATH"
677 echo ""
678 echo "NOTE: The object files are built at the place where configure is launched"
679 exit 1
680 fi
681
682 if test "$mingw32" = "yes" ; then
683     linux="no"
684     EXESUF=".exe"
685     linux_user="no"
686     bsd_user="no"
687     OS_CFLAGS="$OS_CFLAGS -DWIN32_LEAN_AND_MEAN -DWINVER=0x501"
688 fi
689
690 if test ! -x "$(which cgcc 2>/dev/null)"; then
691     sparse="no"
692 fi
693
694 #
695 # Solaris specific configure tool chain decisions
696 #
697 if test "$solaris" = "yes" ; then
698   solinst=`which $install 2> /dev/null | /usr/bin/grep -v "no $install in"`
699   if test -z "$solinst" ; then
700     echo "Solaris install program not found. Use --install=/usr/ucb/install or"
701     echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
702     echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
703     exit 1
704   fi
705   if test "$solinst" = "/usr/sbin/install" ; then
706     echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
707     echo "try ginstall from the GNU fileutils available from www.blastwave.org"
708     echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
709     exit 1
710   fi
711   sol_ar=`which ar 2> /dev/null | /usr/bin/grep -v "no ar in"`
712   if test -z "$sol_ar" ; then
713     echo "Error: No path includes ar"
714     if test -f /usr/ccs/bin/ar ; then
715       echo "Add /usr/ccs/bin to your path and rerun configure"
716     fi
717     exit 1
718   fi
719 fi
720
721
722 if test -z "$target_list" ; then
723 # these targets are portable
724     if [ "$softmmu" = "yes" ] ; then
725         target_list="\
726 i386-softmmu \
727 x86_64-softmmu \
728 arm-softmmu \
729 cris-softmmu \
730 m68k-softmmu \
731 microblaze-softmmu \
732 mips-softmmu \
733 mipsel-softmmu \
734 mips64-softmmu \
735 mips64el-softmmu \
736 ppc-softmmu \
737 ppcemb-softmmu \
738 ppc64-softmmu \
739 sh4-softmmu \
740 sh4eb-softmmu \
741 sparc-softmmu \
742 sparc64-softmmu \
743 "
744     fi
745 # the following are Linux specific
746     if [ "$linux_user" = "yes" ] ; then
747         target_list="${target_list}\
748 i386-linux-user \
749 x86_64-linux-user \
750 alpha-linux-user \
751 arm-linux-user \
752 armeb-linux-user \
753 cris-linux-user \
754 m68k-linux-user \
755 microblaze-linux-user \
756 mips-linux-user \
757 mipsel-linux-user \
758 ppc-linux-user \
759 ppc64-linux-user \
760 ppc64abi32-linux-user \
761 sh4-linux-user \
762 sh4eb-linux-user \
763 sparc-linux-user \
764 sparc64-linux-user \
765 sparc32plus-linux-user \
766 "
767     fi
768 # the following are Darwin specific
769     if [ "$darwin_user" = "yes" ] ; then
770         target_list="$target_list i386-darwin-user ppc-darwin-user "
771     fi
772 # the following are BSD specific
773     if [ "$bsd_user" = "yes" ] ; then
774         target_list="${target_list}\
775 i386-bsd-user \
776 x86_64-bsd-user \
777 sparc-bsd-user \
778 sparc64-bsd-user \
779 "
780     fi
781 else
782     target_list=`echo "$target_list" | sed -e 's/,/ /g'`
783 fi
784 if test -z "$target_list" ; then
785     echo "No targets enabled"
786     exit 1
787 fi
788
789 if test -z "$cross_prefix" ; then
790
791 # ---
792 # big/little endian test
793 cat > $TMPC << EOF
794 #include <inttypes.h>
795 int main(int argc, char ** argv){
796         volatile uint32_t i=0x01234567;
797         return (*((uint8_t*)(&i))) == 0x67;
798 }
799 EOF
800
801 if $cc $ARCH_CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
802 $TMPE && bigendian="yes"
803 else
804 echo big/little test failed
805 fi
806
807 else
808
809 # if cross compiling, cannot launch a program, so make a static guess
810 if test "$cpu" = "armv4b" \
811      -o "$cpu" = "hppa" \
812      -o "$cpu" = "m68k" \
813      -o "$cpu" = "mips" \
814      -o "$cpu" = "mips64" \
815      -o "$cpu" = "ppc" \
816      -o "$cpu" = "ppc64" \
817      -o "$cpu" = "s390" \
818      -o "$cpu" = "sparc" \
819      -o "$cpu" = "sparc64"; then
820     bigendian="yes"
821 fi
822
823 fi
824
825 # host long bits test
826 hostlongbits="32"
827 if test "$cpu" = "x86_64" \
828      -o "$cpu" = "alpha" \
829      -o "$cpu" = "ia64" \
830      -o "$cpu" = "sparc64" \
831      -o "$cpu" = "ppc64"; then
832     hostlongbits="64"
833 fi
834
835 # Check host NPTL support
836 cat > $TMPC <<EOF
837 #include <sched.h>
838 #include <linux/futex.h>
839 void foo()
840 {
841 #if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
842 #error bork
843 #endif
844 }
845 EOF
846
847 if $cc $ARCH_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null ; then
848   :
849 else
850    nptl="no"
851 fi
852
853 ##########################################
854 # zlib check
855
856 cat > $TMPC << EOF
857 #include <zlib.h>
858 int main(void) { zlibVersion(); return 0; }
859 EOF
860 if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $TMPC -lz > /dev/null 2> /dev/null ; then
861     :
862 else
863     echo
864     echo "Error: zlib check failed"
865     echo "Make sure to have the zlib libs and headers installed."
866     echo
867     exit 1
868 fi
869
870 ##########################################
871 # xen probe
872
873 if test "$xen" = "yes" ; then
874   xen_libs="-lxenstore -lxenctrl -lxenguest"
875   cat > $TMPC <<EOF
876 #include <xenctrl.h>
877 #include <xs.h>
878 int main(void) { xs_daemon_open(); xc_interface_open(); return 0; }
879 EOF
880   if $cc $CFLAGS $ARCH_CFLAGS $EXTRA_CFLAGS -c -o $TMPO $TMPC $LDFLAGS $EXTRA_LDFLAGS $xen_libs 2> /dev/null > /dev/null ; then
881     :
882   else
883     xen="no"
884   fi
885 fi
886
887 ##########################################
888 # SDL probe
889
890 sdl_too_old=no
891
892 if test "$sdl" = "yes" ; then
893   sdl=no
894   cat > $TMPC << EOF
895 #include <SDL.h>
896 #undef main /* We don't want SDL to override our main() */
897 int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
898 EOF
899   sdl_cflags=`sdl-config --cflags 2> /dev/null`
900   sdl_libs=`sdl-config --libs 2> /dev/null`
901   if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $sdl_cflags $TMPC $sdl_libs > $TMPSDLLOG 2>&1 ; then
902     _sdlversion=`sdl-config --version | sed 's/[^0-9]//g'`
903     if test "$_sdlversion" -lt 121 ; then
904       sdl_too_old=yes
905     else
906       if test "$cocoa" = "no" ; then
907         sdl=yes
908       fi
909     fi
910
911     # static link with sdl ?
912     if test "$sdl" = "yes" -a "$static" = "yes" ; then
913       sdl_libs=`sdl-config --static-libs 2>/dev/null`
914       if test `sdl-config --static-libs 2>/dev/null | grep \\\-laa > /dev/null` ; then
915          sdl_libs="$sdl_libs `aalib-config --static-libs >2 /dev/null`"
916          sdl_cflags="$sd_cflags `aalib-config --cflags >2 /dev/null`"
917       fi
918       if $cc -o $TMPE ${OS_CFLAGS} $sdl_cflags $TMPC $sdl_libs > /dev/null 2> /dev/null; then
919         :
920       else
921         sdl=no
922       fi
923     fi # static link
924   fi # sdl compile test
925 fi
926
927 if test "$sdl" = "yes" ; then
928   cat > $TMPC <<EOF
929 #include <SDL.h>
930 #if defined(SDL_VIDEO_DRIVER_X11)
931 #include <X11/XKBlib.h>
932 #else
933 #error No x11 support
934 #endif
935 int main(void) { return 0; }
936 EOF
937   if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $sdl_cflags $TMPC $sdl_libs > /dev/null 2>&1 ; then
938     sdl_libs="$sdl_libs -lX11"
939   fi
940 fi
941
942 ##########################################
943 # VNC TLS detection
944 if test "$vnc_tls" = "yes" ; then
945 cat > $TMPC <<EOF
946 #include <gnutls/gnutls.h>
947 int main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
948 EOF
949     vnc_tls_cflags=`pkg-config --cflags gnutls 2> /dev/null`
950     vnc_tls_libs=`pkg-config --libs gnutls 2> /dev/null`
951     if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $vnc_tls_cflags $TMPC \
952            $vnc_tls_libs > /dev/null 2> /dev/null ; then
953         :
954     else
955         vnc_tls="no"
956     fi
957 fi
958
959 ##########################################
960 # VNC SASL detection
961 if test "$vnc_sasl" = "yes" ; then
962 cat > $TMPC <<EOF
963 #include <sasl/sasl.h>
964 #include <stdio.h>
965 int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
966 EOF
967     # Assuming Cyrus-SASL installed in /usr prefix
968     vnc_sasl_cflags=""
969     vnc_sasl_libs="-lsasl2"
970     if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $vnc_sasl_cflags $TMPC \
971            $vnc_sasl_libs 2> /dev/null > /dev/null ; then
972         :
973     else
974         vnc_sasl="no"
975     fi
976 fi
977
978 ##########################################
979 # fnmatch() probe, used for ACL routines
980 fnmatch="no"
981 cat > $TMPC << EOF
982 #include <fnmatch.h>
983 int main(void)
984 {
985     fnmatch("foo", "foo", 0);
986     return 0;
987 }
988 EOF
989 if $cc $ARCH_CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
990    fnmatch="yes"
991 fi
992
993 ##########################################
994 # vde libraries probe
995 if test "$vde" = "yes" ; then
996   vde=no
997   vde_libs="-lvdeplug"
998   cat > $TMPC << EOF
999 #include <libvdeplug.h>
1000 int main(void)
1001 {
1002     struct vde_open_args a = {0, 0, 0};
1003     vde_open("", "", &a);
1004     return 0;
1005 }
1006 EOF
1007   if $cc $ARCH_CFLAGS -o $TMPE $TMPC $vde_libs > /dev/null 2> /dev/null ; then
1008     vde=yes
1009   fi
1010 fi
1011
1012 ##########################################
1013 # Sound support libraries probe
1014
1015 audio_drv_probe()
1016 {
1017     drv=$1
1018     hdr=$2
1019     lib=$3
1020     exp=$4
1021     cfl=$5
1022         cat > $TMPC << EOF
1023 #include <$hdr>
1024 int main(void) { $exp }
1025 EOF
1026     if $cc $ARCH_CFLAGS $cfl -o $TMPE $TMPC $lib > /dev/null 2> /dev/null ; then
1027         :
1028     else
1029         echo
1030         echo "Error: $drv check failed"
1031         echo "Make sure to have the $drv libs and headers installed."
1032         echo
1033         exit 1
1034     fi
1035 }
1036
1037 audio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
1038 for drv in $audio_drv_list; do
1039     case $drv in
1040     alsa)
1041     audio_drv_probe $drv alsa/asoundlib.h -lasound \
1042         "snd_pcm_t **handle; return snd_pcm_close(*handle);"
1043     ;;
1044
1045     fmod)
1046     if test -z $fmod_lib || test -z $fmod_inc; then
1047         echo
1048         echo "Error: You must specify path to FMOD library and headers"
1049         echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
1050         echo
1051         exit 1
1052     fi
1053     audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
1054     ;;
1055
1056     esd)
1057     audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
1058     ;;
1059
1060     pa)
1061     audio_drv_probe $drv pulse/simple.h -lpulse-simple \
1062         "pa_simple *s = NULL; pa_simple_free(s); return 0;"
1063     ;;
1064
1065     oss|sdl|core|wav|dsound)
1066     # XXX: Probes for CoreAudio, DirectSound, SDL(?)
1067     ;;
1068
1069     *)
1070     echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
1071         echo
1072         echo "Error: Unknown driver '$drv' selected"
1073         echo "Possible drivers are: $audio_possible_drivers"
1074         echo
1075         exit 1
1076     }
1077     ;;
1078     esac
1079 done
1080
1081 ##########################################
1082 # BrlAPI probe
1083
1084 if test "$brlapi" = "yes" ; then
1085   brlapi=no
1086   brlapi_libs="-lbrlapi"
1087   cat > $TMPC << EOF
1088 #include <brlapi.h>
1089 int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
1090 EOF
1091   if $cc ${ARCH_CFLAGS} -o $TMPE ${OS_CFLAGS} $TMPC $brlapi_libs > /dev/null 2> /dev/null ; then
1092     brlapi=yes
1093   fi
1094 fi
1095
1096 ##########################################
1097 # curses probe
1098
1099 if test "$curses" = "yes" ; then
1100   cat > $TMPC << EOF
1101 #include <curses.h>
1102 #ifdef __OpenBSD__
1103 #define resize_term resizeterm
1104 #endif
1105 int main(void) { resize_term(0, 0); return curses_version(); }
1106 EOF
1107   if $cc $ARCH_CFLAGS -o $TMPE $TMPC -lncurses > /dev/null 2> /dev/null ; then
1108     curses_libs="-lncurses"
1109   elif $cc $ARCH_CFLAGS -o $TMPE $TMPC -lcurses > /dev/null 2> /dev/null ; then
1110     curses_libs="-lcurses"
1111   else
1112     curses=no
1113   fi
1114 fi # test "$curses"
1115
1116 ##########################################
1117 # curl probe
1118
1119 if test "$curl" = "yes" ; then
1120   curl=no
1121   cat > $TMPC << EOF
1122 #include <curl/curl.h>
1123 int main(void) { return curl_easy_init(); }
1124 EOF
1125   curl_libs=`curl-config --libs 2>/dev/null`
1126  if $cc $ARCH_CFLAGS $curl_libs -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
1127     curl=yes
1128   fi
1129 fi # test "$curl"
1130
1131 ##########################################
1132 # bluez support probe
1133 if test "$bluez" = "yes" ; then
1134   `pkg-config bluez 2> /dev/null` || bluez="no"
1135 fi
1136 if test "$bluez" = "yes" ; then
1137   cat > $TMPC << EOF
1138 #include <bluetooth/bluetooth.h>
1139 int main(void) { return bt_error(0); }
1140 EOF
1141   bluez_cflags=`pkg-config --cflags bluez 2> /dev/null`
1142   bluez_libs=`pkg-config --libs bluez 2> /dev/null`
1143   if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $bluez_cflags $TMPC \
1144       $bluez_libs > /dev/null 2> /dev/null ; then
1145     :
1146   else
1147     bluez="no"
1148   fi
1149 fi
1150
1151 ##########################################
1152 # kvm probe
1153 if test "$kvm" = "yes" ; then
1154     cat > $TMPC <<EOF
1155 #include <linux/kvm.h>
1156 #if !defined(KVM_API_VERSION) || KVM_API_VERSION < 12 || KVM_API_VERSION > 12
1157 #error Invalid KVM version
1158 #endif
1159 #if !defined(KVM_CAP_USER_MEMORY)
1160 #error Missing KVM capability KVM_CAP_USER_MEMORY
1161 #endif
1162 #if !defined(KVM_CAP_SET_TSS_ADDR)
1163 #error Missing KVM capability KVM_CAP_SET_TSS_ADDR
1164 #endif
1165 #if !defined(KVM_CAP_DESTROY_MEMORY_REGION_WORKS)
1166 #error Missing KVM capability KVM_CAP_DESTROY_MEMORY_REGION_WORKS
1167 #endif
1168 int main(void) { return 0; }
1169 EOF
1170   if test "$kerneldir" != "" ; then
1171       kvm_cflags=-I"$kerneldir"/include
1172       if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) \
1173          -a -d "$kerneldir/arch/x86/include" ; then
1174             kvm_cflags="$kvm_cflags -I$kerneldir/arch/x86/include"
1175         elif test "$cpu" = "ppc" -a -d "$kerneldir/arch/powerpc/include" ; then
1176             kvm_cflags="$kvm_cflags -I$kerneldir/arch/powerpc/include"
1177         elif test -d "$kerneldir/arch/$cpu/include" ; then
1178             kvm_cflags="$kvm_cflags -I$kerneldir/arch/$cpu/include"
1179       fi
1180   else
1181       kvm_cflags=""
1182   fi
1183   if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $kvm_cflags $TMPC \
1184       > /dev/null 2>/dev/null ; then
1185     :
1186   else
1187     kvm="no";
1188     if [ -x "`which awk 2>/dev/null`" ] && \
1189        [ -x "`which grep 2>/dev/null`" ]; then
1190       kvmerr=`LANG=C $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $kvm_cflags $TMPC 2>&1 \
1191         | grep "error: " \
1192         | awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'`
1193       if test "$kvmerr" != "" ; then
1194         kvm="no - (${kvmerr})\n\
1195     NOTE: To enable KVM support, update your kernel to 2.6.29+ or install \
1196 recent kvm-kmod from http://sourceforge.net/projects/kvm."
1197       fi
1198     fi
1199   fi
1200 fi
1201
1202 ##########################################
1203 # pthread probe
1204 PTHREADLIBS_LIST="-lpthread -lpthreadGC2"
1205 PTHREADLIBS=""
1206
1207 if test "$pthread" = yes; then
1208   pthread=no
1209 cat > $TMPC << EOF
1210 #include <pthread.h>
1211 int main(void) { pthread_create(0,0,0,0); return 0; }
1212 EOF
1213   for pthread_lib in $PTHREADLIBS_LIST; do
1214     if $cc $ARCH_CFLAGS -o $TMPE $TMPC $pthread_lib 2> /dev/null > /dev/null ; then
1215       pthread=yes
1216       PTHREADLIBS="$pthread_lib"
1217       break
1218     fi
1219   done
1220 fi
1221
1222 if test "$pthread" = no; then
1223    aio=no
1224    io_thread=no
1225 fi
1226
1227 ##########################################
1228 # iovec probe
1229 cat > $TMPC <<EOF
1230 #include <sys/types.h>
1231 #include <sys/uio.h>
1232 #include <unistd.h>
1233 int main(void) { struct iovec iov; return 0; }
1234 EOF
1235 iovec=no
1236 if $cc $ARCH_CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
1237   iovec=yes
1238 fi
1239
1240 ##########################################
1241 # preadv probe
1242 cat > $TMPC <<EOF
1243 #include <sys/types.h>
1244 #include <sys/uio.h>
1245 #include <unistd.h>
1246 int main(void) { preadv; }
1247 EOF
1248 preadv=no
1249 if $cc $ARCH_CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
1250   preadv=yes
1251 fi
1252
1253 ##########################################
1254 # fdt probe
1255 if test "$fdt" = "yes" ; then
1256   fdt=no
1257   fdt_libs="-lfdt"
1258   cat > $TMPC << EOF
1259 int main(void) { return 0; }
1260 EOF
1261   if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $TMPC $fdt_libs 2> /dev/null > /dev/null ; then
1262     fdt=yes
1263   fi
1264 fi
1265
1266 #
1267 # Check for xxxat() functions when we are building linux-user
1268 # emulator.  This is done because older glibc versions don't
1269 # have syscall stubs for these implemented.
1270 #
1271 atfile=no
1272 cat > $TMPC << EOF
1273 #define _ATFILE_SOURCE
1274 #include <sys/types.h>
1275 #include <fcntl.h>
1276 #include <unistd.h>
1277
1278 int
1279 main(void)
1280 {
1281         /* try to unlink nonexisting file */
1282         return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
1283 }
1284 EOF
1285 if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null > /dev/null ; then
1286   atfile=yes
1287 fi
1288
1289 # Check for inotify functions when we are building linux-user
1290 # emulator.  This is done because older glibc versions don't
1291 # have syscall stubs for these implemented.  In that case we
1292 # don't provide them even if kernel supports them.
1293 #
1294 inotify=no
1295 cat > $TMPC << EOF
1296 #include <sys/inotify.h>
1297
1298 int
1299 main(void)
1300 {
1301         /* try to start inotify */
1302         return inotify_init();
1303 }
1304 EOF
1305 if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null > /dev/null ; then
1306   inotify=yes
1307 fi
1308
1309 # check if utimensat and futimens are supported
1310 utimens=no
1311 cat > $TMPC << EOF
1312 #define _ATFILE_SOURCE
1313 #define _GNU_SOURCE
1314 #include <stddef.h>
1315 #include <fcntl.h>
1316
1317 int main(void)
1318 {
1319     utimensat(AT_FDCWD, "foo", NULL, 0);
1320     futimens(0, NULL);
1321     return 0;
1322 }
1323 EOF
1324 if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
1325   utimens=yes
1326 fi
1327
1328 # check if pipe2 is there
1329 pipe2=no
1330 cat > $TMPC << EOF
1331 #define _GNU_SOURCE
1332 #include <unistd.h>
1333 #include <fcntl.h>
1334
1335 int main(void)
1336 {
1337     int pipefd[2];
1338     pipe2(pipefd, O_CLOEXEC);
1339     return 0;
1340 }
1341 EOF
1342 if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
1343   pipe2=yes
1344 fi
1345
1346 # check if tee/splice is there. vmsplice was added same time.
1347 splice=no
1348 cat > $TMPC << EOF
1349 #define _GNU_SOURCE
1350 #include <unistd.h>
1351 #include <fcntl.h>
1352 #include <limits.h>
1353
1354 int main(void)
1355 {
1356     int len, fd;
1357     len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
1358     splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
1359     return 0;
1360 }
1361 EOF
1362 if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
1363   splice=yes
1364 fi
1365
1366 # Check if tools are available to build documentation.
1367 if test "$build_docs" = "yes" -a \( ! -x "`which texi2html 2>/dev/null`" -o ! -x "`which pod2man 2>/dev/null`" \) ; then
1368   build_docs="no"
1369 fi
1370
1371 ##########################################
1372 # Do we need librt
1373 CLOCKLIBS=""
1374 cat > $TMPC <<EOF
1375 #include <signal.h>
1376 #include <time.h>
1377 int main(void) { clockid_t id; return clock_gettime(id, NULL); }
1378 EOF
1379
1380 rt=no
1381 if $cc $ARCH_CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
1382   :
1383 elif $cc $ARCH_CFLAGS -o $TMPE $TMPC -lrt > /dev/null 2> /dev/null ; then
1384   rt=yes
1385 fi
1386
1387 if test "$rt" = "yes" ; then
1388   CLOCKLIBS="-lrt"
1389 fi
1390
1391 if test "$mingw32" = "yes" ; then
1392   if test -z "$prefix" ; then
1393       prefix="c:/Program Files/Qemu"
1394   fi
1395   mansuffix=""
1396   datasuffix=""
1397   docsuffix=""
1398   binsuffix=""
1399 else
1400   if test -z "$prefix" ; then
1401       prefix="/usr/local"
1402   fi
1403   mansuffix="/share/man"
1404   datasuffix="/share/qemu"
1405   docsuffix="/share/doc/qemu"
1406   binsuffix="/bin"
1407 fi
1408
1409 echo "Install prefix    $prefix"
1410 echo "BIOS directory    $prefix$datasuffix"
1411 echo "binary directory  $prefix$binsuffix"
1412 if test "$mingw32" = "no" ; then
1413 echo "Manual directory  $prefix$mansuffix"
1414 echo "ELF interp prefix $interp_prefix"
1415 fi
1416 echo "Source path       $source_path"
1417 echo "C compiler        $cc"
1418 echo "Host C compiler   $host_cc"
1419 echo "ARCH_CFLAGS       $ARCH_CFLAGS"
1420 echo "make              $make"
1421 echo "install           $install"
1422 echo "host CPU          $cpu"
1423 echo "host big endian   $bigendian"
1424 echo "target list       $target_list"
1425 echo "tcg debug enabled $debug_tcg"
1426 echo "gprof enabled     $gprof"
1427 echo "sparse enabled    $sparse"
1428 echo "strip binaries    $strip_opt"
1429 echo "profiler          $profiler"
1430 echo "static build      $static"
1431 echo "-Werror enabled   $werror"
1432 if test "$darwin" = "yes" ; then
1433     echo "Cocoa support     $cocoa"
1434 fi
1435 echo "SDL support       $sdl"
1436 echo "curses support    $curses"
1437 echo "curl support      $curl"
1438 echo "mingw32 support   $mingw32"
1439 echo "Audio drivers     $audio_drv_list"
1440 echo "Extra audio cards $audio_card_list"
1441 echo "Mixer emulation   $mixemu"
1442 echo "VNC TLS support   $vnc_tls"
1443 if test "$vnc_tls" = "yes" ; then
1444     echo "    TLS CFLAGS    $vnc_tls_cflags"
1445     echo "    TLS LIBS      $vnc_tls_libs"
1446 fi
1447 echo "VNC SASL support  $vnc_sasl"
1448 if test "$vnc_sasl" = "yes" ; then
1449     echo "    SASL CFLAGS    $vnc_sasl_cflags"
1450     echo "    SASL LIBS      $vnc_sasl_libs"
1451 fi
1452 if test -n "$sparc_cpu"; then
1453     echo "Target Sparc Arch $sparc_cpu"
1454 fi
1455 echo "kqemu support     $kqemu"
1456 echo "xen support       $xen"
1457 echo "brlapi support    $brlapi"
1458 echo "Documentation     $build_docs"
1459 [ ! -z "$uname_release" ] && \
1460 echo "uname -r          $uname_release"
1461 echo "NPTL support      $nptl"
1462 echo "GUEST_BASE        $guest_base"
1463 echo "vde support       $vde"
1464 echo "AIO support       $aio"
1465 echo "IO thread         $io_thread"
1466 echo "Install blobs     $blobs"
1467 echo -e "KVM support       $kvm"
1468 echo "fdt support       $fdt"
1469 echo "preadv support    $preadv"
1470
1471 if test $sdl_too_old = "yes"; then
1472 echo "-> Your SDL version is too old - please upgrade to have SDL support"
1473 fi
1474
1475 config_host_mak="config-host.mak"
1476 config_host_h="config-host.h"
1477 config_host_ld="config-host.ld"
1478
1479 #echo "Creating $config_host_mak and $config_host_h"
1480
1481 test -f $config_host_h && mv $config_host_h ${config_host_h}~
1482
1483 echo "# Automatically generated by configure - do not modify" > $config_host_mak
1484 printf "# Configured with:" >> $config_host_mak
1485 printf " '%s'" "$0" "$@" >> $config_host_mak
1486 echo >> $config_host_mak
1487
1488 echo "CONFIG_QEMU_SHAREDIR=\"$prefix$datasuffix\"" >> $config_host_mak
1489
1490 case "$cpu" in
1491   i386|x86_64|alpha|cris|hppa|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|s390|sparc|sparc64)
1492     ARCH=$cpu
1493   ;;
1494   armv4b|armv4l)
1495     ARCH=arm
1496   ;;
1497   *)
1498     echo "Unsupported CPU = $cpu"
1499     exit 1
1500   ;;
1501 esac
1502 echo "ARCH=$ARCH" >> $config_host_mak
1503 if test "$debug_tcg" = "yes" ; then
1504   echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
1505 fi
1506 if test "$debug" = "yes" ; then
1507   echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
1508 fi
1509 if test "$strip_opt" = "yes" ; then
1510   echo "STRIP_OPT=-s" >> $config_host_mak
1511 fi
1512 if test "$bigendian" = "yes" ; then
1513   echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
1514 fi
1515 echo "HOST_LONG_BITS=$hostlongbits" >> $config_host_mak
1516 if test "$mingw32" = "yes" ; then
1517   echo "CONFIG_WIN32=y" >> $config_host_mak
1518 else
1519   echo "CONFIG_POSIX=y" >> $config_host_mak
1520   cat > $TMPC << EOF
1521 #include <byteswap.h>
1522 int main(void) { return bswap_32(0); }
1523 EOF
1524   if $cc $ARCH_CFLAGS -o $TMPE $TMPC >/dev/null 2> /dev/null ; then
1525     echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
1526   fi
1527   cat > $TMPC << EOF
1528 #include <sys/endian.h>
1529 #include <sys/types.h>
1530 #include <machine/bswap.h>
1531 int main(void) { return bswap32(0); }
1532 EOF
1533   if $cc $ARCH_CFLAGS -o $TMPE $TMPC >/dev/null 2> /dev/null ; then
1534     echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
1535   fi
1536 fi
1537
1538 if test "$darwin" = "yes" ; then
1539   echo "CONFIG_DARWIN=y" >> $config_host_mak
1540 fi
1541
1542 if test "$aix" = "yes" ; then
1543   echo "CONFIG_AIX=y" >> $config_host_mak
1544 fi
1545
1546 if test "$solaris" = "yes" ; then
1547   echo "CONFIG_SOLARIS=y" >> $config_host_mak
1548   echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
1549   if test "$needs_libsunmath" = "yes" ; then
1550     echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
1551   fi
1552 fi
1553 if test -n "$sparc_cpu"; then
1554   echo "CONFIG__sparc_${sparc_cpu}__=y" >> $config_host_mak
1555 fi
1556 if test "$gprof" = "yes" ; then
1557   echo "TARGET_GPROF=yes" >> $config_host_mak
1558 fi
1559 if test "$static" = "yes" ; then
1560   echo "CONFIG_STATIC=y" >> $config_host_mak
1561   LDFLAGS="$LDFLAGS -static"
1562 fi
1563 if test $profiler = "yes" ; then
1564   echo "CONFIG_PROFILER=y" >> $config_host_mak
1565 fi
1566 if test "$slirp" = "yes" ; then
1567   echo "CONFIG_SLIRP=y" >> $config_host_mak
1568 fi
1569 if test "$vde" = "yes" ; then
1570   echo "CONFIG_VDE=y" >> $config_host_mak
1571   echo "VDE_LIBS=$vde_libs" >> $config_host_mak
1572 fi
1573 for card in $audio_card_list; do
1574     def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
1575     echo "$def=y" >> $config_host_mak
1576 done
1577 echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
1578 for drv in $audio_drv_list; do
1579     def=CONFIG_`echo $drv | tr '[:lower:]' '[:upper:]'`
1580     echo "$def=y" >> $config_host_mak
1581     if test "$drv" = "fmod"; then
1582         echo "FMOD_LIBS=$fmod_lib" >> $config_host_mak
1583         echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
1584     elif test "$drv" = "oss"; then
1585         echo "OSS_LIBS=$oss_lib" >> $config_host_mak
1586     fi
1587 done
1588 if test "$mixemu" = "yes" ; then
1589   echo "CONFIG_MIXEMU=y" >> $config_host_mak
1590 fi
1591 if test "$vnc_tls" = "yes" ; then
1592   echo "CONFIG_VNC_TLS=y" >> $config_host_mak
1593   echo "VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_host_mak
1594   echo "VNC_TLS_LIBS=$vnc_tls_libs" >> $config_host_mak
1595 fi
1596 if test "$vnc_sasl" = "yes" ; then
1597   echo "CONFIG_VNC_SASL=y" >> $config_host_mak
1598   echo "VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak
1599   echo "VNC_SASL_LIBS=$vnc_sasl_libs" >> $config_host_mak
1600 fi
1601 if test "$fnmatch" = "yes" ; then
1602   echo "CONFIG_FNMATCH=y" >> $config_host_mak
1603 fi
1604 qemu_version=`head $source_path/VERSION`
1605 echo "VERSION=$qemu_version" >>$config_host_mak
1606 echo "PKGVERSION=$pkgversion" >>$config_host_mak
1607 echo "SRC_PATH=$source_path" >> $config_host_mak
1608 if [ "$source_path_used" = "yes" ]; then
1609   echo "VPATH=$source_path" >> $config_host_mak
1610 fi
1611 echo "TARGET_DIRS=$target_list" >> $config_host_mak
1612 if [ "$build_docs" = "yes" ] ; then
1613   echo "BUILD_DOCS=yes" >> $config_host_mak
1614 fi
1615 if test "$sdl" = "yes" ; then
1616   echo "CONFIG_SDL=y" >> $config_host_mak
1617   echo "SDL_LIBS=$sdl_libs" >> $config_host_mak
1618   echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
1619 fi
1620 if test "$cocoa" = "yes" ; then
1621   echo "CONFIG_COCOA=y" >> $config_host_mak
1622 fi
1623 if test "$curses" = "yes" ; then
1624   echo "CONFIG_CURSES=y" >> $config_host_mak
1625   echo "CURSES_LIBS=$curses_libs" >> $config_host_mak
1626 fi
1627 if test "$atfile" = "yes" ; then
1628   echo "CONFIG_ATFILE=y" >> $config_host_mak
1629 fi
1630 if test "$utimens" = "yes" ; then
1631   echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
1632 fi
1633 if test "$pipe2" = "yes" ; then
1634   echo "CONFIG_PIPE2=y" >> $config_host_mak
1635 fi
1636 if test "$splice" = "yes" ; then
1637   echo "CONFIG_SPLICE=y" >> $config_host_mak
1638 fi
1639 if test "$inotify" = "yes" ; then
1640   echo "CONFIG_INOTIFY=y" >> $config_host_mak
1641 fi
1642 if test "$curl" = "yes" ; then
1643   echo "CONFIG_CURL=y" >> $config_host_mak
1644   echo "CURL_LIBS=$curl_libs" >> $config_host_mak
1645 fi
1646 if test "$brlapi" = "yes" ; then
1647   echo "CONFIG_BRLAPI=y" >> $config_host_mak
1648   echo "BRLAPI_LIBS=$brlapi_libs" >> $config_host_mak
1649 fi
1650 if test "$bluez" = "yes" ; then
1651   echo "CONFIG_BLUEZ=y" >> $config_host_mak
1652   echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
1653   echo "BLUEZ_LIBS=$bluez_libs" >> $config_host_mak
1654 fi
1655 if test "$xen" = "yes" ; then
1656   echo "CONFIG_XEN=y" >> $config_host_mak
1657   echo "XEN_LIBS=$xen_libs" >> $config_host_mak
1658 fi
1659 if test "$aio" = "yes" ; then
1660   echo "CONFIG_AIO=y" >> $config_host_mak
1661 fi
1662 if test "$io_thread" = "yes" ; then
1663   echo "CONFIG_IOTHREAD=y" >> $config_host_mak
1664 fi
1665 if test "$blobs" = "yes" ; then
1666   echo "INSTALL_BLOBS=yes" >> $config_host_mak
1667 fi
1668 if test "$iovec" = "yes" ; then
1669   echo "CONFIG_IOVEC=y" >> $config_host_mak
1670 fi
1671 if test "$preadv" = "yes" ; then
1672   echo "CONFIG_PREADV=y" >> $config_host_mak
1673 fi
1674 if test "$fdt" = "yes" ; then
1675   echo "CONFIG_FDT=y" >> $config_host_mak
1676   echo "FDT_LIBS=$fdt_libs" >> $config_host_mak
1677 fi
1678
1679 # XXX: suppress that
1680 if [ "$bsd" = "yes" ] ; then
1681   echo "CONFIG_BSD=y" >> $config_host_mak
1682 fi
1683
1684 echo "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
1685
1686 # USB host support
1687 case "$usb" in
1688 linux)
1689   echo "HOST_USB=linux" >> $config_host_mak
1690 ;;
1691 bsd)
1692   echo "HOST_USB=bsd" >> $config_host_mak
1693 ;;
1694 *)
1695   echo "HOST_USB=stub" >> $config_host_mak
1696 ;;
1697 esac
1698
1699 # Determine what linker flags to use to force archive inclusion
1700 check_linker_flags()
1701 {
1702     w2=
1703     if test "$2" ; then
1704         w2=-Wl,$2
1705     fi
1706     $cc $ARCH_CFLAGS -o $TMPE $OS_CFLAGS $TMPC -Wl,$1 ${w2} >/dev/null 2>/dev/null
1707 }
1708
1709 cat > $TMPC << EOF
1710 int main(void) { }
1711 EOF
1712 if check_linker_flags --whole-archive --no-whole-archive ; then
1713     # GNU ld
1714     echo "ARLIBS_BEGIN=-Wl,--whole-archive" >> $config_host_mak
1715     echo "ARLIBS_END=-Wl,--no-whole-archive" >> $config_host_mak
1716 elif check_linker_flags -z,allextract -z,defaultextract ; then
1717     # Solaris ld
1718     echo "ARLIBS_BEGIN=-Wl,-z,allextract" >> $config_host_mak
1719     echo "ARLIBS_END=-Wl,-z,defaultextract" >> $config_host_mak
1720 elif check_linker_flags -all_load ; then
1721     # Mac OS X
1722     echo "ARLIBS_BEGIN=-all_load" >> $config_host_mak
1723     echo "ARLIBS_END=" >> $config_host_mak
1724 else
1725     echo "Error: your linker does not support --whole-archive or -z."
1726     echo "Please report to qemu-devel@nongnu.org"
1727     exit 1
1728 fi
1729
1730 tools=
1731 if test `expr "$target_list" : ".*softmmu.*"` != 0 ; then
1732   tools="qemu-img\$(EXESUF) $tools"
1733   if [ "$linux" = "yes" ] ; then
1734       tools="qemu-nbd\$(EXESUF) qemu-io\$(EXESUF) $tools"
1735   fi
1736 fi
1737 echo "TOOLS=$tools" >> $config_host_mak
1738
1739 # Mac OS X ships with a broken assembler
1740 roms=
1741 if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
1742         "$targetos" != "Darwin" ; then
1743   roms="optionrom"
1744 fi
1745 echo "ROMS=$roms" >> $config_host_mak
1746
1747 echo "prefix=$prefix" >> $config_host_mak
1748 echo "bindir=\${prefix}$binsuffix" >> $config_host_mak
1749 echo "mandir=\${prefix}$mansuffix" >> $config_host_mak
1750 echo "datadir=\${prefix}$datasuffix" >> $config_host_mak
1751 echo "docdir=\${prefix}$docsuffix" >> $config_host_mak
1752 echo "MAKE=$make" >> $config_host_mak
1753 echo "INSTALL=$install" >> $config_host_mak
1754 echo "INSTALL_DIR=$install -d -m0755 -p" >> $config_host_mak
1755 echo "INSTALL_DATA=$install -m0644 -p" >> $config_host_mak
1756 echo "INSTALL_PROG=$install -m0755 -p" >> $config_host_mak
1757 echo "CC=$cc" >> $config_host_mak
1758 echo "HOST_CC=$host_cc" >> $config_host_mak
1759 if test "$sparse" = "yes" ; then
1760   echo "CC      := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
1761   echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
1762   echo "CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
1763 fi
1764 echo "AR=$ar" >> $config_host_mak
1765 echo "OBJCOPY=$objcopy" >> $config_host_mak
1766 echo "LD=$ld" >> $config_host_mak
1767 echo "CFLAGS=$CFLAGS $OS_CFLAGS $ARCH_CFLAGS $EXTRA_CFLAGS" >> $config_host_mak
1768 echo "LDFLAGS=$LDFLAGS $OS_LDFLAGS $ARCH_LDFLAGS $EXTRA_LDFLAGS" >> $config_host_mak
1769 echo "EXESUF=$EXESUF" >> $config_host_mak
1770 echo "PTHREADLIBS=$PTHREADLIBS" >> $config_host_mak
1771 echo "CLOCKLIBS=$CLOCKLIBS" >> $config_host_mak
1772
1773 echo "/* Automatically generated by configure - do not modify */" > $config_host_h
1774
1775 $SHELL $source_path/create_config < $config_host_mak >> $config_host_h
1776
1777 if test -f ${config_host_h}~ ; then
1778   if cmp -s $config_host_h ${config_host_h}~ ; then
1779     mv ${config_host_h}~ $config_host_h
1780   else
1781     rm ${config_host_h}~
1782   fi
1783 fi
1784
1785 # generate list of library paths for linker script
1786
1787 $ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
1788
1789 if test -f ${config_host_ld}~ ; then
1790   if cmp -s $config_host_ld ${config_host_ld}~ ; then
1791     mv ${config_host_ld}~ $config_host_ld
1792   else
1793     rm ${config_host_ld}~
1794   fi
1795 fi
1796
1797 for target in $target_list; do
1798 target_dir="$target"
1799 config_mak=$target_dir/config.mak
1800 config_h=$target_dir/config.h
1801 target_arch2=`echo $target | cut -d '-' -f 1`
1802 target_bigendian="no"
1803 case "$target_arch2" in
1804   armeb|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|sh4eb|sparc|sparc64|sparc32plus)
1805   target_bigendian=yes
1806   ;;
1807 esac
1808 target_softmmu="no"
1809 target_user_only="no"
1810 target_linux_user="no"
1811 target_darwin_user="no"
1812 target_bsd_user="no"
1813 case "$target" in
1814   ${target_arch2}-softmmu)
1815     target_softmmu="yes"
1816     ;;
1817   ${target_arch2}-linux-user)
1818     target_user_only="yes"
1819     target_linux_user="yes"
1820     ;;
1821   ${target_arch2}-darwin-user)
1822     target_user_only="yes"
1823     target_darwin_user="yes"
1824     ;;
1825   ${target_arch2}-bsd-user)
1826     target_user_only="yes"
1827     target_bsd_user="yes"
1828     ;;
1829   *)
1830     echo "ERROR: Target '$target' not recognised"
1831     exit 1
1832     ;;
1833 esac
1834
1835 #echo "Creating $config_mak, $config_h and $target_dir/Makefile"
1836
1837 test -f $config_h && mv $config_h ${config_h}~
1838
1839 mkdir -p $target_dir
1840 mkdir -p $target_dir/fpu
1841 mkdir -p $target_dir/tcg
1842 if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
1843   mkdir -p $target_dir/nwfpe
1844 fi
1845
1846 #
1847 # don't use ln -sf as not all "ln -sf" over write the file/link
1848 #
1849 rm -f $target_dir/Makefile
1850 ln -s $source_path/Makefile.target $target_dir/Makefile
1851
1852
1853 echo "# Automatically generated by configure - do not modify" > $config_mak
1854
1855 echo "include ../config-host.mak" >> $config_mak
1856
1857 bflt="no"
1858 elfload32="no"
1859 target_nptl="no"
1860 interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
1861 echo "CONFIG_QEMU_PREFIX=\"$interp_prefix1\"" >> $config_mak
1862 gdb_xml_files=""
1863
1864 TARGET_ARCH="$target_arch2"
1865 TARGET_BASE_ARCH=""
1866 TARGET_ABI_DIR=""
1867
1868 case "$target_arch2" in
1869   i386)
1870     target_phys_bits=32
1871   ;;
1872   x86_64)
1873     TARGET_BASE_ARCH=i386
1874     target_phys_bits=64
1875   ;;
1876   alpha)
1877     target_phys_bits=64
1878   ;;
1879   arm|armeb)
1880     TARGET_ARCH=arm
1881     bflt="yes"
1882     target_nptl="yes"
1883     gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
1884     target_phys_bits=32
1885   ;;
1886   cris)
1887     target_nptl="yes"
1888     target_phys_bits=32
1889   ;;
1890   m68k)
1891     bflt="yes"
1892     gdb_xml_files="cf-core.xml cf-fp.xml"
1893     target_phys_bits=32
1894   ;;
1895   microblaze)
1896     bflt="yes"
1897     target_nptl="yes"
1898     target_phys_bits=32
1899   ;;
1900   mips|mipsel)
1901     TARGET_ARCH=mips
1902     echo "TARGET_ABI_MIPSO32=y" >> $config_mak
1903     target_nptl="yes"
1904     target_phys_bits=64
1905   ;;
1906   mipsn32|mipsn32el)
1907     TARGET_ARCH=mipsn32
1908     TARGET_BASE_ARCH=mips
1909     echo "TARGET_ABI_MIPSN32=y" >> $config_mak
1910     target_phys_bits=64
1911   ;;
1912   mips64|mips64el)
1913     TARGET_ARCH=mips64
1914     TARGET_BASE_ARCH=mips
1915     echo "TARGET_ABI_MIPSN64=y" >> $config_mak
1916     target_phys_bits=64
1917   ;;
1918   ppc)
1919     gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
1920     target_phys_bits=32
1921     target_nptl="yes"
1922   ;;
1923   ppcemb)
1924     TARGET_BASE_ARCH=ppc
1925     TARGET_ABI_DIR=ppc
1926     gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
1927     target_phys_bits=64
1928     target_nptl="yes"
1929   ;;
1930   ppc64)
1931     TARGET_BASE_ARCH=ppc
1932     TARGET_ABI_DIR=ppc
1933     gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
1934     target_phys_bits=64
1935   ;;
1936   ppc64abi32)
1937     TARGET_ARCH=ppc64
1938     TARGET_BASE_ARCH=ppc
1939     TARGET_ABI_DIR=ppc
1940     echo "TARGET_ABI32=y" >> $config_mak
1941     gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
1942     target_phys_bits=64
1943   ;;
1944   sh4|sh4eb)
1945     TARGET_ARCH=sh4
1946     bflt="yes"
1947     target_nptl="yes"
1948     target_phys_bits=32
1949   ;;
1950   sparc)
1951     target_phys_bits=64
1952   ;;
1953   sparc64)
1954     TARGET_BASE_ARCH=sparc
1955     elfload32="yes"
1956     target_phys_bits=64
1957   ;;
1958   sparc32plus)
1959     TARGET_ARCH=sparc64
1960     TARGET_BASE_ARCH=sparc
1961     TARGET_ABI_DIR=sparc
1962     echo "TARGET_ABI32=y" >> $config_mak
1963     target_phys_bits=64
1964   ;;
1965   *)
1966     echo "Unsupported target CPU"
1967     exit 1
1968   ;;
1969 esac
1970 echo "TARGET_ARCH=$TARGET_ARCH" >> $config_mak
1971 echo "TARGET_ARCH2=$target_arch2" >> $config_mak
1972 # TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
1973 if [ "$TARGET_BASE_ARCH" = "" ]; then
1974   TARGET_BASE_ARCH=$TARGET_ARCH
1975 fi
1976 echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_mak
1977 if [ "$TARGET_ABI_DIR" = "" ]; then
1978   TARGET_ABI_DIR=$TARGET_ARCH
1979 fi
1980 echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_mak
1981 if [ $target_phys_bits -lt $hostlongbits ] ; then
1982   target_phys_bits=$hostlongbits
1983 fi
1984 case "$target_arch2" in
1985   i386|x86_64)
1986     if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
1987       echo "CONFIG_XEN=y" >> $config_mak
1988     fi
1989     if test $kqemu = "yes" -a "$target_softmmu" = "yes"
1990     then
1991       echo "CONFIG_KQEMU=y" >> $config_mak
1992     fi
1993 esac
1994 case "$target_arch2" in
1995   i386|x86_64|ppcemb|ppc|ppc64)
1996     # Make sure the target and host cpus are compatible
1997     if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
1998       \( "$target_arch2" = "$cpu" -o \
1999       \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
2000       \( "$target_arch2" = "ppc64"  -a "$cpu" = "ppc" \) -o \
2001       \( "$target_arch2" = "x86_64" -a "$cpu" = "i386"   \) -o \
2002       \( "$target_arch2" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
2003       echo "CONFIG_KVM=y" >> $config_mak
2004       echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak
2005     fi
2006 esac
2007 echo "HWLIB=../libhw$target_phys_bits/libqemuhw$target_phys_bits.a" >> $config_mak
2008 echo "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_mak
2009 echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
2010 if test "$target_bigendian" = "yes" ; then
2011   echo "TARGET_WORDS_BIGENDIAN=y" >> $config_mak
2012 fi
2013 if test "$target_softmmu" = "yes" ; then
2014   echo "CONFIG_SOFTMMU=y" >> $config_mak
2015 fi
2016 if test "$target_user_only" = "yes" ; then
2017   echo "CONFIG_USER_ONLY=y" >> $config_mak
2018 fi
2019 if test "$target_linux_user" = "yes" ; then
2020   echo "CONFIG_LINUX_USER=y" >> $config_mak
2021 fi
2022 if test "$target_darwin_user" = "yes" ; then
2023   echo "CONFIG_DARWIN_USER=y" >> $config_mak
2024 fi
2025 list=""
2026 if test ! -z "$gdb_xml_files" ; then
2027   for x in $gdb_xml_files; do
2028     list="$list $source_path/gdb-xml/$x"
2029   done
2030 fi
2031 echo "TARGET_XML_FILES=$list" >> $config_mak
2032
2033 case "$target_arch2" in
2034   arm|armeb|m68k|microblaze|mips|mipsel|mipsn32|mipsn32el|mips64|mips64el|ppc|ppc64|ppc64abi32|ppcemb|sparc|sparc64|sparc32plus)
2035     echo "CONFIG_SOFTFLOAT=y" >> $config_mak
2036     ;;
2037 esac
2038
2039 if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
2040   echo "TARGET_HAS_BFLT=y" >> $config_mak
2041 fi
2042 if test "$target_user_only" = "yes" \
2043         -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
2044   echo "CONFIG_USE_NPTL=y" >> $config_mak
2045 fi
2046 # 32 bit ELF loader in addition to native 64 bit loader?
2047 if test "$target_user_only" = "yes" -a "$elfload32" = "yes"; then
2048   echo "TARGET_HAS_ELFLOAD32=y" >> $config_mak
2049 fi
2050 if test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
2051   echo "CONFIG_USE_GUEST_BASE=y" >> $config_mak
2052 fi
2053 if test "$target_bsd_user" = "yes" ; then
2054   echo "CONFIG_BSD_USER=y" >> $config_mak
2055 fi
2056
2057 # generate LDFLAGS for targets
2058
2059 ldflags=""
2060 if test "$target_linux_user" = "yes" -o "$target_linux_user" = "yes" ; then
2061   case "$ARCH" in
2062   i386)
2063     if test "$gprof" = "yes" -o "$static" = "yes" ; then
2064       ldflags='-Wl,-T../config-host.ld -Wl,-T,$(SRC_PATH)/$(ARCH).ld'
2065     else
2066       # WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
2067       # that the kernel ELF loader considers as an executable. I think this
2068       # is the simplest way to make it self virtualizable!
2069       ldflags='-Wl,-shared'
2070     fi
2071     ;;
2072   sparc)
2073     # -static is used to avoid g1/g3 usage by the dynamic linker
2074     ldflags='-Wl,-T../config-host.ld -Wl,-T,$(SRC_PATH)/$(ARCH).ld -static'
2075     ;;
2076   ia64)
2077     ldflags='-Wl,-G0 -Wl,-T../config-host.ld -Wl,-T,$(SRC_PATH)/$(ARCH).ld -static'
2078     ;;
2079   x86_64|ppc|ppc64|s390|sparc64|alpha|arm|m68k|mips|mips64)
2080     ldflags='-Wl,-T../config-host.ld -Wl,-T,$(SRC_PATH)/$(ARCH).ld'
2081     ;;
2082   esac
2083 fi
2084 if test "$target_softmmu" = "yes" ; then
2085   case "$ARCH" in
2086   ia64)
2087     ldflags='-Wl,-G0 -Wl,-T../config-host.ld -Wl,-T,$(SRC_PATH)/$(ARCH).ld -static'
2088     ;;
2089   esac
2090 fi
2091
2092 if test "$ldflags" != "" ; then
2093   echo "LDFLAGS+=$ldflags" >> $config_mak
2094 fi
2095
2096 echo "/* Automatically generated by configure - do not modify */" > $config_h
2097 echo "#include \"../config-host.h\"" >> $config_h
2098
2099 $SHELL $source_path/create_config < $config_mak >> $config_h
2100
2101 if test -f ${config_h}~ ; then
2102   if cmp -s $config_h ${config_h}~ ; then
2103     mv ${config_h}~ $config_h
2104   else
2105     rm ${config_h}~
2106   fi
2107 fi
2108
2109 done # for target in $targets
2110
2111 # build tree in object directory if source path is different from current one
2112 if test "$source_path_used" = "yes" ; then
2113     DIRS="tests tests/cris slirp audio block pc-bios/optionrom"
2114     FILES="Makefile tests/Makefile"
2115     FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
2116     FILES="$FILES tests/test-mmap.c"
2117     FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps pc-bios/video.x"
2118     for bios_file in $source_path/pc-bios/*.bin $source_path/pc-bios/*.dtb $source_path/pc-bios/openbios-*; do
2119         FILES="$FILES pc-bios/`basename $bios_file`"
2120     done
2121     for dir in $DIRS ; do
2122             mkdir -p $dir
2123     done
2124     # remove the link and recreate it, as not all "ln -sf" overwrite the link
2125     for f in $FILES ; do
2126         rm -f $f
2127         ln -s $source_path/$f $f
2128     done
2129 fi
2130
2131 for hwlib in 32 64; do
2132   d=libhw$hwlib
2133   mkdir -p $d
2134   rm -f $d/Makefile
2135   ln -s $source_path/Makefile.hw $d/Makefile
2136   echo "HWLIB=libqemuhw$hwlib.a" > $d/config.mak
2137   echo "CPPFLAGS=-DTARGET_PHYS_ADDR_BITS=$hwlib" >> $d/config.mak
2138 done