#!/bin/bash -e
#
# elisp install file for Debian mailcrypt package.
# $Id: install.in,v 1.9 2002/09/01 15:08:40 salve Exp $
#
# Copyright (C) 1998, 99, 2000, 01, 02 by Davide Giovanni Maria Salvetti.
#
# This program 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.
#
# On Debian GNU/Linux System you can find a copy of the GNU General Public
# License in "/usr/share/common-licenses/GPL".

set -o posix

FLAVOR=$1

EFLAGS="-batch -q -l lpath.el -f batch-byte-compile"

case "$FLAVOR" in
    (emacs)
	:
    ;;
    (emacs20|emacs21|mule2)
	echo -n "install/mailcrypt: Byte-compiling for $FLAVOR... "
	install -m 755 -d /usr/share/$FLAVOR/site-lisp/mailcrypt/
	for i in mailcrypt.el mc-toplev.el mc-pgp.el mc-remail.el mc-pgp5.el mc-gpg.el expect.el mc-setversion.el
	    do cp /usr/share/emacs/site-lisp/mailcrypt//$i /usr/share/$FLAVOR/site-lisp/mailcrypt/
	done
	cat <<-EOF >/usr/share/$FLAVOR/site-lisp/mailcrypt//lpath.el
		(setq load-path (cons nil load-path))
	EOF
	(cd /usr/share/$FLAVOR/site-lisp/mailcrypt/ \
	    && $FLAVOR $EFLAGS mailcrypt.el mc-toplev.el mc-pgp.el mc-remail.el mc-pgp5.el mc-gpg.el expect.el mc-setversion.el  2>&1 \
	    | gzip -9qf > CompilationLog.gz)
	rm -f /usr/share/$FLAVOR/site-lisp/mailcrypt//*.el
	echo "done."
    ;;
    (*)
	echo "install/mailcrypt: Ignoring emacsen flavor $FLAVOR."
    ;;
esac

exit 0
