aclocal-no-force.sh 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #! /bin/sh
  2. # Copyright (C) 2003-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 aclocal does not overwrite aclocal.m4 needlessly.
  17. # Also make sure automake --no-force does not overwrite Makefile.in needlessly.
  18. . test-init.sh
  19. cat >> configure.ac << 'END'
  20. SOME_DEFS
  21. AC_CONFIG_FILES([sub/Makefile])
  22. END
  23. mkdir sub
  24. : > sub/Makefile.am
  25. cat >> Makefile.am << 'END'
  26. SUBDIRS = sub
  27. include fragment.inc
  28. END
  29. : > fragment.inc
  30. mkdir m4
  31. echo 'AC_DEFUN([SOME_DEFS], [])' > m4/somedefs.m4
  32. # Automake will take aclocal.m4 to be newer if it has the same timestamp
  33. # as Makefile.in. Avoid the confusing by sleeping.
  34. AUTOMAKE_after_aclocal ()
  35. {
  36. $sleep
  37. $AUTOMAKE --no-force
  38. }
  39. # aclocal will rewrite aclocal.m4 unless the input files are all older than the
  40. # existing aclocal.m4 -- sleep to ensure somedefs.m4 has an older timestamp
  41. # than the aclocal.m4 that the next aclocal call will generate.
  42. $sleep
  43. $ACLOCAL -I m4
  44. AUTOMAKE_after_aclocal
  45. touch foo
  46. $sleep
  47. $ACLOCAL -I m4
  48. AUTOMAKE_after_aclocal
  49. # aclocal.m4 and Makefile.in should not have been updated, so 'foo'
  50. # should be younger
  51. is_newest foo aclocal.m4 Makefile.in sub/Makefile.in
  52. $sleep
  53. $ACLOCAL -I m4 --force
  54. is_newest aclocal.m4 foo
  55. # We still use --no-force for automake, but since aclocal.m4 has
  56. # changed all Makefile.ins should be updated.
  57. AUTOMAKE_after_aclocal
  58. is_newest Makefile.in aclocal.m4 foo
  59. is_newest sub/Makefile.in aclocal.m4 foo
  60. $sleep
  61. touch m4/somedefs.m4
  62. $sleep
  63. $ACLOCAL -I m4
  64. AUTOMAKE_after_aclocal
  65. # aclocal.m4 should have been updated, although its contents haven't
  66. # changed.
  67. is_newest aclocal.m4 m4/somedefs.m4
  68. is_newest Makefile.in m4/somedefs.m4
  69. is_newest sub/Makefile.in m4/somedefs.m4
  70. $sleep
  71. touch fragment.inc
  72. $sleep
  73. $ACLOCAL -I m4
  74. AUTOMAKE_after_aclocal
  75. # Only ./Makefile.in should change.
  76. is_newest Makefile.in fragment.inc
  77. is_newest fragment.inc aclocal.m4
  78. is_newest fragment.inc sub/Makefile.in
  79. grep README Makefile.in && exit 1
  80. $sleep
  81. : > README
  82. $sleep
  83. $AUTOMAKE --no-force
  84. # Even if no dependency change, the content changed.
  85. is_newest Makefile.in README
  86. is_newest README sub/Makefile.in
  87. grep README Makefile.in
  88. : > sub/Makefile.in
  89. $sleep
  90. touch foo
  91. $sleep
  92. $ACLOCAL -I m4
  93. $AUTOMAKE --no-force
  94. # Only sub/Makefile.in should change.
  95. is_newest foo aclocal.m4
  96. is_newest foo Makefile.in
  97. is_newest sub/Makefile.in foo
  98. :