3 MES=${MES-$(dirname $0)/mes}
5 echo '()' | cat $moduledir/mes/base-0.mes $0 /dev/stdin | $MES $MES_FLAGS "$@"
8 ([ -f a.out ] && chmod +x a.out)
12 ;;; Mes --- Maxwell Equations of Software
13 ;;; Copyright © 2016,2017 Jan Nieuwenhuizen <janneke@gnu.org>
15 ;;; This file is part of Mes.
17 ;;; Mes is free software; you can redistribute it and/or modify it
18 ;;; under the terms of the GNU General Public License as published by
19 ;;; the Free Software Foundation; either version 3 of the License, or (at
20 ;;; your option) any later version.
22 ;;; Mes is distributed in the hope that it will be useful, but
23 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
24 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 ;;; GNU General Public License for more details.
27 ;;; You should have received a copy of the GNU General Public License
28 ;;; along with Mes. If not, see <http://www.gnu.org/licenses/>.
32 ;;; mescc.mes is a proof-of-concept simplistic C compiler and linker
37 ;;(mes-use-module (language c compiler))
39 (mes-use-module (mes guile))
40 (mes-use-module (language c99 compiler))
42 (define %datadir (if (string-prefix? "@DATADIR" "@DATADIR@") "" "@DATADIR@"))
43 (define %docdir (if (string-prefix? "@DOCDIR" "@DOCDIR@") "doc/" "@DOCDIR@"))
44 (define %moduledir "module/")
45 (define %prefix (if (string-prefix? "@PREFIX" "@PREFIX@") "" "@PREFIX@"))
46 (define %version (if (string-prefix? "@VERSION" "@VERSION@") "git" "@VERSION@"))
48 (define (main arguments)
49 (let* ((files (cdr arguments))
50 (file (if (null? files) (string-append %docdir "examples/main.c")
52 (with-input-from-file file