warnopts.sh 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. # Make sure that we can enable or disable warnings on a per-file basis.
  17. . test-init.sh
  18. cat >>configure.ac <<END
  19. AC_CONFIG_FILES([sub/Makefile])
  20. AC_OUTPUT
  21. END
  22. mkdir sub
  23. # These two Makefile contain the same errors, but have different
  24. # warnings disabled.
  25. cat >Makefile.am <<END
  26. AUTOMAKE_OPTIONS = -Wno-obsolete
  27. INCLUDES = -Ifoo
  28. foo_SOURCES = unused
  29. SUBDIRS = sub
  30. END
  31. cat >sub/Makefile.am <<END
  32. AUTOMAKE_OPTIONS = -Wno-syntax
  33. INCLUDES = -Ifoo
  34. foo_SOURCES = unused
  35. END
  36. $ACLOCAL
  37. AUTOMAKE_fails
  38. # The expected diagnostic is
  39. # Makefile.am:3: warning: variable 'foo_SOURCES' is defined but no program or
  40. # library has 'foo' as canonical name (possible typo)
  41. # sub/Makefile.am:2: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS'
  42. grep '^Makefile.am:.*foo_SOURCES' stderr
  43. grep '^sub/Makefile.am:.*INCLUDES' stderr
  44. grep '^sub/Makefile.am:.*foo_SOURCES' stderr && exit 1
  45. grep '^Makefile.am:.*INCLUDES' stderr && exit 1
  46. # Only three lines of warnings.
  47. test $(grep -v 'warnings are treated as errors' stderr | wc -l) -eq 3
  48. # On fast machines the autom4te.cache created during the above run of
  49. # $AUTOMAKE is likely to have the same time stamp as the configure.ac
  50. # created below; thus causing traces for the old configure.ac to be
  51. # used. We could do '$sleep', but it's faster to erase the
  52. # directory. (Erase autom4te*.cache, not autom4te.cache, because some
  53. # bogus installations of Autoconf use a versioned cache).
  54. rm -rf autom4te*.cache
  55. # If we add a global -Wnone, all warnings should disappear.
  56. cat >configure.ac <<END
  57. AC_INIT([warnopts], [1.0])
  58. AM_INIT_AUTOMAKE([-Wnone])
  59. AC_CONFIG_FILES([Makefile sub/Makefile])
  60. AC_OUTPUT
  61. END
  62. $ACLOCAL
  63. $AUTOMAKE
  64. :