Add xref-pulse-on-jump
[emacs.git] / make-dist
blob441070fd7c096a186a5246861718e0fe5acf61d1
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
56 while [ $# -gt 0 ]; do
57 case "$1" in
58 ## This option tells make-dist to delete the staging directory
59 ## when done. It is useless to use this unless you make a tar file.
60 "--clean-up" )
61 clean_up=yes
63 ## This option tells make-dist to make a tar file.
64 "--tar" )
65 make_tar=yes
67 ## This option tells make-dist not to recompile or do analogous things.
68 "--no-update" )
69 update=no
71 ## This option says don't check for bad file names, etc.
72 "--no-check" )
73 check=no
75 ## This option tells make-dist to make the distribution normally, then
76 ## remove all files older than the given timestamp file. This is useful
77 ## for creating incremental or patch distributions.
78 "--newer")
79 newer="$2"
80 new_extension=".new"
81 shift
83 ## This option tells make-dist to use 'bzip2' instead of gzip.
84 "--bzip2")
85 default_gzip="bzip2"
87 ## Same with xz.
88 "--xz")
89 default_gzip="xz"
91 "--no-compress")
92 default_gzip="cat"
95 "--snapshot")
96 clean_up=yes
97 make_tar=yes
98 update=no
99 check=no
102 ## Include the test/ directory.
103 ## This option is mainly for the hydra build server.
104 "--tests")
105 with_tests=yes
108 "--help")
109 echo "Usage: ${progname} [options]"
110 echo ""
111 echo " --bzip2 use bzip2 instead of gzip"
112 echo " --clean-up delete staging directories when done"
113 echo " --xz use xz instead of gzip"
114 echo " --no-compress don't compress"
115 echo " --newer=TIME don't include files older than TIME"
116 echo " --no-check don't check for bad file names etc."
117 echo " --no-update don't recompile or do analogous things"
118 echo " --snapshot same as --clean-up --no-update --tar --no-check"
119 echo " --tar make a tar file"
120 echo " --tests include the test/ directory"
121 echo ""
122 exit 0
126 echo "${progname}: Unrecognized argument: $1" >&2
127 exit 1
129 esac
130 shift
131 done
133 ### Make sure we're running in the right place.
134 if [ ! -d src -o ! -f src/lisp.h -o ! -d lisp -o ! -f lisp/subr.el ]; then
135 echo "${progname}: Can't find 'src/lisp.h' and 'lisp/subr.el'." >&2
136 echo "${progname} must be run in the top directory of the Emacs" >&2
137 echo "distribution tree. cd to that directory and try again." >&2
138 exit 1
141 ### Find where to run Emacs.
142 ### (Accept only absolute file names.)
143 if [ $update = yes ];
144 then
145 if [ -f src/emacs ];
146 then
147 EMACS=`pwd`/src/emacs
148 else
149 case $EMACS in
150 /*) ;;
152 if [ ! -f "$EMACS" ]; then
153 echo "$0: You must set the EMACS environment variable " \
154 "to an absolute file name." 2>&1
155 exit 1
156 fi;;
157 esac
161 ### Find out which version of Emacs this is.
162 version=`
163 sed -n 's/^AC_INIT(GNU Emacs,[ ]*\([^ ,)]*\).*/\1/p' <configure.ac
164 ` || version=
165 if [ ! "${version}" ]; then
166 echo "${progname}: can't find current Emacs version in './src/emacs.c'" >&2
167 exit 1
170 echo Version number is $version
172 if [ $update = yes ]; then
173 if ! grep -q "tree holds version *${version}" README; then
174 echo "WARNING: README has 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 > /tmp/el
206 ls -1 lisp/[a-zA-Z]*.elc lisp/[a-z]*/[a-zA-Z0-9]*.elc \
207 lisp/[a-z]*/[a-z]*/[a-zA-Z0-9]*.elc \
208 lisp/[a-z]*/[a-z]*/[a-z]*/[a-zA-Z0-9]*.elc > /tmp/elc
210 ## Check for .elc files with no corresponding .el file.
211 sed 's/\.el$/.elc/' /tmp/el > /tmp/elelc
213 bogosities=`comm -13 /tmp/elelc /tmp/elc`
214 if [ x"${bogosities}" != x"" ]; then
215 echo "The following .elc files have no corresponding .el files:"
216 echo "${bogosities}"
219 ### Check for .el files with no corresponding .elc file.
220 sed 's/\.elc$/.el/' /tmp/elc > /tmp/elcel
221 losers=`comm -23 /tmp/el /tmp/elcel`
223 rm -f /tmp/el /tmp/elc /tmp/elcel /tmp/elelc
225 bogosities=
226 for file in $losers; do
227 grep -q "no-byte-compile: t" $file && continue
228 case $file in
229 site-init.el | site-load.el | site-start.el | default.el) continue ;;
230 esac
232 bogosities="$file $bogosities"
234 done
235 if [ x"${bogosities}" != x"" ]; then
236 echo "The following .el files have no corresponding .elc files:"
237 echo "${bogosities}"
241 if [ $update = yes ]; then
243 ## Make sure configure is newer than configure.ac, etc.
244 ## It is better to let autoreconf do what is needed than
245 ## for us to try and duplicate all its checks.
246 echo "Running autoreconf"
247 autoreconf -i -I m4 || { x=$?; echo Autoreconf FAILED! >&2; exit $x; }
249 ## Make sure src/stamp-h.in is newer than configure.ac.
250 rm -f src/stamp-h.in
251 echo timestamp > src/stamp-h.in
253 echo "Updating Info files"
254 make info
256 echo "Updating finder, custom and autoload data"
257 (cd lisp && make updates EMACS="$EMACS")
259 echo "Updating leim-list.el"
260 (cd leim && make leim-list.el EMACS="$EMACS")
262 echo "Recompiling Lisp files"
263 $EMACS -batch -f batch-byte-recompile-directory lisp
264 fi # $update = yes
266 echo "Creating staging directory: '${tempparent}'"
268 mkdir ${tempparent}
269 tempdir="${tempparent}/${emacsname}"
271 ### This trap ensures that the staging directory will be cleaned up even
272 ### when the script is interrupted in mid-career.
273 if [ "${clean_up}" = yes ]; then
274 trap "echo 'Cleaning up the staging directory'; rm -rf ${tempparent}" EXIT
277 echo "Creating top directory: '${tempdir}'"
278 mkdir ${tempdir}
280 if test -d .git; then
281 echo "Making top-level ChangeLog"
282 make distprefix=${tempdir}/ ChangeLog
283 else
284 echo "No repository, so omitting top-level ChangeLog"
287 ### We copy in the top-level files before creating the subdirectories in
288 ### hopes that this will make the top-level files appear first in the
289 ### tar file; this means that people can start reading the INSTALL and
290 ### README while the rest of the tar file is still unpacking. Whoopee.
291 echo "Making links to top-level files"
292 ln INSTALL README BUGS ${tempdir}
293 ln ChangeLog.*[0-9] Makefile.in autogen.sh configure configure.ac ${tempdir}
294 ln config.bat make-dist .dir-locals.el ${tempdir}
295 ln aclocal.m4 ${tempdir}
297 echo "Creating subdirectories"
298 for subdir in site-lisp \
299 leim leim/CXTERM-DIC leim/MISC-DIC leim/SKK-DIC \
300 build-aux build-aux/snippet \
301 src src/bitmaps lib lib-src oldXMenu lwlib \
302 nt nt/inc nt/inc/sys nt/inc/arpa nt/inc/netinet nt/icons \
303 `find etc lisp admin test -type d` \
304 doc doc/emacs doc/misc doc/man doc/lispref doc/lispintro \
305 info m4 msdos \
306 nextstep nextstep/templates \
307 nextstep/Cocoa nextstep/Cocoa/Emacs.base \
308 nextstep/Cocoa/Emacs.base/Contents \
309 nextstep/Cocoa/Emacs.base/Contents/Resources \
310 nextstep/GNUstep \
311 nextstep/GNUstep/Emacs.base \
312 nextstep/GNUstep/Emacs.base/Resources
315 if [ "$with_tests" != "yes" ]; then
316 case $subdir in
317 test*) continue ;;
318 esac
321 ## site-lisp for in-place installs (?).
322 [ "$subdir" = "site-lisp" ] || [ -d "$subdir" ] || \
323 echo "WARNING: $subdir not found, making anyway"
324 echo " ${tempdir}/${subdir}"
325 mkdir ${tempdir}/${subdir}
326 done
328 echo "Making links to 'lisp' and its subdirectories"
329 files=`find lisp \( -name '*.el' -o -name '*.elc' -o -name 'ChangeLog*' \
330 -o -name 'README' \)`
332 ### Don't distribute site-init.el, site-load.el, or default.el.
333 for file in lisp/Makefile.in lisp/makefile.w32-in $files; do
334 case $file in
335 */site-init*|*/site-load*|*/default*) continue ;;
336 esac
337 ln $file $tempdir/$file
338 done
340 echo "Making links to 'leim' and its subdirectories"
341 (cd leim
342 ln makefile.w32-in ../${tempdir}/leim
343 ln ChangeLog.*[0-9] README ../${tempdir}/leim
344 ln CXTERM-DIC/README CXTERM-DIC/*.tit ../${tempdir}/leim/CXTERM-DIC
345 ln SKK-DIC/README SKK-DIC/SKK-JISYO.L ../${tempdir}/leim/SKK-DIC
346 ln MISC-DIC/README MISC-DIC/*.* ../${tempdir}/leim/MISC-DIC
347 ln Makefile.in ../${tempdir}/leim/Makefile.in
348 ln leim-ext.el ../${tempdir}/leim/leim-ext.el)
350 ## FIXME Can we not just use the "find -type f" method for this one?
351 echo "Making links to 'build-aux'"
352 (cd build-aux
353 ln compile config.guess config.sub depcomp msys-to-w32 ../${tempdir}/build-aux
354 ln gitlog-to-changelog gitlog-to-emacslog ../${tempdir}/build-aux
355 ln install-sh missing move-if-change ../${tempdir}/build-aux
356 ln update-copyright update-subdirs ../${tempdir}/build-aux
357 ln dir_top make-info-dir ../${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.*[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.*[0-9] Makefile.in README ../${tempdir}/lib-src
394 ln rcs2log ../${tempdir}/lib-src
395 ln makefile.w32-in ../${tempdir}/lib-src
396 ln update-game-score.exe.manifest ../${tempdir}/lib-src)
398 echo "Making links to 'm4'"
399 (cd m4
400 ln *.m4 ../${tempdir}/m4)
402 echo "Making links to 'nt'"
403 (cd nt
404 ln emacs-x86.manifest emacs-x64.manifest ../${tempdir}/nt
405 ln config.nt emacs-src.tags ../${tempdir}/nt
406 ln nmake.defs gmake.defs subdirs.el [a-z]*.bat [a-z]*.[ch] ../${tempdir}/nt
407 ln *.in gnulib.mk ../${tempdir}/nt
408 ln mingw-cfg.site epaths.nt INSTALL.OLD ../${tempdir}/nt
409 ln ChangeLog.*[0-9] INSTALL README README.W32 makefile.w32-in ../${tempdir}/nt)
411 echo "Making links to 'nt/inc' and its subdirectories"
412 for f in `find nt/inc -type f -name '[a-z]*.h'`; do
413 ln $f $tempdir/$f
414 done
416 echo "Making links to 'nt/icons'"
417 (cd nt/icons
418 ln README [a-z]*.ico ../../${tempdir}/nt/icons
419 ln [a-z]*.cur ../../${tempdir}/nt/icons)
421 echo "Making links to 'msdos'"
422 (cd msdos
423 ln ChangeLog.*[0-9] INSTALL README emacs.ico emacs.pif ../${tempdir}/msdos
424 ln depfiles.bat inttypes.h ../${tempdir}/msdos
425 ln mainmake.v2 sed*.inp ../${tempdir}/msdos)
427 echo "Making links to 'nextstep'"
428 (cd nextstep
429 ln ChangeLog.*[0-9] README INSTALL Makefile.in ../${tempdir}/nextstep)
431 echo "Making links to 'nextstep/templates'"
432 (cd nextstep/templates
433 ln Emacs.desktop.in Info-gnustep.plist.in Info.plist.in InfoPlist.strings.in ../../${tempdir}/nextstep/templates)
435 echo "Making links to 'nextstep/Cocoa/Emacs.base/Contents'"
436 (cd nextstep/Cocoa/Emacs.base/Contents
437 ln PkgInfo ../../../../${tempdir}/nextstep/Cocoa/Emacs.base/Contents)
439 echo "Making links to 'nextstep/Cocoa/Emacs.base/Contents/Resources'"
440 (cd nextstep/Cocoa/Emacs.base/Contents/Resources
441 ln Credits.html *.icns ../../../../../${tempdir}/nextstep/Cocoa/Emacs.base/Contents/Resources)
443 echo "Making links to 'nextstep/GNUstep/Emacs.base/Resources'"
444 (cd nextstep/GNUstep/Emacs.base/Resources
445 ln README emacs.tiff ../../../../${tempdir}/nextstep/GNUstep/Emacs.base/Resources )
447 echo "Making links to 'oldXMenu'"
448 (cd oldXMenu
449 ln *.[ch] *.in *.mk ../${tempdir}/oldXMenu
450 ln README ChangeLog.*[0-9] ../${tempdir}/oldXMenu)
452 echo "Making links to 'lwlib'"
453 (cd lwlib
454 ln *.[ch] *.in *.mk ../${tempdir}/lwlib
455 ln README ChangeLog.*[0-9] ../${tempdir}/lwlib)
457 ## It is important to distribute admin/ because it contains sources
458 ## for generated lisp/international/uni-*.el files.
459 echo "Making links to 'admin' and its subdirectories"
460 for f in `find admin -type f`; do
461 case $f in
462 */Makefile) [ -f $f.in ] && continue ;;
463 esac
464 ln $f $tempdir/$f
465 done
467 if [ "$with_tests" = "yes" ]; then
468 echo "Making links to 'test' and its subdirectories"
469 for f in `find test -type f`; do
470 case $f in
471 test/automated/*.log) continue ;;
472 test/automated/flymake/warnpred/a.out) continue ;;
473 test/automated/Makefile) continue ;;
474 esac
475 ln $f $tempdir/$f
476 done
479 echo "Making links to 'etc' and its subdirectories"
480 for f in `find etc -type f`; do
481 case $f in
482 etc/DOC*|etc/*.pyc) continue ;;
483 ## Arguably we should not exclude *.ps.
484 etc/refcards/*.aux|etc/refcards/*.dvi|etc/refcards/*.log|etc/refcards/*.ps)
485 continue ;;
486 esac
487 ln $f $tempdir/$f
488 done
490 echo "Making links to 'info'"
491 ln `find info -type f -print` ${tempdir}/info
493 echo "Making links to 'doc/emacs'"
494 (cd doc/emacs
495 ln *.texi *.in makefile.w32-in ChangeLog.*[0-9] ../../${tempdir}/doc/emacs)
497 echo "Making links to 'doc/misc'"
498 (cd doc/misc
499 ln *.texi *.tex *.in makefile.w32-in gnus-news.el ChangeLog.*[0-9] \
500 ../../${tempdir}/doc/misc)
502 echo "Making links to 'doc/lispref'"
503 (cd doc/lispref
504 ln *.texi *.in makefile.w32-in README ChangeLog.*[0-9] \
505 ../../${tempdir}/doc/lispref
506 ln spellfile ../../${tempdir}/doc/lispref
507 ln two-volume.make two-volume-cross-refs.txt ../../${tempdir}/doc/lispref)
509 echo "Making links to 'doc/lispintro'"
510 (cd doc/lispintro
511 ln *.texi *.in makefile.w32-in *.eps *.pdf ../../${tempdir}/doc/lispintro
512 ln README ChangeLog.*[0-9] ../../${tempdir}/doc/lispintro
513 cd ../../${tempdir}/doc/lispintro)
515 echo "Making links to 'doc/man'"
516 (cd doc/man
517 ln *.*[0-9] *.in ../../${tempdir}/doc/man
518 cd ../../${tempdir}/doc/man
519 rm -f emacs.1)
521 ### It would be nice if they could all be symlinks to top-level copy, but
522 ### you're not supposed to have any symlinks in distribution tar files.
523 echo "Making sure copying notices are all copies of 'COPYING'"
524 for subdir in . etc leim lib lib-src lisp lwlib msdos nt src; do
525 rm -f ${tempdir}/${subdir}/COPYING
526 cp COPYING ${tempdir}/${subdir}
527 done
529 if [ "${newer}" ]; then
530 echo "Removing files older than $newer"
531 ## We remove .elc files unconditionally, on the theory that anyone picking
532 ## up an incremental distribution already has a running Emacs to byte-compile
533 ## them with.
534 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
537 ## Don't distribute backups, autosaves, etc.
538 echo "Removing unwanted files"
539 find ${tempparent} \( -name '*~' -o -name '#*#' -o -name '.*ignore' -o -name '=*' -o -name 'TAGS' \) -exec rm -f {} \;
541 if [ "${make_tar}" = yes ]; then
542 echo "Looking for $default_gzip"
543 found=0
544 temppath=`echo $PATH | sed -e 's/^:/.:/' -e 's/::/:.:/g' -e 's/:$/:./' \
545 -e 's/:/ /g'`
546 for dir in ${temppath}; do
547 [ -x ${dir}/$default_gzip ] || continue
548 found=1; break
549 done
550 if [ "$found" = "0" ]; then
551 echo "WARNING: '$default_gzip' not found, will not compress" >&2
552 default_gzip=cat
554 case "${default_gzip}" in
555 bzip2) gzip_extension=.bz2 ;;
556 xz) gzip_extension=.xz ;;
557 gzip) gzip_extension=.gz ; default_gzip="gzip --best";;
558 *) gzip_extension= ;;
559 esac
560 echo "Creating tar file"
561 (cd ${tempparent} ; tar cvf - ${emacsname} ) \
562 | ${default_gzip} \
563 > ${emacsname}.tar${gzip_extension}
566 if [ "${clean_up}" != yes ]; then
567 (cd ${tempparent}; mv ${emacsname} ..)
568 rm -rf ${tempparent}
571 ### make-dist ends here