[HAVE_NTGUI]: Declare Vwindow_system.
[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 8
4c9c1174
KH
9# Copyright (C) 1995 Free Software Foundation, Inc.
10#
11# This file is part of GNU Emacs.
12#
13# GNU Emacs is free software; you can redistribute it and/or modify
14# it under the terms of the GNU General Public License as published by
15# the Free Software Foundation; either version 2, or (at your option)
16# any later version.
17#
18# GNU Emacs is distributed in the hope that it will be useful,
19# but WITHOUT ANY WARRANTY; without even the implied warranty of
20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21# GNU General Public License for more details.
22#
23# You should have received a copy of the GNU General Public License
24# along with GNU Emacs; see the file COPYING. If not, write to
25# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26
f7dbcf3c
JB
27progname="$0"
28
76fb0a58
JB
29### Exit if a command fails.
30### set -e
f7dbcf3c 31
76fb0a58
JB
32### Print out each line we read, for debugging's sake.
33### set -v
f7dbcf3c 34
4746118a
JB
35clean_up=yes
36make_tar=yes
1260d6ba 37newer=""
f7dbcf3c
JB
38
39while [ $# -gt 0 ]; do
40 case "$1" in
76fb0a58
JB
41 ## This option tells make-dist not to delete the staging directory
42 ## after it's done making the tar file.
1260d6ba 43 "--no-clean-up" )
4746118a
JB
44 clean_up=no
45 ;;
76fb0a58
JB
46 ## This option tells make-dist not to make a tar file. Since it's
47 ## rather pointless to build the whole staging directory and then
48 ## nuke it, using this option also selects '--no-clean-up'.
4746118a
JB
49 "--no-tar" )
50 make_tar=no
51 clean_up=no
f7dbcf3c 52 ;;
76fb0a58 53 ## This option tells make-dist to make the distribution normally, then
7b9cd64c
ER
54 ## remove all files older than the given timestamp file. This is useful
55 ## for creating incremental or patch distributions.
1260d6ba 56 "--newer")
ef15f270
JB
57 newer="$2"
58 new_extension=".new"
1260d6ba
ER
59 shift
60 ;;
922ac4c5
JB
61 ## This option tells make-dist to use `compress' instead of gzip.
62 ## Normally, make-dist uses gzip whenever it is present.
63 "--compress")
64 default_gzip="compress"
65 ;;
f7dbcf3c
JB
66 * )
67 echo "${progname}: Unrecognized argument: $1" >&2
68 exit 1
69 ;;
70 esac
71 shift
72done
73
76fb0a58 74### Make sure we're running in the right place.
f7dbcf3c 75if [ ! -d src -o ! -f src/lisp.h -o ! -d lisp -o ! -f lisp/version.el ]; then
1260d6ba
ER
76 echo "${progname}: Can't find \`src/lisp.h' and \`lisp/version.el'." >&2
77 echo "${progname} must be run in the top directory of the Emacs" >&2
0d122844 78 echo "distribution tree. cd to that directory and try again." >&2
f7dbcf3c
JB
79 exit 1
80fi
81
76fb0a58 82### Find out which version of Emacs this is.
0e0186f1 83shortversion=`grep 'defconst[ ]*emacs-version' lisp/version.el \
47d105b0 84 | sed -e 's/^.*"\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/'`
0e0186f1
RS
85version=`grep 'defconst[ ]*emacs-version' lisp/version.el \
86 | sed -e 's/^[^"]*"\([^"]*\)".*$/\1/'`
f7dbcf3c 87if [ ! "${version}" ]; then
0e0186f1 88 echo "${progname}: can't find current Emacs version in \`./lisp/version.el'." >&2
f7dbcf3c
JB
89 exit 1
90fi
91
47d105b0
RS
92echo $version and $shortversion
93
0e0186f1 94if grep -s "GNU Emacs version ${shortversion}" ./man/emacs.texi > /dev/null; then
f753e9aa
JB
95 true
96else
97 echo "You must update the version number in \`./man/emacs.texi'"
7b7a9d23 98 sleep 5
f753e9aa
JB
99fi
100
bb160193
RS
101### Make sure we don't already have a directory emacs-${version}.
102
103emacsname="emacs-${version}${new_extension}"
104
105if [ -d ${emacsname} ]
106then
107 echo Directory "${emacsname}" already exists >&2
108 exit 1
109fi
110
76fb0a58 111### Make sure the subdirectory is available.
1260d6ba 112tempparent="make-dist.tmp.$$"
f7dbcf3c 113if [ -d ${tempparent} ]; then
1260d6ba
ER
114 echo "${progname}: staging directory \`${tempparent}' already exists.
115Perhaps a previous invocation of \`${progname}' failed to clean up after
116itself. Check that directories whose names are of the form
117\`make-dist.tmp.NNNNN' don't contain any important information, remove
118them, and try again." >&2
f7dbcf3c
JB
119 exit 1
120fi
121
9f7602fd
JB
122### Check for .elc files with no corresponding .el file.
123ls -1 lisp/*.el | sed 's/\.el$/.elc/' > /tmp/el
124ls -1 lisp/*.elc > /tmp/elc
254e10d8
JB
125bogosities="`comm -13 /tmp/el /tmp/elc`"
126if [ "${bogosities}" != "" ]; then
127 echo "The following .elc files have no corresponding .el files:"
128 echo "${bogosities}"
129fi
8f731fcc 130rm -f /tmp/el /tmp/elc
9f7602fd 131
b4e84d5d
JB
132### Make sure configure is newer than configure.in.
133if [ "x`ls -t configure configure.in | head -1`" != "xconfigure" ]; then
863f1210 134 echo "\`./configure.in' seems to be newer than \`./configure.'" >&2
b4e84d5d
JB
135 echo "Attempting to run autoconf." >&2
136 autoconf
137fi
138
2ed56345 139### Update getdate.c.
0e0186f1 140(cd lib-src; make -f Makefile getdate.c YACC="bison -y")
2ed56345 141
980ab937
RS
142echo "Updating Info files."
143
144(cd man; make info)
145
0588a761
RS
146echo "Updating finder-inf.el."
147
148### update finder-inf.el.
419e4198
RS
149(cd lisp; ../src/emacs -batch -l finder -f finder-compile-keywords)
150(cd lisp; ../src/emacs -batch -f batch-byte-compile finder-inf.el)
0588a761 151
f07eebe0
KH
152echo "Making lisp/MANIFEST"
153
154(cd lisp; head -1 *.el | grep '^;' | sed -e 's/;;; //' > MANIFEST)
155
1260d6ba 156echo "Creating staging directory: \`${tempparent}'"
bb160193 157
f7dbcf3c 158mkdir ${tempparent}
f7dbcf3c
JB
159tempdir="${tempparent}/${emacsname}"
160
76fb0a58
JB
161### This trap ensures that the staging directory will be cleaned up even
162### when the script is interrupted in mid-career.
00c00348
ER
163if [ "${clean_up}" = yes ]; then
164 trap "echo 'Interrupted...cleaning up the staging directory.'; rm -rf ${tempparent}; exit 1" 1 2 15
165fi
166
1260d6ba 167echo "Creating top directory: \`${tempdir}'"
f7dbcf3c
JB
168mkdir ${tempdir}
169
76fb0a58
JB
170### We copy in the top-level files before creating the subdirectories in
171### hopes that this will make the top-level files appear first in the
172### tar file; this means that people can start reading the INSTALL and
173### README while the rest of the tar file is still unpacking. Whoopee.
1260d6ba 174echo "Making links to top-level files."
525336b7 175ln GETTING.GNU.SOFTWARE INSTALL PROBLEMS README BUGS move-if-change ${tempdir}
ac4eff2d 176ln ChangeLog Makefile.in configure configure.in ${tempdir}
6f8b09f3 177ln config.bat make-dist update-subdirs vpath.sed ${tempdir}
bb160193 178### Copy these files; they're cross-filesystem symlinks.
a4888c88 179cp mkinstalldirs ${tempdir}
76fb0a58 180cp config.sub ${tempdir}
2ed56345 181cp config.guess ${tempdir}
bb160193 182cp install.sh ${tempdir}
f7dbcf3c 183
f753e9aa
JB
184echo "Updating version number in README."
185(cd ${tempdir}
186 awk \
187 '$1 " " $2 " " $3 " " $4 " " $5 == "This directory tree holds version" { $6 = version; print $0 }
188 $1 " " $2 " " $3 " " $4 " " $5 != "This directory tree holds version"' \
189 version=${version} README > tmp.README
190 mv tmp.README README)
191
192
f7dbcf3c 193echo "Creating subdirectories."
82a82d48 194for subdir in lisp lisp/term site-lisp \
c660c0a7 195 src src/m src/s src/bitmaps lib-src oldXMenu lwlib \
77427171 196 nt nt/inc nt/inc/sys \
8e583b5d 197 etc etc/e lock cpp info man msdos vms; do
f7dbcf3c
JB
198 mkdir ${tempdir}/${subdir}
199done
200
1260d6ba 201echo "Making links to \`lisp'."
7b9cd64c 202### Don't distribute TAGS, =*.el files, site-init.el, site-load.el, or default.el.
f7dbcf3c
JB
203(cd lisp
204 ln [a-zA-Z]*.el ../${tempdir}/lisp
205 ln [a-zA-Z]*.elc ../${tempdir}/lisp
8d2197ac 206 ln [a-zA-Z]*.dat ../${tempdir}/lisp
76fb0a58
JB
207 ## simula.el doesn't keep abbreviations in simula.defns any more.
208 ## ln [a-zA-Z]*.defns ../${tempdir}/lisp
391b3748 209 ln ChangeLog Makefile makefile.nt ChangeLog.? README dired.todo ../${tempdir}/lisp
f7dbcf3c 210 cd ../${tempdir}/lisp
7b9cd64c 211 rm -f TAGS =*
f7dbcf3c 212 rm -f site-init site-init.el site-init.elc
ef15f270
JB
213 rm -f site-load site-load.el site-load.elc
214 rm -f default default.el default.elc)
f7dbcf3c 215
56c31c87
RS
216#echo "Making links to \`lisp/calc-2.02'."
217#### Don't distribute =*.el files, TAGS or backups.
218#(cd lisp/calc-2.02
219# ln [a-zA-Z]*.el ../../${tempdir}/lisp/calc-2.02
220# ln [a-zA-Z]*.elc ../../${tempdir}/lisp/calc-2.02
221# ln calc.info* calc.texinfo calc-refcard.* ../../${tempdir}/lisp/calc-2.02
222# ln INSTALL Makefile README README.prev ../../${tempdir}/lisp/calc-2.02
223# cd ../../${tempdir}/lisp/calc-2.02
224# rm -f *~ TAGS)
fda4e8f6 225
1260d6ba 226echo "Making links to \`lisp/term'."
7b9cd64c 227### Don't distribute =*.el files or TAGS.
f7dbcf3c
JB
228(cd lisp/term
229 ln [a-zA-Z]*.el ../../${tempdir}/lisp/term
230 ln [a-zA-Z]*.elc ../../${tempdir}/lisp/term
3e1fc5a7 231 ln README ../../${tempdir}/lisp/term
7b9cd64c 232 rm -f =* TAGS)
f7dbcf3c 233
1260d6ba 234echo "Making links to \`src'."
76fb0a58 235### Don't distribute =*.[ch] files, or the configured versions of
c3f1e1a9 236### config.in, paths.in, or Makefile.in, or TAGS.
f7dbcf3c 237(cd src
76fb0a58 238 echo " (If we can't link gmalloc.c, that's okay.)"
f7dbcf3c 239 ln [a-zA-Z]*.c ../${tempdir}/src
76fb0a58 240 ## Might be a symlink to a file on another filesystem.
39d6eb8e 241 test -f ../${tempdir}/src/gmalloc.c || cp gmalloc.c ../${tempdir}/src
f7dbcf3c
JB
242 ln [a-zA-Z]*.h ../${tempdir}/src
243 ln [a-zA-Z]*.s ../${tempdir}/src
c3f1e1a9 244 ln README Makefile.in ChangeLog ChangeLog.? config.in paths.in \
f7dbcf3c 245 ../${tempdir}/src
7355fc33 246 ln makefile.nt ../${tempdir}/src
990ee059 247 ln .gdbinit .dbxinit ../${tempdir}/src
6f95b621 248 ln *.opt vms-pp.trans ../${tempdir}/src
f7dbcf3c 249 cd ../${tempdir}/src
a6903f09 250 rm -f config.h paths.h Makefile Makefile.c
7b9cd64c 251 rm -f =* TAGS)
f7dbcf3c 252
690eca32
JB
253echo "Making links to \`src/bitmaps'."
254(cd src/bitmaps
255 ln README *.xbm ../../${tempdir}/src/bitmaps)
256
1260d6ba 257echo "Making links to \`src/m'."
f7dbcf3c 258(cd src/m
facbb78e
RS
259 # We call files for miscellaneous input (to linker etc) .inp.
260 ln README [a-zA-Z0-9]*.h *.inp ../../${tempdir}/src/m)
f7dbcf3c 261
1260d6ba 262echo "Making links to \`src/s'."
f7dbcf3c 263(cd src/s
77427171 264 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/s)
f7dbcf3c 265
1260d6ba 266echo "Making links to \`lib-src'."
f7dbcf3c 267(cd lib-src
375f1bd7 268 ln [a-zA-Z]*.[chy] ../${tempdir}/lib-src
c3f1e1a9 269 ln ChangeLog Makefile.in README testfile vcdiff ../${tempdir}/lib-src
391b3748 270 ln emacs.csh rcs2log rcs-checkin makefile.nt ../${tempdir}/lib-src
1260d6ba 271 cd ../${tempdir}/lib-src
a6903f09 272 rm -f getdate.tab.c y.tab.c y.tab.h Makefile.c
7b9cd64c 273 rm -f =* TAGS)
f7dbcf3c 274
391b3748
RS
275echo "Making links to \`nt'."
276(cd nt
f3f59e86 277 ln emacs.ico emacs.rc config.nt config.w95 [a-z]*.in [a-z]*.c ../${tempdir}/nt
b47cc08a
RS
278 ln [a-z]*.bat [a-z]*.h makefile.def makefile.nt ../${tempdir}/nt
279 ln todo ChangeLog install readme ../${tempdir}/nt)
391b3748
RS
280
281echo "Making links to \`nt/inc'."
282(cd nt/inc
77427171 283 ln [a-z]*.h ../../${tempdir}/nt/inc)
391b3748
RS
284
285echo "Making links to \`nt/inc/sys'."
286(cd nt/inc/sys
77427171 287 ln [a-z]*.h ../../../${tempdir}/nt/inc/sys)
391b3748 288
52d7b2e5
RS
289echo "Making links to \`msdos'."
290(cd msdos
291 ln ChangeLog emacs.ico emacs.pif ../${tempdir}/msdos
6f8b09f3 292 ln mainmake sed*.inp ../${tempdir}/msdos
52d7b2e5
RS
293 cd ../${tempdir}/msdos
294 rm -f =*)
295
1260d6ba 296echo "Making links to \`oldXMenu'."
f7dbcf3c 297(cd oldXMenu
8bdbf9ed 298 ln *.c *.h *.in ../${tempdir}/oldXMenu
df1ec566 299 ln README Imakefile ChangeLog ../${tempdir}/oldXMenu
f395c83a 300 ln compile.com descrip.mms ../${tempdir}/oldXMenu)
f7dbcf3c 301
c660c0a7
RS
302echo "Making links to \`lwlib'."
303(cd lwlib
304 ln *.c *.h *.in ../${tempdir}/lwlib
305 ln README Imakefile ChangeLog ../${tempdir}/lwlib)
306
1260d6ba 307echo "Making links to \`etc'."
f395c83a
JB
308### Don't distribute = files, TAGS, DOC files, backups, autosaves, or
309### tex litter.
f7dbcf3c 310(cd etc
375f1bd7 311 ln `ls -d * | grep -v 'RCS' | grep -v 'Old' | grep -v '^e$'` ../${tempdir}/etc
f7dbcf3c 312 cd ../${tempdir}/etc
f395c83a
JB
313 rm -f DOC* *~ \#*\# *.dvi *.log *,v =* core
314 rm -f TAGS)
f7dbcf3c 315
f08ad882
RS
316echo "Making links to \`etc/e'."
317(cd etc/e
375f1bd7 318 ln `ls -d * | grep -v 'RCS'` ../../${tempdir}/etc/e
a6903f09 319 cd ../../${tempdir}/etc/e
375f1bd7 320 rm -f *~ \#*\# *,v =* core)
f08ad882 321
fda4e8f6
JB
322echo "Making links to \`cpp'."
323(cd cpp
324 ln cccp.c cexp.y Makefile README ../${tempdir}/cpp)
325
66afa119
RS
326echo "Making links to \`info'."
327# Don't distribute backups or autosaves.
328(cd info
329 ln [a-zA-Z]* ../${tempdir}/info
330 cd ../${tempdir}/info
331 # Avoid an error when expanding the wildcards later.
332 ln emacs dummy~ ; ln emacs \#dummy\#
333 rm -f *~ \#*\# core)
fda4e8f6
JB
334
335echo "Making links to \`man'."
336(cd man
298c8970 337 ln *.texi *.aux *.cps *.fns *.kys *.vrs ../${tempdir}/man
5e808bc0 338 test -f README && ln README ../${tempdir}/man
f08ad882 339 test -f Makefile.in && ln Makefile.in ../${tempdir}/man
56c31c87 340 ln ChangeLog split-man ../${tempdir}/man
375f1bd7 341 cp texinfo.tex ../${tempdir}/man
4f8cc93a 342 cd ../${tempdir}/man
56c31c87
RS
343 rm -f \#*\# =* *~ core emacs-index* *.Z *.z xmail
344 rm -f emacs.?? termcap.?? gdb.?? *.log *.toc *.dvi *.oaux)
f7dbcf3c 345
40eef465
JB
346echo "Making links to \`vms'."
347(cd vms
348 ln [0-9a-zA-Z]* ../${tempdir}/vms
349 cd ../${tempdir}/vms
350 rm -f *~)
351
c87b230f
JB
352### It would be nice if they could all be symlinks to etc's copy, but
353### you're not supposed to have any symlinks in distribution tar files.
354echo "Making sure copying notices are all copies of \`etc/COPYING'."
1260d6ba
ER
355rm -f ${tempdir}/etc/COPYING
356cp etc/COPYING ${tempdir}/etc/COPYING
8e583b5d 357for subdir in lisp src lib-src info msdos; do
f7dbcf3c
JB
358 if [ -f ${tempdir}/${subdir}/COPYING ]; then
359 rm ${tempdir}/${subdir}/COPYING
360 fi
96858c42 361 cp etc/COPYING ${tempdir}/${subdir}
f7dbcf3c
JB
362done
363
5b8def65
JB
364#### Make sure that there aren't any hard links between files in the
365#### distribution; people with afs can't deal with that. Okay,
366#### actually we just re-copy anything with a link count greater
375f1bd7
KH
367#### than two. (Yes, strictly greater than 2 is correct; since we
368#### created these files by linking them in from the original tree,
369#### they'll have exactly two links normally.)
bb7e0f81
KH
370####
371#### Commented out since it's not stricly necessary; it should suffice
372#### to just break the link on alloca.c.
9b23a6c7
RS
373#echo "Breaking intra-tree links."
374#find ${tempdir} ! -type d -links +2 \
375# -exec cp -p {} $$ \; -exec rm -f {} \; -exec mv $$ {} \;
bb7e0f81
KH
376rm -f $tempdir/lib-src/alloca.c
377cp $tempdir/src/alloca.c $tempdir/lib-src/alloca.c
5b8def65 378
1260d6ba
ER
379if [ "${newer}" ]; then
380 echo "Removing files older than $newer."
76fb0a58
JB
381 ## We remove .elc files unconditionally, on the theory that anyone picking
382 ## up an incremental distribution already has a running Emacs to byte-compile
383 ## them with.
1260d6ba
ER
384 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
385fi
386
4746118a 387if [ "${make_tar}" = yes ]; then
922ac4c5
JB
388 if [ "${default_gzip}" = "" ]; then
389 echo "Looking for gzip."
390 temppath=`echo $PATH | sed 's/^:/.:/
391 s/::/:.:/g
392 s/:$/:./
393 s/:/ /g'`
394 default_gzip=`(
395 for dir in ${temppath}; do
396 if [ -f ${dir}/gzip ]; then echo 'gzip --best'; exit 0; fi
397 done
398 echo compress
399 )`
400 fi
f395c83a
JB
401 case "${default_gzip}" in
402 compress* ) gzip_extension=.Z ;;
0dc610dd 403 * ) gzip_extension=.gz ;;
f395c83a 404 esac
4746118a 405 echo "Creating tar file."
f395c83a
JB
406 (cd ${tempparent} ; tar cvf - ${emacsname} ) \
407 | ${default_gzip} \
408 > ${emacsname}.tar${gzip_extension}
4746118a 409fi
f7dbcf3c 410
4746118a 411if [ "${clean_up}" = yes ]; then
f7dbcf3c 412 echo "Cleaning up the staging directory."
f395c83a 413 rm -rf ${tempparent}
bb160193
RS
414else
415 (cd ${tempparent}; mv ${emacsname} ..)
416 rm -rf ${tempparent}
f7dbcf3c 417fi
00c00348 418
76fb0a58 419### make-dist ends here