-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathMf-stex
153 lines (122 loc) · 3.61 KB
/
Mf-stex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# 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)
m := $(shell echo '(machine-type)' | $(Scheme) -q)
ifeq ("$m","")
$(error cannot determine machine-type for Scheme=$(Scheme))
endif
TEXINPUTS:=.:$(realpath $(STEXLIB)/inputs):
export TEXINPUTS
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
# solaris /bin/sh doesn't support '!' in test
SHELL=bash
stexsrc = $(x).stex
texsrc = $(x).tex
spellobj = $(x).spell
.SUFFIXES:
.SUFFIXES: .stex .tex .spell .fig .ps .png .pdf .eps
.stex.tex:
$(Sprep) $(stexmacrofiles) $*
chmod -w $*.tex
.tex.spell:
latexspell $*.tex
.fig.ps:
fig2dev -Leps $*.fig $*.ps
.fig.png:
fig2dev -Lppm $*.fig | pnmcrop | pnmtopng -transparent white > $*.png
chmod go=r $*.png
.ps.png:
echo | gs -q -dNOPAUSE -dSAFER -sDEVICE=ppmraw -sOutputFile=- -r90x90 $*.ps | pnmcrop | pnmtopng -transparent white > $*.png
# need to generate eps first to compute bounding box
# need --gs on my machine at home or it fails to find bounding box
.ps.eps:
ps2epsi $*.ps $*.eps
.eps.pdf:
epstopdf --gs $*.eps
.fig.pdf:
fig2dev -Leps $*.fig | epstopdf --filter > $*.pdf
ifeq "$(latex)" "latex"
doitformebaby: $(x).ps $(x).html
$(x).ps: $(x).thirdrun
dvips -o $(x).ps $(x).dvi
$(x).pdf: $(x).ps
ps2pdf $*.ps $*.pdf
chmod 644 $*.pdf
else
doitformebaby: $(x).pdf $(x).html
$(x).pdf: $(x).thirdrun
chmod 644 $(x).pdf
endif
$(x).dvi: $(x).thirdrun
$(x).thirdrun: $(x).secondrun
ifdef index
makeindex $(x)
endif
$(latex) $(x)
touch $(x).thirdrun
$(x).secondrun: $(x).firstrun $(bib)
ifneq ($(strip $(bib)),)
bibtex $(x)
$(fixbibtex) $(x).bbl
endif
ifdef index
makeindex $(x)
endif
$(latex) $(x)
touch $(x).secondrun
$(x).firstrun: $(texsrc)
touch $(x).htoc
$(latex) $(x)
touch $(x).firstrun
all.tex: $(texsrc)
$(x).html: $(x).mathrun
$(x).mathrun: gifs $(mathfiles)
@(cd $(mathdir); make)
touch $(x).mathrun
gifs:
(cd $(STEXLIB); tar -cf - gifs) | tar -xpf -
math:
(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) --mathdir $(mathdir) $(x)
chmod 444 *.html
touch $(x).hthirdrun
$(x).hsecondrun: $(x).hfirstrun
$(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) --mathdir $(mathdir) $(x)
touch $(x).hfirstrun
spell: $(spellobj)
$(x).spell: $(x).bbl $(x).tex
latexspell $(x).bbl
latexspell $(x).tex
clean: $(x).clean
-/bin/rm -f *.log *.dvi *.aux *.out *.toc *.tmp *.idx *.ilg *.ind *.blg *.bbl *.rfm *.sfm *.firstrun *.secondrun *.thirdrun
-/bin/rm -f *.haux *.htoc *.hidx *.hfirstrun *.hsecondrun *.hthirdrun *.mathrun
-/bin/rm -f *.tex
reallyclean: clean $(x).reallyclean
-/bin/rm -f *.html *.ps *.pdf *.png
reallyreallyclean: reallyclean $(x).reallyreallyclean
-/bin/rm -rf $(mathdir)