config-daemon.ac 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. dnl -*- Autoconf -*- fragment for the C++ daemon.
  2. AC_MSG_CHECKING([whether to build daemon])
  3. AC_MSG_RESULT([$guix_build_daemon])
  4. dnl C++ environment. This macro must be used unconditionnaly.
  5. AC_PROG_CXX
  6. AM_PROG_AR
  7. AC_LANG([C++])
  8. if test "x$guix_build_daemon" = "xyes"; then
  9. GUIX_ASSERT_CXX11
  10. AC_PROG_RANLIB
  11. AC_CONFIG_HEADER([nix/config.h])
  12. dnl Use 64-bit file system calls so that we can support files > 2 GiB.
  13. AC_SYS_LARGEFILE
  14. dnl Look for libbz2, a required dependency.
  15. AC_CHECK_LIB([bz2], [BZ2_bzWriteOpen], [true],
  16. [AC_MSG_ERROR([Guix requires libbz2, which is part of bzip2. See http://www.bzip.org/.])])
  17. AC_CHECK_HEADERS([bzlib.h], [true],
  18. [AC_MSG_ERROR([Guix requires libbz2, which is part of bzip2. See http://www.bzip.org/.])])
  19. dnl Look for SQLite, a required dependency.
  20. PKG_CHECK_MODULES([SQLITE3], [sqlite3 >= 3.6.19])
  21. AC_DEFINE([NIX_VERSION], ["0.0.0"], [Fake Nix version number.])
  22. AC_DEFINE_UNQUOTED([SYSTEM], ["$guix_system"],
  23. [Guix host system type--i.e., platform and OS kernel tuple.])
  24. case "$LIBGCRYPT_PREFIX" in
  25. no)
  26. LIBGCRYPT_CFLAGS=""
  27. ;;
  28. *)
  29. LIBGCRYPT_CFLAGS="-I$LIBGCRYPT_PREFIX/include"
  30. ;;
  31. esac
  32. case "$LIBGCRYPT_LIBDIR" in
  33. no)
  34. LIBGCRYPT_LIBS="-lgcrypt"
  35. ;;
  36. *)
  37. LIBGCRYPT_LIBS="-L$LIBGCRYPT_LIBDIR -lgcrypt"
  38. ;;
  39. esac
  40. AC_SUBST([LIBGCRYPT_CFLAGS])
  41. AC_SUBST([LIBGCRYPT_LIBS])
  42. save_CFLAGS="$CFLAGS"
  43. save_LDFLAGS="$LDFLAGS"
  44. CFLAGS="$CFLAGS $LIBGCRYPT_CFLAGS"
  45. LDFLAGS="$LDFLAGS $LIBGCRYPT_LDFLAGS"
  46. have_gcrypt=yes
  47. AC_CHECK_LIB([gcrypt], [gcry_md_open], [:], [have_gcrypt=no])
  48. AC_CHECK_HEADER([gcrypt.h], [:], [have_gcrypt=no])
  49. if test "x$have_gcrypt" != "xyes"; then
  50. AC_MSG_ERROR([GNU libgcrypt not found; please install it.])
  51. fi
  52. CFLAGS="$save_CFLAGS"
  53. LDFLAGS="$save_LDFLAGS"
  54. dnl Chroot support.
  55. AC_CHECK_FUNCS([chroot unshare])
  56. AC_CHECK_HEADERS([sched.h sys/param.h sys/mount.h sys/syscall.h])
  57. if test "x$ac_cv_func_chroot" != "xyes"; then
  58. AC_MSG_ERROR(['chroot' function missing, bailing out])
  59. fi
  60. dnl lutimes and lchown: used when canonicalizing store items.
  61. dnl posix_fallocate: used when extracting archives.
  62. dnl vfork: to speed up spawning of helper programs.
  63. dnl `--> now disabled because of unpredictable behavior:
  64. dnl see <http://lists.gnu.org/archive/html/guix-devel/2014-05/msg00036.html>
  65. dnl and Nix commit f794465c (Nov. 2012).
  66. dnl sched_setaffinity: to improve RPC locality.
  67. dnl statvfs: to detect disk-full conditions.
  68. dnl strsignal: for error reporting.
  69. AC_CHECK_FUNCS([lutimes lchown posix_fallocate sched_setaffinity \
  70. statvfs nanosleep strsignal])
  71. dnl Check whether the store optimiser can optimise symlinks.
  72. AC_MSG_CHECKING([whether it is possible to create a link to a symlink])
  73. ln -s bla tmp_link
  74. if ln tmp_link tmp_link2 2> /dev/null; then
  75. AC_MSG_RESULT(yes)
  76. AC_DEFINE(CAN_LINK_SYMLINK, 1, [Whether link() works on symlinks.])
  77. else
  78. AC_MSG_RESULT(no)
  79. fi
  80. rm -f tmp_link tmp_link2
  81. dnl Check for <locale>.
  82. AC_LANG_PUSH(C++)
  83. AC_CHECK_HEADERS([locale])
  84. AC_LANG_POP(C++)
  85. dnl Check whether we have the `personality' syscall, which allows us
  86. dnl to do i686-linux builds on x86_64-linux machines.
  87. AC_CHECK_HEADERS([sys/personality.h])
  88. dnl Check for <linux/fs.h> (for immutable file support).
  89. AC_CHECK_HEADERS([linux/fs.h])
  90. dnl Determine the appropriate default list of substitute URLs.
  91. GUILE_MODULE_AVAILABLE([have_gnutls], [(gnutls)])
  92. if test "x$have_gnutls" = "xyes"; then
  93. guix_substitute_urls="https://mirror.hydra.gnu.org"
  94. else
  95. AC_MSG_WARN([GnuTLS is missing, substitutes will be downloaded in the clear])
  96. guix_substitute_urls="http://mirror.hydra.gnu.org"
  97. fi
  98. AC_MSG_CHECKING([for default substitute URLs])
  99. AC_MSG_RESULT([$guix_substitute_urls])
  100. AC_DEFINE_UNQUOTED([GUIX_SUBSTITUTE_URLS], ["$guix_substitute_urls"],
  101. [Default list of substitute URLs used by 'guix-daemon'.])
  102. dnl Check whether the 'offload' build hook can be built (uses
  103. dnl 'restore-file-set', which requires unbuffered custom binary input
  104. dnl ports from Guile >= 2.0.10.)
  105. GUIX_CHECK_UNBUFFERED_CBIP
  106. dnl Check for Guile-SSH, which is required by 'guix offload'.
  107. GUIX_CHECK_GUILE_SSH
  108. case "x$ac_cv_guix_cbips_support_setvbuf$guix_cv_have_recent_guile_ssh" in
  109. xyesyes)
  110. guix_build_daemon_offload="yes"
  111. AC_DEFINE([HAVE_DAEMON_OFFLOAD_HOOK], [1],
  112. [Define if the daemon's 'offload' build hook is being built (requires Guile-SSH).])
  113. ;;
  114. *)
  115. guix_build_daemon_offload="no"
  116. ;;
  117. esac
  118. dnl Temporary directory used to store the daemon's data.
  119. GUIX_TEST_ROOT_DIRECTORY
  120. GUIX_TEST_ROOT="$ac_cv_guix_test_root"
  121. AC_SUBST([GUIX_TEST_ROOT])
  122. GUIX_CHECK_LOCALSTATEDIR
  123. AC_CONFIG_FILES([nix/scripts/list-runtime-roots],
  124. [chmod +x nix/scripts/list-runtime-roots])
  125. AC_CONFIG_FILES([nix/scripts/download],
  126. [chmod +x nix/scripts/download])
  127. AC_CONFIG_FILES([nix/scripts/substitute],
  128. [chmod +x nix/scripts/substitute])
  129. AC_CONFIG_FILES([nix/scripts/guix-authenticate],
  130. [chmod +x nix/scripts/guix-authenticate])
  131. AC_CONFIG_FILES([nix/scripts/offload],
  132. [chmod +x nix/scripts/offload])
  133. fi
  134. AM_CONDITIONAL([BUILD_DAEMON], [test "x$guix_build_daemon" = "xyes"])
  135. AM_CONDITIONAL([BUILD_DAEMON_OFFLOAD], \
  136. [test "x$guix_build_daemon" = "xyes" \
  137. && test "x$guix_build_daemon_offload" = "xyes"])