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

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

FLAVOR=$1
PACKAGE=org-mode

[ ${FLAVOR} = emacs ] && exit 0

echo install/${PACKAGE}: Handling install for emacsen flavor ${FLAVOR}

FLAVORTEST=`echo $FLAVOR | cut -c-6`
if [ ${FLAVORTEST} = xemacs ] ; then
    SITEFLAG="-no-site-file"
    FILES="/usr/share/*emacs/site-lisp/${PACKAGE}/*.el"
else
    SITEFLAG="--no-site-file"
    FILES="/usr/share/emacs/site-lisp/${PACKAGE}/*.el"
fi

ELCDIR=/usr/share/${FLAVOR}/site-lisp/${PACKAGE}
install -m 755 -d ${ELCDIR}
cp ${FILES} ${ELCDIR}

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

cd ${ELCDIR}
cat << EOF > path.el
(setq load-path (cons "." load-path))
(setq byte-compile-warnings nil)
EOF

${FLAVOR} ${FLAGS} *.el
rm -f *.el path.el*

exit 0
