lexvpath.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #! /bin/sh
  2. # Copyright (C) 2010-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. # This test checks that dependent files are updated before including
  17. # in the distribution. 'lexer.c' depends on 'lexer.l'. The latter is
  18. # updated so that 'lexer.c' should be rebuild. Then we are running
  19. # 'make' and 'make distdir' and check whether the version of 'lexer.c'
  20. # to be distributed is up to date.
  21. # Please keep this in sync with sister test 'yaccvapth.sh'.
  22. required='cc lex'
  23. . test-init.sh
  24. cat > lexoutroot.in << 'END'
  25. LEX_OUTPUT_ROOT='@LEX_OUTPUT_ROOT@'
  26. END
  27. cat >> configure.ac << 'END'
  28. AC_CONFIG_FILES([lexoutroot])
  29. AC_PROG_CC
  30. AC_PROG_LEX
  31. AC_OUTPUT
  32. END
  33. cat > Makefile.am << 'END'
  34. bin_PROGRAMS = foo
  35. foo_SOURCES = lexer.l foo.c
  36. LDADD = $(LEXLIB)
  37. END
  38. # Original lexer, with a "foobar" comment
  39. cat > lexer.l << 'END'
  40. %{
  41. #define YY_NO_UNISTD_H 1
  42. %}
  43. %%
  44. "END" return EOF;
  45. .
  46. %%
  47. /*foobar*/
  48. END
  49. cat > foo.c << 'END'
  50. int main (void)
  51. {
  52. return 0;
  53. }
  54. /* Avoid possible link errors. */
  55. int yywrap (void)
  56. {
  57. return 1;
  58. }
  59. END
  60. $ACLOCAL
  61. $AUTOCONF
  62. $AUTOMAKE -a
  63. mkdir sub
  64. # We must run configure early, to find out why $LEX_OUTPUT_ROOT is.
  65. cd sub
  66. ../configure
  67. . ./lexoutroot
  68. test -n "$LEX_OUTPUT_ROOT" # Sanity check.
  69. cd ..
  70. $LEX lexer.l
  71. mv "$LEX_OUTPUT_ROOT".c lexer.c
  72. cd sub
  73. # Ensure that lexer.l will be newer than lexer.c.
  74. $sleep
  75. # New lexer, with 'fubar' comment.
  76. cat > ../lexer.l << 'END'
  77. %{
  78. #define YY_NO_UNISTD_H 1
  79. %}
  80. %%
  81. "END" return EOF;
  82. .
  83. %%
  84. /*fubar*/
  85. END
  86. $MAKE
  87. $MAKE distdir
  88. $FGREP '/*fubar*/' $distdir/lexer.c
  89. #
  90. # Now check to make sure that 'make dist' will rebuilt the parser.
  91. #
  92. # Ensure that lexer.l will be newer than lexer.c.
  93. $sleep
  94. # New lexer, with 'maude' comment.
  95. cat > ../lexer.l << 'END'
  96. %{
  97. #define YY_NO_UNISTD_H 1
  98. %}
  99. %%
  100. "END" return EOF;
  101. .
  102. %%
  103. /*maude*/
  104. END
  105. $MAKE distdir
  106. $FGREP '/*maude*/' $distdir/lexer.c
  107. :