Mercurial > mplayer.hg
comparison DOCS/xml/configure @ 10309:3c0e1b182fbc
XML autoconfiguration by Dmitry Baryshkov <lumag@qnc.ru> with some
modifications and improvements by me.
author | diego |
---|---|
date | Wed, 18 Jun 2003 17:37:36 +0000 |
parents | |
children | 373dc373ac4a |
comparison
equal
deleted
inserted
replaced
10308:b27f7db9bccb | 10309:3c0e1b182fbc |
---|---|
1 #!/bin/sh | |
2 | |
3 # Script to check for catalogs, stylesheets, XSL processors and all | |
4 # the other stuff necessary to convert the XML documentation. | |
5 | |
6 _xsltwrapper="xsltproc.sh" | |
7 _xmllintwrapper="xmllint.sh" | |
8 | |
9 for _try_catalog in /etc/sgml/catalog /usr/share/sgml/docbook/xml-dtd-4.1.2/xmlcatalog /usr/share/apps/ksgmltools2/customization/en/catalog /usr/share/sgml/catalog /usr/local/share/sgml/catalog /usr/lib/sgml/catalog /usr/local/lib/sgml/catalog | |
10 do | |
11 if test -f "$_try_catalog" | |
12 then | |
13 _catalog=$_try_catalog | |
14 break | |
15 fi | |
16 done | |
17 | |
18 if test -n "$_catalog" | |
19 then | |
20 echo "Found SGML catalog at $_catalog" | |
21 _sgmlcatalog="export SGML_CATALOG_FILES=$_catalog" | |
22 else | |
23 echo "No SGML catalog found." | |
24 fi | |
25 | |
26 | |
27 | |
28 echo "Searching for stylesheet..." | |
29 for _try_chunk_xsl in /usr/share/sgml/docbook/stylesheet/xsl/nwalsh/html/chunk.xsl /usr/share/sgml/docbook/yelp/docbook/html/chunk.xsl /usr/local/share/sgml/docbook/stylesheet/xsl/nwalsh/html/chunk.xsl /usr/local/share/sgml/docbook/yelp/docbook/html/chunk.xsl | |
30 do | |
31 if test -f "$_try_chunk_xsl" | |
32 then | |
33 _chunk_xsl=$_try_chunk_xsl | |
34 break | |
35 fi | |
36 done | |
37 | |
38 if test -z "$_chunk_xsl" | |
39 then | |
40 echo "Not found." | |
41 _chunk_xsl=/usr/share/sgml/docbook/stylesheet/xsl/nwalsh/html/chunk.xsl | |
42 else | |
43 echo "Found chunk.xsl at $_chunk_xsl" | |
44 fi | |
45 | |
46 cat > html.xsl << EOF | |
47 <?xml version="1.0" encoding="ISO-8859-1"?> | |
48 <!-- ************************************************** | |
49 This file is generated automatically. DO NOT EDIT. | |
50 ************************************************** --> | |
51 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
52 version="1.0"> | |
53 | |
54 <xsl:import href="$_chunk_xsl"/> | |
55 <xsl:include href="html-common.xsl"/> | |
56 | |
57 </xsl:stylesheet> | |
58 EOF | |
59 | |
60 | |
61 | |
62 echo "Looking for a valid XSLT processor..." | |
63 # Checks for xsltproc, then checks for the Saxon processor (it needs Java). | |
64 # Also checks for Jade/OpenJade. | |
65 #FIXME: Add support for the xalan/xalan2 XSLT processors. | |
66 | |
67 if xsltproc --version &> /dev/null | |
68 then | |
69 if test -n "$_chunk_xsl" | |
70 then | |
71 echo "Found xsltproc. If it works, it's probably the best choice." | |
72 if test -n "$_catalog" | |
73 then | |
74 _xsltcommand="xsltproc --catalogs -o \$1 \$2 \$3" | |
75 else | |
76 _xsltcommand="xsltproc -o \$1 \$2 \$3" | |
77 fi | |
78 else | |
79 echo "Found xsltproc but no stylesheets on your system." | |
80 echo "xsltproc is unusable without stylesheets." | |
81 fi | |
82 fi | |
83 | |
84 # xsltproc not found. | |
85 # Now try to find a good Java virtual machine. | |
86 # FIXME: We need more checks for Java virtual machines. | |
87 if test -z "$_xsltcommand" | |
88 then | |
89 for _try_java in java gij-3.3 gij-3.2 gij-3.1 gij-3.0 gij | |
90 do | |
91 if $_try_java --version > /dev/null 2>&1 || $_try_java -version > /dev/null 2>&1 | |
92 then | |
93 _java=$_try_java | |
94 break | |
95 fi | |
96 done | |
97 if test -z "$_java" | |
98 then | |
99 echo "Java VM not found." | |
100 else | |
101 # Try to find the right jar files for classpath. | |
102 # This must not trigger on something like saxon-fop-6.4.4.jar. | |
103 for _try_saxon_jar in /usr/share/java/saxon.jar /usr/local/share/java/saxon.jar /usr/share/java/saxon-[0-9]*.jar /usr/local/share/java/saxon-[0-9]*.jar | |
104 do | |
105 if test -f "$_try_saxon_jar" | |
106 then | |
107 _saxon_jar=$_try_saxon_jar | |
108 #Don't break to find the _latest_ saxon.jar. | |
109 fi | |
110 done | |
111 if test -n "$_saxon_jar" | |
112 then | |
113 if test -n "$_chunk_xsl" | |
114 then | |
115 _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" | |
116 echo "Found the Saxon XSLT Processor ($_saxon_jar), using Java VM '$_java'." | |
117 else | |
118 echo "Found the Saxon XSLT processor but no stylesheets on your system." | |
119 echo "Saxon is unusable without stylesheets." | |
120 fi | |
121 fi | |
122 fi | |
123 fi | |
124 | |
125 if test -z "$_xsltcommand" | |
126 then | |
127 # Java not found. | |
128 # now try openjade/jade. | |
129 for _try_jade in jade openjade | |
130 do | |
131 if command -v $_try_jade > /dev/null | |
132 then | |
133 _jade=$_try_jade | |
134 break | |
135 fi | |
136 done | |
137 if test -n "$_jade" | |
138 then | |
139 echo "xsltproc and Saxon XSLT processors not found." | |
140 echo "I will try to use OpenJade or Jade (using '$_jade')." | |
141 echo "They aren't (currently) fully supported, however." | |
142 for _try_docbook_dsl in /usr/share/sgml/docbook/stylesheet/dsssl/modular/html/docbook.dsl /usr/local/share/sgml/docbook/stylesheet/dsssl/modular/html/docbook.dsl | |
143 do | |
144 if test -f "$_try_docbook_dsl" | |
145 then | |
146 _docbook_dsl=$_try_docbook_dsl | |
147 break | |
148 fi | |
149 done | |
150 for _try_xml_dcl in /usr/share/sgml/declaration/xml.dcl /usr/local/share/sgml/declaration/xml.dcl | |
151 do | |
152 if test -f "$_try_xml_dcl" | |
153 then | |
154 _xml_dcl=$_try_xml_dcl | |
155 break | |
156 fi | |
157 done | |
158 if test "x$_docbook_dsl" = "x" -o "x$_xml_dcl" = "x" | |
159 then | |
160 echo "One of the files docbook.dsl and xml.dcl or both of them weren't found." | |
161 echo "Bailing out." | |
162 exit 1 | |
163 fi | |
164 _xsltcommand="cd \$1 && $_jade -t xml -d $_docbook_dsl $_xml_dcl \$_IN_DIR/\$3 ; mv book1.html index.html" | |
165 else | |
166 echo "No valid XSLT processor found." | |
167 echo "Bailing out." | |
168 exit 1 | |
169 fi | |
170 fi | |
171 | |
172 | |
173 | |
174 cat > $_xsltwrapper << EOF | |
175 #!/bin/sh | |
176 # ************************************************** | |
177 # This file is generated automatically. DO NOT EDIT. | |
178 # ************************************************** | |
179 # This is a small wrapper script around many ways to call the XSLT processor. | |
180 # It accepts 3 arguments: <output_dir> <stylesheet_name> <main XML file name> | |
181 _IN_DIR=\`pwd\` | |
182 | |
183 $_sgmlcatalog | |
184 $_xsltcommand | |
185 EOF | |
186 | |
187 chmod +x $_xsltwrapper | |
188 | |
189 | |
190 | |
191 for _try_xmllint in xmllint | |
192 do | |
193 if command -v $_try_xmllint | |
194 then | |
195 if test -n "$_catalog" | |
196 then | |
197 _xmllint_command="$_try_xmllint --noout --noent --postvalid --catalogs \$*" | |
198 else | |
199 _xmllint_command="$_try_xmllint --noout --noent --postvalid \$*" | |
200 fi | |
201 break | |
202 fi | |
203 done | |
204 | |
205 if test -z "$_xmllint_command" | |
206 then | |
207 _xmllint_command=true | |
208 fi | |
209 | |
210 cat > $_xmllintwrapper << EOF | |
211 #!/bin/sh | |
212 # ************************************************** | |
213 # This file is generated automatically. DO NOT EDIT. | |
214 # ************************************************** | |
215 # This is a small wrapper for XML lintian programs. | |
216 $_sgmlcatalog | |
217 $_xmllint_command | |
218 EOF | |
219 | |
220 chmod +x $_xmllintwrapper |