]>
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 | ||
f160a5b2 DB |
34 | if ! mkdir build || ! touch $MARKER |
35 | then | |
36 | echo "ERROR: Could not create ./build directory. Check the permissions on" | |
37 | echo "your source directory, or try doing an out-of-tree build." | |
38 | exit 1 | |
39 | fi | |
dedad027 DB |
40 | |
41 | cat > GNUmakefile <<'EOF' | |
42 | # This file is auto-generated by configure to support in-source tree | |
43 | # 'make' command invocation | |
44 | ||
45 | ifeq ($(MAKECMDGOALS),) | |
46 | recurse: all | |
47 | endif | |
48 | ||
49 | .NOTPARALLEL: % | |
50 | %: force | |
51 | @echo 'changing dir to build for $(MAKE) "$(MAKECMDGOALS)"...' | |
52 | @$(MAKE) -C build -f Makefile $(MAKECMDGOALS) | |
53 | @if test "$(MAKECMDGOALS)" = "distclean" && \ | |
54 | test -e build/auto-created-by-configure ; \ | |
55 | then \ | |
56 | rm -rf build GNUmakefile ; \ | |
57 | fi | |
58 | force: ; | |
59 | .PHONY: force | |
60 | GNUmakefile: ; | |
61 | ||
62 | EOF | |
63 | cd build | |
64708615 | 64 | exec "$source_path/configure" "$@" |
dedad027 DB |
65 | fi |
66 | ||
8cd05ab6 PM |
67 | # Temporary directory used for files created while |
68 | # configure runs. Since it is in the build directory | |
69 | # we can safely blow away any previous version of it | |
70 | # (and we need not jump through hoops to try to delete | |
71 | # it when configure exits.) | |
72 | TMPDIR1="config-temp" | |
73 | rm -rf "${TMPDIR1}" | |
563661c0 | 74 | if ! mkdir -p "${TMPDIR1}"; then |
8cd05ab6 PM |
75 | echo "ERROR: failed to create temporary directory" |
76 | exit 1 | |
7d13299d FB |
77 | fi |
78 | ||
8cd05ab6 PM |
79 | TMPB="qemu-conf" |
80 | TMPC="${TMPDIR1}/${TMPB}.c" | |
66518bf6 | 81 | TMPO="${TMPDIR1}/${TMPB}.o" |
8cd05ab6 | 82 | TMPE="${TMPDIR1}/${TMPB}.exe" |
7d13299d | 83 | |
da1d85e3 | 84 | rm -f config.log |
9ac81bbb | 85 | |
b48e3611 PM |
86 | # Print a helpful header at the top of config.log |
87 | echo "# QEMU configure log $(date)" >> config.log | |
979ae168 | 88 | printf "# Configured with:" >> config.log |
7f788779 AB |
89 | # repeat the invocation to log and stdout for CI |
90 | invoke=$(printf " '%s'" "$0" "$@") | |
91 | test -n "$GITLAB_CI" && echo "configuring with: $invoke" | |
92 | { echo "$invoke"; echo; echo "#"; } >> config.log | |
b48e3611 | 93 | |
835af899 PB |
94 | quote_sh() { |
95 | printf "%s" "$1" | sed "s,','\\\\'',g; s,.*,'&'," | |
96 | } | |
97 | ||
d880a3ba PB |
98 | print_error() { |
99 | (echo | |
76ad07a4 PM |
100 | echo "ERROR: $1" |
101 | while test -n "$2"; do | |
102 | echo " $2" | |
103 | shift | |
104 | done | |
d880a3ba PB |
105 | echo) >&2 |
106 | } | |
107 | ||
108 | error_exit() { | |
109 | print_error "$@" | |
76ad07a4 PM |
110 | exit 1 |
111 | } | |
112 | ||
9c83ffd8 | 113 | do_compiler() { |
cd362def PB |
114 | # Run the compiler, capturing its output to the log. First argument |
115 | # is compiler binary to execute. | |
b3b5472d | 116 | compiler="$1" |
cd362def PB |
117 | shift |
118 | if test -n "$BASH_VERSION"; then eval ' | |
119 | echo >>config.log " | |
120 | funcs: ${FUNCNAME[*]} | |
121 | lines: ${BASH_LINENO[*]}" | |
122 | '; fi | |
123 | echo $compiler "$@" >> config.log | |
124 | $compiler "$@" >> config.log 2>&1 || return $? | |
125 | } | |
126 | ||
9c83ffd8 | 127 | do_cc() { |
d0016b86 | 128 | do_compiler "$cc" $CPU_CFLAGS "$@" |
9c83ffd8 PM |
129 | } |
130 | ||
52166aa0 | 131 | compile_object() { |
fd0e6053 | 132 | local_cflags="$1" |
a988b4c5 | 133 | do_cc $CFLAGS $EXTRA_CFLAGS $local_cflags -c -o $TMPO $TMPC |
52166aa0 JQ |
134 | } |
135 | ||
136 | compile_prog() { | |
137 | local_cflags="$1" | |
138 | local_ldflags="$2" | |
a988b4c5 PB |
139 | do_cc $CFLAGS $EXTRA_CFLAGS $local_cflags -o $TMPE $TMPC \ |
140 | $LDFLAGS $EXTRA_LDFLAGS $local_ldflags | |
52166aa0 JQ |
141 | } |
142 | ||
11568d6d PB |
143 | # symbolically link $1 to $2. Portable version of "ln -sf". |
144 | symlink() { | |
72b8b5a1 | 145 | rm -rf "$2" |
ec5b06d7 | 146 | mkdir -p "$(dirname "$2")" |
72b8b5a1 | 147 | ln -s "$1" "$2" |
11568d6d PB |
148 | } |
149 | ||
0dba6195 LM |
150 | # check whether a command is available to this shell (may be either an |
151 | # executable or a builtin) | |
152 | has() { | |
153 | type "$1" >/dev/null 2>&1 | |
154 | } | |
155 | ||
0a01d76f | 156 | version_ge () { |
2df52b9b AB |
157 | local_ver1=$(expr "$1" : '\([0-9.]*\)' | tr . ' ') |
158 | local_ver2=$(echo "$2" | tr . ' ') | |
0a01d76f MAL |
159 | while true; do |
160 | set x $local_ver1 | |
161 | local_first=${2-0} | |
c44a33e2 SG |
162 | # 'shift 2' if $2 is set, or 'shift' if $2 is not set |
163 | shift ${2:+2} | |
0a01d76f MAL |
164 | local_ver1=$* |
165 | set x $local_ver2 | |
166 | # the second argument finished, the first must be greater or equal | |
167 | test $# = 1 && return 0 | |
168 | test $local_first -lt $2 && return 1 | |
169 | test $local_first -gt $2 && return 0 | |
c44a33e2 | 170 | shift ${2:+2} |
0a01d76f MAL |
171 | local_ver2=$* |
172 | done | |
173 | } | |
174 | ||
4ace32e2 AO |
175 | if printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]"; |
176 | then | |
177 | error_exit "main directory cannot contain spaces nor colons" | |
178 | fi | |
179 | ||
13cf376c PB |
180 | # parse CC options first; some compiler tests are used to establish |
181 | # some defaults, based on the host environment | |
182 | ||
14211825 | 183 | # default parameters |
2ff6b91e | 184 | cpu="" |
3812c0c4 | 185 | cross_compile="no" |
7d13299d | 186 | cross_prefix="" |
e49d021e | 187 | host_cc="cc" |
13cf376c PB |
188 | EXTRA_CFLAGS="" |
189 | EXTRA_CXXFLAGS="" | |
190 | EXTRA_OBJCFLAGS="" | |
191 | EXTRA_LDFLAGS="" | |
377529c0 PB |
192 | |
193 | # Default value for a variable defining feature "foo". | |
194 | # * foo="no" feature will only be used if --enable-foo arg is given | |
195 | # * foo="" feature will be searched for, and if found, will be used | |
196 | # unless --disable-foo is given | |
197 | # * foo="yes" this value will only be set by --enable-foo flag. | |
198 | # feature will searched for, | |
199 | # if not found, configure exits with error | |
200 | # | |
201 | # Always add --enable-foo and --disable-foo command line args. | |
202 | # Distributions want to ensure that several features are compiled in, and it | |
203 | # is impossible without a --enable-foo that exits if a feature is not found. | |
c87ea116 | 204 | default_feature="" |
3b4da132 | 205 | |
ac0df51d | 206 | for opt do |
89138857 | 207 | optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') |
ac0df51d AL |
208 | case "$opt" in |
209 | --cross-prefix=*) cross_prefix="$optarg" | |
3812c0c4 | 210 | cross_compile="yes" |
ac0df51d | 211 | ;; |
3d8df640 | 212 | --cc=*) CC="$optarg" |
ac0df51d | 213 | ;; |
83f73fce TS |
214 | --cxx=*) CXX="$optarg" |
215 | ;; | |
c0c34c91 PM |
216 | --objcc=*) objcc="$optarg" |
217 | ;; | |
2ff6b91e JQ |
218 | --cpu=*) cpu="$optarg" |
219 | ;; | |
a2866660 PB |
220 | --extra-cflags=*) |
221 | EXTRA_CFLAGS="$EXTRA_CFLAGS $optarg" | |
222 | EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" | |
e910c7d9 | 223 | EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg" |
a2866660 PB |
224 | ;; |
225 | --extra-cxxflags=*) EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" | |
11cde1c8 | 226 | ;; |
e910c7d9 PMD |
227 | --extra-objcflags=*) EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg" |
228 | ;; | |
a2866660 | 229 | --extra-ldflags=*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS $optarg" |
e2a2ed06 | 230 | ;; |
d75402b5 AB |
231 | --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option" |
232 | ;; | |
479ca4cc | 233 | --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-cflags-}; cc_arch=${cc_arch%%=*} |
d422b2bc AB |
234 | eval "cross_cc_cflags_${cc_arch}=\$optarg" |
235 | ;; | |
d75402b5 AB |
236 | --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*} |
237 | eval "cross_cc_${cc_arch}=\$optarg" | |
238 | ;; | |
5adb43be PB |
239 | --cross-prefix-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-prefix-FOO option" |
240 | ;; | |
241 | --cross-prefix-*) cc_arch=${opt#--cross-prefix-}; cc_arch=${cc_arch%%=*} | |
242 | eval "cross_prefix_${cc_arch}=\$optarg" | |
243 | ;; | |
13cf376c PB |
244 | --without-default-features) default_feature="no" |
245 | ;; | |
ac0df51d AL |
246 | esac |
247 | done | |
ac0df51d | 248 | |
13cf376c PB |
249 | |
250 | if test -e "$source_path/.git" | |
251 | then | |
252 | git_submodules_action="update" | |
253 | else | |
254 | git_submodules_action="ignore" | |
255 | fi | |
256 | ||
257 | git_submodules="ui/keycodemapdb" | |
258 | git="git" | |
259 | debug_tcg="no" | |
260 | docs="auto" | |
261 | EXESUF="" | |
262 | prefix="/usr/local" | |
263 | qemu_suffix="qemu" | |
264 | softmmu="yes" | |
265 | linux_user="" | |
266 | bsd_user="" | |
267 | plugins="$default_feature" | |
268 | ninja="" | |
269 | python= | |
270 | pypi="enabled" | |
271 | bindir="bin" | |
272 | skip_meson=no | |
273 | vfio_user_server="disabled" | |
274 | use_containers="yes" | |
275 | gdb_bin=$(command -v "gdb-multiarch" || command -v "gdb") | |
276 | gdb_arches="" | |
277 | werror="" | |
278 | ||
279 | # Don't accept a target_list environment variable. | |
280 | unset target_list | |
281 | unset target_list_exclude | |
282 | ||
283 | # The following Meson options are handled manually (still they | |
284 | # are included in the automatically generated help message) | |
285 | ||
286 | # 1. Track which submodules are needed | |
287 | fdt="auto" | |
288 | ||
289 | # 2. Automatically enable/disable other options | |
290 | tcg="auto" | |
291 | cfi="false" | |
292 | ||
293 | # 3. Need to check for -static-pie before Meson runs. Also, | |
294 | # Meson has PIE as a boolean rather than enabled/disabled/auto. | |
295 | pie="" | |
296 | static="no" | |
297 | ||
e49d021e PM |
298 | # Preferred compiler: |
299 | # ${CC} (if set) | |
300 | # ${cross_prefix}gcc (if cross-prefix specified) | |
301 | # system compiler | |
302 | if test -z "${CC}${cross_prefix}"; then | |
303 | cc="$host_cc" | |
304 | else | |
305 | cc="${CC-${cross_prefix}gcc}" | |
306 | fi | |
307 | ||
83f73fce TS |
308 | if test -z "${CXX}${cross_prefix}"; then |
309 | cxx="c++" | |
310 | else | |
311 | cxx="${CXX-${cross_prefix}g++}" | |
312 | fi | |
313 | ||
c0c34c91 PM |
314 | # Preferred ObjC compiler: |
315 | # $objcc (if set, i.e. via --objcc option) | |
316 | # ${cross_prefix}clang (if cross-prefix specified) | |
317 | # clang (if available) | |
318 | # $cc | |
319 | if test -z "${objcc}${cross_prefix}"; then | |
320 | if has clang; then | |
321 | objcc=clang | |
322 | else | |
323 | objcc="$cc" | |
324 | fi | |
325 | else | |
326 | objcc="${objcc-${cross_prefix}clang}" | |
327 | fi | |
328 | ||
b3198cc2 | 329 | ar="${AR-${cross_prefix}ar}" |
cdbd727c | 330 | as="${AS-${cross_prefix}as}" |
5f6f0e27 | 331 | ccas="${CCAS-$cc}" |
b3198cc2 SY |
332 | objcopy="${OBJCOPY-${cross_prefix}objcopy}" |
333 | ld="${LD-${cross_prefix}ld}" | |
9f81aeb5 | 334 | ranlib="${RANLIB-${cross_prefix}ranlib}" |
4852ee95 | 335 | nm="${NM-${cross_prefix}nm}" |
35acbb30 | 336 | smbd="$SMBD" |
b3198cc2 | 337 | strip="${STRIP-${cross_prefix}strip}" |
158bb224 | 338 | widl="${WIDL-${cross_prefix}widl}" |
b3198cc2 | 339 | windres="${WINDRES-${cross_prefix}windres}" |
f9f0e617 | 340 | windmc="${WINDMC-${cross_prefix}windmc}" |
877c5567 | 341 | pkg_config="${PKG_CONFIG-${cross_prefix}pkg-config}" |
47c03744 | 342 | sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}" |
ac0df51d | 343 | |
ac0df51d AL |
344 | check_define() { |
345 | cat > $TMPC <<EOF | |
346 | #if !defined($1) | |
fd786e1a | 347 | #error $1 not defined |
ac0df51d AL |
348 | #endif |
349 | int main(void) { return 0; } | |
350 | EOF | |
52166aa0 | 351 | compile_object |
ac0df51d AL |
352 | } |
353 | ||
93b25869 JS |
354 | write_c_skeleton() { |
355 | cat > $TMPC <<EOF | |
356 | int main(void) { return 0; } | |
357 | EOF | |
358 | } | |
359 | ||
bbea4050 | 360 | if check_define __linux__ ; then |
ba7c60c2 | 361 | targetos=linux |
bbea4050 | 362 | elif check_define _WIN32 ; then |
ba7c60c2 | 363 | targetos=windows |
bbea4050 | 364 | elif check_define __OpenBSD__ ; then |
ba7c60c2 | 365 | targetos=openbsd |
bbea4050 | 366 | elif check_define __sun__ ; then |
ba7c60c2 | 367 | targetos=sunos |
bbea4050 | 368 | elif check_define __HAIKU__ ; then |
ba7c60c2 | 369 | targetos=haiku |
951fedfc | 370 | elif check_define __FreeBSD__ ; then |
ba7c60c2 | 371 | targetos=freebsd |
951fedfc | 372 | elif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then |
ba7c60c2 | 373 | targetos=gnu/kfreebsd |
951fedfc | 374 | elif check_define __DragonFly__ ; then |
ba7c60c2 | 375 | targetos=dragonfly |
951fedfc | 376 | elif check_define __NetBSD__; then |
ba7c60c2 | 377 | targetos=netbsd |
951fedfc | 378 | elif check_define __APPLE__; then |
ba7c60c2 | 379 | targetos=darwin |
bbea4050 | 380 | else |
951fedfc PM |
381 | # This is a fatal error, but don't report it yet, because we |
382 | # might be going to just print the --help text, or it might | |
383 | # be the result of a missing compiler. | |
ba7c60c2 | 384 | targetos=bogus |
bbea4050 PM |
385 | fi |
386 | ||
65eff01b PB |
387 | # OS specific |
388 | ||
3b0d8643 PB |
389 | mingw32="no" |
390 | bsd="no" | |
391 | linux="no" | |
392 | solaris="no" | |
bbea4050 | 393 | case $targetos in |
65eff01b PB |
394 | windows) |
395 | mingw32="yes" | |
396 | plugins="no" | |
397 | pie="no" | |
398 | ;; | |
399 | gnu/kfreebsd) | |
400 | bsd="yes" | |
401 | ;; | |
402 | freebsd) | |
403 | bsd="yes" | |
65eff01b PB |
404 | make="${MAKE-gmake}" |
405 | # needed for kinfo_getvmmap(3) in libutil.h | |
406 | ;; | |
407 | dragonfly) | |
408 | bsd="yes" | |
409 | make="${MAKE-gmake}" | |
410 | ;; | |
411 | netbsd) | |
412 | bsd="yes" | |
413 | make="${MAKE-gmake}" | |
414 | ;; | |
415 | openbsd) | |
416 | bsd="yes" | |
417 | make="${MAKE-gmake}" | |
418 | ;; | |
419 | darwin) | |
420 | bsd="yes" | |
421 | darwin="yes" | |
65eff01b | 422 | ;; |
ba7c60c2 | 423 | sunos) |
65eff01b PB |
424 | solaris="yes" |
425 | make="${MAKE-gmake}" | |
65eff01b PB |
426 | ;; |
427 | haiku) | |
428 | pie="no" | |
65eff01b PB |
429 | ;; |
430 | linux) | |
431 | linux="yes" | |
65eff01b | 432 | ;; |
bbea4050 PM |
433 | esac |
434 | ||
2ff6b91e JQ |
435 | if test ! -z "$cpu" ; then |
436 | # command line argument | |
437 | : | |
438 | elif check_define __i386__ ; then | |
ac0df51d AL |
439 | cpu="i386" |
440 | elif check_define __x86_64__ ; then | |
c72b26ec RH |
441 | if check_define __ILP32__ ; then |
442 | cpu="x32" | |
443 | else | |
444 | cpu="x86_64" | |
445 | fi | |
3aa9bd6c | 446 | elif check_define __sparc__ ; then |
3aa9bd6c BS |
447 | if check_define __arch64__ ; then |
448 | cpu="sparc64" | |
449 | else | |
450 | cpu="sparc" | |
451 | fi | |
fdf7ed96 | 452 | elif check_define _ARCH_PPC ; then |
453 | if check_define _ARCH_PPC64 ; then | |
f8378acc RH |
454 | if check_define _LITTLE_ENDIAN ; then |
455 | cpu="ppc64le" | |
456 | else | |
457 | cpu="ppc64" | |
458 | fi | |
fdf7ed96 | 459 | else |
460 | cpu="ppc" | |
461 | fi | |
afa05235 AJ |
462 | elif check_define __mips__ ; then |
463 | cpu="mips" | |
d66ed0ea AJ |
464 | elif check_define __s390__ ; then |
465 | if check_define __s390x__ ; then | |
466 | cpu="s390x" | |
467 | else | |
468 | cpu="s390" | |
469 | fi | |
c4f80543 | 470 | elif check_define __riscv ; then |
ba0e7333 | 471 | cpu="riscv" |
21d89f84 PM |
472 | elif check_define __arm__ ; then |
473 | cpu="arm" | |
1f080313 CF |
474 | elif check_define __aarch64__ ; then |
475 | cpu="aarch64" | |
dfcf900b WX |
476 | elif check_define __loongarch64 ; then |
477 | cpu="loongarch64" | |
ac0df51d | 478 | else |
f9c77801 PB |
479 | # Using uname is really broken, but it is just a fallback for architectures |
480 | # that are going to use TCI anyway | |
89138857 | 481 | cpu=$(uname -m) |
f9c77801 | 482 | echo "WARNING: unrecognized host CPU, proceeding with 'uname -m' output '$cpu'" |
ac0df51d AL |
483 | fi |
484 | ||
f9c77801 PB |
485 | # Normalise host CPU name and set multilib cflags. The canonicalization |
486 | # isn't really necessary, because the architectures that we check for | |
487 | # should not hit the 'uname -m' case, but better safe than sorry. | |
359bc95d | 488 | # Note that this case should only have supported host CPUs, not guests. |
7d13299d | 489 | case "$cpu" in |
e4da0e39 PB |
490 | armv*b|armv*l|arm) |
491 | cpu="arm" ;; | |
492 | ||
f9c77801 | 493 | i386|i486|i586|i686) |
97a847bc | 494 | cpu="i386" |
e4da0e39 PB |
495 | CPU_CFLAGS="-m32" ;; |
496 | x32) | |
4da270be | 497 | cpu="x86_64" |
e4da0e39 | 498 | CPU_CFLAGS="-mx32" ;; |
aaa5fa14 AJ |
499 | x86_64|amd64) |
500 | cpu="x86_64" | |
e4da0e39 PB |
501 | # ??? Only extremely old AMD cpus do not have cmpxchg16b. |
502 | # If we truly care, we should simply detect this case at | |
503 | # runtime and generate the fallback to serial emulation. | |
504 | CPU_CFLAGS="-m64 -mcx16" ;; | |
505 | ||
afa05235 | 506 | mips*) |
e4da0e39 PB |
507 | cpu="mips" ;; |
508 | ||
509 | ppc) | |
510 | CPU_CFLAGS="-m32" ;; | |
511 | ppc64) | |
ced5cfff | 512 | CPU_CFLAGS="-m64 -mbig-endian" ;; |
e4da0e39 | 513 | ppc64le) |
d8ff892d | 514 | cpu="ppc64" |
ced5cfff | 515 | CPU_CFLAGS="-m64 -mlittle-endian" ;; |
e4da0e39 PB |
516 | |
517 | s390) | |
823eb013 | 518 | CPU_CFLAGS="-m31" ;; |
e4da0e39 PB |
519 | s390x) |
520 | CPU_CFLAGS="-m64" ;; | |
521 | ||
3142255c | 522 | sparc|sun4[cdmuv]) |
ae228531 | 523 | cpu="sparc" |
e4da0e39 PB |
524 | CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc" ;; |
525 | sparc64) | |
526 | CPU_CFLAGS="-m64 -mcpu=ultrasparc" ;; | |
7d13299d | 527 | esac |
e2d52ad3 | 528 | |
0db4a067 | 529 | : ${make=${MAKE-make}} |
b6daf4d3 | 530 | |
fee6d412 JS |
531 | |
532 | check_py_version() { | |
5591b745 | 533 | # We require python >= 3.7. |
fee6d412 | 534 | # NB: a True python conditional creates a non-zero return code (Failure) |
5591b745 | 535 | "$1" -c 'import sys; sys.exit(sys.version_info < (3,7))' |
fee6d412 JS |
536 | } |
537 | ||
fee6d412 JS |
538 | first_python= |
539 | if test -z "${PYTHON}"; then | |
fee6d412 JS |
540 | # A bare 'python' is traditionally python 2.x, but some distros |
541 | # have it as python 3.x, so check in both places. | |
5591b745 | 542 | for binary in python3 python python3.11 python3.10 python3.9 python3.8 python3.7; do |
fee6d412 JS |
543 | if has "$binary"; then |
544 | python=$(command -v "$binary") | |
545 | if check_py_version "$python"; then | |
546 | # This one is good. | |
547 | first_python= | |
548 | break | |
549 | else | |
550 | first_python=$python | |
551 | fi | |
552 | fi | |
553 | done | |
554 | else | |
555 | # Same as above, but only check the environment variable. | |
556 | has "${PYTHON}" || error_exit "The PYTHON environment variable does not point to an executable" | |
557 | python=$(command -v "$PYTHON") | |
fee6d412 JS |
558 | if check_py_version "$python"; then |
559 | # This one is good. | |
560 | first_python= | |
561 | else | |
562 | first_python=$first_python | |
faf44142 | 563 | fi |
fee6d412 | 564 | fi |
903458c8 | 565 | |
39d87c8c AB |
566 | # Check for ancillary tools used in testing |
567 | genisoimage= | |
3df437c7 | 568 | for binary in genisoimage mkisofs |
39d87c8c AB |
569 | do |
570 | if has $binary | |
571 | then | |
572 | genisoimage=$(command -v "$binary") | |
573 | break | |
574 | fi | |
575 | done | |
576 | ||
3457a3f8 | 577 | if test "$mingw32" = "yes" ; then |
3457a3f8 | 578 | EXESUF=".exe" |
d17f305a | 579 | prefix="/qemu" |
c09c1ce7 | 580 | bindir="" |
77433a5f | 581 | qemu_suffix="" |
3457a3f8 JQ |
582 | fi |
583 | ||
8154f5e6 AO |
584 | meson_option_build_array() { |
585 | printf '[' | |
c5cfdaba | 586 | (if test "$targetos" = windows; then |
8154f5e6 AO |
587 | IFS=\; |
588 | else | |
589 | IFS=: | |
590 | fi | |
591 | for e in $1; do | |
65842b03 PM |
592 | printf '"""' |
593 | # backslash escape any '\' and '"' characters | |
594 | printf "%s" "$e" | sed -e 's/\([\"]\)/\\\1/g' | |
595 | printf '""",' | |
8154f5e6 AO |
596 | done) |
597 | printf ']\n' | |
598 | } | |
599 | ||
64708615 | 600 | . "$source_path/scripts/meson-buildoptions.sh" |
61d63097 PB |
601 | |
602 | meson_options= | |
c54b59ee PB |
603 | meson_option_add() { |
604 | meson_options="$meson_options $(quote_sh "$1")" | |
605 | } | |
61d63097 PB |
606 | meson_option_parse() { |
607 | meson_options="$meson_options $(_meson_option_parse "$@")" | |
608 | if test $? -eq 1; then | |
609 | echo "ERROR: unknown option $1" | |
610 | echo "Try '$0 --help' for more information" | |
611 | exit 1 | |
612 | fi | |
613 | } | |
614 | ||
7d13299d | 615 | for opt do |
89138857 | 616 | optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') |
7d13299d | 617 | case "$opt" in |
2efc3265 FB |
618 | --help|-h) show_help=yes |
619 | ;; | |
64708615 | 620 | --version|-V) exec cat "$source_path/VERSION" |
99123e13 | 621 | ;; |
b1a550a0 | 622 | --prefix=*) prefix="$optarg" |
7d13299d | 623 | ;; |
ac0df51d | 624 | --cross-prefix=*) |
7d13299d | 625 | ;; |
ac0df51d | 626 | --cc=*) |
7d13299d | 627 | ;; |
b1a550a0 | 628 | --host-cc=*) host_cc="$optarg" |
83469015 | 629 | ;; |
83f73fce TS |
630 | --cxx=*) |
631 | ;; | |
c0c34c91 | 632 | --objcc=*) |
3c4a4d0d | 633 | ;; |
b1a550a0 | 634 | --make=*) make="$optarg" |
7d13299d | 635 | ;; |
b6daf4d3 | 636 | --install=*) |
6a882643 | 637 | ;; |
81e2b198 | 638 | --python=*) python="$optarg" |
c886edfb | 639 | ;; |
a5665051 PB |
640 | --skip-meson) skip_meson=yes |
641 | ;; | |
48328880 PB |
642 | --ninja=*) ninja="$optarg" |
643 | ;; | |
e2d8830e BS |
644 | --smbd=*) smbd="$optarg" |
645 | ;; | |
e2a2ed06 | 646 | --extra-cflags=*) |
7d13299d | 647 | ;; |
11cde1c8 BD |
648 | --extra-cxxflags=*) |
649 | ;; | |
e910c7d9 PMD |
650 | --extra-objcflags=*) |
651 | ;; | |
e2a2ed06 | 652 | --extra-ldflags=*) |
7d13299d | 653 | ;; |
28609749 | 654 | --cross-cc-*) |
5bc62e01 | 655 | ;; |
5adb43be PB |
656 | --cross-prefix-*) |
657 | ;; | |
6b0cedcd JS |
658 | --enable-docs) docs=enabled |
659 | ;; | |
660 | --disable-docs) docs=disabled | |
661 | ;; | |
2ff6b91e | 662 | --cpu=*) |
7d13299d | 663 | ;; |
b1a550a0 | 664 | --target-list=*) target_list="$optarg" |
447e133f AB |
665 | if test "$target_list_exclude"; then |
666 | error_exit "Can't mix --target-list with --target-list-exclude" | |
667 | fi | |
668 | ;; | |
669 | --target-list-exclude=*) target_list_exclude="$optarg" | |
670 | if test "$target_list"; then | |
671 | error_exit "Can't mix --target-list-exclude with --target-list" | |
672 | fi | |
de83cd02 | 673 | ;; |
c54b59ee | 674 | --with-default-devices) meson_option_add -Ddefault_devices=true |
f3494749 | 675 | ;; |
c54b59ee | 676 | --without-default-devices) meson_option_add -Ddefault_devices=false |
f3494749 | 677 | ;; |
d1d5e9ee AB |
678 | --with-devices-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --with-devices-FOO option" |
679 | ;; | |
680 | --with-devices-*) device_arch=${opt#--with-devices-}; | |
681 | device_arch=${device_arch%%=*} | |
682 | cf=$source_path/configs/devices/$device_arch-softmmu/$optarg.mak | |
683 | if test -f "$cf"; then | |
684 | device_archs="$device_archs $device_arch" | |
685 | eval "devices_${device_arch}=\$optarg" | |
686 | else | |
687 | error_exit "File $cf does not exist" | |
688 | fi | |
689 | ;; | |
c87ea116 AB |
690 | --without-default-features) # processed above |
691 | ;; | |
877c5567 | 692 | --static) static="yes" |
43ce4dfe | 693 | ;; |
0b24e75f PB |
694 | --bindir=*) bindir="$optarg" |
695 | ;; | |
77433a5f | 696 | --with-suffix=*) qemu_suffix="$optarg" |
023d3d67 | 697 | ;; |
181ce1d0 OH |
698 | --host=*|--build=*|\ |
699 | --disable-dependency-tracking|\ | |
785c23ae | 700 | --sbindir=*|--sharedstatedir=*|\ |
fe0038be | 701 | --oldincludedir=*|--datarootdir=*|--infodir=*|\ |
023ddd74 MF |
702 | --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*) |
703 | # These switches are silently ignored, for compatibility with | |
704 | # autoconf-generated configure scripts. This allows QEMU's | |
705 | # configure to be used by RPM and similar macros that set | |
706 | # lots of directory switches by default. | |
707 | ;; | |
f8393946 AJ |
708 | --enable-debug-tcg) debug_tcg="yes" |
709 | ;; | |
710 | --disable-debug-tcg) debug_tcg="no" | |
711 | ;; | |
f3d08ee6 PB |
712 | --enable-debug) |
713 | # Enable debugging options that aren't excessively noisy | |
714 | debug_tcg="yes" | |
58a2e3f5 | 715 | meson_option_parse --enable-debug-graph-lock "" |
c55cf6ab | 716 | meson_option_parse --enable-debug-mutex "" |
c54b59ee | 717 | meson_option_add -Doptimization=0 |
0aebab04 | 718 | ;; |
1badb709 | 719 | --disable-tcg) tcg="disabled" |
d1a14257 | 720 | plugins="no" |
b3f6ea7e | 721 | ;; |
1badb709 | 722 | --enable-tcg) tcg="enabled" |
b3f6ea7e | 723 | ;; |
cad25d69 | 724 | --disable-system) softmmu="no" |
0a8e90f4 | 725 | ;; |
cad25d69 | 726 | --enable-system) softmmu="yes" |
0a8e90f4 | 727 | ;; |
0953a80f ZA |
728 | --disable-user) |
729 | linux_user="no" ; | |
730 | bsd_user="no" ; | |
0953a80f ZA |
731 | ;; |
732 | --enable-user) ;; | |
831b7825 | 733 | --disable-linux-user) linux_user="no" |
0a8e90f4 | 734 | ;; |
831b7825 TS |
735 | --enable-linux-user) linux_user="yes" |
736 | ;; | |
84778508 BS |
737 | --disable-bsd-user) bsd_user="no" |
738 | ;; | |
739 | --enable-bsd-user) bsd_user="yes" | |
740 | ;; | |
40d6444e | 741 | --enable-pie) pie="yes" |
34005a00 | 742 | ;; |
40d6444e | 743 | --disable-pie) pie="no" |
34005a00 | 744 | ;; |
85aa5189 FB |
745 | --enable-werror) werror="yes" |
746 | ;; | |
747 | --disable-werror) werror="no" | |
748 | ;; | |
9e62ba48 DB |
749 | --enable-cfi) |
750 | cfi="true"; | |
c54b59ee | 751 | meson_option_add -Db_lto=true |
9e62ba48 DB |
752 | ;; |
753 | --disable-cfi) cfi="false" | |
754 | ;; | |
fbb4121d | 755 | --disable-fdt) fdt="disabled" |
2df87df7 | 756 | ;; |
fbb4121d PB |
757 | --enable-fdt) fdt="enabled" |
758 | ;; | |
759 | --enable-fdt=git) fdt="internal" | |
760 | ;; | |
03a3c0b3 | 761 | --enable-fdt=*) fdt="$optarg" |
2df87df7 | 762 | ;; |
cc84d63a DB |
763 | --with-git=*) git="$optarg" |
764 | ;; | |
7d7dbf9d DS |
765 | --with-git-submodules=*) |
766 | git_submodules_action="$optarg" | |
f62bbee5 | 767 | ;; |
0c5f3dcb JS |
768 | --disable-pypi) pypi="disabled" |
769 | ;; | |
770 | --enable-pypi) pypi="enabled" | |
771 | ;; | |
9b8e4298 AB |
772 | --enable-plugins) if test "$mingw32" = "yes"; then |
773 | error_exit "TCG plugins not currently supported on Windows platforms" | |
774 | else | |
775 | plugins="yes" | |
776 | fi | |
40e8c6f4 AB |
777 | ;; |
778 | --disable-plugins) plugins="no" | |
779 | ;; | |
afc3a8f9 AB |
780 | --enable-containers) use_containers="yes" |
781 | ;; | |
782 | --disable-containers) use_containers="no" | |
783 | ;; | |
f48e590a AB |
784 | --gdb=*) gdb_bin="$optarg" |
785 | ;; | |
55116968 JR |
786 | --enable-vfio-user-server) vfio_user_server="enabled" |
787 | ;; | |
788 | --disable-vfio-user-server) vfio_user_server="disabled" | |
789 | ;; | |
3b4da132 | 790 | # everything else has the same name in configure and meson |
4fda6011 | 791 | --*) meson_option_parse "$opt" "$optarg" |
7f1559c6 | 792 | ;; |
7d13299d FB |
793 | esac |
794 | done | |
795 | ||
d1a14257 AB |
796 | # test for any invalid configuration combinations |
797 | if test "$plugins" = "yes" -a "$tcg" = "disabled"; then | |
798 | error_exit "Can't enable plugins on non-TCG builds" | |
799 | fi | |
800 | ||
7d7dbf9d DS |
801 | case $git_submodules_action in |
802 | update|validate) | |
803 | if test ! -e "$source_path/.git"; then | |
804 | echo "ERROR: cannot $git_submodules_action git submodules without .git" | |
805 | exit 1 | |
806 | fi | |
807 | ;; | |
808 | ignore) | |
b80fd281 PB |
809 | if ! test -f "$source_path/ui/keycodemapdb/README" |
810 | then | |
811 | echo | |
812 | echo "ERROR: missing GIT submodules" | |
813 | echo | |
814 | if test -e "$source_path/.git"; then | |
815 | echo "--with-git-submodules=ignore specified but submodules were not" | |
816 | echo "checked out. Please initialize and update submodules." | |
817 | else | |
818 | echo "This is not a GIT checkout but module content appears to" | |
819 | echo "be missing. Do not use 'git archive' or GitHub download links" | |
820 | echo "to acquire QEMU source archives. Non-GIT builds are only" | |
821 | echo "supported with source archives linked from:" | |
822 | echo | |
823 | echo " https://www.qemu.org/download/#source" | |
824 | echo | |
825 | echo "Developers working with GIT can use scripts/archive-source.sh" | |
826 | echo "if they need to create valid source archives." | |
827 | fi | |
828 | echo | |
829 | exit 1 | |
830 | fi | |
7d7dbf9d DS |
831 | ;; |
832 | *) | |
833 | echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'" | |
834 | exit 1 | |
835 | ;; | |
836 | esac | |
837 | ||
60e0df25 | 838 | default_target_list="" |
6e92f823 PM |
839 | mak_wilds="" |
840 | ||
b915a2f1 | 841 | if [ "$linux_user" != no ]; then |
64708615 | 842 | if [ "$targetos" = linux ] && [ -d "$source_path/linux-user/include/host/$cpu" ]; then |
b915a2f1 PB |
843 | linux_user=yes |
844 | elif [ "$linux_user" = yes ]; then | |
845 | error_exit "linux-user not supported on this architecture" | |
846 | fi | |
847 | fi | |
848 | if [ "$bsd_user" != no ]; then | |
849 | if [ "$bsd_user" = "" ]; then | |
850 | test $targetos = freebsd && bsd_user=yes | |
851 | fi | |
64708615 | 852 | if [ "$bsd_user" = yes ] && ! [ -d "$source_path/bsd-user/$targetos" ]; then |
b915a2f1 PB |
853 | error_exit "bsd-user not supported on this host OS" |
854 | fi | |
855 | fi | |
6e92f823 | 856 | if [ "$softmmu" = "yes" ]; then |
812b31d3 | 857 | mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak" |
60e0df25 | 858 | fi |
6e92f823 | 859 | if [ "$linux_user" = "yes" ]; then |
812b31d3 | 860 | mak_wilds="${mak_wilds} $source_path/configs/targets/*-linux-user.mak" |
60e0df25 | 861 | fi |
6e92f823 | 862 | if [ "$bsd_user" = "yes" ]; then |
812b31d3 | 863 | mak_wilds="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak" |
60e0df25 PM |
864 | fi |
865 | ||
2d838d9b AB |
866 | for config in $mak_wilds; do |
867 | target="$(basename "$config" .mak)" | |
98db9a06 | 868 | if echo "$target_list_exclude" | grep -vq "$target"; then |
2d838d9b AB |
869 | default_target_list="${default_target_list} $target" |
870 | fi | |
871 | done | |
6e92f823 | 872 | |
af5db58e PB |
873 | if test x"$show_help" = x"yes" ; then |
874 | cat << EOF | |
875 | ||
876 | Usage: configure [options] | |
877 | Options: [defaults in brackets after descriptions] | |
878 | ||
08fb77ed SW |
879 | Standard options: |
880 | --help print this message | |
881 | --prefix=PREFIX install in PREFIX [$prefix] | |
74154d7e | 882 | --target-list=LIST set target list (default: build all) |
08fb77ed SW |
883 | $(echo Available targets: $default_target_list | \ |
884 | fold -s -w 53 | sed -e 's/^/ /') | |
447e133f | 885 | --target-list-exclude=LIST exclude a set of targets from the default target-list |
08fb77ed SW |
886 | |
887 | Advanced options (experts only): | |
3812c0c4 | 888 | --cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix] |
08fb77ed | 889 | --cc=CC use C compiler CC [$cc] |
08fb77ed SW |
890 | --host-cc=CC use C compiler CC [$host_cc] for code run at |
891 | build time | |
892 | --cxx=CXX use C++ compiler CXX [$cxx] | |
893 | --objcc=OBJCC use Objective-C compiler OBJCC [$objcc] | |
a2866660 PB |
894 | --extra-cflags=CFLAGS append extra C compiler flags CFLAGS |
895 | --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS | |
e910c7d9 | 896 | --extra-objcflags=OBJCFLAGS append extra Objective C compiler flags OBJCFLAGS |
08fb77ed | 897 | --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS |
d75402b5 | 898 | --cross-cc-ARCH=CC use compiler when building ARCH guest test cases |
479ca4cc | 899 | --cross-cc-cflags-ARCH= use compiler flags when building ARCH guest tests |
5adb43be | 900 | --cross-prefix-ARCH=PREFIX cross compiler prefix when building ARCH guest test cases |
08fb77ed | 901 | --make=MAKE use specified make [$make] |
08fb77ed | 902 | --python=PYTHON use specified python [$python] |
48328880 | 903 | --ninja=NINJA use specified ninja [$ninja] |
08fb77ed | 904 | --smbd=SMBD use specified smbd [$smbd] |
db1b5f13 | 905 | --with-git=GIT use specified git [$git] |
7d7dbf9d DS |
906 | --with-git-submodules=update update git submodules (default if .git dir exists) |
907 | --with-git-submodules=validate fail if git submodules are not up to date | |
908 | --with-git-submodules=ignore do not update or check git submodules (default if no .git dir) | |
08fb77ed | 909 | --static enable static build [$static] |
08fb77ed | 910 | --bindir=PATH install binaries in PATH |
ca8c0909 | 911 | --with-suffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix] |
c035c8d6 PB |
912 | --without-default-features default all --enable-* options to "disabled" |
913 | --without-default-devices do not include any device that is not needed to | |
914 | start the emulator (only use if you are including | |
d1d5e9ee AB |
915 | desired devices in configs/devices/) |
916 | --with-devices-ARCH=NAME override default configs/devices | |
08fb77ed | 917 | --enable-debug enable common debug build options |
08fb77ed | 918 | --disable-werror disable compilation abort on warning |
c23f23b9 | 919 | --cpu=CPU Build for host CPU [$cpu] |
40e8c6f4 AB |
920 | --enable-plugins |
921 | enable plugins via shared library loading | |
afc3a8f9 | 922 | --disable-containers don't use containers for cross-building |
f48e590a | 923 | --gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin] |
61d63097 PB |
924 | EOF |
925 | meson_options_help | |
926 | cat << EOF | |
c23f23b9 MT |
927 | system all system emulation targets |
928 | user supported user emulation targets | |
929 | linux-user all linux usermode emulation targets | |
930 | bsd-user all BSD usermode emulation targets | |
c23f23b9 | 931 | pie Position Independent Executables |
c23f23b9 | 932 | debug-tcg TCG debugging (default is disabled) |
08fb77ed SW |
933 | |
934 | NOTE: The object files are built at the place where configure is launched | |
af5db58e | 935 | EOF |
2d2ad6d0 | 936 | exit 0 |
af5db58e PB |
937 | fi |
938 | ||
9c790242 | 939 | # Remove old dependency files to make sure that they get properly regenerated |
002d8c13 | 940 | rm -f ./*/config-devices.mak.d |
9c790242 | 941 | |
faf44142 DB |
942 | if test -z "$python" |
943 | then | |
fee6d412 JS |
944 | # If first_python is set, there was a binary somewhere even though |
945 | # it was not suitable. Use it for the error message. | |
946 | if test -n "$first_python"; then | |
5591b745 | 947 | error_exit "Cannot use '$first_python', Python >= 3.7 is required." \ |
fee6d412 JS |
948 | "Use --python=/path/to/python to specify a supported Python." |
949 | else | |
950 | error_exit "Python not found. Use --python=/path/to/python" | |
951 | fi | |
c53eeaf7 | 952 | fi |
fee6d412 | 953 | |
8e2c76bd RB |
954 | if ! has "$make" |
955 | then | |
956 | error_exit "GNU make ($make) not found" | |
957 | fi | |
c53eeaf7 | 958 | |
fee6d412 | 959 | if ! check_py_version "$python"; then |
5591b745 | 960 | error_exit "Cannot use '$python', Python >= 3.7 is required." \ |
e46b82a0 JS |
961 | "Use --python=/path/to/python to specify a supported Python." \ |
962 | "Maybe try:" \ | |
963 | " openSUSE Leap 15.3+: zypper install python39" \ | |
964 | " CentOS 8: dnf install python38" | |
c53eeaf7 SH |
965 | fi |
966 | ||
81e2b198 JS |
967 | # Resolve PATH |
968 | python="$(command -v "$python")" | |
81e2b198 JS |
969 | |
970 | # Create a Python virtual environment using our configured python. | |
971 | # The stdout of this script will be the location of a symlink that | |
972 | # points to the configured Python. | |
973 | # Entry point scripts for pip, meson, and sphinx are generated if those | |
974 | # packages are present. | |
975 | ||
976 | # Defaults assumed for now: | |
977 | # - venv is cleared if it exists already; | |
978 | # - venv is allowed to use system packages; | |
0c5f3dcb JS |
979 | # - all setup can be performed offline; |
980 | # - missing packages may be fetched from PyPI, | |
981 | # unless --disable-pypi is passed. | |
81e2b198 JS |
982 | # - pip is not installed into the venv when possible, |
983 | # but ensurepip is called as a fallback when necessary. | |
984 | ||
985 | echo "python determined to be '$python'" | |
986 | echo "python version: $($python --version)" | |
987 | ||
988 | python="$($python -B "${source_path}/python/scripts/mkvenv.py" create pyvenv)" | |
989 | if test "$?" -ne 0 ; then | |
990 | error_exit "python venv creation failed" | |
991 | fi | |
992 | ||
993 | # Suppress writing compiled files | |
994 | python="$python -B" | |
6f6652eb | 995 | mkvenv="$python ${source_path}/python/scripts/mkvenv.py" |
462a6567 | 996 | |
0c5f3dcb JS |
997 | mkvenv_flags="" |
998 | if test "$pypi" = "enabled" ; then | |
999 | mkvenv_flags="--online" | |
1000 | fi | |
1001 | ||
6f6652eb | 1002 | if ! $mkvenv ensure \ |
0c5f3dcb | 1003 | $mkvenv_flags \ |
66e2c6cb JS |
1004 | --dir "${source_path}/python/wheels" \ |
1005 | --diagnose "meson" \ | |
3b087f79 | 1006 | "meson>=0.63.0" ; |
66e2c6cb JS |
1007 | then |
1008 | exit 1 | |
a5665051 | 1009 | fi |
a5665051 | 1010 | |
66e2c6cb JS |
1011 | # At this point, we expect Meson to be installed and available. |
1012 | # We expect mkvenv or pip to have created pyvenv/bin/meson for us. | |
1013 | # We ignore PATH completely here: we want to use the venv's Meson | |
1014 | # *exclusively*. | |
0a01d76f | 1015 | |
66e2c6cb | 1016 | meson="$(cd pyvenv/bin; pwd)/meson" |
0a01d76f | 1017 | |
6f6652eb JS |
1018 | # Conditionally ensure Sphinx is installed. |
1019 | ||
0c5f3dcb JS |
1020 | mkvenv_flags="" |
1021 | if test "$pypi" = "enabled" -a "$docs" = "enabled" ; then | |
1022 | mkvenv_flags="--online" | |
1023 | fi | |
1024 | ||
6f6652eb JS |
1025 | if test "$docs" != "disabled" ; then |
1026 | if ! $mkvenv ensure \ | |
0c5f3dcb | 1027 | $mkvenv_flags \ |
6f6652eb JS |
1028 | --diagnose "sphinx-build" \ |
1029 | "sphinx>=1.6.0" "sphinx-rtd-theme>=0.5.0"; | |
1030 | then | |
1031 | if test "$docs" = "enabled" ; then | |
1032 | exit 1 | |
1033 | fi | |
1034 | echo "Sphinx not found/usable, disabling docs." | |
1035 | docs=disabled | |
1036 | else | |
1037 | docs=enabled | |
1038 | fi | |
1039 | fi | |
1040 | ||
09e93326 | 1041 | # Probe for ninja |
48328880 PB |
1042 | |
1043 | if test -z "$ninja"; then | |
1044 | for c in ninja ninja-build samu; do | |
1045 | if has $c; then | |
1046 | ninja=$(command -v "$c") | |
1047 | break | |
1048 | fi | |
1049 | done | |
09e93326 PB |
1050 | if test -z "$ninja"; then |
1051 | error_exit "Cannot find Ninja" | |
1052 | fi | |
48328880 | 1053 | fi |
a5665051 | 1054 | |
9c83ffd8 PM |
1055 | # Consult white-list to determine whether to enable werror |
1056 | # by default. Only enable by default for git builds | |
9c83ffd8 | 1057 | if test -z "$werror" ; then |
7d7dbf9d | 1058 | if test "$git_submodules_action" != "ignore" && \ |
e633a5c6 | 1059 | { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then |
9c83ffd8 PM |
1060 | werror="yes" |
1061 | else | |
1062 | werror="no" | |
1063 | fi | |
1064 | fi | |
1065 | ||
975ff037 | 1066 | if test "$targetos" = "bogus"; then |
fb59dabd PM |
1067 | # Now that we know that we're not printing the help and that |
1068 | # the compiler works (so the results of the check_defines we used | |
1069 | # to identify the OS are reliable), if we didn't recognize the | |
1070 | # host OS we should stop now. | |
951fedfc | 1071 | error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')" |
fb59dabd PM |
1072 | fi |
1073 | ||
40d6444e | 1074 | if test "$static" = "yes" ; then |
5f2453ac AB |
1075 | if test "$plugins" = "yes"; then |
1076 | error_exit "static and plugins are mutually incompatible" | |
ba4dd2aa AB |
1077 | else |
1078 | plugins="no" | |
5f2453ac | 1079 | fi |
40d6444e | 1080 | fi |
37650689 | 1081 | test "$plugins" = "" && plugins=yes |
40d6444e | 1082 | |
b2634124 | 1083 | cat > $TMPC << EOF |
21d4a791 AK |
1084 | |
1085 | #ifdef __linux__ | |
1086 | # define THREAD __thread | |
1087 | #else | |
1088 | # define THREAD | |
1089 | #endif | |
21d4a791 | 1090 | static THREAD int tls_var; |
21d4a791 | 1091 | int main(void) { return tls_var; } |
40d6444e | 1092 | EOF |
412aeacd | 1093 | |
12781462 | 1094 | if test "$static" = "yes"; then |
eca7a8e6 | 1095 | if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then |
12781462 RH |
1096 | pie="yes" |
1097 | elif test "$pie" = "yes"; then | |
1098 | error_exit "-static-pie not available due to missing toolchain support" | |
1099 | else | |
12781462 RH |
1100 | pie="no" |
1101 | fi | |
a988b4c5 PB |
1102 | elif test "$pie" != "no"; then |
1103 | if compile_prog "-Werror -fPIE -DPIE" "-pie"; then | |
1104 | pie="yes" | |
1105 | elif test "$pie" = "yes"; then | |
1106 | error_exit "PIE not available due to missing toolchain support" | |
1107 | else | |
1108 | echo "Disabling PIE due to missing toolchain support" | |
1109 | pie="no" | |
b9eae9ef | 1110 | fi |
40d6444e AK |
1111 | fi |
1112 | ||
09dada40 | 1113 | ########################################## |
09dada40 | 1114 | |
afb63ebd | 1115 | if test -z "${target_list+xxx}" ; then |
fdb75aef | 1116 | default_targets=yes |
d880a3ba | 1117 | for target in $default_target_list; do |
fdb75aef | 1118 | target_list="$target_list $target" |
d880a3ba PB |
1119 | done |
1120 | target_list="${target_list# }" | |
121afa9e | 1121 | else |
fdb75aef | 1122 | default_targets=no |
89138857 | 1123 | target_list=$(echo "$target_list" | sed -e 's/,/ /g') |
d880a3ba PB |
1124 | for target in $target_list; do |
1125 | # Check that we recognised the target name; this allows a more | |
1126 | # friendly error message than if we let it fall through. | |
1127 | case " $default_target_list " in | |
1128 | *" $target "*) | |
1129 | ;; | |
1130 | *) | |
1131 | error_exit "Unknown target name '$target'" | |
1132 | ;; | |
1133 | esac | |
d880a3ba | 1134 | done |
121afa9e | 1135 | fi |
25b48338 | 1136 | |
f55fe278 PB |
1137 | # see if system emulation was really requested |
1138 | case " $target_list " in | |
1139 | *"-softmmu "*) softmmu=yes | |
1140 | ;; | |
1141 | *) softmmu=no | |
1142 | ;; | |
1143 | esac | |
5327cf48 | 1144 | |
7630156d PMD |
1145 | if test "$tcg" = "auto"; then |
1146 | if test -z "$target_list"; then | |
1147 | tcg="disabled" | |
1148 | else | |
1149 | tcg="enabled" | |
1150 | fi | |
1151 | fi | |
1152 | ||
1153 | if test "$tcg" = "enabled"; then | |
1154 | git_submodules="$git_submodules tests/fp/berkeley-testfloat-3" | |
1155 | git_submodules="$git_submodules tests/fp/berkeley-softfloat-3" | |
1156 | fi | |
1157 | ||
33ab5f24 | 1158 | ########################################## |
7d13299d FB |
1159 | # big/little endian test |
1160 | cat > $TMPC << EOF | |
33ab5f24 MP |
1161 | #if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ |
1162 | # error LITTLE | |
1163 | #endif | |
1164 | int main(void) { return 0; } | |
7d13299d FB |
1165 | EOF |
1166 | ||
33ab5f24 MP |
1167 | if ! compile_prog ; then |
1168 | bigendian="no" | |
61cc919f | 1169 | else |
33ab5f24 MP |
1170 | cat > $TMPC << EOF |
1171 | #if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ | |
1172 | # error BIG | |
1173 | #endif | |
1174 | int main(void) { return 0; } | |
1175 | EOF | |
1176 | ||
1177 | if ! compile_prog ; then | |
1178 | bigendian="yes" | |
1179 | else | |
61cc919f | 1180 | echo big/little test failed |
659eb157 | 1181 | exit 1 |
33ab5f24 | 1182 | fi |
7d13299d FB |
1183 | fi |
1184 | ||
f652e6af AJ |
1185 | ########################################## |
1186 | # fdt probe | |
d599938a | 1187 | |
fbb4121d PB |
1188 | case "$fdt" in |
1189 | auto | enabled | internal) | |
1190 | # Simpler to always update submodule, even if not needed. | |
2d652f24 | 1191 | git_submodules="${git_submodules} dtc" |
fbb4121d PB |
1192 | ;; |
1193 | esac | |
f652e6af | 1194 | |
fd0e6053 JS |
1195 | ######################################## |
1196 | # check if ccache is interfering with | |
1197 | # semantic analysis of macros | |
1198 | ||
5e4dfd3d | 1199 | unset CCACHE_CPP2 |
fd0e6053 JS |
1200 | ccache_cpp2=no |
1201 | cat > $TMPC << EOF | |
1202 | static const int Z = 1; | |
1203 | #define fn() ({ Z; }) | |
1204 | #define TAUT(X) ((X) == Z) | |
1205 | #define PAREN(X, Y) (X == Y) | |
1206 | #define ID(X) (X) | |
8a0afbb2 | 1207 | int main(void) |
fd0e6053 JS |
1208 | { |
1209 | int x = 0, y = 0; | |
1210 | x = ID(x); | |
1211 | x = fn(); | |
1212 | fn(); | |
1213 | if (PAREN(x, y)) return 0; | |
1214 | if (TAUT(Z)) return 0; | |
1215 | return 0; | |
1216 | } | |
1217 | EOF | |
1218 | ||
1219 | if ! compile_object "-Werror"; then | |
1220 | ccache_cpp2=yes | |
1221 | fi | |
1222 | ||
cd362def PB |
1223 | ########################################## |
1224 | # functions to probe cross compilers | |
1225 | ||
1226 | container="no" | |
60f999b7 | 1227 | runc="" |
47fdc8fb | 1228 | if test $use_containers = "yes" && (has "docker" || has "podman"); then |
c4575b59 PB |
1229 | case $($python "$source_path"/tests/docker/docker.py probe) in |
1230 | *docker) container=docker ;; | |
1231 | podman) container=podman ;; | |
1232 | no) container=no ;; | |
1233 | esac | |
a3e28f81 PB |
1234 | if test "$container" != "no"; then |
1235 | docker_py="$python $source_path/tests/docker/docker.py --engine $container" | |
60f999b7 | 1236 | runc=$($python "$source_path"/tests/docker/docker.py probe) |
a3e28f81 | 1237 | fi |
cd362def PB |
1238 | fi |
1239 | ||
1240 | # cross compilers defaults, can be overridden with --cross-cc-ARCH | |
5adb43be PB |
1241 | : ${cross_prefix_aarch64="aarch64-linux-gnu-"} |
1242 | : ${cross_prefix_aarch64_be="$cross_prefix_aarch64"} | |
1243 | : ${cross_prefix_alpha="alpha-linux-gnu-"} | |
1244 | : ${cross_prefix_arm="arm-linux-gnueabihf-"} | |
1245 | : ${cross_prefix_armeb="$cross_prefix_arm"} | |
1246 | : ${cross_prefix_hexagon="hexagon-unknown-linux-musl-"} | |
34bb43b0 | 1247 | : ${cross_prefix_loongarch64="loongarch64-unknown-linux-gnu-"} |
5adb43be PB |
1248 | : ${cross_prefix_hppa="hppa-linux-gnu-"} |
1249 | : ${cross_prefix_i386="i686-linux-gnu-"} | |
1250 | : ${cross_prefix_m68k="m68k-linux-gnu-"} | |
1251 | : ${cross_prefix_microblaze="microblaze-linux-musl-"} | |
1252 | : ${cross_prefix_mips64el="mips64el-linux-gnuabi64-"} | |
1253 | : ${cross_prefix_mips64="mips64-linux-gnuabi64-"} | |
1254 | : ${cross_prefix_mipsel="mipsel-linux-gnu-"} | |
1255 | : ${cross_prefix_mips="mips-linux-gnu-"} | |
1256 | : ${cross_prefix_nios2="nios2-linux-gnu-"} | |
1257 | : ${cross_prefix_ppc="powerpc-linux-gnu-"} | |
1258 | : ${cross_prefix_ppc64="powerpc64-linux-gnu-"} | |
1259 | : ${cross_prefix_ppc64le="$cross_prefix_ppc64"} | |
1260 | : ${cross_prefix_riscv64="riscv64-linux-gnu-"} | |
1261 | : ${cross_prefix_s390x="s390x-linux-gnu-"} | |
1262 | : ${cross_prefix_sh4="sh4-linux-gnu-"} | |
1263 | : ${cross_prefix_sparc64="sparc64-linux-gnu-"} | |
1264 | : ${cross_prefix_sparc="$cross_prefix_sparc64"} | |
1265 | : ${cross_prefix_x86_64="x86_64-linux-gnu-"} | |
1266 | ||
cd362def PB |
1267 | : ${cross_cc_aarch64_be="$cross_cc_aarch64"} |
1268 | : ${cross_cc_cflags_aarch64_be="-mbig-endian"} | |
46af66ed | 1269 | : ${cross_cc_armeb="$cross_cc_arm"} |
cd362def PB |
1270 | : ${cross_cc_cflags_armeb="-mbig-endian"} |
1271 | : ${cross_cc_hexagon="hexagon-unknown-linux-musl-clang"} | |
fc2622f6 | 1272 | : ${cross_cc_cflags_hexagon="-mv73 -O2 -static"} |
cd362def | 1273 | : ${cross_cc_cflags_i386="-m32"} |
d44f2f96 | 1274 | : ${cross_cc_cflags_ppc="-m32 -mbig-endian"} |
cd362def PB |
1275 | : ${cross_cc_cflags_ppc64="-m64 -mbig-endian"} |
1276 | : ${cross_cc_ppc64le="$cross_cc_ppc64"} | |
1277 | : ${cross_cc_cflags_ppc64le="-m64 -mlittle-endian"} | |
cd362def | 1278 | : ${cross_cc_cflags_sparc64="-m64 -mcpu=ultrasparc"} |
46af66ed PB |
1279 | : ${cross_cc_sparc="$cross_cc_sparc64"} |
1280 | : ${cross_cc_cflags_sparc="-m32 -mcpu=supersparc"} | |
cd362def PB |
1281 | : ${cross_cc_cflags_x86_64="-m64"} |
1282 | ||
5adb43be | 1283 | compute_target_variable() { |
92e288fc | 1284 | eval "$2=" |
5adb43be PB |
1285 | if eval test -n "\"\${cross_prefix_$1}\""; then |
1286 | if eval has "\"\${cross_prefix_$1}\$3\""; then | |
1287 | eval "$2=\"\${cross_prefix_$1}\$3\"" | |
1288 | fi | |
1289 | fi | |
1290 | } | |
cd362def | 1291 | |
35fd22b0 PB |
1292 | have_target() { |
1293 | for i; do | |
1294 | case " $target_list " in | |
1295 | *" $i "*) return 0;; | |
1296 | *) ;; | |
1297 | esac | |
1298 | done | |
1299 | return 1 | |
1300 | } | |
1301 | ||
52f08dea PB |
1302 | # probe_target_compiler TARGET |
1303 | # | |
1304 | # Look for a compiler for the given target, either native or cross. | |
1305 | # Set variables target_* if a compiler is found, and container_cross_* | |
1306 | # if a Docker-based cross-compiler image is known for the target. | |
1307 | # Set got_cross_cc to yes/no depending on whether a non-container-based | |
1308 | # compiler was found. | |
1309 | # | |
1310 | # If TARGET is a user-mode emulation target, also set build_static to | |
1311 | # "y" if static linking is possible. | |
1312 | # | |
cd362def PB |
1313 | probe_target_compiler() { |
1314 | # reset all output variables | |
92e288fc | 1315 | got_cross_cc=no |
cd362def PB |
1316 | container_image= |
1317 | container_hosts= | |
1318 | container_cross_cc= | |
87eb014c | 1319 | container_cross_ar= |
cd362def PB |
1320 | container_cross_as= |
1321 | container_cross_ld= | |
87eb014c PB |
1322 | container_cross_nm= |
1323 | container_cross_objcopy= | |
1324 | container_cross_ranlib= | |
1325 | container_cross_strip= | |
cd362def | 1326 | |
52f08dea PB |
1327 | target_arch=${1%%-*} |
1328 | case $target_arch in | |
cd362def PB |
1329 | aarch64) container_hosts="x86_64 aarch64" ;; |
1330 | alpha) container_hosts=x86_64 ;; | |
1331 | arm) container_hosts="x86_64 aarch64" ;; | |
1332 | cris) container_hosts=x86_64 ;; | |
1333 | hexagon) container_hosts=x86_64 ;; | |
1334 | hppa) container_hosts=x86_64 ;; | |
1335 | i386) container_hosts=x86_64 ;; | |
b70ec50b | 1336 | loongarch64) container_hosts=x86_64 ;; |
cd362def PB |
1337 | m68k) container_hosts=x86_64 ;; |
1338 | microblaze) container_hosts=x86_64 ;; | |
1339 | mips64el) container_hosts=x86_64 ;; | |
1340 | mips64) container_hosts=x86_64 ;; | |
1341 | mipsel) container_hosts=x86_64 ;; | |
1342 | mips) container_hosts=x86_64 ;; | |
1343 | nios2) container_hosts=x86_64 ;; | |
1344 | ppc) container_hosts=x86_64 ;; | |
1345 | ppc64|ppc64le) container_hosts=x86_64 ;; | |
1346 | riscv64) container_hosts=x86_64 ;; | |
1347 | s390x) container_hosts=x86_64 ;; | |
1348 | sh4) container_hosts=x86_64 ;; | |
1349 | sparc64) container_hosts=x86_64 ;; | |
1350 | tricore) container_hosts=x86_64 ;; | |
1351 | x86_64) container_hosts="aarch64 ppc64el x86_64" ;; | |
1352 | xtensa*) container_hosts=x86_64 ;; | |
1353 | esac | |
1354 | ||
1355 | for host in $container_hosts; do | |
1356 | test "$container" != no || continue | |
1357 | test "$host" = "$cpu" || continue | |
52f08dea | 1358 | case $target_arch in |
cd362def PB |
1359 | aarch64) |
1360 | # We don't have any bigendian build tools so we only use this for AArch64 | |
1361 | container_image=debian-arm64-cross | |
5adb43be PB |
1362 | container_cross_prefix=aarch64-linux-gnu- |
1363 | container_cross_cc=${container_cross_prefix}gcc-10 | |
cd362def PB |
1364 | ;; |
1365 | alpha) | |
1366 | container_image=debian-alpha-cross | |
5adb43be | 1367 | container_cross_prefix=alpha-linux-gnu- |
cd362def PB |
1368 | ;; |
1369 | arm) | |
1370 | # We don't have any bigendian build tools so we only use this for ARM | |
1371 | container_image=debian-armhf-cross | |
5adb43be | 1372 | container_cross_prefix=arm-linux-gnueabihf- |
cd362def PB |
1373 | ;; |
1374 | cris) | |
1375 | container_image=fedora-cris-cross | |
5adb43be | 1376 | container_cross_prefix=cris-linux-gnu- |
cd362def PB |
1377 | ;; |
1378 | hexagon) | |
1379 | container_image=debian-hexagon-cross | |
5adb43be PB |
1380 | container_cross_prefix=hexagon-unknown-linux-musl- |
1381 | container_cross_cc=${container_cross_prefix}clang | |
cd362def PB |
1382 | ;; |
1383 | hppa) | |
1384 | container_image=debian-hppa-cross | |
5adb43be | 1385 | container_cross_prefix=hppa-linux-gnu- |
cd362def PB |
1386 | ;; |
1387 | i386) | |
1388 | container_image=fedora-i386-cross | |
5adb43be | 1389 | container_cross_prefix= |
cd362def | 1390 | ;; |
b70ec50b RH |
1391 | loongarch64) |
1392 | container_image=debian-loongarch-cross | |
1393 | container_cross_prefix=loongarch64-unknown-linux-gnu- | |
1394 | ;; | |
cd362def PB |
1395 | m68k) |
1396 | container_image=debian-m68k-cross | |
5adb43be | 1397 | container_cross_prefix=m68k-linux-gnu- |
cd362def PB |
1398 | ;; |
1399 | microblaze) | |
1400 | container_image=debian-microblaze-cross | |
5adb43be | 1401 | container_cross_prefix=microblaze-linux-musl- |
cd362def PB |
1402 | ;; |
1403 | mips64el) | |
1404 | container_image=debian-mips64el-cross | |
5adb43be | 1405 | container_cross_prefix=mips64el-linux-gnuabi64- |
cd362def PB |
1406 | ;; |
1407 | mips64) | |
1408 | container_image=debian-mips64-cross | |
5adb43be | 1409 | container_cross_prefix=mips64-linux-gnuabi64- |
cd362def PB |
1410 | ;; |
1411 | mipsel) | |
1412 | container_image=debian-mipsel-cross | |
5adb43be | 1413 | container_cross_prefix=mipsel-linux-gnu- |
cd362def PB |
1414 | ;; |
1415 | mips) | |
1416 | container_image=debian-mips-cross | |
5adb43be | 1417 | container_cross_prefix=mips-linux-gnu- |
cd362def PB |
1418 | ;; |
1419 | nios2) | |
1420 | container_image=debian-nios2-cross | |
5adb43be | 1421 | container_cross_prefix=nios2-linux-gnu- |
cd362def PB |
1422 | ;; |
1423 | ppc) | |
1424 | container_image=debian-powerpc-test-cross | |
5adb43be PB |
1425 | container_cross_prefix=powerpc-linux-gnu- |
1426 | container_cross_cc=${container_cross_prefix}gcc-10 | |
cd362def PB |
1427 | ;; |
1428 | ppc64|ppc64le) | |
1429 | container_image=debian-powerpc-test-cross | |
705c881f | 1430 | container_cross_prefix=powerpc${target_arch#ppc}-linux-gnu- |
5adb43be | 1431 | container_cross_cc=${container_cross_prefix}gcc-10 |
cd362def PB |
1432 | ;; |
1433 | riscv64) | |
1434 | container_image=debian-riscv64-test-cross | |
5adb43be | 1435 | container_cross_prefix=riscv64-linux-gnu- |
cd362def PB |
1436 | ;; |
1437 | s390x) | |
1438 | container_image=debian-s390x-cross | |
5adb43be | 1439 | container_cross_prefix=s390x-linux-gnu- |
cd362def PB |
1440 | ;; |
1441 | sh4) | |
1442 | container_image=debian-sh4-cross | |
5adb43be | 1443 | container_cross_prefix=sh4-linux-gnu- |
cd362def PB |
1444 | ;; |
1445 | sparc64) | |
1446 | container_image=debian-sparc64-cross | |
5adb43be | 1447 | container_cross_prefix=sparc64-linux-gnu- |
cd362def PB |
1448 | ;; |
1449 | tricore) | |
1450 | container_image=debian-tricore-cross | |
5adb43be | 1451 | container_cross_prefix=tricore- |
cd362def PB |
1452 | container_cross_as=tricore-as |
1453 | container_cross_ld=tricore-ld | |
5adb43be | 1454 | break |
cd362def PB |
1455 | ;; |
1456 | x86_64) | |
1457 | container_image=debian-amd64-cross | |
5adb43be | 1458 | container_cross_prefix=x86_64-linux-gnu- |
cd362def PB |
1459 | ;; |
1460 | xtensa*) | |
cd362def PB |
1461 | container_hosts=x86_64 |
1462 | container_image=debian-xtensa-cross | |
1463 | ||
1464 | # default to the dc232b cpu | |
5adb43be | 1465 | container_cross_prefix=/opt/2020.07/xtensa-dc232b-elf/bin/xtensa-dc232b-elf- |
cd362def PB |
1466 | ;; |
1467 | esac | |
5adb43be | 1468 | : ${container_cross_cc:=${container_cross_prefix}gcc} |
87eb014c | 1469 | : ${container_cross_ar:=${container_cross_prefix}ar} |
5adb43be PB |
1470 | : ${container_cross_as:=${container_cross_prefix}as} |
1471 | : ${container_cross_ld:=${container_cross_prefix}ld} | |
87eb014c PB |
1472 | : ${container_cross_nm:=${container_cross_prefix}nm} |
1473 | : ${container_cross_objcopy:=${container_cross_prefix}objcopy} | |
1474 | : ${container_cross_ranlib:=${container_cross_prefix}ranlib} | |
1475 | : ${container_cross_strip:=${container_cross_prefix}strip} | |
cd362def PB |
1476 | done |
1477 | ||
92e288fc | 1478 | try=cross |
52f08dea | 1479 | case "$target_arch:$cpu" in |
26e72533 PB |
1480 | aarch64_be:aarch64 | \ |
1481 | armeb:arm | \ | |
640aabc8 | 1482 | i386:x86_64 | \ |
26e72533 | 1483 | mips*:mips64 | \ |
d44f2f96 | 1484 | ppc*:ppc64 | \ |
26e72533 | 1485 | sparc:sparc64 | \ |
640aabc8 | 1486 | "$cpu:$cpu") |
92e288fc | 1487 | try='native cross' ;; |
640aabc8 | 1488 | esac |
92e288fc | 1489 | eval "target_cflags=\${cross_cc_cflags_$target_arch}" |
b3b5472d PM |
1490 | for thistry in $try; do |
1491 | case $thistry in | |
92e288fc PB |
1492 | native) |
1493 | target_cc=$cc | |
1494 | target_ccas=$ccas | |
1495 | target_ar=$ar | |
1496 | target_as=$as | |
1497 | target_ld=$ld | |
1498 | target_nm=$nm | |
1499 | target_objcopy=$objcopy | |
1500 | target_ranlib=$ranlib | |
1501 | target_strip=$strip | |
1502 | ;; | |
1503 | cross) | |
1504 | target_cc= | |
1505 | if eval test -n "\"\${cross_cc_$target_arch}\""; then | |
1506 | if eval has "\"\${cross_cc_$target_arch}\""; then | |
1507 | eval "target_cc=\"\${cross_cc_$target_arch}\"" | |
1508 | fi | |
1509 | else | |
1510 | compute_target_variable $target_arch target_cc gcc | |
1511 | fi | |
1512 | target_ccas=$target_cc | |
1513 | compute_target_variable $target_arch target_ar ar | |
1514 | compute_target_variable $target_arch target_as as | |
1515 | compute_target_variable $target_arch target_ld ld | |
1516 | compute_target_variable $target_arch target_nm nm | |
1517 | compute_target_variable $target_arch target_objcopy objcopy | |
1518 | compute_target_variable $target_arch target_ranlib ranlib | |
1519 | compute_target_variable $target_arch target_strip strip | |
1520 | ;; | |
1521 | esac | |
1522 | ||
1523 | if test -n "$target_cc"; then | |
1524 | case $target_arch in | |
1525 | i386|x86_64) | |
1526 | if $target_cc --version | grep -qi "clang"; then | |
1527 | continue | |
1528 | fi | |
1529 | ;; | |
1530 | esac | |
1531 | elif test -n "$target_as" && test -n "$target_ld"; then | |
1532 | # Special handling for assembler only targets | |
1533 | case $target in | |
1534 | tricore-softmmu) | |
1535 | build_static= | |
1536 | got_cross_cc=yes | |
1537 | break | |
1538 | ;; | |
1539 | *) | |
1540 | continue | |
1541 | ;; | |
1542 | esac | |
1543 | else | |
1544 | continue | |
1545 | fi | |
1546 | ||
1547 | write_c_skeleton | |
1548 | case $1 in | |
1549 | *-softmmu) | |
1550 | if do_compiler "$target_cc" $target_cflags -o $TMPO -c $TMPC && | |
1551 | do_compiler "$target_cc" $target_cflags -r -nostdlib -o "${TMPDIR1}/${TMPB}2.o" "$TMPO" -lgcc; then | |
1552 | got_cross_cc=yes | |
1553 | break | |
1554 | fi | |
1555 | ;; | |
1556 | *) | |
1557 | if do_compiler "$target_cc" $target_cflags -o $TMPE $TMPC -static ; then | |
1558 | build_static=y | |
1559 | got_cross_cc=yes | |
1560 | break | |
1561 | fi | |
1562 | if do_compiler "$target_cc" $target_cflags -o $TMPE $TMPC ; then | |
1563 | build_static= | |
1564 | got_cross_cc=yes | |
1565 | break | |
2ad60f6f PB |
1566 | fi |
1567 | ;; | |
1568 | esac | |
92e288fc PB |
1569 | done |
1570 | if test $got_cross_cc != yes; then | |
1571 | build_static= | |
1572 | target_cc= | |
1573 | target_ccas= | |
92e288fc PB |
1574 | target_ar= |
1575 | target_as= | |
1576 | target_ld= | |
1577 | target_nm= | |
1578 | target_objcopy= | |
1579 | target_ranlib= | |
1580 | target_strip= | |
2ad60f6f | 1581 | fi |
fde10960 | 1582 | test -n "$target_cc" |
cd362def PB |
1583 | } |
1584 | ||
1585 | write_target_makefile() { | |
e81785ab | 1586 | echo "EXTRA_CFLAGS=$target_cflags" |
0825cae0 PB |
1587 | if test -z "$target_cc" && test -z "$target_as"; then |
1588 | test -z "$container_image" && error_exit "Internal error: could not find cross compiler for $1?" | |
1589 | echo "$1: docker-image-$container_image" >> Makefile.prereqs | |
1590 | if test -n "$container_cross_cc"; then | |
1591 | echo "CC=$docker_py cc --cc $container_cross_cc -i qemu/$container_image -s $source_path --" | |
1592 | echo "CCAS=$docker_py cc --cc $container_cross_cc -i qemu/$container_image -s $source_path --" | |
1593 | fi | |
1594 | echo "AR=$docker_py cc --cc $container_cross_ar -i qemu/$container_image -s $source_path --" | |
1595 | echo "AS=$docker_py cc --cc $container_cross_as -i qemu/$container_image -s $source_path --" | |
1596 | echo "LD=$docker_py cc --cc $container_cross_ld -i qemu/$container_image -s $source_path --" | |
1597 | echo "NM=$docker_py cc --cc $container_cross_nm -i qemu/$container_image -s $source_path --" | |
1598 | echo "OBJCOPY=$docker_py cc --cc $container_cross_objcopy -i qemu/$container_image -s $source_path --" | |
1599 | echo "RANLIB=$docker_py cc --cc $container_cross_ranlib -i qemu/$container_image -s $source_path --" | |
1600 | echo "STRIP=$docker_py cc --cc $container_cross_strip -i qemu/$container_image -s $source_path --" | |
1601 | else | |
1602 | if test -n "$target_cc"; then | |
1603 | echo "CC=$target_cc" | |
1604 | echo "CCAS=$target_ccas" | |
1605 | fi | |
1606 | if test -n "$target_ar"; then | |
1607 | echo "AR=$target_ar" | |
1608 | fi | |
1609 | if test -n "$target_as"; then | |
1610 | echo "AS=$target_as" | |
1611 | fi | |
1612 | if test -n "$target_ld"; then | |
1613 | echo "LD=$target_ld" | |
1614 | fi | |
1615 | if test -n "$target_nm"; then | |
1616 | echo "NM=$target_nm" | |
1617 | fi | |
1618 | if test -n "$target_objcopy"; then | |
1619 | echo "OBJCOPY=$target_objcopy" | |
1620 | fi | |
1621 | if test -n "$target_ranlib"; then | |
1622 | echo "RANLIB=$target_ranlib" | |
1623 | fi | |
1624 | if test -n "$target_strip"; then | |
1625 | echo "STRIP=$target_strip" | |
1626 | fi | |
cd362def | 1627 | fi |
cd362def PB |
1628 | } |
1629 | ||
55116968 JR |
1630 | ########################################## |
1631 | # check for vfio_user_server | |
1632 | ||
1633 | case "$vfio_user_server" in | |
1634 | enabled ) | |
1635 | if test "$git_submodules_action" != "ignore"; then | |
1636 | git_submodules="${git_submodules} subprojects/libvfio-user" | |
1637 | fi | |
1638 | ;; | |
1639 | esac | |
1640 | ||
33ab4787 PB |
1641 | ####################################### |
1642 | # cross-compiled firmware targets | |
1643 | ||
ad388845 PB |
1644 | # Set up build tree symlinks that point back into the source tree |
1645 | # (these can be both files and directories). | |
1646 | # Caution: avoid adding files or directories here using wildcards. This | |
1647 | # will result in problems later if a new file matching the wildcard is | |
1648 | # added to the source tree -- nothing will cause configure to be rerun | |
1649 | # so the build tree will be missing the link back to the new file, and | |
1650 | # tests might fail. Prefer to keep the relevant files in their own | |
1651 | # directory and symlink the directory instead. | |
1652 | LINKS="Makefile" | |
201aa17e | 1653 | LINKS="$LINKS docs/config" |
ad388845 PB |
1654 | LINKS="$LINKS pc-bios/optionrom/Makefile" |
1655 | LINKS="$LINKS pc-bios/s390-ccw/Makefile" | |
d695918f | 1656 | LINKS="$LINKS pc-bios/vof/Makefile" |
ad388845 PB |
1657 | LINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit |
1658 | LINKS="$LINKS tests/avocado tests/data" | |
1659 | LINKS="$LINKS tests/qemu-iotests/check" | |
1660 | LINKS="$LINKS python" | |
1661 | LINKS="$LINKS contrib/plugins/Makefile " | |
1662 | for f in $LINKS ; do | |
1663 | if [ -e "$source_path/$f" ]; then | |
ad388845 PB |
1664 | symlink "$source_path/$f" "$f" |
1665 | fi | |
1666 | done | |
1667 | ||
b898bf28 PB |
1668 | echo "# Automatically generated by configure - do not modify" > Makefile.prereqs |
1669 | ||
ca35f780 PB |
1670 | # Mac OS X ships with a broken assembler |
1671 | roms= | |
35fd22b0 PB |
1672 | if have_target i386-softmmu x86_64-softmmu && \ |
1673 | test "$targetos" != "darwin" && test "$targetos" != "sunos" && \ | |
1674 | test "$targetos" != "haiku" && \ | |
61cbb356 | 1675 | probe_target_compiler i386-softmmu; then |
7089977a PB |
1676 | roms="pc-bios/optionrom" |
1677 | config_mak=pc-bios/optionrom/config.mak | |
1678 | echo "# Automatically generated by configure - do not modify" > $config_mak | |
1679 | echo "TOPSRC_DIR=$source_path" >> $config_mak | |
fde10960 | 1680 | write_target_makefile >> $config_mak |
ca35f780 | 1681 | fi |
ca35f780 | 1682 | |
35fd22b0 PB |
1683 | if have_target ppc-softmmu ppc64-softmmu && \ |
1684 | probe_target_compiler ppc-softmmu; then | |
76ca98b0 | 1685 | roms="$roms pc-bios/vof" |
d695918f PB |
1686 | config_mak=pc-bios/vof/config.mak |
1687 | echo "# Automatically generated by configure - do not modify" > $config_mak | |
1688 | echo "SRC_DIR=$source_path/pc-bios/vof" >> $config_mak | |
fde10960 | 1689 | write_target_makefile >> $config_mak |
d695918f PB |
1690 | fi |
1691 | ||
9ffed426 PB |
1692 | # Only build s390-ccw bios if the compiler has -march=z900 or -march=z10 |
1693 | # (which is the lowest architecture level that Clang supports) | |
35fd22b0 | 1694 | if have_target s390x-softmmu && probe_target_compiler s390x-softmmu; then |
fde10960 AB |
1695 | write_c_skeleton |
1696 | do_compiler "$target_cc" $target_cc_cflags -march=z900 -o $TMPO -c $TMPC | |
1697 | has_z900=$? | |
1698 | if [ $has_z900 = 0 ] || do_compiler "$target_cc" $target_cc_cflags -march=z10 -msoft-float -Werror -o $TMPO -c $TMPC; then | |
1699 | if [ $has_z900 != 0 ]; then | |
1700 | echo "WARNING: Your compiler does not support the z900!" | |
1701 | echo " The s390-ccw bios will only work with guest CPUs >= z10." | |
a5b2afd5 | 1702 | fi |
76ca98b0 | 1703 | roms="$roms pc-bios/s390-ccw" |
9ffed426 PB |
1704 | config_mak=pc-bios/s390-ccw/config-host.mak |
1705 | echo "# Automatically generated by configure - do not modify" > $config_mak | |
1706 | echo "SRC_PATH=$source_path/pc-bios/s390-ccw" >> $config_mak | |
fde10960 | 1707 | write_target_makefile >> $config_mak |
1ef6bfc2 PMD |
1708 | # SLOF is required for building the s390-ccw firmware on s390x, |
1709 | # since it is using the libnet code from SLOF for network booting. | |
2d652f24 | 1710 | git_submodules="${git_submodules} roms/SLOF" |
2e33c3f8 | 1711 | fi |
9933c305 CB |
1712 | fi |
1713 | ||
9ffed426 PB |
1714 | ####################################### |
1715 | # generate config-host.mak | |
1716 | ||
35a7a6fc | 1717 | if ! (GIT="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then |
7d7dbf9d | 1718 | exit 1 |
5d91a2ed | 1719 | fi |
5d91a2ed | 1720 | |
98ec69ac | 1721 | config_host_mak="config-host.mak" |
98ec69ac | 1722 | |
98ec69ac | 1723 | echo "# Automatically generated by configure - do not modify" > $config_host_mak |
98ec69ac | 1724 | echo >> $config_host_mak |
98ec69ac | 1725 | |
e6c3b0f7 | 1726 | echo all: >> $config_host_mak |
cc84d63a | 1727 | echo "GIT=$git" >> $config_host_mak |
aef45d51 | 1728 | echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak |
7d7dbf9d | 1729 | echo "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak |
804edf29 | 1730 | |
f8393946 | 1731 | if test "$debug_tcg" = "yes" ; then |
2358a494 | 1732 | echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak |
f8393946 | 1733 | fi |
67b915a5 | 1734 | if test "$mingw32" = "yes" ; then |
98ec69ac | 1735 | echo "CONFIG_WIN32=y" >> $config_host_mak |
954ed68f PB |
1736 | echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER-QEMU}" >> $config_host_mak |
1737 | echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO-Linux}" >> $config_host_mak | |
1738 | echo "QEMU_GA_VERSION=${QEMU_GA_VERSION-$(cat "$source_path"/VERSION)}" >> $config_host_mak | |
210fa556 | 1739 | else |
35f4df27 | 1740 | echo "CONFIG_POSIX=y" >> $config_host_mak |
dffcb71c MM |
1741 | fi |
1742 | ||
1743 | if test "$linux" = "yes" ; then | |
1744 | echo "CONFIG_LINUX=y" >> $config_host_mak | |
67b915a5 | 1745 | fi |
128ab2ff | 1746 | |
83fb7adf | 1747 | if test "$darwin" = "yes" ; then |
98ec69ac | 1748 | echo "CONFIG_DARWIN=y" >> $config_host_mak |
83fb7adf | 1749 | fi |
b29fe3ed | 1750 | |
ec530c81 | 1751 | if test "$solaris" = "yes" ; then |
98ec69ac | 1752 | echo "CONFIG_SOLARIS=y" >> $config_host_mak |
ec530c81 | 1753 | fi |
98ec69ac | 1754 | echo "SRC_PATH=$source_path" >> $config_host_mak |
2b1f35b9 | 1755 | echo "TARGET_DIRS=$target_list" >> $config_host_mak |
277abf15 | 1756 | |
83fb7adf | 1757 | # XXX: suppress that |
7d3505c5 | 1758 | if [ "$bsd" = "yes" ] ; then |
2358a494 | 1759 | echo "CONFIG_BSD=y" >> $config_host_mak |
7d3505c5 FB |
1760 | fi |
1761 | ||
40e8c6f4 AB |
1762 | if test "$plugins" = "yes" ; then |
1763 | echo "CONFIG_PLUGIN=y" >> $config_host_mak | |
40e8c6f4 AB |
1764 | fi |
1765 | ||
b1863ccc AB |
1766 | if test -n "$gdb_bin"; then |
1767 | gdb_version=$($gdb_bin --version | head -n 1) | |
d6a66c81 | 1768 | if version_ge ${gdb_version##* } 9.1; then |
b1863ccc | 1769 | echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak |
4b424c75 | 1770 | gdb_arches=$($python "$source_path/scripts/probe-gdb-support.py" $gdb_bin) |
48543dd7 AB |
1771 | else |
1772 | gdb_bin="" | |
b1863ccc | 1773 | fi |
f48e590a AB |
1774 | fi |
1775 | ||
c4575b59 PB |
1776 | if test "$container" != no; then |
1777 | echo "ENGINE=$container" >> $config_host_mak | |
60f999b7 | 1778 | echo "RUNC=$runc" >> $config_host_mak |
c4575b59 | 1779 | fi |
98ec69ac | 1780 | echo "ROMS=$roms" >> $config_host_mak |
804edf29 | 1781 | echo "MAKE=$make" >> $config_host_mak |
c886edfb | 1782 | echo "PYTHON=$python" >> $config_host_mak |
39d87c8c | 1783 | echo "GENISOIMAGE=$genisoimage" >> $config_host_mak |
a5665051 | 1784 | echo "MESON=$meson" >> $config_host_mak |
09e93326 | 1785 | echo "NINJA=$ninja" >> $config_host_mak |
877c5567 | 1786 | echo "PKG_CONFIG=${pkg_config}" >> $config_host_mak |
804edf29 | 1787 | echo "CC=$cc" >> $config_host_mak |
804edf29 | 1788 | echo "EXESUF=$EXESUF" >> $config_host_mak |
804edf29 | 1789 | |
6efd7517 PM |
1790 | # use included Linux headers |
1791 | if test "$linux" = "yes" ; then | |
a307beb6 | 1792 | mkdir -p linux-headers |
6efd7517 | 1793 | case "$cpu" in |
4da270be | 1794 | i386|x86_64) |
08312a63 | 1795 | linux_arch=x86 |
6efd7517 | 1796 | ;; |
d8ff892d | 1797 | ppc|ppc64) |
08312a63 | 1798 | linux_arch=powerpc |
6efd7517 PM |
1799 | ;; |
1800 | s390x) | |
08312a63 PM |
1801 | linux_arch=s390 |
1802 | ;; | |
1f080313 CF |
1803 | aarch64) |
1804 | linux_arch=arm64 | |
1805 | ;; | |
dfcf900b WX |
1806 | loongarch*) |
1807 | linux_arch=loongarch | |
1808 | ;; | |
222e7d11 SL |
1809 | mips64) |
1810 | linux_arch=mips | |
1811 | ;; | |
08312a63 PM |
1812 | *) |
1813 | # For most CPUs the kernel architecture name and QEMU CPU name match. | |
1814 | linux_arch="$cpu" | |
6efd7517 PM |
1815 | ;; |
1816 | esac | |
08312a63 PM |
1817 | # For non-KVM architectures we will not have asm headers |
1818 | if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then | |
1819 | symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm | |
1820 | fi | |
6efd7517 PM |
1821 | fi |
1822 | ||
1d14ffa9 | 1823 | for target in $target_list; do |
fdb75aef | 1824 | target_dir="$target" |
57a93f16 | 1825 | target_name=$(echo $target | cut -d '-' -f 1)$EXESUF |
64708615 | 1826 | mkdir -p "$target_dir" |
fdb75aef PB |
1827 | case $target in |
1828 | *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;; | |
1829 | *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;; | |
1830 | esac | |
1831 | done | |
7d13299d | 1832 | |
fdb75aef PB |
1833 | if test "$default_targets" = "yes"; then |
1834 | echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak | |
1835 | fi | |
a540f158 | 1836 | |
fd0e6053 JS |
1837 | if test "$ccache_cpp2" = "yes"; then |
1838 | echo "export CCACHE_CPP2=y" >> $config_host_mak | |
1839 | fi | |
1840 | ||
cd362def | 1841 | # tests/tcg configuration |
b898bf28 | 1842 | (config_host_mak=tests/tcg/config-host.mak |
d674342e | 1843 | mkdir -p tests/tcg |
cd362def PB |
1844 | echo "# Automatically generated by configure - do not modify" > $config_host_mak |
1845 | echo "SRC_PATH=$source_path" >> $config_host_mak | |
1846 | echo "HOST_CC=$host_cc" >> $config_host_mak | |
1847 | ||
48543dd7 AB |
1848 | # versioned checked in the main config_host.mak above |
1849 | if test -n "$gdb_bin"; then | |
1850 | echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak | |
1851 | fi | |
d1d94d96 PB |
1852 | if test "$plugins" = "yes" ; then |
1853 | echo "CONFIG_PLUGIN=y" >> $config_host_mak | |
1854 | fi | |
48543dd7 | 1855 | |
cd362def PB |
1856 | tcg_tests_targets= |
1857 | for target in $target_list; do | |
1858 | arch=${target%%-*} | |
1859 | ||
cd362def | 1860 | case $target in |
c48a5c47 PB |
1861 | xtensa*-linux-user) |
1862 | # the toolchain is not complete with headers, only build softmmu tests | |
1863 | continue | |
1864 | ;; | |
cd362def | 1865 | *-softmmu) |
64708615 | 1866 | test -f "$source_path/tests/tcg/$arch/Makefile.softmmu-target" || continue |
cd362def PB |
1867 | qemu="qemu-system-$arch" |
1868 | ;; | |
1869 | *-linux-user|*-bsd-user) | |
1870 | qemu="qemu-$arch" | |
1871 | ;; | |
1872 | esac | |
1873 | ||
fde10960 | 1874 | if probe_target_compiler $target || test -n "$container_image"; then |
0825cae0 | 1875 | test -n "$container_image" && build_static=y |
d674342e | 1876 | mkdir -p "tests/tcg/$target" |
c7022a70 | 1877 | config_target_mak=tests/tcg/$target/config-target.mak |
d674342e | 1878 | ln -sf "$source_path/tests/tcg/Makefile.target" "tests/tcg/$target/Makefile" |
c7022a70 PB |
1879 | echo "# Automatically generated by configure - do not modify" > "$config_target_mak" |
1880 | echo "TARGET_NAME=$arch" >> "$config_target_mak" | |
a3e28f81 | 1881 | echo "TARGET=$target" >> "$config_target_mak" |
c7022a70 | 1882 | write_target_makefile "build-tcg-tests-$target" >> "$config_target_mak" |
15b273f8 | 1883 | echo "BUILD_STATIC=$build_static" >> "$config_target_mak" |
c7022a70 | 1884 | echo "QEMU=$PWD/$qemu" >> "$config_target_mak" |
bcbc36a9 AB |
1885 | |
1886 | # will GDB work with these binaries? | |
1887 | if test "${gdb_arches#*$arch}" != "$gdb_arches"; then | |
1888 | echo "HOST_GDB_SUPPORTS_ARCH=y" >> "$config_target_mak" | |
1889 | fi | |
1890 | ||
b898bf28 | 1891 | echo "run-tcg-tests-$target: $qemu\$(EXESUF)" >> Makefile.prereqs |
cd362def PB |
1892 | tcg_tests_targets="$tcg_tests_targets $target" |
1893 | fi | |
2038f8c8 | 1894 | done |
c0031d38 FR |
1895 | |
1896 | if test "$tcg" = "enabled"; then | |
1897 | echo "TCG_TESTS_TARGETS=$tcg_tests_targets" >> config-host.mak | |
1898 | fi | |
1899 | ) | |
2038f8c8 | 1900 | |
a5665051 | 1901 | if test "$skip_meson" = no; then |
d77e90fa PB |
1902 | cross="config-meson.cross.new" |
1903 | meson_quote() { | |
ac7ebcc5 | 1904 | test $# = 0 && return |
47b30835 | 1905 | echo "'$(echo $* | sed "s/ /','/g")'" |
d77e90fa PB |
1906 | } |
1907 | ||
1908 | echo "# Automatically generated by configure - do not modify" > $cross | |
1909 | echo "[properties]" >> $cross | |
d1d5e9ee AB |
1910 | |
1911 | # unroll any custom device configs | |
11bdcfcd AB |
1912 | for a in $device_archs; do |
1913 | eval "c=\$devices_${a}" | |
1914 | echo "${a}-softmmu = '$c'" >> $cross | |
1915 | done | |
d1d5e9ee | 1916 | |
d77e90fa | 1917 | echo "[built-in options]" >> $cross |
a2866660 PB |
1918 | echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross |
1919 | echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross | |
e910c7d9 | 1920 | test -n "$objcc" && echo "objc_args = [$(meson_quote $OBJCFLAGS $EXTRA_OBJCFLAGS)]" >> $cross |
a2866660 PB |
1921 | echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross |
1922 | echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross | |
d77e90fa | 1923 | echo "[binaries]" >> $cross |
4dba2789 PB |
1924 | echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross |
1925 | test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross | |
1926 | test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross | |
d77e90fa PB |
1927 | echo "ar = [$(meson_quote $ar)]" >> $cross |
1928 | echo "nm = [$(meson_quote $nm)]" >> $cross | |
877c5567 | 1929 | echo "pkgconfig = [$(meson_quote $pkg_config)]" >> $cross |
d77e90fa PB |
1930 | echo "ranlib = [$(meson_quote $ranlib)]" >> $cross |
1931 | if has $sdl2_config; then | |
1932 | echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross | |
1933 | fi | |
1934 | echo "strip = [$(meson_quote $strip)]" >> $cross | |
158bb224 | 1935 | echo "widl = [$(meson_quote $widl)]" >> $cross |
d77e90fa | 1936 | echo "windres = [$(meson_quote $windres)]" >> $cross |
f9f0e617 | 1937 | echo "windmc = [$(meson_quote $windmc)]" >> $cross |
d77e90fa | 1938 | if test "$cross_compile" = "yes"; then |
fc929892 | 1939 | cross_arg="--cross-file config-meson.cross" |
fc929892 | 1940 | echo "[host_machine]" >> $cross |
ba7c60c2 | 1941 | echo "system = '$targetos'" >> $cross |
823eb013 | 1942 | case "$cpu" in |
f6bca9df | 1943 | i386) |
fc929892 MAL |
1944 | echo "cpu_family = 'x86'" >> $cross |
1945 | ;; | |
fc929892 | 1946 | *) |
823eb013 | 1947 | echo "cpu_family = '$cpu'" >> $cross |
fc929892 MAL |
1948 | ;; |
1949 | esac | |
1950 | echo "cpu = '$cpu'" >> $cross | |
1951 | if test "$bigendian" = "yes" ; then | |
1952 | echo "endian = 'big'" >> $cross | |
1953 | else | |
1954 | echo "endian = 'little'" >> $cross | |
1955 | fi | |
d77e90fa | 1956 | else |
fc929892 | 1957 | cross_arg="--native-file config-meson.cross" |
d77e90fa PB |
1958 | fi |
1959 | mv $cross config-meson.cross | |
fc929892 | 1960 | |
d77e90fa | 1961 | rm -rf meson-private meson-info meson-logs |
0a31e3a0 | 1962 | |
5a347a73 MAL |
1963 | # Prevent meson from automatically downloading wrapped subprojects when missing. |
1964 | # You can use 'meson subprojects download' before running configure. | |
1965 | meson_option_add "--wrap-mode=nodownload" | |
1966 | ||
0a31e3a0 PB |
1967 | # Built-in options |
1968 | test "$bindir" != "bin" && meson_option_add "-Dbindir=$bindir" | |
1969 | test "$default_feature" = no && meson_option_add -Dauto_features=disabled | |
a0cbd2e8 | 1970 | test "$static" = yes && meson_option_add -Dprefer_static=true |
0a31e3a0 PB |
1971 | test "$pie" = no && meson_option_add -Db_pie=false |
1972 | test "$werror" = yes && meson_option_add -Dwerror=true | |
1973 | ||
1974 | # QEMU options | |
0a31e3a0 | 1975 | test "$cfi" != false && meson_option_add "-Dcfi=$cfi" |
6b0cedcd | 1976 | test "$docs" != auto && meson_option_add "-Ddocs=$docs" |
0a31e3a0 PB |
1977 | test "$fdt" != auto && meson_option_add "-Dfdt=$fdt" |
1978 | test -n "${LIB_FUZZING_ENGINE+xxx}" && meson_option_add "-Dfuzzing_engine=$LIB_FUZZING_ENGINE" | |
1979 | test "$qemu_suffix" != qemu && meson_option_add "-Dqemu_suffix=$qemu_suffix" | |
0a31e3a0 PB |
1980 | test "$smbd" != '' && meson_option_add "-Dsmbd=$smbd" |
1981 | test "$tcg" != enabled && meson_option_add "-Dtcg=$tcg" | |
55116968 | 1982 | test "$vfio_user_server" != auto && meson_option_add "-Dvfio_user_server=$vfio_user_server" |
61d63097 | 1983 | run_meson() { |
0a31e3a0 | 1984 | NINJA=$ninja $meson setup --prefix "$prefix" "$@" $cross_arg "$PWD" "$source_path" |
61d63097 PB |
1985 | } |
1986 | eval run_meson $meson_options | |
d77e90fa PB |
1987 | if test "$?" -ne 0 ; then |
1988 | error_exit "meson setup failed" | |
1989 | fi | |
973038db PB |
1990 | else |
1991 | if test -f meson-private/cmd_line.txt; then | |
1992 | # Adjust old command line options that were removed | |
1993 | # sed -i is not portable | |
1994 | perl -i -ne ' | |
1995 | /^sphinx_build/ && next; | |
1996 | print;' meson-private/cmd_line.txt | |
1997 | fi | |
a5665051 PB |
1998 | fi |
1999 | ||
dc655404 MT |
2000 | # Save the configure command line for later reuse. |
2001 | cat <<EOD >config.status | |
2002 | #!/bin/sh | |
2003 | # Generated by configure. | |
2004 | # Run this file to recreate the current configuration. | |
2005 | # Compiler output produced by configure, useful for debugging | |
2006 | # configure, is in config.log if it exists. | |
2007 | EOD | |
e811da7f DB |
2008 | |
2009 | preserve_env() { | |
2010 | envname=$1 | |
2011 | ||
2012 | eval envval=\$$envname | |
2013 | ||
2014 | if test -n "$envval" | |
2015 | then | |
2016 | echo "$envname='$envval'" >> config.status | |
2017 | echo "export $envname" >> config.status | |
2018 | else | |
2019 | echo "unset $envname" >> config.status | |
2020 | fi | |
2021 | } | |
2022 | ||
2023 | # Preserve various env variables that influence what | |
2024 | # features/build target configure will detect | |
2025 | preserve_env AR | |
2026 | preserve_env AS | |
2027 | preserve_env CC | |
8009da03 | 2028 | preserve_env CFLAGS |
e811da7f | 2029 | preserve_env CXX |
8009da03 | 2030 | preserve_env CXXFLAGS |
e811da7f | 2031 | preserve_env LD |
8009da03 | 2032 | preserve_env LDFLAGS |
e811da7f | 2033 | preserve_env LD_LIBRARY_PATH |
e811da7f DB |
2034 | preserve_env MAKE |
2035 | preserve_env NM | |
b5569e5b | 2036 | preserve_env OBJCFLAGS |
e811da7f DB |
2037 | preserve_env OBJCOPY |
2038 | preserve_env PATH | |
2039 | preserve_env PKG_CONFIG | |
2040 | preserve_env PKG_CONFIG_LIBDIR | |
2041 | preserve_env PKG_CONFIG_PATH | |
2042 | preserve_env PYTHON | |
954ed68f PB |
2043 | preserve_env QEMU_GA_MANUFACTURER |
2044 | preserve_env QEMU_GA_DISTRO | |
2045 | preserve_env QEMU_GA_VERSION | |
e811da7f DB |
2046 | preserve_env SDL2_CONFIG |
2047 | preserve_env SMBD | |
2048 | preserve_env STRIP | |
158bb224 | 2049 | preserve_env WIDL |
e811da7f | 2050 | preserve_env WINDRES |
f9f0e617 | 2051 | preserve_env WINDMC |
e811da7f | 2052 | |
dc655404 | 2053 | printf "exec" >>config.status |
a5665051 | 2054 | for i in "$0" "$@"; do |
835af899 | 2055 | test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status |
a5665051 | 2056 | done |
cf7cc929 | 2057 | echo ' "$@"' >>config.status |
dc655404 MT |
2058 | chmod +x config.status |
2059 | ||
8cd05ab6 | 2060 | rm -r "$TMPDIR1" |