yacc-dist-nobuild-subdir.sh 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 VPATH builds and "make distcheck" works with packages
  17. # using yacc and the automake 'subdir-objects' option.
  18. # Exposes automake bug#8485.
  19. required='cc yacc'
  20. . test-init.sh
  21. # This test is bounded to fail for any implementation that
  22. # triggers automake bug#7884.
  23. useless_vpath_rebuild && skip_ "would trip on automake bug#7884"
  24. cat >> configure.ac << 'END'
  25. AC_PROG_CC
  26. AC_PROG_YACC
  27. AC_OUTPUT
  28. END
  29. mkdir sub
  30. cat > sub/parse.y << 'END'
  31. %{
  32. int yylex () { return 0; }
  33. void yyerror (char *s) { return; }
  34. %}
  35. %%
  36. x : 'x' {};
  37. %%
  38. int main (void)
  39. {
  40. return yyparse ();
  41. }
  42. END
  43. cat > Makefile.am <<'END'
  44. AUTOMAKE_OPTIONS = subdir-objects
  45. noinst_PROGRAMS = foo bar
  46. foo_SOURCES = sub/parse.y
  47. bar_SOURCES = $(foo_SOURCES)
  48. AM_YFLAGS = -d
  49. bar_YFLAGS =
  50. END
  51. $ACLOCAL
  52. $AUTOCONF
  53. $AUTOMAKE -a
  54. ./configure
  55. $MAKE distdir
  56. # Yacc-derived C source and header files must be built and distributed.
  57. test -f sub/parse.c
  58. test -f sub/parse.h
  59. test -f sub/bar-parse.c
  60. test ! -e sub/bar-parse.h
  61. test -f $distdir/sub/parse.c
  62. test -f $distdir/sub/parse.h
  63. test -f $distdir/sub/bar-parse.c
  64. test ! -e $distdir/sub/bar-parse.h
  65. # But they shouldn't be rebuilt in VPATH builds.
  66. mkdir $distdir/build
  67. chmod -R a-w $distdir
  68. cd $distdir/build
  69. chmod u+w .
  70. # Try to enable dependency tracking even with slow dependency
  71. # extractors, to improve coverage.
  72. ../configure --enable-dependency-tracking YACC=false
  73. $MAKE
  74. ls -l sub/*.[ch] && exit 1
  75. env DISTCHECK_CONFIGURE_FLAGS='YACC=false' $MAKE distcheck
  76. :