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