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