lex-nodist.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. # Checks for .c files derived from non-distributed .l sources.
  17. # The test 'lex-pr204.sh' does similar check with AM_MAINTAINER_MODE
  18. # enabled.
  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 << 'END'
  24. AC_PROG_CC
  25. dnl Sister test 'lex-pr204.sh' should use 'AC_PROG_LEX' instead.
  26. AM_PROG_LEX
  27. AC_OUTPUT
  28. END
  29. cat > Makefile.am << 'END'
  30. .PHONY: test-build test-dist
  31. test-build: all
  32. ls -l
  33. test -f lexer.l
  34. test -f lexer.c
  35. test-dist: distdir
  36. ls -l $(distdir)
  37. test ! -r $(distdir)/lexer.l
  38. test ! -r $(distdir)/lexer.c
  39. check-local: test-build test-dist
  40. lexer.l:
  41. rm -f $@ $@-t
  42. :; { : \
  43. && echo '%{' \
  44. && echo '#define YY_NO_UNISTD_H 1' \
  45. && echo '%}' \
  46. && echo '%%' \
  47. && echo '"GOOD" return EOF;' \
  48. && echo '.'; \
  49. } > $@-t
  50. chmod a-w $@-t && mv -f $@-t $@
  51. bin_PROGRAMS = prog
  52. prog_SOURCES = main.c
  53. nodist_prog_SOURCES = lexer.l
  54. prog_LDADD = $(LEXLIB)
  55. CLEANFILES = $(nodist_prog_SOURCES)
  56. END
  57. cat > main.c << 'END'
  58. int main ()
  59. {
  60. return yylex ();
  61. }
  62. /* Avoid possible link errors. */
  63. int yywrap (void)
  64. {
  65. return 1;
  66. }
  67. END
  68. $ACLOCAL
  69. $AUTOCONF
  70. $AUTOMAKE -a
  71. ./configure
  72. $MAKE
  73. $MAKE test-build
  74. $MAKE test-dist
  75. # But the distribution must work correctly, assuming the user has
  76. # the proper tools to process yacc files.
  77. $MAKE distcheck
  78. :