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