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