]> code.delx.au - gnu-emacs/blob - make-dist
* make-dist: Add clauses to distribute lisp/forms-mode.
[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 version=`grep 'defconst[ ]*emacs-version' lisp/version.el \
66 | sed -e 's/^.*"\([0-9][0-9]*\.[0-9][0-9]*\)\..*$/\1/'`
67 if [ ! "${version}" ]; then
68 echo "${progname}: can't find current emacs version in \`./lisp/version.el'." >&2
69 exit 1
70 fi
71
72 if grep -s "GNU Emacs version ${version}" ./man/emacs.texi > /dev/null; then
73 true
74 else
75 echo "You must update the version number in \`./man/emacs.texi'"
76 sleep 5
77 fi
78
79 ### Make sure the subdirectory is available.
80 tempparent="make-dist.tmp.$$"
81 if [ -d ${tempparent} ]; then
82 echo "${progname}: staging directory \`${tempparent}' already exists.
83 Perhaps a previous invocation of \`${progname}' failed to clean up after
84 itself. Check that directories whose names are of the form
85 \`make-dist.tmp.NNNNN' don't contain any important information, remove
86 them, and try again." >&2
87 exit 1
88 fi
89
90 ### Check for .elc files with no corresponding .el file.
91 ls -1 lisp/*.el | sed 's/\.el$/.elc/' > /tmp/el
92 ls -1 lisp/*.elc > /tmp/elc
93 bogosities="`comm -13 /tmp/el /tmp/elc`"
94 if [ "${bogosities}" != "" ]; then
95 echo "The following .elc files have no corresponding .el files:"
96 echo "${bogosities}"
97 fi
98 rm -f /tmp/el /tmp/elc
99
100 ### Make sure configure is newer than configure.in.
101 if [ "x`ls -t configure configure.in | head -1`" != "xconfigure" ]; then
102 echo "`./configure.in' seems to be newer than `./configure.'" >&2
103 echo "Attempting to run autoconf." >&2
104 autoconf
105 fi
106
107 ### Update getdate.c.
108 (cd lib-src; make -f Makefile.in getdate.c)
109
110 echo "Creating staging directory: \`${tempparent}'"
111 mkdir ${tempparent}
112 emacsname="emacs-${version}${new_extension}"
113 tempdir="${tempparent}/${emacsname}"
114
115 ### This trap ensures that the staging directory will be cleaned up even
116 ### when the script is interrupted in mid-career.
117 if [ "${clean_up}" = yes ]; then
118 trap "echo 'Interrupted...cleaning up the staging directory.'; rm -rf ${tempparent}; exit 1" 1 2 15
119 fi
120
121 echo "Creating top directory: \`${tempdir}'"
122 mkdir ${tempdir}
123
124 ### We copy in the top-level files before creating the subdirectories in
125 ### hopes that this will make the top-level files appear first in the
126 ### tar file; this means that people can start reading the INSTALL and
127 ### README while the rest of the tar file is still unpacking. Whoopee.
128 echo "Making links to top-level files."
129 ln GETTING.GNU.SOFTWARE INSTALL PROBLEMS README move-if-change ${tempdir}
130 ln ChangeLog Makefile.in build-install.in configure configure.in ${tempdir}
131 ln make-dist ${tempdir}
132 ### Copy config.guess and config.sub; they're cross-filesystem symlinks.
133 cp config.sub ${tempdir}
134 cp config.guess ${tempdir}
135
136 echo "Updating version number in README."
137 (cd ${tempdir}
138 awk \
139 '$1 " " $2 " " $3 " " $4 " " $5 == "This directory tree holds version" { $6 = version; print $0 }
140 $1 " " $2 " " $3 " " $4 " " $5 != "This directory tree holds version"' \
141 version=${version} README > tmp.README
142 mv tmp.README README)
143
144
145 echo "Creating subdirectories."
146 # I think we're not going to distribute anything in external-lisp, so
147 # I've removed it from this list.
148 for subdir in lisp lisp/term lisp/forms-mode site-lisp \
149 src src/m src/s src/bitmaps lib-src oldXMenu \
150 etc lock cpp info man shortnames vms; do
151 mkdir ${tempdir}/${subdir}
152 done
153
154 echo "Making links to \`lisp'."
155 ### Don't distribute TAGS, =*.el files, site-init.el, site-load.el, or default.el.
156 (cd lisp
157 ln [a-zA-Z]*.el ../${tempdir}/lisp
158 ln [a-zA-Z]*.elc ../${tempdir}/lisp
159 ## simula.el doesn't keep abbreviations in simula.defns any more.
160 ## ln [a-zA-Z]*.defns ../${tempdir}/lisp
161 ln ChangeLog README ../${tempdir}/lisp
162 cd ../${tempdir}/lisp
163 rm -f TAGS =*
164 rm -f site-init site-init.el site-init.elc
165 rm -f site-load site-load.el site-load.elc
166 rm -f default default.el default.elc)
167
168 #echo "Making links to \`lisp/calc-2.02'."
169 #### Don't distribute =*.el files, TAGS or backups.
170 #(cd lisp/calc-2.02
171 # ln [a-zA-Z]*.el ../../${tempdir}/lisp/calc-2.02
172 # ln [a-zA-Z]*.elc ../../${tempdir}/lisp/calc-2.02
173 # ln calc.info* calc.texinfo calc-refcard.* ../../${tempdir}/lisp/calc-2.02
174 # ln INSTALL Makefile README README.prev ../../${tempdir}/lisp/calc-2.02
175 # cd ../../${tempdir}/lisp/calc-2.02
176 # rm -f *~ TAGS)
177
178 echo "Making links to \`lisp/term'."
179 ### Don't distribute =*.el files or TAGS.
180 (cd lisp/term
181 ln [a-zA-Z]*.el ../../${tempdir}/lisp/term
182 ln [a-zA-Z]*.elc ../../${tempdir}/lisp/term
183 ln README ChangeLog ../../${tempdir}/lisp/term
184 rm -f =* TAGS)
185
186 echo "Making links to \`lisp/forms-mode'."
187 (cd lisp/forms-mode
188 ln [a-zA-Z]*.el ../../${tempdir}/lisp/forms-mode
189 ln [a-zA-Z]*.elc ../../${tempdir}/lisp/forms-mode
190 ln forms.README forms-d2.dat ../../${tempdir}/lisp/forms-mode
191 rm -f =* TAGS)
192
193 ### echo "Making links to \`external-lisp'."
194 ### ### Don't distribute =*.el files or TAGS.
195 ### (cd external-lisp
196 ### ln [a-zA-Z]*.el ../${tempdir}/external-lisp
197 ### ln [a-zA-Z]*.elc ../${tempdir}/external-lisp
198 ### ln ChangeLog README ../${tempdir}/external-lisp
199 ### rm -f =* TAGS)
200
201 echo "Making links to \`src'."
202 ### Don't distribute =*.[ch] files, or the configured versions of
203 ### config.h.in, paths.h.in, or Makefile.in, or TAGS.
204 (cd src
205 echo " (If we can't link gmalloc.c, that's okay.)"
206 ln [a-zA-Z]*.c ../${tempdir}/src
207 ## Might be a symlink to a file on another filesystem.
208 test -f ../${tempdir}/src/gmalloc.c || cp gmalloc.c ../${tempdir}/src
209 ln [a-zA-Z]*.h ../${tempdir}/src
210 ln [a-zA-Z]*.s ../${tempdir}/src
211 ln README Makefile.in ymakefile ChangeLog config.h.in paths.h.in \
212 ../${tempdir}/src
213 ln .gdbinit .dbxinit ../${tempdir}/src
214 ln *.opt vms-pp.trans ../${tempdir}/src
215 cd ../${tempdir}/src
216 rm -f config.h paths.h Makefile
217 if [ -z "${newer}" ]; then
218 etags *.h *.c ../lisp/*.el
219 fi
220 rm -f =* TAGS)
221
222 echo "Making links to \`src/bitmaps'."
223 (cd src/bitmaps
224 ln README *.xbm ../../${tempdir}/src/bitmaps)
225
226 echo "Making links to \`src/m'."
227 (cd src/m
228 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/m)
229
230 echo "Making links to \`src/s'."
231 (cd src/s
232 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/s)
233
234 echo "Making links to \`lib-src'."
235 (cd lib-src
236 ln [a-zA-Z]*.[chy] [a-zA-Z]*.lex ../${tempdir}/lib-src
237 ln ChangeLog Makefile.in README testfile vcdiff rcs2log ../${tempdir}/lib-src
238 ln emacs.csh rcs-checkin ../${tempdir}/lib-src
239 cd ../${tempdir}/lib-src
240 rm -f getdate.c getdate.tab.c y.tab.c y.tab.h
241 rm -f =* TAGS)
242
243 echo "Making links to \`oldXMenu'."
244 (cd oldXMenu
245 ln *.c *.h *.in ../${tempdir}/oldXMenu
246 ln README Imakefile ChangeLog ../${tempdir}/oldXMenu
247 ln compile.com descrip.mms ../${tempdir}/oldXMenu)
248
249 echo "Making links to \`etc'."
250 ### Don't distribute = files, TAGS, DOC files, backups, autosaves, or
251 ### tex litter.
252 (cd etc
253 ln `ls -d * | grep -v 'RCS' | grep -v 'Old'` ../${tempdir}/etc
254 cd ../${tempdir}/etc
255 rm -f DOC* *~ \#*\# *.dvi *.log *,v =* core
256 rm -f TAGS)
257
258 echo "Making links to \`cpp'."
259 (cd cpp
260 ln cccp.c cexp.y Makefile README ../${tempdir}/cpp)
261
262 echo "Making links to \`info'."
263 # Don't distribute backups or autosaves.
264 (cd info
265 ln [a-zA-Z]* ../${tempdir}/info
266 cd ../${tempdir}/info
267 # Avoid an error when expanding the wildcards later.
268 ln emacs dummy~ ; ln emacs \#dummy\#
269 rm -f *~ \#*\# core)
270
271 echo "Making links to \`man'."
272 (cd man
273 ln *.texinfo *.texi *.aux *.cps *.fns *.kys *.vrs ../${tempdir}/man
274 test -f README && ln README ../${tempdir}/man
275 test -f Makefile && ln Makefile ../${tempdir}/man
276 ln ChangeLog split-man ../${tempdir}/man
277 cp texinfo.tex texindex.c ../${tempdir}/man
278 cd ../${tempdir}/man
279 rm -f \#*\# =* *~ core emacs-index* *.Z *.z xmail
280 rm -f emacs.?? termcap.?? gdb.?? *.log *.toc *.dvi *.oaux)
281
282 echo "Making links to \`shortnames'."
283 (cd shortnames
284 ln *.c ../${tempdir}/shortnames
285 ln Makefile reserved special ../${tempdir}/shortnames)
286
287 echo "Making links to \`vms'."
288 (cd vms
289 ln [0-9a-zA-Z]* ../${tempdir}/vms
290 cd ../${tempdir}/vms
291 rm -f *~)
292
293 ### It would be nice if they could all be symlinks to etc's copy, but
294 ### you're not supposed to have any symlinks in distribution tar files.
295 echo "Making sure copying notices are all copies of \`etc/COPYING'."
296 rm -f ${tempdir}/etc/COPYING
297 cp etc/COPYING ${tempdir}/etc/COPYING
298 # I think we're not going to distribute anything in external-lisp, so
299 # I've removed it from this list.
300 for subdir in lisp src lib-src info shortnames; do
301 if [ -f ${tempdir}/${subdir}/COPYING ]; then
302 rm ${tempdir}/${subdir}/COPYING
303 fi
304 cp etc/COPYING ${tempdir}/${subdir}
305 done
306
307 #### Make sure that there aren't any hard links between files in the
308 #### distribution; people with afs can't deal with that. Okay,
309 #### actually we just re-copy anything with a link count greater
310 #### than two.
311 echo "Breaking intra-tree links."
312 find ${tempdir} ! -type d -links +2 \
313 -exec cp {} $$ \; -exec rm -f {} \; -exec mv $$ {} \;
314
315 if [ "${newer}" ]; then
316 echo "Removing files older than $newer."
317 ## We remove .elc files unconditionally, on the theory that anyone picking
318 ## up an incremental distribution already has a running Emacs to byte-compile
319 ## them with.
320 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
321 fi
322
323 if [ "${make_tar}" = yes ]; then
324 if [ "${default_gzip}" = "" ]; then
325 echo "Looking for gzip."
326 temppath=`echo $PATH | sed 's/^:/.:/
327 s/::/:.:/g
328 s/:$/:./
329 s/:/ /g'`
330 default_gzip=`(
331 for dir in ${temppath}; do
332 if [ -f ${dir}/gzip ]; then echo 'gzip --best'; exit 0; fi
333 done
334 echo compress
335 )`
336 fi
337 case "${default_gzip}" in
338 compress* ) gzip_extension=.Z ;;
339 * ) gzip_extension=.z ;;
340 esac
341 echo "Creating tar file."
342 (cd ${tempparent} ; tar cvf - ${emacsname} ) \
343 | ${default_gzip} \
344 > ${emacsname}.tar${gzip_extension}
345 fi
346
347 if [ "${clean_up}" = yes ]; then
348 echo "Cleaning up the staging directory."
349 rm -rf ${tempparent}
350 fi
351
352 ### make-dist ends here