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