Fix IPv6 addresses in Tramp
[emacs.git] / make-dist
blob6bf01ffa11b0844311ada8bc1cd73bd9e3519159
1 #!/bin/sh
2 ### make-dist: create an Emacs distribution tar file from current srcdir
4 ## Copyright (C) 1995, 1997-1998, 2000-2015 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 ## Remove unnecessary restrictions on file access.
46 umask 022
48 update=yes
49 check=yes
50 clean_up=no
51 make_tar=no
52 default_gzip=gzip
53 newer=""
54 with_tests=no
55 changelog=yes
57 while [ $# -gt 0 ]; do
58 case "$1" in
59 ## This option tells make-dist to delete the staging directory
60 ## when done. It is useless to use this unless you make a tar file.
61 "--clean-up" )
62 clean_up=yes
64 ## This option tells make-dist to make a tar file.
65 "--tar" )
66 make_tar=yes
68 ## This option tells make-dist not to recompile or do analogous things.
69 "--no-update" )
70 update=no
72 ## This option says don't check for bad file names, etc.
73 "--no-check" )
74 check=no
76 "--no-changelog" )
77 changelog=no
79 ## This option tells make-dist to make the distribution normally, then
80 ## remove all files older than the given timestamp file. This is useful
81 ## for creating incremental or patch distributions.
82 "--newer")
83 newer="$2"
84 new_extension=".new"
85 shift
87 ## This option tells make-dist to use 'bzip2' instead of gzip.
88 "--bzip2")
89 default_gzip="bzip2"
91 ## Same with xz.
92 "--xz")
93 default_gzip="xz"
95 "--no-compress")
96 default_gzip="cat"
99 "--snapshot")
100 clean_up=yes
101 make_tar=yes
102 update=no
103 check=no
106 ## Include the test/ directory.
107 ## This option is mainly for the hydra build server.
108 "--tests")
109 with_tests=yes
112 "--help")
113 echo "Usage: ${progname} [options]"
114 echo ""
115 echo " --bzip2 use bzip2 instead of gzip"
116 echo " --clean-up delete staging directories when done"
117 echo " --xz use xz instead of gzip"
118 echo " --no-compress don't compress"
119 echo " --newer=TIME don't include files older than TIME"
120 echo " --no-check don't check for bad file names etc."
121 echo " --no-update don't recompile or do analogous things"
122 echo " --no-changelog don't generate the top-level ChangeLog"
123 echo " --snapshot same as --clean-up --no-update --tar --no-check"
124 echo " --tar make a tar file"
125 echo " --tests include the test/ directory"
126 echo ""
127 exit 0
131 echo "${progname}: Unrecognized argument: $1" >&2
132 exit 1
134 esac
135 shift
136 done
138 ### Make sure we're running in the right place.
139 if [ ! -d src -o ! -f src/lisp.h -o ! -d lisp -o ! -f lisp/subr.el ]; then
140 echo "${progname}: Can't find 'src/lisp.h' and 'lisp/subr.el'." >&2
141 echo "${progname} must be run in the top directory of the Emacs" >&2
142 echo "distribution tree. cd to that directory and try again." >&2
143 exit 1
146 ### Find where to run Emacs.
147 ### (Accept only absolute file names.)
148 if [ $update = yes ];
149 then
150 if [ -f src/emacs ];
151 then
152 EMACS=`pwd`/src/emacs
153 else
154 case $EMACS in
155 /*) ;;
157 if [ ! -f "$EMACS" ]; then
158 echo "$0: You must set the EMACS environment variable " \
159 "to an absolute file name." 2>&1
160 exit 1
161 fi;;
162 esac
166 ### Find out which version of Emacs this is.
167 version=`
168 sed -n 's/^AC_INIT(GNU Emacs,[ ]*\([^ ,)]*\).*/\1/p' <configure.ac
169 ` || version=
170 if [ ! "${version}" ]; then
171 echo "${progname}: can't find current Emacs version in './src/emacs.c'" >&2
172 exit 1
175 echo Version number is $version
177 if [ $update = yes ]; then
178 if ! grep -q "tree holds version *${version}" README; then
179 echo "WARNING: README has the wrong version number"
180 echo "Consider running M-x set-version from admin/admin.el"
181 sleep 5
185 ### Make sure we don't already have a directory emacs-${version}.
187 emacsname="emacs-${version}${new_extension}"
189 if [ -d ${emacsname} ]
190 then
191 echo Directory "${emacsname}" already exists >&2
192 exit 1
195 ### Make sure the subdirectory is available.
196 tempparent="make-dist.tmp.$$"
197 if [ -d ${tempparent} ]; then
198 echo "${progname}: staging directory '${tempparent}' already exists.
199 Perhaps a previous invocation of '${progname}' failed to clean up after
200 itself. Check that directories whose names are of the form
201 'make-dist.tmp.NNNNN' don't contain any important information, remove
202 them, and try again." >&2
203 exit 1
206 if [ $check = yes ]; then
207 ls -1 lisp/[a-zA-Z]*.el lisp/[a-z]*/[a-zA-Z0-9]*.el \
208 lisp/[a-z]*/[a-z]*/[a-zA-Z0-9]*.el \
209 lisp/[a-z]*/[a-z]*/[a-z]*/[a-zA-Z0-9]*.el > /tmp/el
211 ls -1 lisp/[a-zA-Z]*.elc lisp/[a-z]*/[a-zA-Z0-9]*.elc \
212 lisp/[a-z]*/[a-z]*/[a-zA-Z0-9]*.elc \
213 lisp/[a-z]*/[a-z]*/[a-z]*/[a-zA-Z0-9]*.elc > /tmp/elc
215 ## Check for .elc files with no corresponding .el file.
216 sed 's/\.el$/.elc/' /tmp/el > /tmp/elelc
218 bogosities=`comm -13 /tmp/elelc /tmp/elc`
219 if [ x"${bogosities}" != x"" ]; then
220 echo "The following .elc files have no corresponding .el files:"
221 echo "${bogosities}"
224 ### Check for .el files with no corresponding .elc file.
225 sed 's/\.elc$/.el/' /tmp/elc > /tmp/elcel
226 losers=`comm -23 /tmp/el /tmp/elcel`
228 rm -f /tmp/el /tmp/elc /tmp/elcel /tmp/elelc
230 bogosities=
231 for file in $losers; do
232 grep -q "no-byte-compile: t" $file && continue
233 case $file in
234 site-init.el | site-load.el | site-start.el | default.el) continue ;;
235 esac
237 bogosities="$file $bogosities"
239 done
240 if [ x"${bogosities}" != x"" ]; then
241 echo "The following .el files have no corresponding .elc files:"
242 echo "${bogosities}"
246 if [ $update = yes ]; then
248 ## Make sure configure is newer than configure.ac, etc.
249 ## It is better to let autoreconf do what is needed than
250 ## for us to try and duplicate all its checks.
251 echo "Running autoreconf"
252 autoreconf -i -I m4 || { x=$?; echo Autoreconf FAILED! >&2; exit $x; }
254 ## Make sure src/stamp-h.in is newer than configure.ac.
255 rm -f src/stamp-h.in
256 echo timestamp > src/stamp-h.in
258 echo "Updating Info files"
259 make info
261 echo "Updating finder, custom and autoload data"
262 (cd lisp && make updates EMACS="$EMACS")
264 echo "Updating leim-list.el"
265 (cd leim && make leim-list.el EMACS="$EMACS")
267 echo "Recompiling Lisp files"
268 $EMACS -batch -f batch-byte-recompile-directory lisp
269 fi # $update = yes
271 echo "Creating staging directory: '${tempparent}'"
273 mkdir ${tempparent}
274 tempdir="${tempparent}/${emacsname}"
276 ### This trap ensures that the staging directory will be cleaned up even
277 ### when the script is interrupted in mid-career.
278 if [ "${clean_up}" = yes ]; then
279 trap "echo 'Cleaning up the staging directory'; rm -rf ${tempparent}" EXIT
282 echo "Creating top directory: '${tempdir}'"
283 mkdir ${tempdir}
285 if [ "$changelog" = yes ]; then
286 if test -d .git; then
287 echo "Making top-level ChangeLog"
288 make ChangeLog CHANGELOG=${tempdir}/ChangeLog || \
289 { x=$?; echo "make ChangeLog FAILED (try --no-changelog?)" >&2; exit $x; }
290 else
291 echo "No repository, so omitting top-level ChangeLog"
295 ### We copy in the top-level files before creating the subdirectories in
296 ### hopes that this will make the top-level files appear first in the
297 ### tar file; this means that people can start reading the INSTALL and
298 ### README while the rest of the tar file is still unpacking. Whoopee.
299 echo "Making links to top-level files"
300 ln INSTALL README BUGS ${tempdir}
301 ln ChangeLog.*[0-9] Makefile.in autogen.sh configure configure.ac ${tempdir}
302 ln config.bat make-dist .dir-locals.el ${tempdir}
303 ln aclocal.m4 ${tempdir}
305 echo "Creating subdirectories"
306 for subdir in site-lisp \
307 leim leim/CXTERM-DIC leim/MISC-DIC leim/SKK-DIC \
308 build-aux build-aux/snippet \
309 src src/bitmaps lib lib-src oldXMenu lwlib \
310 nt nt/inc nt/inc/sys nt/inc/arpa nt/inc/netinet nt/icons \
311 `find etc lisp admin test -type d` \
312 doc doc/emacs doc/misc doc/man doc/lispref doc/lispintro \
313 info m4 msdos \
314 nextstep nextstep/templates \
315 nextstep/Cocoa nextstep/Cocoa/Emacs.base \
316 nextstep/Cocoa/Emacs.base/Contents \
317 nextstep/Cocoa/Emacs.base/Contents/Resources \
318 nextstep/GNUstep \
319 nextstep/GNUstep/Emacs.base \
320 nextstep/GNUstep/Emacs.base/Resources
323 if [ "$with_tests" != "yes" ]; then
324 case $subdir in
325 test*) continue ;;
326 esac
329 ## site-lisp for in-place installs (?).
330 [ "$subdir" = "site-lisp" ] || [ -d "$subdir" ] || \
331 echo "WARNING: $subdir not found, making anyway"
332 echo " ${tempdir}/${subdir}"
333 mkdir ${tempdir}/${subdir}
334 done
336 echo "Making links to 'lisp' and its subdirectories"
337 files=`find lisp \( -name '*.el' -o -name '*.elc' -o -name 'ChangeLog*' \
338 -o -name 'README' \)`
340 ### Don't distribute site-init.el, site-load.el, or default.el.
341 for file in lisp/Makefile.in lisp/makefile.w32-in $files; do
342 case $file in
343 */site-init*|*/site-load*|*/default*) continue ;;
344 esac
345 ln $file $tempdir/$file
346 done
348 echo "Making links to 'leim' and its subdirectories"
349 (cd leim
350 ln makefile.w32-in ../${tempdir}/leim
351 ln ChangeLog.*[0-9] README ../${tempdir}/leim
352 ln CXTERM-DIC/README CXTERM-DIC/*.tit ../${tempdir}/leim/CXTERM-DIC
353 ln SKK-DIC/README SKK-DIC/SKK-JISYO.L ../${tempdir}/leim/SKK-DIC
354 ln MISC-DIC/README MISC-DIC/*.* ../${tempdir}/leim/MISC-DIC
355 ln Makefile.in ../${tempdir}/leim/Makefile.in
356 ln leim-ext.el ../${tempdir}/leim/leim-ext.el)
358 ## FIXME Can we not just use the "find -type f" method for this one?
359 echo "Making links to 'build-aux'"
360 (cd build-aux
361 ln compile config.guess config.sub depcomp msys-to-w32 ../${tempdir}/build-aux
362 ln gitlog-to-changelog gitlog-to-emacslog ../${tempdir}/build-aux
363 ln install-sh missing move-if-change ../${tempdir}/build-aux
364 ln update-copyright update-subdirs ../${tempdir}/build-aux
365 ln dir_top make-info-dir ../${tempdir}/build-aux)
367 echo "Making links to 'build-aux/snippet'"
368 (cd build-aux/snippet
369 ln *.h ../../${tempdir}/build-aux/snippet)
371 echo "Making links to 'src'"
372 ### Don't distribute the configured versions of
373 ### config.in, paths.in, buildobj.h, or Makefile.in.
374 (cd src
375 echo " (It is ok if ln fails in some cases.)"
376 ln [a-zA-Z]*.[chm] ../${tempdir}/src
377 ln [a-zA-Z]*.in ../${tempdir}/src
378 ln deps.mk ../${tempdir}/src
379 ln README ChangeLog.*[0-9] ../${tempdir}/src
380 ln makefile.w32-in ../${tempdir}/src
381 ln .gdbinit .dbxinit ../${tempdir}/src
382 cd ../${tempdir}/src
383 rm -f globals.h config.h epaths.h Makefile buildobj.h)
385 echo "Making links to 'src/bitmaps'"
386 (cd src/bitmaps
387 ln README *.xbm ../../${tempdir}/src/bitmaps)
389 echo "Making links to 'lib'"
390 (snippet_h=`(cd build-aux/snippet && ls *.h)`
391 cd lib
392 ln [a-zA-Z]*.[ch] ../${tempdir}/lib
393 ln gnulib.mk Makefile.am Makefile.in makefile.w32-in ../${tempdir}/lib
394 cd ../${tempdir}/lib
395 script='/[*]/d; s/\.in\.h$/.h/'
396 rm -f `(echo "$snippet_h"; ls *.in.h) | sed "$script"`)
398 echo "Making links to 'lib-src'"
399 (cd lib-src
400 ln [a-zA-Z]*.[ch] ../${tempdir}/lib-src
401 ln ChangeLog.*[0-9] Makefile.in README ../${tempdir}/lib-src
402 ln rcs2log ../${tempdir}/lib-src
403 ln makefile.w32-in ../${tempdir}/lib-src
404 ln update-game-score.exe.manifest ../${tempdir}/lib-src)
406 echo "Making links to 'm4'"
407 (cd m4
408 ln *.m4 ../${tempdir}/m4)
410 echo "Making links to 'nt'"
411 (cd nt
412 ln emacs-x86.manifest emacs-x64.manifest ../${tempdir}/nt
413 ln config.nt emacs-src.tags ../${tempdir}/nt
414 ln nmake.defs gmake.defs subdirs.el [a-z]*.bat [a-z]*.[ch] ../${tempdir}/nt
415 ln *.in gnulib.mk ../${tempdir}/nt
416 ln mingw-cfg.site epaths.nt INSTALL.OLD ../${tempdir}/nt
417 ln ChangeLog.*[0-9] INSTALL README README.W32 makefile.w32-in ../${tempdir}/nt)
419 echo "Making links to 'nt/inc' and its subdirectories"
420 for f in `find nt/inc -type f -name '[a-z]*.h'`; do
421 ln $f $tempdir/$f
422 done
424 echo "Making links to 'nt/icons'"
425 (cd nt/icons
426 ln README [a-z]*.ico ../../${tempdir}/nt/icons
427 ln [a-z]*.cur ../../${tempdir}/nt/icons)
429 echo "Making links to 'msdos'"
430 (cd msdos
431 ln ChangeLog.*[0-9] INSTALL README emacs.ico emacs.pif ../${tempdir}/msdos
432 ln depfiles.bat inttypes.h ../${tempdir}/msdos
433 ln mainmake.v2 sed*.inp ../${tempdir}/msdos)
435 echo "Making links to 'nextstep'"
436 (cd nextstep
437 ln ChangeLog.*[0-9] README INSTALL Makefile.in ../${tempdir}/nextstep)
439 echo "Making links to 'nextstep/templates'"
440 (cd nextstep/templates
441 ln Emacs.desktop.in Info-gnustep.plist.in Info.plist.in InfoPlist.strings.in ../../${tempdir}/nextstep/templates)
443 echo "Making links to 'nextstep/Cocoa/Emacs.base/Contents'"
444 (cd nextstep/Cocoa/Emacs.base/Contents
445 ln PkgInfo ../../../../${tempdir}/nextstep/Cocoa/Emacs.base/Contents)
447 echo "Making links to 'nextstep/Cocoa/Emacs.base/Contents/Resources'"
448 (cd nextstep/Cocoa/Emacs.base/Contents/Resources
449 ln Credits.html *.icns ../../../../../${tempdir}/nextstep/Cocoa/Emacs.base/Contents/Resources)
451 echo "Making links to 'nextstep/GNUstep/Emacs.base/Resources'"
452 (cd nextstep/GNUstep/Emacs.base/Resources
453 ln README emacs.tiff ../../../../${tempdir}/nextstep/GNUstep/Emacs.base/Resources )
455 echo "Making links to 'oldXMenu'"
456 (cd oldXMenu
457 ln *.[ch] *.in *.mk ../${tempdir}/oldXMenu
458 ln README ChangeLog.*[0-9] ../${tempdir}/oldXMenu)
460 echo "Making links to 'lwlib'"
461 (cd lwlib
462 ln *.[ch] *.in *.mk ../${tempdir}/lwlib
463 ln README ChangeLog.*[0-9] ../${tempdir}/lwlib)
465 ## It is important to distribute admin/ because it contains sources
466 ## for generated lisp/international/uni-*.el files.
467 echo "Making links to 'admin' and its subdirectories"
468 for f in `find admin -type f`; do
469 case $f in
470 */Makefile) [ -f $f.in ] && continue ;;
471 esac
472 ln $f $tempdir/$f
473 done
475 if [ "$with_tests" = "yes" ]; then
476 echo "Making links to 'test' and its subdirectories"
477 for f in `find test -type f`; do
478 case $f in
479 test/automated/*.log) continue ;;
480 test/automated/flymake/warnpred/a.out) continue ;;
481 test/automated/Makefile) continue ;;
482 esac
483 ln $f $tempdir/$f
484 done
487 echo "Making links to 'etc' and its subdirectories"
488 for f in `find etc -type f`; do
489 case $f in
490 etc/DOC*|etc/*.pyc) continue ;;
491 ## Arguably we should not exclude *.ps.
492 etc/refcards/*.aux|etc/refcards/*.dvi|etc/refcards/*.log|etc/refcards/*.ps)
493 continue ;;
494 esac
495 ln $f $tempdir/$f
496 done
498 echo "Making links to 'info'"
499 ln `find info -type f -print` ${tempdir}/info
501 echo "Making links to 'doc/emacs'"
502 (cd doc/emacs
503 ln *.texi *.in makefile.w32-in ChangeLog.*[0-9] ../../${tempdir}/doc/emacs)
505 echo "Making links to 'doc/misc'"
506 (cd doc/misc
507 ln *.texi *.tex *.in makefile.w32-in gnus-news.el ChangeLog.*[0-9] \
508 ../../${tempdir}/doc/misc)
510 echo "Making links to 'doc/lispref'"
511 (cd doc/lispref
512 ln *.texi *.in makefile.w32-in README ChangeLog.*[0-9] \
513 ../../${tempdir}/doc/lispref
514 ln spellfile ../../${tempdir}/doc/lispref
515 ln two-volume.make two-volume-cross-refs.txt ../../${tempdir}/doc/lispref)
517 echo "Making links to 'doc/lispintro'"
518 (cd doc/lispintro
519 ln *.texi *.in makefile.w32-in *.eps *.pdf ../../${tempdir}/doc/lispintro
520 ln README ChangeLog.*[0-9] ../../${tempdir}/doc/lispintro
521 cd ../../${tempdir}/doc/lispintro)
523 echo "Making links to 'doc/man'"
524 (cd doc/man
525 ln *.*[0-9] *.in ../../${tempdir}/doc/man
526 cd ../../${tempdir}/doc/man
527 rm -f emacs.1)
529 ### It would be nice if they could all be symlinks to top-level copy, but
530 ### you're not supposed to have any symlinks in distribution tar files.
531 echo "Making sure copying notices are all copies of 'COPYING'"
532 for subdir in . etc leim lib lib-src lisp lwlib msdos nt src; do
533 rm -f ${tempdir}/${subdir}/COPYING
534 cp COPYING ${tempdir}/${subdir}
535 done
537 if [ "${newer}" ]; then
538 echo "Removing files older than $newer"
539 ## We remove .elc files unconditionally, on the theory that anyone picking
540 ## up an incremental distribution already has a running Emacs to byte-compile
541 ## them with.
542 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
545 ## Don't distribute backups, autosaves, etc.
546 echo "Removing unwanted files"
547 find ${tempparent} \( -name '*~' -o -name '#*#' -o -name '.*ignore' -o -name '=*' -o -name 'TAGS' \) -exec rm -f {} \;
549 if [ "${make_tar}" = yes ]; then
550 echo "Looking for $default_gzip"
551 found=0
552 temppath=`echo $PATH | sed -e 's/^:/.:/' -e 's/::/:.:/g' -e 's/:$/:./' \
553 -e 's/:/ /g'`
554 for dir in ${temppath}; do
555 [ -x ${dir}/$default_gzip ] || continue
556 found=1; break
557 done
558 if [ "$found" = "0" ]; then
559 echo "WARNING: '$default_gzip' not found, will not compress" >&2
560 default_gzip=cat
562 case "${default_gzip}" in
563 bzip2) gzip_extension=.bz2 ;;
564 xz) gzip_extension=.xz ;;
565 gzip) gzip_extension=.gz ; default_gzip="gzip --best";;
566 *) gzip_extension= ;;
567 esac
568 echo "Creating tar file"
569 (cd ${tempparent} ; tar cvf - ${emacsname} ) \
570 | ${default_gzip} \
571 > ${emacsname}.tar${gzip_extension}
574 if [ "${clean_up}" != yes ]; then
575 (cd ${tempparent}; mv ${emacsname} ..)
576 rm -rf ${tempparent}
579 ### make-dist ends here