#! /bin/sh -e
# /usr/lib/emacsen-common/packages/install/mdk

# Written by Jim Van Zandt <jrv@vanzandt.mv.com>, borrowing heavily
# from the install scripts for gettext by Santiago Vila
# <sanvila@ctv.es> and octave by Dirk Eddelbuettel <edd@debian.org>.
# Reworked a bit by Peter Pentchev <roam@ringlet.net>, borrowing heavily
# from the emacsen-common example scripts by Rob Browning
# <rlb@defaultvalue.org> and the dictionaries-common install scripts.

set -e

flavor=$1
package=mdk

case "$flavor" in
	emacs)
		# Dummy emacs flavor. Do nothing and exit
		exit 0
		;;
	xemacs*)
		flags="-no-site-file"
		;;
	emacs*)
		flags="--no-site-file"
		;;
	*)
		echo install/$package: Ignoring emacsen flavor [$flavor]
		exit 0
		;;
esac

echo "install/$package: Handling install for emacsen flavor $flavor"

flags="$flags -q -batch -l path.el -f batch-byte-compile"
eldir="/usr/share/emacs/site-lisp/$package"
elcdir="/usr/share/$flavor/site-lisp/$package"

install -m 755 -d "${elcdir}"
cd "$elcdir"
ln -sf "$eldir"/*.el .

cat << EOF > path.el
(setq load-path (cons "." load-path) byte-compile-warnings nil)
EOF
"$flavor" $flags *.el
rm -f path.el path.elc
