(Fmake_temp_name): forgot the \n\ in the docstring
[emacs.git] / make-dist
blob3c57500e300cadc5b617c7913d932803f22cd11d
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 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]*.el 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]*.elc 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]*.el [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]*.elc [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 ! grep -q "dontcompilefiles:.* $file1\($\| \)" lisp/Makefile; then
179 case $file in
180 site-init.el | site-load.el | site-start.el | default.el)
182 term/*)
185 bogosities="$file $bogosities"
187 esac
189 done
190 if [ x"${bogosities}" != x"" ]; then
191 echo "The following .el files have no corresponding .elc files:"
192 echo "${bogosities}"
194 rm -f /tmp/el /tmp/elc
196 ### Check for .el files that would overflow the 14-char limit if compiled.
197 long=`find lisp leim -name '[a-zA-Z0-9]??????????*.el' -print`
198 if [ "$long" != "" ]; then
199 echo "The following .el file names are too long:"
200 echo "$long"
204 ### Make sure configure is newer than configure.in.
205 if [ "x`ls -t configure configure.in | head -1`" != "xconfigure" ]; then
206 echo "\`./configure.in' is newer than \`./configure'" >&2
207 echo "Running autoconf" >&2
208 autoconf || { x=$?; echo Autoconf FAILED! >&2; exit $x; }
211 if [ $update = yes ];
212 then
213 echo "Updating Info files"
215 (cd man; make -f Makefile.in srcdir=. info)
217 echo "Updating finder, custom and autoload data"
219 (cd lisp; make updates EMACS="$EMACS")
221 echo "Updating leim-list.el"
223 (cd leim; make leim-list.el EMACS="$EMACS")
225 echo "Recompiling Lisp files"
227 $EMACS -batch -f batch-byte-recompile-directory lisp leim
230 echo "Making lisp/MANIFEST"
232 (cd lisp;
233 files=`echo [!=]*.el | sed -e 's/ subdirs.el / /' -e 's/ default.el / /'`
234 for dir in [!=]*; do
235 if [ -d $dir ] && [ $dir != term ] && [ $dir != RCS ]; 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/Makefile.in
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.? README ../${tempdir}/lisp
301 (cd ../${tempdir}/lisp
302 rm -f TAGS =*
303 rm -f site-init site-init.el site-init.elc
304 rm -f site-load site-load.el site-load.elc
305 rm -f site-start site-start.el site-start.elc
306 rm -f default default.el default.elc
309 ## Find all subdirs of lisp dir
310 for file in `find . -type d -print`; do
311 case $file in
312 . | .. | */Old | */RCS | */=*)
315 if [ -d $file ]; then
316 subdirs="$file $subdirs"
319 esac
320 done
322 for file in $subdirs; do
323 echo " lisp/$file"
324 mkdir ../${tempdir}/lisp/$file
325 ln $file/[a-zA-Z]*.el ../${tempdir}/lisp/$file
326 ln $file/[a-zA-Z]*.elc ../${tempdir}/lisp/$file
327 if [ -f $file/README ]; then
328 ln $file/README ../${tempdir}/lisp/$file
330 if [ -f $file/ChangeLog ]; then
331 ln $file/ChangeLog ../${tempdir}/lisp/$file
333 done )
335 echo "Making links to \`leim' and its subdirectories for the LEIM distribution"
336 ### Don't distribute TAGS, or =*.el files.
337 (cd leim
338 ln Makefile.in makefile.nt ../${tempdir}/real-leim
339 ln ChangeLog README ../${tempdir}/real-leim
341 ln CXTERM-DIC/*.tit ../${tempdir}/real-leim/CXTERM-DIC
342 ln SKK-DIC/README SKK-DIC/SKK-JISYO.L ../${tempdir}/real-leim/SKK-DIC
343 ln skk/*.el skk/*.elc ../${tempdir}/real-leim/skk
344 ln quail/*.el quail/*.elc ../${tempdir}/real-leim/quail
346 cd ../${tempdir}/real-leim
347 rm -f TAGS =* */=*)
349 ### Move the real-leim directory outside of Emacs proper.
350 (cd ${tempparent}
351 mkdir ${emacsname}-leim
352 mkdir ${emacsname}-leim/${emacsname}
353 mv ${emacsname}/real-leim ${emacsname}-leim/${emacsname}/leim)
355 echo "Making links to \`src'"
356 ### Don't distribute =*.[ch] files, or the configured versions of
357 ### config.in, paths.in, or Makefile.in, or TAGS.
358 (cd src
359 echo " (It is ok if ln fails in some cases.)"
360 ln [a-zA-Z]*.c ../${tempdir}/src
361 ln [a-zA-Z]*.h ../${tempdir}/src
362 ln [a-zA-Z]*.s ../${tempdir}/src
363 ln [a-zA-Z]*.in ../${tempdir}/src
364 ln [a-zA-Z]*.opt ../${tempdir}/src
365 ## If we ended up with a symlink, or if we did not get anything
366 ## due to a cross-device symlink, copy the file.
367 for file in [a-zA-Z]*.[hcs] [a-zA-Z]*.in [a-zA-Z]*.opt; do
368 if test -f ../${tempdir}/src/$file; then
369 # test -f appears to succeed for a symlink
370 if test -L ../${tempdir}/src/$file; then
371 rm ../${tempdir}/src/$file
372 cp -p $file ../${tempdir}/src
373 chmod a-w ../${tempdir}/src/$file
375 else
376 rm ../${tempdir}/src/$file
377 cp -p $file ../${tempdir}/src
378 chmod a-w ../${tempdir}/src/$file
380 done
381 ln README ChangeLog ChangeLog.*[0-9] ../${tempdir}/src
382 ln makefile.nt vms-pp.trans ../${tempdir}/src
383 ln .gdbinit .dbxinit ../${tempdir}/src
384 cd ../${tempdir}/src
385 rm -f config.h paths.h Makefile Makefile.c
386 rm -f =* TAGS)
388 echo "Making links to \`src/bitmaps'"
389 (cd src/bitmaps
390 ln README *.xbm ../../${tempdir}/src/bitmaps)
392 echo "Making links to \`src/m'"
393 (cd src/m
394 # We call files for miscellaneous input (to linker etc) .inp.
395 ln README [a-zA-Z0-9]*.h *.inp ../../${tempdir}/src/m)
397 echo "Making links to \`src/s'"
398 (cd src/s
399 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/s)
401 echo "Making links to \`lib-src'"
402 (cd lib-src
403 ln [a-zA-Z]*.[chy] ../${tempdir}/lib-src
404 ln ChangeLog Makefile.in README testfile vcdiff ../${tempdir}/lib-src
405 ln emacs.csh rcs2log rcs-checkin makefile.nt ../${tempdir}/lib-src
406 ## If we ended up with a symlink, or if we did not get anything
407 ## due to a cross-device symlink, copy the file.
408 for file in [a-zA-Z]*.[chy]; do
409 if test -f ../${tempdir}/lib-src/$file; then
410 # test -f appears to succeed for a symlink
411 if test -L ../${tempdir}/lib-src/$file; then
412 rm ../${tempdir}/lib-src/$file
413 cp $file ../${tempdir}/lib-src
414 chmod a-w ../${tempdir}/lib-src/$file
416 else
417 rm ../${tempdir}/lib-src/$file
418 cp $file ../${tempdir}/lib-src
419 chmod a-w ../${tempdir}/lib-src/$file
421 done
422 cd ../${tempdir}/lib-src
423 rm -f Makefile.c
424 rm -f =* TAGS)
426 echo "Making links to \`nt'"
427 (cd nt
428 ln emacs.ico emacs.rc config.nt [a-z]*.in [a-z]*.c ../${tempdir}/nt
429 ln [a-z]*.bat [a-z]*.h makefile.def makefile.nt ../${tempdir}/nt
430 ln TODO ChangeLog INSTALL README ../${tempdir}/nt)
432 echo "Making links to \`nt/inc'"
433 (cd nt/inc
434 ln [a-z]*.h ../../${tempdir}/nt/inc)
436 echo "Making links to \`nt/inc/sys'"
437 (cd nt/inc/sys
438 ln [a-z]*.h ../../../${tempdir}/nt/inc/sys)
440 echo "Making links to \`nt/inc/arpa'"
441 (cd nt/inc/arpa
442 ln [a-z]*.h ../../../${tempdir}/nt/inc/arpa)
444 echo "Making links to \`nt/inc/netinet'"
445 (cd nt/inc/netinet
446 ln [a-z]*.h ../../../${tempdir}/nt/inc/netinet)
448 echo "Making links to \`nt/icons'"
449 (cd nt/icons
450 ln [a-z]*.ico ../../${tempdir}/nt/icons)
452 echo "Making links to \`msdos'"
453 (cd msdos
454 ln ChangeLog emacs.ico emacs.pif ../${tempdir}/msdos
455 ln is_exec.c sigaction.c mainmake mainmake.v2 sed*.inp ../${tempdir}/msdos
456 cd ../${tempdir}/msdos
457 rm -f =*)
459 echo "Making links to \`oldXMenu'"
460 (cd oldXMenu
461 ln *.c *.h *.in ../${tempdir}/oldXMenu
462 ln README Imakefile ChangeLog ../${tempdir}/oldXMenu
463 ln compile.com descrip.mms ../${tempdir}/oldXMenu)
465 echo "Making links to \`lwlib'"
466 (cd lwlib
467 ln *.c *.h *.in ../${tempdir}/lwlib
468 ln README Imakefile ChangeLog ../${tempdir}/lwlib
469 cd ../${tempdir}/lwlib
470 rm -f lwlib-Xol*)
472 echo "Making links to \`etc'"
473 ### Don't distribute = files, TAGS, DOC files, backups, autosaves, or
474 ### tex litter.
475 (cd etc
476 files=`ls -d * | grep -v 'RCS' | grep -v 'Old' | grep -v '^e$'`
477 ln $files ../${tempdir}/etc
478 ## If we ended up with a symlink, or if we did not get anything
479 ## due to a cross-device symlink, copy the file.
480 for file in $files; do
481 if test -f ../${tempdir}/etc/$file; then
482 # test -f appears to succeed for a symlink
483 if test -L ../${tempdir}/etc/$file; then
484 rm ../${tempdir}/etc/$file
485 cp $file ../${tempdir}/etc
486 chmod a-w ../${tempdir}/etc/$file
488 else
489 rm ../${tempdir}/etc/$file
490 cp $file ../${tempdir}/etc
491 chmod a-w ../${tempdir}/etc/$file
493 done
494 cd ../${tempdir}/etc
495 rm -f fns*.el
496 rm -f DOC* *~ \#*\# *.dvi *.log *.orig *.rej *,v =* core
497 rm -f TAGS)
499 echo "Making links to \`etc/e'"
500 (cd etc/e
501 ln `ls -d * | grep -v 'RCS'` ../../${tempdir}/etc/e
502 cd ../../${tempdir}/etc/e
503 rm -f *~ \#*\# *,v =* core)
505 echo "Making links to \`info'"
506 # Don't distribute backups or autosaves.
507 (cd info
508 ln [a-zA-Z]* ../${tempdir}/info
509 cd ../${tempdir}/info
510 # Avoid an error when expanding the wildcards later.
511 ln emacs dummy~ ; ln emacs \#dummy\#
512 rm -f *~ \#*\# core)
514 echo "Making links to \`man'"
515 (cd man
516 ln *.texi *.aux *.cps *.fns *.kys *.vrs ../${tempdir}/man
517 test -f README && ln README ../${tempdir}/man
518 test -f Makefile.in && ln Makefile.in ../${tempdir}/man
519 ln ChangeLog split-man ../${tempdir}/man
520 cp texinfo.tex ../${tempdir}/man
521 cd ../${tempdir}/man
522 rm -f \#*\# =* *~ core emacs-index* *.Z *.z xmail
523 rm -f emacs.?? termcap.?? gdb.?? *.log *.toc *.dvi *.oaux)
525 echo "Making links to \`vms'"
526 (cd vms
527 ln [0-9a-zA-Z]* ../${tempdir}/vms
528 cd ../${tempdir}/vms
529 rm -f *~)
531 ### It would be nice if they could all be symlinks to etc's copy, but
532 ### you're not supposed to have any symlinks in distribution tar files.
533 echo "Making sure copying notices are all copies of \`etc/COPYING'"
534 rm -f ${tempdir}/etc/COPYING
535 cp etc/COPYING ${tempdir}/etc/COPYING
536 for subdir in lisp src lib-src info msdos; do
537 if [ -f ${tempdir}/${subdir}/COPYING ]; then
538 rm ${tempdir}/${subdir}/COPYING
540 cp etc/COPYING ${tempdir}/${subdir}
541 done
543 #### Make sure that there aren't any hard links between files in the
544 #### distribution; people with afs can't deal with that. Okay,
545 #### actually we just re-copy anything with a link count greater
546 #### than two. (Yes, strictly greater than 2 is correct; since we
547 #### created these files by linking them in from the original tree,
548 #### they'll have exactly two links normally.)
549 ####
550 #### Commented out since it's not strictly necessary; it should suffice
551 #### to just break the link on alloca.c.
552 #echo "Breaking intra-tree links."
553 #find ${tempdir} ! -type d -links +2 \
554 # -exec cp -p {} $$ \; -exec rm -f {} \; -exec mv $$ {} \;
555 rm -f $tempdir/lib-src/alloca.c
556 cp $tempdir/src/alloca.c $tempdir/lib-src/alloca.c
558 if [ "${newer}" ]; then
559 echo "Removing files older than $newer"
560 ## We remove .elc files unconditionally, on the theory that anyone picking
561 ## up an incremental distribution already has a running Emacs to byte-compile
562 ## them with.
563 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
566 if [ "${make_tar}" = yes ]; then
567 if [ "${default_gzip}" = "" ]; then
568 echo "Looking for gzip"
569 temppath=`echo $PATH | sed 's/^:/.:/
570 s/::/:.:/g
571 s/:$/:./
572 s/:/ /g'`
573 default_gzip=`(
574 for dir in ${temppath}; do
575 if [ -f ${dir}/gzip ]; then echo 'gzip --best'; exit 0; fi
576 done
577 echo compress
580 case "${default_gzip}" in
581 compress* ) gzip_extension=.Z ;;
582 * ) gzip_extension=.gz ;;
583 esac
584 echo "Creating tar files"
585 (cd ${tempparent} ; tar cvf - ${emacsname} ) \
586 | ${default_gzip} \
587 > ${emacsname}.tar${gzip_extension}
588 (cd ${tempparent}/${emacsname}-leim ; tar cvf - ${emacsname} ) \
589 | ${default_gzip} \
590 > ${emacsname}-leim.tar${gzip_extension}
593 if [ "${clean_up}" = yes ]; then
594 echo "Cleaning up the staging directory"
595 rm -rf ${tempparent}
596 else
597 (cd ${tempparent}; mv ${emacsname} ${emacsname}-leim ..)
598 rm -rf ${tempparent}
601 ### make-dist ends here