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

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

PACKAGE=mit-scheme
ELCDIR=/usr/share/${FLAVOR}/site-lisp/${PACKAGE}
FLAGS="${SITEFLAG} -q -batch -l path.el -f batch-byte-compile"

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

rm -rf ${ELCDIR}
install --mode=755 --directory ${ELCDIR}

cd /usr/share/emacs/site-lisp/${PACKAGE}
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
