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..."
12 /usr
/share
/xml
/docbook
/*/catalog.xml \
13 /opt
/local
/share
/xml
/docbook-xml
/*/catalog.xml \
14 /usr
/share
/sgml
/docbook
/xml-dtd-4.1
.2/xmlcatalog \
15 /usr
/share
/apps
/ksgmltools
2/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"
25 _catalog
=$_try_catalog
30 if test -n "$_catalog"
32 echo "Found SGML catalog at $_catalog"
33 _sgmlcatalog
="export SGML_CATALOG_FILES=$_catalog"
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
/sgml
/docbook
/stylesheet
/xsl
/nwalsh
/html
/chunk.xsl \
44 /usr
/share
/sgml
/docbook
/yelp
/docbook
/html
/chunk.xsl \
45 /usr
/local
/share
/sgml
/docbook
/stylesheet
/xsl
/nwalsh
/html
/chunk.xsl \
46 /usr
/local
/share
/sgml
/docbook
/yelp
/docbook
/html
/chunk.xsl \
47 /usr
/share
/docbook-xsl
/html
/chunk.xsl \
48 /usr
/share
/sgml
/docbook
/xsl-stylesheets
*/html
/chunk.xsl \
49 /usr
/share
/xml
/docbook
/stylesheet
/nwalsh
/current
/html
/chunk.xsl \
50 /opt
/local
/share
/xsl
/docbook-xsl
/html
/chunk.xsl \
53 if test -f "$_try_chunk_xsl"
55 _chunk_xsl
=$_try_chunk_xsl
60 if test -z "$_chunk_xsl"
62 _chunk_xsl
=/usr
/share
/sgml
/docbook
/stylesheet
/xsl
/nwalsh
/html
/chunk.xsl
63 echo "Not found. Using default ($_chunk_xsl)"
66 echo "Found chunk.xsl at $_chunk_xsl"
69 echo "Searching for html/docbook.xsl..."
70 for _try_docbook_xsl
in \
71 /usr
/share
/sgml
/docbook
/stylesheet
/xsl
/nwalsh
/html
/docbook.xsl \
72 /usr
/share
/sgml
/docbook
/yelp
/docbook
/html
/docbook.xsl \
73 /usr
/local
/share
/sgml
/docbook
/stylesheet
/xsl
/nwalsh
/html
/docbook.xsl \
74 /usr
/local
/share
/sgml
/docbook
/yelp
/docbook
/html
/docbook.xsl \
75 /usr
/share
/docbook-xsl
/html
/docbook.xsl \
76 /usr
/share
/sgml
/docbook
/xsl-stylesheets
*/html
/docbook.xsl \
77 /usr
/share
/xml
/docbook
/stylesheet
/nwalsh
/current
/html
/docbook.xsl \
78 /opt
/local
/share
/xsl
/docbook-xsl
/html
/docbook.xsl \
81 if test -f "$_try_docbook_xsl"
83 _docbook_xsl
=$_try_docbook_xsl
88 if test -z "$_docbook_xsl"
90 _docbook_xsl
=/usr
/share
/sgml
/docbook
/stylesheet
/xsl
/nwalsh
/html
/docbook.xsl
91 echo "Not found. Using default ($_docbook_xsl)"
94 echo "Found docbook.xsl at $_docbook_xsl"
97 cat > html-chunk.xsl
<< EOF
98 <?xml version="1.0" encoding="utf-8"?>
99 <!-- **************************************************
100 This file is generated automatically. DO NOT EDIT.
101 ************************************************** -->
102 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
105 <xsl:import href="$_chunk_xsl"/>
106 <xsl:include href="html-common.xsl"/>
112 cat > html-single.xsl
<< EOF
113 <?xml version="1.0" encoding="utf-8"?>
114 <!-- **************************************************
115 This file is generated automatically. DO NOT EDIT.
116 ************************************************** -->
117 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
120 <xsl:import href="$_docbook_xsl"/>
121 <xsl:include href="html-common.xsl"/>
126 echo "Searching for DTD..."
127 #FIXME: This should prefer higher version numbers, not the other way around ..
129 /usr
/share
/xml
/docbook
/*/dtd
/4*/docbookx.dtd \
130 /usr
/share
/xml
/docbook
/*/docbookx.dtd \
131 /usr
/share
/sgml
/docbook
/*/docbookx.dtd \
132 /usr
/share
/sgml
/docbook
/dtd
/*/docbookx.dtd \
133 /usr
/share
/sgml
/docbook
/dtd
/xml
/*/docbookx.dtd \
134 /usr
/share
/docbook-xml
*/docbookx.dtd \
135 /opt
/local
/share
/xml
/docbook-xml
/*/docbookx.dtd \
136 /usr
/share
/apps
/ksgmltools
2/docbook
/*/docbookx.dtd
138 if test -f "$_try_dtd"
147 _dtd
=/usr
/share
/sgml
/docbook
/dtd
/xml
/4.1.2/docbookx.dtd
148 echo "Not found. Using default ($_dtd)."
150 echo "Found docbookx.dtd at $_dtd"
153 for lang
in `grep 'SUBDIRS =' Makefile|cut -d= -f2`; do
154 cat > $lang/main.xml
<< EOF
155 <?xml version="1.0" encoding="utf-8" standalone="no"?>
156 <!-- **************************************************
157 This file is generated automatically. DO NOT EDIT.
158 ************************************************** -->
159 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
164 for file in `find $lang en -name \*.xml -exec basename \{\} \; | sort -u`; do
165 echo '<!ENTITY '$file' SYSTEM "'$file'">' >> $lang/main.xml
168 cat >> $lang/main.xml
<< EOF
170 <book id="index" lang="$lang">
177 echo "Looking for a valid XSLT processor..."
178 # Checks for xsltproc, then checks for the Saxon processor (it needs Java).
179 # Also checks for Jade/OpenJade.
180 #FIXME: Add support for the xalan/xalan2 XSLT processors.
182 if xsltproc
--version &> /dev
/null
184 if test -z "$_fake_chunk_xsl"
186 echo "Found xsltproc. If it works, it's probably the best choice."
187 if test -n "$_catalog"
189 _xsltcommand
="xsltproc --catalogs -o \$1 \$2 \$3"
191 _xsltcommand
="xsltproc -o \$1 \$2 \$3"
194 echo "Found xsltproc but no stylesheets on your system."
195 echo "xsltproc is unusable without stylesheets."
199 # xsltproc not found.
200 # Now try to find a good Java virtual machine.
201 # FIXME: We need more checks for Java virtual machines.
202 if test -z "$_xsltcommand"
204 #FIXME: Add more suitable machines!!!
205 for _try_java
in java gij-3.3 gij-3.2 gij-3.1 gij-3.0 gij
207 if $_try_java --version > /dev
/null
2>&1 ||
$_try_java -version > /dev
/null
2>&1
215 echo "Java VM not found."
217 # Try to find the right jar files for classpath.
218 # This must not trigger on something like saxon-fop-6.4.4.jar.
219 for _try_saxon_jar
in \
220 /usr
/share
/java
/saxon-
[0-9]*.jar \
221 /usr
/local
/share
/java
/saxon-
[0-9]*.jar \
222 /usr
/share
/java
/saxon.jar \
223 /usr
/local
/share
/java
/saxon.jar
225 if test -f "$_try_saxon_jar"
227 _saxon_jar
=$_try_saxon_jar
228 #Don't break to find the _latest_ saxon.jar.
231 if test -n "$_saxon_jar"
233 if test -z "$_fake_chunk_xsl"
235 # _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"
237 if test \"\`dirname \$2 | head -c 1\`\" = \".\"
239 _STYLESHEET=\$_IN_DIR/\$2
249 _DIRNAME=\"\`dirname \$1\`\"
250 _OUTPUT=\"-o \`basename \$1\`\"
254 java -classpath /usr/share/java/saxon.jar com.icl.saxon.StyleSheet \$_OUTPUT \$_IN_DIR/\$3 \$_STYLESHEET
257 echo "Found the Saxon XSLT Processor ($_saxon_jar), using Java VM '$_java'."
259 echo "Found the Saxon XSLT processor but no stylesheets on your system."
260 echo "Saxon is unusable without stylesheets."
266 if test -z "$_xsltcommand"
269 # now try openjade/jade.
270 for _try_jade
in jade openjade
272 if command -v $_try_jade > /dev
/null
280 echo "xsltproc and Saxon XSLT processors not found."
281 echo "I will try to use OpenJade or Jade (using '$_jade')."
282 echo "They aren't (currently) fully supported, however."
283 for _try_docbook_dsl
in \
284 /usr
/share
/sgml
/docbook
/stylesheet
/dsssl
/modular
/html
/docbook.dsl \
285 /usr
/local
/share
/sgml
/docbook
/stylesheet
/dsssl
/modular
/html
/docbook.dsl
287 if test -f "$_try_docbook_dsl"
289 _docbook_dsl
=$_try_docbook_dsl
293 for _try_xml_dcl
in \
294 /usr
/share
/sgml
/declaration
/xml.dcl \
295 /usr
/local
/share
/sgml
/declaration
/xml.dcl
297 if test -f "$_try_xml_dcl"
299 _xml_dcl
=$_try_xml_dcl
303 if test "x$_docbook_dsl" = "x" -o "x$_xml_dcl" = "x"
305 echo "One of the files docbook.dsl and xml.dcl or both of them weren't found."
309 _xsltcommand
="cd \$1 && $_jade -t xml -d $_docbook_dsl $_xml_dcl \$_IN_DIR/\$3"
311 echo "No valid XSLT processor found."
319 cat > $_xsltwrapper << EOF
321 # **************************************************
322 # This file is generated automatically. DO NOT EDIT.
323 # **************************************************
324 # This is a small wrapper script around many ways to call the XSLT processor.
325 # It accepts 3 arguments: <output_dir> <stylesheet_name> <main XML file name>
332 chmod +x
$_xsltwrapper
335 echo "Searching for XML checker..."
336 for _try_xmllint
in xmllint
338 if command -v $_try_xmllint > /dev
/null
2>&1
340 echo "Found $_try_xmllint"
341 if test -n "$_catalog"
343 _xmllint_command
="$_try_xmllint --noout --noent --postvalid --catalogs \$*"
345 _xmllint_command
="$_try_xmllint --noout --noent --postvalid \$*"
351 if test -z "$_xmllint_command"
354 _xmllint_command
=true
357 cat > $_xmllintwrapper << EOF
359 # **************************************************
360 # This file is generated automatically. DO NOT EDIT.
361 # **************************************************
362 # This is a small wrapper for XML lintian programs.
367 chmod +x
$_xmllintwrapper