news: add entry about recent 'ar-lib' changes
[automake.git] / tests / insthook.test
blob1b03324995b68cb338a2aae207983a78be443577
1 #! /bin/sh
2 # Copyright (C) 2003, 2005, 2007, 2010 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
7 # any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # Make sure the install-exec-hook example we give in the manual works.
19 . ./defs || Exit 1
21 set -e
23 cat >>configure.in <<'EOF'
24 AC_PROG_LN_S
25 AC_OUTPUT
26 EOF
28 cat >Makefile.am <<'END'
29 dist_bin_SCRIPTS = foo
31 install-exec-hook:
32 cd "$(DESTDIR)$(bindir)" && \
33 mv -f foo foo-$(VERSION) && \
34 $(LN_S) foo-$(VERSION) foo
36 installcheck-local:
37 test -f "$(bindir)/foo"
38 test -f "$(bindir)/foo-$(VERSION)"
39 : > $(top_srcdir)/../ok
41 uninstall-hook:
42 rm -f $(DESTDIR)$(bindir)/foo-$(VERSION)
43 END
45 echo 1 > foo
47 $ACLOCAL
48 $AUTOCONF
49 $AUTOMAKE
51 ./configure
52 $MAKE distcheck
53 # Sanity check to make sure installcheck-local was run.
54 test -f ok
56 # Make sure that installing a second version doesn't erase the first
57 # one. (This is error prone since `foo' symlinks to `foo-1.0' and the
58 # second version will overwrite `foo'. Hopefully `install' and `install-sh'
59 # are smart enough to erase the `foo' symlink before installing the new
60 # version.)
61 ./configure "--bindir=`pwd`/bin"
62 $MAKE install
63 echo 2 > foo
64 VERSION=2.0 $MAKE -e install
65 grep 1 bin/foo-1.0
66 grep 2 bin/foo-2.0
67 grep 2 bin/foo
69 # install-hook is an error.
70 cat >>Makefile.am <<EOF
71 install-hook:
72 echo test
73 EOF
75 AUTOMAKE_fails
76 grep install-data-hook stderr
77 grep install-exec-hook stderr