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