]> code.delx.au - gnu-emacs/blob - make-dist
* make-dist: When breaking links, remove the link before moving
[gnu-emacs] / 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 progname="$0"
10
11 ### Exit if a command fails.
12 ### set -e
13
14 ### Print out each line we read, for debugging's sake.
15 ### set -v
16
17 clean_up=yes
18 make_tar=yes
19 newer=""
20
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
27 ;;
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
34 ;;
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
42 ;;
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"
47 ;;
48 * )
49 echo "${progname}: Unrecognized argument: $1" >&2
50 exit 1
51 ;;
52 esac
53 shift
54 done
55
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
62 fi
63
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
70 fi
71
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 exit 1
77 fi
78
79 ### Make sure the subdirectory is available.
80 tempparent="make-dist.tmp.$$"
81 if [ -d ${tempparent} ]; then
82 echo "${progname}: staging directory \`${tempparent}' already exists.
83 Perhaps a previous invocation of \`${progname}' failed to clean up after
84 itself. Check that directories whose names are of the form
85 \`make-dist.tmp.NNNNN' don't contain any important information, remove
86 them, and try again." >&2
87 exit 1
88 fi
89
90 echo "Creating staging directory: \`${tempparent}'"
91 mkdir ${tempparent}
92 emacsname="emacs-${version}${new_extension}"
93 tempdir="${tempparent}/${emacsname}"
94
95 ### This trap ensures that the staging directory will be cleaned up even
96 ### when the script is interrupted in mid-career.
97 if [ "${clean_up}" = yes ]; then
98 trap "echo 'Interrupted...cleaning up the staging directory.'; rm -rf ${tempparent}; exit 1" 1 2 15
99 fi
100
101 echo "Creating top directory: \`${tempdir}'"
102 mkdir ${tempdir}
103
104 ### We copy in the top-level files before creating the subdirectories in
105 ### hopes that this will make the top-level files appear first in the
106 ### tar file; this means that people can start reading the INSTALL and
107 ### README while the rest of the tar file is still unpacking. Whoopee.
108 echo "Making links to top-level files."
109 ln GETTING.GNU.SOFTWARE INSTALL PROBLEMS README move-if-change ${tempdir}
110 ln ChangeLog Makefile.in build-install.in configure configure.in ${tempdir}
111 ln make-dist ${tempdir}
112 ### Copy config.sub; it's a cross-filesystem symlink.
113 cp config.sub ${tempdir}
114
115 echo "Updating version number in README."
116 (cd ${tempdir}
117 awk \
118 '$1 " " $2 " " $3 " " $4 " " $5 == "This directory tree holds version" { $6 = version; print $0 }
119 $1 " " $2 " " $3 " " $4 " " $5 != "This directory tree holds version"' \
120 version=${version} README > tmp.README
121 mv tmp.README README)
122
123
124 echo "Creating subdirectories."
125 # I think we're not going to distribute anything in external-lisp, so
126 # I've removed it from this list.
127 for subdir in lisp lisp/term local-lisp \
128 src src/m src/s src/bitmaps lib-src oldXMenu \
129 etc lock cpp info man shortnames vms; do
130 mkdir ${tempdir}/${subdir}
131 done
132
133 echo "Making links to \`lisp'."
134 ### Don't distribute TAGS, =*.el files, site-init.el, site-load.el, or default.el.
135 (cd lisp
136 ln [a-zA-Z]*.el ../${tempdir}/lisp
137 ln [a-zA-Z]*.elc ../${tempdir}/lisp
138 ## simula.el doesn't keep abbreviations in simula.defns any more.
139 ## ln [a-zA-Z]*.defns ../${tempdir}/lisp
140 ln ChangeLog README ../${tempdir}/lisp
141 cd ../${tempdir}/lisp
142 rm -f TAGS =*
143 rm -f site-init site-init.el site-init.elc
144 rm -f site-load site-load.el site-load.elc
145 rm -f default default.el default.elc)
146
147 #echo "Making links to \`lisp/calc-2.02'."
148 #### Don't distribute =*.el files, TAGS or backups.
149 #(cd lisp/calc-2.02
150 # ln [a-zA-Z]*.el ../../${tempdir}/lisp/calc-2.02
151 # ln [a-zA-Z]*.elc ../../${tempdir}/lisp/calc-2.02
152 # ln calc.info* calc.texinfo calc-refcard.* ../../${tempdir}/lisp/calc-2.02
153 # ln INSTALL Makefile README README.prev ../../${tempdir}/lisp/calc-2.02
154 # cd ../../${tempdir}/lisp/calc-2.02
155 # rm -f *~ TAGS)
156
157 echo "Making links to \`lisp/term'."
158 ### Don't distribute =*.el files or TAGS.
159 (cd lisp/term
160 ln [a-zA-Z]*.el ../../${tempdir}/lisp/term
161 ln [a-zA-Z]*.elc ../../${tempdir}/lisp/term
162 ln README ChangeLog ../../${tempdir}/lisp/term
163 rm -f =* TAGS)
164
165 ### echo "Making links to \`external-lisp'."
166 ### ### Don't distribute =*.el files or TAGS.
167 ### (cd external-lisp
168 ### ln [a-zA-Z]*.el ../${tempdir}/external-lisp
169 ### ln [a-zA-Z]*.elc ../${tempdir}/external-lisp
170 ### ln ChangeLog README ../${tempdir}/external-lisp
171 ### rm -f =* TAGS)
172
173 echo "Making links to \`src'."
174 ### Don't distribute =*.[ch] files, or the configured versions of
175 ### config.h.in, paths.h.in, or Makefile.in, or TAGS.
176 (cd src
177 echo " (If we can't link gmalloc.c, that's okay.)"
178 ln [a-zA-Z]*.c ../${tempdir}/src
179 ## Might be a symlink to a file on another filesystem.
180 test -f ../${tempdir}/src/gmalloc.c || cp gmalloc.c ../${tempdir}/src
181 ln [a-zA-Z]*.h ../${tempdir}/src
182 ln [a-zA-Z]*.s ../${tempdir}/src
183 ln README Makefile.in ymakefile ChangeLog config.h.in paths.h.in \
184 ../${tempdir}/src
185 ln .gdbinit .dbxinit ../${tempdir}/src
186 ln *.opt vms-pp.trans ../${tempdir}/src
187 cd ../${tempdir}/src
188 rm -f config.h paths.h Makefile
189 if [ -z "${newer}" ]; then
190 etags *.h *.c ../lisp/*.el
191 fi
192 rm -f =* TAGS)
193
194 echo "Making links to \`src/bitmaps'."
195 (cd src/bitmaps
196 ln README *.xbm ../../${tempdir}/src/bitmaps)
197
198 echo "Making links to \`src/m'."
199 (cd src/m
200 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/m)
201
202 echo "Making links to \`src/s'."
203 (cd src/s
204 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/s)
205
206 echo "Making links to \`lib-src'."
207 (cd lib-src
208 ln [a-zA-Z]*.[chy] [a-zA-Z]*.lex ../${tempdir}/lib-src
209 ln ChangeLog Makefile.in README testfile vcdiff rcs2log ../${tempdir}/lib-src
210 ln emacs.csh rcs-checkin ../${tempdir}/lib-src
211 cd ../${tempdir}/lib-src
212 rm -f getdate.c getdate.tab.c y.tab.c y.tab.h
213 rm -f =* TAGS)
214
215 echo "Making links to \`oldXMenu'."
216 (cd oldXMenu
217 ln *.c *.h *.in ../${tempdir}/oldXMenu
218 ln README Imakefile ChangeLog ../${tempdir}/oldXMenu
219 ln compile.com descrip.mms ../${tempdir}/oldXMenu)
220
221 echo "Making links to \`etc'."
222 ### Don't distribute = files, TAGS, DOC files, backups, autosaves, or
223 ### tex litter.
224 (cd etc
225 ln `ls -d * | grep -v 'RCS' | grep -v 'Old'` ../${tempdir}/etc
226 cd ../${tempdir}/etc
227 rm -f DOC* *~ \#*\# *.dvi *.log *,v =* core
228 rm -f TAGS)
229
230 echo "Making links to \`cpp'."
231 (cd cpp
232 ln cccp.c cexp.y Makefile README ../${tempdir}/cpp)
233
234 echo "Making links to \`info'."
235 # Don't distribute backups or autosaves.
236 (cd info
237 ln [a-zA-Z]* ../${tempdir}/info
238 cd ../${tempdir}/info
239 # Avoid an error when expanding the wildcards later.
240 ln emacs dummy~ ; ln emacs \#dummy\#
241 rm -f *~ \#*\# core)
242
243 echo "Making links to \`man'."
244 (cd man
245 ln *.texinfo *.texi *.aux *.cps *.fns *.kys *.vrs ../${tempdir}/man
246 test -f README && ln README ../${tempdir}/man
247 test -f Makefile && ln Makefile ../${tempdir}/man
248 ln ChangeLog split-man ../${tempdir}/man
249 cp texinfo.tex texindex.c ../${tempdir}/man
250 cd ../${tempdir}/man
251 rm -f \#*\# =* *~ core emacs-index* *.Z *.z xmail
252 rm -f emacs.?? termcap.?? gdb.?? *.log *.toc *.dvi *.oaux)
253
254 echo "Making links to \`shortnames'."
255 (cd shortnames
256 ln *.c ../${tempdir}/shortnames
257 ln Makefile reserved special ../${tempdir}/shortnames)
258
259 echo "Making links to \`vms'."
260 (cd vms
261 ln [0-9a-zA-Z]* ../${tempdir}/vms
262 cd ../${tempdir}/vms
263 rm -f *~)
264
265 ### It would be nice if they could all be symlinks to etc's copy, but
266 ### you're not supposed to have any symlinks in distribution tar files.
267 echo "Making sure copying notices are all copies of \`etc/COPYING'."
268 rm -f ${tempdir}/etc/COPYING
269 cp etc/COPYING ${tempdir}/etc/COPYING
270 # I think we're not going to distribute anything in external-lisp, so
271 # I've removed it from this list.
272 for subdir in lisp src lib-src info shortnames; do
273 if [ -f ${tempdir}/${subdir}/COPYING ]; then
274 rm ${tempdir}/${subdir}/COPYING
275 fi
276 cp etc/COPYING ${tempdir}/${subdir}
277 done
278
279 #### Make sure that there aren't any hard links between files in the
280 #### distribution; people with afs can't deal with that. Okay,
281 #### actually we just re-copy anything with a link count greater
282 #### than two.
283 echo "Breaking intra-tree links."
284 find ${tempdir} ! -type d -links +2 \
285 -exec cp {} $$ \; -exec rm -f {} \; -exec mv $$ {} \;
286
287 if [ "${newer}" ]; then
288 echo "Removing files older than $newer."
289 ## We remove .elc files unconditionally, on the theory that anyone picking
290 ## up an incremental distribution already has a running Emacs to byte-compile
291 ## them with.
292 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
293 fi
294
295 if [ "${make_tar}" = yes ]; then
296 if [ "${default_gzip}" = "" ]; then
297 echo "Looking for gzip."
298 temppath=`echo $PATH | sed 's/^:/.:/
299 s/::/:.:/g
300 s/:$/:./
301 s/:/ /g'`
302 default_gzip=`(
303 for dir in ${temppath}; do
304 if [ -f ${dir}/gzip ]; then echo 'gzip --best'; exit 0; fi
305 done
306 echo compress
307 )`
308 fi
309 case "${default_gzip}" in
310 compress* ) gzip_extension=.Z ;;
311 * ) gzip_extension=.z ;;
312 esac
313 echo "Creating tar file."
314 (cd ${tempparent} ; tar cvf - ${emacsname} ) \
315 | ${default_gzip} \
316 > ${emacsname}.tar${gzip_extension}
317 fi
318
319 if [ "${clean_up}" = yes ]; then
320 echo "Cleaning up the staging directory."
321 rm -rf ${tempparent}
322 fi
323
324 ### make-dist ends here