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