doc: update Vala documentation
[automake.git] / t / insthook.sh
blobb9fea85f1d248f7ce0e3efaca67f781be5203d8d
1 #! /bin/sh
2 # Copyright (C) 2003-2024 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 <https://www.gnu.org/licenses/>.
17 # Make sure the install-exec-hook example we give in the manual works.
19 . test-init.sh
21 cat >>configure.ac <<'EOF'
22 AC_PROG_LN_S
23 AC_OUTPUT
24 EOF
26 cat >Makefile.am <<'END'
27 dist_bin_SCRIPTS = foo
29 install-exec-hook:
30 cd "$(DESTDIR)$(bindir)" \
31 && mv -f foo foo-$(VERSION) \
32 && $(LN_S) foo-$(VERSION) foo
34 installcheck-local:
35 test -f "$(bindir)/foo"
36 test -f "$(bindir)/foo-$(VERSION)"
37 : > $(top_srcdir)/../ok
39 uninstall-hook:
40 rm -f $(DESTDIR)$(bindir)/foo-$(VERSION)
41 END
43 echo a > foo
45 $ACLOCAL
46 $AUTOCONF
47 $AUTOMAKE
49 ./configure
50 $MAKE distcheck
51 # Sanity check to make sure installcheck-local was run.
52 test -f ok
54 # Make sure that installing a second version doesn't erase the first
55 # one. (This is error prone since 'foo' symlinks to 'foo-1.0' and the
56 # second version will overwrite 'foo'. Hopefully 'install' and 'install-sh'
57 # are smart enough to erase the 'foo' symlink before installing the new
58 # version.)
59 ./configure "--bindir=$(pwd)/bin"
60 $MAKE install
61 echo b > foo
62 run_make VERSION=2.0 install
63 test $(cat bin/foo-1.0) = a
64 test $(cat bin/foo-2.0) = b
65 test $(cat bin/foo) = b
67 # install-hook is an error.
68 cat >>Makefile.am <<EOF
69 install-hook:
70 echo test
71 EOF
73 AUTOMAKE_fails
74 grep install-data-hook stderr
75 grep install-exec-hook stderr