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