make-dist 13.5 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

Karl Heuer's avatar
Karl Heuer committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
# Copyright (C) 1995 Free Software Foundation, Inc.
#
# 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
# along with GNU Emacs; see the file COPYING.  If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.

Jim Blandy's avatar
Jim Blandy committed
27 28
progname="$0"

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

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

Jim Blandy's avatar
Jim Blandy committed
35 36
clean_up=yes
make_tar=yes
Eric S. Raymond's avatar
Eric S. Raymond committed
37
newer=""
Jim Blandy's avatar
Jim Blandy committed
38 39 40

while [ $# -gt 0 ]; do
  case "$1" in
41 42
    ## This option tells make-dist not to delete the staging directory
    ## after it's done making the tar file.
Eric S. Raymond's avatar
Eric S. Raymond committed
43
    "--no-clean-up" )
Jim Blandy's avatar
Jim Blandy committed
44 45
      clean_up=no
    ;;
46 47 48
    ## This option tells make-dist not to make a tar file.  Since it's 
    ## rather pointless to build the whole staging directory and then
    ## nuke it, using this option also selects '--no-clean-up'.
Jim Blandy's avatar
Jim Blandy committed
49 50 51
    "--no-tar" )
      make_tar=no
      clean_up=no
Jim Blandy's avatar
Jim Blandy committed
52
    ;;
53
    ## This option tells make-dist to make the distribution normally, then
54 55
    ## 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
56
    "--newer")
Jim Blandy's avatar
Jim Blandy committed
57 58
      newer="$2"
      new_extension=".new"
Eric S. Raymond's avatar
Eric S. Raymond committed
59 60
      shift
    ;;
61 62 63 64 65
    ## This option tells make-dist to use `compress' instead of gzip.
    ## Normally, make-dist uses gzip whenever it is present.
    "--compress")
      default_gzip="compress"
    ;;
Jim Blandy's avatar
Jim Blandy committed
66 67 68 69 70 71 72 73
    * )
      echo "${progname}: Unrecognized argument: $1" >&2
      exit 1
    ;;
  esac
  shift
done

74
### Make sure we're running in the right place.
Jim Blandy's avatar
Jim Blandy committed
75
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
76 77
  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
78
  echo "distribution tree.  cd to that directory and try again." >&2
Jim Blandy's avatar
Jim Blandy committed
79 80 81
  exit 1
fi

82
### Find out which version of Emacs this is.
Richard M. Stallman's avatar
Richard M. Stallman committed
83
shortversion=`grep 'defconst[	 ]*emacs-version' lisp/version.el \
84
	 | sed -e 's/^.*"\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/'`
Richard M. Stallman's avatar
Richard M. Stallman committed
85 86
version=`grep 'defconst[	 ]*emacs-version' lisp/version.el \
	 | sed -e 's/^[^"]*"\([^"]*\)".*$/\1/'`
Jim Blandy's avatar
Jim Blandy committed
87
if [ ! "${version}" ]; then
Richard M. Stallman's avatar
Richard M. Stallman committed
88
  echo "${progname}: can't find current Emacs version in \`./lisp/version.el'." >&2
Jim Blandy's avatar
Jim Blandy committed
89 90 91
  exit 1
fi

92 93
echo $version and $shortversion

Richard M. Stallman's avatar
Richard M. Stallman committed
94
if grep -s "GNU Emacs version ${shortversion}" ./man/emacs.texi > /dev/null; then
95 96 97
  true
else
  echo "You must update the version number in \`./man/emacs.texi'"
98
  sleep 5
99 100
fi

101 102 103 104 105 106 107 108 109 110
### 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

111
### Make sure the subdirectory is available.
Eric S. Raymond's avatar
Eric S. Raymond committed
112
tempparent="make-dist.tmp.$$"
Jim Blandy's avatar
Jim Blandy committed
113
if [ -d ${tempparent} ]; then
Eric S. Raymond's avatar
Eric S. Raymond committed
114 115 116 117 118
  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
119 120 121
  exit 1
fi

122 123 124
### Check for .elc files with no corresponding .el file.
ls -1 lisp/*.el | sed 's/\.el$/.elc/' > /tmp/el
ls -1 lisp/*.elc > /tmp/elc
125 126 127 128 129
bogosities="`comm -13 /tmp/el /tmp/elc`"
if [ "${bogosities}" != "" ]; then
  echo "The following .elc files have no corresponding .el files:"
  echo "${bogosities}"
fi
130
rm -f /tmp/el /tmp/elc
131

132 133
### Make sure configure is newer than configure.in.
if [ "x`ls -t configure configure.in | head -1`" != "xconfigure" ]; then
134
  echo "\`./configure.in' seems to be newer than \`./configure.'" >&2
135 136 137 138
  echo "Attempting to run autoconf." >&2
  autoconf
fi

Richard M. Stallman's avatar
Richard M. Stallman committed
139
### Update getdate.c.
Richard M. Stallman's avatar
Richard M. Stallman committed
140
(cd lib-src; make -f Makefile getdate.c YACC="bison -y")
Richard M. Stallman's avatar
Richard M. Stallman committed
141

Richard M. Stallman's avatar
Richard M. Stallman committed
142 143 144 145
echo "Updating Info files."

(cd man; make info)

Richard M. Stallman's avatar
Richard M. Stallman committed
146 147 148
echo "Updating finder-inf.el."

### update finder-inf.el.
149 150
(cd lisp; ../src/emacs -batch -l finder -f finder-compile-keywords)
(cd lisp; ../src/emacs -batch -f batch-byte-compile finder-inf.el)
Richard M. Stallman's avatar
Richard M. Stallman committed
151

Karl Heuer's avatar
Karl Heuer committed
152 153 154 155
echo "Making lisp/MANIFEST"

(cd lisp; head -1 *.el | grep '^;' | sed -e 's/;;; //' > MANIFEST)

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

Jim Blandy's avatar
Jim Blandy committed
158 159 160
mkdir ${tempparent}
tempdir="${tempparent}/${emacsname}"

161 162
### 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
163 164 165 166
if [ "${clean_up}" = yes ]; then
  trap "echo 'Interrupted...cleaning up the staging directory.'; rm -rf ${tempparent}; exit 1" 1 2 15
fi

Eric S. Raymond's avatar
Eric S. Raymond committed
167
echo "Creating top directory: \`${tempdir}'"
Jim Blandy's avatar
Jim Blandy committed
168 169
mkdir ${tempdir}

170 171 172 173
### 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.
Eric S. Raymond's avatar
Eric S. Raymond committed
174
echo "Making links to top-level files." 
175
ln GETTING.GNU.SOFTWARE INSTALL PROBLEMS README BUGS move-if-change ${tempdir}
176
ln ChangeLog Makefile.in configure configure.in ${tempdir}
177
ln config.bat make-dist update-subdirs vpath.sed ${tempdir}
178
### Copy these files; they're cross-filesystem symlinks.
179
cp mkinstalldirs ${tempdir}
180
cp config.sub ${tempdir}
Richard M. Stallman's avatar
Richard M. Stallman committed
181
cp config.guess ${tempdir}
182
cp install.sh ${tempdir}
Jim Blandy's avatar
Jim Blandy committed
183

184 185 186 187 188 189 190 191 192
echo "Updating version number in README."
(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
 mv tmp.README README)


Jim Blandy's avatar
Jim Blandy committed
193
echo "Creating subdirectories."
194
for subdir in lisp lisp/term site-lisp \
195
	      src src/m src/s src/bitmaps lib-src oldXMenu lwlib \
196
	      nt nt/inc nt/inc/sys \
197
	      etc etc/e lock cpp info man msdos vms; do
Jim Blandy's avatar
Jim Blandy committed
198 199 200
  mkdir ${tempdir}/${subdir}
done

Eric S. Raymond's avatar
Eric S. Raymond committed
201
echo "Making links to \`lisp'."
202
### Don't distribute TAGS, =*.el files, site-init.el, site-load.el, or default.el.
Jim Blandy's avatar
Jim Blandy committed
203 204 205
(cd lisp
 ln [a-zA-Z]*.el ../${tempdir}/lisp
 ln [a-zA-Z]*.elc ../${tempdir}/lisp
206
 ln [a-zA-Z]*.dat ../${tempdir}/lisp
207 208
 ## simula.el doesn't keep abbreviations in simula.defns any more.
 ## ln [a-zA-Z]*.defns ../${tempdir}/lisp
209
 ln ChangeLog Makefile makefile.nt ChangeLog.? README dired.todo ../${tempdir}/lisp
Jim Blandy's avatar
Jim Blandy committed
210
 cd ../${tempdir}/lisp
211
 rm -f TAGS =*
Richard M. Stallman's avatar
Richard M. Stallman committed
212
 rm -f subdirs.el
Jim Blandy's avatar
Jim Blandy committed
213
 rm -f site-init site-init.el site-init.elc
Jim Blandy's avatar
Jim Blandy committed
214
 rm -f site-load site-load.el site-load.elc
215
 rm -f site-start site-start.el site-start.elc
Jim Blandy's avatar
Jim Blandy committed
216
 rm -f default default.el default.elc)
Jim Blandy's avatar
Jim Blandy committed
217

218 219 220 221 222 223 224 225 226
#echo "Making links to \`lisp/calc-2.02'."
#### Don't distribute =*.el files, TAGS or backups.
#(cd lisp/calc-2.02
# ln [a-zA-Z]*.el ../../${tempdir}/lisp/calc-2.02
# ln [a-zA-Z]*.elc ../../${tempdir}/lisp/calc-2.02
# ln calc.info* calc.texinfo calc-refcard.* ../../${tempdir}/lisp/calc-2.02
# ln INSTALL Makefile README README.prev ../../${tempdir}/lisp/calc-2.02
# cd ../../${tempdir}/lisp/calc-2.02
# rm -f *~ TAGS)
227

Eric S. Raymond's avatar
Eric S. Raymond committed
228
echo "Making links to \`lisp/term'."
229
### Don't distribute =*.el files or TAGS.
Jim Blandy's avatar
Jim Blandy committed
230 231 232
(cd lisp/term
 ln [a-zA-Z]*.el ../../${tempdir}/lisp/term
 ln [a-zA-Z]*.elc ../../${tempdir}/lisp/term
233
 ln README ../../${tempdir}/lisp/term
234
 rm -f =* TAGS)
Jim Blandy's avatar
Jim Blandy committed
235

Eric S. Raymond's avatar
Eric S. Raymond committed
236
echo "Making links to \`src'."
237
### Don't distribute =*.[ch] files, or the configured versions of
238
### config.in, paths.in, or Makefile.in, or TAGS.
Jim Blandy's avatar
Jim Blandy committed
239
(cd src
240
 echo "  (If we can't link gmalloc.c, that's okay.)"
Jim Blandy's avatar
Jim Blandy committed
241
 ln [a-zA-Z]*.c ../${tempdir}/src
242
 ## Might be a symlink to a file on another filesystem.
Jim Blandy's avatar
Jim Blandy committed
243
 test -f ../${tempdir}/src/gmalloc.c || cp gmalloc.c ../${tempdir}/src
Jim Blandy's avatar
Jim Blandy committed
244 245
 ln [a-zA-Z]*.h ../${tempdir}/src
 ln [a-zA-Z]*.s ../${tempdir}/src
246
 ln README Makefile.in ChangeLog ChangeLog.? config.in paths.in \
Jim Blandy's avatar
Jim Blandy committed
247
    ../${tempdir}/src
Karl Heuer's avatar
Karl Heuer committed
248
 ln makefile.nt ../${tempdir}/src
249
 ln .gdbinit .dbxinit ../${tempdir}/src
250
 ln *.opt vms-pp.trans ../${tempdir}/src
Jim Blandy's avatar
Jim Blandy committed
251
 cd ../${tempdir}/src
252
 rm -f config.h paths.h Makefile Makefile.c
253
 rm -f =* TAGS)
Jim Blandy's avatar
Jim Blandy committed
254

255 256 257 258
echo "Making links to \`src/bitmaps'."
(cd src/bitmaps
 ln README *.xbm ../../${tempdir}/src/bitmaps)

Eric S. Raymond's avatar
Eric S. Raymond committed
259
echo "Making links to \`src/m'."
Jim Blandy's avatar
Jim Blandy committed
260
(cd src/m
261 262
 # 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
263

Eric S. Raymond's avatar
Eric S. Raymond committed
264
echo "Making links to \`src/s'."
Jim Blandy's avatar
Jim Blandy committed
265
(cd src/s
266
 ln README [a-zA-Z0-9]*.h ../../${tempdir}/src/s)
Jim Blandy's avatar
Jim Blandy committed
267

Eric S. Raymond's avatar
Eric S. Raymond committed
268
echo "Making links to \`lib-src'."
Jim Blandy's avatar
Jim Blandy committed
269
(cd lib-src
270
 ln [a-zA-Z]*.[chy] ../${tempdir}/lib-src
271
 ln ChangeLog Makefile.in README testfile vcdiff ../${tempdir}/lib-src
272
 ln emacs.csh rcs2log rcs-checkin makefile.nt ../${tempdir}/lib-src
Eric S. Raymond's avatar
Eric S. Raymond committed
273
 cd ../${tempdir}/lib-src
274
 rm -f getdate.tab.c y.tab.c y.tab.h Makefile.c
275
 rm -f =* TAGS)
Jim Blandy's avatar
Jim Blandy committed
276

277 278
echo "Making links to \`nt'."
(cd nt
279
 ln emacs.ico emacs.rc config.nt config.w95 [a-z]*.in [a-z]*.c ../${tempdir}/nt
280
 ln [a-z]*.bat [a-z]*.h makefile.def makefile.nt ../${tempdir}/nt
281
 ln TODO ChangeLog INSTALL README ../${tempdir}/nt)
282 283 284

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

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

291 292 293
echo "Making links to \`msdos'."
(cd msdos
 ln  ChangeLog emacs.ico emacs.pif ../${tempdir}/msdos
294
 ln mainmake sed*.inp ../${tempdir}/msdos
295 296 297
 cd ../${tempdir}/msdos
 rm -f =*)

Eric S. Raymond's avatar
Eric S. Raymond committed
298
echo "Making links to \`oldXMenu'."
Jim Blandy's avatar
Jim Blandy committed
299
(cd oldXMenu
300
 ln *.c *.h *.in ../${tempdir}/oldXMenu
301
 ln README Imakefile ChangeLog ../${tempdir}/oldXMenu
302
 ln compile.com descrip.mms ../${tempdir}/oldXMenu)
Jim Blandy's avatar
Jim Blandy committed
303

304 305 306 307 308
echo "Making links to \`lwlib'."
(cd lwlib
 ln *.c *.h *.in ../${tempdir}/lwlib
 ln README Imakefile ChangeLog ../${tempdir}/lwlib)

Eric S. Raymond's avatar
Eric S. Raymond committed
309
echo "Making links to \`etc'."
310 311
### Don't distribute = files, TAGS, DOC files, backups, autosaves, or
### tex litter.
Jim Blandy's avatar
Jim Blandy committed
312
(cd etc
313
 ln `ls -d * | grep -v 'RCS' | grep -v 'Old' | grep -v '^e$'` ../${tempdir}/etc
Jim Blandy's avatar
Jim Blandy committed
314
 cd ../${tempdir}/etc
315
 rm -f DOC* *~ \#*\# *.dvi *.log *.orig *.rej *,v =* core
316
 rm -f TAGS)
Jim Blandy's avatar
Jim Blandy committed
317

318 319
echo "Making links to \`etc/e'."
(cd etc/e
320
 ln `ls -d * | grep -v 'RCS'` ../../${tempdir}/etc/e
321
 cd ../../${tempdir}/etc/e
322
 rm -f *~ \#*\# *,v =* core)
323

324 325 326 327
echo "Making links to \`cpp'."
(cd cpp
 ln cccp.c cexp.y Makefile README ../${tempdir}/cpp)

328 329 330 331 332 333 334 335
echo "Making links to \`info'."
# Don't distribute backups or autosaves.
(cd info
 ln [a-zA-Z]* ../${tempdir}/info
 cd ../${tempdir}/info
 # Avoid an error when expanding the wildcards later.
 ln emacs dummy~ ; ln emacs \#dummy\#
 rm -f *~ \#*\# core)
336 337 338

echo "Making links to \`man'."
(cd man
339
 ln *.texi *.aux *.cps *.fns *.kys *.vrs ../${tempdir}/man
340
 test -f README && ln README ../${tempdir}/man
341
 test -f Makefile.in && ln Makefile.in ../${tempdir}/man
342
 ln ChangeLog split-man ../${tempdir}/man
343
 cp texinfo.tex ../${tempdir}/man
Richard M. Stallman's avatar
Richard M. Stallman committed
344
 cd ../${tempdir}/man
345 346
 rm -f \#*\# =* *~ core emacs-index* *.Z *.z xmail
 rm -f emacs.?? termcap.?? gdb.?? *.log *.toc *.dvi *.oaux)
Jim Blandy's avatar
Jim Blandy committed
347

Jim Blandy's avatar
Jim Blandy committed
348 349 350 351 352 353
echo "Making links to \`vms'."
(cd vms
 ln [0-9a-zA-Z]* ../${tempdir}/vms
 cd ../${tempdir}/vms
 rm -f *~)

354 355 356
### It would be nice if they could all be symlinks to etc's copy, but
### you're not supposed to have any symlinks in distribution tar files.
echo "Making sure copying notices are all copies of \`etc/COPYING'."
Eric S. Raymond's avatar
Eric S. Raymond committed
357 358
rm -f ${tempdir}/etc/COPYING
cp etc/COPYING ${tempdir}/etc/COPYING
359
for subdir in lisp src lib-src info msdos; do
Jim Blandy's avatar
Jim Blandy committed
360 361 362
  if [ -f ${tempdir}/${subdir}/COPYING ]; then
    rm ${tempdir}/${subdir}/COPYING
  fi
363
  cp etc/COPYING ${tempdir}/${subdir}
Jim Blandy's avatar
Jim Blandy committed
364 365
done

366 367 368
#### 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
369 370 371
#### 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
372 373 374
####
#### Commented out since it's not stricly necessary; it should suffice
#### to just break the link on alloca.c.
375 376 377
#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
378 379
rm -f $tempdir/lib-src/alloca.c
cp $tempdir/src/alloca.c $tempdir/lib-src/alloca.c
380

Eric S. Raymond's avatar
Eric S. Raymond committed
381 382
if [ "${newer}" ]; then
  echo "Removing files older than $newer."
383 384 385
  ## 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
386 387 388
  find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
fi

Jim Blandy's avatar
Jim Blandy committed
389
if [ "${make_tar}" = yes ]; then
390 391 392 393 394 395 396 397 398 399 400 401 402
  if [ "${default_gzip}" = "" ]; then
    echo "Looking for gzip."
    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
403 404
  case "${default_gzip}" in
    compress* ) gzip_extension=.Z ;;
405
    * )         gzip_extension=.gz ;;
406
  esac
Jim Blandy's avatar
Jim Blandy committed
407
  echo "Creating tar file."
408 409 410
  (cd ${tempparent} ; tar cvf - ${emacsname} ) \
    | ${default_gzip} \
    > ${emacsname}.tar${gzip_extension}
Jim Blandy's avatar
Jim Blandy committed
411
fi
Jim Blandy's avatar
Jim Blandy committed
412

Jim Blandy's avatar
Jim Blandy committed
413
if [ "${clean_up}" = yes ]; then
Jim Blandy's avatar
Jim Blandy committed
414
  echo "Cleaning up the staging directory."
415
  rm -rf ${tempparent}
416 417 418
else
  (cd ${tempparent}; mv ${emacsname} ..)
  rm -rf ${tempparent}
Jim Blandy's avatar
Jim Blandy committed
419
fi
Eric S. Raymond's avatar
Eric S. Raymond committed
420

421
### make-dist ends here