remake-after-aclocal-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 aclocal.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. # A non-autogenerated aclocal.m4 can be extended by hand.
  36. $(srcdir)/aclocal.m4: $(srcdir)/tweak-aclocal-m4
  37. $(SHELL) $(srcdir)/tweak-aclocal-m4 <$@ >$@-t
  38. mv -f $@-t $@
  39. touch $@
  40. EXTRA_DIST = $(srcdir)/tweak-aclocal-m4
  41. # Used by "make distcheck" later.
  42. check-local:
  43. test x'$(FINGERPRINT)' = x'DummyValue'
  44. test x"`./foo.sh`" = x"DummyValue"
  45. END
  46. cat > foo.in <<END
  47. #!/bin/sh
  48. echo '@FINGERPRINT@'
  49. END
  50. echo cat > tweak-aclocal-m4 # It is a no-op by default.
  51. $ACLOCAL
  52. # Cheatingly mark aclocal.m4 as non auto-generated.
  53. sed '/^ *#.*generated automatically/d' aclocal.m4 > t
  54. mv -f t aclocal.m4
  55. $AUTOCONF
  56. $AUTOMAKE
  57. for vpath in : false; do
  58. if $vpath; then
  59. mkdir build
  60. cd build
  61. srcdir=..
  62. else
  63. srcdir=.
  64. fi
  65. $srcdir/configure
  66. $MAKE # Should be a no-op.
  67. $sleep
  68. echo "AC_DEFUN([my_fingerprint], [$magic1])dnl %%%" >> $srcdir/aclocal.m4
  69. remake_
  70. $FGREP FINGERPRINT Makefile # For debugging.
  71. $FGREP $magic1 Makefile
  72. test x"$(./foo.sh)" = x"$magic1"
  73. $sleep
  74. echo "sed 's/.*dnl *%%%.*/AC_DEFUN([my_fingerprint], [$magic2])/'" \
  75. > $srcdir/tweak-aclocal-m4
  76. remake_
  77. $FGREP FINGERPRINT Makefile # For debugging.
  78. $FGREP $magic1 Makefile && exit 1
  79. $FGREP $magic2 Makefile
  80. test x"$(./foo.sh)" = x"$magic2"
  81. $sleep
  82. echo cat > $srcdir/tweak-aclocal-m4 # Make it a no-op again.
  83. echo 'AC_DEFUN([my_fingerprint], [DummyValue])' >> $srcdir/aclocal.m4
  84. using_gmake || remake_
  85. $MAKE distcheck
  86. $FGREP $magic1 Makefile && exit 1 # Sanity check.
  87. $FGREP $magic2 Makefile && exit 1 # Likewise.
  88. $MAKE distclean
  89. cd $srcdir
  90. done
  91. :