3471193ede44f99304ee015a1009dec71820384d
[qemu] / 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 host_cc="gcc"
26 ar="ar"
27 make="make"
28 strip="strip"
29 cpu=`uname -m`
30 target_list=""
31 case "$cpu" in
32   i386|i486|i586|i686|i86pc|BePC)
33     cpu="i386"
34   ;;
35   armv*b)
36     cpu="armv4b"
37   ;;
38   armv*l)
39     cpu="armv4l"
40   ;;
41   alpha)
42     cpu="alpha"
43   ;;
44   "Power Macintosh"|ppc|ppc64)
45     cpu="powerpc"
46   ;;
47   mips)
48     cpu="mips"
49   ;;
50   s390)
51     cpu="s390"
52   ;;
53   sparc)
54     cpu="sparc"
55   ;;
56   sparc64)
57     cpu="sparc64"
58   ;;
59   ia64)
60     cpu="ia64"
61   ;;
62   m68k)
63     cpu="m68k"
64   ;;
65   x86_64|amd64)
66     cpu="x86_64"
67   ;;
68   *)
69     cpu="unknown"
70   ;;
71 esac
72 gprof="no"
73 bigendian="no"
74 mingw32="no"
75 EXESUF=""
76 gdbstub="yes"
77 slirp="yes"
78 adlib="no"
79 oss="no"
80 dsound="no"
81 coreaudio="no"
82 alsa="no"
83 fmod="no"
84 fmod_lib=""
85 fmod_inc=""
86 linux="no"
87 kqemu="no"
88 kernel_path=""
89 cocoa="no"
90 check_gfx="yes"
91 check_gcc="yes"
92
93 # OS specific
94 targetos=`uname -s`
95 case $targetos in
96 CYGWIN*)
97 mingw32="yes"
98 CFLAGS="-O2 -mno-cygwin"
99 ;;
100 MINGW32*)
101 mingw32="yes"
102 ;;
103 FreeBSD)
104 bsd="yes"
105 oss="yes"
106 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
107     kqemu="yes"
108 fi
109 ;;
110 NetBSD)
111 bsd="yes"
112 oss="yes"
113 ;;
114 OpenBSD)
115 bsd="yes"
116 oss="yes"
117 ;;
118 Darwin)
119 bsd="yes"
120 darwin="yes"
121 ;;
122 *)
123 oss="yes"
124 linux="yes"
125 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
126     kqemu="yes"
127 fi
128 ;;
129 esac
130
131 if [ "$bsd" = "yes" ] ; then
132   if [ ! "$darwin" = "yes" ] ; then
133     make="gmake"
134   fi
135 fi
136
137 # find source path
138 # XXX: we assume an absolute path is given when launching configure,
139 # except in './configure' case.
140 source_path=${0%configure}
141 source_path=${source_path%/}
142 source_path_used="yes"
143 if test -z "$source_path" -o "$source_path" = "." ; then
144     source_path=`pwd`
145     source_path_used="no"
146 fi
147
148 for opt do
149   case "$opt" in
150   --help|-h) show_help=yes
151   ;;
152   --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
153   ;;
154   --interp-prefix=*) interp_prefix=`echo $opt | cut -d '=' -f 2`
155   ;;
156   --source-path=*) source_path=`echo $opt | cut -d '=' -f 2`
157   ;;
158   --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
159   ;;
160   --cc=*) cc=`echo $opt | cut -d '=' -f 2`
161   ;;
162   --host-cc=*) host_cc=`echo $opt | cut -d '=' -f 2`
163   ;;
164   --make=*) make=`echo $opt | cut -d '=' -f 2`
165   ;;
166   --extra-cflags=*) CFLAGS="${opt#--extra-cflags=}"
167   ;;
168   --extra-ldflags=*) LDFLAGS="${opt#--extra-ldflags=}"
169   ;;
170   --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
171   ;;
172   --target-list=*) target_list=${opt#--target-list=}
173   ;;
174   --enable-gprof) gprof="yes"
175   ;;
176   --static) static="yes"
177   ;;
178   --disable-sdl) sdl="no"
179   ;;
180   --enable-coreaudio) coreaudio="yes"
181   ;;
182   --enable-alsa) alsa="yes"
183   ;;
184   --enable-dsound) dsound="yes"
185   ;;
186   --enable-fmod) fmod="yes"
187   ;;
188   --fmod-lib=*) fmod_lib=${opt#--fmod-lib=}
189   ;;
190   --fmod-inc=*) fmod_inc=${opt#--fmod-inc=}
191   ;;
192   --enable-mingw32) mingw32="yes" ; cross_prefix="i386-mingw32-"
193   ;;
194   --disable-slirp) slirp="no"
195   ;;
196   --enable-adlib) adlib="yes"
197   ;;
198   --disable-kqemu) kqemu="no"
199   ;;
200   --kernel-path=*) kernel_path=${opt#--kernel-path=}
201   ;;
202   --enable-cocoa) cocoa="yes" ; coreaudio="yes" ; sdl="no"
203   ;;
204   --disable-gfx-check) check_gfx="no"
205   ;;
206   --disable-gcc-check) check_gcc="no"
207   ;;
208   esac
209 done
210
211 # Checking for CFLAGS
212 if test -z "$CFLAGS"; then
213     CFLAGS="-O2"
214 fi
215
216 cc="${cross_prefix}${cc}"
217 ar="${cross_prefix}${ar}"
218 strip="${cross_prefix}${strip}"
219
220 if test "$mingw32" = "yes" ; then
221     linux="no"
222     EXESUF=".exe"
223     gdbstub="no"
224     oss="no"
225     if [ "$cpu" = "i386" ] ; then
226         kqemu="yes"
227     fi
228 fi
229
230 if test -z "$target_list" ; then
231 # these targets are portable
232     target_list="i386-softmmu ppc-softmmu sparc-softmmu x86_64-softmmu mips-softmmu arm-softmmu"
233 # the following are Linux specific
234     if [ "$linux" = "yes" ] ; then
235         target_list="i386-user arm-user armeb-user sparc-user ppc-user mips-user mipsel-user $target_list"
236     fi
237 else
238     target_list=$(echo "$target_list" | sed -e 's/,/ /g')
239 fi
240
241 if test -z "$cross_prefix" ; then
242
243 # ---
244 # big/little endian test
245 cat > $TMPC << EOF
246 #include <inttypes.h>
247 int main(int argc, char ** argv){
248         volatile uint32_t i=0x01234567;
249         return (*((uint8_t*)(&i))) == 0x67;
250 }
251 EOF
252
253 if $cc -o $TMPE $TMPC 2>/dev/null ; then
254 $TMPE && bigendian="yes"
255 else
256 echo big/little test failed
257 fi
258
259 else
260
261 # if cross compiling, cannot launch a program, so make a static guess
262 if test "$cpu" = "powerpc" -o "$cpu" = "mips" -o "$cpu" = "s390" -o "$cpu" = "sparc" -o "$cpu" = "sparc64" -o "$cpu" = "m68k" -o "$cpu" = "armv4b"; then
263     bigendian="yes"
264 fi
265
266 fi
267
268 # host long bits test
269 hostlongbits="32"
270 if test "$cpu" = "sparc64" -o "$cpu" = "ia64" -o "$cpu" = "x86_64" -o "$cpu" = "alpha"; then
271     hostlongbits="64"
272 fi
273
274 # check gcc options support
275 cat > $TMPC <<EOF
276 int main(void) {
277 }
278 EOF
279
280 have_gcc3_options="no"
281 if $cc -fno-reorder-blocks -fno-optimize-sibling-calls -o $TMPO $TMPC 2> /dev/null ; then
282    have_gcc3_options="yes"
283 fi
284
285 # Check for gcc4
286 if test "$check_gcc" = "yes" ; then
287     cat > $TMPC <<EOF
288 #if __GNUC__ >= 4
289 #error gcc4
290 #endif
291 int main(){return 0;}
292 EOF
293     if ! $cc -o $TMPO $TMPC 2>/dev/null ; then
294         echo "ERROR: \"$cc\" looks like gcc 4.x"
295         echo "QEMU is known to have problems when compiled with gcc 4.x"
296         echo "It is recommended that you use gcc 3.x to build QEMU"
297         echo "To use this compiler anyway, configure with --disable-gcc-check"
298         exit 1;
299     fi
300 fi
301
302 ##########################################
303 # SDL probe
304
305 sdl_too_old=no
306
307 if test -z "$sdl" ; then
308
309 sdl_config="sdl-config"
310 sdl=no
311 sdl_static=no
312
313 if test "$mingw32" = "yes" -a ! -z "$cross_prefix" ; then
314 # win32 cross compilation case
315     sdl_config="i386-mingw32msvc-sdl-config"
316     sdl=yes
317 else
318 # normal SDL probe
319 cat > $TMPC << EOF
320 #include <SDL.h>
321 #undef main /* We don't want SDL to override our main() */
322 int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
323 EOF
324
325 if $cc -o $TMPE `$sdl_config --cflags 2> /dev/null` $TMPC `$sdl_config --libs 2> /dev/null` 2> /dev/null ; then
326 _sdlversion=`$sdl_config --version | sed 's/[^0-9]//g'`
327 if test "$_sdlversion" -lt 121 ; then
328 sdl_too_old=yes
329 else
330 sdl=yes
331 fi
332
333 # static link with sdl ?
334 if test "$sdl" = "yes" ; then
335 aa="no"
336 `$sdl_config --static-libs | grep \\\-laa > /dev/null` && aa="yes"
337 sdl_static_libs=`$sdl_config --static-libs`
338 if [ "$aa" = "yes" ] ; then
339   sdl_static_libs="$sdl_static_libs `aalib-config --static-libs`"
340 fi
341
342 if $cc -o $TMPE `$sdl_config --cflags 2> /dev/null` $TMPC $sdl_static_libs 2> /dev/null; then
343   sdl_static=yes
344 fi
345
346 fi # static link
347
348 fi # sdl compile test
349
350 fi # cross compilation
351 fi # -z $sdl
352
353 if test x"$show_help" = x"yes" ; then
354 cat << EOF
355
356 Usage: configure [options]
357 Options: [defaults in brackets after descriptions]
358
359 EOF
360 echo "Standard options:"
361 echo "  --help                   print this message"
362 echo "  --prefix=PREFIX          install in PREFIX [$prefix]"
363 echo "  --interp-prefix=PREFIX   where to find shared libraries, etc."
364 echo "                           use %M for cpu name [$interp_prefix]"
365 echo "  --target-list=LIST       set target list [$target_list]"
366 echo ""
367 echo "kqemu kernel acceleration support:"
368 echo "  --disable-kqemu          disable kqemu build"
369 echo "  --kernel-path=PATH       set the kernel path (configure probes it)"
370 echo ""
371 echo "Advanced options (experts only):"
372 echo "  --source-path=PATH       path of source code [$source_path]"
373 echo "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
374 echo "  --cc=CC                  use C compiler CC [$cc]"
375 echo "  --host-cc=CC             use C compiler CC [$host_cc] for dyngen etc."
376 echo "  --make=MAKE              use specified make [$make]"
377 echo "  --static                 enable static build [$static]"
378 echo "  --enable-mingw32         enable Win32 cross compilation with mingw32"
379 echo "  --enable-adlib           enable Adlib emulation"
380 echo "  --enable-coreaudio       enable Coreaudio audio driver"
381 echo "  --enable-alsa            enable ALSA audio driver"
382 echo "  --enable-fmod            enable FMOD audio driver"
383 echo "  --enabled-dsound         enable DirectSound audio driver"
384 echo "  --fmod-lib               path to FMOD library"
385 echo "  --fmod-inc               path to FMOD includes"
386 echo ""
387 echo "NOTE: The object files are build at the place where configure is launched"
388 exit 1
389 fi
390
391 if test "$mingw32" = "yes" ; then
392 if test -z "$prefix" ; then
393     prefix="/c/Program Files/Qemu"
394 fi
395 mandir="$prefix"
396 datadir="$prefix"
397 docdir="$prefix"
398 bindir="$prefix"
399 else
400 if test -z "$prefix" ; then
401     prefix="/usr/local"
402 fi
403 mandir="$prefix/share/man"
404 datadir="$prefix/share/qemu"
405 docdir="$prefix/share/doc/qemu"
406 bindir="$prefix/bin"
407 fi
408
409 # kqemu support
410 if test $kqemu = "yes" ; then
411     # test if the source code is installed
412     if test '!' -f "kqemu/Makefile" ; then
413         kqemu="no"
414     fi
415 fi
416
417 # Linux specific kqemu configuration
418 if test $kqemu = "yes" -a $linux = "yes" ; then
419 # find the kernel path
420 if test -z "$kernel_path" ; then
421 kernel_version=`uname -r`
422 kernel_path="/lib/modules/$kernel_version/build"
423 if test '!' -d "$kernel_path/include" ; then
424     kernel_path="/usr/src/linux"
425     if test '!' -d "$kernel_path/include" ; then
426         echo "Could not find kernel includes in /lib/modules or /usr/src/linux - cannot build the kqemu module"
427         kqemu="no"
428     fi
429 fi
430 fi
431
432 if test $kqemu = "yes" ; then
433
434 # test that the kernel config is present
435 if test '!' -f "$kernel_path/Makefile" ; then
436     echo "No Makefile file present in $kernel_path - kqemu cannot be built"
437     kqemu="no"
438 fi
439
440 # find build system (2.6 or legacy)
441 kbuild26="yes"
442 if grep -q "PATCHLEVEL = 4" $kernel_path/Makefile ; then
443 kbuild26="no"
444 fi
445
446 fi # kqemu
447
448 fi # kqemu and linux
449
450
451 echo "Install prefix    $prefix"
452 echo "BIOS directory    $datadir"
453 echo "binary directory  $bindir"
454 if test "$mingw32" = "no" ; then
455 echo "Manual directory  $mandir"
456 echo "ELF interp prefix $interp_prefix"
457 fi
458 echo "Source path       $source_path"
459 echo "C compiler        $cc"
460 echo "Host C compiler   $host_cc"
461 echo "make              $make"
462 echo "host CPU          $cpu"
463 echo "host big endian   $bigendian"
464 echo "target list       $target_list"
465 echo "gprof enabled     $gprof"
466 echo "static build      $static"
467 if test "$darwin" = "yes" ; then
468     echo "Cocoa support     $cocoa"
469 fi
470 echo "SDL support       $sdl"
471 if test "$sdl" != "no" ; then
472     echo "SDL static link   $sdl_static"
473 fi
474 echo "mingw32 support   $mingw32"
475 echo "Adlib support     $adlib"
476 echo "CoreAudio support $coreaudio"
477 echo "ALSA support      $alsa"
478 echo "DSound support    $dsound"
479 echo -n "FMOD support      $fmod"
480 if test "$fmod" = "yes"; then
481     if test -z $fmod_lib || test -z $fmod_inc; then
482         echo
483         echo "Error: You must specify path to FMOD library and headers"
484         echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
485         echo
486         exit 1
487     fi
488     echo -n " (lib='$fmod_lib' include='$fmod_inc')"
489 fi
490 echo ""
491 echo "kqemu support     $kqemu"
492 if test $kqemu = "yes" -a $linux = "yes" ; then
493 echo ""
494 echo "KQEMU Linux module configuration:"
495 echo "kernel sources    $kernel_path"
496 echo -n "kbuild type       "
497 if test $kbuild26 = "yes"; then
498 echo "2.6"
499 else
500 echo "2.4"
501 fi
502 fi
503
504 if test $sdl_too_old = "yes"; then
505 echo "-> Your SDL version is too old - please upgrade to have SDL support"
506 fi
507 #if test "$sdl_static" = "no"; then
508 #  echo "WARNING: cannot compile statically with SDL - qemu-fast won't have a graphical output"
509 #fi
510
511 config_mak="config-host.mak"
512 config_h="config-host.h"
513
514 #echo "Creating $config_mak and $config_h"
515
516 echo "# Automatically generated by configure - do not modify" > $config_mak
517 echo "/* Automatically generated by configure - do not modify */" > $config_h
518
519 echo "prefix=$prefix" >> $config_mak
520 echo "bindir=$bindir" >> $config_mak
521 echo "mandir=$mandir" >> $config_mak
522 echo "datadir=$datadir" >> $config_mak
523 echo "docdir=$docdir" >> $config_mak
524 echo "#define CONFIG_QEMU_SHAREDIR \"$datadir\"" >> $config_h
525 echo "MAKE=$make" >> $config_mak
526 echo "CC=$cc" >> $config_mak
527 if test "$have_gcc3_options" = "yes" ; then
528   echo "HAVE_GCC3_OPTIONS=yes" >> $config_mak
529 fi
530 echo "HOST_CC=$host_cc" >> $config_mak
531 echo "AR=$ar" >> $config_mak
532 echo "STRIP=$strip -s -R .comment -R .note" >> $config_mak
533 echo "CFLAGS=$CFLAGS" >> $config_mak
534 echo "LDFLAGS=$LDFLAGS" >> $config_mak
535 echo "EXESUF=$EXESUF" >> $config_mak
536 if test "$cpu" = "i386" ; then
537   echo "ARCH=i386" >> $config_mak
538   echo "#define HOST_I386 1" >> $config_h
539 elif test "$cpu" = "x86_64" ; then
540   echo "ARCH=x86_64" >> $config_mak
541   echo "#define HOST_X86_64 1" >> $config_h
542 elif test "$cpu" = "armv4b" ; then
543   echo "ARCH=arm" >> $config_mak
544   echo "#define HOST_ARM 1" >> $config_h
545 elif test "$cpu" = "armv4l" ; then
546   echo "ARCH=arm" >> $config_mak
547   echo "#define HOST_ARM 1" >> $config_h
548 elif test "$cpu" = "powerpc" ; then
549   echo "ARCH=ppc" >> $config_mak
550   echo "#define HOST_PPC 1" >> $config_h
551 elif test "$cpu" = "mips" ; then
552   echo "ARCH=mips" >> $config_mak
553   echo "#define HOST_MIPS 1" >> $config_h
554 elif test "$cpu" = "s390" ; then
555   echo "ARCH=s390" >> $config_mak
556   echo "#define HOST_S390 1" >> $config_h
557 elif test "$cpu" = "alpha" ; then
558   echo "ARCH=alpha" >> $config_mak
559   echo "#define HOST_ALPHA 1" >> $config_h
560 elif test "$cpu" = "sparc" ; then
561   echo "ARCH=sparc" >> $config_mak
562   echo "#define HOST_SPARC 1" >> $config_h
563 elif test "$cpu" = "sparc64" ; then
564   echo "ARCH=sparc64" >> $config_mak
565   echo "#define HOST_SPARC64 1" >> $config_h
566 elif test "$cpu" = "ia64" ; then
567   echo "ARCH=ia64" >> $config_mak
568   echo "#define HOST_IA64 1" >> $config_h
569 elif test "$cpu" = "m68k" ; then
570   echo "ARCH=m68k" >> $config_mak
571   echo "#define HOST_M68K 1" >> $config_h
572 else
573   echo "Unsupported CPU"
574   exit 1
575 fi
576 if test "$bigendian" = "yes" ; then
577   echo "WORDS_BIGENDIAN=yes" >> $config_mak
578   echo "#define WORDS_BIGENDIAN 1" >> $config_h
579 fi
580 echo "#define HOST_LONG_BITS $hostlongbits" >> $config_h
581 if test "$mingw32" = "yes" ; then
582   echo "CONFIG_WIN32=yes" >> $config_mak
583   echo "#define CONFIG_WIN32 1" >> $config_h
584 elif test -f "/usr/include/byteswap.h" ; then
585   echo "#define HAVE_BYTESWAP_H 1" >> $config_h
586 fi
587 if test "$darwin" = "yes" ; then
588   echo "CONFIG_DARWIN=yes" >> $config_mak
589   echo "#define CONFIG_DARWIN 1" >> $config_h
590 fi
591 if test "$gdbstub" = "yes" ; then
592   echo "CONFIG_GDBSTUB=yes" >> $config_mak
593   echo "#define CONFIG_GDBSTUB 1" >> $config_h
594 fi
595 if test "$gprof" = "yes" ; then
596   echo "TARGET_GPROF=yes" >> $config_mak
597   echo "#define HAVE_GPROF 1" >> $config_h
598 fi
599 if test "$static" = "yes" ; then
600   echo "CONFIG_STATIC=yes" >> $config_mak
601   echo "#define CONFIG_STATIC 1" >> $config_h
602 fi
603 if test "$slirp" = "yes" ; then
604   echo "CONFIG_SLIRP=yes" >> $config_mak
605   echo "#define CONFIG_SLIRP 1" >> $config_h
606 fi
607 if test "$adlib" = "yes" ; then
608   echo "CONFIG_ADLIB=yes" >> $config_mak
609   echo "#define CONFIG_ADLIB 1" >> $config_h
610 fi
611 if test "$oss" = "yes" ; then
612   echo "CONFIG_OSS=yes" >> $config_mak
613   echo "#define CONFIG_OSS 1" >> $config_h
614 fi
615 if test "$coreaudio" = "yes" ; then
616   echo "CONFIG_COREAUDIO=yes" >> $config_mak
617   echo "#define CONFIG_COREAUDIO 1" >> $config_h
618 fi
619 if test "$alsa" = "yes" ; then
620   echo "CONFIG_ALSA=yes" >> $config_mak
621   echo "#define CONFIG_ALSA 1" >> $config_h
622 fi
623 if test "$dsound" = "yes" ; then
624   echo "CONFIG_DSOUND=yes" >> $config_mak
625   echo "#define CONFIG_DSOUND 1" >> $config_h
626 fi
627 if test "$fmod" = "yes" ; then
628   echo "CONFIG_FMOD=yes" >> $config_mak
629   echo "CONFIG_FMOD_LIB=$fmod_lib" >> $config_mak
630   echo "CONFIG_FMOD_INC=$fmod_inc" >> $config_mak
631   echo "#define CONFIG_FMOD 1" >> $config_h
632 fi
633 echo -n "VERSION=" >>$config_mak
634 head $source_path/VERSION >>$config_mak
635 echo "" >>$config_mak
636 echo -n "#define QEMU_VERSION \"" >> $config_h
637 head $source_path/VERSION >> $config_h
638 echo "\"" >> $config_h
639
640 if test $kqemu = "yes" ; then
641   echo "CONFIG_KQEMU=yes" >> $config_mak
642   if test $linux = "yes" ; then
643     echo "KERNEL_PATH=$kernel_path" >> $config_mak
644     if test $kbuild26 = "yes" ; then
645       echo "CONFIG_KBUILD26=yes" >> $config_mak
646     fi
647   fi
648 fi
649 echo "SRC_PATH=$source_path" >> $config_mak
650 echo "TARGET_DIRS=$target_list" >> $config_mak
651
652 # XXX: suppress that
653 if [ "$bsd" = "yes" ] ; then
654   echo "#define O_LARGEFILE 0" >> $config_h
655   echo "#define MAP_ANONYMOUS MAP_ANON" >> $config_h
656   echo "#define _BSD 1" >> $config_h
657 fi
658
659 for target in $target_list; do
660
661 target_dir="$target"
662 config_mak=$target_dir/config.mak
663 config_h=$target_dir/config.h
664 target_cpu=`echo $target | cut -d '-' -f 1`
665 target_bigendian="no"
666 [ "$target_cpu" = "armeb" ] && target_bigendian=yes
667 [ "$target_cpu" = "sparc" ] && target_bigendian=yes
668 [ "$target_cpu" = "sparc64" ] && target_bigendian=yes
669 [ "$target_cpu" = "ppc" ] && target_bigendian=yes
670 [ "$target_cpu" = "ppc64" ] && target_bigendian=yes
671 [ "$target_cpu" = "mips" ] && target_bigendian=yes
672 target_softmmu="no"
673 if expr $target : '.*-softmmu' > /dev/null ; then
674   target_softmmu="yes"
675 fi
676 target_user_only="no"
677 if expr $target : '.*-user' > /dev/null ; then
678   target_user_only="yes"
679 fi
680
681 if test "$target_user_only" = "no" -a "$check_gfx" = "yes" \
682         -a "$sdl" = "no" -a "$cocoa" = "no" ; then
683     echo "ERROR: QEMU requires SDL or Cocoa for graphical output"
684     echo "To build QEMU with graphical output configure with --disable-gfx-check"
685     echo "Note that this will disable all output from the virtual graphics card."
686     exit 1;
687 fi
688
689 #echo "Creating $config_mak, $config_h and $target_dir/Makefile"
690
691 mkdir -p $target_dir
692 mkdir -p $target_dir/fpu
693 if test "$target" = "arm-user" -o "$target" = "armeb-user" ; then
694   mkdir -p $target_dir/nwfpe
695 fi
696 if test "$target_user_only" = "no" ; then
697   mkdir -p $target_dir/slirp
698 fi
699
700 ln -sf $source_path/Makefile.target $target_dir/Makefile
701
702 echo "# Automatically generated by configure - do not modify" > $config_mak
703 echo "/* Automatically generated by configure - do not modify */" > $config_h
704
705
706 echo "include ../config-host.mak" >> $config_mak
707 echo "#include \"../config-host.h\"" >> $config_h
708
709 interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_cpu/g"`
710 echo "#define CONFIG_QEMU_PREFIX \"$interp_prefix1\"" >> $config_h
711
712 if test "$target_cpu" = "i386" ; then
713   echo "TARGET_ARCH=i386" >> $config_mak
714   echo "#define TARGET_ARCH \"i386\"" >> $config_h
715   echo "#define TARGET_I386 1" >> $config_h
716   if test $kqemu = "yes" -a "$target_softmmu" = "yes" -a $cpu = "i386" ; then
717     echo "#define USE_KQEMU 1" >> $config_h
718   fi
719 elif test "$target_cpu" = "arm" -o "$target_cpu" = "armeb" ; then
720   echo "TARGET_ARCH=arm" >> $config_mak
721   echo "#define TARGET_ARCH \"arm\"" >> $config_h
722   echo "#define TARGET_ARM 1" >> $config_h
723 elif test "$target_cpu" = "sparc" ; then
724   echo "TARGET_ARCH=sparc" >> $config_mak
725   echo "#define TARGET_ARCH \"sparc\"" >> $config_h
726   echo "#define TARGET_SPARC 1" >> $config_h
727 elif test "$target_cpu" = "sparc64" ; then
728   echo "TARGET_ARCH=sparc64" >> $config_mak
729   echo "#define TARGET_ARCH \"sparc64\"" >> $config_h
730   echo "#define TARGET_SPARC 1" >> $config_h
731   echo "#define TARGET_SPARC64 1" >> $config_h
732 elif test "$target_cpu" = "ppc" ; then
733   echo "TARGET_ARCH=ppc" >> $config_mak
734   echo "#define TARGET_ARCH \"ppc\"" >> $config_h
735   echo "#define TARGET_PPC 1" >> $config_h
736 elif test "$target_cpu" = "ppc64" ; then
737   echo "TARGET_ARCH=ppc64" >> $config_mak
738   echo "#define TARGET_ARCH \"ppc64\"" >> $config_h
739   echo "#define TARGET_PPC 1" >> $config_h
740   echo "#define TARGET_PPC64 1" >> $config_h
741 elif test "$target_cpu" = "x86_64" ; then
742   echo "TARGET_ARCH=x86_64" >> $config_mak
743   echo "#define TARGET_ARCH \"x86_64\"" >> $config_h
744   echo "#define TARGET_I386 1" >> $config_h
745   echo "#define TARGET_X86_64 1" >> $config_h
746   if test $kqemu = "yes" -a "$target_softmmu" = "yes" -a $cpu = "x86_64"  ; then
747     echo "#define USE_KQEMU 1" >> $config_h
748   fi
749 elif test "$target_cpu" = "mips" -o "$target_cpu" = "mipsel" ; then
750   echo "TARGET_ARCH=mips" >> $config_mak
751   echo "#define TARGET_ARCH \"mips\"" >> $config_h
752   echo "#define TARGET_MIPS 1" >> $config_h
753 else
754   echo "Unsupported target CPU"
755   exit 1
756 fi
757 if test "$target_bigendian" = "yes" ; then
758   echo "TARGET_WORDS_BIGENDIAN=yes" >> $config_mak
759   echo "#define TARGET_WORDS_BIGENDIAN 1" >> $config_h
760 fi
761 if test "$target_softmmu" = "yes" ; then
762   echo "CONFIG_SOFTMMU=yes" >> $config_mak
763   echo "#define CONFIG_SOFTMMU 1" >> $config_h
764 fi
765 if test "$target_user_only" = "yes" ; then
766   echo "CONFIG_USER_ONLY=yes" >> $config_mak
767   echo "#define CONFIG_USER_ONLY 1" >> $config_h
768 fi
769
770 if test "$target_cpu" = "arm" -o "$target_cpu" = "armeb" ; then
771   echo "CONFIG_SOFTFLOAT=yes" >> $config_mak
772   echo "#define CONFIG_SOFTFLOAT 1" >> $config_h
773 fi
774 # sdl defines
775
776 if test "$target_user_only" = "no"; then
777     if test "$target_softmmu" = "no" -o "$static" = "yes"; then
778         sdl1=$sdl_static
779     else
780         sdl1=$sdl
781     fi
782     if test "$sdl1" = "yes" ; then
783         echo "#define CONFIG_SDL 1" >> $config_h
784         echo "CONFIG_SDL=yes" >> $config_mak
785         if test "$target_softmmu" = "no" -o "$static" = "yes"; then
786             echo "SDL_LIBS=$sdl_static_libs" >> $config_mak
787         else
788             echo "SDL_LIBS=`$sdl_config --libs`" >> $config_mak
789         fi
790         echo -n "SDL_CFLAGS=`$sdl_config --cflags`" >> $config_mak
791         if [ "${aa}" = "yes" ] ; then
792             echo -n " `aalib-config --cflags`" >> $config_mak ;
793         fi
794         echo "" >> $config_mak
795     fi
796 fi
797
798 if test "$cocoa" = "yes" ; then
799     echo "#define CONFIG_COCOA 1" >> $config_h
800     echo "CONFIG_COCOA=yes" >> $config_mak
801 fi
802
803 done # for target in $targets
804
805 # build tree in object directory if source path is different from current one
806 if test "$source_path_used" = "yes" ; then
807     DIRS="tests"
808     FILES="Makefile tests/Makefile"
809     for dir in $DIRS ; do
810             mkdir -p $dir
811     done
812     for f in $FILES ; do
813         ln -sf $source_path/$f $f
814     done
815 fi
816
817 rm -f $TMPO $TMPC $TMPE $TMPS