#!/bin/sh
#
# emacsen install script for the gri package
# -
# This script is installed by the Gri package `rules' file to 
#  /usr/lib/emacsen-common/packages/install/gri
# It is run by Gri package `postinst' which calls 
#  /usr/lib/emacsen-common/emacs-package-install gri
# The Gri package `postinst' is installed as /var/lib/dpkg/info/gri.postinst
set -e

flavour=$1

package=gri
files="gri-mode.el"
source=/usr/share/emacs/site-lisp/
destination=/usr/share/${flavour}/site-lisp/
flags="--no-site-file --no-init-file --batch -f batch-byte-compile"

if [ ${flavour} != emacs ]
then
    echo install/${package}: Byte-compiling for emacsen flavour ${flavour}

    # Copy the temp .el files into the destination directory
    install -c -m 0755 -d ${destination}
    for i in $files
    do 
	cp $source/$i $destination
    done

    # Byte compile them 
    cd ${destination}
    ${flavour} ${flags} ${files} 2>&1 | gzip -9qf > gri-mode.CompilationLog.gz
    rm ${files}
else
    echo install/${package}: Ignoring emacsen flavour ${flavour}
fi

exit 0;

