* configure: Use GCC-style configuration names, using config.sub.
[bpt/emacs.git] / 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 newer 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 * )
44 echo "${progname}: Unrecognized argument: $1" >&2
45 exit 1
46 ;;
47 esac
48 shift
49 done
50
51 ### Make sure we're running in the right place.
52 if [ ! -d src -o ! -f src/lisp.h -o ! -d lisp -o ! -f lisp/version.el ]; then
53 echo "${progname}: Can't find \`src/lisp.h' and \`lisp/version.el'." >&2
54 echo "${progname} must be run in the top directory of the Emacs" >&2
55 echo "distribution tree. Cd to that directory and try again." >&2
56 exit 1
57 fi
58
59 ### Find out which version of Emacs this is.
60 version=`grep 'defconst[ ]*emacs-version' lisp/version.el \
61 | sed -e 's/^.*"\([0-9][0-9]*\.[0-9][0-9]*\)\..*$/\1/'`
62 if [ ! "${version}" ]; then
63 echo "${progname}: can't find current emacs version in \`./lisp/version.el'." >&2
64 exit 1
65 fi
66
67 ### Make sure the subdirectory is available.
68 tempparent="make-dist.tmp.$$"
69 if [ -d ${tempparent} ]; then
70 echo "${progname}: staging directory \`${tempparent}' already exists.
71 Perhaps a previous invocation of \`${progname}' failed to clean up after
72 itself. Check that directories whose names are of the form
73 \`make-dist.tmp.NNNNN' don't contain any important information, remove
74 them, and try again." >&2
75 exit 1
76 fi
77
78 echo "Creating staging directory: \`${tempparent}'"
79 mkdir ${tempparent}
80 emacsname="emacs-${version}${new_extension}"
81 tempdir="${tempparent}/${emacsname}"
82
83 ### This trap ensures that the staging directory will be cleaned up even
84 ### when the script is interrupted in mid-career.
85 if [ "${clean_up}" = yes ]; then
86 trap "echo 'Interrupted...cleaning up the staging directory.'; rm -rf ${tempparent}; exit 1" 1 2 15
87 fi
88
89 echo "Creating top directory: \`${tempdir}'"
90 mkdir ${tempdir}
91
92 echo
93
94 echo "Don't worry if `ln' complains that it can't make
95 echo "cross-filesystem links for these files; we take care of them
96 echo "later.
97
98 ### We copy in the top-level files before creating the subdirectories in
99 ### hopes that this will make the top-level files appear first in the
100 ### tar file; this means that people can start reading the INSTALL and
101 ### README while the rest of the tar file is still unpacking. Whoopee.
102 echo "Making links to top-level files."
103 ln GETTING.GNU.SOFTWARE INSTALL PROBLEMS README move-if-change ${tempdir}
104 ln ChangeLog Makefile.in build-install.in configure ${tempdir}
105 ln make-dist ${tempdir}
106 ### Copy config.sub; it's a cross-filesystem symlink.
107 cp config.sub ${tempdir}
108
109 echo "Creating subdirectories."
110 for subdir in lisp lisp/term local-lisp external-lisp \
111 src src/m src/s lib-src oldXMenu \
112 etc lock arch-lib cpp info man shortnames vms; do
113 mkdir ${tempdir}/${subdir}
114 done
115
116 echo "Making links to \`lisp'."
117 ### Don't distribute =*.el files, site-init.el, site-load.el, or default.el.
118 (cd lisp
119 ln [a-zA-Z]*.el ../${tempdir}/lisp
120 ln [a-zA-Z]*.elc ../${tempdir}/lisp
121 ## simula.el doesn't keep abbreviations in simula.defns any more.
122 ## ln [a-zA-Z]*.defns ../${tempdir}/lisp
123 ln ChangeLog README ../${tempdir}/lisp
124 cd ../${tempdir}/lisp
125 rm -f site-init site-init.el site-init.elc
126 rm -f site-load site-load.el site-load.elc
127 rm -f default default.el default.elc)
128
129 echo "Making links to \`lisp/term'."
130 ### Don't distribute =*.el files.
131 (cd lisp/term
132 ln [a-zA-Z]*.el ../../${tempdir}/lisp/term
133 ln [a-zA-Z]*.elc ../../${tempdir}/lisp/term
134 ln README ../../${tempdir}/lisp/term)
135
136 echo "Making links to \`external-lisp'."
137 ### Don't distribute =*.el files.
138 (cd external-lisp
139 ln [a-zA-Z]*.el ../${tempdir}/external-lisp
140 ln [a-zA-Z]*.elc ../${tempdir}/external-lisp
141 ln ChangeLog README ../${tempdir}/external-lisp)
142
143 echo "Making links to \`src'."
144 ### Don't distribute =*.[ch] files, or the configured versions of
145 ### config.h.in, paths.h.in, or Makefile.in.
146 (cd src
147 echo " (If we can't link gmalloc.c, that's okay.)"
148 ln [a-zA-Z]*.c ../${tempdir}/src
149 ## Might be a symlink to a file on another filesystem.
150 cp gmalloc.c ../${tempdir}/src
151 ln [a-zA-Z]*.h ../${tempdir}/src
152 ln [a-zA-Z]*.s ../${tempdir}/src
153 ln README Makefile.in ymakefile ChangeLog config.h.in paths.h.in \
154 ../${tempdir}/src
155 ln .gdbinit .dbxinit ../${tempdir}/src
156 ln *.opt vms-pp.trans ../${tempdir}/src
157 cd ../${tempdir}/src
158 rm -f config.h paths.h Makefile
159 if [ -z "${newer}" ]; then
160 etags *.h *.c ../lisp/*.el
161 fi)
162
163 echo "Making links to \`src/m'."
164 (cd src/m
165 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/m)
166
167 echo "Making links to \`src/s'."
168 (cd src/s
169 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/s)
170
171 echo "Making links to \`lib-src'."
172 (cd lib-src
173 ln [a-zA-Z]*.[chy] [a-zA-Z]*.lex [a-zA-Z]*.com ../${tempdir}/lib-src
174 ln ChangeLog Makefile.in README testfile vcdiff rcs2log ../${tempdir}/lib-src
175 ln emacs.csh ../${tempdir}/lib-src
176 cd ../${tempdir}/lib-src
177 rm -f getdate.c getdate.tab.c y.tab.c y.tab.h)
178
179 echo "Making links to \`oldXMenu'."
180 (cd oldXMenu
181 ln *.c *.h ../${tempdir}/oldXMenu
182 ln README Makefile Imakefile ChangeLog ../${tempdir}/oldXMenu)
183
184 echo "Making links to \`etc'."
185 ### Don't distribute DOC files, backups, autosaves, or tex litter.
186 (cd etc
187 ln [0-9a-zA-Z]* ../${tempdir}/etc
188 cd ../${tempdir}/etc
189 ## Avoid an error when expanding the wildcards later.
190 for dummy in DOC-dummy dummy~ \#dummy\# dummy.dvi dummy.log; do
191 ln MACHINES ${dummy}
192 done
193 rm -f DOC* *~ \#*\# *.dvi *.log core)
194
195 ### For now, we comment these out, since I'm not changing them any.
196 ###!! echo "Making links to \`cpp'."
197 ###!! (cd cpp
198 ###!! ln cccp.c cexp.y Makefile README ../${tempdir}/cpp)
199 ###!!
200 ###!! echo "Making links to \`info'."
201 ###!! # Don't distribute backups or autosaves.
202 ###!! (cd info
203 ###!! ln [a-zA-Z]* ../${tempdir}/info
204 ###!! cd ../${tempdir}/info
205 ###!! # Avoid an error when expanding the wildcards later.
206 ###!! ln emacs dummy~ ; ln emacs \#dummy\#
207 ###!! rm -f *~ \#*\# core)
208 ###!!
209 ###!! echo "Making links to \`man'."
210 ###!! (cd man
211 ###!! ln *.tex *.texinfo *.texi *.aux *.cps *.fns *.kys *.vrs ../${tempdir}/man
212 ###!! ln *.c ../${tempdir}/man
213 ###!! ln ChangeLog Makefile README split-man ../${tempdir}/man)
214
215 echo "Making links to \`shortnames'."
216 (cd shortnames
217 ln *.c ../${tempdir}/shortnames
218 ln Makefile reserved special ../${tempdir}/shortnames)
219
220 echo "Making links to \`vms'."
221 (cd vms
222 ln [0-9a-zA-Z]* ../${tempdir}/vms
223 cd ../${tempdir}/vms
224 rm -f *~)
225
226 echo "Making sure copying notices are all symlinks to \`etc/COPYING'."
227 rm -f ${tempdir}/etc/COPYING
228 cp etc/COPYING ${tempdir}/etc/COPYING
229 for subdir in lisp external-lisp src lib-src info shortnames; do
230 if [ -f ${tempdir}/${subdir}/COPYING ]; then
231 rm ${tempdir}/${subdir}/COPYING
232 fi
233 ln -s ../etc/COPYING ${tempdir}/${subdir}
234 done
235
236 if [ "${newer}" ]; then
237 echo "Removing files older than $newer."
238 ## We remove .elc files unconditionally, on the theory that anyone picking
239 ## up an incremental distribution already has a running Emacs to byte-compile
240 ## them with.
241 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
242 fi
243
244 if [ "${make_tar}" = yes ]; then
245 echo "Creating tar file."
246 (cd ${tempparent}; tar cvf - ${emacsname}) | compress > ${emacsname}.tar.Z
247 fi
248
249 if [ "${clean_up}" = yes ]; then
250 echo "Cleaning up the staging directory."
251 rm -rf ${tempparent}
252 fi
253
254 ### make-dist ends here