*** empty log message ***
[emacs.git] / make-dist
blobcbb2dce88f942d4965d71bdfae32a9f6353bf652
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 newer than the given timestamp file. This is useful
37 # for creating incremental or patch distributions
38 "--newer")
39 newer=$2
40 new=.new
41 shift
43 * )
44 echo "${progname}: Unrecognized argument: $1" >&2
45 exit 1
47 esac
48 shift
49 done
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
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]+\)\..*$/\1/'`
62 if [ ! "${version}" ]; then
63 echo "${progname}: can't find current emacs version in \`./lisp/version.el'." >&2
64 exit 1
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
78 echo "Creating staging directory: \`${tempparent}'"
79 mkdir ${tempparent}
80 emacsname="emacs-${version}${new}"
81 tempdir="${tempparent}/${emacsname}"
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
89 echo "Creating top directory: \`${tempdir}'"
90 mkdir ${tempdir}
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}
100 echo "Creating subdirectories."
101 for subdir in lisp lisp/term local-lisp external-lisp \
102 src src/m src/s lib-src oldXMenu \
103 etc lock arch-lib cpp info man shortnames; do
104 mkdir ${tempdir}/${subdir}
105 done
107 echo "Making links to \`lisp'."
108 # Don't distribute =*.el files, site-init.el, or site-load.el.
109 (cd lisp
110 ln [a-zA-Z]*.el ../${tempdir}/lisp
111 ln [a-zA-Z]*.elc ../${tempdir}/lisp
112 # simula.el doesn't keep abbreviations in simula.defns any more.
113 # ln [a-zA-Z]*.defns ../${tempdir}/lisp
114 ln ChangeLog README ../${tempdir}/lisp
115 cd ../${tempdir}/lisp
116 rm -f site-init site-init.el site-init.elc
117 rm -f site-load site-load.el site-load.elc)
119 echo "Making links to \`lisp/term'."
120 # Don't distribute =*.el files.
121 (cd lisp/term
122 ln [a-zA-Z]*.el ../../${tempdir}/lisp/term
123 ln [a-zA-Z]*.elc ../../${tempdir}/lisp/term
124 ln README ../../${tempdir}/lisp/term)
126 echo "Making links to \`external-lisp'."
127 # Don't distribute =*.el files.
128 (cd external-lisp
129 ln [a-zA-Z]*.el ../${tempdir}/external-lisp
130 ln [a-zA-Z]*.elc ../${tempdir}/external-lisp
131 ln ChangeLog README ../${tempdir}/external-lisp)
133 echo "Making links to \`src'."
134 # Don't distribute =*.[ch] files, or the configured versions of
135 # config.h.in, paths.h.in, or Makefile.in.
136 (cd src
137 ln [a-zA-Z]*.c ../${tempdir}/src
138 ln [a-zA-Z]*.h ../${tempdir}/src
139 ln [a-zA-Z]*.s ../${tempdir}/src
140 ln README Makefile.in ymakefile ChangeLog config.h.in paths.h.in \
141 ../${tempdir}/src
142 ln .gdbinit .dbxinit ../${tempdir}/src
143 ln *.com *.opt vms-pp.trans vmsbuild ../${tempdir}/src
144 cd ../${tempdir}/src
145 rm -f config.h paths.h Makefile)
147 echo "Making links to \`src/m'."
148 (cd src/m
149 ln README *.h ../../${tempdir}/src/m)
151 echo "Making links to \`src/s'."
152 (cd src/s
153 ln README *.h ../../${tempdir}/src/s)
155 echo "Making links to \`lib-src'."
156 (cd lib-src
157 ln [a-zA-Z]*.c [a-zA-Z]*.h [a-zA-Z]*.y [a-zA-Z]*.lex ../${tempdir}/lib-src
158 ln ChangeLog Makefile.in README testfile vcdiff rcs2log ../${tempdir}/lib-src
159 cd ../${tempdir}/lib-src
160 rm -f getdate.c getdate.tab.c y.tab.c y.tab.h)
162 echo "Making links to \`oldXMenu'."
163 (cd oldXMenu
164 ln *.c *.h ../${tempdir}/oldXMenu
165 ln README Makefile Imakefile ChangeLog ../${tempdir}/oldXMenu)
167 echo "Making links to \`etc'."
168 # Don't distribute TAGS, DOC files, backups, autosaves, or tex litter.
169 (cd etc
170 ln [0-9a-zA-Z]* ../${tempdir}/etc
171 cd ../${tempdir}/etc
172 # Avoid an error when expanding the wildcards later.
173 for dummy in DOC-dummy dummy~ \#dummy\# dummy.dvi dummy.log; do
174 ln MACHINES ${dummy}
175 done
176 rm -f TAGS DOC* *~ \#*\# *.dvi *.log core)
178 # For now, we comment these out, since I'm not changing them any.
179 #!! echo "Making links to \`cpp'."
180 #!! (cd cpp
181 #!! ln cccp.c cexp.y Makefile README ../${tempdir}/cpp)
182 #!!
183 #!! echo "Making links to \`info'."
184 #!! # Don't distribute backups or autosaves.
185 #!! (cd info
186 #!! ln [a-zA-Z]* ../${tempdir}/info
187 #!! cd ../${tempdir}/info
188 #!! # Avoid an error when expanding the wildcards later.
189 #!! ln emacs dummy~ ; ln emacs \#dummy\#
190 #!! rm -f *~ \#*\# core)
191 #!!
192 #!! echo "Making links to \`man'."
193 #!! (cd man
194 #!! ln *.tex *.texinfo *.texi *.aux *.cps *.fns *.kys *.vrs ../${tempdir}/man
195 #!! ln *.c ../${tempdir}/man
196 #!! ln ChangeLog Makefile README split-man ../${tempdir}/man)
198 echo "Making links to \`shortnames'."
199 (cd shortnames
200 ln *.c ../${tempdir}/shortnames
201 ln Makefile reserved special ../${tempdir}/shortnames)
203 echo "Making sure copying notices are all symlinks to \`etc/COPYING'."
204 rm -f ${tempdir}/etc/COPYING
205 cp etc/COPYING ${tempdir}/etc/COPYING
206 for subdir in lisp external-lisp src lib-src info shortnames; do
207 if [ -f ${tempdir}/${subdir}/COPYING ]; then
208 rm ${tempdir}/${subdir}/COPYING
210 ln -s ../etc/COPYING ${tempdir}/${subdir}
211 done
213 if [ "${newer}" ]; then
214 echo "Removing files older than $newer."
215 # We remove .elc files unconditionally, on the theory that anyone picking
216 # up an incremental distribution already has a running Emacs to byte-compile
217 # them with.
218 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
221 if [ "${make_tar}" = yes ]; then
222 echo "Creating tar file."
223 (cd ${tempparent}; tar cvf - ${emacsname}) | compress > ${emacsname}.tar.Z
226 if [ "${clean_up}" = yes ]; then
227 echo "Cleaning up the staging directory."
228 rm -rf ${tempparent}
231 # make-dist ends here