subdir-distclean.sh 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #! /bin/sh
  2. # Copyright (C) 2012-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 "./configure && make && make distclean" is actually a
  17. # no-op, even when conditional SUBDIRS are involved.
  18. . test-init.sh
  19. cat >> configure.ac << 'END'
  20. AC_CONFIG_FILES([sub1/Makefile sub2/Makefile sub1/subsub/Makefile])
  21. AM_CONDITIONAL([COND], [false])
  22. AC_SUBST([extra_subdirs], [''])
  23. AC_OUTPUT
  24. END
  25. mkdir sub1 sub2 sub1/subsub
  26. cat > Makefile.am << 'END'
  27. SUBDIRS = sub1
  28. if COND
  29. SUBDIRS += sub2
  30. endif
  31. END
  32. cat > sub1/Makefile.am << 'END'
  33. all-local:
  34. : > run
  35. CLEANFILES = run
  36. SUBDIRS = @extra_subdirs@
  37. DIST_SUBDIRS = subsub
  38. END
  39. cat > sub2/Makefile.am << 'END'
  40. all-local:
  41. @echo "Should not run in `pwd`!"
  42. exit 1
  43. DISTCLEANFILES = oops
  44. END
  45. cp sub2/Makefile.am sub1/subsub/Makefile.am
  46. $ACLOCAL
  47. $AUTOCONF
  48. $AUTOMAKE -c --add-missing
  49. ./configure
  50. test -f sub1/Makefile
  51. test -f sub2/Makefile
  52. test -f sub1/subsub/Makefile
  53. $MAKE
  54. test -f sub1/run
  55. touch sub2/oops sub1/subsub/oops
  56. $MAKE distclean
  57. test ! -e sub1/run
  58. test ! -e sub2/oops
  59. test ! -e sub1/subsub/oops
  60. test ! -e sub1/Makefile
  61. test ! -e sub2/Makefile
  62. test ! -e sub1/subsub/Makefile
  63. mkdir build
  64. cd build
  65. ../configure
  66. $MAKE
  67. test -f sub1/Makefile
  68. test -f sub2/Makefile
  69. test -f sub1/subsub/Makefile
  70. test -f sub1/run
  71. touch sub2/oops sub1/subsub/oops
  72. $MAKE maintainer-clean
  73. test ! -e sub1/run
  74. test ! -e sub2/oops
  75. test ! -e sub1/subsub/oops
  76. test ! -e sub1/Makefile
  77. test ! -e sub2/Makefile
  78. test ! -e sub1/subsub/Makefile
  79. cd ..
  80. ./configure
  81. $MAKE distclean
  82. :