lex-depend.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. # Test to make sure automatic dependency tracking work with Lex/C.
  17. # Test suggested by PR automake/6.
  18. required='cc lex'
  19. . test-init.sh
  20. cat >> configure.ac << 'END'
  21. AC_PROG_CC
  22. AM_PROG_LEX
  23. AC_OUTPUT
  24. END
  25. cat > Makefile.am << 'END'
  26. bin_PROGRAMS = zoo
  27. zoo_SOURCES = joe.l
  28. LDADD = $(LEXLIB)
  29. .PHONY: test-deps-exist
  30. test-deps-exist:
  31. ls -l $(DEPDIR) ;: For debugging.
  32. test -f $(DEPDIR)/joe.Po
  33. .PHONY: test-obj-updated
  34. test-obj-updated: joe.$(OBJEXT)
  35. is_newest joe.$(OBJEXT) my-hdr.h
  36. END
  37. cat > joe.l << 'END'
  38. %{
  39. #define YY_NO_UNISTD_H 1
  40. %}
  41. %%
  42. "foo" return EOF;
  43. .
  44. %%
  45. #include "my-hdr.h"
  46. int main (void)
  47. {
  48. printf("%s\n", MESSAGE);
  49. return 0;
  50. }
  51. /* Avoid possible link errors. */
  52. int yywrap (void)
  53. {
  54. return 1;
  55. }
  56. END
  57. cat > my-hdr.h <<'END'
  58. #include <stdio.h>
  59. #define MESSAGE "Hello, World!"
  60. END
  61. $ACLOCAL
  62. $AUTOMAKE -a
  63. $FGREP joe.Po Makefile.in
  64. $AUTOCONF
  65. # Try to enable dependency tracking if possible, even if that means
  66. # using slow dependency extractors.
  67. ./configure --enable-dependency-tracking
  68. $MAKE test-deps-exist
  69. $MAKE
  70. cross_compiling || test "$(./zoo)" = 'Hello, World!' || exit 1
  71. $sleep
  72. cat >> my-hdr.h << 'END'
  73. #undef MESSAGE
  74. #define MESSAGE "Howdy, Earth!"
  75. END
  76. $MAKE test-obj-updated
  77. $MAKE
  78. cross_compiling || test "$(./zoo)" = 'Howdy, Earth!' || exit 1
  79. :