]>
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" |
4cb37d11 | 80 | TMPM="${TMPDIR1}/${TMPB}.m" |
8cd05ab6 | 81 | TMPE="${TMPDIR1}/${TMPB}.exe" |
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 | ||
4cb37d11 PMD |
152 | do_objc() { |
153 | do_compiler "$objcc" $CPU_CFLAGS "$@" | |
154 | } | |
155 | ||
00849b92 RH |
156 | # Append $2 to the variable named $1, with space separation |
157 | add_to() { | |
158 | eval $1=\${$1:+\"\$$1 \"}\$2 | |
159 | } | |
160 | ||
9c83ffd8 PM |
161 | update_cxxflags() { |
162 | # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those | |
163 | # options which some versions of GCC's C++ compiler complain about | |
164 | # because they only make sense for C programs. | |
de38c0cc | 165 | QEMU_CXXFLAGS="-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS" |
8a9d3d56 | 166 | CONFIGURE_CXXFLAGS=$(echo "$CONFIGURE_CFLAGS" | sed s/-std=gnu11/-std=gnu++11/) |
9c83ffd8 PM |
167 | for arg in $QEMU_CFLAGS; do |
168 | case $arg in | |
169 | -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\ | |
170 | -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls) | |
171 | ;; | |
172 | *) | |
173 | QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg | |
174 | ;; | |
175 | esac | |
176 | done | |
177 | } | |
178 | ||
52166aa0 | 179 | compile_object() { |
fd0e6053 | 180 | local_cflags="$1" |
a2866660 | 181 | do_cc $CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC |
52166aa0 JQ |
182 | } |
183 | ||
184 | compile_prog() { | |
185 | local_cflags="$1" | |
186 | local_ldflags="$2" | |
a2866660 PB |
187 | do_cc $CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC \ |
188 | $LDFLAGS $EXTRA_LDFLAGS $CONFIGURE_LDFLAGS $QEMU_LDFLAGS $local_ldflags | |
52166aa0 JQ |
189 | } |
190 | ||
11568d6d PB |
191 | # symbolically link $1 to $2. Portable version of "ln -sf". |
192 | symlink() { | |
72b8b5a1 | 193 | rm -rf "$2" |
ec5b06d7 | 194 | mkdir -p "$(dirname "$2")" |
72b8b5a1 | 195 | ln -s "$1" "$2" |
11568d6d PB |
196 | } |
197 | ||
0dba6195 LM |
198 | # check whether a command is available to this shell (may be either an |
199 | # executable or a builtin) | |
200 | has() { | |
201 | type "$1" >/dev/null 2>&1 | |
202 | } | |
203 | ||
0a01d76f | 204 | version_ge () { |
2df52b9b AB |
205 | local_ver1=$(expr "$1" : '\([0-9.]*\)' | tr . ' ') |
206 | local_ver2=$(echo "$2" | tr . ' ') | |
0a01d76f MAL |
207 | while true; do |
208 | set x $local_ver1 | |
209 | local_first=${2-0} | |
c44a33e2 SG |
210 | # 'shift 2' if $2 is set, or 'shift' if $2 is not set |
211 | shift ${2:+2} | |
0a01d76f MAL |
212 | local_ver1=$* |
213 | set x $local_ver2 | |
214 | # the second argument finished, the first must be greater or equal | |
215 | test $# = 1 && return 0 | |
216 | test $local_first -lt $2 && return 1 | |
217 | test $local_first -gt $2 && return 0 | |
c44a33e2 | 218 | shift ${2:+2} |
0a01d76f MAL |
219 | local_ver2=$* |
220 | done | |
221 | } | |
222 | ||
3b6b7550 PB |
223 | glob() { |
224 | eval test -z '"${1#'"$2"'}"' | |
225 | } | |
226 | ||
e9a3591f CB |
227 | ld_has() { |
228 | $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1 | |
229 | } | |
230 | ||
4ace32e2 AO |
231 | if printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]"; |
232 | then | |
233 | error_exit "main directory cannot contain spaces nor colons" | |
234 | fi | |
235 | ||
14211825 | 236 | # default parameters |
2ff6b91e | 237 | cpu="" |
a31a8642 | 238 | iasl="iasl" |
1e43adfc | 239 | interp_prefix="/usr/gnemul/qemu-%M" |
43ce4dfe | 240 | static="no" |
3812c0c4 | 241 | cross_compile="no" |
7d13299d | 242 | cross_prefix="" |
87430d5b | 243 | audio_drv_list="default" |
b64ec4e4 FZ |
244 | block_drv_rw_whitelist="" |
245 | block_drv_ro_whitelist="" | |
e49d021e | 246 | host_cc="cc" |
cdad781d | 247 | lto="false" |
63678e17 | 248 | stack_protector="" |
1e4f6065 | 249 | safe_stack="" |
afc3a8f9 | 250 | use_containers="yes" |
f2385398 | 251 | gdb_bin=$(command -v "gdb-multiarch" || command -v "gdb") |
ac0df51d | 252 | |
92712822 DB |
253 | if test -e "$source_path/.git" |
254 | then | |
7d7dbf9d | 255 | git_submodules_action="update" |
92712822 | 256 | else |
7d7dbf9d | 257 | git_submodules_action="ignore" |
92712822 | 258 | fi |
2d652f24 PB |
259 | |
260 | git_submodules="ui/keycodemapdb" | |
cc84d63a | 261 | git="git" |
ac0df51d | 262 | |
afb63ebd SW |
263 | # Don't accept a target_list environment variable. |
264 | unset target_list | |
447e133f | 265 | unset target_list_exclude |
377529c0 PB |
266 | |
267 | # Default value for a variable defining feature "foo". | |
268 | # * foo="no" feature will only be used if --enable-foo arg is given | |
269 | # * foo="" feature will be searched for, and if found, will be used | |
270 | # unless --disable-foo is given | |
271 | # * foo="yes" this value will only be set by --enable-foo flag. | |
272 | # feature will searched for, | |
273 | # if not found, configure exits with error | |
274 | # | |
275 | # Always add --enable-foo and --disable-foo command line args. | |
276 | # Distributions want to ensure that several features are compiled in, and it | |
277 | # is impossible without a --enable-foo that exits if a feature is not found. | |
278 | ||
c87ea116 AB |
279 | default_feature="" |
280 | # parse CC options second | |
281 | for opt do | |
282 | optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') | |
283 | case "$opt" in | |
284 | --without-default-features) | |
285 | default_feature="no" | |
286 | ;; | |
287 | esac | |
288 | done | |
289 | ||
a2866660 PB |
290 | EXTRA_CFLAGS="" |
291 | EXTRA_CXXFLAGS="" | |
e910c7d9 | 292 | EXTRA_OBJCFLAGS="" |
a2866660 PB |
293 | EXTRA_LDFLAGS="" |
294 | ||
c87ea116 | 295 | xen_ctrl_version="$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" |
28609749 | 304 | debug_info="yes" |
377529c0 | 305 | debug_tcg="no" |
377529c0 | 306 | debug="no" |
247724cb | 307 | sanitizers="no" |
0aebab04 | 308 | tsan="no" |
1f3f2bfe | 309 | fortify_source="yes" |
1d728c39 | 310 | gcov="no" |
c7328271 | 311 | EXESUF="" |
17969268 | 312 | modules="no" |
377529c0 | 313 | prefix="/usr/local" |
10ff82d1 | 314 | qemu_suffix="qemu" |
377529c0 | 315 | softmmu="yes" |
b915a2f1 PB |
316 | linux_user="" |
317 | bsd_user="" | |
377529c0 | 318 | pkgversion="" |
40d6444e | 319 | pie="" |
377529c0 | 320 | trace_file="trace" |
519175a2 | 321 | coroutine="" |
a1c5e949 | 322 | tls_priority="NORMAL" |
ba4dd2aa | 323 | plugins="$default_feature" |
a5665051 | 324 | meson="" |
3b4da132 | 325 | meson_args="" |
48328880 | 326 | ninja="" |
a5665051 | 327 | skip_meson=no |
377529c0 | 328 | |
3b4da132 PB |
329 | # The following Meson options are handled manually (still they |
330 | # are included in the automatically generated help message) | |
331 | ||
332 | # 1. Track which submodules are needed | |
0577e84d TH |
333 | if test "$default_feature" = no ; then |
334 | capstone="disabled" | |
335 | slirp="disabled" | |
336 | else | |
337 | capstone="auto" | |
338 | slirp="auto" | |
339 | fi | |
3b4da132 | 340 | fdt="auto" |
3b4da132 PB |
341 | |
342 | # 2. Support --with/--without option | |
343 | default_devices="true" | |
344 | ||
345 | # 3. Automatically enable/disable other options | |
346 | tcg="enabled" | |
347 | cfi="false" | |
348 | ||
349 | # 4. Detection partly done in configure | |
350 | xen=${default_feature:+disabled} | |
898be3e0 | 351 | |
c87ea116 | 352 | # parse CC options second |
ac0df51d | 353 | for opt do |
89138857 | 354 | optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') |
ac0df51d AL |
355 | case "$opt" in |
356 | --cross-prefix=*) cross_prefix="$optarg" | |
3812c0c4 | 357 | cross_compile="yes" |
ac0df51d | 358 | ;; |
3d8df640 | 359 | --cc=*) CC="$optarg" |
ac0df51d | 360 | ;; |
83f73fce TS |
361 | --cxx=*) CXX="$optarg" |
362 | ;; | |
2ff6b91e JQ |
363 | --cpu=*) cpu="$optarg" |
364 | ;; | |
a2866660 PB |
365 | --extra-cflags=*) |
366 | EXTRA_CFLAGS="$EXTRA_CFLAGS $optarg" | |
367 | EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" | |
e910c7d9 | 368 | EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg" |
a2866660 PB |
369 | ;; |
370 | --extra-cxxflags=*) EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" | |
11cde1c8 | 371 | ;; |
e910c7d9 PMD |
372 | --extra-objcflags=*) EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg" |
373 | ;; | |
a2866660 | 374 | --extra-ldflags=*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS $optarg" |
e2a2ed06 | 375 | ;; |
d75402b5 AB |
376 | --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option" |
377 | ;; | |
479ca4cc | 378 | --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-cflags-}; cc_arch=${cc_arch%%=*} |
d422b2bc | 379 | eval "cross_cc_cflags_${cc_arch}=\$optarg" |
2038f8c8 | 380 | cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}" |
d422b2bc | 381 | ;; |
d75402b5 AB |
382 | --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*} |
383 | eval "cross_cc_${cc_arch}=\$optarg" | |
2038f8c8 | 384 | cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}" |
d75402b5 | 385 | ;; |
ac0df51d AL |
386 | esac |
387 | done | |
ac0df51d AL |
388 | # OS specific |
389 | # Using uname is really, really broken. Once we have the right set of checks | |
93148aa5 | 390 | # we can eliminate its usage altogether. |
ac0df51d | 391 | |
e49d021e PM |
392 | # Preferred compiler: |
393 | # ${CC} (if set) | |
394 | # ${cross_prefix}gcc (if cross-prefix specified) | |
395 | # system compiler | |
396 | if test -z "${CC}${cross_prefix}"; then | |
397 | cc="$host_cc" | |
398 | else | |
399 | cc="${CC-${cross_prefix}gcc}" | |
400 | fi | |
401 | ||
83f73fce TS |
402 | if test -z "${CXX}${cross_prefix}"; then |
403 | cxx="c++" | |
404 | else | |
405 | cxx="${CXX-${cross_prefix}g++}" | |
406 | fi | |
407 | ||
b3198cc2 | 408 | ar="${AR-${cross_prefix}ar}" |
cdbd727c | 409 | as="${AS-${cross_prefix}as}" |
5f6f0e27 | 410 | ccas="${CCAS-$cc}" |
3dd46c78 | 411 | cpp="${CPP-$cc -E}" |
b3198cc2 SY |
412 | objcopy="${OBJCOPY-${cross_prefix}objcopy}" |
413 | ld="${LD-${cross_prefix}ld}" | |
9f81aeb5 | 414 | ranlib="${RANLIB-${cross_prefix}ranlib}" |
4852ee95 | 415 | nm="${NM-${cross_prefix}nm}" |
35acbb30 | 416 | smbd="$SMBD" |
b3198cc2 SY |
417 | strip="${STRIP-${cross_prefix}strip}" |
418 | windres="${WINDRES-${cross_prefix}windres}" | |
17884d7b ST |
419 | pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}" |
420 | query_pkg_config() { | |
421 | "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@" | |
422 | } | |
423 | pkg_config=query_pkg_config | |
47c03744 | 424 | sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}" |
ac0df51d | 425 | |
be17dc90 | 426 | # default flags for all hosts |
2d31515b PM |
427 | # We use -fwrapv to tell the compiler that we require a C dialect where |
428 | # left shift of signed integers is well defined and has the expected | |
429 | # 2s-complement style results. (Both clang and gcc agree that it | |
430 | # provides these semantics.) | |
de38c0cc | 431 | QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv" |
086d5f75 | 432 | QEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS" |
c95e3080 | 433 | QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS" |
be17dc90 | 434 | QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS" |
5770e8af | 435 | |
de38c0cc PB |
436 | QEMU_LDFLAGS= |
437 | ||
5770e8af | 438 | # Flags that are needed during configure but later taken care of by Meson |
8a9d3d56 | 439 | CONFIGURE_CFLAGS="-std=gnu11 -Wall" |
5770e8af | 440 | CONFIGURE_LDFLAGS= |
086d5f75 | 441 | |
be17dc90 | 442 | |
ac0df51d AL |
443 | check_define() { |
444 | cat > $TMPC <<EOF | |
445 | #if !defined($1) | |
fd786e1a | 446 | #error $1 not defined |
ac0df51d AL |
447 | #endif |
448 | int main(void) { return 0; } | |
449 | EOF | |
52166aa0 | 450 | compile_object |
ac0df51d AL |
451 | } |
452 | ||
307119e7 GH |
453 | check_include() { |
454 | cat > $TMPC <<EOF | |
455 | #include <$1> | |
456 | int main(void) { return 0; } | |
457 | EOF | |
458 | compile_object | |
459 | } | |
460 | ||
93b25869 JS |
461 | write_c_skeleton() { |
462 | cat > $TMPC <<EOF | |
463 | int main(void) { return 0; } | |
464 | EOF | |
465 | } | |
466 | ||
bbea4050 | 467 | if check_define __linux__ ; then |
ba7c60c2 | 468 | targetos=linux |
bbea4050 | 469 | elif check_define _WIN32 ; then |
ba7c60c2 | 470 | targetos=windows |
bbea4050 | 471 | elif check_define __OpenBSD__ ; then |
ba7c60c2 | 472 | targetos=openbsd |
bbea4050 | 473 | elif check_define __sun__ ; then |
ba7c60c2 | 474 | targetos=sunos |
bbea4050 | 475 | elif check_define __HAIKU__ ; then |
ba7c60c2 | 476 | targetos=haiku |
951fedfc | 477 | elif check_define __FreeBSD__ ; then |
ba7c60c2 | 478 | targetos=freebsd |
951fedfc | 479 | elif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then |
ba7c60c2 | 480 | targetos=gnu/kfreebsd |
951fedfc | 481 | elif check_define __DragonFly__ ; then |
ba7c60c2 | 482 | targetos=dragonfly |
951fedfc | 483 | elif check_define __NetBSD__; then |
ba7c60c2 | 484 | targetos=netbsd |
951fedfc | 485 | elif check_define __APPLE__; then |
ba7c60c2 | 486 | targetos=darwin |
bbea4050 | 487 | else |
951fedfc PM |
488 | # This is a fatal error, but don't report it yet, because we |
489 | # might be going to just print the --help text, or it might | |
490 | # be the result of a missing compiler. | |
ba7c60c2 | 491 | targetos=bogus |
bbea4050 PM |
492 | fi |
493 | ||
65eff01b PB |
494 | # OS specific |
495 | ||
3b0d8643 PB |
496 | mingw32="no" |
497 | bsd="no" | |
498 | linux="no" | |
499 | solaris="no" | |
bbea4050 | 500 | case $targetos in |
65eff01b PB |
501 | windows) |
502 | mingw32="yes" | |
503 | plugins="no" | |
504 | pie="no" | |
505 | ;; | |
506 | gnu/kfreebsd) | |
507 | bsd="yes" | |
508 | ;; | |
509 | freebsd) | |
510 | bsd="yes" | |
65eff01b PB |
511 | make="${MAKE-gmake}" |
512 | # needed for kinfo_getvmmap(3) in libutil.h | |
513 | ;; | |
514 | dragonfly) | |
515 | bsd="yes" | |
516 | make="${MAKE-gmake}" | |
517 | ;; | |
518 | netbsd) | |
519 | bsd="yes" | |
520 | make="${MAKE-gmake}" | |
521 | ;; | |
522 | openbsd) | |
523 | bsd="yes" | |
524 | make="${MAKE-gmake}" | |
525 | ;; | |
526 | darwin) | |
527 | bsd="yes" | |
528 | darwin="yes" | |
529 | # Disable attempts to use ObjectiveC features in os/object.h since they | |
530 | # won't work when we're compiling with gcc as a C compiler. | |
531 | QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS" | |
532 | ;; | |
ba7c60c2 | 533 | sunos) |
65eff01b PB |
534 | solaris="yes" |
535 | make="${MAKE-gmake}" | |
65eff01b PB |
536 | # needed for CMSG_ macros in sys/socket.h |
537 | QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS" | |
538 | # needed for TIOCWIN* defines in termios.h | |
539 | QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS" | |
89138857 | 540 | # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo |
65eff01b PB |
541 | # Note that this check is broken for cross-compilation: if you're |
542 | # cross-compiling to one of these OSes then you'll need to specify | |
543 | # the correct CPU with the --cpu option. | |
bbea4050 PM |
544 | if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then |
545 | cpu="x86_64" | |
546 | fi | |
65eff01b PB |
547 | ;; |
548 | haiku) | |
549 | pie="no" | |
550 | QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE -fPIC $QEMU_CFLAGS" | |
551 | ;; | |
552 | linux) | |
553 | linux="yes" | |
65eff01b PB |
554 | vhost_user=${default_feature:-yes} |
555 | ;; | |
bbea4050 PM |
556 | esac |
557 | ||
2ff6b91e JQ |
558 | if test ! -z "$cpu" ; then |
559 | # command line argument | |
560 | : | |
561 | elif check_define __i386__ ; then | |
ac0df51d AL |
562 | cpu="i386" |
563 | elif check_define __x86_64__ ; then | |
c72b26ec RH |
564 | if check_define __ILP32__ ; then |
565 | cpu="x32" | |
566 | else | |
567 | cpu="x86_64" | |
568 | fi | |
3aa9bd6c | 569 | elif check_define __sparc__ ; then |
3aa9bd6c BS |
570 | if check_define __arch64__ ; then |
571 | cpu="sparc64" | |
572 | else | |
573 | cpu="sparc" | |
574 | fi | |
fdf7ed96 | 575 | elif check_define _ARCH_PPC ; then |
576 | if check_define _ARCH_PPC64 ; then | |
f8378acc RH |
577 | if check_define _LITTLE_ENDIAN ; then |
578 | cpu="ppc64le" | |
579 | else | |
580 | cpu="ppc64" | |
581 | fi | |
fdf7ed96 | 582 | else |
583 | cpu="ppc" | |
584 | fi | |
afa05235 AJ |
585 | elif check_define __mips__ ; then |
586 | cpu="mips" | |
d66ed0ea AJ |
587 | elif check_define __s390__ ; then |
588 | if check_define __s390x__ ; then | |
589 | cpu="s390x" | |
590 | else | |
591 | cpu="s390" | |
592 | fi | |
c4f80543 | 593 | elif check_define __riscv ; then |
ba0e7333 | 594 | cpu="riscv" |
21d89f84 PM |
595 | elif check_define __arm__ ; then |
596 | cpu="arm" | |
1f080313 CF |
597 | elif check_define __aarch64__ ; then |
598 | cpu="aarch64" | |
dfcf900b WX |
599 | elif check_define __loongarch64 ; then |
600 | cpu="loongarch64" | |
ac0df51d | 601 | else |
89138857 | 602 | cpu=$(uname -m) |
ac0df51d AL |
603 | fi |
604 | ||
823eb013 | 605 | # Normalise host CPU name, set multilib cflags |
359bc95d | 606 | # Note that this case should only have supported host CPUs, not guests. |
7d13299d | 607 | case "$cpu" in |
e4da0e39 PB |
608 | armv*b|armv*l|arm) |
609 | cpu="arm" ;; | |
610 | ||
7d13299d | 611 | i386|i486|i586|i686|i86pc|BePC) |
97a847bc | 612 | cpu="i386" |
e4da0e39 PB |
613 | CPU_CFLAGS="-m32" ;; |
614 | x32) | |
4da270be | 615 | cpu="x86_64" |
e4da0e39 | 616 | CPU_CFLAGS="-mx32" ;; |
aaa5fa14 AJ |
617 | x86_64|amd64) |
618 | cpu="x86_64" | |
e4da0e39 PB |
619 | # ??? Only extremely old AMD cpus do not have cmpxchg16b. |
620 | # If we truly care, we should simply detect this case at | |
621 | # runtime and generate the fallback to serial emulation. | |
622 | CPU_CFLAGS="-m64 -mcx16" ;; | |
623 | ||
afa05235 | 624 | mips*) |
e4da0e39 PB |
625 | cpu="mips" ;; |
626 | ||
627 | ppc) | |
628 | CPU_CFLAGS="-m32" ;; | |
629 | ppc64) | |
ced5cfff | 630 | CPU_CFLAGS="-m64 -mbig-endian" ;; |
e4da0e39 | 631 | ppc64le) |
d8ff892d | 632 | cpu="ppc64" |
ced5cfff | 633 | CPU_CFLAGS="-m64 -mlittle-endian" ;; |
e4da0e39 PB |
634 | |
635 | s390) | |
823eb013 | 636 | CPU_CFLAGS="-m31" ;; |
e4da0e39 PB |
637 | s390x) |
638 | CPU_CFLAGS="-m64" ;; | |
639 | ||
3142255c | 640 | sparc|sun4[cdmuv]) |
ae228531 | 641 | cpu="sparc" |
e4da0e39 PB |
642 | CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc" ;; |
643 | sparc64) | |
644 | CPU_CFLAGS="-m64 -mcpu=ultrasparc" ;; | |
7d13299d | 645 | esac |
e2d52ad3 | 646 | |
0db4a067 | 647 | : ${make=${MAKE-make}} |
b6daf4d3 | 648 | |
faf44142 DB |
649 | # We prefer python 3.x. A bare 'python' is traditionally |
650 | # python 2.x, but some distros have it as python 3.x, so | |
ddf90699 | 651 | # we check that too |
faf44142 | 652 | python= |
0a01d76f | 653 | explicit_python=no |
ddf90699 | 654 | for binary in "${PYTHON-python3}" python |
faf44142 DB |
655 | do |
656 | if has "$binary" | |
657 | then | |
95c5f2de | 658 | python=$(command -v "$binary") |
faf44142 DB |
659 | break |
660 | fi | |
661 | done | |
903458c8 | 662 | |
903458c8 | 663 | |
39d87c8c AB |
664 | # Check for ancillary tools used in testing |
665 | genisoimage= | |
3df437c7 | 666 | for binary in genisoimage mkisofs |
39d87c8c AB |
667 | do |
668 | if has $binary | |
669 | then | |
670 | genisoimage=$(command -v "$binary") | |
671 | break | |
672 | fi | |
673 | done | |
674 | ||
3c4a4d0d PM |
675 | # Default objcc to clang if available, otherwise use CC |
676 | if has clang; then | |
677 | objcc=clang | |
678 | else | |
679 | objcc="$cc" | |
680 | fi | |
681 | ||
3457a3f8 | 682 | if test "$mingw32" = "yes" ; then |
3457a3f8 | 683 | EXESUF=".exe" |
78e9d4ad | 684 | # MinGW needs -mthreads for TLS and macro _MT. |
5770e8af | 685 | CONFIGURE_CFLAGS="-mthreads $CONFIGURE_CFLAGS" |
93b25869 | 686 | write_c_skeleton; |
d17f305a | 687 | prefix="/qemu" |
77433a5f | 688 | qemu_suffix="" |
3457a3f8 JQ |
689 | fi |
690 | ||
487fefdb | 691 | werror="" |
85aa5189 | 692 | |
61d63097 PB |
693 | . $source_path/scripts/meson-buildoptions.sh |
694 | ||
695 | meson_options= | |
696 | meson_option_parse() { | |
697 | meson_options="$meson_options $(_meson_option_parse "$@")" | |
698 | if test $? -eq 1; then | |
699 | echo "ERROR: unknown option $1" | |
700 | echo "Try '$0 --help' for more information" | |
701 | exit 1 | |
702 | fi | |
703 | } | |
704 | ||
7d13299d | 705 | for opt do |
89138857 | 706 | optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') |
7d13299d | 707 | case "$opt" in |
2efc3265 FB |
708 | --help|-h) show_help=yes |
709 | ;; | |
99123e13 MF |
710 | --version|-V) exec cat $source_path/VERSION |
711 | ;; | |
b1a550a0 | 712 | --prefix=*) prefix="$optarg" |
7d13299d | 713 | ;; |
b1a550a0 | 714 | --interp-prefix=*) interp_prefix="$optarg" |
32ce6337 | 715 | ;; |
ac0df51d | 716 | --cross-prefix=*) |
7d13299d | 717 | ;; |
ac0df51d | 718 | --cc=*) |
7d13299d | 719 | ;; |
b1a550a0 | 720 | --host-cc=*) host_cc="$optarg" |
83469015 | 721 | ;; |
83f73fce TS |
722 | --cxx=*) |
723 | ;; | |
e007dbec MT |
724 | --iasl=*) iasl="$optarg" |
725 | ;; | |
3c4a4d0d PM |
726 | --objcc=*) objcc="$optarg" |
727 | ;; | |
b1a550a0 | 728 | --make=*) make="$optarg" |
7d13299d | 729 | ;; |
b6daf4d3 | 730 | --install=*) |
6a882643 | 731 | ;; |
0a01d76f | 732 | --python=*) python="$optarg" ; explicit_python=yes |
c886edfb | 733 | ;; |
2eb054c2 PM |
734 | --sphinx-build=*) sphinx_build="$optarg" |
735 | ;; | |
a5665051 PB |
736 | --skip-meson) skip_meson=yes |
737 | ;; | |
738 | --meson=*) meson="$optarg" | |
739 | ;; | |
48328880 PB |
740 | --ninja=*) ninja="$optarg" |
741 | ;; | |
e2d8830e BS |
742 | --smbd=*) smbd="$optarg" |
743 | ;; | |
e2a2ed06 | 744 | --extra-cflags=*) |
7d13299d | 745 | ;; |
11cde1c8 BD |
746 | --extra-cxxflags=*) |
747 | ;; | |
e910c7d9 PMD |
748 | --extra-objcflags=*) |
749 | ;; | |
e2a2ed06 | 750 | --extra-ldflags=*) |
7d13299d | 751 | ;; |
28609749 | 752 | --cross-cc-*) |
5bc62e01 | 753 | ;; |
28609749 | 754 | --enable-debug-info) debug_info="yes" |
5bc62e01 | 755 | ;; |
28609749 | 756 | --disable-debug-info) debug_info="no" |
d75402b5 | 757 | ;; |
17969268 FZ |
758 | --enable-modules) |
759 | modules="yes" | |
3aa88b31 SH |
760 | ;; |
761 | --disable-modules) | |
762 | modules="no" | |
17969268 | 763 | ;; |
2ff6b91e | 764 | --cpu=*) |
7d13299d | 765 | ;; |
b1a550a0 | 766 | --target-list=*) target_list="$optarg" |
447e133f AB |
767 | if test "$target_list_exclude"; then |
768 | error_exit "Can't mix --target-list with --target-list-exclude" | |
769 | fi | |
770 | ;; | |
771 | --target-list-exclude=*) target_list_exclude="$optarg" | |
772 | if test "$target_list"; then | |
773 | error_exit "Can't mix --target-list-exclude with --target-list" | |
774 | fi | |
de83cd02 | 775 | ;; |
74242e0f | 776 | --with-trace-file=*) trace_file="$optarg" |
9410b56c | 777 | ;; |
7bc3ca7f | 778 | --with-default-devices) default_devices="true" |
f3494749 | 779 | ;; |
7bc3ca7f | 780 | --without-default-devices) default_devices="false" |
f3494749 | 781 | ;; |
d1d5e9ee AB |
782 | --with-devices-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --with-devices-FOO option" |
783 | ;; | |
784 | --with-devices-*) device_arch=${opt#--with-devices-}; | |
785 | device_arch=${device_arch%%=*} | |
786 | cf=$source_path/configs/devices/$device_arch-softmmu/$optarg.mak | |
787 | if test -f "$cf"; then | |
788 | device_archs="$device_archs $device_arch" | |
789 | eval "devices_${device_arch}=\$optarg" | |
790 | else | |
791 | error_exit "File $cf does not exist" | |
792 | fi | |
793 | ;; | |
c87ea116 AB |
794 | --without-default-features) # processed above |
795 | ;; | |
1d728c39 BS |
796 | --enable-gcov) gcov="yes" |
797 | ;; | |
79427693 LM |
798 | --static) |
799 | static="yes" | |
17884d7b | 800 | QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS" |
43ce4dfe | 801 | ;; |
0b24e75f PB |
802 | --mandir=*) mandir="$optarg" |
803 | ;; | |
804 | --bindir=*) bindir="$optarg" | |
805 | ;; | |
3aa5d2be AL |
806 | --libdir=*) libdir="$optarg" |
807 | ;; | |
8bf188aa MT |
808 | --libexecdir=*) libexecdir="$optarg" |
809 | ;; | |
0f94d6da AL |
810 | --includedir=*) includedir="$optarg" |
811 | ;; | |
528ae5b8 | 812 | --datadir=*) datadir="$optarg" |
0b24e75f | 813 | ;; |
77433a5f | 814 | --with-suffix=*) qemu_suffix="$optarg" |
023d3d67 | 815 | ;; |
c6502638 | 816 | --docdir=*) docdir="$optarg" |
0b24e75f | 817 | ;; |
fe0038be PB |
818 | --localedir=*) localedir="$optarg" |
819 | ;; | |
ca2fb938 | 820 | --sysconfdir=*) sysconfdir="$optarg" |
07381cc1 | 821 | ;; |
785c23ae LC |
822 | --localstatedir=*) local_statedir="$optarg" |
823 | ;; | |
3d5eecab GH |
824 | --firmwarepath=*) firmwarepath="$optarg" |
825 | ;; | |
181ce1d0 OH |
826 | --host=*|--build=*|\ |
827 | --disable-dependency-tracking|\ | |
785c23ae | 828 | --sbindir=*|--sharedstatedir=*|\ |
fe0038be | 829 | --oldincludedir=*|--datarootdir=*|--infodir=*|\ |
023ddd74 MF |
830 | --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*) |
831 | # These switches are silently ignored, for compatibility with | |
832 | # autoconf-generated configure scripts. This allows QEMU's | |
833 | # configure to be used by RPM and similar macros that set | |
834 | # lots of directory switches by default. | |
835 | ;; | |
0c58ac1c | 836 | --audio-drv-list=*) audio_drv_list="$optarg" |
102a52e4 | 837 | ;; |
89138857 | 838 | --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g') |
b64ec4e4 | 839 | ;; |
89138857 | 840 | --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g') |
eb852011 | 841 | ;; |
f8393946 AJ |
842 | --enable-debug-tcg) debug_tcg="yes" |
843 | ;; | |
844 | --disable-debug-tcg) debug_tcg="no" | |
845 | ;; | |
f3d08ee6 PB |
846 | --enable-debug) |
847 | # Enable debugging options that aren't excessively noisy | |
848 | debug_tcg="yes" | |
c55cf6ab | 849 | meson_option_parse --enable-debug-mutex "" |
f3d08ee6 | 850 | debug="yes" |
b553a042 | 851 | fortify_source="no" |
f3d08ee6 | 852 | ;; |
247724cb MAL |
853 | --enable-sanitizers) sanitizers="yes" |
854 | ;; | |
855 | --disable-sanitizers) sanitizers="no" | |
856 | ;; | |
0aebab04 LY |
857 | --enable-tsan) tsan="yes" |
858 | ;; | |
859 | --disable-tsan) tsan="no" | |
860 | ;; | |
4d34a86b | 861 | --disable-slirp) slirp="disabled" |
1d14ffa9 | 862 | ;; |
fd6fc214 PB |
863 | --enable-slirp) slirp="enabled" |
864 | ;; | |
4d34a86b | 865 | --enable-slirp=git) slirp="internal" |
7c57bdd8 | 866 | ;; |
03a3c0b3 | 867 | --enable-slirp=*) slirp="$optarg" |
675b9b53 | 868 | ;; |
1badb709 | 869 | --disable-xen) xen="disabled" |
e37630ca | 870 | ;; |
1badb709 | 871 | --enable-xen) xen="enabled" |
fc321b4b | 872 | ;; |
1badb709 | 873 | --disable-tcg) tcg="disabled" |
d1a14257 | 874 | plugins="no" |
b3f6ea7e | 875 | ;; |
1badb709 | 876 | --enable-tcg) tcg="enabled" |
b3f6ea7e | 877 | ;; |
cad25d69 | 878 | --disable-system) softmmu="no" |
0a8e90f4 | 879 | ;; |
cad25d69 | 880 | --enable-system) softmmu="yes" |
0a8e90f4 | 881 | ;; |
0953a80f ZA |
882 | --disable-user) |
883 | linux_user="no" ; | |
884 | bsd_user="no" ; | |
0953a80f ZA |
885 | ;; |
886 | --enable-user) ;; | |
831b7825 | 887 | --disable-linux-user) linux_user="no" |
0a8e90f4 | 888 | ;; |
831b7825 TS |
889 | --enable-linux-user) linux_user="yes" |
890 | ;; | |
84778508 BS |
891 | --disable-bsd-user) bsd_user="no" |
892 | ;; | |
893 | --enable-bsd-user) bsd_user="yes" | |
894 | ;; | |
40d6444e | 895 | --enable-pie) pie="yes" |
34005a00 | 896 | ;; |
40d6444e | 897 | --disable-pie) pie="no" |
34005a00 | 898 | ;; |
85aa5189 FB |
899 | --enable-werror) werror="yes" |
900 | ;; | |
901 | --disable-werror) werror="no" | |
902 | ;; | |
cdad781d DB |
903 | --enable-lto) lto="true" |
904 | ;; | |
905 | --disable-lto) lto="false" | |
906 | ;; | |
63678e17 SN |
907 | --enable-stack-protector) stack_protector="yes" |
908 | ;; | |
909 | --disable-stack-protector) stack_protector="no" | |
910 | ;; | |
1e4f6065 DB |
911 | --enable-safe-stack) safe_stack="yes" |
912 | ;; | |
913 | --disable-safe-stack) safe_stack="no" | |
914 | ;; | |
9e62ba48 DB |
915 | --enable-cfi) |
916 | cfi="true"; | |
917 | lto="true"; | |
918 | ;; | |
919 | --disable-cfi) cfi="false" | |
920 | ;; | |
fbb4121d | 921 | --disable-fdt) fdt="disabled" |
2df87df7 | 922 | ;; |
fbb4121d PB |
923 | --enable-fdt) fdt="enabled" |
924 | ;; | |
925 | --enable-fdt=git) fdt="internal" | |
926 | ;; | |
03a3c0b3 | 927 | --enable-fdt=*) fdt="$optarg" |
2df87df7 | 928 | ;; |
7e563bfb | 929 | --with-pkgversion=*) pkgversion="$optarg" |
4a19f1ec | 930 | ;; |
519175a2 AB |
931 | --with-coroutine=*) coroutine="$optarg" |
932 | ;; | |
d5970055 MT |
933 | --disable-vhost-net) vhost_net="no" |
934 | ;; | |
935 | --enable-vhost-net) vhost_net="yes" | |
936 | ;; | |
042cea27 GA |
937 | --disable-vhost-crypto) vhost_crypto="no" |
938 | ;; | |
299e6f19 | 939 | --enable-vhost-crypto) vhost_crypto="yes" |
042cea27 | 940 | ;; |
5e9be92d NB |
941 | --disable-vhost-scsi) vhost_scsi="no" |
942 | ;; | |
943 | --enable-vhost-scsi) vhost_scsi="yes" | |
944 | ;; | |
fc0b9b0e SH |
945 | --disable-vhost-vsock) vhost_vsock="no" |
946 | ;; | |
947 | --enable-vhost-vsock) vhost_vsock="yes" | |
948 | ;; | |
98fc1ada DDAG |
949 | --disable-vhost-user-fs) vhost_user_fs="no" |
950 | ;; | |
951 | --enable-vhost-user-fs) vhost_user_fs="yes" | |
952 | ;; | |
1ffb3bbb | 953 | --disable-zlib-test) |
1ece9905 | 954 | ;; |
52b53c04 FZ |
955 | --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane) |
956 | echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2 | |
583f6e7b | 957 | ;; |
cb6414df FZ |
958 | --enable-vhdx|--disable-vhdx) |
959 | echo "$0: $opt is obsolete, VHDX driver is always built" >&2 | |
960 | ;; | |
315d3184 FZ |
961 | --enable-uuid|--disable-uuid) |
962 | echo "$0: $opt is obsolete, UUID support is always built" >&2 | |
963 | ;; | |
a1c5e949 DB |
964 | --tls-priority=*) tls_priority="$optarg" |
965 | ;; | |
e6a74868 MAL |
966 | --disable-vhost-user) vhost_user="no" |
967 | ;; | |
299e6f19 PB |
968 | --enable-vhost-user) vhost_user="yes" |
969 | ;; | |
108a6481 CL |
970 | --disable-vhost-vdpa) vhost_vdpa="no" |
971 | ;; | |
972 | --enable-vhost-vdpa) vhost_vdpa="yes" | |
973 | ;; | |
299e6f19 PB |
974 | --disable-vhost-kernel) vhost_kernel="no" |
975 | ;; | |
976 | --enable-vhost-kernel) vhost_kernel="yes" | |
e6a74868 | 977 | ;; |
8b18cdbf | 978 | --disable-capstone) capstone="disabled" |
8ca80760 | 979 | ;; |
8b18cdbf | 980 | --enable-capstone) capstone="enabled" |
8ca80760 | 981 | ;; |
8b18cdbf | 982 | --enable-capstone=git) capstone="internal" |
e219c499 | 983 | ;; |
03a3c0b3 | 984 | --enable-capstone=*) capstone="$optarg" |
e219c499 | 985 | ;; |
cc84d63a DB |
986 | --with-git=*) git="$optarg" |
987 | ;; | |
7d7dbf9d DS |
988 | --with-git-submodules=*) |
989 | git_submodules_action="$optarg" | |
f62bbee5 | 990 | ;; |
9b8e4298 AB |
991 | --enable-plugins) if test "$mingw32" = "yes"; then |
992 | error_exit "TCG plugins not currently supported on Windows platforms" | |
993 | else | |
994 | plugins="yes" | |
995 | fi | |
40e8c6f4 AB |
996 | ;; |
997 | --disable-plugins) plugins="no" | |
998 | ;; | |
afc3a8f9 AB |
999 | --enable-containers) use_containers="yes" |
1000 | ;; | |
1001 | --disable-containers) use_containers="no" | |
1002 | ;; | |
f48e590a AB |
1003 | --gdb=*) gdb_bin="$optarg" |
1004 | ;; | |
3b4da132 PB |
1005 | # backwards compatibility options |
1006 | --enable-trace-backend=*) meson_option_parse "--enable-trace-backends=$optarg" "$optarg" | |
1007 | ;; | |
1008 | --disable-blobs) meson_option_parse --disable-install-blobs "" | |
1009 | ;; | |
1010 | --enable-tcmalloc) meson_option_parse --enable-malloc=tcmalloc tcmalloc | |
1011 | ;; | |
1012 | --enable-jemalloc) meson_option_parse --enable-malloc=jemalloc jemalloc | |
1013 | ;; | |
1014 | # everything else has the same name in configure and meson | |
61d63097 PB |
1015 | --enable-* | --disable-*) meson_option_parse "$opt" "$optarg" |
1016 | ;; | |
2d2ad6d0 FZ |
1017 | *) |
1018 | echo "ERROR: unknown option $opt" | |
1019 | echo "Try '$0 --help' for more information" | |
1020 | exit 1 | |
7f1559c6 | 1021 | ;; |
7d13299d FB |
1022 | esac |
1023 | done | |
1024 | ||
d1a14257 AB |
1025 | # test for any invalid configuration combinations |
1026 | if test "$plugins" = "yes" -a "$tcg" = "disabled"; then | |
1027 | error_exit "Can't enable plugins on non-TCG builds" | |
1028 | fi | |
1029 | ||
7d7dbf9d DS |
1030 | case $git_submodules_action in |
1031 | update|validate) | |
1032 | if test ! -e "$source_path/.git"; then | |
1033 | echo "ERROR: cannot $git_submodules_action git submodules without .git" | |
1034 | exit 1 | |
1035 | fi | |
1036 | ;; | |
1037 | ignore) | |
b80fd281 PB |
1038 | if ! test -f "$source_path/ui/keycodemapdb/README" |
1039 | then | |
1040 | echo | |
1041 | echo "ERROR: missing GIT submodules" | |
1042 | echo | |
1043 | if test -e "$source_path/.git"; then | |
1044 | echo "--with-git-submodules=ignore specified but submodules were not" | |
1045 | echo "checked out. Please initialize and update submodules." | |
1046 | else | |
1047 | echo "This is not a GIT checkout but module content appears to" | |
1048 | echo "be missing. Do not use 'git archive' or GitHub download links" | |
1049 | echo "to acquire QEMU source archives. Non-GIT builds are only" | |
1050 | echo "supported with source archives linked from:" | |
1051 | echo | |
1052 | echo " https://www.qemu.org/download/#source" | |
1053 | echo | |
1054 | echo "Developers working with GIT can use scripts/archive-source.sh" | |
1055 | echo "if they need to create valid source archives." | |
1056 | fi | |
1057 | echo | |
1058 | exit 1 | |
1059 | fi | |
7d7dbf9d DS |
1060 | ;; |
1061 | *) | |
1062 | echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'" | |
1063 | exit 1 | |
1064 | ;; | |
1065 | esac | |
1066 | ||
22a87800 MAL |
1067 | libdir="${libdir:-$prefix/lib}" |
1068 | libexecdir="${libexecdir:-$prefix/libexec}" | |
1069 | includedir="${includedir:-$prefix/include}" | |
1070 | ||
1071 | if test "$mingw32" = "yes" ; then | |
15588a62 | 1072 | bindir="${bindir:-$prefix}" |
22a87800 | 1073 | else |
22a87800 | 1074 | bindir="${bindir:-$prefix/bin}" |
22a87800 | 1075 | fi |
15588a62 JW |
1076 | mandir="${mandir:-$prefix/share/man}" |
1077 | datadir="${datadir:-$prefix/share}" | |
1078 | docdir="${docdir:-$prefix/share/doc}" | |
1079 | sysconfdir="${sysconfdir:-$prefix/etc}" | |
1080 | local_statedir="${local_statedir:-$prefix/var}" | |
16bf7a33 PB |
1081 | firmwarepath="${firmwarepath:-$datadir/qemu-firmware}" |
1082 | localedir="${localedir:-$datadir/locale}" | |
22a87800 | 1083 | |
9557af9c AB |
1084 | if eval test -z "\${cross_cc_$cpu}"; then |
1085 | eval "cross_cc_${cpu}=\$cc" | |
1086 | cross_cc_vars="$cross_cc_vars cross_cc_${cpu}" | |
1087 | fi | |
79f3b12f | 1088 | |
60e0df25 | 1089 | default_target_list="" |
6e92f823 PM |
1090 | mak_wilds="" |
1091 | ||
b915a2f1 PB |
1092 | if [ "$linux_user" != no ]; then |
1093 | if [ "$targetos" = linux ] && [ -d $source_path/linux-user/include/host/$cpu ]; then | |
1094 | linux_user=yes | |
1095 | elif [ "$linux_user" = yes ]; then | |
1096 | error_exit "linux-user not supported on this architecture" | |
1097 | fi | |
1098 | fi | |
1099 | if [ "$bsd_user" != no ]; then | |
1100 | if [ "$bsd_user" = "" ]; then | |
1101 | test $targetos = freebsd && bsd_user=yes | |
1102 | fi | |
1103 | if [ "$bsd_user" = yes ] && ! [ -d $source_path/bsd-user/$targetos ]; then | |
1104 | error_exit "bsd-user not supported on this host OS" | |
1105 | fi | |
1106 | fi | |
6e92f823 | 1107 | if [ "$softmmu" = "yes" ]; then |
812b31d3 | 1108 | mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak" |
60e0df25 | 1109 | fi |
6e92f823 | 1110 | if [ "$linux_user" = "yes" ]; then |
812b31d3 | 1111 | mak_wilds="${mak_wilds} $source_path/configs/targets/*-linux-user.mak" |
60e0df25 | 1112 | fi |
6e92f823 | 1113 | if [ "$bsd_user" = "yes" ]; then |
812b31d3 | 1114 | mak_wilds="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak" |
60e0df25 PM |
1115 | fi |
1116 | ||
2d838d9b AB |
1117 | for config in $mak_wilds; do |
1118 | target="$(basename "$config" .mak)" | |
98db9a06 | 1119 | if echo "$target_list_exclude" | grep -vq "$target"; then |
2d838d9b AB |
1120 | default_target_list="${default_target_list} $target" |
1121 | fi | |
1122 | done | |
6e92f823 | 1123 | |
af5db58e PB |
1124 | if test x"$show_help" = x"yes" ; then |
1125 | cat << EOF | |
1126 | ||
1127 | Usage: configure [options] | |
1128 | Options: [defaults in brackets after descriptions] | |
1129 | ||
08fb77ed SW |
1130 | Standard options: |
1131 | --help print this message | |
1132 | --prefix=PREFIX install in PREFIX [$prefix] | |
1133 | --interp-prefix=PREFIX where to find shared libraries, etc. | |
1134 | use %M for cpu name [$interp_prefix] | |
74154d7e | 1135 | --target-list=LIST set target list (default: build all) |
08fb77ed SW |
1136 | $(echo Available targets: $default_target_list | \ |
1137 | fold -s -w 53 | sed -e 's/^/ /') | |
447e133f | 1138 | --target-list-exclude=LIST exclude a set of targets from the default target-list |
08fb77ed SW |
1139 | |
1140 | Advanced options (experts only): | |
3812c0c4 | 1141 | --cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix] |
08fb77ed SW |
1142 | --cc=CC use C compiler CC [$cc] |
1143 | --iasl=IASL use ACPI compiler IASL [$iasl] | |
1144 | --host-cc=CC use C compiler CC [$host_cc] for code run at | |
1145 | build time | |
1146 | --cxx=CXX use C++ compiler CXX [$cxx] | |
1147 | --objcc=OBJCC use Objective-C compiler OBJCC [$objcc] | |
a2866660 PB |
1148 | --extra-cflags=CFLAGS append extra C compiler flags CFLAGS |
1149 | --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS | |
e910c7d9 | 1150 | --extra-objcflags=OBJCFLAGS append extra Objective C compiler flags OBJCFLAGS |
08fb77ed | 1151 | --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS |
d75402b5 | 1152 | --cross-cc-ARCH=CC use compiler when building ARCH guest test cases |
479ca4cc | 1153 | --cross-cc-cflags-ARCH= use compiler flags when building ARCH guest tests |
08fb77ed | 1154 | --make=MAKE use specified make [$make] |
08fb77ed | 1155 | --python=PYTHON use specified python [$python] |
2eb054c2 | 1156 | --sphinx-build=SPHINX use specified sphinx-build [$sphinx_build] |
a5665051 | 1157 | --meson=MESON use specified meson [$meson] |
48328880 | 1158 | --ninja=NINJA use specified ninja [$ninja] |
08fb77ed | 1159 | --smbd=SMBD use specified smbd [$smbd] |
db1b5f13 | 1160 | --with-git=GIT use specified git [$git] |
7d7dbf9d DS |
1161 | --with-git-submodules=update update git submodules (default if .git dir exists) |
1162 | --with-git-submodules=validate fail if git submodules are not up to date | |
1163 | --with-git-submodules=ignore do not update or check git submodules (default if no .git dir) | |
08fb77ed SW |
1164 | --static enable static build [$static] |
1165 | --mandir=PATH install man pages in PATH | |
10ff82d1 | 1166 | --datadir=PATH install firmware in PATH/$qemu_suffix |
fe0038be | 1167 | --localedir=PATH install translation in PATH/$qemu_suffix |
10ff82d1 | 1168 | --docdir=PATH install documentation in PATH/$qemu_suffix |
08fb77ed SW |
1169 | --bindir=PATH install binaries in PATH |
1170 | --libdir=PATH install libraries in PATH | |
db1b5f13 | 1171 | --libexecdir=PATH install helper binaries in PATH |
10ff82d1 | 1172 | --sysconfdir=PATH install config in PATH/$qemu_suffix |
08fb77ed | 1173 | --localstatedir=PATH install local state in PATH (set at runtime on win32) |
3d5eecab | 1174 | --firmwarepath=PATH search PATH for firmware files |
13336606 | 1175 | --efi-aarch64=PATH PATH of efi file to use for aarch64 VMs. |
ca8c0909 | 1176 | --with-suffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix] |
db1b5f13 | 1177 | --with-pkgversion=VERS use specified string as sub-version of the package |
c035c8d6 PB |
1178 | --without-default-features default all --enable-* options to "disabled" |
1179 | --without-default-devices do not include any device that is not needed to | |
1180 | start the emulator (only use if you are including | |
d1d5e9ee AB |
1181 | desired devices in configs/devices/) |
1182 | --with-devices-ARCH=NAME override default configs/devices | |
08fb77ed | 1183 | --enable-debug enable common debug build options |
247724cb | 1184 | --enable-sanitizers enable default sanitizers |
0aebab04 | 1185 | --enable-tsan enable thread sanitizer |
08fb77ed | 1186 | --disable-werror disable compilation abort on warning |
63678e17 | 1187 | --disable-stack-protector disable compiler-provided stack protection |
16bfbc70 | 1188 | --audio-drv-list=LIST set audio drivers to try if -audiodev is not used |
08fb77ed SW |
1189 | --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L |
1190 | --block-drv-rw-whitelist=L | |
1191 | set block driver read-write whitelist | |
e5f05f8c | 1192 | (by default affects only QEMU, not tools like qemu-img) |
08fb77ed SW |
1193 | --block-drv-ro-whitelist=L |
1194 | set block driver read-only whitelist | |
e5f05f8c | 1195 | (by default affects only QEMU, not tools like qemu-img) |
08fb77ed SW |
1196 | --with-trace-file=NAME Full PATH,NAME of file to store traces |
1197 | Default:trace-<pid> | |
c23f23b9 | 1198 | --cpu=CPU Build for host CPU [$cpu] |
08fb77ed | 1199 | --with-coroutine=BACKEND coroutine backend. Supported options: |
33c53c54 | 1200 | ucontext, sigaltstack, windows |
08fb77ed | 1201 | --enable-gcov enable test coverage analysis with gcov |
a1c5e949 | 1202 | --tls-priority default TLS protocol/cipher priority string |
40e8c6f4 AB |
1203 | --enable-plugins |
1204 | enable plugins via shared library loading | |
afc3a8f9 | 1205 | --disable-containers don't use containers for cross-building |
f48e590a | 1206 | --gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin] |
61d63097 PB |
1207 | EOF |
1208 | meson_options_help | |
1209 | cat << EOF | |
c23f23b9 MT |
1210 | system all system emulation targets |
1211 | user supported user emulation targets | |
1212 | linux-user all linux usermode emulation targets | |
1213 | bsd-user all BSD usermode emulation targets | |
c23f23b9 | 1214 | pie Position Independent Executables |
21e709aa | 1215 | modules modules support (non-Windows) |
c23f23b9 MT |
1216 | debug-tcg TCG debugging (default is disabled) |
1217 | debug-info debugging information | |
cdad781d | 1218 | lto Enable Link-Time Optimization. |
1e4f6065 DB |
1219 | safe-stack SafeStack Stack Smash Protection. Depends on |
1220 | clang/llvm >= 3.7 and requires coroutine backend ucontext. | |
299e6f19 PB |
1221 | vhost-net vhost-net kernel acceleration support |
1222 | vhost-vsock virtio sockets device support | |
1223 | vhost-scsi vhost-scsi kernel target support | |
1224 | vhost-crypto vhost-user-crypto backend support | |
1225 | vhost-kernel vhost kernel backend support | |
1226 | vhost-user vhost-user backend support | |
108a6481 | 1227 | vhost-vdpa vhost-vdpa kernel backend support |
08fb77ed SW |
1228 | |
1229 | NOTE: The object files are built at the place where configure is launched | |
af5db58e | 1230 | EOF |
2d2ad6d0 | 1231 | exit 0 |
af5db58e PB |
1232 | fi |
1233 | ||
9c790242 | 1234 | # Remove old dependency files to make sure that they get properly regenerated |
bb768f71 | 1235 | rm -f */config-devices.mak.d |
9c790242 | 1236 | |
faf44142 DB |
1237 | if test -z "$python" |
1238 | then | |
1239 | error_exit "Python not found. Use --python=/path/to/python" | |
c53eeaf7 | 1240 | fi |
8e2c76bd RB |
1241 | if ! has "$make" |
1242 | then | |
1243 | error_exit "GNU make ($make) not found" | |
1244 | fi | |
c53eeaf7 SH |
1245 | |
1246 | # Note that if the Python conditional here evaluates True we will exit | |
1247 | # with status 1 which is a shell 'false' value. | |
1b11f28d TH |
1248 | if ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then |
1249 | error_exit "Cannot use '$python', Python >= 3.6 is required." \ | |
c53eeaf7 SH |
1250 | "Use --python=/path/to/python to specify a supported Python." |
1251 | fi | |
1252 | ||
755ee70f | 1253 | # Preserve python version since some functionality is dependent on it |
406ab2f3 | 1254 | 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 | 1255 | |
c53eeaf7 SH |
1256 | # Suppress writing compiled files |
1257 | python="$python -B" | |
1258 | ||
0a01d76f | 1259 | if test -z "$meson"; then |
6638cae5 | 1260 | if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.59.3; then |
0a01d76f | 1261 | meson=meson |
7d7dbf9d | 1262 | elif test $git_submodules_action != 'ignore' ; then |
0a01d76f MAL |
1263 | meson=git |
1264 | elif test -e "${source_path}/meson/meson.py" ; then | |
1265 | meson=internal | |
1266 | else | |
1267 | if test "$explicit_python" = yes; then | |
1268 | error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found." | |
1269 | else | |
1270 | error_exit "Meson not found. Use --meson=/path/to/meson" | |
1271 | fi | |
1272 | fi | |
1273 | else | |
1274 | # Meson uses its own Python interpreter to invoke other Python scripts, | |
1275 | # but the user wants to use the one they specified with --python. | |
1276 | # | |
1277 | # We do not want to override the distro Python interpreter (and sometimes | |
1278 | # cannot: for example in Homebrew /usr/bin/meson is a bash script), so | |
1279 | # just require --meson=git|internal together with --python. | |
1280 | if test "$explicit_python" = yes; then | |
1281 | case "$meson" in | |
1282 | git | internal) ;; | |
1283 | *) error_exit "--python requires using QEMU's embedded Meson distribution." ;; | |
1284 | esac | |
1285 | fi | |
a5665051 | 1286 | fi |
a5665051 | 1287 | |
0a01d76f MAL |
1288 | if test "$meson" = git; then |
1289 | git_submodules="${git_submodules} meson" | |
a5665051 | 1290 | fi |
0a01d76f MAL |
1291 | |
1292 | case "$meson" in | |
1293 | git | internal) | |
0a01d76f MAL |
1294 | meson="$python ${source_path}/meson/meson.py" |
1295 | ;; | |
84ec0c24 | 1296 | *) meson=$(command -v "$meson") ;; |
0a01d76f MAL |
1297 | esac |
1298 | ||
09e93326 | 1299 | # Probe for ninja |
48328880 PB |
1300 | |
1301 | if test -z "$ninja"; then | |
1302 | for c in ninja ninja-build samu; do | |
1303 | if has $c; then | |
1304 | ninja=$(command -v "$c") | |
1305 | break | |
1306 | fi | |
1307 | done | |
09e93326 PB |
1308 | if test -z "$ninja"; then |
1309 | error_exit "Cannot find Ninja" | |
1310 | fi | |
48328880 | 1311 | fi |
a5665051 | 1312 | |
9aae6e54 DHB |
1313 | # Check that the C compiler works. Doing this here before testing |
1314 | # the host CPU ensures that we had a valid CC to autodetect the | |
1315 | # $cpu var (and we should bail right here if that's not the case). | |
1316 | # It also allows the help message to be printed without a CC. | |
1317 | write_c_skeleton; | |
1318 | if compile_object ; then | |
1319 | : C compiler works ok | |
1320 | else | |
1321 | error_exit "\"$cc\" either does not exist or does not work" | |
1322 | fi | |
1323 | if ! compile_prog ; then | |
1324 | error_exit "\"$cc\" cannot build an executable (is your linker broken?)" | |
1325 | fi | |
1326 | ||
9c83ffd8 PM |
1327 | # Consult white-list to determine whether to enable werror |
1328 | # by default. Only enable by default for git builds | |
9c83ffd8 | 1329 | if test -z "$werror" ; then |
7d7dbf9d | 1330 | if test "$git_submodules_action" != "ignore" && \ |
e633a5c6 | 1331 | { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then |
9c83ffd8 PM |
1332 | werror="yes" |
1333 | else | |
1334 | werror="no" | |
1335 | fi | |
1336 | fi | |
1337 | ||
975ff037 | 1338 | if test "$targetos" = "bogus"; then |
fb59dabd PM |
1339 | # Now that we know that we're not printing the help and that |
1340 | # the compiler works (so the results of the check_defines we used | |
1341 | # to identify the OS are reliable), if we didn't recognize the | |
1342 | # host OS we should stop now. | |
951fedfc | 1343 | error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')" |
fb59dabd PM |
1344 | fi |
1345 | ||
efc6c070 TH |
1346 | # Check whether the compiler matches our minimum requirements: |
1347 | cat > $TMPC << EOF | |
1348 | #if defined(__clang_major__) && defined(__clang_minor__) | |
1349 | # ifdef __apple_build_version__ | |
2a85a08c DB |
1350 | # if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0) |
1351 | # error You need at least XCode Clang v10.0 to compile QEMU | |
efc6c070 TH |
1352 | # endif |
1353 | # else | |
2a85a08c DB |
1354 | # if __clang_major__ < 6 || (__clang_major__ == 6 && __clang_minor__ < 0) |
1355 | # error You need at least Clang v6.0 to compile QEMU | |
efc6c070 TH |
1356 | # endif |
1357 | # endif | |
1358 | #elif defined(__GNUC__) && defined(__GNUC_MINOR__) | |
3830df5f | 1359 | # if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4) |
1360 | # error You need at least GCC v7.4.0 to compile QEMU | |
efc6c070 TH |
1361 | # endif |
1362 | #else | |
1363 | # error You either need GCC or Clang to compiler QEMU | |
1364 | #endif | |
1365 | int main (void) { return 0; } | |
1366 | EOF | |
1367 | if ! compile_prog "" "" ; then | |
3830df5f | 1368 | error_exit "You need at least GCC v7.4 or Clang v6.0 (or XCode Clang v10.0)" |
efc6c070 TH |
1369 | fi |
1370 | ||
00849b92 RH |
1371 | # Accumulate -Wfoo and -Wno-bar separately. |
1372 | # We will list all of the enable flags first, and the disable flags second. | |
1373 | # Note that we do not add -Werror, because that would enable it for all | |
1374 | # configure tests. If a configure test failed due to -Werror this would | |
1375 | # just silently disable some features, so it's too error prone. | |
1376 | ||
1377 | warn_flags= | |
1378 | add_to warn_flags -Wold-style-declaration | |
1379 | add_to warn_flags -Wold-style-definition | |
1380 | add_to warn_flags -Wtype-limits | |
1381 | add_to warn_flags -Wformat-security | |
1382 | add_to warn_flags -Wformat-y2k | |
1383 | add_to warn_flags -Winit-self | |
1384 | add_to warn_flags -Wignored-qualifiers | |
1385 | add_to warn_flags -Wempty-body | |
1386 | add_to warn_flags -Wnested-externs | |
1387 | add_to warn_flags -Wendif-labels | |
1388 | add_to warn_flags -Wexpansion-to-defined | |
0a2ebce9 | 1389 | add_to warn_flags -Wimplicit-fallthrough=2 |
00849b92 RH |
1390 | |
1391 | nowarn_flags= | |
1392 | add_to nowarn_flags -Wno-initializer-overrides | |
1393 | add_to nowarn_flags -Wno-missing-include-dirs | |
1394 | add_to nowarn_flags -Wno-shift-negative-value | |
1395 | add_to nowarn_flags -Wno-string-plus-int | |
1396 | add_to nowarn_flags -Wno-typedef-redefinition | |
aabab967 | 1397 | add_to nowarn_flags -Wno-tautological-type-limit-compare |
bac8d222 | 1398 | add_to nowarn_flags -Wno-psabi |
00849b92 RH |
1399 | |
1400 | gcc_flags="$warn_flags $nowarn_flags" | |
93b25869 JS |
1401 | |
1402 | cc_has_warning_flag() { | |
1403 | write_c_skeleton; | |
1404 | ||
a1d29d6c PM |
1405 | # Use the positive sense of the flag when testing for -Wno-wombat |
1406 | # support (gcc will happily accept the -Wno- form of unknown | |
1407 | # warning options). | |
93b25869 JS |
1408 | optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')" |
1409 | compile_prog "-Werror $optflag" "" | |
1410 | } | |
1411 | ||
4cb37d11 PMD |
1412 | objcc_has_warning_flag() { |
1413 | cat > $TMPM <<EOF | |
1414 | int main(void) { return 0; } | |
1415 | EOF | |
1416 | ||
1417 | # Use the positive sense of the flag when testing for -Wno-wombat | |
1418 | # support (gcc will happily accept the -Wno- form of unknown | |
1419 | # warning options). | |
1420 | optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')" | |
1421 | do_objc -Werror $optflag \ | |
1422 | $OBJCFLAGS $EXTRA_OBJCFLAGS $CONFIGURE_OBJCFLAGS $QEMU_OBJCFLAGS \ | |
1423 | -o $TMPE $TMPM $QEMU_LDFLAGS | |
1424 | } | |
1425 | ||
93b25869 JS |
1426 | for flag in $gcc_flags; do |
1427 | if cc_has_warning_flag $flag ; then | |
1428 | QEMU_CFLAGS="$QEMU_CFLAGS $flag" | |
8d05095c | 1429 | fi |
4cb37d11 PMD |
1430 | if objcc_has_warning_flag $flag ; then |
1431 | QEMU_OBJCFLAGS="$QEMU_OBJCFLAGS $flag" | |
1432 | fi | |
8d05095c PB |
1433 | done |
1434 | ||
3b463a3f | 1435 | if test "$stack_protector" != "no"; then |
fccd35a0 RR |
1436 | cat > $TMPC << EOF |
1437 | int main(int argc, char *argv[]) | |
1438 | { | |
1439 | char arr[64], *p = arr, *c = argv[0]; | |
1440 | while (*c) { | |
1441 | *p++ = *c++; | |
1442 | } | |
1443 | return 0; | |
1444 | } | |
1445 | EOF | |
63678e17 | 1446 | gcc_flags="-fstack-protector-strong -fstack-protector-all" |
3b463a3f | 1447 | sp_on=0 |
63678e17 | 1448 | for flag in $gcc_flags; do |
590e5dd9 PM |
1449 | # We need to check both a compile and a link, since some compiler |
1450 | # setups fail only on a .c->.o compile and some only at link time | |
086d5f75 | 1451 | if compile_object "-Werror $flag" && |
590e5dd9 | 1452 | compile_prog "-Werror $flag" ""; then |
63678e17 | 1453 | QEMU_CFLAGS="$QEMU_CFLAGS $flag" |
db5adeaa | 1454 | QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" |
3b463a3f | 1455 | sp_on=1 |
63678e17 SN |
1456 | break |
1457 | fi | |
1458 | done | |
3b463a3f MR |
1459 | if test "$stack_protector" = yes; then |
1460 | if test $sp_on = 0; then | |
1461 | error_exit "Stack protector not supported" | |
1462 | fi | |
1463 | fi | |
37746c5e MAL |
1464 | fi |
1465 | ||
20bc94a2 PB |
1466 | # Disable -Wmissing-braces on older compilers that warn even for |
1467 | # the "universal" C zero initializer {0}. | |
1468 | cat > $TMPC << EOF | |
1469 | struct { | |
1470 | int a[2]; | |
1471 | } x = {0}; | |
1472 | EOF | |
1473 | if compile_object "-Werror" "" ; then | |
1474 | : | |
1475 | else | |
1476 | QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces" | |
1477 | fi | |
1478 | ||
21e709aa MAL |
1479 | # Our module code doesn't support Windows |
1480 | if test "$modules" = "yes" && test "$mingw32" = "yes" ; then | |
1481 | error_exit "Modules are not available for Windows" | |
1482 | fi | |
1483 | ||
5f2453ac | 1484 | # Static linking is not possible with plugins, modules or PIE |
40d6444e | 1485 | if test "$static" = "yes" ; then |
aa0d1f44 PB |
1486 | if test "$modules" = "yes" ; then |
1487 | error_exit "static and modules are mutually incompatible" | |
1488 | fi | |
5f2453ac AB |
1489 | if test "$plugins" = "yes"; then |
1490 | error_exit "static and plugins are mutually incompatible" | |
ba4dd2aa AB |
1491 | else |
1492 | plugins="no" | |
5f2453ac | 1493 | fi |
40d6444e | 1494 | fi |
37650689 | 1495 | test "$plugins" = "" && plugins=yes |
40d6444e | 1496 | |
b2634124 | 1497 | cat > $TMPC << EOF |
21d4a791 AK |
1498 | |
1499 | #ifdef __linux__ | |
1500 | # define THREAD __thread | |
1501 | #else | |
1502 | # define THREAD | |
1503 | #endif | |
21d4a791 | 1504 | static THREAD int tls_var; |
21d4a791 | 1505 | int main(void) { return tls_var; } |
40d6444e | 1506 | EOF |
412aeacd | 1507 | |
ffd205ef JC |
1508 | # Check we support -fno-pie and -no-pie first; we will need the former for |
1509 | # building ROMs, and both for everything if --disable-pie is passed. | |
b2634124 RH |
1510 | if compile_prog "-Werror -fno-pie" "-no-pie"; then |
1511 | CFLAGS_NOPIE="-fno-pie" | |
ffd205ef | 1512 | LDFLAGS_NOPIE="-no-pie" |
b2634124 RH |
1513 | fi |
1514 | ||
12781462 | 1515 | if test "$static" = "yes"; then |
eca7a8e6 | 1516 | if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then |
5770e8af | 1517 | CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS" |
12781462 RH |
1518 | QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS" |
1519 | pie="yes" | |
1520 | elif test "$pie" = "yes"; then | |
1521 | error_exit "-static-pie not available due to missing toolchain support" | |
1522 | else | |
1523 | QEMU_LDFLAGS="-static $QEMU_LDFLAGS" | |
1524 | pie="no" | |
1525 | fi | |
1526 | elif test "$pie" = "no"; then | |
5770e8af | 1527 | CONFIGURE_CFLAGS="$CFLAGS_NOPIE $CONFIGURE_CFLAGS" |
ffd205ef | 1528 | CONFIGURE_LDFLAGS="$LDFLAGS_NOPIE $CONFIGURE_LDFLAGS" |
eca7a8e6 | 1529 | elif compile_prog "-Werror -fPIE -DPIE" "-pie"; then |
5770e8af PB |
1530 | CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS" |
1531 | CONFIGURE_LDFLAGS="-pie $CONFIGURE_LDFLAGS" | |
2c674109 RH |
1532 | pie="yes" |
1533 | elif test "$pie" = "yes"; then | |
1534 | error_exit "PIE not available due to missing toolchain support" | |
1535 | else | |
1536 | echo "Disabling PIE due to missing toolchain support" | |
1537 | pie="no" | |
40d6444e AK |
1538 | fi |
1539 | ||
e6cbd751 RH |
1540 | # Detect support for PT_GNU_RELRO + DT_BIND_NOW. |
1541 | # The combination is known as "full relro", because .got.plt is read-only too. | |
1542 | if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then | |
1543 | QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS" | |
1544 | fi | |
1545 | ||
09dada40 PB |
1546 | ########################################## |
1547 | # __sync_fetch_and_and requires at least -march=i486. Many toolchains | |
1548 | # use i686 as default anyway, but for those that don't, an explicit | |
1549 | # specification is necessary | |
1550 | ||
1551 | if test "$cpu" = "i386"; then | |
1552 | cat > $TMPC << EOF | |
1553 | static int sfaa(int *ptr) | |
1554 | { | |
1555 | return __sync_fetch_and_and(ptr, 0); | |
1556 | } | |
1557 | ||
1558 | int main(void) | |
1559 | { | |
1560 | int val = 42; | |
1405b629 | 1561 | val = __sync_val_compare_and_swap(&val, 0, 1); |
09dada40 PB |
1562 | sfaa(&val); |
1563 | return val; | |
1564 | } | |
1565 | EOF | |
1566 | if ! compile_prog "" "" ; then | |
1567 | QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS" | |
1568 | fi | |
1569 | fi | |
1570 | ||
56267b62 PMD |
1571 | if test "$tcg" = "enabled"; then |
1572 | git_submodules="$git_submodules tests/fp/berkeley-testfloat-3" | |
1573 | git_submodules="$git_submodules tests/fp/berkeley-softfloat-3" | |
1574 | fi | |
1575 | ||
afb63ebd | 1576 | if test -z "${target_list+xxx}" ; then |
fdb75aef | 1577 | default_targets=yes |
d880a3ba | 1578 | for target in $default_target_list; do |
fdb75aef | 1579 | target_list="$target_list $target" |
d880a3ba PB |
1580 | done |
1581 | target_list="${target_list# }" | |
121afa9e | 1582 | else |
fdb75aef | 1583 | default_targets=no |
89138857 | 1584 | target_list=$(echo "$target_list" | sed -e 's/,/ /g') |
d880a3ba PB |
1585 | for target in $target_list; do |
1586 | # Check that we recognised the target name; this allows a more | |
1587 | # friendly error message than if we let it fall through. | |
1588 | case " $default_target_list " in | |
1589 | *" $target "*) | |
1590 | ;; | |
1591 | *) | |
1592 | error_exit "Unknown target name '$target'" | |
1593 | ;; | |
1594 | esac | |
d880a3ba | 1595 | done |
121afa9e | 1596 | fi |
25b48338 | 1597 | |
f55fe278 PB |
1598 | # see if system emulation was really requested |
1599 | case " $target_list " in | |
1600 | *"-softmmu "*) softmmu=yes | |
1601 | ;; | |
1602 | *) softmmu=no | |
1603 | ;; | |
1604 | esac | |
5327cf48 | 1605 | |
249247c9 JQ |
1606 | feature_not_found() { |
1607 | feature=$1 | |
21684af0 | 1608 | remedy=$2 |
249247c9 | 1609 | |
76ad07a4 | 1610 | error_exit "User requested feature $feature" \ |
21684af0 SS |
1611 | "configure was not able to find it." \ |
1612 | "$remedy" | |
249247c9 JQ |
1613 | } |
1614 | ||
7d13299d FB |
1615 | # --- |
1616 | # big/little endian test | |
1617 | cat > $TMPC << EOF | |
659eb157 | 1618 | #include <stdio.h> |
61cc919f MF |
1619 | short big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, }; |
1620 | short little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, }; | |
659eb157 TH |
1621 | int main(int argc, char *argv[]) |
1622 | { | |
1623 | return printf("%s %s\n", (char *)big_endian, (char *)little_endian); | |
7d13299d FB |
1624 | } |
1625 | EOF | |
1626 | ||
659eb157 TH |
1627 | if compile_prog ; then |
1628 | if strings -a $TMPE | grep -q BiGeNdIaN ; then | |
61cc919f | 1629 | bigendian="yes" |
659eb157 | 1630 | elif strings -a $TMPE | grep -q LiTtLeEnDiAn ; then |
61cc919f MF |
1631 | bigendian="no" |
1632 | else | |
1633 | echo big/little test failed | |
659eb157 | 1634 | exit 1 |
21d89f84 | 1635 | fi |
61cc919f MF |
1636 | else |
1637 | echo big/little test failed | |
659eb157 | 1638 | exit 1 |
7d13299d FB |
1639 | fi |
1640 | ||
299e6f19 PB |
1641 | ######################################### |
1642 | # vhost interdependencies and host support | |
1643 | ||
1644 | # vhost backends | |
eb9baecd SL |
1645 | if test "$vhost_user" = "yes" && test "$mingw32" = "yes"; then |
1646 | error_exit "vhost-user is not available on Windows" | |
299e6f19 | 1647 | fi |
108a6481 CL |
1648 | test "$vhost_vdpa" = "" && vhost_vdpa=$linux |
1649 | if test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then | |
1650 | error_exit "vhost-vdpa is only available on Linux" | |
1651 | fi | |
299e6f19 PB |
1652 | test "$vhost_kernel" = "" && vhost_kernel=$linux |
1653 | if test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then | |
1654 | error_exit "vhost-kernel is only available on Linux" | |
1655 | fi | |
1656 | ||
1657 | # vhost-kernel devices | |
1658 | test "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel | |
1659 | if test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then | |
1660 | error_exit "--enable-vhost-scsi requires --enable-vhost-kernel" | |
1661 | fi | |
1662 | test "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel | |
1663 | if test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then | |
1664 | error_exit "--enable-vhost-vsock requires --enable-vhost-kernel" | |
1665 | fi | |
1666 | ||
1667 | # vhost-user backends | |
1668 | test "$vhost_net_user" = "" && vhost_net_user=$vhost_user | |
1669 | if test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then | |
1670 | error_exit "--enable-vhost-net-user requires --enable-vhost-user" | |
1671 | fi | |
1672 | test "$vhost_crypto" = "" && vhost_crypto=$vhost_user | |
1673 | if test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then | |
1674 | error_exit "--enable-vhost-crypto requires --enable-vhost-user" | |
1675 | fi | |
98fc1ada DDAG |
1676 | test "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user |
1677 | if test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then | |
1678 | error_exit "--enable-vhost-user-fs requires --enable-vhost-user" | |
1679 | fi | |
108a6481 CL |
1680 | #vhost-vdpa backends |
1681 | test "$vhost_net_vdpa" = "" && vhost_net_vdpa=$vhost_vdpa | |
1682 | if test "$vhost_net_vdpa" = "yes" && test "$vhost_vdpa" = "no"; then | |
1683 | error_exit "--enable-vhost-net-vdpa requires --enable-vhost-vdpa" | |
1684 | fi | |
299e6f19 | 1685 | |
40bc0ca9 | 1686 | # OR the vhost-kernel, vhost-vdpa and vhost-user values for simplicity |
299e6f19 PB |
1687 | if test "$vhost_net" = ""; then |
1688 | test "$vhost_net_user" = "yes" && vhost_net=yes | |
40bc0ca9 | 1689 | test "$vhost_net_vdpa" = "yes" && vhost_net=yes |
299e6f19 PB |
1690 | test "$vhost_kernel" = "yes" && vhost_net=yes |
1691 | fi | |
1692 | ||
779ab5e3 SW |
1693 | ########################################## |
1694 | # pkg-config probe | |
1695 | ||
1696 | if ! has "$pkg_config_exe"; then | |
76ad07a4 | 1697 | error_exit "pkg-config binary '$pkg_config_exe' not found" |
779ab5e3 SW |
1698 | fi |
1699 | ||
e37630ca AL |
1700 | ########################################## |
1701 | # xen probe | |
1702 | ||
1badb709 | 1703 | if test "$xen" != "disabled" ; then |
c1cdd9d5 JG |
1704 | # Check whether Xen library path is specified via --extra-ldflags to avoid |
1705 | # overriding this setting with pkg-config output. If not, try pkg-config | |
1706 | # to obtain all needed flags. | |
1707 | ||
1708 | if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \ | |
1709 | $pkg_config --exists xencontrol ; then | |
1710 | xen_ctrl_version="$(printf '%d%02d%02d' \ | |
1711 | $($pkg_config --modversion xencontrol | sed 's/\./ /g') )" | |
1badb709 | 1712 | xen=enabled |
5b6a8f43 | 1713 | xen_pc="xencontrol xenstore xenforeignmemory xengnttab" |
c1cdd9d5 | 1714 | xen_pc="$xen_pc xenevtchn xendevicemodel" |
58ea9a7a AP |
1715 | if $pkg_config --exists xentoolcore; then |
1716 | xen_pc="$xen_pc xentoolcore" | |
1717 | fi | |
582ea95f MAL |
1718 | xen_cflags="$($pkg_config --cflags $xen_pc)" |
1719 | xen_libs="$($pkg_config --libs $xen_pc)" | |
c1cdd9d5 | 1720 | else |
d5b93ddf | 1721 | |
5b6a8f43 | 1722 | xen_libs="-lxenstore -lxenctrl" |
d9506cab | 1723 | xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn" |
50ced5b3 | 1724 | |
c1cdd9d5 JG |
1725 | # First we test whether Xen headers and libraries are available. |
1726 | # If no, we are done and there is no Xen support. | |
1727 | # If yes, more tests are run to detect the Xen version. | |
1728 | ||
1729 | # Xen (any) | |
1730 | cat > $TMPC <<EOF | |
e37630ca | 1731 | #include <xenctrl.h> |
50ced5b3 SW |
1732 | int main(void) { |
1733 | return 0; | |
1734 | } | |
1735 | EOF | |
c1cdd9d5 JG |
1736 | if ! compile_prog "" "$xen_libs" ; then |
1737 | # Xen not found | |
1badb709 | 1738 | if test "$xen" = "enabled" ; then |
c1cdd9d5 JG |
1739 | feature_not_found "xen" "Install xen devel" |
1740 | fi | |
1badb709 | 1741 | xen=disabled |
50ced5b3 | 1742 | |
c1cdd9d5 JG |
1743 | # Xen unstable |
1744 | elif | |
1745 | cat > $TMPC <<EOF && | |
2cbf8903 RL |
1746 | #undef XC_WANT_COMPAT_DEVICEMODEL_API |
1747 | #define __XEN_TOOLS__ | |
1748 | #include <xendevicemodel.h> | |
d3c49ebb | 1749 | #include <xenforeignmemory.h> |
2cbf8903 RL |
1750 | int main(void) { |
1751 | xendevicemodel_handle *xd; | |
d3c49ebb | 1752 | xenforeignmemory_handle *xfmem; |
2cbf8903 RL |
1753 | |
1754 | xd = xendevicemodel_open(0, 0); | |
1755 | xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0); | |
1756 | ||
d3c49ebb PD |
1757 | xfmem = xenforeignmemory_open(0, 0); |
1758 | xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0); | |
1759 | ||
2cbf8903 RL |
1760 | return 0; |
1761 | } | |
1762 | EOF | |
1763 | compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore" | |
1764 | then | |
1765 | xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore" | |
1766 | xen_ctrl_version=41100 | |
1badb709 | 1767 | xen=enabled |
2cbf8903 RL |
1768 | elif |
1769 | cat > $TMPC <<EOF && | |
5ba3d756 ID |
1770 | #undef XC_WANT_COMPAT_MAP_FOREIGN_API |
1771 | #include <xenforeignmemory.h> | |
58ea9a7a | 1772 | #include <xentoolcore.h> |
5ba3d756 ID |
1773 | int main(void) { |
1774 | xenforeignmemory_handle *xfmem; | |
1775 | ||
1776 | xfmem = xenforeignmemory_open(0, 0); | |
1777 | xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0); | |
58ea9a7a | 1778 | xentoolcore_restrict_all(0); |
5ba3d756 ID |
1779 | |
1780 | return 0; | |
1781 | } | |
1782 | EOF | |
58ea9a7a | 1783 | compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore" |
5ba3d756 | 1784 | then |
58ea9a7a | 1785 | xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore" |
5ba3d756 | 1786 | xen_ctrl_version=41000 |
1badb709 | 1787 | xen=enabled |
5ba3d756 ID |
1788 | elif |
1789 | cat > $TMPC <<EOF && | |
da8090cc PD |
1790 | #undef XC_WANT_COMPAT_DEVICEMODEL_API |
1791 | #define __XEN_TOOLS__ | |
1792 | #include <xendevicemodel.h> | |
1793 | int main(void) { | |
1794 | xendevicemodel_handle *xd; | |
1795 | ||
1796 | xd = xendevicemodel_open(0, 0); | |
1797 | xendevicemodel_close(xd); | |
50ced5b3 | 1798 | |
da8090cc PD |
1799 | return 0; |
1800 | } | |
1801 | EOF | |
c1cdd9d5 JG |
1802 | compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs" |
1803 | then | |
1804 | xen_stable_libs="-lxendevicemodel $xen_stable_libs" | |
1805 | xen_ctrl_version=40900 | |
1badb709 | 1806 | xen=enabled |
c1cdd9d5 JG |
1807 | elif |
1808 | cat > $TMPC <<EOF && | |
b6eb9b45 PS |
1809 | /* |
1810 | * If we have stable libs the we don't want the libxc compat | |
1811 | * layers, regardless of what CFLAGS we may have been given. | |
1812 | * | |
1813 | * Also, check if xengnttab_grant_copy_segment_t is defined and | |
1814 | * grant copy operation is implemented. | |
1815 | */ | |
1816 | #undef XC_WANT_COMPAT_EVTCHN_API | |
1817 | #undef XC_WANT_COMPAT_GNTTAB_API | |
1818 | #undef XC_WANT_COMPAT_MAP_FOREIGN_API | |
1819 | #include <xenctrl.h> | |
1820 | #include <xenstore.h> | |
1821 | #include <xenevtchn.h> | |
1822 | #include <xengnttab.h> | |
1823 | #include <xenforeignmemory.h> | |
1824 | #include <stdint.h> | |
1825 | #include <xen/hvm/hvm_info_table.h> | |
1826 | #if !defined(HVM_MAX_VCPUS) | |
1827 | # error HVM_MAX_VCPUS not defined | |
1828 | #endif | |
1829 | int main(void) { | |
1830 | xc_interface *xc = NULL; | |
1831 | xenforeignmemory_handle *xfmem; | |
1832 | xenevtchn_handle *xe; | |
1833 | xengnttab_handle *xg; | |
b6eb9b45 PS |
1834 | xengnttab_grant_copy_segment_t* seg = NULL; |
1835 | ||
1836 | xs_daemon_open(); | |
1837 | ||
1838 | xc = xc_interface_open(0, 0, 0); | |
1839 | xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); | |
1840 | xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); | |
1841 | xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); | |
1842 | xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL); | |
b6eb9b45 PS |
1843 | |
1844 | xfmem = xenforeignmemory_open(0, 0); | |
1845 | xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0); | |
1846 | ||
1847 | xe = xenevtchn_open(0, 0); | |
1848 | xenevtchn_fd(xe); | |
1849 | ||
1850 | xg = xengnttab_open(0, 0); | |
1851 | xengnttab_grant_copy(xg, 0, seg); | |
1852 | ||
1853 | return 0; | |
1854 | } | |
1855 | EOF | |
c1cdd9d5 JG |
1856 | compile_prog "" "$xen_libs $xen_stable_libs" |
1857 | then | |
1858 | xen_ctrl_version=40800 | |
1badb709 | 1859 | xen=enabled |
c1cdd9d5 JG |
1860 | elif |
1861 | cat > $TMPC <<EOF && | |
5eeb39c2 IC |
1862 | /* |
1863 | * If we have stable libs the we don't want the libxc compat | |
1864 | * layers, regardless of what CFLAGS we may have been given. | |
1865 | */ | |
1866 | #undef XC_WANT_COMPAT_EVTCHN_API | |
1867 | #undef XC_WANT_COMPAT_GNTTAB_API | |
1868 | #undef XC_WANT_COMPAT_MAP_FOREIGN_API | |
1869 | #include <xenctrl.h> | |
1870 | #include <xenstore.h> | |
1871 | #include <xenevtchn.h> | |
1872 | #include <xengnttab.h> | |
1873 | #include <xenforeignmemory.h> | |
1874 | #include <stdint.h> | |
1875 | #include <xen/hvm/hvm_info_table.h> | |
1876 | #if !defined(HVM_MAX_VCPUS) | |
1877 | # error HVM_MAX_VCPUS not defined | |
1878 | #endif | |
1879 | int main(void) { | |
1880 | xc_interface *xc = NULL; | |
1881 | xenforeignmemory_handle *xfmem; | |
1882 | xenevtchn_handle *xe; | |
1883 | xengnttab_handle *xg; | |
5eeb39c2 IC |
1884 | |
1885 | xs_daemon_open(); | |
1886 | ||
1887 | xc = xc_interface_open(0, 0, 0); | |
1888 | xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); | |
1889 | xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); | |
1890 | xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); | |
1891 | xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL); | |
5eeb39c2 IC |
1892 | |
1893 | xfmem = xenforeignmemory_open(0, 0); | |
1894 | xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0); | |
1895 | ||
1896 | xe = xenevtchn_open(0, 0); | |
1897 | xenevtchn_fd(xe); | |
1898 | ||
1899 | xg = xengnttab_open(0, 0); | |
1900 | xengnttab_map_grant_ref(xg, 0, 0, 0); | |
1901 | ||
1902 | return 0; | |
1903 | } | |
1904 | EOF | |
c1cdd9d5 JG |
1905 | compile_prog "" "$xen_libs $xen_stable_libs" |
1906 | then | |
1907 | xen_ctrl_version=40701 | |
1badb709 | 1908 | xen=enabled |
c1cdd9d5 JG |
1909 | |
1910 | # Xen 4.6 | |
1911 | elif | |
1912 | cat > $TMPC <<EOF && | |
cdadde39 | 1913 | #include <xenctrl.h> |
e108a3c1 | 1914 | #include <xenstore.h> |
d5b93ddf AP |
1915 | #include <stdint.h> |
1916 | #include <xen/hvm/hvm_info_table.h> | |
1917 | #if !defined(HVM_MAX_VCPUS) | |
1918 | # error HVM_MAX_VCPUS not defined | |
1919 | #endif | |
d8b441a3 JB |
1920 | int main(void) { |
1921 | xc_interface *xc; | |
1922 | xs_daemon_open(); | |
1923 | xc = xc_interface_open(0, 0, 0); | |
1924 | xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); | |
1925 | xc_gnttab_open(NULL, 0); | |
1926 | xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); | |
1927 | xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); | |
1928 | xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL); | |
20a544c7 | 1929 | xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0); |
d8b441a3 JB |
1930 | return 0; |
1931 | } | |
1932 | EOF | |
c1cdd9d5 JG |
1933 | compile_prog "" "$xen_libs" |
1934 | then | |
1935 | xen_ctrl_version=40600 | |
1badb709 | 1936 | xen=enabled |
c1cdd9d5 JG |
1937 | |
1938 | # Xen 4.5 | |
1939 | elif | |
1940 | cat > $TMPC <<EOF && | |
d8b441a3 JB |
1941 | #include <xenctrl.h> |
1942 | #include <xenstore.h> | |
1943 | #include <stdint.h> | |
1944 | #include <xen/hvm/hvm_info_table.h> | |
1945 | #if !defined(HVM_MAX_VCPUS) | |
1946 | # error HVM_MAX_VCPUS not defined | |
1947 | #endif | |
3996e85c PD |
1948 | int main(void) { |
1949 | xc_interface *xc; | |
1950 | xs_daemon_open(); | |
1951 | xc = xc_interface_open(0, 0, 0); | |
1952 | xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); | |
1953 | xc_gnttab_open(NULL, 0); | |
1954 | xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); | |
1955 | xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); | |
1956 | xc_hvm_create_ioreq_server(xc, 0, 0, NULL); | |
1957 | return 0; | |
1958 | } | |
1959 | EOF | |
c1cdd9d5 JG |
1960 | compile_prog "" "$xen_libs" |
1961 | then | |
1962 | xen_ctrl_version=40500 | |
1badb709 | 1963 | xen=enabled |
3996e85c | 1964 | |
c1cdd9d5 JG |
1965 | elif |
1966 | cat > $TMPC <<EOF && | |
3996e85c PD |
1967 | #include <xenctrl.h> |
1968 | #include <xenstore.h> | |
1969 | #include <stdint.h> | |
1970 | #include <xen/hvm/hvm_info_table.h> | |
1971 | #if !defined(HVM_MAX_VCPUS) | |
1972 | # error HVM_MAX_VCPUS not defined | |
1973 | #endif | |
8688e065 SS |
1974 | int main(void) { |
1975 | xc_interface *xc; | |
1976 | xs_daemon_open(); | |
1977 | xc = xc_interface_open(0, 0, 0); | |
1978 | xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); | |
1979 | xc_gnttab_open(NULL, 0); | |
1980 | xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); | |
1981 | xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); | |
1982 | return 0; | |
1983 | } | |
1984 | EOF | |
c1cdd9d5 JG |
1985 | compile_prog "" "$xen_libs" |
1986 | then | |
1987 | xen_ctrl_version=40200 | |
1badb709 | 1988 | xen=enabled |
8688e065 | 1989 | |
c1cdd9d5 | 1990 | else |
1badb709 | 1991 | if test "$xen" = "enabled" ; then |
c1cdd9d5 JG |
1992 | feature_not_found "xen (unsupported version)" \ |
1993 | "Install a supported xen (xen 4.2 or newer)" | |
1994 | fi | |
1badb709 | 1995 | xen=disabled |
fc321b4b | 1996 | fi |
d5b93ddf | 1997 | |
1badb709 | 1998 | if test "$xen" = enabled; then |
c1cdd9d5 | 1999 | if test $xen_ctrl_version -ge 40701 ; then |
582ea95f | 2000 | xen_libs="$xen_libs $xen_stable_libs " |
c1cdd9d5 | 2001 | fi |
5eeb39c2 | 2002 | fi |
d5b93ddf | 2003 | fi |
e37630ca AL |
2004 | fi |
2005 | ||
e18df141 AL |
2006 | ########################################## |
2007 | # glib support probe | |
a52d28af | 2008 | |
b4c6036f | 2009 | glib_req_ver=2.56 |
aa0d1f44 PB |
2010 | glib_modules=gthread-2.0 |
2011 | if test "$modules" = yes; then | |
a88afc64 | 2012 | glib_modules="$glib_modules gmodule-export-2.0" |
b906acac PB |
2013 | elif test "$plugins" = "yes"; then |
2014 | glib_modules="$glib_modules gmodule-no-export-2.0" | |
54cb65d8 | 2015 | fi |
e26110cf | 2016 | |
aa0d1f44 | 2017 | for i in $glib_modules; do |
e26110cf | 2018 | if $pkg_config --atleast-version=$glib_req_ver $i; then |
89138857 SW |
2019 | glib_cflags=$($pkg_config --cflags $i) |
2020 | glib_libs=$($pkg_config --libs $i) | |
e26110cf FZ |
2021 | else |
2022 | error_exit "glib-$glib_req_ver $i is required to compile QEMU" | |
2023 | fi | |
2024 | done | |
2025 | ||
215b0c2f PB |
2026 | # This workaround is required due to a bug in pkg-config file for glib as it |
2027 | # doesn't define GLIB_STATIC_COMPILATION for pkg-config --static | |
2028 | ||
2029 | if test "$static" = yes && test "$mingw32" = yes; then | |
2030 | glib_cflags="-DGLIB_STATIC_COMPILATION $glib_cflags" | |
2031 | fi | |
2032 | ||
977a82ab DB |
2033 | # Sanity check that the current size_t matches the |
2034 | # size that glib thinks it should be. This catches | |
2035 | # problems on multi-arch where people try to build | |
2036 | # 32-bit QEMU while pointing at 64-bit glib headers | |
2037 | cat > $TMPC <<EOF | |
2038 | #include <glib.h> | |
2039 | #include <unistd.h> | |
2040 | ||
2041 | #define QEMU_BUILD_BUG_ON(x) \ | |
2042 | typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused)); | |
2043 | ||
2044 | int main(void) { | |
2045 | QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T); | |
2046 | return 0; | |
2047 | } | |
2048 | EOF | |
2049 | ||
215b0c2f | 2050 | if ! compile_prog "$glib_cflags" "$glib_libs" ; then |
977a82ab DB |
2051 | error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\ |
2052 | "You probably need to set PKG_CONFIG_LIBDIR"\ | |
2053 | "to point to the right pkg-config files for your"\ | |
2054 | "build target" | |
2055 | fi | |
2056 | ||
9bda600b EB |
2057 | # Silence clang warnings triggered by glib < 2.57.2 |
2058 | cat > $TMPC << EOF | |
2059 | #include <glib.h> | |
2060 | typedef struct Foo { | |
2061 | int i; | |
2062 | } Foo; | |
2063 | static void foo_free(Foo *f) | |
2064 | { | |
2065 | g_free(f); | |
2066 | } | |
e0e7fe07 | 2067 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free) |
9bda600b EB |
2068 | int main(void) { return 0; } |
2069 | EOF | |
2070 | if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then | |
2071 | if cc_has_warning_flag "-Wno-unused-function"; then | |
2072 | glib_cflags="$glib_cflags -Wno-unused-function" | |
5770e8af | 2073 | CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -Wno-unused-function" |
9bda600b EB |
2074 | fi |
2075 | fi | |
2076 | ||
e26110cf FZ |
2077 | ########################################## |
2078 | # SHA command probe for modules | |
2079 | if test "$modules" = yes; then | |
2080 | shacmd_probe="sha1sum sha1 shasum" | |
2081 | for c in $shacmd_probe; do | |
8ccefb91 | 2082 | if has $c; then |
e26110cf FZ |
2083 | shacmd="$c" |
2084 | break | |
2085 | fi | |
2086 | done | |
2087 | if test "$shacmd" = ""; then | |
2088 | error_exit "one of the checksum commands is required to enable modules: $shacmd_probe" | |
2089 | fi | |
e18df141 AL |
2090 | fi |
2091 | ||
f652e6af AJ |
2092 | ########################################## |
2093 | # fdt probe | |
d599938a | 2094 | |
fbb4121d PB |
2095 | case "$fdt" in |
2096 | auto | enabled | internal) | |
2097 | # Simpler to always update submodule, even if not needed. | |
2d652f24 | 2098 | git_submodules="${git_submodules} dtc" |
fbb4121d PB |
2099 | ;; |
2100 | esac | |
f652e6af | 2101 | |
8ca80760 RH |
2102 | ########################################## |
2103 | # capstone | |
2104 | ||
e219c499 | 2105 | case "$capstone" in |
8b18cdbf RH |
2106 | auto | enabled | internal) |
2107 | # Simpler to always update submodule, even if not needed. | |
2d652f24 | 2108 | git_submodules="${git_submodules} capstone" |
e219c499 RH |
2109 | ;; |
2110 | esac | |
8ca80760 | 2111 | |
023367e6 | 2112 | ########################################## |
519175a2 | 2113 | # check and set a backend for coroutine |
d0e2fce5 | 2114 | |
7c2acc70 | 2115 | # We prefer ucontext, but it's not always possible. The fallback |
33c53c54 DB |
2116 | # is sigcontext. On Windows the only valid backend is the Windows |
2117 | # specific one. | |
7c2acc70 PM |
2118 | |
2119 | ucontext_works=no | |
2120 | if test "$darwin" != "yes"; then | |
2121 | cat > $TMPC << EOF | |
d0e2fce5 | 2122 | #include <ucontext.h> |
cdf84806 PM |
2123 | #ifdef __stub_makecontext |
2124 | #error Ignoring glibc stub makecontext which will always fail | |
2125 | #endif | |
75cafad7 | 2126 | int main(void) { makecontext(0, 0, 0); return 0; } |
d0e2fce5 | 2127 | EOF |
7c2acc70 PM |
2128 | if compile_prog "" "" ; then |
2129 | ucontext_works=yes | |
2130 | fi | |
2131 | fi | |
2132 | ||
2133 | if test "$coroutine" = ""; then | |
2134 | if test "$mingw32" = "yes"; then | |
2135 | coroutine=win32 | |
2136 | elif test "$ucontext_works" = "yes"; then | |
2137 | coroutine=ucontext | |
2138 | else | |
2139 | coroutine=sigaltstack | |
d0e2fce5 | 2140 | fi |
519175a2 | 2141 | else |
7c2acc70 PM |
2142 | case $coroutine in |
2143 | windows) | |
2144 | if test "$mingw32" != "yes"; then | |
2145 | error_exit "'windows' coroutine backend only valid for Windows" | |
2146 | fi | |
2147 | # Unfortunately the user visible backend name doesn't match the | |
2148 | # coroutine-*.c filename for this case, so we have to adjust it here. | |
2149 | coroutine=win32 | |
2150 | ;; | |
2151 | ucontext) | |
2152 | if test "$ucontext_works" != "yes"; then | |
2153 | feature_not_found "ucontext" | |
2154 | fi | |
2155 | ;; | |
33c53c54 | 2156 | sigaltstack) |
7c2acc70 PM |
2157 | if test "$mingw32" = "yes"; then |
2158 | error_exit "only the 'windows' coroutine backend is valid for Windows" | |
2159 | fi | |
2160 | ;; | |
2161 | *) | |
2162 | error_exit "unknown coroutine backend $coroutine" | |
2163 | ;; | |
2164 | esac | |
d0e2fce5 AK |
2165 | fi |
2166 | ||
1e4f6065 DB |
2167 | ################################################## |
2168 | # SafeStack | |
2169 | ||
2170 | ||
2171 | if test "$safe_stack" = "yes"; then | |
2172 | cat > $TMPC << EOF | |
2173 | int main(int argc, char *argv[]) | |
2174 | { | |
2175 | #if ! __has_feature(safe_stack) | |
2176 | #error SafeStack Disabled | |
2177 | #endif | |
2178 | return 0; | |
2179 | } | |
2180 | EOF | |
2181 | flag="-fsanitize=safe-stack" | |
2182 | # Check that safe-stack is supported and enabled. | |
2183 | if compile_prog "-Werror $flag" "$flag"; then | |
2184 | # Flag needed both at compilation and at linking | |
2185 | QEMU_CFLAGS="$QEMU_CFLAGS $flag" | |
2186 | QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" | |
2187 | else | |
2188 | error_exit "SafeStack not supported by your compiler" | |
2189 | fi | |
2190 | if test "$coroutine" != "ucontext"; then | |
2191 | error_exit "SafeStack is only supported by the coroutine backend ucontext" | |
2192 | fi | |
2193 | else | |
2194 | cat > $TMPC << EOF | |
2195 | int main(int argc, char *argv[]) | |
2196 | { | |
2197 | #if defined(__has_feature) | |
2198 | #if __has_feature(safe_stack) | |
2199 | #error SafeStack Enabled | |
2200 | #endif | |
2201 | #endif | |
2202 | return 0; | |
2203 | } | |
2204 | EOF | |
2205 | if test "$safe_stack" = "no"; then | |
2206 | # Make sure that safe-stack is disabled | |
2207 | if ! compile_prog "-Werror" ""; then | |
2208 | # SafeStack was already enabled, try to explicitly remove the feature | |
2209 | flag="-fno-sanitize=safe-stack" | |
2210 | if ! compile_prog "-Werror $flag" "$flag"; then | |
2211 | error_exit "Configure cannot disable SafeStack" | |
2212 | fi | |
2213 | QEMU_CFLAGS="$QEMU_CFLAGS $flag" | |
2214 | QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" | |
2215 | fi | |
2216 | else # "$safe_stack" = "" | |
2217 | # Set safe_stack to yes or no based on pre-existing flags | |
2218 | if compile_prog "-Werror" ""; then | |
2219 | safe_stack="no" | |
2220 | else | |
2221 | safe_stack="yes" | |
2222 | if test "$coroutine" != "ucontext"; then | |
2223 | error_exit "SafeStack is only supported by the coroutine backend ucontext" | |
2224 | fi | |
2225 | fi | |
2226 | fi | |
2227 | fi | |
7d992e4d | 2228 | |
fd0e6053 JS |
2229 | ######################################## |
2230 | # check if ccache is interfering with | |
2231 | # semantic analysis of macros | |
2232 | ||
5e4dfd3d | 2233 | unset CCACHE_CPP2 |
fd0e6053 JS |
2234 | ccache_cpp2=no |
2235 | cat > $TMPC << EOF | |
2236 | static const int Z = 1; | |
2237 | #define fn() ({ Z; }) | |
2238 | #define TAUT(X) ((X) == Z) | |
2239 | #define PAREN(X, Y) (X == Y) | |
2240 | #define ID(X) (X) | |
2241 | int main(int argc, char *argv[]) | |
2242 | { | |
2243 | int x = 0, y = 0; | |
2244 | x = ID(x); | |
2245 | x = fn(); | |
2246 | fn(); | |
2247 | if (PAREN(x, y)) return 0; | |
2248 | if (TAUT(Z)) return 0; | |
2249 | return 0; | |
2250 | } | |
2251 | EOF | |
2252 | ||
2253 | if ! compile_object "-Werror"; then | |
2254 | ccache_cpp2=yes | |
2255 | fi | |
2256 | ||
b553a042 JS |
2257 | ################################################# |
2258 | # clang does not support glibc + FORTIFY_SOURCE. | |
2259 | ||
2260 | if test "$fortify_source" != "no"; then | |
2261 | if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then | |
2262 | fortify_source="no"; | |
e189091f | 2263 | elif test -n "$cxx" && has $cxx && |
cfcc7c14 | 2264 | echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then |
b553a042 JS |
2265 | fortify_source="no"; |
2266 | else | |
2267 | fortify_source="yes" | |
2268 | fi | |
2269 | fi | |
2270 | ||
247724cb MAL |
2271 | ########################################## |
2272 | # checks for sanitizers | |
2273 | ||
247724cb MAL |
2274 | have_asan=no |
2275 | have_ubsan=no | |
d83414e1 MAL |
2276 | have_asan_iface_h=no |
2277 | have_asan_iface_fiber=no | |
247724cb MAL |
2278 | |
2279 | if test "$sanitizers" = "yes" ; then | |
b9f44da2 | 2280 | write_c_skeleton |
247724cb MAL |
2281 | if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then |
2282 | have_asan=yes | |
2283 | fi | |
b9f44da2 MAL |
2284 | |
2285 | # we could use a simple skeleton for flags checks, but this also | |
2286 | # detect the static linking issue of ubsan, see also: | |
2287 | # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285 | |
2288 | cat > $TMPC << EOF | |
2289 | #include <stdlib.h> | |
2290 | int main(void) { | |
2291 | void *tmp = malloc(10); | |
f2dfe54c LB |
2292 | if (tmp != NULL) { |
2293 | return *(int *)(tmp + 2); | |
2294 | } | |
d1abf3fc | 2295 | return 1; |
b9f44da2 MAL |
2296 | } |
2297 | EOF | |
247724cb MAL |
2298 | if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then |
2299 | have_ubsan=yes | |
2300 | fi | |
d83414e1 MAL |
2301 | |
2302 | if check_include "sanitizer/asan_interface.h" ; then | |
2303 | have_asan_iface_h=yes | |
2304 | fi | |
2305 | ||
2306 | cat > $TMPC << EOF | |
2307 | #include <sanitizer/asan_interface.h> | |
2308 | int main(void) { | |
2309 | __sanitizer_start_switch_fiber(0, 0, 0); | |
2310 | return 0; | |
2311 | } | |
2312 | EOF | |
2313 | if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then | |
2314 | have_asan_iface_fiber=yes | |
2315 | fi | |
247724cb MAL |
2316 | fi |
2317 | ||
0aebab04 LY |
2318 | # Thread sanitizer is, for now, much noisier than the other sanitizers; |
2319 | # keep it separate until that is not the case. | |
2320 | if test "$tsan" = "yes" && test "$sanitizers" = "yes"; then | |
2321 | error_exit "TSAN is not supported with other sanitiziers." | |
2322 | fi | |
2323 | have_tsan=no | |
2324 | have_tsan_iface_fiber=no | |
2325 | if test "$tsan" = "yes" ; then | |
2326 | write_c_skeleton | |
2327 | if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then | |
2328 | have_tsan=yes | |
2329 | fi | |
2330 | cat > $TMPC << EOF | |
2331 | #include <sanitizer/tsan_interface.h> | |
2332 | int main(void) { | |
2333 | __tsan_create_fiber(0); | |
2334 | return 0; | |
2335 | } | |
2336 | EOF | |
2337 | if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then | |
2338 | have_tsan_iface_fiber=yes | |
2339 | fi | |
2340 | fi | |
2341 | ||
675b9b53 MAL |
2342 | ########################################## |
2343 | # check for slirp | |
2344 | ||
2345 | case "$slirp" in | |
4d34a86b PB |
2346 | auto | enabled | internal) |
2347 | # Simpler to always update submodule, even if not needed. | |
2d652f24 | 2348 | git_submodules="${git_submodules} slirp" |
675b9b53 MAL |
2349 | ;; |
2350 | esac | |
2351 | ||
7e24e92a | 2352 | ########################################## |
e86ecd4b JQ |
2353 | # End of CC checks |
2354 | # After here, no more $cc or $ld runs | |
2355 | ||
d83414e1 MAL |
2356 | write_c_skeleton |
2357 | ||
df42fa7d | 2358 | if test "$fortify_source" = "yes" ; then |
086d5f75 PB |
2359 | QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS" |
2360 | debug=no | |
2361 | fi | |
086d5f75 PB |
2362 | |
2363 | case "$ARCH" in | |
2364 | alpha) | |
2365 | # Ensure there's only a single GP | |
2366 | QEMU_CFLAGS="-msmall-data $QEMU_CFLAGS" | |
2367 | ;; | |
2368 | esac | |
2369 | ||
247724cb | 2370 | if test "$have_asan" = "yes"; then |
db5adeaa PB |
2371 | QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS" |
2372 | QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS" | |
d83414e1 MAL |
2373 | if test "$have_asan_iface_h" = "no" ; then |
2374 | echo "ASAN build enabled, but ASAN header missing." \ | |
2375 | "Without code annotation, the report may be inferior." | |
2376 | elif test "$have_asan_iface_fiber" = "no" ; then | |
2377 | echo "ASAN build enabled, but ASAN header is too old." \ | |
2378 | "Without code annotation, the report may be inferior." | |
2379 | fi | |
247724cb | 2380 | fi |
0aebab04 LY |
2381 | if test "$have_tsan" = "yes" ; then |
2382 | if test "$have_tsan_iface_fiber" = "yes" ; then | |
2383 | QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS" | |
2384 | QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS" | |
2385 | else | |
2386 | error_exit "Cannot enable TSAN due to missing fiber annotation interface." | |
2387 | fi | |
2388 | elif test "$tsan" = "yes" ; then | |
2389 | error_exit "Cannot enable TSAN due to missing sanitize thread interface." | |
2390 | fi | |
247724cb | 2391 | if test "$have_ubsan" = "yes"; then |
db5adeaa PB |
2392 | QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS" |
2393 | QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS" | |
247724cb MAL |
2394 | fi |
2395 | ||
3efac6eb | 2396 | ########################################## |
3efac6eb | 2397 | |
0aebab04 LY |
2398 | # Exclude --warn-common with TSan to suppress warnings from the TSan libraries. |
2399 | if test "$solaris" = "no" && test "$tsan" = "no"; then | |
e86ecd4b | 2400 | if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then |
db5adeaa | 2401 | QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS" |
e86ecd4b JQ |
2402 | fi |
2403 | fi | |
2404 | ||
952afb71 BS |
2405 | # Use ASLR, no-SEH and DEP if available |
2406 | if test "$mingw32" = "yes" ; then | |
cb8baa77 MCA |
2407 | flags="--no-seh --nxcompat" |
2408 | ||
2409 | # Disable ASLR for debug builds to allow debugging with gdb | |
2410 | if test "$debug" = "no" ; then | |
2411 | flags="--dynamicbase $flags" | |
2412 | fi | |
2413 | ||
2414 | for flag in $flags; do | |
e9a3591f | 2415 | if ld_has $flag ; then |
db5adeaa | 2416 | QEMU_LDFLAGS="-Wl,$flag $QEMU_LDFLAGS" |
952afb71 BS |
2417 | fi |
2418 | done | |
2419 | fi | |
2420 | ||
b846ab7c | 2421 | # Guest agent Windows MSI package |
9d6bc27b | 2422 | |
b846ab7c PB |
2423 | if test "$QEMU_GA_MANUFACTURER" = ""; then |
2424 | QEMU_GA_MANUFACTURER=QEMU | |
9d6bc27b | 2425 | fi |
b846ab7c PB |
2426 | if test "$QEMU_GA_DISTRO" = ""; then |
2427 | QEMU_GA_DISTRO=Linux | |
9d6bc27b | 2428 | fi |
b846ab7c PB |
2429 | if test "$QEMU_GA_VERSION" = ""; then |
2430 | QEMU_GA_VERSION=$(cat $source_path/VERSION) | |
2431 | fi | |
2432 | ||
6e444209 | 2433 | QEMU_GA_MSI_MINGW_BIN_PATH="$($pkg_config --variable=prefix glib-2.0)/bin" |
9d6bc27b | 2434 | |
ca35f780 PB |
2435 | # Mac OS X ships with a broken assembler |
2436 | roms= | |
e633a5c6 | 2437 | if { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \ |
ba7c60c2 PB |
2438 | test "$targetos" != "darwin" && test "$targetos" != "sunos" && \ |
2439 | test "$targetos" != "haiku" && test "$softmmu" = yes ; then | |
e57218b6 | 2440 | # Different host OS linkers have different ideas about the name of the ELF |
c65d5e4e BS |
2441 | # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd |
2442 | # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe. | |
2443 | for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do | |
e57218b6 PM |
2444 | if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then |
2445 | ld_i386_emulation="$emu" | |
2446 | roms="optionrom" | |
2447 | break | |
2448 | fi | |
2449 | done | |
ca35f780 | 2450 | fi |
ca35f780 | 2451 | |
2e33c3f8 | 2452 | # Only build s390-ccw bios if we're on s390x and the compiler has -march=z900 |
a5b2afd5 | 2453 | # or -march=z10 (which is the lowest architecture level that Clang supports) |
9933c305 | 2454 | if test "$cpu" = "s390x" ; then |
2e33c3f8 | 2455 | write_c_skeleton |
a5b2afd5 TH |
2456 | compile_prog "-march=z900" "" |
2457 | has_z900=$? | |
3af448b3 | 2458 | if [ $has_z900 = 0 ] || compile_object "-march=z10 -msoft-float -Werror"; then |
a5b2afd5 TH |
2459 | if [ $has_z900 != 0 ]; then |
2460 | echo "WARNING: Your compiler does not support the z900!" | |
2461 | echo " The s390-ccw bios will only work with guest CPUs >= z10." | |
2462 | fi | |
2e33c3f8 | 2463 | roms="$roms s390-ccw" |
1ef6bfc2 PMD |
2464 | # SLOF is required for building the s390-ccw firmware on s390x, |
2465 | # since it is using the libnet code from SLOF for network booting. | |
2d652f24 | 2466 | git_submodules="${git_submodules} roms/SLOF" |
2e33c3f8 | 2467 | fi |
9933c305 CB |
2468 | fi |
2469 | ||
11cde1c8 BD |
2470 | # Check that the C++ compiler exists and works with the C compiler. |
2471 | # All the QEMU_CXXFLAGS are based on QEMU_CFLAGS. Keep this at the end to don't miss any other that could be added. | |
2472 | if has $cxx; then | |
2473 | cat > $TMPC <<EOF | |
2474 | int c_function(void); | |
2475 | int main(void) { return c_function(); } | |
2476 | EOF | |
2477 | ||
2478 | compile_object | |
2479 | ||
2480 | cat > $TMPCXX <<EOF | |
2481 | extern "C" { | |
2482 | int c_function(void); | |
2483 | } | |
2484 | int c_function(void) { return 42; } | |
2485 | EOF | |
2486 | ||
2487 | update_cxxflags | |
2488 | ||
a2866660 | 2489 | if do_cxx $CXXFLAGS $EXTRA_CXXFLAGS $CONFIGURE_CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then |
11cde1c8 BD |
2490 | # C++ compiler $cxx works ok with C compiler $cc |
2491 | : | |
2492 | else | |
2493 | echo "C++ compiler $cxx does not work with C compiler $cc" | |
2494 | echo "Disabling C++ specific optional code" | |
2495 | cxx= | |
2496 | fi | |
2497 | else | |
2498 | echo "No C++ compiler available; disabling C++ specific optional code" | |
2499 | cxx= | |
2500 | fi | |
2501 | ||
7d7dbf9d DS |
2502 | if !(GIT="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then |
2503 | exit 1 | |
5d91a2ed | 2504 | fi |
5d91a2ed | 2505 | |
98ec69ac | 2506 | config_host_mak="config-host.mak" |
98ec69ac | 2507 | |
98ec69ac | 2508 | echo "# Automatically generated by configure - do not modify" > $config_host_mak |
98ec69ac | 2509 | echo >> $config_host_mak |
98ec69ac | 2510 | |
e6c3b0f7 | 2511 | echo all: >> $config_host_mak |
cc84d63a | 2512 | echo "GIT=$git" >> $config_host_mak |
aef45d51 | 2513 | echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak |
7d7dbf9d | 2514 | echo "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak |
804edf29 | 2515 | |
f8393946 | 2516 | if test "$debug_tcg" = "yes" ; then |
2358a494 | 2517 | echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak |
f8393946 | 2518 | fi |
67b915a5 | 2519 | if test "$mingw32" = "yes" ; then |
98ec69ac | 2520 | echo "CONFIG_WIN32=y" >> $config_host_mak |
6e444209 | 2521 | echo "QEMU_GA_MSI_MINGW_BIN_PATH=${QEMU_GA_MSI_MINGW_BIN_PATH}" >> $config_host_mak |
b846ab7c PB |
2522 | echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak |
2523 | echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak | |
2524 | echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak | |
210fa556 | 2525 | else |
35f4df27 | 2526 | echo "CONFIG_POSIX=y" >> $config_host_mak |
dffcb71c MM |
2527 | fi |
2528 | ||
2529 | if test "$linux" = "yes" ; then | |
2530 | echo "CONFIG_LINUX=y" >> $config_host_mak | |
67b915a5 | 2531 | fi |
128ab2ff | 2532 | |
83fb7adf | 2533 | if test "$darwin" = "yes" ; then |
98ec69ac | 2534 | echo "CONFIG_DARWIN=y" >> $config_host_mak |
83fb7adf | 2535 | fi |
b29fe3ed | 2536 | |
ec530c81 | 2537 | if test "$solaris" = "yes" ; then |
98ec69ac | 2538 | echo "CONFIG_SOLARIS=y" >> $config_host_mak |
ec530c81 | 2539 | fi |
97a847bc | 2540 | if test "$static" = "yes" ; then |
98ec69ac | 2541 | echo "CONFIG_STATIC=y" >> $config_host_mak |
7d13299d | 2542 | fi |
b64ec4e4 FZ |
2543 | echo "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak |
2544 | echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak | |
89138857 | 2545 | qemu_version=$(head $source_path/VERSION) |
2358a494 | 2546 | echo "PKGVERSION=$pkgversion" >>$config_host_mak |
98ec69ac | 2547 | echo "SRC_PATH=$source_path" >> $config_host_mak |
2b1f35b9 | 2548 | echo "TARGET_DIRS=$target_list" >> $config_host_mak |
17969268 | 2549 | if test "$modules" = "yes"; then |
e26110cf FZ |
2550 | # $shacmd can generate a hash started with digit, which the compiler doesn't |
2551 | # like as an symbol. So prefix it with an underscore | |
89138857 | 2552 | echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak |
17969268 FZ |
2553 | echo "CONFIG_MODULES=y" >> $config_host_mak |
2554 | fi | |
a1c5e949 | 2555 | echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak |
277abf15 | 2556 | |
1badb709 | 2557 | if test "$xen" = "enabled" ; then |
6dbd588a | 2558 | echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak |
d5b93ddf | 2559 | echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak |
582ea95f MAL |
2560 | echo "XEN_CFLAGS=$xen_cflags" >> $config_host_mak |
2561 | echo "XEN_LIBS=$xen_libs" >> $config_host_mak | |
e37630ca | 2562 | fi |
5e9be92d NB |
2563 | if test "$vhost_scsi" = "yes" ; then |
2564 | echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak | |
2565 | fi | |
af3bba76 PB |
2566 | if test "$vhost_net" = "yes" ; then |
2567 | echo "CONFIG_VHOST_NET=y" >> $config_host_mak | |
2568 | fi | |
2569 | if test "$vhost_net_user" = "yes" ; then | |
56f41de7 | 2570 | echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak |
03ce5744 | 2571 | fi |
108a6481 CL |
2572 | if test "$vhost_net_vdpa" = "yes" ; then |
2573 | echo "CONFIG_VHOST_NET_VDPA=y" >> $config_host_mak | |
2574 | fi | |
042cea27 GA |
2575 | if test "$vhost_crypto" = "yes" ; then |
2576 | echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak | |
2577 | fi | |
fc0b9b0e SH |
2578 | if test "$vhost_vsock" = "yes" ; then |
2579 | echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak | |
5fe97d88 SG |
2580 | if test "$vhost_user" = "yes" ; then |
2581 | echo "CONFIG_VHOST_USER_VSOCK=y" >> $config_host_mak | |
2582 | fi | |
fc0b9b0e | 2583 | fi |
299e6f19 PB |
2584 | if test "$vhost_kernel" = "yes" ; then |
2585 | echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak | |
2586 | fi | |
e6a74868 MAL |
2587 | if test "$vhost_user" = "yes" ; then |
2588 | echo "CONFIG_VHOST_USER=y" >> $config_host_mak | |
2589 | fi | |
108a6481 CL |
2590 | if test "$vhost_vdpa" = "yes" ; then |
2591 | echo "CONFIG_VHOST_VDPA=y" >> $config_host_mak | |
2592 | fi | |
98fc1ada DDAG |
2593 | if test "$vhost_user_fs" = "yes" ; then |
2594 | echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak | |
2595 | fi | |
58d3f3ff | 2596 | |
83fb7adf | 2597 | # XXX: suppress that |
7d3505c5 | 2598 | if [ "$bsd" = "yes" ] ; then |
2358a494 | 2599 | echo "CONFIG_BSD=y" >> $config_host_mak |
7d3505c5 FB |
2600 | fi |
2601 | ||
7c2acc70 | 2602 | echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak |
7d992e4d | 2603 | |
d83414e1 MAL |
2604 | if test "$have_asan_iface_fiber" = "yes" ; then |
2605 | echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak | |
2606 | fi | |
2607 | ||
0aebab04 LY |
2608 | if test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then |
2609 | echo "CONFIG_TSAN=y" >> $config_host_mak | |
2610 | fi | |
2611 | ||
40e8c6f4 AB |
2612 | if test "$plugins" = "yes" ; then |
2613 | echo "CONFIG_PLUGIN=y" >> $config_host_mak | |
40e8c6f4 AB |
2614 | fi |
2615 | ||
b1863ccc AB |
2616 | if test -n "$gdb_bin"; then |
2617 | gdb_version=$($gdb_bin --version | head -n 1) | |
d6a66c81 | 2618 | if version_ge ${gdb_version##* } 9.1; then |
b1863ccc AB |
2619 | echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak |
2620 | fi | |
f48e590a AB |
2621 | fi |
2622 | ||
98ec69ac | 2623 | echo "ROMS=$roms" >> $config_host_mak |
804edf29 | 2624 | echo "MAKE=$make" >> $config_host_mak |
c886edfb | 2625 | echo "PYTHON=$python" >> $config_host_mak |
39d87c8c | 2626 | echo "GENISOIMAGE=$genisoimage" >> $config_host_mak |
a5665051 | 2627 | echo "MESON=$meson" >> $config_host_mak |
09e93326 | 2628 | echo "NINJA=$ninja" >> $config_host_mak |
804edf29 | 2629 | echo "CC=$cc" >> $config_host_mak |
804edf29 | 2630 | echo "AR=$ar" >> $config_host_mak |
cdbd727c | 2631 | echo "AS=$as" >> $config_host_mak |
5f6f0e27 | 2632 | echo "CCAS=$ccas" >> $config_host_mak |
3dd46c78 | 2633 | echo "CPP=$cpp" >> $config_host_mak |
804edf29 JQ |
2634 | echo "OBJCOPY=$objcopy" >> $config_host_mak |
2635 | echo "LD=$ld" >> $config_host_mak | |
46eef33b | 2636 | echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak |
a558ee17 | 2637 | echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak |
11cde1c8 | 2638 | echo "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak |
4cb37d11 | 2639 | echo "QEMU_OBJCFLAGS=$QEMU_OBJCFLAGS" >> $config_host_mak |
a81df1b6 PB |
2640 | echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak |
2641 | echo "GLIB_LIBS=$glib_libs" >> $config_host_mak | |
d83acfd0 | 2642 | echo "GLIB_VERSION=$(pkg-config --modversion glib-2.0)" >> $config_host_mak |
8a99e9a3 | 2643 | echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak |
e57218b6 | 2644 | echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak |
a70248db | 2645 | echo "STRIP=$strip" >> $config_host_mak |
804edf29 | 2646 | echo "EXESUF=$EXESUF" >> $config_host_mak |
804edf29 | 2647 | |
6efd7517 PM |
2648 | # use included Linux headers |
2649 | if test "$linux" = "yes" ; then | |
a307beb6 | 2650 | mkdir -p linux-headers |
6efd7517 | 2651 | case "$cpu" in |
4da270be | 2652 | i386|x86_64) |
08312a63 | 2653 | linux_arch=x86 |
6efd7517 | 2654 | ;; |
d8ff892d | 2655 | ppc|ppc64) |
08312a63 | 2656 | linux_arch=powerpc |
6efd7517 PM |
2657 | ;; |
2658 | s390x) | |
08312a63 PM |
2659 | linux_arch=s390 |
2660 | ;; | |
1f080313 CF |
2661 | aarch64) |
2662 | linux_arch=arm64 | |
2663 | ;; | |
dfcf900b WX |
2664 | loongarch*) |
2665 | linux_arch=loongarch | |
2666 | ;; | |
222e7d11 SL |
2667 | mips64) |
2668 | linux_arch=mips | |
2669 | ;; | |
08312a63 PM |
2670 | *) |
2671 | # For most CPUs the kernel architecture name and QEMU CPU name match. | |
2672 | linux_arch="$cpu" | |
6efd7517 PM |
2673 | ;; |
2674 | esac | |
08312a63 PM |
2675 | # For non-KVM architectures we will not have asm headers |
2676 | if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then | |
2677 | symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm | |
2678 | fi | |
6efd7517 PM |
2679 | fi |
2680 | ||
1d14ffa9 | 2681 | for target in $target_list; do |
fdb75aef | 2682 | target_dir="$target" |
57a93f16 | 2683 | target_name=$(echo $target | cut -d '-' -f 1)$EXESUF |
fdb75aef PB |
2684 | mkdir -p $target_dir |
2685 | case $target in | |
2686 | *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;; | |
2687 | *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;; | |
2688 | esac | |
2689 | done | |
7d13299d | 2690 | |
765686d6 | 2691 | echo "CONFIG_QEMU_INTERP_PREFIX=$interp_prefix" | sed 's/%M/@0@/' >> $config_host_mak |
fdb75aef PB |
2692 | if test "$default_targets" = "yes"; then |
2693 | echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak | |
2694 | fi | |
a540f158 | 2695 | |
fd0e6053 JS |
2696 | if test "$ccache_cpp2" = "yes"; then |
2697 | echo "export CCACHE_CPP2=y" >> $config_host_mak | |
2698 | fi | |
2699 | ||
1e4f6065 DB |
2700 | if test "$safe_stack" = "yes"; then |
2701 | echo "CONFIG_SAFESTACK=y" >> $config_host_mak | |
2702 | fi | |
2703 | ||
e29e5c6e | 2704 | # If we're using a separate build tree, set it up now. |
e29e5c6e PM |
2705 | # LINKS are things to symlink back into the source tree |
2706 | # (these can be both files and directories). | |
2707 | # Caution: do not add files or directories here using wildcards. This | |
2708 | # will result in problems later if a new file matching the wildcard is | |
2709 | # added to the source tree -- nothing will cause configure to be rerun | |
2710 | # so the build tree will be missing the link back to the new file, and | |
2711 | # tests might fail. Prefer to keep the relevant files in their own | |
2712 | # directory and symlink the directory instead. | |
2038f8c8 | 2713 | LINKS="Makefile" |
3941996b | 2714 | LINKS="$LINKS tests/tcg/Makefile.target" |
ddcf607f | 2715 | LINKS="$LINKS pc-bios/optionrom/Makefile" |
e29e5c6e | 2716 | LINKS="$LINKS pc-bios/s390-ccw/Makefile" |
e29e5c6e | 2717 | LINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit |
bbbd9b6e | 2718 | LINKS="$LINKS tests/avocado tests/data" |
39950353 | 2719 | LINKS="$LINKS tests/qemu-iotests/check" |
8f8fd9ed | 2720 | LINKS="$LINKS python" |
c17a386b | 2721 | LINKS="$LINKS contrib/plugins/Makefile " |
753d11f2 RH |
2722 | for bios_file in \ |
2723 | $source_path/pc-bios/*.bin \ | |
3a631b8e | 2724 | $source_path/pc-bios/*.elf \ |
225a9ab8 | 2725 | $source_path/pc-bios/*.lid \ |
753d11f2 RH |
2726 | $source_path/pc-bios/*.rom \ |
2727 | $source_path/pc-bios/*.dtb \ | |
e89e33e1 | 2728 | $source_path/pc-bios/*.img \ |
753d11f2 | 2729 | $source_path/pc-bios/openbios-* \ |
4e73c781 | 2730 | $source_path/pc-bios/u-boot.* \ |
cd946e5c JA |
2731 | $source_path/pc-bios/palcode-* \ |
2732 | $source_path/pc-bios/qemu_vga.ndrv | |
2733 | ||
753d11f2 | 2734 | do |
e29e5c6e | 2735 | LINKS="$LINKS pc-bios/$(basename $bios_file)" |
d1807a4f | 2736 | done |
e29e5c6e | 2737 | for f in $LINKS ; do |
0f4d8894 | 2738 | if [ -e "$source_path/$f" ]; then |
5dce7b8d | 2739 | mkdir -p `dirname ./$f` |
f9245e10 PM |
2740 | symlink "$source_path/$f" "$f" |
2741 | fi | |
d1807a4f | 2742 | done |
1ad2134f | 2743 | |
2038f8c8 PB |
2744 | (for i in $cross_cc_vars; do |
2745 | export $i | |
2746 | done | |
544f4a25 | 2747 | export target_list source_path use_containers cpu host_cc |
2038f8c8 PB |
2748 | $source_path/tests/tcg/configure.sh) |
2749 | ||
98409991 HK |
2750 | config_mak=pc-bios/optionrom/config.mak |
2751 | echo "# Automatically generated by configure - do not modify" > $config_mak | |
2752 | echo "TOPSRC_DIR=$source_path" >> $config_mak | |
2753 | ||
a5665051 | 2754 | if test "$skip_meson" = no; then |
d77e90fa PB |
2755 | cross="config-meson.cross.new" |
2756 | meson_quote() { | |
ac7ebcc5 | 2757 | test $# = 0 && return |
47b30835 | 2758 | echo "'$(echo $* | sed "s/ /','/g")'" |
d77e90fa PB |
2759 | } |
2760 | ||
2761 | echo "# Automatically generated by configure - do not modify" > $cross | |
2762 | echo "[properties]" >> $cross | |
d1d5e9ee AB |
2763 | |
2764 | # unroll any custom device configs | |
11bdcfcd AB |
2765 | for a in $device_archs; do |
2766 | eval "c=\$devices_${a}" | |
2767 | echo "${a}-softmmu = '$c'" >> $cross | |
2768 | done | |
d1d5e9ee | 2769 | |
d77e90fa PB |
2770 | test -z "$cxx" && echo "link_language = 'c'" >> $cross |
2771 | echo "[built-in options]" >> $cross | |
a2866660 PB |
2772 | echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross |
2773 | echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross | |
e910c7d9 | 2774 | test -n "$objcc" && echo "objc_args = [$(meson_quote $OBJCFLAGS $EXTRA_OBJCFLAGS)]" >> $cross |
a2866660 PB |
2775 | echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross |
2776 | echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross | |
d77e90fa | 2777 | echo "[binaries]" >> $cross |
4dba2789 PB |
2778 | echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross |
2779 | test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross | |
2780 | test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross | |
d77e90fa PB |
2781 | echo "ar = [$(meson_quote $ar)]" >> $cross |
2782 | echo "nm = [$(meson_quote $nm)]" >> $cross | |
2783 | echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross | |
2784 | echo "ranlib = [$(meson_quote $ranlib)]" >> $cross | |
2785 | if has $sdl2_config; then | |
2786 | echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross | |
2787 | fi | |
2788 | echo "strip = [$(meson_quote $strip)]" >> $cross | |
2789 | echo "windres = [$(meson_quote $windres)]" >> $cross | |
2790 | if test "$cross_compile" = "yes"; then | |
fc929892 | 2791 | cross_arg="--cross-file config-meson.cross" |
fc929892 | 2792 | echo "[host_machine]" >> $cross |
ba7c60c2 | 2793 | echo "system = '$targetos'" >> $cross |
823eb013 | 2794 | case "$cpu" in |
f6bca9df | 2795 | i386) |
fc929892 MAL |
2796 | echo "cpu_family = 'x86'" >> $cross |
2797 | ;; | |
fc929892 | 2798 | *) |
823eb013 | 2799 | echo "cpu_family = '$cpu'" >> $cross |
fc929892 MAL |
2800 | ;; |
2801 | esac | |
2802 | echo "cpu = '$cpu'" >> $cross | |
2803 | if test "$bigendian" = "yes" ; then | |
2804 | echo "endian = 'big'" >> $cross | |
2805 | else | |
2806 | echo "endian = 'little'" >> $cross | |
2807 | fi | |
d77e90fa | 2808 | else |
fc929892 | 2809 | cross_arg="--native-file config-meson.cross" |
d77e90fa PB |
2810 | fi |
2811 | mv $cross config-meson.cross | |
fc929892 | 2812 | |
d77e90fa | 2813 | rm -rf meson-private meson-info meson-logs |
61d63097 PB |
2814 | run_meson() { |
2815 | NINJA=$ninja $meson setup \ | |
d17f305a PB |
2816 | --prefix "$prefix" \ |
2817 | --libdir "$libdir" \ | |
2818 | --libexecdir "$libexecdir" \ | |
2819 | --bindir "$bindir" \ | |
2820 | --includedir "$includedir" \ | |
2821 | --datadir "$datadir" \ | |
2822 | --mandir "$mandir" \ | |
2823 | --sysconfdir "$sysconfdir" \ | |
16bf7a33 | 2824 | --localedir "$localedir" \ |
d17f305a | 2825 | --localstatedir "$local_statedir" \ |
3b4da132 PB |
2826 | -Daudio_drv_list=$audio_drv_list \ |
2827 | -Ddefault_devices=$default_devices \ | |
d17f305a | 2828 | -Ddocdir="$docdir" \ |
5dc4618e | 2829 | -Diasl="$($iasl -h >/dev/null 2>&1 && printf %s "$iasl")" \ |
16bf7a33 | 2830 | -Dqemu_firmwarepath="$firmwarepath" \ |
73f3aa37 | 2831 | -Dqemu_suffix="$qemu_suffix" \ |
35acbb30 | 2832 | -Dsmbd="$smbd" \ |
3b4da132 PB |
2833 | -Dsphinx_build="$sphinx_build" \ |
2834 | -Dtrace_file="$trace_file" \ | |
a5665051 PB |
2835 | -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) \ |
2836 | -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo false; fi) \ | |
2837 | -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \ | |
da6d48b9 | 2838 | -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \ |
bf0e56a3 | 2839 | -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \ |
3b4da132 PB |
2840 | -Db_lto=$lto -Dcfi=$cfi -Dtcg=$tcg -Dxen=$xen \ |
2841 | -Dcapstone=$capstone -Dfdt=$fdt -Dslirp=$slirp \ | |
537b7248 | 2842 | $(test -n "${LIB_FUZZING_ENGINE+xxx}" && echo "-Dfuzzing_engine=$LIB_FUZZING_ENGINE") \ |
332008e0 | 2843 | $(if test "$default_feature" = no; then echo "-Dauto_features=disabled"; fi) \ |
61d63097 PB |
2844 | "$@" $cross_arg "$PWD" "$source_path" |
2845 | } | |
2846 | eval run_meson $meson_options | |
d77e90fa PB |
2847 | if test "$?" -ne 0 ; then |
2848 | error_exit "meson setup failed" | |
2849 | fi | |
699d3884 PB |
2850 | else |
2851 | if test -f meson-private/cmd_line.txt; then | |
2852 | # Adjust old command line options whose type was changed | |
2853 | # Avoids having to use "setup --wipe" when Meson is upgraded | |
2854 | perl -i -ne ' | |
2855 | s/^gettext = true$/gettext = auto/; | |
2856 | s/^gettext = false$/gettext = disabled/; | |
654d6b04 | 2857 | /^b_staticpic/ && next; |
699d3884 PB |
2858 | print;' meson-private/cmd_line.txt |
2859 | fi | |
a5665051 PB |
2860 | fi |
2861 | ||
dc655404 MT |
2862 | # Save the configure command line for later reuse. |
2863 | cat <<EOD >config.status | |
2864 | #!/bin/sh | |
2865 | # Generated by configure. | |
2866 | # Run this file to recreate the current configuration. | |
2867 | # Compiler output produced by configure, useful for debugging | |
2868 | # configure, is in config.log if it exists. | |
2869 | EOD | |
e811da7f DB |
2870 | |
2871 | preserve_env() { | |
2872 | envname=$1 | |
2873 | ||
2874 | eval envval=\$$envname | |
2875 | ||
2876 | if test -n "$envval" | |
2877 | then | |
2878 | echo "$envname='$envval'" >> config.status | |
2879 | echo "export $envname" >> config.status | |
2880 | else | |
2881 | echo "unset $envname" >> config.status | |
2882 | fi | |
2883 | } | |
2884 | ||
2885 | # Preserve various env variables that influence what | |
2886 | # features/build target configure will detect | |
2887 | preserve_env AR | |
2888 | preserve_env AS | |
2889 | preserve_env CC | |
2890 | preserve_env CPP | |
8009da03 | 2891 | preserve_env CFLAGS |
e811da7f | 2892 | preserve_env CXX |
8009da03 | 2893 | preserve_env CXXFLAGS |
e811da7f DB |
2894 | preserve_env INSTALL |
2895 | preserve_env LD | |
8009da03 | 2896 | preserve_env LDFLAGS |
e811da7f DB |
2897 | preserve_env LD_LIBRARY_PATH |
2898 | preserve_env LIBTOOL | |
2899 | preserve_env MAKE | |
2900 | preserve_env NM | |
2901 | preserve_env OBJCOPY | |
2902 | preserve_env PATH | |
2903 | preserve_env PKG_CONFIG | |
2904 | preserve_env PKG_CONFIG_LIBDIR | |
2905 | preserve_env PKG_CONFIG_PATH | |
2906 | preserve_env PYTHON | |
e811da7f DB |
2907 | preserve_env SDL2_CONFIG |
2908 | preserve_env SMBD | |
2909 | preserve_env STRIP | |
2910 | preserve_env WINDRES | |
2911 | ||
dc655404 | 2912 | printf "exec" >>config.status |
a5665051 | 2913 | for i in "$0" "$@"; do |
835af899 | 2914 | test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status |
a5665051 | 2915 | done |
cf7cc929 | 2916 | echo ' "$@"' >>config.status |
dc655404 MT |
2917 | chmod +x config.status |
2918 | ||
8cd05ab6 | 2919 | rm -r "$TMPDIR1" |