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