#!/bin/sh
# Script to try and find out where XSL stylesheets are installed on
# this system.  If we succeed, we build FOO.xsl from FOO.xsl.in.

function generate_xsl2()
{
	echo '<?xml version="1.0" encoding="utf-8"?>' > $2
	echo >> $2
	echo '<!-- DO NOT EDIT THIS FILE. IT IS GENERATED FROM '$2.in' -->' >> $2
	echo >> $2
	sed -e "s/XSLDIR/$1/" < $2.in >> $2
}
	
function generate_xsl()
{
	generate_xsl2 "$1" fo.xsl
	generate_xsl2 "$1" html.xsl
}
	
if [ -e /usr/share/xml/docbook/xsl-stylesheets ]
then
	generate_xsl '\/usr\/share\/xml\/docbook\/xsl-stylesheets'
elif [ -e /usr/share/sgml/docbook/xsl-stylesheets ]
then
	generate_xsl '\/usr\/share\/sgml\/docbook\/xsl-stylesheets'
else
	echo ERROR: Failed to find the DocBook stylesheet directory. If
	echo the stylesheets are indeed installed, please hack the findxsl
	echo script to add the logic needed to find them.
	exit 1
fi	
