#! /bin/sh -e
# Written by Mario Lang <mlang@debian.org>
# Updated by Arnaud Fontaine <arnau@debian.org>

FLAVOR=$1
PACKAGE=nethack-el

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

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

ELDIR=/usr/share/emacs/site-lisp/nethack
ELCDIR=/usr/share/${FLAVOR}/site-lisp/nethack
FLAGS="${SITEFLAGS} -q -batch -l path.el -f batch-byte-compile"

install -m 755 -d ${ELCDIR}

# Copy the *.el files in the byte-compiled directory of the flavour
cd ${ELDIR}
FILES=`echo *.el`
cp *.el ${ELCDIR}

# Byte-compile the *.el files
cd ${ELCDIR}

cat << EOF > path.el
(setq load-path (cons "." load-path) byte-compile-warnings nil)
EOF

${FLAVOR} ${FLAGS} ${FILES}

# Remove *.el from the byte-compiled directory
rm -f *.el path.el
