| 1 | dnl -*- Autoconf -*- fragment for the C++ daemon. |
| 2 | |
| 3 | AC_MSG_CHECKING([whether to build daemon]) |
| 4 | AC_MSG_RESULT([$guix_build_daemon]) |
| 5 | |
| 6 | dnl C++ environment. This macro must be used unconditionnaly. |
| 7 | AC_PROG_CXX |
| 8 | AM_PROG_AR |
| 9 | AC_LANG([C++]) |
| 10 | |
| 11 | if test "x$guix_build_daemon" = "xyes"; then |
| 12 | |
| 13 | GUIX_ASSERT_CXX11 |
| 14 | |
| 15 | AC_PROG_RANLIB |
| 16 | AC_CONFIG_HEADERS([nix/config.h]) |
| 17 | |
| 18 | dnl Use 64-bit file system calls so that we can support files > 2 GiB. |
| 19 | AC_SYS_LARGEFILE |
| 20 | |
| 21 | dnl Look for zlib, a required dependency. |
| 22 | AC_CHECK_LIB([z], [gzdopen], [true], |
| 23 | [AC_MSG_ERROR([Guix requires zlib. See http://www.zlib.net/.])]) |
| 24 | AC_CHECK_HEADERS([zlib.h], [true], |
| 25 | [AC_MSG_ERROR([Guix requires zlib. See http://www.zlib.net/.])]) |
| 26 | |
| 27 | dnl Look for libbz2, an optional dependency. |
| 28 | AC_CHECK_LIB([bz2], [BZ2_bzWriteOpen], [HAVE_LIBBZ2=yes], [HAVE_LIBBZ2=no]) |
| 29 | if test "x$HAVE_LIBBZ2" = xyes; then |
| 30 | AC_CHECK_HEADERS([bzlib.h]) |
| 31 | HAVE_LIBBZ2="$ac_cv_header_bzlib_h" |
| 32 | fi |
| 33 | |
| 34 | dnl Look for SQLite, a required dependency. |
| 35 | PKG_CHECK_MODULES([SQLITE3], [sqlite3 >= 3.6.19]) |
| 36 | |
| 37 | AC_DEFINE_UNQUOTED([SYSTEM], ["$guix_system"], |
| 38 | [Guix host system type--i.e., platform and OS kernel tuple.]) |
| 39 | |
| 40 | case "$LIBGCRYPT_PREFIX" in |
| 41 | no) |
| 42 | LIBGCRYPT_CPPFLAGS="" |
| 43 | ;; |
| 44 | *) |
| 45 | LIBGCRYPT_CPPFLAGS="-I$LIBGCRYPT_PREFIX/include" |
| 46 | ;; |
| 47 | esac |
| 48 | |
| 49 | case "$LIBGCRYPT_LIBDIR" in |
| 50 | no | "") |
| 51 | ;; |
| 52 | *) |
| 53 | LIBGCRYPT_LDFLAGS="-L$LIBGCRYPT_LIBDIR" |
| 54 | ;; |
| 55 | esac |
| 56 | |
| 57 | LIBGCRYPT_LIBS="-lgcrypt" |
| 58 | AC_SUBST([LIBGCRYPT_CPPFLAGS]) |
| 59 | AC_SUBST([LIBGCRYPT_LDFLAGS]) |
| 60 | AC_SUBST([LIBGCRYPT_LIBS]) |
| 61 | |
| 62 | save_CPPFLAGS="$CPPFLAGS" |
| 63 | save_LDFLAGS="$LDFLAGS" |
| 64 | save_LIBS="$LIBS" |
| 65 | CPPFLAGS="$CPPFLAGS $LIBGCRYPT_CPPFLAGS" |
| 66 | LDFLAGS="$LDFLAGS $LIBGCRYPT_LDFLAGS" |
| 67 | LIBS="$LIBS $LIBGCRYPT_LIBS" |
| 68 | |
| 69 | have_gcrypt=yes |
| 70 | AC_CHECK_LIB([gcrypt], [gcry_md_open], [:], [have_gcrypt=no]) |
| 71 | AC_CHECK_HEADER([gcrypt.h], [:], [have_gcrypt=no]) |
| 72 | if test "x$have_gcrypt" != "xyes"; then |
| 73 | AC_MSG_ERROR([GNU libgcrypt not found; please install it.]) |
| 74 | fi |
| 75 | CPPFLAGS="$save_CPPFLAGS" |
| 76 | LDFLAGS="$save_LDFLAGS" |
| 77 | LIBS="$save_LIBS" |
| 78 | |
| 79 | dnl Chroot support. |
| 80 | AC_CHECK_FUNCS([chroot unshare]) |
| 81 | AC_CHECK_HEADERS([sched.h sys/param.h sys/mount.h sys/syscall.h \ |
| 82 | linux/close_range.h sys/prctl.h]) |
| 83 | |
| 84 | if test "x$ac_cv_func_chroot" != "xyes"; then |
| 85 | AC_MSG_ERROR(['chroot' function missing, bailing out]) |
| 86 | fi |
| 87 | |
| 88 | dnl lutimes and lchown: used when canonicalizing store items. |
| 89 | dnl posix_fallocate: used when extracting archives. |
| 90 | dnl vfork: to speed up spawning of helper programs. |
| 91 | dnl `--> now disabled because of unpredictable behavior: |
| 92 | dnl see <http://lists.gnu.org/archive/html/guix-devel/2014-05/msg00036.html> |
| 93 | dnl and Nix commit f794465c (Nov. 2012). |
| 94 | dnl sched_setaffinity: to improve RPC locality. |
| 95 | dnl statvfs: to detect disk-full conditions. |
| 96 | dnl strsignal: for error reporting. |
| 97 | dnl statx: fine-grain 'stat' call, new in glibc 2.28. |
| 98 | AC_CHECK_FUNCS([lutimes lchown posix_fallocate sched_setaffinity \ |
| 99 | statvfs nanosleep strsignal statx close_range]) |
| 100 | |
| 101 | dnl Check for <locale>. |
| 102 | AC_LANG_PUSH(C++) |
| 103 | AC_CHECK_HEADERS([locale]) |
| 104 | AC_LANG_POP(C++) |
| 105 | |
| 106 | |
| 107 | dnl Check whether we have the `personality' syscall, which allows us |
| 108 | dnl to do i686-linux builds on x86_64-linux machines. |
| 109 | AC_CHECK_HEADERS([sys/personality.h]) |
| 110 | |
| 111 | dnl Determine the appropriate default list of substitute URLs (GnuTLS |
| 112 | dnl is required so we can default to 'https'.) |
| 113 | GUIX_SUBSTITUTE_URLS="https://bordeaux.guix.gnu.org https://ci.guix.gnu.org" |
| 114 | |
| 115 | AC_MSG_CHECKING([for default substitute URLs]) |
| 116 | AC_MSG_RESULT([$GUIX_SUBSTITUTE_URLS]) |
| 117 | AC_SUBST([GUIX_SUBSTITUTE_URLS]) |
| 118 | |
| 119 | AC_DEFINE_UNQUOTED([GUIX_SUBSTITUTE_URLS], ["$GUIX_SUBSTITUTE_URLS"], |
| 120 | [Default list of substitute URLs used by 'guix-daemon'.]) |
| 121 | |
| 122 | dnl Check for Guile-SSH, which is required by 'guix offload'. |
| 123 | GUIX_CHECK_GUILE_SSH |
| 124 | |
| 125 | case "x$guix_cv_have_recent_guile_ssh" in |
| 126 | xyes) |
| 127 | guix_build_daemon_offload="yes" |
| 128 | AC_DEFINE([HAVE_DAEMON_OFFLOAD_HOOK], [1], |
| 129 | [Define if the daemon's 'offload' build hook is being built (requires Guile-SSH).]) |
| 130 | ;; |
| 131 | *) |
| 132 | guix_build_daemon_offload="no" |
| 133 | ;; |
| 134 | esac |
| 135 | |
| 136 | dnl Temporary directory used to store the daemon's data. |
| 137 | GUIX_TEST_ROOT_DIRECTORY |
| 138 | GUIX_TEST_ROOT="$ac_cv_guix_test_root" |
| 139 | AC_SUBST([GUIX_TEST_ROOT]) |
| 140 | |
| 141 | GUIX_CHECK_LOCALSTATEDIR |
| 142 | |
| 143 | case "x$host_os" in |
| 144 | x*linux*) |
| 145 | AC_CHECK_PROG([have_slirp4netns], [slirp4netns], [yes]) |
| 146 | if test "x$have_slirp4netns" != "xyes" |
| 147 | then |
| 148 | AC_MSG_WARN([Slirp4netns not found; fixed-output chroot builds won't work without it.]) |
| 149 | fi |
| 150 | ;; |
| 151 | esac |
| 152 | AC_PATH_PROG([SLIRP4NETNS], [slirp4netns], [slirp4netns]) |
| 153 | AC_DEFINE_UNQUOTED([SLIRP4NETNS], ["$SLIRP4NETNS"], |
| 154 | [Path to the slirp4netns program, if any.]) |
| 155 | |
| 156 | dnl needed for inspecting 64-bit system call arguments in seccomp's Berkeley |
| 157 | dnl Packet Filter VM, which only directly operates on 32-bit words. |
| 158 | AC_C_BIGENDIAN |
| 159 | fi |
| 160 | |
| 161 | AM_CONDITIONAL([HAVE_LIBBZ2], [test "x$HAVE_LIBBZ2" = "xyes"]) |
| 162 | AM_CONDITIONAL([BUILD_DAEMON], [test "x$guix_build_daemon" = "xyes"]) |
| 163 | AM_CONDITIONAL([BUILD_DAEMON_OFFLOAD], \ |
| 164 | [test "x$guix_build_daemon" = "xyes" \ |
| 165 | && test "x$guix_build_daemon_offload" = "xyes"]) |