Commit | Line | Data |
---|---|---|
f7dbcf3c | 1 | #!/bin/sh |
76fb0a58 JB |
2 | |
3 | #### make-dist: create an Emacs distribution tar file from the current | |
1d650ff1 | 4 | #### source tree. This basically creates a duplicate directory |
76fb0a58 JB |
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. | |
f7dbcf3c JB |
8 | |
9 | progname="$0" | |
10 | ||
76fb0a58 JB |
11 | ### Exit if a command fails. |
12 | ### set -e | |
f7dbcf3c | 13 | |
76fb0a58 JB |
14 | ### Print out each line we read, for debugging's sake. |
15 | ### set -v | |
f7dbcf3c | 16 | |
4746118a JB |
17 | clean_up=yes |
18 | make_tar=yes | |
1260d6ba | 19 | newer="" |
f7dbcf3c JB |
20 | |
21 | while [ $# -gt 0 ]; do | |
22 | case "$1" in | |
76fb0a58 JB |
23 | ## This option tells make-dist not to delete the staging directory |
24 | ## after it's done making the tar file. | |
1260d6ba | 25 | "--no-clean-up" ) |
4746118a JB |
26 | clean_up=no |
27 | ;; | |
76fb0a58 JB |
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'. | |
4746118a JB |
31 | "--no-tar" ) |
32 | make_tar=no | |
33 | clean_up=no | |
f7dbcf3c | 34 | ;; |
76fb0a58 | 35 | ## This option tells make-dist to make the distribution normally, then |
7b9cd64c ER |
36 | ## remove all files older than the given timestamp file. This is useful |
37 | ## for creating incremental or patch distributions. | |
1260d6ba | 38 | "--newer") |
ef15f270 JB |
39 | newer="$2" |
40 | new_extension=".new" | |
1260d6ba ER |
41 | shift |
42 | ;; | |
922ac4c5 JB |
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 | ;; | |
f7dbcf3c JB |
48 | * ) |
49 | echo "${progname}: Unrecognized argument: $1" >&2 | |
50 | exit 1 | |
51 | ;; | |
52 | esac | |
53 | shift | |
54 | done | |
55 | ||
76fb0a58 | 56 | ### Make sure we're running in the right place. |
f7dbcf3c | 57 | if [ ! -d src -o ! -f src/lisp.h -o ! -d lisp -o ! -f lisp/version.el ]; then |
1260d6ba ER |
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 | |
0d122844 | 60 | echo "distribution tree. cd to that directory and try again." >&2 |
f7dbcf3c JB |
61 | exit 1 |
62 | fi | |
63 | ||
76fb0a58 | 64 | ### Find out which version of Emacs this is. |
f7dbcf3c | 65 | version=`grep 'defconst[ ]*emacs-version' lisp/version.el \ |
b7cceaf1 | 66 | | sed -e 's/^.*"\([0-9][0-9]*\.[0-9][0-9]*\)\..*$/\1/'` |
f7dbcf3c | 67 | if [ ! "${version}" ]; then |
1260d6ba | 68 | echo "${progname}: can't find current emacs version in \`./lisp/version.el'." >&2 |
f7dbcf3c JB |
69 | exit 1 |
70 | fi | |
71 | ||
f753e9aa JB |
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'" | |
7b7a9d23 | 76 | sleep 5 |
f753e9aa JB |
77 | fi |
78 | ||
bb160193 RS |
79 | ### Make sure we don't already have a directory emacs-${version}. |
80 | ||
81 | emacsname="emacs-${version}${new_extension}" | |
82 | ||
83 | if [ -d ${emacsname} ] | |
84 | then | |
85 | echo Directory "${emacsname}" already exists >&2 | |
86 | exit 1 | |
87 | fi | |
88 | ||
76fb0a58 | 89 | ### Make sure the subdirectory is available. |
1260d6ba | 90 | tempparent="make-dist.tmp.$$" |
f7dbcf3c | 91 | if [ -d ${tempparent} ]; then |
1260d6ba ER |
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 | |
f7dbcf3c JB |
97 | exit 1 |
98 | fi | |
99 | ||
9f7602fd JB |
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 | |
254e10d8 JB |
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}" | |
107 | fi | |
8f731fcc | 108 | rm -f /tmp/el /tmp/elc |
9f7602fd | 109 | |
b4e84d5d JB |
110 | ### Make sure configure is newer than configure.in. |
111 | if [ "x`ls -t configure configure.in | head -1`" != "xconfigure" ]; then | |
863f1210 | 112 | echo "\`./configure.in' seems to be newer than \`./configure.'" >&2 |
b4e84d5d JB |
113 | echo "Attempting to run autoconf." >&2 |
114 | autoconf | |
115 | fi | |
116 | ||
2ed56345 | 117 | ### Update getdate.c. |
6820b552 | 118 | (cd lib-src; make -f Makefile.in getdate.c YACC="bison -y") |
2ed56345 | 119 | |
1260d6ba | 120 | echo "Creating staging directory: \`${tempparent}'" |
bb160193 | 121 | |
f7dbcf3c | 122 | mkdir ${tempparent} |
f7dbcf3c JB |
123 | tempdir="${tempparent}/${emacsname}" |
124 | ||
76fb0a58 JB |
125 | ### This trap ensures that the staging directory will be cleaned up even |
126 | ### when the script is interrupted in mid-career. | |
00c00348 ER |
127 | if [ "${clean_up}" = yes ]; then |
128 | trap "echo 'Interrupted...cleaning up the staging directory.'; rm -rf ${tempparent}; exit 1" 1 2 15 | |
129 | fi | |
130 | ||
1260d6ba | 131 | echo "Creating top directory: \`${tempdir}'" |
f7dbcf3c JB |
132 | mkdir ${tempdir} |
133 | ||
76fb0a58 JB |
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. | |
1260d6ba ER |
138 | echo "Making links to top-level files." |
139 | ln GETTING.GNU.SOFTWARE INSTALL PROBLEMS README move-if-change ${tempdir} | |
ad8f07cd | 140 | ln ChangeLog Makefile.in build-ins.in configure configure.in ${tempdir} |
cd376b50 | 141 | ln make-dist vpath.sed ${tempdir} |
bb160193 | 142 | ### Copy these files; they're cross-filesystem symlinks. |
76fb0a58 | 143 | cp config.sub ${tempdir} |
2ed56345 | 144 | cp config.guess ${tempdir} |
bb160193 | 145 | cp install.sh ${tempdir} |
f7dbcf3c | 146 | |
f753e9aa JB |
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) | |
154 | ||
155 | ||
f7dbcf3c | 156 | echo "Creating subdirectories." |
e793672b JB |
157 | # I think we're not going to distribute anything in external-lisp, so |
158 | # I've removed it from this list. | |
82a82d48 | 159 | for subdir in lisp lisp/term site-lisp \ |
c660c0a7 | 160 | src src/m src/s src/bitmaps lib-src oldXMenu lwlib \ |
52d7b2e5 | 161 | etc lock cpp info man msdos shortnames vms; do |
f7dbcf3c JB |
162 | mkdir ${tempdir}/${subdir} |
163 | done | |
164 | ||
1260d6ba | 165 | echo "Making links to \`lisp'." |
7b9cd64c | 166 | ### Don't distribute TAGS, =*.el files, site-init.el, site-load.el, or default.el. |
f7dbcf3c JB |
167 | (cd lisp |
168 | ln [a-zA-Z]*.el ../${tempdir}/lisp | |
169 | ln [a-zA-Z]*.elc ../${tempdir}/lisp | |
8d2197ac | 170 | ln [a-zA-Z]*.dat ../${tempdir}/lisp |
76fb0a58 JB |
171 | ## simula.el doesn't keep abbreviations in simula.defns any more. |
172 | ## ln [a-zA-Z]*.defns ../${tempdir}/lisp | |
8cce1257 | 173 | ln ChangeLog ChangeLog.? README dired.todo ../${tempdir}/lisp |
f7dbcf3c | 174 | cd ../${tempdir}/lisp |
7b9cd64c | 175 | rm -f TAGS =* |
f7dbcf3c | 176 | rm -f site-init site-init.el site-init.elc |
ef15f270 JB |
177 | rm -f site-load site-load.el site-load.elc |
178 | rm -f default default.el default.elc) | |
f7dbcf3c | 179 | |
56c31c87 RS |
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) | |
fda4e8f6 | 189 | |
1260d6ba | 190 | echo "Making links to \`lisp/term'." |
7b9cd64c | 191 | ### Don't distribute =*.el files or TAGS. |
f7dbcf3c JB |
192 | (cd lisp/term |
193 | ln [a-zA-Z]*.el ../../${tempdir}/lisp/term | |
194 | ln [a-zA-Z]*.elc ../../${tempdir}/lisp/term | |
3e1fc5a7 | 195 | ln README ../../${tempdir}/lisp/term |
7b9cd64c | 196 | rm -f =* TAGS) |
f7dbcf3c | 197 | |
e793672b | 198 | ### echo "Making links to \`external-lisp'." |
7b9cd64c | 199 | ### ### Don't distribute =*.el files or TAGS. |
e793672b JB |
200 | ### (cd external-lisp |
201 | ### ln [a-zA-Z]*.el ../${tempdir}/external-lisp | |
202 | ### ln [a-zA-Z]*.elc ../${tempdir}/external-lisp | |
7b9cd64c ER |
203 | ### ln ChangeLog README ../${tempdir}/external-lisp |
204 | ### rm -f =* TAGS) | |
1260d6ba ER |
205 | |
206 | echo "Making links to \`src'." | |
76fb0a58 | 207 | ### Don't distribute =*.[ch] files, or the configured versions of |
9284d3a4 | 208 | ### config.h.in, paths.h.in, or Makefile.in.in, or TAGS. |
f7dbcf3c | 209 | (cd src |
76fb0a58 | 210 | echo " (If we can't link gmalloc.c, that's okay.)" |
f7dbcf3c | 211 | ln [a-zA-Z]*.c ../${tempdir}/src |
76fb0a58 | 212 | ## Might be a symlink to a file on another filesystem. |
39d6eb8e | 213 | test -f ../${tempdir}/src/gmalloc.c || cp gmalloc.c ../${tempdir}/src |
f7dbcf3c JB |
214 | ln [a-zA-Z]*.h ../${tempdir}/src |
215 | ln [a-zA-Z]*.s ../${tempdir}/src | |
8cce1257 | 216 | ln README Makefile.in.in ChangeLog ChangeLog.? config.h.in paths.h.in \ |
f7dbcf3c | 217 | ../${tempdir}/src |
990ee059 | 218 | ln .gdbinit .dbxinit ../${tempdir}/src |
6f95b621 | 219 | ln *.opt vms-pp.trans ../${tempdir}/src |
f7dbcf3c | 220 | cd ../${tempdir}/src |
ef15f270 | 221 | rm -f config.h paths.h Makefile |
7b9cd64c | 222 | rm -f =* TAGS) |
f7dbcf3c | 223 | |
690eca32 JB |
224 | echo "Making links to \`src/bitmaps'." |
225 | (cd src/bitmaps | |
226 | ln README *.xbm ../../${tempdir}/src/bitmaps) | |
227 | ||
1260d6ba | 228 | echo "Making links to \`src/m'." |
f7dbcf3c | 229 | (cd src/m |
1dce54a1 | 230 | ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/m) |
f7dbcf3c | 231 | |
1260d6ba | 232 | echo "Making links to \`src/s'." |
f7dbcf3c | 233 | (cd src/s |
1dce54a1 | 234 | ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/s) |
f7dbcf3c | 235 | |
1260d6ba | 236 | echo "Making links to \`lib-src'." |
f7dbcf3c | 237 | (cd lib-src |
fa377791 | 238 | ln [a-zA-Z]*.[chy] [a-zA-Z]*.lex ../${tempdir}/lib-src |
1260d6ba | 239 | ln ChangeLog Makefile.in README testfile vcdiff rcs2log ../${tempdir}/lib-src |
d1b985ec | 240 | ln emacs.csh rcs-checkin ../${tempdir}/lib-src |
1260d6ba | 241 | cd ../${tempdir}/lib-src |
690a797c | 242 | rm -f getdate.tab.c y.tab.c y.tab.h |
7b9cd64c | 243 | rm -f =* TAGS) |
f7dbcf3c | 244 | |
52d7b2e5 RS |
245 | echo "Making links to \`msdos'." |
246 | (cd msdos | |
247 | ln ChangeLog emacs.ico emacs.pif ../${tempdir}/msdos | |
ccd5f1ca | 248 | ln mainmake sed[123].inp ../${tempdir}/msdos |
52d7b2e5 RS |
249 | cd ../${tempdir}/msdos |
250 | rm -f =*) | |
251 | ||
1260d6ba | 252 | echo "Making links to \`oldXMenu'." |
f7dbcf3c | 253 | (cd oldXMenu |
8bdbf9ed | 254 | ln *.c *.h *.in ../${tempdir}/oldXMenu |
df1ec566 | 255 | ln README Imakefile ChangeLog ../${tempdir}/oldXMenu |
f395c83a | 256 | ln compile.com descrip.mms ../${tempdir}/oldXMenu) |
f7dbcf3c | 257 | |
c660c0a7 RS |
258 | echo "Making links to \`lwlib'." |
259 | (cd lwlib | |
260 | ln *.c *.h *.in ../${tempdir}/lwlib | |
261 | ln README Imakefile ChangeLog ../${tempdir}/lwlib) | |
262 | ||
1260d6ba | 263 | echo "Making links to \`etc'." |
f395c83a JB |
264 | ### Don't distribute = files, TAGS, DOC files, backups, autosaves, or |
265 | ### tex litter. | |
f7dbcf3c | 266 | (cd etc |
f395c83a | 267 | ln `ls -d * | grep -v 'RCS' | grep -v 'Old'` ../${tempdir}/etc |
f7dbcf3c | 268 | cd ../${tempdir}/etc |
f395c83a JB |
269 | rm -f DOC* *~ \#*\# *.dvi *.log *,v =* core |
270 | rm -f TAGS) | |
f7dbcf3c | 271 | |
fda4e8f6 JB |
272 | echo "Making links to \`cpp'." |
273 | (cd cpp | |
274 | ln cccp.c cexp.y Makefile README ../${tempdir}/cpp) | |
275 | ||
66afa119 RS |
276 | echo "Making links to \`info'." |
277 | # Don't distribute backups or autosaves. | |
278 | (cd info | |
279 | ln [a-zA-Z]* ../${tempdir}/info | |
280 | cd ../${tempdir}/info | |
281 | # Avoid an error when expanding the wildcards later. | |
282 | ln emacs dummy~ ; ln emacs \#dummy\# | |
283 | rm -f *~ \#*\# core) | |
fda4e8f6 JB |
284 | |
285 | echo "Making links to \`man'." | |
286 | (cd man | |
298c8970 | 287 | ln *.texi *.aux *.cps *.fns *.kys *.vrs ../${tempdir}/man |
5e808bc0 JB |
288 | test -f README && ln README ../${tempdir}/man |
289 | test -f Makefile && ln Makefile ../${tempdir}/man | |
56c31c87 | 290 | ln ChangeLog split-man ../${tempdir}/man |
91a480c1 | 291 | cp texinfo.tex texindex.c getopt.c ../${tempdir}/man |
4f8cc93a | 292 | cd ../${tempdir}/man |
56c31c87 RS |
293 | rm -f \#*\# =* *~ core emacs-index* *.Z *.z xmail |
294 | rm -f emacs.?? termcap.?? gdb.?? *.log *.toc *.dvi *.oaux) | |
f7dbcf3c | 295 | |
1260d6ba | 296 | echo "Making links to \`shortnames'." |
f7dbcf3c JB |
297 | (cd shortnames |
298 | ln *.c ../${tempdir}/shortnames | |
299 | ln Makefile reserved special ../${tempdir}/shortnames) | |
300 | ||
40eef465 JB |
301 | echo "Making links to \`vms'." |
302 | (cd vms | |
303 | ln [0-9a-zA-Z]* ../${tempdir}/vms | |
304 | cd ../${tempdir}/vms | |
305 | rm -f *~) | |
306 | ||
c87b230f JB |
307 | ### It would be nice if they could all be symlinks to etc's copy, but |
308 | ### you're not supposed to have any symlinks in distribution tar files. | |
309 | echo "Making sure copying notices are all copies of \`etc/COPYING'." | |
1260d6ba ER |
310 | rm -f ${tempdir}/etc/COPYING |
311 | cp etc/COPYING ${tempdir}/etc/COPYING | |
52d7b2e5 | 312 | for subdir in lisp src lib-src info shortnames msdos; do |
f7dbcf3c JB |
313 | if [ -f ${tempdir}/${subdir}/COPYING ]; then |
314 | rm ${tempdir}/${subdir}/COPYING | |
315 | fi | |
96858c42 | 316 | cp etc/COPYING ${tempdir}/${subdir} |
f7dbcf3c JB |
317 | done |
318 | ||
5b8def65 JB |
319 | #### Make sure that there aren't any hard links between files in the |
320 | #### distribution; people with afs can't deal with that. Okay, | |
321 | #### actually we just re-copy anything with a link count greater | |
322 | #### than two. | |
323 | echo "Breaking intra-tree links." | |
e94817d7 | 324 | find ${tempdir} ! -type d -links +2 \ |
2752c6f9 | 325 | -exec cp -p {} $$ \; -exec rm -f {} \; -exec mv $$ {} \; |
5b8def65 | 326 | |
1260d6ba ER |
327 | if [ "${newer}" ]; then |
328 | echo "Removing files older than $newer." | |
76fb0a58 JB |
329 | ## We remove .elc files unconditionally, on the theory that anyone picking |
330 | ## up an incremental distribution already has a running Emacs to byte-compile | |
331 | ## them with. | |
1260d6ba ER |
332 | find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \; |
333 | fi | |
334 | ||
4746118a | 335 | if [ "${make_tar}" = yes ]; then |
922ac4c5 JB |
336 | if [ "${default_gzip}" = "" ]; then |
337 | echo "Looking for gzip." | |
338 | temppath=`echo $PATH | sed 's/^:/.:/ | |
339 | s/::/:.:/g | |
340 | s/:$/:./ | |
341 | s/:/ /g'` | |
342 | default_gzip=`( | |
343 | for dir in ${temppath}; do | |
344 | if [ -f ${dir}/gzip ]; then echo 'gzip --best'; exit 0; fi | |
345 | done | |
346 | echo compress | |
347 | )` | |
348 | fi | |
f395c83a JB |
349 | case "${default_gzip}" in |
350 | compress* ) gzip_extension=.Z ;; | |
0dc610dd | 351 | * ) gzip_extension=.gz ;; |
f395c83a | 352 | esac |
4746118a | 353 | echo "Creating tar file." |
f395c83a JB |
354 | (cd ${tempparent} ; tar cvf - ${emacsname} ) \ |
355 | | ${default_gzip} \ | |
356 | > ${emacsname}.tar${gzip_extension} | |
4746118a | 357 | fi |
f7dbcf3c | 358 | |
4746118a | 359 | if [ "${clean_up}" = yes ]; then |
f7dbcf3c | 360 | echo "Cleaning up the staging directory." |
f395c83a | 361 | rm -rf ${tempparent} |
bb160193 RS |
362 | else |
363 | (cd ${tempparent}; mv ${emacsname} ..) | |
364 | rm -rf ${tempparent} | |
f7dbcf3c | 365 | fi |
00c00348 | 366 | |
76fb0a58 | 367 | ### make-dist ends here |