dist-repeated.sh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. # Test that we can distribute the same file as many times as we want.
  17. # The distdir target should take care of not copying it more than one
  18. # time anyway.
  19. . test-init.sh
  20. echo AC_OUTPUT >> configure.ac
  21. cat > Makefile.am <<'END'
  22. bin_PROGRAMS = foo bar
  23. foo_SOURCES = foo.c
  24. bar_SOURCES = foo.c
  25. python_PYTHON = bar.py
  26. EXTRA_DIST = foo.c bar.py
  27. .PHONY: sanity-check
  28. sanity-check:
  29. for f in $(DISTFILES); do echo " $$f "; done > dist.txt
  30. cat dist.txt
  31. test `grep ' foo\.c ' dist.txt | wc -l` -eq 3
  32. test `grep ' bar\.py ' dist.txt | wc -l` -eq 2
  33. # So that we don't have to require a C compiler.
  34. AUTOMAKE_OPTIONS = no-dependencies
  35. CC = false
  36. # So that we don't have to require a Python interpreter.
  37. pythondir = ${prefix}/py
  38. PYTHON = false
  39. END
  40. ocwd=$(pwd) || fatal_ "cannot get current working directory"
  41. # Help to ensure cp won't see the same file twice.
  42. mkdir bin
  43. cat > bin/cp <<END
  44. #!/bin/sh
  45. PATH='$PATH'; export PATH
  46. case " \$* " in
  47. *foo.c\ *)
  48. if test -f '$ocwd'/foo-c-copied; then
  49. echo "\$0: we tried to copy foo.c twice" >&2
  50. exit 1
  51. else
  52. # For a sanity check later.
  53. echo ok > '$ocwd'/cp-wrapper-has-seen-foo-c
  54. fi
  55. ;;
  56. esac
  57. case " \$* " in
  58. *bar.py\ *)
  59. if test -f '$ocwd'/bar-py-copied; then
  60. echo "\$0: we tried to copy bar.py twice" >&2
  61. exit 1
  62. else
  63. # For a sanity check later.
  64. echo ok > '$ocwd'/cp-wrapper-has-seen-bar-py
  65. fi
  66. ;;
  67. esac
  68. exec cp "\$@"
  69. END
  70. chmod a+x bin/cp
  71. PATH=$(pwd)/bin$PATH_SEPARATOR$PATH; export PATH;
  72. : > foo.c
  73. : > bar.py
  74. : > py-compile
  75. # Help to ensure cp won't try to copy the same file twice.
  76. chmod a-w foo.c bar.py
  77. $ACLOCAL
  78. $AUTOCONF
  79. $AUTOMAKE
  80. ./configure
  81. $MAKE sanity-check || fatal_ "expected invariants not verified"
  82. $MAKE distdir
  83. test -f cp-wrapper-has-seen-foo-c && test -f cp-wrapper-has-seen-bar-py \
  84. || fatal_ "our cp wrapper hasn't run correctly"
  85. :