]> git.proxmox.com Git - qemu.git/blame - configure
Clean up assertion in get_boot_devices_list()
[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
da1d85e3 21rm -f config.log
9ac81bbb 22
52166aa0 23compile_object() {
da1d85e3
GH
24 echo $cc $QEMU_CFLAGS -c -o $TMPO $TMPC >> config.log
25 $cc $QEMU_CFLAGS -c -o $TMPO $TMPC >> config.log 2>&1
52166aa0
JQ
26}
27
28compile_prog() {
29 local_cflags="$1"
30 local_ldflags="$2"
da1d85e3
GH
31 echo $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags >> config.log
32 $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags >> config.log 2>&1
52166aa0
JQ
33}
34
11568d6d
PB
35# symbolically link $1 to $2. Portable version of "ln -sf".
36symlink() {
37 rm -f $2
38 ln -s $1 $2
39}
40
0dba6195
LM
41# check whether a command is available to this shell (may be either an
42# executable or a builtin)
43has() {
44 type "$1" >/dev/null 2>&1
45}
46
47# search for an executable in PATH
48path_of() {
49 local_command="$1"
50 local_ifs="$IFS"
51 local_dir=""
52
53 # pathname has a dir component?
54 if [ "${local_command#*/}" != "$local_command" ]; then
55 if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
56 echo "$local_command"
57 return 0
58 fi
59 fi
60 if [ -z "$local_command" ]; then
61 return 1
62 fi
63
64 IFS=:
65 for local_dir in $PATH; do
66 if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
67 echo "$local_dir/$local_command"
68 IFS="${local_ifs:-$(printf ' \t\n')}"
69 return 0
70 fi
71 done
72 # not found
73 IFS="${local_ifs:-$(printf ' \t\n')}"
74 return 1
75}
76
7d13299d 77# default parameters
ca4deeb1 78source_path=`dirname "$0"`
2ff6b91e 79cpu=""
1e43adfc 80interp_prefix="/usr/gnemul/qemu-%M"
43ce4dfe 81static="no"
ed968ff1 82sparc_cpu=""
7d13299d 83cross_prefix=""
0c58ac1c 84audio_drv_list=""
d61a4ce8
GH
85audio_card_list="ac97 es1370 sb16 hda"
86audio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus hda"
eb852011 87block_drv_whitelist=""
7d13299d 88host_cc="gcc"
c81da56e 89helper_cflags=""
73da375e 90libs_softmmu=""
3e2e0e6b 91libs_tools=""
67f86e8e 92audio_pt_int=""
d5631638 93audio_win_int=""
2b2e59e6 94cc_i386=i386-pc-linux-gnu-gcc
957f1f99 95libs_qga=""
ac0df51d 96
377529c0
PB
97target_list=""
98
99# Default value for a variable defining feature "foo".
100# * foo="no" feature will only be used if --enable-foo arg is given
101# * foo="" feature will be searched for, and if found, will be used
102# unless --disable-foo is given
103# * foo="yes" this value will only be set by --enable-foo flag.
104# feature will searched for,
105# if not found, configure exits with error
106#
107# Always add --enable-foo and --disable-foo command line args.
108# Distributions want to ensure that several features are compiled in, and it
109# is impossible without a --enable-foo that exits if a feature is not found.
110
111bluez=""
112brlapi=""
113curl=""
114curses=""
115docs=""
116fdt=""
377529c0
PB
117nptl=""
118sdl=""
821601ea 119vnc="yes"
377529c0
PB
120sparse="no"
121uuid=""
122vde=""
123vnc_tls=""
124vnc_sasl=""
125vnc_jpeg=""
126vnc_png=""
127vnc_thread="no"
128xen=""
d5b93ddf 129xen_ctrl_version=""
377529c0
PB
130linux_aio=""
131attr=""
377529c0
PB
132xfs=""
133
d41a75a2
B
134vhost_net="no"
135kvm="no"
377529c0
PB
136gprof="no"
137debug_tcg="no"
138debug_mon="no"
139debug="no"
140strip_opt="yes"
9195b2c2 141tcg_interpreter="no"
377529c0
PB
142bigendian="no"
143mingw32="no"
144EXESUF=""
145prefix="/usr/local"
146mandir="\${prefix}/share/man"
147datadir="\${prefix}/share/qemu"
148docdir="\${prefix}/share/doc/qemu"
149bindir="\${prefix}/bin"
3aa5d2be 150libdir="\${prefix}/lib"
0f94d6da 151includedir="\${prefix}/include"
377529c0
PB
152sysconfdir="\${prefix}/etc"
153confsuffix="/qemu"
154slirp="yes"
155fmod_lib=""
156fmod_inc=""
157oss_lib=""
158bsd="no"
159linux="no"
160solaris="no"
161profiler="no"
162cocoa="no"
163softmmu="yes"
164linux_user="no"
165darwin_user="no"
166bsd_user="no"
167guest_base=""
168uname_release=""
377529c0 169mixemu="no"
377529c0
PB
170aix="no"
171blobs="yes"
172pkgversion=""
25b651be 173check_utests=""
377529c0
PB
174user_pie="no"
175zero_malloc=""
176trace_backend="nop"
177trace_file="trace"
178spice=""
179rbd=""
36707144 180smartcard=""
111a38b0 181smartcard_nss=""
69354a83 182usb_redir=""
430a3c18 183opengl=""
1ece9905 184zlib="yes"
d138cee9 185guest_agent="yes"
c589b249 186libiscsi=""
377529c0 187
ac0df51d
AL
188# parse CC options first
189for opt do
190 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
191 case "$opt" in
192 --cross-prefix=*) cross_prefix="$optarg"
193 ;;
3d8df640 194 --cc=*) CC="$optarg"
ac0df51d 195 ;;
ca4deeb1
PB
196 --source-path=*) source_path="$optarg"
197 ;;
2ff6b91e
JQ
198 --cpu=*) cpu="$optarg"
199 ;;
a558ee17 200 --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
e2a2ed06
JQ
201 ;;
202 --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
203 ;;
50e7b1a0
JQ
204 --sparc_cpu=*)
205 sparc_cpu="$optarg"
206 case $sparc_cpu in
ed968ff1 207 v7|v8|v8plus|v8plusa)
50e7b1a0
JQ
208 cpu="sparc"
209 ;;
210 v9)
50e7b1a0
JQ
211 cpu="sparc64"
212 ;;
213 *)
214 echo "undefined SPARC architecture. Exiting";
215 exit 1
216 ;;
217 esac
218 ;;
ac0df51d
AL
219 esac
220done
ac0df51d
AL
221# OS specific
222# Using uname is really, really broken. Once we have the right set of checks
223# we can eliminate it's usage altogether
224
b3198cc2
SY
225cc="${CC-${cross_prefix}gcc}"
226ar="${AR-${cross_prefix}ar}"
227objcopy="${OBJCOPY-${cross_prefix}objcopy}"
228ld="${LD-${cross_prefix}ld}"
3f534581 229libtool="${LIBTOOL-${cross_prefix}libtool}"
b3198cc2
SY
230strip="${STRIP-${cross_prefix}strip}"
231windres="${WINDRES-${cross_prefix}windres}"
232pkg_config="${PKG_CONFIG-${cross_prefix}pkg-config}"
233sdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
ac0df51d 234
be17dc90
MT
235# default flags for all hosts
236QEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
237CFLAGS="-g $CFLAGS"
f9188227 238QEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
be17dc90
MT
239QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
240QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
84958305 241QEMU_CFLAGS="-D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
cbbab922 242QEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/fpu"
be17dc90
MT
243LDFLAGS="-g $LDFLAGS"
244
ca4deeb1
PB
245# make source path absolute
246source_path=`cd "$source_path"; pwd`
247
ac0df51d
AL
248check_define() {
249cat > $TMPC <<EOF
250#if !defined($1)
251#error Not defined
252#endif
253int main(void) { return 0; }
254EOF
52166aa0 255 compile_object
ac0df51d
AL
256}
257
2ff6b91e
JQ
258if test ! -z "$cpu" ; then
259 # command line argument
260 :
261elif check_define __i386__ ; then
ac0df51d
AL
262 cpu="i386"
263elif check_define __x86_64__ ; then
264 cpu="x86_64"
3aa9bd6c
BS
265elif check_define __sparc__ ; then
266 # We can't check for 64 bit (when gcc is biarch) or V8PLUSA
267 # They must be specified using --sparc_cpu
268 if check_define __arch64__ ; then
269 cpu="sparc64"
270 else
271 cpu="sparc"
272 fi
fdf7ed96 273elif check_define _ARCH_PPC ; then
274 if check_define _ARCH_PPC64 ; then
275 cpu="ppc64"
276 else
277 cpu="ppc"
278 fi
afa05235
AJ
279elif check_define __mips__ ; then
280 cpu="mips"
477ba620
AJ
281elif check_define __ia64__ ; then
282 cpu="ia64"
d66ed0ea
AJ
283elif check_define __s390__ ; then
284 if check_define __s390x__ ; then
285 cpu="s390x"
286 else
287 cpu="s390"
288 fi
f28ffed5
B
289elif check_define __ARMEB__ ; then
290 cpu="armv4b"
291elif check_define __ARMEL__ ; then
292 cpu="armv4l"
293elif check_define __hppa__ ; then
294 cpu="hppa"
ac0df51d 295else
fdf7ed96 296 cpu=`uname -m`
ac0df51d
AL
297fi
298
7d13299d 299case "$cpu" in
d2fbca94 300 alpha|cris|ia64|lm32|m68k|microblaze|ppc|ppc64|sparc64|unicore32)
ea8f20f8
JQ
301 cpu="$cpu"
302 ;;
7d13299d 303 i386|i486|i586|i686|i86pc|BePC)
97a847bc 304 cpu="i386"
7d13299d 305 ;;
aaa5fa14
AJ
306 x86_64|amd64)
307 cpu="x86_64"
308 ;;
ba68055e 309 armv*b)
808c4954
FB
310 cpu="armv4b"
311 ;;
ba68055e 312 armv*l)
7d13299d
FB
313 cpu="armv4l"
314 ;;
f28ffed5 315 hppa|parisc|parisc64)
f54b3f92
AJ
316 cpu="hppa"
317 ;;
afa05235
AJ
318 mips*)
319 cpu="mips"
320 ;;
24e804ec 321 s390)
fb3e5849
FB
322 cpu="s390"
323 ;;
24e804ec
AG
324 s390x)
325 cpu="s390x"
326 ;;
3142255c 327 sparc|sun4[cdmuv])
ae228531
FB
328 cpu="sparc"
329 ;;
7d13299d 330 *)
a447d4dc
PB
331 echo "Unsupported CPU = $cpu"
332 exit 1
7d13299d
FB
333 ;;
334esac
e2d52ad3 335
7d13299d 336# OS specific
ac0df51d
AL
337if check_define __linux__ ; then
338 targetos="Linux"
339elif check_define _WIN32 ; then
340 targetos='MINGW32'
169dc5d3
BS
341elif check_define __OpenBSD__ ; then
342 targetos='OpenBSD'
343elif check_define __sun__ ; then
344 targetos='SunOS'
179cf400
AF
345elif check_define __HAIKU__ ; then
346 targetos='Haiku'
ac0df51d
AL
347else
348 targetos=`uname -s`
349fi
0dbfc675 350
7d13299d 351case $targetos in
c326e0af 352CYGWIN*)
0dbfc675 353 mingw32="yes"
a558ee17 354 QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
d5631638 355 audio_possible_drivers="winwave sdl"
356 audio_drv_list="winwave"
c326e0af 357;;
67b915a5 358MINGW32*)
0dbfc675 359 mingw32="yes"
d5631638 360 audio_possible_drivers="winwave dsound sdl fmod"
361 audio_drv_list="winwave"
67b915a5 362;;
5c40d2bd 363GNU/kFreeBSD)
a167ba50 364 bsd="yes"
0dbfc675
JQ
365 audio_drv_list="oss"
366 audio_possible_drivers="oss sdl esd pa"
5c40d2bd 367;;
7d3505c5 368FreeBSD)
0dbfc675 369 bsd="yes"
0db4a067 370 make="${MAKE-gmake}"
0dbfc675
JQ
371 audio_drv_list="oss"
372 audio_possible_drivers="oss sdl esd pa"
f01576f1
JL
373 # needed for kinfo_getvmmap(3) in libutil.h
374 LIBS="-lutil $LIBS"
7d3505c5 375;;
c5e97233 376DragonFly)
0dbfc675 377 bsd="yes"
0db4a067 378 make="${MAKE-gmake}"
0dbfc675
JQ
379 audio_drv_list="oss"
380 audio_possible_drivers="oss sdl esd pa"
c5e97233 381;;
7d3505c5 382NetBSD)
0dbfc675 383 bsd="yes"
0db4a067 384 make="${MAKE-gmake}"
0dbfc675
JQ
385 audio_drv_list="oss"
386 audio_possible_drivers="oss sdl esd"
387 oss_lib="-lossaudio"
7d3505c5
FB
388;;
389OpenBSD)
0dbfc675 390 bsd="yes"
0db4a067 391 make="${MAKE-gmake}"
0dbfc675
JQ
392 audio_drv_list="oss"
393 audio_possible_drivers="oss sdl esd"
394 oss_lib="-lossaudio"
7d3505c5 395;;
83fb7adf 396Darwin)
0dbfc675
JQ
397 bsd="yes"
398 darwin="yes"
399 # on Leopard most of the system is 32-bit, so we have to ask the kernel it if we can
400 # run 64-bit userspace code
401 if [ "$cpu" = "i386" ] ; then
aab8588a 402 is_x86_64=`sysctl -n hw.optional.x86_64`
403 [ "$is_x86_64" = "1" ] && cpu=x86_64
0dbfc675
JQ
404 fi
405 if [ "$cpu" = "x86_64" ] ; then
a558ee17 406 QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
0c439cbf 407 LDFLAGS="-arch x86_64 $LDFLAGS"
0dbfc675 408 else
a558ee17 409 QEMU_CFLAGS="-mdynamic-no-pic $QEMU_CFLAGS"
0dbfc675
JQ
410 fi
411 darwin_user="yes"
412 cocoa="yes"
413 audio_drv_list="coreaudio"
414 audio_possible_drivers="coreaudio sdl fmod"
415 LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
7973f21c 416 libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
83fb7adf 417;;
ec530c81 418SunOS)
0dbfc675 419 solaris="yes"
0db4a067
PB
420 make="${MAKE-gmake}"
421 install="${INSTALL-ginstall}"
fa58948d 422 ld="gld"
e2d8830e 423 smbd="${SMBD-/usr/sfw/sbin/smbd}"
0dbfc675
JQ
424 needs_libsunmath="no"
425 solarisrev=`uname -r | cut -f2 -d.`
426 # have to select again, because `uname -m` returns i86pc
427 # even on an x86_64 box.
428 solariscpu=`isainfo -k`
429 if test "${solariscpu}" = "amd64" ; then
430 cpu="x86_64"
431 fi
432 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
433 if test "$solarisrev" -le 9 ; then
434 if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
435 needs_libsunmath="yes"
f14bfdf9
JQ
436 QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
437 LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
438 LIBS="-lsunmath $LIBS"
0dbfc675
JQ
439 else
440 echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
441 echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
442 echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
443 echo "Studio 11 can be downloaded from www.sun.com."
444 exit 1
445 fi
86b2bd93 446 fi
0dbfc675
JQ
447 fi
448 if test -f /usr/include/sys/soundcard.h ; then
449 audio_drv_list="oss"
450 fi
451 audio_possible_drivers="oss sdl"
d741429a
BS
452# needed for CMSG_ macros in sys/socket.h
453 QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
454# needed for TIOCWIN* defines in termios.h
455 QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
a558ee17 456 QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
e174c0bb 457 LIBS="-lsocket -lnsl -lresolv $LIBS"
86b2bd93 458;;
b29fe3ed 459AIX)
0dbfc675 460 aix="yes"
0db4a067 461 make="${MAKE-gmake}"
b29fe3ed 462;;
179cf400
AF
463Haiku)
464 haiku="yes"
465 QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
466 LIBS="-lposix_error_mapper -lnetwork $LIBS"
467;;
1d14ffa9 468*)
0dbfc675
JQ
469 audio_drv_list="oss"
470 audio_possible_drivers="oss alsa sdl esd pa"
471 linux="yes"
472 linux_user="yes"
473 usb="linux"
af2be207
JK
474 kvm="yes"
475 vhost_net="yes"
0dbfc675 476 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
c2de5c91 477 audio_possible_drivers="$audio_possible_drivers fmod"
0dbfc675 478 fi
fb065187 479;;
7d13299d
FB
480esac
481
7d3505c5 482if [ "$bsd" = "yes" ] ; then
b1a550a0 483 if [ "$darwin" != "yes" ] ; then
68063649 484 usb="bsd"
83fb7adf 485 fi
84778508 486 bsd_user="yes"
7d3505c5
FB
487fi
488
0db4a067
PB
489: ${make=${MAKE-make}}
490: ${install=${INSTALL-install}}
c886edfb 491: ${python=${PYTHON-python}}
e2d8830e 492: ${smbd=${SMBD-/usr/sbin/smbd}}
0db4a067 493
3457a3f8 494if test "$mingw32" = "yes" ; then
3457a3f8 495 EXESUF=".exe"
a558ee17 496 QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
e94a7936
SW
497 # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
498 QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
08f3896a 499 LIBS="-lwinmm -lws2_32 -liberty -liphlpapi $LIBS"
683035de
PB
500 prefix="c:/Program Files/Qemu"
501 mandir="\${prefix}"
502 datadir="\${prefix}"
503 docdir="\${prefix}"
504 bindir="\${prefix}"
505 sysconfdir="\${prefix}"
506 confsuffix=""
83b2f0a0 507 guest_agent="no"
3457a3f8
JQ
508fi
509
487fefdb 510werror=""
85aa5189 511
7d13299d 512for opt do
a46e4035 513 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
7d13299d 514 case "$opt" in
2efc3265
FB
515 --help|-h) show_help=yes
516 ;;
99123e13
MF
517 --version|-V) exec cat $source_path/VERSION
518 ;;
b1a550a0 519 --prefix=*) prefix="$optarg"
7d13299d 520 ;;
b1a550a0 521 --interp-prefix=*) interp_prefix="$optarg"
32ce6337 522 ;;
ca4deeb1 523 --source-path=*)
7d13299d 524 ;;
ac0df51d 525 --cross-prefix=*)
7d13299d 526 ;;
ac0df51d 527 --cc=*)
7d13299d 528 ;;
b1a550a0 529 --host-cc=*) host_cc="$optarg"
83469015 530 ;;
b1a550a0 531 --make=*) make="$optarg"
7d13299d 532 ;;
6a882643
PB
533 --install=*) install="$optarg"
534 ;;
c886edfb
BS
535 --python=*) python="$optarg"
536 ;;
e2d8830e
B
537 --smbd=*) smbd="$optarg"
538 ;;
e2a2ed06 539 --extra-cflags=*)
7d13299d 540 ;;
e2a2ed06 541 --extra-ldflags=*)
7d13299d 542 ;;
2ff6b91e 543 --cpu=*)
7d13299d 544 ;;
b1a550a0 545 --target-list=*) target_list="$optarg"
de83cd02 546 ;;
74242e0f 547 --enable-trace-backend=*) trace_backend="$optarg"
94a420b1 548 ;;
74242e0f 549 --with-trace-file=*) trace_file="$optarg"
9410b56c 550 ;;
7d13299d
FB
551 --enable-gprof) gprof="yes"
552 ;;
79427693
LM
553 --static)
554 static="yes"
555 LDFLAGS="-static $LDFLAGS"
43ce4dfe 556 ;;
0b24e75f
PB
557 --mandir=*) mandir="$optarg"
558 ;;
559 --bindir=*) bindir="$optarg"
560 ;;
3aa5d2be
AL
561 --libdir=*) libdir="$optarg"
562 ;;
0f94d6da
AL
563 --includedir=*) includedir="$optarg"
564 ;;
0b24e75f
PB
565 --datadir=*) datadir="$optarg"
566 ;;
567 --docdir=*) docdir="$optarg"
568 ;;
ca2fb938 569 --sysconfdir=*) sysconfdir="$optarg"
07381cc1 570 ;;
97a847bc
FB
571 --disable-sdl) sdl="no"
572 ;;
c4198157
JQ
573 --enable-sdl) sdl="yes"
574 ;;
821601ea
JS
575 --disable-vnc) vnc="no"
576 ;;
577 --enable-vnc) vnc="yes"
578 ;;
0c58ac1c 579 --fmod-lib=*) fmod_lib="$optarg"
1d14ffa9 580 ;;
c2de5c91 581 --fmod-inc=*) fmod_inc="$optarg"
582 ;;
2f6a1ab0
BS
583 --oss-lib=*) oss_lib="$optarg"
584 ;;
2fa7d3bf 585 --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
102a52e4 586 ;;
0c58ac1c 587 --audio-drv-list=*) audio_drv_list="$optarg"
102a52e4 588 ;;
eb852011
MA
589 --block-drv-whitelist=*) block_drv_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
590 ;;
f8393946
AJ
591 --enable-debug-tcg) debug_tcg="yes"
592 ;;
593 --disable-debug-tcg) debug_tcg="no"
594 ;;
b4475aa2
LC
595 --enable-debug-mon) debug_mon="yes"
596 ;;
597 --disable-debug-mon) debug_mon="no"
598 ;;
f3d08ee6
PB
599 --enable-debug)
600 # Enable debugging options that aren't excessively noisy
601 debug_tcg="yes"
b4475aa2 602 debug_mon="yes"
f3d08ee6
PB
603 debug="yes"
604 strip_opt="no"
605 ;;
03b4fe7d
AL
606 --enable-sparse) sparse="yes"
607 ;;
608 --disable-sparse) sparse="no"
609 ;;
1625af87
AL
610 --disable-strip) strip_opt="no"
611 ;;
8d5d2d4c
TS
612 --disable-vnc-tls) vnc_tls="no"
613 ;;
1be10ad2
JQ
614 --enable-vnc-tls) vnc_tls="yes"
615 ;;
2f9606b3
AL
616 --disable-vnc-sasl) vnc_sasl="no"
617 ;;
ea784e3b
JQ
618 --enable-vnc-sasl) vnc_sasl="yes"
619 ;;
2f6f5c7a
CC
620 --disable-vnc-jpeg) vnc_jpeg="no"
621 ;;
622 --enable-vnc-jpeg) vnc_jpeg="yes"
623 ;;
efe556ad
CC
624 --disable-vnc-png) vnc_png="no"
625 ;;
626 --enable-vnc-png) vnc_png="yes"
627 ;;
bd023f95
CC
628 --disable-vnc-thread) vnc_thread="no"
629 ;;
630 --enable-vnc-thread) vnc_thread="yes"
631 ;;
443f1376 632 --disable-slirp) slirp="no"
1d14ffa9 633 ;;
ee682d27
SW
634 --disable-uuid) uuid="no"
635 ;;
636 --enable-uuid) uuid="yes"
637 ;;
e0e6c8c0 638 --disable-vde) vde="no"
8a16d273 639 ;;
dfb278bd
JQ
640 --enable-vde) vde="yes"
641 ;;
e37630ca
AL
642 --disable-xen) xen="no"
643 ;;
fc321b4b
JQ
644 --enable-xen) xen="yes"
645 ;;
2e4d9fb1
AJ
646 --disable-brlapi) brlapi="no"
647 ;;
4ffcedb6
JQ
648 --enable-brlapi) brlapi="yes"
649 ;;
fb599c9a
AZ
650 --disable-bluez) bluez="no"
651 ;;
a20a6f46
JQ
652 --enable-bluez) bluez="yes"
653 ;;
7ba1e619
AL
654 --disable-kvm) kvm="no"
655 ;;
b31a0277
JQ
656 --enable-kvm) kvm="yes"
657 ;;
9195b2c2
SW
658 --disable-tcg-interpreter) tcg_interpreter="no"
659 ;;
660 --enable-tcg-interpreter) tcg_interpreter="yes"
661 ;;
cd4ec0b4
GH
662 --disable-spice) spice="no"
663 ;;
664 --enable-spice) spice="yes"
665 ;;
c589b249
RS
666 --disable-libiscsi) libiscsi="no"
667 ;;
668 --enable-libiscsi) libiscsi="yes"
669 ;;
05c2a3e7
FB
670 --enable-profiler) profiler="yes"
671 ;;
c2de5c91 672 --enable-cocoa)
673 cocoa="yes" ;
674 sdl="no" ;
675 audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
1d14ffa9 676 ;;
cad25d69 677 --disable-system) softmmu="no"
0a8e90f4 678 ;;
cad25d69 679 --enable-system) softmmu="yes"
0a8e90f4 680 ;;
0953a80f
ZA
681 --disable-user)
682 linux_user="no" ;
683 bsd_user="no" ;
684 darwin_user="no"
685 ;;
686 --enable-user) ;;
831b7825 687 --disable-linux-user) linux_user="no"
0a8e90f4 688 ;;
831b7825
TS
689 --enable-linux-user) linux_user="yes"
690 ;;
691 --disable-darwin-user) darwin_user="no"
692 ;;
693 --enable-darwin-user) darwin_user="yes"
0a8e90f4 694 ;;
84778508
BS
695 --disable-bsd-user) bsd_user="no"
696 ;;
697 --enable-bsd-user) bsd_user="yes"
698 ;;
379f6698
PB
699 --enable-guest-base) guest_base="yes"
700 ;;
701 --disable-guest-base) guest_base="no"
702 ;;
34005a00
KS
703 --enable-user-pie) user_pie="yes"
704 ;;
705 --disable-user-pie) user_pie="no"
706 ;;
c5937220
PB
707 --enable-uname-release=*) uname_release="$optarg"
708 ;;
3142255c 709 --sparc_cpu=*)
3142255c 710 ;;
85aa5189
FB
711 --enable-werror) werror="yes"
712 ;;
713 --disable-werror) werror="no"
714 ;;
4d3b6f6e
AZ
715 --disable-curses) curses="no"
716 ;;
c584a6d0
JQ
717 --enable-curses) curses="yes"
718 ;;
769ce76d
AG
719 --disable-curl) curl="no"
720 ;;
788c8196
JQ
721 --enable-curl) curl="yes"
722 ;;
2df87df7
JQ
723 --disable-fdt) fdt="no"
724 ;;
725 --enable-fdt) fdt="yes"
726 ;;
5495ed11
LC
727 --disable-check-utests) check_utests="no"
728 ;;
729 --enable-check-utests) check_utests="yes"
730 ;;
bd0c5661
PB
731 --disable-nptl) nptl="no"
732 ;;
b0a47e79
JQ
733 --enable-nptl) nptl="yes"
734 ;;
8ff9cbf7 735 --enable-mixemu) mixemu="yes"
736 ;;
5c6c3a6c
CH
737 --disable-linux-aio) linux_aio="no"
738 ;;
739 --enable-linux-aio) linux_aio="yes"
740 ;;
758e8e38
VJJ
741 --disable-attr) attr="no"
742 ;;
743 --enable-attr) attr="yes"
744 ;;
77755340
TS
745 --disable-blobs) blobs="no"
746 ;;
4a19f1ec
PB
747 --with-pkgversion=*) pkgversion=" ($optarg)"
748 ;;
a25dba17 749 --disable-docs) docs="no"
70ec5dc0 750 ;;
a25dba17 751 --enable-docs) docs="yes"
83a3ab8b 752 ;;
d5970055
MT
753 --disable-vhost-net) vhost_net="no"
754 ;;
755 --enable-vhost-net) vhost_net="yes"
756 ;;
20ff075b
MW
757 --disable-opengl) opengl="no"
758 ;;
759 --enable-opengl) opengl="yes"
760 ;;
6bde81cb
PB
761 --*dir)
762 ;;
f27aaf4b
CB
763 --disable-rbd) rbd="no"
764 ;;
765 --enable-rbd) rbd="yes"
766 ;;
36707144
AL
767 --disable-smartcard) smartcard="no"
768 ;;
769 --enable-smartcard) smartcard="yes"
770 ;;
111a38b0
RR
771 --disable-smartcard-nss) smartcard_nss="no"
772 ;;
773 --enable-smartcard-nss) smartcard_nss="yes"
774 ;;
69354a83
HG
775 --disable-usb-redir) usb_redir="no"
776 ;;
777 --enable-usb-redir) usb_redir="yes"
778 ;;
1ece9905
AL
779 --disable-zlib-test) zlib="no"
780 ;;
d138cee9
MR
781 --enable-guest-agent) guest_agent="yes"
782 ;;
783 --disable-guest-agent) guest_agent="no"
784 ;;
7f1559c6
AZ
785 *) echo "ERROR: unknown option $opt"; show_help="yes"
786 ;;
7d13299d
FB
787 esac
788done
789
3142255c
BS
790#
791# If cpu ~= sparc and sparc_cpu hasn't been defined, plug in the right
a558ee17 792# QEMU_CFLAGS/LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
3142255c 793#
379f6698 794host_guest_base="no"
40293e58 795case "$cpu" in
ed968ff1
JQ
796 sparc) case $sparc_cpu in
797 v7|v8)
a558ee17 798 QEMU_CFLAGS="-mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
ed968ff1
JQ
799 ;;
800 v8plus|v8plusa)
a558ee17 801 QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
ed968ff1
JQ
802 ;;
803 *) # sparc_cpu not defined in the command line
a558ee17 804 QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_v8plus__ $QEMU_CFLAGS"
ed968ff1
JQ
805 esac
806 LDFLAGS="-m32 $LDFLAGS"
a558ee17 807 QEMU_CFLAGS="-m32 -ffixed-g2 -ffixed-g3 $QEMU_CFLAGS"
762e8230 808 if test "$solaris" = "no" ; then
a558ee17 809 QEMU_CFLAGS="-ffixed-g1 -ffixed-g6 $QEMU_CFLAGS"
c81da56e 810 helper_cflags="-ffixed-i0"
762e8230 811 fi
3142255c 812 ;;
ed968ff1 813 sparc64)
a558ee17 814 QEMU_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__ $QEMU_CFLAGS"
ed968ff1 815 LDFLAGS="-m64 $LDFLAGS"
a558ee17 816 QEMU_CFLAGS="-ffixed-g5 -ffixed-g6 -ffixed-g7 $QEMU_CFLAGS"
ed968ff1 817 if test "$solaris" != "no" ; then
a558ee17 818 QEMU_CFLAGS="-ffixed-g1 $QEMU_CFLAGS"
762e8230 819 fi
3142255c 820 ;;
76d83bde 821 s390)
28d7cc49
RH
822 QEMU_CFLAGS="-m31 -march=z990 $QEMU_CFLAGS"
823 LDFLAGS="-m31 $LDFLAGS"
48bb3750 824 host_guest_base="yes"
28d7cc49
RH
825 ;;
826 s390x)
827 QEMU_CFLAGS="-m64 -march=z990 $QEMU_CFLAGS"
828 LDFLAGS="-m64 $LDFLAGS"
48bb3750 829 host_guest_base="yes"
76d83bde 830 ;;
40293e58 831 i386)
a558ee17 832 QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
0c439cbf 833 LDFLAGS="-m32 $LDFLAGS"
2b2e59e6 834 cc_i386='$(CC) -m32'
c81da56e 835 helper_cflags="-fomit-frame-pointer"
379f6698 836 host_guest_base="yes"
40293e58
FB
837 ;;
838 x86_64)
a558ee17 839 QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
0c439cbf 840 LDFLAGS="-m64 $LDFLAGS"
2b2e59e6 841 cc_i386='$(CC) -m32'
379f6698
PB
842 host_guest_base="yes"
843 ;;
844 arm*)
845 host_guest_base="yes"
40293e58 846 ;;
f6548c0a 847 ppc*)
848 host_guest_base="yes"
849 ;;
cc01cc8e
AJ
850 mips*)
851 host_guest_base="yes"
852 ;;
477ba620
AJ
853 ia64*)
854 host_guest_base="yes"
855 ;;
fd76e73a
RH
856 hppa*)
857 host_guest_base="yes"
858 ;;
d2fbca94
GX
859 unicore32*)
860 host_guest_base="yes"
861 ;;
3142255c
BS
862esac
863
379f6698
PB
864[ -z "$guest_base" ] && guest_base="$host_guest_base"
865
60e0df25
PM
866
867default_target_list=""
868
869# these targets are portable
870if [ "$softmmu" = "yes" ] ; then
871 default_target_list="\
872i386-softmmu \
873x86_64-softmmu \
27cdad67 874alpha-softmmu \
60e0df25
PM
875arm-softmmu \
876cris-softmmu \
877lm32-softmmu \
878m68k-softmmu \
879microblaze-softmmu \
880microblazeel-softmmu \
881mips-softmmu \
882mipsel-softmmu \
883mips64-softmmu \
884mips64el-softmmu \
885ppc-softmmu \
886ppcemb-softmmu \
887ppc64-softmmu \
888sh4-softmmu \
889sh4eb-softmmu \
890sparc-softmmu \
891sparc64-softmmu \
0f3301d4 892s390x-softmmu \
cfa550c6
MF
893xtensa-softmmu \
894xtensaeb-softmmu \
60e0df25
PM
895"
896fi
897# the following are Linux specific
898if [ "$linux_user" = "yes" ] ; then
899 default_target_list="${default_target_list}\
900i386-linux-user \
901x86_64-linux-user \
902alpha-linux-user \
903arm-linux-user \
904armeb-linux-user \
905cris-linux-user \
906m68k-linux-user \
907microblaze-linux-user \
908microblazeel-linux-user \
909mips-linux-user \
910mipsel-linux-user \
911ppc-linux-user \
912ppc64-linux-user \
913ppc64abi32-linux-user \
914sh4-linux-user \
915sh4eb-linux-user \
916sparc-linux-user \
917sparc64-linux-user \
918sparc32plus-linux-user \
919unicore32-linux-user \
0f3301d4 920s390x-linux-user \
60e0df25
PM
921"
922fi
923# the following are Darwin specific
924if [ "$darwin_user" = "yes" ] ; then
925 default_target_list="$default_target_list i386-darwin-user ppc-darwin-user "
926fi
927# the following are BSD specific
928if [ "$bsd_user" = "yes" ] ; then
929 default_target_list="${default_target_list}\
930i386-bsd-user \
931x86_64-bsd-user \
932sparc-bsd-user \
933sparc64-bsd-user \
934"
935fi
936
af5db58e
PB
937if test x"$show_help" = x"yes" ; then
938cat << EOF
939
940Usage: configure [options]
941Options: [defaults in brackets after descriptions]
942
943EOF
944echo "Standard options:"
945echo " --help print this message"
946echo " --prefix=PREFIX install in PREFIX [$prefix]"
947echo " --interp-prefix=PREFIX where to find shared libraries, etc."
948echo " use %M for cpu name [$interp_prefix]"
60e0df25
PM
949echo " --target-list=LIST set target list (default: build everything)"
950echo "Available targets: $default_target_list" | \
951 fold -s -w 53 | sed -e 's/^/ /'
af5db58e 952echo ""
af5db58e
PB
953echo "Advanced options (experts only):"
954echo " --source-path=PATH path of source code [$source_path]"
955echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
956echo " --cc=CC use C compiler CC [$cc]"
0bfe8cc0
PB
957echo " --host-cc=CC use C compiler CC [$host_cc] for code run at"
958echo " build time"
a558ee17 959echo " --extra-cflags=CFLAGS append extra C compiler flags QEMU_CFLAGS"
e3fc14c3 960echo " --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS"
af5db58e 961echo " --make=MAKE use specified make [$make]"
6a882643 962echo " --install=INSTALL use specified install [$install]"
c886edfb 963echo " --python=PYTHON use specified python [$python]"
e2d8830e 964echo " --smbd=SMBD use specified smbd [$smbd]"
af5db58e 965echo " --static enable static build [$static]"
0b24e75f
PB
966echo " --mandir=PATH install man pages in PATH"
967echo " --datadir=PATH install firmware in PATH"
968echo " --docdir=PATH install documentation in PATH"
969echo " --bindir=PATH install binaries in PATH"
970echo " --sysconfdir=PATH install config in PATH/qemu"
f8393946
AJ
971echo " --enable-debug-tcg enable TCG debugging"
972echo " --disable-debug-tcg disable TCG debugging (default)"
09695a4a 973echo " --enable-debug enable common debug build options"
890b1658
AL
974echo " --enable-sparse enable sparse checker"
975echo " --disable-sparse disable sparse checker (default)"
1625af87 976echo " --disable-strip disable stripping binaries"
85aa5189 977echo " --disable-werror disable compilation abort on warning"
fe8f78e4 978echo " --disable-sdl disable SDL"
c4198157 979echo " --enable-sdl enable SDL"
821601ea
JS
980echo " --disable-vnc disable VNC"
981echo " --enable-vnc enable VNC"
af5db58e 982echo " --enable-cocoa enable COCOA (Mac OS X only)"
c2de5c91 983echo " --audio-drv-list=LIST set audio drivers list:"
984echo " Available drivers: $audio_possible_drivers"
4c9b53e3 985echo " --audio-card-list=LIST set list of emulated audio cards [$audio_card_list]"
986echo " Available cards: $audio_possible_cards"
eb852011
MA
987echo " --block-drv-whitelist=L set block driver whitelist"
988echo " (affects only QEMU, not qemu-img)"
8ff9cbf7 989echo " --enable-mixemu enable mixer emulation"
e37630ca 990echo " --disable-xen disable xen backend driver support"
fc321b4b 991echo " --enable-xen enable xen backend driver support"
2e4d9fb1 992echo " --disable-brlapi disable BrlAPI"
4ffcedb6 993echo " --enable-brlapi enable BrlAPI"
8d5d2d4c 994echo " --disable-vnc-tls disable TLS encryption for VNC server"
1be10ad2 995echo " --enable-vnc-tls enable TLS encryption for VNC server"
2f9606b3 996echo " --disable-vnc-sasl disable SASL encryption for VNC server"
ea784e3b 997echo " --enable-vnc-sasl enable SASL encryption for VNC server"
2f6f5c7a
CC
998echo " --disable-vnc-jpeg disable JPEG lossy compression for VNC server"
999echo " --enable-vnc-jpeg enable JPEG lossy compression for VNC server"
96763cf9 1000echo " --disable-vnc-png disable PNG compression for VNC server (default)"
efe556ad 1001echo " --enable-vnc-png enable PNG compression for VNC server"
bd023f95
CC
1002echo " --disable-vnc-thread disable threaded VNC server"
1003echo " --enable-vnc-thread enable threaded VNC server"
af896aaa 1004echo " --disable-curses disable curses output"
c584a6d0 1005echo " --enable-curses enable curses output"
769ce76d 1006echo " --disable-curl disable curl connectivity"
788c8196 1007echo " --enable-curl enable curl connectivity"
2df87df7
JQ
1008echo " --disable-fdt disable fdt device tree"
1009echo " --enable-fdt enable fdt device tree"
5495ed11
LC
1010echo " --disable-check-utests disable check unit-tests"
1011echo " --enable-check-utests enable check unit-tests"
fb599c9a 1012echo " --disable-bluez disable bluez stack connectivity"
a20a6f46 1013echo " --enable-bluez enable bluez stack connectivity"
6093d3d4 1014echo " --disable-slirp disable SLIRP userspace network connectivity"
7ba1e619 1015echo " --disable-kvm disable KVM acceleration support"
b31a0277 1016echo " --enable-kvm enable KVM acceleration support"
9195b2c2 1017echo " --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)"
bd0c5661 1018echo " --disable-nptl disable usermode NPTL support"
e5934d33 1019echo " --enable-nptl enable usermode NPTL support"
af5db58e
PB
1020echo " --enable-system enable all system emulation targets"
1021echo " --disable-system disable all system emulation targets"
0953a80f
ZA
1022echo " --enable-user enable supported user emulation targets"
1023echo " --disable-user disable all user emulation targets"
831b7825
TS
1024echo " --enable-linux-user enable all linux usermode emulation targets"
1025echo " --disable-linux-user disable all linux usermode emulation targets"
1026echo " --enable-darwin-user enable all darwin usermode emulation targets"
1027echo " --disable-darwin-user disable all darwin usermode emulation targets"
84778508
BS
1028echo " --enable-bsd-user enable all BSD usermode emulation targets"
1029echo " --disable-bsd-user disable all BSD usermode emulation targets"
379f6698
PB
1030echo " --enable-guest-base enable GUEST_BASE support for usermode"
1031echo " emulation targets"
1032echo " --disable-guest-base disable GUEST_BASE support"
34005a00
KS
1033echo " --enable-user-pie build usermode emulation targets as PIE"
1034echo " --disable-user-pie do not build usermode emulation targets as PIE"
af5db58e
PB
1035echo " --fmod-lib path to FMOD library"
1036echo " --fmod-inc path to FMOD includes"
2f6a1ab0 1037echo " --oss-lib path to OSS library"
c5937220 1038echo " --enable-uname-release=R Return R for uname -r in usermode emulation"
3142255c 1039echo " --sparc_cpu=V Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
ee682d27
SW
1040echo " --disable-uuid disable uuid support"
1041echo " --enable-uuid enable uuid support"
e0e6c8c0 1042echo " --disable-vde disable support for vde network"
dfb278bd 1043echo " --enable-vde enable support for vde network"
5c6c3a6c
CH
1044echo " --disable-linux-aio disable Linux AIO support"
1045echo " --enable-linux-aio enable Linux AIO support"
758e8e38
VJJ
1046echo " --disable-attr disables attr and xattr support"
1047echo " --enable-attr enable attr and xattr support"
77755340 1048echo " --disable-blobs disable installing provided firmware blobs"
d2807bc9
DU
1049echo " --enable-docs enable documentation build"
1050echo " --disable-docs disable documentation build"
d5970055
MT
1051echo " --disable-vhost-net disable vhost-net acceleration support"
1052echo " --enable-vhost-net enable vhost-net acceleration support"
320fba2a
FC
1053echo " --enable-trace-backend=B Set trace backend"
1054echo " Available backends:" $("$source_path"/scripts/tracetool --list-backends)
74242e0f 1055echo " --with-trace-file=NAME Full PATH,NAME of file to store traces"
9410b56c 1056echo " Default:trace-<pid>"
cd4ec0b4
GH
1057echo " --disable-spice disable spice"
1058echo " --enable-spice enable spice"
f27aaf4b 1059echo " --enable-rbd enable building the rados block device (rbd)"
c589b249
RS
1060echo " --disable-libiscsi disable iscsi support"
1061echo " --enable-libiscsi enable iscsi support"
36707144
AL
1062echo " --disable-smartcard disable smartcard support"
1063echo " --enable-smartcard enable smartcard support"
111a38b0
RR
1064echo " --disable-smartcard-nss disable smartcard nss support"
1065echo " --enable-smartcard-nss enable smartcard nss support"
69354a83
HG
1066echo " --disable-usb-redir disable usb network redirection support"
1067echo " --enable-usb-redir enable usb network redirection support"
d138cee9
MR
1068echo " --disable-guest-agent disable building of the QEMU Guest Agent"
1069echo " --enable-guest-agent enable building of the QEMU Guest Agent"
af5db58e 1070echo ""
5bf08934 1071echo "NOTE: The object files are built at the place where configure is launched"
af5db58e
PB
1072exit 1
1073fi
1074
8d05095c
PB
1075# check that the C compiler works.
1076cat > $TMPC <<EOF
1077int main(void) {}
1078EOF
1079
1080if compile_object ; then
1081 : C compiler works ok
1082else
1083 echo "ERROR: \"$cc\" either does not exist or does not work"
1084 exit 1
1085fi
1086
1087gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
1088gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
1089gcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
f9188227 1090gcc_flags="-fstack-protector-all -Wendif-labels $gcc_flags"
8d05095c
PB
1091cat > $TMPC << EOF
1092int main(void) { return 0; }
1093EOF
1094for flag in $gcc_flags; do
af2d37de 1095 if compile_prog "$flag -Werror" "" ; then
8d05095c
PB
1096 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1097 fi
1098done
1099
ec530c81
FB
1100#
1101# Solaris specific configure tool chain decisions
1102#
1103if test "$solaris" = "yes" ; then
6792aa11
LM
1104 if has $install; then
1105 :
1106 else
ec530c81
FB
1107 echo "Solaris install program not found. Use --install=/usr/ucb/install or"
1108 echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
1109 echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1110 exit 1
1111 fi
6792aa11 1112 if test "`path_of $install`" = "/usr/sbin/install" ; then
ec530c81
FB
1113 echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
1114 echo "try ginstall from the GNU fileutils available from www.blastwave.org"
1115 echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1116 exit 1
1117 fi
6792aa11
LM
1118 if has ar; then
1119 :
1120 else
ec530c81
FB
1121 echo "Error: No path includes ar"
1122 if test -f /usr/ccs/bin/ar ; then
1123 echo "Add /usr/ccs/bin to your path and rerun configure"
1124 fi
1125 exit 1
1126 fi
5fafdf24 1127fi
ec530c81 1128
d138cee9
MR
1129if test "$guest_agent" != "no" ; then
1130 if has $python; then
1131 :
1132 else
1133 echo "Python not found. Use --python=/path/to/python"
1134 exit 1
1135 fi
c886edfb
BS
1136fi
1137
5327cf48 1138if test -z "$target_list" ; then
60e0df25 1139 target_list="$default_target_list"
6e20a45f 1140else
b1a550a0 1141 target_list=`echo "$target_list" | sed -e 's/,/ /g'`
5327cf48 1142fi
0a8e90f4
PB
1143if test -z "$target_list" ; then
1144 echo "No targets enabled"
1145 exit 1
1146fi
f55fe278
PB
1147# see if system emulation was really requested
1148case " $target_list " in
1149 *"-softmmu "*) softmmu=yes
1150 ;;
1151 *) softmmu=no
1152 ;;
1153esac
5327cf48 1154
249247c9
JQ
1155feature_not_found() {
1156 feature=$1
1157
1158 echo "ERROR"
1159 echo "ERROR: User requested feature $feature"
9332f6a2 1160 echo "ERROR: configure was not able to find it"
249247c9
JQ
1161 echo "ERROR"
1162 exit 1;
1163}
1164
7d13299d
FB
1165if test -z "$cross_prefix" ; then
1166
1167# ---
1168# big/little endian test
1169cat > $TMPC << EOF
1170#include <inttypes.h>
1171int main(int argc, char ** argv){
1d14ffa9
FB
1172 volatile uint32_t i=0x01234567;
1173 return (*((uint8_t*)(&i))) == 0x67;
7d13299d
FB
1174}
1175EOF
1176
52166aa0 1177if compile_prog "" "" ; then
7d13299d
FB
1178$TMPE && bigendian="yes"
1179else
1180echo big/little test failed
1181fi
1182
1183else
1184
1185# if cross compiling, cannot launch a program, so make a static guess
ea8f20f8 1186case "$cpu" in
24e804ec 1187 armv4b|hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
ea8f20f8
JQ
1188 bigendian=yes
1189 ;;
1190esac
7d13299d
FB
1191
1192fi
1193
70be1a2e
PB
1194# host long bits test, actually a pointer size test
1195cat > $TMPC << EOF
1196int sizeof_pointer_is_8[sizeof(void *) == 8 ? 1 : -1];
1197EOF
1198if compile_object; then
1199hostlongbits=64
1200else
1201hostlongbits=32
1202fi
b6853697 1203
b0a47e79
JQ
1204
1205##########################################
1206# NPTL probe
1207
1208if test "$nptl" != "no" ; then
1209 cat > $TMPC <<EOF
bd0c5661 1210#include <sched.h>
30813cea 1211#include <linux/futex.h>
bd0c5661
PB
1212void foo()
1213{
1214#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1215#error bork
1216#endif
1217}
1218EOF
1219
b0a47e79
JQ
1220 if compile_object ; then
1221 nptl=yes
1222 else
1223 if test "$nptl" = "yes" ; then
1224 feature_not_found "nptl"
1225 fi
1226 nptl=no
1227 fi
bd0c5661
PB
1228fi
1229
ac62922e
AZ
1230##########################################
1231# zlib check
1232
1ece9905
AL
1233if test "$zlib" != "no" ; then
1234 cat > $TMPC << EOF
ac62922e
AZ
1235#include <zlib.h>
1236int main(void) { zlibVersion(); return 0; }
1237EOF
1ece9905
AL
1238 if compile_prog "" "-lz" ; then
1239 :
1240 else
1241 echo
1242 echo "Error: zlib check failed"
1243 echo "Make sure to have the zlib libs and headers installed."
1244 echo
1245 exit 1
1246 fi
ac62922e
AZ
1247fi
1248
e37630ca
AL
1249##########################################
1250# xen probe
1251
fc321b4b 1252if test "$xen" != "no" ; then
b2266bee 1253 xen_libs="-lxenstore -lxenctrl -lxenguest"
d5b93ddf
AP
1254
1255 # Xen unstable
b2266bee 1256 cat > $TMPC <<EOF
e37630ca
AL
1257#include <xenctrl.h>
1258#include <xs.h>
d5b93ddf
AP
1259#include <stdint.h>
1260#include <xen/hvm/hvm_info_table.h>
1261#if !defined(HVM_MAX_VCPUS)
1262# error HVM_MAX_VCPUS not defined
1263#endif
1264int main(void) {
1265 xc_interface *xc;
1266 xs_daemon_open();
1267 xc = xc_interface_open(0, 0, 0);
1268 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1269 xc_gnttab_open(NULL, 0);
b87de24e 1270 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
d5b93ddf
AP
1271 return 0;
1272}
e37630ca 1273EOF
52166aa0 1274 if compile_prog "" "$xen_libs" ; then
d5b93ddf 1275 xen_ctrl_version=410
fc321b4b 1276 xen=yes
d5b93ddf
AP
1277
1278 # Xen 4.0.0
1279 elif (
1280 cat > $TMPC <<EOF
1281#include <xenctrl.h>
1282#include <xs.h>
1283#include <stdint.h>
1284#include <xen/hvm/hvm_info_table.h>
1285#if !defined(HVM_MAX_VCPUS)
1286# error HVM_MAX_VCPUS not defined
1287#endif
1288int main(void) {
b87de24e
AP
1289 struct xen_add_to_physmap xatp = {
1290 .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1291 };
d5b93ddf
AP
1292 xs_daemon_open();
1293 xc_interface_open();
1294 xc_gnttab_open();
1295 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
b87de24e 1296 xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
d5b93ddf
AP
1297 return 0;
1298}
1299EOF
1300 compile_prog "" "$xen_libs"
1301 ) ; then
1302 xen_ctrl_version=400
1303 xen=yes
1304
b87de24e
AP
1305 # Xen 3.4.0
1306 elif (
1307 cat > $TMPC <<EOF
1308#include <xenctrl.h>
1309#include <xs.h>
1310int main(void) {
1311 struct xen_add_to_physmap xatp = {
1312 .domid = 0, .space = XENMAPSPACE_gmfn, .idx = 0, .gpfn = 0,
1313 };
1314 xs_daemon_open();
1315 xc_interface_open();
1316 xc_gnttab_open();
1317 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1318 xc_memory_op(0, XENMEM_add_to_physmap, &xatp);
1319 return 0;
1320}
1321EOF
1322 compile_prog "" "$xen_libs"
1323 ) ; then
1324 xen_ctrl_version=340
1325 xen=yes
1326
1327 # Xen 3.3.0
d5b93ddf
AP
1328 elif (
1329 cat > $TMPC <<EOF
1330#include <xenctrl.h>
1331#include <xs.h>
1332int main(void) {
1333 xs_daemon_open();
1334 xc_interface_open();
1335 xc_gnttab_open();
1336 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1337 return 0;
1338}
1339EOF
1340 compile_prog "" "$xen_libs"
1341 ) ; then
1342 xen_ctrl_version=330
1343 xen=yes
1344
1345 # Xen not found or unsupported
b2266bee 1346 else
fc321b4b
JQ
1347 if test "$xen" = "yes" ; then
1348 feature_not_found "xen"
1349 fi
1350 xen=no
b2266bee 1351 fi
d5b93ddf
AP
1352
1353 if test "$xen" = yes; then
1354 libs_softmmu="$xen_libs $libs_softmmu"
1355 fi
e37630ca
AL
1356fi
1357
f91672e5 1358##########################################
a8bd70ad 1359# pkg-config probe
f91672e5 1360
a8bd70ad 1361if ! has $pkg_config; then
a213fcb2
PM
1362 echo "Error: pkg-config binary '$pkg_config' not found"
1363 exit 1
f91672e5
PB
1364fi
1365
44dc0ca3
AL
1366##########################################
1367# libtool probe
1368
3f534581 1369if ! has $libtool; then
44dc0ca3 1370 libtool=
44dc0ca3
AL
1371fi
1372
dfffc653
JQ
1373##########################################
1374# Sparse probe
1375if test "$sparse" != "no" ; then
0dba6195 1376 if has cgcc; then
dfffc653
JQ
1377 sparse=yes
1378 else
1379 if test "$sparse" = "yes" ; then
1380 feature_not_found "sparse"
1381 fi
1382 sparse=no
1383 fi
1384fi
1385
11d9f695
FB
1386##########################################
1387# SDL probe
1388
3ec87ffe
PB
1389# Look for sdl configuration program (pkg-config or sdl-config). Try
1390# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
1391if test "`basename $sdl_config`" != sdl-config && ! has ${sdl_config}; then
1392 sdl_config=sdl-config
1393fi
1394
1395if $pkg_config sdl --modversion >/dev/null 2>&1; then
a8bd70ad 1396 sdlconfig="$pkg_config sdl"
9316f803 1397 _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
3ec87ffe
PB
1398elif has ${sdl_config}; then
1399 sdlconfig="$sdl_config"
9316f803 1400 _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
a0dfd8a4
LM
1401else
1402 if test "$sdl" = "yes" ; then
1403 feature_not_found "sdl"
1404 fi
1405 sdl=no
9316f803 1406fi
29e5bada 1407if test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
3ec87ffe
PB
1408 echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
1409fi
11d9f695 1410
9316f803 1411sdl_too_old=no
c4198157 1412if test "$sdl" != "no" ; then
ac119f9d 1413 cat > $TMPC << EOF
11d9f695
FB
1414#include <SDL.h>
1415#undef main /* We don't want SDL to override our main() */
1416int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
1417EOF
9316f803 1418 sdl_cflags=`$sdlconfig --cflags 2> /dev/null`
74f42e18
T
1419 if test "$static" = "yes" ; then
1420 sdl_libs=`$sdlconfig --static-libs 2>/dev/null`
1421 else
1422 sdl_libs=`$sdlconfig --libs 2> /dev/null`
1423 fi
52166aa0 1424 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
ac119f9d
JQ
1425 if test "$_sdlversion" -lt 121 ; then
1426 sdl_too_old=yes
1427 else
1428 if test "$cocoa" = "no" ; then
1429 sdl=yes
1430 fi
1431 fi
cd01b4a3 1432
67c274d3 1433 # static link with sdl ? (note: sdl.pc's --static --libs is broken)
ac119f9d 1434 if test "$sdl" = "yes" -a "$static" = "yes" ; then
67c274d3 1435 if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
f8aa6c7b
SW
1436 sdl_libs="$sdl_libs `aalib-config --static-libs 2>/dev/null`"
1437 sdl_cflags="$sdl_cflags `aalib-config --cflags 2>/dev/null`"
ac119f9d 1438 fi
52166aa0 1439 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
ac119f9d
JQ
1440 :
1441 else
1442 sdl=no
1443 fi
1444 fi # static link
c4198157
JQ
1445 else # sdl not found
1446 if test "$sdl" = "yes" ; then
1447 feature_not_found "sdl"
1448 fi
1449 sdl=no
ac119f9d 1450 fi # sdl compile test
a68551bc 1451fi
11d9f695 1452
5368a422 1453if test "$sdl" = "yes" ; then
ac119f9d 1454 cat > $TMPC <<EOF
5368a422
AL
1455#include <SDL.h>
1456#if defined(SDL_VIDEO_DRIVER_X11)
1457#include <X11/XKBlib.h>
1458#else
1459#error No x11 support
1460#endif
1461int main(void) { return 0; }
1462EOF
52166aa0 1463 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
ac119f9d
JQ
1464 sdl_libs="$sdl_libs -lX11"
1465 fi
07d9ac44
JQ
1466 if test "$mingw32" = "yes" ; then
1467 sdl_libs="`echo $sdl_libs | sed s/-mwindows//g` -mconsole"
1468 fi
0705667e 1469 libs_softmmu="$sdl_libs $libs_softmmu"
5368a422
AL
1470fi
1471
8d5d2d4c
TS
1472##########################################
1473# VNC TLS detection
821601ea 1474if test "$vnc" = "yes" -a "$vnc_tls" != "no" ; then
1be10ad2 1475 cat > $TMPC <<EOF
ae6b5e5a
AL
1476#include <gnutls/gnutls.h>
1477int main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
1478EOF
a8bd70ad
PB
1479 vnc_tls_cflags=`$pkg_config --cflags gnutls 2> /dev/null`
1480 vnc_tls_libs=`$pkg_config --libs gnutls 2> /dev/null`
1be10ad2
JQ
1481 if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
1482 vnc_tls=yes
1483 libs_softmmu="$vnc_tls_libs $libs_softmmu"
1484 else
1485 if test "$vnc_tls" = "yes" ; then
1486 feature_not_found "vnc-tls"
ae6b5e5a 1487 fi
1be10ad2
JQ
1488 vnc_tls=no
1489 fi
8d5d2d4c
TS
1490fi
1491
2f9606b3
AL
1492##########################################
1493# VNC SASL detection
821601ea 1494if test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
ea784e3b 1495 cat > $TMPC <<EOF
2f9606b3
AL
1496#include <sasl/sasl.h>
1497#include <stdio.h>
1498int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
1499EOF
ea784e3b
JQ
1500 # Assuming Cyrus-SASL installed in /usr prefix
1501 vnc_sasl_cflags=""
1502 vnc_sasl_libs="-lsasl2"
1503 if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1504 vnc_sasl=yes
1505 libs_softmmu="$vnc_sasl_libs $libs_softmmu"
1506 else
1507 if test "$vnc_sasl" = "yes" ; then
1508 feature_not_found "vnc-sasl"
2f9606b3 1509 fi
ea784e3b
JQ
1510 vnc_sasl=no
1511 fi
2f9606b3
AL
1512fi
1513
2f6f5c7a
CC
1514##########################################
1515# VNC JPEG detection
821601ea 1516if test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
2f6f5c7a
CC
1517cat > $TMPC <<EOF
1518#include <stdio.h>
1519#include <jpeglib.h>
1520int main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
1521EOF
1522 vnc_jpeg_cflags=""
1523 vnc_jpeg_libs="-ljpeg"
1524 if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
1525 vnc_jpeg=yes
1526 libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
1527 else
1528 if test "$vnc_jpeg" = "yes" ; then
1529 feature_not_found "vnc-jpeg"
1530 fi
1531 vnc_jpeg=no
1532 fi
1533fi
1534
efe556ad
CC
1535##########################################
1536# VNC PNG detection
821601ea 1537if test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
efe556ad
CC
1538cat > $TMPC <<EOF
1539//#include <stdio.h>
1540#include <png.h>
832ce9c2 1541#include <stddef.h>
efe556ad
CC
1542int main(void) {
1543 png_structp png_ptr;
1544 png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
1545 return 0;
1546}
1547EOF
9af8025e
B
1548 if $pkg_config libpng --modversion >/dev/null 2>&1; then
1549 vnc_png_cflags=`$pkg_config libpng --cflags 2> /dev/null`
1550 vnc_png_libs=`$pkg_config libpng --libs 2> /dev/null`
1551 else
efe556ad
CC
1552 vnc_png_cflags=""
1553 vnc_png_libs="-lpng"
9af8025e 1554 fi
efe556ad
CC
1555 if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
1556 vnc_png=yes
1557 libs_softmmu="$vnc_png_libs $libs_softmmu"
9af8025e 1558 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
efe556ad
CC
1559 else
1560 if test "$vnc_png" = "yes" ; then
1561 feature_not_found "vnc-png"
1562 fi
1563 vnc_png=no
1564 fi
1565fi
1566
76655d6d
AL
1567##########################################
1568# fnmatch() probe, used for ACL routines
1569fnmatch="no"
1570cat > $TMPC << EOF
1571#include <fnmatch.h>
1572int main(void)
1573{
1574 fnmatch("foo", "foo", 0);
1575 return 0;
1576}
1577EOF
52166aa0 1578if compile_prog "" "" ; then
76655d6d
AL
1579 fnmatch="yes"
1580fi
1581
ee682d27
SW
1582##########################################
1583# uuid_generate() probe, used for vdi block driver
1584if test "$uuid" != "no" ; then
1585 uuid_libs="-luuid"
1586 cat > $TMPC << EOF
1587#include <uuid/uuid.h>
1588int main(void)
1589{
1590 uuid_t my_uuid;
1591 uuid_generate(my_uuid);
1592 return 0;
1593}
1594EOF
1595 if compile_prog "" "$uuid_libs" ; then
1596 uuid="yes"
1597 libs_softmmu="$uuid_libs $libs_softmmu"
1598 libs_tools="$uuid_libs $libs_tools"
1599 else
1600 if test "$uuid" = "yes" ; then
1601 feature_not_found "uuid"
1602 fi
1603 uuid=no
1604 fi
1605fi
1606
dce512de
CH
1607##########################################
1608# xfsctl() probe, used for raw-posix
1609if test "$xfs" != "no" ; then
1610 cat > $TMPC << EOF
1611#include <xfs/xfs.h>
1612int main(void)
1613{
1614 xfsctl(NULL, 0, 0, NULL);
1615 return 0;
1616}
1617EOF
1618 if compile_prog "" "" ; then
1619 xfs="yes"
1620 else
1621 if test "$xfs" = "yes" ; then
1622 feature_not_found "xfs"
1623 fi
1624 xfs=no
1625 fi
1626fi
1627
8a16d273
TS
1628##########################################
1629# vde libraries probe
dfb278bd 1630if test "$vde" != "no" ; then
4baae0ac 1631 vde_libs="-lvdeplug"
8a16d273
TS
1632 cat > $TMPC << EOF
1633#include <libvdeplug.h>
4a7f0e06
PB
1634int main(void)
1635{
1636 struct vde_open_args a = {0, 0, 0};
1637 vde_open("", "", &a);
1638 return 0;
1639}
8a16d273 1640EOF
52166aa0 1641 if compile_prog "" "$vde_libs" ; then
4baae0ac 1642 vde=yes
8e02e54c
JQ
1643 libs_softmmu="$vde_libs $libs_softmmu"
1644 libs_tools="$vde_libs $libs_tools"
dfb278bd
JQ
1645 else
1646 if test "$vde" = "yes" ; then
1647 feature_not_found "vde"
1648 fi
1649 vde=no
4baae0ac 1650 fi
8a16d273
TS
1651fi
1652
8f28f3fb 1653##########################################
c2de5c91 1654# Sound support libraries probe
8f28f3fb 1655
c2de5c91 1656audio_drv_probe()
1657{
1658 drv=$1
1659 hdr=$2
1660 lib=$3
1661 exp=$4
1662 cfl=$5
1663 cat > $TMPC << EOF
1664#include <$hdr>
1665int main(void) { $exp }
8f28f3fb 1666EOF
52166aa0 1667 if compile_prog "$cfl" "$lib" ; then
c2de5c91 1668 :
1669 else
1670 echo
1671 echo "Error: $drv check failed"
1672 echo "Make sure to have the $drv libs and headers installed."
1673 echo
1674 exit 1
1675 fi
1676}
1677
2fa7d3bf 1678audio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
c2de5c91 1679for drv in $audio_drv_list; do
1680 case $drv in
1681 alsa)
1682 audio_drv_probe $drv alsa/asoundlib.h -lasound \
1683 "snd_pcm_t **handle; return snd_pcm_close(*handle);"
a4bf6780 1684 libs_softmmu="-lasound $libs_softmmu"
c2de5c91 1685 ;;
1686
1687 fmod)
1688 if test -z $fmod_lib || test -z $fmod_inc; then
1689 echo
1690 echo "Error: You must specify path to FMOD library and headers"
1691 echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
1692 echo
1693 exit 1
1694 fi
1695 audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
a4bf6780 1696 libs_softmmu="$fmod_lib $libs_softmmu"
c2de5c91 1697 ;;
1698
1699 esd)
1700 audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
a4bf6780 1701 libs_softmmu="-lesd $libs_softmmu"
67f86e8e 1702 audio_pt_int="yes"
c2de5c91 1703 ;;
b8e59f18 1704
1705 pa)
493abda6 1706 audio_drv_probe $drv pulse/simple.h "-lpulse-simple -lpulse" \
20fa53ec 1707 "pa_simple *s = 0; pa_simple_free(s); return 0;"
493abda6 1708 libs_softmmu="-lpulse -lpulse-simple $libs_softmmu"
67f86e8e 1709 audio_pt_int="yes"
b8e59f18 1710 ;;
1711
997e690a
JQ
1712 coreaudio)
1713 libs_softmmu="-framework CoreAudio $libs_softmmu"
1714 ;;
1715
a4bf6780
JQ
1716 dsound)
1717 libs_softmmu="-lole32 -ldxguid $libs_softmmu"
d5631638 1718 audio_win_int="yes"
a4bf6780
JQ
1719 ;;
1720
1721 oss)
1722 libs_softmmu="$oss_lib $libs_softmmu"
1723 ;;
1724
1725 sdl|wav)
2f6a1ab0
BS
1726 # XXX: Probes for CoreAudio, DirectSound, SDL(?)
1727 ;;
1728
d5631638 1729 winwave)
1730 libs_softmmu="-lwinmm $libs_softmmu"
1731 audio_win_int="yes"
1732 ;;
1733
e4c63a6a 1734 *)
1c9b2a52 1735 echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
e4c63a6a 1736 echo
1737 echo "Error: Unknown driver '$drv' selected"
1738 echo "Possible drivers are: $audio_possible_drivers"
1739 echo
1740 exit 1
1741 }
1742 ;;
c2de5c91 1743 esac
1744done
8f28f3fb 1745
2e4d9fb1
AJ
1746##########################################
1747# BrlAPI probe
1748
4ffcedb6 1749if test "$brlapi" != "no" ; then
eb82284f
JQ
1750 brlapi_libs="-lbrlapi"
1751 cat > $TMPC << EOF
2e4d9fb1 1752#include <brlapi.h>
832ce9c2 1753#include <stddef.h>
2e4d9fb1
AJ
1754int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
1755EOF
52166aa0 1756 if compile_prog "" "$brlapi_libs" ; then
eb82284f 1757 brlapi=yes
264606b3 1758 libs_softmmu="$brlapi_libs $libs_softmmu"
4ffcedb6
JQ
1759 else
1760 if test "$brlapi" = "yes" ; then
1761 feature_not_found "brlapi"
1762 fi
1763 brlapi=no
eb82284f
JQ
1764 fi
1765fi
2e4d9fb1 1766
4d3b6f6e
AZ
1767##########################################
1768# curses probe
e095e2f3
SW
1769if test "$mingw32" = "yes" ; then
1770 curses_list="-lpdcurses"
1771else
1772 curses_list="-lncurses -lcurses"
1773fi
4d3b6f6e 1774
c584a6d0
JQ
1775if test "$curses" != "no" ; then
1776 curses_found=no
4d3b6f6e
AZ
1777 cat > $TMPC << EOF
1778#include <curses.h>
5a8ff3aa
BS
1779#ifdef __OpenBSD__
1780#define resize_term resizeterm
1781#endif
1782int main(void) { resize_term(0, 0); return curses_version(); }
4d3b6f6e 1783EOF
4f78ef9a
JQ
1784 for curses_lib in $curses_list; do
1785 if compile_prog "" "$curses_lib" ; then
c584a6d0 1786 curses_found=yes
4f78ef9a
JQ
1787 libs_softmmu="$curses_lib $libs_softmmu"
1788 break
1789 fi
1790 done
c584a6d0
JQ
1791 if test "$curses_found" = "yes" ; then
1792 curses=yes
1793 else
1794 if test "$curses" = "yes" ; then
1795 feature_not_found "curses"
1796 fi
1797 curses=no
1798 fi
4f78ef9a 1799fi
4d3b6f6e 1800
769ce76d
AG
1801##########################################
1802# curl probe
1803
a8bd70ad
PB
1804if $pkg_config libcurl --modversion >/dev/null 2>&1; then
1805 curlconfig="$pkg_config libcurl"
4e2b0658
PB
1806else
1807 curlconfig=curl-config
1808fi
1809
788c8196 1810if test "$curl" != "no" ; then
769ce76d
AG
1811 cat > $TMPC << EOF
1812#include <curl/curl.h>
0b862ced 1813int main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
769ce76d 1814EOF
4e2b0658
PB
1815 curl_cflags=`$curlconfig --cflags 2>/dev/null`
1816 curl_libs=`$curlconfig --libs 2>/dev/null`
b1d5a277 1817 if compile_prog "$curl_cflags" "$curl_libs" ; then
769ce76d 1818 curl=yes
f0302935
JQ
1819 libs_tools="$curl_libs $libs_tools"
1820 libs_softmmu="$curl_libs $libs_softmmu"
788c8196
JQ
1821 else
1822 if test "$curl" = "yes" ; then
1823 feature_not_found "curl"
1824 fi
1825 curl=no
769ce76d
AG
1826 fi
1827fi # test "$curl"
1828
5495ed11
LC
1829##########################################
1830# check framework probe
1831
1832if test "$check_utests" != "no" ; then
1833 cat > $TMPC << EOF
1834#include <check.h>
1835int main(void) { suite_create("qemu test"); return 0; }
1836EOF
f809c0d6 1837 check_libs=`$pkg_config --libs check 2>/dev/null`
5495ed11
LC
1838 if compile_prog "" $check_libs ; then
1839 check_utests=yes
1840 libs_tools="$check_libs $libs_tools"
1841 else
1842 if test "$check_utests" = "yes" ; then
1843 feature_not_found "check"
1844 fi
1845 check_utests=no
1846 fi
1847fi # test "$check_utests"
1848
fb599c9a
AZ
1849##########################################
1850# bluez support probe
a20a6f46 1851if test "$bluez" != "no" ; then
e820e3f4
AZ
1852 cat > $TMPC << EOF
1853#include <bluetooth/bluetooth.h>
1854int main(void) { return bt_error(0); }
1855EOF
a8bd70ad
PB
1856 bluez_cflags=`$pkg_config --cflags bluez 2> /dev/null`
1857 bluez_libs=`$pkg_config --libs bluez 2> /dev/null`
52166aa0 1858 if compile_prog "$bluez_cflags" "$bluez_libs" ; then
a20a6f46 1859 bluez=yes
e482d56a 1860 libs_softmmu="$bluez_libs $libs_softmmu"
e820e3f4 1861 else
a20a6f46
JQ
1862 if test "$bluez" = "yes" ; then
1863 feature_not_found "bluez"
1864 fi
e820e3f4
AZ
1865 bluez="no"
1866 fi
fb599c9a
AZ
1867fi
1868
e18df141
AL
1869##########################################
1870# glib support probe
4b76a481
SH
1871if $pkg_config --modversion gthread-2.0 > /dev/null 2>&1 ; then
1872 glib_cflags=`$pkg_config --cflags gthread-2.0 2>/dev/null`
1873 glib_libs=`$pkg_config --libs gthread-2.0 2>/dev/null`
14015304 1874 LIBS="$glib_libs $LIBS"
957f1f99 1875 libs_qga="$glib_libs $libs_qga"
4b76a481
SH
1876else
1877 echo "glib-2.0 required to compile QEMU"
1878 exit 1
e18df141
AL
1879fi
1880
414f0dab 1881##########################################
e5d355d1 1882# pthread probe
4b29ec41 1883PTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
3c529d93 1884
4dd75c70 1885pthread=no
e5d355d1 1886cat > $TMPC << EOF
3c529d93 1887#include <pthread.h>
de65fe0f 1888int main(void) { pthread_create(0,0,0,0); return 0; }
414f0dab 1889EOF
bd00d539
AF
1890if compile_prog "" "" ; then
1891 pthread=yes
1892else
1893 for pthread_lib in $PTHREADLIBS_LIST; do
1894 if compile_prog "" "$pthread_lib" ; then
1895 pthread=yes
1896 LIBS="$pthread_lib $LIBS"
1897 break
1898 fi
1899 done
1900fi
414f0dab 1901
4617e593 1902if test "$mingw32" != yes -a "$pthread" = no; then
4dd75c70
CH
1903 echo
1904 echo "Error: pthread check failed"
1905 echo "Make sure to have the pthread libs and headers installed."
1906 echo
1907 exit 1
e5d355d1
AL
1908fi
1909
f27aaf4b
CB
1910##########################################
1911# rbd probe
1912if test "$rbd" != "no" ; then
1913 cat > $TMPC <<EOF
1914#include <stdio.h>
ad32e9c0 1915#include <rbd/librbd.h>
f27aaf4b 1916int main(void) {
ad32e9c0
JD
1917 rados_t cluster;
1918 rados_create(&cluster, NULL);
f27aaf4b
CB
1919 return 0;
1920}
1921EOF
ad32e9c0
JD
1922 rbd_libs="-lrbd -lrados"
1923 if compile_prog "" "$rbd_libs" ; then
1924 rbd=yes
1925 libs_tools="$rbd_libs $libs_tools"
1926 libs_softmmu="$rbd_libs $libs_softmmu"
f27aaf4b
CB
1927 else
1928 if test "$rbd" = "yes" ; then
1929 feature_not_found "rados block device"
1930 fi
1931 rbd=no
1932 fi
f27aaf4b
CB
1933fi
1934
5c6c3a6c
CH
1935##########################################
1936# linux-aio probe
5c6c3a6c
CH
1937
1938if test "$linux_aio" != "no" ; then
1939 cat > $TMPC <<EOF
1940#include <libaio.h>
1941#include <sys/eventfd.h>
832ce9c2 1942#include <stddef.h>
5c6c3a6c
CH
1943int main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
1944EOF
1945 if compile_prog "" "-laio" ; then
1946 linux_aio=yes
048d179f
PB
1947 libs_softmmu="$libs_softmmu -laio"
1948 libs_tools="$libs_tools -laio"
5c6c3a6c
CH
1949 else
1950 if test "$linux_aio" = "yes" ; then
1951 feature_not_found "linux AIO"
1952 fi
3cfcae3c 1953 linux_aio=no
5c6c3a6c
CH
1954 fi
1955fi
1956
758e8e38
VJJ
1957##########################################
1958# attr probe
1959
1960if test "$attr" != "no" ; then
1961 cat > $TMPC <<EOF
1962#include <stdio.h>
1963#include <sys/types.h>
1964#include <attr/xattr.h>
1965int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
1966EOF
1967 if compile_prog "" "-lattr" ; then
1968 attr=yes
1969 LIBS="-lattr $LIBS"
1970 else
1971 if test "$attr" = "yes" ; then
1972 feature_not_found "ATTR"
1973 fi
1974 attr=no
1975 fi
1976fi
1977
bf9298b9
AL
1978##########################################
1979# iovec probe
1980cat > $TMPC <<EOF
db34f0b3 1981#include <sys/types.h>
bf9298b9 1982#include <sys/uio.h>
db34f0b3 1983#include <unistd.h>
bf9298b9
AL
1984int main(void) { struct iovec iov; return 0; }
1985EOF
1986iovec=no
52166aa0 1987if compile_prog "" "" ; then
bf9298b9
AL
1988 iovec=yes
1989fi
1990
ceb42de8
AL
1991##########################################
1992# preadv probe
1993cat > $TMPC <<EOF
1994#include <sys/types.h>
1995#include <sys/uio.h>
1996#include <unistd.h>
1997int main(void) { preadv; }
1998EOF
1999preadv=no
52166aa0 2000if compile_prog "" "" ; then
ceb42de8
AL
2001 preadv=yes
2002fi
2003
f652e6af
AJ
2004##########################################
2005# fdt probe
2df87df7 2006if test "$fdt" != "no" ; then
b41af4ba
JQ
2007 fdt_libs="-lfdt"
2008 cat > $TMPC << EOF
f652e6af
AJ
2009int main(void) { return 0; }
2010EOF
52166aa0 2011 if compile_prog "" "$fdt_libs" ; then
f652e6af 2012 fdt=yes
2df87df7
JQ
2013 else
2014 if test "$fdt" = "yes" ; then
2015 feature_not_found "fdt"
2016 fi
de3a354a 2017 fdt_libs=
2df87df7 2018 fdt=no
f652e6af
AJ
2019 fi
2020fi
2021
20ff075b
MW
2022##########################################
2023# opengl probe, used by milkymist-tmu2
2024if test "$opengl" != "no" ; then
2025 opengl_libs="-lGL"
2026 cat > $TMPC << EOF
2027#include <X11/Xlib.h>
2028#include <GL/gl.h>
2029#include <GL/glx.h>
2030int main(void) { GL_VERSION; return 0; }
2031EOF
2032 if compile_prog "" "-lGL" ; then
2033 opengl=yes
20ff075b
MW
2034 else
2035 if test "$opengl" = "yes" ; then
2036 feature_not_found "opengl"
2037 fi
de3a354a 2038 opengl_libs=
20ff075b
MW
2039 opengl=no
2040 fi
2041fi
2042
3b3f24ad
AJ
2043#
2044# Check for xxxat() functions when we are building linux-user
2045# emulator. This is done because older glibc versions don't
2046# have syscall stubs for these implemented.
2047#
2048atfile=no
67ba57f6 2049cat > $TMPC << EOF
3b3f24ad
AJ
2050#define _ATFILE_SOURCE
2051#include <sys/types.h>
2052#include <fcntl.h>
2053#include <unistd.h>
2054
2055int
2056main(void)
2057{
2058 /* try to unlink nonexisting file */
2059 return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
2060}
2061EOF
52166aa0 2062if compile_prog "" "" ; then
67ba57f6 2063 atfile=yes
3b3f24ad
AJ
2064fi
2065
39386ac7 2066# Check for inotify functions when we are building linux-user
3b3f24ad
AJ
2067# emulator. This is done because older glibc versions don't
2068# have syscall stubs for these implemented. In that case we
2069# don't provide them even if kernel supports them.
2070#
2071inotify=no
67ba57f6 2072cat > $TMPC << EOF
3b3f24ad
AJ
2073#include <sys/inotify.h>
2074
2075int
2076main(void)
2077{
2078 /* try to start inotify */
8690e420 2079 return inotify_init();
3b3f24ad
AJ
2080}
2081EOF
52166aa0 2082if compile_prog "" "" ; then
67ba57f6 2083 inotify=yes
3b3f24ad
AJ
2084fi
2085
c05c7a73
RV
2086inotify1=no
2087cat > $TMPC << EOF
2088#include <sys/inotify.h>
2089
2090int
2091main(void)
2092{
2093 /* try to start inotify */
2094 return inotify_init1(0);
2095}
2096EOF
2097if compile_prog "" "" ; then
2098 inotify1=yes
2099fi
2100
ebc996f3
RV
2101# check if utimensat and futimens are supported
2102utimens=no
2103cat > $TMPC << EOF
2104#define _ATFILE_SOURCE
ebc996f3
RV
2105#include <stddef.h>
2106#include <fcntl.h>
2107
2108int main(void)
2109{
2110 utimensat(AT_FDCWD, "foo", NULL, 0);
2111 futimens(0, NULL);
2112 return 0;
2113}
2114EOF
52166aa0 2115if compile_prog "" "" ; then
ebc996f3
RV
2116 utimens=yes
2117fi
2118
099d6b0f
RV
2119# check if pipe2 is there
2120pipe2=no
2121cat > $TMPC << EOF
099d6b0f
RV
2122#include <unistd.h>
2123#include <fcntl.h>
2124
2125int main(void)
2126{
2127 int pipefd[2];
2128 pipe2(pipefd, O_CLOEXEC);
2129 return 0;
2130}
2131EOF
52166aa0 2132if compile_prog "" "" ; then
099d6b0f
RV
2133 pipe2=yes
2134fi
2135
40ff6d7e
KW
2136# check if accept4 is there
2137accept4=no
2138cat > $TMPC << EOF
40ff6d7e
KW
2139#include <sys/socket.h>
2140#include <stddef.h>
2141
2142int main(void)
2143{
2144 accept4(0, NULL, NULL, SOCK_CLOEXEC);
2145 return 0;
2146}
2147EOF
2148if compile_prog "" "" ; then
2149 accept4=yes
2150fi
2151
3ce34dfb 2152# check if tee/splice is there. vmsplice was added same time.
2153splice=no
2154cat > $TMPC << EOF
3ce34dfb 2155#include <unistd.h>
2156#include <fcntl.h>
2157#include <limits.h>
2158
2159int main(void)
2160{
2161 int len, fd;
2162 len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
2163 splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
2164 return 0;
2165}
2166EOF
52166aa0 2167if compile_prog "" "" ; then
3ce34dfb 2168 splice=yes
2169fi
2170
dcc38d1c
MT
2171##########################################
2172# signalfd probe
2173signalfd="no"
2174cat > $TMPC << EOF
2175#define _GNU_SOURCE
2176#include <unistd.h>
2177#include <sys/syscall.h>
2178#include <signal.h>
2179int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
2180EOF
2181
2182if compile_prog "" "" ; then
2183 signalfd=yes
2184fi
2185
c2882b96
RV
2186# check if eventfd is supported
2187eventfd=no
2188cat > $TMPC << EOF
2189#include <sys/eventfd.h>
2190
2191int main(void)
2192{
2193 int efd = eventfd(0, 0);
2194 return 0;
2195}
2196EOF
2197if compile_prog "" "" ; then
2198 eventfd=yes
2199fi
2200
d0927938
UH
2201# check for fallocate
2202fallocate=no
2203cat > $TMPC << EOF
2204#include <fcntl.h>
2205
2206int main(void)
2207{
2208 fallocate(0, 0, 0, 0);
2209 return 0;
2210}
2211EOF
be17dc90 2212if compile_prog "$ARCH_CFLAGS" "" ; then
d0927938
UH
2213 fallocate=yes
2214fi
2215
c727f47d
PM
2216# check for sync_file_range
2217sync_file_range=no
2218cat > $TMPC << EOF
2219#include <fcntl.h>
2220
2221int main(void)
2222{
2223 sync_file_range(0, 0, 0, 0);
2224 return 0;
2225}
2226EOF
2227if compile_prog "$ARCH_CFLAGS" "" ; then
2228 sync_file_range=yes
2229fi
2230
dace20dc
PM
2231# check for linux/fiemap.h and FS_IOC_FIEMAP
2232fiemap=no
2233cat > $TMPC << EOF
2234#include <sys/ioctl.h>
2235#include <linux/fs.h>
2236#include <linux/fiemap.h>
2237
2238int main(void)
2239{
2240 ioctl(0, FS_IOC_FIEMAP, 0);
2241 return 0;
2242}
2243EOF
2244if compile_prog "$ARCH_CFLAGS" "" ; then
2245 fiemap=yes
2246fi
2247
d0927938
UH
2248# check for dup3
2249dup3=no
2250cat > $TMPC << EOF
2251#include <unistd.h>
2252
2253int main(void)
2254{
2255 dup3(0, 0, 0);
2256 return 0;
2257}
2258EOF
78f5d726 2259if compile_prog "" "" ; then
d0927938
UH
2260 dup3=yes
2261fi
2262
3b6edd16
PM
2263# check for epoll support
2264epoll=no
2265cat > $TMPC << EOF
2266#include <sys/epoll.h>
2267
2268int main(void)
2269{
2270 epoll_create(0);
2271 return 0;
2272}
2273EOF
2274if compile_prog "$ARCH_CFLAGS" "" ; then
2275 epoll=yes
2276fi
2277
2278# epoll_create1 and epoll_pwait are later additions
2279# so we must check separately for their presence
2280epoll_create1=no
2281cat > $TMPC << EOF
2282#include <sys/epoll.h>
2283
2284int main(void)
2285{
19e83f6b
PM
2286 /* Note that we use epoll_create1 as a value, not as
2287 * a function being called. This is necessary so that on
2288 * old SPARC glibc versions where the function was present in
2289 * the library but not declared in the header file we will
2290 * fail the configure check. (Otherwise we will get a compiler
2291 * warning but not an error, and will proceed to fail the
2292 * qemu compile where we compile with -Werror.)
2293 */
2294 epoll_create1;
3b6edd16
PM
2295 return 0;
2296}
2297EOF
2298if compile_prog "$ARCH_CFLAGS" "" ; then
2299 epoll_create1=yes
2300fi
2301
2302epoll_pwait=no
2303cat > $TMPC << EOF
2304#include <sys/epoll.h>
2305
2306int main(void)
2307{
2308 epoll_pwait(0, 0, 0, 0, 0);
2309 return 0;
2310}
2311EOF
2312if compile_prog "$ARCH_CFLAGS" "" ; then
2313 epoll_pwait=yes
2314fi
2315
cc8ae6de 2316# Check if tools are available to build documentation.
a25dba17 2317if test "$docs" != "no" ; then
01668d98 2318 if has makeinfo && has pod2man; then
a25dba17 2319 docs=yes
83a3ab8b 2320 else
a25dba17
JQ
2321 if test "$docs" = "yes" ; then
2322 feature_not_found "docs"
83a3ab8b 2323 fi
a25dba17 2324 docs=no
83a3ab8b 2325 fi
cc8ae6de
PB
2326fi
2327
f514f41c 2328# Search for bswap_32 function
6ae9a1f4
JQ
2329byteswap_h=no
2330cat > $TMPC << EOF
2331#include <byteswap.h>
2332int main(void) { return bswap_32(0); }
2333EOF
52166aa0 2334if compile_prog "" "" ; then
6ae9a1f4
JQ
2335 byteswap_h=yes
2336fi
2337
f514f41c 2338# Search for bswap_32 function
6ae9a1f4
JQ
2339bswap_h=no
2340cat > $TMPC << EOF
2341#include <sys/endian.h>
2342#include <sys/types.h>
2343#include <machine/bswap.h>
2344int main(void) { return bswap32(0); }
2345EOF
52166aa0 2346if compile_prog "" "" ; then
6ae9a1f4
JQ
2347 bswap_h=yes
2348fi
2349
c589b249
RS
2350##########################################
2351# Do we have libiscsi
2352if test "$libiscsi" != "no" ; then
2353 cat > $TMPC << EOF
2354#include <iscsi/iscsi.h>
2355int main(void) { iscsi_create_context(""); return 0; }
2356EOF
2357 if compile_prog "-Werror" "-liscsi" ; then
2358 libiscsi="yes"
2359 LIBS="$LIBS -liscsi"
2360 else
2361 if test "$libiscsi" = "yes" ; then
2362 feature_not_found "libiscsi"
2363 fi
2364 libiscsi="no"
2365 fi
2366fi
2367
2368
da93a1fd
AL
2369##########################################
2370# Do we need librt
2371cat > $TMPC <<EOF
2372#include <signal.h>
2373#include <time.h>
2374int main(void) { clockid_t id; return clock_gettime(id, NULL); }
2375EOF
2376
52166aa0 2377if compile_prog "" "" ; then
07ffa4bd 2378 :
52166aa0 2379elif compile_prog "" "-lrt" ; then
07ffa4bd 2380 LIBS="-lrt $LIBS"
da93a1fd
AL
2381fi
2382
31ff504d 2383if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
179cf400 2384 "$aix" != "yes" -a "$haiku" != "yes" ; then
6362a53f
JQ
2385 libs_softmmu="-lutil $libs_softmmu"
2386fi
2387
de5071c5
BS
2388##########################################
2389# check if the compiler defines offsetof
2390
2391need_offsetof=yes
2392cat > $TMPC << EOF
2393#include <stddef.h>
2394int main(void) { struct s { int f; }; return offsetof(struct s, f); }
2395EOF
2396if compile_prog "" "" ; then
2397 need_offsetof=no
2398fi
2399
cd4ec0b4
GH
2400# spice probe
2401if test "$spice" != "no" ; then
2402 cat > $TMPC << EOF
2403#include <spice.h>
2404int main(void) { spice_server_new(); return 0; }
2405EOF
710fc4f5
JD
2406 spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
2407 spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
012b80d3 2408 if $pkg_config --atleast-version=0.6.0 spice-server >/dev/null 2>&1 && \
cd4ec0b4
GH
2409 compile_prog "$spice_cflags" "$spice_libs" ; then
2410 spice="yes"
2411 libs_softmmu="$libs_softmmu $spice_libs"
2412 QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
2413 else
2414 if test "$spice" = "yes" ; then
2415 feature_not_found "spice"
2416 fi
2417 spice="no"
2418 fi
2419fi
2420
111a38b0
RR
2421# check for libcacard for smartcard support
2422if test "$smartcard" != "no" ; then
2423 smartcard="yes"
2424 smartcard_cflags=""
2425 # TODO - what's the minimal nss version we support?
2426 if test "$smartcard_nss" != "no"; then
2427 if $pkg_config --atleast-version=3.12.8 nss >/dev/null 2>&1 ; then
2428 smartcard_nss="yes"
2429 smartcard_cflags="-I\$(SRC_PATH)/libcacard"
2430 libcacard_libs=$($pkg_config --libs nss 2>/dev/null)
2431 libcacard_cflags=$($pkg_config --cflags nss 2>/dev/null)
2432 QEMU_CFLAGS="$QEMU_CFLAGS $smartcard_cflags $libcacard_cflags"
2433 LIBS="$libcacard_libs $LIBS"
2434 else
2435 if test "$smartcard_nss" = "yes"; then
2436 feature_not_found "nss"
2437 fi
2438 smartcard_nss="no"
2439 fi
2440 fi
2441fi
2442if test "$smartcard" = "no" ; then
2443 smartcard_nss="no"
2444fi
2445
69354a83
HG
2446# check for usbredirparser for usb network redirection support
2447if test "$usb_redir" != "no" ; then
2448 if $pkg_config libusbredirparser >/dev/null 2>&1 ; then
2449 usb_redir="yes"
2450 usb_redir_cflags=$($pkg_config --cflags libusbredirparser 2>/dev/null)
2451 usb_redir_libs=$($pkg_config --libs libusbredirparser 2>/dev/null)
2452 QEMU_CFLAGS="$QEMU_CFLAGS $usb_redir_cflags"
2453 LIBS="$LIBS $usb_redir_libs"
2454 else
2455 if test "$usb_redir" = "yes"; then
2456 feature_not_found "usb-redir"
2457 fi
2458 usb_redir="no"
2459 fi
2460fi
2461
cd4ec0b4
GH
2462##########################################
2463
5f6b9e8f
BS
2464##########################################
2465# check if we have fdatasync
2466
2467fdatasync=no
2468cat > $TMPC << EOF
2469#include <unistd.h>
d1722a27
AR
2470int main(void) {
2471#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
2472return fdatasync(0);
2473#else
2474#abort Not supported
2475#endif
2476}
5f6b9e8f
BS
2477EOF
2478if compile_prog "" "" ; then
2479 fdatasync=yes
2480fi
2481
e78815a5
AF
2482##########################################
2483# check if we have madvise
2484
2485madvise=no
2486cat > $TMPC << EOF
2487#include <sys/types.h>
2488#include <sys/mman.h>
832ce9c2 2489#include <stddef.h>
e78815a5
AF
2490int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
2491EOF
2492if compile_prog "" "" ; then
2493 madvise=yes
2494fi
2495
2496##########################################
2497# check if we have posix_madvise
2498
2499posix_madvise=no
2500cat > $TMPC << EOF
2501#include <sys/mman.h>
832ce9c2 2502#include <stddef.h>
e78815a5
AF
2503int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
2504EOF
2505if compile_prog "" "" ; then
2506 posix_madvise=yes
2507fi
2508
94a420b1
SH
2509##########################################
2510# check if trace backend exists
2511
4c3b5a48 2512sh "$source_path/scripts/tracetool" "--$trace_backend" --check-backend > /dev/null 2> /dev/null
94a420b1
SH
2513if test "$?" -ne 0 ; then
2514 echo
2515 echo "Error: invalid trace backend"
2516 echo "Please choose a supported trace backend."
2517 echo
2518 exit 1
2519fi
2520
7e24e92a
SH
2521##########################################
2522# For 'ust' backend, test if ust headers are present
2523if test "$trace_backend" = "ust"; then
2524 cat > $TMPC << EOF
2525#include <ust/tracepoint.h>
2526#include <ust/marker.h>
2527int main(void) { return 0; }
2528EOF
2529 if compile_prog "" "" ; then
2530 LIBS="-lust $LIBS"
2531 else
2532 echo
2533 echo "Error: Trace backend 'ust' missing libust header files"
2534 echo
2535 exit 1
2536 fi
2537fi
b3d08c02
DB
2538
2539##########################################
2540# For 'dtrace' backend, test if 'dtrace' command is present
2541if test "$trace_backend" = "dtrace"; then
2542 if ! has 'dtrace' ; then
2543 echo
2544 echo "Error: dtrace command is not found in PATH $PATH"
2545 echo
2546 exit 1
2547 fi
c276b17d
DB
2548 trace_backend_stap="no"
2549 if has 'stap' ; then
2550 trace_backend_stap="yes"
2551 fi
b3d08c02
DB
2552fi
2553
023367e6
WM
2554##########################################
2555# __sync_fetch_and_and requires at least -march=i486. Many toolchains
2556# use i686 as default anyway, but for those that don't, an explicit
2557# specification is necessary
1ba16968 2558if test "$vhost_net" = "yes" && test "$cpu" = "i386"; then
023367e6
WM
2559 cat > $TMPC << EOF
2560int sfaa(unsigned *ptr)
2561{
2562 return __sync_fetch_and_and(ptr, 0);
2563}
2564
2565int main(int argc, char **argv)
2566{
2567 int val = 42;
2568 sfaa(&val);
2569 return val;
2570}
2571EOF
2572 if ! compile_prog "" "" ; then
2573 CFLAGS+="-march=i486"
2574 fi
2575fi
2576
d0e2fce5
AK
2577##########################################
2578# check if we have makecontext
2579
2580ucontext_coroutine=no
2581if test "$darwin" != "yes"; then
2582 cat > $TMPC << EOF
2583#include <ucontext.h>
2584int main(void) { makecontext(0, 0, 0); }
2585EOF
2586 if compile_prog "" "" ; then
2587 ucontext_coroutine=yes
2588 fi
2589fi
2590
d2042378
AK
2591##########################################
2592# check if we have open_by_handle_at
2593
2594open_by_hande_at=no
2595cat > $TMPC << EOF
2596#include <fcntl.h>
15329e83 2597int main(void) { struct file_handle fh; open_by_handle_at(0, &fh, 0); }
d2042378
AK
2598EOF
2599if compile_prog "" "" ; then
2600 open_by_handle_at=yes
2601fi
2602
e06a765e
HPB
2603########################################
2604# check if we have linux/magic.h
2605
2606linux_magic_h=no
2607cat > $TMPC << EOF
2608#include <linux/magic.h>
2609int main(void) {
2610}
2611EOF
2612if compile_prog "" "" ; then
2613 linux_magic_h=yes
2614fi
2615
7e24e92a 2616##########################################
e86ecd4b
JQ
2617# End of CC checks
2618# After here, no more $cc or $ld runs
2619
e86ecd4b 2620if test "$debug" = "no" ; then
1156c669 2621 CFLAGS="-O2 $CFLAGS"
e86ecd4b 2622fi
a316e378 2623
e86ecd4b
JQ
2624# Consult white-list to determine whether to enable werror
2625# by default. Only enable by default for git builds
20ff6c80
AL
2626z_version=`cut -f3 -d. $source_path/VERSION`
2627
e86ecd4b 2628if test -z "$werror" ; then
e86ecd4b
JQ
2629 if test "$z_version" = "50" -a \
2630 "$linux" = "yes" ; then
2631 werror="yes"
2632 else
2633 werror="no"
2634 fi
2635fi
2636
20ff6c80
AL
2637# Disable zero malloc errors for official releases unless explicitly told to
2638# enable/disable
2639if test -z "$zero_malloc" ; then
2640 if test "$z_version" = "50" ; then
2641 zero_malloc="no"
2642 else
2643 zero_malloc="yes"
2644 fi
2645fi
2646
e86ecd4b 2647if test "$werror" = "yes" ; then
a558ee17 2648 QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
e86ecd4b
JQ
2649fi
2650
2651if test "$solaris" = "no" ; then
2652 if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
1156c669 2653 LDFLAGS="-Wl,--warn-common $LDFLAGS"
e86ecd4b
JQ
2654 fi
2655fi
2656
952afb71
BS
2657# Use ASLR, no-SEH and DEP if available
2658if test "$mingw32" = "yes" ; then
2659 for flag in --dynamicbase --no-seh --nxcompat; do
2660 if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
2661 LDFLAGS="-Wl,$flag $LDFLAGS"
2662 fi
2663 done
2664fi
2665
190e9c59 2666confdir=$sysconfdir$confsuffix
e7b45cc4 2667
ca35f780
PB
2668tools=
2669if test "$softmmu" = yes ; then
2670 tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
2671 if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
2672 tools="qemu-nbd\$(EXESUF) $tools"
d138cee9 2673 if [ "$guest_agent" = "yes" ]; then
48ff7a62 2674 tools="qemu-ga\$(EXESUF) $tools"
d138cee9 2675 fi
ca35f780 2676 if [ "$check_utests" = "yes" ]; then
fffbeb75 2677 checks="check-qint check-qstring check-qdict check-qlist"
695833bc 2678 checks="check-qfloat check-qjson test-coroutine $checks"
ca35f780
PB
2679 fi
2680 fi
2681fi
2682
2683# Mac OS X ships with a broken assembler
2684roms=
2685if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
2686 "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
2687 "$softmmu" = yes ; then
2688 roms="optionrom"
2689fi
d0384d1d 2690if test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
39ac8455
DG
2691 roms="$roms spapr-rtas"
2692fi
ca35f780 2693
43ce4dfe 2694echo "Install prefix $prefix"
f2b9e1e3
PB
2695echo "BIOS directory `eval echo $datadir`"
2696echo "binary directory `eval echo $bindir`"
3aa5d2be 2697echo "library directory `eval echo $libdir`"
0f94d6da 2698echo "include directory `eval echo $includedir`"
1c0fd160 2699echo "config directory `eval echo $sysconfdir`"
11d9f695 2700if test "$mingw32" = "no" ; then
f2b9e1e3 2701echo "Manual directory `eval echo $mandir`"
43ce4dfe 2702echo "ELF interp prefix $interp_prefix"
11d9f695 2703fi
5a67135a 2704echo "Source path $source_path"
43ce4dfe 2705echo "C compiler $cc"
83469015 2706echo "Host C compiler $host_cc"
0c439cbf 2707echo "CFLAGS $CFLAGS"
a558ee17 2708echo "QEMU_CFLAGS $QEMU_CFLAGS"
0c439cbf 2709echo "LDFLAGS $LDFLAGS"
43ce4dfe 2710echo "make $make"
6a882643 2711echo "install $install"
c886edfb 2712echo "python $python"
e2d8830e
B
2713if test "$slirp" = "yes" ; then
2714 echo "smbd $smbd"
2715fi
43ce4dfe 2716echo "host CPU $cpu"
de83cd02 2717echo "host big endian $bigendian"
97a847bc 2718echo "target list $target_list"
ade25b0d 2719echo "tcg debug enabled $debug_tcg"
b4475aa2 2720echo "Mon debug enabled $debug_mon"
43ce4dfe 2721echo "gprof enabled $gprof"
03b4fe7d 2722echo "sparse enabled $sparse"
1625af87 2723echo "strip binaries $strip_opt"
05c2a3e7 2724echo "profiler $profiler"
43ce4dfe 2725echo "static build $static"
85aa5189 2726echo "-Werror enabled $werror"
5b0753e0
FB
2727if test "$darwin" = "yes" ; then
2728 echo "Cocoa support $cocoa"
2729fi
97a847bc 2730echo "SDL support $sdl"
4d3b6f6e 2731echo "curses support $curses"
769ce76d 2732echo "curl support $curl"
5495ed11 2733echo "check support $check_utests"
67b915a5 2734echo "mingw32 support $mingw32"
0c58ac1c 2735echo "Audio drivers $audio_drv_list"
2736echo "Extra audio cards $audio_card_list"
eb852011 2737echo "Block whitelist $block_drv_whitelist"
8ff9cbf7 2738echo "Mixer emulation $mixemu"
821601ea
JS
2739echo "VNC support $vnc"
2740if test "$vnc" = "yes" ; then
2741 echo "VNC TLS support $vnc_tls"
2742 echo "VNC SASL support $vnc_sasl"
2743 echo "VNC JPEG support $vnc_jpeg"
2744 echo "VNC PNG support $vnc_png"
2745 echo "VNC thread $vnc_thread"
2746fi
3142255c
BS
2747if test -n "$sparc_cpu"; then
2748 echo "Target Sparc Arch $sparc_cpu"
2749fi
e37630ca 2750echo "xen support $xen"
2e4d9fb1 2751echo "brlapi support $brlapi"
a20a6f46 2752echo "bluez support $bluez"
a25dba17 2753echo "Documentation $docs"
c5937220
PB
2754[ ! -z "$uname_release" ] && \
2755echo "uname -r $uname_release"
bd0c5661 2756echo "NPTL support $nptl"
379f6698 2757echo "GUEST_BASE $guest_base"
34005a00 2758echo "PIE user targets $user_pie"
8a16d273 2759echo "vde support $vde"
5c6c3a6c 2760echo "Linux AIO support $linux_aio"
758e8e38 2761echo "ATTR/XATTR support $attr"
77755340 2762echo "Install blobs $blobs"
b31a0277 2763echo "KVM support $kvm"
9195b2c2 2764echo "TCG interpreter $tcg_interpreter"
f652e6af 2765echo "fdt support $fdt"
ceb42de8 2766echo "preadv support $preadv"
5f6b9e8f 2767echo "fdatasync $fdatasync"
e78815a5
AF
2768echo "madvise $madvise"
2769echo "posix_madvise $posix_madvise"
ee682d27 2770echo "uuid support $uuid"
d5970055 2771echo "vhost-net support $vhost_net"
94a420b1 2772echo "Trace backend $trace_backend"
9410b56c 2773echo "Trace output file $trace_file-<pid>"
cd4ec0b4 2774echo "spice support $spice"
f27aaf4b 2775echo "rbd support $rbd"
dce512de 2776echo "xfsctl support $xfs"
111a38b0 2777echo "nss used $smartcard_nss"
69354a83 2778echo "usb net redir $usb_redir"
20ff075b 2779echo "OpenGL support $opengl"
c589b249 2780echo "libiscsi support $libiscsi"
d138cee9 2781echo "build guest agent $guest_agent"
67b915a5 2782
1ba16968 2783if test "$sdl_too_old" = "yes"; then
24b55b96 2784echo "-> Your SDL version is too old - please upgrade to have SDL support"
7c1f25b4 2785fi
7d13299d 2786
98ec69ac 2787config_host_mak="config-host.mak"
4bf6b55b 2788config_host_ld="config-host.ld"
98ec69ac 2789
98ec69ac
JQ
2790echo "# Automatically generated by configure - do not modify" > $config_host_mak
2791printf "# Configured with:" >> $config_host_mak
2792printf " '%s'" "$0" "$@" >> $config_host_mak
2793echo >> $config_host_mak
98ec69ac 2794
e6c3b0f7 2795echo all: >> $config_host_mak
99d7cc75
PB
2796echo "prefix=$prefix" >> $config_host_mak
2797echo "bindir=$bindir" >> $config_host_mak
3aa5d2be 2798echo "libdir=$libdir" >> $config_host_mak
0f94d6da 2799echo "includedir=$includedir" >> $config_host_mak
99d7cc75
PB
2800echo "mandir=$mandir" >> $config_host_mak
2801echo "datadir=$datadir" >> $config_host_mak
2802echo "sysconfdir=$sysconfdir" >> $config_host_mak
2803echo "docdir=$docdir" >> $config_host_mak
1dabe05c 2804echo "confdir=$confdir" >> $config_host_mak
804edf29 2805
2408a527 2806case "$cpu" in
d2fbca94 2807 i386|x86_64|alpha|cris|hppa|ia64|lm32|m68k|microblaze|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64|unicore32)
e0da9dd3 2808 ARCH=$cpu
2408a527 2809 ;;
a302c32d 2810 armv4b|armv4l)
16dbd14f 2811 ARCH=arm
2408a527 2812 ;;
9195b2c2
SW
2813 *)
2814 if test "$tcg_interpreter" = "yes" ; then
2815 echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
2816 ARCH=tci
2817 else
2818 echo "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
2819 exit 1
2820 fi
2821 ;;
2408a527 2822esac
98ec69ac 2823echo "ARCH=$ARCH" >> $config_host_mak
f8393946 2824if test "$debug_tcg" = "yes" ; then
2358a494 2825 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
f8393946 2826fi
b4475aa2
LC
2827if test "$debug_mon" = "yes" ; then
2828 echo "CONFIG_DEBUG_MONITOR=y" >> $config_host_mak
2829fi
f3d08ee6 2830if test "$debug" = "yes" ; then
2358a494 2831 echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
f3d08ee6 2832fi
1625af87 2833if test "$strip_opt" = "yes" ; then
52ba784d 2834 echo "STRIP=${strip}" >> $config_host_mak
1625af87 2835fi
7d13299d 2836if test "$bigendian" = "yes" ; then
e2542fe2 2837 echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
97a847bc 2838fi
2358a494 2839echo "HOST_LONG_BITS=$hostlongbits" >> $config_host_mak
67b915a5 2840if test "$mingw32" = "yes" ; then
98ec69ac 2841 echo "CONFIG_WIN32=y" >> $config_host_mak
9fe6de94
BS
2842 rc_version=`cat $source_path/VERSION`
2843 version_major=${rc_version%%.*}
2844 rc_version=${rc_version#*.}
2845 version_minor=${rc_version%%.*}
2846 rc_version=${rc_version#*.}
2847 version_subminor=${rc_version%%.*}
2848 version_micro=0
2849 echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
2850 echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
210fa556 2851else
35f4df27 2852 echo "CONFIG_POSIX=y" >> $config_host_mak
dffcb71c
MM
2853fi
2854
2855if test "$linux" = "yes" ; then
2856 echo "CONFIG_LINUX=y" >> $config_host_mak
67b915a5 2857fi
128ab2ff 2858
83fb7adf 2859if test "$darwin" = "yes" ; then
98ec69ac 2860 echo "CONFIG_DARWIN=y" >> $config_host_mak
83fb7adf 2861fi
b29fe3ed 2862
2863if test "$aix" = "yes" ; then
98ec69ac 2864 echo "CONFIG_AIX=y" >> $config_host_mak
b29fe3ed 2865fi
2866
ec530c81 2867if test "$solaris" = "yes" ; then
98ec69ac 2868 echo "CONFIG_SOLARIS=y" >> $config_host_mak
2358a494 2869 echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
0475a5ca 2870 if test "$needs_libsunmath" = "yes" ; then
75b5a697 2871 echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
0475a5ca 2872 fi
ec530c81 2873fi
179cf400
AF
2874if test "$haiku" = "yes" ; then
2875 echo "CONFIG_HAIKU=y" >> $config_host_mak
2876fi
97a847bc 2877if test "$static" = "yes" ; then
98ec69ac 2878 echo "CONFIG_STATIC=y" >> $config_host_mak
7d13299d 2879fi
1ba16968 2880if test "$profiler" = "yes" ; then
2358a494 2881 echo "CONFIG_PROFILER=y" >> $config_host_mak
05c2a3e7 2882fi
c20709aa 2883if test "$slirp" = "yes" ; then
98ec69ac 2884 echo "CONFIG_SLIRP=y" >> $config_host_mak
e2d8830e 2885 echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
f9728943 2886 QEMU_INCLUDES="-I\$(SRC_PATH)/slirp $QEMU_INCLUDES"
c20709aa 2887fi
8a16d273 2888if test "$vde" = "yes" ; then
98ec69ac 2889 echo "CONFIG_VDE=y" >> $config_host_mak
8a16d273 2890fi
0c58ac1c 2891for card in $audio_card_list; do
f6e5889e 2892 def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
98ec69ac 2893 echo "$def=y" >> $config_host_mak
0c58ac1c 2894done
2358a494 2895echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
0c58ac1c 2896for drv in $audio_drv_list; do
f6e5889e 2897 def=CONFIG_`echo $drv | tr '[:lower:]' '[:upper:]'`
98ec69ac 2898 echo "$def=y" >> $config_host_mak
923e4521 2899 if test "$drv" = "fmod"; then
7aac6cb1 2900 echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
0c58ac1c 2901 fi
2902done
67f86e8e
JQ
2903if test "$audio_pt_int" = "yes" ; then
2904 echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
2905fi
d5631638 2906if test "$audio_win_int" = "yes" ; then
2907 echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
2908fi
eb852011 2909echo "CONFIG_BDRV_WHITELIST=$block_drv_whitelist" >> $config_host_mak
8ff9cbf7 2910if test "$mixemu" = "yes" ; then
98ec69ac 2911 echo "CONFIG_MIXEMU=y" >> $config_host_mak
8ff9cbf7 2912fi
821601ea
JS
2913if test "$vnc" = "yes" ; then
2914 echo "CONFIG_VNC=y" >> $config_host_mak
2915fi
8d5d2d4c 2916if test "$vnc_tls" = "yes" ; then
98ec69ac 2917 echo "CONFIG_VNC_TLS=y" >> $config_host_mak
525061bf 2918 echo "VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_host_mak
8d5d2d4c 2919fi
2f9606b3 2920if test "$vnc_sasl" = "yes" ; then
98ec69ac 2921 echo "CONFIG_VNC_SASL=y" >> $config_host_mak
60ddf533 2922 echo "VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak
2f9606b3 2923fi
821601ea 2924if test "$vnc_jpeg" = "yes" ; then
2f6f5c7a
CC
2925 echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
2926 echo "VNC_JPEG_CFLAGS=$vnc_jpeg_cflags" >> $config_host_mak
2927fi
821601ea 2928if test "$vnc_png" = "yes" ; then
efe556ad
CC
2929 echo "CONFIG_VNC_PNG=y" >> $config_host_mak
2930 echo "VNC_PNG_CFLAGS=$vnc_png_cflags" >> $config_host_mak
2931fi
821601ea 2932if test "$vnc_thread" = "yes" ; then
bd023f95 2933 echo "CONFIG_VNC_THREAD=y" >> $config_host_mak
bd023f95 2934fi
76655d6d 2935if test "$fnmatch" = "yes" ; then
2358a494 2936 echo "CONFIG_FNMATCH=y" >> $config_host_mak
76655d6d 2937fi
ee682d27
SW
2938if test "$uuid" = "yes" ; then
2939 echo "CONFIG_UUID=y" >> $config_host_mak
2940fi
dce512de
CH
2941if test "$xfs" = "yes" ; then
2942 echo "CONFIG_XFS=y" >> $config_host_mak
2943fi
b1a550a0 2944qemu_version=`head $source_path/VERSION`
98ec69ac 2945echo "VERSION=$qemu_version" >>$config_host_mak
2358a494 2946echo "PKGVERSION=$pkgversion" >>$config_host_mak
98ec69ac 2947echo "SRC_PATH=$source_path" >> $config_host_mak
98ec69ac 2948echo "TARGET_DIRS=$target_list" >> $config_host_mak
a25dba17 2949if [ "$docs" = "yes" ] ; then
98ec69ac 2950 echo "BUILD_DOCS=yes" >> $config_host_mak
cc8ae6de 2951fi
1ac88f28 2952if test "$sdl" = "yes" ; then
98ec69ac 2953 echo "CONFIG_SDL=y" >> $config_host_mak
1ac88f28 2954 echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
49ecc3fa
FB
2955fi
2956if test "$cocoa" = "yes" ; then
98ec69ac 2957 echo "CONFIG_COCOA=y" >> $config_host_mak
4d3b6f6e
AZ
2958fi
2959if test "$curses" = "yes" ; then
98ec69ac 2960 echo "CONFIG_CURSES=y" >> $config_host_mak
49ecc3fa 2961fi
3b3f24ad 2962if test "$atfile" = "yes" ; then
2358a494 2963 echo "CONFIG_ATFILE=y" >> $config_host_mak
3b3f24ad 2964fi
ebc996f3 2965if test "$utimens" = "yes" ; then
2358a494 2966 echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
ebc996f3 2967fi
099d6b0f 2968if test "$pipe2" = "yes" ; then
2358a494 2969 echo "CONFIG_PIPE2=y" >> $config_host_mak
099d6b0f 2970fi
40ff6d7e
KW
2971if test "$accept4" = "yes" ; then
2972 echo "CONFIG_ACCEPT4=y" >> $config_host_mak
2973fi
3ce34dfb 2974if test "$splice" = "yes" ; then
2358a494 2975 echo "CONFIG_SPLICE=y" >> $config_host_mak
3ce34dfb 2976fi
c2882b96
RV
2977if test "$eventfd" = "yes" ; then
2978 echo "CONFIG_EVENTFD=y" >> $config_host_mak
2979fi
d0927938
UH
2980if test "$fallocate" = "yes" ; then
2981 echo "CONFIG_FALLOCATE=y" >> $config_host_mak
2982fi
c727f47d
PM
2983if test "$sync_file_range" = "yes" ; then
2984 echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
2985fi
dace20dc
PM
2986if test "$fiemap" = "yes" ; then
2987 echo "CONFIG_FIEMAP=y" >> $config_host_mak
2988fi
d0927938
UH
2989if test "$dup3" = "yes" ; then
2990 echo "CONFIG_DUP3=y" >> $config_host_mak
2991fi
3b6edd16
PM
2992if test "$epoll" = "yes" ; then
2993 echo "CONFIG_EPOLL=y" >> $config_host_mak
2994fi
2995if test "$epoll_create1" = "yes" ; then
2996 echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
2997fi
2998if test "$epoll_pwait" = "yes" ; then
2999 echo "CONFIG_EPOLL_PWAIT=y" >> $config_host_mak
3000fi
3b3f24ad 3001if test "$inotify" = "yes" ; then
2358a494 3002 echo "CONFIG_INOTIFY=y" >> $config_host_mak
3b3f24ad 3003fi
c05c7a73
RV
3004if test "$inotify1" = "yes" ; then
3005 echo "CONFIG_INOTIFY1=y" >> $config_host_mak
3006fi
6ae9a1f4
JQ
3007if test "$byteswap_h" = "yes" ; then
3008 echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
3009fi
3010if test "$bswap_h" = "yes" ; then
3011 echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
3012fi
769ce76d 3013if test "$curl" = "yes" ; then
98ec69ac 3014 echo "CONFIG_CURL=y" >> $config_host_mak
b1d5a277 3015 echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
769ce76d 3016fi
2e4d9fb1 3017if test "$brlapi" = "yes" ; then
98ec69ac 3018 echo "CONFIG_BRLAPI=y" >> $config_host_mak
2e4d9fb1 3019fi
fb599c9a 3020if test "$bluez" = "yes" ; then
98ec69ac 3021 echo "CONFIG_BLUEZ=y" >> $config_host_mak
ef7635ec 3022 echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
fb599c9a 3023fi
e18df141 3024echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
e37630ca 3025if test "$xen" = "yes" ; then
6dbd588a 3026 echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
d5b93ddf 3027 echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
e37630ca 3028fi
5c6c3a6c
CH
3029if test "$linux_aio" = "yes" ; then
3030 echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
3031fi
758e8e38
VJJ
3032if test "$attr" = "yes" ; then
3033 echo "CONFIG_ATTR=y" >> $config_host_mak
3034fi
3035if test "$linux" = "yes" ; then
3036 if test "$attr" = "yes" ; then
3037 echo "CONFIG_VIRTFS=y" >> $config_host_mak
3038 fi
3039fi
77755340 3040if test "$blobs" = "yes" ; then
98ec69ac 3041 echo "INSTALL_BLOBS=yes" >> $config_host_mak
77755340 3042fi
bf9298b9 3043if test "$iovec" = "yes" ; then
2358a494 3044 echo "CONFIG_IOVEC=y" >> $config_host_mak
bf9298b9 3045fi
ceb42de8 3046if test "$preadv" = "yes" ; then
2358a494 3047 echo "CONFIG_PREADV=y" >> $config_host_mak
ceb42de8 3048fi
f652e6af 3049if test "$fdt" = "yes" ; then
3f0855b1 3050 echo "CONFIG_FDT=y" >> $config_host_mak
f652e6af 3051fi
dcc38d1c
MT
3052if test "$signalfd" = "yes" ; then
3053 echo "CONFIG_SIGNALFD=y" >> $config_host_mak
3054fi
9195b2c2
SW
3055if test "$tcg_interpreter" = "yes" ; then
3056 echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
3057fi
de5071c5
BS
3058if test "$need_offsetof" = "yes" ; then
3059 echo "CONFIG_NEED_OFFSETOF=y" >> $config_host_mak
3060fi
5f6b9e8f
BS
3061if test "$fdatasync" = "yes" ; then
3062 echo "CONFIG_FDATASYNC=y" >> $config_host_mak
3063fi
e78815a5
AF
3064if test "$madvise" = "yes" ; then
3065 echo "CONFIG_MADVISE=y" >> $config_host_mak
3066fi
3067if test "$posix_madvise" = "yes" ; then
3068 echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
3069fi
97a847bc 3070
cd4ec0b4
GH
3071if test "$spice" = "yes" ; then
3072 echo "CONFIG_SPICE=y" >> $config_host_mak
3073fi
36707144
AL
3074
3075if test "$smartcard" = "yes" ; then
3076 echo "CONFIG_SMARTCARD=y" >> $config_host_mak
3077fi
cd4ec0b4 3078
111a38b0
RR
3079if test "$smartcard_nss" = "yes" ; then
3080 echo "CONFIG_SMARTCARD_NSS=y" >> $config_host_mak
3081fi
3082
69354a83
HG
3083if test "$usb_redir" = "yes" ; then
3084 echo "CONFIG_USB_REDIR=y" >> $config_host_mak
3085fi
3086
20ff075b
MW
3087if test "$opengl" = "yes" ; then
3088 echo "CONFIG_OPENGL=y" >> $config_host_mak
3089fi
3090
c589b249
RS
3091if test "$libiscsi" = "yes" ; then
3092 echo "CONFIG_LIBISCSI=y" >> $config_host_mak
3093fi
3094
83fb7adf 3095# XXX: suppress that
7d3505c5 3096if [ "$bsd" = "yes" ] ; then
2358a494 3097 echo "CONFIG_BSD=y" >> $config_host_mak
7d3505c5
FB
3098fi
3099
2358a494 3100echo "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
c5937220 3101
20ff6c80
AL
3102if test "$zero_malloc" = "yes" ; then
3103 echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
3104fi
f27aaf4b
CB
3105if test "$rbd" = "yes" ; then
3106 echo "CONFIG_RBD=y" >> $config_host_mak
d0e2fce5
AK
3107fi
3108
3109if test "$ucontext_coroutine" = "yes" ; then
3110 echo "CONFIG_UCONTEXT_COROUTINE=y" >> $config_host_mak
f27aaf4b 3111fi
20ff6c80 3112
d2042378
AK
3113if test "$open_by_handle_at" = "yes" ; then
3114 echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
3115fi
3116
e06a765e
HPB
3117if test "$linux_magic_h" = "yes" ; then
3118 echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
3119fi
3120
68063649
BS
3121# USB host support
3122case "$usb" in
3123linux)
98ec69ac 3124 echo "HOST_USB=linux" >> $config_host_mak
68063649
BS
3125;;
3126bsd)
98ec69ac 3127 echo "HOST_USB=bsd" >> $config_host_mak
68063649
BS
3128;;
3129*)
98ec69ac 3130 echo "HOST_USB=stub" >> $config_host_mak
68063649
BS
3131;;
3132esac
3133
e4858974
L
3134# use default implementation for tracing backend-specific routines
3135trace_default=yes
94a420b1 3136echo "TRACE_BACKEND=$trace_backend" >> $config_host_mak
6d8a764e
L
3137if test "$trace_backend" = "nop"; then
3138 echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
22890ab5 3139fi
9410b56c 3140if test "$trace_backend" = "simple"; then
6d8a764e 3141 echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
e4858974 3142 trace_default=no
6d8a764e 3143 # Set the appropriate trace file.
953ffe0f 3144 trace_file="\"$trace_file-\" FMT_pid"
9410b56c 3145fi
6d8a764e
L
3146if test "$trace_backend" = "stderr"; then
3147 echo "CONFIG_TRACE_STDERR=y" >> $config_host_mak
9a82b6a5 3148 trace_default=no
6d8a764e
L
3149fi
3150if test "$trace_backend" = "ust"; then
3151 echo "CONFIG_TRACE_UST=y" >> $config_host_mak
3152fi
3153if test "$trace_backend" = "dtrace"; then
3154 echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
3155 if test "$trace_backend_stap" = "yes" ; then
3156 echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
3157 fi
c276b17d 3158fi
9410b56c 3159echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
e4858974
L
3160if test "$trace_default" = "yes"; then
3161 echo "CONFIG_TRACE_DEFAULT=y" >> $config_host_mak
3162fi
9410b56c 3163
98ec69ac 3164echo "TOOLS=$tools" >> $config_host_mak
fffbeb75 3165echo "CHECKS=$checks" >> $config_host_mak
98ec69ac 3166echo "ROMS=$roms" >> $config_host_mak
804edf29
JQ
3167echo "MAKE=$make" >> $config_host_mak
3168echo "INSTALL=$install" >> $config_host_mak
1901cb14
B
3169echo "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
3170echo "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
3171echo "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
c886edfb 3172echo "PYTHON=$python" >> $config_host_mak
804edf29 3173echo "CC=$cc" >> $config_host_mak
2b2e59e6 3174echo "CC_I386=$cc_i386" >> $config_host_mak
804edf29 3175echo "HOST_CC=$host_cc" >> $config_host_mak
804edf29
JQ
3176echo "AR=$ar" >> $config_host_mak
3177echo "OBJCOPY=$objcopy" >> $config_host_mak
3178echo "LD=$ld" >> $config_host_mak
9fe6de94 3179echo "WINDRES=$windres" >> $config_host_mak
44dc0ca3 3180echo "LIBTOOL=$libtool" >> $config_host_mak
e2a2ed06 3181echo "CFLAGS=$CFLAGS" >> $config_host_mak
a558ee17 3182echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
f9728943 3183echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
e39f0062
PB
3184if test "$sparse" = "yes" ; then
3185 echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_host_mak
3186 echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_host_mak
3187 echo "QEMU_CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
3188fi
c81da56e 3189echo "HELPER_CFLAGS=$helper_cflags" >> $config_host_mak
e2a2ed06 3190echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
a36abbbb
JQ
3191echo "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak
3192echo "ARLIBS_END=$arlibs_end" >> $config_host_mak
73da375e 3193echo "LIBS+=$LIBS" >> $config_host_mak
3e2e0e6b 3194echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
804edf29 3195echo "EXESUF=$EXESUF" >> $config_host_mak
957f1f99 3196echo "LIBS_QGA+=$libs_qga" >> $config_host_mak
804edf29 3197
4bf6b55b
JQ
3198# generate list of library paths for linker script
3199
3200$ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
3201
3202if test -f ${config_host_ld}~ ; then
3203 if cmp -s $config_host_ld ${config_host_ld}~ ; then
3204 mv ${config_host_ld}~ $config_host_ld
3205 else
3206 rm ${config_host_ld}~
3207 fi
3208fi
3209
4d904533
BS
3210for d in libdis libdis-user; do
3211 mkdir -p $d
11568d6d 3212 symlink $source_path/Makefile.dis $d/Makefile
4d904533
BS
3213 echo > $d/config.mak
3214done
d44cff22
RH
3215if test "$static" = "no" -a "$user_pie" = "yes" ; then
3216 echo "QEMU_CFLAGS+=-fpie" > libdis-user/config.mak
3217fi
4d904533 3218
1d14ffa9 3219for target in $target_list; do
97a847bc 3220target_dir="$target"
25be210f 3221config_target_mak=$target_dir/config-target.mak
600309b6 3222target_arch2=`echo $target | cut -d '-' -f 1`
97a847bc 3223target_bigendian="no"
1f3d3c8f 3224
ea2d6a39 3225case "$target_arch2" in
cfa550c6 3226 armeb|lm32|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
ea2d6a39
JQ
3227 target_bigendian=yes
3228 ;;
3229esac
97a847bc 3230target_softmmu="no"
997344f3 3231target_user_only="no"
831b7825 3232target_linux_user="no"
831b7825 3233target_darwin_user="no"
84778508 3234target_bsd_user="no"
9e407a85 3235case "$target" in
600309b6 3236 ${target_arch2}-softmmu)
9e407a85
PB
3237 target_softmmu="yes"
3238 ;;
600309b6 3239 ${target_arch2}-linux-user)
9c7a4202
BS
3240 if test "$linux" != "yes" ; then
3241 echo "ERROR: Target '$target' is only available on a Linux host"
3242 exit 1
3243 fi
9e407a85
PB
3244 target_user_only="yes"
3245 target_linux_user="yes"
3246 ;;
600309b6 3247 ${target_arch2}-darwin-user)
9c7a4202
BS
3248 if test "$darwin" != "yes" ; then
3249 echo "ERROR: Target '$target' is only available on a Darwin host"
3250 exit 1
3251 fi
9e407a85
PB
3252 target_user_only="yes"
3253 target_darwin_user="yes"
3254 ;;
600309b6 3255 ${target_arch2}-bsd-user)
9cf55765 3256 if test "$bsd" != "yes" ; then
9c7a4202
BS
3257 echo "ERROR: Target '$target' is only available on a BSD host"
3258 exit 1
3259 fi
84778508
BS
3260 target_user_only="yes"
3261 target_bsd_user="yes"
3262 ;;
9e407a85
PB
3263 *)
3264 echo "ERROR: Target '$target' not recognised"
3265 exit 1
3266 ;;
3267esac
831b7825 3268
97a847bc 3269mkdir -p $target_dir
158142c2 3270mkdir -p $target_dir/fpu
57fec1fe 3271mkdir -p $target_dir/tcg
59f2a787 3272mkdir -p $target_dir/ide
353ac78d 3273mkdir -p $target_dir/9pfs
84778508 3274if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
69de927c
FB
3275 mkdir -p $target_dir/nwfpe
3276fi
11568d6d 3277symlink $source_path/Makefile.target $target_dir/Makefile
ec530c81 3278
97a847bc 3279
25be210f 3280echo "# Automatically generated by configure - do not modify" > $config_target_mak
de83cd02 3281
e5fe0c52 3282bflt="no"
bd0c5661 3283target_nptl="no"
600309b6 3284interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
7ee2822c 3285echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
56aebc89 3286gdb_xml_files=""
c2e3dee6
LV
3287target_short_alignment=2
3288target_int_alignment=4
3289target_long_alignment=4
3290target_llong_alignment=8
de3a354a 3291target_libs_softmmu=
7ba1e619 3292
938b1edd 3293TARGET_ARCH="$target_arch2"
6acff7da 3294TARGET_BASE_ARCH=""
e6e91b9c 3295TARGET_ABI_DIR=""
e73aae67 3296
600309b6 3297case "$target_arch2" in
2408a527 3298 i386)
71deff27 3299 target_phys_bits=64
2408a527
AJ
3300 ;;
3301 x86_64)
6acff7da 3302 TARGET_BASE_ARCH=i386
1ad2134f 3303 target_phys_bits=64
c2e3dee6 3304 target_long_alignment=8
2408a527
AJ
3305 ;;
3306 alpha)
1ad2134f 3307 target_phys_bits=64
c2e3dee6 3308 target_long_alignment=8
a4b388ff 3309 target_nptl="yes"
2408a527
AJ
3310 ;;
3311 arm|armeb)
b498c8a0 3312 TARGET_ARCH=arm
2408a527 3313 bflt="yes"
bd0c5661 3314 target_nptl="yes"
56aebc89 3315 gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
1ad2134f 3316 target_phys_bits=32
c2e3dee6 3317 target_llong_alignment=4
2408a527
AJ
3318 ;;
3319 cris)
253bd7f8 3320 target_nptl="yes"
1ad2134f 3321 target_phys_bits=32
2408a527 3322 ;;
613a22c9
MW
3323 lm32)
3324 target_phys_bits=32
de3a354a 3325 target_libs_softmmu="$opengl_libs"
613a22c9 3326 ;;
2408a527 3327 m68k)
2408a527 3328 bflt="yes"
56aebc89 3329 gdb_xml_files="cf-core.xml cf-fp.xml"
1ad2134f 3330 target_phys_bits=32
c2e3dee6
LV
3331 target_int_alignment=2
3332 target_long_alignment=2
3333 target_llong_alignment=2
2408a527 3334 ;;
877fdc12
EI
3335 microblaze|microblazeel)
3336 TARGET_ARCH=microblaze
72b675ca
EI
3337 bflt="yes"
3338 target_nptl="yes"
3339 target_phys_bits=32
de3a354a 3340 target_libs_softmmu="$fdt_libs"
72b675ca 3341 ;;
0adcffb1 3342 mips|mipsel)
b498c8a0 3343 TARGET_ARCH=mips
25be210f 3344 echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
f04dc72f 3345 target_nptl="yes"
1ad2134f 3346 target_phys_bits=64
2408a527
AJ
3347 ;;
3348 mipsn32|mipsn32el)
b498c8a0 3349 TARGET_ARCH=mipsn32
6acff7da 3350 TARGET_BASE_ARCH=mips
25be210f 3351 echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
1ad2134f 3352 target_phys_bits=64
2408a527
AJ
3353 ;;
3354 mips64|mips64el)
b498c8a0 3355 TARGET_ARCH=mips64
6acff7da 3356 TARGET_BASE_ARCH=mips
25be210f 3357 echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
1ad2134f 3358 target_phys_bits=64
c2e3dee6 3359 target_long_alignment=8
2408a527
AJ
3360 ;;
3361 ppc)
c8b3532d 3362 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
8b242eba 3363 target_phys_bits=64
d6630708 3364 target_nptl="yes"
de3a354a 3365 target_libs_softmmu="$fdt_libs"
2408a527
AJ
3366 ;;
3367 ppcemb)
6acff7da 3368 TARGET_BASE_ARCH=ppc
e6e91b9c 3369 TARGET_ABI_DIR=ppc
c8b3532d 3370 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
1ad2134f 3371 target_phys_bits=64
d6630708 3372 target_nptl="yes"
de3a354a 3373 target_libs_softmmu="$fdt_libs"
2408a527
AJ
3374 ;;
3375 ppc64)
6acff7da 3376 TARGET_BASE_ARCH=ppc
e6e91b9c 3377 TARGET_ABI_DIR=ppc
c8b3532d 3378 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
1ad2134f 3379 target_phys_bits=64
c2e3dee6 3380 target_long_alignment=8
de3a354a 3381 target_libs_softmmu="$fdt_libs"
2408a527
AJ
3382 ;;
3383 ppc64abi32)
b498c8a0 3384 TARGET_ARCH=ppc64
6acff7da 3385 TARGET_BASE_ARCH=ppc
e6e91b9c 3386 TARGET_ABI_DIR=ppc
25be210f 3387 echo "TARGET_ABI32=y" >> $config_target_mak
c8b3532d 3388 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
1ad2134f 3389 target_phys_bits=64
de3a354a 3390 target_libs_softmmu="$fdt_libs"
2408a527
AJ
3391 ;;
3392 sh4|sh4eb)
b498c8a0 3393 TARGET_ARCH=sh4
2408a527 3394 bflt="yes"
0b6d3ae0 3395 target_nptl="yes"
1ad2134f 3396 target_phys_bits=32
2408a527
AJ
3397 ;;
3398 sparc)
1ad2134f 3399 target_phys_bits=64
2408a527
AJ
3400 ;;
3401 sparc64)
6acff7da 3402 TARGET_BASE_ARCH=sparc
1ad2134f 3403 target_phys_bits=64
c2e3dee6 3404 target_long_alignment=8
2408a527
AJ
3405 ;;
3406 sparc32plus)
b498c8a0 3407 TARGET_ARCH=sparc64
6acff7da 3408 TARGET_BASE_ARCH=sparc
e6e91b9c 3409 TARGET_ABI_DIR=sparc
25be210f 3410 echo "TARGET_ABI32=y" >> $config_target_mak
1ad2134f 3411 target_phys_bits=64
2408a527 3412 ;;
24e804ec 3413 s390x)
bc434676 3414 target_nptl="yes"
24e804ec 3415 target_phys_bits=64
7b3da903 3416 target_long_alignment=8
24e804ec 3417 ;;
d2fbca94
GX
3418 unicore32)
3419 target_phys_bits=32
3420 ;;
cfa550c6
MF
3421 xtensa|xtensaeb)
3422 TARGET_ARCH=xtensa
3423 target_phys_bits=32
3424 ;;
2408a527
AJ
3425 *)
3426 echo "Unsupported target CPU"
3427 exit 1
3428 ;;
3429esac
c2e3dee6
LV
3430echo "TARGET_SHORT_ALIGNMENT=$target_short_alignment" >> $config_target_mak
3431echo "TARGET_INT_ALIGNMENT=$target_int_alignment" >> $config_target_mak
3432echo "TARGET_LONG_ALIGNMENT=$target_long_alignment" >> $config_target_mak
3433echo "TARGET_LLONG_ALIGNMENT=$target_llong_alignment" >> $config_target_mak
25be210f 3434echo "TARGET_ARCH=$TARGET_ARCH" >> $config_target_mak
053dd92e 3435target_arch_name="`echo $TARGET_ARCH | tr '[:lower:]' '[:upper:]'`"
25be210f
JQ
3436echo "TARGET_$target_arch_name=y" >> $config_target_mak
3437echo "TARGET_ARCH2=$target_arch2" >> $config_target_mak
42bc608b 3438# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
6acff7da
JQ
3439if [ "$TARGET_BASE_ARCH" = "" ]; then
3440 TARGET_BASE_ARCH=$TARGET_ARCH
6acff7da 3441fi
25be210f 3442echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
e6e91b9c
JQ
3443if [ "$TARGET_ABI_DIR" = "" ]; then
3444 TARGET_ABI_DIR=$TARGET_ARCH
3445fi
25be210f 3446echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
1b0c87fc
JQ
3447case "$target_arch2" in
3448 i386|x86_64)
3449 if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
64b3cfdb 3450 target_phys_bits=64
25be210f 3451 echo "CONFIG_XEN=y" >> $config_target_mak
59d21e53
AG
3452 else
3453 echo "CONFIG_NO_XEN=y" >> $config_target_mak
1b0c87fc 3454 fi
59d21e53
AG
3455 ;;
3456 *)
3457 echo "CONFIG_NO_XEN=y" >> $config_target_mak
1b0c87fc 3458esac
c59249f9 3459case "$target_arch2" in
0e60a699 3460 i386|x86_64|ppcemb|ppc|ppc64|s390x)
c59249f9
JQ
3461 # Make sure the target and host cpus are compatible
3462 if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
3463 \( "$target_arch2" = "$cpu" -o \
3464 \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
5f114bc6 3465 \( "$target_arch2" = "ppc64" -a "$cpu" = "ppc" \) -o \
adf82011
RR
3466 \( "$target_arch2" = "ppc" -a "$cpu" = "ppc64" \) -o \
3467 \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc64" \) -o \
c59249f9
JQ
3468 \( "$target_arch2" = "x86_64" -a "$cpu" = "i386" \) -o \
3469 \( "$target_arch2" = "i386" -a "$cpu" = "x86_64" \) \) ; then
25be210f 3470 echo "CONFIG_KVM=y" >> $config_target_mak
1ba16968 3471 if test "$vhost_net" = "yes" ; then
d5970055
MT
3472 echo "CONFIG_VHOST_NET=y" >> $config_target_mak
3473 fi
c59249f9
JQ
3474 fi
3475esac
7f762366 3476if test "$target_arch2" = "ppc64" -a "$fdt" = "yes"; then
0a6b8dde
AG
3477 echo "CONFIG_PSERIES=y" >> $config_target_mak
3478fi
de83cd02 3479if test "$target_bigendian" = "yes" ; then
25be210f 3480 echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
de83cd02 3481fi
97a847bc 3482if test "$target_softmmu" = "yes" ; then
b1aa27c4 3483 echo "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_target_mak
25be210f 3484 echo "CONFIG_SOFTMMU=y" >> $config_target_mak
de3a354a 3485 echo "LIBS+=$libs_softmmu $target_libs_softmmu" >> $config_target_mak
0e8c9214 3486 echo "HWDIR=../libhw$target_phys_bits" >> $config_target_mak
5791f45b 3487 echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
43ce4dfe 3488fi
997344f3 3489if test "$target_user_only" = "yes" ; then
25be210f 3490 echo "CONFIG_USER_ONLY=y" >> $config_target_mak
997344f3 3491fi
831b7825 3492if test "$target_linux_user" = "yes" ; then
25be210f 3493 echo "CONFIG_LINUX_USER=y" >> $config_target_mak
831b7825
TS
3494fi
3495if test "$target_darwin_user" = "yes" ; then
25be210f 3496 echo "CONFIG_DARWIN_USER=y" >> $config_target_mak
831b7825 3497fi
111a38b0
RR
3498if test "$smartcard_nss" = "yes" ; then
3499 echo "subdir-$target: subdir-libcacard" >> $config_host_mak
3500 echo "libcacard_libs=$libcacard_libs" >> $config_host_mak
3501 echo "libcacard_cflags=$libcacard_cflags" >> $config_host_mak
3502fi
56aebc89
PB
3503list=""
3504if test ! -z "$gdb_xml_files" ; then
3505 for x in $gdb_xml_files; do
3506 list="$list $source_path/gdb-xml/$x"
3507 done
3d0f1517 3508 echo "TARGET_XML_FILES=$list" >> $config_target_mak
56aebc89 3509fi
97a847bc 3510
e5fe0c52 3511if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
25be210f 3512 echo "TARGET_HAS_BFLT=y" >> $config_target_mak
e5fe0c52 3513fi
bd0c5661
PB
3514if test "$target_user_only" = "yes" \
3515 -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
25be210f 3516 echo "CONFIG_USE_NPTL=y" >> $config_target_mak
bd0c5661 3517fi
379f6698 3518if test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
25be210f 3519 echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
379f6698 3520fi
84778508 3521if test "$target_bsd_user" = "yes" ; then
25be210f 3522 echo "CONFIG_BSD_USER=y" >> $config_target_mak
84778508 3523fi
5b0753e0 3524
4afddb55 3525# generate QEMU_CFLAGS/LDFLAGS for targets
fa282484 3526
4afddb55 3527cflags=""
f9728943 3528includes=""
fa282484 3529ldflags=""
9b8e111f 3530
9195b2c2
SW
3531if test "$tcg_interpreter" = "yes"; then
3532 includes="-I\$(SRC_PATH)/tcg/tci $includes"
3533elif test "$ARCH" = "sparc64" ; then
f9728943 3534 includes="-I\$(SRC_PATH)/tcg/sparc $includes"
24e804ec 3535elif test "$ARCH" = "s390x" ; then
f9728943 3536 includes="-I\$(SRC_PATH)/tcg/s390 $includes"
5d8a4f8f 3537elif test "$ARCH" = "x86_64" ; then
f9728943 3538 includes="-I\$(SRC_PATH)/tcg/i386 $includes"
57ddfbf7 3539else
f9728943 3540 includes="-I\$(SRC_PATH)/tcg/\$(ARCH) $includes"
57ddfbf7 3541fi
f9728943 3542includes="-I\$(SRC_PATH)/tcg $includes"
57ddfbf7 3543
4d904533
BS
3544if test "$target_user_only" = "yes" ; then
3545 libdis_config_mak=libdis-user/config.mak
3546else
3547 libdis_config_mak=libdis/config.mak
3548fi
3549
64656024
JQ
3550for i in $ARCH $TARGET_BASE_ARCH ; do
3551 case "$i" in
3552 alpha)
25be210f 3553 echo "CONFIG_ALPHA_DIS=y" >> $config_target_mak
4d904533 3554 echo "CONFIG_ALPHA_DIS=y" >> $libdis_config_mak
64656024
JQ
3555 ;;
3556 arm)
25be210f 3557 echo "CONFIG_ARM_DIS=y" >> $config_target_mak
4d904533 3558 echo "CONFIG_ARM_DIS=y" >> $libdis_config_mak
64656024
JQ
3559 ;;
3560 cris)
25be210f 3561 echo "CONFIG_CRIS_DIS=y" >> $config_target_mak
4d904533 3562 echo "CONFIG_CRIS_DIS=y" >> $libdis_config_mak
64656024
JQ
3563 ;;
3564 hppa)
25be210f 3565 echo "CONFIG_HPPA_DIS=y" >> $config_target_mak
4d904533 3566 echo "CONFIG_HPPA_DIS=y" >> $libdis_config_mak
64656024
JQ
3567 ;;
3568 i386|x86_64)
25be210f 3569 echo "CONFIG_I386_DIS=y" >> $config_target_mak
4d904533 3570 echo "CONFIG_I386_DIS=y" >> $libdis_config_mak
64656024 3571 ;;
903ec55c
AJ
3572 ia64*)
3573 echo "CONFIG_IA64_DIS=y" >> $config_target_mak
3574 echo "CONFIG_IA64_DIS=y" >> $libdis_config_mak
3575 ;;
64656024 3576 m68k)
25be210f 3577 echo "CONFIG_M68K_DIS=y" >> $config_target_mak
4d904533 3578 echo "CONFIG_M68K_DIS=y" >> $libdis_config_mak
64656024 3579 ;;
877fdc12 3580 microblaze*)
25be210f 3581 echo "CONFIG_MICROBLAZE_DIS=y" >> $config_target_mak
4d904533 3582 echo "CONFIG_MICROBLAZE_DIS=y" >> $libdis_config_mak
64656024
JQ
3583 ;;
3584 mips*)
25be210f 3585 echo "CONFIG_MIPS_DIS=y" >> $config_target_mak
4d904533 3586 echo "CONFIG_MIPS_DIS=y" >> $libdis_config_mak
64656024
JQ
3587 ;;
3588 ppc*)
25be210f 3589 echo "CONFIG_PPC_DIS=y" >> $config_target_mak
4d904533 3590 echo "CONFIG_PPC_DIS=y" >> $libdis_config_mak
64656024 3591 ;;
24e804ec 3592 s390*)
25be210f 3593 echo "CONFIG_S390_DIS=y" >> $config_target_mak
4d904533 3594 echo "CONFIG_S390_DIS=y" >> $libdis_config_mak
64656024
JQ
3595 ;;
3596 sh4)
25be210f 3597 echo "CONFIG_SH4_DIS=y" >> $config_target_mak
4d904533 3598 echo "CONFIG_SH4_DIS=y" >> $libdis_config_mak
64656024
JQ
3599 ;;
3600 sparc*)
25be210f 3601 echo "CONFIG_SPARC_DIS=y" >> $config_target_mak
4d904533 3602 echo "CONFIG_SPARC_DIS=y" >> $libdis_config_mak
64656024 3603 ;;
cfa550c6
MF
3604 xtensa*)
3605 echo "CONFIG_XTENSA_DIS=y" >> $config_target_mak
3606 echo "CONFIG_XTENSA_DIS=y" >> $libdis_config_mak
3607 ;;
64656024
JQ
3608 esac
3609done
9195b2c2
SW
3610if test "$tcg_interpreter" = "yes" ; then
3611 echo "CONFIG_TCI_DIS=y" >> $config_target_mak
3612 echo "CONFIG_TCI_DIS=y" >> $libdis_config_mak
3613fi
64656024 3614
6ee7126f
JQ
3615case "$ARCH" in
3616alpha)
3617 # Ensure there's only a single GP
3618 cflags="-msmall-data $cflags"
3619;;
3620esac
3621
55d9c04b
JQ
3622if test "$target_softmmu" = "yes" ; then
3623 case "$TARGET_BASE_ARCH" in
3624 arm)
3625 cflags="-DHAS_AUDIO $cflags"
25a8bb96
MW
3626 ;;
3627 lm32)
3628 cflags="-DHAS_AUDIO $cflags"
55d9c04b
JQ
3629 ;;
3630 i386|mips|ppc)
3631 cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags"
3632 ;;
3633 esac
3634fi
3635
34005a00 3636if test "$target_user_only" = "yes" -a "$static" = "no" -a \
50108930 3637 "$user_pie" = "yes" ; then
34005a00
KS
3638 cflags="-fpie $cflags"
3639 ldflags="-pie $ldflags"
3640fi
3641
471857dd
JQ
3642if test "$target_softmmu" = "yes" -a \( \
3643 "$TARGET_ARCH" = "microblaze" -o \
3644 "$TARGET_ARCH" = "cris" \) ; then
25be210f 3645 echo "CONFIG_NEED_MMU=y" >> $config_target_mak
471857dd
JQ
3646fi
3647
d02c1db3 3648if test "$gprof" = "yes" ; then
25be210f 3649 echo "TARGET_GPROF=yes" >> $config_target_mak
d02c1db3
JQ
3650 if test "$target_linux_user" = "yes" ; then
3651 cflags="-p $cflags"
3652 ldflags="-p $ldflags"
3653 fi
3654 if test "$target_softmmu" = "yes" ; then
3655 ldflags="-p $ldflags"
25be210f 3656 echo "GPROF_CFLAGS=-p" >> $config_target_mak
d02c1db3
JQ
3657 fi
3658fi
3659
9195b2c2
SW
3660if test "$ARCH" = "tci"; then
3661 linker_script=""
3662else
3663 linker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/\$(ARCH).ld"
3664fi
3665
9b8e111f 3666if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
fa282484 3667 case "$ARCH" in
fa282484
JQ
3668 sparc)
3669 # -static is used to avoid g1/g3 usage by the dynamic linker
322e5878 3670 ldflags="$linker_script -static $ldflags"
fa282484 3671 ;;
4d58be06
RH
3672 alpha | s390x)
3673 # The default placement of the application is fine.
3674 ;;
fd76e73a 3675 *)
322e5878 3676 ldflags="$linker_script $ldflags"
fa282484
JQ
3677 ;;
3678 esac
3679fi
fa282484 3680
e205c790 3681# use included Linux headers
af2be207
JK
3682if test "$linux" = "yes" ; then
3683 includes="-I\$(SRC_PATH)/linux-headers $includes"
3684 mkdir -p linux-headers
3685 case "$cpu" in
3686 i386|x86_64)
3687 symlink $source_path/linux-headers/asm-x86 linux-headers/asm
3688 ;;
3689 ppcemb|ppc|ppc64)
3690 symlink $source_path/linux-headers/asm-powerpc linux-headers/asm
3691 ;;
3692 s390x)
3693 symlink $source_path/linux-headers/asm-s390 linux-headers/asm
3694 ;;
3695 esac
3696fi
e205c790 3697
25be210f
JQ
3698echo "LDFLAGS+=$ldflags" >> $config_target_mak
3699echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak
f9728943 3700echo "QEMU_INCLUDES+=$includes" >> $config_target_mak
fa282484 3701
97a847bc 3702done # for target in $targets
7d13299d 3703
d1807a4f
PB
3704# build tree in object directory in case the source is not in the current directory
3705DIRS="tests tests/cris slirp audio block net pc-bios/optionrom"
446b9165 3706DIRS="$DIRS pc-bios/spapr-rtas"
d1807a4f
PB
3707DIRS="$DIRS roms/seabios roms/vgabios"
3708DIRS="$DIRS fsdev ui"
e098fc3f 3709DIRS="$DIRS qapi qapi-generated"
d9cd446b 3710DIRS="$DIRS qga trace"
70371cfb 3711FILES="Makefile tests/Makefile qdict-test-data.txt"
d1807a4f
PB
3712FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
3713FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
446b9165 3714FILES="$FILES pc-bios/spapr-rtas/Makefile"
d1807a4f 3715FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
753d11f2
RH
3716for bios_file in \
3717 $source_path/pc-bios/*.bin \
3718 $source_path/pc-bios/*.rom \
3719 $source_path/pc-bios/*.dtb \
3720 $source_path/pc-bios/openbios-* \
3721 $source_path/pc-bios/palcode-*
3722do
d1807a4f
PB
3723 FILES="$FILES pc-bios/`basename $bios_file`"
3724done
3725mkdir -p $DIRS
3726for f in $FILES ; do
f9245e10
PM
3727 if [ -e "$source_path/$f" ] && ! [ -e "$f" ]; then
3728 symlink "$source_path/$f" "$f"
3729 fi
d1807a4f 3730done
1ad2134f 3731
c34ebfdc 3732# temporary config to build submodules
2d9f27d2 3733for rom in seabios vgabios ; do
c34ebfdc 3734 config_mak=roms/$rom/config.mak
37116c89 3735 echo "# Automatically generated by configure - do not modify" > $config_mak
c34ebfdc
AL
3736 echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
3737 echo "CC=$cc" >> $config_mak
3738 echo "BCC=bcc" >> $config_mak
3739 echo "CPP=${cross_prefix}cpp" >> $config_mak
3740 echo "OBJCOPY=objcopy" >> $config_mak
3741 echo "IASL=iasl" >> $config_mak
c34ebfdc
AL
3742 echo "LD=$ld" >> $config_mak
3743done
3744
1ad2134f
PB
3745for hwlib in 32 64; do
3746 d=libhw$hwlib
3747 mkdir -p $d
9953b2fc 3748 mkdir -p $d/ide
11568d6d 3749 symlink $source_path/Makefile.hw $d/Makefile
353ac78d 3750 mkdir -p $d/9pfs
37116c89 3751 echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" > $d/config.mak
1ad2134f 3752done
add16157 3753
111a38b0
RR
3754if [ "$source_path" != `pwd` ]; then
3755 # out of tree build
3756 mkdir -p libcacard
3757 rm -f libcacard/Makefile
44dc0ca3 3758 symlink "$source_path/libcacard/Makefile" libcacard/Makefile
111a38b0
RR
3759fi
3760
add16157
BS
3761d=libuser
3762mkdir -p $d
937b1258 3763mkdir -p $d/trace
11568d6d 3764symlink $source_path/Makefile.user $d/Makefile
299060a0
KS
3765if test "$static" = "no" -a "$user_pie" = "yes" ; then
3766 echo "QEMU_CFLAGS+=-fpie" > $d/config.mak
3767fi
b40292e7
JK
3768
3769if test "$docs" = "yes" ; then
3770 mkdir -p QMP
3771fi