Mercurial > hg > xemacs-beta
comparison lib-src/update-elc.sh @ 428:3ecd8885ac67 r21-2-22
Import from CVS: tag r21-2-22
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:28:15 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
427:0a0253eac470 | 428:3ecd8885ac67 |
---|---|
1 #!/bin/sh | |
2 # update-elc.sh --- recompile all missing or out-of-date .elc files | |
3 | |
4 # Author: Jamie Zawinski, Ben Wing, Martin Buchholz | |
5 # Maintainer: Martin Buchholz | |
6 # Keywords: recompile byte-compile .el .elc | |
7 | |
8 # This file is part of XEmacs. | |
9 | |
10 # XEmacs is free software; you can redistribute it and/or modify it | |
11 # under the terms of the GNU General Public License as published by | |
12 # the Free Software Foundation; either version 2, or (at your option) | |
13 # any later version. | |
14 | |
15 # XEmacs is distributed in the hope that it will be useful, but | |
16 # WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
18 # General Public License for more details. | |
19 | |
20 # You should have received a copy of the GNU General Public License | |
21 # along with XEmacs; see the file COPYING. If not, write to | |
22 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 # Boston, MA 02111-1307, USA. | |
24 | |
25 ### Commentary: | |
26 ## Recompile all .elc files that need recompilation. Requires a | |
27 ## working version of "xemacs". Correctly handles the case where the | |
28 ## .elc files are missing; thus you can execute "rm lisp/*/*.elc" | |
29 ## before running this script. Run this from the parent of the | |
30 ## "lisp" directory, or another nearby directory. | |
31 | |
32 set -e | |
33 | |
34 # Try to find the lisp directory in several places. | |
35 # (Sun workspaces have an "editor" directory) | |
36 for dir in . .. ../.. editor ../editor ; do | |
37 if test -d $dir/lisp/. ; then cd $dir ; break ; fi | |
38 done | |
39 | |
40 if test ! -d lisp/. ; then | |
41 echo "$0: Cannot find the \"lisp\" directory." | |
42 exit 1 | |
43 fi | |
44 | |
45 if test -z "$EMACS"; then EMACS="./src/xemacs"; fi | |
46 export EMACS | |
47 | |
48 echo " (using $EMACS)" | |
49 | |
50 # fuckin' sysv, man... | |
51 # Nuke this function... | |
52 if [ "`uname -r | sed 's/[^0-9]*\([0-9]*\).*/\1/'`" -gt 4 ]; then | |
53 echon() | |
54 { | |
55 /bin/echo $* '\c' | |
56 } | |
57 else | |
58 echon() | |
59 { | |
60 echo -n $* | |
61 } | |
62 fi | |
63 | |
64 EMACS_DIR=`cd \`dirname $EMACS\` && pwd`; | |
65 CANON_PWD=`pwd` | |
66 # Account for various system automounter configurations | |
67 if test -d "/net"; then | |
68 if test -d "/tmp_mnt/net"; then tdir="/tmp_mnt/net"; else tdir="/tmp_mnt"; fi | |
69 EMACS_DIR=`echo "$EMACS_DIR" | \ | |
70 sed -e "s|^${tdir}/|/net/|" -e "s|^/a/|/net/|" -e "s|^/amd/|/net/|"` | |
71 CANON_PWD=`echo "$CANON_PWD" | \ | |
72 sed -e "s|^${tdir}/|/net/|" -e "s|^/a/|/net/|" -e "s|^/amd/|/net/|"` | |
73 fi | |
74 REAL="$EMACS_DIR/`basename $EMACS`" | |
75 | |
76 echo "Recompiling in $CANON_PWD" | |
77 echo " with $REAL..." | |
78 | |
79 BYTECOMP="$REAL -batch -vanilla " | |
80 | |
81 $EMACS -batch -vanilla -l $CANON_PWD/lisp/cleantree -f batch-remove-old-elc lisp | |
82 | |
83 prune_vc="( -name '.*' -o -name SCCS -o -name RCS -o -name CVS ) -prune -o" | |
84 | |
85 # $els is a list of all .el files | |
86 # $elcs is a list of all .elc files | |
87 els=/tmp/update-elc-1.$$ elcs=/tmp/update-elc-2.$$ | |
88 rm -f $els $elcs | |
89 trap "rm -f $els $elcs" 0 1 2 3 15 | |
90 find lisp/. $prune_vc -name '*.el' -print | sort > $els | |
91 find lisp/. $prune_vc -name '*.elc' -print | sed 's/elc$/el/' | sort > $elcs | |
92 | |
93 | |
94 echon "Deleting .elc files without .el files..." | |
95 comm -13 $els $elcs | sed -e '\!/vm.el!d' -e 's/el$/elc/' | \ | |
96 while read file ; do echo rm "$file" ; rm "$file" ; done | |
97 echo done. | |
98 | |
99 | |
100 # Compute patterns to ignore when searching for files | |
101 ignore_dirs="" | |
102 ignore_pattern='' | |
103 | |
104 # Only use Mule XEmacs to compile Mule-specific elisp dirs | |
105 echon "Checking for Mule support..." | |
106 lisp_prog='(princ (featurep (quote mule)))' | |
107 mule_p="`$EMACS -batch -vanilla -eval \"$lisp_prog\"`" | |
108 if test "$mule_p" = nil ; then | |
109 echo No | |
110 ignore_dirs="$ignore_dirs mule" | |
111 else | |
112 echo Yes | |
113 fi | |
114 | |
115 # first recompile the byte-compiler, so that the other compiles take place | |
116 # with the latest version (assuming we're compiling the lisp dir of the emacs | |
117 # we're running, which might not be the case, but often is.) | |
118 #echo "Checking the byte compiler..." | |
119 #$BYTECOMP -f batch-byte-recompile-directory lisp/bytecomp | |
120 | |
121 # Prepare for byte-compiling directories with directory-specific instructions | |
122 # Not necessary any more, but I want to keep the text current to cut & paste | |
123 # into the package lisp maintenance tree. | |
124 #make_special_commands='' | |
125 #make_special () { | |
126 # dir="$1"; shift; | |
127 # ignore_dirs="$ignore_dirs $dir" | |
128 # make_special_commands="$make_special_commands \ | |
129 #echo \"Compiling in lisp/$dir\"; \ | |
130 #(cd \"lisp/$dir\" && ${MAKE:-make} EMACS=$REAL ${1+$*}); \ | |
131 #echo \"lisp/$dir done.\";" | |
132 #} | |
133 | |
134 #if test "$mule_p" != nil; then | |
135 # make_special skk all | |
136 #fi | |
137 | |
138 ## AUCTeX is a package now | |
139 # if test "$mule_p" = nil ; then | |
140 # make_special auctex some | |
141 # else | |
142 # make_special auctex some MULE_ELC=tex-jp.elc | |
143 # fi | |
144 #make_special cc-mode all | |
145 # EFS is now packaged | |
146 # make_special efs x20 | |
147 #make_special eos -k # not strictly necessary... | |
148 ## make_special gnus some # Now this is a package. | |
149 # hyperbole is now packaged | |
150 # make_special hyperbole elc | |
151 # We're not ready for the following, yet. | |
152 #make_special ilisp XEmacsELC=custom-load.elc elc | |
153 # ilisp is now packaged | |
154 # make_special ilisp elc | |
155 # oobr is now packaged | |
156 # make_special oobr HYPB_ELC='' elc | |
157 ## W3 is a package now. | |
158 #make_special w3 xemacs-w3 | |
159 | |
160 for dir in $ignore_dirs ; do | |
161 ignore_pattern="${ignore_pattern}/\\/$dir\\//d | |
162 /\\/$dir\$/d | |
163 " | |
164 done | |
165 | |
166 # Other special-case filenames that don't get byte-compiled | |
167 ignore_pattern="$ignore_pattern"' | |
168 \!/,!d | |
169 \!/paths.el$!d | |
170 \!/loadup.el$!d | |
171 \!/loadup-el.el$!d | |
172 \!/update-elc.el$!d | |
173 \!/dumped-lisp.el$!d | |
174 \!/make-docfile.el$!d | |
175 \!/site-start.el$!d | |
176 \!/site-load.el$!d | |
177 \!/site-init.el$!d | |
178 \!/version.el$!d | |
179 \!/very-early-lisp.el$!d | |
180 ' | |
181 | |
182 echo "Compiling files without .elc..." | |
183 NUMTOCOMPILE=20 # compile this many files with each invocation | |
184 comm -23 $els $elcs | \ | |
185 sed "$ignore_pattern" | \ | |
186 xargs -t -n$NUMTOCOMPILE $BYTECOMP -f batch-byte-compile | |
187 echo "Compiling files without .elc... Done" | |
188 | |
189 #if test "$mule_p" != nil; then | |
190 # eval "$make_special_commands" | |
191 #fi |