blob: 51eae49daf7d9ef5debd4d34cbcf08d799c76542 [file] [log] [blame]
bellard7d132992003-03-06 23:23:54 +00001#!/bin/sh
2#
bellard3ef693a2003-03-23 20:17:16 +00003# qemu configure script (c) 2003 Fabrice Bellard
bellard7d132992003-03-06 23:23:54 +00004#
Peter Maydell8cd05ab2014-05-23 17:07:24 +01005
Cornelia Huck99519e62014-05-28 12:39:17 +02006# 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
John Snow5e4dfd32015-10-28 13:56:40 -040011# Don't allow CCACHE, if present, to use cached results of compile tests!
12export CCACHE_RECACHE=yes
13
Daniel P. Berrangédedad022020-08-21 12:22:04 +020014# 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
Peter Maydell8cd05ab2014-05-23 17:07:24 +010063# 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
bellard7d132992003-03-06 23:23:54 +000074fi
75
Peter Maydell8cd05ab2014-05-23 17:07:24 +010076TMPB="qemu-conf"
77TMPC="${TMPDIR1}/${TMPB}.c"
Don Slutz66518bf2014-01-02 21:12:46 -050078TMPO="${TMPDIR1}/${TMPB}.o"
Peter Maydell9c83ffd2014-02-25 18:27:49 +000079TMPCXX="${TMPDIR1}/${TMPB}.cxx"
Peter Maydell8cd05ab2014-05-23 17:07:24 +010080TMPE="${TMPDIR1}/${TMPB}.exe"
Emilio G. Cota26fffe22018-10-21 13:56:29 -040081TMPTXT="${TMPDIR1}/${TMPB}.txt"
bellard7d132992003-03-06 23:23:54 +000082
Gerd Hoffmannda1d85e2010-04-23 13:44:10 +020083rm -f config.log
malc9ac81bb2008-11-29 20:09:56 +000084
Peter Maydellb48e3612011-11-23 17:26:44 +000085# Print a helpful header at the top of config.log
86echo "# QEMU configure log $(date)" >> config.log
Peter Maydell979ae162012-03-07 12:16:29 +000087printf "# Configured with:" >> config.log
88printf " '%s'" "$0" "$@" >> config.log
89echo >> config.log
Peter Maydellb48e3612011-11-23 17:26:44 +000090echo "#" >> config.log
91
Paolo Bonzini835af892020-09-08 13:20:45 +020092quote_sh() {
93 printf "%s" "$1" | sed "s,','\\\\'',g; s,.*,'&',"
94}
95
Paolo Bonzinid880a3b2017-07-03 16:58:28 +020096print_error() {
97 (echo
Peter Maydell76ad07a2013-04-08 12:11:26 +010098 echo "ERROR: $1"
99 while test -n "$2"; do
100 echo " $2"
101 shift
102 done
Paolo Bonzinid880a3b2017-07-03 16:58:28 +0200103 echo) >&2
104}
105
106error_exit() {
107 print_error "$@"
Peter Maydell76ad07a2013-04-08 12:11:26 +0100108 exit 1
109}
110
Peter Maydell9c83ffd2014-02-25 18:27:49 +0000111do_compiler() {
112 # Run the compiler, capturing its output to the log. First argument
113 # is compiler binary to execute.
David CARLIER630d86b2020-07-18 14:19:10 +0100114 compiler="$1"
Peter Maydell9c83ffd2014-02-25 18:27:49 +0000115 shift
Ian Jackson8bbe05d2017-09-25 16:41:03 +0100116 if test -n "$BASH_VERSION"; then eval '
117 echo >>config.log "
118funcs: ${FUNCNAME[*]}
119lines: ${BASH_LINENO[*]}"
120 '; fi
Peter Maydell9c83ffd2014-02-25 18:27:49 +0000121 echo $compiler "$@" >> config.log
122 $compiler "$@" >> config.log 2>&1 || return $?
Peter Maydell8dc38a72012-07-18 15:10:28 +0100123 # Test passed. If this is an --enable-werror build, rerun
124 # the test with -Werror and bail out if it fails. This
125 # makes warning-generating-errors in configure test code
126 # obvious to developers.
127 if test "$werror" != "yes"; then
128 return 0
129 fi
130 # Don't bother rerunning the compile if we were already using -Werror
131 case "$*" in
132 *-Werror*)
133 return 0
134 ;;
135 esac
Peter Maydell9c83ffd2014-02-25 18:27:49 +0000136 echo $compiler -Werror "$@" >> config.log
137 $compiler -Werror "$@" >> config.log 2>&1 && return $?
Peter Maydell76ad07a2013-04-08 12:11:26 +0100138 error_exit "configure test passed without -Werror but failed with -Werror." \
139 "This is probably a bug in the configure script. The failing command" \
140 "will be at the bottom of config.log." \
141 "You can run configure with --disable-werror to bypass this check."
Peter Maydell8dc38a72012-07-18 15:10:28 +0100142}
143
Peter Maydell9c83ffd2014-02-25 18:27:49 +0000144do_cc() {
Paolo Bonzini4dba2782021-09-29 17:14:43 +0200145 do_compiler "$cc" $CPU_CFLAGS "$@"
Peter Maydell9c83ffd2014-02-25 18:27:49 +0000146}
147
148do_cxx() {
Paolo Bonzini4dba2782021-09-29 17:14:43 +0200149 do_compiler "$cxx" $CPU_CFLAGS "$@"
Peter Maydell9c83ffd2014-02-25 18:27:49 +0000150}
151
Richard Henderson00849b92020-06-17 13:13:06 -0700152# Append $2 to the variable named $1, with space separation
153add_to() {
154 eval $1=\${$1:+\"\$$1 \"}\$2
155}
156
Peter Maydell9c83ffd2014-02-25 18:27:49 +0000157update_cxxflags() {
158 # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
159 # options which some versions of GCC's C++ compiler complain about
160 # because they only make sense for C programs.
Paolo Bonzinide38c0c2021-11-08 08:58:23 +0100161 QEMU_CXXFLAGS="-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS"
Richard Henderson8a9d3d52021-06-14 16:31:36 -0700162 CONFIGURE_CXXFLAGS=$(echo "$CONFIGURE_CFLAGS" | sed s/-std=gnu11/-std=gnu++11/)
Peter Maydell9c83ffd2014-02-25 18:27:49 +0000163 for arg in $QEMU_CFLAGS; do
164 case $arg in
165 -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
166 -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
167 ;;
168 *)
169 QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
170 ;;
171 esac
172 done
173}
174
Juan Quintela52166aa2009-08-03 14:46:03 +0200175compile_object() {
John Snowfd0e6052015-03-25 18:57:39 -0400176 local_cflags="$1"
Paolo Bonzinia2866662021-11-05 10:09:26 +0100177 do_cc $CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
Juan Quintela52166aa2009-08-03 14:46:03 +0200178}
179
180compile_prog() {
181 local_cflags="$1"
182 local_ldflags="$2"
Paolo Bonzinia2866662021-11-05 10:09:26 +0100183 do_cc $CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC \
184 $LDFLAGS $EXTRA_LDFLAGS $CONFIGURE_LDFLAGS $QEMU_LDFLAGS $local_ldflags
Juan Quintela52166aa2009-08-03 14:46:03 +0200185}
186
Paolo Bonzini11568d62010-12-23 11:43:58 +0100187# symbolically link $1 to $2. Portable version of "ln -sf".
188symlink() {
Stefan Weil72b8b5a2012-03-19 13:20:47 +0100189 rm -rf "$2"
Anthony Liguoriec5b06d2012-06-06 16:57:00 +0800190 mkdir -p "$(dirname "$2")"
Stefan Weil72b8b5a2012-03-19 13:20:47 +0100191 ln -s "$1" "$2"
Paolo Bonzini11568d62010-12-23 11:43:58 +0100192}
193
Loïc Minier0dba6192010-01-28 21:26:51 +0000194# check whether a command is available to this shell (may be either an
195# executable or a builtin)
196has() {
197 type "$1" >/dev/null 2>&1
198}
199
Marc-André Lureau0a01d762019-08-21 11:21:16 +0400200version_ge () {
Alex Bennée2df52b92021-02-02 13:39:52 +0000201 local_ver1=$(expr "$1" : '\([0-9.]*\)' | tr . ' ')
202 local_ver2=$(echo "$2" | tr . ' ')
Marc-André Lureau0a01d762019-08-21 11:21:16 +0400203 while true; do
204 set x $local_ver1
205 local_first=${2-0}
Stefano Garzarellac44a33e2020-08-21 22:35:58 +0200206 # 'shift 2' if $2 is set, or 'shift' if $2 is not set
207 shift ${2:+2}
Marc-André Lureau0a01d762019-08-21 11:21:16 +0400208 local_ver1=$*
209 set x $local_ver2
210 # the second argument finished, the first must be greater or equal
211 test $# = 1 && return 0
212 test $local_first -lt $2 && return 1
213 test $local_first -gt $2 && return 0
Stefano Garzarellac44a33e2020-08-21 22:35:58 +0200214 shift ${2:+2}
Marc-André Lureau0a01d762019-08-21 11:21:16 +0400215 local_ver2=$*
216 done
217}
218
Paolo Bonzini3b6b7552012-09-17 11:59:41 +0200219glob() {
220 eval test -z '"${1#'"$2"'}"'
221}
222
Christian Borntraegere9a35912017-08-23 12:16:23 +0200223ld_has() {
224 $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
225}
226
Antonio Ospite4ace32e2019-05-26 16:47:47 +0200227if printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]";
228then
229 error_exit "main directory cannot contain spaces nor colons"
230fi
231
Antonio Ospite14211822019-05-26 16:47:46 +0200232# default parameters
Juan Quintela2ff6b912009-08-03 14:45:55 +0200233cpu=""
Michael S. Tsirkina31a8642013-07-24 18:56:03 +0300234iasl="iasl"
bellard1e43adf2003-09-30 20:54:24 +0000235interp_prefix="/usr/gnemul/qemu-%M"
bellard43ce4df2003-06-09 19:53:12 +0000236static="no"
Joelle van Dyne3812c0c2021-01-25 17:24:48 -0800237cross_compile="no"
bellard7d132992003-03-06 23:23:54 +0000238cross_prefix=""
Paolo Bonzini87430d52021-10-07 15:06:09 +0200239audio_drv_list="default"
Fam Zhengb64ec4e2013-05-29 19:35:40 +0800240block_drv_rw_whitelist=""
241block_drv_ro_whitelist=""
Kevin Wolfe5f05f82021-07-09 18:41:41 +0200242block_drv_whitelist_tools="no"
Peter Maydelle49d0212012-12-07 15:39:13 +0000243host_cc="cc"
Michael Roth957f1f92011-08-11 15:38:12 -0500244libs_qga=""
Gerd Hoffmann5bc62e02012-02-08 13:54:13 +0100245debug_info="yes"
Daniele Buonocdad7812020-12-04 18:06:11 -0500246lto="false"
Steven Noonan63678e12014-03-28 17:19:02 +0100247stack_protector=""
Daniele Buono1e4f6062020-05-29 16:51:21 -0400248safe_stack=""
Alex Bennéeafc3a8f2019-11-28 16:35:24 +0100249use_containers="yes"
Alex Bennéef2385392020-04-30 20:01:14 +0100250gdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
aliguoriac0df512008-12-29 17:14:15 +0000251
Daniel P. Berrange92712822017-09-29 11:11:58 +0100252if test -e "$source_path/.git"
253then
Dan Streetman7d7dbf92021-01-19 12:20:46 -0500254 git_submodules_action="update"
Daniel P. Berrange92712822017-09-29 11:11:58 +0100255else
Dan Streetman7d7dbf92021-01-19 12:20:46 -0500256 git_submodules_action="ignore"
Daniel P. Berrange92712822017-09-29 11:11:58 +0100257fi
Paolo Bonzini2d652f22021-05-12 09:21:56 +0200258
259git_submodules="ui/keycodemapdb"
Daniel P. Berrangecc84d632017-10-20 15:02:43 +0100260git="git"
aliguoriac0df512008-12-29 17:14:15 +0000261
Stefan Weilafb63eb2012-09-26 22:04:38 +0200262# Don't accept a target_list environment variable.
263unset target_list
Alex Bennée447e1332019-03-19 11:59:12 +0000264unset target_list_exclude
Paolo Bonzini377529c2010-12-23 11:43:50 +0100265
266# Default value for a variable defining feature "foo".
267# * foo="no" feature will only be used if --enable-foo arg is given
268# * foo="" feature will be searched for, and if found, will be used
269# unless --disable-foo is given
270# * foo="yes" this value will only be set by --enable-foo flag.
271# feature will searched for,
272# if not found, configure exits with error
273#
274# Always add --enable-foo and --disable-foo command line args.
275# Distributions want to ensure that several features are compiled in, and it
276# is impossible without a --enable-foo that exits if a feature is not found.
277
Alex Bennéec87ea112020-12-10 19:04:13 +0000278default_feature=""
279# parse CC options second
280for opt do
281 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
282 case "$opt" in
283 --without-default-features)
284 default_feature="no"
285 ;;
286 esac
287done
288
Paolo Bonzinia2866662021-11-05 10:09:26 +0100289EXTRA_CFLAGS=""
290EXTRA_CXXFLAGS=""
291EXTRA_LDFLAGS=""
292
Alex Bennéec87ea112020-12-10 19:04:13 +0000293xen_ctrl_version="$default_feature"
Alex Bennéec87ea112020-12-10 19:04:13 +0000294xfs="$default_feature"
Alex Bennéec87ea112020-12-10 19:04:13 +0000295membarrier="$default_feature"
Thomas Huth0848f8a2021-07-13 11:31:55 +0200296vhost_kernel="$default_feature"
Alex Bennéec87ea112020-12-10 19:04:13 +0000297vhost_net="$default_feature"
298vhost_crypto="$default_feature"
299vhost_scsi="$default_feature"
300vhost_vsock="$default_feature"
Stefan Hajnoczid88618f2020-11-10 17:11:21 +0000301vhost_user="no"
Alex Bennéec87ea112020-12-10 19:04:13 +0000302vhost_user_fs="$default_feature"
Thomas Huth0848f8a2021-07-13 11:31:55 +0200303vhost_vdpa="$default_feature"
Alex Bennéec87ea112020-12-10 19:04:13 +0000304rdma="$default_feature"
305pvrdma="$default_feature"
Paolo Bonzini377529c2010-12-23 11:43:50 +0100306gprof="no"
307debug_tcg="no"
Paolo Bonzini377529c2010-12-23 11:43:50 +0100308debug="no"
Marc-André Lureau247724c2018-01-16 16:11:51 +0100309sanitizers="no"
Lingfeng Yang0aebab02020-06-12 20:02:23 +0100310tsan="no"
Alex Bennéec87ea112020-12-10 19:04:13 +0000311fortify_source="$default_feature"
Paolo Bonzini377529c2010-12-23 11:43:50 +0100312strip_opt="yes"
Paolo Bonzini377529c2010-12-23 11:43:50 +0100313mingw32="no"
Blue Swirl1d728c32012-05-01 18:45:39 +0000314gcov="no"
Miroslav Rezaninac7328272021-03-31 10:18:45 +0200315EXESUF=""
Fam Zheng17969262014-02-10 14:48:56 +0800316modules="no"
Christian Ehrhardtbd83c862020-03-10 15:58:06 +0100317module_upgrades="no"
Paolo Bonzini377529c2010-12-23 11:43:50 +0100318prefix="/usr/local"
Marc-André Lureau10ff82d2020-08-26 15:04:13 +0400319qemu_suffix="qemu"
Paolo Bonzini377529c2010-12-23 11:43:50 +0100320bsd="no"
321linux="no"
322solaris="no"
323profiler="no"
Paolo Bonzini377529c2010-12-23 11:43:50 +0100324softmmu="yes"
325linux_user="no"
Paolo Bonzini377529c2010-12-23 11:43:50 +0100326bsd_user="no"
Paolo Bonzini377529c2010-12-23 11:43:50 +0100327pkgversion=""
Avi Kivity40d64442011-11-15 20:12:17 +0200328pie=""
Paolo Bonzini3556c232013-05-10 14:16:40 +0200329qom_cast_debug="yes"
Paolo Bonzinibaf86d62016-01-07 16:55:31 +0300330trace_backends="log"
Paolo Bonzini377529c2010-12-23 11:43:50 +0100331trace_file="trace"
Alex Bennéec87ea112020-12-10 19:04:13 +0000332opengl="$default_feature"
Richard Henderson5dd89902017-07-18 18:40:18 -1000333cpuid_h="no"
Alex Bennéec87ea112020-12-10 19:04:13 +0000334avx2_opt="$default_feature"
Alex Bennéec87ea112020-12-10 19:04:13 +0000335guest_agent="$default_feature"
Tomoki Sekiyamad9840e22013-08-07 11:40:03 -0400336guest_agent_with_vss="no"
Michael Roth50cbebb2015-07-07 18:10:09 -0500337guest_agent_ntddscsi="no"
Alex Bennéec87ea112020-12-10 19:04:13 +0000338vss_win32_sdk="$default_feature"
Tomoki Sekiyamad9840e22013-08-07 11:40:03 -0400339win_sdk="no"
Alex Bennéec87ea112020-12-10 19:04:13 +0000340want_tools="$default_feature"
Alex Barcelo519175a2012-02-28 12:25:50 +0100341coroutine=""
Alex Bennéec87ea112020-12-10 19:04:13 +0000342coroutine_pool="$default_feature"
Peter Lieven7d992e42016-09-27 11:58:45 +0200343debug_stack_usage="no"
Longpeng(Mike)f0d92b52017-07-14 14:04:05 -0400344crypto_afalg="no"
Daniel P. Berrangea1c5e942016-06-06 10:05:06 +0100345tls_priority="NORMAL"
Alex Bennéec87ea112020-12-10 19:04:13 +0000346tpm="$default_feature"
Alex Bennéec87ea112020-12-10 19:04:13 +0000347live_block_migration=${default_feature:-yes}
348numa="$default_feature"
Alex Bennéec87ea112020-12-10 19:04:13 +0000349replication=${default_feature:-yes}
350bochs=${default_feature:-yes}
351cloop=${default_feature:-yes}
352dmg=${default_feature:-yes}
353qcow1=${default_feature:-yes}
354vdi=${default_feature:-yes}
355vvfat=${default_feature:-yes}
356qed=${default_feature:-yes}
357parallels=${default_feature:-yes}
Paolo Bonziniba59fb72018-06-13 14:23:08 +0200358debug_mutex="no"
Alex Bennéeba4dd2a2021-07-09 15:29:57 +0100359plugins="$default_feature"
Marek Marczykowski-Góreckib767d252020-05-20 15:20:23 +0200360rng_none="no"
Alex Bennéec87ea112020-12-10 19:04:13 +0000361secret_keyring="$default_feature"
Paolo Bonzinia5665052019-06-10 12:05:14 +0200362meson=""
Paolo Bonzini3b4da132021-10-07 15:08:29 +0200363meson_args=""
Paolo Bonzini48328882020-08-26 08:04:15 +0200364ninja=""
Paolo Bonzini3b4da132021-10-07 15:08:29 +0200365gio="$default_feature"
Paolo Bonzinia5665052019-06-10 12:05:14 +0200366skip_meson=no
Joelle van Dyneb8e0c492021-03-15 11:03:41 -0700367slirp_smbd="$default_feature"
Paolo Bonzini377529c2010-12-23 11:43:50 +0100368
Paolo Bonzini3b4da132021-10-07 15:08:29 +0200369# The following Meson options are handled manually (still they
370# are included in the automatically generated help message)
371
372# 1. Track which submodules are needed
373capstone="auto"
374fdt="auto"
375slirp="auto"
376
377# 2. Support --with/--without option
378default_devices="true"
379
380# 3. Automatically enable/disable other options
381tcg="enabled"
382cfi="false"
383
384# 4. Detection partly done in configure
385xen=${default_feature:+disabled}
Peter Maydell898be3e2017-03-21 14:31:57 +0000386
Alex Bennéec87ea112020-12-10 19:04:13 +0000387# parse CC options second
aliguoriac0df512008-12-29 17:14:15 +0000388for opt do
Stefan Weil89138852016-05-16 15:10:20 +0200389 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
aliguoriac0df512008-12-29 17:14:15 +0000390 case "$opt" in
391 --cross-prefix=*) cross_prefix="$optarg"
Joelle van Dyne3812c0c2021-01-25 17:24:48 -0800392 cross_compile="yes"
aliguoriac0df512008-12-29 17:14:15 +0000393 ;;
Paolo Bonzini3d8df642010-12-23 11:43:48 +0100394 --cc=*) CC="$optarg"
aliguoriac0df512008-12-29 17:14:15 +0000395 ;;
Tomoki Sekiyama83f73fc2013-08-07 11:39:36 -0400396 --cxx=*) CXX="$optarg"
397 ;;
Juan Quintela2ff6b912009-08-03 14:45:55 +0200398 --cpu=*) cpu="$optarg"
399 ;;
Paolo Bonzinia2866662021-11-05 10:09:26 +0100400 --extra-cflags=*)
401 EXTRA_CFLAGS="$EXTRA_CFLAGS $optarg"
402 EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg"
403 ;;
404 --extra-cxxflags=*) EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg"
Juan Quintelae2a2ed02009-08-03 14:46:02 +0200405 ;;
Paolo Bonzinia2866662021-11-05 10:09:26 +0100406 --extra-ldflags=*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS $optarg"
Juan Quintelae2a2ed02009-08-03 14:46:02 +0200407 ;;
Gerd Hoffmann5bc62e02012-02-08 13:54:13 +0100408 --enable-debug-info) debug_info="yes"
409 ;;
410 --disable-debug-info) debug_info="no"
411 ;;
Alex Bennéed75402b2018-04-04 20:27:05 +0100412 --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
413 ;;
Alex Bennéed422b2b2018-04-13 11:07:58 +0100414 --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-flags-}; cc_arch=${cc_arch%%=*}
415 eval "cross_cc_cflags_${cc_arch}=\$optarg"
Paolo Bonzini2038f8c2019-08-07 16:35:23 +0200416 cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}"
Alex Bennéed422b2b2018-04-13 11:07:58 +0100417 ;;
Alex Bennéed75402b2018-04-04 20:27:05 +0100418 --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
Paolo Bonzini2038f8c2019-08-07 16:35:23 +0200419 cc_archs="$cc_archs $cc_arch"
Alex Bennéed75402b2018-04-04 20:27:05 +0100420 eval "cross_cc_${cc_arch}=\$optarg"
Paolo Bonzini2038f8c2019-08-07 16:35:23 +0200421 cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}"
Alex Bennéed75402b2018-04-04 20:27:05 +0100422 ;;
aliguoriac0df512008-12-29 17:14:15 +0000423 esac
424done
aliguoriac0df512008-12-29 17:14:15 +0000425# OS specific
426# Using uname is really, really broken. Once we have the right set of checks
Stefan Weil93148aa2012-02-26 18:46:12 +0100427# we can eliminate its usage altogether.
aliguoriac0df512008-12-29 17:14:15 +0000428
Peter Maydelle49d0212012-12-07 15:39:13 +0000429# Preferred compiler:
430# ${CC} (if set)
431# ${cross_prefix}gcc (if cross-prefix specified)
432# system compiler
433if test -z "${CC}${cross_prefix}"; then
434 cc="$host_cc"
435else
436 cc="${CC-${cross_prefix}gcc}"
437fi
438
Tomoki Sekiyama83f73fc2013-08-07 11:39:36 -0400439if test -z "${CXX}${cross_prefix}"; then
440 cxx="c++"
441else
442 cxx="${CXX-${cross_prefix}g++}"
443fi
444
Stuart Yoderb3198cc2011-08-04 17:10:08 -0500445ar="${AR-${cross_prefix}ar}"
Richard Hendersoncdbd7272016-07-07 21:49:36 -0700446as="${AS-${cross_prefix}as}"
Richard Henderson5f6f0e22016-06-23 10:39:18 -0700447ccas="${CCAS-$cc}"
Blue Swirl3dd46c72013-01-05 10:10:27 +0000448cpp="${CPP-$cc -E}"
Stuart Yoderb3198cc2011-08-04 17:10:08 -0500449objcopy="${OBJCOPY-${cross_prefix}objcopy}"
450ld="${LD-${cross_prefix}ld}"
Alistair Francis9f81aeb2017-11-07 17:10:46 -0800451ranlib="${RANLIB-${cross_prefix}ranlib}"
Stefan Weil4852ee92014-09-18 21:55:08 +0200452nm="${NM-${cross_prefix}nm}"
Stuart Yoderb3198cc2011-08-04 17:10:08 -0500453strip="${STRIP-${cross_prefix}strip}"
454windres="${WINDRES-${cross_prefix}windres}"
Sergei Trofimovich17884d72012-01-31 22:03:45 +0300455pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
456query_pkg_config() {
457 "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
458}
459pkg_config=query_pkg_config
Dave Airlie47c03742013-12-10 14:05:51 +1000460sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
aliguoriac0df512008-12-29 17:14:15 +0000461
Michael S. Tsirkinbe17dc92009-11-11 13:50:09 +0200462# default flags for all hosts
Peter Maydell2d315152016-09-12 14:10:08 +0100463# We use -fwrapv to tell the compiler that we require a C dialect where
464# left shift of signed integers is well defined and has the expected
465# 2s-complement style results. (Both clang and gcc agree that it
466# provides these semantics.)
Paolo Bonzinide38c0c2021-11-08 08:58:23 +0100467QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv"
Paolo Bonzini086d5f72020-02-03 15:22:17 +0100468QEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
Kevin Wolfc95e3082013-02-22 21:08:51 +0100469QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
Michael S. Tsirkinbe17dc92009-11-11 13:50:09 +0200470QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
Paolo Bonzini5770e8a2020-09-23 05:26:15 -0400471
Paolo Bonzinide38c0c2021-11-08 08:58:23 +0100472QEMU_LDFLAGS=
473
Paolo Bonzini5770e8a2020-09-23 05:26:15 -0400474# Flags that are needed during configure but later taken care of by Meson
Richard Henderson8a9d3d52021-06-14 16:31:36 -0700475CONFIGURE_CFLAGS="-std=gnu11 -Wall"
Paolo Bonzini5770e8a2020-09-23 05:26:15 -0400476CONFIGURE_LDFLAGS=
Paolo Bonzini086d5f72020-02-03 15:22:17 +0100477
Michael S. Tsirkinbe17dc92009-11-11 13:50:09 +0200478
aliguoriac0df512008-12-29 17:14:15 +0000479check_define() {
480cat > $TMPC <<EOF
481#if !defined($1)
Peter Maydellfd786e12011-11-23 17:26:43 +0000482#error $1 not defined
aliguoriac0df512008-12-29 17:14:15 +0000483#endif
484int main(void) { return 0; }
485EOF
Juan Quintela52166aa2009-08-03 14:46:03 +0200486 compile_object
aliguoriac0df512008-12-29 17:14:15 +0000487}
488
Gerd Hoffmann307119e2015-06-10 09:07:35 +0200489check_include() {
490cat > $TMPC <<EOF
491#include <$1>
492int main(void) { return 0; }
493EOF
494 compile_object
495}
496
John Snow93b25862015-03-25 18:57:37 -0400497write_c_skeleton() {
498 cat > $TMPC <<EOF
499int main(void) { return 0; }
500EOF
501}
502
Peter Maydellbbea4052012-08-14 15:35:34 +0100503if check_define __linux__ ; then
Paolo Bonziniba7c60c2021-11-08 14:47:54 +0100504 targetos=linux
Peter Maydellbbea4052012-08-14 15:35:34 +0100505elif check_define _WIN32 ; then
Paolo Bonziniba7c60c2021-11-08 14:47:54 +0100506 targetos=windows
Peter Maydellbbea4052012-08-14 15:35:34 +0100507elif check_define __OpenBSD__ ; then
Paolo Bonziniba7c60c2021-11-08 14:47:54 +0100508 targetos=openbsd
Peter Maydellbbea4052012-08-14 15:35:34 +0100509elif check_define __sun__ ; then
Paolo Bonziniba7c60c2021-11-08 14:47:54 +0100510 targetos=sunos
Peter Maydellbbea4052012-08-14 15:35:34 +0100511elif check_define __HAIKU__ ; then
Paolo Bonziniba7c60c2021-11-08 14:47:54 +0100512 targetos=haiku
Peter Maydell951fedf2017-07-13 16:15:32 +0100513elif check_define __FreeBSD__ ; then
Paolo Bonziniba7c60c2021-11-08 14:47:54 +0100514 targetos=freebsd
Peter Maydell951fedf2017-07-13 16:15:32 +0100515elif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
Paolo Bonziniba7c60c2021-11-08 14:47:54 +0100516 targetos=gnu/kfreebsd
Peter Maydell951fedf2017-07-13 16:15:32 +0100517elif check_define __DragonFly__ ; then
Paolo Bonziniba7c60c2021-11-08 14:47:54 +0100518 targetos=dragonfly
Peter Maydell951fedf2017-07-13 16:15:32 +0100519elif check_define __NetBSD__; then
Paolo Bonziniba7c60c2021-11-08 14:47:54 +0100520 targetos=netbsd
Peter Maydell951fedf2017-07-13 16:15:32 +0100521elif check_define __APPLE__; then
Paolo Bonziniba7c60c2021-11-08 14:47:54 +0100522 targetos=darwin
Peter Maydellbbea4052012-08-14 15:35:34 +0100523else
Peter Maydell951fedf2017-07-13 16:15:32 +0100524 # This is a fatal error, but don't report it yet, because we
525 # might be going to just print the --help text, or it might
526 # be the result of a missing compiler.
Paolo Bonziniba7c60c2021-11-08 14:47:54 +0100527 targetos=bogus
Peter Maydellbbea4052012-08-14 15:35:34 +0100528fi
529
Paolo Bonzini65eff012021-11-08 22:52:35 +0100530# OS specific
531
Peter Maydellbbea4052012-08-14 15:35:34 +0100532case $targetos in
Paolo Bonzini65eff012021-11-08 22:52:35 +0100533windows)
534 mingw32="yes"
535 plugins="no"
536 pie="no"
537;;
538gnu/kfreebsd)
539 bsd="yes"
540;;
541freebsd)
542 bsd="yes"
543 bsd_user="yes"
544 make="${MAKE-gmake}"
545 # needed for kinfo_getvmmap(3) in libutil.h
546;;
547dragonfly)
548 bsd="yes"
549 make="${MAKE-gmake}"
550;;
551netbsd)
552 bsd="yes"
553 make="${MAKE-gmake}"
554;;
555openbsd)
556 bsd="yes"
557 make="${MAKE-gmake}"
558;;
559darwin)
560 bsd="yes"
561 darwin="yes"
562 # Disable attempts to use ObjectiveC features in os/object.h since they
563 # won't work when we're compiling with gcc as a C compiler.
564 QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
565;;
Paolo Bonziniba7c60c2021-11-08 14:47:54 +0100566sunos)
Paolo Bonzini65eff012021-11-08 22:52:35 +0100567 solaris="yes"
568 make="${MAKE-gmake}"
569 smbd="${SMBD-/usr/sfw/sbin/smbd}"
570# needed for CMSG_ macros in sys/socket.h
571 QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
572# needed for TIOCWIN* defines in termios.h
573 QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
Stefan Weil89138852016-05-16 15:10:20 +0200574 # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
Paolo Bonzini65eff012021-11-08 22:52:35 +0100575 # Note that this check is broken for cross-compilation: if you're
576 # cross-compiling to one of these OSes then you'll need to specify
577 # the correct CPU with the --cpu option.
Peter Maydellbbea4052012-08-14 15:35:34 +0100578 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
579 cpu="x86_64"
580 fi
Paolo Bonzini65eff012021-11-08 22:52:35 +0100581;;
582haiku)
583 pie="no"
584 QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE -fPIC $QEMU_CFLAGS"
585;;
586linux)
587 linux="yes"
588 linux_user="yes"
589 vhost_user=${default_feature:-yes}
590;;
Peter Maydellbbea4052012-08-14 15:35:34 +0100591esac
592
Juan Quintela2ff6b912009-08-03 14:45:55 +0200593if test ! -z "$cpu" ; then
594 # command line argument
595 :
596elif check_define __i386__ ; then
aliguoriac0df512008-12-29 17:14:15 +0000597 cpu="i386"
598elif check_define __x86_64__ ; then
Richard Hendersonc72b26e2013-08-20 12:20:05 -0700599 if check_define __ILP32__ ; then
600 cpu="x32"
601 else
602 cpu="x86_64"
603 fi
blueswir13aa9bd62008-12-31 16:55:26 +0000604elif check_define __sparc__ ; then
blueswir13aa9bd62008-12-31 16:55:26 +0000605 if check_define __arch64__ ; then
606 cpu="sparc64"
607 else
608 cpu="sparc"
609 fi
malcfdf7ed92009-01-14 18:39:52 +0000610elif check_define _ARCH_PPC ; then
611 if check_define _ARCH_PPC64 ; then
Richard Hendersonf8378ac2019-05-01 15:38:18 -0700612 if check_define _LITTLE_ENDIAN ; then
613 cpu="ppc64le"
614 else
615 cpu="ppc64"
616 fi
malcfdf7ed92009-01-14 18:39:52 +0000617 else
618 cpu="ppc"
619 fi
Aurelien Jarnoafa05232009-10-17 14:17:47 +0200620elif check_define __mips__ ; then
621 cpu="mips"
Aurelien Jarnod66ed0e2010-06-13 12:28:21 +0200622elif check_define __s390__ ; then
623 if check_define __s390x__ ; then
624 cpu="s390x"
625 else
626 cpu="s390"
627 fi
Alistair Francisc4f80542018-12-19 19:20:19 +0000628elif check_define __riscv ; then
Richard Hendersonba0e7332021-09-17 11:08:09 -0700629 cpu="riscv"
Peter Maydell21d89f82011-11-30 10:57:48 +0100630elif check_define __arm__ ; then
631 cpu="arm"
Claudio Fontana1f080312013-06-12 16:20:23 +0100632elif check_define __aarch64__ ; then
633 cpu="aarch64"
aliguoriac0df512008-12-29 17:14:15 +0000634else
Stefan Weil89138852016-05-16 15:10:20 +0200635 cpu=$(uname -m)
aliguoriac0df512008-12-29 17:14:15 +0000636fi
637
Paolo Bonzini823eb012021-11-08 14:18:17 +0100638# Normalise host CPU name, set multilib cflags
Peter Maydell359bc952011-12-24 13:07:25 +0000639# Note that this case should only have supported host CPUs, not guests.
bellard7d132992003-03-06 23:23:54 +0000640case "$cpu" in
Paolo Bonzinie4da0e32021-11-09 09:23:56 +0100641 armv*b|armv*l|arm)
642 cpu="arm" ;;
643
bellard7d132992003-03-06 23:23:54 +0000644 i386|i486|i586|i686|i86pc|BePC)
bellard97a847b2003-08-10 21:36:04 +0000645 cpu="i386"
Paolo Bonzinie4da0e32021-11-09 09:23:56 +0100646 CPU_CFLAGS="-m32" ;;
647 x32)
Paolo Bonzini4da270b2021-11-09 09:36:10 +0100648 cpu="x86_64"
Paolo Bonzinie4da0e32021-11-09 09:23:56 +0100649 CPU_CFLAGS="-mx32" ;;
aurel32aaa5fa12008-04-11 22:04:22 +0000650 x86_64|amd64)
651 cpu="x86_64"
Paolo Bonzinie4da0e32021-11-09 09:23:56 +0100652 # ??? 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
Aurelien Jarnoafa05232009-10-17 14:17:47 +0200657 mips*)
Paolo Bonzinie4da0e32021-11-09 09:23:56 +0100658 cpu="mips" ;;
659
660 ppc)
661 CPU_CFLAGS="-m32" ;;
662 ppc64)
Paolo Bonzinid8ff8922021-11-09 09:18:20 +0100663 CPU_CFLAGS="-m64 -mbig" ;;
Paolo Bonzinie4da0e32021-11-09 09:23:56 +0100664 ppc64le)
Paolo Bonzinid8ff8922021-11-09 09:18:20 +0100665 cpu="ppc64"
666 CPU_CFLAGS="-m64 -mlittle" ;;
Paolo Bonzinie4da0e32021-11-09 09:23:56 +0100667
668 s390)
Paolo Bonzini823eb012021-11-08 14:18:17 +0100669 CPU_CFLAGS="-m31" ;;
Paolo Bonzinie4da0e32021-11-09 09:23:56 +0100670 s390x)
671 CPU_CFLAGS="-m64" ;;
672
blueswir131422552007-04-16 18:27:06 +0000673 sparc|sun4[cdmuv])
bellardae228532003-05-13 18:59:59 +0000674 cpu="sparc"
Paolo Bonzinie4da0e32021-11-09 09:23:56 +0100675 CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc" ;;
676 sparc64)
677 CPU_CFLAGS="-m64 -mcpu=ultrasparc" ;;
bellard7d132992003-03-06 23:23:54 +0000678esac
Juan Quintelae2d52ad2009-08-12 18:20:24 +0200679
Paolo Bonzini0db4a062010-12-23 11:43:49 +0100680: ${make=${MAKE-make}}
Paolo Bonzinib6daf4d2020-09-01 06:38:04 -0400681
Daniel P. Berrangéfaf44142019-03-27 17:07:01 +0000682# We prefer python 3.x. A bare 'python' is traditionally
683# python 2.x, but some distros have it as python 3.x, so
Eduardo Habkostddf90692019-10-16 19:42:37 -0300684# we check that too
Daniel P. Berrangéfaf44142019-03-27 17:07:01 +0000685python=
Marc-André Lureau0a01d762019-08-21 11:21:16 +0400686explicit_python=no
Eduardo Habkostddf90692019-10-16 19:42:37 -0300687for binary in "${PYTHON-python3}" python
Daniel P. Berrangéfaf44142019-03-27 17:07:01 +0000688do
689 if has "$binary"
690 then
Paolo Bonzini95c5f2d2019-06-10 12:03:44 +0200691 python=$(command -v "$binary")
Daniel P. Berrangéfaf44142019-03-27 17:07:01 +0000692 break
693 fi
694done
Markus Armbruster903458c2020-02-14 18:18:41 +0100695
Markus Armbruster903458c2020-02-14 18:18:41 +0100696
Alex Bennée39d87c82020-03-03 15:06:20 +0000697# Check for ancillary tools used in testing
698genisoimage=
Alex Bennée3df437c2020-05-19 09:22:48 -0400699for binary in genisoimage mkisofs
Alex Bennée39d87c82020-03-03 15:06:20 +0000700do
701 if has $binary
702 then
703 genisoimage=$(command -v "$binary")
704 break
705 fi
706done
707
Peter Maydell3c4a4d02012-08-11 22:34:40 +0100708# Default objcc to clang if available, otherwise use CC
709if has clang; then
710 objcc=clang
711else
712 objcc="$cc"
713fi
714
Juan Quintela3457a3f2009-08-03 14:46:07 +0200715if test "$mingw32" = "yes" ; then
Juan Quintela3457a3f2009-08-03 14:46:07 +0200716 EXESUF=".exe"
Stefan Weil78e9d4a2015-11-26 12:13:12 +0100717 # MinGW needs -mthreads for TLS and macro _MT.
Paolo Bonzini5770e8a2020-09-23 05:26:15 -0400718 CONFIGURE_CFLAGS="-mthreads $CONFIGURE_CFLAGS"
John Snow93b25862015-03-25 18:57:37 -0400719 write_c_skeleton;
Paolo Bonzinid17f3052020-08-18 12:17:01 +0200720 prefix="/qemu"
Marc-André Lureau77433a52020-08-26 15:04:12 +0400721 qemu_suffix=""
Bishara AbuHattoum105fad62017-08-22 16:55:04 +0300722 libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
Juan Quintela3457a3f2009-08-03 14:46:07 +0200723fi
724
Anthony Liguori487fefd2009-06-11 13:28:25 -0500725werror=""
bellard85aa5182007-11-11 20:17:03 +0000726
Paolo Bonzini61d63092021-10-07 15:08:28 +0200727. $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
bellard7d132992003-03-06 23:23:54 +0000739for opt do
Stefan Weil89138852016-05-16 15:10:20 +0200740 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
bellard7d132992003-03-06 23:23:54 +0000741 case "$opt" in
bellard2efc3262005-12-18 19:14:49 +0000742 --help|-h) show_help=yes
743 ;;
Mike Frysinger99123e12011-04-07 01:12:28 -0400744 --version|-V) exec cat $source_path/VERSION
745 ;;
pbrookb1a550a2006-04-16 13:28:56 +0000746 --prefix=*) prefix="$optarg"
bellard7d132992003-03-06 23:23:54 +0000747 ;;
pbrookb1a550a2006-04-16 13:28:56 +0000748 --interp-prefix=*) interp_prefix="$optarg"
bellard32ce6332003-04-11 00:16:16 +0000749 ;;
aliguoriac0df512008-12-29 17:14:15 +0000750 --cross-prefix=*)
bellard7d132992003-03-06 23:23:54 +0000751 ;;
aliguoriac0df512008-12-29 17:14:15 +0000752 --cc=*)
bellard7d132992003-03-06 23:23:54 +0000753 ;;
pbrookb1a550a2006-04-16 13:28:56 +0000754 --host-cc=*) host_cc="$optarg"
bellard83469012005-07-23 14:27:54 +0000755 ;;
Tomoki Sekiyama83f73fc2013-08-07 11:39:36 -0400756 --cxx=*)
757 ;;
Michael S. Tsirkine007dbe2013-11-24 11:38:05 +0200758 --iasl=*) iasl="$optarg"
759 ;;
Peter Maydell3c4a4d02012-08-11 22:34:40 +0100760 --objcc=*) objcc="$optarg"
761 ;;
pbrookb1a550a2006-04-16 13:28:56 +0000762 --make=*) make="$optarg"
bellard7d132992003-03-06 23:23:54 +0000763 ;;
Paolo Bonzinib6daf4d2020-09-01 06:38:04 -0400764 --install=*)
pbrook6a882642006-04-17 13:57:12 +0000765 ;;
Marc-André Lureau0a01d762019-08-21 11:21:16 +0400766 --python=*) python="$optarg" ; explicit_python=yes
Blue Swirlc886edf2011-07-22 21:08:09 +0000767 ;;
Peter Maydell2eb054c2020-02-13 17:56:18 +0000768 --sphinx-build=*) sphinx_build="$optarg"
769 ;;
Paolo Bonzinia5665052019-06-10 12:05:14 +0200770 --skip-meson) skip_meson=yes
771 ;;
772 --meson=*) meson="$optarg"
773 ;;
Paolo Bonzini48328882020-08-26 08:04:15 +0200774 --ninja=*) ninja="$optarg"
775 ;;
Brade2d88302011-09-02 16:53:28 -0400776 --smbd=*) smbd="$optarg"
777 ;;
Juan Quintelae2a2ed02009-08-03 14:46:02 +0200778 --extra-cflags=*)
bellard7d132992003-03-06 23:23:54 +0000779 ;;
Bruno Dominguez11cde1c2017-06-06 14:07:47 +0100780 --extra-cxxflags=*)
781 ;;
Juan Quintelae2a2ed02009-08-03 14:46:02 +0200782 --extra-ldflags=*)
bellard7d132992003-03-06 23:23:54 +0000783 ;;
Gerd Hoffmann5bc62e02012-02-08 13:54:13 +0100784 --enable-debug-info)
785 ;;
786 --disable-debug-info)
787 ;;
Alex Bennéed75402b2018-04-04 20:27:05 +0100788 --cross-cc-*)
789 ;;
Fam Zheng17969262014-02-10 14:48:56 +0800790 --enable-modules)
791 modules="yes"
792 ;;
Stefan Hajnoczi3aa88b32015-11-02 14:06:23 +0000793 --disable-modules)
794 modules="no"
795 ;;
Christian Ehrhardtbd83c862020-03-10 15:58:06 +0100796 --disable-module-upgrades) module_upgrades="no"
797 ;;
798 --enable-module-upgrades) module_upgrades="yes"
799 ;;
Juan Quintela2ff6b912009-08-03 14:45:55 +0200800 --cpu=*)
bellard7d132992003-03-06 23:23:54 +0000801 ;;
pbrookb1a550a2006-04-16 13:28:56 +0000802 --target-list=*) target_list="$optarg"
Alex Bennée447e1332019-03-19 11:59:12 +0000803 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
bellardde83cd02003-06-15 20:25:43 +0000811 ;;
Paolo Bonzini74242e02010-12-23 11:44:02 +0100812 --with-trace-file=*) trace_file="$optarg"
Prerna Saxena9410b562010-07-13 09:26:32 +0100813 ;;
Paolo Bonzini7bc3ca72020-11-20 08:38:22 +0100814 --with-default-devices) default_devices="true"
Paolo Bonzinif3494742019-01-23 14:56:17 +0800815 ;;
Paolo Bonzini7bc3ca72020-11-20 08:38:22 +0100816 --without-default-devices) default_devices="false"
Paolo Bonzinif3494742019-01-23 14:56:17 +0800817 ;;
Alex Bennéed1d5e9e2021-07-07 14:17:44 +0100818 --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 ;;
Alex Bennéec87ea112020-12-10 19:04:13 +0000830 --without-default-features) # processed above
831 ;;
bellard7d132992003-03-06 23:23:54 +0000832 --enable-gprof) gprof="yes"
833 ;;
Blue Swirl1d728c32012-05-01 18:45:39 +0000834 --enable-gcov) gcov="yes"
835 ;;
Loïc Minier79427692010-01-31 12:23:45 +0100836 --static)
837 static="yes"
Sergei Trofimovich17884d72012-01-31 22:03:45 +0300838 QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
bellard43ce4df2003-06-09 19:53:12 +0000839 ;;
Paolo Bonzini0b24e752010-05-26 16:08:26 +0200840 --mandir=*) mandir="$optarg"
841 ;;
842 --bindir=*) bindir="$optarg"
843 ;;
Alon Levy3aa5d2b2011-05-15 12:08:59 +0300844 --libdir=*) libdir="$optarg"
845 ;;
Michael Tokarev8bf188a2012-06-07 01:11:00 +0400846 --libexecdir=*) libexecdir="$optarg"
847 ;;
Alon Levy0f94d6d2011-06-27 11:58:20 +0200848 --includedir=*) includedir="$optarg"
849 ;;
Eduardo Habkost528ae5b2012-04-18 16:55:49 -0300850 --datadir=*) datadir="$optarg"
Paolo Bonzini0b24e752010-05-26 16:08:26 +0200851 ;;
Marc-André Lureau77433a52020-08-26 15:04:12 +0400852 --with-suffix=*) qemu_suffix="$optarg"
Eduardo Habkost023d3d62012-04-18 16:55:50 -0300853 ;;
Bruce Rogersc6502632020-10-15 13:07:42 -0600854 --docdir=*) docdir="$optarg"
Paolo Bonzini0b24e752010-05-26 16:08:26 +0200855 ;;
Paolo Bonzinife0038b2020-10-16 04:35:10 -0400856 --localedir=*) localedir="$optarg"
857 ;;
Andre Przywaraca2fb932010-03-08 14:09:48 +0100858 --sysconfdir=*) sysconfdir="$optarg"
Anthony Liguori07381cc2010-01-21 10:30:29 -0600859 ;;
Luiz Capitulino785c23a2012-10-03 18:35:57 -0300860 --localstatedir=*) local_statedir="$optarg"
861 ;;
Gerd Hoffmann3d5eeca2017-09-14 13:42:36 +0200862 --firmwarepath=*) firmwarepath="$optarg"
863 ;;
Olaf Hering181ce1d2018-04-18 09:50:44 +0200864 --host=*|--build=*|\
865 --disable-dependency-tracking|\
Luiz Capitulino785c23a2012-10-03 18:35:57 -0300866 --sbindir=*|--sharedstatedir=*|\
Paolo Bonzinife0038b2020-10-16 04:35:10 -0400867 --oldincludedir=*|--datarootdir=*|--infodir=*|\
Max Filippov023ddd72011-11-24 16:11:31 +0400868 --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 ;;
Paolo Bonzini3556c232013-05-10 14:16:40 +0200874 --disable-qom-cast-debug) qom_cast_debug="no"
875 ;;
876 --enable-qom-cast-debug) qom_cast_debug="yes"
877 ;;
malc0c58ac12008-06-25 21:04:05 +0000878 --audio-drv-list=*) audio_drv_list="$optarg"
879 ;;
Stefan Weil89138852016-05-16 15:10:20 +0200880 --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
Fam Zhengb64ec4e2013-05-29 19:35:40 +0800881 ;;
Stefan Weil89138852016-05-16 15:10:20 +0200882 --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
Markus Armbrustereb852012009-10-27 18:41:44 +0100883 ;;
Kevin Wolfe5f05f82021-07-09 18:41:41 +0200884 --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 ;;
aurel32f8393942009-04-13 18:45:38 +0000888 --enable-debug-tcg) debug_tcg="yes"
889 ;;
890 --disable-debug-tcg) debug_tcg="no"
891 ;;
Paul Brookf3d08ee2009-06-04 11:39:04 +0100892 --enable-debug)
893 # Enable debugging options that aren't excessively noisy
894 debug_tcg="yes"
Peter Xu1fcc6d42018-04-25 10:54:59 +0800895 debug_mutex="yes"
Paul Brookf3d08ee2009-06-04 11:39:04 +0100896 debug="yes"
897 strip_opt="no"
John Snowb553a042015-11-03 15:43:42 -0500898 fortify_source="no"
Paul Brookf3d08ee2009-06-04 11:39:04 +0100899 ;;
Marc-André Lureau247724c2018-01-16 16:11:51 +0100900 --enable-sanitizers) sanitizers="yes"
901 ;;
902 --disable-sanitizers) sanitizers="no"
903 ;;
Lingfeng Yang0aebab02020-06-12 20:02:23 +0100904 --enable-tsan) tsan="yes"
905 ;;
906 --disable-tsan) tsan="no"
907 ;;
aliguori1625af82009-04-05 17:41:02 +0000908 --disable-strip) strip_opt="no"
909 ;;
Paolo Bonzini4d34a862020-10-05 11:31:15 +0200910 --disable-slirp) slirp="disabled"
bellard1d14ffa2005-10-30 18:58:22 +0000911 ;;
Paolo Bonzinifd6fc212020-11-20 11:19:38 +0100912 --enable-slirp) slirp="enabled"
913 ;;
Paolo Bonzini4d34a862020-10-05 11:31:15 +0200914 --enable-slirp=git) slirp="internal"
Marc-André Lureau7c57bdd2019-04-24 13:00:41 +0200915 ;;
Paolo Bonzini03a3c0b2021-10-07 15:08:27 +0200916 --enable-slirp=*) slirp="$optarg"
Marc-André Lureau675b9b52019-02-12 17:25:23 +0100917 ;;
Paolo Bonzini1badb702020-09-18 04:57:25 -0400918 --disable-xen) xen="disabled"
aliguorie37630c2009-04-22 15:19:10 +0000919 ;;
Paolo Bonzini1badb702020-09-18 04:57:25 -0400920 --enable-xen) xen="enabled"
Juan Quintelafc321b42009-08-12 18:29:55 +0200921 ;;
Paolo Bonzini1badb702020-09-18 04:57:25 -0400922 --disable-tcg) tcg="disabled"
Alex Bennéed1a14252021-07-09 15:29:54 +0100923 plugins="no"
Paolo Bonzinib3f6ea72017-07-03 16:59:07 +0200924 ;;
Paolo Bonzini1badb702020-09-18 04:57:25 -0400925 --enable-tcg) tcg="enabled"
Paolo Bonzinib3f6ea72017-07-03 16:59:07 +0200926 ;;
bellard05c2a3e2006-02-08 22:39:17 +0000927 --enable-profiler) profiler="yes"
928 ;;
pbrookcad25d62006-03-19 16:31:11 +0000929 --disable-system) softmmu="no"
pbrook0a8e90f2006-03-19 14:54:16 +0000930 ;;
pbrookcad25d62006-03-19 16:31:11 +0000931 --enable-system) softmmu="yes"
pbrook0a8e90f2006-03-19 14:54:16 +0000932 ;;
Zachary Amsden0953a802009-07-30 00:14:59 -1000933 --disable-user)
934 linux_user="no" ;
935 bsd_user="no" ;
Zachary Amsden0953a802009-07-30 00:14:59 -1000936 ;;
937 --enable-user) ;;
ths831b7822007-01-18 20:06:33 +0000938 --disable-linux-user) linux_user="no"
pbrook0a8e90f2006-03-19 14:54:16 +0000939 ;;
ths831b7822007-01-18 20:06:33 +0000940 --enable-linux-user) linux_user="yes"
941 ;;
blueswir184778502008-10-26 20:33:16 +0000942 --disable-bsd-user) bsd_user="no"
943 ;;
944 --enable-bsd-user) bsd_user="yes"
945 ;;
Avi Kivity40d64442011-11-15 20:12:17 +0200946 --enable-pie) pie="yes"
Kirill A. Shutemov34005a02009-09-12 02:17:55 +0300947 ;;
Avi Kivity40d64442011-11-15 20:12:17 +0200948 --disable-pie) pie="no"
Kirill A. Shutemov34005a02009-09-12 02:17:55 +0300949 ;;
bellard85aa5182007-11-11 20:17:03 +0000950 --enable-werror) werror="yes"
951 ;;
952 --disable-werror) werror="no"
953 ;;
Daniele Buonocdad7812020-12-04 18:06:11 -0500954 --enable-lto) lto="true"
955 ;;
956 --disable-lto) lto="false"
957 ;;
Steven Noonan63678e12014-03-28 17:19:02 +0100958 --enable-stack-protector) stack_protector="yes"
959 ;;
960 --disable-stack-protector) stack_protector="no"
961 ;;
Daniele Buono1e4f6062020-05-29 16:51:21 -0400962 --enable-safe-stack) safe_stack="yes"
963 ;;
964 --disable-safe-stack) safe_stack="no"
965 ;;
Daniele Buono9e62ba42020-12-04 18:06:14 -0500966 --enable-cfi)
967 cfi="true";
968 lto="true";
969 ;;
970 --disable-cfi) cfi="false"
971 ;;
Paolo Bonzinifbb41212020-10-05 11:31:15 +0200972 --disable-fdt) fdt="disabled"
Juan Quintela2df87df2009-08-12 18:29:54 +0200973 ;;
Paolo Bonzinifbb41212020-10-05 11:31:15 +0200974 --enable-fdt) fdt="enabled"
975 ;;
976 --enable-fdt=git) fdt="internal"
977 ;;
Paolo Bonzini03a3c0b2021-10-07 15:08:27 +0200978 --enable-fdt=*) fdt="$optarg"
Juan Quintela2df87df2009-08-12 18:29:54 +0200979 ;;
Paolo Bonzinia40161c2018-02-16 10:05:23 +0100980 --disable-membarrier) membarrier="no"
981 ;;
982 --enable-membarrier) membarrier="yes"
983 ;;
Thomas Huth7e563bf2018-02-15 12:06:47 +0100984 --with-pkgversion=*) pkgversion="$optarg"
pbrook4a19f1e2009-04-07 23:17:49 +0000985 ;;
Alex Barcelo519175a2012-02-28 12:25:50 +0100986 --with-coroutine=*) coroutine="$optarg"
987 ;;
Stefan Hajnoczi70c60c02013-09-11 16:42:35 +0200988 --disable-coroutine-pool) coroutine_pool="no"
989 ;;
990 --enable-coroutine-pool) coroutine_pool="yes"
991 ;;
Peter Lieven7d992e42016-09-27 11:58:45 +0200992 --enable-debug-stack-usage) debug_stack_usage="yes"
993 ;;
Longpeng(Mike)f0d92b52017-07-14 14:04:05 -0400994 --enable-crypto-afalg) crypto_afalg="yes"
995 ;;
996 --disable-crypto-afalg) crypto_afalg="no"
997 ;;
Michael S. Tsirkind5970052010-03-17 13:08:17 +0200998 --disable-vhost-net) vhost_net="no"
999 ;;
1000 --enable-vhost-net) vhost_net="yes"
1001 ;;
Gonglei042cea22018-03-01 21:46:28 +08001002 --disable-vhost-crypto) vhost_crypto="no"
1003 ;;
Paolo Bonzini299e6f12019-02-14 18:35:53 +01001004 --enable-vhost-crypto) vhost_crypto="yes"
Gonglei042cea22018-03-01 21:46:28 +08001005 ;;
Nicholas Bellinger5e9be922013-03-29 01:08:16 +00001006 --disable-vhost-scsi) vhost_scsi="no"
1007 ;;
1008 --enable-vhost-scsi) vhost_scsi="yes"
1009 ;;
Stefan Hajnoczifc0b9b02016-08-16 13:27:22 +01001010 --disable-vhost-vsock) vhost_vsock="no"
1011 ;;
1012 --enable-vhost-vsock) vhost_vsock="yes"
1013 ;;
Dr. David Alan Gilbert98fc1ad2019-09-30 11:51:34 +01001014 --disable-vhost-user-fs) vhost_user_fs="no"
1015 ;;
1016 --enable-vhost-user-fs) vhost_user_fs="yes"
1017 ;;
Gerd Hoffmannda076ff2014-11-20 09:49:44 +01001018 --disable-opengl) opengl="no"
Michael Walle20ff0752011-03-07 23:32:39 +01001019 ;;
Gerd Hoffmannda076ff2014-11-20 09:49:44 +01001020 --enable-opengl) opengl="yes"
Michael Walle20ff0752011-03-07 23:32:39 +01001021 ;;
Sergei Trofimovich8c84cf12012-01-24 20:42:40 +03001022 --disable-xfsctl) xfs="no"
1023 ;;
1024 --enable-xfsctl) xfs="yes"
1025 ;;
Paolo Bonzini1ffb3bb2020-08-28 19:33:54 +02001026 --disable-zlib-test)
Alon Levy1ece9902011-07-26 12:30:40 +03001027 ;;
Michael Rothd138cee2011-08-01 14:52:57 -05001028 --enable-guest-agent) guest_agent="yes"
1029 ;;
1030 --disable-guest-agent) guest_agent="no"
1031 ;;
Tomoki Sekiyamad9840e22013-08-07 11:40:03 -04001032 --with-vss-sdk) vss_win32_sdk=""
1033 ;;
1034 --with-vss-sdk=*) vss_win32_sdk="$optarg"
1035 ;;
1036 --without-vss-sdk) vss_win32_sdk="no"
1037 ;;
1038 --with-win-sdk) win_sdk=""
1039 ;;
1040 --with-win-sdk=*) win_sdk="$optarg"
1041 ;;
1042 --without-win-sdk) win_sdk="no"
1043 ;;
Daniel P. Berrange4b1c11f2012-09-10 12:26:29 +01001044 --enable-tools) want_tools="yes"
1045 ;;
1046 --disable-tools) want_tools="no"
1047 ;;
Liam Merwick86583a02018-10-19 21:38:59 +01001048 --disable-avx2) avx2_opt="no"
1049 ;;
1050 --enable-avx2) avx2_opt="yes"
1051 ;;
Robert Hoo6b8cd442020-02-29 20:34:34 +08001052 --disable-avx512f) avx512f_opt="no"
1053 ;;
1054 --enable-avx512f) avx512f_opt="yes"
1055 ;;
Fam Zheng52b53c02014-09-10 14:17:51 +08001056 --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
1057 echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
Stefan Hajnoczi583f6e72012-11-14 15:04:15 +01001058 ;;
Fam Zhengcb6414d2016-09-21 12:27:16 +08001059 --enable-vhdx|--disable-vhdx)
1060 echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1061 ;;
Fam Zheng315d3182016-09-21 12:27:21 +08001062 --enable-uuid|--disable-uuid)
1063 echo "$0: $opt is obsolete, UUID support is always built" >&2
1064 ;;
Daniel P. Berrangea1c5e942016-06-06 10:05:06 +01001065 --tls-priority=*) tls_priority="$optarg"
1066 ;;
Michael R. Hines2da776d2013-07-22 10:01:54 -04001067 --enable-rdma) rdma="yes"
1068 ;;
1069 --disable-rdma) rdma="no"
1070 ;;
Marcel Apfelbaum21ab34c2018-08-16 18:16:37 +03001071 --enable-pvrdma) pvrdma="yes"
1072 ;;
1073 --disable-pvrdma) pvrdma="no"
1074 ;;
Cole Robinsone91c7932014-06-16 15:32:47 -04001075 --disable-tpm) tpm="no"
1076 ;;
Stefan Bergerab214c22013-02-27 12:47:52 -05001077 --enable-tpm) tpm="yes"
1078 ;;
Dr. David Alan Gilberted1701c2017-05-15 15:05:29 +01001079 --disable-live-block-migration) live_block_migration="no"
1080 ;;
1081 --enable-live-block-migration) live_block_migration="yes"
1082 ;;
Wanlong Gaoa99d57b2014-05-14 17:43:28 +08001083 --disable-numa) numa="no"
1084 ;;
1085 --enable-numa) numa="yes"
1086 ;;
Changlong Xiea6b1d4c2016-07-27 15:01:48 +08001087 --disable-replication) replication="no"
1088 ;;
1089 --enable-replication) replication="yes"
1090 ;;
Jeff Cody2f740132018-11-07 07:36:44 +01001091 --disable-bochs) bochs="no"
1092 ;;
1093 --enable-bochs) bochs="yes"
1094 ;;
1095 --disable-cloop) cloop="no"
1096 ;;
1097 --enable-cloop) cloop="yes"
1098 ;;
1099 --disable-dmg) dmg="no"
1100 ;;
1101 --enable-dmg) dmg="yes"
1102 ;;
1103 --disable-qcow1) qcow1="no"
1104 ;;
1105 --enable-qcow1) qcow1="yes"
1106 ;;
1107 --disable-vdi) vdi="no"
1108 ;;
1109 --enable-vdi) vdi="yes"
1110 ;;
1111 --disable-vvfat) vvfat="no"
1112 ;;
1113 --enable-vvfat) vvfat="yes"
1114 ;;
1115 --disable-qed) qed="no"
1116 ;;
1117 --enable-qed) qed="yes"
1118 ;;
1119 --disable-parallels) parallels="no"
1120 ;;
1121 --enable-parallels) parallels="yes"
1122 ;;
Marc-André Lureaue6a74862017-08-03 11:07:46 +02001123 --disable-vhost-user) vhost_user="no"
1124 ;;
Paolo Bonzini299e6f12019-02-14 18:35:53 +01001125 --enable-vhost-user) vhost_user="yes"
1126 ;;
Cindy Lu108a6482020-07-01 22:55:37 +08001127 --disable-vhost-vdpa) vhost_vdpa="no"
1128 ;;
1129 --enable-vhost-vdpa) vhost_vdpa="yes"
1130 ;;
Paolo Bonzini299e6f12019-02-14 18:35:53 +01001131 --disable-vhost-kernel) vhost_kernel="no"
1132 ;;
1133 --enable-vhost-kernel) vhost_kernel="yes"
Marc-André Lureaue6a74862017-08-03 11:07:46 +02001134 ;;
Richard Henderson8b18cdb2020-09-13 12:19:25 -07001135 --disable-capstone) capstone="disabled"
Richard Henderson8ca80762017-09-14 09:41:12 -07001136 ;;
Richard Henderson8b18cdb2020-09-13 12:19:25 -07001137 --enable-capstone) capstone="enabled"
Richard Henderson8ca80762017-09-14 09:41:12 -07001138 ;;
Richard Henderson8b18cdb2020-09-13 12:19:25 -07001139 --enable-capstone=git) capstone="internal"
Richard Hendersone219c492017-09-28 09:01:23 -07001140 ;;
Paolo Bonzini03a3c0b2021-10-07 15:08:27 +02001141 --enable-capstone=*) capstone="$optarg"
Richard Hendersone219c492017-09-28 09:01:23 -07001142 ;;
Daniel P. Berrangecc84d632017-10-20 15:02:43 +01001143 --with-git=*) git="$optarg"
1144 ;;
Dan Streetman7d7dbf92021-01-19 12:20:46 -05001145 --with-git-submodules=*)
1146 git_submodules_action="$optarg"
Daniel P. Berrangef62bbee2017-10-26 13:52:26 +01001147 ;;
Paolo Bonziniba59fb72018-06-13 14:23:08 +02001148 --enable-debug-mutex) debug_mutex=yes
1149 ;;
1150 --disable-debug-mutex) debug_mutex=no
1151 ;;
Alex Bennée9b8e4292021-07-09 15:29:56 +01001152 --enable-plugins) if test "$mingw32" = "yes"; then
1153 error_exit "TCG plugins not currently supported on Windows platforms"
1154 else
1155 plugins="yes"
1156 fi
Alex Bennée40e8c6f2019-06-13 14:52:25 +01001157 ;;
1158 --disable-plugins) plugins="no"
1159 ;;
Alex Bennéeafc3a8f2019-11-28 16:35:24 +01001160 --enable-containers) use_containers="yes"
1161 ;;
1162 --disable-containers) use_containers="no"
1163 ;;
Alex Bennéef48e5902020-03-16 17:21:48 +00001164 --gdb=*) gdb_bin="$optarg"
1165 ;;
Marek Marczykowski-Góreckib767d252020-05-20 15:20:23 +02001166 --enable-rng-none) rng_none=yes
1167 ;;
1168 --disable-rng-none) rng_none=no
1169 ;;
Alexey Krasikov54e7aac2020-05-25 14:19:12 +03001170 --enable-keyring) secret_keyring="yes"
1171 ;;
1172 --disable-keyring) secret_keyring="no"
1173 ;;
Denis Plotnikov20cf7b82021-03-12 18:14:40 +03001174 --enable-gio) gio=yes
1175 ;;
1176 --disable-gio) gio=no
1177 ;;
Joelle van Dyneb8e0c492021-03-15 11:03:41 -07001178 --enable-slirp-smbd) slirp_smbd=yes
1179 ;;
1180 --disable-slirp-smbd) slirp_smbd=no
1181 ;;
Paolo Bonzini3b4da132021-10-07 15:08:29 +02001182 # backwards compatibility options
1183 --enable-trace-backend=*) meson_option_parse "--enable-trace-backends=$optarg" "$optarg"
1184 ;;
1185 --disable-blobs) meson_option_parse --disable-install-blobs ""
1186 ;;
1187 --enable-tcmalloc) meson_option_parse --enable-malloc=tcmalloc tcmalloc
1188 ;;
1189 --enable-jemalloc) meson_option_parse --enable-malloc=jemalloc jemalloc
1190 ;;
1191 # everything else has the same name in configure and meson
Paolo Bonzini61d63092021-10-07 15:08:28 +02001192 --enable-* | --disable-*) meson_option_parse "$opt" "$optarg"
1193 ;;
Fam Zheng2d2ad6d2014-04-18 14:55:36 +08001194 *)
1195 echo "ERROR: unknown option $opt"
1196 echo "Try '$0 --help' for more information"
1197 exit 1
balrog7f1559c2007-11-17 10:24:32 +00001198 ;;
bellard7d132992003-03-06 23:23:54 +00001199 esac
1200done
1201
Alex Bennéed1a14252021-07-09 15:29:54 +01001202# test for any invalid configuration combinations
1203if test "$plugins" = "yes" -a "$tcg" = "disabled"; then
1204 error_exit "Can't enable plugins on non-TCG builds"
1205fi
1206
Dan Streetman7d7dbf92021-01-19 12:20:46 -05001207case $git_submodules_action in
1208 update|validate)
1209 if test ! -e "$source_path/.git"; then
1210 echo "ERROR: cannot $git_submodules_action git submodules without .git"
1211 exit 1
1212 fi
1213 ;;
1214 ignore)
Paolo Bonzinib80fd282021-05-12 09:18:55 +02001215 if ! test -f "$source_path/ui/keycodemapdb/README"
1216 then
1217 echo
1218 echo "ERROR: missing GIT submodules"
1219 echo
1220 if test -e "$source_path/.git"; then
1221 echo "--with-git-submodules=ignore specified but submodules were not"
1222 echo "checked out. Please initialize and update submodules."
1223 else
1224 echo "This is not a GIT checkout but module content appears to"
1225 echo "be missing. Do not use 'git archive' or GitHub download links"
1226 echo "to acquire QEMU source archives. Non-GIT builds are only"
1227 echo "supported with source archives linked from:"
1228 echo
1229 echo " https://www.qemu.org/download/#source"
1230 echo
1231 echo "Developers working with GIT can use scripts/archive-source.sh"
1232 echo "if they need to create valid source archives."
1233 fi
1234 echo
1235 exit 1
1236 fi
Dan Streetman7d7dbf92021-01-19 12:20:46 -05001237 ;;
1238 *)
1239 echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'"
1240 exit 1
1241 ;;
1242esac
1243
Marc-André Lureau22a87802019-07-11 19:13:39 +04001244libdir="${libdir:-$prefix/lib}"
1245libexecdir="${libexecdir:-$prefix/libexec}"
1246includedir="${includedir:-$prefix/include}"
1247
1248if test "$mingw32" = "yes" ; then
Joshua Watt15588a62021-01-12 15:02:39 -06001249 bindir="${bindir:-$prefix}"
Marc-André Lureau22a87802019-07-11 19:13:39 +04001250else
Marc-André Lureau22a87802019-07-11 19:13:39 +04001251 bindir="${bindir:-$prefix/bin}"
Marc-André Lureau22a87802019-07-11 19:13:39 +04001252fi
Joshua Watt15588a62021-01-12 15:02:39 -06001253mandir="${mandir:-$prefix/share/man}"
1254datadir="${datadir:-$prefix/share}"
1255docdir="${docdir:-$prefix/share/doc}"
1256sysconfdir="${sysconfdir:-$prefix/etc}"
1257local_statedir="${local_statedir:-$prefix/var}"
Paolo Bonzini16bf7a32020-10-16 03:19:14 -04001258firmwarepath="${firmwarepath:-$datadir/qemu-firmware}"
1259localedir="${localedir:-$datadir/locale}"
Marc-André Lureau22a87802019-07-11 19:13:39 +04001260
Alex Bennée9557af92021-09-17 17:23:22 +01001261if eval test -z "\${cross_cc_$cpu}"; then
1262 eval "cross_cc_${cpu}=\$cc"
1263 cross_cc_vars="$cross_cc_vars cross_cc_${cpu}"
1264fi
Peter Crosthwaite79f3b122013-04-18 14:46:14 +10001265
Peter Maydellaffc88c2016-06-13 11:32:24 +01001266# For user-mode emulation the host arch has to be one we explicitly
1267# support, even if we're using TCI.
1268if [ "$ARCH" = "unknown" ]; then
1269 bsd_user="no"
1270 linux_user="no"
1271fi
1272
Peter Maydell60e0df22011-05-03 14:50:13 +01001273default_target_list=""
Markus Armbruster43692232021-05-03 10:40:34 +02001274deprecated_targets_list=ppc64abi32-linux-user
Paolo Bonzinifdb75ae2020-09-21 04:37:49 -04001275deprecated_features=""
Peter Maydell6e92f822013-05-20 16:16:15 +01001276mak_wilds=""
1277
1278if [ "$softmmu" = "yes" ]; then
Alex Bennée812b31d2021-07-07 14:17:43 +01001279 mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak"
Peter Maydell60e0df22011-05-03 14:50:13 +01001280fi
Peter Maydell6e92f822013-05-20 16:16:15 +01001281if [ "$linux_user" = "yes" ]; then
Alex Bennée812b31d2021-07-07 14:17:43 +01001282 mak_wilds="${mak_wilds} $source_path/configs/targets/*-linux-user.mak"
Peter Maydell60e0df22011-05-03 14:50:13 +01001283fi
Peter Maydell6e92f822013-05-20 16:16:15 +01001284if [ "$bsd_user" = "yes" ]; then
Alex Bennée812b31d2021-07-07 14:17:43 +01001285 mak_wilds="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak"
Peter Maydell60e0df22011-05-03 14:50:13 +01001286fi
1287
Alex Bennée3a5ae4a2020-09-15 14:43:13 +01001288# If the user doesn't explicitly specify a deprecated target we will
1289# skip it.
1290if test -z "$target_list"; then
1291 if test -z "$target_list_exclude"; then
1292 target_list_exclude="$deprecated_targets_list"
1293 else
1294 target_list_exclude="$target_list_exclude,$deprecated_targets_list"
1295 fi
Alex Bennée2d838d92020-09-09 12:27:37 +01001296fi
1297
Alex Bennée2d838d92020-09-09 12:27:37 +01001298for config in $mak_wilds; do
1299 target="$(basename "$config" .mak)"
Alex Bennée98db9a02020-09-15 14:43:14 +01001300 if echo "$target_list_exclude" | grep -vq "$target"; then
Alex Bennée2d838d92020-09-09 12:27:37 +01001301 default_target_list="${default_target_list} $target"
1302 fi
1303done
Peter Maydell6e92f822013-05-20 16:16:15 +01001304
pbrookaf5db582006-04-08 14:26:41 +00001305if test x"$show_help" = x"yes" ; then
1306cat << EOF
1307
1308Usage: configure [options]
1309Options: [defaults in brackets after descriptions]
1310
Stefan Weil08fb77e2013-12-18 22:09:39 +01001311Standard options:
1312 --help print this message
1313 --prefix=PREFIX install in PREFIX [$prefix]
1314 --interp-prefix=PREFIX where to find shared libraries, etc.
1315 use %M for cpu name [$interp_prefix]
Alex Bennée2deca812020-10-29 20:14:49 +00001316 --target-list=LIST set target list (default: build all non-deprecated)
Stefan Weil08fb77e2013-12-18 22:09:39 +01001317$(echo Available targets: $default_target_list | \
1318 fold -s -w 53 | sed -e 's/^/ /')
Alex Bennée2deca812020-10-29 20:14:49 +00001319$(echo Deprecated targets: $deprecated_targets_list | \
1320 fold -s -w 53 | sed -e 's/^/ /')
Alex Bennée447e1332019-03-19 11:59:12 +00001321 --target-list-exclude=LIST exclude a set of targets from the default target-list
Stefan Weil08fb77e2013-12-18 22:09:39 +01001322
1323Advanced options (experts only):
Joelle van Dyne3812c0c2021-01-25 17:24:48 -08001324 --cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix]
Stefan Weil08fb77e2013-12-18 22:09:39 +01001325 --cc=CC use C compiler CC [$cc]
1326 --iasl=IASL use ACPI compiler IASL [$iasl]
1327 --host-cc=CC use C compiler CC [$host_cc] for code run at
1328 build time
1329 --cxx=CXX use C++ compiler CXX [$cxx]
1330 --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
Paolo Bonzinia2866662021-11-05 10:09:26 +01001331 --extra-cflags=CFLAGS append extra C compiler flags CFLAGS
1332 --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS
Stefan Weil08fb77e2013-12-18 22:09:39 +01001333 --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS
Alex Bennéed75402b2018-04-04 20:27:05 +01001334 --cross-cc-ARCH=CC use compiler when building ARCH guest test cases
Alex Bennéed422b2b2018-04-13 11:07:58 +01001335 --cross-cc-flags-ARCH= use compiler flags when building ARCH guest tests
Stefan Weil08fb77e2013-12-18 22:09:39 +01001336 --make=MAKE use specified make [$make]
Stefan Weil08fb77e2013-12-18 22:09:39 +01001337 --python=PYTHON use specified python [$python]
Peter Maydell2eb054c2020-02-13 17:56:18 +00001338 --sphinx-build=SPHINX use specified sphinx-build [$sphinx_build]
Paolo Bonzinia5665052019-06-10 12:05:14 +02001339 --meson=MESON use specified meson [$meson]
Paolo Bonzini48328882020-08-26 08:04:15 +02001340 --ninja=NINJA use specified ninja [$ninja]
Stefan Weil08fb77e2013-12-18 22:09:39 +01001341 --smbd=SMBD use specified smbd [$smbd]
Thomas Huthdb1b5f12018-03-27 17:09:30 +02001342 --with-git=GIT use specified git [$git]
Dan Streetman7d7dbf92021-01-19 12:20:46 -05001343 --with-git-submodules=update update git submodules (default if .git dir exists)
1344 --with-git-submodules=validate fail if git submodules are not up to date
1345 --with-git-submodules=ignore do not update or check git submodules (default if no .git dir)
Stefan Weil08fb77e2013-12-18 22:09:39 +01001346 --static enable static build [$static]
1347 --mandir=PATH install man pages in PATH
Marc-André Lureau10ff82d2020-08-26 15:04:13 +04001348 --datadir=PATH install firmware in PATH/$qemu_suffix
Paolo Bonzinife0038b2020-10-16 04:35:10 -04001349 --localedir=PATH install translation in PATH/$qemu_suffix
Marc-André Lureau10ff82d2020-08-26 15:04:13 +04001350 --docdir=PATH install documentation in PATH/$qemu_suffix
Stefan Weil08fb77e2013-12-18 22:09:39 +01001351 --bindir=PATH install binaries in PATH
1352 --libdir=PATH install libraries in PATH
Thomas Huthdb1b5f12018-03-27 17:09:30 +02001353 --libexecdir=PATH install helper binaries in PATH
Marc-André Lureau10ff82d2020-08-26 15:04:13 +04001354 --sysconfdir=PATH install config in PATH/$qemu_suffix
Stefan Weil08fb77e2013-12-18 22:09:39 +01001355 --localstatedir=PATH install local state in PATH (set at runtime on win32)
Gerd Hoffmann3d5eeca2017-09-14 13:42:36 +02001356 --firmwarepath=PATH search PATH for firmware files
Robert Foley13336602020-07-01 14:56:21 +01001357 --efi-aarch64=PATH PATH of efi file to use for aarch64 VMs.
Marc-André Lureauca8c0902020-08-26 15:04:14 +04001358 --with-suffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix]
Thomas Huthdb1b5f12018-03-27 17:09:30 +02001359 --with-pkgversion=VERS use specified string as sub-version of the package
Paolo Bonzinic035c8d2020-12-14 11:34:47 +01001360 --without-default-features default all --enable-* options to "disabled"
1361 --without-default-devices do not include any device that is not needed to
1362 start the emulator (only use if you are including
Alex Bennéed1d5e9e2021-07-07 14:17:44 +01001363 desired devices in configs/devices/)
1364 --with-devices-ARCH=NAME override default configs/devices
Stefan Weil08fb77e2013-12-18 22:09:39 +01001365 --enable-debug enable common debug build options
Marc-André Lureau247724c2018-01-16 16:11:51 +01001366 --enable-sanitizers enable default sanitizers
Lingfeng Yang0aebab02020-06-12 20:02:23 +01001367 --enable-tsan enable thread sanitizer
Stefan Weil08fb77e2013-12-18 22:09:39 +01001368 --disable-strip disable stripping binaries
1369 --disable-werror disable compilation abort on warning
Steven Noonan63678e12014-03-28 17:19:02 +01001370 --disable-stack-protector disable compiler-provided stack protection
Paolo Bonzini16bfbc72021-11-02 14:56:22 +01001371 --audio-drv-list=LIST set audio drivers to try if -audiodev is not used
Stefan Weil08fb77e2013-12-18 22:09:39 +01001372 --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L
1373 --block-drv-rw-whitelist=L
1374 set block driver read-write whitelist
Kevin Wolfe5f05f82021-07-09 18:41:41 +02001375 (by default affects only QEMU, not tools like qemu-img)
Stefan Weil08fb77e2013-12-18 22:09:39 +01001376 --block-drv-ro-whitelist=L
1377 set block driver read-only whitelist
Kevin Wolfe5f05f82021-07-09 18:41:41 +02001378 (by default affects only QEMU, not tools like qemu-img)
1379 --enable-block-drv-whitelist-in-tools
1380 use block whitelist also in tools instead of only QEMU
Stefan Weil08fb77e2013-12-18 22:09:39 +01001381 --with-trace-file=NAME Full PATH,NAME of file to store traces
1382 Default:trace-<pid>
Michael Tokarevc23f23b2015-06-17 22:19:26 +03001383 --cpu=CPU Build for host CPU [$cpu]
Stefan Weil08fb77e2013-12-18 22:09:39 +01001384 --with-coroutine=BACKEND coroutine backend. Supported options:
Daniel P. Berrange33c53c52017-04-28 13:24:44 +01001385 ucontext, sigaltstack, windows
Stefan Weil08fb77e2013-12-18 22:09:39 +01001386 --enable-gcov enable test coverage analysis with gcov
Michael Tokarevc23f23b2015-06-17 22:19:26 +03001387 --with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent
1388 --with-win-sdk=SDK-path path to Windows Platform SDK (to build VSS .tlb)
Daniel P. Berrangea1c5e942016-06-06 10:05:06 +01001389 --tls-priority default TLS protocol/cipher priority string
Lin Mac12d66a2017-03-10 18:14:05 +08001390 --enable-gprof QEMU profiling with gprof
1391 --enable-profiler profiler support
Lin Mac12d66a2017-03-10 18:14:05 +08001392 --enable-debug-stack-usage
1393 track the maximum stack usage of stacks created by qemu_alloc_stack
Alex Bennée40e8c6f2019-06-13 14:52:25 +01001394 --enable-plugins
1395 enable plugins via shared library loading
Alex Bennéeafc3a8f2019-11-28 16:35:24 +01001396 --disable-containers don't use containers for cross-building
Alex Bennéef48e5902020-03-16 17:21:48 +00001397 --gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin]
Paolo Bonzini61d63092021-10-07 15:08:28 +02001398EOF
1399 meson_options_help
1400cat << EOF
Michael Tokarevc23f23b2015-06-17 22:19:26 +03001401 system all system emulation targets
1402 user supported user emulation targets
1403 linux-user all linux usermode emulation targets
1404 bsd-user all BSD usermode emulation targets
Michael Tokarevc23f23b2015-06-17 22:19:26 +03001405 guest-agent build the QEMU Guest Agent
Michael Tokarevc23f23b2015-06-17 22:19:26 +03001406 pie Position Independent Executables
Marc-André Lureau21e709a2019-07-18 16:04:13 +04001407 modules modules support (non-Windows)
Christian Ehrhardtbd83c862020-03-10 15:58:06 +01001408 module-upgrades try to load modules from alternate paths for upgrades
Michael Tokarevc23f23b2015-06-17 22:19:26 +03001409 debug-tcg TCG debugging (default is disabled)
1410 debug-info debugging information
Daniele Buonocdad7812020-12-04 18:06:11 -05001411 lto Enable Link-Time Optimization.
Daniele Buono1e4f6062020-05-29 16:51:21 -04001412 safe-stack SafeStack Stack Smash Protection. Depends on
1413 clang/llvm >= 3.7 and requires coroutine backend ucontext.
Paolo Bonzinia40161c2018-02-16 10:05:23 +01001414 membarrier membarrier system call (for Linux 4.14+ or Windows)
Marcel Apfelbaum21ab34c2018-08-16 18:16:37 +03001415 rdma Enable RDMA-based migration
1416 pvrdma Enable PVRDMA support
Paolo Bonzini299e6f12019-02-14 18:35:53 +01001417 vhost-net vhost-net kernel acceleration support
1418 vhost-vsock virtio sockets device support
1419 vhost-scsi vhost-scsi kernel target support
1420 vhost-crypto vhost-user-crypto backend support
1421 vhost-kernel vhost kernel backend support
1422 vhost-user vhost-user backend support
Cindy Lu108a6482020-07-01 22:55:37 +08001423 vhost-vdpa vhost-vdpa kernel backend support
Dr. David Alan Gilberted1701c2017-05-15 15:05:29 +01001424 live-block-migration Block migration in the main migration stream
Michael Tokarevc23f23b2015-06-17 22:19:26 +03001425 coroutine-pool coroutine freelist (better performance)
Michael Tokarevc23f23b2015-06-17 22:19:26 +03001426 tpm TPM support
Michael Tokarevc23f23b2015-06-17 22:19:26 +03001427 numa libnuma support
Liam Merwick86583a02018-10-19 21:38:59 +01001428 avx2 AVX2 optimization support
Robert Hoo6b8cd442020-02-29 20:34:34 +08001429 avx512f AVX512F optimization support
Changlong Xiea6b1d4c2016-07-27 15:01:48 +08001430 replication replication support
Lin Mac12d66a2017-03-10 18:14:05 +08001431 opengl opengl support
Lin Mac12d66a2017-03-10 18:14:05 +08001432 xfsctl xfsctl support
1433 qom-cast-debug cast debugging support
Cleber Rosa8de73fa2019-02-07 14:36:03 -05001434 tools build qemu-io, qemu-nbd and qemu-img tools
Jeff Cody2f740132018-11-07 07:36:44 +01001435 bochs bochs image format support
1436 cloop cloop image format support
1437 dmg dmg image format support
1438 qcow1 qcow v1 image format support
1439 vdi vdi image format support
1440 vvfat vvfat image format support
1441 qed qed image format support
1442 parallels parallels image format support
Longpeng(Mike)f0d92b52017-07-14 14:04:05 -04001443 crypto-afalg Linux AF_ALG crypto backend driver
Paolo Bonziniba59fb72018-06-13 14:23:08 +02001444 debug-mutex mutex debugging support
Marek Marczykowski-Góreckib767d252020-05-20 15:20:23 +02001445 rng-none dummy RNG, avoid using /dev/(u)random and getrandom()
Denis Plotnikov20cf7b82021-03-12 18:14:40 +03001446 gio libgio support
Joelle van Dyneb8e0c492021-03-15 11:03:41 -07001447 slirp-smbd use smbd (at path --smbd=*) in slirp networking
Stefan Weil08fb77e2013-12-18 22:09:39 +01001448
1449NOTE: The object files are built at the place where configure is launched
pbrookaf5db582006-04-08 14:26:41 +00001450EOF
Fam Zheng2d2ad6d2014-04-18 14:55:36 +08001451exit 0
pbrookaf5db582006-04-08 14:26:41 +00001452fi
1453
Thomas Huth9c790242019-03-11 11:20:34 +01001454# Remove old dependency files to make sure that they get properly regenerated
Thomas Huthbb768f72019-05-10 10:11:59 +02001455rm -f */config-devices.mak.d
Thomas Huth9c790242019-03-11 11:20:34 +01001456
Daniel P. Berrangéfaf44142019-03-27 17:07:01 +00001457if test -z "$python"
1458then
1459 error_exit "Python not found. Use --python=/path/to/python"
Stefan Hajnoczic53eeaf2017-03-28 14:44:18 +01001460fi
Roman Bolshakov8e2c76b2020-08-25 23:27:55 +03001461if ! has "$make"
1462then
1463 error_exit "GNU make ($make) not found"
1464fi
Stefan Hajnoczic53eeaf2017-03-28 14:44:18 +01001465
1466# Note that if the Python conditional here evaluates True we will exit
1467# with status 1 which is a shell 'false' value.
Thomas Huth1b11f282020-09-25 16:40:27 +01001468if ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then
1469 error_exit "Cannot use '$python', Python >= 3.6 is required." \
Stefan Hajnoczic53eeaf2017-03-28 14:44:18 +01001470 "Use --python=/path/to/python to specify a supported Python."
1471fi
1472
Cleber Rosa755ee702018-11-09 10:07:07 -05001473# Preserve python version since some functionality is dependent on it
Cleber Rosa406ab2f2019-08-26 11:58:32 -04001474python_version=$($python -c 'import sys; print("%d.%d.%d" % (sys.version_info[0], sys.version_info[1], sys.version_info[2]))' 2>/dev/null)
Cleber Rosa755ee702018-11-09 10:07:07 -05001475
Stefan Hajnoczic53eeaf2017-03-28 14:44:18 +01001476# Suppress writing compiled files
1477python="$python -B"
1478
Marc-André Lureau0a01d762019-08-21 11:21:16 +04001479if test -z "$meson"; then
Paolo Bonzini6638cae2021-10-27 15:18:48 +02001480 if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.59.3; then
Marc-André Lureau0a01d762019-08-21 11:21:16 +04001481 meson=meson
Dan Streetman7d7dbf92021-01-19 12:20:46 -05001482 elif test $git_submodules_action != 'ignore' ; then
Marc-André Lureau0a01d762019-08-21 11:21:16 +04001483 meson=git
1484 elif test -e "${source_path}/meson/meson.py" ; then
1485 meson=internal
1486 else
1487 if test "$explicit_python" = yes; then
1488 error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found."
1489 else
1490 error_exit "Meson not found. Use --meson=/path/to/meson"
1491 fi
1492 fi
1493else
1494 # Meson uses its own Python interpreter to invoke other Python scripts,
1495 # but the user wants to use the one they specified with --python.
1496 #
1497 # We do not want to override the distro Python interpreter (and sometimes
1498 # cannot: for example in Homebrew /usr/bin/meson is a bash script), so
1499 # just require --meson=git|internal together with --python.
1500 if test "$explicit_python" = yes; then
1501 case "$meson" in
1502 git | internal) ;;
1503 *) error_exit "--python requires using QEMU's embedded Meson distribution." ;;
1504 esac
1505 fi
Paolo Bonzinia5665052019-06-10 12:05:14 +02001506fi
Paolo Bonzinia5665052019-06-10 12:05:14 +02001507
Marc-André Lureau0a01d762019-08-21 11:21:16 +04001508if test "$meson" = git; then
1509 git_submodules="${git_submodules} meson"
Paolo Bonzinia5665052019-06-10 12:05:14 +02001510fi
Marc-André Lureau0a01d762019-08-21 11:21:16 +04001511
1512case "$meson" in
1513 git | internal)
Marc-André Lureau0a01d762019-08-21 11:21:16 +04001514 meson="$python ${source_path}/meson/meson.py"
1515 ;;
Paolo Bonzini84ec0c22020-09-04 10:00:26 -04001516 *) meson=$(command -v "$meson") ;;
Marc-André Lureau0a01d762019-08-21 11:21:16 +04001517esac
1518
Paolo Bonzini09e93322020-08-13 09:28:11 -04001519# Probe for ninja
Paolo Bonzini48328882020-08-26 08:04:15 +02001520
1521if test -z "$ninja"; then
1522 for c in ninja ninja-build samu; do
1523 if has $c; then
1524 ninja=$(command -v "$c")
1525 break
1526 fi
1527 done
Paolo Bonzini09e93322020-08-13 09:28:11 -04001528 if test -z "$ninja"; then
1529 error_exit "Cannot find Ninja"
1530 fi
Paolo Bonzini48328882020-08-26 08:04:15 +02001531fi
Paolo Bonzinia5665052019-06-10 12:05:14 +02001532
Daniel Henrique Barboza9aae6e52017-11-02 07:09:06 -02001533# Check that the C compiler works. Doing this here before testing
1534# the host CPU ensures that we had a valid CC to autodetect the
1535# $cpu var (and we should bail right here if that's not the case).
1536# It also allows the help message to be printed without a CC.
1537write_c_skeleton;
1538if compile_object ; then
1539 : C compiler works ok
1540else
1541 error_exit "\"$cc\" either does not exist or does not work"
1542fi
1543if ! compile_prog ; then
1544 error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
1545fi
1546
Peter Maydell9c83ffd2014-02-25 18:27:49 +00001547# Consult white-list to determine whether to enable werror
1548# by default. Only enable by default for git builds
Peter Maydell9c83ffd2014-02-25 18:27:49 +00001549if test -z "$werror" ; then
Dan Streetman7d7dbf92021-01-19 12:20:46 -05001550 if test "$git_submodules_action" != "ignore" && \
Eric Blakee633a5c2019-02-04 20:39:37 -06001551 { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
Peter Maydell9c83ffd2014-02-25 18:27:49 +00001552 werror="yes"
1553 else
1554 werror="no"
1555 fi
1556fi
1557
Paolo Bonzini975ff032020-11-20 10:34:10 +01001558if test "$targetos" = "bogus"; then
Peter Maydellfb59dab2017-03-28 14:01:52 +01001559 # Now that we know that we're not printing the help and that
1560 # the compiler works (so the results of the check_defines we used
1561 # to identify the OS are reliable), if we didn't recognize the
1562 # host OS we should stop now.
Peter Maydell951fedf2017-07-13 16:15:32 +01001563 error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
Peter Maydellfb59dab2017-03-28 14:01:52 +01001564fi
1565
Thomas Huthefc6c072018-12-03 10:12:32 +01001566# Check whether the compiler matches our minimum requirements:
1567cat > $TMPC << EOF
1568#if defined(__clang_major__) && defined(__clang_minor__)
1569# ifdef __apple_build_version__
Daniel P. Berrangé2a85a082021-05-14 13:04:15 +01001570# if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0)
1571# error You need at least XCode Clang v10.0 to compile QEMU
Thomas Huthefc6c072018-12-03 10:12:32 +01001572# endif
1573# else
Daniel P. Berrangé2a85a082021-05-14 13:04:15 +01001574# if __clang_major__ < 6 || (__clang_major__ == 6 && __clang_minor__ < 0)
1575# error You need at least Clang v6.0 to compile QEMU
Thomas Huthefc6c072018-12-03 10:12:32 +01001576# endif
1577# endif
1578#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
nia3830df52021-10-01 15:30:03 +00001579# if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4)
1580# error You need at least GCC v7.4.0 to compile QEMU
Thomas Huthefc6c072018-12-03 10:12:32 +01001581# endif
1582#else
1583# error You either need GCC or Clang to compiler QEMU
1584#endif
1585int main (void) { return 0; }
1586EOF
1587if ! compile_prog "" "" ; then
nia3830df52021-10-01 15:30:03 +00001588 error_exit "You need at least GCC v7.4 or Clang v6.0 (or XCode Clang v10.0)"
Thomas Huthefc6c072018-12-03 10:12:32 +01001589fi
1590
Richard Henderson00849b92020-06-17 13:13:06 -07001591# Accumulate -Wfoo and -Wno-bar separately.
1592# We will list all of the enable flags first, and the disable flags second.
1593# Note that we do not add -Werror, because that would enable it for all
1594# configure tests. If a configure test failed due to -Werror this would
1595# just silently disable some features, so it's too error prone.
1596
1597warn_flags=
1598add_to warn_flags -Wold-style-declaration
1599add_to warn_flags -Wold-style-definition
1600add_to warn_flags -Wtype-limits
1601add_to warn_flags -Wformat-security
1602add_to warn_flags -Wformat-y2k
1603add_to warn_flags -Winit-self
1604add_to warn_flags -Wignored-qualifiers
1605add_to warn_flags -Wempty-body
1606add_to warn_flags -Wnested-externs
1607add_to warn_flags -Wendif-labels
1608add_to warn_flags -Wexpansion-to-defined
Thomas Huth0a2ebce2020-12-11 16:24:26 +01001609add_to warn_flags -Wimplicit-fallthrough=2
Richard Henderson00849b92020-06-17 13:13:06 -07001610
1611nowarn_flags=
1612add_to nowarn_flags -Wno-initializer-overrides
1613add_to nowarn_flags -Wno-missing-include-dirs
1614add_to nowarn_flags -Wno-shift-negative-value
1615add_to nowarn_flags -Wno-string-plus-int
1616add_to nowarn_flags -Wno-typedef-redefinition
Richard Hendersonaabab962020-06-17 13:13:07 -07001617add_to nowarn_flags -Wno-tautological-type-limit-compare
Richard Hendersonbac8d222020-06-17 13:13:08 -07001618add_to nowarn_flags -Wno-psabi
Richard Henderson00849b92020-06-17 13:13:06 -07001619
1620gcc_flags="$warn_flags $nowarn_flags"
John Snow93b25862015-03-25 18:57:37 -04001621
1622cc_has_warning_flag() {
1623 write_c_skeleton;
1624
Peter Maydella1d29d62012-10-27 22:19:07 +01001625 # Use the positive sense of the flag when testing for -Wno-wombat
1626 # support (gcc will happily accept the -Wno- form of unknown
1627 # warning options).
John Snow93b25862015-03-25 18:57:37 -04001628 optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
1629 compile_prog "-Werror $optflag" ""
1630}
1631
1632for flag in $gcc_flags; do
1633 if cc_has_warning_flag $flag ; then
1634 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
Paolo Bonzini8d050952010-12-23 11:43:52 +01001635 fi
1636done
1637
Miroslav Rezanina3b463a32014-07-02 10:05:24 +02001638if test "$stack_protector" != "no"; then
Rodrigo Rebellofccd35a2015-11-12 12:04:28 -02001639 cat > $TMPC << EOF
1640int main(int argc, char *argv[])
1641{
1642 char arr[64], *p = arr, *c = argv[0];
1643 while (*c) {
1644 *p++ = *c++;
1645 }
1646 return 0;
1647}
1648EOF
Steven Noonan63678e12014-03-28 17:19:02 +01001649 gcc_flags="-fstack-protector-strong -fstack-protector-all"
Miroslav Rezanina3b463a32014-07-02 10:05:24 +02001650 sp_on=0
Steven Noonan63678e12014-03-28 17:19:02 +01001651 for flag in $gcc_flags; do
Peter Maydell590e5dd2014-04-11 17:13:52 +01001652 # We need to check both a compile and a link, since some compiler
1653 # setups fail only on a .c->.o compile and some only at link time
Paolo Bonzini086d5f72020-02-03 15:22:17 +01001654 if compile_object "-Werror $flag" &&
Peter Maydell590e5dd2014-04-11 17:13:52 +01001655 compile_prog "-Werror $flag" ""; then
Steven Noonan63678e12014-03-28 17:19:02 +01001656 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
Paolo Bonzinidb5adea2019-12-11 15:34:27 +01001657 QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
Miroslav Rezanina3b463a32014-07-02 10:05:24 +02001658 sp_on=1
Steven Noonan63678e12014-03-28 17:19:02 +01001659 break
1660 fi
1661 done
Miroslav Rezanina3b463a32014-07-02 10:05:24 +02001662 if test "$stack_protector" = yes; then
1663 if test $sp_on = 0; then
1664 error_exit "Stack protector not supported"
1665 fi
1666 fi
Marc-André Lureau37746c52013-02-25 23:31:12 +01001667fi
1668
Paolo Bonzini20bc94a2017-10-20 12:11:32 +02001669# Disable -Wmissing-braces on older compilers that warn even for
1670# the "universal" C zero initializer {0}.
1671cat > $TMPC << EOF
1672struct {
1673 int a[2];
1674} x = {0};
1675EOF
1676if compile_object "-Werror" "" ; then
1677 :
1678else
1679 QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
1680fi
1681
Marc-André Lureau21e709a2019-07-18 16:04:13 +04001682# Our module code doesn't support Windows
1683if test "$modules" = "yes" && test "$mingw32" = "yes" ; then
1684 error_exit "Modules are not available for Windows"
1685fi
1686
Christian Ehrhardtbd83c862020-03-10 15:58:06 +01001687# module_upgrades is only reasonable if modules are enabled
1688if test "$modules" = "no" && test "$module_upgrades" = "yes" ; then
1689 error_exit "Can't enable module-upgrades as Modules are not enabled"
1690fi
1691
Alex Bennée5f2453a2021-07-09 15:29:55 +01001692# Static linking is not possible with plugins, modules or PIE
Avi Kivity40d64442011-11-15 20:12:17 +02001693if test "$static" = "yes" ; then
Paolo Bonziniaa0d1f42014-02-25 17:36:55 +01001694 if test "$modules" = "yes" ; then
1695 error_exit "static and modules are mutually incompatible"
1696 fi
Alex Bennée5f2453a2021-07-09 15:29:55 +01001697 if test "$plugins" = "yes"; then
1698 error_exit "static and plugins are mutually incompatible"
Alex Bennéeba4dd2a2021-07-09 15:29:57 +01001699 else
1700 plugins="no"
Alex Bennée5f2453a2021-07-09 15:29:55 +01001701 fi
Avi Kivity40d64442011-11-15 20:12:17 +02001702fi
1703
Richard Hendersonb2634122019-12-17 13:54:56 -10001704cat > $TMPC << EOF
Avi Kivity21d4a792011-11-23 11:24:25 +02001705
1706#ifdef __linux__
1707# define THREAD __thread
1708#else
1709# define THREAD
1710#endif
Avi Kivity21d4a792011-11-23 11:24:25 +02001711static THREAD int tls_var;
Avi Kivity21d4a792011-11-23 11:24:25 +02001712int main(void) { return tls_var; }
Avi Kivity40d64442011-11-15 20:12:17 +02001713EOF
Alex Bennée412aeac2019-08-15 19:41:51 +00001714
Jessica Clarkeffd205e2021-08-05 20:25:45 +01001715# Check we support -fno-pie and -no-pie first; we will need the former for
1716# building ROMs, and both for everything if --disable-pie is passed.
Richard Hendersonb2634122019-12-17 13:54:56 -10001717if compile_prog "-Werror -fno-pie" "-no-pie"; then
1718 CFLAGS_NOPIE="-fno-pie"
Jessica Clarkeffd205e2021-08-05 20:25:45 +01001719 LDFLAGS_NOPIE="-no-pie"
Richard Hendersonb2634122019-12-17 13:54:56 -10001720fi
1721
Richard Henderson12781462019-12-17 15:30:14 -10001722if test "$static" = "yes"; then
Richard Hendersoneca7a8e2020-04-03 20:11:50 +01001723 if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then
Paolo Bonzini5770e8a2020-09-23 05:26:15 -04001724 CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
Richard Henderson12781462019-12-17 15:30:14 -10001725 QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS"
1726 pie="yes"
1727 elif test "$pie" = "yes"; then
1728 error_exit "-static-pie not available due to missing toolchain support"
1729 else
1730 QEMU_LDFLAGS="-static $QEMU_LDFLAGS"
1731 pie="no"
1732 fi
1733elif test "$pie" = "no"; then
Paolo Bonzini5770e8a2020-09-23 05:26:15 -04001734 CONFIGURE_CFLAGS="$CFLAGS_NOPIE $CONFIGURE_CFLAGS"
Jessica Clarkeffd205e2021-08-05 20:25:45 +01001735 CONFIGURE_LDFLAGS="$LDFLAGS_NOPIE $CONFIGURE_LDFLAGS"
Richard Hendersoneca7a8e2020-04-03 20:11:50 +01001736elif compile_prog "-Werror -fPIE -DPIE" "-pie"; then
Paolo Bonzini5770e8a2020-09-23 05:26:15 -04001737 CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
1738 CONFIGURE_LDFLAGS="-pie $CONFIGURE_LDFLAGS"
Richard Henderson2c674102019-12-17 15:15:01 -10001739 pie="yes"
1740elif test "$pie" = "yes"; then
1741 error_exit "PIE not available due to missing toolchain support"
1742else
1743 echo "Disabling PIE due to missing toolchain support"
1744 pie="no"
Avi Kivity40d64442011-11-15 20:12:17 +02001745fi
1746
Richard Hendersone6cbd752019-12-17 14:00:39 -10001747# Detect support for PT_GNU_RELRO + DT_BIND_NOW.
1748# The combination is known as "full relro", because .got.plt is read-only too.
1749if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
1750 QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS"
1751fi
1752
Paolo Bonzini09dada42013-04-17 16:26:47 +02001753##########################################
1754# __sync_fetch_and_and requires at least -march=i486. Many toolchains
1755# use i686 as default anyway, but for those that don't, an explicit
1756# specification is necessary
1757
1758if test "$cpu" = "i386"; then
1759 cat > $TMPC << EOF
1760static int sfaa(int *ptr)
1761{
1762 return __sync_fetch_and_and(ptr, 0);
1763}
1764
1765int main(void)
1766{
1767 int val = 42;
Stefan Weil1405b622013-05-11 21:46:58 +02001768 val = __sync_val_compare_and_swap(&val, 0, 1);
Paolo Bonzini09dada42013-04-17 16:26:47 +02001769 sfaa(&val);
1770 return val;
1771}
1772EOF
1773 if ! compile_prog "" "" ; then
1774 QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
1775 fi
1776fi
1777
Philippe Mathieu-Daudé56267b62021-05-12 06:58:21 +02001778if test "$tcg" = "enabled"; then
1779 git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
1780 git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
1781fi
1782
Stefan Weilafb63eb2012-09-26 22:04:38 +02001783if test -z "${target_list+xxx}" ; then
Paolo Bonzinifdb75ae2020-09-21 04:37:49 -04001784 default_targets=yes
Paolo Bonzinid880a3b2017-07-03 16:58:28 +02001785 for target in $default_target_list; do
Paolo Bonzinifdb75ae2020-09-21 04:37:49 -04001786 target_list="$target_list $target"
Paolo Bonzinid880a3b2017-07-03 16:58:28 +02001787 done
1788 target_list="${target_list# }"
Anthony Liguori121afa92012-09-14 08:17:03 -05001789else
Paolo Bonzinifdb75ae2020-09-21 04:37:49 -04001790 default_targets=no
Stefan Weil89138852016-05-16 15:10:20 +02001791 target_list=$(echo "$target_list" | sed -e 's/,/ /g')
Paolo Bonzinid880a3b2017-07-03 16:58:28 +02001792 for target in $target_list; do
1793 # Check that we recognised the target name; this allows a more
1794 # friendly error message than if we let it fall through.
1795 case " $default_target_list " in
1796 *" $target "*)
1797 ;;
1798 *)
1799 error_exit "Unknown target name '$target'"
1800 ;;
1801 esac
Paolo Bonzinid880a3b2017-07-03 16:58:28 +02001802 done
bellard5327cf42005-01-10 23:18:50 +00001803fi
Peter Maydell25b48332013-05-20 16:16:16 +01001804
Paolo Bonzinifdb75ae2020-09-21 04:37:49 -04001805for target in $target_list; do
1806 # if a deprecated target is enabled we note it here
1807 if echo "$deprecated_targets_list" | grep -q "$target"; then
1808 add_to deprecated_features $target
1809 fi
1810done
1811
Paolo Bonzinif55fe272010-05-26 16:08:17 +02001812# see if system emulation was really requested
1813case " $target_list " in
1814 *"-softmmu "*) softmmu=yes
1815 ;;
1816 *) softmmu=no
1817 ;;
1818esac
bellard5327cf42005-01-10 23:18:50 +00001819
Juan Quintela249247c2009-08-12 18:20:25 +02001820feature_not_found() {
1821 feature=$1
Stewart Smith21684af2014-01-24 12:39:10 +11001822 remedy=$2
Juan Quintela249247c2009-08-12 18:20:25 +02001823
Peter Maydell76ad07a2013-04-08 12:11:26 +01001824 error_exit "User requested feature $feature" \
Stewart Smith21684af2014-01-24 12:39:10 +11001825 "configure was not able to find it." \
1826 "$remedy"
Juan Quintela249247c2009-08-12 18:20:25 +02001827}
1828
bellard7d132992003-03-06 23:23:54 +00001829# ---
1830# big/little endian test
1831cat > $TMPC << EOF
Thomas Huth659eb152021-07-15 10:39:28 +02001832#include <stdio.h>
Mike Frysinger61cc9192013-06-30 23:30:18 -04001833short big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
1834short little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
Thomas Huth659eb152021-07-15 10:39:28 +02001835int main(int argc, char *argv[])
1836{
1837 return printf("%s %s\n", (char *)big_endian, (char *)little_endian);
bellard7d132992003-03-06 23:23:54 +00001838}
1839EOF
1840
Thomas Huth659eb152021-07-15 10:39:28 +02001841if compile_prog ; then
1842 if strings -a $TMPE | grep -q BiGeNdIaN ; then
Mike Frysinger61cc9192013-06-30 23:30:18 -04001843 bigendian="yes"
Thomas Huth659eb152021-07-15 10:39:28 +02001844 elif strings -a $TMPE | grep -q LiTtLeEnDiAn ; then
Mike Frysinger61cc9192013-06-30 23:30:18 -04001845 bigendian="no"
1846 else
1847 echo big/little test failed
Thomas Huth659eb152021-07-15 10:39:28 +02001848 exit 1
Peter Maydell21d89f82011-11-30 10:57:48 +01001849 fi
Mike Frysinger61cc9192013-06-30 23:30:18 -04001850else
1851 echo big/little test failed
Thomas Huth659eb152021-07-15 10:39:28 +02001852 exit 1
bellard7d132992003-03-06 23:23:54 +00001853fi
1854
Juan Quintelab0a47e72009-08-12 18:29:49 +02001855##########################################
Philippe Mathieu-Daudée10ee3f2020-02-17 14:33:27 +01001856# system tools
1857if test -z "$want_tools"; then
1858 if test "$softmmu" = "no"; then
1859 want_tools=no
1860 else
1861 want_tools=yes
1862 fi
1863fi
1864
Paolo Bonzini299e6f12019-02-14 18:35:53 +01001865#########################################
1866# vhost interdependencies and host support
1867
1868# vhost backends
Stefan Hajnoczid88618f2020-11-10 17:11:21 +00001869if test "$vhost_user" = "yes" && test "$linux" != "yes"; then
1870 error_exit "vhost-user is only available on Linux"
Paolo Bonzini299e6f12019-02-14 18:35:53 +01001871fi
Cindy Lu108a6482020-07-01 22:55:37 +08001872test "$vhost_vdpa" = "" && vhost_vdpa=$linux
1873if test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then
1874 error_exit "vhost-vdpa is only available on Linux"
1875fi
Paolo Bonzini299e6f12019-02-14 18:35:53 +01001876test "$vhost_kernel" = "" && vhost_kernel=$linux
1877if test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then
1878 error_exit "vhost-kernel is only available on Linux"
1879fi
1880
1881# vhost-kernel devices
1882test "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel
1883if test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then
1884 error_exit "--enable-vhost-scsi requires --enable-vhost-kernel"
1885fi
1886test "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel
1887if test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then
1888 error_exit "--enable-vhost-vsock requires --enable-vhost-kernel"
1889fi
1890
1891# vhost-user backends
1892test "$vhost_net_user" = "" && vhost_net_user=$vhost_user
1893if test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then
1894 error_exit "--enable-vhost-net-user requires --enable-vhost-user"
1895fi
1896test "$vhost_crypto" = "" && vhost_crypto=$vhost_user
1897if test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then
1898 error_exit "--enable-vhost-crypto requires --enable-vhost-user"
1899fi
Dr. David Alan Gilbert98fc1ad2019-09-30 11:51:34 +01001900test "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user
1901if test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then
1902 error_exit "--enable-vhost-user-fs requires --enable-vhost-user"
1903fi
Cindy Lu108a6482020-07-01 22:55:37 +08001904#vhost-vdpa backends
1905test "$vhost_net_vdpa" = "" && vhost_net_vdpa=$vhost_vdpa
1906if test "$vhost_net_vdpa" = "yes" && test "$vhost_vdpa" = "no"; then
1907 error_exit "--enable-vhost-net-vdpa requires --enable-vhost-vdpa"
1908fi
Paolo Bonzini299e6f12019-02-14 18:35:53 +01001909
Laurent Vivier40bc0ca2020-09-24 23:00:23 +02001910# OR the vhost-kernel, vhost-vdpa and vhost-user values for simplicity
Paolo Bonzini299e6f12019-02-14 18:35:53 +01001911if test "$vhost_net" = ""; then
1912 test "$vhost_net_user" = "yes" && vhost_net=yes
Laurent Vivier40bc0ca2020-09-24 23:00:23 +02001913 test "$vhost_net_vdpa" = "yes" && vhost_net=yes
Paolo Bonzini299e6f12019-02-14 18:35:53 +01001914 test "$vhost_kernel" = "yes" && vhost_net=yes
1915fi
1916
Gonglei015a33b2014-07-01 20:58:08 +08001917##########################################
Stefan Weil779ab5e2012-12-16 11:29:45 +01001918# pkg-config probe
1919
1920if ! has "$pkg_config_exe"; then
Peter Maydell76ad07a2013-04-08 12:11:26 +01001921 error_exit "pkg-config binary '$pkg_config_exe' not found"
Stefan Weil779ab5e2012-12-16 11:29:45 +01001922fi
1923
1924##########################################
aliguorie37630c2009-04-22 15:19:10 +00001925# xen probe
1926
Paolo Bonzini1badb702020-09-18 04:57:25 -04001927if test "$xen" != "disabled" ; then
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02001928 # Check whether Xen library path is specified via --extra-ldflags to avoid
1929 # overriding this setting with pkg-config output. If not, try pkg-config
1930 # to obtain all needed flags.
Anthony PERARDd5b93dd2011-02-25 16:20:34 +00001931
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02001932 if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
1933 $pkg_config --exists xencontrol ; then
1934 xen_ctrl_version="$(printf '%d%02d%02d' \
1935 $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
Paolo Bonzini1badb702020-09-18 04:57:25 -04001936 xen=enabled
Michael Tokarev5b6a8f42020-07-27 17:00:48 +03001937 xen_pc="xencontrol xenstore xenforeignmemory xengnttab"
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02001938 xen_pc="$xen_pc xenevtchn xendevicemodel"
Anthony PERARD58ea9a72017-09-25 16:01:48 +01001939 if $pkg_config --exists xentoolcore; then
1940 xen_pc="$xen_pc xentoolcore"
1941 fi
Marc-André Lureau582ea952019-08-15 15:15:32 +04001942 xen_cflags="$($pkg_config --cflags $xen_pc)"
1943 xen_libs="$($pkg_config --libs $xen_pc)"
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02001944 else
Stefan Weil50ced5b2011-12-17 09:27:39 +01001945
Michael Tokarev5b6a8f42020-07-27 17:00:48 +03001946 xen_libs="-lxenstore -lxenctrl"
Anthony PERARDd9506ca2017-05-11 12:35:42 +01001947 xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02001948
1949 # First we test whether Xen headers and libraries are available.
1950 # If no, we are done and there is no Xen support.
1951 # If yes, more tests are run to detect the Xen version.
1952
1953 # Xen (any)
1954 cat > $TMPC <<EOF
aliguorie37630c2009-04-22 15:19:10 +00001955#include <xenctrl.h>
Stefan Weil50ced5b2011-12-17 09:27:39 +01001956int main(void) {
1957 return 0;
1958}
1959EOF
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02001960 if ! compile_prog "" "$xen_libs" ; then
1961 # Xen not found
Paolo Bonzini1badb702020-09-18 04:57:25 -04001962 if test "$xen" = "enabled" ; then
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02001963 feature_not_found "xen" "Install xen devel"
1964 fi
Paolo Bonzini1badb702020-09-18 04:57:25 -04001965 xen=disabled
Stefan Weil50ced5b2011-12-17 09:27:39 +01001966
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02001967 # Xen unstable
1968 elif
1969 cat > $TMPC <<EOF &&
Ross Lagerwall2cbf8902017-10-23 10:27:27 +01001970#undef XC_WANT_COMPAT_DEVICEMODEL_API
1971#define __XEN_TOOLS__
1972#include <xendevicemodel.h>
Paul Durrantd3c49eb2018-05-15 17:40:53 +01001973#include <xenforeignmemory.h>
Ross Lagerwall2cbf8902017-10-23 10:27:27 +01001974int main(void) {
1975 xendevicemodel_handle *xd;
Paul Durrantd3c49eb2018-05-15 17:40:53 +01001976 xenforeignmemory_handle *xfmem;
Ross Lagerwall2cbf8902017-10-23 10:27:27 +01001977
1978 xd = xendevicemodel_open(0, 0);
1979 xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
1980
Paul Durrantd3c49eb2018-05-15 17:40:53 +01001981 xfmem = xenforeignmemory_open(0, 0);
1982 xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
1983
Ross Lagerwall2cbf8902017-10-23 10:27:27 +01001984 return 0;
1985}
1986EOF
1987 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
1988 then
1989 xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
1990 xen_ctrl_version=41100
Paolo Bonzini1badb702020-09-18 04:57:25 -04001991 xen=enabled
Ross Lagerwall2cbf8902017-10-23 10:27:27 +01001992 elif
1993 cat > $TMPC <<EOF &&
Igor Druzhinin5ba3d752017-07-10 23:40:02 +01001994#undef XC_WANT_COMPAT_MAP_FOREIGN_API
1995#include <xenforeignmemory.h>
Anthony PERARD58ea9a72017-09-25 16:01:48 +01001996#include <xentoolcore.h>
Igor Druzhinin5ba3d752017-07-10 23:40:02 +01001997int main(void) {
1998 xenforeignmemory_handle *xfmem;
1999
2000 xfmem = xenforeignmemory_open(0, 0);
2001 xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
Anthony PERARD58ea9a72017-09-25 16:01:48 +01002002 xentoolcore_restrict_all(0);
Igor Druzhinin5ba3d752017-07-10 23:40:02 +01002003
2004 return 0;
2005}
2006EOF
Anthony PERARD58ea9a72017-09-25 16:01:48 +01002007 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
Igor Druzhinin5ba3d752017-07-10 23:40:02 +01002008 then
Anthony PERARD58ea9a72017-09-25 16:01:48 +01002009 xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
Igor Druzhinin5ba3d752017-07-10 23:40:02 +01002010 xen_ctrl_version=41000
Paolo Bonzini1badb702020-09-18 04:57:25 -04002011 xen=enabled
Igor Druzhinin5ba3d752017-07-10 23:40:02 +01002012 elif
2013 cat > $TMPC <<EOF &&
Paul Durrantda8090c2017-03-07 10:55:33 +00002014#undef XC_WANT_COMPAT_DEVICEMODEL_API
2015#define __XEN_TOOLS__
2016#include <xendevicemodel.h>
2017int main(void) {
2018 xendevicemodel_handle *xd;
2019
2020 xd = xendevicemodel_open(0, 0);
2021 xendevicemodel_close(xd);
2022
2023 return 0;
2024}
2025EOF
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02002026 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2027 then
2028 xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2029 xen_ctrl_version=40900
Paolo Bonzini1badb702020-09-18 04:57:25 -04002030 xen=enabled
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02002031 elif
2032 cat > $TMPC <<EOF &&
Ian Campbell5eeb39c2016-01-15 13:23:42 +00002033/*
2034 * If we have stable libs the we don't want the libxc compat
2035 * layers, regardless of what CFLAGS we may have been given.
Paulina Szubarczykb6eb9b42016-09-14 21:10:03 +02002036 *
2037 * Also, check if xengnttab_grant_copy_segment_t is defined and
2038 * grant copy operation is implemented.
2039 */
2040#undef XC_WANT_COMPAT_EVTCHN_API
2041#undef XC_WANT_COMPAT_GNTTAB_API
2042#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2043#include <xenctrl.h>
2044#include <xenstore.h>
2045#include <xenevtchn.h>
2046#include <xengnttab.h>
2047#include <xenforeignmemory.h>
2048#include <stdint.h>
2049#include <xen/hvm/hvm_info_table.h>
2050#if !defined(HVM_MAX_VCPUS)
2051# error HVM_MAX_VCPUS not defined
2052#endif
2053int main(void) {
2054 xc_interface *xc = NULL;
2055 xenforeignmemory_handle *xfmem;
2056 xenevtchn_handle *xe;
2057 xengnttab_handle *xg;
Paulina Szubarczykb6eb9b42016-09-14 21:10:03 +02002058 xengnttab_grant_copy_segment_t* seg = NULL;
2059
2060 xs_daemon_open();
2061
2062 xc = xc_interface_open(0, 0, 0);
2063 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2064 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2065 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2066 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
Paulina Szubarczykb6eb9b42016-09-14 21:10:03 +02002067
2068 xfmem = xenforeignmemory_open(0, 0);
2069 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2070
2071 xe = xenevtchn_open(0, 0);
2072 xenevtchn_fd(xe);
2073
2074 xg = xengnttab_open(0, 0);
2075 xengnttab_grant_copy(xg, 0, seg);
2076
2077 return 0;
2078}
2079EOF
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02002080 compile_prog "" "$xen_libs $xen_stable_libs"
2081 then
2082 xen_ctrl_version=40800
Paolo Bonzini1badb702020-09-18 04:57:25 -04002083 xen=enabled
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02002084 elif
2085 cat > $TMPC <<EOF &&
Paulina Szubarczykb6eb9b42016-09-14 21:10:03 +02002086/*
2087 * If we have stable libs the we don't want the libxc compat
2088 * layers, regardless of what CFLAGS we may have been given.
Ian Campbell5eeb39c2016-01-15 13:23:42 +00002089 */
2090#undef XC_WANT_COMPAT_EVTCHN_API
2091#undef XC_WANT_COMPAT_GNTTAB_API
2092#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2093#include <xenctrl.h>
2094#include <xenstore.h>
2095#include <xenevtchn.h>
2096#include <xengnttab.h>
2097#include <xenforeignmemory.h>
2098#include <stdint.h>
2099#include <xen/hvm/hvm_info_table.h>
2100#if !defined(HVM_MAX_VCPUS)
2101# error HVM_MAX_VCPUS not defined
2102#endif
2103int main(void) {
2104 xc_interface *xc = NULL;
2105 xenforeignmemory_handle *xfmem;
2106 xenevtchn_handle *xe;
2107 xengnttab_handle *xg;
Ian Campbell5eeb39c2016-01-15 13:23:42 +00002108
2109 xs_daemon_open();
2110
2111 xc = xc_interface_open(0, 0, 0);
2112 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2113 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2114 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2115 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
Ian Campbell5eeb39c2016-01-15 13:23:42 +00002116
2117 xfmem = xenforeignmemory_open(0, 0);
2118 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2119
2120 xe = xenevtchn_open(0, 0);
2121 xenevtchn_fd(xe);
2122
2123 xg = xengnttab_open(0, 0);
2124 xengnttab_map_grant_ref(xg, 0, 0, 0);
2125
2126 return 0;
2127}
2128EOF
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02002129 compile_prog "" "$xen_libs $xen_stable_libs"
2130 then
2131 xen_ctrl_version=40701
Paolo Bonzini1badb702020-09-18 04:57:25 -04002132 xen=enabled
Roger Pau Monnecdadde32015-11-13 17:38:06 +00002133
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02002134 # Xen 4.6
2135 elif
2136 cat > $TMPC <<EOF &&
Roger Pau Monnecdadde32015-11-13 17:38:06 +00002137#include <xenctrl.h>
Anthony PERARDe108a3c2012-06-21 11:44:35 +00002138#include <xenstore.h>
Anthony PERARDd5b93dd2011-02-25 16:20:34 +00002139#include <stdint.h>
2140#include <xen/hvm/hvm_info_table.h>
2141#if !defined(HVM_MAX_VCPUS)
2142# error HVM_MAX_VCPUS not defined
2143#endif
2144int main(void) {
2145 xc_interface *xc;
2146 xs_daemon_open();
2147 xc = xc_interface_open(0, 0, 0);
2148 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2149 xc_gnttab_open(NULL, 0);
Anthony PERARDb87de242011-05-24 14:34:20 +01002150 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
Stefano Stabellini8688e062012-04-17 17:04:18 +00002151 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
Jan Beulichd8b441a2015-07-24 03:38:28 -06002152 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
Konrad Rzeszutek Wilk20a544c2015-06-29 12:51:05 -04002153 xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
Jan Beulichd8b441a2015-07-24 03:38:28 -06002154 return 0;
2155}
2156EOF
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02002157 compile_prog "" "$xen_libs"
2158 then
2159 xen_ctrl_version=40600
Paolo Bonzini1badb702020-09-18 04:57:25 -04002160 xen=enabled
Jan Beulichd8b441a2015-07-24 03:38:28 -06002161
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02002162 # Xen 4.5
2163 elif
2164 cat > $TMPC <<EOF &&
Jan Beulichd8b441a2015-07-24 03:38:28 -06002165#include <xenctrl.h>
2166#include <xenstore.h>
2167#include <stdint.h>
2168#include <xen/hvm/hvm_info_table.h>
2169#if !defined(HVM_MAX_VCPUS)
2170# error HVM_MAX_VCPUS not defined
2171#endif
2172int main(void) {
2173 xc_interface *xc;
2174 xs_daemon_open();
2175 xc = xc_interface_open(0, 0, 0);
2176 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2177 xc_gnttab_open(NULL, 0);
2178 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2179 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
Paul Durrant3996e852015-01-20 11:06:19 +00002180 xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
2181 return 0;
2182}
2183EOF
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02002184 compile_prog "" "$xen_libs"
2185 then
2186 xen_ctrl_version=40500
Paolo Bonzini1badb702020-09-18 04:57:25 -04002187 xen=enabled
Paul Durrant3996e852015-01-20 11:06:19 +00002188
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02002189 elif
2190 cat > $TMPC <<EOF &&
Paul Durrant3996e852015-01-20 11:06:19 +00002191#include <xenctrl.h>
2192#include <xenstore.h>
2193#include <stdint.h>
2194#include <xen/hvm/hvm_info_table.h>
2195#if !defined(HVM_MAX_VCPUS)
2196# error HVM_MAX_VCPUS not defined
2197#endif
2198int main(void) {
2199 xc_interface *xc;
2200 xs_daemon_open();
2201 xc = xc_interface_open(0, 0, 0);
2202 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2203 xc_gnttab_open(NULL, 0);
2204 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2205 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
Stefano Stabellini8688e062012-04-17 17:04:18 +00002206 return 0;
2207}
2208EOF
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02002209 compile_prog "" "$xen_libs"
2210 then
2211 xen_ctrl_version=40200
Paolo Bonzini1badb702020-09-18 04:57:25 -04002212 xen=enabled
Stefano Stabellini8688e062012-04-17 17:04:18 +00002213
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02002214 else
Paolo Bonzini1badb702020-09-18 04:57:25 -04002215 if test "$xen" = "enabled" ; then
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02002216 feature_not_found "xen (unsupported version)" \
2217 "Install a supported xen (xen 4.2 or newer)"
2218 fi
Paolo Bonzini1badb702020-09-18 04:57:25 -04002219 xen=disabled
Juan Quintelafc321b42009-08-12 18:29:55 +02002220 fi
Anthony PERARDd5b93dd2011-02-25 16:20:34 +00002221
Paolo Bonzini1badb702020-09-18 04:57:25 -04002222 if test "$xen" = enabled; then
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02002223 if test $xen_ctrl_version -ge 40701 ; then
Marc-André Lureau582ea952019-08-15 15:15:32 +04002224 xen_libs="$xen_libs $xen_stable_libs "
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02002225 fi
Ian Campbell5eeb39c2016-01-15 13:23:42 +00002226 fi
Anthony PERARDd5b93dd2011-02-25 16:20:34 +00002227 fi
aliguorie37630c2009-04-22 15:19:10 +00002228fi
2229
2230##########################################
Michael R. Hines2da776d2013-07-22 10:01:54 -04002231# RDMA needs OpenFabrics libraries
2232if test "$rdma" != "no" ; then
2233 cat > $TMPC <<EOF
2234#include <rdma/rdma_cma.h>
2235int main(void) { return 0; }
2236EOF
Yuval Shaiaef6d4cc2018-02-09 15:23:18 +02002237 rdma_libs="-lrdmacm -libverbs -libumad"
Michael R. Hines2da776d2013-07-22 10:01:54 -04002238 if compile_prog "" "$rdma_libs" ; then
2239 rdma="yes"
Michael R. Hines2da776d2013-07-22 10:01:54 -04002240 else
2241 if test "$rdma" = "yes" ; then
2242 error_exit \
Yuval Shaiaef6d4cc2018-02-09 15:23:18 +02002243 " OpenFabrics librdmacm/libibverbs/libibumad not present." \
Michael R. Hines2da776d2013-07-22 10:01:54 -04002244 " Your options:" \
Yuval Shaiaef6d4cc2018-02-09 15:23:18 +02002245 " (1) Fast: Install infiniband packages (devel) from your distro." \
Michael R. Hines2da776d2013-07-22 10:01:54 -04002246 " (2) Cleanest: Install libraries from www.openfabrics.org" \
2247 " (3) Also: Install softiwarp if you don't have RDMA hardware"
2248 fi
2249 rdma="no"
2250 fi
2251fi
2252
Marcel Apfelbaum21ab34c2018-08-16 18:16:37 +03002253##########################################
2254# PVRDMA detection
2255
2256cat > $TMPC <<EOF &&
2257#include <sys/mman.h>
2258
2259int
2260main(void)
2261{
2262 char buf = 0;
2263 void *addr = &buf;
2264 addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED);
2265
2266 return 0;
2267}
2268EOF
2269
2270if test "$rdma" = "yes" ; then
2271 case "$pvrdma" in
2272 "")
2273 if compile_prog "" ""; then
2274 pvrdma="yes"
2275 else
2276 pvrdma="no"
2277 fi
2278 ;;
2279 "yes")
2280 if ! compile_prog "" ""; then
2281 error_exit "PVRDMA is not supported since mremap is not implemented"
2282 fi
2283 pvrdma="yes"
2284 ;;
2285 "no")
2286 pvrdma="no"
2287 ;;
2288 esac
2289else
2290 if test "$pvrdma" = "yes" ; then
2291 error_exit "PVRDMA requires rdma suppport"
2292 fi
2293 pvrdma="no"
2294fi
ths8d5d2d42007-08-25 01:37:51 +00002295
Yuval Shaiaee108582019-08-18 16:21:06 +03002296# Let's see if enhanced reg_mr is supported
2297if test "$pvrdma" = "yes" ; then
2298
2299cat > $TMPC <<EOF &&
2300#include <infiniband/verbs.h>
2301
2302int
2303main(void)
2304{
2305 struct ibv_mr *mr;
2306 struct ibv_pd *pd = NULL;
2307 size_t length = 10;
2308 uint64_t iova = 0;
2309 int access = 0;
2310 void *addr = NULL;
2311
2312 mr = ibv_reg_mr_iova(pd, addr, length, iova, access);
2313
2314 ibv_dereg_mr(mr);
2315
2316 return 0;
2317}
2318EOF
2319 if ! compile_prog "" "-libverbs"; then
2320 QEMU_CFLAGS="$QEMU_CFLAGS -DLEGACY_RDMA_REG_MR"
2321 fi
2322fi
2323
ths8d5d2d42007-08-25 01:37:51 +00002324##########################################
Eric Blakec1bb86c2016-12-02 13:48:54 -06002325# xfsctl() probe, used for file-posix.c
Christoph Hellwigdce512d2010-12-17 11:41:15 +01002326if test "$xfs" != "no" ; then
2327 cat > $TMPC << EOF
Stefan Weilffc41d12011-12-17 09:27:36 +01002328#include <stddef.h> /* NULL */
Christoph Hellwigdce512d2010-12-17 11:41:15 +01002329#include <xfs/xfs.h>
2330int main(void)
2331{
2332 xfsctl(NULL, 0, 0, NULL);
2333 return 0;
2334}
2335EOF
2336 if compile_prog "" "" ; then
2337 xfs="yes"
2338 else
2339 if test "$xfs" = "yes" ; then
zhaolichange3a6e0d2020-09-17 15:50:20 +08002340 feature_not_found "xfs" "Install xfsprogs/xfslibs devel"
Christoph Hellwigdce512d2010-12-17 11:41:15 +01002341 fi
2342 xfs=no
2343 fi
2344fi
2345
2346##########################################
Alex Bennéeba4dd2a2021-07-09 15:29:57 +01002347# plugin linker support probe
2348
2349if test "$plugins" != "no"; then
2350
2351 #########################################
2352 # See if --dynamic-list is supported by the linker
2353
2354 ld_dynamic_list="no"
2355 cat > $TMPTXT <<EOF
2356{
2357 foo;
2358};
2359EOF
2360
2361 cat > $TMPC <<EOF
2362#include <stdio.h>
2363void foo(void);
2364
2365void foo(void)
2366{
2367 printf("foo\n");
2368}
2369
2370int main(void)
2371{
2372 foo();
2373 return 0;
2374}
2375EOF
2376
2377 if compile_prog "" "-Wl,--dynamic-list=$TMPTXT" ; then
2378 ld_dynamic_list="yes"
2379 fi
2380
2381 #########################################
2382 # See if -exported_symbols_list is supported by the linker
2383
2384 ld_exported_symbols_list="no"
2385 cat > $TMPTXT <<EOF
2386 _foo
2387EOF
2388
2389 if compile_prog "" "-Wl,-exported_symbols_list,$TMPTXT" ; then
2390 ld_exported_symbols_list="yes"
2391 fi
2392
2393 if test "$ld_dynamic_list" = "no" &&
2394 test "$ld_exported_symbols_list" = "no" ; then
2395 if test "$plugins" = "yes"; then
2396 error_exit \
2397 "Plugin support requires dynamic linking and specifying a set of symbols " \
2398 "that are exported to plugins. Unfortunately your linker doesn't " \
2399 "support the flag (--dynamic-list or -exported_symbols_list) used " \
2400 "for this purpose."
2401 else
2402 plugins="no"
2403 fi
2404 else
2405 plugins="yes"
2406 fi
2407fi
2408
2409##########################################
Anthony Liguorie18df142011-07-19 14:50:29 -05002410# glib support probe
Paolo Bonzinia52d28a2012-04-05 13:01:54 +02002411
Daniel P. Berrangéb4c60362021-05-14 13:04:13 +01002412glib_req_ver=2.56
Paolo Bonziniaa0d1f42014-02-25 17:36:55 +01002413glib_modules=gthread-2.0
2414if test "$modules" = yes; then
Gerd Hoffmanna88afc62018-03-08 09:53:00 +01002415 glib_modules="$glib_modules gmodule-export-2.0"
Paolo Bonzinib906aca2021-08-11 12:05:50 +02002416elif test "$plugins" = "yes"; then
2417 glib_modules="$glib_modules gmodule-no-export-2.0"
Emilio G. Cota54cb65d2017-08-30 18:39:53 -04002418fi
Fam Zhenge26110c2014-02-10 14:48:57 +08002419
Paolo Bonziniaa0d1f42014-02-25 17:36:55 +01002420for i in $glib_modules; do
Fam Zhenge26110c2014-02-10 14:48:57 +08002421 if $pkg_config --atleast-version=$glib_req_ver $i; then
Stefan Weil89138852016-05-16 15:10:20 +02002422 glib_cflags=$($pkg_config --cflags $i)
2423 glib_libs=$($pkg_config --libs $i)
Fam Zhenge26110c2014-02-10 14:48:57 +08002424 else
2425 error_exit "glib-$glib_req_ver $i is required to compile QEMU"
2426 fi
2427done
2428
Paolo Bonzini215b0c22020-09-01 08:41:17 -04002429# This workaround is required due to a bug in pkg-config file for glib as it
2430# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
2431
2432if test "$static" = yes && test "$mingw32" = yes; then
2433 glib_cflags="-DGLIB_STATIC_COMPILATION $glib_cflags"
2434fi
2435
Denis Plotnikov20cf7b82021-03-12 18:14:40 +03002436if ! test "$gio" = "no"; then
2437 pass=no
2438 if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
2439 gio_cflags=$($pkg_config --cflags gio-2.0)
2440 gio_libs=$($pkg_config --libs gio-2.0)
2441 gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0)
Paolo Bonzini5ecfb762021-05-05 10:15:34 -04002442 if ! has "$gdbus_codegen"; then
Denis Plotnikov20cf7b82021-03-12 18:14:40 +03002443 gdbus_codegen=
2444 fi
2445 # Check that the libraries actually work -- Ubuntu 18.04 ships
2446 # with pkg-config --static --libs data for gio-2.0 that is missing
2447 # -lblkid and will give a link error.
2448 cat > $TMPC <<EOF
Peter Maydell13ceae62020-11-17 12:56:33 +00002449#include <gio/gio.h>
2450int main(void)
2451{
2452 g_dbus_proxy_new_sync(0, 0, 0, 0, 0, 0, 0, 0);
2453 return 0;
2454}
2455EOF
Denis Plotnikov20cf7b82021-03-12 18:14:40 +03002456 if compile_prog "$gio_cflags" "$gio_libs" ; then
2457 pass=yes
2458 else
2459 pass=no
2460 fi
Marc-André Lureauf876b762019-02-21 12:07:00 +01002461
Denis Plotnikov20cf7b82021-03-12 18:14:40 +03002462 if test "$pass" = "yes" &&
2463 $pkg_config --atleast-version=$glib_req_ver gio-unix-2.0; then
2464 gio_cflags="$gio_cflags $($pkg_config --cflags gio-unix-2.0)"
2465 gio_libs="$gio_libs $($pkg_config --libs gio-unix-2.0)"
2466 fi
2467 fi
2468
2469 if test "$pass" = "no"; then
2470 if test "$gio" = "yes"; then
2471 feature_not_found "gio" "Install libgio >= 2.0"
2472 else
2473 gio=no
2474 fi
2475 else
2476 gio=yes
2477 fi
Marc-André Lureau25a97a52019-09-27 11:34:42 +04002478fi
2479
Daniel P. Berrange977a82a2016-01-27 09:00:45 +00002480# Sanity check that the current size_t matches the
2481# size that glib thinks it should be. This catches
2482# problems on multi-arch where people try to build
2483# 32-bit QEMU while pointing at 64-bit glib headers
2484cat > $TMPC <<EOF
2485#include <glib.h>
2486#include <unistd.h>
2487
2488#define QEMU_BUILD_BUG_ON(x) \
2489 typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
2490
2491int main(void) {
2492 QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
2493 return 0;
2494}
2495EOF
2496
Paolo Bonzini215b0c22020-09-01 08:41:17 -04002497if ! compile_prog "$glib_cflags" "$glib_libs" ; then
Daniel P. Berrange977a82a2016-01-27 09:00:45 +00002498 error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
2499 "You probably need to set PKG_CONFIG_LIBDIR"\
2500 "to point to the right pkg-config files for your"\
2501 "build target"
2502fi
2503
Eric Blake9bda6002020-03-17 12:55:34 -05002504# Silence clang warnings triggered by glib < 2.57.2
2505cat > $TMPC << EOF
2506#include <glib.h>
2507typedef struct Foo {
2508 int i;
2509} Foo;
2510static void foo_free(Foo *f)
2511{
2512 g_free(f);
2513}
2514G_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free);
2515int main(void) { return 0; }
2516EOF
2517if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
2518 if cc_has_warning_flag "-Wno-unused-function"; then
2519 glib_cflags="$glib_cflags -Wno-unused-function"
Paolo Bonzini5770e8a2020-09-23 05:26:15 -04002520 CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -Wno-unused-function"
Eric Blake9bda6002020-03-17 12:55:34 -05002521 fi
2522fi
2523
Fam Zhenge26110c2014-02-10 14:48:57 +08002524##########################################
2525# SHA command probe for modules
2526if test "$modules" = yes; then
2527 shacmd_probe="sha1sum sha1 shasum"
2528 for c in $shacmd_probe; do
Fam Zheng8ccefb92014-12-04 14:18:16 +08002529 if has $c; then
Fam Zhenge26110c2014-02-10 14:48:57 +08002530 shacmd="$c"
2531 break
2532 fi
2533 done
2534 if test "$shacmd" = ""; then
2535 error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
2536 fi
Anthony Liguorie18df142011-07-19 14:50:29 -05002537fi
2538
2539##########################################
Paolo Bonzini7aaa6a12019-01-23 14:56:07 +08002540# TPM emulation is only on POSIX
Paolo Bonzini3b8acc12013-03-18 16:37:50 +01002541
Paolo Bonzini7aaa6a12019-01-23 14:56:07 +08002542if test "$tpm" = ""; then
2543 if test "$mingw32" = "yes"; then
2544 tpm=no
2545 else
2546 tpm=yes
2547 fi
2548elif test "$tpm" = "yes"; then
2549 if test "$mingw32" = "yes" ; then
2550 error_exit "TPM emulation only available on POSIX systems"
2551 fi
Paolo Bonzini3b8acc12013-03-18 16:37:50 +01002552fi
2553
2554##########################################
aurel32f652e6a2008-12-16 10:43:48 +00002555# fdt probe
Paolo Bonzinifbb41212020-10-05 11:31:15 +02002556
2557case "$fdt" in
2558 auto | enabled | internal)
2559 # Simpler to always update submodule, even if not needed.
Paolo Bonzini2d652f22021-05-12 09:21:56 +02002560 git_submodules="${git_submodules} dtc"
Peter Maydelle169e1e2013-05-24 16:26:54 +01002561 ;;
Paolo Bonzinifbb41212020-10-05 11:31:15 +02002562esac
aurel32f652e6a2008-12-16 10:43:48 +00002563
Michael Walle20ff0752011-03-07 23:32:39 +01002564##########################################
Markus Armbruster9d49bcf2021-05-03 10:40:33 +02002565# opengl probe (for sdl2, gtk)
Gerd Hoffmannb1546f32015-03-16 10:03:53 +01002566
Gerd Hoffmannda076ff2014-11-20 09:49:44 +01002567if test "$opengl" != "no" ; then
Akihiko Odakibc6a3562021-02-23 15:03:07 +09002568 epoxy=no
2569 if $pkg_config epoxy; then
2570 cat > $TMPC << EOF
2571#include <epoxy/egl.h>
2572int main(void) { return 0; }
2573EOF
2574 if compile_prog "" "" ; then
2575 epoxy=yes
2576 fi
2577 fi
2578
2579 if test "$epoxy" = "yes" ; then
2580 opengl_cflags="$($pkg_config --cflags epoxy)"
2581 opengl_libs="$($pkg_config --libs epoxy)"
Gerd Hoffmannda076ff2014-11-20 09:49:44 +01002582 opengl=yes
Michael Walle20ff0752011-03-07 23:32:39 +01002583 else
Gerd Hoffmannda076ff2014-11-20 09:49:44 +01002584 if test "$opengl" = "yes" ; then
Akihiko Odakibc6a3562021-02-23 15:03:07 +09002585 feature_not_found "opengl" "Please install epoxy with EGL"
Michael Walle20ff0752011-03-07 23:32:39 +01002586 fi
Jeremy Whitef676c672015-01-09 13:08:49 -06002587 opengl_cflags=""
Gerd Hoffmannda076ff2014-11-20 09:49:44 +01002588 opengl_libs=""
2589 opengl=no
Michael Walle20ff0752011-03-07 23:32:39 +01002590 fi
2591fi
2592
Marcelo Tosattidcc38d12010-10-11 15:31:15 -03002593##########################################
Wanlong Gaoa99d57b2014-05-14 17:43:28 +08002594# libnuma probe
2595
2596if test "$numa" != "no" ; then
2597 cat > $TMPC << EOF
2598#include <numa.h>
2599int main(void) { return numa_available(); }
2600EOF
2601
2602 if compile_prog "" "-lnuma" ; then
2603 numa=yes
Marc-André Lureauab318052019-07-24 19:23:16 +04002604 numa_libs="-lnuma"
Wanlong Gaoa99d57b2014-05-14 17:43:28 +08002605 else
2606 if test "$numa" = "yes" ; then
2607 feature_not_found "numa" "install numactl devel"
2608 fi
2609 numa=no
2610 fi
2611fi
2612
Cortland Tölva955727d2018-10-08 09:35:19 -07002613# check for usbfs
2614have_usbfs=no
2615if test "$linux_user" = "yes"; then
Thomas Petazzoni96566d02019-02-13 22:18:27 +01002616 cat > $TMPC << EOF
2617#include <linux/usbdevice_fs.h>
2618
2619#ifndef USBDEVFS_GET_CAPABILITIES
2620#error "USBDEVFS_GET_CAPABILITIES undefined"
2621#endif
2622
2623#ifndef USBDEVFS_DISCONNECT_CLAIM
2624#error "USBDEVFS_DISCONNECT_CLAIM undefined"
2625#endif
2626
2627int main(void)
2628{
2629 return 0;
2630}
2631EOF
2632 if compile_prog "" ""; then
Cortland Tölva955727d2018-10-08 09:35:19 -07002633 have_usbfs=yes
2634 fi
Cortland Tölva955727d2018-10-08 09:35:19 -07002635fi
Marc-André Lureau751bcc32015-10-09 17:17:16 +02002636
Blue Swirlde5071c2009-09-12 09:58:46 +00002637##########################################
Tomoki Sekiyamad9840e22013-08-07 11:40:03 -04002638# check if we have VSS SDK headers for win
2639
Eric Blakee633a5c2019-02-04 20:39:37 -06002640if test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
2641 test "$vss_win32_sdk" != "no" ; then
Tomoki Sekiyamad9840e22013-08-07 11:40:03 -04002642 case "$vss_win32_sdk" in
Michael Roth690604f2016-06-28 17:31:49 -05002643 "") vss_win32_include="-isystem $source_path" ;;
Tomoki Sekiyamad9840e22013-08-07 11:40:03 -04002644 *\ *) # The SDK is installed in "Program Files" by default, but we cannot
2645 # handle path with spaces. So we symlink the headers into ".sdk/vss".
Michael Roth690604f2016-06-28 17:31:49 -05002646 vss_win32_include="-isystem $source_path/.sdk/vss"
Tomoki Sekiyamad9840e22013-08-07 11:40:03 -04002647 symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
2648 ;;
Michael Roth690604f2016-06-28 17:31:49 -05002649 *) vss_win32_include="-isystem $vss_win32_sdk"
Tomoki Sekiyamad9840e22013-08-07 11:40:03 -04002650 esac
2651 cat > $TMPC << EOF
2652#define __MIDL_user_allocate_free_DEFINED__
2653#include <inc/win2003/vss.h>
2654int main(void) { return VSS_CTX_BACKUP; }
2655EOF
2656 if compile_prog "$vss_win32_include" "" ; then
2657 guest_agent_with_vss="yes"
2658 QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
Fam Zheng315d3182016-09-21 12:27:21 +08002659 libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
Michael Rothf33ca812015-08-26 16:19:41 -05002660 qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
Tomoki Sekiyamad9840e22013-08-07 11:40:03 -04002661 else
2662 if test "$vss_win32_sdk" != "" ; then
2663 echo "ERROR: Please download and install Microsoft VSS SDK:"
2664 echo "ERROR: http://www.microsoft.com/en-us/download/details.aspx?id=23490"
2665 echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
2666 echo "ERROR: scripts/extract-vsssdk-headers setup.exe"
2667 echo "ERROR: The headers are extracted in the directory \`inc'."
2668 feature_not_found "VSS support"
2669 fi
2670 guest_agent_with_vss="no"
2671 fi
2672fi
2673
2674##########################################
2675# lookup Windows platform SDK (if not specified)
2676# The SDK is needed only to build .tlb (type library) file of guest agent
2677# VSS provider from the source. It is usually unnecessary because the
2678# pre-compiled .tlb file is included.
2679
Eric Blakee633a5c2019-02-04 20:39:37 -06002680if test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
2681 test "$guest_agent_with_vss" = "yes" ; then
Tomoki Sekiyamad9840e22013-08-07 11:40:03 -04002682 if test -z "$win_sdk"; then
2683 programfiles="$PROGRAMFILES"
2684 test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
2685 if test -n "$programfiles"; then
2686 win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
2687 else
2688 feature_not_found "Windows SDK"
2689 fi
2690 elif test "$win_sdk" = "no"; then
2691 win_sdk=""
2692 fi
2693fi
2694
2695##########################################
Michael Roth50cbebb2015-07-07 18:10:09 -05002696# check if mingw environment provides a recent ntddscsi.h
Eric Blakee633a5c2019-02-04 20:39:37 -06002697if test "$mingw32" = "yes" && test "$guest_agent" != "no"; then
Michael Roth50cbebb2015-07-07 18:10:09 -05002698 cat > $TMPC << EOF
2699#include <windows.h>
2700#include <ntddscsi.h>
2701int main(void) {
2702#if !defined(IOCTL_SCSI_GET_ADDRESS)
2703#error Missing required ioctl definitions
2704#endif
2705 SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
2706 return addr.Lun;
2707}
2708EOF
2709 if compile_prog "" "" ; then
2710 guest_agent_ntddscsi=yes
Matt Hines996b9cd2019-01-28 14:30:56 -08002711 libs_qga="-lsetupapi -lcfgmgr32 $libs_qga"
Michael Roth50cbebb2015-07-07 18:10:09 -05002712 fi
2713fi
2714
2715##########################################
Richard Henderson8ca80762017-09-14 09:41:12 -07002716# capstone
2717
Richard Hendersone219c492017-09-28 09:01:23 -07002718case "$capstone" in
Richard Henderson8b18cdb2020-09-13 12:19:25 -07002719 auto | enabled | internal)
2720 # Simpler to always update submodule, even if not needed.
Paolo Bonzini2d652f22021-05-12 09:21:56 +02002721 git_submodules="${git_submodules} capstone"
Richard Hendersone219c492017-09-28 09:01:23 -07002722 ;;
2723esac
Richard Henderson8ca80762017-09-14 09:41:12 -07002724
2725##########################################
Alex Barcelo519175a2012-02-28 12:25:50 +01002726# check and set a backend for coroutine
Aneesh Kumar K.Vd0e2fce2011-06-09 23:11:06 +05302727
Peter Maydell7c2acc72013-04-08 12:11:27 +01002728# We prefer ucontext, but it's not always possible. The fallback
Daniel P. Berrange33c53c52017-04-28 13:24:44 +01002729# is sigcontext. On Windows the only valid backend is the Windows
2730# specific one.
Peter Maydell7c2acc72013-04-08 12:11:27 +01002731
2732ucontext_works=no
2733if test "$darwin" != "yes"; then
2734 cat > $TMPC << EOF
Aneesh Kumar K.Vd0e2fce2011-06-09 23:11:06 +05302735#include <ucontext.h>
Peter Maydellcdf84802012-02-23 16:20:05 +00002736#ifdef __stub_makecontext
2737#error Ignoring glibc stub makecontext which will always fail
2738#endif
Stefan Weil75cafad2011-12-17 09:27:29 +01002739int main(void) { makecontext(0, 0, 0); return 0; }
Aneesh Kumar K.Vd0e2fce2011-06-09 23:11:06 +05302740EOF
Peter Maydell7c2acc72013-04-08 12:11:27 +01002741 if compile_prog "" "" ; then
2742 ucontext_works=yes
Aneesh Kumar K.Vd0e2fce2011-06-09 23:11:06 +05302743 fi
Peter Maydell7c2acc72013-04-08 12:11:27 +01002744fi
2745
2746if test "$coroutine" = ""; then
2747 if test "$mingw32" = "yes"; then
2748 coroutine=win32
2749 elif test "$ucontext_works" = "yes"; then
2750 coroutine=ucontext
2751 else
2752 coroutine=sigaltstack
2753 fi
Alex Barcelo519175a2012-02-28 12:25:50 +01002754else
Peter Maydell7c2acc72013-04-08 12:11:27 +01002755 case $coroutine in
2756 windows)
2757 if test "$mingw32" != "yes"; then
2758 error_exit "'windows' coroutine backend only valid for Windows"
2759 fi
2760 # Unfortunately the user visible backend name doesn't match the
2761 # coroutine-*.c filename for this case, so we have to adjust it here.
2762 coroutine=win32
2763 ;;
2764 ucontext)
2765 if test "$ucontext_works" != "yes"; then
2766 feature_not_found "ucontext"
2767 fi
2768 ;;
Daniel P. Berrange33c53c52017-04-28 13:24:44 +01002769 sigaltstack)
Peter Maydell7c2acc72013-04-08 12:11:27 +01002770 if test "$mingw32" = "yes"; then
2771 error_exit "only the 'windows' coroutine backend is valid for Windows"
2772 fi
2773 ;;
2774 *)
2775 error_exit "unknown coroutine backend $coroutine"
2776 ;;
2777 esac
Aneesh Kumar K.Vd0e2fce2011-06-09 23:11:06 +05302778fi
2779
Stefan Hajnoczi70c60c02013-09-11 16:42:35 +02002780if test "$coroutine_pool" = ""; then
Daniel P. Berrange33c53c52017-04-28 13:24:44 +01002781 coroutine_pool=yes
Stefan Hajnoczi70c60c02013-09-11 16:42:35 +02002782fi
2783
Peter Lieven7d992e42016-09-27 11:58:45 +02002784if test "$debug_stack_usage" = "yes"; then
Peter Lieven7d992e42016-09-27 11:58:45 +02002785 if test "$coroutine_pool" = "yes"; then
2786 echo "WARN: disabling coroutine pool for stack usage debugging"
2787 coroutine_pool=no
2788 fi
2789fi
2790
Daniele Buono1e4f6062020-05-29 16:51:21 -04002791##################################################
2792# SafeStack
2793
2794
2795if test "$safe_stack" = "yes"; then
2796cat > $TMPC << EOF
2797int main(int argc, char *argv[])
2798{
2799#if ! __has_feature(safe_stack)
2800#error SafeStack Disabled
2801#endif
2802 return 0;
2803}
2804EOF
2805 flag="-fsanitize=safe-stack"
2806 # Check that safe-stack is supported and enabled.
2807 if compile_prog "-Werror $flag" "$flag"; then
2808 # Flag needed both at compilation and at linking
2809 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
2810 QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
2811 else
2812 error_exit "SafeStack not supported by your compiler"
2813 fi
2814 if test "$coroutine" != "ucontext"; then
2815 error_exit "SafeStack is only supported by the coroutine backend ucontext"
2816 fi
2817else
2818cat > $TMPC << EOF
2819int main(int argc, char *argv[])
2820{
2821#if defined(__has_feature)
2822#if __has_feature(safe_stack)
2823#error SafeStack Enabled
2824#endif
2825#endif
2826 return 0;
2827}
2828EOF
2829if test "$safe_stack" = "no"; then
2830 # Make sure that safe-stack is disabled
2831 if ! compile_prog "-Werror" ""; then
2832 # SafeStack was already enabled, try to explicitly remove the feature
2833 flag="-fno-sanitize=safe-stack"
2834 if ! compile_prog "-Werror $flag" "$flag"; then
2835 error_exit "Configure cannot disable SafeStack"
2836 fi
2837 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
2838 QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
2839 fi
2840else # "$safe_stack" = ""
2841 # Set safe_stack to yes or no based on pre-existing flags
2842 if compile_prog "-Werror" ""; then
2843 safe_stack="no"
2844 else
2845 safe_stack="yes"
2846 if test "$coroutine" != "ucontext"; then
2847 error_exit "SafeStack is only supported by the coroutine backend ucontext"
2848 fi
2849 fi
2850fi
2851fi
Peter Lieven7d992e42016-09-27 11:58:45 +02002852
Richard Henderson76a347e2012-12-28 14:17:02 -08002853########################################
2854# check if cpuid.h is usable.
2855
Richard Henderson76a347e2012-12-28 14:17:02 -08002856cat > $TMPC << EOF
2857#include <cpuid.h>
2858int main(void) {
Peter Maydell774d5662014-02-20 19:42:53 +00002859 unsigned a, b, c, d;
2860 int max = __get_cpuid_max(0, 0);
2861
2862 if (max >= 1) {
2863 __cpuid(1, a, b, c, d);
2864 }
2865
2866 if (max >= 7) {
2867 __cpuid_count(7, 0, a, b, c, d);
2868 }
2869
2870 return 0;
Richard Henderson76a347e2012-12-28 14:17:02 -08002871}
2872EOF
2873if compile_prog "" "" ; then
2874 cpuid_h=yes
2875fi
2876
Richard Henderson5dd89902017-07-18 18:40:18 -10002877##########################################
2878# avx2 optimization requirement check
2879#
2880# There is no point enabling this if cpuid.h is not usable,
2881# since we won't be able to select the new routines.
2882
Eric Blakee633a5c2019-02-04 20:39:37 -06002883if test "$cpuid_h" = "yes" && test "$avx2_opt" != "no"; then
Richard Henderson5dd89902017-07-18 18:40:18 -10002884 cat > $TMPC << EOF
2885#pragma GCC push_options
2886#pragma GCC target("avx2")
2887#include <cpuid.h>
2888#include <immintrin.h>
2889static int bar(void *a) {
2890 __m256i x = *(__m256i *)a;
2891 return _mm256_testz_si256(x, x);
2892}
2893int main(int argc, char *argv[]) { return bar(argv[0]); }
2894EOF
Richard Henderson5b945f22021-07-19 10:01:12 -10002895 if compile_object "-Werror" ; then
Richard Henderson5dd89902017-07-18 18:40:18 -10002896 avx2_opt="yes"
Liam Merwick86583a02018-10-19 21:38:59 +01002897 else
2898 avx2_opt="no"
Richard Henderson5dd89902017-07-18 18:40:18 -10002899 fi
2900fi
2901
Robert Hoo6b8cd442020-02-29 20:34:34 +08002902##########################################
2903# avx512f optimization requirement check
2904#
2905# There is no point enabling this if cpuid.h is not usable,
2906# since we won't be able to select the new routines.
2907# by default, it is turned off.
2908# if user explicitly want to enable it, check environment
2909
2910if test "$cpuid_h" = "yes" && test "$avx512f_opt" = "yes"; then
2911 cat > $TMPC << EOF
2912#pragma GCC push_options
2913#pragma GCC target("avx512f")
2914#include <cpuid.h>
2915#include <immintrin.h>
2916static int bar(void *a) {
2917 __m512i x = *(__m512i *)a;
2918 return _mm512_test_epi64_mask(x, x);
2919}
2920int main(int argc, char *argv[])
2921{
2922 return bar(argv[0]);
2923}
2924EOF
Richard Henderson5b945f22021-07-19 10:01:12 -10002925 if ! compile_object "-Werror" ; then
Robert Hoo6b8cd442020-02-29 20:34:34 +08002926 avx512f_opt="no"
2927 fi
2928else
2929 avx512f_opt="no"
2930fi
2931
Richard Hendersonf5401662013-02-16 12:46:59 -08002932########################################
2933# check if __[u]int128_t is usable.
2934
2935int128=no
2936cat > $TMPC << EOF
2937__int128_t a;
2938__uint128_t b;
2939int main (void) {
2940 a = a + b;
2941 b = a * b;
Peter Maydell464e3672013-06-21 14:01:31 +01002942 a = a * a;
Richard Hendersonf5401662013-02-16 12:46:59 -08002943 return 0;
2944}
2945EOF
2946if compile_prog "" "" ; then
2947 int128=yes
2948fi
Richard Henderson76a347e2012-12-28 14:17:02 -08002949
Richard Henderson7ebee432016-06-29 21:10:59 -07002950#########################################
2951# See if 128-bit atomic operations are supported.
2952
2953atomic128=no
2954if test "$int128" = "yes"; then
2955 cat > $TMPC << EOF
2956int main(void)
2957{
2958 unsigned __int128 x = 0, y = 0;
Thomas Huthbceac542021-03-23 16:52:57 +00002959 y = __atomic_load(&x, 0);
2960 __atomic_store(&x, y, 0);
2961 __atomic_compare_exchange(&x, &y, x, 0, 0, 0);
Richard Henderson7ebee432016-06-29 21:10:59 -07002962 return 0;
2963}
2964EOF
2965 if compile_prog "" "" ; then
2966 atomic128=yes
2967 fi
2968fi
2969
Richard Hendersone6cd4bb2018-08-15 16:31:47 -07002970cmpxchg128=no
Eric Blakee633a5c2019-02-04 20:39:37 -06002971if test "$int128" = yes && test "$atomic128" = no; then
Richard Hendersone6cd4bb2018-08-15 16:31:47 -07002972 cat > $TMPC << EOF
2973int main(void)
2974{
2975 unsigned __int128 x = 0, y = 0;
2976 __sync_val_compare_and_swap_16(&x, y, x);
2977 return 0;
2978}
2979EOF
2980 if compile_prog "" "" ; then
2981 cmpxchg128=yes
2982 fi
2983fi
2984
John Snowfd0e6052015-03-25 18:57:39 -04002985########################################
2986# check if ccache is interfering with
2987# semantic analysis of macros
2988
John Snow5e4dfd32015-10-28 13:56:40 -04002989unset CCACHE_CPP2
John Snowfd0e6052015-03-25 18:57:39 -04002990ccache_cpp2=no
2991cat > $TMPC << EOF
2992static const int Z = 1;
2993#define fn() ({ Z; })
2994#define TAUT(X) ((X) == Z)
2995#define PAREN(X, Y) (X == Y)
2996#define ID(X) (X)
2997int main(int argc, char *argv[])
2998{
2999 int x = 0, y = 0;
3000 x = ID(x);
3001 x = fn();
3002 fn();
3003 if (PAREN(x, y)) return 0;
3004 if (TAUT(Z)) return 0;
3005 return 0;
3006}
3007EOF
3008
3009if ! compile_object "-Werror"; then
3010 ccache_cpp2=yes
3011fi
3012
John Snowb553a042015-11-03 15:43:42 -05003013#################################################
3014# clang does not support glibc + FORTIFY_SOURCE.
3015
3016if test "$fortify_source" != "no"; then
3017 if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
3018 fortify_source="no";
Peter Maydelle1890912017-06-26 16:25:24 +01003019 elif test -n "$cxx" && has $cxx &&
John Snowcfcc7c12015-11-12 11:29:49 -05003020 echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
John Snowb553a042015-11-03 15:43:42 -05003021 fortify_source="no";
3022 else
3023 fortify_source="yes"
3024 fi
3025fi
3026
Aneesh Kumar K.Vd2042372011-10-12 19:11:24 +05303027##########################################
Paolo Bonzinia40161c2018-02-16 10:05:23 +01003028# check for usable membarrier system call
3029if test "$membarrier" = "yes"; then
3030 have_membarrier=no
3031 if test "$mingw32" = "yes" ; then
3032 have_membarrier=yes
3033 elif test "$linux" = "yes" ; then
3034 cat > $TMPC << EOF
3035 #include <linux/membarrier.h>
3036 #include <sys/syscall.h>
3037 #include <unistd.h>
3038 #include <stdlib.h>
3039 int main(void) {
3040 syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
3041 syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0);
3042 exit(0);
3043 }
3044EOF
3045 if compile_prog "" "" ; then
3046 have_membarrier=yes
3047 fi
3048 fi
3049 if test "$have_membarrier" = "no"; then
3050 feature_not_found "membarrier" "membarrier system call not available"
3051 fi
3052else
3053 # Do not enable it by default even for Mingw32, because it doesn't
3054 # work on Wine.
3055 membarrier=no
3056fi
3057
3058##########################################
Longpeng(Mike)f0d92b52017-07-14 14:04:05 -04003059# check for usable AF_ALG environment
Thomas Huth4f673662020-02-03 16:55:34 +01003060have_afalg=no
Longpeng(Mike)f0d92b52017-07-14 14:04:05 -04003061cat > $TMPC << EOF
3062#include <errno.h>
3063#include <sys/types.h>
3064#include <sys/socket.h>
3065#include <linux/if_alg.h>
3066int main(void) {
3067 int sock;
3068 sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
3069 return sock;
3070}
3071EOF
3072if compile_prog "" "" ; then
3073 have_afalg=yes
3074fi
3075if test "$crypto_afalg" = "yes"
3076then
3077 if test "$have_afalg" != "yes"
3078 then
3079 error_exit "AF_ALG requested but could not be detected"
3080 fi
3081fi
3082
3083
Richard Hendersondb1ed1a2019-03-13 20:57:28 -07003084##########################################
Marc-André Lureau247724c2018-01-16 16:11:51 +01003085# checks for sanitizers
3086
Marc-André Lureau247724c2018-01-16 16:11:51 +01003087have_asan=no
3088have_ubsan=no
Marc-André Lureaud83414e2018-01-16 16:11:52 +01003089have_asan_iface_h=no
3090have_asan_iface_fiber=no
Marc-André Lureau247724c2018-01-16 16:11:51 +01003091
3092if test "$sanitizers" = "yes" ; then
Marc-André Lureaub9f44da2018-02-15 22:25:47 +01003093 write_c_skeleton
Marc-André Lureau247724c2018-01-16 16:11:51 +01003094 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
3095 have_asan=yes
3096 fi
Marc-André Lureaub9f44da2018-02-15 22:25:47 +01003097
3098 # we could use a simple skeleton for flags checks, but this also
3099 # detect the static linking issue of ubsan, see also:
3100 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
3101 cat > $TMPC << EOF
3102#include <stdlib.h>
3103int main(void) {
3104 void *tmp = malloc(10);
Leonid Blochf2dfe542020-05-25 01:12:04 +03003105 if (tmp != NULL) {
3106 return *(int *)(tmp + 2);
3107 }
Olaf Heringd1abf3f2020-07-07 19:13:25 +02003108 return 1;
Marc-André Lureaub9f44da2018-02-15 22:25:47 +01003109}
3110EOF
Marc-André Lureau247724c2018-01-16 16:11:51 +01003111 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
3112 have_ubsan=yes
3113 fi
Marc-André Lureaud83414e2018-01-16 16:11:52 +01003114
3115 if check_include "sanitizer/asan_interface.h" ; then
3116 have_asan_iface_h=yes
3117 fi
3118
3119 cat > $TMPC << EOF
3120#include <sanitizer/asan_interface.h>
3121int main(void) {
3122 __sanitizer_start_switch_fiber(0, 0, 0);
3123 return 0;
3124}
3125EOF
3126 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
3127 have_asan_iface_fiber=yes
3128 fi
Marc-André Lureau247724c2018-01-16 16:11:51 +01003129fi
3130
Lingfeng Yang0aebab02020-06-12 20:02:23 +01003131# Thread sanitizer is, for now, much noisier than the other sanitizers;
3132# keep it separate until that is not the case.
3133if test "$tsan" = "yes" && test "$sanitizers" = "yes"; then
3134 error_exit "TSAN is not supported with other sanitiziers."
3135fi
3136have_tsan=no
3137have_tsan_iface_fiber=no
3138if test "$tsan" = "yes" ; then
3139 write_c_skeleton
3140 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
3141 have_tsan=yes
3142 fi
3143 cat > $TMPC << EOF
3144#include <sanitizer/tsan_interface.h>
3145int main(void) {
3146 __tsan_create_fiber(0);
3147 return 0;
3148}
3149EOF
3150 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
3151 have_tsan_iface_fiber=yes
3152 fi
3153fi
3154
Alexander Bulekovadc28022020-02-19 23:11:14 -05003155##########################################
Marc-André Lureau675b9b52019-02-12 17:25:23 +01003156# check for slirp
3157
3158case "$slirp" in
Paolo Bonzini4d34a862020-10-05 11:31:15 +02003159 auto | enabled | internal)
3160 # Simpler to always update submodule, even if not needed.
Paolo Bonzini2d652f22021-05-12 09:21:56 +02003161 git_submodules="${git_submodules} slirp"
Marc-André Lureau675b9b52019-02-12 17:25:23 +01003162 ;;
3163esac
3164
Joelle van Dyneb8e0c492021-03-15 11:03:41 -07003165# Check for slirp smbd dupport
3166: ${smbd=${SMBD-/usr/sbin/smbd}}
3167if test "$slirp_smbd" != "no" ; then
3168 if test "$mingw32" = "yes" ; then
3169 if test "$slirp_smbd" = "yes" ; then
3170 error_exit "Host smbd not supported on this platform."
3171 fi
3172 slirp_smbd=no
3173 else
3174 slirp_smbd=yes
3175 fi
3176fi
3177
Alexey Krasikov54e7aac2020-05-25 14:19:12 +03003178##########################################
3179# check for usable __NR_keyctl syscall
3180
3181if test "$linux" = "yes" ; then
3182
3183 have_keyring=no
3184 cat > $TMPC << EOF
3185#include <errno.h>
3186#include <asm/unistd.h>
3187#include <linux/keyctl.h>
3188#include <unistd.h>
3189int main(void) {
3190 return syscall(__NR_keyctl, KEYCTL_READ, 0, NULL, NULL, 0);
3191}
3192EOF
3193 if compile_prog "" "" ; then
3194 have_keyring=yes
3195 fi
3196fi
3197if test "$secret_keyring" != "no"
3198then
David Edmondsonb418d262020-07-01 14:56:15 +01003199 if test "$have_keyring" = "yes"
Alexey Krasikov54e7aac2020-05-25 14:19:12 +03003200 then
3201 secret_keyring=yes
3202 else
3203 if test "$secret_keyring" = "yes"
3204 then
3205 error_exit "syscall __NR_keyctl requested, \
3206but not implemented on your system"
3207 else
3208 secret_keyring=no
3209 fi
3210 fi
3211fi
3212
Alexey Krasikov92500362020-05-25 14:19:13 +03003213##########################################
Juan Quintelae86ecd42009-08-03 14:45:59 +02003214# End of CC checks
3215# After here, no more $cc or $ld runs
3216
Marc-André Lureaud83414e2018-01-16 16:11:52 +01003217write_c_skeleton
3218
Blue Swirl1d728c32012-05-01 18:45:39 +00003219if test "$gcov" = "yes" ; then
Marc-André Lureaubf0e56a2019-10-04 17:35:16 +04003220 :
John Snowb553a042015-11-03 15:43:42 -05003221elif test "$fortify_source" = "yes" ; then
Paolo Bonzini086d5f72020-02-03 15:22:17 +01003222 QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
3223 debug=no
3224fi
Paolo Bonzini086d5f72020-02-03 15:22:17 +01003225
3226case "$ARCH" in
3227alpha)
3228 # Ensure there's only a single GP
3229 QEMU_CFLAGS="-msmall-data $QEMU_CFLAGS"
3230;;
3231esac
3232
3233if test "$gprof" = "yes" ; then
3234 QEMU_CFLAGS="-p $QEMU_CFLAGS"
3235 QEMU_LDFLAGS="-p $QEMU_LDFLAGS"
3236fi
Juan Quintelaa316e372009-09-30 01:10:55 +02003237
Marc-André Lureau247724c2018-01-16 16:11:51 +01003238if test "$have_asan" = "yes"; then
Paolo Bonzinidb5adea2019-12-11 15:34:27 +01003239 QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS"
3240 QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS"
Marc-André Lureaud83414e2018-01-16 16:11:52 +01003241 if test "$have_asan_iface_h" = "no" ; then
3242 echo "ASAN build enabled, but ASAN header missing." \
3243 "Without code annotation, the report may be inferior."
3244 elif test "$have_asan_iface_fiber" = "no" ; then
3245 echo "ASAN build enabled, but ASAN header is too old." \
3246 "Without code annotation, the report may be inferior."
3247 fi
Marc-André Lureau247724c2018-01-16 16:11:51 +01003248fi
Lingfeng Yang0aebab02020-06-12 20:02:23 +01003249if test "$have_tsan" = "yes" ; then
3250 if test "$have_tsan_iface_fiber" = "yes" ; then
3251 QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS"
3252 QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS"
3253 else
3254 error_exit "Cannot enable TSAN due to missing fiber annotation interface."
3255 fi
3256elif test "$tsan" = "yes" ; then
3257 error_exit "Cannot enable TSAN due to missing sanitize thread interface."
3258fi
Marc-André Lureau247724c2018-01-16 16:11:51 +01003259if test "$have_ubsan" = "yes"; then
Paolo Bonzinidb5adea2019-12-11 15:34:27 +01003260 QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS"
3261 QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS"
Marc-André Lureau247724c2018-01-16 16:11:51 +01003262fi
3263
Peter Lieven6542aa92014-02-03 10:26:13 +01003264##########################################
Tomáš Golembiovský3efac6e2018-10-23 13:23:10 +02003265
Lingfeng Yang0aebab02020-06-12 20:02:23 +01003266# Exclude --warn-common with TSan to suppress warnings from the TSan libraries.
3267if test "$solaris" = "no" && test "$tsan" = "no"; then
Juan Quintelae86ecd42009-08-03 14:45:59 +02003268 if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
Paolo Bonzinidb5adea2019-12-11 15:34:27 +01003269 QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS"
Juan Quintelae86ecd42009-08-03 14:45:59 +02003270 fi
3271fi
3272
Blue Swirl952afb72010-09-19 08:36:34 +00003273# Use ASLR, no-SEH and DEP if available
3274if test "$mingw32" = "yes" ; then
Mark Cave-Aylandcb8baa72020-10-05 14:34:34 +01003275 flags="--no-seh --nxcompat"
3276
3277 # Disable ASLR for debug builds to allow debugging with gdb
3278 if test "$debug" = "no" ; then
3279 flags="--dynamicbase $flags"
3280 fi
3281
3282 for flag in $flags; do
Christian Borntraegere9a35912017-08-23 12:16:23 +02003283 if ld_has $flag ; then
Paolo Bonzinidb5adea2019-12-11 15:34:27 +01003284 QEMU_LDFLAGS="-Wl,$flag $QEMU_LDFLAGS"
Blue Swirl952afb72010-09-19 08:36:34 +00003285 fi
3286 done
3287fi
3288
Michael Roth9d6bc272015-08-26 10:49:13 -05003289# Probe for guest agent support/options
3290
Michael Tokareve8ef31a2013-07-31 14:22:07 +04003291if [ "$guest_agent" != "no" ]; then
Laurent Viviera5125902019-04-01 16:12:20 +02003292 if [ "$softmmu" = no -a "$want_tools" = no ] ; then
3293 guest_agent=no
3294 elif [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
Michael Tokareve8ef31a2013-07-31 14:22:07 +04003295 guest_agent=yes
3296 elif [ "$guest_agent" != yes ]; then
3297 guest_agent=no
3298 else
3299 error_exit "Guest agent is not supported on this platform"
Paolo Bonzinica35f782010-05-26 16:08:29 +02003300 fi
Paolo Bonzini00c705f2012-05-29 11:40:24 +02003301fi
Paolo Bonzinica35f782010-05-26 16:08:29 +02003302
Paolo Bonzinib846ab72021-01-21 11:49:04 +01003303# Guest agent Windows MSI package
Michael Roth9d6bc272015-08-26 10:49:13 -05003304
Paolo Bonzinib846ab72021-01-21 11:49:04 +01003305if test "$QEMU_GA_MANUFACTURER" = ""; then
3306 QEMU_GA_MANUFACTURER=QEMU
3307fi
3308if test "$QEMU_GA_DISTRO" = ""; then
3309 QEMU_GA_DISTRO=Linux
3310fi
3311if test "$QEMU_GA_VERSION" = ""; then
3312 QEMU_GA_VERSION=$(cat $source_path/VERSION)
Michael Roth9d6bc272015-08-26 10:49:13 -05003313fi
3314
Paolo Bonzinib846ab72021-01-21 11:49:04 +01003315QEMU_GA_MSI_MINGW_DLL_PATH="$($pkg_config --variable=prefix glib-2.0)/bin"
Michael Roth9d6bc272015-08-26 10:49:13 -05003316
Paolo Bonzinica35f782010-05-26 16:08:29 +02003317# Mac OS X ships with a broken assembler
3318roms=
Eric Blakee633a5c2019-02-04 20:39:37 -06003319if { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \
Paolo Bonziniba7c60c2021-11-08 14:47:54 +01003320 test "$targetos" != "darwin" && test "$targetos" != "sunos" && \
3321 test "$targetos" != "haiku" && test "$softmmu" = yes ; then
Peter Maydelle57218b2016-08-08 17:11:28 +01003322 # Different host OS linkers have different ideas about the name of the ELF
Brad Smithc65d5e42017-11-07 18:46:11 -05003323 # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
3324 # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
3325 for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
Peter Maydelle57218b2016-08-08 17:11:28 +01003326 if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
3327 ld_i386_emulation="$emu"
3328 roms="optionrom"
3329 break
3330 fi
3331 done
Paolo Bonzinica35f782010-05-26 16:08:29 +02003332fi
Paolo Bonzinica35f782010-05-26 16:08:29 +02003333
Thomas Huth2e33c3f2019-01-14 13:52:26 +01003334# Only build s390-ccw bios if we're on s390x and the compiler has -march=z900
Thomas Hutha5b2afd2021-05-02 13:22:21 +02003335# or -march=z10 (which is the lowest architecture level that Clang supports)
Christian Borntraeger9933c302013-04-23 01:23:03 +00003336if test "$cpu" = "s390x" ; then
Thomas Huth2e33c3f2019-01-14 13:52:26 +01003337 write_c_skeleton
Thomas Hutha5b2afd2021-05-02 13:22:21 +02003338 compile_prog "-march=z900" ""
3339 has_z900=$?
Thomas Huth3af448b2021-05-25 16:20:32 +02003340 if [ $has_z900 = 0 ] || compile_object "-march=z10 -msoft-float -Werror"; then
Thomas Hutha5b2afd2021-05-02 13:22:21 +02003341 if [ $has_z900 != 0 ]; then
3342 echo "WARNING: Your compiler does not support the z900!"
3343 echo " The s390-ccw bios will only work with guest CPUs >= z10."
3344 fi
Thomas Huth2e33c3f2019-01-14 13:52:26 +01003345 roms="$roms s390-ccw"
Philippe Mathieu-Daudé1ef6bfc2020-06-15 09:49:19 +02003346 # SLOF is required for building the s390-ccw firmware on s390x,
3347 # since it is using the libnet code from SLOF for network booting.
Paolo Bonzini2d652f22021-05-12 09:21:56 +02003348 git_submodules="${git_submodules} roms/SLOF"
Thomas Huth2e33c3f2019-01-14 13:52:26 +01003349 fi
Christian Borntraeger9933c302013-04-23 01:23:03 +00003350fi
3351
Bruno Dominguez11cde1c2017-06-06 14:07:47 +01003352# Check that the C++ compiler exists and works with the C compiler.
3353# All the QEMU_CXXFLAGS are based on QEMU_CFLAGS. Keep this at the end to don't miss any other that could be added.
3354if has $cxx; then
3355 cat > $TMPC <<EOF
3356int c_function(void);
3357int main(void) { return c_function(); }
3358EOF
3359
3360 compile_object
3361
3362 cat > $TMPCXX <<EOF
3363extern "C" {
3364 int c_function(void);
3365}
3366int c_function(void) { return 42; }
3367EOF
3368
3369 update_cxxflags
3370
Paolo Bonzinia2866662021-11-05 10:09:26 +01003371 if do_cxx $CXXFLAGS $EXTRA_CXXFLAGS $CONFIGURE_CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then
Bruno Dominguez11cde1c2017-06-06 14:07:47 +01003372 # C++ compiler $cxx works ok with C compiler $cc
3373 :
3374 else
3375 echo "C++ compiler $cxx does not work with C compiler $cc"
3376 echo "Disabling C++ specific optional code"
3377 cxx=
3378 fi
3379else
3380 echo "No C++ compiler available; disabling C++ specific optional code"
3381 cxx=
3382fi
3383
Dan Streetman7d7dbf92021-01-19 12:20:46 -05003384if !(GIT="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then
3385 exit 1
Yonggang Luo5d91a2e2020-09-03 01:00:49 +08003386fi
Yonggang Luo5d91a2e2020-09-03 01:00:49 +08003387
Juan Quintela98ec69a2009-07-16 18:34:18 +02003388config_host_mak="config-host.mak"
bellard97a847b2003-08-10 21:36:04 +00003389
Juan Quintela98ec69a2009-07-16 18:34:18 +02003390echo "# Automatically generated by configure - do not modify" > $config_host_mak
Juan Quintela98ec69a2009-07-16 18:34:18 +02003391echo >> $config_host_mak
Juan Quintela98ec69a2009-07-16 18:34:18 +02003392
Paolo Bonzinie6c3b0f2010-10-21 10:18:35 +02003393echo all: >> $config_host_mak
Daniel P. Berrangecc84d632017-10-20 15:02:43 +01003394echo "GIT=$git" >> $config_host_mak
Daniel P. Berrangeaef45d52017-09-29 11:11:56 +01003395echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
Dan Streetman7d7dbf92021-01-19 12:20:46 -05003396echo "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak
Juan Quintela804edf22009-07-27 16:12:49 +02003397
aurel32f8393942009-04-13 18:45:38 +00003398if test "$debug_tcg" = "yes" ; then
Juan Quintela2358a492009-07-27 16:13:25 +02003399 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
aurel32f8393942009-04-13 18:45:38 +00003400fi
aliguori1625af82009-04-05 17:41:02 +00003401if test "$strip_opt" = "yes" ; then
Hollis Blanchard52ba7842010-08-04 17:21:34 -07003402 echo "STRIP=${strip}" >> $config_host_mak
aliguori1625af82009-04-05 17:41:02 +00003403fi
bellard67b915a2004-03-31 23:37:16 +00003404if test "$mingw32" = "yes" ; then
Juan Quintela98ec69a2009-07-16 18:34:18 +02003405 echo "CONFIG_WIN32=y" >> $config_host_mak
Tomoki Sekiyamad9840e22013-08-07 11:40:03 -04003406 if test "$guest_agent_with_vss" = "yes" ; then
3407 echo "CONFIG_QGA_VSS=y" >> $config_host_mak
Michael Rothf33ca812015-08-26 16:19:41 -05003408 echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
Tomoki Sekiyamad9840e22013-08-07 11:40:03 -04003409 echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
3410 fi
Michael Roth50cbebb2015-07-07 18:10:09 -05003411 if test "$guest_agent_ntddscsi" = "yes" ; then
Tomáš Golembiovský76dc75c2018-10-23 13:23:16 +02003412 echo "CONFIG_QGA_NTDDSCSI=y" >> $config_host_mak
Michael Roth50cbebb2015-07-07 18:10:09 -05003413 fi
Paolo Bonzinib846ab72021-01-21 11:49:04 +01003414 echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
3415 echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
3416 echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
3417 echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
pbrook210fa552007-02-27 21:04:49 +00003418else
Juan Quintela35f4df22009-07-27 16:13:07 +02003419 echo "CONFIG_POSIX=y" >> $config_host_mak
bellard67b915a2004-03-31 23:37:16 +00003420fi
blueswir1128ab2f2008-08-15 18:33:42 +00003421
Mark McLoughlindffcb712009-10-22 17:49:11 +01003422if test "$linux" = "yes" ; then
3423 echo "CONFIG_LINUX=y" >> $config_host_mak
3424fi
3425
bellard83fb7ad2004-07-05 21:25:26 +00003426if test "$darwin" = "yes" ; then
Juan Quintela98ec69a2009-07-16 18:34:18 +02003427 echo "CONFIG_DARWIN=y" >> $config_host_mak
bellard83fb7ad2004-07-05 21:25:26 +00003428fi
malcb29fe3e2008-11-18 01:42:22 +00003429
bellardec530c82006-04-25 22:36:06 +00003430if test "$solaris" = "yes" ; then
Juan Quintela98ec69a2009-07-16 18:34:18 +02003431 echo "CONFIG_SOLARIS=y" >> $config_host_mak
bellardec530c82006-04-25 22:36:06 +00003432fi
bellard97a847b2003-08-10 21:36:04 +00003433if test "$static" = "yes" ; then
Juan Quintela98ec69a2009-07-16 18:34:18 +02003434 echo "CONFIG_STATIC=y" >> $config_host_mak
bellard97a847b2003-08-10 21:36:04 +00003435fi
Stefan Weil1ba16962011-07-29 22:40:45 +02003436if test "$profiler" = "yes" ; then
Juan Quintela2358a492009-07-27 16:13:25 +02003437 echo "CONFIG_PROFILER=y" >> $config_host_mak
bellard05c2a3e2006-02-08 22:39:17 +00003438fi
Paolo Bonzinic932ce32019-07-18 12:24:29 +02003439if test "$want_tools" = "yes" ; then
3440 echo "CONFIG_TOOLS=y" >> $config_host_mak
3441fi
Paolo Bonzinif15bff22019-07-18 13:19:02 +02003442if test "$guest_agent" = "yes" ; then
3443 echo "CONFIG_GUEST_AGENT=y" >> $config_host_mak
3444fi
Joelle van Dyneb8e0c492021-03-15 11:03:41 -07003445if test "$slirp_smbd" = "yes" ; then
3446 echo "CONFIG_SLIRP_SMBD=y" >> $config_host_mak
3447 echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
3448fi
Paolo Bonzini4cc600d2020-02-04 17:11:04 +01003449if test "$gprof" = "yes" ; then
3450 echo "CONFIG_GPROF=y" >> $config_host_mak
3451fi
Fam Zhengb64ec4e2013-05-29 19:35:40 +08003452echo "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
3453echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
Kevin Wolfe5f05f82021-07-09 18:41:41 +02003454if test "$block_drv_whitelist_tools" = "yes" ; then
3455 echo "CONFIG_BDRV_WHITELIST_TOOLS=y" >> $config_host_mak
3456fi
Christoph Hellwigdce512d2010-12-17 11:41:15 +01003457if test "$xfs" = "yes" ; then
3458 echo "CONFIG_XFS=y" >> $config_host_mak
3459fi
Stefan Weil89138852016-05-16 15:10:20 +02003460qemu_version=$(head $source_path/VERSION)
Juan Quintela2358a492009-07-27 16:13:25 +02003461echo "PKGVERSION=$pkgversion" >>$config_host_mak
Juan Quintela98ec69a2009-07-16 18:34:18 +02003462echo "SRC_PATH=$source_path" >> $config_host_mak
Alex Bennée2b1f35b2018-07-04 07:30:11 +01003463echo "TARGET_DIRS=$target_list" >> $config_host_mak
Fam Zheng17969262014-02-10 14:48:56 +08003464if test "$modules" = "yes"; then
Fam Zhenge26110c2014-02-10 14:48:57 +08003465 # $shacmd can generate a hash started with digit, which the compiler doesn't
3466 # like as an symbol. So prefix it with an underscore
Stefan Weil89138852016-05-16 15:10:20 +02003467 echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
Fam Zheng17969262014-02-10 14:48:56 +08003468 echo "CONFIG_MODULES=y" >> $config_host_mak
3469fi
Christian Ehrhardtbd83c862020-03-10 15:58:06 +01003470if test "$module_upgrades" = "yes"; then
3471 echo "CONFIG_MODULE_UPGRADES=y" >> $config_host_mak
3472fi
Cortland Tölva955727d2018-10-08 09:35:19 -07003473if test "$have_usbfs" = "yes" ; then
3474 echo "CONFIG_USBFS=y" >> $config_host_mak
3475fi
Marc-André Lureauf876b762019-02-21 12:07:00 +01003476if test "$gio" = "yes" ; then
3477 echo "CONFIG_GIO=y" >> $config_host_mak
3478 echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak
3479 echo "GIO_LIBS=$gio_libs" >> $config_host_mak
Paolo Bonzini5ecfb762021-05-05 10:15:34 -04003480fi
3481if test "$gdbus_codegen" != "" ; then
Marc-André Lureau25a97a52019-09-27 11:34:42 +04003482 echo "GDBUS_CODEGEN=$gdbus_codegen" >> $config_host_mak
Marc-André Lureauf876b762019-02-21 12:07:00 +01003483fi
Daniel P. Berrangea1c5e942016-06-06 10:05:06 +01003484echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
Jan Vesely277abf12016-04-29 13:15:23 -04003485
Paolo Bonzini1badb702020-09-18 04:57:25 -04003486if test "$xen" = "enabled" ; then
Jan Kiszka6dbd5882011-06-21 22:59:07 +02003487 echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
Anthony PERARDd5b93dd2011-02-25 16:20:34 +00003488 echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
Marc-André Lureau582ea952019-08-15 15:15:32 +04003489 echo "XEN_CFLAGS=$xen_cflags" >> $config_host_mak
3490 echo "XEN_LIBS=$xen_libs" >> $config_host_mak
aliguorie37630c2009-04-22 15:19:10 +00003491fi
Nicholas Bellinger5e9be922013-03-29 01:08:16 +00003492if test "$vhost_scsi" = "yes" ; then
3493 echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
3494fi
Paolo Bonziniaf3bba72019-02-14 18:35:52 +01003495if test "$vhost_net" = "yes" ; then
3496 echo "CONFIG_VHOST_NET=y" >> $config_host_mak
3497fi
3498if test "$vhost_net_user" = "yes" ; then
Paolo Bonzini56f41de2019-02-14 18:35:49 +01003499 echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak
Nikolay Nikolaev03ce5742014-06-10 13:02:16 +03003500fi
Cindy Lu108a6482020-07-01 22:55:37 +08003501if test "$vhost_net_vdpa" = "yes" ; then
3502 echo "CONFIG_VHOST_NET_VDPA=y" >> $config_host_mak
3503fi
Gonglei042cea22018-03-01 21:46:28 +08003504if test "$vhost_crypto" = "yes" ; then
3505 echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
3506fi
Stefan Hajnoczifc0b9b02016-08-16 13:27:22 +01003507if test "$vhost_vsock" = "yes" ; then
3508 echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
Stefano Garzarella5fe97d82020-05-22 14:25:11 +02003509 if test "$vhost_user" = "yes" ; then
3510 echo "CONFIG_VHOST_USER_VSOCK=y" >> $config_host_mak
3511 fi
Stefan Hajnoczifc0b9b02016-08-16 13:27:22 +01003512fi
Paolo Bonzini299e6f12019-02-14 18:35:53 +01003513if test "$vhost_kernel" = "yes" ; then
3514 echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak
3515fi
Marc-André Lureaue6a74862017-08-03 11:07:46 +02003516if test "$vhost_user" = "yes" ; then
3517 echo "CONFIG_VHOST_USER=y" >> $config_host_mak
3518fi
Cindy Lu108a6482020-07-01 22:55:37 +08003519if test "$vhost_vdpa" = "yes" ; then
3520 echo "CONFIG_VHOST_VDPA=y" >> $config_host_mak
3521fi
Dr. David Alan Gilbert98fc1ad2019-09-30 11:51:34 +01003522if test "$vhost_user_fs" = "yes" ; then
3523 echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak
3524fi
Paolo Bonzinia40161c2018-02-16 10:05:23 +01003525if test "$membarrier" = "yes" ; then
3526 echo "CONFIG_MEMBARRIER=y" >> $config_host_mak
3527fi
Richard Hendersone5b46542021-02-07 18:15:04 -08003528if test "$tcg" = "enabled" -a "$tcg_interpreter" = "true" ; then
3529 echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
3530fi
Gerd Hoffmann58d3f3f2021-05-19 07:39:32 +02003531
Gerd Hoffmannda076ff2014-11-20 09:49:44 +01003532if test "$opengl" = "yes" ; then
3533 echo "CONFIG_OPENGL=y" >> $config_host_mak
Paolo Bonzinide2d3002020-09-01 08:41:17 -04003534 echo "OPENGL_CFLAGS=$opengl_cflags" >> $config_host_mak
Gerd Hoffmannda076ff2014-11-20 09:49:44 +01003535 echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
Michael Walle20ff0752011-03-07 23:32:39 +01003536fi
3537
Liang Li99f2dbd2016-03-08 13:53:16 +08003538if test "$avx2_opt" = "yes" ; then
3539 echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
3540fi
3541
Robert Hoo6b8cd442020-02-29 20:34:34 +08003542if test "$avx512f_opt" = "yes" ; then
3543 echo "CONFIG_AVX512F_OPT=y" >> $config_host_mak
3544fi
3545
bellard83fb7ad2004-07-05 21:25:26 +00003546# XXX: suppress that
bellard7d3505c2004-05-12 19:32:15 +00003547if [ "$bsd" = "yes" ] ; then
Juan Quintela2358a492009-07-27 16:13:25 +02003548 echo "CONFIG_BSD=y" >> $config_host_mak
bellard7d3505c2004-05-12 19:32:15 +00003549fi
3550
Paolo Bonzini3556c232013-05-10 14:16:40 +02003551if test "$qom_cast_debug" = "yes" ; then
3552 echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
3553fi
Anthony Liguori20ff6c82009-12-09 12:59:36 -06003554
Peter Maydell7c2acc72013-04-08 12:11:27 +01003555echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
Stefan Hajnoczi70c60c02013-09-11 16:42:35 +02003556if test "$coroutine_pool" = "yes" ; then
3557 echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
3558else
3559 echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
3560fi
Aneesh Kumar K.Vd0e2fce2011-06-09 23:11:06 +05303561
Peter Lieven7d992e42016-09-27 11:58:45 +02003562if test "$debug_stack_usage" = "yes" ; then
3563 echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
3564fi
3565
Longpeng(Mike)f0d92b52017-07-14 14:04:05 -04003566if test "$crypto_afalg" = "yes" ; then
3567 echo "CONFIG_AF_ALG=y" >> $config_host_mak
3568fi
3569
Marc-André Lureaud83414e2018-01-16 16:11:52 +01003570if test "$have_asan_iface_fiber" = "yes" ; then
3571 echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
3572fi
3573
Lingfeng Yang0aebab02020-06-12 20:02:23 +01003574if test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then
3575 echo "CONFIG_TSAN=y" >> $config_host_mak
3576fi
3577
Richard Henderson76a347e2012-12-28 14:17:02 -08003578if test "$cpuid_h" = "yes" ; then
3579 echo "CONFIG_CPUID_H=y" >> $config_host_mak
3580fi
3581
Richard Hendersonf5401662013-02-16 12:46:59 -08003582if test "$int128" = "yes" ; then
3583 echo "CONFIG_INT128=y" >> $config_host_mak
3584fi
3585
Richard Henderson7ebee432016-06-29 21:10:59 -07003586if test "$atomic128" = "yes" ; then
3587 echo "CONFIG_ATOMIC128=y" >> $config_host_mak
3588fi
3589
Richard Hendersone6cd4bb2018-08-15 16:31:47 -07003590if test "$cmpxchg128" = "yes" ; then
3591 echo "CONFIG_CMPXCHG128=y" >> $config_host_mak
3592fi
3593
Dr. David Alan Gilberted1701c2017-05-15 15:05:29 +01003594if test "$live_block_migration" = "yes" ; then
3595 echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
3596fi
3597
Paolo Bonzini3b8acc12013-03-18 16:37:50 +01003598if test "$tpm" = "yes"; then
Paolo Bonzini3cae16d2019-07-11 19:08:36 +02003599 echo 'CONFIG_TPM=y' >> $config_host_mak
Paolo Bonzini3b8acc12013-03-18 16:37:50 +01003600fi
3601
Michael R. Hines2da776d2013-07-22 10:01:54 -04003602if test "$rdma" = "yes" ; then
3603 echo "CONFIG_RDMA=y" >> $config_host_mak
Fam Zheng392fb642017-09-07 16:42:30 +08003604 echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
Michael R. Hines2da776d2013-07-22 10:01:54 -04003605fi
3606
Marcel Apfelbaum21ab34c2018-08-16 18:16:37 +03003607if test "$pvrdma" = "yes" ; then
3608 echo "CONFIG_PVRDMA=y" >> $config_host_mak
3609fi
3610
Changlong Xiea6b1d4c2016-07-27 15:01:48 +08003611if test "$replication" = "yes" ; then
3612 echo "CONFIG_REPLICATION=y" >> $config_host_mak
3613fi
3614
Paolo Bonziniba59fb72018-06-13 14:23:08 +02003615if test "$debug_mutex" = "yes" ; then
3616 echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak
3617fi
Kamil Rytarowskie0580342017-07-14 09:33:44 +01003618
Jeff Cody2f740132018-11-07 07:36:44 +01003619if test "$bochs" = "yes" ; then
3620 echo "CONFIG_BOCHS=y" >> $config_host_mak
3621fi
3622if test "$cloop" = "yes" ; then
3623 echo "CONFIG_CLOOP=y" >> $config_host_mak
3624fi
3625if test "$dmg" = "yes" ; then
3626 echo "CONFIG_DMG=y" >> $config_host_mak
3627fi
3628if test "$qcow1" = "yes" ; then
3629 echo "CONFIG_QCOW1=y" >> $config_host_mak
3630fi
3631if test "$vdi" = "yes" ; then
3632 echo "CONFIG_VDI=y" >> $config_host_mak
3633fi
3634if test "$vvfat" = "yes" ; then
3635 echo "CONFIG_VVFAT=y" >> $config_host_mak
3636fi
3637if test "$qed" = "yes" ; then
3638 echo "CONFIG_QED=y" >> $config_host_mak
3639fi
3640if test "$parallels" = "yes" ; then
3641 echo "CONFIG_PARALLELS=y" >> $config_host_mak
3642fi
Jeff Cody2f740132018-11-07 07:36:44 +01003643
Alex Bennée40e8c6f2019-06-13 14:52:25 +01003644if test "$plugins" = "yes" ; then
3645 echo "CONFIG_PLUGIN=y" >> $config_host_mak
Emilio G. Cota26fffe22018-10-21 13:56:29 -04003646 # Copy the export object list to the build dir
3647 if test "$ld_dynamic_list" = "yes" ; then
3648 echo "CONFIG_HAS_LD_DYNAMIC_LIST=yes" >> $config_host_mak
3649 ld_symbols=qemu-plugins-ld.symbols
3650 cp "$source_path/plugins/qemu-plugins.symbols" $ld_symbols
3651 elif test "$ld_exported_symbols_list" = "yes" ; then
3652 echo "CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST=yes" >> $config_host_mak
3653 ld64_symbols=qemu-plugins-ld64.symbols
3654 echo "# Automatically generated by configure - do not modify" > $ld64_symbols
3655 grep 'qemu_' "$source_path/plugins/qemu-plugins.symbols" | sed 's/;//g' | \
3656 sed -E 's/^[[:space:]]*(.*)/_\1/' >> $ld64_symbols
3657 else
3658 error_exit \
3659 "If \$plugins=yes, either \$ld_dynamic_list or " \
3660 "\$ld_exported_symbols_list should have been set to 'yes'."
3661 fi
Alex Bennée40e8c6f2019-06-13 14:52:25 +01003662fi
3663
Alex Bennéeb1863cc2021-01-08 22:42:39 +00003664if test -n "$gdb_bin"; then
3665 gdb_version=$($gdb_bin --version | head -n 1)
Alex Bennéed6a66c82021-02-02 13:39:53 +00003666 if version_ge ${gdb_version##* } 9.1; then
Alex Bennéeb1863cc2021-01-08 22:42:39 +00003667 echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
3668 fi
Alex Bennéef48e5902020-03-16 17:21:48 +00003669fi
3670
Alexey Krasikov54e7aac2020-05-25 14:19:12 +03003671if test "$secret_keyring" = "yes" ; then
3672 echo "CONFIG_SECRET_KEYRING=y" >> $config_host_mak
3673fi
3674
Juan Quintela98ec69a2009-07-16 18:34:18 +02003675echo "ROMS=$roms" >> $config_host_mak
Juan Quintela804edf22009-07-27 16:12:49 +02003676echo "MAKE=$make" >> $config_host_mak
Blue Swirlc886edf2011-07-22 21:08:09 +00003677echo "PYTHON=$python" >> $config_host_mak
Alex Bennée39d87c82020-03-03 15:06:20 +00003678echo "GENISOIMAGE=$genisoimage" >> $config_host_mak
Paolo Bonzinia5665052019-06-10 12:05:14 +02003679echo "MESON=$meson" >> $config_host_mak
Paolo Bonzini09e93322020-08-13 09:28:11 -04003680echo "NINJA=$ninja" >> $config_host_mak
Juan Quintela804edf22009-07-27 16:12:49 +02003681echo "CC=$cc" >> $config_host_mak
Bastian Koppelmann433de742021-05-12 11:20:35 +01003682echo "HOST_CC=$host_cc" >> $config_host_mak
Michael S. Tsirkina31a8642013-07-24 18:56:03 +03003683if $iasl -h > /dev/null 2>&1; then
Paolo Bonzini859aef02020-08-04 18:14:26 +02003684 echo "CONFIG_IASL=$iasl" >> $config_host_mak
Michael S. Tsirkina31a8642013-07-24 18:56:03 +03003685fi
Juan Quintela804edf22009-07-27 16:12:49 +02003686echo "AR=$ar" >> $config_host_mak
Richard Hendersoncdbd7272016-07-07 21:49:36 -07003687echo "AS=$as" >> $config_host_mak
Richard Henderson5f6f0e22016-06-23 10:39:18 -07003688echo "CCAS=$ccas" >> $config_host_mak
Blue Swirl3dd46c72013-01-05 10:10:27 +00003689echo "CPP=$cpp" >> $config_host_mak
Juan Quintela804edf22009-07-27 16:12:49 +02003690echo "OBJCOPY=$objcopy" >> $config_host_mak
3691echo "LD=$ld" >> $config_host_mak
Brad46eef332013-12-10 19:49:08 -05003692echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
Juan Quintelaa558ee12009-08-03 14:46:21 +02003693echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
Bruno Dominguez11cde1c2017-06-06 14:07:47 +01003694echo "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04003695echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
3696echo "GLIB_LIBS=$glib_libs" >> $config_host_mak
Marc-André Lureaud83acfd2021-10-09 17:37:40 +04003697echo "GLIB_VERSION=$(pkg-config --modversion glib-2.0)" >> $config_host_mak
Philippe Mathieu-Daudé8a99e9a2018-04-15 20:05:19 -03003698echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
Peter Maydelle57218b2016-08-08 17:11:28 +01003699echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
Juan Quintela804edf22009-07-27 16:12:49 +02003700echo "EXESUF=$EXESUF" >> $config_host_mak
Paolo Bonzinif15bff22019-07-18 13:19:02 +02003701echo "LIBS_QGA=$libs_qga" >> $config_host_mak
Juan Quintela804edf22009-07-27 16:12:49 +02003702
Marek Marczykowski-Góreckib767d252020-05-20 15:20:23 +02003703if test "$rng_none" = "yes"; then
3704 echo "CONFIG_RNG_NONE=y" >> $config_host_mak
3705fi
3706
Peter Maydell6efd7512011-11-30 11:59:04 +00003707# use included Linux headers
3708if test "$linux" = "yes" ; then
Andreas Färbera307beb2012-06-14 15:14:33 +00003709 mkdir -p linux-headers
Peter Maydell6efd7512011-11-30 11:59:04 +00003710 case "$cpu" in
Paolo Bonzini4da270b2021-11-09 09:36:10 +01003711 i386|x86_64)
Peter Maydell08312a62012-08-03 13:51:25 +01003712 linux_arch=x86
Peter Maydell6efd7512011-11-30 11:59:04 +00003713 ;;
Paolo Bonzinid8ff8922021-11-09 09:18:20 +01003714 ppc|ppc64)
Peter Maydell08312a62012-08-03 13:51:25 +01003715 linux_arch=powerpc
Peter Maydell6efd7512011-11-30 11:59:04 +00003716 ;;
3717 s390x)
Peter Maydell08312a62012-08-03 13:51:25 +01003718 linux_arch=s390
3719 ;;
Claudio Fontana1f080312013-06-12 16:20:23 +01003720 aarch64)
3721 linux_arch=arm64
3722 ;;
Sanjay Lal222e7d12014-06-17 23:10:36 +01003723 mips64)
3724 linux_arch=mips
3725 ;;
Peter Maydell08312a62012-08-03 13:51:25 +01003726 *)
3727 # For most CPUs the kernel architecture name and QEMU CPU name match.
3728 linux_arch="$cpu"
Peter Maydell6efd7512011-11-30 11:59:04 +00003729 ;;
3730 esac
Peter Maydell08312a62012-08-03 13:51:25 +01003731 # For non-KVM architectures we will not have asm headers
3732 if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
3733 symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
3734 fi
Peter Maydell6efd7512011-11-30 11:59:04 +00003735fi
3736
bellard1d14ffa2005-10-30 18:58:22 +00003737for target in $target_list; do
Paolo Bonzinifdb75ae2020-09-21 04:37:49 -04003738 target_dir="$target"
Philippe Mathieu-Daudé57a93f12021-11-09 15:45:04 +01003739 target_name=$(echo $target | cut -d '-' -f 1)$EXESUF
Paolo Bonzinifdb75ae2020-09-21 04:37:49 -04003740 mkdir -p $target_dir
3741 case $target in
3742 *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;;
3743 *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;;
3744 esac
3745done
bellard7d132992003-03-06 23:23:54 +00003746
Paolo Bonzini765686d2020-09-18 06:37:21 -04003747echo "CONFIG_QEMU_INTERP_PREFIX=$interp_prefix" | sed 's/%M/@0@/' >> $config_host_mak
Paolo Bonzinifdb75ae2020-09-21 04:37:49 -04003748if test "$default_targets" = "yes"; then
3749 echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak
3750fi
Peter Crosthwaitea540f152013-04-18 14:47:31 +10003751
Wanlong Gaoa99d57b2014-05-14 17:43:28 +08003752if test "$numa" = "yes"; then
3753 echo "CONFIG_NUMA=y" >> $config_host_mak
Marc-André Lureauab318052019-07-24 19:23:16 +04003754 echo "NUMA_LIBS=$numa_libs" >> $config_host_mak
Wanlong Gaoa99d57b2014-05-14 17:43:28 +08003755fi
3756
John Snowfd0e6052015-03-25 18:57:39 -04003757if test "$ccache_cpp2" = "yes"; then
3758 echo "export CCACHE_CPP2=y" >> $config_host_mak
3759fi
3760
Daniele Buono1e4f6062020-05-29 16:51:21 -04003761if test "$safe_stack" = "yes"; then
3762 echo "CONFIG_SAFESTACK=y" >> $config_host_mak
3763fi
3764
Peter Maydelle29e5c62018-11-02 11:52:38 +00003765# If we're using a separate build tree, set it up now.
Peter Maydelle29e5c62018-11-02 11:52:38 +00003766# LINKS are things to symlink back into the source tree
3767# (these can be both files and directories).
3768# Caution: do not add files or directories here using wildcards. This
3769# will result in problems later if a new file matching the wildcard is
3770# added to the source tree -- nothing will cause configure to be rerun
3771# so the build tree will be missing the link back to the new file, and
3772# tests might fail. Prefer to keep the relevant files in their own
3773# directory and symlink the directory instead.
Gerd Hoffmann09db9b92020-08-27 12:26:17 +02003774# UNLINK is used to remove symlinks from older development versions
3775# that might get into the way when doing "git update" without doing
3776# a "make distclean" in between.
Paolo Bonzini2038f8c2019-08-07 16:35:23 +02003777LINKS="Makefile"
Paolo Bonzini39419962020-08-06 14:08:31 +02003778LINKS="$LINKS tests/tcg/Makefile.target"
Gerd Hoffmannddcf6072020-08-24 09:40:57 +02003779LINKS="$LINKS pc-bios/optionrom/Makefile"
Peter Maydelle29e5c62018-11-02 11:52:38 +00003780LINKS="$LINKS pc-bios/s390-ccw/Makefile"
Gerd Hoffmann8db2a4f2020-06-22 15:12:40 +02003781LINKS="$LINKS roms/seabios/Makefile"
Peter Maydelle29e5c62018-11-02 11:52:38 +00003782LINKS="$LINKS pc-bios/qemu-icon.bmp"
3783LINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
Willian Rampazzobbbd9b62021-11-05 12:53:54 -03003784LINKS="$LINKS tests/avocado tests/data"
Peter Maydell39950352018-11-02 11:52:39 +00003785LINKS="$LINKS tests/qemu-iotests/check"
Cleber Rosa8f8fd9e2019-02-06 11:29:01 -05003786LINKS="$LINKS python"
Alex Bennéec17a3862020-09-09 12:27:41 +01003787LINKS="$LINKS contrib/plugins/Makefile "
Gerd Hoffmann09db9b92020-08-27 12:26:17 +02003788UNLINK="pc-bios/keymaps"
Richard Henderson753d11f2011-06-24 11:58:37 -07003789for bios_file in \
3790 $source_path/pc-bios/*.bin \
Bin Meng3a631b82020-06-22 13:09:32 +08003791 $source_path/pc-bios/*.elf \
Alexey Kardashevskiy225a9ab2016-10-26 13:18:03 +11003792 $source_path/pc-bios/*.lid \
Richard Henderson753d11f2011-06-24 11:58:37 -07003793 $source_path/pc-bios/*.rom \
3794 $source_path/pc-bios/*.dtb \
Dominik Dingele89e33e2013-04-29 04:52:06 +00003795 $source_path/pc-bios/*.img \
Richard Henderson753d11f2011-06-24 11:58:37 -07003796 $source_path/pc-bios/openbios-* \
Alexander Graf4e73c782014-01-20 00:25:40 +01003797 $source_path/pc-bios/u-boot.* \
John Arbucklecd946e52021-08-31 12:50:20 -04003798 $source_path/pc-bios/palcode-* \
3799 $source_path/pc-bios/qemu_vga.ndrv
3800
Richard Henderson753d11f2011-06-24 11:58:37 -07003801do
Peter Maydelle29e5c62018-11-02 11:52:38 +00003802 LINKS="$LINKS pc-bios/$(basename $bios_file)"
Paolo Bonzinid1807a42010-12-23 11:43:59 +01003803done
Peter Maydelle29e5c62018-11-02 11:52:38 +00003804for f in $LINKS ; do
Paolo Bonzini0f4d8892020-09-01 03:23:47 -04003805 if [ -e "$source_path/$f" ]; then
Paolo Bonzini5dce7b82021-10-13 13:56:24 +02003806 mkdir -p `dirname ./$f`
Peter Maydellf9245e12011-06-03 17:10:40 +01003807 symlink "$source_path/$f" "$f"
3808 fi
Paolo Bonzinid1807a42010-12-23 11:43:59 +01003809done
Gerd Hoffmann09db9b92020-08-27 12:26:17 +02003810for f in $UNLINK ; do
3811 if [ -L "$f" ]; then
3812 rm -f "$f"
3813 fi
3814done
Paul Brook1ad21342009-05-19 16:17:58 +01003815
Paolo Bonzini2038f8c2019-08-07 16:35:23 +02003816(for i in $cross_cc_vars; do
3817 export $i
3818done
Alex Bennéede6d7e62021-04-01 11:25:22 +01003819export target_list source_path use_containers ARCH
Paolo Bonzini2038f8c2019-08-07 16:35:23 +02003820$source_path/tests/tcg/configure.sh)
3821
Anthony Liguoric34ebfd2009-09-04 10:13:29 -05003822# temporary config to build submodules
Gerd Hoffmann8db2a4f2020-06-22 15:12:40 +02003823for rom in seabios; do
Anthony Liguoric34ebfd2009-09-04 10:13:29 -05003824 config_mak=roms/$rom/config.mak
Stefan Weil37116c82010-03-01 22:20:29 +01003825 echo "# Automatically generated by configure - do not modify" > $config_mak
Anthony Liguoric34ebfd2009-09-04 10:13:29 -05003826 echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
Richard Hendersoncdbd7272016-07-07 21:49:36 -07003827 echo "AS=$as" >> $config_mak
Richard Henderson5f6f0e22016-06-23 10:39:18 -07003828 echo "CCAS=$ccas" >> $config_mak
Anthony Liguoric34ebfd2009-09-04 10:13:29 -05003829 echo "CC=$cc" >> $config_mak
3830 echo "BCC=bcc" >> $config_mak
Blue Swirl3dd46c72013-01-05 10:10:27 +00003831 echo "CPP=$cpp" >> $config_mak
Anthony Liguoric34ebfd2009-09-04 10:13:29 -05003832 echo "OBJCOPY=objcopy" >> $config_mak
Michael S. Tsirkina31a8642013-07-24 18:56:03 +03003833 echo "IASL=$iasl" >> $config_mak
Anthony Liguoric34ebfd2009-09-04 10:13:29 -05003834 echo "LD=$ld" >> $config_mak
Alistair Francis9f81aeb2017-11-07 17:10:46 -08003835 echo "RANLIB=$ranlib" >> $config_mak
Anthony Liguoric34ebfd2009-09-04 10:13:29 -05003836done
3837
Helge Konetzka98409992021-09-15 12:56:34 +02003838config_mak=pc-bios/optionrom/config.mak
3839echo "# Automatically generated by configure - do not modify" > $config_mak
3840echo "TOPSRC_DIR=$source_path" >> $config_mak
3841
Paolo Bonzinia5665052019-06-10 12:05:14 +02003842if test "$skip_meson" = no; then
Paolo Bonzinid77e90f2021-03-16 08:19:34 +01003843 cross="config-meson.cross.new"
3844 meson_quote() {
Paolo Bonziniac7ebcc2021-11-05 10:07:37 +01003845 test $# = 0 && return
Paolo Bonzini47b30832020-09-23 05:26:17 -04003846 echo "'$(echo $* | sed "s/ /','/g")'"
Paolo Bonzinid77e90f2021-03-16 08:19:34 +01003847 }
Marc-André Lureaufc929892019-07-13 01:47:54 +04003848
Paolo Bonzinid77e90f2021-03-16 08:19:34 +01003849 echo "# Automatically generated by configure - do not modify" > $cross
3850 echo "[properties]" >> $cross
Alex Bennéed1d5e9e2021-07-07 14:17:44 +01003851
3852 # unroll any custom device configs
Alex Bennée11bdcfc2021-07-21 00:26:38 +01003853 for a in $device_archs; do
3854 eval "c=\$devices_${a}"
3855 echo "${a}-softmmu = '$c'" >> $cross
3856 done
Alex Bennéed1d5e9e2021-07-07 14:17:44 +01003857
Paolo Bonzinid77e90f2021-03-16 08:19:34 +01003858 test -z "$cxx" && echo "link_language = 'c'" >> $cross
3859 echo "[built-in options]" >> $cross
Paolo Bonzinia2866662021-11-05 10:09:26 +01003860 echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross
3861 echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross
3862 echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross
3863 echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross
Paolo Bonzinid77e90f2021-03-16 08:19:34 +01003864 echo "[binaries]" >> $cross
Paolo Bonzini4dba2782021-09-29 17:14:43 +02003865 echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross
3866 test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross
3867 test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross
Paolo Bonzinid77e90f2021-03-16 08:19:34 +01003868 echo "ar = [$(meson_quote $ar)]" >> $cross
3869 echo "nm = [$(meson_quote $nm)]" >> $cross
3870 echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross
3871 echo "ranlib = [$(meson_quote $ranlib)]" >> $cross
3872 if has $sdl2_config; then
3873 echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross
3874 fi
3875 echo "strip = [$(meson_quote $strip)]" >> $cross
3876 echo "windres = [$(meson_quote $windres)]" >> $cross
3877 if test "$cross_compile" = "yes"; then
Marc-André Lureaufc929892019-07-13 01:47:54 +04003878 cross_arg="--cross-file config-meson.cross"
Marc-André Lureaufc929892019-07-13 01:47:54 +04003879 echo "[host_machine]" >> $cross
Paolo Bonziniba7c60c2021-11-08 14:47:54 +01003880 echo "system = '$targetos'" >> $cross
Paolo Bonzini823eb012021-11-08 14:18:17 +01003881 case "$cpu" in
Joelle van Dynef6bca9d2021-01-25 17:24:54 -08003882 i386)
Marc-André Lureaufc929892019-07-13 01:47:54 +04003883 echo "cpu_family = 'x86'" >> $cross
3884 ;;
Marc-André Lureaufc929892019-07-13 01:47:54 +04003885 *)
Paolo Bonzini823eb012021-11-08 14:18:17 +01003886 echo "cpu_family = '$cpu'" >> $cross
Marc-André Lureaufc929892019-07-13 01:47:54 +04003887 ;;
3888 esac
3889 echo "cpu = '$cpu'" >> $cross
3890 if test "$bigendian" = "yes" ; then
3891 echo "endian = 'big'" >> $cross
3892 else
3893 echo "endian = 'little'" >> $cross
3894 fi
Paolo Bonzinid77e90f2021-03-16 08:19:34 +01003895 else
Marc-André Lureaufc929892019-07-13 01:47:54 +04003896 cross_arg="--native-file config-meson.cross"
Paolo Bonzinid77e90f2021-03-16 08:19:34 +01003897 fi
3898 mv $cross config-meson.cross
Marc-André Lureaufc929892019-07-13 01:47:54 +04003899
Paolo Bonzinid77e90f2021-03-16 08:19:34 +01003900 rm -rf meson-private meson-info meson-logs
Paolo Bonzini61d63092021-10-07 15:08:28 +02003901 run_meson() {
3902 NINJA=$ninja $meson setup \
Paolo Bonzinid17f3052020-08-18 12:17:01 +02003903 --prefix "$prefix" \
3904 --libdir "$libdir" \
3905 --libexecdir "$libexecdir" \
3906 --bindir "$bindir" \
3907 --includedir "$includedir" \
3908 --datadir "$datadir" \
3909 --mandir "$mandir" \
3910 --sysconfdir "$sysconfdir" \
Paolo Bonzini16bf7a32020-10-16 03:19:14 -04003911 --localedir "$localedir" \
Paolo Bonzinid17f3052020-08-18 12:17:01 +02003912 --localstatedir "$local_statedir" \
Paolo Bonzini3b4da132021-10-07 15:08:29 +02003913 -Daudio_drv_list=$audio_drv_list \
3914 -Ddefault_devices=$default_devices \
Paolo Bonzinid17f3052020-08-18 12:17:01 +02003915 -Ddocdir="$docdir" \
Paolo Bonzini16bf7a32020-10-16 03:19:14 -04003916 -Dqemu_firmwarepath="$firmwarepath" \
Marc-André Lureau73f3aa32020-08-26 15:04:15 +04003917 -Dqemu_suffix="$qemu_suffix" \
Paolo Bonzini3b4da132021-10-07 15:08:29 +02003918 -Dsphinx_build="$sphinx_build" \
3919 -Dtrace_file="$trace_file" \
Paolo Bonzinia5665052019-06-10 12:05:14 +02003920 -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) \
3921 -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo false; fi) \
3922 -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \
3923 -Dstrip=$(if test "$strip_opt" = yes; then echo true; else echo false; fi) \
Marc-André Lureauda6d48b2019-09-17 15:39:36 +04003924 -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \
Marc-André Lureaubf0e56a2019-10-04 17:35:16 +04003925 -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \
Paolo Bonzini3b4da132021-10-07 15:08:29 +02003926 -Db_lto=$lto -Dcfi=$cfi -Dtcg=$tcg -Dxen=$xen \
3927 -Dcapstone=$capstone -Dfdt=$fdt -Dslirp=$slirp \
Paolo Bonzini537b7242021-10-07 15:08:12 +02003928 $(test -n "${LIB_FUZZING_ENGINE+xxx}" && echo "-Dfuzzing_engine=$LIB_FUZZING_ENGINE") \
Thomas Huth332008e2021-07-13 11:31:52 +02003929 $(if test "$default_feature" = no; then echo "-Dauto_features=disabled"; fi) \
Paolo Bonzini61d63092021-10-07 15:08:28 +02003930 "$@" $cross_arg "$PWD" "$source_path"
3931 }
3932 eval run_meson $meson_options
Paolo Bonzinid77e90f2021-03-16 08:19:34 +01003933 if test "$?" -ne 0 ; then
3934 error_exit "meson setup failed"
3935 fi
Paolo Bonzini699d3882021-03-16 08:27:40 +01003936else
3937 if test -f meson-private/cmd_line.txt; then
3938 # Adjust old command line options whose type was changed
3939 # Avoids having to use "setup --wipe" when Meson is upgraded
3940 perl -i -ne '
3941 s/^gettext = true$/gettext = auto/;
3942 s/^gettext = false$/gettext = disabled/;
Paolo Bonzini654d6b02021-02-09 14:59:26 +01003943 /^b_staticpic/ && next;
Paolo Bonzini699d3882021-03-16 08:27:40 +01003944 print;' meson-private/cmd_line.txt
3945 fi
Paolo Bonzinia5665052019-06-10 12:05:14 +02003946fi
3947
Alex Bennée2d838d92020-09-09 12:27:37 +01003948if test -n "${deprecated_features}"; then
3949 echo "Warning, deprecated features enabled."
Mao Zhongyia476b212021-07-23 14:58:28 +08003950 echo "Please see docs/about/deprecated.rst"
Alex Bennée2d838d92020-09-09 12:27:37 +01003951 echo " features: ${deprecated_features}"
3952fi
3953
Thomas Huthe0447a82021-04-14 13:20:04 +02003954# Create list of config switches that should be poisoned in common code...
3955# but filter out CONFIG_TCG and CONFIG_USER_ONLY which are special.
Thomas Huth54b03062021-05-19 13:38:40 +02003956target_configs_h=$(ls *-config-devices.h *-config-target.h 2>/dev/null)
3957if test -n "$target_configs_h" ; then
3958 sed -n -e '/CONFIG_TCG/d' -e '/CONFIG_USER_ONLY/d' \
3959 -e '/^#define / { s///; s/ .*//; s/^/#pragma GCC poison /p; }' \
3960 $target_configs_h | sort -u > config-poison.h
3961else
3962 :> config-poison.h
3963fi
Thomas Huthe0447a82021-04-14 13:20:04 +02003964
Michael S. Tsirkindc655402014-03-09 17:37:49 +02003965# Save the configure command line for later reuse.
3966cat <<EOD >config.status
3967#!/bin/sh
3968# Generated by configure.
3969# Run this file to recreate the current configuration.
3970# Compiler output produced by configure, useful for debugging
3971# configure, is in config.log if it exists.
3972EOD
Daniel P. Berrangée811da72018-09-04 13:36:03 +01003973
3974preserve_env() {
3975 envname=$1
3976
3977 eval envval=\$$envname
3978
3979 if test -n "$envval"
3980 then
3981 echo "$envname='$envval'" >> config.status
3982 echo "export $envname" >> config.status
3983 else
3984 echo "unset $envname" >> config.status
3985 fi
3986}
3987
3988# Preserve various env variables that influence what
3989# features/build target configure will detect
3990preserve_env AR
3991preserve_env AS
3992preserve_env CC
3993preserve_env CPP
Paolo Bonzini8009da02021-11-05 10:08:43 +01003994preserve_env CFLAGS
Daniel P. Berrangée811da72018-09-04 13:36:03 +01003995preserve_env CXX
Paolo Bonzini8009da02021-11-05 10:08:43 +01003996preserve_env CXXFLAGS
Daniel P. Berrangée811da72018-09-04 13:36:03 +01003997preserve_env INSTALL
3998preserve_env LD
Paolo Bonzini8009da02021-11-05 10:08:43 +01003999preserve_env LDFLAGS
Daniel P. Berrangée811da72018-09-04 13:36:03 +01004000preserve_env LD_LIBRARY_PATH
4001preserve_env LIBTOOL
4002preserve_env MAKE
4003preserve_env NM
4004preserve_env OBJCOPY
4005preserve_env PATH
4006preserve_env PKG_CONFIG
4007preserve_env PKG_CONFIG_LIBDIR
4008preserve_env PKG_CONFIG_PATH
4009preserve_env PYTHON
Daniel P. Berrangée811da72018-09-04 13:36:03 +01004010preserve_env SDL2_CONFIG
4011preserve_env SMBD
4012preserve_env STRIP
4013preserve_env WINDRES
4014
Michael S. Tsirkindc655402014-03-09 17:37:49 +02004015printf "exec" >>config.status
Paolo Bonzinia5665052019-06-10 12:05:14 +02004016for i in "$0" "$@"; do
Paolo Bonzini835af892020-09-08 13:20:45 +02004017 test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status
Paolo Bonzinia5665052019-06-10 12:05:14 +02004018done
Dr. David Alan Gilbertcf7cc922016-01-12 11:58:48 +00004019echo ' "$@"' >>config.status
Michael S. Tsirkindc655402014-03-09 17:37:49 +02004020chmod +x config.status
4021
Peter Maydell8cd05ab2014-05-23 17:07:24 +01004022rm -r "$TMPDIR1"