2
0

yacc-clean.sh 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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 and .h files derived from non-distributed .y sources
  17. # are cleaned by "make clean", while .c and .h files derived from
  18. # distributed .y sources are cleaned by "make maintainer-clean".
  19. # See also sister test 'yacc-cxx-clean.sh'.
  20. required='cc yacc'
  21. . test-init.sh
  22. cat >> configure.ac << 'END'
  23. AC_PROG_CC
  24. AC_PROG_YACC
  25. AC_CONFIG_FILES([sub1/Makefile sub2/Makefile])
  26. AC_OUTPUT
  27. END
  28. cat > Makefile.am << 'END'
  29. # Use two subdirectories, one to test with '-d' in YFLAGS, the
  30. # other one to test with empty YFLAGS.
  31. SUBDIRS = sub1 sub2
  32. END
  33. mkdir sub1 sub2
  34. cat > sub1/Makefile.am << 'END'
  35. bin_PROGRAMS = foo bar baz qux
  36. foo_SOURCES = main.c parse.y
  37. bar_SOURCES = main.c parse.y
  38. bar_YFLAGS = $(AM_YFLAGS)
  39. baz_SOURCES = main.c
  40. nodist_baz_SOURCES = baz.y
  41. qux_SOURCES = main.c
  42. nodist_qux_SOURCES = baz.y
  43. qux_YFLAGS = $(AM_YFLAGS)
  44. baz.y:
  45. cp $(srcdir)/parse.y $@
  46. CLEANFILES = baz.y
  47. END
  48. cat > sub2/Makefile.am << 'END'
  49. include $(top_srcdir)/sub1/Makefile.am
  50. AM_YFLAGS = -d
  51. END
  52. cat > sub1/parse.y << 'END'
  53. %{
  54. int yylex () { return (getchar ()); }
  55. void yyerror (char *s) {}
  56. %}
  57. %%
  58. x : 'x' { };
  59. END
  60. cp sub1/parse.y sub2/parse.y
  61. cat > sub1/main.c << 'END'
  62. int main ()
  63. {
  64. return yyparse ();
  65. }
  66. END
  67. cp sub1/main.c sub2/main.c
  68. $ACLOCAL
  69. $AUTOCONF
  70. $AUTOMAKE -a
  71. ./configure
  72. cp config.status config.sav
  73. $MAKE
  74. ls -l . sub1 sub2
  75. # Sanity checks.
  76. test -f sub1/parse.y
  77. test -f sub1/parse.c
  78. test -f sub1/bar-parse.c
  79. test -f sub1/baz.y
  80. test -f sub1/baz.c
  81. test -f sub1/qux-baz.c
  82. test -f sub2/parse.y
  83. test -f sub2/parse.c
  84. test -f sub2/parse.h
  85. test -f sub2/bar-parse.c
  86. test -f sub2/bar-parse.h
  87. test -f sub2/baz.y
  88. test -f sub2/baz.c
  89. test -f sub2/baz.h
  90. test -f sub2/qux-baz.c
  91. test -f sub2/qux-baz.h
  92. for target in clean distclean; do
  93. $MAKE $target
  94. ls -l . sub1 sub2
  95. test -f sub1/parse.y
  96. test -f sub1/parse.c
  97. test -f sub1/bar-parse.c
  98. test ! -e sub1/baz.y
  99. test ! -e sub1/baz.c
  100. test ! -e sub1/qux-baz.c
  101. test -f sub2/parse.y
  102. test -f sub2/parse.c
  103. test -f sub2/parse.h
  104. test -f sub2/bar-parse.c
  105. test -f sub2/bar-parse.h
  106. test ! -e sub2/baz.y
  107. test ! -e sub2/baz.c
  108. test ! -e sub2/baz.h
  109. test ! -e sub2/qux-baz.c
  110. test ! -e sub2/qux-baz.h
  111. done
  112. cp config.sav config.status
  113. ./config.status # Re-create 'Makefile'.
  114. $MAKE maintainer-clean
  115. ls -l . sub1 sub2
  116. test -f sub1/parse.y
  117. test ! -e sub1/parse.c
  118. test ! -e sub1/bar-parse.c
  119. test -f sub2/parse.y
  120. test ! -e sub2/parse.c
  121. test ! -e sub2/parse.h
  122. test ! -e sub2/bar-parse.c
  123. test ! -e sub2/bar-parse.h
  124. :