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