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