0
|
1 #!/bin/sh
|
108
|
2 # update-elc.sh --- recompile all missing or out-of-date .elc files
|
0
|
3
|
70
|
4 # Author: Jamie Zawinski, Ben Wing, Martin Buchholz
|
|
5 # Maintainer: Martin Buchholz
|
108
|
6 # Keywords: recompile byte-compile .el .elc
|
0
|
7
|
|
8 ### Commentary:
|
70
|
9 ## Recompile all .elc files that need recompilation. Requires a
|
108
|
10 ## working version of "xemacs". Correctly handles the case where the
|
|
11 ## .elc files are missing; thus you can execute "rm lisp/*/*.elc"
|
70
|
12 ## before running this script. Run this from the parent of the
|
108
|
13 ## "lisp" directory, or another nearby directory.
|
0
|
14
|
108
|
15 set -e
|
0
|
16
|
70
|
17 # Try to find the lisp directory in several places.
|
108
|
18 # (Sun workspaces have an "editor" directory)
|
70
|
19 for dir in . .. ../.. editor ../editor ; do
|
108
|
20 if test -d $dir/lisp/. ; then cd $dir ; break ; fi
|
70
|
21 done
|
0
|
22
|
70
|
23 if test ! -d lisp/. ; then
|
108
|
24 echo "$0: Cannot find the \"lisp\" directory."
|
70
|
25 exit 1
|
0
|
26 fi
|
|
27
|
108
|
28 # Determine xemacs executable to use for compilation.
|
|
29 if test -n "$XEMACS" ; then
|
|
30 EMACS="$XEMACS"
|
|
31 elif test -x ./src/xemacs ; then
|
|
32 EMACS="./src/xemacs"
|
|
33 elif test -x "$EMACS" ; then
|
|
34 :
|
|
35 else
|
|
36 EMACS=xemacs
|
|
37 fi
|
|
38 case "$EMACS" in
|
|
39 */* ) : ;; # Pathname specified
|
|
40 *) # Need to find executable on PATH
|
|
41 for dir in `echo $PATH | sed 's/:/ /g'` ; do
|
|
42 if test -x "dir/xemacs" ; then
|
|
43 EMACS="$dir/$EMACS"
|
|
44 break
|
|
45 fi
|
|
46 done ;;
|
|
47 esac
|
|
48 # Canonicalize
|
|
49 EMACS=`cd \`dirname $EMACS\` ; pwd | sed 's:^/tmp_mnt::'`/`basename $EMACS`
|
|
50 export EMACS
|
36
|
51
|
70
|
52 echo "Recompiling in `pwd|sed 's:^/tmp_mnt::'`"
|
108
|
53 echo " with $EMACS..."
|
70
|
54
|
78
|
55 prune_vc="( -name SCCS -o -name RCS -o -name CVS ) -prune -o"
|
0
|
56
|
112
|
57 $EMACS -batch -q -l `pwd`/lisp/prim/cleantree -f batch-remove-old-elc lisp
|
108
|
58
|
70
|
59 # $els is a list of all .el files
|
|
60 # $elcs is a list of all .elc files
|
108
|
61 els=/tmp/update-elc-1.$$ elcs=/tmp/update-elc-2.$$
|
70
|
62 rm -f $els $elcs
|
|
63 trap "rm -f $els $elcs" 0 1 2 3 15
|
80
|
64 find lisp/. $prune_vc -name '*.el' -print | sort > $els
|
|
65 find lisp/. $prune_vc -name '*.elc' -print | sed 's/elc$/el/' | sort > $elcs
|
70
|
66
|
0
|
67
|
70
|
68 echo "Deleting .elc files without .el files..."
|
108
|
69 comm -13 $els $elcs | sed -e '\!/vm.el!d' -e 's/el$/elc/' | \
|
70
|
70 while read file ; do echo rm "$file" ; rm "$file" ; done
|
|
71 echo "Deleting .elc files without .el files... Done"
|
0
|
72
|
30
|
73
|
70
|
74 # Compute patterns to ignore when searching for files
|
100
|
75 ignore_dirs="its quail" # ### Not ported yet...
|
0
|
76
|
70
|
77 # Only use Mule XEmacs to compile Mule-specific elisp dirs
|
|
78 echo "Checking for Mule support..."
|
84
|
79 lisp_prog='(princ (featurep (quote mule)))'
|
108
|
80 mule_p="`$EMACS -batch -no-site-file -eval \"$lisp_prog\"`"
|
84
|
81 if test "$mule_p" = nil ; then
|
|
82 echo No
|
70
|
83 ignore_dirs="$ignore_dirs mule"
|
84
|
84 elif test "$mule_p" = t; then
|
|
85 echo Yes
|
|
86 else
|
|
87 echo "Error determining presence of mule support"
|
|
88 exit 1;
|
70
|
89 fi
|
0
|
90
|
|
91 # first recompile the byte-compiler, so that the other compiles take place
|
|
92 # with the latest version (assuming we're compiling the lisp dir of the emacs
|
|
93 # we're running, which might not be the case, but often is.)
|
74
|
94 echo "Checking the byte compiler..."
|
108
|
95 BYTECOMP="$EMACS -batch -q -no-site-file -l bytecomp"
|
78
|
96 $BYTECOMP -f batch-byte-recompile-directory lisp/bytecomp
|
0
|
97
|
108
|
98 # Byte-compile VM first, because other packages depend on it,
|
|
99 # but it depends on nothing (Kyle is like that).
|
|
100 ignore_dirs="$ignore_dirs vm"
|
|
101 echo "Compiling in lisp/vm";
|
110
|
102 (cd lisp/vm && ${MAKE:-make} EMACS=$EMACS autoload)
|
108
|
103 echo "lisp/vm done."
|
|
104
|
70
|
105 # Prepare for byte-compiling directories with directory-specific instructions
|
|
106 make_special_commands=''
|
|
107 make_special () {
|
|
108 dir="$1"; shift;
|
|
109 ignore_dirs="$ignore_dirs $dir"
|
|
110 make_special_commands="$make_special_commands \
|
|
111 echo \"Compiling in lisp/$dir\"; \
|
108
|
112 (cd \"lisp/$dir\" && ${MAKE:-make} EMACS=$EMACS ${1+$*}); \
|
70
|
113 echo \"lisp/$dir done.\";"
|
|
114 }
|
30
|
115
|
108
|
116 #make_special vm
|
80
|
117 #make_special ediff elc
|
|
118 #make_special viper elc
|
108
|
119 make_special efs
|
70
|
120 make_special gnus some
|
|
121 make_special w3
|
|
122 make_special hyperbole elc
|
78
|
123 make_special oobr HYPB_ELC='' elc
|
70
|
124 make_special eos -k # not stricly necessary...
|
80
|
125 make_special ilisp elc
|
102
|
126 make_special auctex some
|
0
|
127
|
70
|
128 ignore_pattern=''
|
|
129 for dir in $ignore_dirs ; do
|
|
130 ignore_pattern="${ignore_pattern}/\\/$dir\\//d
|
|
131 /\\/$dir\$/d
|
|
132 "
|
|
133 done
|
0
|
134
|
70
|
135 # Other special-case filenames that don't get byte-compiled
|
|
136 ignore_pattern="$ignore_pattern"'
|
0
|
137 \!/,!d
|
|
138 \!/edebug/edebug-test.el$!d
|
|
139 \!/energize/energize-load.el$!d
|
|
140 \!/energize/write-file.el$!d
|
|
141 \!/paths.el$!d
|
|
142 \!/prim/loadup.el$!d
|
|
143 \!/prim/loadup-el.el$!d
|
|
144 \!/prim/update-elc.el$!d
|
|
145 \!/site-start.el$!d
|
|
146 \!/site-load.el$!d
|
|
147 \!/site-init.el$!d
|
|
148 \!/version.el$!d
|
|
149 \!/sunpro/sunpro-load.el$!d
|
70
|
150 '
|
0
|
151
|
70
|
152 echo "Compiling files without .elc..."
|
|
153 NUMTOCOMPILE=20 # compile this many files with each invocation
|
78
|
154 comm -23 $els $elcs | \
|
|
155 sed "$ignore_pattern" | \
|
|
156 xargs -t -n$NUMTOCOMPILE $BYTECOMP -f batch-byte-compile
|
70
|
157 echo "Compiling files without .elc... Done"
|
22
|
158
|
70
|
159 eval "$make_special_commands"
|