#!/bin/sh
# /usr/lib/emacsen-common/packages/install/foo
# [ Sample only -- this script hasn't been tested, so be careful. ]
set -e

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

byte_compile_options="-batch -f batch-byte-compile"
el_files="some-file.el some-other-file.el etc.el" 
el_dir=/usr/share/emacs/site-lisp/foo/
elc_dir=/usr/share/${FLAVOR}/site-lisp/foo/

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

  [ -d ${elc_dir} ] || mkdir ${elc_dir}

  # Create symlinks to the .el files (see section 6E in debian-emacs polcy).
  (cd ${elc_dir}
    for el in ${el_files}
    do
      ln -s ../../emacs/site-lisp/foo/$el .
    done)

  # Byte compile them
  (cd ${elc_dir}
    ${FLAVOR} ${byte_compile_options} ${el_files} 2> /dev/null)
fi
exit 0;
