merge trunk
[emacs.git] / make-dist
blob7a17fa02372ef9a5f552be5886c4b4a25a6f435e
1 #!/bin/sh
2 ### make-dist: create an Emacs distribution tar file from current srcdir
4 ## Copyright (C) 1995, 1997-1998, 2000-2012 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=""
54 while [ $# -gt 0 ]; do
55 case "$1" in
56 ## This option tells make-dist to delete the staging directory
57 ## when done. It is useless to use this unless you make a tar file.
58 "--clean-up" )
59 clean_up=yes
61 ## This option tells make-dist to make a tar file.
62 "--tar" )
63 make_tar=yes
65 ## This option tells make-dist not to recompile or do analogous things.
66 "--no-update" )
67 update=no
69 ## This option says don't check for bad file names, etc.
70 "--no-check" )
71 check=no
73 ## This option tells make-dist to make the distribution normally, then
74 ## remove all files older than the given timestamp file. This is useful
75 ## for creating incremental or patch distributions.
76 "--newer")
77 newer="$2"
78 new_extension=".new"
79 shift
81 ## This option tells make-dist to use `bzip2' instead of gzip.
82 "--bzip2")
83 default_gzip="bzip2"
85 ## Same with lzma.
86 "--lzma")
87 default_gzip="lzma"
90 "--snapshot")
91 clean_up=yes
92 make_tar=yes
93 update=no
94 check=no
97 "--help")
98 echo "Usage: ${progname} [options]"
99 echo ""
100 echo " --bzip2 use bzip2 instead of gzip"
101 echo " --clean-up delete staging directories when done"
102 echo " --lzma use lzma instead of gzip"
103 echo " --newer=TIME don't include files older than TIME"
104 echo " --no-check don't check for bad file names etc."
105 echo " --no-update don't recompile or do analogous things"
106 echo " --snapshot same as --clean-up --no-update --tar --no-check"
107 echo " --tar make a tar file"
108 echo ""
109 exit 0
113 echo "${progname}: Unrecognized argument: $1" >&2
114 exit 1
116 esac
117 shift
118 done
120 ### Make sure we're running in the right place.
121 if [ ! -d src -o ! -f src/lisp.h -o ! -d lisp -o ! -f lisp/subr.el ]; then
122 echo "${progname}: Can't find \`src/lisp.h' and \`lisp/subr.el'." >&2
123 echo "${progname} must be run in the top directory of the Emacs" >&2
124 echo "distribution tree. cd to that directory and try again." >&2
125 exit 1
128 ### Find where to run Emacs.
129 ### (Accept only absolute file names.)
130 if [ $update = yes ];
131 then
132 if [ -f src/emacs ];
133 then
134 EMACS=`pwd`/src/emacs
135 else
136 case $EMACS in
137 /*) ;;
139 if [ ! -f "$EMACS" ]; then
140 echo "$0: You must set the EMACS environment variable " \
141 "to an absolute file name." 2>&1
142 exit 1
143 fi;;
144 esac
148 ### Find out which version of Emacs this is.
149 version=`
150 sed -n 's/^AC_INIT(emacs,[ ]*\([^ )]*\).*/\1/p' <configure.ac
151 ` || version=
152 if [ ! "${version}" ]; then
153 echo "${progname}: can't find current Emacs version in \`./src/emacs.c'" >&2
154 exit 1
157 echo Version number is $version
159 if [ $update = yes ]; then
160 if ! grep -q "@set EMACSVER *${version}" doc/emacs/emacsver.texi || \
161 ! grep -q "tree holds version *${version}" README; then
162 echo "WARNING: README and/or emacsver.texi have the wrong version number"
163 echo "Consider running M-x set-version from admin/admin.el"
164 sleep 5
168 ### Make sure we don't already have a directory emacs-${version}.
170 emacsname="emacs-${version}${new_extension}"
172 if [ -d ${emacsname} ]
173 then
174 echo Directory "${emacsname}" already exists >&2
175 exit 1
178 ### Make sure the subdirectory is available.
179 tempparent="make-dist.tmp.$$"
180 if [ -d ${tempparent} ]; then
181 echo "${progname}: staging directory \`${tempparent}' already exists.
182 Perhaps a previous invocation of \`${progname}' failed to clean up after
183 itself. Check that directories whose names are of the form
184 \`make-dist.tmp.NNNNN' don't contain any important information, remove
185 them, and try again." >&2
186 exit 1
189 if [ $check = yes ]; then
190 ls -1 lisp/[a-zA-Z]*.el lisp/[a-z]*/[a-zA-Z0-9]*.el \
191 lisp/[a-z]*/[a-z]*/[a-zA-Z0-9]*.el \
192 lisp/[a-z]*/[a-z]*/[a-z]*/[a-zA-Z0-9]*.el \
193 leim/[a-z]*/[a-z]*.el > /tmp/el
195 ls -1 lisp/[a-zA-Z]*.elc lisp/[a-z]*/[a-zA-Z0-9]*.elc \
196 lisp/[a-z]*/[a-z]*/[a-zA-Z0-9]*.elc \
197 lisp/[a-z]*/[a-z]*/[a-z]*/[a-zA-Z0-9]*.elc \
198 leim/[a-z]*/[a-z]*.elc > /tmp/elc
200 ## Check for .elc files with no corresponding .el file.
201 sed 's/\.el$/.elc/' /tmp/el > /tmp/elelc
203 bogosities="`comm -13 /tmp/elelc /tmp/elc`"
204 if [ x"${bogosities}" != x"" ]; then
205 echo "The following .elc files have no corresponding .el files:"
206 echo "${bogosities}"
209 ### Check for .el files with no corresponding .elc file.
210 sed 's/\.elc$/.el/' /tmp/elc > /tmp/elcel
211 losers="`comm -23 /tmp/el /tmp/elcel`"
213 rm -f /tmp/el /tmp/elc /tmp/elcel /tmp/elelc
215 bogosities=
216 for file in $losers; do
217 grep -q "no-byte-compile: t" $file && continue
218 case $file in
219 site-init.el | site-load.el | site-start.el | default.el) continue ;;
220 esac
222 bogosities="$file $bogosities"
224 done
225 if [ x"${bogosities}" != x"" ]; then
226 echo "The following .el files have no corresponding .elc files:"
227 echo "${bogosities}"
231 if [ $update = yes ]; then
233 ## Make sure configure is newer than configure.ac, etc.
234 ## It is better to let autoreconf do what is needed than
235 ## for us to try and duplicate all its checks.
236 echo "Running autoreconf"
237 autoreconf -i -I m4 || { x=$?; echo Autoreconf FAILED! >&2; exit $x; }
239 ## Make sure src/stamp-h.in is newer than configure.ac.
240 rm -f src/stamp-h.in
241 echo timestamp > src/stamp-h.in
243 echo "Updating Info files"
244 make info-real
246 echo "Updating finder, custom and autoload data"
247 (cd lisp && make updates EMACS="$EMACS")
249 echo "Updating leim-list.el"
250 (cd leim && make leim-list.el EMACS="$EMACS")
252 echo "Recompiling Lisp files"
253 $EMACS -batch -f batch-byte-recompile-directory lisp leim
254 fi # $update = yes
256 echo "Creating staging directory: \`${tempparent}'"
258 mkdir ${tempparent}
259 tempdir="${tempparent}/${emacsname}"
261 ### This trap ensures that the staging directory will be cleaned up even
262 ### when the script is interrupted in mid-career.
263 if [ "${clean_up}" = yes ]; then
264 trap "echo 'Cleaning up the staging directory'; rm -rf ${tempparent}" EXIT
267 echo "Creating top directory: \`${tempdir}'"
268 mkdir ${tempdir}
270 ### We copy in the top-level files before creating the subdirectories in
271 ### hopes that this will make the top-level files appear first in the
272 ### tar file; this means that people can start reading the INSTALL and
273 ### README while the rest of the tar file is still unpacking. Whoopee.
274 echo "Making links to top-level files"
275 ln INSTALL README BUGS ${tempdir}
276 ln ChangeLog Makefile.in autogen.sh configure configure.ac ${tempdir}
277 ln config.bat make-dist .dir-locals.el ${tempdir}
278 ln aclocal.m4 ${tempdir}
280 echo "Creating subdirectories"
281 for subdir in site-lisp \
282 leim leim/CXTERM-DIC leim/MISC-DIC \
283 leim/SKK-DIC leim/ja-dic leim/quail \
284 build-aux build-aux/snippet \
285 src src/bitmaps lib lib-src oldXMenu lwlib \
286 nt nt/inc nt/inc/sys nt/inc/arpa nt/inc/netinet nt/icons \
287 `find etc lisp admin -type d` \
288 doc doc/emacs doc/misc doc/man doc/lispref doc/lispintro \
289 info m4 msdos \
290 nextstep nextstep/templates \
291 nextstep/Cocoa nextstep/Cocoa/Emacs.base \
292 nextstep/Cocoa/Emacs.base/Contents \
293 nextstep/Cocoa/Emacs.base/Contents/Resources \
294 nextstep/GNUstep \
295 nextstep/GNUstep/Emacs.base \
296 nextstep/GNUstep/Emacs.base/Resources
298 ## site-lisp for in-place installs (?).
299 [ "$subdir" = "site-lisp" ] || [ -d "$subdir" ] || \
300 echo "WARNING: $subdir not found, making anyway"
301 echo " ${tempdir}/${subdir}"
302 mkdir ${tempdir}/${subdir}
303 done
305 echo "Making links to \`lisp' and its subdirectories"
306 files=`find lisp \( -name '*.el' -o -name '*.elc' -o -name 'ChangeLog*' \
307 -o -name 'README*' \)`
309 ### Don't distribute site-init.el, site-load.el, or default.el.
310 for file in lisp/Makefile.in lisp/makefile.w32-in $files; do
311 case $file in
312 */site-init*|*/site-load*|*/default*) continue ;;
313 esac
314 ln $file $tempdir/$file
315 done
317 echo "Making links to \`leim' and its subdirectories"
318 (cd leim
319 ln makefile.w32-in ../${tempdir}/leim
320 ln ChangeLog README ../${tempdir}/leim
321 ln CXTERM-DIC/README CXTERM-DIC/*.tit ../${tempdir}/leim/CXTERM-DIC
322 ln SKK-DIC/README SKK-DIC/SKK-JISYO.L ../${tempdir}/leim/SKK-DIC
323 ln MISC-DIC/README MISC-DIC/*.* ../${tempdir}/leim/MISC-DIC
324 ln ja-dic/*.el ja-dic/*.elc ../${tempdir}/leim/ja-dic
325 ln Makefile.in ../${tempdir}/leim/Makefile.in
326 ln leim-ext.el ../${tempdir}/leim/leim-ext.el
327 ## Lisp files that start with a capital (also 4Corner.el) are
328 ## generated from TIT dictionaries so we don't distribute them.
329 ln quail/[a-z]*.el quail/[a-z]*.elc ../${tempdir}/leim/quail
330 rm -f ../${tempdir}/leim/quail/quick-b5.*
331 rm -f ../${tempdir}/leim/quail/quick-cns.*
332 rm -f ../${tempdir}/leim/quail/tsang-b5.*
333 rm -f ../${tempdir}/leim/quail/tsang-cns.*)
335 echo "Making links to \`build-aux'"
336 (cd build-aux
337 ln compile config.guess config.sub depcomp ../${tempdir}/build-aux
338 ln install-sh missing move-if-change update-subdirs ../${tempdir}/build-aux)
340 echo "Making links to \`build-aux/snippet'"
341 (cd build-aux/snippet
342 ln *.h ../../${tempdir}/build-aux/snippet)
344 echo "Making links to \`src'"
345 ### Don't distribute the configured versions of
346 ### config.in, paths.in, buildobj.h, or Makefile.in.
347 (cd src
348 echo " (It is ok if ln fails in some cases.)"
349 ln [a-zA-Z]*.[chm] ../${tempdir}/src
350 ln [a-zA-Z]*.in ../${tempdir}/src
351 ln [a-zA-Z]*.mk ../${tempdir}/src
352 ln README ChangeLog ChangeLog.*[0-9] ../${tempdir}/src
353 ln makefile.w32-in ../${tempdir}/src
354 ln .gdbinit .dbxinit ../${tempdir}/src
355 cd ../${tempdir}/src
356 rm -f globals.h config.h epaths.h Makefile buildobj.h)
358 echo "Making links to \`src/bitmaps'"
359 (cd src/bitmaps
360 ln README *.xbm ../../${tempdir}/src/bitmaps)
362 echo "Making links to \`lib'"
363 (snippet_h=`(cd build-aux/snippet && ls *.h)`
364 cd lib
365 ln [a-zA-Z]*.[ch] ../${tempdir}/lib
366 ln gnulib.mk Makefile.am Makefile.in makefile.w32-in ../${tempdir}/lib
367 cd ../${tempdir}/lib
368 script='/[*]/d; s/\.in\.h$/.h/'
369 rm -f `(echo "$snippet_h"; ls *.in.h) | sed "$script"`)
371 echo "Making links to \`lib-src'"
372 (cd lib-src
373 ln [a-zA-Z]*.[ch] ../${tempdir}/lib-src
374 ln ChangeLog Makefile.in README testfile ../${tempdir}/lib-src
375 ln grep-changelog rcs2log ../${tempdir}/lib-src
376 ln makefile.w32-in ../${tempdir}/lib-src)
378 echo "Making links to \`m4'"
379 (cd m4
380 ln *.m4 ../${tempdir}/m4)
382 echo "Making links to \`nt'"
383 (cd nt
384 ln emacs.manifest emacs.rc emacsclient.rc config.nt ../${tempdir}/nt
385 ln emacs-src.tags nmake.defs gmake.defs subdirs.el ../${tempdir}/nt
386 ln [a-z]*.bat [a-z]*.[ch] ../${tempdir}/nt
387 ln ChangeLog INSTALL README README.W32 makefile.w32-in ../${tempdir}/nt)
389 echo "Making links to \`nt/inc' and its subdirectories"
390 for f in `find nt/inc -type f -name '[a-z]*.h'`; do
391 ln $f $tempdir/$f
392 done
394 echo "Making links to \`nt/icons'"
395 (cd nt/icons
396 ln README [a-z]*.ico ../../${tempdir}/nt/icons
397 ln [a-z]*.cur ../../${tempdir}/nt/icons)
399 echo "Making links to \`msdos'"
400 (cd msdos
401 ln ChangeLog INSTALL README emacs.ico emacs.pif ../${tempdir}/msdos
402 ln depfiles.bat inttypes.h ../${tempdir}/msdos
403 ln is_exec.c sigaction.c mainmake.v2 sed*.inp ../${tempdir}/msdos)
405 echo "Making links to \`nextstep'"
406 (cd nextstep
407 ln ChangeLog README INSTALL Makefile.in ../${tempdir}/nextstep)
409 echo "Making links to \`nextstep/templates'"
410 (cd nextstep/templates
411 ln Emacs.desktop.in Info-gnustep.plist.in Info.plist.in InfoPlist.strings.in ../../${tempdir}/nextstep/templates)
413 echo "Making links to \`nextstep/Cocoa/Emacs.base/Contents'"
414 (cd nextstep/Cocoa/Emacs.base/Contents
415 ln PkgInfo ../../../../${tempdir}/nextstep/Cocoa/Emacs.base/Contents)
417 echo "Making links to \`nextstep/Cocoa/Emacs.base/Contents/Resources'"
418 (cd nextstep/Cocoa/Emacs.base/Contents/Resources
419 ln Credits.html *.icns ../../../../../${tempdir}/nextstep/Cocoa/Emacs.base/Contents/Resources)
421 echo "Making links to \`nextstep/GNUstep/Emacs.base/Resources'"
422 (cd nextstep/GNUstep/Emacs.base/Resources
423 ln README emacs.tiff ../../../../${tempdir}/nextstep/GNUstep/Emacs.base/Resources )
425 echo "Making links to \`oldXMenu'"
426 (cd oldXMenu
427 ln *.[ch] *.in ../${tempdir}/oldXMenu
428 ln README ChangeLog ../${tempdir}/oldXMenu)
430 echo "Making links to \`lwlib'"
431 (cd lwlib
432 ln *.[ch] *.in ../${tempdir}/lwlib
433 ln README ChangeLog ../${tempdir}/lwlib)
435 echo "Making links to \`admin' and its subdirectories"
436 for f in `find admin -type f`; do
437 ln $f $tempdir/$f
438 done
440 echo "Making links to \`etc' and its subdirectories"
441 for f in `find etc -type f`; do
442 case $f in
443 etc/DOC*|etc/*.pyc) continue ;;
444 esac
445 ln $f $tempdir/$f
446 done
448 echo "Making links to \`info'"
449 ln `find info -type f -print` ${tempdir}/info
451 echo "Making links to \`doc/emacs'"
452 (cd doc/emacs
453 ln *.texi *.in makefile.w32-in ChangeLog* ../../${tempdir}/doc/emacs)
455 echo "Making links to \`doc/misc'"
456 (cd doc/misc
457 ln *.texi *.tex *.in makefile.w32-in gnus-news.el ChangeLog* ../../${tempdir}/doc/misc)
459 echo "Making links to \`doc/lispref'"
460 (cd doc/lispref
461 ln *.texi *.in makefile.w32-in README ChangeLog* ../../${tempdir}/doc/lispref
462 ln spellfile ../../${tempdir}/doc/lispref
463 ln two-volume.make two-volume-cross-refs.txt ../../${tempdir}/doc/lispref)
465 echo "Making links to \`doc/lispintro'"
466 (cd doc/lispintro
467 ln *.texi *.in makefile.w32-in *.eps *.pdf ../../${tempdir}/doc/lispintro
468 ln README ChangeLog* ../../${tempdir}/doc/lispintro
469 cd ../../${tempdir}/doc/lispintro)
471 echo "Making links to \`doc/man'"
472 (cd doc/man
473 ln ChangeLog* *.1 ../../${tempdir}/doc/man
474 cd ../../${tempdir}/doc/man)
476 ### It would be nice if they could all be symlinks to top-level copy, but
477 ### you're not supposed to have any symlinks in distribution tar files.
478 echo "Making sure copying notices are all copies of \`COPYING'"
479 for subdir in . etc info leim lib lib-src lisp lwlib msdos nt src; do
480 rm -f ${tempdir}/${subdir}/COPYING
481 cp COPYING ${tempdir}/${subdir}
482 done
484 if [ "${newer}" ]; then
485 echo "Removing files older than $newer"
486 ## We remove .elc files unconditionally, on the theory that anyone picking
487 ## up an incremental distribution already has a running Emacs to byte-compile
488 ## them with.
489 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
492 ## Don't distribute backups, autosaves, etc.
493 echo "Removing unwanted files"
494 find ${tempparent} \( -name '*~' -o -name '#*#' -o -name '.*ignore' -o -name '=*' -o -name 'TAGS' \) -exec rm -f {} \;
496 if [ "${make_tar}" = yes ]; then
497 echo "Looking for $default_gzip"
498 found=0
499 temppath=`echo $PATH | sed -e 's/^:/.:/' -e 's/::/:.:/g' -e 's/:$/:./' \
500 -e 's/:/ /g'`
501 for dir in ${temppath}; do
502 [ -x ${dir}/$default_gzip ] || continue
503 found=1; break
504 done
505 if [ "$found" = "0" ]; then
506 echo "WARNING: \`$default_gzip' not found, will not compress" >&2
507 default_gzip=cat
509 case "${default_gzip}" in
510 bzip2) gzip_extension=.bz2 ;;
511 lzma) gzip_extension=.lzma ;;
512 gzip) gzip_extension=.gz ; default_gzip="gzip --best";;
513 *) gzip_extension= ;;
514 esac
515 echo "Creating tar file"
516 (cd ${tempparent} ; tar cvf - ${emacsname} ) \
517 | ${default_gzip} \
518 > ${emacsname}.tar${gzip_extension}
521 if [ "${clean_up}" != yes ]; then
522 (cd ${tempparent}; mv ${emacsname} ..)
523 rm -rf ${tempparent}
526 ### make-dist ends here