2016-12-31 08:03:07 +00:00
|
|
|
#! /bin/sh
|
|
|
|
# -*-scheme-*-
|
2017-04-12 19:27:59 +00:00
|
|
|
GODIR=${GODIR-@GODIR@}
|
|
|
|
MODULEDIR=${MODULEDIR-@MODULEDIR@}
|
|
|
|
[ "$GODIR" = @"GODIR"@ ] && GODIR=guile
|
|
|
|
[ "$MODULEDIR" = @"MODULEDIR"@ ] && MODULEDIR=guile
|
2017-01-17 18:03:08 +00:00
|
|
|
export GUILE_AUTO_COMPILE=${GUILE_AUTO_COMPILE-0}
|
2017-04-12 19:27:59 +00:00
|
|
|
exec ${GUILE-guile} -L $MODULEDIR -C $GODIR -e '(mescc)' -s "$0" "$@"
|
2016-12-31 08:03:07 +00:00
|
|
|
!#
|
|
|
|
|
|
|
|
;;; Mes --- The Maxwell Equations of Software
|
mescc: Run module/base-0.mes.
* gc.c: New file.
* vector.c: New file.
* mes.c: Remove vector and gc functions, include vector.c, gc.c.
* GNUmakefile (mes.o): Add gc, vector dependencies.
* scaffold/mini-mes.c (eval_apply): Support primitive-load through
read_input_file.
(getenv_, open_input_file, current_input_port,
set_current_input_port force_output, exit_, values, arity_, xassq,
is_p, minus, plus, divide, modulo multiply, logior, ash): New function.
(mes_symbols): Add symbols %gnuc, %mesc.
* scaffold/mini-mes.c (): New functions.
* scaffold/b-0.mes: New file.
* scaffold/t-0.mes: New file.
2017-03-26 19:13:01 +00:00
|
|
|
;;; Copyright © 2016,2017 Jan Nieuwenhuizen <janneke@gnu.org>
|
2016-12-31 08:03:07 +00:00
|
|
|
;;;
|
|
|
|
;;; This file is part of GNU Guix.
|
|
|
|
;;;
|
|
|
|
;;; Mes is free software; you can redistribute it and/or modify it
|
|
|
|
;;; under the terms of the GNU General Public License as published by
|
|
|
|
;;; the Free Software Foundation; either version 3 of the License, or (at
|
|
|
|
;;; your option) any later version.
|
|
|
|
;;;
|
|
|
|
;;; Mes is distributed in the hope that it will be useful, but
|
|
|
|
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;;; GNU General Public License for more details.
|
|
|
|
;;;
|
|
|
|
;;; You should have received a copy of the GNU General Public License
|
|
|
|
;;; along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
;; The Maxwell Equations of Software -- John McCarthy page 13
|
|
|
|
;; http://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf
|
|
|
|
|
|
|
|
#!
|
|
|
|
Run with Guile-1.8:
|
|
|
|
GUILE='~/src/guile-1.8/build/pre-inst-guile --debug -q' guile/mescc.scm
|
|
|
|
!#
|
|
|
|
|
|
|
|
(define-module (mescc)
|
|
|
|
#:use-module (language c99 compiler)
|
|
|
|
#:use-module (ice-9 rdelim)
|
|
|
|
#:use-module (ice-9 pretty-print)
|
|
|
|
#:export (main))
|
|
|
|
|
2017-04-02 16:50:07 +00:00
|
|
|
(define %prefix (if (string-prefix? "@PREFIX" "@PREFIX@") "" "@PREFIX@"))
|
|
|
|
(define %datadir (if (string-prefix? "@DATADIR" "@DATADIR@") "" "@DATADIR@"))
|
|
|
|
(define %docdir (if (string-prefix? "@DOCDIR" "@DOCDIR@") "doc/" "@DOCDIR@"))
|
|
|
|
(define %moduledir "module/")
|
|
|
|
(define %version (if (string-prefix? "@VERSION" "@VERSION@") "git" "@VERSION@"))
|
|
|
|
(module-define! (resolve-module '(language c99 compiler)) '%datadir %datadir)
|
|
|
|
(module-define! (resolve-module '(language c99 compiler)) '%docdir %docdir)
|
|
|
|
(module-define! (resolve-module '(language c99 compiler)) '%moduledir %moduledir)
|
|
|
|
(module-define! (resolve-module '(language c99 compiler)) '%prefix %prefix)
|
|
|
|
(module-define! (resolve-module '(language c99 compiler)) '%version %version)
|
|
|
|
|
2016-12-31 08:03:07 +00:00
|
|
|
(define (main arguments)
|
|
|
|
(let* ((files (cdr arguments))
|
2017-04-02 16:50:07 +00:00
|
|
|
(file (if (null? files) (string-append %docdir "examples/main.c")
|
2016-12-31 08:03:07 +00:00
|
|
|
(car files))))
|
2017-04-04 07:53:05 +00:00
|
|
|
(cond ((equal? file "--help")
|
|
|
|
(format (current-error-port) "Usage: mescc.scm [--help|--version|FILE] > a.out\n")
|
|
|
|
(exit 0))
|
|
|
|
((equal? file "--version")
|
|
|
|
(format (current-error-port) "mescc.scm (mes) ~a\n" %version)
|
|
|
|
(exit 0)))
|
mescc: Parse mlibc early, show progress.
* module/mes/libc.mes (_start, strlen, getchar, assert_fail, ungetc,
putchar, fputc, eputs, fputs, puts, strcmp, itoa, isdigit, atoi,
malloc, realloc, strncmp, c:getenv): Change to function, add
progress. Update callers.
* module/language/c99/compiler.mes (c99-input->info): Compile libc separately.
* guile/mescc.scm: Update progress.
* scripts/mescc.mes: Update progress.
2017-04-24 17:09:54 +00:00
|
|
|
(format (current-error-port) "input: ~a\n" file)
|
2016-12-31 08:03:07 +00:00
|
|
|
(with-input-from-file file
|
2017-04-12 19:27:59 +00:00
|
|
|
c99-input->elf)))
|
mescc: Parse mlibc early, show progress.
* module/mes/libc.mes (_start, strlen, getchar, assert_fail, ungetc,
putchar, fputc, eputs, fputs, puts, strcmp, itoa, isdigit, atoi,
malloc, realloc, strncmp, c:getenv): Change to function, add
progress. Update callers.
* module/language/c99/compiler.mes (c99-input->info): Compile libc separately.
* guile/mescc.scm: Update progress.
* scripts/mescc.mes: Update progress.
2017-04-24 17:09:54 +00:00
|
|
|
|
|
|
|
(format (current-error-port) "compiler loaded\n")
|
|
|
|
(format (current-error-port) "calling ~s\n" (cons 'main (command-line)))
|