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

FLAVOR=$1
echo install/cvs-pcl: Handling install of emacsen flavor ${FLAVOR}

byte_compile_options="-batch"
el_files="`cd /usr/share/emacs/site-lisp/pcl-cvs; echo *.el`"
el_dir=/usr/share/emacs/site-lisp/pcl-cvs/
elc_dir=/usr/share/${FLAVOR}/site-lisp/pcl-cvs/

if [ ${FLAVOR} != emacs ]; then
    echo install/cvs-pcl: install Info links for ${FLAVOR}
    if test -x /usr/sbin/install-info-altdir; then
	install-info-altdir --quiet --section "" "" --dirname=${FLAVOR} /usr/info/pcl-cvs.info.gz
    fi

    echo install/cvs-pcl: byte-compiling for ${FLAVOR}
	    
    rm -rf ${elc_dir}
    mkdir -p ${elc_dir}
    cp ${el_dir}/* ${elc_dir}
    cd ${elc_dir}
    make EMACS=${FLAVOR} PCLDIR=${elc_dir} elcfiles startup.el
    mv -f startup.el /etc/${FLAVOR}/site-start.d/50pcl-cvs-startup.el
    rm -f pcl-cvs-startup.el

    rm Makefile
    for d in *.el; do
	if test -f ${d}c; then
	    rm $d
	fi
    done
fi
exit 0
