4 GUILEDIR=${GUILEDIR-@GUILEDIR@}
5 [ "$GODIR" = @"GODIR"@ ] && GODIR=guile
6 [ "$GUILEDIR" = @"GUILEDIR"@ ] && GUILEDIR=guile
7 export GUILE_AUTO_COMPILE=${GUILE_AUTO_COMPILE-0}
8 exec ${GUILE-guile} -L $GUILEDIR -C $GODIR -e '(mescc)' -s "$0" "$@"
11 ;;; Mes --- The Maxwell Equations of Software
12 ;;; Copyright © 2016,2017 Jan Nieuwenhuizen <janneke@gnu.org>
14 ;;; This file is part of GNU Guix.
16 ;;; Mes is free software; you can redistribute it and/or modify it
17 ;;; under the terms of the GNU General Public License as published by
18 ;;; the Free Software Foundation; either version 3 of the License, or (at
19 ;;; your option) any later version.
21 ;;; Mes is distributed in the hope that it will be useful, but
22 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
23 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 ;;; GNU General Public License for more details.
26 ;;; You should have received a copy of the GNU General Public License
27 ;;; along with Mes. If not, see <http://www.gnu.org/licenses/>.
29 ;; The Maxwell Equations of Software -- John McCarthy page 13
30 ;; http://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf
34 GUILE='~/src/guile-1.8/build/pre-inst-guile --debug -q' guile/mescc.scm
37 (define-module (mescc)
38 #:use-module (language c99 compiler)
39 #:use-module (ice-9 rdelim)
40 #:use-module (ice-9 pretty-print)
43 (define %prefix (if (string-prefix? "@PREFIX" "@PREFIX@") "" "@PREFIX@"))
44 (define %datadir (if (string-prefix? "@DATADIR" "@DATADIR@") "" "@DATADIR@"))
45 (define %docdir (if (string-prefix? "@DOCDIR" "@DOCDIR@") "doc/" "@DOCDIR@"))
46 (define %moduledir "module/")
47 (define %version (if (string-prefix? "@VERSION" "@VERSION@") "git" "@VERSION@"))
48 (module-define! (resolve-module '(language c99 compiler)) '%datadir %datadir)
49 (module-define! (resolve-module '(language c99 compiler)) '%docdir %docdir)
50 (module-define! (resolve-module '(language c99 compiler)) '%moduledir %moduledir)
51 (module-define! (resolve-module '(language c99 compiler)) '%prefix %prefix)
52 (module-define! (resolve-module '(language c99 compiler)) '%version %version)
54 (define (main arguments)
55 (let* ((files (cdr arguments))
56 (file (if (null? files) (string-append %docdir "examples/main.c")
58 (cond ((equal? file "--help")
59 (format (current-error-port) "Usage: mescc.scm [--help|--version|FILE] > a.out\n")
61 ((equal? file "--version")
62 (format (current-error-port) "mescc.scm (mes) ~a\n" %version)
64 (format (current-error-port) "input: ~a\n" file)
65 (with-input-from-file file
68 (format (current-error-port) "compiler loaded\n")
69 (format (current-error-port) "calling ~s\n" (cons 'main (command-line)))