]> code.delx.au - gnu-emacs/blob - make-dist
Don't distribute oldXMenu/Makefile.
[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 ### 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
81 fi
82
83 echo "Creating staging directory: \`${tempparent}'"
84 mkdir ${tempparent}
85 emacsname="emacs-${version}${new_extension}"
86 tempdir="${tempparent}/${emacsname}"
87
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
92 fi
93
94 echo "Creating top directory: \`${tempdir}'"
95 mkdir ${tempdir}
96
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 configure.in ${tempdir}
104 ln make-dist ${tempdir}
105 ### Copy config.sub; it's a cross-filesystem symlink.
106 cp config.sub ${tempdir}
107
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/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
116
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)
130
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)
140
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 ChangeLog ../../${tempdir}/lisp/term
147 rm -f =* TAGS)
148
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)
156
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
175 fi
176 rm -f =* TAGS)
177
178 echo "Making links to \`src/bitmaps'."
179 (cd src/bitmaps
180 ln README *.xbm ../../${tempdir}/src/bitmaps)
181
182 echo "Making links to \`src/m'."
183 (cd src/m
184 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/m)
185
186 echo "Making links to \`src/s'."
187 (cd src/s
188 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/s)
189
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 rcs-checkin ../${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)
198
199 echo "Making links to \`oldXMenu'."
200 (cd oldXMenu
201 ln *.c *.h *.in ../${tempdir}/oldXMenu
202 ln README Imakefile ChangeLog ../${tempdir}/oldXMenu
203 ln compile.com descrip.mms ../${tempdir}/oldXMenu)
204
205 echo "Making links to \`etc'."
206 ### Don't distribute = files, TAGS, DOC files, backups, autosaves, or
207 ### tex litter.
208 (cd etc
209 ln `ls -d * | grep -v 'RCS' | grep -v 'Old'` ../${tempdir}/etc
210 cd ../${tempdir}/etc
211 rm -f DOC* *~ \#*\# *.dvi *.log *,v =* core
212 rm -f TAGS)
213
214 echo "Making links to \`cpp'."
215 (cd cpp
216 ln cccp.c cexp.y Makefile README ../${tempdir}/cpp)
217
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)
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
231 test -f README && ln README ../${tempdir}/man
232 test -f Makefile && ln Makefile ../${tempdir}/man
233 ln ChangeLog split-man ../${tempdir}/man
234 cp texinfo.tex texindex.c ../${tempdir}/man
235 cd ../${tempdir}/man
236 rm -f \#*\# =* *~ core emacs-index* *.Z *.z xmail
237 rm -f emacs.?? termcap.?? gdb.?? *.log *.toc *.dvi *.oaux)
238
239 echo "Making links to \`shortnames'."
240 (cd shortnames
241 ln *.c ../${tempdir}/shortnames
242 ln Makefile reserved special ../${tempdir}/shortnames)
243
244 echo "Making links to \`vms'."
245 (cd vms
246 ln [0-9a-zA-Z]* ../${tempdir}/vms
247 cd ../${tempdir}/vms
248 rm -f *~)
249
250 ### It would be nice if they could all be symlinks to etc's copy, but
251 ### you're not supposed to have any symlinks in distribution tar files.
252 echo "Making sure copying notices are all copies of \`etc/COPYING'."
253 rm -f ${tempdir}/etc/COPYING
254 cp etc/COPYING ${tempdir}/etc/COPYING
255 # I think we're not going to distribute anything in external-lisp, so
256 # I've removed it from this list.
257 for subdir in lisp src lib-src info shortnames; do
258 if [ -f ${tempdir}/${subdir}/COPYING ]; then
259 rm ${tempdir}/${subdir}/COPYING
260 fi
261 cp etc/COPYING ${tempdir}/${subdir}
262 done
263
264 if [ "${newer}" ]; then
265 echo "Removing files older than $newer."
266 ## We remove .elc files unconditionally, on the theory that anyone picking
267 ## up an incremental distribution already has a running Emacs to byte-compile
268 ## them with.
269 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
270 fi
271
272 if [ "${make_tar}" = yes ]; then
273 if [ "${default_gzip}" = "" ]; then
274 echo "Looking for gzip."
275 temppath=`echo $PATH | sed 's/^:/.:/
276 s/::/:.:/g
277 s/:$/:./
278 s/:/ /g'`
279 default_gzip=`(
280 for dir in ${temppath}; do
281 if [ -f ${dir}/gzip ]; then echo 'gzip --best'; exit 0; fi
282 done
283 echo compress
284 )`
285 fi
286 case "${default_gzip}" in
287 compress* ) gzip_extension=.Z ;;
288 * ) gzip_extension=.z ;;
289 esac
290 echo "Creating tar file."
291 (cd ${tempparent} ; tar cvf - ${emacsname} ) \
292 | ${default_gzip} \
293 > ${emacsname}.tar${gzip_extension}
294 fi
295
296 if [ "${clean_up}" = yes ]; then
297 echo "Cleaning up the staging directory."
298 rm -rf ${tempparent}
299 fi
300
301 ### make-dist ends here