#! /usr/bin/env sh
#
#
#  A script to generate the main LaTeX file given the list of sections.

the_date=`date +%B`" "`date +%d`", "`date +%Y`

cat <<EOF > api_main.tex
%%%
%%%  =======   DO NOT EDIT THIS FILE !!!   =======
%%%
%%%  This file has been generated by the script 
%%%
%%%    $0
%%%
%%%  and will be automatically deleted by 
%%%
%%%    "make clean"
%%%
%%%  =======   DO NOT EDIT THIS FILE !!!   =======
%%%
\documentclass[11pt]{book}

\usepackage{amsmath}
\usepackage{html}
\usepackage{hthtml}
\usepackage{graphicx}

\usepackage[dvips]{epsfig}
\def\scalefig#1{\epsfxsize #1\textwidth}

\bibliographystyle{plain}

\usepackage{color} 
\usepackage[dvips]{hyperref} 
\definecolor{darkgreen}{rgb}{0,0.4,0} 
\definecolor{darkblue}{rgb}{0,0,0.4} 
\definecolor{darkred}{rgb}{0.5,0,0} 
\hypersetup{breaklinks=true, 
  colorlinks=true, 
  linkcolor=darkgreen,
  citecolor=darkblue,
  pagecolor=darkred,
  pdftitle={MITgcm Release 1 Documentation}, 
  pdfauthor={MITgcm-support@mitgcm.org}, 
  pdfkeywords={oceanography, ocean model, general circulation model,
    non-hydrostatic, finite volume, inverse methods, adjoint method} 
  } 

\def\p#1{{\partial \over {\partial #1}}}
\def\pp#1#2{{\partial #1 \over {\partial #2}}}
\def\dd#1#2{{d #1 \over {d #2}}}
\def\bq{\begin{equation}}
\def\bqa{\begin{eqnarray}}
\def\eq{\end{equation}}
\def\eqa{\end{eqnarray}}

\def\h{ {1\over2} }
\def\txt{\mbox{\$2^\circ\$ x \$2.5^\circ \,\$}}
\def\fxf{\mbox{\$4^\circ\$ x \$5^\circ \,\$}}

\def\blankpage{ \vspace*{\fill} \vspace{5in} \vfill \newpage}


\begin{document}

\bodytext{bgcolor="#FFFFFFFF"} 

\title{MITgcm API Reference Manual}
\author{--- The MITgcm Development Team ---}
\date{$the_date}
\maketitle

\tableofcontents

EOF

cat introduction.tex >> api_main.tex

echo "Building: api_main.tex"
for file ; do

    echo "  including \"$file\""
    a=`echo $file | sed -e 's|.tex$||g'`
    echo "\input{$a}" >> api_main.tex

done

cat <<EOF >> api_main.tex


\bibliography{mitgcm}


\end{document}

EOF

