Include config.h.
[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.
149(cd src; emacs -batch -l finder -f finder-compile-keywords)
150
1260d6ba 151echo "Creating staging directory: \`${tempparent}'"
bb160193 152
f7dbcf3c 153mkdir ${tempparent}
f7dbcf3c
JB
154tempdir="${tempparent}/${emacsname}"
155
76fb0a58
JB
156### This trap ensures that the staging directory will be cleaned up even
157### when the script is interrupted in mid-career.
00c00348
ER
158if [ "${clean_up}" = yes ]; then
159 trap "echo 'Interrupted...cleaning up the staging directory.'; rm -rf ${tempparent}; exit 1" 1 2 15
160fi
161
1260d6ba 162echo "Creating top directory: \`${tempdir}'"
f7dbcf3c
JB
163mkdir ${tempdir}
164
76fb0a58
JB
165### We copy in the top-level files before creating the subdirectories in
166### hopes that this will make the top-level files appear first in the
167### tar file; this means that people can start reading the INSTALL and
168### README while the rest of the tar file is still unpacking. Whoopee.
1260d6ba 169echo "Making links to top-level files."
525336b7 170ln GETTING.GNU.SOFTWARE INSTALL PROBLEMS README BUGS move-if-change ${tempdir}
ac4eff2d 171ln ChangeLog Makefile.in configure configure.in ${tempdir}
6f8b09f3 172ln config.bat make-dist update-subdirs vpath.sed ${tempdir}
bb160193 173### Copy these files; they're cross-filesystem symlinks.
a4888c88 174cp mkinstalldirs ${tempdir}
76fb0a58 175cp config.sub ${tempdir}
2ed56345 176cp config.guess ${tempdir}
bb160193 177cp install.sh ${tempdir}
f7dbcf3c 178
f753e9aa
JB
179echo "Updating version number in README."
180(cd ${tempdir}
181 awk \
182 '$1 " " $2 " " $3 " " $4 " " $5 == "This directory tree holds version" { $6 = version; print $0 }
183 $1 " " $2 " " $3 " " $4 " " $5 != "This directory tree holds version"' \
184 version=${version} README > tmp.README
185 mv tmp.README README)
186
187
f7dbcf3c 188echo "Creating subdirectories."
82a82d48 189for subdir in lisp lisp/term site-lisp \
c660c0a7 190 src src/m src/s src/bitmaps lib-src oldXMenu lwlib \
77427171 191 nt nt/inc nt/inc/sys \
8e583b5d 192 etc etc/e lock cpp info man msdos vms; do
f7dbcf3c
JB
193 mkdir ${tempdir}/${subdir}
194done
195
1260d6ba 196echo "Making links to \`lisp'."
7b9cd64c 197### Don't distribute TAGS, =*.el files, site-init.el, site-load.el, or default.el.
f7dbcf3c
JB
198(cd lisp
199 ln [a-zA-Z]*.el ../${tempdir}/lisp
200 ln [a-zA-Z]*.elc ../${tempdir}/lisp
8d2197ac 201 ln [a-zA-Z]*.dat ../${tempdir}/lisp
76fb0a58
JB
202 ## simula.el doesn't keep abbreviations in simula.defns any more.
203 ## ln [a-zA-Z]*.defns ../${tempdir}/lisp
391b3748 204 ln ChangeLog Makefile makefile.nt ChangeLog.? README dired.todo ../${tempdir}/lisp
f7dbcf3c 205 cd ../${tempdir}/lisp
7b9cd64c 206 rm -f TAGS =*
f7dbcf3c 207 rm -f site-init site-init.el site-init.elc
ef15f270
JB
208 rm -f site-load site-load.el site-load.elc
209 rm -f default default.el default.elc)
f7dbcf3c 210
56c31c87
RS
211#echo "Making links to \`lisp/calc-2.02'."
212#### Don't distribute =*.el files, TAGS or backups.
213#(cd lisp/calc-2.02
214# ln [a-zA-Z]*.el ../../${tempdir}/lisp/calc-2.02
215# ln [a-zA-Z]*.elc ../../${tempdir}/lisp/calc-2.02
216# ln calc.info* calc.texinfo calc-refcard.* ../../${tempdir}/lisp/calc-2.02
217# ln INSTALL Makefile README README.prev ../../${tempdir}/lisp/calc-2.02
218# cd ../../${tempdir}/lisp/calc-2.02
219# rm -f *~ TAGS)
fda4e8f6 220
1260d6ba 221echo "Making links to \`lisp/term'."
7b9cd64c 222### Don't distribute =*.el files or TAGS.
f7dbcf3c
JB
223(cd lisp/term
224 ln [a-zA-Z]*.el ../../${tempdir}/lisp/term
225 ln [a-zA-Z]*.elc ../../${tempdir}/lisp/term
3e1fc5a7 226 ln README ../../${tempdir}/lisp/term
7b9cd64c 227 rm -f =* TAGS)
f7dbcf3c 228
1260d6ba 229echo "Making links to \`src'."
76fb0a58 230### Don't distribute =*.[ch] files, or the configured versions of
9284d3a4 231### config.h.in, paths.h.in, or Makefile.in.in, or TAGS.
f7dbcf3c 232(cd src
76fb0a58 233 echo " (If we can't link gmalloc.c, that's okay.)"
f7dbcf3c 234 ln [a-zA-Z]*.c ../${tempdir}/src
76fb0a58 235 ## Might be a symlink to a file on another filesystem.
39d6eb8e 236 test -f ../${tempdir}/src/gmalloc.c || cp gmalloc.c ../${tempdir}/src
f7dbcf3c
JB
237 ln [a-zA-Z]*.h ../${tempdir}/src
238 ln [a-zA-Z]*.s ../${tempdir}/src
8cce1257 239 ln README Makefile.in.in ChangeLog ChangeLog.? config.h.in paths.h.in \
f7dbcf3c 240 ../${tempdir}/src
990ee059 241 ln .gdbinit .dbxinit ../${tempdir}/src
6f95b621 242 ln *.opt vms-pp.trans ../${tempdir}/src
f7dbcf3c 243 cd ../${tempdir}/src
ef15f270 244 rm -f config.h paths.h Makefile
7b9cd64c 245 rm -f =* TAGS)
f7dbcf3c 246
690eca32
JB
247echo "Making links to \`src/bitmaps'."
248(cd src/bitmaps
249 ln README *.xbm ../../${tempdir}/src/bitmaps)
250
1260d6ba 251echo "Making links to \`src/m'."
f7dbcf3c 252(cd src/m
facbb78e
RS
253 # We call files for miscellaneous input (to linker etc) .inp.
254 ln README [a-zA-Z0-9]*.h *.inp ../../${tempdir}/src/m)
f7dbcf3c 255
1260d6ba 256echo "Making links to \`src/s'."
f7dbcf3c 257(cd src/s
77427171 258 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/s)
f7dbcf3c 259
1260d6ba 260echo "Making links to \`lib-src'."
f7dbcf3c 261(cd lib-src
375f1bd7 262 ln [a-zA-Z]*.[chy] ../${tempdir}/lib-src
0e0186f1 263 ln ChangeLog Makefile.in.in README testfile vcdiff ../${tempdir}/lib-src
391b3748 264 ln emacs.csh rcs2log rcs-checkin makefile.nt ../${tempdir}/lib-src
1260d6ba 265 cd ../${tempdir}/lib-src
690a797c 266 rm -f getdate.tab.c y.tab.c y.tab.h
7b9cd64c 267 rm -f =* TAGS)
f7dbcf3c 268
391b3748
RS
269echo "Making links to \`nt'."
270(cd nt
77427171 271 ln [a-z]*.bat [a-z]*.h makefile.* todo ChangeLog install readme ../${tempdir}/nt)
391b3748
RS
272
273echo "Making links to \`nt/inc'."
274(cd nt/inc
77427171 275 ln [a-z]*.h ../../${tempdir}/nt/inc)
391b3748
RS
276
277echo "Making links to \`nt/inc/sys'."
278(cd nt/inc/sys
77427171 279 ln [a-z]*.h ../../../${tempdir}/nt/inc/sys)
391b3748 280
52d7b2e5
RS
281echo "Making links to \`msdos'."
282(cd msdos
283 ln ChangeLog emacs.ico emacs.pif ../${tempdir}/msdos
6f8b09f3 284 ln mainmake sed*.inp ../${tempdir}/msdos
52d7b2e5
RS
285 cd ../${tempdir}/msdos
286 rm -f =*)
287
1260d6ba 288echo "Making links to \`oldXMenu'."
f7dbcf3c 289(cd oldXMenu
8bdbf9ed 290 ln *.c *.h *.in ../${tempdir}/oldXMenu
df1ec566 291 ln README Imakefile ChangeLog ../${tempdir}/oldXMenu
f395c83a 292 ln compile.com descrip.mms ../${tempdir}/oldXMenu)
f7dbcf3c 293
c660c0a7
RS
294echo "Making links to \`lwlib'."
295(cd lwlib
296 ln *.c *.h *.in ../${tempdir}/lwlib
297 ln README Imakefile ChangeLog ../${tempdir}/lwlib)
298
1260d6ba 299echo "Making links to \`etc'."
f395c83a
JB
300### Don't distribute = files, TAGS, DOC files, backups, autosaves, or
301### tex litter.
f7dbcf3c 302(cd etc
375f1bd7 303 ln `ls -d * | grep -v 'RCS' | grep -v 'Old' | grep -v '^e$'` ../${tempdir}/etc
f7dbcf3c 304 cd ../${tempdir}/etc
f395c83a
JB
305 rm -f DOC* *~ \#*\# *.dvi *.log *,v =* core
306 rm -f TAGS)
f7dbcf3c 307
f08ad882
RS
308echo "Making links to \`etc/e'."
309(cd etc/e
375f1bd7
KH
310 ln `ls -d * | grep -v 'RCS'` ../../${tempdir}/etc/e
311 cd ../../${tempdir}/etc
312 rm -f *~ \#*\# *,v =* core)
f08ad882 313
fda4e8f6
JB
314echo "Making links to \`cpp'."
315(cd cpp
316 ln cccp.c cexp.y Makefile README ../${tempdir}/cpp)
317
66afa119
RS
318echo "Making links to \`info'."
319# Don't distribute backups or autosaves.
320(cd info
321 ln [a-zA-Z]* ../${tempdir}/info
322 cd ../${tempdir}/info
323 # Avoid an error when expanding the wildcards later.
324 ln emacs dummy~ ; ln emacs \#dummy\#
325 rm -f *~ \#*\# core)
fda4e8f6
JB
326
327echo "Making links to \`man'."
328(cd man
298c8970 329 ln *.texi *.aux *.cps *.fns *.kys *.vrs ../${tempdir}/man
5e808bc0 330 test -f README && ln README ../${tempdir}/man
f08ad882 331 test -f Makefile.in && ln Makefile.in ../${tempdir}/man
56c31c87 332 ln ChangeLog split-man ../${tempdir}/man
375f1bd7 333 cp texinfo.tex ../${tempdir}/man
4f8cc93a 334 cd ../${tempdir}/man
56c31c87
RS
335 rm -f \#*\# =* *~ core emacs-index* *.Z *.z xmail
336 rm -f emacs.?? termcap.?? gdb.?? *.log *.toc *.dvi *.oaux)
f7dbcf3c 337
40eef465
JB
338echo "Making links to \`vms'."
339(cd vms
340 ln [0-9a-zA-Z]* ../${tempdir}/vms
341 cd ../${tempdir}/vms
342 rm -f *~)
343
c87b230f
JB
344### It would be nice if they could all be symlinks to etc's copy, but
345### you're not supposed to have any symlinks in distribution tar files.
346echo "Making sure copying notices are all copies of \`etc/COPYING'."
1260d6ba
ER
347rm -f ${tempdir}/etc/COPYING
348cp etc/COPYING ${tempdir}/etc/COPYING
8e583b5d 349for subdir in lisp src lib-src info msdos; do
f7dbcf3c
JB
350 if [ -f ${tempdir}/${subdir}/COPYING ]; then
351 rm ${tempdir}/${subdir}/COPYING
352 fi
96858c42 353 cp etc/COPYING ${tempdir}/${subdir}
f7dbcf3c
JB
354done
355
5b8def65
JB
356#### Make sure that there aren't any hard links between files in the
357#### distribution; people with afs can't deal with that. Okay,
358#### actually we just re-copy anything with a link count greater
375f1bd7
KH
359#### than two. (Yes, strictly greater than 2 is correct; since we
360#### created these files by linking them in from the original tree,
361#### they'll have exactly two links normally.)
5b8def65 362echo "Breaking intra-tree links."
e94817d7 363find ${tempdir} ! -type d -links +2 \
2752c6f9 364 -exec cp -p {} $$ \; -exec rm -f {} \; -exec mv $$ {} \;
5b8def65 365
1260d6ba
ER
366if [ "${newer}" ]; then
367 echo "Removing files older than $newer."
76fb0a58
JB
368 ## We remove .elc files unconditionally, on the theory that anyone picking
369 ## up an incremental distribution already has a running Emacs to byte-compile
370 ## them with.
1260d6ba
ER
371 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
372fi
373
4746118a 374if [ "${make_tar}" = yes ]; then
922ac4c5
JB
375 if [ "${default_gzip}" = "" ]; then
376 echo "Looking for gzip."
377 temppath=`echo $PATH | sed 's/^:/.:/
378 s/::/:.:/g
379 s/:$/:./
380 s/:/ /g'`
381 default_gzip=`(
382 for dir in ${temppath}; do
383 if [ -f ${dir}/gzip ]; then echo 'gzip --best'; exit 0; fi
384 done
385 echo compress
386 )`
387 fi
f395c83a
JB
388 case "${default_gzip}" in
389 compress* ) gzip_extension=.Z ;;
0dc610dd 390 * ) gzip_extension=.gz ;;
f395c83a 391 esac
4746118a 392 echo "Creating tar file."
f395c83a
JB
393 (cd ${tempparent} ; tar cvf - ${emacsname} ) \
394 | ${default_gzip} \
395 > ${emacsname}.tar${gzip_extension}
4746118a 396fi
f7dbcf3c 397
4746118a 398if [ "${clean_up}" = yes ]; then
f7dbcf3c 399 echo "Cleaning up the staging directory."
f395c83a 400 rm -rf ${tempparent}
bb160193
RS
401else
402 (cd ${tempparent}; mv ${emacsname} ..)
403 rm -rf ${tempparent}
f7dbcf3c 404fi
00c00348 405
76fb0a58 406### make-dist ends here