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

FLAVOR=$1
echo install/debview: Handling install of emacsen flavor ${FLAVOR}

byte_compile_options="-batch -f batch-byte-compile"
el_file=deb-view.el
el_dir=/usr/share/emacs/site-lisp/debview
elc_dir=/usr/share/${FLAVOR}/site-lisp/debview

if [ ${FLAVOR} != emacs ]; then
    echo install/debview: byte-compiling for ${FLAVOR}
	    
    # Copy the temp .el file
    mkdir -p ${elc_dir}
    cp ${el_dir}/${el_file} ${elc_dir}

    # Byte compile them
    LOG=`tempfile`
    ${FLAVOR} ${byte_compile_options} ${elc_dir}/${el_file} >$LOG 2>&1
    mv $LOG ${elc_dir}/install.log
    echo "Compilation log for ${FLAVOR} saved to ${elc_dir}/install.log"

    # remove the redundant .el files
    # presumes that any .el files in the <flavor> dir are trash.
    rm ${elc_dir}/*.el
fi
exit 0
