subpkg-yacc.sh 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. #! /bin/sh
  2. # Copyright (C) 2002-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 that ylwrap is installed properly, and $(YLWRAP) us defined
  17. # properly, when a subpackage is involved.
  18. required='cc yacc'
  19. . test-init.sh
  20. cat >>configure.ac <<'END'
  21. AC_PROG_CC
  22. AC_CONFIG_SUBDIRS([lib])
  23. AC_OUTPUT
  24. END
  25. cat >Makefile.am <<'EOF'
  26. SUBDIRS = lib
  27. bin_PROGRAMS = MU
  28. MU_LDADD = lib/liblib.a
  29. # It's ok to override distdir.
  30. distdir = subpack-1
  31. # Remove a file created by rules in subdir lib.
  32. CLEANFILES = lib-dist-hook-has-run
  33. EOF
  34. cat >MU.c <<'EOF'
  35. int lib (void);
  36. int main (void)
  37. {
  38. return lib ();
  39. }
  40. EOF
  41. mkdir lib
  42. mkdir lib/src
  43. cat >lib/configure.ac <<'EOF'
  44. AC_INIT([lib], [2.3])
  45. AM_INIT_AUTOMAKE([subdir-objects])
  46. AC_PROG_RANLIB
  47. AC_PROG_YACC
  48. dnl This comes after YACC and RANLIB checks, deliberately.
  49. AC_PROG_CC
  50. AM_PROG_AR
  51. AC_CONFIG_HEADERS([config.h:config.hin])
  52. AC_CONFIG_FILES([Makefile])
  53. AC_OUTPUT
  54. EOF
  55. cat >lib/Makefile.am <<'EOF'
  56. noinst_LIBRARIES = liblib.a
  57. liblib_a_SOURCES = src/x.c foo.y
  58. EXTRA_liblib_a_SOURCES = bar.y
  59. dist-hook:
  60. test -d $(top_distdir)
  61. test -d $(distdir)
  62. find $(top_distdir) $(distdir) ;: For debugging.
  63. test -f $(top_distdir)/MU.c
  64. test ! -f $(distdir)/MU.c
  65. for suf in y c; do \
  66. for name in foo bar; do \
  67. test -f $(distdir)/$$name.$$suf || exit 1; \
  68. test ! -f $(top_distdir)/$$name.$$suf || exit 1; \
  69. done; \
  70. done
  71. test -f $(distdir)/foo.y
  72. test ! -f $(top_distdir)/foo.y
  73. test -f $(distdir)/src/x.c
  74. test ! -f $(top_distdir)/src/x.c
  75. test -f $(YLWRAP)
  76. : > $(top_builddir)/../lib-dist-hook-has-run
  77. EOF
  78. cat > lib/foo.y << 'END'
  79. %{
  80. int yylex (void) { return 0; }
  81. void yyerror (char *s) {}
  82. %}
  83. %%
  84. foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
  85. END
  86. cp lib/foo.y lib/bar.y
  87. cat >lib/src/x.c <<'EOF'
  88. #include <config.h>
  89. int lib (void)
  90. {
  91. return 0;
  92. }
  93. EOF
  94. $ACLOCAL
  95. $AUTOCONF
  96. $AUTOMAKE -Wno-override
  97. cd lib
  98. $ACLOCAL
  99. $AUTOCONF
  100. $AUTOHEADER
  101. $AUTOMAKE -Wno-override --add-missing
  102. cd ..
  103. ./configure
  104. $MAKE dist
  105. test -f lib-dist-hook-has-run
  106. test -f subpack-1.tar.gz
  107. test ! -e subpack-1 # Make sure "dist" cleans up after itself.
  108. rm -f lib-dist-hook-has-run subpack-1.tar.gz
  109. yl_distcheck
  110. :