remake-after-acinclude-m4.sh 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 remake rules when acinclude.m4 or its prerequisites change.
  17. # Keep in sync with the other sister tests 'remake-after-*.sh'.
  18. . test-init.sh
  19. magic1=::MagicStringOne::
  20. magic2=__MagicStringTwo__
  21. if using_gmake; then
  22. remake_() { $MAKE nil; }
  23. else
  24. remake_() { $MAKE Makefile && $MAKE foo.sh; }
  25. fi
  26. cat >> configure.ac <<END
  27. FINGERPRINT='my_fingerprint'
  28. AC_SUBST([FINGERPRINT])
  29. AC_CONFIG_FILES([foo.sh:foo.in], [chmod a+x foo.sh])
  30. AC_OUTPUT
  31. END
  32. cat > Makefile.am <<'END'
  33. nil:
  34. .PHONY: nil
  35. # The right way to extend an autogenerated aclocal.m4 is to provide
  36. # an acinclude.m4 file.
  37. $(srcdir)/acinclude.m4: $(srcdir)/tweak-acinclude-m4
  38. $(SHELL) $(srcdir)/tweak-acinclude-m4 <$@ >$@-t
  39. mv -f $@-t $@
  40. touch $@
  41. EXTRA_DIST = $(srcdir)/tweak-acinclude-m4
  42. # Used by "make distcheck" later.
  43. check-local:
  44. test x'$(FINGERPRINT)' = x'DummyValue'
  45. test x"`./foo.sh`" = x"DummyValue"
  46. END
  47. cat > foo.in <<END
  48. #!/bin/sh
  49. echo '@FINGERPRINT@'
  50. END
  51. echo "AC_DEFUN([my_fingerprint], [BadBadBad])" > acinclude.m4
  52. echo : > tweak-acinclude-m4 # It is a no-op by default.
  53. $ACLOCAL
  54. $AUTOCONF
  55. $AUTOMAKE
  56. for vpath in : false; do
  57. if $vpath; then
  58. mkdir build
  59. cd build
  60. srcdir=..
  61. else
  62. srcdir=.
  63. fi
  64. $srcdir/configure
  65. $MAKE # Should be a no-op.
  66. $sleep
  67. echo "AC_DEFUN([my_fingerprint], [$magic1])" > $srcdir/acinclude.m4
  68. remake_
  69. $FGREP FINGERPRINT Makefile # For debugging.
  70. $FGREP $magic1 Makefile
  71. test x"$(./foo.sh)" = x"$magic1"
  72. $sleep
  73. echo "echo 'AC_DEFUN([my_fingerprint], [$magic2])'" \
  74. > $srcdir/tweak-acinclude-m4
  75. remake_
  76. $FGREP FINGERPRINT Makefile # For debugging.
  77. $FGREP $magic1 Makefile && exit 1
  78. $FGREP $magic2 Makefile
  79. test x"$(./foo.sh)" = x"$magic2"
  80. $sleep
  81. echo : > $srcdir/tweak-acinclude-m4 # Make it a no-op again.
  82. echo "AC_DEFUN([my_fingerprint], [DummyValue])" > $srcdir/acinclude.m4
  83. using_gmake || remake_
  84. $MAKE distcheck
  85. $FGREP $magic1 Makefile && exit 1 # Sanity check.
  86. $FGREP $magic2 Makefile && exit 1 # Likewise.
  87. $MAKE distclean
  88. cd $srcdir
  89. done
  90. :