Add defgroup's; use defcustom for user vars.
[emacs.git] / make-dist
blobd219fb58ce51ed8fa371e47e2722323a5737d242
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 update=yes
37 clean_up=no
38 make_tar=no
39 newer=""
41 while [ $# -gt 0 ]; do
42 case "$1" in
43 ## This option tells make-dist to delete the staging directory
44 ## when done. It is useless to use this unless you make a tar file.
45 "--clean-up" )
46 clean_up=yes
48 ## This option tells make-dist to make a tar file.
49 "--tar" )
50 make_tar=yes
52 ## This option tells make-dist not to recompile or do analogous things.
53 "--no-update" )
54 update=no
56 ## This option tells make-dist to make the distribution normally, then
57 ## remove all files older than the given timestamp file. This is useful
58 ## for creating incremental or patch distributions.
59 "--newer")
60 newer="$2"
61 new_extension=".new"
62 shift
64 ## This option tells make-dist to use `compress' instead of gzip.
65 ## Normally, make-dist uses gzip whenever it is present.
66 "--compress")
67 default_gzip="compress"
69 * )
70 echo "${progname}: Unrecognized argument: $1" >&2
71 exit 1
73 esac
74 shift
75 done
77 ### Make sure we're running in the right place.
78 if [ ! -d src -o ! -f src/lisp.h -o ! -d lisp -o ! -f lisp/version.el ]; then
79 echo "${progname}: Can't find \`src/lisp.h' and \`lisp/version.el'." >&2
80 echo "${progname} must be run in the top directory of the Emacs" >&2
81 echo "distribution tree. cd to that directory and try again." >&2
82 exit 1
85 ### Find where to run Emacs.
86 if [ $update = yes ];
87 then
88 if [ -f src/emacs ];
89 then
90 EMACS=`pwd`/src/emacs
91 else
92 if [ x$EMACS = x ];
93 then
94 echo You must specify the EMACS environment variable 2>&1
95 exit 1
100 ### Find out which version of Emacs this is.
101 shortversion=`grep 'defconst[ ]*emacs-version' lisp/version.el \
102 | sed -e 's/^.*"\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/'`
103 version=`grep 'defconst[ ]*emacs-version' lisp/version.el \
104 | sed -e 's/^[^"]*"\([^"]*\)".*$/\1/'`
105 if [ ! "${version}" ]; then
106 echo "${progname}: can't find current Emacs version in \`./lisp/version.el'" >&2
107 exit 1
110 echo Version numbers are $version and $shortversion
112 if [ $update = yes ];
113 then
114 if grep -s "GNU Emacs version ${shortversion}" ./man/emacs.texi > /dev/null; then
115 true
116 else
117 echo "You must update the version number in \`./man/emacs.texi'"
118 sleep 5
122 ### Make sure we don't already have a directory emacs-${version}.
124 emacsname="emacs-${version}${new_extension}"
126 if [ -d ${emacsname} ]
127 then
128 echo Directory "${emacsname}" already exists >&2
129 exit 1
132 ### Make sure the subdirectory is available.
133 tempparent="make-dist.tmp.$$"
134 if [ -d ${tempparent} ]; then
135 echo "${progname}: staging directory \`${tempparent}' already exists.
136 Perhaps a previous invocation of \`${progname}' failed to clean up after
137 itself. Check that directories whose names are of the form
138 \`make-dist.tmp.NNNNN' don't contain any important information, remove
139 them, and try again." >&2
140 exit 1
143 ### Check for .elc files with no corresponding .el file.
144 ls -1 lisp/*.el | sed 's/\.el$/.elc/' > /tmp/el
145 ls -1 lisp/*.elc > /tmp/elc
146 bogosities="`comm -13 /tmp/el /tmp/elc`"
147 if [ "${bogosities}" != "" ]; then
148 echo "The following .elc files have no corresponding .el files:"
149 echo "${bogosities}"
151 rm -f /tmp/el /tmp/elc
153 ### Check for .el files that would overflow the 14-char limit if compiled.
154 long=`find lisp -name '[a-zA-Z0-9]??????????*.el' -print`
155 if [ "$long" != "" ]; then
156 echo "The following .el file names are too long:"
157 echo "$long"
160 ### Make sure configure is newer than configure.in.
161 if [ "x`ls -t configure configure.in | head -1`" != "xconfigure" ]; then
162 echo "\`./configure.in' is newer than \`./configure'" >&2
163 echo "Running autoconf" >&2
164 autoconf || { x=$?; echo Autoconf FAILED! >&2; exit $x; }
167 if [ $update = yes ];
168 then
169 echo "Updating Info files"
171 (cd man; make info)
173 echo "Updating finder-inf.el"
175 (cd lisp; make finder-inf.el))
177 echo "Recompiling Lisp files"
179 $EMACS -batch -f batch-byte-recompile-directory lisp
181 echo "Updating autoloads"
183 (cd lisp; make autoloads)
185 echo "Updating cus-load.el"
187 (cd lisp; make cus-load.el)
190 echo "Making lisp/MANIFEST"
192 (cd lisp; head -1 [!=]*.el | grep '^;' | sed -e 's/;;; //' > MANIFEST)
194 echo "Creating staging directory: \`${tempparent}'"
196 mkdir ${tempparent}
197 tempdir="${tempparent}/${emacsname}"
199 ### This trap ensures that the staging directory will be cleaned up even
200 ### when the script is interrupted in mid-career.
201 if [ "${clean_up}" = yes ]; then
202 trap "echo 'Interrupted...cleaning up the staging directory'; rm -rf ${tempparent}; exit 1" 1 2 15
205 echo "Creating top directory: \`${tempdir}'"
206 mkdir ${tempdir}
208 ### We copy in the top-level files before creating the subdirectories in
209 ### hopes that this will make the top-level files appear first in the
210 ### tar file; this means that people can start reading the INSTALL and
211 ### README while the rest of the tar file is still unpacking. Whoopee.
212 echo "Making links to top-level files"
213 ln GETTING.GNU.SOFTWARE INSTALL PROBLEMS README BUGS move-if-change ${tempdir}
214 ln ChangeLog Makefile.in configure configure.in ${tempdir}
215 ln config.bat make-dist update-subdirs vpath.sed ${tempdir}
216 ### Copy these files; they're cross-filesystem symlinks.
217 cp mkinstalldirs ${tempdir}
218 cp config.sub ${tempdir}
219 cp config.guess ${tempdir}
220 cp install.sh ${tempdir}
222 echo "Updating version number in README"
223 (cd ${tempdir}
224 awk \
225 '$1 " " $2 " " $3 " " $4 " " $5 == "This directory tree holds version" { $6 = version; print $0 }
226 $1 " " $2 " " $3 " " $4 " " $5 != "This directory tree holds version"' \
227 version=${version} README > tmp.README
228 mv tmp.README README)
231 echo "Creating subdirectories"
232 for subdir in lisp lisp/term lisp/language site-lisp \
233 src src/m src/s src/bitmaps lib-src oldXMenu lwlib \
234 nt nt/inc nt/inc/sys nt/inc/arpa nt/inc/netinet \
235 etc etc/e lock cpp info man msdos vms; do
236 mkdir ${tempdir}/${subdir}
237 done
239 echo "Making links to \`lisp'"
240 ### Don't distribute TAGS, =*.el files, site-init.el, site-load.el, or default.el.
241 (cd lisp
242 ln [a-zA-Z]*.el ../${tempdir}/lisp
243 ln [a-zA-Z]*.elc ../${tempdir}/lisp
244 ln [a-zA-Z]*.dat ../${tempdir}/lisp
245 ## simula.el doesn't keep abbreviations in simula.defns any more.
246 ## ln [a-zA-Z]*.defns ../${tempdir}/lisp
247 ln ChangeLog Makefile makefile.nt ChangeLog.? README ../${tempdir}/lisp
248 cd ../${tempdir}/lisp
249 rm -f TAGS =*
250 rm -f subdirs.el
251 rm -f site-init site-init.el site-init.elc
252 rm -f site-load site-load.el site-load.elc
253 rm -f site-start site-start.el site-start.elc
254 rm -f default default.el default.elc)
256 #echo "Making links to \`lisp/calc-2.02'"
257 #### Don't distribute =*.el files, TAGS or backups.
258 #(cd lisp/calc-2.02
259 # ln [a-zA-Z]*.el ../../${tempdir}/lisp/calc-2.02
260 # ln [a-zA-Z]*.elc ../../${tempdir}/lisp/calc-2.02
261 # ln calc.info* calc.texinfo calc-refcard.* ../../${tempdir}/lisp/calc-2.02
262 # ln INSTALL Makefile README README.prev ../../${tempdir}/lisp/calc-2.02
263 # cd ../../${tempdir}/lisp/calc-2.02
264 # rm -f *~ TAGS)
266 echo "Making links to \`lisp/term'"
267 ### Don't distribute =*.el files or TAGS.
268 (cd lisp/term
269 ln [a-zA-Z]*.el ../../${tempdir}/lisp/term
270 ln [a-zA-Z]*.elc ../../${tempdir}/lisp/term
271 ln README ../../${tempdir}/lisp/term
272 rm -f =* TAGS)
274 echo "Making links to \`lisp/term'"
275 ### Don't distribute =*.el files or TAGS.
276 (cd lisp/language
277 ln [a-zA-Z]*.el ../../${tempdir}/lisp/language
278 ln [a-zA-Z]*.elc ../../${tempdir}/lisp/language
279 rm -f =* TAGS)
281 echo "Making links to \`src'"
282 ### Don't distribute =*.[ch] files, or the configured versions of
283 ### config.in, paths.in, or Makefile.in, or TAGS.
284 (cd src
285 echo " (It is ok if ln fails in some cases.)"
286 ln [a-zA-Z]*.c ../${tempdir}/src
287 ln [a-zA-Z]*.h ../${tempdir}/src
288 ln [a-zA-Z]*.s ../${tempdir}/src
289 ln [a-zA-Z]*.in ../${tempdir}/src
290 ln [a-zA-Z]*.opt ../${tempdir}/src
291 ## If we ended up with a symlink, or if we did not get anything
292 ## due to a cross-device symlink, copy the file.
293 for file in [a-zA-Z]*.[hcs] [a-zA-Z]*.in [a-zA-Z]*.opt; do
294 if test -f ../${tempdir}/src/$file; then
295 # test -f appears to succeed for a symlink
296 if test -L ../${tempdir}/src/$file; then
297 rm ../${tempdir}/src/$file
298 cp $file ../${tempdir}/src
299 chmod a-w ../${tempdir}/src/$file
301 else
302 rm ../${tempdir}/src/$file
303 cp $file ../${tempdir}/src
304 chmod a-w ../${tempdir}/src/$file
306 done
307 ln README ChangeLog ChangeLog.*[0-9] ../${tempdir}/src
308 ln makefile.nt vms-pp.trans ../${tempdir}/src
309 ln .gdbinit .dbxinit ../${tempdir}/src
310 cd ../${tempdir}/src
311 rm -f config.h paths.h Makefile Makefile.c
312 rm -f =* TAGS)
314 echo "Making links to \`src/bitmaps'"
315 (cd src/bitmaps
316 ln README *.xbm ../../${tempdir}/src/bitmaps)
318 echo "Making links to \`src/m'"
319 (cd src/m
320 # We call files for miscellaneous input (to linker etc) .inp.
321 ln README [a-zA-Z0-9]*.h *.inp ../../${tempdir}/src/m)
323 echo "Making links to \`src/s'"
324 (cd src/s
325 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/s)
327 echo "Making links to \`lib-src'"
328 (cd lib-src
329 ln [a-zA-Z]*.[chy] ../${tempdir}/lib-src
330 ln ChangeLog Makefile.in README testfile vcdiff ../${tempdir}/lib-src
331 ln emacs.csh rcs2log rcs-checkin makefile.nt ../${tempdir}/lib-src
332 ## If we ended up with a symlink, or if we did not get anything
333 ## due to a cross-device symlink, copy the file.
334 for file in [a-zA-Z]*.[chy]; do
335 if test -f ../${tempdir}/lib-src/$file; then
336 # test -f appears to succeed for a symlink
337 if test -L ../${tempdir}/lib-src/$file; then
338 rm ../${tempdir}/lib-src/$file
339 cp $file ../${tempdir}/lib-src
340 chmod a-w ../${tempdir}/lib-src/$file
342 else
343 rm ../${tempdir}/lib-src/$file
344 cp $file ../${tempdir}/lib-src
345 chmod a-w ../${tempdir}/lib-src/$file
347 done
348 cd ../${tempdir}/lib-src
349 rm -f Makefile.c
350 rm -f =* TAGS)
352 echo "Making links to \`nt'"
353 (cd nt
354 ln emacs.ico emacs.rc config.nt [a-z]*.in [a-z]*.c ../${tempdir}/nt
355 ln [a-z]*.bat [a-z]*.h makefile.def makefile.nt ../${tempdir}/nt
356 ln TODO ChangeLog INSTALL README ../${tempdir}/nt)
358 echo "Making links to \`nt/inc'"
359 (cd nt/inc
360 ln [a-z]*.h ../../${tempdir}/nt/inc)
362 echo "Making links to \`nt/inc/sys'"
363 (cd nt/inc/sys
364 ln [a-z]*.h ../../../${tempdir}/nt/inc/sys)
366 echo "Making links to \`nt/inc/arpa'"
367 (cd nt/inc/arpa
368 ln [a-z]*.h ../../../${tempdir}/nt/inc/arpa)
370 echo "Making links to \`nt/inc/netinet'"
371 (cd nt/inc/netinet
372 ln [a-z]*.h ../../../${tempdir}/nt/inc/netinet)
374 echo "Making links to \`msdos'"
375 (cd msdos
376 ln ChangeLog emacs.ico emacs.pif ../${tempdir}/msdos
377 ln is_exec.c sigaction.c mainmake mainmake.v2 sed*.inp ../${tempdir}/msdos
378 cd ../${tempdir}/msdos
379 rm -f =*)
381 echo "Making links to \`oldXMenu'"
382 (cd oldXMenu
383 ln *.c *.h *.in ../${tempdir}/oldXMenu
384 ln README Imakefile ChangeLog ../${tempdir}/oldXMenu
385 ln compile.com descrip.mms ../${tempdir}/oldXMenu)
387 echo "Making links to \`lwlib'"
388 (cd lwlib
389 ln *.c *.h *.in ../${tempdir}/lwlib
390 ln README Imakefile ChangeLog ../${tempdir}/lwlib
391 cd ../${tempdir}/lwlib
392 rm -f lwlib-Xol*)
394 echo "Making links to \`etc'"
395 ### Don't distribute = files, TAGS, DOC files, backups, autosaves, or
396 ### tex litter.
397 (cd etc
398 ln `ls -d * | grep -v 'RCS' | grep -v 'Old' | grep -v '^e$'` ../${tempdir}/etc
399 cd ../${tempdir}/etc
400 rm -f DOC* *~ \#*\# *.dvi *.log *.orig *.rej *,v =* core
401 rm -f TAGS)
403 echo "Making links to \`etc/e'"
404 (cd etc/e
405 ln `ls -d * | grep -v 'RCS'` ../../${tempdir}/etc/e
406 cd ../../${tempdir}/etc/e
407 rm -f *~ \#*\# *,v =* core)
409 echo "Making links to \`cpp'"
410 (cd cpp
411 ln cccp.c cexp.y Makefile README ../${tempdir}/cpp)
413 echo "Making links to \`info'"
414 # Don't distribute backups or autosaves.
415 (cd info
416 ln [a-zA-Z]* ../${tempdir}/info
417 cd ../${tempdir}/info
418 # Avoid an error when expanding the wildcards later.
419 ln emacs dummy~ ; ln emacs \#dummy\#
420 rm -f *~ \#*\# core)
422 echo "Making links to \`man'"
423 (cd man
424 ln *.texi *.aux *.cps *.fns *.kys *.vrs ../${tempdir}/man
425 test -f README && ln README ../${tempdir}/man
426 test -f Makefile.in && ln Makefile.in ../${tempdir}/man
427 ln ChangeLog split-man ../${tempdir}/man
428 cp texinfo.tex ../${tempdir}/man
429 cd ../${tempdir}/man
430 rm -f \#*\# =* *~ core emacs-index* *.Z *.z xmail
431 rm -f emacs.?? termcap.?? gdb.?? *.log *.toc *.dvi *.oaux)
433 echo "Making links to \`vms'"
434 (cd vms
435 ln [0-9a-zA-Z]* ../${tempdir}/vms
436 cd ../${tempdir}/vms
437 rm -f *~)
439 ### It would be nice if they could all be symlinks to etc's copy, but
440 ### you're not supposed to have any symlinks in distribution tar files.
441 echo "Making sure copying notices are all copies of \`etc/COPYING'"
442 rm -f ${tempdir}/etc/COPYING
443 cp etc/COPYING ${tempdir}/etc/COPYING
444 for subdir in lisp src lib-src info msdos; do
445 if [ -f ${tempdir}/${subdir}/COPYING ]; then
446 rm ${tempdir}/${subdir}/COPYING
448 cp etc/COPYING ${tempdir}/${subdir}
449 done
451 #### Make sure that there aren't any hard links between files in the
452 #### distribution; people with afs can't deal with that. Okay,
453 #### actually we just re-copy anything with a link count greater
454 #### than two. (Yes, strictly greater than 2 is correct; since we
455 #### created these files by linking them in from the original tree,
456 #### they'll have exactly two links normally.)
457 ####
458 #### Commented out since it's not strictly necessary; it should suffice
459 #### to just break the link on alloca.c.
460 #echo "Breaking intra-tree links."
461 #find ${tempdir} ! -type d -links +2 \
462 # -exec cp -p {} $$ \; -exec rm -f {} \; -exec mv $$ {} \;
463 rm -f $tempdir/lib-src/alloca.c
464 cp $tempdir/src/alloca.c $tempdir/lib-src/alloca.c
466 if [ "${newer}" ]; then
467 echo "Removing files older than $newer"
468 ## We remove .elc files unconditionally, on the theory that anyone picking
469 ## up an incremental distribution already has a running Emacs to byte-compile
470 ## them with.
471 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
474 if [ "${make_tar}" = yes ]; then
475 if [ "${default_gzip}" = "" ]; then
476 echo "Looking for gzip"
477 temppath=`echo $PATH | sed 's/^:/.:/
478 s/::/:.:/g
479 s/:$/:./
480 s/:/ /g'`
481 default_gzip=`(
482 for dir in ${temppath}; do
483 if [ -f ${dir}/gzip ]; then echo 'gzip --best'; exit 0; fi
484 done
485 echo compress
488 case "${default_gzip}" in
489 compress* ) gzip_extension=.Z ;;
490 * ) gzip_extension=.gz ;;
491 esac
492 echo "Creating tar file"
493 (cd ${tempparent} ; tar cvf - ${emacsname} ) \
494 | ${default_gzip} \
495 > ${emacsname}.tar${gzip_extension}
498 if [ "${clean_up}" = yes ]; then
499 echo "Cleaning up the staging directory"
500 rm -rf ${tempparent}
501 else
502 (cd ${tempparent}; mv ${emacsname} ..)
503 rm -rf ${tempparent}
506 ### make-dist ends here