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 | |
f7dbcf3c JB |
60 | echo "distribution tree. Cd to that directory and try again." >&2 |
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 | ||
76fb0a58 | 72 | ### Make sure the subdirectory is available. |
1260d6ba | 73 | tempparent="make-dist.tmp.$$" |
f7dbcf3c | 74 | if [ -d ${tempparent} ]; then |
1260d6ba ER |
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 | |
f7dbcf3c JB |
80 | exit 1 |
81 | fi | |
82 | ||
1260d6ba | 83 | echo "Creating staging directory: \`${tempparent}'" |
f7dbcf3c | 84 | mkdir ${tempparent} |
ef15f270 | 85 | emacsname="emacs-${version}${new_extension}" |
f7dbcf3c JB |
86 | tempdir="${tempparent}/${emacsname}" |
87 | ||
76fb0a58 JB |
88 | ### This trap ensures that the staging directory will be cleaned up even |
89 | ### when the script is interrupted in mid-career. | |
00c00348 ER |
90 | if [ "${clean_up}" = yes ]; then |
91 | trap "echo 'Interrupted...cleaning up the staging directory.'; rm -rf ${tempparent}; exit 1" 1 2 15 | |
92 | fi | |
93 | ||
1260d6ba | 94 | echo "Creating top directory: \`${tempdir}'" |
f7dbcf3c JB |
95 | mkdir ${tempdir} |
96 | ||
76fb0a58 JB |
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. | |
1260d6ba ER |
101 | echo "Making links to top-level files." |
102 | ln GETTING.GNU.SOFTWARE INSTALL PROBLEMS README move-if-change ${tempdir} | |
76fb0a58 | 103 | ln ChangeLog Makefile.in build-install.in configure ${tempdir} |
1dce54a1 | 104 | ln make-dist ${tempdir} |
76fb0a58 JB |
105 | ### Copy config.sub; it's a cross-filesystem symlink. |
106 | cp config.sub ${tempdir} | |
f7dbcf3c JB |
107 | |
108 | echo "Creating subdirectories." | |
e793672b JB |
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 \ | |
690eca32 | 112 | src src/m src/s src/bitmaps lib-src oldXMenu \ |
1d650ff1 | 113 | etc lock cpp info man shortnames vms; do |
f7dbcf3c JB |
114 | mkdir ${tempdir}/${subdir} |
115 | done | |
116 | ||
1260d6ba | 117 | echo "Making links to \`lisp'." |
7b9cd64c | 118 | ### Don't distribute TAGS, =*.el files, site-init.el, site-load.el, or default.el. |
f7dbcf3c JB |
119 | (cd lisp |
120 | ln [a-zA-Z]*.el ../${tempdir}/lisp | |
121 | ln [a-zA-Z]*.elc ../${tempdir}/lisp | |
76fb0a58 JB |
122 | ## simula.el doesn't keep abbreviations in simula.defns any more. |
123 | ## ln [a-zA-Z]*.defns ../${tempdir}/lisp | |
f7dbcf3c JB |
124 | ln ChangeLog README ../${tempdir}/lisp |
125 | cd ../${tempdir}/lisp | |
7b9cd64c | 126 | rm -f TAGS =* |
f7dbcf3c | 127 | rm -f site-init site-init.el site-init.elc |
ef15f270 JB |
128 | rm -f site-load site-load.el site-load.elc |
129 | rm -f default default.el default.elc) | |
f7dbcf3c | 130 | |
fda4e8f6 | 131 | echo "Making links to \`lisp/calc-2.02'." |
7b9cd64c | 132 | ### Don't distribute =*.el files, TAGS or backups. |
fda4e8f6 JB |
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 | |
7b9cd64c | 139 | rm -f *~ TAGS) |
fda4e8f6 | 140 | |
1260d6ba | 141 | echo "Making links to \`lisp/term'." |
7b9cd64c | 142 | ### Don't distribute =*.el files or TAGS. |
f7dbcf3c JB |
143 | (cd lisp/term |
144 | ln [a-zA-Z]*.el ../../${tempdir}/lisp/term | |
145 | ln [a-zA-Z]*.elc ../../${tempdir}/lisp/term | |
33d09384 | 146 | ln README ChangeLog ../../${tempdir}/lisp/term |
7b9cd64c | 147 | rm -f =* TAGS) |
f7dbcf3c | 148 | |
e793672b | 149 | ### echo "Making links to \`external-lisp'." |
7b9cd64c | 150 | ### ### Don't distribute =*.el files or TAGS. |
e793672b JB |
151 | ### (cd external-lisp |
152 | ### ln [a-zA-Z]*.el ../${tempdir}/external-lisp | |
153 | ### ln [a-zA-Z]*.elc ../${tempdir}/external-lisp | |
7b9cd64c ER |
154 | ### ln ChangeLog README ../${tempdir}/external-lisp |
155 | ### rm -f =* TAGS) | |
1260d6ba ER |
156 | |
157 | echo "Making links to \`src'." | |
76fb0a58 | 158 | ### Don't distribute =*.[ch] files, or the configured versions of |
7b9cd64c | 159 | ### config.h.in, paths.h.in, or Makefile.in, or TAGS. |
f7dbcf3c | 160 | (cd src |
76fb0a58 | 161 | echo " (If we can't link gmalloc.c, that's okay.)" |
f7dbcf3c | 162 | ln [a-zA-Z]*.c ../${tempdir}/src |
76fb0a58 | 163 | ## Might be a symlink to a file on another filesystem. |
39d6eb8e | 164 | test -f ../${tempdir}/src/gmalloc.c || cp gmalloc.c ../${tempdir}/src |
f7dbcf3c JB |
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 | |
59f2b692 | 170 | ln *.opt vms-pp.trans ../${tempdir}/src |
f7dbcf3c | 171 | cd ../${tempdir}/src |
ef15f270 JB |
172 | rm -f config.h paths.h Makefile |
173 | if [ -z "${newer}" ]; then | |
174 | etags *.h *.c ../lisp/*.el | |
7b9cd64c ER |
175 | fi |
176 | rm -f =* TAGS) | |
f7dbcf3c | 177 | |
690eca32 JB |
178 | echo "Making links to \`src/bitmaps'." |
179 | (cd src/bitmaps | |
180 | ln README *.xbm ../../${tempdir}/src/bitmaps) | |
181 | ||
1260d6ba | 182 | echo "Making links to \`src/m'." |
f7dbcf3c | 183 | (cd src/m |
1dce54a1 | 184 | ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/m) |
f7dbcf3c | 185 | |
1260d6ba | 186 | echo "Making links to \`src/s'." |
f7dbcf3c | 187 | (cd src/s |
1dce54a1 | 188 | ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/s) |
f7dbcf3c | 189 | |
1260d6ba | 190 | echo "Making links to \`lib-src'." |
f7dbcf3c | 191 | (cd lib-src |
22cb290f | 192 | ln [a-zA-Z]*.[chy] [a-zA-Z]*.lex [a-zA-Z]*.com ../${tempdir}/lib-src |
1260d6ba | 193 | ln ChangeLog Makefile.in README testfile vcdiff rcs2log ../${tempdir}/lib-src |
d1b985ec | 194 | ln emacs.csh rcs-checkin ../${tempdir}/lib-src |
1260d6ba | 195 | cd ../${tempdir}/lib-src |
7b9cd64c ER |
196 | rm -f getdate.c getdate.tab.c y.tab.c y.tab.h |
197 | rm -f =* TAGS) | |
f7dbcf3c | 198 | |
1260d6ba | 199 | echo "Making links to \`oldXMenu'." |
f7dbcf3c JB |
200 | (cd oldXMenu |
201 | ln *.c *.h ../${tempdir}/oldXMenu | |
d352289c | 202 | ln README Makefile Imakefile ChangeLog ../${tempdir}/oldXMenu |
f395c83a | 203 | ln compile.com descrip.mms ../${tempdir}/oldXMenu) |
f7dbcf3c | 204 | |
1260d6ba | 205 | echo "Making links to \`etc'." |
f395c83a JB |
206 | ### Don't distribute = files, TAGS, DOC files, backups, autosaves, or |
207 | ### tex litter. | |
f7dbcf3c | 208 | (cd etc |
f395c83a | 209 | ln `ls -d * | grep -v 'RCS' | grep -v 'Old'` ../${tempdir}/etc |
f7dbcf3c | 210 | cd ../${tempdir}/etc |
f395c83a JB |
211 | rm -f DOC* *~ \#*\# *.dvi *.log *,v =* core |
212 | rm -f TAGS) | |
f7dbcf3c | 213 | |
fda4e8f6 JB |
214 | echo "Making links to \`cpp'." |
215 | (cd cpp | |
216 | ln cccp.c cexp.y Makefile README ../${tempdir}/cpp) | |
217 | ||
bf03a38a JB |
218 | ###!! echo "Making links to \`info'." |
219 | ###!! # Don't distribute backups or autosaves. | |
220 | ###!! (cd info | |
221 | ###!! ln [a-zA-Z]* ../${tempdir}/info | |
222 | ###!! cd ../${tempdir}/info | |
223 | ###!! # Avoid an error when expanding the wildcards later. | |
224 | ###!! ln emacs dummy~ ; ln emacs \#dummy\# | |
225 | ###!! rm -f *~ \#*\# core) | |
fda4e8f6 JB |
226 | |
227 | echo "Making links to \`man'." | |
228 | (cd man | |
229 | ln *.tex *.texinfo *.texi *.aux *.cps *.fns *.kys *.vrs ../${tempdir}/man | |
230 | ln *.c ../${tempdir}/man | |
5e808bc0 JB |
231 | test -f README && ln README ../${tempdir}/man |
232 | test -f Makefile && ln Makefile ../${tempdir}/man | |
233 | ln ChangeLog split-man ../${tempdir}/man) | |
f7dbcf3c | 234 | |
1260d6ba | 235 | echo "Making links to \`shortnames'." |
f7dbcf3c JB |
236 | (cd shortnames |
237 | ln *.c ../${tempdir}/shortnames | |
238 | ln Makefile reserved special ../${tempdir}/shortnames) | |
239 | ||
40eef465 JB |
240 | echo "Making links to \`vms'." |
241 | (cd vms | |
242 | ln [0-9a-zA-Z]* ../${tempdir}/vms | |
243 | cd ../${tempdir}/vms | |
244 | rm -f *~) | |
245 | ||
c87b230f JB |
246 | ### It would be nice if they could all be symlinks to etc's copy, but |
247 | ### you're not supposed to have any symlinks in distribution tar files. | |
248 | echo "Making sure copying notices are all copies of \`etc/COPYING'." | |
1260d6ba ER |
249 | rm -f ${tempdir}/etc/COPYING |
250 | cp etc/COPYING ${tempdir}/etc/COPYING | |
5b246836 JB |
251 | # I think we're not going to distribute anything in external-lisp, so |
252 | # I've removed it from this list. | |
253 | for subdir in lisp src lib-src info shortnames; do | |
f7dbcf3c JB |
254 | if [ -f ${tempdir}/${subdir}/COPYING ]; then |
255 | rm ${tempdir}/${subdir}/COPYING | |
256 | fi | |
96858c42 | 257 | cp etc/COPYING ${tempdir}/${subdir} |
f7dbcf3c JB |
258 | done |
259 | ||
1260d6ba ER |
260 | if [ "${newer}" ]; then |
261 | echo "Removing files older than $newer." | |
76fb0a58 JB |
262 | ## We remove .elc files unconditionally, on the theory that anyone picking |
263 | ## up an incremental distribution already has a running Emacs to byte-compile | |
264 | ## them with. | |
1260d6ba ER |
265 | find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \; |
266 | fi | |
267 | ||
4746118a | 268 | if [ "${make_tar}" = yes ]; then |
922ac4c5 JB |
269 | if [ "${default_gzip}" = "" ]; then |
270 | echo "Looking for gzip." | |
271 | temppath=`echo $PATH | sed 's/^:/.:/ | |
272 | s/::/:.:/g | |
273 | s/:$/:./ | |
274 | s/:/ /g'` | |
275 | default_gzip=`( | |
276 | for dir in ${temppath}; do | |
277 | if [ -f ${dir}/gzip ]; then echo 'gzip --best'; exit 0; fi | |
278 | done | |
279 | echo compress | |
280 | )` | |
281 | fi | |
f395c83a JB |
282 | case "${default_gzip}" in |
283 | compress* ) gzip_extension=.Z ;; | |
284 | * ) gzip_extension=.z ;; | |
285 | esac | |
4746118a | 286 | echo "Creating tar file." |
f395c83a JB |
287 | (cd ${tempparent} ; tar cvf - ${emacsname} ) \ |
288 | | ${default_gzip} \ | |
289 | > ${emacsname}.tar${gzip_extension} | |
4746118a | 290 | fi |
f7dbcf3c | 291 | |
4746118a | 292 | if [ "${clean_up}" = yes ]; then |
f7dbcf3c | 293 | echo "Cleaning up the staging directory." |
f395c83a | 294 | rm -rf ${tempparent} |
f7dbcf3c | 295 | fi |
00c00348 | 296 | |
76fb0a58 | 297 | ### make-dist ends here |