distcheck-missing-m4.sh 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 m4 files
  17. # missing from the 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. dnl We *deliberately* don't use m4_pattern_forbid here.
  30. AC_OUTPUT
  31. MY_FOO
  32. MY_BAR
  33. MY_BAZ
  34. MY_ZAR
  35. END
  36. mkdir m4 acdir acdir1 acdir2 pth
  37. cat > acdir/dirlist << END
  38. $cwd/acdir1
  39. $cwd/acdir2
  40. END
  41. echo 'AC_DEFUN([MY_FOO], [:])' > m4/foo.m4
  42. echo 'AC_DEFUN([MY_BAR], [:])' > acdir1/bar.m4
  43. echo 'AC_DEFUN([MY_BAZ], [:])' > acdir1/baz.m4
  44. echo 'AC_DEFUN([MY_QUX], [:])' > acdir2/qux.m4
  45. echo 'AC_DEFUN([MY_ZAR], [:])' > pth/zar.m4
  46. echo 'AC_DEFUN([MY_BLA], [:])' > pth/bla.m4
  47. ACLOCAL="$ACLOCAL --system-acdir=$cwd/acdir"; export ACLOCAL
  48. ACLOCAL_PATH=$cwd/pth; export ACLOCAL_PATH
  49. # We don't use '--install' here. Our distcheck-hook should catch this.
  50. $ACLOCAL -I m4
  51. $AUTOCONF
  52. $EGREP 'MY_(FOO|BAR|BAZ|ZAR)' configure && exit 1 # Sanity check.
  53. $AUTOMAKE
  54. check_no_spurious_error ()
  55. {
  56. $EGREP -i 'mkdir:|:.*(permission|denied)' output && exit 1
  57. # On failure, some make implementations (such as Solaris make) print the
  58. # whole failed recipe on stdout. The first grep works around this.
  59. grep -v 'rm -rf ' output | grep -i 'autom4te.*\.cache' && exit 1
  60. : To placate 'set -e'.
  61. }
  62. ./configure
  63. run_make -M -e FAIL distcheck
  64. for x in bar baz zar; do
  65. $EGREP "required m4 file.*not distributed.* $x.m4( |$)" output
  66. done
  67. check_no_spurious_error
  68. # Now we use '--install', and "make distcheck" should pass.
  69. $ACLOCAL -I m4 --install
  70. test -f m4/bar.m4 # Sanity check.
  71. test -f m4/baz.m4 # Likewise.
  72. test -f m4/zar.m4 # Likewise.
  73. using_gmake || $MAKE Makefile
  74. $MAKE distcheck
  75. # We start to use new "third-party" macros from new .m4 files, but forget
  76. # to re-run "aclocal --install" by hand, relying on automatic remake rules.
  77. # Our distcheck-hook should catch this too.
  78. cat >> configure.ac << 'END'
  79. MY_QUX
  80. MY_BLA
  81. END
  82. $MAKE
  83. $EGREP 'MY_(FOO|BAR|BAZ|QUX|ZAR|BLA)' configure && exit 1 # Sanity check.
  84. run_make -M -e FAIL distcheck
  85. $EGREP "required m4 file.*not distributed.* qux.m4( |$)" output
  86. $EGREP "required m4 file.*not distributed.* bla.m4( |$)" output
  87. check_no_spurious_error
  88. # Check that we don't complain for files that should have been found.
  89. $FGREP " (bar|baz|zar).m4" output && exit 1
  90. # Now we again use '--install', and "make distcheck" should pass.
  91. $ACLOCAL -I m4 --install
  92. test -f m4/qux.m4 # Sanity check.
  93. test -f m4/bla.m4 # Likewise.
  94. using_gmake || $MAKE Makefile
  95. $MAKE distcheck
  96. :