Skip to content

Commit

Permalink
- recast include files preplib.ss, dsm.ss, and script.ss as libraries,
Browse files Browse the repository at this point in the history
  replaced global variables with parameters (those that cross library
  boundares out of necessity, and those that don't for consistency), and
  Makefile uses whole-program compilation to create a single object file
  for each program.  (note: this last requires an update to Chez Scheme's
  compile-whole-program to transfer the hash-bang line from the wpo file
  to the object file.  this update should be pushed shortly.)
    dsm.ss, preplib.ss, script.ss, scheme-prep.ss, html-prep.ss,
    fixbibtex.ss, Makefile
- Makefile provides a PREFIX variable that can be overridden to change
  in one shot the tree under which the Scheme executable is installed and
  under which the stex library should be installed.
    Makefile
- Mf-stex now assumes Scheme and STEXLIB variables have been set by the
  including make file, and Makefile.template does so, and also includes
  Mf-stex via the directory identified by STEXLIB.  Mf-stex looks for
  and runs the binary scheme-prep, html-prep, and fixbibtex if they
  exist for the machine type of the specified Scheme in the specified
  STEXLIB.  Otherwise it uses the source scheme-prep.ss, html-prep.ss,
  and fixbibtex.ss, setting libdirs appropriately.
    Mf-stex, Makefile.template
- added .gitignore to ignore editor temp files
    .gitignore
  • Loading branch information
dybvig committed May 5, 2016
1 parent 3f3cb92 commit 3bd2b86
Show file tree
Hide file tree
Showing 10 changed files with 1,299 additions and 1,273 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*~
.*.sw?
.sw?
26 changes: 14 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
VERSION=1.1
VERSION=1.2

# location of scheme executable
BIN=/usr/bin
# override PREFIX, Scheme, and LIB as necessary
PREFIX=/usr

# scheme executable
Scheme=$(PREFIX)/bin/scheme

# target location for stex
LIB=/usr/lib/stex$(VERSION)
LIB=$(PREFIX)/lib/stex$(VERSION)

Scheme = $(BIN)/scheme
m := $(shell echo '(machine-type)' | $(Scheme) -q)

Install=./sbin/install
Expand All @@ -15,22 +17,22 @@ exec = $m/scheme-prep $m/html-prep $m/fixbibtex

all: $(exec)

$m/scheme-prep: src/dsm.ss src/preplib.ss src/scheme-prep.ss
$m/scheme-prep: src/dsm.ss src/preplib.ss src/script.ss src/scheme-prep.ss
if [ ! -d $m ] ; then mkdir $m ; fi
sed -e 's;^#! /usr/bin/scheme --program;#! $(Scheme) --program;' src/scheme-prep.ss > $m/scheme-prep.ss
echo '(reset-handler abort) (source-directories (quote ("src"))) (compile-program "$m/scheme-prep.ss" "$m/scheme-prep")' | $(Scheme) -q
chmod 711 $m/scheme-prep
echo '(reset-handler abort) (library-directories (quote "src::$m")) (compile-imported-libraries #t) (generate-wpo-files #t) (compile-program "$m/scheme-prep.ss") (compile-whole-program "$m/scheme-prep.wpo" "$m/scheme-prep")' | $(Scheme) -q
chmod 755 $m/scheme-prep

$m/html-prep: src/dsm.ss src/preplib.ss src/html-prep.ss
$m/html-prep: src/dsm.ss src/preplib.ss src/script.ss src/html-prep.ss
if [ ! -d $m ] ; then mkdir $m ; fi
sed -e 's;^#! /usr/bin/scheme --program;#! $(Scheme) --program;' src/html-prep.ss > $m/html-prep.ss
echo '(reset-handler abort) (source-directories (quote ("src")))(compile-program "$m/html-prep.ss" "$m/html-prep")' | $(Scheme) -q
chmod 711 $m/html-prep
echo '(reset-handler abort) (library-directories (quote "src::$m")) (compile-imported-libraries #t) (generate-wpo-files #t) (compile-program "$m/html-prep.ss") (compile-whole-program "$m/html-prep.wpo" "$m/html-prep")' | $(Scheme) -q
chmod 755 $m/html-prep

$m/fixbibtex: src/fixbibtex.ss
-if [ ! -d $m ] ; then mkdir $m ; fi
sed -e 's;^#! /usr/bin/scheme --program;#! $(Scheme) --program;' src/fixbibtex.ss > $m/fixbibtex.ss
echo '(reset-handler abort) (source-directories (quote ("src")))(compile-program "$m/fixbibtex.ss" "$m/fixbibtex")' | $(Scheme) -q
echo '(reset-handler abort) (library-directories (quote "src::$m")) (compile-imported-libraries #t) (generate-wpo-files #t) (compile-program "$m/fixbibtex.ss") (compile-whole-program "$m/fixbibtex.wpo" "$m/fixbibtex")' | $(Scheme) -q
chmod 755 $m/fixbibtex

install: $(exec)
Expand Down
6 changes: 5 additions & 1 deletion Makefile.template
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
VERSION=1.2
Scheme=scheme
STEXLIB=/usr/lib/stex$(VERSION)

# define default document pathname here
# override on command line with 'make x=newdoc'
x = ???
Expand All @@ -14,7 +18,7 @@ bib =
# define index if an index is to be generated
# index=yes

include ~/stex/Mf-stex
include $(STEXLIB)/Mf-stex

# define or override suffixes here

Expand Down
41 changes: 28 additions & 13 deletions Mf-stex
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
VERSION=1.2
LIB=$(HOME)/stex
Petite=petite
# Mf-stex expects to be included in a make file that defines:
# Scheme the path of the Chez Scheme executable
# STEXLIB the path to the stex library (the library containing this file)

TEXINPUTS:=.:$(LIB)/inputs:
m := $(shell echo '(machine-type)' | $(Scheme) -q)

TEXINPUTS:=.:$(STEXLIB)/inputs:
export TEXINPUTS

m := $(shell echo '(machine-type)' | $(Petite) -q)
ifeq ($(wildcard $(STEXLIB)/$m/scheme-prep),)
Sprep = $(Scheme) --libdirs "$(STEXLIB)/src" --program $(STEXLIB)/src/scheme-prep.ss
else
Sprep = $(STEXLIB)/$m/scheme-prep
endif

ifeq ($(wildcard $(STEXLIB)/$m/html-prep),)
Hprep = $(Scheme) --libdirs "$(STEXLIB)/src" --program $(STEXLIB)/src/html-prep.ss
else
Hprep = $(STEXLIB)/$m/html-prep
endif

ifeq ($(wildcard $(STEXLIB)/$m/fixbibtex),)
fixbibtex = $(Scheme) --libdirs "$(STEXLIB)/src" --program $(STEXLIB)/src/fixbibtex.ss
else
fixbibtex = $(STEXLIB)/$m/fixbibtex
endif

mathdir=math/$(x)
mathfiles=$(mathdir)/mathfiles
Sprep = $(LIB)/$m/scheme-prep
Hprep = $(LIB)/$m/html-prep --mathdir $(mathdir)
fixbibtex = $(LIB)/$m/fixbibtex

# solaris /bin/sh doesn't support '!' in test
SHELL=bash
Expand Down Expand Up @@ -93,28 +108,28 @@ $(x).mathrun: gifs $(mathfiles)
touch $(x).mathrun

gifs:
(cd $(LIB); tar -cf - gifs) | tar -xpf -
(cd $(STEXLIB); tar -cf - gifs) | tar -xpf -

math:
(cd $(LIB); tar -cf - math) | tar -xpf -
(cd $(STEXLIB); tar -cf - math) | tar -xpf -

$(mathfiles): $(x).hthirdrun $(figps)
echo -n gifs= > $(mathfiles)
(cd $(mathdir); echo *.tex | sed -e "s/\.tex/.gif/g") >> $(mathfiles)

$(x).hthirdrun: $(x).hsecondrun
$(Hprep) $(x)
$(Hprep) --mathdir $(mathdir) $(x)
chmod 444 *.html
touch $(x).hthirdrun

$(x).hsecondrun: $(x).hfirstrun
$(Hprep) $(x)
$(Hprep) --mathdir $(mathdir) $(x)
chmod 444 *.html
touch $(x).hsecondrun

$(x).hfirstrun: math $(x).thirdrun
(if [ ! -e $(mathdir) ] ; then mkdir -p -m u=rwx,g=srx,o=rx $(mathdir); ln -s ../Makefile ../mathmacros $(mathdir); fi)
$(Hprep) $(x)
$(Hprep) --mathdir $(mathdir) $(x)
touch $(x).hfirstrun

spell: $(spellobj)
Expand Down
58 changes: 30 additions & 28 deletions src/dsm.ss
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,33 @@

;;; authors: R. Kent Dybvig and Oscar Waddell

(define-syntax define-syntactic-monad
(syntax-rules ()
[(_ name formal ...)
(andmap identifier? #'(name formal ...))
(define-syntax name
(lambda (x)
(syntax-case x (lambda case-lambda)
[(key lambda more-formals . body)
(with-implicit (key formal ...)
#'(lambda (formal ... . more-formals) . body))]
[(key case-lambda (more-formals . body) (... ...))
(with-implicit (key formal ...)
#'(case-lambda ((formal ... . more-formals) . body) (... ...)))]
[(key proc ((x e) (... ...)) arg (... ...))
(andmap identifier? #'(x (... ...)))
(with-implicit (key formal ...)
(for-each
(lambda (x)
(unless (let mem ((ls #'(formal ...)))
(and (not (null? ls))
(or (free-identifier=? x (car ls))
(mem (cdr ls)))))
(syntax-error x (format "in syntactic monad ~s, unrecognized identifier" 'name))))
#'(x (... ...)))
(with-syntax ([(t (... ...)) (generate-temporaries #'(arg (... ...)))])
#'(let ((p proc) (x e) (... ...) (t arg) (... ...))
(p formal ... t (... ...)))))]
[(key proc) #'(key proc ())])))]))
(library (dsm) (export define-syntactic-monad) (import (chezscheme))
(define-syntax define-syntactic-monad
(syntax-rules ()
[(_ name formal ...)
(andmap identifier? #'(name formal ...))
(define-syntax name
(lambda (x)
(syntax-case x (lambda case-lambda)
[(key lambda more-formals . body)
(with-implicit (key formal ...)
#'(lambda (formal ... . more-formals) . body))]
[(key case-lambda (more-formals . body) (... ...))
(with-implicit (key formal ...)
#'(case-lambda ((formal ... . more-formals) . body) (... ...)))]
[(key proc ((x e) (... ...)) arg (... ...))
(andmap identifier? #'(x (... ...)))
(with-implicit (key formal ...)
(for-each
(lambda (x)
(unless (let mem ((ls #'(formal ...)))
(and (not (null? ls))
(or (free-identifier=? x (car ls))
(mem (cdr ls)))))
(syntax-error x (format "in syntactic monad ~s, unrecognized identifier" 'name))))
#'(x (... ...)))
(with-syntax ([(t (... ...)) (generate-temporaries #'(arg (... ...)))])
#'(let ((p proc) (x e) (... ...) (t arg) (... ...))
(p formal ... t (... ...)))))]
[(key proc) #'(key proc ())])))]))
)
2 changes: 1 addition & 1 deletion src/fixbibtex.ss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/petite --program
#! /usr/bin/scheme --program

;;; fixbibtex.ss

Expand Down
Loading

0 comments on commit 3bd2b86

Please sign in to comment.