aclocal-m4-include-are-scanned-aclocal-amflags.sh 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #! /bin/sh
  2. # Copyright (C) 2004-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. # Make sure m4_included files are also scanned for definitions.
  17. # Report from Phil Edwards.
  18. . test-init.sh
  19. cat >> configure.ac << 'END'
  20. AM_PROG_LIBTOOL
  21. AC_OUTPUT
  22. END
  23. echo 'm4_include([a.m4])' > acinclude.m4
  24. echo 'm4_include([b.m4])' > a.m4
  25. cat >b.m4 <<EOF
  26. m4_include([c.m4])
  27. AC_DEFUN([AM_PROG_LIBTOOL],
  28. [AC_REQUIRE([SOMETHING])dnl
  29. AC_REQUIRE([SOMETHING_ELSE])dnl
  30. ])
  31. AC_DEFUN([SOMETHING])
  32. EOF
  33. echo 'm4_include([d.m4])' > c.m4
  34. echo 'AC_DEFUN([SOMETHING_ELSE])' >d.m4
  35. mkdir defs
  36. echo 'AC_DEFUN([SOMETHING_ELSE])' >defs/e.m4
  37. echo 'AC_DEFUN([ANOTHER_MACRO])' >defs/f.m4
  38. cat >>Makefile.am<<\EOF
  39. ACLOCAL_AMFLAGS = -I defs
  40. testdist1: distdir
  41. test -f $(distdir)/acinclude.m4
  42. test -f $(distdir)/a.m4
  43. test -f $(distdir)/b.m4
  44. test -f $(distdir)/c.m4
  45. test -f $(distdir)/d.m4
  46. test ! -d $(distdir)/defs
  47. testdist2: distdir
  48. test -f $(distdir)/acinclude.m4
  49. test -f $(distdir)/a.m4
  50. test -f $(distdir)/b.m4
  51. test -f $(distdir)/c.m4
  52. test -f $(distdir)/d.m4
  53. test ! -f $(distdir)/defs/e.m4
  54. test -f $(distdir)/defs/f.m4
  55. EOF
  56. $ACLOCAL -I defs
  57. $FGREP acinclude.m4 aclocal.m4
  58. # None of the following macro should be included. acinclude.m4
  59. # includes the first four, and the last two are not needed at all.
  60. $FGREP a.m4 aclocal.m4 && exit 1
  61. $FGREP b.m4 aclocal.m4 && exit 1
  62. $FGREP c.m4 aclocal.m4 && exit 1
  63. $FGREP d.m4 aclocal.m4 && exit 1
  64. $FGREP defs/e.m4 aclocal.m4 && exit 1
  65. $FGREP defs/f.m4 aclocal.m4 && exit 1
  66. $AUTOCONF
  67. $AUTOMAKE
  68. ./configure
  69. $MAKE testdist1
  70. cp aclocal.m4 aclocal.old
  71. $sleep
  72. echo 'AC_DEFUN([FOO], [ANOTHER_MACRO])' >> c.m4
  73. $MAKE
  74. # Because c.m4 has changed, aclocal.m4 must have been rebuilt.
  75. is_newest aclocal.m4 aclocal.old
  76. # However, since FOO is not used, f.m4 should not be included
  77. # and the contents of aclocal.m4 should remain the same
  78. diff aclocal.m4 aclocal.old
  79. # If FOO where to be used, that would be another story, of course:
  80. # f.m4 should be included
  81. $sleep
  82. echo FOO >> configure.ac
  83. $MAKE
  84. $FGREP defs/f.m4 aclocal.m4
  85. $MAKE testdist2
  86. # Make sure aclocal diagnose missing included files with correct 'file:line:'.
  87. rm -f b.m4
  88. $ACLOCAL 2>stderr && { cat stderr >&2; exit 1; }
  89. cat stderr >&2
  90. grep 'a\.m4:1: .*b\.m4.*does not exist' stderr
  91. :