gnu: nyacc: Use versioned Guile site directory.
[jackhill/guix/guix.git] / gnu / packages / mes.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2017, 2018, 2019, 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
3 ;;; Copyright © 2017, 2018 Efraim Flashner <efraim@flashner.co.il>
4 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
5 ;;;
6 ;;; This file is part of GNU Guix.
7 ;;;
8 ;;; GNU Guix is free software; you can redistribute it and/or modify it
9 ;;; under the terms of the GNU General Public License as published by
10 ;;; the Free Software Foundation; either version 3 of the License, or (at
11 ;;; your option) any later version.
12 ;;;
13 ;;; GNU Guix is distributed in the hope that it will be useful, but
14 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;;; GNU General Public License for more details.
17 ;;;
18 ;;; You should have received a copy of the GNU General Public License
19 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20
21 (define-module (gnu packages mes)
22 #:use-module (gnu packages)
23 #:use-module (gnu packages base)
24 #:use-module (gnu packages bash)
25 #:use-module (gnu packages bootstrap)
26 #:use-module (gnu packages compression)
27 #:use-module (gnu packages cross-base)
28 #:use-module (gnu packages gcc)
29 #:use-module (gnu packages graphviz)
30 #:use-module (gnu packages guile)
31 #:use-module (gnu packages man)
32 #:use-module (gnu packages package-management)
33 #:use-module (gnu packages perl)
34 #:use-module (gnu packages pkg-config)
35 #:use-module (gnu packages texinfo)
36 #:use-module (guix build-system gnu)
37 #:use-module (guix download)
38 #:use-module (guix git-download)
39 #:use-module (guix licenses)
40 #:use-module (guix packages)
41 #:use-module (guix utils))
42
43 (define-public nyacc-0.86
44 ;; Nyacc used for bootstrap.
45 (package
46 (name "nyacc")
47 (version "0.86.0")
48 (source (origin
49 (method url-fetch)
50 (uri (string-append "mirror://savannah/nyacc/"
51 name "-" version ".tar.gz"))
52 (patches (search-patches "nyacc-binary-literals.patch"))
53 (sha256
54 (base32
55 "0lkd9lyspvhxlfs0496gsllwinh62jk9wij6gpadvx9gwz6yavd9"))))
56 (build-system gnu-build-system)
57 (native-inputs
58 `(("guile" ,guile-2.2)))
59 (synopsis "LALR(1) Parser Generator in Guile")
60 (description
61 "NYACC is an LALR(1) parser generator implemented in Guile.
62 The syntax and nomenclature should be considered not stable. It comes with
63 extensive examples, including parsers for the Javascript and C99 languages.")
64 (home-page "https://savannah.nongnu.org/projects/nyacc")
65 (license (list gpl3+ lgpl3+))))
66
67 (define-public nyacc-0.99
68 (package
69 (inherit nyacc-0.86)
70 (version "0.99.0")
71 (source (origin
72 (method url-fetch)
73 (uri (string-append "mirror://savannah/nyacc/nyacc-"
74 version ".tar.gz"))
75 (sha256
76 (base32
77 "0hl5qxx19i4x1r0839sxm19ziqq65g4hy97yik81cc2yb9yvgyv3"))
78 (modules '((guix build utils)))
79 (snippet
80 '(begin
81 (substitute* (find-files "." "^Makefile\\.in$")
82 (("^SITE_SCM_DIR =.*")
83 "SITE_SCM_DIR = \
84 @prefix@/share/guile/site/@GUILE_EFFECTIVE_VERSION@\n")
85 (("^SITE_SCM_GO_DIR =.*")
86 "SITE_SCM_GO_DIR = \
87 @prefix@/lib/guile/@GUILE_EFFECTIVE_VERSION@/site-ccache\n")
88 (("^INFODIR =.*")
89 "INFODIR = @prefix@/share/info\n")
90 (("^DOCDIR =.*")
91 "DOCDIR = @prefix@/share/doc/$(PACKAGE_TARNAME)\n"))
92 #t))))
93 (native-inputs
94 `(("pkg-config" ,pkg-config)))
95 (inputs
96 `(("guile" ,guile-2.2)))))
97
98 (define-public nyacc
99 (package
100 (inherit nyacc-0.99)
101 (version "1.03.0")
102 (source (origin
103 (method url-fetch)
104 (uri (string-append "mirror://savannah/nyacc/nyacc-"
105 version ".tar.gz"))
106 (sha256
107 (base32
108 "1vdiqpm3p0ndmpmkzcpkpjvgklfsk4wxrhkixdxbczpafdfl635p"))
109 (modules '((guix build utils)))
110 (snippet
111 '(begin
112 (substitute* "configure"
113 (("GUILE_GLOBAL_SITE=\\$prefix.*")
114 "GUILE_GLOBAL_SITE=\
115 $prefix/share/guile/site/$GUILE_EFFECTIVE_VERSION\n"))
116 #t))))
117 (inputs
118 `(("guile" ,guile-3.0)))))
119
120 (define-public mes-0.19
121 ;; Mes used for bootstrap.
122 (package
123 (name "mes")
124 (version "0.19")
125 (source (origin
126 (method url-fetch)
127 (uri (string-append "mirror://gnu/mes/"
128 "mes-" version ".tar.gz"))
129 (sha256
130 (base32
131 "15h4yhaywdc0djpjlin2jz1kzahpqxfki0r0aav1qm9nxxmnp1l0"))))
132 (build-system gnu-build-system)
133 (supported-systems '("i686-linux" "x86_64-linux"))
134 (propagated-inputs
135 `(("mescc-tools" ,mescc-tools-0.5.2)
136 ("nyacc" ,nyacc-0.86)))
137 (native-inputs
138 `(("guile" ,guile-2.2)
139 ,@(let ((target-system (or (%current-target-system)
140 (%current-system))))
141 (cond
142 ((string-prefix? "x86_64-linux" target-system)
143 ;; Use cross-compiler rather than #:system "i686-linux" to get
144 ;; MesCC 64 bit .go files installed ready for use with Guile.
145 `(("i686-linux-binutils" ,(cross-binutils "i686-unknown-linux-gnu"))
146 ("i686-linux-gcc" ,(cross-gcc "i686-unknown-linux-gnu"))))
147 (else
148 '())))
149 ("graphviz" ,graphviz)
150 ("help2man" ,help2man)
151 ("perl" ,perl) ; build-aux/gitlog-to-changelog
152 ("texinfo" ,texinfo)))
153 (arguments
154 `(#:strip-binaries? #f)) ; binutil's strip b0rkes MesCC/M1/hex2 binaries
155 (synopsis "Scheme interpreter and C compiler for full source bootstrapping")
156 (description
157 "GNU Mes--Maxwell Equations of Software--brings the Reduced Binary Seed
158 bootstrap to Guix and aims to help create full source bootstrapping for
159 GNU/Linux distributions. It consists of a mutual self-hosting Scheme
160 interpreter in C and a Nyacc-based C compiler in Scheme and is compatible with
161 Guile.")
162 (home-page "https://www.gnu.org/software/mes/")
163 (license gpl3+)))
164
165 (define-public mes
166 (package
167 (inherit mes-0.19)
168 (version "0.22")
169 (source (origin
170 (method url-fetch)
171 (uri (string-append "mirror://gnu/mes/"
172 "mes-" version ".tar.gz"))
173 (sha256
174 (base32
175 "0p1jsrrmcbc0zrvbvnjbb6iyxr0in71km293q8qj6gnar6bw09av"))))
176 (propagated-inputs
177 `(("mescc-tools" ,mescc-tools)
178 ("nyacc" ,nyacc-0.99)))
179 (native-search-paths
180 (list (search-path-specification
181 (variable "C_INCLUDE_PATH")
182 (files '("include")))
183 (search-path-specification
184 (variable "LIBRARY_PATH")
185 (files '("lib")))
186 (search-path-specification
187 (variable "MES_PREFIX")
188 (separator #f)
189 (files '("")))))))
190
191 (define-public mes-rb5
192 ;; This is the Reproducible-Builds summit 5's Mes, also built on Debian
193 ;; GNU/Linux and NixOS to produce the same, bit-for-bit identical result.
194 (package
195 (inherit mes)
196 (name "mes-rb5")
197 (inputs '())
198 (propagated-inputs '())
199 (native-inputs
200 `(("bash" ,bash)
201 ("coreutils" ,coreutils)
202 ("grep" ,grep)
203 ("guile" ,guile-2.2)
204 ("gzip" ,gzip)
205 ("libc" ,glibc)
206 ("locales" ,glibc-utf8-locales)
207 ("make" ,gnu-make)
208 ("mes" ,mes)
209 ("mescc-tools" ,mescc-tools)
210 ("nyacc" ,nyacc-0.99)
211 ("sed" ,sed)
212 ("tar" ,tar)))
213 (supported-systems '("i686-linux"))
214 (arguments
215 `(#:implicit-inputs? #f
216 #:strip-binaries? #f ; binutil's strip b0rkes MesCC/M1/hex2 binaries
217 #:modules ((guix build gnu-build-system)
218 (guix build utils)
219 (ice-9 popen)
220 (ice-9 rdelim))
221 #:phases
222 (modify-phases %standard-phases
223 (add-before 'configure 'setenv
224 (lambda _
225 (setenv "AR" "mesar")
226 (setenv "CC" "mescc")
227 (setenv "GUILD" "true")
228 (setenv "SCHEME" "mes")
229 (setenv "LC_ALL" "en_US.UTF-8")
230 #t))
231 (replace 'configure
232 (lambda _
233 (let ((out (assoc-ref %outputs "out")))
234 (invoke "sh" "configure.sh"
235 (string-append "--prefix=" out)
236 "--host=i686-unkown-linux-gnu"
237 "--with-courage"))))
238 (replace 'build
239 (lambda _
240 (invoke "sh" "bootstrap.sh")))
241 (replace 'check
242 (lambda _
243 (copy-file "bin/mes-mescc" "bin/mes-mescc-0.21")
244 (system* "sed" "-i" "s/0\\.22/0\\.21/" "bin/mes-mescc-0.21")
245 (let ((sha256sum
246 (read-delimited
247 " "
248 (open-pipe* OPEN_READ "sha256sum" "bin/mes-mescc-0.21"))))
249 (unless
250 (equal?
251 sha256sum
252 "9e0bcb1633c58e7bc415f6ea27cee7951d6b0658e13cdc147e992b31a14625fb")
253 (throw 'error "mes checksum failure"))
254 #t)))
255 (replace 'install
256 (lambda _
257 (invoke "sh" "install.sh"))))))))
258
259 (define-public mescc-tools-0.5.2
260 ;; Mescc-tools used for bootstrap.
261 (let ((commit "bb062b0da7bf2724ca40f9002b121579898d4ef7")
262 (revision "0")
263 (version "0.5.2"))
264 (package
265 (name "mescc-tools")
266 (version (git-version version revision commit))
267 (source (origin
268 (method git-fetch)
269 (uri (git-reference
270 (url "https://git.savannah.nongnu.org/r/mescc-tools.git")
271 (commit commit)))
272 (file-name (git-file-name name version))
273 (sha256
274 (base32
275 "1nc6rnax66vmhqsjg0kgx23pihdcxmww6v325ywf59vsq1jqjvff"))))
276 (build-system gnu-build-system)
277 (supported-systems '("i686-linux" "x86_64-linux"))
278 (arguments
279 `(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")))
280 #:test-target "test"
281 #:phases (modify-phases %standard-phases
282 (delete 'configure))))
283 (synopsis "Tools for the full source bootstrapping process")
284 (description
285 "Mescc-tools is a collection of tools for use in a full source
286 bootstrapping process. It consists of the M1 macro assembler, the hex2
287 linker, the blood-elf symbol table generator, the kaem shell, exec_enable and
288 get_machine.")
289 (home-page "https://savannah.nongnu.org/projects/mescc-tools")
290 (license gpl3+))))
291
292 (define-public mescc-tools
293 (package
294 (inherit mescc-tools-0.5.2)
295 (name "mescc-tools")
296 (version "0.6.1")
297 (source (origin
298 (method git-fetch)
299 (uri (git-reference
300 (url "https://git.savannah.nongnu.org/r/mescc-tools.git")
301 (commit (string-append "Release_" version))))
302 (file-name (string-append "mescc-tools-" version "-checkout"))
303 (sha256
304 (base32
305 "1cgxcdza6ws725x84i31la7jxmlk5a3nsij5shz1zljg0i36kj99"))))
306 (arguments
307 (substitute-keyword-arguments (package-arguments mescc-tools-0.5.2)
308 ((#:make-flags _)
309 `(list (string-append "PREFIX=" (assoc-ref %outputs "out"))
310 "CC=gcc"))))))
311
312 (define-public m2-planet
313 (let ((commit "b87ddb0051b168ea45f8d49a610dcd069263336a")
314 (revision "2"))
315 (package
316 (name "m2-planet")
317 (version (string-append "1.4.0-" revision "." (string-take commit 7)))
318 (source (origin
319 (method git-fetch)
320 (uri (git-reference
321 (url "https://github.com/oriansj/m2-planet")
322 (commit commit)))
323 (file-name (git-file-name name version))
324 (sha256
325 (base32
326 "0yyc0fcbbxi9jqa1n76x0rwspdrwmc8g09jlmsw9c35nflrhmz8q"))))
327 (native-inputs
328 `(("mescc-tools" ,mescc-tools)))
329 (build-system gnu-build-system)
330 (arguments
331 `(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")))
332 #:tests? #f
333 #:phases (modify-phases %standard-phases
334 (delete 'bootstrap)
335 (delete 'configure))))
336 (synopsis "The PLAtform NEutral Transpiler")
337 (description
338 "M2-Planet, the PLAtform NEutral Transpiler, when combined with
339 mescc-tools, compiles a subset of the C language into working binaries with
340 introspective steps in between. It is self-hosting and for bootstrapping it
341 also has an implementation in the M1 macro assembly language. M2-Planet is
342 built as Phase-5 of the full source bootstrapping process and is capable of
343 building GNU Mes.")
344 (home-page "https://github.com/oriansj/m2-planet")
345 (license gpl3+))))