Include config.h.
[bpt/emacs.git] / make-dist
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
25 # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26
27 progname="$0"
28
29 ### Exit if a command fails.
30 ### set -e
31
32 ### Print out each line we read, for debugging's sake.
33 ### set -v
34
35 clean_up=yes
36 make_tar=yes
37 newer=""
38
39 while [ $# -gt 0 ]; do
40 case "$1" in
41 ## This option tells make-dist not to delete the staging directory
42 ## after it's done making the tar file.
43 "--no-clean-up" )
44 clean_up=no
45 ;;
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'.
49 "--no-tar" )
50 make_tar=no
51 clean_up=no
52 ;;
53 ## This option tells make-dist to make the distribution normally, then
54 ## remove all files older than the given timestamp file. This is useful
55 ## for creating incremental or patch distributions.
56 "--newer")
57 newer="$2"
58 new_extension=".new"
59 shift
60 ;;
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 ;;
66 * )
67 echo "${progname}: Unrecognized argument: $1" >&2
68 exit 1
69 ;;
70 esac
71 shift
72 done
73
74 ### Make sure we're running in the right place.
75 if [ ! -d src -o ! -f src/lisp.h -o ! -d lisp -o ! -f lisp/version.el ]; then
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
78 echo "distribution tree. cd to that directory and try again." >&2
79 exit 1
80 fi
81
82 ### Find out which version of Emacs this is.
83 shortversion=`grep 'defconst[ ]*emacs-version' lisp/version.el \
84 | sed -e 's/^.*"\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/'`
85 version=`grep 'defconst[ ]*emacs-version' lisp/version.el \
86 | sed -e 's/^[^"]*"\([^"]*\)".*$/\1/'`
87 if [ ! "${version}" ]; then
88 echo "${progname}: can't find current Emacs version in \`./lisp/version.el'." >&2
89 exit 1
90 fi
91
92 echo $version and $shortversion
93
94 if grep -s "GNU Emacs version ${shortversion}" ./man/emacs.texi > /dev/null; then
95 true
96 else
97 echo "You must update the version number in \`./man/emacs.texi'"
98 sleep 5
99 fi
100
101 ### Make sure we don't already have a directory emacs-${version}.
102
103 emacsname="emacs-${version}${new_extension}"
104
105 if [ -d ${emacsname} ]
106 then
107 echo Directory "${emacsname}" already exists >&2
108 exit 1
109 fi
110
111 ### Make sure the subdirectory is available.
112 tempparent="make-dist.tmp.$$"
113 if [ -d ${tempparent} ]; then
114 echo "${progname}: staging directory \`${tempparent}' already exists.
115 Perhaps a previous invocation of \`${progname}' failed to clean up after
116 itself. Check that directories whose names are of the form
117 \`make-dist.tmp.NNNNN' don't contain any important information, remove
118 them, and try again." >&2
119 exit 1
120 fi
121
122 ### Check for .elc files with no corresponding .el file.
123 ls -1 lisp/*.el | sed 's/\.el$/.elc/' > /tmp/el
124 ls -1 lisp/*.elc > /tmp/elc
125 bogosities="`comm -13 /tmp/el /tmp/elc`"
126 if [ "${bogosities}" != "" ]; then
127 echo "The following .elc files have no corresponding .el files:"
128 echo "${bogosities}"
129 fi
130 rm -f /tmp/el /tmp/elc
131
132 ### Make sure configure is newer than configure.in.
133 if [ "x`ls -t configure configure.in | head -1`" != "xconfigure" ]; then
134 echo "\`./configure.in' seems to be newer than \`./configure.'" >&2
135 echo "Attempting to run autoconf." >&2
136 autoconf
137 fi
138
139 ### Update getdate.c.
140 (cd lib-src; make -f Makefile getdate.c YACC="bison -y")
141
142 echo "Updating Info files."
143
144 (cd man; make info)
145
146 echo "Updating finder-inf.el."
147
148 ### update finder-inf.el.
149 (cd src; emacs -batch -l finder -f finder-compile-keywords)
150
151 echo "Creating staging directory: \`${tempparent}'"
152
153 mkdir ${tempparent}
154 tempdir="${tempparent}/${emacsname}"
155
156 ### This trap ensures that the staging directory will be cleaned up even
157 ### when the script is interrupted in mid-career.
158 if [ "${clean_up}" = yes ]; then
159 trap "echo 'Interrupted...cleaning up the staging directory.'; rm -rf ${tempparent}; exit 1" 1 2 15
160 fi
161
162 echo "Creating top directory: \`${tempdir}'"
163 mkdir ${tempdir}
164
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.
169 echo "Making links to top-level files."
170 ln GETTING.GNU.SOFTWARE INSTALL PROBLEMS README BUGS move-if-change ${tempdir}
171 ln ChangeLog Makefile.in configure configure.in ${tempdir}
172 ln config.bat make-dist update-subdirs vpath.sed ${tempdir}
173 ### Copy these files; they're cross-filesystem symlinks.
174 cp mkinstalldirs ${tempdir}
175 cp config.sub ${tempdir}
176 cp config.guess ${tempdir}
177 cp install.sh ${tempdir}
178
179 echo "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
188 echo "Creating subdirectories."
189 for subdir in lisp lisp/term site-lisp \
190 src src/m src/s src/bitmaps lib-src oldXMenu lwlib \
191 nt nt/inc nt/inc/sys \
192 etc etc/e lock cpp info man msdos vms; do
193 mkdir ${tempdir}/${subdir}
194 done
195
196 echo "Making links to \`lisp'."
197 ### Don't distribute TAGS, =*.el files, site-init.el, site-load.el, or default.el.
198 (cd lisp
199 ln [a-zA-Z]*.el ../${tempdir}/lisp
200 ln [a-zA-Z]*.elc ../${tempdir}/lisp
201 ln [a-zA-Z]*.dat ../${tempdir}/lisp
202 ## simula.el doesn't keep abbreviations in simula.defns any more.
203 ## ln [a-zA-Z]*.defns ../${tempdir}/lisp
204 ln ChangeLog Makefile makefile.nt ChangeLog.? README dired.todo ../${tempdir}/lisp
205 cd ../${tempdir}/lisp
206 rm -f TAGS =*
207 rm -f site-init site-init.el site-init.elc
208 rm -f site-load site-load.el site-load.elc
209 rm -f default default.el default.elc)
210
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)
220
221 echo "Making links to \`lisp/term'."
222 ### Don't distribute =*.el files or TAGS.
223 (cd lisp/term
224 ln [a-zA-Z]*.el ../../${tempdir}/lisp/term
225 ln [a-zA-Z]*.elc ../../${tempdir}/lisp/term
226 ln README ../../${tempdir}/lisp/term
227 rm -f =* TAGS)
228
229 echo "Making links to \`src'."
230 ### Don't distribute =*.[ch] files, or the configured versions of
231 ### config.h.in, paths.h.in, or Makefile.in.in, or TAGS.
232 (cd src
233 echo " (If we can't link gmalloc.c, that's okay.)"
234 ln [a-zA-Z]*.c ../${tempdir}/src
235 ## Might be a symlink to a file on another filesystem.
236 test -f ../${tempdir}/src/gmalloc.c || cp gmalloc.c ../${tempdir}/src
237 ln [a-zA-Z]*.h ../${tempdir}/src
238 ln [a-zA-Z]*.s ../${tempdir}/src
239 ln README Makefile.in.in ChangeLog ChangeLog.? config.h.in paths.h.in \
240 ../${tempdir}/src
241 ln .gdbinit .dbxinit ../${tempdir}/src
242 ln *.opt vms-pp.trans ../${tempdir}/src
243 cd ../${tempdir}/src
244 rm -f config.h paths.h Makefile
245 rm -f =* TAGS)
246
247 echo "Making links to \`src/bitmaps'."
248 (cd src/bitmaps
249 ln README *.xbm ../../${tempdir}/src/bitmaps)
250
251 echo "Making links to \`src/m'."
252 (cd src/m
253 # We call files for miscellaneous input (to linker etc) .inp.
254 ln README [a-zA-Z0-9]*.h *.inp ../../${tempdir}/src/m)
255
256 echo "Making links to \`src/s'."
257 (cd src/s
258 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/s)
259
260 echo "Making links to \`lib-src'."
261 (cd lib-src
262 ln [a-zA-Z]*.[chy] ../${tempdir}/lib-src
263 ln ChangeLog Makefile.in.in README testfile vcdiff ../${tempdir}/lib-src
264 ln emacs.csh rcs2log rcs-checkin makefile.nt ../${tempdir}/lib-src
265 cd ../${tempdir}/lib-src
266 rm -f getdate.tab.c y.tab.c y.tab.h
267 rm -f =* TAGS)
268
269 echo "Making links to \`nt'."
270 (cd nt
271 ln [a-z]*.bat [a-z]*.h makefile.* todo ChangeLog install readme ../${tempdir}/nt)
272
273 echo "Making links to \`nt/inc'."
274 (cd nt/inc
275 ln [a-z]*.h ../../${tempdir}/nt/inc)
276
277 echo "Making links to \`nt/inc/sys'."
278 (cd nt/inc/sys
279 ln [a-z]*.h ../../../${tempdir}/nt/inc/sys)
280
281 echo "Making links to \`msdos'."
282 (cd msdos
283 ln ChangeLog emacs.ico emacs.pif ../${tempdir}/msdos
284 ln mainmake sed*.inp ../${tempdir}/msdos
285 cd ../${tempdir}/msdos
286 rm -f =*)
287
288 echo "Making links to \`oldXMenu'."
289 (cd oldXMenu
290 ln *.c *.h *.in ../${tempdir}/oldXMenu
291 ln README Imakefile ChangeLog ../${tempdir}/oldXMenu
292 ln compile.com descrip.mms ../${tempdir}/oldXMenu)
293
294 echo "Making links to \`lwlib'."
295 (cd lwlib
296 ln *.c *.h *.in ../${tempdir}/lwlib
297 ln README Imakefile ChangeLog ../${tempdir}/lwlib)
298
299 echo "Making links to \`etc'."
300 ### Don't distribute = files, TAGS, DOC files, backups, autosaves, or
301 ### tex litter.
302 (cd etc
303 ln `ls -d * | grep -v 'RCS' | grep -v 'Old' | grep -v '^e$'` ../${tempdir}/etc
304 cd ../${tempdir}/etc
305 rm -f DOC* *~ \#*\# *.dvi *.log *,v =* core
306 rm -f TAGS)
307
308 echo "Making links to \`etc/e'."
309 (cd etc/e
310 ln `ls -d * | grep -v 'RCS'` ../../${tempdir}/etc/e
311 cd ../../${tempdir}/etc
312 rm -f *~ \#*\# *,v =* core)
313
314 echo "Making links to \`cpp'."
315 (cd cpp
316 ln cccp.c cexp.y Makefile README ../${tempdir}/cpp)
317
318 echo "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)
326
327 echo "Making links to \`man'."
328 (cd man
329 ln *.texi *.aux *.cps *.fns *.kys *.vrs ../${tempdir}/man
330 test -f README && ln README ../${tempdir}/man
331 test -f Makefile.in && ln Makefile.in ../${tempdir}/man
332 ln ChangeLog split-man ../${tempdir}/man
333 cp texinfo.tex ../${tempdir}/man
334 cd ../${tempdir}/man
335 rm -f \#*\# =* *~ core emacs-index* *.Z *.z xmail
336 rm -f emacs.?? termcap.?? gdb.?? *.log *.toc *.dvi *.oaux)
337
338 echo "Making links to \`vms'."
339 (cd vms
340 ln [0-9a-zA-Z]* ../${tempdir}/vms
341 cd ../${tempdir}/vms
342 rm -f *~)
343
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.
346 echo "Making sure copying notices are all copies of \`etc/COPYING'."
347 rm -f ${tempdir}/etc/COPYING
348 cp etc/COPYING ${tempdir}/etc/COPYING
349 for subdir in lisp src lib-src info msdos; do
350 if [ -f ${tempdir}/${subdir}/COPYING ]; then
351 rm ${tempdir}/${subdir}/COPYING
352 fi
353 cp etc/COPYING ${tempdir}/${subdir}
354 done
355
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
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.)
362 echo "Breaking intra-tree links."
363 find ${tempdir} ! -type d -links +2 \
364 -exec cp -p {} $$ \; -exec rm -f {} \; -exec mv $$ {} \;
365
366 if [ "${newer}" ]; then
367 echo "Removing files older than $newer."
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.
371 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
372 fi
373
374 if [ "${make_tar}" = yes ]; then
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
388 case "${default_gzip}" in
389 compress* ) gzip_extension=.Z ;;
390 * ) gzip_extension=.gz ;;
391 esac
392 echo "Creating tar file."
393 (cd ${tempparent} ; tar cvf - ${emacsname} ) \
394 | ${default_gzip} \
395 > ${emacsname}.tar${gzip_extension}
396 fi
397
398 if [ "${clean_up}" = yes ]; then
399 echo "Cleaning up the staging directory."
400 rm -rf ${tempparent}
401 else
402 (cd ${tempparent}; mv ${emacsname} ..)
403 rm -rf ${tempparent}
404 fi
405
406 ### make-dist ends here