* fileio.c (Fsubstitute_in_file_name, Ffile_name_directory)
[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
e91081eb 9# Copyright (C) 1995, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005,
dfe07b9d 10# 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
b33ba812 11
4c9c1174
KH
12# This file is part of GNU Emacs.
13#
b33ba812 14# GNU Emacs is free software: you can redistribute it and/or modify
4c9c1174 15# it under the terms of the GNU General Public License as published by
b33ba812
GM
16# the Free Software Foundation, either version 3 of the License, or
17# (at your option) any later version.
18
4c9c1174
KH
19# GNU Emacs is distributed in the hope that it will be useful,
20# but WITHOUT ANY WARRANTY; without even the implied warranty of
21# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22# GNU General Public License for more details.
b33ba812 23
4c9c1174 24# You should have received a copy of the GNU General Public License
b33ba812
GM
25# along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
26
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
8df317a6
GM
36LANGUAGE=C
37LC_ALL=C
38LC_MESSAGES=
39LANG=
40export LANGUAGE LC_ALL LC_MESSAGES LANG
41
ccd57f4d 42## Don't restrict access to any files.
67ffab69
RS
43umask 0
44
c75cfabd 45update=yes
e4e1c623 46check=yes
f22edcea
RS
47clean_up=no
48make_tar=no
1260d6ba 49newer=""
f7dbcf3c
JB
50
51while [ $# -gt 0 ]; do
52 case "$1" in
f22edcea
RS
53 ## This option tells make-dist to delete the staging directory
54 ## when done. It is useless to use this unless you make a tar file.
55 "--clean-up" )
56 clean_up=yes
4746118a 57 ;;
f22edcea
RS
58 ## This option tells make-dist to make a tar file.
59 "--tar" )
60 make_tar=yes
f7dbcf3c 61 ;;
c75cfabd
RS
62 ## This option tells make-dist not to recompile or do analogous things.
63 "--no-update" )
64 update=no
65 ;;
e4e1c623
RS
66 ## This option says don't check for bad file names, etc.
67 "--no-check" )
68 check=no
69 ;;
76fb0a58 70 ## This option tells make-dist to make the distribution normally, then
7b9cd64c
ER
71 ## remove all files older than the given timestamp file. This is useful
72 ## for creating incremental or patch distributions.
1260d6ba 73 "--newer")
ef15f270
JB
74 newer="$2"
75 new_extension=".new"
1260d6ba
ER
76 shift
77 ;;
922ac4c5
JB
78 ## This option tells make-dist to use `compress' instead of gzip.
79 ## Normally, make-dist uses gzip whenever it is present.
80 "--compress")
81 default_gzip="compress"
82 ;;
37d6e313
RF
83 ## Same with bzip2.
84 "--bzip2")
85 default_gzip="bzip2"
86 ;;
ed398055
GM
87 ## Same with lzma.
88 "--lzma")
89 default_gzip="lzma"
90 ;;
2a714d4e
GM
91
92 "--snapshot")
93 clean_up=yes
94 make_tar=yes
95 update=no
96 check=no
97 ;;
98
99 "--help")
100 echo "Usage: ${progname} [options]"
101 echo ""
8772b5a8 102 echo " --bzip2 use bzip2 instead of gzip"
2a714d4e
GM
103 echo " --clean-up delete staging directories when done"
104 echo " --compress use compress instead of gzip"
8772b5a8 105 echo " --lzma use lzma instead of gzip"
2a714d4e
GM
106 echo " --newer=TIME don't include files older than TIME"
107 echo " --no-check don't check for bad file names etc."
108 echo " --no-update don't recompile or do analogous things"
109 echo " --snapshot same as --clean-up --no-update --tar --no-check"
110 echo " --tar make a tar file"
111 echo ""
112 exit 0
113 ;;
114
f7dbcf3c
JB
115 * )
116 echo "${progname}: Unrecognized argument: $1" >&2
117 exit 1
118 ;;
119 esac
120 shift
121done
122
76fb0a58 123### Make sure we're running in the right place.
f7dbcf3c 124if [ ! -d src -o ! -f src/lisp.h -o ! -d lisp -o ! -f lisp/version.el ]; then
1260d6ba
ER
125 echo "${progname}: Can't find \`src/lisp.h' and \`lisp/version.el'." >&2
126 echo "${progname} must be run in the top directory of the Emacs" >&2
0d122844 127 echo "distribution tree. cd to that directory and try again." >&2
f7dbcf3c
JB
128 exit 1
129fi
130
c75cfabd 131### Find where to run Emacs.
4b1aaa8b 132### (Accept only absolute file names.)
c75cfabd
RS
133if [ $update = yes ];
134then
59d05d2d 135 unset EMACS_UNIBYTE
c75cfabd
RS
136 if [ -f src/emacs ];
137 then
138 EMACS=`pwd`/src/emacs
139 else
4b1aaa8b
PE
140 case $EMACS in
141 /*) ;;
142 *)
143 if [ ! -f "$EMACS" ]; then
2906a94c 144 echo "$0: You must set the EMACS environment variable " \
4b1aaa8b
PE
145 "to an absolute file name." 2>&1
146 exit 1
147 fi;;
148 esac
c75cfabd
RS
149 fi
150fi
151
76fb0a58 152### Find out which version of Emacs this is.
0e0186f1 153shortversion=`grep 'defconst[ ]*emacs-version' lisp/version.el \
47d105b0 154 | sed -e 's/^.*"\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/'`
0e0186f1
RS
155version=`grep 'defconst[ ]*emacs-version' lisp/version.el \
156 | sed -e 's/^[^"]*"\([^"]*\)".*$/\1/'`
f7dbcf3c 157if [ ! "${version}" ]; then
21764d60 158 echo "${progname}: can't find current Emacs version in \`./lisp/version.el'" >&2
f7dbcf3c
JB
159 exit 1
160fi
161
21764d60 162echo Version numbers are $version and $shortversion
47d105b0 163
c75cfabd
RS
164if [ $update = yes ];
165then
d175b0ae 166 if grep -s "@set EMACSVER *${shortversion}" ./doc/emacs/emacs.texi > /dev/null; then
c75cfabd
RS
167 true
168 else
d175b0ae 169 echo "You must update the version number in \`./doc/emacs/emacs.texi'"
c75cfabd
RS
170 sleep 5
171 fi
f753e9aa
JB
172fi
173
bb160193
RS
174### Make sure we don't already have a directory emacs-${version}.
175
176emacsname="emacs-${version}${new_extension}"
177
178if [ -d ${emacsname} ]
179then
180 echo Directory "${emacsname}" already exists >&2
181 exit 1
182fi
183
76fb0a58 184### Make sure the subdirectory is available.
1260d6ba 185tempparent="make-dist.tmp.$$"
f7dbcf3c 186if [ -d ${tempparent} ]; then
1260d6ba
ER
187 echo "${progname}: staging directory \`${tempparent}' already exists.
188Perhaps a previous invocation of \`${progname}' failed to clean up after
189itself. Check that directories whose names are of the form
190\`make-dist.tmp.NNNNN' don't contain any important information, remove
191them, and try again." >&2
f7dbcf3c
JB
192 exit 1
193fi
194
e4e1c623
RS
195### Find where to run Emacs.
196if [ $check = yes ];
197then
198 ### Check for .elc files with no corresponding .el file.
fb0797ca 199 ls -1 lisp/[a-zA-Z]*.el lisp/[a-z]*/[a-zA-Z0-9]*.el \
5eea385d 200 leim/[a-z]*/[a-z]*.el | sed 's/\.el$/.elc/' > /tmp/el
fb0797ca 201 ls -1 lisp/[a-zA-Z]*.elc lisp/[a-z]*/[a-zA-Z0-9]*.elc \
5eea385d 202 leim/[a-z]*/[a-z]*.elc > /tmp/elc
e4e1c623
RS
203 bogosities="`comm -13 /tmp/el /tmp/elc`"
204 if [ "${bogosities}" != "" ]; then
205 echo "The following .elc files have no corresponding .el files:"
206 echo "${bogosities}"
8615e792 207 fi
e4e1c623
RS
208 rm -f /tmp/el /tmp/elc
209
210 ### Check for .el files with no corresponding .elc file.
fb0797ca 211 ls -1 lisp/[a-zA-Z]*.el lisp/[a-z]*/[a-zA-Z0-9]*.el \
33740d04 212 leim/[a-z]*/[a-z]*.el > /tmp/el
fb0797ca 213 ls -1 lisp/[a-zA-Z]*.elc lisp/[a-z]*/[a-zA-Z0-9]*.elc \
33740d04 214 leim/[a-z]*/[a-z]*.elc | sed 's/\.elc$/.el/' > /tmp/elc
e4e1c623
RS
215 losers="`comm -23 /tmp/el /tmp/elc`"
216 bogosities=
217 for file in $losers; do
33740d04 218 if ! grep -q "no-byte-compile: t" $file; then
e4e1c623
RS
219 case $file in
220 site-init.el | site-load.el | site-start.el | default.el)
221 ;;
e4e1c623
RS
222 *)
223 bogosities="$file $bogosities"
224 ;;
225 esac
226 fi
227 done
228 if [ x"${bogosities}" != x"" ]; then
229 echo "The following .el files have no corresponding .elc files:"
230 echo "${bogosities}"
231 fi
232 rm -f /tmp/el /tmp/elc
f5674423
KH
233fi
234
b4e84d5d 235### Make sure configure is newer than configure.in.
a8a8fcfa 236if [ "x`ls -t configure configure.in | sed q`" != "xconfigure" ]; then
21764d60
KH
237 echo "\`./configure.in' is newer than \`./configure'" >&2
238 echo "Running autoconf" >&2
28335560 239 autoconf || { x=$?; echo Autoconf FAILED! >&2; exit $x; }
b4e84d5d
JB
240fi
241
a49eb675
AS
242### Make sure src/config-in.stamp is newer than configure.in.
243if [ "x`ls -t src/stamp-h.in configure.in | sed q`" != "xsrc/stamp-h.in" ]; then
244 echo "\`./configure.in' is newer than \`./src/stamp-h.in'" >&2
245 echo "Running autoheader" >&2
246 autoheader || { x=$?; echo Autoheader FAILED! >&2; exit $x; }
247 rm -f src/stamp-h.in
248 echo timestamp > src/stamp-h.in
249fi
250
c75cfabd
RS
251if [ $update = yes ];
252then
253 echo "Updating Info files"
d175b0ae
RF
254 (cd doc/emacs; make -f Makefile.in srcdir=. info)
255 (cd doc/misc; make -f Makefile.in srcdir=. info)
256 (cd doc/lispref; make -f Makefile.in srcdir=. info)
257 (cd doc/lispintro; make -f Makefile.in SHELL=/bin/sh srcdir=. info VPATH=.)
980ab937 258
e888d449 259 echo "Updating finder, custom and autoload data"
59d05d2d 260 (cd lisp; make updates EMACS="$EMACS")
7cf45b04 261
5eea385d
GM
262 if test -f leim/leim-list.el; then
263 echo "Updating leim-list.el"
264 (cd leim; make leim-list.el EMACS="$EMACS")
265 fi
29c98ed3
RS
266
267 echo "Recompiling Lisp files"
29c98ed3 268 $EMACS -batch -f batch-byte-recompile-directory lisp leim
c75cfabd 269fi
0588a761 270
f07eebe0
KH
271echo "Making lisp/MANIFEST"
272
73494596
RS
273(cd lisp;
274 files=`echo [!=]*.el | sed -e 's/ subdirs.el / /' -e 's/ default.el / /'`
275 for dir in [!=]*; do
5eea385d
GM
276 if [ -d $dir ] && [ $dir != term ] && [ $dir != CVS ] && [ $dir != RCS ]
277 then
73494596
RS
278 echo $dir
279 thisdir=`echo $dir/[!=]*.el | sed -e 's/ subdirs.el / /'`
280 files="$files $thisdir"
281 fi
282 done
a8a8fcfa
PE
283 for file in $files
284 do sed -n 's/^;;; //p; q' $file
285 done | sort > MANIFEST)
f07eebe0 286
1260d6ba 287echo "Creating staging directory: \`${tempparent}'"
bb160193 288
f7dbcf3c 289mkdir ${tempparent}
f7dbcf3c
JB
290tempdir="${tempparent}/${emacsname}"
291
76fb0a58
JB
292### This trap ensures that the staging directory will be cleaned up even
293### when the script is interrupted in mid-career.
00c00348 294if [ "${clean_up}" = yes ]; then
21764d60 295 trap "echo 'Interrupted...cleaning up the staging directory'; rm -rf ${tempparent}; exit 1" 1 2 15
00c00348
ER
296fi
297
1260d6ba 298echo "Creating top directory: \`${tempdir}'"
f7dbcf3c
JB
299mkdir ${tempdir}
300
76fb0a58
JB
301### We copy in the top-level files before creating the subdirectories in
302### hopes that this will make the top-level files appear first in the
303### tar file; this means that people can start reading the INSTALL and
304### README while the rest of the tar file is still unpacking. Whoopee.
21764d60 305echo "Making links to top-level files"
3ada8b66 306ln INSTALL README BUGS move-if-change ${tempdir}
bcea38a3 307ln ChangeLog Makefile.in configure configure.in ${tempdir}
b08ddfb4 308ln config.bat make-dist update-subdirs vpath.sed .dir-locals.el ${tempdir}
bb160193 309### Copy these files; they're cross-filesystem symlinks.
a4888c88 310cp mkinstalldirs ${tempdir}
76fb0a58 311cp config.sub ${tempdir}
2ed56345 312cp config.guess ${tempdir}
dc7717ab 313cp install-sh ${tempdir}
f7dbcf3c 314
21764d60 315echo "Updating version number in README"
f753e9aa
JB
316(cd ${tempdir}
317 awk \
318 '$1 " " $2 " " $3 " " $4 " " $5 == "This directory tree holds version" { $6 = version; print $0 }
319 $1 " " $2 " " $3 " " $4 " " $5 != "This directory tree holds version"' \
320 version=${version} README > tmp.README
af559a4e 321 mv -f tmp.README README)
f753e9aa
JB
322
323
21764d60 324echo "Creating subdirectories"
d175b0ae 325for subdir in lisp site-lisp \
05494c29 326 leim leim/CXTERM-DIC leim/MISC-DIC \
ca111811 327 leim/SKK-DIC leim/ja-dic leim/quail \
c660c0a7 328 src src/m src/s src/bitmaps lib-src oldXMenu lwlib \
5ec8424f 329 nt nt/inc nt/inc/sys nt/inc/arpa nt/inc/netinet nt/icons \
0bd50841 330 etc etc/charsets etc/e etc/gnus etc/nxml \
4e1fb954
GM
331 etc/images etc/images/custom etc/images/ezimage etc/images/gnus \
332 etc/images/gud etc/images/icons etc/images/icons/hicolor \
dc6150eb 333 etc/images/icons/hicolor/*x* etc/images/icons/hicolor/scalable \
10eae9dd 334 etc/images/icons/hicolor/*/apps etc/images/icons/hicolor/*/mimetypes \
d8981daf 335 etc/images/low-color etc/images/mail \
56bcdb80
GM
336 etc/images/smilies etc/images/smilies/grayscale \
337 etc/images/smilies/medium etc/images/tree-widget \
338 etc/images/tree-widget/default etc/images/tree-widget/folder \
3ada8b66 339 etc/refcards etc/schema etc/tutorials info doc doc/emacs \
7c2fb837 340 doc/misc doc/man doc/lispref doc/lispintro m4 msdos \
2c369af7
GM
341 nextstep nextstep/Cocoa nextstep/Cocoa/Emacs.base \
342 nextstep/Cocoa/Emacs.base/Contents \
343 nextstep/Cocoa/Emacs.base/Contents/Resources \
344 nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj \
2c369af7
GM
345 nextstep/Cocoa/Emacs.xcodeproj \
346 nextstep/GNUstep \
347 nextstep/GNUstep/Emacs.base \
eeebcbb9 348 nextstep/GNUstep/Emacs.base/Resources
b3635775 349do
0da746de
GM
350 ## site-lisp for in-place installs (?).
351 [ "$subdir" = "site-lisp" ] || [ -d "$subdir" ] || \
352 echo "WARNING: $subdir not found, making anyway"
b3635775 353 echo " ${tempdir}/${subdir}"
f7dbcf3c
JB
354 mkdir ${tempdir}/${subdir}
355done
356
67ffab69 357echo "Making links to \`lisp' and its subdirectories"
7b9cd64c 358### Don't distribute TAGS, =*.el files, site-init.el, site-load.el, or default.el.
f7dbcf3c
JB
359(cd lisp
360 ln [a-zA-Z]*.el ../${tempdir}/lisp
361 ln [a-zA-Z]*.elc ../${tempdir}/lisp
76fb0a58
JB
362 ## simula.el doesn't keep abbreviations in simula.defns any more.
363 ## ln [a-zA-Z]*.defns ../${tempdir}/lisp
fb0797ca
LK
364 ln ChangeLog ChangeLog.*[0-9] ../${tempdir}/lisp
365 ln Makefile.in makefile.w32-in ../${tempdir}/lisp
5eea385d 366 test -f README && ln README ../${tempdir}/lisp
67ffab69
RS
367 (cd ../${tempdir}/lisp
368 rm -f TAGS =*
369 rm -f site-init site-init.el site-init.elc
370 rm -f site-load site-load.el site-load.elc
371 rm -f site-start site-start.el site-start.elc
372 rm -f default default.el default.elc
373 )
374
375 ## Find all subdirs of lisp dir
376 for file in `find . -type d -print`; do
377 case $file in
5eea385d 378 . | .. | */Old | */CVS | */RCS | */=*)
177c0ea7 379 ;;
67ffab69
RS
380 *)
381 if [ -d $file ]; then
382 subdirs="$file $subdirs"
383 fi
384 ;;
385 esac
386 done
387
388 for file in $subdirs; do
389 echo " lisp/$file"
3ada8b66 390 mkdir -p ../${tempdir}/lisp/$file
b3635775
GM
391 ln $file/[a-zA-Z0-9]*.el ../${tempdir}/lisp/$file
392 ln $file/[a-zA-Z0-9]*.elc ../${tempdir}/lisp/$file
4e1fb954
GM
393 ## calc/README.priv, nxml/TODO
394 for f in $file/[a-zA-Z]*.xpm $file/[a-zA-Z]*.[xp]bm \
395 $file/README $file/ChangeLog $file/ChangeLog.*[0-9] \
396 $file/README.prev $file/TODO; do
397 if [ -f $f ]; then
398 ln $f ../${tempdir}/lisp/$file
365949b7
GM
399 fi
400 done
67ffab69 401 done )
a78c106d 402
ca111811 403echo "Making links to \`leim' and its subdirectories"
91741841
RS
404### Don't distribute TAGS, or =*.el files.
405(cd leim
561bd1a1 406 ln makefile.w32-in ../${tempdir}/leim
ca111811
EZ
407 ln ChangeLog README ../${tempdir}/leim
408
4e1fb954 409 ln CXTERM-DIC/README CXTERM-DIC/*.tit ../${tempdir}/leim/CXTERM-DIC
ca111811 410 ln SKK-DIC/README SKK-DIC/SKK-JISYO.L ../${tempdir}/leim/SKK-DIC
4e1fb954 411 ln MISC-DIC/README MISC-DIC/*.* ../${tempdir}/leim/MISC-DIC
ca111811
EZ
412 ln ja-dic/*.el ja-dic/*.elc ../${tempdir}/leim/ja-dic
413 ln Makefile.in ../${tempdir}/leim/Makefile.in
1d390bd8 414 ln leim-ext.el ../${tempdir}/leim/leim-ext.el
4e1fb954
GM
415 ## Lisp files that start with a capital (also 4Corner.el) are
416 ## generated from TIT dictionaries so we don't distribute them.
ca111811
EZ
417 ln quail/[a-z]*.el quail/[a-z]*.elc ../${tempdir}/leim/quail
418 rm -f ../${tempdir}/leim/quail/quick-b5.*
419 rm -f ../${tempdir}/leim/quail/quick-cns.*
420 rm -f ../${tempdir}/leim/quail/tsang-b5.*
421 rm -f ../${tempdir}/leim/quail/tsang-cns.*
422
423 cd ../${tempdir}/leim
91741841
RS
424 rm -f TAGS =* */=*)
425
21764d60 426echo "Making links to \`src'"
76fb0a58 427### Don't distribute =*.[ch] files, or the configured versions of
c3f1e1a9 428### config.in, paths.in, or Makefile.in, or TAGS.
f7dbcf3c 429(cd src
c75cfabd 430 echo " (It is ok if ln fails in some cases.)"
f7dbcf3c
JB
431 ln [a-zA-Z]*.c ../${tempdir}/src
432 ln [a-zA-Z]*.h ../${tempdir}/src
2c369af7 433 ln [a-zA-Z]*.m ../${tempdir}/src
c75cfabd 434 ln [a-zA-Z]*.in ../${tempdir}/src
c75cfabd
RS
435 ## If we ended up with a symlink, or if we did not get anything
436 ## due to a cross-device symlink, copy the file.
4e1fb954 437 for file in [a-zA-Z]*.[hcs] [a-zA-Z]*.in; do
c75cfabd
RS
438 if test -f ../${tempdir}/src/$file; then
439 # test -f appears to succeed for a symlink
440 if test -L ../${tempdir}/src/$file; then
441 rm ../${tempdir}/src/$file
62dfdaf0 442 cp -p $file ../${tempdir}/src
c75cfabd
RS
443 chmod a-w ../${tempdir}/src/$file
444 fi
445 else
446 rm ../${tempdir}/src/$file
62dfdaf0 447 cp -p $file ../${tempdir}/src
c75cfabd
RS
448 chmod a-w ../${tempdir}/src/$file
449 fi
450 done
451 ln README ChangeLog ChangeLog.*[0-9] ../${tempdir}/src
561bd1a1 452 ln makefile.w32-in ../${tempdir}/src
990ee059 453 ln .gdbinit .dbxinit ../${tempdir}/src
f7dbcf3c 454 cd ../${tempdir}/src
8c28d444 455 rm -f config.h epaths.h Makefile Makefile.c
7b9cd64c 456 rm -f =* TAGS)
f7dbcf3c 457
21764d60 458echo "Making links to \`src/bitmaps'"
690eca32
JB
459(cd src/bitmaps
460 ln README *.xbm ../../${tempdir}/src/bitmaps)
461
21764d60 462echo "Making links to \`src/m'"
f7dbcf3c 463(cd src/m
facbb78e
RS
464 # We call files for miscellaneous input (to linker etc) .inp.
465 ln README [a-zA-Z0-9]*.h *.inp ../../${tempdir}/src/m)
f7dbcf3c 466
21764d60 467echo "Making links to \`src/s'"
f7dbcf3c 468(cd src/s
77427171 469 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/s)
f7dbcf3c 470
21764d60 471echo "Making links to \`lib-src'"
f7dbcf3c 472(cd lib-src
2c369af7 473 ln [a-zA-Z]*.[chmy] ../${tempdir}/lib-src
c3f1e1a9 474 ln ChangeLog Makefile.in README testfile vcdiff ../${tempdir}/lib-src
4e1fb954 475 ln b2m.pl grep-changelog rcs2log rcs-checkin ../${tempdir}/lib-src
b3635775 476 ln makefile.w32-in ../${tempdir}/lib-src
c75cfabd
RS
477 ## If we ended up with a symlink, or if we did not get anything
478 ## due to a cross-device symlink, copy the file.
479 for file in [a-zA-Z]*.[chy]; do
480 if test -f ../${tempdir}/lib-src/$file; then
481 # test -f appears to succeed for a symlink
482 if test -L ../${tempdir}/lib-src/$file; then
483 rm ../${tempdir}/lib-src/$file
484 cp $file ../${tempdir}/lib-src
485 chmod a-w ../${tempdir}/lib-src/$file
486 fi
487 else
488 rm ../${tempdir}/lib-src/$file
489 cp $file ../${tempdir}/lib-src
490 chmod a-w ../${tempdir}/lib-src/$file
491 fi
492 done
1260d6ba 493 cd ../${tempdir}/lib-src
c75cfabd 494 rm -f Makefile.c
9eff9fe3 495 rm -f getopt.h
7b9cd64c 496 rm -f =* TAGS)
f7dbcf3c 497
9eff9fe3
PE
498echo "Making links to \`m4'"
499(cd m4
500 ln *.m4 ../${tempdir}/m4)
501
21764d60 502echo "Making links to \`nt'"
391b3748 503(cd nt
3271ac8c 504 ln emacs.manifest emacs.rc emacsclient.rc config.nt [a-z]*.c ../${tempdir}/nt
bcea38a3 505 ln nmake.defs gmake.defs subdirs.el ../${tempdir}/nt
561bd1a1 506 ln [a-z]*.bat [a-z]*.h ../${tempdir}/nt
bcea38a3 507 ln ChangeLog INSTALL README makefile.w32-in ../${tempdir}/nt)
391b3748 508
21764d60 509echo "Making links to \`nt/inc'"
391b3748 510(cd nt/inc
77427171 511 ln [a-z]*.h ../../${tempdir}/nt/inc)
391b3748 512
21764d60 513echo "Making links to \`nt/inc/sys'"
391b3748 514(cd nt/inc/sys
77427171 515 ln [a-z]*.h ../../../${tempdir}/nt/inc/sys)
391b3748 516
e827bc37
RS
517echo "Making links to \`nt/inc/arpa'"
518(cd nt/inc/arpa
519 ln [a-z]*.h ../../../${tempdir}/nt/inc/arpa)
520
521echo "Making links to \`nt/inc/netinet'"
522(cd nt/inc/netinet
523 ln [a-z]*.h ../../../${tempdir}/nt/inc/netinet)
524
5ec8424f
GV
525echo "Making links to \`nt/icons'"
526(cd nt/icons
4e1fb954 527 ln README [a-z]*.ico ../../${tempdir}/nt/icons
d6dc647f 528 ln [a-z]*.cur ../../${tempdir}/nt/icons)
5ec8424f 529
21764d60 530echo "Making links to \`msdos'"
52d7b2e5 531(cd msdos
4e1fb954 532 ln ChangeLog INSTALL README emacs.ico emacs.pif ../${tempdir}/msdos
7fd85d56 533 ln is_exec.c sigaction.c mainmake mainmake.v2 sed*.inp ../${tempdir}/msdos
52d7b2e5
RS
534 cd ../${tempdir}/msdos
535 rm -f =*)
536
99cc1583 537## FIXME are DEV-NOTES and FOR-RELEASE appropriate?
2c369af7
GM
538echo "Making links to \`nextstep'"
539(cd nextstep
99cc1583 540 ln AUTHORS ChangeLog DEV-NOTES FOR-RELEASE README INSTALL ../${tempdir}/nextstep)
2c369af7
GM
541
542echo "Making links to \`nextstep/Cocoa/Emacs.base/Contents'"
543(cd nextstep/Cocoa/Emacs.base/Contents
544 ln Info.plist PkgInfo ../../../../${tempdir}/nextstep/Cocoa/Emacs.base/Contents)
545
546echo "Making links to \`nextstep/Cocoa/Emacs.base/Contents/Resources'"
547(cd nextstep/Cocoa/Emacs.base/Contents/Resources
5338a639 548 ln Credits.html *.icns ../../../../../${tempdir}/nextstep/Cocoa/Emacs.base/Contents/Resources)
2c369af7
GM
549
550echo "Making links to \`nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj'"
551(cd nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj
552 ln InfoPlist.strings ../../../../../../${tempdir}/nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj)
553
2c369af7
GM
554echo "Making links to \`nextstep/Cocoa/Emacs.xcodeproj'"
555(cd nextstep/Cocoa/Emacs.xcodeproj
556 ln project.pbxproj ../../../${tempdir}/nextstep/Cocoa/Emacs.xcodeproj)
557
558echo "Making links to \`nextstep/GNUstep/Emacs.base/Resources'"
559(cd nextstep/GNUstep/Emacs.base/Resources
5338a639 560 ln Emacs.desktop Info-gnustep.plist README emacs.tiff ../../../../${tempdir}/nextstep/GNUstep/Emacs.base/Resources )
2c369af7 561
21764d60 562echo "Making links to \`oldXMenu'"
f7dbcf3c 563(cd oldXMenu
8bdbf9ed 564 ln *.c *.h *.in ../${tempdir}/oldXMenu
7c2fb837 565 ln README ChangeLog ../${tempdir}/oldXMenu)
f7dbcf3c 566
21764d60 567echo "Making links to \`lwlib'"
c660c0a7
RS
568(cd lwlib
569 ln *.c *.h *.in ../${tempdir}/lwlib
ebb81677 570 ln README ChangeLog ../${tempdir}/lwlib)
c660c0a7 571
21764d60 572echo "Making links to \`etc'"
f395c83a
JB
573### Don't distribute = files, TAGS, DOC files, backups, autosaves, or
574### tex litter.
f7dbcf3c 575(cd etc
561bd1a1 576 files=`ls -d * | grep -v CVS | grep -v RCS | grep -v 'Old' | grep -v '^e$' \
0bd50841 577 | grep -v '^charsets$' | grep -v '^gnus$' | grep -v '^images$' | grep -v '^nxml$' \
916447e4 578 | grep -v '^refcards$' | grep -v '^tutorials$'| grep -v '^schema$'`
7a6ee7ae 579 ln $files ../${tempdir}/etc
98d4c1d0
RS
580 ## If we ended up with a symlink, or if we did not get anything
581 ## due to a cross-device symlink, copy the file.
7a6ee7ae 582 for file in $files; do
98d4c1d0
RS
583 if test -f ../${tempdir}/etc/$file; then
584 # test -f appears to succeed for a symlink
585 if test -L ../${tempdir}/etc/$file; then
586 rm ../${tempdir}/etc/$file
587 cp $file ../${tempdir}/etc
588 chmod a-w ../${tempdir}/etc/$file
589 fi
590 else
591 rm ../${tempdir}/etc/$file
592 cp $file ../${tempdir}/etc
593 chmod a-w ../${tempdir}/etc/$file
594 fi
595 done
f7dbcf3c 596 cd ../${tempdir}/etc
d175b0ae 597 rm -f fns*.el
23a58692 598 rm -f DOC* *~ \#*\# *.dvi *.log *.orig *.rej *,v =* core
f395c83a 599 rm -f TAGS)
f7dbcf3c 600
0bd50841 601for dir in etc/charsets etc/e etc/gnus etc/nxml etc/tutorials etc/refcards etc/schema ; do
561c44e8
RF
602 echo "Making links to \`${dir}'"
603 (cd ${dir}
604 ln `ls -d * | grep -v CVS | grep -v RCS` ../../${tempdir}/${dir}
605 cd ../../${tempdir}/${dir}
606 rm -f *~ \#*\# *,v =* core)
607done
f08ad882 608
36eaa68f
RF
609echo "Making links to \`etc/images'"
610(cd etc/images
2906a94c
GM
611 for f in *; do
612 [ -f "$f" ] || continue
613 case $f in
614 (*~|\#*\#|*,v|=*|core) continue ;;
615 esac
616 ln $f ../../${tempdir}/etc/images
36eaa68f
RF
617 done)
618
4e1fb954
GM
619for dir in etc/images/custom etc/images/ezimage etc/images/gnus \
620 etc/images/gud etc/images/icons etc/images/low-color etc/images/mail \
621 etc/images/smilies ; do
561bd1a1
EZ
622 echo "Making links to \`${dir}'"
623 (cd ${dir}
2906a94c
GM
624 for f in *; do
625 [ -f "$f" ] || continue
626 case $f in
627 (*~|\#*\#|*,v|=*|core) continue ;;
628 esac
629 ln $f ../../../${tempdir}/${dir}
630 done
631 )
561bd1a1
EZ
632done
633
56bcdb80 634for dir in etc/images/tree-widget/default etc/images/tree-widget/folder \
d8981daf 635 etc/images/smilies/grayscale etc/images/smilies/medium; do
561c44e8
RF
636 echo "Making links to \`${dir}'"
637 (cd ${dir}
638 ln `ls -d * | grep -v CVS | grep -v RCS` ../../../../${tempdir}/${dir}
639 cd ../../../../${tempdir}/${dir}
640 rm -f *~ \#*\# *,v =* core)
641done
642
10eae9dd
GM
643for dir in etc/images/icons/hicolor/*/apps \
644 etc/images/icons/hicolor/*/mimetypes; do
d8981daf
GM
645 echo "Making links to \`${dir}'"
646 (cd ${dir}
647 ln `ls -d * | grep -v CVS | grep -v RCS` ../../../../../../${tempdir}/${dir}
648 cd ../../../../../../${tempdir}/${dir}
649 rm -f *~ \#*\# *,v =* core)
650done
651
21764d60 652echo "Making links to \`info'"
66afa119
RS
653# Don't distribute backups or autosaves.
654(cd info
b3635775 655 ln `find . -type f -print | grep -v CVS | grep -v RCS | grep -v cvsignore` ../${tempdir}/info
5eea385d 656 #ln [a-zA-Z]* ../${tempdir}/info
66afa119
RS
657 cd ../${tempdir}/info
658 # Avoid an error when expanding the wildcards later.
659 ln emacs dummy~ ; ln emacs \#dummy\#
3122b073 660 rm -f *~ \#*\# core .arch-inventory .gitignore)
fda4e8f6 661
d175b0ae
RF
662echo "Making links to \`doc/emacs'"
663(cd doc/emacs
4e1fb954 664 ln *.texi *.aux *.fns *.kys *.vrs ../../${tempdir}/doc/emacs
d175b0ae 665 ln makefile.w32-in ../../${tempdir}/doc/emacs
d175b0ae
RF
666 test -f Makefile.in && ln Makefile.in ../../${tempdir}/doc/emacs
667 ln ChangeLog ../../${tempdir}/doc/emacs
d175b0ae 668 cd ../../${tempdir}/doc/emacs
56c31c87
RS
669 rm -f \#*\# =* *~ core emacs-index* *.Z *.z xmail
670 rm -f emacs.?? termcap.?? gdb.?? *.log *.toc *.dvi *.oaux)
f7dbcf3c 671
d175b0ae
RF
672echo "Making links to \`doc/misc'"
673(cd doc/misc
4e1fb954 674 ln *.texi *.aux *.fns *.kys *.vrs ../../${tempdir}/doc/misc
d175b0ae 675 ln makefile.w32-in ../../${tempdir}/doc/misc
4e1fb954 676 ln gnus-news.el ../../${tempdir}/doc/misc
d175b0ae
RF
677 test -f README && ln README ../../${tempdir}/doc/misc
678 test -f Makefile.in && ln Makefile.in ../../${tempdir}/doc/misc
679 ln ChangeLog ../../${tempdir}/doc/misc
680 cp texinfo.tex ../../${tempdir}/doc/misc
681 cd ../../${tempdir}/doc/misc
682 rm -f \#*\# =* *~ core emacs-index* *.Z *.z xmail
683 rm -f emacs.?? termcap.?? gdb.?? *.log *.toc *.dvi *.oaux)
684
4e1fb954 685## FIXME book-spine.texinfo unused?
d175b0ae
RF
686echo "Making links to \`doc/lispref'"
687(cd doc/lispref
4e1fb954 688 ln *.texi *.aux *.fns *.kys *.vrs ../../${tempdir}/doc/lispref
d175b0ae
RF
689 ln *.txt *.el spellfile tindex.pl ../../${tempdir}/doc/lispref
690 ln makefile.w32-in ../../${tempdir}/doc/lispref
4e1fb954 691 ln book-spine.texinfo two-volume.make ../../${tempdir}/doc/lispref
d175b0ae
RF
692 test -f README && ln README ../../${tempdir}/doc/lispref
693 test -f Makefile.in && ln Makefile.in ../../${tempdir}/doc/lispref
694 ln ChangeLog ../../${tempdir}/doc/lispref
695 cd ../../${tempdir}/doc/lispref
1d951084
EZ
696 rm -f \#*\# =* *~ core elisp-index* *.Z *.z xmail
697 rm -f elisp.?? *.log *.toc *.dvi *.oaux)
698
d175b0ae
RF
699echo "Making links to \`doc/lispintro'"
700(cd doc/lispintro
4e1fb954 701 ln *.texi *.aux *.fns *.kys *.vrs *.eps ../../${tempdir}/doc/lispintro
d175b0ae 702 ln makefile.w32-in ../../${tempdir}/doc/lispintro
d175b0ae
RF
703 test -f README && ln README ../../${tempdir}/doc/lispintro
704 test -f Makefile.in && ln Makefile.in ../../${tempdir}/doc/lispintro
705 ln ChangeLog ../../${tempdir}/doc/lispintro
706 cd ../../${tempdir}/doc/lispintro
3716a206
EZ
707 rm -f \#*\# =* *~ core *.Z *.z xmail
708 rm -f emacs-lisp-intro.?? *.log *.toc *.dvi *.oaux)
709
d175b0ae
RF
710echo "Making links to \`doc/man'"
711(cd doc/man
265f3a4d
RF
712 ln *.1 ../../${tempdir}/doc/man
713 ln ChangeLog ../../${tempdir}/doc/man)
d175b0ae 714
6ab508db 715### It would be nice if they could all be symlinks to top-level copy, but
c87b230f 716### you're not supposed to have any symlinks in distribution tar files.
fd4bc580 717echo "Making sure copying notices are all copies of \`COPYING'"
9e2a2647 718for subdir in . etc info leim lib-src lisp lwlib msdos nt src; do
b37017c6 719 rm -f ${tempdir}/${subdir}/COPYING
fd4bc580 720 cp COPYING ${tempdir}/${subdir}
f7dbcf3c
JB
721done
722
1260d6ba 723if [ "${newer}" ]; then
21764d60 724 echo "Removing files older than $newer"
76fb0a58
JB
725 ## We remove .elc files unconditionally, on the theory that anyone picking
726 ## up an incremental distribution already has a running Emacs to byte-compile
727 ## them with.
1260d6ba
ER
728 find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
729fi
730
4746118a 731if [ "${make_tar}" = yes ]; then
922ac4c5 732 if [ "${default_gzip}" = "" ]; then
21764d60 733 echo "Looking for gzip"
922ac4c5
JB
734 temppath=`echo $PATH | sed 's/^:/.:/
735 s/::/:.:/g
736 s/:$/:./
737 s/:/ /g'`
738 default_gzip=`(
739 for dir in ${temppath}; do
740 if [ -f ${dir}/gzip ]; then echo 'gzip --best'; exit 0; fi
741 done
742 echo compress
743 )`
744 fi
f395c83a 745 case "${default_gzip}" in
37d6e313 746 bzip2) gzip_extension=.bz2 ;;
f395c83a 747 compress* ) gzip_extension=.Z ;;
ed398055 748 lzma) gzip_extension=.lzma ;;
0dc610dd 749 * ) gzip_extension=.gz ;;
f395c83a 750 esac
ca111811 751 echo "Creating tar file"
f395c83a
JB
752 (cd ${tempparent} ; tar cvf - ${emacsname} ) \
753 | ${default_gzip} \
754 > ${emacsname}.tar${gzip_extension}
4746118a 755fi
f7dbcf3c 756
4746118a 757if [ "${clean_up}" = yes ]; then
21764d60 758 echo "Cleaning up the staging directory"
f395c83a 759 rm -rf ${tempparent}
bb160193 760else
ca111811 761 (cd ${tempparent}; mv ${emacsname} ..)
bb160193 762 rm -rf ${tempparent}
f7dbcf3c 763fi
00c00348 764
ab5796a9 765# arch-tag: 26e3eb50-a394-4ab2-82b2-d8e5af500de7
76fb0a58 766### make-dist ends here