Obsolete.
[emacs.git] / make-dist
blob86a78f88e51a78fa12e36220885118c1a810a8d3
1 #!/bin/sh
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.
9 # Copyright (C) 1995, 1997, 1998, 2000 Free Software Foundation, Inc.
11 # This file is part of GNU Emacs.
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.
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.
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.
28 progname="$0"
30 ### Exit if a command fails.
31 ### set -e
33 ### Print out each line we read, for debugging's sake.
34 ### set -v
36 ## Don't restrict access to any files.
37 umask 0
39 update=yes
40 check=yes
41 clean_up=no
42 make_tar=no
43 newer=""
45 while [ $# -gt 0 ]; do
46 case "$1" in
47 ## This option tells make-dist to delete the staging directory
48 ## when done. It is useless to use this unless you make a tar file.
49 "--clean-up" )
50 clean_up=yes
52 ## This option tells make-dist to make a tar file.
53 "--tar" )
54 make_tar=yes
56 ## This option tells make-dist not to recompile or do analogous things.
57 "--no-update" )
58 update=no
60 ## This option says don't check for bad file names, etc.
61 "--no-check" )
62 check=no
64 ## This option tells make-dist to make the distribution normally, then
65 ## remove all files older than the given timestamp file. This is useful
66 ## for creating incremental or patch distributions.
67 "--newer")
68 newer="$2"
69 new_extension=".new"
70 shift
72 ## This option tells make-dist to use `compress' instead of gzip.
73 ## Normally, make-dist uses gzip whenever it is present.
74 "--compress")
75 default_gzip="compress"
77 * )
78 echo "${progname}: Unrecognized argument: $1" >&2
79 exit 1
81 esac
82 shift
83 done
85 ### Make sure we're running in the right place.
86 if [ ! -d src -o ! -f src/lisp.h -o ! -d lisp -o ! -f lisp/version.el ]; then
87 echo "${progname}: Can't find \`src/lisp.h' and \`lisp/version.el'." >&2
88 echo "${progname} must be run in the top directory of the Emacs" >&2
89 echo "distribution tree. cd to that directory and try again." >&2
90 exit 1
93 ### Find where to run Emacs.
94 ### (We don't accept EMACS=t as an answer, since that probably only means
95 ### that the shell is running in an Emacs window.)
96 if [ $update = yes ];
97 then
98 unset EMACS_UNIBYTE
99 if [ -f src/emacs ];
100 then
101 EMACS=`pwd`/src/emacs
102 else
103 if [ "x$EMACS" = "x" -o "x$EMACS" = "xt" ];
104 then
105 echo You must specify the EMACS environment variable 2>&1
106 exit 1
111 ### Find out which version of Emacs this is.
112 shortversion=`grep 'defconst[ ]*emacs-version' lisp/version.el \
113 | sed -e 's/^.*"\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/'`
114 version=`grep 'defconst[ ]*emacs-version' lisp/version.el \
115 | sed -e 's/^[^"]*"\([^"]*\)".*$/\1/'`
116 if [ ! "${version}" ]; then
117 echo "${progname}: can't find current Emacs version in \`./lisp/version.el'" >&2
118 exit 1
121 echo Version numbers are $version and $shortversion
123 if [ $update = yes ];
124 then
125 if grep -s "GNU Emacs version ${shortversion}" ./man/emacs.texi > /dev/null; then
126 true
127 else
128 echo "You must update the version number in \`./man/emacs.texi'"
129 sleep 5
133 ### Make sure we don't already have a directory emacs-${version}.
135 emacsname="emacs-${version}${new_extension}"
137 if [ -d ${emacsname} ]
138 then
139 echo Directory "${emacsname}" already exists >&2
140 exit 1
143 ### Make sure the subdirectory is available.
144 tempparent="make-dist.tmp.$$"
145 if [ -d ${tempparent} ]; then
146 echo "${progname}: staging directory \`${tempparent}' already exists.
147 Perhaps a previous invocation of \`${progname}' failed to clean up after
148 itself. Check that directories whose names are of the form
149 \`make-dist.tmp.NNNNN' don't contain any important information, remove
150 them, and try again." >&2
151 exit 1
154 ### Find where to run Emacs.
155 if [ $check = yes ];
156 then
157 ### Check for .elc files with no corresponding .el file.
158 ls -1 lisp/[a-z]*.el lisp/[a-z]*/[a-z]*.el \
159 leim/[a-z]*/[a-z]*.el | sed 's/\.el$/.elc/' > /tmp/el
160 ls -1 lisp/[a-z]*.elc lisp/[a-z]*/[a-z]*.elc \
161 leim/[a-z]*/[a-z]*.elc > /tmp/elc
162 bogosities="`comm -13 /tmp/el /tmp/elc`"
163 if [ "${bogosities}" != "" ]; then
164 echo "The following .elc files have no corresponding .el files:"
165 echo "${bogosities}"
167 rm -f /tmp/el /tmp/elc
169 ### Check for .el files with no corresponding .elc file.
170 (cd lisp; ls -1 [a-z]*.el [a-z]*/[a-z]*.el ; \
171 cd ../leim; ls -1 [a-z]*/[a-z]*.el) > /tmp/el
172 (cd lisp; ls -1 [a-z]*.elc [a-z]*/[a-z]*.elc; \
173 cd ../leim; ls -1 [a-z]*/[a-z]*.elc) | sed 's/\.elc$/.el/' > /tmp/elc
174 losers="`comm -23 /tmp/el /tmp/elc`"
175 bogosities=
176 for file in $losers; do
177 file1=`echo $file | sed -e "s|.*/||"`
178 if ! sed -n -e "/^DONTCOMPILE/,/[^\\]\$/p" lisp/Makefile |
179 grep -q "[ ]$file1\($\| \)"; then
180 case $file in
181 site-init.el | site-load.el | site-start.el | default.el)
183 term/*)
186 bogosities="$file $bogosities"
188 esac
190 done
191 if [ x"${bogosities}" != x"" ]; then
192 echo "The following .el files have no corresponding .elc files:"
193 echo "${bogosities}"
195 rm -f /tmp/el /tmp/elc
197 ### Check for .el files that would overflow the 14-char limit if compiled.
198 long=`find lisp leim -name '[a-zA-Z0-9]??????????*.el' -print`
199 if [ "$long" != "" ]; then
200 echo "The following .el file names are too long:"
201 echo "$long"
205 ### Make sure configure is newer than configure.in.
206 if [ "x`ls -t configure configure.in | head -1`" != "xconfigure" ]; then
207 echo "\`./configure.in' is newer than \`./configure'" >&2
208 echo "Running autoconf" >&2
209 autoconf || { x=$?; echo Autoconf FAILED! >&2; exit $x; }
212 if [ $update = yes ];
213 then
214 echo "Updating Info files"
215 (cd man; make -f Makefile.in srcdir=. info)
217 echo "Updating finder, custom and autoload data"
218 (cd lisp; make updates EMACS="$EMACS")
220 if test -f leim/leim-list.el; then
221 echo "Updating leim-list.el"
222 (cd leim; make leim-list.el EMACS="$EMACS")
225 echo "Recompiling Lisp files"
226 $EMACS -batch -f batch-byte-recompile-directory lisp leim
229 echo "Making lisp/MANIFEST"
231 (cd lisp;
232 files=`echo [!=]*.el | sed -e 's/ subdirs.el / /' -e 's/ default.el / /'`
233 for dir in [!=]*; do
234 if [ -d $dir ] && [ $dir != term ] && [ $dir != CVS ] && [ $dir != RCS ]
235 then
236 echo $dir
237 thisdir=`echo $dir/[!=]*.el | sed -e 's/ subdirs.el / /'`
238 files="$files $thisdir"
240 done
241 head -1 $files | grep '^;' | sed -e 's/;;; //' | sort > MANIFEST)
243 echo "Creating staging directory: \`${tempparent}'"
245 mkdir ${tempparent}
246 tempdir="${tempparent}/${emacsname}"
248 ### This trap ensures that the staging directory will be cleaned up even
249 ### when the script is interrupted in mid-career.
250 if [ "${clean_up}" = yes ]; then
251 trap "echo 'Interrupted...cleaning up the staging directory'; rm -rf ${tempparent}; exit 1" 1 2 15
254 echo "Creating top directory: \`${tempdir}'"
255 mkdir ${tempdir}
257 ### We copy in the top-level files before creating the subdirectories in
258 ### hopes that this will make the top-level files appear first in the
259 ### tar file; this means that people can start reading the INSTALL and
260 ### README while the rest of the tar file is still unpacking. Whoopee.
261 echo "Making links to top-level files"
262 ln GETTING.GNU.SOFTWARE INSTALL README BUGS move-if-change ${tempdir}
263 ln ChangeLog Makefile.in configure configure.in ${tempdir}
264 ln config.bat make-dist update-subdirs vpath.sed ${tempdir}
265 ### Copy these files; they're cross-filesystem symlinks.
266 cp mkinstalldirs ${tempdir}
267 cp config.sub ${tempdir}
268 cp config.guess ${tempdir}
269 cp install.sh ${tempdir}
271 echo "Updating version number in README"
272 (cd ${tempdir}
273 awk \
274 '$1 " " $2 " " $3 " " $4 " " $5 == "This directory tree holds version" { $6 = version; print $0 }
275 $1 " " $2 " " $3 " " $4 " " $5 != "This directory tree holds version"' \
276 version=${version} README > tmp.README
277 mv -f tmp.README README)
280 echo "Creating subdirectories"
281 for subdir in lisp site-lisp leim real-leim real-leim/CXTERM-DIC \
282 real-leim/SKK-DIC real-leim/skk real-leim/quail \
283 src src/m src/s src/bitmaps lib-src oldXMenu lwlib \
284 nt nt/inc nt/inc/sys nt/inc/arpa nt/inc/netinet nt/icons \
285 etc etc/e lock info man msdos vms; do
286 mkdir ${tempdir}/${subdir}
287 done
289 echo "Initializing \`leim' subdirectory"
290 cp leim/Makefile.in ${tempdir}/leim
292 echo "Making links to \`lisp' and its subdirectories"
293 ### Don't distribute TAGS, =*.el files, site-init.el, site-load.el, or default.el.
294 (cd lisp
295 ln [a-zA-Z]*.el ../${tempdir}/lisp
296 ln [a-zA-Z]*.elc ../${tempdir}/lisp
297 ln [a-zA-Z]*.dat ../${tempdir}/lisp
298 ## simula.el doesn't keep abbreviations in simula.defns any more.
299 ## ln [a-zA-Z]*.defns ../${tempdir}/lisp
300 ln ChangeLog Makefile makefile.nt ChangeLog.? ../${tempdir}/lisp
301 test -f README && ln README ../${tempdir}/lisp
302 (cd ../${tempdir}/lisp
303 rm -f TAGS =*
304 rm -f site-init site-init.el site-init.elc
305 rm -f site-load site-load.el site-load.elc
306 rm -f site-start site-start.el site-start.elc
307 rm -f default default.el default.elc
310 ## Find all subdirs of lisp dir
311 for file in `find . -type d -print`; do
312 case $file in
313 . | .. | */Old | */CVS | */RCS | */=*)
316 if [ -d $file ]; then
317 subdirs="$file $subdirs"
320 esac
321 done
323 for file in $subdirs; do
324 echo " lisp/$file"
325 mkdir ../${tempdir}/lisp/$file
326 ln $file/[a-zA-Z]*.el ../${tempdir}/lisp/$file
327 ln $file/[a-zA-Z]*.elc ../${tempdir}/lisp/$file
328 if [ -f $file/README ]; then
329 ln $file/README ../${tempdir}/lisp/$file
331 if [ -f $file/ChangeLog ]; then
332 ln $file/ChangeLog ../${tempdir}/lisp/$file
334 done )
336 echo "Making links to \`leim' and its subdirectories for the LEIM distribution"
337 ### Don't distribute TAGS, or =*.el files.
338 (cd leim
339 ln makefile.nt ../${tempdir}/real-leim
340 ln ChangeLog README ../${tempdir}/real-leim
342 ln CXTERM-DIC/*.tit ../${tempdir}/real-leim/CXTERM-DIC
343 ln SKK-DIC/README SKK-DIC/SKK-JISYO.L ../${tempdir}/real-leim/SKK-DIC
344 ln skk/*.el skk/*.elc ../${tempdir}/real-leim/skk
345 ln quail/*.el quail/*.elc ../${tempdir}/real-leim/quail
347 cp ../leim-Makefile.in ../${tempdir}/real-leim/Makefile.in
349 cd ../${tempdir}/real-leim
350 rm -f TAGS =* */=*)
352 ### Move the real-leim directory outside of Emacs proper.
353 (cd ${tempparent}
354 mkdir ${emacsname}-leim
355 mkdir ${emacsname}-leim/${emacsname}
356 mv ${emacsname}/real-leim ${emacsname}-leim/${emacsname}/leim)
358 echo "Making links to \`src'"
359 ### Don't distribute =*.[ch] files, or the configured versions of
360 ### config.in, paths.in, or Makefile.in, or TAGS.
361 (cd src
362 echo " (It is ok if ln fails in some cases.)"
363 ln [a-zA-Z]*.c ../${tempdir}/src
364 ln [a-zA-Z]*.h ../${tempdir}/src
365 ln [a-zA-Z]*.s ../${tempdir}/src
366 ln [a-zA-Z]*.in ../${tempdir}/src
367 ln [a-zA-Z]*.opt ../${tempdir}/src
368 ## If we ended up with a symlink, or if we did not get anything
369 ## due to a cross-device symlink, copy the file.
370 for file in [a-zA-Z]*.[hcs] [a-zA-Z]*.in [a-zA-Z]*.opt; do
371 if test -f ../${tempdir}/src/$file; then
372 # test -f appears to succeed for a symlink
373 if test -L ../${tempdir}/src/$file; then
374 rm ../${tempdir}/src/$file
375 cp -p $file ../${tempdir}/src
376 chmod a-w ../${tempdir}/src/$file
378 else
379 rm ../${tempdir}/src/$file
380 cp -p $file ../${tempdir}/src
381 chmod a-w ../${tempdir}/src/$file
383 done
384 ln README ChangeLog ChangeLog.*[0-9] ../${tempdir}/src
385 ln makefile.nt vms-pp.trans ../${tempdir}/src
386 ln .gdbinit .dbxinit ../${tempdir}/src
387 cd ../${tempdir}/src
388 rm -f config.h paths.h Makefile Makefile.c
389 rm -f =* TAGS)
391 echo "Making links to \`src/bitmaps'"
392 (cd src/bitmaps
393 ln README *.xbm ../../${tempdir}/src/bitmaps)
395 echo "Making links to \`src/m'"
396 (cd src/m
397 # We call files for miscellaneous input (to linker etc) .inp.
398 ln README [a-zA-Z0-9]*.h *.inp ../../${tempdir}/src/m)
400 echo "Making links to \`src/s'"
401 (cd src/s
402 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/s)
404 echo "Making links to \`lib-src'"
405 (cd lib-src
406 ln [a-zA-Z]*.[chy] ../${tempdir}/lib-src
407 ln ChangeLog Makefile.in README testfile vcdiff ../${tempdir}/lib-src
408 ln rcs2log rcs-checkin makefile.nt ../${tempdir}/lib-src
409 ## If we ended up with a symlink, or if we did not get anything
410 ## due to a cross-device symlink, copy the file.
411 for file in [a-zA-Z]*.[chy]; do
412 if test -f ../${tempdir}/lib-src/$file; then
413 # test -f appears to succeed for a symlink
414 if test -L ../${tempdir}/lib-src/$file; then
415 rm ../${tempdir}/lib-src/$file
416 cp $file ../${tempdir}/lib-src
417 chmod a-w ../${tempdir}/lib-src/$file
419 else
420 rm ../${tempdir}/lib-src/$file
421 cp $file ../${tempdir}/lib-src
422 chmod a-w ../${tempdir}/lib-src/$file
424 done
425 cd ../${tempdir}/lib-src
426 rm -f Makefile.c
427 rm -f =* TAGS)
429 echo "Making links to \`nt'"
430 (cd nt
431 ln emacs.rc config.nt [a-z]*.in [a-z]*.c ../${tempdir}/nt
432 ln [a-z]*.bat [a-z]*.h makefile.def makefile.nt ../${tempdir}/nt
433 ln TODO ChangeLog INSTALL README ../${tempdir}/nt)
435 echo "Making links to \`nt/inc'"
436 (cd nt/inc
437 ln [a-z]*.h ../../${tempdir}/nt/inc)
439 echo "Making links to \`nt/inc/sys'"
440 (cd nt/inc/sys
441 ln [a-z]*.h ../../../${tempdir}/nt/inc/sys)
443 echo "Making links to \`nt/inc/arpa'"
444 (cd nt/inc/arpa
445 ln [a-z]*.h ../../../${tempdir}/nt/inc/arpa)
447 echo "Making links to \`nt/inc/netinet'"
448 (cd nt/inc/netinet
449 ln [a-z]*.h ../../../${tempdir}/nt/inc/netinet)
451 echo "Making links to \`nt/icons'"
452 (cd nt/icons
453 ln [a-z]*.ico ../../${tempdir}/nt/icons)
455 echo "Making links to \`msdos'"
456 (cd msdos
457 ln ChangeLog emacs.ico emacs.pif ../${tempdir}/msdos
458 ln is_exec.c sigaction.c mainmake mainmake.v2 sed*.inp ../${tempdir}/msdos
459 cd ../${tempdir}/msdos
460 rm -f =*)
462 echo "Making links to \`oldXMenu'"
463 (cd oldXMenu
464 ln *.c *.h *.in ../${tempdir}/oldXMenu
465 ln README Imakefile ChangeLog ../${tempdir}/oldXMenu
466 ln compile.com descrip.mms ../${tempdir}/oldXMenu)
468 echo "Making links to \`lwlib'"
469 (cd lwlib
470 ln *.c *.h *.in ../${tempdir}/lwlib
471 ln README Imakefile ChangeLog ../${tempdir}/lwlib
472 cd ../${tempdir}/lwlib
473 rm -f lwlib-Xol*)
475 echo "Making links to \`etc'"
476 ### Don't distribute = files, TAGS, DOC files, backups, autosaves, or
477 ### tex litter.
478 (cd etc
479 files=`ls -d * | grep -v CVS | grep -v RCS | grep -v 'Old' | grep -v '^e$'`
480 ln $files ../${tempdir}/etc
481 ## If we ended up with a symlink, or if we did not get anything
482 ## due to a cross-device symlink, copy the file.
483 for file in $files; do
484 if test -f ../${tempdir}/etc/$file; then
485 # test -f appears to succeed for a symlink
486 if test -L ../${tempdir}/etc/$file; then
487 rm ../${tempdir}/etc/$file
488 cp $file ../${tempdir}/etc
489 chmod a-w ../${tempdir}/etc/$file
491 else
492 rm ../${tempdir}/etc/$file
493 cp $file ../${tempdir}/etc
494 chmod a-w ../${tempdir}/etc/$file
496 done
497 cd ../${tempdir}/etc
498 rm -f fns*.el
499 rm -f DOC* *~ \#*\# *.dvi *.log *.orig *.rej *,v =* core
500 rm -f TAGS)
502 echo "Making links to \`etc/e'"
503 (cd etc/e
504 ln `ls -d * | grep -v CVS | grep -v RCS` ../../${tempdir}/etc/e
505 cd ../../${tempdir}/etc/e
506 rm -f *~ \#*\# *,v =* core)
508 echo "Making links to \`info'"
509 # Don't distribute backups or autosaves.
510 (cd info
511 ln `find . -type f -print | grep -v CVS | grep -v RCS` ../${tempdir}/info
512 #ln [a-zA-Z]* ../${tempdir}/info
513 cd ../${tempdir}/info
514 # Avoid an error when expanding the wildcards later.
515 ln emacs dummy~ ; ln emacs \#dummy\#
516 rm -f *~ \#*\# core)
518 echo "Making links to \`man'"
519 (cd man
520 ln *.texi *.aux *.cps *.fns *.kys *.vrs ../${tempdir}/man
521 test -f README && ln README ../${tempdir}/man
522 test -f Makefile.in && ln Makefile.in ../${tempdir}/man
523 ln ChangeLog ../${tempdir}/man
524 test -f split-man && ln split-man ../${tempdir}/man
525 test -f texinfo.tex && cp texinfo.tex ../${tempdir}/man
526 cd ../${tempdir}/man
527 rm -f \#*\# =* *~ core emacs-index* *.Z *.z xmail
528 rm -f emacs.?? termcap.?? gdb.?? *.log *.toc *.dvi *.oaux)
530 echo "Making links to \`vms'"
531 (cd vms
532 test -f README && ln README ../${tempdir}/vms
533 cd ../${tempdir}/vms
534 rm -f *~)
536 ### It would be nice if they could all be symlinks to etc's copy, but
537 ### you're not supposed to have any symlinks in distribution tar files.
538 echo "Making sure copying notices are all copies of \`etc/COPYING'"
539 rm -f ${tempdir}/etc/COPYING
540 cp etc/COPYING ${tempdir}/etc/COPYING
541 for subdir in lisp src lib-src info msdos; do
542 if [ -f ${tempdir}/${subdir}/COPYING ]; then
543 rm ${tempdir}/${subdir}/COPYING
545 cp etc/COPYING ${tempdir}/${subdir}
546 done
548 #### Make sure that there aren't any hard links between files in the
549 #### distribution; people with afs can't deal with that. Okay,
550 #### actually we just re-copy anything with a link count greater
551 #### than two. (Yes, strictly greater than 2 is correct; since we
552 #### created these files by linking them in from the original tree,
553 #### they'll have exactly two links normally.)
554 ####
555 #### Commented out since it's not strictly necessary; it should suffice
556 #### to just break the link on alloca.c.
557 #echo "Breaking intra-tree links."
558 #find ${tempdir} ! -type d -links +2 \
559 # -exec cp -p {} $$ \; -exec rm -f {} \; -exec mv $$ {} \;
560 rm -f $tempdir/lib-src/alloca.c
561 cp $tempdir/src/alloca.c $tempdir/lib-src/alloca.c
563 if [ "${newer}" ]; then
564 echo "Removing files older than $newer"
565 ## We remove .elc files unconditionally, on the theory that anyone picking
566 ## up an incremental distribution already has a running Emacs to byte-compile
567 ## them with.
568 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
571 if [ "${make_tar}" = yes ]; then
572 if [ "${default_gzip}" = "" ]; then
573 echo "Looking for gzip"
574 temppath=`echo $PATH | sed 's/^:/.:/
575 s/::/:.:/g
576 s/:$/:./
577 s/:/ /g'`
578 default_gzip=`(
579 for dir in ${temppath}; do
580 if [ -f ${dir}/gzip ]; then echo 'gzip --best'; exit 0; fi
581 done
582 echo compress
585 case "${default_gzip}" in
586 compress* ) gzip_extension=.Z ;;
587 * ) gzip_extension=.gz ;;
588 esac
589 echo "Creating tar files"
590 (cd ${tempparent} ; tar cvf - ${emacsname} ) \
591 | ${default_gzip} \
592 > ${emacsname}.tar${gzip_extension}
593 (cd ${tempparent}/${emacsname}-leim ; tar cvf - ${emacsname} ) \
594 | ${default_gzip} \
595 > leim-${version}${new_extension}.tar${gzip_extension}
598 if [ "${clean_up}" = yes ]; then
599 echo "Cleaning up the staging directory"
600 rm -rf ${tempparent}
601 else
602 (cd ${tempparent}; mv ${emacsname} ${emacsname}-leim ..)
603 rm -rf ${tempparent}
606 ### make-dist ends here