posixsubst-scripts.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #! /bin/sh
  2. # Copyright (C) 2010-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. # Test that POSIX variable expansion '$(var:str=rpl)' works when used
  17. # with the SCRIPTS primary.
  18. . test-init.sh
  19. cat >> configure.ac << 'END'
  20. AC_OUTPUT
  21. END
  22. # We have to be careful with 'test -x' commands on MinGW/MSYS, because
  23. # the file system does not actually have execute permission information.
  24. # Instead, that is emulated by looking at the file content, and returning
  25. # 0 if the file starts with, e.g., a COFF header or with '#!'.
  26. # So we need to create actual scripts in the make rules and in the file
  27. # creation below.
  28. cat > Makefile.am << 'END'
  29. t1 = foo1 foo2
  30. t2 = bar1x bar2
  31. t3 = quu-baz
  32. bar1 bar2:
  33. (echo '#!/bin/sh' && echo 'exit 0') > $@
  34. quux.pl:
  35. (echo '#!/bin/perl' && echo '1;') > $@
  36. CLEANFILES = bar1 bar2 quux.pl
  37. # Also try an empty match suffix, to ensure that the ':=' in there is
  38. # not confused by the parser with an unportable assignment operator.
  39. dist_sbin_SCRIPTS = $(t1:=.sh)
  40. libexec_SCRIPTS = $(t2:x=)
  41. nodist_bin_SCRIPTS = $(t3:-baz=x.pl)
  42. check-local: test1 test2
  43. .PHONY: test1 test2
  44. test1:
  45. ls -l
  46. test -f bar1
  47. test -f bar2
  48. test -f quux.pl
  49. test2: distdir
  50. ls -l $(distdir)
  51. ## The scripts foo1.sh and foo2.sh should be distributed.
  52. test -f $(distdir)/foo1.sh
  53. test -f $(distdir)/foo2.sh
  54. ## The scripts bar1, bar2 and quux.pl shouldn't be distributed.
  55. test ! -r $(distdir)/bar1
  56. test ! -r $(distdir)/bar2
  57. test ! -r $(distdir)/quux.pl
  58. installcheck-local:
  59. ls -l $(libexecdir) $(bindir) $(sbindir)
  60. test -f $(sbindir)/foo1.sh
  61. test -x $(sbindir)/foo1.sh
  62. test -f $(sbindir)/foo2.sh
  63. test -x $(sbindir)/foo2.sh
  64. test -f $(libexecdir)/bar1
  65. test -x $(libexecdir)/bar1
  66. test -f $(libexecdir)/bar2
  67. test -x $(libexecdir)/bar2
  68. test -f $(bindir)/quux.pl
  69. test -x $(bindir)/quux.pl
  70. END
  71. cat > foo1.sh <<'END'
  72. #!/bin/sh
  73. exit 0
  74. END
  75. cp foo1.sh foo2.sh
  76. $ACLOCAL
  77. $AUTOCONF
  78. $AUTOMAKE
  79. cwd=$(pwd) || fatal_ "getting current working directory"
  80. ./configure --prefix="$cwd/_inst"
  81. $MAKE
  82. $MAKE test1 test2
  83. $MAKE install
  84. $MAKE installcheck
  85. $MAKE distcheck
  86. :