(SOME_MACHINE_OBJECTS): New var.
[emacs.git] / make-dist
blobe6c9ed99433d026c910295b938278969be30b625
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 if grep -s "GNU Emacs version ${version}" ./man/emacs.texi > /dev/null; then
73 true
74 else
75 echo "You must update the version number in \`./man/emacs.texi'"
76 sleep 5
79 ### Make sure we don't already have a directory emacs-${version}.
81 emacsname="emacs-${version}${new_extension}"
83 if [ -d ${emacsname} ]
84 then
85 echo Directory "${emacsname}" already exists >&2
86 exit 1
89 ### Make sure the subdirectory is available.
90 tempparent="make-dist.tmp.$$"
91 if [ -d ${tempparent} ]; then
92 echo "${progname}: staging directory \`${tempparent}' already exists.
93 Perhaps a previous invocation of \`${progname}' failed to clean up after
94 itself. Check that directories whose names are of the form
95 \`make-dist.tmp.NNNNN' don't contain any important information, remove
96 them, and try again." >&2
97 exit 1
100 ### Check for .elc files with no corresponding .el file.
101 ls -1 lisp/*.el | sed 's/\.el$/.elc/' > /tmp/el
102 ls -1 lisp/*.elc > /tmp/elc
103 bogosities="`comm -13 /tmp/el /tmp/elc`"
104 if [ "${bogosities}" != "" ]; then
105 echo "The following .elc files have no corresponding .el files:"
106 echo "${bogosities}"
108 rm -f /tmp/el /tmp/elc
110 ### Make sure configure is newer than configure.in.
111 if [ "x`ls -t configure configure.in | head -1`" != "xconfigure" ]; then
112 echo "\`./configure.in' seems to be newer than \`./configure.'" >&2
113 echo "Attempting to run autoconf." >&2
114 autoconf
117 ### Update getdate.c.
118 (cd lib-src; make -f Makefile.in getdate.c YACC="bison -y")
120 echo "Creating staging directory: \`${tempparent}'"
122 mkdir ${tempparent}
123 tempdir="${tempparent}/${emacsname}"
125 ### This trap ensures that the staging directory will be cleaned up even
126 ### when the script is interrupted in mid-career.
127 if [ "${clean_up}" = yes ]; then
128 trap "echo 'Interrupted...cleaning up the staging directory.'; rm -rf ${tempparent}; exit 1" 1 2 15
131 echo "Creating top directory: \`${tempdir}'"
132 mkdir ${tempdir}
134 ### We copy in the top-level files before creating the subdirectories in
135 ### hopes that this will make the top-level files appear first in the
136 ### tar file; this means that people can start reading the INSTALL and
137 ### README while the rest of the tar file is still unpacking. Whoopee.
138 echo "Making links to top-level files."
139 ln GETTING.GNU.SOFTWARE INSTALL PROBLEMS README move-if-change ${tempdir}
140 ln ChangeLog Makefile.in build-ins.in configure configure.in ${tempdir}
141 ln make-dist vpath.sed ${tempdir}
142 ### Copy these files; they're cross-filesystem symlinks.
143 cp config.sub ${tempdir}
144 cp config.guess ${tempdir}
145 cp install.sh ${tempdir}
147 echo "Updating version number in README."
148 (cd ${tempdir}
149 awk \
150 '$1 " " $2 " " $3 " " $4 " " $5 == "This directory tree holds version" { $6 = version; print $0 }
151 $1 " " $2 " " $3 " " $4 " " $5 != "This directory tree holds version"' \
152 version=${version} README > tmp.README
153 mv tmp.README README)
156 echo "Creating subdirectories."
157 # I think we're not going to distribute anything in external-lisp, so
158 # I've removed it from this list.
159 for subdir in lisp lisp/term site-lisp \
160 src src/m src/s src/bitmaps lib-src oldXMenu \
161 etc lock cpp info man shortnames vms; do
162 mkdir ${tempdir}/${subdir}
163 done
165 echo "Making links to \`lisp'."
166 ### Don't distribute TAGS, =*.el files, site-init.el, site-load.el, or default.el.
167 (cd lisp
168 ln [a-zA-Z]*.el ../${tempdir}/lisp
169 ln [a-zA-Z]*.elc ../${tempdir}/lisp
170 ln [a-zA-Z]*.dat ../${tempdir}/lisp
171 ## simula.el doesn't keep abbreviations in simula.defns any more.
172 ## ln [a-zA-Z]*.defns ../${tempdir}/lisp
173 ln ChangeLog OChangeLog README dired.todo ../${tempdir}/lisp
174 cd ../${tempdir}/lisp
175 rm -f TAGS =*
176 rm -f site-init site-init.el site-init.elc
177 rm -f site-load site-load.el site-load.elc
178 rm -f default default.el default.elc)
180 #echo "Making links to \`lisp/calc-2.02'."
181 #### Don't distribute =*.el files, TAGS or backups.
182 #(cd lisp/calc-2.02
183 # ln [a-zA-Z]*.el ../../${tempdir}/lisp/calc-2.02
184 # ln [a-zA-Z]*.elc ../../${tempdir}/lisp/calc-2.02
185 # ln calc.info* calc.texinfo calc-refcard.* ../../${tempdir}/lisp/calc-2.02
186 # ln INSTALL Makefile README README.prev ../../${tempdir}/lisp/calc-2.02
187 # cd ../../${tempdir}/lisp/calc-2.02
188 # rm -f *~ TAGS)
190 echo "Making links to \`lisp/term'."
191 ### Don't distribute =*.el files or TAGS.
192 (cd lisp/term
193 ln [a-zA-Z]*.el ../../${tempdir}/lisp/term
194 ln [a-zA-Z]*.elc ../../${tempdir}/lisp/term
195 ln README ../../${tempdir}/lisp/term
196 rm -f =* TAGS)
198 ### echo "Making links to \`external-lisp'."
199 ### ### Don't distribute =*.el files or TAGS.
200 ### (cd external-lisp
201 ### ln [a-zA-Z]*.el ../${tempdir}/external-lisp
202 ### ln [a-zA-Z]*.elc ../${tempdir}/external-lisp
203 ### ln ChangeLog README ../${tempdir}/external-lisp
204 ### rm -f =* TAGS)
206 echo "Making links to \`src'."
207 ### Don't distribute =*.[ch] files, or the configured versions of
208 ### config.h.in, paths.h.in, or Makefile.in.in, or TAGS.
209 (cd src
210 echo " (If we can't link gmalloc.c, that's okay.)"
211 ln [a-zA-Z]*.c ../${tempdir}/src
212 ## Might be a symlink to a file on another filesystem.
213 test -f ../${tempdir}/src/gmalloc.c || cp gmalloc.c ../${tempdir}/src
214 ln [a-zA-Z]*.h ../${tempdir}/src
215 ln [a-zA-Z]*.s ../${tempdir}/src
216 ln README Makefile.in.in ChangeLog OChangeLog config.h.in paths.h.in \
217 ../${tempdir}/src
218 ln .gdbinit .dbxinit ../${tempdir}/src
219 ln *.opt vms-pp.trans ../${tempdir}/src
220 cd ../${tempdir}/src
221 rm -f config.h paths.h Makefile
222 rm -f =* TAGS)
224 echo "Making links to \`src/bitmaps'."
225 (cd src/bitmaps
226 ln README *.xbm ../../${tempdir}/src/bitmaps)
228 echo "Making links to \`src/m'."
229 (cd src/m
230 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/m)
232 echo "Making links to \`src/s'."
233 (cd src/s
234 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/s)
236 echo "Making links to \`lib-src'."
237 (cd lib-src
238 ln [a-zA-Z]*.[chy] [a-zA-Z]*.lex ../${tempdir}/lib-src
239 ln ChangeLog Makefile.in README testfile vcdiff rcs2log ../${tempdir}/lib-src
240 ln emacs.csh rcs-checkin ../${tempdir}/lib-src
241 cd ../${tempdir}/lib-src
242 rm -f getdate.tab.c y.tab.c y.tab.h
243 rm -f =* TAGS)
245 echo "Making links to \`oldXMenu'."
246 (cd oldXMenu
247 ln *.c *.h *.in ../${tempdir}/oldXMenu
248 ln README Imakefile ChangeLog ../${tempdir}/oldXMenu
249 ln compile.com descrip.mms ../${tempdir}/oldXMenu)
251 echo "Making links to \`etc'."
252 ### Don't distribute = files, TAGS, DOC files, backups, autosaves, or
253 ### tex litter.
254 (cd etc
255 ln `ls -d * | grep -v 'RCS' | grep -v 'Old'` ../${tempdir}/etc
256 cd ../${tempdir}/etc
257 rm -f DOC* *~ \#*\# *.dvi *.log *,v =* core
258 rm -f TAGS)
260 echo "Making links to \`cpp'."
261 (cd cpp
262 ln cccp.c cexp.y Makefile README ../${tempdir}/cpp)
264 echo "Making links to \`info'."
265 # Don't distribute backups or autosaves.
266 (cd info
267 ln [a-zA-Z]* ../${tempdir}/info
268 cd ../${tempdir}/info
269 # Avoid an error when expanding the wildcards later.
270 ln emacs dummy~ ; ln emacs \#dummy\#
271 rm -f *~ \#*\# core)
273 echo "Making links to \`man'."
274 (cd man
275 ln *.texi *.aux *.cps *.fns *.kys *.vrs ../${tempdir}/man
276 test -f README && ln README ../${tempdir}/man
277 test -f Makefile && ln Makefile ../${tempdir}/man
278 ln ChangeLog split-man ../${tempdir}/man
279 cp texinfo.tex texindex.c getopt.c ../${tempdir}/man
280 cd ../${tempdir}/man
281 rm -f \#*\# =* *~ core emacs-index* *.Z *.z xmail
282 rm -f emacs.?? termcap.?? gdb.?? *.log *.toc *.dvi *.oaux)
284 echo "Making links to \`shortnames'."
285 (cd shortnames
286 ln *.c ../${tempdir}/shortnames
287 ln Makefile reserved special ../${tempdir}/shortnames)
289 echo "Making links to \`vms'."
290 (cd vms
291 ln [0-9a-zA-Z]* ../${tempdir}/vms
292 cd ../${tempdir}/vms
293 rm -f *~)
295 ### It would be nice if they could all be symlinks to etc's copy, but
296 ### you're not supposed to have any symlinks in distribution tar files.
297 echo "Making sure copying notices are all copies of \`etc/COPYING'."
298 rm -f ${tempdir}/etc/COPYING
299 cp etc/COPYING ${tempdir}/etc/COPYING
300 # I think we're not going to distribute anything in external-lisp, so
301 # I've removed it from this list.
302 for subdir in lisp src lib-src info shortnames; do
303 if [ -f ${tempdir}/${subdir}/COPYING ]; then
304 rm ${tempdir}/${subdir}/COPYING
306 cp etc/COPYING ${tempdir}/${subdir}
307 done
309 #### Make sure that there aren't any hard links between files in the
310 #### distribution; people with afs can't deal with that. Okay,
311 #### actually we just re-copy anything with a link count greater
312 #### than two.
313 echo "Breaking intra-tree links."
314 find ${tempdir} ! -type d -links +2 \
315 -exec cp -p {} $$ \; -exec rm -f {} \; -exec mv $$ {} \;
317 if [ "${newer}" ]; then
318 echo "Removing files older than $newer."
319 ## We remove .elc files unconditionally, on the theory that anyone picking
320 ## up an incremental distribution already has a running Emacs to byte-compile
321 ## them with.
322 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
325 if [ "${make_tar}" = yes ]; then
326 if [ "${default_gzip}" = "" ]; then
327 echo "Looking for gzip."
328 temppath=`echo $PATH | sed 's/^:/.:/
329 s/::/:.:/g
330 s/:$/:./
331 s/:/ /g'`
332 default_gzip=`(
333 for dir in ${temppath}; do
334 if [ -f ${dir}/gzip ]; then echo 'gzip --best'; exit 0; fi
335 done
336 echo compress
339 case "${default_gzip}" in
340 compress* ) gzip_extension=.Z ;;
341 * ) gzip_extension=.gz ;;
342 esac
343 echo "Creating tar file."
344 (cd ${tempparent} ; tar cvf - ${emacsname} ) \
345 | ${default_gzip} \
346 > ${emacsname}.tar${gzip_extension}
349 if [ "${clean_up}" = yes ]; then
350 echo "Cleaning up the staging directory."
351 rm -rf ${tempparent}
352 else
353 (cd ${tempparent}; mv ${emacsname} ..)
354 rm -rf ${tempparent}
357 ### make-dist ends here