subdir-add2-pr46.sh 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #! /bin/sh
  2. # Copyright (C) 2003-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 to make sure that adding a new directory works, even from
  17. # subdirectories. The sister test 'subdir-add-pr46.sh' makes sure
  18. # it works when make is run from the top-level directory.
  19. # PR automake/46
  20. . test-init.sh
  21. cat >> configure.ac << 'END'
  22. AC_CONFIG_MACRO_DIR([m4])
  23. m4_include([confiles.m4])
  24. MORE_DEFS
  25. AC_OUTPUT
  26. END
  27. echo 'AC_CONFIG_FILES([sub/Makefile])' > confiles.m4
  28. cat > Makefile.am << 'END'
  29. SUBDIRS = sub
  30. END
  31. mkdir sub
  32. : > sub/Makefile.am
  33. mkdir m4
  34. echo 'AC_DEFUN([MORE_DEFS], [])' > m4/moredefs.m4
  35. $ACLOCAL
  36. $AUTOCONF
  37. $AUTOMAKE
  38. ./configure
  39. $MAKE
  40. # Now add new directories.
  41. # The first step users typically do when adding a new subdir is editing
  42. # configure.ac. That is already tested by 'subdir-add-pr46.sh' though,
  43. # so here we try to just edit a file that is included by configure.ac,
  44. # without touching configure.ac itself.
  45. mkdir sub/maude
  46. cat > sub/maude/Makefile.am << 'END'
  47. include_HEADERS = foo.h
  48. END
  49. : > sub/maude/foo.h
  50. echo 'SUBDIRS = maude' >> sub/Makefile.am
  51. mkdir maude
  52. : > maude/Makefile.am
  53. # Update confiles.m4 *after* updating sub/Makefile.am; the sister test
  54. # 'subdir-add-pr46.sh' does it the in other way: it updates configure.ac
  55. # before Makefile.am. We sleep here because modified configure
  56. # dependencies must be newer than config.status.
  57. $sleep
  58. echo 'AC_CONFIG_FILES([maude/Makefile sub/maude/Makefile])' >> confiles.m4
  59. # We want a simple rebuild from sub/ to create sub/maude/Makefile
  60. # and maude/Makefile automatically.
  61. cd sub
  62. $MAKE
  63. cd ..
  64. grep '^SUBDIRS = *maude *$' sub/Makefile.in
  65. grep '^SUBDIRS = *maude *$' sub/Makefile
  66. test -f maude/Makefile
  67. test -f sub/maude/Makefile
  68. # Make sure the dependencies of aclocal.m4 or honored at least from
  69. # the top-level directory.
  70. echo 'AC_DEFUN([MORE_DEFS], [AC_SUBST([GREPME])])' > m4/moredefs.m4
  71. $MAKE
  72. for ext in '.in' ''; do
  73. for d in . maude sub sub/maude; do
  74. grep '^GREPME =' $d/Makefile$ext
  75. done
  76. done
  77. :