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