#!/bin/bash -e
#
# Copyright(c)1998 Hidenobu NABETANI <nabe@debian.or.jp>
#
# License: GPL2
# This program is written for Debian GNU/Linux YaTeX package.

PACKAGE=yatex

FLAVOR=$1

ELDIR=/usr/share/emacs/site-lisp/${PACKAGE}/
ELCDIR=/usr/share/${FLAVOR}/site-lisp/${PACKAGE}/
LOG=CompilationLog

byte_compile_options="-q -batch -no-site-file -no-init-file"

# don't byte-compile yatex19.el 
LISP="comment.el yatex.el yatexadd.el yatexgen.el yatexenv.el \
    yatexlib.el yatexprc.el \
    yatexmth.el yatexhks.el yatexhlp.el \
    yatexm-o.el yatexsec.el  yatexhie.el yahtml.el"

if [ ${FLAVOR} != emacs ]
    then
    echo install/${PACKAGE}: Byte-compiling for ${FLAVOR}...

    install -m 755 -d ${ELCDIR}
    # Copy the temp .el files
    cp ${ELDIR}/*.el ${ELCDIR}
    
    # Byte compile them
    echo '(setq load-path (cons "." load-path))' >  ${ELCDIR}/lp.el
    echo '(load-file "./yatexlib.el")'           >> ${ELCDIR}/lp.el
    (cd ${ELCDIR} && ${FLAVOR} ${byte_compile_options} -l ./lp.el \
	-e bcf-and-exit ${LISP} 2>&1 | gzip -9qf > $LOG.gz)
    rm ${ELCDIR}/*.el
# use el file for yatex19 instead of yatex19.elc
    cp ${ELDIR}/yatex19.el ${ELCDIR}
    cp ${ELDIR}/YATEXHLP.eng ${ELCDIR}
    cp ${ELDIR}/YATEXHLP.jp  ${ELCDIR}
    echo "done."
fi

exit 0

### Local Variables:
### mode: shell-script
### End:

