#!/bin/sh

# Run this and it calls everything else.
#
# 

unset CLASSPATH
export CLASSPATH

[ -d "$1" ] && chdir $1

pwd=`pwd`

#
# Make subdirs
#

for dir in `ls`
do
	[ -d $dir ] || continue
	DIRS="$DIRS $dir"
	cd $dir
	if [ -f ${dir}.txt ]; then
		echo Making Code in $dir.
		../makeCode ${dir}.txt
		echo Compiling Code in $dir.
		javac *.java
		echo Making Output in $dir.
		../makeOutput
	fi
	echo Making SourceLinks in $dir.
	../makeSourceLinks > index.html
	cd $pwd
done


echo Making Top Level index.html.

#
# Make header
#
cat > index.html << EOF
<HTML>
<HEAD>
	<TITLE>
	Java 2 Programmer's Interactive Workbook Source Code
	</TITLE>
</HEAD>
<BODY BGCOLOR=#ffffff >
<H2> Java 2 Interactive Programmer's Workbook </H2>
<H3> Source code for all exercises and examples </H3>

Here is the source code to the exercises and examples for the
entire book.
When possible, we have linked to the corresponding applet as well.
You will need to make sure that the 
<A HREF="http://java.sun.com/products/plugin"> Java 2 plug-in </A>
is installed on your browser for the applets to run.
<p>
<b> Note: </b> 
These pages contain the raw source code, but nothing
else.  Some of the code here may also be found in the "Test Your Thinking"
section.  Make sure to visit those pages as they contain addional notes
and discussion about the answers.  That information is not included
in these pages.
<hr>

<UL>

EOF

#
# Make Chapter links
#

for dir in $DIRS
do
	chapter=`echo $dir | sed 's/Chapter/Chapter /'`
	cat >> index.html <<EOF
	<LI> <A HREF="$dir/index.html"> $chapter </A>
EOF
done


#
# Make footer
#

cat >> index.html <<EOF
</UL>

<HR>
<FONT SIZE=2>
Authors: Kevin Chu and Eric Brower
<br>
Copyright 2000 Prentice Hall PTR
</FONT>
</BODY>
</HTML>
EOF
