silent-yacc-headers.sh 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. # Check silent-rules mode for Yacc, when yacc-generated headers are
  17. # involved (i.e., the '-d' option is in *YFLAGS).
  18. required='cc yacc'
  19. . test-init.sh
  20. mkdir sub
  21. cat >>configure.ac <<'EOF'
  22. AC_PROG_YACC
  23. AC_PROG_CC
  24. AC_OUTPUT
  25. EOF
  26. cat > Makefile.am <<'EOF'
  27. # Need generic and non-generic rules.
  28. AM_YFLAGS = -d
  29. bin_PROGRAMS = foo bar
  30. foo_SOURCES = parse.y
  31. bar_SOURCES = $(foo_SOURCES)
  32. bar_YFLAGS = $(AM_YFLAGS)
  33. EOF
  34. cat > parse.y <<'EOF'
  35. %{
  36. void yyerror (char *s) { return; }
  37. int yylex (void) { return 0; }
  38. int main (void) { return 0; }
  39. %}
  40. %token EOF
  41. %%
  42. fubar : 'f' 'o' 'o' 'b' 'a' 'r' EOF {};
  43. EOF
  44. $ACLOCAL
  45. $AUTOMAKE --add-missing
  46. $AUTOCONF
  47. # Check that the expected non-generic rules has been truly generated.
  48. # Otherwise, the coverage offered by this test will be weaker then
  49. # expected and planned.
  50. $FGREP 'bar-parse.c' Makefile.in
  51. $FGREP '$(bar_YFLAGS)' Makefile.in
  52. ./configure --enable-silent-rules
  53. run_make -O
  54. $EGREP ' (-c|-d|-o)' stdout && exit 1
  55. $EGREP '(mv|ylwrap) ' stdout && exit 1
  56. grep 'YACC *parse\.c' stdout
  57. grep 'updating *parse\.h' stdout
  58. grep 'YACC *bar-parse\.c' stdout
  59. grep 'updating *bar-parse\.h' stdout
  60. grep ' CC *parse\.' stdout
  61. grep ' CC *bar-parse\.' stdout
  62. grep 'CCLD *foo' stdout
  63. grep 'CCLD *bar' stdout
  64. # Check recovering from header removal.
  65. rm -f parse.h bar-parse.h
  66. run_make -O parse.h bar-parse.h
  67. $EGREP ' (-c|-d|-o)' stdout && exit 1
  68. $EGREP '(mv|ylwrap) ' stdout && exit 1
  69. grep 'YACC *parse\.c' stdout
  70. grep 'updating *parse\.h' stdout
  71. grep 'YACC *bar-parse\.c' stdout
  72. grep 'updating *bar-parse\.h' stdout
  73. # Cleaning and then rebuilding with the same V flag (and without
  74. # removing the generated sources in between) shouldn't trigger a
  75. # different set of rules.
  76. $MAKE clean
  77. run_make -O
  78. $EGREP ' (-c|-d|-o)' stdout && exit 1
  79. $EGREP '(mv|ylwrap) ' stdout && exit 1
  80. # Don't look for "YACC *.c" and "updating *.h", as yacc shouldn't
  81. # have been re-run.
  82. grep ' CC *parse\.' stdout
  83. grep ' CC *bar-parse\.' stdout
  84. grep 'CCLD *foo' stdout
  85. grep 'CCLD *bar' stdout
  86. # Check recovering from header removal.
  87. rm -f parse.h bar-parse.h
  88. run_make -O parse.h bar-parse.h
  89. $EGREP ' (-c|-d|-o)' stdout && exit 1
  90. $EGREP '(mv|ylwrap) ' stdout && exit 1
  91. grep 'YACC *parse\.c' stdout
  92. grep 'updating *parse\.h' stdout
  93. grep 'YACC *bar-parse\.c' stdout
  94. grep 'updating *bar-parse\.h' stdout
  95. # Ensure a truly clean rebuild.
  96. $MAKE maintainer-clean
  97. ./configure --enable-silent-rules
  98. run_make -O V=1
  99. grep ' -c ' stdout
  100. grep ' -o ' stdout
  101. grep ' -d ' stdout
  102. grep 'ylwrap ' stdout
  103. $EGREP '(YACC|CC|CCLD) ' stdout && exit 1
  104. # Check recovering from header removal.
  105. rm -f parse.h bar-parse.h
  106. run_make -O V=1 parse.h bar-parse.h
  107. grep ' -d ' stdout
  108. grep 'ylwrap ' stdout
  109. grep 'YACC' stdout && exit 1
  110. # Cleaning and then rebuilding with the same V flag (and without
  111. # removing the generated sources in between) shouldn't trigger a
  112. # different set of rules.
  113. $MAKE clean
  114. run_make -O V=1
  115. # Don't look for ylwrap, as probably lex hasn't been re-run.
  116. grep ' -c ' stdout
  117. grep ' -o ' stdout
  118. $EGREP '(YACC|CC|CCLD) ' stdout && exit 1
  119. # Check recovering from header removal.
  120. rm -f parse.h bar-parse.h
  121. run_make -O V=1 parse.h bar-parse.h
  122. grep ' -d ' stdout
  123. grep 'ylwrap ' stdout
  124. grep 'YACC' stdout && exit 1
  125. :