lex-clean-cxx.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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++ source files derived from non-distributed Lex sources
  17. # are cleaned by "make clean", while C++ source files derived from
  18. # distributed Lex sources are cleaned by "make maintainer-clean".
  19. # See also sister test 'lex-clean.sh'.
  20. required='c++ lex'
  21. . test-init.sh
  22. cat >> configure.ac << 'END'
  23. AC_PROG_CXX
  24. AC_PROG_LEX
  25. AC_OUTPUT
  26. END
  27. cat > Makefile.am << 'END'
  28. bin_PROGRAMS = foo bar baz qux
  29. foo_SOURCES = mainfoo.cc parsefoo.lxx
  30. bar_SOURCES = mainbar.cpp parsebar.ll
  31. bar_LFLAGS = $(AM_LFLAGS)
  32. baz_SOURCES = mainbaz.c++
  33. nodist_baz_SOURCES = parsebaz.l++
  34. qux_SOURCES = mainqux.cxx
  35. nodist_qux_SOURCES = parsequx.lpp
  36. qux_LFLAGS = $(AM_LFLAGS)
  37. parsebaz.l++ parsequx.lpp:
  38. cp $(srcdir)/parsefoo.lxx $@
  39. CLEANFILES = parsebaz.l++ parsequx.lpp
  40. LDADD = $(LEXLIB)
  41. END
  42. cat > parsefoo.lxx << 'END'
  43. %{
  44. #define YY_NO_UNISTD_H 1
  45. int isatty (int fd) { return 0; }
  46. %}
  47. %%
  48. "GOOD" return EOF;
  49. .
  50. %%
  51. int yywrap (void)
  52. {
  53. return 1;
  54. }
  55. END
  56. cp parsefoo.lxx parsebar.ll
  57. cat > mainfoo.cc << 'END'
  58. // This file should contain valid C++ but invalid C.
  59. using namespace std;
  60. int main (int argc, char **argv)
  61. {
  62. extern int yylex (void);
  63. return yylex ();
  64. }
  65. END
  66. cp mainfoo.cc mainbar.cpp
  67. cp mainfoo.cc mainbaz.c++
  68. cp mainfoo.cc mainqux.cxx
  69. $ACLOCAL
  70. $AUTOCONF
  71. $AUTOMAKE -a
  72. ./configure
  73. cp config.status config.sav
  74. $MAKE
  75. ls -l
  76. # Sanity checks.
  77. test -f parsefoo.cxx
  78. test -f bar-parsebar.cc
  79. test -f parsebaz.l++
  80. test -f parsebaz.c++
  81. test -f parsequx.lpp
  82. test -f qux-parsequx.cpp
  83. for target in clean distclean; do
  84. $MAKE $target
  85. ls -l
  86. test -f parsefoo.cxx
  87. test -f bar-parsebar.cc
  88. test ! -e parsebaz.l++
  89. test ! -e parsebaz.c++
  90. test ! -e parsequx.lpp
  91. test ! -e qux-parsequx.cpp
  92. done
  93. cp config.sav config.status
  94. ./config.status # re-create Makefile
  95. $MAKE maintainer-clean
  96. ls -l
  97. test -f parsefoo.lxx
  98. test -f parsebar.ll
  99. test ! -e parsefoo.cxx
  100. test ! -e bar-parsebar.cc
  101. test -f parsefoo.lxx
  102. test -f parsebar.ll
  103. test ! -e parsefoo.cxx
  104. test ! -e bar-parsebar.cc
  105. :