yacc-cxx-grepping.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #! /bin/sh
  2. # Copyright (C) 1997-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 to make sure Yacc + C++ is not obviously broken.
  17. # See also related tests 'yacc-cxx.sh' and 'yacc-d-cxx.sh',
  18. # which does much more in-depth checks (but requires an actual
  19. # Yacc program and a working C++ compiler).
  20. . test-init.sh
  21. cat >> configure.ac << 'END'
  22. AC_PROG_CXX
  23. AC_PROG_YACC
  24. END
  25. cat > Makefile.am << 'END'
  26. bin_PROGRAMS = foo bar baz qux
  27. foo_SOURCES = foo.y++
  28. bar_SOURCES = bar.ypp
  29. baz_SOURCES = baz.yy
  30. qux_SOURCES = qux.yxx
  31. END
  32. $ACLOCAL
  33. $AUTOMAKE -a
  34. $EGREP '(\.[ch]|foo|bar|baz|qux)' Makefile.in # For debugging.
  35. $EGREP '(foo|bar|baz|qux)\.h' Makefile.in && exit 1
  36. sed -e 's/^/ /' -e 's/$/ /' Makefile.in >mk
  37. $FGREP ' foo.c++ ' mk
  38. $FGREP ' bar.cpp ' mk
  39. $FGREP ' baz.cc ' mk
  40. $FGREP ' qux.cxx ' mk
  41. cat >> Makefile.am <<END
  42. AM_YFLAGS = -d
  43. qux_YFLAGS = foo
  44. END
  45. $AUTOMAKE
  46. $EGREP '(\.[ch]|foo|bar|baz|qux)' Makefile.in # For debugging.
  47. sed -e 's/^/ /' -e 's/$/ /' Makefile.in >mk
  48. $FGREP ' foo.c++ ' mk
  49. $FGREP ' foo.h++ ' mk
  50. $FGREP ' bar.cpp ' mk
  51. $FGREP ' bar.hpp ' mk
  52. $FGREP ' baz.cc ' mk
  53. $FGREP ' baz.hh ' mk
  54. $EGREP '(^| )foo\.h\+\+(:| .*:)' Makefile.in
  55. $EGREP '(^| )bar\.hpp(:| .*:)' Makefile.in
  56. $EGREP '(^| )baz\.hh(:| .*:)' Makefile.in
  57. grep ' foo\.h[ :]' mk && exit 1
  58. grep ' bar\.h[ :]' mk && exit 1
  59. grep ' baz\.h[ :]' mk && exit 1
  60. $FGREP ' qux-qux.cxx ' mk
  61. $EGREP '(^| )qux-qux\.cxx(:| .*:)' Makefile.in
  62. grep 'qux\.h.*:' Makefile.in && exit 1
  63. :