Auto-commit of generated files.
[emacs.git] / make-dist
blob920ca2bc78689fc94200d148273069aed6d609fb
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, Inc.
6 ## This file is part of GNU Emacs.
8 ## GNU Emacs is free software: you can redistribute it and/or modify
9 ## it under the terms of the GNU General Public License as published by
10 ## the Free Software Foundation, either version 3 of the License, or
11 ## (at your option) any later version.
13 ## GNU Emacs is distributed in the hope that it will be useful,
14 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ## GNU General Public License for more details.
18 ## You should have received a copy of the GNU General Public License
19 ## along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
21 ### Commentary:
23 ## This basically creates a duplicate directory structure, and then
24 ## hard links into it only those files that should be distributed.
25 ## This means that if you add a file with an odd name, you should make
26 ## sure that this script will include it.
28 ### Code:
30 progname="$0"
32 ### Exit if a command fails.
33 #set -e
35 ### Print out each line we read, for debugging's sake.
36 #set -v
38 LANGUAGE=C
39 LC_ALL=C
40 LC_MESSAGES=
41 LANG=
42 export LANGUAGE LC_ALL LC_MESSAGES LANG
44 ## Remove unnecessary restrictions on file access.
45 umask 022
47 update=yes
48 check=yes
49 clean_up=no
50 make_tar=no
51 default_gzip=gzip
52 newer=""
53 with_tests=no
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 xz.
87 "--xz")
88 default_gzip="xz"
90 "--no-compress")
91 default_gzip="cat"
94 "--snapshot")
95 clean_up=yes
96 make_tar=yes
97 update=no
98 check=no
101 ## Include the test/ directory.
102 ## This option is mainly for the hydra build server.
103 "--tests")
104 with_tests=yes
107 "--help")
108 echo "Usage: ${progname} [options]"
109 echo ""
110 echo " --bzip2 use bzip2 instead of gzip"
111 echo " --clean-up delete staging directories when done"
112 echo " --xz use xz instead of gzip"
113 echo " --no-compress don't compress"
114 echo " --newer=TIME don't include files older than TIME"
115 echo " --no-check don't check for bad file names etc."
116 echo " --no-update don't recompile or do analogous things"
117 echo " --snapshot same as --clean-up --no-update --tar --no-check"
118 echo " --tar make a tar file"
119 echo " --tests include the test/ directory"
120 echo ""
121 exit 0
125 echo "${progname}: Unrecognized argument: $1" >&2
126 exit 1
128 esac
129 shift
130 done
132 ### Make sure we're running in the right place.
133 if [ ! -d src -o ! -f src/lisp.h -o ! -d lisp -o ! -f lisp/subr.el ]; then
134 echo "${progname}: Can't find \`src/lisp.h' and \`lisp/subr.el'." >&2
135 echo "${progname} must be run in the top directory of the Emacs" >&2
136 echo "distribution tree. cd to that directory and try again." >&2
137 exit 1
140 ### Find where to run Emacs.
141 ### (Accept only absolute file names.)
142 if [ $update = yes ];
143 then
144 if [ -f src/emacs ];
145 then
146 EMACS=`pwd`/src/emacs
147 else
148 case $EMACS in
149 /*) ;;
151 if [ ! -f "$EMACS" ]; then
152 echo "$0: You must set the EMACS environment variable " \
153 "to an absolute file name." 2>&1
154 exit 1
155 fi;;
156 esac
160 ### Find out which version of Emacs this is.
161 version=`
162 sed -n 's/^AC_INIT(emacs,[ ]*\([^ )]*\).*/\1/p' <configure.ac
163 ` || version=
164 if [ ! "${version}" ]; then
165 echo "${progname}: can't find current Emacs version in \`./src/emacs.c'" >&2
166 exit 1
169 echo Version number is $version
171 if [ $update = yes ]; then
172 if ! grep -q "@set EMACSVER *${version}" doc/emacs/emacsver.texi || \
173 ! grep -q "tree holds version *${version}" README; then
174 echo "WARNING: README and/or emacsver.texi have the wrong version number"
175 echo "Consider running M-x set-version from admin/admin.el"
176 sleep 5
180 ### Make sure we don't already have a directory emacs-${version}.
182 emacsname="emacs-${version}${new_extension}"
184 if [ -d ${emacsname} ]
185 then
186 echo Directory "${emacsname}" already exists >&2
187 exit 1
190 ### Make sure the subdirectory is available.
191 tempparent="make-dist.tmp.$$"
192 if [ -d ${tempparent} ]; then
193 echo "${progname}: staging directory \`${tempparent}' already exists.
194 Perhaps a previous invocation of \`${progname}' failed to clean up after
195 itself. Check that directories whose names are of the form
196 \`make-dist.tmp.NNNNN' don't contain any important information, remove
197 them, and try again." >&2
198 exit 1
201 if [ $check = yes ]; then
202 ls -1 lisp/[a-zA-Z]*.el lisp/[a-z]*/[a-zA-Z0-9]*.el \
203 lisp/[a-z]*/[a-z]*/[a-zA-Z0-9]*.el \
204 lisp/[a-z]*/[a-z]*/[a-z]*/[a-zA-Z0-9]*.el \
205 leim/[a-z]*/[a-z]*.el > /tmp/el
207 ls -1 lisp/[a-zA-Z]*.elc lisp/[a-z]*/[a-zA-Z0-9]*.elc \
208 lisp/[a-z]*/[a-z]*/[a-zA-Z0-9]*.elc \
209 lisp/[a-z]*/[a-z]*/[a-z]*/[a-zA-Z0-9]*.elc \
210 leim/[a-z]*/[a-z]*.elc > /tmp/elc
212 ## Check for .elc files with no corresponding .el file.
213 sed 's/\.el$/.elc/' /tmp/el > /tmp/elelc
215 bogosities="`comm -13 /tmp/elelc /tmp/elc`"
216 if [ x"${bogosities}" != x"" ]; then
217 echo "The following .elc files have no corresponding .el files:"
218 echo "${bogosities}"
221 ### Check for .el files with no corresponding .elc file.
222 sed 's/\.elc$/.el/' /tmp/elc > /tmp/elcel
223 losers="`comm -23 /tmp/el /tmp/elcel`"
225 rm -f /tmp/el /tmp/elc /tmp/elcel /tmp/elelc
227 bogosities=
228 for file in $losers; do
229 grep -q "no-byte-compile: t" $file && continue
230 case $file in
231 site-init.el | site-load.el | site-start.el | default.el) continue ;;
232 esac
234 bogosities="$file $bogosities"
236 done
237 if [ x"${bogosities}" != x"" ]; then
238 echo "The following .el files have no corresponding .elc files:"
239 echo "${bogosities}"
243 if [ $update = yes ]; then
245 ## Make sure configure is newer than configure.ac, etc.
246 ## It is better to let autoreconf do what is needed than
247 ## for us to try and duplicate all its checks.
248 echo "Running autoreconf"
249 autoreconf -i -I m4 || { x=$?; echo Autoreconf FAILED! >&2; exit $x; }
251 ## Make sure src/stamp-h.in is newer than configure.ac.
252 rm -f src/stamp-h.in
253 echo timestamp > src/stamp-h.in
255 echo "Updating Info files"
256 make info-real
258 echo "Updating finder, custom and autoload data"
259 (cd lisp && make updates EMACS="$EMACS")
261 echo "Updating leim-list.el"
262 (cd leim && make leim-list.el EMACS="$EMACS")
264 echo "Recompiling Lisp files"
265 $EMACS -batch -f batch-byte-recompile-directory lisp leim
266 fi # $update = yes
268 echo "Creating staging directory: \`${tempparent}'"
270 mkdir ${tempparent}
271 tempdir="${tempparent}/${emacsname}"
273 ### This trap ensures that the staging directory will be cleaned up even
274 ### when the script is interrupted in mid-career.
275 if [ "${clean_up}" = yes ]; then
276 trap "echo 'Cleaning up the staging directory'; rm -rf ${tempparent}" EXIT
279 echo "Creating top directory: \`${tempdir}'"
280 mkdir ${tempdir}
282 ### We copy in the top-level files before creating the subdirectories in
283 ### hopes that this will make the top-level files appear first in the
284 ### tar file; this means that people can start reading the INSTALL and
285 ### README while the rest of the tar file is still unpacking. Whoopee.
286 echo "Making links to top-level files"
287 ln INSTALL README BUGS ${tempdir}
288 ln ChangeLog Makefile.in autogen.sh configure configure.ac ${tempdir}
289 ln config.bat make-dist .dir-locals.el ${tempdir}
290 ln aclocal.m4 ${tempdir}
292 echo "Creating subdirectories"
293 for subdir in site-lisp \
294 leim leim/CXTERM-DIC leim/MISC-DIC \
295 leim/SKK-DIC leim/ja-dic leim/quail \
296 build-aux build-aux/snippet \
297 src src/bitmaps lib lib-src oldXMenu lwlib \
298 nt nt/inc nt/inc/sys nt/inc/arpa nt/inc/netinet nt/icons \
299 `find etc lisp admin test -type d` \
300 doc doc/emacs doc/misc doc/man doc/lispref doc/lispintro \
301 info m4 msdos \
302 nextstep nextstep/templates \
303 nextstep/Cocoa nextstep/Cocoa/Emacs.base \
304 nextstep/Cocoa/Emacs.base/Contents \
305 nextstep/Cocoa/Emacs.base/Contents/Resources \
306 nextstep/GNUstep \
307 nextstep/GNUstep/Emacs.base \
308 nextstep/GNUstep/Emacs.base/Resources
311 if [ "$with_tests" != "yes" ]; then
312 case $subdir in
313 test*) continue ;;
314 esac
317 ## site-lisp for in-place installs (?).
318 [ "$subdir" = "site-lisp" ] || [ -d "$subdir" ] || \
319 echo "WARNING: $subdir not found, making anyway"
320 echo " ${tempdir}/${subdir}"
321 mkdir ${tempdir}/${subdir}
322 done
324 echo "Making links to \`lisp' and its subdirectories"
325 files=`find lisp \( -name '*.el' -o -name '*.elc' -o -name 'ChangeLog*' \
326 -o -name 'README' \)`
328 ### Don't distribute site-init.el, site-load.el, or default.el.
329 for file in lisp/Makefile.in lisp/makefile.w32-in $files; do
330 case $file in
331 */site-init*|*/site-load*|*/default*) continue ;;
332 esac
333 ln $file $tempdir/$file
334 done
336 echo "Making links to \`leim' and its subdirectories"
337 (cd leim
338 ln makefile.w32-in ../${tempdir}/leim
339 ln ChangeLog README ../${tempdir}/leim
340 ln CXTERM-DIC/README CXTERM-DIC/*.tit ../${tempdir}/leim/CXTERM-DIC
341 ln SKK-DIC/README SKK-DIC/SKK-JISYO.L ../${tempdir}/leim/SKK-DIC
342 ln MISC-DIC/README MISC-DIC/*.* ../${tempdir}/leim/MISC-DIC
343 ln ja-dic/*.el ja-dic/*.elc ../${tempdir}/leim/ja-dic
344 ln Makefile.in ../${tempdir}/leim/Makefile.in
345 ln leim-ext.el ../${tempdir}/leim/leim-ext.el
346 ## Lisp files that start with a capital (also 4Corner.el) are
347 ## generated from TIT dictionaries so we don't distribute them.
348 ln quail/[a-z]*.el quail/[a-z]*.elc ../${tempdir}/leim/quail
349 rm -f ../${tempdir}/leim/quail/quick-b5.*
350 rm -f ../${tempdir}/leim/quail/quick-cns.*
351 rm -f ../${tempdir}/leim/quail/tsang-b5.*
352 rm -f ../${tempdir}/leim/quail/tsang-cns.*)
354 echo "Making links to \`build-aux'"
355 (cd build-aux
356 ln compile config.guess config.sub depcomp ../${tempdir}/build-aux
357 ln install-sh missing move-if-change update-subdirs ../${tempdir}/build-aux)
359 echo "Making links to \`build-aux/snippet'"
360 (cd build-aux/snippet
361 ln *.h ../../${tempdir}/build-aux/snippet)
363 echo "Making links to \`src'"
364 ### Don't distribute the configured versions of
365 ### config.in, paths.in, buildobj.h, or Makefile.in.
366 (cd src
367 echo " (It is ok if ln fails in some cases.)"
368 ln [a-zA-Z]*.[chm] ../${tempdir}/src
369 ln [a-zA-Z]*.in ../${tempdir}/src
370 ln [a-zA-Z]*.mk ../${tempdir}/src
371 ln README ChangeLog ChangeLog.*[0-9] ../${tempdir}/src
372 ln makefile.w32-in ../${tempdir}/src
373 ln .gdbinit .dbxinit ../${tempdir}/src
374 cd ../${tempdir}/src
375 rm -f globals.h config.h epaths.h Makefile buildobj.h)
377 echo "Making links to \`src/bitmaps'"
378 (cd src/bitmaps
379 ln README *.xbm ../../${tempdir}/src/bitmaps)
381 echo "Making links to \`lib'"
382 (snippet_h=`(cd build-aux/snippet && ls *.h)`
383 cd lib
384 ln [a-zA-Z]*.[ch] ../${tempdir}/lib
385 ln gnulib.mk Makefile.am Makefile.in makefile.w32-in ../${tempdir}/lib
386 cd ../${tempdir}/lib
387 script='/[*]/d; s/\.in\.h$/.h/'
388 rm -f `(echo "$snippet_h"; ls *.in.h) | sed "$script"`)
390 echo "Making links to \`lib-src'"
391 (cd lib-src
392 ln [a-zA-Z]*.[ch] ../${tempdir}/lib-src
393 ln ChangeLog Makefile.in README testfile ../${tempdir}/lib-src
394 ln grep-changelog rcs2log ../${tempdir}/lib-src
395 ln makefile.w32-in ../${tempdir}/lib-src)
397 echo "Making links to \`m4'"
398 (cd m4
399 ln *.m4 ../${tempdir}/m4)
401 echo "Making links to \`nt'"
402 (cd nt
403 ln emacs-x86.manifest emacs-x64.manifest emacs.rc ../${tempdir}/nt
404 ln config.nt emacsclient.rc emacs-src.tags ../${tempdir}/nt
405 ln nmake.defs gmake.defs subdirs.el [a-z]*.bat [a-z]*.[ch] ../${tempdir}/nt
406 ln Makefile.in gnulib.mk ../${tempdir}/nt
407 ln msysconfig.sh mingw-cfg.site epaths.nt INSTALL.MSYS ../${tempdir}/nt
408 ln ChangeLog INSTALL README README.W32 makefile.w32-in ../${tempdir}/nt)
410 echo "Making links to \`nt/inc' and its subdirectories"
411 for f in `find nt/inc -type f -name '[a-z]*.h'`; do
412 ln $f $tempdir/$f
413 done
415 echo "Making links to \`nt/icons'"
416 (cd nt/icons
417 ln README [a-z]*.ico ../../${tempdir}/nt/icons
418 ln [a-z]*.cur ../../${tempdir}/nt/icons)
420 echo "Making links to \`msdos'"
421 (cd msdos
422 ln ChangeLog INSTALL README emacs.ico emacs.pif ../${tempdir}/msdos
423 ln depfiles.bat inttypes.h ../${tempdir}/msdos
424 ln is_exec.c sigaction.c mainmake.v2 sed*.inp ../${tempdir}/msdos)
426 echo "Making links to \`nextstep'"
427 (cd nextstep
428 ln ChangeLog README INSTALL Makefile.in ../${tempdir}/nextstep)
430 echo "Making links to \`nextstep/templates'"
431 (cd nextstep/templates
432 ln Emacs.desktop.in Info-gnustep.plist.in Info.plist.in InfoPlist.strings.in ../../${tempdir}/nextstep/templates)
434 echo "Making links to \`nextstep/Cocoa/Emacs.base/Contents'"
435 (cd nextstep/Cocoa/Emacs.base/Contents
436 ln PkgInfo ../../../../${tempdir}/nextstep/Cocoa/Emacs.base/Contents)
438 echo "Making links to \`nextstep/Cocoa/Emacs.base/Contents/Resources'"
439 (cd nextstep/Cocoa/Emacs.base/Contents/Resources
440 ln Credits.html *.icns ../../../../../${tempdir}/nextstep/Cocoa/Emacs.base/Contents/Resources)
442 echo "Making links to \`nextstep/GNUstep/Emacs.base/Resources'"
443 (cd nextstep/GNUstep/Emacs.base/Resources
444 ln README emacs.tiff ../../../../${tempdir}/nextstep/GNUstep/Emacs.base/Resources )
446 echo "Making links to \`oldXMenu'"
447 (cd oldXMenu
448 ln *.[ch] *.in ../${tempdir}/oldXMenu
449 ln README ChangeLog ../${tempdir}/oldXMenu)
451 echo "Making links to \`lwlib'"
452 (cd lwlib
453 ln *.[ch] *.in ../${tempdir}/lwlib
454 ln README ChangeLog ../${tempdir}/lwlib)
456 echo "Making links to \`admin' and its subdirectories"
457 for f in `find admin -type f`; do
458 case $f in
459 admin/unidata/Makefile) continue ;;
460 esac
461 ln $f $tempdir/$f
462 done
464 if [ "$with_tests" = "yes" ]; then
465 echo "Making links to \`test' and its subdirectories"
466 for f in `find test -type f`; do
467 case $f in
468 test/automated/flymake/warnpred/a.out) continue ;;
469 test/automated/Makefile) continue ;;
470 esac
471 ln $f $tempdir/$f
472 done
475 echo "Making links to \`etc' and its subdirectories"
476 for f in `find etc -type f`; do
477 case $f in
478 etc/DOC*|etc/*.pyc) continue ;;
479 ## Arguably we should not exclude *.ps.
480 etc/refcards/*.aux|etc/refcards/*.dvi|etc/refcards/*.log|etc/refcards/*.ps)
481 continue ;;
482 esac
483 ln $f $tempdir/$f
484 done
486 echo "Making links to \`info'"
487 ln `find info -type f -print` ${tempdir}/info
489 echo "Making links to \`doc/emacs'"
490 (cd doc/emacs
491 ln *.texi *.in makefile.w32-in ChangeLog* ../../${tempdir}/doc/emacs)
493 echo "Making links to \`doc/misc'"
494 (cd doc/misc
495 ln *.texi *.tex *.in makefile.w32-in gnus-news.el ChangeLog* ../../${tempdir}/doc/misc)
497 echo "Making links to \`doc/lispref'"
498 (cd doc/lispref
499 ln *.texi *.in makefile.w32-in README ChangeLog* ../../${tempdir}/doc/lispref
500 ln spellfile ../../${tempdir}/doc/lispref
501 ln two-volume.make two-volume-cross-refs.txt ../../${tempdir}/doc/lispref)
503 echo "Making links to \`doc/lispintro'"
504 (cd doc/lispintro
505 ln *.texi *.in makefile.w32-in *.eps *.pdf ../../${tempdir}/doc/lispintro
506 ln README ChangeLog* ../../${tempdir}/doc/lispintro
507 cd ../../${tempdir}/doc/lispintro)
509 echo "Making links to \`doc/man'"
510 (cd doc/man
511 ln ChangeLog* *.1 ../../${tempdir}/doc/man
512 cd ../../${tempdir}/doc/man)
514 ### It would be nice if they could all be symlinks to top-level copy, but
515 ### you're not supposed to have any symlinks in distribution tar files.
516 echo "Making sure copying notices are all copies of \`COPYING'"
517 for subdir in . etc info leim lib lib-src lisp lwlib msdos nt src; do
518 rm -f ${tempdir}/${subdir}/COPYING
519 cp COPYING ${tempdir}/${subdir}
520 done
522 if [ "${newer}" ]; then
523 echo "Removing files older than $newer"
524 ## We remove .elc files unconditionally, on the theory that anyone picking
525 ## up an incremental distribution already has a running Emacs to byte-compile
526 ## them with.
527 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
530 ## Don't distribute backups, autosaves, etc.
531 echo "Removing unwanted files"
532 find ${tempparent} \( -name '*~' -o -name '#*#' -o -name '.*ignore' -o -name '=*' -o -name 'TAGS' \) -exec rm -f {} \;
534 if [ "${make_tar}" = yes ]; then
535 echo "Looking for $default_gzip"
536 found=0
537 temppath=`echo $PATH | sed -e 's/^:/.:/' -e 's/::/:.:/g' -e 's/:$/:./' \
538 -e 's/:/ /g'`
539 for dir in ${temppath}; do
540 [ -x ${dir}/$default_gzip ] || continue
541 found=1; break
542 done
543 if [ "$found" = "0" ]; then
544 echo "WARNING: \`$default_gzip' not found, will not compress" >&2
545 default_gzip=cat
547 case "${default_gzip}" in
548 bzip2) gzip_extension=.bz2 ;;
549 xz) gzip_extension=.xz ;;
550 gzip) gzip_extension=.gz ; default_gzip="gzip --best";;
551 *) gzip_extension= ;;
552 esac
553 echo "Creating tar file"
554 (cd ${tempparent} ; tar cvf - ${emacsname} ) \
555 | ${default_gzip} \
556 > ${emacsname}.tar${gzip_extension}
559 if [ "${clean_up}" != yes ]; then
560 (cd ${tempparent}; mv ${emacsname} ..)
561 rm -rf ${tempparent}
564 ### make-dist ends here