#!/bin/sh
# /usr/lib/emacsen-common/packages/install/jde
# Ruud de Rooij <ruud@debian.org>  Mon,  7 Sep 1998 20:34:47 +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-compile.el jde-complete.el jde-db.el jde-gen.el jde-help.el jde-make.el jde-parse.el jde-run.el jde-widgets.el jde-wiz.el jde.el"

# thingatpt.el is included with emacs20 and xemacs21, but not with xemacs20
if [ ${FLAVOR} = xemacs20 ]
then
  el_files="${el_files} thingatpt.el"
fi

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} = xemacs20 -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
