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

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

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

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

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

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