gnu: emacs-svg-icon: Fix grammar.
[jackhill/guix/guix.git] / gnu / packages / mercury.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2020 Brett Gilio <brettg@gnu.org>
3 ;;;
4 ;;; This file is part of GNU Guix.
5 ;;;
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
10 ;;;
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
15 ;;;
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19 (define-module (gnu packages mercury)
20 #:use-module (guix download)
21 #:use-module (guix git-download)
22 #:use-module (guix packages)
23 #:use-module (guix utils)
24 #:use-module ((guix licenses) #:prefix license:)
25 #:use-module (guix build-system gnu)
26 #:use-module (gnu packages autotools)
27 #:use-module (gnu packages bdw-gc)
28 #:use-module (gnu packages readline)
29 #:use-module (gnu packages texinfo)
30 #:use-module (gnu packages flex)
31 #:use-module (gnu packages shells)
32 #:use-module (gnu packages bison)
33 #:use-module (gnu packages pkg-config)
34 #:use-module (ice-9 match)) ; match-lambda
35
36 ;; NOTE: Mercury uses a tightly coupled fork of BDWGC and
37 ;; libatomic-ops. When updating the package, please check the GitHub
38 ;; repository to ensure that the submodule commit matches what is
39 ;; provided.
40 (define (gc-fork package-name package-url
41 package-commit package-hash)
42 (let ((commit package-commit))
43 (package (inherit package-name)
44 (source
45 (origin
46 (method git-fetch)
47 (uri (git-reference
48 (url package-url)
49 (commit commit)))
50 (sha256 (base32 package-hash)))))))
51
52 ;; NOTE: Mercury /MUST/ bootstrap from a tarball release.
53 ;; Once the bootstrapping compiler is established, this
54 ;; minimal build can be used for further compiling Mercury
55 ;; from a git checkout with additional grades enabled.
56 (define-public mercury-minimal
57 (package
58 (name "mercury-minimal")
59 (version "20.06.1")
60 (source (origin
61 (method url-fetch)
62 (uri (string-append
63 "https://dl.mercurylang.org/release/mercury-srcdist-"
64 version ".tar.gz"))
65 (sha256
66 (base32
67 "07qwkk871yxd4q1sw5xv26g8jrpvnpprmzvfd7zg7i142kl3l2gg"))))
68 (build-system gnu-build-system)
69 (arguments
70 `(#:modules ((guix build gnu-build-system)
71 (guix build utils)
72 (ice-9 match))
73 #:tests? #f ; Tests are run on the stage-2 compiler.
74 ;; TODO: Find a way to bypass all static linkages.
75 #:configure-flags (list "--enable-minimal-install")
76 #:phases
77 (modify-phases %standard-phases
78 (add-after 'unpack 'replace-boehm-gc
79 (lambda* (#:key inputs outputs #:allow-other-keys)
80 (let ((out (assoc-ref outputs "out"))
81 (libgc (assoc-ref inputs "libgc"))
82 (libatomic-ops (assoc-ref inputs "libatomic-ops"))
83 (unpack (assoc-ref %standard-phases 'unpack))
84 (patch-source-shebangs
85 (assoc-ref %standard-phases 'patch-source-shebangs)))
86 (map (match-lambda
87 ((src orig-name new-name)
88 (with-directory-excursion "."
89 (apply unpack (list #:source src)))
90 (delete-file-recursively new-name)
91 (invoke "mv" orig-name new-name)
92 (with-directory-excursion new-name
93 (apply patch-source-shebangs (list #:source src)))))
94 `((,libgc "source" "boehm_gc")))
95 (map (match-lambda
96 ((src orig-name new-name)
97 (with-directory-excursion "."
98 (apply unpack (list #:source src)))
99 (delete-file-recursively new-name)
100 (invoke "mv" orig-name new-name)
101 (with-directory-excursion new-name
102 (apply patch-source-shebangs (list #:source src)))))
103 `((,libatomic-ops "source" "boehm_gc/libatomic_ops")))
104 #t)))
105 (add-after 'replace-boehm-gc 'patch-paths
106 (lambda _
107 (substitute*
108 (list "Makefile"
109 "Mmakefile"
110 "scripts/mercury_update_interface.in"
111 "scripts/mercury_config.in"
112 "scripts/mmake.in"
113 "scripts/Mmake.vars.in"
114 "scripts/mdb.in"
115 "scripts/rs6000_hack"
116 "scripts/fullarch"
117 "scripts/mmc.in"
118 "scripts/canonical_grade"
119 "scripts/mprof.in"
120 "scripts/gud.el"
121 "scripts/ml.in"
122 "scripts/canonical_grade.in"
123 "scripts/mdprof.in"
124 "scripts/vpath_find"
125 "scripts/mkfifo_using_mknod.in"
126 "scripts/prepare_install_dir.in"
127 "scripts/mprof_merge_runs"
128 "scripts/mtc"
129 "scripts/mgnuc.in"
130 "scripts/c2init.in"
131 "bindist/bindist.Makefile"
132 "boehm_gc/configure.ac"
133 "boehm_gc/Makefile.direct")
134 (("/bin/sh") (which "sh"))
135 (("/bin/pwd") (which "pwd"))
136 (("/bin/rm") (which "rm")))
137 #t)))))
138 (native-inputs
139 `(("texinfo" ,texinfo)
140 ("flex" ,flex)
141 ("tcsh" ,tcsh)
142 ("bison" ,bison)
143 ("readline" ,readline)
144 ("libatomic-ops" ,(package-source
145 (gc-fork
146 libatomic-ops
147 "https://github.com/Mercury-Language/libatomic_ops.git"
148 "49b70d57f6922fd8be55a7dcb77955c8abfc9ae9"
149 "1flvwscsa6b2b8a38vhhcgl10bbkb5nnihw7s7iia60cinf7wcqm")))
150 ("libgc" ,(package-source
151 (gc-fork
152 libgc-7
153 "https://github.com/Mercury-Language/bdwgc.git"
154 "43ac2ea45261ba0a715534e9da41b2504904c46a"
155 "0bmzmbs7id0ndyhy9xli6fhfad1shrim6vmy2k8m1nqr5wb31q76")))
156 ("pkg-config" ,pkg-config)))
157 (synopsis "Pure logic programming language (used only for
158 bootstrapping dependent Mercury)")
159 (description "Mercury is a logic/functional programming language which
160 combines the clarity and expressiveness of declarative programming with advanced
161 static analysis and error detection features. Its highly optimized execution
162 algorithm delivers efficiency far in excess of existing logic programming
163 systems, and close to conventional programming systems. Mercury addresses
164 the problems of large-scale program development, allowing modularity,
165 separate compilation, and numerous optimization/time trade-offs.")
166 (home-page "https://mercurylang.org")
167 (license license:gpl2)))
168
169 ;; NOTE: This package is quite large and will take an extensive
170 ;; amount of time to compile, especially with bootcheck functionality
171 ;; enabled. To ensure that we do not monopolize the CI & build servers,
172 ;; please make sure that your changes are justified.
173 (define-public mercury
174 (package (inherit mercury-minimal)
175 (name "mercury")
176 (version "20.06.1")
177 (source
178 (origin
179 (method git-fetch)
180 (uri (git-reference
181 (url "https://github.com/Mercury-Language/mercury")
182 (commit (string-append
183 "version-"
184 (string-join (string-split version #\.) "_")))))
185 (file-name (git-file-name name version))
186 (sha256
187 (base32
188 "1b6rmdinw8mj6n9sc7c75kkf42gd2k254rf51x4snlrqckxj7aaz"))))
189 (arguments
190 (substitute-keyword-arguments
191 (package-arguments mercury-minimal)
192 ;; TODO: Find a way to bypass all static linkages.
193 ((#:configure-flags flags ''())
194 `(list ""))
195 ((#:tests? _) #f) ; FIXME: Many test-cases failing.
196 ((#:phases phases)
197 `(modify-phases ,phases
198 (replace 'patch-paths
199 (lambda _
200 (substitute*
201 (list "prepare.sh"
202 "Makefile"
203 "Mmakefile"
204 "scripts/mercury_update_interface.in"
205 "scripts/mercury_config.in"
206 "scripts/mmake.in"
207 "scripts/Mmake.vars.in"
208 "scripts/mdb.in"
209 "scripts/rs6000_hack"
210 "scripts/fullarch"
211 "scripts/mmc.in"
212 "scripts/mprof.in"
213 "scripts/gud.el"
214 "scripts/ml.in"
215 "scripts/canonical_grade.in"
216 "scripts/mdprof.in"
217 "scripts/vpath_find"
218 "scripts/mkfifo_using_mknod.in"
219 "scripts/prepare_install_dir.in"
220 "scripts/mprof_merge_runs"
221 "scripts/mtc"
222 "scripts/mgnuc.in"
223 "scripts/c2init.in"
224 "tools/bootcheck"
225 "boehm_gc/configure.ac"
226 "boehm_gc/Makefile.direct")
227 (("/bin/sh") (which "sh"))
228 (("/bin/pwd") (which "pwd"))
229 (("/bin/rm") (which "rm"))
230 (("boehm_gc/.git") "boehm_gc"))
231 #t))
232 (replace 'bootstrap
233 (lambda _
234 (invoke "./prepare.sh")
235 #t))))))
236 ;; TODO: Uncomment phase when tests are enabled.
237 ;; (replace 'check
238 ;; (lambda _
239 ;; (invoke "./tools/bootcheck")
240 ;; #t))
241 ;;
242 ;; TODO: The mercury configuration system determines
243 ;; grade support by looking for available toolchains.
244 ;; Eventually we need to add inputs for Java, Erlang,
245 ;; C#, etc. in order to enable these extra grades.
246 (native-inputs
247 `(("mercury-minimal" ,mercury-minimal)
248 ("autoconf" ,autoconf)
249 ("automake" ,automake)
250 ,@(package-native-inputs mercury-minimal)))
251 (synopsis "Pure logic programming language")))