annotate lib-src/update-elc.sh @ 112:48d667d6f17f r20-1b8

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