Remove trailing / from directory names.
[emacs.git] / make-dist
blob2a51b91241e5917a739b0a3fcebb6c79f82c5a87
1 #!/bin/sh
2 ### make-dist: create an Emacs distribution tar file from current srcdir
4 ## Copyright (C) 1995, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005,
5 ## 2006, 2007, 2008, 2009, 2010 Free Software Foundation, 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 ## Don't restrict access to any files.
46 umask 0
48 update=yes
49 check=yes
50 clean_up=no
51 make_tar=no
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 `compress' instead of gzip.
82 ## Normally, make-dist uses gzip whenever it is present.
83 "--compress")
84 default_gzip="compress"
86 ## Same with bzip2.
87 "--bzip2")
88 default_gzip="bzip2"
90 ## Same with lzma.
91 "--lzma")
92 default_gzip="lzma"
95 "--snapshot")
96 clean_up=yes
97 make_tar=yes
98 update=no
99 check=no
102 "--help")
103 echo "Usage: ${progname} [options]"
104 echo ""
105 echo " --bzip2 use bzip2 instead of gzip"
106 echo " --clean-up delete staging directories when done"
107 echo " --compress use compress instead of gzip"
108 echo " --lzma use lzma instead of gzip"
109 echo " --newer=TIME don't include files older than TIME"
110 echo " --no-check don't check for bad file names etc."
111 echo " --no-update don't recompile or do analogous things"
112 echo " --snapshot same as --clean-up --no-update --tar --no-check"
113 echo " --tar make a tar file"
114 echo ""
115 exit 0
119 echo "${progname}: Unrecognized argument: $1" >&2
120 exit 1
122 esac
123 shift
124 done
126 ### Make sure we're running in the right place.
127 if [ ! -d src -o ! -f src/lisp.h -o ! -d lisp -o ! -f lisp/subr.el ]; then
128 echo "${progname}: Can't find \`src/lisp.h' and \`lisp/subr.el'." >&2
129 echo "${progname} must be run in the top directory of the Emacs" >&2
130 echo "distribution tree. cd to that directory and try again." >&2
131 exit 1
134 ### Find where to run Emacs.
135 ### (Accept only absolute file names.)
136 if [ $update = yes ];
137 then
138 unset EMACS_UNIBYTE
139 if [ -f src/emacs ];
140 then
141 EMACS=`pwd`/src/emacs
142 else
143 case $EMACS in
144 /*) ;;
146 if [ ! -f "$EMACS" ]; then
147 echo "$0: You must set the EMACS environment variable " \
148 "to an absolute file name." 2>&1
149 exit 1
150 fi;;
151 esac
155 ### Find out which version of Emacs this is.
156 version=`sed -n '/char emacs_version/ s/^[^"]*"\([^"]*\)".*$/\1/p' src/emacs.c`
157 if [ ! "${version}" ]; then
158 echo "${progname}: can't find current Emacs version in \`./src/emacs.c'" >&2
159 exit 1
162 echo Version number is $version
164 if [ $update = yes ];
165 then
166 if grep -s "@set EMACSVER *${version}" ./doc/emacs/emacsver.texi > /dev/null; then
167 true
168 else
169 echo "You must update the version number in \`./doc/emacs/emacsver.texi'"
170 sleep 5
174 ### Make sure we don't already have a directory emacs-${version}.
176 emacsname="emacs-${version}${new_extension}"
178 if [ -d ${emacsname} ]
179 then
180 echo Directory "${emacsname}" already exists >&2
181 exit 1
184 ### Make sure the subdirectory is available.
185 tempparent="make-dist.tmp.$$"
186 if [ -d ${tempparent} ]; then
187 echo "${progname}: staging directory \`${tempparent}' already exists.
188 Perhaps a previous invocation of \`${progname}' failed to clean up after
189 itself. Check that directories whose names are of the form
190 \`make-dist.tmp.NNNNN' don't contain any important information, remove
191 them, and try again." >&2
192 exit 1
195 ### Find where to run Emacs.
196 if [ $check = yes ];
197 then
198 ### Check for .elc files with no corresponding .el file.
199 ls -1 lisp/[a-zA-Z]*.el lisp/[a-z]*/[a-zA-Z0-9]*.el \
200 lisp/[a-z]*/[a-z]*/[a-zA-Z0-9]*.el \
201 lisp/[a-z]*/[a-z]*/[a-z]*/[a-zA-Z0-9]*.el \
202 leim/[a-z]*/[a-z]*.el | sed 's/\.el$/.elc/' > /tmp/el
203 ls -1 lisp/[a-zA-Z]*.elc lisp/[a-z]*/[a-zA-Z0-9]*.elc \
204 lisp/[a-z]*/[a-z]*/[a-zA-Z0-9]*.elc \
205 lisp/[a-z]*/[a-z]*/[a-z]*/[a-zA-Z0-9]*.elc \
206 leim/[a-z]*/[a-z]*.elc > /tmp/elc
207 bogosities="`comm -13 /tmp/el /tmp/elc`"
208 if [ "${bogosities}" != "" ]; then
209 echo "The following .elc files have no corresponding .el files:"
210 echo "${bogosities}"
212 rm -f /tmp/el /tmp/elc
214 ### Check for .el files with no corresponding .elc file.
215 ls -1 lisp/[a-zA-Z]*.el lisp/[a-z]*/[a-zA-Z0-9]*.el \
216 lisp/[a-z]*/[a-z]*/[a-zA-Z0-9]*.el \
217 lisp/[a-z]*/[a-z]*/[a-z]*/[a-zA-Z0-9]*.el \
218 leim/[a-z]*/[a-z]*.el > /tmp/el
219 ls -1 lisp/[a-zA-Z]*.elc lisp/[a-z]*/[a-zA-Z0-9]*.elc \
220 lisp/[a-z]*/[a-z]*/[a-zA-Z0-9]*.el \
221 lisp/[a-z]*/[a-z]*/[a-z]*/[a-zA-Z0-9]*.el \
222 leim/[a-z]*/[a-z]*.elc | sed 's/\.elc$/.el/' > /tmp/elc
223 losers="`comm -23 /tmp/el /tmp/elc`"
224 bogosities=
225 for file in $losers; do
226 if ! grep -q "no-byte-compile: t" $file; then
227 case $file in
228 site-init.el | site-load.el | site-start.el | default.el)
231 bogosities="$file $bogosities"
233 esac
235 done
236 if [ x"${bogosities}" != x"" ]; then
237 echo "The following .el files have no corresponding .elc files:"
238 echo "${bogosities}"
240 rm -f /tmp/el /tmp/elc
243 ### Make sure configure is newer than configure.in.
244 if [ "x`ls -t configure configure.in | sed q`" != "xconfigure" ]; then
245 echo "\`./configure.in' is newer than \`./configure'" >&2
246 echo "Running autoconf" >&2
247 autoconf || { x=$?; echo Autoconf FAILED! >&2; exit $x; }
250 ### Make sure src/stamp-h.in is newer than configure.in.
251 if [ "x`ls -t src/stamp-h.in configure.in | sed q`" != "xsrc/stamp-h.in" ]; then
252 echo "\`./configure.in' is newer than \`./src/stamp-h.in'" >&2
253 echo "Running autoheader" >&2
254 autoheader || { x=$?; echo Autoheader FAILED! >&2; exit $x; }
255 rm -f src/stamp-h.in
256 echo timestamp > src/stamp-h.in
259 if [ $update = yes ];
260 then
261 echo "Updating Info files"
262 (cd doc/emacs; make info)
263 (cd doc/misc; make info)
264 (cd doc/lispref; make info)
265 (cd doc/lispintro; make info)
267 echo "Updating finder, custom and autoload data"
268 (cd lisp; make updates EMACS="$EMACS")
270 if test -f leim/leim-list.el; then
271 echo "Updating leim-list.el"
272 (cd leim; make leim-list.el EMACS="$EMACS")
275 echo "Recompiling Lisp files"
276 $EMACS -batch -f batch-byte-recompile-directory lisp leim
279 ## What is this file for? It goes in srcdir, not the tarfile.
280 ## Why does it exclude term/ ?
281 echo "Making lisp/MANIFEST"
283 files=`find lisp -type f -name '*.el'`
284 for file in $files; do
285 case "$file" in
286 */subdirs.el|*/default.el|*/loaddefs.el|*/term/*) continue ;;
287 esac
288 sed -n 's/^;;; //p; q' $file
289 done | sort > lisp/MANIFEST
291 echo "Creating staging directory: \`${tempparent}'"
293 mkdir ${tempparent}
294 tempdir="${tempparent}/${emacsname}"
296 ### This trap ensures that the staging directory will be cleaned up even
297 ### when the script is interrupted in mid-career.
298 if [ "${clean_up}" = yes ]; then
299 trap "echo 'Cleaning up the staging directory'; rm -rf ${tempparent}" EXIT
302 echo "Creating top directory: \`${tempdir}'"
303 mkdir ${tempdir}
305 ### We copy in the top-level files before creating the subdirectories in
306 ### hopes that this will make the top-level files appear first in the
307 ### tar file; this means that people can start reading the INSTALL and
308 ### README while the rest of the tar file is still unpacking. Whoopee.
309 echo "Making links to top-level files"
310 ln INSTALL README BUGS move-if-change ${tempdir}
311 ln ChangeLog Makefile.in configure configure.in ${tempdir}
312 ln config.bat make-dist update-subdirs vpath.sed .dir-locals.el ${tempdir}
313 ln mkinstalldirs config.sub config.guess install-sh ${tempdir}
315 ## FIXME why do we bother doing this? set-version in admin/admin.el
316 ## does this, and more besides.
317 echo "Updating version number in README"
318 (cd ${tempdir}
319 awk \
320 '$1 " " $2 " " $3 " " $4 " " $5 == "This directory tree holds version" { $6 = version; print $0 }
321 $1 " " $2 " " $3 " " $4 " " $5 != "This directory tree holds version"' \
322 version=${version} README > tmp.README
323 mv -f tmp.README README)
326 echo "Creating subdirectories"
327 for subdir in site-lisp \
328 leim leim/CXTERM-DIC leim/MISC-DIC \
329 leim/SKK-DIC leim/ja-dic leim/quail \
330 src src/m src/s src/bitmaps lib-src oldXMenu lwlib \
331 nt nt/inc nt/inc/sys nt/inc/arpa nt/inc/netinet nt/icons \
332 `find etc lisp -type d` \
333 doc doc/emacs doc/misc doc/man doc/lispref doc/lispintro \
334 info m4 msdos \
335 nextstep nextstep/Cocoa nextstep/Cocoa/Emacs.base \
336 nextstep/Cocoa/Emacs.base/Contents \
337 nextstep/Cocoa/Emacs.base/Contents/Resources \
338 nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj \
339 nextstep/Cocoa/Emacs.xcodeproj \
340 nextstep/GNUstep \
341 nextstep/GNUstep/Emacs.base \
342 nextstep/GNUstep/Emacs.base/Resources
344 ## site-lisp for in-place installs (?).
345 [ "$subdir" = "site-lisp" ] || [ -d "$subdir" ] || \
346 echo "WARNING: $subdir not found, making anyway"
347 echo " ${tempdir}/${subdir}"
348 mkdir ${tempdir}/${subdir}
349 done
351 echo "Making links to \`lisp' and its subdirectories"
352 files=`find lisp \( -name '*.el' -o -name '*.elc' -o -name 'ChangeLog*' \
353 -o -name 'README*' \)`
355 ### Don't distribute site-init.el, site-load.el, or default.el.
356 for file in lisp/Makefile.in lisp/makefile.w32-in $files; do
357 case $file in
358 */site-init*|*/site-load*|*/default*) continue ;;
359 esac
360 ln $file $tempdir/$file
361 done
363 echo "Making links to \`leim' and its subdirectories"
364 (cd leim
365 ln makefile.w32-in ../${tempdir}/leim
366 ln ChangeLog README ../${tempdir}/leim
367 ln CXTERM-DIC/README CXTERM-DIC/*.tit ../${tempdir}/leim/CXTERM-DIC
368 ln SKK-DIC/README SKK-DIC/SKK-JISYO.L ../${tempdir}/leim/SKK-DIC
369 ln MISC-DIC/README MISC-DIC/*.* ../${tempdir}/leim/MISC-DIC
370 ln ja-dic/*.el ja-dic/*.elc ../${tempdir}/leim/ja-dic
371 ln Makefile.in ../${tempdir}/leim/Makefile.in
372 ln leim-ext.el ../${tempdir}/leim/leim-ext.el
373 ## Lisp files that start with a capital (also 4Corner.el) are
374 ## generated from TIT dictionaries so we don't distribute them.
375 ln quail/[a-z]*.el quail/[a-z]*.elc ../${tempdir}/leim/quail
376 rm -f ../${tempdir}/leim/quail/quick-b5.*
377 rm -f ../${tempdir}/leim/quail/quick-cns.*
378 rm -f ../${tempdir}/leim/quail/tsang-b5.*
379 rm -f ../${tempdir}/leim/quail/tsang-cns.*)
381 echo "Making links to \`src'"
382 ### Don't distribute the configured versions of
383 ### config.in, paths.in, buildobj.h, or Makefile.in.
384 (cd src
385 echo " (It is ok if ln fails in some cases.)"
386 ln [a-zA-Z]*.[chm] ../${tempdir}/src
387 ln [a-zA-Z]*.in ../${tempdir}/src
388 ln [a-zA-Z]*.mk ../${tempdir}/src
389 ln README ChangeLog ChangeLog.*[0-9] ../${tempdir}/src
390 ln makefile.w32-in ../${tempdir}/src
391 ln .gdbinit .dbxinit ../${tempdir}/src
392 cd ../${tempdir}/src
393 rm -f config.h epaths.h Makefile buildobj.h)
395 echo "Making links to \`src/bitmaps'"
396 (cd src/bitmaps
397 ln README *.xbm ../../${tempdir}/src/bitmaps)
399 echo "Making links to \`src/m'"
400 (cd src/m
401 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/m)
403 echo "Making links to \`src/s'"
404 (cd src/s
405 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/s)
407 echo "Making links to \`lib-src'"
408 (cd lib-src
409 ln [a-zA-Z]*.[ch] ../${tempdir}/lib-src
410 ln ChangeLog Makefile.in README testfile vcdiff ../${tempdir}/lib-src
411 ln grep-changelog rcs2log rcs-checkin ../${tempdir}/lib-src
412 ln makefile.w32-in ../${tempdir}/lib-src
413 cd ../${tempdir}/lib-src
414 rm -f getopt.h)
416 echo "Making links to \`m4'"
417 (cd m4
418 ln *.m4 ../${tempdir}/m4)
420 echo "Making links to \`nt'"
421 (cd nt
422 ln emacs.manifest emacs.rc emacsclient.rc config.nt ../${tempdir}/nt
423 ln emacs-src.tags nmake.defs gmake.defs subdirs.el ../${tempdir}/nt
424 ln [a-z]*.bat [a-z]*.[ch] ../${tempdir}/nt
425 ln ChangeLog INSTALL README README.W32 makefile.w32-in ../${tempdir}/nt)
427 echo "Making links to \`nt/inc'"
428 (cd nt/inc
429 ln [a-z]*.h ../../${tempdir}/nt/inc)
431 echo "Making links to \`nt/inc/sys'"
432 (cd nt/inc/sys
433 ln [a-z]*.h ../../../${tempdir}/nt/inc/sys)
435 echo "Making links to \`nt/inc/arpa'"
436 (cd nt/inc/arpa
437 ln [a-z]*.h ../../../${tempdir}/nt/inc/arpa)
439 echo "Making links to \`nt/inc/netinet'"
440 (cd nt/inc/netinet
441 ln [a-z]*.h ../../../${tempdir}/nt/inc/netinet)
443 echo "Making links to \`nt/icons'"
444 (cd nt/icons
445 ln README [a-z]*.ico ../../${tempdir}/nt/icons
446 ln [a-z]*.cur ../../${tempdir}/nt/icons)
448 echo "Making links to \`msdos'"
449 (cd msdos
450 ln ChangeLog INSTALL README emacs.ico emacs.pif ../${tempdir}/msdos
451 ln is_exec.c sigaction.c mainmake.v2 sed*.inp ../${tempdir}/msdos)
453 echo "Making links to \`nextstep'"
454 (cd nextstep
455 ln AUTHORS ChangeLog README INSTALL ../${tempdir}/nextstep)
457 echo "Making links to \`nextstep/Cocoa/Emacs.base/Contents'"
458 (cd nextstep/Cocoa/Emacs.base/Contents
459 ln Info.plist PkgInfo ../../../../${tempdir}/nextstep/Cocoa/Emacs.base/Contents)
461 echo "Making links to \`nextstep/Cocoa/Emacs.base/Contents/Resources'"
462 (cd nextstep/Cocoa/Emacs.base/Contents/Resources
463 ln Credits.html *.icns ../../../../../${tempdir}/nextstep/Cocoa/Emacs.base/Contents/Resources)
465 echo "Making links to \`nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj'"
466 (cd nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj
467 ln InfoPlist.strings ../../../../../../${tempdir}/nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj)
469 echo "Making links to \`nextstep/Cocoa/Emacs.xcodeproj'"
470 (cd nextstep/Cocoa/Emacs.xcodeproj
471 ln project.pbxproj ../../../${tempdir}/nextstep/Cocoa/Emacs.xcodeproj)
473 echo "Making links to \`nextstep/GNUstep/Emacs.base/Resources'"
474 (cd nextstep/GNUstep/Emacs.base/Resources
475 ln Emacs.desktop Info-gnustep.plist README emacs.tiff ../../../../${tempdir}/nextstep/GNUstep/Emacs.base/Resources )
477 echo "Making links to \`oldXMenu'"
478 (cd oldXMenu
479 ln *.[ch] *.in ../${tempdir}/oldXMenu
480 ln README ChangeLog ../${tempdir}/oldXMenu)
482 echo "Making links to \`lwlib'"
483 (cd lwlib
484 ln *.[ch] *.in ../${tempdir}/lwlib
485 ln README ChangeLog ../${tempdir}/lwlib)
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*) continue ;;
491 esac
492 ln $f $tempdir/$f
493 done
495 echo "Making links to \`info'"
496 (cd info
497 ln `find . -type f -print` ../${tempdir}/info)
499 echo "Making links to \`doc/emacs'"
500 (cd doc/emacs
501 ln *.texi *.in makefile.w32-in ChangeLog* ../../${tempdir}/doc/emacs)
503 echo "Making links to \`doc/misc'"
504 (cd doc/misc
505 ln *.texi *.tex *.in makefile.w32-in gnus-news.el ChangeLog* ../../${tempdir}/doc/misc)
507 echo "Making links to \`doc/lispref'"
508 (cd doc/lispref
509 ln *.texi *.in makefile.w32-in README ChangeLog* ../../${tempdir}/doc/lispref
510 ln *.txt *.el spellfile tindex.pl ../../${tempdir}/doc/lispref
511 ln two-volume.make ../../${tempdir}/doc/lispref)
513 echo "Making links to \`doc/lispintro'"
514 (cd doc/lispintro
515 ln *.texi *.in makefile.w32-in *.eps *.pdf ../../${tempdir}/doc/lispintro
516 ln README ChangeLog* ../../${tempdir}/doc/lispintro
517 cd ../../${tempdir}/doc/lispintro)
519 echo "Making links to \`doc/man'"
520 (cd doc/man
521 ln ChangeLog* *.1 ../../${tempdir}/doc/man
522 cd ../../${tempdir}/doc/man)
524 ### It would be nice if they could all be symlinks to top-level copy, but
525 ### you're not supposed to have any symlinks in distribution tar files.
526 echo "Making sure copying notices are all copies of \`COPYING'"
527 for subdir in . etc info leim lib-src lisp lwlib msdos nt src; do
528 rm -f ${tempdir}/${subdir}/COPYING
529 cp COPYING ${tempdir}/${subdir}
530 done
532 if [ "${newer}" ]; then
533 echo "Removing files older than $newer"
534 ## We remove .elc files unconditionally, on the theory that anyone picking
535 ## up an incremental distribution already has a running Emacs to byte-compile
536 ## them with.
537 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
540 ## Don't distribute backups, autosaves, etc.
541 echo "Removing unwanted files"
542 find ${tempparent} \( -name '*~' -o -name '#*#' -o -name '.*ignore' -o -name '=*' -o -name 'TAGS' \) -exec rm -f {} \;
544 if [ "${make_tar}" = yes ]; then
545 if [ "${default_gzip}" = "" ]; then
546 echo "Looking for gzip"
547 temppath=`echo $PATH | sed 's/^:/.:/
548 s/::/:.:/g
549 s/:$/:./
550 s/:/ /g'`
551 default_gzip=`(
552 for dir in ${temppath}; do
553 if [ -f ${dir}/gzip ]; then echo 'gzip --best'; exit 0; fi
554 done
555 echo compress
558 case "${default_gzip}" in
559 bzip2) gzip_extension=.bz2 ;;
560 compress* ) gzip_extension=.Z ;;
561 lzma) gzip_extension=.lzma ;;
562 * ) gzip_extension=.gz ;;
563 esac
564 echo "Creating tar file"
565 (cd ${tempparent} ; tar cvf - ${emacsname} ) \
566 | ${default_gzip} \
567 > ${emacsname}.tar${gzip_extension}
570 if [ "${clean_up}" != yes ]; then
571 (cd ${tempparent}; mv ${emacsname} ..)
572 rm -rf ${tempparent}
575 ### make-dist ends here