yacc-depend.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. # Make sure depcomp does not needlessly update headers for yacc rules.
  17. # Report from Paolo Bonzini.
  18. required='cc yacc'
  19. . test-init.sh
  20. cat >> configure.ac << 'END'
  21. AC_PROG_CC
  22. AC_PROG_YACC
  23. AC_OUTPUT
  24. END
  25. cat > Makefile.am << 'END'
  26. bin_PROGRAMS = foo
  27. AM_YFLAGS = -d
  28. foo_SOURCES = foo.y main.c
  29. BUILT_SOURCES = foo.h
  30. END
  31. cat > foo.y << 'END'
  32. %{
  33. int yylex () { return 0; }
  34. void yyerror (char *s) { return; }
  35. %}
  36. %token TOKEN
  37. %%
  38. foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
  39. END
  40. cat > main.c << 'END'
  41. #include "foo.h"
  42. int main(void)
  43. {
  44. return yyparse ();
  45. }
  46. END
  47. $ACLOCAL
  48. $AUTOCONF
  49. $AUTOMAKE -a
  50. # Try to enable dependency tracking if possible, even if that means
  51. # using slow dependency extractors.
  52. ./configure --enable-dependency-tracking
  53. $MAKE
  54. ls -l # For debugging.
  55. # Make sure foo.h is not updated if not really needed.
  56. $sleep
  57. : > my-timestamp
  58. $sleep
  59. touch foo.y
  60. $MAKE
  61. stat my-timestamp foo.* || : # For debugging.
  62. is_newest my-timestamp foo.h
  63. # Make sure foo.h is updated if needed.
  64. $sleep
  65. sed 's/TOKEN/TEKON/g' foo.y > t
  66. mv -f t foo.y
  67. $MAKE
  68. stat my-timestamp foo.* || : # For debugging.
  69. is_newest foo.h my-timestamp
  70. :