]> code.delx.au - gnu-emacs/blob - make-dist
Don't put lisp/dired.todo in the dist.
[gnu-emacs] / make-dist
1 #!/bin/sh
2
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.
8
9 # Copyright (C) 1995 Free Software Foundation, Inc.
10 #
11 # This file is part of GNU Emacs.
12 #
13 # GNU Emacs is free software; you can redistribute it and/or modify
14 # it under the terms of the GNU General Public License as published by
15 # the Free Software Foundation; either version 2, or (at your option)
16 # any later version.
17 #
18 # GNU Emacs is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
22 #
23 # You should have received a copy of the GNU General Public License
24 # along with GNU Emacs; see the file COPYING. If not, write to
25 # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26
27 progname="$0"
28
29 ### Exit if a command fails.
30 ### set -e
31
32 ### Print out each line we read, for debugging's sake.
33 ### set -v
34
35 clean_up=yes
36 make_tar=yes
37 newer=""
38
39 while [ $# -gt 0 ]; do
40 case "$1" in
41 ## This option tells make-dist not to delete the staging directory
42 ## after it's done making the tar file.
43 "--no-clean-up" )
44 clean_up=no
45 ;;
46 ## This option tells make-dist not to make a tar file. Since it's
47 ## rather pointless to build the whole staging directory and then
48 ## nuke it, using this option also selects '--no-clean-up'.
49 "--no-tar" )
50 make_tar=no
51 clean_up=no
52 ;;
53 ## This option tells make-dist to make the distribution normally, then
54 ## remove all files older than the given timestamp file. This is useful
55 ## for creating incremental or patch distributions.
56 "--newer")
57 newer="$2"
58 new_extension=".new"
59 shift
60 ;;
61 ## This option tells make-dist to use `compress' instead of gzip.
62 ## Normally, make-dist uses gzip whenever it is present.
63 "--compress")
64 default_gzip="compress"
65 ;;
66 * )
67 echo "${progname}: Unrecognized argument: $1" >&2
68 exit 1
69 ;;
70 esac
71 shift
72 done
73
74 ### Make sure we're running in the right place.
75 if [ ! -d src -o ! -f src/lisp.h -o ! -d lisp -o ! -f lisp/version.el ]; then
76 echo "${progname}: Can't find \`src/lisp.h' and \`lisp/version.el'." >&2
77 echo "${progname} must be run in the top directory of the Emacs" >&2
78 echo "distribution tree. cd to that directory and try again." >&2
79 exit 1
80 fi
81
82 ### Find out which version of Emacs this is.
83 shortversion=`grep 'defconst[ ]*emacs-version' lisp/version.el \
84 | sed -e 's/^.*"\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/'`
85 version=`grep 'defconst[ ]*emacs-version' lisp/version.el \
86 | sed -e 's/^[^"]*"\([^"]*\)".*$/\1/'`
87 if [ ! "${version}" ]; then
88 echo "${progname}: can't find current Emacs version in \`./lisp/version.el'" >&2
89 exit 1
90 fi
91
92 echo Version numbers are $version and $shortversion
93
94 if grep -s "GNU Emacs version ${shortversion}" ./man/emacs.texi > /dev/null; then
95 true
96 else
97 echo "You must update the version number in \`./man/emacs.texi'"
98 sleep 5
99 fi
100
101 ### Make sure we don't already have a directory emacs-${version}.
102
103 emacsname="emacs-${version}${new_extension}"
104
105 if [ -d ${emacsname} ]
106 then
107 echo Directory "${emacsname}" already exists >&2
108 exit 1
109 fi
110
111 ### Make sure the subdirectory is available.
112 tempparent="make-dist.tmp.$$"
113 if [ -d ${tempparent} ]; then
114 echo "${progname}: staging directory \`${tempparent}' already exists.
115 Perhaps a previous invocation of \`${progname}' failed to clean up after
116 itself. Check that directories whose names are of the form
117 \`make-dist.tmp.NNNNN' don't contain any important information, remove
118 them, and try again." >&2
119 exit 1
120 fi
121
122 ### Check for .elc files with no corresponding .el file.
123 ls -1 lisp/*.el | sed 's/\.el$/.elc/' > /tmp/el
124 ls -1 lisp/*.elc > /tmp/elc
125 bogosities="`comm -13 /tmp/el /tmp/elc`"
126 if [ "${bogosities}" != "" ]; then
127 echo "The following .elc files have no corresponding .el files:"
128 echo "${bogosities}"
129 fi
130 rm -f /tmp/el /tmp/elc
131
132 ### Make sure configure is newer than configure.in.
133 if [ "x`ls -t configure configure.in | head -1`" != "xconfigure" ]; then
134 echo "\`./configure.in' is newer than \`./configure'" >&2
135 echo "Running autoconf" >&2
136 autoconf
137 fi
138
139 ### Update getdate.c.
140 (cd lib-src; make -f Makefile getdate.c YACC="bison -y")
141
142 echo "Updating Info files"
143
144 (cd man; make info)
145
146 echo "Updating finder-inf.el"
147
148 (cd lisp; ../src/emacs -batch -l finder -f finder-compile-keywords-make-dist)
149
150 echo "Recompiling Lisp files"
151
152 src/emacs -batch -f batch-byte-recompile-directory lisp
153
154 echo "Updating autoloads"
155
156 src/emacs -batch -f batch-update-autoloads lisp
157
158 echo "Making lisp/MANIFEST"
159
160 (cd lisp; head -1 *.el | grep '^;' | sed -e 's/;;; //' > MANIFEST)
161
162 echo "Creating staging directory: \`${tempparent}'"
163
164 mkdir ${tempparent}
165 tempdir="${tempparent}/${emacsname}"
166
167 ### This trap ensures that the staging directory will be cleaned up even
168 ### when the script is interrupted in mid-career.
169 if [ "${clean_up}" = yes ]; then
170 trap "echo 'Interrupted...cleaning up the staging directory'; rm -rf ${tempparent}; exit 1" 1 2 15
171 fi
172
173 echo "Creating top directory: \`${tempdir}'"
174 mkdir ${tempdir}
175
176 ### We copy in the top-level files before creating the subdirectories in
177 ### hopes that this will make the top-level files appear first in the
178 ### tar file; this means that people can start reading the INSTALL and
179 ### README while the rest of the tar file is still unpacking. Whoopee.
180 echo "Making links to top-level files"
181 ln GETTING.GNU.SOFTWARE INSTALL PROBLEMS README BUGS move-if-change ${tempdir}
182 ln ChangeLog Makefile.in configure configure.in ${tempdir}
183 ln config.bat make-dist update-subdirs vpath.sed ${tempdir}
184 ### Copy these files; they're cross-filesystem symlinks.
185 cp mkinstalldirs ${tempdir}
186 cp config.sub ${tempdir}
187 cp config.guess ${tempdir}
188 cp install.sh ${tempdir}
189
190 echo "Updating version number in README"
191 (cd ${tempdir}
192 awk \
193 '$1 " " $2 " " $3 " " $4 " " $5 == "This directory tree holds version" { $6 = version; print $0 }
194 $1 " " $2 " " $3 " " $4 " " $5 != "This directory tree holds version"' \
195 version=${version} README > tmp.README
196 mv tmp.README README)
197
198
199 echo "Creating subdirectories"
200 for subdir in lisp lisp/term site-lisp \
201 src src/m src/s src/bitmaps lib-src oldXMenu lwlib \
202 nt nt/inc nt/inc/sys \
203 etc etc/e lock cpp info man msdos vms; do
204 mkdir ${tempdir}/${subdir}
205 done
206
207 echo "Making links to \`lisp'"
208 ### Don't distribute TAGS, =*.el files, site-init.el, site-load.el, or default.el.
209 (cd lisp
210 ln [a-zA-Z]*.el ../${tempdir}/lisp
211 ln [a-zA-Z]*.elc ../${tempdir}/lisp
212 ln [a-zA-Z]*.dat ../${tempdir}/lisp
213 ## simula.el doesn't keep abbreviations in simula.defns any more.
214 ## ln [a-zA-Z]*.defns ../${tempdir}/lisp
215 ln ChangeLog Makefile makefile.nt ChangeLog.? README ../${tempdir}/lisp
216 cd ../${tempdir}/lisp
217 rm -f TAGS =*
218 rm -f subdirs.el
219 rm -f site-init site-init.el site-init.elc
220 rm -f site-load site-load.el site-load.elc
221 rm -f site-start site-start.el site-start.elc
222 rm -f default default.el default.elc)
223
224 #echo "Making links to \`lisp/calc-2.02'"
225 #### Don't distribute =*.el files, TAGS or backups.
226 #(cd lisp/calc-2.02
227 # ln [a-zA-Z]*.el ../../${tempdir}/lisp/calc-2.02
228 # ln [a-zA-Z]*.elc ../../${tempdir}/lisp/calc-2.02
229 # ln calc.info* calc.texinfo calc-refcard.* ../../${tempdir}/lisp/calc-2.02
230 # ln INSTALL Makefile README README.prev ../../${tempdir}/lisp/calc-2.02
231 # cd ../../${tempdir}/lisp/calc-2.02
232 # rm -f *~ TAGS)
233
234 echo "Making links to \`lisp/term'"
235 ### Don't distribute =*.el files or TAGS.
236 (cd lisp/term
237 ln [a-zA-Z]*.el ../../${tempdir}/lisp/term
238 ln [a-zA-Z]*.elc ../../${tempdir}/lisp/term
239 ln README ../../${tempdir}/lisp/term
240 rm -f =* TAGS)
241
242 echo "Making links to \`src'"
243 ### Don't distribute =*.[ch] files, or the configured versions of
244 ### config.in, paths.in, or Makefile.in, or TAGS.
245 (cd src
246 echo " (If we can't link gmalloc.c, that's okay.)"
247 ln [a-zA-Z]*.c ../${tempdir}/src
248 ## Might be a symlink to a file on another filesystem.
249 test -f ../${tempdir}/src/gmalloc.c || cp gmalloc.c ../${tempdir}/src
250 ln [a-zA-Z]*.h ../${tempdir}/src
251 ln [a-zA-Z]*.s ../${tempdir}/src
252 ln README Makefile.in ChangeLog ChangeLog.? config.in paths.in \
253 ../${tempdir}/src
254 ln makefile.nt ../${tempdir}/src
255 ln .gdbinit .dbxinit ../${tempdir}/src
256 ln *.opt vms-pp.trans ../${tempdir}/src
257 cd ../${tempdir}/src
258 rm -f config.h paths.h Makefile Makefile.c
259 rm -f =* TAGS)
260
261 echo "Making links to \`src/bitmaps'"
262 (cd src/bitmaps
263 ln README *.xbm ../../${tempdir}/src/bitmaps)
264
265 echo "Making links to \`src/m'"
266 (cd src/m
267 # We call files for miscellaneous input (to linker etc) .inp.
268 ln README [a-zA-Z0-9]*.h *.inp ../../${tempdir}/src/m)
269
270 echo "Making links to \`src/s'"
271 (cd src/s
272 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/s)
273
274 echo "Making links to \`lib-src'"
275 (cd lib-src
276 ln [a-zA-Z]*.[chy] ../${tempdir}/lib-src
277 ln ChangeLog Makefile.in README testfile vcdiff ../${tempdir}/lib-src
278 ln emacs.csh rcs2log rcs-checkin makefile.nt ../${tempdir}/lib-src
279 cd ../${tempdir}/lib-src
280 rm -f getdate.tab.c y.tab.c y.tab.h Makefile.c
281 rm -f =* TAGS)
282
283 echo "Making links to \`nt'"
284 (cd nt
285 ln emacs.ico emacs.rc config.nt config.w95 [a-z]*.in [a-z]*.c ../${tempdir}/nt
286 ln [a-z]*.bat [a-z]*.h makefile.def makefile.nt ../${tempdir}/nt
287 ln TODO ChangeLog INSTALL README ../${tempdir}/nt)
288
289 echo "Making links to \`nt/inc'"
290 (cd nt/inc
291 ln [a-z]*.h ../../${tempdir}/nt/inc)
292
293 echo "Making links to \`nt/inc/sys'"
294 (cd nt/inc/sys
295 ln [a-z]*.h ../../../${tempdir}/nt/inc/sys)
296
297 echo "Making links to \`msdos'"
298 (cd msdos
299 ln ChangeLog emacs.ico emacs.pif ../${tempdir}/msdos
300 ln mainmake sed*.inp ../${tempdir}/msdos
301 cd ../${tempdir}/msdos
302 rm -f =*)
303
304 echo "Making links to \`oldXMenu'"
305 (cd oldXMenu
306 ln *.c *.h *.in ../${tempdir}/oldXMenu
307 ln README Imakefile ChangeLog ../${tempdir}/oldXMenu
308 ln compile.com descrip.mms ../${tempdir}/oldXMenu)
309
310 echo "Making links to \`lwlib'"
311 (cd lwlib
312 ln *.c *.h *.in ../${tempdir}/lwlib
313 ln README Imakefile ChangeLog ../${tempdir}/lwlib
314 cd ../${tempdir}/lwlib
315 rm -f lwlib-Xol*)
316
317 echo "Making links to \`etc'"
318 ### Don't distribute = files, TAGS, DOC files, backups, autosaves, or
319 ### tex litter.
320 (cd etc
321 ln `ls -d * | grep -v 'RCS' | grep -v 'Old' | grep -v '^e$'` ../${tempdir}/etc
322 cd ../${tempdir}/etc
323 rm -f DOC* *~ \#*\# *.dvi *.log *.orig *.rej *,v =* core
324 rm -f TAGS)
325
326 echo "Making links to \`etc/e'"
327 (cd etc/e
328 ln `ls -d * | grep -v 'RCS'` ../../${tempdir}/etc/e
329 cd ../../${tempdir}/etc/e
330 rm -f *~ \#*\# *,v =* core)
331
332 echo "Making links to \`cpp'"
333 (cd cpp
334 ln cccp.c cexp.y Makefile README ../${tempdir}/cpp)
335
336 echo "Making links to \`info'"
337 # Don't distribute backups or autosaves.
338 (cd info
339 ln [a-zA-Z]* ../${tempdir}/info
340 cd ../${tempdir}/info
341 # Avoid an error when expanding the wildcards later.
342 ln emacs dummy~ ; ln emacs \#dummy\#
343 rm -f *~ \#*\# core)
344
345 echo "Making links to \`man'"
346 (cd man
347 ln *.texi *.aux *.cps *.fns *.kys *.vrs ../${tempdir}/man
348 test -f README && ln README ../${tempdir}/man
349 test -f Makefile.in && ln Makefile.in ../${tempdir}/man
350 ln ChangeLog split-man ../${tempdir}/man
351 cp texinfo.tex ../${tempdir}/man
352 cd ../${tempdir}/man
353 rm -f \#*\# =* *~ core emacs-index* *.Z *.z xmail
354 rm -f emacs.?? termcap.?? gdb.?? *.log *.toc *.dvi *.oaux)
355
356 echo "Making links to \`vms'"
357 (cd vms
358 ln [0-9a-zA-Z]* ../${tempdir}/vms
359 cd ../${tempdir}/vms
360 rm -f *~)
361
362 ### It would be nice if they could all be symlinks to etc's copy, but
363 ### you're not supposed to have any symlinks in distribution tar files.
364 echo "Making sure copying notices are all copies of \`etc/COPYING'"
365 rm -f ${tempdir}/etc/COPYING
366 cp etc/COPYING ${tempdir}/etc/COPYING
367 for subdir in lisp src lib-src info msdos; do
368 if [ -f ${tempdir}/${subdir}/COPYING ]; then
369 rm ${tempdir}/${subdir}/COPYING
370 fi
371 cp etc/COPYING ${tempdir}/${subdir}
372 done
373
374 #### Make sure that there aren't any hard links between files in the
375 #### distribution; people with afs can't deal with that. Okay,
376 #### actually we just re-copy anything with a link count greater
377 #### than two. (Yes, strictly greater than 2 is correct; since we
378 #### created these files by linking them in from the original tree,
379 #### they'll have exactly two links normally.)
380 ####
381 #### Commented out since it's not strictly necessary; it should suffice
382 #### to just break the link on alloca.c.
383 #echo "Breaking intra-tree links."
384 #find ${tempdir} ! -type d -links +2 \
385 # -exec cp -p {} $$ \; -exec rm -f {} \; -exec mv $$ {} \;
386 rm -f $tempdir/lib-src/alloca.c
387 cp $tempdir/src/alloca.c $tempdir/lib-src/alloca.c
388
389 if [ "${newer}" ]; then
390 echo "Removing files older than $newer"
391 ## We remove .elc files unconditionally, on the theory that anyone picking
392 ## up an incremental distribution already has a running Emacs to byte-compile
393 ## them with.
394 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
395 fi
396
397 if [ "${make_tar}" = yes ]; then
398 if [ "${default_gzip}" = "" ]; then
399 echo "Looking for gzip"
400 temppath=`echo $PATH | sed 's/^:/.:/
401 s/::/:.:/g
402 s/:$/:./
403 s/:/ /g'`
404 default_gzip=`(
405 for dir in ${temppath}; do
406 if [ -f ${dir}/gzip ]; then echo 'gzip --best'; exit 0; fi
407 done
408 echo compress
409 )`
410 fi
411 case "${default_gzip}" in
412 compress* ) gzip_extension=.Z ;;
413 * ) gzip_extension=.gz ;;
414 esac
415 echo "Creating tar file"
416 (cd ${tempparent} ; tar cvf - ${emacsname} ) \
417 | ${default_gzip} \
418 > ${emacsname}.tar${gzip_extension}
419 fi
420
421 if [ "${clean_up}" = yes ]; then
422 echo "Cleaning up the staging directory"
423 rm -rf ${tempparent}
424 else
425 (cd ${tempparent}; mv ${emacsname} ..)
426 rm -rf ${tempparent}
427 fi
428
429 ### make-dist ends here