remake-makefile-vpath.sh 3.9 KB

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