lex-clean.sh 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 .c files derived from non-distributed .l sources
  17. # are cleaned by "make clean", while .c files derived from
  18. # distributed .l sources are cleaned by "make maintainer-clean".
  19. # See also sister test 'lex-clean-cxx.sh'.
  20. required='cc lex'
  21. . test-init.sh
  22. cat >> configure.ac << 'END'
  23. AC_PROG_CC
  24. AC_PROG_LEX
  25. AC_OUTPUT
  26. END
  27. cat > Makefile.am << 'END'
  28. bin_PROGRAMS = foo bar baz qux
  29. foo_SOURCES = main.c lexer.l
  30. bar_SOURCES = main.c lexer.l
  31. bar_LFLAGS = $(AM_LFLAGS)
  32. baz_SOURCES = main.c
  33. nodist_baz_SOURCES = baz.l
  34. qux_SOURCES = main.c
  35. nodist_qux_SOURCES = baz.l
  36. qux_LFLAGS = $(AM_LFLAGS)
  37. baz.l:
  38. cp $(srcdir)/lexer.l $@
  39. CLEANFILES = baz.l
  40. LDADD = $(LEXLIB)
  41. END
  42. cat > lexer.l << 'END'
  43. %{
  44. #define YY_NO_UNISTD_H 1
  45. %}
  46. %%
  47. "GOOD" return EOF;
  48. .
  49. END
  50. cat > main.c << 'END'
  51. int main (void)
  52. {
  53. return yylex ();
  54. }
  55. /* Avoid possible link errors. */
  56. int yywrap (void)
  57. {
  58. return 1;
  59. }
  60. END
  61. $ACLOCAL
  62. $AUTOCONF
  63. $AUTOMAKE -a
  64. ./configure
  65. cp config.status config.sav
  66. $MAKE
  67. ls -l
  68. # Sanity checks.
  69. test -f lexer.l
  70. test -f lexer.c
  71. test -f bar-lexer.c
  72. test -f baz.l
  73. test -f baz.c
  74. test -f qux-baz.c
  75. for target in clean distclean; do
  76. $MAKE $target
  77. ls -l
  78. test -f lexer.l
  79. test -f lexer.c
  80. test -f bar-lexer.c
  81. test ! -e baz.l
  82. test ! -e baz.c
  83. test ! -e qux-baz.c
  84. done
  85. cp config.sav config.status
  86. ./config.status # re-create Makefile
  87. $MAKE maintainer-clean
  88. ls -l
  89. test -f lexer.l
  90. test ! -e lexer.c
  91. test ! -e bar-lexer.c
  92. :