*** empty log message ***
[bpt/emacs.git] / make-dist
CommitLineData
f7dbcf3c
JB
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
9progname="$0"
10
11# Exit if a command fails.
00c00348 12# set -e
f7dbcf3c
JB
13
14# Print out each line we read, for debugging's sake.
15# set -v
16
4746118a
JB
17clean_up=yes
18make_tar=yes
1260d6ba 19newer=""
f7dbcf3c
JB
20
21while [ $# -gt 0 ]; do
22 case "$1" in
1260d6ba
ER
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" )
4746118a
JB
26 clean_up=no
27 ;;
1260d6ba
ER
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 ;;
1260d6ba
ER
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")
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
51# Make sure we're running in the right place.
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
59# Find out which version of Emacs this is.
60version=`grep 'defconst[ ]*emacs-version' lisp/version.el \
61 | sed -e 's/^.*"\([0-9]+\.[0-9]+\)\..*$/\1/'`
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
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
00c00348
ER
83# This trap ensures that the staging directory will be cleaned up even
84# when the script is interrupted in mid-career.
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
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
4746118a
JB
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}
f7dbcf3c
JB
98ln ChangeLog Makefile.in build-install.in configure make-dist ${tempdir}
99
100echo "Creating subdirectories."
1260d6ba
ER
101for 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
f7dbcf3c
JB
104 mkdir ${tempdir}/${subdir}
105done
106
1260d6ba 107echo "Making links to \`lisp'."
ef15f270 108# Don't distribute =*.el files, site-init.el, site-load.el, or default.el.
f7dbcf3c
JB
109(cd lisp
110 ln [a-zA-Z]*.el ../${tempdir}/lisp
111 ln [a-zA-Z]*.elc ../${tempdir}/lisp
1260d6ba
ER
112 # simula.el doesn't keep abbreviations in simula.defns any more.
113 # ln [a-zA-Z]*.defns ../${tempdir}/lisp
f7dbcf3c
JB
114 ln ChangeLog README ../${tempdir}/lisp
115 cd ../${tempdir}/lisp
116 rm -f site-init site-init.el site-init.elc
ef15f270
JB
117 rm -f site-load site-load.el site-load.elc
118 rm -f default default.el default.elc)
f7dbcf3c 119
1260d6ba 120echo "Making links to \`lisp/term'."
f7dbcf3c
JB
121# Don't distribute =*.el files.
122(cd lisp/term
123 ln [a-zA-Z]*.el ../../${tempdir}/lisp/term
124 ln [a-zA-Z]*.elc ../../${tempdir}/lisp/term
125 ln README ../../${tempdir}/lisp/term)
126
1260d6ba
ER
127echo "Making links to \`external-lisp'."
128# Don't distribute =*.el files.
129(cd external-lisp
130 ln [a-zA-Z]*.el ../${tempdir}/external-lisp
131 ln [a-zA-Z]*.elc ../${tempdir}/external-lisp
132 ln ChangeLog README ../${tempdir}/external-lisp)
133
134echo "Making links to \`src'."
f7dbcf3c
JB
135# Don't distribute =*.[ch] files, or the configured versions of
136# config.h.in, paths.h.in, or Makefile.in.
137(cd src
138 ln [a-zA-Z]*.c ../${tempdir}/src
139 ln [a-zA-Z]*.h ../${tempdir}/src
140 ln [a-zA-Z]*.s ../${tempdir}/src
141 ln README Makefile.in ymakefile ChangeLog config.h.in paths.h.in \
142 ../${tempdir}/src
143 ln .gdbinit .dbxinit ../${tempdir}/src
144 ln *.com *.opt vms-pp.trans vmsbuild ../${tempdir}/src
145 cd ../${tempdir}/src
ef15f270
JB
146 rm -f config.h paths.h Makefile
147 if [ -z "${newer}" ]; then
148 etags *.h *.c ../lisp/*.el
149 fi)
f7dbcf3c 150
1260d6ba 151echo "Making links to \`src/m'."
f7dbcf3c
JB
152(cd src/m
153 ln README *.h ../../${tempdir}/src/m)
154
1260d6ba 155echo "Making links to \`src/s'."
f7dbcf3c
JB
156(cd src/s
157 ln README *.h ../../${tempdir}/src/s)
158
1260d6ba 159echo "Making links to \`lib-src'."
f7dbcf3c
JB
160(cd lib-src
161 ln [a-zA-Z]*.c [a-zA-Z]*.h [a-zA-Z]*.y [a-zA-Z]*.lex ../${tempdir}/lib-src
1260d6ba
ER
162 ln ChangeLog Makefile.in README testfile vcdiff rcs2log ../${tempdir}/lib-src
163 cd ../${tempdir}/lib-src
164 rm -f getdate.c getdate.tab.c y.tab.c y.tab.h)
f7dbcf3c 165
1260d6ba 166echo "Making links to \`oldXMenu'."
f7dbcf3c
JB
167(cd oldXMenu
168 ln *.c *.h ../${tempdir}/oldXMenu
169 ln README Makefile Imakefile ChangeLog ../${tempdir}/oldXMenu)
170
1260d6ba 171echo "Making links to \`etc'."
ef15f270 172# Don't distribute DOC files, backups, autosaves, or tex litter.
f7dbcf3c
JB
173(cd etc
174 ln [0-9a-zA-Z]* ../${tempdir}/etc
175 cd ../${tempdir}/etc
176 # Avoid an error when expanding the wildcards later.
177 for dummy in DOC-dummy dummy~ \#dummy\# dummy.dvi dummy.log; do
178 ln MACHINES ${dummy}
179 done
ef15f270 180 rm -f DOC* *~ \#*\# *.dvi *.log core)
f7dbcf3c
JB
181
182# For now, we comment these out, since I'm not changing them any.
1260d6ba 183#!! echo "Making links to \`cpp'."
f7dbcf3c
JB
184#!! (cd cpp
185#!! ln cccp.c cexp.y Makefile README ../${tempdir}/cpp)
186#!!
1260d6ba 187#!! echo "Making links to \`info'."
f7dbcf3c
JB
188#!! # Don't distribute backups or autosaves.
189#!! (cd info
190#!! ln [a-zA-Z]* ../${tempdir}/info
191#!! cd ../${tempdir}/info
192#!! # Avoid an error when expanding the wildcards later.
193#!! ln emacs dummy~ ; ln emacs \#dummy\#
194#!! rm -f *~ \#*\# core)
195#!!
1260d6ba 196#!! echo "Making links to \`man'."
f7dbcf3c
JB
197#!! (cd man
198#!! ln *.tex *.texinfo *.texi *.aux *.cps *.fns *.kys *.vrs ../${tempdir}/man
199#!! ln *.c ../${tempdir}/man
200#!! ln ChangeLog Makefile README split-man ../${tempdir}/man)
201
1260d6ba 202echo "Making links to \`shortnames'."
f7dbcf3c
JB
203(cd shortnames
204 ln *.c ../${tempdir}/shortnames
205 ln Makefile reserved special ../${tempdir}/shortnames)
206
1260d6ba
ER
207echo "Making sure copying notices are all symlinks to \`etc/COPYING'."
208rm -f ${tempdir}/etc/COPYING
209cp etc/COPYING ${tempdir}/etc/COPYING
210for subdir in lisp external-lisp src lib-src info shortnames; do
f7dbcf3c
JB
211 if [ -f ${tempdir}/${subdir}/COPYING ]; then
212 rm ${tempdir}/${subdir}/COPYING
213 fi
214 ln -s ../etc/COPYING ${tempdir}/${subdir}
215done
216
1260d6ba
ER
217if [ "${newer}" ]; then
218 echo "Removing files older than $newer."
219 # We remove .elc files unconditionally, on the theory that anyone picking
220 # up an incremental distribution already has a running Emacs to byte-compile
221 # them with.
222 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
223fi
224
4746118a
JB
225if [ "${make_tar}" = yes ]; then
226 echo "Creating tar file."
227 (cd ${tempparent}; tar cvf - ${emacsname}) | compress > ${emacsname}.tar.Z
228fi
f7dbcf3c 229
4746118a 230if [ "${clean_up}" = yes ]; then
f7dbcf3c
JB
231 echo "Cleaning up the staging directory."
232 rm -rf ${tempparent}
233fi
00c00348
ER
234
235# make-dist ends here