aboutsummaryrefslogtreecommitdiff
path: root/config-daemon.ac
blob: 9854f1d694f86cdb73dfb60439ae08cd10542224 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
dnl -*- Autoconf -*- fragment for the C++ daemon.

AC_MSG_CHECKING([whether to build daemon])
AC_MSG_RESULT([$guix_build_daemon])

dnl C++ environment.  This macro must be used unconditionnaly.
AC_PROG_CXX
AM_PROG_AR
AC_LANG([C++])

if test "x$guix_build_daemon" = "xyes"; then

  GUIX_ASSERT_CXX11

  AC_PROG_RANLIB
  AC_CONFIG_HEADERS([nix/config.h])

  dnl Use 64-bit file system calls so that we can support files > 2 GiB.
  AC_SYS_LARGEFILE

  dnl Look for zlib, a required dependency.
  AC_CHECK_LIB([z], [gzdopen], [true],
    [AC_MSG_ERROR([Guix requires zlib.  See http://www.zlib.net/.])])
  AC_CHECK_HEADERS([zlib.h], [true],
    [AC_MSG_ERROR([Guix requires zlib.  See http://www.zlib.net/.])])

  dnl Look for libbz2, an optional dependency.
  AC_CHECK_LIB([bz2], [BZ2_bzWriteOpen], [HAVE_LIBBZ2=yes], [HAVE_LIBBZ2=no])
  if test "x$HAVE_LIBBZ2" = xyes; then
    AC_CHECK_HEADERS([bzlib.h])
    HAVE_LIBBZ2="$ac_cv_header_bzlib_h"
  fi

  dnl Look for SQLite, a required dependency.
  PKG_CHECK_MODULES([SQLITE3], [sqlite3 >= 3.6.19])

  AC_DEFINE_UNQUOTED([SYSTEM], ["$guix_system"],
    [Guix host system type--i.e., platform and OS kernel tuple.])

  case "$LIBGCRYPT_PREFIX" in
    no)
      LIBGCRYPT_CFLAGS=""
      ;;
    *)
      LIBGCRYPT_CFLAGS="-I$LIBGCRYPT_PREFIX/include"
      ;;
  esac

  case "$LIBGCRYPT_LIBDIR" in
    no | "")
      LIBGCRYPT_LIBS="-lgcrypt"
      ;;
    *)
      LIBGCRYPT_LIBS="-L$LIBGCRYPT_LIBDIR -lgcrypt"
      ;;
  esac

  AC_SUBST([LIBGCRYPT_CFLAGS])
  AC_SUBST([LIBGCRYPT_LIBS])

  save_CFLAGS="$CFLAGS"
  save_LDFLAGS="$LDFLAGS"
  CFLAGS="$CFLAGS $LIBGCRYPT_CFLAGS"
  LDFLAGS="$LDFLAGS $LIBGCRYPT_LDFLAGS"

  have_gcrypt=yes
  AC_CHECK_LIB([gcrypt], [gcry_md_open], [:], [have_gcrypt=no])
  AC_CHECK_HEADER([gcrypt.h], [:], [have_gcrypt=no])
  if test "x$have_gcrypt" != "xyes"; then
    AC_MSG_ERROR([GNU libgcrypt not found; please install it.])
  fi

  CFLAGS="$save_CFLAGS"
  LDFLAGS="$save_LDFLAGS"

  dnl Chroot support.
  AC_CHECK_FUNCS([chroot unshare])
  AC_CHECK_HEADERS([sched.h sys/param.h sys/mount.h sys/syscall.h])

  if test "x$ac_cv_func_chroot" != "xyes"; then
    AC_MSG_ERROR(['chroot' function missing, bailing out])
  fi

  dnl lutimes and lchown: used when canonicalizing store items.
  dnl posix_fallocate: used when extracting archives.
  dnl vfork: to speed up spawning of helper programs.
  dnl   `--> now disabled because of unpredictable behavior:
  dnl        see <http://lists.gnu.org/archive/html/guix-devel/2014-05/msg00036.html>
  dnl        and Nix commit f794465c (Nov. 2012).
  dnl sched_setaffinity: to improve RPC locality.
  dnl statvfs: to detect disk-full conditions.
  dnl strsignal: for error reporting.
  dnl statx: fine-grain 'stat' call, new in glibc 2.28.
  AC_CHECK_FUNCS([lutimes lchown posix_fallocate sched_setaffinity \
     statvfs nanosleep strsignal statx])

  dnl Check for <locale>.
  AC_LANG_PUSH(C++)
  AC_CHECK_HEADERS([locale])
  AC_LANG_POP(C++)


  dnl Check whether we have the `personality' syscall, which allows us
  dnl to do i686-linux builds on x86_64-linux machines.
  AC_CHECK_HEADERS([sys/personality.h])

  dnl Determine the appropriate default list of substitute URLs (GnuTLS
  dnl is required so we can default to 'https'.)
  GUIX_SUBSTITUTE_URLS="https://bordeaux.guix.gnu.org https://ci.guix.gnu.org"

  AC_MSG_CHECKING([for default substitute URLs])
  AC_MSG_RESULT([$GUIX_SUBSTITUTE_URLS])
  AC_SUBST([GUIX_SUBSTITUTE_URLS])

  AC_DEFINE_UNQUOTED([GUIX_SUBSTITUTE_URLS], ["$GUIX_SUBSTITUTE_URLS"],
    [Default list of substitute URLs used by 'guix-daemon'.])

  dnl Check for Guile-SSH, which is required by 'guix offload'.
  GUIX_CHECK_GUILE_SSH

  case "x$guix_cv_have_recent_guile_ssh" in
    xyes)
      guix_build_daemon_offload="yes"
      AC_DEFINE([HAVE_DAEMON_OFFLOAD_HOOK], [1],
	[Define if the daemon's 'offload' build hook is being built (requires Guile-SSH).])
      ;;
    *)
      guix_build_daemon_offload="no"
      ;;
  esac

  dnl Temporary directory used to store the daemon's data.
  GUIX_TEST_ROOT_DIRECTORY
  GUIX_TEST_ROOT="$ac_cv_guix_test_root"
  AC_SUBST([GUIX_TEST_ROOT])

  GUIX_CHECK_LOCALSTATEDIR
fi

AM_CONDITIONAL([HAVE_LIBBZ2], [test "x$HAVE_LIBBZ2" = "xyes"])
AM_CONDITIONAL([BUILD_DAEMON], [test "x$guix_build_daemon" = "xyes"])
AM_CONDITIONAL([BUILD_DAEMON_OFFLOAD],			\
  [test "x$guix_build_daemon" = "xyes"			\
   && test "x$guix_build_daemon_offload" = "xyes"])
ckages) #:use-module (guix utils) #:use-module ((guix licenses) #:prefix license:) #:use-module (guix build-system gnu) #:use-module (gnu packages autotools) #:use-module (gnu packages bdw-gc) #:use-module (gnu packages readline) #:use-module (gnu packages texinfo) #:use-module (gnu packages flex) #:use-module (gnu packages shells) #:use-module (gnu packages bison) #:use-module (gnu packages pkg-config) #:use-module (ice-9 match)) ; match-lambda ;; NOTE: Mercury uses a tightly coupled fork of BDWGC and ;; libatomic-ops. When updating the package, please check the GitHub ;; repository to ensure that the submodule commit matches what is ;; provided. (define (gc-fork package-name package-url package-commit package-hash) (let ((commit package-commit)) (package (inherit package-name) (source (origin (method git-fetch) (uri (git-reference (url package-url) (commit commit))) (sha256 (base32 package-hash))))))) ;; NOTE: Mercury /MUST/ bootstrap from a tarball release. ;; Once the bootstrapping compiler is established, this ;; minimal build can be used for further compiling Mercury ;; from a git checkout with additional grades enabled. (define-public mercury-minimal (package (name "mercury-minimal") (version "20.06") (source (origin (method url-fetch) (uri (string-append "https://dl.mercurylang.org/release/mercury-srcdist-" version ".tar.gz")) (sha256 (base32 "1gkr9w8lsdzqykqwd3f1a1phsqv090648i14ilhv8jdg85frdimr")))) (build-system gnu-build-system) (arguments `(#:modules ((guix build gnu-build-system) (guix build utils) (ice-9 match)) #:tests? #f ; Tests are run on the stage-2 compiler. ;; TODO: Find a way to bypass all static linkages. #:configure-flags (list "--enable-minimal-install") #:phases (modify-phases %standard-phases (add-after 'unpack 'replace-boehm-gc (lambda* (#:key inputs outputs #:allow-other-keys) (let ((out (assoc-ref outputs "out")) (libgc (assoc-ref inputs "libgc")) (libatomic-ops (assoc-ref inputs "libatomic-ops")) (unpack (assoc-ref %standard-phases 'unpack)) (patch-source-shebangs (assoc-ref %standard-phases 'patch-source-shebangs))) (map (match-lambda ((src orig-name new-name) (with-directory-excursion "." (apply unpack (list #:source src))) (delete-file-recursively new-name) (invoke "mv" orig-name new-name) (with-directory-excursion new-name (apply patch-source-shebangs (list #:source src))))) `((,libgc "source" "boehm_gc"))) (map (match-lambda ((src orig-name new-name) (with-directory-excursion "." (apply unpack (list #:source src))) (delete-file-recursively new-name) (invoke "mv" orig-name new-name) (with-directory-excursion new-name (apply patch-source-shebangs (list #:source src))))) `((,libatomic-ops "source" "boehm_gc/libatomic_ops"))) #t))) (add-after 'replace-boehm-gc 'patch-paths (lambda _ (substitute* (list "Makefile" "Mmakefile" "scripts/mercury_update_interface.in" "scripts/mercury_config.in" "scripts/mmake.in" "scripts/Mmake.vars.in" "scripts/mdb.in" "scripts/rs6000_hack" "scripts/fullarch" "scripts/mmc.in" "scripts/canonical_grade" "scripts/mprof.in" "scripts/gud.el" "scripts/ml.in" "scripts/canonical_grade.in" "scripts/mdprof.in" "scripts/vpath_find" "scripts/mkfifo_using_mknod.in" "scripts/prepare_install_dir.in" "scripts/mprof_merge_runs" "scripts/mtc" "scripts/mgnuc.in" "scripts/c2init.in" "bindist/bindist.Makefile" "boehm_gc/configure.ac" "boehm_gc/Makefile.direct") (("/bin/sh") (which "sh")) (("/bin/pwd") (which "pwd")) (("/bin/rm") (which "rm"))) #t))))) (native-inputs `(("texinfo" ,texinfo) ("flex" ,flex) ("tcsh", tcsh) ("bison" ,bison) ("readline" ,readline) ("libatomic-ops" ,(package-source (gc-fork libatomic-ops "https://github.com/Mercury-Language/libatomic_ops.git" "49b70d57f6922fd8be55a7dcb77955c8abfc9ae9" "1flvwscsa6b2b8a38vhhcgl10bbkb5nnihw7s7iia60cinf7wcqm"))) ("libgc" ,(package-source (gc-fork libgc-7 "https://github.com/Mercury-Language/bdwgc.git" "43ac2ea45261ba0a715534e9da41b2504904c46a" "0bmzmbs7id0ndyhy9xli6fhfad1shrim6vmy2k8m1nqr5wb31q76"))) ("pkg-config" ,pkg-config))) (synopsis "Pure logic programming language (used only for bootstrapping dependent Mercury)") (description "Mercury is a logic/functional programming language which combines the clarity and expressiveness of declarative programming with advanced static analysis and error detection features. Its highly optimized execution algorithm delivers efficiency far in excess of existing logic programming systems, and close to conventional programming systems. Mercury addresses the problems of large-scale program development, allowing modularity, separate compilation, and numerous optimization/time trade-offs.") (home-page "https://mercurylang.org") (license license:gpl2))) ;; NOTE: This package is quite large and will take an extensive ;; amount of time to compile, especially with bootcheck functionality ;; enabled. To ensure that we do not monopolize the CI & build servers, ;; please make sure that your changes are justified. (define-public mercury (package (inherit mercury-minimal) (name "mercury") (version "20.06") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/Mercury-Language/mercury") (commit (string-append "version-" (string-join (string-split version #\.) "_"))))) (file-name (git-file-name name version)) (sha256 (base32 "1pc51r7vlqmi689rkwdkk1ka2dyk36q11dqvl339cizng6mp72h6")))) (arguments (substitute-keyword-arguments (package-arguments mercury-minimal) ;; TODO: Find a way to bypass all static linkages. ((#:configure-flags flags ''()) `(list "")) ((#:tests? _) #f) ; FIXME: Many test-cases failing. ((#:phases phases) `(modify-phases ,phases (replace 'patch-paths (lambda _ (substitute* (list "prepare.sh" "Makefile" "Mmakefile" "scripts/mercury_update_interface.in" "scripts/mercury_config.in" "scripts/mmake.in" "scripts/Mmake.vars.in" "scripts/mdb.in" "scripts/rs6000_hack" "scripts/fullarch" "scripts/mmc.in" "scripts/mprof.in" "scripts/gud.el" "scripts/ml.in" "scripts/canonical_grade.in" "scripts/mdprof.in" "scripts/vpath_find" "scripts/mkfifo_using_mknod.in" "scripts/prepare_install_dir.in" "scripts/mprof_merge_runs" "scripts/mtc" "scripts/mgnuc.in" "scripts/c2init.in" "tools/bootcheck" "boehm_gc/configure.ac" "boehm_gc/Makefile.direct") (("/bin/sh") (which "sh")) (("/bin/pwd") (which "pwd")) (("/bin/rm") (which "rm")) (("boehm_gc/.git") "boehm_gc")) #t)) (replace 'bootstrap (lambda _ (invoke "./prepare.sh") #t)))))) ;; TODO: Uncomment phase when tests are enabled. ;; (replace 'check ;; (lambda _ ;; (invoke "./tools/bootcheck") ;; #t)) ;; ;; TODO: The mercury configuration system determines ;; grade support by looking for available toolchains. ;; Eventually we need to add inputs for Java, Erlang, ;; C#, etc. in order to enable these extra grades. (native-inputs `(("mercury-minimal" ,mercury-minimal) ("autoconf" ,autoconf) ("automake" ,automake) ,@(package-native-inputs mercury-minimal))) (synopsis "Pure logic programming language")))