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