yacc-subdir.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #! /bin/sh
  2. # Copyright (C) 2002-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. # Test for subdir parsers.
  17. required='cc yacc'
  18. . test-init.sh
  19. cat >> configure.ac << 'END'
  20. AC_PROG_CC
  21. AC_PROG_YACC
  22. AC_OUTPUT
  23. END
  24. cat > Makefile.am << 'END'
  25. AUTOMAKE_OPTIONS = subdir-objects
  26. bin_PROGRAMS = foo/foo
  27. foo_foo_SOURCES = foo/parse.y
  28. AM_YFLAGS = -d
  29. .PHONY: obj
  30. obj: foo/parse.$(OBJEXT)
  31. .PHONY: test1 test2
  32. test1: foo/parse.$(OBJEXT)
  33. test -f foo/parse.c
  34. test -f foo/parse.$(OBJEXT)
  35. test2: foo/parse2.$(OBJEXT)
  36. test -f foo/parse2.c
  37. test -f foo/parse2.$(OBJEXT)
  38. END
  39. mkdir foo
  40. cat > foo/parse.y << 'END'
  41. %{
  42. int yylex () { return 0; }
  43. void yyerror (char *s) {}
  44. %}
  45. %%
  46. foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
  47. END
  48. $ACLOCAL
  49. $AUTOCONF
  50. $AUTOMAKE -a
  51. mkdir sub
  52. cd sub
  53. ../configure
  54. $MAKE test1
  55. # Aside of the rest of this test, let's see if we can recover from
  56. # parse.h removal.
  57. test -f foo/parse.h
  58. rm -f foo/parse.h
  59. $MAKE foo/parse.h
  60. test -f foo/parse.h
  61. # Make sure foo/parse.h is not updated, unless when needed.
  62. $sleep
  63. touch ../foo/parse.y
  64. $MAKE obj
  65. is_newest ../foo/parse.y foo/parse.h
  66. $sleep
  67. sed 's/%%/%token TOKEN\n%%/g' ../foo/parse.y >../foo/parse.yt
  68. mv -f ../foo/parse.yt ../foo/parse.y
  69. $MAKE obj
  70. is_newest foo/parse.h ../foo/parse.y
  71. # Now, adds another parser to test ylwrap.
  72. cd ..
  73. # Sleep some to make sure timestamp of Makefile.am will change.
  74. $sleep
  75. cp foo/parse.y foo/parse2.y
  76. cat >> Makefile.am << 'END'
  77. EXTRA_foo_foo_SOURCES = foo/parse2.y
  78. END
  79. $AUTOMAKE -a
  80. test -f ./ylwrap
  81. cd sub
  82. # Regenerate Makefile (automatic in GNU Make, but not in other Makes).
  83. ./config.status
  84. $MAKE test2
  85. :