#!/bin/sh
#
# Ganymede distribution cleaner
#
# Release: $Name: ganymede_001000011 $
# Version: $Revision: 1.12 $
# Date: $Date: 2001/06/01 01:34:58 $
#
# This script is intended to be used to clean out files
# used during the build process, in preparation of tar'ing
# up a ganymede release.
#
# I.e., to build ganymede, export ganymede from the CVS
# archive to get a clean distrib copy, then do
#
# ./configure
# cd src
# make
# make kits
# make jars
# cd ../doc
# ./buildjavadoc
# cd ..
# ./distribclean
#
# this will leave you with a copy of the Ganymede tree with
# the class and jar files necessary to allow someone to install
# and run Ganymede directly from a download without having
# to build the source themselves.
#
############################################################

echo "Ganymede distribution cleaner"
echo

prog=$0

GROOTDIR=`echo $prog|sed 's%/[^/][^/]*$%%'`
# if the program name is the same as the srcdir name, we have no path
# set.. must be .
test "x$GROOTDIR" = "x$prog" && GROOTDIR=.
if test ! -d $GROOTDIR/src/classes; then
  echo "configure: error: can not find sources in $rootdir" 1>&2; exit 1;
fi
export GROOTDIR

# Okay, GROOTDIR is where we're at.

cd $GROOTDIR

# Remove the configured install scripts

echo "Removing custom install scripts"

rm -f installClient*
rm -f installServer
rm -f installWeb

# Clean up the src tree.. remove the configured makefile,
# config.sh and rebuild files

echo "Cleaning doc tree"

cd doc

find . -name config.sh -exec rm {} \;

cd ..

echo "Cleaning source tree"

cd src

rm -f Makefile

find . -name config.sh -exec rm {} \;

find . -name rebuild -exec rm {} \;

# Clean up the classes tree.. we've got the jars, so we don't
# need the classes in the classes tree.

cd classes

rm -f *.class
rm -f *.jar

# Remove all the class files from under arlut.. note that
# we're deliberately leaving the gnu classes in place,
# since we don't have the gnu stuff integrated into our
# build process

find arlut -name \*.class -exec rm {} \;

# And all the xml stuff under com and org

find com -name \*.class -exec rm {} \;
find org -name \*.class -exec rm {} \;

# Clean up all the files we sync'ed into server_classes
# and client_classes and admin_classes

find server_classes -name \*.class -exec rm {} \;
find client_classes -name \*.class -exec rm {} \;
find admin_classes -name \*.class -exec rm {} \;

# Remove the configured sync_tree files.

find arlut -name sync_tree\* -exec rm {} \;
find server_classes -name sync_tree\* -exec rm {} \;
find client_classes -name sync_tree\* -exec rm {} \;
find admin_classes -name sync_tree\* -exec rm {} \;

cd $GROOTDIR

echo "Configured files and redundant classes removed."
echo "Distribution is ready for packaging."
