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