]> code.delx.au - gnu-emacs/blob - make-dist
* make-dist: Don't distribute files in src/m and src/s whose names
[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 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 # We copy in the top-level files before creating the subdirectories in
93 # hopes that this will make the top-level files appear first in the
94 # tar file; this means that people can start reading the INSTALL and
95 # README while the rest of the tar file is still unpacking. Whoopee.
96 echo "Making links to top-level files."
97 ln GETTING.GNU.SOFTWARE INSTALL PROBLEMS README move-if-change ${tempdir}
98 ln ChangeLog Makefile.in build-install.in configure make-dist ${tempdir}
99 # Copy these files; on the GNU machines, at least, they are symbolic
100 # links to files on another file system, so we can't make a hard link
101 # to it. Eech.
102 cp config.sub ${tempdir}
103
104 echo "Creating subdirectories."
105 for subdir in lisp lisp/term local-lisp external-lisp \
106 src src/m src/s lib-src oldXMenu \
107 etc lock arch-lib cpp info man shortnames vms; do
108 mkdir ${tempdir}/${subdir}
109 done
110
111 echo "Making links to \`lisp'."
112 # Don't distribute =*.el files, site-init.el, site-load.el, or default.el.
113 (cd lisp
114 ln [a-zA-Z]*.el ../${tempdir}/lisp
115 ln [a-zA-Z]*.elc ../${tempdir}/lisp
116 # simula.el doesn't keep abbreviations in simula.defns any more.
117 # ln [a-zA-Z]*.defns ../${tempdir}/lisp
118 ln ChangeLog README ../${tempdir}/lisp
119 cd ../${tempdir}/lisp
120 rm -f site-init site-init.el site-init.elc
121 rm -f site-load site-load.el site-load.elc
122 rm -f default default.el default.elc)
123
124 echo "Making links to \`lisp/term'."
125 # Don't distribute =*.el files.
126 (cd lisp/term
127 ln [a-zA-Z]*.el ../../${tempdir}/lisp/term
128 ln [a-zA-Z]*.elc ../../${tempdir}/lisp/term
129 ln README ../../${tempdir}/lisp/term)
130
131 echo "Making links to \`external-lisp'."
132 # Don't distribute =*.el files.
133 (cd external-lisp
134 ln [a-zA-Z]*.el ../${tempdir}/external-lisp
135 ln [a-zA-Z]*.elc ../${tempdir}/external-lisp
136 ln ChangeLog README ../${tempdir}/external-lisp)
137
138 echo "Making links to \`src'."
139 # Don't distribute =*.[ch] files, or the configured versions of
140 # config.h.in, paths.h.in, or Makefile.in.
141 (cd src
142 ln [a-zA-Z]*.c ../${tempdir}/src
143 ln [a-zA-Z]*.h ../${tempdir}/src
144 ln [a-zA-Z]*.s ../${tempdir}/src
145 ln README Makefile.in ymakefile ChangeLog config.h.in paths.h.in \
146 ../${tempdir}/src
147 ln .gdbinit .dbxinit ../${tempdir}/src
148 ln *.com *.opt vms-pp.trans vmsbuild ../${tempdir}/src
149 cd ../${tempdir}/src
150 rm -f config.h paths.h Makefile
151 if [ -z "${newer}" ]; then
152 etags *.h *.c ../lisp/*.el
153 fi)
154
155 echo "Making links to \`src/m'."
156 (cd src/m
157 ln README [a-zA-Z].h ../../${tempdir}/src/m)
158
159 echo "Making links to \`src/s'."
160 (cd src/s
161 ln README [a-zA-Z].h ../../${tempdir}/src/s)
162
163 echo "Making links to \`lib-src'."
164 (cd lib-src
165 ln [a-zA-Z]*.[chy] [a-zA-Z]*.lex [a-zA-Z]*.com ../${tempdir}/lib-src
166 ln ChangeLog Makefile.in README testfile vcdiff rcs2log ../${tempdir}/lib-src
167 ln emacs.csh ../${tempdir}/lib-src
168 cd ../${tempdir}/lib-src
169 rm -f getdate.c getdate.tab.c y.tab.c y.tab.h)
170
171 echo "Making links to \`oldXMenu'."
172 (cd oldXMenu
173 ln *.c *.h ../${tempdir}/oldXMenu
174 ln README Makefile Imakefile ChangeLog ../${tempdir}/oldXMenu)
175
176 echo "Making links to \`etc'."
177 # Don't distribute DOC files, backups, autosaves, or tex litter.
178 (cd etc
179 ln [0-9a-zA-Z]* ../${tempdir}/etc
180 cd ../${tempdir}/etc
181 # Avoid an error when expanding the wildcards later.
182 for dummy in DOC-dummy dummy~ \#dummy\# dummy.dvi dummy.log; do
183 ln MACHINES ${dummy}
184 done
185 rm -f DOC* *~ \#*\# *.dvi *.log core)
186
187 # For now, we comment these out, since I'm not changing them any.
188 #!! echo "Making links to \`cpp'."
189 #!! (cd cpp
190 #!! ln cccp.c cexp.y Makefile README ../${tempdir}/cpp)
191 #!!
192 #!! echo "Making links to \`info'."
193 #!! # Don't distribute backups or autosaves.
194 #!! (cd info
195 #!! ln [a-zA-Z]* ../${tempdir}/info
196 #!! cd ../${tempdir}/info
197 #!! # Avoid an error when expanding the wildcards later.
198 #!! ln emacs dummy~ ; ln emacs \#dummy\#
199 #!! rm -f *~ \#*\# core)
200 #!!
201 #!! echo "Making links to \`man'."
202 #!! (cd man
203 #!! ln *.tex *.texinfo *.texi *.aux *.cps *.fns *.kys *.vrs ../${tempdir}/man
204 #!! ln *.c ../${tempdir}/man
205 #!! ln ChangeLog Makefile README split-man ../${tempdir}/man)
206
207 echo "Making links to \`shortnames'."
208 (cd shortnames
209 ln *.c ../${tempdir}/shortnames
210 ln Makefile reserved special ../${tempdir}/shortnames)
211
212 echo "Making links to \`vms'."
213 (cd vms
214 ln [0-9a-zA-Z]* ../${tempdir}/vms
215 cd ../${tempdir}/vms
216 rm -f *~)
217
218 echo "Making sure copying notices are all symlinks to \`etc/COPYING'."
219 rm -f ${tempdir}/etc/COPYING
220 cp etc/COPYING ${tempdir}/etc/COPYING
221 for subdir in lisp external-lisp src lib-src info shortnames; do
222 if [ -f ${tempdir}/${subdir}/COPYING ]; then
223 rm ${tempdir}/${subdir}/COPYING
224 fi
225 ln -s ../etc/COPYING ${tempdir}/${subdir}
226 done
227
228 if [ "${newer}" ]; then
229 echo "Removing files older than $newer."
230 # We remove .elc files unconditionally, on the theory that anyone picking
231 # up an incremental distribution already has a running Emacs to byte-compile
232 # them with.
233 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
234 fi
235
236 if [ "${make_tar}" = yes ]; then
237 echo "Creating tar file."
238 (cd ${tempparent}; tar cvf - ${emacsname}) | compress > ${emacsname}.tar.Z
239 fi
240
241 if [ "${clean_up}" = yes ]; then
242 echo "Cleaning up the staging directory."
243 rm -rf ${tempparent}
244 fi
245
246 # make-dist ends here