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