#! /bin/sh

# Build and install an XEmacs package

# Path to your local version of XEmacs-20.3
EMACS=/usr/src/xemacs-20.0/src/xemacs
# Default package (top level) directory
PACKAGEDIR=/usr/local/lib/xemacs/packages

EVIL_LISP="cus-edit.el cus-face.el custom.el wid-browse.el wid-edit.el x-overlay.el md5.el widget.el"

for i in ${EVIL_LISP}; do
	if [ -f lisp/$i ]; then
		mv lisp/$i lisp/=$i
		rm -f lisp/${i}c
	fi
done

rm -f lisp/auto-autoloads.el*
rm -f lisp/custom-load.el*

echo Building Main Gnus lisp
(cd lisp; make EMACS=$EMACS)

echo Building Gnus autoloads
$EMACS -batch -q -no-site-file -eval '(setq autoload-package-name "gnus")' \
	-l autoload -f batch-update-directory lisp
$EMACS -batch -q -no-site-file -f batch-byte-compile lisp/auto-autoloads.el
$EMACS -batch -q -no-site-file -f batch-byte-compile lisp/custom-load.el

if [ -d $PACKAGEDIR/lisp/gnus ]; then
	rm -rf $PACKAGEDIR/lisp/gnus
fi

mkdir $PACKAGEDIR/lisp/gnus
install -c -m644 lisp/*.el $PACKAGEDIR/lisp/gnus
install -c -m644 lisp/*.elc $PACKAGEDIR/lisp/gnus

rm -f $PACKAGEDIR/info/gnus.info* $PACKAGEDIR/info/message.info*
(cd texi
 makeinfo gnus.texi -o $PACKAGEDIR/info/gnus.info
 makeinfo message.texi -o $PACKAGEDIR/info/message.info
)
