cond35.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #!/bin/sh
  2. # Copyright (C) 2004-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 rules output for parser defined conditionally.
  17. # Report from Roman Fietze.
  18. required='cc lex yacc'
  19. . test-init.sh
  20. cat >>configure.ac <<'EOF'
  21. AM_CONDITIONAL([CASE_A], [test -z "$case_B"])
  22. AC_PROG_CC
  23. AM_PROG_LEX
  24. AC_PROG_YACC
  25. AC_OUTPUT
  26. EOF
  27. cat > Makefile.am <<'EOF'
  28. AM_YFLAGS = -d
  29. BUILT_SOURCES = tparse.h
  30. if CASE_A
  31. bin_PROGRAMS = ta
  32. ta_SOURCES = ta.c tparse.h tscan.l tparse.y
  33. ta_LDADD = $(LEXLIB)
  34. else
  35. bin_PROGRAMS = tb
  36. tb_SOURCES = tb.c tparse.h tscan.l tparse.y
  37. tb_LDADD = $(LEXLIB)
  38. endif
  39. test-ta:
  40. test -f ta$(EXEEXT)
  41. test-tb:
  42. test -f tb$(EXEEXT)
  43. EOF
  44. $ACLOCAL
  45. $AUTOCONF
  46. $AUTOMAKE --add-missing
  47. $FGREP 'tparse.h' Makefile.in # For debugging.
  48. test $($FGREP -c 'tparse.h:' Makefile.in) -eq 1
  49. cat > tscan.l << 'END'
  50. %{
  51. #define YY_NO_UNISTD_H 1
  52. %}
  53. %%
  54. "END" return EOF;
  55. %%
  56. /* Avoid possible link errors. */
  57. int yywrap (void)
  58. {
  59. return 1;
  60. }
  61. END
  62. cat > tparse.y << 'END'
  63. %{
  64. void yyerror (char *s) {}
  65. %}
  66. %token EOF
  67. %%
  68. foobar : 'f' 'o' 'o' 'b' 'a' 'r' EOF {};
  69. END
  70. cat > ta.c << 'END'
  71. int main (void)
  72. {
  73. return 0;
  74. }
  75. END
  76. cp ta.c tb.c
  77. ./configure
  78. $MAKE
  79. $MAKE test-ta
  80. ./configure case_B=yes
  81. $MAKE
  82. $MAKE test-tb
  83. :