#! /bin/sh -e

FLAVOR=$1
PACKAGE=windows

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

SRCS="windows.el revive.el"

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

byte_compile_options="-batch -q -no-site-file -l ${ELDIR}/pre.el -f batch-byte-compile"

if [ ${FLAVOR} = emacs ]
then
    echo "Ignoring emacsen flavor ${FLAVOR}"
else
    echo install/${PACKAGE}: byte-compiling for ${FLAVOR}

    install -m 755 -d ${ELCDIR}

    # make symlinks for source files for compiling, and for
    # find-function and find-library to work properly
    for f in ${SRCS}; do
        ln -sf ${ELDIR}/${f} ${ELCDIR}/${f}
    done

    # Byte compile them
    (cd ${ELCDIR}
    for i in ${SRCS}
    do
        ${FLAVOR} ${byte_compile_options} ${i}
    done 2>&1 | gzip -9qf > CompilationLog.gz
    )
fi

exit 0
