make-dist 23.2 KB
Newer Older
Jim Blandy's avatar
Jim Blandy committed
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 6 7
#### structure, and then hard links into it only those files that should
#### be distributed.  This means that if you add a file with an odd name,
#### you should make sure that this script will include it.
Jim Blandy's avatar
Jim Blandy committed
8

Glenn Morris's avatar
Glenn Morris committed
9
# Copyright (C) 1995, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005,
Glenn Morris's avatar
Glenn Morris committed
10
#   2006, 2007  Free Software Foundation, Inc.
Karl Heuer's avatar
Karl Heuer committed
11 12 13 14 15 16 17 18 19 20 21 22 23 24
#
# This file is part of GNU Emacs.
#
# GNU Emacs is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# GNU Emacs is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
Karl Heuer's avatar
Karl Heuer committed
25
# along with GNU Emacs; see the file COPYING.  If not, write to the
Lute Kamstra's avatar
Lute Kamstra committed
26 27
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
Karl Heuer's avatar
Karl Heuer committed
28

Jim Blandy's avatar
Jim Blandy committed
29 30
progname="$0"

31
### Exit if a command fails.
32
#set -e
Jim Blandy's avatar
Jim Blandy committed
33

34
### Print out each line we read, for debugging's sake.
35
#set -v
Jim Blandy's avatar
Jim Blandy committed
36

37 38 39 40 41 42
LANGUAGE=C
LC_ALL=C
LC_MESSAGES=
LANG=
export LANGUAGE LC_ALL LC_MESSAGES LANG

43
## Don't restrict access to any files.
44 45
umask 0

46
update=yes
Richard M. Stallman's avatar
Richard M. Stallman committed
47
check=yes
48 49
clean_up=no
make_tar=no
Eric S. Raymond's avatar
Eric S. Raymond committed
50
newer=""
Jim Blandy's avatar
Jim Blandy committed
51 52 53

while [ $# -gt 0 ]; do
  case "$1" in
54 55 56 57
    ## This option tells make-dist to delete the staging directory
    ## when done.  It is useless to use this unless you make a tar file.
    "--clean-up" )
      clean_up=yes
Jim Blandy's avatar
Jim Blandy committed
58
    ;;
59 60 61
    ## This option tells make-dist to make a tar file.
    "--tar" )
      make_tar=yes
Jim Blandy's avatar
Jim Blandy committed
62
    ;;
63 64 65 66
    ## This option tells make-dist not to recompile or do analogous things.
    "--no-update" )
      update=no
    ;;
Richard M. Stallman's avatar
Richard M. Stallman committed
67 68 69 70
    ## This option says don't check for bad file names, etc.
    "--no-check" )
      check=no
    ;;
71
    ## This option tells make-dist to make the distribution normally, then
72 73
    ## remove all files older than the given timestamp file.  This is useful
    ## for creating incremental or patch distributions.
Eric S. Raymond's avatar
Eric S. Raymond committed
74
    "--newer")
Jim Blandy's avatar
Jim Blandy committed
75 76
      newer="$2"
      new_extension=".new"
Eric S. Raymond's avatar
Eric S. Raymond committed
77 78
      shift
    ;;
79 80 81 82 83
    ## This option tells make-dist to use `compress' instead of gzip.
    ## Normally, make-dist uses gzip whenever it is present.
    "--compress")
      default_gzip="compress"
    ;;
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105

    "--snapshot")
      clean_up=yes
      make_tar=yes
      update=no
      check=no
     ;;

    "--help")
      echo "Usage: ${progname} [options]"
      echo ""
      echo "  --clean-up	delete staging directories when done"
      echo "  --compress	use compress instead of gzip"
      echo "  --newer=TIME	don't include files older than TIME"
      echo "  --no-check	don't check for bad file names etc."
      echo "  --no-update	don't recompile or do analogous things"
      echo "  --snapshot	same as --clean-up --no-update --tar --no-check"
      echo "  --tar		make a tar file"
      echo ""
      exit 0
    ;;

Jim Blandy's avatar
Jim Blandy committed
106 107 108 109 110 111 112 113
    * )
      echo "${progname}: Unrecognized argument: $1" >&2
      exit 1
    ;;
  esac
  shift
done

114
### Make sure we're running in the right place.
Jim Blandy's avatar
Jim Blandy committed
115
if [ ! -d src -o ! -f src/lisp.h -o ! -d lisp -o ! -f lisp/version.el ]; then
Eric S. Raymond's avatar
Eric S. Raymond committed
116 117
  echo "${progname}: Can't find \`src/lisp.h' and \`lisp/version.el'." >&2
  echo "${progname} must be run in the top directory of the Emacs" >&2
118
  echo "distribution tree.  cd to that directory and try again." >&2
Jim Blandy's avatar
Jim Blandy committed
119 120 121
  exit 1
fi

122
### Find where to run Emacs.
123
### (Accept only absolute file names.)
124 125
if [ $update = yes ];
then
126
  unset EMACS_UNIBYTE
127 128 129 130
  if [ -f src/emacs ];
  then
    EMACS=`pwd`/src/emacs
  else
131 132 133 134 135 136 137 138 139
    case $EMACS in
      /*) ;;
      *)
	if [ ! -f "$EMACS" ]; then
	  echo "$0: You must specify the EMACS environment variable " \
	       "to an absolute file name." 2>&1
	  exit 1
	fi;;
    esac
140 141 142
  fi
fi

143
### Find out which version of Emacs this is.
Richard M. Stallman's avatar
Richard M. Stallman committed
144
shortversion=`grep 'defconst[	 ]*emacs-version' lisp/version.el \
145
	 | sed -e 's/^.*"\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/'`
Richard M. Stallman's avatar
Richard M. Stallman committed
146 147
version=`grep 'defconst[	 ]*emacs-version' lisp/version.el \
	 | sed -e 's/^[^"]*"\([^"]*\)".*$/\1/'`
Jim Blandy's avatar
Jim Blandy committed
148
if [ ! "${version}" ]; then
149
  echo "${progname}: can't find current Emacs version in \`./lisp/version.el'" >&2
Jim Blandy's avatar
Jim Blandy committed
150 151 152
  exit 1
fi

153
echo Version numbers are $version and $shortversion
154

155 156
if [ $update = yes ];
then
157
  if grep -s "@set EMACSVER  *${shortversion}" ./man/emacs.texi > /dev/null; then
158 159 160 161 162
    true
  else
    echo "You must update the version number in \`./man/emacs.texi'"
    sleep 5
  fi
163 164
fi

165 166 167 168 169 170 171 172 173 174
### Make sure we don't already have a directory  emacs-${version}.

emacsname="emacs-${version}${new_extension}"

if [ -d ${emacsname} ]
then
  echo Directory "${emacsname}" already exists >&2
  exit 1
fi

175
### Make sure the subdirectory is available.
Eric S. Raymond's avatar
Eric S. Raymond committed
176
tempparent="make-dist.tmp.$$"
Jim Blandy's avatar
Jim Blandy committed
177
if [ -d ${tempparent} ]; then
Eric S. Raymond's avatar
Eric S. Raymond committed
178 179 180 181 182
  echo "${progname}: staging directory \`${tempparent}' already exists.
Perhaps a previous invocation of \`${progname}' failed to clean up after
itself.  Check that directories whose names are of the form
\`make-dist.tmp.NNNNN' don't contain any important information, remove
them, and try again." >&2
Jim Blandy's avatar
Jim Blandy committed
183 184 185
  exit 1
fi

Richard M. Stallman's avatar
Richard M. Stallman committed
186 187 188 189
### Find where to run Emacs.
if [ $check = yes ];
then
  ### Check for .elc files with no corresponding .el file.
190
  ls -1 lisp/[a-zA-Z]*.el lisp/[a-z]*/[a-zA-Z0-9]*.el \
191
	leim/[a-z]*/[a-z]*.el | sed 's/\.el$/.elc/' > /tmp/el
192
  ls -1 lisp/[a-zA-Z]*.elc lisp/[a-z]*/[a-zA-Z0-9]*.elc \
193
	leim/[a-z]*/[a-z]*.elc > /tmp/elc
Richard M. Stallman's avatar
Richard M. Stallman committed
194 195 196 197
  bogosities="`comm -13 /tmp/el /tmp/elc`"
  if [ "${bogosities}" != "" ]; then
    echo "The following .elc files have no corresponding .el files:"
    echo "${bogosities}"
198
  fi
Richard M. Stallman's avatar
Richard M. Stallman committed
199 200 201
  rm -f /tmp/el /tmp/elc

  ### Check for .el files with no corresponding .elc file.
202
  ls -1 lisp/[a-zA-Z]*.el lisp/[a-z]*/[a-zA-Z0-9]*.el \
203
	leim/[a-z]*/[a-z]*.el > /tmp/el
204
  ls -1 lisp/[a-zA-Z]*.elc lisp/[a-z]*/[a-zA-Z0-9]*.elc \
205
	leim/[a-z]*/[a-z]*.elc | sed 's/\.elc$/.el/' > /tmp/elc
Richard M. Stallman's avatar
Richard M. Stallman committed
206 207 208
  losers="`comm -23 /tmp/el /tmp/elc`"
  bogosities=
  for file in $losers; do
209
    if ! grep -q "no-byte-compile: t" $file; then
Richard M. Stallman's avatar
Richard M. Stallman committed
210 211 212 213 214 215 216 217 218 219 220 221 222 223
      case $file in
	site-init.el | site-load.el | site-start.el | default.el)
	  ;;
	*)
	  bogosities="$file $bogosities"
	  ;;
      esac
    fi
  done
  if [ x"${bogosities}" != x"" ]; then
    echo "The following .el files have no corresponding .elc files:"
    echo "${bogosities}"
  fi
  rm -f /tmp/el /tmp/elc
Karl Heuer's avatar
Karl Heuer committed
224 225
fi

226
### Make sure configure is newer than configure.in.
227
if [ "x`ls -t configure configure.in | sed q`" != "xconfigure" ]; then
228 229
  echo "\`./configure.in' is newer than \`./configure'" >&2
  echo "Running autoconf" >&2
230
  autoconf || { x=$?; echo Autoconf FAILED! >&2; exit $x; }
231 232
fi

Andreas Schwab's avatar
Andreas Schwab committed
233 234 235 236 237 238 239 240 241
### Make sure src/config-in.stamp is newer than configure.in.
if [ "x`ls -t src/stamp-h.in configure.in | sed q`" != "xsrc/stamp-h.in" ]; then
  echo "\`./configure.in' is newer than \`./src/stamp-h.in'" >&2
  echo "Running autoheader" >&2
  autoheader || { x=$?; echo Autoheader FAILED! >&2; exit $x; }
  rm -f src/stamp-h.in
  echo timestamp > src/stamp-h.in
fi

242 243 244
if [ $update = yes ];
then
  echo "Updating Info files"
245
  (cd man; make -f Makefile.in srcdir=. info)
246
  (cd lispref; make -f Makefile.in srcdir=. info)
247
  (cd lispintro; make -f Makefile.in SHELL=/bin/sh srcdir=. info VPATH=.)
Richard M. Stallman's avatar
Richard M. Stallman committed
248

249
  echo "Updating finder, custom and autoload data"
250
  (cd lisp; make updates EMACS="$EMACS")
251

252 253 254 255
  if test -f leim/leim-list.el; then
    echo "Updating leim-list.el"
    (cd leim; make leim-list.el EMACS="$EMACS")
  fi
256 257 258

  echo "Recompiling Lisp files"
  $EMACS -batch -f batch-byte-recompile-directory lisp leim
259
fi
Richard M. Stallman's avatar
Richard M. Stallman committed
260

Karl Heuer's avatar
Karl Heuer committed
261 262
echo "Making lisp/MANIFEST"

263 264 265
(cd lisp;
 files=`echo [!=]*.el | sed -e 's/ subdirs.el / /' -e 's/ default.el / /'`
 for dir in [!=]*; do
266 267
  if [ -d $dir ] && [ $dir != term ] && [ $dir != CVS ] && [ $dir != RCS ]
  then
268 269 270 271 272
    echo $dir
    thisdir=`echo $dir/[!=]*.el | sed -e 's/ subdirs.el / /'`
    files="$files $thisdir"
  fi
 done
273 274 275
 for file in $files
 do sed -n 's/^;;; //p; q' $file
 done | sort > MANIFEST)
Karl Heuer's avatar
Karl Heuer committed
276

Eric S. Raymond's avatar
Eric S. Raymond committed
277
echo "Creating staging directory: \`${tempparent}'"
278

Jim Blandy's avatar
Jim Blandy committed
279 280 281
mkdir ${tempparent}
tempdir="${tempparent}/${emacsname}"

282 283
### This trap ensures that the staging directory will be cleaned up even
### when the script is interrupted in mid-career.
Eric S. Raymond's avatar
Eric S. Raymond committed
284
if [ "${clean_up}" = yes ]; then
285
  trap "echo 'Interrupted...cleaning up the staging directory'; rm -rf ${tempparent}; exit 1" 1 2 15
Eric S. Raymond's avatar
Eric S. Raymond committed
286 287
fi

Eric S. Raymond's avatar
Eric S. Raymond committed
288
echo "Creating top directory: \`${tempdir}'"
Jim Blandy's avatar
Jim Blandy committed
289 290
mkdir ${tempdir}

291 292 293 294
### We copy in the top-level files before creating the subdirectories in
### hopes that this will make the top-level files appear first in the
### tar file; this means that people can start reading the INSTALL and
### README while the rest of the tar file is still unpacking.  Whoopee.
295
echo "Making links to top-level files"
296
ln AUTHORS FTP INSTALL README BUGS CONTRIBUTE move-if-change ${tempdir}
297
ln ChangeLog Makefile.in configure configure.in ${tempdir}
298
ln config.bat make-dist update-subdirs vpath.sed ${tempdir}
299
### Copy these files; they're cross-filesystem symlinks.
300
cp mkinstalldirs ${tempdir}
301
cp config.sub ${tempdir}
Richard M. Stallman's avatar
Richard M. Stallman committed
302
cp config.guess ${tempdir}
303
cp install-sh ${tempdir}
Jim Blandy's avatar
Jim Blandy committed
304

305
echo "Updating version number in README"
306 307 308 309 310
(cd ${tempdir}
 awk \
   '$1 " " $2 " " $3 " " $4 " " $5 == "This directory tree holds version" { $6 = version; print $0 }
    $1 " " $2 " " $3 " " $4 " " $5 != "This directory tree holds version"' \
   version=${version} README > tmp.README
311
 mv -f tmp.README README)
312 313


314
echo "Creating subdirectories"
315
for subdir in lisp site-lisp lispref lispintro \
Pavel Janík's avatar
Pavel Janík committed
316
	      leim leim/CXTERM-DIC leim/MISC-DIC \
317
	      leim/SKK-DIC leim/ja-dic leim/quail \
318
	      src src/m src/s src/bitmaps lib-src oldXMenu lwlib \
319
	      nt nt/inc nt/inc/sys nt/inc/arpa nt/inc/netinet nt/icons \
320
	      etc etc/e \
321
	      etc/images etc/images/ezimage etc/images/gnus etc/images/gud \
Romain Francoise's avatar
Romain Francoise committed
322 323 324 325
	      etc/images/icons etc/images/low-color etc/images/mail \
	      etc/images/smilies etc/tree-widget etc/tree-widget/default \
	      etc/tree-widget/folder info man m4 msdos vms mac mac/inc \
	      mac/inc/sys mac/src mac/Emacs.app mac/Emacs.app/Contents \
326 327
	      mac/Emacs.app/Contents/MacOS mac/Emacs.app/Contents/Resources \
	      mac/Emacs.app/Contents/Resources/English.lproj
328 329
do
  echo "  ${tempdir}/${subdir}"
Jim Blandy's avatar
Jim Blandy committed
330 331 332
  mkdir ${tempdir}/${subdir}
done

333
echo "Making links to \`lisp' and its subdirectories"
334
### Don't distribute TAGS, =*.el files, site-init.el, site-load.el, or default.el.
Jim Blandy's avatar
Jim Blandy committed
335 336 337
(cd lisp
 ln [a-zA-Z]*.el ../${tempdir}/lisp
 ln [a-zA-Z]*.elc ../${tempdir}/lisp
338
 ln [a-zA-Z]*.dat ../${tempdir}/lisp
339
 for img in [a-zA-Z]*.xpm [a-zA-Z]*.xbm [a-zA-Z]*.pbm; do
340 341 342 343 344
   # If there are no images, the shell won't expand the pattern.
   if [ -f $img ]; then
     ln $img ../${tempdir}/lisp
   fi
 done
345 346
 ## simula.el doesn't keep abbreviations in simula.defns any more.
 ## ln [a-zA-Z]*.defns ../${tempdir}/lisp
347 348
 ln ChangeLog ChangeLog.*[0-9] ../${tempdir}/lisp
 ln Makefile.in makefile.w32-in ../${tempdir}/lisp
349
 test -f README && ln README ../${tempdir}/lisp
350 351 352 353 354 355 356 357 358 359 360
 (cd ../${tempdir}/lisp
  rm -f TAGS =*
  rm -f site-init site-init.el site-init.elc
  rm -f site-load site-load.el site-load.elc
  rm -f site-start site-start.el site-start.elc
  rm -f default default.el default.elc
  )

 ## Find all subdirs of lisp dir
 for file in `find . -type d -print`; do
   case $file in
361
     . | .. | */Old | */CVS | */RCS | */=*)
362
       ;;
363 364 365 366 367 368 369 370 371 372 373
     *)
       if [ -d $file ]; then
	 subdirs="$file $subdirs"
       fi
       ;;
   esac
 done

 for file in $subdirs; do
   echo "  lisp/$file"
   mkdir ../${tempdir}/lisp/$file
374 375 376
   ln $file/[a-zA-Z0-9]*.el ../${tempdir}/lisp/$file
   ln $file/[a-zA-Z0-9]*.elc ../${tempdir}/lisp/$file
   for img in $file/[a-zA-Z]*.xpm $file/[a-zA-Z]*.xbm $file/[a-zA-Z]*.pbm; do
377 378 379 380
     if [ -f $img ]; then
       ln $img ../${tempdir}/lisp/$file
     fi
   done
381 382 383
   if [ -f $file/README ]; then
     ln $file/README ../${tempdir}/lisp/$file
   fi
384

385 386
   if [ -f $file/ChangeLog ]; then
     ln $file/ChangeLog ../${tempdir}/lisp/$file
387
     for f in $file/ChangeLog.*[0-9]; do
388 389 390 391
       if [ -f $f ]; then
	 ln $f ../${tempdir}/lisp/$file
       fi
     done
392
   fi
393
 done )
394

395
echo "Making links to \`leim' and its subdirectories"
396 397
### Don't distribute TAGS, or =*.el files.
(cd leim
398
 ln makefile.w32-in ../${tempdir}/leim
399 400 401 402 403 404 405
 ln ChangeLog README ../${tempdir}/leim

 ln CXTERM-DIC/*.tit ../${tempdir}/leim/CXTERM-DIC
 ln SKK-DIC/README SKK-DIC/SKK-JISYO.L ../${tempdir}/leim/SKK-DIC
 ln MISC-DIC/*.* ../${tempdir}/leim/MISC-DIC
 ln ja-dic/*.el ja-dic/*.elc ../${tempdir}/leim/ja-dic
 ln Makefile.in ../${tempdir}/leim/Makefile.in
Kenichi Handa's avatar
Kenichi Handa committed
406
 ln leim-ext.el ../${tempdir}/leim/leim-ext.el
407 408
 ## Lisp files that start with a capital are generated from TIT
 ## dictionaries so we don't distribute them.
409 410 411 412 413 414 415
 ln quail/[a-z]*.el quail/[a-z]*.elc ../${tempdir}/leim/quail
 rm -f ../${tempdir}/leim/quail/quick-b5.*
 rm -f ../${tempdir}/leim/quail/quick-cns.*
 rm -f ../${tempdir}/leim/quail/tsang-b5.*
 rm -f ../${tempdir}/leim/quail/tsang-cns.*

 cd ../${tempdir}/leim
416 417
 rm -f TAGS =* */=*)

418
echo "Making links to \`src'"
419
### Don't distribute =*.[ch] files, or the configured versions of
420
### config.in, paths.in, or Makefile.in, or TAGS.
Jim Blandy's avatar
Jim Blandy committed
421
(cd src
422
 echo "  (It is ok if ln fails in some cases.)"
Jim Blandy's avatar
Jim Blandy committed
423 424 425
 ln [a-zA-Z]*.c ../${tempdir}/src
 ln [a-zA-Z]*.h ../${tempdir}/src
 ln [a-zA-Z]*.s ../${tempdir}/src
426 427 428 429 430 431 432 433 434
 ln [a-zA-Z]*.in ../${tempdir}/src
 ln [a-zA-Z]*.opt ../${tempdir}/src
 ## If we ended up with a symlink, or if we did not get anything
 ## due to a cross-device symlink, copy the file.
 for file in [a-zA-Z]*.[hcs] [a-zA-Z]*.in [a-zA-Z]*.opt; do
   if test -f ../${tempdir}/src/$file; then
     # test -f appears to succeed for a symlink
     if test -L ../${tempdir}/src/$file; then
       rm ../${tempdir}/src/$file
435
       cp -p $file ../${tempdir}/src
436 437 438 439
       chmod a-w ../${tempdir}/src/$file
     fi
   else
     rm ../${tempdir}/src/$file
440
     cp -p $file ../${tempdir}/src
441 442 443 444
     chmod a-w ../${tempdir}/src/$file
   fi
 done
 ln README ChangeLog ChangeLog.*[0-9] ../${tempdir}/src
445
 ln makefile.w32-in ../${tempdir}/src
446
 ln .gdbinit .dbxinit ../${tempdir}/src
Jim Blandy's avatar
Jim Blandy committed
447
 cd ../${tempdir}/src
448
 rm -f config.h epaths.h Makefile Makefile.c
449
 rm -f =* TAGS)
Jim Blandy's avatar
Jim Blandy committed
450

451
echo "Making links to \`src/bitmaps'"
452 453 454
(cd src/bitmaps
 ln README *.xbm ../../${tempdir}/src/bitmaps)

455
echo "Making links to \`src/m'"
Jim Blandy's avatar
Jim Blandy committed
456
(cd src/m
457 458
 # We call files for miscellaneous input (to linker etc) .inp.
 ln README [a-zA-Z0-9]*.h *.inp ../../${tempdir}/src/m)
Jim Blandy's avatar
Jim Blandy committed
459

460
echo "Making links to \`src/s'"
Jim Blandy's avatar
Jim Blandy committed
461
(cd src/s
462
 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/s)
Jim Blandy's avatar
Jim Blandy committed
463

464
echo "Making links to \`lib-src'"
Jim Blandy's avatar
Jim Blandy committed
465
(cd lib-src
466
 ln [a-zA-Z]*.[chy] ../${tempdir}/lib-src
467
 ln ChangeLog Makefile.in README testfile vcdiff ../${tempdir}/lib-src
468
 ln grep-changelog rcs2log rcs-checkin ../${tempdir}/lib-src
469
 ln makefile.w32-in ../${tempdir}/lib-src
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485
 ## If we ended up with a symlink, or if we did not get anything
 ## due to a cross-device symlink, copy the file.
 for file in [a-zA-Z]*.[chy]; do
   if test -f ../${tempdir}/lib-src/$file; then
     # test -f appears to succeed for a symlink
     if test -L ../${tempdir}/lib-src/$file; then
       rm ../${tempdir}/lib-src/$file
       cp $file ../${tempdir}/lib-src
       chmod a-w ../${tempdir}/lib-src/$file
     fi
   else
     rm ../${tempdir}/lib-src/$file
     cp $file ../${tempdir}/lib-src
     chmod a-w ../${tempdir}/lib-src/$file
   fi
 done
Eric S. Raymond's avatar
Eric S. Raymond committed
486
 cd ../${tempdir}/lib-src
487
 rm -f Makefile.c
488
 rm -f getopt.h
489
 rm -f =* TAGS)
Jim Blandy's avatar
Jim Blandy committed
490

491 492 493 494
echo "Making links to \`m4'"
(cd m4
 ln *.m4 ../${tempdir}/m4)

495
echo "Making links to \`nt'"
496
(cd nt
497 498
 ln emacs.rc config.nt [a-z]*.c ../${tempdir}/nt
 ln nmake.defs gmake.defs subdirs.el ../${tempdir}/nt
499
 ln [a-z]*.bat [a-z]*.h ../${tempdir}/nt
500
 ln ChangeLog INSTALL README makefile.w32-in ../${tempdir}/nt)
501

502
echo "Making links to \`nt/inc'"
503
(cd nt/inc
504
 ln [a-z]*.h ../../${tempdir}/nt/inc)
505

506
echo "Making links to \`nt/inc/sys'"
507
(cd nt/inc/sys
508
 ln [a-z]*.h ../../../${tempdir}/nt/inc/sys)
509

510 511 512 513 514 515 516 517
echo "Making links to \`nt/inc/arpa'"
(cd nt/inc/arpa
 ln [a-z]*.h ../../../${tempdir}/nt/inc/arpa)

echo "Making links to \`nt/inc/netinet'"
(cd nt/inc/netinet
 ln [a-z]*.h ../../../${tempdir}/nt/inc/netinet)

518 519
echo "Making links to \`nt/icons'"
(cd nt/icons
520 521
 ln [a-z]*.ico ../../${tempdir}/nt/icons
 ln [a-z]*.cur ../../${tempdir}/nt/icons)
522

523 524
echo "Making links to \`mac'"
(cd mac
525
 ln ChangeLog INSTALL README make-package *.xml *.MPW ../${tempdir}/mac)
526 527 528 529 530 531 532 533 534 535 536 537 538

echo "Making links to \`mac/inc'"
(cd mac/inc
 ln [a-z]*.h ../../${tempdir}/mac/inc)

echo "Making links to \`mac/inc/sys'"
(cd mac/inc/sys
 ln [a-z]*.h ../../../${tempdir}/mac/inc/sys)

echo "Making links to \`mac/src'"
(cd mac/src
 ln [a-z]*.c *.r ../../${tempdir}/mac/src)

539 540 541 542
echo "Making links to \`mac/Emacs.app/Contents'"
(cd mac/Emacs.app/Contents
 ln Info.plist PkgInfo ../../../${tempdir}/mac/Emacs.app/Contents)

543 544 545 546
echo "Making links to \`mac/Emacs.app/Contents/Resources'"
(cd mac/Emacs.app/Contents/Resources
 ln Emacs.icns ../../../../${tempdir}/mac/Emacs.app/Contents/Resources)

547 548 549
echo "Making links to \`mac/Emacs.app/Contents/Resources/English.lproj'"
(cd mac/Emacs.app/Contents/Resources/English.lproj
 ln InfoPlist.strings ../../../../../${tempdir}/mac/Emacs.app/Contents/Resources/English.lproj)
550

551
echo "Making links to \`msdos'"
552 553
(cd msdos
 ln  ChangeLog emacs.ico emacs.pif ../${tempdir}/msdos
554
 ln is_exec.c sigaction.c mainmake mainmake.v2 sed*.inp ../${tempdir}/msdos
555 556 557
 cd ../${tempdir}/msdos
 rm -f =*)

558
echo "Making links to \`oldXMenu'"
Jim Blandy's avatar
Jim Blandy committed
559
(cd oldXMenu
560
 ln *.c *.h *.in ../${tempdir}/oldXMenu
561
 ln README Imakefile ChangeLog ../${tempdir}/oldXMenu
562
 ln compile.com descrip.mms ../${tempdir}/oldXMenu)
Jim Blandy's avatar
Jim Blandy committed
563

564
echo "Making links to \`lwlib'"
565 566
(cd lwlib
 ln *.c *.h *.in ../${tempdir}/lwlib
Pavel Janík's avatar
Pavel Janík committed
567
 ln README ChangeLog ../${tempdir}/lwlib)
568

569
echo "Making links to \`etc'"
570 571
### Don't distribute = files, TAGS, DOC files, backups, autosaves, or
### tex litter.
572
### Don't distribute gfdl.1, since no man page references it.
Jim Blandy's avatar
Jim Blandy committed
573
(cd etc
574 575
 files=`ls -d * | grep -v CVS | grep -v RCS | grep -v 'Old' | grep -v '^e$' \
        | grep -v '^images$' | grep -v '^tree-widget$'`
576
 ln $files ../${tempdir}/etc
577 578
 ## If we ended up with a symlink, or if we did not get anything
 ## due to a cross-device symlink, copy the file.
579
 for file in $files; do
580 581 582 583 584 585 586 587 588 589 590 591 592
   if test -f ../${tempdir}/etc/$file; then
     # test -f appears to succeed for a symlink
     if test -L ../${tempdir}/etc/$file; then
       rm ../${tempdir}/etc/$file
       cp $file ../${tempdir}/etc
       chmod a-w ../${tempdir}/etc/$file
     fi
   else
     rm ../${tempdir}/etc/$file
     cp $file ../${tempdir}/etc
     chmod a-w ../${tempdir}/etc/$file
   fi
 done
Jim Blandy's avatar
Jim Blandy committed
593
 cd ../${tempdir}/etc
594
 rm -f fns*.el gfdl.1
595
 rm -f DOC* *~ \#*\# *.dvi *.log *.orig *.rej *,v =* core
596
 rm -f TAGS)
Jim Blandy's avatar
Jim Blandy committed
597

598
echo "Making links to \`etc/e'"
599
(cd etc/e
600
 ln `ls -d * | grep -v CVS | grep -v RCS` ../../${tempdir}/etc/e
601
 cd ../../${tempdir}/etc/e
602
 rm -f *~ \#*\# *,v =* core)
603

604 605 606 607 608 609 610 611
echo "Making links to \`etc/images'"
(cd etc/images
 for img in [a-zA-Z]*.xpm [a-zA-Z]*.xbm [a-zA-Z]*.pbm; do
   if [ -f $img ]; then
     ln $img ../../${tempdir}/etc/images
   fi
 done)

Romain Francoise's avatar
Romain Francoise committed
612
for dir in etc/images/ezimage etc/images/gnus etc/images/gud etc/images/icons \
613
           etc/images/low-color etc/images/mail etc/images/smilies \
614
           etc/tree-widget/default etc/tree-widget/folder ; do
615 616 617 618 619 620 621
    echo "Making links to \`${dir}'"
    (cd ${dir}
     ln `ls -d * | grep -v CVS | grep -v RCS` ../../../${tempdir}/${dir}
     cd ../../../${tempdir}/${dir}
     rm -f *~ \#*\# *,v =* core)
done

622
echo "Making links to \`info'"
623 624
# Don't distribute backups or autosaves.
(cd info
625
 ln `find . -type f -print | grep -v CVS | grep -v RCS | grep -v cvsignore` ../${tempdir}/info
626
 #ln [a-zA-Z]* ../${tempdir}/info
627 628 629 630
 cd ../${tempdir}/info
 # Avoid an error when expanding the wildcards later.
 ln emacs dummy~ ; ln emacs \#dummy\#
 rm -f *~ \#*\# core)
631

632
echo "Making links to \`man'"
633
(cd man
634
 ln *.texi *.aux *.cps *.fns *.kys *.vrs ../${tempdir}/man
635
 ln makefile.w32-in ../${tempdir}/man
636
 test -f README && ln README ../${tempdir}/man
637
 test -f Makefile.in && ln Makefile.in ../${tempdir}/man
638 639
 ln ChangeLog ../${tempdir}/man
 test -f split-man && ln split-man ../${tempdir}/man
640
 cp texinfo.tex ../${tempdir}/man
Richard M. Stallman's avatar
Richard M. Stallman committed
641
 cd ../${tempdir}/man
642 643
 rm -f \#*\# =* *~ core emacs-index* *.Z *.z xmail
 rm -f emacs.?? termcap.?? gdb.?? *.log *.toc *.dvi *.oaux)
Jim Blandy's avatar
Jim Blandy committed
644

645 646
echo "Making links to \`lispref'"
(cd lispref
647
 ln `ls -1 *.texi` ../${tempdir}/lispref
648 649
 ln *.aux *.cps *.fns *.kys *.vrs ../${tempdir}/lispref
 ln *.txt *.el spellfile tindex.pl ../${tempdir}/lispref
650
 ln makefile.w32-in ../${tempdir}/lispref
651 652 653 654 655 656 657
 test -f README && ln README ../${tempdir}/lispref
 test -f Makefile.in && ln Makefile.in ../${tempdir}/lispref
 ln ChangeLog ../${tempdir}/lispref
 cd ../${tempdir}/lispref
 rm -f \#*\# =* *~ core elisp-index* *.Z *.z xmail
 rm -f elisp.?? *.log *.toc *.dvi *.oaux)

658 659 660
echo "Making links to \`lispintro'"
(cd lispintro
 ln *.texi *.aux *.cps *.fns *.kys *.vrs *.eps ../${tempdir}/lispintro
661
 ln makefile.w32-in ../${tempdir}/lispintro
662 663 664 665 666 667 668 669
 test -f texinfo.tex && ln texinfo.tex ../${tempdir}/lispintro
 test -f README && ln README ../${tempdir}/lispintro
 test -f Makefile.in && ln Makefile.in ../${tempdir}/lispintro
 ln ChangeLog ../${tempdir}/lispintro
 cd ../${tempdir}/lispintro
 rm -f \#*\# =* *~ core *.Z *.z xmail
 rm -f emacs-lisp-intro.?? *.log *.toc *.dvi *.oaux)

670
echo "Making links to \`vms'"
Jim Blandy's avatar
Jim Blandy committed
671
(cd vms
672
 test -f README && ln README ../${tempdir}/vms
Jim Blandy's avatar
Jim Blandy committed
673 674 675
 cd ../${tempdir}/vms
 rm -f *~)

Pavel Janík's avatar
Pavel Janík committed
676
### It would be nice if they could all be symlinks to top-level copy, but
677
### you're not supposed to have any symlinks in distribution tar files.
678
echo "Making sure copying notices are all copies of \`COPYING'"
679
for subdir in . etc info leim lib-src lisp lwlib mac msdos nt src; do
680
  rm -f ${tempdir}/${subdir}/COPYING
681
  cp COPYING ${tempdir}/${subdir}
Jim Blandy's avatar
Jim Blandy committed
682 683
done

684 685 686
#### Make sure that there aren't any hard links between files in the
#### distribution; people with afs can't deal with that.  Okay,
#### actually we just re-copy anything with a link count greater
687 688 689
#### than two.  (Yes, strictly greater than 2 is correct; since we
#### created these files by linking them in from the original tree,
#### they'll have exactly two links normally.)
Karl Heuer's avatar
Karl Heuer committed
690
####
Karl Heuer's avatar
Karl Heuer committed
691
#### Commented out since it's not strictly necessary; it should suffice
Karl Heuer's avatar
Karl Heuer committed
692
#### to just break the link on alloca.c.
693 694 695
#echo "Breaking intra-tree links."
#find ${tempdir} ! -type d -links +2 \
#  -exec cp -p {} $$ \; -exec rm -f {} \; -exec mv $$ {} \;
Karl Heuer's avatar
Karl Heuer committed
696 697
rm -f $tempdir/lib-src/alloca.c
cp $tempdir/src/alloca.c $tempdir/lib-src/alloca.c
698

Eric S. Raymond's avatar
Eric S. Raymond committed
699
if [ "${newer}" ]; then
700
  echo "Removing files older than $newer"
701 702 703
  ## We remove .elc files unconditionally, on the theory that anyone picking
  ## up an incremental distribution already has a running Emacs to byte-compile
  ## them with.
Eric S. Raymond's avatar
Eric S. Raymond committed
704 705 706
  find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
fi

Jim Blandy's avatar
Jim Blandy committed
707
if [ "${make_tar}" = yes ]; then
708
  if [ "${default_gzip}" = "" ]; then
709
    echo "Looking for gzip"
710 711 712 713 714 715 716 717 718 719 720
    temppath=`echo $PATH | sed 's/^:/.:/
				s/::/:.:/g
				s/:$/:./
				s/:/ /g'`
    default_gzip=`(
      for dir in ${temppath}; do
	if [ -f ${dir}/gzip ]; then echo 'gzip --best'; exit 0; fi
      done
      echo compress
    )`
  fi
721 722
  case "${default_gzip}" in
    compress* ) gzip_extension=.Z ;;
723
    * )         gzip_extension=.gz ;;
724
  esac
725
  echo "Creating tar file"
726 727 728
  (cd ${tempparent} ; tar cvf - ${emacsname} ) \
    | ${default_gzip} \
    > ${emacsname}.tar${gzip_extension}
Jim Blandy's avatar
Jim Blandy committed
729
fi
Jim Blandy's avatar
Jim Blandy committed
730

Jim Blandy's avatar
Jim Blandy committed
731
if [ "${clean_up}" = yes ]; then
732
  echo "Cleaning up the staging directory"
733
  rm -rf ${tempparent}
734
else
735
  (cd ${tempparent}; mv ${emacsname} ..)
736
  rm -rf ${tempparent}
Jim Blandy's avatar
Jim Blandy committed
737
fi
Eric S. Raymond's avatar
Eric S. Raymond committed
738

Miles Bader's avatar
Miles Bader committed
739
# arch-tag: 26e3eb50-a394-4ab2-82b2-d8e5af500de7
740
### make-dist ends here