autodist-subdir.sh 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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 automake really automatically distributes all the files
  17. # it advertises to do, even when in subdirectories.
  18. #
  19. # This behavior might be suboptimal, but it has been in place for quite
  20. # a long time, and it would be risky to change it now. See also the
  21. # discussion of automake bug#7819:
  22. # <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7819>
  23. #
  24. # Keep this test in sync with sister test 'autodist.sh'.
  25. . test-init.sh
  26. cat >> configure.ac <<'END'
  27. AC_CONFIG_FILES([sub/Makefile])
  28. AC_OUTPUT
  29. END
  30. $ACLOCAL
  31. $AUTOCONF
  32. # The automake manual states that the list of automatically-distributed
  33. # files should be given by 'automake --help'.
  34. list=$($AUTOMAKE --help \
  35. | sed -n '/^Files.*automatically distributed.*if found.*always/,/^ *$/p' \
  36. | sed 1d)
  37. # Normalize whitespace, just in case.
  38. list=$(echo $list)
  39. test -n "$list"
  40. cat > Makefile.am <<'END'
  41. SUBDIRS = sub
  42. check-local:
  43. ## For debugging.
  44. @echo DIST_COMMON:
  45. @for f in $(DIST_COMMON); do echo " $$f"; done
  46. @echo DISTDIR:
  47. @ls -l $(distdir) | sed 's/^/ /'
  48. ## Now the checks.
  49. @for f in $(autodist_list); do \
  50. echo "file: sub/$$f"; \
  51. test -f $(distdir)/sub/$$f \
  52. || { echo $$f: distdir fail >&2; exit 1; }; \
  53. done
  54. END
  55. mkdir sub
  56. cat > sub/Makefile.am <<'END'
  57. include distfiles.am
  58. check-local:
  59. ## For debugging.
  60. @echo DIST_COMMON:
  61. @for f in $(DIST_COMMON); do echo " $$f"; done
  62. @echo DISTDIR:
  63. @ls -l $(distdir) | sed 's/^/ /'
  64. ## Now the checks.
  65. @for f in $(autodist_list); do \
  66. echo "file: $$f"; \
  67. ## Some filenames might contain dots, but this won't cause spurious
  68. ## failures, and "spurious successes" are so unlikely that they're
  69. ## not worth worrying about.
  70. echo ' ' $(DIST_COMMON) ' ' | grep "[ /]$$f " >/dev/null \
  71. || { echo $$f: distcom fail >&2; exit 1; }; \
  72. done
  73. END
  74. : First try listing the automatically-distributed files in proper
  75. : targets in Makefile.am
  76. echo "MAINTAINERCLEANFILES = $list" > sub/distfiles.am
  77. for f in $list; do echo "$f :; touch $f"; done >> sub/distfiles.am
  78. cat sub/distfiles.am # For debugging.
  79. $AUTOMAKE -a
  80. ./configure
  81. $MAKE distdir
  82. autodist_list="$list" $MAKE check
  83. $MAKE maintainer-clean
  84. test ! -e sub/README # Sanity check.
  85. rm -rf $me-1.0 # Remove $(distdir).
  86. : Now try creating the automatically-distributed files before
  87. : running automake.
  88. : > sub/distfiles.am
  89. for f in $list; do
  90. echo dummy > sub/$f
  91. done
  92. ls -l # For debugging.
  93. $AUTOMAKE
  94. ./configure
  95. $MAKE distdir
  96. autodist_list="$list" $MAKE check
  97. :