2 ### make-dist: create an Emacs distribution tar file from current srcdir
4 ## Copyright (C) 1995, 1997-1998, 2000-2016 Free Software Foundation,
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/>.
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.
33 ### Exit if a command fails.
36 ### Print out each line we read, for debugging's sake.
43 export LANGUAGE LC_ALL LC_MESSAGES LANG
45 ## Remove unnecessary restrictions on file access.
57 while [ $# -gt 0 ]; do
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.
64 ## This option tells make-dist to make a tar file.
68 ## This option tells make-dist not to recompile or do analogous things.
72 ## This option says don't check for bad file names, etc.
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.
87 ## This option tells make-dist to use 'bzip2' instead of gzip.
106 ## Include the test/ directory.
107 ## This option is mainly for the hydra build server.
113 printf '%s\n' "Usage: ${progname} [options]"
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"
131 printf '%s\n' "${progname}: Unrecognized argument: $1" >&2
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 printf '%s\n' "${progname}: Can't find 'src/lisp.h' and 'lisp/subr.el'." >&2
141 printf '%s\n' "${progname} must be run in the top directory of the Emacs" >&2
142 printf '%s\n' "distribution tree. cd to that directory and try again." >&2
146 ### Find where to run Emacs.
147 ### (Accept only absolute file names.)
148 if [ $update = yes ];
152 EMACS
=`pwd`/src
/emacs
157 if [ ! -f "$EMACS" ]; then
158 printf '%s\n' "$0: You must set the EMACS environment variable " \
159 "to an absolute file name." 2>&1
166 ### Find out which version of Emacs this is.
168 sed -n 's/^AC_INIT(GNU Emacs,[ ]*\([^ ,)]*\).*/\1/p' <configure.ac
170 if [ ! "${version}" ]; then
172 "${progname}: can't find current Emacs version in './src/emacs.c'" >&2
176 echo Version number is
$version
178 if [ $update = yes ]; then
179 if ! grep -q "tree holds version *${version}" README
; then
180 echo "WARNING: README has the wrong version number"
181 echo "Consider running M-x set-version from admin/admin.el"
186 ### Make sure we don't already have a directory emacs-${version}.
188 emacsname
="emacs-${version}${new_extension}"
190 if [ -d ${emacsname} ]
192 echo Directory
"${emacsname}" already exists
>&2
196 ### Make sure the subdirectory is available.
197 tempparent
="make-dist.tmp.$$"
198 if [ -d ${tempparent} ]; then
199 printf '%s\n' "${progname}: staging directory '${tempparent}' already exists.
200 Perhaps a previous invocation of '${progname}' failed to clean up after
201 itself. Check that directories whose names are of the form
202 'make-dist.tmp.NNNNN' don't contain any important information, remove
203 them, and try again." >&2
207 if [ $check = yes ]; then
208 ls -1 lisp
/[a-zA-Z
]*.el lisp
/[a-z
]*/[a-zA-Z0-9
]*.el \
209 lisp
/[a-z
]*/[a-z
]*/[a-zA-Z0-9
]*.el \
210 lisp
/[a-z
]*/[a-z
]*/[a-z
]*/[a-zA-Z0-9
]*.el
> /tmp
/el
212 ls -1 lisp
/[a-zA-Z
]*.elc lisp
/[a-z
]*/[a-zA-Z0-9
]*.elc \
213 lisp
/[a-z
]*/[a-z
]*/[a-zA-Z0-9
]*.elc \
214 lisp
/[a-z
]*/[a-z
]*/[a-z
]*/[a-zA-Z0-9
]*.elc
> /tmp
/elc
216 ## Check for .elc files with no corresponding .el file.
217 sed 's/\.el$/.elc/' /tmp
/el
> /tmp
/elelc
219 bogosities
=`comm -13 /tmp/elelc /tmp/elc`
220 if [ x
"${bogosities}" != x
"" ]; then
221 echo "The following .elc files have no corresponding .el files:"
225 ### Check for .el files with no corresponding .elc file.
226 sed 's/\.elc$/.el/' /tmp
/elc
> /tmp
/elcel
227 losers
=`comm -23 /tmp/el /tmp/elcel`
229 rm -f /tmp
/el
/tmp
/elc
/tmp
/elcel
/tmp
/elelc
232 for file in $losers; do
233 grep -q "no-byte-compile: t" $file && continue
235 site-init.el | site-load.el | site-start.el | default.el
) continue ;;
238 bogosities
="$file $bogosities"
241 if [ x
"${bogosities}" != x
"" ]; then
242 echo "The following .el files have no corresponding .elc files:"
247 if [ $update = yes ]; then
249 ## Make sure configure is newer than configure.ac, etc.
250 ## It is better to let autoreconf do what is needed than
251 ## for us to try and duplicate all its checks.
252 echo "Running autoreconf"
253 autoreconf
-i -I m4 ||
{ x
=$?
; echo Autoreconf FAILED
! >&2; exit $x; }
255 ## Make sure src/stamp-h.in is newer than configure.ac.
257 echo timestamp
> src
/stamp-h.
in
259 echo "Updating Info files"
262 echo "Updating finder, custom and autoload data"
263 (cd lisp
&& make updates EMACS
="$EMACS")
265 echo "Updating leim-list.el"
266 (cd leim
&& make leim-list.el EMACS
="$EMACS")
268 echo "Recompiling Lisp files"
269 $EMACS -batch -f batch-byte-recompile-directory lisp
272 echo "Creating staging directory: '${tempparent}'"
275 tempdir
="${tempparent}/${emacsname}"
277 ### This trap ensures that the staging directory will be cleaned up even
278 ### when the script is interrupted in mid-career.
279 if [ "${clean_up}" = yes ]; then
280 trap "echo 'Cleaning up the staging directory'; rm -rf ${tempparent}" EXIT
283 echo "Creating top directory: '${tempdir}'"
286 if [ "$changelog" = yes ]; then
287 if test -e .git
; then
288 echo "Making top-level ChangeLog"
289 make ChangeLog CHANGELOG
=${tempdir}/ChangeLog || \
290 { x
=$?
; echo "make ChangeLog FAILED (try --no-changelog?)" >&2; exit $x; }
292 echo "No repository, so omitting top-level ChangeLog"
296 ### We copy in the top-level files before creating the subdirectories in
297 ### hopes that this will make the top-level files appear first in the
298 ### tar file; this means that people can start reading the INSTALL and
299 ### README while the rest of the tar file is still unpacking. Whoopee.
300 echo "Making links to top-level files"
301 ln INSTALL README BUGS
${tempdir}
302 ln ChangeLog.
*[0-9] Makefile.
in autogen.sh configure configure.ac
${tempdir}
303 ln config.bat make-dist .dir-locals.el
${tempdir}
304 ln aclocal.
m4 CONTRIBUTE
${tempdir}
306 echo "Creating subdirectories"
307 for subdir
in site-lisp \
308 leim leim
/CXTERM-DIC leim
/MISC-DIC leim
/SKK-DIC \
309 build-aux build-aux
/snippet \
310 src src
/bitmaps lib lib-src oldXMenu lwlib \
311 nt nt
/inc nt
/inc
/sys nt
/inc
/arpa nt
/inc
/netinet nt
/icons \
312 `find etc lisp admin test -type d` \
313 doc
doc
/emacs
doc
/misc
doc
/man
doc
/lispref
doc
/lispintro \
314 info
m4 modules modules
/mod-test msdos \
315 nextstep nextstep
/templates \
316 nextstep
/Cocoa nextstep
/Cocoa
/Emacs.base \
317 nextstep
/Cocoa
/Emacs.base
/Contents \
318 nextstep
/Cocoa
/Emacs.base
/Contents
/Resources \
320 nextstep
/GNUstep
/Emacs.base \
321 nextstep
/GNUstep
/Emacs.base
/Resources
324 if [ "$with_tests" != "yes" ]; then
326 test*|
*/mod-test
*) continue ;;
330 ## site-lisp for in-place installs (?).
331 [ "$subdir" = "site-lisp" ] ||
[ -d "$subdir" ] || \
332 echo "WARNING: $subdir not found, making anyway"
333 echo " ${tempdir}/${subdir}"
334 mkdir
${tempdir}/${subdir}
337 echo "Making links to 'lisp' and its subdirectories"
338 files
=`find lisp \( -name '*.el' -o -name '*.elc' -o -name 'ChangeLog*' \
339 -o -name 'README' \)`
341 ### Don't distribute site-init.el, site-load.el, or default.el.
342 for file in lisp
/Makefile.
in $files; do
344 */site-init
*|
*/site-load
*|
*/default
*) continue ;;
346 ln $file $tempdir/$file
349 echo "Making links to 'leim' and its subdirectories"
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'"
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 ar-lib ..
/${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.
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 .gdbinit .dbxinit ..
/${tempdir}/src
382 rm -f globals.h config.h epaths.h Makefile buildobj.h
)
384 echo "Making links to 'src/bitmaps'"
386 ln README
*.xbm ..
/..
/${tempdir}/src
/bitmaps
)
388 echo "Making links to 'lib'"
389 (snippet_h
=`(cd build-aux/snippet && ls *.h)`
391 ln [a-zA-Z
]*.
[ch
] ..
/${tempdir}/lib
392 ln gnulib.mk Makefile.am Makefile.
in ..
/${tempdir}/lib
394 script='/[*]/d; s/\.in\.h$/.h/'
395 rm -f `(echo "$snippet_h"; ls *.in.h) | sed "$script"`)
397 echo "Making links to 'lib-src'"
399 ln [a-zA-Z
]*.
[ch
] ..
/${tempdir}/lib-src
400 ln ChangeLog.
*[0-9] Makefile.
in README ..
/${tempdir}/lib-src
401 ln rcs2log ..
/${tempdir}/lib-src
402 ln update-game-score.exe.manifest ..
/${tempdir}/lib-src
)
404 echo "Making links to 'm4'"
406 ln *.
m4 ..
/${tempdir}/m4)
408 echo "Making links to 'modules'"
410 ln *.py ..
/${tempdir}/modules
411 if [ "$with_tests" = "yes" ]; then
412 for f
in `find mod-test -type f`; do
414 *.log|
*.o|
*.so
) continue ;;
416 ln $f ..
/$tempdir/modules
/$f
421 echo "Making links to 'nt'"
423 ln emacs-x86.manifest emacs-x64.manifest ..
/${tempdir}/nt
424 ln [a-z
]*.bat
[a-z
]*.
[ch
] ..
/${tempdir}/nt
425 ln *.
in gnulib.mk ..
/${tempdir}/nt
426 ln mingw-cfg.site epaths.nt INSTALL.W64 ..
/${tempdir}/nt
427 ln ChangeLog.
*[0-9] INSTALL README README.W32 ..
/${tempdir}/nt
)
429 echo "Making links to 'nt/inc' and its subdirectories"
430 for f
in `find nt/inc -type f -name '[a-z]*.h'`; do
434 echo "Making links to 'nt/icons'"
436 ln README
[a-z
]*.ico ..
/..
/${tempdir}/nt
/icons
437 ln [a-z
]*.cur ..
/..
/${tempdir}/nt
/icons
)
439 echo "Making links to 'msdos'"
441 ln ChangeLog.
*[0-9] INSTALL README emacs.ico emacs.pif ..
/${tempdir}/msdos
442 ln depfiles.bat inttypes.h ..
/${tempdir}/msdos
443 ln mainmake.v2
sed*.inp ..
/${tempdir}/msdos
)
445 echo "Making links to 'nextstep'"
447 ln ChangeLog.
*[0-9] README INSTALL Makefile.
in ..
/${tempdir}/nextstep
)
449 echo "Making links to 'nextstep/templates'"
450 (cd nextstep
/templates
451 ln Emacs.desktop.
in Info-gnustep.plist.
in Info.plist.
in InfoPlist.
strings.
in ..
/..
/${tempdir}/nextstep
/templates
)
453 echo "Making links to 'nextstep/Cocoa/Emacs.base/Contents'"
454 (cd nextstep
/Cocoa
/Emacs.base
/Contents
455 ln PkgInfo ..
/..
/..
/..
/${tempdir}/nextstep
/Cocoa
/Emacs.base
/Contents
)
457 echo "Making links to 'nextstep/Cocoa/Emacs.base/Contents/Resources'"
458 (cd nextstep
/Cocoa
/Emacs.base
/Contents
/Resources
459 ln Credits.html
*.icns ..
/..
/..
/..
/..
/${tempdir}/nextstep
/Cocoa
/Emacs.base
/Contents
/Resources
)
461 echo "Making links to 'nextstep/GNUstep/Emacs.base/Resources'"
462 (cd nextstep
/GNUstep
/Emacs.base
/Resources
463 ln README emacs.tiff ..
/..
/..
/..
/${tempdir}/nextstep
/GNUstep
/Emacs.base
/Resources
)
465 echo "Making links to 'oldXMenu'"
467 ln *.
[ch
] *.
in *.mk ..
/${tempdir}/oldXMenu
468 ln README ChangeLog.
*[0-9] ..
/${tempdir}/oldXMenu
)
470 echo "Making links to 'lwlib'"
472 ln *.
[ch
] *.
in *.mk ..
/${tempdir}/lwlib
473 ln README ChangeLog.
*[0-9] ..
/${tempdir}/lwlib
)
475 ## It is important to distribute admin/ because it contains sources
476 ## for generated lisp/international/uni-*.el files.
477 echo "Making links to 'admin' and its subdirectories"
478 for f
in `find admin -type f`; do
480 */Makefile
) [ -f $f.
in ] && continue ;;
485 if [ "$with_tests" = "yes" ]; then
486 echo "Making links to 'test' and its subdirectories"
487 for f
in `find test -type f`; do
489 test
/automated
/*.log
) continue ;;
490 test
/automated
/flymake
/warnpred
/a.out
) continue ;;
491 test
/automated
/Makefile
) continue ;;
497 echo "Making links to 'etc' and its subdirectories"
498 for f
in `find etc -type f`; do
500 etc
/DOC
*|etc
/*.pyc
) continue ;;
501 ## Arguably we should not exclude *.ps.
502 etc
/refcards
/*.aux|etc
/refcards
/*.dvi|etc
/refcards
/*.log|etc
/refcards
/*.ps
)
508 echo "Making links to 'info'"
509 ln `find info -type f -print` ${tempdir}/info
511 echo "Making links to 'doc/emacs'"
513 ln *.texi
*.
in ChangeLog.
*[0-9] ..
/..
/${tempdir}/doc
/emacs
)
515 echo "Making links to 'doc/misc'"
517 ln *.texi
*.tex
*.
in gnus-news.el ChangeLog.
*[0-9] \
518 ..
/..
/${tempdir}/doc
/misc
)
520 echo "Making links to 'doc/lispref'"
522 ln *.texi
*.
in README ChangeLog.
*[0-9] ..
/..
/${tempdir}/doc
/lispref
523 ln spellfile ..
/..
/${tempdir}/doc
/lispref
524 ln two-volume.
make two-volume-cross-refs.txt ..
/..
/${tempdir}/doc
/lispref
)
526 echo "Making links to 'doc/lispintro'"
528 ln *.texi
*.
in *.eps
*.pdf ..
/..
/${tempdir}/doc
/lispintro
529 ln README ChangeLog.
*[0-9] ..
/..
/${tempdir}/doc
/lispintro
530 cd ..
/..
/${tempdir}/doc
/lispintro
)
532 echo "Making links to 'doc/man'"
534 ln *.
*[0-9] *.
in ..
/..
/${tempdir}/doc
/man
535 cd ..
/..
/${tempdir}/doc
/man
538 ### It would be nice if they could all be symlinks to top-level copy, but
539 ### you're not supposed to have any symlinks in distribution tar files.
540 echo "Making sure copying notices are all copies of 'COPYING'"
541 for subdir
in . etc leim lib lib-src lisp lwlib msdos nt src
; do
542 rm -f ${tempdir}/${subdir}/COPYING
543 cp COPYING
${tempdir}/${subdir}
546 if [ "${newer}" ]; then
547 printf '%s\n' "Removing files older than $newer"
548 ## We remove .elc files unconditionally, on the theory that anyone picking
549 ## up an incremental distribution already has a running Emacs to byte-compile
551 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \
;
554 ## Don't distribute backups, autosaves, etc.
555 echo "Removing unwanted files"
556 find ${tempparent} \
( -name '*~' -o -name '#*#' -o -name '.*ignore' -o -name '=*' -o -name 'TAGS' \
) -exec rm -f {} \
;
558 if [ "${make_tar}" = yes ]; then
559 echo "Looking for $default_gzip"
561 temppath
=`printf '%s\n' "$PATH" |
562 sed -e 's/^:/.:/' -e 's/::/:.:/g' -e 's/:$/:./' -e 's/:/ /g'
564 for dir
in ${temppath}; do
565 [ -x ${dir}/$default_gzip ] ||
continue
568 if [ "$found" = "0" ]; then
569 echo "WARNING: '$default_gzip' not found, will not compress" >&2
572 case "${default_gzip}" in
573 bzip2) gzip_extension
=.bz2
;;
574 xz
) gzip_extension
=.xz
;;
575 gzip) gzip_extension
=.gz
; default_gzip
="gzip --best";;
576 *) gzip_extension
= ;;
578 echo "Creating tar file"
579 (cd ${tempparent} ; tar cvf
- ${emacsname} ) \
581 > ${emacsname}.
tar${gzip_extension}
584 if [ "${clean_up}" != yes ]; then
585 (cd ${tempparent}; mv ${emacsname} ..
)
589 ### make-dist ends here