(Ftry_completion, Fall_completions, Fcompleting_read): Harmonize arguments
[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 8
4c9c1174
KH
9# Copyright (C) 1995 Free Software Foundation, Inc.
10#
11# This file is part of GNU Emacs.
12#
13# GNU Emacs is free software; you can redistribute it and/or modify
14# it under the terms of the GNU General Public License as published by
15# the Free Software Foundation; either version 2, or (at your option)
16# any later version.
17#
18# GNU Emacs is distributed in the hope that it will be useful,
19# but WITHOUT ANY WARRANTY; without even the implied warranty of
20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21# GNU General Public License for more details.
22#
23# You should have received a copy of the GNU General Public License
24# along with GNU Emacs; see the file COPYING. If not, write to
25# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26
f7dbcf3c
JB
27progname="$0"
28
76fb0a58
JB
29### Exit if a command fails.
30### set -e
f7dbcf3c 31
76fb0a58
JB
32### Print out each line we read, for debugging's sake.
33### set -v
f7dbcf3c 34
4746118a
JB
35clean_up=yes
36make_tar=yes
1260d6ba 37newer=""
f7dbcf3c
JB
38
39while [ $# -gt 0 ]; do
40 case "$1" in
76fb0a58
JB
41 ## This option tells make-dist not to delete the staging directory
42 ## after it's done making the tar file.
1260d6ba 43 "--no-clean-up" )
4746118a
JB
44 clean_up=no
45 ;;
76fb0a58
JB
46 ## This option tells make-dist not to make a tar file. Since it's
47 ## rather pointless to build the whole staging directory and then
48 ## nuke it, using this option also selects '--no-clean-up'.
4746118a
JB
49 "--no-tar" )
50 make_tar=no
51 clean_up=no
f7dbcf3c 52 ;;
76fb0a58 53 ## This option tells make-dist to make the distribution normally, then
7b9cd64c
ER
54 ## remove all files older than the given timestamp file. This is useful
55 ## for creating incremental or patch distributions.
1260d6ba 56 "--newer")
ef15f270
JB
57 newer="$2"
58 new_extension=".new"
1260d6ba
ER
59 shift
60 ;;
922ac4c5
JB
61 ## This option tells make-dist to use `compress' instead of gzip.
62 ## Normally, make-dist uses gzip whenever it is present.
63 "--compress")
64 default_gzip="compress"
65 ;;
f7dbcf3c
JB
66 * )
67 echo "${progname}: Unrecognized argument: $1" >&2
68 exit 1
69 ;;
70 esac
71 shift
72done
73
76fb0a58 74### Make sure we're running in the right place.
f7dbcf3c 75if [ ! -d src -o ! -f src/lisp.h -o ! -d lisp -o ! -f lisp/version.el ]; then
1260d6ba
ER
76 echo "${progname}: Can't find \`src/lisp.h' and \`lisp/version.el'." >&2
77 echo "${progname} must be run in the top directory of the Emacs" >&2
0d122844 78 echo "distribution tree. cd to that directory and try again." >&2
f7dbcf3c
JB
79 exit 1
80fi
81
76fb0a58 82### Find out which version of Emacs this is.
0e0186f1 83shortversion=`grep 'defconst[ ]*emacs-version' lisp/version.el \
47d105b0 84 | sed -e 's/^.*"\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/'`
0e0186f1
RS
85version=`grep 'defconst[ ]*emacs-version' lisp/version.el \
86 | sed -e 's/^[^"]*"\([^"]*\)".*$/\1/'`
f7dbcf3c 87if [ ! "${version}" ]; then
0e0186f1 88 echo "${progname}: can't find current Emacs version in \`./lisp/version.el'." >&2
f7dbcf3c
JB
89 exit 1
90fi
91
47d105b0
RS
92echo $version and $shortversion
93
0e0186f1 94if grep -s "GNU Emacs version ${shortversion}" ./man/emacs.texi > /dev/null; then
f753e9aa
JB
95 true
96else
97 echo "You must update the version number in \`./man/emacs.texi'"
7b7a9d23 98 sleep 5
f753e9aa
JB
99fi
100
bb160193
RS
101### Make sure we don't already have a directory emacs-${version}.
102
103emacsname="emacs-${version}${new_extension}"
104
105if [ -d ${emacsname} ]
106then
107 echo Directory "${emacsname}" already exists >&2
108 exit 1
109fi
110
76fb0a58 111### Make sure the subdirectory is available.
1260d6ba 112tempparent="make-dist.tmp.$$"
f7dbcf3c 113if [ -d ${tempparent} ]; then
1260d6ba
ER
114 echo "${progname}: staging directory \`${tempparent}' already exists.
115Perhaps a previous invocation of \`${progname}' failed to clean up after
116itself. Check that directories whose names are of the form
117\`make-dist.tmp.NNNNN' don't contain any important information, remove
118them, and try again." >&2
f7dbcf3c
JB
119 exit 1
120fi
121
9f7602fd
JB
122### Check for .elc files with no corresponding .el file.
123ls -1 lisp/*.el | sed 's/\.el$/.elc/' > /tmp/el
124ls -1 lisp/*.elc > /tmp/elc
254e10d8
JB
125bogosities="`comm -13 /tmp/el /tmp/elc`"
126if [ "${bogosities}" != "" ]; then
127 echo "The following .elc files have no corresponding .el files:"
128 echo "${bogosities}"
129fi
8f731fcc 130rm -f /tmp/el /tmp/elc
9f7602fd 131
b4e84d5d
JB
132### Make sure configure is newer than configure.in.
133if [ "x`ls -t configure configure.in | head -1`" != "xconfigure" ]; then
863f1210 134 echo "\`./configure.in' seems to be newer than \`./configure.'" >&2
b4e84d5d
JB
135 echo "Attempting to run autoconf." >&2
136 autoconf
137fi
138
2ed56345 139### Update getdate.c.
0e0186f1 140(cd lib-src; make -f Makefile getdate.c YACC="bison -y")
2ed56345 141
980ab937
RS
142echo "Updating Info files."
143
144(cd man; make info)
145
0588a761
RS
146echo "Updating finder-inf.el."
147
148### update finder-inf.el.
419e4198
RS
149(cd lisp; ../src/emacs -batch -l finder -f finder-compile-keywords)
150(cd lisp; ../src/emacs -batch -f batch-byte-compile finder-inf.el)
0588a761 151
f07eebe0
KH
152echo "Making lisp/MANIFEST"
153
154(cd lisp; head -1 *.el | grep '^;' | sed -e 's/;;; //' > MANIFEST)
155
1260d6ba 156echo "Creating staging directory: \`${tempparent}'"
bb160193 157
f7dbcf3c 158mkdir ${tempparent}
f7dbcf3c
JB
159tempdir="${tempparent}/${emacsname}"
160
76fb0a58
JB
161### This trap ensures that the staging directory will be cleaned up even
162### when the script is interrupted in mid-career.
00c00348
ER
163if [ "${clean_up}" = yes ]; then
164 trap "echo 'Interrupted...cleaning up the staging directory.'; rm -rf ${tempparent}; exit 1" 1 2 15
165fi
166
1260d6ba 167echo "Creating top directory: \`${tempdir}'"
f7dbcf3c
JB
168mkdir ${tempdir}
169
76fb0a58
JB
170### We copy in the top-level files before creating the subdirectories in
171### hopes that this will make the top-level files appear first in the
172### tar file; this means that people can start reading the INSTALL and
173### README while the rest of the tar file is still unpacking. Whoopee.
1260d6ba 174echo "Making links to top-level files."
525336b7 175ln GETTING.GNU.SOFTWARE INSTALL PROBLEMS README BUGS move-if-change ${tempdir}
ac4eff2d 176ln ChangeLog Makefile.in configure configure.in ${tempdir}
6f8b09f3 177ln config.bat make-dist update-subdirs vpath.sed ${tempdir}
bb160193 178### Copy these files; they're cross-filesystem symlinks.
a4888c88 179cp mkinstalldirs ${tempdir}
76fb0a58 180cp config.sub ${tempdir}
2ed56345 181cp config.guess ${tempdir}
bb160193 182cp install.sh ${tempdir}
f7dbcf3c 183
f753e9aa
JB
184echo "Updating version number in README."
185(cd ${tempdir}
186 awk \
187 '$1 " " $2 " " $3 " " $4 " " $5 == "This directory tree holds version" { $6 = version; print $0 }
188 $1 " " $2 " " $3 " " $4 " " $5 != "This directory tree holds version"' \
189 version=${version} README > tmp.README
190 mv tmp.README README)
191
192
f7dbcf3c 193echo "Creating subdirectories."
82a82d48 194for subdir in lisp lisp/term site-lisp \
c660c0a7 195 src src/m src/s src/bitmaps lib-src oldXMenu lwlib \
77427171 196 nt nt/inc nt/inc/sys \
8e583b5d 197 etc etc/e lock cpp info man msdos vms; do
f7dbcf3c
JB
198 mkdir ${tempdir}/${subdir}
199done
200
1260d6ba 201echo "Making links to \`lisp'."
7b9cd64c 202### Don't distribute TAGS, =*.el files, site-init.el, site-load.el, or default.el.
f7dbcf3c
JB
203(cd lisp
204 ln [a-zA-Z]*.el ../${tempdir}/lisp
205 ln [a-zA-Z]*.elc ../${tempdir}/lisp
8d2197ac 206 ln [a-zA-Z]*.dat ../${tempdir}/lisp
76fb0a58
JB
207 ## simula.el doesn't keep abbreviations in simula.defns any more.
208 ## ln [a-zA-Z]*.defns ../${tempdir}/lisp
391b3748 209 ln ChangeLog Makefile makefile.nt ChangeLog.? README dired.todo ../${tempdir}/lisp
f7dbcf3c 210 cd ../${tempdir}/lisp
7b9cd64c 211 rm -f TAGS =*
db1e13f0 212 rm -f subdirs.el
f7dbcf3c 213 rm -f site-init site-init.el site-init.elc
ef15f270 214 rm -f site-load site-load.el site-load.elc
da0e2548 215 rm -f site-start site-start.el site-start.elc
ef15f270 216 rm -f default default.el default.elc)
f7dbcf3c 217
56c31c87
RS
218#echo "Making links to \`lisp/calc-2.02'."
219#### Don't distribute =*.el files, TAGS or backups.
220#(cd lisp/calc-2.02
221# ln [a-zA-Z]*.el ../../${tempdir}/lisp/calc-2.02
222# ln [a-zA-Z]*.elc ../../${tempdir}/lisp/calc-2.02
223# ln calc.info* calc.texinfo calc-refcard.* ../../${tempdir}/lisp/calc-2.02
224# ln INSTALL Makefile README README.prev ../../${tempdir}/lisp/calc-2.02
225# cd ../../${tempdir}/lisp/calc-2.02
226# rm -f *~ TAGS)
fda4e8f6 227
1260d6ba 228echo "Making links to \`lisp/term'."
7b9cd64c 229### Don't distribute =*.el files or TAGS.
f7dbcf3c
JB
230(cd lisp/term
231 ln [a-zA-Z]*.el ../../${tempdir}/lisp/term
232 ln [a-zA-Z]*.elc ../../${tempdir}/lisp/term
3e1fc5a7 233 ln README ../../${tempdir}/lisp/term
7b9cd64c 234 rm -f =* TAGS)
f7dbcf3c 235
1260d6ba 236echo "Making links to \`src'."
76fb0a58 237### Don't distribute =*.[ch] files, or the configured versions of
c3f1e1a9 238### config.in, paths.in, or Makefile.in, or TAGS.
f7dbcf3c 239(cd src
76fb0a58 240 echo " (If we can't link gmalloc.c, that's okay.)"
f7dbcf3c 241 ln [a-zA-Z]*.c ../${tempdir}/src
76fb0a58 242 ## Might be a symlink to a file on another filesystem.
39d6eb8e 243 test -f ../${tempdir}/src/gmalloc.c || cp gmalloc.c ../${tempdir}/src
f7dbcf3c
JB
244 ln [a-zA-Z]*.h ../${tempdir}/src
245 ln [a-zA-Z]*.s ../${tempdir}/src
c3f1e1a9 246 ln README Makefile.in ChangeLog ChangeLog.? config.in paths.in \
f7dbcf3c 247 ../${tempdir}/src
7355fc33 248 ln makefile.nt ../${tempdir}/src
990ee059 249 ln .gdbinit .dbxinit ../${tempdir}/src
6f95b621 250 ln *.opt vms-pp.trans ../${tempdir}/src
f7dbcf3c 251 cd ../${tempdir}/src
a6903f09 252 rm -f config.h paths.h Makefile Makefile.c
7b9cd64c 253 rm -f =* TAGS)
f7dbcf3c 254
690eca32
JB
255echo "Making links to \`src/bitmaps'."
256(cd src/bitmaps
257 ln README *.xbm ../../${tempdir}/src/bitmaps)
258
1260d6ba 259echo "Making links to \`src/m'."
f7dbcf3c 260(cd src/m
facbb78e
RS
261 # We call files for miscellaneous input (to linker etc) .inp.
262 ln README [a-zA-Z0-9]*.h *.inp ../../${tempdir}/src/m)
f7dbcf3c 263
1260d6ba 264echo "Making links to \`src/s'."
f7dbcf3c 265(cd src/s
77427171 266 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/s)
f7dbcf3c 267
1260d6ba 268echo "Making links to \`lib-src'."
f7dbcf3c 269(cd lib-src
375f1bd7 270 ln [a-zA-Z]*.[chy] ../${tempdir}/lib-src
c3f1e1a9 271 ln ChangeLog Makefile.in README testfile vcdiff ../${tempdir}/lib-src
391b3748 272 ln emacs.csh rcs2log rcs-checkin makefile.nt ../${tempdir}/lib-src
1260d6ba 273 cd ../${tempdir}/lib-src
a6903f09 274 rm -f getdate.tab.c y.tab.c y.tab.h Makefile.c
7b9cd64c 275 rm -f =* TAGS)
f7dbcf3c 276
391b3748
RS
277echo "Making links to \`nt'."
278(cd nt
f3f59e86 279 ln emacs.ico emacs.rc config.nt config.w95 [a-z]*.in [a-z]*.c ../${tempdir}/nt
b47cc08a 280 ln [a-z]*.bat [a-z]*.h makefile.def makefile.nt ../${tempdir}/nt
3bb3cfe7 281 ln TODO ChangeLog INSTALL README ../${tempdir}/nt)
391b3748
RS
282
283echo "Making links to \`nt/inc'."
284(cd nt/inc
77427171 285 ln [a-z]*.h ../../${tempdir}/nt/inc)
391b3748
RS
286
287echo "Making links to \`nt/inc/sys'."
288(cd nt/inc/sys
77427171 289 ln [a-z]*.h ../../../${tempdir}/nt/inc/sys)
391b3748 290
52d7b2e5
RS
291echo "Making links to \`msdos'."
292(cd msdos
293 ln ChangeLog emacs.ico emacs.pif ../${tempdir}/msdos
6f8b09f3 294 ln mainmake sed*.inp ../${tempdir}/msdos
52d7b2e5
RS
295 cd ../${tempdir}/msdos
296 rm -f =*)
297
1260d6ba 298echo "Making links to \`oldXMenu'."
f7dbcf3c 299(cd oldXMenu
8bdbf9ed 300 ln *.c *.h *.in ../${tempdir}/oldXMenu
df1ec566 301 ln README Imakefile ChangeLog ../${tempdir}/oldXMenu
f395c83a 302 ln compile.com descrip.mms ../${tempdir}/oldXMenu)
f7dbcf3c 303
c660c0a7
RS
304echo "Making links to \`lwlib'."
305(cd lwlib
306 ln *.c *.h *.in ../${tempdir}/lwlib
307 ln README Imakefile ChangeLog ../${tempdir}/lwlib)
308
1260d6ba 309echo "Making links to \`etc'."
f395c83a
JB
310### Don't distribute = files, TAGS, DOC files, backups, autosaves, or
311### tex litter.
f7dbcf3c 312(cd etc
375f1bd7 313 ln `ls -d * | grep -v 'RCS' | grep -v 'Old' | grep -v '^e$'` ../${tempdir}/etc
f7dbcf3c 314 cd ../${tempdir}/etc
23a58692 315 rm -f DOC* *~ \#*\# *.dvi *.log *.orig *.rej *,v =* core
f395c83a 316 rm -f TAGS)
f7dbcf3c 317
f08ad882
RS
318echo "Making links to \`etc/e'."
319(cd etc/e
375f1bd7 320 ln `ls -d * | grep -v 'RCS'` ../../${tempdir}/etc/e
a6903f09 321 cd ../../${tempdir}/etc/e
375f1bd7 322 rm -f *~ \#*\# *,v =* core)
f08ad882 323
fda4e8f6
JB
324echo "Making links to \`cpp'."
325(cd cpp
326 ln cccp.c cexp.y Makefile README ../${tempdir}/cpp)
327
66afa119
RS
328echo "Making links to \`info'."
329# Don't distribute backups or autosaves.
330(cd info
331 ln [a-zA-Z]* ../${tempdir}/info
332 cd ../${tempdir}/info
333 # Avoid an error when expanding the wildcards later.
334 ln emacs dummy~ ; ln emacs \#dummy\#
335 rm -f *~ \#*\# core)
fda4e8f6
JB
336
337echo "Making links to \`man'."
338(cd man
298c8970 339 ln *.texi *.aux *.cps *.fns *.kys *.vrs ../${tempdir}/man
5e808bc0 340 test -f README && ln README ../${tempdir}/man
f08ad882 341 test -f Makefile.in && ln Makefile.in ../${tempdir}/man
56c31c87 342 ln ChangeLog split-man ../${tempdir}/man
375f1bd7 343 cp texinfo.tex ../${tempdir}/man
4f8cc93a 344 cd ../${tempdir}/man
56c31c87
RS
345 rm -f \#*\# =* *~ core emacs-index* *.Z *.z xmail
346 rm -f emacs.?? termcap.?? gdb.?? *.log *.toc *.dvi *.oaux)
f7dbcf3c 347
40eef465
JB
348echo "Making links to \`vms'."
349(cd vms
350 ln [0-9a-zA-Z]* ../${tempdir}/vms
351 cd ../${tempdir}/vms
352 rm -f *~)
353
c87b230f
JB
354### It would be nice if they could all be symlinks to etc's copy, but
355### you're not supposed to have any symlinks in distribution tar files.
356echo "Making sure copying notices are all copies of \`etc/COPYING'."
1260d6ba
ER
357rm -f ${tempdir}/etc/COPYING
358cp etc/COPYING ${tempdir}/etc/COPYING
8e583b5d 359for subdir in lisp src lib-src info msdos; do
f7dbcf3c
JB
360 if [ -f ${tempdir}/${subdir}/COPYING ]; then
361 rm ${tempdir}/${subdir}/COPYING
362 fi
96858c42 363 cp etc/COPYING ${tempdir}/${subdir}
f7dbcf3c
JB
364done
365
5b8def65
JB
366#### Make sure that there aren't any hard links between files in the
367#### distribution; people with afs can't deal with that. Okay,
368#### actually we just re-copy anything with a link count greater
375f1bd7
KH
369#### than two. (Yes, strictly greater than 2 is correct; since we
370#### created these files by linking them in from the original tree,
371#### they'll have exactly two links normally.)
bb7e0f81 372####
908ff139 373#### Commented out since it's not strictly necessary; it should suffice
bb7e0f81 374#### to just break the link on alloca.c.
9b23a6c7
RS
375#echo "Breaking intra-tree links."
376#find ${tempdir} ! -type d -links +2 \
377# -exec cp -p {} $$ \; -exec rm -f {} \; -exec mv $$ {} \;
bb7e0f81
KH
378rm -f $tempdir/lib-src/alloca.c
379cp $tempdir/src/alloca.c $tempdir/lib-src/alloca.c
5b8def65 380
1260d6ba
ER
381if [ "${newer}" ]; then
382 echo "Removing files older than $newer."
76fb0a58
JB
383 ## We remove .elc files unconditionally, on the theory that anyone picking
384 ## up an incremental distribution already has a running Emacs to byte-compile
385 ## them with.
1260d6ba
ER
386 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
387fi
388
4746118a 389if [ "${make_tar}" = yes ]; then
922ac4c5
JB
390 if [ "${default_gzip}" = "" ]; then
391 echo "Looking for gzip."
392 temppath=`echo $PATH | sed 's/^:/.:/
393 s/::/:.:/g
394 s/:$/:./
395 s/:/ /g'`
396 default_gzip=`(
397 for dir in ${temppath}; do
398 if [ -f ${dir}/gzip ]; then echo 'gzip --best'; exit 0; fi
399 done
400 echo compress
401 )`
402 fi
f395c83a
JB
403 case "${default_gzip}" in
404 compress* ) gzip_extension=.Z ;;
0dc610dd 405 * ) gzip_extension=.gz ;;
f395c83a 406 esac
4746118a 407 echo "Creating tar file."
f395c83a
JB
408 (cd ${tempparent} ; tar cvf - ${emacsname} ) \
409 | ${default_gzip} \
410 > ${emacsname}.tar${gzip_extension}
4746118a 411fi
f7dbcf3c 412
4746118a 413if [ "${clean_up}" = yes ]; then
f7dbcf3c 414 echo "Cleaning up the staging directory."
f395c83a 415 rm -rf ${tempparent}
bb160193
RS
416else
417 (cd ${tempparent}; mv ${emacsname} ..)
418 rm -rf ${tempparent}
f7dbcf3c 419fi
00c00348 420
76fb0a58 421### make-dist ends here