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