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