]> git.proxmox.com Git - qemu.git/blame - configure
move sparc_cpu arg parsing to the begining
[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}"
7d13299d 17
9784cde5 18trap "rm -f $TMPC $TMPO $TMPE ; exit" 0 2 3 15
9ac81bbb 19
52166aa0
JQ
20compile_object() {
21 $cc $CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null
22}
23
24compile_prog() {
25 local_cflags="$1"
26 local_ldflags="$2"
27 $cc $CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags > /dev/null 2> /dev/null
28}
29
7d13299d 30# default parameters
2ff6b91e 31cpu=""
11d9f695 32prefix=""
1e43adfc 33interp_prefix="/usr/gnemul/qemu-%M"
43ce4dfe 34static="no"
7d13299d
FB
35cross_prefix=""
36cc="gcc"
0c58ac1c 37audio_drv_list=""
4c9b53e3 38audio_card_list="ac97 es1370 sb16"
39audio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus"
7d13299d
FB
40host_cc="gcc"
41ar="ar"
42make="make"
6a882643 43install="install"
7aa486fe
AL
44objcopy="objcopy"
45ld="ld"
ac0df51d
AL
46
47# parse CC options first
48for opt do
49 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
50 case "$opt" in
51 --cross-prefix=*) cross_prefix="$optarg"
52 ;;
53 --cc=*) cc="$optarg"
54 ;;
2ff6b91e
JQ
55 --cpu=*) cpu="$optarg"
56 ;;
e2a2ed06
JQ
57 --extra-cflags=*) CFLAGS="$optarg $CFLAGS"
58 ;;
59 --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
60 ;;
50e7b1a0
JQ
61 --sparc_cpu=*)
62 sparc_cpu="$optarg"
63 case $sparc_cpu in
64 v7|v8)
65 CFLAGS="-m32 -mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__ $CFLAGS"
66 LDFLAGS="-m32 $LDFLAGS"
67 cpu="sparc"
68 ;;
69 v8plus|v8plusa)
70 CFLAGS="-m32 -mcpu=ultrasparc -D__sparc_${sparc_cpu}__ $CFLAGS"
71 LDFLAGS="-m32 $LDFLAGS"
72 cpu="sparc"
73 ;;
74 v9)
75 CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_${sparc_cpu}__ $CFLAGS"
76 LDFLAGS="-m64 $LDFLAGS"
77 cpu="sparc64"
78 ;;
79 *)
80 echo "undefined SPARC architecture. Exiting";
81 exit 1
82 ;;
83 esac
84 ;;
ac0df51d
AL
85 esac
86done
87
88# OS specific
89# Using uname is really, really broken. Once we have the right set of checks
90# we can eliminate it's usage altogether
91
92cc="${cross_prefix}${cc}"
93ar="${cross_prefix}${ar}"
7aa486fe
AL
94objcopy="${cross_prefix}${objcopy}"
95ld="${cross_prefix}${ld}"
ac0df51d
AL
96
97# check that the C compiler works.
98cat > $TMPC <<EOF
99int main(void) {}
100EOF
101
52166aa0 102if compile_object ; then
ac0df51d
AL
103 : C compiler works ok
104else
105 echo "ERROR: \"$cc\" either does not exist or does not work"
106 exit 1
107fi
108
109check_define() {
110cat > $TMPC <<EOF
111#if !defined($1)
112#error Not defined
113#endif
114int main(void) { return 0; }
115EOF
52166aa0 116 compile_object
ac0df51d
AL
117}
118
2ff6b91e
JQ
119if test ! -z "$cpu" ; then
120 # command line argument
121 :
122elif check_define __i386__ ; then
ac0df51d
AL
123 cpu="i386"
124elif check_define __x86_64__ ; then
125 cpu="x86_64"
3aa9bd6c
BS
126elif check_define __sparc__ ; then
127 # We can't check for 64 bit (when gcc is biarch) or V8PLUSA
128 # They must be specified using --sparc_cpu
129 if check_define __arch64__ ; then
130 cpu="sparc64"
131 else
132 cpu="sparc"
133 fi
fdf7ed96 134elif check_define _ARCH_PPC ; then
135 if check_define _ARCH_PPC64 ; then
136 cpu="ppc64"
137 else
138 cpu="ppc"
139 fi
ac0df51d 140else
fdf7ed96 141 cpu=`uname -m`
ac0df51d
AL
142fi
143
5327cf48 144target_list=""
7d13299d
FB
145case "$cpu" in
146 i386|i486|i586|i686|i86pc|BePC)
97a847bc 147 cpu="i386"
7d13299d 148 ;;
aaa5fa14
AJ
149 x86_64|amd64)
150 cpu="x86_64"
151 ;;
152 alpha)
153 cpu="alpha"
154 ;;
ba68055e 155 armv*b)
808c4954
FB
156 cpu="armv4b"
157 ;;
ba68055e 158 armv*l)
7d13299d
FB
159 cpu="armv4l"
160 ;;
aaa5fa14
AJ
161 cris)
162 cpu="cris"
7d13299d 163 ;;
f54b3f92
AJ
164 parisc|parisc64)
165 cpu="hppa"
166 ;;
aaa5fa14
AJ
167 ia64)
168 cpu="ia64"
169 ;;
170 m68k)
171 cpu="m68k"
7d13299d 172 ;;
72b675ca
EI
173 microblaze)
174 cpu="microblaze"
175 ;;
7d13299d
FB
176 mips)
177 cpu="mips"
178 ;;
fbe4f65b
TS
179 mips64)
180 cpu="mips64"
181 ;;
fdf7ed96 182 ppc)
183 cpu="ppc"
184 ;;
185 ppc64)
186 cpu="ppc64"
e7daa605 187 ;;
0e7b8a9f 188 s390*)
fb3e5849
FB
189 cpu="s390"
190 ;;
3142255c 191 sparc|sun4[cdmuv])
ae228531
FB
192 cpu="sparc"
193 ;;
194 sparc64)
195 cpu="sparc64"
196 ;;
7d13299d
FB
197 *)
198 cpu="unknown"
199 ;;
200esac
eb82284f 201brlapi="yes"
7d13299d 202gprof="no"
f8393946 203debug_tcg="no"
f3d08ee6 204debug="no"
03b4fe7d 205sparse="no"
1625af87 206strip_opt="yes"
7d13299d 207bigendian="no"
67b915a5
FB
208mingw32="no"
209EXESUF=""
443f1376 210slirp="yes"
e0e6c8c0 211vde="yes"
102a52e4
FB
212fmod_lib=""
213fmod_inc=""
2f6a1ab0 214oss_lib=""
8d5d2d4c 215vnc_tls="yes"
2f9606b3 216vnc_sasl="yes"
b1a550a0 217bsd="no"
5327cf48 218linux="no"
d2c7c9b8 219solaris="no"
c9ec1fe4 220kqemu="no"
05c2a3e7 221profiler="no"
5b0753e0 222cocoa="no"
0a8e90f4 223softmmu="yes"
831b7825
TS
224linux_user="no"
225darwin_user="no"
84778508 226bsd_user="no"
379f6698 227guest_base=""
70ec5dc0 228build_docs="yes"
c5937220 229uname_release=""
4d3b6f6e 230curses="yes"
769ce76d 231curl="yes"
e5d355d1 232pthread="yes"
414f0dab 233aio="yes"
e5d355d1 234io_thread="no"
bd0c5661 235nptl="yes"
8ff9cbf7 236mixemu="no"
fb599c9a 237bluez="yes"
dff84034 238kvm="no"
eac30262 239kerneldir=""
b29fe3ed 240aix="no"
77755340 241blobs="yes"
f652e6af 242fdt="yes"
f92f8afe 243sdl="yes"
e37630ca 244xen="yes"
4a19f1ec 245pkgversion=""
7d13299d
FB
246
247# OS specific
ac0df51d
AL
248if check_define __linux__ ; then
249 targetos="Linux"
250elif check_define _WIN32 ; then
251 targetos='MINGW32'
169dc5d3
BS
252elif check_define __OpenBSD__ ; then
253 targetos='OpenBSD'
254elif check_define __sun__ ; then
255 targetos='SunOS'
ac0df51d
AL
256else
257 targetos=`uname -s`
258fi
7d13299d 259case $targetos in
c326e0af
FB
260CYGWIN*)
261mingw32="yes"
0c439cbf 262CFLAGS="-mno-cygwin $CFLAGS"
c2de5c91 263audio_possible_drivers="sdl"
c326e0af 264;;
67b915a5
FB
265MINGW32*)
266mingw32="yes"
c2de5c91 267audio_possible_drivers="dsound sdl fmod"
67b915a5 268;;
5c40d2bd 269GNU/kFreeBSD)
0c58ac1c 270audio_drv_list="oss"
f34af52c 271audio_possible_drivers="oss sdl esd pa"
5c40d2bd
TS
272if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
273 kqemu="yes"
274fi
275;;
7d3505c5
FB
276FreeBSD)
277bsd="yes"
0c58ac1c 278audio_drv_list="oss"
f34af52c 279audio_possible_drivers="oss sdl esd pa"
e99f9060 280if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
07f4ddbf
FB
281 kqemu="yes"
282fi
7d3505c5 283;;
c5e97233
BS
284DragonFly)
285bsd="yes"
286audio_drv_list="oss"
287audio_possible_drivers="oss sdl esd pa"
288if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
289 kqemu="yes"
290fi
291aio="no"
292;;
7d3505c5
FB
293NetBSD)
294bsd="yes"
0c58ac1c 295audio_drv_list="oss"
c2de5c91 296audio_possible_drivers="oss sdl esd"
8ef92a88 297oss_lib="-lossaudio"
7d3505c5
FB
298;;
299OpenBSD)
300bsd="yes"
0c58ac1c 301audio_drv_list="oss"
c2de5c91 302audio_possible_drivers="oss sdl esd"
2f6a1ab0 303oss_lib="-lossaudio"
7d3505c5 304;;
83fb7adf
FB
305Darwin)
306bsd="yes"
307darwin="yes"
1b0f9cc2 308# on Leopard most of the system is 32-bit, so we have to ask the kernel it if we can run 64-bit userspace code
aab8588a 309if [ "$cpu" = "i386" ] ; then
310 is_x86_64=`sysctl -n hw.optional.x86_64`
311 [ "$is_x86_64" = "1" ] && cpu=x86_64
1b0f9cc2
AL
312fi
313if [ "$cpu" = "x86_64" ] ; then
0c439cbf
JQ
314 CFLAGS="-arch x86_64 $CFLAGS"
315 LDFLAGS="-arch x86_64 $LDFLAGS"
1b0f9cc2 316else
0c439cbf 317 CFLAGS="-mdynamic-no-pic $CFLAGS"
1b0f9cc2 318fi
831b7825 319darwin_user="yes"
fd677642 320cocoa="yes"
0c58ac1c 321audio_drv_list="coreaudio"
c2de5c91 322audio_possible_drivers="coreaudio sdl fmod"
0c439cbf 323LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
83fb7adf 324;;
ec530c81 325SunOS)
c2b84fab
TS
326 solaris="yes"
327 make="gmake"
328 install="ginstall"
0475a5ca 329 needs_libsunmath="no"
c2b84fab 330 solarisrev=`uname -r | cut -f2 -d.`
ef18c883
TS
331 # have to select again, because `uname -m` returns i86pc
332 # even on an x86_64 box.
333 solariscpu=`isainfo -k`
334 if test "${solariscpu}" = "amd64" ; then
335 cpu="x86_64"
336 fi
c2b84fab 337 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
0475a5ca
TS
338 if test "$solarisrev" -le 9 ; then
339 if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
340 needs_libsunmath="yes"
341 else
342 echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
343 echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
344 echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
345 echo "Studio 11 can be downloaded from www.sun.com."
346 exit 1
347 fi
348 fi
349 if test "$solarisrev" -ge 9 ; then
c2b84fab
TS
350 kqemu="yes"
351 fi
86b2bd93 352 fi
6b4d2ba1 353 if test -f /usr/include/sys/soundcard.h ; then
0c58ac1c 354 audio_drv_list="oss"
6b4d2ba1 355 fi
c2de5c91 356 audio_possible_drivers="oss sdl"
0c439cbf 357 CFLAGS="-std=gnu99 $CFLAGS"
86b2bd93 358;;
b29fe3ed 359AIX)
360aix="yes"
361make="gmake"
362;;
1d14ffa9 363*)
0c58ac1c 364audio_drv_list="oss"
b8e59f18 365audio_possible_drivers="oss alsa sdl esd pa"
5327cf48 366linux="yes"
831b7825 367linux_user="yes"
68063649 368usb="linux"
dff84034 369kvm="yes"
07f4ddbf 370if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
c9ec1fe4 371 kqemu="yes"
c2de5c91 372 audio_possible_drivers="$audio_possible_drivers fmod"
c9ec1fe4 373fi
fb065187 374;;
7d13299d
FB
375esac
376
7d3505c5 377if [ "$bsd" = "yes" ] ; then
b1a550a0 378 if [ "$darwin" != "yes" ] ; then
83fb7adf 379 make="gmake"
68063649 380 usb="bsd"
83fb7adf 381 fi
84778508 382 bsd_user="yes"
7d3505c5
FB
383fi
384
3457a3f8 385if test "$mingw32" = "yes" ; then
fecde40a
JQ
386 if [ "$cpu" = "i386" ] ; then
387 kqemu="yes"
388 fi
3457a3f8 389 EXESUF=".exe"
3457a3f8
JQ
390 CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $CFLAGS"
391fi
392
7d13299d 393# find source path
ad064840 394source_path=`dirname "$0"`
59faef3a
AZ
395source_path_used="no"
396workdir=`pwd`
ad064840 397if [ -z "$source_path" ]; then
59faef3a 398 source_path=$workdir
ad064840
PB
399else
400 source_path=`cd "$source_path"; pwd`
7d13299d 401fi
724db118 402[ -f "$workdir/vl.c" ] || source_path_used="yes"
7d13299d 403
487fefdb 404werror=""
85aa5189 405
7d13299d 406for opt do
a46e4035 407 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
7d13299d 408 case "$opt" in
2efc3265
FB
409 --help|-h) show_help=yes
410 ;;
b1a550a0 411 --prefix=*) prefix="$optarg"
7d13299d 412 ;;
b1a550a0 413 --interp-prefix=*) interp_prefix="$optarg"
32ce6337 414 ;;
b1a550a0 415 --source-path=*) source_path="$optarg"
ad064840 416 source_path_used="yes"
7d13299d 417 ;;
ac0df51d 418 --cross-prefix=*)
7d13299d 419 ;;
ac0df51d 420 --cc=*)
7d13299d 421 ;;
b1a550a0 422 --host-cc=*) host_cc="$optarg"
83469015 423 ;;
b1a550a0 424 --make=*) make="$optarg"
7d13299d 425 ;;
6a882643
PB
426 --install=*) install="$optarg"
427 ;;
e2a2ed06 428 --extra-cflags=*)
7d13299d 429 ;;
e2a2ed06 430 --extra-ldflags=*)
7d13299d 431 ;;
2ff6b91e 432 --cpu=*)
7d13299d 433 ;;
b1a550a0 434 --target-list=*) target_list="$optarg"
de83cd02 435 ;;
7d13299d
FB
436 --enable-gprof) gprof="yes"
437 ;;
43ce4dfe
FB
438 --static) static="yes"
439 ;;
97a847bc
FB
440 --disable-sdl) sdl="no"
441 ;;
0c58ac1c 442 --fmod-lib=*) fmod_lib="$optarg"
1d14ffa9 443 ;;
c2de5c91 444 --fmod-inc=*) fmod_inc="$optarg"
445 ;;
2f6a1ab0
BS
446 --oss-lib=*) oss_lib="$optarg"
447 ;;
2fa7d3bf 448 --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
102a52e4 449 ;;
0c58ac1c 450 --audio-drv-list=*) audio_drv_list="$optarg"
102a52e4 451 ;;
f8393946
AJ
452 --enable-debug-tcg) debug_tcg="yes"
453 ;;
454 --disable-debug-tcg) debug_tcg="no"
455 ;;
f3d08ee6
PB
456 --enable-debug)
457 # Enable debugging options that aren't excessively noisy
458 debug_tcg="yes"
459 debug="yes"
460 strip_opt="no"
461 ;;
03b4fe7d
AL
462 --enable-sparse) sparse="yes"
463 ;;
464 --disable-sparse) sparse="no"
465 ;;
1625af87
AL
466 --disable-strip) strip_opt="no"
467 ;;
8d5d2d4c
TS
468 --disable-vnc-tls) vnc_tls="no"
469 ;;
2f9606b3
AL
470 --disable-vnc-sasl) vnc_sasl="no"
471 ;;
443f1376 472 --disable-slirp) slirp="no"
1d14ffa9 473 ;;
e0e6c8c0 474 --disable-vde) vde="no"
8a16d273 475 ;;
c9ec1fe4 476 --disable-kqemu) kqemu="no"
1d14ffa9 477 ;;
e37630ca
AL
478 --disable-xen) xen="no"
479 ;;
2e4d9fb1
AJ
480 --disable-brlapi) brlapi="no"
481 ;;
fb599c9a
AZ
482 --disable-bluez) bluez="no"
483 ;;
7ba1e619
AL
484 --disable-kvm) kvm="no"
485 ;;
05c2a3e7
FB
486 --enable-profiler) profiler="yes"
487 ;;
c2de5c91 488 --enable-cocoa)
489 cocoa="yes" ;
490 sdl="no" ;
491 audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
1d14ffa9 492 ;;
cad25d69 493 --disable-system) softmmu="no"
0a8e90f4 494 ;;
cad25d69 495 --enable-system) softmmu="yes"
0a8e90f4 496 ;;
831b7825 497 --disable-linux-user) linux_user="no"
0a8e90f4 498 ;;
831b7825
TS
499 --enable-linux-user) linux_user="yes"
500 ;;
501 --disable-darwin-user) darwin_user="no"
502 ;;
503 --enable-darwin-user) darwin_user="yes"
0a8e90f4 504 ;;
84778508
BS
505 --disable-bsd-user) bsd_user="no"
506 ;;
507 --enable-bsd-user) bsd_user="yes"
508 ;;
379f6698
PB
509 --enable-guest-base) guest_base="yes"
510 ;;
511 --disable-guest-base) guest_base="no"
512 ;;
c5937220
PB
513 --enable-uname-release=*) uname_release="$optarg"
514 ;;
3142255c 515 --sparc_cpu=*)
3142255c 516 ;;
85aa5189
FB
517 --enable-werror) werror="yes"
518 ;;
519 --disable-werror) werror="no"
520 ;;
4d3b6f6e
AZ
521 --disable-curses) curses="no"
522 ;;
769ce76d
AG
523 --disable-curl) curl="no"
524 ;;
bd0c5661
PB
525 --disable-nptl) nptl="no"
526 ;;
8ff9cbf7 527 --enable-mixemu) mixemu="yes"
528 ;;
e5d355d1
AL
529 --disable-pthread) pthread="no"
530 ;;
414f0dab
BS
531 --disable-aio) aio="no"
532 ;;
e5d355d1
AL
533 --enable-io-thread) io_thread="yes"
534 ;;
77755340
TS
535 --disable-blobs) blobs="no"
536 ;;
eac30262
AL
537 --kerneldir=*) kerneldir="$optarg"
538 ;;
4a19f1ec
PB
539 --with-pkgversion=*) pkgversion=" ($optarg)"
540 ;;
70ec5dc0
AL
541 --disable-docs) build_docs="no"
542 ;;
7f1559c6
AZ
543 *) echo "ERROR: unknown option $opt"; show_help="yes"
544 ;;
7d13299d
FB
545 esac
546done
547
3142255c
BS
548#
549# If cpu ~= sparc and sparc_cpu hasn't been defined, plug in the right
0c439cbf 550# CFLAGS/LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
3142255c 551#
379f6698 552host_guest_base="no"
40293e58 553case "$cpu" in
3142255c 554 sparc) if test -z "$sparc_cpu" ; then
0c439cbf
JQ
555 CFLAGS="-m32 -mcpu=ultrasparc -D__sparc_v8plus__ $CFLAGS"
556 LDFLAGS="-m32 $LDFLAGS"
3142255c 557 fi
0c439cbf 558 CFLAGS="-ffixed-g2 -ffixed-g3 $CFLAGS"
762e8230 559 if test "$solaris" = "no" ; then
0c439cbf 560 CFLAGS="-ffixed-g1 -ffixed-g6 $CFLAGS"
762e8230 561 fi
3142255c
BS
562 ;;
563 sparc64) if test -z "$sparc_cpu" ; then
0c439cbf
JQ
564 CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__ $CFLAGS"
565 LDFLAGS="-m64 $LDFLAGS"
3142255c 566 fi
762e8230 567 if test "$solaris" = "no" ; then
0c439cbf 568 CFLAGS="-ffixed-g5 -ffixed-g6 -ffixed-g7 $CFLAGS"
762e8230 569 else
0c439cbf 570 CFLAGS="-ffixed-g1 -ffixed-g5 -ffixed-g6 -ffixed-g7 $CFLAGS"
762e8230 571 fi
3142255c 572 ;;
76d83bde 573 s390)
0c439cbf 574 CFLAGS="-march=z900 $CFLAGS"
76d83bde 575 ;;
40293e58 576 i386)
0c439cbf
JQ
577 CFLAGS="-m32 $CFLAGS"
578 LDFLAGS="-m32 $LDFLAGS"
379f6698 579 host_guest_base="yes"
40293e58
FB
580 ;;
581 x86_64)
0c439cbf
JQ
582 CFLAGS="-m64 $CFLAGS"
583 LDFLAGS="-m64 $LDFLAGS"
379f6698
PB
584 host_guest_base="yes"
585 ;;
586 arm*)
587 host_guest_base="yes"
40293e58 588 ;;
f6548c0a 589 ppc*)
590 host_guest_base="yes"
591 ;;
3142255c
BS
592esac
593
379f6698
PB
594[ -z "$guest_base" ] && guest_base="$host_guest_base"
595
af5db58e
PB
596if test x"$show_help" = x"yes" ; then
597cat << EOF
598
599Usage: configure [options]
600Options: [defaults in brackets after descriptions]
601
602EOF
603echo "Standard options:"
604echo " --help print this message"
605echo " --prefix=PREFIX install in PREFIX [$prefix]"
606echo " --interp-prefix=PREFIX where to find shared libraries, etc."
607echo " use %M for cpu name [$interp_prefix]"
608echo " --target-list=LIST set target list [$target_list]"
609echo ""
610echo "kqemu kernel acceleration support:"
611echo " --disable-kqemu disable kqemu support"
af5db58e
PB
612echo ""
613echo "Advanced options (experts only):"
614echo " --source-path=PATH path of source code [$source_path]"
615echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
616echo " --cc=CC use C compiler CC [$cc]"
617echo " --host-cc=CC use C compiler CC [$host_cc] for dyngen etc."
e3fc14c3
JK
618echo " --extra-cflags=CFLAGS append extra C compiler flags CFLAGS"
619echo " --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS"
af5db58e 620echo " --make=MAKE use specified make [$make]"
6a882643 621echo " --install=INSTALL use specified install [$install]"
af5db58e 622echo " --static enable static build [$static]"
f8393946
AJ
623echo " --enable-debug-tcg enable TCG debugging"
624echo " --disable-debug-tcg disable TCG debugging (default)"
09695a4a 625echo " --enable-debug enable common debug build options"
890b1658
AL
626echo " --enable-sparse enable sparse checker"
627echo " --disable-sparse disable sparse checker (default)"
1625af87 628echo " --disable-strip disable stripping binaries"
85aa5189 629echo " --disable-werror disable compilation abort on warning"
fe8f78e4 630echo " --disable-sdl disable SDL"
af5db58e 631echo " --enable-cocoa enable COCOA (Mac OS X only)"
c2de5c91 632echo " --audio-drv-list=LIST set audio drivers list:"
633echo " Available drivers: $audio_possible_drivers"
4c9b53e3 634echo " --audio-card-list=LIST set list of emulated audio cards [$audio_card_list]"
635echo " Available cards: $audio_possible_cards"
8ff9cbf7 636echo " --enable-mixemu enable mixer emulation"
e37630ca 637echo " --disable-xen disable xen backend driver support"
2e4d9fb1 638echo " --disable-brlapi disable BrlAPI"
8d5d2d4c 639echo " --disable-vnc-tls disable TLS encryption for VNC server"
2f9606b3 640echo " --disable-vnc-sasl disable SASL encryption for VNC server"
af896aaa 641echo " --disable-curses disable curses output"
769ce76d 642echo " --disable-curl disable curl connectivity"
fb599c9a 643echo " --disable-bluez disable bluez stack connectivity"
7ba1e619 644echo " --disable-kvm disable KVM acceleration support"
bd0c5661 645echo " --disable-nptl disable usermode NPTL support"
af5db58e
PB
646echo " --enable-system enable all system emulation targets"
647echo " --disable-system disable all system emulation targets"
831b7825
TS
648echo " --enable-linux-user enable all linux usermode emulation targets"
649echo " --disable-linux-user disable all linux usermode emulation targets"
650echo " --enable-darwin-user enable all darwin usermode emulation targets"
651echo " --disable-darwin-user disable all darwin usermode emulation targets"
84778508
BS
652echo " --enable-bsd-user enable all BSD usermode emulation targets"
653echo " --disable-bsd-user disable all BSD usermode emulation targets"
379f6698
PB
654echo " --enable-guest-base enable GUEST_BASE support for usermode"
655echo " emulation targets"
656echo " --disable-guest-base disable GUEST_BASE support"
af5db58e
PB
657echo " --fmod-lib path to FMOD library"
658echo " --fmod-inc path to FMOD includes"
2f6a1ab0 659echo " --oss-lib path to OSS library"
c5937220 660echo " --enable-uname-release=R Return R for uname -r in usermode emulation"
3142255c 661echo " --sparc_cpu=V Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
e0e6c8c0 662echo " --disable-vde disable support for vde network"
e5d355d1 663echo " --disable-pthread disable pthread support"
414f0dab 664echo " --disable-aio disable AIO support"
e5d355d1 665echo " --enable-io-thread enable IO thread"
77755340 666echo " --disable-blobs disable installing provided firmware blobs"
eac30262 667echo " --kerneldir=PATH look for kernel includes in PATH"
af5db58e 668echo ""
5bf08934 669echo "NOTE: The object files are built at the place where configure is launched"
af5db58e
PB
670exit 1
671fi
672
03b4fe7d
AL
673if test ! -x "$(which cgcc 2>/dev/null)"; then
674 sparse="no"
675fi
676
ec530c81
FB
677#
678# Solaris specific configure tool chain decisions
679#
680if test "$solaris" = "yes" ; then
ec530c81
FB
681 solinst=`which $install 2> /dev/null | /usr/bin/grep -v "no $install in"`
682 if test -z "$solinst" ; then
683 echo "Solaris install program not found. Use --install=/usr/ucb/install or"
684 echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
685 echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
686 exit 1
687 fi
688 if test "$solinst" = "/usr/sbin/install" ; then
689 echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
690 echo "try ginstall from the GNU fileutils available from www.blastwave.org"
691 echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
692 exit 1
693 fi
ec530c81
FB
694 sol_ar=`which ar 2> /dev/null | /usr/bin/grep -v "no ar in"`
695 if test -z "$sol_ar" ; then
696 echo "Error: No path includes ar"
697 if test -f /usr/ccs/bin/ar ; then
698 echo "Add /usr/ccs/bin to your path and rerun configure"
699 fi
700 exit 1
701 fi
5fafdf24 702fi
ec530c81
FB
703
704
5327cf48
FB
705if test -z "$target_list" ; then
706# these targets are portable
0a8e90f4 707 if [ "$softmmu" = "yes" ] ; then
2408a527
AJ
708 target_list="\
709i386-softmmu \
710x86_64-softmmu \
711arm-softmmu \
712cris-softmmu \
713m68k-softmmu \
72b675ca 714microblaze-softmmu \
2408a527
AJ
715mips-softmmu \
716mipsel-softmmu \
717mips64-softmmu \
718mips64el-softmmu \
719ppc-softmmu \
720ppcemb-softmmu \
721ppc64-softmmu \
722sh4-softmmu \
723sh4eb-softmmu \
724sparc-softmmu \
1b64fcae 725sparc64-softmmu \
2408a527 726"
0a8e90f4 727 fi
5327cf48 728# the following are Linux specific
831b7825 729 if [ "$linux_user" = "yes" ] ; then
2408a527
AJ
730 target_list="${target_list}\
731i386-linux-user \
732x86_64-linux-user \
733alpha-linux-user \
734arm-linux-user \
735armeb-linux-user \
736cris-linux-user \
737m68k-linux-user \
72b675ca 738microblaze-linux-user \
2408a527
AJ
739mips-linux-user \
740mipsel-linux-user \
741ppc-linux-user \
742ppc64-linux-user \
743ppc64abi32-linux-user \
744sh4-linux-user \
745sh4eb-linux-user \
746sparc-linux-user \
747sparc64-linux-user \
748sparc32plus-linux-user \
749"
831b7825
TS
750 fi
751# the following are Darwin specific
752 if [ "$darwin_user" = "yes" ] ; then
6cdc7375 753 target_list="$target_list i386-darwin-user ppc-darwin-user "
5327cf48 754 fi
84778508
BS
755# the following are BSD specific
756 if [ "$bsd_user" = "yes" ] ; then
757 target_list="${target_list}\
31fc12df
BS
758i386-bsd-user \
759x86_64-bsd-user \
760sparc-bsd-user \
84778508
BS
761sparc64-bsd-user \
762"
763 fi
6e20a45f 764else
b1a550a0 765 target_list=`echo "$target_list" | sed -e 's/,/ /g'`
5327cf48 766fi
0a8e90f4
PB
767if test -z "$target_list" ; then
768 echo "No targets enabled"
769 exit 1
770fi
5327cf48 771
7d13299d
FB
772if test -z "$cross_prefix" ; then
773
774# ---
775# big/little endian test
776cat > $TMPC << EOF
777#include <inttypes.h>
778int main(int argc, char ** argv){
1d14ffa9
FB
779 volatile uint32_t i=0x01234567;
780 return (*((uint8_t*)(&i))) == 0x67;
7d13299d
FB
781}
782EOF
783
52166aa0 784if compile_prog "" "" ; then
7d13299d
FB
785$TMPE && bigendian="yes"
786else
787echo big/little test failed
788fi
789
790else
791
792# if cross compiling, cannot launch a program, so make a static guess
0938cda5 793if test "$cpu" = "armv4b" \
f54b3f92 794 -o "$cpu" = "hppa" \
0938cda5
AJ
795 -o "$cpu" = "m68k" \
796 -o "$cpu" = "mips" \
797 -o "$cpu" = "mips64" \
fdf7ed96 798 -o "$cpu" = "ppc" \
799 -o "$cpu" = "ppc64" \
0938cda5
AJ
800 -o "$cpu" = "s390" \
801 -o "$cpu" = "sparc" \
802 -o "$cpu" = "sparc64"; then
7d13299d
FB
803 bigendian="yes"
804fi
805
806fi
807
b6853697
FB
808# host long bits test
809hostlongbits="32"
0938cda5
AJ
810if test "$cpu" = "x86_64" \
811 -o "$cpu" = "alpha" \
812 -o "$cpu" = "ia64" \
fdf7ed96 813 -o "$cpu" = "sparc64" \
814 -o "$cpu" = "ppc64"; then
b6853697
FB
815 hostlongbits="64"
816fi
817
bd0c5661
PB
818# Check host NPTL support
819cat > $TMPC <<EOF
820#include <sched.h>
30813cea 821#include <linux/futex.h>
bd0c5661
PB
822void foo()
823{
824#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
825#error bork
826#endif
827}
828EOF
829
52166aa0 830if compile_object ; then
bd0c5661
PB
831 :
832else
833 nptl="no"
834fi
835
ac62922e
AZ
836##########################################
837# zlib check
838
839cat > $TMPC << EOF
840#include <zlib.h>
841int main(void) { zlibVersion(); return 0; }
842EOF
52166aa0 843if compile_prog "" "-lz" ; then
ac62922e
AZ
844 :
845else
846 echo
847 echo "Error: zlib check failed"
848 echo "Make sure to have the zlib libs and headers installed."
849 echo
850 exit 1
851fi
852
e37630ca
AL
853##########################################
854# xen probe
855
856if test "$xen" = "yes" ; then
b2266bee
JQ
857 xen_libs="-lxenstore -lxenctrl -lxenguest"
858 cat > $TMPC <<EOF
e37630ca
AL
859#include <xenctrl.h>
860#include <xs.h>
df7a607b 861int main(void) { xs_daemon_open(); xc_interface_open(); return 0; }
e37630ca 862EOF
52166aa0 863 if compile_prog "" "$xen_libs" ; then
b2266bee
JQ
864 :
865 else
866 xen="no"
867 fi
e37630ca
AL
868fi
869
11d9f695
FB
870##########################################
871# SDL probe
872
873sdl_too_old=no
874
f92f8afe 875if test "$sdl" = "yes" ; then
ac119f9d
JQ
876 sdl=no
877 cat > $TMPC << EOF
11d9f695
FB
878#include <SDL.h>
879#undef main /* We don't want SDL to override our main() */
880int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
881EOF
ac119f9d
JQ
882 sdl_cflags=`sdl-config --cflags 2> /dev/null`
883 sdl_libs=`sdl-config --libs 2> /dev/null`
52166aa0 884 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
ac119f9d
JQ
885 _sdlversion=`sdl-config --version | sed 's/[^0-9]//g'`
886 if test "$_sdlversion" -lt 121 ; then
887 sdl_too_old=yes
888 else
889 if test "$cocoa" = "no" ; then
890 sdl=yes
891 fi
892 fi
cd01b4a3 893
ac119f9d
JQ
894 # static link with sdl ?
895 if test "$sdl" = "yes" -a "$static" = "yes" ; then
896 sdl_libs=`sdl-config --static-libs 2>/dev/null`
897 if test `sdl-config --static-libs 2>/dev/null | grep \\\-laa > /dev/null` ; then
898 sdl_libs="$sdl_libs `aalib-config --static-libs >2 /dev/null`"
899 sdl_cflags="$sd_cflags `aalib-config --cflags >2 /dev/null`"
900 fi
52166aa0 901 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
ac119f9d
JQ
902 :
903 else
904 sdl=no
905 fi
906 fi # static link
907 fi # sdl compile test
a68551bc 908fi
11d9f695 909
5368a422 910if test "$sdl" = "yes" ; then
ac119f9d 911 cat > $TMPC <<EOF
5368a422
AL
912#include <SDL.h>
913#if defined(SDL_VIDEO_DRIVER_X11)
914#include <X11/XKBlib.h>
915#else
916#error No x11 support
917#endif
918int main(void) { return 0; }
919EOF
52166aa0 920 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
ac119f9d
JQ
921 sdl_libs="$sdl_libs -lX11"
922 fi
5368a422
AL
923fi
924
8d5d2d4c
TS
925##########################################
926# VNC TLS detection
927if test "$vnc_tls" = "yes" ; then
ae6b5e5a
AL
928cat > $TMPC <<EOF
929#include <gnutls/gnutls.h>
930int main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
931EOF
932 vnc_tls_cflags=`pkg-config --cflags gnutls 2> /dev/null`
933 vnc_tls_libs=`pkg-config --libs gnutls 2> /dev/null`
52166aa0 934 if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
ae6b5e5a
AL
935 :
936 else
937 vnc_tls="no"
938 fi
8d5d2d4c
TS
939fi
940
2f9606b3
AL
941##########################################
942# VNC SASL detection
943if test "$vnc_sasl" = "yes" ; then
944cat > $TMPC <<EOF
945#include <sasl/sasl.h>
946#include <stdio.h>
947int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
948EOF
949 # Assuming Cyrus-SASL installed in /usr prefix
950 vnc_sasl_cflags=""
951 vnc_sasl_libs="-lsasl2"
52166aa0 952 if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
2f9606b3
AL
953 :
954 else
955 vnc_sasl="no"
956 fi
957fi
958
76655d6d
AL
959##########################################
960# fnmatch() probe, used for ACL routines
961fnmatch="no"
962cat > $TMPC << EOF
963#include <fnmatch.h>
964int main(void)
965{
966 fnmatch("foo", "foo", 0);
967 return 0;
968}
969EOF
52166aa0 970if compile_prog "" "" ; then
76655d6d
AL
971 fnmatch="yes"
972fi
973
8a16d273
TS
974##########################################
975# vde libraries probe
976if test "$vde" = "yes" ; then
4baae0ac
JQ
977 vde=no
978 vde_libs="-lvdeplug"
8a16d273
TS
979 cat > $TMPC << EOF
980#include <libvdeplug.h>
4a7f0e06
PB
981int main(void)
982{
983 struct vde_open_args a = {0, 0, 0};
984 vde_open("", "", &a);
985 return 0;
986}
8a16d273 987EOF
52166aa0 988 if compile_prog "" "$vde_libs" ; then
4baae0ac
JQ
989 vde=yes
990 fi
8a16d273
TS
991fi
992
8f28f3fb 993##########################################
c2de5c91 994# Sound support libraries probe
8f28f3fb 995
c2de5c91 996audio_drv_probe()
997{
998 drv=$1
999 hdr=$2
1000 lib=$3
1001 exp=$4
1002 cfl=$5
1003 cat > $TMPC << EOF
1004#include <$hdr>
1005int main(void) { $exp }
8f28f3fb 1006EOF
52166aa0 1007 if compile_prog "$cfl" "$lib" ; then
c2de5c91 1008 :
1009 else
1010 echo
1011 echo "Error: $drv check failed"
1012 echo "Make sure to have the $drv libs and headers installed."
1013 echo
1014 exit 1
1015 fi
1016}
1017
2fa7d3bf 1018audio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
c2de5c91 1019for drv in $audio_drv_list; do
1020 case $drv in
1021 alsa)
1022 audio_drv_probe $drv alsa/asoundlib.h -lasound \
1023 "snd_pcm_t **handle; return snd_pcm_close(*handle);"
1024 ;;
1025
1026 fmod)
1027 if test -z $fmod_lib || test -z $fmod_inc; then
1028 echo
1029 echo "Error: You must specify path to FMOD library and headers"
1030 echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
1031 echo
1032 exit 1
1033 fi
1034 audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
1035 ;;
1036
1037 esd)
1038 audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
1039 ;;
b8e59f18 1040
1041 pa)
1042 audio_drv_probe $drv pulse/simple.h -lpulse-simple \
1043 "pa_simple *s = NULL; pa_simple_free(s); return 0;"
1044 ;;
1045
2f6a1ab0
BS
1046 oss|sdl|core|wav|dsound)
1047 # XXX: Probes for CoreAudio, DirectSound, SDL(?)
1048 ;;
1049
e4c63a6a 1050 *)
1c9b2a52 1051 echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
e4c63a6a 1052 echo
1053 echo "Error: Unknown driver '$drv' selected"
1054 echo "Possible drivers are: $audio_possible_drivers"
1055 echo
1056 exit 1
1057 }
1058 ;;
c2de5c91 1059 esac
1060done
8f28f3fb 1061
2e4d9fb1
AJ
1062##########################################
1063# BrlAPI probe
1064
eb82284f
JQ
1065if test "$brlapi" = "yes" ; then
1066 brlapi=no
1067 brlapi_libs="-lbrlapi"
1068 cat > $TMPC << EOF
2e4d9fb1
AJ
1069#include <brlapi.h>
1070int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
1071EOF
52166aa0 1072 if compile_prog "" "$brlapi_libs" ; then
eb82284f
JQ
1073 brlapi=yes
1074 fi
1075fi
2e4d9fb1 1076
4d3b6f6e
AZ
1077##########################################
1078# curses probe
1079
1080if test "$curses" = "yes" ; then
4d3b6f6e
AZ
1081 cat > $TMPC << EOF
1082#include <curses.h>
5a8ff3aa
BS
1083#ifdef __OpenBSD__
1084#define resize_term resizeterm
1085#endif
1086int main(void) { resize_term(0, 0); return curses_version(); }
4d3b6f6e 1087EOF
52166aa0 1088 if compile_prog "" "-lncurses" ; then
e0b7a42b 1089 curses_libs="-lncurses"
52166aa0 1090 elif compile_prog "" "-lcurses" ; then
e0b7a42b
JQ
1091 curses_libs="-lcurses"
1092 else
1093 curses=no
4d3b6f6e
AZ
1094 fi
1095fi # test "$curses"
1096
769ce76d
AG
1097##########################################
1098# curl probe
1099
1100if test "$curl" = "yes" ; then
1101 curl=no
1102 cat > $TMPC << EOF
1103#include <curl/curl.h>
1104int main(void) { return curl_easy_init(); }
1105EOF
b1d5a277 1106 curl_cflags=`curl-config --cflags 2>/dev/null`
52368552 1107 curl_libs=`curl-config --libs 2>/dev/null`
b1d5a277 1108 if compile_prog "$curl_cflags" "$curl_libs" ; then
769ce76d
AG
1109 curl=yes
1110 fi
1111fi # test "$curl"
1112
fb599c9a
AZ
1113##########################################
1114# bluez support probe
1115if test "$bluez" = "yes" ; then
efcfd0c5 1116 `pkg-config bluez 2> /dev/null` || bluez="no"
fb599c9a
AZ
1117fi
1118if test "$bluez" = "yes" ; then
e820e3f4
AZ
1119 cat > $TMPC << EOF
1120#include <bluetooth/bluetooth.h>
1121int main(void) { return bt_error(0); }
1122EOF
efcfd0c5
BS
1123 bluez_cflags=`pkg-config --cflags bluez 2> /dev/null`
1124 bluez_libs=`pkg-config --libs bluez 2> /dev/null`
52166aa0 1125 if compile_prog "$bluez_cflags" "$bluez_libs" ; then
e820e3f4
AZ
1126 :
1127 else
1128 bluez="no"
1129 fi
fb599c9a
AZ
1130fi
1131
7ba1e619
AL
1132##########################################
1133# kvm probe
1134if test "$kvm" = "yes" ; then
1135 cat > $TMPC <<EOF
1136#include <linux/kvm.h>
9fd8d8d7 1137#if !defined(KVM_API_VERSION) || KVM_API_VERSION < 12 || KVM_API_VERSION > 12
7ba1e619
AL
1138#error Invalid KVM version
1139#endif
9fd8d8d7
AL
1140#if !defined(KVM_CAP_USER_MEMORY)
1141#error Missing KVM capability KVM_CAP_USER_MEMORY
1142#endif
1143#if !defined(KVM_CAP_SET_TSS_ADDR)
1144#error Missing KVM capability KVM_CAP_SET_TSS_ADDR
1145#endif
1146#if !defined(KVM_CAP_DESTROY_MEMORY_REGION_WORKS)
1147#error Missing KVM capability KVM_CAP_DESTROY_MEMORY_REGION_WORKS
1148#endif
7ba1e619
AL
1149int main(void) { return 0; }
1150EOF
eac30262
AL
1151 if test "$kerneldir" != "" ; then
1152 kvm_cflags=-I"$kerneldir"/include
8444eb6e
AL
1153 if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) \
1154 -a -d "$kerneldir/arch/x86/include" ; then
1155 kvm_cflags="$kvm_cflags -I$kerneldir/arch/x86/include"
406b430d
AL
1156 elif test "$cpu" = "ppc" -a -d "$kerneldir/arch/powerpc/include" ; then
1157 kvm_cflags="$kvm_cflags -I$kerneldir/arch/powerpc/include"
8444eb6e
AL
1158 elif test -d "$kerneldir/arch/$cpu/include" ; then
1159 kvm_cflags="$kvm_cflags -I$kerneldir/arch/$cpu/include"
1160 fi
eac30262
AL
1161 else
1162 kvm_cflags=""
1163 fi
52166aa0 1164 if compile_prog "$kvm_cflags" "" ; then
7ba1e619
AL
1165 :
1166 else
9fd8d8d7
AL
1167 kvm="no";
1168 if [ -x "`which awk 2>/dev/null`" ] && \
1169 [ -x "`which grep 2>/dev/null`" ]; then
0c439cbf 1170 kvmerr=`LANG=C $cc $CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&1 \
9fd8d8d7
AL
1171 | grep "error: " \
1172 | awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'`
1173 if test "$kvmerr" != "" ; then
168ccc11
JK
1174 kvm="no - (${kvmerr})\n\
1175 NOTE: To enable KVM support, update your kernel to 2.6.29+ or install \
1176recent kvm-kmod from http://sourceforge.net/projects/kvm."
9fd8d8d7
AL
1177 fi
1178 fi
7ba1e619
AL
1179 fi
1180fi
1181
414f0dab 1182##########################################
e5d355d1 1183# pthread probe
de65fe0f 1184PTHREADLIBS_LIST="-lpthread -lpthreadGC2"
e5d355d1 1185PTHREADLIBS=""
3c529d93 1186
e5d355d1
AL
1187if test "$pthread" = yes; then
1188 pthread=no
1189cat > $TMPC << EOF
3c529d93 1190#include <pthread.h>
de65fe0f 1191int main(void) { pthread_create(0,0,0,0); return 0; }
414f0dab 1192EOF
de65fe0f 1193 for pthread_lib in $PTHREADLIBS_LIST; do
52166aa0 1194 if compile_prog "" "$pthread_lib" ; then
de65fe0f
SH
1195 pthread=yes
1196 PTHREADLIBS="$pthread_lib"
1197 break
1198 fi
1199 done
414f0dab
BS
1200fi
1201
e5d355d1
AL
1202if test "$pthread" = no; then
1203 aio=no
1204 io_thread=no
1205fi
1206
bf9298b9
AL
1207##########################################
1208# iovec probe
1209cat > $TMPC <<EOF
db34f0b3 1210#include <sys/types.h>
bf9298b9 1211#include <sys/uio.h>
db34f0b3 1212#include <unistd.h>
bf9298b9
AL
1213int main(void) { struct iovec iov; return 0; }
1214EOF
1215iovec=no
52166aa0 1216if compile_prog "" "" ; then
bf9298b9
AL
1217 iovec=yes
1218fi
1219
ceb42de8
AL
1220##########################################
1221# preadv probe
1222cat > $TMPC <<EOF
1223#include <sys/types.h>
1224#include <sys/uio.h>
1225#include <unistd.h>
1226int main(void) { preadv; }
1227EOF
1228preadv=no
52166aa0 1229if compile_prog "" "" ; then
ceb42de8
AL
1230 preadv=yes
1231fi
1232
f652e6af
AJ
1233##########################################
1234# fdt probe
1235if test "$fdt" = "yes" ; then
b41af4ba
JQ
1236 fdt=no
1237 fdt_libs="-lfdt"
1238 cat > $TMPC << EOF
f652e6af
AJ
1239int main(void) { return 0; }
1240EOF
52166aa0 1241 if compile_prog "" "$fdt_libs" ; then
f652e6af
AJ
1242 fdt=yes
1243 fi
1244fi
1245
3b3f24ad
AJ
1246#
1247# Check for xxxat() functions when we are building linux-user
1248# emulator. This is done because older glibc versions don't
1249# have syscall stubs for these implemented.
1250#
1251atfile=no
67ba57f6 1252cat > $TMPC << EOF
3b3f24ad
AJ
1253#define _ATFILE_SOURCE
1254#include <sys/types.h>
1255#include <fcntl.h>
1256#include <unistd.h>
1257
1258int
1259main(void)
1260{
1261 /* try to unlink nonexisting file */
1262 return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
1263}
1264EOF
52166aa0 1265if compile_prog "" "" ; then
67ba57f6 1266 atfile=yes
3b3f24ad
AJ
1267fi
1268
39386ac7 1269# Check for inotify functions when we are building linux-user
3b3f24ad
AJ
1270# emulator. This is done because older glibc versions don't
1271# have syscall stubs for these implemented. In that case we
1272# don't provide them even if kernel supports them.
1273#
1274inotify=no
67ba57f6 1275cat > $TMPC << EOF
3b3f24ad
AJ
1276#include <sys/inotify.h>
1277
1278int
1279main(void)
1280{
1281 /* try to start inotify */
8690e420 1282 return inotify_init();
3b3f24ad
AJ
1283}
1284EOF
52166aa0 1285if compile_prog "" "" ; then
67ba57f6 1286 inotify=yes
3b3f24ad
AJ
1287fi
1288
ebc996f3
RV
1289# check if utimensat and futimens are supported
1290utimens=no
1291cat > $TMPC << EOF
1292#define _ATFILE_SOURCE
1293#define _GNU_SOURCE
1294#include <stddef.h>
1295#include <fcntl.h>
1296
1297int main(void)
1298{
1299 utimensat(AT_FDCWD, "foo", NULL, 0);
1300 futimens(0, NULL);
1301 return 0;
1302}
1303EOF
52166aa0 1304if compile_prog "" "" ; then
ebc996f3
RV
1305 utimens=yes
1306fi
1307
099d6b0f
RV
1308# check if pipe2 is there
1309pipe2=no
1310cat > $TMPC << EOF
1311#define _GNU_SOURCE
1312#include <unistd.h>
1313#include <fcntl.h>
1314
1315int main(void)
1316{
1317 int pipefd[2];
1318 pipe2(pipefd, O_CLOEXEC);
1319 return 0;
1320}
1321EOF
52166aa0 1322if compile_prog "" "" ; then
099d6b0f
RV
1323 pipe2=yes
1324fi
1325
3ce34dfb 1326# check if tee/splice is there. vmsplice was added same time.
1327splice=no
1328cat > $TMPC << EOF
1329#define _GNU_SOURCE
1330#include <unistd.h>
1331#include <fcntl.h>
1332#include <limits.h>
1333
1334int main(void)
1335{
1336 int len, fd;
1337 len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
1338 splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
1339 return 0;
1340}
1341EOF
52166aa0 1342if compile_prog "" "" ; then
3ce34dfb 1343 splice=yes
1344fi
1345
cc8ae6de 1346# Check if tools are available to build documentation.
70ec5dc0
AL
1347if test "$build_docs" = "yes" -a \( ! -x "`which texi2html 2>/dev/null`" -o ! -x "`which pod2man 2>/dev/null`" \) ; then
1348 build_docs="no"
cc8ae6de
PB
1349fi
1350
6ae9a1f4
JQ
1351# Search for bsawp_32 function
1352byteswap_h=no
1353cat > $TMPC << EOF
1354#include <byteswap.h>
1355int main(void) { return bswap_32(0); }
1356EOF
52166aa0 1357if compile_prog "" "" ; then
6ae9a1f4
JQ
1358 byteswap_h=yes
1359fi
1360
1361# Search for bsawp_32 function
1362bswap_h=no
1363cat > $TMPC << EOF
1364#include <sys/endian.h>
1365#include <sys/types.h>
1366#include <machine/bswap.h>
1367int main(void) { return bswap32(0); }
1368EOF
52166aa0 1369if compile_prog "" "" ; then
6ae9a1f4
JQ
1370 bswap_h=yes
1371fi
1372
da93a1fd
AL
1373##########################################
1374# Do we need librt
1375cat > $TMPC <<EOF
1376#include <signal.h>
1377#include <time.h>
1378int main(void) { clockid_t id; return clock_gettime(id, NULL); }
1379EOF
1380
52166aa0 1381if compile_prog "" "" ; then
5169202b 1382 CLOCKLIBS=""
52166aa0 1383elif compile_prog "" "-lrt" ; then
e5d355d1 1384 CLOCKLIBS="-lrt"
da93a1fd
AL
1385fi
1386
a36abbbb
JQ
1387# Determine what linker flags to use to force archive inclusion
1388check_linker_flags()
1389{
1390 w2=
1391 if test "$2" ; then
1392 w2=-Wl,$2
1393 fi
52166aa0 1394 compile_prog "" "-Wl,$1 ${w2}"
a36abbbb
JQ
1395}
1396
1397cat > $TMPC << EOF
1398int main(void) { }
1399EOF
1400if check_linker_flags --whole-archive --no-whole-archive ; then
1401 # GNU ld
1402 arlibs_begin="-Wl,--whole-archive"
1403 arlibs_end="-Wl,--no-whole-archive"
1404elif check_linker_flags -z,allextract -z,defaultextract ; then
1405 # Solaris ld
1406 arlibs_begin"=-Wl,-z,allextract"
1407 arlibs_end="-Wl,-z,defaultextract"
1408elif check_linker_flags -all_load ; then
1409 # Mac OS X
1410 arlibs_begin="-all_load"
1411 arlibs_end=""
1412else
1413 echo "Error: your linker does not support --whole-archive or -z."
1414 echo "Please report to qemu-devel@nongnu.org"
1415 exit 1
1416fi
1417
e86ecd4b
JQ
1418# End of CC checks
1419# After here, no more $cc or $ld runs
1420
1421# default flags for all hosts
1156c669 1422CFLAGS="-g -fno-strict-aliasing $CFLAGS"
e86ecd4b 1423if test "$debug" = "no" ; then
1156c669 1424 CFLAGS="-O2 $CFLAGS"
e86ecd4b 1425fi
1156c669
JQ
1426CFLAGS="-Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls $CFLAGS"
1427LDFLAGS="-g $LDFLAGS"
e86ecd4b
JQ
1428
1429# Consult white-list to determine whether to enable werror
1430# by default. Only enable by default for git builds
1431if test -z "$werror" ; then
1432 z_version=`cut -f3 -d. $source_path/VERSION`
1433 if test "$z_version" = "50" -a \
1434 "$linux" = "yes" ; then
1435 werror="yes"
1436 else
1437 werror="no"
1438 fi
1439fi
1440
1441if test "$werror" = "yes" ; then
1156c669 1442 CFLAGS="-Werror $CFLAGS"
e86ecd4b
JQ
1443fi
1444
1445if test "$solaris" = "no" ; then
1446 if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
1156c669 1447 LDFLAGS="-Wl,--warn-common $LDFLAGS"
e86ecd4b
JQ
1448 fi
1449fi
1450
11d9f695 1451if test "$mingw32" = "yes" ; then
308c3593 1452 if test -z "$prefix" ; then
55418b96 1453 prefix="c:/Program Files/Qemu"
308c3593
PB
1454 fi
1455 mansuffix=""
1456 datasuffix=""
1457 docsuffix=""
1458 binsuffix=""
11d9f695 1459else
308c3593
PB
1460 if test -z "$prefix" ; then
1461 prefix="/usr/local"
1462 fi
1463 mansuffix="/share/man"
1464 datasuffix="/share/qemu"
1465 docsuffix="/share/doc/qemu"
1466 binsuffix="/bin"
11d9f695 1467fi
5a67135a 1468
43ce4dfe 1469echo "Install prefix $prefix"
308c3593
PB
1470echo "BIOS directory $prefix$datasuffix"
1471echo "binary directory $prefix$binsuffix"
11d9f695 1472if test "$mingw32" = "no" ; then
308c3593 1473echo "Manual directory $prefix$mansuffix"
43ce4dfe 1474echo "ELF interp prefix $interp_prefix"
11d9f695 1475fi
5a67135a 1476echo "Source path $source_path"
43ce4dfe 1477echo "C compiler $cc"
83469015 1478echo "Host C compiler $host_cc"
0c439cbf
JQ
1479echo "CFLAGS $CFLAGS"
1480echo "LDFLAGS $LDFLAGS"
43ce4dfe 1481echo "make $make"
6a882643 1482echo "install $install"
43ce4dfe 1483echo "host CPU $cpu"
de83cd02 1484echo "host big endian $bigendian"
97a847bc 1485echo "target list $target_list"
ade25b0d 1486echo "tcg debug enabled $debug_tcg"
43ce4dfe 1487echo "gprof enabled $gprof"
03b4fe7d 1488echo "sparse enabled $sparse"
1625af87 1489echo "strip binaries $strip_opt"
05c2a3e7 1490echo "profiler $profiler"
43ce4dfe 1491echo "static build $static"
85aa5189 1492echo "-Werror enabled $werror"
5b0753e0
FB
1493if test "$darwin" = "yes" ; then
1494 echo "Cocoa support $cocoa"
1495fi
97a847bc 1496echo "SDL support $sdl"
4d3b6f6e 1497echo "curses support $curses"
769ce76d 1498echo "curl support $curl"
67b915a5 1499echo "mingw32 support $mingw32"
0c58ac1c 1500echo "Audio drivers $audio_drv_list"
1501echo "Extra audio cards $audio_card_list"
8ff9cbf7 1502echo "Mixer emulation $mixemu"
8d5d2d4c
TS
1503echo "VNC TLS support $vnc_tls"
1504if test "$vnc_tls" = "yes" ; then
1505 echo " TLS CFLAGS $vnc_tls_cflags"
1506 echo " TLS LIBS $vnc_tls_libs"
1507fi
2f9606b3
AL
1508echo "VNC SASL support $vnc_sasl"
1509if test "$vnc_sasl" = "yes" ; then
1510 echo " SASL CFLAGS $vnc_sasl_cflags"
1511 echo " SASL LIBS $vnc_sasl_libs"
1512fi
3142255c
BS
1513if test -n "$sparc_cpu"; then
1514 echo "Target Sparc Arch $sparc_cpu"
1515fi
07f4ddbf 1516echo "kqemu support $kqemu"
e37630ca 1517echo "xen support $xen"
2e4d9fb1 1518echo "brlapi support $brlapi"
cc8ae6de 1519echo "Documentation $build_docs"
c5937220
PB
1520[ ! -z "$uname_release" ] && \
1521echo "uname -r $uname_release"
bd0c5661 1522echo "NPTL support $nptl"
379f6698 1523echo "GUEST_BASE $guest_base"
8a16d273 1524echo "vde support $vde"
414f0dab 1525echo "AIO support $aio"
e5d355d1 1526echo "IO thread $io_thread"
77755340 1527echo "Install blobs $blobs"
168ccc11 1528echo -e "KVM support $kvm"
f652e6af 1529echo "fdt support $fdt"
ceb42de8 1530echo "preadv support $preadv"
67b915a5 1531
97a847bc 1532if test $sdl_too_old = "yes"; then
24b55b96 1533echo "-> Your SDL version is too old - please upgrade to have SDL support"
7c1f25b4 1534fi
7d13299d 1535
98ec69ac
JQ
1536config_host_mak="config-host.mak"
1537config_host_h="config-host.h"
4bf6b55b 1538config_host_ld="config-host.ld"
98ec69ac
JQ
1539
1540#echo "Creating $config_host_mak and $config_host_h"
1541
1542test -f $config_host_h && mv $config_host_h ${config_host_h}~
1543
1544echo "# Automatically generated by configure - do not modify" > $config_host_mak
1545printf "# Configured with:" >> $config_host_mak
1546printf " '%s'" "$0" "$@" >> $config_host_mak
1547echo >> $config_host_mak
98ec69ac 1548
2358a494 1549echo "CONFIG_QEMU_SHAREDIR=\"$prefix$datasuffix\"" >> $config_host_mak
804edf29 1550
2408a527 1551case "$cpu" in
c62bbcd3 1552 i386|x86_64|alpha|cris|hppa|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|s390|sparc|sparc64)
e0da9dd3 1553 ARCH=$cpu
2408a527 1554 ;;
a302c32d 1555 armv4b|armv4l)
16dbd14f 1556 ARCH=arm
2408a527 1557 ;;
2408a527
AJ
1558 *)
1559 echo "Unsupported CPU = $cpu"
1560 exit 1
1561 ;;
1562esac
98ec69ac 1563echo "ARCH=$ARCH" >> $config_host_mak
f8393946 1564if test "$debug_tcg" = "yes" ; then
2358a494 1565 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
f8393946 1566fi
f3d08ee6 1567if test "$debug" = "yes" ; then
2358a494 1568 echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
f3d08ee6 1569fi
1625af87 1570if test "$strip_opt" = "yes" ; then
98ec69ac 1571 echo "STRIP_OPT=-s" >> $config_host_mak
1625af87 1572fi
7d13299d 1573if test "$bigendian" = "yes" ; then
e2542fe2 1574 echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
97a847bc 1575fi
2358a494 1576echo "HOST_LONG_BITS=$hostlongbits" >> $config_host_mak
67b915a5 1577if test "$mingw32" = "yes" ; then
98ec69ac 1578 echo "CONFIG_WIN32=y" >> $config_host_mak
210fa556 1579else
35f4df27 1580 echo "CONFIG_POSIX=y" >> $config_host_mak
67b915a5 1581fi
128ab2ff 1582
83fb7adf 1583if test "$darwin" = "yes" ; then
98ec69ac 1584 echo "CONFIG_DARWIN=y" >> $config_host_mak
83fb7adf 1585fi
b29fe3ed 1586
1587if test "$aix" = "yes" ; then
98ec69ac 1588 echo "CONFIG_AIX=y" >> $config_host_mak
b29fe3ed 1589fi
1590
ec530c81 1591if test "$solaris" = "yes" ; then
98ec69ac 1592 echo "CONFIG_SOLARIS=y" >> $config_host_mak
2358a494 1593 echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
0475a5ca 1594 if test "$needs_libsunmath" = "yes" ; then
75b5a697 1595 echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
0475a5ca 1596 fi
ec530c81 1597fi
97a847bc 1598if test "$gprof" = "yes" ; then
98ec69ac 1599 echo "TARGET_GPROF=yes" >> $config_host_mak
97a847bc
FB
1600fi
1601if test "$static" = "yes" ; then
98ec69ac 1602 echo "CONFIG_STATIC=y" >> $config_host_mak
1156c669 1603 LDFLAGS="-static $LDFLAGS"
7d13299d 1604fi
05c2a3e7 1605if test $profiler = "yes" ; then
2358a494 1606 echo "CONFIG_PROFILER=y" >> $config_host_mak
05c2a3e7 1607fi
c20709aa 1608if test "$slirp" = "yes" ; then
98ec69ac 1609 echo "CONFIG_SLIRP=y" >> $config_host_mak
c20709aa 1610fi
8a16d273 1611if test "$vde" = "yes" ; then
98ec69ac 1612 echo "CONFIG_VDE=y" >> $config_host_mak
4baae0ac 1613 echo "VDE_LIBS=$vde_libs" >> $config_host_mak
8a16d273 1614fi
0c58ac1c 1615for card in $audio_card_list; do
f6e5889e 1616 def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
98ec69ac 1617 echo "$def=y" >> $config_host_mak
0c58ac1c 1618done
2358a494 1619echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
0c58ac1c 1620for drv in $audio_drv_list; do
f6e5889e 1621 def=CONFIG_`echo $drv | tr '[:lower:]' '[:upper:]'`
98ec69ac 1622 echo "$def=y" >> $config_host_mak
923e4521 1623 if test "$drv" = "fmod"; then
7aac6cb1
JQ
1624 echo "FMOD_LIBS=$fmod_lib" >> $config_host_mak
1625 echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
2f6a1ab0 1626 elif test "$drv" = "oss"; then
6881964c 1627 echo "OSS_LIBS=$oss_lib" >> $config_host_mak
0c58ac1c 1628 fi
1629done
8ff9cbf7 1630if test "$mixemu" = "yes" ; then
98ec69ac 1631 echo "CONFIG_MIXEMU=y" >> $config_host_mak
8ff9cbf7 1632fi
8d5d2d4c 1633if test "$vnc_tls" = "yes" ; then
98ec69ac 1634 echo "CONFIG_VNC_TLS=y" >> $config_host_mak
525061bf
JQ
1635 echo "VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_host_mak
1636 echo "VNC_TLS_LIBS=$vnc_tls_libs" >> $config_host_mak
8d5d2d4c 1637fi
2f9606b3 1638if test "$vnc_sasl" = "yes" ; then
98ec69ac 1639 echo "CONFIG_VNC_SASL=y" >> $config_host_mak
60ddf533
JQ
1640 echo "VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak
1641 echo "VNC_SASL_LIBS=$vnc_sasl_libs" >> $config_host_mak
2f9606b3 1642fi
76655d6d 1643if test "$fnmatch" = "yes" ; then
2358a494 1644 echo "CONFIG_FNMATCH=y" >> $config_host_mak
76655d6d 1645fi
b1a550a0 1646qemu_version=`head $source_path/VERSION`
98ec69ac 1647echo "VERSION=$qemu_version" >>$config_host_mak
2358a494 1648echo "PKGVERSION=$pkgversion" >>$config_host_mak
98ec69ac 1649echo "SRC_PATH=$source_path" >> $config_host_mak
ad064840 1650if [ "$source_path_used" = "yes" ]; then
98ec69ac 1651 echo "VPATH=$source_path" >> $config_host_mak
ad064840 1652fi
98ec69ac 1653echo "TARGET_DIRS=$target_list" >> $config_host_mak
cc8ae6de 1654if [ "$build_docs" = "yes" ] ; then
98ec69ac 1655 echo "BUILD_DOCS=yes" >> $config_host_mak
cc8ae6de 1656fi
1ac88f28 1657if test "$sdl" = "yes" ; then
98ec69ac 1658 echo "CONFIG_SDL=y" >> $config_host_mak
1ac88f28
JQ
1659 echo "SDL_LIBS=$sdl_libs" >> $config_host_mak
1660 echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
49ecc3fa
FB
1661fi
1662if test "$cocoa" = "yes" ; then
98ec69ac 1663 echo "CONFIG_COCOA=y" >> $config_host_mak
4d3b6f6e
AZ
1664fi
1665if test "$curses" = "yes" ; then
98ec69ac 1666 echo "CONFIG_CURSES=y" >> $config_host_mak
e0b7a42b 1667 echo "CURSES_LIBS=$curses_libs" >> $config_host_mak
49ecc3fa 1668fi
3b3f24ad 1669if test "$atfile" = "yes" ; then
2358a494 1670 echo "CONFIG_ATFILE=y" >> $config_host_mak
3b3f24ad 1671fi
ebc996f3 1672if test "$utimens" = "yes" ; then
2358a494 1673 echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
ebc996f3 1674fi
099d6b0f 1675if test "$pipe2" = "yes" ; then
2358a494 1676 echo "CONFIG_PIPE2=y" >> $config_host_mak
099d6b0f 1677fi
3ce34dfb 1678if test "$splice" = "yes" ; then
2358a494 1679 echo "CONFIG_SPLICE=y" >> $config_host_mak
3ce34dfb 1680fi
3b3f24ad 1681if test "$inotify" = "yes" ; then
2358a494 1682 echo "CONFIG_INOTIFY=y" >> $config_host_mak
3b3f24ad 1683fi
6ae9a1f4
JQ
1684if test "$byteswap_h" = "yes" ; then
1685 echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
1686fi
1687if test "$bswap_h" = "yes" ; then
1688 echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
1689fi
769ce76d 1690if test "$curl" = "yes" ; then
98ec69ac 1691 echo "CONFIG_CURL=y" >> $config_host_mak
b1d5a277 1692 echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
98ec69ac 1693 echo "CURL_LIBS=$curl_libs" >> $config_host_mak
769ce76d 1694fi
2e4d9fb1 1695if test "$brlapi" = "yes" ; then
98ec69ac 1696 echo "CONFIG_BRLAPI=y" >> $config_host_mak
eb82284f 1697 echo "BRLAPI_LIBS=$brlapi_libs" >> $config_host_mak
2e4d9fb1 1698fi
fb599c9a 1699if test "$bluez" = "yes" ; then
98ec69ac 1700 echo "CONFIG_BLUEZ=y" >> $config_host_mak
ef7635ec
JQ
1701 echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
1702 echo "BLUEZ_LIBS=$bluez_libs" >> $config_host_mak
fb599c9a 1703fi
e37630ca 1704if test "$xen" = "yes" ; then
5647eb74 1705 echo "CONFIG_XEN=y" >> $config_host_mak
b2266bee 1706 echo "XEN_LIBS=$xen_libs" >> $config_host_mak
e37630ca 1707fi
414f0dab 1708if test "$aio" = "yes" ; then
98ec69ac 1709 echo "CONFIG_AIO=y" >> $config_host_mak
414f0dab 1710fi
e5d355d1 1711if test "$io_thread" = "yes" ; then
98ec69ac 1712 echo "CONFIG_IOTHREAD=y" >> $config_host_mak
e5d355d1 1713fi
77755340 1714if test "$blobs" = "yes" ; then
98ec69ac 1715 echo "INSTALL_BLOBS=yes" >> $config_host_mak
77755340 1716fi
bf9298b9 1717if test "$iovec" = "yes" ; then
2358a494 1718 echo "CONFIG_IOVEC=y" >> $config_host_mak
bf9298b9 1719fi
ceb42de8 1720if test "$preadv" = "yes" ; then
2358a494 1721 echo "CONFIG_PREADV=y" >> $config_host_mak
ceb42de8 1722fi
f652e6af 1723if test "$fdt" = "yes" ; then
3f0855b1 1724 echo "CONFIG_FDT=y" >> $config_host_mak
b41af4ba 1725 echo "FDT_LIBS=$fdt_libs" >> $config_host_mak
f652e6af 1726fi
97a847bc 1727
83fb7adf 1728# XXX: suppress that
7d3505c5 1729if [ "$bsd" = "yes" ] ; then
2358a494 1730 echo "CONFIG_BSD=y" >> $config_host_mak
7d3505c5
FB
1731fi
1732
2358a494 1733echo "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
c5937220 1734
68063649
BS
1735# USB host support
1736case "$usb" in
1737linux)
98ec69ac 1738 echo "HOST_USB=linux" >> $config_host_mak
68063649
BS
1739;;
1740bsd)
98ec69ac 1741 echo "HOST_USB=bsd" >> $config_host_mak
68063649
BS
1742;;
1743*)
98ec69ac 1744 echo "HOST_USB=stub" >> $config_host_mak
68063649
BS
1745;;
1746esac
1747
c39e3338
PB
1748tools=
1749if test `expr "$target_list" : ".*softmmu.*"` != 0 ; then
3dd1f8ef 1750 tools="qemu-img\$(EXESUF) $tools"
7a5ca864 1751 if [ "$linux" = "yes" ] ; then
3dd1f8ef 1752 tools="qemu-nbd\$(EXESUF) qemu-io\$(EXESUF) $tools"
7a5ca864 1753 fi
c39e3338 1754fi
98ec69ac 1755echo "TOOLS=$tools" >> $config_host_mak
c39e3338 1756
161294d8 1757# Mac OS X ships with a broken assembler
253d0942 1758roms=
161294d8
JQ
1759if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
1760 "$targetos" != "Darwin" ; then
c05ac895 1761 roms="optionrom"
253d0942 1762fi
98ec69ac 1763echo "ROMS=$roms" >> $config_host_mak
253d0942 1764
804edf29
JQ
1765echo "prefix=$prefix" >> $config_host_mak
1766echo "bindir=\${prefix}$binsuffix" >> $config_host_mak
1767echo "mandir=\${prefix}$mansuffix" >> $config_host_mak
1768echo "datadir=\${prefix}$datasuffix" >> $config_host_mak
1769echo "docdir=\${prefix}$docsuffix" >> $config_host_mak
1770echo "MAKE=$make" >> $config_host_mak
1771echo "INSTALL=$install" >> $config_host_mak
1772echo "INSTALL_DIR=$install -d -m0755 -p" >> $config_host_mak
1773echo "INSTALL_DATA=$install -m0644 -p" >> $config_host_mak
1774echo "INSTALL_PROG=$install -m0755 -p" >> $config_host_mak
1775echo "CC=$cc" >> $config_host_mak
1776echo "HOST_CC=$host_cc" >> $config_host_mak
1777if test "$sparse" = "yes" ; then
1778 echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_host_mak
1779 echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_host_mak
1780 echo "CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
1781fi
1782echo "AR=$ar" >> $config_host_mak
1783echo "OBJCOPY=$objcopy" >> $config_host_mak
1784echo "LD=$ld" >> $config_host_mak
e2a2ed06
JQ
1785echo "CFLAGS=$CFLAGS" >> $config_host_mak
1786echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
a36abbbb
JQ
1787echo "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak
1788echo "ARLIBS_END=$arlibs_end" >> $config_host_mak
804edf29
JQ
1789echo "EXESUF=$EXESUF" >> $config_host_mak
1790echo "PTHREADLIBS=$PTHREADLIBS" >> $config_host_mak
1791echo "CLOCKLIBS=$CLOCKLIBS" >> $config_host_mak
1792
2358a494
JQ
1793echo "/* Automatically generated by configure - do not modify */" > $config_host_h
1794
0ff6697d 1795$SHELL $source_path/create_config < $config_host_mak >> $config_host_h
2358a494 1796
98ec69ac
JQ
1797if test -f ${config_host_h}~ ; then
1798 if cmp -s $config_host_h ${config_host_h}~ ; then
1799 mv ${config_host_h}~ $config_host_h
370ab986 1800 else
98ec69ac 1801 rm ${config_host_h}~
370ab986
PB
1802 fi
1803fi
1804
4bf6b55b
JQ
1805# generate list of library paths for linker script
1806
1807$ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
1808
1809if test -f ${config_host_ld}~ ; then
1810 if cmp -s $config_host_ld ${config_host_ld}~ ; then
1811 mv ${config_host_ld}~ $config_host_ld
1812 else
1813 rm ${config_host_ld}~
1814 fi
1815fi
1816
1d14ffa9 1817for target in $target_list; do
97a847bc
FB
1818target_dir="$target"
1819config_mak=$target_dir/config.mak
1820config_h=$target_dir/config.h
600309b6 1821target_arch2=`echo $target | cut -d '-' -f 1`
97a847bc 1822target_bigendian="no"
ea2d6a39
JQ
1823case "$target_arch2" in
1824 armeb|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|sh4eb|sparc|sparc64|sparc32plus)
1825 target_bigendian=yes
1826 ;;
1827esac
97a847bc 1828target_softmmu="no"
997344f3 1829target_user_only="no"
831b7825 1830target_linux_user="no"
831b7825 1831target_darwin_user="no"
84778508 1832target_bsd_user="no"
9e407a85 1833case "$target" in
600309b6 1834 ${target_arch2}-softmmu)
9e407a85
PB
1835 target_softmmu="yes"
1836 ;;
600309b6 1837 ${target_arch2}-linux-user)
9e407a85
PB
1838 target_user_only="yes"
1839 target_linux_user="yes"
1840 ;;
600309b6 1841 ${target_arch2}-darwin-user)
9e407a85
PB
1842 target_user_only="yes"
1843 target_darwin_user="yes"
1844 ;;
600309b6 1845 ${target_arch2}-bsd-user)
84778508
BS
1846 target_user_only="yes"
1847 target_bsd_user="yes"
1848 ;;
9e407a85
PB
1849 *)
1850 echo "ERROR: Target '$target' not recognised"
1851 exit 1
1852 ;;
1853esac
831b7825 1854
7c1f25b4 1855#echo "Creating $config_mak, $config_h and $target_dir/Makefile"
97a847bc 1856
15d9ca0f
TS
1857test -f $config_h && mv $config_h ${config_h}~
1858
97a847bc 1859mkdir -p $target_dir
158142c2 1860mkdir -p $target_dir/fpu
57fec1fe 1861mkdir -p $target_dir/tcg
84778508 1862if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
69de927c
FB
1863 mkdir -p $target_dir/nwfpe
1864fi
1865
ec530c81
FB
1866#
1867# don't use ln -sf as not all "ln -sf" over write the file/link
1868#
1869rm -f $target_dir/Makefile
1870ln -s $source_path/Makefile.target $target_dir/Makefile
1871
97a847bc
FB
1872
1873echo "# Automatically generated by configure - do not modify" > $config_mak
de83cd02 1874
97a847bc 1875echo "include ../config-host.mak" >> $config_mak
1e43adfc 1876
e5fe0c52 1877bflt="no"
cb33da57 1878elfload32="no"
bd0c5661 1879target_nptl="no"
600309b6 1880interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
42bc608b 1881echo "CONFIG_QEMU_PREFIX=\"$interp_prefix1\"" >> $config_mak
56aebc89 1882gdb_xml_files=""
7ba1e619 1883
938b1edd 1884TARGET_ARCH="$target_arch2"
6acff7da 1885TARGET_BASE_ARCH=""
e6e91b9c 1886TARGET_ABI_DIR=""
e73aae67 1887
600309b6 1888case "$target_arch2" in
2408a527 1889 i386)
1ad2134f 1890 target_phys_bits=32
2408a527
AJ
1891 ;;
1892 x86_64)
6acff7da 1893 TARGET_BASE_ARCH=i386
1ad2134f 1894 target_phys_bits=64
2408a527
AJ
1895 ;;
1896 alpha)
1ad2134f 1897 target_phys_bits=64
2408a527
AJ
1898 ;;
1899 arm|armeb)
b498c8a0 1900 TARGET_ARCH=arm
2408a527 1901 bflt="yes"
bd0c5661 1902 target_nptl="yes"
56aebc89 1903 gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
1ad2134f 1904 target_phys_bits=32
2408a527
AJ
1905 ;;
1906 cris)
253bd7f8 1907 target_nptl="yes"
1ad2134f 1908 target_phys_bits=32
2408a527
AJ
1909 ;;
1910 m68k)
2408a527 1911 bflt="yes"
56aebc89 1912 gdb_xml_files="cf-core.xml cf-fp.xml"
1ad2134f 1913 target_phys_bits=32
2408a527 1914 ;;
72b675ca 1915 microblaze)
72b675ca
EI
1916 bflt="yes"
1917 target_nptl="yes"
1918 target_phys_bits=32
1919 ;;
0adcffb1 1920 mips|mipsel)
b498c8a0 1921 TARGET_ARCH=mips
42bc608b 1922 echo "TARGET_ABI_MIPSO32=y" >> $config_mak
f04dc72f 1923 target_nptl="yes"
1ad2134f 1924 target_phys_bits=64
2408a527
AJ
1925 ;;
1926 mipsn32|mipsn32el)
b498c8a0 1927 TARGET_ARCH=mipsn32
6acff7da 1928 TARGET_BASE_ARCH=mips
42bc608b 1929 echo "TARGET_ABI_MIPSN32=y" >> $config_mak
1ad2134f 1930 target_phys_bits=64
2408a527
AJ
1931 ;;
1932 mips64|mips64el)
b498c8a0 1933 TARGET_ARCH=mips64
6acff7da 1934 TARGET_BASE_ARCH=mips
42bc608b 1935 echo "TARGET_ABI_MIPSN64=y" >> $config_mak
1ad2134f 1936 target_phys_bits=64
2408a527
AJ
1937 ;;
1938 ppc)
c8b3532d 1939 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
1ad2134f 1940 target_phys_bits=32
d6630708 1941 target_nptl="yes"
2408a527
AJ
1942 ;;
1943 ppcemb)
6acff7da 1944 TARGET_BASE_ARCH=ppc
e6e91b9c 1945 TARGET_ABI_DIR=ppc
c8b3532d 1946 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
1ad2134f 1947 target_phys_bits=64
d6630708 1948 target_nptl="yes"
2408a527
AJ
1949 ;;
1950 ppc64)
6acff7da 1951 TARGET_BASE_ARCH=ppc
e6e91b9c 1952 TARGET_ABI_DIR=ppc
c8b3532d 1953 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
1ad2134f 1954 target_phys_bits=64
2408a527
AJ
1955 ;;
1956 ppc64abi32)
b498c8a0 1957 TARGET_ARCH=ppc64
6acff7da 1958 TARGET_BASE_ARCH=ppc
e6e91b9c 1959 TARGET_ABI_DIR=ppc
42bc608b 1960 echo "TARGET_ABI32=y" >> $config_mak
c8b3532d 1961 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
1ad2134f 1962 target_phys_bits=64
2408a527
AJ
1963 ;;
1964 sh4|sh4eb)
b498c8a0 1965 TARGET_ARCH=sh4
2408a527 1966 bflt="yes"
0b6d3ae0 1967 target_nptl="yes"
1ad2134f 1968 target_phys_bits=32
2408a527
AJ
1969 ;;
1970 sparc)
1ad2134f 1971 target_phys_bits=64
2408a527
AJ
1972 ;;
1973 sparc64)
6acff7da 1974 TARGET_BASE_ARCH=sparc
2408a527 1975 elfload32="yes"
1ad2134f 1976 target_phys_bits=64
2408a527
AJ
1977 ;;
1978 sparc32plus)
b498c8a0 1979 TARGET_ARCH=sparc64
6acff7da 1980 TARGET_BASE_ARCH=sparc
e6e91b9c 1981 TARGET_ABI_DIR=sparc
42bc608b 1982 echo "TARGET_ABI32=y" >> $config_mak
1ad2134f 1983 target_phys_bits=64
2408a527
AJ
1984 ;;
1985 *)
1986 echo "Unsupported target CPU"
1987 exit 1
1988 ;;
1989esac
b498c8a0 1990echo "TARGET_ARCH=$TARGET_ARCH" >> $config_mak
0adcffb1 1991echo "TARGET_ARCH2=$target_arch2" >> $config_mak
42bc608b 1992# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
6acff7da
JQ
1993if [ "$TARGET_BASE_ARCH" = "" ]; then
1994 TARGET_BASE_ARCH=$TARGET_ARCH
6acff7da
JQ
1995fi
1996echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_mak
e6e91b9c
JQ
1997if [ "$TARGET_ABI_DIR" = "" ]; then
1998 TARGET_ABI_DIR=$TARGET_ARCH
1999fi
2000echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_mak
1ad2134f
PB
2001if [ $target_phys_bits -lt $hostlongbits ] ; then
2002 target_phys_bits=$hostlongbits
2003fi
1b0c87fc
JQ
2004case "$target_arch2" in
2005 i386|x86_64)
2006 if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
2007 echo "CONFIG_XEN=y" >> $config_mak
1b0c87fc 2008 fi
0d46b7ed
JQ
2009 if test $kqemu = "yes" -a "$target_softmmu" = "yes"
2010 then
2011 echo "CONFIG_KQEMU=y" >> $config_mak
0d46b7ed 2012 fi
1b0c87fc 2013esac
c59249f9 2014case "$target_arch2" in
5f114bc6 2015 i386|x86_64|ppcemb|ppc|ppc64)
c59249f9
JQ
2016 # Make sure the target and host cpus are compatible
2017 if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
2018 \( "$target_arch2" = "$cpu" -o \
2019 \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
5f114bc6 2020 \( "$target_arch2" = "ppc64" -a "$cpu" = "ppc" \) -o \
c59249f9
JQ
2021 \( "$target_arch2" = "x86_64" -a "$cpu" = "i386" \) -o \
2022 \( "$target_arch2" = "i386" -a "$cpu" = "x86_64" \) \) ; then
2023 echo "CONFIG_KVM=y" >> $config_mak
2024 echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak
c59249f9
JQ
2025 fi
2026esac
1ad2134f 2027echo "HWLIB=../libhw$target_phys_bits/libqemuhw$target_phys_bits.a" >> $config_mak
42bc608b 2028echo "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_mak
1ad2134f 2029echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
de83cd02 2030if test "$target_bigendian" = "yes" ; then
42bc608b 2031 echo "TARGET_WORDS_BIGENDIAN=y" >> $config_mak
de83cd02 2032fi
97a847bc 2033if test "$target_softmmu" = "yes" ; then
e34af2ce 2034 echo "CONFIG_SOFTMMU=y" >> $config_mak
43ce4dfe 2035fi
997344f3 2036if test "$target_user_only" = "yes" ; then
e34af2ce 2037 echo "CONFIG_USER_ONLY=y" >> $config_mak
997344f3 2038fi
831b7825 2039if test "$target_linux_user" = "yes" ; then
e34af2ce 2040 echo "CONFIG_LINUX_USER=y" >> $config_mak
831b7825
TS
2041fi
2042if test "$target_darwin_user" = "yes" ; then
e34af2ce 2043 echo "CONFIG_DARWIN_USER=y" >> $config_mak
831b7825 2044fi
56aebc89
PB
2045list=""
2046if test ! -z "$gdb_xml_files" ; then
2047 for x in $gdb_xml_files; do
2048 list="$list $source_path/gdb-xml/$x"
2049 done
2050fi
2051echo "TARGET_XML_FILES=$list" >> $config_mak
97a847bc 2052
f57975fb
JQ
2053case "$target_arch2" in
2054 arm|armeb|m68k|microblaze|mips|mipsel|mipsn32|mipsn32el|mips64|mips64el|ppc|ppc64|ppc64abi32|ppcemb|sparc|sparc64|sparc32plus)
2055 echo "CONFIG_SOFTFLOAT=y" >> $config_mak
f57975fb
JQ
2056 ;;
2057esac
2058
e5fe0c52 2059if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
e34af2ce 2060 echo "TARGET_HAS_BFLT=y" >> $config_mak
e5fe0c52 2061fi
bd0c5661
PB
2062if test "$target_user_only" = "yes" \
2063 -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
2f7bb878 2064 echo "CONFIG_USE_NPTL=y" >> $config_mak
bd0c5661 2065fi
cb33da57
BS
2066# 32 bit ELF loader in addition to native 64 bit loader?
2067if test "$target_user_only" = "yes" -a "$elfload32" = "yes"; then
e34af2ce 2068 echo "TARGET_HAS_ELFLOAD32=y" >> $config_mak
cb33da57 2069fi
379f6698
PB
2070if test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
2071 echo "CONFIG_USE_GUEST_BASE=y" >> $config_mak
2072fi
84778508 2073if test "$target_bsd_user" = "yes" ; then
e34af2ce 2074 echo "CONFIG_BSD_USER=y" >> $config_mak
84778508 2075fi
5b0753e0 2076
fa282484
JQ
2077# generate LDFLAGS for targets
2078
2079ldflags=""
2080if test "$target_linux_user" = "yes" -o "$target_linux_user" = "yes" ; then
2081 case "$ARCH" in
2082 i386)
2083 if test "$gprof" = "yes" -o "$static" = "yes" ; then
4bf6b55b 2084 ldflags='-Wl,-T../config-host.ld -Wl,-T,$(SRC_PATH)/$(ARCH).ld'
fa282484
JQ
2085 else
2086 # WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
2087 # that the kernel ELF loader considers as an executable. I think this
2088 # is the simplest way to make it self virtualizable!
2089 ldflags='-Wl,-shared'
2090 fi
2091 ;;
2092 sparc)
2093 # -static is used to avoid g1/g3 usage by the dynamic linker
4bf6b55b 2094 ldflags='-Wl,-T../config-host.ld -Wl,-T,$(SRC_PATH)/$(ARCH).ld -static'
fa282484
JQ
2095 ;;
2096 ia64)
4bf6b55b 2097 ldflags='-Wl,-G0 -Wl,-T../config-host.ld -Wl,-T,$(SRC_PATH)/$(ARCH).ld -static'
fa282484
JQ
2098 ;;
2099 x86_64|ppc|ppc64|s390|sparc64|alpha|arm|m68k|mips|mips64)
4bf6b55b 2100 ldflags='-Wl,-T../config-host.ld -Wl,-T,$(SRC_PATH)/$(ARCH).ld'
fa282484
JQ
2101 ;;
2102 esac
2103fi
2104if test "$target_softmmu" = "yes" ; then
2105 case "$ARCH" in
2106 ia64)
4bf6b55b 2107 ldflags='-Wl,-G0 -Wl,-T../config-host.ld -Wl,-T,$(SRC_PATH)/$(ARCH).ld -static'
fa282484
JQ
2108 ;;
2109 esac
2110fi
2111
2112if test "$ldflags" != "" ; then
2113 echo "LDFLAGS+=$ldflags" >> $config_mak
2114fi
2115
2358a494
JQ
2116echo "/* Automatically generated by configure - do not modify */" > $config_h
2117echo "#include \"../config-host.h\"" >> $config_h
2118
0ff6697d 2119$SHELL $source_path/create_config < $config_mak >> $config_h
42bc608b 2120
a900c002
JQ
2121if test -f ${config_h}~ ; then
2122 if cmp -s $config_h ${config_h}~ ; then
2123 mv ${config_h}~ $config_h
2124 else
2125 rm ${config_h}~
2126 fi
2127fi
15d9ca0f 2128
97a847bc 2129done # for target in $targets
7d13299d
FB
2130
2131# build tree in object directory if source path is different from current one
2132if test "$source_path_used" = "yes" ; then
253d0942 2133 DIRS="tests tests/cris slirp audio block pc-bios/optionrom"
7d13299d 2134 FILES="Makefile tests/Makefile"
e7daa605 2135 FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
e1ffb0f1 2136 FILES="$FILES tests/test-mmap.c"
7ea78b74
JK
2137 FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps pc-bios/video.x"
2138 for bios_file in $source_path/pc-bios/*.bin $source_path/pc-bios/*.dtb $source_path/pc-bios/openbios-*; do
2139 FILES="$FILES pc-bios/`basename $bios_file`"
2140 done
7d13299d
FB
2141 for dir in $DIRS ; do
2142 mkdir -p $dir
2143 done
ec530c81 2144 # remove the link and recreate it, as not all "ln -sf" overwrite the link
7d13299d 2145 for f in $FILES ; do
ec530c81
FB
2146 rm -f $f
2147 ln -s $source_path/$f $f
7d13299d
FB
2148 done
2149fi
1ad2134f
PB
2150
2151for hwlib in 32 64; do
2152 d=libhw$hwlib
2153 mkdir -p $d
2154 rm -f $d/Makefile
2155 ln -s $source_path/Makefile.hw $d/Makefile
2156 echo "HWLIB=libqemuhw$hwlib.a" > $d/config.mak
2157 echo "CPPFLAGS=-DTARGET_PHYS_ADDR_BITS=$hwlib" >> $d/config.mak
2158done