#!/bin/sh -e
# /usr/lib/emacsen-common/packages/install/asn1-mode

# Written by Jim Van Zandt <jrv@vanzandt.mv.com>, borrowing heavily
# from the install scripts for gettext by Santiago Vila
# <sanvila@ctv.es> and octave by Dirk Eddelbuettel <edd@debian.org>.

FLAVOUR=$1
PACKAGE=asn1-mode

if [ ${FLAVOUR} = emacs ]; then exit 0; fi

echo install/${PACKAGE}: Handling install for emacsen flavour ${FLAVOUR}

FLAVOURTEST=`echo $FLAVOUR | cut -c-6`
if [ ${FLAVOURTEST} = xemacs ] ; then
    SITEFLAG="-no-site-file"
else
    SITEFLAG="--no-site-file"
fi
# XEmacs need full path of this file
ASN1FLAG="-l /usr/share/emacs/site-lisp/asn1-mode/asn1-byteopts.el"
FLAGS="${SITEFLAG} -q -batch -l path.el ${ASN1FLAG} -f batch-byte-compile"

ELDIR=/usr/share/emacs/site-lisp/${PACKAGE}
ELCDIR=/usr/share/${FLAVOUR}/site-lisp/${PACKAGE}

# Install-info-altdir does not actually exist. 
# Maybe somebody will write it.
if test -x /usr/sbin/install-info-altdir; then
    echo install/${PACKAGE}: install Info links for ${FLAVOUR}
    for i in asn1-diff-en asn1-diff-fr asn1-mode-en asn1-mode-fr; do
        install-info-altdir --quiet --section "" "" --dirname=${FLAVOUR} \
	    /usr/info/$i.info.gz
    done
fi

install -m 755 -d ${ELCDIR}
cd ${ELDIR}
FILES="asn1-conf.el asn1-diff.el asn1-mode.el asn1-syntax.el"
cp ${FILES} ${ELCDIR}
cd ${ELCDIR}

cat << EOF > path.el
(setq load-path (cons "." load-path) byte-compile-warnings nil)
EOF
LANG=C
LC_ALL=C
export LANG LC_ALL
${FLAVOUR} ${FLAGS} ${FILES}
rm -f *.el path.el

exit 0
