]> git.proxmox.com Git - mirror_qemu.git/blame - configure
Avoid exit in trap as it breaks with some shells
[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"
a91b857c 16TMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.exe"
7d13299d 17
0ba8681e
LM
18# NB: do not call "exit" in the trap handler; this is buggy with some shells;
19# see <1285349658-3122-1-git-send-email-loic.minier@linaro.org>
20trap "rm -f $TMPC $TMPO $TMPE" EXIT INT QUIT TERM
9ac81bbb 21
52166aa0 22compile_object() {
a558ee17 23 $cc $QEMU_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null
52166aa0
JQ
24}
25
26compile_prog() {
27 local_cflags="$1"
28 local_ldflags="$2"
a558ee17 29 $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags > /dev/null 2> /dev/null
52166aa0
JQ
30}
31
0dba6195
LM
32# check whether a command is available to this shell (may be either an
33# executable or a builtin)
34has() {
35 type "$1" >/dev/null 2>&1
36}
37
38# search for an executable in PATH
39path_of() {
40 local_command="$1"
41 local_ifs="$IFS"
42 local_dir=""
43
44 # pathname has a dir component?
45 if [ "${local_command#*/}" != "$local_command" ]; then
46 if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
47 echo "$local_command"
48 return 0
49 fi
50 fi
51 if [ -z "$local_command" ]; then
52 return 1
53 fi
54
55 IFS=:
56 for local_dir in $PATH; do
57 if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
58 echo "$local_dir/$local_command"
59 IFS="${local_ifs:-$(printf ' \t\n')}"
60 return 0
61 fi
62 done
63 # not found
64 IFS="${local_ifs:-$(printf ' \t\n')}"
65 return 1
66}
67
7d13299d 68# default parameters
2ff6b91e 69cpu=""
1e43adfc 70interp_prefix="/usr/gnemul/qemu-%M"
43ce4dfe 71static="no"
ed968ff1 72sparc_cpu=""
7d13299d
FB
73cross_prefix=""
74cc="gcc"
0c58ac1c 75audio_drv_list=""
4c9b53e3 76audio_card_list="ac97 es1370 sb16"
77audio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus"
eb852011 78block_drv_whitelist=""
7d13299d
FB
79host_cc="gcc"
80ar="ar"
81make="make"
6a882643 82install="install"
7aa486fe
AL
83objcopy="objcopy"
84ld="ld"
52ba784d 85strip="strip"
c81da56e 86helper_cflags=""
73da375e 87libs_softmmu=""
3e2e0e6b 88libs_tools=""
67f86e8e 89audio_pt_int=""
d5631638 90audio_win_int=""
ac0df51d
AL
91
92# parse CC options first
93for opt do
94 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
95 case "$opt" in
96 --cross-prefix=*) cross_prefix="$optarg"
97 ;;
98 --cc=*) cc="$optarg"
99 ;;
2ff6b91e
JQ
100 --cpu=*) cpu="$optarg"
101 ;;
a558ee17 102 --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
e2a2ed06
JQ
103 ;;
104 --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
105 ;;
50e7b1a0
JQ
106 --sparc_cpu=*)
107 sparc_cpu="$optarg"
108 case $sparc_cpu in
ed968ff1 109 v7|v8|v8plus|v8plusa)
50e7b1a0
JQ
110 cpu="sparc"
111 ;;
112 v9)
50e7b1a0
JQ
113 cpu="sparc64"
114 ;;
115 *)
116 echo "undefined SPARC architecture. Exiting";
117 exit 1
118 ;;
119 esac
120 ;;
ac0df51d
AL
121 esac
122done
ac0df51d
AL
123# OS specific
124# Using uname is really, really broken. Once we have the right set of checks
125# we can eliminate it's usage altogether
126
127cc="${cross_prefix}${cc}"
128ar="${cross_prefix}${ar}"
7aa486fe
AL
129objcopy="${cross_prefix}${objcopy}"
130ld="${cross_prefix}${ld}"
52ba784d 131strip="${cross_prefix}${strip}"
ac0df51d 132
be17dc90
MT
133# default flags for all hosts
134QEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
135CFLAGS="-g $CFLAGS"
136QEMU_CFLAGS="-Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
137QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
138QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
84958305 139QEMU_CFLAGS="-D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
be17dc90
MT
140QEMU_CFLAGS="-I. -I\$(SRC_PATH) $QEMU_CFLAGS"
141LDFLAGS="-g $LDFLAGS"
142
a21493e0
BS
143gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
144gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
0b65b9e1 145gcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
a21493e0 146gcc_flags="-fstack-protector-all $gcc_flags"
be17dc90 147cat > $TMPC << EOF
aa527b65 148int main(void) { return 0; }
be17dc90
MT
149EOF
150for flag in $gcc_flags; do
aa527b65 151 if compile_prog "-Werror $QEMU_CFLAGS" "-Werror $flag" ; then
be17dc90
MT
152 QEMU_CFLAGS="$flag $QEMU_CFLAGS"
153 fi
154done
155
ac0df51d
AL
156# check that the C compiler works.
157cat > $TMPC <<EOF
158int main(void) {}
159EOF
160
52166aa0 161if compile_object ; then
ac0df51d
AL
162 : C compiler works ok
163else
164 echo "ERROR: \"$cc\" either does not exist or does not work"
165 exit 1
166fi
167
168check_define() {
169cat > $TMPC <<EOF
170#if !defined($1)
171#error Not defined
172#endif
173int main(void) { return 0; }
174EOF
52166aa0 175 compile_object
ac0df51d
AL
176}
177
2ff6b91e
JQ
178if test ! -z "$cpu" ; then
179 # command line argument
180 :
181elif check_define __i386__ ; then
ac0df51d
AL
182 cpu="i386"
183elif check_define __x86_64__ ; then
184 cpu="x86_64"
3aa9bd6c
BS
185elif check_define __sparc__ ; then
186 # We can't check for 64 bit (when gcc is biarch) or V8PLUSA
187 # They must be specified using --sparc_cpu
188 if check_define __arch64__ ; then
189 cpu="sparc64"
190 else
191 cpu="sparc"
192 fi
fdf7ed96 193elif check_define _ARCH_PPC ; then
194 if check_define _ARCH_PPC64 ; then
195 cpu="ppc64"
196 else
197 cpu="ppc"
198 fi
afa05235
AJ
199elif check_define __mips__ ; then
200 cpu="mips"
477ba620
AJ
201elif check_define __ia64__ ; then
202 cpu="ia64"
d66ed0ea
AJ
203elif check_define __s390__ ; then
204 if check_define __s390x__ ; then
205 cpu="s390x"
206 else
207 cpu="s390"
208 fi
ac0df51d 209else
fdf7ed96 210 cpu=`uname -m`
ac0df51d
AL
211fi
212
5327cf48 213target_list=""
7d13299d 214case "$cpu" in
afa05235 215 alpha|cris|ia64|m68k|microblaze|ppc|ppc64|sparc64)
ea8f20f8
JQ
216 cpu="$cpu"
217 ;;
7d13299d 218 i386|i486|i586|i686|i86pc|BePC)
97a847bc 219 cpu="i386"
7d13299d 220 ;;
aaa5fa14
AJ
221 x86_64|amd64)
222 cpu="x86_64"
223 ;;
ba68055e 224 armv*b)
808c4954
FB
225 cpu="armv4b"
226 ;;
ba68055e 227 armv*l)
7d13299d
FB
228 cpu="armv4l"
229 ;;
f54b3f92
AJ
230 parisc|parisc64)
231 cpu="hppa"
232 ;;
afa05235
AJ
233 mips*)
234 cpu="mips"
235 ;;
24e804ec 236 s390)
fb3e5849
FB
237 cpu="s390"
238 ;;
24e804ec
AG
239 s390x)
240 cpu="s390x"
241 ;;
3142255c 242 sparc|sun4[cdmuv])
ae228531
FB
243 cpu="sparc"
244 ;;
7d13299d 245 *)
a447d4dc
PB
246 echo "Unsupported CPU = $cpu"
247 exit 1
7d13299d
FB
248 ;;
249esac
e2d52ad3 250
3a3fb96d
SW
251# Default value for a variable defining feature "foo".
252# * foo="no" feature will only be used if --enable-foo arg is given
253# * foo="" feature will be searched for, and if found, will be used
254# unless --disable-foo is given
255# * foo="yes" this value will only be set by --enable-foo flag.
256# feature will searched for,
257# if not found, configure exits with error
e2d52ad3 258#
3a3fb96d
SW
259# Always add --enable-foo and --disable-foo command line args.
260# Distributions want to ensure that several features are compiled in, and it
261# is impossible without a --enable-foo that exits if a feature is not found.
e2d52ad3 262
a20a6f46 263bluez=""
4ffcedb6 264brlapi=""
788c8196 265curl=""
c584a6d0 266curses=""
a25dba17 267docs=""
2df87df7 268fdt=""
b31a0277 269kvm=""
dae5079a 270kvm_para=""
b0a47e79 271nptl=""
c4198157 272sdl=""
dfffc653 273sparse="no"
ee682d27 274uuid=""
dfb278bd 275vde=""
1be10ad2 276vnc_tls=""
ea784e3b 277vnc_sasl=""
2f6f5c7a 278vnc_jpeg=""
efe556ad 279vnc_png=""
96763cf9 280vnc_thread="no"
fc321b4b 281xen=""
5c6c3a6c 282linux_aio=""
758e8e38 283attr=""
d5970055 284vhost_net=""
dfb278bd 285
7d13299d 286gprof="no"
f8393946 287debug_tcg="no"
b4475aa2 288debug_mon="no"
f3d08ee6 289debug="no"
1625af87 290strip_opt="yes"
7d13299d 291bigendian="no"
67b915a5
FB
292mingw32="no"
293EXESUF=""
683035de
PB
294prefix="/usr/local"
295mandir="\${prefix}/share/man"
296datadir="\${prefix}/share/qemu"
297docdir="\${prefix}/share/doc/qemu"
298bindir="\${prefix}/bin"
299sysconfdir="\${prefix}/etc"
300confsuffix="/qemu"
443f1376 301slirp="yes"
102a52e4
FB
302fmod_lib=""
303fmod_inc=""
2f6a1ab0 304oss_lib=""
b1a550a0 305bsd="no"
5327cf48 306linux="no"
d2c7c9b8 307solaris="no"
05c2a3e7 308profiler="no"
5b0753e0 309cocoa="no"
0a8e90f4 310softmmu="yes"
831b7825
TS
311linux_user="no"
312darwin_user="no"
84778508 313bsd_user="no"
379f6698 314guest_base=""
c5937220 315uname_release=""
e5d355d1 316io_thread="no"
8ff9cbf7 317mixemu="no"
eac30262 318kerneldir=""
b29fe3ed 319aix="no"
77755340 320blobs="yes"
4a19f1ec 321pkgversion=""
5495ed11 322check_utests="no"
34005a00 323user_pie="no"
20ff6c80 324zero_malloc=""
94a420b1 325trace_backend="nop"
9410b56c 326trace_file="trace"
7d13299d
FB
327
328# OS specific
ac0df51d
AL
329if check_define __linux__ ; then
330 targetos="Linux"
331elif check_define _WIN32 ; then
332 targetos='MINGW32'
169dc5d3
BS
333elif check_define __OpenBSD__ ; then
334 targetos='OpenBSD'
335elif check_define __sun__ ; then
336 targetos='SunOS'
ac0df51d
AL
337else
338 targetos=`uname -s`
339fi
0dbfc675 340
7d13299d 341case $targetos in
c326e0af 342CYGWIN*)
0dbfc675 343 mingw32="yes"
a558ee17 344 QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
d5631638 345 audio_possible_drivers="winwave sdl"
346 audio_drv_list="winwave"
c326e0af 347;;
67b915a5 348MINGW32*)
0dbfc675 349 mingw32="yes"
d5631638 350 audio_possible_drivers="winwave dsound sdl fmod"
351 audio_drv_list="winwave"
67b915a5 352;;
5c40d2bd 353GNU/kFreeBSD)
a167ba50 354 bsd="yes"
0dbfc675
JQ
355 audio_drv_list="oss"
356 audio_possible_drivers="oss sdl esd pa"
5c40d2bd 357;;
7d3505c5 358FreeBSD)
0dbfc675 359 bsd="yes"
a167ba50 360 make="gmake"
0dbfc675
JQ
361 audio_drv_list="oss"
362 audio_possible_drivers="oss sdl esd pa"
f01576f1
JL
363 # needed for kinfo_getvmmap(3) in libutil.h
364 LIBS="-lutil $LIBS"
7d3505c5 365;;
c5e97233 366DragonFly)
0dbfc675 367 bsd="yes"
a167ba50 368 make="gmake"
0dbfc675
JQ
369 audio_drv_list="oss"
370 audio_possible_drivers="oss sdl esd pa"
c5e97233 371;;
7d3505c5 372NetBSD)
0dbfc675 373 bsd="yes"
a167ba50 374 make="gmake"
0dbfc675
JQ
375 audio_drv_list="oss"
376 audio_possible_drivers="oss sdl esd"
377 oss_lib="-lossaudio"
7d3505c5
FB
378;;
379OpenBSD)
0dbfc675 380 bsd="yes"
a167ba50 381 make="gmake"
0dbfc675
JQ
382 audio_drv_list="oss"
383 audio_possible_drivers="oss sdl esd"
384 oss_lib="-lossaudio"
7d3505c5 385;;
83fb7adf 386Darwin)
0dbfc675
JQ
387 bsd="yes"
388 darwin="yes"
389 # on Leopard most of the system is 32-bit, so we have to ask the kernel it if we can
390 # run 64-bit userspace code
391 if [ "$cpu" = "i386" ] ; then
aab8588a 392 is_x86_64=`sysctl -n hw.optional.x86_64`
393 [ "$is_x86_64" = "1" ] && cpu=x86_64
0dbfc675
JQ
394 fi
395 if [ "$cpu" = "x86_64" ] ; then
a558ee17 396 QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
0c439cbf 397 LDFLAGS="-arch x86_64 $LDFLAGS"
0dbfc675 398 else
a558ee17 399 QEMU_CFLAGS="-mdynamic-no-pic $QEMU_CFLAGS"
0dbfc675
JQ
400 fi
401 darwin_user="yes"
402 cocoa="yes"
403 audio_drv_list="coreaudio"
404 audio_possible_drivers="coreaudio sdl fmod"
405 LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
7973f21c 406 libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
83fb7adf 407;;
ec530c81 408SunOS)
0dbfc675
JQ
409 solaris="yes"
410 make="gmake"
411 install="ginstall"
fa58948d 412 ld="gld"
0dbfc675
JQ
413 needs_libsunmath="no"
414 solarisrev=`uname -r | cut -f2 -d.`
415 # have to select again, because `uname -m` returns i86pc
416 # even on an x86_64 box.
417 solariscpu=`isainfo -k`
418 if test "${solariscpu}" = "amd64" ; then
419 cpu="x86_64"
420 fi
421 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
422 if test "$solarisrev" -le 9 ; then
423 if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
424 needs_libsunmath="yes"
f14bfdf9
JQ
425 QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
426 LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
427 LIBS="-lsunmath $LIBS"
0dbfc675
JQ
428 else
429 echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
430 echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
431 echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
432 echo "Studio 11 can be downloaded from www.sun.com."
433 exit 1
434 fi
86b2bd93 435 fi
0dbfc675
JQ
436 fi
437 if test -f /usr/include/sys/soundcard.h ; then
438 audio_drv_list="oss"
439 fi
440 audio_possible_drivers="oss sdl"
d741429a
BS
441# needed for CMSG_ macros in sys/socket.h
442 QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
443# needed for TIOCWIN* defines in termios.h
444 QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
a558ee17 445 QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
e174c0bb 446 LIBS="-lsocket -lnsl -lresolv $LIBS"
86b2bd93 447;;
b29fe3ed 448AIX)
0dbfc675
JQ
449 aix="yes"
450 make="gmake"
b29fe3ed 451;;
1d14ffa9 452*)
0dbfc675
JQ
453 audio_drv_list="oss"
454 audio_possible_drivers="oss alsa sdl esd pa"
455 linux="yes"
456 linux_user="yes"
457 usb="linux"
0dbfc675 458 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
c2de5c91 459 audio_possible_drivers="$audio_possible_drivers fmod"
0dbfc675 460 fi
fb065187 461;;
7d13299d
FB
462esac
463
7d3505c5 464if [ "$bsd" = "yes" ] ; then
b1a550a0 465 if [ "$darwin" != "yes" ] ; then
68063649 466 usb="bsd"
83fb7adf 467 fi
84778508 468 bsd_user="yes"
7d3505c5
FB
469fi
470
3457a3f8 471if test "$mingw32" = "yes" ; then
3457a3f8 472 EXESUF=".exe"
a558ee17 473 QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
e94a7936
SW
474 # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
475 QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
884044aa 476 LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
683035de
PB
477 prefix="c:/Program Files/Qemu"
478 mandir="\${prefix}"
479 datadir="\${prefix}"
480 docdir="\${prefix}"
481 bindir="\${prefix}"
482 sysconfdir="\${prefix}"
483 confsuffix=""
3457a3f8
JQ
484fi
485
7d13299d 486# find source path
ad064840 487source_path=`dirname "$0"`
59faef3a
AZ
488source_path_used="no"
489workdir=`pwd`
ad064840 490if [ -z "$source_path" ]; then
59faef3a 491 source_path=$workdir
ad064840
PB
492else
493 source_path=`cd "$source_path"; pwd`
7d13299d 494fi
724db118 495[ -f "$workdir/vl.c" ] || source_path_used="yes"
7d13299d 496
487fefdb 497werror=""
85aa5189 498
7d13299d 499for opt do
a46e4035 500 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
7d13299d 501 case "$opt" in
2efc3265
FB
502 --help|-h) show_help=yes
503 ;;
b1a550a0 504 --prefix=*) prefix="$optarg"
7d13299d 505 ;;
b1a550a0 506 --interp-prefix=*) interp_prefix="$optarg"
32ce6337 507 ;;
b1a550a0 508 --source-path=*) source_path="$optarg"
ad064840 509 source_path_used="yes"
7d13299d 510 ;;
ac0df51d 511 --cross-prefix=*)
7d13299d 512 ;;
ac0df51d 513 --cc=*)
7d13299d 514 ;;
b1a550a0 515 --host-cc=*) host_cc="$optarg"
83469015 516 ;;
b1a550a0 517 --make=*) make="$optarg"
7d13299d 518 ;;
6a882643
PB
519 --install=*) install="$optarg"
520 ;;
e2a2ed06 521 --extra-cflags=*)
7d13299d 522 ;;
e2a2ed06 523 --extra-ldflags=*)
7d13299d 524 ;;
2ff6b91e 525 --cpu=*)
7d13299d 526 ;;
b1a550a0 527 --target-list=*) target_list="$optarg"
de83cd02 528 ;;
94a420b1
SH
529 --trace-backend=*) trace_backend="$optarg"
530 ;;
9410b56c
PS
531 --trace-file=*) trace_file="$optarg"
532 ;;
7d13299d
FB
533 --enable-gprof) gprof="yes"
534 ;;
79427693
LM
535 --static)
536 static="yes"
537 LDFLAGS="-static $LDFLAGS"
43ce4dfe 538 ;;
0b24e75f
PB
539 --mandir=*) mandir="$optarg"
540 ;;
541 --bindir=*) bindir="$optarg"
542 ;;
543 --datadir=*) datadir="$optarg"
544 ;;
545 --docdir=*) docdir="$optarg"
546 ;;
ca2fb938 547 --sysconfdir=*) sysconfdir="$optarg"
07381cc1 548 ;;
97a847bc
FB
549 --disable-sdl) sdl="no"
550 ;;
c4198157
JQ
551 --enable-sdl) sdl="yes"
552 ;;
0c58ac1c 553 --fmod-lib=*) fmod_lib="$optarg"
1d14ffa9 554 ;;
c2de5c91 555 --fmod-inc=*) fmod_inc="$optarg"
556 ;;
2f6a1ab0
BS
557 --oss-lib=*) oss_lib="$optarg"
558 ;;
2fa7d3bf 559 --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
102a52e4 560 ;;
0c58ac1c 561 --audio-drv-list=*) audio_drv_list="$optarg"
102a52e4 562 ;;
eb852011
MA
563 --block-drv-whitelist=*) block_drv_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
564 ;;
f8393946
AJ
565 --enable-debug-tcg) debug_tcg="yes"
566 ;;
567 --disable-debug-tcg) debug_tcg="no"
568 ;;
b4475aa2
LC
569 --enable-debug-mon) debug_mon="yes"
570 ;;
571 --disable-debug-mon) debug_mon="no"
572 ;;
f3d08ee6
PB
573 --enable-debug)
574 # Enable debugging options that aren't excessively noisy
575 debug_tcg="yes"
b4475aa2 576 debug_mon="yes"
f3d08ee6
PB
577 debug="yes"
578 strip_opt="no"
579 ;;
03b4fe7d
AL
580 --enable-sparse) sparse="yes"
581 ;;
582 --disable-sparse) sparse="no"
583 ;;
1625af87
AL
584 --disable-strip) strip_opt="no"
585 ;;
8d5d2d4c
TS
586 --disable-vnc-tls) vnc_tls="no"
587 ;;
1be10ad2
JQ
588 --enable-vnc-tls) vnc_tls="yes"
589 ;;
2f9606b3
AL
590 --disable-vnc-sasl) vnc_sasl="no"
591 ;;
ea784e3b
JQ
592 --enable-vnc-sasl) vnc_sasl="yes"
593 ;;
2f6f5c7a
CC
594 --disable-vnc-jpeg) vnc_jpeg="no"
595 ;;
596 --enable-vnc-jpeg) vnc_jpeg="yes"
597 ;;
efe556ad
CC
598 --disable-vnc-png) vnc_png="no"
599 ;;
600 --enable-vnc-png) vnc_png="yes"
601 ;;
bd023f95
CC
602 --disable-vnc-thread) vnc_thread="no"
603 ;;
604 --enable-vnc-thread) vnc_thread="yes"
605 ;;
443f1376 606 --disable-slirp) slirp="no"
1d14ffa9 607 ;;
ee682d27
SW
608 --disable-uuid) uuid="no"
609 ;;
610 --enable-uuid) uuid="yes"
611 ;;
e0e6c8c0 612 --disable-vde) vde="no"
8a16d273 613 ;;
dfb278bd
JQ
614 --enable-vde) vde="yes"
615 ;;
e37630ca
AL
616 --disable-xen) xen="no"
617 ;;
fc321b4b
JQ
618 --enable-xen) xen="yes"
619 ;;
2e4d9fb1
AJ
620 --disable-brlapi) brlapi="no"
621 ;;
4ffcedb6
JQ
622 --enable-brlapi) brlapi="yes"
623 ;;
fb599c9a
AZ
624 --disable-bluez) bluez="no"
625 ;;
a20a6f46
JQ
626 --enable-bluez) bluez="yes"
627 ;;
7ba1e619
AL
628 --disable-kvm) kvm="no"
629 ;;
b31a0277
JQ
630 --enable-kvm) kvm="yes"
631 ;;
05c2a3e7
FB
632 --enable-profiler) profiler="yes"
633 ;;
c2de5c91 634 --enable-cocoa)
635 cocoa="yes" ;
636 sdl="no" ;
637 audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
1d14ffa9 638 ;;
cad25d69 639 --disable-system) softmmu="no"
0a8e90f4 640 ;;
cad25d69 641 --enable-system) softmmu="yes"
0a8e90f4 642 ;;
0953a80f
ZA
643 --disable-user)
644 linux_user="no" ;
645 bsd_user="no" ;
646 darwin_user="no"
647 ;;
648 --enable-user) ;;
831b7825 649 --disable-linux-user) linux_user="no"
0a8e90f4 650 ;;
831b7825
TS
651 --enable-linux-user) linux_user="yes"
652 ;;
653 --disable-darwin-user) darwin_user="no"
654 ;;
655 --enable-darwin-user) darwin_user="yes"
0a8e90f4 656 ;;
84778508
BS
657 --disable-bsd-user) bsd_user="no"
658 ;;
659 --enable-bsd-user) bsd_user="yes"
660 ;;
379f6698
PB
661 --enable-guest-base) guest_base="yes"
662 ;;
663 --disable-guest-base) guest_base="no"
664 ;;
34005a00
KS
665 --enable-user-pie) user_pie="yes"
666 ;;
667 --disable-user-pie) user_pie="no"
668 ;;
c5937220
PB
669 --enable-uname-release=*) uname_release="$optarg"
670 ;;
3142255c 671 --sparc_cpu=*)
3142255c 672 ;;
85aa5189
FB
673 --enable-werror) werror="yes"
674 ;;
675 --disable-werror) werror="no"
676 ;;
4d3b6f6e
AZ
677 --disable-curses) curses="no"
678 ;;
c584a6d0
JQ
679 --enable-curses) curses="yes"
680 ;;
769ce76d
AG
681 --disable-curl) curl="no"
682 ;;
788c8196
JQ
683 --enable-curl) curl="yes"
684 ;;
2df87df7
JQ
685 --disable-fdt) fdt="no"
686 ;;
687 --enable-fdt) fdt="yes"
688 ;;
5495ed11
LC
689 --disable-check-utests) check_utests="no"
690 ;;
691 --enable-check-utests) check_utests="yes"
692 ;;
bd0c5661
PB
693 --disable-nptl) nptl="no"
694 ;;
b0a47e79
JQ
695 --enable-nptl) nptl="yes"
696 ;;
8ff9cbf7 697 --enable-mixemu) mixemu="yes"
698 ;;
5c6c3a6c
CH
699 --disable-linux-aio) linux_aio="no"
700 ;;
701 --enable-linux-aio) linux_aio="yes"
702 ;;
758e8e38
VJ
703 --disable-attr) attr="no"
704 ;;
705 --enable-attr) attr="yes"
706 ;;
e5d355d1
AL
707 --enable-io-thread) io_thread="yes"
708 ;;
77755340
TS
709 --disable-blobs) blobs="no"
710 ;;
eac30262
AL
711 --kerneldir=*) kerneldir="$optarg"
712 ;;
4a19f1ec
PB
713 --with-pkgversion=*) pkgversion=" ($optarg)"
714 ;;
a25dba17 715 --disable-docs) docs="no"
70ec5dc0 716 ;;
a25dba17 717 --enable-docs) docs="yes"
83a3ab8b 718 ;;
d5970055
MT
719 --disable-vhost-net) vhost_net="no"
720 ;;
721 --enable-vhost-net) vhost_net="yes"
722 ;;
6bde81cb
PB
723 --*dir)
724 ;;
7f1559c6
AZ
725 *) echo "ERROR: unknown option $opt"; show_help="yes"
726 ;;
7d13299d
FB
727 esac
728done
729
3142255c
BS
730#
731# If cpu ~= sparc and sparc_cpu hasn't been defined, plug in the right
a558ee17 732# QEMU_CFLAGS/LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
3142255c 733#
379f6698 734host_guest_base="no"
40293e58 735case "$cpu" in
ed968ff1
JQ
736 sparc) case $sparc_cpu in
737 v7|v8)
a558ee17 738 QEMU_CFLAGS="-mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
ed968ff1
JQ
739 ;;
740 v8plus|v8plusa)
a558ee17 741 QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
ed968ff1
JQ
742 ;;
743 *) # sparc_cpu not defined in the command line
a558ee17 744 QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_v8plus__ $QEMU_CFLAGS"
ed968ff1
JQ
745 esac
746 LDFLAGS="-m32 $LDFLAGS"
a558ee17 747 QEMU_CFLAGS="-m32 -ffixed-g2 -ffixed-g3 $QEMU_CFLAGS"
762e8230 748 if test "$solaris" = "no" ; then
a558ee17 749 QEMU_CFLAGS="-ffixed-g1 -ffixed-g6 $QEMU_CFLAGS"
c81da56e 750 helper_cflags="-ffixed-i0"
762e8230 751 fi
3142255c 752 ;;
ed968ff1 753 sparc64)
a558ee17 754 QEMU_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__ $QEMU_CFLAGS"
ed968ff1 755 LDFLAGS="-m64 $LDFLAGS"
a558ee17 756 QEMU_CFLAGS="-ffixed-g5 -ffixed-g6 -ffixed-g7 $QEMU_CFLAGS"
ed968ff1 757 if test "$solaris" != "no" ; then
a558ee17 758 QEMU_CFLAGS="-ffixed-g1 $QEMU_CFLAGS"
762e8230 759 fi
3142255c 760 ;;
76d83bde 761 s390)
28d7cc49
RH
762 QEMU_CFLAGS="-m31 -march=z990 $QEMU_CFLAGS"
763 LDFLAGS="-m31 $LDFLAGS"
48bb3750 764 host_guest_base="yes"
28d7cc49
RH
765 ;;
766 s390x)
767 QEMU_CFLAGS="-m64 -march=z990 $QEMU_CFLAGS"
768 LDFLAGS="-m64 $LDFLAGS"
48bb3750 769 host_guest_base="yes"
76d83bde 770 ;;
40293e58 771 i386)
a558ee17 772 QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
0c439cbf 773 LDFLAGS="-m32 $LDFLAGS"
c81da56e 774 helper_cflags="-fomit-frame-pointer"
379f6698 775 host_guest_base="yes"
40293e58
FB
776 ;;
777 x86_64)
a558ee17 778 QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
0c439cbf 779 LDFLAGS="-m64 $LDFLAGS"
379f6698
PB
780 host_guest_base="yes"
781 ;;
782 arm*)
783 host_guest_base="yes"
40293e58 784 ;;
f6548c0a 785 ppc*)
786 host_guest_base="yes"
787 ;;
cc01cc8e
AJ
788 mips*)
789 host_guest_base="yes"
790 ;;
477ba620
AJ
791 ia64*)
792 host_guest_base="yes"
793 ;;
fd76e73a
RH
794 hppa*)
795 host_guest_base="yes"
796 ;;
3142255c
BS
797esac
798
379f6698
PB
799[ -z "$guest_base" ] && guest_base="$host_guest_base"
800
af5db58e
PB
801if test x"$show_help" = x"yes" ; then
802cat << EOF
803
804Usage: configure [options]
805Options: [defaults in brackets after descriptions]
806
807EOF
808echo "Standard options:"
809echo " --help print this message"
810echo " --prefix=PREFIX install in PREFIX [$prefix]"
811echo " --interp-prefix=PREFIX where to find shared libraries, etc."
812echo " use %M for cpu name [$interp_prefix]"
813echo " --target-list=LIST set target list [$target_list]"
814echo ""
af5db58e
PB
815echo "Advanced options (experts only):"
816echo " --source-path=PATH path of source code [$source_path]"
817echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
818echo " --cc=CC use C compiler CC [$cc]"
0bfe8cc0
PB
819echo " --host-cc=CC use C compiler CC [$host_cc] for code run at"
820echo " build time"
a558ee17 821echo " --extra-cflags=CFLAGS append extra C compiler flags QEMU_CFLAGS"
e3fc14c3 822echo " --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS"
af5db58e 823echo " --make=MAKE use specified make [$make]"
6a882643 824echo " --install=INSTALL use specified install [$install]"
af5db58e 825echo " --static enable static build [$static]"
0b24e75f
PB
826echo " --mandir=PATH install man pages in PATH"
827echo " --datadir=PATH install firmware in PATH"
828echo " --docdir=PATH install documentation in PATH"
829echo " --bindir=PATH install binaries in PATH"
830echo " --sysconfdir=PATH install config in PATH/qemu"
f8393946
AJ
831echo " --enable-debug-tcg enable TCG debugging"
832echo " --disable-debug-tcg disable TCG debugging (default)"
09695a4a 833echo " --enable-debug enable common debug build options"
890b1658
AL
834echo " --enable-sparse enable sparse checker"
835echo " --disable-sparse disable sparse checker (default)"
1625af87 836echo " --disable-strip disable stripping binaries"
85aa5189 837echo " --disable-werror disable compilation abort on warning"
fe8f78e4 838echo " --disable-sdl disable SDL"
c4198157 839echo " --enable-sdl enable SDL"
af5db58e 840echo " --enable-cocoa enable COCOA (Mac OS X only)"
c2de5c91 841echo " --audio-drv-list=LIST set audio drivers list:"
842echo " Available drivers: $audio_possible_drivers"
4c9b53e3 843echo " --audio-card-list=LIST set list of emulated audio cards [$audio_card_list]"
844echo " Available cards: $audio_possible_cards"
eb852011
MA
845echo " --block-drv-whitelist=L set block driver whitelist"
846echo " (affects only QEMU, not qemu-img)"
8ff9cbf7 847echo " --enable-mixemu enable mixer emulation"
e37630ca 848echo " --disable-xen disable xen backend driver support"
fc321b4b 849echo " --enable-xen enable xen backend driver support"
2e4d9fb1 850echo " --disable-brlapi disable BrlAPI"
4ffcedb6 851echo " --enable-brlapi enable BrlAPI"
8d5d2d4c 852echo " --disable-vnc-tls disable TLS encryption for VNC server"
1be10ad2 853echo " --enable-vnc-tls enable TLS encryption for VNC server"
2f9606b3 854echo " --disable-vnc-sasl disable SASL encryption for VNC server"
ea784e3b 855echo " --enable-vnc-sasl enable SASL encryption for VNC server"
2f6f5c7a
CC
856echo " --disable-vnc-jpeg disable JPEG lossy compression for VNC server"
857echo " --enable-vnc-jpeg enable JPEG lossy compression for VNC server"
96763cf9 858echo " --disable-vnc-png disable PNG compression for VNC server (default)"
efe556ad 859echo " --enable-vnc-png enable PNG compression for VNC server"
bd023f95
CC
860echo " --disable-vnc-thread disable threaded VNC server"
861echo " --enable-vnc-thread enable threaded VNC server"
af896aaa 862echo " --disable-curses disable curses output"
c584a6d0 863echo " --enable-curses enable curses output"
769ce76d 864echo " --disable-curl disable curl connectivity"
788c8196 865echo " --enable-curl enable curl connectivity"
2df87df7
JQ
866echo " --disable-fdt disable fdt device tree"
867echo " --enable-fdt enable fdt device tree"
5495ed11
LC
868echo " --disable-check-utests disable check unit-tests"
869echo " --enable-check-utests enable check unit-tests"
fb599c9a 870echo " --disable-bluez disable bluez stack connectivity"
a20a6f46 871echo " --enable-bluez enable bluez stack connectivity"
7ba1e619 872echo " --disable-kvm disable KVM acceleration support"
b31a0277 873echo " --enable-kvm enable KVM acceleration support"
bd0c5661 874echo " --disable-nptl disable usermode NPTL support"
e5934d33 875echo " --enable-nptl enable usermode NPTL support"
af5db58e
PB
876echo " --enable-system enable all system emulation targets"
877echo " --disable-system disable all system emulation targets"
0953a80f
ZA
878echo " --enable-user enable supported user emulation targets"
879echo " --disable-user disable all user emulation targets"
831b7825
TS
880echo " --enable-linux-user enable all linux usermode emulation targets"
881echo " --disable-linux-user disable all linux usermode emulation targets"
882echo " --enable-darwin-user enable all darwin usermode emulation targets"
883echo " --disable-darwin-user disable all darwin usermode emulation targets"
84778508
BS
884echo " --enable-bsd-user enable all BSD usermode emulation targets"
885echo " --disable-bsd-user disable all BSD usermode emulation targets"
379f6698
PB
886echo " --enable-guest-base enable GUEST_BASE support for usermode"
887echo " emulation targets"
888echo " --disable-guest-base disable GUEST_BASE support"
34005a00
KS
889echo " --enable-user-pie build usermode emulation targets as PIE"
890echo " --disable-user-pie do not build usermode emulation targets as PIE"
af5db58e
PB
891echo " --fmod-lib path to FMOD library"
892echo " --fmod-inc path to FMOD includes"
2f6a1ab0 893echo " --oss-lib path to OSS library"
c5937220 894echo " --enable-uname-release=R Return R for uname -r in usermode emulation"
3142255c 895echo " --sparc_cpu=V Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
ee682d27
SW
896echo " --disable-uuid disable uuid support"
897echo " --enable-uuid enable uuid support"
e0e6c8c0 898echo " --disable-vde disable support for vde network"
dfb278bd 899echo " --enable-vde enable support for vde network"
5c6c3a6c
CH
900echo " --disable-linux-aio disable Linux AIO support"
901echo " --enable-linux-aio enable Linux AIO support"
758e8e38
VJ
902echo " --disable-attr disables attr and xattr support"
903echo " --enable-attr enable attr and xattr support"
e5d355d1 904echo " --enable-io-thread enable IO thread"
77755340 905echo " --disable-blobs disable installing provided firmware blobs"
eac30262 906echo " --kerneldir=PATH look for kernel includes in PATH"
d2807bc9
DU
907echo " --enable-docs enable documentation build"
908echo " --disable-docs disable documentation build"
d5970055
MT
909echo " --disable-vhost-net disable vhost-net acceleration support"
910echo " --enable-vhost-net enable vhost-net acceleration support"
7e24e92a 911echo " --trace-backend=B Trace backend nop simple ust"
9410b56c
PS
912echo " --trace-file=NAME Full PATH,NAME of file to store traces"
913echo " Default:trace-<pid>"
af5db58e 914echo ""
5bf08934 915echo "NOTE: The object files are built at the place where configure is launched"
af5db58e
PB
916exit 1
917fi
918
ec530c81
FB
919#
920# Solaris specific configure tool chain decisions
921#
922if test "$solaris" = "yes" ; then
6792aa11
LM
923 if has $install; then
924 :
925 else
ec530c81
FB
926 echo "Solaris install program not found. Use --install=/usr/ucb/install or"
927 echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
928 echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
929 exit 1
930 fi
6792aa11 931 if test "`path_of $install`" = "/usr/sbin/install" ; then
ec530c81
FB
932 echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
933 echo "try ginstall from the GNU fileutils available from www.blastwave.org"
934 echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
935 exit 1
936 fi
6792aa11
LM
937 if has ar; then
938 :
939 else
ec530c81
FB
940 echo "Error: No path includes ar"
941 if test -f /usr/ccs/bin/ar ; then
942 echo "Add /usr/ccs/bin to your path and rerun configure"
943 fi
944 exit 1
945 fi
5fafdf24 946fi
ec530c81
FB
947
948
5327cf48
FB
949if test -z "$target_list" ; then
950# these targets are portable
0a8e90f4 951 if [ "$softmmu" = "yes" ] ; then
2408a527
AJ
952 target_list="\
953i386-softmmu \
954x86_64-softmmu \
955arm-softmmu \
956cris-softmmu \
957m68k-softmmu \
72b675ca 958microblaze-softmmu \
2408a527
AJ
959mips-softmmu \
960mipsel-softmmu \
961mips64-softmmu \
962mips64el-softmmu \
963ppc-softmmu \
964ppcemb-softmmu \
965ppc64-softmmu \
966sh4-softmmu \
967sh4eb-softmmu \
968sparc-softmmu \
1b64fcae 969sparc64-softmmu \
2408a527 970"
0a8e90f4 971 fi
5327cf48 972# the following are Linux specific
831b7825 973 if [ "$linux_user" = "yes" ] ; then
2408a527
AJ
974 target_list="${target_list}\
975i386-linux-user \
976x86_64-linux-user \
977alpha-linux-user \
978arm-linux-user \
979armeb-linux-user \
980cris-linux-user \
981m68k-linux-user \
72b675ca 982microblaze-linux-user \
2408a527
AJ
983mips-linux-user \
984mipsel-linux-user \
985ppc-linux-user \
986ppc64-linux-user \
987ppc64abi32-linux-user \
988sh4-linux-user \
989sh4eb-linux-user \
990sparc-linux-user \
991sparc64-linux-user \
992sparc32plus-linux-user \
993"
831b7825
TS
994 fi
995# the following are Darwin specific
996 if [ "$darwin_user" = "yes" ] ; then
6cdc7375 997 target_list="$target_list i386-darwin-user ppc-darwin-user "
5327cf48 998 fi
84778508
BS
999# the following are BSD specific
1000 if [ "$bsd_user" = "yes" ] ; then
1001 target_list="${target_list}\
31fc12df
BS
1002i386-bsd-user \
1003x86_64-bsd-user \
1004sparc-bsd-user \
84778508
BS
1005sparc64-bsd-user \
1006"
1007 fi
6e20a45f 1008else
b1a550a0 1009 target_list=`echo "$target_list" | sed -e 's/,/ /g'`
5327cf48 1010fi
0a8e90f4
PB
1011if test -z "$target_list" ; then
1012 echo "No targets enabled"
1013 exit 1
1014fi
f55fe278
PB
1015# see if system emulation was really requested
1016case " $target_list " in
1017 *"-softmmu "*) softmmu=yes
1018 ;;
1019 *) softmmu=no
1020 ;;
1021esac
5327cf48 1022
249247c9
JQ
1023feature_not_found() {
1024 feature=$1
1025
1026 echo "ERROR"
1027 echo "ERROR: User requested feature $feature"
9332f6a2 1028 echo "ERROR: configure was not able to find it"
249247c9
JQ
1029 echo "ERROR"
1030 exit 1;
1031}
1032
7d13299d
FB
1033if test -z "$cross_prefix" ; then
1034
1035# ---
1036# big/little endian test
1037cat > $TMPC << EOF
1038#include <inttypes.h>
1039int main(int argc, char ** argv){
1d14ffa9
FB
1040 volatile uint32_t i=0x01234567;
1041 return (*((uint8_t*)(&i))) == 0x67;
7d13299d
FB
1042}
1043EOF
1044
52166aa0 1045if compile_prog "" "" ; then
7d13299d
FB
1046$TMPE && bigendian="yes"
1047else
1048echo big/little test failed
1049fi
1050
1051else
1052
1053# if cross compiling, cannot launch a program, so make a static guess
ea8f20f8 1054case "$cpu" in
24e804ec 1055 armv4b|hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
ea8f20f8
JQ
1056 bigendian=yes
1057 ;;
1058esac
7d13299d
FB
1059
1060fi
1061
b6853697
FB
1062# host long bits test
1063hostlongbits="32"
ea8f20f8 1064case "$cpu" in
24e804ec 1065 x86_64|alpha|ia64|sparc64|ppc64|s390x)
ea8f20f8
JQ
1066 hostlongbits=64
1067 ;;
1068esac
b6853697 1069
b0a47e79
JQ
1070
1071##########################################
1072# NPTL probe
1073
1074if test "$nptl" != "no" ; then
1075 cat > $TMPC <<EOF
bd0c5661 1076#include <sched.h>
30813cea 1077#include <linux/futex.h>
bd0c5661
PB
1078void foo()
1079{
1080#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1081#error bork
1082#endif
1083}
1084EOF
1085
b0a47e79
JQ
1086 if compile_object ; then
1087 nptl=yes
1088 else
1089 if test "$nptl" = "yes" ; then
1090 feature_not_found "nptl"
1091 fi
1092 nptl=no
1093 fi
bd0c5661
PB
1094fi
1095
ac62922e
AZ
1096##########################################
1097# zlib check
1098
1099cat > $TMPC << EOF
1100#include <zlib.h>
1101int main(void) { zlibVersion(); return 0; }
1102EOF
52166aa0 1103if compile_prog "" "-lz" ; then
ac62922e
AZ
1104 :
1105else
1106 echo
1107 echo "Error: zlib check failed"
1108 echo "Make sure to have the zlib libs and headers installed."
1109 echo
1110 exit 1
1111fi
1112
e37630ca
AL
1113##########################################
1114# xen probe
1115
fc321b4b 1116if test "$xen" != "no" ; then
b2266bee
JQ
1117 xen_libs="-lxenstore -lxenctrl -lxenguest"
1118 cat > $TMPC <<EOF
e37630ca
AL
1119#include <xenctrl.h>
1120#include <xs.h>
df7a607b 1121int main(void) { xs_daemon_open(); xc_interface_open(); return 0; }
e37630ca 1122EOF
52166aa0 1123 if compile_prog "" "$xen_libs" ; then
fc321b4b 1124 xen=yes
3efd632b 1125 libs_softmmu="$xen_libs $libs_softmmu"
b2266bee 1126 else
fc321b4b
JQ
1127 if test "$xen" = "yes" ; then
1128 feature_not_found "xen"
1129 fi
1130 xen=no
b2266bee 1131 fi
e37630ca
AL
1132fi
1133
f91672e5
PB
1134##########################################
1135# pkgconfig probe
1136
1137pkgconfig="${cross_prefix}pkg-config"
0dba6195 1138if ! has $pkgconfig; then
f91672e5
PB
1139 # likely not cross compiling, or hope for the best
1140 pkgconfig=pkg-config
1141fi
1142
dfffc653
JQ
1143##########################################
1144# Sparse probe
1145if test "$sparse" != "no" ; then
0dba6195 1146 if has cgcc; then
dfffc653
JQ
1147 sparse=yes
1148 else
1149 if test "$sparse" = "yes" ; then
1150 feature_not_found "sparse"
1151 fi
1152 sparse=no
1153 fi
1154fi
1155
11d9f695
FB
1156##########################################
1157# SDL probe
1158
fec0e3e8
SW
1159# Look for sdl configuration program (pkg-config or sdl-config).
1160# Prefer variant with cross prefix if cross compiling,
1161# and favour pkg-config with sdl over sdl-config.
1162if test -n "$cross_prefix" -a $pkgconfig != pkg-config && \
1163 $pkgconfig sdl --modversion >/dev/null 2>&1; then
1164 sdlconfig="$pkgconfig sdl"
1165 _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
1166elif test -n "$cross_prefix" && has ${cross_prefix}sdl-config; then
1167 sdlconfig="${cross_prefix}sdl-config"
1168 _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
1169elif $pkgconfig sdl --modversion >/dev/null 2>&1; then
9316f803
PB
1170 sdlconfig="$pkgconfig sdl"
1171 _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
0dba6195 1172elif has sdl-config; then
9316f803
PB
1173 sdlconfig='sdl-config'
1174 _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
a0dfd8a4
LM
1175else
1176 if test "$sdl" = "yes" ; then
1177 feature_not_found "sdl"
1178 fi
1179 sdl=no
9316f803 1180fi
11d9f695 1181
9316f803 1182sdl_too_old=no
c4198157 1183if test "$sdl" != "no" ; then
ac119f9d 1184 cat > $TMPC << EOF
11d9f695
FB
1185#include <SDL.h>
1186#undef main /* We don't want SDL to override our main() */
1187int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
1188EOF
9316f803 1189 sdl_cflags=`$sdlconfig --cflags 2> /dev/null`
74f42e18
T
1190 if test "$static" = "yes" ; then
1191 sdl_libs=`$sdlconfig --static-libs 2>/dev/null`
1192 else
1193 sdl_libs=`$sdlconfig --libs 2> /dev/null`
1194 fi
52166aa0 1195 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
ac119f9d
JQ
1196 if test "$_sdlversion" -lt 121 ; then
1197 sdl_too_old=yes
1198 else
1199 if test "$cocoa" = "no" ; then
1200 sdl=yes
1201 fi
1202 fi
cd01b4a3 1203
67c274d3 1204 # static link with sdl ? (note: sdl.pc's --static --libs is broken)
ac119f9d 1205 if test "$sdl" = "yes" -a "$static" = "yes" ; then
67c274d3 1206 if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
f8aa6c7b
SW
1207 sdl_libs="$sdl_libs `aalib-config --static-libs 2>/dev/null`"
1208 sdl_cflags="$sdl_cflags `aalib-config --cflags 2>/dev/null`"
ac119f9d 1209 fi
52166aa0 1210 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
ac119f9d
JQ
1211 :
1212 else
1213 sdl=no
1214 fi
1215 fi # static link
c4198157
JQ
1216 else # sdl not found
1217 if test "$sdl" = "yes" ; then
1218 feature_not_found "sdl"
1219 fi
1220 sdl=no
ac119f9d 1221 fi # sdl compile test
a68551bc 1222fi
11d9f695 1223
5368a422 1224if test "$sdl" = "yes" ; then
ac119f9d 1225 cat > $TMPC <<EOF
5368a422
AL
1226#include <SDL.h>
1227#if defined(SDL_VIDEO_DRIVER_X11)
1228#include <X11/XKBlib.h>
1229#else
1230#error No x11 support
1231#endif
1232int main(void) { return 0; }
1233EOF
52166aa0 1234 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
ac119f9d
JQ
1235 sdl_libs="$sdl_libs -lX11"
1236 fi
07d9ac44
JQ
1237 if test "$mingw32" = "yes" ; then
1238 sdl_libs="`echo $sdl_libs | sed s/-mwindows//g` -mconsole"
1239 fi
0705667e 1240 libs_softmmu="$sdl_libs $libs_softmmu"
5368a422
AL
1241fi
1242
8d5d2d4c
TS
1243##########################################
1244# VNC TLS detection
1be10ad2
JQ
1245if test "$vnc_tls" != "no" ; then
1246 cat > $TMPC <<EOF
ae6b5e5a
AL
1247#include <gnutls/gnutls.h>
1248int main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
1249EOF
f91672e5
PB
1250 vnc_tls_cflags=`$pkgconfig --cflags gnutls 2> /dev/null`
1251 vnc_tls_libs=`$pkgconfig --libs gnutls 2> /dev/null`
1be10ad2
JQ
1252 if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
1253 vnc_tls=yes
1254 libs_softmmu="$vnc_tls_libs $libs_softmmu"
1255 else
1256 if test "$vnc_tls" = "yes" ; then
1257 feature_not_found "vnc-tls"
ae6b5e5a 1258 fi
1be10ad2
JQ
1259 vnc_tls=no
1260 fi
8d5d2d4c
TS
1261fi
1262
2f9606b3
AL
1263##########################################
1264# VNC SASL detection
3aefa744 1265if test "$vnc_sasl" != "no" ; then
ea784e3b 1266 cat > $TMPC <<EOF
2f9606b3
AL
1267#include <sasl/sasl.h>
1268#include <stdio.h>
1269int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
1270EOF
ea784e3b
JQ
1271 # Assuming Cyrus-SASL installed in /usr prefix
1272 vnc_sasl_cflags=""
1273 vnc_sasl_libs="-lsasl2"
1274 if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1275 vnc_sasl=yes
1276 libs_softmmu="$vnc_sasl_libs $libs_softmmu"
1277 else
1278 if test "$vnc_sasl" = "yes" ; then
1279 feature_not_found "vnc-sasl"
2f9606b3 1280 fi
ea784e3b
JQ
1281 vnc_sasl=no
1282 fi
2f9606b3
AL
1283fi
1284
2f6f5c7a
CC
1285##########################################
1286# VNC JPEG detection
96763cf9 1287if test "$vnc_jpeg" != "no" ; then
2f6f5c7a
CC
1288cat > $TMPC <<EOF
1289#include <stdio.h>
1290#include <jpeglib.h>
1291int main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
1292EOF
1293 vnc_jpeg_cflags=""
1294 vnc_jpeg_libs="-ljpeg"
1295 if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
1296 vnc_jpeg=yes
1297 libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
1298 else
1299 if test "$vnc_jpeg" = "yes" ; then
1300 feature_not_found "vnc-jpeg"
1301 fi
1302 vnc_jpeg=no
1303 fi
1304fi
1305
efe556ad
CC
1306##########################################
1307# VNC PNG detection
96763cf9 1308if test "$vnc_png" != "no" ; then
efe556ad
CC
1309cat > $TMPC <<EOF
1310//#include <stdio.h>
1311#include <png.h>
1312int main(void) {
1313 png_structp png_ptr;
1314 png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
1315 return 0;
1316}
1317EOF
1318 vnc_png_cflags=""
1319 vnc_png_libs="-lpng"
1320 if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
1321 vnc_png=yes
1322 libs_softmmu="$vnc_png_libs $libs_softmmu"
1323 else
1324 if test "$vnc_png" = "yes" ; then
1325 feature_not_found "vnc-png"
1326 fi
1327 vnc_png=no
1328 fi
1329fi
1330
76655d6d
AL
1331##########################################
1332# fnmatch() probe, used for ACL routines
1333fnmatch="no"
1334cat > $TMPC << EOF
1335#include <fnmatch.h>
1336int main(void)
1337{
1338 fnmatch("foo", "foo", 0);
1339 return 0;
1340}
1341EOF
52166aa0 1342if compile_prog "" "" ; then
76655d6d
AL
1343 fnmatch="yes"
1344fi
1345
ee682d27
SW
1346##########################################
1347# uuid_generate() probe, used for vdi block driver
1348if test "$uuid" != "no" ; then
1349 uuid_libs="-luuid"
1350 cat > $TMPC << EOF
1351#include <uuid/uuid.h>
1352int main(void)
1353{
1354 uuid_t my_uuid;
1355 uuid_generate(my_uuid);
1356 return 0;
1357}
1358EOF
1359 if compile_prog "" "$uuid_libs" ; then
1360 uuid="yes"
1361 libs_softmmu="$uuid_libs $libs_softmmu"
1362 libs_tools="$uuid_libs $libs_tools"
1363 else
1364 if test "$uuid" = "yes" ; then
1365 feature_not_found "uuid"
1366 fi
1367 uuid=no
1368 fi
1369fi
1370
8a16d273
TS
1371##########################################
1372# vde libraries probe
dfb278bd 1373if test "$vde" != "no" ; then
4baae0ac 1374 vde_libs="-lvdeplug"
8a16d273
TS
1375 cat > $TMPC << EOF
1376#include <libvdeplug.h>
4a7f0e06
PB
1377int main(void)
1378{
1379 struct vde_open_args a = {0, 0, 0};
1380 vde_open("", "", &a);
1381 return 0;
1382}
8a16d273 1383EOF
52166aa0 1384 if compile_prog "" "$vde_libs" ; then
4baae0ac 1385 vde=yes
8e02e54c
JQ
1386 libs_softmmu="$vde_libs $libs_softmmu"
1387 libs_tools="$vde_libs $libs_tools"
dfb278bd
JQ
1388 else
1389 if test "$vde" = "yes" ; then
1390 feature_not_found "vde"
1391 fi
1392 vde=no
4baae0ac 1393 fi
8a16d273
TS
1394fi
1395
8f28f3fb 1396##########################################
c2de5c91 1397# Sound support libraries probe
8f28f3fb 1398
c2de5c91 1399audio_drv_probe()
1400{
1401 drv=$1
1402 hdr=$2
1403 lib=$3
1404 exp=$4
1405 cfl=$5
1406 cat > $TMPC << EOF
1407#include <$hdr>
1408int main(void) { $exp }
8f28f3fb 1409EOF
52166aa0 1410 if compile_prog "$cfl" "$lib" ; then
c2de5c91 1411 :
1412 else
1413 echo
1414 echo "Error: $drv check failed"
1415 echo "Make sure to have the $drv libs and headers installed."
1416 echo
1417 exit 1
1418 fi
1419}
1420
2fa7d3bf 1421audio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
c2de5c91 1422for drv in $audio_drv_list; do
1423 case $drv in
1424 alsa)
1425 audio_drv_probe $drv alsa/asoundlib.h -lasound \
1426 "snd_pcm_t **handle; return snd_pcm_close(*handle);"
a4bf6780 1427 libs_softmmu="-lasound $libs_softmmu"
c2de5c91 1428 ;;
1429
1430 fmod)
1431 if test -z $fmod_lib || test -z $fmod_inc; then
1432 echo
1433 echo "Error: You must specify path to FMOD library and headers"
1434 echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
1435 echo
1436 exit 1
1437 fi
1438 audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
a4bf6780 1439 libs_softmmu="$fmod_lib $libs_softmmu"
c2de5c91 1440 ;;
1441
1442 esd)
1443 audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
a4bf6780 1444 libs_softmmu="-lesd $libs_softmmu"
67f86e8e 1445 audio_pt_int="yes"
c2de5c91 1446 ;;
b8e59f18 1447
1448 pa)
493abda6 1449 audio_drv_probe $drv pulse/simple.h "-lpulse-simple -lpulse" \
b8e59f18 1450 "pa_simple *s = NULL; pa_simple_free(s); return 0;"
493abda6 1451 libs_softmmu="-lpulse -lpulse-simple $libs_softmmu"
67f86e8e 1452 audio_pt_int="yes"
b8e59f18 1453 ;;
1454
997e690a
JQ
1455 coreaudio)
1456 libs_softmmu="-framework CoreAudio $libs_softmmu"
1457 ;;
1458
a4bf6780
JQ
1459 dsound)
1460 libs_softmmu="-lole32 -ldxguid $libs_softmmu"
d5631638 1461 audio_win_int="yes"
a4bf6780
JQ
1462 ;;
1463
1464 oss)
1465 libs_softmmu="$oss_lib $libs_softmmu"
1466 ;;
1467
1468 sdl|wav)
2f6a1ab0
BS
1469 # XXX: Probes for CoreAudio, DirectSound, SDL(?)
1470 ;;
1471
d5631638 1472 winwave)
1473 libs_softmmu="-lwinmm $libs_softmmu"
1474 audio_win_int="yes"
1475 ;;
1476
e4c63a6a 1477 *)
1c9b2a52 1478 echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
e4c63a6a 1479 echo
1480 echo "Error: Unknown driver '$drv' selected"
1481 echo "Possible drivers are: $audio_possible_drivers"
1482 echo
1483 exit 1
1484 }
1485 ;;
c2de5c91 1486 esac
1487done
8f28f3fb 1488
2e4d9fb1
AJ
1489##########################################
1490# BrlAPI probe
1491
4ffcedb6 1492if test "$brlapi" != "no" ; then
eb82284f
JQ
1493 brlapi_libs="-lbrlapi"
1494 cat > $TMPC << EOF
2e4d9fb1
AJ
1495#include <brlapi.h>
1496int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
1497EOF
52166aa0 1498 if compile_prog "" "$brlapi_libs" ; then
eb82284f 1499 brlapi=yes
264606b3 1500 libs_softmmu="$brlapi_libs $libs_softmmu"
4ffcedb6
JQ
1501 else
1502 if test "$brlapi" = "yes" ; then
1503 feature_not_found "brlapi"
1504 fi
1505 brlapi=no
eb82284f
JQ
1506 fi
1507fi
2e4d9fb1 1508
4d3b6f6e
AZ
1509##########################################
1510# curses probe
4f78ef9a 1511curses_list="-lncurses -lcurses"
4d3b6f6e 1512
c584a6d0
JQ
1513if test "$curses" != "no" ; then
1514 curses_found=no
4d3b6f6e
AZ
1515 cat > $TMPC << EOF
1516#include <curses.h>
5a8ff3aa
BS
1517#ifdef __OpenBSD__
1518#define resize_term resizeterm
1519#endif
1520int main(void) { resize_term(0, 0); return curses_version(); }
4d3b6f6e 1521EOF
4f78ef9a
JQ
1522 for curses_lib in $curses_list; do
1523 if compile_prog "" "$curses_lib" ; then
c584a6d0 1524 curses_found=yes
4f78ef9a
JQ
1525 libs_softmmu="$curses_lib $libs_softmmu"
1526 break
1527 fi
1528 done
c584a6d0
JQ
1529 if test "$curses_found" = "yes" ; then
1530 curses=yes
1531 else
1532 if test "$curses" = "yes" ; then
1533 feature_not_found "curses"
1534 fi
1535 curses=no
1536 fi
4f78ef9a 1537fi
4d3b6f6e 1538
769ce76d
AG
1539##########################################
1540# curl probe
1541
4e2b0658
PB
1542if $pkgconfig libcurl --modversion >/dev/null 2>&1; then
1543 curlconfig="$pkgconfig libcurl"
1544else
1545 curlconfig=curl-config
1546fi
1547
788c8196 1548if test "$curl" != "no" ; then
769ce76d
AG
1549 cat > $TMPC << EOF
1550#include <curl/curl.h>
1551int main(void) { return curl_easy_init(); }
1552EOF
4e2b0658
PB
1553 curl_cflags=`$curlconfig --cflags 2>/dev/null`
1554 curl_libs=`$curlconfig --libs 2>/dev/null`
b1d5a277 1555 if compile_prog "$curl_cflags" "$curl_libs" ; then
769ce76d 1556 curl=yes
f0302935
JQ
1557 libs_tools="$curl_libs $libs_tools"
1558 libs_softmmu="$curl_libs $libs_softmmu"
788c8196
JQ
1559 else
1560 if test "$curl" = "yes" ; then
1561 feature_not_found "curl"
1562 fi
1563 curl=no
769ce76d
AG
1564 fi
1565fi # test "$curl"
1566
5495ed11
LC
1567##########################################
1568# check framework probe
1569
1570if test "$check_utests" != "no" ; then
1571 cat > $TMPC << EOF
1572#include <check.h>
1573int main(void) { suite_create("qemu test"); return 0; }
1574EOF
f91672e5 1575 check_libs=`$pkgconfig --libs check`
5495ed11
LC
1576 if compile_prog "" $check_libs ; then
1577 check_utests=yes
1578 libs_tools="$check_libs $libs_tools"
1579 else
1580 if test "$check_utests" = "yes" ; then
1581 feature_not_found "check"
1582 fi
1583 check_utests=no
1584 fi
1585fi # test "$check_utests"
1586
fb599c9a
AZ
1587##########################################
1588# bluez support probe
a20a6f46 1589if test "$bluez" != "no" ; then
e820e3f4
AZ
1590 cat > $TMPC << EOF
1591#include <bluetooth/bluetooth.h>
1592int main(void) { return bt_error(0); }
1593EOF
f91672e5
PB
1594 bluez_cflags=`$pkgconfig --cflags bluez 2> /dev/null`
1595 bluez_libs=`$pkgconfig --libs bluez 2> /dev/null`
52166aa0 1596 if compile_prog "$bluez_cflags" "$bluez_libs" ; then
a20a6f46 1597 bluez=yes
e482d56a 1598 libs_softmmu="$bluez_libs $libs_softmmu"
e820e3f4 1599 else
a20a6f46
JQ
1600 if test "$bluez" = "yes" ; then
1601 feature_not_found "bluez"
1602 fi
e820e3f4
AZ
1603 bluez="no"
1604 fi
fb599c9a
AZ
1605fi
1606
7ba1e619
AL
1607##########################################
1608# kvm probe
b31a0277 1609if test "$kvm" != "no" ; then
7ba1e619
AL
1610 cat > $TMPC <<EOF
1611#include <linux/kvm.h>
9fd8d8d7 1612#if !defined(KVM_API_VERSION) || KVM_API_VERSION < 12 || KVM_API_VERSION > 12
7ba1e619
AL
1613#error Invalid KVM version
1614#endif
9fd8d8d7
AL
1615#if !defined(KVM_CAP_USER_MEMORY)
1616#error Missing KVM capability KVM_CAP_USER_MEMORY
1617#endif
1618#if !defined(KVM_CAP_SET_TSS_ADDR)
1619#error Missing KVM capability KVM_CAP_SET_TSS_ADDR
1620#endif
1621#if !defined(KVM_CAP_DESTROY_MEMORY_REGION_WORKS)
1622#error Missing KVM capability KVM_CAP_DESTROY_MEMORY_REGION_WORKS
1623#endif
7ba1e619
AL
1624int main(void) { return 0; }
1625EOF
eac30262
AL
1626 if test "$kerneldir" != "" ; then
1627 kvm_cflags=-I"$kerneldir"/include
8444eb6e
AL
1628 if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) \
1629 -a -d "$kerneldir/arch/x86/include" ; then
1630 kvm_cflags="$kvm_cflags -I$kerneldir/arch/x86/include"
406b430d
AL
1631 elif test "$cpu" = "ppc" -a -d "$kerneldir/arch/powerpc/include" ; then
1632 kvm_cflags="$kvm_cflags -I$kerneldir/arch/powerpc/include"
0e60a699
AG
1633 elif test "$cpu" = "s390x" -a -d "$kerneldir/arch/s390/include" ; then
1634 kvm_cflags="$kvm_cflags -I$kerneldir/arch/s390/include"
8444eb6e
AL
1635 elif test -d "$kerneldir/arch/$cpu/include" ; then
1636 kvm_cflags="$kvm_cflags -I$kerneldir/arch/$cpu/include"
1637 fi
eac30262 1638 else
f038e8f7 1639 kvm_cflags=`$pkgconfig --cflags kvm-kmod 2>/dev/null`
eac30262 1640 fi
52166aa0 1641 if compile_prog "$kvm_cflags" "" ; then
b31a0277 1642 kvm=yes
dae5079a
JK
1643 cat > $TMPC <<EOF
1644#include <linux/kvm_para.h>
1645int main(void) { return 0; }
1646EOF
1647 if compile_prog "$kvm_cflags" "" ; then
1648 kvm_para=yes
1649 fi
7ba1e619 1650 else
b31a0277 1651 if test "$kvm" = "yes" ; then
0dba6195 1652 if has awk && has grep; then
b31a0277 1653 kvmerr=`LANG=C $cc $QEMU_CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&1 \
9fd8d8d7
AL
1654 | grep "error: " \
1655 | awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'`
b31a0277
JQ
1656 if test "$kvmerr" != "" ; then
1657 echo -e "${kvmerr}\n\
1658 NOTE: To enable KVM support, update your kernel to 2.6.29+ or install \
1659 recent kvm-kmod from http://sourceforge.net/projects/kvm."
1660 fi
9fd8d8d7 1661 fi
b31a0277 1662 feature_not_found "kvm"
9fd8d8d7 1663 fi
b31a0277 1664 kvm=no
7ba1e619
AL
1665 fi
1666fi
1667
d5970055
MT
1668##########################################
1669# test for vhost net
1670
1671if test "$vhost_net" != "no"; then
1672 if test "$kvm" != "no"; then
1673 cat > $TMPC <<EOF
1674 #include <linux/vhost.h>
1675 int main(void) { return 0; }
1676EOF
1677 if compile_prog "$kvm_cflags" "" ; then
1678 vhost_net=yes
1679 else
1680 if test "$vhost_net" = "yes" ; then
1681 feature_not_found "vhost-net"
1682 fi
1683 vhost_net=no
1684 fi
1685 else
1686 if test "$vhost_net" = "yes" ; then
4021d247 1687 echo "NOTE: vhost-net feature requires KVM (--enable-kvm)."
d5970055
MT
1688 feature_not_found "vhost-net"
1689 fi
1690 vhost_net=no
1691 fi
1692fi
1693
414f0dab 1694##########################################
e5d355d1 1695# pthread probe
de65fe0f 1696PTHREADLIBS_LIST="-lpthread -lpthreadGC2"
3c529d93 1697
4dd75c70 1698pthread=no
e5d355d1 1699cat > $TMPC << EOF
3c529d93 1700#include <pthread.h>
de65fe0f 1701int main(void) { pthread_create(0,0,0,0); return 0; }
414f0dab 1702EOF
4dd75c70
CH
1703for pthread_lib in $PTHREADLIBS_LIST; do
1704 if compile_prog "" "$pthread_lib" ; then
1705 pthread=yes
1706 LIBS="$pthread_lib $LIBS"
1707 break
1708 fi
1709done
414f0dab 1710
4617e593 1711if test "$mingw32" != yes -a "$pthread" = no; then
4dd75c70
CH
1712 echo
1713 echo "Error: pthread check failed"
1714 echo "Make sure to have the pthread libs and headers installed."
1715 echo
1716 exit 1
e5d355d1
AL
1717fi
1718
5c6c3a6c
CH
1719##########################################
1720# linux-aio probe
5c6c3a6c
CH
1721
1722if test "$linux_aio" != "no" ; then
1723 cat > $TMPC <<EOF
1724#include <libaio.h>
1725#include <sys/eventfd.h>
1726int main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
1727EOF
1728 if compile_prog "" "-laio" ; then
1729 linux_aio=yes
048d179f
PB
1730 libs_softmmu="$libs_softmmu -laio"
1731 libs_tools="$libs_tools -laio"
5c6c3a6c
CH
1732 else
1733 if test "$linux_aio" = "yes" ; then
1734 feature_not_found "linux AIO"
1735 fi
3cfcae3c 1736 linux_aio=no
5c6c3a6c
CH
1737 fi
1738fi
1739
758e8e38
VJ
1740##########################################
1741# attr probe
1742
1743if test "$attr" != "no" ; then
1744 cat > $TMPC <<EOF
1745#include <stdio.h>
1746#include <sys/types.h>
1747#include <attr/xattr.h>
1748int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
1749EOF
1750 if compile_prog "" "-lattr" ; then
1751 attr=yes
1752 LIBS="-lattr $LIBS"
1753 else
1754 if test "$attr" = "yes" ; then
1755 feature_not_found "ATTR"
1756 fi
1757 attr=no
1758 fi
1759fi
1760
bf9298b9
AL
1761##########################################
1762# iovec probe
1763cat > $TMPC <<EOF
db34f0b3 1764#include <sys/types.h>
bf9298b9 1765#include <sys/uio.h>
db34f0b3 1766#include <unistd.h>
bf9298b9
AL
1767int main(void) { struct iovec iov; return 0; }
1768EOF
1769iovec=no
52166aa0 1770if compile_prog "" "" ; then
bf9298b9
AL
1771 iovec=yes
1772fi
1773
ceb42de8
AL
1774##########################################
1775# preadv probe
1776cat > $TMPC <<EOF
1777#include <sys/types.h>
1778#include <sys/uio.h>
1779#include <unistd.h>
1780int main(void) { preadv; }
1781EOF
1782preadv=no
52166aa0 1783if compile_prog "" "" ; then
ceb42de8
AL
1784 preadv=yes
1785fi
1786
f652e6af
AJ
1787##########################################
1788# fdt probe
2df87df7 1789if test "$fdt" != "no" ; then
b41af4ba
JQ
1790 fdt_libs="-lfdt"
1791 cat > $TMPC << EOF
f652e6af
AJ
1792int main(void) { return 0; }
1793EOF
52166aa0 1794 if compile_prog "" "$fdt_libs" ; then
f652e6af 1795 fdt=yes
e4782985 1796 libs_softmmu="$fdt_libs $libs_softmmu"
2df87df7
JQ
1797 else
1798 if test "$fdt" = "yes" ; then
1799 feature_not_found "fdt"
1800 fi
1801 fdt=no
f652e6af
AJ
1802 fi
1803fi
1804
3b3f24ad
AJ
1805#
1806# Check for xxxat() functions when we are building linux-user
1807# emulator. This is done because older glibc versions don't
1808# have syscall stubs for these implemented.
1809#
1810atfile=no
67ba57f6 1811cat > $TMPC << EOF
3b3f24ad
AJ
1812#define _ATFILE_SOURCE
1813#include <sys/types.h>
1814#include <fcntl.h>
1815#include <unistd.h>
1816
1817int
1818main(void)
1819{
1820 /* try to unlink nonexisting file */
1821 return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
1822}
1823EOF
52166aa0 1824if compile_prog "" "" ; then
67ba57f6 1825 atfile=yes
3b3f24ad
AJ
1826fi
1827
39386ac7 1828# Check for inotify functions when we are building linux-user
3b3f24ad
AJ
1829# emulator. This is done because older glibc versions don't
1830# have syscall stubs for these implemented. In that case we
1831# don't provide them even if kernel supports them.
1832#
1833inotify=no
67ba57f6 1834cat > $TMPC << EOF
3b3f24ad
AJ
1835#include <sys/inotify.h>
1836
1837int
1838main(void)
1839{
1840 /* try to start inotify */
8690e420 1841 return inotify_init();
3b3f24ad
AJ
1842}
1843EOF
52166aa0 1844if compile_prog "" "" ; then
67ba57f6 1845 inotify=yes
3b3f24ad
AJ
1846fi
1847
c05c7a73
RV
1848inotify1=no
1849cat > $TMPC << EOF
1850#include <sys/inotify.h>
1851
1852int
1853main(void)
1854{
1855 /* try to start inotify */
1856 return inotify_init1(0);
1857}
1858EOF
1859if compile_prog "" "" ; then
1860 inotify1=yes
1861fi
1862
ebc996f3
RV
1863# check if utimensat and futimens are supported
1864utimens=no
1865cat > $TMPC << EOF
1866#define _ATFILE_SOURCE
1867#define _GNU_SOURCE
1868#include <stddef.h>
1869#include <fcntl.h>
1870
1871int main(void)
1872{
1873 utimensat(AT_FDCWD, "foo", NULL, 0);
1874 futimens(0, NULL);
1875 return 0;
1876}
1877EOF
52166aa0 1878if compile_prog "" "" ; then
ebc996f3
RV
1879 utimens=yes
1880fi
1881
099d6b0f
RV
1882# check if pipe2 is there
1883pipe2=no
1884cat > $TMPC << EOF
1885#define _GNU_SOURCE
1886#include <unistd.h>
1887#include <fcntl.h>
1888
1889int main(void)
1890{
1891 int pipefd[2];
1892 pipe2(pipefd, O_CLOEXEC);
1893 return 0;
1894}
1895EOF
52166aa0 1896if compile_prog "" "" ; then
099d6b0f
RV
1897 pipe2=yes
1898fi
1899
40ff6d7e
KW
1900# check if accept4 is there
1901accept4=no
1902cat > $TMPC << EOF
1903#define _GNU_SOURCE
1904#include <sys/socket.h>
1905#include <stddef.h>
1906
1907int main(void)
1908{
1909 accept4(0, NULL, NULL, SOCK_CLOEXEC);
1910 return 0;
1911}
1912EOF
1913if compile_prog "" "" ; then
1914 accept4=yes
1915fi
1916
3ce34dfb
VS
1917# check if tee/splice is there. vmsplice was added same time.
1918splice=no
1919cat > $TMPC << EOF
1920#define _GNU_SOURCE
1921#include <unistd.h>
1922#include <fcntl.h>
1923#include <limits.h>
1924
1925int main(void)
1926{
1927 int len, fd;
1928 len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
1929 splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
1930 return 0;
1931}
1932EOF
52166aa0 1933if compile_prog "" "" ; then
3ce34dfb
VS
1934 splice=yes
1935fi
1936
c2882b96
RV
1937# check if eventfd is supported
1938eventfd=no
1939cat > $TMPC << EOF
1940#include <sys/eventfd.h>
1941
1942int main(void)
1943{
1944 int efd = eventfd(0, 0);
1945 return 0;
1946}
1947EOF
1948if compile_prog "" "" ; then
1949 eventfd=yes
1950fi
1951
d0927938
UH
1952# check for fallocate
1953fallocate=no
1954cat > $TMPC << EOF
1955#include <fcntl.h>
1956
1957int main(void)
1958{
1959 fallocate(0, 0, 0, 0);
1960 return 0;
1961}
1962EOF
be17dc90 1963if compile_prog "$ARCH_CFLAGS" "" ; then
d0927938
UH
1964 fallocate=yes
1965fi
1966
1967# check for dup3
1968dup3=no
1969cat > $TMPC << EOF
1970#include <unistd.h>
1971
1972int main(void)
1973{
1974 dup3(0, 0, 0);
1975 return 0;
1976}
1977EOF
78f5d726 1978if compile_prog "" "" ; then
d0927938
UH
1979 dup3=yes
1980fi
1981
cc8ae6de 1982# Check if tools are available to build documentation.
a25dba17 1983if test "$docs" != "no" ; then
01668d98 1984 if has makeinfo && has pod2man; then
a25dba17 1985 docs=yes
83a3ab8b 1986 else
a25dba17
JQ
1987 if test "$docs" = "yes" ; then
1988 feature_not_found "docs"
83a3ab8b 1989 fi
a25dba17 1990 docs=no
83a3ab8b 1991 fi
cc8ae6de
PB
1992fi
1993
f514f41c 1994# Search for bswap_32 function
6ae9a1f4
JQ
1995byteswap_h=no
1996cat > $TMPC << EOF
1997#include <byteswap.h>
1998int main(void) { return bswap_32(0); }
1999EOF
52166aa0 2000if compile_prog "" "" ; then
6ae9a1f4
JQ
2001 byteswap_h=yes
2002fi
2003
f514f41c 2004# Search for bswap_32 function
6ae9a1f4
JQ
2005bswap_h=no
2006cat > $TMPC << EOF
2007#include <sys/endian.h>
2008#include <sys/types.h>
2009#include <machine/bswap.h>
2010int main(void) { return bswap32(0); }
2011EOF
52166aa0 2012if compile_prog "" "" ; then
6ae9a1f4
JQ
2013 bswap_h=yes
2014fi
2015
da93a1fd
AL
2016##########################################
2017# Do we need librt
2018cat > $TMPC <<EOF
2019#include <signal.h>
2020#include <time.h>
2021int main(void) { clockid_t id; return clock_gettime(id, NULL); }
2022EOF
2023
52166aa0 2024if compile_prog "" "" ; then
07ffa4bd 2025 :
52166aa0 2026elif compile_prog "" "-lrt" ; then
07ffa4bd 2027 LIBS="-lrt $LIBS"
da93a1fd
AL
2028fi
2029
31ff504d 2030if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
6362a53f
JQ
2031 "$aix" != "yes" ; then
2032 libs_softmmu="-lutil $libs_softmmu"
2033fi
2034
de5071c5
BS
2035##########################################
2036# check if the compiler defines offsetof
2037
2038need_offsetof=yes
2039cat > $TMPC << EOF
2040#include <stddef.h>
2041int main(void) { struct s { int f; }; return offsetof(struct s, f); }
2042EOF
2043if compile_prog "" "" ; then
2044 need_offsetof=no
2045fi
2046
747bbdf7
BS
2047##########################################
2048# check if the compiler understands attribute warn_unused_result
2049#
2050# This could be smarter, but gcc -Werror does not error out even when warning
2051# about attribute warn_unused_result
2052
2053gcc_attribute_warn_unused_result=no
2054cat > $TMPC << EOF
2055#if defined(__GNUC__) && (__GNUC__ < 4) && defined(__GNUC_MINOR__) && (__GNUC__ < 4)
2056#error gcc 3.3 or older
2057#endif
2058int main(void) { return 0;}
2059EOF
2060if compile_prog "" ""; then
2061 gcc_attribute_warn_unused_result=yes
2062fi
2063
5f6b9e8f
BS
2064##########################################
2065# check if we have fdatasync
2066
2067fdatasync=no
2068cat > $TMPC << EOF
2069#include <unistd.h>
2070int main(void) { return fdatasync(0); }
2071EOF
2072if compile_prog "" "" ; then
2073 fdatasync=yes
2074fi
2075
e78815a5
AF
2076##########################################
2077# check if we have madvise
2078
2079madvise=no
2080cat > $TMPC << EOF
2081#include <sys/types.h>
2082#include <sys/mman.h>
2083int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
2084EOF
2085if compile_prog "" "" ; then
2086 madvise=yes
2087fi
2088
2089##########################################
2090# check if we have posix_madvise
2091
2092posix_madvise=no
2093cat > $TMPC << EOF
2094#include <sys/mman.h>
2095int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
2096EOF
2097if compile_prog "" "" ; then
2098 posix_madvise=yes
2099fi
2100
94a420b1
SH
2101##########################################
2102# check if trace backend exists
2103
2104sh "$source_path/tracetool" "--$trace_backend" --check-backend > /dev/null 2> /dev/null
2105if test "$?" -ne 0 ; then
2106 echo
2107 echo "Error: invalid trace backend"
2108 echo "Please choose a supported trace backend."
2109 echo
2110 exit 1
2111fi
2112
7e24e92a
SH
2113##########################################
2114# For 'ust' backend, test if ust headers are present
2115if test "$trace_backend" = "ust"; then
2116 cat > $TMPC << EOF
2117#include <ust/tracepoint.h>
2118#include <ust/marker.h>
2119int main(void) { return 0; }
2120EOF
2121 if compile_prog "" "" ; then
2122 LIBS="-lust $LIBS"
2123 else
2124 echo
2125 echo "Error: Trace backend 'ust' missing libust header files"
2126 echo
2127 exit 1
2128 fi
2129fi
2130##########################################
e86ecd4b
JQ
2131# End of CC checks
2132# After here, no more $cc or $ld runs
2133
e86ecd4b 2134if test "$debug" = "no" ; then
1156c669 2135 CFLAGS="-O2 $CFLAGS"
e86ecd4b 2136fi
a316e378 2137
e86ecd4b
JQ
2138# Consult white-list to determine whether to enable werror
2139# by default. Only enable by default for git builds
20ff6c80
AL
2140z_version=`cut -f3 -d. $source_path/VERSION`
2141
e86ecd4b 2142if test -z "$werror" ; then
e86ecd4b
JQ
2143 if test "$z_version" = "50" -a \
2144 "$linux" = "yes" ; then
2145 werror="yes"
2146 else
2147 werror="no"
2148 fi
2149fi
2150
20ff6c80
AL
2151# Disable zero malloc errors for official releases unless explicitly told to
2152# enable/disable
2153if test -z "$zero_malloc" ; then
2154 if test "$z_version" = "50" ; then
2155 zero_malloc="no"
2156 else
2157 zero_malloc="yes"
2158 fi
2159fi
2160
e86ecd4b 2161if test "$werror" = "yes" ; then
a558ee17 2162 QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
e86ecd4b
JQ
2163fi
2164
2165if test "$solaris" = "no" ; then
2166 if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
1156c669 2167 LDFLAGS="-Wl,--warn-common $LDFLAGS"
e86ecd4b
JQ
2168 fi
2169fi
2170
952afb71
BS
2171# Use ASLR, no-SEH and DEP if available
2172if test "$mingw32" = "yes" ; then
2173 for flag in --dynamicbase --no-seh --nxcompat; do
2174 if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
2175 LDFLAGS="-Wl,$flag $LDFLAGS"
2176 fi
2177 done
2178fi
2179
190e9c59 2180confdir=$sysconfdir$confsuffix
e7b45cc4 2181
ca35f780
PB
2182tools=
2183if test "$softmmu" = yes ; then
2184 tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
2185 if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
2186 tools="qemu-nbd\$(EXESUF) $tools"
2187 if [ "$check_utests" = "yes" ]; then
2188 tools="check-qint check-qstring check-qdict check-qlist $tools"
2189 tools="check-qfloat check-qjson $tools"
2190 fi
2191 fi
2192fi
2193
2194# Mac OS X ships with a broken assembler
2195roms=
2196if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
2197 "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
2198 "$softmmu" = yes ; then
2199 roms="optionrom"
2200fi
2201
2202
43ce4dfe 2203echo "Install prefix $prefix"
f2b9e1e3
PB
2204echo "BIOS directory `eval echo $datadir`"
2205echo "binary directory `eval echo $bindir`"
1c0fd160 2206echo "config directory `eval echo $sysconfdir`"
11d9f695 2207if test "$mingw32" = "no" ; then
f2b9e1e3 2208echo "Manual directory `eval echo $mandir`"
43ce4dfe 2209echo "ELF interp prefix $interp_prefix"
11d9f695 2210fi
5a67135a 2211echo "Source path $source_path"
43ce4dfe 2212echo "C compiler $cc"
83469015 2213echo "Host C compiler $host_cc"
0c439cbf 2214echo "CFLAGS $CFLAGS"
a558ee17 2215echo "QEMU_CFLAGS $QEMU_CFLAGS"
0c439cbf 2216echo "LDFLAGS $LDFLAGS"
43ce4dfe 2217echo "make $make"
6a882643 2218echo "install $install"
43ce4dfe 2219echo "host CPU $cpu"
de83cd02 2220echo "host big endian $bigendian"
97a847bc 2221echo "target list $target_list"
ade25b0d 2222echo "tcg debug enabled $debug_tcg"
b4475aa2 2223echo "Mon debug enabled $debug_mon"
43ce4dfe 2224echo "gprof enabled $gprof"
03b4fe7d 2225echo "sparse enabled $sparse"
1625af87 2226echo "strip binaries $strip_opt"
05c2a3e7 2227echo "profiler $profiler"
43ce4dfe 2228echo "static build $static"
85aa5189 2229echo "-Werror enabled $werror"
5b0753e0
FB
2230if test "$darwin" = "yes" ; then
2231 echo "Cocoa support $cocoa"
2232fi
97a847bc 2233echo "SDL support $sdl"
4d3b6f6e 2234echo "curses support $curses"
769ce76d 2235echo "curl support $curl"
5495ed11 2236echo "check support $check_utests"
67b915a5 2237echo "mingw32 support $mingw32"
0c58ac1c 2238echo "Audio drivers $audio_drv_list"
2239echo "Extra audio cards $audio_card_list"
eb852011 2240echo "Block whitelist $block_drv_whitelist"
8ff9cbf7 2241echo "Mixer emulation $mixemu"
8d5d2d4c 2242echo "VNC TLS support $vnc_tls"
2f9606b3 2243echo "VNC SASL support $vnc_sasl"
2f6f5c7a 2244echo "VNC JPEG support $vnc_jpeg"
efe556ad 2245echo "VNC PNG support $vnc_png"
bd023f95 2246echo "VNC thread $vnc_thread"
3142255c
BS
2247if test -n "$sparc_cpu"; then
2248 echo "Target Sparc Arch $sparc_cpu"
2249fi
e37630ca 2250echo "xen support $xen"
2e4d9fb1 2251echo "brlapi support $brlapi"
a20a6f46 2252echo "bluez support $bluez"
a25dba17 2253echo "Documentation $docs"
c5937220
PB
2254[ ! -z "$uname_release" ] && \
2255echo "uname -r $uname_release"
bd0c5661 2256echo "NPTL support $nptl"
379f6698 2257echo "GUEST_BASE $guest_base"
34005a00 2258echo "PIE user targets $user_pie"
8a16d273 2259echo "vde support $vde"
e5d355d1 2260echo "IO thread $io_thread"
5c6c3a6c 2261echo "Linux AIO support $linux_aio"
758e8e38 2262echo "ATTR/XATTR support $attr"
77755340 2263echo "Install blobs $blobs"
b31a0277 2264echo "KVM support $kvm"
f652e6af 2265echo "fdt support $fdt"
ceb42de8 2266echo "preadv support $preadv"
5f6b9e8f 2267echo "fdatasync $fdatasync"
e78815a5
AF
2268echo "madvise $madvise"
2269echo "posix_madvise $posix_madvise"
ee682d27 2270echo "uuid support $uuid"
d5970055 2271echo "vhost-net support $vhost_net"
94a420b1 2272echo "Trace backend $trace_backend"
9410b56c 2273echo "Trace output file $trace_file-<pid>"
67b915a5 2274
97a847bc 2275if test $sdl_too_old = "yes"; then
24b55b96 2276echo "-> Your SDL version is too old - please upgrade to have SDL support"
7c1f25b4 2277fi
7d13299d 2278
98ec69ac 2279config_host_mak="config-host.mak"
4bf6b55b 2280config_host_ld="config-host.ld"
98ec69ac 2281
98ec69ac
JQ
2282echo "# Automatically generated by configure - do not modify" > $config_host_mak
2283printf "# Configured with:" >> $config_host_mak
2284printf " '%s'" "$0" "$@" >> $config_host_mak
2285echo >> $config_host_mak
98ec69ac 2286
99d7cc75
PB
2287echo "prefix=$prefix" >> $config_host_mak
2288echo "bindir=$bindir" >> $config_host_mak
2289echo "mandir=$mandir" >> $config_host_mak
2290echo "datadir=$datadir" >> $config_host_mak
2291echo "sysconfdir=$sysconfdir" >> $config_host_mak
2292echo "docdir=$docdir" >> $config_host_mak
1dabe05c 2293echo "confdir=$confdir" >> $config_host_mak
804edf29 2294
2408a527 2295case "$cpu" in
24e804ec 2296 i386|x86_64|alpha|cris|hppa|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
e0da9dd3 2297 ARCH=$cpu
2408a527 2298 ;;
a302c32d 2299 armv4b|armv4l)
16dbd14f 2300 ARCH=arm
2408a527 2301 ;;
2408a527 2302esac
98ec69ac 2303echo "ARCH=$ARCH" >> $config_host_mak
f8393946 2304if test "$debug_tcg" = "yes" ; then
2358a494 2305 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
f8393946 2306fi
b4475aa2
LC
2307if test "$debug_mon" = "yes" ; then
2308 echo "CONFIG_DEBUG_MONITOR=y" >> $config_host_mak
2309fi
f3d08ee6 2310if test "$debug" = "yes" ; then
2358a494 2311 echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
f3d08ee6 2312fi
1625af87 2313if test "$strip_opt" = "yes" ; then
52ba784d 2314 echo "STRIP=${strip}" >> $config_host_mak
1625af87 2315fi
7d13299d 2316if test "$bigendian" = "yes" ; then
e2542fe2 2317 echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
97a847bc 2318fi
2358a494 2319echo "HOST_LONG_BITS=$hostlongbits" >> $config_host_mak
67b915a5 2320if test "$mingw32" = "yes" ; then
98ec69ac 2321 echo "CONFIG_WIN32=y" >> $config_host_mak
210fa556 2322else
35f4df27 2323 echo "CONFIG_POSIX=y" >> $config_host_mak
dffcb71c
MM
2324fi
2325
2326if test "$linux" = "yes" ; then
2327 echo "CONFIG_LINUX=y" >> $config_host_mak
67b915a5 2328fi
128ab2ff 2329
83fb7adf 2330if test "$darwin" = "yes" ; then
98ec69ac 2331 echo "CONFIG_DARWIN=y" >> $config_host_mak
83fb7adf 2332fi
b29fe3ed 2333
2334if test "$aix" = "yes" ; then
98ec69ac 2335 echo "CONFIG_AIX=y" >> $config_host_mak
b29fe3ed 2336fi
2337
ec530c81 2338if test "$solaris" = "yes" ; then
98ec69ac 2339 echo "CONFIG_SOLARIS=y" >> $config_host_mak
2358a494 2340 echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
0475a5ca 2341 if test "$needs_libsunmath" = "yes" ; then
75b5a697 2342 echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
0475a5ca 2343 fi
ec530c81 2344fi
97a847bc 2345if test "$static" = "yes" ; then
98ec69ac 2346 echo "CONFIG_STATIC=y" >> $config_host_mak
7d13299d 2347fi
05c2a3e7 2348if test $profiler = "yes" ; then
2358a494 2349 echo "CONFIG_PROFILER=y" >> $config_host_mak
05c2a3e7 2350fi
c20709aa 2351if test "$slirp" = "yes" ; then
98ec69ac 2352 echo "CONFIG_SLIRP=y" >> $config_host_mak
b6e31c12 2353 QEMU_CFLAGS="-I\$(SRC_PATH)/slirp $QEMU_CFLAGS"
c20709aa 2354fi
8a16d273 2355if test "$vde" = "yes" ; then
98ec69ac 2356 echo "CONFIG_VDE=y" >> $config_host_mak
8a16d273 2357fi
0c58ac1c 2358for card in $audio_card_list; do
f6e5889e 2359 def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
98ec69ac 2360 echo "$def=y" >> $config_host_mak
0c58ac1c 2361done
2358a494 2362echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
0c58ac1c 2363for drv in $audio_drv_list; do
f6e5889e 2364 def=CONFIG_`echo $drv | tr '[:lower:]' '[:upper:]'`
98ec69ac 2365 echo "$def=y" >> $config_host_mak
923e4521 2366 if test "$drv" = "fmod"; then
7aac6cb1 2367 echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
0c58ac1c 2368 fi
2369done
67f86e8e
JQ
2370if test "$audio_pt_int" = "yes" ; then
2371 echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
2372fi
d5631638 2373if test "$audio_win_int" = "yes" ; then
2374 echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
2375fi
eb852011 2376echo "CONFIG_BDRV_WHITELIST=$block_drv_whitelist" >> $config_host_mak
8ff9cbf7 2377if test "$mixemu" = "yes" ; then
98ec69ac 2378 echo "CONFIG_MIXEMU=y" >> $config_host_mak
8ff9cbf7 2379fi
8d5d2d4c 2380if test "$vnc_tls" = "yes" ; then
98ec69ac 2381 echo "CONFIG_VNC_TLS=y" >> $config_host_mak
525061bf 2382 echo "VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_host_mak
8d5d2d4c 2383fi
2f9606b3 2384if test "$vnc_sasl" = "yes" ; then
98ec69ac 2385 echo "CONFIG_VNC_SASL=y" >> $config_host_mak
60ddf533 2386 echo "VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak
2f9606b3 2387fi
96763cf9 2388if test "$vnc_jpeg" != "no" ; then
2f6f5c7a
CC
2389 echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
2390 echo "VNC_JPEG_CFLAGS=$vnc_jpeg_cflags" >> $config_host_mak
2391fi
96763cf9 2392if test "$vnc_png" != "no" ; then
efe556ad
CC
2393 echo "CONFIG_VNC_PNG=y" >> $config_host_mak
2394 echo "VNC_PNG_CFLAGS=$vnc_png_cflags" >> $config_host_mak
2395fi
96763cf9 2396if test "$vnc_thread" != "no" ; then
bd023f95
CC
2397 echo "CONFIG_VNC_THREAD=y" >> $config_host_mak
2398 echo "CONFIG_THREAD=y" >> $config_host_mak
2399fi
76655d6d 2400if test "$fnmatch" = "yes" ; then
2358a494 2401 echo "CONFIG_FNMATCH=y" >> $config_host_mak
76655d6d 2402fi
ee682d27
SW
2403if test "$uuid" = "yes" ; then
2404 echo "CONFIG_UUID=y" >> $config_host_mak
2405fi
b1a550a0 2406qemu_version=`head $source_path/VERSION`
98ec69ac 2407echo "VERSION=$qemu_version" >>$config_host_mak
2358a494 2408echo "PKGVERSION=$pkgversion" >>$config_host_mak
98ec69ac 2409echo "SRC_PATH=$source_path" >> $config_host_mak
98ec69ac 2410echo "TARGET_DIRS=$target_list" >> $config_host_mak
a25dba17 2411if [ "$docs" = "yes" ] ; then
98ec69ac 2412 echo "BUILD_DOCS=yes" >> $config_host_mak
cc8ae6de 2413fi
1ac88f28 2414if test "$sdl" = "yes" ; then
98ec69ac 2415 echo "CONFIG_SDL=y" >> $config_host_mak
1ac88f28 2416 echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
49ecc3fa
FB
2417fi
2418if test "$cocoa" = "yes" ; then
98ec69ac 2419 echo "CONFIG_COCOA=y" >> $config_host_mak
4d3b6f6e
AZ
2420fi
2421if test "$curses" = "yes" ; then
98ec69ac 2422 echo "CONFIG_CURSES=y" >> $config_host_mak
49ecc3fa 2423fi
3b3f24ad 2424if test "$atfile" = "yes" ; then
2358a494 2425 echo "CONFIG_ATFILE=y" >> $config_host_mak
3b3f24ad 2426fi
ebc996f3 2427if test "$utimens" = "yes" ; then
2358a494 2428 echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
ebc996f3 2429fi
099d6b0f 2430if test "$pipe2" = "yes" ; then
2358a494 2431 echo "CONFIG_PIPE2=y" >> $config_host_mak
099d6b0f 2432fi
40ff6d7e
KW
2433if test "$accept4" = "yes" ; then
2434 echo "CONFIG_ACCEPT4=y" >> $config_host_mak
2435fi
3ce34dfb 2436if test "$splice" = "yes" ; then
2358a494 2437 echo "CONFIG_SPLICE=y" >> $config_host_mak
3ce34dfb 2438fi
c2882b96
RV
2439if test "$eventfd" = "yes" ; then
2440 echo "CONFIG_EVENTFD=y" >> $config_host_mak
2441fi
d0927938
UH
2442if test "$fallocate" = "yes" ; then
2443 echo "CONFIG_FALLOCATE=y" >> $config_host_mak
2444fi
2445if test "$dup3" = "yes" ; then
2446 echo "CONFIG_DUP3=y" >> $config_host_mak
2447fi
3b3f24ad 2448if test "$inotify" = "yes" ; then
2358a494 2449 echo "CONFIG_INOTIFY=y" >> $config_host_mak
3b3f24ad 2450fi
c05c7a73
RV
2451if test "$inotify1" = "yes" ; then
2452 echo "CONFIG_INOTIFY1=y" >> $config_host_mak
2453fi
6ae9a1f4
JQ
2454if test "$byteswap_h" = "yes" ; then
2455 echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
2456fi
2457if test "$bswap_h" = "yes" ; then
2458 echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
2459fi
769ce76d 2460if test "$curl" = "yes" ; then
98ec69ac 2461 echo "CONFIG_CURL=y" >> $config_host_mak
b1d5a277 2462 echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
769ce76d 2463fi
2e4d9fb1 2464if test "$brlapi" = "yes" ; then
98ec69ac 2465 echo "CONFIG_BRLAPI=y" >> $config_host_mak
2e4d9fb1 2466fi
fb599c9a 2467if test "$bluez" = "yes" ; then
98ec69ac 2468 echo "CONFIG_BLUEZ=y" >> $config_host_mak
ef7635ec 2469 echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
fb599c9a 2470fi
e37630ca 2471if test "$xen" = "yes" ; then
5647eb74 2472 echo "CONFIG_XEN=y" >> $config_host_mak
e37630ca 2473fi
e5d355d1 2474if test "$io_thread" = "yes" ; then
98ec69ac 2475 echo "CONFIG_IOTHREAD=y" >> $config_host_mak
bd023f95 2476 echo "CONFIG_THREAD=y" >> $config_host_mak
e5d355d1 2477fi
5c6c3a6c
CH
2478if test "$linux_aio" = "yes" ; then
2479 echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
2480fi
758e8e38
VJ
2481if test "$attr" = "yes" ; then
2482 echo "CONFIG_ATTR=y" >> $config_host_mak
2483fi
2484if test "$linux" = "yes" ; then
2485 if test "$attr" = "yes" ; then
2486 echo "CONFIG_VIRTFS=y" >> $config_host_mak
2487 fi
2488fi
77755340 2489if test "$blobs" = "yes" ; then
98ec69ac 2490 echo "INSTALL_BLOBS=yes" >> $config_host_mak
77755340 2491fi
bf9298b9 2492if test "$iovec" = "yes" ; then
2358a494 2493 echo "CONFIG_IOVEC=y" >> $config_host_mak
bf9298b9 2494fi
ceb42de8 2495if test "$preadv" = "yes" ; then
2358a494 2496 echo "CONFIG_PREADV=y" >> $config_host_mak
ceb42de8 2497fi
f652e6af 2498if test "$fdt" = "yes" ; then
3f0855b1 2499 echo "CONFIG_FDT=y" >> $config_host_mak
f652e6af 2500fi
de5071c5
BS
2501if test "$need_offsetof" = "yes" ; then
2502 echo "CONFIG_NEED_OFFSETOF=y" >> $config_host_mak
2503fi
747bbdf7
BS
2504if test "$gcc_attribute_warn_unused_result" = "yes" ; then
2505 echo "CONFIG_GCC_ATTRIBUTE_WARN_UNUSED_RESULT=y" >> $config_host_mak
2506fi
5f6b9e8f
BS
2507if test "$fdatasync" = "yes" ; then
2508 echo "CONFIG_FDATASYNC=y" >> $config_host_mak
2509fi
e78815a5
AF
2510if test "$madvise" = "yes" ; then
2511 echo "CONFIG_MADVISE=y" >> $config_host_mak
2512fi
2513if test "$posix_madvise" = "yes" ; then
2514 echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
2515fi
97a847bc 2516
83fb7adf 2517# XXX: suppress that
7d3505c5 2518if [ "$bsd" = "yes" ] ; then
2358a494 2519 echo "CONFIG_BSD=y" >> $config_host_mak
7d3505c5
FB
2520fi
2521
2358a494 2522echo "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
c5937220 2523
20ff6c80
AL
2524if test "$zero_malloc" = "yes" ; then
2525 echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
2526fi
2527
68063649
BS
2528# USB host support
2529case "$usb" in
2530linux)
98ec69ac 2531 echo "HOST_USB=linux" >> $config_host_mak
68063649
BS
2532;;
2533bsd)
98ec69ac 2534 echo "HOST_USB=bsd" >> $config_host_mak
68063649
BS
2535;;
2536*)
98ec69ac 2537 echo "HOST_USB=stub" >> $config_host_mak
68063649
BS
2538;;
2539esac
2540
94a420b1 2541echo "TRACE_BACKEND=$trace_backend" >> $config_host_mak
22890ab5
PS
2542if test "$trace_backend" = "simple"; then
2543 echo "CONFIG_SIMPLE_TRACE=y" >> $config_host_mak
2544fi
9410b56c
PS
2545# Set the appropriate trace file.
2546if test "$trace_backend" = "simple"; then
2547 trace_file="\"$trace_file-%u\""
2548fi
2549echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
2550
98ec69ac 2551echo "TOOLS=$tools" >> $config_host_mak
98ec69ac 2552echo "ROMS=$roms" >> $config_host_mak
804edf29
JQ
2553echo "MAKE=$make" >> $config_host_mak
2554echo "INSTALL=$install" >> $config_host_mak
2555echo "INSTALL_DIR=$install -d -m0755 -p" >> $config_host_mak
2556echo "INSTALL_DATA=$install -m0644 -p" >> $config_host_mak
2557echo "INSTALL_PROG=$install -m0755 -p" >> $config_host_mak
2558echo "CC=$cc" >> $config_host_mak
2559echo "HOST_CC=$host_cc" >> $config_host_mak
2560if test "$sparse" = "yes" ; then
2561 echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_host_mak
2562 echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_host_mak
a558ee17 2563 echo "QEMU_CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
804edf29
JQ
2564fi
2565echo "AR=$ar" >> $config_host_mak
2566echo "OBJCOPY=$objcopy" >> $config_host_mak
2567echo "LD=$ld" >> $config_host_mak
e2a2ed06 2568echo "CFLAGS=$CFLAGS" >> $config_host_mak
a558ee17 2569echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
c81da56e 2570echo "HELPER_CFLAGS=$helper_cflags" >> $config_host_mak
e2a2ed06 2571echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
a36abbbb
JQ
2572echo "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak
2573echo "ARLIBS_END=$arlibs_end" >> $config_host_mak
73da375e 2574echo "LIBS+=$LIBS" >> $config_host_mak
3e2e0e6b 2575echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
804edf29 2576echo "EXESUF=$EXESUF" >> $config_host_mak
804edf29 2577
4bf6b55b
JQ
2578# generate list of library paths for linker script
2579
2580$ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
2581
2582if test -f ${config_host_ld}~ ; then
2583 if cmp -s $config_host_ld ${config_host_ld}~ ; then
2584 mv ${config_host_ld}~ $config_host_ld
2585 else
2586 rm ${config_host_ld}~
2587 fi
2588fi
2589
4d904533
BS
2590for d in libdis libdis-user; do
2591 mkdir -p $d
2592 rm -f $d/Makefile
2593 ln -s $source_path/Makefile.dis $d/Makefile
2594 echo > $d/config.mak
2595done
d44cff22
RH
2596if test "$static" = "no" -a "$user_pie" = "yes" ; then
2597 echo "QEMU_CFLAGS+=-fpie" > libdis-user/config.mak
2598fi
4d904533 2599
1d14ffa9 2600for target in $target_list; do
97a847bc 2601target_dir="$target"
25be210f 2602config_target_mak=$target_dir/config-target.mak
600309b6 2603target_arch2=`echo $target | cut -d '-' -f 1`
97a847bc 2604target_bigendian="no"
1f3d3c8f 2605
ea2d6a39 2606case "$target_arch2" in
24e804ec 2607 armeb|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus)
ea2d6a39
JQ
2608 target_bigendian=yes
2609 ;;
2610esac
97a847bc 2611target_softmmu="no"
997344f3 2612target_user_only="no"
831b7825 2613target_linux_user="no"
831b7825 2614target_darwin_user="no"
84778508 2615target_bsd_user="no"
9e407a85 2616case "$target" in
600309b6 2617 ${target_arch2}-softmmu)
9e407a85
PB
2618 target_softmmu="yes"
2619 ;;
600309b6 2620 ${target_arch2}-linux-user)
9c7a4202
BS
2621 if test "$linux" != "yes" ; then
2622 echo "ERROR: Target '$target' is only available on a Linux host"
2623 exit 1
2624 fi
9e407a85
PB
2625 target_user_only="yes"
2626 target_linux_user="yes"
2627 ;;
600309b6 2628 ${target_arch2}-darwin-user)
9c7a4202
BS
2629 if test "$darwin" != "yes" ; then
2630 echo "ERROR: Target '$target' is only available on a Darwin host"
2631 exit 1
2632 fi
9e407a85
PB
2633 target_user_only="yes"
2634 target_darwin_user="yes"
2635 ;;
600309b6 2636 ${target_arch2}-bsd-user)
9cf55765 2637 if test "$bsd" != "yes" ; then
9c7a4202
BS
2638 echo "ERROR: Target '$target' is only available on a BSD host"
2639 exit 1
2640 fi
84778508
BS
2641 target_user_only="yes"
2642 target_bsd_user="yes"
2643 ;;
9e407a85
PB
2644 *)
2645 echo "ERROR: Target '$target' not recognised"
2646 exit 1
2647 ;;
2648esac
831b7825 2649
97a847bc 2650mkdir -p $target_dir
158142c2 2651mkdir -p $target_dir/fpu
57fec1fe 2652mkdir -p $target_dir/tcg
59f2a787 2653mkdir -p $target_dir/ide
84778508 2654if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
69de927c
FB
2655 mkdir -p $target_dir/nwfpe
2656fi
2657
ec530c81
FB
2658#
2659# don't use ln -sf as not all "ln -sf" over write the file/link
2660#
2661rm -f $target_dir/Makefile
2662ln -s $source_path/Makefile.target $target_dir/Makefile
2663
97a847bc 2664
25be210f 2665echo "# Automatically generated by configure - do not modify" > $config_target_mak
de83cd02 2666
e5fe0c52 2667bflt="no"
bd0c5661 2668target_nptl="no"
600309b6 2669interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
7ee2822c 2670echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
56aebc89 2671gdb_xml_files=""
7ba1e619 2672
938b1edd 2673TARGET_ARCH="$target_arch2"
6acff7da 2674TARGET_BASE_ARCH=""
e6e91b9c 2675TARGET_ABI_DIR=""
e73aae67 2676
600309b6 2677case "$target_arch2" in
2408a527 2678 i386)
1ad2134f 2679 target_phys_bits=32
2408a527
AJ
2680 ;;
2681 x86_64)
6acff7da 2682 TARGET_BASE_ARCH=i386
1ad2134f 2683 target_phys_bits=64
2408a527
AJ
2684 ;;
2685 alpha)
1ad2134f 2686 target_phys_bits=64
a4b388ff 2687 target_nptl="yes"
2408a527
AJ
2688 ;;
2689 arm|armeb)
b498c8a0 2690 TARGET_ARCH=arm
2408a527 2691 bflt="yes"
bd0c5661 2692 target_nptl="yes"
56aebc89 2693 gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
1ad2134f 2694 target_phys_bits=32
2408a527
AJ
2695 ;;
2696 cris)
253bd7f8 2697 target_nptl="yes"
1ad2134f 2698 target_phys_bits=32
2408a527
AJ
2699 ;;
2700 m68k)
2408a527 2701 bflt="yes"
56aebc89 2702 gdb_xml_files="cf-core.xml cf-fp.xml"
1ad2134f 2703 target_phys_bits=32
2408a527 2704 ;;
72b675ca 2705 microblaze)
72b675ca
EI
2706 bflt="yes"
2707 target_nptl="yes"
2708 target_phys_bits=32
2709 ;;
0adcffb1 2710 mips|mipsel)
b498c8a0 2711 TARGET_ARCH=mips
25be210f 2712 echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
f04dc72f 2713 target_nptl="yes"
1ad2134f 2714 target_phys_bits=64
2408a527
AJ
2715 ;;
2716 mipsn32|mipsn32el)
b498c8a0 2717 TARGET_ARCH=mipsn32
6acff7da 2718 TARGET_BASE_ARCH=mips
25be210f 2719 echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
1ad2134f 2720 target_phys_bits=64
2408a527
AJ
2721 ;;
2722 mips64|mips64el)
b498c8a0 2723 TARGET_ARCH=mips64
6acff7da 2724 TARGET_BASE_ARCH=mips
25be210f 2725 echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
1ad2134f 2726 target_phys_bits=64
2408a527
AJ
2727 ;;
2728 ppc)
c8b3532d 2729 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
1ad2134f 2730 target_phys_bits=32
d6630708 2731 target_nptl="yes"
2408a527
AJ
2732 ;;
2733 ppcemb)
6acff7da 2734 TARGET_BASE_ARCH=ppc
e6e91b9c 2735 TARGET_ABI_DIR=ppc
c8b3532d 2736 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
1ad2134f 2737 target_phys_bits=64
d6630708 2738 target_nptl="yes"
2408a527
AJ
2739 ;;
2740 ppc64)
6acff7da 2741 TARGET_BASE_ARCH=ppc
e6e91b9c 2742 TARGET_ABI_DIR=ppc
c8b3532d 2743 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
1ad2134f 2744 target_phys_bits=64
2408a527
AJ
2745 ;;
2746 ppc64abi32)
b498c8a0 2747 TARGET_ARCH=ppc64
6acff7da 2748 TARGET_BASE_ARCH=ppc
e6e91b9c 2749 TARGET_ABI_DIR=ppc
25be210f 2750 echo "TARGET_ABI32=y" >> $config_target_mak
c8b3532d 2751 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
1ad2134f 2752 target_phys_bits=64
2408a527
AJ
2753 ;;
2754 sh4|sh4eb)
b498c8a0 2755 TARGET_ARCH=sh4
2408a527 2756 bflt="yes"
0b6d3ae0 2757 target_nptl="yes"
1ad2134f 2758 target_phys_bits=32
2408a527
AJ
2759 ;;
2760 sparc)
1ad2134f 2761 target_phys_bits=64
2408a527
AJ
2762 ;;
2763 sparc64)
6acff7da 2764 TARGET_BASE_ARCH=sparc
1ad2134f 2765 target_phys_bits=64
2408a527
AJ
2766 ;;
2767 sparc32plus)
b498c8a0 2768 TARGET_ARCH=sparc64
6acff7da 2769 TARGET_BASE_ARCH=sparc
e6e91b9c 2770 TARGET_ABI_DIR=sparc
25be210f 2771 echo "TARGET_ABI32=y" >> $config_target_mak
1ad2134f 2772 target_phys_bits=64
2408a527 2773 ;;
24e804ec
AG
2774 s390x)
2775 target_phys_bits=64
2776 ;;
2408a527
AJ
2777 *)
2778 echo "Unsupported target CPU"
2779 exit 1
2780 ;;
2781esac
25be210f 2782echo "TARGET_ARCH=$TARGET_ARCH" >> $config_target_mak
053dd92e 2783target_arch_name="`echo $TARGET_ARCH | tr '[:lower:]' '[:upper:]'`"
25be210f
JQ
2784echo "TARGET_$target_arch_name=y" >> $config_target_mak
2785echo "TARGET_ARCH2=$target_arch2" >> $config_target_mak
42bc608b 2786# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
6acff7da
JQ
2787if [ "$TARGET_BASE_ARCH" = "" ]; then
2788 TARGET_BASE_ARCH=$TARGET_ARCH
6acff7da 2789fi
25be210f 2790echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
e6e91b9c
JQ
2791if [ "$TARGET_ABI_DIR" = "" ]; then
2792 TARGET_ABI_DIR=$TARGET_ARCH
2793fi
25be210f 2794echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
1b0c87fc
JQ
2795case "$target_arch2" in
2796 i386|x86_64)
2797 if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
25be210f 2798 echo "CONFIG_XEN=y" >> $config_target_mak
1b0c87fc
JQ
2799 fi
2800esac
c59249f9 2801case "$target_arch2" in
0e60a699 2802 i386|x86_64|ppcemb|ppc|ppc64|s390x)
c59249f9
JQ
2803 # Make sure the target and host cpus are compatible
2804 if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
2805 \( "$target_arch2" = "$cpu" -o \
2806 \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
5f114bc6 2807 \( "$target_arch2" = "ppc64" -a "$cpu" = "ppc" \) -o \
c59249f9
JQ
2808 \( "$target_arch2" = "x86_64" -a "$cpu" = "i386" \) -o \
2809 \( "$target_arch2" = "i386" -a "$cpu" = "x86_64" \) \) ; then
25be210f
JQ
2810 echo "CONFIG_KVM=y" >> $config_target_mak
2811 echo "KVM_CFLAGS=$kvm_cflags" >> $config_target_mak
dae5079a
JK
2812 if test "$kvm_para" = "yes"; then
2813 echo "CONFIG_KVM_PARA=y" >> $config_target_mak
2814 fi
d5970055
MT
2815 if test $vhost_net = "yes" ; then
2816 echo "CONFIG_VHOST_NET=y" >> $config_target_mak
2817 fi
c59249f9
JQ
2818 fi
2819esac
de83cd02 2820if test "$target_bigendian" = "yes" ; then
25be210f 2821 echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
de83cd02 2822fi
97a847bc 2823if test "$target_softmmu" = "yes" ; then
b1aa27c4 2824 echo "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_target_mak
25be210f
JQ
2825 echo "CONFIG_SOFTMMU=y" >> $config_target_mak
2826 echo "LIBS+=$libs_softmmu" >> $config_target_mak
0e8c9214 2827 echo "HWDIR=../libhw$target_phys_bits" >> $config_target_mak
5791f45b 2828 echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
43ce4dfe 2829fi
997344f3 2830if test "$target_user_only" = "yes" ; then
25be210f 2831 echo "CONFIG_USER_ONLY=y" >> $config_target_mak
997344f3 2832fi
831b7825 2833if test "$target_linux_user" = "yes" ; then
25be210f 2834 echo "CONFIG_LINUX_USER=y" >> $config_target_mak
831b7825
TS
2835fi
2836if test "$target_darwin_user" = "yes" ; then
25be210f 2837 echo "CONFIG_DARWIN_USER=y" >> $config_target_mak
831b7825 2838fi
56aebc89
PB
2839list=""
2840if test ! -z "$gdb_xml_files" ; then
2841 for x in $gdb_xml_files; do
2842 list="$list $source_path/gdb-xml/$x"
2843 done
3d0f1517 2844 echo "TARGET_XML_FILES=$list" >> $config_target_mak
56aebc89 2845fi
97a847bc 2846
f57975fb 2847case "$target_arch2" in
990b3e19 2848 alpha|arm|armeb|m68k|microblaze|mips|mipsel|mipsn32|mipsn32el|mips64|mips64el|ppc|ppc64|ppc64abi32|ppcemb|s390x|sparc|sparc64|sparc32plus)
25be210f 2849 echo "CONFIG_SOFTFLOAT=y" >> $config_target_mak
f57975fb 2850 ;;
d6b38939 2851 *)
25be210f 2852 echo "CONFIG_NOSOFTFLOAT=y" >> $config_target_mak
d6b38939 2853 ;;
f57975fb
JQ
2854esac
2855
e5fe0c52 2856if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
25be210f 2857 echo "TARGET_HAS_BFLT=y" >> $config_target_mak
e5fe0c52 2858fi
bd0c5661
PB
2859if test "$target_user_only" = "yes" \
2860 -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
25be210f 2861 echo "CONFIG_USE_NPTL=y" >> $config_target_mak
bd0c5661 2862fi
379f6698 2863if test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
25be210f 2864 echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
379f6698 2865fi
84778508 2866if test "$target_bsd_user" = "yes" ; then
25be210f 2867 echo "CONFIG_BSD_USER=y" >> $config_target_mak
84778508 2868fi
5b0753e0 2869
4afddb55 2870# generate QEMU_CFLAGS/LDFLAGS for targets
fa282484 2871
4afddb55 2872cflags=""
fa282484 2873ldflags=""
9b8e111f 2874
57ddfbf7
JQ
2875if test "$ARCH" = "sparc64" ; then
2876 cflags="-I\$(SRC_PATH)/tcg/sparc $cflags"
24e804ec
AG
2877elif test "$ARCH" = "s390x" ; then
2878 cflags="-I\$(SRC_PATH)/tcg/s390 $cflags"
5d8a4f8f
RH
2879elif test "$ARCH" = "x86_64" ; then
2880 cflags="-I\$(SRC_PATH)/tcg/i386 $cflags"
57ddfbf7
JQ
2881else
2882 cflags="-I\$(SRC_PATH)/tcg/\$(ARCH) $cflags"
2883fi
2884cflags="-I\$(SRC_PATH)/tcg $cflags"
2885cflags="-I\$(SRC_PATH)/fpu $cflags"
2886
4d904533
BS
2887if test "$target_user_only" = "yes" ; then
2888 libdis_config_mak=libdis-user/config.mak
2889else
2890 libdis_config_mak=libdis/config.mak
2891fi
2892
64656024
JQ
2893for i in $ARCH $TARGET_BASE_ARCH ; do
2894 case "$i" in
2895 alpha)
25be210f 2896 echo "CONFIG_ALPHA_DIS=y" >> $config_target_mak
4d904533 2897 echo "CONFIG_ALPHA_DIS=y" >> $libdis_config_mak
64656024
JQ
2898 ;;
2899 arm)
25be210f 2900 echo "CONFIG_ARM_DIS=y" >> $config_target_mak
4d904533 2901 echo "CONFIG_ARM_DIS=y" >> $libdis_config_mak
64656024
JQ
2902 ;;
2903 cris)
25be210f 2904 echo "CONFIG_CRIS_DIS=y" >> $config_target_mak
4d904533 2905 echo "CONFIG_CRIS_DIS=y" >> $libdis_config_mak
64656024
JQ
2906 ;;
2907 hppa)
25be210f 2908 echo "CONFIG_HPPA_DIS=y" >> $config_target_mak
4d904533 2909 echo "CONFIG_HPPA_DIS=y" >> $libdis_config_mak
64656024
JQ
2910 ;;
2911 i386|x86_64)
25be210f 2912 echo "CONFIG_I386_DIS=y" >> $config_target_mak
4d904533 2913 echo "CONFIG_I386_DIS=y" >> $libdis_config_mak
64656024 2914 ;;
903ec55c
AJ
2915 ia64*)
2916 echo "CONFIG_IA64_DIS=y" >> $config_target_mak
2917 echo "CONFIG_IA64_DIS=y" >> $libdis_config_mak
2918 ;;
64656024 2919 m68k)
25be210f 2920 echo "CONFIG_M68K_DIS=y" >> $config_target_mak
4d904533 2921 echo "CONFIG_M68K_DIS=y" >> $libdis_config_mak
64656024
JQ
2922 ;;
2923 microblaze)
25be210f 2924 echo "CONFIG_MICROBLAZE_DIS=y" >> $config_target_mak
4d904533 2925 echo "CONFIG_MICROBLAZE_DIS=y" >> $libdis_config_mak
64656024
JQ
2926 ;;
2927 mips*)
25be210f 2928 echo "CONFIG_MIPS_DIS=y" >> $config_target_mak
4d904533 2929 echo "CONFIG_MIPS_DIS=y" >> $libdis_config_mak
64656024
JQ
2930 ;;
2931 ppc*)
25be210f 2932 echo "CONFIG_PPC_DIS=y" >> $config_target_mak
4d904533 2933 echo "CONFIG_PPC_DIS=y" >> $libdis_config_mak
64656024 2934 ;;
24e804ec 2935 s390*)
25be210f 2936 echo "CONFIG_S390_DIS=y" >> $config_target_mak
4d904533 2937 echo "CONFIG_S390_DIS=y" >> $libdis_config_mak
64656024
JQ
2938 ;;
2939 sh4)
25be210f 2940 echo "CONFIG_SH4_DIS=y" >> $config_target_mak
4d904533 2941 echo "CONFIG_SH4_DIS=y" >> $libdis_config_mak
64656024
JQ
2942 ;;
2943 sparc*)
25be210f 2944 echo "CONFIG_SPARC_DIS=y" >> $config_target_mak
4d904533 2945 echo "CONFIG_SPARC_DIS=y" >> $libdis_config_mak
64656024
JQ
2946 ;;
2947 esac
2948done
2949
6ee7126f
JQ
2950case "$ARCH" in
2951alpha)
2952 # Ensure there's only a single GP
2953 cflags="-msmall-data $cflags"
2954;;
2955esac
2956
55d9c04b
JQ
2957if test "$target_softmmu" = "yes" ; then
2958 case "$TARGET_BASE_ARCH" in
2959 arm)
2960 cflags="-DHAS_AUDIO $cflags"
2961 ;;
2962 i386|mips|ppc)
2963 cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags"
2964 ;;
2965 esac
2966fi
2967
34005a00 2968if test "$target_user_only" = "yes" -a "$static" = "no" -a \
50108930 2969 "$user_pie" = "yes" ; then
34005a00
KS
2970 cflags="-fpie $cflags"
2971 ldflags="-pie $ldflags"
2972fi
2973
471857dd
JQ
2974if test "$target_softmmu" = "yes" -a \( \
2975 "$TARGET_ARCH" = "microblaze" -o \
2976 "$TARGET_ARCH" = "cris" \) ; then
25be210f 2977 echo "CONFIG_NEED_MMU=y" >> $config_target_mak
471857dd
JQ
2978fi
2979
d02c1db3 2980if test "$gprof" = "yes" ; then
25be210f 2981 echo "TARGET_GPROF=yes" >> $config_target_mak
d02c1db3
JQ
2982 if test "$target_linux_user" = "yes" ; then
2983 cflags="-p $cflags"
2984 ldflags="-p $ldflags"
2985 fi
2986 if test "$target_softmmu" = "yes" ; then
2987 ldflags="-p $ldflags"
25be210f 2988 echo "GPROF_CFLAGS=-p" >> $config_target_mak
d02c1db3
JQ
2989 fi
2990fi
2991
6ee7126f 2992linker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/\$(ARCH).ld"
9b8e111f 2993if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
fa282484 2994 case "$ARCH" in
fa282484
JQ
2995 sparc)
2996 # -static is used to avoid g1/g3 usage by the dynamic linker
322e5878 2997 ldflags="$linker_script -static $ldflags"
fa282484 2998 ;;
4d58be06
RH
2999 alpha | s390x)
3000 # The default placement of the application is fine.
3001 ;;
fd76e73a 3002 *)
322e5878 3003 ldflags="$linker_script $ldflags"
fa282484
JQ
3004 ;;
3005 esac
3006fi
fa282484 3007
25be210f
JQ
3008echo "LDFLAGS+=$ldflags" >> $config_target_mak
3009echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak
fa282484 3010
97a847bc 3011done # for target in $targets
7d13299d
FB
3012
3013# build tree in object directory if source path is different from current one
3014if test "$source_path_used" = "yes" ; then
e1144d00 3015 DIRS="tests tests/cris slirp audio block net pc-bios/optionrom"
2d9f27d2 3016 DIRS="$DIRS roms/seabios roms/vgabios"
3e230dd2 3017 DIRS="$DIRS fsdev ui"
7d13299d 3018 FILES="Makefile tests/Makefile"
e7daa605 3019 FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
e1ffb0f1 3020 FILES="$FILES tests/test-mmap.c"
7ea78b74 3021 FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps pc-bios/video.x"
2d9f27d2 3022 FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
7ea78b74
JK
3023 for bios_file in $source_path/pc-bios/*.bin $source_path/pc-bios/*.dtb $source_path/pc-bios/openbios-*; do
3024 FILES="$FILES pc-bios/`basename $bios_file`"
3025 done
7d13299d
FB
3026 for dir in $DIRS ; do
3027 mkdir -p $dir
3028 done
ec530c81 3029 # remove the link and recreate it, as not all "ln -sf" overwrite the link
7d13299d 3030 for f in $FILES ; do
ec530c81
FB
3031 rm -f $f
3032 ln -s $source_path/$f $f
7d13299d
FB
3033 done
3034fi
1ad2134f 3035
c34ebfdc 3036# temporary config to build submodules
2d9f27d2 3037for rom in seabios vgabios ; do
c34ebfdc 3038 config_mak=roms/$rom/config.mak
37116c89 3039 echo "# Automatically generated by configure - do not modify" > $config_mak
c34ebfdc
AL
3040 echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
3041 echo "CC=$cc" >> $config_mak
3042 echo "BCC=bcc" >> $config_mak
3043 echo "CPP=${cross_prefix}cpp" >> $config_mak
3044 echo "OBJCOPY=objcopy" >> $config_mak
3045 echo "IASL=iasl" >> $config_mak
3046 echo "HOST_CC=$host_cc" >> $config_mak
3047 echo "LD=$ld" >> $config_mak
3048done
3049
1ad2134f
PB
3050for hwlib in 32 64; do
3051 d=libhw$hwlib
3052 mkdir -p $d
9953b2fc 3053 mkdir -p $d/ide
1ad2134f
PB
3054 rm -f $d/Makefile
3055 ln -s $source_path/Makefile.hw $d/Makefile
37116c89 3056 echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" > $d/config.mak
1ad2134f 3057done
add16157
BS
3058
3059d=libuser
3060mkdir -p $d
3061rm -f $d/Makefile
3062ln -s $source_path/Makefile.user $d/Makefile
299060a0
KS
3063if test "$static" = "no" -a "$user_pie" = "yes" ; then
3064 echo "QEMU_CFLAGS+=-fpie" > $d/config.mak
3065fi
b40292e7
JK
3066
3067if test "$docs" = "yes" ; then
3068 mkdir -p QMP
3069fi