2003-06-18 17:37:36 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Script to check for catalogs, stylesheets, XSL processors and all
|
|
|
|
# the other stuff necessary to convert the XML documentation.
|
|
|
|
|
2004-01-20 23:27:25 +00:00
|
|
|
echo "Searching for XML catalogs..."
|
2010-07-28 05:35:15 +00:00
|
|
|
for try_catalog in \
|
2005-04-11 22:59:33 +00:00
|
|
|
/etc/sgml/catalog \
|
2005-12-25 17:38:19 +00:00
|
|
|
/usr/share/xml/docbook/*/catalog.xml \
|
2007-01-04 20:42:02 +00:00
|
|
|
/opt/local/share/xml/docbook-xml/*/catalog.xml \
|
2010-07-28 05:35:15 +00:00
|
|
|
/opt/local/share/xml/docbook/*/catalog.xml \
|
2008-03-06 08:52:22 +00:00
|
|
|
/usr/share/sgml/docbook/*/*catalog \
|
2005-04-11 22:59:33 +00:00
|
|
|
/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 \
|
|
|
|
/usr/share/docbook-xml42/catalog.xml \
|
|
|
|
/usr/share/sgml/docbook/xmlcatalog
|
2003-06-18 17:37:36 +00:00
|
|
|
do
|
2010-07-28 05:35:15 +00:00
|
|
|
if test -f "$try_catalog"; then
|
|
|
|
catalog=$try_catalog
|
2003-06-18 17:37:36 +00:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2010-07-28 05:35:15 +00:00
|
|
|
if test -n "$catalog"; then
|
|
|
|
echo "Found SGML catalog at $catalog"
|
|
|
|
catalog_opts=--catalogs
|
2003-06-18 17:37:36 +00:00
|
|
|
else
|
|
|
|
echo "No SGML catalog found."
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-10-21 11:07:02 +00:00
|
|
|
echo "Searching for stylesheets..."
|
|
|
|
echo "Searching for html/chunk.xsl..."
|
2010-07-28 05:35:15 +00:00
|
|
|
for try_chunk_xsl in \
|
2008-03-06 08:52:22 +00:00
|
|
|
/usr/share/xml/docbook/*/html/chunk.xsl \
|
2005-04-11 22:59:33 +00:00
|
|
|
/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 \
|
|
|
|
/usr/share/docbook-xsl/html/chunk.xsl \
|
2006-02-24 17:38:23 +00:00
|
|
|
/usr/share/sgml/docbook/xsl-stylesheets*/html/chunk.xsl \
|
|
|
|
/usr/share/xml/docbook/stylesheet/nwalsh/current/html/chunk.xsl \
|
2007-01-04 20:42:02 +00:00
|
|
|
/opt/local/share/xsl/docbook-xsl/html/chunk.xsl \
|
2006-02-24 17:38:23 +00:00
|
|
|
|
2003-06-18 17:37:36 +00:00
|
|
|
do
|
2010-07-28 05:35:15 +00:00
|
|
|
if test -f "$try_chunk_xsl"; then
|
|
|
|
chunk_xsl=$try_chunk_xsl
|
2003-06-18 17:37:36 +00:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2010-07-28 05:35:15 +00:00
|
|
|
if test -z "$chunk_xsl"; then
|
|
|
|
chunk_xsl=/usr/share/sgml/docbook/stylesheet/xsl/nwalsh/html/chunk.xsl
|
|
|
|
echo "Not found. Using default ($chunk_xsl)"
|
|
|
|
fake_chunk_xsl=yes
|
2003-06-18 17:37:36 +00:00
|
|
|
else
|
2010-07-28 05:35:15 +00:00
|
|
|
echo "Found chunk.xsl at $chunk_xsl"
|
2003-06-18 17:37:36 +00:00
|
|
|
fi
|
|
|
|
|
2003-10-20 09:56:48 +00:00
|
|
|
echo "Searching for html/docbook.xsl..."
|
2010-07-28 05:35:15 +00:00
|
|
|
for try_docbook_xsl in \
|
2008-03-06 08:52:22 +00:00
|
|
|
/usr/share/xml/docbook/*/html/docbook.xsl \
|
2005-04-11 22:59:33 +00:00
|
|
|
/usr/share/sgml/docbook/stylesheet/xsl/nwalsh/html/docbook.xsl \
|
|
|
|
/usr/share/sgml/docbook/yelp/docbook/html/docbook.xsl \
|
|
|
|
/usr/local/share/sgml/docbook/stylesheet/xsl/nwalsh/html/docbook.xsl \
|
|
|
|
/usr/local/share/sgml/docbook/yelp/docbook/html/docbook.xsl \
|
|
|
|
/usr/share/docbook-xsl/html/docbook.xsl \
|
2006-02-24 17:38:23 +00:00
|
|
|
/usr/share/sgml/docbook/xsl-stylesheets*/html/docbook.xsl \
|
|
|
|
/usr/share/xml/docbook/stylesheet/nwalsh/current/html/docbook.xsl \
|
2007-01-04 20:42:02 +00:00
|
|
|
/opt/local/share/xsl/docbook-xsl/html/docbook.xsl \
|
2006-02-24 17:38:23 +00:00
|
|
|
|
2003-10-20 09:56:48 +00:00
|
|
|
do
|
2010-07-28 05:35:15 +00:00
|
|
|
if test -f "$try_docbook_xsl"; then
|
|
|
|
docbook_xsl=$try_docbook_xsl
|
2003-10-20 09:56:48 +00:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2010-07-28 05:35:15 +00:00
|
|
|
if test -z "$docbook_xsl"; then
|
|
|
|
docbook_xsl=/usr/share/sgml/docbook/stylesheet/xsl/nwalsh/html/docbook.xsl
|
|
|
|
echo "Not found. Using default ($docbook_xsl)"
|
2003-10-20 09:56:48 +00:00
|
|
|
else
|
2010-07-28 05:35:15 +00:00
|
|
|
echo "Found docbook.xsl at $docbook_xsl"
|
2003-10-20 09:56:48 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
cat > html-chunk.xsl << EOF
|
2006-11-08 12:39:16 +00:00
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
2003-06-18 17:37:36 +00:00
|
|
|
<!-- **************************************************
|
|
|
|
This file is generated automatically. DO NOT EDIT.
|
|
|
|
************************************************** -->
|
|
|
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
|
|
|
version="1.0">
|
|
|
|
|
2010-07-28 05:35:15 +00:00
|
|
|
<xsl:import href="$chunk_xsl"/>
|
2003-06-18 17:37:36 +00:00
|
|
|
<xsl:include href="html-common.xsl"/>
|
|
|
|
|
|
|
|
</xsl:stylesheet>
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
2003-10-21 11:07:02 +00:00
|
|
|
cat > html-single.xsl << EOF
|
2006-11-08 12:39:16 +00:00
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
2003-10-20 09:56:48 +00:00
|
|
|
<!-- **************************************************
|
|
|
|
This file is generated automatically. DO NOT EDIT.
|
|
|
|
************************************************** -->
|
|
|
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
|
|
|
version="1.0">
|
|
|
|
|
2010-07-28 05:35:15 +00:00
|
|
|
<xsl:import href="$docbook_xsl"/>
|
2003-10-20 09:56:48 +00:00
|
|
|
<xsl:include href="html-common.xsl"/>
|
|
|
|
|
|
|
|
</xsl:stylesheet>
|
|
|
|
EOF
|
|
|
|
|
2004-01-20 23:27:25 +00:00
|
|
|
echo "Searching for DTD..."
|
2007-03-11 16:50:52 +00:00
|
|
|
#FIXME: This should prefer higher version numbers, not the other way around ..
|
2010-07-28 05:35:15 +00:00
|
|
|
for try_dtd in \
|
2007-03-11 16:50:52 +00:00
|
|
|
/usr/share/xml/docbook/*/dtd/4*/docbookx.dtd \
|
2005-12-25 17:38:19 +00:00
|
|
|
/usr/share/xml/docbook/*/docbookx.dtd \
|
2007-02-05 14:17:33 +00:00
|
|
|
/usr/share/sgml/docbook/*/docbookx.dtd \
|
|
|
|
/usr/share/sgml/docbook/dtd/*/docbookx.dtd \
|
|
|
|
/usr/share/sgml/docbook/dtd/xml/*/docbookx.dtd \
|
|
|
|
/usr/share/docbook-xml*/docbookx.dtd \
|
2008-02-21 21:53:24 +00:00
|
|
|
/opt/local/share/xml/docbook*/*/docbookx.dtd \
|
2007-02-05 14:17:33 +00:00
|
|
|
/usr/share/apps/ksgmltools2/docbook/*/docbookx.dtd
|
2004-01-20 23:27:25 +00:00
|
|
|
do
|
2010-07-28 05:35:15 +00:00
|
|
|
if test -f "$try_dtd"; then
|
|
|
|
dtd=$try_dtd
|
2004-01-20 23:27:25 +00:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2010-07-28 05:35:15 +00:00
|
|
|
if test -z "$dtd"; then
|
|
|
|
dtd=/usr/share/sgml/docbook/dtd/xml/4.1.2/docbookx.dtd
|
|
|
|
echo "Not found. Using default ($dtd)."
|
2004-01-20 23:27:25 +00:00
|
|
|
else
|
2010-07-28 05:35:15 +00:00
|
|
|
echo "Found docbookx.dtd at $dtd"
|
2004-01-20 23:27:25 +00:00
|
|
|
fi
|
|
|
|
|
2008-07-19 07:11:18 +00:00
|
|
|
for lang in `grep 'DOC_LANGS =' ../../config.mak|cut -d= -f2`; do
|
2004-01-20 23:27:25 +00:00
|
|
|
cat > $lang/main.xml << EOF
|
2006-11-08 12:39:16 +00:00
|
|
|
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
2006-10-26 09:10:32 +00:00
|
|
|
<!-- **************************************************
|
|
|
|
This file is generated automatically. DO NOT EDIT.
|
|
|
|
************************************************** -->
|
2004-01-20 23:27:25 +00:00
|
|
|
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
|
2010-07-28 05:35:15 +00:00
|
|
|
"$dtd"
|
2009-05-13 02:58:57 +00:00
|
|
|
[
|
2004-01-20 23:27:25 +00:00
|
|
|
EOF
|
|
|
|
|
2010-07-28 05:35:15 +00:00
|
|
|
for file in $(find en -name \*.xml -exec basename \{\} \;); do
|
2010-04-12 10:56:17 +00:00
|
|
|
echo '<!ENTITY '$file' SYSTEM "'$file'">' >> $lang/main.xml
|
2004-01-20 23:27:25 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
cat >> $lang/main.xml << EOF
|
|
|
|
]>
|
|
|
|
<book id="index" lang="$lang">
|
|
|
|
&documentation.xml;
|
|
|
|
</book>
|
|
|
|
EOF
|
2003-10-20 09:56:48 +00:00
|
|
|
|
2004-01-20 23:27:25 +00:00
|
|
|
done
|
2003-06-18 17:37:36 +00:00
|
|
|
|
|
|
|
echo "Looking for a valid XSLT processor..."
|
2010-07-28 05:35:15 +00:00
|
|
|
if xsltproc --version > /dev/null 2>&1; then
|
|
|
|
if test -z "$fake_chunk_xsl"; then
|
2003-06-18 17:37:36 +00:00
|
|
|
echo "Found xsltproc. If it works, it's probably the best choice."
|
2010-07-28 05:35:15 +00:00
|
|
|
xsltcommand="xsltproc $catalog_opts -o \$\$1 \$\$2 \$\$3"
|
2003-06-18 17:37:36 +00:00
|
|
|
else
|
|
|
|
echo "Found xsltproc but no stylesheets on your system."
|
|
|
|
echo "xsltproc is unusable without stylesheets."
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2010-06-23 12:07:29 +00:00
|
|
|
cat > xml.mak << EOF
|
2010-07-28 05:35:15 +00:00
|
|
|
CATALOG = $catalog
|
|
|
|
XMLLINT_COMMAND = xmllint --noout --noent --postvalid $catalog_opts \$*
|
|
|
|
XSLT_COMMAND = $xsltcommand
|
2003-06-18 17:37:36 +00:00
|
|
|
EOF
|