#!/bin/sh
# /usr/lib/emacsen-common/packages/install/crypt++el
set -e

FLAVOR=$1
echo install/crypt++el: Handling install of emacsen flavor ${FLAVOR}

byte_compile_options="-batch -f batch-byte-compile"
el_files="crypt++.el" 
el_dir=/usr/share/emacs/site-lisp/
elc_dir=/usr/share/${FLAVOR}/site-lisp/
el_path_list=`echo ${el_files} | perl -pe "s|^|${el_dir}|o"`
elc_path_list=`echo ${el_files} | perl -pe "s|^|${elc_dir}|o"`
#etc_dir=/etc/${FLAVOR}/site-start.d/

if [ ${FLAVOR} != emacs ]
then
  echo install/crypt++el: byte-compiling for ${FLAVOR}

#  ln -sf ${el_dir}/crypt++-init.el ${etc_dir}/50crypt++.el

  # Copy the temp .el files
  cp ${el_path_list} ${elc_dir}

  # Byte compile them
#  cat <<-EOF >${elc_dir}/load-path-hack.el
#(setq load-path (cons nil load-path))
#EOF
  (cd ${elc_dir} && ${FLAVOR} ${byte_compile_options} ${elc_path_list} 2>/dev/null)

  # remove the redundant .el files
  # presumes that any .el files in the <flavor> dir are trash.
#  rm ${elc_dir}/load-path-hack.el
  rm ${elc_dir}/crypt++.el
fi
exit 0;

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