subst3.sh 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. #! /bin/sh
  2. # Copyright (C) 2001-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 installation with substitutions. This test is based on
  17. # 'nobase.sh'.
  18. required=cc
  19. . test-init.sh
  20. cat >> configure.ac <<'EOF'
  21. AC_PROG_CC
  22. AM_PROG_AR
  23. AC_PROG_RANLIB
  24. if test x"$doit" = x"yes"; then
  25. AC_SUBST([basehdr], [sub/base.h])
  26. AC_SUBST([nobasehdr], [sub/nobase.h])
  27. AC_SUBST([basedata], [sub/base.dat])
  28. AC_SUBST([nobasedata], [sub/nobase.dat])
  29. AC_SUBST([basescript], [sub/base.sh])
  30. AC_SUBST([nobasescript], [sub/nobase.sh])
  31. AC_SUBST([baseprog], ['sub/base$(EXEEXT)'])
  32. AC_SUBST([nobaseprog], ['sub/nobase$(EXEEXT)'])
  33. AC_SUBST([baselib], [sub/libbase.a])
  34. AC_SUBST([nobaselib], [sub/libnobase.a])
  35. fi
  36. AC_OUTPUT
  37. EOF
  38. cat > Makefile.am << 'EOF'
  39. foodir = $(prefix)/foo
  40. fooexecdir = $(prefix)/foo
  41. foo_HEADERS = @basehdr@
  42. nobase_foo_HEADERS = @nobasehdr@
  43. EXTRA_HEADERS = sub/base.h sub/nobase.h
  44. dist_foo_DATA = @basedata@
  45. nobase_dist_foo_DATA = @nobasedata@
  46. dist_fooexec_SCRIPTS = @basescript@
  47. nobase_dist_fooexec_SCRIPTS = @nobasescript@
  48. EXTRA_SCRIPTS = sub/base.sh sub/nobase.sh
  49. fooexec_PROGRAMS = @baseprog@
  50. nobase_fooexec_PROGRAMS = @nobaseprog@
  51. EXTRA_PROGRAMS = sub/base sub/nobase
  52. sub_base_SOURCES = source.c
  53. sub_nobase_SOURCES = source.c
  54. fooexec_LIBRARIES = @baselib@
  55. nobase_fooexec_LIBRARIES = @nobaselib@
  56. EXTRA_LIBRARIES = sub/libbase.a sub/libnobase.a
  57. sub_libbase_a_SOURCES = source.c
  58. sub_libnobase_a_SOURCES = source.c
  59. test-install-data: install-data
  60. test -f inst/foo/sub/nobase.h
  61. test ! -f inst/foo/nobase.h
  62. test -f inst/foo/base.h
  63. test -f inst/foo/sub/nobase.dat
  64. test ! -f inst/foo/nobase.dat
  65. test -f inst/foo/base.dat
  66. test ! -f inst/foo/sub/pnobase.sh
  67. test ! -f inst/foo/pbase.sh
  68. test ! -f inst/foo/sub/pnobase$(EXEEXT)
  69. test ! -f inst/foo/pbase$(EXEEXT)
  70. test ! -f inst/foo/sub/libnobase.a
  71. test ! -f inst/foo/libbase.a
  72. test-install-exec: install-exec
  73. test -f inst/foo/sub/pnobase.sh
  74. test ! -f inst/foo/pnobase.sh
  75. test -f inst/foo/pbase.sh
  76. test -f inst/foo/sub/pnobase$(EXEEXT)
  77. test ! -f inst/foo/pnobase$(EXEEXT)
  78. test -f inst/foo/pbase$(EXEEXT)
  79. test -f inst/foo/sub/libnobase.a
  80. test ! -f inst/foo/libnobase.a
  81. test -f inst/foo/libbase.a
  82. test-install-nothing-data: install-data
  83. test ! -f inst/foo/sub/nobase.h
  84. test ! -f inst/foo/nobase.h
  85. test ! -f inst/foo/base.h
  86. test ! -f inst/foo/sub/nobase.dat
  87. test ! -f inst/foo/nobase.dat
  88. test ! -f inst/foo/base.dat
  89. test ! -f inst/foo/sub/pnobase.sh
  90. test ! -f inst/foo/pbase.sh
  91. test ! -f inst/foo/sub/pnobase$(EXEEXT)
  92. test ! -f inst/foo/pbase$(EXEEXT)
  93. test ! -f inst/foo/sub/libnobase.a
  94. test ! -f inst/foo/libbase.a
  95. test-install-nothing-exec: install-exec
  96. test ! -f inst/foo/sub/pnobase.sh
  97. test ! -f inst/foo/pnobase.sh
  98. test ! -f inst/foo/pbase.sh
  99. test ! -f inst/foo/sub/pnobase$(EXEEXT)
  100. test ! -f inst/foo/pnobase$(EXEEXT)
  101. test ! -f inst/foo/pbase$(EXEEXT)
  102. test ! -f inst/foo/sub/libnobase.a
  103. test ! -f inst/foo/libnobase.a
  104. test ! -f inst/foo/libbase.a
  105. EOF
  106. mkdir sub
  107. : > sub/base.h
  108. : > sub/nobase.h
  109. : > sub/base.dat
  110. : > sub/nobase.dat
  111. : > sub/base.sh
  112. : > sub/nobase.sh
  113. cat >source.c <<'EOF'
  114. int
  115. main (int argc, char *argv[])
  116. {
  117. return 0;
  118. }
  119. EOF
  120. cp source.c source2.c
  121. rm -f install-sh
  122. $ACLOCAL
  123. $AUTOCONF
  124. $AUTOMAKE -a --copy
  125. ./configure --prefix "$(pwd)/inst" --program-prefix=p doit=yes
  126. $MAKE
  127. $MAKE test-install-data
  128. $MAKE test-install-exec
  129. $MAKE uninstall
  130. $MAKE clean
  131. test $(find inst/foo -type f -print | wc -l) -eq 0
  132. ./configure --prefix "$(pwd)/inst" --program-prefix=p doit=no
  133. $MAKE
  134. $MAKE test-install-nothing-data
  135. $MAKE test-install-nothing-exec
  136. $MAKE uninstall
  137. # Likewise, in a VPATH build.
  138. $MAKE distclean
  139. mkdir build
  140. cd build
  141. ../configure --prefix "$(pwd)/inst" --program-prefix=p doit=yes
  142. $MAKE
  143. $MAKE test-install-data
  144. $MAKE test-install-exec
  145. $MAKE uninstall
  146. test $(find inst/foo -type f -print | wc -l) -eq 0
  147. ../configure --prefix "$(pwd)/inst" --program-prefix=p doit=no
  148. $MAKE
  149. $MAKE test-install-nothing-data
  150. $MAKE test-install-nothing-exec
  151. :