yacc-d-vpath.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. # This test checks that dependent files are updated before including
  17. # in the distribution. 'parse.c' depends on 'parse.y'. The latter is
  18. # updated so that 'parse.c' should be rebuilt. Then we are running
  19. # 'make' and 'make distdir' and check whether the version of 'parse.c'
  20. # to be distributed is up to date.
  21. # Please keep this in sync with sister test 'yaccvpath.sh'.
  22. required='cc yacc'
  23. . test-init.sh
  24. cat >> configure.ac << 'END'
  25. AC_PROG_CC
  26. AC_PROG_YACC
  27. AC_OUTPUT
  28. END
  29. cat > Makefile.am << 'END'
  30. bin_PROGRAMS = foo
  31. foo_SOURCES = parse.y foo.c
  32. AM_YFLAGS = -d
  33. END
  34. # Original parser, with 'foobar'.
  35. cat > parse.y << 'END'
  36. %{
  37. int yylex () { return 0; }
  38. void yyerror (char *s) {}
  39. %}
  40. %token FOOBAR
  41. %%
  42. foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
  43. END
  44. cat > foo.c << 'END'
  45. #include "parse.h"
  46. int main () { return 0; }
  47. END
  48. $ACLOCAL
  49. $AUTOCONF
  50. $AUTOMAKE -a
  51. $YACC -d parse.y
  52. mv y.tab.c parse.c
  53. mv y.tab.h parse.h
  54. # Sanity checks.
  55. grep foobar parse.c
  56. grep FOOBAR parse.h
  57. mkdir sub
  58. cd sub
  59. ../configure
  60. $sleep
  61. # New parser, with 'fubar'.
  62. cat > ../parse.y << 'END'
  63. %{
  64. int yylex () { return 0; }
  65. void yyerror (char *s) {}
  66. %}
  67. %token FUBAR
  68. %%
  69. fubar : 'f' 'u' 'b' 'a' 'r' {};
  70. END
  71. $MAKE
  72. $MAKE distdir
  73. $FGREP fubar $distdir/parse.c
  74. $FGREP FUBAR $distdir/parse.h
  75. # Now check to make sure that 'make dist' will rebuild the parser.
  76. $sleep
  77. # New parser, with 'maude'.
  78. cat > ../parse.y << 'END'
  79. %{
  80. int yylex () { return 0; }
  81. void yyerror (char *s) {}
  82. %}
  83. %token MAUDE
  84. %%
  85. maude : 'm' 'a' 'u' 'd' 'e' {};
  86. END
  87. $MAKE distdir
  88. $FGREP maude $distdir/parse.c
  89. $FGREP MAUDE $distdir/parse.h
  90. :