mmodely.sh 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. # Verify that intermediate files are only built from Yacc and Lex
  17. # sources in maintainer mode.
  18. # From Derek R. Price.
  19. required=cc
  20. . test-init.sh
  21. cat >> configure.ac << 'END'
  22. AM_MAINTAINER_MODE
  23. AC_PROG_CC
  24. AM_PROG_LEX
  25. AC_PROG_YACC
  26. AC_OUTPUT
  27. END
  28. cat > Makefile.am <<'END'
  29. YACC = false
  30. LEX = false
  31. bin_PROGRAMS = zardoz
  32. zardoz_SOURCES = zardoz.y joe.l
  33. LDADD = @LEXLIB@
  34. END
  35. # The point of this test is that it is not dependent on a working lex
  36. # or yacc.
  37. cat > joe.c <<EOF
  38. int joe (int arg)
  39. {
  40. return arg * 2;
  41. }
  42. EOF
  43. # On systems which link in libraries non-lazily and whose linkers
  44. # complain about unresolved symbols by default, such as Solaris, an
  45. # yylex function needs to be defined to avoid an error due to an
  46. # unresolved symbol.
  47. cat > zardoz.c <<EOF
  48. int joe (int arg);
  49. int yylex (void)
  50. {
  51. return 0;
  52. }
  53. int main (int argc, char **argv)
  54. {
  55. return joe (argc);
  56. }
  57. EOF
  58. # Ensure a later timestamp for our Lex & Yacc sources.
  59. $sleep
  60. : > joe.l
  61. : > zardoz.y
  62. $ACLOCAL
  63. $AUTOCONF
  64. $AUTOMAKE -a
  65. ./configure
  66. $MAKE
  67. cat >myyacc.sh <<'END'
  68. #! /bin/sh
  69. echo "$@" >y.tab.c
  70. END
  71. cat >mylex.sh <<'END'
  72. echo "$@" >lex.yy.c
  73. END
  74. chmod +x myyacc.sh mylex.sh
  75. PATH=$(pwd)$PATH_SEPARATOR$PATH; export PATH
  76. # "make maintainer-clean; ./configure; make" should always work,
  77. # per GNU Standard.
  78. $MAKE maintainer-clean
  79. ./configure
  80. run_make YACC=myyacc.sh LEX=mylex.sh LEX_OUTPUT_ROOT=lex.yy zardoz.c joe.c
  81. $FGREP zardoz.y zardoz.c
  82. $FGREP joe.l joe.c
  83. :