add finalizeForeignPtr
[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_INDEX = ../tools/run_index
24 VERBATIM = ../tools/verbatim
25 VERB_TEX4HT = ../tools/verb-tex4ht
26
27 # splitAndIndexPgm won't work unless you have "perl"
28 SPLITPGM = perl ../tools/splitAndIndexPgm
29
30 RM = rm -f
31 CP = cp
32 LN = ln -sf
33 LATEX = latex
34 PDFLATEX = pdflatex
35 BIBTEX = bibtex
36 MAKEINDEX = makeindex
37
38 # 'expand' expands tabs to spaces
39 # On my machine the windows program (which does something
40 # quite different) shadows it. Sigh.
41 EXPAND = expand
42 # EXPAND = c:/cygwin/bin/expand
43
44
45 #########################################
46 # Files
47 #########################################
48
49 RELEASE_DIR = ../haskell-prime-draft
50 JFP_DIR = ../jfp-release
51
52 PARTS = haskell.tex preface.tex $(PARTS_NO_PREFACE) $(LIB_TEX)
53
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 fixity.tex \
59 pragmas.tex standard-prelude.tex \
60 syntax-lexical.tex syntax-iso.tex ffi.tex \
61 Prelude.tex PreludeList.tex PreludeText.tex PreludeIO.tex
62
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 Numeric \
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 haskell.dvi: haskell.tex ${PARTS}
116 haskell.pdf: haskell.tex haddock.sty ${PARTS}
117
118 haskell.ps : haskell.dvi
119 dvips haskell.dvi -o haskell.ps
120
121 # Can't use pdflatex because of eps inclusion
122
123 release: haskell.ps html
124 if ! test -d $(RELEASE_DIR); then mkdir $(RELEASE_DIR); fi
125 ps2pdf haskell.ps
126 gzip < haskell.ps > $(RELEASE_DIR)/haskell.ps.gz
127 cp haskell.pdf $(RELEASE_DIR)/haskell.pdf
128 cp -r haskell-report-html $(RELEASE_DIR)
129 tar cvf - haskell-report-html | gzip > $(RELEASE_DIR)/haskell-report-html.tar.gz
130 cp *.png *.gif $(RELEASE_DIR)
131 #cp h98-revised.html $(RELEASE_DIR)/index.html
132 #cp haskell98-bugs.html h98.gif $(RELEASE_DIR)
133 #cp haskell98-revised-bugs.html h98.gif $(RELEASE_DIR)
134
135 publish-pdf: report.pdf
136 gzip < report.pdf > y:Haskell/haskell-report/report.pdf.gz
137
138 #########################################
139 # HTML
140 #########################################
141
142 ht/classes.eps : classes.eps
143 $(CP) $< $@
144
145 .PHONY: html
146 html: $(HT_TEXS) ht/classes.eps ht/haddock.sty ht/haskell.bbl
147 cd ht && htlatex haskell.tex "haskell,2"
148
149 # Grab the .bbl file from building the PDF version, so we get a bibliography
150 # in the tex4ht version too.
151 ht/haskell.bbl : haskell.bbl
152 $(CP) $< $@
153
154 haskell.bbl : haskell.pdf
155
156 #########################################
157 # Generic stuff
158 #########################################
159
160 .PHONY: clean veryclean
161 veryclean: clean
162 $(RM) *~ $(LIB_TEX)
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 ht/*.bbl ht/*.blg
168 $(RM) *.dvi *.log *.aux *.ilg *.blg *.toc *.bbl *.idx *.tmp *.out \
169 haskell.tex preface.tex $(PARTS_NO_PREFACE) \
170 haskell.tex haskell.ps haskell.pdf *.o lex.yy.c haskell-report-html/* \
171 libs/haddock.sty libs/Prelude.tex libs/haskell*.tex
172
173 # NB. don't clean $(LIB_TEX) here
174
175
176 #########################################
177 # Suffix rules
178 #########################################
179
180 %.tex: %.verb
181 $(EXPAND) < $< | $(VERBATIM) | sh ../tools/subsection >$@
182 # The 'subsection' part changes section -> chapter for the book style
183
184 %.verb: %.hs
185 $(EXPAND) < $< | $(SPLITPGM) >$@
186
187 %.tex: %.hs
188 $(EXPAND) < $< | $(SPLITPGM) | $(VERBATIM) >$@
189
190 %.tex: %.hi
191 $(EXPAND) < $< | $(SPLITPGM) | $(VERBATIM) >$@
192
193 %.dvi: %.tex
194 $(LATEX) $<
195
196 %.pdf: %.tex
197 $(PDFLATEX) $<
198 $(BIBTEX) $*
199 $(MAKEINDEX) -i -t haskell.ilg < haskell.idx > haskell.ind
200 $(PDFLATEX) $<
201 $(PDFLATEX) $<
202
203 ht/%.tex: %.verb
204 $(EXPAND) < $< | $(VERB_TEX4HT) | sh ../tools/subsection >$@
205
206 ht/libs/%.tex: libs/%.tex
207 $(CP) $< $@
208
209 jfp: h98-book.tex preface-jfp.tex ${PARTS_NO_PREFACE}
210 -mkdir $(JFP_DIR)
211 for n in h98-book.tex preface-jfp.tex \
212 ${PARTS_NO_PREFACE}; do \
213 ../tools/subsection < $$n > $(JFP_DIR)/$$n ; done
214 cp classes.eps $(JFP_DIR)
215 cp haskell.bbl $(JFP_DIR)/h98-book.bbl
216 cp Makefile-jfp-book $(JFP_DIR)/Makefile
217
218
219
220
221 # Stuff to make the "two-up" version for SIGPLAN Notices:
222 # We take the A4 pages and double them up onto (virtual) A3 pages:
223 # (two A5 pages make one A4 page; two A4 pages make one A3 page; ...)
224 #
225 # % dvidvi '2:0,1(210mm,0)' haskell.dvi > haskell-2up.dvi
226 #
227 # We now print the "A3" pages in landscape, but "magnify" them by
228 # 1 / sqrt(2) ~ 0.7071; this should make our "A4" pages print in an
229 # A4 space: presto! 2up printing!
230 # (except that I've tried to make it give us 1" margins all round
231 # when we print on US 8.5"x11" paper)
232 #
233 # % dvips -t landscape -x 707 haskell-2up.dvi > haskell-2up.ps
234 #
235 # if your "dvips" is set up properly, it will run Metafont for you,
236 # creating just-right magnifications for all the fonts.
237 #
238 # print with: lpr -Pmy-laserwriter haskell-2up.ps
239
240 # These rules keep failing for me (segmentation fault on haskell-2up.dvi)
241 # The output seems fine, though, and the individual commands work
242 # perfectly(!). More network wierdness? KH
243
244 haskell-2up.ps : haskell-2up.dvi
245 dvips -t landscape -x 707 haskell-2up.dvi > haskell-2up.ps
246
247 haskell-2up.dvi : haskellx.dvi
248 -dvidvi '2:0(0in,0in),1(160mm,0in)' haskellx.dvi > haskell-2up.dvi
249
250 haskellx.dvi : sigplan_haskell.dvi
251 dviselect =4: haskell.dvi haskellx.dvi
252
253 haskell-libraries-2up.ps : haskell-libraries-2up.dvi
254 dvips -t landscape -x 707 haskell-libraries-2up.dvi > haskell-libraries-2up.ps
255
256 haskell-libraries-2up.dvi : haskell-librariesx.dvi
257 -dvidvi '2:0(0in,0in),1(160mm,0in)' haskell-librariesx.dvi > haskell-libraries-2up.dvi
258
259 haskell-librariesx.dvi : sigplan_haskell-libraries.dvi
260 dviselect =4: sigplan_haskell-libraries.dvi haskell-librariesx.dvi
261
262
263 # -----------------------------------------------------------------------------
264 # Haddock-generated library docs
265
266 # The results of auto-generating the library docs are in the
267 # repository already, so you only need to re-generate if you are
268 # changing anything.
269
270 # To generate the library docs, we need to run Haddock against the
271 # modules of the haskell2010 package.
272 #
273 # Basically the plan is to run Haddock in the same way as for
274 # generating the HTML documentation, except that we
275 #
276 # * replace --html with --latex
277 # * Add --latex-style=NONE to prevent Haddock dumping its haddock.sty
278 # * Add --odir=$(HADDOCK_DIR)
279 #
280 # Hopefully you should be able to modify the variables below to set
281 # the location of your GHC build and the versions of the relevant
282 # packages, and then say 'make haddock' to build the docs. Then you
283 # can use 'darcs whatsnew' to see the differences between what you
284 # just generated and what is checked into the repository.
285
286 GHC_BUILD = /home/simonmar/builds/testing
287
288 # Change these to match the current versions. Use
289 #
290 # $(GHC_BUILD)/inplace/bin/ghc-pkg list
291 #
292 # to find out what they should be.
293 #
294 HASKELL2010_PKG = haskell2010-1.0.0.0
295 BASE_PKG = base-4.3.0.0
296 ARRAY_PKG = array-0.3.0.0
297
298 GHC_PRIM_PKG = ghc-prim
299
300 HADDOCK = $(GHC_BUILD)/inplace/bin/haddock
301 LIBDIR = $(GHC_BUILD)/libraries
302
303 haddock :
304 $(HADDOCK) --odir=$(HADDOCK_ODIR) --no-tmp-comp-dir \
305 --latex --latex-style=NONE \
306 --title="haskell2010-1.0.0.0: Compatibility with Haskell 2010" \
307 --read-interface=../$(GHC_PRIM_PKG),$(LIBDIR)/ghc-prim/dist-install/doc/html/ghc-prim/ghc-prim.haddock \
308 --read-interface=../$(ARRAY_PKG),$(LIBDIR)/array/dist-install/doc/html/array/array.haddock \
309 --read-interface=../$(BASE_PKG),$(LIBDIR)/base/dist-install/doc/html/base/base.haddock \
310 --optghc=-package-name --optghc=$(HASKELL2010_PKG) --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_PKG) --optghc=-package --optghc=$(BASE_PKG) --optghc=-XPackageImports --optghc=-XCPP --optghc=-no-user-package-conf --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 \
311 $(patsubst %, $(LIBDIR)/haskell2010/%, $(addsuffix .hs, $(subst .,/,$(LIB_MODULES))))
312 for i in $(LIB_TEX); do \
313 sed 's/instance\(\\ [^\]*\)*\\ ReadP\($$\|\\\\\)//g' $$i | \
314 sed 's/instance\(\\ [^\]*\)*\\ P\($$\|\\\\\)//g' | \
315 sed 's/instance\\ Typeable\(1\|\)\(\\ [^\]*\)*\($$\|\\\\\)//g' | \
316 sed 's/instance\\ Exception\(\\ [^\]*\)*\($$\|\\\\\)//g' | \
317 sed 's/instance\\ (Data\(\\ [^\]*\)*\($$\|\\\\\)//g' >$$i.tmp \
318 && mv $$i.tmp $$i; done
319
320 # NB. Haddock accumulates all instances including some for types and
321 # classes that are not part of the Haskell standard, hence we remove
322 # them manually here. This seemed easier than trying to modify
323 # Haddock to avoid generating them somehow.