2
0

lex3.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #! /bin/sh
  2. # Copyright (C) 1999-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. # Basic semantic checks on Lex support.
  17. # Test associated with PR 19.
  18. # From Matthew D. Langston.
  19. required='cc lex'
  20. . test-init.sh
  21. cat >> configure.ac << 'END'
  22. AC_PROG_CC
  23. AM_PROG_LEX
  24. AC_OUTPUT
  25. END
  26. cat > Makefile.am << 'END'
  27. noinst_PROGRAMS = foo
  28. foo_SOURCES = foo.l
  29. END
  30. cat > foo.l << 'END'
  31. %{
  32. #define YY_NO_UNISTD_H 1
  33. %}
  34. %%
  35. "GOOD" return EOF;
  36. .
  37. %%
  38. int main (void)
  39. {
  40. /* We don't use a 'while' loop here (like a real lexer would do)
  41. to avoid possible hangs. */
  42. if (yylex () == EOF)
  43. return 0;
  44. else
  45. return 1;
  46. }
  47. /* Avoid possible link errors. */
  48. int yywrap (void)
  49. {
  50. return 1;
  51. }
  52. END
  53. $ACLOCAL
  54. $AUTOCONF
  55. $AUTOMAKE -a
  56. ./configure
  57. # Program should build and run.
  58. $MAKE
  59. if ! cross_compiling; then
  60. echo GOOD | ./foo
  61. echo BAD | ./foo && exit 1
  62. : For shells with busted 'set -e'.
  63. fi
  64. # The generated file 'foo.c' must be shipped.
  65. $MAKE distdir
  66. test -f $distdir/foo.c
  67. # Sanity check on distribution.
  68. yl_distcheck
  69. # While we are at it, make sure that foo.c is erased by
  70. # maintainer-clean, and not by distclean.
  71. test -f foo.c
  72. $MAKE distclean
  73. test -f foo.c
  74. ./configure # Re-create 'Makefile'.
  75. $MAKE maintainer-clean
  76. test ! -e foo.c
  77. :