diff-sentinel trivia.
[bpt/emacs.git] / make-dist
... / ...
CommitLineData
1#!/bin/sh
2### make-dist: create an Emacs distribution tar file from current srcdir
3
4## Copyright (C) 1995, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005,
5## 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
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.
150version=`sed -n '/char emacs_version/ s/^[^"]*"\([^"]*\)".*$/\1/p' src/emacs.c`
151if [ ! "${version}" ]; then
152 echo "${progname}: can't find current Emacs version in \`./src/emacs.c'" >&2
153 exit 1
154fi
155
156echo Version number is $version
157
158if [ $update = yes ]; then
159 if ! grep -q "@set EMACSVER *${version}" doc/emacs/emacsver.texi || \
160 ! grep -q "tree holds version *${version}" README; then
161 echo "WARNING: README and/or emacsver.texi have the wrong version number"
162 echo "Consider running M-x set-version from admin/admin.el"
163 sleep 5
164 fi
165fi
166
167### Make sure we don't already have a directory emacs-${version}.
168
169emacsname="emacs-${version}${new_extension}"
170
171if [ -d ${emacsname} ]
172then
173 echo Directory "${emacsname}" already exists >&2
174 exit 1
175fi
176
177### Make sure the subdirectory is available.
178tempparent="make-dist.tmp.$$"
179if [ -d ${tempparent} ]; then
180 echo "${progname}: staging directory \`${tempparent}' already exists.
181Perhaps a previous invocation of \`${progname}' failed to clean up after
182itself. Check that directories whose names are of the form
183\`make-dist.tmp.NNNNN' don't contain any important information, remove
184them, and try again." >&2
185 exit 1
186fi
187
188if [ $check = yes ]; then
189 ls -1 lisp/[a-zA-Z]*.el lisp/[a-z]*/[a-zA-Z0-9]*.el \
190 lisp/[a-z]*/[a-z]*/[a-zA-Z0-9]*.el \
191 lisp/[a-z]*/[a-z]*/[a-z]*/[a-zA-Z0-9]*.el \
192 leim/[a-z]*/[a-z]*.el > /tmp/el
193
194 ls -1 lisp/[a-zA-Z]*.elc lisp/[a-z]*/[a-zA-Z0-9]*.elc \
195 lisp/[a-z]*/[a-z]*/[a-zA-Z0-9]*.elc \
196 lisp/[a-z]*/[a-z]*/[a-z]*/[a-zA-Z0-9]*.elc \
197 leim/[a-z]*/[a-z]*.elc > /tmp/elc
198
199 ## Check for .elc files with no corresponding .el file.
200 sed 's/\.el$/.elc/' /tmp/el > /tmp/elelc
201
202 bogosities="`comm -13 /tmp/elelc /tmp/elc`"
203 if [ x"${bogosities}" != x"" ]; then
204 echo "The following .elc files have no corresponding .el files:"
205 echo "${bogosities}"
206 fi
207
208 ### Check for .el files with no corresponding .elc file.
209 sed 's/\.elc$/.el/' /tmp/elc > /tmp/elcel
210 losers="`comm -23 /tmp/el /tmp/elcel`"
211
212 rm -f /tmp/el /tmp/elc /tmp/elcel /tmp/elelc
213
214 bogosities=
215 for file in $losers; do
216 grep -q "no-byte-compile: t" $file && continue
217 case $file in
218 site-init.el | site-load.el | site-start.el | default.el) continue ;;
219 esac
220
221 bogosities="$file $bogosities"
222
223 done
224 if [ x"${bogosities}" != x"" ]; then
225 echo "The following .el files have no corresponding .elc files:"
226 echo "${bogosities}"
227 fi
228fi
229
230if [ $update = yes ]; then
231
232 ## Make sure configure is newer than configure.in.
233 if [ "x`ls -t configure configure.in | sed q`" != "xconfigure" ]; then
234 echo "\`./configure.in' is newer than \`./configure'" >&2
235 echo "Running autoconf" >&2
236 autoconf || { x=$?; echo Autoconf FAILED! >&2; exit $x; }
237 fi
238
239 ## Make sure src/stamp-h.in is newer than configure.in.
240 if [ "x`ls -t src/stamp-h.in configure.in | sed q`" != "xsrc/stamp-h.in" ]; then
241 echo "\`./configure.in' is newer than \`./src/stamp-h.in'" >&2
242 echo "Running autoheader" >&2
243 autoheader || { x=$?; echo Autoheader FAILED! >&2; exit $x; }
244 rm -f src/stamp-h.in
245 echo timestamp > src/stamp-h.in
246 fi
247
248 echo "Updating Info files"
249 (cd doc/emacs; make info)
250 (cd doc/misc; make info)
251 (cd doc/lispref; make info)
252 (cd doc/lispintro; make info)
253
254 echo "Updating finder, custom and autoload data"
255 (cd lisp; make updates EMACS="$EMACS")
256
257 if test -f leim/leim-list.el; then
258 echo "Updating leim-list.el"
259 (cd leim; make leim-list.el EMACS="$EMACS")
260 fi
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"
285ln INSTALL README BUGS move-if-change ${tempdir}
286ln ChangeLog Makefile.in configure configure.in ${tempdir}
287ln config.bat make-dist update-subdirs vpath.sed .dir-locals.el ${tempdir}
288ln mkinstalldirs config.sub config.guess install-sh ${tempdir}
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 \
294 src src/m src/s src/bitmaps lib-src oldXMenu lwlib \
295 nt nt/inc nt/inc/sys nt/inc/arpa nt/inc/netinet nt/icons \
296 `find etc lisp -type d` \
297 doc doc/emacs doc/misc doc/man doc/lispref doc/lispintro \
298 info m4 msdos \
299 nextstep nextstep/Cocoa nextstep/Cocoa/Emacs.base \
300 nextstep/Cocoa/Emacs.base/Contents \
301 nextstep/Cocoa/Emacs.base/Contents/Resources \
302 nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj \
303 nextstep/Cocoa/Emacs.xcodeproj \
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
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
357 rm -f config.h epaths.h Makefile buildobj.h)
358
359echo "Making links to \`src/bitmaps'"
360(cd src/bitmaps
361 ln README *.xbm ../../${tempdir}/src/bitmaps)
362
363echo "Making links to \`src/m'"
364(cd src/m
365 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/m)
366
367echo "Making links to \`src/s'"
368(cd src/s
369 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/s)
370
371echo "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 vcdiff ../${tempdir}/lib-src
375 ln grep-changelog rcs2log rcs-checkin ../${tempdir}/lib-src
376 ln makefile.w32-in ../${tempdir}/lib-src
377 cd ../${tempdir}/lib-src
378 rm -f getopt.h)
379
380echo "Making links to \`m4'"
381(cd m4
382 ln *.m4 ../${tempdir}/m4)
383
384## Exclude README.W32 because it is specific to pre-built binaries(?).
385echo "Making links to \`nt'"
386(cd nt
387 ln emacs.manifest emacs.rc emacsclient.rc config.nt ../${tempdir}/nt
388 ln emacs-src.tags nmake.defs gmake.defs subdirs.el ../${tempdir}/nt
389 ln [a-z]*.bat [a-z]*.[ch] ../${tempdir}/nt
390 ln ChangeLog INSTALL README makefile.w32-in ../${tempdir}/nt)
391
392echo "Making links to \`nt/inc' and its subdirectories"
393for f in `find nt/inc -type f -name '[a-z]*.h'`; do
394 ln $f $tempdir/$f
395done
396
397echo "Making links to \`nt/icons'"
398(cd nt/icons
399 ln README [a-z]*.ico ../../${tempdir}/nt/icons
400 ln [a-z]*.cur ../../${tempdir}/nt/icons)
401
402echo "Making links to \`msdos'"
403(cd msdos
404 ln ChangeLog INSTALL README emacs.ico emacs.pif ../${tempdir}/msdos
405 ln is_exec.c sigaction.c mainmake.v2 sed*.inp ../${tempdir}/msdos)
406
407echo "Making links to \`nextstep'"
408(cd nextstep
409 ln ChangeLog README INSTALL ../${tempdir}/nextstep)
410
411echo "Making links to \`nextstep/Cocoa/Emacs.base/Contents'"
412(cd nextstep/Cocoa/Emacs.base/Contents
413 ln Info.plist PkgInfo ../../../../${tempdir}/nextstep/Cocoa/Emacs.base/Contents)
414
415echo "Making links to \`nextstep/Cocoa/Emacs.base/Contents/Resources'"
416(cd nextstep/Cocoa/Emacs.base/Contents/Resources
417 ln Credits.html *.icns ../../../../../${tempdir}/nextstep/Cocoa/Emacs.base/Contents/Resources)
418
419echo "Making links to \`nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj'"
420(cd nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj
421 ln InfoPlist.strings ../../../../../../${tempdir}/nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj)
422
423echo "Making links to \`nextstep/Cocoa/Emacs.xcodeproj'"
424(cd nextstep/Cocoa/Emacs.xcodeproj
425 ln project.pbxproj ../../../${tempdir}/nextstep/Cocoa/Emacs.xcodeproj)
426
427echo "Making links to \`nextstep/GNUstep/Emacs.base/Resources'"
428(cd nextstep/GNUstep/Emacs.base/Resources
429 ln Emacs.desktop Info-gnustep.plist README emacs.tiff ../../../../${tempdir}/nextstep/GNUstep/Emacs.base/Resources )
430
431echo "Making links to \`oldXMenu'"
432(cd oldXMenu
433 ln *.[ch] *.in ../${tempdir}/oldXMenu
434 ln README ChangeLog ../${tempdir}/oldXMenu)
435
436echo "Making links to \`lwlib'"
437(cd lwlib
438 ln *.[ch] *.in ../${tempdir}/lwlib
439 ln README ChangeLog ../${tempdir}/lwlib)
440
441echo "Making links to \`etc' and its subdirectories"
442for f in `find etc -type f`; do
443 case $f in
444 etc/DOC*) continue ;;
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
463 ln *.txt *.el spellfile tindex.pl ../../${tempdir}/doc/lispref
464 ln two-volume.make ../../${tempdir}/doc/lispref)
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'"
480for subdir in . etc info leim lib-src lisp lwlib msdos nt src; do
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