lex-lib.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 that we can provide a personal 'yywrap' function in a custom
  17. # library.
  18. # See also test 'lex-lib-external.sh'.
  19. required='cc lex'
  20. . test-init.sh
  21. cat >> configure.ac << 'END'
  22. AC_PROG_CC
  23. AM_PROG_AR
  24. AC_PROG_RANLIB
  25. LEXLIB=libmylex.a
  26. AC_PROG_LEX
  27. AC_OUTPUT
  28. END
  29. cat > Makefile.am << 'END'
  30. bin_PROGRAMS = lexer
  31. lexer_SOURCES = foo.l
  32. lexer_LDADD = $(LEXLIB)
  33. EXTRA_lexer_DEPENDENCIES = $(LEXLIB)
  34. noinst_LIBRARIES = libmylex.a
  35. libmylex_a_SOURCES = mu.c
  36. END
  37. cat > mu.c << 'END'
  38. int yywrap (void)
  39. {
  40. return 1;
  41. }
  42. END
  43. cat > foo.l <<'END'
  44. %{
  45. #define YY_NO_UNISTD_H 1
  46. %}
  47. %%
  48. "END" return EOF;
  49. .
  50. %%
  51. int main (void)
  52. {
  53. return 0;
  54. }
  55. END
  56. $ACLOCAL
  57. $AUTOCONF
  58. $AUTOMAKE -a
  59. ./configure
  60. $MAKE
  61. test -f foo.c
  62. test -f libmylex.a
  63. :