(parse_str_to_multibyte): Extern it.
[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
5eea385d 9# Copyright (C) 1995, 1997, 1998, 2000 Free Software Foundation, Inc.
4c9c1174
KH
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
1fb87c77
KH
24# along with GNU Emacs; see the file COPYING. If not, write to the
25# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26# Boston, MA 02111-1307, USA.
4c9c1174 27
f7dbcf3c
JB
28progname="$0"
29
76fb0a58 30### Exit if a command fails.
8c28d444 31#set -e
f7dbcf3c 32
76fb0a58 33### Print out each line we read, for debugging's sake.
8c28d444 34#set -v
f7dbcf3c 35
ccd57f4d 36## Don't restrict access to any files.
67ffab69
RS
37umask 0
38
c75cfabd 39update=yes
e4e1c623 40check=yes
f22edcea
RS
41clean_up=no
42make_tar=no
1260d6ba 43newer=""
f7dbcf3c
JB
44
45while [ $# -gt 0 ]; do
46 case "$1" in
f22edcea
RS
47 ## This option tells make-dist to delete the staging directory
48 ## when done. It is useless to use this unless you make a tar file.
49 "--clean-up" )
50 clean_up=yes
4746118a 51 ;;
f22edcea
RS
52 ## This option tells make-dist to make a tar file.
53 "--tar" )
54 make_tar=yes
f7dbcf3c 55 ;;
c75cfabd
RS
56 ## This option tells make-dist not to recompile or do analogous things.
57 "--no-update" )
58 update=no
59 ;;
e4e1c623
RS
60 ## This option says don't check for bad file names, etc.
61 "--no-check" )
62 check=no
63 ;;
76fb0a58 64 ## This option tells make-dist to make the distribution normally, then
7b9cd64c
ER
65 ## remove all files older than the given timestamp file. This is useful
66 ## for creating incremental or patch distributions.
1260d6ba 67 "--newer")
ef15f270
JB
68 newer="$2"
69 new_extension=".new"
1260d6ba
ER
70 shift
71 ;;
922ac4c5
JB
72 ## This option tells make-dist to use `compress' instead of gzip.
73 ## Normally, make-dist uses gzip whenever it is present.
74 "--compress")
75 default_gzip="compress"
76 ;;
2a714d4e
GM
77
78 "--snapshot")
79 clean_up=yes
80 make_tar=yes
81 update=no
82 check=no
83 ;;
84
85 "--help")
86 echo "Usage: ${progname} [options]"
87 echo ""
88 echo " --clean-up delete staging directories when done"
89 echo " --compress use compress instead of gzip"
90 echo " --newer=TIME don't include files older than TIME"
91 echo " --no-check don't check for bad file names etc."
92 echo " --no-update don't recompile or do analogous things"
93 echo " --snapshot same as --clean-up --no-update --tar --no-check"
94 echo " --tar make a tar file"
95 echo ""
96 exit 0
97 ;;
98
f7dbcf3c
JB
99 * )
100 echo "${progname}: Unrecognized argument: $1" >&2
101 exit 1
102 ;;
103 esac
104 shift
105done
106
76fb0a58 107### Make sure we're running in the right place.
f7dbcf3c 108if [ ! -d src -o ! -f src/lisp.h -o ! -d lisp -o ! -f lisp/version.el ]; then
1260d6ba
ER
109 echo "${progname}: Can't find \`src/lisp.h' and \`lisp/version.el'." >&2
110 echo "${progname} must be run in the top directory of the Emacs" >&2
0d122844 111 echo "distribution tree. cd to that directory and try again." >&2
f7dbcf3c
JB
112 exit 1
113fi
114
c75cfabd 115### Find where to run Emacs.
fcea5346
KH
116### (We don't accept EMACS=t as an answer, since that probably only means
117### that the shell is running in an Emacs window.)
c75cfabd
RS
118if [ $update = yes ];
119then
59d05d2d 120 unset EMACS_UNIBYTE
c75cfabd
RS
121 if [ -f src/emacs ];
122 then
123 EMACS=`pwd`/src/emacs
124 else
fcea5346 125 if [ "x$EMACS" = "x" -o "x$EMACS" = "xt" ];
c75cfabd
RS
126 then
127 echo You must specify the EMACS environment variable 2>&1
128 exit 1
129 fi
130 fi
131fi
132
76fb0a58 133### Find out which version of Emacs this is.
0e0186f1 134shortversion=`grep 'defconst[ ]*emacs-version' lisp/version.el \
47d105b0 135 | sed -e 's/^.*"\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/'`
0e0186f1
RS
136version=`grep 'defconst[ ]*emacs-version' lisp/version.el \
137 | sed -e 's/^[^"]*"\([^"]*\)".*$/\1/'`
f7dbcf3c 138if [ ! "${version}" ]; then
21764d60 139 echo "${progname}: can't find current Emacs version in \`./lisp/version.el'" >&2
f7dbcf3c
JB
140 exit 1
141fi
142
21764d60 143echo Version numbers are $version and $shortversion
47d105b0 144
c75cfabd
RS
145if [ $update = yes ];
146then
147 if grep -s "GNU Emacs version ${shortversion}" ./man/emacs.texi > /dev/null; then
148 true
149 else
150 echo "You must update the version number in \`./man/emacs.texi'"
151 sleep 5
152 fi
f753e9aa
JB
153fi
154
bb160193
RS
155### Make sure we don't already have a directory emacs-${version}.
156
157emacsname="emacs-${version}${new_extension}"
158
159if [ -d ${emacsname} ]
160then
161 echo Directory "${emacsname}" already exists >&2
162 exit 1
163fi
164
76fb0a58 165### Make sure the subdirectory is available.
1260d6ba 166tempparent="make-dist.tmp.$$"
f7dbcf3c 167if [ -d ${tempparent} ]; then
1260d6ba
ER
168 echo "${progname}: staging directory \`${tempparent}' already exists.
169Perhaps a previous invocation of \`${progname}' failed to clean up after
170itself. Check that directories whose names are of the form
171\`make-dist.tmp.NNNNN' don't contain any important information, remove
172them, and try again." >&2
f7dbcf3c
JB
173 exit 1
174fi
175
e4e1c623
RS
176### Find where to run Emacs.
177if [ $check = yes ];
178then
179 ### Check for .elc files with no corresponding .el file.
180 ls -1 lisp/[a-z]*.el lisp/[a-z]*/[a-z]*.el \
5eea385d 181 leim/[a-z]*/[a-z]*.el | sed 's/\.el$/.elc/' > /tmp/el
e4e1c623 182 ls -1 lisp/[a-z]*.elc lisp/[a-z]*/[a-z]*.elc \
5eea385d 183 leim/[a-z]*/[a-z]*.elc > /tmp/elc
e4e1c623
RS
184 bogosities="`comm -13 /tmp/el /tmp/elc`"
185 if [ "${bogosities}" != "" ]; then
186 echo "The following .elc files have no corresponding .el files:"
187 echo "${bogosities}"
8615e792 188 fi
e4e1c623
RS
189 rm -f /tmp/el /tmp/elc
190
191 ### Check for .el files with no corresponding .elc file.
3985f85d 192 (cd lisp; ls -1 [a-z]*.el [a-z]*/[a-z]*.el ; \
5eea385d 193 cd ../leim; ls -1 [a-z]*/[a-z]*.el) > /tmp/el
3985f85d 194 (cd lisp; ls -1 [a-z]*.elc [a-z]*/[a-z]*.elc; \
5eea385d 195 cd ../leim; ls -1 [a-z]*/[a-z]*.elc) | sed 's/\.elc$/.el/' > /tmp/elc
e4e1c623
RS
196 losers="`comm -23 /tmp/el /tmp/elc`"
197 bogosities=
198 for file in $losers; do
199 file1=`echo $file | sed -e "s|.*/||"`
bf7e917e 200 if ! sed -n -e "/^DONTCOMPILE/,/[^\\]\$/p" lisp/Makefile.in |
aa501770 201 grep -q "[ ]$file1\($\| \)"; then
e4e1c623
RS
202 case $file in
203 site-init.el | site-load.el | site-start.el | default.el)
204 ;;
205 term/*)
206 ;;
207 *)
208 bogosities="$file $bogosities"
209 ;;
210 esac
211 fi
212 done
213 if [ x"${bogosities}" != x"" ]; then
214 echo "The following .el files have no corresponding .elc files:"
215 echo "${bogosities}"
216 fi
217 rm -f /tmp/el /tmp/elc
8615e792 218
e4e1c623
RS
219 ### Check for .el files that would overflow the 14-char limit if compiled.
220 long=`find lisp leim -name '[a-zA-Z0-9]??????????*.el' -print`
221 if [ "$long" != "" ]; then
222 echo "The following .el file names are too long:"
223 echo "$long"
224 fi
f5674423
KH
225fi
226
b4e84d5d
JB
227### Make sure configure is newer than configure.in.
228if [ "x`ls -t configure configure.in | head -1`" != "xconfigure" ]; then
21764d60
KH
229 echo "\`./configure.in' is newer than \`./configure'" >&2
230 echo "Running autoconf" >&2
28335560 231 autoconf || { x=$?; echo Autoconf FAILED! >&2; exit $x; }
b4e84d5d
JB
232fi
233
c75cfabd
RS
234if [ $update = yes ];
235then
236 echo "Updating Info files"
870cfc55 237 (cd man; make -f Makefile.in srcdir=. info)
980ab937 238
e888d449 239 echo "Updating finder, custom and autoload data"
59d05d2d 240 (cd lisp; make updates EMACS="$EMACS")
7cf45b04 241
5eea385d
GM
242 if test -f leim/leim-list.el; then
243 echo "Updating leim-list.el"
244 (cd leim; make leim-list.el EMACS="$EMACS")
245 fi
29c98ed3
RS
246
247 echo "Recompiling Lisp files"
29c98ed3 248 $EMACS -batch -f batch-byte-recompile-directory lisp leim
c75cfabd 249fi
0588a761 250
f07eebe0
KH
251echo "Making lisp/MANIFEST"
252
73494596
RS
253(cd lisp;
254 files=`echo [!=]*.el | sed -e 's/ subdirs.el / /' -e 's/ default.el / /'`
255 for dir in [!=]*; do
5eea385d
GM
256 if [ -d $dir ] && [ $dir != term ] && [ $dir != CVS ] && [ $dir != RCS ]
257 then
73494596
RS
258 echo $dir
259 thisdir=`echo $dir/[!=]*.el | sed -e 's/ subdirs.el / /'`
260 files="$files $thisdir"
261 fi
262 done
263 head -1 $files | grep '^;' | sed -e 's/;;; //' | sort > MANIFEST)
f07eebe0 264
1260d6ba 265echo "Creating staging directory: \`${tempparent}'"
bb160193 266
f7dbcf3c 267mkdir ${tempparent}
f7dbcf3c
JB
268tempdir="${tempparent}/${emacsname}"
269
76fb0a58
JB
270### This trap ensures that the staging directory will be cleaned up even
271### when the script is interrupted in mid-career.
00c00348 272if [ "${clean_up}" = yes ]; then
21764d60 273 trap "echo 'Interrupted...cleaning up the staging directory'; rm -rf ${tempparent}; exit 1" 1 2 15
00c00348
ER
274fi
275
1260d6ba 276echo "Creating top directory: \`${tempdir}'"
f7dbcf3c
JB
277mkdir ${tempdir}
278
76fb0a58
JB
279### We copy in the top-level files before creating the subdirectories in
280### hopes that this will make the top-level files appear first in the
281### tar file; this means that people can start reading the INSTALL and
282### README while the rest of the tar file is still unpacking. Whoopee.
21764d60 283echo "Making links to top-level files"
1a93302c 284ln FTP INSTALL README BUGS move-if-change ${tempdir}
9d38d529 285ln ChangeLog Makefile.in configure configure.in aclocal.m4 ${tempdir}
6f8b09f3 286ln config.bat make-dist update-subdirs vpath.sed ${tempdir}
bb160193 287### Copy these files; they're cross-filesystem symlinks.
a4888c88 288cp mkinstalldirs ${tempdir}
76fb0a58 289cp config.sub ${tempdir}
2ed56345 290cp config.guess ${tempdir}
dc7717ab 291cp install-sh ${tempdir}
f7dbcf3c 292
21764d60 293echo "Updating version number in README"
f753e9aa
JB
294(cd ${tempdir}
295 awk \
296 '$1 " " $2 " " $3 " " $4 " " $5 == "This directory tree holds version" { $6 = version; print $0 }
297 $1 " " $2 " " $3 " " $4 " " $5 != "This directory tree holds version"' \
298 version=${version} README > tmp.README
af559a4e 299 mv -f tmp.README README)
f753e9aa
JB
300
301
21764d60 302echo "Creating subdirectories"
91741841 303for subdir in lisp site-lisp leim real-leim real-leim/CXTERM-DIC \
0744c2f1 304 real-leim/SKK-DIC real-leim/ja-dic real-leim/quail \
c660c0a7 305 src src/m src/s src/bitmaps lib-src oldXMenu lwlib \
5ec8424f 306 nt nt/inc nt/inc/sys nt/inc/arpa nt/inc/netinet nt/icons \
b3635775
GM
307 etc etc/e lock info man msdos vms mac mac/inc mac/inc/sys \
308 mac/src
309do
310 echo " ${tempdir}/${subdir}"
f7dbcf3c
JB
311 mkdir ${tempdir}/${subdir}
312done
313
91741841 314echo "Initializing \`leim' subdirectory"
a1363c1d 315cp noleim-Makefile.in ${tempdir}/leim/Makefile.in
91741841 316
67ffab69 317echo "Making links to \`lisp' and its subdirectories"
7b9cd64c 318### Don't distribute TAGS, =*.el files, site-init.el, site-load.el, or default.el.
f7dbcf3c
JB
319(cd lisp
320 ln [a-zA-Z]*.el ../${tempdir}/lisp
321 ln [a-zA-Z]*.elc ../${tempdir}/lisp
8d2197ac 322 ln [a-zA-Z]*.dat ../${tempdir}/lisp
a1363c1d 323 for img in [a-zA-Z]*.xpm [a-zA-Z]*.xbm [a-zA-Z]*.pbm; do
365949b7
GM
324 # If there are no images, the shell won't expand the pattern.
325 if [ -f $img ]; then
326 ln $img ../${tempdir}/lisp
327 fi
328 done
76fb0a58
JB
329 ## simula.el doesn't keep abbreviations in simula.defns any more.
330 ## ln [a-zA-Z]*.defns ../${tempdir}/lisp
bf7e917e 331 ln ChangeLog Makefile.in makefile.nt ChangeLog.? ../${tempdir}/lisp
b3635775 332 ln makefile.w32-in ../${tempdir}/lisp
5eea385d 333 test -f README && ln README ../${tempdir}/lisp
67ffab69
RS
334 (cd ../${tempdir}/lisp
335 rm -f TAGS =*
336 rm -f site-init site-init.el site-init.elc
337 rm -f site-load site-load.el site-load.elc
338 rm -f site-start site-start.el site-start.elc
339 rm -f default default.el default.elc
340 )
341
342 ## Find all subdirs of lisp dir
343 for file in `find . -type d -print`; do
344 case $file in
5eea385d 345 . | .. | */Old | */CVS | */RCS | */=*)
67ffab69
RS
346 ;;
347 *)
348 if [ -d $file ]; then
349 subdirs="$file $subdirs"
350 fi
351 ;;
352 esac
353 done
354
355 for file in $subdirs; do
356 echo " lisp/$file"
357 mkdir ../${tempdir}/lisp/$file
b3635775
GM
358 ln $file/[a-zA-Z0-9]*.el ../${tempdir}/lisp/$file
359 ln $file/[a-zA-Z0-9]*.elc ../${tempdir}/lisp/$file
360 for img in $file/[a-zA-Z]*.xpm $file/[a-zA-Z]*.xbm $file/[a-zA-Z]*.pbm; do
365949b7
GM
361 if [ -f $img ]; then
362 ln $img ../${tempdir}/lisp/$file
363 fi
364 done
67ffab69
RS
365 if [ -f $file/README ]; then
366 ln $file/README ../${tempdir}/lisp/$file
367 fi
b3635775 368
dcf3ff7f
RS
369 if [ -f $file/ChangeLog ]; then
370 ln $file/ChangeLog ../${tempdir}/lisp/$file
b3635775
GM
371 for f in $file/ChangeLog.[0-9]; do
372 if [ -f $f ]; then
373 ln $f ../${tempdir}/lisp/$file
374 fi
375 done
dcf3ff7f 376 fi
67ffab69 377 done )
a78c106d 378
91741841
RS
379echo "Making links to \`leim' and its subdirectories for the LEIM distribution"
380### Don't distribute TAGS, or =*.el files.
381(cd leim
b3635775 382 ln makefile.nt makefile.w32-in ../${tempdir}/real-leim
9089d8d7 383 ln ChangeLog README ../${tempdir}/real-leim
91741841
RS
384
385 ln CXTERM-DIC/*.tit ../${tempdir}/real-leim/CXTERM-DIC
5f8d02be 386 ln SKK-DIC/README SKK-DIC/SKK-JISYO.L ../${tempdir}/real-leim/SKK-DIC
0744c2f1 387 ln ja-dic/*.el ja-dic/*.elc ../${tempdir}/real-leim/ja-dic
91741841 388 ln quail/*.el quail/*.elc ../${tempdir}/real-leim/quail
a1363c1d 389 ln Makefile.in ../${tempdir}/real-leim/Makefile.in
5eea385d 390
91741841
RS
391 cd ../${tempdir}/real-leim
392 rm -f TAGS =* */=*)
393
394### Move the real-leim directory outside of Emacs proper.
65fda17c
RS
395(cd ${tempparent}
396 mkdir ${emacsname}-leim
397 mkdir ${emacsname}-leim/${emacsname}
398 mv ${emacsname}/real-leim ${emacsname}-leim/${emacsname}/leim)
91741841 399
21764d60 400echo "Making links to \`src'"
76fb0a58 401### Don't distribute =*.[ch] files, or the configured versions of
c3f1e1a9 402### config.in, paths.in, or Makefile.in, or TAGS.
f7dbcf3c 403(cd src
c75cfabd 404 echo " (It is ok if ln fails in some cases.)"
f7dbcf3c
JB
405 ln [a-zA-Z]*.c ../${tempdir}/src
406 ln [a-zA-Z]*.h ../${tempdir}/src
407 ln [a-zA-Z]*.s ../${tempdir}/src
c75cfabd
RS
408 ln [a-zA-Z]*.in ../${tempdir}/src
409 ln [a-zA-Z]*.opt ../${tempdir}/src
410 ## If we ended up with a symlink, or if we did not get anything
411 ## due to a cross-device symlink, copy the file.
412 for file in [a-zA-Z]*.[hcs] [a-zA-Z]*.in [a-zA-Z]*.opt; do
413 if test -f ../${tempdir}/src/$file; then
414 # test -f appears to succeed for a symlink
415 if test -L ../${tempdir}/src/$file; then
416 rm ../${tempdir}/src/$file
62dfdaf0 417 cp -p $file ../${tempdir}/src
c75cfabd
RS
418 chmod a-w ../${tempdir}/src/$file
419 fi
420 else
421 rm ../${tempdir}/src/$file
62dfdaf0 422 cp -p $file ../${tempdir}/src
c75cfabd
RS
423 chmod a-w ../${tempdir}/src/$file
424 fi
425 done
426 ln README ChangeLog ChangeLog.*[0-9] ../${tempdir}/src
b3635775 427 ln makefile.nt makefile.w32-in vms-pp.trans ../${tempdir}/src
990ee059 428 ln .gdbinit .dbxinit ../${tempdir}/src
f7dbcf3c 429 cd ../${tempdir}/src
8c28d444 430 rm -f config.h epaths.h Makefile Makefile.c
7b9cd64c 431 rm -f =* TAGS)
f7dbcf3c 432
21764d60 433echo "Making links to \`src/bitmaps'"
690eca32
JB
434(cd src/bitmaps
435 ln README *.xbm ../../${tempdir}/src/bitmaps)
436
21764d60 437echo "Making links to \`src/m'"
f7dbcf3c 438(cd src/m
facbb78e
RS
439 # We call files for miscellaneous input (to linker etc) .inp.
440 ln README [a-zA-Z0-9]*.h *.inp ../../${tempdir}/src/m)
f7dbcf3c 441
21764d60 442echo "Making links to \`src/s'"
f7dbcf3c 443(cd src/s
77427171 444 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/s)
f7dbcf3c 445
21764d60 446echo "Making links to \`lib-src'"
f7dbcf3c 447(cd lib-src
375f1bd7 448 ln [a-zA-Z]*.[chy] ../${tempdir}/lib-src
c3f1e1a9 449 ln ChangeLog Makefile.in README testfile vcdiff ../${tempdir}/lib-src
dc7717ab 450 ln grep-changelog rcs2log rcs-checkin makefile.nt ../${tempdir}/lib-src
b3635775 451 ln makefile.w32-in ../${tempdir}/lib-src
c75cfabd
RS
452 ## If we ended up with a symlink, or if we did not get anything
453 ## due to a cross-device symlink, copy the file.
454 for file in [a-zA-Z]*.[chy]; do
455 if test -f ../${tempdir}/lib-src/$file; then
456 # test -f appears to succeed for a symlink
457 if test -L ../${tempdir}/lib-src/$file; then
458 rm ../${tempdir}/lib-src/$file
459 cp $file ../${tempdir}/lib-src
460 chmod a-w ../${tempdir}/lib-src/$file
461 fi
462 else
463 rm ../${tempdir}/lib-src/$file
464 cp $file ../${tempdir}/lib-src
465 chmod a-w ../${tempdir}/lib-src/$file
466 fi
467 done
1260d6ba 468 cd ../${tempdir}/lib-src
c75cfabd 469 rm -f Makefile.c
7b9cd64c 470 rm -f =* TAGS)
f7dbcf3c 471
21764d60 472echo "Making links to \`nt'"
391b3748 473(cd nt
5eea385d 474 ln emacs.rc config.nt [a-z]*.in [a-z]*.c ../${tempdir}/nt
b3635775 475 ln _emacs nmake.defs gmake.defs ../${tempdir}/nt
b47cc08a 476 ln [a-z]*.bat [a-z]*.h makefile.def makefile.nt ../${tempdir}/nt
b3635775 477 ln TODO ChangeLog INSTALL README makefile.w32-in ../${tempdir}/nt)
391b3748 478
21764d60 479echo "Making links to \`nt/inc'"
391b3748 480(cd nt/inc
77427171 481 ln [a-z]*.h ../../${tempdir}/nt/inc)
391b3748 482
21764d60 483echo "Making links to \`nt/inc/sys'"
391b3748 484(cd nt/inc/sys
77427171 485 ln [a-z]*.h ../../../${tempdir}/nt/inc/sys)
391b3748 486
e827bc37
RS
487echo "Making links to \`nt/inc/arpa'"
488(cd nt/inc/arpa
489 ln [a-z]*.h ../../../${tempdir}/nt/inc/arpa)
490
491echo "Making links to \`nt/inc/netinet'"
492(cd nt/inc/netinet
493 ln [a-z]*.h ../../../${tempdir}/nt/inc/netinet)
494
5ec8424f
GV
495echo "Making links to \`nt/icons'"
496(cd nt/icons
91978d00 497 ln [a-z]*.ico ../../${tempdir}/nt/icons)
5ec8424f 498
b3635775
GM
499echo "Making links to \`mac'"
500(cd mac
501 ln ChangeLog INSTALL README *.xml *.MPW ../${tempdir}/mac)
502
503echo "Making links to \`mac/inc'"
504(cd mac/inc
505 ln [a-z]*.h ../../${tempdir}/mac/inc)
506
507echo "Making links to \`mac/inc/sys'"
508(cd mac/inc/sys
509 ln [a-z]*.h ../../../${tempdir}/mac/inc/sys)
510
511echo "Making links to \`mac/src'"
512(cd mac/src
513 ln [a-z]*.c *.r ../../${tempdir}/mac/src)
514
21764d60 515echo "Making links to \`msdos'"
52d7b2e5
RS
516(cd msdos
517 ln ChangeLog emacs.ico emacs.pif ../${tempdir}/msdos
7fd85d56 518 ln is_exec.c sigaction.c mainmake mainmake.v2 sed*.inp ../${tempdir}/msdos
52d7b2e5
RS
519 cd ../${tempdir}/msdos
520 rm -f =*)
521
21764d60 522echo "Making links to \`oldXMenu'"
f7dbcf3c 523(cd oldXMenu
8bdbf9ed 524 ln *.c *.h *.in ../${tempdir}/oldXMenu
df1ec566 525 ln README Imakefile ChangeLog ../${tempdir}/oldXMenu
f395c83a 526 ln compile.com descrip.mms ../${tempdir}/oldXMenu)
f7dbcf3c 527
21764d60 528echo "Making links to \`lwlib'"
c660c0a7
RS
529(cd lwlib
530 ln *.c *.h *.in ../${tempdir}/lwlib
72e7e784
KH
531 ln README Imakefile ChangeLog ../${tempdir}/lwlib
532 cd ../${tempdir}/lwlib
533 rm -f lwlib-Xol*)
c660c0a7 534
21764d60 535echo "Making links to \`etc'"
f395c83a
JB
536### Don't distribute = files, TAGS, DOC files, backups, autosaves, or
537### tex litter.
f7dbcf3c 538(cd etc
5eea385d 539 files=`ls -d * | grep -v CVS | grep -v RCS | grep -v 'Old' | grep -v '^e$'`
7a6ee7ae 540 ln $files ../${tempdir}/etc
98d4c1d0
RS
541 ## If we ended up with a symlink, or if we did not get anything
542 ## due to a cross-device symlink, copy the file.
7a6ee7ae 543 for file in $files; do
98d4c1d0
RS
544 if test -f ../${tempdir}/etc/$file; then
545 # test -f appears to succeed for a symlink
546 if test -L ../${tempdir}/etc/$file; then
547 rm ../${tempdir}/etc/$file
548 cp $file ../${tempdir}/etc
549 chmod a-w ../${tempdir}/etc/$file
550 fi
551 else
552 rm ../${tempdir}/etc/$file
553 cp $file ../${tempdir}/etc
554 chmod a-w ../${tempdir}/etc/$file
555 fi
556 done
f7dbcf3c 557 cd ../${tempdir}/etc
ebd32d7b 558 rm -f fns*.el
23a58692 559 rm -f DOC* *~ \#*\# *.dvi *.log *.orig *.rej *,v =* core
f395c83a 560 rm -f TAGS)
f7dbcf3c 561
21764d60 562echo "Making links to \`etc/e'"
f08ad882 563(cd etc/e
5eea385d 564 ln `ls -d * | grep -v CVS | grep -v RCS` ../../${tempdir}/etc/e
a6903f09 565 cd ../../${tempdir}/etc/e
375f1bd7 566 rm -f *~ \#*\# *,v =* core)
f08ad882 567
21764d60 568echo "Making links to \`info'"
66afa119
RS
569# Don't distribute backups or autosaves.
570(cd info
b3635775 571 ln `find . -type f -print | grep -v CVS | grep -v RCS | grep -v cvsignore` ../${tempdir}/info
5eea385d 572 #ln [a-zA-Z]* ../${tempdir}/info
66afa119
RS
573 cd ../${tempdir}/info
574 # Avoid an error when expanding the wildcards later.
575 ln emacs dummy~ ; ln emacs \#dummy\#
576 rm -f *~ \#*\# core)
fda4e8f6 577
21764d60 578echo "Making links to \`man'"
fda4e8f6 579(cd man
298c8970 580 ln *.texi *.aux *.cps *.fns *.kys *.vrs ../${tempdir}/man
5e808bc0 581 test -f README && ln README ../${tempdir}/man
f08ad882 582 test -f Makefile.in && ln Makefile.in ../${tempdir}/man
5eea385d
GM
583 ln ChangeLog ../${tempdir}/man
584 test -f split-man && ln split-man ../${tempdir}/man
585 test -f texinfo.tex && cp texinfo.tex ../${tempdir}/man
4f8cc93a 586 cd ../${tempdir}/man
56c31c87
RS
587 rm -f \#*\# =* *~ core emacs-index* *.Z *.z xmail
588 rm -f emacs.?? termcap.?? gdb.?? *.log *.toc *.dvi *.oaux)
f7dbcf3c 589
21764d60 590echo "Making links to \`vms'"
40eef465 591(cd vms
5eea385d 592 test -f README && ln README ../${tempdir}/vms
40eef465
JB
593 cd ../${tempdir}/vms
594 rm -f *~)
595
c87b230f
JB
596### It would be nice if they could all be symlinks to etc's copy, but
597### you're not supposed to have any symlinks in distribution tar files.
21764d60 598echo "Making sure copying notices are all copies of \`etc/COPYING'"
1260d6ba
ER
599rm -f ${tempdir}/etc/COPYING
600cp etc/COPYING ${tempdir}/etc/COPYING
8e583b5d 601for subdir in lisp src lib-src info msdos; do
f7dbcf3c
JB
602 if [ -f ${tempdir}/${subdir}/COPYING ]; then
603 rm ${tempdir}/${subdir}/COPYING
604 fi
96858c42 605 cp etc/COPYING ${tempdir}/${subdir}
f7dbcf3c
JB
606done
607
5b8def65
JB
608#### Make sure that there aren't any hard links between files in the
609#### distribution; people with afs can't deal with that. Okay,
610#### actually we just re-copy anything with a link count greater
375f1bd7
KH
611#### than two. (Yes, strictly greater than 2 is correct; since we
612#### created these files by linking them in from the original tree,
613#### they'll have exactly two links normally.)
bb7e0f81 614####
908ff139 615#### Commented out since it's not strictly necessary; it should suffice
bb7e0f81 616#### to just break the link on alloca.c.
9b23a6c7
RS
617#echo "Breaking intra-tree links."
618#find ${tempdir} ! -type d -links +2 \
619# -exec cp -p {} $$ \; -exec rm -f {} \; -exec mv $$ {} \;
bb7e0f81
KH
620rm -f $tempdir/lib-src/alloca.c
621cp $tempdir/src/alloca.c $tempdir/lib-src/alloca.c
5b8def65 622
1260d6ba 623if [ "${newer}" ]; then
21764d60 624 echo "Removing files older than $newer"
76fb0a58
JB
625 ## We remove .elc files unconditionally, on the theory that anyone picking
626 ## up an incremental distribution already has a running Emacs to byte-compile
627 ## them with.
1260d6ba
ER
628 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
629fi
630
4746118a 631if [ "${make_tar}" = yes ]; then
922ac4c5 632 if [ "${default_gzip}" = "" ]; then
21764d60 633 echo "Looking for gzip"
922ac4c5
JB
634 temppath=`echo $PATH | sed 's/^:/.:/
635 s/::/:.:/g
636 s/:$/:./
637 s/:/ /g'`
638 default_gzip=`(
639 for dir in ${temppath}; do
640 if [ -f ${dir}/gzip ]; then echo 'gzip --best'; exit 0; fi
641 done
642 echo compress
643 )`
644 fi
f395c83a
JB
645 case "${default_gzip}" in
646 compress* ) gzip_extension=.Z ;;
0dc610dd 647 * ) gzip_extension=.gz ;;
f395c83a 648 esac
91741841 649 echo "Creating tar files"
f395c83a
JB
650 (cd ${tempparent} ; tar cvf - ${emacsname} ) \
651 | ${default_gzip} \
652 > ${emacsname}.tar${gzip_extension}
65fda17c 653 (cd ${tempparent}/${emacsname}-leim ; tar cvf - ${emacsname} ) \
91741841 654 | ${default_gzip} \
5eea385d 655 > leim-${version}${new_extension}.tar${gzip_extension}
4746118a 656fi
f7dbcf3c 657
4746118a 658if [ "${clean_up}" = yes ]; then
21764d60 659 echo "Cleaning up the staging directory"
f395c83a 660 rm -rf ${tempparent}
bb160193 661else
91741841 662 (cd ${tempparent}; mv ${emacsname} ${emacsname}-leim ..)
bb160193 663 rm -rf ${tempparent}
f7dbcf3c 664fi
00c00348 665
76fb0a58 666### make-dist ends here