(posn-col-row): Doc fix.
[bpt/emacs.git] / make-dist
CommitLineData
f7dbcf3c 1#!/bin/sh
76fb0a58
JB
2
3#### make-dist: create an Emacs distribution tar file from the current
1d650ff1 4#### source tree. This basically creates a duplicate directory
76fb0a58
JB
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.
f7dbcf3c
JB
8
9progname="$0"
10
76fb0a58
JB
11### Exit if a command fails.
12### set -e
f7dbcf3c 13
76fb0a58
JB
14### Print out each line we read, for debugging's sake.
15### set -v
f7dbcf3c 16
4746118a
JB
17clean_up=yes
18make_tar=yes
1260d6ba 19newer=""
f7dbcf3c
JB
20
21while [ $# -gt 0 ]; do
22 case "$1" in
76fb0a58
JB
23 ## This option tells make-dist not to delete the staging directory
24 ## after it's done making the tar file.
1260d6ba 25 "--no-clean-up" )
4746118a
JB
26 clean_up=no
27 ;;
76fb0a58
JB
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'.
4746118a
JB
31 "--no-tar" )
32 make_tar=no
33 clean_up=no
f7dbcf3c 34 ;;
76fb0a58 35 ## This option tells make-dist to make the distribution normally, then
7b9cd64c
ER
36 ## remove all files older than the given timestamp file. This is useful
37 ## for creating incremental or patch distributions.
1260d6ba 38 "--newer")
ef15f270
JB
39 newer="$2"
40 new_extension=".new"
1260d6ba
ER
41 shift
42 ;;
922ac4c5
JB
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 ;;
f7dbcf3c
JB
48 * )
49 echo "${progname}: Unrecognized argument: $1" >&2
50 exit 1
51 ;;
52 esac
53 shift
54done
55
76fb0a58 56### Make sure we're running in the right place.
f7dbcf3c 57if [ ! -d src -o ! -f src/lisp.h -o ! -d lisp -o ! -f lisp/version.el ]; then
1260d6ba
ER
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
0d122844 60 echo "distribution tree. cd to that directory and try again." >&2
f7dbcf3c
JB
61 exit 1
62fi
63
76fb0a58 64### Find out which version of Emacs this is.
0e0186f1 65shortversion=`grep 'defconst[ ]*emacs-version' lisp/version.el \
b7cceaf1 66 | sed -e 's/^.*"\([0-9][0-9]*\.[0-9][0-9]*\)\..*$/\1/'`
0e0186f1
RS
67version=`grep 'defconst[ ]*emacs-version' lisp/version.el \
68 | sed -e 's/^[^"]*"\([^"]*\)".*$/\1/'`
f7dbcf3c 69if [ ! "${version}" ]; then
0e0186f1 70 echo "${progname}: can't find current Emacs version in \`./lisp/version.el'." >&2
f7dbcf3c
JB
71 exit 1
72fi
73
0e0186f1 74if grep -s "GNU Emacs version ${shortversion}" ./man/emacs.texi > /dev/null; then
f753e9aa
JB
75 true
76else
77 echo "You must update the version number in \`./man/emacs.texi'"
7b7a9d23 78 sleep 5
f753e9aa
JB
79fi
80
bb160193
RS
81### Make sure we don't already have a directory emacs-${version}.
82
83emacsname="emacs-${version}${new_extension}"
84
85if [ -d ${emacsname} ]
86then
87 echo Directory "${emacsname}" already exists >&2
88 exit 1
89fi
90
76fb0a58 91### Make sure the subdirectory is available.
1260d6ba 92tempparent="make-dist.tmp.$$"
f7dbcf3c 93if [ -d ${tempparent} ]; then
1260d6ba
ER
94 echo "${progname}: staging directory \`${tempparent}' already exists.
95Perhaps a previous invocation of \`${progname}' failed to clean up after
96itself. Check that directories whose names are of the form
97\`make-dist.tmp.NNNNN' don't contain any important information, remove
98them, and try again." >&2
f7dbcf3c
JB
99 exit 1
100fi
101
9f7602fd
JB
102### Check for .elc files with no corresponding .el file.
103ls -1 lisp/*.el | sed 's/\.el$/.elc/' > /tmp/el
104ls -1 lisp/*.elc > /tmp/elc
254e10d8
JB
105bogosities="`comm -13 /tmp/el /tmp/elc`"
106if [ "${bogosities}" != "" ]; then
107 echo "The following .elc files have no corresponding .el files:"
108 echo "${bogosities}"
109fi
8f731fcc 110rm -f /tmp/el /tmp/elc
9f7602fd 111
b4e84d5d
JB
112### Make sure configure is newer than configure.in.
113if [ "x`ls -t configure configure.in | head -1`" != "xconfigure" ]; then
863f1210 114 echo "\`./configure.in' seems to be newer than \`./configure.'" >&2
b4e84d5d
JB
115 echo "Attempting to run autoconf." >&2
116 autoconf
117fi
118
2ed56345 119### Update getdate.c.
0e0186f1 120(cd lib-src; make -f Makefile getdate.c YACC="bison -y")
2ed56345 121
1260d6ba 122echo "Creating staging directory: \`${tempparent}'"
bb160193 123
f7dbcf3c 124mkdir ${tempparent}
f7dbcf3c
JB
125tempdir="${tempparent}/${emacsname}"
126
76fb0a58
JB
127### This trap ensures that the staging directory will be cleaned up even
128### when the script is interrupted in mid-career.
00c00348
ER
129if [ "${clean_up}" = yes ]; then
130 trap "echo 'Interrupted...cleaning up the staging directory.'; rm -rf ${tempparent}; exit 1" 1 2 15
131fi
132
1260d6ba 133echo "Creating top directory: \`${tempdir}'"
f7dbcf3c
JB
134mkdir ${tempdir}
135
76fb0a58
JB
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.
1260d6ba
ER
140echo "Making links to top-level files."
141ln GETTING.GNU.SOFTWARE INSTALL PROBLEMS README move-if-change ${tempdir}
ad8f07cd 142ln ChangeLog Makefile.in build-ins.in configure configure.in ${tempdir}
0e0186f1 143ln config.bat make-dist vpath.sed ${tempdir}
bb160193 144### Copy these files; they're cross-filesystem symlinks.
76fb0a58 145cp config.sub ${tempdir}
2ed56345 146cp config.guess ${tempdir}
bb160193 147cp install.sh ${tempdir}
f7dbcf3c 148
f753e9aa
JB
149echo "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
f7dbcf3c 158echo "Creating subdirectories."
e793672b
JB
159# I think we're not going to distribute anything in external-lisp, so
160# I've removed it from this list.
82a82d48 161for subdir in lisp lisp/term site-lisp \
c660c0a7 162 src src/m src/s src/bitmaps lib-src oldXMenu lwlib \
52d7b2e5 163 etc lock cpp info man msdos shortnames vms; do
f7dbcf3c
JB
164 mkdir ${tempdir}/${subdir}
165done
166
1260d6ba 167echo "Making links to \`lisp'."
7b9cd64c 168### Don't distribute TAGS, =*.el files, site-init.el, site-load.el, or default.el.
f7dbcf3c
JB
169(cd lisp
170 ln [a-zA-Z]*.el ../${tempdir}/lisp
171 ln [a-zA-Z]*.elc ../${tempdir}/lisp
8d2197ac 172 ln [a-zA-Z]*.dat ../${tempdir}/lisp
76fb0a58
JB
173 ## simula.el doesn't keep abbreviations in simula.defns any more.
174 ## ln [a-zA-Z]*.defns ../${tempdir}/lisp
62357a35 175 ln ChangeLog Makefile ChangeLog.? README dired.todo ../${tempdir}/lisp
f7dbcf3c 176 cd ../${tempdir}/lisp
7b9cd64c 177 rm -f TAGS =*
f7dbcf3c 178 rm -f site-init site-init.el site-init.elc
ef15f270
JB
179 rm -f site-load site-load.el site-load.elc
180 rm -f default default.el default.elc)
f7dbcf3c 181
56c31c87
RS
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)
fda4e8f6 191
1260d6ba 192echo "Making links to \`lisp/term'."
7b9cd64c 193### Don't distribute =*.el files or TAGS.
f7dbcf3c
JB
194(cd lisp/term
195 ln [a-zA-Z]*.el ../../${tempdir}/lisp/term
196 ln [a-zA-Z]*.elc ../../${tempdir}/lisp/term
3e1fc5a7 197 ln README ../../${tempdir}/lisp/term
7b9cd64c 198 rm -f =* TAGS)
f7dbcf3c 199
e793672b 200### echo "Making links to \`external-lisp'."
7b9cd64c 201### ### Don't distribute =*.el files or TAGS.
e793672b
JB
202### (cd external-lisp
203### ln [a-zA-Z]*.el ../${tempdir}/external-lisp
204### ln [a-zA-Z]*.elc ../${tempdir}/external-lisp
7b9cd64c
ER
205### ln ChangeLog README ../${tempdir}/external-lisp
206### rm -f =* TAGS)
1260d6ba
ER
207
208echo "Making links to \`src'."
76fb0a58 209### Don't distribute =*.[ch] files, or the configured versions of
9284d3a4 210### config.h.in, paths.h.in, or Makefile.in.in, or TAGS.
f7dbcf3c 211(cd src
76fb0a58 212 echo " (If we can't link gmalloc.c, that's okay.)"
f7dbcf3c 213 ln [a-zA-Z]*.c ../${tempdir}/src
76fb0a58 214 ## Might be a symlink to a file on another filesystem.
39d6eb8e 215 test -f ../${tempdir}/src/gmalloc.c || cp gmalloc.c ../${tempdir}/src
f7dbcf3c
JB
216 ln [a-zA-Z]*.h ../${tempdir}/src
217 ln [a-zA-Z]*.s ../${tempdir}/src
8cce1257 218 ln README Makefile.in.in ChangeLog ChangeLog.? config.h.in paths.h.in \
f7dbcf3c 219 ../${tempdir}/src
990ee059 220 ln .gdbinit .dbxinit ../${tempdir}/src
6f95b621 221 ln *.opt vms-pp.trans ../${tempdir}/src
f7dbcf3c 222 cd ../${tempdir}/src
ef15f270 223 rm -f config.h paths.h Makefile
7b9cd64c 224 rm -f =* TAGS)
f7dbcf3c 225
690eca32
JB
226echo "Making links to \`src/bitmaps'."
227(cd src/bitmaps
228 ln README *.xbm ../../${tempdir}/src/bitmaps)
229
1260d6ba 230echo "Making links to \`src/m'."
f7dbcf3c 231(cd src/m
1dce54a1 232 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/m)
f7dbcf3c 233
1260d6ba 234echo "Making links to \`src/s'."
f7dbcf3c 235(cd src/s
1dce54a1 236 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/s)
f7dbcf3c 237
1260d6ba 238echo "Making links to \`lib-src'."
f7dbcf3c 239(cd lib-src
fa377791 240 ln [a-zA-Z]*.[chy] [a-zA-Z]*.lex ../${tempdir}/lib-src
0e0186f1
RS
241 ln ChangeLog Makefile.in.in README testfile vcdiff ../${tempdir}/lib-src
242 ln emacs.csh rcs2log rcs-checkin ../${tempdir}/lib-src
1260d6ba 243 cd ../${tempdir}/lib-src
690a797c 244 rm -f getdate.tab.c y.tab.c y.tab.h
7b9cd64c 245 rm -f =* TAGS)
f7dbcf3c 246
52d7b2e5
RS
247echo "Making links to \`msdos'."
248(cd msdos
249 ln ChangeLog emacs.ico emacs.pif ../${tempdir}/msdos
ccd5f1ca 250 ln mainmake sed[123].inp ../${tempdir}/msdos
52d7b2e5
RS
251 cd ../${tempdir}/msdos
252 rm -f =*)
253
1260d6ba 254echo "Making links to \`oldXMenu'."
f7dbcf3c 255(cd oldXMenu
8bdbf9ed 256 ln *.c *.h *.in ../${tempdir}/oldXMenu
df1ec566 257 ln README Imakefile ChangeLog ../${tempdir}/oldXMenu
f395c83a 258 ln compile.com descrip.mms ../${tempdir}/oldXMenu)
f7dbcf3c 259
c660c0a7
RS
260echo "Making links to \`lwlib'."
261(cd lwlib
262 ln *.c *.h *.in ../${tempdir}/lwlib
263 ln README Imakefile ChangeLog ../${tempdir}/lwlib)
264
1260d6ba 265echo "Making links to \`etc'."
f395c83a
JB
266### Don't distribute = files, TAGS, DOC files, backups, autosaves, or
267### tex litter.
f7dbcf3c 268(cd etc
f395c83a 269 ln `ls -d * | grep -v 'RCS' | grep -v 'Old'` ../${tempdir}/etc
f7dbcf3c 270 cd ../${tempdir}/etc
f395c83a
JB
271 rm -f DOC* *~ \#*\# *.dvi *.log *,v =* core
272 rm -f TAGS)
f7dbcf3c 273
fda4e8f6
JB
274echo "Making links to \`cpp'."
275(cd cpp
276 ln cccp.c cexp.y Makefile README ../${tempdir}/cpp)
277
66afa119
RS
278echo "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)
fda4e8f6
JB
286
287echo "Making links to \`man'."
288(cd man
298c8970 289 ln *.texi *.aux *.cps *.fns *.kys *.vrs ../${tempdir}/man
5e808bc0
JB
290 test -f README && ln README ../${tempdir}/man
291 test -f Makefile && ln Makefile ../${tempdir}/man
56c31c87 292 ln ChangeLog split-man ../${tempdir}/man
91a480c1 293 cp texinfo.tex texindex.c getopt.c ../${tempdir}/man
4f8cc93a 294 cd ../${tempdir}/man
56c31c87
RS
295 rm -f \#*\# =* *~ core emacs-index* *.Z *.z xmail
296 rm -f emacs.?? termcap.?? gdb.?? *.log *.toc *.dvi *.oaux)
f7dbcf3c 297
1260d6ba 298echo "Making links to \`shortnames'."
f7dbcf3c
JB
299(cd shortnames
300 ln *.c ../${tempdir}/shortnames
301 ln Makefile reserved special ../${tempdir}/shortnames)
302
40eef465
JB
303echo "Making links to \`vms'."
304(cd vms
305 ln [0-9a-zA-Z]* ../${tempdir}/vms
306 cd ../${tempdir}/vms
307 rm -f *~)
308
c87b230f
JB
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.
311echo "Making sure copying notices are all copies of \`etc/COPYING'."
1260d6ba
ER
312rm -f ${tempdir}/etc/COPYING
313cp etc/COPYING ${tempdir}/etc/COPYING
52d7b2e5 314for subdir in lisp src lib-src info shortnames msdos; do
f7dbcf3c
JB
315 if [ -f ${tempdir}/${subdir}/COPYING ]; then
316 rm ${tempdir}/${subdir}/COPYING
317 fi
96858c42 318 cp etc/COPYING ${tempdir}/${subdir}
f7dbcf3c
JB
319done
320
5b8def65
JB
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.
325echo "Breaking intra-tree links."
e94817d7 326find ${tempdir} ! -type d -links +2 \
2752c6f9 327 -exec cp -p {} $$ \; -exec rm -f {} \; -exec mv $$ {} \;
5b8def65 328
1260d6ba
ER
329if [ "${newer}" ]; then
330 echo "Removing files older than $newer."
76fb0a58
JB
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.
1260d6ba
ER
334 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
335fi
336
4746118a 337if [ "${make_tar}" = yes ]; then
922ac4c5
JB
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
f395c83a
JB
351 case "${default_gzip}" in
352 compress* ) gzip_extension=.Z ;;
0dc610dd 353 * ) gzip_extension=.gz ;;
f395c83a 354 esac
4746118a 355 echo "Creating tar file."
f395c83a
JB
356 (cd ${tempparent} ; tar cvf - ${emacsname} ) \
357 | ${default_gzip} \
358 > ${emacsname}.tar${gzip_extension}
4746118a 359fi
f7dbcf3c 360
4746118a 361if [ "${clean_up}" = yes ]; then
f7dbcf3c 362 echo "Cleaning up the staging directory."
f395c83a 363 rm -rf ${tempparent}
bb160193
RS
364else
365 (cd ${tempparent}; mv ${emacsname} ..)
366 rm -rf ${tempparent}
f7dbcf3c 367fi
00c00348 368
76fb0a58 369### make-dist ends here