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