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
76 (uri (string-append "https://gitlab.com/janneke/nyacc"
77 "/-/archive/v" version
78 "/nyacc-" version ".tar.gz"))
81 "0c8c8kxir0h2d4nxr131xbkfs7c80haipmkp2g6677sh14wn0b3y"))))))
83 (define-public mescc-tools
90 "https://github.com/oriansj/mescc-tools/archive/Release_"
93 (file-name (string-append name "-" version ".tar.gz"))
96 "0rsxbjc3bg0jl3h7ai4hndxx2iyyk8bvwj9nd3xv2vgz3bmypnah"))))
97 (build-system gnu-build-system)
98 (supported-systems '("i686-linux" "x86_64-linux"))
100 `(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")))
102 #:phases (modify-phases %standard-phases
103 (delete 'configure))))
104 (synopsis "Tools for the full source bootstrapping process")
106 "Mescc-tools is a collection of tools for use in a full source
107 bootstrapping process. Currently consists of the M1 macro assembler and the
109 (home-page "https://github.com/oriansj/mescc-tools")
113 (let ((triplet "i686-unknown-linux-gnu")
121 "https://alpha.gnu.org/pub/gnu/mes/mes-" version ".tar.gz"))
123 (base32 #!mes!# "171bwanlnvwy406i5s0a6806iffcdz086njk8wbhgrc33n6jr8ir"))))
124 (build-system gnu-build-system)
125 (supported-systems '("i686-linux" "x86_64-linux"))
127 `(("mescc-tools" ,mescc-tools)
128 ("nyacc" ,nyacc-for-mes)))
132 ,@(if (string-prefix? "x86_64-linux" (or (%current-target-system)
134 ;; Use cross-compiler rather than #:system "i686-linux" to get
135 ;; MesCC 64 bit .go files installed ready for use with Guile.
136 `(("i686-linux-binutils" ,(cross-binutils triplet))
137 ("i686-linux-gcc" ,(cross-gcc triplet)))
139 ("graphviz" ,graphviz)
140 ("help2man" ,help2man)
141 ("perl" ,perl) ; build-aux/gitlog-to-changelog
142 ("texinfo" ,texinfo)))
145 (modify-phases %standard-phases
146 (add-before 'build 'make-git-source-writable
147 (lambda* (#:key outputs #:allow-other-keys)
148 (for-each make-file-writable
149 (find-files "." ".*\\.M1"))))
150 (delete 'strip)))) ; binutil's strip b0rkes Mescc/M1/hex2 binaries
151 (synopsis "Scheme interpreter and C compiler for full source bootstrapping")
153 "GNU Mes [Maxwell Equations of Software] aims to create full source
154 bootstrapping for GuixSD. It consists of a mutual self-hosting [close to
155 Guile-] Scheme interpreter prototype in C and a Nyacc-based C compiler in
157 (home-page "https://www.gnu.org/software/mes")
160 (define-public mes.git
161 (let ((version "0.17")
163 (commit (read-string (open-pipe "git show HEAD | head -1 | cut -d ' ' -f 2" OPEN_READ))))
167 (version (string-append version "-" revision "." (string-take commit 7)))
168 (source (local-file %source-dir #:recursive? #t #:select? git-file?)))))