#! /bin/sh
# /usr/lib/emacsen-common/packages/install/migemo-el

set -e
FLAVOR=$1
PACKAGE=migemo-el
case ${FLAVOR} in
    emacs|emacs23|emacs22|emacs21|emacs20|emacs19|mule2|xemacs*)
        exit 0
        ;;
    *)
        SITEFLAG="--no-site-file"
        ;;
esac
FLAGS="${SITEFLAG} -q -batch -l path.el -f batch-byte-compile"

ELDIR=/usr/share/emacs/site-lisp/${PACKAGE}
ELCDIR=/usr/share/${FLAVOR}/site-lisp/${PACKAGE}
ELCSTAMP=$ELCDIR/compile-stamp
if [ -f "$ELCSTAMP" ]; then
    echo "install/${PACKAGE}: already byte-compiled for $FLAVOR, skipped"
    exit 0
fi
echo "install/${PACKAGE}: Handling install for emacsen flavor ${FLAVOR}"
if [ ! -d "$ELCDIR" ]; then
    install -m 755 -d ${ELCDIR}
fi
cd ${ELDIR}
FILES=`echo *.el`
cp ${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 path.el
touch "$ELCSTAMP"
exit 0
