lex-pr204.sh 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. # Related to PR 204.
  17. # C sources derived from nodist_ lex sources should not be distributed.
  18. # See also related test 'lex-nodist.sh'.
  19. # The tests 'yacc-nodist.sh' and 'yacc-pr204.sh' does similar checks
  20. # for yacc-generated .c and .h files.
  21. required='cc lex'
  22. . test-init.sh
  23. cat >> configure.ac <<'EOF'
  24. AM_MAINTAINER_MODE
  25. AC_PROG_CC
  26. dnl We use AC_PROG_LEX deliberately.
  27. dnl Sister 'lex-nodist.sh' should use 'AM_PROG_LEX' instead.
  28. AC_PROG_LEX
  29. AC_OUTPUT
  30. EOF
  31. # The LEXER2 intermediate variable is there to make sure Automake
  32. # matches 'nodist_' against the right variable name...
  33. cat > Makefile.am << 'EOF'
  34. EXTRA_PROGRAMS = foo
  35. LEXER2 = lexer2.l
  36. nodist_foo_SOURCES = lexer.l $(LEXER2)
  37. distdirtest: distdir
  38. test ! -f $(distdir)/lexer.c
  39. test ! -f $(distdir)/lexer.l
  40. test ! -f $(distdir)/lexer.h
  41. test ! -f $(distdir)/lexer2.c
  42. test ! -f $(distdir)/lexer2.l
  43. test ! -f $(distdir)/lexer2.h
  44. EOF
  45. cat > lexer.l << 'END'
  46. %{
  47. #define YY_NO_UNISTD_H 1
  48. %}
  49. %%
  50. "GOOD" return EOF;
  51. .
  52. %%
  53. int main (void)
  54. {
  55. return yylex ();
  56. }
  57. END
  58. cp lexer.l lexer2.l
  59. $ACLOCAL
  60. $AUTOCONF
  61. $AUTOMAKE -a
  62. ./configure
  63. $MAKE distdirtest
  64. # Make sure lexer.c and lexer2.c are still targets.
  65. $MAKE lexer.c lexer2.c
  66. test -f lexer.c
  67. test -f lexer2.c
  68. # Ensure the rebuild rule works despite AM_MAINTAINER_MODE, because
  69. # it's a nodist_ lexer.
  70. $sleep
  71. touch lexer.l lexer2.l
  72. $sleep
  73. $MAKE lexer.c lexer2.c
  74. is_newest lexer.c lexer.l
  75. is_newest lexer2.c lexer2.l
  76. :