You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

7978 lines
206KB

  1. #!/bin/sh
  2. #
  3. # qemu configure script (c) 2003 Fabrice Bellard
  4. #
  5. # Unset some variables known to interfere with behavior of common tools,
  6. # just as autoconf does.
  7. CLICOLOR_FORCE= GREP_OPTIONS=
  8. unset CLICOLOR_FORCE GREP_OPTIONS
  9. # Don't allow CCACHE, if present, to use cached results of compile tests!
  10. export CCACHE_RECACHE=yes
  11. # Temporary directory used for files created while
  12. # configure runs. Since it is in the build directory
  13. # we can safely blow away any previous version of it
  14. # (and we need not jump through hoops to try to delete
  15. # it when configure exits.)
  16. TMPDIR1="config-temp"
  17. rm -rf "${TMPDIR1}"
  18. mkdir -p "${TMPDIR1}"
  19. if [ $? -ne 0 ]; then
  20. echo "ERROR: failed to create temporary directory"
  21. exit 1
  22. fi
  23. TMPB="qemu-conf"
  24. TMPC="${TMPDIR1}/${TMPB}.c"
  25. TMPO="${TMPDIR1}/${TMPB}.o"
  26. TMPCXX="${TMPDIR1}/${TMPB}.cxx"
  27. TMPE="${TMPDIR1}/${TMPB}.exe"
  28. TMPMO="${TMPDIR1}/${TMPB}.mo"
  29. rm -f config.log
  30. # Print a helpful header at the top of config.log
  31. echo "# QEMU configure log $(date)" >> config.log
  32. printf "# Configured with:" >> config.log
  33. printf " '%s'" "$0" "$@" >> config.log
  34. echo >> config.log
  35. echo "#" >> config.log
  36. print_error() {
  37. (echo
  38. echo "ERROR: $1"
  39. while test -n "$2"; do
  40. echo " $2"
  41. shift
  42. done
  43. echo) >&2
  44. }
  45. error_exit() {
  46. print_error "$@"
  47. exit 1
  48. }
  49. do_compiler() {
  50. # Run the compiler, capturing its output to the log. First argument
  51. # is compiler binary to execute.
  52. local compiler="$1"
  53. shift
  54. if test -n "$BASH_VERSION"; then eval '
  55. echo >>config.log "
  56. funcs: ${FUNCNAME[*]}
  57. lines: ${BASH_LINENO[*]}"
  58. '; fi
  59. echo $compiler "$@" >> config.log
  60. $compiler "$@" >> config.log 2>&1 || return $?
  61. # Test passed. If this is an --enable-werror build, rerun
  62. # the test with -Werror and bail out if it fails. This
  63. # makes warning-generating-errors in configure test code
  64. # obvious to developers.
  65. if test "$werror" != "yes"; then
  66. return 0
  67. fi
  68. # Don't bother rerunning the compile if we were already using -Werror
  69. case "$*" in
  70. *-Werror*)
  71. return 0
  72. ;;
  73. esac
  74. echo $compiler -Werror "$@" >> config.log
  75. $compiler -Werror "$@" >> config.log 2>&1 && return $?
  76. error_exit "configure test passed without -Werror but failed with -Werror." \
  77. "This is probably a bug in the configure script. The failing command" \
  78. "will be at the bottom of config.log." \
  79. "You can run configure with --disable-werror to bypass this check."
  80. }
  81. do_cc() {
  82. do_compiler "$cc" "$@"
  83. }
  84. do_cxx() {
  85. do_compiler "$cxx" "$@"
  86. }
  87. update_cxxflags() {
  88. # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
  89. # options which some versions of GCC's C++ compiler complain about
  90. # because they only make sense for C programs.
  91. QEMU_CXXFLAGS="$QEMU_CXXFLAGS -D__STDC_LIMIT_MACROS"
  92. for arg in $QEMU_CFLAGS; do
  93. case $arg in
  94. -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
  95. -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
  96. ;;
  97. -std=gnu99)
  98. QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }"-std=gnu++98"
  99. ;;
  100. *)
  101. QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
  102. ;;
  103. esac
  104. done
  105. }
  106. compile_object() {
  107. local_cflags="$1"
  108. do_cc $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
  109. }
  110. compile_prog() {
  111. local_cflags="$1"
  112. local_ldflags="$2"
  113. do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
  114. }
  115. # symbolically link $1 to $2. Portable version of "ln -sf".
  116. symlink() {
  117. rm -rf "$2"
  118. mkdir -p "$(dirname "$2")"
  119. ln -s "$1" "$2"
  120. }
  121. # check whether a command is available to this shell (may be either an
  122. # executable or a builtin)
  123. has() {
  124. type "$1" >/dev/null 2>&1
  125. }
  126. # search for an executable in PATH
  127. path_of() {
  128. local_command="$1"
  129. local_ifs="$IFS"
  130. local_dir=""
  131. # pathname has a dir component?
  132. if [ "${local_command#*/}" != "$local_command" ]; then
  133. if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
  134. echo "$local_command"
  135. return 0
  136. fi
  137. fi
  138. if [ -z "$local_command" ]; then
  139. return 1
  140. fi
  141. IFS=:
  142. for local_dir in $PATH; do
  143. if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
  144. echo "$local_dir/$local_command"
  145. IFS="${local_ifs:-$(printf ' \t\n')}"
  146. return 0
  147. fi
  148. done
  149. # not found
  150. IFS="${local_ifs:-$(printf ' \t\n')}"
  151. return 1
  152. }
  153. have_backend () {
  154. echo "$trace_backends" | grep "$1" >/dev/null
  155. }
  156. glob() {
  157. eval test -z '"${1#'"$2"'}"'
  158. }
  159. supported_hax_target() {
  160. test "$hax" = "yes" || return 1
  161. glob "$1" "*-softmmu" || return 1
  162. case "${1%-softmmu}" in
  163. i386|x86_64)
  164. return 0
  165. ;;
  166. esac
  167. return 1
  168. }
  169. supported_kvm_target() {
  170. test "$kvm" = "yes" || return 1
  171. glob "$1" "*-softmmu" || return 1
  172. case "${1%-softmmu}:$cpu" in
  173. arm:arm | aarch64:aarch64 | \
  174. i386:i386 | i386:x86_64 | i386:x32 | \
  175. x86_64:i386 | x86_64:x86_64 | x86_64:x32 | \
  176. mips:mips | mipsel:mips | \
  177. ppc:ppc | ppc64:ppc | ppc:ppc64 | ppc64:ppc64 | \
  178. s390x:s390x)
  179. return 0
  180. ;;
  181. esac
  182. return 1
  183. }
  184. supported_xen_target() {
  185. test "$xen" = "yes" || return 1
  186. glob "$1" "*-softmmu" || return 1
  187. # Only i386 and x86_64 provide the xenpv machine.
  188. case "${1%-softmmu}" in
  189. i386|x86_64)
  190. return 0
  191. ;;
  192. esac
  193. return 1
  194. }
  195. supported_hvf_target() {
  196. test "$hvf" = "yes" || return 1
  197. glob "$1" "*-softmmu" || return 1
  198. case "${1%-softmmu}" in
  199. x86_64)
  200. return 0
  201. ;;
  202. esac
  203. return 1
  204. }
  205. supported_whpx_target() {
  206. test "$whpx" = "yes" || return 1
  207. glob "$1" "*-softmmu" || return 1
  208. case "${1%-softmmu}" in
  209. i386|x86_64)
  210. return 0
  211. ;;
  212. esac
  213. return 1
  214. }
  215. supported_target() {
  216. case "$1" in
  217. *-softmmu)
  218. ;;
  219. *-linux-user)
  220. if test "$linux" != "yes"; then
  221. print_error "Target '$target' is only available on a Linux host"
  222. return 1
  223. fi
  224. ;;
  225. *-bsd-user)
  226. if test "$bsd" != "yes"; then
  227. print_error "Target '$target' is only available on a BSD host"
  228. return 1
  229. fi
  230. ;;
  231. *)
  232. print_error "Invalid target name '$target'"
  233. return 1
  234. ;;
  235. esac
  236. test "$tcg" = "yes" && return 0
  237. supported_kvm_target "$1" && return 0
  238. supported_xen_target "$1" && return 0
  239. supported_hax_target "$1" && return 0
  240. supported_hvf_target "$1" && return 0
  241. supported_whpx_target "$1" && return 0
  242. print_error "TCG disabled, but hardware accelerator not available for '$target'"
  243. return 1
  244. }
  245. ld_has() {
  246. $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
  247. }
  248. # default parameters
  249. source_path=$(dirname "$0")
  250. # make source path absolute
  251. source_path=$(cd "$source_path"; pwd)
  252. cpu=""
  253. iasl="iasl"
  254. interp_prefix="/usr/gnemul/qemu-%M"
  255. static="no"
  256. cross_prefix=""
  257. audio_drv_list=""
  258. block_drv_rw_whitelist=""
  259. block_drv_ro_whitelist=""
  260. host_cc="cc"
  261. libs_softmmu=""
  262. libs_tools=""
  263. audio_pt_int=""
  264. audio_win_int=""
  265. libs_qga=""
  266. debug_info="yes"
  267. stack_protector=""
  268. if test -e "$source_path/.git"
  269. then
  270. git_update=yes
  271. git_submodules="ui/keycodemapdb"
  272. git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
  273. git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
  274. else
  275. git_update=no
  276. git_submodules=""
  277. if ! test -f "$source_path/ui/keycodemapdb/README"
  278. then
  279. echo
  280. echo "ERROR: missing file $source_path/ui/keycodemapdb/README"
  281. echo
  282. echo "This is not a GIT checkout but module content appears to"
  283. echo "be missing. Do not use 'git archive' or GitHub download links"
  284. echo "to acquire QEMU source archives. Non-GIT builds are only"
  285. echo "supported with source archives linked from:"
  286. echo
  287. echo " https://www.qemu.org/download/"
  288. echo
  289. echo "Developers working with GIT can use scripts/archive-source.sh"
  290. echo "if they need to create valid source archives."
  291. echo
  292. exit 1
  293. fi
  294. fi
  295. git="git"
  296. # Don't accept a target_list environment variable.
  297. unset target_list
  298. unset target_list_exclude
  299. # Default value for a variable defining feature "foo".
  300. # * foo="no" feature will only be used if --enable-foo arg is given
  301. # * foo="" feature will be searched for, and if found, will be used
  302. # unless --disable-foo is given
  303. # * foo="yes" this value will only be set by --enable-foo flag.
  304. # feature will searched for,
  305. # if not found, configure exits with error
  306. #
  307. # Always add --enable-foo and --disable-foo command line args.
  308. # Distributions want to ensure that several features are compiled in, and it
  309. # is impossible without a --enable-foo that exits if a feature is not found.
  310. bluez=""
  311. brlapi=""
  312. curl=""
  313. curses=""
  314. docs=""
  315. fdt=""
  316. netmap="no"
  317. sdl=""
  318. sdl_image=""
  319. virtfs=""
  320. mpath=""
  321. vnc="yes"
  322. sparse="no"
  323. vde=""
  324. vnc_sasl=""
  325. vnc_jpeg=""
  326. vnc_png=""
  327. xkbcommon=""
  328. xen=""
  329. xen_ctrl_version=""
  330. xen_pci_passthrough=""
  331. linux_aio=""
  332. cap_ng=""
  333. attr=""
  334. libattr=""
  335. xfs=""
  336. tcg="yes"
  337. membarrier=""
  338. vhost_net=""
  339. vhost_crypto=""
  340. vhost_scsi=""
  341. vhost_vsock=""
  342. vhost_user=""
  343. kvm="no"
  344. hax="no"
  345. hvf="no"
  346. whpx="no"
  347. rdma=""
  348. pvrdma=""
  349. gprof="no"
  350. debug_tcg="no"
  351. debug="no"
  352. sanitizers="no"
  353. fortify_source=""
  354. strip_opt="yes"
  355. tcg_interpreter="no"
  356. bigendian="no"
  357. mingw32="no"
  358. gcov="no"
  359. gcov_tool="gcov"
  360. EXESUF=""
  361. DSOSUF=".so"
  362. LDFLAGS_SHARED="-shared"
  363. modules="no"
  364. prefix="/usr/local"
  365. mandir="\${prefix}/share/man"
  366. datadir="\${prefix}/share"
  367. firmwarepath="\${prefix}/share/qemu-firmware"
  368. qemu_docdir="\${prefix}/share/doc/qemu"
  369. bindir="\${prefix}/bin"
  370. libdir="\${prefix}/lib"
  371. libexecdir="\${prefix}/libexec"
  372. includedir="\${prefix}/include"
  373. sysconfdir="\${prefix}/etc"
  374. local_statedir="\${prefix}/var"
  375. confsuffix="/qemu"
  376. slirp=""
  377. oss_lib=""
  378. bsd="no"
  379. linux="no"
  380. solaris="no"
  381. profiler="no"
  382. cocoa="no"
  383. softmmu="yes"
  384. linux_user="no"
  385. bsd_user="no"
  386. blobs="yes"
  387. pkgversion=""
  388. pie=""
  389. qom_cast_debug="yes"
  390. trace_backends="log"
  391. trace_file="trace"
  392. spice=""
  393. rbd=""
  394. smartcard=""
  395. libusb=""
  396. usb_redir=""
  397. opengl=""
  398. opengl_dmabuf="no"
  399. cpuid_h="no"
  400. avx2_opt=""
  401. zlib="yes"
  402. capstone=""
  403. lzo=""
  404. snappy=""
  405. bzip2=""
  406. lzfse=""
  407. guest_agent=""
  408. guest_agent_with_vss="no"
  409. guest_agent_ntddscsi="no"
  410. guest_agent_msi=""
  411. vss_win32_sdk=""
  412. win_sdk="no"
  413. want_tools="yes"
  414. libiscsi=""
  415. libnfs=""
  416. coroutine=""
  417. coroutine_pool=""
  418. debug_stack_usage="no"
  419. crypto_afalg="no"
  420. seccomp=""
  421. glusterfs=""
  422. glusterfs_xlator_opt="no"
  423. glusterfs_discard="no"
  424. glusterfs_fallocate="no"
  425. glusterfs_zerofill="no"
  426. glusterfs_ftruncate_has_stat="no"
  427. glusterfs_iocb_has_stat="no"
  428. gtk=""
  429. gtk_gl="no"
  430. tls_priority="NORMAL"
  431. gnutls=""
  432. nettle=""
  433. gcrypt=""
  434. gcrypt_hmac="no"
  435. auth_pam=""
  436. vte=""
  437. virglrenderer=""
  438. tpm=""
  439. libssh2=""
  440. live_block_migration="yes"
  441. numa=""
  442. tcmalloc="no"
  443. jemalloc="no"
  444. replication="yes"
  445. vxhs=""
  446. bochs="yes"
  447. cloop="yes"
  448. dmg="yes"
  449. qcow1="yes"
  450. vdi="yes"
  451. vvfat="yes"
  452. qed="yes"
  453. parallels="yes"
  454. sheepdog="yes"
  455. libxml2=""
  456. docker="no"
  457. debug_mutex="no"
  458. libpmem=""
  459. default_devices="yes"
  460. # cross compilers defaults, can be overridden with --cross-cc-ARCH
  461. cross_cc_aarch64="aarch64-linux-gnu-gcc"
  462. cross_cc_aarch64_be="$cross_cc_aarch64"
  463. cross_cc_cflags_aarch64_be="-mbig-endian"
  464. cross_cc_arm="arm-linux-gnueabihf-gcc"
  465. cross_cc_cflags_armeb="-mbig-endian"
  466. cross_cc_i386="i386-pc-linux-gnu-gcc"
  467. cross_cc_cflags_i386=""
  468. cross_cc_powerpc="powerpc-linux-gnu-gcc"
  469. cross_cc_powerpc="powerpc-linux-gnu-gcc"
  470. enabled_cross_compilers=""
  471. supported_cpu="no"
  472. supported_os="no"
  473. bogus_os="no"
  474. malloc_trim=""
  475. # parse CC options first
  476. for opt do
  477. optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
  478. case "$opt" in
  479. --cross-prefix=*) cross_prefix="$optarg"
  480. ;;
  481. --cc=*) CC="$optarg"
  482. ;;
  483. --cxx=*) CXX="$optarg"
  484. ;;
  485. --cpu=*) cpu="$optarg"
  486. ;;
  487. --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
  488. ;;
  489. --extra-cxxflags=*) QEMU_CXXFLAGS="$QEMU_CXXFLAGS $optarg"
  490. ;;
  491. --extra-ldflags=*) LDFLAGS="$LDFLAGS $optarg"
  492. EXTRA_LDFLAGS="$optarg"
  493. ;;
  494. --enable-debug-info) debug_info="yes"
  495. ;;
  496. --disable-debug-info) debug_info="no"
  497. ;;
  498. --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
  499. ;;
  500. --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-flags-}; cc_arch=${cc_arch%%=*}
  501. eval "cross_cc_cflags_${cc_arch}=\$optarg"
  502. ;;
  503. --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
  504. eval "cross_cc_${cc_arch}=\$optarg"
  505. ;;
  506. esac
  507. done
  508. # OS specific
  509. # Using uname is really, really broken. Once we have the right set of checks
  510. # we can eliminate its usage altogether.
  511. # Preferred compiler:
  512. # ${CC} (if set)
  513. # ${cross_prefix}gcc (if cross-prefix specified)
  514. # system compiler
  515. if test -z "${CC}${cross_prefix}"; then
  516. cc="$host_cc"
  517. else
  518. cc="${CC-${cross_prefix}gcc}"
  519. fi
  520. if test -z "${CXX}${cross_prefix}"; then
  521. cxx="c++"
  522. else
  523. cxx="${CXX-${cross_prefix}g++}"
  524. fi
  525. ar="${AR-${cross_prefix}ar}"
  526. as="${AS-${cross_prefix}as}"
  527. ccas="${CCAS-$cc}"
  528. cpp="${CPP-$cc -E}"
  529. objcopy="${OBJCOPY-${cross_prefix}objcopy}"
  530. ld="${LD-${cross_prefix}ld}"
  531. ranlib="${RANLIB-${cross_prefix}ranlib}"
  532. nm="${NM-${cross_prefix}nm}"
  533. strip="${STRIP-${cross_prefix}strip}"
  534. windres="${WINDRES-${cross_prefix}windres}"
  535. pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
  536. query_pkg_config() {
  537. "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
  538. }
  539. pkg_config=query_pkg_config
  540. sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
  541. # If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
  542. ARFLAGS="${ARFLAGS-rv}"
  543. # default flags for all hosts
  544. # We use -fwrapv to tell the compiler that we require a C dialect where
  545. # left shift of signed integers is well defined and has the expected
  546. # 2s-complement style results. (Both clang and gcc agree that it
  547. # provides these semantics.)
  548. QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv -std=gnu99 $QEMU_CFLAGS"
  549. QEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
  550. QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
  551. QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
  552. QEMU_INCLUDES="-iquote . -iquote \$(SRC_PATH) -iquote \$(SRC_PATH)/accel/tcg -iquote \$(SRC_PATH)/include"
  553. if test "$debug_info" = "yes"; then
  554. CFLAGS="-g $CFLAGS"
  555. LDFLAGS="-g $LDFLAGS"
  556. fi
  557. # running configure in the source tree?
  558. # we know that's the case if configure is there.
  559. if test -f "./configure"; then
  560. pwd_is_source_path="y"
  561. else
  562. pwd_is_source_path="n"
  563. fi
  564. check_define() {
  565. cat > $TMPC <<EOF
  566. #if !defined($1)
  567. #error $1 not defined
  568. #endif
  569. int main(void) { return 0; }
  570. EOF
  571. compile_object
  572. }
  573. check_include() {
  574. cat > $TMPC <<EOF
  575. #include <$1>
  576. int main(void) { return 0; }
  577. EOF
  578. compile_object
  579. }
  580. write_c_skeleton() {
  581. cat > $TMPC <<EOF
  582. int main(void) { return 0; }
  583. EOF
  584. }
  585. if check_define __linux__ ; then
  586. targetos="Linux"
  587. elif check_define _WIN32 ; then
  588. targetos='MINGW32'
  589. elif check_define __OpenBSD__ ; then
  590. targetos='OpenBSD'
  591. elif check_define __sun__ ; then
  592. targetos='SunOS'
  593. elif check_define __HAIKU__ ; then
  594. targetos='Haiku'
  595. elif check_define __FreeBSD__ ; then
  596. targetos='FreeBSD'
  597. elif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
  598. targetos='GNU/kFreeBSD'
  599. elif check_define __DragonFly__ ; then
  600. targetos='DragonFly'
  601. elif check_define __NetBSD__; then
  602. targetos='NetBSD'
  603. elif check_define __APPLE__; then
  604. targetos='Darwin'
  605. else
  606. # This is a fatal error, but don't report it yet, because we
  607. # might be going to just print the --help text, or it might
  608. # be the result of a missing compiler.
  609. targetos='bogus'
  610. bogus_os='yes'
  611. fi
  612. # Some host OSes need non-standard checks for which CPU to use.
  613. # Note that these checks are broken for cross-compilation: if you're
  614. # cross-compiling to one of these OSes then you'll need to specify
  615. # the correct CPU with the --cpu option.
  616. case $targetos in
  617. Darwin)
  618. # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
  619. # run 64-bit userspace code.
  620. # If the user didn't specify a CPU explicitly and the kernel says this is
  621. # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
  622. if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
  623. cpu="x86_64"
  624. fi
  625. ;;
  626. SunOS)
  627. # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
  628. if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
  629. cpu="x86_64"
  630. fi
  631. esac
  632. if test ! -z "$cpu" ; then
  633. # command line argument
  634. :
  635. elif check_define __i386__ ; then
  636. cpu="i386"
  637. elif check_define __x86_64__ ; then
  638. if check_define __ILP32__ ; then
  639. cpu="x32"
  640. else
  641. cpu="x86_64"
  642. fi
  643. elif check_define __sparc__ ; then
  644. if check_define __arch64__ ; then
  645. cpu="sparc64"
  646. else
  647. cpu="sparc"
  648. fi
  649. elif check_define _ARCH_PPC ; then
  650. if check_define _ARCH_PPC64 ; then
  651. cpu="ppc64"
  652. else
  653. cpu="ppc"
  654. fi
  655. elif check_define __mips__ ; then
  656. cpu="mips"
  657. elif check_define __s390__ ; then
  658. if check_define __s390x__ ; then
  659. cpu="s390x"
  660. else
  661. cpu="s390"
  662. fi
  663. elif check_define __riscv ; then
  664. if check_define _LP64 ; then
  665. cpu="riscv64"
  666. else
  667. cpu="riscv32"
  668. fi
  669. elif check_define __arm__ ; then
  670. cpu="arm"
  671. elif check_define __aarch64__ ; then
  672. cpu="aarch64"
  673. else
  674. cpu=$(uname -m)
  675. fi
  676. ARCH=
  677. # Normalise host CPU name and set ARCH.
  678. # Note that this case should only have supported host CPUs, not guests.
  679. case "$cpu" in
  680. ppc|ppc64|s390|s390x|sparc64|x32|riscv32|riscv64)
  681. cpu="$cpu"
  682. supported_cpu="yes"
  683. eval "cross_cc_${cpu}=\$host_cc"
  684. ;;
  685. i386|i486|i586|i686|i86pc|BePC)
  686. cpu="i386"
  687. supported_cpu="yes"
  688. cross_cc_i386=$host_cc
  689. ;;
  690. x86_64|amd64)
  691. cpu="x86_64"
  692. supported_cpu="yes"
  693. cross_cc_x86_64=$host_cc
  694. ;;
  695. armv*b|armv*l|arm)
  696. cpu="arm"
  697. supported_cpu="yes"
  698. cross_cc_arm=$host_cc
  699. ;;
  700. aarch64)
  701. cpu="aarch64"
  702. supported_cpu="yes"
  703. cross_cc_aarch64=$host_cc
  704. ;;
  705. mips*)
  706. cpu="mips"
  707. supported_cpu="yes"
  708. cross_cc_mips=$host_cc
  709. ;;
  710. sparc|sun4[cdmuv])
  711. cpu="sparc"
  712. supported_cpu="yes"
  713. cross_cc_sparc=$host_cc
  714. ;;
  715. *)
  716. # This will result in either an error or falling back to TCI later
  717. ARCH=unknown
  718. ;;
  719. esac
  720. if test -z "$ARCH"; then
  721. ARCH="$cpu"
  722. fi
  723. # OS specific
  724. # host *BSD for user mode
  725. HOST_VARIANT_DIR=""
  726. case $targetos in
  727. MINGW32*)
  728. mingw32="yes"
  729. hax="yes"
  730. vhost_user="no"
  731. audio_possible_drivers="dsound sdl"
  732. if check_include dsound.h; then
  733. audio_drv_list="dsound"
  734. else
  735. audio_drv_list=""
  736. fi
  737. supported_os="yes"
  738. ;;
  739. GNU/kFreeBSD)
  740. bsd="yes"
  741. audio_drv_list="oss try-sdl"
  742. audio_possible_drivers="oss sdl pa"
  743. ;;
  744. FreeBSD)
  745. bsd="yes"
  746. make="${MAKE-gmake}"
  747. audio_drv_list="oss try-sdl"
  748. audio_possible_drivers="oss sdl pa"
  749. # needed for kinfo_getvmmap(3) in libutil.h
  750. LIBS="-lutil $LIBS"
  751. # needed for kinfo_getproc
  752. libs_qga="-lutil $libs_qga"
  753. netmap="" # enable netmap autodetect
  754. HOST_VARIANT_DIR="freebsd"
  755. supported_os="yes"
  756. ;;
  757. DragonFly)
  758. bsd="yes"
  759. make="${MAKE-gmake}"
  760. audio_drv_list="oss try-sdl"
  761. audio_possible_drivers="oss sdl pa"
  762. HOST_VARIANT_DIR="dragonfly"
  763. ;;
  764. NetBSD)
  765. bsd="yes"
  766. hax="yes"
  767. make="${MAKE-gmake}"
  768. audio_drv_list="oss try-sdl"
  769. audio_possible_drivers="oss sdl"
  770. oss_lib="-lossaudio"
  771. HOST_VARIANT_DIR="netbsd"
  772. supported_os="yes"
  773. ;;
  774. OpenBSD)
  775. bsd="yes"
  776. make="${MAKE-gmake}"
  777. audio_drv_list="try-sdl"
  778. audio_possible_drivers="sdl"
  779. HOST_VARIANT_DIR="openbsd"
  780. supported_os="yes"
  781. ;;
  782. Darwin)
  783. bsd="yes"
  784. darwin="yes"
  785. hax="yes"
  786. hvf="yes"
  787. LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
  788. if [ "$cpu" = "x86_64" ] ; then
  789. QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
  790. LDFLAGS="-arch x86_64 $LDFLAGS"
  791. fi
  792. cocoa="yes"
  793. audio_drv_list="coreaudio try-sdl"
  794. audio_possible_drivers="coreaudio sdl"
  795. LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
  796. libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
  797. # Disable attempts to use ObjectiveC features in os/object.h since they
  798. # won't work when we're compiling with gcc as a C compiler.
  799. QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
  800. HOST_VARIANT_DIR="darwin"
  801. supported_os="yes"
  802. ;;
  803. SunOS)
  804. solaris="yes"
  805. make="${MAKE-gmake}"
  806. install="${INSTALL-ginstall}"
  807. smbd="${SMBD-/usr/sfw/sbin/smbd}"
  808. if test -f /usr/include/sys/soundcard.h ; then
  809. audio_drv_list="oss try-sdl"
  810. fi
  811. audio_possible_drivers="oss sdl"
  812. # needed for CMSG_ macros in sys/socket.h
  813. QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
  814. # needed for TIOCWIN* defines in termios.h
  815. QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
  816. QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
  817. solarisnetlibs="-lsocket -lnsl -lresolv"
  818. LIBS="$solarisnetlibs $LIBS"
  819. libs_qga="$solarisnetlibs $libs_qga"
  820. ;;
  821. Haiku)
  822. haiku="yes"
  823. QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
  824. LIBS="-lposix_error_mapper -lnetwork $LIBS"
  825. ;;
  826. Linux)
  827. audio_drv_list="try-pa oss"
  828. audio_possible_drivers="oss alsa sdl pa"
  829. linux="yes"
  830. linux_user="yes"
  831. kvm="yes"
  832. QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$PWD/linux-headers $QEMU_INCLUDES"
  833. supported_os="yes"
  834. libudev="yes"
  835. ;;
  836. esac
  837. if [ "$bsd" = "yes" ] ; then
  838. if [ "$darwin" != "yes" ] ; then
  839. bsd_user="yes"
  840. fi
  841. fi
  842. : ${make=${MAKE-make}}
  843. : ${install=${INSTALL-install}}
  844. : ${python=${PYTHON-python}}
  845. : ${smbd=${SMBD-/usr/sbin/smbd}}
  846. # Default objcc to clang if available, otherwise use CC
  847. if has clang; then
  848. objcc=clang
  849. else
  850. objcc="$cc"
  851. fi
  852. if test "$mingw32" = "yes" ; then
  853. EXESUF=".exe"
  854. DSOSUF=".dll"
  855. # MinGW needs -mthreads for TLS and macro _MT.
  856. QEMU_CFLAGS="-mthreads $QEMU_CFLAGS"
  857. LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
  858. write_c_skeleton;
  859. if compile_prog "" "-liberty" ; then
  860. LIBS="-liberty $LIBS"
  861. fi
  862. prefix="c:/Program Files/QEMU"
  863. mandir="\${prefix}"
  864. datadir="\${prefix}"
  865. qemu_docdir="\${prefix}"
  866. bindir="\${prefix}"
  867. sysconfdir="\${prefix}"
  868. local_statedir=
  869. confsuffix=""
  870. libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
  871. fi
  872. werror=""
  873. for opt do
  874. optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
  875. case "$opt" in
  876. --help|-h) show_help=yes
  877. ;;
  878. --version|-V) exec cat $source_path/VERSION
  879. ;;
  880. --prefix=*) prefix="$optarg"
  881. ;;
  882. --interp-prefix=*) interp_prefix="$optarg"
  883. ;;
  884. --cross-prefix=*)
  885. ;;
  886. --cc=*)
  887. ;;
  888. --host-cc=*) host_cc="$optarg"
  889. ;;
  890. --cxx=*)
  891. ;;
  892. --iasl=*) iasl="$optarg"
  893. ;;
  894. --objcc=*) objcc="$optarg"
  895. ;;
  896. --make=*) make="$optarg"
  897. ;;
  898. --install=*) install="$optarg"
  899. ;;
  900. --python=*) python="$optarg"
  901. ;;
  902. --gcov=*) gcov_tool="$optarg"
  903. ;;
  904. --smbd=*) smbd="$optarg"
  905. ;;
  906. --extra-cflags=*)
  907. ;;
  908. --extra-cxxflags=*)
  909. ;;
  910. --extra-ldflags=*)
  911. ;;
  912. --enable-debug-info)
  913. ;;
  914. --disable-debug-info)
  915. ;;
  916. --cross-cc-*)
  917. ;;
  918. --enable-modules)
  919. modules="yes"
  920. ;;
  921. --disable-modules)
  922. modules="no"
  923. ;;
  924. --cpu=*)
  925. ;;
  926. --target-list=*) target_list="$optarg"
  927. if test "$target_list_exclude"; then
  928. error_exit "Can't mix --target-list with --target-list-exclude"
  929. fi
  930. ;;
  931. --target-list-exclude=*) target_list_exclude="$optarg"
  932. if test "$target_list"; then
  933. error_exit "Can't mix --target-list-exclude with --target-list"
  934. fi
  935. ;;
  936. --enable-trace-backends=*) trace_backends="$optarg"
  937. ;;
  938. # XXX: backwards compatibility
  939. --enable-trace-backend=*) trace_backends="$optarg"
  940. ;;
  941. --with-trace-file=*) trace_file="$optarg"
  942. ;;
  943. --with-default-devices) default_devices="yes"
  944. ;;
  945. --without-default-devices) default_devices="no"
  946. ;;
  947. --enable-gprof) gprof="yes"
  948. ;;
  949. --enable-gcov) gcov="yes"
  950. ;;
  951. --static)
  952. static="yes"
  953. LDFLAGS="-static $LDFLAGS"
  954. QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
  955. ;;
  956. --mandir=*) mandir="$optarg"
  957. ;;
  958. --bindir=*) bindir="$optarg"
  959. ;;
  960. --libdir=*) libdir="$optarg"
  961. ;;
  962. --libexecdir=*) libexecdir="$optarg"
  963. ;;
  964. --includedir=*) includedir="$optarg"
  965. ;;
  966. --datadir=*) datadir="$optarg"
  967. ;;
  968. --with-confsuffix=*) confsuffix="$optarg"
  969. ;;
  970. --docdir=*) qemu_docdir="$optarg"
  971. ;;
  972. --sysconfdir=*) sysconfdir="$optarg"
  973. ;;
  974. --localstatedir=*) local_statedir="$optarg"
  975. ;;
  976. --firmwarepath=*) firmwarepath="$optarg"
  977. ;;
  978. --host=*|--build=*|\
  979. --disable-dependency-tracking|\
  980. --sbindir=*|--sharedstatedir=*|\
  981. --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
  982. --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
  983. # These switches are silently ignored, for compatibility with
  984. # autoconf-generated configure scripts. This allows QEMU's
  985. # configure to be used by RPM and similar macros that set
  986. # lots of directory switches by default.
  987. ;;
  988. --disable-sdl) sdl="no"
  989. ;;
  990. --enable-sdl) sdl="yes"
  991. ;;
  992. --disable-sdl-image) sdl_image="no"
  993. ;;
  994. --enable-sdl-image) sdl_image="yes"
  995. ;;
  996. --disable-qom-cast-debug) qom_cast_debug="no"
  997. ;;
  998. --enable-qom-cast-debug) qom_cast_debug="yes"
  999. ;;
  1000. --disable-virtfs) virtfs="no"
  1001. ;;
  1002. --enable-virtfs) virtfs="yes"
  1003. ;;
  1004. --disable-mpath) mpath="no"
  1005. ;;
  1006. --enable-mpath) mpath="yes"
  1007. ;;
  1008. --disable-vnc) vnc="no"
  1009. ;;
  1010. --enable-vnc) vnc="yes"
  1011. ;;
  1012. --oss-lib=*) oss_lib="$optarg"
  1013. ;;
  1014. --audio-drv-list=*) audio_drv_list="$optarg"
  1015. ;;
  1016. --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
  1017. ;;
  1018. --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
  1019. ;;
  1020. --enable-debug-tcg) debug_tcg="yes"
  1021. ;;
  1022. --disable-debug-tcg) debug_tcg="no"
  1023. ;;
  1024. --enable-debug)
  1025. # Enable debugging options that aren't excessively noisy
  1026. debug_tcg="yes"
  1027. debug_mutex="yes"
  1028. debug="yes"
  1029. strip_opt="no"
  1030. fortify_source="no"
  1031. ;;
  1032. --enable-sanitizers) sanitizers="yes"
  1033. ;;
  1034. --disable-sanitizers) sanitizers="no"
  1035. ;;
  1036. --enable-sparse) sparse="yes"
  1037. ;;
  1038. --disable-sparse) sparse="no"
  1039. ;;
  1040. --disable-strip) strip_opt="no"
  1041. ;;
  1042. --disable-vnc-sasl) vnc_sasl="no"
  1043. ;;
  1044. --enable-vnc-sasl) vnc_sasl="yes"
  1045. ;;
  1046. --disable-vnc-jpeg) vnc_jpeg="no"
  1047. ;;
  1048. --enable-vnc-jpeg) vnc_jpeg="yes"
  1049. ;;
  1050. --disable-vnc-png) vnc_png="no"
  1051. ;;
  1052. --enable-vnc-png) vnc_png="yes"
  1053. ;;
  1054. --disable-slirp) slirp="no"
  1055. ;;
  1056. --enable-slirp=system) slirp="system"
  1057. ;;
  1058. --disable-vde) vde="no"
  1059. ;;
  1060. --enable-vde) vde="yes"
  1061. ;;
  1062. --disable-netmap) netmap="no"
  1063. ;;
  1064. --enable-netmap) netmap="yes"
  1065. ;;
  1066. --disable-xen) xen="no"
  1067. ;;
  1068. --enable-xen) xen="yes"
  1069. ;;
  1070. --disable-xen-pci-passthrough) xen_pci_passthrough="no"
  1071. ;;
  1072. --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
  1073. ;;
  1074. --disable-brlapi) brlapi="no"
  1075. ;;
  1076. --enable-brlapi) brlapi="yes"
  1077. ;;
  1078. --disable-bluez) bluez="no"
  1079. ;;
  1080. --enable-bluez) bluez="yes"
  1081. ;;
  1082. --disable-kvm) kvm="no"
  1083. ;;
  1084. --enable-kvm) kvm="yes"
  1085. ;;
  1086. --disable-hax) hax="no"
  1087. ;;
  1088. --enable-hax) hax="yes"
  1089. ;;
  1090. --disable-hvf) hvf="no"
  1091. ;;
  1092. --enable-hvf) hvf="yes"
  1093. ;;
  1094. --disable-whpx) whpx="no"
  1095. ;;
  1096. --enable-whpx) whpx="yes"
  1097. ;;
  1098. --disable-tcg-interpreter) tcg_interpreter="no"
  1099. ;;
  1100. --enable-tcg-interpreter) tcg_interpreter="yes"
  1101. ;;
  1102. --disable-cap-ng) cap_ng="no"
  1103. ;;
  1104. --enable-cap-ng) cap_ng="yes"
  1105. ;;
  1106. --disable-tcg) tcg="no"
  1107. ;;
  1108. --enable-tcg) tcg="yes"
  1109. ;;
  1110. --disable-malloc-trim) malloc_trim="no"
  1111. ;;
  1112. --enable-malloc-trim) malloc_trim="yes"
  1113. ;;
  1114. --disable-spice) spice="no"
  1115. ;;
  1116. --enable-spice) spice="yes"
  1117. ;;
  1118. --disable-libiscsi) libiscsi="no"
  1119. ;;
  1120. --enable-libiscsi) libiscsi="yes"
  1121. ;;
  1122. --disable-libnfs) libnfs="no"
  1123. ;;
  1124. --enable-libnfs) libnfs="yes"
  1125. ;;
  1126. --enable-profiler) profiler="yes"
  1127. ;;
  1128. --disable-cocoa) cocoa="no"
  1129. ;;
  1130. --enable-cocoa)
  1131. cocoa="yes" ;
  1132. audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
  1133. ;;
  1134. --disable-system) softmmu="no"
  1135. ;;
  1136. --enable-system) softmmu="yes"
  1137. ;;
  1138. --disable-user)
  1139. linux_user="no" ;
  1140. bsd_user="no" ;
  1141. ;;
  1142. --enable-user) ;;
  1143. --disable-linux-user) linux_user="no"
  1144. ;;
  1145. --enable-linux-user) linux_user="yes"
  1146. ;;
  1147. --disable-bsd-user) bsd_user="no"
  1148. ;;
  1149. --enable-bsd-user) bsd_user="yes"
  1150. ;;
  1151. --enable-pie) pie="yes"
  1152. ;;
  1153. --disable-pie) pie="no"
  1154. ;;
  1155. --enable-werror) werror="yes"
  1156. ;;
  1157. --disable-werror) werror="no"
  1158. ;;
  1159. --enable-stack-protector) stack_protector="yes"
  1160. ;;
  1161. --disable-stack-protector) stack_protector="no"
  1162. ;;
  1163. --disable-curses) curses="no"
  1164. ;;
  1165. --enable-curses) curses="yes"
  1166. ;;
  1167. --disable-iconv) iconv="no"
  1168. ;;
  1169. --enable-iconv) iconv="yes"
  1170. ;;
  1171. --disable-curl) curl="no"
  1172. ;;
  1173. --enable-curl) curl="yes"
  1174. ;;
  1175. --disable-fdt) fdt="no"
  1176. ;;
  1177. --enable-fdt) fdt="yes"
  1178. ;;
  1179. --disable-linux-aio) linux_aio="no"
  1180. ;;
  1181. --enable-linux-aio) linux_aio="yes"
  1182. ;;
  1183. --disable-attr) attr="no"
  1184. ;;
  1185. --enable-attr) attr="yes"
  1186. ;;
  1187. --disable-membarrier) membarrier="no"
  1188. ;;
  1189. --enable-membarrier) membarrier="yes"
  1190. ;;
  1191. --disable-blobs) blobs="no"
  1192. ;;
  1193. --with-pkgversion=*) pkgversion="$optarg"
  1194. ;;
  1195. --with-coroutine=*) coroutine="$optarg"
  1196. ;;
  1197. --disable-coroutine-pool) coroutine_pool="no"
  1198. ;;
  1199. --enable-coroutine-pool) coroutine_pool="yes"
  1200. ;;
  1201. --enable-debug-stack-usage) debug_stack_usage="yes"
  1202. ;;
  1203. --enable-crypto-afalg) crypto_afalg="yes"
  1204. ;;
  1205. --disable-crypto-afalg) crypto_afalg="no"
  1206. ;;
  1207. --disable-docs) docs="no"
  1208. ;;
  1209. --enable-docs) docs="yes"
  1210. ;;
  1211. --disable-vhost-net) vhost_net="no"
  1212. ;;
  1213. --enable-vhost-net) vhost_net="yes"
  1214. ;;
  1215. --disable-vhost-crypto) vhost_crypto="no"
  1216. ;;
  1217. --enable-vhost-crypto) vhost_crypto="yes"
  1218. ;;
  1219. --disable-vhost-scsi) vhost_scsi="no"
  1220. ;;
  1221. --enable-vhost-scsi) vhost_scsi="yes"
  1222. ;;
  1223. --disable-vhost-vsock) vhost_vsock="no"
  1224. ;;
  1225. --enable-vhost-vsock) vhost_vsock="yes"
  1226. ;;
  1227. --disable-opengl) opengl="no"
  1228. ;;
  1229. --enable-opengl) opengl="yes"
  1230. ;;
  1231. --disable-rbd) rbd="no"
  1232. ;;
  1233. --enable-rbd) rbd="yes"
  1234. ;;
  1235. --disable-xfsctl) xfs="no"
  1236. ;;
  1237. --enable-xfsctl) xfs="yes"
  1238. ;;
  1239. --disable-smartcard) smartcard="no"
  1240. ;;
  1241. --enable-smartcard) smartcard="yes"
  1242. ;;
  1243. --disable-libusb) libusb="no"
  1244. ;;
  1245. --enable-libusb) libusb="yes"
  1246. ;;
  1247. --disable-usb-redir) usb_redir="no"
  1248. ;;
  1249. --enable-usb-redir) usb_redir="yes"
  1250. ;;
  1251. --disable-zlib-test) zlib="no"
  1252. ;;
  1253. --disable-lzo) lzo="no"
  1254. ;;
  1255. --enable-lzo) lzo="yes"
  1256. ;;
  1257. --disable-snappy) snappy="no"
  1258. ;;
  1259. --enable-snappy) snappy="yes"
  1260. ;;
  1261. --disable-bzip2) bzip2="no"
  1262. ;;
  1263. --enable-bzip2) bzip2="yes"
  1264. ;;
  1265. --enable-lzfse) lzfse="yes"
  1266. ;;
  1267. --disable-lzfse) lzfse="no"
  1268. ;;
  1269. --enable-guest-agent) guest_agent="yes"
  1270. ;;
  1271. --disable-guest-agent) guest_agent="no"
  1272. ;;
  1273. --enable-guest-agent-msi) guest_agent_msi="yes"
  1274. ;;
  1275. --disable-guest-agent-msi) guest_agent_msi="no"
  1276. ;;
  1277. --with-vss-sdk) vss_win32_sdk=""
  1278. ;;
  1279. --with-vss-sdk=*) vss_win32_sdk="$optarg"
  1280. ;;
  1281. --without-vss-sdk) vss_win32_sdk="no"
  1282. ;;
  1283. --with-win-sdk) win_sdk=""
  1284. ;;
  1285. --with-win-sdk=*) win_sdk="$optarg"
  1286. ;;
  1287. --without-win-sdk) win_sdk="no"
  1288. ;;
  1289. --enable-tools) want_tools="yes"
  1290. ;;
  1291. --disable-tools) want_tools="no"
  1292. ;;
  1293. --enable-seccomp) seccomp="yes"
  1294. ;;
  1295. --disable-seccomp) seccomp="no"
  1296. ;;
  1297. --disable-glusterfs) glusterfs="no"
  1298. ;;
  1299. --disable-avx2) avx2_opt="no"
  1300. ;;
  1301. --enable-avx2) avx2_opt="yes"
  1302. ;;
  1303. --enable-glusterfs) glusterfs="yes"
  1304. ;;
  1305. --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
  1306. echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
  1307. ;;
  1308. --enable-vhdx|--disable-vhdx)
  1309. echo "$0: $opt is obsolete, VHDX driver is always built" >&2
  1310. ;;
  1311. --enable-uuid|--disable-uuid)
  1312. echo "$0: $opt is obsolete, UUID support is always built" >&2
  1313. ;;
  1314. --disable-gtk) gtk="no"
  1315. ;;
  1316. --enable-gtk) gtk="yes"
  1317. ;;
  1318. --tls-priority=*) tls_priority="$optarg"
  1319. ;;
  1320. --disable-gnutls) gnutls="no"
  1321. ;;
  1322. --enable-gnutls) gnutls="yes"
  1323. ;;
  1324. --disable-nettle) nettle="no"
  1325. ;;
  1326. --enable-nettle) nettle="yes"
  1327. ;;
  1328. --disable-gcrypt) gcrypt="no"
  1329. ;;
  1330. --enable-gcrypt) gcrypt="yes"
  1331. ;;
  1332. --disable-auth-pam) auth_pam="no"
  1333. ;;
  1334. --enable-auth-pam) auth_pam="yes"
  1335. ;;
  1336. --enable-rdma) rdma="yes"
  1337. ;;
  1338. --disable-rdma) rdma="no"
  1339. ;;
  1340. --enable-pvrdma) pvrdma="yes"
  1341. ;;
  1342. --disable-pvrdma) pvrdma="no"
  1343. ;;
  1344. --disable-vte) vte="no"
  1345. ;;
  1346. --enable-vte) vte="yes"
  1347. ;;
  1348. --disable-virglrenderer) virglrenderer="no"
  1349. ;;
  1350. --enable-virglrenderer) virglrenderer="yes"
  1351. ;;
  1352. --disable-tpm) tpm="no"
  1353. ;;
  1354. --enable-tpm) tpm="yes"
  1355. ;;
  1356. --disable-libssh2) libssh2="no"
  1357. ;;
  1358. --enable-libssh2) libssh2="yes"
  1359. ;;
  1360. --disable-live-block-migration) live_block_migration="no"
  1361. ;;
  1362. --enable-live-block-migration) live_block_migration="yes"
  1363. ;;
  1364. --disable-numa) numa="no"
  1365. ;;
  1366. --enable-numa) numa="yes"
  1367. ;;
  1368. --disable-libxml2) libxml2="no"
  1369. ;;
  1370. --enable-libxml2) libxml2="yes"
  1371. ;;
  1372. --disable-tcmalloc) tcmalloc="no"
  1373. ;;
  1374. --enable-tcmalloc) tcmalloc="yes"
  1375. ;;
  1376. --disable-jemalloc) jemalloc="no"
  1377. ;;
  1378. --enable-jemalloc) jemalloc="yes"
  1379. ;;
  1380. --disable-replication) replication="no"
  1381. ;;
  1382. --enable-replication) replication="yes"
  1383. ;;
  1384. --disable-vxhs) vxhs="no"
  1385. ;;
  1386. --enable-vxhs) vxhs="yes"
  1387. ;;
  1388. --disable-bochs) bochs="no"
  1389. ;;
  1390. --enable-bochs) bochs="yes"
  1391. ;;
  1392. --disable-cloop) cloop="no"
  1393. ;;
  1394. --enable-cloop) cloop="yes"
  1395. ;;
  1396. --disable-dmg) dmg="no"
  1397. ;;
  1398. --enable-dmg) dmg="yes"
  1399. ;;
  1400. --disable-qcow1) qcow1="no"
  1401. ;;
  1402. --enable-qcow1) qcow1="yes"
  1403. ;;
  1404. --disable-vdi) vdi="no"
  1405. ;;
  1406. --enable-vdi) vdi="yes"
  1407. ;;
  1408. --disable-vvfat) vvfat="no"
  1409. ;;
  1410. --enable-vvfat) vvfat="yes"
  1411. ;;
  1412. --disable-qed) qed="no"
  1413. ;;
  1414. --enable-qed) qed="yes"
  1415. ;;
  1416. --disable-parallels) parallels="no"
  1417. ;;
  1418. --enable-parallels) parallels="yes"
  1419. ;;
  1420. --disable-sheepdog) sheepdog="no"
  1421. ;;
  1422. --enable-sheepdog) sheepdog="yes"
  1423. ;;
  1424. --disable-vhost-user) vhost_user="no"
  1425. ;;
  1426. --enable-vhost-user) vhost_user="yes"
  1427. ;;
  1428. --disable-vhost-kernel) vhost_kernel="no"
  1429. ;;
  1430. --enable-vhost-kernel) vhost_kernel="yes"
  1431. ;;
  1432. --disable-capstone) capstone="no"
  1433. ;;
  1434. --enable-capstone) capstone="yes"
  1435. ;;
  1436. --enable-capstone=git) capstone="git"
  1437. ;;
  1438. --enable-capstone=system) capstone="system"
  1439. ;;
  1440. --with-git=*) git="$optarg"
  1441. ;;
  1442. --enable-git-update) git_update=yes
  1443. ;;
  1444. --disable-git-update) git_update=no
  1445. ;;
  1446. --enable-debug-mutex) debug_mutex=yes
  1447. ;;
  1448. --disable-debug-mutex) debug_mutex=no
  1449. ;;
  1450. --enable-libpmem) libpmem=yes
  1451. ;;
  1452. --disable-libpmem) libpmem=no
  1453. ;;
  1454. *)
  1455. echo "ERROR: unknown option $opt"
  1456. echo "Try '$0 --help' for more information"
  1457. exit 1
  1458. ;;
  1459. esac
  1460. done
  1461. case "$cpu" in
  1462. ppc)
  1463. CPU_CFLAGS="-m32"
  1464. LDFLAGS="-m32 $LDFLAGS"
  1465. cross_cc_powerpc=$cc
  1466. cross_cc_cflags_powerpc=$CPU_CFLAGS
  1467. ;;
  1468. ppc64)
  1469. CPU_CFLAGS="-m64"
  1470. LDFLAGS="-m64 $LDFLAGS"
  1471. cross_cc_ppc64=$cc
  1472. cross_cc_cflags_ppc64=$CPU_CFLAGS
  1473. ;;
  1474. sparc)
  1475. CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
  1476. LDFLAGS="-m32 -mv8plus $LDFLAGS"
  1477. cross_cc_sparc=$cc
  1478. cross_cc_cflags_sparc=$CPU_CFLAGS
  1479. ;;
  1480. sparc64)
  1481. CPU_CFLAGS="-m64 -mcpu=ultrasparc"
  1482. LDFLAGS="-m64 $LDFLAGS"
  1483. cross_cc_sparc64=$cc
  1484. cross_cc_cflags_sparc64=$CPU_CFLAGS
  1485. ;;
  1486. s390)
  1487. CPU_CFLAGS="-m31"
  1488. LDFLAGS="-m31 $LDFLAGS"
  1489. cross_cc_s390=$cc
  1490. cross_cc_cflags_s390=$CPU_CFLAGS
  1491. ;;
  1492. s390x)
  1493. CPU_CFLAGS="-m64"
  1494. LDFLAGS="-m64 $LDFLAGS"
  1495. cross_cc_s390x=$cc
  1496. cross_cc_cflags_s390x=$CPU_CFLAGS
  1497. ;;
  1498. i386)
  1499. CPU_CFLAGS="-m32"
  1500. LDFLAGS="-m32 $LDFLAGS"
  1501. cross_cc_i386=$cc
  1502. cross_cc_cflags_i386=$CPU_CFLAGS
  1503. ;;
  1504. x86_64)
  1505. # ??? Only extremely old AMD cpus do not have cmpxchg16b.
  1506. # If we truly care, we should simply detect this case at
  1507. # runtime and generate the fallback to serial emulation.
  1508. CPU_CFLAGS="-m64 -mcx16"
  1509. LDFLAGS="-m64 $LDFLAGS"
  1510. cross_cc_x86_64=$cc
  1511. cross_cc_cflags_x86_64=$CPU_CFLAGS
  1512. ;;
  1513. x32)
  1514. CPU_CFLAGS="-mx32"
  1515. LDFLAGS="-mx32 $LDFLAGS"
  1516. cross_cc_i386=$cc
  1517. cross_cc_cflags_i386=$CPU_CFLAGS
  1518. ;;
  1519. # No special flags required for other host CPUs
  1520. esac
  1521. QEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
  1522. # For user-mode emulation the host arch has to be one we explicitly
  1523. # support, even if we're using TCI.
  1524. if [ "$ARCH" = "unknown" ]; then
  1525. bsd_user="no"
  1526. linux_user="no"
  1527. fi
  1528. default_target_list=""
  1529. mak_wilds=""
  1530. if [ "$softmmu" = "yes" ]; then
  1531. mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
  1532. fi
  1533. if [ "$linux_user" = "yes" ]; then
  1534. mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
  1535. fi
  1536. if [ "$bsd_user" = "yes" ]; then
  1537. mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
  1538. fi
  1539. if test -z "$target_list_exclude"; then
  1540. for config in $mak_wilds; do
  1541. default_target_list="${default_target_list} $(basename "$config" .mak)"
  1542. done
  1543. else
  1544. exclude_list=$(echo "$target_list_exclude" | sed -e 's/,/ /g')
  1545. for config in $mak_wilds; do
  1546. target="$(basename "$config" .mak)"
  1547. exclude="no"
  1548. for excl in $exclude_list; do
  1549. if test "$excl" = "$target"; then
  1550. exclude="yes"
  1551. break;
  1552. fi
  1553. done
  1554. if test "$exclude" = "no"; then
  1555. default_target_list="${default_target_list} $target"
  1556. fi
  1557. done
  1558. fi
  1559. # Enumerate public trace backends for --help output
  1560. trace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
  1561. if test x"$show_help" = x"yes" ; then
  1562. cat << EOF
  1563. Usage: configure [options]
  1564. Options: [defaults in brackets after descriptions]
  1565. Standard options:
  1566. --help print this message
  1567. --prefix=PREFIX install in PREFIX [$prefix]
  1568. --interp-prefix=PREFIX where to find shared libraries, etc.
  1569. use %M for cpu name [$interp_prefix]
  1570. --target-list=LIST set target list (default: build everything)
  1571. $(echo Available targets: $default_target_list | \
  1572. fold -s -w 53 | sed -e 's/^/ /')
  1573. --target-list-exclude=LIST exclude a set of targets from the default target-list
  1574. Advanced options (experts only):
  1575. --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
  1576. --cc=CC use C compiler CC [$cc]
  1577. --iasl=IASL use ACPI compiler IASL [$iasl]
  1578. --host-cc=CC use C compiler CC [$host_cc] for code run at
  1579. build time
  1580. --cxx=CXX use C++ compiler CXX [$cxx]
  1581. --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
  1582. --extra-cflags=CFLAGS append extra C compiler flags QEMU_CFLAGS
  1583. --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
  1584. --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS
  1585. --cross-cc-ARCH=CC use compiler when building ARCH guest test cases
  1586. --cross-cc-flags-ARCH= use compiler flags when building ARCH guest tests
  1587. --make=MAKE use specified make [$make]
  1588. --install=INSTALL use specified install [$install]
  1589. --python=PYTHON use specified python [$python]
  1590. --smbd=SMBD use specified smbd [$smbd]
  1591. --with-git=GIT use specified git [$git]
  1592. --static enable static build [$static]
  1593. --mandir=PATH install man pages in PATH
  1594. --datadir=PATH install firmware in PATH$confsuffix
  1595. --docdir=PATH install documentation in PATH$confsuffix
  1596. --bindir=PATH install binaries in PATH
  1597. --libdir=PATH install libraries in PATH
  1598. --libexecdir=PATH install helper binaries in PATH
  1599. --sysconfdir=PATH install config in PATH$confsuffix
  1600. --localstatedir=PATH install local state in PATH (set at runtime on win32)
  1601. --firmwarepath=PATH search PATH for firmware files
  1602. --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
  1603. --with-pkgversion=VERS use specified string as sub-version of the package
  1604. --enable-debug enable common debug build options
  1605. --enable-sanitizers enable default sanitizers
  1606. --disable-strip disable stripping binaries
  1607. --disable-werror disable compilation abort on warning
  1608. --disable-stack-protector disable compiler-provided stack protection
  1609. --audio-drv-list=LIST set audio drivers list:
  1610. Available drivers: $audio_possible_drivers
  1611. --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L
  1612. --block-drv-rw-whitelist=L
  1613. set block driver read-write whitelist
  1614. (affects only QEMU, not qemu-img)
  1615. --block-drv-ro-whitelist=L
  1616. set block driver read-only whitelist
  1617. (affects only QEMU, not qemu-img)
  1618. --enable-trace-backends=B Set trace backend
  1619. Available backends: $trace_backend_list
  1620. --with-trace-file=NAME Full PATH,NAME of file to store traces
  1621. Default:trace-<pid>
  1622. --disable-slirp disable SLIRP userspace network connectivity
  1623. --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
  1624. --enable-malloc-trim enable libc malloc_trim() for memory optimization
  1625. --oss-lib path to OSS library
  1626. --cpu=CPU Build for host CPU [$cpu]
  1627. --with-coroutine=BACKEND coroutine backend. Supported options:
  1628. ucontext, sigaltstack, windows
  1629. --enable-gcov enable test coverage analysis with gcov
  1630. --gcov=GCOV use specified gcov [$gcov_tool]
  1631. --disable-blobs disable installing provided firmware blobs
  1632. --with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent
  1633. --with-win-sdk=SDK-path path to Windows Platform SDK (to build VSS .tlb)
  1634. --tls-priority default TLS protocol/cipher priority string
  1635. --enable-gprof QEMU profiling with gprof
  1636. --enable-profiler profiler support
  1637. --enable-debug-stack-usage
  1638. track the maximum stack usage of stacks created by qemu_alloc_stack
  1639. Optional features, enabled with --enable-FEATURE and
  1640. disabled with --disable-FEATURE, default is enabled if available:
  1641. system all system emulation targets
  1642. user supported user emulation targets
  1643. linux-user all linux usermode emulation targets
  1644. bsd-user all BSD usermode emulation targets
  1645. docs build documentation
  1646. guest-agent build the QEMU Guest Agent
  1647. guest-agent-msi build guest agent Windows MSI installation package
  1648. pie Position Independent Executables
  1649. modules modules support
  1650. debug-tcg TCG debugging (default is disabled)
  1651. debug-info debugging information
  1652. sparse sparse checker
  1653. gnutls GNUTLS cryptography support
  1654. nettle nettle cryptography support
  1655. gcrypt libgcrypt cryptography support
  1656. auth-pam PAM access control
  1657. sdl SDL UI
  1658. sdl_image SDL Image support for icons
  1659. gtk gtk UI
  1660. vte vte support for the gtk UI
  1661. curses curses UI
  1662. iconv font glyph conversion support
  1663. vnc VNC UI support
  1664. vnc-sasl SASL encryption for VNC server
  1665. vnc-jpeg JPEG lossy compression for VNC server
  1666. vnc-png PNG compression for VNC server
  1667. cocoa Cocoa UI (Mac OS X only)
  1668. virtfs VirtFS
  1669. mpath Multipath persistent reservation passthrough
  1670. xen xen backend driver support
  1671. xen-pci-passthrough PCI passthrough support for Xen
  1672. brlapi BrlAPI (Braile)
  1673. curl curl connectivity
  1674. membarrier membarrier system call (for Linux 4.14+ or Windows)
  1675. fdt fdt device tree
  1676. bluez bluez stack connectivity
  1677. kvm KVM acceleration support
  1678. hax HAX acceleration support
  1679. hvf Hypervisor.framework acceleration support
  1680. whpx Windows Hypervisor Platform acceleration support
  1681. rdma Enable RDMA-based migration
  1682. pvrdma Enable PVRDMA support
  1683. vde support for vde network
  1684. netmap support for netmap network
  1685. linux-aio Linux AIO support
  1686. cap-ng libcap-ng support
  1687. attr attr and xattr support
  1688. vhost-net vhost-net kernel acceleration support
  1689. vhost-vsock virtio sockets device support
  1690. vhost-scsi vhost-scsi kernel target support
  1691. vhost-crypto vhost-user-crypto backend support
  1692. vhost-kernel vhost kernel backend support
  1693. vhost-user vhost-user backend support
  1694. spice spice
  1695. rbd rados block device (rbd)
  1696. libiscsi iscsi support
  1697. libnfs nfs support
  1698. smartcard smartcard support (libcacard)
  1699. libusb libusb (for usb passthrough)
  1700. live-block-migration Block migration in the main migration stream
  1701. usb-redir usb network redirection support
  1702. lzo support of lzo compression library
  1703. snappy support of snappy compression library
  1704. bzip2 support of bzip2 compression library
  1705. (for reading bzip2-compressed dmg images)
  1706. lzfse support of lzfse compression library
  1707. (for reading lzfse-compressed dmg images)
  1708. seccomp seccomp support
  1709. coroutine-pool coroutine freelist (better performance)
  1710. glusterfs GlusterFS backend
  1711. tpm TPM support
  1712. libssh2 ssh block device support
  1713. numa libnuma support
  1714. libxml2 for Parallels image format
  1715. tcmalloc tcmalloc support
  1716. jemalloc jemalloc support
  1717. avx2 AVX2 optimization support
  1718. replication replication support
  1719. opengl opengl support
  1720. virglrenderer virgl rendering support
  1721. xfsctl xfsctl support
  1722. qom-cast-debug cast debugging support
  1723. tools build qemu-io, qemu-nbd and qemu-img tools
  1724. vxhs Veritas HyperScale vDisk backend support
  1725. bochs bochs image format support
  1726. cloop cloop image format support
  1727. dmg dmg image format support
  1728. qcow1 qcow v1 image format support
  1729. vdi vdi image format support
  1730. vvfat vvfat image format support
  1731. qed qed image format support
  1732. parallels parallels image format support
  1733. sheepdog sheepdog block driver support
  1734. crypto-afalg Linux AF_ALG crypto backend driver
  1735. capstone capstone disassembler support
  1736. debug-mutex mutex debugging support
  1737. libpmem libpmem support
  1738. NOTE: The object files are built at the place where configure is launched
  1739. EOF
  1740. exit 0
  1741. fi
  1742. if ! has $python; then
  1743. error_exit "Python not found. Use --python=/path/to/python"
  1744. fi
  1745. # Note that if the Python conditional here evaluates True we will exit
  1746. # with status 1 which is a shell 'false' value.
  1747. if ! $python -c 'import sys; sys.exit(sys.version_info < (2,7))'; then
  1748. error_exit "Cannot use '$python', Python 2 >= 2.7 or Python 3 is required." \
  1749. "Use --python=/path/to/python to specify a supported Python."
  1750. fi
  1751. # Preserve python version since some functionality is dependent on it
  1752. python_version=$($python -V 2>&1 | sed -e 's/Python\ //')
  1753. # Suppress writing compiled files
  1754. python="$python -B"
  1755. # Check that the C compiler works. Doing this here before testing
  1756. # the host CPU ensures that we had a valid CC to autodetect the
  1757. # $cpu var (and we should bail right here if that's not the case).
  1758. # It also allows the help message to be printed without a CC.
  1759. write_c_skeleton;
  1760. if compile_object ; then
  1761. : C compiler works ok
  1762. else
  1763. error_exit "\"$cc\" either does not exist or does not work"
  1764. fi
  1765. if ! compile_prog ; then
  1766. error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
  1767. fi
  1768. # Now we have handled --enable-tcg-interpreter and know we're not just
  1769. # printing the help message, bail out if the host CPU isn't supported.
  1770. if test "$ARCH" = "unknown"; then
  1771. if test "$tcg_interpreter" = "yes" ; then
  1772. echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
  1773. else
  1774. error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
  1775. fi
  1776. fi
  1777. # Consult white-list to determine whether to enable werror
  1778. # by default. Only enable by default for git builds
  1779. if test -z "$werror" ; then
  1780. if test -e "$source_path/.git" && \
  1781. { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
  1782. werror="yes"
  1783. else
  1784. werror="no"
  1785. fi
  1786. fi
  1787. if test "$bogus_os" = "yes"; then
  1788. # Now that we know that we're not printing the help and that
  1789. # the compiler works (so the results of the check_defines we used
  1790. # to identify the OS are reliable), if we didn't recognize the
  1791. # host OS we should stop now.
  1792. error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
  1793. fi
  1794. # Check whether the compiler matches our minimum requirements:
  1795. cat > $TMPC << EOF
  1796. #if defined(__clang_major__) && defined(__clang_minor__)
  1797. # ifdef __apple_build_version__
  1798. # if __clang_major__ < 5 || (__clang_major__ == 5 && __clang_minor__ < 1)
  1799. # error You need at least XCode Clang v5.1 to compile QEMU
  1800. # endif
  1801. # else
  1802. # if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 4)
  1803. # error You need at least Clang v3.4 to compile QEMU
  1804. # endif
  1805. # endif
  1806. #elif defined(__GNUC__) && defined(__GNUC_MINOR__)
  1807. # if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8)
  1808. # error You need at least GCC v4.8 to compile QEMU
  1809. # endif
  1810. #else
  1811. # error You either need GCC or Clang to compiler QEMU
  1812. #endif
  1813. int main (void) { return 0; }
  1814. EOF
  1815. if ! compile_prog "" "" ; then
  1816. error_exit "You need at least GCC v4.8 or Clang v3.4 (or XCode Clang v5.1)"
  1817. fi
  1818. gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
  1819. gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
  1820. gcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
  1821. gcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
  1822. gcc_flags="-Wno-initializer-overrides -Wexpansion-to-defined $gcc_flags"
  1823. gcc_flags="-Wno-string-plus-int $gcc_flags"
  1824. # Note that we do not add -Werror to gcc_flags here, because that would
  1825. # enable it for all configure tests. If a configure test failed due
  1826. # to -Werror this would just silently disable some features,
  1827. # so it's too error prone.
  1828. cc_has_warning_flag() {
  1829. write_c_skeleton;
  1830. # Use the positive sense of the flag when testing for -Wno-wombat
  1831. # support (gcc will happily accept the -Wno- form of unknown
  1832. # warning options).
  1833. optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
  1834. compile_prog "-Werror $optflag" ""
  1835. }
  1836. for flag in $gcc_flags; do
  1837. if cc_has_warning_flag $flag ; then
  1838. QEMU_CFLAGS="$QEMU_CFLAGS $flag"
  1839. fi
  1840. done
  1841. if test "$stack_protector" != "no"; then
  1842. cat > $TMPC << EOF
  1843. int main(int argc, char *argv[])
  1844. {
  1845. char arr[64], *p = arr, *c = argv[0];
  1846. while (*c) {
  1847. *p++ = *c++;
  1848. }
  1849. return 0;
  1850. }
  1851. EOF
  1852. gcc_flags="-fstack-protector-strong -fstack-protector-all"
  1853. sp_on=0
  1854. for flag in $gcc_flags; do
  1855. # We need to check both a compile and a link, since some compiler
  1856. # setups fail only on a .c->.o compile and some only at link time
  1857. if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
  1858. compile_prog "-Werror $flag" ""; then
  1859. QEMU_CFLAGS="$QEMU_CFLAGS $flag"
  1860. sp_on=1
  1861. break
  1862. fi
  1863. done
  1864. if test "$stack_protector" = yes; then
  1865. if test $sp_on = 0; then
  1866. error_exit "Stack protector not supported"
  1867. fi
  1868. fi
  1869. fi
  1870. # Disable -Wmissing-braces on older compilers that warn even for
  1871. # the "universal" C zero initializer {0}.
  1872. cat > $TMPC << EOF
  1873. struct {
  1874. int a[2];
  1875. } x = {0};
  1876. EOF
  1877. if compile_object "-Werror" "" ; then
  1878. :
  1879. else
  1880. QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
  1881. fi
  1882. # Static linking is not possible with modules or PIE
  1883. if test "$static" = "yes" ; then
  1884. if test "$modules" = "yes" ; then
  1885. error_exit "static and modules are mutually incompatible"
  1886. fi
  1887. if test "$pie" = "yes" ; then
  1888. error_exit "static and pie are mutually incompatible"
  1889. else
  1890. pie="no"
  1891. fi
  1892. fi
  1893. # Unconditional check for compiler __thread support
  1894. cat > $TMPC << EOF
  1895. static __thread int tls_var;
  1896. int main(void) { return tls_var; }
  1897. EOF
  1898. if ! compile_prog "-Werror" "" ; then
  1899. error_exit "Your compiler does not support the __thread specifier for " \
  1900. "Thread-Local Storage (TLS). Please upgrade to a version that does."
  1901. fi
  1902. if test "$pie" = ""; then
  1903. case "$cpu-$targetos" in
  1904. i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
  1905. ;;
  1906. *)
  1907. pie="no"
  1908. ;;
  1909. esac
  1910. fi
  1911. if test "$pie" != "no" ; then
  1912. cat > $TMPC << EOF
  1913. #ifdef __linux__
  1914. # define THREAD __thread
  1915. #else
  1916. # define THREAD
  1917. #endif
  1918. static THREAD int tls_var;
  1919. int main(void) { return tls_var; }
  1920. EOF
  1921. if compile_prog "-fPIE -DPIE" "-pie"; then
  1922. QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
  1923. LDFLAGS="-pie $LDFLAGS"
  1924. pie="yes"
  1925. if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
  1926. LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
  1927. fi
  1928. else
  1929. if test "$pie" = "yes"; then
  1930. error_exit "PIE not available due to missing toolchain support"
  1931. else
  1932. echo "Disabling PIE due to missing toolchain support"
  1933. pie="no"
  1934. fi
  1935. fi
  1936. if compile_prog "-Werror -fno-pie" "-nopie"; then
  1937. CFLAGS_NOPIE="-fno-pie"
  1938. LDFLAGS_NOPIE="-nopie"
  1939. fi
  1940. fi
  1941. ##########################################
  1942. # __sync_fetch_and_and requires at least -march=i486. Many toolchains
  1943. # use i686 as default anyway, but for those that don't, an explicit
  1944. # specification is necessary
  1945. if test "$cpu" = "i386"; then
  1946. cat > $TMPC << EOF
  1947. static int sfaa(int *ptr)
  1948. {
  1949. return __sync_fetch_and_and(ptr, 0);
  1950. }
  1951. int main(void)
  1952. {
  1953. int val = 42;
  1954. val = __sync_val_compare_and_swap(&val, 0, 1);
  1955. sfaa(&val);
  1956. return val;
  1957. }
  1958. EOF
  1959. if ! compile_prog "" "" ; then
  1960. QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
  1961. fi
  1962. fi
  1963. #########################################
  1964. # Solaris specific configure tool chain decisions
  1965. if test "$solaris" = "yes" ; then
  1966. if has $install; then
  1967. :
  1968. else
  1969. error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
  1970. "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
  1971. "to get ginstall which is used by default (which lives in /opt/csw/bin)"
  1972. fi
  1973. if test "$(path_of $install)" = "/usr/sbin/install" ; then
  1974. error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
  1975. "try ginstall from the GNU fileutils available from www.blastwave.org" \
  1976. "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
  1977. fi
  1978. if has ar; then
  1979. :
  1980. else
  1981. if test -f /usr/ccs/bin/ar ; then
  1982. error_exit "No path includes ar" \
  1983. "Add /usr/ccs/bin to your path and rerun configure"
  1984. fi
  1985. error_exit "No path includes ar"
  1986. fi
  1987. fi
  1988. if test -z "${target_list+xxx}" ; then
  1989. for target in $default_target_list; do
  1990. supported_target $target 2>/dev/null && \
  1991. target_list="$target_list $target"
  1992. done
  1993. target_list="${target_list# }"
  1994. else
  1995. target_list=$(echo "$target_list" | sed -e 's/,/ /g')
  1996. for target in $target_list; do
  1997. # Check that we recognised the target name; this allows a more
  1998. # friendly error message than if we let it fall through.
  1999. case " $default_target_list " in
  2000. *" $target "*)
  2001. ;;
  2002. *)
  2003. error_exit "Unknown target name '$target'"
  2004. ;;
  2005. esac
  2006. supported_target $target || exit 1
  2007. done
  2008. fi
  2009. # see if system emulation was really requested
  2010. case " $target_list " in
  2011. *"-softmmu "*) softmmu=yes
  2012. ;;
  2013. *) softmmu=no
  2014. ;;
  2015. esac
  2016. feature_not_found() {
  2017. feature=$1
  2018. remedy=$2
  2019. error_exit "User requested feature $feature" \
  2020. "configure was not able to find it." \
  2021. "$remedy"
  2022. }
  2023. # ---
  2024. # big/little endian test
  2025. cat > $TMPC << EOF
  2026. short big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
  2027. short little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
  2028. extern int foo(short *, short *);
  2029. int main(int argc, char *argv[]) {
  2030. return foo(big_endian, little_endian);
  2031. }
  2032. EOF
  2033. if compile_object ; then
  2034. if strings -a $TMPO | grep -q BiGeNdIaN ; then
  2035. bigendian="yes"
  2036. elif strings -a $TMPO | grep -q LiTtLeEnDiAn ; then
  2037. bigendian="no"
  2038. else
  2039. echo big/little test failed
  2040. fi
  2041. else
  2042. echo big/little test failed
  2043. fi
  2044. ##########################################
  2045. # cocoa implies not SDL or GTK
  2046. # (the cocoa UI code currently assumes it is always the active UI
  2047. # and doesn't interact well with other UI frontend code)
  2048. if test "$cocoa" = "yes"; then
  2049. if test "$sdl" = "yes"; then
  2050. error_exit "Cocoa and SDL UIs cannot both be enabled at once"
  2051. fi
  2052. if test "$gtk" = "yes"; then
  2053. error_exit "Cocoa and GTK UIs cannot both be enabled at once"
  2054. fi
  2055. gtk=no
  2056. sdl=no
  2057. fi
  2058. # Some versions of Mac OS X incorrectly define SIZE_MAX
  2059. cat > $TMPC << EOF
  2060. #include <stdint.h>
  2061. #include <stdio.h>
  2062. int main(int argc, char *argv[]) {
  2063. return printf("%zu", SIZE_MAX);
  2064. }
  2065. EOF
  2066. have_broken_size_max=no
  2067. if ! compile_object -Werror ; then
  2068. have_broken_size_max=yes
  2069. fi
  2070. ##########################################
  2071. # L2TPV3 probe
  2072. cat > $TMPC <<EOF
  2073. #include <sys/socket.h>
  2074. #include <linux/ip.h>
  2075. int main(void) { return sizeof(struct mmsghdr); }
  2076. EOF
  2077. if compile_prog "" "" ; then
  2078. l2tpv3=yes
  2079. else
  2080. l2tpv3=no
  2081. fi
  2082. #########################################
  2083. # vhost interdependencies and host support
  2084. # vhost backends
  2085. test "$vhost_user" = "" && vhost_user=yes
  2086. if test "$vhost_user" = "yes" && test "$mingw32" = "yes"; then
  2087. error_exit "vhost-user isn't available on win32"
  2088. fi
  2089. test "$vhost_kernel" = "" && vhost_kernel=$linux
  2090. if test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then
  2091. error_exit "vhost-kernel is only available on Linux"
  2092. fi
  2093. # vhost-kernel devices
  2094. test "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel
  2095. if test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then
  2096. error_exit "--enable-vhost-scsi requires --enable-vhost-kernel"
  2097. fi
  2098. test "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel
  2099. if test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then
  2100. error_exit "--enable-vhost-vsock requires --enable-vhost-kernel"
  2101. fi
  2102. # vhost-user backends
  2103. test "$vhost_net_user" = "" && vhost_net_user=$vhost_user
  2104. if test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then
  2105. error_exit "--enable-vhost-net-user requires --enable-vhost-user"
  2106. fi
  2107. test "$vhost_crypto" = "" && vhost_crypto=$vhost_user
  2108. if test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then
  2109. error_exit "--enable-vhost-crypto requires --enable-vhost-user"
  2110. fi
  2111. # OR the vhost-kernel and vhost-user values for simplicity
  2112. if test "$vhost_net" = ""; then
  2113. test "$vhost_net_user" = "yes" && vhost_net=yes
  2114. test "$vhost_kernel" = "yes" && vhost_net=yes
  2115. fi
  2116. ##########################################
  2117. # MinGW / Mingw-w64 localtime_r/gmtime_r check
  2118. if test "$mingw32" = "yes"; then
  2119. # Some versions of MinGW / Mingw-w64 lack localtime_r
  2120. # and gmtime_r entirely.
  2121. #
  2122. # Some versions of Mingw-w64 define a macro for
  2123. # localtime_r/gmtime_r.
  2124. #
  2125. # Some versions of Mingw-w64 will define functions
  2126. # for localtime_r/gmtime_r, but only if you have
  2127. # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
  2128. # though, unistd.h and pthread.h both define
  2129. # that for you.
  2130. #
  2131. # So this #undef localtime_r and #include <unistd.h>
  2132. # are not in fact redundant.
  2133. cat > $TMPC << EOF
  2134. #include <unistd.h>
  2135. #include <time.h>
  2136. #undef localtime_r
  2137. int main(void) { localtime_r(NULL, NULL); return 0; }
  2138. EOF
  2139. if compile_prog "" "" ; then
  2140. localtime_r="yes"
  2141. else
  2142. localtime_r="no"
  2143. fi
  2144. fi
  2145. ##########################################
  2146. # pkg-config probe
  2147. if ! has "$pkg_config_exe"; then
  2148. error_exit "pkg-config binary '$pkg_config_exe' not found"
  2149. fi
  2150. ##########################################
  2151. # NPTL probe
  2152. if test "$linux_user" = "yes"; then
  2153. cat > $TMPC <<EOF
  2154. #include <sched.h>
  2155. #include <linux/futex.h>
  2156. int main(void) {
  2157. #if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
  2158. #error bork
  2159. #endif
  2160. return 0;
  2161. }
  2162. EOF
  2163. if ! compile_object ; then
  2164. feature_not_found "nptl" "Install glibc and linux kernel headers."
  2165. fi
  2166. fi
  2167. ##########################################
  2168. # lzo check
  2169. if test "$lzo" != "no" ; then
  2170. cat > $TMPC << EOF
  2171. #include <lzo/lzo1x.h>
  2172. int main(void) { lzo_version(); return 0; }
  2173. EOF
  2174. if compile_prog "" "-llzo2" ; then
  2175. libs_softmmu="$libs_softmmu -llzo2"
  2176. lzo="yes"
  2177. else
  2178. if test "$lzo" = "yes"; then
  2179. feature_not_found "liblzo2" "Install liblzo2 devel"
  2180. fi
  2181. lzo="no"
  2182. fi
  2183. fi
  2184. ##########################################
  2185. # snappy check
  2186. if test "$snappy" != "no" ; then
  2187. cat > $TMPC << EOF
  2188. #include <snappy-c.h>
  2189. int main(void) { snappy_max_compressed_length(4096); return 0; }
  2190. EOF
  2191. if compile_prog "" "-lsnappy" ; then
  2192. libs_softmmu="$libs_softmmu -lsnappy"
  2193. snappy="yes"
  2194. else
  2195. if test "$snappy" = "yes"; then
  2196. feature_not_found "libsnappy" "Install libsnappy devel"
  2197. fi
  2198. snappy="no"
  2199. fi
  2200. fi
  2201. ##########################################
  2202. # bzip2 check
  2203. if test "$bzip2" != "no" ; then
  2204. cat > $TMPC << EOF
  2205. #include <bzlib.h>
  2206. int main(void) { BZ2_bzlibVersion(); return 0; }
  2207. EOF
  2208. if compile_prog "" "-lbz2" ; then
  2209. bzip2="yes"
  2210. else
  2211. if test "$bzip2" = "yes"; then
  2212. feature_not_found "libbzip2" "Install libbzip2 devel"
  2213. fi
  2214. bzip2="no"
  2215. fi
  2216. fi
  2217. ##########################################
  2218. # lzfse check
  2219. if test "$lzfse" != "no" ; then
  2220. cat > $TMPC << EOF
  2221. #include <lzfse.h>
  2222. int main(void) { lzfse_decode_scratch_size(); return 0; }
  2223. EOF
  2224. if compile_prog "" "-llzfse" ; then
  2225. lzfse="yes"
  2226. else
  2227. if test "$lzfse" = "yes"; then
  2228. feature_not_found "lzfse" "Install lzfse devel"
  2229. fi
  2230. lzfse="no"
  2231. fi
  2232. fi
  2233. ##########################################
  2234. # libseccomp check
  2235. libseccomp_minver="2.2.0"
  2236. if test "$seccomp" != "no" ; then
  2237. case "$cpu" in
  2238. i386|x86_64|mips)
  2239. ;;
  2240. arm|aarch64)
  2241. libseccomp_minver="2.2.3"
  2242. ;;
  2243. ppc|ppc64|s390x)
  2244. libseccomp_minver="2.3.0"
  2245. ;;
  2246. *)
  2247. libseccomp_minver=""
  2248. ;;
  2249. esac
  2250. if test "$libseccomp_minver" != "" &&
  2251. $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
  2252. seccomp_cflags="$($pkg_config --cflags libseccomp)"
  2253. seccomp_libs="$($pkg_config --libs libseccomp)"
  2254. seccomp="yes"
  2255. else
  2256. if test "$seccomp" = "yes" ; then
  2257. if test "$libseccomp_minver" != "" ; then
  2258. feature_not_found "libseccomp" \
  2259. "Install libseccomp devel >= $libseccomp_minver"
  2260. else
  2261. feature_not_found "libseccomp" \
  2262. "libseccomp is not supported for host cpu $cpu"
  2263. fi
  2264. fi
  2265. seccomp="no"
  2266. fi
  2267. fi
  2268. ##########################################
  2269. # xen probe
  2270. if test "$xen" != "no" ; then
  2271. # Check whether Xen library path is specified via --extra-ldflags to avoid
  2272. # overriding this setting with pkg-config output. If not, try pkg-config
  2273. # to obtain all needed flags.
  2274. if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
  2275. $pkg_config --exists xencontrol ; then
  2276. xen_ctrl_version="$(printf '%d%02d%02d' \
  2277. $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
  2278. xen=yes
  2279. xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab"
  2280. xen_pc="$xen_pc xenevtchn xendevicemodel"
  2281. if $pkg_config --exists xentoolcore; then
  2282. xen_pc="$xen_pc xentoolcore"
  2283. fi
  2284. QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags $xen_pc)"
  2285. libs_softmmu="$($pkg_config --libs $xen_pc) $libs_softmmu"
  2286. else
  2287. xen_libs="-lxenstore -lxenctrl -lxenguest"
  2288. xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
  2289. # First we test whether Xen headers and libraries are available.
  2290. # If no, we are done and there is no Xen support.
  2291. # If yes, more tests are run to detect the Xen version.
  2292. # Xen (any)
  2293. cat > $TMPC <<EOF
  2294. #include <xenctrl.h>
  2295. int main(void) {
  2296. return 0;
  2297. }
  2298. EOF
  2299. if ! compile_prog "" "$xen_libs" ; then
  2300. # Xen not found
  2301. if test "$xen" = "yes" ; then
  2302. feature_not_found "xen" "Install xen devel"
  2303. fi
  2304. xen=no
  2305. # Xen unstable
  2306. elif
  2307. cat > $TMPC <<EOF &&
  2308. #undef XC_WANT_COMPAT_DEVICEMODEL_API
  2309. #define __XEN_TOOLS__
  2310. #include <xendevicemodel.h>
  2311. #include <xenforeignmemory.h>
  2312. int main(void) {
  2313. xendevicemodel_handle *xd;
  2314. xenforeignmemory_handle *xfmem;
  2315. xd = xendevicemodel_open(0, 0);
  2316. xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
  2317. xfmem = xenforeignmemory_open(0, 0);
  2318. xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
  2319. return 0;
  2320. }
  2321. EOF
  2322. compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
  2323. then
  2324. xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
  2325. xen_ctrl_version=41100
  2326. xen=yes
  2327. elif
  2328. cat > $TMPC <<EOF &&
  2329. #undef XC_WANT_COMPAT_MAP_FOREIGN_API
  2330. #include <xenforeignmemory.h>
  2331. #include <xentoolcore.h>
  2332. int main(void) {
  2333. xenforeignmemory_handle *xfmem;
  2334. xfmem = xenforeignmemory_open(0, 0);
  2335. xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
  2336. xentoolcore_restrict_all(0);
  2337. return 0;
  2338. }
  2339. EOF
  2340. compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
  2341. then
  2342. xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
  2343. xen_ctrl_version=41000
  2344. xen=yes
  2345. elif
  2346. cat > $TMPC <<EOF &&
  2347. #undef XC_WANT_COMPAT_DEVICEMODEL_API
  2348. #define __XEN_TOOLS__
  2349. #include <xendevicemodel.h>
  2350. int main(void) {
  2351. xendevicemodel_handle *xd;
  2352. xd = xendevicemodel_open(0, 0);
  2353. xendevicemodel_close(xd);
  2354. return 0;
  2355. }
  2356. EOF
  2357. compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
  2358. then
  2359. xen_stable_libs="-lxendevicemodel $xen_stable_libs"
  2360. xen_ctrl_version=40900
  2361. xen=yes
  2362. elif
  2363. cat > $TMPC <<EOF &&
  2364. /*
  2365. * If we have stable libs the we don't want the libxc compat
  2366. * layers, regardless of what CFLAGS we may have been given.
  2367. *
  2368. * Also, check if xengnttab_grant_copy_segment_t is defined and
  2369. * grant copy operation is implemented.
  2370. */
  2371. #undef XC_WANT_COMPAT_EVTCHN_API
  2372. #undef XC_WANT_COMPAT_GNTTAB_API
  2373. #undef XC_WANT_COMPAT_MAP_FOREIGN_API
  2374. #include <xenctrl.h>
  2375. #include <xenstore.h>
  2376. #include <xenevtchn.h>
  2377. #include <xengnttab.h>
  2378. #include <xenforeignmemory.h>
  2379. #include <stdint.h>
  2380. #include <xen/hvm/hvm_info_table.h>
  2381. #if !defined(HVM_MAX_VCPUS)
  2382. # error HVM_MAX_VCPUS not defined
  2383. #endif
  2384. int main(void) {
  2385. xc_interface *xc = NULL;
  2386. xenforeignmemory_handle *xfmem;
  2387. xenevtchn_handle *xe;
  2388. xengnttab_handle *xg;
  2389. xengnttab_grant_copy_segment_t* seg = NULL;
  2390. xs_daemon_open();
  2391. xc = xc_interface_open(0, 0, 0);
  2392. xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
  2393. xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
  2394. xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
  2395. xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
  2396. xfmem = xenforeignmemory_open(0, 0);
  2397. xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
  2398. xe = xenevtchn_open(0, 0);
  2399. xenevtchn_fd(xe);
  2400. xg = xengnttab_open(0, 0);
  2401. xengnttab_grant_copy(xg, 0, seg);
  2402. return 0;
  2403. }
  2404. EOF
  2405. compile_prog "" "$xen_libs $xen_stable_libs"
  2406. then
  2407. xen_ctrl_version=40800
  2408. xen=yes
  2409. elif
  2410. cat > $TMPC <<EOF &&
  2411. /*
  2412. * If we have stable libs the we don't want the libxc compat
  2413. * layers, regardless of what CFLAGS we may have been given.
  2414. */
  2415. #undef XC_WANT_COMPAT_EVTCHN_API
  2416. #undef XC_WANT_COMPAT_GNTTAB_API
  2417. #undef XC_WANT_COMPAT_MAP_FOREIGN_API
  2418. #include <xenctrl.h>
  2419. #include <xenstore.h>
  2420. #include <xenevtchn.h>
  2421. #include <xengnttab.h>
  2422. #include <xenforeignmemory.h>
  2423. #include <stdint.h>
  2424. #include <xen/hvm/hvm_info_table.h>
  2425. #if !defined(HVM_MAX_VCPUS)
  2426. # error HVM_MAX_VCPUS not defined
  2427. #endif
  2428. int main(void) {
  2429. xc_interface *xc = NULL;
  2430. xenforeignmemory_handle *xfmem;
  2431. xenevtchn_handle *xe;
  2432. xengnttab_handle *xg;
  2433. xs_daemon_open();
  2434. xc = xc_interface_open(0, 0, 0);
  2435. xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
  2436. xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
  2437. xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
  2438. xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
  2439. xfmem = xenforeignmemory_open(0, 0);
  2440. xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
  2441. xe = xenevtchn_open(0, 0);
  2442. xenevtchn_fd(xe);
  2443. xg = xengnttab_open(0, 0);
  2444. xengnttab_map_grant_ref(xg, 0, 0, 0);
  2445. return 0;
  2446. }
  2447. EOF
  2448. compile_prog "" "$xen_libs $xen_stable_libs"
  2449. then
  2450. xen_ctrl_version=40701
  2451. xen=yes
  2452. # Xen 4.6
  2453. elif
  2454. cat > $TMPC <<EOF &&
  2455. #include <xenctrl.h>
  2456. #include <xenstore.h>
  2457. #include <stdint.h>
  2458. #include <xen/hvm/hvm_info_table.h>
  2459. #if !defined(HVM_MAX_VCPUS)
  2460. # error HVM_MAX_VCPUS not defined
  2461. #endif
  2462. int main(void) {
  2463. xc_interface *xc;
  2464. xs_daemon_open();
  2465. xc = xc_interface_open(0, 0, 0);
  2466. xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
  2467. xc_gnttab_open(NULL, 0);
  2468. xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
  2469. xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
  2470. xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
  2471. xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
  2472. return 0;
  2473. }
  2474. EOF
  2475. compile_prog "" "$xen_libs"
  2476. then
  2477. xen_ctrl_version=40600
  2478. xen=yes
  2479. # Xen 4.5
  2480. elif
  2481. cat > $TMPC <<EOF &&
  2482. #include <xenctrl.h>
  2483. #include <xenstore.h>
  2484. #include <stdint.h>
  2485. #include <xen/hvm/hvm_info_table.h>
  2486. #if !defined(HVM_MAX_VCPUS)
  2487. # error HVM_MAX_VCPUS not defined
  2488. #endif
  2489. int main(void) {
  2490. xc_interface *xc;
  2491. xs_daemon_open();
  2492. xc = xc_interface_open(0, 0, 0);
  2493. xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
  2494. xc_gnttab_open(NULL, 0);
  2495. xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
  2496. xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
  2497. xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
  2498. return 0;
  2499. }
  2500. EOF
  2501. compile_prog "" "$xen_libs"
  2502. then
  2503. xen_ctrl_version=40500
  2504. xen=yes
  2505. elif
  2506. cat > $TMPC <<EOF &&
  2507. #include <xenctrl.h>
  2508. #include <xenstore.h>
  2509. #include <stdint.h>
  2510. #include <xen/hvm/hvm_info_table.h>
  2511. #if !defined(HVM_MAX_VCPUS)
  2512. # error HVM_MAX_VCPUS not defined
  2513. #endif
  2514. int main(void) {
  2515. xc_interface *xc;
  2516. xs_daemon_open();
  2517. xc = xc_interface_open(0, 0, 0);
  2518. xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
  2519. xc_gnttab_open(NULL, 0);
  2520. xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
  2521. xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
  2522. return 0;
  2523. }
  2524. EOF
  2525. compile_prog "" "$xen_libs"
  2526. then
  2527. xen_ctrl_version=40200
  2528. xen=yes
  2529. else
  2530. if test "$xen" = "yes" ; then
  2531. feature_not_found "xen (unsupported version)" \
  2532. "Install a supported xen (xen 4.2 or newer)"
  2533. fi
  2534. xen=no
  2535. fi
  2536. if test "$xen" = yes; then
  2537. if test $xen_ctrl_version -ge 40701 ; then
  2538. libs_softmmu="$xen_stable_libs $libs_softmmu"
  2539. fi
  2540. libs_softmmu="$xen_libs $libs_softmmu"
  2541. fi
  2542. fi
  2543. fi
  2544. if test "$xen_pci_passthrough" != "no"; then
  2545. if test "$xen" = "yes" && test "$linux" = "yes"; then
  2546. xen_pci_passthrough=yes
  2547. else
  2548. if test "$xen_pci_passthrough" = "yes"; then
  2549. error_exit "User requested feature Xen PCI Passthrough" \
  2550. " but this feature requires /sys from Linux"
  2551. fi
  2552. xen_pci_passthrough=no
  2553. fi
  2554. fi
  2555. ##########################################
  2556. # Windows Hypervisor Platform accelerator (WHPX) check
  2557. if test "$whpx" != "no" ; then
  2558. if check_include "WinHvPlatform.h" && check_include "WinHvEmulation.h"; then
  2559. whpx="yes"
  2560. else
  2561. if test "$whpx" = "yes"; then
  2562. feature_not_found "WinHvPlatform" "WinHvEmulation is not installed"
  2563. fi
  2564. whpx="no"
  2565. fi
  2566. fi
  2567. ##########################################
  2568. # Sparse probe
  2569. if test "$sparse" != "no" ; then
  2570. if has cgcc; then
  2571. sparse=yes
  2572. else
  2573. if test "$sparse" = "yes" ; then
  2574. feature_not_found "sparse" "Install sparse binary"
  2575. fi
  2576. sparse=no
  2577. fi
  2578. fi
  2579. ##########################################
  2580. # X11 probe
  2581. if $pkg_config --exists "x11"; then
  2582. have_x11=yes
  2583. x11_cflags=$($pkg_config --cflags x11)
  2584. x11_libs=$($pkg_config --libs x11)
  2585. fi
  2586. ##########################################
  2587. # GTK probe
  2588. if test "$gtk" != "no"; then
  2589. gtkpackage="gtk+-3.0"
  2590. gtkx11package="gtk+-x11-3.0"
  2591. gtkversion="3.14.0"
  2592. if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
  2593. gtk_cflags=$($pkg_config --cflags $gtkpackage)
  2594. gtk_libs=$($pkg_config --libs $gtkpackage)
  2595. gtk_version=$($pkg_config --modversion $gtkpackage)
  2596. if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
  2597. need_x11=yes
  2598. gtk_cflags="$gtk_cflags $x11_cflags"
  2599. gtk_libs="$gtk_libs $x11_libs"
  2600. fi
  2601. gtk="yes"
  2602. elif test "$gtk" = "yes"; then
  2603. feature_not_found "gtk" "Install gtk3-devel"
  2604. else
  2605. gtk="no"
  2606. fi
  2607. fi
  2608. ##########################################
  2609. # GNUTLS probe
  2610. if test "$gnutls" != "no"; then
  2611. if $pkg_config --exists "gnutls >= 3.1.18"; then
  2612. gnutls_cflags=$($pkg_config --cflags gnutls)
  2613. gnutls_libs=$($pkg_config --libs gnutls)
  2614. libs_softmmu="$gnutls_libs $libs_softmmu"
  2615. libs_tools="$gnutls_libs $libs_tools"
  2616. QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
  2617. gnutls="yes"
  2618. elif test "$gnutls" = "yes"; then
  2619. feature_not_found "gnutls" "Install gnutls devel >= 3.1.18"
  2620. else
  2621. gnutls="no"
  2622. fi
  2623. fi
  2624. # If user didn't give a --disable/enable-gcrypt flag,
  2625. # then mark as disabled if user requested nettle
  2626. # explicitly
  2627. if test -z "$gcrypt"
  2628. then
  2629. if test "$nettle" = "yes"
  2630. then
  2631. gcrypt="no"
  2632. fi
  2633. fi
  2634. # If user didn't give a --disable/enable-nettle flag,
  2635. # then mark as disabled if user requested gcrypt
  2636. # explicitly
  2637. if test -z "$nettle"
  2638. then
  2639. if test "$gcrypt" = "yes"
  2640. then
  2641. nettle="no"
  2642. fi
  2643. fi
  2644. has_libgcrypt() {
  2645. if ! has "libgcrypt-config"
  2646. then
  2647. return 1
  2648. fi
  2649. if test -n "$cross_prefix"
  2650. then
  2651. host=$(libgcrypt-config --host)
  2652. if test "$host-" != $cross_prefix
  2653. then
  2654. return 1
  2655. fi
  2656. fi
  2657. maj=`libgcrypt-config --version | awk -F . '{print $1}'`
  2658. min=`libgcrypt-config --version | awk -F . '{print $2}'`
  2659. if test $maj != 1 || test $min -lt 5
  2660. then
  2661. return 1
  2662. fi
  2663. return 0
  2664. }
  2665. if test "$nettle" != "no"; then
  2666. if $pkg_config --exists "nettle >= 2.7.1"; then
  2667. nettle_cflags=$($pkg_config --cflags nettle)
  2668. nettle_libs=$($pkg_config --libs nettle)
  2669. nettle_version=$($pkg_config --modversion nettle)
  2670. libs_softmmu="$nettle_libs $libs_softmmu"
  2671. libs_tools="$nettle_libs $libs_tools"
  2672. QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
  2673. nettle="yes"
  2674. if test -z "$gcrypt"; then
  2675. gcrypt="no"
  2676. fi
  2677. else
  2678. if test "$nettle" = "yes"; then
  2679. feature_not_found "nettle" "Install nettle devel >= 2.7.1"
  2680. else
  2681. nettle="no"
  2682. fi
  2683. fi
  2684. fi
  2685. if test "$gcrypt" != "no"; then
  2686. if has_libgcrypt; then
  2687. gcrypt_cflags=$(libgcrypt-config --cflags)
  2688. gcrypt_libs=$(libgcrypt-config --libs)
  2689. # Debian has remove -lgpg-error from libgcrypt-config
  2690. # as it "spreads unnecessary dependencies" which in
  2691. # turn breaks static builds...
  2692. if test "$static" = "yes"
  2693. then
  2694. gcrypt_libs="$gcrypt_libs -lgpg-error"
  2695. fi
  2696. libs_softmmu="$gcrypt_libs $libs_softmmu"
  2697. libs_tools="$gcrypt_libs $libs_tools"
  2698. QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
  2699. gcrypt="yes"
  2700. cat > $TMPC << EOF
  2701. #include <gcrypt.h>
  2702. int main(void) {
  2703. gcry_mac_hd_t handle;
  2704. gcry_mac_open(&handle, GCRY_MAC_HMAC_MD5,
  2705. GCRY_MAC_FLAG_SECURE, NULL);
  2706. return 0;
  2707. }
  2708. EOF
  2709. if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
  2710. gcrypt_hmac=yes
  2711. fi
  2712. else
  2713. if test "$gcrypt" = "yes"; then
  2714. feature_not_found "gcrypt" "Install gcrypt devel >= 1.5.0"
  2715. else
  2716. gcrypt="no"
  2717. fi
  2718. fi
  2719. fi
  2720. if test "$gcrypt" = "yes" && test "$nettle" = "yes"
  2721. then
  2722. error_exit "Only one of gcrypt & nettle can be enabled"
  2723. fi
  2724. ##########################################
  2725. # libtasn1 - only for the TLS creds/session test suite
  2726. tasn1=yes
  2727. tasn1_cflags=""
  2728. tasn1_libs=""
  2729. if $pkg_config --exists "libtasn1"; then
  2730. tasn1_cflags=$($pkg_config --cflags libtasn1)
  2731. tasn1_libs=$($pkg_config --libs libtasn1)
  2732. else
  2733. tasn1=no
  2734. fi
  2735. ##########################################
  2736. # PAM probe
  2737. if test "$auth_pam" != "no"; then
  2738. cat > $TMPC <<EOF
  2739. #include <security/pam_appl.h>
  2740. #include <stdio.h>
  2741. int main(void) {
  2742. const char *service_name = "qemu";
  2743. const char *user = "frank";
  2744. const struct pam_conv *pam_conv = NULL;
  2745. pam_handle_t *pamh = NULL;
  2746. pam_start(service_name, user, pam_conv, &pamh);
  2747. return 0;
  2748. }
  2749. EOF
  2750. if compile_prog "" "-lpam" ; then
  2751. auth_pam=yes
  2752. else
  2753. if test "$auth_pam" = "yes"; then
  2754. feature_not_found "PAM" "Install PAM development package"
  2755. else
  2756. auth_pam=no
  2757. fi
  2758. fi
  2759. fi
  2760. ##########################################
  2761. # getifaddrs (for tests/test-io-channel-socket )
  2762. have_ifaddrs_h=yes
  2763. if ! check_include "ifaddrs.h" ; then
  2764. have_ifaddrs_h=no
  2765. fi
  2766. ##########################################
  2767. # VTE probe
  2768. if test "$vte" != "no"; then
  2769. vteminversion="0.32.0"
  2770. if $pkg_config --exists "vte-2.91"; then
  2771. vtepackage="vte-2.91"
  2772. else
  2773. vtepackage="vte-2.90"
  2774. fi
  2775. if $pkg_config --exists "$vtepackage >= $vteminversion"; then
  2776. vte_cflags=$($pkg_config --cflags $vtepackage)
  2777. vte_libs=$($pkg_config --libs $vtepackage)
  2778. vteversion=$($pkg_config --modversion $vtepackage)
  2779. vte="yes"
  2780. elif test "$vte" = "yes"; then
  2781. feature_not_found "vte" "Install libvte-2.90/2.91 devel"
  2782. else
  2783. vte="no"
  2784. fi
  2785. fi
  2786. ##########################################
  2787. # SDL probe
  2788. # Look for sdl configuration program (pkg-config or sdl-config). Try
  2789. # sdl-config even without cross prefix, and favour pkg-config over sdl-config.
  2790. sdl_probe ()
  2791. {
  2792. if $pkg_config sdl2 --exists; then
  2793. sdlconfig="$pkg_config sdl2"
  2794. sdlversion=$($sdlconfig --modversion 2>/dev/null)
  2795. elif has ${sdl_config}; then
  2796. sdlconfig="$sdl2_config"
  2797. sdlversion=$($sdlconfig --version)
  2798. else
  2799. if test "$sdl" = "yes" ; then
  2800. feature_not_found "sdl" "Install SDL2-devel"
  2801. fi
  2802. sdl=no
  2803. # no need to do the rest
  2804. return
  2805. fi
  2806. if test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
  2807. echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
  2808. fi
  2809. cat > $TMPC << EOF
  2810. #include <SDL.h>
  2811. #undef main /* We don't want SDL to override our main() */
  2812. int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
  2813. EOF
  2814. sdl_cflags=$($sdlconfig --cflags 2>/dev/null)
  2815. sdl_cflags="$sdl_cflags -Wno-undef" # workaround 2.0.8 bug
  2816. if test "$static" = "yes" ; then
  2817. if $pkg_config sdl2 --exists; then
  2818. sdl_libs=$($pkg_config sdl2 --static --libs 2>/dev/null)
  2819. else
  2820. sdl_libs=$($sdlconfig --static-libs 2>/dev/null)
  2821. fi
  2822. else
  2823. sdl_libs=$($sdlconfig --libs 2>/dev/null)
  2824. fi
  2825. if compile_prog "$sdl_cflags" "$sdl_libs" ; then
  2826. sdl=yes
  2827. # static link with sdl ? (note: sdl.pc's --static --libs is broken)
  2828. if test "$sdl" = "yes" && test "$static" = "yes" ; then
  2829. if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
  2830. sdl_libs="$sdl_libs $(aalib-config --static-libs 2>/dev/null)"
  2831. sdl_cflags="$sdl_cflags $(aalib-config --cflags 2>/dev/null)"
  2832. fi
  2833. if compile_prog "$sdl_cflags" "$sdl_libs" ; then
  2834. :
  2835. else
  2836. sdl=no
  2837. fi
  2838. fi # static link
  2839. else # sdl not found
  2840. if test "$sdl" = "yes" ; then
  2841. feature_not_found "sdl" "Install SDL2 devel"
  2842. fi
  2843. sdl=no
  2844. fi # sdl compile test
  2845. }
  2846. sdl_image_probe ()
  2847. {
  2848. if test "$sdl_image" != "no" ; then
  2849. if $pkg_config SDL2_image --exists; then
  2850. if test "$static" = "yes"; then
  2851. sdl_image_libs=$($pkg_config SDL2_image --libs --static 2>/dev/null)
  2852. else
  2853. sdl_image_libs=$($pkg_config SDL2_image --libs 2>/dev/null)
  2854. fi
  2855. sdl_image_cflags=$($pkg_config SDL2_image --cflags 2>/dev/null)
  2856. sdl_image=yes
  2857. sdl_cflags="$sdl_cflags $sdl_image_cflags"
  2858. sdl_libs="$sdl_libs $sdl_image_libs"
  2859. else
  2860. if test "$sdl_image" = "yes" ; then
  2861. feature_not_found "sdl_image" "Install SDL Image devel"
  2862. else
  2863. sdl_image=no
  2864. fi
  2865. fi
  2866. fi
  2867. }
  2868. if test "$sdl" != "no" ; then
  2869. sdl_probe
  2870. fi
  2871. if test "$sdl" = "yes" ; then
  2872. sdl_image_probe
  2873. else
  2874. if test "$sdl_image" = "yes"; then
  2875. echo "warning: SDL Image requested, but SDL is not available, disabling"
  2876. fi
  2877. sdl_image=no
  2878. fi
  2879. if test "$sdl" = "yes" ; then
  2880. cat > $TMPC <<EOF
  2881. #include <SDL.h>
  2882. #if defined(SDL_VIDEO_DRIVER_X11)
  2883. #include <X11/XKBlib.h>
  2884. #else
  2885. #error No x11 support
  2886. #endif
  2887. int main(void) { return 0; }
  2888. EOF
  2889. if compile_prog "$sdl_cflags $x11_cflags" "$sdl_libs $x11_libs" ; then
  2890. need_x11=yes
  2891. sdl_cflags="$sdl_cflags $x11_cflags"
  2892. sdl_libs="$sdl_libs $x11_libs"
  2893. fi
  2894. fi
  2895. ##########################################
  2896. # RDMA needs OpenFabrics libraries
  2897. if test "$rdma" != "no" ; then
  2898. cat > $TMPC <<EOF
  2899. #include <rdma/rdma_cma.h>
  2900. int main(void) { return 0; }
  2901. EOF
  2902. rdma_libs="-lrdmacm -libverbs -libumad"
  2903. if compile_prog "" "$rdma_libs" ; then
  2904. rdma="yes"
  2905. libs_softmmu="$libs_softmmu $rdma_libs"
  2906. else
  2907. if test "$rdma" = "yes" ; then
  2908. error_exit \
  2909. " OpenFabrics librdmacm/libibverbs/libibumad not present." \
  2910. " Your options:" \
  2911. " (1) Fast: Install infiniband packages (devel) from your distro." \
  2912. " (2) Cleanest: Install libraries from www.openfabrics.org" \
  2913. " (3) Also: Install softiwarp if you don't have RDMA hardware"
  2914. fi
  2915. rdma="no"
  2916. fi
  2917. fi
  2918. ##########################################
  2919. # PVRDMA detection
  2920. cat > $TMPC <<EOF &&
  2921. #include <sys/mman.h>
  2922. int
  2923. main(void)
  2924. {
  2925. char buf = 0;
  2926. void *addr = &buf;
  2927. addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED);
  2928. return 0;
  2929. }
  2930. EOF
  2931. if test "$rdma" = "yes" ; then
  2932. case "$pvrdma" in
  2933. "")
  2934. if compile_prog "" ""; then
  2935. pvrdma="yes"
  2936. else
  2937. pvrdma="no"
  2938. fi
  2939. ;;
  2940. "yes")
  2941. if ! compile_prog "" ""; then
  2942. error_exit "PVRDMA is not supported since mremap is not implemented"
  2943. fi
  2944. pvrdma="yes"
  2945. ;;
  2946. "no")
  2947. pvrdma="no"
  2948. ;;
  2949. esac
  2950. else
  2951. if test "$pvrdma" = "yes" ; then
  2952. error_exit "PVRDMA requires rdma suppport"
  2953. fi
  2954. pvrdma="no"
  2955. fi
  2956. ##########################################
  2957. # VNC SASL detection
  2958. if test "$vnc" = "yes" && test "$vnc_sasl" != "no" ; then
  2959. cat > $TMPC <<EOF
  2960. #include <sasl/sasl.h>
  2961. #include <stdio.h>
  2962. int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
  2963. EOF
  2964. # Assuming Cyrus-SASL installed in /usr prefix
  2965. vnc_sasl_cflags=""
  2966. vnc_sasl_libs="-lsasl2"
  2967. if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
  2968. vnc_sasl=yes
  2969. libs_softmmu="$vnc_sasl_libs $libs_softmmu"
  2970. QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
  2971. else
  2972. if test "$vnc_sasl" = "yes" ; then
  2973. feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
  2974. fi
  2975. vnc_sasl=no
  2976. fi
  2977. fi
  2978. ##########################################
  2979. # VNC JPEG detection
  2980. if test "$vnc" = "yes" && test "$vnc_jpeg" != "no" ; then
  2981. cat > $TMPC <<EOF
  2982. #include <stdio.h>
  2983. #include <jpeglib.h>
  2984. int main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
  2985. EOF
  2986. vnc_jpeg_cflags=""
  2987. vnc_jpeg_libs="-ljpeg"
  2988. if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
  2989. vnc_jpeg=yes
  2990. libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
  2991. QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
  2992. else
  2993. if test "$vnc_jpeg" = "yes" ; then
  2994. feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
  2995. fi
  2996. vnc_jpeg=no
  2997. fi
  2998. fi
  2999. ##########################################
  3000. # VNC PNG detection
  3001. if test "$vnc" = "yes" && test "$vnc_png" != "no" ; then
  3002. cat > $TMPC <<EOF
  3003. //#include <stdio.h>
  3004. #include <png.h>
  3005. #include <stddef.h>
  3006. int main(void) {
  3007. png_structp png_ptr;
  3008. png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
  3009. return png_ptr != 0;
  3010. }
  3011. EOF
  3012. if $pkg_config libpng --exists; then
  3013. vnc_png_cflags=$($pkg_config libpng --cflags)
  3014. vnc_png_libs=$($pkg_config libpng --libs)
  3015. else
  3016. vnc_png_cflags=""
  3017. vnc_png_libs="-lpng"
  3018. fi
  3019. if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
  3020. vnc_png=yes
  3021. libs_softmmu="$vnc_png_libs $libs_softmmu"
  3022. QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
  3023. else
  3024. if test "$vnc_png" = "yes" ; then
  3025. feature_not_found "vnc-png" "Install libpng devel"
  3026. fi
  3027. vnc_png=no
  3028. fi
  3029. fi
  3030. ##########################################
  3031. # xkbcommon probe
  3032. if test "$xkbcommon" != "no" ; then
  3033. if $pkg_config xkbcommon --exists; then
  3034. xkbcommon_cflags=$($pkg_config xkbcommon --cflags)
  3035. xkbcommon_libs=$($pkg_config xkbcommon --libs)
  3036. xkbcommon=yes
  3037. else
  3038. if test "$xkbcommon" = "yes" ; then
  3039. feature_not_found "xkbcommon" "Install libxkbcommon-devel"
  3040. fi
  3041. xkbcommon=no
  3042. fi
  3043. fi
  3044. ##########################################
  3045. # xfsctl() probe, used for file-posix.c
  3046. if test "$xfs" != "no" ; then
  3047. cat > $TMPC << EOF
  3048. #include <stddef.h> /* NULL */
  3049. #include <xfs/xfs.h>
  3050. int main(void)
  3051. {
  3052. xfsctl(NULL, 0, 0, NULL);
  3053. return 0;
  3054. }
  3055. EOF
  3056. if compile_prog "" "" ; then
  3057. xfs="yes"
  3058. else
  3059. if test "$xfs" = "yes" ; then
  3060. feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
  3061. fi
  3062. xfs=no
  3063. fi
  3064. fi
  3065. ##########################################
  3066. # vde libraries probe
  3067. if test "$vde" != "no" ; then
  3068. vde_libs="-lvdeplug"
  3069. cat > $TMPC << EOF
  3070. #include <libvdeplug.h>
  3071. int main(void)
  3072. {
  3073. struct vde_open_args a = {0, 0, 0};
  3074. char s[] = "";
  3075. vde_open(s, s, &a);
  3076. return 0;
  3077. }
  3078. EOF
  3079. if compile_prog "" "$vde_libs" ; then
  3080. vde=yes
  3081. else
  3082. if test "$vde" = "yes" ; then
  3083. feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
  3084. fi
  3085. vde=no
  3086. fi
  3087. fi
  3088. ##########################################
  3089. # netmap support probe
  3090. # Apart from looking for netmap headers, we make sure that the host API version
  3091. # supports the netmap backend (>=11). The upper bound (15) is meant to simulate
  3092. # a minor/major version number. Minor new features will be marked with values up
  3093. # to 15, and if something happens that requires a change to the backend we will
  3094. # move above 15, submit the backend fixes and modify this two bounds.
  3095. if test "$netmap" != "no" ; then
  3096. cat > $TMPC << EOF
  3097. #include <inttypes.h>
  3098. #include <net/if.h>
  3099. #include <net/netmap.h>
  3100. #include <net/netmap_user.h>
  3101. #if (NETMAP_API < 11) || (NETMAP_API > 15)
  3102. #error
  3103. #endif
  3104. int main(void) { return 0; }
  3105. EOF
  3106. if compile_prog "" "" ; then
  3107. netmap=yes
  3108. else
  3109. if test "$netmap" = "yes" ; then
  3110. feature_not_found "netmap"
  3111. fi
  3112. netmap=no
  3113. fi
  3114. fi
  3115. ##########################################
  3116. # libcap-ng library probe
  3117. if test "$cap_ng" != "no" ; then
  3118. cap_libs="-lcap-ng"
  3119. cat > $TMPC << EOF
  3120. #include <cap-ng.h>
  3121. int main(void)
  3122. {
  3123. capng_capability_to_name(CAPNG_EFFECTIVE);
  3124. return 0;
  3125. }
  3126. EOF
  3127. if compile_prog "" "$cap_libs" ; then
  3128. cap_ng=yes
  3129. libs_tools="$cap_libs $libs_tools"
  3130. else
  3131. if test "$cap_ng" = "yes" ; then
  3132. feature_not_found "cap_ng" "Install libcap-ng devel"
  3133. fi
  3134. cap_ng=no
  3135. fi
  3136. fi
  3137. ##########################################
  3138. # Sound support libraries probe
  3139. audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
  3140. for drv in $audio_drv_list; do
  3141. case $drv in
  3142. alsa | try-alsa)
  3143. if $pkg_config alsa --exists; then
  3144. alsa_libs=$($pkg_config alsa --libs)
  3145. if test "$drv" = "try-alsa"; then
  3146. audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa/alsa/')
  3147. fi
  3148. else
  3149. if test "$drv" = "try-alsa"; then
  3150. audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa//')
  3151. else
  3152. error_exit "$drv check failed" \
  3153. "Make sure to have the $drv libs and headers installed."
  3154. fi
  3155. fi
  3156. ;;
  3157. pa | try-pa)
  3158. if $pkg_config libpulse --exists; then
  3159. pulse_libs=$($pkg_config libpulse --libs)
  3160. audio_pt_int="yes"
  3161. if test "$drv" = "try-pa"; then
  3162. audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa/pa/')
  3163. fi
  3164. else
  3165. if test "$drv" = "try-pa"; then
  3166. audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa//')
  3167. else
  3168. error_exit "$drv check failed" \
  3169. "Make sure to have the $drv libs and headers installed."
  3170. fi
  3171. fi
  3172. ;;
  3173. sdl)
  3174. if test "$sdl" = "no"; then
  3175. error_exit "sdl not found or disabled, can not use sdl audio driver"
  3176. fi
  3177. ;;
  3178. try-sdl)
  3179. if test "$sdl" = "no"; then
  3180. audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl//')
  3181. else
  3182. audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl/sdl/')
  3183. fi
  3184. ;;
  3185. coreaudio)
  3186. coreaudio_libs="-framework CoreAudio"
  3187. ;;
  3188. dsound)
  3189. dsound_libs="-lole32 -ldxguid"
  3190. audio_win_int="yes"
  3191. ;;
  3192. oss)
  3193. oss_libs="$oss_lib"
  3194. ;;
  3195. *)
  3196. echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
  3197. error_exit "Unknown driver '$drv' selected" \
  3198. "Possible drivers are: $audio_possible_drivers"
  3199. }
  3200. ;;
  3201. esac
  3202. done
  3203. ##########################################
  3204. # BrlAPI probe
  3205. if test "$brlapi" != "no" ; then
  3206. brlapi_libs="-lbrlapi"
  3207. cat > $TMPC << EOF
  3208. #include <brlapi.h>
  3209. #include <stddef.h>
  3210. int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
  3211. EOF
  3212. if compile_prog "" "$brlapi_libs" ; then
  3213. brlapi=yes
  3214. else
  3215. if test "$brlapi" = "yes" ; then
  3216. feature_not_found "brlapi" "Install brlapi devel"
  3217. fi
  3218. brlapi=no
  3219. fi
  3220. fi
  3221. ##########################################
  3222. # iconv probe
  3223. if test "$iconv" != "no" ; then
  3224. cat > $TMPC << EOF
  3225. #include <iconv.h>
  3226. int main(void) {
  3227. iconv_t conv = iconv_open("WCHAR_T", "UCS-2");
  3228. return conv != (iconv_t) -1;
  3229. }
  3230. EOF
  3231. iconv_prefix_list="/usr/local:/usr"
  3232. iconv_lib_list=":-liconv"
  3233. IFS=:
  3234. for iconv_prefix in $iconv_prefix_list; do
  3235. IFS=:
  3236. iconv_cflags="-I$iconv_prefix/include"
  3237. iconv_ldflags="-L$iconv_prefix/lib"
  3238. for iconv_link in $iconv_lib_list; do
  3239. unset IFS
  3240. iconv_lib="$iconv_ldflags $iconv_link"
  3241. echo "looking at iconv in '$iconv_cflags' '$iconv_lib'" >> config.log
  3242. if compile_prog "$iconv_cflags" "$iconv_lib" ; then
  3243. iconv_found=yes
  3244. break
  3245. fi
  3246. done
  3247. if test "$iconv_found" = yes ; then
  3248. break
  3249. fi
  3250. done
  3251. if test "$iconv_found" = "yes" ; then
  3252. iconv=yes
  3253. else
  3254. if test "$iconv" = "yes" ; then
  3255. feature_not_found "iconv" "Install iconv devel"
  3256. fi
  3257. iconv=no
  3258. fi
  3259. fi
  3260. ##########################################
  3261. # curses probe
  3262. if test "$iconv" = "no" ; then
  3263. # curses will need iconv
  3264. curses=no
  3265. fi
  3266. if test "$curses" != "no" ; then
  3267. if test "$mingw32" = "yes" ; then
  3268. curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
  3269. curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
  3270. else
  3271. curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"
  3272. curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
  3273. fi
  3274. curses_found=no
  3275. cat > $TMPC << EOF
  3276. #include <locale.h>
  3277. #include <curses.h>
  3278. #include <wchar.h>
  3279. #include <langinfo.h>
  3280. int main(void) {
  3281. const char *codeset;
  3282. wchar_t wch = L'w';
  3283. setlocale(LC_ALL, "");
  3284. resize_term(0, 0);
  3285. addwstr(L"wide chars\n");
  3286. addnwstr(&wch, 1);
  3287. add_wch(WACS_DEGREE);
  3288. codeset = nl_langinfo(CODESET);
  3289. return codeset != 0;
  3290. }
  3291. EOF
  3292. IFS=:
  3293. for curses_inc in $curses_inc_list; do
  3294. # Make sure we get the wide character prototypes
  3295. curses_inc="-DNCURSES_WIDECHAR $curses_inc"
  3296. IFS=:
  3297. for curses_lib in $curses_lib_list; do
  3298. unset IFS
  3299. if compile_prog "$curses_inc" "$curses_lib" ; then
  3300. curses_found=yes
  3301. break
  3302. fi
  3303. done
  3304. if test "$curses_found" = yes ; then
  3305. break
  3306. fi
  3307. done
  3308. unset IFS
  3309. if test "$curses_found" = "yes" ; then
  3310. curses=yes
  3311. else
  3312. if test "$curses" = "yes" ; then
  3313. feature_not_found "curses" "Install ncurses devel"
  3314. fi
  3315. curses=no
  3316. fi
  3317. fi
  3318. ##########################################
  3319. # curl probe
  3320. if test "$curl" != "no" ; then
  3321. if $pkg_config libcurl --exists; then
  3322. curlconfig="$pkg_config libcurl"
  3323. else
  3324. curlconfig=curl-config
  3325. fi
  3326. cat > $TMPC << EOF
  3327. #include <curl/curl.h>
  3328. int main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
  3329. EOF
  3330. curl_cflags=$($curlconfig --cflags 2>/dev/null)
  3331. curl_libs=$($curlconfig --libs 2>/dev/null)
  3332. if compile_prog "$curl_cflags" "$curl_libs" ; then
  3333. curl=yes
  3334. else
  3335. if test "$curl" = "yes" ; then
  3336. feature_not_found "curl" "Install libcurl devel"
  3337. fi
  3338. curl=no
  3339. fi
  3340. fi # test "$curl"
  3341. ##########################################
  3342. # bluez support probe
  3343. if test "$bluez" != "no" ; then
  3344. cat > $TMPC << EOF
  3345. #include <bluetooth/bluetooth.h>
  3346. int main(void) { return bt_error(0); }
  3347. EOF
  3348. bluez_cflags=$($pkg_config --cflags bluez 2>/dev/null)
  3349. bluez_libs=$($pkg_config --libs bluez 2>/dev/null)
  3350. if compile_prog "$bluez_cflags" "$bluez_libs" ; then
  3351. bluez=yes
  3352. libs_softmmu="$bluez_libs $libs_softmmu"
  3353. else
  3354. if test "$bluez" = "yes" ; then
  3355. feature_not_found "bluez" "Install bluez-libs/libbluetooth devel"
  3356. fi
  3357. bluez="no"
  3358. fi
  3359. fi
  3360. ##########################################
  3361. # glib support probe
  3362. glib_req_ver=2.40
  3363. glib_modules=gthread-2.0
  3364. if test "$modules" = yes; then
  3365. glib_modules="$glib_modules gmodule-export-2.0"
  3366. fi
  3367. # This workaround is required due to a bug in pkg-config file for glib as it
  3368. # doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
  3369. if test "$static" = yes && test "$mingw32" = yes; then
  3370. QEMU_CFLAGS="-DGLIB_STATIC_COMPILATION $QEMU_CFLAGS"
  3371. fi
  3372. for i in $glib_modules; do
  3373. if $pkg_config --atleast-version=$glib_req_ver $i; then
  3374. glib_cflags=$($pkg_config --cflags $i)
  3375. glib_libs=$($pkg_config --libs $i)
  3376. QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
  3377. LIBS="$glib_libs $LIBS"
  3378. libs_qga="$glib_libs $libs_qga"
  3379. else
  3380. error_exit "glib-$glib_req_ver $i is required to compile QEMU"
  3381. fi
  3382. done
  3383. if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
  3384. gio=yes
  3385. gio_cflags=$($pkg_config --cflags gio-2.0)
  3386. gio_libs=$($pkg_config --libs gio-2.0)
  3387. else
  3388. gio=no
  3389. fi
  3390. # Sanity check that the current size_t matches the
  3391. # size that glib thinks it should be. This catches
  3392. # problems on multi-arch where people try to build
  3393. # 32-bit QEMU while pointing at 64-bit glib headers
  3394. cat > $TMPC <<EOF
  3395. #include <glib.h>
  3396. #include <unistd.h>
  3397. #define QEMU_BUILD_BUG_ON(x) \
  3398. typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
  3399. int main(void) {
  3400. QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
  3401. return 0;
  3402. }
  3403. EOF
  3404. if ! compile_prog "$CFLAGS" "$LIBS" ; then
  3405. error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
  3406. "You probably need to set PKG_CONFIG_LIBDIR"\
  3407. "to point to the right pkg-config files for your"\
  3408. "build target"
  3409. fi
  3410. # Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
  3411. cat > $TMPC << EOF
  3412. #include <glib.h>
  3413. int main(void) { return 0; }
  3414. EOF
  3415. if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
  3416. if cc_has_warning_flag "-Wno-unknown-attributes"; then
  3417. glib_cflags="-Wno-unknown-attributes $glib_cflags"
  3418. CFLAGS="-Wno-unknown-attributes $CFLAGS"
  3419. fi
  3420. fi
  3421. #########################################
  3422. # zlib check
  3423. if test "$zlib" != "no" ; then
  3424. if $pkg_config --exists zlib; then
  3425. zlib_cflags=$($pkg_config --cflags zlib)
  3426. zlib_libs=$($pkg_config --libs zlib)
  3427. QEMU_CFLAGS="$zlib_cflags $QEMU_CFLAGS"
  3428. LIBS="$zlib_libs $LIBS"
  3429. else
  3430. cat > $TMPC << EOF
  3431. #include <zlib.h>
  3432. int main(void) { zlibVersion(); return 0; }
  3433. EOF
  3434. if compile_prog "" "-lz" ; then
  3435. LIBS="$LIBS -lz"
  3436. else
  3437. error_exit "zlib check failed" \
  3438. "Make sure to have the zlib libs and headers installed."
  3439. fi
  3440. fi
  3441. fi
  3442. ##########################################
  3443. # SHA command probe for modules
  3444. if test "$modules" = yes; then
  3445. shacmd_probe="sha1sum sha1 shasum"
  3446. for c in $shacmd_probe; do
  3447. if has $c; then
  3448. shacmd="$c"
  3449. break
  3450. fi
  3451. done
  3452. if test "$shacmd" = ""; then
  3453. error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
  3454. fi
  3455. fi
  3456. ##########################################
  3457. # pixman support probe
  3458. if test "$want_tools" = "no" && test "$softmmu" = "no"; then
  3459. pixman_cflags=
  3460. pixman_libs=
  3461. elif $pkg_config --atleast-version=0.21.8 pixman-1 > /dev/null 2>&1; then
  3462. pixman_cflags=$($pkg_config --cflags pixman-1)
  3463. pixman_libs=$($pkg_config --libs pixman-1)
  3464. else
  3465. error_exit "pixman >= 0.21.8 not present." \
  3466. "Please install the pixman devel package."
  3467. fi
  3468. ##########################################
  3469. # libmpathpersist probe
  3470. if test "$mpath" != "no" ; then
  3471. # probe for the new API
  3472. cat > $TMPC <<EOF
  3473. #include <libudev.h>
  3474. #include <mpath_persist.h>
  3475. unsigned mpath_mx_alloc_len = 1024;
  3476. int logsink;
  3477. static struct config *multipath_conf;
  3478. extern struct udev *udev;
  3479. extern struct config *get_multipath_config(void);
  3480. extern void put_multipath_config(struct config *conf);
  3481. struct udev *udev;
  3482. struct config *get_multipath_config(void) { return multipath_conf; }
  3483. void put_multipath_config(struct config *conf) { }
  3484. int main(void) {
  3485. udev = udev_new();
  3486. multipath_conf = mpath_lib_init();
  3487. return 0;
  3488. }
  3489. EOF
  3490. if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
  3491. mpathpersist=yes
  3492. mpathpersist_new_api=yes
  3493. else
  3494. # probe for the old API
  3495. cat > $TMPC <<EOF
  3496. #include <libudev.h>
  3497. #include <mpath_persist.h>
  3498. unsigned mpath_mx_alloc_len = 1024;
  3499. int logsink;
  3500. int main(void) {
  3501. struct udev *udev = udev_new();
  3502. mpath_lib_init(udev);
  3503. return 0;
  3504. }
  3505. EOF
  3506. if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
  3507. mpathpersist=yes
  3508. mpathpersist_new_api=no
  3509. else
  3510. mpathpersist=no
  3511. fi
  3512. fi
  3513. else
  3514. mpathpersist=no
  3515. fi
  3516. ##########################################
  3517. # libcap probe
  3518. if test "$cap" != "no" ; then
  3519. cat > $TMPC <<EOF
  3520. #include <stdio.h>
  3521. #include <sys/capability.h>
  3522. int main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
  3523. EOF
  3524. if compile_prog "" "-lcap" ; then
  3525. cap=yes
  3526. else
  3527. cap=no
  3528. fi
  3529. fi
  3530. ##########################################
  3531. # pthread probe
  3532. PTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
  3533. pthread=no
  3534. cat > $TMPC << EOF
  3535. #include <pthread.h>
  3536. static void *f(void *p) { return NULL; }
  3537. int main(void) {
  3538. pthread_t thread;
  3539. pthread_create(&thread, 0, f, 0);
  3540. return 0;
  3541. }
  3542. EOF
  3543. if compile_prog "" "" ; then
  3544. pthread=yes
  3545. else
  3546. for pthread_lib in $PTHREADLIBS_LIST; do
  3547. if compile_prog "" "$pthread_lib" ; then
  3548. pthread=yes
  3549. found=no
  3550. for lib_entry in $LIBS; do
  3551. if test "$lib_entry" = "$pthread_lib"; then
  3552. found=yes
  3553. break
  3554. fi
  3555. done
  3556. if test "$found" = "no"; then
  3557. LIBS="$pthread_lib $LIBS"
  3558. libs_qga="$pthread_lib $libs_qga"
  3559. fi
  3560. PTHREAD_LIB="$pthread_lib"
  3561. break
  3562. fi
  3563. done
  3564. fi
  3565. if test "$mingw32" != yes && test "$pthread" = no; then
  3566. error_exit "pthread check failed" \
  3567. "Make sure to have the pthread libs and headers installed."
  3568. fi
  3569. # check for pthread_setname_np with thread id
  3570. pthread_setname_np_w_tid=no
  3571. cat > $TMPC << EOF
  3572. #include <pthread.h>
  3573. static void *f(void *p) { return NULL; }
  3574. int main(void)
  3575. {
  3576. pthread_t thread;
  3577. pthread_create(&thread, 0, f, 0);
  3578. pthread_setname_np(thread, "QEMU");
  3579. return 0;
  3580. }
  3581. EOF
  3582. if compile_prog "" "$pthread_lib" ; then
  3583. pthread_setname_np_w_tid=yes
  3584. fi
  3585. # check for pthread_setname_np without thread id
  3586. pthread_setname_np_wo_tid=no
  3587. cat > $TMPC << EOF
  3588. #include <pthread.h>
  3589. static void *f(void *p) { pthread_setname_np("QEMU"); }
  3590. int main(void)
  3591. {
  3592. pthread_t thread;
  3593. pthread_create(&thread, 0, f, 0);
  3594. return 0;
  3595. }
  3596. EOF
  3597. if compile_prog "" "$pthread_lib" ; then
  3598. pthread_setname_np_wo_tid=yes
  3599. fi
  3600. ##########################################
  3601. # rbd probe
  3602. if test "$rbd" != "no" ; then
  3603. cat > $TMPC <<EOF
  3604. #include <stdio.h>
  3605. #include <rbd/librbd.h>
  3606. int main(void) {
  3607. rados_t cluster;
  3608. rados_create(&cluster, NULL);
  3609. return 0;
  3610. }
  3611. EOF
  3612. rbd_libs="-lrbd -lrados"
  3613. if compile_prog "" "$rbd_libs" ; then
  3614. rbd=yes
  3615. else
  3616. if test "$rbd" = "yes" ; then
  3617. feature_not_found "rados block device" "Install librbd/ceph devel"
  3618. fi
  3619. rbd=no
  3620. fi
  3621. fi
  3622. ##########################################
  3623. # libssh2 probe
  3624. min_libssh2_version=1.2.8
  3625. if test "$libssh2" != "no" ; then
  3626. if $pkg_config --atleast-version=$min_libssh2_version libssh2; then
  3627. libssh2_cflags=$($pkg_config libssh2 --cflags)
  3628. libssh2_libs=$($pkg_config libssh2 --libs)
  3629. libssh2=yes
  3630. else
  3631. if test "$libssh2" = "yes" ; then
  3632. error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2"
  3633. fi
  3634. libssh2=no
  3635. fi
  3636. fi
  3637. ##########################################
  3638. # libssh2_sftp_fsync probe
  3639. if test "$libssh2" = "yes"; then
  3640. cat > $TMPC <<EOF
  3641. #include <stdio.h>
  3642. #include <libssh2.h>
  3643. #include <libssh2_sftp.h>
  3644. int main(void) {
  3645. LIBSSH2_SESSION *session;
  3646. LIBSSH2_SFTP *sftp;
  3647. LIBSSH2_SFTP_HANDLE *sftp_handle;
  3648. session = libssh2_session_init ();
  3649. sftp = libssh2_sftp_init (session);
  3650. sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0);
  3651. libssh2_sftp_fsync (sftp_handle);
  3652. return 0;
  3653. }
  3654. EOF
  3655. # libssh2_cflags/libssh2_libs defined in previous test.
  3656. if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then
  3657. QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS"
  3658. fi
  3659. fi
  3660. ##########################################
  3661. # linux-aio probe
  3662. if test "$linux_aio" != "no" ; then
  3663. cat > $TMPC <<EOF
  3664. #include <libaio.h>
  3665. #include <sys/eventfd.h>
  3666. #include <stddef.h>
  3667. int main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
  3668. EOF
  3669. if compile_prog "" "-laio" ; then
  3670. linux_aio=yes
  3671. else
  3672. if test "$linux_aio" = "yes" ; then
  3673. feature_not_found "linux AIO" "Install libaio devel"
  3674. fi
  3675. linux_aio=no
  3676. fi
  3677. fi
  3678. ##########################################
  3679. # TPM emulation is only on POSIX
  3680. if test "$tpm" = ""; then
  3681. if test "$mingw32" = "yes"; then
  3682. tpm=no
  3683. else
  3684. tpm=yes
  3685. fi
  3686. elif test "$tpm" = "yes"; then
  3687. if test "$mingw32" = "yes" ; then
  3688. error_exit "TPM emulation only available on POSIX systems"
  3689. fi
  3690. fi
  3691. ##########################################
  3692. # attr probe
  3693. if test "$attr" != "no" ; then
  3694. cat > $TMPC <<EOF
  3695. #include <stdio.h>
  3696. #include <sys/types.h>
  3697. #ifdef CONFIG_LIBATTR
  3698. #include <attr/xattr.h>
  3699. #else
  3700. #include <sys/xattr.h>
  3701. #endif
  3702. int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
  3703. EOF
  3704. if compile_prog "" "" ; then
  3705. attr=yes
  3706. # Older distros have <attr/xattr.h>, and need -lattr:
  3707. elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
  3708. attr=yes
  3709. LIBS="-lattr $LIBS"
  3710. libattr=yes
  3711. else
  3712. if test "$attr" = "yes" ; then
  3713. feature_not_found "ATTR" "Install libc6 or libattr devel"
  3714. fi
  3715. attr=no
  3716. fi
  3717. fi
  3718. ##########################################
  3719. # iovec probe
  3720. cat > $TMPC <<EOF
  3721. #include <sys/types.h>
  3722. #include <sys/uio.h>
  3723. #include <unistd.h>
  3724. int main(void) { return sizeof(struct iovec); }
  3725. EOF
  3726. iovec=no
  3727. if compile_prog "" "" ; then
  3728. iovec=yes
  3729. fi
  3730. ##########################################
  3731. # preadv probe
  3732. cat > $TMPC <<EOF
  3733. #include <sys/types.h>
  3734. #include <sys/uio.h>
  3735. #include <unistd.h>
  3736. int main(void) { return preadv(0, 0, 0, 0); }
  3737. EOF
  3738. preadv=no
  3739. if compile_prog "" "" ; then
  3740. preadv=yes
  3741. fi
  3742. ##########################################
  3743. # fdt probe
  3744. # fdt support is mandatory for at least some target architectures,
  3745. # so insist on it if we're building those system emulators.
  3746. fdt_required=no
  3747. for target in $target_list; do
  3748. case $target in
  3749. aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu|riscv*-softmmu)
  3750. fdt_required=yes
  3751. ;;
  3752. esac
  3753. done
  3754. if test "$fdt_required" = "yes"; then
  3755. if test "$fdt" = "no"; then
  3756. error_exit "fdt disabled but some requested targets require it." \
  3757. "You can turn off fdt only if you also disable all the system emulation" \
  3758. "targets which need it (by specifying a cut down --target-list)."
  3759. fi
  3760. fdt=yes
  3761. fi
  3762. if test "$fdt" != "no" ; then
  3763. fdt_libs="-lfdt"
  3764. # explicitly check for libfdt_env.h as it is missing in some stable installs
  3765. # and test for required functions to make sure we are on a version >= 1.4.2
  3766. cat > $TMPC << EOF
  3767. #include <libfdt.h>
  3768. #include <libfdt_env.h>
  3769. int main(void) { fdt_check_full(NULL, 0); return 0; }
  3770. EOF
  3771. if compile_prog "" "$fdt_libs" ; then
  3772. # system DTC is good - use it
  3773. fdt=system
  3774. else
  3775. # have GIT checkout, so activate dtc submodule
  3776. if test -e "${source_path}/.git" ; then
  3777. git_submodules="${git_submodules} dtc"
  3778. fi
  3779. if test -d "${source_path}/dtc/libfdt" || test -e "${source_path}/.git" ; then
  3780. fdt=git
  3781. mkdir -p dtc
  3782. if [ "$pwd_is_source_path" != "y" ] ; then
  3783. symlink "$source_path/dtc/Makefile" "dtc/Makefile"
  3784. symlink "$source_path/dtc/scripts" "dtc/scripts"
  3785. fi
  3786. fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
  3787. fdt_ldflags="-L\$(BUILD_DIR)/dtc/libfdt"
  3788. fdt_libs="$fdt_libs"
  3789. elif test "$fdt" = "yes" ; then
  3790. # Not a git build & no libfdt found, prompt for system install
  3791. error_exit "DTC (libfdt) version >= 1.4.2 not present." \
  3792. "Please install the DTC (libfdt) devel package"
  3793. else
  3794. # don't have and don't want
  3795. fdt_libs=
  3796. fdt=no
  3797. fi
  3798. fi
  3799. fi
  3800. libs_softmmu="$libs_softmmu $fdt_libs"
  3801. ##########################################
  3802. # opengl probe (for sdl2, gtk, milkymist-tmu2)
  3803. if test "$opengl" != "no" ; then
  3804. opengl_pkgs="epoxy gbm"
  3805. if $pkg_config $opengl_pkgs; then
  3806. opengl_cflags="$($pkg_config --cflags $opengl_pkgs)"
  3807. opengl_libs="$($pkg_config --libs $opengl_pkgs)"
  3808. opengl=yes
  3809. if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
  3810. gtk_gl="yes"
  3811. fi
  3812. QEMU_CFLAGS="$QEMU_CFLAGS $opengl_cflags"
  3813. else
  3814. if test "$opengl" = "yes" ; then
  3815. feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
  3816. fi
  3817. opengl_cflags=""
  3818. opengl_libs=""
  3819. opengl=no
  3820. fi
  3821. fi
  3822. if test "$opengl" = "yes"; then
  3823. cat > $TMPC << EOF
  3824. #include <epoxy/egl.h>
  3825. #ifndef EGL_MESA_image_dma_buf_export
  3826. # error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
  3827. #endif
  3828. int main(void) { return 0; }
  3829. EOF
  3830. if compile_prog "" "" ; then
  3831. opengl_dmabuf=yes
  3832. fi
  3833. fi
  3834. if test "$opengl" = "yes" && test "$have_x11" = "yes"; then
  3835. for target in $target_list; do
  3836. case $target in
  3837. lm32-softmmu) # milkymist-tmu2 requires X11 and OpenGL
  3838. need_x11=yes
  3839. ;;
  3840. esac
  3841. done
  3842. fi
  3843. ##########################################
  3844. # libxml2 probe
  3845. if test "$libxml2" != "no" ; then
  3846. if $pkg_config --exists libxml-2.0; then
  3847. libxml2="yes"
  3848. libxml2_cflags=$($pkg_config --cflags libxml-2.0)
  3849. libxml2_libs=$($pkg_config --libs libxml-2.0)
  3850. else
  3851. if test "$libxml2" = "yes"; then
  3852. feature_not_found "libxml2" "Install libxml2 devel"
  3853. fi
  3854. libxml2="no"
  3855. fi
  3856. fi
  3857. ##########################################
  3858. # glusterfs probe
  3859. if test "$glusterfs" != "no" ; then
  3860. if $pkg_config --atleast-version=3 glusterfs-api; then
  3861. glusterfs="yes"
  3862. glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
  3863. glusterfs_libs=$($pkg_config --libs glusterfs-api)
  3864. if $pkg_config --atleast-version=4 glusterfs-api; then
  3865. glusterfs_xlator_opt="yes"
  3866. fi
  3867. if $pkg_config --atleast-version=5 glusterfs-api; then
  3868. glusterfs_discard="yes"
  3869. fi
  3870. if $pkg_config --atleast-version=6 glusterfs-api; then
  3871. glusterfs_fallocate="yes"
  3872. glusterfs_zerofill="yes"
  3873. fi
  3874. cat > $TMPC << EOF
  3875. #include <glusterfs/api/glfs.h>
  3876. int
  3877. main(void)
  3878. {
  3879. /* new glfs_ftruncate() passes two additional args */
  3880. return glfs_ftruncate(NULL, 0, NULL, NULL);
  3881. }
  3882. EOF
  3883. if compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then
  3884. glusterfs_ftruncate_has_stat="yes"
  3885. fi
  3886. cat > $TMPC << EOF
  3887. #include <glusterfs/api/glfs.h>
  3888. /* new glfs_io_cbk() passes two additional glfs_stat structs */
  3889. static void
  3890. glusterfs_iocb(glfs_fd_t *fd, ssize_t ret, struct glfs_stat *prestat, struct glfs_stat *poststat, void *data)
  3891. {}
  3892. int
  3893. main(void)
  3894. {
  3895. glfs_io_cbk iocb = &glusterfs_iocb;
  3896. iocb(NULL, 0 , NULL, NULL, NULL);
  3897. return 0;
  3898. }
  3899. EOF
  3900. if compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then
  3901. glusterfs_iocb_has_stat="yes"
  3902. fi
  3903. else
  3904. if test "$glusterfs" = "yes" ; then
  3905. feature_not_found "GlusterFS backend support" \
  3906. "Install glusterfs-api devel >= 3"
  3907. fi
  3908. glusterfs="no"
  3909. fi
  3910. fi
  3911. # Check for inotify functions when we are building linux-user
  3912. # emulator. This is done because older glibc versions don't
  3913. # have syscall stubs for these implemented. In that case we
  3914. # don't provide them even if kernel supports them.
  3915. #
  3916. inotify=no
  3917. cat > $TMPC << EOF
  3918. #include <sys/inotify.h>
  3919. int
  3920. main(void)
  3921. {
  3922. /* try to start inotify */
  3923. return inotify_init();
  3924. }
  3925. EOF
  3926. if compile_prog "" "" ; then
  3927. inotify=yes
  3928. fi
  3929. inotify1=no
  3930. cat > $TMPC << EOF
  3931. #include <sys/inotify.h>
  3932. int
  3933. main(void)
  3934. {
  3935. /* try to start inotify */
  3936. return inotify_init1(0);
  3937. }
  3938. EOF
  3939. if compile_prog "" "" ; then
  3940. inotify1=yes
  3941. fi
  3942. # check if pipe2 is there
  3943. pipe2=no
  3944. cat > $TMPC << EOF
  3945. #include <unistd.h>
  3946. #include <fcntl.h>
  3947. int main(void)
  3948. {
  3949. int pipefd[2];
  3950. return pipe2(pipefd, O_CLOEXEC);
  3951. }
  3952. EOF
  3953. if compile_prog "" "" ; then
  3954. pipe2=yes
  3955. fi
  3956. # check if accept4 is there
  3957. accept4=no
  3958. cat > $TMPC << EOF
  3959. #include <sys/socket.h>
  3960. #include <stddef.h>
  3961. int main(void)
  3962. {
  3963. accept4(0, NULL, NULL, SOCK_CLOEXEC);
  3964. return 0;
  3965. }
  3966. EOF
  3967. if compile_prog "" "" ; then
  3968. accept4=yes
  3969. fi
  3970. # check if tee/splice is there. vmsplice was added same time.
  3971. splice=no
  3972. cat > $TMPC << EOF
  3973. #include <unistd.h>
  3974. #include <fcntl.h>
  3975. #include <limits.h>
  3976. int main(void)
  3977. {
  3978. int len, fd = 0;
  3979. len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
  3980. splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
  3981. return 0;
  3982. }
  3983. EOF
  3984. if compile_prog "" "" ; then
  3985. splice=yes
  3986. fi
  3987. ##########################################
  3988. # libnuma probe
  3989. if test "$numa" != "no" ; then
  3990. cat > $TMPC << EOF
  3991. #include <numa.h>
  3992. int main(void) { return numa_available(); }
  3993. EOF
  3994. if compile_prog "" "-lnuma" ; then
  3995. numa=yes
  3996. libs_softmmu="-lnuma $libs_softmmu"
  3997. else
  3998. if test "$numa" = "yes" ; then
  3999. feature_not_found "numa" "install numactl devel"
  4000. fi
  4001. numa=no
  4002. fi
  4003. fi
  4004. if test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
  4005. echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
  4006. exit 1
  4007. fi
  4008. # Even if malloc_trim() is available, these non-libc memory allocators
  4009. # do not support it.
  4010. if test "$tcmalloc" = "yes" || test "$jemalloc" = "yes" ; then
  4011. if test "$malloc_trim" = "yes" ; then
  4012. echo "Disabling malloc_trim with non-libc memory allocator"
  4013. fi
  4014. malloc_trim="no"
  4015. fi
  4016. #######################################
  4017. # malloc_trim
  4018. if test "$malloc_trim" != "no" ; then
  4019. cat > $TMPC << EOF
  4020. #include <malloc.h>
  4021. int main(void) { malloc_trim(0); return 0; }
  4022. EOF
  4023. if compile_prog "" "" ; then
  4024. malloc_trim="yes"
  4025. else
  4026. malloc_trim="no"
  4027. fi
  4028. fi
  4029. ##########################################
  4030. # tcmalloc probe
  4031. if test "$tcmalloc" = "yes" ; then
  4032. cat > $TMPC << EOF
  4033. #include <stdlib.h>
  4034. int main(void) { malloc(1); return 0; }
  4035. EOF
  4036. if compile_prog "" "-ltcmalloc" ; then
  4037. LIBS="-ltcmalloc $LIBS"
  4038. else
  4039. feature_not_found "tcmalloc" "install gperftools devel"
  4040. fi
  4041. fi
  4042. ##########################################
  4043. # jemalloc probe
  4044. if test "$jemalloc" = "yes" ; then
  4045. cat > $TMPC << EOF
  4046. #include <stdlib.h>
  4047. int main(void) { malloc(1); return 0; }
  4048. EOF
  4049. if compile_prog "" "-ljemalloc" ; then
  4050. LIBS="-ljemalloc $LIBS"
  4051. else
  4052. feature_not_found "jemalloc" "install jemalloc devel"
  4053. fi
  4054. fi
  4055. ##########################################
  4056. # signalfd probe
  4057. signalfd="no"
  4058. cat > $TMPC << EOF
  4059. #include <unistd.h>
  4060. #include <sys/syscall.h>
  4061. #include <signal.h>
  4062. int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
  4063. EOF
  4064. if compile_prog "" "" ; then
  4065. signalfd=yes
  4066. fi
  4067. # check if optreset global is declared by <getopt.h>
  4068. optreset="no"
  4069. cat > $TMPC << EOF
  4070. #include <getopt.h>
  4071. int main(void) { return optreset; }
  4072. EOF
  4073. if compile_prog "" "" ; then
  4074. optreset=yes
  4075. fi
  4076. # check if eventfd is supported
  4077. eventfd=no
  4078. cat > $TMPC << EOF
  4079. #include <sys/eventfd.h>
  4080. int main(void)
  4081. {
  4082. return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
  4083. }
  4084. EOF
  4085. if compile_prog "" "" ; then
  4086. eventfd=yes
  4087. fi
  4088. # check if memfd is supported
  4089. memfd=no
  4090. cat > $TMPC << EOF
  4091. #include <sys/mman.h>
  4092. int main(void)
  4093. {
  4094. return memfd_create("foo", MFD_ALLOW_SEALING);
  4095. }
  4096. EOF
  4097. if compile_prog "" "" ; then
  4098. memfd=yes
  4099. fi
  4100. # check for usbfs
  4101. have_usbfs=no
  4102. if test "$linux_user" = "yes"; then
  4103. cat > $TMPC << EOF
  4104. #include <linux/usbdevice_fs.h>
  4105. #ifndef USBDEVFS_GET_CAPABILITIES
  4106. #error "USBDEVFS_GET_CAPABILITIES undefined"
  4107. #endif
  4108. #ifndef USBDEVFS_DISCONNECT_CLAIM
  4109. #error "USBDEVFS_DISCONNECT_CLAIM undefined"
  4110. #endif
  4111. int main(void)
  4112. {
  4113. return 0;
  4114. }
  4115. EOF
  4116. if compile_prog "" ""; then
  4117. have_usbfs=yes
  4118. fi
  4119. fi
  4120. # check for fallocate
  4121. fallocate=no
  4122. cat > $TMPC << EOF
  4123. #include <fcntl.h>
  4124. int main(void)
  4125. {
  4126. fallocate(0, 0, 0, 0);
  4127. return 0;
  4128. }
  4129. EOF
  4130. if compile_prog "" "" ; then
  4131. fallocate=yes
  4132. fi
  4133. # check for fallocate hole punching
  4134. fallocate_punch_hole=no
  4135. cat > $TMPC << EOF
  4136. #include <fcntl.h>
  4137. #include <linux/falloc.h>
  4138. int main(void)
  4139. {
  4140. fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
  4141. return 0;
  4142. }
  4143. EOF
  4144. if compile_prog "" "" ; then
  4145. fallocate_punch_hole=yes
  4146. fi
  4147. # check that fallocate supports range zeroing inside the file
  4148. fallocate_zero_range=no
  4149. cat > $TMPC << EOF
  4150. #include <fcntl.h>
  4151. #include <linux/falloc.h>
  4152. int main(void)
  4153. {
  4154. fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
  4155. return 0;
  4156. }
  4157. EOF
  4158. if compile_prog "" "" ; then
  4159. fallocate_zero_range=yes
  4160. fi
  4161. # check for posix_fallocate
  4162. posix_fallocate=no
  4163. cat > $TMPC << EOF
  4164. #include <fcntl.h>
  4165. int main(void)
  4166. {
  4167. posix_fallocate(0, 0, 0);
  4168. return 0;
  4169. }
  4170. EOF
  4171. if compile_prog "" "" ; then
  4172. posix_fallocate=yes
  4173. fi
  4174. # check for sync_file_range
  4175. sync_file_range=no
  4176. cat > $TMPC << EOF
  4177. #include <fcntl.h>
  4178. int main(void)
  4179. {
  4180. sync_file_range(0, 0, 0, 0);
  4181. return 0;
  4182. }
  4183. EOF
  4184. if compile_prog "" "" ; then
  4185. sync_file_range=yes
  4186. fi
  4187. # check for linux/fiemap.h and FS_IOC_FIEMAP
  4188. fiemap=no
  4189. cat > $TMPC << EOF
  4190. #include <sys/ioctl.h>
  4191. #include <linux/fs.h>
  4192. #include <linux/fiemap.h>
  4193. int main(void)
  4194. {
  4195. ioctl(0, FS_IOC_FIEMAP, 0);
  4196. return 0;
  4197. }
  4198. EOF
  4199. if compile_prog "" "" ; then
  4200. fiemap=yes
  4201. fi
  4202. # check for dup3
  4203. dup3=no
  4204. cat > $TMPC << EOF
  4205. #include <unistd.h>
  4206. int main(void)
  4207. {
  4208. dup3(0, 0, 0);
  4209. return 0;
  4210. }
  4211. EOF
  4212. if compile_prog "" "" ; then
  4213. dup3=yes
  4214. fi
  4215. # check for ppoll support
  4216. ppoll=no
  4217. cat > $TMPC << EOF
  4218. #include <poll.h>
  4219. int main(void)
  4220. {
  4221. struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
  4222. ppoll(&pfd, 1, 0, 0);
  4223. return 0;
  4224. }
  4225. EOF
  4226. if compile_prog "" "" ; then
  4227. ppoll=yes
  4228. fi
  4229. # check for prctl(PR_SET_TIMERSLACK , ... ) support
  4230. prctl_pr_set_timerslack=no
  4231. cat > $TMPC << EOF
  4232. #include <sys/prctl.h>
  4233. int main(void)
  4234. {
  4235. prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
  4236. return 0;
  4237. }
  4238. EOF
  4239. if compile_prog "" "" ; then
  4240. prctl_pr_set_timerslack=yes
  4241. fi
  4242. # check for epoll support
  4243. epoll=no
  4244. cat > $TMPC << EOF
  4245. #include <sys/epoll.h>
  4246. int main(void)
  4247. {
  4248. epoll_create(0);
  4249. return 0;
  4250. }
  4251. EOF
  4252. if compile_prog "" "" ; then
  4253. epoll=yes
  4254. fi
  4255. # epoll_create1 is a later addition
  4256. # so we must check separately for its presence
  4257. epoll_create1=no
  4258. cat > $TMPC << EOF
  4259. #include <sys/epoll.h>
  4260. int main(void)
  4261. {
  4262. /* Note that we use epoll_create1 as a value, not as
  4263. * a function being called. This is necessary so that on
  4264. * old SPARC glibc versions where the function was present in
  4265. * the library but not declared in the header file we will
  4266. * fail the configure check. (Otherwise we will get a compiler
  4267. * warning but not an error, and will proceed to fail the
  4268. * qemu compile where we compile with -Werror.)
  4269. */
  4270. return (int)(uintptr_t)&epoll_create1;
  4271. }
  4272. EOF
  4273. if compile_prog "" "" ; then
  4274. epoll_create1=yes
  4275. fi
  4276. # check for sendfile support
  4277. sendfile=no
  4278. cat > $TMPC << EOF
  4279. #include <sys/sendfile.h>
  4280. int main(void)
  4281. {
  4282. return sendfile(0, 0, 0, 0);
  4283. }
  4284. EOF
  4285. if compile_prog "" "" ; then
  4286. sendfile=yes
  4287. fi
  4288. # check for timerfd support (glibc 2.8 and newer)
  4289. timerfd=no
  4290. cat > $TMPC << EOF
  4291. #include <sys/timerfd.h>
  4292. int main(void)
  4293. {
  4294. return(timerfd_create(CLOCK_REALTIME, 0));
  4295. }
  4296. EOF
  4297. if compile_prog "" "" ; then
  4298. timerfd=yes
  4299. fi
  4300. # check for setns and unshare support
  4301. setns=no
  4302. cat > $TMPC << EOF
  4303. #include <sched.h>
  4304. int main(void)
  4305. {
  4306. int ret;
  4307. ret = setns(0, 0);
  4308. ret = unshare(0);
  4309. return ret;
  4310. }
  4311. EOF
  4312. if compile_prog "" "" ; then
  4313. setns=yes
  4314. fi
  4315. # clock_adjtime probe
  4316. clock_adjtime=no
  4317. cat > $TMPC <<EOF
  4318. #include <time.h>
  4319. int main(void)
  4320. {
  4321. return clock_adjtime(0, 0);
  4322. }
  4323. EOF
  4324. clock_adjtime=no
  4325. if compile_prog "" "" ; then
  4326. clock_adjtime=yes
  4327. fi
  4328. # syncfs probe
  4329. syncfs=no
  4330. cat > $TMPC <<EOF
  4331. #include <unistd.h>
  4332. int main(void)
  4333. {
  4334. return syncfs(0);
  4335. }
  4336. EOF
  4337. syncfs=no
  4338. if compile_prog "" "" ; then
  4339. syncfs=yes
  4340. fi
  4341. # Check we have a new enough version of sphinx-build
  4342. has_sphinx_build() {
  4343. # This is a bit awkward but works: create a trivial document and
  4344. # try to run it with our configuration file (which enforces a
  4345. # version requirement). This will fail if either
  4346. # sphinx-build doesn't exist at all or if it is too old.
  4347. mkdir -p "$TMPDIR1/sphinx"
  4348. touch "$TMPDIR1/sphinx/index.rst"
  4349. sphinx-build -c "$source_path/docs" -b html "$TMPDIR1/sphinx" "$TMPDIR1/sphinx/out" >/dev/null 2>&1
  4350. }
  4351. # Check if tools are available to build documentation.
  4352. if test "$docs" != "no" ; then
  4353. if has makeinfo && has pod2man && has_sphinx_build; then
  4354. docs=yes
  4355. else
  4356. if test "$docs" = "yes" ; then
  4357. feature_not_found "docs" "Install texinfo, Perl/perl-podlators and python-sphinx"
  4358. fi
  4359. docs=no
  4360. fi
  4361. fi
  4362. # Search for bswap_32 function
  4363. byteswap_h=no
  4364. cat > $TMPC << EOF
  4365. #include <byteswap.h>
  4366. int main(void) { return bswap_32(0); }
  4367. EOF
  4368. if compile_prog "" "" ; then
  4369. byteswap_h=yes
  4370. fi
  4371. # Search for bswap32 function
  4372. bswap_h=no
  4373. cat > $TMPC << EOF
  4374. #include <sys/endian.h>
  4375. #include <sys/types.h>
  4376. #include <machine/bswap.h>
  4377. int main(void) { return bswap32(0); }
  4378. EOF
  4379. if compile_prog "" "" ; then
  4380. bswap_h=yes
  4381. fi
  4382. ##########################################
  4383. # Do we have libiscsi >= 1.9.0
  4384. if test "$libiscsi" != "no" ; then
  4385. if $pkg_config --atleast-version=1.9.0 libiscsi; then
  4386. libiscsi="yes"
  4387. libiscsi_cflags=$($pkg_config --cflags libiscsi)
  4388. libiscsi_libs=$($pkg_config --libs libiscsi)
  4389. else
  4390. if test "$libiscsi" = "yes" ; then
  4391. feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
  4392. fi
  4393. libiscsi="no"
  4394. fi
  4395. fi
  4396. ##########################################
  4397. # Do we need libm
  4398. cat > $TMPC << EOF
  4399. #include <math.h>
  4400. int main(int argc, char **argv) { return isnan(sin((double)argc)); }
  4401. EOF
  4402. if compile_prog "" "" ; then
  4403. :
  4404. elif compile_prog "" "-lm" ; then
  4405. LIBS="-lm $LIBS"
  4406. libs_qga="-lm $libs_qga"
  4407. else
  4408. error_exit "libm check failed"
  4409. fi
  4410. ##########################################
  4411. # Do we need librt
  4412. # uClibc provides 2 versions of clock_gettime(), one with realtime
  4413. # support and one without. This means that the clock_gettime() don't
  4414. # need -lrt. We still need it for timer_create() so we check for this
  4415. # function in addition.
  4416. cat > $TMPC <<EOF
  4417. #include <signal.h>
  4418. #include <time.h>
  4419. int main(void) {
  4420. timer_create(CLOCK_REALTIME, NULL, NULL);
  4421. return clock_gettime(CLOCK_REALTIME, NULL);
  4422. }
  4423. EOF
  4424. if compile_prog "" "" ; then
  4425. :
  4426. # we need pthread for static linking. use previous pthread test result
  4427. elif compile_prog "" "$pthread_lib -lrt" ; then
  4428. LIBS="$LIBS -lrt"
  4429. libs_qga="$libs_qga -lrt"
  4430. fi
  4431. # Check whether we need to link libutil for openpty()
  4432. cat > $TMPC << EOF
  4433. extern int openpty(int *am, int *as, char *name, void *termp, void *winp);
  4434. int main(void) { return openpty(0, 0, 0, 0, 0); }
  4435. EOF
  4436. if ! compile_prog "" "" ; then
  4437. if compile_prog "" "-lutil" ; then
  4438. libs_softmmu="-lutil $libs_softmmu"
  4439. libs_tools="-lutil $libs_tools"
  4440. fi
  4441. fi
  4442. ##########################################
  4443. # spice probe
  4444. if test "$spice" != "no" ; then
  4445. cat > $TMPC << EOF
  4446. #include <spice.h>
  4447. int main(void) { spice_server_new(); return 0; }
  4448. EOF
  4449. spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
  4450. spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
  4451. if $pkg_config --atleast-version=0.12.5 spice-server && \
  4452. $pkg_config --atleast-version=0.12.3 spice-protocol && \
  4453. compile_prog "$spice_cflags" "$spice_libs" ; then
  4454. spice="yes"
  4455. libs_softmmu="$libs_softmmu $spice_libs"
  4456. QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
  4457. spice_protocol_version=$($pkg_config --modversion spice-protocol)
  4458. spice_server_version=$($pkg_config --modversion spice-server)
  4459. else
  4460. if test "$spice" = "yes" ; then
  4461. feature_not_found "spice" \
  4462. "Install spice-server(>=0.12.5) and spice-protocol(>=0.12.3) devel"
  4463. fi
  4464. spice="no"
  4465. fi
  4466. fi
  4467. # check for smartcard support
  4468. if test "$smartcard" != "no"; then
  4469. if $pkg_config --atleast-version=2.5.1 libcacard; then
  4470. libcacard_cflags=$($pkg_config --cflags libcacard)
  4471. libcacard_libs=$($pkg_config --libs libcacard)
  4472. smartcard="yes"
  4473. else
  4474. if test "$smartcard" = "yes"; then
  4475. feature_not_found "smartcard" "Install libcacard devel"
  4476. fi
  4477. smartcard="no"
  4478. fi
  4479. fi
  4480. # check for libusb
  4481. if test "$libusb" != "no" ; then
  4482. if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
  4483. libusb="yes"
  4484. libusb_cflags=$($pkg_config --cflags libusb-1.0)
  4485. libusb_libs=$($pkg_config --libs libusb-1.0)
  4486. else
  4487. if test "$libusb" = "yes"; then
  4488. feature_not_found "libusb" "Install libusb devel >= 1.0.13"
  4489. fi
  4490. libusb="no"
  4491. fi
  4492. fi
  4493. # check for usbredirparser for usb network redirection support
  4494. if test "$usb_redir" != "no" ; then
  4495. if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
  4496. usb_redir="yes"
  4497. usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
  4498. usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
  4499. else
  4500. if test "$usb_redir" = "yes"; then
  4501. feature_not_found "usb-redir" "Install usbredir devel"
  4502. fi
  4503. usb_redir="no"
  4504. fi
  4505. fi
  4506. ##########################################
  4507. # check if we have VSS SDK headers for win
  4508. if test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
  4509. test "$vss_win32_sdk" != "no" ; then
  4510. case "$vss_win32_sdk" in
  4511. "") vss_win32_include="-isystem $source_path" ;;
  4512. *\ *) # The SDK is installed in "Program Files" by default, but we cannot
  4513. # handle path with spaces. So we symlink the headers into ".sdk/vss".
  4514. vss_win32_include="-isystem $source_path/.sdk/vss"
  4515. symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
  4516. ;;
  4517. *) vss_win32_include="-isystem $vss_win32_sdk"
  4518. esac
  4519. cat > $TMPC << EOF
  4520. #define __MIDL_user_allocate_free_DEFINED__
  4521. #include <inc/win2003/vss.h>
  4522. int main(void) { return VSS_CTX_BACKUP; }
  4523. EOF
  4524. if compile_prog "$vss_win32_include" "" ; then
  4525. guest_agent_with_vss="yes"
  4526. QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
  4527. libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
  4528. qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
  4529. else
  4530. if test "$vss_win32_sdk" != "" ; then
  4531. echo "ERROR: Please download and install Microsoft VSS SDK:"
  4532. echo "ERROR: http://www.microsoft.com/en-us/download/details.aspx?id=23490"
  4533. echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
  4534. echo "ERROR: scripts/extract-vsssdk-headers setup.exe"
  4535. echo "ERROR: The headers are extracted in the directory \`inc'."
  4536. feature_not_found "VSS support"
  4537. fi
  4538. guest_agent_with_vss="no"
  4539. fi
  4540. fi
  4541. ##########################################
  4542. # lookup Windows platform SDK (if not specified)
  4543. # The SDK is needed only to build .tlb (type library) file of guest agent
  4544. # VSS provider from the source. It is usually unnecessary because the
  4545. # pre-compiled .tlb file is included.
  4546. if test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
  4547. test "$guest_agent_with_vss" = "yes" ; then
  4548. if test -z "$win_sdk"; then
  4549. programfiles="$PROGRAMFILES"
  4550. test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
  4551. if test -n "$programfiles"; then
  4552. win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
  4553. else
  4554. feature_not_found "Windows SDK"
  4555. fi
  4556. elif test "$win_sdk" = "no"; then
  4557. win_sdk=""
  4558. fi
  4559. fi
  4560. ##########################################
  4561. # check if mingw environment provides a recent ntddscsi.h
  4562. if test "$mingw32" = "yes" && test "$guest_agent" != "no"; then
  4563. cat > $TMPC << EOF
  4564. #include <windows.h>
  4565. #include <ntddscsi.h>
  4566. int main(void) {
  4567. #if !defined(IOCTL_SCSI_GET_ADDRESS)
  4568. #error Missing required ioctl definitions
  4569. #endif
  4570. SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
  4571. return addr.Lun;
  4572. }
  4573. EOF
  4574. if compile_prog "" "" ; then
  4575. guest_agent_ntddscsi=yes
  4576. libs_qga="-lsetupapi -lcfgmgr32 $libs_qga"
  4577. fi
  4578. fi
  4579. ##########################################
  4580. # virgl renderer probe
  4581. if test "$virglrenderer" != "no" ; then
  4582. cat > $TMPC << EOF
  4583. #include <virglrenderer.h>
  4584. int main(void) { virgl_renderer_poll(); return 0; }
  4585. EOF
  4586. virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
  4587. virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
  4588. virgl_version=$($pkg_config --modversion virglrenderer 2>/dev/null)
  4589. if $pkg_config virglrenderer >/dev/null 2>&1 && \
  4590. compile_prog "$virgl_cflags" "$virgl_libs" ; then
  4591. virglrenderer="yes"
  4592. else
  4593. if test "$virglrenderer" = "yes" ; then
  4594. feature_not_found "virglrenderer"
  4595. fi
  4596. virglrenderer="no"
  4597. fi
  4598. fi
  4599. ##########################################
  4600. # capstone
  4601. case "$capstone" in
  4602. "" | yes)
  4603. if $pkg_config capstone; then
  4604. capstone=system
  4605. elif test -e "${source_path}/.git" && test $git_update = 'yes' ; then
  4606. capstone=git
  4607. elif test -e "${source_path}/capstone/Makefile" ; then
  4608. capstone=internal
  4609. elif test -z "$capstone" ; then
  4610. capstone=no
  4611. else
  4612. feature_not_found "capstone" "Install capstone devel or git submodule"
  4613. fi
  4614. ;;
  4615. system)
  4616. if ! $pkg_config capstone; then
  4617. feature_not_found "capstone" "Install capstone devel"
  4618. fi
  4619. ;;
  4620. esac
  4621. case "$capstone" in
  4622. git | internal)
  4623. if test "$capstone" = git; then
  4624. git_submodules="${git_submodules} capstone"
  4625. fi
  4626. mkdir -p capstone
  4627. QEMU_CFLAGS="$QEMU_CFLAGS -I\$(SRC_PATH)/capstone/include"
  4628. if test "$mingw32" = "yes"; then
  4629. LIBCAPSTONE=capstone.lib
  4630. else
  4631. LIBCAPSTONE=libcapstone.a
  4632. fi
  4633. LIBS="-L\$(BUILD_DIR)/capstone -lcapstone $LIBS"
  4634. ;;
  4635. system)
  4636. QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags capstone)"
  4637. LIBS="$($pkg_config --libs capstone) $LIBS"
  4638. ;;
  4639. no)
  4640. ;;
  4641. *)
  4642. error_exit "Unknown state for capstone: $capstone"
  4643. ;;
  4644. esac
  4645. ##########################################
  4646. # check if we have fdatasync
  4647. fdatasync=no
  4648. cat > $TMPC << EOF
  4649. #include <unistd.h>
  4650. int main(void) {
  4651. #if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
  4652. return fdatasync(0);
  4653. #else
  4654. #error Not supported
  4655. #endif
  4656. }
  4657. EOF
  4658. if compile_prog "" "" ; then
  4659. fdatasync=yes
  4660. fi
  4661. ##########################################
  4662. # check if we have madvise
  4663. madvise=no
  4664. cat > $TMPC << EOF
  4665. #include <sys/types.h>
  4666. #include <sys/mman.h>
  4667. #include <stddef.h>
  4668. int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
  4669. EOF
  4670. if compile_prog "" "" ; then
  4671. madvise=yes
  4672. fi
  4673. ##########################################
  4674. # check if we have posix_madvise
  4675. posix_madvise=no
  4676. cat > $TMPC << EOF
  4677. #include <sys/mman.h>
  4678. #include <stddef.h>
  4679. int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
  4680. EOF
  4681. if compile_prog "" "" ; then
  4682. posix_madvise=yes
  4683. fi
  4684. ##########################################
  4685. # check if we have posix_memalign()
  4686. posix_memalign=no
  4687. cat > $TMPC << EOF
  4688. #include <stdlib.h>
  4689. int main(void) {
  4690. void *p;
  4691. return posix_memalign(&p, 8, 8);
  4692. }
  4693. EOF
  4694. if compile_prog "" "" ; then
  4695. posix_memalign=yes
  4696. fi
  4697. ##########################################
  4698. # check if we have posix_syslog
  4699. posix_syslog=no
  4700. cat > $TMPC << EOF
  4701. #include <syslog.h>
  4702. int main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
  4703. EOF
  4704. if compile_prog "" "" ; then
  4705. posix_syslog=yes
  4706. fi
  4707. ##########################################
  4708. # check if we have sem_timedwait
  4709. sem_timedwait=no
  4710. cat > $TMPC << EOF
  4711. #include <semaphore.h>
  4712. int main(void) { return sem_timedwait(0, 0); }
  4713. EOF
  4714. if compile_prog "" "" ; then
  4715. sem_timedwait=yes
  4716. fi
  4717. ##########################################
  4718. # check if we have strchrnul
  4719. strchrnul=no
  4720. cat > $TMPC << EOF
  4721. #include <string.h>
  4722. int main(void);
  4723. // Use a haystack that the compiler shouldn't be able to constant fold
  4724. char *haystack = (char*)&main;
  4725. int main(void) { return strchrnul(haystack, 'x') != &haystack[6]; }
  4726. EOF
  4727. if compile_prog "" "" ; then
  4728. strchrnul=yes
  4729. fi
  4730. ##########################################
  4731. # check if trace backend exists
  4732. $python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends > /dev/null 2> /dev/null
  4733. if test "$?" -ne 0 ; then
  4734. error_exit "invalid trace backends" \
  4735. "Please choose supported trace backends."
  4736. fi
  4737. ##########################################
  4738. # For 'ust' backend, test if ust headers are present
  4739. if have_backend "ust"; then
  4740. cat > $TMPC << EOF
  4741. #include <lttng/tracepoint.h>
  4742. int main(void) { return 0; }
  4743. EOF
  4744. if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
  4745. if $pkg_config lttng-ust --exists; then
  4746. lttng_ust_libs=$($pkg_config --libs lttng-ust)
  4747. else
  4748. lttng_ust_libs="-llttng-ust -ldl"
  4749. fi
  4750. if $pkg_config liburcu-bp --exists; then
  4751. urcu_bp_libs=$($pkg_config --libs liburcu-bp)
  4752. else
  4753. urcu_bp_libs="-lurcu-bp"
  4754. fi
  4755. LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
  4756. libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
  4757. else
  4758. error_exit "Trace backend 'ust' missing lttng-ust header files"
  4759. fi
  4760. fi
  4761. ##########################################
  4762. # For 'dtrace' backend, test if 'dtrace' command is present
  4763. if have_backend "dtrace"; then
  4764. if ! has 'dtrace' ; then
  4765. error_exit "dtrace command is not found in PATH $PATH"
  4766. fi
  4767. trace_backend_stap="no"
  4768. if has 'stap' ; then
  4769. trace_backend_stap="yes"
  4770. fi
  4771. fi
  4772. ##########################################
  4773. # check and set a backend for coroutine
  4774. # We prefer ucontext, but it's not always possible. The fallback
  4775. # is sigcontext. On Windows the only valid backend is the Windows
  4776. # specific one.
  4777. ucontext_works=no
  4778. if test "$darwin" != "yes"; then
  4779. cat > $TMPC << EOF
  4780. #include <ucontext.h>
  4781. #ifdef __stub_makecontext
  4782. #error Ignoring glibc stub makecontext which will always fail
  4783. #endif
  4784. int main(void) { makecontext(0, 0, 0); return 0; }
  4785. EOF
  4786. if compile_prog "" "" ; then
  4787. ucontext_works=yes
  4788. fi
  4789. fi
  4790. if test "$coroutine" = ""; then
  4791. if test "$mingw32" = "yes"; then
  4792. coroutine=win32
  4793. elif test "$ucontext_works" = "yes"; then
  4794. coroutine=ucontext
  4795. else
  4796. coroutine=sigaltstack
  4797. fi
  4798. else
  4799. case $coroutine in
  4800. windows)
  4801. if test "$mingw32" != "yes"; then
  4802. error_exit "'windows' coroutine backend only valid for Windows"
  4803. fi
  4804. # Unfortunately the user visible backend name doesn't match the
  4805. # coroutine-*.c filename for this case, so we have to adjust it here.
  4806. coroutine=win32
  4807. ;;
  4808. ucontext)
  4809. if test "$ucontext_works" != "yes"; then
  4810. feature_not_found "ucontext"
  4811. fi
  4812. ;;
  4813. sigaltstack)
  4814. if test "$mingw32" = "yes"; then
  4815. error_exit "only the 'windows' coroutine backend is valid for Windows"
  4816. fi
  4817. ;;
  4818. *)
  4819. error_exit "unknown coroutine backend $coroutine"
  4820. ;;
  4821. esac
  4822. fi
  4823. if test "$coroutine_pool" = ""; then
  4824. coroutine_pool=yes
  4825. fi
  4826. if test "$debug_stack_usage" = "yes"; then
  4827. if test "$coroutine_pool" = "yes"; then
  4828. echo "WARN: disabling coroutine pool for stack usage debugging"
  4829. coroutine_pool=no
  4830. fi
  4831. fi
  4832. ##########################################
  4833. # check if we have open_by_handle_at
  4834. open_by_handle_at=no
  4835. cat > $TMPC << EOF
  4836. #include <fcntl.h>
  4837. #if !defined(AT_EMPTY_PATH)
  4838. # error missing definition
  4839. #else
  4840. int main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
  4841. #endif
  4842. EOF
  4843. if compile_prog "" "" ; then
  4844. open_by_handle_at=yes
  4845. fi
  4846. ########################################
  4847. # check if we have linux/magic.h
  4848. linux_magic_h=no
  4849. cat > $TMPC << EOF
  4850. #include <linux/magic.h>
  4851. int main(void) {
  4852. return 0;
  4853. }
  4854. EOF
  4855. if compile_prog "" "" ; then
  4856. linux_magic_h=yes
  4857. fi
  4858. ########################################
  4859. # check whether we can disable warning option with a pragma (this is needed
  4860. # to silence warnings in the headers of some versions of external libraries).
  4861. # This test has to be compiled with -Werror as otherwise an unknown pragma is
  4862. # only a warning.
  4863. #
  4864. # If we can't selectively disable warning in the code, disable -Werror so that
  4865. # the build doesn't fail anyway.
  4866. pragma_disable_unused_but_set=no
  4867. cat > $TMPC << EOF
  4868. #pragma GCC diagnostic push
  4869. #pragma GCC diagnostic ignored "-Wstrict-prototypes"
  4870. #pragma GCC diagnostic pop
  4871. int main(void) {
  4872. return 0;
  4873. }
  4874. EOF
  4875. if compile_prog "-Werror" "" ; then
  4876. pragma_diagnostic_available=yes
  4877. else
  4878. werror=no
  4879. fi
  4880. ########################################
  4881. # check if we have valgrind/valgrind.h
  4882. valgrind_h=no
  4883. cat > $TMPC << EOF
  4884. #include <valgrind/valgrind.h>
  4885. int main(void) {
  4886. return 0;
  4887. }
  4888. EOF
  4889. if compile_prog "" "" ; then
  4890. valgrind_h=yes
  4891. fi
  4892. ########################################
  4893. # check if environ is declared
  4894. has_environ=no
  4895. cat > $TMPC << EOF
  4896. #include <unistd.h>
  4897. int main(void) {
  4898. environ = 0;
  4899. return 0;
  4900. }
  4901. EOF
  4902. if compile_prog "" "" ; then
  4903. has_environ=yes
  4904. fi
  4905. ########################################
  4906. # check if cpuid.h is usable.
  4907. cat > $TMPC << EOF
  4908. #include <cpuid.h>
  4909. int main(void) {
  4910. unsigned a, b, c, d;
  4911. int max = __get_cpuid_max(0, 0);
  4912. if (max >= 1) {
  4913. __cpuid(1, a, b, c, d);
  4914. }
  4915. if (max >= 7) {
  4916. __cpuid_count(7, 0, a, b, c, d);
  4917. }
  4918. return 0;
  4919. }
  4920. EOF
  4921. if compile_prog "" "" ; then
  4922. cpuid_h=yes
  4923. fi
  4924. ##########################################
  4925. # avx2 optimization requirement check
  4926. #
  4927. # There is no point enabling this if cpuid.h is not usable,
  4928. # since we won't be able to select the new routines.
  4929. if test "$cpuid_h" = "yes" && test "$avx2_opt" != "no"; then
  4930. cat > $TMPC << EOF
  4931. #pragma GCC push_options
  4932. #pragma GCC target("avx2")
  4933. #include <cpuid.h>
  4934. #include <immintrin.h>
  4935. static int bar(void *a) {
  4936. __m256i x = *(__m256i *)a;
  4937. return _mm256_testz_si256(x, x);
  4938. }
  4939. int main(int argc, char *argv[]) { return bar(argv[0]); }
  4940. EOF
  4941. if compile_object "" ; then
  4942. avx2_opt="yes"
  4943. else
  4944. avx2_opt="no"
  4945. fi
  4946. fi
  4947. ########################################
  4948. # check if __[u]int128_t is usable.
  4949. int128=no
  4950. cat > $TMPC << EOF
  4951. __int128_t a;
  4952. __uint128_t b;
  4953. int main (void) {
  4954. a = a + b;
  4955. b = a * b;
  4956. a = a * a;
  4957. return 0;
  4958. }
  4959. EOF
  4960. if compile_prog "" "" ; then
  4961. int128=yes
  4962. fi
  4963. #########################################
  4964. # See if 128-bit atomic operations are supported.
  4965. atomic128=no
  4966. if test "$int128" = "yes"; then
  4967. cat > $TMPC << EOF
  4968. int main(void)
  4969. {
  4970. unsigned __int128 x = 0, y = 0;
  4971. y = __atomic_load_16(&x, 0);
  4972. __atomic_store_16(&x, y, 0);
  4973. __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
  4974. return 0;
  4975. }
  4976. EOF
  4977. if compile_prog "" "" ; then
  4978. atomic128=yes
  4979. fi
  4980. fi
  4981. cmpxchg128=no
  4982. if test "$int128" = yes && test "$atomic128" = no; then
  4983. cat > $TMPC << EOF
  4984. int main(void)
  4985. {
  4986. unsigned __int128 x = 0, y = 0;
  4987. __sync_val_compare_and_swap_16(&x, y, x);
  4988. return 0;
  4989. }
  4990. EOF
  4991. if compile_prog "" "" ; then
  4992. cmpxchg128=yes
  4993. fi
  4994. fi
  4995. #########################################
  4996. # See if 64-bit atomic operations are supported.
  4997. # Note that without __atomic builtins, we can only
  4998. # assume atomic loads/stores max at pointer size.
  4999. cat > $TMPC << EOF
  5000. #include <stdint.h>
  5001. int main(void)
  5002. {
  5003. uint64_t x = 0, y = 0;
  5004. #ifdef __ATOMIC_RELAXED
  5005. y = __atomic_load_8(&x, 0);
  5006. __atomic_store_8(&x, y, 0);
  5007. __atomic_compare_exchange_8(&x, &y, x, 0, 0, 0);
  5008. __atomic_exchange_8(&x, y, 0);
  5009. __atomic_fetch_add_8(&x, y, 0);
  5010. #else
  5011. typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
  5012. __sync_lock_test_and_set(&x, y);
  5013. __sync_val_compare_and_swap(&x, y, 0);
  5014. __sync_fetch_and_add(&x, y);
  5015. #endif
  5016. return 0;
  5017. }
  5018. EOF
  5019. if compile_prog "" "" ; then
  5020. atomic64=yes
  5021. fi
  5022. ########################################
  5023. # See if 16-byte vector operations are supported.
  5024. # Even without a vector unit the compiler may expand these.
  5025. # There is a bug in old GCC for PPC that crashes here.
  5026. # Unfortunately it's the system compiler for Centos 7.
  5027. cat > $TMPC << EOF
  5028. typedef unsigned char U1 __attribute__((vector_size(16)));
  5029. typedef unsigned short U2 __attribute__((vector_size(16)));
  5030. typedef unsigned int U4 __attribute__((vector_size(16)));
  5031. typedef unsigned long long U8 __attribute__((vector_size(16)));
  5032. typedef signed char S1 __attribute__((vector_size(16)));
  5033. typedef signed short S2 __attribute__((vector_size(16)));
  5034. typedef signed int S4 __attribute__((vector_size(16)));
  5035. typedef signed long long S8 __attribute__((vector_size(16)));
  5036. static U1 a1, b1;
  5037. static U2 a2, b2;
  5038. static U4 a4, b4;
  5039. static U8 a8, b8;
  5040. static S1 c1;
  5041. static S2 c2;
  5042. static S4 c4;
  5043. static S8 c8;
  5044. static int i;
  5045. void helper(void *d, void *a, int shift, int i);
  5046. void helper(void *d, void *a, int shift, int i)
  5047. {
  5048. *(U1 *)(d + i) = *(U1 *)(a + i) << shift;
  5049. *(U2 *)(d + i) = *(U2 *)(a + i) << shift;
  5050. *(U4 *)(d + i) = *(U4 *)(a + i) << shift;
  5051. *(U8 *)(d + i) = *(U8 *)(a + i) << shift;
  5052. }
  5053. int main(void)
  5054. {
  5055. a1 += b1; a2 += b2; a4 += b4; a8 += b8;
  5056. a1 -= b1; a2 -= b2; a4 -= b4; a8 -= b8;
  5057. a1 *= b1; a2 *= b2; a4 *= b4; a8 *= b8;
  5058. a1 &= b1; a2 &= b2; a4 &= b4; a8 &= b8;
  5059. a1 |= b1; a2 |= b2; a4 |= b4; a8 |= b8;
  5060. a1 ^= b1; a2 ^= b2; a4 ^= b4; a8 ^= b8;
  5061. a1 <<= i; a2 <<= i; a4 <<= i; a8 <<= i;
  5062. a1 >>= i; a2 >>= i; a4 >>= i; a8 >>= i;
  5063. c1 >>= i; c2 >>= i; c4 >>= i; c8 >>= i;
  5064. return 0;
  5065. }
  5066. EOF
  5067. vector16=no
  5068. if compile_prog "" "" ; then
  5069. vector16=yes
  5070. fi
  5071. ########################################
  5072. # check if getauxval is available.
  5073. getauxval=no
  5074. cat > $TMPC << EOF
  5075. #include <sys/auxv.h>
  5076. int main(void) {
  5077. return getauxval(AT_HWCAP) == 0;
  5078. }
  5079. EOF
  5080. if compile_prog "" "" ; then
  5081. getauxval=yes
  5082. fi
  5083. ########################################
  5084. # check if ccache is interfering with
  5085. # semantic analysis of macros
  5086. unset CCACHE_CPP2
  5087. ccache_cpp2=no
  5088. cat > $TMPC << EOF
  5089. static const int Z = 1;
  5090. #define fn() ({ Z; })
  5091. #define TAUT(X) ((X) == Z)
  5092. #define PAREN(X, Y) (X == Y)
  5093. #define ID(X) (X)
  5094. int main(int argc, char *argv[])
  5095. {
  5096. int x = 0, y = 0;
  5097. x = ID(x);
  5098. x = fn();
  5099. fn();
  5100. if (PAREN(x, y)) return 0;
  5101. if (TAUT(Z)) return 0;
  5102. return 0;
  5103. }
  5104. EOF
  5105. if ! compile_object "-Werror"; then
  5106. ccache_cpp2=yes
  5107. fi
  5108. #################################################
  5109. # clang does not support glibc + FORTIFY_SOURCE.
  5110. if test "$fortify_source" != "no"; then
  5111. if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
  5112. fortify_source="no";
  5113. elif test -n "$cxx" && has $cxx &&
  5114. echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
  5115. fortify_source="no";
  5116. else
  5117. fortify_source="yes"
  5118. fi
  5119. fi
  5120. ###############################################
  5121. # Check if copy_file_range is provided by glibc
  5122. have_copy_file_range=no
  5123. cat > $TMPC << EOF
  5124. #include <unistd.h>
  5125. int main(void) {
  5126. copy_file_range(0, NULL, 0, NULL, 0, 0);
  5127. return 0;
  5128. }
  5129. EOF
  5130. if compile_prog "" "" ; then
  5131. have_copy_file_range=yes
  5132. fi
  5133. ##########################################
  5134. # check if struct fsxattr is available via linux/fs.h
  5135. have_fsxattr=no
  5136. cat > $TMPC << EOF
  5137. #include <linux/fs.h>
  5138. struct fsxattr foo;
  5139. int main(void) {
  5140. return 0;
  5141. }
  5142. EOF
  5143. if compile_prog "" "" ; then
  5144. have_fsxattr=yes
  5145. fi
  5146. ##########################################
  5147. # check for usable membarrier system call
  5148. if test "$membarrier" = "yes"; then
  5149. have_membarrier=no
  5150. if test "$mingw32" = "yes" ; then
  5151. have_membarrier=yes
  5152. elif test "$linux" = "yes" ; then
  5153. cat > $TMPC << EOF
  5154. #include <linux/membarrier.h>
  5155. #include <sys/syscall.h>
  5156. #include <unistd.h>
  5157. #include <stdlib.h>
  5158. int main(void) {
  5159. syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
  5160. syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0);
  5161. exit(0);
  5162. }
  5163. EOF
  5164. if compile_prog "" "" ; then
  5165. have_membarrier=yes
  5166. fi
  5167. fi
  5168. if test "$have_membarrier" = "no"; then
  5169. feature_not_found "membarrier" "membarrier system call not available"
  5170. fi
  5171. else
  5172. # Do not enable it by default even for Mingw32, because it doesn't
  5173. # work on Wine.
  5174. membarrier=no
  5175. fi
  5176. ##########################################
  5177. # check if rtnetlink.h exists and is useful
  5178. have_rtnetlink=no
  5179. cat > $TMPC << EOF
  5180. #include <linux/rtnetlink.h>
  5181. int main(void) {
  5182. return IFLA_PROTO_DOWN;
  5183. }
  5184. EOF
  5185. if compile_prog "" "" ; then
  5186. have_rtnetlink=yes
  5187. fi
  5188. ##########################################
  5189. # check for usable AF_VSOCK environment
  5190. have_af_vsock=no
  5191. cat > $TMPC << EOF
  5192. #include <errno.h>
  5193. #include <sys/types.h>
  5194. #include <sys/socket.h>
  5195. #if !defined(AF_VSOCK)
  5196. # error missing AF_VSOCK flag
  5197. #endif
  5198. #include <linux/vm_sockets.h>
  5199. int main(void) {
  5200. int sock, ret;
  5201. struct sockaddr_vm svm;
  5202. socklen_t len = sizeof(svm);
  5203. sock = socket(AF_VSOCK, SOCK_STREAM, 0);
  5204. ret = getpeername(sock, (struct sockaddr *)&svm, &len);
  5205. if ((ret == -1) && (errno == ENOTCONN)) {
  5206. return 0;
  5207. }
  5208. return -1;
  5209. }
  5210. EOF
  5211. if compile_prog "" "" ; then
  5212. have_af_vsock=yes
  5213. fi
  5214. ##########################################
  5215. # check for usable AF_ALG environment
  5216. hava_afalg=no
  5217. cat > $TMPC << EOF
  5218. #include <errno.h>
  5219. #include <sys/types.h>
  5220. #include <sys/socket.h>
  5221. #include <linux/if_alg.h>
  5222. int main(void) {
  5223. int sock;
  5224. sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
  5225. return sock;
  5226. }
  5227. EOF
  5228. if compile_prog "" "" ; then
  5229. have_afalg=yes
  5230. fi
  5231. if test "$crypto_afalg" = "yes"
  5232. then
  5233. if test "$have_afalg" != "yes"
  5234. then
  5235. error_exit "AF_ALG requested but could not be detected"
  5236. fi
  5237. fi
  5238. #################################################
  5239. # Check to see if we have the Hypervisor framework
  5240. if [ "$darwin" = "yes" ] ; then
  5241. cat > $TMPC << EOF
  5242. #include <Hypervisor/hv.h>
  5243. int main() { return 0;}
  5244. EOF
  5245. if ! compile_object ""; then
  5246. hvf='no'
  5247. else
  5248. hvf='yes'
  5249. LDFLAGS="-framework Hypervisor $LDFLAGS"
  5250. fi
  5251. fi
  5252. #################################################
  5253. # Sparc implicitly links with --relax, which is
  5254. # incompatible with -r, so --no-relax should be
  5255. # given. It does no harm to give it on other
  5256. # platforms too.
  5257. # Note: the prototype is needed since QEMU_CFLAGS
  5258. # contains -Wmissing-prototypes
  5259. cat > $TMPC << EOF
  5260. extern int foo(void);
  5261. int foo(void) { return 0; }
  5262. EOF
  5263. if ! compile_object ""; then
  5264. error_exit "Failed to compile object file for LD_REL_FLAGS test"
  5265. fi
  5266. for i in '-Wl,-r -Wl,--no-relax' -Wl,-r -r; do
  5267. if do_cc -nostdlib $i -o $TMPMO $TMPO; then
  5268. LD_REL_FLAGS=$i
  5269. break
  5270. fi
  5271. done
  5272. if test "$modules" = "yes" && test "$LD_REL_FLAGS" = ""; then
  5273. feature_not_found "modules" "Cannot find how to build relocatable objects"
  5274. fi
  5275. ##########################################
  5276. # check for sysmacros.h
  5277. have_sysmacros=no
  5278. cat > $TMPC << EOF
  5279. #include <sys/sysmacros.h>
  5280. int main(void) {
  5281. return makedev(0, 0);
  5282. }
  5283. EOF
  5284. if compile_prog "" "" ; then
  5285. have_sysmacros=yes
  5286. fi
  5287. ##########################################
  5288. # Veritas HyperScale block driver VxHS
  5289. # Check if libvxhs is installed
  5290. if test "$vxhs" != "no" ; then
  5291. cat > $TMPC <<EOF
  5292. #include <stdint.h>
  5293. #include <qnio/qnio_api.h>
  5294. void *vxhs_callback;
  5295. int main(void) {
  5296. iio_init(QNIO_VERSION, vxhs_callback);
  5297. return 0;
  5298. }
  5299. EOF
  5300. vxhs_libs="-lvxhs -lssl"
  5301. if compile_prog "" "$vxhs_libs" ; then
  5302. vxhs=yes
  5303. else
  5304. if test "$vxhs" = "yes" ; then
  5305. feature_not_found "vxhs block device" "Install libvxhs See github"
  5306. fi
  5307. vxhs=no
  5308. fi
  5309. fi
  5310. ##########################################
  5311. # check for _Static_assert()
  5312. have_static_assert=no
  5313. cat > $TMPC << EOF
  5314. _Static_assert(1, "success");
  5315. int main(void) {
  5316. return 0;
  5317. }
  5318. EOF
  5319. if compile_prog "" "" ; then
  5320. have_static_assert=yes
  5321. fi
  5322. ##########################################
  5323. # check for utmpx.h, it is missing e.g. on OpenBSD
  5324. have_utmpx=no
  5325. cat > $TMPC << EOF
  5326. #include <utmpx.h>
  5327. struct utmpx user_info;
  5328. int main(void) {
  5329. return 0;
  5330. }
  5331. EOF
  5332. if compile_prog "" "" ; then
  5333. have_utmpx=yes
  5334. fi
  5335. ##########################################
  5336. # checks for sanitizers
  5337. have_asan=no
  5338. have_ubsan=no
  5339. have_asan_iface_h=no
  5340. have_asan_iface_fiber=no
  5341. if test "$sanitizers" = "yes" ; then
  5342. write_c_skeleton
  5343. if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
  5344. have_asan=yes
  5345. fi
  5346. # we could use a simple skeleton for flags checks, but this also
  5347. # detect the static linking issue of ubsan, see also:
  5348. # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
  5349. cat > $TMPC << EOF
  5350. #include <stdlib.h>
  5351. int main(void) {
  5352. void *tmp = malloc(10);
  5353. return *(int *)(tmp + 2);
  5354. }
  5355. EOF
  5356. if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
  5357. have_ubsan=yes
  5358. fi
  5359. if check_include "sanitizer/asan_interface.h" ; then
  5360. have_asan_iface_h=yes
  5361. fi
  5362. cat > $TMPC << EOF
  5363. #include <sanitizer/asan_interface.h>
  5364. int main(void) {
  5365. __sanitizer_start_switch_fiber(0, 0, 0);
  5366. return 0;
  5367. }
  5368. EOF
  5369. if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
  5370. have_asan_iface_fiber=yes
  5371. fi
  5372. fi
  5373. ##########################################
  5374. # Docker and cross-compiler support
  5375. #
  5376. # This is specifically for building test
  5377. # cases for foreign architectures, not
  5378. # cross-compiling QEMU itself.
  5379. if has "docker"; then
  5380. docker=$($python $source_path/tests/docker/docker.py probe)
  5381. fi
  5382. ##########################################
  5383. # check for libpmem
  5384. if test "$libpmem" != "no"; then
  5385. if $pkg_config --exists "libpmem"; then
  5386. libpmem="yes"
  5387. libpmem_libs=$($pkg_config --libs libpmem)
  5388. libpmem_cflags=$($pkg_config --cflags libpmem)
  5389. libs_softmmu="$libs_softmmu $libpmem_libs"
  5390. QEMU_CFLAGS="$QEMU_CFLAGS $libpmem_cflags"
  5391. else
  5392. if test "$libpmem" = "yes" ; then
  5393. feature_not_found "libpmem" "Install nvml or pmdk"
  5394. fi
  5395. libpmem="no"
  5396. fi
  5397. fi
  5398. ##########################################
  5399. # check for slirp
  5400. case "$slirp" in
  5401. "" | yes)
  5402. if $pkg_config slirp; then
  5403. slirp=system
  5404. elif test -e "${source_path}/slirp/Makefile" ; then
  5405. slirp=internal
  5406. elif test -z "$slirp" ; then
  5407. slirp=no
  5408. else
  5409. feature_not_found "slirp" "Install slirp devel or git submodule"
  5410. fi
  5411. ;;
  5412. system)
  5413. if ! $pkg_config slirp; then
  5414. feature_not_found "slirp" "Install slirp devel"
  5415. fi
  5416. ;;
  5417. esac
  5418. case "$slirp" in
  5419. internal)
  5420. mkdir -p slirp
  5421. slirp_cflags="-I\$(SRC_PATH)/slirp/src -I\$(BUILD_DIR)/slirp/src"
  5422. slirp_libs="-L\$(BUILD_DIR)/slirp -lslirp"
  5423. ;;
  5424. system)
  5425. slirp_version=$($pkg_config --modversion slirp 2>/dev/null)
  5426. slirp_cflags=$($pkg_config --cflags slirp 2>/dev/null)
  5427. slirp_libs=$($pkg_config --libs slirp 2>/dev/null)
  5428. ;;
  5429. no)
  5430. ;;
  5431. *)
  5432. error_exit "Unknown state for slirp: $slirp"
  5433. ;;
  5434. esac
  5435. ##########################################
  5436. # End of CC checks
  5437. # After here, no more $cc or $ld runs
  5438. write_c_skeleton
  5439. if test "$gcov" = "yes" ; then
  5440. CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
  5441. LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
  5442. elif test "$fortify_source" = "yes" ; then
  5443. CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
  5444. elif test "$debug" = "no"; then
  5445. CFLAGS="-O2 $CFLAGS"
  5446. fi
  5447. if test "$have_asan" = "yes"; then
  5448. CFLAGS="-fsanitize=address $CFLAGS"
  5449. if test "$have_asan_iface_h" = "no" ; then
  5450. echo "ASAN build enabled, but ASAN header missing." \
  5451. "Without code annotation, the report may be inferior."
  5452. elif test "$have_asan_iface_fiber" = "no" ; then
  5453. echo "ASAN build enabled, but ASAN header is too old." \
  5454. "Without code annotation, the report may be inferior."
  5455. fi
  5456. fi
  5457. if test "$have_ubsan" = "yes"; then
  5458. CFLAGS="-fsanitize=undefined $CFLAGS"
  5459. fi
  5460. ##########################################
  5461. # Do we have libnfs
  5462. if test "$libnfs" != "no" ; then
  5463. if $pkg_config --atleast-version=1.9.3 libnfs; then
  5464. libnfs="yes"
  5465. libnfs_libs=$($pkg_config --libs libnfs)
  5466. else
  5467. if test "$libnfs" = "yes" ; then
  5468. feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
  5469. fi
  5470. libnfs="no"
  5471. fi
  5472. fi
  5473. ##########################################
  5474. # Do we have libudev
  5475. if test "$libudev" != "no" ; then
  5476. if $pkg_config libudev && test "$static" != "yes"; then
  5477. libudev="yes"
  5478. libudev_libs=$($pkg_config --libs libudev)
  5479. else
  5480. libudev="no"
  5481. fi
  5482. fi
  5483. # Now we've finished running tests it's OK to add -Werror to the compiler flags
  5484. if test "$werror" = "yes"; then
  5485. QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
  5486. fi
  5487. if test "$solaris" = "no" ; then
  5488. if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
  5489. LDFLAGS="-Wl,--warn-common $LDFLAGS"
  5490. fi
  5491. fi
  5492. # test if pod2man has --utf8 option
  5493. if pod2man --help | grep -q utf8; then
  5494. POD2MAN="pod2man --utf8"
  5495. else
  5496. POD2MAN="pod2man"
  5497. fi
  5498. # Use ASLR, no-SEH and DEP if available
  5499. if test "$mingw32" = "yes" ; then
  5500. for flag in --dynamicbase --no-seh --nxcompat; do
  5501. if ld_has $flag ; then
  5502. LDFLAGS="-Wl,$flag $LDFLAGS"
  5503. fi
  5504. done
  5505. fi
  5506. # Disable OpenBSD W^X if available
  5507. if test "$tcg" = "yes" && test "$targetos" = "OpenBSD"; then
  5508. cat > $TMPC <<EOF
  5509. int main(void) { return 0; }
  5510. EOF
  5511. wx_ldflags="-Wl,-z,wxneeded"
  5512. if compile_prog "" "$wx_ldflags"; then
  5513. QEMU_LDFLAGS="$QEMU_LDFLAGS $wx_ldflags"
  5514. fi
  5515. fi
  5516. qemu_confdir=$sysconfdir$confsuffix
  5517. qemu_moddir=$libdir$confsuffix
  5518. qemu_datadir=$datadir$confsuffix
  5519. qemu_localedir="$datadir/locale"
  5520. qemu_icondir="$datadir/icons"
  5521. qemu_desktopdir="$datadir/applications"
  5522. # We can only support ivshmem if we have eventfd
  5523. if [ "$eventfd" = "yes" ]; then
  5524. ivshmem=yes
  5525. fi
  5526. tools=""
  5527. if test "$want_tools" = "yes" ; then
  5528. tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) qemu-edid\$(EXESUF) $tools"
  5529. if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
  5530. tools="qemu-nbd\$(EXESUF) $tools"
  5531. fi
  5532. if [ "$ivshmem" = "yes" ]; then
  5533. tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools"
  5534. fi
  5535. if [ "$curl" = "yes" ]; then
  5536. tools="elf2dmp\$(EXESUF) $tools"
  5537. fi
  5538. fi
  5539. if test "$softmmu" = yes ; then
  5540. if test "$linux" = yes; then
  5541. if test "$virtfs" != no && test "$cap" = yes && test "$attr" = yes ; then
  5542. virtfs=yes
  5543. tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
  5544. else
  5545. if test "$virtfs" = yes; then
  5546. error_exit "VirtFS requires libcap devel and libattr devel"
  5547. fi
  5548. virtfs=no
  5549. fi
  5550. if test "$mpath" != no && test "$mpathpersist" = yes ; then
  5551. mpath=yes
  5552. else
  5553. if test "$mpath" = yes; then
  5554. error_exit "Multipath requires libmpathpersist devel"
  5555. fi
  5556. mpath=no
  5557. fi
  5558. tools="$tools scsi/qemu-pr-helper\$(EXESUF)"
  5559. else
  5560. if test "$virtfs" = yes; then
  5561. error_exit "VirtFS is supported only on Linux"
  5562. fi
  5563. virtfs=no
  5564. if test "$mpath" = yes; then
  5565. error_exit "Multipath is supported only on Linux"
  5566. fi
  5567. mpath=no
  5568. fi
  5569. if test "$xkbcommon" = "yes"; then
  5570. tools="qemu-keymap\$(EXESUF) $tools"
  5571. fi
  5572. fi
  5573. # Probe for guest agent support/options
  5574. if [ "$guest_agent" != "no" ]; then
  5575. if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
  5576. tools="qemu-ga $tools"
  5577. guest_agent=yes
  5578. elif [ "$guest_agent" != yes ]; then
  5579. guest_agent=no
  5580. else
  5581. error_exit "Guest agent is not supported on this platform"
  5582. fi
  5583. fi
  5584. # Guest agent Window MSI package
  5585. if test "$guest_agent" != yes; then
  5586. if test "$guest_agent_msi" = yes; then
  5587. error_exit "MSI guest agent package requires guest agent enabled"
  5588. fi
  5589. guest_agent_msi=no
  5590. elif test "$mingw32" != "yes"; then
  5591. if test "$guest_agent_msi" = "yes"; then
  5592. error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
  5593. fi
  5594. guest_agent_msi=no
  5595. elif ! has wixl; then
  5596. if test "$guest_agent_msi" = "yes"; then
  5597. error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
  5598. fi
  5599. guest_agent_msi=no
  5600. else
  5601. # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
  5602. # disabled explicitly
  5603. if test "$guest_agent_msi" != "no"; then
  5604. guest_agent_msi=yes
  5605. fi
  5606. fi
  5607. if test "$guest_agent_msi" = "yes"; then
  5608. if test "$guest_agent_with_vss" = "yes"; then
  5609. QEMU_GA_MSI_WITH_VSS="-D InstallVss"
  5610. fi
  5611. if test "$QEMU_GA_MANUFACTURER" = ""; then
  5612. QEMU_GA_MANUFACTURER=QEMU
  5613. fi
  5614. if test "$QEMU_GA_DISTRO" = ""; then
  5615. QEMU_GA_DISTRO=Linux
  5616. fi
  5617. if test "$QEMU_GA_VERSION" = ""; then
  5618. QEMU_GA_VERSION=$(cat $source_path/VERSION)
  5619. fi
  5620. QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
  5621. case "$cpu" in
  5622. x86_64)
  5623. QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
  5624. ;;
  5625. i386)
  5626. QEMU_GA_MSI_ARCH="-D Arch=32"
  5627. ;;
  5628. *)
  5629. error_exit "CPU $cpu not supported for building installation package"
  5630. ;;
  5631. esac
  5632. fi
  5633. # Mac OS X ships with a broken assembler
  5634. roms=
  5635. if { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \
  5636. test "$targetos" != "Darwin" && test "$targetos" != "SunOS" && \
  5637. test "$softmmu" = yes ; then
  5638. # Different host OS linkers have different ideas about the name of the ELF
  5639. # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
  5640. # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
  5641. for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
  5642. if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
  5643. ld_i386_emulation="$emu"
  5644. roms="optionrom"
  5645. break
  5646. fi
  5647. done
  5648. fi
  5649. if test "$cpu" = "ppc64" && test "$targetos" != "Darwin" ; then
  5650. roms="$roms spapr-rtas"
  5651. fi
  5652. # Only build s390-ccw bios if we're on s390x and the compiler has -march=z900
  5653. if test "$cpu" = "s390x" ; then
  5654. write_c_skeleton
  5655. if compile_prog "-march=z900" ""; then
  5656. roms="$roms s390-ccw"
  5657. fi
  5658. fi
  5659. # Probe for the need for relocating the user-only binary.
  5660. if ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) && [ "$pie" = no ]; then
  5661. textseg_addr=
  5662. case "$cpu" in
  5663. arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
  5664. # ??? Rationale for choosing this address
  5665. textseg_addr=0x60000000
  5666. ;;
  5667. mips)
  5668. # A 256M aligned address, high in the address space, with enough
  5669. # room for the code_gen_buffer above it before the stack.
  5670. textseg_addr=0x60000000
  5671. ;;
  5672. esac
  5673. if [ -n "$textseg_addr" ]; then
  5674. cat > $TMPC <<EOF
  5675. int main(void) { return 0; }
  5676. EOF
  5677. textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
  5678. if ! compile_prog "" "$textseg_ldflags"; then
  5679. # In case ld does not support -Ttext-segment, edit the default linker
  5680. # script via sed to set the .text start addr. This is needed on FreeBSD
  5681. # at least.
  5682. if ! $ld --verbose >/dev/null 2>&1; then
  5683. error_exit \
  5684. "We need to link the QEMU user mode binaries at a" \
  5685. "specific text address. Unfortunately your linker" \
  5686. "doesn't support either the -Ttext-segment option or" \
  5687. "printing the default linker script with --verbose." \
  5688. "If you don't want the user mode binaries, pass the" \
  5689. "--disable-user option to configure."
  5690. fi
  5691. $ld --verbose | sed \
  5692. -e '1,/==================================================/d' \
  5693. -e '/==================================================/,$d' \
  5694. -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
  5695. -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
  5696. textseg_ldflags="-Wl,-T../config-host.ld"
  5697. fi
  5698. fi
  5699. fi
  5700. # Check that the C++ compiler exists and works with the C compiler.
  5701. # All the QEMU_CXXFLAGS are based on QEMU_CFLAGS. Keep this at the end to don't miss any other that could be added.
  5702. if has $cxx; then
  5703. cat > $TMPC <<EOF
  5704. int c_function(void);
  5705. int main(void) { return c_function(); }
  5706. EOF
  5707. compile_object
  5708. cat > $TMPCXX <<EOF
  5709. extern "C" {
  5710. int c_function(void);
  5711. }
  5712. int c_function(void) { return 42; }
  5713. EOF
  5714. update_cxxflags
  5715. if do_cxx $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $LDFLAGS; then
  5716. # C++ compiler $cxx works ok with C compiler $cc
  5717. :
  5718. else
  5719. echo "C++ compiler $cxx does not work with C compiler $cc"
  5720. echo "Disabling C++ specific optional code"
  5721. cxx=
  5722. fi
  5723. else
  5724. echo "No C++ compiler available; disabling C++ specific optional code"
  5725. cxx=
  5726. fi
  5727. echo_version() {
  5728. if test "$1" = "yes" ; then
  5729. echo "($2)"
  5730. fi
  5731. }
  5732. # prepend pixman and ftd flags after all config tests are done
  5733. QEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"
  5734. QEMU_LDFLAGS="$fdt_ldflags $QEMU_LDFLAGS"
  5735. libs_softmmu="$pixman_libs $libs_softmmu"
  5736. echo "Install prefix $prefix"
  5737. echo "BIOS directory $(eval echo $qemu_datadir)"
  5738. echo "firmware path $(eval echo $firmwarepath)"
  5739. echo "binary directory $(eval echo $bindir)"
  5740. echo "library directory $(eval echo $libdir)"
  5741. echo "module directory $(eval echo $qemu_moddir)"
  5742. echo "libexec directory $(eval echo $libexecdir)"
  5743. echo "include directory $(eval echo $includedir)"
  5744. echo "config directory $(eval echo $sysconfdir)"
  5745. if test "$mingw32" = "no" ; then
  5746. echo "local state directory $(eval echo $local_statedir)"
  5747. echo "Manual directory $(eval echo $mandir)"
  5748. echo "ELF interp prefix $interp_prefix"
  5749. else
  5750. echo "local state directory queried at runtime"
  5751. echo "Windows SDK $win_sdk"
  5752. fi
  5753. echo "Source path $source_path"
  5754. echo "GIT binary $git"
  5755. echo "GIT submodules $git_submodules"
  5756. echo "C compiler $cc"
  5757. echo "Host C compiler $host_cc"
  5758. echo "C++ compiler $cxx"
  5759. echo "Objective-C compiler $objcc"
  5760. echo "ARFLAGS $ARFLAGS"
  5761. echo "CFLAGS $CFLAGS"
  5762. echo "QEMU_CFLAGS $QEMU_CFLAGS"
  5763. echo "LDFLAGS $LDFLAGS"
  5764. echo "QEMU_LDFLAGS $QEMU_LDFLAGS"
  5765. echo "make $make"
  5766. echo "install $install"
  5767. echo "python $python ($python_version)"
  5768. echo "slirp support $slirp $(echo_version $slirp $slirp_version)"
  5769. if test "$slirp" != "no" ; then
  5770. echo "smbd $smbd"
  5771. fi
  5772. echo "module support $modules"
  5773. echo "host CPU $cpu"
  5774. echo "host big endian $bigendian"
  5775. echo "target list $target_list"
  5776. echo "gprof enabled $gprof"
  5777. echo "sparse enabled $sparse"
  5778. echo "strip binaries $strip_opt"
  5779. echo "profiler $profiler"
  5780. echo "static build $static"
  5781. if test "$darwin" = "yes" ; then
  5782. echo "Cocoa support $cocoa"
  5783. fi
  5784. echo "SDL support $sdl $(echo_version $sdl $sdlversion)"
  5785. echo "SDL image support $sdl_image"
  5786. echo "GTK support $gtk $(echo_version $gtk $gtk_version)"
  5787. echo "GTK GL support $gtk_gl"
  5788. echo "VTE support $vte $(echo_version $vte $vteversion)"
  5789. echo "TLS priority $tls_priority"
  5790. echo "GNUTLS support $gnutls"
  5791. echo "libgcrypt $gcrypt"
  5792. echo "nettle $nettle $(echo_version $nettle $nettle_version)"
  5793. echo "libtasn1 $tasn1"
  5794. echo "PAM $auth_pam"
  5795. echo "iconv support $iconv"
  5796. echo "curses support $curses"
  5797. echo "virgl support $virglrenderer $(echo_version $virglrenderer $virgl_version)"
  5798. echo "curl support $curl"
  5799. echo "mingw32 support $mingw32"
  5800. echo "Audio drivers $audio_drv_list"
  5801. echo "Block whitelist (rw) $block_drv_rw_whitelist"
  5802. echo "Block whitelist (ro) $block_drv_ro_whitelist"
  5803. echo "VirtFS support $virtfs"
  5804. echo "Multipath support $mpath"
  5805. echo "VNC support $vnc"
  5806. if test "$vnc" = "yes" ; then
  5807. echo "VNC SASL support $vnc_sasl"
  5808. echo "VNC JPEG support $vnc_jpeg"
  5809. echo "VNC PNG support $vnc_png"
  5810. fi
  5811. if test -n "$sparc_cpu"; then
  5812. echo "Target Sparc Arch $sparc_cpu"
  5813. fi
  5814. echo "xen support $xen"
  5815. if test "$xen" = "yes" ; then
  5816. echo "xen ctrl version $xen_ctrl_version"
  5817. fi
  5818. echo "brlapi support $brlapi"
  5819. echo "bluez support $bluez"
  5820. echo "Documentation $docs"
  5821. echo "PIE $pie"
  5822. echo "vde support $vde"
  5823. echo "netmap support $netmap"
  5824. echo "Linux AIO support $linux_aio"
  5825. echo "ATTR/XATTR support $attr"
  5826. echo "Install blobs $blobs"
  5827. echo "KVM support $kvm"
  5828. echo "HAX support $hax"
  5829. echo "HVF support $hvf"
  5830. echo "WHPX support $whpx"
  5831. echo "TCG support $tcg"
  5832. if test "$tcg" = "yes" ; then
  5833. echo "TCG debug enabled $debug_tcg"
  5834. echo "TCG interpreter $tcg_interpreter"
  5835. fi
  5836. echo "malloc trim support $malloc_trim"
  5837. echo "RDMA support $rdma"
  5838. echo "PVRDMA support $pvrdma"
  5839. echo "fdt support $fdt"
  5840. echo "membarrier $membarrier"
  5841. echo "preadv support $preadv"
  5842. echo "fdatasync $fdatasync"
  5843. echo "madvise $madvise"
  5844. echo "posix_madvise $posix_madvise"
  5845. echo "posix_memalign $posix_memalign"
  5846. echo "libcap-ng support $cap_ng"
  5847. echo "vhost-net support $vhost_net"
  5848. echo "vhost-crypto support $vhost_crypto"
  5849. echo "vhost-scsi support $vhost_scsi"
  5850. echo "vhost-vsock support $vhost_vsock"
  5851. echo "vhost-user support $vhost_user"
  5852. echo "Trace backends $trace_backends"
  5853. if have_backend "simple"; then
  5854. echo "Trace output file $trace_file-<pid>"
  5855. fi
  5856. echo "spice support $spice $(echo_version $spice $spice_protocol_version/$spice_server_version)"
  5857. echo "rbd support $rbd"
  5858. echo "xfsctl support $xfs"
  5859. echo "smartcard support $smartcard"
  5860. echo "libusb $libusb"
  5861. echo "usb net redir $usb_redir"
  5862. echo "OpenGL support $opengl"
  5863. echo "OpenGL dmabufs $opengl_dmabuf"
  5864. echo "libiscsi support $libiscsi"
  5865. echo "libnfs support $libnfs"
  5866. echo "build guest agent $guest_agent"
  5867. echo "QGA VSS support $guest_agent_with_vss"
  5868. echo "QGA w32 disk info $guest_agent_ntddscsi"
  5869. echo "QGA MSI support $guest_agent_msi"
  5870. echo "seccomp support $seccomp"
  5871. echo "coroutine backend $coroutine"
  5872. echo "coroutine pool $coroutine_pool"
  5873. echo "debug stack usage $debug_stack_usage"
  5874. echo "mutex debugging $debug_mutex"
  5875. echo "crypto afalg $crypto_afalg"
  5876. echo "GlusterFS support $glusterfs"
  5877. echo "gcov $gcov_tool"
  5878. echo "gcov enabled $gcov"
  5879. echo "TPM support $tpm"
  5880. echo "libssh2 support $libssh2"
  5881. echo "TPM passthrough $tpm_passthrough"
  5882. echo "TPM emulator $tpm_emulator"
  5883. echo "QOM debugging $qom_cast_debug"
  5884. echo "Live block migration $live_block_migration"
  5885. echo "lzo support $lzo"
  5886. echo "snappy support $snappy"
  5887. echo "bzip2 support $bzip2"
  5888. echo "lzfse support $lzfse"
  5889. echo "NUMA host support $numa"
  5890. echo "libxml2 $libxml2"
  5891. echo "tcmalloc support $tcmalloc"
  5892. echo "jemalloc support $jemalloc"
  5893. echo "avx2 optimization $avx2_opt"
  5894. echo "replication support $replication"
  5895. echo "VxHS block device $vxhs"
  5896. echo "bochs support $bochs"
  5897. echo "cloop support $cloop"
  5898. echo "dmg support $dmg"
  5899. echo "qcow v1 support $qcow1"
  5900. echo "vdi support $vdi"
  5901. echo "vvfat support $vvfat"
  5902. echo "qed support $qed"
  5903. echo "parallels support $parallels"
  5904. echo "sheepdog support $sheepdog"
  5905. echo "capstone $capstone"
  5906. echo "docker $docker"
  5907. echo "libpmem support $libpmem"
  5908. echo "libudev $libudev"
  5909. echo "default devices $default_devices"
  5910. if test "$supported_cpu" = "no"; then
  5911. echo
  5912. echo "WARNING: SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!"
  5913. echo
  5914. echo "CPU host architecture $cpu support is not currently maintained."
  5915. echo "The QEMU project intends to remove support for this host CPU in"
  5916. echo "a future release if nobody volunteers to maintain it and to"
  5917. echo "provide a build host for our continuous integration setup."
  5918. echo "configure has succeeded and you can continue to build, but"
  5919. echo "if you care about QEMU on this platform you should contact"
  5920. echo "us upstream at qemu-devel@nongnu.org."
  5921. fi
  5922. if test "$supported_os" = "no"; then
  5923. echo
  5924. echo "WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!"
  5925. echo
  5926. echo "Host OS $targetos support is not currently maintained."
  5927. echo "The QEMU project intends to remove support for this host OS in"
  5928. echo "a future release if nobody volunteers to maintain it and to"
  5929. echo "provide a build host for our continuous integration setup."
  5930. echo "configure has succeeded and you can continue to build, but"
  5931. echo "if you care about QEMU on this platform you should contact"
  5932. echo "us upstream at qemu-devel@nongnu.org."
  5933. fi
  5934. config_host_mak="config-host.mak"
  5935. echo "# Automatically generated by configure - do not modify" >config-all-disas.mak
  5936. echo "# Automatically generated by configure - do not modify" > $config_host_mak
  5937. echo >> $config_host_mak
  5938. echo all: >> $config_host_mak
  5939. echo "prefix=$prefix" >> $config_host_mak
  5940. echo "bindir=$bindir" >> $config_host_mak
  5941. echo "libdir=$libdir" >> $config_host_mak
  5942. echo "libexecdir=$libexecdir" >> $config_host_mak
  5943. echo "includedir=$includedir" >> $config_host_mak
  5944. echo "mandir=$mandir" >> $config_host_mak
  5945. echo "sysconfdir=$sysconfdir" >> $config_host_mak
  5946. echo "qemu_confdir=$qemu_confdir" >> $config_host_mak
  5947. echo "qemu_datadir=$qemu_datadir" >> $config_host_mak
  5948. echo "qemu_firmwarepath=$firmwarepath" >> $config_host_mak
  5949. echo "qemu_docdir=$qemu_docdir" >> $config_host_mak
  5950. echo "qemu_moddir=$qemu_moddir" >> $config_host_mak
  5951. if test "$mingw32" = "no" ; then
  5952. echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
  5953. fi
  5954. echo "qemu_helperdir=$libexecdir" >> $config_host_mak
  5955. echo "qemu_localedir=$qemu_localedir" >> $config_host_mak
  5956. echo "qemu_icondir=$qemu_icondir" >> $config_host_mak
  5957. echo "qemu_desktopdir=$qemu_desktopdir" >> $config_host_mak
  5958. echo "libs_softmmu=$libs_softmmu" >> $config_host_mak
  5959. echo "GIT=$git" >> $config_host_mak
  5960. echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
  5961. echo "GIT_UPDATE=$git_update" >> $config_host_mak
  5962. echo "ARCH=$ARCH" >> $config_host_mak
  5963. if test "$default_devices" = "yes" ; then
  5964. echo "CONFIG_MINIKCONF_MODE=--defconfig" >> $config_host_mak
  5965. else
  5966. echo "CONFIG_MINIKCONF_MODE=--allnoconfig" >> $config_host_mak
  5967. fi
  5968. if test "$debug_tcg" = "yes" ; then
  5969. echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
  5970. fi
  5971. if test "$strip_opt" = "yes" ; then
  5972. echo "STRIP=${strip}" >> $config_host_mak
  5973. fi
  5974. if test "$bigendian" = "yes" ; then
  5975. echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
  5976. fi
  5977. if test "$mingw32" = "yes" ; then
  5978. echo "CONFIG_WIN32=y" >> $config_host_mak
  5979. rc_version=$(cat $source_path/VERSION)
  5980. version_major=${rc_version%%.*}
  5981. rc_version=${rc_version#*.}
  5982. version_minor=${rc_version%%.*}
  5983. rc_version=${rc_version#*.}
  5984. version_subminor=${rc_version%%.*}
  5985. version_micro=0
  5986. echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
  5987. echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
  5988. if test "$guest_agent_with_vss" = "yes" ; then
  5989. echo "CONFIG_QGA_VSS=y" >> $config_host_mak
  5990. echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
  5991. echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
  5992. fi
  5993. if test "$guest_agent_ntddscsi" = "yes" ; then
  5994. echo "CONFIG_QGA_NTDDSCSI=y" >> $config_host_mak
  5995. fi
  5996. if test "$guest_agent_msi" = "yes"; then
  5997. echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
  5998. echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
  5999. echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
  6000. echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
  6001. echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
  6002. echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
  6003. echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
  6004. fi
  6005. else
  6006. echo "CONFIG_POSIX=y" >> $config_host_mak
  6007. fi
  6008. if test "$linux" = "yes" ; then
  6009. echo "CONFIG_LINUX=y" >> $config_host_mak
  6010. fi
  6011. if test "$darwin" = "yes" ; then
  6012. echo "CONFIG_DARWIN=y" >> $config_host_mak
  6013. fi
  6014. if test "$solaris" = "yes" ; then
  6015. echo "CONFIG_SOLARIS=y" >> $config_host_mak
  6016. fi
  6017. if test "$haiku" = "yes" ; then
  6018. echo "CONFIG_HAIKU=y" >> $config_host_mak
  6019. fi
  6020. if test "$static" = "yes" ; then
  6021. echo "CONFIG_STATIC=y" >> $config_host_mak
  6022. fi
  6023. if test "$profiler" = "yes" ; then
  6024. echo "CONFIG_PROFILER=y" >> $config_host_mak
  6025. fi
  6026. if test "$slirp" != "no"; then
  6027. echo "CONFIG_SLIRP=y" >> $config_host_mak
  6028. echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
  6029. echo "SLIRP_CFLAGS=$slirp_cflags" >> $config_host_mak
  6030. echo "SLIRP_LIBS=$slirp_libs" >> $config_host_mak
  6031. fi
  6032. if [ "$slirp" = "internal" ]; then
  6033. echo "config-host.h: subdir-slirp" >> $config_host_mak
  6034. fi
  6035. if test "$vde" = "yes" ; then
  6036. echo "CONFIG_VDE=y" >> $config_host_mak
  6037. echo "VDE_LIBS=$vde_libs" >> $config_host_mak
  6038. fi
  6039. if test "$netmap" = "yes" ; then
  6040. echo "CONFIG_NETMAP=y" >> $config_host_mak
  6041. fi
  6042. if test "$l2tpv3" = "yes" ; then
  6043. echo "CONFIG_L2TPV3=y" >> $config_host_mak
  6044. fi
  6045. if test "$cap_ng" = "yes" ; then
  6046. echo "CONFIG_LIBCAP=y" >> $config_host_mak
  6047. fi
  6048. echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
  6049. for drv in $audio_drv_list; do
  6050. def=CONFIG_AUDIO_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
  6051. case "$drv" in
  6052. alsa | oss | pa | sdl)
  6053. echo "$def=m" >> $config_host_mak ;;
  6054. *)
  6055. echo "$def=y" >> $config_host_mak ;;
  6056. esac
  6057. done
  6058. echo "ALSA_LIBS=$alsa_libs" >> $config_host_mak
  6059. echo "PULSE_LIBS=$pulse_libs" >> $config_host_mak
  6060. echo "COREAUDIO_LIBS=$coreaudio_libs" >> $config_host_mak
  6061. echo "DSOUND_LIBS=$dsound_libs" >> $config_host_mak
  6062. echo "OSS_LIBS=$oss_libs" >> $config_host_mak
  6063. if test "$audio_pt_int" = "yes" ; then
  6064. echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
  6065. fi
  6066. if test "$audio_win_int" = "yes" ; then
  6067. echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
  6068. fi
  6069. echo "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
  6070. echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
  6071. if test "$vnc" = "yes" ; then
  6072. echo "CONFIG_VNC=y" >> $config_host_mak
  6073. fi
  6074. if test "$vnc_sasl" = "yes" ; then
  6075. echo "CONFIG_VNC_SASL=y" >> $config_host_mak
  6076. fi
  6077. if test "$vnc_jpeg" = "yes" ; then
  6078. echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
  6079. fi
  6080. if test "$vnc_png" = "yes" ; then
  6081. echo "CONFIG_VNC_PNG=y" >> $config_host_mak
  6082. fi
  6083. if test "$xkbcommon" = "yes" ; then
  6084. echo "XKBCOMMON_CFLAGS=$xkbcommon_cflags" >> $config_host_mak
  6085. echo "XKBCOMMON_LIBS=$xkbcommon_libs" >> $config_host_mak
  6086. fi
  6087. if test "$xfs" = "yes" ; then
  6088. echo "CONFIG_XFS=y" >> $config_host_mak
  6089. fi
  6090. qemu_version=$(head $source_path/VERSION)
  6091. echo "VERSION=$qemu_version" >>$config_host_mak
  6092. echo "PKGVERSION=$pkgversion" >>$config_host_mak
  6093. echo "SRC_PATH=$source_path" >> $config_host_mak
  6094. echo "TARGET_DIRS=$target_list" >> $config_host_mak
  6095. if [ "$docs" = "yes" ] ; then
  6096. echo "BUILD_DOCS=yes" >> $config_host_mak
  6097. fi
  6098. if test "$modules" = "yes"; then
  6099. # $shacmd can generate a hash started with digit, which the compiler doesn't
  6100. # like as an symbol. So prefix it with an underscore
  6101. echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
  6102. echo "CONFIG_MODULES=y" >> $config_host_mak
  6103. fi
  6104. if test "$have_x11" = "yes" && test "$need_x11" = "yes"; then
  6105. echo "CONFIG_X11=y" >> $config_host_mak
  6106. echo "X11_CFLAGS=$x11_cflags" >> $config_host_mak
  6107. echo "X11_LIBS=$x11_libs" >> $config_host_mak
  6108. fi
  6109. if test "$sdl" = "yes" ; then
  6110. echo "CONFIG_SDL=m" >> $config_host_mak
  6111. echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
  6112. echo "SDL_LIBS=$sdl_libs" >> $config_host_mak
  6113. if test "$sdl_image" = "yes" ; then
  6114. echo "CONFIG_SDL_IMAGE=y" >> $config_host_mak
  6115. fi
  6116. fi
  6117. if test "$cocoa" = "yes" ; then
  6118. echo "CONFIG_COCOA=y" >> $config_host_mak
  6119. fi
  6120. if test "$iconv" = "yes" ; then
  6121. echo "CONFIG_ICONV=y" >> $config_host_mak
  6122. echo "ICONV_CFLAGS=$iconv_cflags" >> $config_host_mak
  6123. echo "ICONV_LIBS=$iconv_lib" >> $config_host_mak
  6124. fi
  6125. if test "$curses" = "yes" ; then
  6126. echo "CONFIG_CURSES=m" >> $config_host_mak
  6127. echo "CURSES_CFLAGS=$curses_inc" >> $config_host_mak
  6128. echo "CURSES_LIBS=$curses_lib" >> $config_host_mak
  6129. fi
  6130. if test "$pipe2" = "yes" ; then
  6131. echo "CONFIG_PIPE2=y" >> $config_host_mak
  6132. fi
  6133. if test "$accept4" = "yes" ; then
  6134. echo "CONFIG_ACCEPT4=y" >> $config_host_mak
  6135. fi
  6136. if test "$splice" = "yes" ; then
  6137. echo "CONFIG_SPLICE=y" >> $config_host_mak
  6138. fi
  6139. if test "$eventfd" = "yes" ; then
  6140. echo "CONFIG_EVENTFD=y" >> $config_host_mak
  6141. fi
  6142. if test "$memfd" = "yes" ; then
  6143. echo "CONFIG_MEMFD=y" >> $config_host_mak
  6144. fi
  6145. if test "$have_usbfs" = "yes" ; then
  6146. echo "CONFIG_USBFS=y" >> $config_host_mak
  6147. fi
  6148. if test "$fallocate" = "yes" ; then
  6149. echo "CONFIG_FALLOCATE=y" >> $config_host_mak
  6150. fi
  6151. if test "$fallocate_punch_hole" = "yes" ; then
  6152. echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
  6153. fi
  6154. if test "$fallocate_zero_range" = "yes" ; then
  6155. echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
  6156. fi
  6157. if test "$posix_fallocate" = "yes" ; then
  6158. echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
  6159. fi
  6160. if test "$sync_file_range" = "yes" ; then
  6161. echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
  6162. fi
  6163. if test "$fiemap" = "yes" ; then
  6164. echo "CONFIG_FIEMAP=y" >> $config_host_mak
  6165. fi
  6166. if test "$dup3" = "yes" ; then
  6167. echo "CONFIG_DUP3=y" >> $config_host_mak
  6168. fi
  6169. if test "$ppoll" = "yes" ; then
  6170. echo "CONFIG_PPOLL=y" >> $config_host_mak
  6171. fi
  6172. if test "$prctl_pr_set_timerslack" = "yes" ; then
  6173. echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
  6174. fi
  6175. if test "$epoll" = "yes" ; then
  6176. echo "CONFIG_EPOLL=y" >> $config_host_mak
  6177. fi
  6178. if test "$epoll_create1" = "yes" ; then
  6179. echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
  6180. fi
  6181. if test "$sendfile" = "yes" ; then
  6182. echo "CONFIG_SENDFILE=y" >> $config_host_mak
  6183. fi
  6184. if test "$timerfd" = "yes" ; then
  6185. echo "CONFIG_TIMERFD=y" >> $config_host_mak
  6186. fi
  6187. if test "$setns" = "yes" ; then
  6188. echo "CONFIG_SETNS=y" >> $config_host_mak
  6189. fi
  6190. if test "$clock_adjtime" = "yes" ; then
  6191. echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
  6192. fi
  6193. if test "$syncfs" = "yes" ; then
  6194. echo "CONFIG_SYNCFS=y" >> $config_host_mak
  6195. fi
  6196. if test "$inotify" = "yes" ; then
  6197. echo "CONFIG_INOTIFY=y" >> $config_host_mak
  6198. fi
  6199. if test "$inotify1" = "yes" ; then
  6200. echo "CONFIG_INOTIFY1=y" >> $config_host_mak
  6201. fi
  6202. if test "$sem_timedwait" = "yes" ; then
  6203. echo "CONFIG_SEM_TIMEDWAIT=y" >> $config_host_mak
  6204. fi
  6205. if test "$strchrnul" = "yes" ; then
  6206. echo "HAVE_STRCHRNUL=y" >> $config_host_mak
  6207. fi
  6208. if test "$byteswap_h" = "yes" ; then
  6209. echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
  6210. fi
  6211. if test "$bswap_h" = "yes" ; then
  6212. echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
  6213. fi
  6214. if test "$curl" = "yes" ; then
  6215. echo "CONFIG_CURL=m" >> $config_host_mak
  6216. echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
  6217. echo "CURL_LIBS=$curl_libs" >> $config_host_mak
  6218. fi
  6219. if test "$brlapi" = "yes" ; then
  6220. echo "CONFIG_BRLAPI=y" >> $config_host_mak
  6221. echo "BRLAPI_LIBS=$brlapi_libs" >> $config_host_mak
  6222. fi
  6223. if test "$bluez" = "yes" ; then
  6224. echo "CONFIG_BLUEZ=y" >> $config_host_mak
  6225. echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
  6226. fi
  6227. if test "$gtk" = "yes" ; then
  6228. echo "CONFIG_GTK=m" >> $config_host_mak
  6229. echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
  6230. echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
  6231. if test "$gtk_gl" = "yes" ; then
  6232. echo "CONFIG_GTK_GL=y" >> $config_host_mak
  6233. fi
  6234. fi
  6235. if test "$gio" = "yes" ; then
  6236. echo "CONFIG_GIO=y" >> $config_host_mak
  6237. echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak
  6238. echo "GIO_LIBS=$gio_libs" >> $config_host_mak
  6239. fi
  6240. echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
  6241. if test "$gnutls" = "yes" ; then
  6242. echo "CONFIG_GNUTLS=y" >> $config_host_mak
  6243. fi
  6244. if test "$gcrypt" = "yes" ; then
  6245. echo "CONFIG_GCRYPT=y" >> $config_host_mak
  6246. if test "$gcrypt_hmac" = "yes" ; then
  6247. echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
  6248. fi
  6249. fi
  6250. if test "$nettle" = "yes" ; then
  6251. echo "CONFIG_NETTLE=y" >> $config_host_mak
  6252. echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
  6253. fi
  6254. if test "$tasn1" = "yes" ; then
  6255. echo "CONFIG_TASN1=y" >> $config_host_mak
  6256. fi
  6257. if test "$auth_pam" = "yes" ; then
  6258. echo "CONFIG_AUTH_PAM=y" >> $config_host_mak
  6259. fi
  6260. if test "$have_ifaddrs_h" = "yes" ; then
  6261. echo "HAVE_IFADDRS_H=y" >> $config_host_mak
  6262. fi
  6263. if test "$have_broken_size_max" = "yes" ; then
  6264. echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
  6265. fi
  6266. # Work around a system header bug with some kernel/XFS header
  6267. # versions where they both try to define 'struct fsxattr':
  6268. # xfs headers will not try to redefine structs from linux headers
  6269. # if this macro is set.
  6270. if test "$have_fsxattr" = "yes" ; then
  6271. echo "HAVE_FSXATTR=y" >> $config_host_mak
  6272. fi
  6273. if test "$have_copy_file_range" = "yes" ; then
  6274. echo "HAVE_COPY_FILE_RANGE=y" >> $config_host_mak
  6275. fi
  6276. if test "$vte" = "yes" ; then
  6277. echo "CONFIG_VTE=y" >> $config_host_mak
  6278. echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
  6279. echo "VTE_LIBS=$vte_libs" >> $config_host_mak
  6280. fi
  6281. if test "$virglrenderer" = "yes" ; then
  6282. echo "CONFIG_VIRGL=y" >> $config_host_mak
  6283. echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
  6284. echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
  6285. fi
  6286. if test "$xen" = "yes" ; then
  6287. echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
  6288. echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
  6289. fi
  6290. if test "$linux_aio" = "yes" ; then
  6291. echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
  6292. fi
  6293. if test "$attr" = "yes" ; then
  6294. echo "CONFIG_ATTR=y" >> $config_host_mak
  6295. fi
  6296. if test "$libattr" = "yes" ; then
  6297. echo "CONFIG_LIBATTR=y" >> $config_host_mak
  6298. fi
  6299. if test "$virtfs" = "yes" ; then
  6300. echo "CONFIG_VIRTFS=y" >> $config_host_mak
  6301. fi
  6302. if test "$mpath" = "yes" ; then
  6303. echo "CONFIG_MPATH=y" >> $config_host_mak
  6304. if test "$mpathpersist_new_api" = "yes"; then
  6305. echo "CONFIG_MPATH_NEW_API=y" >> $config_host_mak
  6306. fi
  6307. fi
  6308. if test "$vhost_scsi" = "yes" ; then
  6309. echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
  6310. fi
  6311. if test "$vhost_net" = "yes" ; then
  6312. echo "CONFIG_VHOST_NET=y" >> $config_host_mak
  6313. fi
  6314. if test "$vhost_net_user" = "yes" ; then
  6315. echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak
  6316. fi
  6317. if test "$vhost_crypto" = "yes" ; then
  6318. echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
  6319. fi
  6320. if test "$vhost_vsock" = "yes" ; then
  6321. echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
  6322. fi
  6323. if test "$vhost_kernel" = "yes" ; then
  6324. echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak
  6325. fi
  6326. if test "$vhost_user" = "yes" ; then
  6327. echo "CONFIG_VHOST_USER=y" >> $config_host_mak
  6328. fi
  6329. if test "$blobs" = "yes" ; then
  6330. echo "INSTALL_BLOBS=yes" >> $config_host_mak
  6331. fi
  6332. if test "$iovec" = "yes" ; then
  6333. echo "CONFIG_IOVEC=y" >> $config_host_mak
  6334. fi
  6335. if test "$preadv" = "yes" ; then
  6336. echo "CONFIG_PREADV=y" >> $config_host_mak
  6337. fi
  6338. if test "$fdt" != "no" ; then
  6339. echo "CONFIG_FDT=y" >> $config_host_mak
  6340. fi
  6341. if test "$membarrier" = "yes" ; then
  6342. echo "CONFIG_MEMBARRIER=y" >> $config_host_mak
  6343. fi
  6344. if test "$signalfd" = "yes" ; then
  6345. echo "CONFIG_SIGNALFD=y" >> $config_host_mak
  6346. fi
  6347. if test "$optreset" = "yes" ; then
  6348. echo "HAVE_OPTRESET=y" >> $config_host_mak
  6349. fi
  6350. if test "$tcg" = "yes"; then
  6351. echo "CONFIG_TCG=y" >> $config_host_mak
  6352. if test "$tcg_interpreter" = "yes" ; then
  6353. echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
  6354. fi
  6355. fi
  6356. if test "$fdatasync" = "yes" ; then
  6357. echo "CONFIG_FDATASYNC=y" >> $config_host_mak
  6358. fi
  6359. if test "$madvise" = "yes" ; then
  6360. echo "CONFIG_MADVISE=y" >> $config_host_mak
  6361. fi
  6362. if test "$posix_madvise" = "yes" ; then
  6363. echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
  6364. fi
  6365. if test "$posix_memalign" = "yes" ; then
  6366. echo "CONFIG_POSIX_MEMALIGN=y" >> $config_host_mak
  6367. fi
  6368. if test "$spice" = "yes" ; then
  6369. echo "CONFIG_SPICE=y" >> $config_host_mak
  6370. fi
  6371. if test "$smartcard" = "yes" ; then
  6372. echo "CONFIG_SMARTCARD=y" >> $config_host_mak
  6373. echo "SMARTCARD_CFLAGS=$libcacard_cflags" >> $config_host_mak
  6374. echo "SMARTCARD_LIBS=$libcacard_libs" >> $config_host_mak
  6375. fi
  6376. if test "$libusb" = "yes" ; then
  6377. echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
  6378. echo "LIBUSB_CFLAGS=$libusb_cflags" >> $config_host_mak
  6379. echo "LIBUSB_LIBS=$libusb_libs" >> $config_host_mak
  6380. fi
  6381. if test "$usb_redir" = "yes" ; then
  6382. echo "CONFIG_USB_REDIR=y" >> $config_host_mak
  6383. echo "USB_REDIR_CFLAGS=$usb_redir_cflags" >> $config_host_mak
  6384. echo "USB_REDIR_LIBS=$usb_redir_libs" >> $config_host_mak
  6385. fi
  6386. if test "$opengl" = "yes" ; then
  6387. echo "CONFIG_OPENGL=y" >> $config_host_mak
  6388. echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
  6389. if test "$opengl_dmabuf" = "yes" ; then
  6390. echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
  6391. fi
  6392. fi
  6393. if test "$malloc_trim" = "yes" ; then
  6394. echo "CONFIG_MALLOC_TRIM=y" >> $config_host_mak
  6395. fi
  6396. if test "$avx2_opt" = "yes" ; then
  6397. echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
  6398. fi
  6399. if test "$lzo" = "yes" ; then
  6400. echo "CONFIG_LZO=y" >> $config_host_mak
  6401. fi
  6402. if test "$snappy" = "yes" ; then
  6403. echo "CONFIG_SNAPPY=y" >> $config_host_mak
  6404. fi
  6405. if test "$bzip2" = "yes" ; then
  6406. echo "CONFIG_BZIP2=y" >> $config_host_mak
  6407. echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
  6408. fi
  6409. if test "$lzfse" = "yes" ; then
  6410. echo "CONFIG_LZFSE=y" >> $config_host_mak
  6411. echo "LZFSE_LIBS=-llzfse" >> $config_host_mak
  6412. fi
  6413. if test "$libiscsi" = "yes" ; then
  6414. echo "CONFIG_LIBISCSI=m" >> $config_host_mak
  6415. echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
  6416. echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
  6417. fi
  6418. if test "$libnfs" = "yes" ; then
  6419. echo "CONFIG_LIBNFS=m" >> $config_host_mak
  6420. echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
  6421. fi
  6422. if test "$seccomp" = "yes"; then
  6423. echo "CONFIG_SECCOMP=y" >> $config_host_mak
  6424. echo "SECCOMP_CFLAGS=$seccomp_cflags" >> $config_host_mak
  6425. echo "SECCOMP_LIBS=$seccomp_libs" >> $config_host_mak
  6426. fi
  6427. # XXX: suppress that
  6428. if [ "$bsd" = "yes" ] ; then
  6429. echo "CONFIG_BSD=y" >> $config_host_mak
  6430. fi
  6431. if test "$localtime_r" = "yes" ; then
  6432. echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
  6433. fi
  6434. if test "$qom_cast_debug" = "yes" ; then
  6435. echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
  6436. fi
  6437. if test "$rbd" = "yes" ; then
  6438. echo "CONFIG_RBD=m" >> $config_host_mak
  6439. echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
  6440. echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
  6441. fi
  6442. echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
  6443. if test "$coroutine_pool" = "yes" ; then
  6444. echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
  6445. else
  6446. echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
  6447. fi
  6448. if test "$debug_stack_usage" = "yes" ; then
  6449. echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
  6450. fi
  6451. if test "$crypto_afalg" = "yes" ; then
  6452. echo "CONFIG_AF_ALG=y" >> $config_host_mak
  6453. fi
  6454. if test "$open_by_handle_at" = "yes" ; then
  6455. echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
  6456. fi
  6457. if test "$linux_magic_h" = "yes" ; then
  6458. echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
  6459. fi
  6460. if test "$pragma_diagnostic_available" = "yes" ; then
  6461. echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
  6462. fi
  6463. if test "$valgrind_h" = "yes" ; then
  6464. echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
  6465. fi
  6466. if test "$have_asan_iface_fiber" = "yes" ; then
  6467. echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
  6468. fi
  6469. if test "$has_environ" = "yes" ; then
  6470. echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
  6471. fi
  6472. if test "$cpuid_h" = "yes" ; then
  6473. echo "CONFIG_CPUID_H=y" >> $config_host_mak
  6474. fi
  6475. if test "$int128" = "yes" ; then
  6476. echo "CONFIG_INT128=y" >> $config_host_mak
  6477. fi
  6478. if test "$atomic128" = "yes" ; then
  6479. echo "CONFIG_ATOMIC128=y" >> $config_host_mak
  6480. fi
  6481. if test "$cmpxchg128" = "yes" ; then
  6482. echo "CONFIG_CMPXCHG128=y" >> $config_host_mak
  6483. fi
  6484. if test "$atomic64" = "yes" ; then
  6485. echo "CONFIG_ATOMIC64=y" >> $config_host_mak
  6486. fi
  6487. if test "$vector16" = "yes" ; then
  6488. echo "CONFIG_VECTOR16=y" >> $config_host_mak
  6489. fi
  6490. if test "$getauxval" = "yes" ; then
  6491. echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
  6492. fi
  6493. if test "$glusterfs" = "yes" ; then
  6494. echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
  6495. echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
  6496. echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
  6497. fi
  6498. if test "$glusterfs_xlator_opt" = "yes" ; then
  6499. echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
  6500. fi
  6501. if test "$glusterfs_discard" = "yes" ; then
  6502. echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
  6503. fi
  6504. if test "$glusterfs_fallocate" = "yes" ; then
  6505. echo "CONFIG_GLUSTERFS_FALLOCATE=y" >> $config_host_mak
  6506. fi
  6507. if test "$glusterfs_zerofill" = "yes" ; then
  6508. echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
  6509. fi
  6510. if test "$glusterfs_ftruncate_has_stat" = "yes" ; then
  6511. echo "CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT=y" >> $config_host_mak
  6512. fi
  6513. if test "$glusterfs_iocb_has_stat" = "yes" ; then
  6514. echo "CONFIG_GLUSTERFS_IOCB_HAS_STAT=y" >> $config_host_mak
  6515. fi
  6516. if test "$libssh2" = "yes" ; then
  6517. echo "CONFIG_LIBSSH2=m" >> $config_host_mak
  6518. echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
  6519. echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak
  6520. fi
  6521. if test "$live_block_migration" = "yes" ; then
  6522. echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
  6523. fi
  6524. if test "$tpm" = "yes"; then
  6525. echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak
  6526. # TPM passthrough support?
  6527. if test "$tpm_passthrough" = "yes"; then
  6528. echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
  6529. fi
  6530. # TPM emulator support?
  6531. if test "$tpm_emulator" = "yes"; then
  6532. echo "CONFIG_TPM_EMULATOR=y" >> $config_host_mak
  6533. fi
  6534. fi
  6535. echo "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
  6536. if have_backend "nop"; then
  6537. echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
  6538. fi
  6539. if have_backend "simple"; then
  6540. echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
  6541. # Set the appropriate trace file.
  6542. trace_file="\"$trace_file-\" FMT_pid"
  6543. fi
  6544. if have_backend "log"; then
  6545. echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
  6546. fi
  6547. if have_backend "ust"; then
  6548. echo "CONFIG_TRACE_UST=y" >> $config_host_mak
  6549. fi
  6550. if have_backend "dtrace"; then
  6551. echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
  6552. if test "$trace_backend_stap" = "yes" ; then
  6553. echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
  6554. fi
  6555. fi
  6556. if have_backend "ftrace"; then
  6557. if test "$linux" = "yes" ; then
  6558. echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
  6559. else
  6560. feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
  6561. fi
  6562. fi
  6563. if have_backend "syslog"; then
  6564. if test "$posix_syslog" = "yes" ; then
  6565. echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
  6566. else
  6567. feature_not_found "syslog(trace backend)" "syslog not available"
  6568. fi
  6569. fi
  6570. echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
  6571. if test "$rdma" = "yes" ; then
  6572. echo "CONFIG_RDMA=y" >> $config_host_mak
  6573. echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
  6574. fi
  6575. if test "$pvrdma" = "yes" ; then
  6576. echo "CONFIG_PVRDMA=y" >> $config_host_mak
  6577. fi
  6578. if test "$have_rtnetlink" = "yes" ; then
  6579. echo "CONFIG_RTNETLINK=y" >> $config_host_mak
  6580. fi
  6581. if test "$libxml2" = "yes" ; then
  6582. echo "CONFIG_LIBXML2=y" >> $config_host_mak
  6583. echo "LIBXML2_CFLAGS=$libxml2_cflags" >> $config_host_mak
  6584. echo "LIBXML2_LIBS=$libxml2_libs" >> $config_host_mak
  6585. fi
  6586. if test "$replication" = "yes" ; then
  6587. echo "CONFIG_REPLICATION=y" >> $config_host_mak
  6588. fi
  6589. if test "$have_af_vsock" = "yes" ; then
  6590. echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
  6591. fi
  6592. if test "$have_sysmacros" = "yes" ; then
  6593. echo "CONFIG_SYSMACROS=y" >> $config_host_mak
  6594. fi
  6595. if test "$have_static_assert" = "yes" ; then
  6596. echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
  6597. fi
  6598. if test "$have_utmpx" = "yes" ; then
  6599. echo "HAVE_UTMPX=y" >> $config_host_mak
  6600. fi
  6601. if test "$ivshmem" = "yes" ; then
  6602. echo "CONFIG_IVSHMEM=y" >> $config_host_mak
  6603. fi
  6604. if test "$capstone" != "no" ; then
  6605. echo "CONFIG_CAPSTONE=y" >> $config_host_mak
  6606. fi
  6607. if test "$debug_mutex" = "yes" ; then
  6608. echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak
  6609. fi
  6610. # Hold two types of flag:
  6611. # CONFIG_THREAD_SETNAME_BYTHREAD - we've got a way of setting the name on
  6612. # a thread we have a handle to
  6613. # CONFIG_PTHREAD_SETNAME_NP_W_TID - A way of doing it on a particular
  6614. # platform
  6615. if test "$pthread_setname_np_w_tid" = "yes" ; then
  6616. echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
  6617. echo "CONFIG_PTHREAD_SETNAME_NP_W_TID=y" >> $config_host_mak
  6618. elif test "$pthread_setname_np_wo_tid" = "yes" ; then
  6619. echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
  6620. echo "CONFIG_PTHREAD_SETNAME_NP_WO_TID=y" >> $config_host_mak
  6621. fi
  6622. if test "$vxhs" = "yes" ; then
  6623. echo "CONFIG_VXHS=y" >> $config_host_mak
  6624. echo "VXHS_LIBS=$vxhs_libs" >> $config_host_mak
  6625. fi
  6626. if test "$libpmem" = "yes" ; then
  6627. echo "CONFIG_LIBPMEM=y" >> $config_host_mak
  6628. fi
  6629. if test "$bochs" = "yes" ; then
  6630. echo "CONFIG_BOCHS=y" >> $config_host_mak
  6631. fi
  6632. if test "$cloop" = "yes" ; then
  6633. echo "CONFIG_CLOOP=y" >> $config_host_mak
  6634. fi
  6635. if test "$dmg" = "yes" ; then
  6636. echo "CONFIG_DMG=y" >> $config_host_mak
  6637. fi
  6638. if test "$qcow1" = "yes" ; then
  6639. echo "CONFIG_QCOW1=y" >> $config_host_mak
  6640. fi
  6641. if test "$vdi" = "yes" ; then
  6642. echo "CONFIG_VDI=y" >> $config_host_mak
  6643. fi
  6644. if test "$vvfat" = "yes" ; then
  6645. echo "CONFIG_VVFAT=y" >> $config_host_mak
  6646. fi
  6647. if test "$qed" = "yes" ; then
  6648. echo "CONFIG_QED=y" >> $config_host_mak
  6649. fi
  6650. if test "$parallels" = "yes" ; then
  6651. echo "CONFIG_PARALLELS=y" >> $config_host_mak
  6652. fi
  6653. if test "$sheepdog" = "yes" ; then
  6654. echo "CONFIG_SHEEPDOG=y" >> $config_host_mak
  6655. fi
  6656. if test "$tcg_interpreter" = "yes"; then
  6657. QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
  6658. elif test "$ARCH" = "sparc64" ; then
  6659. QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
  6660. elif test "$ARCH" = "s390x" ; then
  6661. QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
  6662. elif test "$ARCH" = "x86_64" || test "$ARCH" = "x32" ; then
  6663. QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
  6664. elif test "$ARCH" = "ppc64" ; then
  6665. QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/ppc $QEMU_INCLUDES"
  6666. elif test "$ARCH" = "riscv32" || test "$ARCH" = "riscv64" ; then
  6667. QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/riscv $QEMU_INCLUDES"
  6668. else
  6669. QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
  6670. fi
  6671. QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg $QEMU_INCLUDES"
  6672. echo "TOOLS=$tools" >> $config_host_mak
  6673. echo "ROMS=$roms" >> $config_host_mak
  6674. echo "MAKE=$make" >> $config_host_mak
  6675. echo "INSTALL=$install" >> $config_host_mak
  6676. echo "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
  6677. echo "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
  6678. echo "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
  6679. echo "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
  6680. echo "PYTHON=$python" >> $config_host_mak
  6681. echo "PYTHON_VERSION=$python_version" >> $config_host_mak
  6682. echo "CC=$cc" >> $config_host_mak
  6683. if $iasl -h > /dev/null 2>&1; then
  6684. echo "IASL=$iasl" >> $config_host_mak
  6685. fi
  6686. echo "HOST_CC=$host_cc" >> $config_host_mak
  6687. echo "CXX=$cxx" >> $config_host_mak
  6688. echo "OBJCC=$objcc" >> $config_host_mak
  6689. echo "AR=$ar" >> $config_host_mak
  6690. echo "ARFLAGS=$ARFLAGS" >> $config_host_mak
  6691. echo "AS=$as" >> $config_host_mak
  6692. echo "CCAS=$ccas" >> $config_host_mak
  6693. echo "CPP=$cpp" >> $config_host_mak
  6694. echo "OBJCOPY=$objcopy" >> $config_host_mak
  6695. echo "LD=$ld" >> $config_host_mak
  6696. echo "RANLIB=$ranlib" >> $config_host_mak
  6697. echo "NM=$nm" >> $config_host_mak
  6698. echo "WINDRES=$windres" >> $config_host_mak
  6699. echo "CFLAGS=$CFLAGS" >> $config_host_mak
  6700. echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
  6701. echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
  6702. echo "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
  6703. echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
  6704. if test "$sparse" = "yes" ; then
  6705. echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_host_mak
  6706. echo "CPP := REAL_CC=\"\$(CPP)\" cgcc" >> $config_host_mak
  6707. echo "CXX := REAL_CC=\"\$(CXX)\" cgcc" >> $config_host_mak
  6708. echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_host_mak
  6709. echo "QEMU_CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
  6710. fi
  6711. if test "$cross_prefix" != ""; then
  6712. echo "AUTOCONF_HOST := --host=${cross_prefix%-}" >> $config_host_mak
  6713. else
  6714. echo "AUTOCONF_HOST := " >> $config_host_mak
  6715. fi
  6716. echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
  6717. echo "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
  6718. echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
  6719. echo "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
  6720. echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
  6721. echo "LIBS+=$LIBS" >> $config_host_mak
  6722. echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
  6723. echo "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
  6724. echo "EXESUF=$EXESUF" >> $config_host_mak
  6725. echo "DSOSUF=$DSOSUF" >> $config_host_mak
  6726. echo "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
  6727. echo "LIBS_QGA+=$libs_qga" >> $config_host_mak
  6728. echo "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
  6729. echo "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
  6730. echo "POD2MAN=$POD2MAN" >> $config_host_mak
  6731. if test "$gcov" = "yes" ; then
  6732. echo "CONFIG_GCOV=y" >> $config_host_mak
  6733. echo "GCOV=$gcov_tool" >> $config_host_mak
  6734. fi
  6735. if test "$docker" != "no"; then
  6736. echo "HAVE_USER_DOCKER=y" >> $config_host_mak
  6737. fi
  6738. if test "$libudev" != "no"; then
  6739. echo "CONFIG_LIBUDEV=y" >> $config_host_mak
  6740. echo "LIBUDEV_LIBS=$libudev_libs" >> $config_host_mak
  6741. fi
  6742. # use included Linux headers
  6743. if test "$linux" = "yes" ; then
  6744. mkdir -p linux-headers
  6745. case "$cpu" in
  6746. i386|x86_64|x32)
  6747. linux_arch=x86
  6748. ;;
  6749. ppc|ppc64)
  6750. linux_arch=powerpc
  6751. ;;
  6752. s390x)
  6753. linux_arch=s390
  6754. ;;
  6755. aarch64)
  6756. linux_arch=arm64
  6757. ;;
  6758. mips64)
  6759. linux_arch=mips
  6760. ;;
  6761. *)
  6762. # For most CPUs the kernel architecture name and QEMU CPU name match.
  6763. linux_arch="$cpu"
  6764. ;;
  6765. esac
  6766. # For non-KVM architectures we will not have asm headers
  6767. if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
  6768. symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
  6769. fi
  6770. fi
  6771. for target in $target_list; do
  6772. target_dir="$target"
  6773. config_target_mak=$target_dir/config-target.mak
  6774. target_name=$(echo $target | cut -d '-' -f 1)
  6775. target_bigendian="no"
  6776. case "$target_name" in
  6777. armeb|aarch64_be|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
  6778. target_bigendian=yes
  6779. ;;
  6780. esac
  6781. target_softmmu="no"
  6782. target_user_only="no"
  6783. target_linux_user="no"
  6784. target_bsd_user="no"
  6785. case "$target" in
  6786. ${target_name}-softmmu)
  6787. target_softmmu="yes"
  6788. ;;
  6789. ${target_name}-linux-user)
  6790. target_user_only="yes"
  6791. target_linux_user="yes"
  6792. ;;
  6793. ${target_name}-bsd-user)
  6794. target_user_only="yes"
  6795. target_bsd_user="yes"
  6796. ;;
  6797. *)
  6798. error_exit "Target '$target' not recognised"
  6799. exit 1
  6800. ;;
  6801. esac
  6802. target_compiler=""
  6803. target_compiler_static=""
  6804. target_compiler_cflags=""
  6805. mkdir -p $target_dir
  6806. echo "# Automatically generated by configure - do not modify" > $config_target_mak
  6807. bflt="no"
  6808. mttcg="no"
  6809. interp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
  6810. gdb_xml_files=""
  6811. TARGET_ARCH="$target_name"
  6812. TARGET_BASE_ARCH=""
  6813. TARGET_ABI_DIR=""
  6814. case "$target_name" in
  6815. i386)
  6816. mttcg="yes"
  6817. gdb_xml_files="i386-32bit.xml"
  6818. target_compiler=$cross_cc_i386
  6819. target_compiler_cflags=$cross_cc_ccflags_i386
  6820. ;;
  6821. x86_64)
  6822. TARGET_BASE_ARCH=i386
  6823. mttcg="yes"
  6824. gdb_xml_files="i386-64bit.xml"
  6825. target_compiler=$cross_cc_x86_64
  6826. ;;
  6827. alpha)
  6828. mttcg="yes"
  6829. target_compiler=$cross_cc_alpha
  6830. ;;
  6831. arm|armeb)
  6832. TARGET_ARCH=arm
  6833. bflt="yes"
  6834. mttcg="yes"
  6835. gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
  6836. target_compiler=$cross_cc_arm
  6837. eval "target_compiler_cflags=\$cross_cc_cflags_${target_name}"
  6838. ;;
  6839. aarch64|aarch64_be)
  6840. TARGET_ARCH=aarch64
  6841. TARGET_BASE_ARCH=arm
  6842. bflt="yes"
  6843. mttcg="yes"
  6844. gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
  6845. target_compiler=$cross_cc_aarch64
  6846. eval "target_compiler_cflags=\$cross_cc_cflags_${target_name}"
  6847. ;;
  6848. cris)
  6849. target_compiler=$cross_cc_cris
  6850. ;;
  6851. hppa)
  6852. mttcg="yes"
  6853. target_compiler=$cross_cc_hppa
  6854. ;;
  6855. lm32)
  6856. target_compiler=$cross_cc_lm32
  6857. ;;
  6858. m68k)
  6859. bflt="yes"
  6860. gdb_xml_files="cf-core.xml cf-fp.xml m68k-fp.xml"
  6861. target_compiler=$cross_cc_m68k
  6862. ;;
  6863. microblaze|microblazeel)
  6864. TARGET_ARCH=microblaze
  6865. bflt="yes"
  6866. echo "TARGET_ABI32=y" >> $config_target_mak
  6867. target_compiler=$cross_cc_microblaze
  6868. ;;
  6869. mips|mipsel)
  6870. mttcg="yes"
  6871. TARGET_ARCH=mips
  6872. target_compiler=$cross_cc_mips
  6873. echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
  6874. ;;
  6875. mipsn32|mipsn32el)
  6876. mttcg="yes"
  6877. TARGET_ARCH=mips64
  6878. TARGET_BASE_ARCH=mips
  6879. target_compiler=$cross_cc_mipsn32
  6880. echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
  6881. echo "TARGET_ABI32=y" >> $config_target_mak
  6882. ;;
  6883. mips64|mips64el)
  6884. mttcg="yes"
  6885. TARGET_ARCH=mips64
  6886. TARGET_BASE_ARCH=mips
  6887. target_compiler=$cross_cc_mips64
  6888. echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
  6889. ;;
  6890. moxie)
  6891. target_compiler=$cross_cc_moxie
  6892. ;;
  6893. nios2)
  6894. target_compiler=$cross_cc_nios2
  6895. ;;
  6896. or1k)
  6897. target_compiler=$cross_cc_or1k
  6898. TARGET_ARCH=openrisc
  6899. TARGET_BASE_ARCH=openrisc
  6900. ;;
  6901. ppc)
  6902. gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
  6903. target_compiler=$cross_cc_powerpc
  6904. ;;
  6905. ppc64)
  6906. TARGET_BASE_ARCH=ppc
  6907. TARGET_ABI_DIR=ppc
  6908. mttcg=yes
  6909. gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
  6910. target_compiler=$cross_cc_ppc64
  6911. ;;
  6912. ppc64le)
  6913. TARGET_ARCH=ppc64
  6914. TARGET_BASE_ARCH=ppc
  6915. TARGET_ABI_DIR=ppc
  6916. mttcg=yes
  6917. gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
  6918. target_compiler=$cross_cc_ppc64le
  6919. ;;
  6920. ppc64abi32)
  6921. TARGET_ARCH=ppc64
  6922. TARGET_BASE_ARCH=ppc
  6923. TARGET_ABI_DIR=ppc
  6924. echo "TARGET_ABI32=y" >> $config_target_mak
  6925. gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
  6926. target_compiler=$cross_cc_ppc64abi32
  6927. ;;
  6928. riscv32)
  6929. TARGET_BASE_ARCH=riscv
  6930. TARGET_ABI_DIR=riscv
  6931. mttcg=yes
  6932. gdb_xml_files="riscv-32bit-cpu.xml riscv-32bit-fpu.xml riscv-32bit-csr.xml"
  6933. target_compiler=$cross_cc_riscv32
  6934. ;;
  6935. riscv64)
  6936. TARGET_BASE_ARCH=riscv
  6937. TARGET_ABI_DIR=riscv
  6938. mttcg=yes
  6939. gdb_xml_files="riscv-64bit-cpu.xml riscv-64bit-fpu.xml riscv-64bit-csr.xml"
  6940. target_compiler=$cross_cc_riscv64
  6941. ;;
  6942. sh4|sh4eb)
  6943. TARGET_ARCH=sh4
  6944. bflt="yes"
  6945. target_compiler=$cross_cc_sh4
  6946. ;;
  6947. sparc)
  6948. target_compiler=$cross_cc_sparc
  6949. ;;
  6950. sparc64)
  6951. TARGET_BASE_ARCH=sparc
  6952. target_compiler=$cross_cc_sparc64
  6953. ;;
  6954. sparc32plus)
  6955. TARGET_ARCH=sparc64
  6956. TARGET_BASE_ARCH=sparc
  6957. TARGET_ABI_DIR=sparc
  6958. target_compiler=$cross_cc_sparc32plus
  6959. echo "TARGET_ABI32=y" >> $config_target_mak
  6960. ;;
  6961. s390x)
  6962. mttcg=yes
  6963. gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml s390-cr.xml s390-virt.xml s390-gs.xml"
  6964. target_compiler=$cross_cc_s390x
  6965. ;;
  6966. tilegx)
  6967. target_compiler=$cross_cc_tilegx
  6968. ;;
  6969. tricore)
  6970. target_compiler=$cross_cc_tricore
  6971. ;;
  6972. unicore32)
  6973. target_compiler=$cross_cc_unicore32
  6974. ;;
  6975. xtensa|xtensaeb)
  6976. TARGET_ARCH=xtensa
  6977. bflt="yes"
  6978. mttcg="yes"
  6979. target_compiler=$cross_cc_xtensa
  6980. ;;
  6981. *)
  6982. error_exit "Unsupported target CPU"
  6983. ;;
  6984. esac
  6985. # TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
  6986. if [ "$TARGET_BASE_ARCH" = "" ]; then
  6987. TARGET_BASE_ARCH=$TARGET_ARCH
  6988. fi
  6989. # Do we have a cross compiler for this target?
  6990. if has $target_compiler; then
  6991. write_c_skeleton
  6992. if ! do_compiler "$target_compiler" $target_compiler_cflags -o $TMPE $TMPC -static ; then
  6993. # For host systems we might get away with building without -static
  6994. if ! do_compiler "$target_compiler" $target_compiler_cflags -o $TMPE $TMPC ; then
  6995. target_compiler=""
  6996. else
  6997. enabled_cross_compilers="${enabled_cross_compilers} '${target_compiler}'"
  6998. target_compiler_static="n"
  6999. fi
  7000. else
  7001. enabled_cross_compilers="${enabled_cross_compilers} '${target_compiler}'"
  7002. target_compiler_static="y"
  7003. fi
  7004. else
  7005. target_compiler=""
  7006. fi
  7007. symlink "$source_path/Makefile.target" "$target_dir/Makefile"
  7008. upper() {
  7009. echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
  7010. }
  7011. target_arch_name="$(upper $TARGET_ARCH)"
  7012. echo "TARGET_$target_arch_name=y" >> $config_target_mak
  7013. echo "TARGET_NAME=$target_name" >> $config_target_mak
  7014. echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
  7015. if [ "$TARGET_ABI_DIR" = "" ]; then
  7016. TARGET_ABI_DIR=$TARGET_ARCH
  7017. fi
  7018. echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
  7019. if [ "$HOST_VARIANT_DIR" != "" ]; then
  7020. echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
  7021. fi
  7022. if supported_xen_target $target; then
  7023. echo "CONFIG_XEN=y" >> $config_target_mak
  7024. echo "$target/config-devices.mak: CONFIG_XEN=y" >> $config_host_mak
  7025. if test "$xen_pci_passthrough" = yes; then
  7026. echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
  7027. fi
  7028. else
  7029. echo "$target/config-devices.mak: CONFIG_XEN=n" >> $config_host_mak
  7030. fi
  7031. if supported_kvm_target $target; then
  7032. echo "CONFIG_KVM=y" >> $config_target_mak
  7033. echo "$target/config-devices.mak: CONFIG_KVM=y" >> $config_host_mak
  7034. else
  7035. echo "$target/config-devices.mak: CONFIG_KVM=n" >> $config_host_mak
  7036. fi
  7037. if supported_hax_target $target; then
  7038. echo "CONFIG_HAX=y" >> $config_target_mak
  7039. fi
  7040. if supported_hvf_target $target; then
  7041. echo "CONFIG_HVF=y" >> $config_target_mak
  7042. fi
  7043. if supported_whpx_target $target; then
  7044. echo "CONFIG_WHPX=y" >> $config_target_mak
  7045. fi
  7046. if test "$target_bigendian" = "yes" ; then
  7047. echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
  7048. fi
  7049. if test "$target_softmmu" = "yes" ; then
  7050. echo "CONFIG_SOFTMMU=y" >> $config_target_mak
  7051. if test "$mttcg" = "yes" ; then
  7052. echo "TARGET_SUPPORTS_MTTCG=y" >> $config_target_mak
  7053. fi
  7054. fi
  7055. if test "$target_user_only" = "yes" ; then
  7056. echo "CONFIG_USER_ONLY=y" >> $config_target_mak
  7057. echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
  7058. fi
  7059. if test "$target_linux_user" = "yes" ; then
  7060. echo "CONFIG_LINUX_USER=y" >> $config_target_mak
  7061. fi
  7062. list=""
  7063. if test ! -z "$gdb_xml_files" ; then
  7064. for x in $gdb_xml_files; do
  7065. list="$list $source_path/gdb-xml/$x"
  7066. done
  7067. echo "TARGET_XML_FILES=$list" >> $config_target_mak
  7068. fi
  7069. if test "$target_user_only" = "yes" && test "$bflt" = "yes"; then
  7070. echo "TARGET_HAS_BFLT=y" >> $config_target_mak
  7071. fi
  7072. if test "$target_bsd_user" = "yes" ; then
  7073. echo "CONFIG_BSD_USER=y" >> $config_target_mak
  7074. fi
  7075. if test -n "$target_compiler"; then
  7076. echo "CROSS_CC_GUEST=\"$target_compiler\"" >> $config_target_mak
  7077. if test -n "$target_compiler_static"; then
  7078. echo "CROSS_CC_GUEST_STATIC=$target_compiler_static" >> $config_target_mak
  7079. fi
  7080. if test -n "$target_compiler_cflags"; then
  7081. echo "CROSS_CC_GUEST_CFLAGS=$target_compiler_cflags" >> $config_target_mak
  7082. fi
  7083. fi
  7084. # generate QEMU_CFLAGS/LDFLAGS for targets
  7085. cflags=""
  7086. ldflags=""
  7087. disas_config() {
  7088. echo "CONFIG_${1}_DIS=y" >> $config_target_mak
  7089. echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
  7090. }
  7091. for i in $ARCH $TARGET_BASE_ARCH ; do
  7092. case "$i" in
  7093. alpha)
  7094. disas_config "ALPHA"
  7095. ;;
  7096. aarch64)
  7097. if test -n "${cxx}"; then
  7098. disas_config "ARM_A64"
  7099. fi
  7100. ;;
  7101. arm)
  7102. disas_config "ARM"
  7103. if test -n "${cxx}"; then
  7104. disas_config "ARM_A64"
  7105. fi
  7106. ;;
  7107. cris)
  7108. disas_config "CRIS"
  7109. ;;
  7110. hppa)
  7111. disas_config "HPPA"
  7112. ;;
  7113. i386|x86_64|x32)
  7114. disas_config "I386"
  7115. ;;
  7116. lm32)
  7117. disas_config "LM32"
  7118. ;;
  7119. m68k)
  7120. disas_config "M68K"
  7121. ;;
  7122. microblaze*)
  7123. disas_config "MICROBLAZE"
  7124. ;;
  7125. mips*)
  7126. disas_config "MIPS"
  7127. if test -n "${cxx}"; then
  7128. disas_config "NANOMIPS"
  7129. fi
  7130. ;;
  7131. moxie*)
  7132. disas_config "MOXIE"
  7133. ;;
  7134. nios2)
  7135. disas_config "NIOS2"
  7136. ;;
  7137. or1k)
  7138. disas_config "OPENRISC"
  7139. ;;
  7140. ppc*)
  7141. disas_config "PPC"
  7142. ;;
  7143. riscv*)
  7144. disas_config "RISCV"
  7145. ;;
  7146. s390*)
  7147. disas_config "S390"
  7148. ;;
  7149. sh4)
  7150. disas_config "SH4"
  7151. ;;
  7152. sparc*)
  7153. disas_config "SPARC"
  7154. ;;
  7155. xtensa*)
  7156. disas_config "XTENSA"
  7157. ;;
  7158. esac
  7159. done
  7160. if test "$tcg_interpreter" = "yes" ; then
  7161. disas_config "TCI"
  7162. fi
  7163. case "$ARCH" in
  7164. alpha)
  7165. # Ensure there's only a single GP
  7166. cflags="-msmall-data $cflags"
  7167. ;;
  7168. esac
  7169. if test "$gprof" = "yes" ; then
  7170. echo "TARGET_GPROF=y" >> $config_target_mak
  7171. if test "$target_linux_user" = "yes" ; then
  7172. cflags="-p $cflags"
  7173. ldflags="-p $ldflags"
  7174. fi
  7175. if test "$target_softmmu" = "yes" ; then
  7176. ldflags="-p $ldflags"
  7177. echo "GPROF_CFLAGS=-p" >> $config_target_mak
  7178. fi
  7179. fi
  7180. if test "$target_linux_user" = "yes" || test "$target_bsd_user" = "yes" ; then
  7181. ldflags="$ldflags $textseg_ldflags"
  7182. fi
  7183. # Newer kernels on s390 check for an S390_PGSTE program header and
  7184. # enable the pgste page table extensions in that case. This makes
  7185. # the vm.allocate_pgste sysctl unnecessary. We enable this program
  7186. # header if
  7187. # - we build on s390x
  7188. # - we build the system emulation for s390x (qemu-system-s390x)
  7189. # - KVM is enabled
  7190. # - the linker supports --s390-pgste
  7191. if test "$TARGET_ARCH" = "s390x" && test "$target_softmmu" = "yes" && \
  7192. test "$ARCH" = "s390x" && test "$kvm" = "yes"; then
  7193. if ld_has --s390-pgste ; then
  7194. ldflags="-Wl,--s390-pgste $ldflags"
  7195. fi
  7196. fi
  7197. echo "LDFLAGS+=$ldflags" >> $config_target_mak
  7198. echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak
  7199. done # for target in $targets
  7200. if test -n "$enabled_cross_compilers"; then
  7201. echo
  7202. echo "NOTE: cross-compilers enabled: $enabled_cross_compilers"
  7203. fi
  7204. if [ "$fdt" = "git" ]; then
  7205. echo "config-host.h: subdir-dtc" >> $config_host_mak
  7206. fi
  7207. if [ "$capstone" = "git" -o "$capstone" = "internal" ]; then
  7208. echo "config-host.h: subdir-capstone" >> $config_host_mak
  7209. fi
  7210. if test -n "$LIBCAPSTONE"; then
  7211. echo "LIBCAPSTONE=$LIBCAPSTONE" >> $config_host_mak
  7212. fi
  7213. if test "$numa" = "yes"; then
  7214. echo "CONFIG_NUMA=y" >> $config_host_mak
  7215. fi
  7216. if test "$ccache_cpp2" = "yes"; then
  7217. echo "export CCACHE_CPP2=y" >> $config_host_mak
  7218. fi
  7219. # If we're using a separate build tree, set it up now.
  7220. # DIRS are directories which we simply mkdir in the build tree;
  7221. # LINKS are things to symlink back into the source tree
  7222. # (these can be both files and directories).
  7223. # Caution: do not add files or directories here using wildcards. This
  7224. # will result in problems later if a new file matching the wildcard is
  7225. # added to the source tree -- nothing will cause configure to be rerun
  7226. # so the build tree will be missing the link back to the new file, and
  7227. # tests might fail. Prefer to keep the relevant files in their own
  7228. # directory and symlink the directory instead.
  7229. DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests tests/vm"
  7230. DIRS="$DIRS tests/fp tests/qgraph"
  7231. DIRS="$DIRS docs docs/interop fsdev scsi"
  7232. DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
  7233. DIRS="$DIRS roms/seabios roms/vgabios"
  7234. LINKS="Makefile tests/tcg/Makefile"
  7235. LINKS="$LINKS tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
  7236. LINKS="$LINKS tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
  7237. LINKS="$LINKS tests/fp/Makefile"
  7238. LINKS="$LINKS pc-bios/optionrom/Makefile pc-bios/keymaps"
  7239. LINKS="$LINKS pc-bios/spapr-rtas/Makefile"
  7240. LINKS="$LINKS pc-bios/s390-ccw/Makefile"
  7241. LINKS="$LINKS roms/seabios/Makefile roms/vgabios/Makefile"
  7242. LINKS="$LINKS pc-bios/qemu-icon.bmp"
  7243. LINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
  7244. LINKS="$LINKS tests/acceptance tests/data"
  7245. LINKS="$LINKS tests/qemu-iotests/check"
  7246. LINKS="$LINKS python"
  7247. for bios_file in \
  7248. $source_path/pc-bios/*.bin \
  7249. $source_path/pc-bios/*.lid \
  7250. $source_path/pc-bios/*.aml \
  7251. $source_path/pc-bios/*.rom \
  7252. $source_path/pc-bios/*.dtb \
  7253. $source_path/pc-bios/*.img \
  7254. $source_path/pc-bios/openbios-* \
  7255. $source_path/pc-bios/u-boot.* \
  7256. $source_path/pc-bios/edk2-*.fd.bz2 \
  7257. $source_path/pc-bios/palcode-*
  7258. do
  7259. LINKS="$LINKS pc-bios/$(basename $bios_file)"
  7260. done
  7261. mkdir -p $DIRS
  7262. for f in $LINKS ; do
  7263. if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
  7264. symlink "$source_path/$f" "$f"
  7265. fi
  7266. done
  7267. # temporary config to build submodules
  7268. for rom in seabios vgabios ; do
  7269. config_mak=roms/$rom/config.mak
  7270. echo "# Automatically generated by configure - do not modify" > $config_mak
  7271. echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
  7272. echo "AS=$as" >> $config_mak
  7273. echo "CCAS=$ccas" >> $config_mak
  7274. echo "CC=$cc" >> $config_mak
  7275. echo "BCC=bcc" >> $config_mak
  7276. echo "CPP=$cpp" >> $config_mak
  7277. echo "OBJCOPY=objcopy" >> $config_mak
  7278. echo "IASL=$iasl" >> $config_mak
  7279. echo "LD=$ld" >> $config_mak
  7280. echo "RANLIB=$ranlib" >> $config_mak
  7281. done
  7282. # set up qemu-iotests in this build directory
  7283. iotests_common_env="tests/qemu-iotests/common.env"
  7284. echo "# Automatically generated by configure - do not modify" > "$iotests_common_env"
  7285. echo >> "$iotests_common_env"
  7286. echo "export PYTHON='$python'" >> "$iotests_common_env"
  7287. # Save the configure command line for later reuse.
  7288. cat <<EOD >config.status
  7289. #!/bin/sh
  7290. # Generated by configure.
  7291. # Run this file to recreate the current configuration.
  7292. # Compiler output produced by configure, useful for debugging
  7293. # configure, is in config.log if it exists.
  7294. EOD
  7295. preserve_env() {
  7296. envname=$1
  7297. eval envval=\$$envname
  7298. if test -n "$envval"
  7299. then
  7300. echo "$envname='$envval'" >> config.status
  7301. echo "export $envname" >> config.status
  7302. else
  7303. echo "unset $envname" >> config.status
  7304. fi
  7305. }
  7306. # Preserve various env variables that influence what
  7307. # features/build target configure will detect
  7308. preserve_env AR
  7309. preserve_env AS
  7310. preserve_env CC
  7311. preserve_env CPP
  7312. preserve_env CXX
  7313. preserve_env INSTALL
  7314. preserve_env LD
  7315. preserve_env LD_LIBRARY_PATH
  7316. preserve_env LIBTOOL
  7317. preserve_env MAKE
  7318. preserve_env NM
  7319. preserve_env OBJCOPY
  7320. preserve_env PATH
  7321. preserve_env PKG_CONFIG
  7322. preserve_env PKG_CONFIG_LIBDIR
  7323. preserve_env PKG_CONFIG_PATH
  7324. preserve_env PYTHON
  7325. preserve_env SDL_CONFIG
  7326. preserve_env SDL2_CONFIG
  7327. preserve_env SMBD
  7328. preserve_env STRIP
  7329. preserve_env WINDRES
  7330. printf "exec" >>config.status
  7331. printf " '%s'" "$0" "$@" >>config.status
  7332. echo ' "$@"' >>config.status
  7333. chmod +x config.status
  7334. rm -r "$TMPDIR1"