(internal_equal): Once again use a switch.
[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 \
47d105b0 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
47d105b0
RS
74echo $version and $shortversion
75
0e0186f1 76if grep -s "GNU Emacs version ${shortversion}" ./man/emacs.texi > /dev/null; then
f753e9aa
JB
77 true
78else
79 echo "You must update the version number in \`./man/emacs.texi'"
7b7a9d23 80 sleep 5
f753e9aa
JB
81fi
82
bb160193
RS
83### Make sure we don't already have a directory emacs-${version}.
84
85emacsname="emacs-${version}${new_extension}"
86
87if [ -d ${emacsname} ]
88then
89 echo Directory "${emacsname}" already exists >&2
90 exit 1
91fi
92
76fb0a58 93### Make sure the subdirectory is available.
1260d6ba 94tempparent="make-dist.tmp.$$"
f7dbcf3c 95if [ -d ${tempparent} ]; then
1260d6ba
ER
96 echo "${progname}: staging directory \`${tempparent}' already exists.
97Perhaps a previous invocation of \`${progname}' failed to clean up after
98itself. Check that directories whose names are of the form
99\`make-dist.tmp.NNNNN' don't contain any important information, remove
100them, and try again." >&2
f7dbcf3c
JB
101 exit 1
102fi
103
9f7602fd
JB
104### Check for .elc files with no corresponding .el file.
105ls -1 lisp/*.el | sed 's/\.el$/.elc/' > /tmp/el
106ls -1 lisp/*.elc > /tmp/elc
254e10d8
JB
107bogosities="`comm -13 /tmp/el /tmp/elc`"
108if [ "${bogosities}" != "" ]; then
109 echo "The following .elc files have no corresponding .el files:"
110 echo "${bogosities}"
111fi
8f731fcc 112rm -f /tmp/el /tmp/elc
9f7602fd 113
b4e84d5d
JB
114### Make sure configure is newer than configure.in.
115if [ "x`ls -t configure configure.in | head -1`" != "xconfigure" ]; then
863f1210 116 echo "\`./configure.in' seems to be newer than \`./configure.'" >&2
b4e84d5d
JB
117 echo "Attempting to run autoconf." >&2
118 autoconf
119fi
120
2ed56345 121### Update getdate.c.
0e0186f1 122(cd lib-src; make -f Makefile getdate.c YACC="bison -y")
2ed56345 123
980ab937
RS
124echo "Updating Info files."
125
126(cd man; make info)
127
0588a761
RS
128echo "Updating finder-inf.el."
129
130### update finder-inf.el.
131(cd src; emacs -batch -l finder -f finder-compile-keywords)
132
1260d6ba 133echo "Creating staging directory: \`${tempparent}'"
bb160193 134
f7dbcf3c 135mkdir ${tempparent}
f7dbcf3c
JB
136tempdir="${tempparent}/${emacsname}"
137
76fb0a58
JB
138### This trap ensures that the staging directory will be cleaned up even
139### when the script is interrupted in mid-career.
00c00348
ER
140if [ "${clean_up}" = yes ]; then
141 trap "echo 'Interrupted...cleaning up the staging directory.'; rm -rf ${tempparent}; exit 1" 1 2 15
142fi
143
1260d6ba 144echo "Creating top directory: \`${tempdir}'"
f7dbcf3c
JB
145mkdir ${tempdir}
146
76fb0a58
JB
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.
1260d6ba 151echo "Making links to top-level files."
525336b7 152ln GETTING.GNU.SOFTWARE INSTALL PROBLEMS README BUGS move-if-change ${tempdir}
ac4eff2d 153ln ChangeLog Makefile.in configure configure.in ${tempdir}
6f8b09f3 154ln config.bat make-dist update-subdirs vpath.sed ${tempdir}
bb160193 155### Copy these files; they're cross-filesystem symlinks.
76fb0a58 156cp config.sub ${tempdir}
2ed56345 157cp config.guess ${tempdir}
bb160193 158cp install.sh ${tempdir}
f7dbcf3c 159
f753e9aa
JB
160echo "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
f7dbcf3c 169echo "Creating subdirectories."
82a82d48 170for subdir in lisp lisp/term site-lisp \
c660c0a7 171 src src/m src/s src/bitmaps lib-src oldXMenu lwlib \
391b3748 172 nt nt/inc nt/inc/sys nt/src \
f08ad882 173 etc etc/e lock cpp info man msdos shortnames vms; do
f7dbcf3c
JB
174 mkdir ${tempdir}/${subdir}
175done
176
1260d6ba 177echo "Making links to \`lisp'."
7b9cd64c 178### Don't distribute TAGS, =*.el files, site-init.el, site-load.el, or default.el.
f7dbcf3c
JB
179(cd lisp
180 ln [a-zA-Z]*.el ../${tempdir}/lisp
181 ln [a-zA-Z]*.elc ../${tempdir}/lisp
8d2197ac 182 ln [a-zA-Z]*.dat ../${tempdir}/lisp
76fb0a58
JB
183 ## simula.el doesn't keep abbreviations in simula.defns any more.
184 ## ln [a-zA-Z]*.defns ../${tempdir}/lisp
391b3748 185 ln ChangeLog Makefile makefile.nt ChangeLog.? README dired.todo ../${tempdir}/lisp
f7dbcf3c 186 cd ../${tempdir}/lisp
7b9cd64c 187 rm -f TAGS =*
f7dbcf3c 188 rm -f site-init site-init.el site-init.elc
ef15f270
JB
189 rm -f site-load site-load.el site-load.elc
190 rm -f default default.el default.elc)
f7dbcf3c 191
56c31c87
RS
192#echo "Making links to \`lisp/calc-2.02'."
193#### Don't distribute =*.el files, TAGS or backups.
194#(cd lisp/calc-2.02
195# ln [a-zA-Z]*.el ../../${tempdir}/lisp/calc-2.02
196# ln [a-zA-Z]*.elc ../../${tempdir}/lisp/calc-2.02
197# ln calc.info* calc.texinfo calc-refcard.* ../../${tempdir}/lisp/calc-2.02
198# ln INSTALL Makefile README README.prev ../../${tempdir}/lisp/calc-2.02
199# cd ../../${tempdir}/lisp/calc-2.02
200# rm -f *~ TAGS)
fda4e8f6 201
1260d6ba 202echo "Making links to \`lisp/term'."
7b9cd64c 203### Don't distribute =*.el files or TAGS.
f7dbcf3c
JB
204(cd lisp/term
205 ln [a-zA-Z]*.el ../../${tempdir}/lisp/term
206 ln [a-zA-Z]*.elc ../../${tempdir}/lisp/term
3e1fc5a7 207 ln README ../../${tempdir}/lisp/term
7b9cd64c 208 rm -f =* TAGS)
f7dbcf3c 209
1260d6ba 210echo "Making links to \`src'."
76fb0a58 211### Don't distribute =*.[ch] files, or the configured versions of
9284d3a4 212### config.h.in, paths.h.in, or Makefile.in.in, or TAGS.
f7dbcf3c 213(cd src
76fb0a58 214 echo " (If we can't link gmalloc.c, that's okay.)"
f7dbcf3c 215 ln [a-zA-Z]*.c ../${tempdir}/src
76fb0a58 216 ## Might be a symlink to a file on another filesystem.
39d6eb8e 217 test -f ../${tempdir}/src/gmalloc.c || cp gmalloc.c ../${tempdir}/src
f7dbcf3c
JB
218 ln [a-zA-Z]*.h ../${tempdir}/src
219 ln [a-zA-Z]*.s ../${tempdir}/src
8cce1257 220 ln README Makefile.in.in ChangeLog ChangeLog.? config.h.in paths.h.in \
f7dbcf3c 221 ../${tempdir}/src
990ee059 222 ln .gdbinit .dbxinit ../${tempdir}/src
6f95b621 223 ln *.opt vms-pp.trans ../${tempdir}/src
f7dbcf3c 224 cd ../${tempdir}/src
ef15f270 225 rm -f config.h paths.h Makefile
7b9cd64c 226 rm -f =* TAGS)
f7dbcf3c 227
690eca32
JB
228echo "Making links to \`src/bitmaps'."
229(cd src/bitmaps
230 ln README *.xbm ../../${tempdir}/src/bitmaps)
231
1260d6ba 232echo "Making links to \`src/m'."
f7dbcf3c 233(cd src/m
facbb78e
RS
234 # We call files for miscellaneous input (to linker etc) .inp.
235 ln README [a-zA-Z0-9]*.h *.inp ../../${tempdir}/src/m)
f7dbcf3c 236
1260d6ba 237echo "Making links to \`src/s'."
f7dbcf3c 238(cd src/s
facbb78e 239 ln README [a-zA-Z0-9]*.h *.inp ../../${tempdir}/src/s)
f7dbcf3c 240
1260d6ba 241echo "Making links to \`lib-src'."
f7dbcf3c 242(cd lib-src
fa377791 243 ln [a-zA-Z]*.[chy] [a-zA-Z]*.lex ../${tempdir}/lib-src
0e0186f1 244 ln ChangeLog Makefile.in.in README testfile vcdiff ../${tempdir}/lib-src
391b3748 245 ln emacs.csh rcs2log rcs-checkin makefile.nt ../${tempdir}/lib-src
1260d6ba 246 cd ../${tempdir}/lib-src
690a797c 247 rm -f getdate.tab.c y.tab.c y.tab.h
7b9cd64c 248 rm -f =* TAGS)
f7dbcf3c 249
391b3748
RS
250echo "Making links to \`nt'."
251(cd nt
252 ln [a-z]*.cmd makefile.* todo ChangeLog install readme ../${tempdir}/nt)
253
254echo "Making links to \`nt/inc'."
255(cd nt/inc
256 ln [a-z]*.h ../${tempdir}/nt/inc)
257
258echo "Making links to \`nt/inc/sys'."
259(cd nt/inc/sys
260 ln [a-z]*.h ../${tempdir}/nt/inc/sys)
261
262echo "Making links to \`nt/src'."
263(cd nt/src
264 ln [a-z]*.h ../${tempdir}/nt/src)
265
52d7b2e5
RS
266echo "Making links to \`msdos'."
267(cd msdos
268 ln ChangeLog emacs.ico emacs.pif ../${tempdir}/msdos
6f8b09f3 269 ln mainmake sed*.inp ../${tempdir}/msdos
52d7b2e5
RS
270 cd ../${tempdir}/msdos
271 rm -f =*)
272
1260d6ba 273echo "Making links to \`oldXMenu'."
f7dbcf3c 274(cd oldXMenu
8bdbf9ed 275 ln *.c *.h *.in ../${tempdir}/oldXMenu
df1ec566 276 ln README Imakefile ChangeLog ../${tempdir}/oldXMenu
f395c83a 277 ln compile.com descrip.mms ../${tempdir}/oldXMenu)
f7dbcf3c 278
c660c0a7
RS
279echo "Making links to \`lwlib'."
280(cd lwlib
281 ln *.c *.h *.in ../${tempdir}/lwlib
282 ln README Imakefile ChangeLog ../${tempdir}/lwlib)
283
1260d6ba 284echo "Making links to \`etc'."
f395c83a
JB
285### Don't distribute = files, TAGS, DOC files, backups, autosaves, or
286### tex litter.
f7dbcf3c 287(cd etc
f395c83a 288 ln `ls -d * | grep -v 'RCS' | grep -v 'Old'` ../${tempdir}/etc
f7dbcf3c 289 cd ../${tempdir}/etc
f395c83a
JB
290 rm -f DOC* *~ \#*\# *.dvi *.log *,v =* core
291 rm -f TAGS)
f7dbcf3c 292
f08ad882
RS
293echo "Making links to \`etc/e'."
294(cd etc/e
295 ln `ls -d * | grep -v 'RCS' ../${tempdir}/etc/e
296 cd ../${tempdir}/etc
297 rm -f DOC* *~ \#*\# *,v =* core)
298
fda4e8f6
JB
299echo "Making links to \`cpp'."
300(cd cpp
301 ln cccp.c cexp.y Makefile README ../${tempdir}/cpp)
302
66afa119
RS
303echo "Making links to \`info'."
304# Don't distribute backups or autosaves.
305(cd info
306 ln [a-zA-Z]* ../${tempdir}/info
307 cd ../${tempdir}/info
308 # Avoid an error when expanding the wildcards later.
309 ln emacs dummy~ ; ln emacs \#dummy\#
310 rm -f *~ \#*\# core)
fda4e8f6
JB
311
312echo "Making links to \`man'."
313(cd man
298c8970 314 ln *.texi *.aux *.cps *.fns *.kys *.vrs ../${tempdir}/man
5e808bc0 315 test -f README && ln README ../${tempdir}/man
f08ad882 316 test -f Makefile.in && ln Makefile.in ../${tempdir}/man
56c31c87 317 ln ChangeLog split-man ../${tempdir}/man
91a480c1 318 cp texinfo.tex texindex.c getopt.c ../${tempdir}/man
4f8cc93a 319 cd ../${tempdir}/man
56c31c87
RS
320 rm -f \#*\# =* *~ core emacs-index* *.Z *.z xmail
321 rm -f emacs.?? termcap.?? gdb.?? *.log *.toc *.dvi *.oaux)
f7dbcf3c 322
1260d6ba 323echo "Making links to \`shortnames'."
f7dbcf3c
JB
324(cd shortnames
325 ln *.c ../${tempdir}/shortnames
326 ln Makefile reserved special ../${tempdir}/shortnames)
327
40eef465
JB
328echo "Making links to \`vms'."
329(cd vms
330 ln [0-9a-zA-Z]* ../${tempdir}/vms
331 cd ../${tempdir}/vms
332 rm -f *~)
333
c87b230f
JB
334### It would be nice if they could all be symlinks to etc's copy, but
335### you're not supposed to have any symlinks in distribution tar files.
336echo "Making sure copying notices are all copies of \`etc/COPYING'."
1260d6ba
ER
337rm -f ${tempdir}/etc/COPYING
338cp etc/COPYING ${tempdir}/etc/COPYING
52d7b2e5 339for subdir in lisp src lib-src info shortnames msdos; do
f7dbcf3c
JB
340 if [ -f ${tempdir}/${subdir}/COPYING ]; then
341 rm ${tempdir}/${subdir}/COPYING
342 fi
96858c42 343 cp etc/COPYING ${tempdir}/${subdir}
f7dbcf3c
JB
344done
345
5b8def65
JB
346#### Make sure that there aren't any hard links between files in the
347#### distribution; people with afs can't deal with that. Okay,
348#### actually we just re-copy anything with a link count greater
349#### than two.
350echo "Breaking intra-tree links."
e94817d7 351find ${tempdir} ! -type d -links +2 \
2752c6f9 352 -exec cp -p {} $$ \; -exec rm -f {} \; -exec mv $$ {} \;
5b8def65 353
1260d6ba
ER
354if [ "${newer}" ]; then
355 echo "Removing files older than $newer."
76fb0a58
JB
356 ## We remove .elc files unconditionally, on the theory that anyone picking
357 ## up an incremental distribution already has a running Emacs to byte-compile
358 ## them with.
1260d6ba
ER
359 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
360fi
361
4746118a 362if [ "${make_tar}" = yes ]; then
922ac4c5
JB
363 if [ "${default_gzip}" = "" ]; then
364 echo "Looking for gzip."
365 temppath=`echo $PATH | sed 's/^:/.:/
366 s/::/:.:/g
367 s/:$/:./
368 s/:/ /g'`
369 default_gzip=`(
370 for dir in ${temppath}; do
371 if [ -f ${dir}/gzip ]; then echo 'gzip --best'; exit 0; fi
372 done
373 echo compress
374 )`
375 fi
f395c83a
JB
376 case "${default_gzip}" in
377 compress* ) gzip_extension=.Z ;;
0dc610dd 378 * ) gzip_extension=.gz ;;
f395c83a 379 esac
4746118a 380 echo "Creating tar file."
f395c83a
JB
381 (cd ${tempparent} ; tar cvf - ${emacsname} ) \
382 | ${default_gzip} \
383 > ${emacsname}.tar${gzip_extension}
4746118a 384fi
f7dbcf3c 385
4746118a 386if [ "${clean_up}" = yes ]; then
f7dbcf3c 387 echo "Cleaning up the staging directory."
f395c83a 388 rm -rf ${tempparent}
bb160193
RS
389else
390 (cd ${tempparent}; mv ${emacsname} ..)
391 rm -rf ${tempparent}
f7dbcf3c 392fi
00c00348 393
76fb0a58 394### make-dist ends here