remake-makefile-intree.sh 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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 basic remake rules for Makefiles, for an *in-tree build*.
  17. # This testcase checks dependency of generated Makefile from Makefile.am,
  18. # configure.ac, acinclude.m4, aclocal.m4, and extra m4 files considered
  19. # by aclocal.
  20. # Keep this in sync with sister test 'remake-makefile-vpath.sh', which
  21. # performs the same checks for a VPATH build.
  22. . test-init.sh
  23. mv -f configure.ac configure.stub
  24. cat > Makefile.am <<'END'
  25. all-local: foo
  26. foo:
  27. echo '!Foo!' >$@
  28. check-local:
  29. cat foo
  30. grep '!Foo!' foo
  31. CLEANFILES = foo
  32. END
  33. cat configure.stub - > configure.ac <<'END'
  34. AC_OUTPUT
  35. END
  36. $ACLOCAL
  37. $AUTOCONF
  38. $AUTOMAKE
  39. srcdir='.' # To make syncing with remake-makefile-vpath.sh easier.
  40. $srcdir/configure
  41. $MAKE
  42. cat foo
  43. grep '!Foo!' foo
  44. $MAKE distcheck
  45. rm -f foo
  46. # Modify just Makefile.am.
  47. $sleep
  48. cat > $srcdir/Makefile.am <<'END'
  49. all-local: bar
  50. bar:
  51. echo '!Baz!' >$@
  52. check-local:
  53. cat bar
  54. grep '!Baz!' bar
  55. test ! -r $(srcdir)/foo
  56. test ! -r foo
  57. CLEANFILES = bar
  58. END
  59. using_gmake || $MAKE Makefile
  60. $MAKE
  61. cat bar
  62. grep '!Baz!' bar
  63. test ! -e foo
  64. $MAKE distcheck
  65. rm -f bar
  66. # Modify Makefile.am and configure.ac.
  67. $sleep
  68. cat > $srcdir/Makefile.am <<'END'
  69. check-local:
  70. cat quux
  71. grep '!Zardoz!' quux
  72. test ! -r $(srcdir)/bar
  73. test ! -r bar
  74. END
  75. cat $srcdir/configure.stub - > $srcdir/configure.ac <<'END'
  76. AC_CONFIG_FILES([quux])
  77. AC_SUBST([QUUX], [Zardoz])
  78. AC_OUTPUT
  79. END
  80. cat > $srcdir/quux.in <<'END'
  81. !@QUUX@!
  82. END
  83. using_gmake || $MAKE Makefile
  84. $MAKE
  85. cat quux
  86. grep '!Zardoz!' quux
  87. test ! -e bar
  88. $MAKE distcheck
  89. rm -f quux
  90. # Modify configure.ac and aclocal.m4 to add a directory of extra m4
  91. # files considered by aclocal. Also update checks in Makefile.am.
  92. # Note that we won't use this new directory of extra m4 files in the
  93. # first rebuild below (but we will in the second).
  94. $sleep
  95. mkdir $srcdir/m4
  96. cat > $srcdir/Makefile.am <<'END'
  97. all-local: quux
  98. check-local:
  99. cat quux
  100. grep '%Foo%' quux
  101. test x'$(QUUX)' = x'%Foo%'
  102. END
  103. # Modify configure.ac and aclocal.m4.
  104. $sleep
  105. cat $srcdir/configure.stub - > $srcdir/configure.ac <<'END'
  106. AC_CONFIG_MACRO_DIR([m4])
  107. AC_CONFIG_FILES([quux])
  108. MY_CUSTOM_MACRO
  109. AC_OUTPUT
  110. END
  111. cat >> $srcdir/aclocal.m4 <<'END'
  112. AC_DEFUN([MY_CUSTOM_MACRO], [AC_SUBST([QUUX], [%Foo%])])
  113. END
  114. $MAKE
  115. cat quux
  116. grep '%Foo%' quux
  117. $MAKE distcheck
  118. # Modify Makefile.am, remove aclocal.m4, and add a new m4 file to
  119. # the directory of extra m4 files considered by aclocal. This new
  120. # file should now provide a macro required by configure.ac and that
  121. # was previously provided by aclocal.m4.
  122. $sleep
  123. sed 's/%Foo%/%Bar%/g' $srcdir/Makefile.am > t
  124. mv -f t $srcdir/Makefile.am
  125. cat $srcdir/Makefile.am
  126. rm -f $srcdir/aclocal.m4
  127. cat > $srcdir/m4/blah.m4 <<'END'
  128. AC_DEFUN([MY_CUSTOM_MACRO], [AC_SUBST([QUUX], [%Bar%])])
  129. END
  130. $MAKE
  131. cat quux
  132. grep '%Bar%' quux
  133. $MAKE distcheck
  134. # Modify Makefile.am, remove all the extra m4 files to considered
  135. # by aclocal, and add an acinclude.m4 file. This last file should
  136. # now provide a macro required by configure.ac, and that was
  137. # previously provided by the extra m4 files considered by aclocal.
  138. $sleep
  139. rm -f $srcdir/m4/*.m4
  140. sed 's/%Bar%/%Quux%/g' $srcdir/Makefile.am > t
  141. mv -f t $srcdir/Makefile.am
  142. cat $srcdir/Makefile.am
  143. cat > $srcdir/acinclude.m4 <<'END'
  144. AC_DEFUN([MY_CUSTOM_MACRO], [AC_SUBST([QUUX], [%Quux%])])
  145. END
  146. $MAKE
  147. cat quux
  148. grep '%Quux%' quux
  149. $MAKE distcheck
  150. :