Check for long file names.
[emacs.git] / make-dist
blob0a516bf173245f615d9dfdcb9cded582acc384e0
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 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
25 # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
27 progname="$0"
29 ### Exit if a command fails.
30 ### set -e
32 ### Print out each line we read, for debugging's sake.
33 ### set -v
35 clean_up=no
36 make_tar=no
37 newer=""
39 while [ $# -gt 0 ]; do
40 case "$1" in
41 ## This option tells make-dist to delete the staging directory
42 ## when done. It is useless to use this unless you make a tar file.
43 "--clean-up" )
44 clean_up=yes
46 ## This option tells make-dist to make a tar file.
47 "--tar" )
48 make_tar=yes
50 ## This option tells make-dist to make the distribution normally, then
51 ## remove all files older than the given timestamp file. This is useful
52 ## for creating incremental or patch distributions.
53 "--newer")
54 newer="$2"
55 new_extension=".new"
56 shift
58 ## This option tells make-dist to use `compress' instead of gzip.
59 ## Normally, make-dist uses gzip whenever it is present.
60 "--compress")
61 default_gzip="compress"
63 * )
64 echo "${progname}: Unrecognized argument: $1" >&2
65 exit 1
67 esac
68 shift
69 done
71 ### Make sure we're running in the right place.
72 if [ ! -d src -o ! -f src/lisp.h -o ! -d lisp -o ! -f lisp/version.el ]; then
73 echo "${progname}: Can't find \`src/lisp.h' and \`lisp/version.el'." >&2
74 echo "${progname} must be run in the top directory of the Emacs" >&2
75 echo "distribution tree. cd to that directory and try again." >&2
76 exit 1
79 ### Find out which version of Emacs this is.
80 shortversion=`grep 'defconst[ ]*emacs-version' lisp/version.el \
81 | sed -e 's/^.*"\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/'`
82 version=`grep 'defconst[ ]*emacs-version' lisp/version.el \
83 | sed -e 's/^[^"]*"\([^"]*\)".*$/\1/'`
84 if [ ! "${version}" ]; then
85 echo "${progname}: can't find current Emacs version in \`./lisp/version.el'" >&2
86 exit 1
89 echo Version numbers are $version and $shortversion
91 if grep -s "GNU Emacs version ${shortversion}" ./man/emacs.texi > /dev/null; then
92 true
93 else
94 echo "You must update the version number in \`./man/emacs.texi'"
95 sleep 5
98 ### Make sure we don't already have a directory emacs-${version}.
100 emacsname="emacs-${version}${new_extension}"
102 if [ -d ${emacsname} ]
103 then
104 echo Directory "${emacsname}" already exists >&2
105 exit 1
108 ### Make sure the subdirectory is available.
109 tempparent="make-dist.tmp.$$"
110 if [ -d ${tempparent} ]; then
111 echo "${progname}: staging directory \`${tempparent}' already exists.
112 Perhaps a previous invocation of \`${progname}' failed to clean up after
113 itself. Check that directories whose names are of the form
114 \`make-dist.tmp.NNNNN' don't contain any important information, remove
115 them, and try again." >&2
116 exit 1
119 ### Check for .elc files with no corresponding .el file.
120 ls -1 lisp/*.el | sed 's/\.el$/.elc/' > /tmp/el
121 ls -1 lisp/*.elc > /tmp/elc
122 bogosities="`comm -13 /tmp/el /tmp/elc`"
123 if [ "${bogosities}" != "" ]; then
124 echo "The following .elc files have no corresponding .el files:"
125 echo "${bogosities}"
127 rm -f /tmp/el /tmp/elc
129 ### Check for .el files that would overflow the 14-char limit if compiled.
130 long=`find lisp -name '???????????*.el' -print`
131 if [ "$long" != "" ]; then
132 echo "The following .el file names are too long:"
133 echo "$long"
136 ### Make sure configure is newer than configure.in.
137 if [ "x`ls -t configure configure.in | head -1`" != "xconfigure" ]; then
138 echo "\`./configure.in' is newer than \`./configure'" >&2
139 echo "Running autoconf" >&2
140 autoconf || { x=$?; echo Autoconf FAILED! >&2; exit $x; }
143 ### Update getdate.c.
144 (cd lib-src; make -f Makefile getdate.c YACC="bison -y")
146 echo "Updating Info files"
148 (cd man; make info)
150 echo "Updating finder-inf.el"
152 (cd lisp; ../src/emacs -batch -l finder -f finder-compile-keywords-make-dist)
154 echo "Recompiling Lisp files"
156 src/emacs -batch -f batch-byte-recompile-directory lisp
158 echo "Updating autoloads"
160 src/emacs -batch -f batch-update-autoloads lisp
162 echo "Making lisp/MANIFEST"
164 (cd lisp; head -1 [!=]*.el | grep '^;' | sed -e 's/;;; //' > MANIFEST)
166 echo "Creating staging directory: \`${tempparent}'"
168 mkdir ${tempparent}
169 tempdir="${tempparent}/${emacsname}"
171 ### This trap ensures that the staging directory will be cleaned up even
172 ### when the script is interrupted in mid-career.
173 if [ "${clean_up}" = yes ]; then
174 trap "echo 'Interrupted...cleaning up the staging directory'; rm -rf ${tempparent}; exit 1" 1 2 15
177 echo "Creating top directory: \`${tempdir}'"
178 mkdir ${tempdir}
180 ### We copy in the top-level files before creating the subdirectories in
181 ### hopes that this will make the top-level files appear first in the
182 ### tar file; this means that people can start reading the INSTALL and
183 ### README while the rest of the tar file is still unpacking. Whoopee.
184 echo "Making links to top-level files"
185 ln GETTING.GNU.SOFTWARE INSTALL PROBLEMS README BUGS move-if-change ${tempdir}
186 ln ChangeLog Makefile.in configure configure.in ${tempdir}
187 ln config.bat make-dist update-subdirs vpath.sed ${tempdir}
188 ### Copy these files; they're cross-filesystem symlinks.
189 cp mkinstalldirs ${tempdir}
190 cp config.sub ${tempdir}
191 cp config.guess ${tempdir}
192 cp install.sh ${tempdir}
194 echo "Updating version number in README"
195 (cd ${tempdir}
196 awk \
197 '$1 " " $2 " " $3 " " $4 " " $5 == "This directory tree holds version" { $6 = version; print $0 }
198 $1 " " $2 " " $3 " " $4 " " $5 != "This directory tree holds version"' \
199 version=${version} README > tmp.README
200 mv tmp.README README)
203 echo "Creating subdirectories"
204 for subdir in lisp lisp/term site-lisp \
205 src src/m src/s src/bitmaps lib-src oldXMenu lwlib \
206 nt nt/inc nt/inc/sys nt/inc/arpa nt/inc/netinet \
207 etc etc/e lock cpp info man msdos vms; do
208 mkdir ${tempdir}/${subdir}
209 done
211 echo "Making links to \`lisp'"
212 ### Don't distribute TAGS, =*.el files, site-init.el, site-load.el, or default.el.
213 (cd lisp
214 ln [a-zA-Z]*.el ../${tempdir}/lisp
215 ln [a-zA-Z]*.elc ../${tempdir}/lisp
216 ln [a-zA-Z]*.dat ../${tempdir}/lisp
217 ## simula.el doesn't keep abbreviations in simula.defns any more.
218 ## ln [a-zA-Z]*.defns ../${tempdir}/lisp
219 ln ChangeLog Makefile makefile.nt ChangeLog.? README ../${tempdir}/lisp
220 cd ../${tempdir}/lisp
221 rm -f TAGS =*
222 rm -f subdirs.el
223 rm -f site-init site-init.el site-init.elc
224 rm -f site-load site-load.el site-load.elc
225 rm -f site-start site-start.el site-start.elc
226 rm -f default default.el default.elc)
228 #echo "Making links to \`lisp/calc-2.02'"
229 #### Don't distribute =*.el files, TAGS or backups.
230 #(cd lisp/calc-2.02
231 # ln [a-zA-Z]*.el ../../${tempdir}/lisp/calc-2.02
232 # ln [a-zA-Z]*.elc ../../${tempdir}/lisp/calc-2.02
233 # ln calc.info* calc.texinfo calc-refcard.* ../../${tempdir}/lisp/calc-2.02
234 # ln INSTALL Makefile README README.prev ../../${tempdir}/lisp/calc-2.02
235 # cd ../../${tempdir}/lisp/calc-2.02
236 # rm -f *~ TAGS)
238 echo "Making links to \`lisp/term'"
239 ### Don't distribute =*.el files or TAGS.
240 (cd lisp/term
241 ln [a-zA-Z]*.el ../../${tempdir}/lisp/term
242 ln [a-zA-Z]*.elc ../../${tempdir}/lisp/term
243 ln README ../../${tempdir}/lisp/term
244 rm -f =* TAGS)
246 echo "Making links to \`src'"
247 ### Don't distribute =*.[ch] files, or the configured versions of
248 ### config.in, paths.in, or Makefile.in, or TAGS.
249 (cd src
250 echo " (If we can't link gmalloc.c, that's okay.)"
251 ln [a-zA-Z]*.c ../${tempdir}/src
252 ## Might be a symlink to a file on another filesystem.
253 test -f ../${tempdir}/src/gmalloc.c || cp gmalloc.c ../${tempdir}/src
254 ln [a-zA-Z]*.h ../${tempdir}/src
255 ln [a-zA-Z]*.s ../${tempdir}/src
256 ln README Makefile.in ChangeLog ChangeLog.? config.in paths.in \
257 ../${tempdir}/src
258 ln makefile.nt ../${tempdir}/src
259 ln .gdbinit .dbxinit ../${tempdir}/src
260 ln *.opt vms-pp.trans ../${tempdir}/src
261 cd ../${tempdir}/src
262 rm -f config.h paths.h Makefile Makefile.c
263 rm -f =* TAGS)
265 echo "Making links to \`src/bitmaps'"
266 (cd src/bitmaps
267 ln README *.xbm ../../${tempdir}/src/bitmaps)
269 echo "Making links to \`src/m'"
270 (cd src/m
271 # We call files for miscellaneous input (to linker etc) .inp.
272 ln README [a-zA-Z0-9]*.h *.inp ../../${tempdir}/src/m)
274 echo "Making links to \`src/s'"
275 (cd src/s
276 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/s)
278 echo "Making links to \`lib-src'"
279 (cd lib-src
280 ln [a-zA-Z]*.[chy] ../${tempdir}/lib-src
281 ln ChangeLog Makefile.in README testfile vcdiff ../${tempdir}/lib-src
282 ln emacs.csh rcs2log rcs-checkin makefile.nt ../${tempdir}/lib-src
283 cd ../${tempdir}/lib-src
284 rm -f getdate.tab.c y.tab.c y.tab.h Makefile.c
285 rm -f =* TAGS)
287 echo "Making links to \`nt'"
288 (cd nt
289 ln emacs.ico emacs.rc config.nt [a-z]*.in [a-z]*.c ../${tempdir}/nt
290 ln [a-z]*.bat [a-z]*.h makefile.def makefile.nt ../${tempdir}/nt
291 ln TODO ChangeLog INSTALL README ../${tempdir}/nt)
293 echo "Making links to \`nt/inc'"
294 (cd nt/inc
295 ln [a-z]*.h ../../${tempdir}/nt/inc)
297 echo "Making links to \`nt/inc/sys'"
298 (cd nt/inc/sys
299 ln [a-z]*.h ../../../${tempdir}/nt/inc/sys)
301 echo "Making links to \`nt/inc/arpa'"
302 (cd nt/inc/arpa
303 ln [a-z]*.h ../../../${tempdir}/nt/inc/arpa)
305 echo "Making links to \`nt/inc/netinet'"
306 (cd nt/inc/netinet
307 ln [a-z]*.h ../../../${tempdir}/nt/inc/netinet)
309 echo "Making links to \`msdos'"
310 (cd msdos
311 ln ChangeLog emacs.ico emacs.pif ../${tempdir}/msdos
312 ln mainmake mainmake.v2 sed*.inp ../${tempdir}/msdos
313 cd ../${tempdir}/msdos
314 rm -f =*)
316 echo "Making links to \`oldXMenu'"
317 (cd oldXMenu
318 ln *.c *.h *.in ../${tempdir}/oldXMenu
319 ln README Imakefile ChangeLog ../${tempdir}/oldXMenu
320 ln compile.com descrip.mms ../${tempdir}/oldXMenu)
322 echo "Making links to \`lwlib'"
323 (cd lwlib
324 ln *.c *.h *.in ../${tempdir}/lwlib
325 ln README Imakefile ChangeLog ../${tempdir}/lwlib
326 cd ../${tempdir}/lwlib
327 rm -f lwlib-Xol*)
329 echo "Making links to \`etc'"
330 ### Don't distribute = files, TAGS, DOC files, backups, autosaves, or
331 ### tex litter.
332 (cd etc
333 ln `ls -d * | grep -v 'RCS' | grep -v 'Old' | grep -v '^e$'` ../${tempdir}/etc
334 cd ../${tempdir}/etc
335 rm -f DOC* *~ \#*\# *.dvi *.log *.orig *.rej *,v =* core
336 rm -f TAGS)
338 echo "Making links to \`etc/e'"
339 (cd etc/e
340 ln `ls -d * | grep -v 'RCS'` ../../${tempdir}/etc/e
341 cd ../../${tempdir}/etc/e
342 rm -f *~ \#*\# *,v =* core)
344 echo "Making links to \`cpp'"
345 (cd cpp
346 ln cccp.c cexp.y Makefile README ../${tempdir}/cpp)
348 echo "Making links to \`info'"
349 # Don't distribute backups or autosaves.
350 (cd info
351 ln [a-zA-Z]* ../${tempdir}/info
352 cd ../${tempdir}/info
353 # Avoid an error when expanding the wildcards later.
354 ln emacs dummy~ ; ln emacs \#dummy\#
355 rm -f *~ \#*\# core)
357 echo "Making links to \`man'"
358 (cd man
359 ln *.texi *.aux *.cps *.fns *.kys *.vrs ../${tempdir}/man
360 test -f README && ln README ../${tempdir}/man
361 test -f Makefile.in && ln Makefile.in ../${tempdir}/man
362 ln ChangeLog split-man ../${tempdir}/man
363 cp texinfo.tex ../${tempdir}/man
364 cd ../${tempdir}/man
365 rm -f \#*\# =* *~ core emacs-index* *.Z *.z xmail
366 rm -f emacs.?? termcap.?? gdb.?? *.log *.toc *.dvi *.oaux)
368 echo "Making links to \`vms'"
369 (cd vms
370 ln [0-9a-zA-Z]* ../${tempdir}/vms
371 cd ../${tempdir}/vms
372 rm -f *~)
374 ### It would be nice if they could all be symlinks to etc's copy, but
375 ### you're not supposed to have any symlinks in distribution tar files.
376 echo "Making sure copying notices are all copies of \`etc/COPYING'"
377 rm -f ${tempdir}/etc/COPYING
378 cp etc/COPYING ${tempdir}/etc/COPYING
379 for subdir in lisp src lib-src info msdos; do
380 if [ -f ${tempdir}/${subdir}/COPYING ]; then
381 rm ${tempdir}/${subdir}/COPYING
383 cp etc/COPYING ${tempdir}/${subdir}
384 done
386 #### Make sure that there aren't any hard links between files in the
387 #### distribution; people with afs can't deal with that. Okay,
388 #### actually we just re-copy anything with a link count greater
389 #### than two. (Yes, strictly greater than 2 is correct; since we
390 #### created these files by linking them in from the original tree,
391 #### they'll have exactly two links normally.)
392 ####
393 #### Commented out since it's not strictly necessary; it should suffice
394 #### to just break the link on alloca.c.
395 #echo "Breaking intra-tree links."
396 #find ${tempdir} ! -type d -links +2 \
397 # -exec cp -p {} $$ \; -exec rm -f {} \; -exec mv $$ {} \;
398 rm -f $tempdir/lib-src/alloca.c
399 cp $tempdir/src/alloca.c $tempdir/lib-src/alloca.c
401 if [ "${newer}" ]; then
402 echo "Removing files older than $newer"
403 ## We remove .elc files unconditionally, on the theory that anyone picking
404 ## up an incremental distribution already has a running Emacs to byte-compile
405 ## them with.
406 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
409 if [ "${make_tar}" = yes ]; then
410 if [ "${default_gzip}" = "" ]; then
411 echo "Looking for gzip"
412 temppath=`echo $PATH | sed 's/^:/.:/
413 s/::/:.:/g
414 s/:$/:./
415 s/:/ /g'`
416 default_gzip=`(
417 for dir in ${temppath}; do
418 if [ -f ${dir}/gzip ]; then echo 'gzip --best'; exit 0; fi
419 done
420 echo compress
423 case "${default_gzip}" in
424 compress* ) gzip_extension=.Z ;;
425 * ) gzip_extension=.gz ;;
426 esac
427 echo "Creating tar file"
428 (cd ${tempparent} ; tar cvf - ${emacsname} ) \
429 | ${default_gzip} \
430 > ${emacsname}.tar${gzip_extension}
433 if [ "${clean_up}" = yes ]; then
434 echo "Cleaning up the staging directory"
435 rm -rf ${tempparent}
436 else
437 (cd ${tempparent}; mv ${emacsname} ..)
438 rm -rf ${tempparent}
441 ### make-dist ends here