-
Notifications
You must be signed in to change notification settings - Fork 28
/
Makefile
247 lines (200 loc) · 6.9 KB
/
Makefile
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
include config.mk
main := src/Main.lhs
psources := $(main) src/TeXCommands.lhs src/TeXParser.lhs \
src/Typewriter.lhs src/Math.lhs src/MathPoly.lhs \
src/MathCommon.lhs src/NewCode.lhs \
src/Directives.lhs src/HsLexer.lhs src/FileNameUtils.lhs \
src/Parser.lhs src/FiniteMap.lhs src/Auxiliaries.lhs \
src/StateT.lhs src/Document.lhs src/Verbatim.lhs src/Value.lhs \
src/License.lhs src/State.lhs
sources := $(psources) src/Version.lhs
snipssrc := sorts.snip id.snip cata.snip spec.snip
snips := sorts.tt sorts.math id.math cata.math spec.math
objects := $(sources:.lhs=.o)
sections := $(sources:.lhs=.tex)
MKINSTDIR := ./mkinstalldirs
###
### lhs dependencies (from %include lines)
###
ifdef SORT
ifdef UNIQ
MKLHSDEPEND = $(GREP) "^%include " $< \
| $(SED) -e 's,^%include ,$*.tex : ,' \
| $(SORT) | $(UNIQ) > $*.ld
MKFMTDEPEND = $(GREP) "^%include " $< \
| $(SED) -e 's,^%include ,$*.fmt : ,' \
| $(SORT) | $(UNIQ) > $*.ld
endif
endif
###
### dependency postprocessing
###
DEPPOSTPROC = $(SED) -e 's/\#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
-e '/^$$/ d' -e 's/$$/ :/'
###
### default targets
###
.PHONY : default xdvi gv print install backup clean all depend bin doc srcdist
all : default
default : bin doc
bin : lhs2TeX lhs2TeX.fmt lhs2TeX.sty
-include $(sources:%.lhs=%.d)
# I don't understand this ... (ks)
#
# %.hi : %.o
# @if [ ! -f $@ ] ; then \
# echo $(RM) $< ; \
# $(RM) $< ; \
# set +e ; \
# echo $(MAKE) $(notdir $<) ; \
# $(MAKE) $(notdir $<) ; \
# if [ $$? -ne 0 ] ; then \
# exit 1; \
# fi ; \
# fi
ifdef MKLHSDEPEND
%.ld : %.lhs
$(MKLHSDEPEND); \
$(CP) $*.ld $*.ldd; \
$(DEPPOSTPROC) < $*.ldd >> $*.ld; \
$(RM) -f $*.ldd
%.ld : %.fmt
$(MKFMTDEPEND); \
$(CP) $*.ld $*.ldd; \
$(DEPPOSTPROC) < $*.ldd >> $*.ld; \
$(RM) -f $*.ldd
-include $(sources:%.lhs=%.ld)
endif
%.tex : %.lhs lhs2TeX Lhs2TeX.fmt lhs2TeX.fmt
# lhs2TeX -verb -iLhs2TeX.fmt $< > $@
./lhs2TeX --math --align 33 -iLhs2TeX.fmt $< > $@
%.tt : %.snip lhs2TeX lhs2TeX.fmt
./lhs2TeX --tt -lmeta=True -ilhs2TeX.fmt $< > $@
%.math : %.snip lhs2TeX lhs2TeX.fmt
./lhs2TeX --math --align 33 -lmeta=True -ilhs2TeX.fmt $< > $@
%.tex : %.lit lhs2TeX
./lhs2TeX --verb -ilhs2TeX.fmt $< > $@
lhs2TeX.sty: lhs2TeX.sty.lit lhs2TeX
./lhs2TeX --code lhs2TeX.sty.lit > lhs2TeX.sty
lhs2TeX.fmt: lhs2TeX.fmt.lit lhs2TeX
./lhs2TeX --code lhs2TeX.fmt.lit > lhs2TeX.fmt
lhs2TeX : $(sources)
$(GHC) $(GHCFLAGS) -isrc --make -o lhs2TeX $(main)
doc : bin
cd doc; $(MAKE)
# cd Guide; $(MAKE) Guide.pdf
INSTALL : lhs2TeX INSTALL0 INSTALL1
cp INSTALL0 $@
./lhs2TeX --searchpath >> $@
cat INSTALL1 >> $@
depend:
$(GHC) -M -optdep-f -optdeplhs2TeX.d $(GHCFLAGS) $(sources)
$(RM) -f lhs2TeX.d.bak
lhs2TeX-includes : lhs2TeX.sty $(sections) $(snips) lhs2TeX.sty.tex lhs2TeX.fmt.tex Makefile.tex
Lhs2TeX.dvi : lhs2TeX-includes
Lhs2TeX.pdf : lhs2TeX-includes
xdvi : Lhs2TeX.dvi
$(XDVI) -s 3 Lhs2TeX.dvi &
gv : Lhs2TeX.ps
$(GV) Lhs2TeX.ps &
print : Lhs2TeX.dvi
$(DVIPS) -D600 -f Lhs2TeX.dvi | lpr -Pa -Zl
install : bin doc
$(MKINSTDIR) $(DESTDIR)$(bindir)
$(INSTALL) -m 755 lhs2TeX $(DESTDIR)$(bindir)
$(MKINSTDIR) $(DESTDIR)$(stydir)
$(INSTALL) -m 644 lhs2TeX.sty lhs2TeX.fmt $(DESTDIR)$(stydir)
$(INSTALL) -m 644 Library/*.fmt $(DESTDIR)$(stydir)
$(MKINSTDIR) $(DESTDIR)$(docdir)
$(INSTALL) -m 644 doc/Guide2.pdf $(DESTDIR)$(docdir)
$(MKINSTDIR) $(DESTDIR)$(mandir)/man1
$(INSTALL) -m 644 lhs2TeX.1 $(DESTDIR)$(mandir)/man1
ifeq ($(INSTALL_POLYTABLE),yes)
# install polytable package
$(MKINSTDIR) $(DESTDIR)$(polydir)
$(INSTALL) -m 644 polytable/*.sty $(DESTDIR)$(polydir)
endif
# $(MKINSTDIR) $(DESTDIR)$(texdir)
# $(INSTALL) -m 644 Library/*.sty $(DESTDIR)$(texdir)
ifndef DESTDIR
$(MKTEXLSR)
else
echo "Please update the TeX filename database."
endif
srcdist : INSTALL doc
if test -d $(DISTDIR); then $(RM) -rf $(DISTDIR); fi
$(MKINSTDIR) $(DISTDIR)
$(MKINSTDIR) $(DISTDIR)/src
$(MKINSTDIR) $(DISTDIR)/doc
$(MKINSTDIR) $(DISTDIR)/polytable
$(MKINSTDIR) $(DISTDIR)/Testsuite
$(MKINSTDIR) $(DISTDIR)/Examples
$(MKINSTDIR) $(DISTDIR)/Library
$(INSTALL) -m 644 $(psources) src/Version.lhs.in $(DISTDIR)/src
$(INSTALL) -m 644 $(snipssrc) $(DISTDIR)
$(INSTALL) -m 644 Setup.hs lhs2tex.cabal $(DISTDIR)
$(INSTALL) -m 644 lhs2TeX.fmt.lit lhs2TeX.sty.lit $(DISTDIR)
$(INSTALL) -m 644 Makefile common.mk config.mk.in $(DISTDIR)
$(INSTALL) -m 644 lhs2TeX.1.in $(DISTDIR)
$(INSTALL) -m 755 configure mkinstalldirs install-sh $(DISTDIR)
$(INSTALL) -m 644 TODO AUTHORS LICENSE CHANGELOG.md $(DISTDIR)
cat INSTALL | sed -e "s/@ProgramVersion@/$(PACKAGE_VERSION)/" \
> $(DISTDIR)/INSTALL
chmod 644 $(DISTDIR)/INSTALL
cd doc; $(MAKE) srcdist
$(INSTALL) -m 644 polytable/*.{sty,pdf} $(DISTDIR)/polytable
$(INSTALL) -m 644 Testsuite/*.{lhs,snip} Testsuite/Makefile $(DISTDIR)/Testsuite
$(INSTALL) -m 644 Examples/*.lhs $(DISTDIR)/Examples
$(INSTALL) -m 755 Examples/lhs2TeXpre $(DISTDIR)/Examples
$(INSTALL) -m 644 Library/*.fmt $(DISTDIR)/Library
tar --format=ustar -cvzf $(DISTDIR).tar.gz $(DISTDIR)
chmod 644 $(DISTDIR).tar.gz
ifdef DISTTYPE
bindist: lhs2TeX lhs2TeX.fmt lhs2TeX.sty doc
if test -d $(DISTDIR); then $(RM) -rf $(DISTDIR); fi
$(MKINSTDIR) $(DISTDIR)
$(MKINSTDIR) $(DISTDIR)/doc
$(MKINSTDIR) $(DISTDIR)/polytable
$(MKINSTDIR) $(DISTDIR)/Testsuite
$(MKINSTDIR) $(DISTDIR)/Examples
$(MKINSTDIR) $(DISTDIR)/Library
$(INSTALL) -m 755 lhs2TeX $(DISTDIR)
$(INSTALL) -m 644 lhs2TeX.fmt lhs2TeX.sty $(DISTDIR)
$(INSTALL) -m 644 $(psources) Version.lhs.in $(snipssrc) $(DISTDIR)
$(INSTALL) -m 644 lhs2TeX.fmt.lit lhs2TeX.sty.lit $(DISTDIR)
$(INSTALL) -m 644 Makefile common.mk config.mk.in $(DISTDIR)
$(INSTALL) -m 644 lhs2TeX.1.in $(DISTDIR)
$(INSTALL) -m 755 configure mkinstalldirs install-sh $(DISTDIR)
$(INSTALL) -m 644 TODO AUTHORS LICENSE CHANGELOG.md $(DISTDIR)
cat INSTALL | sed -e "s/@ProgramVersion@/$(PACKAGE_VERSION)/" \
> $(DISTDIR)/INSTALL
chmod 644 $(DISTDIR)/INSTALL
cd doc; $(MAKE) srcdist
$(INSTALL) -m 644 polytable/*.{sty,pdf} $(DISTDIR)/polytable
$(INSTALL) -m 644 Testsuite/*.{lhs,snip} Testsuite/Makefile $(DISTDIR)/Testsuite
$(INSTALL) -m 644 Examples/*.lhs $(DISTDIR)/Examples
$(INSTALL) -m 755 Examples/lhs2TeXpre $(DISTDIR)/Examples
$(INSTALL) -m 644 Library/*.fmt $(DISTDIR)/Library
tar cvjf $(DISTDIR)-$(DISTTYPE).tar.bz2 $(DISTDIR)
chmod 644 $(DISTDIR)-$(DISTTYPE).tar.bz2
else
bindist:
@echo "You must define DISTTYPE."
endif
backup:
cd ..; \
$(RM) -f Literate.tar Literate.tar.gz; \
tar -cf Literate.tar Literate; \
gzip Literate.tar; \
chmod a+r Literate.tar.gz
clean :
# clean
$(RM) -f lhs2TeX $(sections) $(snips) $(objects) *.hi *.dvi *.ps
-$(RM) -f *.d *.dd *.ld *.ldd
$(RM) -f lhs2TeX.sty lhs2TeX.fmt
$(RM) -f Lhs2TeX.tex lhs2TeX.sty.tex lhs2TeX.fmt.tex Makefile.tex
cd doc; $(MAKE) clean
# all:
# $(MAKE) install
# $(MAKE) Lhs2TeX.dvi
include common.mk