*** empty log message ***
[emacs.git] / make-dist
blob80758bce847452458f13f299c43d002eb510a8d6
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 ! 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"
216 (cd man; make -f Makefile.in srcdir=. info)
218 echo "Updating finder, custom and autoload data"
220 (cd lisp; make updates EMACS="$EMACS")
222 echo "Updating leim-list.el"
224 (cd leim; make leim-list.el EMACS="$EMACS")
226 echo "Recompiling Lisp files"
228 $EMACS -batch -f batch-byte-recompile-directory lisp leim
231 echo "Making lisp/MANIFEST"
233 (cd lisp;
234 files=`echo [!=]*.el | sed -e 's/ subdirs.el / /' -e 's/ default.el / /'`
235 for dir in [!=]*; do
236 if [ -d $dir ] && [ $dir != term ] && [ $dir != RCS ]; then
237 echo $dir
238 thisdir=`echo $dir/[!=]*.el | sed -e 's/ subdirs.el / /'`
239 files="$files $thisdir"
241 done
242 head -1 $files | grep '^;' | sed -e 's/;;; //' | sort > MANIFEST)
244 echo "Creating staging directory: \`${tempparent}'"
246 mkdir ${tempparent}
247 tempdir="${tempparent}/${emacsname}"
249 ### This trap ensures that the staging directory will be cleaned up even
250 ### when the script is interrupted in mid-career.
251 if [ "${clean_up}" = yes ]; then
252 trap "echo 'Interrupted...cleaning up the staging directory'; rm -rf ${tempparent}; exit 1" 1 2 15
255 echo "Creating top directory: \`${tempdir}'"
256 mkdir ${tempdir}
258 ### We copy in the top-level files before creating the subdirectories in
259 ### hopes that this will make the top-level files appear first in the
260 ### tar file; this means that people can start reading the INSTALL and
261 ### README while the rest of the tar file is still unpacking. Whoopee.
262 echo "Making links to top-level files"
263 ln GETTING.GNU.SOFTWARE INSTALL README BUGS move-if-change ${tempdir}
264 ln ChangeLog Makefile.in configure configure.in ${tempdir}
265 ln config.bat make-dist update-subdirs vpath.sed ${tempdir}
266 ### Copy these files; they're cross-filesystem symlinks.
267 cp mkinstalldirs ${tempdir}
268 cp config.sub ${tempdir}
269 cp config.guess ${tempdir}
270 cp install.sh ${tempdir}
272 echo "Updating version number in README"
273 (cd ${tempdir}
274 awk \
275 '$1 " " $2 " " $3 " " $4 " " $5 == "This directory tree holds version" { $6 = version; print $0 }
276 $1 " " $2 " " $3 " " $4 " " $5 != "This directory tree holds version"' \
277 version=${version} README > tmp.README
278 mv -f tmp.README README)
281 echo "Creating subdirectories"
282 for subdir in lisp site-lisp leim real-leim real-leim/CXTERM-DIC \
283 real-leim/SKK-DIC real-leim/skk real-leim/quail \
284 src src/m src/s src/bitmaps lib-src oldXMenu lwlib \
285 nt nt/inc nt/inc/sys nt/inc/arpa nt/inc/netinet nt/icons \
286 etc etc/e lock info man msdos vms; do
287 mkdir ${tempdir}/${subdir}
288 done
290 echo "Initializing \`leim' subdirectory"
291 cp leim-Makefile.in ${tempdir}/leim/Makefile.in
293 echo "Making links to \`lisp' and its subdirectories"
294 ### Don't distribute TAGS, =*.el files, site-init.el, site-load.el, or default.el.
295 (cd lisp
296 ln [a-zA-Z]*.el ../${tempdir}/lisp
297 ln [a-zA-Z]*.elc ../${tempdir}/lisp
298 ln [a-zA-Z]*.dat ../${tempdir}/lisp
299 ## simula.el doesn't keep abbreviations in simula.defns any more.
300 ## ln [a-zA-Z]*.defns ../${tempdir}/lisp
301 ln ChangeLog Makefile makefile.nt ChangeLog.? 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 | */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.in 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 cd ../${tempdir}/real-leim
348 rm -f TAGS =* */=*)
350 ### Move the real-leim directory outside of Emacs proper.
351 (cd ${tempparent}
352 mkdir ${emacsname}-leim
353 mkdir ${emacsname}-leim/${emacsname}
354 mv ${emacsname}/real-leim ${emacsname}-leim/${emacsname}/leim)
356 echo "Making links to \`src'"
357 ### Don't distribute =*.[ch] files, or the configured versions of
358 ### config.in, paths.in, or Makefile.in, or TAGS.
359 (cd src
360 echo " (It is ok if ln fails in some cases.)"
361 ln [a-zA-Z]*.c ../${tempdir}/src
362 ln [a-zA-Z]*.h ../${tempdir}/src
363 ln [a-zA-Z]*.s ../${tempdir}/src
364 ln [a-zA-Z]*.in ../${tempdir}/src
365 ln [a-zA-Z]*.opt ../${tempdir}/src
366 ## If we ended up with a symlink, or if we did not get anything
367 ## due to a cross-device symlink, copy the file.
368 for file in [a-zA-Z]*.[hcs] [a-zA-Z]*.in [a-zA-Z]*.opt; do
369 if test -f ../${tempdir}/src/$file; then
370 # test -f appears to succeed for a symlink
371 if test -L ../${tempdir}/src/$file; then
372 rm ../${tempdir}/src/$file
373 cp -p $file ../${tempdir}/src
374 chmod a-w ../${tempdir}/src/$file
376 else
377 rm ../${tempdir}/src/$file
378 cp -p $file ../${tempdir}/src
379 chmod a-w ../${tempdir}/src/$file
381 done
382 ln README ChangeLog ChangeLog.*[0-9] ../${tempdir}/src
383 ln makefile.nt vms-pp.trans ../${tempdir}/src
384 ln .gdbinit .dbxinit ../${tempdir}/src
385 cd ../${tempdir}/src
386 rm -f config.h paths.h Makefile Makefile.c
387 rm -f =* TAGS)
389 echo "Making links to \`src/bitmaps'"
390 (cd src/bitmaps
391 ln README *.xbm ../../${tempdir}/src/bitmaps)
393 echo "Making links to \`src/m'"
394 (cd src/m
395 # We call files for miscellaneous input (to linker etc) .inp.
396 ln README [a-zA-Z0-9]*.h *.inp ../../${tempdir}/src/m)
398 echo "Making links to \`src/s'"
399 (cd src/s
400 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/s)
402 echo "Making links to \`lib-src'"
403 (cd lib-src
404 ln [a-zA-Z]*.[chy] ../${tempdir}/lib-src
405 ln ChangeLog Makefile.in README testfile vcdiff ../${tempdir}/lib-src
406 ln emacs.csh rcs2log rcs-checkin makefile.nt ../${tempdir}/lib-src
407 ## If we ended up with a symlink, or if we did not get anything
408 ## due to a cross-device symlink, copy the file.
409 for file in [a-zA-Z]*.[chy]; do
410 if test -f ../${tempdir}/lib-src/$file; then
411 # test -f appears to succeed for a symlink
412 if test -L ../${tempdir}/lib-src/$file; then
413 rm ../${tempdir}/lib-src/$file
414 cp $file ../${tempdir}/lib-src
415 chmod a-w ../${tempdir}/lib-src/$file
417 else
418 rm ../${tempdir}/lib-src/$file
419 cp $file ../${tempdir}/lib-src
420 chmod a-w ../${tempdir}/lib-src/$file
422 done
423 cd ../${tempdir}/lib-src
424 rm -f Makefile.c
425 rm -f =* TAGS)
427 echo "Making links to \`nt'"
428 (cd nt
429 ln emacs.ico emacs.rc config.nt [a-z]*.in [a-z]*.c ../${tempdir}/nt
430 ln [a-z]*.bat [a-z]*.h makefile.def makefile.nt ../${tempdir}/nt
431 ln TODO ChangeLog INSTALL README ../${tempdir}/nt)
433 echo "Making links to \`nt/inc'"
434 (cd nt/inc
435 ln [a-z]*.h ../../${tempdir}/nt/inc)
437 echo "Making links to \`nt/inc/sys'"
438 (cd nt/inc/sys
439 ln [a-z]*.h ../../../${tempdir}/nt/inc/sys)
441 echo "Making links to \`nt/inc/arpa'"
442 (cd nt/inc/arpa
443 ln [a-z]*.h ../../../${tempdir}/nt/inc/arpa)
445 echo "Making links to \`nt/inc/netinet'"
446 (cd nt/inc/netinet
447 ln [a-z]*.h ../../../${tempdir}/nt/inc/netinet)
449 echo "Making links to \`nt/icons'"
450 (cd nt/icons
451 ln [a-z]*.ico ../../${tempdir}/nt/icons)
453 echo "Making links to \`msdos'"
454 (cd msdos
455 ln ChangeLog emacs.ico emacs.pif ../${tempdir}/msdos
456 ln is_exec.c sigaction.c mainmake mainmake.v2 sed*.inp ../${tempdir}/msdos
457 cd ../${tempdir}/msdos
458 rm -f =*)
460 echo "Making links to \`oldXMenu'"
461 (cd oldXMenu
462 ln *.c *.h *.in ../${tempdir}/oldXMenu
463 ln README Imakefile ChangeLog ../${tempdir}/oldXMenu
464 ln compile.com descrip.mms ../${tempdir}/oldXMenu)
466 echo "Making links to \`lwlib'"
467 (cd lwlib
468 ln *.c *.h *.in ../${tempdir}/lwlib
469 ln README Imakefile ChangeLog ../${tempdir}/lwlib
470 cd ../${tempdir}/lwlib
471 rm -f lwlib-Xol*)
473 echo "Making links to \`etc'"
474 ### Don't distribute = files, TAGS, DOC files, backups, autosaves, or
475 ### tex litter.
476 (cd etc
477 files=`ls -d * | grep -v 'RCS' | grep -v 'Old' | grep -v '^e$'`
478 ln $files ../${tempdir}/etc
479 ## If we ended up with a symlink, or if we did not get anything
480 ## due to a cross-device symlink, copy the file.
481 for file in $files; do
482 if test -f ../${tempdir}/etc/$file; then
483 # test -f appears to succeed for a symlink
484 if test -L ../${tempdir}/etc/$file; then
485 rm ../${tempdir}/etc/$file
486 cp $file ../${tempdir}/etc
487 chmod a-w ../${tempdir}/etc/$file
489 else
490 rm ../${tempdir}/etc/$file
491 cp $file ../${tempdir}/etc
492 chmod a-w ../${tempdir}/etc/$file
494 done
495 cd ../${tempdir}/etc
496 rm -f fns*.el
497 rm -f DOC* *~ \#*\# *.dvi *.log *.orig *.rej *,v =* core
498 rm -f TAGS)
500 echo "Making links to \`etc/e'"
501 (cd etc/e
502 ln `ls -d * | grep -v 'RCS'` ../../${tempdir}/etc/e
503 cd ../../${tempdir}/etc/e
504 rm -f *~ \#*\# *,v =* core)
506 echo "Making links to \`info'"
507 # Don't distribute backups or autosaves.
508 (cd info
509 ln [a-zA-Z]* ../${tempdir}/info
510 cd ../${tempdir}/info
511 # Avoid an error when expanding the wildcards later.
512 ln emacs dummy~ ; ln emacs \#dummy\#
513 rm -f *~ \#*\# core)
515 echo "Making links to \`man'"
516 (cd man
517 ln *.texi *.aux *.cps *.fns *.kys *.vrs ../${tempdir}/man
518 test -f README && ln README ../${tempdir}/man
519 test -f Makefile.in && ln Makefile.in ../${tempdir}/man
520 ln ChangeLog split-man ../${tempdir}/man
521 cp texinfo.tex ../${tempdir}/man
522 cd ../${tempdir}/man
523 rm -f \#*\# =* *~ core emacs-index* *.Z *.z xmail
524 rm -f emacs.?? termcap.?? gdb.?? *.log *.toc *.dvi *.oaux)
526 echo "Making links to \`vms'"
527 (cd vms
528 ln [0-9a-zA-Z]* ../${tempdir}/vms
529 cd ../${tempdir}/vms
530 rm -f *~)
532 ### It would be nice if they could all be symlinks to etc's copy, but
533 ### you're not supposed to have any symlinks in distribution tar files.
534 echo "Making sure copying notices are all copies of \`etc/COPYING'"
535 rm -f ${tempdir}/etc/COPYING
536 cp etc/COPYING ${tempdir}/etc/COPYING
537 for subdir in lisp src lib-src info msdos; do
538 if [ -f ${tempdir}/${subdir}/COPYING ]; then
539 rm ${tempdir}/${subdir}/COPYING
541 cp etc/COPYING ${tempdir}/${subdir}
542 done
544 #### Make sure that there aren't any hard links between files in the
545 #### distribution; people with afs can't deal with that. Okay,
546 #### actually we just re-copy anything with a link count greater
547 #### than two. (Yes, strictly greater than 2 is correct; since we
548 #### created these files by linking them in from the original tree,
549 #### they'll have exactly two links normally.)
550 ####
551 #### Commented out since it's not strictly necessary; it should suffice
552 #### to just break the link on alloca.c.
553 #echo "Breaking intra-tree links."
554 #find ${tempdir} ! -type d -links +2 \
555 # -exec cp -p {} $$ \; -exec rm -f {} \; -exec mv $$ {} \;
556 rm -f $tempdir/lib-src/alloca.c
557 cp $tempdir/src/alloca.c $tempdir/lib-src/alloca.c
559 if [ "${newer}" ]; then
560 echo "Removing files older than $newer"
561 ## We remove .elc files unconditionally, on the theory that anyone picking
562 ## up an incremental distribution already has a running Emacs to byte-compile
563 ## them with.
564 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
567 if [ "${make_tar}" = yes ]; then
568 if [ "${default_gzip}" = "" ]; then
569 echo "Looking for gzip"
570 temppath=`echo $PATH | sed 's/^:/.:/
571 s/::/:.:/g
572 s/:$/:./
573 s/:/ /g'`
574 default_gzip=`(
575 for dir in ${temppath}; do
576 if [ -f ${dir}/gzip ]; then echo 'gzip --best'; exit 0; fi
577 done
578 echo compress
581 case "${default_gzip}" in
582 compress* ) gzip_extension=.Z ;;
583 * ) gzip_extension=.gz ;;
584 esac
585 echo "Creating tar files"
586 (cd ${tempparent} ; tar cvf - ${emacsname} ) \
587 | ${default_gzip} \
588 > ${emacsname}.tar${gzip_extension}
589 (cd ${tempparent}/${emacsname}-leim ; tar cvf - ${emacsname} ) \
590 | ${default_gzip} \
591 > ${emacsname}-leim.tar${gzip_extension}
594 if [ "${clean_up}" = yes ]; then
595 echo "Cleaning up the staging directory"
596 rm -rf ${tempparent}
597 else
598 (cd ${tempparent}; mv ${emacsname} ${emacsname}-leim ..)
599 rm -rf ${tempparent}
602 ### make-dist ends here