#!/bin/sh
# $Id: convert.sh,v 1.5 2003/12/12 13:53:29 k-fish Exp $
#
# Removes all HTML files and calls xsltproc
# to generate HTML from all DocBook XML sources
# found under docbook/

# adjust if needed
CATALOG=/etc/sgml/catalog

# clumsy, is there better way?
cd docbook
LANGUAGES=`ls -d [!C]*`
cd ..

# do the hard work...
for LANG in $LANGUAGES ; do
    rm -rf html/$LANG
    rm -f manual.$LANG.chm
    mkdir -p html/$LANG
    case "$1" in
	single )
	    SGML_CATALOG_FILES=$CATALOG xsltproc -o html/$LANG/manual.html --catalogs mgw-manual-nochunk.xsl docbook/$LANG/mgw-manual.xml;;
	chm )
	    SGML_CATALOG_FILES=$CATALOG xsltproc -o manual.$LANG.chm --catalogs mgw-manual-chm.xsl docbook/$LANG/mgw-manual.xml;;
	full )
	    SGML_CATALOG_FILES=$CATALOG xsltproc -o html/$LANG/ --catalogs mgw-manual.xsl docbook/$LANG/mgw-manual.xml
	    SGML_CATALOG_FILES=$CATALOG xsltproc -o html/$LANG/manual.html --catalogs mgw-manual-nochunk.xsl docbook/$LANG/mgw-manual.xml
	    SGML_CATALOG_FILES=$CATALOG xsltproc -o manual.$LANG.chm --catalogs mgw-manual-chm.xsl docbook/$LANG/mgw-manual.xml;;
	* )
	    SGML_CATALOG_FILES=$CATALOG xsltproc -o html/$LANG/ --catalogs mgw-manual.xsl docbook/$LANG/mgw-manual.xml
    esac

    cp -r images/ html/$LANG/
    cp mgw-manual.css html/$LANG/

    rm -rf `find html -name CVS -type d`
done

# add some code for tarring up, etc...
