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