remake-after-makefile-am.sh 2.6 KB

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