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