2
0

lex-lib-external.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #! /bin/sh
  2. # Copyright (C) 2011-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 that we can get use the 'yywrap' function from a system-wide
  17. # library, if that's available.
  18. required='cc lex'
  19. . test-init.sh
  20. cat >> configure.ac << 'END'
  21. AC_PROG_CC
  22. AC_PROG_RANLIB
  23. AC_PROG_LEX
  24. AC_OUTPUT
  25. END
  26. cat > Makefile.am << 'END'
  27. bin_PROGRAMS = lexer
  28. lexer_SOURCES = foo.l
  29. lexer_LDADD = $(LEXLIB)
  30. .PHONY: have-lexlib
  31. have-lexlib:
  32. test x'$(LEXLIB)' != x
  33. echo 'int main (void) { return yywrap (); }' > x.c
  34. $(CC) -c x.c
  35. $(CC) x.$(OBJEXT) $(LEXLIB)
  36. rm -f x.c *.$(OBJEXT) *.o *.out *.exe
  37. END
  38. cat > foo.l <<'END'
  39. %{
  40. #define YY_NO_UNISTD_H 1
  41. %}
  42. %%
  43. "GOOD" return EOF;
  44. .
  45. %%
  46. int main (void)
  47. {
  48. /* We don't use a 'while' loop here (like a real lexer would do)
  49. to avoid possible hangs. */
  50. if (yylex () == EOF)
  51. return 0;
  52. else
  53. return 1;
  54. }
  55. END
  56. $ACLOCAL
  57. $AUTOCONF
  58. $AUTOMAKE -a
  59. ./configure
  60. $MAKE have-lexlib || skip_ "no system-wide lex library found"
  61. # Program should build and run and distribute.
  62. $MAKE all
  63. if ! cross_compiling; then
  64. echo GOOD | ./lexer
  65. echo BAD | ./lexer && exit 1
  66. : For shells with busted 'set -e'.
  67. fi
  68. yl_distcheck
  69. :