(Farray_length): Delete this obsolete function.
[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 progname="$0"
10
11 ### Exit if a command fails.
12 ### set -e
13
14 ### Print out each line we read, for debugging's sake.
15 ### set -v
16
17 clean_up=yes
18 make_tar=yes
19 newer=""
20
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
27 ;;
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
34 ;;
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
42 ;;
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"
47 ;;
48 * )
49 echo "${progname}: Unrecognized argument: $1" >&2
50 exit 1
51 ;;
52 esac
53 shift
54 done
55
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
62 fi
63
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
72 fi
73
74 echo $version and $shortversion
75
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
81 fi
82
83 ### Make sure we don't already have a directory emacs-${version}.
84
85 emacsname="emacs-${version}${new_extension}"
86
87 if [ -d ${emacsname} ]
88 then
89 echo Directory "${emacsname}" already exists >&2
90 exit 1
91 fi
92
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
102 fi
103
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}"
111 fi
112 rm -f /tmp/el /tmp/elc
113
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
119 fi
120
121 ### Update getdate.c.
122 (cd lib-src; make -f Makefile getdate.c YACC="bison -y")
123
124 echo "Updating Info files."
125
126 (cd man; make info)
127
128 echo "Updating finder-inf.el."
129
130 ### update finder-inf.el.
131 (cd src; emacs -batch -l finder -f finder-compile-keywords)
132
133 echo "Creating staging directory: \`${tempparent}'"
134
135 mkdir ${tempparent}
136 tempdir="${tempparent}/${emacsname}"
137
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
142 fi
143
144 echo "Creating top directory: \`${tempdir}'"
145 mkdir ${tempdir}
146
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}
159
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)
167
168
169 echo "Creating subdirectories."
170 # I think we're not going to distribute anything in external-lisp, so
171 # I've removed it from this list.
172 for subdir in lisp lisp/term site-lisp \
173 src src/m src/s src/bitmaps lib-src oldXMenu lwlib \
174 nt nt/inc nt/inc/sys nt/src \
175 etc lock cpp info man msdos shortnames vms; do
176 mkdir ${tempdir}/${subdir}
177 done
178
179 echo "Making links to \`lisp'."
180 ### Don't distribute TAGS, =*.el files, site-init.el, site-load.el, or default.el.
181 (cd lisp
182 ln [a-zA-Z]*.el ../${tempdir}/lisp
183 ln [a-zA-Z]*.elc ../${tempdir}/lisp
184 ln [a-zA-Z]*.dat ../${tempdir}/lisp
185 ## simula.el doesn't keep abbreviations in simula.defns any more.
186 ## ln [a-zA-Z]*.defns ../${tempdir}/lisp
187 ln ChangeLog Makefile makefile.nt ChangeLog.? README dired.todo ../${tempdir}/lisp
188 cd ../${tempdir}/lisp
189 rm -f TAGS =*
190 rm -f site-init site-init.el site-init.elc
191 rm -f site-load site-load.el site-load.elc
192 rm -f default default.el default.elc)
193
194 #echo "Making links to \`lisp/calc-2.02'."
195 #### Don't distribute =*.el files, TAGS or backups.
196 #(cd lisp/calc-2.02
197 # ln [a-zA-Z]*.el ../../${tempdir}/lisp/calc-2.02
198 # ln [a-zA-Z]*.elc ../../${tempdir}/lisp/calc-2.02
199 # ln calc.info* calc.texinfo calc-refcard.* ../../${tempdir}/lisp/calc-2.02
200 # ln INSTALL Makefile README README.prev ../../${tempdir}/lisp/calc-2.02
201 # cd ../../${tempdir}/lisp/calc-2.02
202 # rm -f *~ TAGS)
203
204 echo "Making links to \`lisp/term'."
205 ### Don't distribute =*.el files or TAGS.
206 (cd lisp/term
207 ln [a-zA-Z]*.el ../../${tempdir}/lisp/term
208 ln [a-zA-Z]*.elc ../../${tempdir}/lisp/term
209 ln README ../../${tempdir}/lisp/term
210 rm -f =* TAGS)
211
212 ### echo "Making links to \`external-lisp'."
213 ### ### Don't distribute =*.el files or TAGS.
214 ### (cd external-lisp
215 ### ln [a-zA-Z]*.el ../${tempdir}/external-lisp
216 ### ln [a-zA-Z]*.elc ../${tempdir}/external-lisp
217 ### ln ChangeLog README ../${tempdir}/external-lisp
218 ### rm -f =* TAGS)
219
220 echo "Making links to \`src'."
221 ### Don't distribute =*.[ch] files, or the configured versions of
222 ### config.h.in, paths.h.in, or Makefile.in.in, or TAGS.
223 (cd src
224 echo " (If we can't link gmalloc.c, that's okay.)"
225 ln [a-zA-Z]*.c ../${tempdir}/src
226 ## Might be a symlink to a file on another filesystem.
227 test -f ../${tempdir}/src/gmalloc.c || cp gmalloc.c ../${tempdir}/src
228 ln [a-zA-Z]*.h ../${tempdir}/src
229 ln [a-zA-Z]*.s ../${tempdir}/src
230 ln README Makefile.in.in ChangeLog ChangeLog.? config.h.in paths.h.in \
231 ../${tempdir}/src
232 ln .gdbinit .dbxinit ../${tempdir}/src
233 ln *.opt vms-pp.trans ../${tempdir}/src
234 cd ../${tempdir}/src
235 rm -f config.h paths.h Makefile
236 rm -f =* TAGS)
237
238 echo "Making links to \`src/bitmaps'."
239 (cd src/bitmaps
240 ln README *.xbm ../../${tempdir}/src/bitmaps)
241
242 echo "Making links to \`src/m'."
243 (cd src/m
244 # We call files for miscellaneous input (to linker etc) .inp.
245 ln README [a-zA-Z0-9]*.h *.inp ../../${tempdir}/src/m)
246
247 echo "Making links to \`src/s'."
248 (cd src/s
249 ln README [a-zA-Z0-9]*.h *.inp ../../${tempdir}/src/s)
250
251 echo "Making links to \`lib-src'."
252 (cd lib-src
253 ln [a-zA-Z]*.[chy] [a-zA-Z]*.lex ../${tempdir}/lib-src
254 ln ChangeLog Makefile.in.in README testfile vcdiff ../${tempdir}/lib-src
255 ln emacs.csh rcs2log rcs-checkin makefile.nt ../${tempdir}/lib-src
256 cd ../${tempdir}/lib-src
257 rm -f getdate.tab.c y.tab.c y.tab.h
258 rm -f =* TAGS)
259
260 echo "Making links to \`nt'."
261 (cd nt
262 ln [a-z]*.cmd makefile.* todo ChangeLog install readme ../${tempdir}/nt)
263
264 echo "Making links to \`nt/inc'."
265 (cd nt/inc
266 ln [a-z]*.h ../${tempdir}/nt/inc)
267
268 echo "Making links to \`nt/inc/sys'."
269 (cd nt/inc/sys
270 ln [a-z]*.h ../${tempdir}/nt/inc/sys)
271
272 echo "Making links to \`nt/src'."
273 (cd nt/src
274 ln [a-z]*.h ../${tempdir}/nt/src)
275
276 echo "Making links to \`msdos'."
277 (cd msdos
278 ln ChangeLog emacs.ico emacs.pif ../${tempdir}/msdos
279 ln mainmake sed*.inp ../${tempdir}/msdos
280 cd ../${tempdir}/msdos
281 rm -f =*)
282
283 echo "Making links to \`oldXMenu'."
284 (cd oldXMenu
285 ln *.c *.h *.in ../${tempdir}/oldXMenu
286 ln README Imakefile ChangeLog ../${tempdir}/oldXMenu
287 ln compile.com descrip.mms ../${tempdir}/oldXMenu)
288
289 echo "Making links to \`lwlib'."
290 (cd lwlib
291 ln *.c *.h *.in ../${tempdir}/lwlib
292 ln README Imakefile ChangeLog ../${tempdir}/lwlib)
293
294 echo "Making links to \`etc'."
295 ### Don't distribute = files, TAGS, DOC files, backups, autosaves, or
296 ### tex litter.
297 (cd etc
298 ln `ls -d * | grep -v 'RCS' | grep -v 'Old'` ../${tempdir}/etc
299 cd ../${tempdir}/etc
300 rm -f DOC* *~ \#*\# *.dvi *.log *,v =* core
301 rm -f TAGS)
302
303 echo "Making links to \`cpp'."
304 (cd cpp
305 ln cccp.c cexp.y Makefile README ../${tempdir}/cpp)
306
307 echo "Making links to \`info'."
308 # Don't distribute backups or autosaves.
309 (cd info
310 ln [a-zA-Z]* ../${tempdir}/info
311 cd ../${tempdir}/info
312 # Avoid an error when expanding the wildcards later.
313 ln emacs dummy~ ; ln emacs \#dummy\#
314 rm -f *~ \#*\# core)
315
316 echo "Making links to \`man'."
317 (cd man
318 ln *.texi *.aux *.cps *.fns *.kys *.vrs ../${tempdir}/man
319 test -f README && ln README ../${tempdir}/man
320 test -f Makefile && ln Makefile ../${tempdir}/man
321 ln ChangeLog split-man ../${tempdir}/man
322 cp texinfo.tex texindex.c getopt.c ../${tempdir}/man
323 cd ../${tempdir}/man
324 rm -f \#*\# =* *~ core emacs-index* *.Z *.z xmail
325 rm -f emacs.?? termcap.?? gdb.?? *.log *.toc *.dvi *.oaux)
326
327 echo "Making links to \`shortnames'."
328 (cd shortnames
329 ln *.c ../${tempdir}/shortnames
330 ln Makefile reserved special ../${tempdir}/shortnames)
331
332 echo "Making links to \`vms'."
333 (cd vms
334 ln [0-9a-zA-Z]* ../${tempdir}/vms
335 cd ../${tempdir}/vms
336 rm -f *~)
337
338 ### It would be nice if they could all be symlinks to etc's copy, but
339 ### you're not supposed to have any symlinks in distribution tar files.
340 echo "Making sure copying notices are all copies of \`etc/COPYING'."
341 rm -f ${tempdir}/etc/COPYING
342 cp etc/COPYING ${tempdir}/etc/COPYING
343 for subdir in lisp src lib-src info shortnames msdos; do
344 if [ -f ${tempdir}/${subdir}/COPYING ]; then
345 rm ${tempdir}/${subdir}/COPYING
346 fi
347 cp etc/COPYING ${tempdir}/${subdir}
348 done
349
350 #### Make sure that there aren't any hard links between files in the
351 #### distribution; people with afs can't deal with that. Okay,
352 #### actually we just re-copy anything with a link count greater
353 #### than two.
354 echo "Breaking intra-tree links."
355 find ${tempdir} ! -type d -links +2 \
356 -exec cp -p {} $$ \; -exec rm -f {} \; -exec mv $$ {} \;
357
358 if [ "${newer}" ]; then
359 echo "Removing files older than $newer."
360 ## We remove .elc files unconditionally, on the theory that anyone picking
361 ## up an incremental distribution already has a running Emacs to byte-compile
362 ## them with.
363 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
364 fi
365
366 if [ "${make_tar}" = yes ]; then
367 if [ "${default_gzip}" = "" ]; then
368 echo "Looking for gzip."
369 temppath=`echo $PATH | sed 's/^:/.:/
370 s/::/:.:/g
371 s/:$/:./
372 s/:/ /g'`
373 default_gzip=`(
374 for dir in ${temppath}; do
375 if [ -f ${dir}/gzip ]; then echo 'gzip --best'; exit 0; fi
376 done
377 echo compress
378 )`
379 fi
380 case "${default_gzip}" in
381 compress* ) gzip_extension=.Z ;;
382 * ) gzip_extension=.gz ;;
383 esac
384 echo "Creating tar file."
385 (cd ${tempparent} ; tar cvf - ${emacsname} ) \
386 | ${default_gzip} \
387 > ${emacsname}.tar${gzip_extension}
388 fi
389
390 if [ "${clean_up}" = yes ]; then
391 echo "Cleaning up the staging directory."
392 rm -rf ${tempparent}
393 else
394 (cd ${tempparent}; mv ${emacsname} ..)
395 rm -rf ${tempparent}
396 fi
397
398 ### make-dist ends here