Removed several more gratuitous autoload cookies.
[emacs.git] / make-dist
blob141b6d5e6a5974aed1ab1dcbe4c3a3c28514f0c9
1 #!/bin/sh
3 #### make-dist: create an Emacs distribution tar file from the current
4 #### source tree. This basically creates a duplicate directory
5 #### structure, and then hard links into it only those files that should
6 #### be distributed. This means that if you add a file with an odd name,
7 #### you should make sure that this script will include it.
9 progname="$0"
11 ### Exit if a command fails.
12 ### set -e
14 ### Print out each line we read, for debugging's sake.
15 ### set -v
17 clean_up=yes
18 make_tar=yes
19 newer=""
21 while [ $# -gt 0 ]; do
22 case "$1" in
23 ## This option tells make-dist not to delete the staging directory
24 ## after it's done making the tar file.
25 "--no-clean-up" )
26 clean_up=no
28 ## This option tells make-dist not to make a tar file. Since it's
29 ## rather pointless to build the whole staging directory and then
30 ## nuke it, using this option also selects '--no-clean-up'.
31 "--no-tar" )
32 make_tar=no
33 clean_up=no
35 ## This option tells make-dist to make the distribution normally, then
36 ## remove all files older than the given timestamp file. This is useful
37 ## for creating incremental or patch distributions.
38 "--newer")
39 newer="$2"
40 new_extension=".new"
41 shift
43 ## This option tells make-dist to use `compress' instead of gzip.
44 ## Normally, make-dist uses gzip whenever it is present.
45 "--compress")
46 default_gzip="compress"
48 * )
49 echo "${progname}: Unrecognized argument: $1" >&2
50 exit 1
52 esac
53 shift
54 done
56 ### Make sure we're running in the right place.
57 if [ ! -d src -o ! -f src/lisp.h -o ! -d lisp -o ! -f lisp/version.el ]; then
58 echo "${progname}: Can't find \`src/lisp.h' and \`lisp/version.el'." >&2
59 echo "${progname} must be run in the top directory of the Emacs" >&2
60 echo "distribution tree. cd to that directory and try again." >&2
61 exit 1
64 ### Find out which version of Emacs this is.
65 shortversion=`grep 'defconst[ ]*emacs-version' lisp/version.el \
66 | sed -e 's/^.*"\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/'`
67 version=`grep 'defconst[ ]*emacs-version' lisp/version.el \
68 | sed -e 's/^[^"]*"\([^"]*\)".*$/\1/'`
69 if [ ! "${version}" ]; then
70 echo "${progname}: can't find current Emacs version in \`./lisp/version.el'." >&2
71 exit 1
74 echo $version and $shortversion
76 if grep -s "GNU Emacs version ${shortversion}" ./man/emacs.texi > /dev/null; then
77 true
78 else
79 echo "You must update the version number in \`./man/emacs.texi'"
80 sleep 5
83 ### Make sure we don't already have a directory emacs-${version}.
85 emacsname="emacs-${version}${new_extension}"
87 if [ -d ${emacsname} ]
88 then
89 echo Directory "${emacsname}" already exists >&2
90 exit 1
93 ### Make sure the subdirectory is available.
94 tempparent="make-dist.tmp.$$"
95 if [ -d ${tempparent} ]; then
96 echo "${progname}: staging directory \`${tempparent}' already exists.
97 Perhaps a previous invocation of \`${progname}' failed to clean up after
98 itself. Check that directories whose names are of the form
99 \`make-dist.tmp.NNNNN' don't contain any important information, remove
100 them, and try again." >&2
101 exit 1
104 ### Check for .elc files with no corresponding .el file.
105 ls -1 lisp/*.el | sed 's/\.el$/.elc/' > /tmp/el
106 ls -1 lisp/*.elc > /tmp/elc
107 bogosities="`comm -13 /tmp/el /tmp/elc`"
108 if [ "${bogosities}" != "" ]; then
109 echo "The following .elc files have no corresponding .el files:"
110 echo "${bogosities}"
112 rm -f /tmp/el /tmp/elc
114 ### Make sure configure is newer than configure.in.
115 if [ "x`ls -t configure configure.in | head -1`" != "xconfigure" ]; then
116 echo "\`./configure.in' seems to be newer than \`./configure.'" >&2
117 echo "Attempting to run autoconf." >&2
118 autoconf
121 ### Update getdate.c.
122 (cd lib-src; make -f Makefile getdate.c YACC="bison -y")
124 echo "Updating Info files."
126 (cd man; make info)
128 echo "Updating finder-inf.el."
130 ### update finder-inf.el.
131 (cd src; emacs -batch -l finder -f finder-compile-keywords)
133 echo "Creating staging directory: \`${tempparent}'"
135 mkdir ${tempparent}
136 tempdir="${tempparent}/${emacsname}"
138 ### This trap ensures that the staging directory will be cleaned up even
139 ### when the script is interrupted in mid-career.
140 if [ "${clean_up}" = yes ]; then
141 trap "echo 'Interrupted...cleaning up the staging directory.'; rm -rf ${tempparent}; exit 1" 1 2 15
144 echo "Creating top directory: \`${tempdir}'"
145 mkdir ${tempdir}
147 ### We copy in the top-level files before creating the subdirectories in
148 ### hopes that this will make the top-level files appear first in the
149 ### tar file; this means that people can start reading the INSTALL and
150 ### README while the rest of the tar file is still unpacking. Whoopee.
151 echo "Making links to top-level files."
152 ln GETTING.GNU.SOFTWARE INSTALL PROBLEMS README BUGS move-if-change ${tempdir}
153 ln ChangeLog Makefile.in configure configure.in ${tempdir}
154 ln config.bat make-dist update-subdirs vpath.sed ${tempdir}
155 ### Copy these files; they're cross-filesystem symlinks.
156 cp config.sub ${tempdir}
157 cp config.guess ${tempdir}
158 cp install.sh ${tempdir}
160 echo "Updating version number in README."
161 (cd ${tempdir}
162 awk \
163 '$1 " " $2 " " $3 " " $4 " " $5 == "This directory tree holds version" { $6 = version; print $0 }
164 $1 " " $2 " " $3 " " $4 " " $5 != "This directory tree holds version"' \
165 version=${version} README > tmp.README
166 mv tmp.README README)
169 echo "Creating subdirectories."
170 for subdir in lisp lisp/term site-lisp \
171 src src/m src/s src/bitmaps lib-src oldXMenu lwlib \
172 nt nt/inc nt/inc/sys nt/src \
173 etc etc/e lock cpp info man msdos shortnames vms; do
174 mkdir ${tempdir}/${subdir}
175 done
177 echo "Making links to \`lisp'."
178 ### Don't distribute TAGS, =*.el files, site-init.el, site-load.el, or default.el.
179 (cd lisp
180 ln [a-zA-Z]*.el ../${tempdir}/lisp
181 ln [a-zA-Z]*.elc ../${tempdir}/lisp
182 ln [a-zA-Z]*.dat ../${tempdir}/lisp
183 ## simula.el doesn't keep abbreviations in simula.defns any more.
184 ## ln [a-zA-Z]*.defns ../${tempdir}/lisp
185 ln ChangeLog Makefile makefile.nt ChangeLog.? README dired.todo ../${tempdir}/lisp
186 cd ../${tempdir}/lisp
187 rm -f TAGS =*
188 rm -f site-init site-init.el site-init.elc
189 rm -f site-load site-load.el site-load.elc
190 rm -f default default.el default.elc)
192 #echo "Making links to \`lisp/calc-2.02'."
193 #### Don't distribute =*.el files, TAGS or backups.
194 #(cd lisp/calc-2.02
195 # ln [a-zA-Z]*.el ../../${tempdir}/lisp/calc-2.02
196 # ln [a-zA-Z]*.elc ../../${tempdir}/lisp/calc-2.02
197 # ln calc.info* calc.texinfo calc-refcard.* ../../${tempdir}/lisp/calc-2.02
198 # ln INSTALL Makefile README README.prev ../../${tempdir}/lisp/calc-2.02
199 # cd ../../${tempdir}/lisp/calc-2.02
200 # rm -f *~ TAGS)
202 echo "Making links to \`lisp/term'."
203 ### Don't distribute =*.el files or TAGS.
204 (cd lisp/term
205 ln [a-zA-Z]*.el ../../${tempdir}/lisp/term
206 ln [a-zA-Z]*.elc ../../${tempdir}/lisp/term
207 ln README ../../${tempdir}/lisp/term
208 rm -f =* TAGS)
210 echo "Making links to \`src'."
211 ### Don't distribute =*.[ch] files, or the configured versions of
212 ### config.h.in, paths.h.in, or Makefile.in.in, or TAGS.
213 (cd src
214 echo " (If we can't link gmalloc.c, that's okay.)"
215 ln [a-zA-Z]*.c ../${tempdir}/src
216 ## Might be a symlink to a file on another filesystem.
217 test -f ../${tempdir}/src/gmalloc.c || cp gmalloc.c ../${tempdir}/src
218 ln [a-zA-Z]*.h ../${tempdir}/src
219 ln [a-zA-Z]*.s ../${tempdir}/src
220 ln README Makefile.in.in ChangeLog ChangeLog.? config.h.in paths.h.in \
221 ../${tempdir}/src
222 ln .gdbinit .dbxinit ../${tempdir}/src
223 ln *.opt vms-pp.trans ../${tempdir}/src
224 cd ../${tempdir}/src
225 rm -f config.h paths.h Makefile
226 rm -f =* TAGS)
228 echo "Making links to \`src/bitmaps'."
229 (cd src/bitmaps
230 ln README *.xbm ../../${tempdir}/src/bitmaps)
232 echo "Making links to \`src/m'."
233 (cd src/m
234 # We call files for miscellaneous input (to linker etc) .inp.
235 ln README [a-zA-Z0-9]*.h *.inp ../../${tempdir}/src/m)
237 echo "Making links to \`src/s'."
238 (cd src/s
239 ln README [a-zA-Z0-9]*.h *.inp ../../${tempdir}/src/s)
241 echo "Making links to \`lib-src'."
242 (cd lib-src
243 ln [a-zA-Z]*.[chy] [a-zA-Z]*.lex ../${tempdir}/lib-src
244 ln ChangeLog Makefile.in.in README testfile vcdiff ../${tempdir}/lib-src
245 ln emacs.csh rcs2log rcs-checkin makefile.nt ../${tempdir}/lib-src
246 cd ../${tempdir}/lib-src
247 rm -f getdate.tab.c y.tab.c y.tab.h
248 rm -f =* TAGS)
250 echo "Making links to \`nt'."
251 (cd nt
252 ln [a-z]*.cmd makefile.* todo ChangeLog install readme ../${tempdir}/nt)
254 echo "Making links to \`nt/inc'."
255 (cd nt/inc
256 ln [a-z]*.h ../${tempdir}/nt/inc)
258 echo "Making links to \`nt/inc/sys'."
259 (cd nt/inc/sys
260 ln [a-z]*.h ../${tempdir}/nt/inc/sys)
262 echo "Making links to \`nt/src'."
263 (cd nt/src
264 ln [a-z]*.h ../${tempdir}/nt/src)
266 echo "Making links to \`msdos'."
267 (cd msdos
268 ln ChangeLog emacs.ico emacs.pif ../${tempdir}/msdos
269 ln mainmake sed*.inp ../${tempdir}/msdos
270 cd ../${tempdir}/msdos
271 rm -f =*)
273 echo "Making links to \`oldXMenu'."
274 (cd oldXMenu
275 ln *.c *.h *.in ../${tempdir}/oldXMenu
276 ln README Imakefile ChangeLog ../${tempdir}/oldXMenu
277 ln compile.com descrip.mms ../${tempdir}/oldXMenu)
279 echo "Making links to \`lwlib'."
280 (cd lwlib
281 ln *.c *.h *.in ../${tempdir}/lwlib
282 ln README Imakefile ChangeLog ../${tempdir}/lwlib)
284 echo "Making links to \`etc'."
285 ### Don't distribute = files, TAGS, DOC files, backups, autosaves, or
286 ### tex litter.
287 (cd etc
288 ln `ls -d * | grep -v 'RCS' | grep -v 'Old'` ../${tempdir}/etc
289 cd ../${tempdir}/etc
290 rm -f DOC* *~ \#*\# *.dvi *.log *,v =* core
291 rm -f TAGS)
293 echo "Making links to \`etc/e'."
294 (cd etc/e
295 ln `ls -d * | grep -v 'RCS' ../${tempdir}/etc/e
296 cd ../${tempdir}/etc
297 rm -f DOC* *~ \#*\# *,v =* core)
299 echo "Making links to \`cpp'."
300 (cd cpp
301 ln cccp.c cexp.y Makefile README ../${tempdir}/cpp)
303 echo "Making links to \`info'."
304 # Don't distribute backups or autosaves.
305 (cd info
306 ln [a-zA-Z]* ../${tempdir}/info
307 cd ../${tempdir}/info
308 # Avoid an error when expanding the wildcards later.
309 ln emacs dummy~ ; ln emacs \#dummy\#
310 rm -f *~ \#*\# core)
312 echo "Making links to \`man'."
313 (cd man
314 ln *.texi *.aux *.cps *.fns *.kys *.vrs ../${tempdir}/man
315 test -f README && ln README ../${tempdir}/man
316 test -f Makefile.in && ln Makefile.in ../${tempdir}/man
317 ln ChangeLog split-man ../${tempdir}/man
318 cp texinfo.tex texindex.c getopt.c ../${tempdir}/man
319 cd ../${tempdir}/man
320 rm -f \#*\# =* *~ core emacs-index* *.Z *.z xmail
321 rm -f emacs.?? termcap.?? gdb.?? *.log *.toc *.dvi *.oaux)
323 echo "Making links to \`shortnames'."
324 (cd shortnames
325 ln *.c ../${tempdir}/shortnames
326 ln Makefile reserved special ../${tempdir}/shortnames)
328 echo "Making links to \`vms'."
329 (cd vms
330 ln [0-9a-zA-Z]* ../${tempdir}/vms
331 cd ../${tempdir}/vms
332 rm -f *~)
334 ### It would be nice if they could all be symlinks to etc's copy, but
335 ### you're not supposed to have any symlinks in distribution tar files.
336 echo "Making sure copying notices are all copies of \`etc/COPYING'."
337 rm -f ${tempdir}/etc/COPYING
338 cp etc/COPYING ${tempdir}/etc/COPYING
339 for subdir in lisp src lib-src info shortnames msdos; do
340 if [ -f ${tempdir}/${subdir}/COPYING ]; then
341 rm ${tempdir}/${subdir}/COPYING
343 cp etc/COPYING ${tempdir}/${subdir}
344 done
346 #### Make sure that there aren't any hard links between files in the
347 #### distribution; people with afs can't deal with that. Okay,
348 #### actually we just re-copy anything with a link count greater
349 #### than two.
350 echo "Breaking intra-tree links."
351 find ${tempdir} ! -type d -links +2 \
352 -exec cp -p {} $$ \; -exec rm -f {} \; -exec mv $$ {} \;
354 if [ "${newer}" ]; then
355 echo "Removing files older than $newer."
356 ## We remove .elc files unconditionally, on the theory that anyone picking
357 ## up an incremental distribution already has a running Emacs to byte-compile
358 ## them with.
359 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
362 if [ "${make_tar}" = yes ]; then
363 if [ "${default_gzip}" = "" ]; then
364 echo "Looking for gzip."
365 temppath=`echo $PATH | sed 's/^:/.:/
366 s/::/:.:/g
367 s/:$/:./
368 s/:/ /g'`
369 default_gzip=`(
370 for dir in ${temppath}; do
371 if [ -f ${dir}/gzip ]; then echo 'gzip --best'; exit 0; fi
372 done
373 echo compress
376 case "${default_gzip}" in
377 compress* ) gzip_extension=.Z ;;
378 * ) gzip_extension=.gz ;;
379 esac
380 echo "Creating tar file."
381 (cd ${tempparent} ; tar cvf - ${emacsname} ) \
382 | ${default_gzip} \
383 > ${emacsname}.tar${gzip_extension}
386 if [ "${clean_up}" = yes ]; then
387 echo "Cleaning up the staging directory."
388 rm -rf ${tempparent}
389 else
390 (cd ${tempparent}; mv ${emacsname} ..)
391 rm -rf ${tempparent}
394 ### make-dist ends here