remake-after-configure-ac.sh 2.6 KB

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