#! /bin/sh
#
# releaseprep - prepares the tree for release
#
# Copyright (C) 2004 Eggheads Development Team
#
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
#
# $Id: releaseprep,v 1.5 2004/04/09 20:16:25 wcc Exp $

if test ! -f src/main.c; then
	echo "You are not in the Eggdrop root directory."
	exit 1
fi

# Change default make from "debug" to "eggdrop"...
echo -n "Changing default make..."
cat configure | sed 's/DEFAULT_MAKE="debug"/DEFAULT_MAKE="eggdrop"/g' > configure_
cat aclocal.m4 | sed 's/DEFAULT_MAKE="debug"/DEFAULT_MAKE="eggdrop"/g' > aclocal.m4_
mv configure_ configure
mv aclocal.m4_ aclocal.m4
chmod +x configure
echo " done."

# Fix patch.h...
echo -n "Fixing patch.h..."
cat src/patch.h | sed 's/^patch.*/\/* PATCH GOES HERE *\//g' > src/patch.h_
mv src/patch.h_ src/patch.h
echo " done."

# Remove CVS dirs.
echo -n "Removing CVS directories..."
find ./ -name CVS -print | xargs rm -rf
echo " done."

# Remove .cvsignores.
echo -n "Removing .cvsignore files..."
find ./ -name .cvsignore -print | xargs rm -f
echo " done."

# Remove doc/web_docs/
if test -d ./doc/web_docs; then
	echo -n "Removing doc/web_docs/..."
	rm -rf doc/web_docs
	echo " done."
fi

# make distclean
echo ""
echo "Running make distclean."
sh configure >/dev/null && make distclean >/dev/null
echo ""

# Create Makefile.
echo -n "Creating Makefile..."
cat << '_EOF' > Makefile
all:
	@echo ""
	@echo "Before you can compile your bot you have to configure it."
	@echo "Please start the configure script now:"
	@echo ""
	@echo " % ./configure"
	@echo ""

_EOF
echo " done."

echo "Complete."
