make-dist 8.44 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 9 10

progname="$0"

11 12
### Exit if a command fails.
### set -e
Jim Blandy's avatar
Jim Blandy committed
13

14 15
### Print out each line we read, for debugging's sake.
### set -v
Jim Blandy's avatar
Jim Blandy committed
16

Jim Blandy's avatar
Jim Blandy committed
17 18
clean_up=yes
make_tar=yes
Eric S. Raymond's avatar
Eric S. Raymond committed
19
newer=""
Jim Blandy's avatar
Jim Blandy committed
20 21 22

while [ $# -gt 0 ]; do
  case "$1" in
23 24
    ## 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
25
    "--no-clean-up" )
Jim Blandy's avatar
Jim Blandy committed
26 27
      clean_up=no
    ;;
28 29 30
    ## 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
31 32 33
    "--no-tar" )
      make_tar=no
      clean_up=no
Jim Blandy's avatar
Jim Blandy committed
34
    ;;
35 36 37
    ## This option tells make-dist to make the distribution normally, then
    ## remove all files newer than the given timestamp file.  This is useful
    ## for creating incremental or patch distributions
Eric S. Raymond's avatar
Eric S. Raymond committed
38
    "--newer")
Jim Blandy's avatar
Jim Blandy committed
39 40
      newer="$2"
      new_extension=".new"
Eric S. Raymond's avatar
Eric S. Raymond committed
41 42
      shift
    ;;
Jim Blandy's avatar
Jim Blandy committed
43 44 45 46 47 48 49 50
    * )
      echo "${progname}: Unrecognized argument: $1" >&2
      exit 1
    ;;
  esac
  shift
done

51
### Make sure we're running in the right place.
Jim Blandy's avatar
Jim Blandy committed
52
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
53 54
  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
Jim Blandy's avatar
Jim Blandy committed
55 56 57 58
  echo "distribution tree.  Cd to that directory and try again." >&2
  exit 1
fi

59
### Find out which version of Emacs this is.
Jim Blandy's avatar
Jim Blandy committed
60
version=`grep 'defconst[	 ]*emacs-version' lisp/version.el \
Jim Blandy's avatar
Jim Blandy committed
61
	 | sed -e 's/^.*"\([0-9][0-9]*\.[0-9][0-9]*\)\..*$/\1/'`
Jim Blandy's avatar
Jim Blandy committed
62
if [ ! "${version}" ]; then
Eric S. Raymond's avatar
Eric S. Raymond committed
63
  echo "${progname}: can't find current emacs version in \`./lisp/version.el'." >&2
Jim Blandy's avatar
Jim Blandy committed
64 65 66
  exit 1
fi

67
### Make sure the subdirectory is available.
Eric S. Raymond's avatar
Eric S. Raymond committed
68
tempparent="make-dist.tmp.$$"
Jim Blandy's avatar
Jim Blandy committed
69
if [ -d ${tempparent} ]; then
Eric S. Raymond's avatar
Eric S. Raymond committed
70 71 72 73 74
  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
75 76 77
  exit 1
fi

Eric S. Raymond's avatar
Eric S. Raymond committed
78
echo "Creating staging directory: \`${tempparent}'"
Jim Blandy's avatar
Jim Blandy committed
79
mkdir ${tempparent}
Jim Blandy's avatar
Jim Blandy committed
80
emacsname="emacs-${version}${new_extension}"
Jim Blandy's avatar
Jim Blandy committed
81 82
tempdir="${tempparent}/${emacsname}"

83 84
### 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
85 86 87 88
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
89
echo "Creating top directory: \`${tempdir}'"
Jim Blandy's avatar
Jim Blandy committed
90 91
mkdir ${tempdir}

92 93 94 95
### 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
96 97
echo "Making links to top-level files." 
ln GETTING.GNU.SOFTWARE INSTALL PROBLEMS README move-if-change ${tempdir}
98
ln ChangeLog Makefile.in build-install.in configure ${tempdir}
99
ln make-dist ${tempdir}
100 101
### Copy config.sub; it's a cross-filesystem symlink.
cp config.sub ${tempdir}
Jim Blandy's avatar
Jim Blandy committed
102 103

echo "Creating subdirectories."
104
for subdir in lisp lisp/calc-2.02 lisp/term local-lisp external-lisp \
Eric S. Raymond's avatar
Eric S. Raymond committed
105
	      src src/m src/s lib-src oldXMenu \
106
	      etc lock cpp info man shortnames vms; do
Jim Blandy's avatar
Jim Blandy committed
107 108 109
  mkdir ${tempdir}/${subdir}
done

Eric S. Raymond's avatar
Eric S. Raymond committed
110
echo "Making links to \`lisp'."
111
### Don't distribute =*.el files, site-init.el, site-load.el, or default.el.
Jim Blandy's avatar
Jim Blandy committed
112 113 114
(cd lisp
 ln [a-zA-Z]*.el ../${tempdir}/lisp
 ln [a-zA-Z]*.elc ../${tempdir}/lisp
115 116
 ## simula.el doesn't keep abbreviations in simula.defns any more.
 ## ln [a-zA-Z]*.defns ../${tempdir}/lisp
Jim Blandy's avatar
Jim Blandy committed
117 118 119
 ln ChangeLog README ../${tempdir}/lisp
 cd ../${tempdir}/lisp
 rm -f site-init site-init.el site-init.elc
Jim Blandy's avatar
Jim Blandy committed
120 121
 rm -f site-load site-load.el site-load.elc
 rm -f default default.el default.elc)
Jim Blandy's avatar
Jim Blandy committed
122

123 124 125 126 127 128 129 130 131 132
echo "Making links to \`lisp/calc-2.02'."
### Don't distribute =*.el files 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 *~)

Eric S. Raymond's avatar
Eric S. Raymond committed
133
echo "Making links to \`lisp/term'."
134
### Don't distribute =*.el files.
Jim Blandy's avatar
Jim Blandy committed
135 136 137 138 139
(cd lisp/term
 ln [a-zA-Z]*.el ../../${tempdir}/lisp/term
 ln [a-zA-Z]*.elc ../../${tempdir}/lisp/term
 ln README ../../${tempdir}/lisp/term)

Eric S. Raymond's avatar
Eric S. Raymond committed
140
echo "Making links to \`external-lisp'."
141
### Don't distribute =*.el files.
Eric S. Raymond's avatar
Eric S. Raymond committed
142 143 144 145 146 147
(cd external-lisp
 ln [a-zA-Z]*.el ../${tempdir}/external-lisp
 ln [a-zA-Z]*.elc ../${tempdir}/external-lisp
 ln ChangeLog README ../${tempdir}/external-lisp)

echo "Making links to \`src'."
148 149
### Don't distribute =*.[ch] files, or the configured versions of
### config.h.in, paths.h.in, or Makefile.in.
Jim Blandy's avatar
Jim Blandy committed
150
(cd src
151
 echo "  (If we can't link gmalloc.c, that's okay.)"
Jim Blandy's avatar
Jim Blandy committed
152
 ln [a-zA-Z]*.c ../${tempdir}/src
153 154
 ## Might be a symlink to a file on another filesystem.
 cp gmalloc.c ../${tempdir}/src
Jim Blandy's avatar
Jim Blandy committed
155 156 157 158 159
 ln [a-zA-Z]*.h ../${tempdir}/src
 ln [a-zA-Z]*.s ../${tempdir}/src
 ln README Makefile.in ymakefile ChangeLog config.h.in paths.h.in \
    ../${tempdir}/src
 ln .gdbinit .dbxinit ../${tempdir}/src
160
 ln *.opt vms-pp.trans ../${tempdir}/src
Jim Blandy's avatar
Jim Blandy committed
161
 cd ../${tempdir}/src
Jim Blandy's avatar
Jim Blandy committed
162 163 164 165
 rm -f config.h paths.h Makefile
 if [ -z "${newer}" ]; then
   etags *.h *.c ../lisp/*.el
 fi)
Jim Blandy's avatar
Jim Blandy committed
166

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

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

Eric S. Raymond's avatar
Eric S. Raymond committed
175
echo "Making links to \`lib-src'."
Jim Blandy's avatar
Jim Blandy committed
176
(cd lib-src
177
 ln [a-zA-Z]*.[chy] [a-zA-Z]*.lex [a-zA-Z]*.com ../${tempdir}/lib-src
Eric S. Raymond's avatar
Eric S. Raymond committed
178
 ln ChangeLog Makefile.in README testfile vcdiff rcs2log ../${tempdir}/lib-src
179
 ln emacs.csh ../${tempdir}/lib-src
Eric S. Raymond's avatar
Eric S. Raymond committed
180 181
 cd ../${tempdir}/lib-src
 rm -f getdate.c getdate.tab.c y.tab.c y.tab.h)
Jim Blandy's avatar
Jim Blandy committed
182

Eric S. Raymond's avatar
Eric S. Raymond committed
183
echo "Making links to \`oldXMenu'."
Jim Blandy's avatar
Jim Blandy committed
184 185 186 187
(cd oldXMenu
 ln *.c *.h ../${tempdir}/oldXMenu
 ln README Makefile Imakefile ChangeLog ../${tempdir}/oldXMenu)

Eric S. Raymond's avatar
Eric S. Raymond committed
188
echo "Making links to \`etc'."
189
### Don't distribute DOC files, backups, autosaves, or tex litter.
Jim Blandy's avatar
Jim Blandy committed
190 191 192
(cd etc
 ln [0-9a-zA-Z]* ../${tempdir}/etc
 cd ../${tempdir}/etc
193
 ## Avoid an error when expanding the wildcards later.
Jim Blandy's avatar
Jim Blandy committed
194 195 196
 for dummy in DOC-dummy dummy~ \#dummy\# dummy.dvi dummy.log; do
   ln MACHINES ${dummy}
 done
Jim Blandy's avatar
Jim Blandy committed
197
 rm -f DOC* *~ \#*\# *.dvi *.log core)
Jim Blandy's avatar
Jim Blandy committed
198

199 200 201 202
echo "Making links to \`cpp'."
(cd cpp
 ln cccp.c cexp.y Makefile README ../${tempdir}/cpp)

203 204 205 206 207 208 209 210
###!! 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)
211 212 213 214 215 216

echo "Making links to \`man'."
(cd man
 ln *.tex *.texinfo *.texi *.aux *.cps *.fns *.kys *.vrs ../${tempdir}/man
 ln *.c ../${tempdir}/man
 ln ChangeLog Makefile README split-man ../${tempdir}/man)
Jim Blandy's avatar
Jim Blandy committed
217

Eric S. Raymond's avatar
Eric S. Raymond committed
218
echo "Making links to \`shortnames'."
Jim Blandy's avatar
Jim Blandy committed
219 220 221 222
(cd shortnames
 ln *.c ../${tempdir}/shortnames
 ln Makefile reserved special ../${tempdir}/shortnames)

Jim Blandy's avatar
Jim Blandy committed
223 224 225 226 227 228
echo "Making links to \`vms'."
(cd vms
 ln [0-9a-zA-Z]* ../${tempdir}/vms
 cd ../${tempdir}/vms
 rm -f *~)

229 230 231
### 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
232 233 234
rm -f ${tempdir}/etc/COPYING
cp etc/COPYING ${tempdir}/etc/COPYING
for subdir in lisp external-lisp src lib-src info shortnames; do
Jim Blandy's avatar
Jim Blandy committed
235 236 237
  if [ -f ${tempdir}/${subdir}/COPYING ]; then
    rm ${tempdir}/${subdir}/COPYING
  fi
238
  cp etc/COPYING ${tempdir}/${subdir}
Jim Blandy's avatar
Jim Blandy committed
239 240
done

Eric S. Raymond's avatar
Eric S. Raymond committed
241 242
if [ "${newer}" ]; then
  echo "Removing files older than $newer."
243 244 245
  ## 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
246 247 248
  find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) -exec rm -f {} \;
fi

Jim Blandy's avatar
Jim Blandy committed
249 250 251 252
if [ "${make_tar}" = yes ]; then
  echo "Creating tar file."
  (cd ${tempparent}; tar cvf - ${emacsname}) | compress > ${emacsname}.tar.Z
fi
Jim Blandy's avatar
Jim Blandy committed
253

Jim Blandy's avatar
Jim Blandy committed
254
if [ "${clean_up}" = yes ]; then
Jim Blandy's avatar
Jim Blandy committed
255 256 257
  echo "Cleaning up the staging directory."
  rm -rf ${tempparent}
fi
Eric S. Raymond's avatar
Eric S. Raymond committed
258

259
### make-dist ends here