#! /bin/sh
# /usr/lib/emacsen-common/packages/install/jde
# Ruud de Rooij <ruud@debian.org>  Fri,  8 Sep 2000 10:45:21 +0200
# Heavily based on Rob Browning's sample script distributed with the
# emacsen-common package.

set -e

FLAVOR=$1

byte_compile_options="-batch -f batch-byte-compile"

el_files="beanshell.el jde-bug.el jde-compile.el jde-complete.el jde-db.el jde-dbo.el jde-dbs.el jde.el jde-gen.el jde-help.el jde-imenu.el jde-import.el jde-javadoc.el jde-javadoc-gen.el jde-java-font-lock.el jde-java-grammar.el jde-make.el jde-parse.el jde-project.el jde-run.el jde-stat.el jde-which-method.el jde-widgets.el jde-wiz.el senator.el senator-isearch.el setnu.el"


el_dir=/usr/share/emacs/site-lisp/jde
elc_dir=/usr/share/${FLAVOR}/site-lisp/jde
el_paths=
elc_paths=

for el_file in $el_files 
do
    el_paths="$el_paths $el_dir/$el_file"
    elc_paths="$elc_paths $elc_dir/$el_file"
done

if [ ${FLAVOR} = emacs20 -o ${FLAVOR} = emacs21 -o ${FLAVOR} = xemacs21 ]
then
  echo jde: Installing byte-compiled files for emacsen flavor ${FLAVOR}

  # Copy the temporary .el files
  mkdir -p ${elc_dir}
  install -m 644 ${el_paths} ${elc_dir}

  # Byte compile them
  ${FLAVOR} ${byte_compile_options} ${elc_paths} >${elc_dir}/compile.log 2>&1
  echo jde: Compile log saved to ${elc_dir}/compile.log

  # remove the redundant .el files
  # presumes that any .el files in the <flavor> dir are trash.
  rm ${elc_dir}/*.el
else
  echo jde: Skipping installation for emacsen flavor ${FLAVOR}
fi
exit 0
