#!/bin/sh

# copied from sgmltools-lite, POSTINSTALL
#
# - DocBook DTD catalog: "docbook.cat" in the DocBook DTD directory
# - DocBook DSSL catalog: "catalog" in the DocBook DSSSL stylesheets directory
# - ISO Entities catalog: "iso-entities.cat" in the ISO 8870:1986 directory
# - Jade catalog: "dsssl.cat" in the Jade data directory
# - SGMLtools DTD catalog: "catalog" in the SGMLtools DTD directory
# - SGMLtools DSSSL catalog: "sgmltools.cat" in the SGMLtools DSSSL director

TMPFILE="find-sgml-catalog.tmp" 

if [ -f $TMPFILE ] ; then
	echo "this script uses the file \"$TMPFILE\" as a temporary file."
	echo "please remove the file and execute again."
	exit 1 ;
fi

rm -f $TMPFILE
TARG_LIST="docbook.cat catalog iso-entities.cat dsssl.cat sgmltools.cat"

for TARG in $TARG_LIST ; do
	find /usr -name $TARG -print 2>/dev/null | \
	  grep sgml \
	  >> $TMPFILE
done

FILE_LIST=`sort < $TMPFILE | uniq`
SGML_PATH="" ;
for SGMLFILE in $FILE_LIST ; do
	SGML_PATH="$SGML_PATH$SGMLFILE:" ;
done
SGML_PATH=`echo $SGML_PATH | sed 's/:$$//'`

echo "#!/bin/sh"
echo "# sgml catalog location (generated by find-sgml-catalog)"
echo "export SGML_CATALOG_FILES=\"$SGML_PATH\"" ;

rm -f $TMPFILE

exit 0 ;

