Update release notes and docs with LLVM info.
[ghc-hetmet.git] / docs / man / gen_flags.xsl.sh
1 #!/bin/sh
2
3 if [ "$#" -ne 2 ]
4 then
5     echo "Usage: $0 <ghc commands> <libdir>"
6     exit 1
7 fi
8
9 GHC_COMMANDS="$1"
10 LIBDIR="$2"
11
12 cat <<'EOF'
13 <?xml version="1.0" encoding="iso-8859-1"?>
14 <!DOCTYPE xsl:stylesheet [
15 ]>
16
17 <xsl:stylesheet version="1.0"
18  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
19  xmlns="http://www.w3.org/TR/xhtml1/strict">
20
21 <xsl:output method="text" omit-xml-declaration="yes" />
22
23 <xsl:template match="/">.\"
24 .\" This is a generated file.  Changes might get clobbered.  Edit at own's risk.
25 .\"
26 .TH GHC 1 "2002-10-25" "Glasgow FP Suite" "Glasgow Haskell Compiler"
27 .SH NAME
28 GHC \- the Glasgow Haskell Compiler
29
30
31 .SH SYNOPSIS
32 EOF
33
34 STARTED=0
35
36 for GHC_COMMAND in $GHC_COMMANDS
37 do
38     if [ "$STARTED" -ne 0 ]
39     then
40         echo ".br"
41     fi
42     STARTED=1
43     cat <<EOF
44 .B $GHC_COMMAND
45 .RI [ option | filename ]...
46 EOF
47 done
48
49 cat <<'EOF'
50
51 .SH DESCRIPTION
52 This manual page documents briefly the
53 .B ghc
54 and
55 .B ghci
56 commands.
57 Note that
58 .B ghci
59 is not yet available on all architectures.
60 Extensive documentation is available in various other formats
61 including DVI, PostScript and HTML; see below.
62
63 .PP
64 Each of GHC's command line options is classified as either
65 .IR static " or " dynamic .
66 A static flag may only be specified on the command line, whereas a
67 dynamic flag may also be given in an \f(CROPTIONS\fP pragma in a
68 source file or set from the GHCi command-line with \f(CR:set\fP.
69
70 As a rule of thumb, all the language options are dynamic, as are the
71 warning options and the debugging options.
72
73 The rest are static, with the notable exceptions of
74 .BR \-v ", " \-cpp ", " \-fasm ", " \-fvia\-C ", " \-fllvm ", and
75 " \-#include .
76 The OPTIONS sections lists the status of each flag.
77
78 .PP
79 Common suffixes of file names for Haskell are:
80 .TP
81 .B .hs
82 Haskell source code; preprocess, compile
83 .TP
84 .B .lhs
85 literate Haskell source; unlit, preprocess, compile
86 .TP
87 .B .hi
88 Interface file; contains information about exported
89 symbols
90 .TP
91 .B .hc
92 intermediate C files
93 .TP
94 .BI . x _o
95 way
96 .I x
97 object files; common ways are:
98 .BR p ", " u ", " s
99 .TP
100 .BI . x _hi
101 way
102 .I x
103 interface files
104
105
106 .SH OPTIONS
107
108 <xsl:apply-templates select="sect1/sect2" mode="overview"/>
109
110 <xsl:apply-templates select="sect1/sect2"/>
111
112
113 .SH FILES
114 EOF
115
116 echo ".I $LIBDIR"
117 cat <<'EOF'
118
119 .SH COPYRIGHT
120
121 Copyright 2002, The University Court of the University of Glasgow.
122 .br
123 All rights reserved.
124
125
126 .SH AUTHOR
127
128 This manual page was generated from the XML documentation of GHC with blood,
129 sweat, tears and a breaks-if-you-look-at-it-the-wrong-way XSL
130 stylesheet originally written by Michael Weber &lt;michaelw@debian.org&gt;
131 for the Debian GNU/Linux system (but may be used by others).
132
133 .\" End
134 </xsl:template>
135
136
137 <xsl:template match="sect1/sect2" mode="overview">
138 <xsl:choose>
139 <xsl:when test="contains(title/.,' (')">
140 .SS <xsl:value-of select="substring-before(title/.,' (')"/>
141 </xsl:when>
142 <xsl:otherwise>
143 .SS <xsl:value-of select="title/."/>
144 </xsl:otherwise>
145 </xsl:choose>
146 .nh
147 <xsl:apply-templates select="informaltable/tgroup/tbody/row" mode="overview"/>
148 .hy
149 </xsl:template>
150
151
152 <xsl:template match="sect1/sect2">
153 <xsl:choose>
154 <xsl:when test="contains(title/.,' (')">
155
156 .SH <xsl:value-of select='translate(substring-before(title/.," ("),"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")'/>
157
158 </xsl:when>
159 <xsl:otherwise>
160
161 .SH <xsl:value-of select='translate(title/.,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")'/>
162
163 </xsl:otherwise>
164 </xsl:choose><xsl:text>
165 </xsl:text>
166 <xsl:apply-templates select="informaltable/tgroup/tbody/row"/>
167 </xsl:template>
168
169
170 <xsl:template match="informaltable/tgroup/tbody/row" mode="overview">
171   <xsl:apply-templates select="entry[1]|entry[4]" mode="overview"/>
172   <xsl:text> </xsl:text>
173 </xsl:template>
174
175 <xsl:template match="informaltable/tgroup/tbody/row">
176 .TP
177 <xsl:apply-templates select="entry[1]"/><xsl:text>
178 </xsl:text>
179 <xsl:variable name="x">
180 <xsl:apply-templates select="entry[2]"/>
181 </xsl:variable>
182 <xsl:value-of select="normalize-space($x)"/>
183 .rj
184 [<xsl:apply-templates select="entry[3]"/>]
185 <!-- IGNORE NEGATIVE OPTIONS
186 <xsl:if test="not(entry[4]='-')">
187   <xsl:text>.TP
188 </xsl:text>
189   <xsl:apply-templates select="entry[4]/option"/>
190 </xsl:if>
191  -->
192 </xsl:template>
193
194
195 <xsl:template match="option" mode="escape-dash">
196   <xsl:variable name="x">
197     <xsl:value-of select="."/>
198   </xsl:variable>
199   <xsl:variable name="y">
200     <xsl:call-template name="replace-string">
201       <xsl:with-param name="text" select="$x"/>
202       <xsl:with-param name="from" select="'-'"/>
203       <xsl:with-param name="to" select="'\-'"/>
204     </xsl:call-template>
205   </xsl:variable>
206   <xsl:value-of select="$y"/>
207 </xsl:template>
208
209 <xsl:template match="option" mode="overview">
210   <xsl:apply-templates select="." mode="escape-dash"/>
211 </xsl:template>
212
213 <xsl:template match="option">
214   <xsl:text>\fB</xsl:text>
215   <xsl:apply-templates select="." mode="escape-dash"/>
216   <xsl:text>\fP</xsl:text>
217 </xsl:template>
218
219
220 <xsl:template match="entry[1]" mode="overview">
221   <xsl:apply-templates mode="overview"/>
222   <xsl:text> </xsl:text>
223 </xsl:template>
224
225 <xsl:template match="entry[1]">
226   <xsl:apply-templates/><xsl:text> </xsl:text>
227 </xsl:template>
228
229 <xsl:template match="entry[4]" mode="overview">
230   <xsl:if test="not(.='-')">
231     <xsl:apply-templates select="option" mode="overview"/>
232     <xsl:text> </xsl:text>
233   </xsl:if>
234 </xsl:template>
235
236 <xsl:template match="entry[4]">
237   <xsl:if test="not(.='-')">
238     <xsl:value-of select="."/><xsl:text> </xsl:text>
239   </xsl:if>
240 </xsl:template>
241
242
243 <xsl:template match="replaceable" mode="overview">
244   <xsl:apply-templates select="."/>
245 </xsl:template>
246
247 <xsl:template match="replaceable">
248   <xsl:text>\fI</xsl:text>
249   <xsl:value-of select='.'/>
250   <xsl:text>\fP</xsl:text>
251 </xsl:template>
252
253
254 <xsl:template match="literal">
255   <xsl:text>\f(CR</xsl:text>
256   <xsl:value-of select="."/>
257   <xsl:text>\fP</xsl:text>
258 </xsl:template>
259
260
261
262 <!-- reusable replace-string function -->
263   <xsl:template name="replace-string">
264      <xsl:param name="text"/>
265      <xsl:param name="from"/>
266      <xsl:param name="to"/>
267
268      <xsl:choose>
269        <xsl:when test="contains($text, $from)">
270
271          <xsl:variable name="before" select="substring-before($text, $from)"/>
272          <xsl:variable name="after" select="substring-after($text, $from)"/>
273          <xsl:variable name="prefix" select="concat($before, $to)"/>
274
275          <xsl:value-of select="$before"/>
276          <xsl:value-of select="$to"/>
277          <xsl:call-template name="replace-string">
278            <xsl:with-param name="text" select="$after"/>
279            <xsl:with-param name="from" select="$from"/>
280            <xsl:with-param name="to" select="$to"/>
281          </xsl:call-template>
282        </xsl:when>
283        <xsl:otherwise>
284          <xsl:value-of select="$text"/>
285        </xsl:otherwise>
286      </xsl:choose>
287   </xsl:template>
288 </xsl:stylesheet>
289 EOF
290