Bump version to 24.2.92
[emacs.git] / make-dist
blob60afb0c618f2af1bffd31d8baf69a548eb40af41
1 #!/bin/sh
2 ### make-dist: create an Emacs distribution tar file from current srcdir
4 ## Copyright (C) 1995, 1997-1998, 2000-2013 Free Software Foundation,
5 ## Inc.
7 ## This file is part of GNU Emacs.
9 ## GNU Emacs is free software: you can redistribute it and/or modify
10 ## it under the terms of the GNU General Public License as published by
11 ## the Free Software Foundation, either version 3 of the License, or
12 ## (at your option) any later version.
14 ## GNU Emacs is distributed in the hope that it will be useful,
15 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ## GNU General Public License for more details.
19 ## You should have received a copy of the GNU General Public License
20 ## along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
22 ### Commentary:
24 ## This basically creates a duplicate directory structure, and then
25 ## hard links into it only those files that should be distributed.
26 ## This means that if you add a file with an odd name, you should make
27 ## sure that this script will include it.
29 ### Code:
31 progname="$0"
33 ### Exit if a command fails.
34 #set -e
36 ### Print out each line we read, for debugging's sake.
37 #set -v
39 LANGUAGE=C
40 LC_ALL=C
41 LC_MESSAGES=
42 LANG=
43 export LANGUAGE LC_ALL LC_MESSAGES LANG
45 ## Don't restrict access to any files.
46 umask 0
48 update=yes
49 check=yes
50 clean_up=no
51 make_tar=no
52 default_gzip=gzip
53 newer=""
55 while [ $# -gt 0 ]; do
56 case "$1" in
57 ## This option tells make-dist to delete the staging directory
58 ## when done. It is useless to use this unless you make a tar file.
59 "--clean-up" )
60 clean_up=yes
62 ## This option tells make-dist to make a tar file.
63 "--tar" )
64 make_tar=yes
66 ## This option tells make-dist not to recompile or do analogous things.
67 "--no-update" )
68 update=no
70 ## This option says don't check for bad file names, etc.
71 "--no-check" )
72 check=no
74 ## This option tells make-dist to make the distribution normally, then
75 ## remove all files older than the given timestamp file. This is useful
76 ## for creating incremental or patch distributions.
77 "--newer")
78 newer="$2"
79 new_extension=".new"
80 shift
82 ## This option tells make-dist to use `bzip2' instead of gzip.
83 "--bzip2")
84 default_gzip="bzip2"
86 ## Same with lzma.
87 "--lzma")
88 default_gzip="lzma"
91 "--snapshot")
92 clean_up=yes
93 make_tar=yes
94 update=no
95 check=no
98 "--help")
99 echo "Usage: ${progname} [options]"
100 echo ""
101 echo " --bzip2 use bzip2 instead of gzip"
102 echo " --clean-up delete staging directories when done"
103 echo " --lzma use lzma instead of gzip"
104 echo " --newer=TIME don't include files older than TIME"
105 echo " --no-check don't check for bad file names etc."
106 echo " --no-update don't recompile or do analogous things"
107 echo " --snapshot same as --clean-up --no-update --tar --no-check"
108 echo " --tar make a tar file"
109 echo ""
110 exit 0
114 echo "${progname}: Unrecognized argument: $1" >&2
115 exit 1
117 esac
118 shift
119 done
121 ### Make sure we're running in the right place.
122 if [ ! -d src -o ! -f src/lisp.h -o ! -d lisp -o ! -f lisp/subr.el ]; then
123 echo "${progname}: Can't find \`src/lisp.h' and \`lisp/subr.el'." >&2
124 echo "${progname} must be run in the top directory of the Emacs" >&2
125 echo "distribution tree. cd to that directory and try again." >&2
126 exit 1
129 ### Find where to run Emacs.
130 ### (Accept only absolute file names.)
131 if [ $update = yes ];
132 then
133 if [ -f src/emacs ];
134 then
135 EMACS=`pwd`/src/emacs
136 else
137 case $EMACS in
138 /*) ;;
140 if [ ! -f "$EMACS" ]; then
141 echo "$0: You must set the EMACS environment variable " \
142 "to an absolute file name." 2>&1
143 exit 1
144 fi;;
145 esac
149 ### Find out which version of Emacs this is.
150 version=`
151 sed -n 's/^AC_INIT(emacs,[ ]*\([^ )]*\).*/\1/p' <configure.ac
152 ` || version=
153 if [ ! "${version}" ]; then
154 echo "${progname}: can't find current Emacs version in \`./src/emacs.c'" >&2
155 exit 1
158 echo Version number is $version
160 if [ $update = yes ]; then
161 if ! grep -q "@set EMACSVER *${version}" doc/emacs/emacsver.texi || \
162 ! grep -q "tree holds version *${version}" README; then
163 echo "WARNING: README and/or emacsver.texi have the wrong version number"
164 echo "Consider running M-x set-version from admin/admin.el"
165 sleep 5
169 ### Make sure we don't already have a directory emacs-${version}.
171 emacsname="emacs-${version}${new_extension}"
173 if [ -d ${emacsname} ]
174 then
175 echo Directory "${emacsname}" already exists >&2
176 exit 1
179 ### Make sure the subdirectory is available.
180 tempparent="make-dist.tmp.$$"
181 if [ -d ${tempparent} ]; then
182 echo "${progname}: staging directory \`${tempparent}' already exists.
183 Perhaps a previous invocation of \`${progname}' failed to clean up after
184 itself. Check that directories whose names are of the form
185 \`make-dist.tmp.NNNNN' don't contain any important information, remove
186 them, and try again." >&2
187 exit 1
190 if [ $check = yes ]; then
191 ls -1 lisp/[a-zA-Z]*.el lisp/[a-z]*/[a-zA-Z0-9]*.el \
192 lisp/[a-z]*/[a-z]*/[a-zA-Z0-9]*.el \
193 lisp/[a-z]*/[a-z]*/[a-z]*/[a-zA-Z0-9]*.el \
194 leim/[a-z]*/[a-z]*.el > /tmp/el
196 ls -1 lisp/[a-zA-Z]*.elc lisp/[a-z]*/[a-zA-Z0-9]*.elc \
197 lisp/[a-z]*/[a-z]*/[a-zA-Z0-9]*.elc \
198 lisp/[a-z]*/[a-z]*/[a-z]*/[a-zA-Z0-9]*.elc \
199 leim/[a-z]*/[a-z]*.elc > /tmp/elc
201 ## Check for .elc files with no corresponding .el file.
202 sed 's/\.el$/.elc/' /tmp/el > /tmp/elelc
204 bogosities="`comm -13 /tmp/elelc /tmp/elc`"
205 if [ x"${bogosities}" != x"" ]; then
206 echo "The following .elc files have no corresponding .el files:"
207 echo "${bogosities}"
210 ### Check for .el files with no corresponding .elc file.
211 sed 's/\.elc$/.el/' /tmp/elc > /tmp/elcel
212 losers="`comm -23 /tmp/el /tmp/elcel`"
214 rm -f /tmp/el /tmp/elc /tmp/elcel /tmp/elelc
216 bogosities=
217 for file in $losers; do
218 grep -q "no-byte-compile: t" $file && continue
219 case $file in
220 site-init.el | site-load.el | site-start.el | default.el) continue ;;
221 esac
223 bogosities="$file $bogosities"
225 done
226 if [ x"${bogosities}" != x"" ]; then
227 echo "The following .el files have no corresponding .elc files:"
228 echo "${bogosities}"
232 if [ $update = yes ]; then
234 ## Make sure configure is newer than configure.ac, etc.
235 ## It is better to let autoreconf do what is needed than
236 ## for us to try and duplicate all its checks.
237 echo "Running autoreconf"
238 autoreconf -i -I m4 || { x=$?; echo Autoreconf FAILED! >&2; exit $x; }
240 ## Make sure src/stamp-h.in is newer than configure.ac.
241 rm -f src/stamp-h.in
242 echo timestamp > src/stamp-h.in
244 echo "Updating Info files"
245 make info-real
247 echo "Updating finder, custom and autoload data"
248 (cd lisp && make updates EMACS="$EMACS")
250 echo "Updating leim-list.el"
251 (cd leim && make leim-list.el EMACS="$EMACS")
253 echo "Recompiling Lisp files"
254 $EMACS -batch -f batch-byte-recompile-directory lisp leim
255 fi # $update = yes
257 echo "Creating staging directory: \`${tempparent}'"
259 mkdir ${tempparent}
260 tempdir="${tempparent}/${emacsname}"
262 ### This trap ensures that the staging directory will be cleaned up even
263 ### when the script is interrupted in mid-career.
264 if [ "${clean_up}" = yes ]; then
265 trap "echo 'Cleaning up the staging directory'; rm -rf ${tempparent}" EXIT
268 echo "Creating top directory: \`${tempdir}'"
269 mkdir ${tempdir}
271 ### We copy in the top-level files before creating the subdirectories in
272 ### hopes that this will make the top-level files appear first in the
273 ### tar file; this means that people can start reading the INSTALL and
274 ### README while the rest of the tar file is still unpacking. Whoopee.
275 echo "Making links to top-level files"
276 ln INSTALL README BUGS ${tempdir}
277 ln ChangeLog Makefile.in autogen.sh configure configure.ac ${tempdir}
278 ln config.bat make-dist .dir-locals.el ${tempdir}
279 ln aclocal.m4 ${tempdir}
281 echo "Creating subdirectories"
282 for subdir in site-lisp \
283 leim leim/CXTERM-DIC leim/MISC-DIC \
284 leim/SKK-DIC leim/ja-dic leim/quail \
285 build-aux build-aux/snippet \
286 src src/bitmaps lib lib-src oldXMenu lwlib \
287 nt nt/inc nt/inc/sys nt/inc/arpa nt/inc/netinet nt/icons \
288 `find etc lisp admin -type d` \
289 doc doc/emacs doc/misc doc/man doc/lispref doc/lispintro \
290 info m4 msdos \
291 nextstep nextstep/templates \
292 nextstep/Cocoa nextstep/Cocoa/Emacs.base \
293 nextstep/Cocoa/Emacs.base/Contents \
294 nextstep/Cocoa/Emacs.base/Contents/Resources \
295 nextstep/GNUstep \
296 nextstep/GNUstep/Emacs.base \
297 nextstep/GNUstep/Emacs.base/Resources
299 ## site-lisp for in-place installs (?).
300 [ "$subdir" = "site-lisp" ] || [ -d "$subdir" ] || \
301 echo "WARNING: $subdir not found, making anyway"
302 echo " ${tempdir}/${subdir}"
303 mkdir ${tempdir}/${subdir}
304 done
306 echo "Making links to \`lisp' and its subdirectories"
307 files=`find lisp \( -name '*.el' -o -name '*.elc' -o -name 'ChangeLog*' \
308 -o -name 'README*' \)`
310 ### Don't distribute site-init.el, site-load.el, or default.el.
311 for file in lisp/Makefile.in lisp/makefile.w32-in $files; do
312 case $file in
313 */site-init*|*/site-load*|*/default*) continue ;;
314 esac
315 ln $file $tempdir/$file
316 done
318 echo "Making links to \`leim' and its subdirectories"
319 (cd leim
320 ln makefile.w32-in ../${tempdir}/leim
321 ln ChangeLog README ../${tempdir}/leim
322 ln CXTERM-DIC/README CXTERM-DIC/*.tit ../${tempdir}/leim/CXTERM-DIC
323 ln SKK-DIC/README SKK-DIC/SKK-JISYO.L ../${tempdir}/leim/SKK-DIC
324 ln MISC-DIC/README MISC-DIC/*.* ../${tempdir}/leim/MISC-DIC
325 ln ja-dic/*.el ja-dic/*.elc ../${tempdir}/leim/ja-dic
326 ln Makefile.in ../${tempdir}/leim/Makefile.in
327 ln leim-ext.el ../${tempdir}/leim/leim-ext.el
328 ## Lisp files that start with a capital (also 4Corner.el) are
329 ## generated from TIT dictionaries so we don't distribute them.
330 ln quail/[a-z]*.el quail/[a-z]*.elc ../${tempdir}/leim/quail
331 rm -f ../${tempdir}/leim/quail/quick-b5.*
332 rm -f ../${tempdir}/leim/quail/quick-cns.*
333 rm -f ../${tempdir}/leim/quail/tsang-b5.*
334 rm -f ../${tempdir}/leim/quail/tsang-cns.*)
336 echo "Making links to \`build-aux'"
337 (cd build-aux
338 ln compile config.guess config.sub depcomp ../${tempdir}/build-aux
339 ln install-sh missing move-if-change update-subdirs ../${tempdir}/build-aux)
341 echo "Making links to \`build-aux/snippet'"
342 (cd build-aux/snippet
343 ln *.h ../../${tempdir}/build-aux/snippet)
345 echo "Making links to \`src'"
346 ### Don't distribute the configured versions of
347 ### config.in, paths.in, buildobj.h, or Makefile.in.
348 (cd src
349 echo " (It is ok if ln fails in some cases.)"
350 ln [a-zA-Z]*.[chm] ../${tempdir}/src
351 ln [a-zA-Z]*.in ../${tempdir}/src
352 ln [a-zA-Z]*.mk ../${tempdir}/src
353 ln README ChangeLog ChangeLog.*[0-9] ../${tempdir}/src
354 ln makefile.w32-in ../${tempdir}/src
355 ln .gdbinit .dbxinit ../${tempdir}/src
356 cd ../${tempdir}/src
357 rm -f globals.h config.h epaths.h Makefile buildobj.h)
359 echo "Making links to \`src/bitmaps'"
360 (cd src/bitmaps
361 ln README *.xbm ../../${tempdir}/src/bitmaps)
363 echo "Making links to \`lib'"
364 (snippet_h=`(cd build-aux/snippet && ls *.h)`
365 cd lib
366 ln [a-zA-Z]*.[ch] ../${tempdir}/lib
367 ln gnulib.mk Makefile.am Makefile.in makefile.w32-in ../${tempdir}/lib
368 cd ../${tempdir}/lib
369 script='/[*]/d; s/\.in\.h$/.h/'
370 rm -f `(echo "$snippet_h"; ls *.in.h) | sed "$script"`)
372 echo "Making links to \`lib-src'"
373 (cd lib-src
374 ln [a-zA-Z]*.[ch] ../${tempdir}/lib-src
375 ln ChangeLog Makefile.in README testfile ../${tempdir}/lib-src
376 ln grep-changelog rcs2log ../${tempdir}/lib-src
377 ln makefile.w32-in ../${tempdir}/lib-src)
379 echo "Making links to \`m4'"
380 (cd m4
381 ln *.m4 ../${tempdir}/m4)
383 echo "Making links to \`nt'"
384 (cd nt
385 ln emacs-x86.manifest emacs-x64.manifest emacs.rc ../${tempdir}/nt
386 ln config.nt emacsclient.rc emacs-src.tags ../${tempdir}/nt
387 ln nmake.defs gmake.defs subdirs.el [a-z]*.bat [a-z]*.[ch] ../${tempdir}/nt
388 ln ChangeLog INSTALL README README.W32 makefile.w32-in ../${tempdir}/nt)
390 echo "Making links to \`nt/inc' and its subdirectories"
391 for f in `find nt/inc -type f -name '[a-z]*.h'`; do
392 ln $f $tempdir/$f
393 done
395 echo "Making links to \`nt/icons'"
396 (cd nt/icons
397 ln README [a-z]*.ico ../../${tempdir}/nt/icons
398 ln [a-z]*.cur ../../${tempdir}/nt/icons)
400 echo "Making links to \`msdos'"
401 (cd msdos
402 ln ChangeLog INSTALL README emacs.ico emacs.pif ../${tempdir}/msdos
403 ln depfiles.bat inttypes.h ../${tempdir}/msdos
404 ln is_exec.c sigaction.c mainmake.v2 sed*.inp ../${tempdir}/msdos)
406 echo "Making links to \`nextstep'"
407 (cd nextstep
408 ln ChangeLog README INSTALL Makefile.in ../${tempdir}/nextstep)
410 echo "Making links to \`nextstep/templates'"
411 (cd nextstep/templates
412 ln Emacs.desktop.in Info-gnustep.plist.in Info.plist.in InfoPlist.strings.in ../../${tempdir}/nextstep/templates)
414 echo "Making links to \`nextstep/Cocoa/Emacs.base/Contents'"
415 (cd nextstep/Cocoa/Emacs.base/Contents
416 ln PkgInfo ../../../../${tempdir}/nextstep/Cocoa/Emacs.base/Contents)
418 echo "Making links to \`nextstep/Cocoa/Emacs.base/Contents/Resources'"
419 (cd nextstep/Cocoa/Emacs.base/Contents/Resources
420 ln Credits.html *.icns ../../../../../${tempdir}/nextstep/Cocoa/Emacs.base/Contents/Resources)
422 echo "Making links to \`nextstep/GNUstep/Emacs.base/Resources'"
423 (cd nextstep/GNUstep/Emacs.base/Resources
424 ln README emacs.tiff ../../../../${tempdir}/nextstep/GNUstep/Emacs.base/Resources )
426 echo "Making links to \`oldXMenu'"
427 (cd oldXMenu
428 ln *.[ch] *.in ../${tempdir}/oldXMenu
429 ln README ChangeLog ../${tempdir}/oldXMenu)
431 echo "Making links to \`lwlib'"
432 (cd lwlib
433 ln *.[ch] *.in ../${tempdir}/lwlib
434 ln README ChangeLog ../${tempdir}/lwlib)
436 echo "Making links to \`admin' and its subdirectories"
437 for f in `find admin -type f`; do
438 ln $f $tempdir/$f
439 done
441 echo "Making links to \`etc' and its subdirectories"
442 for f in `find etc -type f`; do
443 case $f in
444 etc/DOC*|etc/*.pyc) continue ;;
445 esac
446 ln $f $tempdir/$f
447 done
449 echo "Making links to \`info'"
450 ln `find info -type f -print` ${tempdir}/info
452 echo "Making links to \`doc/emacs'"
453 (cd doc/emacs
454 ln *.texi *.in makefile.w32-in ChangeLog* ../../${tempdir}/doc/emacs)
456 echo "Making links to \`doc/misc'"
457 (cd doc/misc
458 ln *.texi *.tex *.in makefile.w32-in gnus-news.el ChangeLog* ../../${tempdir}/doc/misc)
460 echo "Making links to \`doc/lispref'"
461 (cd doc/lispref
462 ln *.texi *.in makefile.w32-in README ChangeLog* ../../${tempdir}/doc/lispref
463 ln spellfile ../../${tempdir}/doc/lispref
464 ln two-volume.make two-volume-cross-refs.txt ../../${tempdir}/doc/lispref)
466 echo "Making links to \`doc/lispintro'"
467 (cd doc/lispintro
468 ln *.texi *.in makefile.w32-in *.eps *.pdf ../../${tempdir}/doc/lispintro
469 ln README ChangeLog* ../../${tempdir}/doc/lispintro
470 cd ../../${tempdir}/doc/lispintro)
472 echo "Making links to \`doc/man'"
473 (cd doc/man
474 ln ChangeLog* *.1 ../../${tempdir}/doc/man
475 cd ../../${tempdir}/doc/man)
477 ### It would be nice if they could all be symlinks to top-level copy, but
478 ### you're not supposed to have any symlinks in distribution tar files.
479 echo "Making sure copying notices are all copies of \`COPYING'"
480 for subdir in . etc info leim lib lib-src lisp lwlib msdos nt src; do
481 rm -f ${tempdir}/${subdir}/COPYING
482 cp COPYING ${tempdir}/${subdir}
483 done
485 if [ "${newer}" ]; then
486 echo "Removing files older than $newer"
487 ## We remove .elc files unconditionally, on the theory that anyone picking
488 ## up an incremental distribution already has a running Emacs to byte-compile
489 ## them with.
490 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
493 ## Don't distribute backups, autosaves, etc.
494 echo "Removing unwanted files"
495 find ${tempparent} \( -name '*~' -o -name '#*#' -o -name '.*ignore' -o -name '=*' -o -name 'TAGS' \) -exec rm -f {} \;
497 if [ "${make_tar}" = yes ]; then
498 echo "Looking for $default_gzip"
499 found=0
500 temppath=`echo $PATH | sed -e 's/^:/.:/' -e 's/::/:.:/g' -e 's/:$/:./' \
501 -e 's/:/ /g'`
502 for dir in ${temppath}; do
503 [ -x ${dir}/$default_gzip ] || continue
504 found=1; break
505 done
506 if [ "$found" = "0" ]; then
507 echo "WARNING: \`$default_gzip' not found, will not compress" >&2
508 default_gzip=cat
510 case "${default_gzip}" in
511 bzip2) gzip_extension=.bz2 ;;
512 lzma) gzip_extension=.lzma ;;
513 gzip) gzip_extension=.gz ; default_gzip="gzip --best";;
514 *) gzip_extension= ;;
515 esac
516 echo "Creating tar file"
517 (cd ${tempparent} ; tar cvf - ${emacsname} ) \
518 | ${default_gzip} \
519 > ${emacsname}.tar${gzip_extension}
522 if [ "${clean_up}" != yes ]; then
523 (cd ${tempparent}; mv ${emacsname} ..)
524 rm -rf ${tempparent}
527 ### make-dist ends here