yacc-vpath.sh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #! /bin/sh
  2. # Copyright (C) 2001-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 later is
  18. # updated so that 'parse.c' should be rebuild. 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 'yacc-d-vpath.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. END
  33. # Original parser, with 'foobar'.
  34. cat > parse.y << 'END'
  35. %{
  36. int yylex () { return 0; }
  37. void yyerror (char *s) {}
  38. %}
  39. %%
  40. foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
  41. END
  42. cat > foo.c << 'END'
  43. int main () { return 0; }
  44. END
  45. $ACLOCAL
  46. $AUTOCONF
  47. $AUTOMAKE -a
  48. $YACC parse.y
  49. mv y.tab.c parse.c
  50. mkdir sub
  51. cd sub
  52. ../configure
  53. $sleep
  54. # New parser, with 'fubar'.
  55. cat > ../parse.y << 'END'
  56. %{
  57. int yylex () { return 0; }
  58. void yyerror (char *s) {}
  59. %}
  60. %%
  61. fubar : 'f' 'o' 'o' 'b' 'a' 'r' {};
  62. END
  63. $MAKE
  64. $MAKE distdir
  65. $FGREP fubar $distdir/parse.c
  66. # Now check to make sure that 'make dist' will rebuild the parser.
  67. $sleep
  68. # New parser, with 'maude'.
  69. cat > ../parse.y << 'END'
  70. %{
  71. int yylex () { return 0; }
  72. void yyerror (char *s) {}
  73. %}
  74. %%
  75. maude : 'm' 'a' 'u' 'd' 'e' {};
  76. END
  77. $MAKE distdir
  78. $FGREP maude $distdir/parse.c
  79. :