silent-yacc.sh 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #!/bin/sh
  2. # Copyright (C) 2010-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.
  17. required='cc yacc'
  18. . test-init.sh
  19. mkdir sub
  20. cat >>configure.ac <<'EOF'
  21. AC_PROG_CC
  22. AC_PROG_YACC
  23. AC_CONFIG_FILES([sub/Makefile])
  24. AC_OUTPUT
  25. EOF
  26. cat > Makefile.am <<'EOF'
  27. # Need generic and non-generic rules.
  28. bin_PROGRAMS = foo1 foo2
  29. foo1_SOURCES = foo.y
  30. foo2_SOURCES = $(foo1_SOURCES)
  31. foo2_YFLAGS = -v
  32. foo2_CFLAGS = $(AM_CPPFLAGS)
  33. SUBDIRS = sub
  34. EOF
  35. cat > sub/Makefile.am <<'EOF'
  36. AUTOMAKE_OPTIONS = subdir-objects
  37. # Need generic and non-generic rules.
  38. bin_PROGRAMS = bar1 bar2
  39. bar1_SOURCES = bar.y
  40. bar2_SOURCES = $(bar1_SOURCES)
  41. bar2_YFLAGS = -v
  42. bar2_CFLAGS = $(AM_CPPFLAGS)
  43. EOF
  44. cat > foo.y <<'EOF'
  45. %{
  46. void yyerror (char *s) { return; }
  47. int yylex (void) { return 0; }
  48. int main (void) { return 0; }
  49. %}
  50. %token EOF
  51. %%
  52. fubar : 'f' 'o' 'o' 'b' 'a' 'r' EOF {};
  53. EOF
  54. cp foo.y sub/bar.y
  55. $ACLOCAL
  56. $AUTOMAKE --add-missing
  57. $AUTOCONF
  58. # Ensure per-target rules are used, to ensure their coverage below.
  59. $FGREP 'foo2-foo.c' Makefile.in || exit 99
  60. $FGREP 'bar2-bar.c' sub/Makefile.in || exit 99
  61. ./configure --enable-silent-rules
  62. run_make -O
  63. $EGREP ' (-c|-o)' stdout && exit 1
  64. $EGREP '(mv|ylwrap) ' stdout && exit 1
  65. grep 'YACC .*foo\.' stdout
  66. grep 'YACC .*bar\.' stdout
  67. grep ' CC .*foo\.' stdout
  68. grep ' CC .*bar\.' stdout
  69. grep 'CCLD .*foo1' stdout
  70. grep 'CCLD .*bar1' stdout
  71. grep 'CCLD .*foo2' stdout
  72. grep 'CCLD .*bar2' 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|-o)' stdout && exit 1
  79. $EGREP '(mv|ylwrap) ' stdout && exit 1
  80. # Don't look for YACC, as probably yacc hasn't been re-run.
  81. grep ' CC .*foo\.' stdout
  82. grep ' CC .*bar\.' stdout
  83. grep 'CCLD .*foo1' stdout
  84. grep 'CCLD .*bar1' stdout
  85. grep 'CCLD .*foo2' stdout
  86. grep 'CCLD .*bar2' stdout
  87. # Ensure a truly clean rebuild.
  88. $MAKE clean
  89. rm -f *foo.[ch] sub/*bar.[ch]
  90. run_make -O V=1
  91. grep ' -c ' stdout
  92. grep ' -o ' stdout
  93. grep 'ylwrap ' stdout
  94. $EGREP '(YACC|CC|CCLD) ' stdout && exit 1
  95. # Cleaning and then rebuilding with the same V flag (and without
  96. # removing the generated sources in between) shouldn't trigger a
  97. # different set of rules.
  98. $MAKE clean
  99. run_make -O V=1
  100. # Don't look for ylwrap, as probably lex hasn't been re-run.
  101. grep ' -c ' stdout
  102. grep ' -o ' stdout
  103. $EGREP '(YACC|CC|CCLD) ' stdout && exit 1
  104. :