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