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