Display SDL configuration error, idea by Ben Taylor.
[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
19 # default parameters
20 prefix=""
21 interp_prefix="/usr/gnemul/qemu-%M"
22 static="no"
23 cross_prefix=""
24 cc="gcc"
25 gcc3_search="yes"
26 gcc3_list="gcc-3.4 gcc34 gcc-3.3 gcc33 gcc-3.2 gcc32"
27 host_cc="gcc"
28 ar="ar"
29 make="make"
30 install="install"
31 strip="strip"
32 cpu=`uname -m`
33 target_list=""
34 case "$cpu" in
35   i386|i486|i586|i686|i86pc|BePC)
36     cpu="i386"
37   ;;
38   armv*b)
39     cpu="armv4b"
40   ;;
41   armv*l)
42     cpu="armv4l"
43   ;;
44   alpha)
45     cpu="alpha"
46   ;;
47   "Power Macintosh"|ppc|ppc64)
48     cpu="powerpc"
49   ;;
50   mips)
51     cpu="mips"
52   ;;
53   mips64)
54     cpu="mips64"
55   ;;
56   s390)
57     cpu="s390"
58   ;;
59   sparc|sun4[cdmuv])
60     cpu="sparc"
61   ;;
62   sparc64)
63     cpu="sparc64"
64   ;;
65   ia64)
66     cpu="ia64"
67   ;;
68   m68k)
69     cpu="m68k"
70   ;;
71   x86_64|amd64)
72     cpu="x86_64"
73   ;;
74   *)
75     cpu="unknown"
76   ;;
77 esac
78 gprof="no"
79 bigendian="no"
80 mingw32="no"
81 EXESUF=""
82 gdbstub="yes"
83 slirp="yes"
84 adlib="no"
85 oss="no"
86 dsound="no"
87 coreaudio="no"
88 alsa="no"
89 fmod="no"
90 fmod_lib=""
91 fmod_inc=""
92 bsd="no"
93 linux="no"
94 kqemu="no"
95 profiler="no"
96 cocoa="no"
97 check_gfx="yes"
98 check_gcc="yes"
99 softmmu="yes"
100 linux_user="no"
101 darwin_user="no"
102 build_docs="no"
103 uname_release=""
104
105 # OS specific
106 targetos=`uname -s`
107 case $targetos in
108 CYGWIN*)
109 mingw32="yes"
110 OS_CFLAGS="-mno-cygwin"
111 ;;
112 MINGW32*)
113 mingw32="yes"
114 ;;
115 GNU/kFreeBSD)
116 oss="yes"
117 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
118     kqemu="yes"
119 fi
120 ;;
121 FreeBSD)
122 bsd="yes"
123 oss="yes"
124 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
125     kqemu="yes"
126 fi
127 ;;
128 NetBSD)
129 bsd="yes"
130 oss="yes"
131 ;;
132 OpenBSD)
133 bsd="yes"
134 oss="yes"
135 ;;
136 Darwin)
137 bsd="yes"
138 darwin="yes"
139 darwin_user="yes"
140 cocoa="yes"
141 coreaudio="yes"
142 OS_CFLAGS="-mdynamic-no-pic"
143 ;;
144 SunOS)
145     solaris="yes"
146     make="gmake"
147     install="ginstall"
148     needs_libsunmath="no"
149     solarisrev=`uname -r | cut -f2 -d.`
150     if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
151         if test "$solarisrev" -le 9 ; then
152             if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
153                 needs_libsunmath="yes"
154             else
155                 echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
156                 echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
157                 echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
158                 echo "Studio 11 can be downloaded from www.sun.com."
159                 exit 1
160             fi
161         fi
162         if test "$solarisrev" -ge 9 ; then
163             kqemu="yes"
164         fi
165     fi
166     if test -f /usr/include/sys/soundcard.h ; then
167         oss=yes
168     fi
169 ;;
170 *)
171 oss="yes"
172 linux="yes"
173 linux_user="yes"
174 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
175     kqemu="yes"
176 fi
177 ;;
178 esac
179
180 if [ "$bsd" = "yes" ] ; then
181   if [ "$darwin" != "yes" ] ; then
182     make="gmake"
183   fi
184 fi
185
186 # find source path
187 source_path=`dirname "$0"`
188 if [ -z "$source_path" ]; then
189     source_path=`pwd`
190 else
191     source_path=`cd "$source_path"; pwd`
192 fi
193 if test "$source_path" = `pwd` ; then
194     source_path_used="no"
195 else
196     source_path_used="yes"
197 fi
198
199 for opt do
200   optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
201   case "$opt" in
202   --help|-h) show_help=yes
203   ;;
204   --prefix=*) prefix="$optarg"
205   ;;
206   --interp-prefix=*) interp_prefix="$optarg"
207   ;;
208   --source-path=*) source_path="$optarg"
209   source_path_used="yes"
210   ;;
211   --cross-prefix=*) cross_prefix="$optarg"
212   ;;
213   --cc=*) cc="$optarg"
214   gcc3_search="no"
215   ;;
216   --host-cc=*) host_cc="$optarg"
217   ;;
218   --make=*) make="$optarg"
219   ;;
220   --install=*) install="$optarg"
221   ;;
222   --extra-cflags=*) CFLAGS="$optarg"
223   ;;
224   --extra-ldflags=*) LDFLAGS="$optarg"
225   ;;
226   --cpu=*) cpu="$optarg"
227   ;;
228   --target-list=*) target_list="$optarg"
229   ;;
230   --enable-gprof) gprof="yes"
231   ;;
232   --static) static="yes"
233   ;;
234   --disable-sdl) sdl="no"
235   ;;
236   --enable-coreaudio) coreaudio="yes"
237   ;;
238   --enable-alsa) alsa="yes"
239   ;;
240   --enable-dsound) dsound="yes"
241   ;;
242   --enable-fmod) fmod="yes"
243   ;;
244   --fmod-lib=*) fmod_lib="$optarg"
245   ;;
246   --fmod-inc=*) fmod_inc="$optarg"
247   ;;
248   --enable-mingw32) mingw32="yes" ; cross_prefix="i386-mingw32-" ; linux_user="no"
249   ;;
250   --disable-slirp) slirp="no"
251   ;;
252   --enable-adlib) adlib="yes"
253   ;;
254   --disable-kqemu) kqemu="no"
255   ;;
256   --enable-profiler) profiler="yes"
257   ;;
258   --enable-cocoa) cocoa="yes" ; coreaudio="yes" ; sdl="no"
259   ;;
260   --disable-gfx-check) check_gfx="no"
261   ;;
262   --disable-gcc-check) check_gcc="no"
263   ;;
264   --disable-system) softmmu="no"
265   ;;
266   --enable-system) softmmu="yes"
267   ;;
268   --disable-linux-user) linux_user="no"
269   ;;
270   --enable-linux-user) linux_user="yes"
271   ;;
272   --disable-darwin-user) darwin_user="no"
273   ;;
274   --enable-darwin-user) darwin_user="yes"
275   ;;
276   --enable-uname-release=*) uname_release="$optarg"
277   ;;
278   --sparc_cpu=*)
279       sparc_cpu="$optarg"
280       case $sparc_cpu in
281         v7|v8) SP_CFLAGS="-m32 -mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__"; SP_LDFLAGS="-m32"
282                  target_cpu="sparc"; cpu="sparc" ;;
283         v8plus|v8plusa) SP_CFLAGS="-m32 -mcpu=ultrasparc -D__sparc_${sparc_cpu}__"; SP_LDFLAGS="-m32"
284                  target_cpu="sparc"; cpu="sparc" ;;
285         v9)    SP_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_${sparc_cpu}__"; SP_LDFLAGS="-m64"
286                  target_cpu="sparc64"; cpu="sparc64" ;;
287         *)     echo "undefined SPARC architecture. Exiting";exit 1;;
288       esac
289   ;;
290   esac
291 done
292
293 if [ "$bsd" = "yes" -o "$darwin" = "yes" -o "$mingw32" = "yes" ] ; then
294     AIOLIBS=
295 else
296     AIOLIBS="-lrt"
297 fi
298
299 # default flags for all hosts
300 CFLAGS="$CFLAGS -Wall -O2 -g -fno-strict-aliasing"
301 LDFLAGS="$LDFLAGS -g"
302
303 #
304 # If cpu ~= sparc and  sparc_cpu hasn't been defined, plug in the right
305 # ARCH_CFLAGS/ARCH_LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
306 #
307 case $cpu in
308     sparc) if test -z "$sparc_cpu" ; then
309                ARCH_CFLAGS="-m32 -mcpu=ultrasparc -D__sparc_v8plus__"
310                ARCH_LDFLAGS="-m32"
311            else
312                ARCH_CFLAGS="${SP_CFLAGS}"
313                ARCH_LDFLAGS="${SP_LDFLAGS}"
314            fi
315            ;;
316     sparc64) if test -z "$sparc_cpu" ; then
317                ARCH_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__"
318                ARCH_LDFLAGS="-m64"
319            else
320                ARCH_CFLAGS="${SP_CFLAGS}"
321                ARCH_LDFLAGS="${SP_LDFLAGS}"
322            fi
323            ;;
324 esac
325
326 if test x"$show_help" = x"yes" ; then
327 cat << EOF
328
329 Usage: configure [options]
330 Options: [defaults in brackets after descriptions]
331
332 EOF
333 echo "Standard options:"
334 echo "  --help                   print this message"
335 echo "  --prefix=PREFIX          install in PREFIX [$prefix]"
336 echo "  --interp-prefix=PREFIX   where to find shared libraries, etc."
337 echo "                           use %M for cpu name [$interp_prefix]"
338 echo "  --target-list=LIST       set target list [$target_list]"
339 echo ""
340 echo "kqemu kernel acceleration support:"
341 echo "  --disable-kqemu          disable kqemu support"
342 echo ""
343 echo "Advanced options (experts only):"
344 echo "  --source-path=PATH       path of source code [$source_path]"
345 echo "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
346 echo "  --cc=CC                  use C compiler CC [$cc]"
347 echo "  --host-cc=CC             use C compiler CC [$host_cc] for dyngen etc."
348 echo "  --make=MAKE              use specified make [$make]"
349 echo "  --install=INSTALL        use specified install [$install]"
350 echo "  --static                 enable static build [$static]"
351 echo "  --enable-cocoa           enable COCOA (Mac OS X only)"
352 echo "  --enable-mingw32         enable Win32 cross compilation with mingw32"
353 echo "  --enable-adlib           enable Adlib emulation"
354 echo "  --enable-coreaudio       enable Coreaudio audio driver"
355 echo "  --enable-alsa            enable ALSA audio driver"
356 echo "  --enable-fmod            enable FMOD audio driver"
357 echo "  --enable-dsound          enable DirectSound audio driver"
358 echo "  --enable-system          enable all system emulation targets"
359 echo "  --disable-system         disable all system emulation targets"
360 echo "  --enable-linux-user      enable all linux usermode emulation targets"
361 echo "  --disable-linux-user     disable all linux usermode emulation targets"
362 echo "  --enable-darwin-user     enable all darwin usermode emulation targets"
363 echo "  --disable-darwin-user    disable all darwin usermode emulation targets"
364 echo "  --fmod-lib               path to FMOD library"
365 echo "  --fmod-inc               path to FMOD includes"
366 echo "  --enable-uname-release=R Return R for uname -r in usermode emulation"
367 echo "  --sparc_cpu=V            Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
368 echo ""
369 echo "NOTE: The object files are built at the place where configure is launched"
370 exit 1
371 fi
372
373 cc="${cross_prefix}${cc}"
374 ar="${cross_prefix}${ar}"
375 strip="${cross_prefix}${strip}"
376
377 # check that the C compiler works.
378 cat > $TMPC <<EOF
379 int main(void) {}
380 EOF
381
382 if $cc -c -o $TMPO $TMPC 2> /dev/null ; then
383   : C compiler works ok
384 else
385     echo "ERROR: \"$cc\" either does not exist or does not work"
386     exit 1
387 fi
388
389 if test "$mingw32" = "yes" ; then
390     linux="no"
391     EXESUF=".exe"
392     oss="no"
393     if [ "$cpu" = "i386" ] ; then
394         kqemu="yes"
395     fi
396 fi
397
398 # Check for gcc4, error if pre-gcc4 
399 if test "$check_gcc" = "yes" ; then
400     cat > $TMPC <<EOF
401 #if __GNUC__ < 4
402 #error gcc3
403 #endif
404 int main(){return 0;}
405 EOF
406     if "$cc" -o $TMPE $TMPC 2> /dev/null ; then
407         echo "WARNING: \"$cc\" looks like gcc 4.x"
408         found_compat_cc="no"
409         if test "$gcc3_search" = "yes" ; then
410             echo "Looking for gcc 3.x"
411             for compat_cc in $gcc3_list ; do
412                 if "$cross_prefix$compat_cc" --version > /dev/null 2>&1 ; then
413                     echo "Found \"$compat_cc\""
414                     cc="$cross_prefix$compat_cc"
415                     found_compat_cc="yes"
416                     break
417                 fi
418             done
419             if test "$found_compat_cc" = "no" ; then
420                 echo "gcc 3.x not found!"
421             fi
422         fi
423         if test "$found_compat_cc" = "no" ; then
424             echo "QEMU is known to have problems when compiled with gcc 4.x"
425             echo "It is recommended that you use gcc 3.x to build QEMU"
426             echo "To use this compiler anyway, configure with --disable-gcc-check"
427             exit 1;
428         fi
429     fi
430 fi
431
432 #
433 # Solaris specific configure tool chain decisions
434 #
435 if test "$solaris" = "yes" ; then
436   #
437   # gcc for solaris 10/fcs in /usr/sfw/bin doesn't compile qemu correctly
438   # override the check with --disable-gcc-check
439   # 
440   if test "$solarisrev" -eq 10 -a "$check_gcc" = "yes" ; then
441     solgcc=`which $cc`
442     if test "$solgcc" = "/usr/sfw/bin/gcc" ; then
443       echo "Solaris 10/FCS gcc in /usr/sfw/bin will not compiled qemu correctly."
444       echo "please get gcc-3.4.3 or later, from www.blastwave.org using pkg-get -i gcc3"
445       echo "or get the latest patch from SunSolve for gcc"
446       exit 1
447     fi
448   fi
449   solinst=`which $install 2> /dev/null | /usr/bin/grep -v "no $install in"`
450   if test -z "$solinst" ; then
451     echo "Solaris install program not found. Use --install=/usr/ucb/install or"
452     echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
453     echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
454     exit 1
455   fi
456   if test "$solinst" = "/usr/sbin/install" ; then
457     echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
458     echo "try ginstall from the GNU fileutils available from www.blastwave.org"
459     echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
460     exit 1
461   fi
462   sol_ar=`which ar 2> /dev/null | /usr/bin/grep -v "no ar in"`
463   if test -z "$sol_ar" ; then
464     echo "Error: No path includes ar"
465     if test -f /usr/ccs/bin/ar ; then
466       echo "Add /usr/ccs/bin to your path and rerun configure"
467     fi
468     exit 1
469   fi
470 fi 
471
472
473 if test -z "$target_list" ; then
474 # these targets are portable
475     if [ "$softmmu" = "yes" ] ; then
476         target_list="i386-softmmu ppc-softmmu sparc-softmmu x86_64-softmmu mips-softmmu mipsel-softmmu mips64-softmmu mips64el-softmmu arm-softmmu ppc64-softmmu ppcemb-softmmu m68k-softmmu"
477     fi
478 # the following are Linux specific
479     if [ "$linux_user" = "yes" ] ; then
480         target_list="i386-linux-user arm-linux-user armeb-linux-user sparc-linux-user ppc-linux-user mips-linux-user mipsel-linux-user m68k-linux-user alpha-linux-user $target_list"
481     fi
482 # the following are Darwin specific
483     if [ "$darwin_user" = "yes" ] ; then
484         target_list="i386-darwin-user ppc-darwin-user $target_list"
485     fi
486 else
487     target_list=`echo "$target_list" | sed -e 's/,/ /g'`
488 fi
489 if test -z "$target_list" ; then
490     echo "No targets enabled"
491     exit 1
492 fi
493
494 if test -z "$cross_prefix" ; then
495
496 # ---
497 # big/little endian test
498 cat > $TMPC << EOF
499 #include <inttypes.h>
500 int main(int argc, char ** argv){
501         volatile uint32_t i=0x01234567;
502         return (*((uint8_t*)(&i))) == 0x67;
503 }
504 EOF
505
506 if $cc -o $TMPE $TMPC 2> /dev/null ; then
507 $TMPE && bigendian="yes"
508 else
509 echo big/little test failed
510 fi
511
512 else
513
514 # if cross compiling, cannot launch a program, so make a static guess
515 if test "$cpu" = "powerpc" -o "$cpu" = "mips" -o "$cpu" = "mips64" -o "$cpu" = "s390" -o "$cpu" = "sparc" -o "$cpu" = "sparc64" -o "$cpu" = "m68k" -o "$cpu" = "armv4b"; then
516     bigendian="yes"
517 fi
518
519 fi
520
521 # host long bits test
522 hostlongbits="32"
523 if test "$cpu" = "sparc64" -o "$cpu" = "ia64" -o "$cpu" = "x86_64" -o "$cpu" = "alpha"; then
524     hostlongbits="64"
525 fi
526
527 # check gcc options support
528 cat > $TMPC <<EOF
529 int main(void) {
530 }
531 EOF
532
533 ##########################################
534 # SDL probe
535
536 sdl_too_old=no
537
538 if test -z "$sdl" ; then
539
540 sdl_config="sdl-config"
541 sdl=no
542 sdl_static=no
543
544 if test "$mingw32" = "yes" -a ! -z "$cross_prefix" ; then
545 # win32 cross compilation case
546     sdl_config="i386-mingw32msvc-sdl-config"
547     sdl=yes
548 else
549 # normal SDL probe
550 cat > $TMPC << EOF
551 #include <SDL.h>
552 #undef main /* We don't want SDL to override our main() */
553 int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
554 EOF
555
556 if $cc -o $TMPE `$sdl_config --cflags 2> /dev/null` $TMPC `$sdl_config --libs 2> /dev/null` 2> /tmp/qemu-$$-sdl-config.log ; then
557 _sdlversion=`$sdl_config --version | sed 's/[^0-9]//g'`
558 if test "$_sdlversion" -lt 121 ; then
559 sdl_too_old=yes
560 else
561  if test "$cocoa" = "no" ; then
562    sdl=yes
563  fi
564 fi
565
566 # static link with sdl ?
567 if test "$sdl" = "yes" ; then
568 aa="no"
569 `$sdl_config --static-libs 2>/dev/null | grep \\\-laa > /dev/null` && aa="yes"
570 sdl_static_libs=`$sdl_config --static-libs 2>/dev/null`
571 if [ "$aa" = "yes" ] ; then
572   sdl_static_libs="$sdl_static_libs `aalib-config --static-libs`"
573 fi
574
575 if $cc -o $TMPE `$sdl_config --cflags 2> /dev/null` $TMPC $sdl_static_libs 2> /dev/null; then
576   sdl_static=yes
577 fi
578
579 fi # static link
580
581 fi # sdl compile test
582
583 fi # cross compilation
584
585 else
586  # Make sure to disable cocoa if sdl was set
587  if test "$sdl" = "yes" ; then
588    cocoa="no"
589    coreaudio="no"
590  fi
591 fi # -z $sdl
592
593 ##########################################
594 # alsa sound support libraries
595
596 if test "$alsa" = "yes" ; then
597   cat > $TMPC << EOF
598 #include <alsa/asoundlib.h>
599 int main(void) { snd_pcm_t **handle; return snd_pcm_close(*handle); }
600 EOF
601   if $cc -o $TMPE $TMPC -lasound 2> /dev/null ; then
602     :
603   else
604     echo
605     echo "Error: Could not find alsa"
606     echo "Make sure to have the alsa libs and headers installed."
607     echo
608     exit 1
609   fi
610 fi
611
612 # Check if tools are available to build documentation.
613 if [ -x "`which texi2html 2>/dev/null`" ] && \
614    [ -x "`which pod2man 2>/dev/null`" ]; then
615   build_docs="yes"
616 fi
617
618 if test "$mingw32" = "yes" ; then
619   if test -z "$prefix" ; then
620       prefix="/c/Program Files/Qemu"
621   fi
622   mansuffix=""
623   datasuffix=""
624   docsuffix=""
625   binsuffix=""
626 else
627   if test -z "$prefix" ; then
628       prefix="/usr/local"
629   fi
630   mansuffix="/share/man"
631   datasuffix="/share/qemu"
632   docsuffix="/share/doc/qemu"
633   binsuffix="/bin"
634 fi
635
636 echo "Install prefix    $prefix"
637 echo "BIOS directory    $prefix$datasuffix"
638 echo "binary directory  $prefix$binsuffix"
639 if test "$mingw32" = "no" ; then
640 echo "Manual directory  $prefix$mansuffix"
641 echo "ELF interp prefix $interp_prefix"
642 fi
643 echo "Source path       $source_path"
644 echo "C compiler        $cc"
645 echo "Host C compiler   $host_cc"
646 echo "make              $make"
647 echo "install           $install"
648 echo "host CPU          $cpu"
649 echo "host big endian   $bigendian"
650 echo "target list       $target_list"
651 echo "gprof enabled     $gprof"
652 echo "profiler          $profiler"
653 echo "static build      $static"
654 if test "$darwin" = "yes" ; then
655     echo "Cocoa support     $cocoa"
656 fi
657 echo "SDL support       $sdl"
658 if test "$sdl" != "no" ; then
659     echo "SDL static link   $sdl_static"
660 fi
661 echo "mingw32 support   $mingw32"
662 echo "Adlib support     $adlib"
663 echo "CoreAudio support $coreaudio"
664 echo "ALSA support      $alsa"
665 echo "DSound support    $dsound"
666 if test "$fmod" = "yes"; then
667     if test -z $fmod_lib || test -z $fmod_inc; then
668         echo
669         echo "Error: You must specify path to FMOD library and headers"
670         echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
671         echo
672         exit 1
673     fi
674     fmod_support=" (lib='$fmod_lib' include='$fmod_inc')"
675 else
676     fmod_support=""
677 fi
678 echo "FMOD support      $fmod $fmod_support"
679 echo "OSS support       $oss"
680 if test -n "$sparc_cpu"; then
681     echo "Target Sparc Arch $sparc_cpu"
682 fi
683 echo "kqemu support     $kqemu"
684 echo "Documentation     $build_docs"
685 [ ! -z "$uname_release" ] && \
686 echo "uname -r          $uname_release"
687
688 if test $sdl_too_old = "yes"; then
689 echo "-> Your SDL version is too old - please upgrade to have SDL support"
690 fi
691 if [ -s /tmp/qemu-$$-sdl-config.log ]; then
692   echo "The error log from compiling the libSDL test is: "
693   cat /tmp/qemu-$$-sdl-config.log
694 fi
695 rm -f /tmp/qemu-$$-sdl-config.log
696 #if test "$sdl_static" = "no"; then
697 #  echo "WARNING: cannot compile statically with SDL - qemu-fast won't have a graphical output"
698 #fi
699 config_mak="config-host.mak"
700 config_h="config-host.h"
701
702 #echo "Creating $config_mak and $config_h"
703
704 echo "# Automatically generated by configure - do not modify" > $config_mak
705 echo "# Configured with: $0 $@" >> $config_mak
706 echo "/* Automatically generated by configure - do not modify */" > $config_h
707
708 echo "prefix=$prefix" >> $config_mak
709 echo "bindir=\${prefix}$binsuffix" >> $config_mak
710 echo "mandir=\${prefix}$mansuffix" >> $config_mak
711 echo "datadir=\${prefix}$datasuffix" >> $config_mak
712 echo "docdir=\${prefix}$docsuffix" >> $config_mak
713 echo "#define CONFIG_QEMU_SHAREDIR \"$prefix$datasuffix\"" >> $config_h
714 echo "MAKE=$make" >> $config_mak
715 echo "INSTALL=$install" >> $config_mak
716 echo "CC=$cc" >> $config_mak
717 echo "HOST_CC=$host_cc" >> $config_mak
718 echo "AR=$ar" >> $config_mak
719 echo "STRIP=$strip -s -R .comment -R .note" >> $config_mak
720 echo "OS_CFLAGS=$OS_CFLAGS" >> $config_mak
721 echo "OS_LDFLAGS=$OS_LDFLAGS" >> $config_mak
722 echo "ARCH_CFLAGS=$ARCH_CFLAGS" >> $config_mak
723 echo "ARCH_LDFLAGS=$ARCH_LDFLAGS" >> $config_mak
724 echo "CFLAGS=$CFLAGS" >> $config_mak
725 echo "LDFLAGS=$LDFLAGS" >> $config_mak
726 echo "EXESUF=$EXESUF" >> $config_mak
727 echo "AIOLIBS=$AIOLIBS" >> $config_mak
728 if test "$cpu" = "i386" ; then
729   echo "ARCH=i386" >> $config_mak
730   echo "#define HOST_I386 1" >> $config_h
731 elif test "$cpu" = "x86_64" ; then
732   echo "ARCH=x86_64" >> $config_mak
733   echo "#define HOST_X86_64 1" >> $config_h
734 elif test "$cpu" = "armv4b" ; then
735   echo "ARCH=arm" >> $config_mak
736   echo "#define HOST_ARM 1" >> $config_h
737 elif test "$cpu" = "armv4l" ; then
738   echo "ARCH=arm" >> $config_mak
739   echo "#define HOST_ARM 1" >> $config_h
740 elif test "$cpu" = "powerpc" ; then
741   echo "ARCH=ppc" >> $config_mak
742   echo "#define HOST_PPC 1" >> $config_h
743 elif test "$cpu" = "mips" ; then
744   echo "ARCH=mips" >> $config_mak
745   echo "#define HOST_MIPS 1" >> $config_h
746 elif test "$cpu" = "mips64" ; then
747   echo "ARCH=mips64" >> $config_mak
748   echo "#define HOST_MIPS64 1" >> $config_h
749 elif test "$cpu" = "s390" ; then
750   echo "ARCH=s390" >> $config_mak
751   echo "#define HOST_S390 1" >> $config_h
752 elif test "$cpu" = "alpha" ; then
753   echo "ARCH=alpha" >> $config_mak
754   echo "#define HOST_ALPHA 1" >> $config_h
755 elif test "$cpu" = "sparc" ; then
756   echo "ARCH=sparc" >> $config_mak
757   echo "#define HOST_SPARC 1" >> $config_h
758 elif test "$cpu" = "sparc64" ; then
759   echo "ARCH=sparc64" >> $config_mak
760   echo "#define HOST_SPARC64 1" >> $config_h
761 elif test "$cpu" = "ia64" ; then
762   echo "ARCH=ia64" >> $config_mak
763   echo "#define HOST_IA64 1" >> $config_h
764 elif test "$cpu" = "m68k" ; then
765   echo "ARCH=m68k" >> $config_mak
766   echo "#define HOST_M68K 1" >> $config_h
767 else
768   echo "Unsupported CPU = $cpu"
769   exit 1
770 fi
771 if test "$bigendian" = "yes" ; then
772   echo "WORDS_BIGENDIAN=yes" >> $config_mak
773   echo "#define WORDS_BIGENDIAN 1" >> $config_h
774 fi
775 echo "#define HOST_LONG_BITS $hostlongbits" >> $config_h
776 if test "$mingw32" = "yes" ; then
777   echo "CONFIG_WIN32=yes" >> $config_mak
778   echo "#define CONFIG_WIN32 1" >> $config_h
779 else
780   cat > $TMPC << EOF
781 #include <byteswap.h>
782 int main(void) { return bswap_32(0); }
783 EOF
784   if $cc -o $TMPE $TMPC 2> /dev/null ; then
785     echo "#define HAVE_BYTESWAP_H 1" >> $config_h
786   fi
787 fi
788 if test "$darwin" = "yes" ; then
789   echo "CONFIG_DARWIN=yes" >> $config_mak
790   echo "#define CONFIG_DARWIN 1" >> $config_h
791 fi
792 if test "$solaris" = "yes" ; then
793   echo "CONFIG_SOLARIS=yes" >> $config_mak
794   echo "#define HOST_SOLARIS $solarisrev" >> $config_h
795   if test "$needs_libsunmath" = "yes" ; then
796     echo "NEEDS_LIBSUNMATH=yes" >> $config_mak
797     echo "#define NEEDS_LIBSUNMATH 1" >> $config_h
798   fi
799 fi
800 if test -n "$sparc_cpu"; then
801   echo "CONFIG__sparc_${sparc_cpu}__=yes" >> $config_mak
802   echo "#define __sparc_${sparc_cpu}__ 1" >> $config_h
803 fi
804 if test "$gdbstub" = "yes" ; then
805   echo "CONFIG_GDBSTUB=yes" >> $config_mak
806   echo "#define CONFIG_GDBSTUB 1" >> $config_h
807 fi
808 if test "$gprof" = "yes" ; then
809   echo "TARGET_GPROF=yes" >> $config_mak
810   echo "#define HAVE_GPROF 1" >> $config_h
811 fi
812 if test "$static" = "yes" ; then
813   echo "CONFIG_STATIC=yes" >> $config_mak
814   echo "#define CONFIG_STATIC 1" >> $config_h
815 fi
816 if test $profiler = "yes" ; then
817   echo "#define CONFIG_PROFILER 1" >> $config_h
818 fi
819 if test "$slirp" = "yes" ; then
820   echo "CONFIG_SLIRP=yes" >> $config_mak
821   echo "#define CONFIG_SLIRP 1" >> $config_h
822 fi
823 if test "$adlib" = "yes" ; then
824   echo "CONFIG_ADLIB=yes" >> $config_mak
825   echo "#define CONFIG_ADLIB 1" >> $config_h
826 fi
827 if test "$oss" = "yes" ; then
828   echo "CONFIG_OSS=yes" >> $config_mak
829   echo "#define CONFIG_OSS 1" >> $config_h
830 fi
831 if test "$coreaudio" = "yes" ; then
832   echo "CONFIG_COREAUDIO=yes" >> $config_mak
833   echo "#define CONFIG_COREAUDIO 1" >> $config_h
834 fi
835 if test "$alsa" = "yes" ; then
836   echo "CONFIG_ALSA=yes" >> $config_mak
837   echo "#define CONFIG_ALSA 1" >> $config_h
838 fi
839 if test "$dsound" = "yes" ; then
840   echo "CONFIG_DSOUND=yes" >> $config_mak
841   echo "#define CONFIG_DSOUND 1" >> $config_h
842 fi
843 if test "$fmod" = "yes" ; then
844   echo "CONFIG_FMOD=yes" >> $config_mak
845   echo "CONFIG_FMOD_LIB=$fmod_lib" >> $config_mak
846   echo "CONFIG_FMOD_INC=$fmod_inc" >> $config_mak
847   echo "#define CONFIG_FMOD 1" >> $config_h
848 fi
849 qemu_version=`head $source_path/VERSION`
850 echo "VERSION=$qemu_version" >>$config_mak
851 echo "#define QEMU_VERSION \"$qemu_version\"" >> $config_h
852
853 echo "SRC_PATH=$source_path" >> $config_mak
854 if [ "$source_path_used" = "yes" ]; then
855   echo "VPATH=$source_path" >> $config_mak
856 fi
857 echo "TARGET_DIRS=$target_list" >> $config_mak
858 if [ "$build_docs" = "yes" ] ; then
859   echo "BUILD_DOCS=yes" >> $config_mak
860 fi
861
862 # XXX: suppress that
863 if [ "$bsd" = "yes" ] ; then
864   echo "#define O_LARGEFILE 0" >> $config_h
865   echo "#define MAP_ANONYMOUS MAP_ANON" >> $config_h
866   echo "#define _BSD 1" >> $config_h
867 fi
868
869 echo "#define CONFIG_UNAME_RELEASE \"$uname_release\"" >> $config_h
870
871 for target in $target_list; do
872 target_dir="$target"
873 config_mak=$target_dir/config.mak
874 config_h=$target_dir/config.h
875 target_cpu=`echo $target | cut -d '-' -f 1`
876 target_bigendian="no"
877 [ "$target_cpu" = "armeb" ] && target_bigendian=yes
878 [ "$target_cpu" = "sparc" ] && target_bigendian=yes
879 [ "$target_cpu" = "sparc64" ] && target_bigendian=yes
880 [ "$target_cpu" = "ppc" ] && target_bigendian=yes
881 [ "$target_cpu" = "ppc64" ] && target_bigendian=yes
882 [ "$target_cpu" = "ppcemb" ] && target_bigendian=yes
883 [ "$target_cpu" = "mips" ] && target_bigendian=yes
884 [ "$target_cpu" = "mips64" ] && target_bigendian=yes
885 [ "$target_cpu" = "sh4eb" ] && target_bigendian=yes
886 [ "$target_cpu" = "m68k" ] && target_bigendian=yes
887 target_softmmu="no"
888 target_user_only="no"
889 target_linux_user="no"
890 target_darwin_user="no"
891 case "$target" in
892   ${target_cpu}-softmmu)
893     target_softmmu="yes"
894     ;;
895   ${target_cpu}-linux-user)
896     target_user_only="yes"
897     target_linux_user="yes"
898     ;;
899   ${target_cpu}-darwin-user)
900     target_user_only="yes"
901     target_darwin_user="yes"
902     ;;
903   *)
904     echo "ERROR: Target '$target' not recognised"
905     exit 1
906     ;;
907 esac
908
909 if test "$target_user_only" = "no" -a "$check_gfx" = "yes" \
910         -a "$sdl" = "no" -a "$cocoa" = "no" ; then
911     echo "ERROR: QEMU requires SDL or Cocoa for graphical output"
912     echo "To build QEMU without graphical output configure with --disable-gfx-check"
913     echo "Note that this will disable all output from the virtual graphics card."
914     exit 1;
915 fi
916
917 #echo "Creating $config_mak, $config_h and $target_dir/Makefile"
918
919 mkdir -p $target_dir
920 mkdir -p $target_dir/fpu
921 if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" ; then
922   mkdir -p $target_dir/nwfpe
923 fi
924 if test "$target_user_only" = "no" ; then
925   mkdir -p $target_dir/slirp
926 fi
927
928 #
929 # don't use ln -sf as not all "ln -sf" over write the file/link
930 #
931 rm -f $target_dir/Makefile
932 ln -s $source_path/Makefile.target $target_dir/Makefile
933
934
935 echo "# Automatically generated by configure - do not modify" > $config_mak
936 echo "/* Automatically generated by configure - do not modify */" > $config_h
937
938
939 echo "include ../config-host.mak" >> $config_mak
940 echo "#include \"../config-host.h\"" >> $config_h
941
942 bflt="no"
943 interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_cpu/g"`
944 echo "#define CONFIG_QEMU_PREFIX \"$interp_prefix1\"" >> $config_h
945
946 if test "$target_cpu" = "i386" ; then
947   echo "TARGET_ARCH=i386" >> $config_mak
948   echo "#define TARGET_ARCH \"i386\"" >> $config_h
949   echo "#define TARGET_I386 1" >> $config_h
950   if test $kqemu = "yes" -a "$target_softmmu" = "yes" -a $cpu = "i386" ; then
951     echo "#define USE_KQEMU 1" >> $config_h
952   fi
953 elif test "$target_cpu" = "arm" -o "$target_cpu" = "armeb" ; then
954   echo "TARGET_ARCH=arm" >> $config_mak
955   echo "#define TARGET_ARCH \"arm\"" >> $config_h
956   echo "#define TARGET_ARM 1" >> $config_h
957   bflt="yes"
958 elif test "$target_cpu" = "sparc" ; then
959   echo "TARGET_ARCH=sparc" >> $config_mak
960   echo "#define TARGET_ARCH \"sparc\"" >> $config_h
961   echo "#define TARGET_SPARC 1" >> $config_h
962 elif test "$target_cpu" = "sparc64" ; then
963   echo "TARGET_ARCH=sparc64" >> $config_mak
964   echo "#define TARGET_ARCH \"sparc64\"" >> $config_h
965   echo "#define TARGET_SPARC 1" >> $config_h
966   echo "#define TARGET_SPARC64 1" >> $config_h
967 elif test "$target_cpu" = "ppc" ; then
968   echo "TARGET_ARCH=ppc" >> $config_mak
969   echo "#define TARGET_ARCH \"ppc\"" >> $config_h
970   echo "#define TARGET_PPC 1" >> $config_h
971 elif test "$target_cpu" = "ppc64" ; then
972   echo "TARGET_ARCH=ppc64" >> $config_mak
973   echo "#define TARGET_ARCH \"ppc64\"" >> $config_h
974   echo "#define TARGET_PPC 1" >> $config_h
975   echo "#define TARGET_PPC64 1" >> $config_h
976 elif test "$target_cpu" = "ppcemb" ; then
977   echo "TARGET_ARCH=ppcemb" >> $config_mak
978   echo "#define TARGET_ARCH \"ppcemb\"" >> $config_h
979   echo "#define TARGET_PPC 1" >> $config_h
980   echo "#define TARGET_PPCEMB 1" >> $config_h
981 elif test "$target_cpu" = "x86_64" ; then
982   echo "TARGET_ARCH=x86_64" >> $config_mak
983   echo "#define TARGET_ARCH \"x86_64\"" >> $config_h
984   echo "#define TARGET_I386 1" >> $config_h
985   echo "#define TARGET_X86_64 1" >> $config_h
986   if test $kqemu = "yes" -a "$target_softmmu" = "yes" -a $cpu = "x86_64"  ; then
987     echo "#define USE_KQEMU 1" >> $config_h
988   fi
989 elif test "$target_cpu" = "mips" -o "$target_cpu" = "mipsel" ; then
990   echo "TARGET_ARCH=mips" >> $config_mak
991   echo "#define TARGET_ARCH \"mips\"" >> $config_h
992   echo "#define TARGET_MIPS 1" >> $config_h
993   echo "CONFIG_SOFTFLOAT=yes" >> $config_mak
994   echo "#define CONFIG_SOFTFLOAT 1" >> $config_h
995 elif test "$target_cpu" = "mips64" -o "$target_cpu" = "mips64el" ; then
996   echo "TARGET_ARCH=mips64" >> $config_mak
997   echo "#define TARGET_ARCH \"mips64\"" >> $config_h
998   echo "#define TARGET_MIPS 1" >> $config_h
999   echo "#define TARGET_MIPS64 1" >> $config_h
1000   echo "CONFIG_SOFTFLOAT=yes" >> $config_mak
1001   echo "#define CONFIG_SOFTFLOAT 1" >> $config_h
1002 elif test "$target_cpu" = "sh4" -o "$target_cpu" = "sh4eb" ; then
1003   echo "TARGET_ARCH=sh4" >> $config_mak
1004   echo "#define TARGET_ARCH \"sh4\"" >> $config_h
1005   echo "#define TARGET_SH4 1" >> $config_h
1006   bflt="yes"
1007 elif test "$target_cpu" = "m68k" ; then
1008   echo "TARGET_ARCH=m68k" >> $config_mak
1009   echo "#define TARGET_ARCH \"m68k\"" >> $config_h
1010   echo "#define TARGET_M68K 1" >> $config_h
1011   bflt="yes"
1012 elif test "$target_cpu" = "alpha" ; then
1013   echo "TARGET_ARCH=alpha" >> $config_mak
1014   echo "#define TARGET_ARCH \"alpha\"" >> $config_h
1015   echo "#define TARGET_ALPHA 1" >> $config_h
1016 else
1017   echo "Unsupported target CPU"
1018   exit 1
1019 fi
1020 if test "$target_bigendian" = "yes" ; then
1021   echo "TARGET_WORDS_BIGENDIAN=yes" >> $config_mak
1022   echo "#define TARGET_WORDS_BIGENDIAN 1" >> $config_h
1023 fi
1024 if test "$target_softmmu" = "yes" ; then
1025   echo "CONFIG_SOFTMMU=yes" >> $config_mak
1026   echo "#define CONFIG_SOFTMMU 1" >> $config_h
1027 fi
1028 if test "$target_user_only" = "yes" ; then
1029   echo "CONFIG_USER_ONLY=yes" >> $config_mak
1030   echo "#define CONFIG_USER_ONLY 1" >> $config_h
1031 fi
1032 if test "$target_linux_user" = "yes" ; then
1033   echo "CONFIG_LINUX_USER=yes" >> $config_mak
1034   echo "#define CONFIG_LINUX_USER 1" >> $config_h
1035 fi
1036 if test "$target_darwin_user" = "yes" ; then
1037   echo "CONFIG_DARWIN_USER=yes" >> $config_mak
1038   echo "#define CONFIG_DARWIN_USER 1" >> $config_h
1039 fi
1040
1041 if test "$target_cpu" = "arm" -o "$target_cpu" = "armeb" -o "$target_cpu" = "sparc" -o "$target_cpu" = "sparc64" -o "$target_cpu" = "m68k"; then
1042   echo "CONFIG_SOFTFLOAT=yes" >> $config_mak
1043   echo "#define CONFIG_SOFTFLOAT 1" >> $config_h
1044 fi
1045 if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
1046   echo "TARGET_HAS_BFLT=yes" >> $config_mak
1047   echo "#define TARGET_HAS_BFLT 1" >> $config_h
1048 fi
1049 # sdl defines
1050
1051 if test "$target_user_only" = "no"; then
1052     if test "$target_softmmu" = "no" -o "$static" = "yes"; then
1053         sdl1=$sdl_static
1054     else
1055         sdl1=$sdl
1056     fi
1057     if test "$sdl1" = "yes" ; then
1058         echo "#define CONFIG_SDL 1" >> $config_h
1059         echo "CONFIG_SDL=yes" >> $config_mak
1060         if test "$target_softmmu" = "no" -o "$static" = "yes"; then
1061             echo "SDL_LIBS=$sdl_static_libs" >> $config_mak
1062         else
1063             echo "SDL_LIBS=`$sdl_config --libs`" >> $config_mak
1064         fi
1065         if [ "${aa}" = "yes" ] ; then
1066             echo "SDL_CFLAGS=`$sdl_config --cflags` `aalib-config --cflags`" >> $config_mak
1067         else
1068             echo "SDL_CFLAGS=`$sdl_config --cflags`" >> $config_mak
1069         fi
1070     fi
1071 fi
1072
1073 if test "$cocoa" = "yes" ; then
1074     echo "#define CONFIG_COCOA 1" >> $config_h
1075     echo "CONFIG_COCOA=yes" >> $config_mak
1076 fi
1077
1078 done # for target in $targets
1079
1080 # build tree in object directory if source path is different from current one
1081 if test "$source_path_used" = "yes" ; then
1082     DIRS="tests"
1083     FILES="Makefile tests/Makefile"
1084     for dir in $DIRS ; do
1085             mkdir -p $dir
1086     done
1087     # remove the link and recreate it, as not all "ln -sf" overwrite the link
1088     for f in $FILES ; do
1089         rm -f $f
1090         ln -s $source_path/$f $f
1091     done
1092 fi
1093
1094 rm -f $TMPO $TMPC $TMPE $TMPS