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