* iswitchb.el (iswitchb-read-buffer): Fix typo.
[bpt/emacs.git] / make-dist
CommitLineData
067d23c9
KY
1#!/bin/sh
2### make-dist: create an Emacs distribution tar file from current srcdir
3
ab422c4d
PE
4## Copyright (C) 1995, 1997-1998, 2000-2013 Free Software Foundation,
5## Inc.
067d23c9
KY
6
7## This file is part of GNU Emacs.
8
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.
13
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.
18
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/>.
21
22### Commentary:
23
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.
28
29### Code:
30
31progname="$0"
32
33### Exit if a command fails.
34#set -e
35
36### Print out each line we read, for debugging's sake.
37#set -v
38
39LANGUAGE=C
40LC_ALL=C
41LC_MESSAGES=
42LANG=
43export LANGUAGE LC_ALL LC_MESSAGES LANG
44
45## Don't restrict access to any files.
46umask 0
47
48update=yes
49check=yes
50clean_up=no
51make_tar=no
52default_gzip=gzip
53newer=""
54
55while [ $# -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
61 ;;
62 ## This option tells make-dist to make a tar file.
63 "--tar" )
64 make_tar=yes
65 ;;
66 ## This option tells make-dist not to recompile or do analogous things.
67 "--no-update" )
68 update=no
69 ;;
70 ## This option says don't check for bad file names, etc.
71 "--no-check" )
72 check=no
73 ;;
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
81 ;;
82 ## This option tells make-dist to use `bzip2' instead of gzip.
83 "--bzip2")
84 default_gzip="bzip2"
85 ;;
86 ## Same with lzma.
87 "--lzma")
88 default_gzip="lzma"
89 ;;
39aff4a7
GM
90 ## Same with xz.
91 "--xz")
92 default_gzip="xz"
93 ;;
94 "--no-compress")
95 default_gzip="cat"
96 ;;
067d23c9
KY
97
98 "--snapshot")
99 clean_up=yes
100 make_tar=yes
101 update=no
102 check=no
103 ;;
104
105 "--help")
106 echo "Usage: ${progname} [options]"
107 echo ""
108 echo " --bzip2 use bzip2 instead of gzip"
109 echo " --clean-up delete staging directories when done"
110 echo " --lzma use lzma instead of gzip"
39aff4a7
GM
111 echo " --xz use xz instead of gzip"
112 echo " --no-compress don't compress"
067d23c9
KY
113 echo " --newer=TIME don't include files older than TIME"
114 echo " --no-check don't check for bad file names etc."
115 echo " --no-update don't recompile or do analogous things"
116 echo " --snapshot same as --clean-up --no-update --tar --no-check"
117 echo " --tar make a tar file"
118 echo ""
119 exit 0
120 ;;
121
122 * )
123 echo "${progname}: Unrecognized argument: $1" >&2
124 exit 1
125 ;;
126 esac
127 shift
128done
129
130### Make sure we're running in the right place.
131if [ ! -d src -o ! -f src/lisp.h -o ! -d lisp -o ! -f lisp/subr.el ]; then
132 echo "${progname}: Can't find \`src/lisp.h' and \`lisp/subr.el'." >&2
133 echo "${progname} must be run in the top directory of the Emacs" >&2
134 echo "distribution tree. cd to that directory and try again." >&2
135 exit 1
136fi
137
138### Find where to run Emacs.
139### (Accept only absolute file names.)
140if [ $update = yes ];
141then
142 if [ -f src/emacs ];
143 then
144 EMACS=`pwd`/src/emacs
145 else
146 case $EMACS in
147 /*) ;;
148 *)
149 if [ ! -f "$EMACS" ]; then
150 echo "$0: You must set the EMACS environment variable " \
151 "to an absolute file name." 2>&1
152 exit 1
153 fi;;
154 esac
155 fi
156fi
157
158### Find out which version of Emacs this is.
16fab143 159version=`
c4444d16 160 sed -n 's/^AC_INIT(emacs,[ ]*\([^ )]*\).*/\1/p' <configure.ac
16fab143 161` || version=
067d23c9
KY
162if [ ! "${version}" ]; then
163 echo "${progname}: can't find current Emacs version in \`./src/emacs.c'" >&2
164 exit 1
165fi
166
167echo Version number is $version
168
169if [ $update = yes ]; then
170 if ! grep -q "@set EMACSVER *${version}" doc/emacs/emacsver.texi || \
171 ! grep -q "tree holds version *${version}" README; then
172 echo "WARNING: README and/or emacsver.texi have the wrong version number"
173 echo "Consider running M-x set-version from admin/admin.el"
174 sleep 5
175 fi
176fi
177
178### Make sure we don't already have a directory emacs-${version}.
179
180emacsname="emacs-${version}${new_extension}"
181
182if [ -d ${emacsname} ]
183then
184 echo Directory "${emacsname}" already exists >&2
185 exit 1
186fi
187
188### Make sure the subdirectory is available.
189tempparent="make-dist.tmp.$$"
190if [ -d ${tempparent} ]; then
191 echo "${progname}: staging directory \`${tempparent}' already exists.
192Perhaps a previous invocation of \`${progname}' failed to clean up after
193itself. Check that directories whose names are of the form
194\`make-dist.tmp.NNNNN' don't contain any important information, remove
195them, and try again." >&2
196 exit 1
197fi
198
199if [ $check = yes ]; then
200 ls -1 lisp/[a-zA-Z]*.el lisp/[a-z]*/[a-zA-Z0-9]*.el \
201 lisp/[a-z]*/[a-z]*/[a-zA-Z0-9]*.el \
202 lisp/[a-z]*/[a-z]*/[a-z]*/[a-zA-Z0-9]*.el \
203 leim/[a-z]*/[a-z]*.el > /tmp/el
204
205 ls -1 lisp/[a-zA-Z]*.elc lisp/[a-z]*/[a-zA-Z0-9]*.elc \
206 lisp/[a-z]*/[a-z]*/[a-zA-Z0-9]*.elc \
207 lisp/[a-z]*/[a-z]*/[a-z]*/[a-zA-Z0-9]*.elc \
208 leim/[a-z]*/[a-z]*.elc > /tmp/elc
209
210 ## Check for .elc files with no corresponding .el file.
211 sed 's/\.el$/.elc/' /tmp/el > /tmp/elelc
212
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}"
217 fi
218
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`"
222
223 rm -f /tmp/el /tmp/elc /tmp/elcel /tmp/elelc
224
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
231
232 bogosities="$file $bogosities"
233
234 done
235 if [ x"${bogosities}" != x"" ]; then
236 echo "The following .el files have no corresponding .elc files:"
237 echo "${bogosities}"
238 fi
239fi
240
241if [ $update = yes ]; then
242
c4444d16 243 ## Make sure configure is newer than configure.ac, etc.
a02d99e7
GM
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; }
067d23c9 248
c4444d16 249 ## Make sure src/stamp-h.in is newer than configure.ac.
a02d99e7
GM
250 rm -f src/stamp-h.in
251 echo timestamp > src/stamp-h.in
067d23c9
KY
252
253 echo "Updating Info files"
a02d99e7 254 make info-real
067d23c9
KY
255
256 echo "Updating finder, custom and autoload data"
a02d99e7 257 (cd lisp && make updates EMACS="$EMACS")
067d23c9 258
a02d99e7
GM
259 echo "Updating leim-list.el"
260 (cd leim && make leim-list.el EMACS="$EMACS")
067d23c9
KY
261
262 echo "Recompiling Lisp files"
263 $EMACS -batch -f batch-byte-recompile-directory lisp leim
264fi # $update = yes
265
266echo "Creating staging directory: \`${tempparent}'"
267
268mkdir ${tempparent}
269tempdir="${tempparent}/${emacsname}"
270
271### This trap ensures that the staging directory will be cleaned up even
272### when the script is interrupted in mid-career.
273if [ "${clean_up}" = yes ]; then
274 trap "echo 'Cleaning up the staging directory'; rm -rf ${tempparent}" EXIT
275fi
276
277echo "Creating top directory: \`${tempdir}'"
278mkdir ${tempdir}
279
280### We copy in the top-level files before creating the subdirectories in
281### hopes that this will make the top-level files appear first in the
282### tar file; this means that people can start reading the INSTALL and
283### README while the rest of the tar file is still unpacking. Whoopee.
284echo "Making links to top-level files"
24e0f6b1 285ln INSTALL README BUGS ${tempdir}
b8b0239f 286ln ChangeLog Makefile.in autogen.sh configure configure.ac ${tempdir}
ff0c3cfb 287ln config.bat make-dist .dir-locals.el ${tempdir}
9a514d4a 288ln aclocal.m4 ${tempdir}
067d23c9
KY
289
290echo "Creating subdirectories"
291for subdir in site-lisp \
292 leim leim/CXTERM-DIC leim/MISC-DIC \
293 leim/SKK-DIC leim/ja-dic leim/quail \
24e0f6b1 294 build-aux build-aux/snippet \
d66b744d 295 src src/bitmaps lib lib-src oldXMenu lwlib \
067d23c9 296 nt nt/inc nt/inc/sys nt/inc/arpa nt/inc/netinet nt/icons \
6166381e 297 `find etc lisp admin -type d` \
067d23c9 298 doc doc/emacs doc/misc doc/man doc/lispref doc/lispintro \
07f3add9 299 info m4 msdos \
83da1b55
GM
300 nextstep nextstep/templates \
301 nextstep/Cocoa nextstep/Cocoa/Emacs.base \
067d23c9
KY
302 nextstep/Cocoa/Emacs.base/Contents \
303 nextstep/Cocoa/Emacs.base/Contents/Resources \
067d23c9
KY
304 nextstep/GNUstep \
305 nextstep/GNUstep/Emacs.base \
306 nextstep/GNUstep/Emacs.base/Resources
307do
308 ## site-lisp for in-place installs (?).
309 [ "$subdir" = "site-lisp" ] || [ -d "$subdir" ] || \
310 echo "WARNING: $subdir not found, making anyway"
311 echo " ${tempdir}/${subdir}"
312 mkdir ${tempdir}/${subdir}
313done
314
315echo "Making links to \`lisp' and its subdirectories"
316files=`find lisp \( -name '*.el' -o -name '*.elc' -o -name 'ChangeLog*' \
317 -o -name 'README*' \)`
318
319### Don't distribute site-init.el, site-load.el, or default.el.
320for file in lisp/Makefile.in lisp/makefile.w32-in $files; do
321 case $file in
322 */site-init*|*/site-load*|*/default*) continue ;;
323 esac
324 ln $file $tempdir/$file
325done
326
327echo "Making links to \`leim' and its subdirectories"
328(cd leim
329 ln makefile.w32-in ../${tempdir}/leim
330 ln ChangeLog README ../${tempdir}/leim
331 ln CXTERM-DIC/README CXTERM-DIC/*.tit ../${tempdir}/leim/CXTERM-DIC
332 ln SKK-DIC/README SKK-DIC/SKK-JISYO.L ../${tempdir}/leim/SKK-DIC
333 ln MISC-DIC/README MISC-DIC/*.* ../${tempdir}/leim/MISC-DIC
334 ln ja-dic/*.el ja-dic/*.elc ../${tempdir}/leim/ja-dic
335 ln Makefile.in ../${tempdir}/leim/Makefile.in
336 ln leim-ext.el ../${tempdir}/leim/leim-ext.el
337 ## Lisp files that start with a capital (also 4Corner.el) are
338 ## generated from TIT dictionaries so we don't distribute them.
339 ln quail/[a-z]*.el quail/[a-z]*.elc ../${tempdir}/leim/quail
340 rm -f ../${tempdir}/leim/quail/quick-b5.*
341 rm -f ../${tempdir}/leim/quail/quick-cns.*
342 rm -f ../${tempdir}/leim/quail/tsang-b5.*
343 rm -f ../${tempdir}/leim/quail/tsang-cns.*)
344
24e0f6b1
PE
345echo "Making links to \`build-aux'"
346(cd build-aux
347 ln compile config.guess config.sub depcomp ../${tempdir}/build-aux
ff0c3cfb 348 ln install-sh missing move-if-change update-subdirs ../${tempdir}/build-aux)
24e0f6b1
PE
349
350echo "Making links to \`build-aux/snippet'"
351(cd build-aux/snippet
352 ln *.h ../../${tempdir}/build-aux/snippet)
353
067d23c9
KY
354echo "Making links to \`src'"
355### Don't distribute the configured versions of
356### config.in, paths.in, buildobj.h, or Makefile.in.
357(cd src
358 echo " (It is ok if ln fails in some cases.)"
359 ln [a-zA-Z]*.[chm] ../${tempdir}/src
360 ln [a-zA-Z]*.in ../${tempdir}/src
361 ln [a-zA-Z]*.mk ../${tempdir}/src
362 ln README ChangeLog ChangeLog.*[0-9] ../${tempdir}/src
363 ln makefile.w32-in ../${tempdir}/src
364 ln .gdbinit .dbxinit ../${tempdir}/src
365 cd ../${tempdir}/src
57e96f8e 366 rm -f globals.h config.h epaths.h Makefile buildobj.h)
067d23c9
KY
367
368echo "Making links to \`src/bitmaps'"
369(cd src/bitmaps
370 ln README *.xbm ../../${tempdir}/src/bitmaps)
371
9a514d4a 372echo "Making links to \`lib'"
24e0f6b1 373(snippet_h=`(cd build-aux/snippet && ls *.h)`
9a514d4a
PE
374 cd lib
375 ln [a-zA-Z]*.[ch] ../${tempdir}/lib
6e99ef20 376 ln gnulib.mk Makefile.am Makefile.in makefile.w32-in ../${tempdir}/lib
9a514d4a 377 cd ../${tempdir}/lib
24e0f6b1
PE
378 script='/[*]/d; s/\.in\.h$/.h/'
379 rm -f `(echo "$snippet_h"; ls *.in.h) | sed "$script"`)
9a514d4a 380
067d23c9
KY
381echo "Making links to \`lib-src'"
382(cd lib-src
383 ln [a-zA-Z]*.[ch] ../${tempdir}/lib-src
276d5f5d 384 ln ChangeLog Makefile.in README testfile ../${tempdir}/lib-src
418cd726 385 ln grep-changelog rcs2log ../${tempdir}/lib-src
84bbb1ad 386 ln makefile.w32-in ../${tempdir}/lib-src)
067d23c9
KY
387
388echo "Making links to \`m4'"
389(cd m4
390 ln *.m4 ../${tempdir}/m4)
391
067d23c9
KY
392echo "Making links to \`nt'"
393(cd nt
50a60e02
EZ
394 ln emacs-x86.manifest emacs-x64.manifest emacs.rc ../${tempdir}/nt
395 ln config.nt emacsclient.rc emacs-src.tags ../${tempdir}/nt
396 ln nmake.defs gmake.defs subdirs.el [a-z]*.bat [a-z]*.[ch] ../${tempdir}/nt
3e44c782 397 ln ChangeLog INSTALL README README.W32 makefile.w32-in ../${tempdir}/nt)
067d23c9
KY
398
399echo "Making links to \`nt/inc' and its subdirectories"
400for f in `find nt/inc -type f -name '[a-z]*.h'`; do
401 ln $f $tempdir/$f
402done
403
404echo "Making links to \`nt/icons'"
405(cd nt/icons
406 ln README [a-z]*.ico ../../${tempdir}/nt/icons
407 ln [a-z]*.cur ../../${tempdir}/nt/icons)
408
409echo "Making links to \`msdos'"
410(cd msdos
411 ln ChangeLog INSTALL README emacs.ico emacs.pif ../${tempdir}/msdos
0bd3cb7b 412 ln depfiles.bat inttypes.h ../${tempdir}/msdos
067d23c9
KY
413 ln is_exec.c sigaction.c mainmake.v2 sed*.inp ../${tempdir}/msdos)
414
415echo "Making links to \`nextstep'"
416(cd nextstep
92f7c6f1 417 ln ChangeLog README INSTALL Makefile.in ../${tempdir}/nextstep)
067d23c9 418
83da1b55
GM
419echo "Making links to \`nextstep/templates'"
420(cd nextstep/templates
51eed9b8 421 ln Emacs.desktop.in Info-gnustep.plist.in Info.plist.in InfoPlist.strings.in ../../${tempdir}/nextstep/templates)
83da1b55 422
067d23c9
KY
423echo "Making links to \`nextstep/Cocoa/Emacs.base/Contents'"
424(cd nextstep/Cocoa/Emacs.base/Contents
83da1b55 425 ln PkgInfo ../../../../${tempdir}/nextstep/Cocoa/Emacs.base/Contents)
067d23c9
KY
426
427echo "Making links to \`nextstep/Cocoa/Emacs.base/Contents/Resources'"
428(cd nextstep/Cocoa/Emacs.base/Contents/Resources
429 ln Credits.html *.icns ../../../../../${tempdir}/nextstep/Cocoa/Emacs.base/Contents/Resources)
430
067d23c9
KY
431echo "Making links to \`nextstep/GNUstep/Emacs.base/Resources'"
432(cd nextstep/GNUstep/Emacs.base/Resources
83da1b55 433 ln README emacs.tiff ../../../../${tempdir}/nextstep/GNUstep/Emacs.base/Resources )
067d23c9
KY
434
435echo "Making links to \`oldXMenu'"
436(cd oldXMenu
437 ln *.[ch] *.in ../${tempdir}/oldXMenu
438 ln README ChangeLog ../${tempdir}/oldXMenu)
439
440echo "Making links to \`lwlib'"
441(cd lwlib
442 ln *.[ch] *.in ../${tempdir}/lwlib
443 ln README ChangeLog ../${tempdir}/lwlib)
444
6166381e
CY
445echo "Making links to \`admin' and its subdirectories"
446for f in `find admin -type f`; do
447 ln $f $tempdir/$f
448done
449
067d23c9
KY
450echo "Making links to \`etc' and its subdirectories"
451for f in `find etc -type f`; do
452 case $f in
838db889 453 etc/DOC*|etc/*.pyc) continue ;;
067d23c9
KY
454 esac
455 ln $f $tempdir/$f
456done
457
458echo "Making links to \`info'"
459ln `find info -type f -print` ${tempdir}/info
460
461echo "Making links to \`doc/emacs'"
462(cd doc/emacs
463 ln *.texi *.in makefile.w32-in ChangeLog* ../../${tempdir}/doc/emacs)
464
465echo "Making links to \`doc/misc'"
466(cd doc/misc
467 ln *.texi *.tex *.in makefile.w32-in gnus-news.el ChangeLog* ../../${tempdir}/doc/misc)
468
469echo "Making links to \`doc/lispref'"
470(cd doc/lispref
471 ln *.texi *.in makefile.w32-in README ChangeLog* ../../${tempdir}/doc/lispref
5122804a
GM
472 ln spellfile ../../${tempdir}/doc/lispref
473 ln two-volume.make two-volume-cross-refs.txt ../../${tempdir}/doc/lispref)
067d23c9
KY
474
475echo "Making links to \`doc/lispintro'"
476(cd doc/lispintro
477 ln *.texi *.in makefile.w32-in *.eps *.pdf ../../${tempdir}/doc/lispintro
478 ln README ChangeLog* ../../${tempdir}/doc/lispintro
479 cd ../../${tempdir}/doc/lispintro)
480
481echo "Making links to \`doc/man'"
482(cd doc/man
483 ln ChangeLog* *.1 ../../${tempdir}/doc/man
484 cd ../../${tempdir}/doc/man)
485
486### It would be nice if they could all be symlinks to top-level copy, but
487### you're not supposed to have any symlinks in distribution tar files.
488echo "Making sure copying notices are all copies of \`COPYING'"
9a514d4a 489for subdir in . etc info leim lib lib-src lisp lwlib msdos nt src; do
067d23c9
KY
490 rm -f ${tempdir}/${subdir}/COPYING
491 cp COPYING ${tempdir}/${subdir}
492done
493
494if [ "${newer}" ]; then
495 echo "Removing files older than $newer"
496 ## We remove .elc files unconditionally, on the theory that anyone picking
497 ## up an incremental distribution already has a running Emacs to byte-compile
498 ## them with.
499 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
500fi
501
502## Don't distribute backups, autosaves, etc.
503echo "Removing unwanted files"
504find ${tempparent} \( -name '*~' -o -name '#*#' -o -name '.*ignore' -o -name '=*' -o -name 'TAGS' \) -exec rm -f {} \;
505
506if [ "${make_tar}" = yes ]; then
507 echo "Looking for $default_gzip"
508 found=0
509 temppath=`echo $PATH | sed -e 's/^:/.:/' -e 's/::/:.:/g' -e 's/:$/:./' \
510 -e 's/:/ /g'`
511 for dir in ${temppath}; do
512 [ -x ${dir}/$default_gzip ] || continue
513 found=1; break
514 done
515 if [ "$found" = "0" ]; then
516 echo "WARNING: \`$default_gzip' not found, will not compress" >&2
517 default_gzip=cat
518 fi
519 case "${default_gzip}" in
520 bzip2) gzip_extension=.bz2 ;;
521 lzma) gzip_extension=.lzma ;;
39aff4a7 522 xz) gzip_extension=.xz ;;
067d23c9
KY
523 gzip) gzip_extension=.gz ; default_gzip="gzip --best";;
524 *) gzip_extension= ;;
525 esac
526 echo "Creating tar file"
527 (cd ${tempparent} ; tar cvf - ${emacsname} ) \
528 | ${default_gzip} \
529 > ${emacsname}.tar${gzip_extension}
530fi
531
532if [ "${clean_up}" != yes ]; then
533 (cd ${tempparent}; mv ${emacsname} ..)
534 rm -rf ${tempparent}
535fi
536
537### make-dist ends here