#! /bin/sh -e
# /usr/lib/emacsen-common/packages/install/mit-scheme

# 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>.

FLAVOR="${1}"

[ "${FLAVOR}" != "emacs" ] || exit 0

PACKAGE="mit-scheme"
ELDIR="/usr/share/emacs/site-lisp/${PACKAGE}"
ELCDIR="/usr/share/${FLAVOR}/site-lisp/${PACKAGE}"

if [ -z "${FLAGS}" ] ; then
    FLAGS="-q -no-site-file --no-site-file -batch -l path.el -f batch-byte-compile"
fi

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

install -m 755 -d "${ELCDIR}"

cd "${ELDIR}"
FILES="$(echo *.el)"
cp -a ${FILES} "${ELCDIR}"/.

cd "${ELCDIR}"
cat << EOF > path.el
(setq load-path (cons "." load-path) byte-compile-warnings nil)
EOF
"${FLAVOR}" ${FLAGS} ${FILES}
rm -f *.el

exit 0
