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