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