remake-subdir-long-time.sh 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #! /bin/sh
  2. # Copyright (C) 2011-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. # Check that remake rules from subdirectories do not hang or cycle
  17. # endlessly, even with build systems that takes several seconds to
  18. # rebuild the Makefiles.
  19. # This test tries to ensure a long-enough rebuild time by introducing
  20. # an explicit delay in the build process.
  21. # Suggestion by Ralf Wildenhues.
  22. . test-init.sh
  23. cat > configure.ac <<END
  24. AC_INIT([$me], [1.0])
  25. AM_INIT_AUTOMAKE([foreign -Wall -Werror])
  26. AC_CONFIG_FILES([Makefile sub/Makefile])
  27. AC_SUBST([MAGIC], [magic])
  28. AC_OUTPUT
  29. END
  30. echo SUBDIRS = sub > Makefile.am
  31. mkdir sub
  32. : > sub/Makefile.am
  33. # Both aclocal and automake are expected to run one and just one time.
  34. # Create and use wrappers that will verify that.
  35. ocwd=$(pwd) || fatal_ "cannot get current working directory"
  36. mkdir bin
  37. cat > bin/automake <<END
  38. #!/bin/sh
  39. set -e
  40. PATH='$PATH'; export PATH
  41. sentinel='$ocwd/automake-has-run'
  42. if test -f "\$sentinel"; then
  43. echo "Automake has been run more than one time" >&2
  44. exit 1
  45. else
  46. echo automake has run > "\$sentinel"
  47. fi
  48. $sleep; $sleep;
  49. exec $AUTOMAKE \${1+"\$@"}
  50. END
  51. chmod a+x bin/automake
  52. cat > bin/aclocal <<END
  53. #!/bin/sh
  54. set -e
  55. PATH='$PATH'; export PATH
  56. sentinel='$ocwd/aclocal-has-run'
  57. if test -f "\$sentinel"; then
  58. echo "Aclocal has been run more than one time" >&2
  59. exit 1
  60. else
  61. echo aclocal has run > "\$sentinel"
  62. fi
  63. $sleep; $sleep;
  64. exec $ACLOCAL \${1+"\$@"}
  65. END
  66. chmod a+x bin/aclocal
  67. # Just to be sure.
  68. cp bin/automake bin/automake-$APIVERSION
  69. cp bin/aclocal bin/aclocal-$APIVERSION
  70. PATH=$ocwd/bin$PATH_SEPARATOR$PATH; export PATH
  71. AUTOMAKE=automake ACLOCAL=aclocal; export AUTOMAKE ACLOCAL
  72. $ACLOCAL # Should use or just-defined wrapper.
  73. $AUTOMAKE # Likewise.
  74. $AUTOCONF
  75. # Sanity check: the wrappers have been used.
  76. test -f automake-has-run
  77. test -f aclocal-has-run
  78. rm -f automake-has-run aclocal-has-run
  79. ./configure
  80. # Sanity check: Makefile doesn't get updated uselessly.
  81. run_make ACLOCAL=false AUTOMAKE=false AUTOCONF=false
  82. $sleep
  83. sed "s|magic|magic2|" configure.ac > t
  84. mv -f t configure.ac
  85. cd sub
  86. run_make Makefile AUTOMAKE="$AUTOMAKE" ACLOCAL="$ACLOCAL"
  87. cd ..
  88. # For debugging.
  89. ls -l . sub
  90. grep -i magic configure Makefile.in Makefile sub/Makefile.in sub/Makefile
  91. # Sanity checks.
  92. $FGREP magic2 configure
  93. $FGREP magic2 Makefile
  94. $FGREP magic2 sub/Makefile
  95. :