+2003-03-20 Alexandre Duret-Lutz <adl@gnu.org>
+
+ For Debian Bug #185388:
+ * automake.texi (Extending): Augment the install-exec-hook
+ discussion with an example how to symlink a versioned binary.
+ * tests/insthook.test: Rewrite to test the above example.
+ Report from James R. Van Zandt.
+
2003-03-19 Alexandre Duret-Lutz <adl@gnu.org>
* Makefile.am (maintainer-check): Allow `automake:' tokens,
Imacat imacat@mail.imacat.idv.tw
Inoue inoue@ainet.or.jp
James Henstridge james@daa.com.au
+James R. Van Zandt jrv@vanzandt.mv.com
James Youngman jay@gnu.org
Janos Farkas chexum@shadow.banki.hu
Jared Davis abiword@aiksaurus.com
@example
install-exec-hook:
- ln $(DESTDIR)$(bindir)/program $(DESTDIR)$(bindir)/proglink
+ ln $(DESTDIR)$(bindir)/program$(EXEEXT) \
+ $(DESTDIR)$(bindir)/proglink$(EXEEXT)
@end example
+Although cheaper and more portable than symbolic links, hard links
+will not work everywhere (for instance OS/2 does not have
+@command{ln}). Ideally you should fall back to @code{cp -p} when
+@code{ln} does not work. An easy way, if symbolic links are
+acceptable to you, is to add @code{AC_PROG_LN_S} to
+@file{configure.in} (@pxref{Particular Programs, , Particular Program
+Checks, autoconf, The Autoconf Manual}) and use @code{$(LN_S)} in
+@file{Makefile.am}.
+
+@cindex versioned binaries, installing
+@cindex installing versioned binaries
+@cindex LN_S example
+For instance, here is how you could install a versioned copy of a
+program using @code{$(LN_S)}:
+
+@example
+install-exec-hook:
+ cd $(DESTDIR)$(bindir) && \
+ mv -f prog$(EXEEXT) prog-$(VERSION)$(EXEEXT) && \
+ $(LN_S) prog-$(VERSION)$(EXEEXT) prog$(EXEEXT)
+@end example
+
+Note that we rename the program so that a new version will erase the
+symbolic link, not the real binary. Also we @code{cd} into the
+destination directory in order to create relative links.
+
@c FIXME should include discussion of variables you can use in these
@c rules
-@set UPDATED 5 March 2003
+@set UPDATED 20 March 2003
@set UPDATED-MONTH March 2003
@set EDITION 1.7a
@set VERSION 1.7a
#! /bin/sh
-# Copyright (C) 1998, 1999, 2001, 2002 Free Software Foundation, Inc.
+# Copyright (C) 2003 Free Software Foundation, Inc.
#
# This file is part of GNU Automake.
#
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
-# Test to make sure install-exec-hook works.
-# Report from Tim Goodwin.
+# Make sure the install-exec-hook example we give in the manual works.
. ./defs || exit 1
-cat > Makefile.am << 'END'
+set -e
+
+cat >>configure.in <<'EOF'
+AC_PROG_LN_S
+AC_OUTPUT
+EOF
+
+cat >Makefile.am <<'END'
+dist_bin_SCRIPTS = foo
+
install-exec-hook:
- @echo nothing
+ cd $(DESTDIR)$(bindir) && \
+ mv -f foo foo-$(VERSION) && \
+ $(LN_S) foo-$(VERSION) foo
+
+installcheck-local:
+ test -f $(bindir)/foo
+ test -f $(bindir)/foo-$(VERSION)
+ : > $(top_srcdir)/../ok
END
-$ACLOCAL || exit 1
-$AUTOMAKE || exit 1
+echo 1 > foo
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE distcheck
+# Sanity check to make sure installcheck-local was run.
+test -f ok
-test "`grep install-exec-hook Makefile.in | wc -l`" -gt 1 || exit 1
-# install-exec-hook must appear in the install-exec-am rule.
-sed -n '/^install-exec-am:/,/^[^ ]/p' Makefile.in | \
- grep install-exec-hook
+# Make sure that installing a second version doesn't erase the first
+# one. (This is error prone since `foo' symlinks to `foo-1.0' and the
+# second version will overwrite `foo'. Hopefully `install' and `install-sh'
+# are smart enough to erase the `foo' symlink before installing the new
+# version.)
+./configure --bindir=`pwd`/bin
+$MAKE install
+echo 2 > foo
+VERSION=2.0 make -e install
+grep 1 bin/foo-1.0
+grep 2 bin/foo-2.0
+grep 2 bin/foo
-@set UPDATED 5 March 2003
+@set UPDATED 20 March 2003
@set UPDATED-MONTH March 2003
@set EDITION 1.7a
@set VERSION 1.7a