dist-auxdir-many-subdirs.sh 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. # It should be legitimate for many subdir Makefiles to require the
  17. # same config-aux files.
  18. am_create_testdir=empty
  19. required=cc
  20. . test-init.sh
  21. count=0
  22. ocwd=$(pwd) || fatal_ "cannot get current working directory"
  23. # Usage: do_check [--add-missing] [CONFIG-AUXDIR-PATH=.]
  24. do_check ()
  25. {
  26. case $1 in
  27. -a|--add-missing) add_missing=yes; shift;;
  28. *) add_missing=no;;
  29. esac
  30. auxdir=${1-.}
  31. count=$(($count + 1))
  32. mkdir T$count.d
  33. cd T$count.d
  34. distdir=$me-$count
  35. unindent > configure.ac << END
  36. AC_INIT([$me], [$count])
  37. AC_CONFIG_AUX_DIR([$auxdir])
  38. AM_INIT_AUTOMAKE
  39. AC_PROG_CC
  40. # We don't want to require python or emcas in this test, so
  41. # the tricks below.
  42. AM_PATH_PYTHON([2.2], [], [:])
  43. EMACS=no; AM_PATH_LISPDIR
  44. AC_CONFIG_FILES([Makefile])
  45. END
  46. unindent > Makefile.stub <<'END'
  47. ## For depcomp.
  48. bin_PROGRAMS = foo
  49. foo_SOURCES = foo.c
  50. ## For py-compile.
  51. python_PYTHON = bar.py
  52. ## For test-driver.
  53. TESTS =
  54. END
  55. required_files='
  56. install-sh
  57. missing
  58. compile
  59. depcomp
  60. py-compile
  61. test-driver
  62. '
  63. echo "SUBDIRS =" > Makefile.am
  64. suffixes='0 1 2 3 4 5 6 7 8 9'
  65. for x in $suffixes; do
  66. mkdir sub$x
  67. echo "SUBDIRS += sub$x" >> Makefile.am
  68. echo "AC_CONFIG_FILES([sub$x/Makefile])" >> configure.ac
  69. cp Makefile.stub sub$x/Makefile.am
  70. echo 'int main (void) { return 0; }' > sub$x/foo.c
  71. touch sub$x/bar.py sub$x/baz.el
  72. done
  73. echo AC_OUTPUT >> configure.ac
  74. $ACLOCAL
  75. $AUTOCONF
  76. "$am_scriptdir"/install-sh -d $auxdir \
  77. || fatal_ "creating directory '$auxdir' with install-sh"
  78. if test $add_missing = yes; then
  79. $AUTOMAKE -a --copy
  80. for f in $required_files; do
  81. test -f $auxdir/$f
  82. # To ensure that if a auxiliary file is required and distributed
  83. # by many Makefiles, the "dist" rule won't try to copy it multiple
  84. # times in $(distdir).
  85. chmod a-w $auxdir/$f
  86. done
  87. else
  88. for f in $required_files; do
  89. cp "$am_scriptdir"/$f $auxdir/$f \
  90. || fatal_ "faild to fetch auxiliary script '$f'"
  91. # See comments above.
  92. chmod a-w $auxdir/$f
  93. done
  94. $AUTOMAKE
  95. fi
  96. for vpath in : false; do
  97. if $vpath; then
  98. mkdir build
  99. cd build
  100. srcdir=..
  101. else
  102. srcdir=.
  103. fi
  104. $srcdir/configure
  105. $MAKE distdir
  106. find $distdir # For debugging.
  107. for f in $required_files; do
  108. test -f $distdir/$auxdir/$f
  109. done
  110. cd $srcdir
  111. done
  112. cd "$ocwd" || fatal_ "cannot chdir back to '$ocwd'"
  113. }
  114. do_check .
  115. do_check --add-missing .
  116. do_check build-aux
  117. do_check --add-missing build-aux
  118. do_check a/b/c
  119. do_check --add-missing a/b/c
  120. :