#!/bin/sh 
#                               -*- Mode: Sh -*- 
# emacsen-common-install --- 
# Author           : Manoj Srivastava ( srivasta@tiamat.datasync.com ) 
# Created On       : Wed Oct 14 23:23:39 1998
# Created On Node  : tiamat.datasync.com
# Last Modified By : Manoj Srivastava
# Last Modified On : Sun May 16 14:48:14 1999
# Last Machine Used: glaurung.green-gryphon.com
# Update Count     : 17
# Status           : Unknown, Use with caution!
# HISTORY          : 
# Description      : 
# 
# 

set -e

FLAVOUR=$1
PACKAGE="gnus"
VERSION="5.8.3-9"

if [ "X$FLAVOUR" = "X" ]; then
    echo Need argument to determin FLAVOUR of emacs;
    exit 1
fi

if [ "X$PACKAGE" = "X" ]; then
    echo Internal error: need package name;
    exit 1;
fi

if [ "X$VERSION" = "X" ]; then
    echo Internal error: need package version;
    exit 1;
fi

ELDIR=/usr/share/emacs/site-lisp/$PACKAGE
ELCDIR=/usr/share/$FLAVOUR/site-lisp/$PACKAGE

BATCHFLAGS="-batch -q -no-site-file"
PRELOADS="  -l ./dgnushack.el";
COMPILE="-f dgnushack-compile";

INFO_FILES="/usr/info/gnus.gz";

STARTDIR=/etc/$FLAVOUR/site-start.d
STARTFILE="$PACKAGE-init.el";

case "$FLAVOUR" in
    emacs | emacs19)
	echo "install/$PACKAGE: Ignoring $FLAVOUR."
	;;
    emacs20 | xemacs20 | xemacs21)
	echo -n "install/$PACKAGE: Byte-compiling for $FLAVOUR..."
	#if [ "$FLAVOUR" = "emacs19" ]; then
	#    CUSTOMINIT="-l /usr/share/emacs/site-lisp/custom-init.el";
	#fi
        if [ -d $ELCDIR ]; then
	    test -f $ELCDIR/install.log && rm -f $ELCDIR/install.log
            rm -f $ELCDIR/*.elc || true;
            rmdir $ELCDIR
        fi
        if [ ! -d $ELCDIR ]; then
            install -m 755 -d $ELCDIR
        fi
        cd $ELDIR

        LOG=`tempfile`;

	($FLAVOUR $BATCHFLAGS $CUSTOMINIT $PRELOADS $COMPILE) >$LOG 2>&1

	echo install -m 644 *.elc  $ELCDIR  >> $LOG;
	install      -m 644 *.elc  $ELCDIR;
	mv -f $LOG                 $ELCDIR/install.log;
	rm -f *.elc

	if [ ! -f $STARTDIR/20$STARTFILE ]; then
	    ln -s $ELDIR/$STARTFILE $STARTDIR/20$STARTFILE;
	fi
        if test -x /usr/sbin/install-info-altdir; then
            for infofile in $INFO_FILES; do
                if [ -e $infofile ]; then
                    install-info-altdir --quiet --section "" "" \
                        --dirname=${FLAVOUR} $infofile
                fi
            done
        fi
        echo "done."
	;;
    *)
        echo "install/$PACKAGE: Ignoring emacsen flavor $FLAVOUR.";	
esac


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