yacc-nodist.sh 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 and .h files derived from non-distributed yacc sources.
  17. # The test 'yacc-pr204.sh' does similar check with AM_MAINTAINER_MODE
  18. # enabled.
  19. # The tests 'lex-nodist.sh' and 'lex-pr204.sh' does similar checks
  20. # for lex-generated .c files.
  21. required='cc yacc'
  22. . test-init.sh
  23. cat >> configure.ac << 'END'
  24. AC_PROG_CC
  25. AC_PROG_YACC
  26. AC_CONFIG_FILES([sub1/Makefile sub2/Makefile])
  27. AC_OUTPUT
  28. END
  29. cat > Makefile.am << 'END'
  30. SUBDIRS = sub1 sub2
  31. .PHONY: test-build test-dist
  32. test-build: all
  33. ls -l . sub1 sub2
  34. test -f sub1/parse.y
  35. test -f sub1/parse.c
  36. test -f sub2/parse.y
  37. test -f sub2/parse.c
  38. test -f sub2/parse.h
  39. test-dist: distdir
  40. ls -l $(distdir) $(distdir)/sub1 $(distdir)/sub2
  41. test ! -r $(distdir)/sub1/parse.y
  42. test ! -r $(distdir)/sub1/parse.c
  43. test ! -r $(distdir)/sub1/parse.h
  44. test ! -r $(distdir)/sub2/parse.y
  45. test ! -r $(distdir)/sub2/parse.c
  46. test ! -r $(distdir)/sub2/parse.h
  47. check-local: test-build test-dist
  48. END
  49. mkdir sub1 sub2
  50. cat > sub1/Makefile.am << 'END'
  51. parse.y:
  52. rm -f $@ $@-t
  53. :; { : \
  54. && echo "%{" \
  55. && echo "int yylex () { return 0; }" \
  56. && echo "void yyerror (char *s) {}" \
  57. && echo "%}" \
  58. && echo "%%" \
  59. && echo "maude : 'm' 'a' 'u' 'd' 'e' {}"; \
  60. } > $@-t
  61. chmod a-w $@-t && mv -f $@-t $@
  62. bin_PROGRAMS = prog
  63. prog_SOURCES = main.c
  64. nodist_prog_SOURCES = parse.y
  65. CLEANFILES = $(nodist_prog_SOURCES)
  66. END
  67. cat sub1/Makefile.am - > sub2/Makefile.am << 'END'
  68. AM_YFLAGS = -d
  69. BUILT_SOURCES = parse.h
  70. END
  71. cat > sub1/main.c << 'END'
  72. int main ()
  73. {
  74. return yyparse ();
  75. }
  76. END
  77. cat - sub1/main.c > sub2/main.c << 'END'
  78. #include "parse.h"
  79. END
  80. $ACLOCAL
  81. $AUTOCONF
  82. $AUTOMAKE -a
  83. ./configure
  84. $MAKE
  85. $MAKE test-build
  86. $MAKE test-dist
  87. yl_distcheck
  88. :