Add rules to install gmplayer manual pages.
[mplayer/glamo.git] / DOCS / xml / configure
bloba15cdecd032efaf895d33065588bd04f0eca49e4
1 #!/bin/sh
3 # Script to check for catalogs, stylesheets, XSL processors and all
4 # the other stuff necessary to convert the XML documentation.
6 _xsltwrapper="xsltproc.sh"
7 _xmllintwrapper="xmllint.sh"
9 echo "Searching for XML catalogs..."
10 for _try_catalog in \
11 /etc/sgml/catalog \
12 /usr/share/xml/docbook/*/catalog.xml \
13 /opt/local/share/xml/docbook-xml/*/catalog.xml \
14 /usr/share/sgml/docbook/*/*catalog \
15 /usr/share/apps/ksgmltools2/customization/en/catalog \
16 /usr/share/sgml/catalog \
17 /usr/local/share/sgml/catalog \
18 /usr/lib/sgml/catalog \
19 /usr/local/lib/sgml/catalog \
20 /usr/share/docbook-xml42/catalog.xml \
21 /usr/share/sgml/docbook/xmlcatalog
23 if test -f "$_try_catalog"
24 then
25 _catalog=$_try_catalog
26 break
28 done
30 if test -n "$_catalog"
31 then
32 echo "Found SGML catalog at $_catalog"
33 _sgmlcatalog="export SGML_CATALOG_FILES=$_catalog"
34 else
35 echo "No SGML catalog found."
40 echo "Searching for stylesheets..."
41 echo "Searching for html/chunk.xsl..."
42 for _try_chunk_xsl in \
43 /usr/share/xml/docbook/*/html/chunk.xsl \
44 /usr/share/sgml/docbook/stylesheet/xsl/nwalsh/html/chunk.xsl \
45 /usr/share/sgml/docbook/yelp/docbook/html/chunk.xsl \
46 /usr/local/share/sgml/docbook/stylesheet/xsl/nwalsh/html/chunk.xsl \
47 /usr/local/share/sgml/docbook/yelp/docbook/html/chunk.xsl \
48 /usr/share/docbook-xsl/html/chunk.xsl \
49 /usr/share/sgml/docbook/xsl-stylesheets*/html/chunk.xsl \
50 /usr/share/xml/docbook/stylesheet/nwalsh/current/html/chunk.xsl \
51 /opt/local/share/xsl/docbook-xsl/html/chunk.xsl \
54 if test -f "$_try_chunk_xsl"
55 then
56 _chunk_xsl=$_try_chunk_xsl
57 break
59 done
61 if test -z "$_chunk_xsl"
62 then
63 _chunk_xsl=/usr/share/sgml/docbook/stylesheet/xsl/nwalsh/html/chunk.xsl
64 echo "Not found. Using default ($_chunk_xsl)"
65 _fake_chunk_xsl=yes
66 else
67 echo "Found chunk.xsl at $_chunk_xsl"
70 echo "Searching for html/docbook.xsl..."
71 for _try_docbook_xsl in \
72 /usr/share/xml/docbook/*/html/docbook.xsl \
73 /usr/share/sgml/docbook/stylesheet/xsl/nwalsh/html/docbook.xsl \
74 /usr/share/sgml/docbook/yelp/docbook/html/docbook.xsl \
75 /usr/local/share/sgml/docbook/stylesheet/xsl/nwalsh/html/docbook.xsl \
76 /usr/local/share/sgml/docbook/yelp/docbook/html/docbook.xsl \
77 /usr/share/docbook-xsl/html/docbook.xsl \
78 /usr/share/sgml/docbook/xsl-stylesheets*/html/docbook.xsl \
79 /usr/share/xml/docbook/stylesheet/nwalsh/current/html/docbook.xsl \
80 /opt/local/share/xsl/docbook-xsl/html/docbook.xsl \
83 if test -f "$_try_docbook_xsl"
84 then
85 _docbook_xsl=$_try_docbook_xsl
86 break
88 done
90 if test -z "$_docbook_xsl"
91 then
92 _docbook_xsl=/usr/share/sgml/docbook/stylesheet/xsl/nwalsh/html/docbook.xsl
93 echo "Not found. Using default ($_docbook_xsl)"
94 _fake_docbook_xsl=yes
95 else
96 echo "Found docbook.xsl at $_docbook_xsl"
99 cat > html-chunk.xsl << EOF
100 <?xml version="1.0" encoding="utf-8"?>
101 <!-- **************************************************
102 This file is generated automatically. DO NOT EDIT.
103 ************************************************** -->
104 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
105 version="1.0">
107 <xsl:import href="$_chunk_xsl"/>
108 <xsl:include href="html-common.xsl"/>
110 </xsl:stylesheet>
114 cat > html-single.xsl << EOF
115 <?xml version="1.0" encoding="utf-8"?>
116 <!-- **************************************************
117 This file is generated automatically. DO NOT EDIT.
118 ************************************************** -->
119 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
120 version="1.0">
122 <xsl:import href="$_docbook_xsl"/>
123 <xsl:include href="html-common.xsl"/>
125 </xsl:stylesheet>
128 echo "Searching for DTD..."
129 #FIXME: This should prefer higher version numbers, not the other way around ..
130 for _try_dtd in \
131 /usr/share/xml/docbook/*/dtd/4*/docbookx.dtd \
132 /usr/share/xml/docbook/*/docbookx.dtd \
133 /usr/share/sgml/docbook/*/docbookx.dtd \
134 /usr/share/sgml/docbook/dtd/*/docbookx.dtd \
135 /usr/share/sgml/docbook/dtd/xml/*/docbookx.dtd \
136 /usr/share/docbook-xml*/docbookx.dtd \
137 /opt/local/share/xml/docbook*/*/docbookx.dtd \
138 /usr/share/apps/ksgmltools2/docbook/*/docbookx.dtd
140 if test -f "$_try_dtd"
141 then
142 _dtd=$_try_dtd
143 break
145 done
147 if test -z "$_dtd"
148 then
149 _dtd=/usr/share/sgml/docbook/dtd/xml/4.1.2/docbookx.dtd
150 echo "Not found. Using default ($_dtd)."
151 else
152 echo "Found docbookx.dtd at $_dtd"
155 for lang in `grep 'DOC_LANGS =' ../../config.mak|cut -d= -f2`; do
156 cat > $lang/main.xml << EOF
157 <?xml version="1.0" encoding="utf-8" standalone="no"?>
158 <!-- **************************************************
159 This file is generated automatically. DO NOT EDIT.
160 ************************************************** -->
161 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
162 "$_dtd"
166 for file in `find $lang en -name \*.xml -exec basename \{\} \; | sort -u`; do
167 echo '<!ENTITY '$file' SYSTEM "'$file'">' >> $lang/main.xml
168 done
170 cat >> $lang/main.xml << EOF
172 <book id="index" lang="$lang">
173 &documentation.xml;
174 </book>
177 done
179 echo "Looking for a valid XSLT processor..."
180 # Checks for xsltproc, then checks for the Saxon processor (it needs Java).
181 # Also checks for Jade/OpenJade.
182 #FIXME: Add support for the xalan/xalan2 XSLT processors.
184 if xsltproc --version &> /dev/null
185 then
186 if test -z "$_fake_chunk_xsl"
187 then
188 echo "Found xsltproc. If it works, it's probably the best choice."
189 # HACK: xslt always need a target file if a doctype is set
190 _xsltcommand="OUTPUT=\"\$1\"; if test -d \"\$OUTPUT\" ; then OUTPUT=\"\$OUTPUT/dummy.html\" ; fi;"
191 if test -n "$_catalog"
192 then
193 _xsltcommand="$_xsltcommand xsltproc --catalogs -o \$OUTPUT \$2 \$3"
194 else
195 _xsltcommand="$_xsltcommand xsltproc -o \$OUTPUT \$2 \$3"
197 else
198 echo "Found xsltproc but no stylesheets on your system."
199 echo "xsltproc is unusable without stylesheets."
203 # xsltproc not found.
204 # Now try to find a good Java virtual machine.
205 # FIXME: We need more checks for Java virtual machines.
206 if test -z "$_xsltcommand"
207 then
208 #FIXME: Add more suitable machines!!!
209 for _try_java in java gij-3.3 gij-3.2 gij-3.1 gij-3.0 gij
211 if $_try_java --version > /dev/null 2>&1 || $_try_java -version > /dev/null 2>&1
212 then
213 _java=$_try_java
214 break
216 done
217 if test -z "$_java"
218 then
219 echo "Java VM not found."
220 else
221 # Try to find the right jar files for classpath.
222 # This must not trigger on something like saxon-fop-6.4.4.jar.
223 for _try_saxon_jar in \
224 /usr/share/java/saxon-[0-9]*.jar \
225 /usr/local/share/java/saxon-[0-9]*.jar \
226 /usr/share/java/saxon.jar \
227 /usr/local/share/java/saxon.jar
229 if test -f "$_try_saxon_jar"
230 then
231 _saxon_jar=$_try_saxon_jar
232 #Don't break to find the _latest_ saxon.jar.
234 done
235 if test -n "$_saxon_jar"
236 then
237 if test -z "$_fake_chunk_xsl"
238 then
239 # _xsltcommand="cd \$1 && if test \"\`dirname \$2 | head -c 1\`\" = \".\" ; then $_java -classpath $_saxon_jar com.icl.saxon.StyleSheet \$_IN_DIR/\$3 \$_IN_DIR/\$2 ; else $_java -classpath $_saxon_jar com.icl.saxon.StyleSheet \$_IN_DIR/\$3 \$2 ;fi"
240 _xsltcommand="
241 if test \"\`dirname \$2 | head -c 1\`\" = \".\"
242 then
243 _STYLESHEET=\$_IN_DIR/\$2
244 else
245 _STYLESHEET=\$2
248 if test -d \$1
249 then
250 _DIRNAME=\"\$1\"
251 _OUTPUT=\"\"
252 else
253 _DIRNAME=\"\`dirname \$1\`\"
254 _OUTPUT=\"-o \`basename \$1\`\"
257 cd \$_DIRNAME &&
258 java -classpath /usr/share/java/saxon.jar com.icl.saxon.StyleSheet \$_OUTPUT \$_IN_DIR/\$3 \$_STYLESHEET
261 echo "Found the Saxon XSLT Processor ($_saxon_jar), using Java VM '$_java'."
262 else
263 echo "Found the Saxon XSLT processor but no stylesheets on your system."
264 echo "Saxon is unusable without stylesheets."
270 if test -z "$_xsltcommand"
271 then
272 # Java not found.
273 # now try openjade/jade.
274 for _try_jade in jade openjade
276 if command -v $_try_jade > /dev/null
277 then
278 _jade=$_try_jade
279 break
281 done
282 if test -n "$_jade"
283 then
284 echo "xsltproc and Saxon XSLT processors not found."
285 echo "I will try to use OpenJade or Jade (using '$_jade')."
286 echo "They aren't (currently) fully supported, however."
287 for _try_docbook_dsl in \
288 /usr/share/sgml/docbook/stylesheet/dsssl/modular/html/docbook.dsl \
289 /usr/local/share/sgml/docbook/stylesheet/dsssl/modular/html/docbook.dsl
291 if test -f "$_try_docbook_dsl"
292 then
293 _docbook_dsl=$_try_docbook_dsl
294 break
296 done
297 for _try_xml_dcl in \
298 /usr/share/sgml/declaration/xml.dcl \
299 /usr/local/share/sgml/declaration/xml.dcl
301 if test -f "$_try_xml_dcl"
302 then
303 _xml_dcl=$_try_xml_dcl
304 break
306 done
307 if test "x$_docbook_dsl" = "x" -o "x$_xml_dcl" = "x"
308 then
309 echo "One of the files docbook.dsl and xml.dcl or both of them weren't found."
310 echo "Bailing out."
311 exit 1
313 _xsltcommand="cd \$1 && $_jade -t xml -d $_docbook_dsl $_xml_dcl \$_IN_DIR/\$3"
314 else
315 echo "No valid XSLT processor found."
316 echo "Bailing out."
317 exit 1
323 cat > $_xsltwrapper << EOF
324 #!/bin/sh
325 # **************************************************
326 # This file is generated automatically. DO NOT EDIT.
327 # **************************************************
328 # This is a small wrapper script around many ways to call the XSLT processor.
329 # It accepts 3 arguments: <output_dir> <stylesheet_name> <main XML file name>
330 _IN_DIR=\`pwd\`
332 $_sgmlcatalog
333 $_xsltcommand
336 chmod +x $_xsltwrapper
339 echo "Searching for XML checker..."
340 for _try_xmllint in xmllint
342 if command -v $_try_xmllint > /dev/null 2>&1
343 then
344 echo "Found $_try_xmllint"
345 if test -n "$_catalog"
346 then
347 _xmllint_command="$_try_xmllint --noout --noent --postvalid --catalogs \$*"
348 else
349 _xmllint_command="$_try_xmllint --noout --noent --postvalid \$*"
351 break
353 done
355 if test -z "$_xmllint_command"
356 then
357 echo "Not found"
358 _xmllint_command=true
361 cat > $_xmllintwrapper << EOF
362 #!/bin/sh
363 # **************************************************
364 # This file is generated automatically. DO NOT EDIT.
365 # **************************************************
366 # This is a small wrapper for XML lintian programs.
367 $_sgmlcatalog
368 $_xmllint_command
371 chmod +x $_xmllintwrapper