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