build: Update Guix build and install.
* guix.scm (%source-dir): New variable. (git-file?): New function. (mes): Use them to simplify building/installing from git. * make/install.make (READMES): Add INSTALL, README. * (install): Install mescc.scm and read-0-32.mo.
This commit is contained in:
parent
8f09f1a5cf
commit
b4a4e39050
53
GNUmakefile
53
GNUmakefile
|
@ -1,3 +1,5 @@
|
|||
SHELL:=bash
|
||||
|
||||
.PHONY: all check clean default distclean help install release
|
||||
default: all
|
||||
|
||||
|
@ -15,8 +17,16 @@ CFLAGS:=-std=c99 -O3 -finline-functions
|
|||
include .config.make
|
||||
include make/install.make
|
||||
|
||||
MACHINE:=$(shell $(CC) -dumpmachine)
|
||||
##CC:=gcc
|
||||
LIBRARY_PATH=:$(dir $(shell type -p ldd))../lib
|
||||
CC:=LIBRARY_PATH=$(LIBRARY_PATH) gcc
|
||||
|
||||
CPPFLAGS+=-I.
|
||||
CPPFLAGS+=-DPREFIX='"$(PREFIX)"'
|
||||
CPPFLAGS+=-DDATADIR='"$(DATADIR)/"'
|
||||
CPPFLAGS+=-DDOCDIR='"$(DOCDIR)/"'
|
||||
CPPFLAGS+=-DMODULEDIR='"$(MODULEDIR)/"'
|
||||
CPPFLAGS+=-DPREFIX='"$(PREFIX)/"'
|
||||
CPPFLAGS+=-DVERSION='"$(VERSION)"'
|
||||
|
||||
export BOOT
|
||||
|
@ -28,6 +38,10 @@ endif
|
|||
|
||||
all: mes module/mes/read-0.mo module/mes/read-0-32.mo
|
||||
|
||||
ifeq ($(MES_BOOTSTRAP),mes-mini-mes)
|
||||
all: mes-mini-mes
|
||||
endif
|
||||
|
||||
S:=
|
||||
mes.o$(S): GNUmakefile
|
||||
mes.o$(S): mes.c
|
||||
|
@ -89,13 +103,16 @@ export MES_FLAGS
|
|||
MES_DEBUG:=1
|
||||
#export MES_DEBUG
|
||||
|
||||
export C_INCLUDE_PATH
|
||||
|
||||
mes-check: all
|
||||
set -e; for i in $(TESTS); do ./$$i; done
|
||||
set -e; for i in $(TESTS); do MES_MAX_ARENA=20000000 ./$$i; done
|
||||
|
||||
mini-mes-check: all mini-mes
|
||||
$(MAKE) mes-check MES=./mini-mes
|
||||
|
||||
module/mes/read-0.mo: module/mes/read-0.mes mes
|
||||
rm -f $@
|
||||
./mes --dump < $< > $@
|
||||
|
||||
dump: module/mes/read-0.mo
|
||||
|
@ -106,16 +123,23 @@ mes.o$(S): mes.c
|
|||
mes$(S): mes.o$(S)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
|
||||
|
||||
ifeq ($(MACHINE),i686-unknown-linux-gnu)
|
||||
mes-32: mes
|
||||
ln -f $< $@
|
||||
else
|
||||
mes$(S)-32: GNUmakefile
|
||||
mes$(S)-32: mes.c gc.c lib.c math.c posix.c vector.c
|
||||
guix environment --system=i686-linux --ad-hoc gcc-toolchain -- bash -c 'make mes-32 S=-32 CC=i686-unknown-linux-gnu-gcc LIBRARY_PATH=$${PATH%%/bin:*}/lib'
|
||||
endif
|
||||
|
||||
module/mes/read-0-32.mo: module/mes/read-0.mes
|
||||
module/mes/read-0-32.mo: module/mes/read-0.mo
|
||||
module/mes/read-0-32.mo: mes-32
|
||||
rm -f $@
|
||||
MES_MINI=1 ./mes-32 --dump < $< > $@
|
||||
|
||||
module/mes/tiny-0-32.mo: module/mes/tiny-0.mes mes-32
|
||||
rm -f $@
|
||||
MES_TINY=1 ./mes-32 --dump < $< > $@
|
||||
|
||||
guile-check:
|
||||
|
@ -160,6 +184,7 @@ guile-mini-mes: mlibc.c mstart.c
|
|||
guile-mini-mes: GNUmakefile
|
||||
guile-mini-mes: module/mes/read-0-32.mo
|
||||
guile-mini-mes: scaffold/mini-mes.c
|
||||
rm -f $@
|
||||
guile/mescc.scm $< > $@ || rm -f $@
|
||||
chmod +x $@
|
||||
|
||||
|
@ -170,43 +195,52 @@ mes-mini-mes: mlibc.c mstart.c
|
|||
mes-mini-mes: GNUmakefile
|
||||
mes-mini-mes: module/mes/read-0-32.mo
|
||||
mes-mini-mes: scaffold/mini-mes.c
|
||||
rm -f $@
|
||||
# MES_FLAGS= MES_DEBUG=1 scripts/mescc.mes $< > $@ || rm -f $@
|
||||
MES_FLAGS= MES_DEBUG=1 scripts/mescc.mes $< > $@
|
||||
chmod +x $@
|
||||
|
||||
mes-hello: GNUmakefile
|
||||
mes-hello: mlibc.c mstart.c
|
||||
mes-hello: module/mes/read-0-32.mo
|
||||
mes-hello: scaffold/hello.c
|
||||
rm -f $@
|
||||
MES_FLAGS= MES_DEBUG=1 scripts/mescc.mes $< > $@ || rm -f $@
|
||||
chmod +x $@
|
||||
|
||||
cons-mes: module/mes/tiny-0-32.mo
|
||||
cons-mes: scaffold/cons-mes.c GNUmakefile
|
||||
rm -f $@
|
||||
gcc -nostdlib --std=gnu99 -m32 -g -o $@ $(CPPFLAGS) $<
|
||||
chmod +x $@
|
||||
|
||||
guile-cons-mes: module/mes/tiny-0-32.mo
|
||||
guile-cons-mes: scaffold/cons-mes.c
|
||||
rm -f $@
|
||||
guile/mescc.scm $< > $@ || rm -f $@
|
||||
chmod +x $@
|
||||
|
||||
tiny-mes: module/mes/tiny-0-32.mo
|
||||
tiny-mes: scaffold/tiny-mes.c GNUmakefile
|
||||
rm -f $@
|
||||
gcc -nostdlib --std=gnu99 -m32 -g -o $@ $(CPPFLAGS) $<
|
||||
chmod +x $@
|
||||
|
||||
guile-tiny-mes: module/mes/tiny-0-32.mo
|
||||
guile-tiny-mes: scaffold/tiny-mes.c
|
||||
rm -f $@
|
||||
guile/mescc.scm $< > $@ || rm -f $@
|
||||
chmod +x $@
|
||||
|
||||
m: scaffold/m.c GNUmakefile
|
||||
rm -f $@
|
||||
gcc -nostdlib --std=gnu99 -m32 -g -o $@ $(CPPFLAGS) $<
|
||||
# gcc --std=gnu99 -g -o $@ $(CPPFLAGS) $<
|
||||
chmod +x $@
|
||||
|
||||
guile-m: scaffold/m.c
|
||||
rm -f $@
|
||||
guile/mescc.scm $< > $@ || rm -f $@
|
||||
chmod +x $@
|
||||
|
||||
malloc: scaffold/malloc.c GNUmakefile
|
||||
rm -f $@
|
||||
gcc -nostdlib --std=gnu99 -m32 -g -o $@ $(CPPFLAGS) $<
|
||||
chmod +x $@
|
||||
|
||||
|
@ -244,13 +278,14 @@ guile-t: scaffold/t.c
|
|||
|
||||
MAIN_C:=doc/examples/main.c
|
||||
mescc: all $(MAIN_C)
|
||||
mescc: doc/examples/main.c all
|
||||
rm -f a.out
|
||||
scripts/mescc.mes $(MAIN_C) > a.out
|
||||
MES_DEBUG=1 scripts/mescc.mes $< > a.out
|
||||
./a.out; r=$$?; [ $$r = 42 ]
|
||||
|
||||
guile-mescc: $(MAIN_C)
|
||||
guile-mescc: doc/examples/main.c
|
||||
rm -f a.out
|
||||
guile/mescc.scm $(MAIN_C) > a.out
|
||||
guile/mescc.scm $< > a.out
|
||||
chmod +x a.out
|
||||
./a.out; r=$$?; [ $$r = 42 ]
|
||||
|
||||
|
|
5
configure
vendored
5
configure
vendored
|
@ -55,6 +55,7 @@ exec ${GUILE} --no-auto-compile -L $(pwd) -e '(@@ (configure) main)' -s "$0" ${1
|
|||
(define PREFIX "/usr/local")
|
||||
(define GUILE_EV (effective-version))
|
||||
(define CC (or (getenv "CC") "gcc"))
|
||||
(define CC32 (or (getenv "CC32") "i686-unknown-linux-gnu-gcc"))
|
||||
(define GUILE (or (getenv "guile") "guile"))
|
||||
(define SYSCONFDIR "$(PREFIX)/etc")
|
||||
|
||||
|
@ -107,6 +108,7 @@ exec ${GUILE} --no-auto-compile -L $(pwd) -e '(@@ (configure) main)' -s "$0" ${1
|
|||
(and-let* ((version (string-tokenize string
|
||||
(char-set-adjoin char-set:digit #\.)))
|
||||
((pair? version))
|
||||
(version (sort version (lambda (a b) (> (string-length a) (string-length b)))))
|
||||
(version (car version))
|
||||
(version (string-tokenize version
|
||||
(char-set-complement (char-set #\.)))))
|
||||
|
@ -182,6 +184,7 @@ Usage: ./configure [OPTION]...
|
|||
(sysconfdir (option-ref options 'sysconfdir SYSCONFDIR)))
|
||||
(check-version 'bash '(4 0))
|
||||
(check-version 'gcc '(4 8))
|
||||
(check-version 'i686-unknown-linux-gnu-gcc '(4 8))
|
||||
(check-version 'guile '(2 0))
|
||||
(check-version 'make '(4 0))
|
||||
(check-version 'perl '(5))
|
||||
|
@ -195,8 +198,10 @@ Usage: ./configure [OPTION]...
|
|||
(with-output-to-file ".config.make"
|
||||
(lambda ()
|
||||
(stdout "CC:=~a\n" CC)
|
||||
(stdout "CC32:=~a\n" CC32)
|
||||
(stdout "GUILE:=~a\n" GUILE)
|
||||
(stdout "GUILE_EV:=~a\n" GUILE_EV)
|
||||
(stdout "GUIX_P:=~a\n" (if guix? guix? ""))
|
||||
(stdout "PACKAGE:=~a\n" PACKAGE)
|
||||
(stdout "VERSION:=~a\n" VERSION)
|
||||
(stdout "PREFIX:=~a\n" (gulp-pipe (string-append "echo " prefix)))
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#! /bin/sh
|
||||
# -*-scheme-*-
|
||||
DATADIR=${DATADIR-@DATADIR@}
|
||||
[ "$DATADIR" = @"DATADIR"@ ] && DATADIR=.
|
||||
export GUILE_AUTO_COMPILE=${GUILE_AUTO_COMPILE-0}
|
||||
exec ${GUILE-guile} -L $(pwd)/guile -e '(mescc)' -s "$0" "$@"
|
||||
exec ${GUILE-guile} -L $DATADIR/guile -e '(mescc)' -s "$0" "$@"
|
||||
!#
|
||||
|
||||
;;; Mes --- The Maxwell Equations of Software
|
||||
|
@ -36,9 +38,20 @@ GUILE='~/src/guile-1.8/build/pre-inst-guile --debug -q' guile/mescc.scm
|
|||
#:use-module (ice-9 pretty-print)
|
||||
#:export (main))
|
||||
|
||||
(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)
|
||||
|
||||
(define (main arguments)
|
||||
(let* ((files (cdr arguments))
|
||||
(file (if (null? files) "doc/examples/main.c"
|
||||
(file (if (null? files) (string-append %docdir "examples/main.c")
|
||||
(car files))))
|
||||
(with-input-from-file file
|
||||
compile)))
|
||||
|
|
|
@ -1,89 +0,0 @@
|
|||
#! /bin/sh
|
||||
# -*-scheme-*-
|
||||
export GUILE_AUTO_COMPILE=0
|
||||
exec ${GUILE-guile} -L $(pwd)/guile -e '(nyacc)' -s "$0" "$@"
|
||||
!#
|
||||
|
||||
;;; Mes --- The Maxwell Equations of Software
|
||||
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;;
|
||||
;;; 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/nyacc.scm
|
||||
!#
|
||||
|
||||
;; Tcalc.scm - calculator
|
||||
;;
|
||||
;; Copyright (C) 2015 Matthew R. Wette
|
||||
;;
|
||||
;; Copying and distribution of this file, with or without modification,
|
||||
;; are permitted in any medium without royalty provided the copyright
|
||||
;; notice and this notice are preserved. This file is offered as-is,
|
||||
;; without any warranty.
|
||||
|
||||
(cond-expand
|
||||
(guile-2)
|
||||
(guile
|
||||
(use-modules (ice-9 syncase))
|
||||
(use-modules (ice-9 optargs))))
|
||||
|
||||
(define-module (nyacc)
|
||||
#:use-module (nyacc lalr)
|
||||
#:use-module (nyacc lex)
|
||||
#:use-module (nyacc parse)
|
||||
#:use-module (ice-9 rdelim)
|
||||
#:use-module (ice-9 pretty-print)
|
||||
#:export (main))
|
||||
|
||||
(define simple-spec
|
||||
(lalr-spec
|
||||
(prec< (left "+" "-") (left "*" "/"))
|
||||
(start expr)
|
||||
(grammar
|
||||
(expr
|
||||
(expr "+" expr ($$ (+ $1 $3)))
|
||||
(expr "-" expr ($$ (- $1 $3)))
|
||||
(expr "*" expr ($$ (* $1 $3)))
|
||||
(expr "/" expr ($$ (/ $1 $3)))
|
||||
("*" $error)
|
||||
($fixed ($$ (string->number $1)))
|
||||
($float ($$ (string->number $1)))
|
||||
("(" expr ")" ($$ $2))))))
|
||||
|
||||
(define simple-mach (make-lalr-machine simple-spec))
|
||||
;; OR
|
||||
;; (use-modules (nyacc bison))
|
||||
;; (define simple-mach (make-lalr-machine/bison simple-spec))
|
||||
|
||||
(define match-table (assq-ref simple-mach 'mtab))
|
||||
|
||||
(define gen-lexer (make-lexer-generator match-table))
|
||||
|
||||
(define parse (make-lalr-parser simple-mach))
|
||||
|
||||
(define demo-string "2 + 2")
|
||||
|
||||
(define (main arguments)
|
||||
(display demo-string)
|
||||
(display " => ")
|
||||
(display (with-input-from-string demo-string
|
||||
(lambda () (parse (gen-lexer)))))
|
||||
(newline))
|
|
@ -1,50 +0,0 @@
|
|||
#! /bin/sh
|
||||
# -*-scheme-*-
|
||||
export GUILE_AUTO_COMPILE=0
|
||||
exec ${GUILE-guile} -L $(pwd)/guile -e '(nyacc)' -s "$0" "$@"
|
||||
!#
|
||||
|
||||
;;; Mes --- The Maxwell Equations of Software
|
||||
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;;
|
||||
;;; 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/nyacc.scm
|
||||
!#
|
||||
|
||||
(cond-expand
|
||||
(guile-2)
|
||||
(guile
|
||||
(use-modules (ice-9 syncase))
|
||||
(use-modules (ice-9 optargs))))
|
||||
|
||||
(define-module (nyacc)
|
||||
#:use-module (nyacc lang c99 parser)
|
||||
#:use-module (ice-9 rdelim)
|
||||
#:use-module (ice-9 pretty-print)
|
||||
#:export (main))
|
||||
|
||||
(define (main arguments)
|
||||
(let* ((file (if (> (length arguments) 1) (cadr arguments)
|
||||
"doc/examples/main.c"))
|
||||
(ast (with-input-from-file file
|
||||
(lambda () (parse-c99 #:inc-dirs '())))))
|
||||
(pretty-print ast)))
|
67
guix.scm
67
guix.scm
|
@ -2,6 +2,11 @@
|
|||
|
||||
;;; Mes --- Maxwell Equations of Software
|
||||
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
|
||||
;;; Also borrowing code from:
|
||||
;;; guile-sdl2 --- FFI bindings for SDL2
|
||||
;;; Copyright © 2015 David Thompson <davet@gnu.org>
|
||||
|
||||
;;;
|
||||
;;; guix.scm: This file is part of Mes.
|
||||
;;;
|
||||
|
@ -34,36 +39,62 @@
|
|||
;;
|
||||
;;; Code:
|
||||
|
||||
(use-modules (gnu packages)
|
||||
(use-modules (srfi srfi-1)
|
||||
(srfi srfi-26)
|
||||
(ice-9 match)
|
||||
(ice-9 popen)
|
||||
(ice-9 rdelim)
|
||||
(gnu packages)
|
||||
(gnu packages base)
|
||||
(gnu packages commencement)
|
||||
(gnu packages gcc)
|
||||
(gnu packages guile)
|
||||
(gnu packages package-management)
|
||||
(gnu packages perl)
|
||||
(gnu packages version-control)
|
||||
((guix build utils) #:select (with-directory-excursion))
|
||||
(guix build-system gnu)
|
||||
(guix build-system trivial)
|
||||
(guix gexp)
|
||||
(guix git-download)
|
||||
(guix licenses)
|
||||
(guix packages)
|
||||
(guix build-system gnu))
|
||||
(guix packages))
|
||||
|
||||
(define %source-dir (dirname (current-filename)))
|
||||
|
||||
(define git-file?
|
||||
(let* ((pipe (with-directory-excursion %source-dir
|
||||
(open-pipe* OPEN_READ "git" "ls-files")))
|
||||
(files (let loop ((lines '()))
|
||||
(match (read-line pipe)
|
||||
((? eof-object?)
|
||||
(reverse lines))
|
||||
(line
|
||||
(loop (cons line lines))))))
|
||||
(status (close-pipe pipe)))
|
||||
(lambda (file stat)
|
||||
(match (stat:type stat)
|
||||
('directory #t)
|
||||
((or 'regular 'symlink)
|
||||
(any (cut string-suffix? <> file) files))
|
||||
(_ #f)))))
|
||||
|
||||
(define-public mes
|
||||
(package
|
||||
(name "mes")
|
||||
(version "0.4.f84e97fc")
|
||||
(source (origin
|
||||
(method git-fetch)
|
||||
(uri (git-reference
|
||||
(url "https://gitlab.com/janneke/mes")
|
||||
(commit "f84e97fc33f5e2a2ad7033795967d44c95d34b8f")))
|
||||
(file-name (string-append name "-" version))
|
||||
(sha256
|
||||
(base32 "1jpm8m8y2dqsl3sc6flf8da4rpdrqh6zgr2mghzjw0lg34v1r21j"))))
|
||||
(version "git")
|
||||
(source (local-file %source-dir #:recursive? #t #:select? git-file?))
|
||||
(build-system gnu-build-system)
|
||||
(native-inputs
|
||||
`(("git" ,git)
|
||||
("guile" ,guile-2.0)
|
||||
("guile" ,guile-2.2)
|
||||
("gcc" ,gcc-toolchain-4.9)
|
||||
("perl" ,perl))) ; build-aux/gitlog-to-changelog
|
||||
(supported-systems '("i686-linux"))
|
||||
(arguments
|
||||
`(#:phases
|
||||
`(#:system "i686-linux"
|
||||
;;#:make-flags '("MES_BOOTSTRAP=mes-mes")
|
||||
#:phases
|
||||
(modify-phases %standard-phases
|
||||
(add-before 'install 'generate-changelog
|
||||
(lambda _
|
||||
|
@ -73,10 +104,10 @@
|
|||
#t)))))
|
||||
(synopsis "Maxwell Equations of Software")
|
||||
(description
|
||||
"Mes aims to create an entirely source-based bootstrapping path.
|
||||
The target is to [have GuixSD] boostrap from a minimal, easily
|
||||
inspectable binary --that should be readable as source-- into
|
||||
something close to R6RS Scheme.")
|
||||
"Mes aims to create full source bootstrapping for GuixSD: an
|
||||
entirely source-based bootstrap path. The target is to [have GuixSD]
|
||||
boostrap from a minimal, easily inspectable binary --that should be
|
||||
readable as source-- into something close to R6RS Scheme.")
|
||||
(home-page "https://gitlab.com/janneke/mes")
|
||||
(license gpl3+)))
|
||||
|
||||
|
|
4
lib.c
4
lib.c
|
@ -322,7 +322,7 @@ load_env (SCM a) ///((internal))
|
|||
{
|
||||
r0 = a;
|
||||
g_stdin = open ("module/mes/read-0.mes", O_RDONLY);
|
||||
g_stdin = g_stdin ? g_stdin : open (PREFIX "module/mes/read-0.mes", O_RDONLY);
|
||||
g_stdin = g_stdin >= 0 ? g_stdin : open (MODULEDIR "mes/read-0.mes", O_RDONLY);
|
||||
if (!g_function) r0 = mes_builtins (r0);
|
||||
r2 = read_input_file_env (r0);
|
||||
g_stdin = STDIN;
|
||||
|
@ -336,7 +336,7 @@ bload_env (SCM a) ///((internal))
|
|||
g_stdin = fopen ("module/mes/read-0-32.mo", O_RDONLY);
|
||||
#else
|
||||
g_stdin = open ("module/mes/read-0.mo", O_RDONLY);
|
||||
g_stdin = g_stdin ? g_stdin : open (PREFIX "module/mes/read-0.mo", O_RDONLY);
|
||||
g_stdin = g_stdin >= 0 ? g_stdin : open (MODULEDIR "mes/read-0.mo", O_RDONLY);
|
||||
#endif
|
||||
|
||||
char *p = (char*)g_cells;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
.PHONY: tree-clean-p
|
||||
|
||||
READMES:=\
|
||||
ANNOUNCE\
|
||||
ANNOUNCE-2\
|
||||
AUTHORS\
|
||||
COPYING\
|
||||
HACKING\
|
||||
INSTALL\
|
||||
NEWS\
|
||||
README\
|
||||
#
|
||||
|
||||
COMMIT:=$(shell test -d .git && (git show 2>/dev/null | head -1 | cut -d' ' -f 2) || cat .tarball-version)
|
||||
|
@ -18,11 +18,20 @@ OPT_CLEAN:=$(OPT_CLEAN) $(TARBALL) .tarball-version
|
|||
|
||||
GIT_ARCHIVE_HEAD:=git archive HEAD --
|
||||
GIT_LS_FILES:=git ls-files
|
||||
ifeq ($(wildcard .git),)
|
||||
ifeq ($(wildcard .git/HEAD),)
|
||||
GIT_ARCHIVE_HEAD:=tar -cf-
|
||||
GIT_LS_FILES:=find
|
||||
endif
|
||||
|
||||
ifeq ($(GUIX),)
|
||||
DATADIR:=$(PREFIX)/share/mes
|
||||
DOCDIR:=$(DATADIR)/doc/mes
|
||||
else
|
||||
DATADIR:=$(PREFIX)/share
|
||||
DOCDIR:=$(DATADIR)/doc
|
||||
endif
|
||||
MODULEDIR:=$(DATADIR)/module
|
||||
|
||||
.tarball-version: tree-clean-p
|
||||
echo $(COMMIT) > $@
|
||||
|
||||
|
@ -45,22 +54,33 @@ ChangeLog:
|
|||
install: all ChangeLog
|
||||
mkdir -p $(DESTDIR)$(PREFIX)/bin
|
||||
install mes $(DESTDIR)$(PREFIX)/bin/mes
|
||||
install mes-mini-mes $(DESTDIR)$(PREFIX)/bin/mes-mini-mes
|
||||
install scripts/mescc.mes $(DESTDIR)$(PREFIX)/bin/mescc.mes
|
||||
install scripts/repl.mes $(DESTDIR)$(PREFIX)/bin/repl.mes
|
||||
mkdir -p $(DESTDIR)$(PREFIX)/share/mes
|
||||
install guile/mescc.scm $(DESTDIR)$(PREFIX)/bin/mescc.scm
|
||||
mkdir -p $(DESTDIR)$(DATADIR)
|
||||
$(GIT_ARCHIVE_HEAD) module\
|
||||
| tar -C $(DESTDIR)$(PREFIX)/share/mes -xf-
|
||||
cp module/mes/read-0.mo $(DESTDIR)$(PREFIX)/share/mes/module/mes
|
||||
sed -i -e 's@module/@$(PREFIX)/share/mes/module/@' \
|
||||
$(DESTDIR)$(PREFIX)/share/mes/module/mes/base-0.mes \
|
||||
| tar -C $(DESTDIR)$(DATADIR) -xf-
|
||||
$(GIT_ARCHIVE_HEAD) guile\
|
||||
| tar -C $(DESTDIR)$(DATADIR) -xf-
|
||||
sed -i \
|
||||
-e 's,module/,$(DATADIR)/module/,' \
|
||||
-e 's,@DATADIR@,$(DATADIR)/,g' \
|
||||
-e 's,@DOCDIR@,$(DOCDIR)/,g' \
|
||||
-e 's,@PREFIX@,$(PREFIX)/,g' \
|
||||
-e 's,@VERSION@,$(VERSION),g' \
|
||||
$(DESTDIR)$(DATADIR)/module/mes/base-0.mes \
|
||||
$(DESTDIR)$(PREFIX)/bin/mescc.mes \
|
||||
$(DESTDIR)$(PREFIX)/bin/repl.mes \
|
||||
mkdir -p $(DESTDIR)$(PREFIX)/share/doc/mes
|
||||
$(DESTDIR)$(PREFIX)/bin/mescc.scm \
|
||||
$(DESTDIR)$(PREFIX)/bin/repl.mes
|
||||
cp module/mes/read-0.mo $(DESTDIR)$(DATADIR)/module/mes
|
||||
cp module/mes/read-0-32.mo $(DESTDIR)$(DATADIR)/module/mes
|
||||
mkdir -p $(DESTDIR)$(DOCDIR)
|
||||
$(GIT_ARCHIVE_HEAD) $(READMES) \
|
||||
| tar -C $(DESTDIR)$(PREFIX)/share/doc/mes -xf-
|
||||
| tar -C $(DESTDIR)$(DOCDIR) -xf-
|
||||
$(GIT_ARCHIVE_HEAD) doc \
|
||||
| tar -C $(DESTDIR)$(PREFIX)/share/doc/mes --strip=1 -xf-
|
||||
cp ChangeLog $(DESTDIR)$(PREFIX)/share/doc/mes
|
||||
| tar -C $(DESTDIR)$(DOCDIR) --strip=1 -xf-
|
||||
cp ChangeLog $(DESTDIR)$(DOCDIR)
|
||||
|
||||
release: tree-clean-p check dist
|
||||
git tag v$(VERSION)
|
||||
|
|
2
mes.c
2
mes.c
|
@ -1093,8 +1093,10 @@ main (int argc, char *argv[])
|
|||
{
|
||||
#if __GNUC__
|
||||
g_debug = getenv ("MES_DEBUG");
|
||||
if (g_debug) {eputs ("MODULEDIR=");eputs (MODULEDIR);eputs ("\n");}
|
||||
#endif
|
||||
if (getenv ("MES_ARENA")) ARENA_SIZE = atoi (getenv ("MES_ARENA"));
|
||||
if (getenv ("MES_MAX_ARENA")) MAX_ARENA_SIZE = atoi (getenv ("MES_MAX_ARENA"));
|
||||
if (argc > 1 && !strcmp (argv[1], "--help")) return puts ("Usage: mes [--dump|--load] < FILE");
|
||||
if (argc > 1 && !strcmp (argv[1], "--version")) {puts ("Mes ");puts (VERSION);return 0;};
|
||||
g_stdin = STDIN;
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
(define (mescc)
|
||||
(parse-c99
|
||||
#:inc-dirs (string-split (getenv "C_INCLUDE_PATH") #\:)
|
||||
#:cpp-defs '(
|
||||
#:cpp-defs `(
|
||||
"_POSIX_SOURCE=0"
|
||||
"__GNUC__=0"
|
||||
"__MESC__=1"
|
||||
|
@ -62,8 +62,11 @@
|
|||
"INT_MIN=-2147483648"
|
||||
"INT_MAX=2147483647"
|
||||
|
||||
"VERSION=\"0.4\""
|
||||
"PREFIX=\"\""
|
||||
,(string-append "DATADIR=\"" %datadir "\"")
|
||||
,(string-append "DOCDIR=\"" %docdir "\"")
|
||||
,(string-append "PREFIX=\"" %prefix "\"")
|
||||
,(string-append "MODULEDIR=\"" %moduledir "\"")
|
||||
,(string-append "VERSION=\"" %version "\"")
|
||||
)
|
||||
#:mode 'code))
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
|
||||
;;; Code:
|
||||
|
||||
(define (effective-version) %version)
|
||||
(define mes? #t)
|
||||
(define guile? #f)
|
||||
(define guile-1.8? #f)
|
||||
|
@ -107,8 +106,6 @@
|
|||
(list 'set-current-input-port (list 'pop! '*input-ports*))))
|
||||
|
||||
(define include load)
|
||||
(define-macro (include-from-path file)
|
||||
(list 'load (list string-append "module/" file)))
|
||||
|
||||
(define (append . rest)
|
||||
(if (null? rest) '()
|
||||
|
@ -117,6 +114,25 @@
|
|||
|
||||
(include "module/mes/type-0.mes")
|
||||
|
||||
(define (symbol->string s)
|
||||
(apply string (symbol->list s)))
|
||||
|
||||
(define (string-append . rest)
|
||||
(apply string (apply append (map1 string->list rest))))
|
||||
|
||||
(define %moduledir "module/")
|
||||
(define %version (if (eq? (car (string->list "@VERSION@")) #\@) "git" "@VERSION@"))
|
||||
(define (effective-version) %version)
|
||||
|
||||
(if (getenv "MES_DEBUG")
|
||||
(begin
|
||||
(core:display-error "%moduledir=")
|
||||
(core:display-error %moduledir)
|
||||
(core:display-error "\n")))
|
||||
|
||||
(define-macro (include-from-path file)
|
||||
(list 'load (list string-append %moduledir file)))
|
||||
|
||||
(define (memq x lst)
|
||||
(if (null? lst) #f
|
||||
(if (eq? x (car lst)) lst
|
||||
|
@ -126,14 +142,13 @@
|
|||
(if (null? (cdr lst)) (car lst)
|
||||
(string-append (car lst) infix (string-join (cdr lst) infix))))
|
||||
|
||||
(define *mes-prefix* "module/")
|
||||
(define (module->file o)
|
||||
(string-append (string-join (map1 symbol->string o) "/") ".mes"))
|
||||
|
||||
(define *modules* '(mes/base-0.mes))
|
||||
(define (mes-load-module-env module a)
|
||||
(push! *input-ports* (current-input-port))
|
||||
(set-current-input-port (open-input-file (string-append *mes-prefix* (module->file module))))
|
||||
(set-current-input-port (open-input-file (string-append %moduledir (module->file module))))
|
||||
(let ((x (core:eval (append2 (cons 'begin (read-input-file-env a))
|
||||
'((current-module)))
|
||||
a)))
|
||||
|
@ -148,7 +163,7 @@
|
|||
(list
|
||||
'begin
|
||||
(list 'set! '*modules* (list cons (list string->symbol (module->file module)) '*modules*))
|
||||
(list 'load (list string-append '*mes-prefix* (module->file module)))))))
|
||||
(list 'load (list string-append '%moduledir (module->file module)))))))
|
||||
|
||||
(mes-use-module (mes base))
|
||||
(mes-use-module (srfi srfi-0))
|
||||
|
|
Binary file not shown.
|
@ -1,7 +1,7 @@
|
|||
;;; -*-scheme-*-
|
||||
|
||||
;;; Mes --- Maxwell Equations of Software
|
||||
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;; Copyright © 2016,2017 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;;
|
||||
;;; This file is part of Mes.
|
||||
;;;
|
||||
|
@ -135,12 +135,6 @@
|
|||
(define (keyword->list s)
|
||||
(core:car s))
|
||||
|
||||
(define (symbol->string s)
|
||||
(apply string (symbol->list s)))
|
||||
|
||||
(define (string-append . rest)
|
||||
(apply string (apply append (map1 string->list rest))))
|
||||
|
||||
(define (integer->char x)
|
||||
(core:make-cell <cell:character> 0 x))
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#! /bin/sh
|
||||
# -*-scheme-*-
|
||||
MES=${MES-$(dirname $0)/mes}
|
||||
prefix=module/
|
||||
echo '()' | cat $prefix/mes/base-0.mes $0 /dev/stdin | $MES $MES_FLAGS "$@"
|
||||
moduledir=module/
|
||||
echo '()' | cat $moduledir/mes/base-0.mes $0 /dev/stdin | $MES $MES_FLAGS "$@"
|
||||
#paredit:||
|
||||
r=$?
|
||||
([ -f a.out ] && chmod +x a.out)
|
||||
|
@ -39,9 +39,15 @@ exit $r
|
|||
(mes-use-module (mes guile))
|
||||
(mes-use-module (language c99 compiler))
|
||||
|
||||
(define %datadir (if (string-prefix? "@DATADIR" "@DATADIR@") "" "@DATADIR@"))
|
||||
(define %docdir (if (string-prefix? "@DOCDIR" "@DOCDIR@") "doc/" "@DOCDIR@"))
|
||||
(define %moduledir "module/")
|
||||
(define %prefix (if (string-prefix? "@PREFIX" "@PREFIX@") "" "@PREFIX@"))
|
||||
(define %version (if (string-prefix? "@VERSION" "@VERSION@") "git" "@VERSION@"))
|
||||
|
||||
(define (main arguments)
|
||||
(let* ((files (cdr arguments))
|
||||
(file (if (null? files) "doc/examples/main.c"
|
||||
(file (if (null? files) (string-append %docdir "examples/main.c")
|
||||
(car files))))
|
||||
(with-input-from-file file
|
||||
compile)))
|
||||
|
|
Loading…
Reference in a new issue