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