remove instances for types/classes that are not part of Haskell
[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) $(LIB_TEX)
54
55 PARTS_NO_PREFACE = iso-chars.tex \
56 intro.tex lexemes.tex exps.tex \
57 decls.tex modules.tex basic.tex io-13.tex \
58 derived.tex \
59 index-extra.tex index-intro.tex fixity.tex \
60 pragmas.tex standard-prelude.tex \
61 syntax-lexical.tex syntax-iso.tex ffi.tex \
62 Prelude.tex PreludeList.tex PreludeText.tex PreludeIO.tex
63
64
65 LIB_MODULES = Data.Array \
66 Data.Char \
67 Data.Complex \
68 System.IO \
69 System.IO.Error \
70 Data.Ix \
71 Data.List \
72 Data.Maybe \
73 Control.Monad \
74 Data.Ratio \
75 System.Environment \
76 System.Exit \
77 Data.Int \
78 Data.Word \
79 Data.Bits \
80 Foreign \
81 Foreign.Ptr \
82 Foreign.ForeignPtr \
83 Foreign.StablePtr \
84 Foreign.Storable \
85 Foreign.C \
86 Foreign.C.Error \
87 Foreign.C.String \
88 Foreign.C.Types \
89 Foreign.Marshal \
90 Foreign.Marshal.Alloc \
91 Foreign.Marshal.Array \
92 Foreign.Marshal.Error \
93 Foreign.Marshal.Utils
94
95 HADDOCK_ODIR = libs
96
97 LIB_TEX = $(patsubst %, $(HADDOCK_ODIR)/%, $(addsuffix .tex, $(subst .,-,$(LIB_MODULES))))
98
99 HT_TEXS = $(patsubst %, ht/%, $(PARTS))
100
101 show:
102 @echo '$(VALUE)="$($(VALUE))"'
103
104 #########################################
105 # Main targets
106 #########################################
107
108 # The normally formatted report -- 2 sided, one-up
109 # haskell.verb: plain_haskell.verb
110 # -cp plain_haskell.verb haskell.verb
111
112 haskell.tex: haskell.verb
113 $(EXPAND) < $< | $(VERBATIM) >$@
114
115 # I have no idea why run_tex is run twice. SLPJ
116 # html: index.html ${PARTS}
117 # -mkdir haskell-report-html
118 # $(RUN_TEX)
119 # $(RUN_TEX)
120 # $(RUN_INDEX)
121 # cp index.html *.png *.gif haskell-report-html
122
123 haskell.dvi: haskell.tex haskell.ind ${PARTS}
124 haskell.pdf: haskell.tex haskell.ind haddock.sty ${PARTS}
125
126 haskell.ps : haskell.dvi
127 dvips haskell.dvi -o haskell.ps
128
129 # Can't use pdflatex because of eps inclusion
130
131 release: haskell.ps html
132 if ! test -d $(RELEASE_DIR); then mkdir $(RELEASE_DIR); fi
133 ps2pdf haskell.ps
134 gzip < haskell.ps > $(RELEASE_DIR)/haskell.ps.gz
135 cp haskell.pdf $(RELEASE_DIR)/haskell.pdf
136 cp -r haskell-report-html $(RELEASE_DIR)
137 tar cvf - haskell-report-html | gzip > $(RELEASE_DIR)/haskell-report-html.tar.gz
138 cp *.png *.gif $(RELEASE_DIR)
139 #cp h98-revised.html $(RELEASE_DIR)/index.html
140 #cp haskell98-bugs.html h98.gif $(RELEASE_DIR)
141 #cp haskell98-revised-bugs.html h98.gif $(RELEASE_DIR)
142
143 publish-pdf: report.pdf
144 gzip < report.pdf > y:Haskell/haskell-report/report.pdf.gz
145
146 #########################################
147 # HTML
148 #########################################
149
150 ht/classes.eps : classes.eps
151 $(CP) $< $@
152
153 .PHONY: html
154 html: $(HT_TEXS) ht/classes.eps ht/haddock.sty
155 cd ht && htlatex haskell.tex "haskell,2"
156
157 #########################################
158 # Generic stuff
159 #########################################
160
161 .PHONY: clean veryclean
162 veryclean: clean
163 $(RM) *~ $(LIB_TEX)
164
165 clean:
166 $(RM) ${HT_TEXS} ht/*.html ht/html/* ht/*.htm ht/hask*.png ht/*.log ht/*.tmp \
167 ht/*.xref ht/classes.eps ht/*.css ht/*.idx ht/*.aux ht/*.dvi \
168 ht/*.4ct ht/*.4tc
169 $(RM) *.dvi *.log *.aux *.ilg *.blg *.toc *.bbl *.idx *.tmp *.out \
170 haskell.tex preface.tex $(PARTS_NO_PREFACE) \
171 haskell.tex haskell.ps haskell.pdf *.o lex.yy.c haskell-report-html/*
172 # NB. don't clean $(LIB_TEX) here
173
174
175 #########################################
176 # Suffix rules
177 #########################################
178
179 %.tex: %.verb
180 $(EXPAND) < $< | $(VERBATIM) | sh ../tools/subsection >$@
181 # The 'subsection' part changes section -> chapter for the book style
182
183 %.verb: %.hs
184 $(EXPAND) < $< | $(SPLITPGM) >$@
185
186 %.tex: %.hs
187 $(EXPAND) < $< | $(SPLITPGM) | $(VERBATIM) >$@
188
189 %.tex: %.hi
190 $(EXPAND) < $< | $(SPLITPGM) | $(VERBATIM) >$@
191
192 %.dvi: %.tex
193 $(LATEX) $<
194
195 %.pdf: %.tex
196 $(PDFLATEX) $<
197 $(BIBTEX) $*
198 $(MAKEINDEX) -i -t haskell.ilg < haskell.idx > haskell.ind
199 $(PDFLATEX) $<
200 $(PDFLATEX) $<
201
202 ht/%.tex: %.verb
203 $(EXPAND) < $< | $(VERB_TEX4HT) | sh ../tools/subsection >$@
204
205 ht/libs/%.tex: libs/%.tex
206 $(CP) $< $@
207
208 jfp: h98-book.tex preface-jfp.tex ${PARTS_NO_PREFACE}
209 -mkdir $(JFP_DIR)
210 for n in h98-book.tex preface-jfp.tex \
211 ${PARTS_NO_PREFACE}; do \
212 ../tools/subsection < $$n > $(JFP_DIR)/$$n ; done
213 cp classes.eps $(JFP_DIR)
214 cp haskell.bbl $(JFP_DIR)/h98-book.bbl
215 cp Makefile-jfp-book $(JFP_DIR)/Makefile
216
217
218
219
220 # Stuff to make the "two-up" version for SIGPLAN Notices:
221 # We take the A4 pages and double them up onto (virtual) A3 pages:
222 # (two A5 pages make one A4 page; two A4 pages make one A3 page; ...)
223 #
224 # % dvidvi '2:0,1(210mm,0)' haskell.dvi > haskell-2up.dvi
225 #
226 # We now print the "A3" pages in landscape, but "magnify" them by
227 # 1 / sqrt(2) ~ 0.7071; this should make our "A4" pages print in an
228 # A4 space: presto! 2up printing!
229 # (except that I've tried to make it give us 1" margins all round
230 # when we print on US 8.5"x11" paper)
231 #
232 # % dvips -t landscape -x 707 haskell-2up.dvi > haskell-2up.ps
233 #
234 # if your "dvips" is set up properly, it will run Metafont for you,
235 # creating just-right magnifications for all the fonts.
236 #
237 # print with: lpr -Pmy-laserwriter haskell-2up.ps
238
239 # These rules keep failing for me (segmentation fault on haskell-2up.dvi)
240 # The output seems fine, though, and the individual commands work
241 # perfectly(!). More network wierdness? KH
242
243 haskell-2up.ps : haskell-2up.dvi
244 dvips -t landscape -x 707 haskell-2up.dvi > haskell-2up.ps
245
246 haskell-2up.dvi : haskellx.dvi
247 -dvidvi '2:0(0in,0in),1(160mm,0in)' haskellx.dvi > haskell-2up.dvi
248
249 haskellx.dvi : sigplan_haskell.dvi
250 dviselect =4: haskell.dvi haskellx.dvi
251
252 haskell-libraries-2up.ps : haskell-libraries-2up.dvi
253 dvips -t landscape -x 707 haskell-libraries-2up.dvi > haskell-libraries-2up.ps
254
255 haskell-libraries-2up.dvi : haskell-librariesx.dvi
256 -dvidvi '2:0(0in,0in),1(160mm,0in)' haskell-librariesx.dvi > haskell-libraries-2up.dvi
257
258 haskell-librariesx.dvi : sigplan_haskell-libraries.dvi
259 dviselect =4: sigplan_haskell-libraries.dvi haskell-librariesx.dvi
260
261
262 # -----------------------------------------------------------------------------
263 # Haddock-generated library docs
264
265 # The results of auto-generating the library docs are in the
266 # repository already, so you only need to re-generate if you are
267 # changing anything.
268
269 # To generate the library docs, we need to run Haddock against the
270 # modules of the haskell2010 package. The package is here:
271 #
272 # http://darcs.haskell.org/packages/haskell2010
273 #
274 # I generated the documentation using a GHC build, but you could
275 # probably do it using just the package sources, as long as you have
276 # GHC and all the package documentation installed.
277 #
278 # Basically the plan is to run Haddock in the same way as for
279 # generating the HTML documentation, except that we
280 #
281 # * replace --html with --latex
282 # * Add --latex-style=NONE to prevent Haddock dumping its haddock.sty
283 # * Add --odir=$(HADDOCK_DIR)
284 #
285 # So to get started, in a GHC build, you could run
286 #
287 # $ cd libraries/haskell2010
288 # $ make html stage=0 FAST=YES
289 #
290 # And grab the Haddock command line that the build system emits.
291 #
292 # The following rules will probably need a lot of manual modification,
293 # sorry about that.
294
295 # Set this to Haddock (version 2.8 or later with the LaTeX back-end)
296 HADDOCK = /home/simonmar/builds/testing/inplace/bin/haddock
297
298 # Set this to the location of the libraries in a GHC build
299 LIBDIR = /home/simonmar/builds/testing/libraries
300
301 haddock :
302 $(HADDOCK) --odir=$(HADDOCK_ODIR) --no-tmp-comp-dir \
303 --latex --latex-style=NONE \
304 --title="haskell2010-1.0.0.0: Compatibility with Haskell 2010" \
305 --read-interface=../ghc-prim,$(LIBDIR)/ghc-prim/dist-install/doc/html/ghc-prim/ghc-prim.haddock \
306 --read-interface=../array-0.3.0.0,$(LIBDIR)/array/dist-install/doc/html/array/array.haddock \
307 --read-interface=../base-4.3.0.0,$(LIBDIR)/base/dist-install/doc/html/base/base.haddock \
308 --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 \
309 $(patsubst %, $(LIBDIR)/haskell2010/%, $(addsuffix .hs, $(subst .,/,$(LIB_MODULES))))
310 for i in $(LIB_TEX); do \
311 sed 's/instance\(\\ [^\]*\)*\\ ReadP\($$\|\\\\\)//g' $$i | \
312 sed 's/instance\(\\ [^\]*\)*\\ P\($$\|\\\\\)//g' | \
313 sed 's/instance\\ Typeable\(1\|\)\(\\ [^\]*\)*\($$\|\\\\\)//g' | \
314 sed 's/instance\\ Exception\(\\ [^\]*\)*\($$\|\\\\\)//g' | \
315 sed 's/instance\(\\ [^\]*\)*\\ \(WordPtr\|IntPtr\)\($$\|\\\\\)//g' | \
316 sed 's/instance\\ (Data\(\\ [^\]*\)*\($$\|\\\\\)//g' >$$i.tmp \
317 && mv $$i.tmp $$i; done
318
319 # NB. Haddock accumulates all instances including some for types and
320 # classes that are not part of the Haskell standard, hence we remove
321 # them manually here. This seemed easier than trying to modify
322 # Haddock to avoid generating them somehow.