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