primary-prefix-couples-force-valid.sh 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #! /bin/sh
  2. # Copyright (C) 2011-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. # Check that a user who wants to use an invalid prefix/primary
  17. # combination can do so with a proper workaround.
  18. # For example, this:
  19. # lib_PROGRAMS = foo
  20. # is expected to cause an automake error, but this:
  21. # bardir = $(libdir)
  22. # bar_PROGRAMS = foo
  23. # should work.
  24. required=cc
  25. . test-init.sh
  26. cat >> configure.ac <<'END'
  27. AC_PROG_CC
  28. AM_PROG_AR
  29. AC_PROG_RANLIB
  30. AC_OUTPUT
  31. END
  32. cat > Makefile.am <<'END'
  33. my_libdir = $(libdir)
  34. my_lib_PROGRAMS = foo
  35. foodir = $(bindir)
  36. foo_LIBRARIES = libquux.a
  37. xdir = $(libexecdir)
  38. x_HEADERS = bar.h
  39. installcheck-local: test
  40. .PHONY: test
  41. test:
  42. (cd '$(prefix)' && find .);: For debugging.
  43. ls -l '$(libdir)/foo$(EXEEXT)'
  44. test -f '$(libdir)/foo$(EXEEXT)'
  45. test -x '$(libdir)/foo$(EXEEXT)'
  46. ls -l '$(bindir)/libquux.a'
  47. test -f '$(bindir)/libquux.a'
  48. ls -l '$(libexecdir)/bar.h'
  49. test -f '$(libexecdir)/bar.h'
  50. ## If this test is run as root, "test -x" could succeed also for
  51. ## non-executable files, so we need to protect the next check.
  52. ## See automake bug#12041.
  53. if test -x Makefile; then echo SKIP THIS; else \
  54. test ! -x '$(libexecdir)/bar.h'; \
  55. fi;
  56. END
  57. cat > foo.c <<'END'
  58. int main (void)
  59. {
  60. return 0;
  61. }
  62. END
  63. cat > libquux.c <<'END'
  64. int quux(void)
  65. {
  66. return 1;
  67. }
  68. END
  69. : > bar.h
  70. $ACLOCAL
  71. $AUTOMAKE -a
  72. $AUTOCONF
  73. cwd=$(pwd) || fatal_ "getting current working directory"
  74. ./configure --prefix="$cwd/_inst"
  75. $MAKE install
  76. $MAKE installcheck
  77. $MAKE distcheck
  78. :