silent-many-languages.sh 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. #!/bin/sh
  2. # Copyright (C) 2009-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 silent-rules mode, with many languages at once.
  17. # This test partly overlaps with other 'silent*.sh', but it serves as
  18. # a stress test by using many different languages at once -- so don't
  19. # remove this test script.
  20. required='cc c++ fortran fortran77 lex yacc'
  21. . test-init.sh
  22. # Avoids too much code duplication.
  23. do_and_check_silent_build ()
  24. {
  25. case $1 in
  26. --rebuild) rebuild=true;;
  27. *) rebuild=false;;
  28. esac
  29. run_make -O
  30. # Avoid spurious failures with SunStudio Fortran compilers.
  31. sed '/^NOTICE:/d' stdout > t
  32. mv -f t stdout
  33. cat stdout
  34. $EGREP ' (-c|-o)' stdout && exit 1
  35. $EGREP '(mv|ylwrap) ' stdout && exit 1
  36. grep 'CXX .*foo1\.' stdout
  37. grep 'CXX .*baz1\.' stdout
  38. grep 'FC .*foo2\.' stdout
  39. grep 'FC .*baz2\.' stdout
  40. grep 'F77 .*foo3\.' stdout
  41. grep 'F77 .*baz3\.' stdout
  42. grep ' CC .*foo5\.' stdout
  43. grep ' CC .*baz5\.' stdout
  44. grep ' CC .*foo6\.' stdout
  45. grep ' CC .*baz6\.' stdout
  46. grep 'CXXLD .*foo' stdout
  47. grep 'CCLD .*bar' stdout
  48. grep 'CXXLD .*baz' stdout
  49. grep 'CCLD .*bla' stdout
  50. if ! $rebuild; then
  51. grep 'YACC .*foo6\.' stdout
  52. grep 'YACC .*baz6\.' stdout
  53. grep 'LEX .*foo5\.' stdout
  54. grep 'LEX .*baz5\.' stdout
  55. fi
  56. unset rebuild
  57. }
  58. # Avoids too much code duplication.
  59. do_and_check_verbose_build ()
  60. {
  61. case $1 in
  62. --rebuild) rebuild=true;;
  63. *) rebuild=false;;
  64. esac
  65. run_make -O V=1
  66. grep ' -c ' stdout
  67. grep ' -o ' stdout
  68. $EGREP '(CC|CXX|FC|F77|LD) ' stdout && exit 1
  69. if ! $rebuild; then
  70. grep 'ylwrap ' stdout
  71. $EGREP '(LEX|YACC) ' stdout && exit 1
  72. fi
  73. unset rebuild
  74. }
  75. mkdir sub
  76. cat >>configure.ac <<'EOF'
  77. AC_PROG_F77
  78. AC_PROG_FC
  79. AC_PROG_LEX
  80. AC_PROG_YACC
  81. AC_PROG_CXX
  82. # The SunStudio C++ compiler is unfortunately named 'sunCC' (or even just
  83. # 'CC', yuck!); similarly and the Portland group C++ compiler is named
  84. # 'pgCC'. This can cause problems with our grepping checks on the output
  85. # from make. Avoid these problems by invoking a wrapper script, as
  86. # filtering the make output proved too fragile.
  87. case " $CXX " in
  88. *'CC '*)
  89. AC_MSG_WARN([the C++ compiler '$CXX' name ends with 'CC'])
  90. AC_MSG_WARN([it will be wrapped with the custom script 'am--cxx'])
  91. echo '#!/bin/sh' > bin/am--cxx
  92. echo 'PATH=$saved_PATH; export PATH' >> bin/am--cxx
  93. echo "case \$# in" >> bin/am--cxx
  94. echo " 0) exec $CXX ;;" >> bin/am--cxx
  95. echo " *) exec $CXX \"\$@\" ;;" >> bin/am--cxx
  96. echo "esac" >> bin/am--cxx
  97. chmod a+x bin/am--cxx
  98. CXX=am--cxx
  99. esac
  100. AC_CONFIG_FILES([sub/Makefile])
  101. AC_OUTPUT
  102. EOF
  103. cat > Makefile.am <<'EOF'
  104. # Need generic and non-generic rules.
  105. bin_PROGRAMS = foo bar fo2
  106. bar_CFLAGS = $(AM_CFLAGS)
  107. foo_SOURCES = foo1.cpp foo2.f90 foo3.f foo5.l foo6.y
  108. fo2_SOURCES = $(foo_SOURCES)
  109. fo2_CPPFLAGS = $(AM_CPPFLAGS)
  110. fo2_FFLAGS = $(AM_FFLAGS)
  111. fo2_FCFLAGS = $(AM_FCFLAGS)
  112. fo2_YFLAGS = -v
  113. fo2_LFLAGS = -n
  114. SUBDIRS = sub
  115. AM_YFLAGS = -d
  116. LDADD = $(LEXLIB)
  117. BUILT_SOURCES = foo6.h
  118. EOF
  119. cat > sub/Makefile.am <<'EOF'
  120. AUTOMAKE_OPTIONS = subdir-objects
  121. # Need generic and non-generic rules.
  122. bin_PROGRAMS = baz bla ba2
  123. bla_CFLAGS = $(AM_CFLAGS)
  124. baz_SOURCES = baz1.cpp baz2.f90 baz3.f baz5.l baz6.y
  125. ba2_SOURCES = $(baz_SOURCES)
  126. ba2_CPPFLAGS = $(AM_CPPFLAGS)
  127. ba2_FFLAGS = $(AM_FFLAGS)
  128. ba2_FCFLAGS = $(AM_FCFLAGS)
  129. ba2_YFLAGS = -v
  130. ba2_LFLAGS = -n
  131. AM_YFLAGS = -d
  132. LDADD = $(LEXLIB)
  133. BUILT_SOURCES = baz6.h
  134. EOF
  135. cat > foo1.cpp <<'EOF'
  136. int main ()
  137. {
  138. return 0;
  139. }
  140. EOF
  141. cat > foo2.f90 <<'EOF'
  142. subroutine foo2
  143. return
  144. end
  145. EOF
  146. cat > foo3.f <<'EOF'
  147. subroutine foo3
  148. return
  149. end
  150. EOF
  151. cat > foo5.l <<'EOF'
  152. %{
  153. #define YY_NO_UNISTD_H 1
  154. %}
  155. %%
  156. "END" return EOF;
  157. .
  158. %%
  159. /* Avoid possible link errors. */
  160. int yywrap (void)
  161. {
  162. return 1;
  163. }
  164. EOF
  165. cat > foo6.y <<'EOF'
  166. %{
  167. void yyerror (char *s) {}
  168. %}
  169. %token EOF
  170. %%
  171. fubar : 'f' 'o' 'o' 'b' 'a' 'r' EOF {};
  172. EOF
  173. cp foo1.cpp bar.c
  174. cp foo1.cpp sub/baz.c
  175. cp foo1.cpp sub/bla.c
  176. cp foo1.cpp sub/baz1.cpp
  177. cp foo2.f90 sub/baz2.f90
  178. cp foo3.f sub/baz3.f
  179. cp foo5.l sub/baz5.l
  180. cp foo6.y sub/baz6.y
  181. mkdir bin
  182. saved_PATH=$PATH; export saved_PATH
  183. PATH=$(pwd)/bin$PATH_SEPARATOR$PATH; export PATH
  184. $ACLOCAL
  185. $AUTOMAKE --add-missing
  186. $AUTOCONF
  187. # Ensure per-target rules are used, to ensure their coverage below.
  188. # (We do not do an exhaustive check, that wouldn't be practical).
  189. $FGREP 'bar-bar.o' Makefile.in
  190. $FGREP 'fo2-foo5.c' Makefile.in
  191. $FGREP 'fo2-foo6.c' Makefile.in
  192. # Force dependency tracking explicitly, so that slow dependency
  193. # extractors are not rejected. Try also with dependency tracking
  194. # explicitly disabled.
  195. for config_args in \
  196. --enable-dependency-tracking --disable-dependency-tracking
  197. do
  198. ./configure $config_args --enable-silent-rules
  199. do_and_check_silent_build
  200. # Cleaning and then rebuilding with the same V flag (and without
  201. # removing the generated sources in between) shouldn't trigger a
  202. # different set of rules.
  203. $MAKE clean
  204. do_and_check_silent_build --rebuild
  205. # Ensure a clean rebuild.
  206. $MAKE clean
  207. # This is required, since these files are not removed by 'make clean'
  208. # (as dictated by the GNU Coding Standards).
  209. rm -f *foo5.c *foo6.[ch] sub/*baz5.c sub/*baz6.[ch]
  210. do_and_check_verbose_build
  211. # Cleaning and then rebuilding with the same V flag (and without
  212. # removing the generated sources in between) shouldn't trigger a
  213. # different set of rules.
  214. $MAKE clean
  215. do_and_check_verbose_build --rebuild
  216. # Ensure a clean reconfiguration/rebuild.
  217. $MAKE clean
  218. $MAKE maintainer-clean
  219. done
  220. :