silent-lex.sh 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. # Check silent-rules mode for Lex.
  17. required='cc lex'
  18. . test-init.sh
  19. mkdir sub
  20. cat >>configure.ac <<'EOF'
  21. AC_PROG_LEX
  22. AC_CONFIG_FILES([sub/Makefile])
  23. AC_OUTPUT
  24. EOF
  25. cat > Makefile.am <<'EOF'
  26. # Need generic and non-generic rules.
  27. bin_PROGRAMS = foo1 foo2
  28. foo1_SOURCES = foo.l
  29. foo2_SOURCES = $(foo1_SOURCES)
  30. foo2_LFLAGS = -n
  31. foo2_CFLAGS = $(AM_CFLAGS)
  32. SUBDIRS = sub
  33. LDADD = $(LEXLIB)
  34. EOF
  35. cat > sub/Makefile.am <<'EOF'
  36. AUTOMAKE_OPTIONS = subdir-objects
  37. # Need generic and non-generic rules.
  38. bin_PROGRAMS = bar1 bar2
  39. bar1_SOURCES = bar.l
  40. bar2_SOURCES = $(bar1_SOURCES)
  41. bar2_LFLAGS = -n
  42. bar2_CFLAGS = $(AM_CFLAGS)
  43. LDADD = $(LEXLIB)
  44. EOF
  45. cat > foo.l <<'EOF'
  46. %{
  47. #define YY_NO_UNISTD_H 1
  48. %}
  49. %%
  50. "END" return EOF;
  51. .
  52. %%
  53. /* Avoid possible link errors. */
  54. int yywrap (void) { return 1; }
  55. int main (void) { return 0; }
  56. EOF
  57. cp foo.l sub/bar.l
  58. $ACLOCAL
  59. $AUTOMAKE --add-missing
  60. $AUTOCONF
  61. # Ensure per-target rules are used, to ensure their coverage below.
  62. $FGREP 'foo2-foo.c' Makefile.in || exit 99
  63. $FGREP 'bar2-bar.c' sub/Makefile.in || exit 99
  64. ./configure --enable-silent-rules
  65. run_make -O
  66. $EGREP ' (-c|-o)' stdout && exit 1
  67. $EGREP '(mv|ylwrap) ' stdout && exit 1
  68. grep 'LEX .*foo\.' stdout
  69. grep 'LEX .*bar\.' stdout
  70. grep ' CC .*foo\.' stdout
  71. grep ' CC .*bar\.' stdout
  72. grep 'CCLD .*foo1' stdout
  73. grep 'CCLD .*bar1' stdout
  74. grep 'CCLD .*foo2' stdout
  75. grep 'CCLD .*bar2' stdout
  76. # Cleaning and then rebuilding with the same V flag (and without
  77. # removing the generated sources in between) shouldn't trigger a
  78. # different set of rules.
  79. $MAKE clean
  80. run_make -O
  81. $EGREP ' (-c|-o)' stdout && exit 1
  82. $EGREP '(mv|ylwrap) ' stdout && exit 1
  83. # Don't look for LEX, as probably lex hasn't been re-run.
  84. grep ' CC .*foo\.' stdout
  85. grep ' CC .*bar\.' stdout
  86. grep 'CCLD .*foo1' stdout
  87. grep 'CCLD .*bar1' stdout
  88. grep 'CCLD .*foo2' stdout
  89. grep 'CCLD .*bar2' stdout
  90. # Ensure a truly clean rebuild.
  91. $MAKE clean
  92. rm -f *foo.c sub/*bar.c
  93. run_make -O V=1
  94. grep ' -c ' stdout
  95. grep ' -o ' stdout
  96. grep 'ylwrap ' stdout
  97. $EGREP '(LEX|CC|CCLD) ' stdout && exit 1
  98. # Cleaning and then rebuilding with the same V flag (and without
  99. # removing the generated sources in between) shouldn't trigger a
  100. # different set of rules.
  101. $MAKE clean
  102. run_make -O V=1
  103. # Don't look for ylwrap, as probably lex hasn't been re-run.
  104. grep ' -c ' stdout
  105. grep ' -o ' stdout
  106. $EGREP '(LEX|CC|CCLD) ' stdout && exit 1
  107. :