]> git.proxmox.com Git - mirror_qemu.git/blame - configure
Consistency
[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"
328a4240 25gcc3_search="yes"
fe8f78e4 26gcc3_list="gcc-3.4.6 gcc-3.4 gcc34 gcc-3.3.6 gcc-3.3 gcc33 gcc-3.2 gcc32"
0c58ac1c 27audio_drv_list=""
28audio_card_list=""
7d13299d
FB
29host_cc="gcc"
30ar="ar"
31make="make"
6a882643 32install="install"
7d13299d
FB
33strip="strip"
34cpu=`uname -m`
5327cf48 35target_list=""
7d13299d
FB
36case "$cpu" in
37 i386|i486|i586|i686|i86pc|BePC)
97a847bc 38 cpu="i386"
7d13299d 39 ;;
aaa5fa14
AJ
40 x86_64|amd64)
41 cpu="x86_64"
42 ;;
43 alpha)
44 cpu="alpha"
45 ;;
ba68055e 46 armv*b)
808c4954
FB
47 cpu="armv4b"
48 ;;
ba68055e 49 armv*l)
7d13299d
FB
50 cpu="armv4l"
51 ;;
aaa5fa14
AJ
52 cris)
53 cpu="cris"
7d13299d 54 ;;
f54b3f92
AJ
55 parisc|parisc64)
56 cpu="hppa"
57 ;;
aaa5fa14
AJ
58 ia64)
59 cpu="ia64"
60 ;;
61 m68k)
62 cpu="m68k"
7d13299d
FB
63 ;;
64 mips)
65 cpu="mips"
66 ;;
fbe4f65b
TS
67 mips64)
68 cpu="mips64"
69 ;;
aaa5fa14
AJ
70 "Power Macintosh"|ppc|ppc64)
71 cpu="powerpc"
e7daa605 72 ;;
0e7b8a9f 73 s390*)
fb3e5849
FB
74 cpu="s390"
75 ;;
3142255c 76 sparc|sun4[cdmuv])
ae228531
FB
77 cpu="sparc"
78 ;;
79 sparc64)
80 cpu="sparc64"
81 ;;
7d13299d
FB
82 *)
83 cpu="unknown"
84 ;;
85esac
86gprof="no"
87bigendian="no"
67b915a5
FB
88mingw32="no"
89EXESUF=""
90gdbstub="yes"
443f1376 91slirp="yes"
102a52e4
FB
92fmod_lib=""
93fmod_inc=""
8d5d2d4c 94vnc_tls="yes"
b1a550a0 95bsd="no"
5327cf48 96linux="no"
c9ec1fe4 97kqemu="no"
05c2a3e7 98profiler="no"
5b0753e0 99cocoa="no"
97ccc689 100check_gfx="yes"
1aff381f 101check_gcc="yes"
0a8e90f4 102softmmu="yes"
831b7825
TS
103linux_user="no"
104darwin_user="no"
cc8ae6de 105build_docs="no"
c5937220 106uname_release=""
4d3b6f6e 107curses="yes"
bd0c5661 108nptl="yes"
8ff9cbf7 109mixemu="no"
7d13299d
FB
110
111# OS specific
112targetos=`uname -s`
113case $targetos in
c326e0af
FB
114CYGWIN*)
115mingw32="yes"
6f30fa85 116OS_CFLAGS="-mno-cygwin"
db8d7dd1
TS
117if [ "$cpu" = "i386" ] ; then
118 kqemu="yes"
119fi
c326e0af 120;;
67b915a5
FB
121MINGW32*)
122mingw32="yes"
db8d7dd1
TS
123if [ "$cpu" = "i386" ] ; then
124 kqemu="yes"
125fi
67b915a5 126;;
5c40d2bd 127GNU/kFreeBSD)
0c58ac1c 128audio_drv_list="oss"
5c40d2bd
TS
129if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
130 kqemu="yes"
131fi
132;;
7d3505c5
FB
133FreeBSD)
134bsd="yes"
0c58ac1c 135audio_drv_list="oss"
e99f9060 136if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
07f4ddbf
FB
137 kqemu="yes"
138fi
7d3505c5
FB
139;;
140NetBSD)
141bsd="yes"
0c58ac1c 142audio_drv_list="oss"
7d3505c5
FB
143;;
144OpenBSD)
145bsd="yes"
0c58ac1c 146audio_drv_list="oss"
7d3505c5 147;;
83fb7adf
FB
148Darwin)
149bsd="yes"
150darwin="yes"
831b7825 151darwin_user="yes"
fd677642 152cocoa="yes"
0c58ac1c 153audio_drv_list="coreaudio"
6f30fa85 154OS_CFLAGS="-mdynamic-no-pic"
c2c59c3e 155OS_LDFLAGS="-framework CoreFoundation -framework IOKit"
83fb7adf 156;;
ec530c81 157SunOS)
c2b84fab
TS
158 solaris="yes"
159 make="gmake"
160 install="ginstall"
0475a5ca 161 needs_libsunmath="no"
c2b84fab 162 solarisrev=`uname -r | cut -f2 -d.`
ef18c883
TS
163 # have to select again, because `uname -m` returns i86pc
164 # even on an x86_64 box.
165 solariscpu=`isainfo -k`
166 if test "${solariscpu}" = "amd64" ; then
167 cpu="x86_64"
168 fi
c2b84fab 169 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
0475a5ca
TS
170 if test "$solarisrev" -le 9 ; then
171 if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
172 needs_libsunmath="yes"
173 else
174 echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
175 echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
176 echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
177 echo "Studio 11 can be downloaded from www.sun.com."
178 exit 1
179 fi
180 fi
181 if test "$solarisrev" -ge 9 ; then
c2b84fab
TS
182 kqemu="yes"
183 fi
86b2bd93 184 fi
6b4d2ba1 185 if test -f /usr/include/sys/soundcard.h ; then
0c58ac1c 186 audio_drv_list="oss"
6b4d2ba1 187 fi
86b2bd93 188;;
1d14ffa9 189*)
0c58ac1c 190audio_drv_list="oss"
5327cf48 191linux="yes"
831b7825 192linux_user="yes"
07f4ddbf 193if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
c9ec1fe4
FB
194 kqemu="yes"
195fi
fb065187 196;;
7d13299d
FB
197esac
198
7d3505c5 199if [ "$bsd" = "yes" ] ; then
b1a550a0 200 if [ "$darwin" != "yes" ] ; then
83fb7adf
FB
201 make="gmake"
202 fi
7d3505c5
FB
203fi
204
7d13299d 205# find source path
ad064840 206source_path=`dirname "$0"`
59faef3a
AZ
207source_path_used="no"
208workdir=`pwd`
ad064840 209if [ -z "$source_path" ]; then
59faef3a 210 source_path=$workdir
ad064840
PB
211else
212 source_path=`cd "$source_path"; pwd`
7d13299d 213fi
724db118 214[ -f "$workdir/vl.c" ] || source_path_used="yes"
7d13299d 215
85aa5189 216werror="no"
0d1e2394
FB
217# generate compile errors on warnings for development builds
218#if grep cvs $source_path/VERSION > /dev/null 2>&1 ; then
219#werror="yes";
220#fi
85aa5189 221
7d13299d 222for opt do
a46e4035 223 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
7d13299d 224 case "$opt" in
2efc3265
FB
225 --help|-h) show_help=yes
226 ;;
b1a550a0 227 --prefix=*) prefix="$optarg"
7d13299d 228 ;;
b1a550a0 229 --interp-prefix=*) interp_prefix="$optarg"
32ce6337 230 ;;
b1a550a0 231 --source-path=*) source_path="$optarg"
ad064840 232 source_path_used="yes"
7d13299d 233 ;;
b1a550a0 234 --cross-prefix=*) cross_prefix="$optarg"
7d13299d 235 ;;
b1a550a0 236 --cc=*) cc="$optarg"
328a4240 237 gcc3_search="no"
7d13299d 238 ;;
b1a550a0 239 --host-cc=*) host_cc="$optarg"
83469015 240 ;;
b1a550a0 241 --make=*) make="$optarg"
7d13299d 242 ;;
6a882643
PB
243 --install=*) install="$optarg"
244 ;;
b1a550a0 245 --extra-cflags=*) CFLAGS="$optarg"
7d13299d 246 ;;
b1a550a0 247 --extra-ldflags=*) LDFLAGS="$optarg"
7d13299d 248 ;;
b1a550a0 249 --cpu=*) cpu="$optarg"
7d13299d 250 ;;
b1a550a0 251 --target-list=*) target_list="$optarg"
de83cd02 252 ;;
7d13299d
FB
253 --enable-gprof) gprof="yes"
254 ;;
43ce4dfe
FB
255 --static) static="yes"
256 ;;
97a847bc
FB
257 --disable-sdl) sdl="no"
258 ;;
0c58ac1c 259 --fmod-lib=*) fmod_lib="$optarg"
1d14ffa9 260 ;;
0c58ac1c 261 --audio-card-list=*) audio_card_list="$optarg"
102a52e4 262 ;;
0c58ac1c 263 --audio-drv-list=*) audio_drv_list="$optarg"
102a52e4 264 ;;
b1a550a0 265 --fmod-inc=*) fmod_inc="$optarg"
102a52e4 266 ;;
8d5d2d4c
TS
267 --disable-vnc-tls) vnc_tls="no"
268 ;;
b93aebec 269 --enable-mingw32) mingw32="yes" ; cross_prefix="i386-mingw32-" ; linux_user="no"
1d14ffa9 270 ;;
443f1376 271 --disable-slirp) slirp="no"
1d14ffa9 272 ;;
c9ec1fe4 273 --disable-kqemu) kqemu="no"
1d14ffa9 274 ;;
2e4d9fb1
AJ
275 --disable-brlapi) brlapi="no"
276 ;;
05c2a3e7
FB
277 --enable-profiler) profiler="yes"
278 ;;
0c58ac1c 279 --enable-cocoa) cocoa="yes" ; sdl="no" ;
1d14ffa9 280 ;;
97ccc689
FB
281 --disable-gfx-check) check_gfx="no"
282 ;;
1aff381f
FB
283 --disable-gcc-check) check_gcc="no"
284 ;;
cad25d69 285 --disable-system) softmmu="no"
0a8e90f4 286 ;;
cad25d69 287 --enable-system) softmmu="yes"
0a8e90f4 288 ;;
831b7825 289 --disable-linux-user) linux_user="no"
0a8e90f4 290 ;;
831b7825
TS
291 --enable-linux-user) linux_user="yes"
292 ;;
293 --disable-darwin-user) darwin_user="no"
294 ;;
295 --enable-darwin-user) darwin_user="yes"
0a8e90f4 296 ;;
c5937220
PB
297 --enable-uname-release=*) uname_release="$optarg"
298 ;;
3142255c
BS
299 --sparc_cpu=*)
300 sparc_cpu="$optarg"
301 case $sparc_cpu in
302 v7|v8) SP_CFLAGS="-m32 -mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__"; SP_LDFLAGS="-m32"
303 target_cpu="sparc"; cpu="sparc" ;;
304 v8plus|v8plusa) SP_CFLAGS="-m32 -mcpu=ultrasparc -D__sparc_${sparc_cpu}__"; SP_LDFLAGS="-m32"
305 target_cpu="sparc"; cpu="sparc" ;;
306 v9) SP_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_${sparc_cpu}__"; SP_LDFLAGS="-m64"
307 target_cpu="sparc64"; cpu="sparc64" ;;
308 *) echo "undefined SPARC architecture. Exiting";exit 1;;
309 esac
310 ;;
85aa5189
FB
311 --enable-werror) werror="yes"
312 ;;
313 --disable-werror) werror="no"
314 ;;
4d3b6f6e
AZ
315 --disable-curses) curses="no"
316 ;;
bd0c5661
PB
317 --disable-nptl) nptl="no"
318 ;;
8ff9cbf7 319 --enable-mixemu) mixemu="yes"
320 ;;
7f1559c6
AZ
321 *) echo "ERROR: unknown option $opt"; show_help="yes"
322 ;;
7d13299d
FB
323 esac
324done
325
209afb9e
TS
326if [ "$bsd" = "yes" -o "$darwin" = "yes" -o "$mingw32" = "yes" ] ; then
327 AIOLIBS=
328else
4259e1a5
TS
329 # Some Linux architectures (e.g. s390) don't imply -lpthread automatically.
330 AIOLIBS="-lrt -lpthread"
209afb9e
TS
331fi
332
6f30fa85
TS
333# default flags for all hosts
334CFLAGS="$CFLAGS -Wall -O2 -g -fno-strict-aliasing"
335LDFLAGS="$LDFLAGS -g"
85aa5189
FB
336if test "$werror" = "yes" ; then
337CFLAGS="$CFLAGS -Werror"
338fi
6f30fa85 339
3142255c
BS
340#
341# If cpu ~= sparc and sparc_cpu hasn't been defined, plug in the right
342# ARCH_CFLAGS/ARCH_LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
343#
40293e58 344case "$cpu" in
3142255c
BS
345 sparc) if test -z "$sparc_cpu" ; then
346 ARCH_CFLAGS="-m32 -mcpu=ultrasparc -D__sparc_v8plus__"
347 ARCH_LDFLAGS="-m32"
348 else
349 ARCH_CFLAGS="${SP_CFLAGS}"
350 ARCH_LDFLAGS="${SP_LDFLAGS}"
351 fi
352 ;;
353 sparc64) if test -z "$sparc_cpu" ; then
354 ARCH_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__"
355 ARCH_LDFLAGS="-m64"
356 else
357 ARCH_CFLAGS="${SP_CFLAGS}"
358 ARCH_LDFLAGS="${SP_LDFLAGS}"
359 fi
360 ;;
76d83bde
TS
361 s390)
362 ARCH_CFLAGS="-march=z900"
363 ;;
40293e58
FB
364 i386)
365 ARCH_CFLAGS="-m32"
366 ARCH_LDFLAGS="-m32"
367 ;;
368 x86_64)
369 ARCH_CFLAGS="-m64"
370 ARCH_LDFLAGS="-m64"
371 ;;
3142255c
BS
372esac
373
af5db58e
PB
374if test x"$show_help" = x"yes" ; then
375cat << EOF
376
377Usage: configure [options]
378Options: [defaults in brackets after descriptions]
379
380EOF
381echo "Standard options:"
382echo " --help print this message"
383echo " --prefix=PREFIX install in PREFIX [$prefix]"
384echo " --interp-prefix=PREFIX where to find shared libraries, etc."
385echo " use %M for cpu name [$interp_prefix]"
386echo " --target-list=LIST set target list [$target_list]"
387echo ""
388echo "kqemu kernel acceleration support:"
389echo " --disable-kqemu disable kqemu support"
af5db58e
PB
390echo ""
391echo "Advanced options (experts only):"
392echo " --source-path=PATH path of source code [$source_path]"
393echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
394echo " --cc=CC use C compiler CC [$cc]"
395echo " --host-cc=CC use C compiler CC [$host_cc] for dyngen etc."
396echo " --make=MAKE use specified make [$make]"
6a882643 397echo " --install=INSTALL use specified install [$install]"
af5db58e 398echo " --static enable static build [$static]"
85aa5189 399echo " --disable-werror disable compilation abort on warning"
fe8f78e4 400echo " --disable-sdl disable SDL"
af5db58e
PB
401echo " --enable-cocoa enable COCOA (Mac OS X only)"
402echo " --enable-mingw32 enable Win32 cross compilation with mingw32"
0c58ac1c 403echo " --audio-drv-list set audio drivers list"
404echo " --audio-card-list set list of additional emulated audio cards"
8ff9cbf7 405echo " --enable-mixemu enable mixer emulation"
2e4d9fb1 406echo " --disable-brlapi disable BrlAPI"
8d5d2d4c 407echo " --disable-vnc-tls disable TLS encryption for VNC server"
af896aaa 408echo " --disable-curses disable curses output"
bd0c5661 409echo " --disable-nptl disable usermode NPTL support"
af5db58e
PB
410echo " --enable-system enable all system emulation targets"
411echo " --disable-system disable all system emulation targets"
831b7825
TS
412echo " --enable-linux-user enable all linux usermode emulation targets"
413echo " --disable-linux-user disable all linux usermode emulation targets"
414echo " --enable-darwin-user enable all darwin usermode emulation targets"
415echo " --disable-darwin-user disable all darwin usermode emulation targets"
af5db58e
PB
416echo " --fmod-lib path to FMOD library"
417echo " --fmod-inc path to FMOD includes"
c5937220 418echo " --enable-uname-release=R Return R for uname -r in usermode emulation"
3142255c 419echo " --sparc_cpu=V Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
af5db58e 420echo ""
5bf08934 421echo "NOTE: The object files are built at the place where configure is launched"
af5db58e
PB
422exit 1
423fi
424
7d13299d
FB
425cc="${cross_prefix}${cc}"
426ar="${cross_prefix}${ar}"
427strip="${cross_prefix}${strip}"
428
064aae13
PB
429# check that the C compiler works.
430cat > $TMPC <<EOF
431int main(void) {}
432EOF
433
db7287ed 434if $cc $ARCH_CFLAGS -c -o $TMPO $TMPC 2> /dev/null ; then
064aae13
PB
435 : C compiler works ok
436else
437 echo "ERROR: \"$cc\" either does not exist or does not work"
438 exit 1
a7350fa1
FB
439fi
440
67b915a5 441if test "$mingw32" = "yes" ; then
5327cf48 442 linux="no"
67b915a5 443 EXESUF=".exe"
9f059eca 444 oss="no"
67b915a5
FB
445fi
446
5fafdf24 447# Check for gcc4, error if pre-gcc4
328a4240
PB
448if test "$check_gcc" = "yes" ; then
449 cat > $TMPC <<EOF
450#if __GNUC__ < 4
451#error gcc3
452#endif
453int main(){return 0;}
454EOF
db7287ed 455 if "$cc" $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
328a4240
PB
456 echo "WARNING: \"$cc\" looks like gcc 4.x"
457 found_compat_cc="no"
458 if test "$gcc3_search" = "yes" ; then
459 echo "Looking for gcc 3.x"
460 for compat_cc in $gcc3_list ; do
d4af3de2 461 if "$cross_prefix$compat_cc" --version 2> /dev/null | fgrep '(GCC) 3.' > /dev/null 2>&1 ; then
328a4240 462 echo "Found \"$compat_cc\""
1124426a 463 cc="$cross_prefix$compat_cc"
328a4240
PB
464 found_compat_cc="yes"
465 break
466 fi
467 done
468 if test "$found_compat_cc" = "no" ; then
469 echo "gcc 3.x not found!"
470 fi
471 fi
472 if test "$found_compat_cc" = "no" ; then
473 echo "QEMU is known to have problems when compiled with gcc 4.x"
474 echo "It is recommended that you use gcc 3.x to build QEMU"
475 echo "To use this compiler anyway, configure with --disable-gcc-check"
476 exit 1;
477 fi
478 fi
479fi
480
ec530c81
FB
481#
482# Solaris specific configure tool chain decisions
483#
484if test "$solaris" = "yes" ; then
485 #
486 # gcc for solaris 10/fcs in /usr/sfw/bin doesn't compile qemu correctly
487 # override the check with --disable-gcc-check
5fafdf24 488 #
ec530c81
FB
489 if test "$solarisrev" -eq 10 -a "$check_gcc" = "yes" ; then
490 solgcc=`which $cc`
491 if test "$solgcc" = "/usr/sfw/bin/gcc" ; then
492 echo "Solaris 10/FCS gcc in /usr/sfw/bin will not compiled qemu correctly."
493 echo "please get gcc-3.4.3 or later, from www.blastwave.org using pkg-get -i gcc3"
494 echo "or get the latest patch from SunSolve for gcc"
495 exit 1
496 fi
497 fi
498 solinst=`which $install 2> /dev/null | /usr/bin/grep -v "no $install in"`
499 if test -z "$solinst" ; then
500 echo "Solaris install program not found. Use --install=/usr/ucb/install or"
501 echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
502 echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
503 exit 1
504 fi
505 if test "$solinst" = "/usr/sbin/install" ; then
506 echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
507 echo "try ginstall from the GNU fileutils available from www.blastwave.org"
508 echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
509 exit 1
510 fi
ec530c81
FB
511 sol_ar=`which ar 2> /dev/null | /usr/bin/grep -v "no ar in"`
512 if test -z "$sol_ar" ; then
513 echo "Error: No path includes ar"
514 if test -f /usr/ccs/bin/ar ; then
515 echo "Add /usr/ccs/bin to your path and rerun configure"
516 fi
517 exit 1
518 fi
5fafdf24 519fi
ec530c81
FB
520
521
5327cf48
FB
522if test -z "$target_list" ; then
523# these targets are portable
0a8e90f4 524 if [ "$softmmu" = "yes" ] ; then
2408a527
AJ
525 target_list="\
526i386-softmmu \
527x86_64-softmmu \
528arm-softmmu \
529cris-softmmu \
530m68k-softmmu \
531mips-softmmu \
532mipsel-softmmu \
533mips64-softmmu \
534mips64el-softmmu \
535ppc-softmmu \
536ppcemb-softmmu \
537ppc64-softmmu \
538sh4-softmmu \
539sh4eb-softmmu \
540sparc-softmmu \
541"
0a8e90f4 542 fi
5327cf48 543# the following are Linux specific
831b7825 544 if [ "$linux_user" = "yes" ] ; then
2408a527
AJ
545 target_list="${target_list}\
546i386-linux-user \
547x86_64-linux-user \
548alpha-linux-user \
549arm-linux-user \
550armeb-linux-user \
551cris-linux-user \
552m68k-linux-user \
553mips-linux-user \
554mipsel-linux-user \
555ppc-linux-user \
556ppc64-linux-user \
557ppc64abi32-linux-user \
558sh4-linux-user \
559sh4eb-linux-user \
560sparc-linux-user \
561sparc64-linux-user \
562sparc32plus-linux-user \
563"
831b7825
TS
564 fi
565# the following are Darwin specific
566 if [ "$darwin_user" = "yes" ] ; then
2408a527 567 target_list="$target_list i386-darwin-user ppc-darwin-user"
5327cf48 568 fi
6e20a45f 569else
b1a550a0 570 target_list=`echo "$target_list" | sed -e 's/,/ /g'`
5327cf48 571fi
0a8e90f4
PB
572if test -z "$target_list" ; then
573 echo "No targets enabled"
574 exit 1
575fi
5327cf48 576
7d13299d
FB
577if test -z "$cross_prefix" ; then
578
579# ---
580# big/little endian test
581cat > $TMPC << EOF
582#include <inttypes.h>
583int main(int argc, char ** argv){
1d14ffa9
FB
584 volatile uint32_t i=0x01234567;
585 return (*((uint8_t*)(&i))) == 0x67;
7d13299d
FB
586}
587EOF
588
db7287ed 589if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
7d13299d
FB
590$TMPE && bigendian="yes"
591else
592echo big/little test failed
593fi
594
595else
596
597# if cross compiling, cannot launch a program, so make a static guess
0938cda5 598if test "$cpu" = "armv4b" \
f54b3f92 599 -o "$cpu" = "hppa" \
0938cda5
AJ
600 -o "$cpu" = "m68k" \
601 -o "$cpu" = "mips" \
602 -o "$cpu" = "mips64" \
603 -o "$cpu" = "powerpc" \
604 -o "$cpu" = "s390" \
605 -o "$cpu" = "sparc" \
606 -o "$cpu" = "sparc64"; then
7d13299d
FB
607 bigendian="yes"
608fi
609
610fi
611
b6853697
FB
612# host long bits test
613hostlongbits="32"
0938cda5
AJ
614if test "$cpu" = "x86_64" \
615 -o "$cpu" = "alpha" \
616 -o "$cpu" = "ia64" \
617 -o "$cpu" = "sparc64"; then
b6853697
FB
618 hostlongbits="64"
619fi
620
e8cd23de 621# check gcc options support
04369ff2
FB
622cat > $TMPC <<EOF
623int main(void) {
04369ff2
FB
624}
625EOF
626
bd0c5661
PB
627# Check host NPTL support
628cat > $TMPC <<EOF
629#include <sched.h>
30813cea 630#include <linux/futex.h>
bd0c5661
PB
631void foo()
632{
633#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
634#error bork
635#endif
636}
637EOF
638
639if $cc $ARCH_CFLAGS -c -o $TMPO $TMPC 2> /dev/null ; then
640 :
641else
642 nptl="no"
643fi
644
11d9f695
FB
645##########################################
646# SDL probe
647
648sdl_too_old=no
649
650if test -z "$sdl" ; then
069b0bda
TS
651 sdl_config="sdl-config"
652 sdl=no
653 sdl_static=no
654
655 if test "$mingw32" = "yes" -a ! -z "$cross_prefix" ; then
656 # win32 cross compilation case
657 sdl_config="i386-mingw32msvc-sdl-config"
658 sdl=yes
659 else
660 # normal SDL probe
11d9f695
FB
661cat > $TMPC << EOF
662#include <SDL.h>
663#undef main /* We don't want SDL to override our main() */
664int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
665EOF
db7287ed 666 if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} `$sdl_config --cflags 2> /dev/null` $TMPC `$sdl_config --libs 2> /dev/null` 2> /tmp/qemu-$$-sdl-config.log ; then
069b0bda
TS
667 _sdlversion=`$sdl_config --version | sed 's/[^0-9]//g'`
668 if test "$_sdlversion" -lt 121 ; then
669 sdl_too_old=yes
670 else
671 if test "$cocoa" = "no" ; then
672 sdl=yes
673 fi
674 fi
11d9f695 675
069b0bda
TS
676 # static link with sdl ?
677 if test "$sdl" = "yes" ; then
678 aa="no"
679 `$sdl_config --static-libs 2>/dev/null | grep \\\-laa > /dev/null` && aa="yes"
680 sdl_static_libs=`$sdl_config --static-libs 2>/dev/null`
681 if [ "$aa" = "yes" ] ; then
682 sdl_static_libs="$sdl_static_libs `aalib-config --static-libs`"
683 fi
684
8281db4d 685 if $cc -o $TMPE ${OS_CFLAGS} `$sdl_config --cflags 2> /dev/null` $TMPC $sdl_static_libs 2> /dev/null; then
069b0bda
TS
686 sdl_static=yes
687 fi
688 fi # static link
689 fi # sdl compile test
690 fi # cross compilation
fd677642 691else
069b0bda
TS
692 # Make sure to disable cocoa if sdl was set
693 if test "$sdl" = "yes" ; then
694 cocoa="no"
0c58ac1c 695 audio_drv_list="echo $audio_drv_list | sed s,coreaudio,,g"
069b0bda 696 fi
a6e022ad 697fi # -z $sdl
11d9f695 698
8d5d2d4c
TS
699##########################################
700# VNC TLS detection
701if test "$vnc_tls" = "yes" ; then
702 `pkg-config gnutls` || vnc_tls="no"
703fi
704if test "$vnc_tls" = "yes" ; then
705 vnc_tls_cflags=`pkg-config --cflags gnutls`
706 vnc_tls_libs=`pkg-config --libs gnutls`
707fi
708
8f28f3fb
TS
709##########################################
710# alsa sound support libraries
711
712if test "$alsa" = "yes" ; then
713 cat > $TMPC << EOF
714#include <alsa/asoundlib.h>
715int main(void) { snd_pcm_t **handle; return snd_pcm_close(*handle); }
716EOF
db7287ed 717 if $cc $ARCH_CFLAGS -o $TMPE $TMPC -lasound 2> /dev/null ; then
8f28f3fb
TS
718 :
719 else
720 echo
721 echo "Error: Could not find alsa"
722 echo "Make sure to have the alsa libs and headers installed."
723 echo
724 exit 1
725 fi
726fi
727
2e4d9fb1
AJ
728##########################################
729# BrlAPI probe
730
731if test -z "$brlapi" ; then
732 brlapi=no
733cat > $TMPC << EOF
734#include <brlapi.h>
735int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
736EOF
a40e56d5 737 if $cc ${ARCH_CFLAGS} -o $TMPE ${OS_CFLAGS} $TMPC -lbrlapi 2> /dev/null ; then
2e4d9fb1
AJ
738 brlapi=yes
739 fi # brlapi compile test
740fi # -z $brlapi
741
4d3b6f6e
AZ
742##########################################
743# curses probe
744
745if test "$curses" = "yes" ; then
746 curses=no
747 cat > $TMPC << EOF
748#include <curses.h>
749int main(void) { return curses_version(); }
750EOF
af896aaa 751 if $cc $ARCH_CFLAGS -o $TMPE $TMPC -lcurses 2> /dev/null ; then
4d3b6f6e
AZ
752 curses=yes
753 fi
754fi # test "$curses"
755
cc8ae6de 756# Check if tools are available to build documentation.
6c591867
TS
757if [ -x "`which texi2html 2>/dev/null`" ] && \
758 [ -x "`which pod2man 2>/dev/null`" ]; then
cc8ae6de
PB
759 build_docs="yes"
760fi
761
11d9f695 762if test "$mingw32" = "yes" ; then
308c3593
PB
763 if test -z "$prefix" ; then
764 prefix="/c/Program Files/Qemu"
765 fi
766 mansuffix=""
767 datasuffix=""
768 docsuffix=""
769 binsuffix=""
11d9f695 770else
308c3593
PB
771 if test -z "$prefix" ; then
772 prefix="/usr/local"
773 fi
774 mansuffix="/share/man"
775 datasuffix="/share/qemu"
776 docsuffix="/share/doc/qemu"
777 binsuffix="/bin"
11d9f695 778fi
5a67135a 779
43ce4dfe 780echo "Install prefix $prefix"
308c3593
PB
781echo "BIOS directory $prefix$datasuffix"
782echo "binary directory $prefix$binsuffix"
11d9f695 783if test "$mingw32" = "no" ; then
308c3593 784echo "Manual directory $prefix$mansuffix"
43ce4dfe 785echo "ELF interp prefix $interp_prefix"
11d9f695 786fi
5a67135a 787echo "Source path $source_path"
43ce4dfe 788echo "C compiler $cc"
83469015 789echo "Host C compiler $host_cc"
db7287ed 790echo "ARCH_CFLAGS $ARCH_CFLAGS"
43ce4dfe 791echo "make $make"
6a882643 792echo "install $install"
43ce4dfe 793echo "host CPU $cpu"
de83cd02 794echo "host big endian $bigendian"
97a847bc 795echo "target list $target_list"
43ce4dfe 796echo "gprof enabled $gprof"
05c2a3e7 797echo "profiler $profiler"
43ce4dfe 798echo "static build $static"
85aa5189 799echo "-Werror enabled $werror"
5b0753e0
FB
800if test "$darwin" = "yes" ; then
801 echo "Cocoa support $cocoa"
802fi
97a847bc 803echo "SDL support $sdl"
e4afee97
FB
804if test "$sdl" != "no" ; then
805 echo "SDL static link $sdl_static"
806fi
4d3b6f6e 807echo "curses support $curses"
67b915a5 808echo "mingw32 support $mingw32"
0c58ac1c 809echo "Audio drivers $audio_drv_list"
810echo "Extra audio cards $audio_card_list"
8ff9cbf7 811echo "Mixer emulation $mixemu"
1d14ffa9
FB
812if test "$fmod" = "yes"; then
813 if test -z $fmod_lib || test -z $fmod_inc; then
814 echo
815 echo "Error: You must specify path to FMOD library and headers"
816 echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
817 echo
818 exit 1
819 fi
b1a550a0
PB
820 fmod_support=" (lib='$fmod_lib' include='$fmod_inc')"
821else
822 fmod_support=""
102a52e4 823fi
b1a550a0 824echo "FMOD support $fmod $fmod_support"
6b4d2ba1 825echo "OSS support $oss"
8d5d2d4c
TS
826echo "VNC TLS support $vnc_tls"
827if test "$vnc_tls" = "yes" ; then
828 echo " TLS CFLAGS $vnc_tls_cflags"
829 echo " TLS LIBS $vnc_tls_libs"
830fi
3142255c
BS
831if test -n "$sparc_cpu"; then
832 echo "Target Sparc Arch $sparc_cpu"
833fi
07f4ddbf 834echo "kqemu support $kqemu"
2e4d9fb1 835echo "brlapi support $brlapi"
cc8ae6de 836echo "Documentation $build_docs"
c5937220
PB
837[ ! -z "$uname_release" ] && \
838echo "uname -r $uname_release"
bd0c5661 839echo "NPTL support $nptl"
67b915a5 840
97a847bc 841if test $sdl_too_old = "yes"; then
24b55b96 842echo "-> Your SDL version is too old - please upgrade to have SDL support"
7c1f25b4 843fi
20b40c6a
TS
844if [ -s /tmp/qemu-$$-sdl-config.log ]; then
845 echo "The error log from compiling the libSDL test is: "
846 cat /tmp/qemu-$$-sdl-config.log
847fi
848rm -f /tmp/qemu-$$-sdl-config.log
24b55b96
FB
849#if test "$sdl_static" = "no"; then
850# echo "WARNING: cannot compile statically with SDL - qemu-fast won't have a graphical output"
851#fi
97a847bc
FB
852config_mak="config-host.mak"
853config_h="config-host.h"
7d13299d 854
7c1f25b4 855#echo "Creating $config_mak and $config_h"
7d13299d 856
15d9ca0f
TS
857test -f $config_h && mv $config_h ${config_h}~
858
97a847bc 859echo "# Automatically generated by configure - do not modify" > $config_mak
29517134 860echo "# Configured with: $0 $@" >> $config_mak
97a847bc 861echo "/* Automatically generated by configure - do not modify */" > $config_h
7d13299d 862
97a847bc 863echo "prefix=$prefix" >> $config_mak
308c3593
PB
864echo "bindir=\${prefix}$binsuffix" >> $config_mak
865echo "mandir=\${prefix}$mansuffix" >> $config_mak
866echo "datadir=\${prefix}$datasuffix" >> $config_mak
4ad5b06d 867echo "docdir=\${prefix}$docsuffix" >> $config_mak
308c3593 868echo "#define CONFIG_QEMU_SHAREDIR \"$prefix$datasuffix\"" >> $config_h
97a847bc 869echo "MAKE=$make" >> $config_mak
6a882643 870echo "INSTALL=$install" >> $config_mak
97a847bc 871echo "CC=$cc" >> $config_mak
97a847bc
FB
872echo "HOST_CC=$host_cc" >> $config_mak
873echo "AR=$ar" >> $config_mak
874echo "STRIP=$strip -s -R .comment -R .note" >> $config_mak
40293e58
FB
875# XXX: only use CFLAGS and LDFLAGS ?
876# XXX: should export HOST_CFLAGS and HOST_LDFLAGS for cross
877# compilation of dyngen tool (useful for win32 build on Linux host)
6f30fa85 878echo "OS_CFLAGS=$OS_CFLAGS" >> $config_mak
3142255c
BS
879echo "OS_LDFLAGS=$OS_LDFLAGS" >> $config_mak
880echo "ARCH_CFLAGS=$ARCH_CFLAGS" >> $config_mak
881echo "ARCH_LDFLAGS=$ARCH_LDFLAGS" >> $config_mak
97a847bc
FB
882echo "CFLAGS=$CFLAGS" >> $config_mak
883echo "LDFLAGS=$LDFLAGS" >> $config_mak
67b915a5 884echo "EXESUF=$EXESUF" >> $config_mak
70956b77 885echo "AIOLIBS=$AIOLIBS" >> $config_mak
2408a527
AJ
886case "$cpu" in
887 i386)
888 echo "ARCH=i386" >> $config_mak
889 echo "#define HOST_I386 1" >> $config_h
890 ;;
891 x86_64)
892 echo "ARCH=x86_64" >> $config_mak
893 echo "#define HOST_X86_64 1" >> $config_h
894 ;;
895 alpha)
896 echo "ARCH=alpha" >> $config_mak
897 echo "#define HOST_ALPHA 1" >> $config_h
898 ;;
899 armv4b)
900 echo "ARCH=arm" >> $config_mak
901 echo "#define HOST_ARM 1" >> $config_h
902 ;;
903 armv4l)
904 echo "ARCH=arm" >> $config_mak
905 echo "#define HOST_ARM 1" >> $config_h
906 ;;
907 cris)
908 echo "ARCH=cris" >> $config_mak
909 echo "#define HOST_CRIS 1" >> $config_h
910 ;;
911 hppa)
912 echo "ARCH=hppa" >> $config_mak
913 echo "#define HOST_HPPA 1" >> $config_h
914 ;;
915 ia64)
916 echo "ARCH=ia64" >> $config_mak
917 echo "#define HOST_IA64 1" >> $config_h
918 ;;
919 m68k)
920 echo "ARCH=m68k" >> $config_mak
921 echo "#define HOST_M68K 1" >> $config_h
922 ;;
923 mips)
924 echo "ARCH=mips" >> $config_mak
925 echo "#define HOST_MIPS 1" >> $config_h
926 ;;
927 mips64)
928 echo "ARCH=mips64" >> $config_mak
929 echo "#define HOST_MIPS64 1" >> $config_h
930 ;;
931 powerpc)
932 echo "ARCH=ppc" >> $config_mak
933 echo "#define HOST_PPC 1" >> $config_h
934 ;;
935 s390)
936 echo "ARCH=s390" >> $config_mak
937 echo "#define HOST_S390 1" >> $config_h
938 ;;
939 sparc)
940 echo "ARCH=sparc" >> $config_mak
941 echo "#define HOST_SPARC 1" >> $config_h
942 ;;
943 sparc64)
944 echo "ARCH=sparc64" >> $config_mak
945 echo "#define HOST_SPARC64 1" >> $config_h
946 ;;
947 *)
948 echo "Unsupported CPU = $cpu"
949 exit 1
950 ;;
951esac
7d13299d 952if test "$bigendian" = "yes" ; then
97a847bc
FB
953 echo "WORDS_BIGENDIAN=yes" >> $config_mak
954 echo "#define WORDS_BIGENDIAN 1" >> $config_h
955fi
b6853697 956echo "#define HOST_LONG_BITS $hostlongbits" >> $config_h
67b915a5
FB
957if test "$mingw32" = "yes" ; then
958 echo "CONFIG_WIN32=yes" >> $config_mak
11d9f695 959 echo "#define CONFIG_WIN32 1" >> $config_h
210fa556
PB
960else
961 cat > $TMPC << EOF
962#include <byteswap.h>
963int main(void) { return bswap_32(0); }
964EOF
db7287ed 965 if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
210fa556
PB
966 echo "#define HAVE_BYTESWAP_H 1" >> $config_h
967 fi
67b915a5 968fi
83fb7adf
FB
969if test "$darwin" = "yes" ; then
970 echo "CONFIG_DARWIN=yes" >> $config_mak
971 echo "#define CONFIG_DARWIN 1" >> $config_h
972fi
ec530c81
FB
973if test "$solaris" = "yes" ; then
974 echo "CONFIG_SOLARIS=yes" >> $config_mak
38cfa06c 975 echo "#define HOST_SOLARIS $solarisrev" >> $config_h
0475a5ca
TS
976 if test "$needs_libsunmath" = "yes" ; then
977 echo "NEEDS_LIBSUNMATH=yes" >> $config_mak
978 echo "#define NEEDS_LIBSUNMATH 1" >> $config_h
979 fi
ec530c81 980fi
3142255c
BS
981if test -n "$sparc_cpu"; then
982 echo "CONFIG__sparc_${sparc_cpu}__=yes" >> $config_mak
983 echo "#define __sparc_${sparc_cpu}__ 1" >> $config_h
984fi
67b915a5
FB
985if test "$gdbstub" = "yes" ; then
986 echo "CONFIG_GDBSTUB=yes" >> $config_mak
987 echo "#define CONFIG_GDBSTUB 1" >> $config_h
988fi
97a847bc
FB
989if test "$gprof" = "yes" ; then
990 echo "TARGET_GPROF=yes" >> $config_mak
991 echo "#define HAVE_GPROF 1" >> $config_h
992fi
993if test "$static" = "yes" ; then
994 echo "CONFIG_STATIC=yes" >> $config_mak
50863472 995 echo "#define CONFIG_STATIC 1" >> $config_h
7d13299d 996fi
05c2a3e7
FB
997if test $profiler = "yes" ; then
998 echo "#define CONFIG_PROFILER 1" >> $config_h
999fi
c20709aa
FB
1000if test "$slirp" = "yes" ; then
1001 echo "CONFIG_SLIRP=yes" >> $config_mak
1002 echo "#define CONFIG_SLIRP 1" >> $config_h
1003fi
0c58ac1c 1004for card in $audio_card_list; do
1005 def=CONFIG_`echo $card | tr [:lower:] [:upper:]`
1006 echo "$def=yes" >> $config_mak
1007 echo "#define $def 1" >> $config_h
1008done
1009echo "#define AUDIO_DRIVERS \\" >> $config_h
1010for drv in $audio_drv_list; do
1011 echo " &${drv}_audio_driver, \\" >>$config_h
1012 def=CONFIG_`echo $drv | tr [:lower:] [:upper:]`
1013 echo "$def=yes" >> $config_mak
1014 if test "$drv" == "fmod"; then
1015 echo "CONFIG_FMOD_LIB=$fmod_lib" >> $config_mak
1016 echo "CONFIG_FMOD_INC=$fmod_inc" >> $config_mak
1017 fi
1018done
1019echo "" >>$config_h
8ff9cbf7 1020if test "$mixemu" = "yes" ; then
1021 echo "CONFIG_MIXEMU=yes" >> $config_mak
1022 echo "#define CONFIG_MIXEMU 1" >> $config_h
1023fi
8d5d2d4c
TS
1024if test "$vnc_tls" = "yes" ; then
1025 echo "CONFIG_VNC_TLS=yes" >> $config_mak
1026 echo "CONFIG_VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_mak
1027 echo "CONFIG_VNC_TLS_LIBS=$vnc_tls_libs" >> $config_mak
1028 echo "#define CONFIG_VNC_TLS 1" >> $config_h
1029fi
b1a550a0
PB
1030qemu_version=`head $source_path/VERSION`
1031echo "VERSION=$qemu_version" >>$config_mak
d4b8f039 1032echo "#define QEMU_VERSION \"$qemu_version\"" >> $config_h
97a847bc
FB
1033
1034echo "SRC_PATH=$source_path" >> $config_mak
ad064840
PB
1035if [ "$source_path_used" = "yes" ]; then
1036 echo "VPATH=$source_path" >> $config_mak
1037fi
97a847bc 1038echo "TARGET_DIRS=$target_list" >> $config_mak
cc8ae6de
PB
1039if [ "$build_docs" = "yes" ] ; then
1040 echo "BUILD_DOCS=yes" >> $config_mak
1041fi
49ecc3fa
FB
1042if test "$static" = "yes"; then
1043 sdl1=$sdl_static
1044else
1045 sdl1=$sdl
1046fi
1047if test "$sdl1" = "yes" ; then
1048 echo "#define CONFIG_SDL 1" >> $config_h
1049 echo "CONFIG_SDL=yes" >> $config_mak
1050 if test "$target_softmmu" = "no" -o "$static" = "yes"; then
1051 echo "SDL_LIBS=$sdl_static_libs" >> $config_mak
1052 else
1053 echo "SDL_LIBS=`$sdl_config --libs`" >> $config_mak
1054 fi
1055 if [ "${aa}" = "yes" ] ; then
1056 echo "SDL_CFLAGS=`$sdl_config --cflags` `aalib-config --cflags`" >> $config_mak
1057 else
1058 echo "SDL_CFLAGS=`$sdl_config --cflags`" >> $config_mak
1059 fi
1060fi
1061if test "$cocoa" = "yes" ; then
4d3b6f6e
AZ
1062 echo "#define CONFIG_COCOA 1" >> $config_h
1063 echo "CONFIG_COCOA=yes" >> $config_mak
1064fi
1065if test "$curses" = "yes" ; then
1066 echo "#define CONFIG_CURSES 1" >> $config_h
1067 echo "CONFIG_CURSES=yes" >> $config_mak
1068 echo "CURSES_LIBS=-lcurses" >> $config_mak
49ecc3fa 1069fi
2e4d9fb1
AJ
1070if test "$brlapi" = "yes" ; then
1071 echo "CONFIG_BRLAPI=yes" >> $config_mak
1072 echo "#define CONFIG_BRLAPI 1" >> $config_h
1073 echo "BRLAPI_LIBS=-lbrlapi" >> $config_mak
1074fi
97a847bc 1075
83fb7adf 1076# XXX: suppress that
7d3505c5 1077if [ "$bsd" = "yes" ] ; then
43003046 1078 echo "#define O_LARGEFILE 0" >> $config_h
43003046 1079 echo "#define MAP_ANONYMOUS MAP_ANON" >> $config_h
7d3505c5
FB
1080 echo "#define _BSD 1" >> $config_h
1081fi
1082
c5937220
PB
1083echo "#define CONFIG_UNAME_RELEASE \"$uname_release\"" >> $config_h
1084
c39e3338
PB
1085tools=
1086if test `expr "$target_list" : ".*softmmu.*"` != 0 ; then
1087 tools="qemu-img\$(EXESUF) $tools"
7a5ca864
FB
1088 if [ "$linux" = "yes" ] ; then
1089 tools="qemu-nbd\$(EXESUF) $tools"
1090 fi
c39e3338
PB
1091fi
1092echo "TOOLS=$tools" >> $config_mak
1093
15d9ca0f
TS
1094test -f ${config_h}~ && cmp -s $config_h ${config_h}~ && mv ${config_h}~ $config_h
1095
1d14ffa9 1096for target in $target_list; do
97a847bc
FB
1097target_dir="$target"
1098config_mak=$target_dir/config.mak
1099config_h=$target_dir/config.h
1100target_cpu=`echo $target | cut -d '-' -f 1`
1101target_bigendian="no"
808c4954 1102[ "$target_cpu" = "armeb" ] && target_bigendian=yes
0938cda5
AJ
1103[ "$target_cpu" = "m68k" ] && target_bigendian=yes
1104[ "$target_cpu" = "mips" ] && target_bigendian=yes
1105[ "$target_cpu" = "mipsn32" ] && target_bigendian=yes
1106[ "$target_cpu" = "mips64" ] && target_bigendian=yes
67867308 1107[ "$target_cpu" = "ppc" ] && target_bigendian=yes
d4082e95 1108[ "$target_cpu" = "ppcemb" ] && target_bigendian=yes
22f8a8b3 1109[ "$target_cpu" = "ppc64" ] && target_bigendian=yes
e85e7c6e 1110[ "$target_cpu" = "ppc64abi32" ] && target_bigendian=yes
908f52b0 1111[ "$target_cpu" = "sh4eb" ] && target_bigendian=yes
0938cda5
AJ
1112[ "$target_cpu" = "sparc" ] && target_bigendian=yes
1113[ "$target_cpu" = "sparc64" ] && target_bigendian=yes
1114[ "$target_cpu" = "sparc32plus" ] && target_bigendian=yes
97a847bc 1115target_softmmu="no"
997344f3 1116target_user_only="no"
831b7825 1117target_linux_user="no"
831b7825 1118target_darwin_user="no"
9e407a85
PB
1119case "$target" in
1120 ${target_cpu}-softmmu)
1121 target_softmmu="yes"
1122 ;;
1123 ${target_cpu}-linux-user)
1124 target_user_only="yes"
1125 target_linux_user="yes"
1126 ;;
1127 ${target_cpu}-darwin-user)
1128 target_user_only="yes"
1129 target_darwin_user="yes"
1130 ;;
1131 *)
1132 echo "ERROR: Target '$target' not recognised"
1133 exit 1
1134 ;;
1135esac
831b7825 1136
97ccc689 1137if test "$target_user_only" = "no" -a "$check_gfx" = "yes" \
1d14ffa9 1138 -a "$sdl" = "no" -a "$cocoa" = "no" ; then
97ccc689 1139 echo "ERROR: QEMU requires SDL or Cocoa for graphical output"
9c038506 1140 echo "To build QEMU without graphical output configure with --disable-gfx-check"
4d3b6f6e
AZ
1141 echo "Note that this will disable all output from the virtual graphics card"
1142 echo "except through VNC or curses."
97ccc689
FB
1143 exit 1;
1144fi
1145
7c1f25b4 1146#echo "Creating $config_mak, $config_h and $target_dir/Makefile"
97a847bc 1147
15d9ca0f
TS
1148test -f $config_h && mv $config_h ${config_h}~
1149
97a847bc 1150mkdir -p $target_dir
158142c2 1151mkdir -p $target_dir/fpu
57fec1fe 1152mkdir -p $target_dir/tcg
831b7825 1153if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" ; then
69de927c
FB
1154 mkdir -p $target_dir/nwfpe
1155fi
1156
ec530c81
FB
1157#
1158# don't use ln -sf as not all "ln -sf" over write the file/link
1159#
1160rm -f $target_dir/Makefile
1161ln -s $source_path/Makefile.target $target_dir/Makefile
1162
97a847bc
FB
1163
1164echo "# Automatically generated by configure - do not modify" > $config_mak
1165echo "/* Automatically generated by configure - do not modify */" > $config_h
1166
de83cd02 1167
97a847bc
FB
1168echo "include ../config-host.mak" >> $config_mak
1169echo "#include \"../config-host.h\"" >> $config_h
1e43adfc 1170
e5fe0c52 1171bflt="no"
cb33da57 1172elfload32="no"
bd0c5661 1173target_nptl="no"
1e43adfc
FB
1174interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_cpu/g"`
1175echo "#define CONFIG_QEMU_PREFIX \"$interp_prefix1\"" >> $config_h
97a847bc 1176
2408a527
AJ
1177case "$target_cpu" in
1178 i386)
1179 echo "TARGET_ARCH=i386" >> $config_mak
1180 echo "#define TARGET_ARCH \"i386\"" >> $config_h
1181 echo "#define TARGET_I386 1" >> $config_h
da260249 1182 if test $kqemu = "yes" -a "$target_softmmu" = "yes"
2408a527
AJ
1183 then
1184 echo "#define USE_KQEMU 1" >> $config_h
1185 fi
f2bf094e 1186 gcc3minver=`$cc --version 2> /dev/null| fgrep "(GCC) 3." | awk '{ print $3 }' | cut -f2 -d.`
11d1fdb0 1187 if test -n "$gcc3minver" && test $gcc3minver -gt 3
f2bf094e
AJ
1188 then
1189 echo "HAVE_GT_GCC_3_3=true" >> $config_mak
1190 else
1191 echo "HAVE_GT_GCC_3_3=false" >> $config_mak
1192 fi
2408a527
AJ
1193 ;;
1194 x86_64)
1195 echo "TARGET_ARCH=x86_64" >> $config_mak
1196 echo "#define TARGET_ARCH \"x86_64\"" >> $config_h
1197 echo "#define TARGET_I386 1" >> $config_h
1198 echo "#define TARGET_X86_64 1" >> $config_h
1199 if test $kqemu = "yes" -a "$target_softmmu" = "yes" -a $cpu = "x86_64"
1200 then
1201 echo "#define USE_KQEMU 1" >> $config_h
1202 fi
1203 ;;
1204 alpha)
1205 echo "TARGET_ARCH=alpha" >> $config_mak
bf6247fb 1206 echo "CONFIG_DYNGEN_OP=yes" >> $config_mak
2408a527
AJ
1207 echo "#define TARGET_ARCH \"alpha\"" >> $config_h
1208 echo "#define TARGET_ALPHA 1" >> $config_h
bf6247fb 1209 echo "#define CONFIG_DYNGEN_OP 1" >> $config_h
2408a527
AJ
1210 ;;
1211 arm|armeb)
1212 echo "TARGET_ARCH=arm" >> $config_mak
2408a527
AJ
1213 echo "#define TARGET_ARCH \"arm\"" >> $config_h
1214 echo "#define TARGET_ARM 1" >> $config_h
2408a527 1215 bflt="yes"
bd0c5661 1216 target_nptl="yes"
2408a527
AJ
1217 ;;
1218 cris)
1219 echo "TARGET_ARCH=cris" >> $config_mak
1220 echo "#define TARGET_ARCH \"cris\"" >> $config_h
1221 echo "#define TARGET_CRIS 1" >> $config_h
2408a527
AJ
1222 ;;
1223 m68k)
1224 echo "TARGET_ARCH=m68k" >> $config_mak
1225 echo "#define TARGET_ARCH \"m68k\"" >> $config_h
1226 echo "#define TARGET_M68K 1" >> $config_h
1227 bflt="yes"
1228 ;;
1229 mips|mipsel)
1230 echo "TARGET_ARCH=mips" >> $config_mak
1231 echo "#define TARGET_ARCH \"mips\"" >> $config_h
1232 echo "#define TARGET_MIPS 1" >> $config_h
1233 echo "#define TARGET_ABI_MIPSO32 1" >> $config_h
1234 ;;
1235 mipsn32|mipsn32el)
1236 echo "TARGET_ARCH=mipsn32" >> $config_mak
1237 echo "#define TARGET_ARCH \"mipsn32\"" >> $config_h
1238 echo "#define TARGET_MIPS 1" >> $config_h
1239 echo "#define TARGET_ABI_MIPSN32 1" >> $config_h
1240 ;;
1241 mips64|mips64el)
1242 echo "TARGET_ARCH=mips64" >> $config_mak
1243 echo "#define TARGET_ARCH \"mips64\"" >> $config_h
1244 echo "#define TARGET_MIPS 1" >> $config_h
1245 echo "#define TARGET_MIPS64 1" >> $config_h
1246 echo "#define TARGET_ABI_MIPSN64 1" >> $config_h
1247 ;;
1248 ppc)
1249 echo "TARGET_ARCH=ppc" >> $config_mak
bf6247fb 1250 echo "CONFIG_DYNGEN_OP=yes" >> $config_mak
2408a527
AJ
1251 echo "#define TARGET_ARCH \"ppc\"" >> $config_h
1252 echo "#define TARGET_PPC 1" >> $config_h
bf6247fb 1253 echo "#define CONFIG_DYNGEN_OP 1" >> $config_h
2408a527
AJ
1254 ;;
1255 ppcemb)
1256 echo "TARGET_ARCH=ppcemb" >> $config_mak
1257 echo "TARGET_ABI_DIR=ppc" >> $config_mak
bf6247fb 1258 echo "CONFIG_DYNGEN_OP=yes" >> $config_mak
2408a527
AJ
1259 echo "#define TARGET_ARCH \"ppcemb\"" >> $config_h
1260 echo "#define TARGET_PPC 1" >> $config_h
1261 echo "#define TARGET_PPCEMB 1" >> $config_h
ec5b78cd 1262 echo "#define CONFIG_DYNGEN_OP 1" >> $config_h
2408a527
AJ
1263 ;;
1264 ppc64)
1265 echo "TARGET_ARCH=ppc64" >> $config_mak
1266 echo "TARGET_ABI_DIR=ppc" >> $config_mak
bf6247fb 1267 echo "CONFIG_DYNGEN_OP=yes" >> $config_mak
2408a527
AJ
1268 echo "#define TARGET_ARCH \"ppc64\"" >> $config_h
1269 echo "#define TARGET_PPC 1" >> $config_h
1270 echo "#define TARGET_PPC64 1" >> $config_h
bf6247fb 1271 echo "#define CONFIG_DYNGEN_OP 1" >> $config_h
2408a527
AJ
1272 ;;
1273 ppc64abi32)
1274 echo "TARGET_ARCH=ppc64" >> $config_mak
1275 echo "TARGET_ABI_DIR=ppc" >> $config_mak
1276 echo "TARGET_ARCH2=ppc64abi32" >> $config_mak
bf6247fb 1277 echo "CONFIG_DYNGEN_OP=yes" >> $config_mak
2408a527
AJ
1278 echo "#define TARGET_ARCH \"ppc64\"" >> $config_h
1279 echo "#define TARGET_PPC 1" >> $config_h
1280 echo "#define TARGET_PPC64 1" >> $config_h
1281 echo "#define TARGET_ABI32 1" >> $config_h
bf6247fb 1282 echo "#define CONFIG_DYNGEN_OP 1" >> $config_h
2408a527
AJ
1283 ;;
1284 sh4|sh4eb)
1285 echo "TARGET_ARCH=sh4" >> $config_mak
bf6247fb 1286 echo "CONFIG_DYNGEN_OP=yes" >> $config_mak
2408a527
AJ
1287 echo "#define TARGET_ARCH \"sh4\"" >> $config_h
1288 echo "#define TARGET_SH4 1" >> $config_h
bf6247fb 1289 echo "#define CONFIG_DYNGEN_OP 1" >> $config_h
2408a527
AJ
1290 bflt="yes"
1291 ;;
1292 sparc)
1293 echo "TARGET_ARCH=sparc" >> $config_mak
1294 echo "#define TARGET_ARCH \"sparc\"" >> $config_h
1295 echo "#define TARGET_SPARC 1" >> $config_h
1296 ;;
1297 sparc64)
1298 echo "TARGET_ARCH=sparc64" >> $config_mak
1299 echo "#define TARGET_ARCH \"sparc64\"" >> $config_h
1300 echo "#define TARGET_SPARC 1" >> $config_h
1301 echo "#define TARGET_SPARC64 1" >> $config_h
1302 elfload32="yes"
1303 ;;
1304 sparc32plus)
1305 echo "TARGET_ARCH=sparc64" >> $config_mak
1306 echo "TARGET_ABI_DIR=sparc" >> $config_mak
1307 echo "TARGET_ARCH2=sparc32plus" >> $config_mak
1308 echo "#define TARGET_ARCH \"sparc64\"" >> $config_h
1309 echo "#define TARGET_SPARC 1" >> $config_h
1310 echo "#define TARGET_SPARC64 1" >> $config_h
1311 echo "#define TARGET_ABI32 1" >> $config_h
1312 ;;
1313 *)
1314 echo "Unsupported target CPU"
1315 exit 1
1316 ;;
1317esac
de83cd02 1318if test "$target_bigendian" = "yes" ; then
97a847bc
FB
1319 echo "TARGET_WORDS_BIGENDIAN=yes" >> $config_mak
1320 echo "#define TARGET_WORDS_BIGENDIAN 1" >> $config_h
de83cd02 1321fi
97a847bc
FB
1322if test "$target_softmmu" = "yes" ; then
1323 echo "CONFIG_SOFTMMU=yes" >> $config_mak
1324 echo "#define CONFIG_SOFTMMU 1" >> $config_h
43ce4dfe 1325fi
997344f3
FB
1326if test "$target_user_only" = "yes" ; then
1327 echo "CONFIG_USER_ONLY=yes" >> $config_mak
1328 echo "#define CONFIG_USER_ONLY 1" >> $config_h
1329fi
831b7825
TS
1330if test "$target_linux_user" = "yes" ; then
1331 echo "CONFIG_LINUX_USER=yes" >> $config_mak
1332 echo "#define CONFIG_LINUX_USER 1" >> $config_h
1333fi
1334if test "$target_darwin_user" = "yes" ; then
1335 echo "CONFIG_DARWIN_USER=yes" >> $config_mak
1336 echo "#define CONFIG_DARWIN_USER 1" >> $config_h
1337fi
97a847bc 1338
0938cda5
AJ
1339if test "$target_cpu" = "arm" \
1340 -o "$target_cpu" = "armeb" \
1341 -o "$target_cpu" = "m68k" \
1342 -o "$target_cpu" = "mips" \
1343 -o "$target_cpu" = "mipsel" \
1344 -o "$target_cpu" = "mipsn32" \
1345 -o "$target_cpu" = "mipsn32el" \
1346 -o "$target_cpu" = "mips64" \
1347 -o "$target_cpu" = "mips64el" \
1348 -o "$target_cpu" = "sparc" \
1349 -o "$target_cpu" = "sparc64" \
1350 -o "$target_cpu" = "sparc32plus"; then
158142c2
FB
1351 echo "CONFIG_SOFTFLOAT=yes" >> $config_mak
1352 echo "#define CONFIG_SOFTFLOAT 1" >> $config_h
1353fi
e5fe0c52
PB
1354if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
1355 echo "TARGET_HAS_BFLT=yes" >> $config_mak
1356 echo "#define TARGET_HAS_BFLT 1" >> $config_h
1357fi
bd0c5661
PB
1358if test "$target_user_only" = "yes" \
1359 -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
1360 echo "#define USE_NPTL 1" >> $config_h
1361fi
cb33da57
BS
1362# 32 bit ELF loader in addition to native 64 bit loader?
1363if test "$target_user_only" = "yes" -a "$elfload32" = "yes"; then
1364 echo "TARGET_HAS_ELFLOAD32=yes" >> $config_mak
1365 echo "#define TARGET_HAS_ELFLOAD32 1" >> $config_h
1366fi
5b0753e0 1367
15d9ca0f
TS
1368test -f ${config_h}~ && cmp -s $config_h ${config_h}~ && mv ${config_h}~ $config_h
1369
97a847bc 1370done # for target in $targets
7d13299d
FB
1371
1372# build tree in object directory if source path is different from current one
1373if test "$source_path_used" = "yes" ; then
49ecc3fa 1374 DIRS="tests tests/cris slirp audio"
7d13299d 1375 FILES="Makefile tests/Makefile"
e7daa605 1376 FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
e1ffb0f1 1377 FILES="$FILES tests/test-mmap.c"
7d13299d
FB
1378 for dir in $DIRS ; do
1379 mkdir -p $dir
1380 done
ec530c81 1381 # remove the link and recreate it, as not all "ln -sf" overwrite the link
7d13299d 1382 for f in $FILES ; do
ec530c81
FB
1383 rm -f $f
1384 ln -s $source_path/$f $f
7d13299d
FB
1385 done
1386fi
7d13299d 1387
97a847bc 1388rm -f $TMPO $TMPC $TMPE $TMPS