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
/*/*catalog \
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
/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"
56 _chunk_xsl
=$_try_chunk_xsl
61 if test -z "$_chunk_xsl"
63 _chunk_xsl
=/usr
/share
/sgml
/docbook
/stylesheet
/xsl
/nwalsh
/html
/chunk.xsl
64 echo "Not found. Using default ($_chunk_xsl)"
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"
85 _docbook_xsl
=$_try_docbook_xsl
90 if test -z "$_docbook_xsl"
92 _docbook_xsl
=/usr
/share
/sgml
/docbook
/stylesheet
/xsl
/nwalsh
/html
/docbook.xsl
93 echo "Not found. Using default ($_docbook_xsl)"
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"
107 <xsl:import href="$_chunk_xsl"/>
108 <xsl:include href="html-common.xsl"/>
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"
122 <xsl:import href="$_docbook_xsl"/>
123 <xsl:include href="html-common.xsl"/>
128 echo "Searching for DTD..."
129 #FIXME: This should prefer higher version numbers, not the other way around ..
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
/ksgmltools
2/docbook
/*/docbookx.dtd
140 if test -f "$_try_dtd"
149 _dtd
=/usr
/share
/sgml
/docbook
/dtd
/xml
/4.1.2/docbookx.dtd
150 echo "Not found. Using default ($_dtd)."
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"
166 for file in `find $lang en -name \*.xml -exec basename \{\} \; | sort -u`; do
167 echo '<!ENTITY '$file' SYSTEM "'$file'">' >> $lang/main.xml
170 cat >> $lang/main.xml
<< EOF
172 <book id="index" lang="$lang">
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
186 if test -z "$_fake_chunk_xsl"
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"
193 _xsltcommand
="$_xsltcommand xsltproc --catalogs -o \$OUTPUT \$2 \$3"
195 _xsltcommand
="$_xsltcommand xsltproc -o \$OUTPUT \$2 \$3"
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"
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
219 echo "Java VM not found."
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"
231 _saxon_jar
=$_try_saxon_jar
232 #Don't break to find the _latest_ saxon.jar.
235 if test -n "$_saxon_jar"
237 if test -z "$_fake_chunk_xsl"
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"
241 if test \"\`dirname \$2 | head -c 1\`\" = \".\"
243 _STYLESHEET=\$_IN_DIR/\$2
253 _DIRNAME=\"\`dirname \$1\`\"
254 _OUTPUT=\"-o \`basename \$1\`\"
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'."
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"
273 # now try openjade/jade.
274 for _try_jade
in jade openjade
276 if command -v $_try_jade > /dev
/null
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"
293 _docbook_dsl
=$_try_docbook_dsl
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"
303 _xml_dcl
=$_try_xml_dcl
307 if test "x$_docbook_dsl" = "x" -o "x$_xml_dcl" = "x"
309 echo "One of the files docbook.dsl and xml.dcl or both of them weren't found."
313 _xsltcommand
="cd \$1 && $_jade -t xml -d $_docbook_dsl $_xml_dcl \$_IN_DIR/\$3"
315 echo "No valid XSLT processor found."
323 cat > $_xsltwrapper << EOF
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>
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
344 echo "Found $_try_xmllint"
345 if test -n "$_catalog"
347 _xmllint_command
="$_try_xmllint --noout --noent --postvalid --catalogs \$*"
349 _xmllint_command
="$_try_xmllint --noout --noent --postvalid \$*"
355 if test -z "$_xmllint_command"
358 _xmllint_command
=true
361 cat > $_xmllintwrapper << EOF
363 # **************************************************
364 # This file is generated automatically. DO NOT EDIT.
365 # **************************************************
366 # This is a small wrapper for XML lintian programs.
371 chmod +x
$_xmllintwrapper