yacc-headers-and-dist-pr47.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #! /bin/sh
  2. # Copyright (C) 2001-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. # Test to make sure dependencies are generated correctly for .h files.
  17. # Report from Richard Boulton.
  18. #
  19. # Also check that the sources of the generated parser are distributed.
  20. # PR/47.
  21. required='cc yacc'
  22. . test-init.sh
  23. cat >> configure.ac << 'END'
  24. AC_PROG_CC
  25. AC_PROG_YACC
  26. AC_OUTPUT
  27. END
  28. cat > Makefile.am << 'END'
  29. bin_PROGRAMS = foo
  30. foo_SOURCES = foo.y
  31. AM_YFLAGS = -d
  32. check-dist: distdir
  33. test -f $(distdir)/foo.y
  34. test -f $(distdir)/foo.c
  35. test -f $(distdir)/foo.h
  36. END
  37. # The %union will cause Bison to output '#line's in y.tab.h too.
  38. cat > foo.y << 'END'
  39. %union
  40. {
  41. int i;
  42. char c;
  43. }
  44. %%
  45. WORD: "up";
  46. %%
  47. END
  48. $ACLOCAL
  49. $AUTOMAKE -a
  50. $AUTOCONF
  51. ./configure
  52. $MAKE foo.h
  53. test -f foo.h
  54. rm -f foo.h foo.c
  55. $MAKE check-dist
  56. # We should be able to recover if foo.h is deleted.
  57. rm -f foo.h
  58. $MAKE foo.h
  59. test -f foo.h
  60. # Make sure '#line ... y.tab.h' gets replaced.
  61. $FGREP 'y.tab.h' foo.h && exit 1
  62. # Make distclean must not erase foo.c nor foo.h (by GNU standards) ...
  63. $MAKE foo.c
  64. test -f foo.h
  65. test -f foo.c
  66. $MAKE distclean
  67. test -f foo.h
  68. test -f foo.c
  69. # ... but maintainer-clean should.
  70. ./configure # Re-create 'Makefile'.
  71. $MAKE maintainer-clean
  72. test ! -e foo.h
  73. test ! -e foo.c
  74. :