#!/bin/sh
# /usr/lib/emacsen-common/packages/install/debview
# [ This particular script hasn't been tested, so be careful. ]
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
    ${FLAVOR} ${byte_compile_options} ${elc_dir}/${el_file}

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