]> code.delx.au - gnu-emacs/blob - make-dist
Make links for files under lisp/language.
[gnu-emacs] / make-dist
1 #!/bin/sh
2
3 #### make-dist: create an Emacs distribution tar file from the current
4 #### source tree. This basically creates a duplicate directory
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.
8
9 # Copyright (C) 1995 Free Software Foundation, Inc.
10 #
11 # This file is part of GNU Emacs.
12 #
13 # GNU Emacs is free software; you can redistribute it and/or modify
14 # it under the terms of the GNU General Public License as published by
15 # the Free Software Foundation; either version 2, or (at your option)
16 # any later version.
17 #
18 # GNU Emacs is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
22 #
23 # You should have received a copy of the GNU General Public License
24 # along with GNU Emacs; see the file COPYING. If not, write to the
25 # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26 # Boston, MA 02111-1307, USA.
27
28 progname="$0"
29
30 ### Exit if a command fails.
31 ### set -e
32
33 ### Print out each line we read, for debugging's sake.
34 ### set -v
35
36 update=yes
37 clean_up=no
38 make_tar=no
39 newer=""
40
41 while [ $# -gt 0 ]; do
42 case "$1" in
43 ## This option tells make-dist to delete the staging directory
44 ## when done. It is useless to use this unless you make a tar file.
45 "--clean-up" )
46 clean_up=yes
47 ;;
48 ## This option tells make-dist to make a tar file.
49 "--tar" )
50 make_tar=yes
51 ;;
52 ## This option tells make-dist not to recompile or do analogous things.
53 "--no-update" )
54 update=no
55 ;;
56 ## This option tells make-dist to make the distribution normally, then
57 ## remove all files older than the given timestamp file. This is useful
58 ## for creating incremental or patch distributions.
59 "--newer")
60 newer="$2"
61 new_extension=".new"
62 shift
63 ;;
64 ## This option tells make-dist to use `compress' instead of gzip.
65 ## Normally, make-dist uses gzip whenever it is present.
66 "--compress")
67 default_gzip="compress"
68 ;;
69 * )
70 echo "${progname}: Unrecognized argument: $1" >&2
71 exit 1
72 ;;
73 esac
74 shift
75 done
76
77 ### Make sure we're running in the right place.
78 if [ ! -d src -o ! -f src/lisp.h -o ! -d lisp -o ! -f lisp/version.el ]; then
79 echo "${progname}: Can't find \`src/lisp.h' and \`lisp/version.el'." >&2
80 echo "${progname} must be run in the top directory of the Emacs" >&2
81 echo "distribution tree. cd to that directory and try again." >&2
82 exit 1
83 fi
84
85 ### Find where to run Emacs.
86 if [ $update = yes ];
87 then
88 if [ -f src/emacs ];
89 then
90 EMACS=`pwd`/src/emacs
91 else
92 if [ x$EMACS = x ];
93 then
94 echo You must specify the EMACS environment variable 2>&1
95 exit 1
96 fi
97 fi
98 fi
99
100 ### Find out which version of Emacs this is.
101 shortversion=`grep 'defconst[ ]*emacs-version' lisp/version.el \
102 | sed -e 's/^.*"\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/'`
103 version=`grep 'defconst[ ]*emacs-version' lisp/version.el \
104 | sed -e 's/^[^"]*"\([^"]*\)".*$/\1/'`
105 if [ ! "${version}" ]; then
106 echo "${progname}: can't find current Emacs version in \`./lisp/version.el'" >&2
107 exit 1
108 fi
109
110 echo Version numbers are $version and $shortversion
111
112 if [ $update = yes ];
113 then
114 if grep -s "GNU Emacs version ${shortversion}" ./man/emacs.texi > /dev/null; then
115 true
116 else
117 echo "You must update the version number in \`./man/emacs.texi'"
118 sleep 5
119 fi
120 fi
121
122 ### Make sure we don't already have a directory emacs-${version}.
123
124 emacsname="emacs-${version}${new_extension}"
125
126 if [ -d ${emacsname} ]
127 then
128 echo Directory "${emacsname}" already exists >&2
129 exit 1
130 fi
131
132 ### Make sure the subdirectory is available.
133 tempparent="make-dist.tmp.$$"
134 if [ -d ${tempparent} ]; then
135 echo "${progname}: staging directory \`${tempparent}' already exists.
136 Perhaps a previous invocation of \`${progname}' failed to clean up after
137 itself. Check that directories whose names are of the form
138 \`make-dist.tmp.NNNNN' don't contain any important information, remove
139 them, and try again." >&2
140 exit 1
141 fi
142
143 ### Check for .elc files with no corresponding .el file.
144 ls -1 lisp/*.el | sed 's/\.el$/.elc/' > /tmp/el
145 ls -1 lisp/*.elc > /tmp/elc
146 bogosities="`comm -13 /tmp/el /tmp/elc`"
147 if [ "${bogosities}" != "" ]; then
148 echo "The following .elc files have no corresponding .el files:"
149 echo "${bogosities}"
150 fi
151 rm -f /tmp/el /tmp/elc
152
153 ### Check for .el files that would overflow the 14-char limit if compiled.
154 long=`find lisp -name '[a-zA-Z0-9]??????????*.el' -print`
155 if [ "$long" != "" ]; then
156 echo "The following .el file names are too long:"
157 echo "$long"
158 fi
159
160 ### Make sure configure is newer than configure.in.
161 if [ "x`ls -t configure configure.in | head -1`" != "xconfigure" ]; then
162 echo "\`./configure.in' is newer than \`./configure'" >&2
163 echo "Running autoconf" >&2
164 autoconf || { x=$?; echo Autoconf FAILED! >&2; exit $x; }
165 fi
166
167 if [ $update = yes ];
168 then
169 echo "Updating Info files"
170
171 (cd man; make info)
172
173 echo "Updating finder-inf.el"
174
175 (cd lisp; $EMACS -batch -l finder -f finder-compile-keywords-make-dist)
176
177 echo "Recompiling Lisp files"
178
179 $EMACS -batch -f batch-byte-recompile-directory lisp
180
181 echo "Updating autoloads"
182
183 $EMACS -batch -f batch-update-autoloads lisp
184 fi
185
186 echo "Making lisp/MANIFEST"
187
188 (cd lisp; head -1 [!=]*.el | grep '^;' | sed -e 's/;;; //' > MANIFEST)
189
190 echo "Creating staging directory: \`${tempparent}'"
191
192 mkdir ${tempparent}
193 tempdir="${tempparent}/${emacsname}"
194
195 ### This trap ensures that the staging directory will be cleaned up even
196 ### when the script is interrupted in mid-career.
197 if [ "${clean_up}" = yes ]; then
198 trap "echo 'Interrupted...cleaning up the staging directory'; rm -rf ${tempparent}; exit 1" 1 2 15
199 fi
200
201 echo "Creating top directory: \`${tempdir}'"
202 mkdir ${tempdir}
203
204 ### We copy in the top-level files before creating the subdirectories in
205 ### hopes that this will make the top-level files appear first in the
206 ### tar file; this means that people can start reading the INSTALL and
207 ### README while the rest of the tar file is still unpacking. Whoopee.
208 echo "Making links to top-level files"
209 ln GETTING.GNU.SOFTWARE INSTALL PROBLEMS README BUGS move-if-change ${tempdir}
210 ln ChangeLog Makefile.in configure configure.in ${tempdir}
211 ln config.bat make-dist update-subdirs vpath.sed ${tempdir}
212 ### Copy these files; they're cross-filesystem symlinks.
213 cp mkinstalldirs ${tempdir}
214 cp config.sub ${tempdir}
215 cp config.guess ${tempdir}
216 cp install.sh ${tempdir}
217
218 echo "Updating version number in README"
219 (cd ${tempdir}
220 awk \
221 '$1 " " $2 " " $3 " " $4 " " $5 == "This directory tree holds version" { $6 = version; print $0 }
222 $1 " " $2 " " $3 " " $4 " " $5 != "This directory tree holds version"' \
223 version=${version} README > tmp.README
224 mv tmp.README README)
225
226
227 echo "Creating subdirectories"
228 for subdir in lisp lisp/term lisp/language site-lisp \
229 src src/m src/s src/bitmaps lib-src oldXMenu lwlib \
230 nt nt/inc nt/inc/sys nt/inc/arpa nt/inc/netinet \
231 etc etc/e lock cpp info man msdos vms; do
232 mkdir ${tempdir}/${subdir}
233 done
234
235 echo "Making links to \`lisp'"
236 ### Don't distribute TAGS, =*.el files, site-init.el, site-load.el, or default.el.
237 (cd lisp
238 ln [a-zA-Z]*.el ../${tempdir}/lisp
239 ln [a-zA-Z]*.elc ../${tempdir}/lisp
240 ln [a-zA-Z]*.dat ../${tempdir}/lisp
241 ## simula.el doesn't keep abbreviations in simula.defns any more.
242 ## ln [a-zA-Z]*.defns ../${tempdir}/lisp
243 ln ChangeLog Makefile makefile.nt ChangeLog.? README ../${tempdir}/lisp
244 cd ../${tempdir}/lisp
245 rm -f TAGS =*
246 rm -f subdirs.el
247 rm -f site-init site-init.el site-init.elc
248 rm -f site-load site-load.el site-load.elc
249 rm -f site-start site-start.el site-start.elc
250 rm -f default default.el default.elc)
251
252 #echo "Making links to \`lisp/calc-2.02'"
253 #### Don't distribute =*.el files, TAGS or backups.
254 #(cd lisp/calc-2.02
255 # ln [a-zA-Z]*.el ../../${tempdir}/lisp/calc-2.02
256 # ln [a-zA-Z]*.elc ../../${tempdir}/lisp/calc-2.02
257 # ln calc.info* calc.texinfo calc-refcard.* ../../${tempdir}/lisp/calc-2.02
258 # ln INSTALL Makefile README README.prev ../../${tempdir}/lisp/calc-2.02
259 # cd ../../${tempdir}/lisp/calc-2.02
260 # rm -f *~ TAGS)
261
262 echo "Making links to \`lisp/term'"
263 ### Don't distribute =*.el files or TAGS.
264 (cd lisp/term
265 ln [a-zA-Z]*.el ../../${tempdir}/lisp/term
266 ln [a-zA-Z]*.elc ../../${tempdir}/lisp/term
267 ln README ../../${tempdir}/lisp/term
268 rm -f =* TAGS)
269
270 echo "Making links to \`lisp/term'"
271 ### Don't distribute =*.el files or TAGS.
272 (cd lisp/language
273 ln [a-zA-Z]*.el ../../${tempdir}/lisp/language
274 ln [a-zA-Z]*.elc ../../${tempdir}/lisp/language
275 rm -f =* TAGS)
276
277 echo "Making links to \`src'"
278 ### Don't distribute =*.[ch] files, or the configured versions of
279 ### config.in, paths.in, or Makefile.in, or TAGS.
280 (cd src
281 echo " (It is ok if ln fails in some cases.)"
282 ln [a-zA-Z]*.c ../${tempdir}/src
283 ln [a-zA-Z]*.h ../${tempdir}/src
284 ln [a-zA-Z]*.s ../${tempdir}/src
285 ln [a-zA-Z]*.in ../${tempdir}/src
286 ln [a-zA-Z]*.opt ../${tempdir}/src
287 ## If we ended up with a symlink, or if we did not get anything
288 ## due to a cross-device symlink, copy the file.
289 for file in [a-zA-Z]*.[hcs] [a-zA-Z]*.in [a-zA-Z]*.opt; do
290 if test -f ../${tempdir}/src/$file; then
291 # test -f appears to succeed for a symlink
292 if test -L ../${tempdir}/src/$file; then
293 rm ../${tempdir}/src/$file
294 cp $file ../${tempdir}/src
295 chmod a-w ../${tempdir}/src/$file
296 fi
297 else
298 rm ../${tempdir}/src/$file
299 cp $file ../${tempdir}/src
300 chmod a-w ../${tempdir}/src/$file
301 fi
302 done
303 ln README ChangeLog ChangeLog.*[0-9] ../${tempdir}/src
304 ln makefile.nt vms-pp.trans ../${tempdir}/src
305 ln .gdbinit .dbxinit ../${tempdir}/src
306 cd ../${tempdir}/src
307 rm -f config.h paths.h Makefile Makefile.c
308 rm -f =* TAGS)
309
310 echo "Making links to \`src/bitmaps'"
311 (cd src/bitmaps
312 ln README *.xbm ../../${tempdir}/src/bitmaps)
313
314 echo "Making links to \`src/m'"
315 (cd src/m
316 # We call files for miscellaneous input (to linker etc) .inp.
317 ln README [a-zA-Z0-9]*.h *.inp ../../${tempdir}/src/m)
318
319 echo "Making links to \`src/s'"
320 (cd src/s
321 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/s)
322
323 echo "Making links to \`lib-src'"
324 (cd lib-src
325 ln [a-zA-Z]*.[chy] ../${tempdir}/lib-src
326 ln ChangeLog Makefile.in README testfile vcdiff ../${tempdir}/lib-src
327 ln emacs.csh rcs2log rcs-checkin makefile.nt ../${tempdir}/lib-src
328 ## If we ended up with a symlink, or if we did not get anything
329 ## due to a cross-device symlink, copy the file.
330 for file in [a-zA-Z]*.[chy]; do
331 if test -f ../${tempdir}/lib-src/$file; then
332 # test -f appears to succeed for a symlink
333 if test -L ../${tempdir}/lib-src/$file; then
334 rm ../${tempdir}/lib-src/$file
335 cp $file ../${tempdir}/lib-src
336 chmod a-w ../${tempdir}/lib-src/$file
337 fi
338 else
339 rm ../${tempdir}/lib-src/$file
340 cp $file ../${tempdir}/lib-src
341 chmod a-w ../${tempdir}/lib-src/$file
342 fi
343 done
344 cd ../${tempdir}/lib-src
345 rm -f Makefile.c
346 rm -f =* TAGS)
347
348 echo "Making links to \`nt'"
349 (cd nt
350 ln emacs.ico emacs.rc config.nt [a-z]*.in [a-z]*.c ../${tempdir}/nt
351 ln [a-z]*.bat [a-z]*.h makefile.def makefile.nt ../${tempdir}/nt
352 ln TODO ChangeLog INSTALL README ../${tempdir}/nt)
353
354 echo "Making links to \`nt/inc'"
355 (cd nt/inc
356 ln [a-z]*.h ../../${tempdir}/nt/inc)
357
358 echo "Making links to \`nt/inc/sys'"
359 (cd nt/inc/sys
360 ln [a-z]*.h ../../../${tempdir}/nt/inc/sys)
361
362 echo "Making links to \`nt/inc/arpa'"
363 (cd nt/inc/arpa
364 ln [a-z]*.h ../../../${tempdir}/nt/inc/arpa)
365
366 echo "Making links to \`nt/inc/netinet'"
367 (cd nt/inc/netinet
368 ln [a-z]*.h ../../../${tempdir}/nt/inc/netinet)
369
370 echo "Making links to \`msdos'"
371 (cd msdos
372 ln ChangeLog emacs.ico emacs.pif ../${tempdir}/msdos
373 ln is_exec.c sigaction.c mainmake mainmake.v2 sed*.inp ../${tempdir}/msdos
374 cd ../${tempdir}/msdos
375 rm -f =*)
376
377 echo "Making links to \`oldXMenu'"
378 (cd oldXMenu
379 ln *.c *.h *.in ../${tempdir}/oldXMenu
380 ln README Imakefile ChangeLog ../${tempdir}/oldXMenu
381 ln compile.com descrip.mms ../${tempdir}/oldXMenu)
382
383 echo "Making links to \`lwlib'"
384 (cd lwlib
385 ln *.c *.h *.in ../${tempdir}/lwlib
386 ln README Imakefile ChangeLog ../${tempdir}/lwlib
387 cd ../${tempdir}/lwlib
388 rm -f lwlib-Xol*)
389
390 echo "Making links to \`etc'"
391 ### Don't distribute = files, TAGS, DOC files, backups, autosaves, or
392 ### tex litter.
393 (cd etc
394 ln `ls -d * | grep -v 'RCS' | grep -v 'Old' | grep -v '^e$'` ../${tempdir}/etc
395 cd ../${tempdir}/etc
396 rm -f DOC* *~ \#*\# *.dvi *.log *.orig *.rej *,v =* core
397 rm -f TAGS)
398
399 echo "Making links to \`etc/e'"
400 (cd etc/e
401 ln `ls -d * | grep -v 'RCS'` ../../${tempdir}/etc/e
402 cd ../../${tempdir}/etc/e
403 rm -f *~ \#*\# *,v =* core)
404
405 echo "Making links to \`cpp'"
406 (cd cpp
407 ln cccp.c cexp.y Makefile README ../${tempdir}/cpp)
408
409 echo "Making links to \`info'"
410 # Don't distribute backups or autosaves.
411 (cd info
412 ln [a-zA-Z]* ../${tempdir}/info
413 cd ../${tempdir}/info
414 # Avoid an error when expanding the wildcards later.
415 ln emacs dummy~ ; ln emacs \#dummy\#
416 rm -f *~ \#*\# core)
417
418 echo "Making links to \`man'"
419 (cd man
420 ln *.texi *.aux *.cps *.fns *.kys *.vrs ../${tempdir}/man
421 test -f README && ln README ../${tempdir}/man
422 test -f Makefile.in && ln Makefile.in ../${tempdir}/man
423 ln ChangeLog split-man ../${tempdir}/man
424 cp texinfo.tex ../${tempdir}/man
425 cd ../${tempdir}/man
426 rm -f \#*\# =* *~ core emacs-index* *.Z *.z xmail
427 rm -f emacs.?? termcap.?? gdb.?? *.log *.toc *.dvi *.oaux)
428
429 echo "Making links to \`vms'"
430 (cd vms
431 ln [0-9a-zA-Z]* ../${tempdir}/vms
432 cd ../${tempdir}/vms
433 rm -f *~)
434
435 ### It would be nice if they could all be symlinks to etc's copy, but
436 ### you're not supposed to have any symlinks in distribution tar files.
437 echo "Making sure copying notices are all copies of \`etc/COPYING'"
438 rm -f ${tempdir}/etc/COPYING
439 cp etc/COPYING ${tempdir}/etc/COPYING
440 for subdir in lisp src lib-src info msdos; do
441 if [ -f ${tempdir}/${subdir}/COPYING ]; then
442 rm ${tempdir}/${subdir}/COPYING
443 fi
444 cp etc/COPYING ${tempdir}/${subdir}
445 done
446
447 #### Make sure that there aren't any hard links between files in the
448 #### distribution; people with afs can't deal with that. Okay,
449 #### actually we just re-copy anything with a link count greater
450 #### than two. (Yes, strictly greater than 2 is correct; since we
451 #### created these files by linking them in from the original tree,
452 #### they'll have exactly two links normally.)
453 ####
454 #### Commented out since it's not strictly necessary; it should suffice
455 #### to just break the link on alloca.c.
456 #echo "Breaking intra-tree links."
457 #find ${tempdir} ! -type d -links +2 \
458 # -exec cp -p {} $$ \; -exec rm -f {} \; -exec mv $$ {} \;
459 rm -f $tempdir/lib-src/alloca.c
460 cp $tempdir/src/alloca.c $tempdir/lib-src/alloca.c
461
462 if [ "${newer}" ]; then
463 echo "Removing files older than $newer"
464 ## We remove .elc files unconditionally, on the theory that anyone picking
465 ## up an incremental distribution already has a running Emacs to byte-compile
466 ## them with.
467 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
468 fi
469
470 if [ "${make_tar}" = yes ]; then
471 if [ "${default_gzip}" = "" ]; then
472 echo "Looking for gzip"
473 temppath=`echo $PATH | sed 's/^:/.:/
474 s/::/:.:/g
475 s/:$/:./
476 s/:/ /g'`
477 default_gzip=`(
478 for dir in ${temppath}; do
479 if [ -f ${dir}/gzip ]; then echo 'gzip --best'; exit 0; fi
480 done
481 echo compress
482 )`
483 fi
484 case "${default_gzip}" in
485 compress* ) gzip_extension=.Z ;;
486 * ) gzip_extension=.gz ;;
487 esac
488 echo "Creating tar file"
489 (cd ${tempparent} ; tar cvf - ${emacsname} ) \
490 | ${default_gzip} \
491 > ${emacsname}.tar${gzip_extension}
492 fi
493
494 if [ "${clean_up}" = yes ]; then
495 echo "Cleaning up the staging directory"
496 rm -rf ${tempparent}
497 else
498 (cd ${tempparent}; mv ${emacsname} ..)
499 rm -rf ${tempparent}
500 fi
501
502 ### make-dist ends here