silent-custom.sh 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #!/bin/sh
  2. # Copyright (C) 2009-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 user extensibility of silent-rules mode.
  17. . test-init.sh
  18. cat >>configure.ac <<'EOF'
  19. AC_CONFIG_FILES([sub/Makefile])
  20. AC_OUTPUT
  21. EOF
  22. # We delegate all the work to the subdir makefile. This is done
  23. # to ensure any command-line setting of $(V) gets correctly passed
  24. # down to recursive make invocations.
  25. echo SUBDIRS = sub > Makefile.am
  26. mkdir sub
  27. cat > sub/Makefile.am <<'EOF'
  28. AUTOMAKE_OPTIONS = -Wno-portability-recursive
  29. my_verbose = $(my_verbose_$(V))
  30. my_verbose_ = $(my_verbose_$(AM_DEFAULT_VERBOSITY))
  31. my_verbose_0 = @echo " XGEN $@";
  32. all-local: foo gen-headers
  33. list = 0 1 2
  34. .PHONY: gen-headers
  35. gen-headers:
  36. @headers=`for i in $(list); do echo sub/$$i.h; done`; \
  37. if $(AM_V_P); then set -x; else \
  38. echo " GEN [headers]"; \
  39. fi; \
  40. rm -f $$headers || exit 1; \
  41. ## Only fake header generation.
  42. : generate-header --flags $$headers
  43. foo: foo.in
  44. $(my_verbose)cp $(srcdir)/foo.in $@
  45. EXTRA_DIST = foo.in
  46. CLEANFILES = foo
  47. EOF
  48. : > sub/foo.in
  49. $ACLOCAL
  50. $AUTOMAKE --add-missing
  51. $AUTOCONF
  52. do_check ()
  53. {
  54. case ${1-} in
  55. --silent) silent=:;;
  56. --verbose) silent=false;;
  57. *) fatal_ "do_check(): incorrect usage";;
  58. esac
  59. shift
  60. $MAKE clean
  61. run_make -M -- ${1+"$@"}
  62. if $silent; then
  63. $FGREP 'cp ' output && exit 1
  64. $FGREP 'generate-header' output && exit 1
  65. $FGREP 'rm -f' output && exit 1
  66. grep '[012]\.h' output && exit 1
  67. grep '^ XGEN foo$' output
  68. grep '^ GEN \[headers\]$' output
  69. else
  70. $FGREP 'GEN ' output && exit 1
  71. $FGREP 'cp ./foo.in foo' output
  72. # Be prepared to handle "creative quoting" in the shell traces.
  73. # See automake bug#14760.
  74. ok=false
  75. for q in '' \' \"; do
  76. files="${q}sub/0.h${q} ${q}sub/1.h${q} ${q}sub/2.h${q}"
  77. $FGREP "rm -f $files" output || continue
  78. $FGREP "generate-header --flags $files" output || continue
  79. ok=:
  80. break
  81. done
  82. $ok || exit 1
  83. unset ok
  84. fi
  85. }
  86. ./configure --enable-silent-rules
  87. do_check --silent
  88. do_check --verbose V=1
  89. $MAKE distclean
  90. ./configure --disable-silent-rules
  91. do_check --verbose
  92. do_check --silent V=0
  93. $MAKE distclean
  94. :