silent-cxx.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 C++, both with and without automatic
  17. # dependency tracking.
  18. required=c++
  19. . test-init.sh
  20. mkdir sub
  21. cat >>configure.ac <<'EOF'
  22. AC_PROG_CXX
  23. AC_CONFIG_FILES([sub/Makefile])
  24. AC_OUTPUT
  25. EOF
  26. cat > Makefile.am <<'EOF'
  27. # Need generic and non-generic rules.
  28. bin_PROGRAMS = foo1 foo2
  29. foo1_SOURCES = foo.cpp baz.cxx quux.cc
  30. foo2_SOURCES = $(foo1_SOURCES)
  31. foo2_CXXFLAGS = $(AM_CXXFLAGS)
  32. SUBDIRS = sub
  33. EOF
  34. cat > sub/Makefile.am <<'EOF'
  35. AUTOMAKE_OPTIONS = subdir-objects
  36. # Need generic and non-generic rules.
  37. bin_PROGRAMS = bar1 bar2
  38. bar1_SOURCES = bar.cpp
  39. bar2_SOURCES = $(bar1_SOURCES)
  40. bar2_CXXFLAGS = $(AM_CXXFLAGS)
  41. EOF
  42. cat > foo.cpp <<'EOF'
  43. using namespace std; /* C compilers fail on this. */
  44. int main (void) { return 0; }
  45. EOF
  46. # Let's try out other extensions too.
  47. echo 'class Baz { public: int i; };' > baz.cxx
  48. echo 'class Quux { public: bool b; };' > quux.cc
  49. cp foo.cpp sub/bar.cpp
  50. $ACLOCAL
  51. $AUTOMAKE --add-missing
  52. $AUTOCONF
  53. # Sanity check: make sure the cache variable we force is really used
  54. # by configure.
  55. $FGREP am_cv_CXX_dependencies_compiler_type configure
  56. # Force dependency tracking explicitly, so that slow dependency
  57. # extractors are not rejected. Try also with dependency tracking
  58. # explicitly disabled.
  59. for config_args in \
  60. --enable-dependency-tracking --disable-dependency-tracking
  61. do
  62. ./configure $config_args --enable-silent-rules
  63. run_make -O
  64. $EGREP ' (-c|-o)' stdout && exit 1
  65. grep 'mv ' stdout && exit 1
  66. grep 'CXX .*foo\.' stdout
  67. grep 'CXX .*baz\.' stdout
  68. grep 'CXX .*quux\.' stdout
  69. grep 'CXX .*bar\.' stdout
  70. grep 'CXXLD .*foo1' stdout
  71. grep 'CXXLD .*bar1' stdout
  72. grep 'CXXLD .*foo2' stdout
  73. grep 'CXXLD .*bar2' stdout
  74. # Ensure a clean rebuild.
  75. $MAKE clean
  76. run_make -O V=1
  77. grep ' -c ' stdout
  78. grep ' -o ' stdout
  79. $EGREP '(CXX|LD) ' stdout && exit 1
  80. # Ensure a clean reconfiguration/rebuild.
  81. $MAKE clean
  82. $MAKE maintainer-clean
  83. done
  84. :