]> git.proxmox.com Git - mirror_qemu.git/blame - configure
crypto: add cryptographic random byte source
[mirror_qemu.git] / configure
CommitLineData
7d13299d
FB
1#!/bin/sh
2#
3ef693a0 3# qemu configure script (c) 2003 Fabrice Bellard
7d13299d 4#
8cd05ab6 5
99519e67
CH
6# Unset some variables known to interfere with behavior of common tools,
7# just as autoconf does.
8CLICOLOR_FORCE= GREP_OPTIONS=
9unset CLICOLOR_FORCE GREP_OPTIONS
10
5e4dfd3d
JS
11# Don't allow CCACHE, if present, to use cached results of compile tests!
12export CCACHE_RECACHE=yes
13
8cd05ab6
PM
14# Temporary directory used for files created while
15# configure runs. Since it is in the build directory
16# we can safely blow away any previous version of it
17# (and we need not jump through hoops to try to delete
18# it when configure exits.)
19TMPDIR1="config-temp"
20rm -rf "${TMPDIR1}"
21mkdir -p "${TMPDIR1}"
22if [ $? -ne 0 ]; then
23 echo "ERROR: failed to create temporary directory"
24 exit 1
7d13299d
FB
25fi
26
8cd05ab6
PM
27TMPB="qemu-conf"
28TMPC="${TMPDIR1}/${TMPB}.c"
66518bf6 29TMPO="${TMPDIR1}/${TMPB}.o"
9c83ffd8 30TMPCXX="${TMPDIR1}/${TMPB}.cxx"
66518bf6
DS
31TMPL="${TMPDIR1}/${TMPB}.lo"
32TMPA="${TMPDIR1}/lib${TMPB}.la"
8cd05ab6 33TMPE="${TMPDIR1}/${TMPB}.exe"
7d13299d 34
da1d85e3 35rm -f config.log
9ac81bbb 36
b48e3611
PM
37# Print a helpful header at the top of config.log
38echo "# QEMU configure log $(date)" >> config.log
979ae168
PM
39printf "# Configured with:" >> config.log
40printf " '%s'" "$0" "$@" >> config.log
41echo >> config.log
b48e3611
PM
42echo "#" >> config.log
43
76ad07a4
PM
44error_exit() {
45 echo
46 echo "ERROR: $1"
47 while test -n "$2"; do
48 echo " $2"
49 shift
50 done
51 echo
52 exit 1
53}
54
9c83ffd8
PM
55do_compiler() {
56 # Run the compiler, capturing its output to the log. First argument
57 # is compiler binary to execute.
58 local compiler="$1"
59 shift
60 echo $compiler "$@" >> config.log
61 $compiler "$@" >> config.log 2>&1 || return $?
8dc38a78
PM
62 # Test passed. If this is an --enable-werror build, rerun
63 # the test with -Werror and bail out if it fails. This
64 # makes warning-generating-errors in configure test code
65 # obvious to developers.
66 if test "$werror" != "yes"; then
67 return 0
68 fi
69 # Don't bother rerunning the compile if we were already using -Werror
70 case "$*" in
71 *-Werror*)
72 return 0
73 ;;
74 esac
9c83ffd8
PM
75 echo $compiler -Werror "$@" >> config.log
76 $compiler -Werror "$@" >> config.log 2>&1 && return $?
76ad07a4
PM
77 error_exit "configure test passed without -Werror but failed with -Werror." \
78 "This is probably a bug in the configure script. The failing command" \
79 "will be at the bottom of config.log." \
80 "You can run configure with --disable-werror to bypass this check."
8dc38a78
PM
81}
82
9c83ffd8
PM
83do_cc() {
84 do_compiler "$cc" "$@"
85}
86
87do_cxx() {
88 do_compiler "$cxx" "$@"
89}
90
91update_cxxflags() {
92 # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
93 # options which some versions of GCC's C++ compiler complain about
94 # because they only make sense for C programs.
95 QEMU_CXXFLAGS=
96 for arg in $QEMU_CFLAGS; do
97 case $arg in
98 -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
99 -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
100 ;;
101 *)
102 QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
103 ;;
104 esac
105 done
106}
107
52166aa0 108compile_object() {
fd0e6053
JS
109 local_cflags="$1"
110 do_cc $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
52166aa0
JQ
111}
112
113compile_prog() {
114 local_cflags="$1"
115 local_ldflags="$2"
8dc38a78 116 do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
52166aa0
JQ
117}
118
11568d6d
PB
119# symbolically link $1 to $2. Portable version of "ln -sf".
120symlink() {
72b8b5a1 121 rm -rf "$2"
ec5b06d7 122 mkdir -p "$(dirname "$2")"
72b8b5a1 123 ln -s "$1" "$2"
11568d6d
PB
124}
125
0dba6195
LM
126# check whether a command is available to this shell (may be either an
127# executable or a builtin)
128has() {
129 type "$1" >/dev/null 2>&1
130}
131
132# search for an executable in PATH
133path_of() {
134 local_command="$1"
135 local_ifs="$IFS"
136 local_dir=""
137
138 # pathname has a dir component?
139 if [ "${local_command#*/}" != "$local_command" ]; then
140 if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
141 echo "$local_command"
142 return 0
143 fi
144 fi
145 if [ -z "$local_command" ]; then
146 return 1
147 fi
148
149 IFS=:
150 for local_dir in $PATH; do
151 if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
152 echo "$local_dir/$local_command"
153 IFS="${local_ifs:-$(printf ' \t\n')}"
154 return 0
155 fi
156 done
157 # not found
158 IFS="${local_ifs:-$(printf ' \t\n')}"
159 return 1
160}
161
5b808275
LV
162have_backend () {
163 echo "$trace_backends" | grep "$1" >/dev/null
164}
165
7d13299d 166# default parameters
ca4deeb1 167source_path=`dirname "$0"`
2ff6b91e 168cpu=""
a31a8642 169iasl="iasl"
1e43adfc 170interp_prefix="/usr/gnemul/qemu-%M"
43ce4dfe 171static="no"
7d13299d 172cross_prefix=""
0c58ac1c 173audio_drv_list=""
b64ec4e4
FZ
174block_drv_rw_whitelist=""
175block_drv_ro_whitelist=""
e49d021e 176host_cc="cc"
73da375e 177libs_softmmu=""
3e2e0e6b 178libs_tools=""
67f86e8e 179audio_pt_int=""
d5631638 180audio_win_int=""
2b2e59e6 181cc_i386=i386-pc-linux-gnu-gcc
957f1f99 182libs_qga=""
5bc62e01 183debug_info="yes"
63678e17 184stack_protector=""
ac0df51d 185
afb63ebd
SW
186# Don't accept a target_list environment variable.
187unset target_list
377529c0
PB
188
189# Default value for a variable defining feature "foo".
190# * foo="no" feature will only be used if --enable-foo arg is given
191# * foo="" feature will be searched for, and if found, will be used
192# unless --disable-foo is given
193# * foo="yes" this value will only be set by --enable-foo flag.
194# feature will searched for,
195# if not found, configure exits with error
196#
197# Always add --enable-foo and --disable-foo command line args.
198# Distributions want to ensure that several features are compiled in, and it
199# is impossible without a --enable-foo that exits if a feature is not found.
200
201bluez=""
202brlapi=""
203curl=""
204curses=""
205docs=""
206fdt=""
58952137 207netmap="no"
e2134eb9 208pixman=""
377529c0 209sdl=""
47c03744 210sdlabi="1.2"
983eef5a 211virtfs=""
821601ea 212vnc="yes"
377529c0
PB
213sparse="no"
214uuid=""
215vde=""
377529c0
PB
216vnc_sasl=""
217vnc_jpeg=""
218vnc_png=""
377529c0 219xen=""
d5b93ddf 220xen_ctrl_version=""
64a7ad6f 221xen_pv_domain_build="no"
eb6fda0f 222xen_pci_passthrough=""
377529c0 223linux_aio=""
47e98658 224cap_ng=""
377529c0 225attr=""
4f26f2b6 226libattr=""
377529c0
PB
227xfs=""
228
d41a75a2 229vhost_net="no"
5e9be92d 230vhost_scsi="no"
d41a75a2 231kvm="no"
2da776db 232rdma=""
377529c0
PB
233gprof="no"
234debug_tcg="no"
377529c0 235debug="no"
b553a042 236fortify_source=""
377529c0 237strip_opt="yes"
9195b2c2 238tcg_interpreter="no"
377529c0
PB
239bigendian="no"
240mingw32="no"
1d728c39
BS
241gcov="no"
242gcov_tool="gcov"
377529c0 243EXESUF=""
17969268
FZ
244DSOSUF=".so"
245LDFLAGS_SHARED="-shared"
246modules="no"
377529c0
PB
247prefix="/usr/local"
248mandir="\${prefix}/share/man"
528ae5b8 249datadir="\${prefix}/share"
850da188 250qemu_docdir="\${prefix}/share/doc/qemu"
377529c0 251bindir="\${prefix}/bin"
3aa5d2be 252libdir="\${prefix}/lib"
8bf188aa 253libexecdir="\${prefix}/libexec"
0f94d6da 254includedir="\${prefix}/include"
377529c0 255sysconfdir="\${prefix}/etc"
785c23ae 256local_statedir="\${prefix}/var"
377529c0
PB
257confsuffix="/qemu"
258slirp="yes"
377529c0
PB
259oss_lib=""
260bsd="no"
261linux="no"
262solaris="no"
263profiler="no"
264cocoa="no"
265softmmu="yes"
266linux_user="no"
377529c0 267bsd_user="no"
377529c0
PB
268aix="no"
269blobs="yes"
270pkgversion=""
40d6444e 271pie=""
377529c0 272zero_malloc=""
3556c233 273qom_cast_debug="yes"
baf86d6b 274trace_backends="log"
377529c0
PB
275trace_file="trace"
276spice=""
277rbd=""
7b02f544 278smartcard=""
2b2325ff 279libusb=""
69354a83 280usb_redir=""
da076ffe 281opengl=""
014cb152 282opengl_dmabuf="no"
99f2dbd3 283avx2_opt="no"
1ece9905 284zlib="yes"
b25c9dff
SW
285lzo=""
286snappy=""
6b383c08 287bzip2=""
e8ef31a3 288guest_agent=""
d9840e25 289guest_agent_with_vss="no"
50cbebb9 290guest_agent_ntddscsi="no"
9dacf32d 291guest_agent_msi=""
d9840e25
TS
292vss_win32_sdk=""
293win_sdk="no"
4b1c11fd 294want_tools="yes"
c589b249 295libiscsi=""
6542aa9c 296libnfs=""
519175a2 297coroutine=""
70c60c08 298coroutine_pool=""
f794573e 299seccomp=""
eb100396 300glusterfs=""
0c14fb47 301glusterfs_discard="no"
7c815372 302glusterfs_zerofill="no"
6a460ed1 303archipelago="no"
a4ccabcf 304gtk=""
9e04c683 305gtkabi=""
925a0400 306gtk_gl="no"
ddbb0d09
DB
307gnutls=""
308gnutls_hash=""
b917da4c 309gnutls_rnd=""
91bfcdb0
DB
310nettle=""
311gcrypt=""
bbbf9bfb 312vte=""
9d9e1521 313virglrenderer=""
e91c793c 314tpm="yes"
0a12ec87 315libssh2=""
4f18b782 316vhdx=""
a99d57bb 317numa=""
2847b469 318tcmalloc="no"
7b01cb97 319jemalloc="no"
377529c0 320
ac0df51d
AL
321# parse CC options first
322for opt do
323 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
324 case "$opt" in
325 --cross-prefix=*) cross_prefix="$optarg"
326 ;;
3d8df640 327 --cc=*) CC="$optarg"
ac0df51d 328 ;;
83f73fce
TS
329 --cxx=*) CXX="$optarg"
330 ;;
ca4deeb1
PB
331 --source-path=*) source_path="$optarg"
332 ;;
2ff6b91e
JQ
333 --cpu=*) cpu="$optarg"
334 ;;
de385287 335 --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
f9943cd5 336 EXTRA_CFLAGS="$optarg"
e2a2ed06 337 ;;
a4969e90 338 --extra-ldflags=*) LDFLAGS="$LDFLAGS $optarg"
f9943cd5 339 EXTRA_LDFLAGS="$optarg"
e2a2ed06 340 ;;
5bc62e01
GH
341 --enable-debug-info) debug_info="yes"
342 ;;
343 --disable-debug-info) debug_info="no"
344 ;;
ac0df51d
AL
345 esac
346done
ac0df51d
AL
347# OS specific
348# Using uname is really, really broken. Once we have the right set of checks
93148aa5 349# we can eliminate its usage altogether.
ac0df51d 350
e49d021e
PM
351# Preferred compiler:
352# ${CC} (if set)
353# ${cross_prefix}gcc (if cross-prefix specified)
354# system compiler
355if test -z "${CC}${cross_prefix}"; then
356 cc="$host_cc"
357else
358 cc="${CC-${cross_prefix}gcc}"
359fi
360
83f73fce
TS
361if test -z "${CXX}${cross_prefix}"; then
362 cxx="c++"
363else
364 cxx="${CXX-${cross_prefix}g++}"
365fi
366
b3198cc2 367ar="${AR-${cross_prefix}ar}"
3dd46c78
BS
368as="${AS-${cross_prefix}as}"
369cpp="${CPP-$cc -E}"
b3198cc2
SY
370objcopy="${OBJCOPY-${cross_prefix}objcopy}"
371ld="${LD-${cross_prefix}ld}"
4852ee95 372nm="${NM-${cross_prefix}nm}"
b3198cc2
SY
373strip="${STRIP-${cross_prefix}strip}"
374windres="${WINDRES-${cross_prefix}windres}"
17884d7b
ST
375pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
376query_pkg_config() {
377 "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
378}
379pkg_config=query_pkg_config
b3198cc2 380sdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
47c03744 381sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
ac0df51d 382
45d285ab
PM
383# If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
384ARFLAGS="${ARFLAGS-rv}"
385
be17dc90 386# default flags for all hosts
4c288acb 387QEMU_CFLAGS="-fno-strict-aliasing -fno-common $QEMU_CFLAGS"
f9188227 388QEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
c95e3080 389QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
be17dc90 390QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
6b4c305c 391QEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/include"
5bc62e01
GH
392if test "$debug_info" = "yes"; then
393 CFLAGS="-g $CFLAGS"
394 LDFLAGS="-g $LDFLAGS"
395fi
be17dc90 396
ca4deeb1
PB
397# make source path absolute
398source_path=`cd "$source_path"; pwd`
399
cab00a5a
MT
400# running configure in the source tree?
401# we know that's the case if configure is there.
402if test -f "./configure"; then
403 pwd_is_source_path="y"
404else
405 pwd_is_source_path="n"
406fi
407
ac0df51d
AL
408check_define() {
409cat > $TMPC <<EOF
410#if !defined($1)
fd786e1a 411#error $1 not defined
ac0df51d
AL
412#endif
413int main(void) { return 0; }
414EOF
52166aa0 415 compile_object
ac0df51d
AL
416}
417
307119e7
GH
418check_include() {
419cat > $TMPC <<EOF
420#include <$1>
421int main(void) { return 0; }
422EOF
423 compile_object
424}
425
93b25869
JS
426write_c_skeleton() {
427 cat > $TMPC <<EOF
428int main(void) { return 0; }
429EOF
430}
431
bbea4050
PM
432if check_define __linux__ ; then
433 targetos="Linux"
434elif check_define _WIN32 ; then
435 targetos='MINGW32'
436elif check_define __OpenBSD__ ; then
437 targetos='OpenBSD'
438elif check_define __sun__ ; then
439 targetos='SunOS'
440elif check_define __HAIKU__ ; then
441 targetos='Haiku'
442else
443 targetos=`uname -s`
444fi
445
446# Some host OSes need non-standard checks for which CPU to use.
447# Note that these checks are broken for cross-compilation: if you're
448# cross-compiling to one of these OSes then you'll need to specify
449# the correct CPU with the --cpu option.
450case $targetos in
451Darwin)
452 # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
453 # run 64-bit userspace code.
454 # If the user didn't specify a CPU explicitly and the kernel says this is
455 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
456 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
457 cpu="x86_64"
458 fi
459 ;;
460SunOS)
461 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
462 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
463 cpu="x86_64"
464 fi
465esac
466
2ff6b91e
JQ
467if test ! -z "$cpu" ; then
468 # command line argument
469 :
470elif check_define __i386__ ; then
ac0df51d
AL
471 cpu="i386"
472elif check_define __x86_64__ ; then
c72b26ec
RH
473 if check_define __ILP32__ ; then
474 cpu="x32"
475 else
476 cpu="x86_64"
477 fi
3aa9bd6c 478elif check_define __sparc__ ; then
3aa9bd6c
BS
479 if check_define __arch64__ ; then
480 cpu="sparc64"
481 else
482 cpu="sparc"
483 fi
fdf7ed96 484elif check_define _ARCH_PPC ; then
485 if check_define _ARCH_PPC64 ; then
486 cpu="ppc64"
487 else
488 cpu="ppc"
489 fi
afa05235
AJ
490elif check_define __mips__ ; then
491 cpu="mips"
477ba620
AJ
492elif check_define __ia64__ ; then
493 cpu="ia64"
d66ed0ea
AJ
494elif check_define __s390__ ; then
495 if check_define __s390x__ ; then
496 cpu="s390x"
497 else
498 cpu="s390"
499 fi
21d89f84
PM
500elif check_define __arm__ ; then
501 cpu="arm"
1f080313
CF
502elif check_define __aarch64__ ; then
503 cpu="aarch64"
f28ffed5
BS
504elif check_define __hppa__ ; then
505 cpu="hppa"
ac0df51d 506else
fdf7ed96 507 cpu=`uname -m`
ac0df51d
AL
508fi
509
359bc95d
PM
510ARCH=
511# Normalise host CPU name and set ARCH.
512# Note that this case should only have supported host CPUs, not guests.
7d13299d 513case "$cpu" in
c72b26ec 514 ia64|ppc|ppc64|s390|s390x|sparc64|x32)
ea8f20f8
JQ
515 cpu="$cpu"
516 ;;
7d13299d 517 i386|i486|i586|i686|i86pc|BePC)
97a847bc 518 cpu="i386"
7d13299d 519 ;;
aaa5fa14
AJ
520 x86_64|amd64)
521 cpu="x86_64"
522 ;;
21d89f84
PM
523 armv*b|armv*l|arm)
524 cpu="arm"
7d13299d 525 ;;
1f080313
CF
526 aarch64)
527 cpu="aarch64"
528 ;;
afa05235
AJ
529 mips*)
530 cpu="mips"
531 ;;
3142255c 532 sparc|sun4[cdmuv])
ae228531
FB
533 cpu="sparc"
534 ;;
7d13299d 535 *)
359bc95d
PM
536 # This will result in either an error or falling back to TCI later
537 ARCH=unknown
7d13299d
FB
538 ;;
539esac
359bc95d
PM
540if test -z "$ARCH"; then
541 ARCH="$cpu"
542fi
e2d52ad3 543
7d13299d 544# OS specific
0dbfc675 545
adfc3e91
SS
546# host *BSD for user mode
547HOST_VARIANT_DIR=""
548
7d13299d 549case $targetos in
c326e0af 550CYGWIN*)
0dbfc675 551 mingw32="yes"
a558ee17 552 QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
3cec7cc2
KZ
553 audio_possible_drivers="sdl"
554 audio_drv_list="sdl"
c326e0af 555;;
67b915a5 556MINGW32*)
0dbfc675 557 mingw32="yes"
3cec7cc2 558 audio_possible_drivers="dsound sdl"
307119e7
GH
559 if check_include dsound.h; then
560 audio_drv_list="dsound"
561 else
562 audio_drv_list=""
563 fi
67b915a5 564;;
5c40d2bd 565GNU/kFreeBSD)
a167ba50 566 bsd="yes"
0dbfc675 567 audio_drv_list="oss"
0bac1111 568 audio_possible_drivers="oss sdl pa"
5c40d2bd 569;;
7d3505c5 570FreeBSD)
0dbfc675 571 bsd="yes"
0db4a067 572 make="${MAKE-gmake}"
0dbfc675 573 audio_drv_list="oss"
0bac1111 574 audio_possible_drivers="oss sdl pa"
f01576f1
JL
575 # needed for kinfo_getvmmap(3) in libutil.h
576 LIBS="-lutil $LIBS"
58952137 577 netmap="" # enable netmap autodetect
adfc3e91 578 HOST_VARIANT_DIR="freebsd"
7d3505c5 579;;
c5e97233 580DragonFly)
0dbfc675 581 bsd="yes"
0db4a067 582 make="${MAKE-gmake}"
0dbfc675 583 audio_drv_list="oss"
0bac1111 584 audio_possible_drivers="oss sdl pa"
adfc3e91 585 HOST_VARIANT_DIR="dragonfly"
c5e97233 586;;
7d3505c5 587NetBSD)
0dbfc675 588 bsd="yes"
0db4a067 589 make="${MAKE-gmake}"
0dbfc675 590 audio_drv_list="oss"
0bac1111 591 audio_possible_drivers="oss sdl"
0dbfc675 592 oss_lib="-lossaudio"
adfc3e91 593 HOST_VARIANT_DIR="netbsd"
7d3505c5
FB
594;;
595OpenBSD)
0dbfc675 596 bsd="yes"
0db4a067 597 make="${MAKE-gmake}"
4f6ab397 598 audio_drv_list="sdl"
0bac1111 599 audio_possible_drivers="sdl"
adfc3e91 600 HOST_VARIANT_DIR="openbsd"
7d3505c5 601;;
83fb7adf 602Darwin)
0dbfc675
JQ
603 bsd="yes"
604 darwin="yes"
17969268 605 LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
0dbfc675 606 if [ "$cpu" = "x86_64" ] ; then
a558ee17 607 QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
0c439cbf 608 LDFLAGS="-arch x86_64 $LDFLAGS"
0dbfc675 609 fi
0dbfc675
JQ
610 cocoa="yes"
611 audio_drv_list="coreaudio"
14382605 612 audio_possible_drivers="coreaudio sdl"
0dbfc675 613 LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
7973f21c 614 libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
a0b7cf6b
PM
615 # Disable attempts to use ObjectiveC features in os/object.h since they
616 # won't work when we're compiling with gcc as a C compiler.
617 QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
adfc3e91 618 HOST_VARIANT_DIR="darwin"
83fb7adf 619;;
ec530c81 620SunOS)
0dbfc675 621 solaris="yes"
0db4a067
PB
622 make="${MAKE-gmake}"
623 install="${INSTALL-ginstall}"
fa58948d 624 ld="gld"
e2d8830e 625 smbd="${SMBD-/usr/sfw/sbin/smbd}"
0dbfc675
JQ
626 needs_libsunmath="no"
627 solarisrev=`uname -r | cut -f2 -d.`
0dbfc675
JQ
628 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
629 if test "$solarisrev" -le 9 ; then
630 if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
631 needs_libsunmath="yes"
f14bfdf9
JQ
632 QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
633 LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
634 LIBS="-lsunmath $LIBS"
0dbfc675 635 else
76ad07a4
PM
636 error_exit "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without" \
637 "libsunmath from the Sun Studio compilers tools, due to a lack of" \
638 "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86" \
639 "Studio 11 can be downloaded from www.sun.com."
0dbfc675 640 fi
86b2bd93 641 fi
0dbfc675
JQ
642 fi
643 if test -f /usr/include/sys/soundcard.h ; then
644 audio_drv_list="oss"
645 fi
646 audio_possible_drivers="oss sdl"
d741429a
BS
647# needed for CMSG_ macros in sys/socket.h
648 QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
649# needed for TIOCWIN* defines in termios.h
650 QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
a558ee17 651 QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
560d375f
AF
652 solarisnetlibs="-lsocket -lnsl -lresolv"
653 LIBS="$solarisnetlibs $LIBS"
654 libs_qga="$solarisnetlibs $libs_qga"
86b2bd93 655;;
b29fe3ed 656AIX)
0dbfc675 657 aix="yes"
0db4a067 658 make="${MAKE-gmake}"
b29fe3ed 659;;
179cf400
AF
660Haiku)
661 haiku="yes"
662 QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
663 LIBS="-lposix_error_mapper -lnetwork $LIBS"
664;;
1d14ffa9 665*)
0dbfc675 666 audio_drv_list="oss"
0bac1111 667 audio_possible_drivers="oss alsa sdl pa"
0dbfc675
JQ
668 linux="yes"
669 linux_user="yes"
af2be207
JK
670 kvm="yes"
671 vhost_net="yes"
5e9be92d 672 vhost_scsi="yes"
a585140d 673 QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
fb065187 674;;
7d13299d
FB
675esac
676
7d3505c5 677if [ "$bsd" = "yes" ] ; then
b1a550a0 678 if [ "$darwin" != "yes" ] ; then
08de3949 679 bsd_user="yes"
83fb7adf 680 fi
7d3505c5
FB
681fi
682
0db4a067
PB
683: ${make=${MAKE-make}}
684: ${install=${INSTALL-install}}
52510f8b 685: ${python=${PYTHON-python}}
e2d8830e 686: ${smbd=${SMBD-/usr/sbin/smbd}}
0db4a067 687
3c4a4d0d
PM
688# Default objcc to clang if available, otherwise use CC
689if has clang; then
690 objcc=clang
691else
692 objcc="$cc"
693fi
694
3457a3f8 695if test "$mingw32" = "yes" ; then
3457a3f8 696 EXESUF=".exe"
17969268 697 DSOSUF=".dll"
a558ee17 698 QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
e94a7936
SW
699 # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
700 QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
78e9d4ad
SW
701 # MinGW needs -mthreads for TLS and macro _MT.
702 QEMU_CFLAGS="-mthreads $QEMU_CFLAGS"
f7cf5d5b 703 LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
93b25869 704 write_c_skeleton;
f7cf5d5b
SW
705 if compile_prog "" "-liberty" ; then
706 LIBS="-liberty $LIBS"
707 fi
c5ec15ea 708 prefix="c:/Program Files/QEMU"
683035de 709 mandir="\${prefix}"
528ae5b8 710 datadir="\${prefix}"
850da188 711 qemu_docdir="\${prefix}"
683035de
PB
712 bindir="\${prefix}"
713 sysconfdir="\${prefix}"
5a699bbb 714 local_statedir=
683035de 715 confsuffix=""
259434b8 716 libs_qga="-lws2_32 -lwinmm -lpowrprof -liphlpapi -lnetapi32 $libs_qga"
3457a3f8
JQ
717fi
718
487fefdb 719werror=""
85aa5189 720
7d13299d 721for opt do
a46e4035 722 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
7d13299d 723 case "$opt" in
2efc3265
FB
724 --help|-h) show_help=yes
725 ;;
99123e13
MF
726 --version|-V) exec cat $source_path/VERSION
727 ;;
b1a550a0 728 --prefix=*) prefix="$optarg"
7d13299d 729 ;;
b1a550a0 730 --interp-prefix=*) interp_prefix="$optarg"
32ce6337 731 ;;
ca4deeb1 732 --source-path=*)
7d13299d 733 ;;
ac0df51d 734 --cross-prefix=*)
7d13299d 735 ;;
ac0df51d 736 --cc=*)
7d13299d 737 ;;
b1a550a0 738 --host-cc=*) host_cc="$optarg"
83469015 739 ;;
83f73fce
TS
740 --cxx=*)
741 ;;
e007dbec
MT
742 --iasl=*) iasl="$optarg"
743 ;;
3c4a4d0d
PM
744 --objcc=*) objcc="$optarg"
745 ;;
b1a550a0 746 --make=*) make="$optarg"
7d13299d 747 ;;
6a882643
PB
748 --install=*) install="$optarg"
749 ;;
c886edfb
BS
750 --python=*) python="$optarg"
751 ;;
1d728c39
BS
752 --gcov=*) gcov_tool="$optarg"
753 ;;
e2d8830e
BS
754 --smbd=*) smbd="$optarg"
755 ;;
e2a2ed06 756 --extra-cflags=*)
7d13299d 757 ;;
e2a2ed06 758 --extra-ldflags=*)
7d13299d 759 ;;
5bc62e01
GH
760 --enable-debug-info)
761 ;;
762 --disable-debug-info)
763 ;;
17969268
FZ
764 --enable-modules)
765 modules="yes"
3aa88b31
SH
766 ;;
767 --disable-modules)
768 modules="no"
17969268 769 ;;
2ff6b91e 770 --cpu=*)
7d13299d 771 ;;
b1a550a0 772 --target-list=*) target_list="$optarg"
de83cd02 773 ;;
5b808275
LV
774 --enable-trace-backends=*) trace_backends="$optarg"
775 ;;
776 # XXX: backwards compatibility
777 --enable-trace-backend=*) trace_backends="$optarg"
94a420b1 778 ;;
74242e0f 779 --with-trace-file=*) trace_file="$optarg"
9410b56c 780 ;;
7d13299d
FB
781 --enable-gprof) gprof="yes"
782 ;;
1d728c39
BS
783 --enable-gcov) gcov="yes"
784 ;;
79427693
LM
785 --static)
786 static="yes"
787 LDFLAGS="-static $LDFLAGS"
17884d7b 788 QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
43ce4dfe 789 ;;
0b24e75f
PB
790 --mandir=*) mandir="$optarg"
791 ;;
792 --bindir=*) bindir="$optarg"
793 ;;
3aa5d2be
AL
794 --libdir=*) libdir="$optarg"
795 ;;
8bf188aa
MT
796 --libexecdir=*) libexecdir="$optarg"
797 ;;
0f94d6da
AL
798 --includedir=*) includedir="$optarg"
799 ;;
528ae5b8 800 --datadir=*) datadir="$optarg"
0b24e75f 801 ;;
023d3d67
EH
802 --with-confsuffix=*) confsuffix="$optarg"
803 ;;
850da188 804 --docdir=*) qemu_docdir="$optarg"
0b24e75f 805 ;;
ca2fb938 806 --sysconfdir=*) sysconfdir="$optarg"
07381cc1 807 ;;
785c23ae
LC
808 --localstatedir=*) local_statedir="$optarg"
809 ;;
810 --sbindir=*|--sharedstatedir=*|\
023ddd74
MF
811 --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
812 --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
813 # These switches are silently ignored, for compatibility with
814 # autoconf-generated configure scripts. This allows QEMU's
815 # configure to be used by RPM and similar macros that set
816 # lots of directory switches by default.
817 ;;
e2134eb9
GH
818 --with-system-pixman) pixman="system"
819 ;;
820 --without-system-pixman) pixman="internal"
821 ;;
74880fe2
RS
822 --without-pixman) pixman="none"
823 ;;
97a847bc
FB
824 --disable-sdl) sdl="no"
825 ;;
c4198157
JQ
826 --enable-sdl) sdl="yes"
827 ;;
47c03744
DA
828 --with-sdlabi=*) sdlabi="$optarg"
829 ;;
3556c233
PB
830 --disable-qom-cast-debug) qom_cast_debug="no"
831 ;;
832 --enable-qom-cast-debug) qom_cast_debug="yes"
833 ;;
983eef5a
MI
834 --disable-virtfs) virtfs="no"
835 ;;
836 --enable-virtfs) virtfs="yes"
837 ;;
821601ea
JS
838 --disable-vnc) vnc="no"
839 ;;
840 --enable-vnc) vnc="yes"
841 ;;
2f6a1ab0
BS
842 --oss-lib=*) oss_lib="$optarg"
843 ;;
0c58ac1c 844 --audio-drv-list=*) audio_drv_list="$optarg"
102a52e4 845 ;;
b64ec4e4
FZ
846 --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
847 ;;
848 --block-drv-ro-whitelist=*) block_drv_ro_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
eb852011 849 ;;
f8393946
AJ
850 --enable-debug-tcg) debug_tcg="yes"
851 ;;
852 --disable-debug-tcg) debug_tcg="no"
853 ;;
f3d08ee6
PB
854 --enable-debug)
855 # Enable debugging options that aren't excessively noisy
856 debug_tcg="yes"
857 debug="yes"
858 strip_opt="no"
b553a042 859 fortify_source="no"
f3d08ee6 860 ;;
03b4fe7d
AL
861 --enable-sparse) sparse="yes"
862 ;;
863 --disable-sparse) sparse="no"
864 ;;
1625af87
AL
865 --disable-strip) strip_opt="no"
866 ;;
2f9606b3
AL
867 --disable-vnc-sasl) vnc_sasl="no"
868 ;;
ea784e3b
JQ
869 --enable-vnc-sasl) vnc_sasl="yes"
870 ;;
2f6f5c7a
CC
871 --disable-vnc-jpeg) vnc_jpeg="no"
872 ;;
873 --enable-vnc-jpeg) vnc_jpeg="yes"
874 ;;
efe556ad
CC
875 --disable-vnc-png) vnc_png="no"
876 ;;
877 --enable-vnc-png) vnc_png="yes"
878 ;;
443f1376 879 --disable-slirp) slirp="no"
1d14ffa9 880 ;;
ee682d27
SW
881 --disable-uuid) uuid="no"
882 ;;
883 --enable-uuid) uuid="yes"
884 ;;
e0e6c8c0 885 --disable-vde) vde="no"
8a16d273 886 ;;
dfb278bd
JQ
887 --enable-vde) vde="yes"
888 ;;
58952137
VM
889 --disable-netmap) netmap="no"
890 ;;
891 --enable-netmap) netmap="yes"
892 ;;
e37630ca
AL
893 --disable-xen) xen="no"
894 ;;
fc321b4b
JQ
895 --enable-xen) xen="yes"
896 ;;
eb6fda0f
AP
897 --disable-xen-pci-passthrough) xen_pci_passthrough="no"
898 ;;
899 --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
900 ;;
64a7ad6f
IC
901 --disable-xen-pv-domain-build) xen_pv_domain_build="no"
902 ;;
903 --enable-xen-pv-domain-build) xen_pv_domain_build="yes"
904 ;;
2e4d9fb1
AJ
905 --disable-brlapi) brlapi="no"
906 ;;
4ffcedb6
JQ
907 --enable-brlapi) brlapi="yes"
908 ;;
fb599c9a
AZ
909 --disable-bluez) bluez="no"
910 ;;
a20a6f46
JQ
911 --enable-bluez) bluez="yes"
912 ;;
7ba1e619
AL
913 --disable-kvm) kvm="no"
914 ;;
b31a0277
JQ
915 --enable-kvm) kvm="yes"
916 ;;
9195b2c2
SW
917 --disable-tcg-interpreter) tcg_interpreter="no"
918 ;;
919 --enable-tcg-interpreter) tcg_interpreter="yes"
920 ;;
47e98658
CB
921 --disable-cap-ng) cap_ng="no"
922 ;;
923 --enable-cap-ng) cap_ng="yes"
924 ;;
cd4ec0b4
GH
925 --disable-spice) spice="no"
926 ;;
927 --enable-spice) spice="yes"
928 ;;
c589b249
RS
929 --disable-libiscsi) libiscsi="no"
930 ;;
931 --enable-libiscsi) libiscsi="yes"
932 ;;
6542aa9c
PL
933 --disable-libnfs) libnfs="no"
934 ;;
935 --enable-libnfs) libnfs="yes"
936 ;;
05c2a3e7
FB
937 --enable-profiler) profiler="yes"
938 ;;
14821030
PB
939 --disable-cocoa) cocoa="no"
940 ;;
c2de5c91 941 --enable-cocoa)
942 cocoa="yes" ;
c2de5c91 943 audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
1d14ffa9 944 ;;
cad25d69 945 --disable-system) softmmu="no"
0a8e90f4 946 ;;
cad25d69 947 --enable-system) softmmu="yes"
0a8e90f4 948 ;;
0953a80f
ZA
949 --disable-user)
950 linux_user="no" ;
951 bsd_user="no" ;
0953a80f
ZA
952 ;;
953 --enable-user) ;;
831b7825 954 --disable-linux-user) linux_user="no"
0a8e90f4 955 ;;
831b7825
TS
956 --enable-linux-user) linux_user="yes"
957 ;;
84778508
BS
958 --disable-bsd-user) bsd_user="no"
959 ;;
960 --enable-bsd-user) bsd_user="yes"
961 ;;
40d6444e 962 --enable-pie) pie="yes"
34005a00 963 ;;
40d6444e 964 --disable-pie) pie="no"
34005a00 965 ;;
85aa5189
FB
966 --enable-werror) werror="yes"
967 ;;
968 --disable-werror) werror="no"
969 ;;
63678e17
SN
970 --enable-stack-protector) stack_protector="yes"
971 ;;
972 --disable-stack-protector) stack_protector="no"
973 ;;
4d3b6f6e
AZ
974 --disable-curses) curses="no"
975 ;;
c584a6d0
JQ
976 --enable-curses) curses="yes"
977 ;;
769ce76d
AG
978 --disable-curl) curl="no"
979 ;;
788c8196
JQ
980 --enable-curl) curl="yes"
981 ;;
2df87df7
JQ
982 --disable-fdt) fdt="no"
983 ;;
984 --enable-fdt) fdt="yes"
985 ;;
5c6c3a6c
CH
986 --disable-linux-aio) linux_aio="no"
987 ;;
988 --enable-linux-aio) linux_aio="yes"
989 ;;
758e8e38
VJ
990 --disable-attr) attr="no"
991 ;;
992 --enable-attr) attr="yes"
993 ;;
77755340
TS
994 --disable-blobs) blobs="no"
995 ;;
4a19f1ec
PB
996 --with-pkgversion=*) pkgversion=" ($optarg)"
997 ;;
519175a2
AB
998 --with-coroutine=*) coroutine="$optarg"
999 ;;
70c60c08
SH
1000 --disable-coroutine-pool) coroutine_pool="no"
1001 ;;
1002 --enable-coroutine-pool) coroutine_pool="yes"
1003 ;;
a25dba17 1004 --disable-docs) docs="no"
70ec5dc0 1005 ;;
a25dba17 1006 --enable-docs) docs="yes"
83a3ab8b 1007 ;;
d5970055
MT
1008 --disable-vhost-net) vhost_net="no"
1009 ;;
1010 --enable-vhost-net) vhost_net="yes"
1011 ;;
5e9be92d
NB
1012 --disable-vhost-scsi) vhost_scsi="no"
1013 ;;
1014 --enable-vhost-scsi) vhost_scsi="yes"
1015 ;;
da076ffe 1016 --disable-opengl) opengl="no"
20ff075b 1017 ;;
da076ffe 1018 --enable-opengl) opengl="yes"
20ff075b 1019 ;;
f27aaf4b
CB
1020 --disable-rbd) rbd="no"
1021 ;;
1022 --enable-rbd) rbd="yes"
1023 ;;
8c84cf11
ST
1024 --disable-xfsctl) xfs="no"
1025 ;;
1026 --enable-xfsctl) xfs="yes"
1027 ;;
7b02f544 1028 --disable-smartcard) smartcard="no"
111a38b0 1029 ;;
7b02f544 1030 --enable-smartcard) smartcard="yes"
111a38b0 1031 ;;
2b2325ff
GH
1032 --disable-libusb) libusb="no"
1033 ;;
1034 --enable-libusb) libusb="yes"
1035 ;;
69354a83
HG
1036 --disable-usb-redir) usb_redir="no"
1037 ;;
1038 --enable-usb-redir) usb_redir="yes"
1039 ;;
1ece9905
AL
1040 --disable-zlib-test) zlib="no"
1041 ;;
b25c9dff
SW
1042 --disable-lzo) lzo="no"
1043 ;;
607dacd0
QN
1044 --enable-lzo) lzo="yes"
1045 ;;
b25c9dff
SW
1046 --disable-snappy) snappy="no"
1047 ;;
607dacd0
QN
1048 --enable-snappy) snappy="yes"
1049 ;;
6b383c08
PW
1050 --disable-bzip2) bzip2="no"
1051 ;;
1052 --enable-bzip2) bzip2="yes"
1053 ;;
d138cee9
MR
1054 --enable-guest-agent) guest_agent="yes"
1055 ;;
1056 --disable-guest-agent) guest_agent="no"
1057 ;;
9dacf32d
YH
1058 --enable-guest-agent-msi) guest_agent_msi="yes"
1059 ;;
1060 --disable-guest-agent-msi) guest_agent_msi="no"
1061 ;;
d9840e25
TS
1062 --with-vss-sdk) vss_win32_sdk=""
1063 ;;
1064 --with-vss-sdk=*) vss_win32_sdk="$optarg"
1065 ;;
1066 --without-vss-sdk) vss_win32_sdk="no"
1067 ;;
1068 --with-win-sdk) win_sdk=""
1069 ;;
1070 --with-win-sdk=*) win_sdk="$optarg"
1071 ;;
1072 --without-win-sdk) win_sdk="no"
1073 ;;
4b1c11fd
DB
1074 --enable-tools) want_tools="yes"
1075 ;;
1076 --disable-tools) want_tools="no"
1077 ;;
f794573e
EO
1078 --enable-seccomp) seccomp="yes"
1079 ;;
1080 --disable-seccomp) seccomp="no"
1081 ;;
eb100396
BR
1082 --disable-glusterfs) glusterfs="no"
1083 ;;
1084 --enable-glusterfs) glusterfs="yes"
1085 ;;
c9a12e75
CN
1086 --disable-archipelago) archipelago="no"
1087 ;;
1088 --enable-archipelago) archipelago="yes"
1089 ;;
52b53c04
FZ
1090 --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
1091 echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
583f6e7b 1092 ;;
a4ccabcf
AL
1093 --disable-gtk) gtk="no"
1094 ;;
1095 --enable-gtk) gtk="yes"
1096 ;;
ddbb0d09
DB
1097 --disable-gnutls) gnutls="no"
1098 ;;
1099 --enable-gnutls) gnutls="yes"
1100 ;;
91bfcdb0
DB
1101 --disable-nettle) nettle="no"
1102 ;;
1103 --enable-nettle) nettle="yes"
1104 ;;
1105 --disable-gcrypt) gcrypt="no"
1106 ;;
1107 --enable-gcrypt) gcrypt="yes"
1108 ;;
2da776db
MH
1109 --enable-rdma) rdma="yes"
1110 ;;
1111 --disable-rdma) rdma="no"
1112 ;;
528de90a
DB
1113 --with-gtkabi=*) gtkabi="$optarg"
1114 ;;
bbbf9bfb
SW
1115 --disable-vte) vte="no"
1116 ;;
1117 --enable-vte) vte="yes"
1118 ;;
9d9e1521
GH
1119 --disable-virglrenderer) virglrenderer="no"
1120 ;;
1121 --enable-virglrenderer) virglrenderer="yes"
1122 ;;
e91c793c
CR
1123 --disable-tpm) tpm="no"
1124 ;;
ab214c29
SB
1125 --enable-tpm) tpm="yes"
1126 ;;
0a12ec87
RJ
1127 --disable-libssh2) libssh2="no"
1128 ;;
1129 --enable-libssh2) libssh2="yes"
1130 ;;
4f18b782
JC
1131 --enable-vhdx) vhdx="yes"
1132 ;;
1133 --disable-vhdx) vhdx="no"
1134 ;;
a99d57bb
WG
1135 --disable-numa) numa="no"
1136 ;;
1137 --enable-numa) numa="yes"
1138 ;;
2847b469
FZ
1139 --disable-tcmalloc) tcmalloc="no"
1140 ;;
1141 --enable-tcmalloc) tcmalloc="yes"
1142 ;;
7b01cb97
AD
1143 --disable-jemalloc) jemalloc="no"
1144 ;;
1145 --enable-jemalloc) jemalloc="yes"
1146 ;;
2d2ad6d0
FZ
1147 *)
1148 echo "ERROR: unknown option $opt"
1149 echo "Try '$0 --help' for more information"
1150 exit 1
7f1559c6 1151 ;;
7d13299d
FB
1152 esac
1153done
1154
f6f0b7d9
SW
1155if ! has $python; then
1156 error_exit "Python not found. Use --python=/path/to/python"
1157fi
1158
1159# Note that if the Python conditional here evaluates True we will exit
1160# with status 1 which is a shell 'false' value.
fec21036
MA
1161if ! $python -c 'import sys; sys.exit(sys.version_info < (2,6) or sys.version_info >= (3,))'; then
1162 error_exit "Cannot use '$python', Python 2.6 or later is required." \
f6f0b7d9
SW
1163 "Note that Python 3 or later is not yet supported." \
1164 "Use --python=/path/to/python to specify a supported Python."
1165fi
1166
fec21036
MA
1167# Suppress writing compiled files
1168python="$python -B"
f6f0b7d9 1169
40293e58 1170case "$cpu" in
e3608d66
RH
1171 ppc)
1172 CPU_CFLAGS="-m32"
1173 LDFLAGS="-m32 $LDFLAGS"
1174 ;;
1175 ppc64)
1176 CPU_CFLAGS="-m64"
1177 LDFLAGS="-m64 $LDFLAGS"
1178 ;;
9b9c37c3 1179 sparc)
ed968ff1 1180 LDFLAGS="-m32 $LDFLAGS"
79f3b12f 1181 CPU_CFLAGS="-m32 -mcpu=ultrasparc"
3142255c 1182 ;;
ed968ff1 1183 sparc64)
ed968ff1 1184 LDFLAGS="-m64 $LDFLAGS"
79f3b12f 1185 CPU_CFLAGS="-m64 -mcpu=ultrasparc"
3142255c 1186 ;;
76d83bde 1187 s390)
061cdd81 1188 CPU_CFLAGS="-m31"
28d7cc49
RH
1189 LDFLAGS="-m31 $LDFLAGS"
1190 ;;
1191 s390x)
061cdd81 1192 CPU_CFLAGS="-m64"
28d7cc49 1193 LDFLAGS="-m64 $LDFLAGS"
76d83bde 1194 ;;
40293e58 1195 i386)
79f3b12f 1196 CPU_CFLAGS="-m32"
0c439cbf 1197 LDFLAGS="-m32 $LDFLAGS"
2b2e59e6 1198 cc_i386='$(CC) -m32'
40293e58
FB
1199 ;;
1200 x86_64)
79f3b12f 1201 CPU_CFLAGS="-m64"
0c439cbf 1202 LDFLAGS="-m64 $LDFLAGS"
2b2e59e6 1203 cc_i386='$(CC) -m32'
d2fbca94 1204 ;;
c72b26ec
RH
1205 x32)
1206 CPU_CFLAGS="-mx32"
1207 LDFLAGS="-mx32 $LDFLAGS"
1208 cc_i386='$(CC) -m32'
1209 ;;
30163d89 1210 # No special flags required for other host CPUs
3142255c
BS
1211esac
1212
79f3b12f
PC
1213QEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
1214EXTRA_CFLAGS="$CPU_CFLAGS $EXTRA_CFLAGS"
1215
60e0df25
PM
1216default_target_list=""
1217
6e92f823
PM
1218mak_wilds=""
1219
1220if [ "$softmmu" = "yes" ]; then
1221 mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
60e0df25 1222fi
6e92f823
PM
1223if [ "$linux_user" = "yes" ]; then
1224 mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
60e0df25 1225fi
6e92f823
PM
1226if [ "$bsd_user" = "yes" ]; then
1227 mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
60e0df25
PM
1228fi
1229
6e92f823
PM
1230for config in $mak_wilds; do
1231 default_target_list="${default_target_list} $(basename "$config" .mak)"
1232done
1233
af5db58e
PB
1234if test x"$show_help" = x"yes" ; then
1235cat << EOF
1236
1237Usage: configure [options]
1238Options: [defaults in brackets after descriptions]
1239
08fb77ed
SW
1240Standard options:
1241 --help print this message
1242 --prefix=PREFIX install in PREFIX [$prefix]
1243 --interp-prefix=PREFIX where to find shared libraries, etc.
1244 use %M for cpu name [$interp_prefix]
1245 --target-list=LIST set target list (default: build everything)
1246$(echo Available targets: $default_target_list | \
1247 fold -s -w 53 | sed -e 's/^/ /')
1248
1249Advanced options (experts only):
1250 --source-path=PATH path of source code [$source_path]
1251 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
1252 --cc=CC use C compiler CC [$cc]
1253 --iasl=IASL use ACPI compiler IASL [$iasl]
1254 --host-cc=CC use C compiler CC [$host_cc] for code run at
1255 build time
1256 --cxx=CXX use C++ compiler CXX [$cxx]
1257 --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
1258 --extra-cflags=CFLAGS append extra C compiler flags QEMU_CFLAGS
1259 --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS
1260 --make=MAKE use specified make [$make]
1261 --install=INSTALL use specified install [$install]
1262 --python=PYTHON use specified python [$python]
1263 --smbd=SMBD use specified smbd [$smbd]
1264 --static enable static build [$static]
1265 --mandir=PATH install man pages in PATH
1266 --datadir=PATH install firmware in PATH$confsuffix
1267 --docdir=PATH install documentation in PATH$confsuffix
1268 --bindir=PATH install binaries in PATH
1269 --libdir=PATH install libraries in PATH
1270 --sysconfdir=PATH install config in PATH$confsuffix
1271 --localstatedir=PATH install local state in PATH (set at runtime on win32)
e26110cf 1272 --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
08fb77ed 1273 --enable-debug enable common debug build options
08fb77ed
SW
1274 --disable-strip disable stripping binaries
1275 --disable-werror disable compilation abort on warning
63678e17 1276 --disable-stack-protector disable compiler-provided stack protection
08fb77ed
SW
1277 --audio-drv-list=LIST set audio drivers list:
1278 Available drivers: $audio_possible_drivers
1279 --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L
1280 --block-drv-rw-whitelist=L
1281 set block driver read-write whitelist
1282 (affects only QEMU, not qemu-img)
1283 --block-drv-ro-whitelist=L
1284 set block driver read-only whitelist
1285 (affects only QEMU, not qemu-img)
5b808275 1286 --enable-trace-backends=B Set trace backend
08fb77ed
SW
1287 Available backends: $($python $source_path/scripts/tracetool.py --list-backends)
1288 --with-trace-file=NAME Full PATH,NAME of file to store traces
1289 Default:trace-<pid>
c23f23b9
MT
1290 --disable-slirp disable SLIRP userspace network connectivity
1291 --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
1292 --oss-lib path to OSS library
1293 --cpu=CPU Build for host CPU [$cpu]
08fb77ed
SW
1294 --with-coroutine=BACKEND coroutine backend. Supported options:
1295 gthread, ucontext, sigaltstack, windows
08fb77ed
SW
1296 --enable-gcov enable test coverage analysis with gcov
1297 --gcov=GCOV use specified gcov [$gcov_tool]
c23f23b9
MT
1298 --disable-blobs disable installing provided firmware blobs
1299 --with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent
1300 --with-win-sdk=SDK-path path to Windows Platform SDK (to build VSS .tlb)
1301
1302Optional features, enabled with --enable-FEATURE and
1303disabled with --disable-FEATURE, default is enabled if available:
1304
1305 system all system emulation targets
1306 user supported user emulation targets
1307 linux-user all linux usermode emulation targets
1308 bsd-user all BSD usermode emulation targets
c23f23b9
MT
1309 docs build documentation
1310 guest-agent build the QEMU Guest Agent
1311 guest-agent-msi build guest agent Windows MSI installation package
1312 pie Position Independent Executables
1313 modules modules support
1314 debug-tcg TCG debugging (default is disabled)
1315 debug-info debugging information
1316 sparse sparse checker
1317
ddbb0d09 1318 gnutls GNUTLS cryptography support
91bfcdb0
DB
1319 nettle nettle cryptography support
1320 gcrypt libgcrypt cryptography support
c23f23b9
MT
1321 sdl SDL UI
1322 --with-sdlabi select preferred SDL ABI 1.2 or 2.0
1323 gtk gtk UI
1324 --with-gtkabi select preferred GTK ABI 2.0 or 3.0
1325 vte vte support for the gtk UI
1326 curses curses UI
1327 vnc VNC UI support
c23f23b9
MT
1328 vnc-sasl SASL encryption for VNC server
1329 vnc-jpeg JPEG lossy compression for VNC server
1330 vnc-png PNG compression for VNC server
c23f23b9
MT
1331 cocoa Cocoa UI (Mac OS X only)
1332 virtfs VirtFS
1333 xen xen backend driver support
1334 xen-pci-passthrough
1335 brlapi BrlAPI (Braile)
1336 curl curl connectivity
1337 fdt fdt device tree
1338 bluez bluez stack connectivity
1339 kvm KVM acceleration support
1340 rdma RDMA-based migration support
1341 uuid uuid support
1342 vde support for vde network
1343 netmap support for netmap network
1344 linux-aio Linux AIO support
1345 cap-ng libcap-ng support
1346 attr attr and xattr support
1347 vhost-net vhost-net acceleration support
1348 spice spice
1349 rbd rados block device (rbd)
1350 libiscsi iscsi support
1351 libnfs nfs support
7b02f544 1352 smartcard smartcard support (libcacard)
c23f23b9
MT
1353 libusb libusb (for usb passthrough)
1354 usb-redir usb network redirection support
1355 lzo support of lzo compression library
1356 snappy support of snappy compression library
1357 bzip2 support of bzip2 compression library
1358 (for reading bzip2-compressed dmg images)
1359 seccomp seccomp support
1360 coroutine-pool coroutine freelist (better performance)
1361 glusterfs GlusterFS backend
1362 archipelago Archipelago backend
1363 tpm TPM support
1364 libssh2 ssh block device support
1365 vhdx support for the Microsoft VHDX image format
c23f23b9
MT
1366 numa libnuma support
1367 tcmalloc tcmalloc support
7b01cb97 1368 jemalloc jemalloc support
08fb77ed
SW
1369
1370NOTE: The object files are built at the place where configure is launched
af5db58e 1371EOF
2d2ad6d0 1372exit 0
af5db58e
PB
1373fi
1374
359bc95d
PM
1375# Now we have handled --enable-tcg-interpreter and know we're not just
1376# printing the help message, bail out if the host CPU isn't supported.
1377if test "$ARCH" = "unknown"; then
1378 if test "$tcg_interpreter" = "yes" ; then
1379 echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1380 ARCH=tci
1381 else
76ad07a4 1382 error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
359bc95d
PM
1383 fi
1384fi
1385
9c83ffd8
PM
1386# Consult white-list to determine whether to enable werror
1387# by default. Only enable by default for git builds
1388z_version=`cut -f3 -d. $source_path/VERSION`
1389
1390if test -z "$werror" ; then
1391 if test -d "$source_path/.git" -a \
1392 "$linux" = "yes" ; then
1393 werror="yes"
1394 else
1395 werror="no"
1396 fi
1397fi
1398
8d05095c 1399# check that the C compiler works.
93b25869 1400write_c_skeleton;
8d05095c
PB
1401if compile_object ; then
1402 : C compiler works ok
1403else
76ad07a4 1404 error_exit "\"$cc\" either does not exist or does not work"
8d05095c 1405fi
0ef74c74
PM
1406if ! compile_prog ; then
1407 error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
1408fi
8d05095c 1409
98b21dcd
PM
1410# Check that the C++ compiler exists and works with the C compiler
1411if has $cxx; then
1412 cat > $TMPC <<EOF
1413int c_function(void);
1414int main(void) { return c_function(); }
1415EOF
1416
1417 compile_object
1418
9c83ffd8 1419 cat > $TMPCXX <<EOF
98b21dcd
PM
1420extern "C" {
1421 int c_function(void);
1422}
1423int c_function(void) { return 42; }
1424EOF
1425
9c83ffd8
PM
1426 update_cxxflags
1427
1428 if do_cxx $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $LDFLAGS; then
98b21dcd
PM
1429 # C++ compiler $cxx works ok with C compiler $cc
1430 :
1431 else
1432 echo "C++ compiler $cxx does not work with C compiler $cc"
1433 echo "Disabling C++ specific optional code"
1434 cxx=
1435 fi
1436else
1437 echo "No C++ compiler available; disabling C++ specific optional code"
1438 cxx=
1439fi
1440
8d05095c
PB
1441gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
1442gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
1443gcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
37746c5e 1444gcc_flags="-Wendif-labels $gcc_flags"
c1556a81 1445gcc_flags="-Wno-initializer-overrides $gcc_flags"
71429097 1446gcc_flags="-Wno-string-plus-int $gcc_flags"
6ca026cb
PM
1447# Note that we do not add -Werror to gcc_flags here, because that would
1448# enable it for all configure tests. If a configure test failed due
1449# to -Werror this would just silently disable some features,
1450# so it's too error prone.
93b25869
JS
1451
1452cc_has_warning_flag() {
1453 write_c_skeleton;
1454
a1d29d6c
PM
1455 # Use the positive sense of the flag when testing for -Wno-wombat
1456 # support (gcc will happily accept the -Wno- form of unknown
1457 # warning options).
93b25869
JS
1458 optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
1459 compile_prog "-Werror $optflag" ""
1460}
1461
1462for flag in $gcc_flags; do
1463 if cc_has_warning_flag $flag ; then
1464 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
8d05095c
PB
1465 fi
1466done
1467
3b463a3f 1468if test "$stack_protector" != "no"; then
fccd35a0
RR
1469 cat > $TMPC << EOF
1470int main(int argc, char *argv[])
1471{
1472 char arr[64], *p = arr, *c = argv[0];
1473 while (*c) {
1474 *p++ = *c++;
1475 }
1476 return 0;
1477}
1478EOF
63678e17 1479 gcc_flags="-fstack-protector-strong -fstack-protector-all"
3b463a3f 1480 sp_on=0
63678e17 1481 for flag in $gcc_flags; do
590e5dd9
PM
1482 # We need to check both a compile and a link, since some compiler
1483 # setups fail only on a .c->.o compile and some only at link time
1484 if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
1485 compile_prog "-Werror $flag" ""; then
63678e17 1486 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
3b463a3f 1487 sp_on=1
63678e17
SN
1488 break
1489 fi
1490 done
3b463a3f
MR
1491 if test "$stack_protector" = yes; then
1492 if test $sp_on = 0; then
1493 error_exit "Stack protector not supported"
1494 fi
1495 fi
37746c5e
MAL
1496fi
1497
cbdd1999
PB
1498# Workaround for http://gcc.gnu.org/PR55489. Happens with -fPIE/-fPIC and
1499# large functions that use global variables. The bug is in all releases of
1500# GCC, but it became particularly acute in 4.6.x and 4.7.x. It is fixed in
1501# 4.7.3 and 4.8.0. We should be able to delete this at the end of 2013.
1502cat > $TMPC << EOF
1503#if __GNUC__ == 4 && (__GNUC_MINOR__ == 6 || (__GNUC_MINOR__ == 7 && __GNUC_PATCHLEVEL__ <= 2))
1504int main(void) { return 0; }
1505#else
1506#error No bug in this compiler.
1507#endif
1508EOF
1509if compile_prog "-Werror -fno-gcse" "" ; then
1510 TRANSLATE_OPT_CFLAGS=-fno-gcse
1511fi
1512
40d6444e 1513if test "$static" = "yes" ; then
aa0d1f44
PB
1514 if test "$modules" = "yes" ; then
1515 error_exit "static and modules are mutually incompatible"
1516 fi
40d6444e 1517 if test "$pie" = "yes" ; then
76ad07a4 1518 error_exit "static and pie are mutually incompatible"
40d6444e
AK
1519 else
1520 pie="no"
1521 fi
1522fi
1523
768b7855
EC
1524# Unconditional check for compiler __thread support
1525 cat > $TMPC << EOF
1526static __thread int tls_var;
1527int main(void) { return tls_var; }
1528EOF
1529
1530if ! compile_prog "-Werror" "" ; then
1531 error_exit "Your compiler does not support the __thread specifier for " \
1532 "Thread-Local Storage (TLS). Please upgrade to a version that does."
1533fi
1534
40d6444e
AK
1535if test "$pie" = ""; then
1536 case "$cpu-$targetos" in
c72b26ec 1537 i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
40d6444e
AK
1538 ;;
1539 *)
1540 pie="no"
1541 ;;
1542 esac
1543fi
1544
1545if test "$pie" != "no" ; then
1546 cat > $TMPC << EOF
21d4a791
AK
1547
1548#ifdef __linux__
1549# define THREAD __thread
1550#else
1551# define THREAD
1552#endif
1553
1554static THREAD int tls_var;
1555
1556int main(void) { return tls_var; }
1557
40d6444e
AK
1558EOF
1559 if compile_prog "-fPIE -DPIE" "-pie"; then
1560 QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
1561 LDFLAGS="-pie $LDFLAGS"
1562 pie="yes"
1563 if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
1564 LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
1565 fi
1566 else
1567 if test "$pie" = "yes"; then
76ad07a4 1568 error_exit "PIE not available due to missing toolchain support"
40d6444e
AK
1569 else
1570 echo "Disabling PIE due to missing toolchain support"
1571 pie="no"
1572 fi
1573 fi
46eef33b 1574
e4a7b344 1575 if compile_prog "-Werror -fno-pie" "-nopie"; then
46eef33b
BS
1576 CFLAGS_NOPIE="-fno-pie"
1577 LDFLAGS_NOPIE="-nopie"
1578 fi
40d6444e
AK
1579fi
1580
09dada40
PB
1581##########################################
1582# __sync_fetch_and_and requires at least -march=i486. Many toolchains
1583# use i686 as default anyway, but for those that don't, an explicit
1584# specification is necessary
1585
1586if test "$cpu" = "i386"; then
1587 cat > $TMPC << EOF
1588static int sfaa(int *ptr)
1589{
1590 return __sync_fetch_and_and(ptr, 0);
1591}
1592
1593int main(void)
1594{
1595 int val = 42;
1405b629 1596 val = __sync_val_compare_and_swap(&val, 0, 1);
09dada40
PB
1597 sfaa(&val);
1598 return val;
1599}
1600EOF
1601 if ! compile_prog "" "" ; then
1602 QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
1603 fi
1604fi
1605
1606#########################################
ec530c81 1607# Solaris specific configure tool chain decisions
09dada40 1608
ec530c81 1609if test "$solaris" = "yes" ; then
6792aa11
LM
1610 if has $install; then
1611 :
1612 else
76ad07a4
PM
1613 error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
1614 "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
1615 "to get ginstall which is used by default (which lives in /opt/csw/bin)"
ec530c81 1616 fi
6792aa11 1617 if test "`path_of $install`" = "/usr/sbin/install" ; then
76ad07a4
PM
1618 error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
1619 "try ginstall from the GNU fileutils available from www.blastwave.org" \
1620 "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
ec530c81 1621 fi
6792aa11
LM
1622 if has ar; then
1623 :
1624 else
ec530c81 1625 if test -f /usr/ccs/bin/ar ; then
76ad07a4
PM
1626 error_exit "No path includes ar" \
1627 "Add /usr/ccs/bin to your path and rerun configure"
ec530c81 1628 fi
76ad07a4 1629 error_exit "No path includes ar"
ec530c81 1630 fi
5fafdf24 1631fi
ec530c81 1632
afb63ebd 1633if test -z "${target_list+xxx}" ; then
121afa9e
AL
1634 target_list="$default_target_list"
1635else
1636 target_list=`echo "$target_list" | sed -e 's/,/ /g'`
1637fi
25b48338
PM
1638
1639# Check that we recognised the target name; this allows a more
1640# friendly error message than if we let it fall through.
1641for target in $target_list; do
1642 case " $default_target_list " in
1643 *" $target "*)
1644 ;;
1645 *)
1646 error_exit "Unknown target name '$target'"
1647 ;;
1648 esac
1649done
1650
f55fe278
PB
1651# see if system emulation was really requested
1652case " $target_list " in
1653 *"-softmmu "*) softmmu=yes
1654 ;;
1655 *) softmmu=no
1656 ;;
1657esac
5327cf48 1658
249247c9
JQ
1659feature_not_found() {
1660 feature=$1
21684af0 1661 remedy=$2
249247c9 1662
76ad07a4 1663 error_exit "User requested feature $feature" \
21684af0
SS
1664 "configure was not able to find it." \
1665 "$remedy"
249247c9
JQ
1666}
1667
7d13299d
FB
1668# ---
1669# big/little endian test
1670cat > $TMPC << EOF
61cc919f
MF
1671short big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
1672short little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
1673extern int foo(short *, short *);
1674int main(int argc, char *argv[]) {
1675 return foo(big_endian, little_endian);
7d13299d
FB
1676}
1677EOF
1678
61cc919f
MF
1679if compile_object ; then
1680 if grep -q BiGeNdIaN $TMPO ; then
1681 bigendian="yes"
1682 elif grep -q LiTtLeEnDiAn $TMPO ; then
1683 bigendian="no"
1684 else
1685 echo big/little test failed
21d89f84 1686 fi
61cc919f
MF
1687else
1688 echo big/little test failed
7d13299d
FB
1689fi
1690
a30878e7
PM
1691##########################################
1692# cocoa implies not SDL or GTK
1693# (the cocoa UI code currently assumes it is always the active UI
1694# and doesn't interact well with other UI frontend code)
1695if test "$cocoa" = "yes"; then
1696 if test "$sdl" = "yes"; then
1697 error_exit "Cocoa and SDL UIs cannot both be enabled at once"
1698 fi
1699 if test "$gtk" = "yes"; then
1700 error_exit "Cocoa and GTK UIs cannot both be enabled at once"
1701 fi
1702 gtk=no
1703 sdl=no
1704fi
1705
015a33bd
GA
1706##########################################
1707# L2TPV3 probe
1708
1709cat > $TMPC <<EOF
1710#include <sys/socket.h>
bff6cb72 1711#include <linux/ip.h>
015a33bd
GA
1712int main(void) { return sizeof(struct mmsghdr); }
1713EOF
1714if compile_prog "" "" ; then
1715 l2tpv3=yes
1716else
1717 l2tpv3=no
1718fi
1719
4d9310f4
DB
1720##########################################
1721# MinGW / Mingw-w64 localtime_r/gmtime_r check
1722
1723if test "$mingw32" = "yes"; then
1724 # Some versions of MinGW / Mingw-w64 lack localtime_r
1725 # and gmtime_r entirely.
1726 #
1727 # Some versions of Mingw-w64 define a macro for
1728 # localtime_r/gmtime_r.
1729 #
1730 # Some versions of Mingw-w64 will define functions
1731 # for localtime_r/gmtime_r, but only if you have
1732 # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
1733 # though, unistd.h and pthread.h both define
1734 # that for you.
1735 #
1736 # So this #undef localtime_r and #include <unistd.h>
1737 # are not in fact redundant.
1738cat > $TMPC << EOF
1739#include <unistd.h>
1740#include <time.h>
1741#undef localtime_r
1742int main(void) { localtime_r(NULL, NULL); return 0; }
1743EOF
1744 if compile_prog "" "" ; then
1745 localtime_r="yes"
1746 else
1747 localtime_r="no"
1748 fi
1749fi
1750
779ab5e3
SW
1751##########################################
1752# pkg-config probe
1753
1754if ! has "$pkg_config_exe"; then
76ad07a4 1755 error_exit "pkg-config binary '$pkg_config_exe' not found"
779ab5e3
SW
1756fi
1757
b0a47e79
JQ
1758##########################################
1759# NPTL probe
1760
24cb36a6 1761if test "$linux_user" = "yes"; then
b0a47e79 1762 cat > $TMPC <<EOF
bd0c5661 1763#include <sched.h>
30813cea 1764#include <linux/futex.h>
182eacc0 1765int main(void) {
bd0c5661
PB
1766#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1767#error bork
1768#endif
182eacc0 1769 return 0;
bd0c5661
PB
1770}
1771EOF
24cb36a6 1772 if ! compile_object ; then
21684af0 1773 feature_not_found "nptl" "Install glibc and linux kernel headers."
b0a47e79 1774 fi
bd0c5661
PB
1775fi
1776
ac62922e 1777##########################################
99f2dbd3
LL
1778# avx2 optimization requirement check
1779
1780cat > $TMPC << EOF
1781static void bar(void) {}
1782static void *bar_ifunc(void) {return (void*) bar;}
1783static void foo(void) __attribute__((ifunc("bar_ifunc")));
1784int main(void) { foo(); return 0; }
1785EOF
1786if compile_prog "-mavx2" "" ; then
1787 if readelf --syms $TMPE |grep "IFUNC.*foo" >/dev/null 2>&1; then
1788 avx2_opt="yes"
1789 fi
1790fi
1791
1792#########################################
ac62922e
AZ
1793# zlib check
1794
1ece9905
AL
1795if test "$zlib" != "no" ; then
1796 cat > $TMPC << EOF
ac62922e
AZ
1797#include <zlib.h>
1798int main(void) { zlibVersion(); return 0; }
1799EOF
1ece9905
AL
1800 if compile_prog "" "-lz" ; then
1801 :
1802 else
76ad07a4
PM
1803 error_exit "zlib check failed" \
1804 "Make sure to have the zlib libs and headers installed."
1ece9905 1805 fi
ac62922e 1806fi
eb0ecd5a 1807LIBS="$LIBS -lz"
ac62922e 1808
607dacd0
QN
1809##########################################
1810# lzo check
1811
1812if test "$lzo" != "no" ; then
1813 cat > $TMPC << EOF
1814#include <lzo/lzo1x.h>
1815int main(void) { lzo_version(); return 0; }
1816EOF
1817 if compile_prog "" "-llzo2" ; then
b25c9dff
SW
1818 libs_softmmu="$libs_softmmu -llzo2"
1819 lzo="yes"
607dacd0 1820 else
b25c9dff
SW
1821 if test "$lzo" = "yes"; then
1822 feature_not_found "liblzo2" "Install liblzo2 devel"
1823 fi
1824 lzo="no"
607dacd0 1825 fi
607dacd0
QN
1826fi
1827
1828##########################################
1829# snappy check
1830
1831if test "$snappy" != "no" ; then
1832 cat > $TMPC << EOF
1833#include <snappy-c.h>
1834int main(void) { snappy_max_compressed_length(4096); return 0; }
1835EOF
1836 if compile_prog "" "-lsnappy" ; then
b25c9dff
SW
1837 libs_softmmu="$libs_softmmu -lsnappy"
1838 snappy="yes"
607dacd0 1839 else
b25c9dff
SW
1840 if test "$snappy" = "yes"; then
1841 feature_not_found "libsnappy" "Install libsnappy devel"
1842 fi
1843 snappy="no"
607dacd0 1844 fi
607dacd0
QN
1845fi
1846
6b383c08
PW
1847##########################################
1848# bzip2 check
1849
1850if test "$bzip2" != "no" ; then
1851 cat > $TMPC << EOF
1852#include <bzlib.h>
1853int main(void) { BZ2_bzlibVersion(); return 0; }
1854EOF
1855 if compile_prog "" "-lbz2" ; then
1856 bzip2="yes"
1857 else
1858 if test "$bzip2" = "yes"; then
1859 feature_not_found "libbzip2" "Install libbzip2 devel"
1860 fi
1861 bzip2="no"
1862 fi
1863fi
1864
f794573e
EO
1865##########################################
1866# libseccomp check
1867
1868if test "$seccomp" != "no" ; then
693e5910
AJ
1869 case "$cpu" in
1870 i386|x86_64)
ba060c53 1871 libseccomp_minver="2.1.0"
693e5910
AJ
1872 ;;
1873 arm|aarch64)
1874 libseccomp_minver="2.2.3"
1875 ;;
1876 *)
1877 libseccomp_minver=""
1878 ;;
1879 esac
1880
1881 if test "$libseccomp_minver" != "" &&
1882 $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
b4451996 1883 libs_softmmu="$libs_softmmu `$pkg_config --libs libseccomp`"
372e47e9 1884 QEMU_CFLAGS="$QEMU_CFLAGS `$pkg_config --cflags libseccomp`"
693e5910 1885 seccomp="yes"
f794573e 1886 else
693e5910
AJ
1887 if test "$seccomp" = "yes" ; then
1888 if test "$libseccomp_minver" != "" ; then
1889 feature_not_found "libseccomp" \
1890 "Install libseccomp devel >= $libseccomp_minver"
1891 else
1892 feature_not_found "libseccomp" \
1893 "libseccomp is not supported for host cpu $cpu"
1894 fi
1895 fi
1896 seccomp="no"
f794573e
EO
1897 fi
1898fi
e37630ca
AL
1899##########################################
1900# xen probe
1901
fc321b4b 1902if test "$xen" != "no" ; then
b2266bee 1903 xen_libs="-lxenstore -lxenctrl -lxenguest"
5eeb39c2 1904 xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
d5b93ddf 1905
50ced5b3
SW
1906 # First we test whether Xen headers and libraries are available.
1907 # If no, we are done and there is no Xen support.
1908 # If yes, more tests are run to detect the Xen version.
1909
1910 # Xen (any)
b2266bee 1911 cat > $TMPC <<EOF
e37630ca 1912#include <xenctrl.h>
50ced5b3
SW
1913int main(void) {
1914 return 0;
1915}
1916EOF
1917 if ! compile_prog "" "$xen_libs" ; then
1918 # Xen not found
1919 if test "$xen" = "yes" ; then
21684af0 1920 feature_not_found "xen" "Install xen devel"
50ced5b3
SW
1921 fi
1922 xen=no
1923
1924 # Xen unstable
69deef08
PM
1925 elif
1926 cat > $TMPC <<EOF &&
5eeb39c2
IC
1927/*
1928 * If we have stable libs the we don't want the libxc compat
1929 * layers, regardless of what CFLAGS we may have been given.
1930 */
1931#undef XC_WANT_COMPAT_EVTCHN_API
1932#undef XC_WANT_COMPAT_GNTTAB_API
1933#undef XC_WANT_COMPAT_MAP_FOREIGN_API
1934#include <xenctrl.h>
1935#include <xenstore.h>
1936#include <xenevtchn.h>
1937#include <xengnttab.h>
1938#include <xenforeignmemory.h>
1939#include <stdint.h>
1940#include <xen/hvm/hvm_info_table.h>
1941#if !defined(HVM_MAX_VCPUS)
1942# error HVM_MAX_VCPUS not defined
1943#endif
1944int main(void) {
1945 xc_interface *xc = NULL;
1946 xenforeignmemory_handle *xfmem;
1947 xenevtchn_handle *xe;
1948 xengnttab_handle *xg;
1949 xen_domain_handle_t handle;
1950
1951 xs_daemon_open();
1952
1953 xc = xc_interface_open(0, 0, 0);
1954 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1955 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1956 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
1957 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
1958 xc_domain_create(xc, 0, handle, 0, NULL, NULL);
1959
1960 xfmem = xenforeignmemory_open(0, 0);
1961 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
1962
1963 xe = xenevtchn_open(0, 0);
1964 xenevtchn_fd(xe);
1965
1966 xg = xengnttab_open(0, 0);
1967 xengnttab_map_grant_ref(xg, 0, 0, 0);
1968
1969 return 0;
1970}
1971EOF
1972 compile_prog "" "$xen_libs $xen_stable_libs"
1973 then
1974 xen_ctrl_version=471
1975 xen=yes
1976 elif
1977 cat > $TMPC <<EOF &&
50ced5b3 1978#include <xenctrl.h>
cdadde39
RPM
1979#include <stdint.h>
1980int main(void) {
1981 xc_interface *xc = NULL;
1982 xen_domain_handle_t handle;
1983 xc_domain_create(xc, 0, handle, 0, NULL, NULL);
1984 return 0;
1985}
1986EOF
1987 compile_prog "" "$xen_libs"
1988 then
1989 xen_ctrl_version=470
1990 xen=yes
1991
1992 # Xen 4.6
1993 elif
1994 cat > $TMPC <<EOF &&
1995#include <xenctrl.h>
e108a3c1 1996#include <xenstore.h>
d5b93ddf
AP
1997#include <stdint.h>
1998#include <xen/hvm/hvm_info_table.h>
1999#if !defined(HVM_MAX_VCPUS)
2000# error HVM_MAX_VCPUS not defined
2001#endif
d8b441a3
JB
2002int main(void) {
2003 xc_interface *xc;
2004 xs_daemon_open();
2005 xc = xc_interface_open(0, 0, 0);
2006 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2007 xc_gnttab_open(NULL, 0);
2008 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2009 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2010 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
20a544c7 2011 xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
d8b441a3
JB
2012 return 0;
2013}
2014EOF
2015 compile_prog "" "$xen_libs"
2016 then
2017 xen_ctrl_version=460
2018 xen=yes
2019
2020 # Xen 4.5
2021 elif
2022 cat > $TMPC <<EOF &&
2023#include <xenctrl.h>
2024#include <xenstore.h>
2025#include <stdint.h>
2026#include <xen/hvm/hvm_info_table.h>
2027#if !defined(HVM_MAX_VCPUS)
2028# error HVM_MAX_VCPUS not defined
2029#endif
3996e85c
PD
2030int main(void) {
2031 xc_interface *xc;
2032 xs_daemon_open();
2033 xc = xc_interface_open(0, 0, 0);
2034 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2035 xc_gnttab_open(NULL, 0);
2036 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2037 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2038 xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
2039 return 0;
2040}
2041EOF
2042 compile_prog "" "$xen_libs"
2043 then
2044 xen_ctrl_version=450
2045 xen=yes
2046
2047 elif
2048 cat > $TMPC <<EOF &&
2049#include <xenctrl.h>
2050#include <xenstore.h>
2051#include <stdint.h>
2052#include <xen/hvm/hvm_info_table.h>
2053#if !defined(HVM_MAX_VCPUS)
2054# error HVM_MAX_VCPUS not defined
2055#endif
8688e065
SS
2056int main(void) {
2057 xc_interface *xc;
2058 xs_daemon_open();
2059 xc = xc_interface_open(0, 0, 0);
2060 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2061 xc_gnttab_open(NULL, 0);
2062 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2063 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2064 return 0;
2065}
2066EOF
2067 compile_prog "" "$xen_libs"
69deef08 2068 then
8688e065
SS
2069 xen_ctrl_version=420
2070 xen=yes
2071
b2266bee 2072 else
fc321b4b 2073 if test "$xen" = "yes" ; then
edfb07ed
IC
2074 feature_not_found "xen (unsupported version)" \
2075 "Install a supported xen (xen 4.2 or newer)"
fc321b4b
JQ
2076 fi
2077 xen=no
b2266bee 2078 fi
d5b93ddf
AP
2079
2080 if test "$xen" = yes; then
5eeb39c2
IC
2081 if test $xen_ctrl_version -ge 471 ; then
2082 libs_softmmu="$xen_stable_libs $libs_softmmu"
2083 fi
d5b93ddf
AP
2084 libs_softmmu="$xen_libs $libs_softmmu"
2085 fi
e37630ca
AL
2086fi
2087
eb6fda0f 2088if test "$xen_pci_passthrough" != "no"; then
edfb07ed 2089 if test "$xen" = "yes" && test "$linux" = "yes"; then
eb6fda0f
AP
2090 xen_pci_passthrough=yes
2091 else
2092 if test "$xen_pci_passthrough" = "yes"; then
76ad07a4
PM
2093 error_exit "User requested feature Xen PCI Passthrough" \
2094 " but this feature requires /sys from Linux"
eb6fda0f
AP
2095 fi
2096 xen_pci_passthrough=no
2097 fi
2098fi
2099
64a7ad6f
IC
2100if test "$xen_pv_domain_build" = "yes" &&
2101 test "$xen" != "yes"; then
2102 error_exit "User requested Xen PV domain builder support" \
2103 "which requires Xen support."
2104fi
2105
dfffc653
JQ
2106##########################################
2107# Sparse probe
2108if test "$sparse" != "no" ; then
0dba6195 2109 if has cgcc; then
dfffc653
JQ
2110 sparse=yes
2111 else
2112 if test "$sparse" = "yes" ; then
21684af0 2113 feature_not_found "sparse" "Install sparse binary"
dfffc653
JQ
2114 fi
2115 sparse=no
2116 fi
2117fi
2118
f676c67e
JW
2119##########################################
2120# X11 probe
2121x11_cflags=
2122x11_libs=-lX11
2123if $pkg_config --exists "x11"; then
2124 x11_cflags=`$pkg_config --cflags x11`
2125 x11_libs=`$pkg_config --libs x11`
2126fi
2127
a4ccabcf
AL
2128##########################################
2129# GTK probe
2130
9e04c683
SW
2131if test "$gtkabi" = ""; then
2132 # The GTK ABI was not specified explicitly, so try whether 2.0 is available.
2133 # Use 3.0 as a fallback if that is available.
2134 if $pkg_config --exists "gtk+-2.0 >= 2.18.0"; then
2135 gtkabi=2.0
2136 elif $pkg_config --exists "gtk+-3.0 >= 3.0.0"; then
2137 gtkabi=3.0
2138 else
2139 gtkabi=2.0
2140 fi
2141fi
2142
a4ccabcf 2143if test "$gtk" != "no"; then
528de90a 2144 gtkpackage="gtk+-$gtkabi"
0a337ed0 2145 gtkx11package="gtk+-x11-$gtkabi"
528de90a
DB
2146 if test "$gtkabi" = "3.0" ; then
2147 gtkversion="3.0.0"
bbbf9bfb
SW
2148 else
2149 gtkversion="2.18.0"
2150 fi
2151 if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
2152 gtk_cflags=`$pkg_config --cflags $gtkpackage`
2153 gtk_libs=`$pkg_config --libs $gtkpackage`
0a337ed0 2154 if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
f676c67e
JW
2155 gtk_cflags="$gtk_cflags $x11_cflags"
2156 gtk_libs="$gtk_libs $x11_libs"
0a337ed0 2157 fi
bbbf9bfb
SW
2158 libs_softmmu="$gtk_libs $libs_softmmu"
2159 gtk="yes"
2160 elif test "$gtk" = "yes"; then
9e04c683 2161 feature_not_found "gtk" "Install gtk2 or gtk3 devel"
bbbf9bfb
SW
2162 else
2163 gtk="no"
2164 fi
2165fi
2166
ddbb0d09
DB
2167
2168##########################################
2169# GNUTLS probe
2170
37371299
PM
2171gnutls_works() {
2172 # Unfortunately some distros have bad pkg-config information for gnutls
2173 # such that it claims to exist but you get a compiler error if you try
2174 # to use the options returned by --libs. Specifically, Ubuntu for --static
2175 # builds doesn't work:
2176 # https://bugs.launchpad.net/ubuntu/+source/gnutls26/+bug/1478035
2177 #
2178 # So sanity check the cflags/libs before assuming gnutls can be used.
2179 if ! $pkg_config --exists "gnutls"; then
2180 return 1
2181 fi
2182
2183 write_c_skeleton
2184 compile_prog "$($pkg_config --cflags gnutls)" "$($pkg_config --libs gnutls)"
2185}
2186
62893b67 2187gnutls_gcrypt=no
ed754746 2188gnutls_nettle=no
ddbb0d09 2189if test "$gnutls" != "no"; then
37371299 2190 if gnutls_works; then
ddbb0d09
DB
2191 gnutls_cflags=`$pkg_config --cflags gnutls`
2192 gnutls_libs=`$pkg_config --libs gnutls`
2193 libs_softmmu="$gnutls_libs $libs_softmmu"
2194 libs_tools="$gnutls_libs $libs_tools"
2195 QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
2196 gnutls="yes"
2197
2198 # gnutls_hash_init requires >= 2.9.10
2199 if $pkg_config --exists "gnutls >= 2.9.10"; then
2200 gnutls_hash="yes"
2201 else
2202 gnutls_hash="no"
2203 fi
62893b67 2204
b917da4c
DB
2205 # gnutls_rnd requires >= 2.11.0
2206 if $pkg_config --exists "gnutls >= 2.11.0"; then
2207 gnutls_rnd="yes"
2208 else
2209 gnutls_rnd="no"
2210 fi
2211
62893b67
DB
2212 if $pkg_config --exists 'gnutls >= 3.0'; then
2213 gnutls_gcrypt=no
ed754746 2214 gnutls_nettle=yes
62893b67
DB
2215 elif $pkg_config --exists 'gnutls >= 2.12'; then
2216 case `$pkg_config --libs --static gnutls` in
ed754746
DB
2217 *gcrypt*)
2218 gnutls_gcrypt=yes
2219 gnutls_nettle=no
2220 ;;
2221 *nettle*)
2222 gnutls_gcrypt=no
2223 gnutls_nettle=yes
2224 ;;
2225 *)
2226 gnutls_gcrypt=yes
2227 gnutls_nettle=no
2228 ;;
62893b67
DB
2229 esac
2230 else
2231 gnutls_gcrypt=yes
ed754746 2232 gnutls_nettle=no
62893b67 2233 fi
ddbb0d09
DB
2234 elif test "$gnutls" = "yes"; then
2235 feature_not_found "gnutls" "Install gnutls devel"
2236 else
2237 gnutls="no"
2238 gnutls_hash="no"
b917da4c 2239 gnutls_rnd="no"
ddbb0d09
DB
2240 fi
2241else
2242 gnutls_hash="no"
b917da4c 2243 gnutls_rnd="no"
ddbb0d09
DB
2244fi
2245
91bfcdb0
DB
2246
2247# If user didn't give a --disable/enable-gcrypt flag,
2248# then mark as disabled if user requested nettle
2249# explicitly, or if gnutls links to nettle
2250if test -z "$gcrypt"
2251then
2252 if test "$nettle" = "yes" || test "$gnutls_nettle" = "yes"
2253 then
2254 gcrypt="no"
2255 fi
2256fi
2257
2258# If user didn't give a --disable/enable-nettle flag,
2259# then mark as disabled if user requested gcrypt
2260# explicitly, or if gnutls links to gcrypt
2261if test -z "$nettle"
2262then
2263 if test "$gcrypt" = "yes" || test "$gnutls_gcrypt" = "yes"
2264 then
2265 nettle="no"
2266 fi
2267fi
2268
2269has_libgcrypt_config() {
2270 if ! has "libgcrypt-config"
2271 then
2272 return 1
2273 fi
2274
2275 if test -n "$cross_prefix"
2276 then
2277 host=`libgcrypt-config --host`
2278 if test "$host-" != $cross_prefix
2279 then
2280 return 1
2281 fi
2282 fi
2283
2284 return 0
2285}
2286
2287if test "$gcrypt" != "no"; then
2288 if has_libgcrypt_config; then
62893b67
DB
2289 gcrypt_cflags=`libgcrypt-config --cflags`
2290 gcrypt_libs=`libgcrypt-config --libs`
91bfcdb0
DB
2291 # Debian has remove -lgpg-error from libgcrypt-config
2292 # as it "spreads unnecessary dependencies" which in
2293 # turn breaks static builds...
2294 if test "$static" = "yes"
2295 then
2296 gcrypt_libs="$gcrypt_libs -lgpg-error"
2297 fi
62893b67
DB
2298 libs_softmmu="$gcrypt_libs $libs_softmmu"
2299 libs_tools="$gcrypt_libs $libs_tools"
2300 QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
91bfcdb0
DB
2301 gcrypt="yes"
2302 if test -z "$nettle"; then
2303 nettle="no"
2304 fi
62893b67 2305 else
91bfcdb0
DB
2306 if test "$gcrypt" = "yes"; then
2307 feature_not_found "gcrypt" "Install gcrypt devel"
2308 else
2309 gcrypt="no"
2310 fi
62893b67
DB
2311 fi
2312fi
2313
ddbb0d09 2314
91bfcdb0 2315if test "$nettle" != "no"; then
ed754746
DB
2316 if $pkg_config --exists "nettle"; then
2317 nettle_cflags=`$pkg_config --cflags nettle`
2318 nettle_libs=`$pkg_config --libs nettle`
becaeb72 2319 nettle_version=`$pkg_config --modversion nettle`
ed754746
DB
2320 libs_softmmu="$nettle_libs $libs_softmmu"
2321 libs_tools="$nettle_libs $libs_tools"
2322 QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
91bfcdb0 2323 nettle="yes"
ed754746 2324 else
91bfcdb0
DB
2325 if test "$nettle" = "yes"; then
2326 feature_not_found "nettle" "Install nettle devel"
2327 else
2328 nettle="no"
2329 fi
ed754746
DB
2330 fi
2331fi
2332
91bfcdb0
DB
2333if test "$gcrypt" = "yes" && test "$nettle" = "yes"
2334then
2335 error_exit "Only one of gcrypt & nettle can be enabled"
2336fi
2337
9a2fd434
DB
2338##########################################
2339# libtasn1 - only for the TLS creds/session test suite
2340
2341tasn1=yes
90246037
DB
2342tasn1_cflags=""
2343tasn1_libs=""
9a2fd434
DB
2344if $pkg_config --exists "libtasn1"; then
2345 tasn1_cflags=`$pkg_config --cflags libtasn1`
2346 tasn1_libs=`$pkg_config --libs libtasn1`
9a2fd434
DB
2347else
2348 tasn1=no
2349fi
2350
ed754746 2351
559607ea
DB
2352##########################################
2353# getifaddrs (for tests/test-io-channel-socket )
2354
2355have_ifaddrs_h=yes
2356if ! check_include "ifaddrs.h" ; then
2357 have_ifaddrs_h=no
2358fi
2359
bbbf9bfb
SW
2360##########################################
2361# VTE probe
2362
2363if test "$vte" != "no"; then
2364 if test "$gtkabi" = "3.0"; then
528de90a
DB
2365 vtepackage="vte-2.90"
2366 vteversion="0.32.0"
2367 else
528de90a
DB
2368 vtepackage="vte"
2369 vteversion="0.24.0"
2370 fi
bbbf9bfb
SW
2371 if $pkg_config --exists "$vtepackage >= $vteversion"; then
2372 vte_cflags=`$pkg_config --cflags $vtepackage`
2373 vte_libs=`$pkg_config --libs $vtepackage`
2374 libs_softmmu="$vte_libs $libs_softmmu"
2375 vte="yes"
2376 elif test "$vte" = "yes"; then
9e04c683
SW
2377 if test "$gtkabi" = "3.0"; then
2378 feature_not_found "vte" "Install libvte-2.90 devel"
2379 else
2380 feature_not_found "vte" "Install libvte devel"
2381 fi
0d185e63 2382 else
bbbf9bfb 2383 vte="no"
a4ccabcf
AL
2384 fi
2385fi
2386
11d9f695
FB
2387##########################################
2388# SDL probe
2389
3ec87ffe
PB
2390# Look for sdl configuration program (pkg-config or sdl-config). Try
2391# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
47c03744
DA
2392
2393if test $sdlabi = "2.0"; then
2394 sdl_config=$sdl2_config
2395 sdlname=sdl2
2396 sdlconfigname=sdl2_config
2397else
2398 sdlname=sdl
2399 sdlconfigname=sdl_config
2400fi
2401
2402if test "`basename $sdl_config`" != $sdlconfigname && ! has ${sdl_config}; then
2403 sdl_config=$sdlconfigname
3ec87ffe
PB
2404fi
2405
47c03744
DA
2406if $pkg_config $sdlname --exists; then
2407 sdlconfig="$pkg_config $sdlname"
9316f803 2408 _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
3ec87ffe
PB
2409elif has ${sdl_config}; then
2410 sdlconfig="$sdl_config"
9316f803 2411 _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
a0dfd8a4
LM
2412else
2413 if test "$sdl" = "yes" ; then
21684af0 2414 feature_not_found "sdl" "Install SDL devel"
a0dfd8a4
LM
2415 fi
2416 sdl=no
9316f803 2417fi
29e5bada 2418if test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
3ec87ffe
PB
2419 echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
2420fi
11d9f695 2421
9316f803 2422sdl_too_old=no
c4198157 2423if test "$sdl" != "no" ; then
ac119f9d 2424 cat > $TMPC << EOF
11d9f695
FB
2425#include <SDL.h>
2426#undef main /* We don't want SDL to override our main() */
2427int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
2428EOF
9316f803 2429 sdl_cflags=`$sdlconfig --cflags 2> /dev/null`
74f42e18
T
2430 if test "$static" = "yes" ; then
2431 sdl_libs=`$sdlconfig --static-libs 2>/dev/null`
2432 else
2433 sdl_libs=`$sdlconfig --libs 2> /dev/null`
2434 fi
52166aa0 2435 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
ac119f9d
JQ
2436 if test "$_sdlversion" -lt 121 ; then
2437 sdl_too_old=yes
2438 else
a30878e7 2439 sdl=yes
ac119f9d 2440 fi
cd01b4a3 2441
67c274d3 2442 # static link with sdl ? (note: sdl.pc's --static --libs is broken)
ac119f9d 2443 if test "$sdl" = "yes" -a "$static" = "yes" ; then
67c274d3 2444 if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
f8aa6c7b
SW
2445 sdl_libs="$sdl_libs `aalib-config --static-libs 2>/dev/null`"
2446 sdl_cflags="$sdl_cflags `aalib-config --cflags 2>/dev/null`"
ac119f9d 2447 fi
52166aa0 2448 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
ac119f9d
JQ
2449 :
2450 else
2451 sdl=no
2452 fi
2453 fi # static link
c4198157
JQ
2454 else # sdl not found
2455 if test "$sdl" = "yes" ; then
21684af0 2456 feature_not_found "sdl" "Install SDL devel"
c4198157
JQ
2457 fi
2458 sdl=no
ac119f9d 2459 fi # sdl compile test
a68551bc 2460fi
11d9f695 2461
5368a422 2462if test "$sdl" = "yes" ; then
ac119f9d 2463 cat > $TMPC <<EOF
5368a422
AL
2464#include <SDL.h>
2465#if defined(SDL_VIDEO_DRIVER_X11)
2466#include <X11/XKBlib.h>
2467#else
2468#error No x11 support
2469#endif
2470int main(void) { return 0; }
2471EOF
f676c67e
JW
2472 if compile_prog "$sdl_cflags $x11_cflags" "$sdl_libs $x11_libs" ; then
2473 sdl_cflags="$sdl_cflags $x11_cflags"
2474 sdl_libs="$sdl_libs $x11_libs"
ac119f9d 2475 fi
0705667e 2476 libs_softmmu="$sdl_libs $libs_softmmu"
5368a422
AL
2477fi
2478
2da776db
MH
2479##########################################
2480# RDMA needs OpenFabrics libraries
2481if test "$rdma" != "no" ; then
2482 cat > $TMPC <<EOF
2483#include <rdma/rdma_cma.h>
2484int main(void) { return 0; }
2485EOF
2486 rdma_libs="-lrdmacm -libverbs"
2487 if compile_prog "" "$rdma_libs" ; then
2488 rdma="yes"
2489 libs_softmmu="$libs_softmmu $rdma_libs"
2490 else
2491 if test "$rdma" = "yes" ; then
2492 error_exit \
2493 " OpenFabrics librdmacm/libibverbs not present." \
2494 " Your options:" \
2495 " (1) Fast: Install infiniband packages from your distro." \
2496 " (2) Cleanest: Install libraries from www.openfabrics.org" \
2497 " (3) Also: Install softiwarp if you don't have RDMA hardware"
2498 fi
2499 rdma="no"
2500 fi
2501fi
2502
95c6bff3 2503
2f9606b3
AL
2504##########################################
2505# VNC SASL detection
821601ea 2506if test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
ea784e3b 2507 cat > $TMPC <<EOF
2f9606b3
AL
2508#include <sasl/sasl.h>
2509#include <stdio.h>
2510int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
2511EOF
ea784e3b
JQ
2512 # Assuming Cyrus-SASL installed in /usr prefix
2513 vnc_sasl_cflags=""
2514 vnc_sasl_libs="-lsasl2"
2515 if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
2516 vnc_sasl=yes
2517 libs_softmmu="$vnc_sasl_libs $libs_softmmu"
ca273d58 2518 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
ea784e3b
JQ
2519 else
2520 if test "$vnc_sasl" = "yes" ; then
21684af0 2521 feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
2f9606b3 2522 fi
ea784e3b
JQ
2523 vnc_sasl=no
2524 fi
2f9606b3
AL
2525fi
2526
2f6f5c7a
CC
2527##########################################
2528# VNC JPEG detection
821601ea 2529if test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
2f6f5c7a
CC
2530cat > $TMPC <<EOF
2531#include <stdio.h>
2532#include <jpeglib.h>
2533int main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
2534EOF
2535 vnc_jpeg_cflags=""
2536 vnc_jpeg_libs="-ljpeg"
2537 if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
2538 vnc_jpeg=yes
2539 libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
ca273d58 2540 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
2f6f5c7a
CC
2541 else
2542 if test "$vnc_jpeg" = "yes" ; then
21684af0 2543 feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
2f6f5c7a
CC
2544 fi
2545 vnc_jpeg=no
2546 fi
2547fi
2548
efe556ad
CC
2549##########################################
2550# VNC PNG detection
821601ea 2551if test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
efe556ad
CC
2552cat > $TMPC <<EOF
2553//#include <stdio.h>
2554#include <png.h>
832ce9c2 2555#include <stddef.h>
efe556ad
CC
2556int main(void) {
2557 png_structp png_ptr;
2558 png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
7edc3fed 2559 return png_ptr != 0;
efe556ad
CC
2560}
2561EOF
65d5d3f9 2562 if $pkg_config libpng --exists; then
ca871ec8
SW
2563 vnc_png_cflags=`$pkg_config libpng --cflags`
2564 vnc_png_libs=`$pkg_config libpng --libs`
9af8025e 2565 else
efe556ad
CC
2566 vnc_png_cflags=""
2567 vnc_png_libs="-lpng"
9af8025e 2568 fi
efe556ad
CC
2569 if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
2570 vnc_png=yes
2571 libs_softmmu="$vnc_png_libs $libs_softmmu"
9af8025e 2572 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
efe556ad
CC
2573 else
2574 if test "$vnc_png" = "yes" ; then
21684af0 2575 feature_not_found "vnc-png" "Install libpng devel"
efe556ad
CC
2576 fi
2577 vnc_png=no
2578 fi
2579fi
2580
76655d6d
AL
2581##########################################
2582# fnmatch() probe, used for ACL routines
2583fnmatch="no"
2584cat > $TMPC << EOF
2585#include <fnmatch.h>
2586int main(void)
2587{
2588 fnmatch("foo", "foo", 0);
2589 return 0;
2590}
2591EOF
52166aa0 2592if compile_prog "" "" ; then
76655d6d
AL
2593 fnmatch="yes"
2594fi
2595
ee682d27
SW
2596##########################################
2597# uuid_generate() probe, used for vdi block driver
2d16c8e9
PM
2598# Note that on some systems (notably MacOSX) no extra library
2599# need be linked to get the uuid functions.
ee682d27
SW
2600if test "$uuid" != "no" ; then
2601 uuid_libs="-luuid"
2602 cat > $TMPC << EOF
2603#include <uuid/uuid.h>
2604int main(void)
2605{
2606 uuid_t my_uuid;
2607 uuid_generate(my_uuid);
2608 return 0;
2609}
2610EOF
2d16c8e9
PM
2611 if compile_prog "" "" ; then
2612 uuid="yes"
2613 elif compile_prog "" "$uuid_libs" ; then
ee682d27
SW
2614 uuid="yes"
2615 libs_softmmu="$uuid_libs $libs_softmmu"
2616 libs_tools="$uuid_libs $libs_tools"
2617 else
2618 if test "$uuid" = "yes" ; then
21684af0 2619 feature_not_found "uuid" "Install libuuid devel"
ee682d27
SW
2620 fi
2621 uuid=no
2622 fi
2623fi
2624
4f18b782
JC
2625if test "$vhdx" = "yes" ; then
2626 if test "$uuid" = "no" ; then
2627 error_exit "uuid required for VHDX support"
2628 fi
2629elif test "$vhdx" != "no" ; then
2630 if test "$uuid" = "yes" ; then
2631 vhdx=yes
2632 else
2633 vhdx=no
2634 fi
2635fi
2636
dce512de
CH
2637##########################################
2638# xfsctl() probe, used for raw-posix
2639if test "$xfs" != "no" ; then
2640 cat > $TMPC << EOF
ffc41d10 2641#include <stddef.h> /* NULL */
dce512de
CH
2642#include <xfs/xfs.h>
2643int main(void)
2644{
2645 xfsctl(NULL, 0, 0, NULL);
2646 return 0;
2647}
2648EOF
2649 if compile_prog "" "" ; then
2650 xfs="yes"
2651 else
2652 if test "$xfs" = "yes" ; then
21684af0 2653 feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
dce512de
CH
2654 fi
2655 xfs=no
2656 fi
2657fi
2658
8a16d273
TS
2659##########################################
2660# vde libraries probe
dfb278bd 2661if test "$vde" != "no" ; then
4baae0ac 2662 vde_libs="-lvdeplug"
8a16d273
TS
2663 cat > $TMPC << EOF
2664#include <libvdeplug.h>
4a7f0e06
PB
2665int main(void)
2666{
2667 struct vde_open_args a = {0, 0, 0};
fea08e08
PM
2668 char s[] = "";
2669 vde_open(s, s, &a);
4a7f0e06
PB
2670 return 0;
2671}
8a16d273 2672EOF
52166aa0 2673 if compile_prog "" "$vde_libs" ; then
4baae0ac 2674 vde=yes
8e02e54c
JQ
2675 libs_softmmu="$vde_libs $libs_softmmu"
2676 libs_tools="$vde_libs $libs_tools"
dfb278bd
JQ
2677 else
2678 if test "$vde" = "yes" ; then
21684af0 2679 feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
dfb278bd
JQ
2680 fi
2681 vde=no
4baae0ac 2682 fi
8a16d273
TS
2683fi
2684
58952137 2685##########################################
0a985b37
VM
2686# netmap support probe
2687# Apart from looking for netmap headers, we make sure that the host API version
2688# supports the netmap backend (>=11). The upper bound (15) is meant to simulate
2689# a minor/major version number. Minor new features will be marked with values up
2690# to 15, and if something happens that requires a change to the backend we will
2691# move above 15, submit the backend fixes and modify this two bounds.
58952137
VM
2692if test "$netmap" != "no" ; then
2693 cat > $TMPC << EOF
2694#include <inttypes.h>
2695#include <net/if.h>
2696#include <net/netmap.h>
2697#include <net/netmap_user.h>
0a985b37
VM
2698#if (NETMAP_API < 11) || (NETMAP_API > 15)
2699#error
2700#endif
58952137
VM
2701int main(void) { return 0; }
2702EOF
2703 if compile_prog "" "" ; then
2704 netmap=yes
2705 else
2706 if test "$netmap" = "yes" ; then
2707 feature_not_found "netmap"
2708 fi
2709 netmap=no
2710 fi
2711fi
2712
47e98658
CB
2713##########################################
2714# libcap-ng library probe
2715if test "$cap_ng" != "no" ; then
2716 cap_libs="-lcap-ng"
2717 cat > $TMPC << EOF
2718#include <cap-ng.h>
2719int main(void)
2720{
2721 capng_capability_to_name(CAPNG_EFFECTIVE);
2722 return 0;
2723}
2724EOF
2725 if compile_prog "" "$cap_libs" ; then
2726 cap_ng=yes
2727 libs_tools="$cap_libs $libs_tools"
2728 else
2729 if test "$cap_ng" = "yes" ; then
21684af0 2730 feature_not_found "cap_ng" "Install libcap-ng devel"
47e98658
CB
2731 fi
2732 cap_ng=no
2733 fi
2734fi
2735
8f28f3fb 2736##########################################
c2de5c91 2737# Sound support libraries probe
8f28f3fb 2738
c2de5c91 2739audio_drv_probe()
2740{
2741 drv=$1
2742 hdr=$2
2743 lib=$3
2744 exp=$4
2745 cfl=$5
2746 cat > $TMPC << EOF
2747#include <$hdr>
2748int main(void) { $exp }
8f28f3fb 2749EOF
52166aa0 2750 if compile_prog "$cfl" "$lib" ; then
c2de5c91 2751 :
2752 else
76ad07a4
PM
2753 error_exit "$drv check failed" \
2754 "Make sure to have the $drv libs and headers installed."
c2de5c91 2755 fi
2756}
2757
2fa7d3bf 2758audio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
c2de5c91 2759for drv in $audio_drv_list; do
2760 case $drv in
2761 alsa)
2762 audio_drv_probe $drv alsa/asoundlib.h -lasound \
e35bcb0c 2763 "return snd_pcm_close((snd_pcm_t *)0);"
a4bf6780 2764 libs_softmmu="-lasound $libs_softmmu"
c2de5c91 2765 ;;
2766
b8e59f18 2767 pa)
a394aed2
MAL
2768 audio_drv_probe $drv pulse/mainloop.h "-lpulse" \
2769 "pa_mainloop *m = 0; pa_mainloop_free (m); return 0;"
2770 libs_softmmu="-lpulse $libs_softmmu"
67f86e8e 2771 audio_pt_int="yes"
b8e59f18 2772 ;;
2773
997e690a
JQ
2774 coreaudio)
2775 libs_softmmu="-framework CoreAudio $libs_softmmu"
2776 ;;
2777
a4bf6780
JQ
2778 dsound)
2779 libs_softmmu="-lole32 -ldxguid $libs_softmmu"
d5631638 2780 audio_win_int="yes"
a4bf6780
JQ
2781 ;;
2782
2783 oss)
2784 libs_softmmu="$oss_lib $libs_softmmu"
2785 ;;
2786
2787 sdl|wav)
2f6a1ab0
BS
2788 # XXX: Probes for CoreAudio, DirectSound, SDL(?)
2789 ;;
2790
e4c63a6a 2791 *)
1c9b2a52 2792 echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
76ad07a4
PM
2793 error_exit "Unknown driver '$drv' selected" \
2794 "Possible drivers are: $audio_possible_drivers"
e4c63a6a 2795 }
2796 ;;
c2de5c91 2797 esac
2798done
8f28f3fb 2799
2e4d9fb1
AJ
2800##########################################
2801# BrlAPI probe
2802
4ffcedb6 2803if test "$brlapi" != "no" ; then
eb82284f
JQ
2804 brlapi_libs="-lbrlapi"
2805 cat > $TMPC << EOF
2e4d9fb1 2806#include <brlapi.h>
832ce9c2 2807#include <stddef.h>
2e4d9fb1
AJ
2808int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
2809EOF
52166aa0 2810 if compile_prog "" "$brlapi_libs" ; then
eb82284f 2811 brlapi=yes
264606b3 2812 libs_softmmu="$brlapi_libs $libs_softmmu"
4ffcedb6
JQ
2813 else
2814 if test "$brlapi" = "yes" ; then
21684af0 2815 feature_not_found "brlapi" "Install brlapi devel"
4ffcedb6
JQ
2816 fi
2817 brlapi=no
eb82284f
JQ
2818 fi
2819fi
2e4d9fb1 2820
4d3b6f6e
AZ
2821##########################################
2822# curses probe
a3605bf6
MT
2823if test "$curses" != "no" ; then
2824 if test "$mingw32" = "yes" ; then
e095e2f3 2825 curses_list="-lpdcurses"
a3605bf6 2826 else
cfeda5f4 2827 curses_list="$($pkg_config --libs ncurses 2>/dev/null):-lncurses:-lcurses"
a3605bf6 2828 fi
c584a6d0 2829 curses_found=no
4d3b6f6e
AZ
2830 cat > $TMPC << EOF
2831#include <curses.h>
ef9a2524
SW
2832int main(void) {
2833 const char *s = curses_version();
2834 resize_term(0, 0);
2835 return s != 0;
2836}
4d3b6f6e 2837EOF
ecbe251f 2838 IFS=:
4f78ef9a 2839 for curses_lib in $curses_list; do
ecbe251f 2840 unset IFS
4f78ef9a 2841 if compile_prog "" "$curses_lib" ; then
c584a6d0 2842 curses_found=yes
4f78ef9a
JQ
2843 libs_softmmu="$curses_lib $libs_softmmu"
2844 break
2845 fi
2846 done
ecbe251f 2847 unset IFS
c584a6d0
JQ
2848 if test "$curses_found" = "yes" ; then
2849 curses=yes
2850 else
2851 if test "$curses" = "yes" ; then
21684af0 2852 feature_not_found "curses" "Install ncurses devel"
c584a6d0
JQ
2853 fi
2854 curses=no
2855 fi
4f78ef9a 2856fi
4d3b6f6e 2857
769ce76d
AG
2858##########################################
2859# curl probe
788c8196 2860if test "$curl" != "no" ; then
65d5d3f9 2861 if $pkg_config libcurl --exists; then
a3605bf6
MT
2862 curlconfig="$pkg_config libcurl"
2863 else
2864 curlconfig=curl-config
2865 fi
769ce76d
AG
2866 cat > $TMPC << EOF
2867#include <curl/curl.h>
0b862ced 2868int main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
769ce76d 2869EOF
4e2b0658
PB
2870 curl_cflags=`$curlconfig --cflags 2>/dev/null`
2871 curl_libs=`$curlconfig --libs 2>/dev/null`
b1d5a277 2872 if compile_prog "$curl_cflags" "$curl_libs" ; then
769ce76d 2873 curl=yes
788c8196
JQ
2874 else
2875 if test "$curl" = "yes" ; then
21684af0 2876 feature_not_found "curl" "Install libcurl devel"
788c8196
JQ
2877 fi
2878 curl=no
769ce76d
AG
2879 fi
2880fi # test "$curl"
2881
fb599c9a
AZ
2882##########################################
2883# bluez support probe
a20a6f46 2884if test "$bluez" != "no" ; then
e820e3f4
AZ
2885 cat > $TMPC << EOF
2886#include <bluetooth/bluetooth.h>
2887int main(void) { return bt_error(0); }
2888EOF
a8bd70ad
PB
2889 bluez_cflags=`$pkg_config --cflags bluez 2> /dev/null`
2890 bluez_libs=`$pkg_config --libs bluez 2> /dev/null`
52166aa0 2891 if compile_prog "$bluez_cflags" "$bluez_libs" ; then
a20a6f46 2892 bluez=yes
e482d56a 2893 libs_softmmu="$bluez_libs $libs_softmmu"
e820e3f4 2894 else
a20a6f46 2895 if test "$bluez" = "yes" ; then
21684af0 2896 feature_not_found "bluez" "Install bluez-libs/libbluetooth devel"
a20a6f46 2897 fi
e820e3f4
AZ
2898 bluez="no"
2899 fi
fb599c9a
AZ
2900fi
2901
e18df141
AL
2902##########################################
2903# glib support probe
a52d28af 2904
f40685c6 2905glib_req_ver=2.22
aa0d1f44
PB
2906glib_modules=gthread-2.0
2907if test "$modules" = yes; then
2908 glib_modules="$glib_modules gmodule-2.0"
2909fi
e26110cf 2910
aa0d1f44 2911for i in $glib_modules; do
e26110cf
FZ
2912 if $pkg_config --atleast-version=$glib_req_ver $i; then
2913 glib_cflags=`$pkg_config --cflags $i`
2914 glib_libs=`$pkg_config --libs $i`
2915 CFLAGS="$glib_cflags $CFLAGS"
2916 LIBS="$glib_libs $LIBS"
2917 libs_qga="$glib_libs $libs_qga"
2918 else
2919 error_exit "glib-$glib_req_ver $i is required to compile QEMU"
2920 fi
2921done
2922
977a82ab
DB
2923# Sanity check that the current size_t matches the
2924# size that glib thinks it should be. This catches
2925# problems on multi-arch where people try to build
2926# 32-bit QEMU while pointing at 64-bit glib headers
2927cat > $TMPC <<EOF
2928#include <glib.h>
2929#include <unistd.h>
2930
2931#define QEMU_BUILD_BUG_ON(x) \
2932 typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
2933
2934int main(void) {
2935 QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
2936 return 0;
2937}
2938EOF
2939
2940if ! compile_prog "-Werror $CFLAGS" "$LIBS" ; then
2941 error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
2942 "You probably need to set PKG_CONFIG_LIBDIR"\
2943 "to point to the right pkg-config files for your"\
2944 "build target"
2945fi
2946
9d41401b
MT
2947# g_test_trap_subprocess added in 2.38. Used by some tests.
2948glib_subprocess=yes
2949if ! $pkg_config --atleast-version=2.38 glib-2.0; then
2950 glib_subprocess=no
2951fi
2952
bbbf2e04
JS
2953# Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
2954cat > $TMPC << EOF
2955#include <glib.h>
2956int main(void) { return 0; }
2957EOF
2958if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
2959 if cc_has_warning_flag "-Wno-unknown-attributes"; then
2960 glib_cflags="-Wno-unknown-attributes $glib_cflags"
2961 CFLAGS="-Wno-unknown-attributes $CFLAGS"
2962 fi
2963fi
2964
e26110cf
FZ
2965##########################################
2966# SHA command probe for modules
2967if test "$modules" = yes; then
2968 shacmd_probe="sha1sum sha1 shasum"
2969 for c in $shacmd_probe; do
8ccefb91 2970 if has $c; then
e26110cf
FZ
2971 shacmd="$c"
2972 break
2973 fi
2974 done
2975 if test "$shacmd" = ""; then
2976 error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
2977 fi
e18df141
AL
2978fi
2979
e2134eb9
GH
2980##########################################
2981# pixman support probe
2982
2983if test "$pixman" = ""; then
74880fe2
RS
2984 if test "$want_tools" = "no" -a "$softmmu" = "no"; then
2985 pixman="none"
236f282c 2986 elif $pkg_config --atleast-version=0.21.8 pixman-1 > /dev/null 2>&1; then
e2134eb9
GH
2987 pixman="system"
2988 else
2989 pixman="internal"
2990 fi
2991fi
74880fe2
RS
2992if test "$pixman" = "none"; then
2993 if test "$want_tools" != "no" -o "$softmmu" != "no"; then
76ad07a4
PM
2994 error_exit "pixman disabled but system emulation or tools build" \
2995 "enabled. You can turn off pixman only if you also" \
2996 "disable all system emulation targets and the tools" \
2997 "build with '--disable-tools --disable-system'."
74880fe2
RS
2998 fi
2999 pixman_cflags=
3000 pixman_libs=
3001elif test "$pixman" = "system"; then
236f282c 3002 # pixman version has been checked above
ca871ec8
SW
3003 pixman_cflags=`$pkg_config --cflags pixman-1`
3004 pixman_libs=`$pkg_config --libs pixman-1`
e2134eb9
GH
3005else
3006 if test ! -d ${source_path}/pixman/pixman; then
236f282c 3007 error_exit "pixman >= 0.21.8 not present. Your options:" \
76ad07a4
PM
3008 " (1) Preferred: Install the pixman devel package (any recent" \
3009 " distro should have packages as Xorg needs pixman too)." \
3010 " (2) Fetch the pixman submodule, using:" \
3011 " git submodule update --init pixman"
e2134eb9 3012 fi
5ca9388a
GH
3013 mkdir -p pixman/pixman
3014 pixman_cflags="-I\$(SRC_PATH)/pixman/pixman -I\$(BUILD_DIR)/pixman/pixman"
3015 pixman_libs="-L\$(BUILD_DIR)/pixman/pixman/.libs -lpixman-1"
e2134eb9 3016fi
e2134eb9 3017
17bff52b
MK
3018##########################################
3019# libcap probe
3020
3021if test "$cap" != "no" ; then
3022 cat > $TMPC <<EOF
3023#include <stdio.h>
3024#include <sys/capability.h>
cc939743 3025int main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
17bff52b
MK
3026EOF
3027 if compile_prog "" "-lcap" ; then
3028 cap=yes
3029 else
3030 cap=no
3031 fi
3032fi
3033
414f0dab 3034##########################################
e5d355d1 3035# pthread probe
4b29ec41 3036PTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
3c529d93 3037
4dd75c70 3038pthread=no
e5d355d1 3039cat > $TMPC << EOF
3c529d93 3040#include <pthread.h>
7a42bbe4
SW
3041static void *f(void *p) { return NULL; }
3042int main(void) {
3043 pthread_t thread;
3044 pthread_create(&thread, 0, f, 0);
3045 return 0;
3046}
414f0dab 3047EOF
bd00d539
AF
3048if compile_prog "" "" ; then
3049 pthread=yes
3050else
3051 for pthread_lib in $PTHREADLIBS_LIST; do
3052 if compile_prog "" "$pthread_lib" ; then
3053 pthread=yes
e3c56761
PP
3054 found=no
3055 for lib_entry in $LIBS; do
3056 if test "$lib_entry" = "$pthread_lib"; then
3057 found=yes
3058 break
3059 fi
3060 done
3061 if test "$found" = "no"; then
3062 LIBS="$pthread_lib $LIBS"
3063 fi
bd00d539
AF
3064 break
3065 fi
3066 done
3067fi
414f0dab 3068
4617e593 3069if test "$mingw32" != yes -a "$pthread" = no; then
76ad07a4
PM
3070 error_exit "pthread check failed" \
3071 "Make sure to have the pthread libs and headers installed."
e5d355d1
AL
3072fi
3073
5c312079
DDAG
3074# check for pthread_setname_np
3075pthread_setname_np=no
3076cat > $TMPC << EOF
3077#include <pthread.h>
3078
3079static void *f(void *p) { return NULL; }
3080int main(void)
3081{
3082 pthread_t thread;
3083 pthread_create(&thread, 0, f, 0);
3084 pthread_setname_np(thread, "QEMU");
3085 return 0;
3086}
3087EOF
3088if compile_prog "" "$pthread_lib" ; then
3089 pthread_setname_np=yes
3090fi
3091
f27aaf4b
CB
3092##########################################
3093# rbd probe
3094if test "$rbd" != "no" ; then
3095 cat > $TMPC <<EOF
3096#include <stdio.h>
ad32e9c0 3097#include <rbd/librbd.h>
f27aaf4b 3098int main(void) {
ad32e9c0
JD
3099 rados_t cluster;
3100 rados_create(&cluster, NULL);
f27aaf4b
CB
3101 return 0;
3102}
3103EOF
ad32e9c0
JD
3104 rbd_libs="-lrbd -lrados"
3105 if compile_prog "" "$rbd_libs" ; then
3106 rbd=yes
f27aaf4b
CB
3107 else
3108 if test "$rbd" = "yes" ; then
21684af0 3109 feature_not_found "rados block device" "Install librbd/ceph devel"
f27aaf4b
CB
3110 fi
3111 rbd=no
3112 fi
f27aaf4b
CB
3113fi
3114
0a12ec87
RJ
3115##########################################
3116# libssh2 probe
4fc16838 3117min_libssh2_version=1.2.8
0a12ec87 3118if test "$libssh2" != "no" ; then
65d5d3f9 3119 if $pkg_config --atleast-version=$min_libssh2_version libssh2; then
0a12ec87
RJ
3120 libssh2_cflags=`$pkg_config libssh2 --cflags`
3121 libssh2_libs=`$pkg_config libssh2 --libs`
0a12ec87 3122 libssh2=yes
0a12ec87
RJ
3123 else
3124 if test "$libssh2" = "yes" ; then
4fc16838 3125 error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2"
0a12ec87
RJ
3126 fi
3127 libssh2=no
3128 fi
3129fi
3130
9a2d462e
RJ
3131##########################################
3132# libssh2_sftp_fsync probe
3133
3134if test "$libssh2" = "yes"; then
3135 cat > $TMPC <<EOF
3136#include <stdio.h>
3137#include <libssh2.h>
3138#include <libssh2_sftp.h>
3139int main(void) {
3140 LIBSSH2_SESSION *session;
3141 LIBSSH2_SFTP *sftp;
3142 LIBSSH2_SFTP_HANDLE *sftp_handle;
3143 session = libssh2_session_init ();
3144 sftp = libssh2_sftp_init (session);
3145 sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0);
3146 libssh2_sftp_fsync (sftp_handle);
3147 return 0;
3148}
3149EOF
3150 # libssh2_cflags/libssh2_libs defined in previous test.
3151 if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then
3152 QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS"
3153 fi
3154fi
3155
5c6c3a6c
CH
3156##########################################
3157# linux-aio probe
5c6c3a6c
CH
3158
3159if test "$linux_aio" != "no" ; then
3160 cat > $TMPC <<EOF
3161#include <libaio.h>
3162#include <sys/eventfd.h>
832ce9c2 3163#include <stddef.h>
5c6c3a6c
CH
3164int main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
3165EOF
3166 if compile_prog "" "-laio" ; then
3167 linux_aio=yes
5c6c3a6c
CH
3168 else
3169 if test "$linux_aio" = "yes" ; then
21684af0 3170 feature_not_found "linux AIO" "Install libaio devel"
5c6c3a6c 3171 fi
3cfcae3c 3172 linux_aio=no
5c6c3a6c
CH
3173 fi
3174fi
3175
3b8acc11
PB
3176##########################################
3177# TPM passthrough is only on x86 Linux
3178
3179if test "$targetos" = Linux && test "$cpu" = i386 -o "$cpu" = x86_64; then
3180 tpm_passthrough=$tpm
3181else
3182 tpm_passthrough=no
3183fi
3184
758e8e38
VJ
3185##########################################
3186# attr probe
3187
3188if test "$attr" != "no" ; then
3189 cat > $TMPC <<EOF
3190#include <stdio.h>
3191#include <sys/types.h>
f2338fb4
PB
3192#ifdef CONFIG_LIBATTR
3193#include <attr/xattr.h>
3194#else
4f26f2b6 3195#include <sys/xattr.h>
f2338fb4 3196#endif
758e8e38
VJ
3197int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
3198EOF
4f26f2b6
AK
3199 if compile_prog "" "" ; then
3200 attr=yes
3201 # Older distros have <attr/xattr.h>, and need -lattr:
f2338fb4 3202 elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
758e8e38
VJ
3203 attr=yes
3204 LIBS="-lattr $LIBS"
4f26f2b6 3205 libattr=yes
758e8e38
VJ
3206 else
3207 if test "$attr" = "yes" ; then
21684af0 3208 feature_not_found "ATTR" "Install libc6 or libattr devel"
758e8e38
VJ
3209 fi
3210 attr=no
3211 fi
3212fi
3213
bf9298b9
AL
3214##########################################
3215# iovec probe
3216cat > $TMPC <<EOF
db34f0b3 3217#include <sys/types.h>
bf9298b9 3218#include <sys/uio.h>
db34f0b3 3219#include <unistd.h>
f91f9bee 3220int main(void) { return sizeof(struct iovec); }
bf9298b9
AL
3221EOF
3222iovec=no
52166aa0 3223if compile_prog "" "" ; then
bf9298b9
AL
3224 iovec=yes
3225fi
3226
ceb42de8
AL
3227##########################################
3228# preadv probe
3229cat > $TMPC <<EOF
3230#include <sys/types.h>
3231#include <sys/uio.h>
3232#include <unistd.h>
c075a723 3233int main(void) { return preadv(0, 0, 0, 0); }
ceb42de8
AL
3234EOF
3235preadv=no
52166aa0 3236if compile_prog "" "" ; then
ceb42de8
AL
3237 preadv=yes
3238fi
3239
f652e6af
AJ
3240##########################################
3241# fdt probe
e169e1e1
PM
3242# fdt support is mandatory for at least some target architectures,
3243# so insist on it if we're building those system emulators.
3244fdt_required=no
3245for target in $target_list; do
3246 case $target in
6a49fa95 3247 aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu)
e169e1e1
PM
3248 fdt_required=yes
3249 ;;
3250 esac
3251done
3252
3253if test "$fdt_required" = "yes"; then
3254 if test "$fdt" = "no"; then
3255 error_exit "fdt disabled but some requested targets require it." \
3256 "You can turn off fdt only if you also disable all the system emulation" \
3257 "targets which need it (by specifying a cut down --target-list)."
3258 fi
3259 fdt=yes
3260fi
3261
2df87df7 3262if test "$fdt" != "no" ; then
b41af4ba 3263 fdt_libs="-lfdt"
96ce6545 3264 # explicitly check for libfdt_env.h as it is missing in some stable installs
31ce0adb 3265 # and test for required functions to make sure we are on a version >= 1.4.0
b41af4ba 3266 cat > $TMPC << EOF
31ce0adb 3267#include <libfdt.h>
96ce6545 3268#include <libfdt_env.h>
31ce0adb 3269int main(void) { fdt_get_property_by_offset(0, 0, 0); return 0; }
f652e6af 3270EOF
52166aa0 3271 if compile_prog "" "$fdt_libs" ; then
a540f158 3272 # system DTC is good - use it
f652e6af 3273 fdt=yes
a540f158
PC
3274 elif test -d ${source_path}/dtc/libfdt ; then
3275 # have submodule DTC - use it
3276 fdt=yes
3277 dtc_internal="yes"
3278 mkdir -p dtc
cab00a5a 3279 if [ "$pwd_is_source_path" != "y" ] ; then
a540f158
PC
3280 symlink "$source_path/dtc/Makefile" "dtc/Makefile"
3281 symlink "$source_path/dtc/scripts" "dtc/scripts"
2df87df7 3282 fi
a540f158
PC
3283 fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
3284 fdt_libs="-L\$(BUILD_DIR)/dtc/libfdt $fdt_libs"
3285 elif test "$fdt" = "yes" ; then
3286 # have neither and want - prompt for system/submodule install
31ce0adb 3287 error_exit "DTC (libfdt) version >= 1.4.0 not present. Your options:" \
3f281822 3288 " (1) Preferred: Install the DTC (libfdt) devel package" \
a540f158
PC
3289 " (2) Fetch the DTC submodule, using:" \
3290 " git submodule update --init dtc"
3291 else
3292 # don't have and don't want
de3a354a 3293 fdt_libs=
2df87df7 3294 fdt=no
f652e6af
AJ
3295 fi
3296fi
3297
a540f158
PC
3298libs_softmmu="$libs_softmmu $fdt_libs"
3299
20ff075b 3300##########################################
fb719563 3301# opengl probe (for sdl2, gtk, milkymist-tmu2)
b1546f32 3302
da076ffe 3303if test "$opengl" != "no" ; then
014cb152 3304 opengl_pkgs="epoxy libdrm gbm"
fb719563 3305 if $pkg_config $opengl_pkgs x11; then
f676c67e
JW
3306 opengl_cflags="$($pkg_config --cflags $opengl_pkgs) $x11_cflags"
3307 opengl_libs="$($pkg_config --libs $opengl_pkgs) $x11_libs"
da076ffe 3308 opengl=yes
925a0400
GH
3309 if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
3310 gtk_gl="yes"
3311 fi
20ff075b 3312 else
da076ffe 3313 if test "$opengl" = "yes" ; then
dcf30025 3314 feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
20ff075b 3315 fi
f676c67e 3316 opengl_cflags=""
da076ffe
GH
3317 opengl_libs=""
3318 opengl=no
20ff075b
MW
3319 fi
3320fi
3321
014cb152
GH
3322if test "$opengl" = "yes"; then
3323 cat > $TMPC << EOF
3324#include <epoxy/egl.h>
3325#ifndef EGL_MESA_image_dma_buf_export
3326# error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
3327#endif
3328int main(void) { return 0; }
3329EOF
3330 if compile_prog "" "" ; then
3331 opengl_dmabuf=yes
3332 fi
3333fi
c9a12e75
CN
3334
3335##########################################
3336# archipelago probe
3337if test "$archipelago" != "no" ; then
3338 cat > $TMPC <<EOF
3339#include <stdio.h>
3340#include <xseg/xseg.h>
3341#include <xseg/protocol.h>
3342int main(void) {
3343 xseg_initialize();
3344 return 0;
3345}
3346EOF
3347 archipelago_libs=-lxseg
3348 if compile_prog "" "$archipelago_libs"; then
3349 archipelago="yes"
3350 libs_tools="$archipelago_libs $libs_tools"
3351 libs_softmmu="$archipelago_libs $libs_softmmu"
6a460ed1
SH
3352
3353 echo "WARNING: Please check the licenses of QEMU and libxseg carefully."
3354 echo "GPLv3 versions of libxseg may not be compatible with QEMU's"
3355 echo "license and therefore prevent redistribution."
3356 echo
3357 echo "To disable Archipelago, use --disable-archipelago"
c9a12e75
CN
3358 else
3359 if test "$archipelago" = "yes" ; then
3360 feature_not_found "Archipelago backend support" "Install libxseg devel"
3361 fi
3362 archipelago="no"
3363 fi
3364fi
3365
3366
eb100396
BR
3367##########################################
3368# glusterfs probe
3369if test "$glusterfs" != "no" ; then
65d5d3f9 3370 if $pkg_config --atleast-version=3 glusterfs-api; then
e01bee08 3371 glusterfs="yes"
ca871ec8
SW
3372 glusterfs_cflags=`$pkg_config --cflags glusterfs-api`
3373 glusterfs_libs=`$pkg_config --libs glusterfs-api`
65d5d3f9 3374 if $pkg_config --atleast-version=5 glusterfs-api; then
0c14fb47
BR
3375 glusterfs_discard="yes"
3376 fi
7c815372
BR
3377 if $pkg_config --atleast-version=6 glusterfs-api; then
3378 glusterfs_zerofill="yes"
3379 fi
eb100396
BR
3380 else
3381 if test "$glusterfs" = "yes" ; then
8efc9363
HT
3382 feature_not_found "GlusterFS backend support" \
3383 "Install glusterfs-api devel >= 3"
eb100396 3384 fi
e01bee08 3385 glusterfs="no"
eb100396
BR
3386 fi
3387fi
3388
39386ac7 3389# Check for inotify functions when we are building linux-user
3b3f24ad
AJ
3390# emulator. This is done because older glibc versions don't
3391# have syscall stubs for these implemented. In that case we
3392# don't provide them even if kernel supports them.
3393#
3394inotify=no
67ba57f6 3395cat > $TMPC << EOF
3b3f24ad
AJ
3396#include <sys/inotify.h>
3397
3398int
3399main(void)
3400{
3401 /* try to start inotify */
8690e420 3402 return inotify_init();
3b3f24ad
AJ
3403}
3404EOF
52166aa0 3405if compile_prog "" "" ; then
67ba57f6 3406 inotify=yes
3b3f24ad
AJ
3407fi
3408
c05c7a73
RV
3409inotify1=no
3410cat > $TMPC << EOF
3411#include <sys/inotify.h>
3412
3413int
3414main(void)
3415{
3416 /* try to start inotify */
3417 return inotify_init1(0);
3418}
3419EOF
3420if compile_prog "" "" ; then
3421 inotify1=yes
3422fi
3423
ebc996f3
RV
3424# check if utimensat and futimens are supported
3425utimens=no
3426cat > $TMPC << EOF
3427#define _ATFILE_SOURCE
ebc996f3
RV
3428#include <stddef.h>
3429#include <fcntl.h>
3014ee00 3430#include <sys/stat.h>
ebc996f3
RV
3431
3432int main(void)
3433{
3434 utimensat(AT_FDCWD, "foo", NULL, 0);
3435 futimens(0, NULL);
3436 return 0;
3437}
3438EOF
52166aa0 3439if compile_prog "" "" ; then
ebc996f3
RV
3440 utimens=yes
3441fi
3442
099d6b0f
RV
3443# check if pipe2 is there
3444pipe2=no
3445cat > $TMPC << EOF
099d6b0f
RV
3446#include <unistd.h>
3447#include <fcntl.h>
3448
3449int main(void)
3450{
3451 int pipefd[2];
9bca8162 3452 return pipe2(pipefd, O_CLOEXEC);
099d6b0f
RV
3453}
3454EOF
52166aa0 3455if compile_prog "" "" ; then
099d6b0f
RV
3456 pipe2=yes
3457fi
3458
40ff6d7e
KW
3459# check if accept4 is there
3460accept4=no
3461cat > $TMPC << EOF
40ff6d7e
KW
3462#include <sys/socket.h>
3463#include <stddef.h>
3464
3465int main(void)
3466{
3467 accept4(0, NULL, NULL, SOCK_CLOEXEC);
3468 return 0;
3469}
3470EOF
3471if compile_prog "" "" ; then
3472 accept4=yes
3473fi
3474
3ce34dfb
VS
3475# check if tee/splice is there. vmsplice was added same time.
3476splice=no
3477cat > $TMPC << EOF
3ce34dfb
VS
3478#include <unistd.h>
3479#include <fcntl.h>
3480#include <limits.h>
3481
3482int main(void)
3483{
66ea0f22 3484 int len, fd = 0;
3ce34dfb
VS
3485 len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
3486 splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
3487 return 0;
3488}
3489EOF
52166aa0 3490if compile_prog "" "" ; then
3ce34dfb
VS
3491 splice=yes
3492fi
3493
a99d57bb
WG
3494##########################################
3495# libnuma probe
3496
3497if test "$numa" != "no" ; then
3498 cat > $TMPC << EOF
3499#include <numa.h>
3500int main(void) { return numa_available(); }
3501EOF
3502
3503 if compile_prog "" "-lnuma" ; then
3504 numa=yes
3505 libs_softmmu="-lnuma $libs_softmmu"
3506 else
3507 if test "$numa" = "yes" ; then
3508 feature_not_found "numa" "install numactl devel"
3509 fi
3510 numa=no
3511 fi
3512fi
3513
7b01cb97
AD
3514if test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
3515 echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
3516 exit 1
3517fi
3518
2847b469
FZ
3519##########################################
3520# tcmalloc probe
3521
3522if test "$tcmalloc" = "yes" ; then
3523 cat > $TMPC << EOF
3524#include <stdlib.h>
3525int main(void) { malloc(1); return 0; }
3526EOF
3527
3528 if compile_prog "" "-ltcmalloc" ; then
3529 LIBS="-ltcmalloc $LIBS"
3530 else
3531 feature_not_found "tcmalloc" "install gperftools devel"
3532 fi
3533fi
3534
7b01cb97
AD
3535##########################################
3536# jemalloc probe
3537
3538if test "$jemalloc" = "yes" ; then
3539 cat > $TMPC << EOF
3540#include <stdlib.h>
3541int main(void) { malloc(1); return 0; }
3542EOF
3543
3544 if compile_prog "" "-ljemalloc" ; then
3545 LIBS="-ljemalloc $LIBS"
3546 else
3547 feature_not_found "jemalloc" "install jemalloc devel"
3548 fi
3549fi
3550
dcc38d1c
MT
3551##########################################
3552# signalfd probe
3553signalfd="no"
3554cat > $TMPC << EOF
dcc38d1c
MT
3555#include <unistd.h>
3556#include <sys/syscall.h>
3557#include <signal.h>
3558int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
3559EOF
3560
3561if compile_prog "" "" ; then
3562 signalfd=yes
3563fi
3564
c2882b96
RV
3565# check if eventfd is supported
3566eventfd=no
3567cat > $TMPC << EOF
3568#include <sys/eventfd.h>
3569
3570int main(void)
3571{
55cc7f3e 3572 return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
c2882b96
RV
3573}
3574EOF
3575if compile_prog "" "" ; then
3576 eventfd=yes
3577fi
3578
751bcc39
MAL
3579# check if memfd is supported
3580memfd=no
3581cat > $TMPC << EOF
3582#include <sys/memfd.h>
3583
3584int main(void)
3585{
3586 return memfd_create("foo", MFD_ALLOW_SEALING);
3587}
3588EOF
3589if compile_prog "" "" ; then
3590 memfd=yes
3591fi
3592
3593
3594
d0927938
UH
3595# check for fallocate
3596fallocate=no
3597cat > $TMPC << EOF
3598#include <fcntl.h>
3599
3600int main(void)
3601{
3602 fallocate(0, 0, 0, 0);
3603 return 0;
3604}
3605EOF
8fb03151 3606if compile_prog "" "" ; then
d0927938
UH
3607 fallocate=yes
3608fi
3609
3d4fa43e
KK
3610# check for fallocate hole punching
3611fallocate_punch_hole=no
3612cat > $TMPC << EOF
3613#include <fcntl.h>
3614#include <linux/falloc.h>
3615
3616int main(void)
3617{
3618 fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
3619 return 0;
3620}
3621EOF
3622if compile_prog "" "" ; then
3623 fallocate_punch_hole=yes
3624fi
3625
b953f075
DL
3626# check that fallocate supports range zeroing inside the file
3627fallocate_zero_range=no
3628cat > $TMPC << EOF
3629#include <fcntl.h>
3630#include <linux/falloc.h>
3631
3632int main(void)
3633{
3634 fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
3635 return 0;
3636}
3637EOF
3638if compile_prog "" "" ; then
3639 fallocate_zero_range=yes
3640fi
3641
ed911435
KW
3642# check for posix_fallocate
3643posix_fallocate=no
3644cat > $TMPC << EOF
3645#include <fcntl.h>
3646
3647int main(void)
3648{
3649 posix_fallocate(0, 0, 0);
3650 return 0;
3651}
3652EOF
3653if compile_prog "" "" ; then
3654 posix_fallocate=yes
3655fi
3656
c727f47d
PM
3657# check for sync_file_range
3658sync_file_range=no
3659cat > $TMPC << EOF
3660#include <fcntl.h>
3661
3662int main(void)
3663{
3664 sync_file_range(0, 0, 0, 0);
3665 return 0;
3666}
3667EOF
8fb03151 3668if compile_prog "" "" ; then
c727f47d
PM
3669 sync_file_range=yes
3670fi
3671
dace20dc
PM
3672# check for linux/fiemap.h and FS_IOC_FIEMAP
3673fiemap=no
3674cat > $TMPC << EOF
3675#include <sys/ioctl.h>
3676#include <linux/fs.h>
3677#include <linux/fiemap.h>
3678
3679int main(void)
3680{
3681 ioctl(0, FS_IOC_FIEMAP, 0);
3682 return 0;
3683}
3684EOF
8fb03151 3685if compile_prog "" "" ; then
dace20dc
PM
3686 fiemap=yes
3687fi
3688
d0927938
UH
3689# check for dup3
3690dup3=no
3691cat > $TMPC << EOF
3692#include <unistd.h>
3693
3694int main(void)
3695{
3696 dup3(0, 0, 0);
3697 return 0;
3698}
3699EOF
78f5d726 3700if compile_prog "" "" ; then
d0927938
UH
3701 dup3=yes
3702fi
3703
4e0c6529
AB
3704# check for ppoll support
3705ppoll=no
3706cat > $TMPC << EOF
3707#include <poll.h>
3708
3709int main(void)
3710{
3711 struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
3712 ppoll(&pfd, 1, 0, 0);
3713 return 0;
3714}
3715EOF
3716if compile_prog "" "" ; then
3717 ppoll=yes
3718fi
3719
cd758dd0
AB
3720# check for prctl(PR_SET_TIMERSLACK , ... ) support
3721prctl_pr_set_timerslack=no
3722cat > $TMPC << EOF
3723#include <sys/prctl.h>
3724
3725int main(void)
3726{
3727 prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
3728 return 0;
3729}
3730EOF
3731if compile_prog "" "" ; then
3732 prctl_pr_set_timerslack=yes
3733fi
3734
3b6edd16
PM
3735# check for epoll support
3736epoll=no
3737cat > $TMPC << EOF
3738#include <sys/epoll.h>
3739
3740int main(void)
3741{
3742 epoll_create(0);
3743 return 0;
3744}
3745EOF
8fb03151 3746if compile_prog "" "" ; then
3b6edd16
PM
3747 epoll=yes
3748fi
3749
3750# epoll_create1 and epoll_pwait are later additions
3751# so we must check separately for their presence
3752epoll_create1=no
3753cat > $TMPC << EOF
3754#include <sys/epoll.h>
3755
3756int main(void)
3757{
19e83f6b
PM
3758 /* Note that we use epoll_create1 as a value, not as
3759 * a function being called. This is necessary so that on
3760 * old SPARC glibc versions where the function was present in
3761 * the library but not declared in the header file we will
3762 * fail the configure check. (Otherwise we will get a compiler
3763 * warning but not an error, and will proceed to fail the
3764 * qemu compile where we compile with -Werror.)
3765 */
c075a723 3766 return (int)(uintptr_t)&epoll_create1;
3b6edd16
PM
3767}
3768EOF
8fb03151 3769if compile_prog "" "" ; then
3b6edd16
PM
3770 epoll_create1=yes
3771fi
3772
3773epoll_pwait=no
3774cat > $TMPC << EOF
3775#include <sys/epoll.h>
3776
3777int main(void)
3778{
3779 epoll_pwait(0, 0, 0, 0, 0);
3780 return 0;
3781}
3782EOF
8fb03151 3783if compile_prog "" "" ; then
3b6edd16
PM
3784 epoll_pwait=yes
3785fi
3786
a8fd1aba
PM
3787# check for sendfile support
3788sendfile=no
3789cat > $TMPC << EOF
3790#include <sys/sendfile.h>
3791
3792int main(void)
3793{
3794 return sendfile(0, 0, 0, 0);
3795}
3796EOF
3797if compile_prog "" "" ; then
3798 sendfile=yes
3799fi
3800
51834341
RV
3801# check for timerfd support (glibc 2.8 and newer)
3802timerfd=no
3803cat > $TMPC << EOF
3804#include <sys/timerfd.h>
3805
3806int main(void)
3807{
3808 return(timerfd_create(CLOCK_REALTIME, 0));
3809}
3810EOF
3811if compile_prog "" "" ; then
3812 timerfd=yes
3813fi
3814
9af5c906
RV
3815# check for setns and unshare support
3816setns=no
3817cat > $TMPC << EOF
3818#include <sched.h>
3819
3820int main(void)
3821{
3822 int ret;
3823 ret = setns(0, 0);
3824 ret = unshare(0);
3825 return ret;
3826}
3827EOF
3828if compile_prog "" "" ; then
3829 setns=yes
3830fi
3831
cc8ae6de 3832# Check if tools are available to build documentation.
a25dba17 3833if test "$docs" != "no" ; then
01668d98 3834 if has makeinfo && has pod2man; then
a25dba17 3835 docs=yes
83a3ab8b 3836 else
a25dba17 3837 if test "$docs" = "yes" ; then
21684af0 3838 feature_not_found "docs" "Install texinfo and Perl/perl-podlators"
83a3ab8b 3839 fi
a25dba17 3840 docs=no
83a3ab8b 3841 fi
cc8ae6de
PB
3842fi
3843
f514f41c 3844# Search for bswap_32 function
6ae9a1f4
JQ
3845byteswap_h=no
3846cat > $TMPC << EOF
3847#include <byteswap.h>
3848int main(void) { return bswap_32(0); }
3849EOF
52166aa0 3850if compile_prog "" "" ; then
6ae9a1f4
JQ
3851 byteswap_h=yes
3852fi
3853
75f13596 3854# Search for bswap32 function
6ae9a1f4
JQ
3855bswap_h=no
3856cat > $TMPC << EOF
3857#include <sys/endian.h>
3858#include <sys/types.h>
3859#include <machine/bswap.h>
3860int main(void) { return bswap32(0); }
3861EOF
52166aa0 3862if compile_prog "" "" ; then
6ae9a1f4
JQ
3863 bswap_h=yes
3864fi
3865
c589b249 3866##########################################
e49ab19f 3867# Do we have libiscsi >= 1.9.0
c589b249 3868if test "$libiscsi" != "no" ; then
e49ab19f 3869 if $pkg_config --atleast-version=1.9.0 libiscsi; then
3c33ea96 3870 libiscsi="yes"
ca871ec8
SW
3871 libiscsi_cflags=$($pkg_config --cflags libiscsi)
3872 libiscsi_libs=$($pkg_config --libs libiscsi)
c589b249
RS
3873 else
3874 if test "$libiscsi" = "yes" ; then
e49ab19f 3875 feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
c589b249
RS
3876 fi
3877 libiscsi="no"
3878 fi
3879fi
3880
8bacde8d
NC
3881##########################################
3882# Do we need libm
3883cat > $TMPC << EOF
3884#include <math.h>
f80ea986 3885int main(int argc, char **argv) { return isnan(sin((double)argc)); }
8bacde8d
NC
3886EOF
3887if compile_prog "" "" ; then
3888 :
3889elif compile_prog "" "-lm" ; then
3890 LIBS="-lm $LIBS"
3891 libs_qga="-lm $libs_qga"
3892else
76ad07a4 3893 error_exit "libm check failed"
8bacde8d
NC
3894fi
3895
da93a1fd
AL
3896##########################################
3897# Do we need librt
8bacde8d
NC
3898# uClibc provides 2 versions of clock_gettime(), one with realtime
3899# support and one without. This means that the clock_gettime() don't
3900# need -lrt. We still need it for timer_create() so we check for this
3901# function in addition.
da93a1fd
AL
3902cat > $TMPC <<EOF
3903#include <signal.h>
3904#include <time.h>
8bacde8d
NC
3905int main(void) {
3906 timer_create(CLOCK_REALTIME, NULL, NULL);
3907 return clock_gettime(CLOCK_REALTIME, NULL);
3908}
da93a1fd
AL
3909EOF
3910
52166aa0 3911if compile_prog "" "" ; then
07ffa4bd 3912 :
8bacde8d 3913# we need pthread for static linking. use previous pthread test result
18e588b1
RL
3914elif compile_prog "" "$pthread_lib -lrt" ; then
3915 LIBS="$LIBS -lrt"
3916 libs_qga="$libs_qga -lrt"
da93a1fd
AL
3917fi
3918
31ff504d 3919if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
179cf400 3920 "$aix" != "yes" -a "$haiku" != "yes" ; then
6362a53f
JQ
3921 libs_softmmu="-lutil $libs_softmmu"
3922fi
3923
de5071c5 3924##########################################
cd4ec0b4
GH
3925# spice probe
3926if test "$spice" != "no" ; then
3927 cat > $TMPC << EOF
3928#include <spice.h>
3929int main(void) { spice_server_new(); return 0; }
3930EOF
710fc4f5
JD
3931 spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
3932 spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
65d5d3f9
SW
3933 if $pkg_config --atleast-version=0.12.0 spice-server && \
3934 $pkg_config --atleast-version=0.12.3 spice-protocol && \
cd4ec0b4
GH
3935 compile_prog "$spice_cflags" "$spice_libs" ; then
3936 spice="yes"
3937 libs_softmmu="$libs_softmmu $spice_libs"
3938 QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
2e0e3c39
AL
3939 spice_protocol_version=$($pkg_config --modversion spice-protocol)
3940 spice_server_version=$($pkg_config --modversion spice-server)
cd4ec0b4
GH
3941 else
3942 if test "$spice" = "yes" ; then
8efc9363
HT
3943 feature_not_found "spice" \
3944 "Install spice-server(>=0.12.0) and spice-protocol(>=0.12.3) devel"
cd4ec0b4
GH
3945 fi
3946 spice="no"
3947 fi
3948fi
3949
7b02f544 3950# check for smartcard support
afd347ab 3951smartcard_cflags=""
7b02f544
MAL
3952if test "$smartcard" != "no"; then
3953 if $pkg_config libcacard; then
3954 libcacard_cflags=$($pkg_config --cflags libcacard)
3955 libcacard_libs=$($pkg_config --libs libcacard)
3956 QEMU_CFLAGS="$QEMU_CFLAGS $libcacard_cflags"
3957 libs_softmmu="$libs_softmmu $libcacard_libs"
3958 smartcard="yes"
afd347ab 3959 else
7b02f544
MAL
3960 if test "$smartcard" = "yes"; then
3961 feature_not_found "smartcard" "Install libcacard devel"
111a38b0 3962 fi
7b02f544 3963 smartcard="no"
111a38b0
RR
3964 fi
3965fi
111a38b0 3966
2b2325ff
GH
3967# check for libusb
3968if test "$libusb" != "no" ; then
65d5d3f9 3969 if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
2b2325ff 3970 libusb="yes"
ca871ec8
SW
3971 libusb_cflags=$($pkg_config --cflags libusb-1.0)
3972 libusb_libs=$($pkg_config --libs libusb-1.0)
2b2325ff
GH
3973 QEMU_CFLAGS="$QEMU_CFLAGS $libusb_cflags"
3974 libs_softmmu="$libs_softmmu $libusb_libs"
3975 else
3976 if test "$libusb" = "yes"; then
8efc9363 3977 feature_not_found "libusb" "Install libusb devel >= 1.0.13"
2b2325ff
GH
3978 fi
3979 libusb="no"
3980 fi
3981fi
3982
69354a83
HG
3983# check for usbredirparser for usb network redirection support
3984if test "$usb_redir" != "no" ; then
65d5d3f9 3985 if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
69354a83 3986 usb_redir="yes"
ca871ec8
SW
3987 usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
3988 usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
69354a83 3989 QEMU_CFLAGS="$QEMU_CFLAGS $usb_redir_cflags"
56ab2ad1 3990 libs_softmmu="$libs_softmmu $usb_redir_libs"
69354a83
HG
3991 else
3992 if test "$usb_redir" = "yes"; then
21684af0 3993 feature_not_found "usb-redir" "Install usbredir devel"
69354a83
HG
3994 fi
3995 usb_redir="no"
3996 fi
3997fi
3998
d9840e25
TS
3999##########################################
4000# check if we have VSS SDK headers for win
4001
4002if test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$vss_win32_sdk" != "no" ; then
4003 case "$vss_win32_sdk" in
4004 "") vss_win32_include="-I$source_path" ;;
4005 *\ *) # The SDK is installed in "Program Files" by default, but we cannot
4006 # handle path with spaces. So we symlink the headers into ".sdk/vss".
4007 vss_win32_include="-I$source_path/.sdk/vss"
4008 symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
4009 ;;
4010 *) vss_win32_include="-I$vss_win32_sdk"
4011 esac
4012 cat > $TMPC << EOF
4013#define __MIDL_user_allocate_free_DEFINED__
4014#include <inc/win2003/vss.h>
4015int main(void) { return VSS_CTX_BACKUP; }
4016EOF
4017 if compile_prog "$vss_win32_include" "" ; then
4018 guest_agent_with_vss="yes"
4019 QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
4020 libs_qga="-lole32 -loleaut32 -lshlwapi -luuid -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
f33ca81f 4021 qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
d9840e25
TS
4022 else
4023 if test "$vss_win32_sdk" != "" ; then
4024 echo "ERROR: Please download and install Microsoft VSS SDK:"
4025 echo "ERROR: http://www.microsoft.com/en-us/download/details.aspx?id=23490"
4026 echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
4027 echo "ERROR: scripts/extract-vsssdk-headers setup.exe"
4028 echo "ERROR: The headers are extracted in the directory \`inc'."
4029 feature_not_found "VSS support"
4030 fi
4031 guest_agent_with_vss="no"
4032 fi
4033fi
4034
4035##########################################
4036# lookup Windows platform SDK (if not specified)
4037# The SDK is needed only to build .tlb (type library) file of guest agent
4038# VSS provider from the source. It is usually unnecessary because the
4039# pre-compiled .tlb file is included.
4040
4041if test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$guest_agent_with_vss" = "yes" ; then
4042 if test -z "$win_sdk"; then
4043 programfiles="$PROGRAMFILES"
4044 test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
4045 if test -n "$programfiles"; then
4046 win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
4047 else
4048 feature_not_found "Windows SDK"
4049 fi
4050 elif test "$win_sdk" = "no"; then
4051 win_sdk=""
4052 fi
4053fi
4054
50cbebb9
MR
4055##########################################
4056# check if mingw environment provides a recent ntddscsi.h
4057if test "$mingw32" = "yes" -a "$guest_agent" != "no"; then
4058 cat > $TMPC << EOF
4059#include <windows.h>
4060#include <ntddscsi.h>
4061int main(void) {
4062#if !defined(IOCTL_SCSI_GET_ADDRESS)
4063#error Missing required ioctl definitions
4064#endif
4065 SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
4066 return addr.Lun;
4067}
4068EOF
4069 if compile_prog "" "" ; then
4070 guest_agent_ntddscsi=yes
c54e1eb4 4071 libs_qga="-lsetupapi $libs_qga"
50cbebb9
MR
4072 fi
4073fi
4074
9d9e1521
GH
4075##########################################
4076# virgl renderer probe
4077
4078if test "$virglrenderer" != "no" ; then
4079 cat > $TMPC << EOF
4080#include <virglrenderer.h>
4081int main(void) { virgl_renderer_poll(); return 0; }
4082EOF
4083 virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
4084 virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
4085 if $pkg_config virglrenderer >/dev/null 2>&1 && \
4086 compile_prog "$virgl_cflags" "$virgl_libs" ; then
4087 virglrenderer="yes"
4088 else
4089 if test "$virglrenderer" = "yes" ; then
4090 feature_not_found "virglrenderer"
4091 fi
4092 virglrenderer="no"
4093 fi
4094fi
4095
5f6b9e8f
BS
4096##########################################
4097# check if we have fdatasync
4098
4099fdatasync=no
4100cat > $TMPC << EOF
4101#include <unistd.h>
d1722a27
AR
4102int main(void) {
4103#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
4104return fdatasync(0);
4105#else
e172fe11 4106#error Not supported
d1722a27
AR
4107#endif
4108}
5f6b9e8f
BS
4109EOF
4110if compile_prog "" "" ; then
4111 fdatasync=yes
4112fi
4113
e78815a5
AF
4114##########################################
4115# check if we have madvise
4116
4117madvise=no
4118cat > $TMPC << EOF
4119#include <sys/types.h>
4120#include <sys/mman.h>
832ce9c2 4121#include <stddef.h>
e78815a5
AF
4122int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
4123EOF
4124if compile_prog "" "" ; then
4125 madvise=yes
4126fi
4127
4128##########################################
4129# check if we have posix_madvise
4130
4131posix_madvise=no
4132cat > $TMPC << EOF
4133#include <sys/mman.h>
832ce9c2 4134#include <stddef.h>
e78815a5
AF
4135int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
4136EOF
4137if compile_prog "" "" ; then
4138 posix_madvise=yes
4139fi
4140
1e9737da
RH
4141##########################################
4142# check if we have usable SIGEV_THREAD_ID
4143
4144sigev_thread_id=no
4145cat > $TMPC << EOF
4146#include <signal.h>
4147int main(void) {
4148 struct sigevent ev;
4149 ev.sigev_notify = SIGEV_THREAD_ID;
4150 ev._sigev_un._tid = 0;
4151 asm volatile("" : : "g"(&ev));
4152 return 0;
4153}
4154EOF
4155if compile_prog "" "" ; then
4156 sigev_thread_id=yes
4157fi
4158
94a420b1
SH
4159##########################################
4160# check if trace backend exists
4161
5b808275 4162$python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends > /dev/null 2> /dev/null
94a420b1 4163if test "$?" -ne 0 ; then
5b808275
LV
4164 error_exit "invalid trace backends" \
4165 "Please choose supported trace backends."
94a420b1
SH
4166fi
4167
7e24e92a
SH
4168##########################################
4169# For 'ust' backend, test if ust headers are present
5b808275 4170if have_backend "ust"; then
7e24e92a 4171 cat > $TMPC << EOF
bf15f63c 4172#include <lttng/tracepoint.h>
7e24e92a
SH
4173int main(void) { return 0; }
4174EOF
4175 if compile_prog "" "" ; then
bf15f63c
MG
4176 if $pkg_config lttng-ust --exists; then
4177 lttng_ust_libs=`$pkg_config --libs lttng-ust`
4178 else
4179 lttng_ust_libs="-llttng-ust"
4180 fi
4181 if $pkg_config liburcu-bp --exists; then
4182 urcu_bp_libs=`$pkg_config --libs liburcu-bp`
4183 else
4184 urcu_bp_libs="-lurcu-bp"
4185 fi
4186
4187 LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
4188 libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
7e24e92a 4189 else
bf15f63c 4190 error_exit "Trace backend 'ust' missing lttng-ust header files"
7e24e92a
SH
4191 fi
4192fi
b3d08c02
DB
4193
4194##########################################
4195# For 'dtrace' backend, test if 'dtrace' command is present
5b808275 4196if have_backend "dtrace"; then
b3d08c02 4197 if ! has 'dtrace' ; then
76ad07a4 4198 error_exit "dtrace command is not found in PATH $PATH"
b3d08c02 4199 fi
c276b17d
DB
4200 trace_backend_stap="no"
4201 if has 'stap' ; then
4202 trace_backend_stap="yes"
4203 fi
b3d08c02
DB
4204fi
4205
023367e6 4206##########################################
519175a2 4207# check and set a backend for coroutine
d0e2fce5 4208
7c2acc70
PM
4209# We prefer ucontext, but it's not always possible. The fallback
4210# is sigcontext. gthread is not selectable except explicitly, because
4211# it is not functional enough to run QEMU proper. (It is occasionally
4212# useful for debugging purposes.) On Windows the only valid backend
4213# is the Windows-specific one.
4214
4215ucontext_works=no
4216if test "$darwin" != "yes"; then
4217 cat > $TMPC << EOF
d0e2fce5 4218#include <ucontext.h>
cdf84806
PM
4219#ifdef __stub_makecontext
4220#error Ignoring glibc stub makecontext which will always fail
4221#endif
75cafad7 4222int main(void) { makecontext(0, 0, 0); return 0; }
d0e2fce5 4223EOF
7c2acc70
PM
4224 if compile_prog "" "" ; then
4225 ucontext_works=yes
4226 fi
4227fi
4228
4229if test "$coroutine" = ""; then
4230 if test "$mingw32" = "yes"; then
4231 coroutine=win32
4232 elif test "$ucontext_works" = "yes"; then
4233 coroutine=ucontext
4234 else
4235 coroutine=sigaltstack
d0e2fce5 4236 fi
519175a2 4237else
7c2acc70
PM
4238 case $coroutine in
4239 windows)
4240 if test "$mingw32" != "yes"; then
4241 error_exit "'windows' coroutine backend only valid for Windows"
4242 fi
4243 # Unfortunately the user visible backend name doesn't match the
4244 # coroutine-*.c filename for this case, so we have to adjust it here.
4245 coroutine=win32
4246 ;;
4247 ucontext)
4248 if test "$ucontext_works" != "yes"; then
4249 feature_not_found "ucontext"
4250 fi
4251 ;;
4252 gthread|sigaltstack)
4253 if test "$mingw32" = "yes"; then
4254 error_exit "only the 'windows' coroutine backend is valid for Windows"
4255 fi
4256 ;;
4257 *)
4258 error_exit "unknown coroutine backend $coroutine"
4259 ;;
4260 esac
d0e2fce5
AK
4261fi
4262
70c60c08
SH
4263if test "$coroutine_pool" = ""; then
4264 if test "$coroutine" = "gthread"; then
4265 coroutine_pool=no
4266 else
4267 coroutine_pool=yes
4268 fi
4269fi
4270if test "$coroutine" = "gthread" -a "$coroutine_pool" = "yes"; then
4271 error_exit "'gthread' coroutine backend does not support pool (use --disable-coroutine-pool)"
4272fi
4273
d2042378
AK
4274##########################################
4275# check if we have open_by_handle_at
4276
4e1797f9 4277open_by_handle_at=no
d2042378
AK
4278cat > $TMPC << EOF
4279#include <fcntl.h>
acc55ba8
SW
4280#if !defined(AT_EMPTY_PATH)
4281# error missing definition
4282#else
75cafad7 4283int main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
acc55ba8 4284#endif
d2042378
AK
4285EOF
4286if compile_prog "" "" ; then
4287 open_by_handle_at=yes
4288fi
4289
e06a765e
HPB
4290########################################
4291# check if we have linux/magic.h
4292
4293linux_magic_h=no
4294cat > $TMPC << EOF
4295#include <linux/magic.h>
4296int main(void) {
75cafad7 4297 return 0;
e06a765e
HPB
4298}
4299EOF
4300if compile_prog "" "" ; then
4301 linux_magic_h=yes
4302fi
4303
06d71fa1 4304########################################
c95e3080
KW
4305# check whether we can disable warning option with a pragma (this is needed
4306# to silence warnings in the headers of some versions of external libraries).
4307# This test has to be compiled with -Werror as otherwise an unknown pragma is
4308# only a warning.
4309#
4310# If we can't selectively disable warning in the code, disable -Werror so that
4311# the build doesn't fail anyway.
4312
06d71fa1
PM
4313pragma_disable_unused_but_set=no
4314cat > $TMPC << EOF
e6f53fd5 4315#pragma GCC diagnostic push
06d71fa1 4316#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
c95e3080 4317#pragma GCC diagnostic ignored "-Wstrict-prototypes"
e6f53fd5 4318#pragma GCC diagnostic pop
c95e3080 4319
06d71fa1
PM
4320int main(void) {
4321 return 0;
4322}
4323EOF
4324if compile_prog "-Werror" "" ; then
cc6e3ca9 4325 pragma_diagnostic_available=yes
c95e3080
KW
4326else
4327 werror=no
06d71fa1
PM
4328fi
4329
3f4349dc 4330########################################
541be927 4331# check if we have valgrind/valgrind.h
3f4349dc
KW
4332
4333valgrind_h=no
4334cat > $TMPC << EOF
4335#include <valgrind/valgrind.h>
3f4349dc 4336int main(void) {
3f4349dc
KW
4337 return 0;
4338}
4339EOF
4340if compile_prog "" "" ; then
4341 valgrind_h=yes
4342fi
4343
8ab1bf12
LC
4344########################################
4345# check if environ is declared
4346
4347has_environ=no
4348cat > $TMPC << EOF
4349#include <unistd.h>
4350int main(void) {
c075a723 4351 environ = 0;
8ab1bf12
LC
4352 return 0;
4353}
4354EOF
4355if compile_prog "" "" ; then
4356 has_environ=yes
4357fi
4358
76a347e1
RH
4359########################################
4360# check if cpuid.h is usable.
4361
4362cpuid_h=no
4363cat > $TMPC << EOF
4364#include <cpuid.h>
4365int main(void) {
774d566c
PM
4366 unsigned a, b, c, d;
4367 int max = __get_cpuid_max(0, 0);
4368
4369 if (max >= 1) {
4370 __cpuid(1, a, b, c, d);
4371 }
4372
4373 if (max >= 7) {
4374 __cpuid_count(7, 0, a, b, c, d);
4375 }
4376
4377 return 0;
76a347e1
RH
4378}
4379EOF
4380if compile_prog "" "" ; then
4381 cpuid_h=yes
4382fi
4383
f540166b
RH
4384########################################
4385# check if __[u]int128_t is usable.
4386
4387int128=no
4388cat > $TMPC << EOF
a00f66ab
SW
4389#if defined(__clang_major__) && defined(__clang_minor__)
4390# if ((__clang_major__ < 3) || (__clang_major__ == 3) && (__clang_minor__ < 2))
4391# error __int128_t does not work in CLANG before 3.2
4392# endif
4393#endif
f540166b
RH
4394__int128_t a;
4395__uint128_t b;
4396int main (void) {
4397 a = a + b;
4398 b = a * b;
464e3671 4399 a = a * a;
f540166b
RH
4400 return 0;
4401}
4402EOF
4403if compile_prog "" "" ; then
4404 int128=yes
4405fi
76a347e1 4406
1e6e9aca
RH
4407########################################
4408# check if getauxval is available.
4409
4410getauxval=no
4411cat > $TMPC << EOF
4412#include <sys/auxv.h>
4413int main(void) {
4414 return getauxval(AT_HWCAP) == 0;
4415}
4416EOF
4417if compile_prog "" "" ; then
4418 getauxval=yes
4419fi
4420
fd0e6053
JS
4421########################################
4422# check if ccache is interfering with
4423# semantic analysis of macros
4424
5e4dfd3d 4425unset CCACHE_CPP2
fd0e6053
JS
4426ccache_cpp2=no
4427cat > $TMPC << EOF
4428static const int Z = 1;
4429#define fn() ({ Z; })
4430#define TAUT(X) ((X) == Z)
4431#define PAREN(X, Y) (X == Y)
4432#define ID(X) (X)
4433int main(int argc, char *argv[])
4434{
4435 int x = 0, y = 0;
4436 x = ID(x);
4437 x = fn();
4438 fn();
4439 if (PAREN(x, y)) return 0;
4440 if (TAUT(Z)) return 0;
4441 return 0;
4442}
4443EOF
4444
4445if ! compile_object "-Werror"; then
4446 ccache_cpp2=yes
4447fi
4448
b553a042
JS
4449#################################################
4450# clang does not support glibc + FORTIFY_SOURCE.
4451
4452if test "$fortify_source" != "no"; then
4453 if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
4454 fortify_source="no";
cfcc7c14
JS
4455 elif test -n "$cxx" &&
4456 echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
b553a042
JS
4457 fortify_source="no";
4458 else
4459 fortify_source="yes"
4460 fi
4461fi
4462
7e24e92a 4463##########################################
e86ecd4b
JQ
4464# End of CC checks
4465# After here, no more $cc or $ld runs
4466
1d728c39
BS
4467if test "$gcov" = "yes" ; then
4468 CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
4469 LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
b553a042 4470elif test "$fortify_source" = "yes" ; then
e600cdf3 4471 CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
ce278618
PM
4472elif test "$debug" = "no"; then
4473 CFLAGS="-O2 $CFLAGS"
e86ecd4b 4474fi
a316e378 4475
6542aa9c
PL
4476##########################################
4477# Do we have libnfs
4478if test "$libnfs" != "no" ; then
b7d769c9 4479 if $pkg_config --atleast-version=1.9.3 libnfs; then
6542aa9c
PL
4480 libnfs="yes"
4481 libnfs_libs=$($pkg_config --libs libnfs)
4482 LIBS="$LIBS $libnfs_libs"
4483 else
4484 if test "$libnfs" = "yes" ; then
8efc9363 4485 feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
6542aa9c
PL
4486 fi
4487 libnfs="no"
4488 fi
4489fi
1d728c39 4490
20ff6c80
AL
4491# Disable zero malloc errors for official releases unless explicitly told to
4492# enable/disable
4493if test -z "$zero_malloc" ; then
4494 if test "$z_version" = "50" ; then
4495 zero_malloc="no"
4496 else
4497 zero_malloc="yes"
4498 fi
4499fi
4500
6ca026cb
PM
4501# Now we've finished running tests it's OK to add -Werror to the compiler flags
4502if test "$werror" = "yes"; then
4503 QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
4504fi
4505
e86ecd4b
JQ
4506if test "$solaris" = "no" ; then
4507 if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
1156c669 4508 LDFLAGS="-Wl,--warn-common $LDFLAGS"
e86ecd4b
JQ
4509 fi
4510fi
4511
94dd53c5
GH
4512# test if pod2man has --utf8 option
4513if pod2man --help | grep -q utf8; then
4514 POD2MAN="pod2man --utf8"
4515else
4516 POD2MAN="pod2man"
4517fi
4518
952afb71
BS
4519# Use ASLR, no-SEH and DEP if available
4520if test "$mingw32" = "yes" ; then
4521 for flag in --dynamicbase --no-seh --nxcompat; do
4522 if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
4523 LDFLAGS="-Wl,$flag $LDFLAGS"
4524 fi
4525 done
4526fi
4527
10ea68b3 4528qemu_confdir=$sysconfdir$confsuffix
e26110cf 4529qemu_moddir=$libdir$confsuffix
528ae5b8 4530qemu_datadir=$datadir$confsuffix
834574ea 4531qemu_localedir="$datadir/locale"
e7b45cc4 4532
4b1c11fd
DB
4533tools=""
4534if test "$want_tools" = "yes" ; then
ca35f780 4535 tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
4b1c11fd
DB
4536 if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
4537 tools="qemu-nbd\$(EXESUF) $tools"
a75eb03b 4538 tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools"
4b1c11fd
DB
4539 fi
4540fi
4541if test "$softmmu" = yes ; then
983eef5a 4542 if test "$virtfs" != no ; then
aabfd88d
AF
4543 if test "$cap" = yes && test "$linux" = yes && test "$attr" = yes ; then
4544 virtfs=yes
4545 tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
4546 else
4547 if test "$virtfs" = yes; then
76ad07a4 4548 error_exit "VirtFS is supported only on Linux and requires libcap-devel and libattr-devel"
983eef5a 4549 fi
17500370 4550 virtfs=no
aabfd88d 4551 fi
17bff52b 4552 fi
e8ef31a3 4553fi
9d6bc27b
MR
4554
4555# Probe for guest agent support/options
4556
e8ef31a3 4557if [ "$guest_agent" != "no" ]; then
b39297ae 4558 if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
fafcaf1d 4559 tools="qemu-ga $tools"
e8ef31a3
MT
4560 guest_agent=yes
4561 elif [ "$guest_agent" != yes ]; then
4562 guest_agent=no
4563 else
4564 error_exit "Guest agent is not supported on this platform"
ca35f780 4565 fi
00c705fb 4566fi
ca35f780 4567
9d6bc27b
MR
4568# Guest agent Window MSI package
4569
4570if test "$guest_agent" != yes; then
4571 if test "$guest_agent_msi" = yes; then
4572 error_exit "MSI guest agent package requires guest agent enabled"
4573 fi
4574 guest_agent_msi=no
4575elif test "$mingw32" != "yes"; then
4576 if test "$guest_agent_msi" = "yes"; then
4577 error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
4578 fi
4579 guest_agent_msi=no
4580elif ! has wixl; then
4581 if test "$guest_agent_msi" = "yes"; then
4582 error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
4583 fi
4584 guest_agent_msi=no
1a34904e
MR
4585else
4586 # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
4587 # disabled explicitly
4588 if test "$guest_agent_msi" != "no"; then
4589 guest_agent_msi=yes
4590 fi
9d6bc27b
MR
4591fi
4592
1a34904e 4593if test "$guest_agent_msi" = "yes"; then
9d6bc27b
MR
4594 if test "$guest_agent_with_vss" = "yes"; then
4595 QEMU_GA_MSI_WITH_VSS="-D InstallVss"
4596 fi
4597
4598 if test "$QEMU_GA_MANUFACTURER" = ""; then
4599 QEMU_GA_MANUFACTURER=QEMU
4600 fi
4601
4602 if test "$QEMU_GA_DISTRO" = ""; then
4603 QEMU_GA_DISTRO=Linux
4604 fi
4605
4606 if test "$QEMU_GA_VERSION" = ""; then
4607 QEMU_GA_VERSION=`cat $source_path/VERSION`
4608 fi
4609
4610 QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=`$pkg_config --variable=prefix glib-2.0`/bin"
4611
4612 case "$cpu" in
4613 x86_64)
4614 QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
4615 ;;
4616 i386)
4617 QEMU_GA_MSI_ARCH="-D Arch=32"
4618 ;;
4619 *)
4620 error_exit "CPU $cpu not supported for building installation package"
4621 ;;
4622 esac
4623fi
4624
ca35f780
PB
4625# Mac OS X ships with a broken assembler
4626roms=
4627if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
4628 "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
4629 "$softmmu" = yes ; then
4630 roms="optionrom"
4631fi
d0384d1d 4632if test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
39ac8455
DG
4633 roms="$roms spapr-rtas"
4634fi
ca35f780 4635
9933c305
CB
4636if test "$cpu" = "s390x" ; then
4637 roms="$roms s390-ccw"
4638fi
4639
964c6fa1
RH
4640# Probe for the need for relocating the user-only binary.
4641if test "$pie" = "no" ; then
4642 textseg_addr=
4643 case "$cpu" in
479eb121
RH
4644 arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
4645 # ??? Rationale for choosing this address
964c6fa1
RH
4646 textseg_addr=0x60000000
4647 ;;
4648 mips)
479eb121
RH
4649 # A 256M aligned address, high in the address space, with enough
4650 # room for the code_gen_buffer above it before the stack.
4651 textseg_addr=0x60000000
964c6fa1
RH
4652 ;;
4653 esac
4654 if [ -n "$textseg_addr" ]; then
4655 cat > $TMPC <<EOF
4656 int main(void) { return 0; }
4657EOF
4658 textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
4659 if ! compile_prog "" "$textseg_ldflags"; then
4660 # In case ld does not support -Ttext-segment, edit the default linker
4661 # script via sed to set the .text start addr. This is needed on FreeBSD
4662 # at least.
4663 $ld --verbose | sed \
4664 -e '1,/==================================================/d' \
4665 -e '/==================================================/,$d' \
4666 -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
4667 -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
4668 textseg_ldflags="-Wl,-T../config-host.ld"
4669 fi
4670 fi
4671fi
4672
50e12060
JK
4673# prepend pixman and ftd flags after all config tests are done
4674QEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"
4675libs_softmmu="$pixman_libs $libs_softmmu"
5ca9388a 4676
43ce4dfe 4677echo "Install prefix $prefix"
c00b2808 4678echo "BIOS directory `eval echo $qemu_datadir`"
f2b9e1e3 4679echo "binary directory `eval echo $bindir`"
3aa5d2be 4680echo "library directory `eval echo $libdir`"
e26110cf 4681echo "module directory `eval echo $qemu_moddir`"
8bf188aa 4682echo "libexec directory `eval echo $libexecdir`"
0f94d6da 4683echo "include directory `eval echo $includedir`"
1c0fd160 4684echo "config directory `eval echo $sysconfdir`"
11d9f695 4685if test "$mingw32" = "no" ; then
5a699bbb 4686echo "local state directory `eval echo $local_statedir`"
f2b9e1e3 4687echo "Manual directory `eval echo $mandir`"
43ce4dfe 4688echo "ELF interp prefix $interp_prefix"
5a699bbb
LE
4689else
4690echo "local state directory queried at runtime"
d9840e25 4691echo "Windows SDK $win_sdk"
11d9f695 4692fi
5a67135a 4693echo "Source path $source_path"
43ce4dfe 4694echo "C compiler $cc"
83469015 4695echo "Host C compiler $host_cc"
83f73fce 4696echo "C++ compiler $cxx"
3c4a4d0d 4697echo "Objective-C compiler $objcc"
45d285ab 4698echo "ARFLAGS $ARFLAGS"
0c439cbf 4699echo "CFLAGS $CFLAGS"
a558ee17 4700echo "QEMU_CFLAGS $QEMU_CFLAGS"
0c439cbf 4701echo "LDFLAGS $LDFLAGS"
43ce4dfe 4702echo "make $make"
6a882643 4703echo "install $install"
c886edfb 4704echo "python $python"
e2d8830e
BS
4705if test "$slirp" = "yes" ; then
4706 echo "smbd $smbd"
4707fi
17969268 4708echo "module support $modules"
43ce4dfe 4709echo "host CPU $cpu"
de83cd02 4710echo "host big endian $bigendian"
97a847bc 4711echo "target list $target_list"
ade25b0d 4712echo "tcg debug enabled $debug_tcg"
43ce4dfe 4713echo "gprof enabled $gprof"
03b4fe7d 4714echo "sparse enabled $sparse"
1625af87 4715echo "strip binaries $strip_opt"
05c2a3e7 4716echo "profiler $profiler"
43ce4dfe 4717echo "static build $static"
5b0753e0
FB
4718if test "$darwin" = "yes" ; then
4719 echo "Cocoa support $cocoa"
4720fi
e2134eb9 4721echo "pixman $pixman"
97a847bc 4722echo "SDL support $sdl"
a4ccabcf 4723echo "GTK support $gtk"
925a0400 4724echo "GTK GL support $gtk_gl"
ddbb0d09
DB
4725echo "GNUTLS support $gnutls"
4726echo "GNUTLS hash $gnutls_hash"
b917da4c 4727echo "GNUTLS rnd $gnutls_rnd"
91bfcdb0 4728echo "libgcrypt $gcrypt"
18f49881
PM
4729if test "$nettle" = "yes"; then
4730 echo "nettle $nettle ($nettle_version)"
4731else
4732 echo "nettle $nettle"
4733fi
9a2fd434 4734echo "libtasn1 $tasn1"
bbbf9bfb 4735echo "VTE support $vte"
4d3b6f6e 4736echo "curses support $curses"
9d9e1521 4737echo "virgl support $virglrenderer"
769ce76d 4738echo "curl support $curl"
67b915a5 4739echo "mingw32 support $mingw32"
0c58ac1c 4740echo "Audio drivers $audio_drv_list"
b64ec4e4
FZ
4741echo "Block whitelist (rw) $block_drv_rw_whitelist"
4742echo "Block whitelist (ro) $block_drv_ro_whitelist"
983eef5a 4743echo "VirtFS support $virtfs"
821601ea
JS
4744echo "VNC support $vnc"
4745if test "$vnc" = "yes" ; then
821601ea
JS
4746 echo "VNC SASL support $vnc_sasl"
4747 echo "VNC JPEG support $vnc_jpeg"
4748 echo "VNC PNG support $vnc_png"
821601ea 4749fi
3142255c
BS
4750if test -n "$sparc_cpu"; then
4751 echo "Target Sparc Arch $sparc_cpu"
4752fi
e37630ca 4753echo "xen support $xen"
3996e85c
PD
4754if test "$xen" = "yes" ; then
4755 echo "xen ctrl version $xen_ctrl_version"
64a7ad6f 4756 echo "pv dom build $xen_pv_domain_build"
3996e85c 4757fi
2e4d9fb1 4758echo "brlapi support $brlapi"
a20a6f46 4759echo "bluez support $bluez"
a25dba17 4760echo "Documentation $docs"
40d6444e 4761echo "PIE $pie"
8a16d273 4762echo "vde support $vde"
58952137 4763echo "netmap support $netmap"
5c6c3a6c 4764echo "Linux AIO support $linux_aio"
758e8e38 4765echo "ATTR/XATTR support $attr"
77755340 4766echo "Install blobs $blobs"
b31a0277 4767echo "KVM support $kvm"
2da776db 4768echo "RDMA support $rdma"
9195b2c2 4769echo "TCG interpreter $tcg_interpreter"
f652e6af 4770echo "fdt support $fdt"
ceb42de8 4771echo "preadv support $preadv"
5f6b9e8f 4772echo "fdatasync $fdatasync"
e78815a5
AF
4773echo "madvise $madvise"
4774echo "posix_madvise $posix_madvise"
1e9737da 4775echo "sigev_thread_id $sigev_thread_id"
ee682d27 4776echo "uuid support $uuid"
47e98658 4777echo "libcap-ng support $cap_ng"
d5970055 4778echo "vhost-net support $vhost_net"
5e9be92d 4779echo "vhost-scsi support $vhost_scsi"
5b808275 4780echo "Trace backends $trace_backends"
713572a7 4781if have_backend "simple"; then
9410b56c 4782echo "Trace output file $trace_file-<pid>"
e00e36fb 4783fi
c9dd4074 4784if test "$spice" = "yes"; then
2e0e3c39 4785echo "spice support $spice ($spice_protocol_version/$spice_server_version)"
c9dd4074
SW
4786else
4787echo "spice support $spice"
4788fi
f27aaf4b 4789echo "rbd support $rbd"
dce512de 4790echo "xfsctl support $xfs"
7b02f544 4791echo "smartcard support $smartcard"
2b2325ff 4792echo "libusb $libusb"
69354a83 4793echo "usb net redir $usb_redir"
da076ffe 4794echo "OpenGL support $opengl"
014cb152 4795echo "OpenGL dmabufs $opengl_dmabuf"
c589b249 4796echo "libiscsi support $libiscsi"
6542aa9c 4797echo "libnfs support $libnfs"
d138cee9 4798echo "build guest agent $guest_agent"
d9840e25 4799echo "QGA VSS support $guest_agent_with_vss"
50cbebb9 4800echo "QGA w32 disk info $guest_agent_ntddscsi"
4c875d89 4801echo "QGA MSI support $guest_agent_msi"
f794573e 4802echo "seccomp support $seccomp"
7c2acc70 4803echo "coroutine backend $coroutine"
70c60c08 4804echo "coroutine pool $coroutine_pool"
eb100396 4805echo "GlusterFS support $glusterfs"
c9a12e75 4806echo "Archipelago support $archipelago"
1d728c39
BS
4807echo "gcov $gcov_tool"
4808echo "gcov enabled $gcov"
ab214c29 4809echo "TPM support $tpm"
0a12ec87 4810echo "libssh2 support $libssh2"
3b8acc11 4811echo "TPM passthrough $tpm_passthrough"
3556c233 4812echo "QOM debugging $qom_cast_debug"
4f18b782 4813echo "vhdx $vhdx"
607dacd0
QN
4814echo "lzo support $lzo"
4815echo "snappy support $snappy"
6b383c08 4816echo "bzip2 support $bzip2"
a99d57bb 4817echo "NUMA host support $numa"
2847b469 4818echo "tcmalloc support $tcmalloc"
7b01cb97 4819echo "jemalloc support $jemalloc"
99f2dbd3 4820echo "avx2 optimization $avx2_opt"
67b915a5 4821
1ba16968 4822if test "$sdl_too_old" = "yes"; then
24b55b96 4823echo "-> Your SDL version is too old - please upgrade to have SDL support"
7c1f25b4 4824fi
7d13299d 4825
98ec69ac 4826config_host_mak="config-host.mak"
98ec69ac 4827
dbd99ae3
SW
4828echo "# Automatically generated by configure - do not modify" >config-all-disas.mak
4829
98ec69ac 4830echo "# Automatically generated by configure - do not modify" > $config_host_mak
98ec69ac 4831echo >> $config_host_mak
98ec69ac 4832
e6c3b0f7 4833echo all: >> $config_host_mak
99d7cc75
PB
4834echo "prefix=$prefix" >> $config_host_mak
4835echo "bindir=$bindir" >> $config_host_mak
3aa5d2be 4836echo "libdir=$libdir" >> $config_host_mak
8bf188aa 4837echo "libexecdir=$libexecdir" >> $config_host_mak
0f94d6da 4838echo "includedir=$includedir" >> $config_host_mak
99d7cc75 4839echo "mandir=$mandir" >> $config_host_mak
99d7cc75 4840echo "sysconfdir=$sysconfdir" >> $config_host_mak
22d07038 4841echo "qemu_confdir=$qemu_confdir" >> $config_host_mak
9afa52ce
EH
4842echo "qemu_datadir=$qemu_datadir" >> $config_host_mak
4843echo "qemu_docdir=$qemu_docdir" >> $config_host_mak
e26110cf 4844echo "qemu_moddir=$qemu_moddir" >> $config_host_mak
5a699bbb
LE
4845if test "$mingw32" = "no" ; then
4846 echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
4847fi
f354b1a1 4848echo "qemu_helperdir=$libexecdir" >> $config_host_mak
f9943cd5
GH
4849echo "extra_cflags=$EXTRA_CFLAGS" >> $config_host_mak
4850echo "extra_ldflags=$EXTRA_LDFLAGS" >> $config_host_mak
834574ea 4851echo "qemu_localedir=$qemu_localedir" >> $config_host_mak
f544a488 4852echo "libs_softmmu=$libs_softmmu" >> $config_host_mak
804edf29 4853
98ec69ac 4854echo "ARCH=$ARCH" >> $config_host_mak
727e5283 4855
f8393946 4856if test "$debug_tcg" = "yes" ; then
2358a494 4857 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
f8393946 4858fi
1625af87 4859if test "$strip_opt" = "yes" ; then
52ba784d 4860 echo "STRIP=${strip}" >> $config_host_mak
1625af87 4861fi
7d13299d 4862if test "$bigendian" = "yes" ; then
e2542fe2 4863 echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
97a847bc 4864fi
67b915a5 4865if test "$mingw32" = "yes" ; then
98ec69ac 4866 echo "CONFIG_WIN32=y" >> $config_host_mak
9fe6de94
BS
4867 rc_version=`cat $source_path/VERSION`
4868 version_major=${rc_version%%.*}
4869 rc_version=${rc_version#*.}
4870 version_minor=${rc_version%%.*}
4871 rc_version=${rc_version#*.}
4872 version_subminor=${rc_version%%.*}
4873 version_micro=0
4874 echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
4875 echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
d9840e25
TS
4876 if test "$guest_agent_with_vss" = "yes" ; then
4877 echo "CONFIG_QGA_VSS=y" >> $config_host_mak
f33ca81f 4878 echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
d9840e25
TS
4879 echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
4880 fi
50cbebb9
MR
4881 if test "$guest_agent_ntddscsi" = "yes" ; then
4882 echo "CONFIG_QGA_NTDDDISK=y" >> $config_host_mak
4883 fi
1a34904e 4884 if test "$guest_agent_msi" = "yes"; then
9dacf32d
YH
4885 echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
4886 echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
4887 echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
4888 echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
4889 echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
4890 echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
4891 echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
4892 fi
210fa556 4893else
35f4df27 4894 echo "CONFIG_POSIX=y" >> $config_host_mak
dffcb71c
MM
4895fi
4896
4897if test "$linux" = "yes" ; then
4898 echo "CONFIG_LINUX=y" >> $config_host_mak
67b915a5 4899fi
128ab2ff 4900
83fb7adf 4901if test "$darwin" = "yes" ; then
98ec69ac 4902 echo "CONFIG_DARWIN=y" >> $config_host_mak
83fb7adf 4903fi
b29fe3ed 4904
4905if test "$aix" = "yes" ; then
98ec69ac 4906 echo "CONFIG_AIX=y" >> $config_host_mak
b29fe3ed 4907fi
4908
ec530c81 4909if test "$solaris" = "yes" ; then
98ec69ac 4910 echo "CONFIG_SOLARIS=y" >> $config_host_mak
2358a494 4911 echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
0475a5ca 4912 if test "$needs_libsunmath" = "yes" ; then
75b5a697 4913 echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
0475a5ca 4914 fi
ec530c81 4915fi
179cf400
AF
4916if test "$haiku" = "yes" ; then
4917 echo "CONFIG_HAIKU=y" >> $config_host_mak
4918fi
97a847bc 4919if test "$static" = "yes" ; then
98ec69ac 4920 echo "CONFIG_STATIC=y" >> $config_host_mak
7d13299d 4921fi
1ba16968 4922if test "$profiler" = "yes" ; then
2358a494 4923 echo "CONFIG_PROFILER=y" >> $config_host_mak
05c2a3e7 4924fi
c20709aa 4925if test "$slirp" = "yes" ; then
98ec69ac 4926 echo "CONFIG_SLIRP=y" >> $config_host_mak
e2d8830e 4927 echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
c20709aa 4928fi
8a16d273 4929if test "$vde" = "yes" ; then
98ec69ac 4930 echo "CONFIG_VDE=y" >> $config_host_mak
8a16d273 4931fi
58952137
VM
4932if test "$netmap" = "yes" ; then
4933 echo "CONFIG_NETMAP=y" >> $config_host_mak
4934fi
015a33bd
GA
4935if test "$l2tpv3" = "yes" ; then
4936 echo "CONFIG_L2TPV3=y" >> $config_host_mak
4937fi
47e98658
CB
4938if test "$cap_ng" = "yes" ; then
4939 echo "CONFIG_LIBCAP=y" >> $config_host_mak
4940fi
2358a494 4941echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
0c58ac1c 4942for drv in $audio_drv_list; do
bb55b712 4943 def=CONFIG_`echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]'`
98ec69ac 4944 echo "$def=y" >> $config_host_mak
0c58ac1c 4945done
67f86e8e
JQ
4946if test "$audio_pt_int" = "yes" ; then
4947 echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
4948fi
d5631638 4949if test "$audio_win_int" = "yes" ; then
4950 echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
4951fi
b64ec4e4
FZ
4952echo "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
4953echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
821601ea
JS
4954if test "$vnc" = "yes" ; then
4955 echo "CONFIG_VNC=y" >> $config_host_mak
4956fi
2f9606b3 4957if test "$vnc_sasl" = "yes" ; then
98ec69ac 4958 echo "CONFIG_VNC_SASL=y" >> $config_host_mak
2f9606b3 4959fi
821601ea 4960if test "$vnc_jpeg" = "yes" ; then
2f6f5c7a 4961 echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
2f6f5c7a 4962fi
821601ea 4963if test "$vnc_png" = "yes" ; then
efe556ad 4964 echo "CONFIG_VNC_PNG=y" >> $config_host_mak
efe556ad 4965fi
76655d6d 4966if test "$fnmatch" = "yes" ; then
2358a494 4967 echo "CONFIG_FNMATCH=y" >> $config_host_mak
76655d6d 4968fi
ee682d27
SW
4969if test "$uuid" = "yes" ; then
4970 echo "CONFIG_UUID=y" >> $config_host_mak
4971fi
dce512de
CH
4972if test "$xfs" = "yes" ; then
4973 echo "CONFIG_XFS=y" >> $config_host_mak
4974fi
b1a550a0 4975qemu_version=`head $source_path/VERSION`
98ec69ac 4976echo "VERSION=$qemu_version" >>$config_host_mak
2358a494 4977echo "PKGVERSION=$pkgversion" >>$config_host_mak
98ec69ac 4978echo "SRC_PATH=$source_path" >> $config_host_mak
98ec69ac 4979echo "TARGET_DIRS=$target_list" >> $config_host_mak
a25dba17 4980if [ "$docs" = "yes" ] ; then
98ec69ac 4981 echo "BUILD_DOCS=yes" >> $config_host_mak
cc8ae6de 4982fi
17969268 4983if test "$modules" = "yes"; then
e26110cf
FZ
4984 # $shacmd can generate a hash started with digit, which the compiler doesn't
4985 # like as an symbol. So prefix it with an underscore
4986 echo "CONFIG_STAMP=_`(echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ `" >> $config_host_mak
17969268
FZ
4987 echo "CONFIG_MODULES=y" >> $config_host_mak
4988fi
1ac88f28 4989if test "$sdl" = "yes" ; then
98ec69ac 4990 echo "CONFIG_SDL=y" >> $config_host_mak
a3f4d63d 4991 echo "CONFIG_SDLABI=$sdlabi" >> $config_host_mak
1ac88f28 4992 echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
49ecc3fa
FB
4993fi
4994if test "$cocoa" = "yes" ; then
98ec69ac 4995 echo "CONFIG_COCOA=y" >> $config_host_mak
4d3b6f6e
AZ
4996fi
4997if test "$curses" = "yes" ; then
98ec69ac 4998 echo "CONFIG_CURSES=y" >> $config_host_mak
49ecc3fa 4999fi
ebc996f3 5000if test "$utimens" = "yes" ; then
2358a494 5001 echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
ebc996f3 5002fi
099d6b0f 5003if test "$pipe2" = "yes" ; then
2358a494 5004 echo "CONFIG_PIPE2=y" >> $config_host_mak
099d6b0f 5005fi
40ff6d7e
KW
5006if test "$accept4" = "yes" ; then
5007 echo "CONFIG_ACCEPT4=y" >> $config_host_mak
5008fi
3ce34dfb 5009if test "$splice" = "yes" ; then
2358a494 5010 echo "CONFIG_SPLICE=y" >> $config_host_mak
3ce34dfb 5011fi
c2882b96
RV
5012if test "$eventfd" = "yes" ; then
5013 echo "CONFIG_EVENTFD=y" >> $config_host_mak
5014fi
751bcc39
MAL
5015if test "$memfd" = "yes" ; then
5016 echo "CONFIG_MEMFD=y" >> $config_host_mak
5017fi
d0927938
UH
5018if test "$fallocate" = "yes" ; then
5019 echo "CONFIG_FALLOCATE=y" >> $config_host_mak
5020fi
3d4fa43e
KK
5021if test "$fallocate_punch_hole" = "yes" ; then
5022 echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
5023fi
b953f075
DL
5024if test "$fallocate_zero_range" = "yes" ; then
5025 echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
5026fi
ed911435
KW
5027if test "$posix_fallocate" = "yes" ; then
5028 echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
5029fi
c727f47d
PM
5030if test "$sync_file_range" = "yes" ; then
5031 echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
5032fi
dace20dc
PM
5033if test "$fiemap" = "yes" ; then
5034 echo "CONFIG_FIEMAP=y" >> $config_host_mak
5035fi
d0927938
UH
5036if test "$dup3" = "yes" ; then
5037 echo "CONFIG_DUP3=y" >> $config_host_mak
5038fi
4e0c6529
AB
5039if test "$ppoll" = "yes" ; then
5040 echo "CONFIG_PPOLL=y" >> $config_host_mak
5041fi
cd758dd0
AB
5042if test "$prctl_pr_set_timerslack" = "yes" ; then
5043 echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
5044fi
3b6edd16
PM
5045if test "$epoll" = "yes" ; then
5046 echo "CONFIG_EPOLL=y" >> $config_host_mak
5047fi
5048if test "$epoll_create1" = "yes" ; then
5049 echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
5050fi
5051if test "$epoll_pwait" = "yes" ; then
5052 echo "CONFIG_EPOLL_PWAIT=y" >> $config_host_mak
5053fi
a8fd1aba
PM
5054if test "$sendfile" = "yes" ; then
5055 echo "CONFIG_SENDFILE=y" >> $config_host_mak
5056fi
51834341
RV
5057if test "$timerfd" = "yes" ; then
5058 echo "CONFIG_TIMERFD=y" >> $config_host_mak
5059fi
9af5c906
RV
5060if test "$setns" = "yes" ; then
5061 echo "CONFIG_SETNS=y" >> $config_host_mak
5062fi
3b3f24ad 5063if test "$inotify" = "yes" ; then
2358a494 5064 echo "CONFIG_INOTIFY=y" >> $config_host_mak
3b3f24ad 5065fi
c05c7a73
RV
5066if test "$inotify1" = "yes" ; then
5067 echo "CONFIG_INOTIFY1=y" >> $config_host_mak
5068fi
6ae9a1f4
JQ
5069if test "$byteswap_h" = "yes" ; then
5070 echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
5071fi
5072if test "$bswap_h" = "yes" ; then
5073 echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
5074fi
769ce76d 5075if test "$curl" = "yes" ; then
d3399d7c 5076 echo "CONFIG_CURL=m" >> $config_host_mak
b1d5a277 5077 echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
6ebc91e5 5078 echo "CURL_LIBS=$curl_libs" >> $config_host_mak
769ce76d 5079fi
2e4d9fb1 5080if test "$brlapi" = "yes" ; then
98ec69ac 5081 echo "CONFIG_BRLAPI=y" >> $config_host_mak
2e4d9fb1 5082fi
fb599c9a 5083if test "$bluez" = "yes" ; then
98ec69ac 5084 echo "CONFIG_BLUEZ=y" >> $config_host_mak
ef7635ec 5085 echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
fb599c9a 5086fi
d46f7c9e 5087if test "$glib_subprocess" = "yes" ; then
9d41401b
MT
5088 echo "CONFIG_HAS_GLIB_SUBPROCESS_TESTS=y" >> $config_host_mak
5089fi
e18df141 5090echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
a4ccabcf
AL
5091if test "$gtk" = "yes" ; then
5092 echo "CONFIG_GTK=y" >> $config_host_mak
a3f4d63d 5093 echo "CONFIG_GTKABI=$gtkabi" >> $config_host_mak
a4ccabcf 5094 echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
014cb152 5095 echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
925a0400
GH
5096 if test "$gtk_gl" = "yes" ; then
5097 echo "CONFIG_GTK_GL=y" >> $config_host_mak
5098 fi
bbbf9bfb 5099fi
ddbb0d09
DB
5100if test "$gnutls" = "yes" ; then
5101 echo "CONFIG_GNUTLS=y" >> $config_host_mak
5102fi
5103if test "$gnutls_hash" = "yes" ; then
5104 echo "CONFIG_GNUTLS_HASH=y" >> $config_host_mak
5105fi
b917da4c
DB
5106if test "$gnutls_rnd" = "yes" ; then
5107 echo "CONFIG_GNUTLS_RND=y" >> $config_host_mak
5108fi
91bfcdb0
DB
5109if test "$gcrypt" = "yes" ; then
5110 echo "CONFIG_GCRYPT=y" >> $config_host_mak
62893b67 5111fi
91bfcdb0
DB
5112if test "$nettle" = "yes" ; then
5113 echo "CONFIG_NETTLE=y" >> $config_host_mak
becaeb72 5114 echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
ed754746 5115fi
9a2fd434
DB
5116if test "$tasn1" = "yes" ; then
5117 echo "CONFIG_TASN1=y" >> $config_host_mak
5118fi
559607ea
DB
5119if test "$have_ifaddrs_h" = "yes" ; then
5120 echo "HAVE_IFADDRS_H=y" >> $config_host_mak
5121fi
bbbf9bfb
SW
5122if test "$vte" = "yes" ; then
5123 echo "CONFIG_VTE=y" >> $config_host_mak
a4ccabcf
AL
5124 echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
5125fi
9d9e1521
GH
5126if test "$virglrenderer" = "yes" ; then
5127 echo "CONFIG_VIRGL=y" >> $config_host_mak
5128 echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
5129 echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
5130fi
e37630ca 5131if test "$xen" = "yes" ; then
6dbd588a 5132 echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
d5b93ddf 5133 echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
64a7ad6f
IC
5134 if test "$xen_pv_domain_build" = "yes" ; then
5135 echo "CONFIG_XEN_PV_DOMAIN_BUILD=y" >> $config_host_mak
5136 fi
e37630ca 5137fi
5c6c3a6c
CH
5138if test "$linux_aio" = "yes" ; then
5139 echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
5140fi
758e8e38
VJ
5141if test "$attr" = "yes" ; then
5142 echo "CONFIG_ATTR=y" >> $config_host_mak
5143fi
4f26f2b6
AK
5144if test "$libattr" = "yes" ; then
5145 echo "CONFIG_LIBATTR=y" >> $config_host_mak
5146fi
983eef5a
MI
5147if test "$virtfs" = "yes" ; then
5148 echo "CONFIG_VIRTFS=y" >> $config_host_mak
758e8e38 5149fi
5e9be92d
NB
5150if test "$vhost_scsi" = "yes" ; then
5151 echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
5152fi
03ce5744
NN
5153if test "$vhost_net" = "yes" ; then
5154 echo "CONFIG_VHOST_NET_USED=y" >> $config_host_mak
5155fi
77755340 5156if test "$blobs" = "yes" ; then
98ec69ac 5157 echo "INSTALL_BLOBS=yes" >> $config_host_mak
77755340 5158fi
bf9298b9 5159if test "$iovec" = "yes" ; then
2358a494 5160 echo "CONFIG_IOVEC=y" >> $config_host_mak
bf9298b9 5161fi
ceb42de8 5162if test "$preadv" = "yes" ; then
2358a494 5163 echo "CONFIG_PREADV=y" >> $config_host_mak
ceb42de8 5164fi
f652e6af 5165if test "$fdt" = "yes" ; then
3f0855b1 5166 echo "CONFIG_FDT=y" >> $config_host_mak
f652e6af 5167fi
dcc38d1c
MT
5168if test "$signalfd" = "yes" ; then
5169 echo "CONFIG_SIGNALFD=y" >> $config_host_mak
5170fi
9195b2c2
SW
5171if test "$tcg_interpreter" = "yes" ; then
5172 echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
5173fi
5f6b9e8f
BS
5174if test "$fdatasync" = "yes" ; then
5175 echo "CONFIG_FDATASYNC=y" >> $config_host_mak
5176fi
e78815a5
AF
5177if test "$madvise" = "yes" ; then
5178 echo "CONFIG_MADVISE=y" >> $config_host_mak
5179fi
5180if test "$posix_madvise" = "yes" ; then
5181 echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
5182fi
1e9737da
RH
5183if test "$sigev_thread_id" = "yes" ; then
5184 echo "CONFIG_SIGEV_THREAD_ID=y" >> $config_host_mak
5185fi
97a847bc 5186
cd4ec0b4
GH
5187if test "$spice" = "yes" ; then
5188 echo "CONFIG_SPICE=y" >> $config_host_mak
5189fi
36707144 5190
7b02f544
MAL
5191if test "$smartcard" = "yes" ; then
5192 echo "CONFIG_SMARTCARD=y" >> $config_host_mak
111a38b0
RR
5193fi
5194
2b2325ff
GH
5195if test "$libusb" = "yes" ; then
5196 echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
5197fi
5198
69354a83
HG
5199if test "$usb_redir" = "yes" ; then
5200 echo "CONFIG_USB_REDIR=y" >> $config_host_mak
5201fi
5202
da076ffe
GH
5203if test "$opengl" = "yes" ; then
5204 echo "CONFIG_OPENGL=y" >> $config_host_mak
f676c67e 5205 echo "OPENGL_CFLAGS=$opengl_cflags" >> $config_host_mak
da076ffe 5206 echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
014cb152
GH
5207 if test "$opengl_dmabuf" = "yes" ; then
5208 echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
5209 fi
20ff075b
MW
5210fi
5211
99f2dbd3
LL
5212if test "$avx2_opt" = "yes" ; then
5213 echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
5214fi
5215
607dacd0
QN
5216if test "$lzo" = "yes" ; then
5217 echo "CONFIG_LZO=y" >> $config_host_mak
5218fi
5219
5220if test "$snappy" = "yes" ; then
5221 echo "CONFIG_SNAPPY=y" >> $config_host_mak
5222fi
5223
6b383c08
PW
5224if test "$bzip2" = "yes" ; then
5225 echo "CONFIG_BZIP2=y" >> $config_host_mak
5226 echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
5227fi
5228
c589b249 5229if test "$libiscsi" = "yes" ; then
d3399d7c 5230 echo "CONFIG_LIBISCSI=m" >> $config_host_mak
6ebc91e5
FZ
5231 echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
5232 echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
c589b249
RS
5233fi
5234
6542aa9c
PL
5235if test "$libnfs" = "yes" ; then
5236 echo "CONFIG_LIBNFS=y" >> $config_host_mak
5237fi
5238
f794573e
EO
5239if test "$seccomp" = "yes"; then
5240 echo "CONFIG_SECCOMP=y" >> $config_host_mak
5241fi
5242
83fb7adf 5243# XXX: suppress that
7d3505c5 5244if [ "$bsd" = "yes" ] ; then
2358a494 5245 echo "CONFIG_BSD=y" >> $config_host_mak
7d3505c5
FB
5246fi
5247
20ff6c80
AL
5248if test "$zero_malloc" = "yes" ; then
5249 echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
5250fi
4d9310f4
DB
5251if test "$localtime_r" = "yes" ; then
5252 echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
5253fi
3556c233
PB
5254if test "$qom_cast_debug" = "yes" ; then
5255 echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
5256fi
f27aaf4b 5257if test "$rbd" = "yes" ; then
d3399d7c 5258 echo "CONFIG_RBD=m" >> $config_host_mak
6ebc91e5
FZ
5259 echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
5260 echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
d0e2fce5
AK
5261fi
5262
7c2acc70 5263echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
70c60c08
SH
5264if test "$coroutine_pool" = "yes" ; then
5265 echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
5266else
5267 echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
5268fi
20ff6c80 5269
d2042378
AK
5270if test "$open_by_handle_at" = "yes" ; then
5271 echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
5272fi
5273
e06a765e
HPB
5274if test "$linux_magic_h" = "yes" ; then
5275 echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
8ab1bf12
LC
5276fi
5277
cc6e3ca9
GH
5278if test "$pragma_diagnostic_available" = "yes" ; then
5279 echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
06d71fa1
PM
5280fi
5281
3f4349dc
KW
5282if test "$valgrind_h" = "yes" ; then
5283 echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
5284fi
5285
8ab1bf12
LC
5286if test "$has_environ" = "yes" ; then
5287 echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
e06a765e
HPB
5288fi
5289
76a347e1
RH
5290if test "$cpuid_h" = "yes" ; then
5291 echo "CONFIG_CPUID_H=y" >> $config_host_mak
5292fi
5293
f540166b
RH
5294if test "$int128" = "yes" ; then
5295 echo "CONFIG_INT128=y" >> $config_host_mak
5296fi
5297
1e6e9aca
RH
5298if test "$getauxval" = "yes" ; then
5299 echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
5300fi
5301
eb100396 5302if test "$glusterfs" = "yes" ; then
d3399d7c 5303 echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
6ebc91e5
FZ
5304 echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
5305 echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
0c14fb47
BR
5306fi
5307
5308if test "$glusterfs_discard" = "yes" ; then
5309 echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
eb100396 5310fi
e06a765e 5311
7c815372
BR
5312if test "$glusterfs_zerofill" = "yes" ; then
5313 echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
5314fi
5315
c9a12e75
CN
5316if test "$archipelago" = "yes" ; then
5317 echo "CONFIG_ARCHIPELAGO=m" >> $config_host_mak
5318 echo "ARCHIPELAGO_LIBS=$archipelago_libs" >> $config_host_mak
5319fi
5320
0a12ec87 5321if test "$libssh2" = "yes" ; then
d3399d7c 5322 echo "CONFIG_LIBSSH2=m" >> $config_host_mak
6ebc91e5
FZ
5323 echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
5324 echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak
0a12ec87
RJ
5325fi
5326
4f18b782
JC
5327if test "$vhdx" = "yes" ; then
5328 echo "CONFIG_VHDX=y" >> $config_host_mak
5329fi
5330
68063649 5331# USB host support
b5613fdc
GH
5332if test "$libusb" = "yes"; then
5333 echo "HOST_USB=libusb legacy" >> $config_host_mak
5334else
98ec69ac 5335 echo "HOST_USB=stub" >> $config_host_mak
b5613fdc 5336fi
68063649 5337
3b8acc11
PB
5338# TPM passthrough support?
5339if test "$tpm" = "yes"; then
5340 echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak
5341 if test "$tpm_passthrough" = "yes"; then
5342 echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
5343 fi
5344fi
5345
5b808275
LV
5346echo "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
5347if have_backend "nop"; then
6d8a764e 5348 echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
22890ab5 5349fi
5b808275 5350if have_backend "simple"; then
6d8a764e
LV
5351 echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
5352 # Set the appropriate trace file.
953ffe0f 5353 trace_file="\"$trace_file-\" FMT_pid"
9410b56c 5354fi
ed7f5f1d
PB
5355if have_backend "log"; then
5356 echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
6d8a764e 5357fi
5b808275 5358if have_backend "ust"; then
6d8a764e
LV
5359 echo "CONFIG_TRACE_UST=y" >> $config_host_mak
5360fi
5b808275 5361if have_backend "dtrace"; then
6d8a764e
LV
5362 echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
5363 if test "$trace_backend_stap" = "yes" ; then
5364 echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
5365 fi
c276b17d 5366fi
5b808275 5367if have_backend "ftrace"; then
781e9545
ET
5368 if test "$linux" = "yes" ; then
5369 echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
781e9545 5370 else
21684af0 5371 feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
781e9545
ET
5372 fi
5373fi
9410b56c
PS
5374echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
5375
2da776db
MH
5376if test "$rdma" = "yes" ; then
5377 echo "CONFIG_RDMA=y" >> $config_host_mak
5378fi
5379
5c312079
DDAG
5380# Hold two types of flag:
5381# CONFIG_THREAD_SETNAME_BYTHREAD - we've got a way of setting the name on
5382# a thread we have a handle to
5383# CONFIG_PTHREAD_SETNAME_NP - A way of doing it on a particular
5384# platform
5385if test "$pthread_setname_np" = "yes" ; then
5386 echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
5387 echo "CONFIG_PTHREAD_SETNAME_NP=y" >> $config_host_mak
5388fi
5389
5b5e3037
PB
5390if test "$tcg_interpreter" = "yes"; then
5391 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
5392elif test "$ARCH" = "sparc64" ; then
5393 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
5394elif test "$ARCH" = "s390x" ; then
5395 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
c72b26ec 5396elif test "$ARCH" = "x86_64" -o "$ARCH" = "x32" ; then
5b5e3037 5397 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
40d964b5
RH
5398elif test "$ARCH" = "ppc64" ; then
5399 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/ppc $QEMU_INCLUDES"
5b5e3037
PB
5400else
5401 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
5402fi
5403QEMU_INCLUDES="-I\$(SRC_PATH)/tcg $QEMU_INCLUDES"
5404
98ec69ac 5405echo "TOOLS=$tools" >> $config_host_mak
98ec69ac 5406echo "ROMS=$roms" >> $config_host_mak
804edf29
JQ
5407echo "MAKE=$make" >> $config_host_mak
5408echo "INSTALL=$install" >> $config_host_mak
1901cb14
BS
5409echo "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
5410echo "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
e999ee44
MT
5411echo "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
5412echo "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
c886edfb 5413echo "PYTHON=$python" >> $config_host_mak
804edf29 5414echo "CC=$cc" >> $config_host_mak
a31a8642
MT
5415if $iasl -h > /dev/null 2>&1; then
5416 echo "IASL=$iasl" >> $config_host_mak
5417fi
2b2e59e6 5418echo "CC_I386=$cc_i386" >> $config_host_mak
804edf29 5419echo "HOST_CC=$host_cc" >> $config_host_mak
83f73fce 5420echo "CXX=$cxx" >> $config_host_mak
3c4a4d0d 5421echo "OBJCC=$objcc" >> $config_host_mak
804edf29 5422echo "AR=$ar" >> $config_host_mak
45d285ab 5423echo "ARFLAGS=$ARFLAGS" >> $config_host_mak
3dd46c78
BS
5424echo "AS=$as" >> $config_host_mak
5425echo "CPP=$cpp" >> $config_host_mak
804edf29
JQ
5426echo "OBJCOPY=$objcopy" >> $config_host_mak
5427echo "LD=$ld" >> $config_host_mak
4852ee95 5428echo "NM=$nm" >> $config_host_mak
9fe6de94 5429echo "WINDRES=$windres" >> $config_host_mak
e2a2ed06 5430echo "CFLAGS=$CFLAGS" >> $config_host_mak
46eef33b 5431echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
a558ee17 5432echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
f9728943 5433echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
e39f0062
PB
5434if test "$sparse" = "yes" ; then
5435 echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_host_mak
80fd48df 5436 echo "CPP := REAL_CC=\"\$(CPP)\" cgcc" >> $config_host_mak
2944d742 5437 echo "CXX := REAL_CC=\"\$(CXX)\" cgcc" >> $config_host_mak
e39f0062
PB
5438 echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_host_mak
5439 echo "QEMU_CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
5440fi
42da6041
GH
5441if test "$cross_prefix" != ""; then
5442 echo "AUTOCONF_HOST := --host=${cross_prefix%-}" >> $config_host_mak
5443else
5444 echo "AUTOCONF_HOST := " >> $config_host_mak
5445fi
e2a2ed06 5446echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
46eef33b 5447echo "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
73da375e 5448echo "LIBS+=$LIBS" >> $config_host_mak
3e2e0e6b 5449echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
804edf29 5450echo "EXESUF=$EXESUF" >> $config_host_mak
17969268
FZ
5451echo "DSOSUF=$DSOSUF" >> $config_host_mak
5452echo "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
957f1f99 5453echo "LIBS_QGA+=$libs_qga" >> $config_host_mak
90246037
DB
5454echo "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
5455echo "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
94dd53c5 5456echo "POD2MAN=$POD2MAN" >> $config_host_mak
cbdd1999 5457echo "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
1d728c39
BS
5458if test "$gcov" = "yes" ; then
5459 echo "CONFIG_GCOV=y" >> $config_host_mak
5460 echo "GCOV=$gcov_tool" >> $config_host_mak
5461fi
804edf29 5462
6efd7517
PM
5463# use included Linux headers
5464if test "$linux" = "yes" ; then
a307beb6 5465 mkdir -p linux-headers
6efd7517 5466 case "$cpu" in
c72b26ec 5467 i386|x86_64|x32)
08312a63 5468 linux_arch=x86
6efd7517
PM
5469 ;;
5470 ppcemb|ppc|ppc64)
08312a63 5471 linux_arch=powerpc
6efd7517
PM
5472 ;;
5473 s390x)
08312a63
PM
5474 linux_arch=s390
5475 ;;
1f080313
CF
5476 aarch64)
5477 linux_arch=arm64
5478 ;;
222e7d11
SL
5479 mips64)
5480 linux_arch=mips
5481 ;;
08312a63
PM
5482 *)
5483 # For most CPUs the kernel architecture name and QEMU CPU name match.
5484 linux_arch="$cpu"
6efd7517
PM
5485 ;;
5486 esac
08312a63
PM
5487 # For non-KVM architectures we will not have asm headers
5488 if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
5489 symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
5490 fi
6efd7517
PM
5491fi
5492
1d14ffa9 5493for target in $target_list; do
97a847bc 5494target_dir="$target"
25be210f 5495config_target_mak=$target_dir/config-target.mak
c1799a84 5496target_name=`echo $target | cut -d '-' -f 1`
97a847bc 5497target_bigendian="no"
1f3d3c8f 5498
c1799a84 5499case "$target_name" in
d15a9c23 5500 armeb|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or32|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
ea2d6a39
JQ
5501 target_bigendian=yes
5502 ;;
5503esac
97a847bc 5504target_softmmu="no"
997344f3 5505target_user_only="no"
831b7825 5506target_linux_user="no"
84778508 5507target_bsd_user="no"
9e407a85 5508case "$target" in
c1799a84 5509 ${target_name}-softmmu)
9e407a85
PB
5510 target_softmmu="yes"
5511 ;;
c1799a84 5512 ${target_name}-linux-user)
9c7a4202 5513 if test "$linux" != "yes" ; then
76ad07a4 5514 error_exit "Target '$target' is only available on a Linux host"
9c7a4202 5515 fi
9e407a85
PB
5516 target_user_only="yes"
5517 target_linux_user="yes"
5518 ;;
c1799a84 5519 ${target_name}-bsd-user)
9cf55765 5520 if test "$bsd" != "yes" ; then
76ad07a4 5521 error_exit "Target '$target' is only available on a BSD host"
9c7a4202 5522 fi
84778508
BS
5523 target_user_only="yes"
5524 target_bsd_user="yes"
5525 ;;
9e407a85 5526 *)
76ad07a4 5527 error_exit "Target '$target' not recognised"
9e407a85
PB
5528 exit 1
5529 ;;
5530esac
831b7825 5531
97a847bc 5532mkdir -p $target_dir
25be210f 5533echo "# Automatically generated by configure - do not modify" > $config_target_mak
de83cd02 5534
e5fe0c52 5535bflt="no"
c1799a84 5536interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_name/g"`
56aebc89 5537gdb_xml_files=""
7ba1e619 5538
c1799a84 5539TARGET_ARCH="$target_name"
6acff7da 5540TARGET_BASE_ARCH=""
e6e91b9c 5541TARGET_ABI_DIR=""
e73aae67 5542
c1799a84 5543case "$target_name" in
2408a527 5544 i386)
2408a527
AJ
5545 ;;
5546 x86_64)
6acff7da 5547 TARGET_BASE_ARCH=i386
2408a527
AJ
5548 ;;
5549 alpha)
2408a527
AJ
5550 ;;
5551 arm|armeb)
b498c8a0 5552 TARGET_ARCH=arm
2408a527 5553 bflt="yes"
56aebc89 5554 gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
2408a527 5555 ;;
6a49fa95
AG
5556 aarch64)
5557 TARGET_BASE_ARCH=arm
5558 bflt="yes"
8f95ce2e 5559 gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
6a49fa95 5560 ;;
2408a527 5561 cris)
2408a527 5562 ;;
613a22c9 5563 lm32)
613a22c9 5564 ;;
2408a527 5565 m68k)
2408a527 5566 bflt="yes"
56aebc89 5567 gdb_xml_files="cf-core.xml cf-fp.xml"
2408a527 5568 ;;
877fdc12
EI
5569 microblaze|microblazeel)
5570 TARGET_ARCH=microblaze
72b675ca 5571 bflt="yes"
72b675ca 5572 ;;
0adcffb1 5573 mips|mipsel)
b498c8a0 5574 TARGET_ARCH=mips
25be210f 5575 echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
2408a527
AJ
5576 ;;
5577 mipsn32|mipsn32el)
597e2cec 5578 TARGET_ARCH=mips64
6acff7da 5579 TARGET_BASE_ARCH=mips
25be210f 5580 echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
597e2cec 5581 echo "TARGET_ABI32=y" >> $config_target_mak
2408a527
AJ
5582 ;;
5583 mips64|mips64el)
b498c8a0 5584 TARGET_ARCH=mips64
6acff7da 5585 TARGET_BASE_ARCH=mips
25be210f 5586 echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
2408a527 5587 ;;
d15a9c23
AG
5588 moxie)
5589 ;;
e67db06e
JL
5590 or32)
5591 TARGET_ARCH=openrisc
5592 TARGET_BASE_ARCH=openrisc
e67db06e 5593 ;;
2408a527 5594 ppc)
c8b3532d 5595 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2408a527
AJ
5596 ;;
5597 ppcemb)
6acff7da 5598 TARGET_BASE_ARCH=ppc
e6e91b9c 5599 TARGET_ABI_DIR=ppc
c8b3532d 5600 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2408a527
AJ
5601 ;;
5602 ppc64)
6acff7da 5603 TARGET_BASE_ARCH=ppc
e6e91b9c 5604 TARGET_ABI_DIR=ppc
1438eff3 5605 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
2408a527 5606 ;;
9c35126c
DK
5607 ppc64le)
5608 TARGET_ARCH=ppc64
5609 TARGET_BASE_ARCH=ppc
5610 TARGET_ABI_DIR=ppc
1438eff3 5611 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
9c35126c 5612 ;;
2408a527 5613 ppc64abi32)
b498c8a0 5614 TARGET_ARCH=ppc64
6acff7da 5615 TARGET_BASE_ARCH=ppc
e6e91b9c 5616 TARGET_ABI_DIR=ppc
25be210f 5617 echo "TARGET_ABI32=y" >> $config_target_mak
1438eff3 5618 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
2408a527
AJ
5619 ;;
5620 sh4|sh4eb)
b498c8a0 5621 TARGET_ARCH=sh4
2408a527
AJ
5622 bflt="yes"
5623 ;;
5624 sparc)
2408a527
AJ
5625 ;;
5626 sparc64)
6acff7da 5627 TARGET_BASE_ARCH=sparc
2408a527
AJ
5628 ;;
5629 sparc32plus)
b498c8a0 5630 TARGET_ARCH=sparc64
6acff7da 5631 TARGET_BASE_ARCH=sparc
e6e91b9c 5632 TARGET_ABI_DIR=sparc
25be210f 5633 echo "TARGET_ABI32=y" >> $config_target_mak
2408a527 5634 ;;
24e804ec 5635 s390x)
8a641ff6 5636 gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml s390-cr.xml s390-virt.xml"
24e804ec 5637 ;;
444e06b1
CG
5638 tilegx)
5639 ;;
5ecaa4ed
PC
5640 tricore)
5641 ;;
d2fbca94 5642 unicore32)
d2fbca94 5643 ;;
cfa550c6
MF
5644 xtensa|xtensaeb)
5645 TARGET_ARCH=xtensa
cfa550c6 5646 ;;
2408a527 5647 *)
76ad07a4 5648 error_exit "Unsupported target CPU"
2408a527
AJ
5649 ;;
5650esac
5e8861a0
PB
5651# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
5652if [ "$TARGET_BASE_ARCH" = "" ]; then
5653 TARGET_BASE_ARCH=$TARGET_ARCH
5654fi
5655
5e8861a0
PB
5656symlink "$source_path/Makefile.target" "$target_dir/Makefile"
5657
99afc91d
DB
5658upper() {
5659 echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
5660}
5661
99afc91d 5662target_arch_name="`upper $TARGET_ARCH`"
25be210f 5663echo "TARGET_$target_arch_name=y" >> $config_target_mak
c1799a84 5664echo "TARGET_NAME=$target_name" >> $config_target_mak
25be210f 5665echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
e6e91b9c
JQ
5666if [ "$TARGET_ABI_DIR" = "" ]; then
5667 TARGET_ABI_DIR=$TARGET_ARCH
5668fi
25be210f 5669echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
adfc3e91
SS
5670if [ "$HOST_VARIANT_DIR" != "" ]; then
5671 echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
5672fi
c1799a84 5673case "$target_name" in
1b0c87fc
JQ
5674 i386|x86_64)
5675 if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
25be210f 5676 echo "CONFIG_XEN=y" >> $config_target_mak
eb6fda0f
AP
5677 if test "$xen_pci_passthrough" = yes; then
5678 echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
5679 fi
1b0c87fc 5680 fi
59d21e53
AG
5681 ;;
5682 *)
1b0c87fc 5683esac
c1799a84 5684case "$target_name" in
222e7d11 5685 aarch64|arm|i386|x86_64|ppcemb|ppc|ppc64|s390x|mipsel|mips)
c59249f9
JQ
5686 # Make sure the target and host cpus are compatible
5687 if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
c1799a84
PB
5688 \( "$target_name" = "$cpu" -o \
5689 \( "$target_name" = "ppcemb" -a "$cpu" = "ppc" \) -o \
5690 \( "$target_name" = "ppc64" -a "$cpu" = "ppc" \) -o \
5691 \( "$target_name" = "ppc" -a "$cpu" = "ppc64" \) -o \
5692 \( "$target_name" = "ppcemb" -a "$cpu" = "ppc64" \) -o \
222e7d11 5693 \( "$target_name" = "mipsel" -a "$cpu" = "mips" \) -o \
c1799a84 5694 \( "$target_name" = "x86_64" -a "$cpu" = "i386" \) -o \
18b8263e
MT
5695 \( "$target_name" = "i386" -a "$cpu" = "x86_64" \) -o \
5696 \( "$target_name" = "x86_64" -a "$cpu" = "x32" \) -o \
5697 \( "$target_name" = "i386" -a "$cpu" = "x32" \) \) ; then
25be210f 5698 echo "CONFIG_KVM=y" >> $config_target_mak
1ba16968 5699 if test "$vhost_net" = "yes" ; then
d5970055 5700 echo "CONFIG_VHOST_NET=y" >> $config_target_mak
421f4448 5701 echo "CONFIG_VHOST_NET_TEST_$target_name=y" >> $config_host_mak
d5970055 5702 fi
c59249f9
JQ
5703 fi
5704esac
de83cd02 5705if test "$target_bigendian" = "yes" ; then
25be210f 5706 echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
de83cd02 5707fi
97a847bc 5708if test "$target_softmmu" = "yes" ; then
25be210f 5709 echo "CONFIG_SOFTMMU=y" >> $config_target_mak
43ce4dfe 5710fi
997344f3 5711if test "$target_user_only" = "yes" ; then
25be210f 5712 echo "CONFIG_USER_ONLY=y" >> $config_target_mak
a2c80be9 5713 echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
997344f3 5714fi
831b7825 5715if test "$target_linux_user" = "yes" ; then
25be210f 5716 echo "CONFIG_LINUX_USER=y" >> $config_target_mak
831b7825 5717fi
56aebc89
PB
5718list=""
5719if test ! -z "$gdb_xml_files" ; then
5720 for x in $gdb_xml_files; do
5721 list="$list $source_path/gdb-xml/$x"
5722 done
3d0f1517 5723 echo "TARGET_XML_FILES=$list" >> $config_target_mak
56aebc89 5724fi
97a847bc 5725
e5fe0c52 5726if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
25be210f 5727 echo "TARGET_HAS_BFLT=y" >> $config_target_mak
e5fe0c52 5728fi
84778508 5729if test "$target_bsd_user" = "yes" ; then
25be210f 5730 echo "CONFIG_BSD_USER=y" >> $config_target_mak
84778508 5731fi
5b0753e0 5732
4afddb55 5733# generate QEMU_CFLAGS/LDFLAGS for targets
fa282484 5734
4afddb55 5735cflags=""
fa282484 5736ldflags=""
9b8e111f 5737
c765fcac
PC
5738disas_config() {
5739 echo "CONFIG_${1}_DIS=y" >> $config_target_mak
5740 echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
5741}
5742
64656024
JQ
5743for i in $ARCH $TARGET_BASE_ARCH ; do
5744 case "$i" in
5745 alpha)
c765fcac 5746 disas_config "ALPHA"
64656024 5747 ;;
82295d8a
RH
5748 aarch64)
5749 if test -n "${cxx}"; then
c765fcac 5750 disas_config "ARM_A64"
82295d8a
RH
5751 fi
5752 ;;
64656024 5753 arm)
c765fcac 5754 disas_config "ARM"
999b53ec 5755 if test -n "${cxx}"; then
c765fcac 5756 disas_config "ARM_A64"
999b53ec 5757 fi
64656024
JQ
5758 ;;
5759 cris)
c765fcac 5760 disas_config "CRIS"
64656024
JQ
5761 ;;
5762 hppa)
c765fcac 5763 disas_config "HPPA"
64656024 5764 ;;
c72b26ec 5765 i386|x86_64|x32)
c765fcac 5766 disas_config "I386"
64656024 5767 ;;
903ec55c 5768 ia64*)
c765fcac 5769 disas_config "IA64"
903ec55c 5770 ;;
79368f49 5771 lm32)
c765fcac 5772 disas_config "LM32"
79368f49 5773 ;;
64656024 5774 m68k)
c765fcac 5775 disas_config "M68K"
64656024 5776 ;;
877fdc12 5777 microblaze*)
c765fcac 5778 disas_config "MICROBLAZE"
64656024
JQ
5779 ;;
5780 mips*)
c765fcac 5781 disas_config "MIPS"
64656024 5782 ;;
d15a9c23 5783 moxie*)
c765fcac 5784 disas_config "MOXIE"
d15a9c23 5785 ;;
e67db06e 5786 or32)
c765fcac 5787 disas_config "OPENRISC"
e67db06e 5788 ;;
64656024 5789 ppc*)
c765fcac 5790 disas_config "PPC"
64656024 5791 ;;
24e804ec 5792 s390*)
c765fcac 5793 disas_config "S390"
64656024
JQ
5794 ;;
5795 sh4)
c765fcac 5796 disas_config "SH4"
64656024
JQ
5797 ;;
5798 sparc*)
c765fcac 5799 disas_config "SPARC"
64656024 5800 ;;
cfa550c6 5801 xtensa*)
c765fcac 5802 disas_config "XTENSA"
cfa550c6 5803 ;;
64656024
JQ
5804 esac
5805done
9195b2c2 5806if test "$tcg_interpreter" = "yes" ; then
c765fcac 5807 disas_config "TCI"
9195b2c2 5808fi
64656024 5809
6ee7126f
JQ
5810case "$ARCH" in
5811alpha)
5812 # Ensure there's only a single GP
5813 cflags="-msmall-data $cflags"
5814;;
5815esac
5816
d02c1db3 5817if test "$gprof" = "yes" ; then
25be210f 5818 echo "TARGET_GPROF=yes" >> $config_target_mak
d02c1db3
JQ
5819 if test "$target_linux_user" = "yes" ; then
5820 cflags="-p $cflags"
5821 ldflags="-p $ldflags"
5822 fi
5823 if test "$target_softmmu" = "yes" ; then
5824 ldflags="-p $ldflags"
25be210f 5825 echo "GPROF_CFLAGS=-p" >> $config_target_mak
d02c1db3
JQ
5826 fi
5827fi
5828
9b8e111f 5829if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
964c6fa1 5830 ldflags="$ldflags $textseg_ldflags"
fa282484 5831fi
fa282484 5832
25be210f
JQ
5833echo "LDFLAGS+=$ldflags" >> $config_target_mak
5834echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak
fa282484 5835
97a847bc 5836done # for target in $targets
7d13299d 5837
b776eca1
GH
5838if [ "$pixman" = "internal" ]; then
5839 echo "config-host.h: subdir-pixman" >> $config_host_mak
2da776db
MH
5840fi
5841
a540f158
PC
5842if [ "$dtc_internal" = "yes" ]; then
5843 echo "config-host.h: subdir-dtc" >> $config_host_mak
5844fi
5845
a99d57bb
WG
5846if test "$numa" = "yes"; then
5847 echo "CONFIG_NUMA=y" >> $config_host_mak
5848fi
5849
fd0e6053
JS
5850if test "$ccache_cpp2" = "yes"; then
5851 echo "export CCACHE_CPP2=y" >> $config_host_mak
5852fi
5853
d1807a4f 5854# build tree in object directory in case the source is not in the current directory
f93296ea 5855DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests"
2b170eff 5856DIRS="$DIRS fsdev"
9933c305 5857DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
d1807a4f 5858DIRS="$DIRS roms/seabios roms/vgabios"
2dee8d54 5859DIRS="$DIRS qapi-generated"
c09015dd
AL
5860FILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
5861FILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
aaa2ebc5 5862FILES="$FILES tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
d1807a4f 5863FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
446b9165 5864FILES="$FILES pc-bios/spapr-rtas/Makefile"
9933c305 5865FILES="$FILES pc-bios/s390-ccw/Makefile"
d1807a4f 5866FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
4652b792 5867FILES="$FILES pc-bios/qemu-icon.bmp"
753d11f2
RH
5868for bios_file in \
5869 $source_path/pc-bios/*.bin \
5acc2ec0 5870 $source_path/pc-bios/*.aml \
753d11f2
RH
5871 $source_path/pc-bios/*.rom \
5872 $source_path/pc-bios/*.dtb \
e89e33e1 5873 $source_path/pc-bios/*.img \
753d11f2 5874 $source_path/pc-bios/openbios-* \
4e73c781 5875 $source_path/pc-bios/u-boot.* \
753d11f2
RH
5876 $source_path/pc-bios/palcode-*
5877do
d1807a4f
PB
5878 FILES="$FILES pc-bios/`basename $bios_file`"
5879done
c2304b52
MA
5880for test_file in `find $source_path/tests/acpi-test-data -type f`
5881do
5882 FILES="$FILES tests/acpi-test-data`echo $test_file | sed -e 's/.*acpi-test-data//'`"
5883done
d1807a4f
PB
5884mkdir -p $DIRS
5885for f in $FILES ; do
cab00a5a 5886 if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
f9245e10
PM
5887 symlink "$source_path/$f" "$f"
5888 fi
d1807a4f 5889done
1ad2134f 5890
c34ebfdc 5891# temporary config to build submodules
2d9f27d2 5892for rom in seabios vgabios ; do
c34ebfdc 5893 config_mak=roms/$rom/config.mak
37116c89 5894 echo "# Automatically generated by configure - do not modify" > $config_mak
c34ebfdc 5895 echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
3dd46c78 5896 echo "AS=$as" >> $config_mak
c34ebfdc
AL
5897 echo "CC=$cc" >> $config_mak
5898 echo "BCC=bcc" >> $config_mak
3dd46c78 5899 echo "CPP=$cpp" >> $config_mak
c34ebfdc 5900 echo "OBJCOPY=objcopy" >> $config_mak
a31a8642 5901 echo "IASL=$iasl" >> $config_mak
c34ebfdc
AL
5902 echo "LD=$ld" >> $config_mak
5903done
5904
76c7560a
HR
5905# set up qemu-iotests in this build directory
5906iotests_common_env="tests/qemu-iotests/common.env"
5907iotests_check="tests/qemu-iotests/check"
5908
5909echo "# Automatically generated by configure - do not modify" > "$iotests_common_env"
5910echo >> "$iotests_common_env"
5911echo "export PYTHON='$python'" >> "$iotests_common_env"
5912
5913if [ ! -e "$iotests_check" ]; then
5914 symlink "$source_path/$iotests_check" "$iotests_check"
5915fi
5916
dc655404
MT
5917# Save the configure command line for later reuse.
5918cat <<EOD >config.status
5919#!/bin/sh
5920# Generated by configure.
5921# Run this file to recreate the current configuration.
5922# Compiler output produced by configure, useful for debugging
5923# configure, is in config.log if it exists.
5924EOD
5925printf "exec" >>config.status
5926printf " '%s'" "$0" "$@" >>config.status
5927echo >>config.status
5928chmod +x config.status
5929
8cd05ab6 5930rm -r "$TMPDIR1"