insthook.sh 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #! /bin/sh
  2. # Copyright (C) 2003-2017 Free Software Foundation, Inc.
  3. #
  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.
  8. #
  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.
  13. #
  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/>.
  16. # Make sure the install-exec-hook example we give in the manual works.
  17. . test-init.sh
  18. cat >>configure.ac <<'EOF'
  19. AC_PROG_LN_S
  20. AC_OUTPUT
  21. EOF
  22. cat >Makefile.am <<'END'
  23. dist_bin_SCRIPTS = foo
  24. install-exec-hook:
  25. cd "$(DESTDIR)$(bindir)" \
  26. && mv -f foo foo-$(VERSION) \
  27. && $(LN_S) foo-$(VERSION) foo
  28. installcheck-local:
  29. test -f "$(bindir)/foo"
  30. test -f "$(bindir)/foo-$(VERSION)"
  31. : > $(top_srcdir)/../ok
  32. uninstall-hook:
  33. rm -f $(DESTDIR)$(bindir)/foo-$(VERSION)
  34. END
  35. echo a > foo
  36. $ACLOCAL
  37. $AUTOCONF
  38. $AUTOMAKE
  39. ./configure
  40. $MAKE distcheck
  41. # Sanity check to make sure installcheck-local was run.
  42. test -f ok
  43. # Make sure that installing a second version doesn't erase the first
  44. # one. (This is error prone since 'foo' symlinks to 'foo-1.0' and the
  45. # second version will overwrite 'foo'. Hopefully 'install' and 'install-sh'
  46. # are smart enough to erase the 'foo' symlink before installing the new
  47. # version.)
  48. ./configure "--bindir=$(pwd)/bin"
  49. $MAKE install
  50. echo b > foo
  51. run_make VERSION=2.0 install
  52. test $(cat bin/foo-1.0) = a
  53. test $(cat bin/foo-2.0) = b
  54. test $(cat bin/foo) = b
  55. # install-hook is an error.
  56. cat >>Makefile.am <<EOF
  57. install-hook:
  58. echo test
  59. EOF
  60. AUTOMAKE_fails
  61. grep install-data-hook stderr
  62. grep install-exec-hook stderr
  63. :