Backport icalendar-tests fixes from trunk
[emacs.git] / make-dist
blob986f784164c25eb4064f7d47f28ff9da87514b65
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 ## Don't restrict access to any files.
45 umask 0
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 lzma.
87 "--lzma")
88 default_gzip="lzma"
90 ## Same with xz.
91 "--xz")
92 default_gzip="xz"
94 "--no-compress")
95 default_gzip="cat"
98 "--snapshot")
99 clean_up=yes
100 make_tar=yes
101 update=no
102 check=no
105 ## Include the test/ directory.
106 ## This option is mainly for the hydra build server.
107 "--tests")
108 with_tests=yes
111 "--help")
112 echo "Usage: ${progname} [options]"
113 echo ""
114 echo " --bzip2 use bzip2 instead of gzip"
115 echo " --clean-up delete staging directories when done"
116 echo " --lzma use lzma instead of gzip"
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 " --snapshot same as --clean-up --no-update --tar --no-check"
123 echo " --tar make a tar file"
124 echo " --tests include the test/ directory"
125 echo ""
126 exit 0
130 echo "${progname}: Unrecognized argument: $1" >&2
131 exit 1
133 esac
134 shift
135 done
137 ### Make sure we're running in the right place.
138 if [ ! -d src -o ! -f src/lisp.h -o ! -d lisp -o ! -f lisp/subr.el ]; then
139 echo "${progname}: Can't find \`src/lisp.h' and \`lisp/subr.el'." >&2
140 echo "${progname} must be run in the top directory of the Emacs" >&2
141 echo "distribution tree. cd to that directory and try again." >&2
142 exit 1
145 ### Find where to run Emacs.
146 ### (Accept only absolute file names.)
147 if [ $update = yes ];
148 then
149 if [ -f src/emacs ];
150 then
151 EMACS=`pwd`/src/emacs
152 else
153 case $EMACS in
154 /*) ;;
156 if [ ! -f "$EMACS" ]; then
157 echo "$0: You must set the EMACS environment variable " \
158 "to an absolute file name." 2>&1
159 exit 1
160 fi;;
161 esac
165 ### Find out which version of Emacs this is.
166 version=`
167 sed -n 's/^AC_INIT(emacs,[ ]*\([^ )]*\).*/\1/p' <configure.ac
168 ` || version=
169 if [ ! "${version}" ]; then
170 echo "${progname}: can't find current Emacs version in \`./src/emacs.c'" >&2
171 exit 1
174 echo Version number is $version
176 if [ $update = yes ]; then
177 if ! grep -q "@set EMACSVER *${version}" doc/emacs/emacsver.texi || \
178 ! grep -q "tree holds version *${version}" README; then
179 echo "WARNING: README and/or emacsver.texi have 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 \
210 leim/[a-z]*/[a-z]*.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 \
215 leim/[a-z]*/[a-z]*.elc > /tmp/elc
217 ## Check for .elc files with no corresponding .el file.
218 sed 's/\.el$/.elc/' /tmp/el > /tmp/elelc
220 bogosities="`comm -13 /tmp/elelc /tmp/elc`"
221 if [ x"${bogosities}" != x"" ]; then
222 echo "The following .elc files have no corresponding .el files:"
223 echo "${bogosities}"
226 ### Check for .el files with no corresponding .elc file.
227 sed 's/\.elc$/.el/' /tmp/elc > /tmp/elcel
228 losers="`comm -23 /tmp/el /tmp/elcel`"
230 rm -f /tmp/el /tmp/elc /tmp/elcel /tmp/elelc
232 bogosities=
233 for file in $losers; do
234 grep -q "no-byte-compile: t" $file && continue
235 case $file in
236 site-init.el | site-load.el | site-start.el | default.el) continue ;;
237 esac
239 bogosities="$file $bogosities"
241 done
242 if [ x"${bogosities}" != x"" ]; then
243 echo "The following .el files have no corresponding .elc files:"
244 echo "${bogosities}"
248 if [ $update = yes ]; then
250 ## Make sure configure is newer than configure.ac, etc.
251 ## It is better to let autoreconf do what is needed than
252 ## for us to try and duplicate all its checks.
253 echo "Running autoreconf"
254 autoreconf -i -I m4 || { x=$?; echo Autoreconf FAILED! >&2; exit $x; }
256 ## Make sure src/stamp-h.in is newer than configure.ac.
257 rm -f src/stamp-h.in
258 echo timestamp > src/stamp-h.in
260 echo "Updating Info files"
261 make info-real
263 echo "Updating finder, custom and autoload data"
264 (cd lisp && make updates EMACS="$EMACS")
266 echo "Updating leim-list.el"
267 (cd leim && make leim-list.el EMACS="$EMACS")
269 echo "Recompiling Lisp files"
270 $EMACS -batch -f batch-byte-recompile-directory lisp leim
271 fi # $update = yes
273 echo "Creating staging directory: \`${tempparent}'"
275 mkdir ${tempparent}
276 tempdir="${tempparent}/${emacsname}"
278 ### This trap ensures that the staging directory will be cleaned up even
279 ### when the script is interrupted in mid-career.
280 if [ "${clean_up}" = yes ]; then
281 trap "echo 'Cleaning up the staging directory'; rm -rf ${tempparent}" EXIT
284 echo "Creating top directory: \`${tempdir}'"
285 mkdir ${tempdir}
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 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 \
300 leim/SKK-DIC leim/ja-dic leim/quail \
301 build-aux build-aux/snippet \
302 src src/bitmaps lib lib-src oldXMenu lwlib \
303 nt nt/inc nt/inc/sys nt/inc/arpa nt/inc/netinet nt/icons \
304 `find etc lisp admin test -type d` \
305 doc doc/emacs doc/misc doc/man doc/lispref doc/lispintro \
306 info m4 msdos \
307 nextstep nextstep/templates \
308 nextstep/Cocoa nextstep/Cocoa/Emacs.base \
309 nextstep/Cocoa/Emacs.base/Contents \
310 nextstep/Cocoa/Emacs.base/Contents/Resources \
311 nextstep/GNUstep \
312 nextstep/GNUstep/Emacs.base \
313 nextstep/GNUstep/Emacs.base/Resources
316 if [ "$with_tests" != "yes" ]; then
317 case $subdir in
318 test*) continue ;;
319 esac
322 ## site-lisp for in-place installs (?).
323 [ "$subdir" = "site-lisp" ] || [ -d "$subdir" ] || \
324 echo "WARNING: $subdir not found, making anyway"
325 echo " ${tempdir}/${subdir}"
326 mkdir ${tempdir}/${subdir}
327 done
329 echo "Making links to \`lisp' and its subdirectories"
330 files=`find lisp \( -name '*.el' -o -name '*.elc' -o -name 'ChangeLog*' \
331 -o -name 'README*' \)`
333 ### Don't distribute site-init.el, site-load.el, or default.el.
334 for file in lisp/Makefile.in lisp/makefile.w32-in $files; do
335 case $file in
336 */site-init*|*/site-load*|*/default*) continue ;;
337 esac
338 ln $file $tempdir/$file
339 done
341 echo "Making links to \`leim' and its subdirectories"
342 (cd leim
343 ln makefile.w32-in ../${tempdir}/leim
344 ln ChangeLog README ../${tempdir}/leim
345 ln CXTERM-DIC/README CXTERM-DIC/*.tit ../${tempdir}/leim/CXTERM-DIC
346 ln SKK-DIC/README SKK-DIC/SKK-JISYO.L ../${tempdir}/leim/SKK-DIC
347 ln MISC-DIC/README MISC-DIC/*.* ../${tempdir}/leim/MISC-DIC
348 ln ja-dic/*.el ja-dic/*.elc ../${tempdir}/leim/ja-dic
349 ln Makefile.in ../${tempdir}/leim/Makefile.in
350 ln leim-ext.el ../${tempdir}/leim/leim-ext.el
351 ## Lisp files that start with a capital (also 4Corner.el) are
352 ## generated from TIT dictionaries so we don't distribute them.
353 ln quail/[a-z]*.el quail/[a-z]*.elc ../${tempdir}/leim/quail
354 rm -f ../${tempdir}/leim/quail/quick-b5.*
355 rm -f ../${tempdir}/leim/quail/quick-cns.*
356 rm -f ../${tempdir}/leim/quail/tsang-b5.*
357 rm -f ../${tempdir}/leim/quail/tsang-cns.*)
359 echo "Making links to \`build-aux'"
360 (cd build-aux
361 ln compile config.guess config.sub depcomp ../${tempdir}/build-aux
362 ln install-sh missing move-if-change update-subdirs ../${tempdir}/build-aux)
364 echo "Making links to \`build-aux/snippet'"
365 (cd build-aux/snippet
366 ln *.h ../../${tempdir}/build-aux/snippet)
368 echo "Making links to \`src'"
369 ### Don't distribute the configured versions of
370 ### config.in, paths.in, buildobj.h, or Makefile.in.
371 (cd src
372 echo " (It is ok if ln fails in some cases.)"
373 ln [a-zA-Z]*.[chm] ../${tempdir}/src
374 ln [a-zA-Z]*.in ../${tempdir}/src
375 ln [a-zA-Z]*.mk ../${tempdir}/src
376 ln README ChangeLog ChangeLog.*[0-9] ../${tempdir}/src
377 ln makefile.w32-in ../${tempdir}/src
378 ln .gdbinit .dbxinit ../${tempdir}/src
379 cd ../${tempdir}/src
380 rm -f globals.h config.h epaths.h Makefile buildobj.h)
382 echo "Making links to \`src/bitmaps'"
383 (cd src/bitmaps
384 ln README *.xbm ../../${tempdir}/src/bitmaps)
386 echo "Making links to \`lib'"
387 (snippet_h=`(cd build-aux/snippet && ls *.h)`
388 cd lib
389 ln [a-zA-Z]*.[ch] ../${tempdir}/lib
390 ln gnulib.mk Makefile.am Makefile.in makefile.w32-in ../${tempdir}/lib
391 cd ../${tempdir}/lib
392 script='/[*]/d; s/\.in\.h$/.h/'
393 rm -f `(echo "$snippet_h"; ls *.in.h) | sed "$script"`)
395 echo "Making links to \`lib-src'"
396 (cd lib-src
397 ln [a-zA-Z]*.[ch] ../${tempdir}/lib-src
398 ln ChangeLog Makefile.in README testfile ../${tempdir}/lib-src
399 ln grep-changelog rcs2log ../${tempdir}/lib-src
400 ln makefile.w32-in ../${tempdir}/lib-src)
402 echo "Making links to \`m4'"
403 (cd m4
404 ln *.m4 ../${tempdir}/m4)
406 echo "Making links to \`nt'"
407 (cd nt
408 ln emacs-x86.manifest emacs-x64.manifest emacs.rc ../${tempdir}/nt
409 ln config.nt emacsclient.rc emacs-src.tags ../${tempdir}/nt
410 ln nmake.defs gmake.defs subdirs.el [a-z]*.bat [a-z]*.[ch] ../${tempdir}/nt
411 ln ChangeLog INSTALL README README.W32 makefile.w32-in ../${tempdir}/nt)
413 echo "Making links to \`nt/inc' and its subdirectories"
414 for f in `find nt/inc -type f -name '[a-z]*.h'`; do
415 ln $f $tempdir/$f
416 done
418 echo "Making links to \`nt/icons'"
419 (cd nt/icons
420 ln README [a-z]*.ico ../../${tempdir}/nt/icons
421 ln [a-z]*.cur ../../${tempdir}/nt/icons)
423 echo "Making links to \`msdos'"
424 (cd msdos
425 ln ChangeLog INSTALL README emacs.ico emacs.pif ../${tempdir}/msdos
426 ln depfiles.bat inttypes.h ../${tempdir}/msdos
427 ln is_exec.c sigaction.c mainmake.v2 sed*.inp ../${tempdir}/msdos)
429 echo "Making links to \`nextstep'"
430 (cd nextstep
431 ln ChangeLog README INSTALL Makefile.in ../${tempdir}/nextstep)
433 echo "Making links to \`nextstep/templates'"
434 (cd nextstep/templates
435 ln Emacs.desktop.in Info-gnustep.plist.in Info.plist.in InfoPlist.strings.in ../../${tempdir}/nextstep/templates)
437 echo "Making links to \`nextstep/Cocoa/Emacs.base/Contents'"
438 (cd nextstep/Cocoa/Emacs.base/Contents
439 ln PkgInfo ../../../../${tempdir}/nextstep/Cocoa/Emacs.base/Contents)
441 echo "Making links to \`nextstep/Cocoa/Emacs.base/Contents/Resources'"
442 (cd nextstep/Cocoa/Emacs.base/Contents/Resources
443 ln Credits.html *.icns ../../../../../${tempdir}/nextstep/Cocoa/Emacs.base/Contents/Resources)
445 echo "Making links to \`nextstep/GNUstep/Emacs.base/Resources'"
446 (cd nextstep/GNUstep/Emacs.base/Resources
447 ln README emacs.tiff ../../../../${tempdir}/nextstep/GNUstep/Emacs.base/Resources )
449 echo "Making links to \`oldXMenu'"
450 (cd oldXMenu
451 ln *.[ch] *.in ../${tempdir}/oldXMenu
452 ln README ChangeLog ../${tempdir}/oldXMenu)
454 echo "Making links to \`lwlib'"
455 (cd lwlib
456 ln *.[ch] *.in ../${tempdir}/lwlib
457 ln README ChangeLog ../${tempdir}/lwlib)
459 echo "Making links to \`admin' and its subdirectories"
460 for f in `find admin -type f`; do
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 esac
480 ln $f $tempdir/$f
481 done
483 echo "Making links to \`info'"
484 ln `find info -type f -print` ${tempdir}/info
486 echo "Making links to \`doc/emacs'"
487 (cd doc/emacs
488 ln *.texi *.in makefile.w32-in ChangeLog* ../../${tempdir}/doc/emacs)
490 echo "Making links to \`doc/misc'"
491 (cd doc/misc
492 ln *.texi *.tex *.in makefile.w32-in gnus-news.el ChangeLog* ../../${tempdir}/doc/misc)
494 echo "Making links to \`doc/lispref'"
495 (cd doc/lispref
496 ln *.texi *.in makefile.w32-in README ChangeLog* ../../${tempdir}/doc/lispref
497 ln spellfile ../../${tempdir}/doc/lispref
498 ln two-volume.make two-volume-cross-refs.txt ../../${tempdir}/doc/lispref)
500 echo "Making links to \`doc/lispintro'"
501 (cd doc/lispintro
502 ln *.texi *.in makefile.w32-in *.eps *.pdf ../../${tempdir}/doc/lispintro
503 ln README ChangeLog* ../../${tempdir}/doc/lispintro
504 cd ../../${tempdir}/doc/lispintro)
506 echo "Making links to \`doc/man'"
507 (cd doc/man
508 ln ChangeLog* *.1 ../../${tempdir}/doc/man
509 cd ../../${tempdir}/doc/man)
511 ### It would be nice if they could all be symlinks to top-level copy, but
512 ### you're not supposed to have any symlinks in distribution tar files.
513 echo "Making sure copying notices are all copies of \`COPYING'"
514 for subdir in . etc info leim lib lib-src lisp lwlib msdos nt src; do
515 rm -f ${tempdir}/${subdir}/COPYING
516 cp COPYING ${tempdir}/${subdir}
517 done
519 if [ "${newer}" ]; then
520 echo "Removing files older than $newer"
521 ## We remove .elc files unconditionally, on the theory that anyone picking
522 ## up an incremental distribution already has a running Emacs to byte-compile
523 ## them with.
524 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
527 ## Don't distribute backups, autosaves, etc.
528 echo "Removing unwanted files"
529 find ${tempparent} \( -name '*~' -o -name '#*#' -o -name '.*ignore' -o -name '=*' -o -name 'TAGS' \) -exec rm -f {} \;
531 if [ "${make_tar}" = yes ]; then
532 echo "Looking for $default_gzip"
533 found=0
534 temppath=`echo $PATH | sed -e 's/^:/.:/' -e 's/::/:.:/g' -e 's/:$/:./' \
535 -e 's/:/ /g'`
536 for dir in ${temppath}; do
537 [ -x ${dir}/$default_gzip ] || continue
538 found=1; break
539 done
540 if [ "$found" = "0" ]; then
541 echo "WARNING: \`$default_gzip' not found, will not compress" >&2
542 default_gzip=cat
544 case "${default_gzip}" in
545 bzip2) gzip_extension=.bz2 ;;
546 lzma) gzip_extension=.lzma ;;
547 xz) gzip_extension=.xz ;;
548 gzip) gzip_extension=.gz ; default_gzip="gzip --best";;
549 *) gzip_extension= ;;
550 esac
551 echo "Creating tar file"
552 (cd ${tempparent} ; tar cvf - ${emacsname} ) \
553 | ${default_gzip} \
554 > ${emacsname}.tar${gzip_extension}
557 if [ "${clean_up}" != yes ]; then
558 (cd ${tempparent}; mv ${emacsname} ..)
559 rm -rf ${tempparent}
562 ### make-dist ends here