Commit | Line | Data |
---|---|---|
f7dbcf3c | 1 | #!/bin/sh |
76fb0a58 JB |
2 | |
3 | #### make-dist: create an Emacs distribution tar file from the current | |
1d650ff1 | 4 | #### source tree. This basically creates a duplicate directory |
76fb0a58 JB |
5 | #### structure, and then hard links into it only those files that should |
6 | #### be distributed. This means that if you add a file with an odd name, | |
7 | #### you should make sure that this script will include it. | |
f7dbcf3c JB |
8 | |
9 | progname="$0" | |
10 | ||
76fb0a58 JB |
11 | ### Exit if a command fails. |
12 | ### set -e | |
f7dbcf3c | 13 | |
76fb0a58 JB |
14 | ### Print out each line we read, for debugging's sake. |
15 | ### set -v | |
f7dbcf3c | 16 | |
4746118a JB |
17 | clean_up=yes |
18 | make_tar=yes | |
1260d6ba | 19 | newer="" |
f7dbcf3c JB |
20 | |
21 | while [ $# -gt 0 ]; do | |
22 | case "$1" in | |
76fb0a58 JB |
23 | ## This option tells make-dist not to delete the staging directory |
24 | ## after it's done making the tar file. | |
1260d6ba | 25 | "--no-clean-up" ) |
4746118a JB |
26 | clean_up=no |
27 | ;; | |
76fb0a58 JB |
28 | ## This option tells make-dist not to make a tar file. Since it's |
29 | ## rather pointless to build the whole staging directory and then | |
30 | ## nuke it, using this option also selects '--no-clean-up'. | |
4746118a JB |
31 | "--no-tar" ) |
32 | make_tar=no | |
33 | clean_up=no | |
f7dbcf3c | 34 | ;; |
76fb0a58 | 35 | ## This option tells make-dist to make the distribution normally, then |
7b9cd64c ER |
36 | ## remove all files older than the given timestamp file. This is useful |
37 | ## for creating incremental or patch distributions. | |
1260d6ba | 38 | "--newer") |
ef15f270 JB |
39 | newer="$2" |
40 | new_extension=".new" | |
1260d6ba ER |
41 | shift |
42 | ;; | |
922ac4c5 JB |
43 | ## This option tells make-dist to use `compress' instead of gzip. |
44 | ## Normally, make-dist uses gzip whenever it is present. | |
45 | "--compress") | |
46 | default_gzip="compress" | |
47 | ;; | |
f7dbcf3c JB |
48 | * ) |
49 | echo "${progname}: Unrecognized argument: $1" >&2 | |
50 | exit 1 | |
51 | ;; | |
52 | esac | |
53 | shift | |
54 | done | |
55 | ||
76fb0a58 | 56 | ### Make sure we're running in the right place. |
f7dbcf3c | 57 | if [ ! -d src -o ! -f src/lisp.h -o ! -d lisp -o ! -f lisp/version.el ]; then |
1260d6ba ER |
58 | echo "${progname}: Can't find \`src/lisp.h' and \`lisp/version.el'." >&2 |
59 | echo "${progname} must be run in the top directory of the Emacs" >&2 | |
f7dbcf3c JB |
60 | echo "distribution tree. Cd to that directory and try again." >&2 |
61 | exit 1 | |
62 | fi | |
63 | ||
76fb0a58 | 64 | ### Find out which version of Emacs this is. |
f7dbcf3c | 65 | version=`grep 'defconst[ ]*emacs-version' lisp/version.el \ |
b7cceaf1 | 66 | | sed -e 's/^.*"\([0-9][0-9]*\.[0-9][0-9]*\)\..*$/\1/'` |
f7dbcf3c | 67 | if [ ! "${version}" ]; then |
1260d6ba | 68 | echo "${progname}: can't find current emacs version in \`./lisp/version.el'." >&2 |
f7dbcf3c JB |
69 | exit 1 |
70 | fi | |
71 | ||
f753e9aa JB |
72 | if grep -s "GNU Emacs version ${version}" ./man/emacs.texi > /dev/null; then |
73 | true | |
74 | else | |
75 | echo "You must update the version number in \`./man/emacs.texi'" | |
76 | exit 1 | |
77 | fi | |
78 | ||
76fb0a58 | 79 | ### Make sure the subdirectory is available. |
1260d6ba | 80 | tempparent="make-dist.tmp.$$" |
f7dbcf3c | 81 | if [ -d ${tempparent} ]; then |
1260d6ba ER |
82 | echo "${progname}: staging directory \`${tempparent}' already exists. |
83 | Perhaps a previous invocation of \`${progname}' failed to clean up after | |
84 | itself. Check that directories whose names are of the form | |
85 | \`make-dist.tmp.NNNNN' don't contain any important information, remove | |
86 | them, and try again." >&2 | |
f7dbcf3c JB |
87 | exit 1 |
88 | fi | |
89 | ||
9f7602fd JB |
90 | ### Check for .elc files with no corresponding .el file. |
91 | ls -1 lisp/*.el | sed 's/\.el$/.elc/' > /tmp/el | |
92 | ls -1 lisp/*.elc > /tmp/elc | |
254e10d8 JB |
93 | bogosities="`comm -13 /tmp/el /tmp/elc`" |
94 | if [ "${bogosities}" != "" ]; then | |
95 | echo "The following .elc files have no corresponding .el files:" | |
96 | echo "${bogosities}" | |
97 | fi | |
9f7602fd | 98 | |
1260d6ba | 99 | echo "Creating staging directory: \`${tempparent}'" |
f7dbcf3c | 100 | mkdir ${tempparent} |
ef15f270 | 101 | emacsname="emacs-${version}${new_extension}" |
f7dbcf3c JB |
102 | tempdir="${tempparent}/${emacsname}" |
103 | ||
76fb0a58 JB |
104 | ### This trap ensures that the staging directory will be cleaned up even |
105 | ### when the script is interrupted in mid-career. | |
00c00348 ER |
106 | if [ "${clean_up}" = yes ]; then |
107 | trap "echo 'Interrupted...cleaning up the staging directory.'; rm -rf ${tempparent}; exit 1" 1 2 15 | |
108 | fi | |
109 | ||
1260d6ba | 110 | echo "Creating top directory: \`${tempdir}'" |
f7dbcf3c JB |
111 | mkdir ${tempdir} |
112 | ||
76fb0a58 JB |
113 | ### We copy in the top-level files before creating the subdirectories in |
114 | ### hopes that this will make the top-level files appear first in the | |
115 | ### tar file; this means that people can start reading the INSTALL and | |
116 | ### README while the rest of the tar file is still unpacking. Whoopee. | |
1260d6ba ER |
117 | echo "Making links to top-level files." |
118 | ln GETTING.GNU.SOFTWARE INSTALL PROBLEMS README move-if-change ${tempdir} | |
3cfb369a | 119 | ln ChangeLog Makefile.in build-install.in configure configure.in ${tempdir} |
1dce54a1 | 120 | ln make-dist ${tempdir} |
76fb0a58 JB |
121 | ### Copy config.sub; it's a cross-filesystem symlink. |
122 | cp config.sub ${tempdir} | |
f7dbcf3c | 123 | |
f753e9aa JB |
124 | echo "Updating version number in README." |
125 | (cd ${tempdir} | |
126 | awk \ | |
127 | '$1 " " $2 " " $3 " " $4 " " $5 == "This directory tree holds version" { $6 = version; print $0 } | |
128 | $1 " " $2 " " $3 " " $4 " " $5 != "This directory tree holds version"' \ | |
129 | version=${version} README > tmp.README | |
130 | mv tmp.README README) | |
131 | ||
132 | ||
f7dbcf3c | 133 | echo "Creating subdirectories." |
e793672b JB |
134 | # I think we're not going to distribute anything in external-lisp, so |
135 | # I've removed it from this list. | |
56c31c87 | 136 | for subdir in lisp lisp/term local-lisp \ |
690eca32 | 137 | src src/m src/s src/bitmaps lib-src oldXMenu \ |
1d650ff1 | 138 | etc lock cpp info man shortnames vms; do |
f7dbcf3c JB |
139 | mkdir ${tempdir}/${subdir} |
140 | done | |
141 | ||
1260d6ba | 142 | echo "Making links to \`lisp'." |
7b9cd64c | 143 | ### Don't distribute TAGS, =*.el files, site-init.el, site-load.el, or default.el. |
f7dbcf3c JB |
144 | (cd lisp |
145 | ln [a-zA-Z]*.el ../${tempdir}/lisp | |
146 | ln [a-zA-Z]*.elc ../${tempdir}/lisp | |
76fb0a58 JB |
147 | ## simula.el doesn't keep abbreviations in simula.defns any more. |
148 | ## ln [a-zA-Z]*.defns ../${tempdir}/lisp | |
f7dbcf3c JB |
149 | ln ChangeLog README ../${tempdir}/lisp |
150 | cd ../${tempdir}/lisp | |
7b9cd64c | 151 | rm -f TAGS =* |
f7dbcf3c | 152 | rm -f site-init site-init.el site-init.elc |
ef15f270 JB |
153 | rm -f site-load site-load.el site-load.elc |
154 | rm -f default default.el default.elc) | |
f7dbcf3c | 155 | |
56c31c87 RS |
156 | #echo "Making links to \`lisp/calc-2.02'." |
157 | #### Don't distribute =*.el files, TAGS or backups. | |
158 | #(cd lisp/calc-2.02 | |
159 | # ln [a-zA-Z]*.el ../../${tempdir}/lisp/calc-2.02 | |
160 | # ln [a-zA-Z]*.elc ../../${tempdir}/lisp/calc-2.02 | |
161 | # ln calc.info* calc.texinfo calc-refcard.* ../../${tempdir}/lisp/calc-2.02 | |
162 | # ln INSTALL Makefile README README.prev ../../${tempdir}/lisp/calc-2.02 | |
163 | # cd ../../${tempdir}/lisp/calc-2.02 | |
164 | # rm -f *~ TAGS) | |
fda4e8f6 | 165 | |
1260d6ba | 166 | echo "Making links to \`lisp/term'." |
7b9cd64c | 167 | ### Don't distribute =*.el files or TAGS. |
f7dbcf3c JB |
168 | (cd lisp/term |
169 | ln [a-zA-Z]*.el ../../${tempdir}/lisp/term | |
170 | ln [a-zA-Z]*.elc ../../${tempdir}/lisp/term | |
33d09384 | 171 | ln README ChangeLog ../../${tempdir}/lisp/term |
7b9cd64c | 172 | rm -f =* TAGS) |
f7dbcf3c | 173 | |
e793672b | 174 | ### echo "Making links to \`external-lisp'." |
7b9cd64c | 175 | ### ### Don't distribute =*.el files or TAGS. |
e793672b JB |
176 | ### (cd external-lisp |
177 | ### ln [a-zA-Z]*.el ../${tempdir}/external-lisp | |
178 | ### ln [a-zA-Z]*.elc ../${tempdir}/external-lisp | |
7b9cd64c ER |
179 | ### ln ChangeLog README ../${tempdir}/external-lisp |
180 | ### rm -f =* TAGS) | |
1260d6ba ER |
181 | |
182 | echo "Making links to \`src'." | |
76fb0a58 | 183 | ### Don't distribute =*.[ch] files, or the configured versions of |
7b9cd64c | 184 | ### config.h.in, paths.h.in, or Makefile.in, or TAGS. |
f7dbcf3c | 185 | (cd src |
76fb0a58 | 186 | echo " (If we can't link gmalloc.c, that's okay.)" |
f7dbcf3c | 187 | ln [a-zA-Z]*.c ../${tempdir}/src |
76fb0a58 | 188 | ## Might be a symlink to a file on another filesystem. |
39d6eb8e | 189 | test -f ../${tempdir}/src/gmalloc.c || cp gmalloc.c ../${tempdir}/src |
f7dbcf3c JB |
190 | ln [a-zA-Z]*.h ../${tempdir}/src |
191 | ln [a-zA-Z]*.s ../${tempdir}/src | |
192 | ln README Makefile.in ymakefile ChangeLog config.h.in paths.h.in \ | |
193 | ../${tempdir}/src | |
194 | ln .gdbinit .dbxinit ../${tempdir}/src | |
6f95b621 | 195 | ln *.opt vms-pp.trans ../${tempdir}/src |
f7dbcf3c | 196 | cd ../${tempdir}/src |
ef15f270 JB |
197 | rm -f config.h paths.h Makefile |
198 | if [ -z "${newer}" ]; then | |
199 | etags *.h *.c ../lisp/*.el | |
7b9cd64c ER |
200 | fi |
201 | rm -f =* TAGS) | |
f7dbcf3c | 202 | |
690eca32 JB |
203 | echo "Making links to \`src/bitmaps'." |
204 | (cd src/bitmaps | |
205 | ln README *.xbm ../../${tempdir}/src/bitmaps) | |
206 | ||
1260d6ba | 207 | echo "Making links to \`src/m'." |
f7dbcf3c | 208 | (cd src/m |
1dce54a1 | 209 | ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/m) |
f7dbcf3c | 210 | |
1260d6ba | 211 | echo "Making links to \`src/s'." |
f7dbcf3c | 212 | (cd src/s |
1dce54a1 | 213 | ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/s) |
f7dbcf3c | 214 | |
1260d6ba | 215 | echo "Making links to \`lib-src'." |
f7dbcf3c | 216 | (cd lib-src |
fa377791 | 217 | ln [a-zA-Z]*.[chy] [a-zA-Z]*.lex ../${tempdir}/lib-src |
1260d6ba | 218 | ln ChangeLog Makefile.in README testfile vcdiff rcs2log ../${tempdir}/lib-src |
d1b985ec | 219 | ln emacs.csh rcs-checkin ../${tempdir}/lib-src |
1260d6ba | 220 | cd ../${tempdir}/lib-src |
7b9cd64c ER |
221 | rm -f getdate.c getdate.tab.c y.tab.c y.tab.h |
222 | rm -f =* TAGS) | |
f7dbcf3c | 223 | |
1260d6ba | 224 | echo "Making links to \`oldXMenu'." |
f7dbcf3c | 225 | (cd oldXMenu |
8bdbf9ed | 226 | ln *.c *.h *.in ../${tempdir}/oldXMenu |
df1ec566 | 227 | ln README Imakefile ChangeLog ../${tempdir}/oldXMenu |
f395c83a | 228 | ln compile.com descrip.mms ../${tempdir}/oldXMenu) |
f7dbcf3c | 229 | |
1260d6ba | 230 | echo "Making links to \`etc'." |
f395c83a JB |
231 | ### Don't distribute = files, TAGS, DOC files, backups, autosaves, or |
232 | ### tex litter. | |
f7dbcf3c | 233 | (cd etc |
f395c83a | 234 | ln `ls -d * | grep -v 'RCS' | grep -v 'Old'` ../${tempdir}/etc |
f7dbcf3c | 235 | cd ../${tempdir}/etc |
f395c83a JB |
236 | rm -f DOC* *~ \#*\# *.dvi *.log *,v =* core |
237 | rm -f TAGS) | |
f7dbcf3c | 238 | |
fda4e8f6 JB |
239 | echo "Making links to \`cpp'." |
240 | (cd cpp | |
241 | ln cccp.c cexp.y Makefile README ../${tempdir}/cpp) | |
242 | ||
66afa119 RS |
243 | echo "Making links to \`info'." |
244 | # Don't distribute backups or autosaves. | |
245 | (cd info | |
246 | ln [a-zA-Z]* ../${tempdir}/info | |
247 | cd ../${tempdir}/info | |
248 | # Avoid an error when expanding the wildcards later. | |
249 | ln emacs dummy~ ; ln emacs \#dummy\# | |
250 | rm -f *~ \#*\# core) | |
fda4e8f6 JB |
251 | |
252 | echo "Making links to \`man'." | |
253 | (cd man | |
fa377791 | 254 | ln *.texinfo *.texi *.aux *.cps *.fns *.kys *.vrs ../${tempdir}/man |
5e808bc0 JB |
255 | test -f README && ln README ../${tempdir}/man |
256 | test -f Makefile && ln Makefile ../${tempdir}/man | |
56c31c87 RS |
257 | ln ChangeLog split-man ../${tempdir}/man |
258 | cp texinfo.tex texindex.c ../${tempdir}/man | |
4f8cc93a | 259 | cd ../${tempdir}/man |
56c31c87 RS |
260 | rm -f \#*\# =* *~ core emacs-index* *.Z *.z xmail |
261 | rm -f emacs.?? termcap.?? gdb.?? *.log *.toc *.dvi *.oaux) | |
f7dbcf3c | 262 | |
1260d6ba | 263 | echo "Making links to \`shortnames'." |
f7dbcf3c JB |
264 | (cd shortnames |
265 | ln *.c ../${tempdir}/shortnames | |
266 | ln Makefile reserved special ../${tempdir}/shortnames) | |
267 | ||
40eef465 JB |
268 | echo "Making links to \`vms'." |
269 | (cd vms | |
270 | ln [0-9a-zA-Z]* ../${tempdir}/vms | |
271 | cd ../${tempdir}/vms | |
272 | rm -f *~) | |
273 | ||
c87b230f JB |
274 | ### It would be nice if they could all be symlinks to etc's copy, but |
275 | ### you're not supposed to have any symlinks in distribution tar files. | |
276 | echo "Making sure copying notices are all copies of \`etc/COPYING'." | |
1260d6ba ER |
277 | rm -f ${tempdir}/etc/COPYING |
278 | cp etc/COPYING ${tempdir}/etc/COPYING | |
5b246836 JB |
279 | # I think we're not going to distribute anything in external-lisp, so |
280 | # I've removed it from this list. | |
281 | for subdir in lisp src lib-src info shortnames; do | |
f7dbcf3c JB |
282 | if [ -f ${tempdir}/${subdir}/COPYING ]; then |
283 | rm ${tempdir}/${subdir}/COPYING | |
284 | fi | |
96858c42 | 285 | cp etc/COPYING ${tempdir}/${subdir} |
f7dbcf3c JB |
286 | done |
287 | ||
5b8def65 JB |
288 | #### Make sure that there aren't any hard links between files in the |
289 | #### distribution; people with afs can't deal with that. Okay, | |
290 | #### actually we just re-copy anything with a link count greater | |
291 | #### than two. | |
292 | echo "Breaking intra-tree links." | |
e94817d7 JB |
293 | find ${tempdir} ! -type d -links +2 \ |
294 | -exec cp {} $$ \; -exec rm -f {} \; -exec mv $$ {} \; | |
5b8def65 | 295 | |
1260d6ba ER |
296 | if [ "${newer}" ]; then |
297 | echo "Removing files older than $newer." | |
76fb0a58 JB |
298 | ## We remove .elc files unconditionally, on the theory that anyone picking |
299 | ## up an incremental distribution already has a running Emacs to byte-compile | |
300 | ## them with. | |
1260d6ba ER |
301 | find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \; |
302 | fi | |
303 | ||
4746118a | 304 | if [ "${make_tar}" = yes ]; then |
922ac4c5 JB |
305 | if [ "${default_gzip}" = "" ]; then |
306 | echo "Looking for gzip." | |
307 | temppath=`echo $PATH | sed 's/^:/.:/ | |
308 | s/::/:.:/g | |
309 | s/:$/:./ | |
310 | s/:/ /g'` | |
311 | default_gzip=`( | |
312 | for dir in ${temppath}; do | |
313 | if [ -f ${dir}/gzip ]; then echo 'gzip --best'; exit 0; fi | |
314 | done | |
315 | echo compress | |
316 | )` | |
317 | fi | |
f395c83a JB |
318 | case "${default_gzip}" in |
319 | compress* ) gzip_extension=.Z ;; | |
320 | * ) gzip_extension=.z ;; | |
321 | esac | |
4746118a | 322 | echo "Creating tar file." |
f395c83a JB |
323 | (cd ${tempparent} ; tar cvf - ${emacsname} ) \ |
324 | | ${default_gzip} \ | |
325 | > ${emacsname}.tar${gzip_extension} | |
4746118a | 326 | fi |
f7dbcf3c | 327 | |
4746118a | 328 | if [ "${clean_up}" = yes ]; then |
f7dbcf3c | 329 | echo "Cleaning up the staging directory." |
f395c83a | 330 | rm -rf ${tempparent} |
f7dbcf3c | 331 | fi |
00c00348 | 332 | |
76fb0a58 | 333 | ### make-dist ends here |