recurs-user-deeply-nested.sh 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 recursion on user-defined targets can be made to work
  17. # with "deeply" nested uses of $(SUBDIRS).
  18. . test-init.sh
  19. cat >> configure.ac <<'END'
  20. AC_CONFIG_FILES([
  21. sub1/Makefile
  22. sub1/sub2/Makefile
  23. sub1/sub2/sub3/Makefile
  24. sub1/sub2/sub3/sub4/Makefile
  25. ])
  26. AM_EXTRA_RECURSIVE_TARGETS([foo])
  27. AC_OUTPUT
  28. END
  29. dirs='sub1 sub1/sub2 sub1/sub2/sub3 sub1/sub2/sub3/sub4'
  30. mkdir $dirs
  31. cat > Makefile.am <<'END'
  32. SUBDIRS = sub1
  33. foo-local:
  34. cp sub1/foo foo
  35. MOSTLYCLEANFILES = foo
  36. .PHONY: test
  37. test:
  38. echo 'It works!' > exp
  39. diff exp foo
  40. diff exp sub1/foo
  41. test ! -f sub1/sub2/foo
  42. test ! -f sub1/sub2/sub3/foo
  43. diff exp sub1/sub2/sub3/sub4/foo
  44. rm -f exp
  45. all-local: foo
  46. check-local: test
  47. END
  48. cat > sub1/Makefile.am <<'END'
  49. SUBDIRS = sub2
  50. foo-local:
  51. test ! -f sub2/sub3/foo
  52. cp sub2/sub3/sub4/foo foo
  53. MOSTLYCLEANFILES = foo
  54. END
  55. # Here we deliberately lack an explicit definition the 'foo-local'
  56. # target; that shouldn't stop 'foo' recursion into subdirectory
  57. # 'sub3/sub4'.
  58. echo SUBDIRS = sub3 > sub1/sub2/Makefile.am
  59. echo SUBDIRS = sub4 > sub1/sub2/sub3/Makefile.am
  60. cat > sub1/sub2/sub3/sub4/Makefile.am <<'END'
  61. foo-local:
  62. echo 'It works!' > foo
  63. MOSTLYCLEANFILES = foo
  64. END
  65. $ACLOCAL
  66. $AUTOCONF
  67. $AUTOMAKE
  68. for d in $dirs; do
  69. $FGREP foo-am $d/Makefile.in || exit 1
  70. case $d in
  71. */sub4);;
  72. *) $FGREP foo-recursive $d/Makefile.in || exit 1;;
  73. esac
  74. done
  75. ./configure
  76. $MAKE foo
  77. $MAKE test
  78. $MAKE distcheck
  79. :