: Use /bin/sh
#
# $Id: Makekit,v 1.5 2003/08/24 11:50:58 ed Exp $
#
# Copyright 1992, 1993, 2001, Geoff Kuenning, Claremont, CA
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
# 3. All modifications to the source code must be clearly marked as
#    such.  Binary redistributions based on modified source code
#    must be clearly marked as modified versions in the documentation
#    and/or other materials provided with the distribution.
# (clause 4 removed with permission from Geoff Kuenning)
# 5. The name of Geoff Kuenning may not be used to endorse or promote
#    products derived from this software without specific prior
#    written permission.
#
# THIS SOFTWARE IS PROVIDED BY GEOFF KUENNING AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL GEOFF KUENNING OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
#	Make an ispell distribution kit.  This is not a clever script,
#	just a handy one.
#
#	Usage:
#
USAGE="Usage:  Makekit [-d destdir] [-e]"
#
#	destdir is the directory in which the kits will be made;  you will
#	want to pick someplace that has lots of space.
#
#	If -e is specified, the list of files in the kit is echoed to
#	stdout and no kit is made.
#
# $Log: Makekit,v $
# Revision 1.5  2003/08/24 11:50:58  ed
# Replaced local.h.samp with local.h.{bsd,linux,sysv}.
#
# Revision 1.4  2003/08/23 10:56:27  ed
# Purging my old email address.
#
# Revision 1.3  2001/10/16 15:14:14  ed
# Merged some more patches from SuSE's ispell-3.2.06 package: parts of
# ispell-3.2.06-languages.patch.  This is to make the manual pages have
# the correct section (file formats go in section 5 not 4) and have
# correct cross-references (no xref to tib (1) or spell (1), which are
# not installed on SuSE).  I parameterized these changes as things in
# config.X.
#
# Makefile: Fixed bug creating directories by using mkdir -p instead of plain
# mkdir.  But -p isn't supported on all Unixes, so this is parameterized
# as the MKDIR variable.  Perhaps this should be a variable in config.X
# rather than the Makefile itself - but I don't know how to do that.
# Added ispell.5 as a target, it is generated from ispell.5X by applying
# substitutions.  This replaces the old ispell.4 which was installed
# as-is.
#
# Two new substitution variables TIB_XREF and SPELL_XREF are used in
# manual pages for making cross-references to tib and spell.  They
# should be defined as a fragment of troff code (ie, text) to be
# included in manual pages.  For example, TIB_XREF might be defined as
# 'tib (1)'.
#
# The section for file format manual pages is controlled by MANFFSECT,
# previously it was hardcoded as 4.  MANFFDIR and MANFFEXT replace
# MAN4DIR and MAN4EXT respectively.
#
# The target install-deformatters no longer calls a recursive Makefile
# inside the deformatters/ directory.  Instead the commands to build
# these two programs are included in the top-level Makefile.  Ditto
# clean-deformatters.
#
# To test the changes to installation, there is a new program test_inst
# which sets some variables in local.h, runs make install, and checks
# the installed files.  It concentrates on making sure the manual pages
# are okay, reading them and checking cross-references.  test_inst is
# now the last target of 'make test'.
#
# Dropped support for manual section 1L (local); now the executable
# commands go in plain old section 1.  It could be added back in using a
# similar mechanism to the section 4 / 5 choice if it is still needed.
#
# The Makefiles for the individual languages have also been changed to
# use MKDIR, and bugfixed to work when LIBDIR is a relative path.
# Previously, Makefiles in subdirectories would do 'cd $$LIBDIR', but
# that will fail if LIBDIR is something like '../install'.  They now go
# through some contortions to keep working whether LIBDIR is relative or
# absolute.  There is a lot of duplicated code across the language
# directories, it would be better factored out.  The english Makefile
# now builds the english.5 manual page by applying substitutions from
# english.5X, and its variants (altamer, american and british) now call
# english/Makefile to make this page and for 'make clean'.
#
# Revision 1.2  2001/10/05 14:22:25  ed
# Imported 3.2.06.epa1 release.  This was previously developed using
# sporadic RCS for certain files, but I'm not really bothered about
# rolling back beyond this release.
#
# Revision 1.45  2001/07/25 21:51:46  geoff
# Minor license update.
#
# Revision 1.44  2001/07/23 20:24:02  geoff
# Update the copyright and the license.
#
# Revision 1.43  2001/06/07 08:02:18  geoff
# Change the kit to use my deformatters.
#
# Revision 1.42  2001/06/06 23:08:23  geoff
# Add some sample deformatters.
#
# Revision 1.41  1999/01/18 03:40:32  geoff
# Build tar file from a version-numbered directory
#
# Revision 1.40  1999/01/07  01:23:03  geoff
# Update the copyright.  Make the kit into a gzipped tar file rather
# than shars.  Get rid of the -c switch.  Remove the following files
# from the kit: ishar, ispell.el, ispell.texinfo, makeshar, splitdict,
# sq.1, sq.c, unsq.c, and all foreign-language affix files.
#
# Revision 1.39  1995/10/11  04:58:07  geoff
# Add the Portuguese language files
#
# Revision 1.38  1995/01/15  00:54:45  geoff
# Add iwhich and the new Spanish support
#
# Revision 1.37  1994/05/18  02:56:25  geoff
# Remember to list dictionaries with the -e switch
#
# Revision 1.36  1994/04/27  02:58:42  geoff
# Add the new English-dialect Makefiles
#
# Revision 1.35  1994/02/07  08:39:49  geoff
# Don't delete everything when we're only echoing names
#
# Revision 1.34  1994/01/25  08:51:16  geoff
# Get rid of all old RCS log lines in preparation for the 3.1 release.
#
#
maxsize=60000		# This leaves room for some headers
destdir=kits
echolist=false
PATH=`pwd`:$PATH; export PATH

while [ $# -gt 0 ]
do
    case "$1" in
	-d)
	    destdir="$2"
	    shift; shift
	    ;;
	-e)
	    echolist=true
	    shift
	    ;;
	*)
	    echo "$USAGE" 1>&2
	    exit 1
	    ;;
    esac
done

case "$destdir" in
    /*)
	;;
    *)
	destdir=`pwd`/$destdir
	;;
esac

flist='
Contributors
README
Magiclines
Makefile
Makekit
Makepatch
WISHES
buildhash.c
config.X
correct.c
defmt.c
dump.c
fields.3
fields.c
fields.h
findaffix.X
good.c
hash.c
icombine.c
ijoin.c
ispell.1X
ispell.5X
ispell.c
ispell.h
iwhich
local.h.bsd
local.h.linux
local.h.sysv
lookup.c
makedict.sh
makedent.c
munchlist.X
parse.y
proto.h
subset.X
term.c
tgood.c
tree.c
tryaffix.X
version.h
xgets.c
zapdups.X
languages/Makefile
languages/Where
languages/fix8bit.c
languages/altamer/Makefile
languages/american/Makefile
languages/british/Makefile
languages/dansk/Makefile
languages/deutsch/Makefile
languages/english/Makefile
languages/english/altamer.0
languages/english/altamer.1
languages/english/altamer.2
languages/english/american.0
languages/english/american.1
languages/english/american.2
languages/english/british.0
languages/english/british.1
languages/english/british.2
languages/english/english.0
languages/english/english.1
languages/english/english.2
languages/english/english.3
languages/english/english.5X
languages/english/english.aff
languages/english/msgs.h
languages/espanol/Makefile
languages/francais/Makefile
languages/nederlands/Makefile
languages/norsk/Makefile
languages/portugues/Makefile
languages/svenska/Makefile
addons/nextispell/Makefile
addons/nextispell/README
addons/nextispell/configure
addons/nextispell/configure.h.template
addons/nextispell/configureTeX
addons/nextispell/nextispell.m
addons/nextispell/services.template
addons/xspell.shar
deformatters/Makefile
deformatters/README
deformatters/deformat-c.c
deformatters/deformat-sh.c
'

if $echolist
then
    echo $flist
    exit 0
fi

[ -d "$destdir" ]  ||  mkdir "$destdir"
version=`egrep 'International Ispell' version.h | awk '{print $5;exit}'`

TMP=$destdir/ispell-$version
rm -rf $TMP
trap "rm -rf $TMP; exit 1" 1 2 15
trap "rm -rf $TMP; exit 0" 13

mkdir $TMP
tar cf - $flist | (cd $TMP; tar xf -)

tarfile=$destdir/ispell-$version.tar.gz

rm -f $tarfile
(cd $destdir; tar cvf - ispell-$version) | gzip -v -9 > $tarfile
rm -rf $TMP
