mirror of
https://git.FreeBSD.org/ports.git
synced 2024-11-01 22:05:08 +00:00
cb722e947d
Added a script to byte-compile PR: 13389 Submitted by: maintainer
132 lines
3.2 KiB
Bash
132 lines
3.2 KiB
Bash
#!/bin/sh
|
|
|
|
PREFIX=${PREFIX:-/usr/local}
|
|
WRKDIR=${WRKDIR:-`pwd`}
|
|
|
|
tmprfx=`basename $0`
|
|
|
|
Usage="\
|
|
byte_compile [options] emacs_name port_name [files]
|
|
-l load_el : load *.el file when byte-compile
|
|
-h : show this message
|
|
emacs_name : should be one of below
|
|
\"emacs\", \"emacs20\", \"mule\", \"xemacs19\", \"xemacs20\",
|
|
\"xemacs21\", \"xemacs-mule\"
|
|
port_name : port name(replaced *.el when files not specified)
|
|
files : *.el files should be compiled"
|
|
|
|
while [ -z "`getopts "l: h" opt > /tmp/${tmprfx}:getopt_err.log`" \
|
|
-a X"${opt}" != "X?" ]; do
|
|
case ${opt} in
|
|
l)
|
|
load_el=${OPTARG}
|
|
break
|
|
;;
|
|
h)
|
|
echo "${Usage}"
|
|
exit 1
|
|
;;
|
|
*)
|
|
;;
|
|
esac
|
|
# echo "opt=${opt},OPTARG=${OPTARG}"
|
|
done
|
|
|
|
if [ -s /tmp/${tmprfx}:getopt_err.log ]; then
|
|
cat /tmp/${tmprfx}:getopt_err.log
|
|
rm -f /tmp/${tmprfx}:getopt_err.log
|
|
exit 1
|
|
fi
|
|
rm -f /tmp/${tmprfx}:getopt_err.log
|
|
|
|
shift `expr ${OPTIND} - 1`
|
|
|
|
if [ -z "$1" -o -z "$2" ]; then
|
|
echo "${Usage}"
|
|
exit 1
|
|
fi
|
|
|
|
emacs_name=$1
|
|
shift
|
|
port_name=$1
|
|
|
|
if [ $# -le 1 ]; then
|
|
files=${port_name}.el
|
|
else
|
|
files=`echo $* | sed -e "s/${port_name} *//"`
|
|
fi
|
|
|
|
#echo "emacs_name=${emacs_name}"
|
|
#echo "port_name=${port_name}"
|
|
#echo "files=${files}"
|
|
#echo "load_el=${load_el}"
|
|
#exit 1
|
|
|
|
case ${emacs_name} in
|
|
emacs)
|
|
load_path=${PREFIX}/share/emacs/19.34/${load_el}
|
|
emacscmd=emacs
|
|
;;
|
|
emacs20)
|
|
load_path=${PREFIX}/share/emacs/20.3/${load_el}
|
|
emacscmd=emacs20
|
|
;;
|
|
mule)
|
|
load_path=${PREFIX}/share/mule/19.34/${load_el}
|
|
emacscmd=mule
|
|
;;
|
|
xemacs19)
|
|
load_path=${PREFIX}/lib/xemacs-19.16/${load_el}
|
|
emacscmd=xemacs
|
|
;;
|
|
xemacs20)
|
|
load_path=${PREFIX}/lib/xemacs-20.4/${load_el}
|
|
emacscmd=xemacs
|
|
;;
|
|
xemacs21)
|
|
load_path=${PREFIX}/lib/xemacs-21.1.4/${load_el}
|
|
pkg_path=${PREFIX}/lib/xemacs/site-packages
|
|
emacscmd=xemacs
|
|
;;
|
|
xemacs-mule)
|
|
load_path=${PREFIX}/lib/xemacs/xemacs-packages/lisp/${load_el}
|
|
pkg_path=${PREFIX}/lib/xemacs/site-packages
|
|
emacscmd=xemacs
|
|
;;
|
|
*)
|
|
echo "${Usage}"
|
|
exit 1
|
|
;;
|
|
esac
|
|
if [ -n "${load_el}" ]; then
|
|
echo "(setq load-path (cons \"${load_path}\" load-path))" > /tmp/${tmprfx}:load.el
|
|
fi
|
|
cp ${pkg_path}/pkginfo/MANIFEST.${port_name} ${pkg_path}/pkginfo/MANIFEST.${port_name}.bak
|
|
for f in ${files}; do
|
|
if [ -f ${WRKDIR}/${f} ]; then
|
|
if [ -n "${load_el}" ]; then
|
|
${emacscmd} -batch -l /tmp/${tmprfx}:load.el -q -no-site-file \
|
|
-f batch-byte-compile ${WRKDIR}/${f}
|
|
else
|
|
${emacscmd} -batch -q -no-site-file -f batch-byte-compile ${WRKDIR}/${f}
|
|
fi
|
|
if [ $? -eq 0 -a -d ${pkg_path}/lisp/${port_name} ]; then
|
|
rm -f ${pkg_path}/lisp/${port_name}/${f}.elc
|
|
ln -s ${WRKDIR}/${f}.elc ${pkg_path}/lisp/${port_name}/${f}.elc
|
|
cp ${pkg_path}/pkginfo/MANIFEST.${port_name} /tmp/${tmprfx}:tempfile
|
|
grep -v "${f}.elc" /tmp/${tmprfx}:tempfile \
|
|
> ${pkg_path}/pkginfo/MANIFEST.${port_name}
|
|
echo "lisp/${port_name}/${f}.elc" >> ${pkg_path}/pkginfo/MANIFEST.${port_name}
|
|
else
|
|
cp ${pkg_path}/pkginfo/MANIFEST.${port_name} /tmp/${tmprfx}:tempfile
|
|
grep -v "${f}.elc" /tmp/${tmprfx}:tempfile \
|
|
> ${pkg_path}/pkginfo/MANIFEST.${port_name}
|
|
rm -f ${pkg_path}/lisp/${port_name}/${f}.elc
|
|
fi
|
|
else
|
|
echo "\"${WRKDIR}/${f}\": file not found!"
|
|
fi
|
|
done
|
|
|
|
rm -f /tmp/${tmprfx}:load.el ${pkg_path}/pkginfo/MANIFEST.${port_name}.bak
|