All fsets changed to defaliases.
[emacs.git] / make-dist
blob60072c9ec0ad83a61975c313b807e10c60194f18
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 ### 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
83 echo "Creating staging directory: \`${tempparent}'"
84 mkdir ${tempparent}
85 emacsname="emacs-${version}${new_extension}"
86 tempdir="${tempparent}/${emacsname}"
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
94 echo "Creating top directory: \`${tempdir}'"
95 mkdir ${tempdir}
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 ${tempdir}
104 ln make-dist ${tempdir}
105 ### Copy config.sub; it's a cross-filesystem symlink.
106 cp config.sub ${tempdir}
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/calc-2.02 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
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)
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)
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)
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)
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
176 rm -f =* TAGS)
178 echo "Making links to \`src/bitmaps'."
179 (cd src/bitmaps
180 ln README *.xbm ../../${tempdir}/src/bitmaps)
182 echo "Making links to \`src/m'."
183 (cd src/m
184 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/m)
186 echo "Making links to \`src/s'."
187 (cd src/s
188 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/s)
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)
199 echo "Making links to \`oldXMenu'."
200 (cd oldXMenu
201 ln *.c *.h ../${tempdir}/oldXMenu
202 ln README Makefile Imakefile ChangeLog ../${tempdir}/oldXMenu
203 ln compile.com descrip.mms ../${tempdir}/oldXMenu)
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)
214 echo "Making links to \`cpp'."
215 (cd cpp
216 ln cccp.c cexp.y Makefile README ../${tempdir}/cpp)
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)
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)
235 echo "Making links to \`shortnames'."
236 (cd shortnames
237 ln *.c ../${tempdir}/shortnames
238 ln Makefile reserved special ../${tempdir}/shortnames)
240 echo "Making links to \`vms'."
241 (cd vms
242 ln [0-9a-zA-Z]* ../${tempdir}/vms
243 cd ../${tempdir}/vms
244 rm -f *~)
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'."
249 rm -f ${tempdir}/etc/COPYING
250 cp etc/COPYING ${tempdir}/etc/COPYING
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
254 if [ -f ${tempdir}/${subdir}/COPYING ]; then
255 rm ${tempdir}/${subdir}/COPYING
257 cp etc/COPYING ${tempdir}/${subdir}
258 done
260 if [ "${newer}" ]; then
261 echo "Removing files older than $newer."
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.
265 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
268 if [ "${make_tar}" = yes ]; then
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
282 case "${default_gzip}" in
283 compress* ) gzip_extension=.Z ;;
284 * ) gzip_extension=.z ;;
285 esac
286 echo "Creating tar file."
287 (cd ${tempparent} ; tar cvf - ${emacsname} ) \
288 | ${default_gzip} \
289 > ${emacsname}.tar${gzip_extension}
292 if [ "${clean_up}" = yes ]; then
293 echo "Cleaning up the staging directory."
294 rm -rf ${tempparent}
297 ### make-dist ends here