distcheck-outdated-m4.sh 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. #! /bin/sh
  2. # Copyright (C) 2011-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 we can define a distcheck-hook to diagnose outdated m4
  17. # files in a dist tarball (interaction with '--install').
  18. # See automake bug#9037.
  19. . test-init.sh
  20. cwd=$(pwd) || fatal_ "cannot get current working directory"
  21. cp "$am_testaux_srcdir"/distcheck-hook-m4.am . \
  22. || fatal_ "cannot fetch makefile fragment 'distcheck-hook-m4.am'"
  23. cat > Makefile.am << 'END'
  24. ## The lack of '--install' here is meant.
  25. ACLOCAL_AMFLAGS = -I m4
  26. include $(srcdir)/distcheck-hook-m4.am
  27. END
  28. cat >> configure.ac << 'END'
  29. AC_OUTPUT
  30. MY_FOO
  31. MY_BAR
  32. MY_BAZ
  33. END
  34. mkdir m4 acdir
  35. echo 'AC_DEFUN([MY_FOO], [:])' > m4/foo.m4
  36. echo 'AC_DEFUN([MY_BAR], [:])' > acdir/bar.m4
  37. cat > acdir/baz.m4 << 'END'
  38. # serial 1
  39. AC_DEFUN([MY_BAZ], [:])
  40. END
  41. ACLOCAL="$ACLOCAL --system-acdir=$cwd/acdir"; export ACLOCAL
  42. # The use of '--install' here won't help when the installed file '.m4'
  43. # will become out-of-date w.r.t. the one in the system acdir.
  44. $ACLOCAL -I m4 --install
  45. $AUTOCONF
  46. $AUTOMAKE
  47. ./configure
  48. $MAKE distcheck # Sanity check.
  49. check_no_spurious_error ()
  50. {
  51. $EGREP -i 'mkdir:|:.*(permission|denied)' output && exit 1
  52. # On failure, some make implementations (such as Solaris make) print the
  53. # whole failed recipe on stdout. The first grep works around this.
  54. grep -v 'rm -rf ' output | grep -i 'autom4te.*\.cache' && exit 1
  55. : To placate 'set -e'.
  56. }
  57. # We start to use a new "third-party" macro in a new version
  58. # of a pre-existing third-party m4 file, but forget to re-run
  59. # "aclocal --install" by hand, relying on automatic remake
  60. # rules. Our distcheck-hook should catch this too.
  61. echo MY_ZARDOZ >> configure.ac
  62. cat > acdir/baz.m4 << 'END'
  63. # serial 2
  64. AC_DEFUN([MY_BAZ], [:])
  65. AC_DEFUN([MY_ZARDOZ], [:])
  66. END
  67. $MAKE # Rebuild configure and makefiles.
  68. run_make -M -e FAIL distcheck
  69. $EGREP "required m4 file.* outdated.* baz.m4( |$)" output
  70. check_no_spurious_error
  71. # Check that we don't complain for files that aren't outdated.
  72. $EGREP " (foo|bar).m4" output && exit 1
  73. # Now we again use '--install' explicitly, and "make distcheck"
  74. # should pass.
  75. $ACLOCAL -I m4 --install
  76. using_gmake || $MAKE Makefile
  77. $MAKE distcheck
  78. # Similar to what have been done above, but this time we:
  79. # - use ACLOCAL_PATH, and
  80. # - do not add the use of a new macro.
  81. echo MY_FNORD >> configure.ac
  82. mkdir pth
  83. cat > pth/fnord.m4 << 'END'
  84. # serial 1
  85. AC_DEFUN([MY_FNORD], [:])
  86. END
  87. ACLOCAL_PATH="$cwd/pth"; export ACLOCAL_PATH
  88. # The explicit use of '--install' here won't help when the installed file
  89. # '.m4' will become out-of-date w.r.t. the one in the system acdir.
  90. $ACLOCAL -I m4 --install
  91. using_gmake || $MAKE Makefile
  92. $MAKE distcheck
  93. # Only increase serial number, without changing the other contents; this
  94. # is deliberate.
  95. cat > pth/fnord.m4 << 'END'
  96. # serial 2
  97. AC_DEFUN([MY_FNORD], [:])
  98. END
  99. $MAKE # Rebuild configure and makefiles.
  100. run_make -M -e FAIL distcheck
  101. $EGREP "required m4 file.* outdated.* fnord.m4( |$)" output
  102. check_no_spurious_error
  103. # Check that we don't complain for files that aren't outdated.
  104. $EGREP " (foo|bar|baz).m4" output && exit 1
  105. # Now we again use '--install' explicitly, and "make distcheck"
  106. # should pass.
  107. $ACLOCAL -I m4 --install
  108. using_gmake || $MAKE Makefile
  109. $MAKE distcheck
  110. :