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