update READMEs
[haskell-report.git] / report / Makefile
1 # Makefile for the Haskell Report
2 # read the README file before you start!
3 #
4 # Target 'jfp' copies stuff into $(JFP_DIR) for the JFP book
5 # you need to do the same in the libraries directory
6
7 ##########################################
8 # What to make if you type 'make'
9
10 default: pdf html
11
12 .PHONY: pdf
13 pdf : haskell.pdf
14
15 # Begin by saying
16 # touch haskell.idx
17
18 #########################################
19 # Tools you need
20 #########################################
21
22 # Stuf from the tools/directory
23 RUN_TEX = ../tools/run_tex
24 RUN_INDEX = ../tools/run_index
25 VERBATIM = ../tools/verbatim
26 VERB_TEX4HT = ../tools/verb-tex4ht
27
28 # splitAndIndexPgm won't work unless you have "perl"
29 SPLITPGM = perl ../tools/splitAndIndexPgm
30
31 RM = rm -f
32 CP = cp
33 LN = ln -sf
34 LATEX = latex
35 PDFLATEX = pdflatex
36 BIBTEX = bibtex
37 MAKEINDEX = makeindex
38
39 # 'expand' expands tabs to spaces
40 # On my machine the windows program (which does something
41 # quite different) shadows it. Sigh.
42 EXPAND = expand
43 # EXPAND = c:/cygwin/bin/expand
44
45
46 #########################################
47 # Files
48 #########################################
49
50 RELEASE_DIR = ../haskell-prime-draft
51 JFP_DIR = ../jfp-release
52
53 PARTS = haskell.tex preface.tex $(PARTS_NO_PREFACE)
54 PARTS_NO_PREFACE = iso-chars.tex \
55 intro.tex lexemes.tex exps.tex \
56 decls.tex modules.tex basic.tex io-13.tex \
57 derived.tex \
58 index-extra.tex index-intro.tex layout.tex fixity.tex \
59 literate.tex pragmas.tex standard-prelude.tex \
60 syntax-lexical.tex syntax-iso.tex ffi.tex \
61 Prelude.tex PreludeList.tex PreludeText.tex PreludeIO.tex \
62 $(LIB_TEX)
63
64 LIB_MODULES = Data.Array \
65 Data.Char \
66 Data.Complex \
67 System.IO \
68 System.IO.Error \
69 Data.Ix \
70 Data.List \
71 Data.Maybe \
72 Control.Monad \
73 Data.Ratio \
74 System.Environment \
75 System.Exit \
76 Data.Int \
77 Data.Word \
78 Data.Bits \
79 Foreign \
80 Foreign.Ptr \
81 Foreign.ForeignPtr \
82 Foreign.StablePtr \
83 Foreign.Storable \
84 Foreign.C \
85 Foreign.C.Error \
86 Foreign.C.String \
87 Foreign.C.Types \
88 Foreign.Marshal \
89 Foreign.Marshal.Alloc \
90 Foreign.Marshal.Array \
91 Foreign.Marshal.Error \
92 Foreign.Marshal.Utils
93
94 HADDOCK_ODIR = libs
95
96 LIB_TEX = $(patsubst %, $(HADDOCK_ODIR)/%, $(addsuffix .tex, $(subst .,-,$(LIB_MODULES))))
97
98 HT_TEXS = $(patsubst %, ht/%, $(PARTS))
99
100 show:
101 @echo '$(VALUE)="$($(VALUE))"'
102
103 #########################################
104 # Main targets
105 #########################################
106
107 # The normally formatted report -- 2 sided, one-up
108 # haskell.verb: plain_haskell.verb
109 # -cp plain_haskell.verb haskell.verb
110
111 haskell.tex: haskell.verb
112 $(EXPAND) < $< | $(VERBATIM) >$@
113
114 # I have no idea why run_tex is run twice. SLPJ
115 # html: index.html ${PARTS}
116 # -mkdir haskell-report-html
117 # $(RUN_TEX)
118 # $(RUN_TEX)
119 # $(RUN_INDEX)
120 # cp index.html *.png *.gif haskell-report-html
121
122 haskell.dvi: haskell.tex haskell.ind ${PARTS}
123 haskell.pdf: haskell.tex haskell.ind haddock.sty ${PARTS}
124
125 haskell.ps : haskell.dvi
126 dvips haskell.dvi -o haskell.ps
127
128 # Can't use pdflatex because of eps inclusion
129
130 release: haskell.ps html
131 if ! test -d $(RELEASE_DIR); then mkdir $(RELEASE_DIR); fi
132 ps2pdf haskell.ps
133 gzip < haskell.ps > $(RELEASE_DIR)/haskell.ps.gz
134 cp haskell.pdf $(RELEASE_DIR)/haskell.pdf
135 cp -r haskell-report-html $(RELEASE_DIR)
136 tar cvf - haskell-report-html | gzip > $(RELEASE_DIR)/haskell-report-html.tar.gz
137 cp *.png *.gif $(RELEASE_DIR)
138 #cp h98-revised.html $(RELEASE_DIR)/index.html
139 #cp haskell98-bugs.html h98.gif $(RELEASE_DIR)
140 #cp haskell98-revised-bugs.html h98.gif $(RELEASE_DIR)
141
142 publish-pdf: report.pdf
143 gzip < report.pdf > y:Haskell/haskell-report/report.pdf.gz
144
145 #########################################
146 # HTML
147 #########################################
148
149 ht/classes.eps : classes.eps
150 $(CP) $< $@
151
152 .PHONY: html
153 html: $(HT_TEXS) ht/classes.eps ht/haddock.sty
154 cd ht && htlatex haskell.tex "haskell,2"
155
156 #########################################
157 # Generic stuff
158 #########################################
159
160 .PHONY: clean veryclean
161 veryclean: clean
162 $(RM) *~
163
164 clean:
165 $(RM) ${HT_TEXS} ht/*.html ht/html/* ht/*.htm ht/hask*.png ht/*.log ht/*.tmp \
166 ht/*.xref ht/classes.eps ht/*.css ht/*.idx ht/*.aux ht/*.dvi \
167 ht/*.4ct ht/*.4tc
168 $(RM) *.dvi *.log *.aux *.ilg *.blg *.toc *.bbl *.idx *.tmp *.out \
169 ${PARTS} \
170 haskell.tex haskell.ps haskell.pdf *.o lex.yy.c haskell-report-html/*
171
172
173 #########################################
174 # Suffix rules
175 #########################################
176
177 %.tex: %.verb
178 $(EXPAND) < $< | $(VERBATIM) | sh ../tools/subsection >$@
179 # The 'subsection' part changes section -> chapter for the book style
180
181 %.verb: %.hs
182 $(EXPAND) < $< | $(SPLITPGM) >$@
183
184 %.tex: %.hs
185 $(EXPAND) < $< | $(SPLITPGM) | $(VERBATIM) >$@
186
187 %.tex: %.hi
188 $(EXPAND) < $< | $(SPLITPGM) | $(VERBATIM) >$@
189
190 %.dvi: %.tex
191 $(LATEX) $<
192
193 %.pdf: %.tex
194 $(PDFLATEX) $<
195 $(BIBTEX) $*
196 $(MAKEINDEX) -i -t haskell.ilg < haskell.idx > haskell.ind
197 $(PDFLATEX) $<
198 $(PDFLATEX) $<
199
200 ht/%.tex: %.verb
201 $(EXPAND) < $< | $(VERB_TEX4HT) | sh ../tools/subsection >$@
202
203 ht/libs/%.tex: libs/%.tex
204 $(CP) $< $@
205
206 jfp: h98-book.tex preface-jfp.tex ${PARTS_NO_PREFACE}
207 -mkdir $(JFP_DIR)
208 for n in h98-book.tex preface-jfp.tex \
209 ${PARTS_NO_PREFACE}; do \
210 ../tools/subsection < $$n > $(JFP_DIR)/$$n ; done
211 cp classes.eps $(JFP_DIR)
212 cp haskell.bbl $(JFP_DIR)/h98-book.bbl
213 cp Makefile-jfp-book $(JFP_DIR)/Makefile
214
215
216
217
218 # Stuff to make the "two-up" version for SIGPLAN Notices:
219 # We take the A4 pages and double them up onto (virtual) A3 pages:
220 # (two A5 pages make one A4 page; two A4 pages make one A3 page; ...)
221 #
222 # % dvidvi '2:0,1(210mm,0)' haskell.dvi > haskell-2up.dvi
223 #
224 # We now print the "A3" pages in landscape, but "magnify" them by
225 # 1 / sqrt(2) ~ 0.7071; this should make our "A4" pages print in an
226 # A4 space: presto! 2up printing!
227 # (except that I've tried to make it give us 1" margins all round
228 # when we print on US 8.5"x11" paper)
229 #
230 # % dvips -t landscape -x 707 haskell-2up.dvi > haskell-2up.ps
231 #
232 # if your "dvips" is set up properly, it will run Metafont for you,
233 # creating just-right magnifications for all the fonts.
234 #
235 # print with: lpr -Pmy-laserwriter haskell-2up.ps
236
237 # These rules keep failing for me (segmentation fault on haskell-2up.dvi)
238 # The output seems fine, though, and the individual commands work
239 # perfectly(!). More network wierdness? KH
240
241 haskell-2up.ps : haskell-2up.dvi
242 dvips -t landscape -x 707 haskell-2up.dvi > haskell-2up.ps
243
244 haskell-2up.dvi : haskellx.dvi
245 -dvidvi '2:0(0in,0in),1(160mm,0in)' haskellx.dvi > haskell-2up.dvi
246
247 haskellx.dvi : sigplan_haskell.dvi
248 dviselect =4: haskell.dvi haskellx.dvi
249
250 haskell-libraries-2up.ps : haskell-libraries-2up.dvi
251 dvips -t landscape -x 707 haskell-libraries-2up.dvi > haskell-libraries-2up.ps
252
253 haskell-libraries-2up.dvi : haskell-librariesx.dvi
254 -dvidvi '2:0(0in,0in),1(160mm,0in)' haskell-librariesx.dvi > haskell-libraries-2up.dvi
255
256 haskell-librariesx.dvi : sigplan_haskell-libraries.dvi
257 dviselect =4: sigplan_haskell-libraries.dvi haskell-librariesx.dvi
258
259
260 # -----------------------------------------------------------------------------
261 # Haddock-generated library docs
262
263 # The results of auto-generating the library docs are in the
264 # repository already, so you only need to re-generate if you are
265 # changing anything.
266
267 # To generate the library docs, we need to run Haddock against the
268 # modules of the haskell2010 package. The package is here:
269 #
270 # http://darcs.haskell.org/packages/haskell2010
271 #
272 # I generated the documentation using a GHC build, but you could
273 # probably do it using just the package sources, as long as you have
274 # GHC and all the package documentation installed.
275 #
276 # Basically the plan is to run Haddock in the same way as for
277 # generating the HTML documentation, except that we
278 #
279 # * replace --html with --latex
280 # * Add --latex-style=NONE to prevent Haddock dumping its haddock.sty
281 # * Add --odir=$(HADDOCK_DIR)
282 #
283 # So to get started, in a GHC build, you could run
284 #
285 # $ cd libraries/haskell2010
286 # $ make html stage=0 FAST=YES
287 #
288 # And grab the Haddock command line that the build system emits.
289 #
290 # The following rules will probably need a lot of manual modification,
291 # sorry about that.
292
293 # Set this to Haddock (version 2.8 or later with the LaTeX back-end)
294 HADDOCK = /home/simonmar/builds/testing/inplace/bin/haddock
295
296 # Set this to the location of the libraries in a GHC build
297 LIBDIR = /home/simonmar/builds/testing/libraries
298
299 haddock :
300 $(HADDOCK) --odir=$(HADDOCK_ODIR) --no-tmp-comp-dir \
301 --latex --latex-style=NONE \
302 --title="haskell2010-1.0.0.0: Compatibility with Haskell 2010" \
303 --read-interface=../ghc-prim,$(LIBDIR)/ghc-prim/dist-install/doc/html/ghc-prim/ghc-prim.haddock \
304 --read-interface=../array-0.3.0.0,$(LIBDIR)/array/dist-install/doc/html/array/array.haddock \
305 --read-interface=../base-4.3.0.0,$(LIBDIR)/base/dist-install/doc/html/base/base.haddock \
306 --optghc=-package-name --optghc=haskell2010-1.0.0.0 --optghc=-hide-all-packages --optghc=-i --optghc=-i$(LIBDIR)/haskell2010/. --optghc=-i$(LIBDIR)/haskell2010/dist-install/build --optghc=-i$(LIBDIR)/haskell2010/dist-install/build/autogen --optghc=-i$(LIBDIR)/haskell2010/dist-install/build --optghc=-i$(LIBDIR)/haskell2010/dist-install/build/autogen --optghc=-i$(LIBDIR)/haskell2010/. --optghc=-optP-include --optghc=-optP$(LIBDIR)/haskell2010/dist-install/build/autogen/cabal_macros.h --optghc=-package --optghc=array-0.3.0.0 --optghc=-package --optghc=base-4.3.0.0 --optghc=-package-name --optghc=haskell2010 --optghc=-XPackageImports --optghc=-XCPP --optghc=-no-user-package-conf --optghc=-rtsopts --optghc=-O --optghc=-fasm --optghc=-dcore-lint --optghc=-fno-warn-deprecated-flags --optghc=-odir --optghc=libraries/haskell2010/dist-install/build --optghc=-hidir --optghc=$(LIBDIR)/haskell2010/dist-install/build --optghc=-stubdir --optghc=$(LIBDIR)/haskell2010/dist-install/build --optghc=-hisuf --optghc=hi --optghc=-osuf --optghc=o --optghc=-hcsuf --optghc=hc \
307 $(patsubst %, $(LIBDIR)/haskell2010/%, $(addsuffix .hs, $(subst .,/,$(LIB_MODULES))))