2 ### quick-install-emacs --- do a halfway-decent job of installing emacs quickly
4 ## Copyright (C) 2001-2011 Free Software Foundation, Inc.
6 ## Author: Miles Bader <miles@gnu.org>
8 ## This file is part of GNU Emacs.
10 ## GNU Emacs is free software: you can redistribute it and/or modify
11 ## it under the terms of the GNU General Public License as published by
12 ## the Free Software Foundation, either version 3 of the License, or
13 ## (at your option) any later version.
15 ## GNU Emacs is distributed in the hope that it will be useful,
16 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ## GNU General Public License for more details.
20 ## You should have received a copy of the GNU General Public License
21 ## along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
26 ## This script is mainly intended for emacs maintainer or pretesters who
27 ## install emacs very often. See the --help output for more details.
30 PUBLIC_LIBSRC_BINARIES
='emacsclient etags ctags ebrowse'
31 PUBLIC_LIBSRC_SCRIPTS
='grep-changelog rcs-checkin'
33 AVOID
="CVS -DIC README COPYING ChangeLog ~ [.]orig$ [.]rej$ Makefile$ Makefile.in$ makefile$ makefile.w32-in$ stamp-subdir [.]cvsignore [.]arch-ids [{]arch[}] [.][cho]$ make-docfile testfile test-distrib"
35 # Prune old binaries lying around in the source tree
37 # Re-install files even if they already exist
39 # Command verbose flag
44 # Install commands (if the user specifies the `--verbose' option, it is
45 # passed to these commands, so that feature only works if these commands
52 # Used to execute commands once once we create them
57 # avoid non-standard command output from non-C locales
58 unset LANG LC_ALL LC_MESSAGES
61 USAGE
="Usage: $me [OPTION...] BUILD_TREE [PREFIX]"
62 TRY
="Try "\
`"$me --help' for more information."
64 # Parse command-line options
84 -n, --dry-run print installation commands instead of
87 -f, --force install even files that haven't changed
88 -v, --verbose print messages describing what is done
90 -p, --prune prune old generated files
91 -P, --no-prune don't prune old generated files (default)
92 --prune-only prune old generated files, but don't install
94 --help display this help and exit
95 --version output version information and exit
97 $me install emacs \`incrementally
,' that is, it will
98 install only those files that have changed since the last time it was
99 invoked, and remove any obsolete files from the installation
100 directories. It also uses hard-links into the source and build trees to
101 do the install, so it uses much less space than the default Makefile
102 install target; however, this also means that $me can
103 not install onto a disk partition other than the one on which the source
104 and build directories reside.
106 Optionally, $me can also remove old versions of
107 automatically generated files that are version-specific (such as the
108 versioned emacs executables in the \`src' directory
, and the DOC-
* files
109 in the \
`etc' directory). The latter action is called \`pruning
,' and
110 can be enabled using the \`-p' or \
`--prune' options.
118 Written by Miles Bader <miles@gnu.org>
123 # split concatenated single-letter options apart
125 set -- `echo $FIRST |
sed 's/-\(.\)\(.*\)/-\1 -\2/'` "$@"
128 echo 1>&2 "$me: unrecognized option "\`"$1'"
137 LINK_CMD
="$LINK $VERBOSE"
138 REMOVE_CMD
="$REMOVE $VERBOSE"
142 2) BUILD
="$1"; prefix
="$2";;
150 if test ! -d "$BUILD"; then
151 echo 1>&2 "$me: $BUILD: Build tree not found"
153 elif test ! -r "$BUILD/config.status"; then
154 echo 1>&2 "$me: $BUILD: Not a proper build tree, config.status not found"
158 CONFIG_STATUS
="$BUILD/config.status"
161 { sed -n "s/^S[[]\"$1\"[]]=\"\([^\"]*\)\"/\1/p" $CONFIG_STATUS |
sed q |
grep ''; } ||
162 { sed -n "s/^s\(.\)@$1@\1\(|#_!!_#|\)*\(.*\)\1.*$/\3/p" $CONFIG_STATUS |
sed q |
grep ''; } ||
164 echo 1>&2 "$me: $1: Configuration variable not found in $CONFIG_STATUS"
169 test x
"$SRC" = x
&& { SRC
="`get_config_var srcdir`" ||
exit 4 ; }
170 test x
"$prefix" = x
&& { prefix
="`get_config_var prefix`" ||
exit 4 ; }
171 test x
"$ARCH" = x
&& { ARCH
="`get_config_var host`" ||
exit 4 ; }
173 VERSION
=`grep 'char emacs_version' $SRC/src/emacs.c \
174 | sed -e 's/^[^"]*"\([^"]*\)".*$/\1/'`
176 DST_SHARE
="$prefix/share/emacs/$VERSION"
177 DST_BIN
="$prefix/bin"
178 DST_LIBEXEC
="$prefix/libexec/emacs/$VERSION/$ARCH"
180 # There are various common places for the info dir to be, so try to
181 # use whatever's already there, defaulting to (and preferring)
185 for D
in "$prefix/share/info" "$prefix/info"; do
186 if test -d "$D"; then
191 DST_INFO
=${DST_INFO:-"$prefix/share/info"}
195 if ! test -d "$1"; then
196 $MKDIR $VERBOSE "$1" 2>&1 |
sed "s/^mkdir:/$me:/" 1>&2
200 maybe_mkdir
"$DST_BIN"
201 maybe_mkdir
"$DST_SHARE"
202 maybe_mkdir
"$DST_SHARE/site-lisp"
203 maybe_mkdir
"$DST_LIBEXEC"
204 maybe_mkdir
"$DST_INFO"
206 ( # start of command-generating sub-shell
209 if test x
"$PRUNE" != xno
; then
210 for D
in `ls -1t $BUILD/etc/DOC-* | sed 1d`; do
214 for D
in `ls -1t $BUILD/src/emacs-$VERSION.* | sed 1d`; do
220 test x
"$PRUNE" = xonly
&& exit 0
224 if test "$FORCE" = yes ||
! cmp -s $1 $2; then
229 maybe_emit_copy
$BUILD/src
/emacs
$DST_BIN/emacs
230 maybe_emit_copy
$BUILD/src
/emacs
$DST_BIN/emacs-
$VERSION
232 for F
in $PUBLIC_LIBSRC_BINARIES; do
233 maybe_emit_copy
$BUILD/lib-src
/$F $DST_BIN/$F
235 for F
in $PUBLIC_LIBSRC_SCRIPTS; do
236 maybe_emit_copy
$SRC/lib-src
/$F $DST_BIN/$F
239 if test x
"$SRC" = x
"$BUILD"; then
245 for SUBDIR
in lisp leim etc lib-src info
; do
249 AVOID_PAT
="`echo "($AVOID)" | tr ' ' '|'`"
251 # Set subdir-specific values
254 DST
="$DST_SHARE/$SUBDIR"
257 DST
="$DST_SHARE/$SUBDIR"
258 # COPYING is in the avoid list, but there should be a copy of it in
259 # the install etc dir, so make that here.
260 FORCED
="$DST/COPYING"
264 AVOID_PAT
="`echo "($AVOID ($PUBLIC_LIBSRC_BINARIES $PUBLIC_LIBSRC_SCRIPTS)\$
)" | tr ' ' '|'`"
273 if [ -d $PFX/$SUBDIR ]; then
274 for DIR
in `(cd $PFX/$SUBDIR; find . -type d -print | sed 's@^./@@')`; do
275 if [ -d $DST/$DIR ]; then
276 echo Directory
$DST/$DIR exists
278 echo Directory
$DST/$DIR non-existent
279 if [ "`echo $DIR | egrep -v "$AVOID_PAT"`" ]; then
280 maybe_mkdir
$DST/$DIR
284 diff -sqr $PFX/$SUBDIR $DST
288 src_pat = "^'"$SRC"'/'"$SUBDIR"'/"
289 build_pat = "^'"$BUILD"'/'"$SUBDIR"'/"
290 dst_pat = "^'"$DST"'/"
291 dst_pfx = "'"$DST"'/"
292 avoid_pat = "'"$AVOID_PAT"'"
293 force = ("'"$FORCE"'" == "yes")
294 shared = ("'"$SHARED"'" == "yes")
295 init_bool_array(pruned, "'"$PRUNED"'")
296 init_bool_array(forced, "'"$FORCED"'")
298 function init_bool_array(array, string, a,k)
304 function install(src, dst)
306 if (! (src in pruned)) {
312 function update(src, dst, copy)
324 function uninstall(dst)
330 if ($2 ~ avoid_pat) {
338 if ($4 ~ avoid_pat && !($4 in forced))
340 else if ($NF == "identical")
341 update($2, $4, force)
355 if (subdir ~ src_pat)
356 sub (src_pat, "", subdir)
358 sub (build_pat, "", subdir)
360 dst = dst_pfx subdir $4
361 if (! (dst ~ avoid_pat))
368 print "'"$REMOVE_CMD"' " f
370 print "'"$LINK_CMD"' " f " " cp[f]