]> code.delx.au - gnu-emacs/blob - make-dist
(lib-src): Don't copy *.lex; it doesn't exist anymore.
[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 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 mkinstalldirs ${tempdir}
157 cp config.sub ${tempdir}
158 cp config.guess ${tempdir}
159 cp install.sh ${tempdir}
160
161 echo "Updating version number in README."
162 (cd ${tempdir}
163 awk \
164 '$1 " " $2 " " $3 " " $4 " " $5 == "This directory tree holds version" { $6 = version; print $0 }
165 $1 " " $2 " " $3 " " $4 " " $5 != "This directory tree holds version"' \
166 version=${version} README > tmp.README
167 mv tmp.README README)
168
169
170 echo "Creating subdirectories."
171 for subdir in lisp lisp/term site-lisp \
172 src src/m src/s src/bitmaps lib-src oldXMenu lwlib \
173 nt nt/inc nt/inc/sys nt/src \
174 etc etc/e lock cpp info man msdos vms; do
175 mkdir ${tempdir}/${subdir}
176 done
177
178 echo "Making links to \`lisp'."
179 ### Don't distribute TAGS, =*.el files, site-init.el, site-load.el, or default.el.
180 (cd lisp
181 ln [a-zA-Z]*.el ../${tempdir}/lisp
182 ln [a-zA-Z]*.elc ../${tempdir}/lisp
183 ln [a-zA-Z]*.dat ../${tempdir}/lisp
184 ## simula.el doesn't keep abbreviations in simula.defns any more.
185 ## ln [a-zA-Z]*.defns ../${tempdir}/lisp
186 ln ChangeLog Makefile makefile.nt ChangeLog.? README dired.todo ../${tempdir}/lisp
187 cd ../${tempdir}/lisp
188 rm -f TAGS =*
189 rm -f site-init site-init.el site-init.elc
190 rm -f site-load site-load.el site-load.elc
191 rm -f default default.el default.elc)
192
193 #echo "Making links to \`lisp/calc-2.02'."
194 #### Don't distribute =*.el files, TAGS or backups.
195 #(cd lisp/calc-2.02
196 # ln [a-zA-Z]*.el ../../${tempdir}/lisp/calc-2.02
197 # ln [a-zA-Z]*.elc ../../${tempdir}/lisp/calc-2.02
198 # ln calc.info* calc.texinfo calc-refcard.* ../../${tempdir}/lisp/calc-2.02
199 # ln INSTALL Makefile README README.prev ../../${tempdir}/lisp/calc-2.02
200 # cd ../../${tempdir}/lisp/calc-2.02
201 # rm -f *~ TAGS)
202
203 echo "Making links to \`lisp/term'."
204 ### Don't distribute =*.el files or TAGS.
205 (cd lisp/term
206 ln [a-zA-Z]*.el ../../${tempdir}/lisp/term
207 ln [a-zA-Z]*.elc ../../${tempdir}/lisp/term
208 ln README ../../${tempdir}/lisp/term
209 rm -f =* TAGS)
210
211 echo "Making links to \`src'."
212 ### Don't distribute =*.[ch] files, or the configured versions of
213 ### config.h.in, paths.h.in, or Makefile.in.in, or TAGS.
214 (cd src
215 echo " (If we can't link gmalloc.c, that's okay.)"
216 ln [a-zA-Z]*.c ../${tempdir}/src
217 ## Might be a symlink to a file on another filesystem.
218 test -f ../${tempdir}/src/gmalloc.c || cp gmalloc.c ../${tempdir}/src
219 ln [a-zA-Z]*.h ../${tempdir}/src
220 ln [a-zA-Z]*.s ../${tempdir}/src
221 ln README Makefile.in.in ChangeLog ChangeLog.? config.h.in paths.h.in \
222 ../${tempdir}/src
223 ln .gdbinit .dbxinit ../${tempdir}/src
224 ln *.opt vms-pp.trans ../${tempdir}/src
225 cd ../${tempdir}/src
226 rm -f config.h paths.h Makefile
227 rm -f =* TAGS)
228
229 echo "Making links to \`src/bitmaps'."
230 (cd src/bitmaps
231 ln README *.xbm ../../${tempdir}/src/bitmaps)
232
233 echo "Making links to \`src/m'."
234 (cd src/m
235 # We call files for miscellaneous input (to linker etc) .inp.
236 ln README [a-zA-Z0-9]*.h *.inp ../../${tempdir}/src/m)
237
238 echo "Making links to \`src/s'."
239 (cd src/s
240 ln README [a-zA-Z0-9]*.h *.inp ../../${tempdir}/src/s)
241
242 echo "Making links to \`lib-src'."
243 (cd lib-src
244 ln [a-zA-Z]*.[chy] ../${tempdir}/lib-src
245 ln ChangeLog Makefile.in.in README testfile vcdiff ../${tempdir}/lib-src
246 ln emacs.csh rcs2log rcs-checkin makefile.nt ../${tempdir}/lib-src
247 cd ../${tempdir}/lib-src
248 rm -f getdate.tab.c y.tab.c y.tab.h
249 rm -f =* TAGS)
250
251 echo "Making links to \`nt'."
252 (cd nt
253 ln [a-z]*.cmd makefile.* todo ChangeLog install readme ../${tempdir}/nt)
254
255 echo "Making links to \`nt/inc'."
256 (cd nt/inc
257 ln [a-z]*.h ../${tempdir}/nt/inc)
258
259 echo "Making links to \`nt/inc/sys'."
260 (cd nt/inc/sys
261 ln [a-z]*.h ../${tempdir}/nt/inc/sys)
262
263 echo "Making links to \`nt/src'."
264 (cd nt/src
265 ln [a-z]*.h ../${tempdir}/nt/src)
266
267 echo "Making links to \`msdos'."
268 (cd msdos
269 ln ChangeLog emacs.ico emacs.pif ../${tempdir}/msdos
270 ln mainmake sed*.inp ../${tempdir}/msdos
271 cd ../${tempdir}/msdos
272 rm -f =*)
273
274 echo "Making links to \`oldXMenu'."
275 (cd oldXMenu
276 ln *.c *.h *.in ../${tempdir}/oldXMenu
277 ln README Imakefile ChangeLog ../${tempdir}/oldXMenu
278 ln compile.com descrip.mms ../${tempdir}/oldXMenu)
279
280 echo "Making links to \`lwlib'."
281 (cd lwlib
282 ln *.c *.h *.in ../${tempdir}/lwlib
283 ln README Imakefile ChangeLog ../${tempdir}/lwlib)
284
285 echo "Making links to \`etc'."
286 ### Don't distribute = files, TAGS, DOC files, backups, autosaves, or
287 ### tex litter.
288 (cd etc
289 ln `ls -d * | grep -v 'RCS' | grep -v 'Old' | grep -v '^e$'` ../${tempdir}/etc
290 cd ../${tempdir}/etc
291 rm -f DOC* *~ \#*\# *.dvi *.log *,v =* core
292 rm -f TAGS)
293
294 echo "Making links to \`etc/e'."
295 (cd etc/e
296 ln `ls -d * | grep -v 'RCS'` ../../${tempdir}/etc/e
297 cd ../../${tempdir}/etc
298 rm -f *~ \#*\# *,v =* core)
299
300 echo "Making links to \`cpp'."
301 (cd cpp
302 ln cccp.c cexp.y Makefile README ../${tempdir}/cpp)
303
304 echo "Making links to \`info'."
305 # Don't distribute backups or autosaves.
306 (cd info
307 ln [a-zA-Z]* ../${tempdir}/info
308 cd ../${tempdir}/info
309 # Avoid an error when expanding the wildcards later.
310 ln emacs dummy~ ; ln emacs \#dummy\#
311 rm -f *~ \#*\# core)
312
313 echo "Making links to \`man'."
314 (cd man
315 ln *.texi *.aux *.cps *.fns *.kys *.vrs ../${tempdir}/man
316 test -f README && ln README ../${tempdir}/man
317 test -f Makefile.in && ln Makefile.in ../${tempdir}/man
318 ln ChangeLog split-man ../${tempdir}/man
319 cp texinfo.tex ../${tempdir}/man
320 cd ../${tempdir}/man
321 rm -f \#*\# =* *~ core emacs-index* *.Z *.z xmail
322 rm -f emacs.?? termcap.?? gdb.?? *.log *.toc *.dvi *.oaux)
323
324 echo "Making links to \`vms'."
325 (cd vms
326 ln [0-9a-zA-Z]* ../${tempdir}/vms
327 cd ../${tempdir}/vms
328 rm -f *~)
329
330 ### It would be nice if they could all be symlinks to etc's copy, but
331 ### you're not supposed to have any symlinks in distribution tar files.
332 echo "Making sure copying notices are all copies of \`etc/COPYING'."
333 rm -f ${tempdir}/etc/COPYING
334 cp etc/COPYING ${tempdir}/etc/COPYING
335 for subdir in lisp src lib-src info msdos; do
336 if [ -f ${tempdir}/${subdir}/COPYING ]; then
337 rm ${tempdir}/${subdir}/COPYING
338 fi
339 cp etc/COPYING ${tempdir}/${subdir}
340 done
341
342 #### Make sure that there aren't any hard links between files in the
343 #### distribution; people with afs can't deal with that. Okay,
344 #### actually we just re-copy anything with a link count greater
345 #### than two. (Yes, strictly greater than 2 is correct; since we
346 #### created these files by linking them in from the original tree,
347 #### they'll have exactly two links normally.)
348 echo "Breaking intra-tree links."
349 find ${tempdir} ! -type d -links +2 \
350 -exec cp -p {} $$ \; -exec rm -f {} \; -exec mv $$ {} \;
351
352 if [ "${newer}" ]; then
353 echo "Removing files older than $newer."
354 ## We remove .elc files unconditionally, on the theory that anyone picking
355 ## up an incremental distribution already has a running Emacs to byte-compile
356 ## them with.
357 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
358 fi
359
360 if [ "${make_tar}" = yes ]; then
361 if [ "${default_gzip}" = "" ]; then
362 echo "Looking for gzip."
363 temppath=`echo $PATH | sed 's/^:/.:/
364 s/::/:.:/g
365 s/:$/:./
366 s/:/ /g'`
367 default_gzip=`(
368 for dir in ${temppath}; do
369 if [ -f ${dir}/gzip ]; then echo 'gzip --best'; exit 0; fi
370 done
371 echo compress
372 )`
373 fi
374 case "${default_gzip}" in
375 compress* ) gzip_extension=.Z ;;
376 * ) gzip_extension=.gz ;;
377 esac
378 echo "Creating tar file."
379 (cd ${tempparent} ; tar cvf - ${emacsname} ) \
380 | ${default_gzip} \
381 > ${emacsname}.tar${gzip_extension}
382 fi
383
384 if [ "${clean_up}" = yes ]; then
385 echo "Cleaning up the staging directory."
386 rm -rf ${tempparent}
387 else
388 (cd ${tempparent}; mv ${emacsname} ..)
389 rm -rf ${tempparent}
390 fi
391
392 ### make-dist ends here