lex-libobj.sh 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 through the
  17. # LIBOBJ machinery.
  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. save_LIBS=$LIBS
  25. LIBS="$LEXLIB $LIBS"
  26. AC_REPLACE_FUNCS([yywrap])
  27. LIBS=$save_LIBS
  28. AC_OUTPUT
  29. END
  30. cat > Makefile.am << 'END'
  31. noinst_PROGRAMS = foo
  32. foo_SOURCES = foo.l
  33. foo_LDADD = $(LEXLIB) $(LIBOBJS)
  34. END
  35. cat > yywrap.c << 'END'
  36. int yywrap (void)
  37. {
  38. return 1;
  39. }
  40. END
  41. cat > foo.l <<'END'
  42. %{
  43. #define YY_NO_UNISTD_H 1
  44. %}
  45. %%
  46. "END" return EOF;
  47. .
  48. %%
  49. int main (void)
  50. {
  51. return 0;
  52. }
  53. END
  54. $ACLOCAL
  55. $AUTOCONF
  56. $AUTOMAKE -a
  57. ./configure
  58. grep LIBOBJS Makefile # For debugging.
  59. $MAKE
  60. $MAKE distclean
  61. # Force "no system lex library". Setting LEXLIB to a non-empty value
  62. # ensures that configure won't search for a "lex library", and simply
  63. # rely on the LEXLIB to provide it, if needed. So, by setting LEXLIB
  64. # to a blank but non-empty value we can fool configure into thinking
  65. # that no system-level library providing a 'yywrap' function is
  66. # available. See also discussion on automake bug#11306.
  67. ./configure LEXLIB=' '
  68. grep LIBOBJS Makefile # For debugging.
  69. grep '^LIBOBJS *=.*yywrap.*\.o' Makefile # Sanity check.
  70. $MAKE
  71. yl_distcheck
  72. :