autodist.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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.
  18. # Related to automake bug#7819.
  19. # Keep this test in sync with sister test 'autodist-subdir.sh'.
  20. am_create_testdir=empty
  21. . test-init.sh
  22. cat > configure.ac <<END
  23. AC_INIT([$me], [1.0])
  24. AC_CONFIG_AUX_DIR([.])
  25. AM_INIT_AUTOMAKE
  26. AC_CONFIG_FILES([Makefile])
  27. AC_OUTPUT
  28. END
  29. $ACLOCAL
  30. $AUTOCONF
  31. # The automake manual states that the list of automatically-distributed
  32. # files should be given by 'automake --help'.
  33. list=$($AUTOMAKE --help \
  34. | sed -n '/^Files.*automatically distributed.*if found.*always/,/^ *$/p' \
  35. | sed 1d)
  36. # Normalize whitespace, just in case.
  37. list=$(echo $list)
  38. test -n "$list"
  39. cat > Makefile.am <<'END'
  40. include distfiles.am
  41. check-local:
  42. ## For debugging.
  43. @echo DIST_COMMON:
  44. @for f in $(DIST_COMMON); do echo " $$f"; done
  45. @echo DISTDIR:
  46. @ls -l $(distdir) | sed 's/^/ /'
  47. ## Now the checks.
  48. @for f in $(autodist_list); do \
  49. echo "file: $$f"; \
  50. test -f $(distdir)/$$f \
  51. || { echo $$f: distdir fail >&2; exit 1; }; \
  52. ## Some filenames might contain dots, but this won't cause spurious
  53. ## failures, and "spurious successes" are so unlikely that they're
  54. ## not worth worrying about.
  55. echo ' ' $(DIST_COMMON) ' ' | grep "[ /]$$f " >/dev/null \
  56. || { echo $$f: distcom fail >&2; exit 1; }; \
  57. done
  58. END
  59. : First try listing the automatically-distributed files in proper
  60. : targets in Makefile.am
  61. echo "MAINTAINERCLEANFILES = $list" > distfiles.am
  62. for f in $list; do echo "$f :; touch $f"; done >> distfiles.am
  63. cat distfiles.am # For debugging.
  64. $AUTOMAKE -a
  65. ./configure
  66. $MAKE distdir
  67. autodist_list="$list" $MAKE check
  68. $MAKE maintainer-clean
  69. test ! -e README # Sanity check.
  70. rm -rf $me-1.0 # Remove $(distdir).
  71. : Now try creating the automatically-distributed files before
  72. : running automake.
  73. : > distfiles.am
  74. for f in $list; do
  75. echo dummy > $f
  76. done
  77. ls -l # For debugging.
  78. $AUTOMAKE
  79. ./configure
  80. $MAKE distdir
  81. autodist_list="$list" $MAKE check
  82. :