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