blob: e404b55da5dbbfcda53e28eea6648c4b248ec50f [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"
Philippe Mathieu-Daudé4cb37d12022-02-15 16:15:13 +010080TMPM="${TMPDIR1}/${TMPB}.m"
Peter Maydell8cd05ab2014-05-23 17:07:24 +010081TMPE="${TMPDIR1}/${TMPB}.exe"
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
Philippe Mathieu-Daudé4cb37d12022-02-15 16:15:13 +0100152do_objc() {
153 do_compiler "$objcc" $CPU_CFLAGS "$@"
154}
155
Richard Henderson00849b92020-06-17 13:13:06 -0700156# Append $2 to the variable named $1, with space separation
157add_to() {
158 eval $1=\${$1:+\"\$$1 \"}\$2
159}
160
Peter Maydell9c83ffd2014-02-25 18:27:49 +0000161update_cxxflags() {
162 # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
163 # options which some versions of GCC's C++ compiler complain about
164 # because they only make sense for C programs.
Paolo Bonzinide38c0c2021-11-08 08:58:23 +0100165 QEMU_CXXFLAGS="-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS"
Richard Henderson8a9d3d52021-06-14 16:31:36 -0700166 CONFIGURE_CXXFLAGS=$(echo "$CONFIGURE_CFLAGS" | sed s/-std=gnu11/-std=gnu++11/)
Peter Maydell9c83ffd2014-02-25 18:27:49 +0000167 for arg in $QEMU_CFLAGS; do
168 case $arg in
169 -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
170 -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
171 ;;
172 *)
173 QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
174 ;;
175 esac
176 done
177}
178
Juan Quintela52166aa2009-08-03 14:46:03 +0200179compile_object() {
John Snowfd0e6052015-03-25 18:57:39 -0400180 local_cflags="$1"
Paolo Bonzinia2866662021-11-05 10:09:26 +0100181 do_cc $CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
Juan Quintela52166aa2009-08-03 14:46:03 +0200182}
183
184compile_prog() {
185 local_cflags="$1"
186 local_ldflags="$2"
Paolo Bonzinia2866662021-11-05 10:09:26 +0100187 do_cc $CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC \
188 $LDFLAGS $EXTRA_LDFLAGS $CONFIGURE_LDFLAGS $QEMU_LDFLAGS $local_ldflags
Juan Quintela52166aa2009-08-03 14:46:03 +0200189}
190
Paolo Bonzini11568d62010-12-23 11:43:58 +0100191# symbolically link $1 to $2. Portable version of "ln -sf".
192symlink() {
Stefan Weil72b8b5a2012-03-19 13:20:47 +0100193 rm -rf "$2"
Anthony Liguoriec5b06d2012-06-06 16:57:00 +0800194 mkdir -p "$(dirname "$2")"
Stefan Weil72b8b5a2012-03-19 13:20:47 +0100195 ln -s "$1" "$2"
Paolo Bonzini11568d62010-12-23 11:43:58 +0100196}
197
Loïc Minier0dba6192010-01-28 21:26:51 +0000198# check whether a command is available to this shell (may be either an
199# executable or a builtin)
200has() {
201 type "$1" >/dev/null 2>&1
202}
203
Marc-André Lureau0a01d762019-08-21 11:21:16 +0400204version_ge () {
Alex Bennée2df52b92021-02-02 13:39:52 +0000205 local_ver1=$(expr "$1" : '\([0-9.]*\)' | tr . ' ')
206 local_ver2=$(echo "$2" | tr . ' ')
Marc-André Lureau0a01d762019-08-21 11:21:16 +0400207 while true; do
208 set x $local_ver1
209 local_first=${2-0}
Stefano Garzarellac44a33e2020-08-21 22:35:58 +0200210 # 'shift 2' if $2 is set, or 'shift' if $2 is not set
211 shift ${2:+2}
Marc-André Lureau0a01d762019-08-21 11:21:16 +0400212 local_ver1=$*
213 set x $local_ver2
214 # the second argument finished, the first must be greater or equal
215 test $# = 1 && return 0
216 test $local_first -lt $2 && return 1
217 test $local_first -gt $2 && return 0
Stefano Garzarellac44a33e2020-08-21 22:35:58 +0200218 shift ${2:+2}
Marc-André Lureau0a01d762019-08-21 11:21:16 +0400219 local_ver2=$*
220 done
221}
222
Paolo Bonzini3b6b7552012-09-17 11:59:41 +0200223glob() {
224 eval test -z '"${1#'"$2"'}"'
225}
226
Christian Borntraegere9a35912017-08-23 12:16:23 +0200227ld_has() {
228 $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
229}
230
Antonio Ospite4ace32e2019-05-26 16:47:47 +0200231if printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]";
232then
233 error_exit "main directory cannot contain spaces nor colons"
234fi
235
Antonio Ospite14211822019-05-26 16:47:46 +0200236# default parameters
Juan Quintela2ff6b912009-08-03 14:45:55 +0200237cpu=""
Michael S. Tsirkina31a8642013-07-24 18:56:03 +0300238iasl="iasl"
bellard1e43adf2003-09-30 20:54:24 +0000239interp_prefix="/usr/gnemul/qemu-%M"
bellard43ce4df2003-06-09 19:53:12 +0000240static="no"
Joelle van Dyne3812c0c2021-01-25 17:24:48 -0800241cross_compile="no"
bellard7d132992003-03-06 23:23:54 +0000242cross_prefix=""
Paolo Bonzini87430d52021-10-07 15:06:09 +0200243audio_drv_list="default"
Fam Zhengb64ec4e2013-05-29 19:35:40 +0800244block_drv_rw_whitelist=""
245block_drv_ro_whitelist=""
Peter Maydelle49d0212012-12-07 15:39:13 +0000246host_cc="cc"
Gerd Hoffmann5bc62e02012-02-08 13:54:13 +0100247debug_info="yes"
Daniele Buonocdad7812020-12-04 18:06:11 -0500248lto="false"
Steven Noonan63678e12014-03-28 17:19:02 +0100249stack_protector=""
Daniele Buono1e4f6062020-05-29 16:51:21 -0400250safe_stack=""
Alex Bennéeafc3a8f2019-11-28 16:35:24 +0100251use_containers="yes"
Alex Bennéef2385392020-04-30 20:01:14 +0100252gdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
aliguoriac0df512008-12-29 17:14:15 +0000253
Daniel P. Berrange92712822017-09-29 11:11:58 +0100254if test -e "$source_path/.git"
255then
Dan Streetman7d7dbf92021-01-19 12:20:46 -0500256 git_submodules_action="update"
Daniel P. Berrange92712822017-09-29 11:11:58 +0100257else
Dan Streetman7d7dbf92021-01-19 12:20:46 -0500258 git_submodules_action="ignore"
Daniel P. Berrange92712822017-09-29 11:11:58 +0100259fi
Paolo Bonzini2d652f22021-05-12 09:21:56 +0200260
261git_submodules="ui/keycodemapdb"
Daniel P. Berrangecc84d632017-10-20 15:02:43 +0100262git="git"
aliguoriac0df512008-12-29 17:14:15 +0000263
Stefan Weilafb63eb2012-09-26 22:04:38 +0200264# Don't accept a target_list environment variable.
265unset target_list
Alex Bennée447e1332019-03-19 11:59:12 +0000266unset target_list_exclude
Paolo Bonzini377529c2010-12-23 11:43:50 +0100267
268# Default value for a variable defining feature "foo".
269# * foo="no" feature will only be used if --enable-foo arg is given
270# * foo="" feature will be searched for, and if found, will be used
271# unless --disable-foo is given
272# * foo="yes" this value will only be set by --enable-foo flag.
273# feature will searched for,
274# if not found, configure exits with error
275#
276# Always add --enable-foo and --disable-foo command line args.
277# Distributions want to ensure that several features are compiled in, and it
278# is impossible without a --enable-foo that exits if a feature is not found.
279
Alex Bennéec87ea112020-12-10 19:04:13 +0000280default_feature=""
281# parse CC options second
282for opt do
283 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
284 case "$opt" in
285 --without-default-features)
286 default_feature="no"
287 ;;
288 esac
289done
290
Paolo Bonzinia2866662021-11-05 10:09:26 +0100291EXTRA_CFLAGS=""
292EXTRA_CXXFLAGS=""
Philippe Mathieu-Daudée910c7d2022-01-08 22:38:55 +0100293EXTRA_OBJCFLAGS=""
Paolo Bonzinia2866662021-11-05 10:09:26 +0100294EXTRA_LDFLAGS=""
295
Alex Bennéec87ea112020-12-10 19:04:13 +0000296xen_ctrl_version="$default_feature"
Thomas Huth0848f8a2021-07-13 11:31:55 +0200297vhost_kernel="$default_feature"
Alex Bennéec87ea112020-12-10 19:04:13 +0000298vhost_net="$default_feature"
299vhost_crypto="$default_feature"
300vhost_scsi="$default_feature"
301vhost_vsock="$default_feature"
Stefan Hajnoczid88618f2020-11-10 17:11:21 +0000302vhost_user="no"
Alex Bennéec87ea112020-12-10 19:04:13 +0000303vhost_user_fs="$default_feature"
Thomas Huth0848f8a2021-07-13 11:31:55 +0200304vhost_vdpa="$default_feature"
Alex Bennéec87ea112020-12-10 19:04:13 +0000305rdma="$default_feature"
306pvrdma="$default_feature"
Paolo Bonzini377529c2010-12-23 11:43:50 +0100307debug_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"
Michael Tokarev1f3f2bf2022-04-22 13:08:25 +0300311fortify_source="yes"
Blue Swirl1d728c32012-05-01 18:45:39 +0000312gcov="no"
Miroslav Rezaninac7328272021-03-31 10:18:45 +0200313EXESUF=""
Fam Zheng17969262014-02-10 14:48:56 +0800314modules="no"
Christian Ehrhardtbd83c862020-03-10 15:58:06 +0100315module_upgrades="no"
Paolo Bonzini377529c2010-12-23 11:43:50 +0100316prefix="/usr/local"
Marc-André Lureau10ff82d2020-08-26 15:04:13 +0400317qemu_suffix="qemu"
Paolo Bonzini377529c2010-12-23 11:43:50 +0100318softmmu="yes"
Paolo Bonzinib915a2f2021-11-09 10:10:41 +0100319linux_user=""
320bsd_user=""
Paolo Bonzini377529c2010-12-23 11:43:50 +0100321pkgversion=""
Avi Kivity40d64442011-11-15 20:12:17 +0200322pie=""
Paolo Bonzini377529c2010-12-23 11:43:50 +0100323trace_file="trace"
Alex Bennéec87ea112020-12-10 19:04:13 +0000324opengl="$default_feature"
Alex Barcelo519175a2012-02-28 12:25:50 +0100325coroutine=""
Daniel P. Berrangea1c5e942016-06-06 10:05:06 +0100326tls_priority="NORMAL"
Alex Bennéeba4dd2a2021-07-09 15:29:57 +0100327plugins="$default_feature"
Alex Bennéec87ea112020-12-10 19:04:13 +0000328secret_keyring="$default_feature"
Paolo Bonzinia5665052019-06-10 12:05:14 +0200329meson=""
Paolo Bonzini3b4da132021-10-07 15:08:29 +0200330meson_args=""
Paolo Bonzini48328882020-08-26 08:04:15 +0200331ninja=""
Paolo Bonzini3b4da132021-10-07 15:08:29 +0200332gio="$default_feature"
Paolo Bonzinia5665052019-06-10 12:05:14 +0200333skip_meson=no
Paolo Bonzini377529c2010-12-23 11:43:50 +0100334
Paolo Bonzini3b4da132021-10-07 15:08:29 +0200335# The following Meson options are handled manually (still they
336# are included in the automatically generated help message)
337
338# 1. Track which submodules are needed
Thomas Huth0577e842022-02-21 10:06:47 +0100339if test "$default_feature" = no ; then
340 capstone="disabled"
341 slirp="disabled"
342else
343 capstone="auto"
344 slirp="auto"
345fi
Paolo Bonzini3b4da132021-10-07 15:08:29 +0200346fdt="auto"
Paolo Bonzini3b4da132021-10-07 15:08:29 +0200347
348# 2. Support --with/--without option
349default_devices="true"
350
351# 3. Automatically enable/disable other options
352tcg="enabled"
353cfi="false"
354
355# 4. Detection partly done in configure
356xen=${default_feature:+disabled}
Peter Maydell898be3e2017-03-21 14:31:57 +0000357
Alex Bennéec87ea112020-12-10 19:04:13 +0000358# parse CC options second
aliguoriac0df512008-12-29 17:14:15 +0000359for opt do
Stefan Weil89138852016-05-16 15:10:20 +0200360 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
aliguoriac0df512008-12-29 17:14:15 +0000361 case "$opt" in
362 --cross-prefix=*) cross_prefix="$optarg"
Joelle van Dyne3812c0c2021-01-25 17:24:48 -0800363 cross_compile="yes"
aliguoriac0df512008-12-29 17:14:15 +0000364 ;;
Paolo Bonzini3d8df642010-12-23 11:43:48 +0100365 --cc=*) CC="$optarg"
aliguoriac0df512008-12-29 17:14:15 +0000366 ;;
Tomoki Sekiyama83f73fc2013-08-07 11:39:36 -0400367 --cxx=*) CXX="$optarg"
368 ;;
Juan Quintela2ff6b912009-08-03 14:45:55 +0200369 --cpu=*) cpu="$optarg"
370 ;;
Paolo Bonzinia2866662021-11-05 10:09:26 +0100371 --extra-cflags=*)
372 EXTRA_CFLAGS="$EXTRA_CFLAGS $optarg"
373 EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg"
Philippe Mathieu-Daudée910c7d2022-01-08 22:38:55 +0100374 EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg"
Paolo Bonzinia2866662021-11-05 10:09:26 +0100375 ;;
376 --extra-cxxflags=*) EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg"
Juan Quintelae2a2ed02009-08-03 14:46:02 +0200377 ;;
Philippe Mathieu-Daudée910c7d2022-01-08 22:38:55 +0100378 --extra-objcflags=*) EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg"
379 ;;
Paolo Bonzinia2866662021-11-05 10:09:26 +0100380 --extra-ldflags=*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS $optarg"
Juan Quintelae2a2ed02009-08-03 14:46:02 +0200381 ;;
Gerd Hoffmann5bc62e02012-02-08 13:54:13 +0100382 --enable-debug-info) debug_info="yes"
383 ;;
384 --disable-debug-info) debug_info="no"
385 ;;
Alex Bennéed75402b2018-04-04 20:27:05 +0100386 --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
387 ;;
Matheus Ferst479ca4c2022-01-20 14:31:41 -0300388 --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-cflags-}; cc_arch=${cc_arch%%=*}
Alex Bennéed422b2b2018-04-13 11:07:58 +0100389 eval "cross_cc_cflags_${cc_arch}=\$optarg"
Paolo Bonzini2038f8c2019-08-07 16:35:23 +0200390 cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}"
Alex Bennéed422b2b2018-04-13 11:07:58 +0100391 ;;
Alex Bennéed75402b2018-04-04 20:27:05 +0100392 --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
393 eval "cross_cc_${cc_arch}=\$optarg"
Paolo Bonzini2038f8c2019-08-07 16:35:23 +0200394 cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}"
Alex Bennéed75402b2018-04-04 20:27:05 +0100395 ;;
aliguoriac0df512008-12-29 17:14:15 +0000396 esac
397done
aliguoriac0df512008-12-29 17:14:15 +0000398# OS specific
399# Using uname is really, really broken. Once we have the right set of checks
Stefan Weil93148aa2012-02-26 18:46:12 +0100400# we can eliminate its usage altogether.
aliguoriac0df512008-12-29 17:14:15 +0000401
Peter Maydelle49d0212012-12-07 15:39:13 +0000402# Preferred compiler:
403# ${CC} (if set)
404# ${cross_prefix}gcc (if cross-prefix specified)
405# system compiler
406if test -z "${CC}${cross_prefix}"; then
407 cc="$host_cc"
408else
409 cc="${CC-${cross_prefix}gcc}"
410fi
411
Tomoki Sekiyama83f73fc2013-08-07 11:39:36 -0400412if test -z "${CXX}${cross_prefix}"; then
413 cxx="c++"
414else
415 cxx="${CXX-${cross_prefix}g++}"
416fi
417
Stuart Yoderb3198cc2011-08-04 17:10:08 -0500418ar="${AR-${cross_prefix}ar}"
Richard Hendersoncdbd7272016-07-07 21:49:36 -0700419as="${AS-${cross_prefix}as}"
Richard Henderson5f6f0e22016-06-23 10:39:18 -0700420ccas="${CCAS-$cc}"
Blue Swirl3dd46c72013-01-05 10:10:27 +0000421cpp="${CPP-$cc -E}"
Stuart Yoderb3198cc2011-08-04 17:10:08 -0500422objcopy="${OBJCOPY-${cross_prefix}objcopy}"
423ld="${LD-${cross_prefix}ld}"
Alistair Francis9f81aeb2017-11-07 17:10:46 -0800424ranlib="${RANLIB-${cross_prefix}ranlib}"
Stefan Weil4852ee92014-09-18 21:55:08 +0200425nm="${NM-${cross_prefix}nm}"
Paolo Bonzini35acbb32021-10-13 13:43:36 +0200426smbd="$SMBD"
Stuart Yoderb3198cc2011-08-04 17:10:08 -0500427strip="${STRIP-${cross_prefix}strip}"
428windres="${WINDRES-${cross_prefix}windres}"
Sergei Trofimovich17884d72012-01-31 22:03:45 +0300429pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
430query_pkg_config() {
431 "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
432}
433pkg_config=query_pkg_config
Dave Airlie47c03742013-12-10 14:05:51 +1000434sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
aliguoriac0df512008-12-29 17:14:15 +0000435
Michael S. Tsirkinbe17dc92009-11-11 13:50:09 +0200436# default flags for all hosts
Peter Maydell2d315152016-09-12 14:10:08 +0100437# We use -fwrapv to tell the compiler that we require a C dialect where
438# left shift of signed integers is well defined and has the expected
439# 2s-complement style results. (Both clang and gcc agree that it
440# provides these semantics.)
Paolo Bonzinide38c0c2021-11-08 08:58:23 +0100441QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv"
Paolo Bonzini086d5f72020-02-03 15:22:17 +0100442QEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
Kevin Wolfc95e3082013-02-22 21:08:51 +0100443QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
Michael S. Tsirkinbe17dc92009-11-11 13:50:09 +0200444QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
Paolo Bonzini5770e8a2020-09-23 05:26:15 -0400445
Paolo Bonzinide38c0c2021-11-08 08:58:23 +0100446QEMU_LDFLAGS=
447
Paolo Bonzini5770e8a2020-09-23 05:26:15 -0400448# Flags that are needed during configure but later taken care of by Meson
Richard Henderson8a9d3d52021-06-14 16:31:36 -0700449CONFIGURE_CFLAGS="-std=gnu11 -Wall"
Paolo Bonzini5770e8a2020-09-23 05:26:15 -0400450CONFIGURE_LDFLAGS=
Paolo Bonzini086d5f72020-02-03 15:22:17 +0100451
Michael S. Tsirkinbe17dc92009-11-11 13:50:09 +0200452
aliguoriac0df512008-12-29 17:14:15 +0000453check_define() {
454cat > $TMPC <<EOF
455#if !defined($1)
Peter Maydellfd786e12011-11-23 17:26:43 +0000456#error $1 not defined
aliguoriac0df512008-12-29 17:14:15 +0000457#endif
458int main(void) { return 0; }
459EOF
Juan Quintela52166aa2009-08-03 14:46:03 +0200460 compile_object
aliguoriac0df512008-12-29 17:14:15 +0000461}
462
Gerd Hoffmann307119e2015-06-10 09:07:35 +0200463check_include() {
464cat > $TMPC <<EOF
465#include <$1>
466int main(void) { return 0; }
467EOF
468 compile_object
469}
470
John Snow93b25862015-03-25 18:57:37 -0400471write_c_skeleton() {
472 cat > $TMPC <<EOF
473int main(void) { return 0; }
474EOF
475}
476
Peter Maydellbbea4052012-08-14 15:35:34 +0100477if check_define __linux__ ; then
Paolo Bonziniba7c60c2021-11-08 14:47:54 +0100478 targetos=linux
Peter Maydellbbea4052012-08-14 15:35:34 +0100479elif check_define _WIN32 ; then
Paolo Bonziniba7c60c2021-11-08 14:47:54 +0100480 targetos=windows
Peter Maydellbbea4052012-08-14 15:35:34 +0100481elif check_define __OpenBSD__ ; then
Paolo Bonziniba7c60c2021-11-08 14:47:54 +0100482 targetos=openbsd
Peter Maydellbbea4052012-08-14 15:35:34 +0100483elif check_define __sun__ ; then
Paolo Bonziniba7c60c2021-11-08 14:47:54 +0100484 targetos=sunos
Peter Maydellbbea4052012-08-14 15:35:34 +0100485elif check_define __HAIKU__ ; then
Paolo Bonziniba7c60c2021-11-08 14:47:54 +0100486 targetos=haiku
Peter Maydell951fedf2017-07-13 16:15:32 +0100487elif check_define __FreeBSD__ ; then
Paolo Bonziniba7c60c2021-11-08 14:47:54 +0100488 targetos=freebsd
Peter Maydell951fedf2017-07-13 16:15:32 +0100489elif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
Paolo Bonziniba7c60c2021-11-08 14:47:54 +0100490 targetos=gnu/kfreebsd
Peter Maydell951fedf2017-07-13 16:15:32 +0100491elif check_define __DragonFly__ ; then
Paolo Bonziniba7c60c2021-11-08 14:47:54 +0100492 targetos=dragonfly
Peter Maydell951fedf2017-07-13 16:15:32 +0100493elif check_define __NetBSD__; then
Paolo Bonziniba7c60c2021-11-08 14:47:54 +0100494 targetos=netbsd
Peter Maydell951fedf2017-07-13 16:15:32 +0100495elif check_define __APPLE__; then
Paolo Bonziniba7c60c2021-11-08 14:47:54 +0100496 targetos=darwin
Peter Maydellbbea4052012-08-14 15:35:34 +0100497else
Peter Maydell951fedf2017-07-13 16:15:32 +0100498 # This is a fatal error, but don't report it yet, because we
499 # might be going to just print the --help text, or it might
500 # be the result of a missing compiler.
Paolo Bonziniba7c60c2021-11-08 14:47:54 +0100501 targetos=bogus
Peter Maydellbbea4052012-08-14 15:35:34 +0100502fi
503
Paolo Bonzini65eff012021-11-08 22:52:35 +0100504# OS specific
505
Paolo Bonzini3b0d8642021-10-13 14:14:53 +0200506mingw32="no"
507bsd="no"
508linux="no"
509solaris="no"
Peter Maydellbbea4052012-08-14 15:35:34 +0100510case $targetos in
Paolo Bonzini65eff012021-11-08 22:52:35 +0100511windows)
512 mingw32="yes"
513 plugins="no"
514 pie="no"
515;;
516gnu/kfreebsd)
517 bsd="yes"
518;;
519freebsd)
520 bsd="yes"
Paolo Bonzini65eff012021-11-08 22:52:35 +0100521 make="${MAKE-gmake}"
522 # needed for kinfo_getvmmap(3) in libutil.h
523;;
524dragonfly)
525 bsd="yes"
526 make="${MAKE-gmake}"
527;;
528netbsd)
529 bsd="yes"
530 make="${MAKE-gmake}"
531;;
532openbsd)
533 bsd="yes"
534 make="${MAKE-gmake}"
535;;
536darwin)
537 bsd="yes"
538 darwin="yes"
539 # Disable attempts to use ObjectiveC features in os/object.h since they
540 # won't work when we're compiling with gcc as a C compiler.
541 QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
542;;
Paolo Bonziniba7c60c2021-11-08 14:47:54 +0100543sunos)
Paolo Bonzini65eff012021-11-08 22:52:35 +0100544 solaris="yes"
545 make="${MAKE-gmake}"
Paolo Bonzini65eff012021-11-08 22:52:35 +0100546# needed for CMSG_ macros in sys/socket.h
547 QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
548# needed for TIOCWIN* defines in termios.h
549 QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
Stefan Weil89138852016-05-16 15:10:20 +0200550 # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
Paolo Bonzini65eff012021-11-08 22:52:35 +0100551 # Note that this check is broken for cross-compilation: if you're
552 # cross-compiling to one of these OSes then you'll need to specify
553 # the correct CPU with the --cpu option.
Peter Maydellbbea4052012-08-14 15:35:34 +0100554 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
555 cpu="x86_64"
556 fi
Paolo Bonzini65eff012021-11-08 22:52:35 +0100557;;
558haiku)
559 pie="no"
560 QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE -fPIC $QEMU_CFLAGS"
561;;
562linux)
563 linux="yes"
Paolo Bonzini65eff012021-11-08 22:52:35 +0100564 vhost_user=${default_feature:-yes}
565;;
Peter Maydellbbea4052012-08-14 15:35:34 +0100566esac
567
Juan Quintela2ff6b912009-08-03 14:45:55 +0200568if test ! -z "$cpu" ; then
569 # command line argument
570 :
571elif check_define __i386__ ; then
aliguoriac0df512008-12-29 17:14:15 +0000572 cpu="i386"
573elif check_define __x86_64__ ; then
Richard Hendersonc72b26e2013-08-20 12:20:05 -0700574 if check_define __ILP32__ ; then
575 cpu="x32"
576 else
577 cpu="x86_64"
578 fi
blueswir13aa9bd62008-12-31 16:55:26 +0000579elif check_define __sparc__ ; then
blueswir13aa9bd62008-12-31 16:55:26 +0000580 if check_define __arch64__ ; then
581 cpu="sparc64"
582 else
583 cpu="sparc"
584 fi
malcfdf7ed92009-01-14 18:39:52 +0000585elif check_define _ARCH_PPC ; then
586 if check_define _ARCH_PPC64 ; then
Richard Hendersonf8378ac2019-05-01 15:38:18 -0700587 if check_define _LITTLE_ENDIAN ; then
588 cpu="ppc64le"
589 else
590 cpu="ppc64"
591 fi
malcfdf7ed92009-01-14 18:39:52 +0000592 else
593 cpu="ppc"
594 fi
Aurelien Jarnoafa05232009-10-17 14:17:47 +0200595elif check_define __mips__ ; then
596 cpu="mips"
Aurelien Jarnod66ed0e2010-06-13 12:28:21 +0200597elif check_define __s390__ ; then
598 if check_define __s390x__ ; then
599 cpu="s390x"
600 else
601 cpu="s390"
602 fi
Alistair Francisc4f80542018-12-19 19:20:19 +0000603elif check_define __riscv ; then
Richard Hendersonba0e7332021-09-17 11:08:09 -0700604 cpu="riscv"
Peter Maydell21d89f82011-11-30 10:57:48 +0100605elif check_define __arm__ ; then
606 cpu="arm"
Claudio Fontana1f080312013-06-12 16:20:23 +0100607elif check_define __aarch64__ ; then
608 cpu="aarch64"
WANG Xueruidfcf9002021-12-21 13:41:04 +0800609elif check_define __loongarch64 ; then
610 cpu="loongarch64"
aliguoriac0df512008-12-29 17:14:15 +0000611else
Stefan Weil89138852016-05-16 15:10:20 +0200612 cpu=$(uname -m)
aliguoriac0df512008-12-29 17:14:15 +0000613fi
614
Paolo Bonzini823eb012021-11-08 14:18:17 +0100615# Normalise host CPU name, set multilib cflags
Peter Maydell359bc952011-12-24 13:07:25 +0000616# Note that this case should only have supported host CPUs, not guests.
bellard7d132992003-03-06 23:23:54 +0000617case "$cpu" in
Paolo Bonzinie4da0e32021-11-09 09:23:56 +0100618 armv*b|armv*l|arm)
619 cpu="arm" ;;
620
bellard7d132992003-03-06 23:23:54 +0000621 i386|i486|i586|i686|i86pc|BePC)
bellard97a847b2003-08-10 21:36:04 +0000622 cpu="i386"
Paolo Bonzinie4da0e32021-11-09 09:23:56 +0100623 CPU_CFLAGS="-m32" ;;
624 x32)
Paolo Bonzini4da270b2021-11-09 09:36:10 +0100625 cpu="x86_64"
Paolo Bonzinie4da0e32021-11-09 09:23:56 +0100626 CPU_CFLAGS="-mx32" ;;
aurel32aaa5fa12008-04-11 22:04:22 +0000627 x86_64|amd64)
628 cpu="x86_64"
Paolo Bonzinie4da0e32021-11-09 09:23:56 +0100629 # ??? Only extremely old AMD cpus do not have cmpxchg16b.
630 # If we truly care, we should simply detect this case at
631 # runtime and generate the fallback to serial emulation.
632 CPU_CFLAGS="-m64 -mcx16" ;;
633
Aurelien Jarnoafa05232009-10-17 14:17:47 +0200634 mips*)
Paolo Bonzinie4da0e32021-11-09 09:23:56 +0100635 cpu="mips" ;;
636
637 ppc)
638 CPU_CFLAGS="-m32" ;;
639 ppc64)
Miroslav Rezaninaced5cff2022-03-05 07:16:46 +0100640 CPU_CFLAGS="-m64 -mbig-endian" ;;
Paolo Bonzinie4da0e32021-11-09 09:23:56 +0100641 ppc64le)
Paolo Bonzinid8ff8922021-11-09 09:18:20 +0100642 cpu="ppc64"
Miroslav Rezaninaced5cff2022-03-05 07:16:46 +0100643 CPU_CFLAGS="-m64 -mlittle-endian" ;;
Paolo Bonzinie4da0e32021-11-09 09:23:56 +0100644
645 s390)
Paolo Bonzini823eb012021-11-08 14:18:17 +0100646 CPU_CFLAGS="-m31" ;;
Paolo Bonzinie4da0e32021-11-09 09:23:56 +0100647 s390x)
648 CPU_CFLAGS="-m64" ;;
649
blueswir131422552007-04-16 18:27:06 +0000650 sparc|sun4[cdmuv])
bellardae228532003-05-13 18:59:59 +0000651 cpu="sparc"
Paolo Bonzinie4da0e32021-11-09 09:23:56 +0100652 CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc" ;;
653 sparc64)
654 CPU_CFLAGS="-m64 -mcpu=ultrasparc" ;;
bellard7d132992003-03-06 23:23:54 +0000655esac
Juan Quintelae2d52ad2009-08-12 18:20:24 +0200656
Paolo Bonzini0db4a062010-12-23 11:43:49 +0100657: ${make=${MAKE-make}}
Paolo Bonzinib6daf4d2020-09-01 06:38:04 -0400658
Daniel P. Berrangéfaf44142019-03-27 17:07:01 +0000659# We prefer python 3.x. A bare 'python' is traditionally
660# python 2.x, but some distros have it as python 3.x, so
Eduardo Habkostddf90692019-10-16 19:42:37 -0300661# we check that too
Daniel P. Berrangéfaf44142019-03-27 17:07:01 +0000662python=
Marc-André Lureau0a01d762019-08-21 11:21:16 +0400663explicit_python=no
Eduardo Habkostddf90692019-10-16 19:42:37 -0300664for binary in "${PYTHON-python3}" python
Daniel P. Berrangéfaf44142019-03-27 17:07:01 +0000665do
666 if has "$binary"
667 then
Paolo Bonzini95c5f2d2019-06-10 12:03:44 +0200668 python=$(command -v "$binary")
Daniel P. Berrangéfaf44142019-03-27 17:07:01 +0000669 break
670 fi
671done
Markus Armbruster903458c2020-02-14 18:18:41 +0100672
Markus Armbruster903458c2020-02-14 18:18:41 +0100673
Alex Bennée39d87c82020-03-03 15:06:20 +0000674# Check for ancillary tools used in testing
675genisoimage=
Alex Bennée3df437c2020-05-19 09:22:48 -0400676for binary in genisoimage mkisofs
Alex Bennée39d87c82020-03-03 15:06:20 +0000677do
678 if has $binary
679 then
680 genisoimage=$(command -v "$binary")
681 break
682 fi
683done
684
Peter Maydell3c4a4d02012-08-11 22:34:40 +0100685# Default objcc to clang if available, otherwise use CC
686if has clang; then
687 objcc=clang
688else
689 objcc="$cc"
690fi
691
Juan Quintela3457a3f2009-08-03 14:46:07 +0200692if test "$mingw32" = "yes" ; then
Juan Quintela3457a3f2009-08-03 14:46:07 +0200693 EXESUF=".exe"
Stefan Weil78e9d4a2015-11-26 12:13:12 +0100694 # MinGW needs -mthreads for TLS and macro _MT.
Paolo Bonzini5770e8a2020-09-23 05:26:15 -0400695 CONFIGURE_CFLAGS="-mthreads $CONFIGURE_CFLAGS"
John Snow93b25862015-03-25 18:57:37 -0400696 write_c_skeleton;
Paolo Bonzinid17f3052020-08-18 12:17:01 +0200697 prefix="/qemu"
Marc-André Lureau77433a52020-08-26 15:04:12 +0400698 qemu_suffix=""
Juan Quintela3457a3f2009-08-03 14:46:07 +0200699fi
700
Anthony Liguori487fefd2009-06-11 13:28:25 -0500701werror=""
bellard85aa5182007-11-11 20:17:03 +0000702
Paolo Bonzini61d63092021-10-07 15:08:28 +0200703. $source_path/scripts/meson-buildoptions.sh
704
705meson_options=
706meson_option_parse() {
707 meson_options="$meson_options $(_meson_option_parse "$@")"
708 if test $? -eq 1; then
709 echo "ERROR: unknown option $1"
710 echo "Try '$0 --help' for more information"
711 exit 1
712 fi
713}
714
bellard7d132992003-03-06 23:23:54 +0000715for opt do
Stefan Weil89138852016-05-16 15:10:20 +0200716 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
bellard7d132992003-03-06 23:23:54 +0000717 case "$opt" in
bellard2efc3262005-12-18 19:14:49 +0000718 --help|-h) show_help=yes
719 ;;
Mike Frysinger99123e12011-04-07 01:12:28 -0400720 --version|-V) exec cat $source_path/VERSION
721 ;;
pbrookb1a550a2006-04-16 13:28:56 +0000722 --prefix=*) prefix="$optarg"
bellard7d132992003-03-06 23:23:54 +0000723 ;;
pbrookb1a550a2006-04-16 13:28:56 +0000724 --interp-prefix=*) interp_prefix="$optarg"
bellard32ce6332003-04-11 00:16:16 +0000725 ;;
aliguoriac0df512008-12-29 17:14:15 +0000726 --cross-prefix=*)
bellard7d132992003-03-06 23:23:54 +0000727 ;;
aliguoriac0df512008-12-29 17:14:15 +0000728 --cc=*)
bellard7d132992003-03-06 23:23:54 +0000729 ;;
pbrookb1a550a2006-04-16 13:28:56 +0000730 --host-cc=*) host_cc="$optarg"
bellard83469012005-07-23 14:27:54 +0000731 ;;
Tomoki Sekiyama83f73fc2013-08-07 11:39:36 -0400732 --cxx=*)
733 ;;
Michael S. Tsirkine007dbe2013-11-24 11:38:05 +0200734 --iasl=*) iasl="$optarg"
735 ;;
Peter Maydell3c4a4d02012-08-11 22:34:40 +0100736 --objcc=*) objcc="$optarg"
737 ;;
pbrookb1a550a2006-04-16 13:28:56 +0000738 --make=*) make="$optarg"
bellard7d132992003-03-06 23:23:54 +0000739 ;;
Paolo Bonzinib6daf4d2020-09-01 06:38:04 -0400740 --install=*)
pbrook6a882642006-04-17 13:57:12 +0000741 ;;
Marc-André Lureau0a01d762019-08-21 11:21:16 +0400742 --python=*) python="$optarg" ; explicit_python=yes
Blue Swirlc886edf2011-07-22 21:08:09 +0000743 ;;
Peter Maydell2eb054c2020-02-13 17:56:18 +0000744 --sphinx-build=*) sphinx_build="$optarg"
745 ;;
Paolo Bonzinia5665052019-06-10 12:05:14 +0200746 --skip-meson) skip_meson=yes
747 ;;
748 --meson=*) meson="$optarg"
749 ;;
Paolo Bonzini48328882020-08-26 08:04:15 +0200750 --ninja=*) ninja="$optarg"
751 ;;
Brade2d88302011-09-02 16:53:28 -0400752 --smbd=*) smbd="$optarg"
753 ;;
Juan Quintelae2a2ed02009-08-03 14:46:02 +0200754 --extra-cflags=*)
bellard7d132992003-03-06 23:23:54 +0000755 ;;
Bruno Dominguez11cde1c2017-06-06 14:07:47 +0100756 --extra-cxxflags=*)
757 ;;
Philippe Mathieu-Daudée910c7d2022-01-08 22:38:55 +0100758 --extra-objcflags=*)
759 ;;
Juan Quintelae2a2ed02009-08-03 14:46:02 +0200760 --extra-ldflags=*)
bellard7d132992003-03-06 23:23:54 +0000761 ;;
Gerd Hoffmann5bc62e02012-02-08 13:54:13 +0100762 --enable-debug-info)
763 ;;
764 --disable-debug-info)
765 ;;
Alex Bennéed75402b2018-04-04 20:27:05 +0100766 --cross-cc-*)
767 ;;
Fam Zheng17969262014-02-10 14:48:56 +0800768 --enable-modules)
769 modules="yes"
770 ;;
Stefan Hajnoczi3aa88b32015-11-02 14:06:23 +0000771 --disable-modules)
772 modules="no"
773 ;;
Christian Ehrhardtbd83c862020-03-10 15:58:06 +0100774 --disable-module-upgrades) module_upgrades="no"
775 ;;
776 --enable-module-upgrades) module_upgrades="yes"
777 ;;
Juan Quintela2ff6b912009-08-03 14:45:55 +0200778 --cpu=*)
bellard7d132992003-03-06 23:23:54 +0000779 ;;
pbrookb1a550a2006-04-16 13:28:56 +0000780 --target-list=*) target_list="$optarg"
Alex Bennée447e1332019-03-19 11:59:12 +0000781 if test "$target_list_exclude"; then
782 error_exit "Can't mix --target-list with --target-list-exclude"
783 fi
784 ;;
785 --target-list-exclude=*) target_list_exclude="$optarg"
786 if test "$target_list"; then
787 error_exit "Can't mix --target-list-exclude with --target-list"
788 fi
bellardde83cd02003-06-15 20:25:43 +0000789 ;;
Paolo Bonzini74242e02010-12-23 11:44:02 +0100790 --with-trace-file=*) trace_file="$optarg"
Prerna Saxena9410b562010-07-13 09:26:32 +0100791 ;;
Paolo Bonzini7bc3ca72020-11-20 08:38:22 +0100792 --with-default-devices) default_devices="true"
Paolo Bonzinif3494742019-01-23 14:56:17 +0800793 ;;
Paolo Bonzini7bc3ca72020-11-20 08:38:22 +0100794 --without-default-devices) default_devices="false"
Paolo Bonzinif3494742019-01-23 14:56:17 +0800795 ;;
Alex Bennéed1d5e9e2021-07-07 14:17:44 +0100796 --with-devices-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --with-devices-FOO option"
797 ;;
798 --with-devices-*) device_arch=${opt#--with-devices-};
799 device_arch=${device_arch%%=*}
800 cf=$source_path/configs/devices/$device_arch-softmmu/$optarg.mak
801 if test -f "$cf"; then
802 device_archs="$device_archs $device_arch"
803 eval "devices_${device_arch}=\$optarg"
804 else
805 error_exit "File $cf does not exist"
806 fi
807 ;;
Alex Bennéec87ea112020-12-10 19:04:13 +0000808 --without-default-features) # processed above
809 ;;
Blue Swirl1d728c32012-05-01 18:45:39 +0000810 --enable-gcov) gcov="yes"
811 ;;
Loïc Minier79427692010-01-31 12:23:45 +0100812 --static)
813 static="yes"
Sergei Trofimovich17884d72012-01-31 22:03:45 +0300814 QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
bellard43ce4df2003-06-09 19:53:12 +0000815 ;;
Paolo Bonzini0b24e752010-05-26 16:08:26 +0200816 --mandir=*) mandir="$optarg"
817 ;;
818 --bindir=*) bindir="$optarg"
819 ;;
Alon Levy3aa5d2b2011-05-15 12:08:59 +0300820 --libdir=*) libdir="$optarg"
821 ;;
Michael Tokarev8bf188a2012-06-07 01:11:00 +0400822 --libexecdir=*) libexecdir="$optarg"
823 ;;
Alon Levy0f94d6d2011-06-27 11:58:20 +0200824 --includedir=*) includedir="$optarg"
825 ;;
Eduardo Habkost528ae5b2012-04-18 16:55:49 -0300826 --datadir=*) datadir="$optarg"
Paolo Bonzini0b24e752010-05-26 16:08:26 +0200827 ;;
Marc-André Lureau77433a52020-08-26 15:04:12 +0400828 --with-suffix=*) qemu_suffix="$optarg"
Eduardo Habkost023d3d62012-04-18 16:55:50 -0300829 ;;
Bruce Rogersc6502632020-10-15 13:07:42 -0600830 --docdir=*) docdir="$optarg"
Paolo Bonzini0b24e752010-05-26 16:08:26 +0200831 ;;
Paolo Bonzinife0038b2020-10-16 04:35:10 -0400832 --localedir=*) localedir="$optarg"
833 ;;
Andre Przywaraca2fb932010-03-08 14:09:48 +0100834 --sysconfdir=*) sysconfdir="$optarg"
Anthony Liguori07381cc2010-01-21 10:30:29 -0600835 ;;
Luiz Capitulino785c23a2012-10-03 18:35:57 -0300836 --localstatedir=*) local_statedir="$optarg"
837 ;;
Gerd Hoffmann3d5eeca2017-09-14 13:42:36 +0200838 --firmwarepath=*) firmwarepath="$optarg"
839 ;;
Olaf Hering181ce1d2018-04-18 09:50:44 +0200840 --host=*|--build=*|\
841 --disable-dependency-tracking|\
Luiz Capitulino785c23a2012-10-03 18:35:57 -0300842 --sbindir=*|--sharedstatedir=*|\
Paolo Bonzinife0038b2020-10-16 04:35:10 -0400843 --oldincludedir=*|--datarootdir=*|--infodir=*|\
Max Filippov023ddd72011-11-24 16:11:31 +0400844 --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
845 # These switches are silently ignored, for compatibility with
846 # autoconf-generated configure scripts. This allows QEMU's
847 # configure to be used by RPM and similar macros that set
848 # lots of directory switches by default.
849 ;;
malc0c58ac12008-06-25 21:04:05 +0000850 --audio-drv-list=*) audio_drv_list="$optarg"
851 ;;
Stefan Weil89138852016-05-16 15:10:20 +0200852 --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
Fam Zhengb64ec4e2013-05-29 19:35:40 +0800853 ;;
Stefan Weil89138852016-05-16 15:10:20 +0200854 --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
Markus Armbrustereb852012009-10-27 18:41:44 +0100855 ;;
aurel32f8393942009-04-13 18:45:38 +0000856 --enable-debug-tcg) debug_tcg="yes"
857 ;;
858 --disable-debug-tcg) debug_tcg="no"
859 ;;
Paul Brookf3d08ee2009-06-04 11:39:04 +0100860 --enable-debug)
861 # Enable debugging options that aren't excessively noisy
862 debug_tcg="yes"
Paolo Bonzinic55cf6a2021-10-13 11:46:09 +0200863 meson_option_parse --enable-debug-mutex ""
Paul Brookf3d08ee2009-06-04 11:39:04 +0100864 debug="yes"
John Snowb553a042015-11-03 15:43:42 -0500865 fortify_source="no"
Paul Brookf3d08ee2009-06-04 11:39:04 +0100866 ;;
Marc-André Lureau247724c2018-01-16 16:11:51 +0100867 --enable-sanitizers) sanitizers="yes"
868 ;;
869 --disable-sanitizers) sanitizers="no"
870 ;;
Lingfeng Yang0aebab02020-06-12 20:02:23 +0100871 --enable-tsan) tsan="yes"
872 ;;
873 --disable-tsan) tsan="no"
874 ;;
Paolo Bonzini4d34a862020-10-05 11:31:15 +0200875 --disable-slirp) slirp="disabled"
bellard1d14ffa2005-10-30 18:58:22 +0000876 ;;
Paolo Bonzinifd6fc212020-11-20 11:19:38 +0100877 --enable-slirp) slirp="enabled"
878 ;;
Paolo Bonzini4d34a862020-10-05 11:31:15 +0200879 --enable-slirp=git) slirp="internal"
Marc-André Lureau7c57bdd82019-04-24 13:00:41 +0200880 ;;
Paolo Bonzini03a3c0b2021-10-07 15:08:27 +0200881 --enable-slirp=*) slirp="$optarg"
Marc-André Lureau675b9b52019-02-12 17:25:23 +0100882 ;;
Paolo Bonzini1badb702020-09-18 04:57:25 -0400883 --disable-xen) xen="disabled"
aliguorie37630c2009-04-22 15:19:10 +0000884 ;;
Paolo Bonzini1badb702020-09-18 04:57:25 -0400885 --enable-xen) xen="enabled"
Juan Quintelafc321b42009-08-12 18:29:55 +0200886 ;;
Paolo Bonzini1badb702020-09-18 04:57:25 -0400887 --disable-tcg) tcg="disabled"
Alex Bennéed1a14252021-07-09 15:29:54 +0100888 plugins="no"
Paolo Bonzinib3f6ea72017-07-03 16:59:07 +0200889 ;;
Paolo Bonzini1badb702020-09-18 04:57:25 -0400890 --enable-tcg) tcg="enabled"
Paolo Bonzinib3f6ea72017-07-03 16:59:07 +0200891 ;;
pbrookcad25d62006-03-19 16:31:11 +0000892 --disable-system) softmmu="no"
pbrook0a8e90f2006-03-19 14:54:16 +0000893 ;;
pbrookcad25d62006-03-19 16:31:11 +0000894 --enable-system) softmmu="yes"
pbrook0a8e90f2006-03-19 14:54:16 +0000895 ;;
Zachary Amsden0953a802009-07-30 00:14:59 -1000896 --disable-user)
897 linux_user="no" ;
898 bsd_user="no" ;
Zachary Amsden0953a802009-07-30 00:14:59 -1000899 ;;
900 --enable-user) ;;
ths831b7822007-01-18 20:06:33 +0000901 --disable-linux-user) linux_user="no"
pbrook0a8e90f2006-03-19 14:54:16 +0000902 ;;
ths831b7822007-01-18 20:06:33 +0000903 --enable-linux-user) linux_user="yes"
904 ;;
blueswir184778502008-10-26 20:33:16 +0000905 --disable-bsd-user) bsd_user="no"
906 ;;
907 --enable-bsd-user) bsd_user="yes"
908 ;;
Avi Kivity40d64442011-11-15 20:12:17 +0200909 --enable-pie) pie="yes"
Kirill A. Shutemov34005a02009-09-12 02:17:55 +0300910 ;;
Avi Kivity40d64442011-11-15 20:12:17 +0200911 --disable-pie) pie="no"
Kirill A. Shutemov34005a02009-09-12 02:17:55 +0300912 ;;
bellard85aa5182007-11-11 20:17:03 +0000913 --enable-werror) werror="yes"
914 ;;
915 --disable-werror) werror="no"
916 ;;
Daniele Buonocdad7812020-12-04 18:06:11 -0500917 --enable-lto) lto="true"
918 ;;
919 --disable-lto) lto="false"
920 ;;
Steven Noonan63678e12014-03-28 17:19:02 +0100921 --enable-stack-protector) stack_protector="yes"
922 ;;
923 --disable-stack-protector) stack_protector="no"
924 ;;
Daniele Buono1e4f6062020-05-29 16:51:21 -0400925 --enable-safe-stack) safe_stack="yes"
926 ;;
927 --disable-safe-stack) safe_stack="no"
928 ;;
Daniele Buono9e62ba42020-12-04 18:06:14 -0500929 --enable-cfi)
930 cfi="true";
931 lto="true";
932 ;;
933 --disable-cfi) cfi="false"
934 ;;
Paolo Bonzinifbb41212020-10-05 11:31:15 +0200935 --disable-fdt) fdt="disabled"
Juan Quintela2df87df2009-08-12 18:29:54 +0200936 ;;
Paolo Bonzinifbb41212020-10-05 11:31:15 +0200937 --enable-fdt) fdt="enabled"
938 ;;
939 --enable-fdt=git) fdt="internal"
940 ;;
Paolo Bonzini03a3c0b2021-10-07 15:08:27 +0200941 --enable-fdt=*) fdt="$optarg"
Juan Quintela2df87df2009-08-12 18:29:54 +0200942 ;;
Thomas Huth7e563bf2018-02-15 12:06:47 +0100943 --with-pkgversion=*) pkgversion="$optarg"
pbrook4a19f1e2009-04-07 23:17:49 +0000944 ;;
Alex Barcelo519175a2012-02-28 12:25:50 +0100945 --with-coroutine=*) coroutine="$optarg"
946 ;;
Michael S. Tsirkind5970052010-03-17 13:08:17 +0200947 --disable-vhost-net) vhost_net="no"
948 ;;
949 --enable-vhost-net) vhost_net="yes"
950 ;;
Gonglei042cea22018-03-01 21:46:28 +0800951 --disable-vhost-crypto) vhost_crypto="no"
952 ;;
Paolo Bonzini299e6f12019-02-14 18:35:53 +0100953 --enable-vhost-crypto) vhost_crypto="yes"
Gonglei042cea22018-03-01 21:46:28 +0800954 ;;
Nicholas Bellinger5e9be922013-03-29 01:08:16 +0000955 --disable-vhost-scsi) vhost_scsi="no"
956 ;;
957 --enable-vhost-scsi) vhost_scsi="yes"
958 ;;
Stefan Hajnoczifc0b9b02016-08-16 13:27:22 +0100959 --disable-vhost-vsock) vhost_vsock="no"
960 ;;
961 --enable-vhost-vsock) vhost_vsock="yes"
962 ;;
Dr. David Alan Gilbert98fc1ad2019-09-30 11:51:34 +0100963 --disable-vhost-user-fs) vhost_user_fs="no"
964 ;;
965 --enable-vhost-user-fs) vhost_user_fs="yes"
966 ;;
Gerd Hoffmannda076ff2014-11-20 09:49:44 +0100967 --disable-opengl) opengl="no"
Michael Walle20ff0752011-03-07 23:32:39 +0100968 ;;
Gerd Hoffmannda076ff2014-11-20 09:49:44 +0100969 --enable-opengl) opengl="yes"
Michael Walle20ff0752011-03-07 23:32:39 +0100970 ;;
Paolo Bonzini1ffb3bb2020-08-28 19:33:54 +0200971 --disable-zlib-test)
Alon Levy1ece9902011-07-26 12:30:40 +0300972 ;;
Fam Zheng52b53c02014-09-10 14:17:51 +0800973 --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
974 echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
Stefan Hajnoczi583f6e72012-11-14 15:04:15 +0100975 ;;
Fam Zhengcb6414d2016-09-21 12:27:16 +0800976 --enable-vhdx|--disable-vhdx)
977 echo "$0: $opt is obsolete, VHDX driver is always built" >&2
978 ;;
Fam Zheng315d3182016-09-21 12:27:21 +0800979 --enable-uuid|--disable-uuid)
980 echo "$0: $opt is obsolete, UUID support is always built" >&2
981 ;;
Daniel P. Berrangea1c5e942016-06-06 10:05:06 +0100982 --tls-priority=*) tls_priority="$optarg"
983 ;;
Michael R. Hines2da776d2013-07-22 10:01:54 -0400984 --enable-rdma) rdma="yes"
985 ;;
986 --disable-rdma) rdma="no"
987 ;;
Marcel Apfelbaum21ab34c2018-08-16 18:16:37 +0300988 --enable-pvrdma) pvrdma="yes"
989 ;;
990 --disable-pvrdma) pvrdma="no"
991 ;;
Marc-André Lureaue6a74862017-08-03 11:07:46 +0200992 --disable-vhost-user) vhost_user="no"
993 ;;
Paolo Bonzini299e6f12019-02-14 18:35:53 +0100994 --enable-vhost-user) vhost_user="yes"
995 ;;
Cindy Lu108a6482020-07-01 22:55:37 +0800996 --disable-vhost-vdpa) vhost_vdpa="no"
997 ;;
998 --enable-vhost-vdpa) vhost_vdpa="yes"
999 ;;
Paolo Bonzini299e6f12019-02-14 18:35:53 +01001000 --disable-vhost-kernel) vhost_kernel="no"
1001 ;;
1002 --enable-vhost-kernel) vhost_kernel="yes"
Marc-André Lureaue6a74862017-08-03 11:07:46 +02001003 ;;
Richard Henderson8b18cdb2020-09-13 12:19:25 -07001004 --disable-capstone) capstone="disabled"
Richard Henderson8ca80762017-09-14 09:41:12 -07001005 ;;
Richard Henderson8b18cdb2020-09-13 12:19:25 -07001006 --enable-capstone) capstone="enabled"
Richard Henderson8ca80762017-09-14 09:41:12 -07001007 ;;
Richard Henderson8b18cdb2020-09-13 12:19:25 -07001008 --enable-capstone=git) capstone="internal"
Richard Hendersone219c492017-09-28 09:01:23 -07001009 ;;
Paolo Bonzini03a3c0b2021-10-07 15:08:27 +02001010 --enable-capstone=*) capstone="$optarg"
Richard Hendersone219c492017-09-28 09:01:23 -07001011 ;;
Daniel P. Berrangecc84d632017-10-20 15:02:43 +01001012 --with-git=*) git="$optarg"
1013 ;;
Dan Streetman7d7dbf92021-01-19 12:20:46 -05001014 --with-git-submodules=*)
1015 git_submodules_action="$optarg"
Daniel P. Berrangef62bbee2017-10-26 13:52:26 +01001016 ;;
Alex Bennée9b8e4292021-07-09 15:29:56 +01001017 --enable-plugins) if test "$mingw32" = "yes"; then
1018 error_exit "TCG plugins not currently supported on Windows platforms"
1019 else
1020 plugins="yes"
1021 fi
Alex Bennée40e8c6f2019-06-13 14:52:25 +01001022 ;;
1023 --disable-plugins) plugins="no"
1024 ;;
Alex Bennéeafc3a8f2019-11-28 16:35:24 +01001025 --enable-containers) use_containers="yes"
1026 ;;
1027 --disable-containers) use_containers="no"
1028 ;;
Alex Bennéef48e5902020-03-16 17:21:48 +00001029 --gdb=*) gdb_bin="$optarg"
1030 ;;
Alexey Krasikov54e7aac2020-05-25 14:19:12 +03001031 --enable-keyring) secret_keyring="yes"
1032 ;;
1033 --disable-keyring) secret_keyring="no"
1034 ;;
Denis Plotnikov20cf7b82021-03-12 18:14:40 +03001035 --enable-gio) gio=yes
1036 ;;
1037 --disable-gio) gio=no
1038 ;;
Paolo Bonzini3b4da132021-10-07 15:08:29 +02001039 # backwards compatibility options
1040 --enable-trace-backend=*) meson_option_parse "--enable-trace-backends=$optarg" "$optarg"
1041 ;;
1042 --disable-blobs) meson_option_parse --disable-install-blobs ""
1043 ;;
1044 --enable-tcmalloc) meson_option_parse --enable-malloc=tcmalloc tcmalloc
1045 ;;
1046 --enable-jemalloc) meson_option_parse --enable-malloc=jemalloc jemalloc
1047 ;;
1048 # everything else has the same name in configure and meson
Paolo Bonzini61d63092021-10-07 15:08:28 +02001049 --enable-* | --disable-*) meson_option_parse "$opt" "$optarg"
1050 ;;
Fam Zheng2d2ad6d2014-04-18 14:55:36 +08001051 *)
1052 echo "ERROR: unknown option $opt"
1053 echo "Try '$0 --help' for more information"
1054 exit 1
balrog7f1559c2007-11-17 10:24:32 +00001055 ;;
bellard7d132992003-03-06 23:23:54 +00001056 esac
1057done
1058
Alex Bennéed1a14252021-07-09 15:29:54 +01001059# test for any invalid configuration combinations
1060if test "$plugins" = "yes" -a "$tcg" = "disabled"; then
1061 error_exit "Can't enable plugins on non-TCG builds"
1062fi
1063
Dan Streetman7d7dbf92021-01-19 12:20:46 -05001064case $git_submodules_action in
1065 update|validate)
1066 if test ! -e "$source_path/.git"; then
1067 echo "ERROR: cannot $git_submodules_action git submodules without .git"
1068 exit 1
1069 fi
1070 ;;
1071 ignore)
Paolo Bonzinib80fd282021-05-12 09:18:55 +02001072 if ! test -f "$source_path/ui/keycodemapdb/README"
1073 then
1074 echo
1075 echo "ERROR: missing GIT submodules"
1076 echo
1077 if test -e "$source_path/.git"; then
1078 echo "--with-git-submodules=ignore specified but submodules were not"
1079 echo "checked out. Please initialize and update submodules."
1080 else
1081 echo "This is not a GIT checkout but module content appears to"
1082 echo "be missing. Do not use 'git archive' or GitHub download links"
1083 echo "to acquire QEMU source archives. Non-GIT builds are only"
1084 echo "supported with source archives linked from:"
1085 echo
1086 echo " https://www.qemu.org/download/#source"
1087 echo
1088 echo "Developers working with GIT can use scripts/archive-source.sh"
1089 echo "if they need to create valid source archives."
1090 fi
1091 echo
1092 exit 1
1093 fi
Dan Streetman7d7dbf92021-01-19 12:20:46 -05001094 ;;
1095 *)
1096 echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'"
1097 exit 1
1098 ;;
1099esac
1100
Marc-André Lureau22a87802019-07-11 19:13:39 +04001101libdir="${libdir:-$prefix/lib}"
1102libexecdir="${libexecdir:-$prefix/libexec}"
1103includedir="${includedir:-$prefix/include}"
1104
1105if test "$mingw32" = "yes" ; then
Joshua Watt15588a62021-01-12 15:02:39 -06001106 bindir="${bindir:-$prefix}"
Marc-André Lureau22a87802019-07-11 19:13:39 +04001107else
Marc-André Lureau22a87802019-07-11 19:13:39 +04001108 bindir="${bindir:-$prefix/bin}"
Marc-André Lureau22a87802019-07-11 19:13:39 +04001109fi
Joshua Watt15588a62021-01-12 15:02:39 -06001110mandir="${mandir:-$prefix/share/man}"
1111datadir="${datadir:-$prefix/share}"
1112docdir="${docdir:-$prefix/share/doc}"
1113sysconfdir="${sysconfdir:-$prefix/etc}"
1114local_statedir="${local_statedir:-$prefix/var}"
Paolo Bonzini16bf7a32020-10-16 03:19:14 -04001115firmwarepath="${firmwarepath:-$datadir/qemu-firmware}"
1116localedir="${localedir:-$datadir/locale}"
Marc-André Lureau22a87802019-07-11 19:13:39 +04001117
Alex Bennée9557af92021-09-17 17:23:22 +01001118if eval test -z "\${cross_cc_$cpu}"; then
1119 eval "cross_cc_${cpu}=\$cc"
1120 cross_cc_vars="$cross_cc_vars cross_cc_${cpu}"
1121fi
Peter Crosthwaite79f3b122013-04-18 14:46:14 +10001122
Peter Maydell60e0df22011-05-03 14:50:13 +01001123default_target_list=""
Peter Maydell6e92f822013-05-20 16:16:15 +01001124mak_wilds=""
1125
Paolo Bonzinib915a2f2021-11-09 10:10:41 +01001126if [ "$linux_user" != no ]; then
1127 if [ "$targetos" = linux ] && [ -d $source_path/linux-user/include/host/$cpu ]; then
1128 linux_user=yes
1129 elif [ "$linux_user" = yes ]; then
1130 error_exit "linux-user not supported on this architecture"
1131 fi
1132fi
1133if [ "$bsd_user" != no ]; then
1134 if [ "$bsd_user" = "" ]; then
1135 test $targetos = freebsd && bsd_user=yes
1136 fi
1137 if [ "$bsd_user" = yes ] && ! [ -d $source_path/bsd-user/$targetos ]; then
1138 error_exit "bsd-user not supported on this host OS"
1139 fi
1140fi
Peter Maydell6e92f822013-05-20 16:16:15 +01001141if [ "$softmmu" = "yes" ]; then
Alex Bennée812b31d2021-07-07 14:17:43 +01001142 mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak"
Peter Maydell60e0df22011-05-03 14:50:13 +01001143fi
Peter Maydell6e92f822013-05-20 16:16:15 +01001144if [ "$linux_user" = "yes" ]; then
Alex Bennée812b31d2021-07-07 14:17:43 +01001145 mak_wilds="${mak_wilds} $source_path/configs/targets/*-linux-user.mak"
Peter Maydell60e0df22011-05-03 14:50:13 +01001146fi
Peter Maydell6e92f822013-05-20 16:16:15 +01001147if [ "$bsd_user" = "yes" ]; then
Alex Bennée812b31d2021-07-07 14:17:43 +01001148 mak_wilds="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak"
Peter Maydell60e0df22011-05-03 14:50:13 +01001149fi
1150
Alex Bennée2d838d92020-09-09 12:27:37 +01001151for config in $mak_wilds; do
1152 target="$(basename "$config" .mak)"
Alex Bennée98db9a02020-09-15 14:43:14 +01001153 if echo "$target_list_exclude" | grep -vq "$target"; then
Alex Bennée2d838d92020-09-09 12:27:37 +01001154 default_target_list="${default_target_list} $target"
1155 fi
1156done
Peter Maydell6e92f822013-05-20 16:16:15 +01001157
pbrookaf5db582006-04-08 14:26:41 +00001158if test x"$show_help" = x"yes" ; then
1159cat << EOF
1160
1161Usage: configure [options]
1162Options: [defaults in brackets after descriptions]
1163
Stefan Weil08fb77e2013-12-18 22:09:39 +01001164Standard options:
1165 --help print this message
1166 --prefix=PREFIX install in PREFIX [$prefix]
1167 --interp-prefix=PREFIX where to find shared libraries, etc.
1168 use %M for cpu name [$interp_prefix]
Thomas Huth74154d72022-01-12 11:27:22 +00001169 --target-list=LIST set target list (default: build all)
Stefan Weil08fb77e2013-12-18 22:09:39 +01001170$(echo Available targets: $default_target_list | \
1171 fold -s -w 53 | sed -e 's/^/ /')
Alex Bennée447e1332019-03-19 11:59:12 +00001172 --target-list-exclude=LIST exclude a set of targets from the default target-list
Stefan Weil08fb77e2013-12-18 22:09:39 +01001173
1174Advanced options (experts only):
Joelle van Dyne3812c0c2021-01-25 17:24:48 -08001175 --cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix]
Stefan Weil08fb77e2013-12-18 22:09:39 +01001176 --cc=CC use C compiler CC [$cc]
1177 --iasl=IASL use ACPI compiler IASL [$iasl]
1178 --host-cc=CC use C compiler CC [$host_cc] for code run at
1179 build time
1180 --cxx=CXX use C++ compiler CXX [$cxx]
1181 --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
Paolo Bonzinia2866662021-11-05 10:09:26 +01001182 --extra-cflags=CFLAGS append extra C compiler flags CFLAGS
1183 --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS
Philippe Mathieu-Daudée910c7d2022-01-08 22:38:55 +01001184 --extra-objcflags=OBJCFLAGS append extra Objective C compiler flags OBJCFLAGS
Stefan Weil08fb77e2013-12-18 22:09:39 +01001185 --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS
Alex Bennéed75402b2018-04-04 20:27:05 +01001186 --cross-cc-ARCH=CC use compiler when building ARCH guest test cases
Matheus Ferst479ca4c2022-01-20 14:31:41 -03001187 --cross-cc-cflags-ARCH= use compiler flags when building ARCH guest tests
Stefan Weil08fb77e2013-12-18 22:09:39 +01001188 --make=MAKE use specified make [$make]
Stefan Weil08fb77e2013-12-18 22:09:39 +01001189 --python=PYTHON use specified python [$python]
Peter Maydell2eb054c2020-02-13 17:56:18 +00001190 --sphinx-build=SPHINX use specified sphinx-build [$sphinx_build]
Paolo Bonzinia5665052019-06-10 12:05:14 +02001191 --meson=MESON use specified meson [$meson]
Paolo Bonzini48328882020-08-26 08:04:15 +02001192 --ninja=NINJA use specified ninja [$ninja]
Stefan Weil08fb77e2013-12-18 22:09:39 +01001193 --smbd=SMBD use specified smbd [$smbd]
Thomas Huthdb1b5f12018-03-27 17:09:30 +02001194 --with-git=GIT use specified git [$git]
Dan Streetman7d7dbf92021-01-19 12:20:46 -05001195 --with-git-submodules=update update git submodules (default if .git dir exists)
1196 --with-git-submodules=validate fail if git submodules are not up to date
1197 --with-git-submodules=ignore do not update or check git submodules (default if no .git dir)
Stefan Weil08fb77e2013-12-18 22:09:39 +01001198 --static enable static build [$static]
1199 --mandir=PATH install man pages in PATH
Marc-André Lureau10ff82d2020-08-26 15:04:13 +04001200 --datadir=PATH install firmware in PATH/$qemu_suffix
Paolo Bonzinife0038b2020-10-16 04:35:10 -04001201 --localedir=PATH install translation in PATH/$qemu_suffix
Marc-André Lureau10ff82d2020-08-26 15:04:13 +04001202 --docdir=PATH install documentation in PATH/$qemu_suffix
Stefan Weil08fb77e2013-12-18 22:09:39 +01001203 --bindir=PATH install binaries in PATH
1204 --libdir=PATH install libraries in PATH
Thomas Huthdb1b5f12018-03-27 17:09:30 +02001205 --libexecdir=PATH install helper binaries in PATH
Marc-André Lureau10ff82d2020-08-26 15:04:13 +04001206 --sysconfdir=PATH install config in PATH/$qemu_suffix
Stefan Weil08fb77e2013-12-18 22:09:39 +01001207 --localstatedir=PATH install local state in PATH (set at runtime on win32)
Gerd Hoffmann3d5eeca2017-09-14 13:42:36 +02001208 --firmwarepath=PATH search PATH for firmware files
Robert Foley13336602020-07-01 14:56:21 +01001209 --efi-aarch64=PATH PATH of efi file to use for aarch64 VMs.
Marc-André Lureauca8c0902020-08-26 15:04:14 +04001210 --with-suffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix]
Thomas Huthdb1b5f12018-03-27 17:09:30 +02001211 --with-pkgversion=VERS use specified string as sub-version of the package
Paolo Bonzinic035c8d2020-12-14 11:34:47 +01001212 --without-default-features default all --enable-* options to "disabled"
1213 --without-default-devices do not include any device that is not needed to
1214 start the emulator (only use if you are including
Alex Bennéed1d5e9e2021-07-07 14:17:44 +01001215 desired devices in configs/devices/)
1216 --with-devices-ARCH=NAME override default configs/devices
Stefan Weil08fb77e2013-12-18 22:09:39 +01001217 --enable-debug enable common debug build options
Marc-André Lureau247724c2018-01-16 16:11:51 +01001218 --enable-sanitizers enable default sanitizers
Lingfeng Yang0aebab02020-06-12 20:02:23 +01001219 --enable-tsan enable thread sanitizer
Stefan Weil08fb77e2013-12-18 22:09:39 +01001220 --disable-werror disable compilation abort on warning
Steven Noonan63678e12014-03-28 17:19:02 +01001221 --disable-stack-protector disable compiler-provided stack protection
Paolo Bonzini16bfbc72021-11-02 14:56:22 +01001222 --audio-drv-list=LIST set audio drivers to try if -audiodev is not used
Stefan Weil08fb77e2013-12-18 22:09:39 +01001223 --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L
1224 --block-drv-rw-whitelist=L
1225 set block driver read-write whitelist
Kevin Wolfe5f05f82021-07-09 18:41:41 +02001226 (by default affects only QEMU, not tools like qemu-img)
Stefan Weil08fb77e2013-12-18 22:09:39 +01001227 --block-drv-ro-whitelist=L
1228 set block driver read-only whitelist
Kevin Wolfe5f05f82021-07-09 18:41:41 +02001229 (by default affects only QEMU, not tools like qemu-img)
Stefan Weil08fb77e2013-12-18 22:09:39 +01001230 --with-trace-file=NAME Full PATH,NAME of file to store traces
1231 Default:trace-<pid>
Michael Tokarevc23f23b2015-06-17 22:19:26 +03001232 --cpu=CPU Build for host CPU [$cpu]
Stefan Weil08fb77e2013-12-18 22:09:39 +01001233 --with-coroutine=BACKEND coroutine backend. Supported options:
Daniel P. Berrange33c53c52017-04-28 13:24:44 +01001234 ucontext, sigaltstack, windows
Stefan Weil08fb77e2013-12-18 22:09:39 +01001235 --enable-gcov enable test coverage analysis with gcov
Daniel P. Berrangea1c5e942016-06-06 10:05:06 +01001236 --tls-priority default TLS protocol/cipher priority string
Alex Bennée40e8c6f2019-06-13 14:52:25 +01001237 --enable-plugins
1238 enable plugins via shared library loading
Alex Bennéeafc3a8f2019-11-28 16:35:24 +01001239 --disable-containers don't use containers for cross-building
Alex Bennéef48e5902020-03-16 17:21:48 +00001240 --gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin]
Paolo Bonzini61d63092021-10-07 15:08:28 +02001241EOF
1242 meson_options_help
1243cat << EOF
Michael Tokarevc23f23b2015-06-17 22:19:26 +03001244 system all system emulation targets
1245 user supported user emulation targets
1246 linux-user all linux usermode emulation targets
1247 bsd-user all BSD usermode emulation targets
Michael Tokarevc23f23b2015-06-17 22:19:26 +03001248 pie Position Independent Executables
Marc-André Lureau21e709a2019-07-18 16:04:13 +04001249 modules modules support (non-Windows)
Christian Ehrhardtbd83c862020-03-10 15:58:06 +01001250 module-upgrades try to load modules from alternate paths for upgrades
Michael Tokarevc23f23b2015-06-17 22:19:26 +03001251 debug-tcg TCG debugging (default is disabled)
1252 debug-info debugging information
Daniele Buonocdad7812020-12-04 18:06:11 -05001253 lto Enable Link-Time Optimization.
Daniele Buono1e4f6062020-05-29 16:51:21 -04001254 safe-stack SafeStack Stack Smash Protection. Depends on
1255 clang/llvm >= 3.7 and requires coroutine backend ucontext.
Marcel Apfelbaum21ab34c2018-08-16 18:16:37 +03001256 rdma Enable RDMA-based migration
1257 pvrdma Enable PVRDMA support
Paolo Bonzini299e6f12019-02-14 18:35:53 +01001258 vhost-net vhost-net kernel acceleration support
1259 vhost-vsock virtio sockets device support
1260 vhost-scsi vhost-scsi kernel target support
1261 vhost-crypto vhost-user-crypto backend support
1262 vhost-kernel vhost kernel backend support
1263 vhost-user vhost-user backend support
Cindy Lu108a6482020-07-01 22:55:37 +08001264 vhost-vdpa vhost-vdpa kernel backend support
Lin Mac12d66a2017-03-10 18:14:05 +08001265 opengl opengl support
Denis Plotnikov20cf7b82021-03-12 18:14:40 +03001266 gio libgio support
Stefan Weil08fb77e2013-12-18 22:09:39 +01001267
1268NOTE: The object files are built at the place where configure is launched
pbrookaf5db582006-04-08 14:26:41 +00001269EOF
Fam Zheng2d2ad6d2014-04-18 14:55:36 +08001270exit 0
pbrookaf5db582006-04-08 14:26:41 +00001271fi
1272
Thomas Huth9c790242019-03-11 11:20:34 +01001273# Remove old dependency files to make sure that they get properly regenerated
Thomas Huthbb768f72019-05-10 10:11:59 +02001274rm -f */config-devices.mak.d
Thomas Huth9c790242019-03-11 11:20:34 +01001275
Daniel P. Berrangéfaf44142019-03-27 17:07:01 +00001276if test -z "$python"
1277then
1278 error_exit "Python not found. Use --python=/path/to/python"
Stefan Hajnoczic53eeaf2017-03-28 14:44:18 +01001279fi
Roman Bolshakov8e2c76b2020-08-25 23:27:55 +03001280if ! has "$make"
1281then
1282 error_exit "GNU make ($make) not found"
1283fi
Stefan Hajnoczic53eeaf2017-03-28 14:44:18 +01001284
1285# Note that if the Python conditional here evaluates True we will exit
1286# with status 1 which is a shell 'false' value.
Thomas Huth1b11f282020-09-25 16:40:27 +01001287if ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then
1288 error_exit "Cannot use '$python', Python >= 3.6 is required." \
Stefan Hajnoczic53eeaf2017-03-28 14:44:18 +01001289 "Use --python=/path/to/python to specify a supported Python."
1290fi
1291
Cleber Rosa755ee702018-11-09 10:07:07 -05001292# Preserve python version since some functionality is dependent on it
Cleber Rosa406ab2f2019-08-26 11:58:32 -04001293python_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 -05001294
Stefan Hajnoczic53eeaf2017-03-28 14:44:18 +01001295# Suppress writing compiled files
1296python="$python -B"
1297
Marc-André Lureau0a01d762019-08-21 11:21:16 +04001298if test -z "$meson"; then
Paolo Bonzini6638cae2021-10-27 15:18:48 +02001299 if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.59.3; then
Marc-André Lureau0a01d762019-08-21 11:21:16 +04001300 meson=meson
Dan Streetman7d7dbf92021-01-19 12:20:46 -05001301 elif test $git_submodules_action != 'ignore' ; then
Marc-André Lureau0a01d762019-08-21 11:21:16 +04001302 meson=git
1303 elif test -e "${source_path}/meson/meson.py" ; then
1304 meson=internal
1305 else
1306 if test "$explicit_python" = yes; then
1307 error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found."
1308 else
1309 error_exit "Meson not found. Use --meson=/path/to/meson"
1310 fi
1311 fi
1312else
1313 # Meson uses its own Python interpreter to invoke other Python scripts,
1314 # but the user wants to use the one they specified with --python.
1315 #
1316 # We do not want to override the distro Python interpreter (and sometimes
1317 # cannot: for example in Homebrew /usr/bin/meson is a bash script), so
1318 # just require --meson=git|internal together with --python.
1319 if test "$explicit_python" = yes; then
1320 case "$meson" in
1321 git | internal) ;;
1322 *) error_exit "--python requires using QEMU's embedded Meson distribution." ;;
1323 esac
1324 fi
Paolo Bonzinia5665052019-06-10 12:05:14 +02001325fi
Paolo Bonzinia5665052019-06-10 12:05:14 +02001326
Marc-André Lureau0a01d762019-08-21 11:21:16 +04001327if test "$meson" = git; then
1328 git_submodules="${git_submodules} meson"
Paolo Bonzinia5665052019-06-10 12:05:14 +02001329fi
Marc-André Lureau0a01d762019-08-21 11:21:16 +04001330
1331case "$meson" in
1332 git | internal)
Marc-André Lureau0a01d762019-08-21 11:21:16 +04001333 meson="$python ${source_path}/meson/meson.py"
1334 ;;
Paolo Bonzini84ec0c22020-09-04 10:00:26 -04001335 *) meson=$(command -v "$meson") ;;
Marc-André Lureau0a01d762019-08-21 11:21:16 +04001336esac
1337
Paolo Bonzini09e93322020-08-13 09:28:11 -04001338# Probe for ninja
Paolo Bonzini48328882020-08-26 08:04:15 +02001339
1340if test -z "$ninja"; then
1341 for c in ninja ninja-build samu; do
1342 if has $c; then
1343 ninja=$(command -v "$c")
1344 break
1345 fi
1346 done
Paolo Bonzini09e93322020-08-13 09:28:11 -04001347 if test -z "$ninja"; then
1348 error_exit "Cannot find Ninja"
1349 fi
Paolo Bonzini48328882020-08-26 08:04:15 +02001350fi
Paolo Bonzinia5665052019-06-10 12:05:14 +02001351
Daniel Henrique Barboza9aae6e52017-11-02 07:09:06 -02001352# Check that the C compiler works. Doing this here before testing
1353# the host CPU ensures that we had a valid CC to autodetect the
1354# $cpu var (and we should bail right here if that's not the case).
1355# It also allows the help message to be printed without a CC.
1356write_c_skeleton;
1357if compile_object ; then
1358 : C compiler works ok
1359else
1360 error_exit "\"$cc\" either does not exist or does not work"
1361fi
1362if ! compile_prog ; then
1363 error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
1364fi
1365
Peter Maydell9c83ffd2014-02-25 18:27:49 +00001366# Consult white-list to determine whether to enable werror
1367# by default. Only enable by default for git builds
Peter Maydell9c83ffd2014-02-25 18:27:49 +00001368if test -z "$werror" ; then
Dan Streetman7d7dbf92021-01-19 12:20:46 -05001369 if test "$git_submodules_action" != "ignore" && \
Eric Blakee633a5c2019-02-04 20:39:37 -06001370 { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
Peter Maydell9c83ffd2014-02-25 18:27:49 +00001371 werror="yes"
1372 else
1373 werror="no"
1374 fi
1375fi
1376
Paolo Bonzini975ff032020-11-20 10:34:10 +01001377if test "$targetos" = "bogus"; then
Peter Maydellfb59dab2017-03-28 14:01:52 +01001378 # Now that we know that we're not printing the help and that
1379 # the compiler works (so the results of the check_defines we used
1380 # to identify the OS are reliable), if we didn't recognize the
1381 # host OS we should stop now.
Peter Maydell951fedf2017-07-13 16:15:32 +01001382 error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
Peter Maydellfb59dab2017-03-28 14:01:52 +01001383fi
1384
Thomas Huthefc6c072018-12-03 10:12:32 +01001385# Check whether the compiler matches our minimum requirements:
1386cat > $TMPC << EOF
1387#if defined(__clang_major__) && defined(__clang_minor__)
1388# ifdef __apple_build_version__
Daniel P. Berrangé2a85a082021-05-14 13:04:15 +01001389# if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0)
1390# error You need at least XCode Clang v10.0 to compile QEMU
Thomas Huthefc6c072018-12-03 10:12:32 +01001391# endif
1392# else
Daniel P. Berrangé2a85a082021-05-14 13:04:15 +01001393# if __clang_major__ < 6 || (__clang_major__ == 6 && __clang_minor__ < 0)
1394# error You need at least Clang v6.0 to compile QEMU
Thomas Huthefc6c072018-12-03 10:12:32 +01001395# endif
1396# endif
1397#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
nia3830df52021-10-01 15:30:03 +00001398# if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4)
1399# error You need at least GCC v7.4.0 to compile QEMU
Thomas Huthefc6c072018-12-03 10:12:32 +01001400# endif
1401#else
1402# error You either need GCC or Clang to compiler QEMU
1403#endif
1404int main (void) { return 0; }
1405EOF
1406if ! compile_prog "" "" ; then
nia3830df52021-10-01 15:30:03 +00001407 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 +01001408fi
1409
Richard Henderson00849b92020-06-17 13:13:06 -07001410# Accumulate -Wfoo and -Wno-bar separately.
1411# We will list all of the enable flags first, and the disable flags second.
1412# Note that we do not add -Werror, because that would enable it for all
1413# configure tests. If a configure test failed due to -Werror this would
1414# just silently disable some features, so it's too error prone.
1415
1416warn_flags=
1417add_to warn_flags -Wold-style-declaration
1418add_to warn_flags -Wold-style-definition
1419add_to warn_flags -Wtype-limits
1420add_to warn_flags -Wformat-security
1421add_to warn_flags -Wformat-y2k
1422add_to warn_flags -Winit-self
1423add_to warn_flags -Wignored-qualifiers
1424add_to warn_flags -Wempty-body
1425add_to warn_flags -Wnested-externs
1426add_to warn_flags -Wendif-labels
1427add_to warn_flags -Wexpansion-to-defined
Thomas Huth0a2ebce2020-12-11 16:24:26 +01001428add_to warn_flags -Wimplicit-fallthrough=2
Richard Henderson00849b92020-06-17 13:13:06 -07001429
1430nowarn_flags=
1431add_to nowarn_flags -Wno-initializer-overrides
1432add_to nowarn_flags -Wno-missing-include-dirs
1433add_to nowarn_flags -Wno-shift-negative-value
1434add_to nowarn_flags -Wno-string-plus-int
1435add_to nowarn_flags -Wno-typedef-redefinition
Richard Hendersonaabab962020-06-17 13:13:07 -07001436add_to nowarn_flags -Wno-tautological-type-limit-compare
Richard Hendersonbac8d222020-06-17 13:13:08 -07001437add_to nowarn_flags -Wno-psabi
Richard Henderson00849b92020-06-17 13:13:06 -07001438
1439gcc_flags="$warn_flags $nowarn_flags"
John Snow93b25862015-03-25 18:57:37 -04001440
1441cc_has_warning_flag() {
1442 write_c_skeleton;
1443
Peter Maydella1d29d62012-10-27 22:19:07 +01001444 # Use the positive sense of the flag when testing for -Wno-wombat
1445 # support (gcc will happily accept the -Wno- form of unknown
1446 # warning options).
John Snow93b25862015-03-25 18:57:37 -04001447 optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
1448 compile_prog "-Werror $optflag" ""
1449}
1450
Philippe Mathieu-Daudé4cb37d12022-02-15 16:15:13 +01001451objcc_has_warning_flag() {
1452 cat > $TMPM <<EOF
1453int main(void) { return 0; }
1454EOF
1455
1456 # Use the positive sense of the flag when testing for -Wno-wombat
1457 # support (gcc will happily accept the -Wno- form of unknown
1458 # warning options).
1459 optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
1460 do_objc -Werror $optflag \
1461 $OBJCFLAGS $EXTRA_OBJCFLAGS $CONFIGURE_OBJCFLAGS $QEMU_OBJCFLAGS \
1462 -o $TMPE $TMPM $QEMU_LDFLAGS
1463}
1464
John Snow93b25862015-03-25 18:57:37 -04001465for flag in $gcc_flags; do
1466 if cc_has_warning_flag $flag ; then
1467 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
Paolo Bonzini8d050952010-12-23 11:43:52 +01001468 fi
Philippe Mathieu-Daudé4cb37d12022-02-15 16:15:13 +01001469 if objcc_has_warning_flag $flag ; then
1470 QEMU_OBJCFLAGS="$QEMU_OBJCFLAGS $flag"
1471 fi
Paolo Bonzini8d050952010-12-23 11:43:52 +01001472done
1473
Miroslav Rezanina3b463a32014-07-02 10:05:24 +02001474if test "$stack_protector" != "no"; then
Rodrigo Rebellofccd35a2015-11-12 12:04:28 -02001475 cat > $TMPC << EOF
1476int main(int argc, char *argv[])
1477{
1478 char arr[64], *p = arr, *c = argv[0];
1479 while (*c) {
1480 *p++ = *c++;
1481 }
1482 return 0;
1483}
1484EOF
Steven Noonan63678e12014-03-28 17:19:02 +01001485 gcc_flags="-fstack-protector-strong -fstack-protector-all"
Miroslav Rezanina3b463a32014-07-02 10:05:24 +02001486 sp_on=0
Steven Noonan63678e12014-03-28 17:19:02 +01001487 for flag in $gcc_flags; do
Peter Maydell590e5dd2014-04-11 17:13:52 +01001488 # We need to check both a compile and a link, since some compiler
1489 # setups fail only on a .c->.o compile and some only at link time
Paolo Bonzini086d5f72020-02-03 15:22:17 +01001490 if compile_object "-Werror $flag" &&
Peter Maydell590e5dd2014-04-11 17:13:52 +01001491 compile_prog "-Werror $flag" ""; then
Steven Noonan63678e12014-03-28 17:19:02 +01001492 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
Paolo Bonzinidb5adea2019-12-11 15:34:27 +01001493 QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
Miroslav Rezanina3b463a32014-07-02 10:05:24 +02001494 sp_on=1
Steven Noonan63678e12014-03-28 17:19:02 +01001495 break
1496 fi
1497 done
Miroslav Rezanina3b463a32014-07-02 10:05:24 +02001498 if test "$stack_protector" = yes; then
1499 if test $sp_on = 0; then
1500 error_exit "Stack protector not supported"
1501 fi
1502 fi
Marc-André Lureau37746c52013-02-25 23:31:12 +01001503fi
1504
Paolo Bonzini20bc94a2017-10-20 12:11:32 +02001505# Disable -Wmissing-braces on older compilers that warn even for
1506# the "universal" C zero initializer {0}.
1507cat > $TMPC << EOF
1508struct {
1509 int a[2];
1510} x = {0};
1511EOF
1512if compile_object "-Werror" "" ; then
1513 :
1514else
1515 QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
1516fi
1517
Marc-André Lureau21e709a2019-07-18 16:04:13 +04001518# Our module code doesn't support Windows
1519if test "$modules" = "yes" && test "$mingw32" = "yes" ; then
1520 error_exit "Modules are not available for Windows"
1521fi
1522
Christian Ehrhardtbd83c862020-03-10 15:58:06 +01001523# module_upgrades is only reasonable if modules are enabled
1524if test "$modules" = "no" && test "$module_upgrades" = "yes" ; then
1525 error_exit "Can't enable module-upgrades as Modules are not enabled"
1526fi
1527
Alex Bennée5f2453a2021-07-09 15:29:55 +01001528# Static linking is not possible with plugins, modules or PIE
Avi Kivity40d64442011-11-15 20:12:17 +02001529if test "$static" = "yes" ; then
Paolo Bonziniaa0d1f42014-02-25 17:36:55 +01001530 if test "$modules" = "yes" ; then
1531 error_exit "static and modules are mutually incompatible"
1532 fi
Alex Bennée5f2453a2021-07-09 15:29:55 +01001533 if test "$plugins" = "yes"; then
1534 error_exit "static and plugins are mutually incompatible"
Alex Bennéeba4dd2a2021-07-09 15:29:57 +01001535 else
1536 plugins="no"
Alex Bennée5f2453a2021-07-09 15:29:55 +01001537 fi
Avi Kivity40d64442011-11-15 20:12:17 +02001538fi
Paolo Bonzini37650682021-12-10 09:55:15 +01001539test "$plugins" = "" && plugins=yes
Avi Kivity40d64442011-11-15 20:12:17 +02001540
Richard Hendersonb2634122019-12-17 13:54:56 -10001541cat > $TMPC << EOF
Avi Kivity21d4a792011-11-23 11:24:25 +02001542
1543#ifdef __linux__
1544# define THREAD __thread
1545#else
1546# define THREAD
1547#endif
Avi Kivity21d4a792011-11-23 11:24:25 +02001548static THREAD int tls_var;
Avi Kivity21d4a792011-11-23 11:24:25 +02001549int main(void) { return tls_var; }
Avi Kivity40d64442011-11-15 20:12:17 +02001550EOF
Alex Bennée412aeac2019-08-15 19:41:51 +00001551
Jessica Clarkeffd205e2021-08-05 20:25:45 +01001552# Check we support -fno-pie and -no-pie first; we will need the former for
1553# building ROMs, and both for everything if --disable-pie is passed.
Richard Hendersonb2634122019-12-17 13:54:56 -10001554if compile_prog "-Werror -fno-pie" "-no-pie"; then
1555 CFLAGS_NOPIE="-fno-pie"
Jessica Clarkeffd205e2021-08-05 20:25:45 +01001556 LDFLAGS_NOPIE="-no-pie"
Richard Hendersonb2634122019-12-17 13:54:56 -10001557fi
1558
Richard Henderson12781462019-12-17 15:30:14 -10001559if test "$static" = "yes"; then
Richard Hendersoneca7a8e2020-04-03 20:11:50 +01001560 if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then
Paolo Bonzini5770e8a2020-09-23 05:26:15 -04001561 CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
Richard Henderson12781462019-12-17 15:30:14 -10001562 QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS"
1563 pie="yes"
1564 elif test "$pie" = "yes"; then
1565 error_exit "-static-pie not available due to missing toolchain support"
1566 else
1567 QEMU_LDFLAGS="-static $QEMU_LDFLAGS"
1568 pie="no"
1569 fi
1570elif test "$pie" = "no"; then
Paolo Bonzini5770e8a2020-09-23 05:26:15 -04001571 CONFIGURE_CFLAGS="$CFLAGS_NOPIE $CONFIGURE_CFLAGS"
Jessica Clarkeffd205e2021-08-05 20:25:45 +01001572 CONFIGURE_LDFLAGS="$LDFLAGS_NOPIE $CONFIGURE_LDFLAGS"
Richard Hendersoneca7a8e2020-04-03 20:11:50 +01001573elif compile_prog "-Werror -fPIE -DPIE" "-pie"; then
Paolo Bonzini5770e8a2020-09-23 05:26:15 -04001574 CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
1575 CONFIGURE_LDFLAGS="-pie $CONFIGURE_LDFLAGS"
Richard Henderson2c674102019-12-17 15:15:01 -10001576 pie="yes"
1577elif test "$pie" = "yes"; then
1578 error_exit "PIE not available due to missing toolchain support"
1579else
1580 echo "Disabling PIE due to missing toolchain support"
1581 pie="no"
Avi Kivity40d64442011-11-15 20:12:17 +02001582fi
1583
Richard Hendersone6cbd752019-12-17 14:00:39 -10001584# Detect support for PT_GNU_RELRO + DT_BIND_NOW.
1585# The combination is known as "full relro", because .got.plt is read-only too.
1586if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
1587 QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS"
1588fi
1589
Paolo Bonzini09dada42013-04-17 16:26:47 +02001590##########################################
1591# __sync_fetch_and_and requires at least -march=i486. Many toolchains
1592# use i686 as default anyway, but for those that don't, an explicit
1593# specification is necessary
1594
1595if test "$cpu" = "i386"; then
1596 cat > $TMPC << EOF
1597static int sfaa(int *ptr)
1598{
1599 return __sync_fetch_and_and(ptr, 0);
1600}
1601
1602int main(void)
1603{
1604 int val = 42;
Stefan Weil1405b622013-05-11 21:46:58 +02001605 val = __sync_val_compare_and_swap(&val, 0, 1);
Paolo Bonzini09dada42013-04-17 16:26:47 +02001606 sfaa(&val);
1607 return val;
1608}
1609EOF
1610 if ! compile_prog "" "" ; then
1611 QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
1612 fi
1613fi
1614
Philippe Mathieu-Daudé56267b62021-05-12 06:58:21 +02001615if test "$tcg" = "enabled"; then
1616 git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
1617 git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
1618fi
1619
Stefan Weilafb63eb2012-09-26 22:04:38 +02001620if test -z "${target_list+xxx}" ; then
Paolo Bonzinifdb75ae2020-09-21 04:37:49 -04001621 default_targets=yes
Paolo Bonzinid880a3b2017-07-03 16:58:28 +02001622 for target in $default_target_list; do
Paolo Bonzinifdb75ae2020-09-21 04:37:49 -04001623 target_list="$target_list $target"
Paolo Bonzinid880a3b2017-07-03 16:58:28 +02001624 done
1625 target_list="${target_list# }"
Anthony Liguori121afa92012-09-14 08:17:03 -05001626else
Paolo Bonzinifdb75ae2020-09-21 04:37:49 -04001627 default_targets=no
Stefan Weil89138852016-05-16 15:10:20 +02001628 target_list=$(echo "$target_list" | sed -e 's/,/ /g')
Paolo Bonzinid880a3b2017-07-03 16:58:28 +02001629 for target in $target_list; do
1630 # Check that we recognised the target name; this allows a more
1631 # friendly error message than if we let it fall through.
1632 case " $default_target_list " in
1633 *" $target "*)
1634 ;;
1635 *)
1636 error_exit "Unknown target name '$target'"
1637 ;;
1638 esac
Paolo Bonzinid880a3b2017-07-03 16:58:28 +02001639 done
bellard5327cf42005-01-10 23:18:50 +00001640fi
Peter Maydell25b48332013-05-20 16:16:16 +01001641
Paolo Bonzinif55fe272010-05-26 16:08:17 +02001642# see if system emulation was really requested
1643case " $target_list " in
1644 *"-softmmu "*) softmmu=yes
1645 ;;
1646 *) softmmu=no
1647 ;;
1648esac
bellard5327cf42005-01-10 23:18:50 +00001649
Juan Quintela249247c2009-08-12 18:20:25 +02001650feature_not_found() {
1651 feature=$1
Stewart Smith21684af2014-01-24 12:39:10 +11001652 remedy=$2
Juan Quintela249247c2009-08-12 18:20:25 +02001653
Peter Maydell76ad07a2013-04-08 12:11:26 +01001654 error_exit "User requested feature $feature" \
Stewart Smith21684af2014-01-24 12:39:10 +11001655 "configure was not able to find it." \
1656 "$remedy"
Juan Quintela249247c2009-08-12 18:20:25 +02001657}
1658
bellard7d132992003-03-06 23:23:54 +00001659# ---
1660# big/little endian test
1661cat > $TMPC << EOF
Thomas Huth659eb152021-07-15 10:39:28 +02001662#include <stdio.h>
Mike Frysinger61cc9192013-06-30 23:30:18 -04001663short big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
1664short little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
Thomas Huth659eb152021-07-15 10:39:28 +02001665int main(int argc, char *argv[])
1666{
1667 return printf("%s %s\n", (char *)big_endian, (char *)little_endian);
bellard7d132992003-03-06 23:23:54 +00001668}
1669EOF
1670
Thomas Huth659eb152021-07-15 10:39:28 +02001671if compile_prog ; then
1672 if strings -a $TMPE | grep -q BiGeNdIaN ; then
Mike Frysinger61cc9192013-06-30 23:30:18 -04001673 bigendian="yes"
Thomas Huth659eb152021-07-15 10:39:28 +02001674 elif strings -a $TMPE | grep -q LiTtLeEnDiAn ; then
Mike Frysinger61cc9192013-06-30 23:30:18 -04001675 bigendian="no"
1676 else
1677 echo big/little test failed
Thomas Huth659eb152021-07-15 10:39:28 +02001678 exit 1
Peter Maydell21d89f82011-11-30 10:57:48 +01001679 fi
Mike Frysinger61cc9192013-06-30 23:30:18 -04001680else
1681 echo big/little test failed
Thomas Huth659eb152021-07-15 10:39:28 +02001682 exit 1
bellard7d132992003-03-06 23:23:54 +00001683fi
1684
Paolo Bonzini299e6f12019-02-14 18:35:53 +01001685#########################################
1686# vhost interdependencies and host support
1687
1688# vhost backends
Sergio Lopezeb9baec2022-03-04 11:08:53 +01001689if test "$vhost_user" = "yes" && test "$mingw32" = "yes"; then
1690 error_exit "vhost-user is not available on Windows"
Paolo Bonzini299e6f12019-02-14 18:35:53 +01001691fi
Cindy Lu108a6482020-07-01 22:55:37 +08001692test "$vhost_vdpa" = "" && vhost_vdpa=$linux
1693if test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then
1694 error_exit "vhost-vdpa is only available on Linux"
1695fi
Paolo Bonzini299e6f12019-02-14 18:35:53 +01001696test "$vhost_kernel" = "" && vhost_kernel=$linux
1697if test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then
1698 error_exit "vhost-kernel is only available on Linux"
1699fi
1700
1701# vhost-kernel devices
1702test "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel
1703if test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then
1704 error_exit "--enable-vhost-scsi requires --enable-vhost-kernel"
1705fi
1706test "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel
1707if test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then
1708 error_exit "--enable-vhost-vsock requires --enable-vhost-kernel"
1709fi
1710
1711# vhost-user backends
1712test "$vhost_net_user" = "" && vhost_net_user=$vhost_user
1713if test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then
1714 error_exit "--enable-vhost-net-user requires --enable-vhost-user"
1715fi
1716test "$vhost_crypto" = "" && vhost_crypto=$vhost_user
1717if test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then
1718 error_exit "--enable-vhost-crypto requires --enable-vhost-user"
1719fi
Dr. David Alan Gilbert98fc1ad2019-09-30 11:51:34 +01001720test "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user
1721if test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then
1722 error_exit "--enable-vhost-user-fs requires --enable-vhost-user"
1723fi
Cindy Lu108a6482020-07-01 22:55:37 +08001724#vhost-vdpa backends
1725test "$vhost_net_vdpa" = "" && vhost_net_vdpa=$vhost_vdpa
1726if test "$vhost_net_vdpa" = "yes" && test "$vhost_vdpa" = "no"; then
1727 error_exit "--enable-vhost-net-vdpa requires --enable-vhost-vdpa"
1728fi
Paolo Bonzini299e6f12019-02-14 18:35:53 +01001729
Laurent Vivier40bc0ca2020-09-24 23:00:23 +02001730# OR the vhost-kernel, vhost-vdpa and vhost-user values for simplicity
Paolo Bonzini299e6f12019-02-14 18:35:53 +01001731if test "$vhost_net" = ""; then
1732 test "$vhost_net_user" = "yes" && vhost_net=yes
Laurent Vivier40bc0ca2020-09-24 23:00:23 +02001733 test "$vhost_net_vdpa" = "yes" && vhost_net=yes
Paolo Bonzini299e6f12019-02-14 18:35:53 +01001734 test "$vhost_kernel" = "yes" && vhost_net=yes
1735fi
1736
Gonglei015a33b2014-07-01 20:58:08 +08001737##########################################
Stefan Weil779ab5e2012-12-16 11:29:45 +01001738# pkg-config probe
1739
1740if ! has "$pkg_config_exe"; then
Peter Maydell76ad07a2013-04-08 12:11:26 +01001741 error_exit "pkg-config binary '$pkg_config_exe' not found"
Stefan Weil779ab5e2012-12-16 11:29:45 +01001742fi
1743
1744##########################################
aliguorie37630c2009-04-22 15:19:10 +00001745# xen probe
1746
Paolo Bonzini1badb702020-09-18 04:57:25 -04001747if test "$xen" != "disabled" ; then
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02001748 # Check whether Xen library path is specified via --extra-ldflags to avoid
1749 # overriding this setting with pkg-config output. If not, try pkg-config
1750 # to obtain all needed flags.
Anthony PERARDd5b93dd2011-02-25 16:20:34 +00001751
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02001752 if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
1753 $pkg_config --exists xencontrol ; then
1754 xen_ctrl_version="$(printf '%d%02d%02d' \
1755 $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
Paolo Bonzini1badb702020-09-18 04:57:25 -04001756 xen=enabled
Michael Tokarev5b6a8f42020-07-27 17:00:48 +03001757 xen_pc="xencontrol xenstore xenforeignmemory xengnttab"
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02001758 xen_pc="$xen_pc xenevtchn xendevicemodel"
Anthony PERARD58ea9a72017-09-25 16:01:48 +01001759 if $pkg_config --exists xentoolcore; then
1760 xen_pc="$xen_pc xentoolcore"
1761 fi
Marc-André Lureau582ea952019-08-15 15:15:32 +04001762 xen_cflags="$($pkg_config --cflags $xen_pc)"
1763 xen_libs="$($pkg_config --libs $xen_pc)"
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02001764 else
Stefan Weil50ced5b2011-12-17 09:27:39 +01001765
Michael Tokarev5b6a8f42020-07-27 17:00:48 +03001766 xen_libs="-lxenstore -lxenctrl"
Anthony PERARDd9506ca2017-05-11 12:35:42 +01001767 xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02001768
1769 # First we test whether Xen headers and libraries are available.
1770 # If no, we are done and there is no Xen support.
1771 # If yes, more tests are run to detect the Xen version.
1772
1773 # Xen (any)
1774 cat > $TMPC <<EOF
aliguorie37630c2009-04-22 15:19:10 +00001775#include <xenctrl.h>
Stefan Weil50ced5b2011-12-17 09:27:39 +01001776int main(void) {
1777 return 0;
1778}
1779EOF
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02001780 if ! compile_prog "" "$xen_libs" ; then
1781 # Xen not found
Paolo Bonzini1badb702020-09-18 04:57:25 -04001782 if test "$xen" = "enabled" ; then
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02001783 feature_not_found "xen" "Install xen devel"
1784 fi
Paolo Bonzini1badb702020-09-18 04:57:25 -04001785 xen=disabled
Stefan Weil50ced5b2011-12-17 09:27:39 +01001786
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02001787 # Xen unstable
1788 elif
1789 cat > $TMPC <<EOF &&
Ross Lagerwall2cbf8902017-10-23 10:27:27 +01001790#undef XC_WANT_COMPAT_DEVICEMODEL_API
1791#define __XEN_TOOLS__
1792#include <xendevicemodel.h>
Paul Durrantd3c49eb2018-05-15 17:40:53 +01001793#include <xenforeignmemory.h>
Ross Lagerwall2cbf8902017-10-23 10:27:27 +01001794int main(void) {
1795 xendevicemodel_handle *xd;
Paul Durrantd3c49eb2018-05-15 17:40:53 +01001796 xenforeignmemory_handle *xfmem;
Ross Lagerwall2cbf8902017-10-23 10:27:27 +01001797
1798 xd = xendevicemodel_open(0, 0);
1799 xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
1800
Paul Durrantd3c49eb2018-05-15 17:40:53 +01001801 xfmem = xenforeignmemory_open(0, 0);
1802 xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
1803
Ross Lagerwall2cbf8902017-10-23 10:27:27 +01001804 return 0;
1805}
1806EOF
1807 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
1808 then
1809 xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
1810 xen_ctrl_version=41100
Paolo Bonzini1badb702020-09-18 04:57:25 -04001811 xen=enabled
Ross Lagerwall2cbf8902017-10-23 10:27:27 +01001812 elif
1813 cat > $TMPC <<EOF &&
Igor Druzhinin5ba3d752017-07-10 23:40:02 +01001814#undef XC_WANT_COMPAT_MAP_FOREIGN_API
1815#include <xenforeignmemory.h>
Anthony PERARD58ea9a72017-09-25 16:01:48 +01001816#include <xentoolcore.h>
Igor Druzhinin5ba3d752017-07-10 23:40:02 +01001817int main(void) {
1818 xenforeignmemory_handle *xfmem;
1819
1820 xfmem = xenforeignmemory_open(0, 0);
1821 xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
Anthony PERARD58ea9a72017-09-25 16:01:48 +01001822 xentoolcore_restrict_all(0);
Igor Druzhinin5ba3d752017-07-10 23:40:02 +01001823
1824 return 0;
1825}
1826EOF
Anthony PERARD58ea9a72017-09-25 16:01:48 +01001827 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
Igor Druzhinin5ba3d752017-07-10 23:40:02 +01001828 then
Anthony PERARD58ea9a72017-09-25 16:01:48 +01001829 xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
Igor Druzhinin5ba3d752017-07-10 23:40:02 +01001830 xen_ctrl_version=41000
Paolo Bonzini1badb702020-09-18 04:57:25 -04001831 xen=enabled
Igor Druzhinin5ba3d752017-07-10 23:40:02 +01001832 elif
1833 cat > $TMPC <<EOF &&
Paul Durrantda8090c2017-03-07 10:55:33 +00001834#undef XC_WANT_COMPAT_DEVICEMODEL_API
1835#define __XEN_TOOLS__
1836#include <xendevicemodel.h>
1837int main(void) {
1838 xendevicemodel_handle *xd;
1839
1840 xd = xendevicemodel_open(0, 0);
1841 xendevicemodel_close(xd);
1842
1843 return 0;
1844}
1845EOF
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02001846 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
1847 then
1848 xen_stable_libs="-lxendevicemodel $xen_stable_libs"
1849 xen_ctrl_version=40900
Paolo Bonzini1badb702020-09-18 04:57:25 -04001850 xen=enabled
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02001851 elif
1852 cat > $TMPC <<EOF &&
Ian Campbell5eeb39c2016-01-15 13:23:42 +00001853/*
1854 * If we have stable libs the we don't want the libxc compat
1855 * layers, regardless of what CFLAGS we may have been given.
Paulina Szubarczykb6eb9b42016-09-14 21:10:03 +02001856 *
1857 * Also, check if xengnttab_grant_copy_segment_t is defined and
1858 * grant copy operation is implemented.
1859 */
1860#undef XC_WANT_COMPAT_EVTCHN_API
1861#undef XC_WANT_COMPAT_GNTTAB_API
1862#undef XC_WANT_COMPAT_MAP_FOREIGN_API
1863#include <xenctrl.h>
1864#include <xenstore.h>
1865#include <xenevtchn.h>
1866#include <xengnttab.h>
1867#include <xenforeignmemory.h>
1868#include <stdint.h>
1869#include <xen/hvm/hvm_info_table.h>
1870#if !defined(HVM_MAX_VCPUS)
1871# error HVM_MAX_VCPUS not defined
1872#endif
1873int main(void) {
1874 xc_interface *xc = NULL;
1875 xenforeignmemory_handle *xfmem;
1876 xenevtchn_handle *xe;
1877 xengnttab_handle *xg;
Paulina Szubarczykb6eb9b42016-09-14 21:10:03 +02001878 xengnttab_grant_copy_segment_t* seg = NULL;
1879
1880 xs_daemon_open();
1881
1882 xc = xc_interface_open(0, 0, 0);
1883 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1884 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1885 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
1886 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
Paulina Szubarczykb6eb9b42016-09-14 21:10:03 +02001887
1888 xfmem = xenforeignmemory_open(0, 0);
1889 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
1890
1891 xe = xenevtchn_open(0, 0);
1892 xenevtchn_fd(xe);
1893
1894 xg = xengnttab_open(0, 0);
1895 xengnttab_grant_copy(xg, 0, seg);
1896
1897 return 0;
1898}
1899EOF
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02001900 compile_prog "" "$xen_libs $xen_stable_libs"
1901 then
1902 xen_ctrl_version=40800
Paolo Bonzini1badb702020-09-18 04:57:25 -04001903 xen=enabled
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02001904 elif
1905 cat > $TMPC <<EOF &&
Paulina Szubarczykb6eb9b42016-09-14 21:10:03 +02001906/*
1907 * If we have stable libs the we don't want the libxc compat
1908 * layers, regardless of what CFLAGS we may have been given.
Ian Campbell5eeb39c2016-01-15 13:23:42 +00001909 */
1910#undef XC_WANT_COMPAT_EVTCHN_API
1911#undef XC_WANT_COMPAT_GNTTAB_API
1912#undef XC_WANT_COMPAT_MAP_FOREIGN_API
1913#include <xenctrl.h>
1914#include <xenstore.h>
1915#include <xenevtchn.h>
1916#include <xengnttab.h>
1917#include <xenforeignmemory.h>
1918#include <stdint.h>
1919#include <xen/hvm/hvm_info_table.h>
1920#if !defined(HVM_MAX_VCPUS)
1921# error HVM_MAX_VCPUS not defined
1922#endif
1923int main(void) {
1924 xc_interface *xc = NULL;
1925 xenforeignmemory_handle *xfmem;
1926 xenevtchn_handle *xe;
1927 xengnttab_handle *xg;
Ian Campbell5eeb39c2016-01-15 13:23:42 +00001928
1929 xs_daemon_open();
1930
1931 xc = xc_interface_open(0, 0, 0);
1932 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1933 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1934 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
1935 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
Ian Campbell5eeb39c2016-01-15 13:23:42 +00001936
1937 xfmem = xenforeignmemory_open(0, 0);
1938 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
1939
1940 xe = xenevtchn_open(0, 0);
1941 xenevtchn_fd(xe);
1942
1943 xg = xengnttab_open(0, 0);
1944 xengnttab_map_grant_ref(xg, 0, 0, 0);
1945
1946 return 0;
1947}
1948EOF
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02001949 compile_prog "" "$xen_libs $xen_stable_libs"
1950 then
1951 xen_ctrl_version=40701
Paolo Bonzini1badb702020-09-18 04:57:25 -04001952 xen=enabled
Roger Pau Monnecdadde32015-11-13 17:38:06 +00001953
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02001954 # Xen 4.6
1955 elif
1956 cat > $TMPC <<EOF &&
Roger Pau Monnecdadde32015-11-13 17:38:06 +00001957#include <xenctrl.h>
Anthony PERARDe108a3c2012-06-21 11:44:35 +00001958#include <xenstore.h>
Anthony PERARDd5b93dd2011-02-25 16:20:34 +00001959#include <stdint.h>
1960#include <xen/hvm/hvm_info_table.h>
1961#if !defined(HVM_MAX_VCPUS)
1962# error HVM_MAX_VCPUS not defined
1963#endif
1964int main(void) {
1965 xc_interface *xc;
1966 xs_daemon_open();
1967 xc = xc_interface_open(0, 0, 0);
1968 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1969 xc_gnttab_open(NULL, 0);
Anthony PERARDb87de242011-05-24 14:34:20 +01001970 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
Stefano Stabellini8688e062012-04-17 17:04:18 +00001971 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
Jan Beulichd8b441a2015-07-24 03:38:28 -06001972 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
Konrad Rzeszutek Wilk20a544c2015-06-29 12:51:05 -04001973 xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
Jan Beulichd8b441a2015-07-24 03:38:28 -06001974 return 0;
1975}
1976EOF
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02001977 compile_prog "" "$xen_libs"
1978 then
1979 xen_ctrl_version=40600
Paolo Bonzini1badb702020-09-18 04:57:25 -04001980 xen=enabled
Jan Beulichd8b441a2015-07-24 03:38:28 -06001981
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02001982 # Xen 4.5
1983 elif
1984 cat > $TMPC <<EOF &&
Jan Beulichd8b441a2015-07-24 03:38:28 -06001985#include <xenctrl.h>
1986#include <xenstore.h>
1987#include <stdint.h>
1988#include <xen/hvm/hvm_info_table.h>
1989#if !defined(HVM_MAX_VCPUS)
1990# error HVM_MAX_VCPUS not defined
1991#endif
1992int main(void) {
1993 xc_interface *xc;
1994 xs_daemon_open();
1995 xc = xc_interface_open(0, 0, 0);
1996 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1997 xc_gnttab_open(NULL, 0);
1998 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1999 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
Paul Durrant3996e852015-01-20 11:06:19 +00002000 xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
2001 return 0;
2002}
2003EOF
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02002004 compile_prog "" "$xen_libs"
2005 then
2006 xen_ctrl_version=40500
Paolo Bonzini1badb702020-09-18 04:57:25 -04002007 xen=enabled
Paul Durrant3996e852015-01-20 11:06:19 +00002008
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02002009 elif
2010 cat > $TMPC <<EOF &&
Paul Durrant3996e852015-01-20 11:06:19 +00002011#include <xenctrl.h>
2012#include <xenstore.h>
2013#include <stdint.h>
2014#include <xen/hvm/hvm_info_table.h>
2015#if !defined(HVM_MAX_VCPUS)
2016# error HVM_MAX_VCPUS not defined
2017#endif
2018int main(void) {
2019 xc_interface *xc;
2020 xs_daemon_open();
2021 xc = xc_interface_open(0, 0, 0);
2022 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2023 xc_gnttab_open(NULL, 0);
2024 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2025 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
Stefano Stabellini8688e062012-04-17 17:04:18 +00002026 return 0;
2027}
2028EOF
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02002029 compile_prog "" "$xen_libs"
2030 then
2031 xen_ctrl_version=40200
Paolo Bonzini1badb702020-09-18 04:57:25 -04002032 xen=enabled
Stefano Stabellini8688e062012-04-17 17:04:18 +00002033
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02002034 else
Paolo Bonzini1badb702020-09-18 04:57:25 -04002035 if test "$xen" = "enabled" ; then
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02002036 feature_not_found "xen (unsupported version)" \
2037 "Install a supported xen (xen 4.2 or newer)"
2038 fi
Paolo Bonzini1badb702020-09-18 04:57:25 -04002039 xen=disabled
Juan Quintelafc321b42009-08-12 18:29:55 +02002040 fi
Anthony PERARDd5b93dd2011-02-25 16:20:34 +00002041
Paolo Bonzini1badb702020-09-18 04:57:25 -04002042 if test "$xen" = enabled; then
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02002043 if test $xen_ctrl_version -ge 40701 ; then
Marc-André Lureau582ea952019-08-15 15:15:32 +04002044 xen_libs="$xen_libs $xen_stable_libs "
Juergen Grossc1cdd9d2017-03-27 09:42:45 +02002045 fi
Ian Campbell5eeb39c2016-01-15 13:23:42 +00002046 fi
Anthony PERARDd5b93dd2011-02-25 16:20:34 +00002047 fi
aliguorie37630c2009-04-22 15:19:10 +00002048fi
2049
2050##########################################
Michael R. Hines2da776d2013-07-22 10:01:54 -04002051# RDMA needs OpenFabrics libraries
2052if test "$rdma" != "no" ; then
2053 cat > $TMPC <<EOF
2054#include <rdma/rdma_cma.h>
2055int main(void) { return 0; }
2056EOF
Yuval Shaiaef6d4cc2018-02-09 15:23:18 +02002057 rdma_libs="-lrdmacm -libverbs -libumad"
Michael R. Hines2da776d2013-07-22 10:01:54 -04002058 if compile_prog "" "$rdma_libs" ; then
2059 rdma="yes"
Michael R. Hines2da776d2013-07-22 10:01:54 -04002060 else
2061 if test "$rdma" = "yes" ; then
2062 error_exit \
Yuval Shaiaef6d4cc2018-02-09 15:23:18 +02002063 " OpenFabrics librdmacm/libibverbs/libibumad not present." \
Michael R. Hines2da776d2013-07-22 10:01:54 -04002064 " Your options:" \
Yuval Shaiaef6d4cc2018-02-09 15:23:18 +02002065 " (1) Fast: Install infiniband packages (devel) from your distro." \
Michael R. Hines2da776d2013-07-22 10:01:54 -04002066 " (2) Cleanest: Install libraries from www.openfabrics.org" \
2067 " (3) Also: Install softiwarp if you don't have RDMA hardware"
2068 fi
2069 rdma="no"
2070 fi
2071fi
2072
Marcel Apfelbaum21ab34c2018-08-16 18:16:37 +03002073##########################################
2074# PVRDMA detection
2075
2076cat > $TMPC <<EOF &&
2077#include <sys/mman.h>
2078
2079int
2080main(void)
2081{
2082 char buf = 0;
2083 void *addr = &buf;
2084 addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED);
2085
2086 return 0;
2087}
2088EOF
2089
2090if test "$rdma" = "yes" ; then
2091 case "$pvrdma" in
2092 "")
2093 if compile_prog "" ""; then
2094 pvrdma="yes"
2095 else
2096 pvrdma="no"
2097 fi
2098 ;;
2099 "yes")
2100 if ! compile_prog "" ""; then
2101 error_exit "PVRDMA is not supported since mremap is not implemented"
2102 fi
2103 pvrdma="yes"
2104 ;;
2105 "no")
2106 pvrdma="no"
2107 ;;
2108 esac
2109else
2110 if test "$pvrdma" = "yes" ; then
2111 error_exit "PVRDMA requires rdma suppport"
2112 fi
2113 pvrdma="no"
2114fi
ths8d5d2d42007-08-25 01:37:51 +00002115
Yuval Shaiaee108582019-08-18 16:21:06 +03002116# Let's see if enhanced reg_mr is supported
2117if test "$pvrdma" = "yes" ; then
2118
2119cat > $TMPC <<EOF &&
2120#include <infiniband/verbs.h>
2121
2122int
2123main(void)
2124{
2125 struct ibv_mr *mr;
2126 struct ibv_pd *pd = NULL;
2127 size_t length = 10;
2128 uint64_t iova = 0;
2129 int access = 0;
2130 void *addr = NULL;
2131
2132 mr = ibv_reg_mr_iova(pd, addr, length, iova, access);
2133
2134 ibv_dereg_mr(mr);
2135
2136 return 0;
2137}
2138EOF
2139 if ! compile_prog "" "-libverbs"; then
2140 QEMU_CFLAGS="$QEMU_CFLAGS -DLEGACY_RDMA_REG_MR"
2141 fi
2142fi
2143
ths8d5d2d42007-08-25 01:37:51 +00002144##########################################
Anthony Liguorie18df142011-07-19 14:50:29 -05002145# glib support probe
Paolo Bonzinia52d28a2012-04-05 13:01:54 +02002146
Daniel P. Berrangéb4c60362021-05-14 13:04:13 +01002147glib_req_ver=2.56
Paolo Bonziniaa0d1f42014-02-25 17:36:55 +01002148glib_modules=gthread-2.0
2149if test "$modules" = yes; then
Gerd Hoffmanna88afc62018-03-08 09:53:00 +01002150 glib_modules="$glib_modules gmodule-export-2.0"
Paolo Bonzinib906aca2021-08-11 12:05:50 +02002151elif test "$plugins" = "yes"; then
2152 glib_modules="$glib_modules gmodule-no-export-2.0"
Emilio G. Cota54cb65d2017-08-30 18:39:53 -04002153fi
Fam Zhenge26110c2014-02-10 14:48:57 +08002154
Paolo Bonziniaa0d1f42014-02-25 17:36:55 +01002155for i in $glib_modules; do
Fam Zhenge26110c2014-02-10 14:48:57 +08002156 if $pkg_config --atleast-version=$glib_req_ver $i; then
Stefan Weil89138852016-05-16 15:10:20 +02002157 glib_cflags=$($pkg_config --cflags $i)
2158 glib_libs=$($pkg_config --libs $i)
Fam Zhenge26110c2014-02-10 14:48:57 +08002159 else
2160 error_exit "glib-$glib_req_ver $i is required to compile QEMU"
2161 fi
2162done
2163
Paolo Bonzini215b0c22020-09-01 08:41:17 -04002164# This workaround is required due to a bug in pkg-config file for glib as it
2165# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
2166
2167if test "$static" = yes && test "$mingw32" = yes; then
2168 glib_cflags="-DGLIB_STATIC_COMPILATION $glib_cflags"
2169fi
2170
Denis Plotnikov20cf7b82021-03-12 18:14:40 +03002171if ! test "$gio" = "no"; then
2172 pass=no
2173 if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
2174 gio_cflags=$($pkg_config --cflags gio-2.0)
2175 gio_libs=$($pkg_config --libs gio-2.0)
2176 gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0)
Paolo Bonzini5ecfb762021-05-05 10:15:34 -04002177 if ! has "$gdbus_codegen"; then
Denis Plotnikov20cf7b82021-03-12 18:14:40 +03002178 gdbus_codegen=
2179 fi
2180 # Check that the libraries actually work -- Ubuntu 18.04 ships
2181 # with pkg-config --static --libs data for gio-2.0 that is missing
2182 # -lblkid and will give a link error.
2183 cat > $TMPC <<EOF
Peter Maydell13ceae62020-11-17 12:56:33 +00002184#include <gio/gio.h>
2185int main(void)
2186{
2187 g_dbus_proxy_new_sync(0, 0, 0, 0, 0, 0, 0, 0);
2188 return 0;
2189}
2190EOF
Denis Plotnikov20cf7b82021-03-12 18:14:40 +03002191 if compile_prog "$gio_cflags" "$gio_libs" ; then
2192 pass=yes
2193 else
2194 pass=no
2195 fi
Marc-André Lureauf876b762019-02-21 12:07:00 +01002196
Denis Plotnikov20cf7b82021-03-12 18:14:40 +03002197 if test "$pass" = "yes" &&
2198 $pkg_config --atleast-version=$glib_req_ver gio-unix-2.0; then
2199 gio_cflags="$gio_cflags $($pkg_config --cflags gio-unix-2.0)"
2200 gio_libs="$gio_libs $($pkg_config --libs gio-unix-2.0)"
2201 fi
2202 fi
2203
2204 if test "$pass" = "no"; then
2205 if test "$gio" = "yes"; then
2206 feature_not_found "gio" "Install libgio >= 2.0"
2207 else
2208 gio=no
2209 fi
2210 else
2211 gio=yes
2212 fi
Marc-André Lureau25a97a52019-09-27 11:34:42 +04002213fi
2214
Daniel P. Berrange977a82a2016-01-27 09:00:45 +00002215# Sanity check that the current size_t matches the
2216# size that glib thinks it should be. This catches
2217# problems on multi-arch where people try to build
2218# 32-bit QEMU while pointing at 64-bit glib headers
2219cat > $TMPC <<EOF
2220#include <glib.h>
2221#include <unistd.h>
2222
2223#define QEMU_BUILD_BUG_ON(x) \
2224 typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
2225
2226int main(void) {
2227 QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
2228 return 0;
2229}
2230EOF
2231
Paolo Bonzini215b0c22020-09-01 08:41:17 -04002232if ! compile_prog "$glib_cflags" "$glib_libs" ; then
Daniel P. Berrange977a82a2016-01-27 09:00:45 +00002233 error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
2234 "You probably need to set PKG_CONFIG_LIBDIR"\
2235 "to point to the right pkg-config files for your"\
2236 "build target"
2237fi
2238
Eric Blake9bda6002020-03-17 12:55:34 -05002239# Silence clang warnings triggered by glib < 2.57.2
2240cat > $TMPC << EOF
2241#include <glib.h>
2242typedef struct Foo {
2243 int i;
2244} Foo;
2245static void foo_free(Foo *f)
2246{
2247 g_free(f);
2248}
Marc-André Lureaue0e7fe02022-03-12 02:22:02 +04002249G_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free)
Eric Blake9bda6002020-03-17 12:55:34 -05002250int main(void) { return 0; }
2251EOF
2252if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
2253 if cc_has_warning_flag "-Wno-unused-function"; then
2254 glib_cflags="$glib_cflags -Wno-unused-function"
Paolo Bonzini5770e8a2020-09-23 05:26:15 -04002255 CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -Wno-unused-function"
Eric Blake9bda6002020-03-17 12:55:34 -05002256 fi
2257fi
2258
Fam Zhenge26110c2014-02-10 14:48:57 +08002259##########################################
2260# SHA command probe for modules
2261if test "$modules" = yes; then
2262 shacmd_probe="sha1sum sha1 shasum"
2263 for c in $shacmd_probe; do
Fam Zheng8ccefb92014-12-04 14:18:16 +08002264 if has $c; then
Fam Zhenge26110c2014-02-10 14:48:57 +08002265 shacmd="$c"
2266 break
2267 fi
2268 done
2269 if test "$shacmd" = ""; then
2270 error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
2271 fi
Anthony Liguorie18df142011-07-19 14:50:29 -05002272fi
2273
2274##########################################
aurel32f652e6a2008-12-16 10:43:48 +00002275# fdt probe
Paolo Bonzinifbb41212020-10-05 11:31:15 +02002276
2277case "$fdt" in
2278 auto | enabled | internal)
2279 # Simpler to always update submodule, even if not needed.
Paolo Bonzini2d652f22021-05-12 09:21:56 +02002280 git_submodules="${git_submodules} dtc"
Peter Maydelle169e1e2013-05-24 16:26:54 +01002281 ;;
Paolo Bonzinifbb41212020-10-05 11:31:15 +02002282esac
aurel32f652e6a2008-12-16 10:43:48 +00002283
Michael Walle20ff0752011-03-07 23:32:39 +01002284##########################################
Markus Armbruster9d49bcf2021-05-03 10:40:33 +02002285# opengl probe (for sdl2, gtk)
Gerd Hoffmannb1546f32015-03-16 10:03:53 +01002286
Gerd Hoffmannda076ff2014-11-20 09:49:44 +01002287if test "$opengl" != "no" ; then
Akihiko Odakibc6a3562021-02-23 15:03:07 +09002288 epoxy=no
2289 if $pkg_config epoxy; then
2290 cat > $TMPC << EOF
2291#include <epoxy/egl.h>
2292int main(void) { return 0; }
2293EOF
2294 if compile_prog "" "" ; then
2295 epoxy=yes
2296 fi
2297 fi
2298
2299 if test "$epoxy" = "yes" ; then
2300 opengl_cflags="$($pkg_config --cflags epoxy)"
2301 opengl_libs="$($pkg_config --libs epoxy)"
Gerd Hoffmannda076ff2014-11-20 09:49:44 +01002302 opengl=yes
Michael Walle20ff0752011-03-07 23:32:39 +01002303 else
Gerd Hoffmannda076ff2014-11-20 09:49:44 +01002304 if test "$opengl" = "yes" ; then
Akihiko Odakibc6a3562021-02-23 15:03:07 +09002305 feature_not_found "opengl" "Please install epoxy with EGL"
Michael Walle20ff0752011-03-07 23:32:39 +01002306 fi
Jeremy Whitef676c672015-01-09 13:08:49 -06002307 opengl_cflags=""
Gerd Hoffmannda076ff2014-11-20 09:49:44 +01002308 opengl_libs=""
2309 opengl=no
Michael Walle20ff0752011-03-07 23:32:39 +01002310 fi
2311fi
2312
Cortland Tölva955727d2018-10-08 09:35:19 -07002313# check for usbfs
2314have_usbfs=no
2315if test "$linux_user" = "yes"; then
Thomas Petazzoni96566d02019-02-13 22:18:27 +01002316 cat > $TMPC << EOF
2317#include <linux/usbdevice_fs.h>
2318
2319#ifndef USBDEVFS_GET_CAPABILITIES
2320#error "USBDEVFS_GET_CAPABILITIES undefined"
2321#endif
2322
2323#ifndef USBDEVFS_DISCONNECT_CLAIM
2324#error "USBDEVFS_DISCONNECT_CLAIM undefined"
2325#endif
2326
2327int main(void)
2328{
2329 return 0;
2330}
2331EOF
2332 if compile_prog "" ""; then
Cortland Tölva955727d2018-10-08 09:35:19 -07002333 have_usbfs=yes
2334 fi
Cortland Tölva955727d2018-10-08 09:35:19 -07002335fi
Marc-André Lureau751bcc32015-10-09 17:17:16 +02002336
Blue Swirlde5071c2009-09-12 09:58:46 +00002337##########################################
Richard Henderson8ca80762017-09-14 09:41:12 -07002338# capstone
2339
Richard Hendersone219c492017-09-28 09:01:23 -07002340case "$capstone" in
Richard Henderson8b18cdb2020-09-13 12:19:25 -07002341 auto | enabled | internal)
2342 # Simpler to always update submodule, even if not needed.
Paolo Bonzini2d652f22021-05-12 09:21:56 +02002343 git_submodules="${git_submodules} capstone"
Richard Hendersone219c492017-09-28 09:01:23 -07002344 ;;
2345esac
Richard Henderson8ca80762017-09-14 09:41:12 -07002346
2347##########################################
Alex Barcelo519175a2012-02-28 12:25:50 +01002348# check and set a backend for coroutine
Aneesh Kumar K.Vd0e2fce2011-06-09 23:11:06 +05302349
Peter Maydell7c2acc72013-04-08 12:11:27 +01002350# We prefer ucontext, but it's not always possible. The fallback
Daniel P. Berrange33c53c52017-04-28 13:24:44 +01002351# is sigcontext. On Windows the only valid backend is the Windows
2352# specific one.
Peter Maydell7c2acc72013-04-08 12:11:27 +01002353
2354ucontext_works=no
2355if test "$darwin" != "yes"; then
2356 cat > $TMPC << EOF
Aneesh Kumar K.Vd0e2fce2011-06-09 23:11:06 +05302357#include <ucontext.h>
Peter Maydellcdf84802012-02-23 16:20:05 +00002358#ifdef __stub_makecontext
2359#error Ignoring glibc stub makecontext which will always fail
2360#endif
Stefan Weil75cafad2011-12-17 09:27:29 +01002361int main(void) { makecontext(0, 0, 0); return 0; }
Aneesh Kumar K.Vd0e2fce2011-06-09 23:11:06 +05302362EOF
Peter Maydell7c2acc72013-04-08 12:11:27 +01002363 if compile_prog "" "" ; then
2364 ucontext_works=yes
Aneesh Kumar K.Vd0e2fce2011-06-09 23:11:06 +05302365 fi
Peter Maydell7c2acc72013-04-08 12:11:27 +01002366fi
2367
2368if test "$coroutine" = ""; then
2369 if test "$mingw32" = "yes"; then
2370 coroutine=win32
2371 elif test "$ucontext_works" = "yes"; then
2372 coroutine=ucontext
2373 else
2374 coroutine=sigaltstack
2375 fi
Alex Barcelo519175a2012-02-28 12:25:50 +01002376else
Peter Maydell7c2acc72013-04-08 12:11:27 +01002377 case $coroutine in
2378 windows)
2379 if test "$mingw32" != "yes"; then
2380 error_exit "'windows' coroutine backend only valid for Windows"
2381 fi
2382 # Unfortunately the user visible backend name doesn't match the
2383 # coroutine-*.c filename for this case, so we have to adjust it here.
2384 coroutine=win32
2385 ;;
2386 ucontext)
2387 if test "$ucontext_works" != "yes"; then
2388 feature_not_found "ucontext"
2389 fi
2390 ;;
Daniel P. Berrange33c53c52017-04-28 13:24:44 +01002391 sigaltstack)
Peter Maydell7c2acc72013-04-08 12:11:27 +01002392 if test "$mingw32" = "yes"; then
2393 error_exit "only the 'windows' coroutine backend is valid for Windows"
2394 fi
2395 ;;
2396 *)
2397 error_exit "unknown coroutine backend $coroutine"
2398 ;;
2399 esac
Aneesh Kumar K.Vd0e2fce2011-06-09 23:11:06 +05302400fi
2401
Daniele Buono1e4f6062020-05-29 16:51:21 -04002402##################################################
2403# SafeStack
2404
2405
2406if test "$safe_stack" = "yes"; then
2407cat > $TMPC << EOF
2408int main(int argc, char *argv[])
2409{
2410#if ! __has_feature(safe_stack)
2411#error SafeStack Disabled
2412#endif
2413 return 0;
2414}
2415EOF
2416 flag="-fsanitize=safe-stack"
2417 # Check that safe-stack is supported and enabled.
2418 if compile_prog "-Werror $flag" "$flag"; then
2419 # Flag needed both at compilation and at linking
2420 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
2421 QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
2422 else
2423 error_exit "SafeStack not supported by your compiler"
2424 fi
2425 if test "$coroutine" != "ucontext"; then
2426 error_exit "SafeStack is only supported by the coroutine backend ucontext"
2427 fi
2428else
2429cat > $TMPC << EOF
2430int main(int argc, char *argv[])
2431{
2432#if defined(__has_feature)
2433#if __has_feature(safe_stack)
2434#error SafeStack Enabled
2435#endif
2436#endif
2437 return 0;
2438}
2439EOF
2440if test "$safe_stack" = "no"; then
2441 # Make sure that safe-stack is disabled
2442 if ! compile_prog "-Werror" ""; then
2443 # SafeStack was already enabled, try to explicitly remove the feature
2444 flag="-fno-sanitize=safe-stack"
2445 if ! compile_prog "-Werror $flag" "$flag"; then
2446 error_exit "Configure cannot disable SafeStack"
2447 fi
2448 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
2449 QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
2450 fi
2451else # "$safe_stack" = ""
2452 # Set safe_stack to yes or no based on pre-existing flags
2453 if compile_prog "-Werror" ""; then
2454 safe_stack="no"
2455 else
2456 safe_stack="yes"
2457 if test "$coroutine" != "ucontext"; then
2458 error_exit "SafeStack is only supported by the coroutine backend ucontext"
2459 fi
2460 fi
2461fi
2462fi
Peter Lieven7d992e42016-09-27 11:58:45 +02002463
Richard Henderson76a347e2012-12-28 14:17:02 -08002464########################################
John Snowfd0e6052015-03-25 18:57:39 -04002465# check if ccache is interfering with
2466# semantic analysis of macros
2467
John Snow5e4dfd32015-10-28 13:56:40 -04002468unset CCACHE_CPP2
John Snowfd0e6052015-03-25 18:57:39 -04002469ccache_cpp2=no
2470cat > $TMPC << EOF
2471static const int Z = 1;
2472#define fn() ({ Z; })
2473#define TAUT(X) ((X) == Z)
2474#define PAREN(X, Y) (X == Y)
2475#define ID(X) (X)
2476int main(int argc, char *argv[])
2477{
2478 int x = 0, y = 0;
2479 x = ID(x);
2480 x = fn();
2481 fn();
2482 if (PAREN(x, y)) return 0;
2483 if (TAUT(Z)) return 0;
2484 return 0;
2485}
2486EOF
2487
2488if ! compile_object "-Werror"; then
2489 ccache_cpp2=yes
2490fi
2491
John Snowb553a042015-11-03 15:43:42 -05002492#################################################
2493# clang does not support glibc + FORTIFY_SOURCE.
2494
2495if test "$fortify_source" != "no"; then
2496 if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
2497 fortify_source="no";
Peter Maydelle1890912017-06-26 16:25:24 +01002498 elif test -n "$cxx" && has $cxx &&
John Snowcfcc7c12015-11-12 11:29:49 -05002499 echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
John Snowb553a042015-11-03 15:43:42 -05002500 fortify_source="no";
2501 else
2502 fortify_source="yes"
2503 fi
2504fi
2505
Aneesh Kumar K.Vd2042372011-10-12 19:11:24 +05302506##########################################
Marc-André Lureau247724c2018-01-16 16:11:51 +01002507# checks for sanitizers
2508
Marc-André Lureau247724c2018-01-16 16:11:51 +01002509have_asan=no
2510have_ubsan=no
Marc-André Lureaud83414e2018-01-16 16:11:52 +01002511have_asan_iface_h=no
2512have_asan_iface_fiber=no
Marc-André Lureau247724c2018-01-16 16:11:51 +01002513
2514if test "$sanitizers" = "yes" ; then
Marc-André Lureaub9f44da2018-02-15 22:25:47 +01002515 write_c_skeleton
Marc-André Lureau247724c2018-01-16 16:11:51 +01002516 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
2517 have_asan=yes
2518 fi
Marc-André Lureaub9f44da2018-02-15 22:25:47 +01002519
2520 # we could use a simple skeleton for flags checks, but this also
2521 # detect the static linking issue of ubsan, see also:
2522 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
2523 cat > $TMPC << EOF
2524#include <stdlib.h>
2525int main(void) {
2526 void *tmp = malloc(10);
Leonid Blochf2dfe542020-05-25 01:12:04 +03002527 if (tmp != NULL) {
2528 return *(int *)(tmp + 2);
2529 }
Olaf Heringd1abf3f2020-07-07 19:13:25 +02002530 return 1;
Marc-André Lureaub9f44da2018-02-15 22:25:47 +01002531}
2532EOF
Marc-André Lureau247724c2018-01-16 16:11:51 +01002533 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
2534 have_ubsan=yes
2535 fi
Marc-André Lureaud83414e2018-01-16 16:11:52 +01002536
2537 if check_include "sanitizer/asan_interface.h" ; then
2538 have_asan_iface_h=yes
2539 fi
2540
2541 cat > $TMPC << EOF
2542#include <sanitizer/asan_interface.h>
2543int main(void) {
2544 __sanitizer_start_switch_fiber(0, 0, 0);
2545 return 0;
2546}
2547EOF
2548 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
2549 have_asan_iface_fiber=yes
2550 fi
Marc-André Lureau247724c2018-01-16 16:11:51 +01002551fi
2552
Lingfeng Yang0aebab02020-06-12 20:02:23 +01002553# Thread sanitizer is, for now, much noisier than the other sanitizers;
2554# keep it separate until that is not the case.
2555if test "$tsan" = "yes" && test "$sanitizers" = "yes"; then
2556 error_exit "TSAN is not supported with other sanitiziers."
2557fi
2558have_tsan=no
2559have_tsan_iface_fiber=no
2560if test "$tsan" = "yes" ; then
2561 write_c_skeleton
2562 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
2563 have_tsan=yes
2564 fi
2565 cat > $TMPC << EOF
2566#include <sanitizer/tsan_interface.h>
2567int main(void) {
2568 __tsan_create_fiber(0);
2569 return 0;
2570}
2571EOF
2572 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
2573 have_tsan_iface_fiber=yes
2574 fi
2575fi
2576
Alexander Bulekovadc28022020-02-19 23:11:14 -05002577##########################################
Marc-André Lureau675b9b52019-02-12 17:25:23 +01002578# check for slirp
2579
2580case "$slirp" in
Paolo Bonzini4d34a862020-10-05 11:31:15 +02002581 auto | enabled | internal)
2582 # Simpler to always update submodule, even if not needed.
Paolo Bonzini2d652f22021-05-12 09:21:56 +02002583 git_submodules="${git_submodules} slirp"
Marc-André Lureau675b9b52019-02-12 17:25:23 +01002584 ;;
2585esac
2586
Alexey Krasikov54e7aac2020-05-25 14:19:12 +03002587##########################################
2588# check for usable __NR_keyctl syscall
2589
2590if test "$linux" = "yes" ; then
2591
2592 have_keyring=no
2593 cat > $TMPC << EOF
2594#include <errno.h>
2595#include <asm/unistd.h>
2596#include <linux/keyctl.h>
2597#include <unistd.h>
2598int main(void) {
2599 return syscall(__NR_keyctl, KEYCTL_READ, 0, NULL, NULL, 0);
2600}
2601EOF
2602 if compile_prog "" "" ; then
2603 have_keyring=yes
2604 fi
2605fi
2606if test "$secret_keyring" != "no"
2607then
David Edmondsonb418d262020-07-01 14:56:15 +01002608 if test "$have_keyring" = "yes"
Alexey Krasikov54e7aac2020-05-25 14:19:12 +03002609 then
2610 secret_keyring=yes
2611 else
2612 if test "$secret_keyring" = "yes"
2613 then
2614 error_exit "syscall __NR_keyctl requested, \
2615but not implemented on your system"
2616 else
2617 secret_keyring=no
2618 fi
2619 fi
2620fi
2621
Alexey Krasikov92500362020-05-25 14:19:13 +03002622##########################################
Juan Quintelae86ecd42009-08-03 14:45:59 +02002623# End of CC checks
2624# After here, no more $cc or $ld runs
2625
Marc-André Lureaud83414e2018-01-16 16:11:52 +01002626write_c_skeleton
2627
Paolo Bonzinidf42fa72022-04-20 17:33:38 +02002628if test "$fortify_source" = "yes" ; then
Paolo Bonzini086d5f72020-02-03 15:22:17 +01002629 QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
2630 debug=no
2631fi
Paolo Bonzini086d5f72020-02-03 15:22:17 +01002632
2633case "$ARCH" in
2634alpha)
2635 # Ensure there's only a single GP
2636 QEMU_CFLAGS="-msmall-data $QEMU_CFLAGS"
2637;;
2638esac
2639
Marc-André Lureau247724c2018-01-16 16:11:51 +01002640if test "$have_asan" = "yes"; then
Paolo Bonzinidb5adea2019-12-11 15:34:27 +01002641 QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS"
2642 QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS"
Marc-André Lureaud83414e2018-01-16 16:11:52 +01002643 if test "$have_asan_iface_h" = "no" ; then
2644 echo "ASAN build enabled, but ASAN header missing." \
2645 "Without code annotation, the report may be inferior."
2646 elif test "$have_asan_iface_fiber" = "no" ; then
2647 echo "ASAN build enabled, but ASAN header is too old." \
2648 "Without code annotation, the report may be inferior."
2649 fi
Marc-André Lureau247724c2018-01-16 16:11:51 +01002650fi
Lingfeng Yang0aebab02020-06-12 20:02:23 +01002651if test "$have_tsan" = "yes" ; then
2652 if test "$have_tsan_iface_fiber" = "yes" ; then
2653 QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS"
2654 QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS"
2655 else
2656 error_exit "Cannot enable TSAN due to missing fiber annotation interface."
2657 fi
2658elif test "$tsan" = "yes" ; then
2659 error_exit "Cannot enable TSAN due to missing sanitize thread interface."
2660fi
Marc-André Lureau247724c2018-01-16 16:11:51 +01002661if test "$have_ubsan" = "yes"; then
Paolo Bonzinidb5adea2019-12-11 15:34:27 +01002662 QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS"
2663 QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS"
Marc-André Lureau247724c2018-01-16 16:11:51 +01002664fi
2665
Peter Lieven6542aa92014-02-03 10:26:13 +01002666##########################################
Tomáš Golembiovský3efac6e2018-10-23 13:23:10 +02002667
Lingfeng Yang0aebab02020-06-12 20:02:23 +01002668# Exclude --warn-common with TSan to suppress warnings from the TSan libraries.
2669if test "$solaris" = "no" && test "$tsan" = "no"; then
Juan Quintelae86ecd42009-08-03 14:45:59 +02002670 if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
Paolo Bonzinidb5adea2019-12-11 15:34:27 +01002671 QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS"
Juan Quintelae86ecd42009-08-03 14:45:59 +02002672 fi
2673fi
2674
Blue Swirl952afb72010-09-19 08:36:34 +00002675# Use ASLR, no-SEH and DEP if available
2676if test "$mingw32" = "yes" ; then
Mark Cave-Aylandcb8baa72020-10-05 14:34:34 +01002677 flags="--no-seh --nxcompat"
2678
2679 # Disable ASLR for debug builds to allow debugging with gdb
2680 if test "$debug" = "no" ; then
2681 flags="--dynamicbase $flags"
2682 fi
2683
2684 for flag in $flags; do
Christian Borntraegere9a35912017-08-23 12:16:23 +02002685 if ld_has $flag ; then
Paolo Bonzinidb5adea2019-12-11 15:34:27 +01002686 QEMU_LDFLAGS="-Wl,$flag $QEMU_LDFLAGS"
Blue Swirl952afb72010-09-19 08:36:34 +00002687 fi
2688 done
2689fi
2690
Paolo Bonzinib846ab72021-01-21 11:49:04 +01002691# Guest agent Windows MSI package
Michael Roth9d6bc272015-08-26 10:49:13 -05002692
Paolo Bonzinib846ab72021-01-21 11:49:04 +01002693if test "$QEMU_GA_MANUFACTURER" = ""; then
2694 QEMU_GA_MANUFACTURER=QEMU
2695fi
2696if test "$QEMU_GA_DISTRO" = ""; then
2697 QEMU_GA_DISTRO=Linux
2698fi
2699if test "$QEMU_GA_VERSION" = ""; then
2700 QEMU_GA_VERSION=$(cat $source_path/VERSION)
Michael Roth9d6bc272015-08-26 10:49:13 -05002701fi
2702
Paolo Bonzini6e444202022-04-20 17:33:36 +02002703QEMU_GA_MSI_MINGW_BIN_PATH="$($pkg_config --variable=prefix glib-2.0)/bin"
Michael Roth9d6bc272015-08-26 10:49:13 -05002704
Paolo Bonzinica35f782010-05-26 16:08:29 +02002705# Mac OS X ships with a broken assembler
2706roms=
Eric Blakee633a5c2019-02-04 20:39:37 -06002707if { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \
Paolo Bonziniba7c60c2021-11-08 14:47:54 +01002708 test "$targetos" != "darwin" && test "$targetos" != "sunos" && \
2709 test "$targetos" != "haiku" && test "$softmmu" = yes ; then
Peter Maydelle57218b2016-08-08 17:11:28 +01002710 # Different host OS linkers have different ideas about the name of the ELF
Brad Smithc65d5e42017-11-07 18:46:11 -05002711 # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
2712 # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
2713 for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
Peter Maydelle57218b2016-08-08 17:11:28 +01002714 if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
2715 ld_i386_emulation="$emu"
2716 roms="optionrom"
2717 break
2718 fi
2719 done
Paolo Bonzinica35f782010-05-26 16:08:29 +02002720fi
Paolo Bonzinica35f782010-05-26 16:08:29 +02002721
Thomas Huth2e33c3f2019-01-14 13:52:26 +01002722# Only build s390-ccw bios if we're on s390x and the compiler has -march=z900
Thomas Hutha5b2afd2021-05-02 13:22:21 +02002723# or -march=z10 (which is the lowest architecture level that Clang supports)
Christian Borntraeger9933c302013-04-23 01:23:03 +00002724if test "$cpu" = "s390x" ; then
Thomas Huth2e33c3f2019-01-14 13:52:26 +01002725 write_c_skeleton
Thomas Hutha5b2afd2021-05-02 13:22:21 +02002726 compile_prog "-march=z900" ""
2727 has_z900=$?
Thomas Huth3af448b2021-05-25 16:20:32 +02002728 if [ $has_z900 = 0 ] || compile_object "-march=z10 -msoft-float -Werror"; then
Thomas Hutha5b2afd2021-05-02 13:22:21 +02002729 if [ $has_z900 != 0 ]; then
2730 echo "WARNING: Your compiler does not support the z900!"
2731 echo " The s390-ccw bios will only work with guest CPUs >= z10."
2732 fi
Thomas Huth2e33c3f2019-01-14 13:52:26 +01002733 roms="$roms s390-ccw"
Philippe Mathieu-Daudé1ef6bfc2020-06-15 09:49:19 +02002734 # SLOF is required for building the s390-ccw firmware on s390x,
2735 # since it is using the libnet code from SLOF for network booting.
Paolo Bonzini2d652f22021-05-12 09:21:56 +02002736 git_submodules="${git_submodules} roms/SLOF"
Thomas Huth2e33c3f2019-01-14 13:52:26 +01002737 fi
Christian Borntraeger9933c302013-04-23 01:23:03 +00002738fi
2739
Bruno Dominguez11cde1c2017-06-06 14:07:47 +01002740# Check that the C++ compiler exists and works with the C compiler.
2741# All the QEMU_CXXFLAGS are based on QEMU_CFLAGS. Keep this at the end to don't miss any other that could be added.
2742if has $cxx; then
2743 cat > $TMPC <<EOF
2744int c_function(void);
2745int main(void) { return c_function(); }
2746EOF
2747
2748 compile_object
2749
2750 cat > $TMPCXX <<EOF
2751extern "C" {
2752 int c_function(void);
2753}
2754int c_function(void) { return 42; }
2755EOF
2756
2757 update_cxxflags
2758
Paolo Bonzinia2866662021-11-05 10:09:26 +01002759 if do_cxx $CXXFLAGS $EXTRA_CXXFLAGS $CONFIGURE_CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then
Bruno Dominguez11cde1c2017-06-06 14:07:47 +01002760 # C++ compiler $cxx works ok with C compiler $cc
2761 :
2762 else
2763 echo "C++ compiler $cxx does not work with C compiler $cc"
2764 echo "Disabling C++ specific optional code"
2765 cxx=
2766 fi
2767else
2768 echo "No C++ compiler available; disabling C++ specific optional code"
2769 cxx=
2770fi
2771
Dan Streetman7d7dbf92021-01-19 12:20:46 -05002772if !(GIT="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then
2773 exit 1
Yonggang Luo5d91a2e2020-09-03 01:00:49 +08002774fi
Yonggang Luo5d91a2e2020-09-03 01:00:49 +08002775
Juan Quintela98ec69a2009-07-16 18:34:18 +02002776config_host_mak="config-host.mak"
bellard97a847b2003-08-10 21:36:04 +00002777
Juan Quintela98ec69a2009-07-16 18:34:18 +02002778echo "# Automatically generated by configure - do not modify" > $config_host_mak
Juan Quintela98ec69a2009-07-16 18:34:18 +02002779echo >> $config_host_mak
Juan Quintela98ec69a2009-07-16 18:34:18 +02002780
Paolo Bonzinie6c3b0f2010-10-21 10:18:35 +02002781echo all: >> $config_host_mak
Daniel P. Berrangecc84d632017-10-20 15:02:43 +01002782echo "GIT=$git" >> $config_host_mak
Daniel P. Berrangeaef45d52017-09-29 11:11:56 +01002783echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
Dan Streetman7d7dbf92021-01-19 12:20:46 -05002784echo "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak
Juan Quintela804edf22009-07-27 16:12:49 +02002785
aurel32f8393942009-04-13 18:45:38 +00002786if test "$debug_tcg" = "yes" ; then
Juan Quintela2358a492009-07-27 16:13:25 +02002787 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
aurel32f8393942009-04-13 18:45:38 +00002788fi
bellard67b915a2004-03-31 23:37:16 +00002789if test "$mingw32" = "yes" ; then
Juan Quintela98ec69a2009-07-16 18:34:18 +02002790 echo "CONFIG_WIN32=y" >> $config_host_mak
Paolo Bonzini6e444202022-04-20 17:33:36 +02002791 echo "QEMU_GA_MSI_MINGW_BIN_PATH=${QEMU_GA_MSI_MINGW_BIN_PATH}" >> $config_host_mak
Paolo Bonzinib846ab72021-01-21 11:49:04 +01002792 echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
2793 echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
2794 echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
pbrook210fa552007-02-27 21:04:49 +00002795else
Juan Quintela35f4df22009-07-27 16:13:07 +02002796 echo "CONFIG_POSIX=y" >> $config_host_mak
bellard67b915a2004-03-31 23:37:16 +00002797fi
blueswir1128ab2f2008-08-15 18:33:42 +00002798
Mark McLoughlindffcb712009-10-22 17:49:11 +01002799if test "$linux" = "yes" ; then
2800 echo "CONFIG_LINUX=y" >> $config_host_mak
2801fi
2802
bellard83fb7ad2004-07-05 21:25:26 +00002803if test "$darwin" = "yes" ; then
Juan Quintela98ec69a2009-07-16 18:34:18 +02002804 echo "CONFIG_DARWIN=y" >> $config_host_mak
bellard83fb7ad2004-07-05 21:25:26 +00002805fi
malcb29fe3e2008-11-18 01:42:22 +00002806
bellardec530c82006-04-25 22:36:06 +00002807if test "$solaris" = "yes" ; then
Juan Quintela98ec69a2009-07-16 18:34:18 +02002808 echo "CONFIG_SOLARIS=y" >> $config_host_mak
bellardec530c82006-04-25 22:36:06 +00002809fi
bellard97a847b2003-08-10 21:36:04 +00002810if test "$static" = "yes" ; then
Juan Quintela98ec69a2009-07-16 18:34:18 +02002811 echo "CONFIG_STATIC=y" >> $config_host_mak
bellard97a847b2003-08-10 21:36:04 +00002812fi
Fam Zhengb64ec4e2013-05-29 19:35:40 +08002813echo "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
2814echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
Stefan Weil89138852016-05-16 15:10:20 +02002815qemu_version=$(head $source_path/VERSION)
Juan Quintela2358a492009-07-27 16:13:25 +02002816echo "PKGVERSION=$pkgversion" >>$config_host_mak
Juan Quintela98ec69a2009-07-16 18:34:18 +02002817echo "SRC_PATH=$source_path" >> $config_host_mak
Alex Bennée2b1f35b2018-07-04 07:30:11 +01002818echo "TARGET_DIRS=$target_list" >> $config_host_mak
Fam Zheng17969262014-02-10 14:48:56 +08002819if test "$modules" = "yes"; then
Fam Zhenge26110c2014-02-10 14:48:57 +08002820 # $shacmd can generate a hash started with digit, which the compiler doesn't
2821 # like as an symbol. So prefix it with an underscore
Stefan Weil89138852016-05-16 15:10:20 +02002822 echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
Fam Zheng17969262014-02-10 14:48:56 +08002823 echo "CONFIG_MODULES=y" >> $config_host_mak
2824fi
Christian Ehrhardtbd83c862020-03-10 15:58:06 +01002825if test "$module_upgrades" = "yes"; then
2826 echo "CONFIG_MODULE_UPGRADES=y" >> $config_host_mak
2827fi
Cortland Tölva955727d2018-10-08 09:35:19 -07002828if test "$have_usbfs" = "yes" ; then
2829 echo "CONFIG_USBFS=y" >> $config_host_mak
2830fi
Marc-André Lureauf876b762019-02-21 12:07:00 +01002831if test "$gio" = "yes" ; then
2832 echo "CONFIG_GIO=y" >> $config_host_mak
2833 echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak
2834 echo "GIO_LIBS=$gio_libs" >> $config_host_mak
Paolo Bonzini5ecfb762021-05-05 10:15:34 -04002835fi
2836if test "$gdbus_codegen" != "" ; then
Marc-André Lureau25a97a52019-09-27 11:34:42 +04002837 echo "GDBUS_CODEGEN=$gdbus_codegen" >> $config_host_mak
Marc-André Lureauf876b762019-02-21 12:07:00 +01002838fi
Daniel P. Berrangea1c5e942016-06-06 10:05:06 +01002839echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
Jan Vesely277abf12016-04-29 13:15:23 -04002840
Paolo Bonzini1badb702020-09-18 04:57:25 -04002841if test "$xen" = "enabled" ; then
Jan Kiszka6dbd5882011-06-21 22:59:07 +02002842 echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
Anthony PERARDd5b93dd2011-02-25 16:20:34 +00002843 echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
Marc-André Lureau582ea952019-08-15 15:15:32 +04002844 echo "XEN_CFLAGS=$xen_cflags" >> $config_host_mak
2845 echo "XEN_LIBS=$xen_libs" >> $config_host_mak
aliguorie37630c2009-04-22 15:19:10 +00002846fi
Nicholas Bellinger5e9be922013-03-29 01:08:16 +00002847if test "$vhost_scsi" = "yes" ; then
2848 echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
2849fi
Paolo Bonziniaf3bba72019-02-14 18:35:52 +01002850if test "$vhost_net" = "yes" ; then
2851 echo "CONFIG_VHOST_NET=y" >> $config_host_mak
2852fi
2853if test "$vhost_net_user" = "yes" ; then
Paolo Bonzini56f41de2019-02-14 18:35:49 +01002854 echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak
Nikolay Nikolaev03ce5742014-06-10 13:02:16 +03002855fi
Cindy Lu108a6482020-07-01 22:55:37 +08002856if test "$vhost_net_vdpa" = "yes" ; then
2857 echo "CONFIG_VHOST_NET_VDPA=y" >> $config_host_mak
2858fi
Gonglei042cea22018-03-01 21:46:28 +08002859if test "$vhost_crypto" = "yes" ; then
2860 echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
2861fi
Stefan Hajnoczifc0b9b02016-08-16 13:27:22 +01002862if test "$vhost_vsock" = "yes" ; then
2863 echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
Stefano Garzarella5fe97d82020-05-22 14:25:11 +02002864 if test "$vhost_user" = "yes" ; then
2865 echo "CONFIG_VHOST_USER_VSOCK=y" >> $config_host_mak
2866 fi
Stefan Hajnoczifc0b9b02016-08-16 13:27:22 +01002867fi
Paolo Bonzini299e6f12019-02-14 18:35:53 +01002868if test "$vhost_kernel" = "yes" ; then
2869 echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak
2870fi
Marc-André Lureaue6a74862017-08-03 11:07:46 +02002871if test "$vhost_user" = "yes" ; then
2872 echo "CONFIG_VHOST_USER=y" >> $config_host_mak
2873fi
Cindy Lu108a6482020-07-01 22:55:37 +08002874if test "$vhost_vdpa" = "yes" ; then
2875 echo "CONFIG_VHOST_VDPA=y" >> $config_host_mak
2876fi
Dr. David Alan Gilbert98fc1ad2019-09-30 11:51:34 +01002877if test "$vhost_user_fs" = "yes" ; then
2878 echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak
2879fi
Gerd Hoffmann58d3f3f2021-05-19 07:39:32 +02002880
Gerd Hoffmannda076ff2014-11-20 09:49:44 +01002881if test "$opengl" = "yes" ; then
2882 echo "CONFIG_OPENGL=y" >> $config_host_mak
Paolo Bonzinide2d3002020-09-01 08:41:17 -04002883 echo "OPENGL_CFLAGS=$opengl_cflags" >> $config_host_mak
Gerd Hoffmannda076ff2014-11-20 09:49:44 +01002884 echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
Michael Walle20ff0752011-03-07 23:32:39 +01002885fi
2886
bellard83fb7ad2004-07-05 21:25:26 +00002887# XXX: suppress that
bellard7d3505c2004-05-12 19:32:15 +00002888if [ "$bsd" = "yes" ] ; then
Juan Quintela2358a492009-07-27 16:13:25 +02002889 echo "CONFIG_BSD=y" >> $config_host_mak
bellard7d3505c2004-05-12 19:32:15 +00002890fi
2891
Peter Maydell7c2acc72013-04-08 12:11:27 +01002892echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
Peter Lieven7d992e42016-09-27 11:58:45 +02002893
Marc-André Lureaud83414e2018-01-16 16:11:52 +01002894if test "$have_asan_iface_fiber" = "yes" ; then
2895 echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
2896fi
2897
Lingfeng Yang0aebab02020-06-12 20:02:23 +01002898if test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then
2899 echo "CONFIG_TSAN=y" >> $config_host_mak
2900fi
2901
Michael R. Hines2da776d2013-07-22 10:01:54 -04002902if test "$rdma" = "yes" ; then
2903 echo "CONFIG_RDMA=y" >> $config_host_mak
Fam Zheng392fb642017-09-07 16:42:30 +08002904 echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
Michael R. Hines2da776d2013-07-22 10:01:54 -04002905fi
2906
Marcel Apfelbaum21ab34c2018-08-16 18:16:37 +03002907if test "$pvrdma" = "yes" ; then
2908 echo "CONFIG_PVRDMA=y" >> $config_host_mak
2909fi
2910
Alex Bennée40e8c6f2019-06-13 14:52:25 +01002911if test "$plugins" = "yes" ; then
2912 echo "CONFIG_PLUGIN=y" >> $config_host_mak
Alex Bennée40e8c6f2019-06-13 14:52:25 +01002913fi
2914
Alex Bennéeb1863cc2021-01-08 22:42:39 +00002915if test -n "$gdb_bin"; then
2916 gdb_version=$($gdb_bin --version | head -n 1)
Alex Bennéed6a66c82021-02-02 13:39:53 +00002917 if version_ge ${gdb_version##* } 9.1; then
Alex Bennéeb1863cc2021-01-08 22:42:39 +00002918 echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
2919 fi
Alex Bennéef48e5902020-03-16 17:21:48 +00002920fi
2921
Alexey Krasikov54e7aac2020-05-25 14:19:12 +03002922if test "$secret_keyring" = "yes" ; then
2923 echo "CONFIG_SECRET_KEYRING=y" >> $config_host_mak
2924fi
2925
Juan Quintela98ec69a2009-07-16 18:34:18 +02002926echo "ROMS=$roms" >> $config_host_mak
Juan Quintela804edf22009-07-27 16:12:49 +02002927echo "MAKE=$make" >> $config_host_mak
Blue Swirlc886edf2011-07-22 21:08:09 +00002928echo "PYTHON=$python" >> $config_host_mak
Alex Bennée39d87c82020-03-03 15:06:20 +00002929echo "GENISOIMAGE=$genisoimage" >> $config_host_mak
Paolo Bonzinia5665052019-06-10 12:05:14 +02002930echo "MESON=$meson" >> $config_host_mak
Paolo Bonzini09e93322020-08-13 09:28:11 -04002931echo "NINJA=$ninja" >> $config_host_mak
Juan Quintela804edf22009-07-27 16:12:49 +02002932echo "CC=$cc" >> $config_host_mak
Juan Quintela804edf22009-07-27 16:12:49 +02002933echo "AR=$ar" >> $config_host_mak
Richard Hendersoncdbd7272016-07-07 21:49:36 -07002934echo "AS=$as" >> $config_host_mak
Richard Henderson5f6f0e22016-06-23 10:39:18 -07002935echo "CCAS=$ccas" >> $config_host_mak
Blue Swirl3dd46c72013-01-05 10:10:27 +00002936echo "CPP=$cpp" >> $config_host_mak
Juan Quintela804edf22009-07-27 16:12:49 +02002937echo "OBJCOPY=$objcopy" >> $config_host_mak
2938echo "LD=$ld" >> $config_host_mak
Brad46eef332013-12-10 19:49:08 -05002939echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
Juan Quintelaa558ee12009-08-03 14:46:21 +02002940echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
Bruno Dominguez11cde1c2017-06-06 14:07:47 +01002941echo "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
Philippe Mathieu-Daudé4cb37d12022-02-15 16:15:13 +01002942echo "QEMU_OBJCFLAGS=$QEMU_OBJCFLAGS" >> $config_host_mak
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002943echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
2944echo "GLIB_LIBS=$glib_libs" >> $config_host_mak
Marc-André Lureaud83acfd2021-10-09 17:37:40 +04002945echo "GLIB_VERSION=$(pkg-config --modversion glib-2.0)" >> $config_host_mak
Philippe Mathieu-Daudé8a99e9a2018-04-15 20:05:19 -03002946echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
Peter Maydelle57218b2016-08-08 17:11:28 +01002947echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
Paolo Bonzinia70248d2021-11-09 10:36:39 +01002948echo "STRIP=$strip" >> $config_host_mak
Juan Quintela804edf22009-07-27 16:12:49 +02002949echo "EXESUF=$EXESUF" >> $config_host_mak
Juan Quintela804edf22009-07-27 16:12:49 +02002950
Peter Maydell6efd7512011-11-30 11:59:04 +00002951# use included Linux headers
2952if test "$linux" = "yes" ; then
Andreas Färbera307beb2012-06-14 15:14:33 +00002953 mkdir -p linux-headers
Peter Maydell6efd7512011-11-30 11:59:04 +00002954 case "$cpu" in
Paolo Bonzini4da270b2021-11-09 09:36:10 +01002955 i386|x86_64)
Peter Maydell08312a62012-08-03 13:51:25 +01002956 linux_arch=x86
Peter Maydell6efd7512011-11-30 11:59:04 +00002957 ;;
Paolo Bonzinid8ff8922021-11-09 09:18:20 +01002958 ppc|ppc64)
Peter Maydell08312a62012-08-03 13:51:25 +01002959 linux_arch=powerpc
Peter Maydell6efd7512011-11-30 11:59:04 +00002960 ;;
2961 s390x)
Peter Maydell08312a62012-08-03 13:51:25 +01002962 linux_arch=s390
2963 ;;
Claudio Fontana1f080312013-06-12 16:20:23 +01002964 aarch64)
2965 linux_arch=arm64
2966 ;;
WANG Xueruidfcf9002021-12-21 13:41:04 +08002967 loongarch*)
2968 linux_arch=loongarch
2969 ;;
Sanjay Lal222e7d12014-06-17 23:10:36 +01002970 mips64)
2971 linux_arch=mips
2972 ;;
Peter Maydell08312a62012-08-03 13:51:25 +01002973 *)
2974 # For most CPUs the kernel architecture name and QEMU CPU name match.
2975 linux_arch="$cpu"
Peter Maydell6efd7512011-11-30 11:59:04 +00002976 ;;
2977 esac
Peter Maydell08312a62012-08-03 13:51:25 +01002978 # For non-KVM architectures we will not have asm headers
2979 if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
2980 symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
2981 fi
Peter Maydell6efd7512011-11-30 11:59:04 +00002982fi
2983
bellard1d14ffa2005-10-30 18:58:22 +00002984for target in $target_list; do
Paolo Bonzinifdb75ae2020-09-21 04:37:49 -04002985 target_dir="$target"
Philippe Mathieu-Daudé57a93f12021-11-09 15:45:04 +01002986 target_name=$(echo $target | cut -d '-' -f 1)$EXESUF
Paolo Bonzinifdb75ae2020-09-21 04:37:49 -04002987 mkdir -p $target_dir
2988 case $target in
2989 *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;;
2990 *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;;
2991 esac
2992done
bellard7d132992003-03-06 23:23:54 +00002993
Paolo Bonzini765686d2020-09-18 06:37:21 -04002994echo "CONFIG_QEMU_INTERP_PREFIX=$interp_prefix" | sed 's/%M/@0@/' >> $config_host_mak
Paolo Bonzinifdb75ae2020-09-21 04:37:49 -04002995if test "$default_targets" = "yes"; then
2996 echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak
2997fi
Peter Crosthwaitea540f152013-04-18 14:47:31 +10002998
John Snowfd0e6052015-03-25 18:57:39 -04002999if test "$ccache_cpp2" = "yes"; then
3000 echo "export CCACHE_CPP2=y" >> $config_host_mak
3001fi
3002
Daniele Buono1e4f6062020-05-29 16:51:21 -04003003if test "$safe_stack" = "yes"; then
3004 echo "CONFIG_SAFESTACK=y" >> $config_host_mak
3005fi
3006
Peter Maydelle29e5c62018-11-02 11:52:38 +00003007# If we're using a separate build tree, set it up now.
Peter Maydelle29e5c62018-11-02 11:52:38 +00003008# LINKS are things to symlink back into the source tree
3009# (these can be both files and directories).
3010# Caution: do not add files or directories here using wildcards. This
3011# will result in problems later if a new file matching the wildcard is
3012# added to the source tree -- nothing will cause configure to be rerun
3013# so the build tree will be missing the link back to the new file, and
3014# tests might fail. Prefer to keep the relevant files in their own
3015# directory and symlink the directory instead.
Paolo Bonzini2038f8c2019-08-07 16:35:23 +02003016LINKS="Makefile"
Paolo Bonzini39419962020-08-06 14:08:31 +02003017LINKS="$LINKS tests/tcg/Makefile.target"
Gerd Hoffmannddcf6072020-08-24 09:40:57 +02003018LINKS="$LINKS pc-bios/optionrom/Makefile"
Peter Maydelle29e5c62018-11-02 11:52:38 +00003019LINKS="$LINKS pc-bios/s390-ccw/Makefile"
Peter Maydelle29e5c62018-11-02 11:52:38 +00003020LINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
Willian Rampazzobbbd9b62021-11-05 12:53:54 -03003021LINKS="$LINKS tests/avocado tests/data"
Peter Maydell39950352018-11-02 11:52:39 +00003022LINKS="$LINKS tests/qemu-iotests/check"
Cleber Rosa8f8fd9e2019-02-06 11:29:01 -05003023LINKS="$LINKS python"
Alex Bennéec17a3862020-09-09 12:27:41 +01003024LINKS="$LINKS contrib/plugins/Makefile "
Richard Henderson753d11f2011-06-24 11:58:37 -07003025for bios_file in \
3026 $source_path/pc-bios/*.bin \
Bin Meng3a631b82020-06-22 13:09:32 +08003027 $source_path/pc-bios/*.elf \
Alexey Kardashevskiy225a9ab2016-10-26 13:18:03 +11003028 $source_path/pc-bios/*.lid \
Richard Henderson753d11f2011-06-24 11:58:37 -07003029 $source_path/pc-bios/*.rom \
3030 $source_path/pc-bios/*.dtb \
Dominik Dingele89e33e2013-04-29 04:52:06 +00003031 $source_path/pc-bios/*.img \
Richard Henderson753d11f2011-06-24 11:58:37 -07003032 $source_path/pc-bios/openbios-* \
Alexander Graf4e73c782014-01-20 00:25:40 +01003033 $source_path/pc-bios/u-boot.* \
John Arbucklecd946e52021-08-31 12:50:20 -04003034 $source_path/pc-bios/palcode-* \
3035 $source_path/pc-bios/qemu_vga.ndrv
3036
Richard Henderson753d11f2011-06-24 11:58:37 -07003037do
Peter Maydelle29e5c62018-11-02 11:52:38 +00003038 LINKS="$LINKS pc-bios/$(basename $bios_file)"
Paolo Bonzinid1807a42010-12-23 11:43:59 +01003039done
Peter Maydelle29e5c62018-11-02 11:52:38 +00003040for f in $LINKS ; do
Paolo Bonzini0f4d8892020-09-01 03:23:47 -04003041 if [ -e "$source_path/$f" ]; then
Paolo Bonzini5dce7b82021-10-13 13:56:24 +02003042 mkdir -p `dirname ./$f`
Peter Maydellf9245e12011-06-03 17:10:40 +01003043 symlink "$source_path/$f" "$f"
3044 fi
Paolo Bonzinid1807a42010-12-23 11:43:59 +01003045done
Paul Brook1ad21342009-05-19 16:17:58 +01003046
Paolo Bonzini2038f8c2019-08-07 16:35:23 +02003047(for i in $cross_cc_vars; do
3048 export $i
3049done
Paolo Bonzini544f4a22022-04-19 10:10:13 +01003050export target_list source_path use_containers cpu host_cc
Paolo Bonzini2038f8c2019-08-07 16:35:23 +02003051$source_path/tests/tcg/configure.sh)
3052
Helge Konetzka98409992021-09-15 12:56:34 +02003053config_mak=pc-bios/optionrom/config.mak
3054echo "# Automatically generated by configure - do not modify" > $config_mak
3055echo "TOPSRC_DIR=$source_path" >> $config_mak
3056
Paolo Bonzinia5665052019-06-10 12:05:14 +02003057if test "$skip_meson" = no; then
Paolo Bonzinid77e90f2021-03-16 08:19:34 +01003058 cross="config-meson.cross.new"
3059 meson_quote() {
Paolo Bonziniac7ebcc2021-11-05 10:07:37 +01003060 test $# = 0 && return
Paolo Bonzini47b30832020-09-23 05:26:17 -04003061 echo "'$(echo $* | sed "s/ /','/g")'"
Paolo Bonzinid77e90f2021-03-16 08:19:34 +01003062 }
Marc-André Lureaufc929892019-07-13 01:47:54 +04003063
Paolo Bonzinid77e90f2021-03-16 08:19:34 +01003064 echo "# Automatically generated by configure - do not modify" > $cross
3065 echo "[properties]" >> $cross
Alex Bennéed1d5e9e2021-07-07 14:17:44 +01003066
3067 # unroll any custom device configs
Alex Bennée11bdcfc2021-07-21 00:26:38 +01003068 for a in $device_archs; do
3069 eval "c=\$devices_${a}"
3070 echo "${a}-softmmu = '$c'" >> $cross
3071 done
Alex Bennéed1d5e9e2021-07-07 14:17:44 +01003072
Paolo Bonzinid77e90f2021-03-16 08:19:34 +01003073 test -z "$cxx" && echo "link_language = 'c'" >> $cross
3074 echo "[built-in options]" >> $cross
Paolo Bonzinia2866662021-11-05 10:09:26 +01003075 echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross
3076 echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross
Philippe Mathieu-Daudée910c7d2022-01-08 22:38:55 +01003077 test -n "$objcc" && echo "objc_args = [$(meson_quote $OBJCFLAGS $EXTRA_OBJCFLAGS)]" >> $cross
Paolo Bonzinia2866662021-11-05 10:09:26 +01003078 echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross
3079 echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross
Paolo Bonzinid77e90f2021-03-16 08:19:34 +01003080 echo "[binaries]" >> $cross
Paolo Bonzini4dba2782021-09-29 17:14:43 +02003081 echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross
3082 test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross
3083 test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross
Paolo Bonzinid77e90f2021-03-16 08:19:34 +01003084 echo "ar = [$(meson_quote $ar)]" >> $cross
3085 echo "nm = [$(meson_quote $nm)]" >> $cross
3086 echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross
3087 echo "ranlib = [$(meson_quote $ranlib)]" >> $cross
3088 if has $sdl2_config; then
3089 echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross
3090 fi
3091 echo "strip = [$(meson_quote $strip)]" >> $cross
3092 echo "windres = [$(meson_quote $windres)]" >> $cross
3093 if test "$cross_compile" = "yes"; then
Marc-André Lureaufc929892019-07-13 01:47:54 +04003094 cross_arg="--cross-file config-meson.cross"
Marc-André Lureaufc929892019-07-13 01:47:54 +04003095 echo "[host_machine]" >> $cross
Paolo Bonziniba7c60c2021-11-08 14:47:54 +01003096 echo "system = '$targetos'" >> $cross
Paolo Bonzini823eb012021-11-08 14:18:17 +01003097 case "$cpu" in
Joelle van Dynef6bca9d2021-01-25 17:24:54 -08003098 i386)
Marc-André Lureaufc929892019-07-13 01:47:54 +04003099 echo "cpu_family = 'x86'" >> $cross
3100 ;;
Marc-André Lureaufc929892019-07-13 01:47:54 +04003101 *)
Paolo Bonzini823eb012021-11-08 14:18:17 +01003102 echo "cpu_family = '$cpu'" >> $cross
Marc-André Lureaufc929892019-07-13 01:47:54 +04003103 ;;
3104 esac
3105 echo "cpu = '$cpu'" >> $cross
3106 if test "$bigendian" = "yes" ; then
3107 echo "endian = 'big'" >> $cross
3108 else
3109 echo "endian = 'little'" >> $cross
3110 fi
Paolo Bonzinid77e90f2021-03-16 08:19:34 +01003111 else
Marc-André Lureaufc929892019-07-13 01:47:54 +04003112 cross_arg="--native-file config-meson.cross"
Paolo Bonzinid77e90f2021-03-16 08:19:34 +01003113 fi
3114 mv $cross config-meson.cross
Marc-André Lureaufc929892019-07-13 01:47:54 +04003115
Paolo Bonzinid77e90f2021-03-16 08:19:34 +01003116 rm -rf meson-private meson-info meson-logs
Paolo Bonzini61d63092021-10-07 15:08:28 +02003117 run_meson() {
3118 NINJA=$ninja $meson setup \
Paolo Bonzinid17f3052020-08-18 12:17:01 +02003119 --prefix "$prefix" \
3120 --libdir "$libdir" \
3121 --libexecdir "$libexecdir" \
3122 --bindir "$bindir" \
3123 --includedir "$includedir" \
3124 --datadir "$datadir" \
3125 --mandir "$mandir" \
3126 --sysconfdir "$sysconfdir" \
Paolo Bonzini16bf7a32020-10-16 03:19:14 -04003127 --localedir "$localedir" \
Paolo Bonzinid17f3052020-08-18 12:17:01 +02003128 --localstatedir "$local_statedir" \
Paolo Bonzini3b4da132021-10-07 15:08:29 +02003129 -Daudio_drv_list=$audio_drv_list \
3130 -Ddefault_devices=$default_devices \
Paolo Bonzinid17f3052020-08-18 12:17:01 +02003131 -Ddocdir="$docdir" \
Paolo Bonzini5dc46182021-10-13 13:19:00 +02003132 -Diasl="$($iasl -h >/dev/null 2>&1 && printf %s "$iasl")" \
Paolo Bonzini16bf7a32020-10-16 03:19:14 -04003133 -Dqemu_firmwarepath="$firmwarepath" \
Marc-André Lureau73f3aa32020-08-26 15:04:15 +04003134 -Dqemu_suffix="$qemu_suffix" \
Paolo Bonzini35acbb32021-10-13 13:43:36 +02003135 -Dsmbd="$smbd" \
Paolo Bonzini3b4da132021-10-07 15:08:29 +02003136 -Dsphinx_build="$sphinx_build" \
3137 -Dtrace_file="$trace_file" \
Paolo Bonzinia5665052019-06-10 12:05:14 +02003138 -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) \
3139 -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo false; fi) \
3140 -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \
Marc-André Lureauda6d48b2019-09-17 15:39:36 +04003141 -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \
Marc-André Lureaubf0e56a2019-10-04 17:35:16 +04003142 -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \
Paolo Bonzini3b4da132021-10-07 15:08:29 +02003143 -Db_lto=$lto -Dcfi=$cfi -Dtcg=$tcg -Dxen=$xen \
3144 -Dcapstone=$capstone -Dfdt=$fdt -Dslirp=$slirp \
Paolo Bonzini537b7242021-10-07 15:08:12 +02003145 $(test -n "${LIB_FUZZING_ENGINE+xxx}" && echo "-Dfuzzing_engine=$LIB_FUZZING_ENGINE") \
Thomas Huth332008e2021-07-13 11:31:52 +02003146 $(if test "$default_feature" = no; then echo "-Dauto_features=disabled"; fi) \
Paolo Bonzini61d63092021-10-07 15:08:28 +02003147 "$@" $cross_arg "$PWD" "$source_path"
3148 }
3149 eval run_meson $meson_options
Paolo Bonzinid77e90f2021-03-16 08:19:34 +01003150 if test "$?" -ne 0 ; then
3151 error_exit "meson setup failed"
3152 fi
Paolo Bonzini699d3882021-03-16 08:27:40 +01003153else
3154 if test -f meson-private/cmd_line.txt; then
3155 # Adjust old command line options whose type was changed
3156 # Avoids having to use "setup --wipe" when Meson is upgraded
3157 perl -i -ne '
3158 s/^gettext = true$/gettext = auto/;
3159 s/^gettext = false$/gettext = disabled/;
Paolo Bonzini654d6b02021-02-09 14:59:26 +01003160 /^b_staticpic/ && next;
Paolo Bonzini699d3882021-03-16 08:27:40 +01003161 print;' meson-private/cmd_line.txt
3162 fi
Paolo Bonzinia5665052019-06-10 12:05:14 +02003163fi
3164
Michael S. Tsirkindc655402014-03-09 17:37:49 +02003165# Save the configure command line for later reuse.
3166cat <<EOD >config.status
3167#!/bin/sh
3168# Generated by configure.
3169# Run this file to recreate the current configuration.
3170# Compiler output produced by configure, useful for debugging
3171# configure, is in config.log if it exists.
3172EOD
Daniel P. Berrangée811da72018-09-04 13:36:03 +01003173
3174preserve_env() {
3175 envname=$1
3176
3177 eval envval=\$$envname
3178
3179 if test -n "$envval"
3180 then
3181 echo "$envname='$envval'" >> config.status
3182 echo "export $envname" >> config.status
3183 else
3184 echo "unset $envname" >> config.status
3185 fi
3186}
3187
3188# Preserve various env variables that influence what
3189# features/build target configure will detect
3190preserve_env AR
3191preserve_env AS
3192preserve_env CC
3193preserve_env CPP
Paolo Bonzini8009da02021-11-05 10:08:43 +01003194preserve_env CFLAGS
Daniel P. Berrangée811da72018-09-04 13:36:03 +01003195preserve_env CXX
Paolo Bonzini8009da02021-11-05 10:08:43 +01003196preserve_env CXXFLAGS
Daniel P. Berrangée811da72018-09-04 13:36:03 +01003197preserve_env INSTALL
3198preserve_env LD
Paolo Bonzini8009da02021-11-05 10:08:43 +01003199preserve_env LDFLAGS
Daniel P. Berrangée811da72018-09-04 13:36:03 +01003200preserve_env LD_LIBRARY_PATH
3201preserve_env LIBTOOL
3202preserve_env MAKE
3203preserve_env NM
3204preserve_env OBJCOPY
3205preserve_env PATH
3206preserve_env PKG_CONFIG
3207preserve_env PKG_CONFIG_LIBDIR
3208preserve_env PKG_CONFIG_PATH
3209preserve_env PYTHON
Daniel P. Berrangée811da72018-09-04 13:36:03 +01003210preserve_env SDL2_CONFIG
3211preserve_env SMBD
3212preserve_env STRIP
3213preserve_env WINDRES
3214
Michael S. Tsirkindc655402014-03-09 17:37:49 +02003215printf "exec" >>config.status
Paolo Bonzinia5665052019-06-10 12:05:14 +02003216for i in "$0" "$@"; do
Paolo Bonzini835af892020-09-08 13:20:45 +02003217 test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status
Paolo Bonzinia5665052019-06-10 12:05:14 +02003218done
Dr. David Alan Gilbertcf7cc922016-01-12 11:58:48 +00003219echo ' "$@"' >>config.status
Michael S. Tsirkindc655402014-03-09 17:37:49 +02003220chmod +x config.status
3221
Peter Maydell8cd05ab2014-05-23 17:07:24 +01003222rm -r "$TMPDIR1"