#!/bin/bash
#
# Compile DocBook documents into several output formats.
#
# Godoy.
# 19991230 - Initial release.
# 20000117 - Placed the options using "case" and parameters passed 
#	     via command line. The pages on the Zope are already updated.
#	      --- Removed to public version (/home/ldp). 
# 20000120 - Placed the call to use the books.dtd.
# 20000126 - Placed the commands for the index generation.
# 

# If the jade is already installed, disconsider the line bellow.
 <envar>JADE</envar>=/usr/bin/jade

# If the jade package is already installed, disconsider the line bellow.
# <envar>JADE</envar>=/usr/bin/openjade

<envar>DOCUMENT</envar>=<envar>$1</envar>
<command>shift</command> 1
<envar>TYPE</envar>=<envar>$1</envar>

<command>.</command> <filename>~/.bash_profile</filename>
<command>.</command> <filename>~/.bashrc</filename>

<command>case</command> <envar>$TYPE</envar> in
    html)
       <command>rm</command> <parameter class="option">-f</parameter> <literal>*.htm</literal>
       <command>rm</command> <parameter class="option">-f</parameter> <literal>*.html</literal>
       <command>perl</command> <filename>/home/ldp/SGML/style/dsssl/docbook/bin/collateindex.pl</filename> <parameter class="option">-N</parameter> <parameter class="option">-o</parameter> <filename>index.sgml</filename> 
       <command>jade</command> <parameter class="option">-t</parameter> <literal>sgml</literal> <parameter class="option">-V</parameter> <literal>html-index</literal> <parameter class="option">-d</parameter> <filename>/home/ldp/SGML/style/dsssl/docbook/html/docbook.dsl</filename> <envar>$DOCUMENT</envar><literal>.sgml</literal>
       <command>perl</command> <filename>/home/ldp/SGML/style/dsssl/docbook/bin/collateindex.pl</filename> <parameter class="option">-o</parameter> <filename>index.sgml</filename> <filename>HTML.index</filename>
       <envar>$JADE</envar> <parameter class="option">-t</parameter> <literal>sgml</literal> <parameter class="option">-i</parameter> <literal>html</literal> <parameter class="option">-d</parameter> <filename>/home/ldp/SGML/style/dsssl/docbook/html/docbook.dsl</filename> <parameter class="option">-d</parameter> <filename>/home/ldp/SGML/conectiva/livros.dsl</filename><literal>#html</literal> <envar>$DOCUMENT</envar><literal>.sgml</literal>
    ;;
    rtf)
       <command>rm</command> <parameter class="option">-f</parameter> <envar>$DOCUMENT</envar><literal>.rtf</literal>
       <command>perl</command> <filename>/home/ldp/SGML/style/dsssl/docbook/bin/collateindex.pl</filename> <parameter class="option">-N</parameter> <parameter class="option">-o</parameter> <filename>index.sgml</filename> 
       <command>jade</command> <parameter class="option">-t</parameter> <literal>sgml</literal> <parameter class="option">-V</parameter> <literal>html-index</literal> <parameter class="option">-d</parameter> <filename>/home/ldp/SGML/style/dsssl/docbook/html/docbook.dsl</filename> <envar>$DOCUMENT</envar><literal>.sgml</literal>
       <command>perl</command> <filename>/home/ldp/SGML/style/dsssl/docbook/bin/collateindex.pl</filename> <parameter class="option">-o</parameter> <filename>indice.sgml</filename> <filename>HTML.index</filename>
       <envar>$JADE</envar> <parameter class="option">-t</parameter> <literal>rtf</literal> <parameter class="option">-V</parameter> <literal>rtf-backend</literal> <parameter class="option">-d</parameter> <filename>/home/ldp/SGML/style/dsssl/docbook/print/docbook.dsl</filename> <parameter class="option">-d</parameter> <filename>/home/ldp/SGML/conectiva/books.dsl</filename><literal>#print</literal> <envar>$DOCUMENT</envar><literal>.sgml</literal>
    ;;
    xml)
       <command>rm</command> <parameter class="option">-f</parameter> <envar>$DOCUMENT</envar><literal>.xml</literal>
       <command>perl</command> <filename>/home/ldp/SGML/style/dsssl/docbook/bin/collateindex.pl</filename> <parameter class="option">-N</parameter> <parameter class="option">-o</parameter> <filename>index.sgml</filename> 
       <command>jade</command> <parameter class="option">-t</parameter> <literal>sgml</literal> <parameter class="option">-V</parameter> <literal>html-index</literal> <parameter class="option">-d</parameter> <filename>/home/ldp/SGML/style/dsssl/docbook/html/docbook.dsl</filename> <envar>$DOCUMENT</envar><literal>.sgml</literal>
       <command>perl</command> <filename>/home/ldp/SGML/style/dsssl/docbook/bin/collateindex.pl</filename> <parameter class="option">-o</parameter> <filename>indice.sgml</filename> <filename>HTML.index</filename>
       <envar>$JADE</envar> <parameter class="option">-t</parameter> <literal>sgml</literal> <parameter class="option">-i</parameter> <literal>xml</literal> <parameter class="option">-d</parameter> <filename>/home/ldp/SGML/style/xsl/docbook/html/docbook.xsl</filename> <envar>$DOCUMENT</envar><literal>.sgml</literal>
    ;;
    tex)
       <command>rm</command> <parameter class="option">-f</parameter> <envar>$DOCUMENT</envar><literal>.tex</literal>
       <command>perl</command> <filename>/home/ldp/SGML/style/dsssl/docbook/bin/collateindex.pl</filename> <parameter class="option">-N</parameter> <parameter class="option">-o</parameter> <filename>indice.sgml</filename> 
       <command>jade</command> <parameter class="option">-t</parameter> <literal>sgml</literal> <parameter class="option">-V</parameter> <literal>html-index</literal> <parameter class="option">-d</parameter> <filename>/home/ldp/SGML/style/dsssl/docbook/html/docbook.dsl</filename> <envar>$DOCUMENT</envar><literal>.sgml</literal>
       <command>perl</command> <filename>/home/ldp/SGML/style/dsssl/docbook/bin/collateindex.pl</filename> <parameter class="option">-o</parameter> <filename>indice.sgml</filename> <filename>HTML.index</filename>
       <envar>$JADE</envar> <parameter class="option">-t</parameter> <literal>tex</literal> <parameter class="option">-V</parameter> <literal>tex-backend</literal> <parameter class="option">-d</parameter> <filename>/home/ldp/SGML/style/dsssl/docbook/print/docbook.dsl</filename> <parameter class="option">-d</parameter> <filename>/home/ldp/SGML/conectiva/livros.dsl</filename><literal>#print</literal> <envar>$DOCUMENT</envar><literal>.sgml</literal>
    ;;
    dvi)
       <command>rm</command> <parameter class="option">-f</parameter> <envar>$DOCUMENT</envar><literal>.tex</literal>
       <command>rm</command> <parameter class="option">-f</parameter> <envar>$DOCUMENT</envar><literal>.dvi</literal>
       <command>perl</command> <filename>/home/ldp/SGML/style/dsssl/docbook/bin/collateindex.pl</filename> <parameter class="option">-N</parameter> <parameter>-o</parameter> <filename>indice.sgml</filename> 
       <command>jade</command> <parameter class="option">-t</parameter> <literal>sgml</literal> <parameter class="option">-V</parameter> <literal>html-index</literal> <parameter class="option">-d</parameter> <filename>/home/ldp/SGML/style/dsssl/docbook/html/docbook.dsl</filename> <envar>$DOCUMENT</envar><literal>.sgml</literal>
       <command>perl</command> <filename>/home/ldp/SGML/style/dsssl/docbook/bin/collateindex.pl</filename> <parameter class="option">-o</parameter> <filename>indice.sgml</filename> <filename>HTML.index</filename>
       <envar>$JADE</envar> <parameter class="option">-t</parameter> <literal>tex</literal> <parameter class="option">-V</parameter> <literal>tex-backend</literal> <parameter class="option">-d</parameter> <filename>/home/ldp/SGML/style/dsssl/docbook/print/docbook.dsl</filename> <parameter class="option">-d</parameter> <filename>/home/ldp/SGML/conectiva/livros.dsl</filename><literal>#print</literal> <envar>$DOCUMENT</envar><literal>.sgml</literal>
       <command>jadetex</command> <envar>$DOCUMENT</envar><literal>.tex</literal>
    ;;
    mirror)
       <command>rm</command> <parameter class="option">-f</parameter> <envar>$DOCUMENT</envar><literal>.tex</literal>
       <command>rm</command> <parameter class="option">-f</parameter> <envar>$DOCUMENT</envar><literal>.dvi</literal>
       <command>rm</command> <parameter class="option">-f</parameter> <envar>$DOCUMENT</envar><literal>.mirror.ps</literal>
       <command>perl</command> <filename>/home/ldp/SGML/style/dsssl/docbook/bin/collateindex.pl</filename> <parameter class="option">-N</parameter> <parameter>-o</parameter> <filename>indice.sgml</filename> 
       <command>jade</command> <parameter class="option">-t</parameter> <literal>sgml</literal> <parameter class="option">-V</parameter> <literal>html-index</literal> <parameter class="option">-d</parameter> <filename>/home/ldp/SGML/style/dsssl/docbook/html/docbook.dsl</filename> <envar>$DOCUMENT</envar><literal>.sgml</literal>
       <command>perl</command> <filename>/home/ldp/SGML/style/dsssl/docbook/bin/collateindex.pl</filename> <parameter class="option">-o</parameter> <filename>indice.sgml</filename> <filename>HTML.index</filename>
       <envar>$JADE</envar> <parameter class="option">-t</parameter> <literal>tex</literal> <parameter class="option">-V</parameter> <literal>tex-backend</literal> <parameter class="option">-d</parameter> <filename>/home/ldp/SGML/style/dsssl/docbook/print/docbook.dsl</filename> <parameter class="option">-d</parameter> <filename>/home/ldp/SGML/conectiva/livros.dsl</filename><literal>#print</literal> <envar>$DOCUMENT</envar><literal>.sgml</literal>
       <command>jadetex</command> <envar>$DOCUMENT</envar><literal>.tex</literal>
       <command>dvips</command> <parameter>-h</parameter> <filename>/home/ldp/estilos/skel/mirr.hd</filename> <parameter class="option">-O</parameter> <literal>1.5cm,3cm</literal> <parameter class="option">-f</parameter> <envar>$DOCUMENT</envar><literal>.dvi</literal> <parameter class="option">-o</parameter> <envar>$DOCUMENT</envar><literal>.mirror.ps</literal>
    ;;
    ps)
       <command>rm</command> <parameter class="option">-f</parameter> <envar>$DOCUMENT</envar><literal>.tex</literal>
       <command>rm</command> <parameter class="option">-f</parameter> <envar>$DOCUMENT</envar><literal>.dvi</literal>
       <command>rm</command> <parameter class="option">-f</parameter> <envar>$DOCUMENT</envar><literal>.ps</literal>
       <command>perl</command> <filename>/home/ldp/SGML/style/dsssl/docbook/bin/collateindex.pl</filename> <parameter class="option">-N</parameter> <parameter>-o</parameter> <filename>indice.sgml</filename> 
       <command>jade</command> <parameter class="option">-t</parameter> <literal>sgml</literal> <parameter class="option">-V</parameter> <literal>html-index</literal> <parameter class="option">-d</parameter> <filename>/home/ldp/SGML/style/dsssl/docbook/html/docbook.dsl</filename> <envar>$DOCUMENT</envar><literal>.sgml</literal>
       <command>perl</command> <filename>/home/ldp/SGML/style/dsssl/docbook/bin/collateindex.pl</filename> <parameter class="option">-o</parameter> <filename>indice.sgml</filename> <filename>HTML.index</filename>
       <envar>$JADE</envar> <parameter class="option">-t</parameter> <literal>tex</literal> <parameter class="option">-V</parameter> <literal>tex-backend</literal> <parameter class="option">-d</parameter> <filename>/home/ldp/SGML/style/dsssl/docbook/print/docbook.dsl</filename> <parameter class="option">-d</parameter> <filename>/home/ldp/SGML/conectiva/livros.dsl</filename><literal>#print</literal> <envar>$DOCUMENT</envar><literal>.sgml</literal>
       <command>jadetex</command> <envar>$DOCUMENT</envar><literal>.tex</literal>
       <command>dvips</command> <parameter class="option">-The</parameter> <literal>1.5cm,3cm</literal> <parameter class="option">-f</parameter> <envar>$DOCUMENT</envar><literal>.dvi</literal> <parameter class="option">-o</parameter> <envar>$DOCUMENT</envar><literal>.ps</literal>
    ;;
    *)
       <command>echo</command> <computeroutput>"How to use: $0 file {html|tex|rtf|xml|ps|dvi|mirror}"</computeroutput>
       <command>exit</command> <returnvalue>1</returnvalue>
       <command>esac</command>

<command>exit</command> <returnvalue>0</returnvalue>
