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