#!/bin/sh
#
# 	$Id: emacsen-install,v 1.5 2004/06/13 20:19:14 agmartin Exp $	
#
# emacsen install script for the Debian GNU/Linux
# dictionaries-common package
#
# Written by Rafael Laboissiere <rafael@debian.org> and 
# Agustin Martin <agmartin@debian.org>
#
# Based in Dirk Eddelbuettel script for the octave package.
# lpath.el trick is stolen from Davide Salvetti's auctex package
# --------------------------------------------------------------

set -e

# Canadian spelling ;-)
flavour=$1 

package=dictionaries-common
files="debian-ispell.el ispell.el"
source=/usr/share/emacs/site-lisp/${package}
destination=/usr/share/${flavour}/site-lisp/${package}

case "$flavour" in
    emacs)
	# Dummy emacs flavour. Do nothing and exit
	exit 0
	;;
    xemacs*)
	flags="-no-site-file"
	;;
    emacs*)
	flags="--no-site-file"
	;;
    *)
	echo install/${package}: Ignoring emacsen flavour [${flavour}]
	exit 0
	;;
esac

flags="${flags} -q -batch -l path.el -f batch-byte-compile"

echo install/${package}: Byte-compiling for emacsen flavour ${flavour}

# Copy the temp .el files into the destination directory

install -m 0755 -d ${destination}

for i in $files; do 
    cp $source/$i $destination
done

cd ${destination}

cat << EOF > path.el
(setq load-path (cons "." load-path) byte-compile-warnings nil)
EOF

# Byte compile them
${flavour} ${flags} ${files}

rm ${files} path.el

exit 0;

