maken3.sh 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. #! /bin/sh
  2. # Copyright (C) 2009-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 'make -n' for various targets, to ensure that:
  17. #
  18. # 1. no files or directories are created or removed, and
  19. #
  20. # 2. if using GNU make or a make implementation supporting the .MAKE
  21. # special target, the output from make is sufficiently complete.
  22. #
  23. # This test exercises the GCS-mandated targets (except for dist)
  24. # as well as tags.
  25. # For gen-testsuite-part: ==> try-with-serial-tests <==
  26. . test-init.sh
  27. # Does $MAKE support the '.MAKE' special target?
  28. have_dotmake=false
  29. if using_gmake; then
  30. have_dotmake=: # GNU make must support it.
  31. else
  32. unindent > mk.tmp << 'END'
  33. targ.tmp:
  34. : > $@
  35. .MAKE: targ.tmp
  36. END
  37. if $MAKE -n -f mk.tmp targ.tmp && test -f targ.tmp; then
  38. have_dotmake=:
  39. fi
  40. fi
  41. mkdir sub sub2
  42. cat >> configure.ac << 'END'
  43. AC_CONFIG_FILES([sub/Makefile sub2/Makefile])
  44. AC_OUTPUT
  45. END
  46. cat > Makefile.am <<'END'
  47. TESTS = foo.test
  48. SUBDIRS = sub sub2
  49. ##BUILT_SOURCES = foo
  50. foo:
  51. foo.test:
  52. all-local:
  53. @: > stamp-all
  54. install-data-local:
  55. @: > stamp-install
  56. uninstall-local:
  57. @: > stamp-uninstall
  58. clean-local:
  59. @: > stamp-clean
  60. distclean-local:
  61. @: > stamp-distclean
  62. info-local:
  63. @: > stamp-info
  64. html-local:
  65. @: > stamp-html
  66. dvi-local:
  67. @: > stamp-dvi
  68. ps-local:
  69. @: > stamp-ps
  70. pdf-local:
  71. @: > stamp-pdf
  72. check-local:
  73. @: > stamp-check
  74. installcheck-local:
  75. @: > stamp-installcheck
  76. mostlyclean-local:
  77. @: > stamp-mostlyclean
  78. maintainer-clean-local:
  79. @: > stamp-maintainer-clean
  80. END
  81. cat >sub/Makefile.am <<'END'
  82. all-local:
  83. @: > stamp-all-sub
  84. install-data-local:
  85. @: > stamp-install-sub
  86. uninstall-local:
  87. @: > stamp-uninstall-sub
  88. clean-local:
  89. @: > stamp-clean-sub
  90. distclean-local:
  91. @: > stamp-distclean-sub
  92. info-local:
  93. @: > stamp-info-sub
  94. html-local:
  95. @: > stamp-html-sub
  96. dvi-local:
  97. @: > stamp-dvi-sub
  98. ps-local:
  99. @: > stamp-ps-sub
  100. pdf-local:
  101. @: > stamp-pdf-sub
  102. check-local:
  103. @: > stamp-check-sub
  104. installcheck-local:
  105. @: > stamp-installcheck-sub
  106. tags:
  107. @: > stamp-tags-sub
  108. mostlyclean-local:
  109. @: > stamp-mostlyclean-sub
  110. maintainer-clean-local:
  111. @: > stamp-maintainer-clean-sub
  112. END
  113. cat >sub2/Makefile.am <<'END'
  114. all install uninstall clean check:
  115. @: > sub2-$@-should-not-be-executed
  116. info dvi pdf ps:
  117. @: > sub2-$@-should-not-be-executed
  118. html:
  119. @: > sub2-$@-should-not-be-executed
  120. install-info install-html install-dvi install-pdf install-ps:
  121. @: > sub2-$@-should-not-be-executed
  122. installcheck installdirs tags mostlyclean:
  123. @: > sub2-$@-should-not-be-executed
  124. ## These targets cannot be overridden like this:
  125. ## install-strip distclean maintainer-clean
  126. END
  127. $ACLOCAL
  128. $AUTOCONF
  129. check_targets ()
  130. {
  131. for target in \
  132. all install install-strip uninstall clean distclean check \
  133. info html dvi pdf ps \
  134. install-info install-html install-dvi install-pdf install-ps \
  135. installcheck installdirs tags mostlyclean maintainer-clean
  136. do
  137. run_make -O -- -n $target
  138. case $target in
  139. install-* | installdirs | tags ) ;;
  140. *)
  141. if $have_dotmake; then
  142. grep "stamp-$target$" stdout || exit 1
  143. fi
  144. test ! -e "stamp-$target" || exit 1
  145. ;;
  146. esac
  147. case $target in
  148. install-* | installdirs ) ;;
  149. *)
  150. if $have_dotmake; then
  151. grep "stamp-$target-sub" stdout || exit 1
  152. fi
  153. test ! -e "sub/stamp-$target-sub" || exit 1
  154. ;;
  155. esac
  156. case $target in
  157. distclean | maintainer-clean ) ;;
  158. *)
  159. if $have_dotmake; then
  160. grep "should-not-be-executed" stdout || exit 1
  161. fi
  162. test ! -e "sub2/sub2-$target-should-not-be-executed" || exit 1
  163. ;;
  164. esac
  165. done
  166. }
  167. $AUTOMAKE -a -Wno-override
  168. ./configure
  169. check_targets || exit 1
  170. # Now, introduce BUILT_SOURCES into the toplevel Makefile
  171. # TODO: add BUILT_SOURCES to sub2, fix fallout.
  172. sed 's/##//' < Makefile.am > t
  173. mv -f t Makefile.am
  174. $AUTOMAKE -Wno-override --force Makefile
  175. ./configure
  176. check_targets || exit 1
  177. exit 0