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

# 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>.

FLAVOR=$1
PACKAGE=lookup-el
VERSION=1.4

if [ ${FLAVOR} = emacs ]; then exit 0; fi

echo install/${PACKAGE}: Handling install for emacsen flavor ${FLAVOR}

# FLAVORTEST=`echo $FLAVOR | cut -c-6`
# if [ ${FLAVORTEST} = xemacs ] ; then
#     SITEFLAG="-no-site-file"
# else
#     SITEFLAG="--no-site-file"
# fi
#FLAGS="${SITEFLAG} -q -batch -l path.el -f batch-byte-compile"
FLAGS="${SITEFLAG} -q -batch -l /usr/share/${FLAVOR}/site-lisp/${PACKAGE}/lookup-compile.el"

ELDIR="/usr/share/emacs/site-lisp/${PACKAGE}"
ELCDIR="/usr/share/${FLAVOR}/site-lisp/${PACKAGE}"

SOURCES="evi.el evi-mule.el lookup.el lookup-utils.el lookup-types.el    lookup-vse.el lookup-package.el lookup-kanji.el lookup-entry.el lookup-content.el lookup-select.el     ndic.el ndeb.el ndtp.el ndict.el ndkks.el ndspell.el    ndcookie.el ndmisc.el ndsrd.el sdicf.el stem-english.el  ndeb-binary.el"

EXTRA_DIST="lookup-vars.el.in lookup-compile.el lookup-logo.xbm lookup-logo.xpm"
#EXTRA_DIST2="ndnmz.el"
case "$FLAVOR" in
    emacs20|emacs21|xemacs21 )
	if [ "${FLAVOR}" = "xemacs21" ]; then
	## Fix compile error with xemacs21 on unset LANG or LANG=C .
	export LANG=ja_JP
	    ## Checking MULE supported XEmacs. ---------
	    CHECKMULE=`${FLAVOR} -batch -vanilla -eval "(if (featurep 'mule)(message \"MULE\"))" 2>&1`
	    if [ "${CHECKMULE}" != "MULE" ]; then exit 0; fi
	fi
    install -m 755 -d ${ELCDIR}
    cd ${ELDIR}
    cp ${SOURCES} ${EXTRA_DIST} ${ELCDIR}
    FILES="${SOURCES} lookup-vars.el"
    cd ${ELCDIR}
    sed -e s/\@VERSION\@/${VERSION}/  -e s!\@pkgemacsdir\@!${ELCDIR}!  lookup-vars.el.in > lookup-vars.el
    ${FLAVOR} ${FLAGS} ${FILES} > CompilationLog 2>&1
    gzip -9 -f CompilationLog
     rm -f ${SOURCES} lookup-vars.el.in
     rm *xbm *xpm
    ;;
    *) echo "install/$PACKAGE: Ignoring emacsen flavor $FLAVOR."
    ;;
esac

exit 0 ;


