2
0

lex-noyywrap.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. # Check Lex support with flex using the '%noyywrap' option.
  17. required='cc flex'
  18. . test-init.sh
  19. cat >> configure.ac << 'END'
  20. AC_PROG_CC
  21. AM_PROG_LEX
  22. AC_OUTPUT
  23. END
  24. cat > Makefile.am << 'END'
  25. bin_PROGRAMS = foo
  26. foo_SOURCES = foo.l
  27. .PHONY: test-no-lexlib
  28. check-local: test-no-lexlib
  29. test-no-lexlib:
  30. test x'$(LEXLIB)' = x'none needed'
  31. END
  32. cat > foo.l << 'END'
  33. %option noyywrap
  34. %{
  35. #define YY_NO_UNISTD_H 1
  36. %}
  37. %%
  38. "GOOD" return EOF;
  39. .
  40. %%
  41. int main (void)
  42. {
  43. /* We don't use a 'while' loop here (like a real lexer would do)
  44. to avoid possible hangs. */
  45. if (yylex () == EOF)
  46. return 0;
  47. else
  48. return 1;
  49. }
  50. END
  51. $ACLOCAL
  52. $AUTOCONF
  53. $AUTOMAKE -a
  54. ./configure LEXLIB="none needed"
  55. # Program should build and run.
  56. $MAKE
  57. if ! cross_compiling; then
  58. echo GOOD | ./foo
  59. echo BAD | ./foo && exit 1
  60. : For shells with busted 'set -e'.
  61. fi
  62. # Sanity check on distribution. Escape in LEXLIB must use backspace,
  63. # not double-quotes, to avoid a spurious failure with AIX make.
  64. yl_distcheck DISTCHECK_CONFIGURE_FLAGS='LEXLIB=none\ needed'
  65. :