1 ;;; GNU Mes --- Maxwell Equations of Software
2 ;;; Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
4 ;;; This file is part of GNU Mes.
6 ;;; Also borrowing code from:
7 ;;; guile-sdl2 --- FFI bindings for SDL2
8 ;;; Copyright © 2015 David Thompson <davet@gnu.org>
10 ;;; GNU Mes is free software; you can redistribute it and/or modify it
11 ;;; under the terms of the GNU General Public License as published by
12 ;;; the Free Software Foundation; either version 3 of the License, or (at
13 ;;; your option) any later version.
15 ;;; GNU Mes is distributed in the hope that it will be useful, but
16 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;;; GNU General Public License for more details.
20 ;;; You should have received a copy of the GNU General Public License
21 ;;; along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
23 (define-module (git mes)
24 #:use-module (srfi srfi-1)
25 #:use-module (srfi srfi-26)
26 #:use-module (ice-9 match)
27 #:use-module (ice-9 popen)
28 #:use-module (ice-9 rdelim)
29 #:use-module (gnu packages)
30 #:use-module (gnu packages base)
31 #:use-module (gnu packages commencement)
32 #:use-module (gnu packages cross-base)
33 #:use-module (gnu packages gcc)
34 #:use-module (gnu packages graphviz)
35 #:use-module (gnu packages guile)
36 #:use-module (gnu packages man)
37 #:use-module (gnu packages mes)
38 #:use-module (gnu packages package-management)
39 #:use-module (gnu packages version-control)
40 #:use-module (gnu packages perl)
41 #:use-module (gnu packages texinfo)
42 #:use-module ((guix build utils) #:select (with-directory-excursion))
43 #:use-module (guix build-system gnu)
44 #:use-module (guix build-system trivial)
45 #:use-module (guix gexp)
46 #:use-module (guix download)
47 #:use-module (guix git-download)
48 #:use-module (guix licenses)
49 #:use-module (guix packages))
51 (define %source-dir (getcwd))
54 (let* ((pipe (with-directory-excursion %source-dir
55 (open-pipe* OPEN_READ "git" "ls-files")))
56 (files (let loop ((lines '()))
57 (match (read-line pipe)
61 (loop (cons line lines))))))
62 (status (close-pipe pipe)))
64 (match (stat:type stat)
66 ((or 'regular 'symlink)
67 (any (cut string-suffix? <> file) files))
70 (define-public nyacc-for-mes
71 (let ((commit "ba24561b77306cd876bb9fd5ac412b15c7535f02")
76 (version (if commit (string-append version "-" revision "." (string-take commit 7))
81 (string-append "http://git.savannah.nongnu.org/cgit/nyacc.git/snapshot/nyacc-"
83 (string-append "http://download.savannah.nongnu.org/releases/nyacc/nyacc-"
87 "08y8ihwm21i333w7b0g1gs4s184ky0wy6fnl1rcakpgrqan9r1ql")))))))
89 (define-public mescc-tools
95 (uri (string-append "http://git.savannah.nongnu.org/cgit/"
96 "mescc-tools.git/snapshot/"
97 "mescc-tools-Release_" version
99 (patches (search-patches "mescc-tools-boot.patch"))
100 (file-name (string-append name "-" version ".tar.gz"))
103 "01x7bhmgwyf6mc2g1hcvibhps98nllacqm4f0j5l51b1mbi18pc2"))))
104 (build-system gnu-build-system)
105 (supported-systems '("i686-linux" "x86_64-linux"))
107 `(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")))
109 #:phases (modify-phases %standard-phases
110 (delete 'configure))))
111 (synopsis "Tools for the full source bootstrapping process")
113 "Mescc-tools is a collection of tools for use in a full source
114 bootstrapping process. Currently consists of the M1 macro assembler and the
116 (home-page "https://github.com/oriansj/mescc-tools")
120 (let ((triplet "i686-unknown-linux-gnu")
128 "https://ftp.gnu.org/pub/gnu/mes/mes-" version ".tar.gz"))
130 (base32 #!mes!# "1dsaaqyanzsq9m5wrcd2bjhb3qd6928c9q97rg5r730pyqjwxyxf"))))
131 (build-system gnu-build-system)
132 (supported-systems '("i686-linux" "x86_64-linux"))
134 `(("mescc-tools" ,mescc-tools)
135 ("nyacc" ,nyacc-for-mes)))
139 ,@(if (string-prefix? "x86_64-linux" (or (%current-target-system)
141 ;; Use cross-compiler rather than #:system "i686-linux" to get
142 ;; MesCC 64 bit .go files installed ready for use with Guile.
143 `(("i686-linux-binutils" ,(cross-binutils triplet))
144 ("i686-linux-gcc" ,(cross-gcc triplet)))
146 ("graphviz" ,graphviz)
147 ("help2man" ,help2man)
148 ("perl" ,perl) ; build-aux/gitlog-to-changelog
149 ("texinfo" ,texinfo)))
152 (modify-phases %standard-phases
153 (add-before 'build 'make-git-source-writable
154 (lambda* (#:key outputs #:allow-other-keys)
155 (for-each make-file-writable
156 (find-files "." ".*\\.M1"))))
157 (delete 'strip)))) ; binutil's strip b0rkes Mescc/M1/hex2 binaries
158 (synopsis "Scheme interpreter and C compiler for full source bootstrapping")
160 "GNU Mes [Maxwell Equations of Software] aims to create full source
161 bootstrapping for GuixSD. It consists of a mutual self-hosting [close to
162 Guile-] Scheme interpreter prototype in C and a Nyacc-based C compiler in
164 (home-page "https://www.gnu.org/software/mes")
167 (define-public mes.git
168 (let ((version "0.18")
170 (commit (read-string (open-pipe "git show HEAD | head -1 | cut -d ' ' -f 2" OPEN_READ))))
174 (version (string-append version "-" revision "." (string-take commit 7)))
175 (source (local-file %source-dir #:recursive? #t #:select? git-file?)))))