All references to 18 changed to past tense; APOLLO and SUNBUG merged
[emacs.git] / make-dist
blob6c3c020b01b798cf0d5451c6bbb3a6c05d412f0d
1 #!/bin/sh
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.
9 progname="$0"
11 ### Exit if a command fails.
12 ### set -e
14 ### Print out each line we read, for debugging's sake.
15 ### set -v
17 clean_up=yes
18 make_tar=yes
19 newer=""
21 while [ $# -gt 0 ]; do
22 case "$1" in
23 ## This option tells make-dist not to delete the staging directory
24 ## after it's done making the tar file.
25 "--no-clean-up" )
26 clean_up=no
28 ## This option tells make-dist not to make a tar file. Since it's
29 ## rather pointless to build the whole staging directory and then
30 ## nuke it, using this option also selects '--no-clean-up'.
31 "--no-tar" )
32 make_tar=no
33 clean_up=no
35 ## This option tells make-dist to make the distribution normally, then
36 ## remove all files older than the given timestamp file. This is useful
37 ## for creating incremental or patch distributions.
38 "--newer")
39 newer="$2"
40 new_extension=".new"
41 shift
43 ## This option tells make-dist to use `compress' instead of gzip.
44 ## Normally, make-dist uses gzip whenever it is present.
45 "--compress")
46 default_gzip="compress"
48 * )
49 echo "${progname}: Unrecognized argument: $1" >&2
50 exit 1
52 esac
53 shift
54 done
56 ### Make sure we're running in the right place.
57 if [ ! -d src -o ! -f src/lisp.h -o ! -d lisp -o ! -f lisp/version.el ]; then
58 echo "${progname}: Can't find \`src/lisp.h' and \`lisp/version.el'." >&2
59 echo "${progname} must be run in the top directory of the Emacs" >&2
60 echo "distribution tree. Cd to that directory and try again." >&2
61 exit 1
64 ### Find out which version of Emacs this is.
65 version=`grep 'defconst[ ]*emacs-version' lisp/version.el \
66 | sed -e 's/^.*"\([0-9][0-9]*\.[0-9][0-9]*\)\..*$/\1/'`
67 if [ ! "${version}" ]; then
68 echo "${progname}: can't find current emacs version in \`./lisp/version.el'." >&2
69 exit 1
72 ### Make sure the subdirectory is available.
73 tempparent="make-dist.tmp.$$"
74 if [ -d ${tempparent} ]; then
75 echo "${progname}: staging directory \`${tempparent}' already exists.
76 Perhaps a previous invocation of \`${progname}' failed to clean up after
77 itself. Check that directories whose names are of the form
78 \`make-dist.tmp.NNNNN' don't contain any important information, remove
79 them, and try again." >&2
80 exit 1
83 echo "Creating staging directory: \`${tempparent}'"
84 mkdir ${tempparent}
85 emacsname="emacs-${version}${new_extension}"
86 tempdir="${tempparent}/${emacsname}"
88 ### This trap ensures that the staging directory will be cleaned up even
89 ### when the script is interrupted in mid-career.
90 if [ "${clean_up}" = yes ]; then
91 trap "echo 'Interrupted...cleaning up the staging directory.'; rm -rf ${tempparent}; exit 1" 1 2 15
94 echo "Creating top directory: \`${tempdir}'"
95 mkdir ${tempdir}
97 ### We copy in the top-level files before creating the subdirectories in
98 ### hopes that this will make the top-level files appear first in the
99 ### tar file; this means that people can start reading the INSTALL and
100 ### README while the rest of the tar file is still unpacking. Whoopee.
101 echo "Making links to top-level files."
102 ln GETTING.GNU.SOFTWARE INSTALL PROBLEMS README move-if-change ${tempdir}
103 ln ChangeLog Makefile.in build-install.in configure ${tempdir}
104 ln make-dist ${tempdir}
105 ### Copy config.sub; it's a cross-filesystem symlink.
106 cp config.sub ${tempdir}
108 echo "Creating subdirectories."
109 # I think we're not going to distribute anything in external-lisp, so
110 # I've removed it from this list.
111 for subdir in lisp lisp/calc-2.02 lisp/term local-lisp \
112 src src/m src/s src/bitmaps lib-src oldXMenu \
113 etc lock cpp info man shortnames vms; do
114 mkdir ${tempdir}/${subdir}
115 done
117 echo "Making links to \`lisp'."
118 ### Don't distribute TAGS, =*.el files, site-init.el, site-load.el, or default.el.
119 (cd lisp
120 ln [a-zA-Z]*.el ../${tempdir}/lisp
121 ln [a-zA-Z]*.elc ../${tempdir}/lisp
122 ## simula.el doesn't keep abbreviations in simula.defns any more.
123 ## ln [a-zA-Z]*.defns ../${tempdir}/lisp
124 ln ChangeLog README ../${tempdir}/lisp
125 cd ../${tempdir}/lisp
126 rm -f TAGS =*
127 rm -f site-init site-init.el site-init.elc
128 rm -f site-load site-load.el site-load.elc
129 rm -f default default.el default.elc)
131 echo "Making links to \`lisp/calc-2.02'."
132 ### Don't distribute =*.el files, TAGS or backups.
133 (cd lisp/calc-2.02
134 ln [a-zA-Z]*.el ../../${tempdir}/lisp/calc-2.02
135 ln [a-zA-Z]*.elc ../../${tempdir}/lisp/calc-2.02
136 ln calc.info* calc.texinfo calc-refcard.* ../../${tempdir}/lisp/calc-2.02
137 ln INSTALL Makefile README README.prev ../../${tempdir}/lisp/calc-2.02
138 cd ../../${tempdir}/lisp/calc-2.02
139 rm -f *~ TAGS)
141 echo "Making links to \`lisp/term'."
142 ### Don't distribute =*.el files or TAGS.
143 (cd lisp/term
144 ln [a-zA-Z]*.el ../../${tempdir}/lisp/term
145 ln [a-zA-Z]*.elc ../../${tempdir}/lisp/term
146 ln README ../../${tempdir}/lisp/term
147 rm -f =* TAGS)
149 ### echo "Making links to \`external-lisp'."
150 ### ### Don't distribute =*.el files or TAGS.
151 ### (cd external-lisp
152 ### ln [a-zA-Z]*.el ../${tempdir}/external-lisp
153 ### ln [a-zA-Z]*.elc ../${tempdir}/external-lisp
154 ### ln ChangeLog README ../${tempdir}/external-lisp
155 ### rm -f =* TAGS)
157 echo "Making links to \`src'."
158 ### Don't distribute =*.[ch] files, or the configured versions of
159 ### config.h.in, paths.h.in, or Makefile.in, or TAGS.
160 (cd src
161 echo " (If we can't link gmalloc.c, that's okay.)"
162 ln [a-zA-Z]*.c ../${tempdir}/src
163 ## Might be a symlink to a file on another filesystem.
164 test -f ../${tempdir}/src/gmalloc.c || cp gmalloc.c ../${tempdir}/src
165 ln [a-zA-Z]*.h ../${tempdir}/src
166 ln [a-zA-Z]*.s ../${tempdir}/src
167 ln README Makefile.in ymakefile ChangeLog config.h.in paths.h.in \
168 ../${tempdir}/src
169 ln .gdbinit .dbxinit ../${tempdir}/src
170 ln *.opt vms-pp.trans ../${tempdir}/src
171 cd ../${tempdir}/src
172 rm -f config.h paths.h Makefile
173 if [ -z "${newer}" ]; then
174 etags *.h *.c ../lisp/*.el
176 rm -f =* TAGS)
178 echo "Making links to \`src/bitmaps'."
179 (cd src/bitmaps
180 ln README *.xbm ../../${tempdir}/src/bitmaps)
182 echo "Making links to \`src/m'."
183 (cd src/m
184 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/m)
186 echo "Making links to \`src/s'."
187 (cd src/s
188 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/s)
190 echo "Making links to \`lib-src'."
191 (cd lib-src
192 ln [a-zA-Z]*.[chy] [a-zA-Z]*.lex [a-zA-Z]*.com ../${tempdir}/lib-src
193 ln ChangeLog Makefile.in README testfile vcdiff rcs2log ../${tempdir}/lib-src
194 ln emacs.csh ../${tempdir}/lib-src
195 cd ../${tempdir}/lib-src
196 rm -f getdate.c getdate.tab.c y.tab.c y.tab.h
197 rm -f =* TAGS)
199 echo "Making links to \`oldXMenu'."
200 (cd oldXMenu
201 ln *.c *.h ../${tempdir}/oldXMenu
202 ln README Makefile Imakefile ChangeLog ../${tempdir}/oldXMenu)
204 echo "Making links to \`etc'."
205 ### Don't distribute = files, TAGS, DOC files, backups, autosaves, or tex litter.
206 (cd etc
207 ln [0-9a-zA-Z]* ../${tempdir}/etc
208 cd ../${tempdir}/etc
209 rm -f DOC* *~ \#*\# *.dvi *.log *,v core
210 rm -f =* TAGS)
212 echo "Making links to \`cpp'."
213 (cd cpp
214 ln cccp.c cexp.y Makefile README ../${tempdir}/cpp)
216 ###!! echo "Making links to \`info'."
217 ###!! # Don't distribute backups or autosaves.
218 ###!! (cd info
219 ###!! ln [a-zA-Z]* ../${tempdir}/info
220 ###!! cd ../${tempdir}/info
221 ###!! # Avoid an error when expanding the wildcards later.
222 ###!! ln emacs dummy~ ; ln emacs \#dummy\#
223 ###!! rm -f *~ \#*\# core)
225 echo "Making links to \`man'."
226 (cd man
227 ln *.tex *.texinfo *.texi *.aux *.cps *.fns *.kys *.vrs ../${tempdir}/man
228 ln *.c ../${tempdir}/man
229 test -f README && ln README ../${tempdir}/man
230 test -f Makefile && ln Makefile ../${tempdir}/man
231 ln ChangeLog split-man ../${tempdir}/man)
233 echo "Making links to \`shortnames'."
234 (cd shortnames
235 ln *.c ../${tempdir}/shortnames
236 ln Makefile reserved special ../${tempdir}/shortnames)
238 echo "Making links to \`vms'."
239 (cd vms
240 ln [0-9a-zA-Z]* ../${tempdir}/vms
241 cd ../${tempdir}/vms
242 rm -f *~)
244 ### It would be nice if they could all be symlinks to etc's copy, but
245 ### you're not supposed to have any symlinks in distribution tar files.
246 echo "Making sure copying notices are all copies of \`etc/COPYING'."
247 rm -f ${tempdir}/etc/COPYING
248 cp etc/COPYING ${tempdir}/etc/COPYING
249 # I think we're not going to distribute anything in external-lisp, so
250 # I've removed it from this list.
251 for subdir in lisp src lib-src info shortnames; do
252 if [ -f ${tempdir}/${subdir}/COPYING ]; then
253 rm ${tempdir}/${subdir}/COPYING
255 cp etc/COPYING ${tempdir}/${subdir}
256 done
258 if [ "${newer}" ]; then
259 echo "Removing files older than $newer."
260 ## We remove .elc files unconditionally, on the theory that anyone picking
261 ## up an incremental distribution already has a running Emacs to byte-compile
262 ## them with.
263 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
266 if [ "${make_tar}" = yes ]; then
267 if [ "${default_gzip}" = "" ]; then
268 echo "Looking for gzip."
269 temppath=`echo $PATH | sed 's/^:/.:/
270 s/::/:.:/g
271 s/:$/:./
272 s/:/ /g'`
273 default_gzip=`(
274 for dir in ${temppath}; do
275 if [ -f ${dir}/gzip ]; then echo 'gzip --best'; exit 0; fi
276 done
277 echo compress
280 echo "Creating tar file."
281 (cd ${tempparent}
282 tar cvf - ${emacsname}) \
283 | ${default_gzip} > ${emacsname}.tar.Z
287 if [ "${clean_up}" = yes ]; then
288 echo "Cleaning up the staging directory."
289 rm -rf ${tempparent}
292 ### make-dist ends here