]> Git Repo - qemu.git/blame - configure
target/ppc: Use atomic min/max helpers
[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"
8cd05ab6 31TMPE="${TMPDIR1}/${TMPB}.exe"
6969ec6c 32TMPMO="${TMPDIR1}/${TMPB}.mo"
7d13299d 33
da1d85e3 34rm -f config.log
9ac81bbb 35
b48e3611
PM
36# Print a helpful header at the top of config.log
37echo "# QEMU configure log $(date)" >> config.log
979ae168
PM
38printf "# Configured with:" >> config.log
39printf " '%s'" "$0" "$@" >> config.log
40echo >> config.log
b48e3611
PM
41echo "#" >> config.log
42
d880a3ba
PB
43print_error() {
44 (echo
76ad07a4
PM
45 echo "ERROR: $1"
46 while test -n "$2"; do
47 echo " $2"
48 shift
49 done
d880a3ba
PB
50 echo) >&2
51}
52
53error_exit() {
54 print_error "$@"
76ad07a4
PM
55 exit 1
56}
57
9c83ffd8
PM
58do_compiler() {
59 # Run the compiler, capturing its output to the log. First argument
60 # is compiler binary to execute.
61 local compiler="$1"
62 shift
8bbe05d7
IJ
63 if test -n "$BASH_VERSION"; then eval '
64 echo >>config.log "
65funcs: ${FUNCNAME[*]}
66lines: ${BASH_LINENO[*]}"
67 '; fi
9c83ffd8
PM
68 echo $compiler "$@" >> config.log
69 $compiler "$@" >> config.log 2>&1 || return $?
8dc38a78
PM
70 # Test passed. If this is an --enable-werror build, rerun
71 # the test with -Werror and bail out if it fails. This
72 # makes warning-generating-errors in configure test code
73 # obvious to developers.
74 if test "$werror" != "yes"; then
75 return 0
76 fi
77 # Don't bother rerunning the compile if we were already using -Werror
78 case "$*" in
79 *-Werror*)
80 return 0
81 ;;
82 esac
9c83ffd8
PM
83 echo $compiler -Werror "$@" >> config.log
84 $compiler -Werror "$@" >> config.log 2>&1 && return $?
76ad07a4
PM
85 error_exit "configure test passed without -Werror but failed with -Werror." \
86 "This is probably a bug in the configure script. The failing command" \
87 "will be at the bottom of config.log." \
88 "You can run configure with --disable-werror to bypass this check."
8dc38a78
PM
89}
90
9c83ffd8
PM
91do_cc() {
92 do_compiler "$cc" "$@"
93}
94
95do_cxx() {
96 do_compiler "$cxx" "$@"
97}
98
99update_cxxflags() {
100 # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
101 # options which some versions of GCC's C++ compiler complain about
102 # because they only make sense for C programs.
11cde1c8
BD
103 QEMU_CXXFLAGS="$QEMU_CXXFLAGS -D__STDC_LIMIT_MACROS"
104
9c83ffd8
PM
105 for arg in $QEMU_CFLAGS; do
106 case $arg in
107 -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
108 -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
109 ;;
110 *)
111 QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
112 ;;
113 esac
114 done
115}
116
52166aa0 117compile_object() {
fd0e6053
JS
118 local_cflags="$1"
119 do_cc $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
52166aa0
JQ
120}
121
122compile_prog() {
123 local_cflags="$1"
124 local_ldflags="$2"
8dc38a78 125 do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
52166aa0
JQ
126}
127
11568d6d
PB
128# symbolically link $1 to $2. Portable version of "ln -sf".
129symlink() {
72b8b5a1 130 rm -rf "$2"
ec5b06d7 131 mkdir -p "$(dirname "$2")"
72b8b5a1 132 ln -s "$1" "$2"
11568d6d
PB
133}
134
0dba6195
LM
135# check whether a command is available to this shell (may be either an
136# executable or a builtin)
137has() {
138 type "$1" >/dev/null 2>&1
139}
140
141# search for an executable in PATH
142path_of() {
143 local_command="$1"
144 local_ifs="$IFS"
145 local_dir=""
146
147 # pathname has a dir component?
148 if [ "${local_command#*/}" != "$local_command" ]; then
149 if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
150 echo "$local_command"
151 return 0
152 fi
153 fi
154 if [ -z "$local_command" ]; then
155 return 1
156 fi
157
158 IFS=:
159 for local_dir in $PATH; do
160 if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
161 echo "$local_dir/$local_command"
162 IFS="${local_ifs:-$(printf ' \t\n')}"
163 return 0
164 fi
165 done
166 # not found
167 IFS="${local_ifs:-$(printf ' \t\n')}"
168 return 1
169}
170
5b808275
LV
171have_backend () {
172 echo "$trace_backends" | grep "$1" >/dev/null
173}
174
3b6b7550
PB
175glob() {
176 eval test -z '"${1#'"$2"'}"'
177}
178
179supported_hax_target() {
180 test "$hax" = "yes" || return 1
181 glob "$1" "*-softmmu" || return 1
182 case "${1%-softmmu}" in
183 i386|x86_64)
184 return 0
185 ;;
186 esac
187 return 1
188}
189
190supported_kvm_target() {
191 test "$kvm" = "yes" || return 1
192 glob "$1" "*-softmmu" || return 1
193 case "${1%-softmmu}:$cpu" in
194 arm:arm | aarch64:aarch64 | \
195 i386:i386 | i386:x86_64 | i386:x32 | \
196 x86_64:i386 | x86_64:x86_64 | x86_64:x32 | \
197 mips:mips | mipsel:mips | \
198 ppc:ppc | ppcemb:ppc | ppc64:ppc | \
199 ppc:ppc64 | ppcemb:ppc64 | ppc64:ppc64 | \
200 s390x:s390x)
201 return 0
202 ;;
203 esac
204 return 1
205}
206
207supported_xen_target() {
208 test "$xen" = "yes" || return 1
209 glob "$1" "*-softmmu" || return 1
b5ed2e11
PB
210 # Only i386 and x86_64 provide the xenpv machine.
211 case "${1%-softmmu}" in
212 i386|x86_64)
3b6b7550
PB
213 return 0
214 ;;
215 esac
216 return 1
217}
218
c97d6d2c
SAGDR
219supported_hvf_target() {
220 test "$hvf" = "yes" || return 1
221 glob "$1" "*-softmmu" || return 1
222 case "${1%-softmmu}" in
223 x86_64)
224 return 0
225 ;;
226 esac
227 return 1
228}
229
d661d9a4
JTV
230supported_whpx_target() {
231 test "$whpx" = "yes" || return 1
232 glob "$1" "*-softmmu" || return 1
233 case "${1%-softmmu}" in
234 i386|x86_64)
235 return 0
236 ;;
237 esac
238 return 1
239}
240
d880a3ba
PB
241supported_target() {
242 case "$1" in
243 *-softmmu)
244 ;;
245 *-linux-user)
246 if test "$linux" != "yes"; then
247 print_error "Target '$target' is only available on a Linux host"
248 return 1
249 fi
250 ;;
251 *-bsd-user)
252 if test "$bsd" != "yes"; then
253 print_error "Target '$target' is only available on a BSD host"
254 return 1
255 fi
256 ;;
257 *)
258 print_error "Invalid target name '$target'"
259 return 1
260 ;;
261 esac
b3f6ea7e
PB
262 test "$tcg" = "yes" && return 0
263 supported_kvm_target "$1" && return 0
264 supported_xen_target "$1" && return 0
265 supported_hax_target "$1" && return 0
c97d6d2c 266 supported_hvf_target "$1" && return 0
d661d9a4 267 supported_whpx_target "$1" && return 0
b3f6ea7e
PB
268 print_error "TCG disabled, but hardware accelerator not available for '$target'"
269 return 1
d880a3ba
PB
270}
271
e9a3591f
CB
272
273ld_has() {
274 $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
275}
276
7d13299d 277# default parameters
89138857 278source_path=$(dirname "$0")
2ff6b91e 279cpu=""
a31a8642 280iasl="iasl"
1e43adfc 281interp_prefix="/usr/gnemul/qemu-%M"
43ce4dfe 282static="no"
7d13299d 283cross_prefix=""
0c58ac1c 284audio_drv_list=""
b64ec4e4
FZ
285block_drv_rw_whitelist=""
286block_drv_ro_whitelist=""
e49d021e 287host_cc="cc"
73da375e 288libs_softmmu=""
3e2e0e6b 289libs_tools=""
67f86e8e 290audio_pt_int=""
d5631638 291audio_win_int=""
957f1f99 292libs_qga=""
5bc62e01 293debug_info="yes"
63678e17 294stack_protector=""
ac0df51d 295
92712822
DB
296if test -e "$source_path/.git"
297then
f62bbee5 298 git_update=yes
92712822
DB
299 git_submodules="ui/keycodemapdb"
300else
f62bbee5 301 git_update=no
92712822
DB
302 git_submodules=""
303fi
cc84d63a 304git="git"
ac0df51d 305
afb63ebd
SW
306# Don't accept a target_list environment variable.
307unset target_list
377529c0
PB
308
309# Default value for a variable defining feature "foo".
310# * foo="no" feature will only be used if --enable-foo arg is given
311# * foo="" feature will be searched for, and if found, will be used
312# unless --disable-foo is given
313# * foo="yes" this value will only be set by --enable-foo flag.
314# feature will searched for,
315# if not found, configure exits with error
316#
317# Always add --enable-foo and --disable-foo command line args.
318# Distributions want to ensure that several features are compiled in, and it
319# is impossible without a --enable-foo that exits if a feature is not found.
320
321bluez=""
322brlapi=""
323curl=""
324curses=""
325docs=""
326fdt=""
58952137 327netmap="no"
377529c0 328sdl=""
ee8466d0 329sdlabi=""
983eef5a 330virtfs=""
fe8fc5ae 331mpath=""
821601ea 332vnc="yes"
377529c0 333sparse="no"
377529c0 334vde=""
377529c0
PB
335vnc_sasl=""
336vnc_jpeg=""
337vnc_png=""
6a021536 338xkbcommon=""
377529c0 339xen=""
d5b93ddf 340xen_ctrl_version=""
64a7ad6f 341xen_pv_domain_build="no"
eb6fda0f 342xen_pci_passthrough=""
377529c0 343linux_aio=""
47e98658 344cap_ng=""
377529c0 345attr=""
4f26f2b6 346libattr=""
377529c0 347xfs=""
b3f6ea7e 348tcg="yes"
a40161cb 349membarrier=""
d41a75a2 350vhost_net="no"
042cea27 351vhost_crypto="no"
5e9be92d 352vhost_scsi="no"
fc0b9b0e 353vhost_vsock="no"
e6a74868 354vhost_user=""
d41a75a2 355kvm="no"
b0cb0a66 356hax="no"
c97d6d2c 357hvf="no"
d661d9a4 358whpx="no"
2da776db 359rdma=""
377529c0
PB
360gprof="no"
361debug_tcg="no"
377529c0 362debug="no"
247724cb 363sanitizers="no"
b553a042 364fortify_source=""
377529c0 365strip_opt="yes"
9195b2c2 366tcg_interpreter="no"
377529c0
PB
367bigendian="no"
368mingw32="no"
1d728c39
BS
369gcov="no"
370gcov_tool="gcov"
377529c0 371EXESUF=""
17969268
FZ
372DSOSUF=".so"
373LDFLAGS_SHARED="-shared"
374modules="no"
377529c0
PB
375prefix="/usr/local"
376mandir="\${prefix}/share/man"
528ae5b8 377datadir="\${prefix}/share"
3d5eecab 378firmwarepath="\${prefix}/share/qemu-firmware"
850da188 379qemu_docdir="\${prefix}/share/doc/qemu"
377529c0 380bindir="\${prefix}/bin"
3aa5d2be 381libdir="\${prefix}/lib"
8bf188aa 382libexecdir="\${prefix}/libexec"
0f94d6da 383includedir="\${prefix}/include"
377529c0 384sysconfdir="\${prefix}/etc"
785c23ae 385local_statedir="\${prefix}/var"
377529c0
PB
386confsuffix="/qemu"
387slirp="yes"
377529c0
PB
388oss_lib=""
389bsd="no"
390linux="no"
391solaris="no"
392profiler="no"
393cocoa="no"
394softmmu="yes"
395linux_user="no"
377529c0 396bsd_user="no"
377529c0
PB
397blobs="yes"
398pkgversion=""
40d6444e 399pie=""
3556c233 400qom_cast_debug="yes"
baf86d6b 401trace_backends="log"
377529c0
PB
402trace_file="trace"
403spice=""
404rbd=""
7b02f544 405smartcard=""
2b2325ff 406libusb=""
69354a83 407usb_redir=""
da076ffe 408opengl=""
014cb152 409opengl_dmabuf="no"
5dd89908 410cpuid_h="no"
99f2dbd3 411avx2_opt="no"
1ece9905 412zlib="yes"
8ca80760 413capstone=""
b25c9dff
SW
414lzo=""
415snappy=""
6b383c08 416bzip2=""
e8ef31a3 417guest_agent=""
d9840e25 418guest_agent_with_vss="no"
50cbebb9 419guest_agent_ntddscsi="no"
9dacf32d 420guest_agent_msi=""
d9840e25
TS
421vss_win32_sdk=""
422win_sdk="no"
4b1c11fd 423want_tools="yes"
c589b249 424libiscsi=""
6542aa9c 425libnfs=""
519175a2 426coroutine=""
70c60c08 427coroutine_pool=""
7d992e4d 428debug_stack_usage="no"
f0d92b56 429crypto_afalg="no"
f794573e 430seccomp=""
eb100396 431glusterfs=""
d85fa9eb 432glusterfs_xlator_opt="no"
0c14fb47 433glusterfs_discard="no"
df3a429a 434glusterfs_fallocate="no"
7c815372 435glusterfs_zerofill="no"
a4ccabcf 436gtk=""
9e04c683 437gtkabi=""
925a0400 438gtk_gl="no"
a1c5e949 439tls_priority="NORMAL"
ddbb0d09 440gnutls=""
b917da4c 441gnutls_rnd=""
91bfcdb0 442nettle=""
fff2f982 443nettle_kdf="no"
91bfcdb0 444gcrypt=""
1f923c70 445gcrypt_hmac="no"
37788f25 446gcrypt_kdf="no"
bbbf9bfb 447vte=""
9d9e1521 448virglrenderer=""
e91c793c 449tpm="yes"
0a12ec87 450libssh2=""
ed1701c6 451live_block_migration="yes"
a99d57bb 452numa=""
2847b469 453tcmalloc="no"
7b01cb97 454jemalloc="no"
a6b1d4c0 455replication="yes"
da92c3ff 456vxhs=""
ed279a06 457libxml2=""
51a12b51 458docker="no"
ba59fb77 459debug_mutex="no"
377529c0 460
d75402b5
AB
461# cross compilers defaults, can be overridden with --cross-cc-ARCH
462cross_cc_aarch64="aarch64-linux-gnu-gcc"
d422b2bc
AB
463cross_cc_aarch64_be="$cross_cc_aarch64"
464cross_cc_cflags_aarch64_be="-mbig-endian"
d75402b5 465cross_cc_arm="arm-linux-gnueabihf-gcc"
d422b2bc 466cross_cc_cflags_armeb="-mbig-endian"
716a507c
AB
467cross_cc_i386="i386-pc-linux-gnu-gcc"
468cross_cc_cflags_i386=""
d75402b5 469cross_cc_powerpc="powerpc-linux-gnu-gcc"
d422b2bc 470cross_cc_powerpc="powerpc-linux-gnu-gcc"
d75402b5
AB
471
472enabled_cross_compilers=""
473
898be3e0
PM
474supported_cpu="no"
475supported_os="no"
fb59dabd 476bogus_os="no"
5a22ab71 477malloc_trim=""
898be3e0 478
ac0df51d
AL
479# parse CC options first
480for opt do
89138857 481 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
ac0df51d
AL
482 case "$opt" in
483 --cross-prefix=*) cross_prefix="$optarg"
484 ;;
3d8df640 485 --cc=*) CC="$optarg"
ac0df51d 486 ;;
83f73fce
TS
487 --cxx=*) CXX="$optarg"
488 ;;
ca4deeb1
PB
489 --source-path=*) source_path="$optarg"
490 ;;
2ff6b91e
JQ
491 --cpu=*) cpu="$optarg"
492 ;;
de385287 493 --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
e2a2ed06 494 ;;
11cde1c8 495 --extra-cxxflags=*) QEMU_CXXFLAGS="$QEMU_CXXFLAGS $optarg"
11cde1c8 496 ;;
a4969e90 497 --extra-ldflags=*) LDFLAGS="$LDFLAGS $optarg"
f9943cd5 498 EXTRA_LDFLAGS="$optarg"
e2a2ed06 499 ;;
5bc62e01
GH
500 --enable-debug-info) debug_info="yes"
501 ;;
502 --disable-debug-info) debug_info="no"
503 ;;
d75402b5
AB
504 --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
505 ;;
d422b2bc
AB
506 --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-flags-}; cc_arch=${cc_arch%%=*}
507 eval "cross_cc_cflags_${cc_arch}=\$optarg"
508 ;;
d75402b5
AB
509 --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
510 eval "cross_cc_${cc_arch}=\$optarg"
511 ;;
ac0df51d
AL
512 esac
513done
ac0df51d
AL
514# OS specific
515# Using uname is really, really broken. Once we have the right set of checks
93148aa5 516# we can eliminate its usage altogether.
ac0df51d 517
e49d021e
PM
518# Preferred compiler:
519# ${CC} (if set)
520# ${cross_prefix}gcc (if cross-prefix specified)
521# system compiler
522if test -z "${CC}${cross_prefix}"; then
523 cc="$host_cc"
524else
525 cc="${CC-${cross_prefix}gcc}"
526fi
527
83f73fce
TS
528if test -z "${CXX}${cross_prefix}"; then
529 cxx="c++"
530else
531 cxx="${CXX-${cross_prefix}g++}"
532fi
533
b3198cc2 534ar="${AR-${cross_prefix}ar}"
cdbd727c 535as="${AS-${cross_prefix}as}"
5f6f0e27 536ccas="${CCAS-$cc}"
3dd46c78 537cpp="${CPP-$cc -E}"
b3198cc2
SY
538objcopy="${OBJCOPY-${cross_prefix}objcopy}"
539ld="${LD-${cross_prefix}ld}"
9f81aeb5 540ranlib="${RANLIB-${cross_prefix}ranlib}"
4852ee95 541nm="${NM-${cross_prefix}nm}"
b3198cc2
SY
542strip="${STRIP-${cross_prefix}strip}"
543windres="${WINDRES-${cross_prefix}windres}"
17884d7b
ST
544pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
545query_pkg_config() {
546 "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
547}
548pkg_config=query_pkg_config
b3198cc2 549sdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
47c03744 550sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
ac0df51d 551
45d285ab
PM
552# If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
553ARFLAGS="${ARFLAGS-rv}"
554
be17dc90 555# default flags for all hosts
2d31515b
PM
556# We use -fwrapv to tell the compiler that we require a C dialect where
557# left shift of signed integers is well defined and has the expected
558# 2s-complement style results. (Both clang and gcc agree that it
559# provides these semantics.)
560QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
f9188227 561QEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
c95e3080 562QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
be17dc90 563QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
9edc19c9 564QEMU_INCLUDES="-iquote . -iquote \$(SRC_PATH) -iquote \$(SRC_PATH)/accel/tcg -iquote \$(SRC_PATH)/include"
5bc62e01
GH
565if test "$debug_info" = "yes"; then
566 CFLAGS="-g $CFLAGS"
567 LDFLAGS="-g $LDFLAGS"
568fi
be17dc90 569
ca4deeb1 570# make source path absolute
89138857 571source_path=$(cd "$source_path"; pwd)
ca4deeb1 572
cab00a5a
MT
573# running configure in the source tree?
574# we know that's the case if configure is there.
575if test -f "./configure"; then
576 pwd_is_source_path="y"
577else
578 pwd_is_source_path="n"
579fi
580
ac0df51d
AL
581check_define() {
582cat > $TMPC <<EOF
583#if !defined($1)
fd786e1a 584#error $1 not defined
ac0df51d
AL
585#endif
586int main(void) { return 0; }
587EOF
52166aa0 588 compile_object
ac0df51d
AL
589}
590
307119e7
GH
591check_include() {
592cat > $TMPC <<EOF
593#include <$1>
594int main(void) { return 0; }
595EOF
596 compile_object
597}
598
93b25869
JS
599write_c_skeleton() {
600 cat > $TMPC <<EOF
601int main(void) { return 0; }
602EOF
603}
604
bbea4050
PM
605if check_define __linux__ ; then
606 targetos="Linux"
607elif check_define _WIN32 ; then
608 targetos='MINGW32'
609elif check_define __OpenBSD__ ; then
610 targetos='OpenBSD'
611elif check_define __sun__ ; then
612 targetos='SunOS'
613elif check_define __HAIKU__ ; then
614 targetos='Haiku'
951fedfc
PM
615elif check_define __FreeBSD__ ; then
616 targetos='FreeBSD'
617elif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
618 targetos='GNU/kFreeBSD'
619elif check_define __DragonFly__ ; then
620 targetos='DragonFly'
621elif check_define __NetBSD__; then
622 targetos='NetBSD'
623elif check_define __APPLE__; then
624 targetos='Darwin'
bbea4050 625else
951fedfc
PM
626 # This is a fatal error, but don't report it yet, because we
627 # might be going to just print the --help text, or it might
628 # be the result of a missing compiler.
629 targetos='bogus'
630 bogus_os='yes'
bbea4050
PM
631fi
632
633# Some host OSes need non-standard checks for which CPU to use.
634# Note that these checks are broken for cross-compilation: if you're
635# cross-compiling to one of these OSes then you'll need to specify
636# the correct CPU with the --cpu option.
637case $targetos in
638Darwin)
639 # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
640 # run 64-bit userspace code.
641 # If the user didn't specify a CPU explicitly and the kernel says this is
642 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
643 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
644 cpu="x86_64"
645 fi
646 ;;
647SunOS)
89138857 648 # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
bbea4050
PM
649 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
650 cpu="x86_64"
651 fi
652esac
653
2ff6b91e
JQ
654if test ! -z "$cpu" ; then
655 # command line argument
656 :
657elif check_define __i386__ ; then
ac0df51d
AL
658 cpu="i386"
659elif check_define __x86_64__ ; then
c72b26ec
RH
660 if check_define __ILP32__ ; then
661 cpu="x32"
662 else
663 cpu="x86_64"
664 fi
3aa9bd6c 665elif check_define __sparc__ ; then
3aa9bd6c
BS
666 if check_define __arch64__ ; then
667 cpu="sparc64"
668 else
669 cpu="sparc"
670 fi
fdf7ed96 671elif check_define _ARCH_PPC ; then
672 if check_define _ARCH_PPC64 ; then
673 cpu="ppc64"
674 else
675 cpu="ppc"
676 fi
afa05235
AJ
677elif check_define __mips__ ; then
678 cpu="mips"
d66ed0ea
AJ
679elif check_define __s390__ ; then
680 if check_define __s390x__ ; then
681 cpu="s390x"
682 else
683 cpu="s390"
684 fi
21d89f84
PM
685elif check_define __arm__ ; then
686 cpu="arm"
1f080313
CF
687elif check_define __aarch64__ ; then
688 cpu="aarch64"
ac0df51d 689else
89138857 690 cpu=$(uname -m)
ac0df51d
AL
691fi
692
359bc95d
PM
693ARCH=
694# Normalise host CPU name and set ARCH.
695# Note that this case should only have supported host CPUs, not guests.
7d13299d 696case "$cpu" in
6499fd15 697 ppc|ppc64|s390|s390x|sparc64|x32)
898be3e0
PM
698 cpu="$cpu"
699 supported_cpu="yes"
d75402b5 700 eval "cross_cc_${cpu}=\$host_cc"
898be3e0 701 ;;
7d13299d 702 i386|i486|i586|i686|i86pc|BePC)
97a847bc 703 cpu="i386"
898be3e0 704 supported_cpu="yes"
d75402b5 705 cross_cc_i386=$host_cc
7d13299d 706 ;;
aaa5fa14
AJ
707 x86_64|amd64)
708 cpu="x86_64"
898be3e0 709 supported_cpu="yes"
d75402b5 710 cross_cc_x86_64=$host_cc
aaa5fa14 711 ;;
21d89f84
PM
712 armv*b|armv*l|arm)
713 cpu="arm"
898be3e0 714 supported_cpu="yes"
d75402b5 715 cross_cc_arm=$host_cc
7d13299d 716 ;;
1f080313
CF
717 aarch64)
718 cpu="aarch64"
898be3e0 719 supported_cpu="yes"
d75402b5 720 cross_cc_aarch64=$host_cc
1f080313 721 ;;
afa05235
AJ
722 mips*)
723 cpu="mips"
898be3e0 724 supported_cpu="yes"
d75402b5 725 cross_cc_mips=$host_cc
afa05235 726 ;;
3142255c 727 sparc|sun4[cdmuv])
ae228531 728 cpu="sparc"
6499fd15 729 supported_cpu="yes"
d75402b5 730 cross_cc_sparc=$host_cc
ae228531 731 ;;
7d13299d 732 *)
359bc95d
PM
733 # This will result in either an error or falling back to TCI later
734 ARCH=unknown
7d13299d
FB
735 ;;
736esac
359bc95d
PM
737if test -z "$ARCH"; then
738 ARCH="$cpu"
739fi
e2d52ad3 740
7d13299d 741# OS specific
0dbfc675 742
adfc3e91
SS
743# host *BSD for user mode
744HOST_VARIANT_DIR=""
745
7d13299d 746case $targetos in
67b915a5 747MINGW32*)
0dbfc675 748 mingw32="yes"
b0cb0a66 749 hax="yes"
3cec7cc2 750 audio_possible_drivers="dsound sdl"
307119e7
GH
751 if check_include dsound.h; then
752 audio_drv_list="dsound"
753 else
754 audio_drv_list=""
755 fi
898be3e0 756 supported_os="yes"
67b915a5 757;;
5c40d2bd 758GNU/kFreeBSD)
a167ba50 759 bsd="yes"
0dbfc675 760 audio_drv_list="oss"
0bac1111 761 audio_possible_drivers="oss sdl pa"
5c40d2bd 762;;
7d3505c5 763FreeBSD)
0dbfc675 764 bsd="yes"
0db4a067 765 make="${MAKE-gmake}"
0dbfc675 766 audio_drv_list="oss"
0bac1111 767 audio_possible_drivers="oss sdl pa"
f01576f1
JL
768 # needed for kinfo_getvmmap(3) in libutil.h
769 LIBS="-lutil $LIBS"
a7764f15
EM
770 # needed for kinfo_getproc
771 libs_qga="-lutil $libs_qga"
58952137 772 netmap="" # enable netmap autodetect
adfc3e91 773 HOST_VARIANT_DIR="freebsd"
898be3e0 774 supported_os="yes"
7d3505c5 775;;
c5e97233 776DragonFly)
0dbfc675 777 bsd="yes"
0db4a067 778 make="${MAKE-gmake}"
0dbfc675 779 audio_drv_list="oss"
0bac1111 780 audio_possible_drivers="oss sdl pa"
adfc3e91 781 HOST_VARIANT_DIR="dragonfly"
c5e97233 782;;
7d3505c5 783NetBSD)
0dbfc675 784 bsd="yes"
0db4a067 785 make="${MAKE-gmake}"
0dbfc675 786 audio_drv_list="oss"
0bac1111 787 audio_possible_drivers="oss sdl"
0dbfc675 788 oss_lib="-lossaudio"
adfc3e91 789 HOST_VARIANT_DIR="netbsd"
3c2bdbc1 790 supported_os="yes"
7d3505c5
FB
791;;
792OpenBSD)
0dbfc675 793 bsd="yes"
0db4a067 794 make="${MAKE-gmake}"
4f6ab397 795 audio_drv_list="sdl"
0bac1111 796 audio_possible_drivers="sdl"
adfc3e91 797 HOST_VARIANT_DIR="openbsd"
0a773d55 798 supported_os="yes"
7d3505c5 799;;
83fb7adf 800Darwin)
0dbfc675
JQ
801 bsd="yes"
802 darwin="yes"
b0cb0a66 803 hax="yes"
c97d6d2c 804 hvf="yes"
17969268 805 LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
0dbfc675 806 if [ "$cpu" = "x86_64" ] ; then
a558ee17 807 QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
0c439cbf 808 LDFLAGS="-arch x86_64 $LDFLAGS"
0dbfc675 809 fi
0dbfc675
JQ
810 cocoa="yes"
811 audio_drv_list="coreaudio"
14382605 812 audio_possible_drivers="coreaudio sdl"
0dbfc675 813 LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
7973f21c 814 libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
a0b7cf6b
PM
815 # Disable attempts to use ObjectiveC features in os/object.h since they
816 # won't work when we're compiling with gcc as a C compiler.
817 QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
adfc3e91 818 HOST_VARIANT_DIR="darwin"
898be3e0 819 supported_os="yes"
83fb7adf 820;;
ec530c81 821SunOS)
0dbfc675 822 solaris="yes"
0db4a067
PB
823 make="${MAKE-gmake}"
824 install="${INSTALL-ginstall}"
e2d8830e 825 smbd="${SMBD-/usr/sfw/sbin/smbd}"
0dbfc675
JQ
826 if test -f /usr/include/sys/soundcard.h ; then
827 audio_drv_list="oss"
828 fi
829 audio_possible_drivers="oss sdl"
d741429a
BS
830# needed for CMSG_ macros in sys/socket.h
831 QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
832# needed for TIOCWIN* defines in termios.h
833 QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
a558ee17 834 QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
560d375f
AF
835 solarisnetlibs="-lsocket -lnsl -lresolv"
836 LIBS="$solarisnetlibs $LIBS"
837 libs_qga="$solarisnetlibs $libs_qga"
86b2bd93 838;;
179cf400
AF
839Haiku)
840 haiku="yes"
841 QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
842 LIBS="-lposix_error_mapper -lnetwork $LIBS"
843;;
898be3e0 844Linux)
0dbfc675 845 audio_drv_list="oss"
0bac1111 846 audio_possible_drivers="oss alsa sdl pa"
0dbfc675
JQ
847 linux="yes"
848 linux_user="yes"
af2be207
JK
849 kvm="yes"
850 vhost_net="yes"
042cea27 851 vhost_crypto="yes"
5e9be92d 852 vhost_scsi="yes"
fc0b9b0e 853 vhost_vsock="yes"
a585140d 854 QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
898be3e0
PM
855 supported_os="yes"
856;;
7d13299d
FB
857esac
858
7d3505c5 859if [ "$bsd" = "yes" ] ; then
b1a550a0 860 if [ "$darwin" != "yes" ] ; then
08de3949 861 bsd_user="yes"
83fb7adf 862 fi
7d3505c5
FB
863fi
864
0db4a067
PB
865: ${make=${MAKE-make}}
866: ${install=${INSTALL-install}}
52510f8b 867: ${python=${PYTHON-python}}
e2d8830e 868: ${smbd=${SMBD-/usr/sbin/smbd}}
0db4a067 869
3c4a4d0d
PM
870# Default objcc to clang if available, otherwise use CC
871if has clang; then
872 objcc=clang
873else
874 objcc="$cc"
875fi
876
3457a3f8 877if test "$mingw32" = "yes" ; then
3457a3f8 878 EXESUF=".exe"
17969268 879 DSOSUF=".dll"
a558ee17 880 QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
e94a7936
SW
881 # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
882 QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
78e9d4ad
SW
883 # MinGW needs -mthreads for TLS and macro _MT.
884 QEMU_CFLAGS="-mthreads $QEMU_CFLAGS"
f7cf5d5b 885 LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
93b25869 886 write_c_skeleton;
f7cf5d5b
SW
887 if compile_prog "" "-liberty" ; then
888 LIBS="-liberty $LIBS"
889 fi
c5ec15ea 890 prefix="c:/Program Files/QEMU"
683035de 891 mandir="\${prefix}"
528ae5b8 892 datadir="\${prefix}"
850da188 893 qemu_docdir="\${prefix}"
683035de
PB
894 bindir="\${prefix}"
895 sysconfdir="\${prefix}"
5a699bbb 896 local_statedir=
683035de 897 confsuffix=""
105fad6b 898 libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
3457a3f8
JQ
899fi
900
487fefdb 901werror=""
85aa5189 902
7d13299d 903for opt do
89138857 904 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
7d13299d 905 case "$opt" in
2efc3265
FB
906 --help|-h) show_help=yes
907 ;;
99123e13
MF
908 --version|-V) exec cat $source_path/VERSION
909 ;;
b1a550a0 910 --prefix=*) prefix="$optarg"
7d13299d 911 ;;
b1a550a0 912 --interp-prefix=*) interp_prefix="$optarg"
32ce6337 913 ;;
ca4deeb1 914 --source-path=*)
7d13299d 915 ;;
ac0df51d 916 --cross-prefix=*)
7d13299d 917 ;;
ac0df51d 918 --cc=*)
7d13299d 919 ;;
b1a550a0 920 --host-cc=*) host_cc="$optarg"
83469015 921 ;;
83f73fce
TS
922 --cxx=*)
923 ;;
e007dbec
MT
924 --iasl=*) iasl="$optarg"
925 ;;
3c4a4d0d
PM
926 --objcc=*) objcc="$optarg"
927 ;;
b1a550a0 928 --make=*) make="$optarg"
7d13299d 929 ;;
6a882643
PB
930 --install=*) install="$optarg"
931 ;;
c886edfb
BS
932 --python=*) python="$optarg"
933 ;;
1d728c39
BS
934 --gcov=*) gcov_tool="$optarg"
935 ;;
e2d8830e
BS
936 --smbd=*) smbd="$optarg"
937 ;;
e2a2ed06 938 --extra-cflags=*)
7d13299d 939 ;;
11cde1c8
BD
940 --extra-cxxflags=*)
941 ;;
e2a2ed06 942 --extra-ldflags=*)
7d13299d 943 ;;
5bc62e01
GH
944 --enable-debug-info)
945 ;;
946 --disable-debug-info)
947 ;;
d75402b5
AB
948 --cross-cc-*)
949 ;;
17969268
FZ
950 --enable-modules)
951 modules="yes"
3aa88b31
SH
952 ;;
953 --disable-modules)
954 modules="no"
17969268 955 ;;
2ff6b91e 956 --cpu=*)
7d13299d 957 ;;
b1a550a0 958 --target-list=*) target_list="$optarg"
de83cd02 959 ;;
5b808275
LV
960 --enable-trace-backends=*) trace_backends="$optarg"
961 ;;
962 # XXX: backwards compatibility
963 --enable-trace-backend=*) trace_backends="$optarg"
94a420b1 964 ;;
74242e0f 965 --with-trace-file=*) trace_file="$optarg"
9410b56c 966 ;;
7d13299d
FB
967 --enable-gprof) gprof="yes"
968 ;;
1d728c39
BS
969 --enable-gcov) gcov="yes"
970 ;;
79427693
LM
971 --static)
972 static="yes"
973 LDFLAGS="-static $LDFLAGS"
17884d7b 974 QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
43ce4dfe 975 ;;
0b24e75f
PB
976 --mandir=*) mandir="$optarg"
977 ;;
978 --bindir=*) bindir="$optarg"
979 ;;
3aa5d2be
AL
980 --libdir=*) libdir="$optarg"
981 ;;
8bf188aa
MT
982 --libexecdir=*) libexecdir="$optarg"
983 ;;
0f94d6da
AL
984 --includedir=*) includedir="$optarg"
985 ;;
528ae5b8 986 --datadir=*) datadir="$optarg"
0b24e75f 987 ;;
023d3d67
EH
988 --with-confsuffix=*) confsuffix="$optarg"
989 ;;
850da188 990 --docdir=*) qemu_docdir="$optarg"
0b24e75f 991 ;;
ca2fb938 992 --sysconfdir=*) sysconfdir="$optarg"
07381cc1 993 ;;
785c23ae
LC
994 --localstatedir=*) local_statedir="$optarg"
995 ;;
3d5eecab
GH
996 --firmwarepath=*) firmwarepath="$optarg"
997 ;;
181ce1d0
OH
998 --host=*|--build=*|\
999 --disable-dependency-tracking|\
785c23ae 1000 --sbindir=*|--sharedstatedir=*|\
023ddd74
MF
1001 --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
1002 --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
1003 # These switches are silently ignored, for compatibility with
1004 # autoconf-generated configure scripts. This allows QEMU's
1005 # configure to be used by RPM and similar macros that set
1006 # lots of directory switches by default.
1007 ;;
97a847bc
FB
1008 --disable-sdl) sdl="no"
1009 ;;
c4198157
JQ
1010 --enable-sdl) sdl="yes"
1011 ;;
47c03744
DA
1012 --with-sdlabi=*) sdlabi="$optarg"
1013 ;;
3556c233
PB
1014 --disable-qom-cast-debug) qom_cast_debug="no"
1015 ;;
1016 --enable-qom-cast-debug) qom_cast_debug="yes"
1017 ;;
983eef5a
MI
1018 --disable-virtfs) virtfs="no"
1019 ;;
1020 --enable-virtfs) virtfs="yes"
1021 ;;
fe8fc5ae
PB
1022 --disable-mpath) mpath="no"
1023 ;;
1024 --enable-mpath) mpath="yes"
1025 ;;
821601ea
JS
1026 --disable-vnc) vnc="no"
1027 ;;
1028 --enable-vnc) vnc="yes"
1029 ;;
2f6a1ab0
BS
1030 --oss-lib=*) oss_lib="$optarg"
1031 ;;
0c58ac1c 1032 --audio-drv-list=*) audio_drv_list="$optarg"
102a52e4 1033 ;;
89138857 1034 --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
b64ec4e4 1035 ;;
89138857 1036 --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
eb852011 1037 ;;
f8393946
AJ
1038 --enable-debug-tcg) debug_tcg="yes"
1039 ;;
1040 --disable-debug-tcg) debug_tcg="no"
1041 ;;
f3d08ee6
PB
1042 --enable-debug)
1043 # Enable debugging options that aren't excessively noisy
1044 debug_tcg="yes"
1fcc6d42 1045 debug_mutex="yes"
f3d08ee6
PB
1046 debug="yes"
1047 strip_opt="no"
b553a042 1048 fortify_source="no"
f3d08ee6 1049 ;;
247724cb
MAL
1050 --enable-sanitizers) sanitizers="yes"
1051 ;;
1052 --disable-sanitizers) sanitizers="no"
1053 ;;
03b4fe7d
AL
1054 --enable-sparse) sparse="yes"
1055 ;;
1056 --disable-sparse) sparse="no"
1057 ;;
1625af87
AL
1058 --disable-strip) strip_opt="no"
1059 ;;
2f9606b3
AL
1060 --disable-vnc-sasl) vnc_sasl="no"
1061 ;;
ea784e3b
JQ
1062 --enable-vnc-sasl) vnc_sasl="yes"
1063 ;;
2f6f5c7a
CC
1064 --disable-vnc-jpeg) vnc_jpeg="no"
1065 ;;
1066 --enable-vnc-jpeg) vnc_jpeg="yes"
1067 ;;
efe556ad
CC
1068 --disable-vnc-png) vnc_png="no"
1069 ;;
1070 --enable-vnc-png) vnc_png="yes"
1071 ;;
443f1376 1072 --disable-slirp) slirp="no"
1d14ffa9 1073 ;;
e0e6c8c0 1074 --disable-vde) vde="no"
8a16d273 1075 ;;
dfb278bd
JQ
1076 --enable-vde) vde="yes"
1077 ;;
58952137
VM
1078 --disable-netmap) netmap="no"
1079 ;;
1080 --enable-netmap) netmap="yes"
1081 ;;
e37630ca
AL
1082 --disable-xen) xen="no"
1083 ;;
fc321b4b
JQ
1084 --enable-xen) xen="yes"
1085 ;;
eb6fda0f
AP
1086 --disable-xen-pci-passthrough) xen_pci_passthrough="no"
1087 ;;
1088 --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
1089 ;;
64a7ad6f
IC
1090 --disable-xen-pv-domain-build) xen_pv_domain_build="no"
1091 ;;
1092 --enable-xen-pv-domain-build) xen_pv_domain_build="yes"
1093 ;;
2e4d9fb1
AJ
1094 --disable-brlapi) brlapi="no"
1095 ;;
4ffcedb6
JQ
1096 --enable-brlapi) brlapi="yes"
1097 ;;
fb599c9a
AZ
1098 --disable-bluez) bluez="no"
1099 ;;
a20a6f46
JQ
1100 --enable-bluez) bluez="yes"
1101 ;;
7ba1e619
AL
1102 --disable-kvm) kvm="no"
1103 ;;
b31a0277
JQ
1104 --enable-kvm) kvm="yes"
1105 ;;
b0cb0a66 1106 --disable-hax) hax="no"
180fb750 1107 ;;
b0cb0a66 1108 --enable-hax) hax="yes"
180fb750 1109 ;;
c97d6d2c
SAGDR
1110 --disable-hvf) hvf="no"
1111 ;;
1112 --enable-hvf) hvf="yes"
1113 ;;
d661d9a4
JTV
1114 --disable-whpx) whpx="no"
1115 ;;
1116 --enable-whpx) whpx="yes"
1117 ;;
9195b2c2
SW
1118 --disable-tcg-interpreter) tcg_interpreter="no"
1119 ;;
1120 --enable-tcg-interpreter) tcg_interpreter="yes"
1121 ;;
47e98658
CB
1122 --disable-cap-ng) cap_ng="no"
1123 ;;
1124 --enable-cap-ng) cap_ng="yes"
1125 ;;
b3f6ea7e
PB
1126 --disable-tcg) tcg="no"
1127 ;;
1128 --enable-tcg) tcg="yes"
1129 ;;
5a22ab71
YZ
1130 --disable-malloc-trim) malloc_trim="no"
1131 ;;
1132 --enable-malloc-trim) malloc_trim="yes"
1133 ;;
cd4ec0b4
GH
1134 --disable-spice) spice="no"
1135 ;;
1136 --enable-spice) spice="yes"
1137 ;;
c589b249
RS
1138 --disable-libiscsi) libiscsi="no"
1139 ;;
1140 --enable-libiscsi) libiscsi="yes"
1141 ;;
6542aa9c
PL
1142 --disable-libnfs) libnfs="no"
1143 ;;
1144 --enable-libnfs) libnfs="yes"
1145 ;;
05c2a3e7
FB
1146 --enable-profiler) profiler="yes"
1147 ;;
14821030
PB
1148 --disable-cocoa) cocoa="no"
1149 ;;
c2de5c91 1150 --enable-cocoa)
1151 cocoa="yes" ;
89138857 1152 audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
1d14ffa9 1153 ;;
cad25d69 1154 --disable-system) softmmu="no"
0a8e90f4 1155 ;;
cad25d69 1156 --enable-system) softmmu="yes"
0a8e90f4 1157 ;;
0953a80f
ZA
1158 --disable-user)
1159 linux_user="no" ;
1160 bsd_user="no" ;
0953a80f
ZA
1161 ;;
1162 --enable-user) ;;
831b7825 1163 --disable-linux-user) linux_user="no"
0a8e90f4 1164 ;;
831b7825
TS
1165 --enable-linux-user) linux_user="yes"
1166 ;;
84778508
BS
1167 --disable-bsd-user) bsd_user="no"
1168 ;;
1169 --enable-bsd-user) bsd_user="yes"
1170 ;;
40d6444e 1171 --enable-pie) pie="yes"
34005a00 1172 ;;
40d6444e 1173 --disable-pie) pie="no"
34005a00 1174 ;;
85aa5189
FB
1175 --enable-werror) werror="yes"
1176 ;;
1177 --disable-werror) werror="no"
1178 ;;
63678e17
SN
1179 --enable-stack-protector) stack_protector="yes"
1180 ;;
1181 --disable-stack-protector) stack_protector="no"
1182 ;;
4d3b6f6e
AZ
1183 --disable-curses) curses="no"
1184 ;;
c584a6d0
JQ
1185 --enable-curses) curses="yes"
1186 ;;
769ce76d
AG
1187 --disable-curl) curl="no"
1188 ;;
788c8196
JQ
1189 --enable-curl) curl="yes"
1190 ;;
2df87df7
JQ
1191 --disable-fdt) fdt="no"
1192 ;;
1193 --enable-fdt) fdt="yes"
1194 ;;
5c6c3a6c
CH
1195 --disable-linux-aio) linux_aio="no"
1196 ;;
1197 --enable-linux-aio) linux_aio="yes"
1198 ;;
758e8e38
VJ
1199 --disable-attr) attr="no"
1200 ;;
1201 --enable-attr) attr="yes"
1202 ;;
a40161cb
PB
1203 --disable-membarrier) membarrier="no"
1204 ;;
1205 --enable-membarrier) membarrier="yes"
1206 ;;
77755340
TS
1207 --disable-blobs) blobs="no"
1208 ;;
7e563bfb 1209 --with-pkgversion=*) pkgversion="$optarg"
4a19f1ec 1210 ;;
519175a2
AB
1211 --with-coroutine=*) coroutine="$optarg"
1212 ;;
70c60c08
SH
1213 --disable-coroutine-pool) coroutine_pool="no"
1214 ;;
1215 --enable-coroutine-pool) coroutine_pool="yes"
1216 ;;
7d992e4d
PL
1217 --enable-debug-stack-usage) debug_stack_usage="yes"
1218 ;;
f0d92b56
LM
1219 --enable-crypto-afalg) crypto_afalg="yes"
1220 ;;
1221 --disable-crypto-afalg) crypto_afalg="no"
1222 ;;
a25dba17 1223 --disable-docs) docs="no"
70ec5dc0 1224 ;;
a25dba17 1225 --enable-docs) docs="yes"
83a3ab8b 1226 ;;
d5970055
MT
1227 --disable-vhost-net) vhost_net="no"
1228 ;;
1229 --enable-vhost-net) vhost_net="yes"
1230 ;;
042cea27
GA
1231 --disable-vhost-crypto) vhost_crypto="no"
1232 ;;
1233 --enable-vhost-crypto)
1234 vhost_crypto="yes"
1235 if test "$mingw32" = "yes"; then
1236 error_exit "vhost-crypto isn't available on win32"
1237 fi
1238 ;;
5e9be92d
NB
1239 --disable-vhost-scsi) vhost_scsi="no"
1240 ;;
1241 --enable-vhost-scsi) vhost_scsi="yes"
1242 ;;
fc0b9b0e
SH
1243 --disable-vhost-vsock) vhost_vsock="no"
1244 ;;
1245 --enable-vhost-vsock) vhost_vsock="yes"
1246 ;;
da076ffe 1247 --disable-opengl) opengl="no"
20ff075b 1248 ;;
da076ffe 1249 --enable-opengl) opengl="yes"
20ff075b 1250 ;;
f27aaf4b
CB
1251 --disable-rbd) rbd="no"
1252 ;;
1253 --enable-rbd) rbd="yes"
1254 ;;
8c84cf11
ST
1255 --disable-xfsctl) xfs="no"
1256 ;;
1257 --enable-xfsctl) xfs="yes"
1258 ;;
7b02f544 1259 --disable-smartcard) smartcard="no"
111a38b0 1260 ;;
7b02f544 1261 --enable-smartcard) smartcard="yes"
111a38b0 1262 ;;
2b2325ff
GH
1263 --disable-libusb) libusb="no"
1264 ;;
1265 --enable-libusb) libusb="yes"
1266 ;;
69354a83
HG
1267 --disable-usb-redir) usb_redir="no"
1268 ;;
1269 --enable-usb-redir) usb_redir="yes"
1270 ;;
1ece9905
AL
1271 --disable-zlib-test) zlib="no"
1272 ;;
b25c9dff
SW
1273 --disable-lzo) lzo="no"
1274 ;;
607dacd0
QN
1275 --enable-lzo) lzo="yes"
1276 ;;
b25c9dff
SW
1277 --disable-snappy) snappy="no"
1278 ;;
607dacd0
QN
1279 --enable-snappy) snappy="yes"
1280 ;;
6b383c08
PW
1281 --disable-bzip2) bzip2="no"
1282 ;;
1283 --enable-bzip2) bzip2="yes"
1284 ;;
d138cee9
MR
1285 --enable-guest-agent) guest_agent="yes"
1286 ;;
1287 --disable-guest-agent) guest_agent="no"
1288 ;;
9dacf32d
YH
1289 --enable-guest-agent-msi) guest_agent_msi="yes"
1290 ;;
1291 --disable-guest-agent-msi) guest_agent_msi="no"
1292 ;;
d9840e25
TS
1293 --with-vss-sdk) vss_win32_sdk=""
1294 ;;
1295 --with-vss-sdk=*) vss_win32_sdk="$optarg"
1296 ;;
1297 --without-vss-sdk) vss_win32_sdk="no"
1298 ;;
1299 --with-win-sdk) win_sdk=""
1300 ;;
1301 --with-win-sdk=*) win_sdk="$optarg"
1302 ;;
1303 --without-win-sdk) win_sdk="no"
1304 ;;
4b1c11fd
DB
1305 --enable-tools) want_tools="yes"
1306 ;;
1307 --disable-tools) want_tools="no"
1308 ;;
f794573e
EO
1309 --enable-seccomp) seccomp="yes"
1310 ;;
1311 --disable-seccomp) seccomp="no"
1312 ;;
eb100396
BR
1313 --disable-glusterfs) glusterfs="no"
1314 ;;
1315 --enable-glusterfs) glusterfs="yes"
1316 ;;
52b53c04
FZ
1317 --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
1318 echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
583f6e7b 1319 ;;
cb6414df
FZ
1320 --enable-vhdx|--disable-vhdx)
1321 echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1322 ;;
315d3184
FZ
1323 --enable-uuid|--disable-uuid)
1324 echo "$0: $opt is obsolete, UUID support is always built" >&2
1325 ;;
a4ccabcf
AL
1326 --disable-gtk) gtk="no"
1327 ;;
1328 --enable-gtk) gtk="yes"
1329 ;;
a1c5e949
DB
1330 --tls-priority=*) tls_priority="$optarg"
1331 ;;
ddbb0d09
DB
1332 --disable-gnutls) gnutls="no"
1333 ;;
1334 --enable-gnutls) gnutls="yes"
1335 ;;
91bfcdb0
DB
1336 --disable-nettle) nettle="no"
1337 ;;
1338 --enable-nettle) nettle="yes"
1339 ;;
1340 --disable-gcrypt) gcrypt="no"
1341 ;;
1342 --enable-gcrypt) gcrypt="yes"
1343 ;;
2da776db
MH
1344 --enable-rdma) rdma="yes"
1345 ;;
1346 --disable-rdma) rdma="no"
1347 ;;
528de90a
DB
1348 --with-gtkabi=*) gtkabi="$optarg"
1349 ;;
bbbf9bfb
SW
1350 --disable-vte) vte="no"
1351 ;;
1352 --enable-vte) vte="yes"
1353 ;;
9d9e1521
GH
1354 --disable-virglrenderer) virglrenderer="no"
1355 ;;
1356 --enable-virglrenderer) virglrenderer="yes"
1357 ;;
e91c793c
CR
1358 --disable-tpm) tpm="no"
1359 ;;
ab214c29
SB
1360 --enable-tpm) tpm="yes"
1361 ;;
0a12ec87
RJ
1362 --disable-libssh2) libssh2="no"
1363 ;;
1364 --enable-libssh2) libssh2="yes"
1365 ;;
ed1701c6
DDAG
1366 --disable-live-block-migration) live_block_migration="no"
1367 ;;
1368 --enable-live-block-migration) live_block_migration="yes"
1369 ;;
a99d57bb
WG
1370 --disable-numa) numa="no"
1371 ;;
1372 --enable-numa) numa="yes"
1373 ;;
ed279a06
KK
1374 --disable-libxml2) libxml2="no"
1375 ;;
1376 --enable-libxml2) libxml2="yes"
1377 ;;
2847b469
FZ
1378 --disable-tcmalloc) tcmalloc="no"
1379 ;;
1380 --enable-tcmalloc) tcmalloc="yes"
1381 ;;
7b01cb97
AD
1382 --disable-jemalloc) jemalloc="no"
1383 ;;
1384 --enable-jemalloc) jemalloc="yes"
1385 ;;
a6b1d4c0
CX
1386 --disable-replication) replication="no"
1387 ;;
1388 --enable-replication) replication="yes"
1389 ;;
da92c3ff
AM
1390 --disable-vxhs) vxhs="no"
1391 ;;
1392 --enable-vxhs) vxhs="yes"
1393 ;;
e6a74868
MAL
1394 --disable-vhost-user) vhost_user="no"
1395 ;;
1396 --enable-vhost-user)
1397 vhost_user="yes"
1398 if test "$mingw32" = "yes"; then
1399 error_exit "vhost-user isn't available on win32"
1400 fi
1401 ;;
8ca80760
RH
1402 --disable-capstone) capstone="no"
1403 ;;
1404 --enable-capstone) capstone="yes"
1405 ;;
e219c499
RH
1406 --enable-capstone=git) capstone="git"
1407 ;;
1408 --enable-capstone=system) capstone="system"
1409 ;;
cc84d63a
DB
1410 --with-git=*) git="$optarg"
1411 ;;
f62bbee5
DB
1412 --enable-git-update) git_update=yes
1413 ;;
1414 --disable-git-update) git_update=no
1415 ;;
ba59fb77
PB
1416 --enable-debug-mutex) debug_mutex=yes
1417 ;;
1418 --disable-debug-mutex) debug_mutex=no
1419 ;;
2d2ad6d0
FZ
1420 *)
1421 echo "ERROR: unknown option $opt"
1422 echo "Try '$0 --help' for more information"
1423 exit 1
7f1559c6 1424 ;;
7d13299d
FB
1425 esac
1426done
1427
e6a74868
MAL
1428if test "$vhost_user" = ""; then
1429 if test "$mingw32" = "yes"; then
1430 vhost_user="no"
1431 else
1432 vhost_user="yes"
1433 fi
1434fi
1435
40293e58 1436case "$cpu" in
e3608d66
RH
1437 ppc)
1438 CPU_CFLAGS="-m32"
1439 LDFLAGS="-m32 $LDFLAGS"
13a5abe2
AB
1440 cross_cc_powerpc=$cc
1441 cross_cc_cflags_powerpc=$CPU_CFLAGS
e3608d66
RH
1442 ;;
1443 ppc64)
1444 CPU_CFLAGS="-m64"
1445 LDFLAGS="-m64 $LDFLAGS"
13a5abe2
AB
1446 cross_cc_ppc64=$cc
1447 cross_cc_cflags_ppc64=$CPU_CFLAGS
e3608d66 1448 ;;
9b9c37c3 1449 sparc)
f1079bb8
RH
1450 CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
1451 LDFLAGS="-m32 -mv8plus $LDFLAGS"
13a5abe2
AB
1452 cross_cc_sparc=$cc
1453 cross_cc_cflags_sparc=$CPU_CFLAGS
3142255c 1454 ;;
ed968ff1 1455 sparc64)
79f3b12f 1456 CPU_CFLAGS="-m64 -mcpu=ultrasparc"
f1079bb8 1457 LDFLAGS="-m64 $LDFLAGS"
13a5abe2
AB
1458 cross_cc_sparc64=$cc
1459 cross_cc_cflags_sparc64=$CPU_CFLAGS
3142255c 1460 ;;
76d83bde 1461 s390)
061cdd81 1462 CPU_CFLAGS="-m31"
28d7cc49 1463 LDFLAGS="-m31 $LDFLAGS"
13a5abe2
AB
1464 cross_cc_s390=$cc
1465 cross_cc_cflags_s390=$CPU_CFLAGS
28d7cc49
RH
1466 ;;
1467 s390x)
061cdd81 1468 CPU_CFLAGS="-m64"
28d7cc49 1469 LDFLAGS="-m64 $LDFLAGS"
13a5abe2
AB
1470 cross_cc_s390x=$cc
1471 cross_cc_cflags_s390x=$CPU_CFLAGS
76d83bde 1472 ;;
40293e58 1473 i386)
79f3b12f 1474 CPU_CFLAGS="-m32"
0c439cbf 1475 LDFLAGS="-m32 $LDFLAGS"
716a507c
AB
1476 cross_cc_i386=$cc
1477 cross_cc_cflags_i386=$CPU_CFLAGS
40293e58
FB
1478 ;;
1479 x86_64)
7ebee43e
RH
1480 # ??? Only extremely old AMD cpus do not have cmpxchg16b.
1481 # If we truly care, we should simply detect this case at
1482 # runtime and generate the fallback to serial emulation.
1483 CPU_CFLAGS="-m64 -mcx16"
0c439cbf 1484 LDFLAGS="-m64 $LDFLAGS"
716a507c
AB
1485 cross_cc_x86_64=$cc
1486 cross_cc_cflags_x86_64=$CPU_CFLAGS
d2fbca94 1487 ;;
c72b26ec
RH
1488 x32)
1489 CPU_CFLAGS="-mx32"
1490 LDFLAGS="-mx32 $LDFLAGS"
716a507c 1491 cross_cc_i386=$cc
13a5abe2 1492 cross_cc_cflags_i386=$CPU_CFLAGS
c72b26ec 1493 ;;
30163d89 1494 # No special flags required for other host CPUs
3142255c
BS
1495esac
1496
79f3b12f 1497QEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
79f3b12f 1498
affc88cc
PM
1499# For user-mode emulation the host arch has to be one we explicitly
1500# support, even if we're using TCI.
1501if [ "$ARCH" = "unknown" ]; then
1502 bsd_user="no"
1503 linux_user="no"
1504fi
1505
60e0df25
PM
1506default_target_list=""
1507
6e92f823
PM
1508mak_wilds=""
1509
1510if [ "$softmmu" = "yes" ]; then
1511 mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
60e0df25 1512fi
6e92f823
PM
1513if [ "$linux_user" = "yes" ]; then
1514 mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
60e0df25 1515fi
6e92f823
PM
1516if [ "$bsd_user" = "yes" ]; then
1517 mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
60e0df25
PM
1518fi
1519
6e92f823
PM
1520for config in $mak_wilds; do
1521 default_target_list="${default_target_list} $(basename "$config" .mak)"
1522done
1523
c53eeaf7 1524# Enumerate public trace backends for --help output
64a6047d 1525trace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
c53eeaf7 1526
af5db58e
PB
1527if test x"$show_help" = x"yes" ; then
1528cat << EOF
1529
1530Usage: configure [options]
1531Options: [defaults in brackets after descriptions]
1532
08fb77ed
SW
1533Standard options:
1534 --help print this message
1535 --prefix=PREFIX install in PREFIX [$prefix]
1536 --interp-prefix=PREFIX where to find shared libraries, etc.
1537 use %M for cpu name [$interp_prefix]
1538 --target-list=LIST set target list (default: build everything)
1539$(echo Available targets: $default_target_list | \
1540 fold -s -w 53 | sed -e 's/^/ /')
1541
1542Advanced options (experts only):
1543 --source-path=PATH path of source code [$source_path]
1544 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
1545 --cc=CC use C compiler CC [$cc]
1546 --iasl=IASL use ACPI compiler IASL [$iasl]
1547 --host-cc=CC use C compiler CC [$host_cc] for code run at
1548 build time
1549 --cxx=CXX use C++ compiler CXX [$cxx]
1550 --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
1551 --extra-cflags=CFLAGS append extra C compiler flags QEMU_CFLAGS
11cde1c8 1552 --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
08fb77ed 1553 --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS
d75402b5 1554 --cross-cc-ARCH=CC use compiler when building ARCH guest test cases
d422b2bc 1555 --cross-cc-flags-ARCH= use compiler flags when building ARCH guest tests
08fb77ed
SW
1556 --make=MAKE use specified make [$make]
1557 --install=INSTALL use specified install [$install]
1558 --python=PYTHON use specified python [$python]
1559 --smbd=SMBD use specified smbd [$smbd]
db1b5f13 1560 --with-git=GIT use specified git [$git]
08fb77ed
SW
1561 --static enable static build [$static]
1562 --mandir=PATH install man pages in PATH
1563 --datadir=PATH install firmware in PATH$confsuffix
1564 --docdir=PATH install documentation in PATH$confsuffix
1565 --bindir=PATH install binaries in PATH
1566 --libdir=PATH install libraries in PATH
db1b5f13 1567 --libexecdir=PATH install helper binaries in PATH
08fb77ed
SW
1568 --sysconfdir=PATH install config in PATH$confsuffix
1569 --localstatedir=PATH install local state in PATH (set at runtime on win32)
3d5eecab 1570 --firmwarepath=PATH search PATH for firmware files
e26110cf 1571 --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
db1b5f13 1572 --with-pkgversion=VERS use specified string as sub-version of the package
08fb77ed 1573 --enable-debug enable common debug build options
247724cb 1574 --enable-sanitizers enable default sanitizers
08fb77ed
SW
1575 --disable-strip disable stripping binaries
1576 --disable-werror disable compilation abort on warning
63678e17 1577 --disable-stack-protector disable compiler-provided stack protection
08fb77ed
SW
1578 --audio-drv-list=LIST set audio drivers list:
1579 Available drivers: $audio_possible_drivers
1580 --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L
1581 --block-drv-rw-whitelist=L
1582 set block driver read-write whitelist
1583 (affects only QEMU, not qemu-img)
1584 --block-drv-ro-whitelist=L
1585 set block driver read-only whitelist
1586 (affects only QEMU, not qemu-img)
5b808275 1587 --enable-trace-backends=B Set trace backend
c53eeaf7 1588 Available backends: $trace_backend_list
08fb77ed
SW
1589 --with-trace-file=NAME Full PATH,NAME of file to store traces
1590 Default:trace-<pid>
c23f23b9
MT
1591 --disable-slirp disable SLIRP userspace network connectivity
1592 --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
5a22ab71 1593 --enable-malloc-trim enable libc malloc_trim() for memory optimization
c23f23b9
MT
1594 --oss-lib path to OSS library
1595 --cpu=CPU Build for host CPU [$cpu]
08fb77ed 1596 --with-coroutine=BACKEND coroutine backend. Supported options:
33c53c54 1597 ucontext, sigaltstack, windows
08fb77ed
SW
1598 --enable-gcov enable test coverage analysis with gcov
1599 --gcov=GCOV use specified gcov [$gcov_tool]
c23f23b9
MT
1600 --disable-blobs disable installing provided firmware blobs
1601 --with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent
1602 --with-win-sdk=SDK-path path to Windows Platform SDK (to build VSS .tlb)
a1c5e949 1603 --tls-priority default TLS protocol/cipher priority string
c12d66aa
LM
1604 --enable-gprof QEMU profiling with gprof
1605 --enable-profiler profiler support
1606 --enable-xen-pv-domain-build
1607 xen pv domain builder
1608 --enable-debug-stack-usage
1609 track the maximum stack usage of stacks created by qemu_alloc_stack
c23f23b9
MT
1610
1611Optional features, enabled with --enable-FEATURE and
1612disabled with --disable-FEATURE, default is enabled if available:
1613
1614 system all system emulation targets
1615 user supported user emulation targets
1616 linux-user all linux usermode emulation targets
1617 bsd-user all BSD usermode emulation targets
c23f23b9
MT
1618 docs build documentation
1619 guest-agent build the QEMU Guest Agent
1620 guest-agent-msi build guest agent Windows MSI installation package
1621 pie Position Independent Executables
1622 modules modules support
1623 debug-tcg TCG debugging (default is disabled)
1624 debug-info debugging information
1625 sparse sparse checker
1626
ddbb0d09 1627 gnutls GNUTLS cryptography support
91bfcdb0
DB
1628 nettle nettle cryptography support
1629 gcrypt libgcrypt cryptography support
c23f23b9
MT
1630 sdl SDL UI
1631 --with-sdlabi select preferred SDL ABI 1.2 or 2.0
1632 gtk gtk UI
1633 --with-gtkabi select preferred GTK ABI 2.0 or 3.0
1634 vte vte support for the gtk UI
1635 curses curses UI
1636 vnc VNC UI support
c23f23b9
MT
1637 vnc-sasl SASL encryption for VNC server
1638 vnc-jpeg JPEG lossy compression for VNC server
1639 vnc-png PNG compression for VNC server
c23f23b9
MT
1640 cocoa Cocoa UI (Mac OS X only)
1641 virtfs VirtFS
fe8fc5ae 1642 mpath Multipath persistent reservation passthrough
c23f23b9 1643 xen xen backend driver support
70c292af 1644 xen-pci-passthrough PCI passthrough support for Xen
c23f23b9
MT
1645 brlapi BrlAPI (Braile)
1646 curl curl connectivity
a40161cb 1647 membarrier membarrier system call (for Linux 4.14+ or Windows)
c23f23b9
MT
1648 fdt fdt device tree
1649 bluez bluez stack connectivity
1650 kvm KVM acceleration support
b0cb0a66 1651 hax HAX acceleration support
c97d6d2c 1652 hvf Hypervisor.framework acceleration support
d661d9a4 1653 whpx Windows Hypervisor Platform acceleration support
ef6d4ccd 1654 rdma Enable RDMA-based migration and PVRDMA support
c23f23b9
MT
1655 vde support for vde network
1656 netmap support for netmap network
1657 linux-aio Linux AIO support
1658 cap-ng libcap-ng support
1659 attr attr and xattr support
1660 vhost-net vhost-net acceleration support
042cea27 1661 vhost-crypto vhost-crypto acceleration support
c23f23b9
MT
1662 spice spice
1663 rbd rados block device (rbd)
1664 libiscsi iscsi support
1665 libnfs nfs support
7b02f544 1666 smartcard smartcard support (libcacard)
c23f23b9 1667 libusb libusb (for usb passthrough)
ed1701c6 1668 live-block-migration Block migration in the main migration stream
c23f23b9
MT
1669 usb-redir usb network redirection support
1670 lzo support of lzo compression library
1671 snappy support of snappy compression library
1672 bzip2 support of bzip2 compression library
1673 (for reading bzip2-compressed dmg images)
1674 seccomp seccomp support
1675 coroutine-pool coroutine freelist (better performance)
1676 glusterfs GlusterFS backend
c23f23b9
MT
1677 tpm TPM support
1678 libssh2 ssh block device support
c23f23b9 1679 numa libnuma support
ed279a06 1680 libxml2 for Parallels image format
c23f23b9 1681 tcmalloc tcmalloc support
7b01cb97 1682 jemalloc jemalloc support
a6b1d4c0 1683 replication replication support
c12d66aa
LM
1684 vhost-vsock virtio sockets device support
1685 opengl opengl support
1686 virglrenderer virgl rendering support
1687 xfsctl xfsctl support
1688 qom-cast-debug cast debugging support
1689 tools build qemu-io, qemu-nbd and qemu-image tools
da92c3ff 1690 vxhs Veritas HyperScale vDisk backend support
f0d92b56 1691 crypto-afalg Linux AF_ALG crypto backend driver
e6a74868 1692 vhost-user vhost-user support
8ca80760 1693 capstone capstone disassembler support
ba59fb77 1694 debug-mutex mutex debugging support
08fb77ed
SW
1695
1696NOTE: The object files are built at the place where configure is launched
af5db58e 1697EOF
2d2ad6d0 1698exit 0
af5db58e
PB
1699fi
1700
c53eeaf7
SH
1701if ! has $python; then
1702 error_exit "Python not found. Use --python=/path/to/python"
1703fi
1704
1705# Note that if the Python conditional here evaluates True we will exit
1706# with status 1 which is a shell 'false' value.
7f2b5544
EH
1707if ! $python -c 'import sys; sys.exit(sys.version_info < (2,7))'; then
1708 error_exit "Cannot use '$python', Python 2 >= 2.7 or Python 3 is required." \
c53eeaf7
SH
1709 "Use --python=/path/to/python to specify a supported Python."
1710fi
1711
1712# Suppress writing compiled files
1713python="$python -B"
1714
9aae6e54
DHB
1715# Check that the C compiler works. Doing this here before testing
1716# the host CPU ensures that we had a valid CC to autodetect the
1717# $cpu var (and we should bail right here if that's not the case).
1718# It also allows the help message to be printed without a CC.
1719write_c_skeleton;
1720if compile_object ; then
1721 : C compiler works ok
1722else
1723 error_exit "\"$cc\" either does not exist or does not work"
1724fi
1725if ! compile_prog ; then
1726 error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
1727fi
1728
359bc95d
PM
1729# Now we have handled --enable-tcg-interpreter and know we're not just
1730# printing the help message, bail out if the host CPU isn't supported.
1731if test "$ARCH" = "unknown"; then
1732 if test "$tcg_interpreter" = "yes" ; then
1733 echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
359bc95d 1734 else
76ad07a4 1735 error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
359bc95d
PM
1736 fi
1737fi
1738
9c83ffd8
PM
1739# Consult white-list to determine whether to enable werror
1740# by default. Only enable by default for git builds
9c83ffd8
PM
1741if test -z "$werror" ; then
1742 if test -d "$source_path/.git" -a \
e4650c81 1743 \( "$linux" = "yes" -o "$mingw32" = "yes" \) ; then
9c83ffd8
PM
1744 werror="yes"
1745 else
1746 werror="no"
1747 fi
1748fi
1749
fb59dabd
PM
1750if test "$bogus_os" = "yes"; then
1751 # Now that we know that we're not printing the help and that
1752 # the compiler works (so the results of the check_defines we used
1753 # to identify the OS are reliable), if we didn't recognize the
1754 # host OS we should stop now.
951fedfc 1755 error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
fb59dabd
PM
1756fi
1757
8d05095c
PB
1758gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
1759gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
ac7568bd 1760gcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
435405ac 1761gcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
b98fcfd8 1762gcc_flags="-Wno-initializer-overrides -Wexpansion-to-defined $gcc_flags"
71429097 1763gcc_flags="-Wno-string-plus-int $gcc_flags"
0e39c4aa 1764gcc_flags="-Wno-error=address-of-packed-member $gcc_flags"
6ca026cb
PM
1765# Note that we do not add -Werror to gcc_flags here, because that would
1766# enable it for all configure tests. If a configure test failed due
1767# to -Werror this would just silently disable some features,
1768# so it's too error prone.
93b25869
JS
1769
1770cc_has_warning_flag() {
1771 write_c_skeleton;
1772
a1d29d6c
PM
1773 # Use the positive sense of the flag when testing for -Wno-wombat
1774 # support (gcc will happily accept the -Wno- form of unknown
1775 # warning options).
93b25869
JS
1776 optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
1777 compile_prog "-Werror $optflag" ""
1778}
1779
1780for flag in $gcc_flags; do
1781 if cc_has_warning_flag $flag ; then
1782 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
8d05095c
PB
1783 fi
1784done
1785
3b463a3f 1786if test "$stack_protector" != "no"; then
fccd35a0
RR
1787 cat > $TMPC << EOF
1788int main(int argc, char *argv[])
1789{
1790 char arr[64], *p = arr, *c = argv[0];
1791 while (*c) {
1792 *p++ = *c++;
1793 }
1794 return 0;
1795}
1796EOF
63678e17 1797 gcc_flags="-fstack-protector-strong -fstack-protector-all"
3b463a3f 1798 sp_on=0
63678e17 1799 for flag in $gcc_flags; do
590e5dd9
PM
1800 # We need to check both a compile and a link, since some compiler
1801 # setups fail only on a .c->.o compile and some only at link time
1802 if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
1803 compile_prog "-Werror $flag" ""; then
63678e17 1804 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
3b463a3f 1805 sp_on=1
63678e17
SN
1806 break
1807 fi
1808 done
3b463a3f
MR
1809 if test "$stack_protector" = yes; then
1810 if test $sp_on = 0; then
1811 error_exit "Stack protector not supported"
1812 fi
1813 fi
37746c5e
MAL
1814fi
1815
20bc94a2
PB
1816# Disable -Wmissing-braces on older compilers that warn even for
1817# the "universal" C zero initializer {0}.
1818cat > $TMPC << EOF
1819struct {
1820 int a[2];
1821} x = {0};
1822EOF
1823if compile_object "-Werror" "" ; then
1824 :
1825else
1826 QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
1827fi
1828
cbdd1999
PB
1829# Workaround for http://gcc.gnu.org/PR55489. Happens with -fPIE/-fPIC and
1830# large functions that use global variables. The bug is in all releases of
1831# GCC, but it became particularly acute in 4.6.x and 4.7.x. It is fixed in
1832# 4.7.3 and 4.8.0. We should be able to delete this at the end of 2013.
1833cat > $TMPC << EOF
1834#if __GNUC__ == 4 && (__GNUC_MINOR__ == 6 || (__GNUC_MINOR__ == 7 && __GNUC_PATCHLEVEL__ <= 2))
1835int main(void) { return 0; }
1836#else
1837#error No bug in this compiler.
1838#endif
1839EOF
1840if compile_prog "-Werror -fno-gcse" "" ; then
1841 TRANSLATE_OPT_CFLAGS=-fno-gcse
1842fi
1843
40d6444e 1844if test "$static" = "yes" ; then
aa0d1f44
PB
1845 if test "$modules" = "yes" ; then
1846 error_exit "static and modules are mutually incompatible"
1847 fi
40d6444e 1848 if test "$pie" = "yes" ; then
76ad07a4 1849 error_exit "static and pie are mutually incompatible"
40d6444e
AK
1850 else
1851 pie="no"
1852 fi
1853fi
1854
768b7855
EC
1855# Unconditional check for compiler __thread support
1856 cat > $TMPC << EOF
1857static __thread int tls_var;
1858int main(void) { return tls_var; }
1859EOF
1860
1861if ! compile_prog "-Werror" "" ; then
1862 error_exit "Your compiler does not support the __thread specifier for " \
1863 "Thread-Local Storage (TLS). Please upgrade to a version that does."
1864fi
1865
40d6444e
AK
1866if test "$pie" = ""; then
1867 case "$cpu-$targetos" in
c72b26ec 1868 i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
40d6444e
AK
1869 ;;
1870 *)
1871 pie="no"
1872 ;;
1873 esac
1874fi
1875
1876if test "$pie" != "no" ; then
1877 cat > $TMPC << EOF
21d4a791
AK
1878
1879#ifdef __linux__
1880# define THREAD __thread
1881#else
1882# define THREAD
1883#endif
1884
1885static THREAD int tls_var;
1886
1887int main(void) { return tls_var; }
1888
40d6444e
AK
1889EOF
1890 if compile_prog "-fPIE -DPIE" "-pie"; then
1891 QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
1892 LDFLAGS="-pie $LDFLAGS"
1893 pie="yes"
1894 if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
1895 LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
1896 fi
1897 else
1898 if test "$pie" = "yes"; then
76ad07a4 1899 error_exit "PIE not available due to missing toolchain support"
40d6444e
AK
1900 else
1901 echo "Disabling PIE due to missing toolchain support"
1902 pie="no"
1903 fi
1904 fi
46eef33b 1905
e4a7b344 1906 if compile_prog "-Werror -fno-pie" "-nopie"; then
46eef33b
BS
1907 CFLAGS_NOPIE="-fno-pie"
1908 LDFLAGS_NOPIE="-nopie"
1909 fi
40d6444e
AK
1910fi
1911
09dada40
PB
1912##########################################
1913# __sync_fetch_and_and requires at least -march=i486. Many toolchains
1914# use i686 as default anyway, but for those that don't, an explicit
1915# specification is necessary
1916
1917if test "$cpu" = "i386"; then
1918 cat > $TMPC << EOF
1919static int sfaa(int *ptr)
1920{
1921 return __sync_fetch_and_and(ptr, 0);
1922}
1923
1924int main(void)
1925{
1926 int val = 42;
1405b629 1927 val = __sync_val_compare_and_swap(&val, 0, 1);
09dada40
PB
1928 sfaa(&val);
1929 return val;
1930}
1931EOF
1932 if ! compile_prog "" "" ; then
1933 QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
1934 fi
1935fi
1936
1937#########################################
ec530c81 1938# Solaris specific configure tool chain decisions
09dada40 1939
ec530c81 1940if test "$solaris" = "yes" ; then
6792aa11
LM
1941 if has $install; then
1942 :
1943 else
76ad07a4
PM
1944 error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
1945 "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
1946 "to get ginstall which is used by default (which lives in /opt/csw/bin)"
ec530c81 1947 fi
89138857 1948 if test "$(path_of $install)" = "/usr/sbin/install" ; then
76ad07a4
PM
1949 error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
1950 "try ginstall from the GNU fileutils available from www.blastwave.org" \
1951 "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
ec530c81 1952 fi
6792aa11
LM
1953 if has ar; then
1954 :
1955 else
ec530c81 1956 if test -f /usr/ccs/bin/ar ; then
76ad07a4
PM
1957 error_exit "No path includes ar" \
1958 "Add /usr/ccs/bin to your path and rerun configure"
ec530c81 1959 fi
76ad07a4 1960 error_exit "No path includes ar"
ec530c81 1961 fi
5fafdf24 1962fi
ec530c81 1963
afb63ebd 1964if test -z "${target_list+xxx}" ; then
d880a3ba
PB
1965 for target in $default_target_list; do
1966 supported_target $target 2>/dev/null && \
1967 target_list="$target_list $target"
1968 done
1969 target_list="${target_list# }"
121afa9e 1970else
89138857 1971 target_list=$(echo "$target_list" | sed -e 's/,/ /g')
d880a3ba
PB
1972 for target in $target_list; do
1973 # Check that we recognised the target name; this allows a more
1974 # friendly error message than if we let it fall through.
1975 case " $default_target_list " in
1976 *" $target "*)
1977 ;;
1978 *)
1979 error_exit "Unknown target name '$target'"
1980 ;;
1981 esac
1982 supported_target $target || exit 1
1983 done
121afa9e 1984fi
25b48338 1985
f55fe278
PB
1986# see if system emulation was really requested
1987case " $target_list " in
1988 *"-softmmu "*) softmmu=yes
1989 ;;
1990 *) softmmu=no
1991 ;;
1992esac
5327cf48 1993
249247c9
JQ
1994feature_not_found() {
1995 feature=$1
21684af0 1996 remedy=$2
249247c9 1997
76ad07a4 1998 error_exit "User requested feature $feature" \
21684af0
SS
1999 "configure was not able to find it." \
2000 "$remedy"
249247c9
JQ
2001}
2002
7d13299d
FB
2003# ---
2004# big/little endian test
2005cat > $TMPC << EOF
61cc919f
MF
2006short big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
2007short little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
2008extern int foo(short *, short *);
2009int main(int argc, char *argv[]) {
2010 return foo(big_endian, little_endian);
7d13299d
FB
2011}
2012EOF
2013
61cc919f 2014if compile_object ; then
12f15c91 2015 if strings -a $TMPO | grep -q BiGeNdIaN ; then
61cc919f 2016 bigendian="yes"
12f15c91 2017 elif strings -a $TMPO | grep -q LiTtLeEnDiAn ; then
61cc919f
MF
2018 bigendian="no"
2019 else
2020 echo big/little test failed
21d89f84 2021 fi
61cc919f
MF
2022else
2023 echo big/little test failed
7d13299d
FB
2024fi
2025
a30878e7
PM
2026##########################################
2027# cocoa implies not SDL or GTK
2028# (the cocoa UI code currently assumes it is always the active UI
2029# and doesn't interact well with other UI frontend code)
2030if test "$cocoa" = "yes"; then
2031 if test "$sdl" = "yes"; then
2032 error_exit "Cocoa and SDL UIs cannot both be enabled at once"
2033 fi
2034 if test "$gtk" = "yes"; then
2035 error_exit "Cocoa and GTK UIs cannot both be enabled at once"
2036 fi
2037 gtk=no
2038 sdl=no
2039fi
2040
6b39b063
EB
2041# Some versions of Mac OS X incorrectly define SIZE_MAX
2042cat > $TMPC << EOF
2043#include <stdint.h>
2044#include <stdio.h>
2045int main(int argc, char *argv[]) {
2046 return printf("%zu", SIZE_MAX);
2047}
2048EOF
2049have_broken_size_max=no
2050if ! compile_object -Werror ; then
2051 have_broken_size_max=yes
2052fi
2053
015a33bd
GA
2054##########################################
2055# L2TPV3 probe
2056
2057cat > $TMPC <<EOF
2058#include <sys/socket.h>
bff6cb72 2059#include <linux/ip.h>
015a33bd
GA
2060int main(void) { return sizeof(struct mmsghdr); }
2061EOF
2062if compile_prog "" "" ; then
2063 l2tpv3=yes
2064else
2065 l2tpv3=no
2066fi
2067
4d9310f4
DB
2068##########################################
2069# MinGW / Mingw-w64 localtime_r/gmtime_r check
2070
2071if test "$mingw32" = "yes"; then
2072 # Some versions of MinGW / Mingw-w64 lack localtime_r
2073 # and gmtime_r entirely.
2074 #
2075 # Some versions of Mingw-w64 define a macro for
2076 # localtime_r/gmtime_r.
2077 #
2078 # Some versions of Mingw-w64 will define functions
2079 # for localtime_r/gmtime_r, but only if you have
2080 # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
2081 # though, unistd.h and pthread.h both define
2082 # that for you.
2083 #
2084 # So this #undef localtime_r and #include <unistd.h>
2085 # are not in fact redundant.
2086cat > $TMPC << EOF
2087#include <unistd.h>
2088#include <time.h>
2089#undef localtime_r
2090int main(void) { localtime_r(NULL, NULL); return 0; }
2091EOF
2092 if compile_prog "" "" ; then
2093 localtime_r="yes"
2094 else
2095 localtime_r="no"
2096 fi
2097fi
2098
779ab5e3
SW
2099##########################################
2100# pkg-config probe
2101
2102if ! has "$pkg_config_exe"; then
76ad07a4 2103 error_exit "pkg-config binary '$pkg_config_exe' not found"
779ab5e3
SW
2104fi
2105
b0a47e79
JQ
2106##########################################
2107# NPTL probe
2108
24cb36a6 2109if test "$linux_user" = "yes"; then
b0a47e79 2110 cat > $TMPC <<EOF
bd0c5661 2111#include <sched.h>
30813cea 2112#include <linux/futex.h>
182eacc0 2113int main(void) {
bd0c5661
PB
2114#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
2115#error bork
2116#endif
182eacc0 2117 return 0;
bd0c5661
PB
2118}
2119EOF
24cb36a6 2120 if ! compile_object ; then
21684af0 2121 feature_not_found "nptl" "Install glibc and linux kernel headers."
b0a47e79 2122 fi
bd0c5661
PB
2123fi
2124
99f2dbd3 2125#########################################
ac62922e
AZ
2126# zlib check
2127
1ece9905
AL
2128if test "$zlib" != "no" ; then
2129 cat > $TMPC << EOF
ac62922e
AZ
2130#include <zlib.h>
2131int main(void) { zlibVersion(); return 0; }
2132EOF
1ece9905
AL
2133 if compile_prog "" "-lz" ; then
2134 :
2135 else
76ad07a4
PM
2136 error_exit "zlib check failed" \
2137 "Make sure to have the zlib libs and headers installed."
1ece9905 2138 fi
ac62922e 2139fi
eb0ecd5a 2140LIBS="$LIBS -lz"
ac62922e 2141
607dacd0
QN
2142##########################################
2143# lzo check
2144
2145if test "$lzo" != "no" ; then
2146 cat > $TMPC << EOF
2147#include <lzo/lzo1x.h>
2148int main(void) { lzo_version(); return 0; }
2149EOF
2150 if compile_prog "" "-llzo2" ; then
b25c9dff
SW
2151 libs_softmmu="$libs_softmmu -llzo2"
2152 lzo="yes"
607dacd0 2153 else
b25c9dff
SW
2154 if test "$lzo" = "yes"; then
2155 feature_not_found "liblzo2" "Install liblzo2 devel"
2156 fi
2157 lzo="no"
607dacd0 2158 fi
607dacd0
QN
2159fi
2160
2161##########################################
2162# snappy check
2163
2164if test "$snappy" != "no" ; then
2165 cat > $TMPC << EOF
2166#include <snappy-c.h>
2167int main(void) { snappy_max_compressed_length(4096); return 0; }
2168EOF
2169 if compile_prog "" "-lsnappy" ; then
b25c9dff
SW
2170 libs_softmmu="$libs_softmmu -lsnappy"
2171 snappy="yes"
607dacd0 2172 else
b25c9dff
SW
2173 if test "$snappy" = "yes"; then
2174 feature_not_found "libsnappy" "Install libsnappy devel"
2175 fi
2176 snappy="no"
607dacd0 2177 fi
607dacd0
QN
2178fi
2179
6b383c08
PW
2180##########################################
2181# bzip2 check
2182
2183if test "$bzip2" != "no" ; then
2184 cat > $TMPC << EOF
2185#include <bzlib.h>
2186int main(void) { BZ2_bzlibVersion(); return 0; }
2187EOF
2188 if compile_prog "" "-lbz2" ; then
2189 bzip2="yes"
2190 else
2191 if test "$bzip2" = "yes"; then
2192 feature_not_found "libbzip2" "Install libbzip2 devel"
2193 fi
2194 bzip2="no"
2195 fi
2196fi
2197
f794573e
EO
2198##########################################
2199# libseccomp check
2200
2201if test "$seccomp" != "no" ; then
693e5910
AJ
2202 case "$cpu" in
2203 i386|x86_64)
ba060c53 2204 libseccomp_minver="2.1.0"
693e5910 2205 ;;
5ce43972
JH
2206 mips)
2207 libseccomp_minver="2.2.0"
2208 ;;
693e5910
AJ
2209 arm|aarch64)
2210 libseccomp_minver="2.2.3"
2211 ;;
3aa35fcf 2212 ppc|ppc64|s390x)
3e684455
MS
2213 libseccomp_minver="2.3.0"
2214 ;;
693e5910
AJ
2215 *)
2216 libseccomp_minver=""
2217 ;;
2218 esac
2219
2220 if test "$libseccomp_minver" != "" &&
2221 $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
c3883e1f
FZ
2222 seccomp_cflags="$($pkg_config --cflags libseccomp)"
2223 seccomp_libs="$($pkg_config --libs libseccomp)"
693e5910 2224 seccomp="yes"
f794573e 2225 else
693e5910
AJ
2226 if test "$seccomp" = "yes" ; then
2227 if test "$libseccomp_minver" != "" ; then
2228 feature_not_found "libseccomp" \
2229 "Install libseccomp devel >= $libseccomp_minver"
2230 else
2231 feature_not_found "libseccomp" \
2232 "libseccomp is not supported for host cpu $cpu"
2233 fi
2234 fi
2235 seccomp="no"
f794573e
EO
2236 fi
2237fi
e37630ca
AL
2238##########################################
2239# xen probe
2240
fc321b4b 2241if test "$xen" != "no" ; then
c1cdd9d5
JG
2242 # Check whether Xen library path is specified via --extra-ldflags to avoid
2243 # overriding this setting with pkg-config output. If not, try pkg-config
2244 # to obtain all needed flags.
2245
2246 if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2247 $pkg_config --exists xencontrol ; then
2248 xen_ctrl_version="$(printf '%d%02d%02d' \
2249 $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
2250 xen=yes
2251 xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab"
2252 xen_pc="$xen_pc xenevtchn xendevicemodel"
58ea9a7a
AP
2253 if $pkg_config --exists xentoolcore; then
2254 xen_pc="$xen_pc xentoolcore"
2255 fi
c1cdd9d5
JG
2256 QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags $xen_pc)"
2257 libs_softmmu="$($pkg_config --libs $xen_pc) $libs_softmmu"
2258 LDFLAGS="$($pkg_config --libs $xen_pc) $LDFLAGS"
2259 else
d5b93ddf 2260
c1cdd9d5 2261 xen_libs="-lxenstore -lxenctrl -lxenguest"
d9506cab 2262 xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
50ced5b3 2263
c1cdd9d5
JG
2264 # First we test whether Xen headers and libraries are available.
2265 # If no, we are done and there is no Xen support.
2266 # If yes, more tests are run to detect the Xen version.
2267
2268 # Xen (any)
2269 cat > $TMPC <<EOF
e37630ca 2270#include <xenctrl.h>
50ced5b3
SW
2271int main(void) {
2272 return 0;
2273}
2274EOF
c1cdd9d5
JG
2275 if ! compile_prog "" "$xen_libs" ; then
2276 # Xen not found
2277 if test "$xen" = "yes" ; then
2278 feature_not_found "xen" "Install xen devel"
2279 fi
2280 xen=no
50ced5b3 2281
c1cdd9d5
JG
2282 # Xen unstable
2283 elif
2284 cat > $TMPC <<EOF &&
2cbf8903
RL
2285#undef XC_WANT_COMPAT_DEVICEMODEL_API
2286#define __XEN_TOOLS__
2287#include <xendevicemodel.h>
d3c49ebb 2288#include <xenforeignmemory.h>
2cbf8903
RL
2289int main(void) {
2290 xendevicemodel_handle *xd;
d3c49ebb 2291 xenforeignmemory_handle *xfmem;
2cbf8903
RL
2292
2293 xd = xendevicemodel_open(0, 0);
2294 xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
2295
d3c49ebb
PD
2296 xfmem = xenforeignmemory_open(0, 0);
2297 xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
2298
2cbf8903
RL
2299 return 0;
2300}
2301EOF
2302 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
2303 then
2304 xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
2305 xen_ctrl_version=41100
2306 xen=yes
2307 elif
2308 cat > $TMPC <<EOF &&
5ba3d756
ID
2309#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2310#include <xenforeignmemory.h>
58ea9a7a 2311#include <xentoolcore.h>
5ba3d756
ID
2312int main(void) {
2313 xenforeignmemory_handle *xfmem;
2314
2315 xfmem = xenforeignmemory_open(0, 0);
2316 xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
58ea9a7a 2317 xentoolcore_restrict_all(0);
5ba3d756
ID
2318
2319 return 0;
2320}
2321EOF
58ea9a7a 2322 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
5ba3d756 2323 then
58ea9a7a 2324 xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
5ba3d756
ID
2325 xen_ctrl_version=41000
2326 xen=yes
2327 elif
2328 cat > $TMPC <<EOF &&
da8090cc
PD
2329#undef XC_WANT_COMPAT_DEVICEMODEL_API
2330#define __XEN_TOOLS__
2331#include <xendevicemodel.h>
2332int main(void) {
2333 xendevicemodel_handle *xd;
2334
2335 xd = xendevicemodel_open(0, 0);
2336 xendevicemodel_close(xd);
50ced5b3 2337
da8090cc
PD
2338 return 0;
2339}
2340EOF
c1cdd9d5
JG
2341 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2342 then
2343 xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2344 xen_ctrl_version=40900
2345 xen=yes
2346 elif
2347 cat > $TMPC <<EOF &&
b6eb9b45
PS
2348/*
2349 * If we have stable libs the we don't want the libxc compat
2350 * layers, regardless of what CFLAGS we may have been given.
2351 *
2352 * Also, check if xengnttab_grant_copy_segment_t is defined and
2353 * grant copy operation is implemented.
2354 */
2355#undef XC_WANT_COMPAT_EVTCHN_API
2356#undef XC_WANT_COMPAT_GNTTAB_API
2357#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2358#include <xenctrl.h>
2359#include <xenstore.h>
2360#include <xenevtchn.h>
2361#include <xengnttab.h>
2362#include <xenforeignmemory.h>
2363#include <stdint.h>
2364#include <xen/hvm/hvm_info_table.h>
2365#if !defined(HVM_MAX_VCPUS)
2366# error HVM_MAX_VCPUS not defined
2367#endif
2368int main(void) {
2369 xc_interface *xc = NULL;
2370 xenforeignmemory_handle *xfmem;
2371 xenevtchn_handle *xe;
2372 xengnttab_handle *xg;
2373 xen_domain_handle_t handle;
2374 xengnttab_grant_copy_segment_t* seg = NULL;
2375
2376 xs_daemon_open();
2377
2378 xc = xc_interface_open(0, 0, 0);
2379 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2380 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2381 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2382 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2383 xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2384
2385 xfmem = xenforeignmemory_open(0, 0);
2386 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2387
2388 xe = xenevtchn_open(0, 0);
2389 xenevtchn_fd(xe);
2390
2391 xg = xengnttab_open(0, 0);
2392 xengnttab_grant_copy(xg, 0, seg);
2393
2394 return 0;
2395}
2396EOF
c1cdd9d5
JG
2397 compile_prog "" "$xen_libs $xen_stable_libs"
2398 then
2399 xen_ctrl_version=40800
2400 xen=yes
2401 elif
2402 cat > $TMPC <<EOF &&
5eeb39c2
IC
2403/*
2404 * If we have stable libs the we don't want the libxc compat
2405 * layers, regardless of what CFLAGS we may have been given.
2406 */
2407#undef XC_WANT_COMPAT_EVTCHN_API
2408#undef XC_WANT_COMPAT_GNTTAB_API
2409#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2410#include <xenctrl.h>
2411#include <xenstore.h>
2412#include <xenevtchn.h>
2413#include <xengnttab.h>
2414#include <xenforeignmemory.h>
2415#include <stdint.h>
2416#include <xen/hvm/hvm_info_table.h>
2417#if !defined(HVM_MAX_VCPUS)
2418# error HVM_MAX_VCPUS not defined
2419#endif
2420int main(void) {
2421 xc_interface *xc = NULL;
2422 xenforeignmemory_handle *xfmem;
2423 xenevtchn_handle *xe;
2424 xengnttab_handle *xg;
2425 xen_domain_handle_t handle;
2426
2427 xs_daemon_open();
2428
2429 xc = xc_interface_open(0, 0, 0);
2430 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2431 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2432 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2433 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2434 xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2435
2436 xfmem = xenforeignmemory_open(0, 0);
2437 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2438
2439 xe = xenevtchn_open(0, 0);
2440 xenevtchn_fd(xe);
2441
2442 xg = xengnttab_open(0, 0);
2443 xengnttab_map_grant_ref(xg, 0, 0, 0);
2444
2445 return 0;
2446}
2447EOF
c1cdd9d5
JG
2448 compile_prog "" "$xen_libs $xen_stable_libs"
2449 then
2450 xen_ctrl_version=40701
2451 xen=yes
2452 elif
2453 cat > $TMPC <<EOF &&
50ced5b3 2454#include <xenctrl.h>
cdadde39
RPM
2455#include <stdint.h>
2456int main(void) {
2457 xc_interface *xc = NULL;
2458 xen_domain_handle_t handle;
2459 xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2460 return 0;
2461}
2462EOF
c1cdd9d5
JG
2463 compile_prog "" "$xen_libs"
2464 then
2465 xen_ctrl_version=40700
2466 xen=yes
2467
2468 # Xen 4.6
2469 elif
2470 cat > $TMPC <<EOF &&
cdadde39 2471#include <xenctrl.h>
e108a3c1 2472#include <xenstore.h>
d5b93ddf
AP
2473#include <stdint.h>
2474#include <xen/hvm/hvm_info_table.h>
2475#if !defined(HVM_MAX_VCPUS)
2476# error HVM_MAX_VCPUS not defined
2477#endif
d8b441a3
JB
2478int main(void) {
2479 xc_interface *xc;
2480 xs_daemon_open();
2481 xc = xc_interface_open(0, 0, 0);
2482 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2483 xc_gnttab_open(NULL, 0);
2484 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2485 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2486 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
20a544c7 2487 xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
d8b441a3
JB
2488 return 0;
2489}
2490EOF
c1cdd9d5
JG
2491 compile_prog "" "$xen_libs"
2492 then
2493 xen_ctrl_version=40600
2494 xen=yes
2495
2496 # Xen 4.5
2497 elif
2498 cat > $TMPC <<EOF &&
d8b441a3
JB
2499#include <xenctrl.h>
2500#include <xenstore.h>
2501#include <stdint.h>
2502#include <xen/hvm/hvm_info_table.h>
2503#if !defined(HVM_MAX_VCPUS)
2504# error HVM_MAX_VCPUS not defined
2505#endif
3996e85c
PD
2506int main(void) {
2507 xc_interface *xc;
2508 xs_daemon_open();
2509 xc = xc_interface_open(0, 0, 0);
2510 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2511 xc_gnttab_open(NULL, 0);
2512 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2513 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2514 xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
2515 return 0;
2516}
2517EOF
c1cdd9d5
JG
2518 compile_prog "" "$xen_libs"
2519 then
2520 xen_ctrl_version=40500
2521 xen=yes
3996e85c 2522
c1cdd9d5
JG
2523 elif
2524 cat > $TMPC <<EOF &&
3996e85c
PD
2525#include <xenctrl.h>
2526#include <xenstore.h>
2527#include <stdint.h>
2528#include <xen/hvm/hvm_info_table.h>
2529#if !defined(HVM_MAX_VCPUS)
2530# error HVM_MAX_VCPUS not defined
2531#endif
8688e065
SS
2532int main(void) {
2533 xc_interface *xc;
2534 xs_daemon_open();
2535 xc = xc_interface_open(0, 0, 0);
2536 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2537 xc_gnttab_open(NULL, 0);
2538 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2539 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2540 return 0;
2541}
2542EOF
c1cdd9d5
JG
2543 compile_prog "" "$xen_libs"
2544 then
2545 xen_ctrl_version=40200
2546 xen=yes
8688e065 2547
c1cdd9d5
JG
2548 else
2549 if test "$xen" = "yes" ; then
2550 feature_not_found "xen (unsupported version)" \
2551 "Install a supported xen (xen 4.2 or newer)"
2552 fi
2553 xen=no
fc321b4b 2554 fi
d5b93ddf 2555
c1cdd9d5
JG
2556 if test "$xen" = yes; then
2557 if test $xen_ctrl_version -ge 40701 ; then
2558 libs_softmmu="$xen_stable_libs $libs_softmmu"
2559 fi
2560 libs_softmmu="$xen_libs $libs_softmmu"
5eeb39c2 2561 fi
d5b93ddf 2562 fi
e37630ca
AL
2563fi
2564
eb6fda0f 2565if test "$xen_pci_passthrough" != "no"; then
edfb07ed 2566 if test "$xen" = "yes" && test "$linux" = "yes"; then
eb6fda0f
AP
2567 xen_pci_passthrough=yes
2568 else
2569 if test "$xen_pci_passthrough" = "yes"; then
76ad07a4
PM
2570 error_exit "User requested feature Xen PCI Passthrough" \
2571 " but this feature requires /sys from Linux"
eb6fda0f
AP
2572 fi
2573 xen_pci_passthrough=no
2574 fi
2575fi
2576
64a7ad6f
IC
2577if test "$xen_pv_domain_build" = "yes" &&
2578 test "$xen" != "yes"; then
2579 error_exit "User requested Xen PV domain builder support" \
2580 "which requires Xen support."
2581fi
2582
d661d9a4
JTV
2583##########################################
2584# Windows Hypervisor Platform accelerator (WHPX) check
2585if test "$whpx" != "no" ; then
327fccb2 2586 if check_include "WinHvPlatform.h" && check_include "WinHvEmulation.h"; then
d661d9a4
JTV
2587 whpx="yes"
2588 else
2589 if test "$whpx" = "yes"; then
53537bb1 2590 feature_not_found "WinHvPlatform" "WinHvEmulation is not installed"
d661d9a4
JTV
2591 fi
2592 whpx="no"
2593 fi
2594fi
2595
dfffc653
JQ
2596##########################################
2597# Sparse probe
2598if test "$sparse" != "no" ; then
0dba6195 2599 if has cgcc; then
dfffc653
JQ
2600 sparse=yes
2601 else
2602 if test "$sparse" = "yes" ; then
21684af0 2603 feature_not_found "sparse" "Install sparse binary"
dfffc653
JQ
2604 fi
2605 sparse=no
2606 fi
2607fi
2608
f676c67e
JW
2609##########################################
2610# X11 probe
f676c67e 2611if $pkg_config --exists "x11"; then
8781595b 2612 have_x11=yes
89138857
SW
2613 x11_cflags=$($pkg_config --cflags x11)
2614 x11_libs=$($pkg_config --libs x11)
f676c67e
JW
2615fi
2616
a4ccabcf
AL
2617##########################################
2618# GTK probe
2619
2620if test "$gtk" != "no"; then
5a464e6c
PX
2621 if test "$gtkabi" = ""; then
2622 # The GTK ABI was not specified explicitly, so try whether 3.0 is available.
2623 # Use 2.0 as a fallback if that is available.
2624 if $pkg_config --exists "gtk+-3.0 >= 3.0.0"; then
2625 gtkabi=3.0
2626 elif $pkg_config --exists "gtk+-2.0 >= 2.18.0"; then
2627 gtkabi=2.0
2628 else
2629 gtkabi=3.0
2630 fi
2631 fi
528de90a 2632 gtkpackage="gtk+-$gtkabi"
0a337ed0 2633 gtkx11package="gtk+-x11-$gtkabi"
528de90a
DB
2634 if test "$gtkabi" = "3.0" ; then
2635 gtkversion="3.0.0"
bbbf9bfb
SW
2636 else
2637 gtkversion="2.18.0"
2638 fi
2639 if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
89138857
SW
2640 gtk_cflags=$($pkg_config --cflags $gtkpackage)
2641 gtk_libs=$($pkg_config --libs $gtkpackage)
2642 gtk_version=$($pkg_config --modversion $gtkpackage)
0a337ed0 2643 if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
8781595b 2644 need_x11=yes
f676c67e
JW
2645 gtk_cflags="$gtk_cflags $x11_cflags"
2646 gtk_libs="$gtk_libs $x11_libs"
0a337ed0 2647 fi
bbbf9bfb
SW
2648 gtk="yes"
2649 elif test "$gtk" = "yes"; then
5fe309ff 2650 feature_not_found "gtk" "Install gtk3-devel"
bbbf9bfb
SW
2651 else
2652 gtk="no"
2653 fi
2654fi
2655
ddbb0d09
DB
2656
2657##########################################
2658# GNUTLS probe
2659
37371299
PM
2660gnutls_works() {
2661 # Unfortunately some distros have bad pkg-config information for gnutls
2662 # such that it claims to exist but you get a compiler error if you try
2663 # to use the options returned by --libs. Specifically, Ubuntu for --static
2664 # builds doesn't work:
2665 # https://bugs.launchpad.net/ubuntu/+source/gnutls26/+bug/1478035
2666 #
2667 # So sanity check the cflags/libs before assuming gnutls can be used.
2668 if ! $pkg_config --exists "gnutls"; then
2669 return 1
2670 fi
2671
2672 write_c_skeleton
2673 compile_prog "$($pkg_config --cflags gnutls)" "$($pkg_config --libs gnutls)"
2674}
2675
62893b67 2676gnutls_gcrypt=no
ed754746 2677gnutls_nettle=no
ddbb0d09 2678if test "$gnutls" != "no"; then
37371299 2679 if gnutls_works; then
89138857
SW
2680 gnutls_cflags=$($pkg_config --cflags gnutls)
2681 gnutls_libs=$($pkg_config --libs gnutls)
ddbb0d09
DB
2682 libs_softmmu="$gnutls_libs $libs_softmmu"
2683 libs_tools="$gnutls_libs $libs_tools"
2684 QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
2685 gnutls="yes"
2686
b917da4c
DB
2687 # gnutls_rnd requires >= 2.11.0
2688 if $pkg_config --exists "gnutls >= 2.11.0"; then
2689 gnutls_rnd="yes"
2690 else
2691 gnutls_rnd="no"
2692 fi
2693
62893b67
DB
2694 if $pkg_config --exists 'gnutls >= 3.0'; then
2695 gnutls_gcrypt=no
ed754746 2696 gnutls_nettle=yes
62893b67 2697 elif $pkg_config --exists 'gnutls >= 2.12'; then
89138857 2698 case $($pkg_config --libs --static gnutls) in
ed754746
DB
2699 *gcrypt*)
2700 gnutls_gcrypt=yes
2701 gnutls_nettle=no
2702 ;;
2703 *nettle*)
2704 gnutls_gcrypt=no
2705 gnutls_nettle=yes
2706 ;;
2707 *)
2708 gnutls_gcrypt=yes
2709 gnutls_nettle=no
2710 ;;
62893b67
DB
2711 esac
2712 else
2713 gnutls_gcrypt=yes
ed754746 2714 gnutls_nettle=no
62893b67 2715 fi
ddbb0d09
DB
2716 elif test "$gnutls" = "yes"; then
2717 feature_not_found "gnutls" "Install gnutls devel"
2718 else
2719 gnutls="no"
b917da4c 2720 gnutls_rnd="no"
ddbb0d09
DB
2721 fi
2722else
b917da4c 2723 gnutls_rnd="no"
ddbb0d09
DB
2724fi
2725
91bfcdb0
DB
2726
2727# If user didn't give a --disable/enable-gcrypt flag,
2728# then mark as disabled if user requested nettle
2729# explicitly, or if gnutls links to nettle
2730if test -z "$gcrypt"
2731then
2732 if test "$nettle" = "yes" || test "$gnutls_nettle" = "yes"
2733 then
2734 gcrypt="no"
2735 fi
2736fi
2737
2738# If user didn't give a --disable/enable-nettle flag,
2739# then mark as disabled if user requested gcrypt
2740# explicitly, or if gnutls links to gcrypt
2741if test -z "$nettle"
2742then
2743 if test "$gcrypt" = "yes" || test "$gnutls_gcrypt" = "yes"
2744 then
2745 nettle="no"
2746 fi
2747fi
2748
2749has_libgcrypt_config() {
2750 if ! has "libgcrypt-config"
2751 then
2752 return 1
2753 fi
2754
2755 if test -n "$cross_prefix"
2756 then
89138857 2757 host=$(libgcrypt-config --host)
91bfcdb0
DB
2758 if test "$host-" != $cross_prefix
2759 then
2760 return 1
2761 fi
2762 fi
2763
2764 return 0
2765}
2766
2767if test "$gcrypt" != "no"; then
2768 if has_libgcrypt_config; then
89138857
SW
2769 gcrypt_cflags=$(libgcrypt-config --cflags)
2770 gcrypt_libs=$(libgcrypt-config --libs)
91bfcdb0
DB
2771 # Debian has remove -lgpg-error from libgcrypt-config
2772 # as it "spreads unnecessary dependencies" which in
2773 # turn breaks static builds...
2774 if test "$static" = "yes"
2775 then
2776 gcrypt_libs="$gcrypt_libs -lgpg-error"
2777 fi
62893b67
DB
2778 libs_softmmu="$gcrypt_libs $libs_softmmu"
2779 libs_tools="$gcrypt_libs $libs_tools"
2780 QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
91bfcdb0
DB
2781 gcrypt="yes"
2782 if test -z "$nettle"; then
2783 nettle="no"
2784 fi
37788f25
DB
2785
2786 cat > $TMPC << EOF
2787#include <gcrypt.h>
2788int main(void) {
2789 gcry_kdf_derive(NULL, 0, GCRY_KDF_PBKDF2,
2790 GCRY_MD_SHA256,
2791 NULL, 0, 0, 0, NULL);
2792 return 0;
2793}
2794EOF
2795 if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
2796 gcrypt_kdf=yes
2797 fi
1f923c70
LM
2798
2799 cat > $TMPC << EOF
2800#include <gcrypt.h>
2801int main(void) {
2802 gcry_mac_hd_t handle;
2803 gcry_mac_open(&handle, GCRY_MAC_HMAC_MD5,
2804 GCRY_MAC_FLAG_SECURE, NULL);
2805 return 0;
2806}
2807EOF
2808 if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
2809 gcrypt_hmac=yes
2810 fi
62893b67 2811 else
91bfcdb0
DB
2812 if test "$gcrypt" = "yes"; then
2813 feature_not_found "gcrypt" "Install gcrypt devel"
2814 else
2815 gcrypt="no"
2816 fi
62893b67
DB
2817 fi
2818fi
2819
ddbb0d09 2820
91bfcdb0 2821if test "$nettle" != "no"; then
ed754746 2822 if $pkg_config --exists "nettle"; then
89138857
SW
2823 nettle_cflags=$($pkg_config --cflags nettle)
2824 nettle_libs=$($pkg_config --libs nettle)
2825 nettle_version=$($pkg_config --modversion nettle)
ed754746
DB
2826 libs_softmmu="$nettle_libs $libs_softmmu"
2827 libs_tools="$nettle_libs $libs_tools"
2828 QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
91bfcdb0 2829 nettle="yes"
fff2f982
DB
2830
2831 cat > $TMPC << EOF
9e87a691 2832#include <stddef.h>
fff2f982
DB
2833#include <nettle/pbkdf2.h>
2834int main(void) {
2835 pbkdf2_hmac_sha256(8, NULL, 1000, 8, NULL, 8, NULL);
2836 return 0;
2837}
2838EOF
2839 if compile_prog "$nettle_cflags" "$nettle_libs" ; then
2840 nettle_kdf=yes
2841 fi
ed754746 2842 else
91bfcdb0
DB
2843 if test "$nettle" = "yes"; then
2844 feature_not_found "nettle" "Install nettle devel"
2845 else
2846 nettle="no"
2847 fi
ed754746
DB
2848 fi
2849fi
2850
91bfcdb0
DB
2851if test "$gcrypt" = "yes" && test "$nettle" = "yes"
2852then
2853 error_exit "Only one of gcrypt & nettle can be enabled"
2854fi
2855
9a2fd434
DB
2856##########################################
2857# libtasn1 - only for the TLS creds/session test suite
2858
2859tasn1=yes
90246037
DB
2860tasn1_cflags=""
2861tasn1_libs=""
9a2fd434 2862if $pkg_config --exists "libtasn1"; then
89138857
SW
2863 tasn1_cflags=$($pkg_config --cflags libtasn1)
2864 tasn1_libs=$($pkg_config --libs libtasn1)
9a2fd434
DB
2865else
2866 tasn1=no
2867fi
2868
ed754746 2869
559607ea
DB
2870##########################################
2871# getifaddrs (for tests/test-io-channel-socket )
2872
2873have_ifaddrs_h=yes
2874if ! check_include "ifaddrs.h" ; then
2875 have_ifaddrs_h=no
2876fi
2877
bbbf9bfb
SW
2878##########################################
2879# VTE probe
2880
2881if test "$vte" != "no"; then
2882 if test "$gtkabi" = "3.0"; then
c6feff9e
CR
2883 vteminversion="0.32.0"
2884 if $pkg_config --exists "vte-2.91"; then
2885 vtepackage="vte-2.91"
2886 else
2887 vtepackage="vte-2.90"
2888 fi
528de90a 2889 else
528de90a 2890 vtepackage="vte"
c6feff9e 2891 vteminversion="0.24.0"
528de90a 2892 fi
c6feff9e 2893 if $pkg_config --exists "$vtepackage >= $vteminversion"; then
89138857
SW
2894 vte_cflags=$($pkg_config --cflags $vtepackage)
2895 vte_libs=$($pkg_config --libs $vtepackage)
2896 vteversion=$($pkg_config --modversion $vtepackage)
bbbf9bfb
SW
2897 vte="yes"
2898 elif test "$vte" = "yes"; then
9e04c683 2899 if test "$gtkabi" = "3.0"; then
c6feff9e 2900 feature_not_found "vte" "Install libvte-2.90/2.91 devel"
9e04c683
SW
2901 else
2902 feature_not_found "vte" "Install libvte devel"
2903 fi
0d185e63 2904 else
bbbf9bfb 2905 vte="no"
a4ccabcf
AL
2906 fi
2907fi
2908
11d9f695
FB
2909##########################################
2910# SDL probe
2911
3ec87ffe
PB
2912# Look for sdl configuration program (pkg-config or sdl-config). Try
2913# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
47c03744 2914
c6093a05
PX
2915sdl_probe ()
2916{
2917 sdl_too_old=no
2918 if test "$sdlabi" = ""; then
2919 if $pkg_config --exists "sdl2"; then
2920 sdlabi=2.0
2921 elif $pkg_config --exists "sdl"; then
2922 sdlabi=1.2
2923 else
2924 sdlabi=2.0
2925 fi
2926 fi
ee8466d0 2927
c6093a05
PX
2928 if test $sdlabi = "2.0"; then
2929 sdl_config=$sdl2_config
2930 sdlname=sdl2
2931 sdlconfigname=sdl2_config
2932 elif test $sdlabi = "1.2"; then
2933 sdlname=sdl
2934 sdlconfigname=sdl_config
2935 else
2936 error_exit "Unknown sdlabi $sdlabi, must be 1.2 or 2.0"
2937 fi
47c03744 2938
c6093a05
PX
2939 if test "$(basename $sdl_config)" != $sdlconfigname && ! has ${sdl_config}; then
2940 sdl_config=$sdlconfigname
2941 fi
3ec87ffe 2942
c6093a05
PX
2943 if $pkg_config $sdlname --exists; then
2944 sdlconfig="$pkg_config $sdlname"
2945 sdlversion=$($sdlconfig --modversion 2>/dev/null)
2946 elif has ${sdl_config}; then
2947 sdlconfig="$sdl_config"
2948 sdlversion=$($sdlconfig --version)
2949 else
2950 if test "$sdl" = "yes" ; then
2951 feature_not_found "sdl" "Install SDL2-devel"
2952 fi
2953 sdl=no
2954 # no need to do the rest
2955 return
2956 fi
2957 if test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
2958 echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
a0dfd8a4 2959 fi
11d9f695 2960
ac119f9d 2961 cat > $TMPC << EOF
11d9f695
FB
2962#include <SDL.h>
2963#undef main /* We don't want SDL to override our main() */
2964int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
2965EOF
89138857 2966 sdl_cflags=$($sdlconfig --cflags 2>/dev/null)
2ca5c430 2967 sdl_cflags="$sdl_cflags -Wno-undef" # workaround 2.0.8 bug
74f42e18 2968 if test "$static" = "yes" ; then
5f37e6d4
TH
2969 if $pkg_config $sdlname --exists; then
2970 sdl_libs=$($pkg_config $sdlname --static --libs 2>/dev/null)
2971 else
2972 sdl_libs=$($sdlconfig --static-libs 2>/dev/null)
2973 fi
74f42e18 2974 else
89138857 2975 sdl_libs=$($sdlconfig --libs 2>/dev/null)
74f42e18 2976 fi
52166aa0 2977 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
89138857 2978 if test $(echo $sdlversion | sed 's/[^0-9]//g') -lt 121 ; then
ac119f9d
JQ
2979 sdl_too_old=yes
2980 else
a30878e7 2981 sdl=yes
ac119f9d 2982 fi
cd01b4a3 2983
67c274d3 2984 # static link with sdl ? (note: sdl.pc's --static --libs is broken)
ac119f9d 2985 if test "$sdl" = "yes" -a "$static" = "yes" ; then
67c274d3 2986 if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
89138857
SW
2987 sdl_libs="$sdl_libs $(aalib-config --static-libs 2>/dev/null)"
2988 sdl_cflags="$sdl_cflags $(aalib-config --cflags 2>/dev/null)"
ac119f9d 2989 fi
52166aa0 2990 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
ac119f9d
JQ
2991 :
2992 else
2993 sdl=no
2994 fi
2995 fi # static link
c4198157
JQ
2996 else # sdl not found
2997 if test "$sdl" = "yes" ; then
21684af0 2998 feature_not_found "sdl" "Install SDL devel"
c4198157
JQ
2999 fi
3000 sdl=no
ac119f9d 3001 fi # sdl compile test
c6093a05
PX
3002}
3003
3004if test "$sdl" != "no" ; then
3005 sdl_probe
a68551bc 3006fi
11d9f695 3007
5368a422 3008if test "$sdl" = "yes" ; then
ac119f9d 3009 cat > $TMPC <<EOF
5368a422
AL
3010#include <SDL.h>
3011#if defined(SDL_VIDEO_DRIVER_X11)
3012#include <X11/XKBlib.h>
3013#else
3014#error No x11 support
3015#endif
3016int main(void) { return 0; }
3017EOF
f676c67e 3018 if compile_prog "$sdl_cflags $x11_cflags" "$sdl_libs $x11_libs" ; then
8781595b 3019 need_x11=yes
f676c67e
JW
3020 sdl_cflags="$sdl_cflags $x11_cflags"
3021 sdl_libs="$sdl_libs $x11_libs"
ac119f9d 3022 fi
5368a422
AL
3023fi
3024
2da776db
MH
3025##########################################
3026# RDMA needs OpenFabrics libraries
3027if test "$rdma" != "no" ; then
3028 cat > $TMPC <<EOF
3029#include <rdma/rdma_cma.h>
3030int main(void) { return 0; }
3031EOF
ef6d4ccd 3032 rdma_libs="-lrdmacm -libverbs -libumad"
2da776db
MH
3033 if compile_prog "" "$rdma_libs" ; then
3034 rdma="yes"
ef6d4ccd 3035 libs_softmmu="$libs_softmmu $rdma_libs"
2da776db
MH
3036 else
3037 if test "$rdma" = "yes" ; then
3038 error_exit \
ef6d4ccd 3039 " OpenFabrics librdmacm/libibverbs/libibumad not present." \
2da776db 3040 " Your options:" \
ef6d4ccd 3041 " (1) Fast: Install infiniband packages (devel) from your distro." \
2da776db
MH
3042 " (2) Cleanest: Install libraries from www.openfabrics.org" \
3043 " (3) Also: Install softiwarp if you don't have RDMA hardware"
3044 fi
3045 rdma="no"
3046 fi
3047fi
3048
95c6bff3 3049
2f9606b3
AL
3050##########################################
3051# VNC SASL detection
821601ea 3052if test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
ea784e3b 3053 cat > $TMPC <<EOF
2f9606b3
AL
3054#include <sasl/sasl.h>
3055#include <stdio.h>
3056int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
3057EOF
ea784e3b
JQ
3058 # Assuming Cyrus-SASL installed in /usr prefix
3059 vnc_sasl_cflags=""
3060 vnc_sasl_libs="-lsasl2"
3061 if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
3062 vnc_sasl=yes
3063 libs_softmmu="$vnc_sasl_libs $libs_softmmu"
ca273d58 3064 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
ea784e3b
JQ
3065 else
3066 if test "$vnc_sasl" = "yes" ; then
21684af0 3067 feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
2f9606b3 3068 fi
ea784e3b
JQ
3069 vnc_sasl=no
3070 fi
2f9606b3
AL
3071fi
3072
2f6f5c7a
CC
3073##########################################
3074# VNC JPEG detection
821601ea 3075if test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
2f6f5c7a
CC
3076cat > $TMPC <<EOF
3077#include <stdio.h>
3078#include <jpeglib.h>
3079int main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
3080EOF
3081 vnc_jpeg_cflags=""
3082 vnc_jpeg_libs="-ljpeg"
3083 if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
3084 vnc_jpeg=yes
3085 libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
ca273d58 3086 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
2f6f5c7a
CC
3087 else
3088 if test "$vnc_jpeg" = "yes" ; then
21684af0 3089 feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
2f6f5c7a
CC
3090 fi
3091 vnc_jpeg=no
3092 fi
3093fi
3094
efe556ad
CC
3095##########################################
3096# VNC PNG detection
821601ea 3097if test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
efe556ad
CC
3098cat > $TMPC <<EOF
3099//#include <stdio.h>
3100#include <png.h>
832ce9c2 3101#include <stddef.h>
efe556ad
CC
3102int main(void) {
3103 png_structp png_ptr;
3104 png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
7edc3fed 3105 return png_ptr != 0;
efe556ad
CC
3106}
3107EOF
65d5d3f9 3108 if $pkg_config libpng --exists; then
89138857
SW
3109 vnc_png_cflags=$($pkg_config libpng --cflags)
3110 vnc_png_libs=$($pkg_config libpng --libs)
9af8025e 3111 else
efe556ad
CC
3112 vnc_png_cflags=""
3113 vnc_png_libs="-lpng"
9af8025e 3114 fi
efe556ad
CC
3115 if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
3116 vnc_png=yes
3117 libs_softmmu="$vnc_png_libs $libs_softmmu"
9af8025e 3118 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
efe556ad
CC
3119 else
3120 if test "$vnc_png" = "yes" ; then
21684af0 3121 feature_not_found "vnc-png" "Install libpng devel"
efe556ad
CC
3122 fi
3123 vnc_png=no
3124 fi
3125fi
3126
6a021536
GH
3127##########################################
3128# xkbcommon probe
3129if test "$xkbcommon" != "no" ; then
3130 if $pkg_config xkbcommon --exists; then
3131 xkbcommon_cflags=$($pkg_config xkbcommon --cflags)
3132 xkbcommon_libs=$($pkg_config xkbcommon --libs)
3133 xkbcommon=yes
3134 else
3135 if test "$xkbcommon" = "yes" ; then
3136 feature_not_found "xkbcommon" "Install libxkbcommon-devel"
3137 fi
3138 xkbcommon=no
3139 fi
3140fi
3141
76655d6d
AL
3142##########################################
3143# fnmatch() probe, used for ACL routines
3144fnmatch="no"
3145cat > $TMPC << EOF
3146#include <fnmatch.h>
3147int main(void)
3148{
3149 fnmatch("foo", "foo", 0);
3150 return 0;
3151}
3152EOF
52166aa0 3153if compile_prog "" "" ; then
76655d6d
AL
3154 fnmatch="yes"
3155fi
3156
ee682d27 3157##########################################
c1bb86cd 3158# xfsctl() probe, used for file-posix.c
dce512de
CH
3159if test "$xfs" != "no" ; then
3160 cat > $TMPC << EOF
ffc41d10 3161#include <stddef.h> /* NULL */
dce512de
CH
3162#include <xfs/xfs.h>
3163int main(void)
3164{
3165 xfsctl(NULL, 0, 0, NULL);
3166 return 0;
3167}
3168EOF
3169 if compile_prog "" "" ; then
3170 xfs="yes"
3171 else
3172 if test "$xfs" = "yes" ; then
21684af0 3173 feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
dce512de
CH
3174 fi
3175 xfs=no
3176 fi
3177fi
3178
8a16d273
TS
3179##########################################
3180# vde libraries probe
dfb278bd 3181if test "$vde" != "no" ; then
4baae0ac 3182 vde_libs="-lvdeplug"
8a16d273
TS
3183 cat > $TMPC << EOF
3184#include <libvdeplug.h>
4a7f0e06
PB
3185int main(void)
3186{
3187 struct vde_open_args a = {0, 0, 0};
fea08e08
PM
3188 char s[] = "";
3189 vde_open(s, s, &a);
4a7f0e06
PB
3190 return 0;
3191}
8a16d273 3192EOF
52166aa0 3193 if compile_prog "" "$vde_libs" ; then
4baae0ac 3194 vde=yes
dfb278bd
JQ
3195 else
3196 if test "$vde" = "yes" ; then
21684af0 3197 feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
dfb278bd
JQ
3198 fi
3199 vde=no
4baae0ac 3200 fi
8a16d273
TS
3201fi
3202
58952137 3203##########################################
0a985b37
VM
3204# netmap support probe
3205# Apart from looking for netmap headers, we make sure that the host API version
3206# supports the netmap backend (>=11). The upper bound (15) is meant to simulate
3207# a minor/major version number. Minor new features will be marked with values up
3208# to 15, and if something happens that requires a change to the backend we will
3209# move above 15, submit the backend fixes and modify this two bounds.
58952137
VM
3210if test "$netmap" != "no" ; then
3211 cat > $TMPC << EOF
3212#include <inttypes.h>
3213#include <net/if.h>
3214#include <net/netmap.h>
3215#include <net/netmap_user.h>
0a985b37
VM
3216#if (NETMAP_API < 11) || (NETMAP_API > 15)
3217#error
3218#endif
58952137
VM
3219int main(void) { return 0; }
3220EOF
3221 if compile_prog "" "" ; then
3222 netmap=yes
3223 else
3224 if test "$netmap" = "yes" ; then
3225 feature_not_found "netmap"
3226 fi
3227 netmap=no
3228 fi
3229fi
3230
47e98658
CB
3231##########################################
3232# libcap-ng library probe
3233if test "$cap_ng" != "no" ; then
3234 cap_libs="-lcap-ng"
3235 cat > $TMPC << EOF
3236#include <cap-ng.h>
3237int main(void)
3238{
3239 capng_capability_to_name(CAPNG_EFFECTIVE);
3240 return 0;
3241}
3242EOF
3243 if compile_prog "" "$cap_libs" ; then
3244 cap_ng=yes
3245 libs_tools="$cap_libs $libs_tools"
3246 else
3247 if test "$cap_ng" = "yes" ; then
21684af0 3248 feature_not_found "cap_ng" "Install libcap-ng devel"
47e98658
CB
3249 fi
3250 cap_ng=no
3251 fi
3252fi
3253
8f28f3fb 3254##########################################
c2de5c91 3255# Sound support libraries probe
8f28f3fb 3256
c2de5c91 3257audio_drv_probe()
3258{
3259 drv=$1
3260 hdr=$2
3261 lib=$3
3262 exp=$4
3263 cfl=$5
3264 cat > $TMPC << EOF
3265#include <$hdr>
3266int main(void) { $exp }
8f28f3fb 3267EOF
52166aa0 3268 if compile_prog "$cfl" "$lib" ; then
c2de5c91 3269 :
3270 else
76ad07a4
PM
3271 error_exit "$drv check failed" \
3272 "Make sure to have the $drv libs and headers installed."
c2de5c91 3273 fi
3274}
3275
89138857 3276audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
c2de5c91 3277for drv in $audio_drv_list; do
3278 case $drv in
3279 alsa)
3280 audio_drv_probe $drv alsa/asoundlib.h -lasound \
e35bcb0c 3281 "return snd_pcm_close((snd_pcm_t *)0);"
b1149911 3282 alsa_libs="-lasound"
c2de5c91 3283 ;;
3284
b8e59f18 3285 pa)
e58ff62d
PK
3286 audio_drv_probe $drv pulse/pulseaudio.h "-lpulse" \
3287 "pa_context_set_source_output_volume(NULL, 0, NULL, NULL, NULL); return 0;"
b1149911 3288 pulse_libs="-lpulse"
67f86e8e 3289 audio_pt_int="yes"
b8e59f18 3290 ;;
3291
373967b2
GH
3292 sdl)
3293 if test "$sdl" = "no"; then
3294 error_exit "sdl not found or disabled, can not use sdl audio driver"
3295 fi
3296 ;;
3297
997e690a 3298 coreaudio)
b1149911 3299 coreaudio_libs="-framework CoreAudio"
997e690a
JQ
3300 ;;
3301
a4bf6780 3302 dsound)
b1149911 3303 dsound_libs="-lole32 -ldxguid"
d5631638 3304 audio_win_int="yes"
a4bf6780
JQ
3305 ;;
3306
3307 oss)
b1149911 3308 oss_libs="$oss_lib"
a4bf6780
JQ
3309 ;;
3310
373967b2
GH
3311 wav)
3312 # XXX: Probes for CoreAudio, DirectSound
2f6a1ab0
BS
3313 ;;
3314
e4c63a6a 3315 *)
1c9b2a52 3316 echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
76ad07a4
PM
3317 error_exit "Unknown driver '$drv' selected" \
3318 "Possible drivers are: $audio_possible_drivers"
e4c63a6a 3319 }
3320 ;;
c2de5c91 3321 esac
3322done
8f28f3fb 3323
2e4d9fb1
AJ
3324##########################################
3325# BrlAPI probe
3326
4ffcedb6 3327if test "$brlapi" != "no" ; then
eb82284f
JQ
3328 brlapi_libs="-lbrlapi"
3329 cat > $TMPC << EOF
2e4d9fb1 3330#include <brlapi.h>
832ce9c2 3331#include <stddef.h>
2e4d9fb1
AJ
3332int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
3333EOF
52166aa0 3334 if compile_prog "" "$brlapi_libs" ; then
eb82284f 3335 brlapi=yes
4ffcedb6
JQ
3336 else
3337 if test "$brlapi" = "yes" ; then
21684af0 3338 feature_not_found "brlapi" "Install brlapi devel"
4ffcedb6
JQ
3339 fi
3340 brlapi=no
eb82284f
JQ
3341 fi
3342fi
2e4d9fb1 3343
4d3b6f6e
AZ
3344##########################################
3345# curses probe
a3605bf6
MT
3346if test "$curses" != "no" ; then
3347 if test "$mingw32" = "yes" ; then
8ddc5bf9
ST
3348 curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
3349 curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
a3605bf6 3350 else
7c703002 3351 curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"
8ddc5bf9 3352 curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
a3605bf6 3353 fi
c584a6d0 3354 curses_found=no
4d3b6f6e 3355 cat > $TMPC << EOF
8ddc5bf9 3356#include <locale.h>
4d3b6f6e 3357#include <curses.h>
8ddc5bf9 3358#include <wchar.h>
ef9a2524 3359int main(void) {
8ddc5bf9
ST
3360 wchar_t wch = L'w';
3361 setlocale(LC_ALL, "");
ef9a2524 3362 resize_term(0, 0);
8ddc5bf9
ST
3363 addwstr(L"wide chars\n");
3364 addnwstr(&wch, 1);
7c703002 3365 add_wch(WACS_DEGREE);
271f37ab 3366 return 0;
ef9a2524 3367}
4d3b6f6e 3368EOF
ecbe251f 3369 IFS=:
8ddc5bf9 3370 for curses_inc in $curses_inc_list; do
b01a4fd3
PM
3371 # Make sure we get the wide character prototypes
3372 curses_inc="-DNCURSES_WIDECHAR $curses_inc"
7c703002 3373 IFS=:
8ddc5bf9
ST
3374 for curses_lib in $curses_lib_list; do
3375 unset IFS
3376 if compile_prog "$curses_inc" "$curses_lib" ; then
3377 curses_found=yes
8ddc5bf9
ST
3378 break
3379 fi
3380 done
7c703002
ST
3381 if test "$curses_found" = yes ; then
3382 break
3383 fi
4f78ef9a 3384 done
ecbe251f 3385 unset IFS
c584a6d0
JQ
3386 if test "$curses_found" = "yes" ; then
3387 curses=yes
3388 else
3389 if test "$curses" = "yes" ; then
21684af0 3390 feature_not_found "curses" "Install ncurses devel"
c584a6d0
JQ
3391 fi
3392 curses=no
3393 fi
4f78ef9a 3394fi
4d3b6f6e 3395
769ce76d
AG
3396##########################################
3397# curl probe
788c8196 3398if test "$curl" != "no" ; then
65d5d3f9 3399 if $pkg_config libcurl --exists; then
a3605bf6
MT
3400 curlconfig="$pkg_config libcurl"
3401 else
3402 curlconfig=curl-config
3403 fi
769ce76d
AG
3404 cat > $TMPC << EOF
3405#include <curl/curl.h>
0b862ced 3406int main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
769ce76d 3407EOF
89138857
SW
3408 curl_cflags=$($curlconfig --cflags 2>/dev/null)
3409 curl_libs=$($curlconfig --libs 2>/dev/null)
b1d5a277 3410 if compile_prog "$curl_cflags" "$curl_libs" ; then
769ce76d 3411 curl=yes
788c8196
JQ
3412 else
3413 if test "$curl" = "yes" ; then
21684af0 3414 feature_not_found "curl" "Install libcurl devel"
788c8196
JQ
3415 fi
3416 curl=no
769ce76d
AG
3417 fi
3418fi # test "$curl"
3419
fb599c9a
AZ
3420##########################################
3421# bluez support probe
a20a6f46 3422if test "$bluez" != "no" ; then
e820e3f4
AZ
3423 cat > $TMPC << EOF
3424#include <bluetooth/bluetooth.h>
3425int main(void) { return bt_error(0); }
3426EOF
89138857
SW
3427 bluez_cflags=$($pkg_config --cflags bluez 2>/dev/null)
3428 bluez_libs=$($pkg_config --libs bluez 2>/dev/null)
52166aa0 3429 if compile_prog "$bluez_cflags" "$bluez_libs" ; then
a20a6f46 3430 bluez=yes
e482d56a 3431 libs_softmmu="$bluez_libs $libs_softmmu"
e820e3f4 3432 else
a20a6f46 3433 if test "$bluez" = "yes" ; then
21684af0 3434 feature_not_found "bluez" "Install bluez-libs/libbluetooth devel"
a20a6f46 3435 fi
e820e3f4
AZ
3436 bluez="no"
3437 fi
fb599c9a
AZ
3438fi
3439
e18df141
AL
3440##########################################
3441# glib support probe
a52d28af 3442
e7b3af81 3443glib_req_ver=2.40
aa0d1f44
PB
3444glib_modules=gthread-2.0
3445if test "$modules" = yes; then
a88afc64 3446 glib_modules="$glib_modules gmodule-export-2.0"
aa0d1f44 3447fi
e26110cf 3448
4eaf7202
SJ
3449# This workaround is required due to a bug in pkg-config file for glib as it
3450# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
3451
3452if test "$static" = yes -a "$mingw32" = yes; then
3453 QEMU_CFLAGS="-DGLIB_STATIC_COMPILATION $QEMU_CFLAGS"
3454fi
3455
aa0d1f44 3456for i in $glib_modules; do
e26110cf 3457 if $pkg_config --atleast-version=$glib_req_ver $i; then
89138857
SW
3458 glib_cflags=$($pkg_config --cflags $i)
3459 glib_libs=$($pkg_config --libs $i)
4a058899 3460 QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
e26110cf
FZ
3461 LIBS="$glib_libs $LIBS"
3462 libs_qga="$glib_libs $libs_qga"
3463 else
3464 error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3465 fi
3466done
3467
977a82ab
DB
3468# Sanity check that the current size_t matches the
3469# size that glib thinks it should be. This catches
3470# problems on multi-arch where people try to build
3471# 32-bit QEMU while pointing at 64-bit glib headers
3472cat > $TMPC <<EOF
3473#include <glib.h>
3474#include <unistd.h>
3475
3476#define QEMU_BUILD_BUG_ON(x) \
3477 typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3478
3479int main(void) {
3480 QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3481 return 0;
3482}
3483EOF
3484
5919e032 3485if ! compile_prog "$CFLAGS" "$LIBS" ; then
977a82ab
DB
3486 error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3487 "You probably need to set PKG_CONFIG_LIBDIR"\
3488 "to point to the right pkg-config files for your"\
3489 "build target"
3490fi
3491
9d41401b
MT
3492# g_test_trap_subprocess added in 2.38. Used by some tests.
3493glib_subprocess=yes
a049223a 3494if ! $pkg_config --atleast-version=2.38 glib-2.0; then
9d41401b
MT
3495 glib_subprocess=no
3496fi
3497
bbbf2e04
JS
3498# Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
3499cat > $TMPC << EOF
3500#include <glib.h>
3501int main(void) { return 0; }
3502EOF
3503if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3504 if cc_has_warning_flag "-Wno-unknown-attributes"; then
3505 glib_cflags="-Wno-unknown-attributes $glib_cflags"
3506 CFLAGS="-Wno-unknown-attributes $CFLAGS"
3507 fi
3508fi
3509
e26110cf
FZ
3510##########################################
3511# SHA command probe for modules
3512if test "$modules" = yes; then
3513 shacmd_probe="sha1sum sha1 shasum"
3514 for c in $shacmd_probe; do
8ccefb91 3515 if has $c; then
e26110cf
FZ
3516 shacmd="$c"
3517 break
3518 fi
3519 done
3520 if test "$shacmd" = ""; then
3521 error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3522 fi
e18df141
AL
3523fi
3524
e2134eb9
GH
3525##########################################
3526# pixman support probe
3527
35c4e86c 3528if test "$want_tools" = "no" -a "$softmmu" = "no"; then
74880fe2
RS
3529 pixman_cflags=
3530 pixman_libs=
35c4e86c 3531elif $pkg_config --atleast-version=0.21.8 pixman-1 > /dev/null 2>&1; then
89138857
SW
3532 pixman_cflags=$($pkg_config --cflags pixman-1)
3533 pixman_libs=$($pkg_config --libs pixman-1)
e2134eb9 3534else
c12b6d70
GH
3535 error_exit "pixman >= 0.21.8 not present." \
3536 "Please install the pixman devel package."
e2134eb9 3537fi
e2134eb9 3538
fe8fc5ae
PB
3539##########################################
3540# libmpathpersist probe
3541
3542if test "$mpath" != "no" ; then
3543 cat > $TMPC <<EOF
3544#include <libudev.h>
3545#include <mpath_persist.h>
3546unsigned mpath_mx_alloc_len = 1024;
3547int logsink;
b3f1c8c4
PB
3548static struct config *multipath_conf;
3549extern struct udev *udev;
3550extern struct config *get_multipath_config(void);
3551extern void put_multipath_config(struct config *conf);
3552struct udev *udev;
3553struct config *get_multipath_config(void) { return multipath_conf; }
3554void put_multipath_config(struct config *conf) { }
3555
fe8fc5ae 3556int main(void) {
b3f1c8c4
PB
3557 udev = udev_new();
3558 multipath_conf = mpath_lib_init();
fe8fc5ae
PB
3559 return 0;
3560}
3561EOF
3562 if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
3563 mpathpersist=yes
3564 else
3565 mpathpersist=no
3566 fi
3567else
3568 mpathpersist=no
3569fi
3570
17bff52b
MK
3571##########################################
3572# libcap probe
3573
3574if test "$cap" != "no" ; then
3575 cat > $TMPC <<EOF
3576#include <stdio.h>
3577#include <sys/capability.h>
cc939743 3578int main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
17bff52b
MK
3579EOF
3580 if compile_prog "" "-lcap" ; then
3581 cap=yes
3582 else
3583 cap=no
3584 fi
3585fi
3586
414f0dab 3587##########################################
e5d355d1 3588# pthread probe
4b29ec41 3589PTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
3c529d93 3590
4dd75c70 3591pthread=no
e5d355d1 3592cat > $TMPC << EOF
3c529d93 3593#include <pthread.h>
7a42bbe4
SW
3594static void *f(void *p) { return NULL; }
3595int main(void) {
3596 pthread_t thread;
3597 pthread_create(&thread, 0, f, 0);
3598 return 0;
3599}
414f0dab 3600EOF
bd00d539
AF
3601if compile_prog "" "" ; then
3602 pthread=yes
3603else
3604 for pthread_lib in $PTHREADLIBS_LIST; do
3605 if compile_prog "" "$pthread_lib" ; then
3606 pthread=yes
e3c56761
PP
3607 found=no
3608 for lib_entry in $LIBS; do
3609 if test "$lib_entry" = "$pthread_lib"; then
3610 found=yes
3611 break
3612 fi
3613 done
3614 if test "$found" = "no"; then
3615 LIBS="$pthread_lib $LIBS"
14ab3aa7 3616 libs_qga="$pthread_lib $libs_qga"
e3c56761 3617 fi
409437e1 3618 PTHREAD_LIB="$pthread_lib"
bd00d539
AF
3619 break
3620 fi
3621 done
3622fi
414f0dab 3623
4617e593 3624if test "$mingw32" != yes -a "$pthread" = no; then
76ad07a4
PM
3625 error_exit "pthread check failed" \
3626 "Make sure to have the pthread libs and headers installed."
e5d355d1
AL
3627fi
3628
5c312079
DDAG
3629# check for pthread_setname_np
3630pthread_setname_np=no
3631cat > $TMPC << EOF
3632#include <pthread.h>
3633
3634static void *f(void *p) { return NULL; }
3635int main(void)
3636{
3637 pthread_t thread;
3638 pthread_create(&thread, 0, f, 0);
3639 pthread_setname_np(thread, "QEMU");
3640 return 0;
3641}
3642EOF
3643if compile_prog "" "$pthread_lib" ; then
3644 pthread_setname_np=yes
3645fi
3646
f27aaf4b
CB
3647##########################################
3648# rbd probe
3649if test "$rbd" != "no" ; then
3650 cat > $TMPC <<EOF
3651#include <stdio.h>
ad32e9c0 3652#include <rbd/librbd.h>
f27aaf4b 3653int main(void) {
ad32e9c0
JD
3654 rados_t cluster;
3655 rados_create(&cluster, NULL);
f27aaf4b
CB
3656 return 0;
3657}
3658EOF
ad32e9c0
JD
3659 rbd_libs="-lrbd -lrados"
3660 if compile_prog "" "$rbd_libs" ; then
3661 rbd=yes
f27aaf4b
CB
3662 else
3663 if test "$rbd" = "yes" ; then
21684af0 3664 feature_not_found "rados block device" "Install librbd/ceph devel"
f27aaf4b
CB
3665 fi
3666 rbd=no
3667 fi
f27aaf4b
CB
3668fi
3669
0a12ec87
RJ
3670##########################################
3671# libssh2 probe
4fc16838 3672min_libssh2_version=1.2.8
0a12ec87 3673if test "$libssh2" != "no" ; then
65d5d3f9 3674 if $pkg_config --atleast-version=$min_libssh2_version libssh2; then
89138857
SW
3675 libssh2_cflags=$($pkg_config libssh2 --cflags)
3676 libssh2_libs=$($pkg_config libssh2 --libs)
0a12ec87 3677 libssh2=yes
0a12ec87
RJ
3678 else
3679 if test "$libssh2" = "yes" ; then
4fc16838 3680 error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2"
0a12ec87
RJ
3681 fi
3682 libssh2=no
3683 fi
3684fi
3685
9a2d462e
RJ
3686##########################################
3687# libssh2_sftp_fsync probe
3688
3689if test "$libssh2" = "yes"; then
3690 cat > $TMPC <<EOF
3691#include <stdio.h>
3692#include <libssh2.h>
3693#include <libssh2_sftp.h>
3694int main(void) {
3695 LIBSSH2_SESSION *session;
3696 LIBSSH2_SFTP *sftp;
3697 LIBSSH2_SFTP_HANDLE *sftp_handle;
3698 session = libssh2_session_init ();
3699 sftp = libssh2_sftp_init (session);
3700 sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0);
3701 libssh2_sftp_fsync (sftp_handle);
3702 return 0;
3703}
3704EOF
3705 # libssh2_cflags/libssh2_libs defined in previous test.
3706 if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then
3707 QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS"
3708 fi
3709fi
3710
5c6c3a6c
CH
3711##########################################
3712# linux-aio probe
5c6c3a6c
CH
3713
3714if test "$linux_aio" != "no" ; then
3715 cat > $TMPC <<EOF
3716#include <libaio.h>
3717#include <sys/eventfd.h>
832ce9c2 3718#include <stddef.h>
5c6c3a6c
CH
3719int main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
3720EOF
3721 if compile_prog "" "-laio" ; then
3722 linux_aio=yes
5c6c3a6c
CH
3723 else
3724 if test "$linux_aio" = "yes" ; then
21684af0 3725 feature_not_found "linux AIO" "Install libaio devel"
5c6c3a6c 3726 fi
3cfcae3c 3727 linux_aio=no
5c6c3a6c
CH
3728 fi
3729fi
3730
3b8acc11
PB
3731##########################################
3732# TPM passthrough is only on x86 Linux
3733
3734if test "$targetos" = Linux && test "$cpu" = i386 -o "$cpu" = x86_64; then
3735 tpm_passthrough=$tpm
3736else
3737 tpm_passthrough=no
3738fi
3739
f4ede81e
AV
3740# TPM emulator is for all posix systems
3741if test "$mingw32" != "yes"; then
3742 tpm_emulator=$tpm
3743else
3744 tpm_emulator=no
3745fi
758e8e38
VJ
3746##########################################
3747# attr probe
3748
3749if test "$attr" != "no" ; then
3750 cat > $TMPC <<EOF
3751#include <stdio.h>
3752#include <sys/types.h>
f2338fb4
PB
3753#ifdef CONFIG_LIBATTR
3754#include <attr/xattr.h>
3755#else
4f26f2b6 3756#include <sys/xattr.h>
f2338fb4 3757#endif
758e8e38
VJ
3758int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
3759EOF
4f26f2b6
AK
3760 if compile_prog "" "" ; then
3761 attr=yes
3762 # Older distros have <attr/xattr.h>, and need -lattr:
f2338fb4 3763 elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
758e8e38
VJ
3764 attr=yes
3765 LIBS="-lattr $LIBS"
4f26f2b6 3766 libattr=yes
758e8e38
VJ
3767 else
3768 if test "$attr" = "yes" ; then
21684af0 3769 feature_not_found "ATTR" "Install libc6 or libattr devel"
758e8e38
VJ
3770 fi
3771 attr=no
3772 fi
3773fi
3774
bf9298b9
AL
3775##########################################
3776# iovec probe
3777cat > $TMPC <<EOF
db34f0b3 3778#include <sys/types.h>
bf9298b9 3779#include <sys/uio.h>
db34f0b3 3780#include <unistd.h>
f91f9bee 3781int main(void) { return sizeof(struct iovec); }
bf9298b9
AL
3782EOF
3783iovec=no
52166aa0 3784if compile_prog "" "" ; then
bf9298b9
AL
3785 iovec=yes
3786fi
3787
ceb42de8
AL
3788##########################################
3789# preadv probe
3790cat > $TMPC <<EOF
3791#include <sys/types.h>
3792#include <sys/uio.h>
3793#include <unistd.h>
c075a723 3794int main(void) { return preadv(0, 0, 0, 0); }
ceb42de8
AL
3795EOF
3796preadv=no
52166aa0 3797if compile_prog "" "" ; then
ceb42de8
AL
3798 preadv=yes
3799fi
3800
f652e6af
AJ
3801##########################################
3802# fdt probe
e169e1e1
PM
3803# fdt support is mandatory for at least some target architectures,
3804# so insist on it if we're building those system emulators.
3805fdt_required=no
3806for target in $target_list; do
3807 case $target in
a666409f 3808 aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu|riscv*-softmmu)
e169e1e1
PM
3809 fdt_required=yes
3810 ;;
3811 esac
3812done
3813
3814if test "$fdt_required" = "yes"; then
3815 if test "$fdt" = "no"; then
3816 error_exit "fdt disabled but some requested targets require it." \
3817 "You can turn off fdt only if you also disable all the system emulation" \
3818 "targets which need it (by specifying a cut down --target-list)."
3819 fi
3820 fdt=yes
3821fi
3822
2df87df7 3823if test "$fdt" != "no" ; then
b41af4ba 3824 fdt_libs="-lfdt"
96ce6545 3825 # explicitly check for libfdt_env.h as it is missing in some stable installs
6e85fce0 3826 # and test for required functions to make sure we are on a version >= 1.4.2
b41af4ba 3827 cat > $TMPC << EOF
31ce0adb 3828#include <libfdt.h>
96ce6545 3829#include <libfdt_env.h>
6e85fce0 3830int main(void) { fdt_first_subnode(0, 0); return 0; }
f652e6af 3831EOF
52166aa0 3832 if compile_prog "" "$fdt_libs" ; then
a540f158 3833 # system DTC is good - use it
e3971d61 3834 fdt=system
a540f158 3835 else
aef45d51
DB
3836 # have GIT checkout, so activate dtc submodule
3837 if test -e "${source_path}/.git" ; then
3838 git_submodules="${git_submodules} dtc"
3839 fi
3840 if test -d "${source_path}/dtc/libfdt" || test -e "${source_path}/.git" ; then
e3971d61 3841 fdt=git
aef45d51
DB
3842 mkdir -p dtc
3843 if [ "$pwd_is_source_path" != "y" ] ; then
3844 symlink "$source_path/dtc/Makefile" "dtc/Makefile"
3845 symlink "$source_path/dtc/scripts" "dtc/scripts"
3846 fi
3847 fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
8a99e9a3
PMD
3848 fdt_ldflags="-L\$(BUILD_DIR)/dtc/libfdt"
3849 fdt_libs="$fdt_libs"
aef45d51
DB
3850 elif test "$fdt" = "yes" ; then
3851 # Not a git build & no libfdt found, prompt for system install
3852 error_exit "DTC (libfdt) version >= 1.4.2 not present." \
3853 "Please install the DTC (libfdt) devel package"
3854 else
3855 # don't have and don't want
3856 fdt_libs=
3857 fdt=no
3858 fi
f652e6af
AJ
3859 fi
3860fi
3861
a540f158
PC
3862libs_softmmu="$libs_softmmu $fdt_libs"
3863
20ff075b 3864##########################################
fb719563 3865# opengl probe (for sdl2, gtk, milkymist-tmu2)
b1546f32 3866
da076ffe 3867if test "$opengl" != "no" ; then
014cb152 3868 opengl_pkgs="epoxy libdrm gbm"
5f9b1e35
GH
3869 if $pkg_config $opengl_pkgs; then
3870 opengl_cflags="$($pkg_config --cflags $opengl_pkgs)"
3871 opengl_libs="$($pkg_config --libs $opengl_pkgs)"
da076ffe 3872 opengl=yes
925a0400
GH
3873 if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
3874 gtk_gl="yes"
3875 fi
cc720a5d 3876 QEMU_CFLAGS="$QEMU_CFLAGS $opengl_cflags"
20ff075b 3877 else
da076ffe 3878 if test "$opengl" = "yes" ; then
dcf30025 3879 feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
20ff075b 3880 fi
f676c67e 3881 opengl_cflags=""
da076ffe
GH
3882 opengl_libs=""
3883 opengl=no
20ff075b
MW
3884 fi
3885fi
3886
014cb152
GH
3887if test "$opengl" = "yes"; then
3888 cat > $TMPC << EOF
3889#include <epoxy/egl.h>
3890#ifndef EGL_MESA_image_dma_buf_export
3891# error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
3892#endif
3893int main(void) { return 0; }
3894EOF
3895 if compile_prog "" "" ; then
3896 opengl_dmabuf=yes
3897 fi
3898fi
c9a12e75 3899
ed279a06
KK
3900##########################################
3901# libxml2 probe
3902if test "$libxml2" != "no" ; then
3903 if $pkg_config --exists libxml-2.0; then
3904 libxml2="yes"
3905 libxml2_cflags=$($pkg_config --cflags libxml-2.0)
3906 libxml2_libs=$($pkg_config --libs libxml-2.0)
3907 else
3908 if test "$libxml2" = "yes"; then
3909 feature_not_found "libxml2" "Install libxml2 devel"
3910 fi
3911 libxml2="no"
3912 fi
3913fi
c9a12e75 3914
eb100396
BR
3915##########################################
3916# glusterfs probe
3917if test "$glusterfs" != "no" ; then
65d5d3f9 3918 if $pkg_config --atleast-version=3 glusterfs-api; then
e01bee08 3919 glusterfs="yes"
89138857
SW
3920 glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
3921 glusterfs_libs=$($pkg_config --libs glusterfs-api)
d85fa9eb
JC
3922 if $pkg_config --atleast-version=4 glusterfs-api; then
3923 glusterfs_xlator_opt="yes"
3924 fi
65d5d3f9 3925 if $pkg_config --atleast-version=5 glusterfs-api; then
0c14fb47
BR
3926 glusterfs_discard="yes"
3927 fi
7c815372 3928 if $pkg_config --atleast-version=6 glusterfs-api; then
df3a429a 3929 glusterfs_fallocate="yes"
7c815372
BR
3930 glusterfs_zerofill="yes"
3931 fi
eb100396
BR
3932 else
3933 if test "$glusterfs" = "yes" ; then
8efc9363
HT
3934 feature_not_found "GlusterFS backend support" \
3935 "Install glusterfs-api devel >= 3"
eb100396 3936 fi
e01bee08 3937 glusterfs="no"
eb100396
BR
3938 fi
3939fi
3940
39386ac7 3941# Check for inotify functions when we are building linux-user
3b3f24ad
AJ
3942# emulator. This is done because older glibc versions don't
3943# have syscall stubs for these implemented. In that case we
3944# don't provide them even if kernel supports them.
3945#
3946inotify=no
67ba57f6 3947cat > $TMPC << EOF
3b3f24ad
AJ
3948#include <sys/inotify.h>
3949
3950int
3951main(void)
3952{
3953 /* try to start inotify */
8690e420 3954 return inotify_init();
3b3f24ad
AJ
3955}
3956EOF
52166aa0 3957if compile_prog "" "" ; then
67ba57f6 3958 inotify=yes
3b3f24ad
AJ
3959fi
3960
c05c7a73
RV
3961inotify1=no
3962cat > $TMPC << EOF
3963#include <sys/inotify.h>
3964
3965int
3966main(void)
3967{
3968 /* try to start inotify */
3969 return inotify_init1(0);
3970}
3971EOF
3972if compile_prog "" "" ; then
3973 inotify1=yes
3974fi
3975
099d6b0f
RV
3976# check if pipe2 is there
3977pipe2=no
3978cat > $TMPC << EOF
099d6b0f
RV
3979#include <unistd.h>
3980#include <fcntl.h>
3981
3982int main(void)
3983{
3984 int pipefd[2];
9bca8162 3985 return pipe2(pipefd, O_CLOEXEC);
099d6b0f
RV
3986}
3987EOF
52166aa0 3988if compile_prog "" "" ; then
099d6b0f
RV
3989 pipe2=yes
3990fi
3991
40ff6d7e
KW
3992# check if accept4 is there
3993accept4=no
3994cat > $TMPC << EOF
40ff6d7e
KW
3995#include <sys/socket.h>
3996#include <stddef.h>
3997
3998int main(void)
3999{
4000 accept4(0, NULL, NULL, SOCK_CLOEXEC);
4001 return 0;
4002}
4003EOF
4004if compile_prog "" "" ; then
4005 accept4=yes
4006fi
4007
3ce34dfb
VS
4008# check if tee/splice is there. vmsplice was added same time.
4009splice=no
4010cat > $TMPC << EOF
3ce34dfb
VS
4011#include <unistd.h>
4012#include <fcntl.h>
4013#include <limits.h>
4014
4015int main(void)
4016{
66ea0f22 4017 int len, fd = 0;
3ce34dfb
VS
4018 len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
4019 splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
4020 return 0;
4021}
4022EOF
52166aa0 4023if compile_prog "" "" ; then
3ce34dfb
VS
4024 splice=yes
4025fi
4026
a99d57bb
WG
4027##########################################
4028# libnuma probe
4029
4030if test "$numa" != "no" ; then
4031 cat > $TMPC << EOF
4032#include <numa.h>
4033int main(void) { return numa_available(); }
4034EOF
4035
4036 if compile_prog "" "-lnuma" ; then
4037 numa=yes
4038 libs_softmmu="-lnuma $libs_softmmu"
4039 else
4040 if test "$numa" = "yes" ; then
4041 feature_not_found "numa" "install numactl devel"
4042 fi
4043 numa=no
4044 fi
4045fi
4046
7b01cb97
AD
4047if test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
4048 echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
4049 exit 1
4050fi
4051
5a22ab71
YZ
4052# Even if malloc_trim() is available, these non-libc memory allocators
4053# do not support it.
4054if test "$tcmalloc" = "yes" || test "$jemalloc" = "yes" ; then
4055 if test "$malloc_trim" = "yes" ; then
4056 echo "Disabling malloc_trim with non-libc memory allocator"
4057 fi
4058 malloc_trim="no"
4059fi
4060
4061#######################################
4062# malloc_trim
4063
4064if test "$malloc_trim" != "no" ; then
4065 cat > $TMPC << EOF
4066#include <malloc.h>
4067int main(void) { malloc_trim(0); return 0; }
4068EOF
4069 if compile_prog "" "" ; then
4070 malloc_trim="yes"
4071 else
4072 malloc_trim="no"
4073 fi
4074fi
4075
2847b469
FZ
4076##########################################
4077# tcmalloc probe
4078
4079if test "$tcmalloc" = "yes" ; then
4080 cat > $TMPC << EOF
4081#include <stdlib.h>
4082int main(void) { malloc(1); return 0; }
4083EOF
4084
4085 if compile_prog "" "-ltcmalloc" ; then
4086 LIBS="-ltcmalloc $LIBS"
4087 else
4088 feature_not_found "tcmalloc" "install gperftools devel"
4089 fi
4090fi
4091
7b01cb97
AD
4092##########################################
4093# jemalloc probe
4094
4095if test "$jemalloc" = "yes" ; then
4096 cat > $TMPC << EOF
4097#include <stdlib.h>
4098int main(void) { malloc(1); return 0; }
4099EOF
4100
4101 if compile_prog "" "-ljemalloc" ; then
4102 LIBS="-ljemalloc $LIBS"
4103 else
4104 feature_not_found "jemalloc" "install jemalloc devel"
4105 fi
4106fi
4107
dcc38d1c
MT
4108##########################################
4109# signalfd probe
4110signalfd="no"
4111cat > $TMPC << EOF
dcc38d1c
MT
4112#include <unistd.h>
4113#include <sys/syscall.h>
4114#include <signal.h>
4115int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
4116EOF
4117
4118if compile_prog "" "" ; then
4119 signalfd=yes
4120fi
4121
c2882b96
RV
4122# check if eventfd is supported
4123eventfd=no
4124cat > $TMPC << EOF
4125#include <sys/eventfd.h>
4126
4127int main(void)
4128{
55cc7f3e 4129 return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
c2882b96
RV
4130}
4131EOF
4132if compile_prog "" "" ; then
4133 eventfd=yes
4134fi
4135
751bcc39
MAL
4136# check if memfd is supported
4137memfd=no
4138cat > $TMPC << EOF
75e5b70e 4139#include <sys/mman.h>
751bcc39
MAL
4140
4141int main(void)
4142{
4143 return memfd_create("foo", MFD_ALLOW_SEALING);
4144}
4145EOF
4146if compile_prog "" "" ; then
4147 memfd=yes
4148fi
4149
4150
4151
d0927938
UH
4152# check for fallocate
4153fallocate=no
4154cat > $TMPC << EOF
4155#include <fcntl.h>
4156
4157int main(void)
4158{
4159 fallocate(0, 0, 0, 0);
4160 return 0;
4161}
4162EOF
8fb03151 4163if compile_prog "" "" ; then
d0927938
UH
4164 fallocate=yes
4165fi
4166
3d4fa43e
KK
4167# check for fallocate hole punching
4168fallocate_punch_hole=no
4169cat > $TMPC << EOF
4170#include <fcntl.h>
4171#include <linux/falloc.h>
4172
4173int main(void)
4174{
4175 fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
4176 return 0;
4177}
4178EOF
4179if compile_prog "" "" ; then
4180 fallocate_punch_hole=yes
4181fi
4182
b953f075
DL
4183# check that fallocate supports range zeroing inside the file
4184fallocate_zero_range=no
4185cat > $TMPC << EOF
4186#include <fcntl.h>
4187#include <linux/falloc.h>
4188
4189int main(void)
4190{
4191 fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
4192 return 0;
4193}
4194EOF
4195if compile_prog "" "" ; then
4196 fallocate_zero_range=yes
4197fi
4198
ed911435
KW
4199# check for posix_fallocate
4200posix_fallocate=no
4201cat > $TMPC << EOF
4202#include <fcntl.h>
4203
4204int main(void)
4205{
4206 posix_fallocate(0, 0, 0);
4207 return 0;
4208}
4209EOF
4210if compile_prog "" "" ; then
4211 posix_fallocate=yes
4212fi
4213
c727f47d
PM
4214# check for sync_file_range
4215sync_file_range=no
4216cat > $TMPC << EOF
4217#include <fcntl.h>
4218
4219int main(void)
4220{
4221 sync_file_range(0, 0, 0, 0);
4222 return 0;
4223}
4224EOF
8fb03151 4225if compile_prog "" "" ; then
c727f47d
PM
4226 sync_file_range=yes
4227fi
4228
dace20dc
PM
4229# check for linux/fiemap.h and FS_IOC_FIEMAP
4230fiemap=no
4231cat > $TMPC << EOF
4232#include <sys/ioctl.h>
4233#include <linux/fs.h>
4234#include <linux/fiemap.h>
4235
4236int main(void)
4237{
4238 ioctl(0, FS_IOC_FIEMAP, 0);
4239 return 0;
4240}
4241EOF
8fb03151 4242if compile_prog "" "" ; then
dace20dc
PM
4243 fiemap=yes
4244fi
4245
d0927938
UH
4246# check for dup3
4247dup3=no
4248cat > $TMPC << EOF
4249#include <unistd.h>
4250
4251int main(void)
4252{
4253 dup3(0, 0, 0);
4254 return 0;
4255}
4256EOF
78f5d726 4257if compile_prog "" "" ; then
d0927938
UH
4258 dup3=yes
4259fi
4260
4e0c6529
AB
4261# check for ppoll support
4262ppoll=no
4263cat > $TMPC << EOF
4264#include <poll.h>
4265
4266int main(void)
4267{
4268 struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
4269 ppoll(&pfd, 1, 0, 0);
4270 return 0;
4271}
4272EOF
4273if compile_prog "" "" ; then
4274 ppoll=yes
4275fi
4276
cd758dd0
AB
4277# check for prctl(PR_SET_TIMERSLACK , ... ) support
4278prctl_pr_set_timerslack=no
4279cat > $TMPC << EOF
4280#include <sys/prctl.h>
4281
4282int main(void)
4283{
4284 prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
4285 return 0;
4286}
4287EOF
4288if compile_prog "" "" ; then
4289 prctl_pr_set_timerslack=yes
4290fi
4291
3b6edd16
PM
4292# check for epoll support
4293epoll=no
4294cat > $TMPC << EOF
4295#include <sys/epoll.h>
4296
4297int main(void)
4298{
4299 epoll_create(0);
4300 return 0;
4301}
4302EOF
8fb03151 4303if compile_prog "" "" ; then
3b6edd16
PM
4304 epoll=yes
4305fi
4306
227f0214
PM
4307# epoll_create1 is a later addition
4308# so we must check separately for its presence
3b6edd16
PM
4309epoll_create1=no
4310cat > $TMPC << EOF
4311#include <sys/epoll.h>
4312
4313int main(void)
4314{
19e83f6b
PM
4315 /* Note that we use epoll_create1 as a value, not as
4316 * a function being called. This is necessary so that on
4317 * old SPARC glibc versions where the function was present in
4318 * the library but not declared in the header file we will
4319 * fail the configure check. (Otherwise we will get a compiler
4320 * warning but not an error, and will proceed to fail the
4321 * qemu compile where we compile with -Werror.)
4322 */
c075a723 4323 return (int)(uintptr_t)&epoll_create1;
3b6edd16
PM
4324}
4325EOF
8fb03151 4326if compile_prog "" "" ; then
3b6edd16
PM
4327 epoll_create1=yes
4328fi
4329
a8fd1aba
PM
4330# check for sendfile support
4331sendfile=no
4332cat > $TMPC << EOF
4333#include <sys/sendfile.h>
4334
4335int main(void)
4336{
4337 return sendfile(0, 0, 0, 0);
4338}
4339EOF
4340if compile_prog "" "" ; then
4341 sendfile=yes
4342fi
4343
51834341
RV
4344# check for timerfd support (glibc 2.8 and newer)
4345timerfd=no
4346cat > $TMPC << EOF
4347#include <sys/timerfd.h>
4348
4349int main(void)
4350{
4351 return(timerfd_create(CLOCK_REALTIME, 0));
4352}
4353EOF
4354if compile_prog "" "" ; then
4355 timerfd=yes
4356fi
4357
9af5c906
RV
4358# check for setns and unshare support
4359setns=no
4360cat > $TMPC << EOF
4361#include <sched.h>
4362
4363int main(void)
4364{
4365 int ret;
4366 ret = setns(0, 0);
4367 ret = unshare(0);
4368 return ret;
4369}
4370EOF
4371if compile_prog "" "" ; then
4372 setns=yes
4373fi
4374
38860a03
AM
4375# clock_adjtime probe
4376clock_adjtime=no
4377cat > $TMPC <<EOF
4378#include <time.h>
4379
4380int main(void)
4381{
4382 return clock_adjtime(0, 0);
4383}
4384EOF
4385clock_adjtime=no
4386if compile_prog "" "" ; then
4387 clock_adjtime=yes
4388fi
4389
5a03cd00
AM
4390# syncfs probe
4391syncfs=no
4392cat > $TMPC <<EOF
4393#include <unistd.h>
4394
4395int main(void)
4396{
4397 return syncfs(0);
4398}
4399EOF
4400syncfs=no
4401if compile_prog "" "" ; then
4402 syncfs=yes
4403fi
4404
cc8ae6de 4405# Check if tools are available to build documentation.
a25dba17 4406if test "$docs" != "no" ; then
01668d98 4407 if has makeinfo && has pod2man; then
a25dba17 4408 docs=yes
83a3ab8b 4409 else
a25dba17 4410 if test "$docs" = "yes" ; then
21684af0 4411 feature_not_found "docs" "Install texinfo and Perl/perl-podlators"
83a3ab8b 4412 fi
a25dba17 4413 docs=no
83a3ab8b 4414 fi
cc8ae6de
PB
4415fi
4416
f514f41c 4417# Search for bswap_32 function
6ae9a1f4
JQ
4418byteswap_h=no
4419cat > $TMPC << EOF
4420#include <byteswap.h>
4421int main(void) { return bswap_32(0); }
4422EOF
52166aa0 4423if compile_prog "" "" ; then
6ae9a1f4
JQ
4424 byteswap_h=yes
4425fi
4426
75f13596 4427# Search for bswap32 function
6ae9a1f4
JQ
4428bswap_h=no
4429cat > $TMPC << EOF
4430#include <sys/endian.h>
4431#include <sys/types.h>
4432#include <machine/bswap.h>
4433int main(void) { return bswap32(0); }
4434EOF
52166aa0 4435if compile_prog "" "" ; then
6ae9a1f4
JQ
4436 bswap_h=yes
4437fi
4438
c589b249 4439##########################################
e49ab19f 4440# Do we have libiscsi >= 1.9.0
c589b249 4441if test "$libiscsi" != "no" ; then
e49ab19f 4442 if $pkg_config --atleast-version=1.9.0 libiscsi; then
3c33ea96 4443 libiscsi="yes"
ca871ec8
SW
4444 libiscsi_cflags=$($pkg_config --cflags libiscsi)
4445 libiscsi_libs=$($pkg_config --libs libiscsi)
c589b249
RS
4446 else
4447 if test "$libiscsi" = "yes" ; then
e49ab19f 4448 feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
c589b249
RS
4449 fi
4450 libiscsi="no"
4451 fi
4452fi
4453
8bacde8d
NC
4454##########################################
4455# Do we need libm
4456cat > $TMPC << EOF
4457#include <math.h>
f80ea986 4458int main(int argc, char **argv) { return isnan(sin((double)argc)); }
8bacde8d
NC
4459EOF
4460if compile_prog "" "" ; then
4461 :
4462elif compile_prog "" "-lm" ; then
4463 LIBS="-lm $LIBS"
4464 libs_qga="-lm $libs_qga"
4465else
76ad07a4 4466 error_exit "libm check failed"
8bacde8d
NC
4467fi
4468
da93a1fd
AL
4469##########################################
4470# Do we need librt
8bacde8d
NC
4471# uClibc provides 2 versions of clock_gettime(), one with realtime
4472# support and one without. This means that the clock_gettime() don't
4473# need -lrt. We still need it for timer_create() so we check for this
4474# function in addition.
da93a1fd
AL
4475cat > $TMPC <<EOF
4476#include <signal.h>
4477#include <time.h>
8bacde8d
NC
4478int main(void) {
4479 timer_create(CLOCK_REALTIME, NULL, NULL);
4480 return clock_gettime(CLOCK_REALTIME, NULL);
4481}
da93a1fd
AL
4482EOF
4483
52166aa0 4484if compile_prog "" "" ; then
07ffa4bd 4485 :
8bacde8d 4486# we need pthread for static linking. use previous pthread test result
18e588b1
RL
4487elif compile_prog "" "$pthread_lib -lrt" ; then
4488 LIBS="$LIBS -lrt"
4489 libs_qga="$libs_qga -lrt"
da93a1fd
AL
4490fi
4491
31ff504d 4492if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
78723752 4493 "$haiku" != "yes" ; then
6362a53f
JQ
4494 libs_softmmu="-lutil $libs_softmmu"
4495fi
4496
de5071c5 4497##########################################
cd4ec0b4
GH
4498# spice probe
4499if test "$spice" != "no" ; then
4500 cat > $TMPC << EOF
4501#include <spice.h>
4502int main(void) { spice_server_new(); return 0; }
4503EOF
710fc4f5
JD
4504 spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
4505 spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
65d5d3f9
SW
4506 if $pkg_config --atleast-version=0.12.0 spice-server && \
4507 $pkg_config --atleast-version=0.12.3 spice-protocol && \
cd4ec0b4
GH
4508 compile_prog "$spice_cflags" "$spice_libs" ; then
4509 spice="yes"
4510 libs_softmmu="$libs_softmmu $spice_libs"
4511 QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
2e0e3c39
AL
4512 spice_protocol_version=$($pkg_config --modversion spice-protocol)
4513 spice_server_version=$($pkg_config --modversion spice-server)
cd4ec0b4
GH
4514 else
4515 if test "$spice" = "yes" ; then
8efc9363
HT
4516 feature_not_found "spice" \
4517 "Install spice-server(>=0.12.0) and spice-protocol(>=0.12.3) devel"
cd4ec0b4
GH
4518 fi
4519 spice="no"
4520 fi
4521fi
4522
7b02f544 4523# check for smartcard support
7b02f544 4524if test "$smartcard" != "no"; then
0f5c642d 4525 if $pkg_config --atleast-version=2.5.1 libcacard; then
7b02f544
MAL
4526 libcacard_cflags=$($pkg_config --cflags libcacard)
4527 libcacard_libs=$($pkg_config --libs libcacard)
7b02f544 4528 smartcard="yes"
afd347ab 4529 else
7b02f544
MAL
4530 if test "$smartcard" = "yes"; then
4531 feature_not_found "smartcard" "Install libcacard devel"
111a38b0 4532 fi
7b02f544 4533 smartcard="no"
111a38b0
RR
4534 fi
4535fi
111a38b0 4536
2b2325ff
GH
4537# check for libusb
4538if test "$libusb" != "no" ; then
65d5d3f9 4539 if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
2b2325ff 4540 libusb="yes"
ca871ec8
SW
4541 libusb_cflags=$($pkg_config --cflags libusb-1.0)
4542 libusb_libs=$($pkg_config --libs libusb-1.0)
2b2325ff
GH
4543 else
4544 if test "$libusb" = "yes"; then
8efc9363 4545 feature_not_found "libusb" "Install libusb devel >= 1.0.13"
2b2325ff
GH
4546 fi
4547 libusb="no"
4548 fi
4549fi
4550
69354a83
HG
4551# check for usbredirparser for usb network redirection support
4552if test "$usb_redir" != "no" ; then
65d5d3f9 4553 if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
69354a83 4554 usb_redir="yes"
ca871ec8
SW
4555 usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
4556 usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
69354a83
HG
4557 else
4558 if test "$usb_redir" = "yes"; then
21684af0 4559 feature_not_found "usb-redir" "Install usbredir devel"
69354a83
HG
4560 fi
4561 usb_redir="no"
4562 fi
4563fi
4564
d9840e25
TS
4565##########################################
4566# check if we have VSS SDK headers for win
4567
4568if test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$vss_win32_sdk" != "no" ; then
4569 case "$vss_win32_sdk" in
690604f6 4570 "") vss_win32_include="-isystem $source_path" ;;
d9840e25
TS
4571 *\ *) # The SDK is installed in "Program Files" by default, but we cannot
4572 # handle path with spaces. So we symlink the headers into ".sdk/vss".
690604f6 4573 vss_win32_include="-isystem $source_path/.sdk/vss"
d9840e25
TS
4574 symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
4575 ;;
690604f6 4576 *) vss_win32_include="-isystem $vss_win32_sdk"
d9840e25
TS
4577 esac
4578 cat > $TMPC << EOF
4579#define __MIDL_user_allocate_free_DEFINED__
4580#include <inc/win2003/vss.h>
4581int main(void) { return VSS_CTX_BACKUP; }
4582EOF
4583 if compile_prog "$vss_win32_include" "" ; then
4584 guest_agent_with_vss="yes"
4585 QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
315d3184 4586 libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
f33ca81f 4587 qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
d9840e25
TS
4588 else
4589 if test "$vss_win32_sdk" != "" ; then
4590 echo "ERROR: Please download and install Microsoft VSS SDK:"
4591 echo "ERROR: http://www.microsoft.com/en-us/download/details.aspx?id=23490"
4592 echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
4593 echo "ERROR: scripts/extract-vsssdk-headers setup.exe"
4594 echo "ERROR: The headers are extracted in the directory \`inc'."
4595 feature_not_found "VSS support"
4596 fi
4597 guest_agent_with_vss="no"
4598 fi
4599fi
4600
4601##########################################
4602# lookup Windows platform SDK (if not specified)
4603# The SDK is needed only to build .tlb (type library) file of guest agent
4604# VSS provider from the source. It is usually unnecessary because the
4605# pre-compiled .tlb file is included.
4606
4607if test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$guest_agent_with_vss" = "yes" ; then
4608 if test -z "$win_sdk"; then
4609 programfiles="$PROGRAMFILES"
4610 test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
4611 if test -n "$programfiles"; then
4612 win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
4613 else
4614 feature_not_found "Windows SDK"
4615 fi
4616 elif test "$win_sdk" = "no"; then
4617 win_sdk=""
4618 fi
4619fi
4620
50cbebb9
MR
4621##########################################
4622# check if mingw environment provides a recent ntddscsi.h
4623if test "$mingw32" = "yes" -a "$guest_agent" != "no"; then
4624 cat > $TMPC << EOF
4625#include <windows.h>
4626#include <ntddscsi.h>
4627int main(void) {
4628#if !defined(IOCTL_SCSI_GET_ADDRESS)
4629#error Missing required ioctl definitions
4630#endif
4631 SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
4632 return addr.Lun;
4633}
4634EOF
4635 if compile_prog "" "" ; then
4636 guest_agent_ntddscsi=yes
c54e1eb4 4637 libs_qga="-lsetupapi $libs_qga"
50cbebb9
MR
4638 fi
4639fi
4640
9d9e1521
GH
4641##########################################
4642# virgl renderer probe
4643
4644if test "$virglrenderer" != "no" ; then
4645 cat > $TMPC << EOF
4646#include <virglrenderer.h>
4647int main(void) { virgl_renderer_poll(); return 0; }
4648EOF
4649 virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
4650 virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
47479c55 4651 virgl_version=$($pkg_config --modversion virglrenderer 2>/dev/null)
9d9e1521
GH
4652 if $pkg_config virglrenderer >/dev/null 2>&1 && \
4653 compile_prog "$virgl_cflags" "$virgl_libs" ; then
4654 virglrenderer="yes"
4655 else
4656 if test "$virglrenderer" = "yes" ; then
4657 feature_not_found "virglrenderer"
4658 fi
4659 virglrenderer="no"
4660 fi
4661fi
4662
8ca80760
RH
4663##########################################
4664# capstone
4665
e219c499
RH
4666case "$capstone" in
4667 "" | yes)
4668 if $pkg_config capstone; then
4669 capstone=system
123ac0bb 4670 elif test -e "${source_path}/.git" -a $git_update = 'yes' ; then
e219c499
RH
4671 capstone=git
4672 elif test -e "${source_path}/capstone/Makefile" ; then
4673 capstone=internal
4674 elif test -z "$capstone" ; then
4675 capstone=no
4676 else
4677 feature_not_found "capstone" "Install capstone devel or git submodule"
4678 fi
4679 ;;
4680
4681 system)
4682 if ! $pkg_config capstone; then
4683 feature_not_found "capstone" "Install capstone devel"
4684 fi
4685 ;;
4686esac
4687
4688case "$capstone" in
4689 git | internal)
4690 if test "$capstone" = git; then
4691 git_submodules="${git_submodules} capstone"
4692 fi
4693 mkdir -p capstone
4694 QEMU_CFLAGS="$QEMU_CFLAGS -I\$(SRC_PATH)/capstone/include"
4695 if test "$mingw32" = "yes"; then
4696 LIBCAPSTONE=capstone.lib
4697 else
4698 LIBCAPSTONE=libcapstone.a
4699 fi
4700 LIBS="-L\$(BUILD_DIR)/capstone -lcapstone $LIBS"
4701 ;;
4702
4703 system)
8ca80760
RH
4704 QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags capstone)"
4705 LIBS="$($pkg_config --libs capstone) $LIBS"
e219c499
RH
4706 ;;
4707
4708 no)
4709 ;;
4710 *)
4711 error_exit "Unknown state for capstone: $capstone"
4712 ;;
4713esac
8ca80760 4714
5f6b9e8f
BS
4715##########################################
4716# check if we have fdatasync
4717
4718fdatasync=no
4719cat > $TMPC << EOF
4720#include <unistd.h>
d1722a27
AR
4721int main(void) {
4722#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
4723return fdatasync(0);
4724#else
e172fe11 4725#error Not supported
d1722a27
AR
4726#endif
4727}
5f6b9e8f
BS
4728EOF
4729if compile_prog "" "" ; then
4730 fdatasync=yes
4731fi
4732
e78815a5
AF
4733##########################################
4734# check if we have madvise
4735
4736madvise=no
4737cat > $TMPC << EOF
4738#include <sys/types.h>
4739#include <sys/mman.h>
832ce9c2 4740#include <stddef.h>
e78815a5
AF
4741int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
4742EOF
4743if compile_prog "" "" ; then
4744 madvise=yes
4745fi
4746
4747##########################################
4748# check if we have posix_madvise
4749
4750posix_madvise=no
4751cat > $TMPC << EOF
4752#include <sys/mman.h>
832ce9c2 4753#include <stddef.h>
e78815a5
AF
4754int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
4755EOF
4756if compile_prog "" "" ; then
4757 posix_madvise=yes
4758fi
4759
9bc5a719
AG
4760##########################################
4761# check if we have posix_memalign()
4762
4763posix_memalign=no
4764cat > $TMPC << EOF
4765#include <stdlib.h>
4766int main(void) {
4767 void *p;
4768 return posix_memalign(&p, 8, 8);
4769}
4770EOF
4771if compile_prog "" "" ; then
4772 posix_memalign=yes
4773fi
4774
0a852417
PD
4775##########################################
4776# check if we have posix_syslog
4777
4778posix_syslog=no
4779cat > $TMPC << EOF
4780#include <syslog.h>
4781int main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
4782EOF
4783if compile_prog "" "" ; then
4784 posix_syslog=yes
4785fi
4786
401bc051
PM
4787##########################################
4788# check if we have sem_timedwait
4789
4790sem_timedwait=no
4791cat > $TMPC << EOF
4792#include <semaphore.h>
4793int main(void) { return sem_timedwait(0, 0); }
4794EOF
4795if compile_prog "" "" ; then
4796 sem_timedwait=yes
4797fi
4798
5c99fa37
KF
4799##########################################
4800# check if we have strchrnul
4801
4802strchrnul=no
4803cat > $TMPC << EOF
4804#include <string.h>
4805int main(void);
4806// Use a haystack that the compiler shouldn't be able to constant fold
4807char *haystack = (char*)&main;
4808int main(void) { return strchrnul(haystack, 'x') != &haystack[6]; }
4809EOF
4810if compile_prog "" "" ; then
4811 strchrnul=yes
4812fi
4813
94a420b1
SH
4814##########################################
4815# check if trace backend exists
4816
5b808275 4817$python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends > /dev/null 2> /dev/null
94a420b1 4818if test "$?" -ne 0 ; then
5b808275
LV
4819 error_exit "invalid trace backends" \
4820 "Please choose supported trace backends."
94a420b1
SH
4821fi
4822
7e24e92a
SH
4823##########################################
4824# For 'ust' backend, test if ust headers are present
5b808275 4825if have_backend "ust"; then
7e24e92a 4826 cat > $TMPC << EOF
bf15f63c 4827#include <lttng/tracepoint.h>
7e24e92a
SH
4828int main(void) { return 0; }
4829EOF
c79ed23d 4830 if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
bf15f63c 4831 if $pkg_config lttng-ust --exists; then
89138857 4832 lttng_ust_libs=$($pkg_config --libs lttng-ust)
bf15f63c 4833 else
c79ed23d 4834 lttng_ust_libs="-llttng-ust -ldl"
bf15f63c
MG
4835 fi
4836 if $pkg_config liburcu-bp --exists; then
89138857 4837 urcu_bp_libs=$($pkg_config --libs liburcu-bp)
bf15f63c
MG
4838 else
4839 urcu_bp_libs="-lurcu-bp"
4840 fi
4841
4842 LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
4843 libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
7e24e92a 4844 else
bf15f63c 4845 error_exit "Trace backend 'ust' missing lttng-ust header files"
7e24e92a
SH
4846 fi
4847fi
b3d08c02
DB
4848
4849##########################################
4850# For 'dtrace' backend, test if 'dtrace' command is present
5b808275 4851if have_backend "dtrace"; then
b3d08c02 4852 if ! has 'dtrace' ; then
76ad07a4 4853 error_exit "dtrace command is not found in PATH $PATH"
b3d08c02 4854 fi
c276b17d
DB
4855 trace_backend_stap="no"
4856 if has 'stap' ; then
4857 trace_backend_stap="yes"
4858 fi
b3d08c02
DB
4859fi
4860
023367e6 4861##########################################
519175a2 4862# check and set a backend for coroutine
d0e2fce5 4863
7c2acc70 4864# We prefer ucontext, but it's not always possible. The fallback
33c53c54
DB
4865# is sigcontext. On Windows the only valid backend is the Windows
4866# specific one.
7c2acc70
PM
4867
4868ucontext_works=no
4869if test "$darwin" != "yes"; then
4870 cat > $TMPC << EOF
d0e2fce5 4871#include <ucontext.h>
cdf84806
PM
4872#ifdef __stub_makecontext
4873#error Ignoring glibc stub makecontext which will always fail
4874#endif
75cafad7 4875int main(void) { makecontext(0, 0, 0); return 0; }
d0e2fce5 4876EOF
7c2acc70
PM
4877 if compile_prog "" "" ; then
4878 ucontext_works=yes
4879 fi
4880fi
4881
4882if test "$coroutine" = ""; then
4883 if test "$mingw32" = "yes"; then
4884 coroutine=win32
4885 elif test "$ucontext_works" = "yes"; then
4886 coroutine=ucontext
4887 else
4888 coroutine=sigaltstack
d0e2fce5 4889 fi
519175a2 4890else
7c2acc70
PM
4891 case $coroutine in
4892 windows)
4893 if test "$mingw32" != "yes"; then
4894 error_exit "'windows' coroutine backend only valid for Windows"
4895 fi
4896 # Unfortunately the user visible backend name doesn't match the
4897 # coroutine-*.c filename for this case, so we have to adjust it here.
4898 coroutine=win32
4899 ;;
4900 ucontext)
4901 if test "$ucontext_works" != "yes"; then
4902 feature_not_found "ucontext"
4903 fi
4904 ;;
33c53c54 4905 sigaltstack)
7c2acc70
PM
4906 if test "$mingw32" = "yes"; then
4907 error_exit "only the 'windows' coroutine backend is valid for Windows"
4908 fi
4909 ;;
4910 *)
4911 error_exit "unknown coroutine backend $coroutine"
4912 ;;
4913 esac
d0e2fce5
AK
4914fi
4915
70c60c08 4916if test "$coroutine_pool" = ""; then
33c53c54 4917 coroutine_pool=yes
70c60c08
SH
4918fi
4919
7d992e4d 4920if test "$debug_stack_usage" = "yes"; then
7d992e4d
PL
4921 if test "$coroutine_pool" = "yes"; then
4922 echo "WARN: disabling coroutine pool for stack usage debugging"
4923 coroutine_pool=no
4924 fi
4925fi
4926
4927
d2042378
AK
4928##########################################
4929# check if we have open_by_handle_at
4930
4e1797f9 4931open_by_handle_at=no
d2042378
AK
4932cat > $TMPC << EOF
4933#include <fcntl.h>
acc55ba8
SW
4934#if !defined(AT_EMPTY_PATH)
4935# error missing definition
4936#else
75cafad7 4937int main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
acc55ba8 4938#endif
d2042378
AK
4939EOF
4940if compile_prog "" "" ; then
4941 open_by_handle_at=yes
4942fi
4943
e06a765e
HPB
4944########################################
4945# check if we have linux/magic.h
4946
4947linux_magic_h=no
4948cat > $TMPC << EOF
4949#include <linux/magic.h>
4950int main(void) {
75cafad7 4951 return 0;
e06a765e
HPB
4952}
4953EOF
4954if compile_prog "" "" ; then
4955 linux_magic_h=yes
4956fi
4957
06d71fa1 4958########################################
c95e3080
KW
4959# check whether we can disable warning option with a pragma (this is needed
4960# to silence warnings in the headers of some versions of external libraries).
4961# This test has to be compiled with -Werror as otherwise an unknown pragma is
4962# only a warning.
4963#
4964# If we can't selectively disable warning in the code, disable -Werror so that
4965# the build doesn't fail anyway.
4966
06d71fa1
PM
4967pragma_disable_unused_but_set=no
4968cat > $TMPC << EOF
e6f53fd5 4969#pragma GCC diagnostic push
c95e3080 4970#pragma GCC diagnostic ignored "-Wstrict-prototypes"
e6f53fd5 4971#pragma GCC diagnostic pop
c95e3080 4972
06d71fa1
PM
4973int main(void) {
4974 return 0;
4975}
4976EOF
4977if compile_prog "-Werror" "" ; then
cc6e3ca9 4978 pragma_diagnostic_available=yes
c95e3080
KW
4979else
4980 werror=no
06d71fa1
PM
4981fi
4982
3f4349dc 4983########################################
541be927 4984# check if we have valgrind/valgrind.h
3f4349dc
KW
4985
4986valgrind_h=no
4987cat > $TMPC << EOF
4988#include <valgrind/valgrind.h>
3f4349dc 4989int main(void) {
3f4349dc
KW
4990 return 0;
4991}
4992EOF
4993if compile_prog "" "" ; then
4994 valgrind_h=yes
4995fi
4996
8ab1bf12
LC
4997########################################
4998# check if environ is declared
4999
5000has_environ=no
5001cat > $TMPC << EOF
5002#include <unistd.h>
5003int main(void) {
c075a723 5004 environ = 0;
8ab1bf12
LC
5005 return 0;
5006}
5007EOF
5008if compile_prog "" "" ; then
5009 has_environ=yes
5010fi
5011
76a347e1
RH
5012########################################
5013# check if cpuid.h is usable.
5014
76a347e1
RH
5015cat > $TMPC << EOF
5016#include <cpuid.h>
5017int main(void) {
774d566c
PM
5018 unsigned a, b, c, d;
5019 int max = __get_cpuid_max(0, 0);
5020
5021 if (max >= 1) {
5022 __cpuid(1, a, b, c, d);
5023 }
5024
5025 if (max >= 7) {
5026 __cpuid_count(7, 0, a, b, c, d);
5027 }
5028
5029 return 0;
76a347e1
RH
5030}
5031EOF
5032if compile_prog "" "" ; then
5033 cpuid_h=yes
5034fi
5035
5dd89908
RH
5036##########################################
5037# avx2 optimization requirement check
5038#
5039# There is no point enabling this if cpuid.h is not usable,
5040# since we won't be able to select the new routines.
5041
5042if test $cpuid_h = yes; then
5043 cat > $TMPC << EOF
5044#pragma GCC push_options
5045#pragma GCC target("avx2")
5046#include <cpuid.h>
5047#include <immintrin.h>
5048static int bar(void *a) {
5049 __m256i x = *(__m256i *)a;
5050 return _mm256_testz_si256(x, x);
5051}
5052int main(int argc, char *argv[]) { return bar(argv[0]); }
5053EOF
5054 if compile_object "" ; then
5055 avx2_opt="yes"
5056 fi
5057fi
5058
f540166b
RH
5059########################################
5060# check if __[u]int128_t is usable.
5061
5062int128=no
5063cat > $TMPC << EOF
a00f66ab
SW
5064#if defined(__clang_major__) && defined(__clang_minor__)
5065# if ((__clang_major__ < 3) || (__clang_major__ == 3) && (__clang_minor__ < 2))
5066# error __int128_t does not work in CLANG before 3.2
5067# endif
5068#endif
f540166b
RH
5069__int128_t a;
5070__uint128_t b;
5071int main (void) {
5072 a = a + b;
5073 b = a * b;
464e3671 5074 a = a * a;
f540166b
RH
5075 return 0;
5076}
5077EOF
5078if compile_prog "" "" ; then
5079 int128=yes
5080fi
76a347e1 5081
7ebee43e
RH
5082#########################################
5083# See if 128-bit atomic operations are supported.
5084
5085atomic128=no
5086if test "$int128" = "yes"; then
5087 cat > $TMPC << EOF
5088int main(void)
5089{
5090 unsigned __int128 x = 0, y = 0;
5091 y = __atomic_load_16(&x, 0);
5092 __atomic_store_16(&x, y, 0);
5093 __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
5094 return 0;
5095}
5096EOF
5097 if compile_prog "" "" ; then
5098 atomic128=yes
5099 fi
5100fi
5101
df79b996
RH
5102#########################################
5103# See if 64-bit atomic operations are supported.
5104# Note that without __atomic builtins, we can only
5105# assume atomic loads/stores max at pointer size.
5106
5107cat > $TMPC << EOF
5108#include <stdint.h>
5109int main(void)
5110{
5111 uint64_t x = 0, y = 0;
5112#ifdef __ATOMIC_RELAXED
5113 y = __atomic_load_8(&x, 0);
5114 __atomic_store_8(&x, y, 0);
5115 __atomic_compare_exchange_8(&x, &y, x, 0, 0, 0);
5116 __atomic_exchange_8(&x, y, 0);
5117 __atomic_fetch_add_8(&x, y, 0);
5118#else
5119 typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
5120 __sync_lock_test_and_set(&x, y);
5121 __sync_val_compare_and_swap(&x, y, 0);
5122 __sync_fetch_and_add(&x, y);
5123#endif
5124 return 0;
5125}
5126EOF
5127if compile_prog "" "" ; then
5128 atomic64=yes
5129fi
5130
db432672
RH
5131########################################
5132# See if 16-byte vector operations are supported.
5133# Even without a vector unit the compiler may expand these.
5134# There is a bug in old GCC for PPC that crashes here.
5135# Unfortunately it's the system compiler for Centos 7.
5136
5137cat > $TMPC << EOF
5138typedef unsigned char U1 __attribute__((vector_size(16)));
5139typedef unsigned short U2 __attribute__((vector_size(16)));
5140typedef unsigned int U4 __attribute__((vector_size(16)));
5141typedef unsigned long long U8 __attribute__((vector_size(16)));
5142typedef signed char S1 __attribute__((vector_size(16)));
5143typedef signed short S2 __attribute__((vector_size(16)));
5144typedef signed int S4 __attribute__((vector_size(16)));
5145typedef signed long long S8 __attribute__((vector_size(16)));
5146static U1 a1, b1;
5147static U2 a2, b2;
5148static U4 a4, b4;
5149static U8 a8, b8;
5150static S1 c1;
5151static S2 c2;
5152static S4 c4;
5153static S8 c8;
5154static int i;
74912f6d
LV
5155void helper(void *d, void *a, int shift, int i);
5156void helper(void *d, void *a, int shift, int i)
5157{
5158 *(U1 *)(d + i) = *(U1 *)(a + i) << shift;
5159 *(U2 *)(d + i) = *(U2 *)(a + i) << shift;
5160 *(U4 *)(d + i) = *(U4 *)(a + i) << shift;
5161 *(U8 *)(d + i) = *(U8 *)(a + i) << shift;
5162}
db432672
RH
5163int main(void)
5164{
5165 a1 += b1; a2 += b2; a4 += b4; a8 += b8;
5166 a1 -= b1; a2 -= b2; a4 -= b4; a8 -= b8;
5167 a1 *= b1; a2 *= b2; a4 *= b4; a8 *= b8;
5168 a1 &= b1; a2 &= b2; a4 &= b4; a8 &= b8;
5169 a1 |= b1; a2 |= b2; a4 |= b4; a8 |= b8;
5170 a1 ^= b1; a2 ^= b2; a4 ^= b4; a8 ^= b8;
5171 a1 <<= i; a2 <<= i; a4 <<= i; a8 <<= i;
5172 a1 >>= i; a2 >>= i; a4 >>= i; a8 >>= i;
5173 c1 >>= i; c2 >>= i; c4 >>= i; c8 >>= i;
5174 return 0;
5175}
5176EOF
5177
5178vector16=no
5179if compile_prog "" "" ; then
5180 vector16=yes
5181fi
5182
1e6e9aca
RH
5183########################################
5184# check if getauxval is available.
5185
5186getauxval=no
5187cat > $TMPC << EOF
5188#include <sys/auxv.h>
5189int main(void) {
5190 return getauxval(AT_HWCAP) == 0;
5191}
5192EOF
5193if compile_prog "" "" ; then
5194 getauxval=yes
5195fi
5196
fd0e6053
JS
5197########################################
5198# check if ccache is interfering with
5199# semantic analysis of macros
5200
5e4dfd3d 5201unset CCACHE_CPP2
fd0e6053
JS
5202ccache_cpp2=no
5203cat > $TMPC << EOF
5204static const int Z = 1;
5205#define fn() ({ Z; })
5206#define TAUT(X) ((X) == Z)
5207#define PAREN(X, Y) (X == Y)
5208#define ID(X) (X)
5209int main(int argc, char *argv[])
5210{
5211 int x = 0, y = 0;
5212 x = ID(x);
5213 x = fn();
5214 fn();
5215 if (PAREN(x, y)) return 0;
5216 if (TAUT(Z)) return 0;
5217 return 0;
5218}
5219EOF
5220
5221if ! compile_object "-Werror"; then
5222 ccache_cpp2=yes
5223fi
5224
b553a042
JS
5225#################################################
5226# clang does not support glibc + FORTIFY_SOURCE.
5227
5228if test "$fortify_source" != "no"; then
5229 if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
5230 fortify_source="no";
e189091f 5231 elif test -n "$cxx" && has $cxx &&
cfcc7c14 5232 echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
b553a042
JS
5233 fortify_source="no";
5234 else
5235 fortify_source="yes"
5236 fi
5237fi
5238
1efad060
FZ
5239###############################################
5240# Check if copy_file_range is provided by glibc
5241have_copy_file_range=no
5242cat > $TMPC << EOF
5243#include <unistd.h>
5244int main(void) {
5245 copy_file_range(0, NULL, 0, NULL, 0, 0);
5246 return 0;
5247}
5248EOF
5249if compile_prog "" "" ; then
5250 have_copy_file_range=yes
5251fi
5252
277abf15
JV
5253##########################################
5254# check if struct fsxattr is available via linux/fs.h
5255
5256have_fsxattr=no
5257cat > $TMPC << EOF
5258#include <linux/fs.h>
5259struct fsxattr foo;
5260int main(void) {
5261 return 0;
5262}
5263EOF
5264if compile_prog "" "" ; then
5265 have_fsxattr=yes
5266fi
5267
a40161cb
PB
5268##########################################
5269# check for usable membarrier system call
5270if test "$membarrier" = "yes"; then
5271 have_membarrier=no
5272 if test "$mingw32" = "yes" ; then
5273 have_membarrier=yes
5274 elif test "$linux" = "yes" ; then
5275 cat > $TMPC << EOF
5276 #include <linux/membarrier.h>
5277 #include <sys/syscall.h>
5278 #include <unistd.h>
5279 #include <stdlib.h>
5280 int main(void) {
5281 syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
5282 syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0);
5283 exit(0);
5284 }
5285EOF
5286 if compile_prog "" "" ; then
5287 have_membarrier=yes
5288 fi
5289 fi
5290 if test "$have_membarrier" = "no"; then
5291 feature_not_found "membarrier" "membarrier system call not available"
5292 fi
5293else
5294 # Do not enable it by default even for Mingw32, because it doesn't
5295 # work on Wine.
5296 membarrier=no
5297fi
5298
b66e10e4
PM
5299##########################################
5300# check if rtnetlink.h exists and is useful
575b22b1
LV
5301have_rtnetlink=no
5302cat > $TMPC << EOF
5303#include <linux/rtnetlink.h>
5304int main(void) {
5305 return IFLA_PROTO_DOWN;
5306}
5307EOF
5308if compile_prog "" "" ; then
5309 have_rtnetlink=yes
5310fi
5311
6a02c806
SH
5312##########################################
5313# check for usable AF_VSOCK environment
5314have_af_vsock=no
5315cat > $TMPC << EOF
5316#include <errno.h>
5317#include <sys/types.h>
5318#include <sys/socket.h>
5319#if !defined(AF_VSOCK)
5320# error missing AF_VSOCK flag
5321#endif
5322#include <linux/vm_sockets.h>
5323int main(void) {
5324 int sock, ret;
5325 struct sockaddr_vm svm;
5326 socklen_t len = sizeof(svm);
5327 sock = socket(AF_VSOCK, SOCK_STREAM, 0);
5328 ret = getpeername(sock, (struct sockaddr *)&svm, &len);
5329 if ((ret == -1) && (errno == ENOTCONN)) {
5330 return 0;
5331 }
5332 return -1;
5333}
5334EOF
5335if compile_prog "" "" ; then
5336 have_af_vsock=yes
5337fi
5338
f0d92b56
LM
5339##########################################
5340# check for usable AF_ALG environment
5341hava_afalg=no
5342cat > $TMPC << EOF
5343#include <errno.h>
5344#include <sys/types.h>
5345#include <sys/socket.h>
5346#include <linux/if_alg.h>
5347int main(void) {
5348 int sock;
5349 sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
5350 return sock;
5351}
5352EOF
5353if compile_prog "" "" ; then
5354 have_afalg=yes
5355fi
5356if test "$crypto_afalg" = "yes"
5357then
5358 if test "$have_afalg" != "yes"
5359 then
5360 error_exit "AF_ALG requested but could not be detected"
5361 fi
5362fi
5363
5364
c97d6d2c
SAGDR
5365#################################################
5366# Check to see if we have the Hypervisor framework
d2d08522 5367if [ "$darwin" = "yes" ] ; then
c97d6d2c
SAGDR
5368 cat > $TMPC << EOF
5369#include <Hypervisor/hv.h>
5370int main() { return 0;}
5371EOF
5372 if ! compile_object ""; then
5373 hvf='no'
5374 else
5375 hvf='yes'
5376 LDFLAGS="-framework Hypervisor $LDFLAGS"
5377 fi
5378fi
5379
6969ec6c
JC
5380#################################################
5381# Sparc implicitly links with --relax, which is
5382# incompatible with -r, so --no-relax should be
5383# given. It does no harm to give it on other
5384# platforms too.
5385
5386# Note: the prototype is needed since QEMU_CFLAGS
5387# contains -Wmissing-prototypes
5388cat > $TMPC << EOF
5389extern int foo(void);
5390int foo(void) { return 0; }
5391EOF
5392if ! compile_object ""; then
5393 error_exit "Failed to compile object file for LD_REL_FLAGS test"
5394fi
7ecf44a5
PB
5395for i in '-Wl,-r -Wl,--no-relax' -Wl,-r -r; do
5396 if do_cc -nostdlib $i -o $TMPMO $TMPO; then
5397 LD_REL_FLAGS=$i
5398 break
5399 fi
5400done
5401if test "$modules" = "yes" && test "$LD_REL_FLAGS" = ""; then
5402 feature_not_found "modules" "Cannot find how to build relocatable objects"
6969ec6c
JC
5403fi
5404
4d04351f
CC
5405##########################################
5406# check for sysmacros.h
5407
5408have_sysmacros=no
5409cat > $TMPC << EOF
5410#include <sys/sysmacros.h>
5411int main(void) {
5412 return makedev(0, 0);
5413}
5414EOF
5415if compile_prog "" "" ; then
5416 have_sysmacros=yes
5417fi
5418
da92c3ff
AM
5419##########################################
5420# Veritas HyperScale block driver VxHS
5421# Check if libvxhs is installed
5422
5423if test "$vxhs" != "no" ; then
5424 cat > $TMPC <<EOF
5425#include <stdint.h>
5426#include <qnio/qnio_api.h>
5427
5428void *vxhs_callback;
5429
5430int main(void) {
5431 iio_init(QNIO_VERSION, vxhs_callback);
5432 return 0;
5433}
5434EOF
5435 vxhs_libs="-lvxhs -lssl"
5436 if compile_prog "" "$vxhs_libs" ; then
5437 vxhs=yes
5438 else
5439 if test "$vxhs" = "yes" ; then
5440 feature_not_found "vxhs block device" "Install libvxhs See github"
5441 fi
5442 vxhs=no
5443 fi
5444fi
5445
49e00a18
AG
5446##########################################
5447# check for _Static_assert()
5448
5449have_static_assert=no
5450cat > $TMPC << EOF
5451_Static_assert(1, "success");
5452int main(void) {
5453 return 0;
5454}
5455EOF
5456if compile_prog "" "" ; then
5457 have_static_assert=yes
5458fi
5459
e674605f
TG
5460##########################################
5461# check for utmpx.h, it is missing e.g. on OpenBSD
5462
5463have_utmpx=no
5464cat > $TMPC << EOF
5465#include <utmpx.h>
5466struct utmpx user_info;
5467int main(void) {
5468 return 0;
5469}
5470EOF
5471if compile_prog "" "" ; then
5472 have_utmpx=yes
5473fi
5474
247724cb
MAL
5475##########################################
5476# checks for sanitizers
5477
247724cb
MAL
5478have_asan=no
5479have_ubsan=no
d83414e1
MAL
5480have_asan_iface_h=no
5481have_asan_iface_fiber=no
247724cb
MAL
5482
5483if test "$sanitizers" = "yes" ; then
b9f44da2 5484 write_c_skeleton
247724cb
MAL
5485 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
5486 have_asan=yes
5487 fi
b9f44da2
MAL
5488
5489 # we could use a simple skeleton for flags checks, but this also
5490 # detect the static linking issue of ubsan, see also:
5491 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
5492 cat > $TMPC << EOF
5493#include <stdlib.h>
5494int main(void) {
5495 void *tmp = malloc(10);
5496 return *(int *)(tmp + 2);
5497}
5498EOF
247724cb
MAL
5499 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
5500 have_ubsan=yes
5501 fi
d83414e1
MAL
5502
5503 if check_include "sanitizer/asan_interface.h" ; then
5504 have_asan_iface_h=yes
5505 fi
5506
5507 cat > $TMPC << EOF
5508#include <sanitizer/asan_interface.h>
5509int main(void) {
5510 __sanitizer_start_switch_fiber(0, 0, 0);
5511 return 0;
5512}
5513EOF
5514 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
5515 have_asan_iface_fiber=yes
5516 fi
247724cb
MAL
5517fi
5518
51a12b51
AB
5519##########################################
5520# Docker and cross-compiler support
5521#
5522# This is specifically for building test
5523# cases for foreign architectures, not
5524# cross-compiling QEMU itself.
5525
5526if has "docker"; then
5527 docker=$($python $source_path/tests/docker/docker.py probe)
5528fi
5529
7e24e92a 5530##########################################
e86ecd4b
JQ
5531# End of CC checks
5532# After here, no more $cc or $ld runs
5533
d83414e1
MAL
5534write_c_skeleton
5535
1d728c39
BS
5536if test "$gcov" = "yes" ; then
5537 CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
5538 LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
b553a042 5539elif test "$fortify_source" = "yes" ; then
e600cdf3 5540 CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
48e56d50
PB
5541elif test "$debug" = "no"; then
5542 CFLAGS="-O2 $CFLAGS"
e86ecd4b 5543fi
a316e378 5544
247724cb
MAL
5545if test "$have_asan" = "yes"; then
5546 CFLAGS="-fsanitize=address $CFLAGS"
d83414e1
MAL
5547 if test "$have_asan_iface_h" = "no" ; then
5548 echo "ASAN build enabled, but ASAN header missing." \
5549 "Without code annotation, the report may be inferior."
5550 elif test "$have_asan_iface_fiber" = "no" ; then
5551 echo "ASAN build enabled, but ASAN header is too old." \
5552 "Without code annotation, the report may be inferior."
5553 fi
247724cb
MAL
5554fi
5555if test "$have_ubsan" = "yes"; then
5556 CFLAGS="-fsanitize=undefined $CFLAGS"
5557fi
5558
6542aa9c
PL
5559##########################################
5560# Do we have libnfs
5561if test "$libnfs" != "no" ; then
b7d769c9 5562 if $pkg_config --atleast-version=1.9.3 libnfs; then
6542aa9c
PL
5563 libnfs="yes"
5564 libnfs_libs=$($pkg_config --libs libnfs)
6542aa9c
PL
5565 else
5566 if test "$libnfs" = "yes" ; then
8efc9363 5567 feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
6542aa9c
PL
5568 fi
5569 libnfs="no"
5570 fi
5571fi
1d728c39 5572
6ca026cb
PM
5573# Now we've finished running tests it's OK to add -Werror to the compiler flags
5574if test "$werror" = "yes"; then
5575 QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
5576fi
5577
e86ecd4b
JQ
5578if test "$solaris" = "no" ; then
5579 if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
1156c669 5580 LDFLAGS="-Wl,--warn-common $LDFLAGS"
e86ecd4b
JQ
5581 fi
5582fi
5583
94dd53c5
GH
5584# test if pod2man has --utf8 option
5585if pod2man --help | grep -q utf8; then
5586 POD2MAN="pod2man --utf8"
5587else
5588 POD2MAN="pod2man"
5589fi
5590
952afb71
BS
5591# Use ASLR, no-SEH and DEP if available
5592if test "$mingw32" = "yes" ; then
5593 for flag in --dynamicbase --no-seh --nxcompat; do
e9a3591f 5594 if ld_has $flag ; then
952afb71
BS
5595 LDFLAGS="-Wl,$flag $LDFLAGS"
5596 fi
5597 done
5598fi
5599
10ea68b3 5600qemu_confdir=$sysconfdir$confsuffix
e26110cf 5601qemu_moddir=$libdir$confsuffix
528ae5b8 5602qemu_datadir=$datadir$confsuffix
834574ea 5603qemu_localedir="$datadir/locale"
e7b45cc4 5604
e0580342
KR
5605# We can only support ivshmem if we have eventfd
5606if [ "$eventfd" = "yes" ]; then
5607 ivshmem=yes
5608fi
5609
4b1c11fd
DB
5610tools=""
5611if test "$want_tools" = "yes" ; then
ca35f780 5612 tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
4b1c11fd
DB
5613 if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
5614 tools="qemu-nbd\$(EXESUF) $tools"
b1449edb
KR
5615 fi
5616 if [ "$ivshmem" = "yes" ]; then
a75eb03b 5617 tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools"
4b1c11fd
DB
5618 fi
5619fi
5620if test "$softmmu" = yes ; then
b855f8d1
PB
5621 if test "$linux" = yes; then
5622 if test "$virtfs" != no && test "$cap" = yes && test "$attr" = yes ; then
aabfd88d
AF
5623 virtfs=yes
5624 tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
5625 else
5626 if test "$virtfs" = yes; then
b855f8d1 5627 error_exit "VirtFS requires libcap devel and libattr devel"
983eef5a 5628 fi
17500370 5629 virtfs=no
aabfd88d 5630 fi
fe8fc5ae
PB
5631 if test "$mpath" != no && test "$mpathpersist" = yes ; then
5632 mpath=yes
5633 else
5634 if test "$mpath" = yes; then
5635 error_exit "Multipath requires libmpathpersist devel"
5636 fi
5637 mpath=no
5638 fi
b855f8d1
PB
5639 tools="$tools scsi/qemu-pr-helper\$(EXESUF)"
5640 else
5641 if test "$virtfs" = yes; then
5642 error_exit "VirtFS is supported only on Linux"
5643 fi
5644 virtfs=no
fe8fc5ae
PB
5645 if test "$mpath" = yes; then
5646 error_exit "Multipath is supported only on Linux"
5647 fi
5648 mpath=no
17bff52b 5649 fi
ff69fd8c
LV
5650 if test "$xkbcommon" = "yes"; then
5651 tools="qemu-keymap\$(EXESUF) $tools"
5652 fi
6a021536 5653fi
9d6bc27b
MR
5654
5655# Probe for guest agent support/options
5656
e8ef31a3 5657if [ "$guest_agent" != "no" ]; then
b39297ae 5658 if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
fafcaf1d 5659 tools="qemu-ga $tools"
e8ef31a3
MT
5660 guest_agent=yes
5661 elif [ "$guest_agent" != yes ]; then
5662 guest_agent=no
5663 else
5664 error_exit "Guest agent is not supported on this platform"
ca35f780 5665 fi
00c705fb 5666fi
ca35f780 5667
9d6bc27b
MR
5668# Guest agent Window MSI package
5669
5670if test "$guest_agent" != yes; then
5671 if test "$guest_agent_msi" = yes; then
5672 error_exit "MSI guest agent package requires guest agent enabled"
5673 fi
5674 guest_agent_msi=no
5675elif test "$mingw32" != "yes"; then
5676 if test "$guest_agent_msi" = "yes"; then
5677 error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
5678 fi
5679 guest_agent_msi=no
5680elif ! has wixl; then
5681 if test "$guest_agent_msi" = "yes"; then
5682 error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
5683 fi
5684 guest_agent_msi=no
1a34904e
MR
5685else
5686 # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
5687 # disabled explicitly
5688 if test "$guest_agent_msi" != "no"; then
5689 guest_agent_msi=yes
5690 fi
9d6bc27b
MR
5691fi
5692
1a34904e 5693if test "$guest_agent_msi" = "yes"; then
9d6bc27b
MR
5694 if test "$guest_agent_with_vss" = "yes"; then
5695 QEMU_GA_MSI_WITH_VSS="-D InstallVss"
5696 fi
5697
5698 if test "$QEMU_GA_MANUFACTURER" = ""; then
5699 QEMU_GA_MANUFACTURER=QEMU
5700 fi
5701
5702 if test "$QEMU_GA_DISTRO" = ""; then
5703 QEMU_GA_DISTRO=Linux
5704 fi
5705
5706 if test "$QEMU_GA_VERSION" = ""; then
89138857 5707 QEMU_GA_VERSION=$(cat $source_path/VERSION)
9d6bc27b
MR
5708 fi
5709
89138857 5710 QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
9d6bc27b
MR
5711
5712 case "$cpu" in
5713 x86_64)
5714 QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
5715 ;;
5716 i386)
5717 QEMU_GA_MSI_ARCH="-D Arch=32"
5718 ;;
5719 *)
5720 error_exit "CPU $cpu not supported for building installation package"
5721 ;;
5722 esac
5723fi
5724
ca35f780
PB
5725# Mac OS X ships with a broken assembler
5726roms=
5727if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
5728 "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
5729 "$softmmu" = yes ; then
e57218b6 5730 # Different host OS linkers have different ideas about the name of the ELF
c65d5e4e
BS
5731 # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
5732 # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
5733 for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
e57218b6
PM
5734 if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
5735 ld_i386_emulation="$emu"
5736 roms="optionrom"
5737 break
5738 fi
5739 done
ca35f780 5740fi
d0384d1d 5741if test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
39ac8455
DG
5742 roms="$roms spapr-rtas"
5743fi
ca35f780 5744
9933c305
CB
5745if test "$cpu" = "s390x" ; then
5746 roms="$roms s390-ccw"
5747fi
5748
964c6fa1 5749# Probe for the need for relocating the user-only binary.
92fe2ba8 5750if ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) && [ "$pie" = no ]; then
964c6fa1
RH
5751 textseg_addr=
5752 case "$cpu" in
479eb121
RH
5753 arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
5754 # ??? Rationale for choosing this address
964c6fa1
RH
5755 textseg_addr=0x60000000
5756 ;;
5757 mips)
479eb121
RH
5758 # A 256M aligned address, high in the address space, with enough
5759 # room for the code_gen_buffer above it before the stack.
5760 textseg_addr=0x60000000
964c6fa1
RH
5761 ;;
5762 esac
5763 if [ -n "$textseg_addr" ]; then
5764 cat > $TMPC <<EOF
5765 int main(void) { return 0; }
5766EOF
5767 textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
5768 if ! compile_prog "" "$textseg_ldflags"; then
5769 # In case ld does not support -Ttext-segment, edit the default linker
5770 # script via sed to set the .text start addr. This is needed on FreeBSD
5771 # at least.
92fe2ba8
PM
5772 if ! $ld --verbose >/dev/null 2>&1; then
5773 error_exit \
5774 "We need to link the QEMU user mode binaries at a" \
5775 "specific text address. Unfortunately your linker" \
5776 "doesn't support either the -Ttext-segment option or" \
5777 "printing the default linker script with --verbose." \
5778 "If you don't want the user mode binaries, pass the" \
5779 "--disable-user option to configure."
5780 fi
5781
964c6fa1
RH
5782 $ld --verbose | sed \
5783 -e '1,/==================================================/d' \
5784 -e '/==================================================/,$d' \
5785 -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
5786 -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
5787 textseg_ldflags="-Wl,-T../config-host.ld"
5788 fi
5789 fi
5790fi
5791
11cde1c8
BD
5792# Check that the C++ compiler exists and works with the C compiler.
5793# All the QEMU_CXXFLAGS are based on QEMU_CFLAGS. Keep this at the end to don't miss any other that could be added.
5794if has $cxx; then
5795 cat > $TMPC <<EOF
5796int c_function(void);
5797int main(void) { return c_function(); }
5798EOF
5799
5800 compile_object
5801
5802 cat > $TMPCXX <<EOF
5803extern "C" {
5804 int c_function(void);
5805}
5806int c_function(void) { return 42; }
5807EOF
5808
5809 update_cxxflags
5810
5811 if do_cxx $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $LDFLAGS; then
5812 # C++ compiler $cxx works ok with C compiler $cc
5813 :
5814 else
5815 echo "C++ compiler $cxx does not work with C compiler $cc"
5816 echo "Disabling C++ specific optional code"
5817 cxx=
5818 fi
5819else
5820 echo "No C++ compiler available; disabling C++ specific optional code"
5821 cxx=
5822fi
5823
02d34f62
CR
5824echo_version() {
5825 if test "$1" = "yes" ; then
5826 echo "($2)"
5827 fi
5828}
5829
50e12060
JK
5830# prepend pixman and ftd flags after all config tests are done
5831QEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"
8a99e9a3 5832QEMU_LDFLAGS="$fdt_ldflags $QEMU_LDFLAGS"
50e12060 5833libs_softmmu="$pixman_libs $libs_softmmu"
5ca9388a 5834
43ce4dfe 5835echo "Install prefix $prefix"
89138857 5836echo "BIOS directory $(eval echo $qemu_datadir)"
3d5eecab 5837echo "firmware path $(eval echo $firmwarepath)"
89138857
SW
5838echo "binary directory $(eval echo $bindir)"
5839echo "library directory $(eval echo $libdir)"
5840echo "module directory $(eval echo $qemu_moddir)"
5841echo "libexec directory $(eval echo $libexecdir)"
5842echo "include directory $(eval echo $includedir)"
5843echo "config directory $(eval echo $sysconfdir)"
11d9f695 5844if test "$mingw32" = "no" ; then
89138857
SW
5845echo "local state directory $(eval echo $local_statedir)"
5846echo "Manual directory $(eval echo $mandir)"
43ce4dfe 5847echo "ELF interp prefix $interp_prefix"
5a699bbb
LE
5848else
5849echo "local state directory queried at runtime"
d9840e25 5850echo "Windows SDK $win_sdk"
11d9f695 5851fi
5a67135a 5852echo "Source path $source_path"
cc84d63a 5853echo "GIT binary $git"
aef45d51 5854echo "GIT submodules $git_submodules"
43ce4dfe 5855echo "C compiler $cc"
83469015 5856echo "Host C compiler $host_cc"
83f73fce 5857echo "C++ compiler $cxx"
3c4a4d0d 5858echo "Objective-C compiler $objcc"
45d285ab 5859echo "ARFLAGS $ARFLAGS"
0c439cbf 5860echo "CFLAGS $CFLAGS"
a558ee17 5861echo "QEMU_CFLAGS $QEMU_CFLAGS"
0c439cbf 5862echo "LDFLAGS $LDFLAGS"
8a99e9a3 5863echo "QEMU_LDFLAGS $QEMU_LDFLAGS"
43ce4dfe 5864echo "make $make"
6a882643 5865echo "install $install"
c886edfb 5866echo "python $python"
e2d8830e
BS
5867if test "$slirp" = "yes" ; then
5868 echo "smbd $smbd"
5869fi
17969268 5870echo "module support $modules"
43ce4dfe 5871echo "host CPU $cpu"
de83cd02 5872echo "host big endian $bigendian"
97a847bc 5873echo "target list $target_list"
43ce4dfe 5874echo "gprof enabled $gprof"
03b4fe7d 5875echo "sparse enabled $sparse"
1625af87 5876echo "strip binaries $strip_opt"
05c2a3e7 5877echo "profiler $profiler"
43ce4dfe 5878echo "static build $static"
5b0753e0
FB
5879if test "$darwin" = "yes" ; then
5880 echo "Cocoa support $cocoa"
5881fi
89138857
SW
5882echo "SDL support $sdl $(echo_version $sdl $sdlversion)"
5883echo "GTK support $gtk $(echo_version $gtk $gtk_version)"
925a0400 5884echo "GTK GL support $gtk_gl"
89138857 5885echo "VTE support $vte $(echo_version $vte $vteversion)"
a1c5e949 5886echo "TLS priority $tls_priority"
ddbb0d09 5887echo "GNUTLS support $gnutls"
b917da4c 5888echo "GNUTLS rnd $gnutls_rnd"
91bfcdb0 5889echo "libgcrypt $gcrypt"
37788f25 5890echo "libgcrypt kdf $gcrypt_kdf"
89138857 5891echo "nettle $nettle $(echo_version $nettle $nettle_version)"
fff2f982 5892echo "nettle kdf $nettle_kdf"
9a2fd434 5893echo "libtasn1 $tasn1"
4d3b6f6e 5894echo "curses support $curses"
47479c55 5895echo "virgl support $virglrenderer $(echo_version $virglrenderer $virgl_version)"
769ce76d 5896echo "curl support $curl"
67b915a5 5897echo "mingw32 support $mingw32"
0c58ac1c 5898echo "Audio drivers $audio_drv_list"
b64ec4e4
FZ
5899echo "Block whitelist (rw) $block_drv_rw_whitelist"
5900echo "Block whitelist (ro) $block_drv_ro_whitelist"
983eef5a 5901echo "VirtFS support $virtfs"
fe8fc5ae 5902echo "Multipath support $mpath"
821601ea
JS
5903echo "VNC support $vnc"
5904if test "$vnc" = "yes" ; then
821601ea
JS
5905 echo "VNC SASL support $vnc_sasl"
5906 echo "VNC JPEG support $vnc_jpeg"
5907 echo "VNC PNG support $vnc_png"
821601ea 5908fi
3142255c
BS
5909if test -n "$sparc_cpu"; then
5910 echo "Target Sparc Arch $sparc_cpu"
5911fi
e37630ca 5912echo "xen support $xen"
3996e85c
PD
5913if test "$xen" = "yes" ; then
5914 echo "xen ctrl version $xen_ctrl_version"
64a7ad6f 5915 echo "pv dom build $xen_pv_domain_build"
3996e85c 5916fi
2e4d9fb1 5917echo "brlapi support $brlapi"
a20a6f46 5918echo "bluez support $bluez"
a25dba17 5919echo "Documentation $docs"
40d6444e 5920echo "PIE $pie"
8a16d273 5921echo "vde support $vde"
58952137 5922echo "netmap support $netmap"
5c6c3a6c 5923echo "Linux AIO support $linux_aio"
758e8e38 5924echo "ATTR/XATTR support $attr"
77755340 5925echo "Install blobs $blobs"
b31a0277 5926echo "KVM support $kvm"
b0cb0a66 5927echo "HAX support $hax"
c97d6d2c 5928echo "HVF support $hvf"
d661d9a4 5929echo "WHPX support $whpx"
b3f6ea7e
PB
5930echo "TCG support $tcg"
5931if test "$tcg" = "yes" ; then
5932 echo "TCG debug enabled $debug_tcg"
5933 echo "TCG interpreter $tcg_interpreter"
5934fi
5a22ab71 5935echo "malloc trim support $malloc_trim"
2da776db 5936echo "RDMA support $rdma"
f652e6af 5937echo "fdt support $fdt"
a40161cb 5938echo "membarrier $membarrier"
ceb42de8 5939echo "preadv support $preadv"
5f6b9e8f 5940echo "fdatasync $fdatasync"
e78815a5
AF
5941echo "madvise $madvise"
5942echo "posix_madvise $posix_madvise"
9bc5a719 5943echo "posix_memalign $posix_memalign"
47e98658 5944echo "libcap-ng support $cap_ng"
d5970055 5945echo "vhost-net support $vhost_net"
042cea27 5946echo "vhost-crypto support $vhost_crypto"
5e9be92d 5947echo "vhost-scsi support $vhost_scsi"
fc0b9b0e 5948echo "vhost-vsock support $vhost_vsock"
e6a74868 5949echo "vhost-user support $vhost_user"
5b808275 5950echo "Trace backends $trace_backends"
713572a7 5951if have_backend "simple"; then
9410b56c 5952echo "Trace output file $trace_file-<pid>"
e00e36fb 5953fi
89138857 5954echo "spice support $spice $(echo_version $spice $spice_protocol_version/$spice_server_version)"
f27aaf4b 5955echo "rbd support $rbd"
dce512de 5956echo "xfsctl support $xfs"
7b02f544 5957echo "smartcard support $smartcard"
2b2325ff 5958echo "libusb $libusb"
69354a83 5959echo "usb net redir $usb_redir"
da076ffe 5960echo "OpenGL support $opengl"
014cb152 5961echo "OpenGL dmabufs $opengl_dmabuf"
c589b249 5962echo "libiscsi support $libiscsi"
6542aa9c 5963echo "libnfs support $libnfs"
d138cee9 5964echo "build guest agent $guest_agent"
d9840e25 5965echo "QGA VSS support $guest_agent_with_vss"
50cbebb9 5966echo "QGA w32 disk info $guest_agent_ntddscsi"
4c875d89 5967echo "QGA MSI support $guest_agent_msi"
f794573e 5968echo "seccomp support $seccomp"
7c2acc70 5969echo "coroutine backend $coroutine"
70c60c08 5970echo "coroutine pool $coroutine_pool"
7d992e4d 5971echo "debug stack usage $debug_stack_usage"
ba59fb77 5972echo "mutex debugging $debug_mutex"
f0d92b56 5973echo "crypto afalg $crypto_afalg"
eb100396 5974echo "GlusterFS support $glusterfs"
1d728c39
BS
5975echo "gcov $gcov_tool"
5976echo "gcov enabled $gcov"
ab214c29 5977echo "TPM support $tpm"
0a12ec87 5978echo "libssh2 support $libssh2"
3b8acc11 5979echo "TPM passthrough $tpm_passthrough"
f4ede81e 5980echo "TPM emulator $tpm_emulator"
3556c233 5981echo "QOM debugging $qom_cast_debug"
ed1701c6 5982echo "Live block migration $live_block_migration"
607dacd0
QN
5983echo "lzo support $lzo"
5984echo "snappy support $snappy"
6b383c08 5985echo "bzip2 support $bzip2"
a99d57bb 5986echo "NUMA host support $numa"
ed279a06 5987echo "libxml2 $libxml2"
2847b469 5988echo "tcmalloc support $tcmalloc"
7b01cb97 5989echo "jemalloc support $jemalloc"
99f2dbd3 5990echo "avx2 optimization $avx2_opt"
a6b1d4c0 5991echo "replication support $replication"
da92c3ff 5992echo "VxHS block device $vxhs"
8ca80760 5993echo "capstone $capstone"
51a12b51 5994echo "docker $docker"
67b915a5 5995
1ba16968 5996if test "$sdl_too_old" = "yes"; then
24b55b96 5997echo "-> Your SDL version is too old - please upgrade to have SDL support"
7c1f25b4 5998fi
7d13299d 5999
b7715af2
DB
6000if test "$gtkabi" = "2.0"; then
6001 echo
6002 echo "WARNING: Use of GTK 2.0 is deprecated and will be removed in"
6003 echo "WARNING: future releases. Please switch to using GTK 3.0"
6004fi
6005
e52c6ba3
DB
6006if test "$sdlabi" = "1.2"; then
6007 echo
6008 echo "WARNING: Use of SDL 1.2 is deprecated and will be removed in"
6009 echo "WARNING: future releases. Please switch to using SDL 2.0"
6010fi
6011
898be3e0
PM
6012if test "$supported_cpu" = "no"; then
6013 echo
6014 echo "WARNING: SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!"
6015 echo
6016 echo "CPU host architecture $cpu support is not currently maintained."
6017 echo "The QEMU project intends to remove support for this host CPU in"
6018 echo "a future release if nobody volunteers to maintain it and to"
6019 echo "provide a build host for our continuous integration setup."
6020 echo "configure has succeeded and you can continue to build, but"
6021 echo "if you care about QEMU on this platform you should contact"
6022 echo "us upstream at [email protected]."
6023fi
6024
6025if test "$supported_os" = "no"; then
6026 echo
6027 echo "WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!"
6028 echo
c50126aa
PM
6029 echo "Host OS $targetos support is not currently maintained."
6030 echo "The QEMU project intends to remove support for this host OS in"
898be3e0
PM
6031 echo "a future release if nobody volunteers to maintain it and to"
6032 echo "provide a build host for our continuous integration setup."
6033 echo "configure has succeeded and you can continue to build, but"
6034 echo "if you care about QEMU on this platform you should contact"
6035 echo "us upstream at [email protected]."
6036fi
6037
98ec69ac 6038config_host_mak="config-host.mak"
98ec69ac 6039
dbd99ae3
SW
6040echo "# Automatically generated by configure - do not modify" >config-all-disas.mak
6041
98ec69ac 6042echo "# Automatically generated by configure - do not modify" > $config_host_mak
98ec69ac 6043echo >> $config_host_mak
98ec69ac 6044
e6c3b0f7 6045echo all: >> $config_host_mak
99d7cc75
PB
6046echo "prefix=$prefix" >> $config_host_mak
6047echo "bindir=$bindir" >> $config_host_mak
3aa5d2be 6048echo "libdir=$libdir" >> $config_host_mak
8bf188aa 6049echo "libexecdir=$libexecdir" >> $config_host_mak
0f94d6da 6050echo "includedir=$includedir" >> $config_host_mak
99d7cc75 6051echo "mandir=$mandir" >> $config_host_mak
99d7cc75 6052echo "sysconfdir=$sysconfdir" >> $config_host_mak
22d07038 6053echo "qemu_confdir=$qemu_confdir" >> $config_host_mak
9afa52ce 6054echo "qemu_datadir=$qemu_datadir" >> $config_host_mak
3d5eecab 6055echo "qemu_firmwarepath=$firmwarepath" >> $config_host_mak
9afa52ce 6056echo "qemu_docdir=$qemu_docdir" >> $config_host_mak
e26110cf 6057echo "qemu_moddir=$qemu_moddir" >> $config_host_mak
5a699bbb
LE
6058if test "$mingw32" = "no" ; then
6059 echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
6060fi
f354b1a1 6061echo "qemu_helperdir=$libexecdir" >> $config_host_mak
834574ea 6062echo "qemu_localedir=$qemu_localedir" >> $config_host_mak
f544a488 6063echo "libs_softmmu=$libs_softmmu" >> $config_host_mak
cc84d63a 6064echo "GIT=$git" >> $config_host_mak
aef45d51 6065echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
f62bbee5 6066echo "GIT_UPDATE=$git_update" >> $config_host_mak
804edf29 6067
98ec69ac 6068echo "ARCH=$ARCH" >> $config_host_mak
727e5283 6069
f8393946 6070if test "$debug_tcg" = "yes" ; then
2358a494 6071 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
f8393946 6072fi
1625af87 6073if test "$strip_opt" = "yes" ; then
52ba784d 6074 echo "STRIP=${strip}" >> $config_host_mak
1625af87 6075fi
7d13299d 6076if test "$bigendian" = "yes" ; then
e2542fe2 6077 echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
97a847bc 6078fi
67b915a5 6079if test "$mingw32" = "yes" ; then
98ec69ac 6080 echo "CONFIG_WIN32=y" >> $config_host_mak
89138857 6081 rc_version=$(cat $source_path/VERSION)
9fe6de94
BS
6082 version_major=${rc_version%%.*}
6083 rc_version=${rc_version#*.}
6084 version_minor=${rc_version%%.*}
6085 rc_version=${rc_version#*.}
6086 version_subminor=${rc_version%%.*}
6087 version_micro=0
6088 echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
6089 echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
d9840e25
TS
6090 if test "$guest_agent_with_vss" = "yes" ; then
6091 echo "CONFIG_QGA_VSS=y" >> $config_host_mak
f33ca81f 6092 echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
d9840e25
TS
6093 echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
6094 fi
50cbebb9
MR
6095 if test "$guest_agent_ntddscsi" = "yes" ; then
6096 echo "CONFIG_QGA_NTDDDISK=y" >> $config_host_mak
6097 fi
1a34904e 6098 if test "$guest_agent_msi" = "yes"; then
d661d9a4 6099 echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
9dacf32d
YH
6100 echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
6101 echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
6102 echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
6103 echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
6104 echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
6105 echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
6106 fi
210fa556 6107else
35f4df27 6108 echo "CONFIG_POSIX=y" >> $config_host_mak
dffcb71c
MM
6109fi
6110
6111if test "$linux" = "yes" ; then
6112 echo "CONFIG_LINUX=y" >> $config_host_mak
67b915a5 6113fi
128ab2ff 6114
83fb7adf 6115if test "$darwin" = "yes" ; then
98ec69ac 6116 echo "CONFIG_DARWIN=y" >> $config_host_mak
83fb7adf 6117fi
b29fe3ed 6118
ec530c81 6119if test "$solaris" = "yes" ; then
98ec69ac 6120 echo "CONFIG_SOLARIS=y" >> $config_host_mak
ec530c81 6121fi
179cf400
AF
6122if test "$haiku" = "yes" ; then
6123 echo "CONFIG_HAIKU=y" >> $config_host_mak
6124fi
97a847bc 6125if test "$static" = "yes" ; then
98ec69ac 6126 echo "CONFIG_STATIC=y" >> $config_host_mak
7d13299d 6127fi
1ba16968 6128if test "$profiler" = "yes" ; then
2358a494 6129 echo "CONFIG_PROFILER=y" >> $config_host_mak
05c2a3e7 6130fi
c20709aa 6131if test "$slirp" = "yes" ; then
98ec69ac 6132 echo "CONFIG_SLIRP=y" >> $config_host_mak
e2d8830e 6133 echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
c20709aa 6134fi
8a16d273 6135if test "$vde" = "yes" ; then
98ec69ac 6136 echo "CONFIG_VDE=y" >> $config_host_mak
e2ad6f16 6137 echo "VDE_LIBS=$vde_libs" >> $config_host_mak
8a16d273 6138fi
58952137
VM
6139if test "$netmap" = "yes" ; then
6140 echo "CONFIG_NETMAP=y" >> $config_host_mak
6141fi
015a33bd
GA
6142if test "$l2tpv3" = "yes" ; then
6143 echo "CONFIG_L2TPV3=y" >> $config_host_mak
6144fi
47e98658
CB
6145if test "$cap_ng" = "yes" ; then
6146 echo "CONFIG_LIBCAP=y" >> $config_host_mak
6147fi
2358a494 6148echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
0c58ac1c 6149for drv in $audio_drv_list; do
1ef1ec2a 6150 def=CONFIG_AUDIO_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
ce3dc033 6151 case "$drv" in
051c7d5c 6152 alsa | oss | pa | sdl)
ce3dc033
GH
6153 echo "$def=m" >> $config_host_mak ;;
6154 *)
6155 echo "$def=y" >> $config_host_mak ;;
6156 esac
0c58ac1c 6157done
b1149911
FZ
6158echo "ALSA_LIBS=$alsa_libs" >> $config_host_mak
6159echo "PULSE_LIBS=$pulse_libs" >> $config_host_mak
6160echo "COREAUDIO_LIBS=$coreaudio_libs" >> $config_host_mak
6161echo "DSOUND_LIBS=$dsound_libs" >> $config_host_mak
6162echo "OSS_LIBS=$oss_libs" >> $config_host_mak
67f86e8e
JQ
6163if test "$audio_pt_int" = "yes" ; then
6164 echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
6165fi
d5631638 6166if test "$audio_win_int" = "yes" ; then
6167 echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
6168fi
b64ec4e4
FZ
6169echo "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
6170echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
821601ea
JS
6171if test "$vnc" = "yes" ; then
6172 echo "CONFIG_VNC=y" >> $config_host_mak
6173fi
2f9606b3 6174if test "$vnc_sasl" = "yes" ; then
98ec69ac 6175 echo "CONFIG_VNC_SASL=y" >> $config_host_mak
2f9606b3 6176fi
821601ea 6177if test "$vnc_jpeg" = "yes" ; then
2f6f5c7a 6178 echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
2f6f5c7a 6179fi
821601ea 6180if test "$vnc_png" = "yes" ; then
efe556ad 6181 echo "CONFIG_VNC_PNG=y" >> $config_host_mak
efe556ad 6182fi
6a021536
GH
6183if test "$xkbcommon" = "yes" ; then
6184 echo "XKBCOMMON_CFLAGS=$xkbcommon_cflags" >> $config_host_mak
6185 echo "XKBCOMMON_LIBS=$xkbcommon_libs" >> $config_host_mak
6186fi
76655d6d 6187if test "$fnmatch" = "yes" ; then
2358a494 6188 echo "CONFIG_FNMATCH=y" >> $config_host_mak
76655d6d 6189fi
dce512de
CH
6190if test "$xfs" = "yes" ; then
6191 echo "CONFIG_XFS=y" >> $config_host_mak
6192fi
89138857 6193qemu_version=$(head $source_path/VERSION)
98ec69ac 6194echo "VERSION=$qemu_version" >>$config_host_mak
2358a494 6195echo "PKGVERSION=$pkgversion" >>$config_host_mak
98ec69ac 6196echo "SRC_PATH=$source_path" >> $config_host_mak
208ecb3e 6197echo "TARGET_LIST=$target_list" >> $config_host_mak
a25dba17 6198if [ "$docs" = "yes" ] ; then
98ec69ac 6199 echo "BUILD_DOCS=yes" >> $config_host_mak
cc8ae6de 6200fi
17969268 6201if test "$modules" = "yes"; then
e26110cf
FZ
6202 # $shacmd can generate a hash started with digit, which the compiler doesn't
6203 # like as an symbol. So prefix it with an underscore
89138857 6204 echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
17969268
FZ
6205 echo "CONFIG_MODULES=y" >> $config_host_mak
6206fi
8781595b
GH
6207if test "$have_x11" = "yes" -a "$need_x11" = "yes"; then
6208 echo "CONFIG_X11=y" >> $config_host_mak
6209 echo "X11_CFLAGS=$x11_cflags" >> $config_host_mak
6210 echo "X11_LIBS=$x11_libs" >> $config_host_mak
6211fi
1ac88f28 6212if test "$sdl" = "yes" ; then
96400a14 6213 echo "CONFIG_SDL=m" >> $config_host_mak
a3f4d63d 6214 echo "CONFIG_SDLABI=$sdlabi" >> $config_host_mak
1ac88f28 6215 echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
8ecc89f6 6216 echo "SDL_LIBS=$sdl_libs" >> $config_host_mak
49ecc3fa
FB
6217fi
6218if test "$cocoa" = "yes" ; then
98ec69ac 6219 echo "CONFIG_COCOA=y" >> $config_host_mak
4d3b6f6e
AZ
6220fi
6221if test "$curses" = "yes" ; then
2373f7d5
GH
6222 echo "CONFIG_CURSES=m" >> $config_host_mak
6223 echo "CURSES_CFLAGS=$curses_inc" >> $config_host_mak
6224 echo "CURSES_LIBS=$curses_lib" >> $config_host_mak
49ecc3fa 6225fi
099d6b0f 6226if test "$pipe2" = "yes" ; then
2358a494 6227 echo "CONFIG_PIPE2=y" >> $config_host_mak
099d6b0f 6228fi
40ff6d7e
KW
6229if test "$accept4" = "yes" ; then
6230 echo "CONFIG_ACCEPT4=y" >> $config_host_mak
6231fi
3ce34dfb 6232if test "$splice" = "yes" ; then
2358a494 6233 echo "CONFIG_SPLICE=y" >> $config_host_mak
3ce34dfb 6234fi
c2882b96
RV
6235if test "$eventfd" = "yes" ; then
6236 echo "CONFIG_EVENTFD=y" >> $config_host_mak
6237fi
751bcc39
MAL
6238if test "$memfd" = "yes" ; then
6239 echo "CONFIG_MEMFD=y" >> $config_host_mak
6240fi
d0927938
UH
6241if test "$fallocate" = "yes" ; then
6242 echo "CONFIG_FALLOCATE=y" >> $config_host_mak
6243fi
3d4fa43e
KK
6244if test "$fallocate_punch_hole" = "yes" ; then
6245 echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
6246fi
b953f075
DL
6247if test "$fallocate_zero_range" = "yes" ; then
6248 echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
6249fi
ed911435
KW
6250if test "$posix_fallocate" = "yes" ; then
6251 echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
6252fi
c727f47d
PM
6253if test "$sync_file_range" = "yes" ; then
6254 echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
6255fi
dace20dc
PM
6256if test "$fiemap" = "yes" ; then
6257 echo "CONFIG_FIEMAP=y" >> $config_host_mak
6258fi
d0927938
UH
6259if test "$dup3" = "yes" ; then
6260 echo "CONFIG_DUP3=y" >> $config_host_mak
6261fi
4e0c6529
AB
6262if test "$ppoll" = "yes" ; then
6263 echo "CONFIG_PPOLL=y" >> $config_host_mak
6264fi
cd758dd0
AB
6265if test "$prctl_pr_set_timerslack" = "yes" ; then
6266 echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
6267fi
3b6edd16
PM
6268if test "$epoll" = "yes" ; then
6269 echo "CONFIG_EPOLL=y" >> $config_host_mak
6270fi
6271if test "$epoll_create1" = "yes" ; then
6272 echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
6273fi
a8fd1aba
PM
6274if test "$sendfile" = "yes" ; then
6275 echo "CONFIG_SENDFILE=y" >> $config_host_mak
6276fi
51834341
RV
6277if test "$timerfd" = "yes" ; then
6278 echo "CONFIG_TIMERFD=y" >> $config_host_mak
6279fi
9af5c906
RV
6280if test "$setns" = "yes" ; then
6281 echo "CONFIG_SETNS=y" >> $config_host_mak
6282fi
38860a03
AM
6283if test "$clock_adjtime" = "yes" ; then
6284 echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
6285fi
5a03cd00
AM
6286if test "$syncfs" = "yes" ; then
6287 echo "CONFIG_SYNCFS=y" >> $config_host_mak
6288fi
3b3f24ad 6289if test "$inotify" = "yes" ; then
2358a494 6290 echo "CONFIG_INOTIFY=y" >> $config_host_mak
3b3f24ad 6291fi
c05c7a73
RV
6292if test "$inotify1" = "yes" ; then
6293 echo "CONFIG_INOTIFY1=y" >> $config_host_mak
6294fi
401bc051
PM
6295if test "$sem_timedwait" = "yes" ; then
6296 echo "CONFIG_SEM_TIMEDWAIT=y" >> $config_host_mak
6297fi
5c99fa37
KF
6298if test "$strchrnul" = "yes" ; then
6299 echo "HAVE_STRCHRNUL=y" >> $config_host_mak
6300fi
6ae9a1f4
JQ
6301if test "$byteswap_h" = "yes" ; then
6302 echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
6303fi
6304if test "$bswap_h" = "yes" ; then
6305 echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
6306fi
769ce76d 6307if test "$curl" = "yes" ; then
d3399d7c 6308 echo "CONFIG_CURL=m" >> $config_host_mak
b1d5a277 6309 echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
6ebc91e5 6310 echo "CURL_LIBS=$curl_libs" >> $config_host_mak
769ce76d 6311fi
2e4d9fb1 6312if test "$brlapi" = "yes" ; then
98ec69ac 6313 echo "CONFIG_BRLAPI=y" >> $config_host_mak
8eca2889 6314 echo "BRLAPI_LIBS=$brlapi_libs" >> $config_host_mak
2e4d9fb1 6315fi
fb599c9a 6316if test "$bluez" = "yes" ; then
98ec69ac 6317 echo "CONFIG_BLUEZ=y" >> $config_host_mak
ef7635ec 6318 echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
fb599c9a 6319fi
d46f7c9e 6320if test "$glib_subprocess" = "yes" ; then
9d41401b
MT
6321 echo "CONFIG_HAS_GLIB_SUBPROCESS_TESTS=y" >> $config_host_mak
6322fi
a4ccabcf 6323if test "$gtk" = "yes" ; then
e0fb129c 6324 echo "CONFIG_GTK=m" >> $config_host_mak
a3f4d63d 6325 echo "CONFIG_GTKABI=$gtkabi" >> $config_host_mak
a4ccabcf 6326 echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
014cb152 6327 echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
925a0400
GH
6328 if test "$gtk_gl" = "yes" ; then
6329 echo "CONFIG_GTK_GL=y" >> $config_host_mak
6330 fi
bbbf9bfb 6331fi
a1c5e949 6332echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
ddbb0d09
DB
6333if test "$gnutls" = "yes" ; then
6334 echo "CONFIG_GNUTLS=y" >> $config_host_mak
6335fi
b917da4c
DB
6336if test "$gnutls_rnd" = "yes" ; then
6337 echo "CONFIG_GNUTLS_RND=y" >> $config_host_mak
6338fi
91bfcdb0
DB
6339if test "$gcrypt" = "yes" ; then
6340 echo "CONFIG_GCRYPT=y" >> $config_host_mak
1f923c70
LM
6341 if test "$gcrypt_hmac" = "yes" ; then
6342 echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
6343 fi
37788f25
DB
6344 if test "$gcrypt_kdf" = "yes" ; then
6345 echo "CONFIG_GCRYPT_KDF=y" >> $config_host_mak
6346 fi
62893b67 6347fi
91bfcdb0
DB
6348if test "$nettle" = "yes" ; then
6349 echo "CONFIG_NETTLE=y" >> $config_host_mak
becaeb72 6350 echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
fff2f982
DB
6351 if test "$nettle_kdf" = "yes" ; then
6352 echo "CONFIG_NETTLE_KDF=y" >> $config_host_mak
6353 fi
ed754746 6354fi
9a2fd434
DB
6355if test "$tasn1" = "yes" ; then
6356 echo "CONFIG_TASN1=y" >> $config_host_mak
6357fi
559607ea
DB
6358if test "$have_ifaddrs_h" = "yes" ; then
6359 echo "HAVE_IFADDRS_H=y" >> $config_host_mak
6360fi
6b39b063
EB
6361if test "$have_broken_size_max" = "yes" ; then
6362 echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
6363fi
277abf15
JV
6364
6365# Work around a system header bug with some kernel/XFS header
6366# versions where they both try to define 'struct fsxattr':
6367# xfs headers will not try to redefine structs from linux headers
6368# if this macro is set.
6369if test "$have_fsxattr" = "yes" ; then
6370 echo "HAVE_FSXATTR=y" >> $config_host_mak
6371fi
1efad060
FZ
6372if test "$have_copy_file_range" = "yes" ; then
6373 echo "HAVE_COPY_FILE_RANGE=y" >> $config_host_mak
6374fi
bbbf9bfb
SW
6375if test "$vte" = "yes" ; then
6376 echo "CONFIG_VTE=y" >> $config_host_mak
a4ccabcf 6377 echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
e0fb129c 6378 echo "VTE_LIBS=$vte_libs" >> $config_host_mak
a4ccabcf 6379fi
9d9e1521
GH
6380if test "$virglrenderer" = "yes" ; then
6381 echo "CONFIG_VIRGL=y" >> $config_host_mak
6382 echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
6383 echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
6384fi
e37630ca 6385if test "$xen" = "yes" ; then
6dbd588a 6386 echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
d5b93ddf 6387 echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
64a7ad6f
IC
6388 if test "$xen_pv_domain_build" = "yes" ; then
6389 echo "CONFIG_XEN_PV_DOMAIN_BUILD=y" >> $config_host_mak
6390 fi
e37630ca 6391fi
5c6c3a6c
CH
6392if test "$linux_aio" = "yes" ; then
6393 echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
6394fi
758e8e38
VJ
6395if test "$attr" = "yes" ; then
6396 echo "CONFIG_ATTR=y" >> $config_host_mak
6397fi
4f26f2b6
AK
6398if test "$libattr" = "yes" ; then
6399 echo "CONFIG_LIBATTR=y" >> $config_host_mak
6400fi
983eef5a
MI
6401if test "$virtfs" = "yes" ; then
6402 echo "CONFIG_VIRTFS=y" >> $config_host_mak
758e8e38 6403fi
fe8fc5ae
PB
6404if test "$mpath" = "yes" ; then
6405 echo "CONFIG_MPATH=y" >> $config_host_mak
6406fi
5e9be92d
NB
6407if test "$vhost_scsi" = "yes" ; then
6408 echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
6409fi
e6a74868 6410if test "$vhost_net" = "yes" -a "$vhost_user" = "yes"; then
03ce5744
NN
6411 echo "CONFIG_VHOST_NET_USED=y" >> $config_host_mak
6412fi
042cea27
GA
6413if test "$vhost_crypto" = "yes" ; then
6414 echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
6415fi
fc0b9b0e
SH
6416if test "$vhost_vsock" = "yes" ; then
6417 echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
6418fi
e6a74868
MAL
6419if test "$vhost_user" = "yes" ; then
6420 echo "CONFIG_VHOST_USER=y" >> $config_host_mak
6421fi
77755340 6422if test "$blobs" = "yes" ; then
98ec69ac 6423 echo "INSTALL_BLOBS=yes" >> $config_host_mak
77755340 6424fi
bf9298b9 6425if test "$iovec" = "yes" ; then
2358a494 6426 echo "CONFIG_IOVEC=y" >> $config_host_mak
bf9298b9 6427fi
ceb42de8 6428if test "$preadv" = "yes" ; then
2358a494 6429 echo "CONFIG_PREADV=y" >> $config_host_mak
ceb42de8 6430fi
e3971d61 6431if test "$fdt" != "no" ; then
3f0855b1 6432 echo "CONFIG_FDT=y" >> $config_host_mak
f652e6af 6433fi
a40161cb
PB
6434if test "$membarrier" = "yes" ; then
6435 echo "CONFIG_MEMBARRIER=y" >> $config_host_mak
6436fi
dcc38d1c
MT
6437if test "$signalfd" = "yes" ; then
6438 echo "CONFIG_SIGNALFD=y" >> $config_host_mak
6439fi
b3f6ea7e
PB
6440if test "$tcg" = "yes"; then
6441 echo "CONFIG_TCG=y" >> $config_host_mak
6442 if test "$tcg_interpreter" = "yes" ; then
6443 echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
6444 fi
9195b2c2 6445fi
5f6b9e8f
BS
6446if test "$fdatasync" = "yes" ; then
6447 echo "CONFIG_FDATASYNC=y" >> $config_host_mak
6448fi
e78815a5
AF
6449if test "$madvise" = "yes" ; then
6450 echo "CONFIG_MADVISE=y" >> $config_host_mak
6451fi
6452if test "$posix_madvise" = "yes" ; then
6453 echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
6454fi
9bc5a719
AG
6455if test "$posix_memalign" = "yes" ; then
6456 echo "CONFIG_POSIX_MEMALIGN=y" >> $config_host_mak
6457fi
97a847bc 6458
cd4ec0b4
GH
6459if test "$spice" = "yes" ; then
6460 echo "CONFIG_SPICE=y" >> $config_host_mak
6461fi
36707144 6462
7b02f544
MAL
6463if test "$smartcard" = "yes" ; then
6464 echo "CONFIG_SMARTCARD=y" >> $config_host_mak
7b62bf5a
FZ
6465 echo "SMARTCARD_CFLAGS=$libcacard_cflags" >> $config_host_mak
6466 echo "SMARTCARD_LIBS=$libcacard_libs" >> $config_host_mak
111a38b0
RR
6467fi
6468
2b2325ff
GH
6469if test "$libusb" = "yes" ; then
6470 echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
b878b652
FZ
6471 echo "LIBUSB_CFLAGS=$libusb_cflags" >> $config_host_mak
6472 echo "LIBUSB_LIBS=$libusb_libs" >> $config_host_mak
2b2325ff
GH
6473fi
6474
69354a83
HG
6475if test "$usb_redir" = "yes" ; then
6476 echo "CONFIG_USB_REDIR=y" >> $config_host_mak
cc7923fc
FZ
6477 echo "USB_REDIR_CFLAGS=$usb_redir_cflags" >> $config_host_mak
6478 echo "USB_REDIR_LIBS=$usb_redir_libs" >> $config_host_mak
69354a83
HG
6479fi
6480
da076ffe
GH
6481if test "$opengl" = "yes" ; then
6482 echo "CONFIG_OPENGL=y" >> $config_host_mak
6483 echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
014cb152
GH
6484 if test "$opengl_dmabuf" = "yes" ; then
6485 echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
6486 fi
20ff075b
MW
6487fi
6488
5a22ab71
YZ
6489if test "$malloc_trim" = "yes" ; then
6490 echo "CONFIG_MALLOC_TRIM=y" >> $config_host_mak
6491fi
6492
99f2dbd3
LL
6493if test "$avx2_opt" = "yes" ; then
6494 echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
6495fi
6496
607dacd0
QN
6497if test "$lzo" = "yes" ; then
6498 echo "CONFIG_LZO=y" >> $config_host_mak
6499fi
6500
6501if test "$snappy" = "yes" ; then
6502 echo "CONFIG_SNAPPY=y" >> $config_host_mak
6503fi
6504
6b383c08
PW
6505if test "$bzip2" = "yes" ; then
6506 echo "CONFIG_BZIP2=y" >> $config_host_mak
6507 echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
6508fi
6509
c589b249 6510if test "$libiscsi" = "yes" ; then
d3399d7c 6511 echo "CONFIG_LIBISCSI=m" >> $config_host_mak
6ebc91e5
FZ
6512 echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
6513 echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
c589b249
RS
6514fi
6515
6542aa9c 6516if test "$libnfs" = "yes" ; then
4be4879f
CL
6517 echo "CONFIG_LIBNFS=m" >> $config_host_mak
6518 echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
6542aa9c
PL
6519fi
6520
f794573e
EO
6521if test "$seccomp" = "yes"; then
6522 echo "CONFIG_SECCOMP=y" >> $config_host_mak
c3883e1f
FZ
6523 echo "SECCOMP_CFLAGS=$seccomp_cflags" >> $config_host_mak
6524 echo "SECCOMP_LIBS=$seccomp_libs" >> $config_host_mak
f794573e
EO
6525fi
6526
83fb7adf 6527# XXX: suppress that
7d3505c5 6528if [ "$bsd" = "yes" ] ; then
2358a494 6529 echo "CONFIG_BSD=y" >> $config_host_mak
7d3505c5
FB
6530fi
6531
4d9310f4
DB
6532if test "$localtime_r" = "yes" ; then
6533 echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
6534fi
3556c233
PB
6535if test "$qom_cast_debug" = "yes" ; then
6536 echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
6537fi
f27aaf4b 6538if test "$rbd" = "yes" ; then
d3399d7c 6539 echo "CONFIG_RBD=m" >> $config_host_mak
6ebc91e5
FZ
6540 echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
6541 echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
d0e2fce5
AK
6542fi
6543
7c2acc70 6544echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
70c60c08
SH
6545if test "$coroutine_pool" = "yes" ; then
6546 echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
6547else
6548 echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
6549fi
20ff6c80 6550
7d992e4d
PL
6551if test "$debug_stack_usage" = "yes" ; then
6552 echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
6553fi
6554
f0d92b56
LM
6555if test "$crypto_afalg" = "yes" ; then
6556 echo "CONFIG_AF_ALG=y" >> $config_host_mak
6557fi
6558
d2042378
AK
6559if test "$open_by_handle_at" = "yes" ; then
6560 echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
6561fi
6562
e06a765e
HPB
6563if test "$linux_magic_h" = "yes" ; then
6564 echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
8ab1bf12
LC
6565fi
6566
cc6e3ca9
GH
6567if test "$pragma_diagnostic_available" = "yes" ; then
6568 echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
06d71fa1
PM
6569fi
6570
3f4349dc
KW
6571if test "$valgrind_h" = "yes" ; then
6572 echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
6573fi
6574
d83414e1
MAL
6575if test "$have_asan_iface_fiber" = "yes" ; then
6576 echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
6577fi
6578
8ab1bf12
LC
6579if test "$has_environ" = "yes" ; then
6580 echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
e06a765e
HPB
6581fi
6582
76a347e1
RH
6583if test "$cpuid_h" = "yes" ; then
6584 echo "CONFIG_CPUID_H=y" >> $config_host_mak
6585fi
6586
f540166b
RH
6587if test "$int128" = "yes" ; then
6588 echo "CONFIG_INT128=y" >> $config_host_mak
6589fi
6590
7ebee43e
RH
6591if test "$atomic128" = "yes" ; then
6592 echo "CONFIG_ATOMIC128=y" >> $config_host_mak
6593fi
6594
df79b996
RH
6595if test "$atomic64" = "yes" ; then
6596 echo "CONFIG_ATOMIC64=y" >> $config_host_mak
6597fi
6598
db432672
RH
6599if test "$vector16" = "yes" ; then
6600 echo "CONFIG_VECTOR16=y" >> $config_host_mak
6601fi
6602
1e6e9aca
RH
6603if test "$getauxval" = "yes" ; then
6604 echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
6605fi
6606
eb100396 6607if test "$glusterfs" = "yes" ; then
d3399d7c 6608 echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
6ebc91e5
FZ
6609 echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
6610 echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
0c14fb47
BR
6611fi
6612
d85fa9eb
JC
6613if test "$glusterfs_xlator_opt" = "yes" ; then
6614 echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
6615fi
6616
0c14fb47
BR
6617if test "$glusterfs_discard" = "yes" ; then
6618 echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
eb100396 6619fi
e06a765e 6620
df3a429a
NV
6621if test "$glusterfs_fallocate" = "yes" ; then
6622 echo "CONFIG_GLUSTERFS_FALLOCATE=y" >> $config_host_mak
6623fi
6624
7c815372
BR
6625if test "$glusterfs_zerofill" = "yes" ; then
6626 echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
6627fi
6628
0a12ec87 6629if test "$libssh2" = "yes" ; then
d3399d7c 6630 echo "CONFIG_LIBSSH2=m" >> $config_host_mak
6ebc91e5
FZ
6631 echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
6632 echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak
0a12ec87
RJ
6633fi
6634
ed1701c6
DDAG
6635if test "$live_block_migration" = "yes" ; then
6636 echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
6637fi
6638
3b8acc11
PB
6639if test "$tpm" = "yes"; then
6640 echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak
f4ede81e 6641 # TPM passthrough support?
3b8acc11
PB
6642 if test "$tpm_passthrough" = "yes"; then
6643 echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
6644 fi
f4ede81e
AV
6645 # TPM emulator support?
6646 if test "$tpm_emulator" = "yes"; then
6647 echo "CONFIG_TPM_EMULATOR=y" >> $config_host_mak
6648 fi
3b8acc11
PB
6649fi
6650
5b808275
LV
6651echo "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
6652if have_backend "nop"; then
6d8a764e 6653 echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
22890ab5 6654fi
5b808275 6655if have_backend "simple"; then
6d8a764e
LV
6656 echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
6657 # Set the appropriate trace file.
953ffe0f 6658 trace_file="\"$trace_file-\" FMT_pid"
9410b56c 6659fi
ed7f5f1d
PB
6660if have_backend "log"; then
6661 echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
6d8a764e 6662fi
5b808275 6663if have_backend "ust"; then
6d8a764e
LV
6664 echo "CONFIG_TRACE_UST=y" >> $config_host_mak
6665fi
5b808275 6666if have_backend "dtrace"; then
6d8a764e
LV
6667 echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
6668 if test "$trace_backend_stap" = "yes" ; then
6669 echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
6670 fi
c276b17d 6671fi
5b808275 6672if have_backend "ftrace"; then
781e9545
ET
6673 if test "$linux" = "yes" ; then
6674 echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
781e9545 6675 else
21684af0 6676 feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
781e9545
ET
6677 fi
6678fi
0a852417
PD
6679if have_backend "syslog"; then
6680 if test "$posix_syslog" = "yes" ; then
6681 echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
6682 else
6683 feature_not_found "syslog(trace backend)" "syslog not available"
6684 fi
6685fi
9410b56c
PS
6686echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
6687
2da776db
MH
6688if test "$rdma" = "yes" ; then
6689 echo "CONFIG_RDMA=y" >> $config_host_mak
392fb643 6690 echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
2da776db
MH
6691fi
6692
575b22b1
LV
6693if test "$have_rtnetlink" = "yes" ; then
6694 echo "CONFIG_RTNETLINK=y" >> $config_host_mak
6695fi
6696
ed279a06
KK
6697if test "$libxml2" = "yes" ; then
6698 echo "CONFIG_LIBXML2=y" >> $config_host_mak
6699 echo "LIBXML2_CFLAGS=$libxml2_cflags" >> $config_host_mak
6700 echo "LIBXML2_LIBS=$libxml2_libs" >> $config_host_mak
6701fi
6702
a6b1d4c0
CX
6703if test "$replication" = "yes" ; then
6704 echo "CONFIG_REPLICATION=y" >> $config_host_mak
6705fi
6706
6a02c806
SH
6707if test "$have_af_vsock" = "yes" ; then
6708 echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
6709fi
6710
4d04351f
CC
6711if test "$have_sysmacros" = "yes" ; then
6712 echo "CONFIG_SYSMACROS=y" >> $config_host_mak
6713fi
6714
49e00a18
AG
6715if test "$have_static_assert" = "yes" ; then
6716 echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
6717fi
6718
e674605f
TG
6719if test "$have_utmpx" = "yes" ; then
6720 echo "HAVE_UTMPX=y" >> $config_host_mak
6721fi
6722
e0580342
KR
6723if test "$ivshmem" = "yes" ; then
6724 echo "CONFIG_IVSHMEM=y" >> $config_host_mak
8ca80760 6725fi
e219c499 6726if test "$capstone" != "no" ; then
8ca80760 6727 echo "CONFIG_CAPSTONE=y" >> $config_host_mak
e0580342 6728fi
ba59fb77
PB
6729if test "$debug_mutex" = "yes" ; then
6730 echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak
6731fi
e0580342 6732
5c312079
DDAG
6733# Hold two types of flag:
6734# CONFIG_THREAD_SETNAME_BYTHREAD - we've got a way of setting the name on
6735# a thread we have a handle to
6736# CONFIG_PTHREAD_SETNAME_NP - A way of doing it on a particular
6737# platform
6738if test "$pthread_setname_np" = "yes" ; then
6739 echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
6740 echo "CONFIG_PTHREAD_SETNAME_NP=y" >> $config_host_mak
6741fi
6742
da92c3ff
AM
6743if test "$vxhs" = "yes" ; then
6744 echo "CONFIG_VXHS=y" >> $config_host_mak
6745 echo "VXHS_LIBS=$vxhs_libs" >> $config_host_mak
6746fi
6747
5b5e3037 6748if test "$tcg_interpreter" = "yes"; then
9edc19c9 6749 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
5b5e3037 6750elif test "$ARCH" = "sparc64" ; then
9edc19c9 6751 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
5b5e3037 6752elif test "$ARCH" = "s390x" ; then
9edc19c9 6753 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
c72b26ec 6754elif test "$ARCH" = "x86_64" -o "$ARCH" = "x32" ; then
9edc19c9 6755 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
40d964b5 6756elif test "$ARCH" = "ppc64" ; then
9edc19c9 6757 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/ppc $QEMU_INCLUDES"
5b5e3037 6758else
9edc19c9 6759 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
5b5e3037 6760fi
9edc19c9 6761QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg $QEMU_INCLUDES"
5b5e3037 6762
98ec69ac 6763echo "TOOLS=$tools" >> $config_host_mak
98ec69ac 6764echo "ROMS=$roms" >> $config_host_mak
804edf29
JQ
6765echo "MAKE=$make" >> $config_host_mak
6766echo "INSTALL=$install" >> $config_host_mak
1901cb14
BS
6767echo "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
6768echo "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
e999ee44
MT
6769echo "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
6770echo "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
c886edfb 6771echo "PYTHON=$python" >> $config_host_mak
804edf29 6772echo "CC=$cc" >> $config_host_mak
a31a8642
MT
6773if $iasl -h > /dev/null 2>&1; then
6774 echo "IASL=$iasl" >> $config_host_mak
6775fi
804edf29 6776echo "HOST_CC=$host_cc" >> $config_host_mak
83f73fce 6777echo "CXX=$cxx" >> $config_host_mak
3c4a4d0d 6778echo "OBJCC=$objcc" >> $config_host_mak
804edf29 6779echo "AR=$ar" >> $config_host_mak
45d285ab 6780echo "ARFLAGS=$ARFLAGS" >> $config_host_mak
cdbd727c 6781echo "AS=$as" >> $config_host_mak
5f6f0e27 6782echo "CCAS=$ccas" >> $config_host_mak
3dd46c78 6783echo "CPP=$cpp" >> $config_host_mak
804edf29
JQ
6784echo "OBJCOPY=$objcopy" >> $config_host_mak
6785echo "LD=$ld" >> $config_host_mak
9f81aeb5 6786echo "RANLIB=$ranlib" >> $config_host_mak
4852ee95 6787echo "NM=$nm" >> $config_host_mak
9fe6de94 6788echo "WINDRES=$windres" >> $config_host_mak
e2a2ed06 6789echo "CFLAGS=$CFLAGS" >> $config_host_mak
46eef33b 6790echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
a558ee17 6791echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
11cde1c8 6792echo "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
f9728943 6793echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
e39f0062
PB
6794if test "$sparse" = "yes" ; then
6795 echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_host_mak
80fd48df 6796 echo "CPP := REAL_CC=\"\$(CPP)\" cgcc" >> $config_host_mak
2944d742 6797 echo "CXX := REAL_CC=\"\$(CXX)\" cgcc" >> $config_host_mak
e39f0062
PB
6798 echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_host_mak
6799 echo "QEMU_CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
6800fi
42da6041
GH
6801if test "$cross_prefix" != ""; then
6802 echo "AUTOCONF_HOST := --host=${cross_prefix%-}" >> $config_host_mak
6803else
6804 echo "AUTOCONF_HOST := " >> $config_host_mak
6805fi
e2a2ed06 6806echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
46eef33b 6807echo "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
8a99e9a3 6808echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
6969ec6c 6809echo "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
e57218b6 6810echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
73da375e 6811echo "LIBS+=$LIBS" >> $config_host_mak
3e2e0e6b 6812echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
409437e1 6813echo "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
804edf29 6814echo "EXESUF=$EXESUF" >> $config_host_mak
17969268
FZ
6815echo "DSOSUF=$DSOSUF" >> $config_host_mak
6816echo "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
957f1f99 6817echo "LIBS_QGA+=$libs_qga" >> $config_host_mak
90246037
DB
6818echo "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
6819echo "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
94dd53c5 6820echo "POD2MAN=$POD2MAN" >> $config_host_mak
cbdd1999 6821echo "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
1d728c39
BS
6822if test "$gcov" = "yes" ; then
6823 echo "CONFIG_GCOV=y" >> $config_host_mak
6824 echo "GCOV=$gcov_tool" >> $config_host_mak
6825fi
804edf29 6826
51a12b51
AB
6827if test "$docker" != "no"; then
6828 echo "HAVE_USER_DOCKER=y" >> $config_host_mak
6829fi
6830
6efd7517
PM
6831# use included Linux headers
6832if test "$linux" = "yes" ; then
a307beb6 6833 mkdir -p linux-headers
6efd7517 6834 case "$cpu" in
c72b26ec 6835 i386|x86_64|x32)
08312a63 6836 linux_arch=x86
6efd7517
PM
6837 ;;
6838 ppcemb|ppc|ppc64)
08312a63 6839 linux_arch=powerpc
6efd7517
PM
6840 ;;
6841 s390x)
08312a63
PM
6842 linux_arch=s390
6843 ;;
1f080313
CF
6844 aarch64)
6845 linux_arch=arm64
6846 ;;
222e7d11
SL
6847 mips64)
6848 linux_arch=mips
6849 ;;
08312a63
PM
6850 *)
6851 # For most CPUs the kernel architecture name and QEMU CPU name match.
6852 linux_arch="$cpu"
6efd7517
PM
6853 ;;
6854 esac
08312a63
PM
6855 # For non-KVM architectures we will not have asm headers
6856 if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
6857 symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
6858 fi
6efd7517
PM
6859fi
6860
1d14ffa9 6861for target in $target_list; do
97a847bc 6862target_dir="$target"
25be210f 6863config_target_mak=$target_dir/config-target.mak
89138857 6864target_name=$(echo $target | cut -d '-' -f 1)
97a847bc 6865target_bigendian="no"
1f3d3c8f 6866
c1799a84 6867case "$target_name" in
722dd7be 6868 armeb|aarch64_be|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
ea2d6a39
JQ
6869 target_bigendian=yes
6870 ;;
6871esac
97a847bc 6872target_softmmu="no"
997344f3 6873target_user_only="no"
831b7825 6874target_linux_user="no"
84778508 6875target_bsd_user="no"
9e407a85 6876case "$target" in
c1799a84 6877 ${target_name}-softmmu)
9e407a85
PB
6878 target_softmmu="yes"
6879 ;;
c1799a84 6880 ${target_name}-linux-user)
9e407a85
PB
6881 target_user_only="yes"
6882 target_linux_user="yes"
6883 ;;
c1799a84 6884 ${target_name}-bsd-user)
84778508
BS
6885 target_user_only="yes"
6886 target_bsd_user="yes"
6887 ;;
9e407a85 6888 *)
76ad07a4 6889 error_exit "Target '$target' not recognised"
9e407a85
PB
6890 exit 1
6891 ;;
6892esac
831b7825 6893
d75402b5
AB
6894target_compiler=""
6895target_compiler_static=""
716a507c 6896target_compiler_cflags=""
d75402b5 6897
97a847bc 6898mkdir -p $target_dir
25be210f 6899echo "# Automatically generated by configure - do not modify" > $config_target_mak
de83cd02 6900
e5fe0c52 6901bflt="no"
ca759f9e 6902mttcg="no"
89138857 6903interp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
56aebc89 6904gdb_xml_files=""
7ba1e619 6905
c1799a84 6906TARGET_ARCH="$target_name"
6acff7da 6907TARGET_BASE_ARCH=""
e6e91b9c 6908TARGET_ABI_DIR=""
e73aae67 6909
c1799a84 6910case "$target_name" in
2408a527 6911 i386)
b8158192 6912 gdb_xml_files="i386-32bit.xml i386-32bit-core.xml i386-32bit-sse.xml"
d75402b5 6913 target_compiler=$cross_cc_i386
716a507c 6914 target_compiler_cflags=$cross_cc_ccflags_i386
2408a527
AJ
6915 ;;
6916 x86_64)
6acff7da 6917 TARGET_BASE_ARCH=i386
b8158192 6918 gdb_xml_files="i386-64bit.xml i386-64bit-core.xml i386-64bit-sse.xml"
d75402b5 6919 target_compiler=$cross_cc_x86_64
2408a527
AJ
6920 ;;
6921 alpha)
5ee4f3c2 6922 mttcg="yes"
d75402b5 6923 target_compiler=$cross_cc_alpha
2408a527
AJ
6924 ;;
6925 arm|armeb)
b498c8a0 6926 TARGET_ARCH=arm
2408a527 6927 bflt="yes"
ca759f9e 6928 mttcg="yes"
56aebc89 6929 gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
d75402b5 6930 target_compiler=$cross_cc_arm
d422b2bc 6931 eval "target_compiler_cflags=\$cross_cc_cflags_${target_name}"
2408a527 6932 ;;
722dd7be
MW
6933 aarch64|aarch64_be)
6934 TARGET_ARCH=aarch64
6a49fa95
AG
6935 TARGET_BASE_ARCH=arm
6936 bflt="yes"
ca759f9e 6937 mttcg="yes"
8f95ce2e 6938 gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
d75402b5 6939 target_compiler=$cross_cc_aarch64
d422b2bc 6940 eval "target_compiler_cflags=\$cross_cc_cflags_${target_name}"
6a49fa95 6941 ;;
2408a527 6942 cris)
d75402b5 6943 target_compiler=$cross_cc_cris
2408a527 6944 ;;
61766fe9 6945 hppa)
7b93dab5 6946 mttcg="yes"
d75402b5 6947 target_compiler=$cross_cc_hppa
61766fe9 6948 ;;
613a22c9 6949 lm32)
d75402b5 6950 target_compiler=$cross_cc_lm32
613a22c9 6951 ;;
2408a527 6952 m68k)
2408a527 6953 bflt="yes"
5a4526b2 6954 gdb_xml_files="cf-core.xml cf-fp.xml m68k-fp.xml"
d75402b5 6955 target_compiler=$cross_cc_m68k
2408a527 6956 ;;
877fdc12
EI
6957 microblaze|microblazeel)
6958 TARGET_ARCH=microblaze
72b675ca 6959 bflt="yes"
be73ef64 6960 echo "TARGET_ABI32=y" >> $config_target_mak
d75402b5 6961 target_compiler=$cross_cc_microblaze
72b675ca 6962 ;;
0adcffb1 6963 mips|mipsel)
b498c8a0 6964 TARGET_ARCH=mips
d75402b5 6965 target_compiler=$cross_cc_mips
25be210f 6966 echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
2408a527
AJ
6967 ;;
6968 mipsn32|mipsn32el)
597e2cec 6969 TARGET_ARCH=mips64
6acff7da 6970 TARGET_BASE_ARCH=mips
d75402b5 6971 target_compiler=$cross_cc_mipsn32
25be210f 6972 echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
597e2cec 6973 echo "TARGET_ABI32=y" >> $config_target_mak
2408a527
AJ
6974 ;;
6975 mips64|mips64el)
b498c8a0 6976 TARGET_ARCH=mips64
6acff7da 6977 TARGET_BASE_ARCH=mips
d75402b5 6978 target_compiler=$cross_cc_mips64
25be210f 6979 echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
2408a527 6980 ;;
d15a9c23 6981 moxie)
d75402b5 6982 target_compiler=$cross_cc_moxie
d15a9c23 6983 ;;
e671711c 6984 nios2)
d75402b5 6985 target_compiler=$cross_cc_nios2
e671711c 6986 ;;
4a09d0bb 6987 or1k)
d75402b5 6988 target_compiler=$cross_cc_or1k
e67db06e
JL
6989 TARGET_ARCH=openrisc
6990 TARGET_BASE_ARCH=openrisc
e67db06e 6991 ;;
2408a527 6992 ppc)
c8b3532d 6993 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
d75402b5 6994 target_compiler=$cross_cc_powerpc
2408a527
AJ
6995 ;;
6996 ppcemb)
6acff7da 6997 TARGET_BASE_ARCH=ppc
e6e91b9c 6998 TARGET_ABI_DIR=ppc
c8b3532d 6999 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
d75402b5 7000 target_compiler=$cross_cc_ppcemb
2408a527
AJ
7001 ;;
7002 ppc64)
6acff7da 7003 TARGET_BASE_ARCH=ppc
e6e91b9c 7004 TARGET_ABI_DIR=ppc
f0b0685d 7005 mttcg=yes
1438eff3 7006 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
d75402b5 7007 target_compiler=$cross_cc_ppc64
2408a527 7008 ;;
9c35126c
DK
7009 ppc64le)
7010 TARGET_ARCH=ppc64
7011 TARGET_BASE_ARCH=ppc
7012 TARGET_ABI_DIR=ppc
f0b0685d 7013 mttcg=yes
1438eff3 7014 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
d75402b5 7015 target_compiler=$cross_cc_ppc64le
9c35126c 7016 ;;
2408a527 7017 ppc64abi32)
b498c8a0 7018 TARGET_ARCH=ppc64
6acff7da 7019 TARGET_BASE_ARCH=ppc
e6e91b9c 7020 TARGET_ABI_DIR=ppc
25be210f 7021 echo "TARGET_ABI32=y" >> $config_target_mak
1438eff3 7022 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
d75402b5 7023 target_compiler=$cross_cc_ppc64abi32
2408a527 7024 ;;
25fa194b
MC
7025 riscv32)
7026 TARGET_BASE_ARCH=riscv
7027 TARGET_ABI_DIR=riscv
7028 mttcg=yes
d75402b5 7029 target_compiler=$cross_cc_riscv32
25fa194b
MC
7030 ;;
7031 riscv64)
7032 TARGET_BASE_ARCH=riscv
7033 TARGET_ABI_DIR=riscv
7034 mttcg=yes
d75402b5 7035 target_compiler=$cross_cc_riscv64
25fa194b 7036 ;;
2408a527 7037 sh4|sh4eb)
b498c8a0 7038 TARGET_ARCH=sh4
2408a527 7039 bflt="yes"
d75402b5 7040 target_compiler=$cross_cc_sh4
2408a527
AJ
7041 ;;
7042 sparc)
d75402b5 7043 target_compiler=$cross_cc_sparc
2408a527
AJ
7044 ;;
7045 sparc64)
6acff7da 7046 TARGET_BASE_ARCH=sparc
d75402b5 7047 target_compiler=$cross_cc_sparc64
2408a527
AJ
7048 ;;
7049 sparc32plus)
b498c8a0 7050 TARGET_ARCH=sparc64
6acff7da 7051 TARGET_BASE_ARCH=sparc
e6e91b9c 7052 TARGET_ABI_DIR=sparc
d75402b5 7053 target_compiler=$cross_cc_sparc32plus
25be210f 7054 echo "TARGET_ABI32=y" >> $config_target_mak
2408a527 7055 ;;
24e804ec 7056 s390x)
63685bc4 7057 mttcg=yes
86158a2a 7058 gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml s390-cr.xml s390-virt.xml s390-gs.xml"
d75402b5 7059 target_compiler=$cross_cc_s390x
24e804ec 7060 ;;
444e06b1 7061 tilegx)
d75402b5 7062 target_compiler=$cross_cc_tilegx
444e06b1 7063 ;;
5ecaa4ed 7064 tricore)
d75402b5 7065 target_compiler=$cross_cc_tricore
5ecaa4ed 7066 ;;
d2fbca94 7067 unicore32)
d75402b5 7068 target_compiler=$cross_cc_unicore32
d2fbca94 7069 ;;
cfa550c6
MF
7070 xtensa|xtensaeb)
7071 TARGET_ARCH=xtensa
9fb40342 7072 mttcg="yes"
d75402b5 7073 target_compiler=$cross_cc_xtensa
cfa550c6 7074 ;;
2408a527 7075 *)
76ad07a4 7076 error_exit "Unsupported target CPU"
2408a527
AJ
7077 ;;
7078esac
5e8861a0
PB
7079# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
7080if [ "$TARGET_BASE_ARCH" = "" ]; then
7081 TARGET_BASE_ARCH=$TARGET_ARCH
7082fi
7083
d75402b5
AB
7084# Do we have a cross compiler for this target?
7085if has $target_compiler; then
7086
7087 write_c_skeleton
7088
716a507c 7089 if ! do_compiler "$target_compiler" $target_compiler_cflags -o $TMPE $TMPC -static ; then
d75402b5 7090 # For host systems we might get away with building without -static
716a507c 7091 if ! do_compiler "$target_compiler" $target_compiler_cflags -o $TMPE $TMPC ; then
d75402b5
AB
7092 target_compiler=""
7093 else
7094 enabled_cross_compilers="${enabled_cross_compilers} '${target_compiler}'"
7095 target_compiler_static="n"
7096 fi
7097 else
7098 enabled_cross_compilers="${enabled_cross_compilers} '${target_compiler}'"
7099 target_compiler_static="y"
7100 fi
7101else
7102 target_compiler=""
7103fi
7104
5e8861a0
PB
7105symlink "$source_path/Makefile.target" "$target_dir/Makefile"
7106
99afc91d
DB
7107upper() {
7108 echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
7109}
7110
89138857 7111target_arch_name="$(upper $TARGET_ARCH)"
25be210f 7112echo "TARGET_$target_arch_name=y" >> $config_target_mak
c1799a84 7113echo "TARGET_NAME=$target_name" >> $config_target_mak
25be210f 7114echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
e6e91b9c
JQ
7115if [ "$TARGET_ABI_DIR" = "" ]; then
7116 TARGET_ABI_DIR=$TARGET_ARCH
7117fi
25be210f 7118echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
adfc3e91
SS
7119if [ "$HOST_VARIANT_DIR" != "" ]; then
7120 echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
7121fi
3b6b7550
PB
7122
7123if supported_xen_target $target; then
7124 echo "CONFIG_XEN=y" >> $config_target_mak
7125 if test "$xen_pci_passthrough" = yes; then
eb6fda0f 7126 echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
1b0c87fc 7127 fi
3b6b7550
PB
7128fi
7129if supported_kvm_target $target; then
7130 echo "CONFIG_KVM=y" >> $config_target_mak
7131 if test "$vhost_net" = "yes" ; then
d5970055 7132 echo "CONFIG_VHOST_NET=y" >> $config_target_mak
e6a74868
MAL
7133 if test "$vhost_user" = "yes" ; then
7134 echo "CONFIG_VHOST_USER_NET_TEST_$target_name=y" >> $config_host_mak
7135 fi
c59249f9 7136 fi
3b6b7550
PB
7137fi
7138if supported_hax_target $target; then
7139 echo "CONFIG_HAX=y" >> $config_target_mak
b0cb0a66 7140fi
c97d6d2c
SAGDR
7141if supported_hvf_target $target; then
7142 echo "CONFIG_HVF=y" >> $config_target_mak
7143fi
d661d9a4
JTV
7144if supported_whpx_target $target; then
7145 echo "CONFIG_WHPX=y" >> $config_target_mak
7146fi
de83cd02 7147if test "$target_bigendian" = "yes" ; then
25be210f 7148 echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
de83cd02 7149fi
97a847bc 7150if test "$target_softmmu" = "yes" ; then
25be210f 7151 echo "CONFIG_SOFTMMU=y" >> $config_target_mak
ca759f9e
AB
7152 if test "$mttcg" = "yes" ; then
7153 echo "TARGET_SUPPORTS_MTTCG=y" >> $config_target_mak
7154 fi
43ce4dfe 7155fi
997344f3 7156if test "$target_user_only" = "yes" ; then
25be210f 7157 echo "CONFIG_USER_ONLY=y" >> $config_target_mak
a2c80be9 7158 echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
997344f3 7159fi
831b7825 7160if test "$target_linux_user" = "yes" ; then
25be210f 7161 echo "CONFIG_LINUX_USER=y" >> $config_target_mak
831b7825 7162fi
56aebc89
PB
7163list=""
7164if test ! -z "$gdb_xml_files" ; then
7165 for x in $gdb_xml_files; do
7166 list="$list $source_path/gdb-xml/$x"
7167 done
3d0f1517 7168 echo "TARGET_XML_FILES=$list" >> $config_target_mak
56aebc89 7169fi
97a847bc 7170
e5fe0c52 7171if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
25be210f 7172 echo "TARGET_HAS_BFLT=y" >> $config_target_mak
e5fe0c52 7173fi
84778508 7174if test "$target_bsd_user" = "yes" ; then
25be210f 7175 echo "CONFIG_BSD_USER=y" >> $config_target_mak
84778508 7176fi
5b0753e0 7177
d75402b5
AB
7178if test -n "$target_compiler"; then
7179 echo "CROSS_CC_GUEST=\"$target_compiler\"" >> $config_target_mak
7180
7181 if test -n "$target_compiler_static"; then
7182 echo "CROSS_CC_GUEST_STATIC=$target_compiler_static" >> $config_target_mak
7183 fi
716a507c
AB
7184
7185 if test -n "$target_compiler_cflags"; then
7186 echo "CROSS_CC_GUEST_CFLAGS=$target_compiler_cflags" >> $config_target_mak
7187 fi
d75402b5
AB
7188fi
7189
716a507c 7190
4afddb55 7191# generate QEMU_CFLAGS/LDFLAGS for targets
fa282484 7192
4afddb55 7193cflags=""
fa282484 7194ldflags=""
9b8e111f 7195
c765fcac
PC
7196disas_config() {
7197 echo "CONFIG_${1}_DIS=y" >> $config_target_mak
7198 echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
7199}
7200
64656024
JQ
7201for i in $ARCH $TARGET_BASE_ARCH ; do
7202 case "$i" in
7203 alpha)
c765fcac 7204 disas_config "ALPHA"
64656024 7205 ;;
82295d8a
RH
7206 aarch64)
7207 if test -n "${cxx}"; then
c765fcac 7208 disas_config "ARM_A64"
82295d8a
RH
7209 fi
7210 ;;
64656024 7211 arm)
c765fcac 7212 disas_config "ARM"
999b53ec 7213 if test -n "${cxx}"; then
c765fcac 7214 disas_config "ARM_A64"
999b53ec 7215 fi
64656024
JQ
7216 ;;
7217 cris)
c765fcac 7218 disas_config "CRIS"
64656024 7219 ;;
429b31a2
RH
7220 hppa)
7221 disas_config "HPPA"
7222 ;;
c72b26ec 7223 i386|x86_64|x32)
c765fcac 7224 disas_config "I386"
64656024 7225 ;;
79368f49 7226 lm32)
c765fcac 7227 disas_config "LM32"
79368f49 7228 ;;
64656024 7229 m68k)
c765fcac 7230 disas_config "M68K"
64656024 7231 ;;
877fdc12 7232 microblaze*)
c765fcac 7233 disas_config "MICROBLAZE"
64656024
JQ
7234 ;;
7235 mips*)
c765fcac 7236 disas_config "MIPS"
64656024 7237 ;;
d15a9c23 7238 moxie*)
c765fcac 7239 disas_config "MOXIE"
d15a9c23 7240 ;;
e671711c
MV
7241 nios2)
7242 disas_config "NIOS2"
7243 ;;
4a09d0bb 7244 or1k)
c765fcac 7245 disas_config "OPENRISC"
e67db06e 7246 ;;
64656024 7247 ppc*)
c765fcac 7248 disas_config "PPC"
64656024 7249 ;;
25fa194b
MC
7250 riscv)
7251 disas_config "RISCV"
7252 ;;
24e804ec 7253 s390*)
c765fcac 7254 disas_config "S390"
64656024
JQ
7255 ;;
7256 sh4)
c765fcac 7257 disas_config "SH4"
64656024
JQ
7258 ;;
7259 sparc*)
c765fcac 7260 disas_config "SPARC"
64656024 7261 ;;
cfa550c6 7262 xtensa*)
c765fcac 7263 disas_config "XTENSA"
cfa550c6 7264 ;;
64656024
JQ
7265 esac
7266done
9195b2c2 7267if test "$tcg_interpreter" = "yes" ; then
c765fcac 7268 disas_config "TCI"
9195b2c2 7269fi
64656024 7270
6ee7126f
JQ
7271case "$ARCH" in
7272alpha)
7273 # Ensure there's only a single GP
7274 cflags="-msmall-data $cflags"
7275;;
7276esac
7277
d02c1db3 7278if test "$gprof" = "yes" ; then
25be210f 7279 echo "TARGET_GPROF=yes" >> $config_target_mak
d02c1db3
JQ
7280 if test "$target_linux_user" = "yes" ; then
7281 cflags="-p $cflags"
7282 ldflags="-p $ldflags"
7283 fi
7284 if test "$target_softmmu" = "yes" ; then
7285 ldflags="-p $ldflags"
25be210f 7286 echo "GPROF_CFLAGS=-p" >> $config_target_mak
d02c1db3
JQ
7287 fi
7288fi
7289
9b8e111f 7290if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
964c6fa1 7291 ldflags="$ldflags $textseg_ldflags"
fa282484 7292fi
fa282484 7293
e9a3591f
CB
7294# Newer kernels on s390 check for an S390_PGSTE program header and
7295# enable the pgste page table extensions in that case. This makes
7296# the vm.allocate_pgste sysctl unnecessary. We enable this program
7297# header if
7298# - we build on s390x
7299# - we build the system emulation for s390x (qemu-system-s390x)
7300# - KVM is enabled
7301# - the linker supports --s390-pgste
7302if test "$TARGET_ARCH" = "s390x" -a "$target_softmmu" = "yes" -a "$ARCH" = "s390x" -a "$kvm" = "yes"; then
7303 if ld_has --s390-pgste ; then
7304 ldflags="-Wl,--s390-pgste $ldflags"
7305 fi
7306fi
7307
25be210f
JQ
7308echo "LDFLAGS+=$ldflags" >> $config_target_mak
7309echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak
fa282484 7310
97a847bc 7311done # for target in $targets
7d13299d 7312
d75402b5
AB
7313if test -n "$enabled_cross_compilers"; then
7314 echo
7315 echo "NOTE: cross-compilers enabled: $enabled_cross_compilers"
7316fi
7317
e3971d61 7318if [ "$fdt" = "git" ]; then
a540f158
PC
7319 echo "config-host.h: subdir-dtc" >> $config_host_mak
7320fi
e219c499
RH
7321if [ "$capstone" = "git" -o "$capstone" = "internal" ]; then
7322 echo "config-host.h: subdir-capstone" >> $config_host_mak
7323fi
7324if test -n "$LIBCAPSTONE"; then
7325 echo "LIBCAPSTONE=$LIBCAPSTONE" >> $config_host_mak
7326fi
a540f158 7327
a99d57bb
WG
7328if test "$numa" = "yes"; then
7329 echo "CONFIG_NUMA=y" >> $config_host_mak
7330fi
7331
fd0e6053
JS
7332if test "$ccache_cpp2" = "yes"; then
7333 echo "export CCACHE_CPP2=y" >> $config_host_mak
7334fi
7335
d1807a4f 7336# build tree in object directory in case the source is not in the current directory
b1fb9a63 7337DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests tests/vm"
b855f8d1 7338DIRS="$DIRS docs docs/interop fsdev scsi"
9933c305 7339DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
d1807a4f 7340DIRS="$DIRS roms/seabios roms/vgabios"
c09015dd
AL
7341FILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
7342FILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
aaa2ebc5 7343FILES="$FILES tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
d1807a4f 7344FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
446b9165 7345FILES="$FILES pc-bios/spapr-rtas/Makefile"
9933c305 7346FILES="$FILES pc-bios/s390-ccw/Makefile"
d1807a4f 7347FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
4652b792 7348FILES="$FILES pc-bios/qemu-icon.bmp"
3a586d2f 7349FILES="$FILES .gdbinit scripts" # scripts needed by relative path in .gdbinit
753d11f2
RH
7350for bios_file in \
7351 $source_path/pc-bios/*.bin \
225a9ab8 7352 $source_path/pc-bios/*.lid \
5acc2ec0 7353 $source_path/pc-bios/*.aml \
753d11f2
RH
7354 $source_path/pc-bios/*.rom \
7355 $source_path/pc-bios/*.dtb \
e89e33e1 7356 $source_path/pc-bios/*.img \
753d11f2 7357 $source_path/pc-bios/openbios-* \
4e73c781 7358 $source_path/pc-bios/u-boot.* \
753d11f2
RH
7359 $source_path/pc-bios/palcode-*
7360do
89138857 7361 FILES="$FILES pc-bios/$(basename $bios_file)"
d1807a4f 7362done
89138857 7363for test_file in $(find $source_path/tests/acpi-test-data -type f)
c2304b52 7364do
89138857 7365 FILES="$FILES tests/acpi-test-data$(echo $test_file | sed -e 's/.*acpi-test-data//')"
c2304b52 7366done
d1807a4f
PB
7367mkdir -p $DIRS
7368for f in $FILES ; do
cab00a5a 7369 if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
f9245e10
PM
7370 symlink "$source_path/$f" "$f"
7371 fi
d1807a4f 7372done
1ad2134f 7373
c34ebfdc 7374# temporary config to build submodules
2d9f27d2 7375for rom in seabios vgabios ; do
c34ebfdc 7376 config_mak=roms/$rom/config.mak
37116c89 7377 echo "# Automatically generated by configure - do not modify" > $config_mak
c34ebfdc 7378 echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
cdbd727c 7379 echo "AS=$as" >> $config_mak
5f6f0e27 7380 echo "CCAS=$ccas" >> $config_mak
c34ebfdc
AL
7381 echo "CC=$cc" >> $config_mak
7382 echo "BCC=bcc" >> $config_mak
3dd46c78 7383 echo "CPP=$cpp" >> $config_mak
c34ebfdc 7384 echo "OBJCOPY=objcopy" >> $config_mak
a31a8642 7385 echo "IASL=$iasl" >> $config_mak
c34ebfdc 7386 echo "LD=$ld" >> $config_mak
9f81aeb5 7387 echo "RANLIB=$ranlib" >> $config_mak
c34ebfdc
AL
7388done
7389
fe31017f 7390# set up tests data directory
1b145d59
PMD
7391for tests_subdir in acceptance data; do
7392 if [ ! -e tests/$tests_subdir ]; then
7393 symlink "$source_path/tests/$tests_subdir" tests/$tests_subdir
7394 fi
7395done
fe31017f 7396
76c7560a
HR
7397# set up qemu-iotests in this build directory
7398iotests_common_env="tests/qemu-iotests/common.env"
7399iotests_check="tests/qemu-iotests/check"
7400
7401echo "# Automatically generated by configure - do not modify" > "$iotests_common_env"
7402echo >> "$iotests_common_env"
7403echo "export PYTHON='$python'" >> "$iotests_common_env"
7404
7405if [ ! -e "$iotests_check" ]; then
7406 symlink "$source_path/$iotests_check" "$iotests_check"
7407fi
7408
dc655404
MT
7409# Save the configure command line for later reuse.
7410cat <<EOD >config.status
7411#!/bin/sh
7412# Generated by configure.
7413# Run this file to recreate the current configuration.
7414# Compiler output produced by configure, useful for debugging
7415# configure, is in config.log if it exists.
7416EOD
7417printf "exec" >>config.status
7418printf " '%s'" "$0" "$@" >>config.status
cf7cc929 7419echo ' "$@"' >>config.status
dc655404
MT
7420chmod +x config.status
7421
8cd05ab6 7422rm -r "$TMPDIR1"
This page took 2.835544 seconds and 4 git commands to generate.