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