shr.el (shr-tag-a): Use url-link as widget type.
[emacs.git] / make-dist
blob713d88481b3c644c84c1c78f5b5ffb62532cafc2
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 default_gzip=gzip
53 newer=""
55 while [ $# -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
62 ## This option tells make-dist to make a tar file.
63 "--tar" )
64 make_tar=yes
66 ## This option tells make-dist not to recompile or do analogous things.
67 "--no-update" )
68 update=no
70 ## This option says don't check for bad file names, etc.
71 "--no-check" )
72 check=no
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
82 ## This option tells make-dist to use `bzip2' instead of gzip.
83 "--bzip2")
84 default_gzip="bzip2"
86 ## Same with lzma.
87 "--lzma")
88 default_gzip="lzma"
91 "--snapshot")
92 clean_up=yes
93 make_tar=yes
94 update=no
95 check=no
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
114 echo "${progname}: Unrecognized argument: $1" >&2
115 exit 1
117 esac
118 shift
119 done
121 ### Make sure we're running in the right place.
122 if [ ! -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
129 ### Find where to run Emacs.
130 ### (Accept only absolute file names.)
131 if [ $update = yes ];
132 then
133 unset EMACS_UNIBYTE
134 if [ -f src/emacs ];
135 then
136 EMACS=`pwd`/src/emacs
137 else
138 case $EMACS in
139 /*) ;;
141 if [ ! -f "$EMACS" ]; then
142 echo "$0: You must set the EMACS environment variable " \
143 "to an absolute file name." 2>&1
144 exit 1
145 fi;;
146 esac
150 ### Find out which version of Emacs this is.
151 version=`sed -n '/char emacs_version/ s/^[^"]*"\([^"]*\)".*$/\1/p' src/emacs.c`
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 ### Find where to run Emacs.
190 if [ $check = yes ];
191 then
192 ### Check for .elc files with no corresponding .el file.
193 ls -1 lisp/[a-zA-Z]*.el lisp/[a-z]*/[a-zA-Z0-9]*.el \
194 lisp/[a-z]*/[a-z]*/[a-zA-Z0-9]*.el \
195 lisp/[a-z]*/[a-z]*/[a-z]*/[a-zA-Z0-9]*.el \
196 leim/[a-z]*/[a-z]*.el | sed 's/\.el$/.elc/' > /tmp/el
197 ls -1 lisp/[a-zA-Z]*.elc lisp/[a-z]*/[a-zA-Z0-9]*.elc \
198 lisp/[a-z]*/[a-z]*/[a-zA-Z0-9]*.elc \
199 lisp/[a-z]*/[a-z]*/[a-z]*/[a-zA-Z0-9]*.elc \
200 leim/[a-z]*/[a-z]*.elc > /tmp/elc
201 bogosities="`comm -13 /tmp/el /tmp/elc`"
202 if [ "${bogosities}" != "" ]; then
203 echo "The following .elc files have no corresponding .el files:"
204 echo "${bogosities}"
206 rm -f /tmp/el /tmp/elc
208 ### Check for .el files with no corresponding .elc file.
209 ls -1 lisp/[a-zA-Z]*.el lisp/[a-z]*/[a-zA-Z0-9]*.el \
210 lisp/[a-z]*/[a-z]*/[a-zA-Z0-9]*.el \
211 lisp/[a-z]*/[a-z]*/[a-z]*/[a-zA-Z0-9]*.el \
212 leim/[a-z]*/[a-z]*.el > /tmp/el
213 ls -1 lisp/[a-zA-Z]*.elc lisp/[a-z]*/[a-zA-Z0-9]*.elc \
214 lisp/[a-z]*/[a-z]*/[a-zA-Z0-9]*.el \
215 lisp/[a-z]*/[a-z]*/[a-z]*/[a-zA-Z0-9]*.el \
216 leim/[a-z]*/[a-z]*.elc | sed 's/\.elc$/.el/' > /tmp/elc
217 losers="`comm -23 /tmp/el /tmp/elc`"
218 bogosities=
219 for file in $losers; do
220 if ! grep -q "no-byte-compile: t" $file; then
221 case $file in
222 site-init.el | site-load.el | site-start.el | default.el)
225 bogosities="$file $bogosities"
227 esac
229 done
230 if [ x"${bogosities}" != x"" ]; then
231 echo "The following .el files have no corresponding .elc files:"
232 echo "${bogosities}"
234 rm -f /tmp/el /tmp/elc
237 ### Make sure configure is newer than configure.in.
238 if [ "x`ls -t configure configure.in | sed q`" != "xconfigure" ]; then
239 echo "\`./configure.in' is newer than \`./configure'" >&2
240 echo "Running autoconf" >&2
241 autoconf || { x=$?; echo Autoconf FAILED! >&2; exit $x; }
244 ### Make sure src/stamp-h.in is newer than configure.in.
245 if [ "x`ls -t src/stamp-h.in configure.in | sed q`" != "xsrc/stamp-h.in" ]; then
246 echo "\`./configure.in' is newer than \`./src/stamp-h.in'" >&2
247 echo "Running autoheader" >&2
248 autoheader || { x=$?; echo Autoheader FAILED! >&2; exit $x; }
249 rm -f src/stamp-h.in
250 echo timestamp > src/stamp-h.in
253 if [ $update = yes ];
254 then
255 echo "Updating Info files"
256 (cd doc/emacs; make info)
257 (cd doc/misc; make info)
258 (cd doc/lispref; make info)
259 (cd doc/lispintro; make info)
261 echo "Updating finder, custom and autoload data"
262 (cd lisp; make updates EMACS="$EMACS")
264 if test -f leim/leim-list.el; then
265 echo "Updating leim-list.el"
266 (cd leim; make leim-list.el EMACS="$EMACS")
269 echo "Recompiling Lisp files"
270 $EMACS -batch -f batch-byte-recompile-directory lisp leim
273 ## What is this file for? It goes in srcdir, not the tarfile.
274 ## Why does it exclude term/ ?
275 echo "Making lisp/MANIFEST"
277 files=`find lisp -type f -name '*.el'`
278 for file in $files; do
279 case "$file" in
280 */subdirs.el|*/default.el|*/loaddefs.el|*/term/*) continue ;;
281 esac
282 sed -n 's/^;;; //p; q' $file
283 done | sort > lisp/MANIFEST
285 echo "Creating staging directory: \`${tempparent}'"
287 mkdir ${tempparent}
288 tempdir="${tempparent}/${emacsname}"
290 ### This trap ensures that the staging directory will be cleaned up even
291 ### when the script is interrupted in mid-career.
292 if [ "${clean_up}" = yes ]; then
293 trap "echo 'Cleaning up the staging directory'; rm -rf ${tempparent}" EXIT
296 echo "Creating top directory: \`${tempdir}'"
297 mkdir ${tempdir}
299 ### We copy in the top-level files before creating the subdirectories in
300 ### hopes that this will make the top-level files appear first in the
301 ### tar file; this means that people can start reading the INSTALL and
302 ### README while the rest of the tar file is still unpacking. Whoopee.
303 echo "Making links to top-level files"
304 ln INSTALL README BUGS move-if-change ${tempdir}
305 ln ChangeLog Makefile.in configure configure.in ${tempdir}
306 ln config.bat make-dist update-subdirs vpath.sed .dir-locals.el ${tempdir}
307 ln mkinstalldirs config.sub config.guess install-sh ${tempdir}
309 echo "Creating subdirectories"
310 for subdir in site-lisp \
311 leim leim/CXTERM-DIC leim/MISC-DIC \
312 leim/SKK-DIC leim/ja-dic leim/quail \
313 src src/m src/s src/bitmaps lib-src oldXMenu lwlib \
314 nt nt/inc nt/inc/sys nt/inc/arpa nt/inc/netinet nt/icons \
315 `find etc lisp -type d` \
316 doc doc/emacs doc/misc doc/man doc/lispref doc/lispintro \
317 info m4 msdos \
318 nextstep nextstep/Cocoa nextstep/Cocoa/Emacs.base \
319 nextstep/Cocoa/Emacs.base/Contents \
320 nextstep/Cocoa/Emacs.base/Contents/Resources \
321 nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj \
322 nextstep/Cocoa/Emacs.xcodeproj \
323 nextstep/GNUstep \
324 nextstep/GNUstep/Emacs.base \
325 nextstep/GNUstep/Emacs.base/Resources
327 ## site-lisp for in-place installs (?).
328 [ "$subdir" = "site-lisp" ] || [ -d "$subdir" ] || \
329 echo "WARNING: $subdir not found, making anyway"
330 echo " ${tempdir}/${subdir}"
331 mkdir ${tempdir}/${subdir}
332 done
334 echo "Making links to \`lisp' and its subdirectories"
335 files=`find lisp \( -name '*.el' -o -name '*.elc' -o -name 'ChangeLog*' \
336 -o -name 'README*' \)`
338 ### Don't distribute site-init.el, site-load.el, or default.el.
339 for file in lisp/Makefile.in lisp/makefile.w32-in $files; do
340 case $file in
341 */site-init*|*/site-load*|*/default*) continue ;;
342 esac
343 ln $file $tempdir/$file
344 done
346 echo "Making links to \`leim' and its subdirectories"
347 (cd leim
348 ln makefile.w32-in ../${tempdir}/leim
349 ln ChangeLog README ../${tempdir}/leim
350 ln CXTERM-DIC/README CXTERM-DIC/*.tit ../${tempdir}/leim/CXTERM-DIC
351 ln SKK-DIC/README SKK-DIC/SKK-JISYO.L ../${tempdir}/leim/SKK-DIC
352 ln MISC-DIC/README MISC-DIC/*.* ../${tempdir}/leim/MISC-DIC
353 ln ja-dic/*.el ja-dic/*.elc ../${tempdir}/leim/ja-dic
354 ln Makefile.in ../${tempdir}/leim/Makefile.in
355 ln leim-ext.el ../${tempdir}/leim/leim-ext.el
356 ## Lisp files that start with a capital (also 4Corner.el) are
357 ## generated from TIT dictionaries so we don't distribute them.
358 ln quail/[a-z]*.el quail/[a-z]*.elc ../${tempdir}/leim/quail
359 rm -f ../${tempdir}/leim/quail/quick-b5.*
360 rm -f ../${tempdir}/leim/quail/quick-cns.*
361 rm -f ../${tempdir}/leim/quail/tsang-b5.*
362 rm -f ../${tempdir}/leim/quail/tsang-cns.*)
364 echo "Making links to \`src'"
365 ### Don't distribute the configured versions of
366 ### config.in, paths.in, buildobj.h, or Makefile.in.
367 (cd src
368 echo " (It is ok if ln fails in some cases.)"
369 ln [a-zA-Z]*.[chm] ../${tempdir}/src
370 ln [a-zA-Z]*.in ../${tempdir}/src
371 ln [a-zA-Z]*.mk ../${tempdir}/src
372 ln README ChangeLog ChangeLog.*[0-9] ../${tempdir}/src
373 ln makefile.w32-in ../${tempdir}/src
374 ln .gdbinit .dbxinit ../${tempdir}/src
375 cd ../${tempdir}/src
376 rm -f config.h epaths.h Makefile buildobj.h)
378 echo "Making links to \`src/bitmaps'"
379 (cd src/bitmaps
380 ln README *.xbm ../../${tempdir}/src/bitmaps)
382 echo "Making links to \`src/m'"
383 (cd src/m
384 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/m)
386 echo "Making links to \`src/s'"
387 (cd src/s
388 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/s)
390 echo "Making links to \`lib-src'"
391 (cd lib-src
392 ln [a-zA-Z]*.[ch] ../${tempdir}/lib-src
393 ln ChangeLog Makefile.in README testfile vcdiff ../${tempdir}/lib-src
394 ln grep-changelog rcs2log rcs-checkin ../${tempdir}/lib-src
395 ln makefile.w32-in ../${tempdir}/lib-src
396 cd ../${tempdir}/lib-src
397 rm -f getopt.h)
399 echo "Making links to \`m4'"
400 (cd m4
401 ln *.m4 ../${tempdir}/m4)
403 ## Exclude README.W32 because it is specific to pre-built binaries(?).
404 echo "Making links to \`nt'"
405 (cd nt
406 ln emacs.manifest emacs.rc emacsclient.rc config.nt ../${tempdir}/nt
407 ln emacs-src.tags nmake.defs gmake.defs subdirs.el ../${tempdir}/nt
408 ln [a-z]*.bat [a-z]*.[ch] ../${tempdir}/nt
409 ln ChangeLog INSTALL README makefile.w32-in ../${tempdir}/nt)
411 echo "Making links to \`nt/inc' and its subdirectories"
412 for f in `find nt/inc -type f -name '[a-z]*.h'`; do
413 ln $f $tempdir/$f
414 done
416 echo "Making links to \`nt/icons'"
417 (cd nt/icons
418 ln README [a-z]*.ico ../../${tempdir}/nt/icons
419 ln [a-z]*.cur ../../${tempdir}/nt/icons)
421 echo "Making links to \`msdos'"
422 (cd msdos
423 ln ChangeLog INSTALL README emacs.ico emacs.pif ../${tempdir}/msdos
424 ln is_exec.c sigaction.c mainmake.v2 sed*.inp ../${tempdir}/msdos)
426 echo "Making links to \`nextstep'"
427 (cd nextstep
428 ln ChangeLog README INSTALL ../${tempdir}/nextstep)
430 echo "Making links to \`nextstep/Cocoa/Emacs.base/Contents'"
431 (cd nextstep/Cocoa/Emacs.base/Contents
432 ln Info.plist PkgInfo ../../../../${tempdir}/nextstep/Cocoa/Emacs.base/Contents)
434 echo "Making links to \`nextstep/Cocoa/Emacs.base/Contents/Resources'"
435 (cd nextstep/Cocoa/Emacs.base/Contents/Resources
436 ln Credits.html *.icns ../../../../../${tempdir}/nextstep/Cocoa/Emacs.base/Contents/Resources)
438 echo "Making links to \`nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj'"
439 (cd nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj
440 ln InfoPlist.strings ../../../../../../${tempdir}/nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj)
442 echo "Making links to \`nextstep/Cocoa/Emacs.xcodeproj'"
443 (cd nextstep/Cocoa/Emacs.xcodeproj
444 ln project.pbxproj ../../../${tempdir}/nextstep/Cocoa/Emacs.xcodeproj)
446 echo "Making links to \`nextstep/GNUstep/Emacs.base/Resources'"
447 (cd nextstep/GNUstep/Emacs.base/Resources
448 ln Emacs.desktop Info-gnustep.plist README emacs.tiff ../../../../${tempdir}/nextstep/GNUstep/Emacs.base/Resources )
450 echo "Making links to \`oldXMenu'"
451 (cd oldXMenu
452 ln *.[ch] *.in ../${tempdir}/oldXMenu
453 ln README ChangeLog ../${tempdir}/oldXMenu)
455 echo "Making links to \`lwlib'"
456 (cd lwlib
457 ln *.[ch] *.in ../${tempdir}/lwlib
458 ln README ChangeLog ../${tempdir}/lwlib)
460 echo "Making links to \`etc' and its subdirectories"
461 for f in `find etc -type f`; do
462 case $f in
463 etc/DOC*) continue ;;
464 esac
465 ln $f $tempdir/$f
466 done
468 echo "Making links to \`info'"
469 ln `find info -type f -print` ${tempdir}/info
471 echo "Making links to \`doc/emacs'"
472 (cd doc/emacs
473 ln *.texi *.in makefile.w32-in ChangeLog* ../../${tempdir}/doc/emacs)
475 echo "Making links to \`doc/misc'"
476 (cd doc/misc
477 ln *.texi *.tex *.in makefile.w32-in gnus-news.el ChangeLog* ../../${tempdir}/doc/misc)
479 echo "Making links to \`doc/lispref'"
480 (cd doc/lispref
481 ln *.texi *.in makefile.w32-in README ChangeLog* ../../${tempdir}/doc/lispref
482 ln *.txt *.el spellfile tindex.pl ../../${tempdir}/doc/lispref
483 ln two-volume.make ../../${tempdir}/doc/lispref)
485 echo "Making links to \`doc/lispintro'"
486 (cd doc/lispintro
487 ln *.texi *.in makefile.w32-in *.eps *.pdf ../../${tempdir}/doc/lispintro
488 ln README ChangeLog* ../../${tempdir}/doc/lispintro
489 cd ../../${tempdir}/doc/lispintro)
491 echo "Making links to \`doc/man'"
492 (cd doc/man
493 ln ChangeLog* *.1 ../../${tempdir}/doc/man
494 cd ../../${tempdir}/doc/man)
496 ### It would be nice if they could all be symlinks to top-level copy, but
497 ### you're not supposed to have any symlinks in distribution tar files.
498 echo "Making sure copying notices are all copies of \`COPYING'"
499 for subdir in . etc info leim lib-src lisp lwlib msdos nt src; do
500 rm -f ${tempdir}/${subdir}/COPYING
501 cp COPYING ${tempdir}/${subdir}
502 done
504 if [ "${newer}" ]; then
505 echo "Removing files older than $newer"
506 ## We remove .elc files unconditionally, on the theory that anyone picking
507 ## up an incremental distribution already has a running Emacs to byte-compile
508 ## them with.
509 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
512 ## Don't distribute backups, autosaves, etc.
513 echo "Removing unwanted files"
514 find ${tempparent} \( -name '*~' -o -name '#*#' -o -name '.*ignore' -o -name '=*' -o -name 'TAGS' \) -exec rm -f {} \;
516 if [ "${make_tar}" = yes ]; then
517 echo "Looking for $default_gzip"
518 found=0
519 temppath=`echo $PATH | sed -e 's/^:/.:/' -e 's/::/:.:/g' -e 's/:$/:./' \
520 -e 's/:/ /g'`
521 for dir in ${temppath}; do
522 [ -x ${dir}/$default_gzip ] || continue
523 found=1; break
524 done
525 if [ "$found" = "0" ]; then
526 echo "WARNING: \`$default_gzip' not found, will not compress" >&2
527 default_gzip=cat
529 case "${default_gzip}" in
530 bzip2) gzip_extension=.bz2 ;;
531 lzma) gzip_extension=.lzma ;;
532 gzip) gzip_extension=.gz ; default_gzip="gzip --best";;
533 *) gzip_extension= ;;
534 esac
535 echo "Creating tar file"
536 (cd ${tempparent} ; tar cvf - ${emacsname} ) \
537 | ${default_gzip} \
538 > ${emacsname}.tar${gzip_extension}
541 if [ "${clean_up}" != yes ]; then
542 (cd ${tempparent}; mv ${emacsname} ..)
543 rm -rf ${tempparent}
546 ### make-dist ends here