2 # quick-install-emacs -- do a halfway-decent job of installing emacs quickly
3 # Written by Miles Bader <miles@gnu.org>
5 # This script is mainly intended for emacs maintainer or pretesters who
6 # install emacs very often. See the --help output for more details.
8 PUBLIC_LIBSRC_BINARIES
='b2m emacsclient etags ctags ebrowse'
9 PUBLIC_LIBSRC_SCRIPTS
='grep-changelog rcs-checkin'
11 AVOID
="CVS -DIC README COPYING ChangeLog ~ \.orig$ \.rej$ Makefile makefile stamp-subdir .cvsignore \.[cho]$ make-docfile testfile test-distrib"
13 # Prune old binaries lying around in the source tree
15 # Re-install files even if they already exist
17 # Command verbose flag
22 # Install commands (these commands are also expected to understand the
23 # GNU -v (--verbose) option)
28 # Used to execute commands once once we create them
30 MKDIR
='mkdir --verbose -p'
34 # avoid non-standard command output from non-C locales
35 unset LANG LC_ALL LC_MESSAGES
38 USAGE
="Usage: $me [OPTION...] BUILD_TREE [PREFIX]"
39 TRY
="Try "\
`"$me --help' for more information."
41 # Parse command-line options
61 -n, --dry-run print installation commands instead of
64 -f, --force install even files that haven't changed
65 -v, --verbose print messages describing what is done
67 -p, --prune prune old generated files
68 -P, --no-prune don't prune old generated files (default)
69 --prune-only prune old generated files, but don't install
71 --help display this help and exit
72 --version output version information and exit
74 $me install emacs \`incrementally
,' that is, it will
75 install only those files that have changed since the last time it was
76 invoked, and remove any obsolete files from the installation
77 directories. It also uses hard-links into the source and build trees to
78 do the install, so it uses much less space than the default Makefile
79 install target; however, this also means that $me can
80 not install onto a disk partition other than the one on which the source
81 and build directories reside.
83 Optionally, $me can also remove old versions of
84 automatically generated files that are version-specific (such as the
85 versioned emacs executables in the \`src' directory
, and the DOC-
* files
86 in the \
`etc' directory). The latter action is called \`pruning
,' and
87 can be enabled using the \`-p' or \
`--prune' options.
95 Written by Miles Bader <miles@gnu.org>
100 # split concatenated single-letter options apart
102 set -- `echo $FIRST |
sed 's/-\(.\)\(.*\)/-\1 -\2/'` "$@"
105 echo 1>&2 "$me: unrecognized option "\`"$1'"
114 LINK_CMD
="$LINK $VERBOSE"
115 REMOVE_CMD
="$REMOVE $VERBOSE"
119 2) BUILD
="$1"; prefix
="$2";;
127 if test ! -d "$BUILD"; then
128 echo 1>&2 "$me: $BUILD: Build tree not found"
130 elif test ! -r "$BUILD/config.status"; then
131 echo 1>&2 "$me: $BUILD: Not a proper build tree, config.status not found"
135 CONFIG_STATUS
="$BUILD/config.status"
136 function get_config_var
() {
137 if ! sed -n "s/^s\(.\)@$1@\1\(.*\)\1.*$/\2/p" $CONFIG_STATUS |
sed q |
grep ''
139 echo 1>&2 "$me: $1: Configuration variable not found in $CONFIG_STATUS"
144 test x
"$SRC" = x
&& { SRC
="`get_config_var srcdir`" ||
exit 4 ; }
145 test x
"$prefix" = x
&& { prefix
="`get_config_var prefix`" ||
exit 4 ; }
146 test x
"$ARCH" = x
&& { ARCH
="`get_config_var host`" ||
exit 4 ; }
148 VERSION
=`grep 'defconst[ ]*emacs-version' $SRC/lisp/version.el \
149 | sed -e 's/^[^"]*"\([^"]*\)".*$/\1/'`
151 DST_SHARE
="$prefix/share/emacs/$VERSION"
152 DST_BIN
="$prefix/bin"
153 DST_LIBEXEC
="$prefix/libexec/emacs/$VERSION/$ARCH"
154 DST_INFO
="$prefix/info"
156 function maybe_mkdir
() {
157 if ! test -d "$1"; then
158 $MKDIR "$1" 2>&1 |
sed "s/^mkdir:/$me:/" 1>&2
162 maybe_mkdir
"$DST_BIN"
163 maybe_mkdir
"$DST_SHARE"
164 maybe_mkdir
"$DST_SHARE/site-lisp"
165 maybe_mkdir
"$DST_LIBEXEC"
166 maybe_mkdir
"$DST_INFO"
168 ( # start of command-generating sub-shell
171 if test x
"$PRUNE" != xno
; then
172 for D
in `ls -1t $BUILD/etc/DOC-* | sed 1d`; do
176 for D
in `ls -1t $BUILD/src/emacs-$VERSION.* | sed 1d`; do
180 for D
in `ls -1t $BUILD/lib-src/fns-* | sed 1d`; do
186 test x
"$PRUNE" = xonly
&& exit 0
188 function maybe_emit_copy
() {
189 if test "$FORCE" = yes ||
! cmp -s $1 $2; then
194 maybe_emit_copy
$BUILD/src
/emacs
$DST_BIN/emacs
195 maybe_emit_copy
$BUILD/src
/emacs
$DST_BIN/emacs-
$VERSION
197 for F
in $PUBLIC_LIBSRC_BINARIES; do
198 maybe_emit_copy
$BUILD/lib-src
/$F $DST_BIN/$F
200 for F
in $PUBLIC_LIBSRC_SCRIPTS; do
201 maybe_emit_copy
$SRC/lib-src
/$F $DST_BIN/$F
204 if test x
"$SRC" = x
"$BUILD"; then
210 for SUBDIR
in lisp leim etc lib-src info
; do
214 AVOID_PAT
="`echo "($AVOID)" | tr ' ' '|'`"
216 # Set subdir-specific values
219 DST
="$DST_SHARE/$SUBDIR"
222 DST
="$DST_SHARE/$SUBDIR"
223 # COPYING is in the avoid list, but there should be a copy of it in
224 # the install etc dir, so make that here.
225 FORCED
="$DST/COPYING"
229 AVOID_PAT
="`echo "($AVOID ($PUBLIC_LIBSRC_BINARIES $PUBLIC_LIBSRC_SCRIPTS)\$
)" | tr ' ' '|'`"
238 if [ -d $PFX/$SUBDIR ]; then
239 for DIR
in `(cd $PFX/$SUBDIR; find . -type d -print | sed 's@^./@@')`; do
240 if [ -d $DST/$DIR ]; then
241 echo Directory
$DST/$DIR exists
243 echo Directory
$DST/$DIR non-existant
244 if [ "`echo $DIR | egrep -v "$AVOID_PAT"`" ]; then
245 maybe_mkdir
$DST/$DIR
249 diff -sqr $PFX/$SUBDIR $DST
253 src_pat = "^'"$SRC"'/'"$SUBDIR"'/"
254 build_pat = "^'"$BUILD"'/'"$SUBDIR"'/"
255 dst_pat = "^'"$DST"'/"
256 dst_pfx = "'"$DST"'/"
257 avoid_pat = "'"$AVOID_PAT"'"
258 force = ("'"$FORCE"'" == "yes")
259 shared = ("'"$SHARED"'" == "yes")
260 init_bool_array(pruned, "'"$PRUNED"'")
261 init_bool_array(forced, "'"$FORCED"'")
263 function init_bool_array(array, string, a,k)
269 function install(src, dst)
271 if (! (src in pruned)) {
277 function update(src, dst, copy)
289 function uninstall(dst)
295 if ($2 ~ avoid_pat) {
303 if ($4 ~ avoid_pat && !($4 in forced))
305 else if ($NF == "identical")
306 update($2, $4, force)
320 if (subdir ~ src_pat)
321 sub (src_pat, "", subdir)
323 sub (build_pat, "", subdir)
325 dst = dst_pfx subdir $4
326 if (! (dst ~ avoid_pat))
333 print "'"$REMOVE_CMD"' " f
335 print "'"$LINK_CMD"' " f " " cp[f]