(redisplay_internal, mark_window_display_accurate)
[bpt/emacs.git] / make-dist
... / ...
CommitLineData
1#!/bin/sh
2
3#### make-dist: create an Emacs distribution tar file from the current
4#### source tree. This basically creates a duplicate directory
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.
8
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 the
25# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26# Boston, MA 02111-1307, USA.
27
28progname="$0"
29
30### Exit if a command fails.
31### set -e
32
33### Print out each line we read, for debugging's sake.
34### set -v
35
36clean_up=no
37make_tar=no
38newer=""
39
40while [ $# -gt 0 ]; do
41 case "$1" in
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
46 ;;
47 ## This option tells make-dist to make a tar file.
48 "--tar" )
49 make_tar=yes
50 ;;
51 ## This option tells make-dist to make the distribution normally, then
52 ## remove all files older than the given timestamp file. This is useful
53 ## for creating incremental or patch distributions.
54 "--newer")
55 newer="$2"
56 new_extension=".new"
57 shift
58 ;;
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 ;;
64 * )
65 echo "${progname}: Unrecognized argument: $1" >&2
66 exit 1
67 ;;
68 esac
69 shift
70done
71
72### Make sure we're running in the right place.
73if [ ! -d src -o ! -f src/lisp.h -o ! -d lisp -o ! -f lisp/version.el ]; then
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
76 echo "distribution tree. cd to that directory and try again." >&2
77 exit 1
78fi
79
80### Find out which version of Emacs this is.
81shortversion=`grep 'defconst[ ]*emacs-version' lisp/version.el \
82 | sed -e 's/^.*"\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/'`
83version=`grep 'defconst[ ]*emacs-version' lisp/version.el \
84 | sed -e 's/^[^"]*"\([^"]*\)".*$/\1/'`
85if [ ! "${version}" ]; then
86 echo "${progname}: can't find current Emacs version in \`./lisp/version.el'" >&2
87 exit 1
88fi
89
90echo Version numbers are $version and $shortversion
91
92if grep -s "GNU Emacs version ${shortversion}" ./man/emacs.texi > /dev/null; then
93 true
94else
95 echo "You must update the version number in \`./man/emacs.texi'"
96 sleep 5
97fi
98
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
109### Make sure the subdirectory is available.
110tempparent="make-dist.tmp.$$"
111if [ -d ${tempparent} ]; then
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
117 exit 1
118fi
119
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
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
128rm -f /tmp/el /tmp/elc
129
130### Check for .el files that would overflow the 14-char limit if compiled.
131long=`find lisp -name '[a-zA-Z0-9]??????????*.el' -print`
132if [ "$long" != "" ]; then
133 echo "The following .el file names are too long:"
134 echo "$long"
135fi
136
137### Make sure configure is newer than configure.in.
138if [ "x`ls -t configure configure.in | head -1`" != "xconfigure" ]; then
139 echo "\`./configure.in' is newer than \`./configure'" >&2
140 echo "Running autoconf" >&2
141 autoconf || { x=$?; echo Autoconf FAILED! >&2; exit $x; }
142fi
143
144echo "Updating Info files"
145
146(cd man; make info)
147
148echo "Updating finder-inf.el"
149
150(cd lisp; ../src/emacs -batch -l finder -f finder-compile-keywords-make-dist)
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
159
160echo "Making lisp/MANIFEST"
161
162(cd lisp; head -1 [!=]*.el | grep '^;' | sed -e 's/;;; //' > MANIFEST)
163
164echo "Creating staging directory: \`${tempparent}'"
165
166mkdir ${tempparent}
167tempdir="${tempparent}/${emacsname}"
168
169### This trap ensures that the staging directory will be cleaned up even
170### when the script is interrupted in mid-career.
171if [ "${clean_up}" = yes ]; then
172 trap "echo 'Interrupted...cleaning up the staging directory'; rm -rf ${tempparent}; exit 1" 1 2 15
173fi
174
175echo "Creating top directory: \`${tempdir}'"
176mkdir ${tempdir}
177
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.
182echo "Making links to top-level files"
183ln GETTING.GNU.SOFTWARE INSTALL PROBLEMS README BUGS move-if-change ${tempdir}
184ln ChangeLog Makefile.in configure configure.in ${tempdir}
185ln config.bat make-dist update-subdirs vpath.sed ${tempdir}
186### Copy these files; they're cross-filesystem symlinks.
187cp mkinstalldirs ${tempdir}
188cp config.sub ${tempdir}
189cp config.guess ${tempdir}
190cp install.sh ${tempdir}
191
192echo "Updating version number in README"
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
201echo "Creating subdirectories"
202for subdir in lisp lisp/term site-lisp \
203 src src/m src/s src/bitmaps lib-src oldXMenu lwlib \
204 nt nt/inc nt/inc/sys nt/inc/arpa nt/inc/netinet \
205 etc etc/e lock cpp info man msdos vms; do
206 mkdir ${tempdir}/${subdir}
207done
208
209echo "Making links to \`lisp'"
210### Don't distribute TAGS, =*.el files, site-init.el, site-load.el, or default.el.
211(cd lisp
212 ln [a-zA-Z]*.el ../${tempdir}/lisp
213 ln [a-zA-Z]*.elc ../${tempdir}/lisp
214 ln [a-zA-Z]*.dat ../${tempdir}/lisp
215 ## simula.el doesn't keep abbreviations in simula.defns any more.
216 ## ln [a-zA-Z]*.defns ../${tempdir}/lisp
217 ln ChangeLog Makefile makefile.nt ChangeLog.? README ../${tempdir}/lisp
218 cd ../${tempdir}/lisp
219 rm -f TAGS =*
220 rm -f subdirs.el
221 rm -f site-init site-init.el site-init.elc
222 rm -f site-load site-load.el site-load.elc
223 rm -f site-start site-start.el site-start.elc
224 rm -f default default.el default.elc)
225
226#echo "Making links to \`lisp/calc-2.02'"
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)
235
236echo "Making links to \`lisp/term'"
237### Don't distribute =*.el files or TAGS.
238(cd lisp/term
239 ln [a-zA-Z]*.el ../../${tempdir}/lisp/term
240 ln [a-zA-Z]*.elc ../../${tempdir}/lisp/term
241 ln README ../../${tempdir}/lisp/term
242 rm -f =* TAGS)
243
244echo "Making links to \`src'"
245### Don't distribute =*.[ch] files, or the configured versions of
246### config.in, paths.in, or Makefile.in, or TAGS.
247(cd src
248 echo " (If we can't link gmalloc.c, that's okay.)"
249 ln [a-zA-Z]*.c ../${tempdir}/src
250 ## Might be a symlink to a file on another filesystem.
251 test -f ../${tempdir}/src/gmalloc.c || cp gmalloc.c ../${tempdir}/src
252 ln [a-zA-Z]*.h ../${tempdir}/src
253 ln [a-zA-Z]*.s ../${tempdir}/src
254 ln README Makefile.in ChangeLog ChangeLog.? config.in paths.in \
255 ../${tempdir}/src
256 ln makefile.nt ../${tempdir}/src
257 ln .gdbinit .dbxinit ../${tempdir}/src
258 ln *.opt vms-pp.trans ../${tempdir}/src
259 cd ../${tempdir}/src
260 rm -f config.h paths.h Makefile Makefile.c
261 rm -f =* TAGS)
262
263echo "Making links to \`src/bitmaps'"
264(cd src/bitmaps
265 ln README *.xbm ../../${tempdir}/src/bitmaps)
266
267echo "Making links to \`src/m'"
268(cd src/m
269 # We call files for miscellaneous input (to linker etc) .inp.
270 ln README [a-zA-Z0-9]*.h *.inp ../../${tempdir}/src/m)
271
272echo "Making links to \`src/s'"
273(cd src/s
274 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/s)
275
276echo "Making links to \`lib-src'"
277(cd lib-src
278 ln [a-zA-Z]*.[chy] ../${tempdir}/lib-src
279 ln ChangeLog Makefile.in README testfile vcdiff ../${tempdir}/lib-src
280 ln emacs.csh rcs2log rcs-checkin makefile.nt ../${tempdir}/lib-src
281 cd ../${tempdir}/lib-src
282 rm -f getdate.tab.c y.tab.c y.tab.h Makefile.c
283 rm -f =* TAGS)
284
285echo "Making links to \`nt'"
286(cd nt
287 ln emacs.ico emacs.rc config.nt [a-z]*.in [a-z]*.c ../${tempdir}/nt
288 ln [a-z]*.bat [a-z]*.h makefile.def makefile.nt ../${tempdir}/nt
289 ln TODO ChangeLog INSTALL README ../${tempdir}/nt)
290
291echo "Making links to \`nt/inc'"
292(cd nt/inc
293 ln [a-z]*.h ../../${tempdir}/nt/inc)
294
295echo "Making links to \`nt/inc/sys'"
296(cd nt/inc/sys
297 ln [a-z]*.h ../../../${tempdir}/nt/inc/sys)
298
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
307echo "Making links to \`msdos'"
308(cd msdos
309 ln ChangeLog emacs.ico emacs.pif ../${tempdir}/msdos
310 ln is_exec.c sigaction.c mainmake mainmake.v2 sed*.inp ../${tempdir}/msdos
311 cd ../${tempdir}/msdos
312 rm -f =*)
313
314echo "Making links to \`oldXMenu'"
315(cd oldXMenu
316 ln *.c *.h *.in ../${tempdir}/oldXMenu
317 ln README Imakefile ChangeLog ../${tempdir}/oldXMenu
318 ln compile.com descrip.mms ../${tempdir}/oldXMenu)
319
320echo "Making links to \`lwlib'"
321(cd lwlib
322 ln *.c *.h *.in ../${tempdir}/lwlib
323 ln README Imakefile ChangeLog ../${tempdir}/lwlib
324 cd ../${tempdir}/lwlib
325 rm -f lwlib-Xol*)
326
327echo "Making links to \`etc'"
328### Don't distribute = files, TAGS, DOC files, backups, autosaves, or
329### tex litter.
330(cd etc
331 ln `ls -d * | grep -v 'RCS' | grep -v 'Old' | grep -v '^e$'` ../${tempdir}/etc
332 cd ../${tempdir}/etc
333 rm -f DOC* *~ \#*\# *.dvi *.log *.orig *.rej *,v =* core
334 rm -f TAGS)
335
336echo "Making links to \`etc/e'"
337(cd etc/e
338 ln `ls -d * | grep -v 'RCS'` ../../${tempdir}/etc/e
339 cd ../../${tempdir}/etc/e
340 rm -f *~ \#*\# *,v =* core)
341
342echo "Making links to \`cpp'"
343(cd cpp
344 ln cccp.c cexp.y Makefile README ../${tempdir}/cpp)
345
346echo "Making links to \`info'"
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)
354
355echo "Making links to \`man'"
356(cd man
357 ln *.texi *.aux *.cps *.fns *.kys *.vrs ../${tempdir}/man
358 test -f README && ln README ../${tempdir}/man
359 test -f Makefile.in && ln Makefile.in ../${tempdir}/man
360 ln ChangeLog split-man ../${tempdir}/man
361 cp texinfo.tex ../${tempdir}/man
362 cd ../${tempdir}/man
363 rm -f \#*\# =* *~ core emacs-index* *.Z *.z xmail
364 rm -f emacs.?? termcap.?? gdb.?? *.log *.toc *.dvi *.oaux)
365
366echo "Making links to \`vms'"
367(cd vms
368 ln [0-9a-zA-Z]* ../${tempdir}/vms
369 cd ../${tempdir}/vms
370 rm -f *~)
371
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.
374echo "Making sure copying notices are all copies of \`etc/COPYING'"
375rm -f ${tempdir}/etc/COPYING
376cp etc/COPYING ${tempdir}/etc/COPYING
377for subdir in lisp src lib-src info msdos; do
378 if [ -f ${tempdir}/${subdir}/COPYING ]; then
379 rm ${tempdir}/${subdir}/COPYING
380 fi
381 cp etc/COPYING ${tempdir}/${subdir}
382done
383
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
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.)
390####
391#### Commented out since it's not strictly necessary; it should suffice
392#### to just break the link on alloca.c.
393#echo "Breaking intra-tree links."
394#find ${tempdir} ! -type d -links +2 \
395# -exec cp -p {} $$ \; -exec rm -f {} \; -exec mv $$ {} \;
396rm -f $tempdir/lib-src/alloca.c
397cp $tempdir/src/alloca.c $tempdir/lib-src/alloca.c
398
399if [ "${newer}" ]; then
400 echo "Removing files older than $newer"
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.
404 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
405fi
406
407if [ "${make_tar}" = yes ]; then
408 if [ "${default_gzip}" = "" ]; then
409 echo "Looking for gzip"
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
421 case "${default_gzip}" in
422 compress* ) gzip_extension=.Z ;;
423 * ) gzip_extension=.gz ;;
424 esac
425 echo "Creating tar file"
426 (cd ${tempparent} ; tar cvf - ${emacsname} ) \
427 | ${default_gzip} \
428 > ${emacsname}.tar${gzip_extension}
429fi
430
431if [ "${clean_up}" = yes ]; then
432 echo "Cleaning up the staging directory"
433 rm -rf ${tempparent}
434else
435 (cd ${tempparent}; mv ${emacsname} ..)
436 rm -rf ${tempparent}
437fi
438
439### make-dist ends here