bellard | 7d13299 | 2003-03-06 23:23:54 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
bellard | 3ef693a | 2003-03-23 20:17:16 +0000 | [diff] [blame] | 3 | # qemu configure script (c) 2003 Fabrice Bellard |
bellard | 7d13299 | 2003-03-06 23:23:54 +0000 | [diff] [blame] | 4 | # |
Peter Maydell | 8cd05ab | 2014-05-23 17:07:24 +0100 | [diff] [blame] | 5 | |
Cornelia Huck | 99519e6 | 2014-05-28 12:39:17 +0200 | [diff] [blame] | 6 | # Unset some variables known to interfere with behavior of common tools, |
| 7 | # just as autoconf does. |
| 8 | CLICOLOR_FORCE= GREP_OPTIONS= |
| 9 | unset CLICOLOR_FORCE GREP_OPTIONS |
| 10 | |
John Snow | 5e4dfd3 | 2015-10-28 13:56:40 -0400 | [diff] [blame] | 11 | # Don't allow CCACHE, if present, to use cached results of compile tests! |
| 12 | export CCACHE_RECACHE=yes |
| 13 | |
Daniel P. Berrangé | dedad02 | 2020-08-21 12:22:04 +0200 | [diff] [blame] | 14 | # make source path absolute |
| 15 | source_path=$(cd "$(dirname -- "$0")"; pwd) |
| 16 | |
| 17 | if test "$PWD" = "$source_path" |
| 18 | then |
| 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 | |
| 41 | ifeq ($(MAKECMDGOALS),) |
| 42 | recurse: all |
| 43 | endif |
| 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 |
| 54 | force: ; |
| 55 | .PHONY: force |
| 56 | GNUmakefile: ; |
| 57 | |
| 58 | EOF |
| 59 | cd build |
| 60 | exec $source_path/configure "$@" |
| 61 | fi |
| 62 | |
Peter Maydell | 8cd05ab | 2014-05-23 17:07:24 +0100 | [diff] [blame] | 63 | # Temporary directory used for files created while |
| 64 | # configure runs. Since it is in the build directory |
| 65 | # we can safely blow away any previous version of it |
| 66 | # (and we need not jump through hoops to try to delete |
| 67 | # it when configure exits.) |
| 68 | TMPDIR1="config-temp" |
| 69 | rm -rf "${TMPDIR1}" |
| 70 | mkdir -p "${TMPDIR1}" |
| 71 | if [ $? -ne 0 ]; then |
| 72 | echo "ERROR: failed to create temporary directory" |
| 73 | exit 1 |
bellard | 7d13299 | 2003-03-06 23:23:54 +0000 | [diff] [blame] | 74 | fi |
| 75 | |
Peter Maydell | 8cd05ab | 2014-05-23 17:07:24 +0100 | [diff] [blame] | 76 | TMPB="qemu-conf" |
| 77 | TMPC="${TMPDIR1}/${TMPB}.c" |
Don Slutz | 66518bf | 2014-01-02 21:12:46 -0500 | [diff] [blame] | 78 | TMPO="${TMPDIR1}/${TMPB}.o" |
Peter Maydell | 9c83ffd | 2014-02-25 18:27:49 +0000 | [diff] [blame] | 79 | TMPCXX="${TMPDIR1}/${TMPB}.cxx" |
Philippe Mathieu-Daudé | 4cb37d1 | 2022-02-15 16:15:13 +0100 | [diff] [blame] | 80 | TMPM="${TMPDIR1}/${TMPB}.m" |
Peter Maydell | 8cd05ab | 2014-05-23 17:07:24 +0100 | [diff] [blame] | 81 | TMPE="${TMPDIR1}/${TMPB}.exe" |
bellard | 7d13299 | 2003-03-06 23:23:54 +0000 | [diff] [blame] | 82 | |
Gerd Hoffmann | da1d85e | 2010-04-23 13:44:10 +0200 | [diff] [blame] | 83 | rm -f config.log |
malc | 9ac81bb | 2008-11-29 20:09:56 +0000 | [diff] [blame] | 84 | |
Peter Maydell | b48e361 | 2011-11-23 17:26:44 +0000 | [diff] [blame] | 85 | # Print a helpful header at the top of config.log |
| 86 | echo "# QEMU configure log $(date)" >> config.log |
Peter Maydell | 979ae16 | 2012-03-07 12:16:29 +0000 | [diff] [blame] | 87 | printf "# Configured with:" >> config.log |
| 88 | printf " '%s'" "$0" "$@" >> config.log |
| 89 | echo >> config.log |
Peter Maydell | b48e361 | 2011-11-23 17:26:44 +0000 | [diff] [blame] | 90 | echo "#" >> config.log |
| 91 | |
Paolo Bonzini | 835af89 | 2020-09-08 13:20:45 +0200 | [diff] [blame] | 92 | quote_sh() { |
| 93 | printf "%s" "$1" | sed "s,','\\\\'',g; s,.*,'&'," |
| 94 | } |
| 95 | |
Paolo Bonzini | d880a3b | 2017-07-03 16:58:28 +0200 | [diff] [blame] | 96 | print_error() { |
| 97 | (echo |
Peter Maydell | 76ad07a | 2013-04-08 12:11:26 +0100 | [diff] [blame] | 98 | echo "ERROR: $1" |
| 99 | while test -n "$2"; do |
| 100 | echo " $2" |
| 101 | shift |
| 102 | done |
Paolo Bonzini | d880a3b | 2017-07-03 16:58:28 +0200 | [diff] [blame] | 103 | echo) >&2 |
| 104 | } |
| 105 | |
| 106 | error_exit() { |
| 107 | print_error "$@" |
Peter Maydell | 76ad07a | 2013-04-08 12:11:26 +0100 | [diff] [blame] | 108 | exit 1 |
| 109 | } |
| 110 | |
Peter Maydell | 9c83ffd | 2014-02-25 18:27:49 +0000 | [diff] [blame] | 111 | do_compiler() { |
| 112 | # Run the compiler, capturing its output to the log. First argument |
| 113 | # is compiler binary to execute. |
David CARLIER | 630d86b | 2020-07-18 14:19:10 +0100 | [diff] [blame] | 114 | compiler="$1" |
Peter Maydell | 9c83ffd | 2014-02-25 18:27:49 +0000 | [diff] [blame] | 115 | shift |
Ian Jackson | 8bbe05d | 2017-09-25 16:41:03 +0100 | [diff] [blame] | 116 | if test -n "$BASH_VERSION"; then eval ' |
| 117 | echo >>config.log " |
| 118 | funcs: ${FUNCNAME[*]} |
| 119 | lines: ${BASH_LINENO[*]}" |
| 120 | '; fi |
Peter Maydell | 9c83ffd | 2014-02-25 18:27:49 +0000 | [diff] [blame] | 121 | echo $compiler "$@" >> config.log |
| 122 | $compiler "$@" >> config.log 2>&1 || return $? |
Peter Maydell | 8dc38a7 | 2012-07-18 15:10:28 +0100 | [diff] [blame] | 123 | # 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 Maydell | 9c83ffd | 2014-02-25 18:27:49 +0000 | [diff] [blame] | 136 | echo $compiler -Werror "$@" >> config.log |
| 137 | $compiler -Werror "$@" >> config.log 2>&1 && return $? |
Peter Maydell | 76ad07a | 2013-04-08 12:11:26 +0100 | [diff] [blame] | 138 | 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 Maydell | 8dc38a7 | 2012-07-18 15:10:28 +0100 | [diff] [blame] | 142 | } |
| 143 | |
Peter Maydell | 9c83ffd | 2014-02-25 18:27:49 +0000 | [diff] [blame] | 144 | do_cc() { |
Paolo Bonzini | 4dba278 | 2021-09-29 17:14:43 +0200 | [diff] [blame] | 145 | do_compiler "$cc" $CPU_CFLAGS "$@" |
Peter Maydell | 9c83ffd | 2014-02-25 18:27:49 +0000 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | do_cxx() { |
Paolo Bonzini | 4dba278 | 2021-09-29 17:14:43 +0200 | [diff] [blame] | 149 | do_compiler "$cxx" $CPU_CFLAGS "$@" |
Peter Maydell | 9c83ffd | 2014-02-25 18:27:49 +0000 | [diff] [blame] | 150 | } |
| 151 | |
Philippe Mathieu-Daudé | 4cb37d1 | 2022-02-15 16:15:13 +0100 | [diff] [blame] | 152 | do_objc() { |
| 153 | do_compiler "$objcc" $CPU_CFLAGS "$@" |
| 154 | } |
| 155 | |
Richard Henderson | 00849b9 | 2020-06-17 13:13:06 -0700 | [diff] [blame] | 156 | # Append $2 to the variable named $1, with space separation |
| 157 | add_to() { |
| 158 | eval $1=\${$1:+\"\$$1 \"}\$2 |
| 159 | } |
| 160 | |
Peter Maydell | 9c83ffd | 2014-02-25 18:27:49 +0000 | [diff] [blame] | 161 | update_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 Bonzini | de38c0c | 2021-11-08 08:58:23 +0100 | [diff] [blame] | 165 | QEMU_CXXFLAGS="-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS" |
Richard Henderson | 8a9d3d5 | 2021-06-14 16:31:36 -0700 | [diff] [blame] | 166 | CONFIGURE_CXXFLAGS=$(echo "$CONFIGURE_CFLAGS" | sed s/-std=gnu11/-std=gnu++11/) |
Peter Maydell | 9c83ffd | 2014-02-25 18:27:49 +0000 | [diff] [blame] | 167 | 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 Quintela | 52166aa | 2009-08-03 14:46:03 +0200 | [diff] [blame] | 179 | compile_object() { |
John Snow | fd0e605 | 2015-03-25 18:57:39 -0400 | [diff] [blame] | 180 | local_cflags="$1" |
Paolo Bonzini | a286666 | 2021-11-05 10:09:26 +0100 | [diff] [blame] | 181 | do_cc $CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC |
Juan Quintela | 52166aa | 2009-08-03 14:46:03 +0200 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | compile_prog() { |
| 185 | local_cflags="$1" |
| 186 | local_ldflags="$2" |
Paolo Bonzini | a286666 | 2021-11-05 10:09:26 +0100 | [diff] [blame] | 187 | 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 Quintela | 52166aa | 2009-08-03 14:46:03 +0200 | [diff] [blame] | 189 | } |
| 190 | |
Paolo Bonzini | 11568d6 | 2010-12-23 11:43:58 +0100 | [diff] [blame] | 191 | # symbolically link $1 to $2. Portable version of "ln -sf". |
| 192 | symlink() { |
Stefan Weil | 72b8b5a | 2012-03-19 13:20:47 +0100 | [diff] [blame] | 193 | rm -rf "$2" |
Anthony Liguori | ec5b06d | 2012-06-06 16:57:00 +0800 | [diff] [blame] | 194 | mkdir -p "$(dirname "$2")" |
Stefan Weil | 72b8b5a | 2012-03-19 13:20:47 +0100 | [diff] [blame] | 195 | ln -s "$1" "$2" |
Paolo Bonzini | 11568d6 | 2010-12-23 11:43:58 +0100 | [diff] [blame] | 196 | } |
| 197 | |
Loïc Minier | 0dba619 | 2010-01-28 21:26:51 +0000 | [diff] [blame] | 198 | # check whether a command is available to this shell (may be either an |
| 199 | # executable or a builtin) |
| 200 | has() { |
| 201 | type "$1" >/dev/null 2>&1 |
| 202 | } |
| 203 | |
Marc-André Lureau | 0a01d76 | 2019-08-21 11:21:16 +0400 | [diff] [blame] | 204 | version_ge () { |
Alex Bennée | 2df52b9 | 2021-02-02 13:39:52 +0000 | [diff] [blame] | 205 | local_ver1=$(expr "$1" : '\([0-9.]*\)' | tr . ' ') |
| 206 | local_ver2=$(echo "$2" | tr . ' ') |
Marc-André Lureau | 0a01d76 | 2019-08-21 11:21:16 +0400 | [diff] [blame] | 207 | while true; do |
| 208 | set x $local_ver1 |
| 209 | local_first=${2-0} |
Stefano Garzarella | c44a33e | 2020-08-21 22:35:58 +0200 | [diff] [blame] | 210 | # 'shift 2' if $2 is set, or 'shift' if $2 is not set |
| 211 | shift ${2:+2} |
Marc-André Lureau | 0a01d76 | 2019-08-21 11:21:16 +0400 | [diff] [blame] | 212 | 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 Garzarella | c44a33e | 2020-08-21 22:35:58 +0200 | [diff] [blame] | 218 | shift ${2:+2} |
Marc-André Lureau | 0a01d76 | 2019-08-21 11:21:16 +0400 | [diff] [blame] | 219 | local_ver2=$* |
| 220 | done |
| 221 | } |
| 222 | |
Paolo Bonzini | 3b6b755 | 2012-09-17 11:59:41 +0200 | [diff] [blame] | 223 | glob() { |
| 224 | eval test -z '"${1#'"$2"'}"' |
| 225 | } |
| 226 | |
Christian Borntraeger | e9a3591 | 2017-08-23 12:16:23 +0200 | [diff] [blame] | 227 | ld_has() { |
| 228 | $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1 |
| 229 | } |
| 230 | |
Antonio Ospite | 4ace32e | 2019-05-26 16:47:47 +0200 | [diff] [blame] | 231 | if printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]"; |
| 232 | then |
| 233 | error_exit "main directory cannot contain spaces nor colons" |
| 234 | fi |
| 235 | |
Antonio Ospite | 1421182 | 2019-05-26 16:47:46 +0200 | [diff] [blame] | 236 | # default parameters |
Juan Quintela | 2ff6b91 | 2009-08-03 14:45:55 +0200 | [diff] [blame] | 237 | cpu="" |
Michael S. Tsirkin | a31a864 | 2013-07-24 18:56:03 +0300 | [diff] [blame] | 238 | iasl="iasl" |
bellard | 1e43adf | 2003-09-30 20:54:24 +0000 | [diff] [blame] | 239 | interp_prefix="/usr/gnemul/qemu-%M" |
bellard | 43ce4df | 2003-06-09 19:53:12 +0000 | [diff] [blame] | 240 | static="no" |
Joelle van Dyne | 3812c0c | 2021-01-25 17:24:48 -0800 | [diff] [blame] | 241 | cross_compile="no" |
bellard | 7d13299 | 2003-03-06 23:23:54 +0000 | [diff] [blame] | 242 | cross_prefix="" |
Paolo Bonzini | 87430d5 | 2021-10-07 15:06:09 +0200 | [diff] [blame] | 243 | audio_drv_list="default" |
Fam Zheng | b64ec4e | 2013-05-29 19:35:40 +0800 | [diff] [blame] | 244 | block_drv_rw_whitelist="" |
| 245 | block_drv_ro_whitelist="" |
Peter Maydell | e49d021 | 2012-12-07 15:39:13 +0000 | [diff] [blame] | 246 | host_cc="cc" |
Daniele Buono | cdad781 | 2020-12-04 18:06:11 -0500 | [diff] [blame] | 247 | lto="false" |
Steven Noonan | 63678e1 | 2014-03-28 17:19:02 +0100 | [diff] [blame] | 248 | stack_protector="" |
Daniele Buono | 1e4f606 | 2020-05-29 16:51:21 -0400 | [diff] [blame] | 249 | safe_stack="" |
Alex Bennée | afc3a8f | 2019-11-28 16:35:24 +0100 | [diff] [blame] | 250 | use_containers="yes" |
Alex Bennée | f238539 | 2020-04-30 20:01:14 +0100 | [diff] [blame] | 251 | gdb_bin=$(command -v "gdb-multiarch" || command -v "gdb") |
aliguori | ac0df51 | 2008-12-29 17:14:15 +0000 | [diff] [blame] | 252 | |
Daniel P. Berrange | 9271282 | 2017-09-29 11:11:58 +0100 | [diff] [blame] | 253 | if test -e "$source_path/.git" |
| 254 | then |
Dan Streetman | 7d7dbf9 | 2021-01-19 12:20:46 -0500 | [diff] [blame] | 255 | git_submodules_action="update" |
Daniel P. Berrange | 9271282 | 2017-09-29 11:11:58 +0100 | [diff] [blame] | 256 | else |
Dan Streetman | 7d7dbf9 | 2021-01-19 12:20:46 -0500 | [diff] [blame] | 257 | git_submodules_action="ignore" |
Daniel P. Berrange | 9271282 | 2017-09-29 11:11:58 +0100 | [diff] [blame] | 258 | fi |
Paolo Bonzini | 2d652f2 | 2021-05-12 09:21:56 +0200 | [diff] [blame] | 259 | |
| 260 | git_submodules="ui/keycodemapdb" |
Daniel P. Berrange | cc84d63 | 2017-10-20 15:02:43 +0100 | [diff] [blame] | 261 | git="git" |
aliguori | ac0df51 | 2008-12-29 17:14:15 +0000 | [diff] [blame] | 262 | |
Stefan Weil | afb63eb | 2012-09-26 22:04:38 +0200 | [diff] [blame] | 263 | # Don't accept a target_list environment variable. |
| 264 | unset target_list |
Alex Bennée | 447e133 | 2019-03-19 11:59:12 +0000 | [diff] [blame] | 265 | unset target_list_exclude |
Paolo Bonzini | 377529c | 2010-12-23 11:43:50 +0100 | [diff] [blame] | 266 | |
| 267 | # Default value for a variable defining feature "foo". |
| 268 | # * foo="no" feature will only be used if --enable-foo arg is given |
| 269 | # * foo="" feature will be searched for, and if found, will be used |
| 270 | # unless --disable-foo is given |
| 271 | # * foo="yes" this value will only be set by --enable-foo flag. |
| 272 | # feature will searched for, |
| 273 | # if not found, configure exits with error |
| 274 | # |
| 275 | # Always add --enable-foo and --disable-foo command line args. |
| 276 | # Distributions want to ensure that several features are compiled in, and it |
| 277 | # is impossible without a --enable-foo that exits if a feature is not found. |
| 278 | |
Alex Bennée | c87ea11 | 2020-12-10 19:04:13 +0000 | [diff] [blame] | 279 | default_feature="" |
| 280 | # parse CC options second |
| 281 | for opt do |
| 282 | optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') |
| 283 | case "$opt" in |
| 284 | --without-default-features) |
| 285 | default_feature="no" |
| 286 | ;; |
| 287 | esac |
| 288 | done |
| 289 | |
Paolo Bonzini | a286666 | 2021-11-05 10:09:26 +0100 | [diff] [blame] | 290 | EXTRA_CFLAGS="" |
| 291 | EXTRA_CXXFLAGS="" |
Philippe Mathieu-Daudé | e910c7d | 2022-01-08 22:38:55 +0100 | [diff] [blame] | 292 | EXTRA_OBJCFLAGS="" |
Paolo Bonzini | a286666 | 2021-11-05 10:09:26 +0100 | [diff] [blame] | 293 | EXTRA_LDFLAGS="" |
| 294 | |
Alex Bennée | c87ea11 | 2020-12-10 19:04:13 +0000 | [diff] [blame] | 295 | xen_ctrl_version="$default_feature" |
Thomas Huth | 0848f8a | 2021-07-13 11:31:55 +0200 | [diff] [blame] | 296 | vhost_kernel="$default_feature" |
Alex Bennée | c87ea11 | 2020-12-10 19:04:13 +0000 | [diff] [blame] | 297 | vhost_net="$default_feature" |
| 298 | vhost_crypto="$default_feature" |
| 299 | vhost_scsi="$default_feature" |
| 300 | vhost_vsock="$default_feature" |
Stefan Hajnoczi | d88618f | 2020-11-10 17:11:21 +0000 | [diff] [blame] | 301 | vhost_user="no" |
Alex Bennée | c87ea11 | 2020-12-10 19:04:13 +0000 | [diff] [blame] | 302 | vhost_user_fs="$default_feature" |
Thomas Huth | 0848f8a | 2021-07-13 11:31:55 +0200 | [diff] [blame] | 303 | vhost_vdpa="$default_feature" |
Paolo Bonzini | 2860974 | 2022-04-20 17:33:39 +0200 | [diff] [blame] | 304 | debug_info="yes" |
Paolo Bonzini | 377529c | 2010-12-23 11:43:50 +0100 | [diff] [blame] | 305 | debug_tcg="no" |
Paolo Bonzini | 377529c | 2010-12-23 11:43:50 +0100 | [diff] [blame] | 306 | debug="no" |
Marc-André Lureau | 247724c | 2018-01-16 16:11:51 +0100 | [diff] [blame] | 307 | sanitizers="no" |
Lingfeng Yang | 0aebab0 | 2020-06-12 20:02:23 +0100 | [diff] [blame] | 308 | tsan="no" |
Michael Tokarev | 1f3f2bf | 2022-04-22 13:08:25 +0300 | [diff] [blame] | 309 | fortify_source="yes" |
Blue Swirl | 1d728c3 | 2012-05-01 18:45:39 +0000 | [diff] [blame] | 310 | gcov="no" |
Miroslav Rezanina | c732827 | 2021-03-31 10:18:45 +0200 | [diff] [blame] | 311 | EXESUF="" |
Fam Zheng | 1796926 | 2014-02-10 14:48:56 +0800 | [diff] [blame] | 312 | modules="no" |
Paolo Bonzini | 377529c | 2010-12-23 11:43:50 +0100 | [diff] [blame] | 313 | prefix="/usr/local" |
Marc-André Lureau | 10ff82d | 2020-08-26 15:04:13 +0400 | [diff] [blame] | 314 | qemu_suffix="qemu" |
Paolo Bonzini | 377529c | 2010-12-23 11:43:50 +0100 | [diff] [blame] | 315 | softmmu="yes" |
Paolo Bonzini | b915a2f | 2021-11-09 10:10:41 +0100 | [diff] [blame] | 316 | linux_user="" |
| 317 | bsd_user="" |
Paolo Bonzini | 377529c | 2010-12-23 11:43:50 +0100 | [diff] [blame] | 318 | pkgversion="" |
Avi Kivity | 40d6444 | 2011-11-15 20:12:17 +0200 | [diff] [blame] | 319 | pie="" |
Paolo Bonzini | 377529c | 2010-12-23 11:43:50 +0100 | [diff] [blame] | 320 | trace_file="trace" |
Alex Barcelo | 519175a | 2012-02-28 12:25:50 +0100 | [diff] [blame] | 321 | coroutine="" |
Daniel P. Berrange | a1c5e94 | 2016-06-06 10:05:06 +0100 | [diff] [blame] | 322 | tls_priority="NORMAL" |
Alex Bennée | ba4dd2a | 2021-07-09 15:29:57 +0100 | [diff] [blame] | 323 | plugins="$default_feature" |
Paolo Bonzini | a566505 | 2019-06-10 12:05:14 +0200 | [diff] [blame] | 324 | meson="" |
Paolo Bonzini | 3b4da13 | 2021-10-07 15:08:29 +0200 | [diff] [blame] | 325 | meson_args="" |
Paolo Bonzini | 4832888 | 2020-08-26 08:04:15 +0200 | [diff] [blame] | 326 | ninja="" |
Paolo Bonzini | a566505 | 2019-06-10 12:05:14 +0200 | [diff] [blame] | 327 | skip_meson=no |
Paolo Bonzini | 377529c | 2010-12-23 11:43:50 +0100 | [diff] [blame] | 328 | |
Paolo Bonzini | 3b4da13 | 2021-10-07 15:08:29 +0200 | [diff] [blame] | 329 | # The following Meson options are handled manually (still they |
| 330 | # are included in the automatically generated help message) |
| 331 | |
| 332 | # 1. Track which submodules are needed |
Thomas Huth | 0577e84 | 2022-02-21 10:06:47 +0100 | [diff] [blame] | 333 | if test "$default_feature" = no ; then |
| 334 | capstone="disabled" |
| 335 | slirp="disabled" |
| 336 | else |
| 337 | capstone="auto" |
| 338 | slirp="auto" |
| 339 | fi |
Paolo Bonzini | 3b4da13 | 2021-10-07 15:08:29 +0200 | [diff] [blame] | 340 | fdt="auto" |
Paolo Bonzini | 3b4da13 | 2021-10-07 15:08:29 +0200 | [diff] [blame] | 341 | |
| 342 | # 2. Support --with/--without option |
| 343 | default_devices="true" |
| 344 | |
| 345 | # 3. Automatically enable/disable other options |
| 346 | tcg="enabled" |
| 347 | cfi="false" |
| 348 | |
| 349 | # 4. Detection partly done in configure |
| 350 | xen=${default_feature:+disabled} |
Peter Maydell | 898be3e | 2017-03-21 14:31:57 +0000 | [diff] [blame] | 351 | |
Alex Bennée | c87ea11 | 2020-12-10 19:04:13 +0000 | [diff] [blame] | 352 | # parse CC options second |
aliguori | ac0df51 | 2008-12-29 17:14:15 +0000 | [diff] [blame] | 353 | for opt do |
Stefan Weil | 8913885 | 2016-05-16 15:10:20 +0200 | [diff] [blame] | 354 | optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') |
aliguori | ac0df51 | 2008-12-29 17:14:15 +0000 | [diff] [blame] | 355 | case "$opt" in |
| 356 | --cross-prefix=*) cross_prefix="$optarg" |
Joelle van Dyne | 3812c0c | 2021-01-25 17:24:48 -0800 | [diff] [blame] | 357 | cross_compile="yes" |
aliguori | ac0df51 | 2008-12-29 17:14:15 +0000 | [diff] [blame] | 358 | ;; |
Paolo Bonzini | 3d8df64 | 2010-12-23 11:43:48 +0100 | [diff] [blame] | 359 | --cc=*) CC="$optarg" |
aliguori | ac0df51 | 2008-12-29 17:14:15 +0000 | [diff] [blame] | 360 | ;; |
Tomoki Sekiyama | 83f73fc | 2013-08-07 11:39:36 -0400 | [diff] [blame] | 361 | --cxx=*) CXX="$optarg" |
| 362 | ;; |
Juan Quintela | 2ff6b91 | 2009-08-03 14:45:55 +0200 | [diff] [blame] | 363 | --cpu=*) cpu="$optarg" |
| 364 | ;; |
Paolo Bonzini | a286666 | 2021-11-05 10:09:26 +0100 | [diff] [blame] | 365 | --extra-cflags=*) |
| 366 | EXTRA_CFLAGS="$EXTRA_CFLAGS $optarg" |
| 367 | EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" |
Philippe Mathieu-Daudé | e910c7d | 2022-01-08 22:38:55 +0100 | [diff] [blame] | 368 | EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg" |
Paolo Bonzini | a286666 | 2021-11-05 10:09:26 +0100 | [diff] [blame] | 369 | ;; |
| 370 | --extra-cxxflags=*) EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" |
Juan Quintela | e2a2ed0 | 2009-08-03 14:46:02 +0200 | [diff] [blame] | 371 | ;; |
Philippe Mathieu-Daudé | e910c7d | 2022-01-08 22:38:55 +0100 | [diff] [blame] | 372 | --extra-objcflags=*) EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg" |
| 373 | ;; |
Paolo Bonzini | a286666 | 2021-11-05 10:09:26 +0100 | [diff] [blame] | 374 | --extra-ldflags=*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS $optarg" |
Juan Quintela | e2a2ed0 | 2009-08-03 14:46:02 +0200 | [diff] [blame] | 375 | ;; |
Alex Bennée | d75402b | 2018-04-04 20:27:05 +0100 | [diff] [blame] | 376 | --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option" |
| 377 | ;; |
Matheus Ferst | 479ca4c | 2022-01-20 14:31:41 -0300 | [diff] [blame] | 378 | --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-cflags-}; cc_arch=${cc_arch%%=*} |
Alex Bennée | d422b2b | 2018-04-13 11:07:58 +0100 | [diff] [blame] | 379 | eval "cross_cc_cflags_${cc_arch}=\$optarg" |
Paolo Bonzini | 2038f8c | 2019-08-07 16:35:23 +0200 | [diff] [blame] | 380 | cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}" |
Alex Bennée | d422b2b | 2018-04-13 11:07:58 +0100 | [diff] [blame] | 381 | ;; |
Alex Bennée | d75402b | 2018-04-04 20:27:05 +0100 | [diff] [blame] | 382 | --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*} |
| 383 | eval "cross_cc_${cc_arch}=\$optarg" |
Paolo Bonzini | 2038f8c | 2019-08-07 16:35:23 +0200 | [diff] [blame] | 384 | cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}" |
Alex Bennée | d75402b | 2018-04-04 20:27:05 +0100 | [diff] [blame] | 385 | ;; |
aliguori | ac0df51 | 2008-12-29 17:14:15 +0000 | [diff] [blame] | 386 | esac |
| 387 | done |
aliguori | ac0df51 | 2008-12-29 17:14:15 +0000 | [diff] [blame] | 388 | # OS specific |
| 389 | # Using uname is really, really broken. Once we have the right set of checks |
Stefan Weil | 93148aa | 2012-02-26 18:46:12 +0100 | [diff] [blame] | 390 | # we can eliminate its usage altogether. |
aliguori | ac0df51 | 2008-12-29 17:14:15 +0000 | [diff] [blame] | 391 | |
Peter Maydell | e49d021 | 2012-12-07 15:39:13 +0000 | [diff] [blame] | 392 | # Preferred compiler: |
| 393 | # ${CC} (if set) |
| 394 | # ${cross_prefix}gcc (if cross-prefix specified) |
| 395 | # system compiler |
| 396 | if test -z "${CC}${cross_prefix}"; then |
| 397 | cc="$host_cc" |
| 398 | else |
| 399 | cc="${CC-${cross_prefix}gcc}" |
| 400 | fi |
| 401 | |
Tomoki Sekiyama | 83f73fc | 2013-08-07 11:39:36 -0400 | [diff] [blame] | 402 | if test -z "${CXX}${cross_prefix}"; then |
| 403 | cxx="c++" |
| 404 | else |
| 405 | cxx="${CXX-${cross_prefix}g++}" |
| 406 | fi |
| 407 | |
Stuart Yoder | b3198cc | 2011-08-04 17:10:08 -0500 | [diff] [blame] | 408 | ar="${AR-${cross_prefix}ar}" |
Richard Henderson | cdbd727 | 2016-07-07 21:49:36 -0700 | [diff] [blame] | 409 | as="${AS-${cross_prefix}as}" |
Richard Henderson | 5f6f0e2 | 2016-06-23 10:39:18 -0700 | [diff] [blame] | 410 | ccas="${CCAS-$cc}" |
Blue Swirl | 3dd46c7 | 2013-01-05 10:10:27 +0000 | [diff] [blame] | 411 | cpp="${CPP-$cc -E}" |
Stuart Yoder | b3198cc | 2011-08-04 17:10:08 -0500 | [diff] [blame] | 412 | objcopy="${OBJCOPY-${cross_prefix}objcopy}" |
| 413 | ld="${LD-${cross_prefix}ld}" |
Alistair Francis | 9f81aeb | 2017-11-07 17:10:46 -0800 | [diff] [blame] | 414 | ranlib="${RANLIB-${cross_prefix}ranlib}" |
Stefan Weil | 4852ee9 | 2014-09-18 21:55:08 +0200 | [diff] [blame] | 415 | nm="${NM-${cross_prefix}nm}" |
Paolo Bonzini | 35acbb3 | 2021-10-13 13:43:36 +0200 | [diff] [blame] | 416 | smbd="$SMBD" |
Stuart Yoder | b3198cc | 2011-08-04 17:10:08 -0500 | [diff] [blame] | 417 | strip="${STRIP-${cross_prefix}strip}" |
Konstantin Kostiuk | 158bb22 | 2022-04-28 21:15:25 +0300 | [diff] [blame^] | 418 | widl="${WIDL-${cross_prefix}widl}" |
Stuart Yoder | b3198cc | 2011-08-04 17:10:08 -0500 | [diff] [blame] | 419 | windres="${WINDRES-${cross_prefix}windres}" |
Sergei Trofimovich | 17884d7 | 2012-01-31 22:03:45 +0300 | [diff] [blame] | 420 | pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}" |
| 421 | query_pkg_config() { |
| 422 | "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@" |
| 423 | } |
| 424 | pkg_config=query_pkg_config |
Dave Airlie | 47c0374 | 2013-12-10 14:05:51 +1000 | [diff] [blame] | 425 | sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}" |
aliguori | ac0df51 | 2008-12-29 17:14:15 +0000 | [diff] [blame] | 426 | |
Michael S. Tsirkin | be17dc9 | 2009-11-11 13:50:09 +0200 | [diff] [blame] | 427 | # default flags for all hosts |
Peter Maydell | 2d31515 | 2016-09-12 14:10:08 +0100 | [diff] [blame] | 428 | # We use -fwrapv to tell the compiler that we require a C dialect where |
| 429 | # left shift of signed integers is well defined and has the expected |
| 430 | # 2s-complement style results. (Both clang and gcc agree that it |
| 431 | # provides these semantics.) |
Paolo Bonzini | de38c0c | 2021-11-08 08:58:23 +0100 | [diff] [blame] | 432 | QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv" |
Paolo Bonzini | 086d5f7 | 2020-02-03 15:22:17 +0100 | [diff] [blame] | 433 | QEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS" |
Kevin Wolf | c95e308 | 2013-02-22 21:08:51 +0100 | [diff] [blame] | 434 | QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS" |
Michael S. Tsirkin | be17dc9 | 2009-11-11 13:50:09 +0200 | [diff] [blame] | 435 | QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS" |
Paolo Bonzini | 5770e8a | 2020-09-23 05:26:15 -0400 | [diff] [blame] | 436 | |
Paolo Bonzini | de38c0c | 2021-11-08 08:58:23 +0100 | [diff] [blame] | 437 | QEMU_LDFLAGS= |
| 438 | |
Paolo Bonzini | 5770e8a | 2020-09-23 05:26:15 -0400 | [diff] [blame] | 439 | # Flags that are needed during configure but later taken care of by Meson |
Richard Henderson | 8a9d3d5 | 2021-06-14 16:31:36 -0700 | [diff] [blame] | 440 | CONFIGURE_CFLAGS="-std=gnu11 -Wall" |
Paolo Bonzini | 5770e8a | 2020-09-23 05:26:15 -0400 | [diff] [blame] | 441 | CONFIGURE_LDFLAGS= |
Paolo Bonzini | 086d5f7 | 2020-02-03 15:22:17 +0100 | [diff] [blame] | 442 | |
Michael S. Tsirkin | be17dc9 | 2009-11-11 13:50:09 +0200 | [diff] [blame] | 443 | |
aliguori | ac0df51 | 2008-12-29 17:14:15 +0000 | [diff] [blame] | 444 | check_define() { |
| 445 | cat > $TMPC <<EOF |
| 446 | #if !defined($1) |
Peter Maydell | fd786e1 | 2011-11-23 17:26:43 +0000 | [diff] [blame] | 447 | #error $1 not defined |
aliguori | ac0df51 | 2008-12-29 17:14:15 +0000 | [diff] [blame] | 448 | #endif |
| 449 | int main(void) { return 0; } |
| 450 | EOF |
Juan Quintela | 52166aa | 2009-08-03 14:46:03 +0200 | [diff] [blame] | 451 | compile_object |
aliguori | ac0df51 | 2008-12-29 17:14:15 +0000 | [diff] [blame] | 452 | } |
| 453 | |
Gerd Hoffmann | 307119e | 2015-06-10 09:07:35 +0200 | [diff] [blame] | 454 | check_include() { |
| 455 | cat > $TMPC <<EOF |
| 456 | #include <$1> |
| 457 | int main(void) { return 0; } |
| 458 | EOF |
| 459 | compile_object |
| 460 | } |
| 461 | |
John Snow | 93b2586 | 2015-03-25 18:57:37 -0400 | [diff] [blame] | 462 | write_c_skeleton() { |
| 463 | cat > $TMPC <<EOF |
| 464 | int main(void) { return 0; } |
| 465 | EOF |
| 466 | } |
| 467 | |
Peter Maydell | bbea405 | 2012-08-14 15:35:34 +0100 | [diff] [blame] | 468 | if check_define __linux__ ; then |
Paolo Bonzini | ba7c60c | 2021-11-08 14:47:54 +0100 | [diff] [blame] | 469 | targetos=linux |
Peter Maydell | bbea405 | 2012-08-14 15:35:34 +0100 | [diff] [blame] | 470 | elif check_define _WIN32 ; then |
Paolo Bonzini | ba7c60c | 2021-11-08 14:47:54 +0100 | [diff] [blame] | 471 | targetos=windows |
Peter Maydell | bbea405 | 2012-08-14 15:35:34 +0100 | [diff] [blame] | 472 | elif check_define __OpenBSD__ ; then |
Paolo Bonzini | ba7c60c | 2021-11-08 14:47:54 +0100 | [diff] [blame] | 473 | targetos=openbsd |
Peter Maydell | bbea405 | 2012-08-14 15:35:34 +0100 | [diff] [blame] | 474 | elif check_define __sun__ ; then |
Paolo Bonzini | ba7c60c | 2021-11-08 14:47:54 +0100 | [diff] [blame] | 475 | targetos=sunos |
Peter Maydell | bbea405 | 2012-08-14 15:35:34 +0100 | [diff] [blame] | 476 | elif check_define __HAIKU__ ; then |
Paolo Bonzini | ba7c60c | 2021-11-08 14:47:54 +0100 | [diff] [blame] | 477 | targetos=haiku |
Peter Maydell | 951fedf | 2017-07-13 16:15:32 +0100 | [diff] [blame] | 478 | elif check_define __FreeBSD__ ; then |
Paolo Bonzini | ba7c60c | 2021-11-08 14:47:54 +0100 | [diff] [blame] | 479 | targetos=freebsd |
Peter Maydell | 951fedf | 2017-07-13 16:15:32 +0100 | [diff] [blame] | 480 | elif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then |
Paolo Bonzini | ba7c60c | 2021-11-08 14:47:54 +0100 | [diff] [blame] | 481 | targetos=gnu/kfreebsd |
Peter Maydell | 951fedf | 2017-07-13 16:15:32 +0100 | [diff] [blame] | 482 | elif check_define __DragonFly__ ; then |
Paolo Bonzini | ba7c60c | 2021-11-08 14:47:54 +0100 | [diff] [blame] | 483 | targetos=dragonfly |
Peter Maydell | 951fedf | 2017-07-13 16:15:32 +0100 | [diff] [blame] | 484 | elif check_define __NetBSD__; then |
Paolo Bonzini | ba7c60c | 2021-11-08 14:47:54 +0100 | [diff] [blame] | 485 | targetos=netbsd |
Peter Maydell | 951fedf | 2017-07-13 16:15:32 +0100 | [diff] [blame] | 486 | elif check_define __APPLE__; then |
Paolo Bonzini | ba7c60c | 2021-11-08 14:47:54 +0100 | [diff] [blame] | 487 | targetos=darwin |
Peter Maydell | bbea405 | 2012-08-14 15:35:34 +0100 | [diff] [blame] | 488 | else |
Peter Maydell | 951fedf | 2017-07-13 16:15:32 +0100 | [diff] [blame] | 489 | # This is a fatal error, but don't report it yet, because we |
| 490 | # might be going to just print the --help text, or it might |
| 491 | # be the result of a missing compiler. |
Paolo Bonzini | ba7c60c | 2021-11-08 14:47:54 +0100 | [diff] [blame] | 492 | targetos=bogus |
Peter Maydell | bbea405 | 2012-08-14 15:35:34 +0100 | [diff] [blame] | 493 | fi |
| 494 | |
Paolo Bonzini | 65eff01 | 2021-11-08 22:52:35 +0100 | [diff] [blame] | 495 | # OS specific |
| 496 | |
Paolo Bonzini | 3b0d864 | 2021-10-13 14:14:53 +0200 | [diff] [blame] | 497 | mingw32="no" |
| 498 | bsd="no" |
| 499 | linux="no" |
| 500 | solaris="no" |
Peter Maydell | bbea405 | 2012-08-14 15:35:34 +0100 | [diff] [blame] | 501 | case $targetos in |
Paolo Bonzini | 65eff01 | 2021-11-08 22:52:35 +0100 | [diff] [blame] | 502 | windows) |
| 503 | mingw32="yes" |
| 504 | plugins="no" |
| 505 | pie="no" |
| 506 | ;; |
| 507 | gnu/kfreebsd) |
| 508 | bsd="yes" |
| 509 | ;; |
| 510 | freebsd) |
| 511 | bsd="yes" |
Paolo Bonzini | 65eff01 | 2021-11-08 22:52:35 +0100 | [diff] [blame] | 512 | make="${MAKE-gmake}" |
| 513 | # needed for kinfo_getvmmap(3) in libutil.h |
| 514 | ;; |
| 515 | dragonfly) |
| 516 | bsd="yes" |
| 517 | make="${MAKE-gmake}" |
| 518 | ;; |
| 519 | netbsd) |
| 520 | bsd="yes" |
| 521 | make="${MAKE-gmake}" |
| 522 | ;; |
| 523 | openbsd) |
| 524 | bsd="yes" |
| 525 | make="${MAKE-gmake}" |
| 526 | ;; |
| 527 | darwin) |
| 528 | bsd="yes" |
| 529 | darwin="yes" |
| 530 | # Disable attempts to use ObjectiveC features in os/object.h since they |
| 531 | # won't work when we're compiling with gcc as a C compiler. |
| 532 | QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS" |
| 533 | ;; |
Paolo Bonzini | ba7c60c | 2021-11-08 14:47:54 +0100 | [diff] [blame] | 534 | sunos) |
Paolo Bonzini | 65eff01 | 2021-11-08 22:52:35 +0100 | [diff] [blame] | 535 | solaris="yes" |
| 536 | make="${MAKE-gmake}" |
Paolo Bonzini | 65eff01 | 2021-11-08 22:52:35 +0100 | [diff] [blame] | 537 | # needed for CMSG_ macros in sys/socket.h |
| 538 | QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS" |
| 539 | # needed for TIOCWIN* defines in termios.h |
| 540 | QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS" |
Stefan Weil | 8913885 | 2016-05-16 15:10:20 +0200 | [diff] [blame] | 541 | # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo |
Paolo Bonzini | 65eff01 | 2021-11-08 22:52:35 +0100 | [diff] [blame] | 542 | # Note that this check is broken for cross-compilation: if you're |
| 543 | # cross-compiling to one of these OSes then you'll need to specify |
| 544 | # the correct CPU with the --cpu option. |
Peter Maydell | bbea405 | 2012-08-14 15:35:34 +0100 | [diff] [blame] | 545 | if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then |
| 546 | cpu="x86_64" |
| 547 | fi |
Paolo Bonzini | 65eff01 | 2021-11-08 22:52:35 +0100 | [diff] [blame] | 548 | ;; |
| 549 | haiku) |
| 550 | pie="no" |
| 551 | QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE -fPIC $QEMU_CFLAGS" |
| 552 | ;; |
| 553 | linux) |
| 554 | linux="yes" |
Paolo Bonzini | 65eff01 | 2021-11-08 22:52:35 +0100 | [diff] [blame] | 555 | vhost_user=${default_feature:-yes} |
| 556 | ;; |
Peter Maydell | bbea405 | 2012-08-14 15:35:34 +0100 | [diff] [blame] | 557 | esac |
| 558 | |
Juan Quintela | 2ff6b91 | 2009-08-03 14:45:55 +0200 | [diff] [blame] | 559 | if test ! -z "$cpu" ; then |
| 560 | # command line argument |
| 561 | : |
| 562 | elif check_define __i386__ ; then |
aliguori | ac0df51 | 2008-12-29 17:14:15 +0000 | [diff] [blame] | 563 | cpu="i386" |
| 564 | elif check_define __x86_64__ ; then |
Richard Henderson | c72b26e | 2013-08-20 12:20:05 -0700 | [diff] [blame] | 565 | if check_define __ILP32__ ; then |
| 566 | cpu="x32" |
| 567 | else |
| 568 | cpu="x86_64" |
| 569 | fi |
blueswir1 | 3aa9bd6 | 2008-12-31 16:55:26 +0000 | [diff] [blame] | 570 | elif check_define __sparc__ ; then |
blueswir1 | 3aa9bd6 | 2008-12-31 16:55:26 +0000 | [diff] [blame] | 571 | if check_define __arch64__ ; then |
| 572 | cpu="sparc64" |
| 573 | else |
| 574 | cpu="sparc" |
| 575 | fi |
malc | fdf7ed9 | 2009-01-14 18:39:52 +0000 | [diff] [blame] | 576 | elif check_define _ARCH_PPC ; then |
| 577 | if check_define _ARCH_PPC64 ; then |
Richard Henderson | f8378ac | 2019-05-01 15:38:18 -0700 | [diff] [blame] | 578 | if check_define _LITTLE_ENDIAN ; then |
| 579 | cpu="ppc64le" |
| 580 | else |
| 581 | cpu="ppc64" |
| 582 | fi |
malc | fdf7ed9 | 2009-01-14 18:39:52 +0000 | [diff] [blame] | 583 | else |
| 584 | cpu="ppc" |
| 585 | fi |
Aurelien Jarno | afa0523 | 2009-10-17 14:17:47 +0200 | [diff] [blame] | 586 | elif check_define __mips__ ; then |
| 587 | cpu="mips" |
Aurelien Jarno | d66ed0e | 2010-06-13 12:28:21 +0200 | [diff] [blame] | 588 | elif check_define __s390__ ; then |
| 589 | if check_define __s390x__ ; then |
| 590 | cpu="s390x" |
| 591 | else |
| 592 | cpu="s390" |
| 593 | fi |
Alistair Francis | c4f8054 | 2018-12-19 19:20:19 +0000 | [diff] [blame] | 594 | elif check_define __riscv ; then |
Richard Henderson | ba0e733 | 2021-09-17 11:08:09 -0700 | [diff] [blame] | 595 | cpu="riscv" |
Peter Maydell | 21d89f8 | 2011-11-30 10:57:48 +0100 | [diff] [blame] | 596 | elif check_define __arm__ ; then |
| 597 | cpu="arm" |
Claudio Fontana | 1f08031 | 2013-06-12 16:20:23 +0100 | [diff] [blame] | 598 | elif check_define __aarch64__ ; then |
| 599 | cpu="aarch64" |
WANG Xuerui | dfcf900 | 2021-12-21 13:41:04 +0800 | [diff] [blame] | 600 | elif check_define __loongarch64 ; then |
| 601 | cpu="loongarch64" |
aliguori | ac0df51 | 2008-12-29 17:14:15 +0000 | [diff] [blame] | 602 | else |
Stefan Weil | 8913885 | 2016-05-16 15:10:20 +0200 | [diff] [blame] | 603 | cpu=$(uname -m) |
aliguori | ac0df51 | 2008-12-29 17:14:15 +0000 | [diff] [blame] | 604 | fi |
| 605 | |
Paolo Bonzini | 823eb01 | 2021-11-08 14:18:17 +0100 | [diff] [blame] | 606 | # Normalise host CPU name, set multilib cflags |
Peter Maydell | 359bc95 | 2011-12-24 13:07:25 +0000 | [diff] [blame] | 607 | # Note that this case should only have supported host CPUs, not guests. |
bellard | 7d13299 | 2003-03-06 23:23:54 +0000 | [diff] [blame] | 608 | case "$cpu" in |
Paolo Bonzini | e4da0e3 | 2021-11-09 09:23:56 +0100 | [diff] [blame] | 609 | armv*b|armv*l|arm) |
| 610 | cpu="arm" ;; |
| 611 | |
bellard | 7d13299 | 2003-03-06 23:23:54 +0000 | [diff] [blame] | 612 | i386|i486|i586|i686|i86pc|BePC) |
bellard | 97a847b | 2003-08-10 21:36:04 +0000 | [diff] [blame] | 613 | cpu="i386" |
Paolo Bonzini | e4da0e3 | 2021-11-09 09:23:56 +0100 | [diff] [blame] | 614 | CPU_CFLAGS="-m32" ;; |
| 615 | x32) |
Paolo Bonzini | 4da270b | 2021-11-09 09:36:10 +0100 | [diff] [blame] | 616 | cpu="x86_64" |
Paolo Bonzini | e4da0e3 | 2021-11-09 09:23:56 +0100 | [diff] [blame] | 617 | CPU_CFLAGS="-mx32" ;; |
aurel32 | aaa5fa1 | 2008-04-11 22:04:22 +0000 | [diff] [blame] | 618 | x86_64|amd64) |
| 619 | cpu="x86_64" |
Paolo Bonzini | e4da0e3 | 2021-11-09 09:23:56 +0100 | [diff] [blame] | 620 | # ??? Only extremely old AMD cpus do not have cmpxchg16b. |
| 621 | # If we truly care, we should simply detect this case at |
| 622 | # runtime and generate the fallback to serial emulation. |
| 623 | CPU_CFLAGS="-m64 -mcx16" ;; |
| 624 | |
Aurelien Jarno | afa0523 | 2009-10-17 14:17:47 +0200 | [diff] [blame] | 625 | mips*) |
Paolo Bonzini | e4da0e3 | 2021-11-09 09:23:56 +0100 | [diff] [blame] | 626 | cpu="mips" ;; |
| 627 | |
| 628 | ppc) |
| 629 | CPU_CFLAGS="-m32" ;; |
| 630 | ppc64) |
Miroslav Rezanina | ced5cff | 2022-03-05 07:16:46 +0100 | [diff] [blame] | 631 | CPU_CFLAGS="-m64 -mbig-endian" ;; |
Paolo Bonzini | e4da0e3 | 2021-11-09 09:23:56 +0100 | [diff] [blame] | 632 | ppc64le) |
Paolo Bonzini | d8ff892 | 2021-11-09 09:18:20 +0100 | [diff] [blame] | 633 | cpu="ppc64" |
Miroslav Rezanina | ced5cff | 2022-03-05 07:16:46 +0100 | [diff] [blame] | 634 | CPU_CFLAGS="-m64 -mlittle-endian" ;; |
Paolo Bonzini | e4da0e3 | 2021-11-09 09:23:56 +0100 | [diff] [blame] | 635 | |
| 636 | s390) |
Paolo Bonzini | 823eb01 | 2021-11-08 14:18:17 +0100 | [diff] [blame] | 637 | CPU_CFLAGS="-m31" ;; |
Paolo Bonzini | e4da0e3 | 2021-11-09 09:23:56 +0100 | [diff] [blame] | 638 | s390x) |
| 639 | CPU_CFLAGS="-m64" ;; |
| 640 | |
blueswir1 | 3142255 | 2007-04-16 18:27:06 +0000 | [diff] [blame] | 641 | sparc|sun4[cdmuv]) |
bellard | ae22853 | 2003-05-13 18:59:59 +0000 | [diff] [blame] | 642 | cpu="sparc" |
Paolo Bonzini | e4da0e3 | 2021-11-09 09:23:56 +0100 | [diff] [blame] | 643 | CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc" ;; |
| 644 | sparc64) |
| 645 | CPU_CFLAGS="-m64 -mcpu=ultrasparc" ;; |
bellard | 7d13299 | 2003-03-06 23:23:54 +0000 | [diff] [blame] | 646 | esac |
Juan Quintela | e2d52ad | 2009-08-12 18:20:24 +0200 | [diff] [blame] | 647 | |
Paolo Bonzini | 0db4a06 | 2010-12-23 11:43:49 +0100 | [diff] [blame] | 648 | : ${make=${MAKE-make}} |
Paolo Bonzini | b6daf4d | 2020-09-01 06:38:04 -0400 | [diff] [blame] | 649 | |
Daniel P. Berrangé | faf4414 | 2019-03-27 17:07:01 +0000 | [diff] [blame] | 650 | # We prefer python 3.x. A bare 'python' is traditionally |
| 651 | # python 2.x, but some distros have it as python 3.x, so |
Eduardo Habkost | ddf9069 | 2019-10-16 19:42:37 -0300 | [diff] [blame] | 652 | # we check that too |
Daniel P. Berrangé | faf4414 | 2019-03-27 17:07:01 +0000 | [diff] [blame] | 653 | python= |
Marc-André Lureau | 0a01d76 | 2019-08-21 11:21:16 +0400 | [diff] [blame] | 654 | explicit_python=no |
Eduardo Habkost | ddf9069 | 2019-10-16 19:42:37 -0300 | [diff] [blame] | 655 | for binary in "${PYTHON-python3}" python |
Daniel P. Berrangé | faf4414 | 2019-03-27 17:07:01 +0000 | [diff] [blame] | 656 | do |
| 657 | if has "$binary" |
| 658 | then |
Paolo Bonzini | 95c5f2d | 2019-06-10 12:03:44 +0200 | [diff] [blame] | 659 | python=$(command -v "$binary") |
Daniel P. Berrangé | faf4414 | 2019-03-27 17:07:01 +0000 | [diff] [blame] | 660 | break |
| 661 | fi |
| 662 | done |
Markus Armbruster | 903458c | 2020-02-14 18:18:41 +0100 | [diff] [blame] | 663 | |
Markus Armbruster | 903458c | 2020-02-14 18:18:41 +0100 | [diff] [blame] | 664 | |
Alex Bennée | 39d87c8 | 2020-03-03 15:06:20 +0000 | [diff] [blame] | 665 | # Check for ancillary tools used in testing |
| 666 | genisoimage= |
Alex Bennée | 3df437c | 2020-05-19 09:22:48 -0400 | [diff] [blame] | 667 | for binary in genisoimage mkisofs |
Alex Bennée | 39d87c8 | 2020-03-03 15:06:20 +0000 | [diff] [blame] | 668 | do |
| 669 | if has $binary |
| 670 | then |
| 671 | genisoimage=$(command -v "$binary") |
| 672 | break |
| 673 | fi |
| 674 | done |
| 675 | |
Peter Maydell | 3c4a4d0 | 2012-08-11 22:34:40 +0100 | [diff] [blame] | 676 | # Default objcc to clang if available, otherwise use CC |
| 677 | if has clang; then |
| 678 | objcc=clang |
| 679 | else |
| 680 | objcc="$cc" |
| 681 | fi |
| 682 | |
Juan Quintela | 3457a3f | 2009-08-03 14:46:07 +0200 | [diff] [blame] | 683 | if test "$mingw32" = "yes" ; then |
Juan Quintela | 3457a3f | 2009-08-03 14:46:07 +0200 | [diff] [blame] | 684 | EXESUF=".exe" |
Stefan Weil | 78e9d4a | 2015-11-26 12:13:12 +0100 | [diff] [blame] | 685 | # MinGW needs -mthreads for TLS and macro _MT. |
Paolo Bonzini | 5770e8a | 2020-09-23 05:26:15 -0400 | [diff] [blame] | 686 | CONFIGURE_CFLAGS="-mthreads $CONFIGURE_CFLAGS" |
John Snow | 93b2586 | 2015-03-25 18:57:37 -0400 | [diff] [blame] | 687 | write_c_skeleton; |
Paolo Bonzini | d17f305 | 2020-08-18 12:17:01 +0200 | [diff] [blame] | 688 | prefix="/qemu" |
Marc-André Lureau | 77433a5 | 2020-08-26 15:04:12 +0400 | [diff] [blame] | 689 | qemu_suffix="" |
Juan Quintela | 3457a3f | 2009-08-03 14:46:07 +0200 | [diff] [blame] | 690 | fi |
| 691 | |
Anthony Liguori | 487fefd | 2009-06-11 13:28:25 -0500 | [diff] [blame] | 692 | werror="" |
bellard | 85aa518 | 2007-11-11 20:17:03 +0000 | [diff] [blame] | 693 | |
Paolo Bonzini | 61d6309 | 2021-10-07 15:08:28 +0200 | [diff] [blame] | 694 | . $source_path/scripts/meson-buildoptions.sh |
| 695 | |
| 696 | meson_options= |
| 697 | meson_option_parse() { |
| 698 | meson_options="$meson_options $(_meson_option_parse "$@")" |
| 699 | if test $? -eq 1; then |
| 700 | echo "ERROR: unknown option $1" |
| 701 | echo "Try '$0 --help' for more information" |
| 702 | exit 1 |
| 703 | fi |
| 704 | } |
| 705 | |
bellard | 7d13299 | 2003-03-06 23:23:54 +0000 | [diff] [blame] | 706 | for opt do |
Stefan Weil | 8913885 | 2016-05-16 15:10:20 +0200 | [diff] [blame] | 707 | optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') |
bellard | 7d13299 | 2003-03-06 23:23:54 +0000 | [diff] [blame] | 708 | case "$opt" in |
bellard | 2efc326 | 2005-12-18 19:14:49 +0000 | [diff] [blame] | 709 | --help|-h) show_help=yes |
| 710 | ;; |
Mike Frysinger | 99123e1 | 2011-04-07 01:12:28 -0400 | [diff] [blame] | 711 | --version|-V) exec cat $source_path/VERSION |
| 712 | ;; |
pbrook | b1a550a | 2006-04-16 13:28:56 +0000 | [diff] [blame] | 713 | --prefix=*) prefix="$optarg" |
bellard | 7d13299 | 2003-03-06 23:23:54 +0000 | [diff] [blame] | 714 | ;; |
pbrook | b1a550a | 2006-04-16 13:28:56 +0000 | [diff] [blame] | 715 | --interp-prefix=*) interp_prefix="$optarg" |
bellard | 32ce633 | 2003-04-11 00:16:16 +0000 | [diff] [blame] | 716 | ;; |
aliguori | ac0df51 | 2008-12-29 17:14:15 +0000 | [diff] [blame] | 717 | --cross-prefix=*) |
bellard | 7d13299 | 2003-03-06 23:23:54 +0000 | [diff] [blame] | 718 | ;; |
aliguori | ac0df51 | 2008-12-29 17:14:15 +0000 | [diff] [blame] | 719 | --cc=*) |
bellard | 7d13299 | 2003-03-06 23:23:54 +0000 | [diff] [blame] | 720 | ;; |
pbrook | b1a550a | 2006-04-16 13:28:56 +0000 | [diff] [blame] | 721 | --host-cc=*) host_cc="$optarg" |
bellard | 8346901 | 2005-07-23 14:27:54 +0000 | [diff] [blame] | 722 | ;; |
Tomoki Sekiyama | 83f73fc | 2013-08-07 11:39:36 -0400 | [diff] [blame] | 723 | --cxx=*) |
| 724 | ;; |
Michael S. Tsirkin | e007dbe | 2013-11-24 11:38:05 +0200 | [diff] [blame] | 725 | --iasl=*) iasl="$optarg" |
| 726 | ;; |
Peter Maydell | 3c4a4d0 | 2012-08-11 22:34:40 +0100 | [diff] [blame] | 727 | --objcc=*) objcc="$optarg" |
| 728 | ;; |
pbrook | b1a550a | 2006-04-16 13:28:56 +0000 | [diff] [blame] | 729 | --make=*) make="$optarg" |
bellard | 7d13299 | 2003-03-06 23:23:54 +0000 | [diff] [blame] | 730 | ;; |
Paolo Bonzini | b6daf4d | 2020-09-01 06:38:04 -0400 | [diff] [blame] | 731 | --install=*) |
pbrook | 6a88264 | 2006-04-17 13:57:12 +0000 | [diff] [blame] | 732 | ;; |
Marc-André Lureau | 0a01d76 | 2019-08-21 11:21:16 +0400 | [diff] [blame] | 733 | --python=*) python="$optarg" ; explicit_python=yes |
Blue Swirl | c886edf | 2011-07-22 21:08:09 +0000 | [diff] [blame] | 734 | ;; |
Peter Maydell | 2eb054c | 2020-02-13 17:56:18 +0000 | [diff] [blame] | 735 | --sphinx-build=*) sphinx_build="$optarg" |
| 736 | ;; |
Paolo Bonzini | a566505 | 2019-06-10 12:05:14 +0200 | [diff] [blame] | 737 | --skip-meson) skip_meson=yes |
| 738 | ;; |
| 739 | --meson=*) meson="$optarg" |
| 740 | ;; |
Paolo Bonzini | 4832888 | 2020-08-26 08:04:15 +0200 | [diff] [blame] | 741 | --ninja=*) ninja="$optarg" |
| 742 | ;; |
Brad | e2d8830 | 2011-09-02 16:53:28 -0400 | [diff] [blame] | 743 | --smbd=*) smbd="$optarg" |
| 744 | ;; |
Juan Quintela | e2a2ed0 | 2009-08-03 14:46:02 +0200 | [diff] [blame] | 745 | --extra-cflags=*) |
bellard | 7d13299 | 2003-03-06 23:23:54 +0000 | [diff] [blame] | 746 | ;; |
Bruno Dominguez | 11cde1c | 2017-06-06 14:07:47 +0100 | [diff] [blame] | 747 | --extra-cxxflags=*) |
| 748 | ;; |
Philippe Mathieu-Daudé | e910c7d | 2022-01-08 22:38:55 +0100 | [diff] [blame] | 749 | --extra-objcflags=*) |
| 750 | ;; |
Juan Quintela | e2a2ed0 | 2009-08-03 14:46:02 +0200 | [diff] [blame] | 751 | --extra-ldflags=*) |
bellard | 7d13299 | 2003-03-06 23:23:54 +0000 | [diff] [blame] | 752 | ;; |
Alex Bennée | d75402b | 2018-04-04 20:27:05 +0100 | [diff] [blame] | 753 | --cross-cc-*) |
| 754 | ;; |
Paolo Bonzini | 2860974 | 2022-04-20 17:33:39 +0200 | [diff] [blame] | 755 | --enable-debug-info) debug_info="yes" |
| 756 | ;; |
| 757 | --disable-debug-info) debug_info="no" |
| 758 | ;; |
Fam Zheng | 1796926 | 2014-02-10 14:48:56 +0800 | [diff] [blame] | 759 | --enable-modules) |
| 760 | modules="yes" |
| 761 | ;; |
Stefan Hajnoczi | 3aa88b3 | 2015-11-02 14:06:23 +0000 | [diff] [blame] | 762 | --disable-modules) |
| 763 | modules="no" |
| 764 | ;; |
Juan Quintela | 2ff6b91 | 2009-08-03 14:45:55 +0200 | [diff] [blame] | 765 | --cpu=*) |
bellard | 7d13299 | 2003-03-06 23:23:54 +0000 | [diff] [blame] | 766 | ;; |
pbrook | b1a550a | 2006-04-16 13:28:56 +0000 | [diff] [blame] | 767 | --target-list=*) target_list="$optarg" |
Alex Bennée | 447e133 | 2019-03-19 11:59:12 +0000 | [diff] [blame] | 768 | if test "$target_list_exclude"; then |
| 769 | error_exit "Can't mix --target-list with --target-list-exclude" |
| 770 | fi |
| 771 | ;; |
| 772 | --target-list-exclude=*) target_list_exclude="$optarg" |
| 773 | if test "$target_list"; then |
| 774 | error_exit "Can't mix --target-list-exclude with --target-list" |
| 775 | fi |
bellard | de83cd0 | 2003-06-15 20:25:43 +0000 | [diff] [blame] | 776 | ;; |
Paolo Bonzini | 74242e0 | 2010-12-23 11:44:02 +0100 | [diff] [blame] | 777 | --with-trace-file=*) trace_file="$optarg" |
Prerna Saxena | 9410b56 | 2010-07-13 09:26:32 +0100 | [diff] [blame] | 778 | ;; |
Paolo Bonzini | 7bc3ca7 | 2020-11-20 08:38:22 +0100 | [diff] [blame] | 779 | --with-default-devices) default_devices="true" |
Paolo Bonzini | f349474 | 2019-01-23 14:56:17 +0800 | [diff] [blame] | 780 | ;; |
Paolo Bonzini | 7bc3ca7 | 2020-11-20 08:38:22 +0100 | [diff] [blame] | 781 | --without-default-devices) default_devices="false" |
Paolo Bonzini | f349474 | 2019-01-23 14:56:17 +0800 | [diff] [blame] | 782 | ;; |
Alex Bennée | d1d5e9e | 2021-07-07 14:17:44 +0100 | [diff] [blame] | 783 | --with-devices-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --with-devices-FOO option" |
| 784 | ;; |
| 785 | --with-devices-*) device_arch=${opt#--with-devices-}; |
| 786 | device_arch=${device_arch%%=*} |
| 787 | cf=$source_path/configs/devices/$device_arch-softmmu/$optarg.mak |
| 788 | if test -f "$cf"; then |
| 789 | device_archs="$device_archs $device_arch" |
| 790 | eval "devices_${device_arch}=\$optarg" |
| 791 | else |
| 792 | error_exit "File $cf does not exist" |
| 793 | fi |
| 794 | ;; |
Alex Bennée | c87ea11 | 2020-12-10 19:04:13 +0000 | [diff] [blame] | 795 | --without-default-features) # processed above |
| 796 | ;; |
Blue Swirl | 1d728c3 | 2012-05-01 18:45:39 +0000 | [diff] [blame] | 797 | --enable-gcov) gcov="yes" |
| 798 | ;; |
Loïc Minier | 7942769 | 2010-01-31 12:23:45 +0100 | [diff] [blame] | 799 | --static) |
| 800 | static="yes" |
Sergei Trofimovich | 17884d7 | 2012-01-31 22:03:45 +0300 | [diff] [blame] | 801 | QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS" |
bellard | 43ce4df | 2003-06-09 19:53:12 +0000 | [diff] [blame] | 802 | ;; |
Paolo Bonzini | 0b24e75 | 2010-05-26 16:08:26 +0200 | [diff] [blame] | 803 | --mandir=*) mandir="$optarg" |
| 804 | ;; |
| 805 | --bindir=*) bindir="$optarg" |
| 806 | ;; |
Alon Levy | 3aa5d2b | 2011-05-15 12:08:59 +0300 | [diff] [blame] | 807 | --libdir=*) libdir="$optarg" |
| 808 | ;; |
Michael Tokarev | 8bf188a | 2012-06-07 01:11:00 +0400 | [diff] [blame] | 809 | --libexecdir=*) libexecdir="$optarg" |
| 810 | ;; |
Alon Levy | 0f94d6d | 2011-06-27 11:58:20 +0200 | [diff] [blame] | 811 | --includedir=*) includedir="$optarg" |
| 812 | ;; |
Eduardo Habkost | 528ae5b | 2012-04-18 16:55:49 -0300 | [diff] [blame] | 813 | --datadir=*) datadir="$optarg" |
Paolo Bonzini | 0b24e75 | 2010-05-26 16:08:26 +0200 | [diff] [blame] | 814 | ;; |
Marc-André Lureau | 77433a5 | 2020-08-26 15:04:12 +0400 | [diff] [blame] | 815 | --with-suffix=*) qemu_suffix="$optarg" |
Eduardo Habkost | 023d3d6 | 2012-04-18 16:55:50 -0300 | [diff] [blame] | 816 | ;; |
Bruce Rogers | c650263 | 2020-10-15 13:07:42 -0600 | [diff] [blame] | 817 | --docdir=*) docdir="$optarg" |
Paolo Bonzini | 0b24e75 | 2010-05-26 16:08:26 +0200 | [diff] [blame] | 818 | ;; |
Paolo Bonzini | fe0038b | 2020-10-16 04:35:10 -0400 | [diff] [blame] | 819 | --localedir=*) localedir="$optarg" |
| 820 | ;; |
Andre Przywara | ca2fb93 | 2010-03-08 14:09:48 +0100 | [diff] [blame] | 821 | --sysconfdir=*) sysconfdir="$optarg" |
Anthony Liguori | 07381cc | 2010-01-21 10:30:29 -0600 | [diff] [blame] | 822 | ;; |
Luiz Capitulino | 785c23a | 2012-10-03 18:35:57 -0300 | [diff] [blame] | 823 | --localstatedir=*) local_statedir="$optarg" |
| 824 | ;; |
Gerd Hoffmann | 3d5eeca | 2017-09-14 13:42:36 +0200 | [diff] [blame] | 825 | --firmwarepath=*) firmwarepath="$optarg" |
| 826 | ;; |
Olaf Hering | 181ce1d | 2018-04-18 09:50:44 +0200 | [diff] [blame] | 827 | --host=*|--build=*|\ |
| 828 | --disable-dependency-tracking|\ |
Luiz Capitulino | 785c23a | 2012-10-03 18:35:57 -0300 | [diff] [blame] | 829 | --sbindir=*|--sharedstatedir=*|\ |
Paolo Bonzini | fe0038b | 2020-10-16 04:35:10 -0400 | [diff] [blame] | 830 | --oldincludedir=*|--datarootdir=*|--infodir=*|\ |
Max Filippov | 023ddd7 | 2011-11-24 16:11:31 +0400 | [diff] [blame] | 831 | --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*) |
| 832 | # These switches are silently ignored, for compatibility with |
| 833 | # autoconf-generated configure scripts. This allows QEMU's |
| 834 | # configure to be used by RPM and similar macros that set |
| 835 | # lots of directory switches by default. |
| 836 | ;; |
malc | 0c58ac1 | 2008-06-25 21:04:05 +0000 | [diff] [blame] | 837 | --audio-drv-list=*) audio_drv_list="$optarg" |
| 838 | ;; |
Stefan Weil | 8913885 | 2016-05-16 15:10:20 +0200 | [diff] [blame] | 839 | --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g') |
Fam Zheng | b64ec4e | 2013-05-29 19:35:40 +0800 | [diff] [blame] | 840 | ;; |
Stefan Weil | 8913885 | 2016-05-16 15:10:20 +0200 | [diff] [blame] | 841 | --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g') |
Markus Armbruster | eb85201 | 2009-10-27 18:41:44 +0100 | [diff] [blame] | 842 | ;; |
aurel32 | f839394 | 2009-04-13 18:45:38 +0000 | [diff] [blame] | 843 | --enable-debug-tcg) debug_tcg="yes" |
| 844 | ;; |
| 845 | --disable-debug-tcg) debug_tcg="no" |
| 846 | ;; |
Paul Brook | f3d08ee | 2009-06-04 11:39:04 +0100 | [diff] [blame] | 847 | --enable-debug) |
| 848 | # Enable debugging options that aren't excessively noisy |
| 849 | debug_tcg="yes" |
Paolo Bonzini | c55cf6a | 2021-10-13 11:46:09 +0200 | [diff] [blame] | 850 | meson_option_parse --enable-debug-mutex "" |
Paul Brook | f3d08ee | 2009-06-04 11:39:04 +0100 | [diff] [blame] | 851 | debug="yes" |
John Snow | b553a04 | 2015-11-03 15:43:42 -0500 | [diff] [blame] | 852 | fortify_source="no" |
Paul Brook | f3d08ee | 2009-06-04 11:39:04 +0100 | [diff] [blame] | 853 | ;; |
Marc-André Lureau | 247724c | 2018-01-16 16:11:51 +0100 | [diff] [blame] | 854 | --enable-sanitizers) sanitizers="yes" |
| 855 | ;; |
| 856 | --disable-sanitizers) sanitizers="no" |
| 857 | ;; |
Lingfeng Yang | 0aebab0 | 2020-06-12 20:02:23 +0100 | [diff] [blame] | 858 | --enable-tsan) tsan="yes" |
| 859 | ;; |
| 860 | --disable-tsan) tsan="no" |
| 861 | ;; |
Paolo Bonzini | 4d34a86 | 2020-10-05 11:31:15 +0200 | [diff] [blame] | 862 | --disable-slirp) slirp="disabled" |
bellard | 1d14ffa | 2005-10-30 18:58:22 +0000 | [diff] [blame] | 863 | ;; |
Paolo Bonzini | fd6fc21 | 2020-11-20 11:19:38 +0100 | [diff] [blame] | 864 | --enable-slirp) slirp="enabled" |
| 865 | ;; |
Paolo Bonzini | 4d34a86 | 2020-10-05 11:31:15 +0200 | [diff] [blame] | 866 | --enable-slirp=git) slirp="internal" |
Marc-André Lureau | 7c57bdd8 | 2019-04-24 13:00:41 +0200 | [diff] [blame] | 867 | ;; |
Paolo Bonzini | 03a3c0b | 2021-10-07 15:08:27 +0200 | [diff] [blame] | 868 | --enable-slirp=*) slirp="$optarg" |
Marc-André Lureau | 675b9b5 | 2019-02-12 17:25:23 +0100 | [diff] [blame] | 869 | ;; |
Paolo Bonzini | 1badb70 | 2020-09-18 04:57:25 -0400 | [diff] [blame] | 870 | --disable-xen) xen="disabled" |
aliguori | e37630c | 2009-04-22 15:19:10 +0000 | [diff] [blame] | 871 | ;; |
Paolo Bonzini | 1badb70 | 2020-09-18 04:57:25 -0400 | [diff] [blame] | 872 | --enable-xen) xen="enabled" |
Juan Quintela | fc321b4 | 2009-08-12 18:29:55 +0200 | [diff] [blame] | 873 | ;; |
Paolo Bonzini | 1badb70 | 2020-09-18 04:57:25 -0400 | [diff] [blame] | 874 | --disable-tcg) tcg="disabled" |
Alex Bennée | d1a1425 | 2021-07-09 15:29:54 +0100 | [diff] [blame] | 875 | plugins="no" |
Paolo Bonzini | b3f6ea7 | 2017-07-03 16:59:07 +0200 | [diff] [blame] | 876 | ;; |
Paolo Bonzini | 1badb70 | 2020-09-18 04:57:25 -0400 | [diff] [blame] | 877 | --enable-tcg) tcg="enabled" |
Paolo Bonzini | b3f6ea7 | 2017-07-03 16:59:07 +0200 | [diff] [blame] | 878 | ;; |
pbrook | cad25d6 | 2006-03-19 16:31:11 +0000 | [diff] [blame] | 879 | --disable-system) softmmu="no" |
pbrook | 0a8e90f | 2006-03-19 14:54:16 +0000 | [diff] [blame] | 880 | ;; |
pbrook | cad25d6 | 2006-03-19 16:31:11 +0000 | [diff] [blame] | 881 | --enable-system) softmmu="yes" |
pbrook | 0a8e90f | 2006-03-19 14:54:16 +0000 | [diff] [blame] | 882 | ;; |
Zachary Amsden | 0953a80 | 2009-07-30 00:14:59 -1000 | [diff] [blame] | 883 | --disable-user) |
| 884 | linux_user="no" ; |
| 885 | bsd_user="no" ; |
Zachary Amsden | 0953a80 | 2009-07-30 00:14:59 -1000 | [diff] [blame] | 886 | ;; |
| 887 | --enable-user) ;; |
ths | 831b782 | 2007-01-18 20:06:33 +0000 | [diff] [blame] | 888 | --disable-linux-user) linux_user="no" |
pbrook | 0a8e90f | 2006-03-19 14:54:16 +0000 | [diff] [blame] | 889 | ;; |
ths | 831b782 | 2007-01-18 20:06:33 +0000 | [diff] [blame] | 890 | --enable-linux-user) linux_user="yes" |
| 891 | ;; |
blueswir1 | 8477850 | 2008-10-26 20:33:16 +0000 | [diff] [blame] | 892 | --disable-bsd-user) bsd_user="no" |
| 893 | ;; |
| 894 | --enable-bsd-user) bsd_user="yes" |
| 895 | ;; |
Avi Kivity | 40d6444 | 2011-11-15 20:12:17 +0200 | [diff] [blame] | 896 | --enable-pie) pie="yes" |
Kirill A. Shutemov | 34005a0 | 2009-09-12 02:17:55 +0300 | [diff] [blame] | 897 | ;; |
Avi Kivity | 40d6444 | 2011-11-15 20:12:17 +0200 | [diff] [blame] | 898 | --disable-pie) pie="no" |
Kirill A. Shutemov | 34005a0 | 2009-09-12 02:17:55 +0300 | [diff] [blame] | 899 | ;; |
bellard | 85aa518 | 2007-11-11 20:17:03 +0000 | [diff] [blame] | 900 | --enable-werror) werror="yes" |
| 901 | ;; |
| 902 | --disable-werror) werror="no" |
| 903 | ;; |
Daniele Buono | cdad781 | 2020-12-04 18:06:11 -0500 | [diff] [blame] | 904 | --enable-lto) lto="true" |
| 905 | ;; |
| 906 | --disable-lto) lto="false" |
| 907 | ;; |
Steven Noonan | 63678e1 | 2014-03-28 17:19:02 +0100 | [diff] [blame] | 908 | --enable-stack-protector) stack_protector="yes" |
| 909 | ;; |
| 910 | --disable-stack-protector) stack_protector="no" |
| 911 | ;; |
Daniele Buono | 1e4f606 | 2020-05-29 16:51:21 -0400 | [diff] [blame] | 912 | --enable-safe-stack) safe_stack="yes" |
| 913 | ;; |
| 914 | --disable-safe-stack) safe_stack="no" |
| 915 | ;; |
Daniele Buono | 9e62ba4 | 2020-12-04 18:06:14 -0500 | [diff] [blame] | 916 | --enable-cfi) |
| 917 | cfi="true"; |
| 918 | lto="true"; |
| 919 | ;; |
| 920 | --disable-cfi) cfi="false" |
| 921 | ;; |
Paolo Bonzini | fbb4121 | 2020-10-05 11:31:15 +0200 | [diff] [blame] | 922 | --disable-fdt) fdt="disabled" |
Juan Quintela | 2df87df | 2009-08-12 18:29:54 +0200 | [diff] [blame] | 923 | ;; |
Paolo Bonzini | fbb4121 | 2020-10-05 11:31:15 +0200 | [diff] [blame] | 924 | --enable-fdt) fdt="enabled" |
| 925 | ;; |
| 926 | --enable-fdt=git) fdt="internal" |
| 927 | ;; |
Paolo Bonzini | 03a3c0b | 2021-10-07 15:08:27 +0200 | [diff] [blame] | 928 | --enable-fdt=*) fdt="$optarg" |
Juan Quintela | 2df87df | 2009-08-12 18:29:54 +0200 | [diff] [blame] | 929 | ;; |
Thomas Huth | 7e563bf | 2018-02-15 12:06:47 +0100 | [diff] [blame] | 930 | --with-pkgversion=*) pkgversion="$optarg" |
pbrook | 4a19f1e | 2009-04-07 23:17:49 +0000 | [diff] [blame] | 931 | ;; |
Alex Barcelo | 519175a | 2012-02-28 12:25:50 +0100 | [diff] [blame] | 932 | --with-coroutine=*) coroutine="$optarg" |
| 933 | ;; |
Michael S. Tsirkin | d597005 | 2010-03-17 13:08:17 +0200 | [diff] [blame] | 934 | --disable-vhost-net) vhost_net="no" |
| 935 | ;; |
| 936 | --enable-vhost-net) vhost_net="yes" |
| 937 | ;; |
Gonglei | 042cea2 | 2018-03-01 21:46:28 +0800 | [diff] [blame] | 938 | --disable-vhost-crypto) vhost_crypto="no" |
| 939 | ;; |
Paolo Bonzini | 299e6f1 | 2019-02-14 18:35:53 +0100 | [diff] [blame] | 940 | --enable-vhost-crypto) vhost_crypto="yes" |
Gonglei | 042cea2 | 2018-03-01 21:46:28 +0800 | [diff] [blame] | 941 | ;; |
Nicholas Bellinger | 5e9be92 | 2013-03-29 01:08:16 +0000 | [diff] [blame] | 942 | --disable-vhost-scsi) vhost_scsi="no" |
| 943 | ;; |
| 944 | --enable-vhost-scsi) vhost_scsi="yes" |
| 945 | ;; |
Stefan Hajnoczi | fc0b9b0 | 2016-08-16 13:27:22 +0100 | [diff] [blame] | 946 | --disable-vhost-vsock) vhost_vsock="no" |
| 947 | ;; |
| 948 | --enable-vhost-vsock) vhost_vsock="yes" |
| 949 | ;; |
Dr. David Alan Gilbert | 98fc1ad | 2019-09-30 11:51:34 +0100 | [diff] [blame] | 950 | --disable-vhost-user-fs) vhost_user_fs="no" |
| 951 | ;; |
| 952 | --enable-vhost-user-fs) vhost_user_fs="yes" |
| 953 | ;; |
Paolo Bonzini | 1ffb3bb | 2020-08-28 19:33:54 +0200 | [diff] [blame] | 954 | --disable-zlib-test) |
Alon Levy | 1ece990 | 2011-07-26 12:30:40 +0300 | [diff] [blame] | 955 | ;; |
Fam Zheng | 52b53c0 | 2014-09-10 14:17:51 +0800 | [diff] [blame] | 956 | --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane) |
| 957 | echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2 |
Stefan Hajnoczi | 583f6e7 | 2012-11-14 15:04:15 +0100 | [diff] [blame] | 958 | ;; |
Fam Zheng | cb6414d | 2016-09-21 12:27:16 +0800 | [diff] [blame] | 959 | --enable-vhdx|--disable-vhdx) |
| 960 | echo "$0: $opt is obsolete, VHDX driver is always built" >&2 |
| 961 | ;; |
Fam Zheng | 315d318 | 2016-09-21 12:27:21 +0800 | [diff] [blame] | 962 | --enable-uuid|--disable-uuid) |
| 963 | echo "$0: $opt is obsolete, UUID support is always built" >&2 |
| 964 | ;; |
Daniel P. Berrange | a1c5e94 | 2016-06-06 10:05:06 +0100 | [diff] [blame] | 965 | --tls-priority=*) tls_priority="$optarg" |
| 966 | ;; |
Marc-André Lureau | e6a7486 | 2017-08-03 11:07:46 +0200 | [diff] [blame] | 967 | --disable-vhost-user) vhost_user="no" |
| 968 | ;; |
Paolo Bonzini | 299e6f1 | 2019-02-14 18:35:53 +0100 | [diff] [blame] | 969 | --enable-vhost-user) vhost_user="yes" |
| 970 | ;; |
Cindy Lu | 108a648 | 2020-07-01 22:55:37 +0800 | [diff] [blame] | 971 | --disable-vhost-vdpa) vhost_vdpa="no" |
| 972 | ;; |
| 973 | --enable-vhost-vdpa) vhost_vdpa="yes" |
| 974 | ;; |
Paolo Bonzini | 299e6f1 | 2019-02-14 18:35:53 +0100 | [diff] [blame] | 975 | --disable-vhost-kernel) vhost_kernel="no" |
| 976 | ;; |
| 977 | --enable-vhost-kernel) vhost_kernel="yes" |
Marc-André Lureau | e6a7486 | 2017-08-03 11:07:46 +0200 | [diff] [blame] | 978 | ;; |
Richard Henderson | 8b18cdb | 2020-09-13 12:19:25 -0700 | [diff] [blame] | 979 | --disable-capstone) capstone="disabled" |
Richard Henderson | 8ca8076 | 2017-09-14 09:41:12 -0700 | [diff] [blame] | 980 | ;; |
Richard Henderson | 8b18cdb | 2020-09-13 12:19:25 -0700 | [diff] [blame] | 981 | --enable-capstone) capstone="enabled" |
Richard Henderson | 8ca8076 | 2017-09-14 09:41:12 -0700 | [diff] [blame] | 982 | ;; |
Richard Henderson | 8b18cdb | 2020-09-13 12:19:25 -0700 | [diff] [blame] | 983 | --enable-capstone=git) capstone="internal" |
Richard Henderson | e219c49 | 2017-09-28 09:01:23 -0700 | [diff] [blame] | 984 | ;; |
Paolo Bonzini | 03a3c0b | 2021-10-07 15:08:27 +0200 | [diff] [blame] | 985 | --enable-capstone=*) capstone="$optarg" |
Richard Henderson | e219c49 | 2017-09-28 09:01:23 -0700 | [diff] [blame] | 986 | ;; |
Daniel P. Berrange | cc84d63 | 2017-10-20 15:02:43 +0100 | [diff] [blame] | 987 | --with-git=*) git="$optarg" |
| 988 | ;; |
Dan Streetman | 7d7dbf9 | 2021-01-19 12:20:46 -0500 | [diff] [blame] | 989 | --with-git-submodules=*) |
| 990 | git_submodules_action="$optarg" |
Daniel P. Berrange | f62bbee | 2017-10-26 13:52:26 +0100 | [diff] [blame] | 991 | ;; |
Alex Bennée | 9b8e429 | 2021-07-09 15:29:56 +0100 | [diff] [blame] | 992 | --enable-plugins) if test "$mingw32" = "yes"; then |
| 993 | error_exit "TCG plugins not currently supported on Windows platforms" |
| 994 | else |
| 995 | plugins="yes" |
| 996 | fi |
Alex Bennée | 40e8c6f | 2019-06-13 14:52:25 +0100 | [diff] [blame] | 997 | ;; |
| 998 | --disable-plugins) plugins="no" |
| 999 | ;; |
Alex Bennée | afc3a8f | 2019-11-28 16:35:24 +0100 | [diff] [blame] | 1000 | --enable-containers) use_containers="yes" |
| 1001 | ;; |
| 1002 | --disable-containers) use_containers="no" |
| 1003 | ;; |
Alex Bennée | f48e590 | 2020-03-16 17:21:48 +0000 | [diff] [blame] | 1004 | --gdb=*) gdb_bin="$optarg" |
| 1005 | ;; |
Paolo Bonzini | 3b4da13 | 2021-10-07 15:08:29 +0200 | [diff] [blame] | 1006 | # backwards compatibility options |
| 1007 | --enable-trace-backend=*) meson_option_parse "--enable-trace-backends=$optarg" "$optarg" |
| 1008 | ;; |
| 1009 | --disable-blobs) meson_option_parse --disable-install-blobs "" |
| 1010 | ;; |
| 1011 | --enable-tcmalloc) meson_option_parse --enable-malloc=tcmalloc tcmalloc |
| 1012 | ;; |
| 1013 | --enable-jemalloc) meson_option_parse --enable-malloc=jemalloc jemalloc |
| 1014 | ;; |
| 1015 | # everything else has the same name in configure and meson |
Paolo Bonzini | 61d6309 | 2021-10-07 15:08:28 +0200 | [diff] [blame] | 1016 | --enable-* | --disable-*) meson_option_parse "$opt" "$optarg" |
| 1017 | ;; |
Fam Zheng | 2d2ad6d | 2014-04-18 14:55:36 +0800 | [diff] [blame] | 1018 | *) |
| 1019 | echo "ERROR: unknown option $opt" |
| 1020 | echo "Try '$0 --help' for more information" |
| 1021 | exit 1 |
balrog | 7f1559c | 2007-11-17 10:24:32 +0000 | [diff] [blame] | 1022 | ;; |
bellard | 7d13299 | 2003-03-06 23:23:54 +0000 | [diff] [blame] | 1023 | esac |
| 1024 | done |
| 1025 | |
Alex Bennée | d1a1425 | 2021-07-09 15:29:54 +0100 | [diff] [blame] | 1026 | # test for any invalid configuration combinations |
| 1027 | if test "$plugins" = "yes" -a "$tcg" = "disabled"; then |
| 1028 | error_exit "Can't enable plugins on non-TCG builds" |
| 1029 | fi |
| 1030 | |
Dan Streetman | 7d7dbf9 | 2021-01-19 12:20:46 -0500 | [diff] [blame] | 1031 | case $git_submodules_action in |
| 1032 | update|validate) |
| 1033 | if test ! -e "$source_path/.git"; then |
| 1034 | echo "ERROR: cannot $git_submodules_action git submodules without .git" |
| 1035 | exit 1 |
| 1036 | fi |
| 1037 | ;; |
| 1038 | ignore) |
Paolo Bonzini | b80fd28 | 2021-05-12 09:18:55 +0200 | [diff] [blame] | 1039 | if ! test -f "$source_path/ui/keycodemapdb/README" |
| 1040 | then |
| 1041 | echo |
| 1042 | echo "ERROR: missing GIT submodules" |
| 1043 | echo |
| 1044 | if test -e "$source_path/.git"; then |
| 1045 | echo "--with-git-submodules=ignore specified but submodules were not" |
| 1046 | echo "checked out. Please initialize and update submodules." |
| 1047 | else |
| 1048 | echo "This is not a GIT checkout but module content appears to" |
| 1049 | echo "be missing. Do not use 'git archive' or GitHub download links" |
| 1050 | echo "to acquire QEMU source archives. Non-GIT builds are only" |
| 1051 | echo "supported with source archives linked from:" |
| 1052 | echo |
| 1053 | echo " https://www.qemu.org/download/#source" |
| 1054 | echo |
| 1055 | echo "Developers working with GIT can use scripts/archive-source.sh" |
| 1056 | echo "if they need to create valid source archives." |
| 1057 | fi |
| 1058 | echo |
| 1059 | exit 1 |
| 1060 | fi |
Dan Streetman | 7d7dbf9 | 2021-01-19 12:20:46 -0500 | [diff] [blame] | 1061 | ;; |
| 1062 | *) |
| 1063 | echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'" |
| 1064 | exit 1 |
| 1065 | ;; |
| 1066 | esac |
| 1067 | |
Marc-André Lureau | 22a8780 | 2019-07-11 19:13:39 +0400 | [diff] [blame] | 1068 | libdir="${libdir:-$prefix/lib}" |
| 1069 | libexecdir="${libexecdir:-$prefix/libexec}" |
| 1070 | includedir="${includedir:-$prefix/include}" |
| 1071 | |
| 1072 | if test "$mingw32" = "yes" ; then |
Joshua Watt | 15588a6 | 2021-01-12 15:02:39 -0600 | [diff] [blame] | 1073 | bindir="${bindir:-$prefix}" |
Marc-André Lureau | 22a8780 | 2019-07-11 19:13:39 +0400 | [diff] [blame] | 1074 | else |
Marc-André Lureau | 22a8780 | 2019-07-11 19:13:39 +0400 | [diff] [blame] | 1075 | bindir="${bindir:-$prefix/bin}" |
Marc-André Lureau | 22a8780 | 2019-07-11 19:13:39 +0400 | [diff] [blame] | 1076 | fi |
Joshua Watt | 15588a6 | 2021-01-12 15:02:39 -0600 | [diff] [blame] | 1077 | mandir="${mandir:-$prefix/share/man}" |
| 1078 | datadir="${datadir:-$prefix/share}" |
| 1079 | docdir="${docdir:-$prefix/share/doc}" |
| 1080 | sysconfdir="${sysconfdir:-$prefix/etc}" |
| 1081 | local_statedir="${local_statedir:-$prefix/var}" |
Paolo Bonzini | 16bf7a3 | 2020-10-16 03:19:14 -0400 | [diff] [blame] | 1082 | firmwarepath="${firmwarepath:-$datadir/qemu-firmware}" |
| 1083 | localedir="${localedir:-$datadir/locale}" |
Marc-André Lureau | 22a8780 | 2019-07-11 19:13:39 +0400 | [diff] [blame] | 1084 | |
Alex Bennée | 9557af9 | 2021-09-17 17:23:22 +0100 | [diff] [blame] | 1085 | if eval test -z "\${cross_cc_$cpu}"; then |
| 1086 | eval "cross_cc_${cpu}=\$cc" |
| 1087 | cross_cc_vars="$cross_cc_vars cross_cc_${cpu}" |
| 1088 | fi |
Peter Crosthwaite | 79f3b12 | 2013-04-18 14:46:14 +1000 | [diff] [blame] | 1089 | |
Peter Maydell | 60e0df2 | 2011-05-03 14:50:13 +0100 | [diff] [blame] | 1090 | default_target_list="" |
Peter Maydell | 6e92f82 | 2013-05-20 16:16:15 +0100 | [diff] [blame] | 1091 | mak_wilds="" |
| 1092 | |
Paolo Bonzini | b915a2f | 2021-11-09 10:10:41 +0100 | [diff] [blame] | 1093 | if [ "$linux_user" != no ]; then |
| 1094 | if [ "$targetos" = linux ] && [ -d $source_path/linux-user/include/host/$cpu ]; then |
| 1095 | linux_user=yes |
| 1096 | elif [ "$linux_user" = yes ]; then |
| 1097 | error_exit "linux-user not supported on this architecture" |
| 1098 | fi |
| 1099 | fi |
| 1100 | if [ "$bsd_user" != no ]; then |
| 1101 | if [ "$bsd_user" = "" ]; then |
| 1102 | test $targetos = freebsd && bsd_user=yes |
| 1103 | fi |
| 1104 | if [ "$bsd_user" = yes ] && ! [ -d $source_path/bsd-user/$targetos ]; then |
| 1105 | error_exit "bsd-user not supported on this host OS" |
| 1106 | fi |
| 1107 | fi |
Peter Maydell | 6e92f82 | 2013-05-20 16:16:15 +0100 | [diff] [blame] | 1108 | if [ "$softmmu" = "yes" ]; then |
Alex Bennée | 812b31d | 2021-07-07 14:17:43 +0100 | [diff] [blame] | 1109 | mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak" |
Peter Maydell | 60e0df2 | 2011-05-03 14:50:13 +0100 | [diff] [blame] | 1110 | fi |
Peter Maydell | 6e92f82 | 2013-05-20 16:16:15 +0100 | [diff] [blame] | 1111 | if [ "$linux_user" = "yes" ]; then |
Alex Bennée | 812b31d | 2021-07-07 14:17:43 +0100 | [diff] [blame] | 1112 | mak_wilds="${mak_wilds} $source_path/configs/targets/*-linux-user.mak" |
Peter Maydell | 60e0df2 | 2011-05-03 14:50:13 +0100 | [diff] [blame] | 1113 | fi |
Peter Maydell | 6e92f82 | 2013-05-20 16:16:15 +0100 | [diff] [blame] | 1114 | if [ "$bsd_user" = "yes" ]; then |
Alex Bennée | 812b31d | 2021-07-07 14:17:43 +0100 | [diff] [blame] | 1115 | mak_wilds="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak" |
Peter Maydell | 60e0df2 | 2011-05-03 14:50:13 +0100 | [diff] [blame] | 1116 | fi |
| 1117 | |
Alex Bennée | 2d838d9 | 2020-09-09 12:27:37 +0100 | [diff] [blame] | 1118 | for config in $mak_wilds; do |
| 1119 | target="$(basename "$config" .mak)" |
Alex Bennée | 98db9a0 | 2020-09-15 14:43:14 +0100 | [diff] [blame] | 1120 | if echo "$target_list_exclude" | grep -vq "$target"; then |
Alex Bennée | 2d838d9 | 2020-09-09 12:27:37 +0100 | [diff] [blame] | 1121 | default_target_list="${default_target_list} $target" |
| 1122 | fi |
| 1123 | done |
Peter Maydell | 6e92f82 | 2013-05-20 16:16:15 +0100 | [diff] [blame] | 1124 | |
pbrook | af5db58 | 2006-04-08 14:26:41 +0000 | [diff] [blame] | 1125 | if test x"$show_help" = x"yes" ; then |
| 1126 | cat << EOF |
| 1127 | |
| 1128 | Usage: configure [options] |
| 1129 | Options: [defaults in brackets after descriptions] |
| 1130 | |
Stefan Weil | 08fb77e | 2013-12-18 22:09:39 +0100 | [diff] [blame] | 1131 | Standard options: |
| 1132 | --help print this message |
| 1133 | --prefix=PREFIX install in PREFIX [$prefix] |
| 1134 | --interp-prefix=PREFIX where to find shared libraries, etc. |
| 1135 | use %M for cpu name [$interp_prefix] |
Thomas Huth | 74154d7 | 2022-01-12 11:27:22 +0000 | [diff] [blame] | 1136 | --target-list=LIST set target list (default: build all) |
Stefan Weil | 08fb77e | 2013-12-18 22:09:39 +0100 | [diff] [blame] | 1137 | $(echo Available targets: $default_target_list | \ |
| 1138 | fold -s -w 53 | sed -e 's/^/ /') |
Alex Bennée | 447e133 | 2019-03-19 11:59:12 +0000 | [diff] [blame] | 1139 | --target-list-exclude=LIST exclude a set of targets from the default target-list |
Stefan Weil | 08fb77e | 2013-12-18 22:09:39 +0100 | [diff] [blame] | 1140 | |
| 1141 | Advanced options (experts only): |
Joelle van Dyne | 3812c0c | 2021-01-25 17:24:48 -0800 | [diff] [blame] | 1142 | --cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix] |
Stefan Weil | 08fb77e | 2013-12-18 22:09:39 +0100 | [diff] [blame] | 1143 | --cc=CC use C compiler CC [$cc] |
| 1144 | --iasl=IASL use ACPI compiler IASL [$iasl] |
| 1145 | --host-cc=CC use C compiler CC [$host_cc] for code run at |
| 1146 | build time |
| 1147 | --cxx=CXX use C++ compiler CXX [$cxx] |
| 1148 | --objcc=OBJCC use Objective-C compiler OBJCC [$objcc] |
Paolo Bonzini | a286666 | 2021-11-05 10:09:26 +0100 | [diff] [blame] | 1149 | --extra-cflags=CFLAGS append extra C compiler flags CFLAGS |
| 1150 | --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS |
Philippe Mathieu-Daudé | e910c7d | 2022-01-08 22:38:55 +0100 | [diff] [blame] | 1151 | --extra-objcflags=OBJCFLAGS append extra Objective C compiler flags OBJCFLAGS |
Stefan Weil | 08fb77e | 2013-12-18 22:09:39 +0100 | [diff] [blame] | 1152 | --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS |
Alex Bennée | d75402b | 2018-04-04 20:27:05 +0100 | [diff] [blame] | 1153 | --cross-cc-ARCH=CC use compiler when building ARCH guest test cases |
Matheus Ferst | 479ca4c | 2022-01-20 14:31:41 -0300 | [diff] [blame] | 1154 | --cross-cc-cflags-ARCH= use compiler flags when building ARCH guest tests |
Stefan Weil | 08fb77e | 2013-12-18 22:09:39 +0100 | [diff] [blame] | 1155 | --make=MAKE use specified make [$make] |
Stefan Weil | 08fb77e | 2013-12-18 22:09:39 +0100 | [diff] [blame] | 1156 | --python=PYTHON use specified python [$python] |
Peter Maydell | 2eb054c | 2020-02-13 17:56:18 +0000 | [diff] [blame] | 1157 | --sphinx-build=SPHINX use specified sphinx-build [$sphinx_build] |
Paolo Bonzini | a566505 | 2019-06-10 12:05:14 +0200 | [diff] [blame] | 1158 | --meson=MESON use specified meson [$meson] |
Paolo Bonzini | 4832888 | 2020-08-26 08:04:15 +0200 | [diff] [blame] | 1159 | --ninja=NINJA use specified ninja [$ninja] |
Stefan Weil | 08fb77e | 2013-12-18 22:09:39 +0100 | [diff] [blame] | 1160 | --smbd=SMBD use specified smbd [$smbd] |
Thomas Huth | db1b5f1 | 2018-03-27 17:09:30 +0200 | [diff] [blame] | 1161 | --with-git=GIT use specified git [$git] |
Dan Streetman | 7d7dbf9 | 2021-01-19 12:20:46 -0500 | [diff] [blame] | 1162 | --with-git-submodules=update update git submodules (default if .git dir exists) |
| 1163 | --with-git-submodules=validate fail if git submodules are not up to date |
| 1164 | --with-git-submodules=ignore do not update or check git submodules (default if no .git dir) |
Stefan Weil | 08fb77e | 2013-12-18 22:09:39 +0100 | [diff] [blame] | 1165 | --static enable static build [$static] |
| 1166 | --mandir=PATH install man pages in PATH |
Marc-André Lureau | 10ff82d | 2020-08-26 15:04:13 +0400 | [diff] [blame] | 1167 | --datadir=PATH install firmware in PATH/$qemu_suffix |
Paolo Bonzini | fe0038b | 2020-10-16 04:35:10 -0400 | [diff] [blame] | 1168 | --localedir=PATH install translation in PATH/$qemu_suffix |
Marc-André Lureau | 10ff82d | 2020-08-26 15:04:13 +0400 | [diff] [blame] | 1169 | --docdir=PATH install documentation in PATH/$qemu_suffix |
Stefan Weil | 08fb77e | 2013-12-18 22:09:39 +0100 | [diff] [blame] | 1170 | --bindir=PATH install binaries in PATH |
| 1171 | --libdir=PATH install libraries in PATH |
Thomas Huth | db1b5f1 | 2018-03-27 17:09:30 +0200 | [diff] [blame] | 1172 | --libexecdir=PATH install helper binaries in PATH |
Marc-André Lureau | 10ff82d | 2020-08-26 15:04:13 +0400 | [diff] [blame] | 1173 | --sysconfdir=PATH install config in PATH/$qemu_suffix |
Stefan Weil | 08fb77e | 2013-12-18 22:09:39 +0100 | [diff] [blame] | 1174 | --localstatedir=PATH install local state in PATH (set at runtime on win32) |
Gerd Hoffmann | 3d5eeca | 2017-09-14 13:42:36 +0200 | [diff] [blame] | 1175 | --firmwarepath=PATH search PATH for firmware files |
Robert Foley | 1333660 | 2020-07-01 14:56:21 +0100 | [diff] [blame] | 1176 | --efi-aarch64=PATH PATH of efi file to use for aarch64 VMs. |
Marc-André Lureau | ca8c090 | 2020-08-26 15:04:14 +0400 | [diff] [blame] | 1177 | --with-suffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix] |
Thomas Huth | db1b5f1 | 2018-03-27 17:09:30 +0200 | [diff] [blame] | 1178 | --with-pkgversion=VERS use specified string as sub-version of the package |
Paolo Bonzini | c035c8d | 2020-12-14 11:34:47 +0100 | [diff] [blame] | 1179 | --without-default-features default all --enable-* options to "disabled" |
| 1180 | --without-default-devices do not include any device that is not needed to |
| 1181 | start the emulator (only use if you are including |
Alex Bennée | d1d5e9e | 2021-07-07 14:17:44 +0100 | [diff] [blame] | 1182 | desired devices in configs/devices/) |
| 1183 | --with-devices-ARCH=NAME override default configs/devices |
Stefan Weil | 08fb77e | 2013-12-18 22:09:39 +0100 | [diff] [blame] | 1184 | --enable-debug enable common debug build options |
Marc-André Lureau | 247724c | 2018-01-16 16:11:51 +0100 | [diff] [blame] | 1185 | --enable-sanitizers enable default sanitizers |
Lingfeng Yang | 0aebab0 | 2020-06-12 20:02:23 +0100 | [diff] [blame] | 1186 | --enable-tsan enable thread sanitizer |
Stefan Weil | 08fb77e | 2013-12-18 22:09:39 +0100 | [diff] [blame] | 1187 | --disable-werror disable compilation abort on warning |
Steven Noonan | 63678e1 | 2014-03-28 17:19:02 +0100 | [diff] [blame] | 1188 | --disable-stack-protector disable compiler-provided stack protection |
Paolo Bonzini | 16bfbc7 | 2021-11-02 14:56:22 +0100 | [diff] [blame] | 1189 | --audio-drv-list=LIST set audio drivers to try if -audiodev is not used |
Stefan Weil | 08fb77e | 2013-12-18 22:09:39 +0100 | [diff] [blame] | 1190 | --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L |
| 1191 | --block-drv-rw-whitelist=L |
| 1192 | set block driver read-write whitelist |
Kevin Wolf | e5f05f8 | 2021-07-09 18:41:41 +0200 | [diff] [blame] | 1193 | (by default affects only QEMU, not tools like qemu-img) |
Stefan Weil | 08fb77e | 2013-12-18 22:09:39 +0100 | [diff] [blame] | 1194 | --block-drv-ro-whitelist=L |
| 1195 | set block driver read-only whitelist |
Kevin Wolf | e5f05f8 | 2021-07-09 18:41:41 +0200 | [diff] [blame] | 1196 | (by default affects only QEMU, not tools like qemu-img) |
Stefan Weil | 08fb77e | 2013-12-18 22:09:39 +0100 | [diff] [blame] | 1197 | --with-trace-file=NAME Full PATH,NAME of file to store traces |
| 1198 | Default:trace-<pid> |
Michael Tokarev | c23f23b | 2015-06-17 22:19:26 +0300 | [diff] [blame] | 1199 | --cpu=CPU Build for host CPU [$cpu] |
Stefan Weil | 08fb77e | 2013-12-18 22:09:39 +0100 | [diff] [blame] | 1200 | --with-coroutine=BACKEND coroutine backend. Supported options: |
Daniel P. Berrange | 33c53c5 | 2017-04-28 13:24:44 +0100 | [diff] [blame] | 1201 | ucontext, sigaltstack, windows |
Stefan Weil | 08fb77e | 2013-12-18 22:09:39 +0100 | [diff] [blame] | 1202 | --enable-gcov enable test coverage analysis with gcov |
Daniel P. Berrange | a1c5e94 | 2016-06-06 10:05:06 +0100 | [diff] [blame] | 1203 | --tls-priority default TLS protocol/cipher priority string |
Alex Bennée | 40e8c6f | 2019-06-13 14:52:25 +0100 | [diff] [blame] | 1204 | --enable-plugins |
| 1205 | enable plugins via shared library loading |
Alex Bennée | afc3a8f | 2019-11-28 16:35:24 +0100 | [diff] [blame] | 1206 | --disable-containers don't use containers for cross-building |
Alex Bennée | f48e590 | 2020-03-16 17:21:48 +0000 | [diff] [blame] | 1207 | --gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin] |
Paolo Bonzini | 61d6309 | 2021-10-07 15:08:28 +0200 | [diff] [blame] | 1208 | EOF |
| 1209 | meson_options_help |
| 1210 | cat << EOF |
Michael Tokarev | c23f23b | 2015-06-17 22:19:26 +0300 | [diff] [blame] | 1211 | system all system emulation targets |
| 1212 | user supported user emulation targets |
| 1213 | linux-user all linux usermode emulation targets |
| 1214 | bsd-user all BSD usermode emulation targets |
Michael Tokarev | c23f23b | 2015-06-17 22:19:26 +0300 | [diff] [blame] | 1215 | pie Position Independent Executables |
Marc-André Lureau | 21e709a | 2019-07-18 16:04:13 +0400 | [diff] [blame] | 1216 | modules modules support (non-Windows) |
Michael Tokarev | c23f23b | 2015-06-17 22:19:26 +0300 | [diff] [blame] | 1217 | debug-tcg TCG debugging (default is disabled) |
| 1218 | debug-info debugging information |
Daniele Buono | cdad781 | 2020-12-04 18:06:11 -0500 | [diff] [blame] | 1219 | lto Enable Link-Time Optimization. |
Daniele Buono | 1e4f606 | 2020-05-29 16:51:21 -0400 | [diff] [blame] | 1220 | safe-stack SafeStack Stack Smash Protection. Depends on |
| 1221 | clang/llvm >= 3.7 and requires coroutine backend ucontext. |
Paolo Bonzini | 299e6f1 | 2019-02-14 18:35:53 +0100 | [diff] [blame] | 1222 | vhost-net vhost-net kernel acceleration support |
| 1223 | vhost-vsock virtio sockets device support |
| 1224 | vhost-scsi vhost-scsi kernel target support |
| 1225 | vhost-crypto vhost-user-crypto backend support |
| 1226 | vhost-kernel vhost kernel backend support |
| 1227 | vhost-user vhost-user backend support |
Cindy Lu | 108a648 | 2020-07-01 22:55:37 +0800 | [diff] [blame] | 1228 | vhost-vdpa vhost-vdpa kernel backend support |
Stefan Weil | 08fb77e | 2013-12-18 22:09:39 +0100 | [diff] [blame] | 1229 | |
| 1230 | NOTE: The object files are built at the place where configure is launched |
pbrook | af5db58 | 2006-04-08 14:26:41 +0000 | [diff] [blame] | 1231 | EOF |
Fam Zheng | 2d2ad6d | 2014-04-18 14:55:36 +0800 | [diff] [blame] | 1232 | exit 0 |
pbrook | af5db58 | 2006-04-08 14:26:41 +0000 | [diff] [blame] | 1233 | fi |
| 1234 | |
Thomas Huth | 9c79024 | 2019-03-11 11:20:34 +0100 | [diff] [blame] | 1235 | # Remove old dependency files to make sure that they get properly regenerated |
Thomas Huth | bb768f7 | 2019-05-10 10:11:59 +0200 | [diff] [blame] | 1236 | rm -f */config-devices.mak.d |
Thomas Huth | 9c79024 | 2019-03-11 11:20:34 +0100 | [diff] [blame] | 1237 | |
Daniel P. Berrangé | faf4414 | 2019-03-27 17:07:01 +0000 | [diff] [blame] | 1238 | if test -z "$python" |
| 1239 | then |
| 1240 | error_exit "Python not found. Use --python=/path/to/python" |
Stefan Hajnoczi | c53eeaf | 2017-03-28 14:44:18 +0100 | [diff] [blame] | 1241 | fi |
Roman Bolshakov | 8e2c76b | 2020-08-25 23:27:55 +0300 | [diff] [blame] | 1242 | if ! has "$make" |
| 1243 | then |
| 1244 | error_exit "GNU make ($make) not found" |
| 1245 | fi |
Stefan Hajnoczi | c53eeaf | 2017-03-28 14:44:18 +0100 | [diff] [blame] | 1246 | |
| 1247 | # Note that if the Python conditional here evaluates True we will exit |
| 1248 | # with status 1 which is a shell 'false' value. |
Thomas Huth | 1b11f28 | 2020-09-25 16:40:27 +0100 | [diff] [blame] | 1249 | if ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then |
| 1250 | error_exit "Cannot use '$python', Python >= 3.6 is required." \ |
Stefan Hajnoczi | c53eeaf | 2017-03-28 14:44:18 +0100 | [diff] [blame] | 1251 | "Use --python=/path/to/python to specify a supported Python." |
| 1252 | fi |
| 1253 | |
Cleber Rosa | 755ee70 | 2018-11-09 10:07:07 -0500 | [diff] [blame] | 1254 | # Preserve python version since some functionality is dependent on it |
Cleber Rosa | 406ab2f | 2019-08-26 11:58:32 -0400 | [diff] [blame] | 1255 | python_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 Rosa | 755ee70 | 2018-11-09 10:07:07 -0500 | [diff] [blame] | 1256 | |
Stefan Hajnoczi | c53eeaf | 2017-03-28 14:44:18 +0100 | [diff] [blame] | 1257 | # Suppress writing compiled files |
| 1258 | python="$python -B" |
| 1259 | |
Marc-André Lureau | 0a01d76 | 2019-08-21 11:21:16 +0400 | [diff] [blame] | 1260 | if test -z "$meson"; then |
Paolo Bonzini | 6638cae | 2021-10-27 15:18:48 +0200 | [diff] [blame] | 1261 | if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.59.3; then |
Marc-André Lureau | 0a01d76 | 2019-08-21 11:21:16 +0400 | [diff] [blame] | 1262 | meson=meson |
Dan Streetman | 7d7dbf9 | 2021-01-19 12:20:46 -0500 | [diff] [blame] | 1263 | elif test $git_submodules_action != 'ignore' ; then |
Marc-André Lureau | 0a01d76 | 2019-08-21 11:21:16 +0400 | [diff] [blame] | 1264 | meson=git |
| 1265 | elif test -e "${source_path}/meson/meson.py" ; then |
| 1266 | meson=internal |
| 1267 | else |
| 1268 | if test "$explicit_python" = yes; then |
| 1269 | error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found." |
| 1270 | else |
| 1271 | error_exit "Meson not found. Use --meson=/path/to/meson" |
| 1272 | fi |
| 1273 | fi |
| 1274 | else |
| 1275 | # Meson uses its own Python interpreter to invoke other Python scripts, |
| 1276 | # but the user wants to use the one they specified with --python. |
| 1277 | # |
| 1278 | # We do not want to override the distro Python interpreter (and sometimes |
| 1279 | # cannot: for example in Homebrew /usr/bin/meson is a bash script), so |
| 1280 | # just require --meson=git|internal together with --python. |
| 1281 | if test "$explicit_python" = yes; then |
| 1282 | case "$meson" in |
| 1283 | git | internal) ;; |
| 1284 | *) error_exit "--python requires using QEMU's embedded Meson distribution." ;; |
| 1285 | esac |
| 1286 | fi |
Paolo Bonzini | a566505 | 2019-06-10 12:05:14 +0200 | [diff] [blame] | 1287 | fi |
Paolo Bonzini | a566505 | 2019-06-10 12:05:14 +0200 | [diff] [blame] | 1288 | |
Marc-André Lureau | 0a01d76 | 2019-08-21 11:21:16 +0400 | [diff] [blame] | 1289 | if test "$meson" = git; then |
| 1290 | git_submodules="${git_submodules} meson" |
Paolo Bonzini | a566505 | 2019-06-10 12:05:14 +0200 | [diff] [blame] | 1291 | fi |
Marc-André Lureau | 0a01d76 | 2019-08-21 11:21:16 +0400 | [diff] [blame] | 1292 | |
| 1293 | case "$meson" in |
| 1294 | git | internal) |
Marc-André Lureau | 0a01d76 | 2019-08-21 11:21:16 +0400 | [diff] [blame] | 1295 | meson="$python ${source_path}/meson/meson.py" |
| 1296 | ;; |
Paolo Bonzini | 84ec0c2 | 2020-09-04 10:00:26 -0400 | [diff] [blame] | 1297 | *) meson=$(command -v "$meson") ;; |
Marc-André Lureau | 0a01d76 | 2019-08-21 11:21:16 +0400 | [diff] [blame] | 1298 | esac |
| 1299 | |
Paolo Bonzini | 09e9332 | 2020-08-13 09:28:11 -0400 | [diff] [blame] | 1300 | # Probe for ninja |
Paolo Bonzini | 4832888 | 2020-08-26 08:04:15 +0200 | [diff] [blame] | 1301 | |
| 1302 | if test -z "$ninja"; then |
| 1303 | for c in ninja ninja-build samu; do |
| 1304 | if has $c; then |
| 1305 | ninja=$(command -v "$c") |
| 1306 | break |
| 1307 | fi |
| 1308 | done |
Paolo Bonzini | 09e9332 | 2020-08-13 09:28:11 -0400 | [diff] [blame] | 1309 | if test -z "$ninja"; then |
| 1310 | error_exit "Cannot find Ninja" |
| 1311 | fi |
Paolo Bonzini | 4832888 | 2020-08-26 08:04:15 +0200 | [diff] [blame] | 1312 | fi |
Paolo Bonzini | a566505 | 2019-06-10 12:05:14 +0200 | [diff] [blame] | 1313 | |
Daniel Henrique Barboza | 9aae6e5 | 2017-11-02 07:09:06 -0200 | [diff] [blame] | 1314 | # Check that the C compiler works. Doing this here before testing |
| 1315 | # the host CPU ensures that we had a valid CC to autodetect the |
| 1316 | # $cpu var (and we should bail right here if that's not the case). |
| 1317 | # It also allows the help message to be printed without a CC. |
| 1318 | write_c_skeleton; |
| 1319 | if compile_object ; then |
| 1320 | : C compiler works ok |
| 1321 | else |
| 1322 | error_exit "\"$cc\" either does not exist or does not work" |
| 1323 | fi |
| 1324 | if ! compile_prog ; then |
| 1325 | error_exit "\"$cc\" cannot build an executable (is your linker broken?)" |
| 1326 | fi |
| 1327 | |
Peter Maydell | 9c83ffd | 2014-02-25 18:27:49 +0000 | [diff] [blame] | 1328 | # Consult white-list to determine whether to enable werror |
| 1329 | # by default. Only enable by default for git builds |
Peter Maydell | 9c83ffd | 2014-02-25 18:27:49 +0000 | [diff] [blame] | 1330 | if test -z "$werror" ; then |
Dan Streetman | 7d7dbf9 | 2021-01-19 12:20:46 -0500 | [diff] [blame] | 1331 | if test "$git_submodules_action" != "ignore" && \ |
Eric Blake | e633a5c | 2019-02-04 20:39:37 -0600 | [diff] [blame] | 1332 | { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then |
Peter Maydell | 9c83ffd | 2014-02-25 18:27:49 +0000 | [diff] [blame] | 1333 | werror="yes" |
| 1334 | else |
| 1335 | werror="no" |
| 1336 | fi |
| 1337 | fi |
| 1338 | |
Paolo Bonzini | 975ff03 | 2020-11-20 10:34:10 +0100 | [diff] [blame] | 1339 | if test "$targetos" = "bogus"; then |
Peter Maydell | fb59dab | 2017-03-28 14:01:52 +0100 | [diff] [blame] | 1340 | # Now that we know that we're not printing the help and that |
| 1341 | # the compiler works (so the results of the check_defines we used |
| 1342 | # to identify the OS are reliable), if we didn't recognize the |
| 1343 | # host OS we should stop now. |
Peter Maydell | 951fedf | 2017-07-13 16:15:32 +0100 | [diff] [blame] | 1344 | error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')" |
Peter Maydell | fb59dab | 2017-03-28 14:01:52 +0100 | [diff] [blame] | 1345 | fi |
| 1346 | |
Thomas Huth | efc6c07 | 2018-12-03 10:12:32 +0100 | [diff] [blame] | 1347 | # Check whether the compiler matches our minimum requirements: |
| 1348 | cat > $TMPC << EOF |
| 1349 | #if defined(__clang_major__) && defined(__clang_minor__) |
| 1350 | # ifdef __apple_build_version__ |
Daniel P. Berrangé | 2a85a08 | 2021-05-14 13:04:15 +0100 | [diff] [blame] | 1351 | # if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0) |
| 1352 | # error You need at least XCode Clang v10.0 to compile QEMU |
Thomas Huth | efc6c07 | 2018-12-03 10:12:32 +0100 | [diff] [blame] | 1353 | # endif |
| 1354 | # else |
Daniel P. Berrangé | 2a85a08 | 2021-05-14 13:04:15 +0100 | [diff] [blame] | 1355 | # if __clang_major__ < 6 || (__clang_major__ == 6 && __clang_minor__ < 0) |
| 1356 | # error You need at least Clang v6.0 to compile QEMU |
Thomas Huth | efc6c07 | 2018-12-03 10:12:32 +0100 | [diff] [blame] | 1357 | # endif |
| 1358 | # endif |
| 1359 | #elif defined(__GNUC__) && defined(__GNUC_MINOR__) |
nia | 3830df5 | 2021-10-01 15:30:03 +0000 | [diff] [blame] | 1360 | # if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4) |
| 1361 | # error You need at least GCC v7.4.0 to compile QEMU |
Thomas Huth | efc6c07 | 2018-12-03 10:12:32 +0100 | [diff] [blame] | 1362 | # endif |
| 1363 | #else |
| 1364 | # error You either need GCC or Clang to compiler QEMU |
| 1365 | #endif |
| 1366 | int main (void) { return 0; } |
| 1367 | EOF |
| 1368 | if ! compile_prog "" "" ; then |
nia | 3830df5 | 2021-10-01 15:30:03 +0000 | [diff] [blame] | 1369 | error_exit "You need at least GCC v7.4 or Clang v6.0 (or XCode Clang v10.0)" |
Thomas Huth | efc6c07 | 2018-12-03 10:12:32 +0100 | [diff] [blame] | 1370 | fi |
| 1371 | |
Richard Henderson | 00849b9 | 2020-06-17 13:13:06 -0700 | [diff] [blame] | 1372 | # Accumulate -Wfoo and -Wno-bar separately. |
| 1373 | # We will list all of the enable flags first, and the disable flags second. |
| 1374 | # Note that we do not add -Werror, because that would enable it for all |
| 1375 | # configure tests. If a configure test failed due to -Werror this would |
| 1376 | # just silently disable some features, so it's too error prone. |
| 1377 | |
| 1378 | warn_flags= |
| 1379 | add_to warn_flags -Wold-style-declaration |
| 1380 | add_to warn_flags -Wold-style-definition |
| 1381 | add_to warn_flags -Wtype-limits |
| 1382 | add_to warn_flags -Wformat-security |
| 1383 | add_to warn_flags -Wformat-y2k |
| 1384 | add_to warn_flags -Winit-self |
| 1385 | add_to warn_flags -Wignored-qualifiers |
| 1386 | add_to warn_flags -Wempty-body |
| 1387 | add_to warn_flags -Wnested-externs |
| 1388 | add_to warn_flags -Wendif-labels |
| 1389 | add_to warn_flags -Wexpansion-to-defined |
Thomas Huth | 0a2ebce | 2020-12-11 16:24:26 +0100 | [diff] [blame] | 1390 | add_to warn_flags -Wimplicit-fallthrough=2 |
Richard Henderson | 00849b9 | 2020-06-17 13:13:06 -0700 | [diff] [blame] | 1391 | |
| 1392 | nowarn_flags= |
| 1393 | add_to nowarn_flags -Wno-initializer-overrides |
| 1394 | add_to nowarn_flags -Wno-missing-include-dirs |
| 1395 | add_to nowarn_flags -Wno-shift-negative-value |
| 1396 | add_to nowarn_flags -Wno-string-plus-int |
| 1397 | add_to nowarn_flags -Wno-typedef-redefinition |
Richard Henderson | aabab96 | 2020-06-17 13:13:07 -0700 | [diff] [blame] | 1398 | add_to nowarn_flags -Wno-tautological-type-limit-compare |
Richard Henderson | bac8d22 | 2020-06-17 13:13:08 -0700 | [diff] [blame] | 1399 | add_to nowarn_flags -Wno-psabi |
Richard Henderson | 00849b9 | 2020-06-17 13:13:06 -0700 | [diff] [blame] | 1400 | |
| 1401 | gcc_flags="$warn_flags $nowarn_flags" |
John Snow | 93b2586 | 2015-03-25 18:57:37 -0400 | [diff] [blame] | 1402 | |
| 1403 | cc_has_warning_flag() { |
| 1404 | write_c_skeleton; |
| 1405 | |
Peter Maydell | a1d29d6 | 2012-10-27 22:19:07 +0100 | [diff] [blame] | 1406 | # Use the positive sense of the flag when testing for -Wno-wombat |
| 1407 | # support (gcc will happily accept the -Wno- form of unknown |
| 1408 | # warning options). |
John Snow | 93b2586 | 2015-03-25 18:57:37 -0400 | [diff] [blame] | 1409 | optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')" |
| 1410 | compile_prog "-Werror $optflag" "" |
| 1411 | } |
| 1412 | |
Philippe Mathieu-Daudé | 4cb37d1 | 2022-02-15 16:15:13 +0100 | [diff] [blame] | 1413 | objcc_has_warning_flag() { |
| 1414 | cat > $TMPM <<EOF |
| 1415 | int main(void) { return 0; } |
| 1416 | EOF |
| 1417 | |
| 1418 | # Use the positive sense of the flag when testing for -Wno-wombat |
| 1419 | # support (gcc will happily accept the -Wno- form of unknown |
| 1420 | # warning options). |
| 1421 | optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')" |
| 1422 | do_objc -Werror $optflag \ |
| 1423 | $OBJCFLAGS $EXTRA_OBJCFLAGS $CONFIGURE_OBJCFLAGS $QEMU_OBJCFLAGS \ |
| 1424 | -o $TMPE $TMPM $QEMU_LDFLAGS |
| 1425 | } |
| 1426 | |
John Snow | 93b2586 | 2015-03-25 18:57:37 -0400 | [diff] [blame] | 1427 | for flag in $gcc_flags; do |
| 1428 | if cc_has_warning_flag $flag ; then |
| 1429 | QEMU_CFLAGS="$QEMU_CFLAGS $flag" |
Paolo Bonzini | 8d05095 | 2010-12-23 11:43:52 +0100 | [diff] [blame] | 1430 | fi |
Philippe Mathieu-Daudé | 4cb37d1 | 2022-02-15 16:15:13 +0100 | [diff] [blame] | 1431 | if objcc_has_warning_flag $flag ; then |
| 1432 | QEMU_OBJCFLAGS="$QEMU_OBJCFLAGS $flag" |
| 1433 | fi |
Paolo Bonzini | 8d05095 | 2010-12-23 11:43:52 +0100 | [diff] [blame] | 1434 | done |
| 1435 | |
Miroslav Rezanina | 3b463a3 | 2014-07-02 10:05:24 +0200 | [diff] [blame] | 1436 | if test "$stack_protector" != "no"; then |
Rodrigo Rebello | fccd35a | 2015-11-12 12:04:28 -0200 | [diff] [blame] | 1437 | cat > $TMPC << EOF |
| 1438 | int main(int argc, char *argv[]) |
| 1439 | { |
| 1440 | char arr[64], *p = arr, *c = argv[0]; |
| 1441 | while (*c) { |
| 1442 | *p++ = *c++; |
| 1443 | } |
| 1444 | return 0; |
| 1445 | } |
| 1446 | EOF |
Steven Noonan | 63678e1 | 2014-03-28 17:19:02 +0100 | [diff] [blame] | 1447 | gcc_flags="-fstack-protector-strong -fstack-protector-all" |
Miroslav Rezanina | 3b463a3 | 2014-07-02 10:05:24 +0200 | [diff] [blame] | 1448 | sp_on=0 |
Steven Noonan | 63678e1 | 2014-03-28 17:19:02 +0100 | [diff] [blame] | 1449 | for flag in $gcc_flags; do |
Peter Maydell | 590e5dd | 2014-04-11 17:13:52 +0100 | [diff] [blame] | 1450 | # We need to check both a compile and a link, since some compiler |
| 1451 | # setups fail only on a .c->.o compile and some only at link time |
Paolo Bonzini | 086d5f7 | 2020-02-03 15:22:17 +0100 | [diff] [blame] | 1452 | if compile_object "-Werror $flag" && |
Peter Maydell | 590e5dd | 2014-04-11 17:13:52 +0100 | [diff] [blame] | 1453 | compile_prog "-Werror $flag" ""; then |
Steven Noonan | 63678e1 | 2014-03-28 17:19:02 +0100 | [diff] [blame] | 1454 | QEMU_CFLAGS="$QEMU_CFLAGS $flag" |
Paolo Bonzini | db5adea | 2019-12-11 15:34:27 +0100 | [diff] [blame] | 1455 | QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" |
Miroslav Rezanina | 3b463a3 | 2014-07-02 10:05:24 +0200 | [diff] [blame] | 1456 | sp_on=1 |
Steven Noonan | 63678e1 | 2014-03-28 17:19:02 +0100 | [diff] [blame] | 1457 | break |
| 1458 | fi |
| 1459 | done |
Miroslav Rezanina | 3b463a3 | 2014-07-02 10:05:24 +0200 | [diff] [blame] | 1460 | if test "$stack_protector" = yes; then |
| 1461 | if test $sp_on = 0; then |
| 1462 | error_exit "Stack protector not supported" |
| 1463 | fi |
| 1464 | fi |
Marc-André Lureau | 37746c5 | 2013-02-25 23:31:12 +0100 | [diff] [blame] | 1465 | fi |
| 1466 | |
Paolo Bonzini | 20bc94a | 2017-10-20 12:11:32 +0200 | [diff] [blame] | 1467 | # Disable -Wmissing-braces on older compilers that warn even for |
| 1468 | # the "universal" C zero initializer {0}. |
| 1469 | cat > $TMPC << EOF |
| 1470 | struct { |
| 1471 | int a[2]; |
| 1472 | } x = {0}; |
| 1473 | EOF |
| 1474 | if compile_object "-Werror" "" ; then |
| 1475 | : |
| 1476 | else |
| 1477 | QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces" |
| 1478 | fi |
| 1479 | |
Marc-André Lureau | 21e709a | 2019-07-18 16:04:13 +0400 | [diff] [blame] | 1480 | # Our module code doesn't support Windows |
| 1481 | if test "$modules" = "yes" && test "$mingw32" = "yes" ; then |
| 1482 | error_exit "Modules are not available for Windows" |
| 1483 | fi |
| 1484 | |
Alex Bennée | 5f2453a | 2021-07-09 15:29:55 +0100 | [diff] [blame] | 1485 | # Static linking is not possible with plugins, modules or PIE |
Avi Kivity | 40d6444 | 2011-11-15 20:12:17 +0200 | [diff] [blame] | 1486 | if test "$static" = "yes" ; then |
Paolo Bonzini | aa0d1f4 | 2014-02-25 17:36:55 +0100 | [diff] [blame] | 1487 | if test "$modules" = "yes" ; then |
| 1488 | error_exit "static and modules are mutually incompatible" |
| 1489 | fi |
Alex Bennée | 5f2453a | 2021-07-09 15:29:55 +0100 | [diff] [blame] | 1490 | if test "$plugins" = "yes"; then |
| 1491 | error_exit "static and plugins are mutually incompatible" |
Alex Bennée | ba4dd2a | 2021-07-09 15:29:57 +0100 | [diff] [blame] | 1492 | else |
| 1493 | plugins="no" |
Alex Bennée | 5f2453a | 2021-07-09 15:29:55 +0100 | [diff] [blame] | 1494 | fi |
Avi Kivity | 40d6444 | 2011-11-15 20:12:17 +0200 | [diff] [blame] | 1495 | fi |
Paolo Bonzini | 3765068 | 2021-12-10 09:55:15 +0100 | [diff] [blame] | 1496 | test "$plugins" = "" && plugins=yes |
Avi Kivity | 40d6444 | 2011-11-15 20:12:17 +0200 | [diff] [blame] | 1497 | |
Richard Henderson | b263412 | 2019-12-17 13:54:56 -1000 | [diff] [blame] | 1498 | cat > $TMPC << EOF |
Avi Kivity | 21d4a79 | 2011-11-23 11:24:25 +0200 | [diff] [blame] | 1499 | |
| 1500 | #ifdef __linux__ |
| 1501 | # define THREAD __thread |
| 1502 | #else |
| 1503 | # define THREAD |
| 1504 | #endif |
Avi Kivity | 21d4a79 | 2011-11-23 11:24:25 +0200 | [diff] [blame] | 1505 | static THREAD int tls_var; |
Avi Kivity | 21d4a79 | 2011-11-23 11:24:25 +0200 | [diff] [blame] | 1506 | int main(void) { return tls_var; } |
Avi Kivity | 40d6444 | 2011-11-15 20:12:17 +0200 | [diff] [blame] | 1507 | EOF |
Alex Bennée | 412aeac | 2019-08-15 19:41:51 +0000 | [diff] [blame] | 1508 | |
Jessica Clarke | ffd205e | 2021-08-05 20:25:45 +0100 | [diff] [blame] | 1509 | # Check we support -fno-pie and -no-pie first; we will need the former for |
| 1510 | # building ROMs, and both for everything if --disable-pie is passed. |
Richard Henderson | b263412 | 2019-12-17 13:54:56 -1000 | [diff] [blame] | 1511 | if compile_prog "-Werror -fno-pie" "-no-pie"; then |
| 1512 | CFLAGS_NOPIE="-fno-pie" |
Jessica Clarke | ffd205e | 2021-08-05 20:25:45 +0100 | [diff] [blame] | 1513 | LDFLAGS_NOPIE="-no-pie" |
Richard Henderson | b263412 | 2019-12-17 13:54:56 -1000 | [diff] [blame] | 1514 | fi |
| 1515 | |
Richard Henderson | 1278146 | 2019-12-17 15:30:14 -1000 | [diff] [blame] | 1516 | if test "$static" = "yes"; then |
Richard Henderson | eca7a8e | 2020-04-03 20:11:50 +0100 | [diff] [blame] | 1517 | if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then |
Paolo Bonzini | 5770e8a | 2020-09-23 05:26:15 -0400 | [diff] [blame] | 1518 | CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS" |
Richard Henderson | 1278146 | 2019-12-17 15:30:14 -1000 | [diff] [blame] | 1519 | QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS" |
| 1520 | pie="yes" |
| 1521 | elif test "$pie" = "yes"; then |
| 1522 | error_exit "-static-pie not available due to missing toolchain support" |
| 1523 | else |
| 1524 | QEMU_LDFLAGS="-static $QEMU_LDFLAGS" |
| 1525 | pie="no" |
| 1526 | fi |
| 1527 | elif test "$pie" = "no"; then |
Paolo Bonzini | 5770e8a | 2020-09-23 05:26:15 -0400 | [diff] [blame] | 1528 | CONFIGURE_CFLAGS="$CFLAGS_NOPIE $CONFIGURE_CFLAGS" |
Jessica Clarke | ffd205e | 2021-08-05 20:25:45 +0100 | [diff] [blame] | 1529 | CONFIGURE_LDFLAGS="$LDFLAGS_NOPIE $CONFIGURE_LDFLAGS" |
Richard Henderson | eca7a8e | 2020-04-03 20:11:50 +0100 | [diff] [blame] | 1530 | elif compile_prog "-Werror -fPIE -DPIE" "-pie"; then |
Paolo Bonzini | 5770e8a | 2020-09-23 05:26:15 -0400 | [diff] [blame] | 1531 | CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS" |
| 1532 | CONFIGURE_LDFLAGS="-pie $CONFIGURE_LDFLAGS" |
Richard Henderson | 2c67410 | 2019-12-17 15:15:01 -1000 | [diff] [blame] | 1533 | pie="yes" |
| 1534 | elif test "$pie" = "yes"; then |
| 1535 | error_exit "PIE not available due to missing toolchain support" |
| 1536 | else |
| 1537 | echo "Disabling PIE due to missing toolchain support" |
| 1538 | pie="no" |
Avi Kivity | 40d6444 | 2011-11-15 20:12:17 +0200 | [diff] [blame] | 1539 | fi |
| 1540 | |
Richard Henderson | e6cbd75 | 2019-12-17 14:00:39 -1000 | [diff] [blame] | 1541 | # Detect support for PT_GNU_RELRO + DT_BIND_NOW. |
| 1542 | # The combination is known as "full relro", because .got.plt is read-only too. |
| 1543 | if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then |
| 1544 | QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS" |
| 1545 | fi |
| 1546 | |
Paolo Bonzini | 09dada4 | 2013-04-17 16:26:47 +0200 | [diff] [blame] | 1547 | ########################################## |
| 1548 | # __sync_fetch_and_and requires at least -march=i486. Many toolchains |
| 1549 | # use i686 as default anyway, but for those that don't, an explicit |
| 1550 | # specification is necessary |
| 1551 | |
| 1552 | if test "$cpu" = "i386"; then |
| 1553 | cat > $TMPC << EOF |
| 1554 | static int sfaa(int *ptr) |
| 1555 | { |
| 1556 | return __sync_fetch_and_and(ptr, 0); |
| 1557 | } |
| 1558 | |
| 1559 | int main(void) |
| 1560 | { |
| 1561 | int val = 42; |
Stefan Weil | 1405b62 | 2013-05-11 21:46:58 +0200 | [diff] [blame] | 1562 | val = __sync_val_compare_and_swap(&val, 0, 1); |
Paolo Bonzini | 09dada4 | 2013-04-17 16:26:47 +0200 | [diff] [blame] | 1563 | sfaa(&val); |
| 1564 | return val; |
| 1565 | } |
| 1566 | EOF |
| 1567 | if ! compile_prog "" "" ; then |
| 1568 | QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS" |
| 1569 | fi |
| 1570 | fi |
| 1571 | |
Philippe Mathieu-Daudé | 56267b6 | 2021-05-12 06:58:21 +0200 | [diff] [blame] | 1572 | if test "$tcg" = "enabled"; then |
| 1573 | git_submodules="$git_submodules tests/fp/berkeley-testfloat-3" |
| 1574 | git_submodules="$git_submodules tests/fp/berkeley-softfloat-3" |
| 1575 | fi |
| 1576 | |
Stefan Weil | afb63eb | 2012-09-26 22:04:38 +0200 | [diff] [blame] | 1577 | if test -z "${target_list+xxx}" ; then |
Paolo Bonzini | fdb75ae | 2020-09-21 04:37:49 -0400 | [diff] [blame] | 1578 | default_targets=yes |
Paolo Bonzini | d880a3b | 2017-07-03 16:58:28 +0200 | [diff] [blame] | 1579 | for target in $default_target_list; do |
Paolo Bonzini | fdb75ae | 2020-09-21 04:37:49 -0400 | [diff] [blame] | 1580 | target_list="$target_list $target" |
Paolo Bonzini | d880a3b | 2017-07-03 16:58:28 +0200 | [diff] [blame] | 1581 | done |
| 1582 | target_list="${target_list# }" |
Anthony Liguori | 121afa9 | 2012-09-14 08:17:03 -0500 | [diff] [blame] | 1583 | else |
Paolo Bonzini | fdb75ae | 2020-09-21 04:37:49 -0400 | [diff] [blame] | 1584 | default_targets=no |
Stefan Weil | 8913885 | 2016-05-16 15:10:20 +0200 | [diff] [blame] | 1585 | target_list=$(echo "$target_list" | sed -e 's/,/ /g') |
Paolo Bonzini | d880a3b | 2017-07-03 16:58:28 +0200 | [diff] [blame] | 1586 | for target in $target_list; do |
| 1587 | # Check that we recognised the target name; this allows a more |
| 1588 | # friendly error message than if we let it fall through. |
| 1589 | case " $default_target_list " in |
| 1590 | *" $target "*) |
| 1591 | ;; |
| 1592 | *) |
| 1593 | error_exit "Unknown target name '$target'" |
| 1594 | ;; |
| 1595 | esac |
Paolo Bonzini | d880a3b | 2017-07-03 16:58:28 +0200 | [diff] [blame] | 1596 | done |
bellard | 5327cf4 | 2005-01-10 23:18:50 +0000 | [diff] [blame] | 1597 | fi |
Peter Maydell | 25b4833 | 2013-05-20 16:16:16 +0100 | [diff] [blame] | 1598 | |
Paolo Bonzini | f55fe27 | 2010-05-26 16:08:17 +0200 | [diff] [blame] | 1599 | # see if system emulation was really requested |
| 1600 | case " $target_list " in |
| 1601 | *"-softmmu "*) softmmu=yes |
| 1602 | ;; |
| 1603 | *) softmmu=no |
| 1604 | ;; |
| 1605 | esac |
bellard | 5327cf4 | 2005-01-10 23:18:50 +0000 | [diff] [blame] | 1606 | |
Juan Quintela | 249247c | 2009-08-12 18:20:25 +0200 | [diff] [blame] | 1607 | feature_not_found() { |
| 1608 | feature=$1 |
Stewart Smith | 21684af | 2014-01-24 12:39:10 +1100 | [diff] [blame] | 1609 | remedy=$2 |
Juan Quintela | 249247c | 2009-08-12 18:20:25 +0200 | [diff] [blame] | 1610 | |
Peter Maydell | 76ad07a | 2013-04-08 12:11:26 +0100 | [diff] [blame] | 1611 | error_exit "User requested feature $feature" \ |
Stewart Smith | 21684af | 2014-01-24 12:39:10 +1100 | [diff] [blame] | 1612 | "configure was not able to find it." \ |
| 1613 | "$remedy" |
Juan Quintela | 249247c | 2009-08-12 18:20:25 +0200 | [diff] [blame] | 1614 | } |
| 1615 | |
bellard | 7d13299 | 2003-03-06 23:23:54 +0000 | [diff] [blame] | 1616 | # --- |
| 1617 | # big/little endian test |
| 1618 | cat > $TMPC << EOF |
Thomas Huth | 659eb15 | 2021-07-15 10:39:28 +0200 | [diff] [blame] | 1619 | #include <stdio.h> |
Mike Frysinger | 61cc919 | 2013-06-30 23:30:18 -0400 | [diff] [blame] | 1620 | short big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, }; |
| 1621 | short little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, }; |
Thomas Huth | 659eb15 | 2021-07-15 10:39:28 +0200 | [diff] [blame] | 1622 | int main(int argc, char *argv[]) |
| 1623 | { |
| 1624 | return printf("%s %s\n", (char *)big_endian, (char *)little_endian); |
bellard | 7d13299 | 2003-03-06 23:23:54 +0000 | [diff] [blame] | 1625 | } |
| 1626 | EOF |
| 1627 | |
Thomas Huth | 659eb15 | 2021-07-15 10:39:28 +0200 | [diff] [blame] | 1628 | if compile_prog ; then |
| 1629 | if strings -a $TMPE | grep -q BiGeNdIaN ; then |
Mike Frysinger | 61cc919 | 2013-06-30 23:30:18 -0400 | [diff] [blame] | 1630 | bigendian="yes" |
Thomas Huth | 659eb15 | 2021-07-15 10:39:28 +0200 | [diff] [blame] | 1631 | elif strings -a $TMPE | grep -q LiTtLeEnDiAn ; then |
Mike Frysinger | 61cc919 | 2013-06-30 23:30:18 -0400 | [diff] [blame] | 1632 | bigendian="no" |
| 1633 | else |
| 1634 | echo big/little test failed |
Thomas Huth | 659eb15 | 2021-07-15 10:39:28 +0200 | [diff] [blame] | 1635 | exit 1 |
Peter Maydell | 21d89f8 | 2011-11-30 10:57:48 +0100 | [diff] [blame] | 1636 | fi |
Mike Frysinger | 61cc919 | 2013-06-30 23:30:18 -0400 | [diff] [blame] | 1637 | else |
| 1638 | echo big/little test failed |
Thomas Huth | 659eb15 | 2021-07-15 10:39:28 +0200 | [diff] [blame] | 1639 | exit 1 |
bellard | 7d13299 | 2003-03-06 23:23:54 +0000 | [diff] [blame] | 1640 | fi |
| 1641 | |
Paolo Bonzini | 299e6f1 | 2019-02-14 18:35:53 +0100 | [diff] [blame] | 1642 | ######################################### |
| 1643 | # vhost interdependencies and host support |
| 1644 | |
| 1645 | # vhost backends |
Sergio Lopez | eb9baec | 2022-03-04 11:08:53 +0100 | [diff] [blame] | 1646 | if test "$vhost_user" = "yes" && test "$mingw32" = "yes"; then |
| 1647 | error_exit "vhost-user is not available on Windows" |
Paolo Bonzini | 299e6f1 | 2019-02-14 18:35:53 +0100 | [diff] [blame] | 1648 | fi |
Cindy Lu | 108a648 | 2020-07-01 22:55:37 +0800 | [diff] [blame] | 1649 | test "$vhost_vdpa" = "" && vhost_vdpa=$linux |
| 1650 | if test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then |
| 1651 | error_exit "vhost-vdpa is only available on Linux" |
| 1652 | fi |
Paolo Bonzini | 299e6f1 | 2019-02-14 18:35:53 +0100 | [diff] [blame] | 1653 | test "$vhost_kernel" = "" && vhost_kernel=$linux |
| 1654 | if test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then |
| 1655 | error_exit "vhost-kernel is only available on Linux" |
| 1656 | fi |
| 1657 | |
| 1658 | # vhost-kernel devices |
| 1659 | test "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel |
| 1660 | if test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then |
| 1661 | error_exit "--enable-vhost-scsi requires --enable-vhost-kernel" |
| 1662 | fi |
| 1663 | test "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel |
| 1664 | if test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then |
| 1665 | error_exit "--enable-vhost-vsock requires --enable-vhost-kernel" |
| 1666 | fi |
| 1667 | |
| 1668 | # vhost-user backends |
| 1669 | test "$vhost_net_user" = "" && vhost_net_user=$vhost_user |
| 1670 | if test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then |
| 1671 | error_exit "--enable-vhost-net-user requires --enable-vhost-user" |
| 1672 | fi |
| 1673 | test "$vhost_crypto" = "" && vhost_crypto=$vhost_user |
| 1674 | if test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then |
| 1675 | error_exit "--enable-vhost-crypto requires --enable-vhost-user" |
| 1676 | fi |
Dr. David Alan Gilbert | 98fc1ad | 2019-09-30 11:51:34 +0100 | [diff] [blame] | 1677 | test "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user |
| 1678 | if test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then |
| 1679 | error_exit "--enable-vhost-user-fs requires --enable-vhost-user" |
| 1680 | fi |
Cindy Lu | 108a648 | 2020-07-01 22:55:37 +0800 | [diff] [blame] | 1681 | #vhost-vdpa backends |
| 1682 | test "$vhost_net_vdpa" = "" && vhost_net_vdpa=$vhost_vdpa |
| 1683 | if test "$vhost_net_vdpa" = "yes" && test "$vhost_vdpa" = "no"; then |
| 1684 | error_exit "--enable-vhost-net-vdpa requires --enable-vhost-vdpa" |
| 1685 | fi |
Paolo Bonzini | 299e6f1 | 2019-02-14 18:35:53 +0100 | [diff] [blame] | 1686 | |
Laurent Vivier | 40bc0ca | 2020-09-24 23:00:23 +0200 | [diff] [blame] | 1687 | # OR the vhost-kernel, vhost-vdpa and vhost-user values for simplicity |
Paolo Bonzini | 299e6f1 | 2019-02-14 18:35:53 +0100 | [diff] [blame] | 1688 | if test "$vhost_net" = ""; then |
| 1689 | test "$vhost_net_user" = "yes" && vhost_net=yes |
Laurent Vivier | 40bc0ca | 2020-09-24 23:00:23 +0200 | [diff] [blame] | 1690 | test "$vhost_net_vdpa" = "yes" && vhost_net=yes |
Paolo Bonzini | 299e6f1 | 2019-02-14 18:35:53 +0100 | [diff] [blame] | 1691 | test "$vhost_kernel" = "yes" && vhost_net=yes |
| 1692 | fi |
| 1693 | |
Gonglei | 015a33b | 2014-07-01 20:58:08 +0800 | [diff] [blame] | 1694 | ########################################## |
Stefan Weil | 779ab5e | 2012-12-16 11:29:45 +0100 | [diff] [blame] | 1695 | # pkg-config probe |
| 1696 | |
| 1697 | if ! has "$pkg_config_exe"; then |
Peter Maydell | 76ad07a | 2013-04-08 12:11:26 +0100 | [diff] [blame] | 1698 | error_exit "pkg-config binary '$pkg_config_exe' not found" |
Stefan Weil | 779ab5e | 2012-12-16 11:29:45 +0100 | [diff] [blame] | 1699 | fi |
| 1700 | |
| 1701 | ########################################## |
aliguori | e37630c | 2009-04-22 15:19:10 +0000 | [diff] [blame] | 1702 | # xen probe |
| 1703 | |
Paolo Bonzini | 1badb70 | 2020-09-18 04:57:25 -0400 | [diff] [blame] | 1704 | if test "$xen" != "disabled" ; then |
Juergen Gross | c1cdd9d | 2017-03-27 09:42:45 +0200 | [diff] [blame] | 1705 | # Check whether Xen library path is specified via --extra-ldflags to avoid |
| 1706 | # overriding this setting with pkg-config output. If not, try pkg-config |
| 1707 | # to obtain all needed flags. |
Anthony PERARD | d5b93dd | 2011-02-25 16:20:34 +0000 | [diff] [blame] | 1708 | |
Juergen Gross | c1cdd9d | 2017-03-27 09:42:45 +0200 | [diff] [blame] | 1709 | if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \ |
| 1710 | $pkg_config --exists xencontrol ; then |
| 1711 | xen_ctrl_version="$(printf '%d%02d%02d' \ |
| 1712 | $($pkg_config --modversion xencontrol | sed 's/\./ /g') )" |
Paolo Bonzini | 1badb70 | 2020-09-18 04:57:25 -0400 | [diff] [blame] | 1713 | xen=enabled |
Michael Tokarev | 5b6a8f4 | 2020-07-27 17:00:48 +0300 | [diff] [blame] | 1714 | xen_pc="xencontrol xenstore xenforeignmemory xengnttab" |
Juergen Gross | c1cdd9d | 2017-03-27 09:42:45 +0200 | [diff] [blame] | 1715 | xen_pc="$xen_pc xenevtchn xendevicemodel" |
Anthony PERARD | 58ea9a7 | 2017-09-25 16:01:48 +0100 | [diff] [blame] | 1716 | if $pkg_config --exists xentoolcore; then |
| 1717 | xen_pc="$xen_pc xentoolcore" |
| 1718 | fi |
Marc-André Lureau | 582ea95 | 2019-08-15 15:15:32 +0400 | [diff] [blame] | 1719 | xen_cflags="$($pkg_config --cflags $xen_pc)" |
| 1720 | xen_libs="$($pkg_config --libs $xen_pc)" |
Juergen Gross | c1cdd9d | 2017-03-27 09:42:45 +0200 | [diff] [blame] | 1721 | else |
Stefan Weil | 50ced5b | 2011-12-17 09:27:39 +0100 | [diff] [blame] | 1722 | |
Michael Tokarev | 5b6a8f4 | 2020-07-27 17:00:48 +0300 | [diff] [blame] | 1723 | xen_libs="-lxenstore -lxenctrl" |
Anthony PERARD | d9506ca | 2017-05-11 12:35:42 +0100 | [diff] [blame] | 1724 | xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn" |
Juergen Gross | c1cdd9d | 2017-03-27 09:42:45 +0200 | [diff] [blame] | 1725 | |
| 1726 | # First we test whether Xen headers and libraries are available. |
| 1727 | # If no, we are done and there is no Xen support. |
| 1728 | # If yes, more tests are run to detect the Xen version. |
| 1729 | |
| 1730 | # Xen (any) |
| 1731 | cat > $TMPC <<EOF |
aliguori | e37630c | 2009-04-22 15:19:10 +0000 | [diff] [blame] | 1732 | #include <xenctrl.h> |
Stefan Weil | 50ced5b | 2011-12-17 09:27:39 +0100 | [diff] [blame] | 1733 | int main(void) { |
| 1734 | return 0; |
| 1735 | } |
| 1736 | EOF |
Juergen Gross | c1cdd9d | 2017-03-27 09:42:45 +0200 | [diff] [blame] | 1737 | if ! compile_prog "" "$xen_libs" ; then |
| 1738 | # Xen not found |
Paolo Bonzini | 1badb70 | 2020-09-18 04:57:25 -0400 | [diff] [blame] | 1739 | if test "$xen" = "enabled" ; then |
Juergen Gross | c1cdd9d | 2017-03-27 09:42:45 +0200 | [diff] [blame] | 1740 | feature_not_found "xen" "Install xen devel" |
| 1741 | fi |
Paolo Bonzini | 1badb70 | 2020-09-18 04:57:25 -0400 | [diff] [blame] | 1742 | xen=disabled |
Stefan Weil | 50ced5b | 2011-12-17 09:27:39 +0100 | [diff] [blame] | 1743 | |
Juergen Gross | c1cdd9d | 2017-03-27 09:42:45 +0200 | [diff] [blame] | 1744 | # Xen unstable |
| 1745 | elif |
| 1746 | cat > $TMPC <<EOF && |
Ross Lagerwall | 2cbf890 | 2017-10-23 10:27:27 +0100 | [diff] [blame] | 1747 | #undef XC_WANT_COMPAT_DEVICEMODEL_API |
| 1748 | #define __XEN_TOOLS__ |
| 1749 | #include <xendevicemodel.h> |
Paul Durrant | d3c49eb | 2018-05-15 17:40:53 +0100 | [diff] [blame] | 1750 | #include <xenforeignmemory.h> |
Ross Lagerwall | 2cbf890 | 2017-10-23 10:27:27 +0100 | [diff] [blame] | 1751 | int main(void) { |
| 1752 | xendevicemodel_handle *xd; |
Paul Durrant | d3c49eb | 2018-05-15 17:40:53 +0100 | [diff] [blame] | 1753 | xenforeignmemory_handle *xfmem; |
Ross Lagerwall | 2cbf890 | 2017-10-23 10:27:27 +0100 | [diff] [blame] | 1754 | |
| 1755 | xd = xendevicemodel_open(0, 0); |
| 1756 | xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0); |
| 1757 | |
Paul Durrant | d3c49eb | 2018-05-15 17:40:53 +0100 | [diff] [blame] | 1758 | xfmem = xenforeignmemory_open(0, 0); |
| 1759 | xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0); |
| 1760 | |
Ross Lagerwall | 2cbf890 | 2017-10-23 10:27:27 +0100 | [diff] [blame] | 1761 | return 0; |
| 1762 | } |
| 1763 | EOF |
| 1764 | compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore" |
| 1765 | then |
| 1766 | xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore" |
| 1767 | xen_ctrl_version=41100 |
Paolo Bonzini | 1badb70 | 2020-09-18 04:57:25 -0400 | [diff] [blame] | 1768 | xen=enabled |
Ross Lagerwall | 2cbf890 | 2017-10-23 10:27:27 +0100 | [diff] [blame] | 1769 | elif |
| 1770 | cat > $TMPC <<EOF && |
Igor Druzhinin | 5ba3d75 | 2017-07-10 23:40:02 +0100 | [diff] [blame] | 1771 | #undef XC_WANT_COMPAT_MAP_FOREIGN_API |
| 1772 | #include <xenforeignmemory.h> |
Anthony PERARD | 58ea9a7 | 2017-09-25 16:01:48 +0100 | [diff] [blame] | 1773 | #include <xentoolcore.h> |
Igor Druzhinin | 5ba3d75 | 2017-07-10 23:40:02 +0100 | [diff] [blame] | 1774 | int main(void) { |
| 1775 | xenforeignmemory_handle *xfmem; |
| 1776 | |
| 1777 | xfmem = xenforeignmemory_open(0, 0); |
| 1778 | xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0); |
Anthony PERARD | 58ea9a7 | 2017-09-25 16:01:48 +0100 | [diff] [blame] | 1779 | xentoolcore_restrict_all(0); |
Igor Druzhinin | 5ba3d75 | 2017-07-10 23:40:02 +0100 | [diff] [blame] | 1780 | |
| 1781 | return 0; |
| 1782 | } |
| 1783 | EOF |
Anthony PERARD | 58ea9a7 | 2017-09-25 16:01:48 +0100 | [diff] [blame] | 1784 | compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore" |
Igor Druzhinin | 5ba3d75 | 2017-07-10 23:40:02 +0100 | [diff] [blame] | 1785 | then |
Anthony PERARD | 58ea9a7 | 2017-09-25 16:01:48 +0100 | [diff] [blame] | 1786 | xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore" |
Igor Druzhinin | 5ba3d75 | 2017-07-10 23:40:02 +0100 | [diff] [blame] | 1787 | xen_ctrl_version=41000 |
Paolo Bonzini | 1badb70 | 2020-09-18 04:57:25 -0400 | [diff] [blame] | 1788 | xen=enabled |
Igor Druzhinin | 5ba3d75 | 2017-07-10 23:40:02 +0100 | [diff] [blame] | 1789 | elif |
| 1790 | cat > $TMPC <<EOF && |
Paul Durrant | da8090c | 2017-03-07 10:55:33 +0000 | [diff] [blame] | 1791 | #undef XC_WANT_COMPAT_DEVICEMODEL_API |
| 1792 | #define __XEN_TOOLS__ |
| 1793 | #include <xendevicemodel.h> |
| 1794 | int main(void) { |
| 1795 | xendevicemodel_handle *xd; |
| 1796 | |
| 1797 | xd = xendevicemodel_open(0, 0); |
| 1798 | xendevicemodel_close(xd); |
| 1799 | |
| 1800 | return 0; |
| 1801 | } |
| 1802 | EOF |
Juergen Gross | c1cdd9d | 2017-03-27 09:42:45 +0200 | [diff] [blame] | 1803 | compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs" |
| 1804 | then |
| 1805 | xen_stable_libs="-lxendevicemodel $xen_stable_libs" |
| 1806 | xen_ctrl_version=40900 |
Paolo Bonzini | 1badb70 | 2020-09-18 04:57:25 -0400 | [diff] [blame] | 1807 | xen=enabled |
Juergen Gross | c1cdd9d | 2017-03-27 09:42:45 +0200 | [diff] [blame] | 1808 | elif |
| 1809 | cat > $TMPC <<EOF && |
Ian Campbell | 5eeb39c | 2016-01-15 13:23:42 +0000 | [diff] [blame] | 1810 | /* |
| 1811 | * If we have stable libs the we don't want the libxc compat |
| 1812 | * layers, regardless of what CFLAGS we may have been given. |
Paulina Szubarczyk | b6eb9b4 | 2016-09-14 21:10:03 +0200 | [diff] [blame] | 1813 | * |
| 1814 | * Also, check if xengnttab_grant_copy_segment_t is defined and |
| 1815 | * grant copy operation is implemented. |
| 1816 | */ |
| 1817 | #undef XC_WANT_COMPAT_EVTCHN_API |
| 1818 | #undef XC_WANT_COMPAT_GNTTAB_API |
| 1819 | #undef XC_WANT_COMPAT_MAP_FOREIGN_API |
| 1820 | #include <xenctrl.h> |
| 1821 | #include <xenstore.h> |
| 1822 | #include <xenevtchn.h> |
| 1823 | #include <xengnttab.h> |
| 1824 | #include <xenforeignmemory.h> |
| 1825 | #include <stdint.h> |
| 1826 | #include <xen/hvm/hvm_info_table.h> |
| 1827 | #if !defined(HVM_MAX_VCPUS) |
| 1828 | # error HVM_MAX_VCPUS not defined |
| 1829 | #endif |
| 1830 | int main(void) { |
| 1831 | xc_interface *xc = NULL; |
| 1832 | xenforeignmemory_handle *xfmem; |
| 1833 | xenevtchn_handle *xe; |
| 1834 | xengnttab_handle *xg; |
Paulina Szubarczyk | b6eb9b4 | 2016-09-14 21:10:03 +0200 | [diff] [blame] | 1835 | xengnttab_grant_copy_segment_t* seg = NULL; |
| 1836 | |
| 1837 | xs_daemon_open(); |
| 1838 | |
| 1839 | xc = xc_interface_open(0, 0, 0); |
| 1840 | xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); |
| 1841 | xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); |
| 1842 | xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); |
| 1843 | xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL); |
Paulina Szubarczyk | b6eb9b4 | 2016-09-14 21:10:03 +0200 | [diff] [blame] | 1844 | |
| 1845 | xfmem = xenforeignmemory_open(0, 0); |
| 1846 | xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0); |
| 1847 | |
| 1848 | xe = xenevtchn_open(0, 0); |
| 1849 | xenevtchn_fd(xe); |
| 1850 | |
| 1851 | xg = xengnttab_open(0, 0); |
| 1852 | xengnttab_grant_copy(xg, 0, seg); |
| 1853 | |
| 1854 | return 0; |
| 1855 | } |
| 1856 | EOF |
Juergen Gross | c1cdd9d | 2017-03-27 09:42:45 +0200 | [diff] [blame] | 1857 | compile_prog "" "$xen_libs $xen_stable_libs" |
| 1858 | then |
| 1859 | xen_ctrl_version=40800 |
Paolo Bonzini | 1badb70 | 2020-09-18 04:57:25 -0400 | [diff] [blame] | 1860 | xen=enabled |
Juergen Gross | c1cdd9d | 2017-03-27 09:42:45 +0200 | [diff] [blame] | 1861 | elif |
| 1862 | cat > $TMPC <<EOF && |
Paulina Szubarczyk | b6eb9b4 | 2016-09-14 21:10:03 +0200 | [diff] [blame] | 1863 | /* |
| 1864 | * If we have stable libs the we don't want the libxc compat |
| 1865 | * layers, regardless of what CFLAGS we may have been given. |
Ian Campbell | 5eeb39c | 2016-01-15 13:23:42 +0000 | [diff] [blame] | 1866 | */ |
| 1867 | #undef XC_WANT_COMPAT_EVTCHN_API |
| 1868 | #undef XC_WANT_COMPAT_GNTTAB_API |
| 1869 | #undef XC_WANT_COMPAT_MAP_FOREIGN_API |
| 1870 | #include <xenctrl.h> |
| 1871 | #include <xenstore.h> |
| 1872 | #include <xenevtchn.h> |
| 1873 | #include <xengnttab.h> |
| 1874 | #include <xenforeignmemory.h> |
| 1875 | #include <stdint.h> |
| 1876 | #include <xen/hvm/hvm_info_table.h> |
| 1877 | #if !defined(HVM_MAX_VCPUS) |
| 1878 | # error HVM_MAX_VCPUS not defined |
| 1879 | #endif |
| 1880 | int main(void) { |
| 1881 | xc_interface *xc = NULL; |
| 1882 | xenforeignmemory_handle *xfmem; |
| 1883 | xenevtchn_handle *xe; |
| 1884 | xengnttab_handle *xg; |
Ian Campbell | 5eeb39c | 2016-01-15 13:23:42 +0000 | [diff] [blame] | 1885 | |
| 1886 | xs_daemon_open(); |
| 1887 | |
| 1888 | xc = xc_interface_open(0, 0, 0); |
| 1889 | xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); |
| 1890 | xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); |
| 1891 | xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); |
| 1892 | xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL); |
Ian Campbell | 5eeb39c | 2016-01-15 13:23:42 +0000 | [diff] [blame] | 1893 | |
| 1894 | xfmem = xenforeignmemory_open(0, 0); |
| 1895 | xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0); |
| 1896 | |
| 1897 | xe = xenevtchn_open(0, 0); |
| 1898 | xenevtchn_fd(xe); |
| 1899 | |
| 1900 | xg = xengnttab_open(0, 0); |
| 1901 | xengnttab_map_grant_ref(xg, 0, 0, 0); |
| 1902 | |
| 1903 | return 0; |
| 1904 | } |
| 1905 | EOF |
Juergen Gross | c1cdd9d | 2017-03-27 09:42:45 +0200 | [diff] [blame] | 1906 | compile_prog "" "$xen_libs $xen_stable_libs" |
| 1907 | then |
| 1908 | xen_ctrl_version=40701 |
Paolo Bonzini | 1badb70 | 2020-09-18 04:57:25 -0400 | [diff] [blame] | 1909 | xen=enabled |
Roger Pau Monne | cdadde3 | 2015-11-13 17:38:06 +0000 | [diff] [blame] | 1910 | |
Juergen Gross | c1cdd9d | 2017-03-27 09:42:45 +0200 | [diff] [blame] | 1911 | # Xen 4.6 |
| 1912 | elif |
| 1913 | cat > $TMPC <<EOF && |
Roger Pau Monne | cdadde3 | 2015-11-13 17:38:06 +0000 | [diff] [blame] | 1914 | #include <xenctrl.h> |
Anthony PERARD | e108a3c | 2012-06-21 11:44:35 +0000 | [diff] [blame] | 1915 | #include <xenstore.h> |
Anthony PERARD | d5b93dd | 2011-02-25 16:20:34 +0000 | [diff] [blame] | 1916 | #include <stdint.h> |
| 1917 | #include <xen/hvm/hvm_info_table.h> |
| 1918 | #if !defined(HVM_MAX_VCPUS) |
| 1919 | # error HVM_MAX_VCPUS not defined |
| 1920 | #endif |
| 1921 | int main(void) { |
| 1922 | xc_interface *xc; |
| 1923 | xs_daemon_open(); |
| 1924 | xc = xc_interface_open(0, 0, 0); |
| 1925 | xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); |
| 1926 | xc_gnttab_open(NULL, 0); |
Anthony PERARD | b87de24 | 2011-05-24 14:34:20 +0100 | [diff] [blame] | 1927 | xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); |
Stefano Stabellini | 8688e06 | 2012-04-17 17:04:18 +0000 | [diff] [blame] | 1928 | xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); |
Jan Beulich | d8b441a | 2015-07-24 03:38:28 -0600 | [diff] [blame] | 1929 | xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL); |
Konrad Rzeszutek Wilk | 20a544c | 2015-06-29 12:51:05 -0400 | [diff] [blame] | 1930 | xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0); |
Jan Beulich | d8b441a | 2015-07-24 03:38:28 -0600 | [diff] [blame] | 1931 | return 0; |
| 1932 | } |
| 1933 | EOF |
Juergen Gross | c1cdd9d | 2017-03-27 09:42:45 +0200 | [diff] [blame] | 1934 | compile_prog "" "$xen_libs" |
| 1935 | then |
| 1936 | xen_ctrl_version=40600 |
Paolo Bonzini | 1badb70 | 2020-09-18 04:57:25 -0400 | [diff] [blame] | 1937 | xen=enabled |
Jan Beulich | d8b441a | 2015-07-24 03:38:28 -0600 | [diff] [blame] | 1938 | |
Juergen Gross | c1cdd9d | 2017-03-27 09:42:45 +0200 | [diff] [blame] | 1939 | # Xen 4.5 |
| 1940 | elif |
| 1941 | cat > $TMPC <<EOF && |
Jan Beulich | d8b441a | 2015-07-24 03:38:28 -0600 | [diff] [blame] | 1942 | #include <xenctrl.h> |
| 1943 | #include <xenstore.h> |
| 1944 | #include <stdint.h> |
| 1945 | #include <xen/hvm/hvm_info_table.h> |
| 1946 | #if !defined(HVM_MAX_VCPUS) |
| 1947 | # error HVM_MAX_VCPUS not defined |
| 1948 | #endif |
| 1949 | int main(void) { |
| 1950 | xc_interface *xc; |
| 1951 | xs_daemon_open(); |
| 1952 | xc = xc_interface_open(0, 0, 0); |
| 1953 | xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); |
| 1954 | xc_gnttab_open(NULL, 0); |
| 1955 | xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); |
| 1956 | xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); |
Paul Durrant | 3996e85 | 2015-01-20 11:06:19 +0000 | [diff] [blame] | 1957 | xc_hvm_create_ioreq_server(xc, 0, 0, NULL); |
| 1958 | return 0; |
| 1959 | } |
| 1960 | EOF |
Juergen Gross | c1cdd9d | 2017-03-27 09:42:45 +0200 | [diff] [blame] | 1961 | compile_prog "" "$xen_libs" |
| 1962 | then |
| 1963 | xen_ctrl_version=40500 |
Paolo Bonzini | 1badb70 | 2020-09-18 04:57:25 -0400 | [diff] [blame] | 1964 | xen=enabled |
Paul Durrant | 3996e85 | 2015-01-20 11:06:19 +0000 | [diff] [blame] | 1965 | |
Juergen Gross | c1cdd9d | 2017-03-27 09:42:45 +0200 | [diff] [blame] | 1966 | elif |
| 1967 | cat > $TMPC <<EOF && |
Paul Durrant | 3996e85 | 2015-01-20 11:06:19 +0000 | [diff] [blame] | 1968 | #include <xenctrl.h> |
| 1969 | #include <xenstore.h> |
| 1970 | #include <stdint.h> |
| 1971 | #include <xen/hvm/hvm_info_table.h> |
| 1972 | #if !defined(HVM_MAX_VCPUS) |
| 1973 | # error HVM_MAX_VCPUS not defined |
| 1974 | #endif |
| 1975 | int main(void) { |
| 1976 | xc_interface *xc; |
| 1977 | xs_daemon_open(); |
| 1978 | xc = xc_interface_open(0, 0, 0); |
| 1979 | xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); |
| 1980 | xc_gnttab_open(NULL, 0); |
| 1981 | xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); |
| 1982 | xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); |
Stefano Stabellini | 8688e06 | 2012-04-17 17:04:18 +0000 | [diff] [blame] | 1983 | return 0; |
| 1984 | } |
| 1985 | EOF |
Juergen Gross | c1cdd9d | 2017-03-27 09:42:45 +0200 | [diff] [blame] | 1986 | compile_prog "" "$xen_libs" |
| 1987 | then |
| 1988 | xen_ctrl_version=40200 |
Paolo Bonzini | 1badb70 | 2020-09-18 04:57:25 -0400 | [diff] [blame] | 1989 | xen=enabled |
Stefano Stabellini | 8688e06 | 2012-04-17 17:04:18 +0000 | [diff] [blame] | 1990 | |
Juergen Gross | c1cdd9d | 2017-03-27 09:42:45 +0200 | [diff] [blame] | 1991 | else |
Paolo Bonzini | 1badb70 | 2020-09-18 04:57:25 -0400 | [diff] [blame] | 1992 | if test "$xen" = "enabled" ; then |
Juergen Gross | c1cdd9d | 2017-03-27 09:42:45 +0200 | [diff] [blame] | 1993 | feature_not_found "xen (unsupported version)" \ |
| 1994 | "Install a supported xen (xen 4.2 or newer)" |
| 1995 | fi |
Paolo Bonzini | 1badb70 | 2020-09-18 04:57:25 -0400 | [diff] [blame] | 1996 | xen=disabled |
Juan Quintela | fc321b4 | 2009-08-12 18:29:55 +0200 | [diff] [blame] | 1997 | fi |
Anthony PERARD | d5b93dd | 2011-02-25 16:20:34 +0000 | [diff] [blame] | 1998 | |
Paolo Bonzini | 1badb70 | 2020-09-18 04:57:25 -0400 | [diff] [blame] | 1999 | if test "$xen" = enabled; then |
Juergen Gross | c1cdd9d | 2017-03-27 09:42:45 +0200 | [diff] [blame] | 2000 | if test $xen_ctrl_version -ge 40701 ; then |
Marc-André Lureau | 582ea95 | 2019-08-15 15:15:32 +0400 | [diff] [blame] | 2001 | xen_libs="$xen_libs $xen_stable_libs " |
Juergen Gross | c1cdd9d | 2017-03-27 09:42:45 +0200 | [diff] [blame] | 2002 | fi |
Ian Campbell | 5eeb39c | 2016-01-15 13:23:42 +0000 | [diff] [blame] | 2003 | fi |
Anthony PERARD | d5b93dd | 2011-02-25 16:20:34 +0000 | [diff] [blame] | 2004 | fi |
aliguori | e37630c | 2009-04-22 15:19:10 +0000 | [diff] [blame] | 2005 | fi |
| 2006 | |
| 2007 | ########################################## |
Anthony Liguori | e18df14 | 2011-07-19 14:50:29 -0500 | [diff] [blame] | 2008 | # glib support probe |
Paolo Bonzini | a52d28a | 2012-04-05 13:01:54 +0200 | [diff] [blame] | 2009 | |
Daniel P. Berrangé | b4c6036 | 2021-05-14 13:04:13 +0100 | [diff] [blame] | 2010 | glib_req_ver=2.56 |
Paolo Bonzini | aa0d1f4 | 2014-02-25 17:36:55 +0100 | [diff] [blame] | 2011 | glib_modules=gthread-2.0 |
| 2012 | if test "$modules" = yes; then |
Gerd Hoffmann | a88afc6 | 2018-03-08 09:53:00 +0100 | [diff] [blame] | 2013 | glib_modules="$glib_modules gmodule-export-2.0" |
Paolo Bonzini | b906aca | 2021-08-11 12:05:50 +0200 | [diff] [blame] | 2014 | elif test "$plugins" = "yes"; then |
| 2015 | glib_modules="$glib_modules gmodule-no-export-2.0" |
Emilio G. Cota | 54cb65d | 2017-08-30 18:39:53 -0400 | [diff] [blame] | 2016 | fi |
Fam Zheng | e26110c | 2014-02-10 14:48:57 +0800 | [diff] [blame] | 2017 | |
Paolo Bonzini | aa0d1f4 | 2014-02-25 17:36:55 +0100 | [diff] [blame] | 2018 | for i in $glib_modules; do |
Fam Zheng | e26110c | 2014-02-10 14:48:57 +0800 | [diff] [blame] | 2019 | if $pkg_config --atleast-version=$glib_req_ver $i; then |
Stefan Weil | 8913885 | 2016-05-16 15:10:20 +0200 | [diff] [blame] | 2020 | glib_cflags=$($pkg_config --cflags $i) |
| 2021 | glib_libs=$($pkg_config --libs $i) |
Fam Zheng | e26110c | 2014-02-10 14:48:57 +0800 | [diff] [blame] | 2022 | else |
| 2023 | error_exit "glib-$glib_req_ver $i is required to compile QEMU" |
| 2024 | fi |
| 2025 | done |
| 2026 | |
Paolo Bonzini | 215b0c2 | 2020-09-01 08:41:17 -0400 | [diff] [blame] | 2027 | # This workaround is required due to a bug in pkg-config file for glib as it |
| 2028 | # doesn't define GLIB_STATIC_COMPILATION for pkg-config --static |
| 2029 | |
| 2030 | if test "$static" = yes && test "$mingw32" = yes; then |
| 2031 | glib_cflags="-DGLIB_STATIC_COMPILATION $glib_cflags" |
| 2032 | fi |
| 2033 | |
Daniel P. Berrange | 977a82a | 2016-01-27 09:00:45 +0000 | [diff] [blame] | 2034 | # Sanity check that the current size_t matches the |
| 2035 | # size that glib thinks it should be. This catches |
| 2036 | # problems on multi-arch where people try to build |
| 2037 | # 32-bit QEMU while pointing at 64-bit glib headers |
| 2038 | cat > $TMPC <<EOF |
| 2039 | #include <glib.h> |
| 2040 | #include <unistd.h> |
| 2041 | |
| 2042 | #define QEMU_BUILD_BUG_ON(x) \ |
| 2043 | typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused)); |
| 2044 | |
| 2045 | int main(void) { |
| 2046 | QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T); |
| 2047 | return 0; |
| 2048 | } |
| 2049 | EOF |
| 2050 | |
Paolo Bonzini | 215b0c2 | 2020-09-01 08:41:17 -0400 | [diff] [blame] | 2051 | if ! compile_prog "$glib_cflags" "$glib_libs" ; then |
Daniel P. Berrange | 977a82a | 2016-01-27 09:00:45 +0000 | [diff] [blame] | 2052 | error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\ |
| 2053 | "You probably need to set PKG_CONFIG_LIBDIR"\ |
| 2054 | "to point to the right pkg-config files for your"\ |
| 2055 | "build target" |
| 2056 | fi |
| 2057 | |
Eric Blake | 9bda600 | 2020-03-17 12:55:34 -0500 | [diff] [blame] | 2058 | # Silence clang warnings triggered by glib < 2.57.2 |
| 2059 | cat > $TMPC << EOF |
| 2060 | #include <glib.h> |
| 2061 | typedef struct Foo { |
| 2062 | int i; |
| 2063 | } Foo; |
| 2064 | static void foo_free(Foo *f) |
| 2065 | { |
| 2066 | g_free(f); |
| 2067 | } |
Marc-André Lureau | e0e7fe0 | 2022-03-12 02:22:02 +0400 | [diff] [blame] | 2068 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free) |
Eric Blake | 9bda600 | 2020-03-17 12:55:34 -0500 | [diff] [blame] | 2069 | int main(void) { return 0; } |
| 2070 | EOF |
| 2071 | if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then |
| 2072 | if cc_has_warning_flag "-Wno-unused-function"; then |
| 2073 | glib_cflags="$glib_cflags -Wno-unused-function" |
Paolo Bonzini | 5770e8a | 2020-09-23 05:26:15 -0400 | [diff] [blame] | 2074 | CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -Wno-unused-function" |
Eric Blake | 9bda600 | 2020-03-17 12:55:34 -0500 | [diff] [blame] | 2075 | fi |
| 2076 | fi |
| 2077 | |
Fam Zheng | e26110c | 2014-02-10 14:48:57 +0800 | [diff] [blame] | 2078 | ########################################## |
| 2079 | # SHA command probe for modules |
| 2080 | if test "$modules" = yes; then |
| 2081 | shacmd_probe="sha1sum sha1 shasum" |
| 2082 | for c in $shacmd_probe; do |
Fam Zheng | 8ccefb9 | 2014-12-04 14:18:16 +0800 | [diff] [blame] | 2083 | if has $c; then |
Fam Zheng | e26110c | 2014-02-10 14:48:57 +0800 | [diff] [blame] | 2084 | shacmd="$c" |
| 2085 | break |
| 2086 | fi |
| 2087 | done |
| 2088 | if test "$shacmd" = ""; then |
| 2089 | error_exit "one of the checksum commands is required to enable modules: $shacmd_probe" |
| 2090 | fi |
Anthony Liguori | e18df14 | 2011-07-19 14:50:29 -0500 | [diff] [blame] | 2091 | fi |
| 2092 | |
| 2093 | ########################################## |
aurel32 | f652e6a | 2008-12-16 10:43:48 +0000 | [diff] [blame] | 2094 | # fdt probe |
Paolo Bonzini | fbb4121 | 2020-10-05 11:31:15 +0200 | [diff] [blame] | 2095 | |
| 2096 | case "$fdt" in |
| 2097 | auto | enabled | internal) |
| 2098 | # Simpler to always update submodule, even if not needed. |
Paolo Bonzini | 2d652f2 | 2021-05-12 09:21:56 +0200 | [diff] [blame] | 2099 | git_submodules="${git_submodules} dtc" |
Peter Maydell | e169e1e | 2013-05-24 16:26:54 +0100 | [diff] [blame] | 2100 | ;; |
Paolo Bonzini | fbb4121 | 2020-10-05 11:31:15 +0200 | [diff] [blame] | 2101 | esac |
aurel32 | f652e6a | 2008-12-16 10:43:48 +0000 | [diff] [blame] | 2102 | |
Michael Walle | 20ff075 | 2011-03-07 23:32:39 +0100 | [diff] [blame] | 2103 | ########################################## |
Richard Henderson | 8ca8076 | 2017-09-14 09:41:12 -0700 | [diff] [blame] | 2104 | # capstone |
| 2105 | |
Richard Henderson | e219c49 | 2017-09-28 09:01:23 -0700 | [diff] [blame] | 2106 | case "$capstone" in |
Richard Henderson | 8b18cdb | 2020-09-13 12:19:25 -0700 | [diff] [blame] | 2107 | auto | enabled | internal) |
| 2108 | # Simpler to always update submodule, even if not needed. |
Paolo Bonzini | 2d652f2 | 2021-05-12 09:21:56 +0200 | [diff] [blame] | 2109 | git_submodules="${git_submodules} capstone" |
Richard Henderson | e219c49 | 2017-09-28 09:01:23 -0700 | [diff] [blame] | 2110 | ;; |
| 2111 | esac |
Richard Henderson | 8ca8076 | 2017-09-14 09:41:12 -0700 | [diff] [blame] | 2112 | |
| 2113 | ########################################## |
Alex Barcelo | 519175a | 2012-02-28 12:25:50 +0100 | [diff] [blame] | 2114 | # check and set a backend for coroutine |
Aneesh Kumar K.V | d0e2fce | 2011-06-09 23:11:06 +0530 | [diff] [blame] | 2115 | |
Peter Maydell | 7c2acc7 | 2013-04-08 12:11:27 +0100 | [diff] [blame] | 2116 | # We prefer ucontext, but it's not always possible. The fallback |
Daniel P. Berrange | 33c53c5 | 2017-04-28 13:24:44 +0100 | [diff] [blame] | 2117 | # is sigcontext. On Windows the only valid backend is the Windows |
| 2118 | # specific one. |
Peter Maydell | 7c2acc7 | 2013-04-08 12:11:27 +0100 | [diff] [blame] | 2119 | |
| 2120 | ucontext_works=no |
| 2121 | if test "$darwin" != "yes"; then |
| 2122 | cat > $TMPC << EOF |
Aneesh Kumar K.V | d0e2fce | 2011-06-09 23:11:06 +0530 | [diff] [blame] | 2123 | #include <ucontext.h> |
Peter Maydell | cdf8480 | 2012-02-23 16:20:05 +0000 | [diff] [blame] | 2124 | #ifdef __stub_makecontext |
| 2125 | #error Ignoring glibc stub makecontext which will always fail |
| 2126 | #endif |
Stefan Weil | 75cafad | 2011-12-17 09:27:29 +0100 | [diff] [blame] | 2127 | int main(void) { makecontext(0, 0, 0); return 0; } |
Aneesh Kumar K.V | d0e2fce | 2011-06-09 23:11:06 +0530 | [diff] [blame] | 2128 | EOF |
Peter Maydell | 7c2acc7 | 2013-04-08 12:11:27 +0100 | [diff] [blame] | 2129 | if compile_prog "" "" ; then |
| 2130 | ucontext_works=yes |
Aneesh Kumar K.V | d0e2fce | 2011-06-09 23:11:06 +0530 | [diff] [blame] | 2131 | fi |
Peter Maydell | 7c2acc7 | 2013-04-08 12:11:27 +0100 | [diff] [blame] | 2132 | fi |
| 2133 | |
| 2134 | if test "$coroutine" = ""; then |
| 2135 | if test "$mingw32" = "yes"; then |
| 2136 | coroutine=win32 |
| 2137 | elif test "$ucontext_works" = "yes"; then |
| 2138 | coroutine=ucontext |
| 2139 | else |
| 2140 | coroutine=sigaltstack |
| 2141 | fi |
Alex Barcelo | 519175a | 2012-02-28 12:25:50 +0100 | [diff] [blame] | 2142 | else |
Peter Maydell | 7c2acc7 | 2013-04-08 12:11:27 +0100 | [diff] [blame] | 2143 | case $coroutine in |
| 2144 | windows) |
| 2145 | if test "$mingw32" != "yes"; then |
| 2146 | error_exit "'windows' coroutine backend only valid for Windows" |
| 2147 | fi |
| 2148 | # Unfortunately the user visible backend name doesn't match the |
| 2149 | # coroutine-*.c filename for this case, so we have to adjust it here. |
| 2150 | coroutine=win32 |
| 2151 | ;; |
| 2152 | ucontext) |
| 2153 | if test "$ucontext_works" != "yes"; then |
| 2154 | feature_not_found "ucontext" |
| 2155 | fi |
| 2156 | ;; |
Daniel P. Berrange | 33c53c5 | 2017-04-28 13:24:44 +0100 | [diff] [blame] | 2157 | sigaltstack) |
Peter Maydell | 7c2acc7 | 2013-04-08 12:11:27 +0100 | [diff] [blame] | 2158 | if test "$mingw32" = "yes"; then |
| 2159 | error_exit "only the 'windows' coroutine backend is valid for Windows" |
| 2160 | fi |
| 2161 | ;; |
| 2162 | *) |
| 2163 | error_exit "unknown coroutine backend $coroutine" |
| 2164 | ;; |
| 2165 | esac |
Aneesh Kumar K.V | d0e2fce | 2011-06-09 23:11:06 +0530 | [diff] [blame] | 2166 | fi |
| 2167 | |
Daniele Buono | 1e4f606 | 2020-05-29 16:51:21 -0400 | [diff] [blame] | 2168 | ################################################## |
| 2169 | # SafeStack |
| 2170 | |
| 2171 | |
| 2172 | if test "$safe_stack" = "yes"; then |
| 2173 | cat > $TMPC << EOF |
| 2174 | int main(int argc, char *argv[]) |
| 2175 | { |
| 2176 | #if ! __has_feature(safe_stack) |
| 2177 | #error SafeStack Disabled |
| 2178 | #endif |
| 2179 | return 0; |
| 2180 | } |
| 2181 | EOF |
| 2182 | flag="-fsanitize=safe-stack" |
| 2183 | # Check that safe-stack is supported and enabled. |
| 2184 | if compile_prog "-Werror $flag" "$flag"; then |
| 2185 | # Flag needed both at compilation and at linking |
| 2186 | QEMU_CFLAGS="$QEMU_CFLAGS $flag" |
| 2187 | QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" |
| 2188 | else |
| 2189 | error_exit "SafeStack not supported by your compiler" |
| 2190 | fi |
| 2191 | if test "$coroutine" != "ucontext"; then |
| 2192 | error_exit "SafeStack is only supported by the coroutine backend ucontext" |
| 2193 | fi |
| 2194 | else |
| 2195 | cat > $TMPC << EOF |
| 2196 | int main(int argc, char *argv[]) |
| 2197 | { |
| 2198 | #if defined(__has_feature) |
| 2199 | #if __has_feature(safe_stack) |
| 2200 | #error SafeStack Enabled |
| 2201 | #endif |
| 2202 | #endif |
| 2203 | return 0; |
| 2204 | } |
| 2205 | EOF |
| 2206 | if test "$safe_stack" = "no"; then |
| 2207 | # Make sure that safe-stack is disabled |
| 2208 | if ! compile_prog "-Werror" ""; then |
| 2209 | # SafeStack was already enabled, try to explicitly remove the feature |
| 2210 | flag="-fno-sanitize=safe-stack" |
| 2211 | if ! compile_prog "-Werror $flag" "$flag"; then |
| 2212 | error_exit "Configure cannot disable SafeStack" |
| 2213 | fi |
| 2214 | QEMU_CFLAGS="$QEMU_CFLAGS $flag" |
| 2215 | QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" |
| 2216 | fi |
| 2217 | else # "$safe_stack" = "" |
| 2218 | # Set safe_stack to yes or no based on pre-existing flags |
| 2219 | if compile_prog "-Werror" ""; then |
| 2220 | safe_stack="no" |
| 2221 | else |
| 2222 | safe_stack="yes" |
| 2223 | if test "$coroutine" != "ucontext"; then |
| 2224 | error_exit "SafeStack is only supported by the coroutine backend ucontext" |
| 2225 | fi |
| 2226 | fi |
| 2227 | fi |
| 2228 | fi |
Peter Lieven | 7d992e4 | 2016-09-27 11:58:45 +0200 | [diff] [blame] | 2229 | |
Richard Henderson | 76a347e | 2012-12-28 14:17:02 -0800 | [diff] [blame] | 2230 | ######################################## |
John Snow | fd0e605 | 2015-03-25 18:57:39 -0400 | [diff] [blame] | 2231 | # check if ccache is interfering with |
| 2232 | # semantic analysis of macros |
| 2233 | |
John Snow | 5e4dfd3 | 2015-10-28 13:56:40 -0400 | [diff] [blame] | 2234 | unset CCACHE_CPP2 |
John Snow | fd0e605 | 2015-03-25 18:57:39 -0400 | [diff] [blame] | 2235 | ccache_cpp2=no |
| 2236 | cat > $TMPC << EOF |
| 2237 | static const int Z = 1; |
| 2238 | #define fn() ({ Z; }) |
| 2239 | #define TAUT(X) ((X) == Z) |
| 2240 | #define PAREN(X, Y) (X == Y) |
| 2241 | #define ID(X) (X) |
| 2242 | int main(int argc, char *argv[]) |
| 2243 | { |
| 2244 | int x = 0, y = 0; |
| 2245 | x = ID(x); |
| 2246 | x = fn(); |
| 2247 | fn(); |
| 2248 | if (PAREN(x, y)) return 0; |
| 2249 | if (TAUT(Z)) return 0; |
| 2250 | return 0; |
| 2251 | } |
| 2252 | EOF |
| 2253 | |
| 2254 | if ! compile_object "-Werror"; then |
| 2255 | ccache_cpp2=yes |
| 2256 | fi |
| 2257 | |
John Snow | b553a04 | 2015-11-03 15:43:42 -0500 | [diff] [blame] | 2258 | ################################################# |
| 2259 | # clang does not support glibc + FORTIFY_SOURCE. |
| 2260 | |
| 2261 | if test "$fortify_source" != "no"; then |
| 2262 | if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then |
| 2263 | fortify_source="no"; |
Peter Maydell | e189091 | 2017-06-26 16:25:24 +0100 | [diff] [blame] | 2264 | elif test -n "$cxx" && has $cxx && |
John Snow | cfcc7c1 | 2015-11-12 11:29:49 -0500 | [diff] [blame] | 2265 | echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then |
John Snow | b553a04 | 2015-11-03 15:43:42 -0500 | [diff] [blame] | 2266 | fortify_source="no"; |
| 2267 | else |
| 2268 | fortify_source="yes" |
| 2269 | fi |
| 2270 | fi |
| 2271 | |
Aneesh Kumar K.V | d204237 | 2011-10-12 19:11:24 +0530 | [diff] [blame] | 2272 | ########################################## |
Marc-André Lureau | 247724c | 2018-01-16 16:11:51 +0100 | [diff] [blame] | 2273 | # checks for sanitizers |
| 2274 | |
Marc-André Lureau | 247724c | 2018-01-16 16:11:51 +0100 | [diff] [blame] | 2275 | have_asan=no |
| 2276 | have_ubsan=no |
Marc-André Lureau | d83414e | 2018-01-16 16:11:52 +0100 | [diff] [blame] | 2277 | have_asan_iface_h=no |
| 2278 | have_asan_iface_fiber=no |
Marc-André Lureau | 247724c | 2018-01-16 16:11:51 +0100 | [diff] [blame] | 2279 | |
| 2280 | if test "$sanitizers" = "yes" ; then |
Marc-André Lureau | b9f44da | 2018-02-15 22:25:47 +0100 | [diff] [blame] | 2281 | write_c_skeleton |
Marc-André Lureau | 247724c | 2018-01-16 16:11:51 +0100 | [diff] [blame] | 2282 | if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then |
| 2283 | have_asan=yes |
| 2284 | fi |
Marc-André Lureau | b9f44da | 2018-02-15 22:25:47 +0100 | [diff] [blame] | 2285 | |
| 2286 | # we could use a simple skeleton for flags checks, but this also |
| 2287 | # detect the static linking issue of ubsan, see also: |
| 2288 | # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285 |
| 2289 | cat > $TMPC << EOF |
| 2290 | #include <stdlib.h> |
| 2291 | int main(void) { |
| 2292 | void *tmp = malloc(10); |
Leonid Bloch | f2dfe54 | 2020-05-25 01:12:04 +0300 | [diff] [blame] | 2293 | if (tmp != NULL) { |
| 2294 | return *(int *)(tmp + 2); |
| 2295 | } |
Olaf Hering | d1abf3f | 2020-07-07 19:13:25 +0200 | [diff] [blame] | 2296 | return 1; |
Marc-André Lureau | b9f44da | 2018-02-15 22:25:47 +0100 | [diff] [blame] | 2297 | } |
| 2298 | EOF |
Marc-André Lureau | 247724c | 2018-01-16 16:11:51 +0100 | [diff] [blame] | 2299 | if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then |
| 2300 | have_ubsan=yes |
| 2301 | fi |
Marc-André Lureau | d83414e | 2018-01-16 16:11:52 +0100 | [diff] [blame] | 2302 | |
| 2303 | if check_include "sanitizer/asan_interface.h" ; then |
| 2304 | have_asan_iface_h=yes |
| 2305 | fi |
| 2306 | |
| 2307 | cat > $TMPC << EOF |
| 2308 | #include <sanitizer/asan_interface.h> |
| 2309 | int main(void) { |
| 2310 | __sanitizer_start_switch_fiber(0, 0, 0); |
| 2311 | return 0; |
| 2312 | } |
| 2313 | EOF |
| 2314 | if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then |
| 2315 | have_asan_iface_fiber=yes |
| 2316 | fi |
Marc-André Lureau | 247724c | 2018-01-16 16:11:51 +0100 | [diff] [blame] | 2317 | fi |
| 2318 | |
Lingfeng Yang | 0aebab0 | 2020-06-12 20:02:23 +0100 | [diff] [blame] | 2319 | # Thread sanitizer is, for now, much noisier than the other sanitizers; |
| 2320 | # keep it separate until that is not the case. |
| 2321 | if test "$tsan" = "yes" && test "$sanitizers" = "yes"; then |
| 2322 | error_exit "TSAN is not supported with other sanitiziers." |
| 2323 | fi |
| 2324 | have_tsan=no |
| 2325 | have_tsan_iface_fiber=no |
| 2326 | if test "$tsan" = "yes" ; then |
| 2327 | write_c_skeleton |
| 2328 | if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then |
| 2329 | have_tsan=yes |
| 2330 | fi |
| 2331 | cat > $TMPC << EOF |
| 2332 | #include <sanitizer/tsan_interface.h> |
| 2333 | int main(void) { |
| 2334 | __tsan_create_fiber(0); |
| 2335 | return 0; |
| 2336 | } |
| 2337 | EOF |
| 2338 | if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then |
| 2339 | have_tsan_iface_fiber=yes |
| 2340 | fi |
| 2341 | fi |
| 2342 | |
Alexander Bulekov | adc2802 | 2020-02-19 23:11:14 -0500 | [diff] [blame] | 2343 | ########################################## |
Marc-André Lureau | 675b9b5 | 2019-02-12 17:25:23 +0100 | [diff] [blame] | 2344 | # check for slirp |
| 2345 | |
| 2346 | case "$slirp" in |
Paolo Bonzini | 4d34a86 | 2020-10-05 11:31:15 +0200 | [diff] [blame] | 2347 | auto | enabled | internal) |
| 2348 | # Simpler to always update submodule, even if not needed. |
Paolo Bonzini | 2d652f2 | 2021-05-12 09:21:56 +0200 | [diff] [blame] | 2349 | git_submodules="${git_submodules} slirp" |
Marc-André Lureau | 675b9b5 | 2019-02-12 17:25:23 +0100 | [diff] [blame] | 2350 | ;; |
| 2351 | esac |
| 2352 | |
Alexey Krasikov | 54e7aac | 2020-05-25 14:19:12 +0300 | [diff] [blame] | 2353 | ########################################## |
Juan Quintela | e86ecd4 | 2009-08-03 14:45:59 +0200 | [diff] [blame] | 2354 | # End of CC checks |
| 2355 | # After here, no more $cc or $ld runs |
| 2356 | |
Marc-André Lureau | d83414e | 2018-01-16 16:11:52 +0100 | [diff] [blame] | 2357 | write_c_skeleton |
| 2358 | |
Paolo Bonzini | df42fa7 | 2022-04-20 17:33:38 +0200 | [diff] [blame] | 2359 | if test "$fortify_source" = "yes" ; then |
Paolo Bonzini | 086d5f7 | 2020-02-03 15:22:17 +0100 | [diff] [blame] | 2360 | QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS" |
| 2361 | debug=no |
| 2362 | fi |
Paolo Bonzini | 086d5f7 | 2020-02-03 15:22:17 +0100 | [diff] [blame] | 2363 | |
| 2364 | case "$ARCH" in |
| 2365 | alpha) |
| 2366 | # Ensure there's only a single GP |
| 2367 | QEMU_CFLAGS="-msmall-data $QEMU_CFLAGS" |
| 2368 | ;; |
| 2369 | esac |
| 2370 | |
Marc-André Lureau | 247724c | 2018-01-16 16:11:51 +0100 | [diff] [blame] | 2371 | if test "$have_asan" = "yes"; then |
Paolo Bonzini | db5adea | 2019-12-11 15:34:27 +0100 | [diff] [blame] | 2372 | QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS" |
| 2373 | QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS" |
Marc-André Lureau | d83414e | 2018-01-16 16:11:52 +0100 | [diff] [blame] | 2374 | if test "$have_asan_iface_h" = "no" ; then |
| 2375 | echo "ASAN build enabled, but ASAN header missing." \ |
| 2376 | "Without code annotation, the report may be inferior." |
| 2377 | elif test "$have_asan_iface_fiber" = "no" ; then |
| 2378 | echo "ASAN build enabled, but ASAN header is too old." \ |
| 2379 | "Without code annotation, the report may be inferior." |
| 2380 | fi |
Marc-André Lureau | 247724c | 2018-01-16 16:11:51 +0100 | [diff] [blame] | 2381 | fi |
Lingfeng Yang | 0aebab0 | 2020-06-12 20:02:23 +0100 | [diff] [blame] | 2382 | if test "$have_tsan" = "yes" ; then |
| 2383 | if test "$have_tsan_iface_fiber" = "yes" ; then |
| 2384 | QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS" |
| 2385 | QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS" |
| 2386 | else |
| 2387 | error_exit "Cannot enable TSAN due to missing fiber annotation interface." |
| 2388 | fi |
| 2389 | elif test "$tsan" = "yes" ; then |
| 2390 | error_exit "Cannot enable TSAN due to missing sanitize thread interface." |
| 2391 | fi |
Marc-André Lureau | 247724c | 2018-01-16 16:11:51 +0100 | [diff] [blame] | 2392 | if test "$have_ubsan" = "yes"; then |
Paolo Bonzini | db5adea | 2019-12-11 15:34:27 +0100 | [diff] [blame] | 2393 | QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS" |
| 2394 | QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS" |
Marc-André Lureau | 247724c | 2018-01-16 16:11:51 +0100 | [diff] [blame] | 2395 | fi |
| 2396 | |
Peter Lieven | 6542aa9 | 2014-02-03 10:26:13 +0100 | [diff] [blame] | 2397 | ########################################## |
Tomáš Golembiovský | 3efac6e | 2018-10-23 13:23:10 +0200 | [diff] [blame] | 2398 | |
Lingfeng Yang | 0aebab0 | 2020-06-12 20:02:23 +0100 | [diff] [blame] | 2399 | # Exclude --warn-common with TSan to suppress warnings from the TSan libraries. |
| 2400 | if test "$solaris" = "no" && test "$tsan" = "no"; then |
Juan Quintela | e86ecd4 | 2009-08-03 14:45:59 +0200 | [diff] [blame] | 2401 | if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then |
Paolo Bonzini | db5adea | 2019-12-11 15:34:27 +0100 | [diff] [blame] | 2402 | QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS" |
Juan Quintela | e86ecd4 | 2009-08-03 14:45:59 +0200 | [diff] [blame] | 2403 | fi |
| 2404 | fi |
| 2405 | |
Blue Swirl | 952afb7 | 2010-09-19 08:36:34 +0000 | [diff] [blame] | 2406 | # Use ASLR, no-SEH and DEP if available |
| 2407 | if test "$mingw32" = "yes" ; then |
Mark Cave-Ayland | cb8baa7 | 2020-10-05 14:34:34 +0100 | [diff] [blame] | 2408 | flags="--no-seh --nxcompat" |
| 2409 | |
| 2410 | # Disable ASLR for debug builds to allow debugging with gdb |
| 2411 | if test "$debug" = "no" ; then |
| 2412 | flags="--dynamicbase $flags" |
| 2413 | fi |
| 2414 | |
| 2415 | for flag in $flags; do |
Christian Borntraeger | e9a3591 | 2017-08-23 12:16:23 +0200 | [diff] [blame] | 2416 | if ld_has $flag ; then |
Paolo Bonzini | db5adea | 2019-12-11 15:34:27 +0100 | [diff] [blame] | 2417 | QEMU_LDFLAGS="-Wl,$flag $QEMU_LDFLAGS" |
Blue Swirl | 952afb7 | 2010-09-19 08:36:34 +0000 | [diff] [blame] | 2418 | fi |
| 2419 | done |
| 2420 | fi |
| 2421 | |
Paolo Bonzini | b846ab7 | 2021-01-21 11:49:04 +0100 | [diff] [blame] | 2422 | # Guest agent Windows MSI package |
Michael Roth | 9d6bc27 | 2015-08-26 10:49:13 -0500 | [diff] [blame] | 2423 | |
Paolo Bonzini | b846ab7 | 2021-01-21 11:49:04 +0100 | [diff] [blame] | 2424 | if test "$QEMU_GA_MANUFACTURER" = ""; then |
| 2425 | QEMU_GA_MANUFACTURER=QEMU |
| 2426 | fi |
| 2427 | if test "$QEMU_GA_DISTRO" = ""; then |
| 2428 | QEMU_GA_DISTRO=Linux |
| 2429 | fi |
| 2430 | if test "$QEMU_GA_VERSION" = ""; then |
| 2431 | QEMU_GA_VERSION=$(cat $source_path/VERSION) |
Michael Roth | 9d6bc27 | 2015-08-26 10:49:13 -0500 | [diff] [blame] | 2432 | fi |
| 2433 | |
Paolo Bonzini | 6e44420 | 2022-04-20 17:33:36 +0200 | [diff] [blame] | 2434 | QEMU_GA_MSI_MINGW_BIN_PATH="$($pkg_config --variable=prefix glib-2.0)/bin" |
Michael Roth | 9d6bc27 | 2015-08-26 10:49:13 -0500 | [diff] [blame] | 2435 | |
Paolo Bonzini | ca35f78 | 2010-05-26 16:08:29 +0200 | [diff] [blame] | 2436 | # Mac OS X ships with a broken assembler |
| 2437 | roms= |
Eric Blake | e633a5c | 2019-02-04 20:39:37 -0600 | [diff] [blame] | 2438 | if { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \ |
Paolo Bonzini | ba7c60c | 2021-11-08 14:47:54 +0100 | [diff] [blame] | 2439 | test "$targetos" != "darwin" && test "$targetos" != "sunos" && \ |
| 2440 | test "$targetos" != "haiku" && test "$softmmu" = yes ; then |
Peter Maydell | e57218b | 2016-08-08 17:11:28 +0100 | [diff] [blame] | 2441 | # Different host OS linkers have different ideas about the name of the ELF |
Brad Smith | c65d5e4 | 2017-11-07 18:46:11 -0500 | [diff] [blame] | 2442 | # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd |
| 2443 | # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe. |
| 2444 | for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do |
Peter Maydell | e57218b | 2016-08-08 17:11:28 +0100 | [diff] [blame] | 2445 | if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then |
| 2446 | ld_i386_emulation="$emu" |
| 2447 | roms="optionrom" |
| 2448 | break |
| 2449 | fi |
| 2450 | done |
Paolo Bonzini | ca35f78 | 2010-05-26 16:08:29 +0200 | [diff] [blame] | 2451 | fi |
Paolo Bonzini | ca35f78 | 2010-05-26 16:08:29 +0200 | [diff] [blame] | 2452 | |
Thomas Huth | 2e33c3f | 2019-01-14 13:52:26 +0100 | [diff] [blame] | 2453 | # Only build s390-ccw bios if we're on s390x and the compiler has -march=z900 |
Thomas Huth | a5b2afd | 2021-05-02 13:22:21 +0200 | [diff] [blame] | 2454 | # or -march=z10 (which is the lowest architecture level that Clang supports) |
Christian Borntraeger | 9933c30 | 2013-04-23 01:23:03 +0000 | [diff] [blame] | 2455 | if test "$cpu" = "s390x" ; then |
Thomas Huth | 2e33c3f | 2019-01-14 13:52:26 +0100 | [diff] [blame] | 2456 | write_c_skeleton |
Thomas Huth | a5b2afd | 2021-05-02 13:22:21 +0200 | [diff] [blame] | 2457 | compile_prog "-march=z900" "" |
| 2458 | has_z900=$? |
Thomas Huth | 3af448b | 2021-05-25 16:20:32 +0200 | [diff] [blame] | 2459 | if [ $has_z900 = 0 ] || compile_object "-march=z10 -msoft-float -Werror"; then |
Thomas Huth | a5b2afd | 2021-05-02 13:22:21 +0200 | [diff] [blame] | 2460 | if [ $has_z900 != 0 ]; then |
| 2461 | echo "WARNING: Your compiler does not support the z900!" |
| 2462 | echo " The s390-ccw bios will only work with guest CPUs >= z10." |
| 2463 | fi |
Thomas Huth | 2e33c3f | 2019-01-14 13:52:26 +0100 | [diff] [blame] | 2464 | roms="$roms s390-ccw" |
Philippe Mathieu-Daudé | 1ef6bfc | 2020-06-15 09:49:19 +0200 | [diff] [blame] | 2465 | # SLOF is required for building the s390-ccw firmware on s390x, |
| 2466 | # since it is using the libnet code from SLOF for network booting. |
Paolo Bonzini | 2d652f2 | 2021-05-12 09:21:56 +0200 | [diff] [blame] | 2467 | git_submodules="${git_submodules} roms/SLOF" |
Thomas Huth | 2e33c3f | 2019-01-14 13:52:26 +0100 | [diff] [blame] | 2468 | fi |
Christian Borntraeger | 9933c30 | 2013-04-23 01:23:03 +0000 | [diff] [blame] | 2469 | fi |
| 2470 | |
Bruno Dominguez | 11cde1c | 2017-06-06 14:07:47 +0100 | [diff] [blame] | 2471 | # Check that the C++ compiler exists and works with the C compiler. |
| 2472 | # All the QEMU_CXXFLAGS are based on QEMU_CFLAGS. Keep this at the end to don't miss any other that could be added. |
| 2473 | if has $cxx; then |
| 2474 | cat > $TMPC <<EOF |
| 2475 | int c_function(void); |
| 2476 | int main(void) { return c_function(); } |
| 2477 | EOF |
| 2478 | |
| 2479 | compile_object |
| 2480 | |
| 2481 | cat > $TMPCXX <<EOF |
| 2482 | extern "C" { |
| 2483 | int c_function(void); |
| 2484 | } |
| 2485 | int c_function(void) { return 42; } |
| 2486 | EOF |
| 2487 | |
| 2488 | update_cxxflags |
| 2489 | |
Paolo Bonzini | a286666 | 2021-11-05 10:09:26 +0100 | [diff] [blame] | 2490 | if do_cxx $CXXFLAGS $EXTRA_CXXFLAGS $CONFIGURE_CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then |
Bruno Dominguez | 11cde1c | 2017-06-06 14:07:47 +0100 | [diff] [blame] | 2491 | # C++ compiler $cxx works ok with C compiler $cc |
| 2492 | : |
| 2493 | else |
| 2494 | echo "C++ compiler $cxx does not work with C compiler $cc" |
| 2495 | echo "Disabling C++ specific optional code" |
| 2496 | cxx= |
| 2497 | fi |
| 2498 | else |
| 2499 | echo "No C++ compiler available; disabling C++ specific optional code" |
| 2500 | cxx= |
| 2501 | fi |
| 2502 | |
Dan Streetman | 7d7dbf9 | 2021-01-19 12:20:46 -0500 | [diff] [blame] | 2503 | if !(GIT="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then |
| 2504 | exit 1 |
Yonggang Luo | 5d91a2e | 2020-09-03 01:00:49 +0800 | [diff] [blame] | 2505 | fi |
Yonggang Luo | 5d91a2e | 2020-09-03 01:00:49 +0800 | [diff] [blame] | 2506 | |
Juan Quintela | 98ec69a | 2009-07-16 18:34:18 +0200 | [diff] [blame] | 2507 | config_host_mak="config-host.mak" |
bellard | 97a847b | 2003-08-10 21:36:04 +0000 | [diff] [blame] | 2508 | |
Juan Quintela | 98ec69a | 2009-07-16 18:34:18 +0200 | [diff] [blame] | 2509 | echo "# Automatically generated by configure - do not modify" > $config_host_mak |
Juan Quintela | 98ec69a | 2009-07-16 18:34:18 +0200 | [diff] [blame] | 2510 | echo >> $config_host_mak |
Juan Quintela | 98ec69a | 2009-07-16 18:34:18 +0200 | [diff] [blame] | 2511 | |
Paolo Bonzini | e6c3b0f | 2010-10-21 10:18:35 +0200 | [diff] [blame] | 2512 | echo all: >> $config_host_mak |
Daniel P. Berrange | cc84d63 | 2017-10-20 15:02:43 +0100 | [diff] [blame] | 2513 | echo "GIT=$git" >> $config_host_mak |
Daniel P. Berrange | aef45d5 | 2017-09-29 11:11:56 +0100 | [diff] [blame] | 2514 | echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak |
Dan Streetman | 7d7dbf9 | 2021-01-19 12:20:46 -0500 | [diff] [blame] | 2515 | echo "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak |
Juan Quintela | 804edf2 | 2009-07-27 16:12:49 +0200 | [diff] [blame] | 2516 | |
aurel32 | f839394 | 2009-04-13 18:45:38 +0000 | [diff] [blame] | 2517 | if test "$debug_tcg" = "yes" ; then |
Juan Quintela | 2358a49 | 2009-07-27 16:13:25 +0200 | [diff] [blame] | 2518 | echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak |
aurel32 | f839394 | 2009-04-13 18:45:38 +0000 | [diff] [blame] | 2519 | fi |
bellard | 67b915a | 2004-03-31 23:37:16 +0000 | [diff] [blame] | 2520 | if test "$mingw32" = "yes" ; then |
Juan Quintela | 98ec69a | 2009-07-16 18:34:18 +0200 | [diff] [blame] | 2521 | echo "CONFIG_WIN32=y" >> $config_host_mak |
Paolo Bonzini | 6e44420 | 2022-04-20 17:33:36 +0200 | [diff] [blame] | 2522 | echo "QEMU_GA_MSI_MINGW_BIN_PATH=${QEMU_GA_MSI_MINGW_BIN_PATH}" >> $config_host_mak |
Paolo Bonzini | b846ab7 | 2021-01-21 11:49:04 +0100 | [diff] [blame] | 2523 | echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak |
| 2524 | echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak |
| 2525 | echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak |
pbrook | 210fa55 | 2007-02-27 21:04:49 +0000 | [diff] [blame] | 2526 | else |
Juan Quintela | 35f4df2 | 2009-07-27 16:13:07 +0200 | [diff] [blame] | 2527 | echo "CONFIG_POSIX=y" >> $config_host_mak |
bellard | 67b915a | 2004-03-31 23:37:16 +0000 | [diff] [blame] | 2528 | fi |
blueswir1 | 128ab2f | 2008-08-15 18:33:42 +0000 | [diff] [blame] | 2529 | |
Mark McLoughlin | dffcb71 | 2009-10-22 17:49:11 +0100 | [diff] [blame] | 2530 | if test "$linux" = "yes" ; then |
| 2531 | echo "CONFIG_LINUX=y" >> $config_host_mak |
| 2532 | fi |
| 2533 | |
bellard | 83fb7ad | 2004-07-05 21:25:26 +0000 | [diff] [blame] | 2534 | if test "$darwin" = "yes" ; then |
Juan Quintela | 98ec69a | 2009-07-16 18:34:18 +0200 | [diff] [blame] | 2535 | echo "CONFIG_DARWIN=y" >> $config_host_mak |
bellard | 83fb7ad | 2004-07-05 21:25:26 +0000 | [diff] [blame] | 2536 | fi |
malc | b29fe3e | 2008-11-18 01:42:22 +0000 | [diff] [blame] | 2537 | |
bellard | ec530c8 | 2006-04-25 22:36:06 +0000 | [diff] [blame] | 2538 | if test "$solaris" = "yes" ; then |
Juan Quintela | 98ec69a | 2009-07-16 18:34:18 +0200 | [diff] [blame] | 2539 | echo "CONFIG_SOLARIS=y" >> $config_host_mak |
bellard | ec530c8 | 2006-04-25 22:36:06 +0000 | [diff] [blame] | 2540 | fi |
bellard | 97a847b | 2003-08-10 21:36:04 +0000 | [diff] [blame] | 2541 | if test "$static" = "yes" ; then |
Juan Quintela | 98ec69a | 2009-07-16 18:34:18 +0200 | [diff] [blame] | 2542 | echo "CONFIG_STATIC=y" >> $config_host_mak |
bellard | 97a847b | 2003-08-10 21:36:04 +0000 | [diff] [blame] | 2543 | fi |
Fam Zheng | b64ec4e | 2013-05-29 19:35:40 +0800 | [diff] [blame] | 2544 | echo "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak |
| 2545 | echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak |
Stefan Weil | 8913885 | 2016-05-16 15:10:20 +0200 | [diff] [blame] | 2546 | qemu_version=$(head $source_path/VERSION) |
Juan Quintela | 2358a49 | 2009-07-27 16:13:25 +0200 | [diff] [blame] | 2547 | echo "PKGVERSION=$pkgversion" >>$config_host_mak |
Juan Quintela | 98ec69a | 2009-07-16 18:34:18 +0200 | [diff] [blame] | 2548 | echo "SRC_PATH=$source_path" >> $config_host_mak |
Alex Bennée | 2b1f35b | 2018-07-04 07:30:11 +0100 | [diff] [blame] | 2549 | echo "TARGET_DIRS=$target_list" >> $config_host_mak |
Fam Zheng | 1796926 | 2014-02-10 14:48:56 +0800 | [diff] [blame] | 2550 | if test "$modules" = "yes"; then |
Fam Zheng | e26110c | 2014-02-10 14:48:57 +0800 | [diff] [blame] | 2551 | # $shacmd can generate a hash started with digit, which the compiler doesn't |
| 2552 | # like as an symbol. So prefix it with an underscore |
Stefan Weil | 8913885 | 2016-05-16 15:10:20 +0200 | [diff] [blame] | 2553 | echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak |
Fam Zheng | 1796926 | 2014-02-10 14:48:56 +0800 | [diff] [blame] | 2554 | echo "CONFIG_MODULES=y" >> $config_host_mak |
| 2555 | fi |
Daniel P. Berrange | a1c5e94 | 2016-06-06 10:05:06 +0100 | [diff] [blame] | 2556 | echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak |
Jan Vesely | 277abf1 | 2016-04-29 13:15:23 -0400 | [diff] [blame] | 2557 | |
Paolo Bonzini | 1badb70 | 2020-09-18 04:57:25 -0400 | [diff] [blame] | 2558 | if test "$xen" = "enabled" ; then |
Jan Kiszka | 6dbd588 | 2011-06-21 22:59:07 +0200 | [diff] [blame] | 2559 | echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak |
Anthony PERARD | d5b93dd | 2011-02-25 16:20:34 +0000 | [diff] [blame] | 2560 | echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak |
Marc-André Lureau | 582ea95 | 2019-08-15 15:15:32 +0400 | [diff] [blame] | 2561 | echo "XEN_CFLAGS=$xen_cflags" >> $config_host_mak |
| 2562 | echo "XEN_LIBS=$xen_libs" >> $config_host_mak |
aliguori | e37630c | 2009-04-22 15:19:10 +0000 | [diff] [blame] | 2563 | fi |
Nicholas Bellinger | 5e9be92 | 2013-03-29 01:08:16 +0000 | [diff] [blame] | 2564 | if test "$vhost_scsi" = "yes" ; then |
| 2565 | echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak |
| 2566 | fi |
Paolo Bonzini | af3bba7 | 2019-02-14 18:35:52 +0100 | [diff] [blame] | 2567 | if test "$vhost_net" = "yes" ; then |
| 2568 | echo "CONFIG_VHOST_NET=y" >> $config_host_mak |
| 2569 | fi |
| 2570 | if test "$vhost_net_user" = "yes" ; then |
Paolo Bonzini | 56f41de | 2019-02-14 18:35:49 +0100 | [diff] [blame] | 2571 | echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak |
Nikolay Nikolaev | 03ce574 | 2014-06-10 13:02:16 +0300 | [diff] [blame] | 2572 | fi |
Cindy Lu | 108a648 | 2020-07-01 22:55:37 +0800 | [diff] [blame] | 2573 | if test "$vhost_net_vdpa" = "yes" ; then |
| 2574 | echo "CONFIG_VHOST_NET_VDPA=y" >> $config_host_mak |
| 2575 | fi |
Gonglei | 042cea2 | 2018-03-01 21:46:28 +0800 | [diff] [blame] | 2576 | if test "$vhost_crypto" = "yes" ; then |
| 2577 | echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak |
| 2578 | fi |
Stefan Hajnoczi | fc0b9b0 | 2016-08-16 13:27:22 +0100 | [diff] [blame] | 2579 | if test "$vhost_vsock" = "yes" ; then |
| 2580 | echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak |
Stefano Garzarella | 5fe97d8 | 2020-05-22 14:25:11 +0200 | [diff] [blame] | 2581 | if test "$vhost_user" = "yes" ; then |
| 2582 | echo "CONFIG_VHOST_USER_VSOCK=y" >> $config_host_mak |
| 2583 | fi |
Stefan Hajnoczi | fc0b9b0 | 2016-08-16 13:27:22 +0100 | [diff] [blame] | 2584 | fi |
Paolo Bonzini | 299e6f1 | 2019-02-14 18:35:53 +0100 | [diff] [blame] | 2585 | if test "$vhost_kernel" = "yes" ; then |
| 2586 | echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak |
| 2587 | fi |
Marc-André Lureau | e6a7486 | 2017-08-03 11:07:46 +0200 | [diff] [blame] | 2588 | if test "$vhost_user" = "yes" ; then |
| 2589 | echo "CONFIG_VHOST_USER=y" >> $config_host_mak |
| 2590 | fi |
Cindy Lu | 108a648 | 2020-07-01 22:55:37 +0800 | [diff] [blame] | 2591 | if test "$vhost_vdpa" = "yes" ; then |
| 2592 | echo "CONFIG_VHOST_VDPA=y" >> $config_host_mak |
| 2593 | fi |
Dr. David Alan Gilbert | 98fc1ad | 2019-09-30 11:51:34 +0100 | [diff] [blame] | 2594 | if test "$vhost_user_fs" = "yes" ; then |
| 2595 | echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak |
| 2596 | fi |
Gerd Hoffmann | 58d3f3f | 2021-05-19 07:39:32 +0200 | [diff] [blame] | 2597 | |
bellard | 83fb7ad | 2004-07-05 21:25:26 +0000 | [diff] [blame] | 2598 | # XXX: suppress that |
bellard | 7d3505c | 2004-05-12 19:32:15 +0000 | [diff] [blame] | 2599 | if [ "$bsd" = "yes" ] ; then |
Juan Quintela | 2358a49 | 2009-07-27 16:13:25 +0200 | [diff] [blame] | 2600 | echo "CONFIG_BSD=y" >> $config_host_mak |
bellard | 7d3505c | 2004-05-12 19:32:15 +0000 | [diff] [blame] | 2601 | fi |
| 2602 | |
Peter Maydell | 7c2acc7 | 2013-04-08 12:11:27 +0100 | [diff] [blame] | 2603 | echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak |
Peter Lieven | 7d992e4 | 2016-09-27 11:58:45 +0200 | [diff] [blame] | 2604 | |
Marc-André Lureau | d83414e | 2018-01-16 16:11:52 +0100 | [diff] [blame] | 2605 | if test "$have_asan_iface_fiber" = "yes" ; then |
| 2606 | echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak |
| 2607 | fi |
| 2608 | |
Lingfeng Yang | 0aebab0 | 2020-06-12 20:02:23 +0100 | [diff] [blame] | 2609 | if test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then |
| 2610 | echo "CONFIG_TSAN=y" >> $config_host_mak |
| 2611 | fi |
| 2612 | |
Alex Bennée | 40e8c6f | 2019-06-13 14:52:25 +0100 | [diff] [blame] | 2613 | if test "$plugins" = "yes" ; then |
| 2614 | echo "CONFIG_PLUGIN=y" >> $config_host_mak |
Alex Bennée | 40e8c6f | 2019-06-13 14:52:25 +0100 | [diff] [blame] | 2615 | fi |
| 2616 | |
Alex Bennée | b1863cc | 2021-01-08 22:42:39 +0000 | [diff] [blame] | 2617 | if test -n "$gdb_bin"; then |
| 2618 | gdb_version=$($gdb_bin --version | head -n 1) |
Alex Bennée | d6a66c8 | 2021-02-02 13:39:53 +0000 | [diff] [blame] | 2619 | if version_ge ${gdb_version##* } 9.1; then |
Alex Bennée | b1863cc | 2021-01-08 22:42:39 +0000 | [diff] [blame] | 2620 | echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak |
| 2621 | fi |
Alex Bennée | f48e590 | 2020-03-16 17:21:48 +0000 | [diff] [blame] | 2622 | fi |
| 2623 | |
Juan Quintela | 98ec69a | 2009-07-16 18:34:18 +0200 | [diff] [blame] | 2624 | echo "ROMS=$roms" >> $config_host_mak |
Juan Quintela | 804edf2 | 2009-07-27 16:12:49 +0200 | [diff] [blame] | 2625 | echo "MAKE=$make" >> $config_host_mak |
Blue Swirl | c886edf | 2011-07-22 21:08:09 +0000 | [diff] [blame] | 2626 | echo "PYTHON=$python" >> $config_host_mak |
Alex Bennée | 39d87c8 | 2020-03-03 15:06:20 +0000 | [diff] [blame] | 2627 | echo "GENISOIMAGE=$genisoimage" >> $config_host_mak |
Paolo Bonzini | a566505 | 2019-06-10 12:05:14 +0200 | [diff] [blame] | 2628 | echo "MESON=$meson" >> $config_host_mak |
Paolo Bonzini | 09e9332 | 2020-08-13 09:28:11 -0400 | [diff] [blame] | 2629 | echo "NINJA=$ninja" >> $config_host_mak |
Juan Quintela | 804edf2 | 2009-07-27 16:12:49 +0200 | [diff] [blame] | 2630 | echo "CC=$cc" >> $config_host_mak |
Juan Quintela | 804edf2 | 2009-07-27 16:12:49 +0200 | [diff] [blame] | 2631 | echo "AR=$ar" >> $config_host_mak |
Richard Henderson | cdbd727 | 2016-07-07 21:49:36 -0700 | [diff] [blame] | 2632 | echo "AS=$as" >> $config_host_mak |
Richard Henderson | 5f6f0e2 | 2016-06-23 10:39:18 -0700 | [diff] [blame] | 2633 | echo "CCAS=$ccas" >> $config_host_mak |
Blue Swirl | 3dd46c7 | 2013-01-05 10:10:27 +0000 | [diff] [blame] | 2634 | echo "CPP=$cpp" >> $config_host_mak |
Juan Quintela | 804edf2 | 2009-07-27 16:12:49 +0200 | [diff] [blame] | 2635 | echo "OBJCOPY=$objcopy" >> $config_host_mak |
| 2636 | echo "LD=$ld" >> $config_host_mak |
Brad | 46eef33 | 2013-12-10 19:49:08 -0500 | [diff] [blame] | 2637 | echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak |
Juan Quintela | a558ee1 | 2009-08-03 14:46:21 +0200 | [diff] [blame] | 2638 | echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak |
Bruno Dominguez | 11cde1c | 2017-06-06 14:07:47 +0100 | [diff] [blame] | 2639 | echo "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak |
Philippe Mathieu-Daudé | 4cb37d1 | 2022-02-15 16:15:13 +0100 | [diff] [blame] | 2640 | echo "QEMU_OBJCFLAGS=$QEMU_OBJCFLAGS" >> $config_host_mak |
Paolo Bonzini | a81df1b | 2020-08-19 08:44:56 -0400 | [diff] [blame] | 2641 | echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak |
| 2642 | echo "GLIB_LIBS=$glib_libs" >> $config_host_mak |
Marc-André Lureau | d83acfd | 2021-10-09 17:37:40 +0400 | [diff] [blame] | 2643 | echo "GLIB_VERSION=$(pkg-config --modversion glib-2.0)" >> $config_host_mak |
Philippe Mathieu-Daudé | 8a99e9a | 2018-04-15 20:05:19 -0300 | [diff] [blame] | 2644 | echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak |
Peter Maydell | e57218b | 2016-08-08 17:11:28 +0100 | [diff] [blame] | 2645 | echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak |
Paolo Bonzini | a70248d | 2021-11-09 10:36:39 +0100 | [diff] [blame] | 2646 | echo "STRIP=$strip" >> $config_host_mak |
Juan Quintela | 804edf2 | 2009-07-27 16:12:49 +0200 | [diff] [blame] | 2647 | echo "EXESUF=$EXESUF" >> $config_host_mak |
Juan Quintela | 804edf2 | 2009-07-27 16:12:49 +0200 | [diff] [blame] | 2648 | |
Peter Maydell | 6efd751 | 2011-11-30 11:59:04 +0000 | [diff] [blame] | 2649 | # use included Linux headers |
| 2650 | if test "$linux" = "yes" ; then |
Andreas Färber | a307beb | 2012-06-14 15:14:33 +0000 | [diff] [blame] | 2651 | mkdir -p linux-headers |
Peter Maydell | 6efd751 | 2011-11-30 11:59:04 +0000 | [diff] [blame] | 2652 | case "$cpu" in |
Paolo Bonzini | 4da270b | 2021-11-09 09:36:10 +0100 | [diff] [blame] | 2653 | i386|x86_64) |
Peter Maydell | 08312a6 | 2012-08-03 13:51:25 +0100 | [diff] [blame] | 2654 | linux_arch=x86 |
Peter Maydell | 6efd751 | 2011-11-30 11:59:04 +0000 | [diff] [blame] | 2655 | ;; |
Paolo Bonzini | d8ff892 | 2021-11-09 09:18:20 +0100 | [diff] [blame] | 2656 | ppc|ppc64) |
Peter Maydell | 08312a6 | 2012-08-03 13:51:25 +0100 | [diff] [blame] | 2657 | linux_arch=powerpc |
Peter Maydell | 6efd751 | 2011-11-30 11:59:04 +0000 | [diff] [blame] | 2658 | ;; |
| 2659 | s390x) |
Peter Maydell | 08312a6 | 2012-08-03 13:51:25 +0100 | [diff] [blame] | 2660 | linux_arch=s390 |
| 2661 | ;; |
Claudio Fontana | 1f08031 | 2013-06-12 16:20:23 +0100 | [diff] [blame] | 2662 | aarch64) |
| 2663 | linux_arch=arm64 |
| 2664 | ;; |
WANG Xuerui | dfcf900 | 2021-12-21 13:41:04 +0800 | [diff] [blame] | 2665 | loongarch*) |
| 2666 | linux_arch=loongarch |
| 2667 | ;; |
Sanjay Lal | 222e7d1 | 2014-06-17 23:10:36 +0100 | [diff] [blame] | 2668 | mips64) |
| 2669 | linux_arch=mips |
| 2670 | ;; |
Peter Maydell | 08312a6 | 2012-08-03 13:51:25 +0100 | [diff] [blame] | 2671 | *) |
| 2672 | # For most CPUs the kernel architecture name and QEMU CPU name match. |
| 2673 | linux_arch="$cpu" |
Peter Maydell | 6efd751 | 2011-11-30 11:59:04 +0000 | [diff] [blame] | 2674 | ;; |
| 2675 | esac |
Peter Maydell | 08312a6 | 2012-08-03 13:51:25 +0100 | [diff] [blame] | 2676 | # For non-KVM architectures we will not have asm headers |
| 2677 | if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then |
| 2678 | symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm |
| 2679 | fi |
Peter Maydell | 6efd751 | 2011-11-30 11:59:04 +0000 | [diff] [blame] | 2680 | fi |
| 2681 | |
bellard | 1d14ffa | 2005-10-30 18:58:22 +0000 | [diff] [blame] | 2682 | for target in $target_list; do |
Paolo Bonzini | fdb75ae | 2020-09-21 04:37:49 -0400 | [diff] [blame] | 2683 | target_dir="$target" |
Philippe Mathieu-Daudé | 57a93f1 | 2021-11-09 15:45:04 +0100 | [diff] [blame] | 2684 | target_name=$(echo $target | cut -d '-' -f 1)$EXESUF |
Paolo Bonzini | fdb75ae | 2020-09-21 04:37:49 -0400 | [diff] [blame] | 2685 | mkdir -p $target_dir |
| 2686 | case $target in |
| 2687 | *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;; |
| 2688 | *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;; |
| 2689 | esac |
| 2690 | done |
bellard | 7d13299 | 2003-03-06 23:23:54 +0000 | [diff] [blame] | 2691 | |
Paolo Bonzini | 765686d | 2020-09-18 06:37:21 -0400 | [diff] [blame] | 2692 | echo "CONFIG_QEMU_INTERP_PREFIX=$interp_prefix" | sed 's/%M/@0@/' >> $config_host_mak |
Paolo Bonzini | fdb75ae | 2020-09-21 04:37:49 -0400 | [diff] [blame] | 2693 | if test "$default_targets" = "yes"; then |
| 2694 | echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak |
| 2695 | fi |
Peter Crosthwaite | a540f15 | 2013-04-18 14:47:31 +1000 | [diff] [blame] | 2696 | |
John Snow | fd0e605 | 2015-03-25 18:57:39 -0400 | [diff] [blame] | 2697 | if test "$ccache_cpp2" = "yes"; then |
| 2698 | echo "export CCACHE_CPP2=y" >> $config_host_mak |
| 2699 | fi |
| 2700 | |
Daniele Buono | 1e4f606 | 2020-05-29 16:51:21 -0400 | [diff] [blame] | 2701 | if test "$safe_stack" = "yes"; then |
| 2702 | echo "CONFIG_SAFESTACK=y" >> $config_host_mak |
| 2703 | fi |
| 2704 | |
Peter Maydell | e29e5c6 | 2018-11-02 11:52:38 +0000 | [diff] [blame] | 2705 | # If we're using a separate build tree, set it up now. |
Peter Maydell | e29e5c6 | 2018-11-02 11:52:38 +0000 | [diff] [blame] | 2706 | # LINKS are things to symlink back into the source tree |
| 2707 | # (these can be both files and directories). |
| 2708 | # Caution: do not add files or directories here using wildcards. This |
| 2709 | # will result in problems later if a new file matching the wildcard is |
| 2710 | # added to the source tree -- nothing will cause configure to be rerun |
| 2711 | # so the build tree will be missing the link back to the new file, and |
| 2712 | # tests might fail. Prefer to keep the relevant files in their own |
| 2713 | # directory and symlink the directory instead. |
Paolo Bonzini | 2038f8c | 2019-08-07 16:35:23 +0200 | [diff] [blame] | 2714 | LINKS="Makefile" |
Paolo Bonzini | 3941996 | 2020-08-06 14:08:31 +0200 | [diff] [blame] | 2715 | LINKS="$LINKS tests/tcg/Makefile.target" |
Gerd Hoffmann | ddcf607 | 2020-08-24 09:40:57 +0200 | [diff] [blame] | 2716 | LINKS="$LINKS pc-bios/optionrom/Makefile" |
Peter Maydell | e29e5c6 | 2018-11-02 11:52:38 +0000 | [diff] [blame] | 2717 | LINKS="$LINKS pc-bios/s390-ccw/Makefile" |
Peter Maydell | e29e5c6 | 2018-11-02 11:52:38 +0000 | [diff] [blame] | 2718 | LINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit |
Willian Rampazzo | bbbd9b6 | 2021-11-05 12:53:54 -0300 | [diff] [blame] | 2719 | LINKS="$LINKS tests/avocado tests/data" |
Peter Maydell | 3995035 | 2018-11-02 11:52:39 +0000 | [diff] [blame] | 2720 | LINKS="$LINKS tests/qemu-iotests/check" |
Cleber Rosa | 8f8fd9e | 2019-02-06 11:29:01 -0500 | [diff] [blame] | 2721 | LINKS="$LINKS python" |
Alex Bennée | c17a386 | 2020-09-09 12:27:41 +0100 | [diff] [blame] | 2722 | LINKS="$LINKS contrib/plugins/Makefile " |
Richard Henderson | 753d11f | 2011-06-24 11:58:37 -0700 | [diff] [blame] | 2723 | for bios_file in \ |
| 2724 | $source_path/pc-bios/*.bin \ |
Bin Meng | 3a631b8 | 2020-06-22 13:09:32 +0800 | [diff] [blame] | 2725 | $source_path/pc-bios/*.elf \ |
Alexey Kardashevskiy | 225a9ab | 2016-10-26 13:18:03 +1100 | [diff] [blame] | 2726 | $source_path/pc-bios/*.lid \ |
Richard Henderson | 753d11f | 2011-06-24 11:58:37 -0700 | [diff] [blame] | 2727 | $source_path/pc-bios/*.rom \ |
| 2728 | $source_path/pc-bios/*.dtb \ |
Dominik Dingel | e89e33e | 2013-04-29 04:52:06 +0000 | [diff] [blame] | 2729 | $source_path/pc-bios/*.img \ |
Richard Henderson | 753d11f | 2011-06-24 11:58:37 -0700 | [diff] [blame] | 2730 | $source_path/pc-bios/openbios-* \ |
Alexander Graf | 4e73c78 | 2014-01-20 00:25:40 +0100 | [diff] [blame] | 2731 | $source_path/pc-bios/u-boot.* \ |
John Arbuckle | cd946e5 | 2021-08-31 12:50:20 -0400 | [diff] [blame] | 2732 | $source_path/pc-bios/palcode-* \ |
| 2733 | $source_path/pc-bios/qemu_vga.ndrv |
| 2734 | |
Richard Henderson | 753d11f | 2011-06-24 11:58:37 -0700 | [diff] [blame] | 2735 | do |
Peter Maydell | e29e5c6 | 2018-11-02 11:52:38 +0000 | [diff] [blame] | 2736 | LINKS="$LINKS pc-bios/$(basename $bios_file)" |
Paolo Bonzini | d1807a4 | 2010-12-23 11:43:59 +0100 | [diff] [blame] | 2737 | done |
Peter Maydell | e29e5c6 | 2018-11-02 11:52:38 +0000 | [diff] [blame] | 2738 | for f in $LINKS ; do |
Paolo Bonzini | 0f4d889 | 2020-09-01 03:23:47 -0400 | [diff] [blame] | 2739 | if [ -e "$source_path/$f" ]; then |
Paolo Bonzini | 5dce7b8 | 2021-10-13 13:56:24 +0200 | [diff] [blame] | 2740 | mkdir -p `dirname ./$f` |
Peter Maydell | f9245e1 | 2011-06-03 17:10:40 +0100 | [diff] [blame] | 2741 | symlink "$source_path/$f" "$f" |
| 2742 | fi |
Paolo Bonzini | d1807a4 | 2010-12-23 11:43:59 +0100 | [diff] [blame] | 2743 | done |
Paul Brook | 1ad2134 | 2009-05-19 16:17:58 +0100 | [diff] [blame] | 2744 | |
Paolo Bonzini | 2038f8c | 2019-08-07 16:35:23 +0200 | [diff] [blame] | 2745 | (for i in $cross_cc_vars; do |
| 2746 | export $i |
| 2747 | done |
Paolo Bonzini | 544f4a2 | 2022-04-19 10:10:13 +0100 | [diff] [blame] | 2748 | export target_list source_path use_containers cpu host_cc |
Paolo Bonzini | 2038f8c | 2019-08-07 16:35:23 +0200 | [diff] [blame] | 2749 | $source_path/tests/tcg/configure.sh) |
| 2750 | |
Helge Konetzka | 9840999 | 2021-09-15 12:56:34 +0200 | [diff] [blame] | 2751 | config_mak=pc-bios/optionrom/config.mak |
| 2752 | echo "# Automatically generated by configure - do not modify" > $config_mak |
| 2753 | echo "TOPSRC_DIR=$source_path" >> $config_mak |
| 2754 | |
Paolo Bonzini | a566505 | 2019-06-10 12:05:14 +0200 | [diff] [blame] | 2755 | if test "$skip_meson" = no; then |
Paolo Bonzini | d77e90f | 2021-03-16 08:19:34 +0100 | [diff] [blame] | 2756 | cross="config-meson.cross.new" |
| 2757 | meson_quote() { |
Paolo Bonzini | ac7ebcc | 2021-11-05 10:07:37 +0100 | [diff] [blame] | 2758 | test $# = 0 && return |
Paolo Bonzini | 47b3083 | 2020-09-23 05:26:17 -0400 | [diff] [blame] | 2759 | echo "'$(echo $* | sed "s/ /','/g")'" |
Paolo Bonzini | d77e90f | 2021-03-16 08:19:34 +0100 | [diff] [blame] | 2760 | } |
Marc-André Lureau | fc92989 | 2019-07-13 01:47:54 +0400 | [diff] [blame] | 2761 | |
Paolo Bonzini | d77e90f | 2021-03-16 08:19:34 +0100 | [diff] [blame] | 2762 | echo "# Automatically generated by configure - do not modify" > $cross |
| 2763 | echo "[properties]" >> $cross |
Alex Bennée | d1d5e9e | 2021-07-07 14:17:44 +0100 | [diff] [blame] | 2764 | |
| 2765 | # unroll any custom device configs |
Alex Bennée | 11bdcfc | 2021-07-21 00:26:38 +0100 | [diff] [blame] | 2766 | for a in $device_archs; do |
| 2767 | eval "c=\$devices_${a}" |
| 2768 | echo "${a}-softmmu = '$c'" >> $cross |
| 2769 | done |
Alex Bennée | d1d5e9e | 2021-07-07 14:17:44 +0100 | [diff] [blame] | 2770 | |
Paolo Bonzini | d77e90f | 2021-03-16 08:19:34 +0100 | [diff] [blame] | 2771 | test -z "$cxx" && echo "link_language = 'c'" >> $cross |
| 2772 | echo "[built-in options]" >> $cross |
Paolo Bonzini | a286666 | 2021-11-05 10:09:26 +0100 | [diff] [blame] | 2773 | echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross |
| 2774 | echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross |
Philippe Mathieu-Daudé | e910c7d | 2022-01-08 22:38:55 +0100 | [diff] [blame] | 2775 | test -n "$objcc" && echo "objc_args = [$(meson_quote $OBJCFLAGS $EXTRA_OBJCFLAGS)]" >> $cross |
Paolo Bonzini | a286666 | 2021-11-05 10:09:26 +0100 | [diff] [blame] | 2776 | echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross |
| 2777 | echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross |
Paolo Bonzini | d77e90f | 2021-03-16 08:19:34 +0100 | [diff] [blame] | 2778 | echo "[binaries]" >> $cross |
Paolo Bonzini | 4dba278 | 2021-09-29 17:14:43 +0200 | [diff] [blame] | 2779 | echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross |
| 2780 | test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross |
| 2781 | test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross |
Paolo Bonzini | d77e90f | 2021-03-16 08:19:34 +0100 | [diff] [blame] | 2782 | echo "ar = [$(meson_quote $ar)]" >> $cross |
| 2783 | echo "nm = [$(meson_quote $nm)]" >> $cross |
| 2784 | echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross |
| 2785 | echo "ranlib = [$(meson_quote $ranlib)]" >> $cross |
| 2786 | if has $sdl2_config; then |
| 2787 | echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross |
| 2788 | fi |
| 2789 | echo "strip = [$(meson_quote $strip)]" >> $cross |
Konstantin Kostiuk | 158bb22 | 2022-04-28 21:15:25 +0300 | [diff] [blame^] | 2790 | echo "widl = [$(meson_quote $widl)]" >> $cross |
Paolo Bonzini | d77e90f | 2021-03-16 08:19:34 +0100 | [diff] [blame] | 2791 | echo "windres = [$(meson_quote $windres)]" >> $cross |
| 2792 | if test "$cross_compile" = "yes"; then |
Marc-André Lureau | fc92989 | 2019-07-13 01:47:54 +0400 | [diff] [blame] | 2793 | cross_arg="--cross-file config-meson.cross" |
Marc-André Lureau | fc92989 | 2019-07-13 01:47:54 +0400 | [diff] [blame] | 2794 | echo "[host_machine]" >> $cross |
Paolo Bonzini | ba7c60c | 2021-11-08 14:47:54 +0100 | [diff] [blame] | 2795 | echo "system = '$targetos'" >> $cross |
Paolo Bonzini | 823eb01 | 2021-11-08 14:18:17 +0100 | [diff] [blame] | 2796 | case "$cpu" in |
Joelle van Dyne | f6bca9d | 2021-01-25 17:24:54 -0800 | [diff] [blame] | 2797 | i386) |
Marc-André Lureau | fc92989 | 2019-07-13 01:47:54 +0400 | [diff] [blame] | 2798 | echo "cpu_family = 'x86'" >> $cross |
| 2799 | ;; |
Marc-André Lureau | fc92989 | 2019-07-13 01:47:54 +0400 | [diff] [blame] | 2800 | *) |
Paolo Bonzini | 823eb01 | 2021-11-08 14:18:17 +0100 | [diff] [blame] | 2801 | echo "cpu_family = '$cpu'" >> $cross |
Marc-André Lureau | fc92989 | 2019-07-13 01:47:54 +0400 | [diff] [blame] | 2802 | ;; |
| 2803 | esac |
| 2804 | echo "cpu = '$cpu'" >> $cross |
| 2805 | if test "$bigendian" = "yes" ; then |
| 2806 | echo "endian = 'big'" >> $cross |
| 2807 | else |
| 2808 | echo "endian = 'little'" >> $cross |
| 2809 | fi |
Paolo Bonzini | d77e90f | 2021-03-16 08:19:34 +0100 | [diff] [blame] | 2810 | else |
Marc-André Lureau | fc92989 | 2019-07-13 01:47:54 +0400 | [diff] [blame] | 2811 | cross_arg="--native-file config-meson.cross" |
Paolo Bonzini | d77e90f | 2021-03-16 08:19:34 +0100 | [diff] [blame] | 2812 | fi |
| 2813 | mv $cross config-meson.cross |
Marc-André Lureau | fc92989 | 2019-07-13 01:47:54 +0400 | [diff] [blame] | 2814 | |
Paolo Bonzini | d77e90f | 2021-03-16 08:19:34 +0100 | [diff] [blame] | 2815 | rm -rf meson-private meson-info meson-logs |
Paolo Bonzini | 61d6309 | 2021-10-07 15:08:28 +0200 | [diff] [blame] | 2816 | run_meson() { |
| 2817 | NINJA=$ninja $meson setup \ |
Paolo Bonzini | d17f305 | 2020-08-18 12:17:01 +0200 | [diff] [blame] | 2818 | --prefix "$prefix" \ |
| 2819 | --libdir "$libdir" \ |
| 2820 | --libexecdir "$libexecdir" \ |
| 2821 | --bindir "$bindir" \ |
| 2822 | --includedir "$includedir" \ |
| 2823 | --datadir "$datadir" \ |
| 2824 | --mandir "$mandir" \ |
| 2825 | --sysconfdir "$sysconfdir" \ |
Paolo Bonzini | 16bf7a3 | 2020-10-16 03:19:14 -0400 | [diff] [blame] | 2826 | --localedir "$localedir" \ |
Paolo Bonzini | d17f305 | 2020-08-18 12:17:01 +0200 | [diff] [blame] | 2827 | --localstatedir "$local_statedir" \ |
Paolo Bonzini | 3b4da13 | 2021-10-07 15:08:29 +0200 | [diff] [blame] | 2828 | -Daudio_drv_list=$audio_drv_list \ |
| 2829 | -Ddefault_devices=$default_devices \ |
Paolo Bonzini | d17f305 | 2020-08-18 12:17:01 +0200 | [diff] [blame] | 2830 | -Ddocdir="$docdir" \ |
Paolo Bonzini | 5dc4618 | 2021-10-13 13:19:00 +0200 | [diff] [blame] | 2831 | -Diasl="$($iasl -h >/dev/null 2>&1 && printf %s "$iasl")" \ |
Paolo Bonzini | 16bf7a3 | 2020-10-16 03:19:14 -0400 | [diff] [blame] | 2832 | -Dqemu_firmwarepath="$firmwarepath" \ |
Marc-André Lureau | 73f3aa3 | 2020-08-26 15:04:15 +0400 | [diff] [blame] | 2833 | -Dqemu_suffix="$qemu_suffix" \ |
Paolo Bonzini | 35acbb3 | 2021-10-13 13:43:36 +0200 | [diff] [blame] | 2834 | -Dsmbd="$smbd" \ |
Paolo Bonzini | 3b4da13 | 2021-10-07 15:08:29 +0200 | [diff] [blame] | 2835 | -Dsphinx_build="$sphinx_build" \ |
| 2836 | -Dtrace_file="$trace_file" \ |
Paolo Bonzini | a566505 | 2019-06-10 12:05:14 +0200 | [diff] [blame] | 2837 | -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) \ |
| 2838 | -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo false; fi) \ |
| 2839 | -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \ |
Marc-André Lureau | da6d48b | 2019-09-17 15:39:36 +0400 | [diff] [blame] | 2840 | -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \ |
Marc-André Lureau | bf0e56a | 2019-10-04 17:35:16 +0400 | [diff] [blame] | 2841 | -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \ |
Paolo Bonzini | 3b4da13 | 2021-10-07 15:08:29 +0200 | [diff] [blame] | 2842 | -Db_lto=$lto -Dcfi=$cfi -Dtcg=$tcg -Dxen=$xen \ |
| 2843 | -Dcapstone=$capstone -Dfdt=$fdt -Dslirp=$slirp \ |
Paolo Bonzini | 537b724 | 2021-10-07 15:08:12 +0200 | [diff] [blame] | 2844 | $(test -n "${LIB_FUZZING_ENGINE+xxx}" && echo "-Dfuzzing_engine=$LIB_FUZZING_ENGINE") \ |
Thomas Huth | 332008e | 2021-07-13 11:31:52 +0200 | [diff] [blame] | 2845 | $(if test "$default_feature" = no; then echo "-Dauto_features=disabled"; fi) \ |
Paolo Bonzini | 61d6309 | 2021-10-07 15:08:28 +0200 | [diff] [blame] | 2846 | "$@" $cross_arg "$PWD" "$source_path" |
| 2847 | } |
| 2848 | eval run_meson $meson_options |
Paolo Bonzini | d77e90f | 2021-03-16 08:19:34 +0100 | [diff] [blame] | 2849 | if test "$?" -ne 0 ; then |
| 2850 | error_exit "meson setup failed" |
| 2851 | fi |
Paolo Bonzini | 699d388 | 2021-03-16 08:27:40 +0100 | [diff] [blame] | 2852 | else |
| 2853 | if test -f meson-private/cmd_line.txt; then |
| 2854 | # Adjust old command line options whose type was changed |
| 2855 | # Avoids having to use "setup --wipe" when Meson is upgraded |
| 2856 | perl -i -ne ' |
| 2857 | s/^gettext = true$/gettext = auto/; |
| 2858 | s/^gettext = false$/gettext = disabled/; |
Paolo Bonzini | 654d6b0 | 2021-02-09 14:59:26 +0100 | [diff] [blame] | 2859 | /^b_staticpic/ && next; |
Paolo Bonzini | 699d388 | 2021-03-16 08:27:40 +0100 | [diff] [blame] | 2860 | print;' meson-private/cmd_line.txt |
| 2861 | fi |
Paolo Bonzini | a566505 | 2019-06-10 12:05:14 +0200 | [diff] [blame] | 2862 | fi |
| 2863 | |
Michael S. Tsirkin | dc65540 | 2014-03-09 17:37:49 +0200 | [diff] [blame] | 2864 | # Save the configure command line for later reuse. |
| 2865 | cat <<EOD >config.status |
| 2866 | #!/bin/sh |
| 2867 | # Generated by configure. |
| 2868 | # Run this file to recreate the current configuration. |
| 2869 | # Compiler output produced by configure, useful for debugging |
| 2870 | # configure, is in config.log if it exists. |
| 2871 | EOD |
Daniel P. Berrangé | e811da7 | 2018-09-04 13:36:03 +0100 | [diff] [blame] | 2872 | |
| 2873 | preserve_env() { |
| 2874 | envname=$1 |
| 2875 | |
| 2876 | eval envval=\$$envname |
| 2877 | |
| 2878 | if test -n "$envval" |
| 2879 | then |
| 2880 | echo "$envname='$envval'" >> config.status |
| 2881 | echo "export $envname" >> config.status |
| 2882 | else |
| 2883 | echo "unset $envname" >> config.status |
| 2884 | fi |
| 2885 | } |
| 2886 | |
| 2887 | # Preserve various env variables that influence what |
| 2888 | # features/build target configure will detect |
| 2889 | preserve_env AR |
| 2890 | preserve_env AS |
| 2891 | preserve_env CC |
| 2892 | preserve_env CPP |
Paolo Bonzini | 8009da0 | 2021-11-05 10:08:43 +0100 | [diff] [blame] | 2893 | preserve_env CFLAGS |
Daniel P. Berrangé | e811da7 | 2018-09-04 13:36:03 +0100 | [diff] [blame] | 2894 | preserve_env CXX |
Paolo Bonzini | 8009da0 | 2021-11-05 10:08:43 +0100 | [diff] [blame] | 2895 | preserve_env CXXFLAGS |
Daniel P. Berrangé | e811da7 | 2018-09-04 13:36:03 +0100 | [diff] [blame] | 2896 | preserve_env INSTALL |
| 2897 | preserve_env LD |
Paolo Bonzini | 8009da0 | 2021-11-05 10:08:43 +0100 | [diff] [blame] | 2898 | preserve_env LDFLAGS |
Daniel P. Berrangé | e811da7 | 2018-09-04 13:36:03 +0100 | [diff] [blame] | 2899 | preserve_env LD_LIBRARY_PATH |
| 2900 | preserve_env LIBTOOL |
| 2901 | preserve_env MAKE |
| 2902 | preserve_env NM |
| 2903 | preserve_env OBJCOPY |
| 2904 | preserve_env PATH |
| 2905 | preserve_env PKG_CONFIG |
| 2906 | preserve_env PKG_CONFIG_LIBDIR |
| 2907 | preserve_env PKG_CONFIG_PATH |
| 2908 | preserve_env PYTHON |
Daniel P. Berrangé | e811da7 | 2018-09-04 13:36:03 +0100 | [diff] [blame] | 2909 | preserve_env SDL2_CONFIG |
| 2910 | preserve_env SMBD |
| 2911 | preserve_env STRIP |
Konstantin Kostiuk | 158bb22 | 2022-04-28 21:15:25 +0300 | [diff] [blame^] | 2912 | preserve_env WIDL |
Daniel P. Berrangé | e811da7 | 2018-09-04 13:36:03 +0100 | [diff] [blame] | 2913 | preserve_env WINDRES |
| 2914 | |
Michael S. Tsirkin | dc65540 | 2014-03-09 17:37:49 +0200 | [diff] [blame] | 2915 | printf "exec" >>config.status |
Paolo Bonzini | a566505 | 2019-06-10 12:05:14 +0200 | [diff] [blame] | 2916 | for i in "$0" "$@"; do |
Paolo Bonzini | 835af89 | 2020-09-08 13:20:45 +0200 | [diff] [blame] | 2917 | test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status |
Paolo Bonzini | a566505 | 2019-06-10 12:05:14 +0200 | [diff] [blame] | 2918 | done |
Dr. David Alan Gilbert | cf7cc92 | 2016-01-12 11:58:48 +0000 | [diff] [blame] | 2919 | echo ' "$@"' >>config.status |
Michael S. Tsirkin | dc65540 | 2014-03-09 17:37:49 +0200 | [diff] [blame] | 2920 | chmod +x config.status |
| 2921 | |
Peter Maydell | 8cd05ab | 2014-05-23 17:07:24 +0100 | [diff] [blame] | 2922 | rm -r "$TMPDIR1" |