]> git.proxmox.com Git - mirror_qemu.git/blame - configure
meson-buildoptions: include list of tracing backends
[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
835af899
PB
92quote_sh() {
93 printf "%s" "$1" | sed "s,','\\\\'',g; s,.*,'&',"
94}
95
d880a3ba
PB
96print_error() {
97 (echo
76ad07a4
PM
98 echo "ERROR: $1"
99 while test -n "$2"; do
100 echo " $2"
101 shift
102 done
d880a3ba
PB
103 echo) >&2
104}
105
106error_exit() {
107 print_error "$@"
76ad07a4
PM
108 exit 1
109}
110
9c83ffd8
PM
111do_compiler() {
112 # Run the compiler, capturing its output to the log. First argument
113 # is compiler binary to execute.
630d86b7 114 compiler="$1"
9c83ffd8 115 shift
8bbe05d7
IJ
116 if test -n "$BASH_VERSION"; then eval '
117 echo >>config.log "
118funcs: ${FUNCNAME[*]}
119lines: ${BASH_LINENO[*]}"
120 '; fi
9c83ffd8
PM
121 echo $compiler "$@" >> config.log
122 $compiler "$@" >> config.log 2>&1 || return $?
8dc38a78
PM
123 # Test passed. If this is an --enable-werror build, rerun
124 # the test with -Werror and bail out if it fails. This
125 # makes warning-generating-errors in configure test code
126 # obvious to developers.
127 if test "$werror" != "yes"; then
128 return 0
129 fi
130 # Don't bother rerunning the compile if we were already using -Werror
131 case "$*" in
132 *-Werror*)
133 return 0
134 ;;
135 esac
9c83ffd8
PM
136 echo $compiler -Werror "$@" >> config.log
137 $compiler -Werror "$@" >> config.log 2>&1 && return $?
76ad07a4
PM
138 error_exit "configure test passed without -Werror but failed with -Werror." \
139 "This is probably a bug in the configure script. The failing command" \
140 "will be at the bottom of config.log." \
141 "You can run configure with --disable-werror to bypass this check."
8dc38a78
PM
142}
143
9c83ffd8 144do_cc() {
4dba2789 145 do_compiler "$cc" $CPU_CFLAGS "$@"
9c83ffd8
PM
146}
147
148do_cxx() {
4dba2789 149 do_compiler "$cxx" $CPU_CFLAGS "$@"
9c83ffd8
PM
150}
151
00849b92
RH
152# Append $2 to the variable named $1, with space separation
153add_to() {
154 eval $1=\${$1:+\"\$$1 \"}\$2
155}
156
9c83ffd8
PM
157update_cxxflags() {
158 # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
159 # options which some versions of GCC's C++ compiler complain about
160 # because they only make sense for C programs.
53422040 161 QEMU_CXXFLAGS="$QEMU_CXXFLAGS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS"
8a9d3d56 162 CONFIGURE_CXXFLAGS=$(echo "$CONFIGURE_CFLAGS" | sed s/-std=gnu11/-std=gnu++11/)
9c83ffd8
PM
163 for arg in $QEMU_CFLAGS; do
164 case $arg in
165 -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
166 -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
167 ;;
168 *)
169 QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
170 ;;
171 esac
172 done
173}
174
52166aa0 175compile_object() {
fd0e6053 176 local_cflags="$1"
5770e8af 177 do_cc $CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
52166aa0
JQ
178}
179
180compile_prog() {
181 local_cflags="$1"
182 local_ldflags="$2"
5770e8af
PB
183 do_cc $CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC \
184 $LDFLAGS $CONFIGURE_LDFLAGS $QEMU_LDFLAGS $local_ldflags
52166aa0
JQ
185}
186
11568d6d
PB
187# symbolically link $1 to $2. Portable version of "ln -sf".
188symlink() {
72b8b5a1 189 rm -rf "$2"
ec5b06d7 190 mkdir -p "$(dirname "$2")"
72b8b5a1 191 ln -s "$1" "$2"
11568d6d
PB
192}
193
0dba6195
LM
194# check whether a command is available to this shell (may be either an
195# executable or a builtin)
196has() {
197 type "$1" >/dev/null 2>&1
198}
199
0a01d76f 200version_ge () {
2df52b9b
AB
201 local_ver1=$(expr "$1" : '\([0-9.]*\)' | tr . ' ')
202 local_ver2=$(echo "$2" | tr . ' ')
0a01d76f
MAL
203 while true; do
204 set x $local_ver1
205 local_first=${2-0}
c44a33e2
SG
206 # 'shift 2' if $2 is set, or 'shift' if $2 is not set
207 shift ${2:+2}
0a01d76f
MAL
208 local_ver1=$*
209 set x $local_ver2
210 # the second argument finished, the first must be greater or equal
211 test $# = 1 && return 0
212 test $local_first -lt $2 && return 1
213 test $local_first -gt $2 && return 0
c44a33e2 214 shift ${2:+2}
0a01d76f
MAL
215 local_ver2=$*
216 done
217}
218
3b6b7550
PB
219glob() {
220 eval test -z '"${1#'"$2"'}"'
221}
222
e9a3591f
CB
223ld_has() {
224 $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
225}
226
4ace32e2
AO
227if printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]";
228then
229 error_exit "main directory cannot contain spaces nor colons"
230fi
231
14211825 232# default parameters
2ff6b91e 233cpu=""
a31a8642 234iasl="iasl"
1e43adfc 235interp_prefix="/usr/gnemul/qemu-%M"
43ce4dfe 236static="no"
3812c0c4 237cross_compile="no"
7d13299d 238cross_prefix=""
87430d5b 239audio_drv_list="default"
b64ec4e4
FZ
240block_drv_rw_whitelist=""
241block_drv_ro_whitelist=""
e5f05f8c 242block_drv_whitelist_tools="no"
e49d021e 243host_cc="cc"
957f1f99 244libs_qga=""
5bc62e01 245debug_info="yes"
cdad781d 246lto="false"
63678e17 247stack_protector=""
1e4f6065 248safe_stack=""
afc3a8f9 249use_containers="yes"
f2385398 250gdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
ac0df51d 251
92712822
DB
252if test -e "$source_path/.git"
253then
7d7dbf9d 254 git_submodules_action="update"
92712822 255else
7d7dbf9d 256 git_submodules_action="ignore"
92712822 257fi
2d652f24
PB
258
259git_submodules="ui/keycodemapdb"
cc84d63a 260git="git"
ac0df51d 261
afb63ebd
SW
262# Don't accept a target_list environment variable.
263unset target_list
447e133f 264unset target_list_exclude
377529c0
PB
265
266# Default value for a variable defining feature "foo".
267# * foo="no" feature will only be used if --enable-foo arg is given
268# * foo="" feature will be searched for, and if found, will be used
269# unless --disable-foo is given
270# * foo="yes" this value will only be set by --enable-foo flag.
271# feature will searched for,
272# if not found, configure exits with error
273#
274# Always add --enable-foo and --disable-foo command line args.
275# Distributions want to ensure that several features are compiled in, and it
276# is impossible without a --enable-foo that exits if a feature is not found.
277
c87ea116
AB
278default_feature=""
279# parse CC options second
280for opt do
281 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
282 case "$opt" in
283 --without-default-features)
284 default_feature="no"
285 ;;
286 esac
287done
288
8c6d4ff4 289brlapi="auto"
f9cd86fe 290curl="auto"
5285e593
YL
291iconv="auto"
292curses="auto"
e3667660 293docs="auto"
fbb4121d 294fdt="auto"
837b84b1 295netmap="auto"
35be72ba
PB
296sdl="auto"
297sdl_image="auto"
cece116c 298virtiofsd="auto"
69202b40 299virtfs="auto"
5c53015a 300libudev="auto"
6ec0e15d 301mpath="auto"
3a6a1256 302vnc="auto"
deb62371 303sparse="auto"
e1723999 304vde="auto"
a0b93237
PB
305vnc_sasl="auto"
306vnc_jpeg="auto"
307vnc_png="auto"
4113f4cf 308xkbcommon="auto"
ca50e523
PB
309alsa="auto"
310coreaudio="auto"
311dsound="auto"
312jack="auto"
313oss="auto"
314pa="auto"
bcf0a7da 315xen=${default_feature:+disabled}
c87ea116 316xen_ctrl_version="$default_feature"
1badb709 317xen_pci_passthrough="auto"
ff66f3e5 318linux_aio="auto"
53c22b68 319linux_io_uring="auto"
727c8bb8 320cap_ng="auto"
f7f2d651 321attr="auto"
c87ea116 322xfs="$default_feature"
1badb709 323tcg="enabled"
c87ea116 324membarrier="$default_feature"
0848f8ac 325vhost_kernel="$default_feature"
c87ea116
AB
326vhost_net="$default_feature"
327vhost_crypto="$default_feature"
328vhost_scsi="$default_feature"
329vhost_vsock="$default_feature"
d88618f7 330vhost_user="no"
e5e856c1 331vhost_user_blk_server="auto"
c87ea116 332vhost_user_fs="$default_feature"
0848f8ac 333vhost_vdpa="$default_feature"
46627f41 334bpf="auto"
3bd40ec7
PB
335kvm="auto"
336hax="auto"
337hvf="auto"
338whpx="auto"
74a414a1 339nvmm="auto"
c87ea116
AB
340rdma="$default_feature"
341pvrdma="$default_feature"
377529c0
PB
342gprof="no"
343debug_tcg="no"
377529c0 344debug="no"
247724cb 345sanitizers="no"
0aebab04 346tsan="no"
c87ea116 347fortify_source="$default_feature"
377529c0 348strip_opt="yes"
23a77b2d 349tcg_interpreter="false"
377529c0 350mingw32="no"
1d728c39 351gcov="no"
c7328271 352EXESUF=""
17969268 353modules="no"
bd83c861 354module_upgrades="no"
377529c0 355prefix="/usr/local"
10ff82d1 356qemu_suffix="qemu"
4d34a86b 357slirp="auto"
377529c0
PB
358bsd="no"
359linux="no"
360solaris="no"
361profiler="no"
b4e312e9 362cocoa="auto"
377529c0
PB
363softmmu="yes"
364linux_user="no"
377529c0 365bsd_user="no"
c8d5450b 366blobs="true"
377529c0 367pkgversion=""
40d6444e 368pie=""
3556c233 369qom_cast_debug="yes"
baf86d6b 370trace_backends="log"
377529c0 371trace_file="trace"
3f0a5d55 372spice="auto"
58d3f3ff 373spice_protocol="auto"
fabd1e93 374rbd="auto"
5f364c57 375smartcard="auto"
0a40bcb7 376u2f="auto"
90540f32 377libusb="auto"
18f31e60 378usb_redir="auto"
c87ea116 379opengl="$default_feature"
5dd89908 380cpuid_h="no"
c87ea116 381avx2_opt="$default_feature"
8b18cdbf 382capstone="auto"
0c32a0ae 383lzo="auto"
241611ea 384snappy="auto"
29ba6116 385bzip2="auto"
ecea3696 386lzfse="auto"
b1def33d 387zstd="auto"
c87ea116 388guest_agent="$default_feature"
d9840e25 389guest_agent_with_vss="no"
50cbebb9 390guest_agent_ntddscsi="no"
b846ab7c 391guest_agent_msi="auto"
c87ea116 392vss_win32_sdk="$default_feature"
d9840e25 393win_sdk="no"
c87ea116 394want_tools="$default_feature"
9db405a3 395libiscsi="auto"
30045c05 396libnfs="auto"
519175a2 397coroutine=""
c87ea116 398coroutine_pool="$default_feature"
7d992e4d 399debug_stack_usage="no"
f0d92b56 400crypto_afalg="no"
9e62ba48
DB
401cfi="false"
402cfi_debug="false"
90835c2b 403seccomp="auto"
08821ca2 404glusterfs="auto"
1b695471 405gtk="auto"
a1c5e949 406tls_priority="NORMAL"
57612511
PB
407gnutls="auto"
408nettle="auto"
409gcrypt="auto"
05e391ae 410auth_pam="auto"
c23d7b4e 411vte="auto"
587d59d6 412virglrenderer="auto"
c87ea116
AB
413tpm="$default_feature"
414libssh="$default_feature"
415live_block_migration=${default_feature:-yes}
416numa="$default_feature"
2847b469 417tcmalloc="no"
7b01cb97 418jemalloc="no"
c87ea116
AB
419replication=${default_feature:-yes}
420bochs=${default_feature:-yes}
421cloop=${default_feature:-yes}
422dmg=${default_feature:-yes}
423qcow1=${default_feature:-yes}
424vdi=${default_feature:-yes}
425vvfat=${default_feature:-yes}
426qed=${default_feature:-yes}
427parallels=${default_feature:-yes}
c5b36c25 428libxml2="auto"
ba59fb77 429debug_mutex="no"
e36e8c70 430libpmem="auto"
7bc3ca7f 431default_devices="true"
ba4dd2aa 432plugins="$default_feature"
537b7248 433fuzzing="false"
b767d257 434rng_none="no"
c87ea116 435secret_keyring="$default_feature"
83ef1682 436libdaxctl="auto"
a5665051 437meson=""
48328880 438ninja=""
a5665051 439skip_meson=no
0e8e77d4 440gettext="auto"
a484a719 441fuse="auto"
df4ea709 442fuse_lseek="auto"
106ad1f9 443multiprocess="auto"
b8e0c493 444slirp_smbd="$default_feature"
377529c0 445
aa087962 446malloc_trim="auto"
20cf7b8e 447gio="$default_feature"
898be3e0 448
c87ea116 449# parse CC options second
ac0df51d 450for opt do
89138857 451 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
ac0df51d
AL
452 case "$opt" in
453 --cross-prefix=*) cross_prefix="$optarg"
3812c0c4 454 cross_compile="yes"
ac0df51d 455 ;;
3d8df640 456 --cc=*) CC="$optarg"
ac0df51d 457 ;;
83f73fce
TS
458 --cxx=*) CXX="$optarg"
459 ;;
2ff6b91e
JQ
460 --cpu=*) cpu="$optarg"
461 ;;
de385287 462 --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
db5adeaa 463 QEMU_LDFLAGS="$QEMU_LDFLAGS $optarg"
e2a2ed06 464 ;;
11cde1c8 465 --extra-cxxflags=*) QEMU_CXXFLAGS="$QEMU_CXXFLAGS $optarg"
11cde1c8 466 ;;
db5adeaa 467 --extra-ldflags=*) QEMU_LDFLAGS="$QEMU_LDFLAGS $optarg"
f9943cd5 468 EXTRA_LDFLAGS="$optarg"
e2a2ed06 469 ;;
5bc62e01
GH
470 --enable-debug-info) debug_info="yes"
471 ;;
472 --disable-debug-info) debug_info="no"
473 ;;
d75402b5
AB
474 --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
475 ;;
d422b2bc
AB
476 --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-flags-}; cc_arch=${cc_arch%%=*}
477 eval "cross_cc_cflags_${cc_arch}=\$optarg"
2038f8c8 478 cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}"
d422b2bc 479 ;;
d75402b5 480 --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
2038f8c8 481 cc_archs="$cc_archs $cc_arch"
d75402b5 482 eval "cross_cc_${cc_arch}=\$optarg"
2038f8c8 483 cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}"
d75402b5 484 ;;
ac0df51d
AL
485 esac
486done
ac0df51d
AL
487# OS specific
488# Using uname is really, really broken. Once we have the right set of checks
93148aa5 489# we can eliminate its usage altogether.
ac0df51d 490
e49d021e
PM
491# Preferred compiler:
492# ${CC} (if set)
493# ${cross_prefix}gcc (if cross-prefix specified)
494# system compiler
495if test -z "${CC}${cross_prefix}"; then
496 cc="$host_cc"
497else
498 cc="${CC-${cross_prefix}gcc}"
499fi
500
83f73fce
TS
501if test -z "${CXX}${cross_prefix}"; then
502 cxx="c++"
503else
504 cxx="${CXX-${cross_prefix}g++}"
505fi
506
b3198cc2 507ar="${AR-${cross_prefix}ar}"
cdbd727c 508as="${AS-${cross_prefix}as}"
5f6f0e27 509ccas="${CCAS-$cc}"
3dd46c78 510cpp="${CPP-$cc -E}"
b3198cc2
SY
511objcopy="${OBJCOPY-${cross_prefix}objcopy}"
512ld="${LD-${cross_prefix}ld}"
9f81aeb5 513ranlib="${RANLIB-${cross_prefix}ranlib}"
4852ee95 514nm="${NM-${cross_prefix}nm}"
b3198cc2
SY
515strip="${STRIP-${cross_prefix}strip}"
516windres="${WINDRES-${cross_prefix}windres}"
17884d7b
ST
517pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
518query_pkg_config() {
519 "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
520}
521pkg_config=query_pkg_config
47c03744 522sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
ac0df51d 523
be17dc90 524# default flags for all hosts
2d31515b
PM
525# We use -fwrapv to tell the compiler that we require a C dialect where
526# left shift of signed integers is well defined and has the expected
527# 2s-complement style results. (Both clang and gcc agree that it
528# provides these semantics.)
086d5f75
PB
529QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
530QEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
c95e3080 531QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
be17dc90 532QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
5770e8af
PB
533
534# Flags that are needed during configure but later taken care of by Meson
8a9d3d56 535CONFIGURE_CFLAGS="-std=gnu11 -Wall"
5770e8af 536CONFIGURE_LDFLAGS=
086d5f75 537
be17dc90 538
ac0df51d
AL
539check_define() {
540cat > $TMPC <<EOF
541#if !defined($1)
fd786e1a 542#error $1 not defined
ac0df51d
AL
543#endif
544int main(void) { return 0; }
545EOF
52166aa0 546 compile_object
ac0df51d
AL
547}
548
307119e7
GH
549check_include() {
550cat > $TMPC <<EOF
551#include <$1>
552int main(void) { return 0; }
553EOF
554 compile_object
555}
556
93b25869
JS
557write_c_skeleton() {
558 cat > $TMPC <<EOF
559int main(void) { return 0; }
560EOF
561}
562
bbea4050
PM
563if check_define __linux__ ; then
564 targetos="Linux"
565elif check_define _WIN32 ; then
566 targetos='MINGW32'
567elif check_define __OpenBSD__ ; then
568 targetos='OpenBSD'
569elif check_define __sun__ ; then
570 targetos='SunOS'
571elif check_define __HAIKU__ ; then
572 targetos='Haiku'
951fedfc
PM
573elif check_define __FreeBSD__ ; then
574 targetos='FreeBSD'
575elif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
576 targetos='GNU/kFreeBSD'
577elif check_define __DragonFly__ ; then
578 targetos='DragonFly'
579elif check_define __NetBSD__; then
580 targetos='NetBSD'
581elif check_define __APPLE__; then
582 targetos='Darwin'
bbea4050 583else
951fedfc
PM
584 # This is a fatal error, but don't report it yet, because we
585 # might be going to just print the --help text, or it might
586 # be the result of a missing compiler.
587 targetos='bogus'
bbea4050
PM
588fi
589
590# Some host OSes need non-standard checks for which CPU to use.
591# Note that these checks are broken for cross-compilation: if you're
592# cross-compiling to one of these OSes then you'll need to specify
593# the correct CPU with the --cpu option.
594case $targetos in
bbea4050 595SunOS)
89138857 596 # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
bbea4050
PM
597 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
598 cpu="x86_64"
599 fi
600esac
601
2ff6b91e
JQ
602if test ! -z "$cpu" ; then
603 # command line argument
604 :
605elif check_define __i386__ ; then
ac0df51d
AL
606 cpu="i386"
607elif check_define __x86_64__ ; then
c72b26ec
RH
608 if check_define __ILP32__ ; then
609 cpu="x32"
610 else
611 cpu="x86_64"
612 fi
3aa9bd6c 613elif check_define __sparc__ ; then
3aa9bd6c
BS
614 if check_define __arch64__ ; then
615 cpu="sparc64"
616 else
617 cpu="sparc"
618 fi
fdf7ed96 619elif check_define _ARCH_PPC ; then
620 if check_define _ARCH_PPC64 ; then
f8378acc
RH
621 if check_define _LITTLE_ENDIAN ; then
622 cpu="ppc64le"
623 else
624 cpu="ppc64"
625 fi
fdf7ed96 626 else
627 cpu="ppc"
628 fi
afa05235
AJ
629elif check_define __mips__ ; then
630 cpu="mips"
d66ed0ea
AJ
631elif check_define __s390__ ; then
632 if check_define __s390x__ ; then
633 cpu="s390x"
634 else
635 cpu="s390"
636 fi
c4f80543
AF
637elif check_define __riscv ; then
638 if check_define _LP64 ; then
639 cpu="riscv64"
640 else
641 cpu="riscv32"
642 fi
21d89f84
PM
643elif check_define __arm__ ; then
644 cpu="arm"
1f080313
CF
645elif check_define __aarch64__ ; then
646 cpu="aarch64"
ac0df51d 647else
89138857 648 cpu=$(uname -m)
ac0df51d
AL
649fi
650
359bc95d
PM
651ARCH=
652# Normalise host CPU name and set ARCH.
653# Note that this case should only have supported host CPUs, not guests.
7d13299d 654case "$cpu" in
ee35e968 655 ppc|ppc64|s390x|sparc64|x32|riscv32|riscv64)
898be3e0 656 ;;
f8378acc
RH
657 ppc64le)
658 ARCH="ppc64"
f8378acc 659 ;;
7d13299d 660 i386|i486|i586|i686|i86pc|BePC)
97a847bc 661 cpu="i386"
7d13299d 662 ;;
aaa5fa14
AJ
663 x86_64|amd64)
664 cpu="x86_64"
665 ;;
21d89f84
PM
666 armv*b|armv*l|arm)
667 cpu="arm"
7d13299d 668 ;;
1f080313
CF
669 aarch64)
670 cpu="aarch64"
671 ;;
afa05235
AJ
672 mips*)
673 cpu="mips"
674 ;;
3142255c 675 sparc|sun4[cdmuv])
ae228531
FB
676 cpu="sparc"
677 ;;
7d13299d 678 *)
359bc95d
PM
679 # This will result in either an error or falling back to TCI later
680 ARCH=unknown
7d13299d
FB
681 ;;
682esac
359bc95d
PM
683if test -z "$ARCH"; then
684 ARCH="$cpu"
685fi
e2d52ad3 686
7d13299d 687# OS specific
0dbfc675 688
7d13299d 689case $targetos in
67b915a5 690MINGW32*)
0dbfc675 691 mingw32="yes"
898be3e0 692 supported_os="yes"
9b8e4298 693 plugins="no"
fb648e9c 694 pie="no"
67b915a5 695;;
5c40d2bd 696GNU/kFreeBSD)
a167ba50 697 bsd="yes"
5c40d2bd 698;;
7d3505c5 699FreeBSD)
0dbfc675 700 bsd="yes"
e2a74729 701 bsd_user="yes"
0db4a067 702 make="${MAKE-gmake}"
f01576f1 703 # needed for kinfo_getvmmap(3) in libutil.h
7d3505c5 704;;
c5e97233 705DragonFly)
0dbfc675 706 bsd="yes"
0db4a067 707 make="${MAKE-gmake}"
c5e97233 708;;
7d3505c5 709NetBSD)
0dbfc675 710 bsd="yes"
0db4a067 711 make="${MAKE-gmake}"
7d3505c5
FB
712;;
713OpenBSD)
0dbfc675 714 bsd="yes"
0db4a067 715 make="${MAKE-gmake}"
7d3505c5 716;;
83fb7adf 717Darwin)
0dbfc675
JQ
718 bsd="yes"
719 darwin="yes"
a0b7cf6b
PM
720 # Disable attempts to use ObjectiveC features in os/object.h since they
721 # won't work when we're compiling with gcc as a C compiler.
722 QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
83fb7adf 723;;
ec530c81 724SunOS)
0dbfc675 725 solaris="yes"
0db4a067 726 make="${MAKE-gmake}"
e2d8830e 727 smbd="${SMBD-/usr/sfw/sbin/smbd}"
d741429a
BS
728# needed for CMSG_ macros in sys/socket.h
729 QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
730# needed for TIOCWIN* defines in termios.h
731 QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
86b2bd93 732;;
179cf400
AF
733Haiku)
734 haiku="yes"
b8ee198d
RZ
735 pie="no"
736 QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE -fPIC $QEMU_CFLAGS"
179cf400 737;;
898be3e0 738Linux)
0dbfc675
JQ
739 linux="yes"
740 linux_user="yes"
c87ea116 741 vhost_user=${default_feature:-yes}
898be3e0 742;;
7d13299d
FB
743esac
744
0db4a067 745: ${make=${MAKE-make}}
b6daf4d3 746
faf44142
DB
747# We prefer python 3.x. A bare 'python' is traditionally
748# python 2.x, but some distros have it as python 3.x, so
ddf90699 749# we check that too
faf44142 750python=
0a01d76f 751explicit_python=no
ddf90699 752for binary in "${PYTHON-python3}" python
faf44142
DB
753do
754 if has "$binary"
755 then
95c5f2de 756 python=$(command -v "$binary")
faf44142
DB
757 break
758 fi
759done
903458c8 760
903458c8 761
39d87c8c
AB
762# Check for ancillary tools used in testing
763genisoimage=
3df437c7 764for binary in genisoimage mkisofs
39d87c8c
AB
765do
766 if has $binary
767 then
768 genisoimage=$(command -v "$binary")
769 break
770 fi
771done
772
3c4a4d0d
PM
773# Default objcc to clang if available, otherwise use CC
774if has clang; then
775 objcc=clang
776else
777 objcc="$cc"
778fi
779
3457a3f8 780if test "$mingw32" = "yes" ; then
3457a3f8 781 EXESUF=".exe"
78e9d4ad 782 # MinGW needs -mthreads for TLS and macro _MT.
5770e8af 783 CONFIGURE_CFLAGS="-mthreads $CONFIGURE_CFLAGS"
93b25869 784 write_c_skeleton;
d17f305a 785 prefix="/qemu"
77433a5f 786 qemu_suffix=""
105fad6b 787 libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
3457a3f8
JQ
788fi
789
487fefdb 790werror=""
85aa5189 791
61d63097
PB
792. $source_path/scripts/meson-buildoptions.sh
793
794meson_options=
795meson_option_parse() {
796 meson_options="$meson_options $(_meson_option_parse "$@")"
797 if test $? -eq 1; then
798 echo "ERROR: unknown option $1"
799 echo "Try '$0 --help' for more information"
800 exit 1
801 fi
802}
803
7d13299d 804for opt do
89138857 805 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
7d13299d 806 case "$opt" in
2efc3265
FB
807 --help|-h) show_help=yes
808 ;;
99123e13
MF
809 --version|-V) exec cat $source_path/VERSION
810 ;;
b1a550a0 811 --prefix=*) prefix="$optarg"
7d13299d 812 ;;
b1a550a0 813 --interp-prefix=*) interp_prefix="$optarg"
32ce6337 814 ;;
ac0df51d 815 --cross-prefix=*)
7d13299d 816 ;;
ac0df51d 817 --cc=*)
7d13299d 818 ;;
b1a550a0 819 --host-cc=*) host_cc="$optarg"
83469015 820 ;;
83f73fce
TS
821 --cxx=*)
822 ;;
e007dbec
MT
823 --iasl=*) iasl="$optarg"
824 ;;
3c4a4d0d
PM
825 --objcc=*) objcc="$optarg"
826 ;;
b1a550a0 827 --make=*) make="$optarg"
7d13299d 828 ;;
b6daf4d3 829 --install=*)
6a882643 830 ;;
0a01d76f 831 --python=*) python="$optarg" ; explicit_python=yes
c886edfb 832 ;;
2eb054c2
PM
833 --sphinx-build=*) sphinx_build="$optarg"
834 ;;
a5665051
PB
835 --skip-meson) skip_meson=yes
836 ;;
837 --meson=*) meson="$optarg"
838 ;;
48328880
PB
839 --ninja=*) ninja="$optarg"
840 ;;
e2d8830e
BS
841 --smbd=*) smbd="$optarg"
842 ;;
e2a2ed06 843 --extra-cflags=*)
7d13299d 844 ;;
11cde1c8
BD
845 --extra-cxxflags=*)
846 ;;
e2a2ed06 847 --extra-ldflags=*)
7d13299d 848 ;;
5bc62e01
GH
849 --enable-debug-info)
850 ;;
851 --disable-debug-info)
852 ;;
d75402b5
AB
853 --cross-cc-*)
854 ;;
17969268
FZ
855 --enable-modules)
856 modules="yes"
3aa88b31
SH
857 ;;
858 --disable-modules)
859 modules="no"
17969268 860 ;;
bd83c861
CE
861 --disable-module-upgrades) module_upgrades="no"
862 ;;
863 --enable-module-upgrades) module_upgrades="yes"
864 ;;
2ff6b91e 865 --cpu=*)
7d13299d 866 ;;
b1a550a0 867 --target-list=*) target_list="$optarg"
447e133f
AB
868 if test "$target_list_exclude"; then
869 error_exit "Can't mix --target-list with --target-list-exclude"
870 fi
871 ;;
872 --target-list-exclude=*) target_list_exclude="$optarg"
873 if test "$target_list"; then
874 error_exit "Can't mix --target-list-exclude with --target-list"
875 fi
de83cd02 876 ;;
5b808275
LV
877 --enable-trace-backends=*) trace_backends="$optarg"
878 ;;
879 # XXX: backwards compatibility
880 --enable-trace-backend=*) trace_backends="$optarg"
94a420b1 881 ;;
74242e0f 882 --with-trace-file=*) trace_file="$optarg"
9410b56c 883 ;;
7bc3ca7f 884 --with-default-devices) default_devices="true"
f3494749 885 ;;
7bc3ca7f 886 --without-default-devices) default_devices="false"
f3494749 887 ;;
d1d5e9ee
AB
888 --with-devices-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --with-devices-FOO option"
889 ;;
890 --with-devices-*) device_arch=${opt#--with-devices-};
891 device_arch=${device_arch%%=*}
892 cf=$source_path/configs/devices/$device_arch-softmmu/$optarg.mak
893 if test -f "$cf"; then
894 device_archs="$device_archs $device_arch"
895 eval "devices_${device_arch}=\$optarg"
896 else
897 error_exit "File $cf does not exist"
898 fi
899 ;;
c87ea116
AB
900 --without-default-features) # processed above
901 ;;
7d13299d
FB
902 --enable-gprof) gprof="yes"
903 ;;
1d728c39
BS
904 --enable-gcov) gcov="yes"
905 ;;
79427693
LM
906 --static)
907 static="yes"
17884d7b 908 QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
43ce4dfe 909 ;;
0b24e75f
PB
910 --mandir=*) mandir="$optarg"
911 ;;
912 --bindir=*) bindir="$optarg"
913 ;;
3aa5d2be
AL
914 --libdir=*) libdir="$optarg"
915 ;;
8bf188aa
MT
916 --libexecdir=*) libexecdir="$optarg"
917 ;;
0f94d6da
AL
918 --includedir=*) includedir="$optarg"
919 ;;
528ae5b8 920 --datadir=*) datadir="$optarg"
0b24e75f 921 ;;
77433a5f 922 --with-suffix=*) qemu_suffix="$optarg"
023d3d67 923 ;;
c6502638 924 --docdir=*) docdir="$optarg"
0b24e75f 925 ;;
fe0038be
PB
926 --localedir=*) localedir="$optarg"
927 ;;
ca2fb938 928 --sysconfdir=*) sysconfdir="$optarg"
07381cc1 929 ;;
785c23ae
LC
930 --localstatedir=*) local_statedir="$optarg"
931 ;;
3d5eecab
GH
932 --firmwarepath=*) firmwarepath="$optarg"
933 ;;
181ce1d0
OH
934 --host=*|--build=*|\
935 --disable-dependency-tracking|\
785c23ae 936 --sbindir=*|--sharedstatedir=*|\
fe0038be 937 --oldincludedir=*|--datarootdir=*|--infodir=*|\
023ddd74
MF
938 --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
939 # These switches are silently ignored, for compatibility with
940 # autoconf-generated configure scripts. This allows QEMU's
941 # configure to be used by RPM and similar macros that set
942 # lots of directory switches by default.
943 ;;
35be72ba 944 --disable-sdl) sdl="disabled"
97a847bc 945 ;;
35be72ba 946 --enable-sdl) sdl="enabled"
c4198157 947 ;;
35be72ba 948 --disable-sdl-image) sdl_image="disabled"
a442fe2f 949 ;;
35be72ba 950 --enable-sdl-image) sdl_image="enabled"
a442fe2f 951 ;;
3556c233
PB
952 --disable-qom-cast-debug) qom_cast_debug="no"
953 ;;
954 --enable-qom-cast-debug) qom_cast_debug="yes"
955 ;;
69202b40 956 --disable-virtfs) virtfs="disabled"
983eef5a 957 ;;
69202b40 958 --enable-virtfs) virtfs="enabled"
983eef5a 959 ;;
5c53015a
PB
960 --disable-libudev) libudev="disabled"
961 ;;
962 --enable-libudev) libudev="enabled"
963 ;;
cece116c
MT
964 --disable-virtiofsd) virtiofsd="disabled"
965 ;;
966 --enable-virtiofsd) virtiofsd="enabled"
967 ;;
6ec0e15d 968 --disable-mpath) mpath="disabled"
fe8fc5ae 969 ;;
6ec0e15d 970 --enable-mpath) mpath="enabled"
fe8fc5ae 971 ;;
a0b93237 972 --disable-vnc) vnc="disabled"
821601ea 973 ;;
a0b93237 974 --enable-vnc) vnc="enabled"
821601ea 975 ;;
0e8e77d4 976 --disable-gettext) gettext="disabled"
e8f3bd71 977 ;;
0e8e77d4 978 --enable-gettext) gettext="enabled"
e8f3bd71 979 ;;
0c58ac1c 980 --audio-drv-list=*) audio_drv_list="$optarg"
102a52e4 981 ;;
89138857 982 --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
b64ec4e4 983 ;;
89138857 984 --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
eb852011 985 ;;
e5f05f8c
KW
986 --enable-block-drv-whitelist-in-tools) block_drv_whitelist_tools="yes"
987 ;;
988 --disable-block-drv-whitelist-in-tools) block_drv_whitelist_tools="no"
989 ;;
f8393946
AJ
990 --enable-debug-tcg) debug_tcg="yes"
991 ;;
992 --disable-debug-tcg) debug_tcg="no"
993 ;;
f3d08ee6
PB
994 --enable-debug)
995 # Enable debugging options that aren't excessively noisy
996 debug_tcg="yes"
1fcc6d42 997 debug_mutex="yes"
f3d08ee6
PB
998 debug="yes"
999 strip_opt="no"
b553a042 1000 fortify_source="no"
f3d08ee6 1001 ;;
247724cb
MAL
1002 --enable-sanitizers) sanitizers="yes"
1003 ;;
1004 --disable-sanitizers) sanitizers="no"
1005 ;;
0aebab04
LY
1006 --enable-tsan) tsan="yes"
1007 ;;
1008 --disable-tsan) tsan="no"
1009 ;;
deb62371 1010 --enable-sparse) sparse="enabled"
03b4fe7d 1011 ;;
deb62371 1012 --disable-sparse) sparse="disabled"
03b4fe7d 1013 ;;
1625af87
AL
1014 --disable-strip) strip_opt="no"
1015 ;;
a0b93237 1016 --disable-vnc-sasl) vnc_sasl="disabled"
2f9606b3 1017 ;;
a0b93237 1018 --enable-vnc-sasl) vnc_sasl="enabled"
ea784e3b 1019 ;;
a0b93237 1020 --disable-vnc-jpeg) vnc_jpeg="disabled"
2f6f5c7a 1021 ;;
a0b93237 1022 --enable-vnc-jpeg) vnc_jpeg="enabled"
2f6f5c7a 1023 ;;
a0b93237 1024 --disable-vnc-png) vnc_png="disabled"
efe556ad 1025 ;;
a0b93237 1026 --enable-vnc-png) vnc_png="enabled"
efe556ad 1027 ;;
4d34a86b 1028 --disable-slirp) slirp="disabled"
1d14ffa9 1029 ;;
fd6fc214
PB
1030 --enable-slirp) slirp="enabled"
1031 ;;
4d34a86b 1032 --enable-slirp=git) slirp="internal"
7c57bdd8 1033 ;;
03a3c0b3 1034 --enable-slirp=*) slirp="$optarg"
675b9b53 1035 ;;
e1723999 1036 --disable-vde) vde="disabled"
8a16d273 1037 ;;
e1723999 1038 --enable-vde) vde="enabled"
dfb278bd 1039 ;;
837b84b1 1040 --disable-netmap) netmap="disabled"
58952137 1041 ;;
837b84b1 1042 --enable-netmap) netmap="enabled"
58952137 1043 ;;
1badb709 1044 --disable-xen) xen="disabled"
e37630ca 1045 ;;
1badb709 1046 --enable-xen) xen="enabled"
fc321b4b 1047 ;;
1badb709 1048 --disable-xen-pci-passthrough) xen_pci_passthrough="disabled"
eb6fda0f 1049 ;;
1badb709 1050 --enable-xen-pci-passthrough) xen_pci_passthrough="enabled"
eb6fda0f 1051 ;;
ca50e523
PB
1052 --disable-alsa) alsa="disabled"
1053 ;;
1054 --enable-alsa) alsa="enabled"
1055 ;;
1056 --disable-coreaudio) coreaudio="disabled"
1057 ;;
1058 --enable-coreaudio) coreaudio="enabled"
1059 ;;
1060 --disable-dsound) dsound="disabled"
1061 ;;
1062 --enable-dsound) dsound="enabled"
1063 ;;
1064 --disable-jack) jack="disabled"
1065 ;;
1066 --enable-jack) jack="enabled"
1067 ;;
1068 --disable-oss) oss="disabled"
1069 ;;
1070 --enable-oss) oss="enabled"
1071 ;;
1072 --disable-pa) pa="disabled"
1073 ;;
1074 --enable-pa) pa="enabled"
1075 ;;
8c6d4ff4 1076 --disable-brlapi) brlapi="disabled"
2e4d9fb1 1077 ;;
8c6d4ff4 1078 --enable-brlapi) brlapi="enabled"
4ffcedb6 1079 ;;
1badb709 1080 --disable-kvm) kvm="disabled"
7ba1e619 1081 ;;
1badb709 1082 --enable-kvm) kvm="enabled"
b31a0277 1083 ;;
1badb709 1084 --disable-hax) hax="disabled"
180fb750 1085 ;;
1badb709 1086 --enable-hax) hax="enabled"
180fb750 1087 ;;
1badb709 1088 --disable-hvf) hvf="disabled"
c97d6d2c 1089 ;;
1badb709 1090 --enable-hvf) hvf="enabled"
c97d6d2c 1091 ;;
74a414a1
RZ
1092 --disable-nvmm) nvmm="disabled"
1093 ;;
1094 --enable-nvmm) nvmm="enabled"
1095 ;;
1badb709 1096 --disable-whpx) whpx="disabled"
d661d9a4 1097 ;;
1badb709 1098 --enable-whpx) whpx="enabled"
d661d9a4 1099 ;;
c6fbea47 1100 --disable-tcg-interpreter) tcg_interpreter="false"
9195b2c2 1101 ;;
c6fbea47 1102 --enable-tcg-interpreter) tcg_interpreter="true"
9195b2c2 1103 ;;
727c8bb8 1104 --disable-cap-ng) cap_ng="disabled"
47e98658 1105 ;;
727c8bb8 1106 --enable-cap-ng) cap_ng="enabled"
47e98658 1107 ;;
1badb709 1108 --disable-tcg) tcg="disabled"
d1a14257 1109 plugins="no"
b3f6ea7e 1110 ;;
1badb709 1111 --enable-tcg) tcg="enabled"
b3f6ea7e 1112 ;;
aa087962 1113 --disable-malloc-trim) malloc_trim="disabled"
5a22ab71 1114 ;;
aa087962 1115 --enable-malloc-trim) malloc_trim="enabled"
5a22ab71 1116 ;;
cd4ec0b4
GH
1117 --disable-spice) spice="no"
1118 ;;
58d3f3ff
GH
1119 --enable-spice)
1120 spice_protocol="yes"
1121 spice="yes"
1122 ;;
1123 --disable-spice-protocol)
1124 spice_protocol="no"
1125 spice="no"
1126 ;;
1127 --enable-spice-protocol) spice_protocol="yes"
cd4ec0b4 1128 ;;
9db405a3 1129 --disable-libiscsi) libiscsi="disabled"
c589b249 1130 ;;
9db405a3 1131 --enable-libiscsi) libiscsi="enabled"
c589b249 1132 ;;
30045c05 1133 --disable-libnfs) libnfs="disabled"
6542aa9c 1134 ;;
30045c05 1135 --enable-libnfs) libnfs="enabled"
6542aa9c 1136 ;;
05c2a3e7
FB
1137 --enable-profiler) profiler="yes"
1138 ;;
b4e312e9 1139 --disable-cocoa) cocoa="disabled"
14821030 1140 ;;
a23a6789 1141 --enable-cocoa) cocoa="enabled"
1d14ffa9 1142 ;;
cad25d69 1143 --disable-system) softmmu="no"
0a8e90f4 1144 ;;
cad25d69 1145 --enable-system) softmmu="yes"
0a8e90f4 1146 ;;
0953a80f
ZA
1147 --disable-user)
1148 linux_user="no" ;
1149 bsd_user="no" ;
0953a80f
ZA
1150 ;;
1151 --enable-user) ;;
831b7825 1152 --disable-linux-user) linux_user="no"
0a8e90f4 1153 ;;
831b7825
TS
1154 --enable-linux-user) linux_user="yes"
1155 ;;
84778508
BS
1156 --disable-bsd-user) bsd_user="no"
1157 ;;
1158 --enable-bsd-user) bsd_user="yes"
1159 ;;
40d6444e 1160 --enable-pie) pie="yes"
34005a00 1161 ;;
40d6444e 1162 --disable-pie) pie="no"
34005a00 1163 ;;
85aa5189
FB
1164 --enable-werror) werror="yes"
1165 ;;
1166 --disable-werror) werror="no"
1167 ;;
cdad781d
DB
1168 --enable-lto) lto="true"
1169 ;;
1170 --disable-lto) lto="false"
1171 ;;
63678e17
SN
1172 --enable-stack-protector) stack_protector="yes"
1173 ;;
1174 --disable-stack-protector) stack_protector="no"
1175 ;;
1e4f6065
DB
1176 --enable-safe-stack) safe_stack="yes"
1177 ;;
1178 --disable-safe-stack) safe_stack="no"
1179 ;;
9e62ba48
DB
1180 --enable-cfi)
1181 cfi="true";
1182 lto="true";
1183 ;;
1184 --disable-cfi) cfi="false"
1185 ;;
1186 --enable-cfi-debug) cfi_debug="true"
1187 ;;
1188 --disable-cfi-debug) cfi_debug="false"
1189 ;;
5285e593 1190 --disable-curses) curses="disabled"
4d3b6f6e 1191 ;;
5285e593 1192 --enable-curses) curses="enabled"
c584a6d0 1193 ;;
5285e593 1194 --disable-iconv) iconv="disabled"
e08bb301 1195 ;;
5285e593 1196 --enable-iconv) iconv="enabled"
e08bb301 1197 ;;
f9cd86fe 1198 --disable-curl) curl="disabled"
769ce76d 1199 ;;
f9cd86fe 1200 --enable-curl) curl="enabled"
788c8196 1201 ;;
fbb4121d 1202 --disable-fdt) fdt="disabled"
2df87df7 1203 ;;
fbb4121d
PB
1204 --enable-fdt) fdt="enabled"
1205 ;;
1206 --enable-fdt=git) fdt="internal"
1207 ;;
03a3c0b3 1208 --enable-fdt=*) fdt="$optarg"
2df87df7 1209 ;;
ff66f3e5 1210 --disable-linux-aio) linux_aio="disabled"
5c6c3a6c 1211 ;;
ff66f3e5 1212 --enable-linux-aio) linux_aio="enabled"
5c6c3a6c 1213 ;;
53c22b68 1214 --disable-linux-io-uring) linux_io_uring="disabled"
c10dd856 1215 ;;
53c22b68 1216 --enable-linux-io-uring) linux_io_uring="enabled"
c10dd856 1217 ;;
f7f2d651 1218 --disable-attr) attr="disabled"
758e8e38 1219 ;;
f7f2d651 1220 --enable-attr) attr="enabled"
758e8e38 1221 ;;
a40161cb
PB
1222 --disable-membarrier) membarrier="no"
1223 ;;
1224 --enable-membarrier) membarrier="yes"
1225 ;;
46627f41
AM
1226 --disable-bpf) bpf="disabled"
1227 ;;
1228 --enable-bpf) bpf="enabled"
1229 ;;
c8d5450b 1230 --disable-blobs) blobs="false"
77755340 1231 ;;
7e563bfb 1232 --with-pkgversion=*) pkgversion="$optarg"
4a19f1ec 1233 ;;
519175a2
AB
1234 --with-coroutine=*) coroutine="$optarg"
1235 ;;
70c60c08
SH
1236 --disable-coroutine-pool) coroutine_pool="no"
1237 ;;
1238 --enable-coroutine-pool) coroutine_pool="yes"
1239 ;;
7d992e4d
PL
1240 --enable-debug-stack-usage) debug_stack_usage="yes"
1241 ;;
f0d92b56
LM
1242 --enable-crypto-afalg) crypto_afalg="yes"
1243 ;;
1244 --disable-crypto-afalg) crypto_afalg="no"
1245 ;;
e3667660 1246 --disable-docs) docs="disabled"
70ec5dc0 1247 ;;
e3667660 1248 --enable-docs) docs="enabled"
83a3ab8b 1249 ;;
d5970055
MT
1250 --disable-vhost-net) vhost_net="no"
1251 ;;
1252 --enable-vhost-net) vhost_net="yes"
1253 ;;
042cea27
GA
1254 --disable-vhost-crypto) vhost_crypto="no"
1255 ;;
299e6f19 1256 --enable-vhost-crypto) vhost_crypto="yes"
042cea27 1257 ;;
5e9be92d
NB
1258 --disable-vhost-scsi) vhost_scsi="no"
1259 ;;
1260 --enable-vhost-scsi) vhost_scsi="yes"
1261 ;;
fc0b9b0e
SH
1262 --disable-vhost-vsock) vhost_vsock="no"
1263 ;;
1264 --enable-vhost-vsock) vhost_vsock="yes"
1265 ;;
e5e856c1 1266 --disable-vhost-user-blk-server) vhost_user_blk_server="disabled"
bc15e44c 1267 ;;
e5e856c1 1268 --enable-vhost-user-blk-server) vhost_user_blk_server="enabled"
bc15e44c 1269 ;;
98fc1ada
DDAG
1270 --disable-vhost-user-fs) vhost_user_fs="no"
1271 ;;
1272 --enable-vhost-user-fs) vhost_user_fs="yes"
1273 ;;
da076ffe 1274 --disable-opengl) opengl="no"
20ff075b 1275 ;;
da076ffe 1276 --enable-opengl) opengl="yes"
20ff075b 1277 ;;
fabd1e93 1278 --disable-rbd) rbd="disabled"
f27aaf4b 1279 ;;
fabd1e93 1280 --enable-rbd) rbd="enabled"
f27aaf4b 1281 ;;
8c84cf11
ST
1282 --disable-xfsctl) xfs="no"
1283 ;;
1284 --enable-xfsctl) xfs="yes"
1285 ;;
5f364c57 1286 --disable-smartcard) smartcard="disabled"
111a38b0 1287 ;;
5f364c57 1288 --enable-smartcard) smartcard="enabled"
111a38b0 1289 ;;
0a40bcb7
CB
1290 --disable-u2f) u2f="disabled"
1291 ;;
1292 --enable-u2f) u2f="enabled"
1293 ;;
90540f32 1294 --disable-libusb) libusb="disabled"
2b2325ff 1295 ;;
90540f32 1296 --enable-libusb) libusb="enabled"
2b2325ff 1297 ;;
18f31e60 1298 --disable-usb-redir) usb_redir="disabled"
69354a83 1299 ;;
18f31e60 1300 --enable-usb-redir) usb_redir="enabled"
69354a83 1301 ;;
1ffb3bbb 1302 --disable-zlib-test)
1ece9905 1303 ;;
0c32a0ae 1304 --disable-lzo) lzo="disabled"
b25c9dff 1305 ;;
0c32a0ae 1306 --enable-lzo) lzo="enabled"
607dacd0 1307 ;;
241611ea 1308 --disable-snappy) snappy="disabled"
b25c9dff 1309 ;;
241611ea 1310 --enable-snappy) snappy="enabled"
607dacd0 1311 ;;
29ba6116 1312 --disable-bzip2) bzip2="disabled"
6b383c08 1313 ;;
29ba6116 1314 --enable-bzip2) bzip2="enabled"
6b383c08 1315 ;;
ecea3696 1316 --enable-lzfse) lzfse="enabled"
83bc1f97 1317 ;;
ecea3696 1318 --disable-lzfse) lzfse="disabled"
83bc1f97 1319 ;;
b1def33d 1320 --disable-zstd) zstd="disabled"
3a678481 1321 ;;
b1def33d 1322 --enable-zstd) zstd="enabled"
3a678481 1323 ;;
d138cee9
MR
1324 --enable-guest-agent) guest_agent="yes"
1325 ;;
1326 --disable-guest-agent) guest_agent="no"
1327 ;;
b846ab7c 1328 --enable-guest-agent-msi) guest_agent_msi="enabled"
9dacf32d 1329 ;;
b846ab7c 1330 --disable-guest-agent-msi) guest_agent_msi="disabled"
9dacf32d 1331 ;;
d9840e25
TS
1332 --with-vss-sdk) vss_win32_sdk=""
1333 ;;
1334 --with-vss-sdk=*) vss_win32_sdk="$optarg"
1335 ;;
1336 --without-vss-sdk) vss_win32_sdk="no"
1337 ;;
1338 --with-win-sdk) win_sdk=""
1339 ;;
1340 --with-win-sdk=*) win_sdk="$optarg"
1341 ;;
1342 --without-win-sdk) win_sdk="no"
1343 ;;
4b1c11fd
DB
1344 --enable-tools) want_tools="yes"
1345 ;;
1346 --disable-tools) want_tools="no"
1347 ;;
90835c2b 1348 --enable-seccomp) seccomp="enabled"
f794573e 1349 ;;
90835c2b 1350 --disable-seccomp) seccomp="disabled"
f794573e 1351 ;;
08821ca2 1352 --disable-glusterfs) glusterfs="disabled"
eb100396 1353 ;;
86583a07
LM
1354 --disable-avx2) avx2_opt="no"
1355 ;;
1356 --enable-avx2) avx2_opt="yes"
1357 ;;
6b8cd447
RH
1358 --disable-avx512f) avx512f_opt="no"
1359 ;;
1360 --enable-avx512f) avx512f_opt="yes"
1361 ;;
1362
08821ca2 1363 --enable-glusterfs) glusterfs="enabled"
eb100396 1364 ;;
52b53c04
FZ
1365 --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
1366 echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
583f6e7b 1367 ;;
cb6414df
FZ
1368 --enable-vhdx|--disable-vhdx)
1369 echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1370 ;;
315d3184
FZ
1371 --enable-uuid|--disable-uuid)
1372 echo "$0: $opt is obsolete, UUID support is always built" >&2
1373 ;;
1b695471 1374 --disable-gtk) gtk="disabled"
a4ccabcf 1375 ;;
1b695471 1376 --enable-gtk) gtk="enabled"
a4ccabcf 1377 ;;
a1c5e949
DB
1378 --tls-priority=*) tls_priority="$optarg"
1379 ;;
57612511 1380 --disable-gnutls) gnutls="disabled"
ddbb0d09 1381 ;;
57612511 1382 --enable-gnutls) gnutls="enabled"
ddbb0d09 1383 ;;
57612511 1384 --disable-nettle) nettle="disabled"
91bfcdb0 1385 ;;
57612511 1386 --enable-nettle) nettle="enabled"
91bfcdb0 1387 ;;
57612511 1388 --disable-gcrypt) gcrypt="disabled"
91bfcdb0 1389 ;;
57612511 1390 --enable-gcrypt) gcrypt="enabled"
91bfcdb0 1391 ;;
05e391ae 1392 --disable-auth-pam) auth_pam="disabled"
8953caf3 1393 ;;
05e391ae 1394 --enable-auth-pam) auth_pam="enabled"
8953caf3 1395 ;;
2da776db
MH
1396 --enable-rdma) rdma="yes"
1397 ;;
1398 --disable-rdma) rdma="no"
1399 ;;
21ab34c9
MA
1400 --enable-pvrdma) pvrdma="yes"
1401 ;;
1402 --disable-pvrdma) pvrdma="no"
1403 ;;
c23d7b4e 1404 --disable-vte) vte="disabled"
bbbf9bfb 1405 ;;
c23d7b4e 1406 --enable-vte) vte="enabled"
bbbf9bfb 1407 ;;
587d59d6 1408 --disable-virglrenderer) virglrenderer="disabled"
9d9e1521 1409 ;;
587d59d6 1410 --enable-virglrenderer) virglrenderer="enabled"
9d9e1521 1411 ;;
e91c793c
CR
1412 --disable-tpm) tpm="no"
1413 ;;
ab214c29
SB
1414 --enable-tpm) tpm="yes"
1415 ;;
b10d49d7 1416 --disable-libssh) libssh="no"
0a12ec87 1417 ;;
b10d49d7 1418 --enable-libssh) libssh="yes"
0a12ec87 1419 ;;
ed1701c6
DDAG
1420 --disable-live-block-migration) live_block_migration="no"
1421 ;;
1422 --enable-live-block-migration) live_block_migration="yes"
1423 ;;
a99d57bb
WG
1424 --disable-numa) numa="no"
1425 ;;
1426 --enable-numa) numa="yes"
1427 ;;
c5b36c25 1428 --disable-libxml2) libxml2="disabled"
ed279a06 1429 ;;
c5b36c25 1430 --enable-libxml2) libxml2="enabled"
ed279a06 1431 ;;
2847b469
FZ
1432 --disable-tcmalloc) tcmalloc="no"
1433 ;;
1434 --enable-tcmalloc) tcmalloc="yes"
1435 ;;
7b01cb97
AD
1436 --disable-jemalloc) jemalloc="no"
1437 ;;
1438 --enable-jemalloc) jemalloc="yes"
1439 ;;
a6b1d4c0
CX
1440 --disable-replication) replication="no"
1441 ;;
1442 --enable-replication) replication="yes"
1443 ;;
2f740136
JC
1444 --disable-bochs) bochs="no"
1445 ;;
1446 --enable-bochs) bochs="yes"
1447 ;;
1448 --disable-cloop) cloop="no"
1449 ;;
1450 --enable-cloop) cloop="yes"
1451 ;;
1452 --disable-dmg) dmg="no"
1453 ;;
1454 --enable-dmg) dmg="yes"
1455 ;;
1456 --disable-qcow1) qcow1="no"
1457 ;;
1458 --enable-qcow1) qcow1="yes"
1459 ;;
1460 --disable-vdi) vdi="no"
1461 ;;
1462 --enable-vdi) vdi="yes"
1463 ;;
1464 --disable-vvfat) vvfat="no"
1465 ;;
1466 --enable-vvfat) vvfat="yes"
1467 ;;
1468 --disable-qed) qed="no"
1469 ;;
1470 --enable-qed) qed="yes"
1471 ;;
1472 --disable-parallels) parallels="no"
1473 ;;
1474 --enable-parallels) parallels="yes"
1475 ;;
e6a74868
MAL
1476 --disable-vhost-user) vhost_user="no"
1477 ;;
299e6f19
PB
1478 --enable-vhost-user) vhost_user="yes"
1479 ;;
108a6481
CL
1480 --disable-vhost-vdpa) vhost_vdpa="no"
1481 ;;
1482 --enable-vhost-vdpa) vhost_vdpa="yes"
1483 ;;
299e6f19
PB
1484 --disable-vhost-kernel) vhost_kernel="no"
1485 ;;
1486 --enable-vhost-kernel) vhost_kernel="yes"
e6a74868 1487 ;;
8b18cdbf 1488 --disable-capstone) capstone="disabled"
8ca80760 1489 ;;
8b18cdbf 1490 --enable-capstone) capstone="enabled"
8ca80760 1491 ;;
8b18cdbf 1492 --enable-capstone=git) capstone="internal"
e219c499 1493 ;;
03a3c0b3 1494 --enable-capstone=*) capstone="$optarg"
e219c499 1495 ;;
cc84d63a
DB
1496 --with-git=*) git="$optarg"
1497 ;;
7d7dbf9d
DS
1498 --with-git-submodules=*)
1499 git_submodules_action="$optarg"
f62bbee5 1500 ;;
ba59fb77
PB
1501 --enable-debug-mutex) debug_mutex=yes
1502 ;;
1503 --disable-debug-mutex) debug_mutex=no
1504 ;;
5cd5d8a7 1505 --enable-libpmem) libpmem="enabled"
17824406 1506 ;;
5cd5d8a7 1507 --disable-libpmem) libpmem="disabled"
17824406 1508 ;;
4113f4cf 1509 --enable-xkbcommon) xkbcommon="enabled"
75411919 1510 ;;
4113f4cf 1511 --disable-xkbcommon) xkbcommon="disabled"
75411919 1512 ;;
9b8e4298
AB
1513 --enable-plugins) if test "$mingw32" = "yes"; then
1514 error_exit "TCG plugins not currently supported on Windows platforms"
1515 else
1516 plugins="yes"
1517 fi
40e8c6f4
AB
1518 ;;
1519 --disable-plugins) plugins="no"
1520 ;;
afc3a8f9
AB
1521 --enable-containers) use_containers="yes"
1522 ;;
1523 --disable-containers) use_containers="no"
1524 ;;
537b7248 1525 --enable-fuzzing) fuzzing=true
adc28027 1526 ;;
537b7248 1527 --disable-fuzzing) fuzzing=false
adc28027 1528 ;;
f48e590a
AB
1529 --gdb=*) gdb_bin="$optarg"
1530 ;;
b767d257
MMG
1531 --enable-rng-none) rng_none=yes
1532 ;;
1533 --disable-rng-none) rng_none=no
1534 ;;
54e7aac0
AK
1535 --enable-keyring) secret_keyring="yes"
1536 ;;
1537 --disable-keyring) secret_keyring="no"
1538 ;;
12033e16 1539 --enable-libdaxctl) libdaxctl="enabled"
21b2eca6 1540 ;;
12033e16 1541 --disable-libdaxctl) libdaxctl="disabled"
21b2eca6 1542 ;;
a484a719
HR
1543 --enable-fuse) fuse="enabled"
1544 ;;
1545 --disable-fuse) fuse="disabled"
1546 ;;
df4ea709
HR
1547 --enable-fuse-lseek) fuse_lseek="enabled"
1548 ;;
1549 --disable-fuse-lseek) fuse_lseek="disabled"
1550 ;;
106ad1f9 1551 --enable-multiprocess) multiprocess="enabled"
3090de69 1552 ;;
106ad1f9 1553 --disable-multiprocess) multiprocess="disabled"
3090de69 1554 ;;
20cf7b8e
DP
1555 --enable-gio) gio=yes
1556 ;;
1557 --disable-gio) gio=no
1558 ;;
b8e0c493
JD
1559 --enable-slirp-smbd) slirp_smbd=yes
1560 ;;
1561 --disable-slirp-smbd) slirp_smbd=no
1562 ;;
61d63097
PB
1563 --enable-* | --disable-*) meson_option_parse "$opt" "$optarg"
1564 ;;
2d2ad6d0
FZ
1565 *)
1566 echo "ERROR: unknown option $opt"
1567 echo "Try '$0 --help' for more information"
1568 exit 1
7f1559c6 1569 ;;
7d13299d
FB
1570 esac
1571done
1572
d1a14257
AB
1573# test for any invalid configuration combinations
1574if test "$plugins" = "yes" -a "$tcg" = "disabled"; then
1575 error_exit "Can't enable plugins on non-TCG builds"
1576fi
1577
7d7dbf9d
DS
1578case $git_submodules_action in
1579 update|validate)
1580 if test ! -e "$source_path/.git"; then
1581 echo "ERROR: cannot $git_submodules_action git submodules without .git"
1582 exit 1
1583 fi
1584 ;;
1585 ignore)
b80fd281
PB
1586 if ! test -f "$source_path/ui/keycodemapdb/README"
1587 then
1588 echo
1589 echo "ERROR: missing GIT submodules"
1590 echo
1591 if test -e "$source_path/.git"; then
1592 echo "--with-git-submodules=ignore specified but submodules were not"
1593 echo "checked out. Please initialize and update submodules."
1594 else
1595 echo "This is not a GIT checkout but module content appears to"
1596 echo "be missing. Do not use 'git archive' or GitHub download links"
1597 echo "to acquire QEMU source archives. Non-GIT builds are only"
1598 echo "supported with source archives linked from:"
1599 echo
1600 echo " https://www.qemu.org/download/#source"
1601 echo
1602 echo "Developers working with GIT can use scripts/archive-source.sh"
1603 echo "if they need to create valid source archives."
1604 fi
1605 echo
1606 exit 1
1607 fi
7d7dbf9d
DS
1608 ;;
1609 *)
1610 echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'"
1611 exit 1
1612 ;;
1613esac
1614
22a87800
MAL
1615libdir="${libdir:-$prefix/lib}"
1616libexecdir="${libexecdir:-$prefix/libexec}"
1617includedir="${includedir:-$prefix/include}"
1618
1619if test "$mingw32" = "yes" ; then
15588a62 1620 bindir="${bindir:-$prefix}"
22a87800 1621else
22a87800 1622 bindir="${bindir:-$prefix/bin}"
22a87800 1623fi
15588a62
JW
1624mandir="${mandir:-$prefix/share/man}"
1625datadir="${datadir:-$prefix/share}"
1626docdir="${docdir:-$prefix/share/doc}"
1627sysconfdir="${sysconfdir:-$prefix/etc}"
1628local_statedir="${local_statedir:-$prefix/var}"
16bf7a33
PB
1629firmwarepath="${firmwarepath:-$datadir/qemu-firmware}"
1630localedir="${localedir:-$datadir/locale}"
22a87800 1631
40293e58 1632case "$cpu" in
e3608d66
RH
1633 ppc)
1634 CPU_CFLAGS="-m32"
db5adeaa 1635 QEMU_LDFLAGS="-m32 $QEMU_LDFLAGS"
e3608d66
RH
1636 ;;
1637 ppc64)
1638 CPU_CFLAGS="-m64"
db5adeaa 1639 QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
e3608d66 1640 ;;
9b9c37c3 1641 sparc)
f1079bb8 1642 CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
db5adeaa 1643 QEMU_LDFLAGS="-m32 -mv8plus $QEMU_LDFLAGS"
3142255c 1644 ;;
ed968ff1 1645 sparc64)
79f3b12f 1646 CPU_CFLAGS="-m64 -mcpu=ultrasparc"
db5adeaa 1647 QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
3142255c 1648 ;;
76d83bde 1649 s390)
061cdd81 1650 CPU_CFLAGS="-m31"
db5adeaa 1651 QEMU_LDFLAGS="-m31 $QEMU_LDFLAGS"
28d7cc49
RH
1652 ;;
1653 s390x)
061cdd81 1654 CPU_CFLAGS="-m64"
db5adeaa 1655 QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
76d83bde 1656 ;;
40293e58 1657 i386)
79f3b12f 1658 CPU_CFLAGS="-m32"
db5adeaa 1659 QEMU_LDFLAGS="-m32 $QEMU_LDFLAGS"
40293e58
FB
1660 ;;
1661 x86_64)
7ebee43e
RH
1662 # ??? Only extremely old AMD cpus do not have cmpxchg16b.
1663 # If we truly care, we should simply detect this case at
1664 # runtime and generate the fallback to serial emulation.
1665 CPU_CFLAGS="-m64 -mcx16"
db5adeaa 1666 QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
d2fbca94 1667 ;;
c72b26ec
RH
1668 x32)
1669 CPU_CFLAGS="-mx32"
db5adeaa 1670 QEMU_LDFLAGS="-mx32 $QEMU_LDFLAGS"
c72b26ec 1671 ;;
30163d89 1672 # No special flags required for other host CPUs
3142255c
BS
1673esac
1674
9557af9c
AB
1675if eval test -z "\${cross_cc_$cpu}"; then
1676 eval "cross_cc_${cpu}=\$cc"
1677 cross_cc_vars="$cross_cc_vars cross_cc_${cpu}"
1678fi
79f3b12f 1679
affc88cc
PM
1680# For user-mode emulation the host arch has to be one we explicitly
1681# support, even if we're using TCI.
1682if [ "$ARCH" = "unknown" ]; then
1683 bsd_user="no"
1684 linux_user="no"
1685fi
1686
60e0df25 1687default_target_list=""
43692239 1688deprecated_targets_list=ppc64abi32-linux-user
fdb75aef 1689deprecated_features=""
6e92f823
PM
1690mak_wilds=""
1691
1692if [ "$softmmu" = "yes" ]; then
812b31d3 1693 mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak"
60e0df25 1694fi
6e92f823 1695if [ "$linux_user" = "yes" ]; then
812b31d3 1696 mak_wilds="${mak_wilds} $source_path/configs/targets/*-linux-user.mak"
60e0df25 1697fi
6e92f823 1698if [ "$bsd_user" = "yes" ]; then
812b31d3 1699 mak_wilds="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak"
60e0df25
PM
1700fi
1701
3a5ae4a9
AB
1702# If the user doesn't explicitly specify a deprecated target we will
1703# skip it.
1704if test -z "$target_list"; then
1705 if test -z "$target_list_exclude"; then
1706 target_list_exclude="$deprecated_targets_list"
1707 else
1708 target_list_exclude="$target_list_exclude,$deprecated_targets_list"
1709 fi
2d838d9b
AB
1710fi
1711
2d838d9b
AB
1712for config in $mak_wilds; do
1713 target="$(basename "$config" .mak)"
98db9a06 1714 if echo "$target_list_exclude" | grep -vq "$target"; then
2d838d9b
AB
1715 default_target_list="${default_target_list} $target"
1716 fi
1717done
6e92f823 1718
c53eeaf7 1719# Enumerate public trace backends for --help output
64a6047d 1720trace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
c53eeaf7 1721
af5db58e
PB
1722if test x"$show_help" = x"yes" ; then
1723cat << EOF
1724
1725Usage: configure [options]
1726Options: [defaults in brackets after descriptions]
1727
08fb77ed
SW
1728Standard options:
1729 --help print this message
1730 --prefix=PREFIX install in PREFIX [$prefix]
1731 --interp-prefix=PREFIX where to find shared libraries, etc.
1732 use %M for cpu name [$interp_prefix]
2deca810 1733 --target-list=LIST set target list (default: build all non-deprecated)
08fb77ed
SW
1734$(echo Available targets: $default_target_list | \
1735 fold -s -w 53 | sed -e 's/^/ /')
2deca810
AB
1736$(echo Deprecated targets: $deprecated_targets_list | \
1737 fold -s -w 53 | sed -e 's/^/ /')
447e133f 1738 --target-list-exclude=LIST exclude a set of targets from the default target-list
08fb77ed
SW
1739
1740Advanced options (experts only):
3812c0c4 1741 --cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix]
08fb77ed
SW
1742 --cc=CC use C compiler CC [$cc]
1743 --iasl=IASL use ACPI compiler IASL [$iasl]
1744 --host-cc=CC use C compiler CC [$host_cc] for code run at
1745 build time
1746 --cxx=CXX use C++ compiler CXX [$cxx]
1747 --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
1748 --extra-cflags=CFLAGS append extra C compiler flags QEMU_CFLAGS
11cde1c8 1749 --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
08fb77ed 1750 --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS
d75402b5 1751 --cross-cc-ARCH=CC use compiler when building ARCH guest test cases
d422b2bc 1752 --cross-cc-flags-ARCH= use compiler flags when building ARCH guest tests
08fb77ed 1753 --make=MAKE use specified make [$make]
08fb77ed 1754 --python=PYTHON use specified python [$python]
2eb054c2 1755 --sphinx-build=SPHINX use specified sphinx-build [$sphinx_build]
a5665051 1756 --meson=MESON use specified meson [$meson]
48328880 1757 --ninja=NINJA use specified ninja [$ninja]
08fb77ed 1758 --smbd=SMBD use specified smbd [$smbd]
db1b5f13 1759 --with-git=GIT use specified git [$git]
7d7dbf9d
DS
1760 --with-git-submodules=update update git submodules (default if .git dir exists)
1761 --with-git-submodules=validate fail if git submodules are not up to date
1762 --with-git-submodules=ignore do not update or check git submodules (default if no .git dir)
08fb77ed
SW
1763 --static enable static build [$static]
1764 --mandir=PATH install man pages in PATH
10ff82d1 1765 --datadir=PATH install firmware in PATH/$qemu_suffix
fe0038be 1766 --localedir=PATH install translation in PATH/$qemu_suffix
10ff82d1 1767 --docdir=PATH install documentation in PATH/$qemu_suffix
08fb77ed
SW
1768 --bindir=PATH install binaries in PATH
1769 --libdir=PATH install libraries in PATH
db1b5f13 1770 --libexecdir=PATH install helper binaries in PATH
10ff82d1 1771 --sysconfdir=PATH install config in PATH/$qemu_suffix
08fb77ed 1772 --localstatedir=PATH install local state in PATH (set at runtime on win32)
3d5eecab 1773 --firmwarepath=PATH search PATH for firmware files
13336606 1774 --efi-aarch64=PATH PATH of efi file to use for aarch64 VMs.
ca8c0909 1775 --with-suffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix]
db1b5f13 1776 --with-pkgversion=VERS use specified string as sub-version of the package
c035c8d6
PB
1777 --without-default-features default all --enable-* options to "disabled"
1778 --without-default-devices do not include any device that is not needed to
1779 start the emulator (only use if you are including
d1d5e9ee
AB
1780 desired devices in configs/devices/)
1781 --with-devices-ARCH=NAME override default configs/devices
08fb77ed 1782 --enable-debug enable common debug build options
247724cb 1783 --enable-sanitizers enable default sanitizers
0aebab04 1784 --enable-tsan enable thread sanitizer
08fb77ed
SW
1785 --disable-strip disable stripping binaries
1786 --disable-werror disable compilation abort on warning
63678e17 1787 --disable-stack-protector disable compiler-provided stack protection
87430d5b 1788 --audio-drv-list=LIST set audio drivers list
08fb77ed
SW
1789 --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L
1790 --block-drv-rw-whitelist=L
1791 set block driver read-write whitelist
e5f05f8c 1792 (by default affects only QEMU, not tools like qemu-img)
08fb77ed
SW
1793 --block-drv-ro-whitelist=L
1794 set block driver read-only whitelist
e5f05f8c
KW
1795 (by default affects only QEMU, not tools like qemu-img)
1796 --enable-block-drv-whitelist-in-tools
1797 use block whitelist also in tools instead of only QEMU
5b808275 1798 --enable-trace-backends=B Set trace backend
c53eeaf7 1799 Available backends: $trace_backend_list
08fb77ed
SW
1800 --with-trace-file=NAME Full PATH,NAME of file to store traces
1801 Default:trace-<pid>
c23f23b9 1802 --disable-slirp disable SLIRP userspace network connectivity
e9a16e38 1803 --enable-tcg-interpreter enable TCI (TCG with bytecode interpreter, experimental and slow)
5a22ab71 1804 --enable-malloc-trim enable libc malloc_trim() for memory optimization
c23f23b9 1805 --cpu=CPU Build for host CPU [$cpu]
08fb77ed 1806 --with-coroutine=BACKEND coroutine backend. Supported options:
33c53c54 1807 ucontext, sigaltstack, windows
08fb77ed 1808 --enable-gcov enable test coverage analysis with gcov
c23f23b9
MT
1809 --disable-blobs disable installing provided firmware blobs
1810 --with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent
1811 --with-win-sdk=SDK-path path to Windows Platform SDK (to build VSS .tlb)
a1c5e949 1812 --tls-priority default TLS protocol/cipher priority string
c12d66aa
LM
1813 --enable-gprof QEMU profiling with gprof
1814 --enable-profiler profiler support
c12d66aa
LM
1815 --enable-debug-stack-usage
1816 track the maximum stack usage of stacks created by qemu_alloc_stack
40e8c6f4
AB
1817 --enable-plugins
1818 enable plugins via shared library loading
afc3a8f9 1819 --disable-containers don't use containers for cross-building
f48e590a 1820 --gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin]
61d63097
PB
1821EOF
1822 meson_options_help
1823cat << EOF
c23f23b9
MT
1824 system all system emulation targets
1825 user supported user emulation targets
1826 linux-user all linux usermode emulation targets
1827 bsd-user all BSD usermode emulation targets
c23f23b9
MT
1828 docs build documentation
1829 guest-agent build the QEMU Guest Agent
1830 guest-agent-msi build guest agent Windows MSI installation package
1831 pie Position Independent Executables
21e709aa 1832 modules modules support (non-Windows)
bd83c861 1833 module-upgrades try to load modules from alternate paths for upgrades
c23f23b9
MT
1834 debug-tcg TCG debugging (default is disabled)
1835 debug-info debugging information
cdad781d 1836 lto Enable Link-Time Optimization.
c23f23b9 1837 sparse sparse checker
1e4f6065
DB
1838 safe-stack SafeStack Stack Smash Protection. Depends on
1839 clang/llvm >= 3.7 and requires coroutine backend ucontext.
9e62ba48
DB
1840 cfi Enable Control-Flow Integrity for indirect function calls.
1841 In case of a cfi violation, QEMU is terminated with SIGILL
1842 Depends on lto and is incompatible with modules
1843 Automatically enables Link-Time Optimization (lto)
1844 cfi-debug In case of a cfi violation, a message containing the line that
1845 triggered the error is written to stderr. After the error,
1846 QEMU is still terminated with SIGILL
ddbb0d09 1847 gnutls GNUTLS cryptography support
91bfcdb0
DB
1848 nettle nettle cryptography support
1849 gcrypt libgcrypt cryptography support
8953caf3 1850 auth-pam PAM access control
c23f23b9 1851 sdl SDL UI
04c6e16f 1852 sdl-image SDL Image support for icons
c23f23b9 1853 gtk gtk UI
c23f23b9
MT
1854 vte vte support for the gtk UI
1855 curses curses UI
e08bb301 1856 iconv font glyph conversion support
c23f23b9 1857 vnc VNC UI support
c23f23b9
MT
1858 vnc-sasl SASL encryption for VNC server
1859 vnc-jpeg JPEG lossy compression for VNC server
1860 vnc-png PNG compression for VNC server
c23f23b9
MT
1861 cocoa Cocoa UI (Mac OS X only)
1862 virtfs VirtFS
cece116c 1863 virtiofsd build virtiofs daemon (virtiofsd)
5c53015a 1864 libudev Use libudev to enumerate host devices
fe8fc5ae 1865 mpath Multipath persistent reservation passthrough
c23f23b9 1866 xen xen backend driver support
70c292af 1867 xen-pci-passthrough PCI passthrough support for Xen
ca50e523
PB
1868 alsa ALSA sound support
1869 coreaudio CoreAudio sound support
1870 dsound DirectSound sound support
1871 jack JACK sound support
1872 oss OSS sound support
1873 pa PulseAudio sound support
c23f23b9
MT
1874 brlapi BrlAPI (Braile)
1875 curl curl connectivity
a40161cb 1876 membarrier membarrier system call (for Linux 4.14+ or Windows)
c23f23b9 1877 fdt fdt device tree
c23f23b9 1878 kvm KVM acceleration support
b0cb0a66 1879 hax HAX acceleration support
c97d6d2c 1880 hvf Hypervisor.framework acceleration support
74a414a1 1881 nvmm NVMM acceleration support
d661d9a4 1882 whpx Windows Hypervisor Platform acceleration support
21ab34c9
MA
1883 rdma Enable RDMA-based migration
1884 pvrdma Enable PVRDMA support
c23f23b9
MT
1885 vde support for vde network
1886 netmap support for netmap network
1887 linux-aio Linux AIO support
c10dd856 1888 linux-io-uring Linux io_uring support
c23f23b9
MT
1889 cap-ng libcap-ng support
1890 attr attr and xattr support
299e6f19
PB
1891 vhost-net vhost-net kernel acceleration support
1892 vhost-vsock virtio sockets device support
1893 vhost-scsi vhost-scsi kernel target support
1894 vhost-crypto vhost-user-crypto backend support
1895 vhost-kernel vhost kernel backend support
1896 vhost-user vhost-user backend support
bc15e44c 1897 vhost-user-blk-server vhost-user-blk server support
108a6481 1898 vhost-vdpa vhost-vdpa kernel backend support
46627f41 1899 bpf BPF kernel support
c23f23b9 1900 spice spice
58d3f3ff 1901 spice-protocol spice-protocol
c23f23b9
MT
1902 rbd rados block device (rbd)
1903 libiscsi iscsi support
1904 libnfs nfs support
7b02f544 1905 smartcard smartcard support (libcacard)
0a40bcb7 1906 u2f U2F support (u2f-emu)
c23f23b9 1907 libusb libusb (for usb passthrough)
ed1701c6 1908 live-block-migration Block migration in the main migration stream
c23f23b9
MT
1909 usb-redir usb network redirection support
1910 lzo support of lzo compression library
1911 snappy support of snappy compression library
1912 bzip2 support of bzip2 compression library
1913 (for reading bzip2-compressed dmg images)
83bc1f97
JF
1914 lzfse support of lzfse compression library
1915 (for reading lzfse-compressed dmg images)
3a678481 1916 zstd support for zstd compression library
d298ac10 1917 (for migration compression and qcow2 cluster compression)
c23f23b9
MT
1918 seccomp seccomp support
1919 coroutine-pool coroutine freelist (better performance)
1920 glusterfs GlusterFS backend
c23f23b9 1921 tpm TPM support
b10d49d7 1922 libssh ssh block device support
c23f23b9 1923 numa libnuma support
ed279a06 1924 libxml2 for Parallels image format
c23f23b9 1925 tcmalloc tcmalloc support
7b01cb97 1926 jemalloc jemalloc support
86583a07 1927 avx2 AVX2 optimization support
6b8cd447 1928 avx512f AVX512F optimization support
a6b1d4c0 1929 replication replication support
c12d66aa
LM
1930 opengl opengl support
1931 virglrenderer virgl rendering support
1932 xfsctl xfsctl support
1933 qom-cast-debug cast debugging support
8de73fa8 1934 tools build qemu-io, qemu-nbd and qemu-img tools
2f740136
JC
1935 bochs bochs image format support
1936 cloop cloop image format support
1937 dmg dmg image format support
1938 qcow1 qcow v1 image format support
1939 vdi vdi image format support
1940 vvfat vvfat image format support
1941 qed qed image format support
1942 parallels parallels image format support
f0d92b56 1943 crypto-afalg Linux AF_ALG crypto backend driver
8ca80760 1944 capstone capstone disassembler support
ba59fb77 1945 debug-mutex mutex debugging support
17824406 1946 libpmem libpmem support
75411919 1947 xkbcommon xkbcommon support
b767d257 1948 rng-none dummy RNG, avoid using /dev/(u)random and getrandom()
21b2eca6 1949 libdaxctl libdaxctl support
a484a719 1950 fuse FUSE block device export
df4ea709 1951 fuse-lseek SEEK_HOLE/SEEK_DATA support for FUSE exports
106ad1f9 1952 multiprocess Out of process device emulation support
20cf7b8e 1953 gio libgio support
b8e0c493 1954 slirp-smbd use smbd (at path --smbd=*) in slirp networking
08fb77ed
SW
1955
1956NOTE: The object files are built at the place where configure is launched
af5db58e 1957EOF
2d2ad6d0 1958exit 0
af5db58e
PB
1959fi
1960
9c790242 1961# Remove old dependency files to make sure that they get properly regenerated
bb768f71 1962rm -f */config-devices.mak.d
9c790242 1963
faf44142
DB
1964if test -z "$python"
1965then
1966 error_exit "Python not found. Use --python=/path/to/python"
c53eeaf7 1967fi
8e2c76bd
RB
1968if ! has "$make"
1969then
1970 error_exit "GNU make ($make) not found"
1971fi
c53eeaf7
SH
1972
1973# Note that if the Python conditional here evaluates True we will exit
1974# with status 1 which is a shell 'false' value.
1b11f28d
TH
1975if ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then
1976 error_exit "Cannot use '$python', Python >= 3.6 is required." \
c53eeaf7
SH
1977 "Use --python=/path/to/python to specify a supported Python."
1978fi
1979
755ee70f 1980# Preserve python version since some functionality is dependent on it
406ab2f3 1981python_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 1982
c53eeaf7
SH
1983# Suppress writing compiled files
1984python="$python -B"
1985
0a01d76f 1986if test -z "$meson"; then
654d6b04 1987 if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.59.2; then
0a01d76f 1988 meson=meson
7d7dbf9d 1989 elif test $git_submodules_action != 'ignore' ; then
0a01d76f
MAL
1990 meson=git
1991 elif test -e "${source_path}/meson/meson.py" ; then
1992 meson=internal
1993 else
1994 if test "$explicit_python" = yes; then
1995 error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found."
1996 else
1997 error_exit "Meson not found. Use --meson=/path/to/meson"
1998 fi
1999 fi
2000else
2001 # Meson uses its own Python interpreter to invoke other Python scripts,
2002 # but the user wants to use the one they specified with --python.
2003 #
2004 # We do not want to override the distro Python interpreter (and sometimes
2005 # cannot: for example in Homebrew /usr/bin/meson is a bash script), so
2006 # just require --meson=git|internal together with --python.
2007 if test "$explicit_python" = yes; then
2008 case "$meson" in
2009 git | internal) ;;
2010 *) error_exit "--python requires using QEMU's embedded Meson distribution." ;;
2011 esac
2012 fi
a5665051 2013fi
a5665051 2014
0a01d76f
MAL
2015if test "$meson" = git; then
2016 git_submodules="${git_submodules} meson"
a5665051 2017fi
0a01d76f
MAL
2018
2019case "$meson" in
2020 git | internal)
0a01d76f
MAL
2021 meson="$python ${source_path}/meson/meson.py"
2022 ;;
84ec0c24 2023 *) meson=$(command -v "$meson") ;;
0a01d76f
MAL
2024esac
2025
09e93326 2026# Probe for ninja
48328880
PB
2027
2028if test -z "$ninja"; then
2029 for c in ninja ninja-build samu; do
2030 if has $c; then
2031 ninja=$(command -v "$c")
2032 break
2033 fi
2034 done
09e93326
PB
2035 if test -z "$ninja"; then
2036 error_exit "Cannot find Ninja"
2037 fi
48328880 2038fi
a5665051 2039
9aae6e54
DHB
2040# Check that the C compiler works. Doing this here before testing
2041# the host CPU ensures that we had a valid CC to autodetect the
2042# $cpu var (and we should bail right here if that's not the case).
2043# It also allows the help message to be printed without a CC.
2044write_c_skeleton;
2045if compile_object ; then
2046 : C compiler works ok
2047else
2048 error_exit "\"$cc\" either does not exist or does not work"
2049fi
2050if ! compile_prog ; then
2051 error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
2052fi
2053
9c83ffd8
PM
2054# Consult white-list to determine whether to enable werror
2055# by default. Only enable by default for git builds
9c83ffd8 2056if test -z "$werror" ; then
7d7dbf9d 2057 if test "$git_submodules_action" != "ignore" && \
e633a5c6 2058 { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
9c83ffd8
PM
2059 werror="yes"
2060 else
2061 werror="no"
2062 fi
2063fi
2064
975ff037 2065if test "$targetos" = "bogus"; then
fb59dabd
PM
2066 # Now that we know that we're not printing the help and that
2067 # the compiler works (so the results of the check_defines we used
2068 # to identify the OS are reliable), if we didn't recognize the
2069 # host OS we should stop now.
951fedfc 2070 error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
fb59dabd
PM
2071fi
2072
efc6c070
TH
2073# Check whether the compiler matches our minimum requirements:
2074cat > $TMPC << EOF
2075#if defined(__clang_major__) && defined(__clang_minor__)
2076# ifdef __apple_build_version__
2a85a08c
DB
2077# if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0)
2078# error You need at least XCode Clang v10.0 to compile QEMU
efc6c070
TH
2079# endif
2080# else
2a85a08c
DB
2081# if __clang_major__ < 6 || (__clang_major__ == 6 && __clang_minor__ < 0)
2082# error You need at least Clang v6.0 to compile QEMU
efc6c070
TH
2083# endif
2084# endif
2085#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
3830df5f 2086# if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4)
2087# error You need at least GCC v7.4.0 to compile QEMU
efc6c070
TH
2088# endif
2089#else
2090# error You either need GCC or Clang to compiler QEMU
2091#endif
2092int main (void) { return 0; }
2093EOF
2094if ! compile_prog "" "" ; then
3830df5f 2095 error_exit "You need at least GCC v7.4 or Clang v6.0 (or XCode Clang v10.0)"
efc6c070
TH
2096fi
2097
00849b92
RH
2098# Accumulate -Wfoo and -Wno-bar separately.
2099# We will list all of the enable flags first, and the disable flags second.
2100# Note that we do not add -Werror, because that would enable it for all
2101# configure tests. If a configure test failed due to -Werror this would
2102# just silently disable some features, so it's too error prone.
2103
2104warn_flags=
2105add_to warn_flags -Wold-style-declaration
2106add_to warn_flags -Wold-style-definition
2107add_to warn_flags -Wtype-limits
2108add_to warn_flags -Wformat-security
2109add_to warn_flags -Wformat-y2k
2110add_to warn_flags -Winit-self
2111add_to warn_flags -Wignored-qualifiers
2112add_to warn_flags -Wempty-body
2113add_to warn_flags -Wnested-externs
2114add_to warn_flags -Wendif-labels
2115add_to warn_flags -Wexpansion-to-defined
0a2ebce9 2116add_to warn_flags -Wimplicit-fallthrough=2
00849b92
RH
2117
2118nowarn_flags=
2119add_to nowarn_flags -Wno-initializer-overrides
2120add_to nowarn_flags -Wno-missing-include-dirs
2121add_to nowarn_flags -Wno-shift-negative-value
2122add_to nowarn_flags -Wno-string-plus-int
2123add_to nowarn_flags -Wno-typedef-redefinition
aabab967 2124add_to nowarn_flags -Wno-tautological-type-limit-compare
bac8d222 2125add_to nowarn_flags -Wno-psabi
00849b92
RH
2126
2127gcc_flags="$warn_flags $nowarn_flags"
93b25869
JS
2128
2129cc_has_warning_flag() {
2130 write_c_skeleton;
2131
a1d29d6c
PM
2132 # Use the positive sense of the flag when testing for -Wno-wombat
2133 # support (gcc will happily accept the -Wno- form of unknown
2134 # warning options).
93b25869
JS
2135 optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
2136 compile_prog "-Werror $optflag" ""
2137}
2138
2139for flag in $gcc_flags; do
2140 if cc_has_warning_flag $flag ; then
2141 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
8d05095c
PB
2142 fi
2143done
2144
3b463a3f 2145if test "$stack_protector" != "no"; then
fccd35a0
RR
2146 cat > $TMPC << EOF
2147int main(int argc, char *argv[])
2148{
2149 char arr[64], *p = arr, *c = argv[0];
2150 while (*c) {
2151 *p++ = *c++;
2152 }
2153 return 0;
2154}
2155EOF
63678e17 2156 gcc_flags="-fstack-protector-strong -fstack-protector-all"
3b463a3f 2157 sp_on=0
63678e17 2158 for flag in $gcc_flags; do
590e5dd9
PM
2159 # We need to check both a compile and a link, since some compiler
2160 # setups fail only on a .c->.o compile and some only at link time
086d5f75 2161 if compile_object "-Werror $flag" &&
590e5dd9 2162 compile_prog "-Werror $flag" ""; then
63678e17 2163 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
db5adeaa 2164 QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
3b463a3f 2165 sp_on=1
63678e17
SN
2166 break
2167 fi
2168 done
3b463a3f
MR
2169 if test "$stack_protector" = yes; then
2170 if test $sp_on = 0; then
2171 error_exit "Stack protector not supported"
2172 fi
2173 fi
37746c5e
MAL
2174fi
2175
20bc94a2
PB
2176# Disable -Wmissing-braces on older compilers that warn even for
2177# the "universal" C zero initializer {0}.
2178cat > $TMPC << EOF
2179struct {
2180 int a[2];
2181} x = {0};
2182EOF
2183if compile_object "-Werror" "" ; then
2184 :
2185else
2186 QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
2187fi
2188
21e709aa
MAL
2189# Our module code doesn't support Windows
2190if test "$modules" = "yes" && test "$mingw32" = "yes" ; then
2191 error_exit "Modules are not available for Windows"
2192fi
2193
bd83c861
CE
2194# module_upgrades is only reasonable if modules are enabled
2195if test "$modules" = "no" && test "$module_upgrades" = "yes" ; then
2196 error_exit "Can't enable module-upgrades as Modules are not enabled"
2197fi
2198
5f2453ac 2199# Static linking is not possible with plugins, modules or PIE
40d6444e 2200if test "$static" = "yes" ; then
aa0d1f44
PB
2201 if test "$modules" = "yes" ; then
2202 error_exit "static and modules are mutually incompatible"
2203 fi
5f2453ac
AB
2204 if test "$plugins" = "yes"; then
2205 error_exit "static and plugins are mutually incompatible"
ba4dd2aa
AB
2206 else
2207 plugins="no"
5f2453ac 2208 fi
40d6444e
AK
2209fi
2210
768b7855
EC
2211# Unconditional check for compiler __thread support
2212 cat > $TMPC << EOF
2213static __thread int tls_var;
2214int main(void) { return tls_var; }
2215EOF
2216
2217if ! compile_prog "-Werror" "" ; then
2218 error_exit "Your compiler does not support the __thread specifier for " \
2219 "Thread-Local Storage (TLS). Please upgrade to a version that does."
2220fi
2221
b2634124 2222cat > $TMPC << EOF
21d4a791
AK
2223
2224#ifdef __linux__
2225# define THREAD __thread
2226#else
2227# define THREAD
2228#endif
21d4a791 2229static THREAD int tls_var;
21d4a791 2230int main(void) { return tls_var; }
40d6444e 2231EOF
412aeacd 2232
b2634124
RH
2233# Check we support --no-pie first; we will need this for building ROMs.
2234if compile_prog "-Werror -fno-pie" "-no-pie"; then
2235 CFLAGS_NOPIE="-fno-pie"
b2634124
RH
2236fi
2237
12781462 2238if test "$static" = "yes"; then
eca7a8e6 2239 if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then
5770e8af 2240 CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
12781462
RH
2241 QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS"
2242 pie="yes"
2243 elif test "$pie" = "yes"; then
2244 error_exit "-static-pie not available due to missing toolchain support"
2245 else
2246 QEMU_LDFLAGS="-static $QEMU_LDFLAGS"
2247 pie="no"
2248 fi
2249elif test "$pie" = "no"; then
5770e8af 2250 CONFIGURE_CFLAGS="$CFLAGS_NOPIE $CONFIGURE_CFLAGS"
eca7a8e6 2251elif compile_prog "-Werror -fPIE -DPIE" "-pie"; then
5770e8af
PB
2252 CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
2253 CONFIGURE_LDFLAGS="-pie $CONFIGURE_LDFLAGS"
2c674109
RH
2254 pie="yes"
2255elif test "$pie" = "yes"; then
2256 error_exit "PIE not available due to missing toolchain support"
2257else
2258 echo "Disabling PIE due to missing toolchain support"
2259 pie="no"
40d6444e
AK
2260fi
2261
e6cbd751
RH
2262# Detect support for PT_GNU_RELRO + DT_BIND_NOW.
2263# The combination is known as "full relro", because .got.plt is read-only too.
2264if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
2265 QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS"
2266fi
2267
09dada40
PB
2268##########################################
2269# __sync_fetch_and_and requires at least -march=i486. Many toolchains
2270# use i686 as default anyway, but for those that don't, an explicit
2271# specification is necessary
2272
2273if test "$cpu" = "i386"; then
2274 cat > $TMPC << EOF
2275static int sfaa(int *ptr)
2276{
2277 return __sync_fetch_and_and(ptr, 0);
2278}
2279
2280int main(void)
2281{
2282 int val = 42;
1405b629 2283 val = __sync_val_compare_and_swap(&val, 0, 1);
09dada40
PB
2284 sfaa(&val);
2285 return val;
2286}
2287EOF
2288 if ! compile_prog "" "" ; then
2289 QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
2290 fi
2291fi
2292
56267b62
PMD
2293if test "$tcg" = "enabled"; then
2294 git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
2295 git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
2296fi
2297
afb63ebd 2298if test -z "${target_list+xxx}" ; then
fdb75aef 2299 default_targets=yes
d880a3ba 2300 for target in $default_target_list; do
fdb75aef 2301 target_list="$target_list $target"
d880a3ba
PB
2302 done
2303 target_list="${target_list# }"
121afa9e 2304else
fdb75aef 2305 default_targets=no
89138857 2306 target_list=$(echo "$target_list" | sed -e 's/,/ /g')
d880a3ba
PB
2307 for target in $target_list; do
2308 # Check that we recognised the target name; this allows a more
2309 # friendly error message than if we let it fall through.
2310 case " $default_target_list " in
2311 *" $target "*)
2312 ;;
2313 *)
2314 error_exit "Unknown target name '$target'"
2315 ;;
2316 esac
d880a3ba 2317 done
121afa9e 2318fi
25b48338 2319
fdb75aef
PB
2320for target in $target_list; do
2321 # if a deprecated target is enabled we note it here
2322 if echo "$deprecated_targets_list" | grep -q "$target"; then
2323 add_to deprecated_features $target
2324 fi
2325done
2326
f55fe278
PB
2327# see if system emulation was really requested
2328case " $target_list " in
2329 *"-softmmu "*) softmmu=yes
2330 ;;
2331 *) softmmu=no
2332 ;;
2333esac
5327cf48 2334
249247c9
JQ
2335feature_not_found() {
2336 feature=$1
21684af0 2337 remedy=$2
249247c9 2338
76ad07a4 2339 error_exit "User requested feature $feature" \
21684af0
SS
2340 "configure was not able to find it." \
2341 "$remedy"
249247c9
JQ
2342}
2343
7d13299d
FB
2344# ---
2345# big/little endian test
2346cat > $TMPC << EOF
659eb157 2347#include <stdio.h>
61cc919f
MF
2348short big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
2349short little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
659eb157
TH
2350int main(int argc, char *argv[])
2351{
2352 return printf("%s %s\n", (char *)big_endian, (char *)little_endian);
7d13299d
FB
2353}
2354EOF
2355
659eb157
TH
2356if compile_prog ; then
2357 if strings -a $TMPE | grep -q BiGeNdIaN ; then
61cc919f 2358 bigendian="yes"
659eb157 2359 elif strings -a $TMPE | grep -q LiTtLeEnDiAn ; then
61cc919f
MF
2360 bigendian="no"
2361 else
2362 echo big/little test failed
659eb157 2363 exit 1
21d89f84 2364 fi
61cc919f
MF
2365else
2366 echo big/little test failed
659eb157 2367 exit 1
7d13299d
FB
2368fi
2369
e10ee3f5
PMD
2370##########################################
2371# system tools
2372if test -z "$want_tools"; then
2373 if test "$softmmu" = "no"; then
2374 want_tools=no
2375 else
2376 want_tools=yes
2377 fi
2378fi
2379
015a33bd
GA
2380##########################################
2381# L2TPV3 probe
2382
2383cat > $TMPC <<EOF
2384#include <sys/socket.h>
bff6cb72 2385#include <linux/ip.h>
015a33bd
GA
2386int main(void) { return sizeof(struct mmsghdr); }
2387EOF
2388if compile_prog "" "" ; then
2389 l2tpv3=yes
2390else
2391 l2tpv3=no
2392fi
2393
299e6f19
PB
2394#########################################
2395# vhost interdependencies and host support
2396
2397# vhost backends
d88618f7
SH
2398if test "$vhost_user" = "yes" && test "$linux" != "yes"; then
2399 error_exit "vhost-user is only available on Linux"
299e6f19 2400fi
108a6481
CL
2401test "$vhost_vdpa" = "" && vhost_vdpa=$linux
2402if test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then
2403 error_exit "vhost-vdpa is only available on Linux"
2404fi
299e6f19
PB
2405test "$vhost_kernel" = "" && vhost_kernel=$linux
2406if test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then
2407 error_exit "vhost-kernel is only available on Linux"
2408fi
2409
2410# vhost-kernel devices
2411test "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel
2412if test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then
2413 error_exit "--enable-vhost-scsi requires --enable-vhost-kernel"
2414fi
2415test "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel
2416if test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then
2417 error_exit "--enable-vhost-vsock requires --enable-vhost-kernel"
2418fi
2419
2420# vhost-user backends
2421test "$vhost_net_user" = "" && vhost_net_user=$vhost_user
2422if test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then
2423 error_exit "--enable-vhost-net-user requires --enable-vhost-user"
2424fi
2425test "$vhost_crypto" = "" && vhost_crypto=$vhost_user
2426if test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then
2427 error_exit "--enable-vhost-crypto requires --enable-vhost-user"
2428fi
98fc1ada
DDAG
2429test "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user
2430if test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then
2431 error_exit "--enable-vhost-user-fs requires --enable-vhost-user"
2432fi
108a6481
CL
2433#vhost-vdpa backends
2434test "$vhost_net_vdpa" = "" && vhost_net_vdpa=$vhost_vdpa
2435if test "$vhost_net_vdpa" = "yes" && test "$vhost_vdpa" = "no"; then
2436 error_exit "--enable-vhost-net-vdpa requires --enable-vhost-vdpa"
2437fi
299e6f19 2438
40bc0ca9 2439# OR the vhost-kernel, vhost-vdpa and vhost-user values for simplicity
299e6f19
PB
2440if test "$vhost_net" = ""; then
2441 test "$vhost_net_user" = "yes" && vhost_net=yes
40bc0ca9 2442 test "$vhost_net_vdpa" = "yes" && vhost_net=yes
299e6f19
PB
2443 test "$vhost_kernel" = "yes" && vhost_net=yes
2444fi
2445
779ab5e3
SW
2446##########################################
2447# pkg-config probe
2448
2449if ! has "$pkg_config_exe"; then
76ad07a4 2450 error_exit "pkg-config binary '$pkg_config_exe' not found"
779ab5e3
SW
2451fi
2452
b0a47e79
JQ
2453##########################################
2454# NPTL probe
2455
24cb36a6 2456if test "$linux_user" = "yes"; then
b0a47e79 2457 cat > $TMPC <<EOF
bd0c5661 2458#include <sched.h>
30813cea 2459#include <linux/futex.h>
182eacc0 2460int main(void) {
bd0c5661
PB
2461#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
2462#error bork
2463#endif
182eacc0 2464 return 0;
bd0c5661
PB
2465}
2466EOF
24cb36a6 2467 if ! compile_object ; then
21684af0 2468 feature_not_found "nptl" "Install glibc and linux kernel headers."
b0a47e79 2469 fi
bd0c5661
PB
2470fi
2471
e37630ca
AL
2472##########################################
2473# xen probe
2474
1badb709 2475if test "$xen" != "disabled" ; then
c1cdd9d5
JG
2476 # Check whether Xen library path is specified via --extra-ldflags to avoid
2477 # overriding this setting with pkg-config output. If not, try pkg-config
2478 # to obtain all needed flags.
2479
2480 if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2481 $pkg_config --exists xencontrol ; then
2482 xen_ctrl_version="$(printf '%d%02d%02d' \
2483 $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
1badb709 2484 xen=enabled
5b6a8f43 2485 xen_pc="xencontrol xenstore xenforeignmemory xengnttab"
c1cdd9d5 2486 xen_pc="$xen_pc xenevtchn xendevicemodel"
58ea9a7a
AP
2487 if $pkg_config --exists xentoolcore; then
2488 xen_pc="$xen_pc xentoolcore"
2489 fi
582ea95f
MAL
2490 xen_cflags="$($pkg_config --cflags $xen_pc)"
2491 xen_libs="$($pkg_config --libs $xen_pc)"
c1cdd9d5 2492 else
d5b93ddf 2493
5b6a8f43 2494 xen_libs="-lxenstore -lxenctrl"
d9506cab 2495 xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
50ced5b3 2496
c1cdd9d5
JG
2497 # First we test whether Xen headers and libraries are available.
2498 # If no, we are done and there is no Xen support.
2499 # If yes, more tests are run to detect the Xen version.
2500
2501 # Xen (any)
2502 cat > $TMPC <<EOF
e37630ca 2503#include <xenctrl.h>
50ced5b3
SW
2504int main(void) {
2505 return 0;
2506}
2507EOF
c1cdd9d5
JG
2508 if ! compile_prog "" "$xen_libs" ; then
2509 # Xen not found
1badb709 2510 if test "$xen" = "enabled" ; then
c1cdd9d5
JG
2511 feature_not_found "xen" "Install xen devel"
2512 fi
1badb709 2513 xen=disabled
50ced5b3 2514
c1cdd9d5
JG
2515 # Xen unstable
2516 elif
2517 cat > $TMPC <<EOF &&
2cbf8903
RL
2518#undef XC_WANT_COMPAT_DEVICEMODEL_API
2519#define __XEN_TOOLS__
2520#include <xendevicemodel.h>
d3c49ebb 2521#include <xenforeignmemory.h>
2cbf8903
RL
2522int main(void) {
2523 xendevicemodel_handle *xd;
d3c49ebb 2524 xenforeignmemory_handle *xfmem;
2cbf8903
RL
2525
2526 xd = xendevicemodel_open(0, 0);
2527 xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
2528
d3c49ebb
PD
2529 xfmem = xenforeignmemory_open(0, 0);
2530 xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
2531
2cbf8903
RL
2532 return 0;
2533}
2534EOF
2535 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
2536 then
2537 xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
2538 xen_ctrl_version=41100
1badb709 2539 xen=enabled
2cbf8903
RL
2540 elif
2541 cat > $TMPC <<EOF &&
5ba3d756
ID
2542#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2543#include <xenforeignmemory.h>
58ea9a7a 2544#include <xentoolcore.h>
5ba3d756
ID
2545int main(void) {
2546 xenforeignmemory_handle *xfmem;
2547
2548 xfmem = xenforeignmemory_open(0, 0);
2549 xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
58ea9a7a 2550 xentoolcore_restrict_all(0);
5ba3d756
ID
2551
2552 return 0;
2553}
2554EOF
58ea9a7a 2555 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
5ba3d756 2556 then
58ea9a7a 2557 xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
5ba3d756 2558 xen_ctrl_version=41000
1badb709 2559 xen=enabled
5ba3d756
ID
2560 elif
2561 cat > $TMPC <<EOF &&
da8090cc
PD
2562#undef XC_WANT_COMPAT_DEVICEMODEL_API
2563#define __XEN_TOOLS__
2564#include <xendevicemodel.h>
2565int main(void) {
2566 xendevicemodel_handle *xd;
2567
2568 xd = xendevicemodel_open(0, 0);
2569 xendevicemodel_close(xd);
50ced5b3 2570
da8090cc
PD
2571 return 0;
2572}
2573EOF
c1cdd9d5
JG
2574 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2575 then
2576 xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2577 xen_ctrl_version=40900
1badb709 2578 xen=enabled
c1cdd9d5
JG
2579 elif
2580 cat > $TMPC <<EOF &&
b6eb9b45
PS
2581/*
2582 * If we have stable libs the we don't want the libxc compat
2583 * layers, regardless of what CFLAGS we may have been given.
2584 *
2585 * Also, check if xengnttab_grant_copy_segment_t is defined and
2586 * grant copy operation is implemented.
2587 */
2588#undef XC_WANT_COMPAT_EVTCHN_API
2589#undef XC_WANT_COMPAT_GNTTAB_API
2590#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2591#include <xenctrl.h>
2592#include <xenstore.h>
2593#include <xenevtchn.h>
2594#include <xengnttab.h>
2595#include <xenforeignmemory.h>
2596#include <stdint.h>
2597#include <xen/hvm/hvm_info_table.h>
2598#if !defined(HVM_MAX_VCPUS)
2599# error HVM_MAX_VCPUS not defined
2600#endif
2601int main(void) {
2602 xc_interface *xc = NULL;
2603 xenforeignmemory_handle *xfmem;
2604 xenevtchn_handle *xe;
2605 xengnttab_handle *xg;
b6eb9b45
PS
2606 xengnttab_grant_copy_segment_t* seg = NULL;
2607
2608 xs_daemon_open();
2609
2610 xc = xc_interface_open(0, 0, 0);
2611 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2612 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2613 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2614 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
b6eb9b45
PS
2615
2616 xfmem = xenforeignmemory_open(0, 0);
2617 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2618
2619 xe = xenevtchn_open(0, 0);
2620 xenevtchn_fd(xe);
2621
2622 xg = xengnttab_open(0, 0);
2623 xengnttab_grant_copy(xg, 0, seg);
2624
2625 return 0;
2626}
2627EOF
c1cdd9d5
JG
2628 compile_prog "" "$xen_libs $xen_stable_libs"
2629 then
2630 xen_ctrl_version=40800
1badb709 2631 xen=enabled
c1cdd9d5
JG
2632 elif
2633 cat > $TMPC <<EOF &&
5eeb39c2
IC
2634/*
2635 * If we have stable libs the we don't want the libxc compat
2636 * layers, regardless of what CFLAGS we may have been given.
2637 */
2638#undef XC_WANT_COMPAT_EVTCHN_API
2639#undef XC_WANT_COMPAT_GNTTAB_API
2640#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2641#include <xenctrl.h>
2642#include <xenstore.h>
2643#include <xenevtchn.h>
2644#include <xengnttab.h>
2645#include <xenforeignmemory.h>
2646#include <stdint.h>
2647#include <xen/hvm/hvm_info_table.h>
2648#if !defined(HVM_MAX_VCPUS)
2649# error HVM_MAX_VCPUS not defined
2650#endif
2651int main(void) {
2652 xc_interface *xc = NULL;
2653 xenforeignmemory_handle *xfmem;
2654 xenevtchn_handle *xe;
2655 xengnttab_handle *xg;
5eeb39c2
IC
2656
2657 xs_daemon_open();
2658
2659 xc = xc_interface_open(0, 0, 0);
2660 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2661 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2662 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2663 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
5eeb39c2
IC
2664
2665 xfmem = xenforeignmemory_open(0, 0);
2666 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2667
2668 xe = xenevtchn_open(0, 0);
2669 xenevtchn_fd(xe);
2670
2671 xg = xengnttab_open(0, 0);
2672 xengnttab_map_grant_ref(xg, 0, 0, 0);
2673
2674 return 0;
2675}
2676EOF
c1cdd9d5
JG
2677 compile_prog "" "$xen_libs $xen_stable_libs"
2678 then
2679 xen_ctrl_version=40701
1badb709 2680 xen=enabled
c1cdd9d5
JG
2681
2682 # Xen 4.6
2683 elif
2684 cat > $TMPC <<EOF &&
cdadde39 2685#include <xenctrl.h>
e108a3c1 2686#include <xenstore.h>
d5b93ddf
AP
2687#include <stdint.h>
2688#include <xen/hvm/hvm_info_table.h>
2689#if !defined(HVM_MAX_VCPUS)
2690# error HVM_MAX_VCPUS not defined
2691#endif
d8b441a3
JB
2692int main(void) {
2693 xc_interface *xc;
2694 xs_daemon_open();
2695 xc = xc_interface_open(0, 0, 0);
2696 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2697 xc_gnttab_open(NULL, 0);
2698 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2699 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2700 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
20a544c7 2701 xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
d8b441a3
JB
2702 return 0;
2703}
2704EOF
c1cdd9d5
JG
2705 compile_prog "" "$xen_libs"
2706 then
2707 xen_ctrl_version=40600
1badb709 2708 xen=enabled
c1cdd9d5
JG
2709
2710 # Xen 4.5
2711 elif
2712 cat > $TMPC <<EOF &&
d8b441a3
JB
2713#include <xenctrl.h>
2714#include <xenstore.h>
2715#include <stdint.h>
2716#include <xen/hvm/hvm_info_table.h>
2717#if !defined(HVM_MAX_VCPUS)
2718# error HVM_MAX_VCPUS not defined
2719#endif
3996e85c
PD
2720int main(void) {
2721 xc_interface *xc;
2722 xs_daemon_open();
2723 xc = xc_interface_open(0, 0, 0);
2724 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2725 xc_gnttab_open(NULL, 0);
2726 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2727 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2728 xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
2729 return 0;
2730}
2731EOF
c1cdd9d5
JG
2732 compile_prog "" "$xen_libs"
2733 then
2734 xen_ctrl_version=40500
1badb709 2735 xen=enabled
3996e85c 2736
c1cdd9d5
JG
2737 elif
2738 cat > $TMPC <<EOF &&
3996e85c
PD
2739#include <xenctrl.h>
2740#include <xenstore.h>
2741#include <stdint.h>
2742#include <xen/hvm/hvm_info_table.h>
2743#if !defined(HVM_MAX_VCPUS)
2744# error HVM_MAX_VCPUS not defined
2745#endif
8688e065
SS
2746int main(void) {
2747 xc_interface *xc;
2748 xs_daemon_open();
2749 xc = xc_interface_open(0, 0, 0);
2750 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2751 xc_gnttab_open(NULL, 0);
2752 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2753 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2754 return 0;
2755}
2756EOF
c1cdd9d5
JG
2757 compile_prog "" "$xen_libs"
2758 then
2759 xen_ctrl_version=40200
1badb709 2760 xen=enabled
8688e065 2761
c1cdd9d5 2762 else
1badb709 2763 if test "$xen" = "enabled" ; then
c1cdd9d5
JG
2764 feature_not_found "xen (unsupported version)" \
2765 "Install a supported xen (xen 4.2 or newer)"
2766 fi
1badb709 2767 xen=disabled
fc321b4b 2768 fi
d5b93ddf 2769
1badb709 2770 if test "$xen" = enabled; then
c1cdd9d5 2771 if test $xen_ctrl_version -ge 40701 ; then
582ea95f 2772 xen_libs="$xen_libs $xen_stable_libs "
c1cdd9d5 2773 fi
5eeb39c2 2774 fi
d5b93ddf 2775 fi
e37630ca
AL
2776fi
2777
2da776db
MH
2778##########################################
2779# RDMA needs OpenFabrics libraries
2780if test "$rdma" != "no" ; then
2781 cat > $TMPC <<EOF
2782#include <rdma/rdma_cma.h>
2783int main(void) { return 0; }
2784EOF
ef6d4ccd 2785 rdma_libs="-lrdmacm -libverbs -libumad"
2da776db
MH
2786 if compile_prog "" "$rdma_libs" ; then
2787 rdma="yes"
2da776db
MH
2788 else
2789 if test "$rdma" = "yes" ; then
2790 error_exit \
ef6d4ccd 2791 " OpenFabrics librdmacm/libibverbs/libibumad not present." \
2da776db 2792 " Your options:" \
ef6d4ccd 2793 " (1) Fast: Install infiniband packages (devel) from your distro." \
2da776db
MH
2794 " (2) Cleanest: Install libraries from www.openfabrics.org" \
2795 " (3) Also: Install softiwarp if you don't have RDMA hardware"
2796 fi
2797 rdma="no"
2798 fi
2799fi
2800
21ab34c9
MA
2801##########################################
2802# PVRDMA detection
2803
2804cat > $TMPC <<EOF &&
2805#include <sys/mman.h>
2806
2807int
2808main(void)
2809{
2810 char buf = 0;
2811 void *addr = &buf;
2812 addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED);
2813
2814 return 0;
2815}
2816EOF
2817
2818if test "$rdma" = "yes" ; then
2819 case "$pvrdma" in
2820 "")
2821 if compile_prog "" ""; then
2822 pvrdma="yes"
2823 else
2824 pvrdma="no"
2825 fi
2826 ;;
2827 "yes")
2828 if ! compile_prog "" ""; then
2829 error_exit "PVRDMA is not supported since mremap is not implemented"
2830 fi
2831 pvrdma="yes"
2832 ;;
2833 "no")
2834 pvrdma="no"
2835 ;;
2836 esac
2837else
2838 if test "$pvrdma" = "yes" ; then
2839 error_exit "PVRDMA requires rdma suppport"
2840 fi
2841 pvrdma="no"
2842fi
95c6bff3 2843
ee108585
YS
2844# Let's see if enhanced reg_mr is supported
2845if test "$pvrdma" = "yes" ; then
2846
2847cat > $TMPC <<EOF &&
2848#include <infiniband/verbs.h>
2849
2850int
2851main(void)
2852{
2853 struct ibv_mr *mr;
2854 struct ibv_pd *pd = NULL;
2855 size_t length = 10;
2856 uint64_t iova = 0;
2857 int access = 0;
2858 void *addr = NULL;
2859
2860 mr = ibv_reg_mr_iova(pd, addr, length, iova, access);
2861
2862 ibv_dereg_mr(mr);
2863
2864 return 0;
2865}
2866EOF
2867 if ! compile_prog "" "-libverbs"; then
2868 QEMU_CFLAGS="$QEMU_CFLAGS -DLEGACY_RDMA_REG_MR"
2869 fi
2870fi
2871
ee682d27 2872##########################################
c1bb86cd 2873# xfsctl() probe, used for file-posix.c
dce512de
CH
2874if test "$xfs" != "no" ; then
2875 cat > $TMPC << EOF
ffc41d10 2876#include <stddef.h> /* NULL */
dce512de
CH
2877#include <xfs/xfs.h>
2878int main(void)
2879{
2880 xfsctl(NULL, 0, 0, NULL);
2881 return 0;
2882}
2883EOF
2884 if compile_prog "" "" ; then
2885 xfs="yes"
2886 else
2887 if test "$xfs" = "yes" ; then
e3a6e0da 2888 feature_not_found "xfs" "Install xfsprogs/xfslibs devel"
dce512de
CH
2889 fi
2890 xfs=no
2891 fi
2892fi
2893
ba4dd2aa
AB
2894##########################################
2895# plugin linker support probe
2896
2897if test "$plugins" != "no"; then
2898
2899 #########################################
2900 # See if --dynamic-list is supported by the linker
2901
2902 ld_dynamic_list="no"
2903 cat > $TMPTXT <<EOF
2904{
2905 foo;
2906};
2907EOF
2908
2909 cat > $TMPC <<EOF
2910#include <stdio.h>
2911void foo(void);
2912
2913void foo(void)
2914{
2915 printf("foo\n");
2916}
2917
2918int main(void)
2919{
2920 foo();
2921 return 0;
2922}
2923EOF
2924
2925 if compile_prog "" "-Wl,--dynamic-list=$TMPTXT" ; then
2926 ld_dynamic_list="yes"
2927 fi
2928
2929 #########################################
2930 # See if -exported_symbols_list is supported by the linker
2931
2932 ld_exported_symbols_list="no"
2933 cat > $TMPTXT <<EOF
2934 _foo
2935EOF
2936
2937 if compile_prog "" "-Wl,-exported_symbols_list,$TMPTXT" ; then
2938 ld_exported_symbols_list="yes"
2939 fi
2940
2941 if test "$ld_dynamic_list" = "no" &&
2942 test "$ld_exported_symbols_list" = "no" ; then
2943 if test "$plugins" = "yes"; then
2944 error_exit \
2945 "Plugin support requires dynamic linking and specifying a set of symbols " \
2946 "that are exported to plugins. Unfortunately your linker doesn't " \
2947 "support the flag (--dynamic-list or -exported_symbols_list) used " \
2948 "for this purpose."
2949 else
2950 plugins="no"
2951 fi
2952 else
2953 plugins="yes"
2954 fi
2955fi
2956
e18df141
AL
2957##########################################
2958# glib support probe
a52d28af 2959
b4c6036f 2960glib_req_ver=2.56
aa0d1f44
PB
2961glib_modules=gthread-2.0
2962if test "$modules" = yes; then
a88afc64 2963 glib_modules="$glib_modules gmodule-export-2.0"
b906acac
PB
2964elif test "$plugins" = "yes"; then
2965 glib_modules="$glib_modules gmodule-no-export-2.0"
54cb65d8 2966fi
e26110cf 2967
aa0d1f44 2968for i in $glib_modules; do
e26110cf 2969 if $pkg_config --atleast-version=$glib_req_ver $i; then
89138857
SW
2970 glib_cflags=$($pkg_config --cflags $i)
2971 glib_libs=$($pkg_config --libs $i)
e26110cf
FZ
2972 else
2973 error_exit "glib-$glib_req_ver $i is required to compile QEMU"
2974 fi
2975done
2976
215b0c2f
PB
2977# This workaround is required due to a bug in pkg-config file for glib as it
2978# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
2979
2980if test "$static" = yes && test "$mingw32" = yes; then
2981 glib_cflags="-DGLIB_STATIC_COMPILATION $glib_cflags"
2982fi
2983
20cf7b8e
DP
2984if ! test "$gio" = "no"; then
2985 pass=no
2986 if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
2987 gio_cflags=$($pkg_config --cflags gio-2.0)
2988 gio_libs=$($pkg_config --libs gio-2.0)
2989 gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0)
5ecfb76c 2990 if ! has "$gdbus_codegen"; then
20cf7b8e
DP
2991 gdbus_codegen=
2992 fi
2993 # Check that the libraries actually work -- Ubuntu 18.04 ships
2994 # with pkg-config --static --libs data for gio-2.0 that is missing
2995 # -lblkid and will give a link error.
2996 cat > $TMPC <<EOF
13ceae66
PM
2997#include <gio/gio.h>
2998int main(void)
2999{
3000 g_dbus_proxy_new_sync(0, 0, 0, 0, 0, 0, 0, 0);
3001 return 0;
3002}
3003EOF
20cf7b8e
DP
3004 if compile_prog "$gio_cflags" "$gio_libs" ; then
3005 pass=yes
3006 else
3007 pass=no
3008 fi
3009
3010 if test "$pass" = "yes" &&
3011 $pkg_config --atleast-version=$glib_req_ver gio-unix-2.0; then
3012 gio_cflags="$gio_cflags $($pkg_config --cflags gio-unix-2.0)"
3013 gio_libs="$gio_libs $($pkg_config --libs gio-unix-2.0)"
3014 fi
76346b62 3015 fi
f876b765 3016
20cf7b8e
DP
3017 if test "$pass" = "no"; then
3018 if test "$gio" = "yes"; then
3019 feature_not_found "gio" "Install libgio >= 2.0"
3020 else
3021 gio=no
3022 fi
3023 else
3024 gio=yes
3025 fi
25a97a56
MAL
3026fi
3027
977a82ab
DB
3028# Sanity check that the current size_t matches the
3029# size that glib thinks it should be. This catches
3030# problems on multi-arch where people try to build
3031# 32-bit QEMU while pointing at 64-bit glib headers
3032cat > $TMPC <<EOF
3033#include <glib.h>
3034#include <unistd.h>
3035
3036#define QEMU_BUILD_BUG_ON(x) \
3037 typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3038
3039int main(void) {
3040 QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3041 return 0;
3042}
3043EOF
3044
215b0c2f 3045if ! compile_prog "$glib_cflags" "$glib_libs" ; then
977a82ab
DB
3046 error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3047 "You probably need to set PKG_CONFIG_LIBDIR"\
3048 "to point to the right pkg-config files for your"\
3049 "build target"
3050fi
3051
9bda600b
EB
3052# Silence clang warnings triggered by glib < 2.57.2
3053cat > $TMPC << EOF
3054#include <glib.h>
3055typedef struct Foo {
3056 int i;
3057} Foo;
3058static void foo_free(Foo *f)
3059{
3060 g_free(f);
3061}
3062G_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free);
3063int main(void) { return 0; }
3064EOF
3065if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3066 if cc_has_warning_flag "-Wno-unused-function"; then
3067 glib_cflags="$glib_cflags -Wno-unused-function"
5770e8af 3068 CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -Wno-unused-function"
9bda600b
EB
3069 fi
3070fi
3071
e26110cf
FZ
3072##########################################
3073# SHA command probe for modules
3074if test "$modules" = yes; then
3075 shacmd_probe="sha1sum sha1 shasum"
3076 for c in $shacmd_probe; do
8ccefb91 3077 if has $c; then
e26110cf
FZ
3078 shacmd="$c"
3079 break
3080 fi
3081 done
3082 if test "$shacmd" = ""; then
3083 error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3084 fi
e18df141
AL
3085fi
3086
0a12ec87 3087##########################################
b10d49d7
PT
3088# libssh probe
3089if test "$libssh" != "no" ; then
b4c10fc6 3090 if $pkg_config --exists "libssh >= 0.8.7"; then
b10d49d7
PT
3091 libssh_cflags=$($pkg_config libssh --cflags)
3092 libssh_libs=$($pkg_config libssh --libs)
3093 libssh=yes
0a12ec87 3094 else
b10d49d7
PT
3095 if test "$libssh" = "yes" ; then
3096 error_exit "libssh required for --enable-libssh"
0a12ec87 3097 fi
b10d49d7 3098 libssh=no
0a12ec87
RJ
3099 fi
3100fi
3101
3b8acc11 3102##########################################
7aaa6a16 3103# TPM emulation is only on POSIX
3b8acc11 3104
7aaa6a16
PB
3105if test "$tpm" = ""; then
3106 if test "$mingw32" = "yes"; then
3107 tpm=no
3108 else
3109 tpm=yes
3110 fi
3111elif test "$tpm" = "yes"; then
3112 if test "$mingw32" = "yes" ; then
3113 error_exit "TPM emulation only available on POSIX systems"
3114 fi
3b8acc11
PB
3115fi
3116
f652e6af
AJ
3117##########################################
3118# fdt probe
d599938a 3119
fbb4121d
PB
3120case "$fdt" in
3121 auto | enabled | internal)
3122 # Simpler to always update submodule, even if not needed.
2d652f24 3123 git_submodules="${git_submodules} dtc"
fbb4121d
PB
3124 ;;
3125esac
f652e6af 3126
20ff075b 3127##########################################
9d49bcf6 3128# opengl probe (for sdl2, gtk)
b1546f32 3129
da076ffe 3130if test "$opengl" != "no" ; then
bc6a3565
AO
3131 epoxy=no
3132 if $pkg_config epoxy; then
3133 cat > $TMPC << EOF
3134#include <epoxy/egl.h>
3135int main(void) { return 0; }
3136EOF
3137 if compile_prog "" "" ; then
3138 epoxy=yes
3139 fi
3140 fi
3141
3142 if test "$epoxy" = "yes" ; then
3143 opengl_cflags="$($pkg_config --cflags epoxy)"
3144 opengl_libs="$($pkg_config --libs epoxy)"
da076ffe 3145 opengl=yes
20ff075b 3146 else
da076ffe 3147 if test "$opengl" = "yes" ; then
bc6a3565 3148 feature_not_found "opengl" "Please install epoxy with EGL"
20ff075b 3149 fi
f676c67e 3150 opengl_cflags=""
da076ffe
GH
3151 opengl_libs=""
3152 opengl=no
20ff075b
MW
3153 fi
3154fi
3155
a99d57bb
WG
3156##########################################
3157# libnuma probe
3158
3159if test "$numa" != "no" ; then
3160 cat > $TMPC << EOF
3161#include <numa.h>
3162int main(void) { return numa_available(); }
3163EOF
3164
3165 if compile_prog "" "-lnuma" ; then
3166 numa=yes
ab318051 3167 numa_libs="-lnuma"
a99d57bb
WG
3168 else
3169 if test "$numa" = "yes" ; then
3170 feature_not_found "numa" "install numactl devel"
3171 fi
3172 numa=no
3173 fi
3174fi
3175
aa087962 3176malloc=system
7b01cb97
AD
3177if test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
3178 echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
3179 exit 1
aa087962
PB
3180elif test "$tcmalloc" = "yes" ; then
3181 malloc=tcmalloc
3182elif test "$jemalloc" = "yes" ; then
3183 malloc=jemalloc
7b01cb97
AD
3184fi
3185
955727d2
CT
3186# check for usbfs
3187have_usbfs=no
3188if test "$linux_user" = "yes"; then
96566d09
TP
3189 cat > $TMPC << EOF
3190#include <linux/usbdevice_fs.h>
3191
3192#ifndef USBDEVFS_GET_CAPABILITIES
3193#error "USBDEVFS_GET_CAPABILITIES undefined"
3194#endif
3195
3196#ifndef USBDEVFS_DISCONNECT_CLAIM
3197#error "USBDEVFS_DISCONNECT_CLAIM undefined"
3198#endif
3199
3200int main(void)
3201{
3202 return 0;
3203}
3204EOF
3205 if compile_prog "" ""; then
955727d2
CT
3206 have_usbfs=yes
3207 fi
955727d2 3208fi
751bcc39 3209
d9840e25
TS
3210##########################################
3211# check if we have VSS SDK headers for win
3212
e633a5c6
EB
3213if test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
3214 test "$vss_win32_sdk" != "no" ; then
d9840e25 3215 case "$vss_win32_sdk" in
690604f6 3216 "") vss_win32_include="-isystem $source_path" ;;
d9840e25
TS
3217 *\ *) # The SDK is installed in "Program Files" by default, but we cannot
3218 # handle path with spaces. So we symlink the headers into ".sdk/vss".
690604f6 3219 vss_win32_include="-isystem $source_path/.sdk/vss"
d9840e25
TS
3220 symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
3221 ;;
690604f6 3222 *) vss_win32_include="-isystem $vss_win32_sdk"
d9840e25
TS
3223 esac
3224 cat > $TMPC << EOF
3225#define __MIDL_user_allocate_free_DEFINED__
3226#include <inc/win2003/vss.h>
3227int main(void) { return VSS_CTX_BACKUP; }
3228EOF
3229 if compile_prog "$vss_win32_include" "" ; then
3230 guest_agent_with_vss="yes"
3231 QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
315d3184 3232 libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
f33ca81f 3233 qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
d9840e25
TS
3234 else
3235 if test "$vss_win32_sdk" != "" ; then
3236 echo "ERROR: Please download and install Microsoft VSS SDK:"
3237 echo "ERROR: http://www.microsoft.com/en-us/download/details.aspx?id=23490"
3238 echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
3239 echo "ERROR: scripts/extract-vsssdk-headers setup.exe"
3240 echo "ERROR: The headers are extracted in the directory \`inc'."
3241 feature_not_found "VSS support"
3242 fi
3243 guest_agent_with_vss="no"
3244 fi
3245fi
3246
3247##########################################
3248# lookup Windows platform SDK (if not specified)
3249# The SDK is needed only to build .tlb (type library) file of guest agent
3250# VSS provider from the source. It is usually unnecessary because the
3251# pre-compiled .tlb file is included.
3252
e633a5c6
EB
3253if test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
3254 test "$guest_agent_with_vss" = "yes" ; then
d9840e25
TS
3255 if test -z "$win_sdk"; then
3256 programfiles="$PROGRAMFILES"
3257 test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
3258 if test -n "$programfiles"; then
3259 win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
3260 else
3261 feature_not_found "Windows SDK"
3262 fi
3263 elif test "$win_sdk" = "no"; then
3264 win_sdk=""
3265 fi
3266fi
3267
50cbebb9
MR
3268##########################################
3269# check if mingw environment provides a recent ntddscsi.h
e633a5c6 3270if test "$mingw32" = "yes" && test "$guest_agent" != "no"; then
50cbebb9
MR
3271 cat > $TMPC << EOF
3272#include <windows.h>
3273#include <ntddscsi.h>
3274int main(void) {
3275#if !defined(IOCTL_SCSI_GET_ADDRESS)
3276#error Missing required ioctl definitions
3277#endif
3278 SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
3279 return addr.Lun;
3280}
3281EOF
3282 if compile_prog "" "" ; then
3283 guest_agent_ntddscsi=yes
996b9cdc 3284 libs_qga="-lsetupapi -lcfgmgr32 $libs_qga"
50cbebb9
MR
3285 fi
3286fi
3287
8ca80760
RH
3288##########################################
3289# capstone
3290
e219c499 3291case "$capstone" in
8b18cdbf
RH
3292 auto | enabled | internal)
3293 # Simpler to always update submodule, even if not needed.
2d652f24 3294 git_submodules="${git_submodules} capstone"
e219c499
RH
3295 ;;
3296esac
8ca80760 3297
023367e6 3298##########################################
519175a2 3299# check and set a backend for coroutine
d0e2fce5 3300
7c2acc70 3301# We prefer ucontext, but it's not always possible. The fallback
33c53c54
DB
3302# is sigcontext. On Windows the only valid backend is the Windows
3303# specific one.
7c2acc70
PM
3304
3305ucontext_works=no
3306if test "$darwin" != "yes"; then
3307 cat > $TMPC << EOF
d0e2fce5 3308#include <ucontext.h>
cdf84806
PM
3309#ifdef __stub_makecontext
3310#error Ignoring glibc stub makecontext which will always fail
3311#endif
75cafad7 3312int main(void) { makecontext(0, 0, 0); return 0; }
d0e2fce5 3313EOF
7c2acc70
PM
3314 if compile_prog "" "" ; then
3315 ucontext_works=yes
3316 fi
3317fi
3318
3319if test "$coroutine" = ""; then
3320 if test "$mingw32" = "yes"; then
3321 coroutine=win32
3322 elif test "$ucontext_works" = "yes"; then
3323 coroutine=ucontext
3324 else
3325 coroutine=sigaltstack
d0e2fce5 3326 fi
519175a2 3327else
7c2acc70
PM
3328 case $coroutine in
3329 windows)
3330 if test "$mingw32" != "yes"; then
3331 error_exit "'windows' coroutine backend only valid for Windows"
3332 fi
3333 # Unfortunately the user visible backend name doesn't match the
3334 # coroutine-*.c filename for this case, so we have to adjust it here.
3335 coroutine=win32
3336 ;;
3337 ucontext)
3338 if test "$ucontext_works" != "yes"; then
3339 feature_not_found "ucontext"
3340 fi
3341 ;;
33c53c54 3342 sigaltstack)
7c2acc70
PM
3343 if test "$mingw32" = "yes"; then
3344 error_exit "only the 'windows' coroutine backend is valid for Windows"
3345 fi
3346 ;;
3347 *)
3348 error_exit "unknown coroutine backend $coroutine"
3349 ;;
3350 esac
d0e2fce5
AK
3351fi
3352
70c60c08 3353if test "$coroutine_pool" = ""; then
33c53c54 3354 coroutine_pool=yes
70c60c08
SH
3355fi
3356
7d992e4d 3357if test "$debug_stack_usage" = "yes"; then
7d992e4d
PL
3358 if test "$coroutine_pool" = "yes"; then
3359 echo "WARN: disabling coroutine pool for stack usage debugging"
3360 coroutine_pool=no
3361 fi
3362fi
3363
1e4f6065
DB
3364##################################################
3365# SafeStack
3366
3367
3368if test "$safe_stack" = "yes"; then
3369cat > $TMPC << EOF
3370int main(int argc, char *argv[])
3371{
3372#if ! __has_feature(safe_stack)
3373#error SafeStack Disabled
3374#endif
3375 return 0;
3376}
3377EOF
3378 flag="-fsanitize=safe-stack"
3379 # Check that safe-stack is supported and enabled.
3380 if compile_prog "-Werror $flag" "$flag"; then
3381 # Flag needed both at compilation and at linking
3382 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
3383 QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
3384 else
3385 error_exit "SafeStack not supported by your compiler"
3386 fi
3387 if test "$coroutine" != "ucontext"; then
3388 error_exit "SafeStack is only supported by the coroutine backend ucontext"
3389 fi
3390else
3391cat > $TMPC << EOF
3392int main(int argc, char *argv[])
3393{
3394#if defined(__has_feature)
3395#if __has_feature(safe_stack)
3396#error SafeStack Enabled
3397#endif
3398#endif
3399 return 0;
3400}
3401EOF
3402if test "$safe_stack" = "no"; then
3403 # Make sure that safe-stack is disabled
3404 if ! compile_prog "-Werror" ""; then
3405 # SafeStack was already enabled, try to explicitly remove the feature
3406 flag="-fno-sanitize=safe-stack"
3407 if ! compile_prog "-Werror $flag" "$flag"; then
3408 error_exit "Configure cannot disable SafeStack"
3409 fi
3410 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
3411 QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
3412 fi
3413else # "$safe_stack" = ""
3414 # Set safe_stack to yes or no based on pre-existing flags
3415 if compile_prog "-Werror" ""; then
3416 safe_stack="no"
3417 else
3418 safe_stack="yes"
3419 if test "$coroutine" != "ucontext"; then
3420 error_exit "SafeStack is only supported by the coroutine backend ucontext"
3421 fi
3422 fi
3423fi
3424fi
7d992e4d 3425
76a347e1
RH
3426########################################
3427# check if cpuid.h is usable.
3428
76a347e1
RH
3429cat > $TMPC << EOF
3430#include <cpuid.h>
3431int main(void) {
774d566c
PM
3432 unsigned a, b, c, d;
3433 int max = __get_cpuid_max(0, 0);
3434
3435 if (max >= 1) {
3436 __cpuid(1, a, b, c, d);
3437 }
3438
3439 if (max >= 7) {
3440 __cpuid_count(7, 0, a, b, c, d);
3441 }
3442
3443 return 0;
76a347e1
RH
3444}
3445EOF
3446if compile_prog "" "" ; then
3447 cpuid_h=yes
3448fi
3449
5dd89908
RH
3450##########################################
3451# avx2 optimization requirement check
3452#
3453# There is no point enabling this if cpuid.h is not usable,
3454# since we won't be able to select the new routines.
3455
e633a5c6 3456if test "$cpuid_h" = "yes" && test "$avx2_opt" != "no"; then
5dd89908
RH
3457 cat > $TMPC << EOF
3458#pragma GCC push_options
3459#pragma GCC target("avx2")
3460#include <cpuid.h>
3461#include <immintrin.h>
3462static int bar(void *a) {
3463 __m256i x = *(__m256i *)a;
3464 return _mm256_testz_si256(x, x);
3465}
3466int main(int argc, char *argv[]) { return bar(argv[0]); }
3467EOF
5b945f23 3468 if compile_object "-Werror" ; then
5dd89908 3469 avx2_opt="yes"
86583a07
LM
3470 else
3471 avx2_opt="no"
5dd89908
RH
3472 fi
3473fi
3474
6b8cd447
RH
3475##########################################
3476# avx512f optimization requirement check
3477#
3478# There is no point enabling this if cpuid.h is not usable,
3479# since we won't be able to select the new routines.
3480# by default, it is turned off.
3481# if user explicitly want to enable it, check environment
3482
3483if test "$cpuid_h" = "yes" && test "$avx512f_opt" = "yes"; then
3484 cat > $TMPC << EOF
3485#pragma GCC push_options
3486#pragma GCC target("avx512f")
3487#include <cpuid.h>
3488#include <immintrin.h>
3489static int bar(void *a) {
3490 __m512i x = *(__m512i *)a;
3491 return _mm512_test_epi64_mask(x, x);
3492}
3493int main(int argc, char *argv[])
3494{
3495 return bar(argv[0]);
3496}
3497EOF
5b945f23 3498 if ! compile_object "-Werror" ; then
6b8cd447
RH
3499 avx512f_opt="no"
3500 fi
3501else
3502 avx512f_opt="no"
3503fi
3504
f540166b
RH
3505########################################
3506# check if __[u]int128_t is usable.
3507
3508int128=no
3509cat > $TMPC << EOF
3510__int128_t a;
3511__uint128_t b;
3512int main (void) {
3513 a = a + b;
3514 b = a * b;
464e3671 3515 a = a * a;
f540166b
RH
3516 return 0;
3517}
3518EOF
3519if compile_prog "" "" ; then
3520 int128=yes
3521fi
76a347e1 3522
7ebee43e
RH
3523#########################################
3524# See if 128-bit atomic operations are supported.
3525
3526atomic128=no
3527if test "$int128" = "yes"; then
3528 cat > $TMPC << EOF
3529int main(void)
3530{
3531 unsigned __int128 x = 0, y = 0;
bceac547
TH
3532 y = __atomic_load(&x, 0);
3533 __atomic_store(&x, y, 0);
3534 __atomic_compare_exchange(&x, &y, x, 0, 0, 0);
7ebee43e
RH
3535 return 0;
3536}
3537EOF
3538 if compile_prog "" "" ; then
3539 atomic128=yes
3540 fi
3541fi
3542
e6cd4bb5 3543cmpxchg128=no
e633a5c6 3544if test "$int128" = yes && test "$atomic128" = no; then
e6cd4bb5
RH
3545 cat > $TMPC << EOF
3546int main(void)
3547{
3548 unsigned __int128 x = 0, y = 0;
3549 __sync_val_compare_and_swap_16(&x, y, x);
3550 return 0;
3551}
3552EOF
3553 if compile_prog "" "" ; then
3554 cmpxchg128=yes
3555 fi
3556fi
3557
fd0e6053
JS
3558########################################
3559# check if ccache is interfering with
3560# semantic analysis of macros
3561
5e4dfd3d 3562unset CCACHE_CPP2
fd0e6053
JS
3563ccache_cpp2=no
3564cat > $TMPC << EOF
3565static const int Z = 1;
3566#define fn() ({ Z; })
3567#define TAUT(X) ((X) == Z)
3568#define PAREN(X, Y) (X == Y)
3569#define ID(X) (X)
3570int main(int argc, char *argv[])
3571{
3572 int x = 0, y = 0;
3573 x = ID(x);
3574 x = fn();
3575 fn();
3576 if (PAREN(x, y)) return 0;
3577 if (TAUT(Z)) return 0;
3578 return 0;
3579}
3580EOF
3581
3582if ! compile_object "-Werror"; then
3583 ccache_cpp2=yes
3584fi
3585
b553a042
JS
3586#################################################
3587# clang does not support glibc + FORTIFY_SOURCE.
3588
3589if test "$fortify_source" != "no"; then
3590 if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
3591 fortify_source="no";
e189091f 3592 elif test -n "$cxx" && has $cxx &&
cfcc7c14 3593 echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
b553a042
JS
3594 fortify_source="no";
3595 else
3596 fortify_source="yes"
3597 fi
3598fi
3599
a40161cb
PB
3600##########################################
3601# check for usable membarrier system call
3602if test "$membarrier" = "yes"; then
3603 have_membarrier=no
3604 if test "$mingw32" = "yes" ; then
3605 have_membarrier=yes
3606 elif test "$linux" = "yes" ; then
3607 cat > $TMPC << EOF
3608 #include <linux/membarrier.h>
3609 #include <sys/syscall.h>
3610 #include <unistd.h>
3611 #include <stdlib.h>
3612 int main(void) {
3613 syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
3614 syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0);
3615 exit(0);
3616 }
3617EOF
3618 if compile_prog "" "" ; then
3619 have_membarrier=yes
3620 fi
3621 fi
3622 if test "$have_membarrier" = "no"; then
3623 feature_not_found "membarrier" "membarrier system call not available"
3624 fi
3625else
3626 # Do not enable it by default even for Mingw32, because it doesn't
3627 # work on Wine.
3628 membarrier=no
3629fi
3630
f0d92b56
LM
3631##########################################
3632# check for usable AF_ALG environment
4f67366e 3633have_afalg=no
f0d92b56
LM
3634cat > $TMPC << EOF
3635#include <errno.h>
3636#include <sys/types.h>
3637#include <sys/socket.h>
3638#include <linux/if_alg.h>
3639int main(void) {
3640 int sock;
3641 sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
3642 return sock;
3643}
3644EOF
3645if compile_prog "" "" ; then
3646 have_afalg=yes
3647fi
3648if test "$crypto_afalg" = "yes"
3649then
3650 if test "$have_afalg" != "yes"
3651 then
3652 error_exit "AF_ALG requested but could not be detected"
3653 fi
3654fi
3655
3656
247724cb
MAL
3657##########################################
3658# checks for sanitizers
3659
247724cb
MAL
3660have_asan=no
3661have_ubsan=no
d83414e1
MAL
3662have_asan_iface_h=no
3663have_asan_iface_fiber=no
247724cb
MAL
3664
3665if test "$sanitizers" = "yes" ; then
b9f44da2 3666 write_c_skeleton
247724cb
MAL
3667 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
3668 have_asan=yes
3669 fi
b9f44da2
MAL
3670
3671 # we could use a simple skeleton for flags checks, but this also
3672 # detect the static linking issue of ubsan, see also:
3673 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
3674 cat > $TMPC << EOF
3675#include <stdlib.h>
3676int main(void) {
3677 void *tmp = malloc(10);
f2dfe54c
LB
3678 if (tmp != NULL) {
3679 return *(int *)(tmp + 2);
3680 }
d1abf3fc 3681 return 1;
b9f44da2
MAL
3682}
3683EOF
247724cb
MAL
3684 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
3685 have_ubsan=yes
3686 fi
d83414e1
MAL
3687
3688 if check_include "sanitizer/asan_interface.h" ; then
3689 have_asan_iface_h=yes
3690 fi
3691
3692 cat > $TMPC << EOF
3693#include <sanitizer/asan_interface.h>
3694int main(void) {
3695 __sanitizer_start_switch_fiber(0, 0, 0);
3696 return 0;
3697}
3698EOF
3699 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
3700 have_asan_iface_fiber=yes
3701 fi
247724cb
MAL
3702fi
3703
0aebab04
LY
3704# Thread sanitizer is, for now, much noisier than the other sanitizers;
3705# keep it separate until that is not the case.
3706if test "$tsan" = "yes" && test "$sanitizers" = "yes"; then
3707 error_exit "TSAN is not supported with other sanitiziers."
3708fi
3709have_tsan=no
3710have_tsan_iface_fiber=no
3711if test "$tsan" = "yes" ; then
3712 write_c_skeleton
3713 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
3714 have_tsan=yes
3715 fi
3716 cat > $TMPC << EOF
3717#include <sanitizer/tsan_interface.h>
3718int main(void) {
3719 __tsan_create_fiber(0);
3720 return 0;
3721}
3722EOF
3723 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
3724 have_tsan_iface_fiber=yes
3725 fi
3726fi
3727
675b9b53
MAL
3728##########################################
3729# check for slirp
3730
3731case "$slirp" in
4d34a86b
PB
3732 auto | enabled | internal)
3733 # Simpler to always update submodule, even if not needed.
2d652f24 3734 git_submodules="${git_submodules} slirp"
675b9b53
MAL
3735 ;;
3736esac
3737
b8e0c493
JD
3738# Check for slirp smbd dupport
3739: ${smbd=${SMBD-/usr/sbin/smbd}}
3740if test "$slirp_smbd" != "no" ; then
3741 if test "$mingw32" = "yes" ; then
3742 if test "$slirp_smbd" = "yes" ; then
3743 error_exit "Host smbd not supported on this platform."
3744 fi
3745 slirp_smbd=no
3746 else
3747 slirp_smbd=yes
3748 fi
3749fi
3750
54e7aac0
AK
3751##########################################
3752# check for usable __NR_keyctl syscall
3753
3754if test "$linux" = "yes" ; then
3755
3756 have_keyring=no
3757 cat > $TMPC << EOF
3758#include <errno.h>
3759#include <asm/unistd.h>
3760#include <linux/keyctl.h>
3761#include <unistd.h>
3762int main(void) {
3763 return syscall(__NR_keyctl, KEYCTL_READ, 0, NULL, NULL, 0);
3764}
3765EOF
3766 if compile_prog "" "" ; then
3767 have_keyring=yes
3768 fi
3769fi
3770if test "$secret_keyring" != "no"
3771then
b418d265 3772 if test "$have_keyring" = "yes"
54e7aac0
AK
3773 then
3774 secret_keyring=yes
3775 else
3776 if test "$secret_keyring" = "yes"
3777 then
3778 error_exit "syscall __NR_keyctl requested, \
3779but not implemented on your system"
3780 else
3781 secret_keyring=no
3782 fi
3783 fi
3784fi
3785
7e24e92a 3786##########################################
e86ecd4b
JQ
3787# End of CC checks
3788# After here, no more $cc or $ld runs
3789
d83414e1
MAL
3790write_c_skeleton
3791
1d728c39 3792if test "$gcov" = "yes" ; then
bf0e56a3 3793 :
b553a042 3794elif test "$fortify_source" = "yes" ; then
086d5f75
PB
3795 QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
3796 debug=no
3797fi
086d5f75
PB
3798
3799case "$ARCH" in
3800alpha)
3801 # Ensure there's only a single GP
3802 QEMU_CFLAGS="-msmall-data $QEMU_CFLAGS"
3803;;
3804esac
3805
3806if test "$gprof" = "yes" ; then
3807 QEMU_CFLAGS="-p $QEMU_CFLAGS"
3808 QEMU_LDFLAGS="-p $QEMU_LDFLAGS"
3809fi
a316e378 3810
247724cb 3811if test "$have_asan" = "yes"; then
db5adeaa
PB
3812 QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS"
3813 QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS"
d83414e1
MAL
3814 if test "$have_asan_iface_h" = "no" ; then
3815 echo "ASAN build enabled, but ASAN header missing." \
3816 "Without code annotation, the report may be inferior."
3817 elif test "$have_asan_iface_fiber" = "no" ; then
3818 echo "ASAN build enabled, but ASAN header is too old." \
3819 "Without code annotation, the report may be inferior."
3820 fi
247724cb 3821fi
0aebab04
LY
3822if test "$have_tsan" = "yes" ; then
3823 if test "$have_tsan_iface_fiber" = "yes" ; then
3824 QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS"
3825 QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS"
3826 else
3827 error_exit "Cannot enable TSAN due to missing fiber annotation interface."
3828 fi
3829elif test "$tsan" = "yes" ; then
3830 error_exit "Cannot enable TSAN due to missing sanitize thread interface."
3831fi
247724cb 3832if test "$have_ubsan" = "yes"; then
db5adeaa
PB
3833 QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS"
3834 QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS"
247724cb
MAL
3835fi
3836
3efac6eb 3837##########################################
3efac6eb 3838
0aebab04
LY
3839# Exclude --warn-common with TSan to suppress warnings from the TSan libraries.
3840if test "$solaris" = "no" && test "$tsan" = "no"; then
e86ecd4b 3841 if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
db5adeaa 3842 QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS"
e86ecd4b
JQ
3843 fi
3844fi
3845
952afb71
BS
3846# Use ASLR, no-SEH and DEP if available
3847if test "$mingw32" = "yes" ; then
cb8baa77
MCA
3848 flags="--no-seh --nxcompat"
3849
3850 # Disable ASLR for debug builds to allow debugging with gdb
3851 if test "$debug" = "no" ; then
3852 flags="--dynamicbase $flags"
3853 fi
3854
3855 for flag in $flags; do
e9a3591f 3856 if ld_has $flag ; then
db5adeaa 3857 QEMU_LDFLAGS="-Wl,$flag $QEMU_LDFLAGS"
952afb71
BS
3858 fi
3859 done
3860fi
3861
9d6bc27b
MR
3862# Probe for guest agent support/options
3863
e8ef31a3 3864if [ "$guest_agent" != "no" ]; then
a5125905
LV
3865 if [ "$softmmu" = no -a "$want_tools" = no ] ; then
3866 guest_agent=no
3867 elif [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
e8ef31a3
MT
3868 guest_agent=yes
3869 elif [ "$guest_agent" != yes ]; then
3870 guest_agent=no
3871 else
3872 error_exit "Guest agent is not supported on this platform"
ca35f780 3873 fi
00c705fb 3874fi
ca35f780 3875
b846ab7c 3876# Guest agent Windows MSI package
9d6bc27b 3877
b846ab7c
PB
3878if test "$QEMU_GA_MANUFACTURER" = ""; then
3879 QEMU_GA_MANUFACTURER=QEMU
9d6bc27b 3880fi
b846ab7c
PB
3881if test "$QEMU_GA_DISTRO" = ""; then
3882 QEMU_GA_DISTRO=Linux
9d6bc27b 3883fi
b846ab7c
PB
3884if test "$QEMU_GA_VERSION" = ""; then
3885 QEMU_GA_VERSION=$(cat $source_path/VERSION)
3886fi
3887
3888QEMU_GA_MSI_MINGW_DLL_PATH="$($pkg_config --variable=prefix glib-2.0)/bin"
9d6bc27b 3889
ca35f780
PB
3890# Mac OS X ships with a broken assembler
3891roms=
e633a5c6
EB
3892if { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \
3893 test "$targetos" != "Darwin" && test "$targetos" != "SunOS" && \
7000a12e 3894 test "$targetos" != "Haiku" && test "$softmmu" = yes ; then
e57218b6 3895 # Different host OS linkers have different ideas about the name of the ELF
c65d5e4e
BS
3896 # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
3897 # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
3898 for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
e57218b6
PM
3899 if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
3900 ld_i386_emulation="$emu"
3901 roms="optionrom"
3902 break
3903 fi
3904 done
ca35f780 3905fi
ca35f780 3906
2e33c3f8 3907# Only build s390-ccw bios if we're on s390x and the compiler has -march=z900
a5b2afd5 3908# or -march=z10 (which is the lowest architecture level that Clang supports)
9933c305 3909if test "$cpu" = "s390x" ; then
2e33c3f8 3910 write_c_skeleton
a5b2afd5
TH
3911 compile_prog "-march=z900" ""
3912 has_z900=$?
3af448b3 3913 if [ $has_z900 = 0 ] || compile_object "-march=z10 -msoft-float -Werror"; then
a5b2afd5
TH
3914 if [ $has_z900 != 0 ]; then
3915 echo "WARNING: Your compiler does not support the z900!"
3916 echo " The s390-ccw bios will only work with guest CPUs >= z10."
3917 fi
2e33c3f8 3918 roms="$roms s390-ccw"
1ef6bfc2
PMD
3919 # SLOF is required for building the s390-ccw firmware on s390x,
3920 # since it is using the libnet code from SLOF for network booting.
2d652f24 3921 git_submodules="${git_submodules} roms/SLOF"
2e33c3f8 3922 fi
9933c305
CB
3923fi
3924
11cde1c8
BD
3925# Check that the C++ compiler exists and works with the C compiler.
3926# All the QEMU_CXXFLAGS are based on QEMU_CFLAGS. Keep this at the end to don't miss any other that could be added.
3927if has $cxx; then
3928 cat > $TMPC <<EOF
3929int c_function(void);
3930int main(void) { return c_function(); }
3931EOF
3932
3933 compile_object
3934
3935 cat > $TMPCXX <<EOF
3936extern "C" {
3937 int c_function(void);
3938}
3939int c_function(void) { return 42; }
3940EOF
3941
3942 update_cxxflags
3943
5770e8af 3944 if do_cxx $CXXFLAGS $CONFIGURE_CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then
11cde1c8
BD
3945 # C++ compiler $cxx works ok with C compiler $cc
3946 :
3947 else
3948 echo "C++ compiler $cxx does not work with C compiler $cc"
3949 echo "Disabling C++ specific optional code"
3950 cxx=
3951 fi
3952else
3953 echo "No C++ compiler available; disabling C++ specific optional code"
3954 cxx=
3955fi
3956
7d7dbf9d
DS
3957if !(GIT="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then
3958 exit 1
5d91a2ed 3959fi
5d91a2ed 3960
98ec69ac 3961config_host_mak="config-host.mak"
98ec69ac 3962
98ec69ac 3963echo "# Automatically generated by configure - do not modify" > $config_host_mak
98ec69ac 3964echo >> $config_host_mak
98ec69ac 3965
e6c3b0f7 3966echo all: >> $config_host_mak
cc84d63a 3967echo "GIT=$git" >> $config_host_mak
aef45d51 3968echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
7d7dbf9d 3969echo "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak
804edf29 3970
98ec69ac 3971echo "ARCH=$ARCH" >> $config_host_mak
727e5283 3972
f8393946 3973if test "$debug_tcg" = "yes" ; then
2358a494 3974 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
f8393946 3975fi
1625af87 3976if test "$strip_opt" = "yes" ; then
52ba784d 3977 echo "STRIP=${strip}" >> $config_host_mak
1625af87 3978fi
67b915a5 3979if test "$mingw32" = "yes" ; then
98ec69ac 3980 echo "CONFIG_WIN32=y" >> $config_host_mak
d9840e25
TS
3981 if test "$guest_agent_with_vss" = "yes" ; then
3982 echo "CONFIG_QGA_VSS=y" >> $config_host_mak
f33ca81f 3983 echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
d9840e25
TS
3984 echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
3985 fi
50cbebb9 3986 if test "$guest_agent_ntddscsi" = "yes" ; then
76dc75ca 3987 echo "CONFIG_QGA_NTDDSCSI=y" >> $config_host_mak
50cbebb9 3988 fi
b846ab7c
PB
3989 echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
3990 echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
3991 echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
3992 echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
210fa556 3993else
35f4df27 3994 echo "CONFIG_POSIX=y" >> $config_host_mak
dffcb71c
MM
3995fi
3996
3997if test "$linux" = "yes" ; then
3998 echo "CONFIG_LINUX=y" >> $config_host_mak
67b915a5 3999fi
128ab2ff 4000
83fb7adf 4001if test "$darwin" = "yes" ; then
98ec69ac 4002 echo "CONFIG_DARWIN=y" >> $config_host_mak
83fb7adf 4003fi
b29fe3ed 4004
ec530c81 4005if test "$solaris" = "yes" ; then
98ec69ac 4006 echo "CONFIG_SOLARIS=y" >> $config_host_mak
ec530c81 4007fi
179cf400
AF
4008if test "$haiku" = "yes" ; then
4009 echo "CONFIG_HAIKU=y" >> $config_host_mak
4010fi
97a847bc 4011if test "$static" = "yes" ; then
98ec69ac 4012 echo "CONFIG_STATIC=y" >> $config_host_mak
7d13299d 4013fi
1ba16968 4014if test "$profiler" = "yes" ; then
2358a494 4015 echo "CONFIG_PROFILER=y" >> $config_host_mak
05c2a3e7 4016fi
c932ce31
PB
4017if test "$want_tools" = "yes" ; then
4018 echo "CONFIG_TOOLS=y" >> $config_host_mak
4019fi
f15bff25
PB
4020if test "$guest_agent" = "yes" ; then
4021 echo "CONFIG_GUEST_AGENT=y" >> $config_host_mak
4022fi
b8e0c493
JD
4023if test "$slirp_smbd" = "yes" ; then
4024 echo "CONFIG_SLIRP_SMBD=y" >> $config_host_mak
4025 echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
4026fi
015a33bd
GA
4027if test "$l2tpv3" = "yes" ; then
4028 echo "CONFIG_L2TPV3=y" >> $config_host_mak
4029fi
4cc600d2
PB
4030if test "$gprof" = "yes" ; then
4031 echo "CONFIG_GPROF=y" >> $config_host_mak
4032fi
b64ec4e4
FZ
4033echo "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
4034echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
e5f05f8c
KW
4035if test "$block_drv_whitelist_tools" = "yes" ; then
4036 echo "CONFIG_BDRV_WHITELIST_TOOLS=y" >> $config_host_mak
4037fi
dce512de
CH
4038if test "$xfs" = "yes" ; then
4039 echo "CONFIG_XFS=y" >> $config_host_mak
4040fi
89138857 4041qemu_version=$(head $source_path/VERSION)
2358a494 4042echo "PKGVERSION=$pkgversion" >>$config_host_mak
98ec69ac 4043echo "SRC_PATH=$source_path" >> $config_host_mak
2b1f35b9 4044echo "TARGET_DIRS=$target_list" >> $config_host_mak
17969268 4045if test "$modules" = "yes"; then
e26110cf
FZ
4046 # $shacmd can generate a hash started with digit, which the compiler doesn't
4047 # like as an symbol. So prefix it with an underscore
89138857 4048 echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
17969268
FZ
4049 echo "CONFIG_MODULES=y" >> $config_host_mak
4050fi
bd83c861
CE
4051if test "$module_upgrades" = "yes"; then
4052 echo "CONFIG_MODULE_UPGRADES=y" >> $config_host_mak
4053fi
955727d2
CT
4054if test "$have_usbfs" = "yes" ; then
4055 echo "CONFIG_USBFS=y" >> $config_host_mak
4056fi
f876b765
MAL
4057if test "$gio" = "yes" ; then
4058 echo "CONFIG_GIO=y" >> $config_host_mak
4059 echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak
4060 echo "GIO_LIBS=$gio_libs" >> $config_host_mak
5ecfb76c
PB
4061fi
4062if test "$gdbus_codegen" != "" ; then
25a97a56 4063 echo "GDBUS_CODEGEN=$gdbus_codegen" >> $config_host_mak
f876b765 4064fi
a1c5e949 4065echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
277abf15 4066
1badb709 4067if test "$xen" = "enabled" ; then
6dbd588a 4068 echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
d5b93ddf 4069 echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
582ea95f
MAL
4070 echo "XEN_CFLAGS=$xen_cflags" >> $config_host_mak
4071 echo "XEN_LIBS=$xen_libs" >> $config_host_mak
e37630ca 4072fi
5e9be92d
NB
4073if test "$vhost_scsi" = "yes" ; then
4074 echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
4075fi
af3bba76
PB
4076if test "$vhost_net" = "yes" ; then
4077 echo "CONFIG_VHOST_NET=y" >> $config_host_mak
4078fi
4079if test "$vhost_net_user" = "yes" ; then
56f41de7 4080 echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak
03ce5744 4081fi
108a6481
CL
4082if test "$vhost_net_vdpa" = "yes" ; then
4083 echo "CONFIG_VHOST_NET_VDPA=y" >> $config_host_mak
4084fi
042cea27
GA
4085if test "$vhost_crypto" = "yes" ; then
4086 echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
4087fi
fc0b9b0e
SH
4088if test "$vhost_vsock" = "yes" ; then
4089 echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
5fe97d88
SG
4090 if test "$vhost_user" = "yes" ; then
4091 echo "CONFIG_VHOST_USER_VSOCK=y" >> $config_host_mak
4092 fi
fc0b9b0e 4093fi
299e6f19
PB
4094if test "$vhost_kernel" = "yes" ; then
4095 echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak
4096fi
e6a74868
MAL
4097if test "$vhost_user" = "yes" ; then
4098 echo "CONFIG_VHOST_USER=y" >> $config_host_mak
4099fi
108a6481
CL
4100if test "$vhost_vdpa" = "yes" ; then
4101 echo "CONFIG_VHOST_VDPA=y" >> $config_host_mak
4102fi
98fc1ada
DDAG
4103if test "$vhost_user_fs" = "yes" ; then
4104 echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak
4105fi
a40161cb
PB
4106if test "$membarrier" = "yes" ; then
4107 echo "CONFIG_MEMBARRIER=y" >> $config_host_mak
4108fi
e5b46549
RH
4109if test "$tcg" = "enabled" -a "$tcg_interpreter" = "true" ; then
4110 echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
4111fi
58d3f3ff 4112
da076ffe
GH
4113if test "$opengl" = "yes" ; then
4114 echo "CONFIG_OPENGL=y" >> $config_host_mak
de2d3005 4115 echo "OPENGL_CFLAGS=$opengl_cflags" >> $config_host_mak
da076ffe 4116 echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
20ff075b
MW
4117fi
4118
99f2dbd3
LL
4119if test "$avx2_opt" = "yes" ; then
4120 echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
4121fi
4122
6b8cd447
RH
4123if test "$avx512f_opt" = "yes" ; then
4124 echo "CONFIG_AVX512F_OPT=y" >> $config_host_mak
4125fi
4126
83fb7adf 4127# XXX: suppress that
7d3505c5 4128if [ "$bsd" = "yes" ] ; then
2358a494 4129 echo "CONFIG_BSD=y" >> $config_host_mak
7d3505c5
FB
4130fi
4131
3556c233
PB
4132if test "$qom_cast_debug" = "yes" ; then
4133 echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
4134fi
d0e2fce5 4135
7c2acc70 4136echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
70c60c08
SH
4137if test "$coroutine_pool" = "yes" ; then
4138 echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
4139else
4140 echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
4141fi
20ff6c80 4142
7d992e4d
PL
4143if test "$debug_stack_usage" = "yes" ; then
4144 echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
4145fi
4146
f0d92b56
LM
4147if test "$crypto_afalg" = "yes" ; then
4148 echo "CONFIG_AF_ALG=y" >> $config_host_mak
4149fi
4150
d83414e1
MAL
4151if test "$have_asan_iface_fiber" = "yes" ; then
4152 echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
4153fi
4154
0aebab04
LY
4155if test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then
4156 echo "CONFIG_TSAN=y" >> $config_host_mak
4157fi
4158
76a347e1
RH
4159if test "$cpuid_h" = "yes" ; then
4160 echo "CONFIG_CPUID_H=y" >> $config_host_mak
4161fi
4162
f540166b
RH
4163if test "$int128" = "yes" ; then
4164 echo "CONFIG_INT128=y" >> $config_host_mak
4165fi
4166
7ebee43e
RH
4167if test "$atomic128" = "yes" ; then
4168 echo "CONFIG_ATOMIC128=y" >> $config_host_mak
4169fi
4170
e6cd4bb5
RH
4171if test "$cmpxchg128" = "yes" ; then
4172 echo "CONFIG_CMPXCHG128=y" >> $config_host_mak
4173fi
4174
b10d49d7 4175if test "$libssh" = "yes" ; then
484e2cc7 4176 echo "CONFIG_LIBSSH=y" >> $config_host_mak
b10d49d7
PT
4177 echo "LIBSSH_CFLAGS=$libssh_cflags" >> $config_host_mak
4178 echo "LIBSSH_LIBS=$libssh_libs" >> $config_host_mak
0a12ec87
RJ
4179fi
4180
ed1701c6
DDAG
4181if test "$live_block_migration" = "yes" ; then
4182 echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
4183fi
4184
3b8acc11 4185if test "$tpm" = "yes"; then
3cae16db 4186 echo 'CONFIG_TPM=y' >> $config_host_mak
3b8acc11
PB
4187fi
4188
2da776db
MH
4189if test "$rdma" = "yes" ; then
4190 echo "CONFIG_RDMA=y" >> $config_host_mak
392fb643 4191 echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
2da776db
MH
4192fi
4193
21ab34c9
MA
4194if test "$pvrdma" = "yes" ; then
4195 echo "CONFIG_PVRDMA=y" >> $config_host_mak
4196fi
4197
a6b1d4c0
CX
4198if test "$replication" = "yes" ; then
4199 echo "CONFIG_REPLICATION=y" >> $config_host_mak
4200fi
4201
ba59fb77
PB
4202if test "$debug_mutex" = "yes" ; then
4203 echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak
4204fi
e0580342 4205
2f740136
JC
4206if test "$bochs" = "yes" ; then
4207 echo "CONFIG_BOCHS=y" >> $config_host_mak
4208fi
4209if test "$cloop" = "yes" ; then
4210 echo "CONFIG_CLOOP=y" >> $config_host_mak
4211fi
4212if test "$dmg" = "yes" ; then
4213 echo "CONFIG_DMG=y" >> $config_host_mak
4214fi
4215if test "$qcow1" = "yes" ; then
4216 echo "CONFIG_QCOW1=y" >> $config_host_mak
4217fi
4218if test "$vdi" = "yes" ; then
4219 echo "CONFIG_VDI=y" >> $config_host_mak
4220fi
4221if test "$vvfat" = "yes" ; then
4222 echo "CONFIG_VVFAT=y" >> $config_host_mak
4223fi
4224if test "$qed" = "yes" ; then
4225 echo "CONFIG_QED=y" >> $config_host_mak
4226fi
4227if test "$parallels" = "yes" ; then
4228 echo "CONFIG_PARALLELS=y" >> $config_host_mak
4229fi
2f740136 4230
40e8c6f4
AB
4231if test "$plugins" = "yes" ; then
4232 echo "CONFIG_PLUGIN=y" >> $config_host_mak
26fffe29
EC
4233 # Copy the export object list to the build dir
4234 if test "$ld_dynamic_list" = "yes" ; then
4235 echo "CONFIG_HAS_LD_DYNAMIC_LIST=yes" >> $config_host_mak
4236 ld_symbols=qemu-plugins-ld.symbols
4237 cp "$source_path/plugins/qemu-plugins.symbols" $ld_symbols
4238 elif test "$ld_exported_symbols_list" = "yes" ; then
4239 echo "CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST=yes" >> $config_host_mak
4240 ld64_symbols=qemu-plugins-ld64.symbols
4241 echo "# Automatically generated by configure - do not modify" > $ld64_symbols
4242 grep 'qemu_' "$source_path/plugins/qemu-plugins.symbols" | sed 's/;//g' | \
4243 sed -E 's/^[[:space:]]*(.*)/_\1/' >> $ld64_symbols
4244 else
4245 error_exit \
4246 "If \$plugins=yes, either \$ld_dynamic_list or " \
4247 "\$ld_exported_symbols_list should have been set to 'yes'."
4248 fi
40e8c6f4
AB
4249fi
4250
b1863ccc
AB
4251if test -n "$gdb_bin"; then
4252 gdb_version=$($gdb_bin --version | head -n 1)
d6a66c81 4253 if version_ge ${gdb_version##* } 9.1; then
b1863ccc
AB
4254 echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
4255 fi
f48e590a
AB
4256fi
4257
54e7aac0
AK
4258if test "$secret_keyring" = "yes" ; then
4259 echo "CONFIG_SECRET_KEYRING=y" >> $config_host_mak
4260fi
4261
98ec69ac 4262echo "ROMS=$roms" >> $config_host_mak
804edf29 4263echo "MAKE=$make" >> $config_host_mak
c886edfb 4264echo "PYTHON=$python" >> $config_host_mak
39d87c8c 4265echo "GENISOIMAGE=$genisoimage" >> $config_host_mak
a5665051 4266echo "MESON=$meson" >> $config_host_mak
09e93326 4267echo "NINJA=$ninja" >> $config_host_mak
804edf29 4268echo "CC=$cc" >> $config_host_mak
433de74c 4269echo "HOST_CC=$host_cc" >> $config_host_mak
a31a8642 4270if $iasl -h > /dev/null 2>&1; then
859aef02 4271 echo "CONFIG_IASL=$iasl" >> $config_host_mak
a31a8642 4272fi
804edf29 4273echo "AR=$ar" >> $config_host_mak
cdbd727c 4274echo "AS=$as" >> $config_host_mak
5f6f0e27 4275echo "CCAS=$ccas" >> $config_host_mak
3dd46c78 4276echo "CPP=$cpp" >> $config_host_mak
804edf29
JQ
4277echo "OBJCOPY=$objcopy" >> $config_host_mak
4278echo "LD=$ld" >> $config_host_mak
46eef33b 4279echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
a558ee17 4280echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
11cde1c8 4281echo "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
a81df1b6
PB
4282echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
4283echo "GLIB_LIBS=$glib_libs" >> $config_host_mak
8a99e9a3 4284echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
e57218b6 4285echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
804edf29 4286echo "EXESUF=$EXESUF" >> $config_host_mak
f15bff25 4287echo "LIBS_QGA=$libs_qga" >> $config_host_mak
804edf29 4288
b767d257
MMG
4289if test "$rng_none" = "yes"; then
4290 echo "CONFIG_RNG_NONE=y" >> $config_host_mak
4291fi
4292
6efd7517
PM
4293# use included Linux headers
4294if test "$linux" = "yes" ; then
a307beb6 4295 mkdir -p linux-headers
6efd7517 4296 case "$cpu" in
c72b26ec 4297 i386|x86_64|x32)
08312a63 4298 linux_arch=x86
6efd7517 4299 ;;
f8378acc 4300 ppc|ppc64|ppc64le)
08312a63 4301 linux_arch=powerpc
6efd7517
PM
4302 ;;
4303 s390x)
08312a63
PM
4304 linux_arch=s390
4305 ;;
1f080313
CF
4306 aarch64)
4307 linux_arch=arm64
4308 ;;
222e7d11
SL
4309 mips64)
4310 linux_arch=mips
4311 ;;
08312a63
PM
4312 *)
4313 # For most CPUs the kernel architecture name and QEMU CPU name match.
4314 linux_arch="$cpu"
6efd7517
PM
4315 ;;
4316 esac
08312a63
PM
4317 # For non-KVM architectures we will not have asm headers
4318 if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
4319 symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
4320 fi
6efd7517
PM
4321fi
4322
1d14ffa9 4323for target in $target_list; do
fdb75aef
PB
4324 target_dir="$target"
4325 target_name=$(echo $target | cut -d '-' -f 1)
4326 mkdir -p $target_dir
4327 case $target in
4328 *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;;
4329 *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;;
4330 esac
4331done
7d13299d 4332
765686d6 4333echo "CONFIG_QEMU_INTERP_PREFIX=$interp_prefix" | sed 's/%M/@0@/' >> $config_host_mak
fdb75aef
PB
4334if test "$default_targets" = "yes"; then
4335 echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak
4336fi
a540f158 4337
a99d57bb
WG
4338if test "$numa" = "yes"; then
4339 echo "CONFIG_NUMA=y" >> $config_host_mak
ab318051 4340 echo "NUMA_LIBS=$numa_libs" >> $config_host_mak
a99d57bb
WG
4341fi
4342
fd0e6053
JS
4343if test "$ccache_cpp2" = "yes"; then
4344 echo "export CCACHE_CPP2=y" >> $config_host_mak
4345fi
4346
1e4f6065
DB
4347if test "$safe_stack" = "yes"; then
4348 echo "CONFIG_SAFESTACK=y" >> $config_host_mak
4349fi
4350
e29e5c6e
PM
4351# If we're using a separate build tree, set it up now.
4352# DIRS are directories which we simply mkdir in the build tree;
4353# LINKS are things to symlink back into the source tree
4354# (these can be both files and directories).
4355# Caution: do not add files or directories here using wildcards. This
4356# will result in problems later if a new file matching the wildcard is
4357# added to the source tree -- nothing will cause configure to be rerun
4358# so the build tree will be missing the link back to the new file, and
4359# tests might fail. Prefer to keep the relevant files in their own
4360# directory and symlink the directory instead.
09db9b9d
GH
4361# UNLINK is used to remove symlinks from older development versions
4362# that might get into the way when doing "git update" without doing
4363# a "make distclean" in between.
9d49bcf6 4364DIRS="tests tests/tcg tests/qapi-schema tests/qtest/libqos"
1cf4323e 4365DIRS="$DIRS tests/qtest tests/qemu-iotests tests/vm tests/fp tests/qgraph"
b855f8d1 4366DIRS="$DIRS docs docs/interop fsdev scsi"
744a928c 4367DIRS="$DIRS pc-bios/optionrom pc-bios/s390-ccw"
8db2a4fd 4368DIRS="$DIRS roms/seabios"
c17a386b 4369DIRS="$DIRS contrib/plugins/"
2038f8c8 4370LINKS="Makefile"
3941996b 4371LINKS="$LINKS tests/tcg/Makefile.target"
ddcf607f 4372LINKS="$LINKS pc-bios/optionrom/Makefile"
e29e5c6e 4373LINKS="$LINKS pc-bios/s390-ccw/Makefile"
8db2a4fd 4374LINKS="$LINKS roms/seabios/Makefile"
e29e5c6e
PM
4375LINKS="$LINKS pc-bios/qemu-icon.bmp"
4376LINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
39950353
PM
4377LINKS="$LINKS tests/acceptance tests/data"
4378LINKS="$LINKS tests/qemu-iotests/check"
8f8fd9ed 4379LINKS="$LINKS python"
c17a386b 4380LINKS="$LINKS contrib/plugins/Makefile "
09db9b9d 4381UNLINK="pc-bios/keymaps"
753d11f2
RH
4382for bios_file in \
4383 $source_path/pc-bios/*.bin \
3a631b8e 4384 $source_path/pc-bios/*.elf \
225a9ab8 4385 $source_path/pc-bios/*.lid \
753d11f2
RH
4386 $source_path/pc-bios/*.rom \
4387 $source_path/pc-bios/*.dtb \
e89e33e1 4388 $source_path/pc-bios/*.img \
753d11f2 4389 $source_path/pc-bios/openbios-* \
4e73c781 4390 $source_path/pc-bios/u-boot.* \
26ce90fd 4391 $source_path/pc-bios/edk2-*.fd.bz2 \
cd946e5c
JA
4392 $source_path/pc-bios/palcode-* \
4393 $source_path/pc-bios/qemu_vga.ndrv
4394
753d11f2 4395do
e29e5c6e 4396 LINKS="$LINKS pc-bios/$(basename $bios_file)"
d1807a4f
PB
4397done
4398mkdir -p $DIRS
e29e5c6e 4399for f in $LINKS ; do
0f4d8894 4400 if [ -e "$source_path/$f" ]; then
f9245e10
PM
4401 symlink "$source_path/$f" "$f"
4402 fi
d1807a4f 4403done
09db9b9d
GH
4404for f in $UNLINK ; do
4405 if [ -L "$f" ]; then
4406 rm -f "$f"
4407 fi
4408done
1ad2134f 4409
2038f8c8
PB
4410(for i in $cross_cc_vars; do
4411 export $i
4412done
de6d7e6b 4413export target_list source_path use_containers ARCH
2038f8c8
PB
4414$source_path/tests/tcg/configure.sh)
4415
c34ebfdc 4416# temporary config to build submodules
8db2a4fd 4417for rom in seabios; do
c34ebfdc 4418 config_mak=roms/$rom/config.mak
37116c89 4419 echo "# Automatically generated by configure - do not modify" > $config_mak
c34ebfdc 4420 echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
cdbd727c 4421 echo "AS=$as" >> $config_mak
5f6f0e27 4422 echo "CCAS=$ccas" >> $config_mak
c34ebfdc
AL
4423 echo "CC=$cc" >> $config_mak
4424 echo "BCC=bcc" >> $config_mak
3dd46c78 4425 echo "CPP=$cpp" >> $config_mak
c34ebfdc 4426 echo "OBJCOPY=objcopy" >> $config_mak
a31a8642 4427 echo "IASL=$iasl" >> $config_mak
c34ebfdc 4428 echo "LD=$ld" >> $config_mak
9f81aeb5 4429 echo "RANLIB=$ranlib" >> $config_mak
c34ebfdc
AL
4430done
4431
a5665051 4432if test "$skip_meson" = no; then
d77e90fa
PB
4433 cross="config-meson.cross.new"
4434 meson_quote() {
47b30835 4435 echo "'$(echo $* | sed "s/ /','/g")'"
d77e90fa
PB
4436 }
4437
4438 echo "# Automatically generated by configure - do not modify" > $cross
4439 echo "[properties]" >> $cross
d1d5e9ee
AB
4440
4441 # unroll any custom device configs
11bdcfcd
AB
4442 for a in $device_archs; do
4443 eval "c=\$devices_${a}"
4444 echo "${a}-softmmu = '$c'" >> $cross
4445 done
d1d5e9ee 4446
d77e90fa
PB
4447 test -z "$cxx" && echo "link_language = 'c'" >> $cross
4448 echo "[built-in options]" >> $cross
4449 echo "c_args = [${CFLAGS:+$(meson_quote $CFLAGS)}]" >> $cross
4450 echo "cpp_args = [${CXXFLAGS:+$(meson_quote $CXXFLAGS)}]" >> $cross
4451 echo "c_link_args = [${LDFLAGS:+$(meson_quote $LDFLAGS)}]" >> $cross
4452 echo "cpp_link_args = [${LDFLAGS:+$(meson_quote $LDFLAGS)}]" >> $cross
4453 echo "[binaries]" >> $cross
4dba2789
PB
4454 echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross
4455 test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross
4456 test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross
d77e90fa
PB
4457 echo "ar = [$(meson_quote $ar)]" >> $cross
4458 echo "nm = [$(meson_quote $nm)]" >> $cross
4459 echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross
4460 echo "ranlib = [$(meson_quote $ranlib)]" >> $cross
4461 if has $sdl2_config; then
4462 echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross
4463 fi
4464 echo "strip = [$(meson_quote $strip)]" >> $cross
4465 echo "windres = [$(meson_quote $windres)]" >> $cross
4466 if test "$cross_compile" = "yes"; then
fc929892 4467 cross_arg="--cross-file config-meson.cross"
fc929892
MAL
4468 echo "[host_machine]" >> $cross
4469 if test "$mingw32" = "yes" ; then
4470 echo "system = 'windows'" >> $cross
fc929892 4471 fi
853b4baf
TH
4472 if test "$linux" = "yes" ; then
4473 echo "system = 'linux'" >> $cross
4474 fi
0ca321ea
JD
4475 if test "$darwin" = "yes" ; then
4476 echo "system = 'darwin'" >> $cross
4477 fi
fc929892 4478 case "$ARCH" in
f6bca9df 4479 i386)
fc929892
MAL
4480 echo "cpu_family = 'x86'" >> $cross
4481 ;;
f8bb7e1c 4482 x86_64|x32)
f6bca9df
JD
4483 echo "cpu_family = 'x86_64'" >> $cross
4484 ;;
fc929892
MAL
4485 ppc64le)
4486 echo "cpu_family = 'ppc64'" >> $cross
4487 ;;
4488 *)
4489 echo "cpu_family = '$ARCH'" >> $cross
4490 ;;
4491 esac
4492 echo "cpu = '$cpu'" >> $cross
4493 if test "$bigendian" = "yes" ; then
4494 echo "endian = 'big'" >> $cross
4495 else
4496 echo "endian = 'little'" >> $cross
4497 fi
d77e90fa 4498 else
fc929892 4499 cross_arg="--native-file config-meson.cross"
d77e90fa
PB
4500 fi
4501 mv $cross config-meson.cross
fc929892 4502
d77e90fa 4503 rm -rf meson-private meson-info meson-logs
61d63097
PB
4504 run_meson() {
4505 NINJA=$ninja $meson setup \
d17f305a
PB
4506 --prefix "$prefix" \
4507 --libdir "$libdir" \
4508 --libexecdir "$libexecdir" \
4509 --bindir "$bindir" \
4510 --includedir "$includedir" \
4511 --datadir "$datadir" \
4512 --mandir "$mandir" \
4513 --sysconfdir "$sysconfdir" \
16bf7a33 4514 --localedir "$localedir" \
d17f305a
PB
4515 --localstatedir "$local_statedir" \
4516 -Ddocdir="$docdir" \
16bf7a33 4517 -Dqemu_firmwarepath="$firmwarepath" \
73f3aa37 4518 -Dqemu_suffix="$qemu_suffix" \
a5665051
PB
4519 -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) \
4520 -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo false; fi) \
4521 -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \
4522 -Dstrip=$(if test "$strip_opt" = yes; then echo true; else echo false; fi) \
da6d48b9 4523 -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \
bf0e56a3 4524 -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \
537b7248
PB
4525 -Db_lto=$lto -Dcfi=$cfi -Dcfi_debug=$cfi_debug -Dfuzzing=$fuzzing \
4526 $(test -n "${LIB_FUZZING_ENGINE+xxx}" && echo "-Dfuzzing_engine=$LIB_FUZZING_ENGINE") \
5f8937d6 4527 -Dmalloc=$malloc -Dmalloc_trim=$malloc_trim -Dsparse=$sparse \
74a414a1 4528 -Dkvm=$kvm -Dhax=$hax -Dwhpx=$whpx -Dhvf=$hvf -Dnvmm=$nvmm \
5f8937d6 4529 -Dxen=$xen -Dxen_pci_passthrough=$xen_pci_passthrough -Dtcg=$tcg \
1b695471 4530 -Dcocoa=$cocoa -Dgtk=$gtk -Dmpath=$mpath -Dsdl=$sdl -Dsdl_image=$sdl_image \
c23d7b4e 4531 -Dlibusb=$libusb -Dsmartcard=$smartcard -Dusb_redir=$usb_redir -Dvte=$vte \
5f8937d6 4532 -Dvnc=$vnc -Dvnc_sasl=$vnc_sasl -Dvnc_jpeg=$vnc_jpeg -Dvnc_png=$vnc_png \
cece116c 4533 -Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f -Dvirtiofsd=$virtiofsd \
8c6d4ff4 4534 -Dcapstone=$capstone -Dslirp=$slirp -Dfdt=$fdt -Dbrlapi=$brlapi \
9db405a3 4535 -Dcurl=$curl -Dglusterfs=$glusterfs -Dbzip2=$bzip2 -Dlibiscsi=$libiscsi \
30045c05 4536 -Dlibnfs=$libnfs -Diconv=$iconv -Dcurses=$curses -Dlibudev=$libudev\
c5b36c25 4537 -Drbd=$rbd -Dlzo=$lzo -Dsnappy=$snappy -Dlzfse=$lzfse -Dlibxml2=$libxml2 \
53c22b68 4538 -Dlibdaxctl=$libdaxctl -Dlibpmem=$libpmem -Dlinux_io_uring=$linux_io_uring \
05e391ae 4539 -Dgnutls=$gnutls -Dnettle=$nettle -Dgcrypt=$gcrypt -Dauth_pam=$auth_pam \
727c8bb8 4540 -Dzstd=$zstd -Dseccomp=$seccomp -Dvirtfs=$virtfs -Dcap_ng=$cap_ng \
587d59d6 4541 -Dattr=$attr -Ddefault_devices=$default_devices -Dvirglrenderer=$virglrenderer \
c8d5450b 4542 -Ddocs=$docs -Dsphinx_build=$sphinx_build -Dinstall_blobs=$blobs \
106ad1f9 4543 -Dvhost_user_blk_server=$vhost_user_blk_server -Dmultiprocess=$multiprocess \
46627f41 4544 -Dfuse=$fuse -Dfuse_lseek=$fuse_lseek -Dguest_agent_msi=$guest_agent_msi -Dbpf=$bpf\
332008e0 4545 $(if test "$default_feature" = no; then echo "-Dauto_features=disabled"; fi) \
ca50e523
PB
4546 -Dalsa=$alsa -Dcoreaudio=$coreaudio -Ddsound=$dsound -Djack=$jack -Doss=$oss \
4547 -Dpa=$pa -Daudio_drv_list=$audio_drv_list -Dtcg_interpreter=$tcg_interpreter \
ff66f3e5 4548 -Dtrace_backends=$trace_backends -Dtrace_file=$trace_file -Dlinux_aio=$linux_aio \
837b84b1 4549 -Dnetmap=$netmap -Dvde=$vde \
61d63097
PB
4550 "$@" $cross_arg "$PWD" "$source_path"
4551 }
4552 eval run_meson $meson_options
d77e90fa
PB
4553 if test "$?" -ne 0 ; then
4554 error_exit "meson setup failed"
4555 fi
699d3884
PB
4556else
4557 if test -f meson-private/cmd_line.txt; then
4558 # Adjust old command line options whose type was changed
4559 # Avoids having to use "setup --wipe" when Meson is upgraded
4560 perl -i -ne '
4561 s/^gettext = true$/gettext = auto/;
4562 s/^gettext = false$/gettext = disabled/;
654d6b04 4563 /^b_staticpic/ && next;
699d3884
PB
4564 print;' meson-private/cmd_line.txt
4565 fi
a5665051
PB
4566fi
4567
2d838d9b
AB
4568if test -n "${deprecated_features}"; then
4569 echo "Warning, deprecated features enabled."
a476b216 4570 echo "Please see docs/about/deprecated.rst"
2d838d9b
AB
4571 echo " features: ${deprecated_features}"
4572fi
4573
e0447a83
TH
4574# Create list of config switches that should be poisoned in common code...
4575# but filter out CONFIG_TCG and CONFIG_USER_ONLY which are special.
54b0306e
TH
4576target_configs_h=$(ls *-config-devices.h *-config-target.h 2>/dev/null)
4577if test -n "$target_configs_h" ; then
4578 sed -n -e '/CONFIG_TCG/d' -e '/CONFIG_USER_ONLY/d' \
4579 -e '/^#define / { s///; s/ .*//; s/^/#pragma GCC poison /p; }' \
4580 $target_configs_h | sort -u > config-poison.h
4581else
4582 :> config-poison.h
4583fi
e0447a83 4584
dc655404
MT
4585# Save the configure command line for later reuse.
4586cat <<EOD >config.status
4587#!/bin/sh
4588# Generated by configure.
4589# Run this file to recreate the current configuration.
4590# Compiler output produced by configure, useful for debugging
4591# configure, is in config.log if it exists.
4592EOD
e811da7f
DB
4593
4594preserve_env() {
4595 envname=$1
4596
4597 eval envval=\$$envname
4598
4599 if test -n "$envval"
4600 then
4601 echo "$envname='$envval'" >> config.status
4602 echo "export $envname" >> config.status
4603 else
4604 echo "unset $envname" >> config.status
4605 fi
4606}
4607
4608# Preserve various env variables that influence what
4609# features/build target configure will detect
4610preserve_env AR
4611preserve_env AS
4612preserve_env CC
4613preserve_env CPP
4614preserve_env CXX
4615preserve_env INSTALL
4616preserve_env LD
4617preserve_env LD_LIBRARY_PATH
4618preserve_env LIBTOOL
4619preserve_env MAKE
4620preserve_env NM
4621preserve_env OBJCOPY
4622preserve_env PATH
4623preserve_env PKG_CONFIG
4624preserve_env PKG_CONFIG_LIBDIR
4625preserve_env PKG_CONFIG_PATH
4626preserve_env PYTHON
e811da7f
DB
4627preserve_env SDL2_CONFIG
4628preserve_env SMBD
4629preserve_env STRIP
4630preserve_env WINDRES
4631
dc655404 4632printf "exec" >>config.status
a5665051 4633for i in "$0" "$@"; do
835af899 4634 test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status
a5665051 4635done
cf7cc929 4636echo ' "$@"' >>config.status
dc655404
MT
4637chmod +x config.status
4638
8cd05ab6 4639rm -r "$TMPDIR1"