extra-portability.sh 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #! /bin/sh
  2. # Copyright (C) 2011-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 interactions between the 'portability' and 'extra-portability'
  17. # warning categories:
  18. # 1. '-Wextra-portability' must imply '-Wportability'.
  19. # 2. '-Wno-portability' must imply '-Wno-extra-portability'.
  20. # 3. '-Wall' must imply '-Wextra-portability'.
  21. . test-init.sh
  22. # We want (almost) complete control over automake options.
  23. AUTOMAKE="$am_original_AUTOMAKE --foreign -Werror"
  24. cat >>configure.ac <<END
  25. AC_PROG_CC
  26. AC_PROG_RANLIB
  27. AC_OUTPUT
  28. END
  29. $ACLOCAL
  30. #
  31. # First, a setup where only an extra-portability warning is present
  32. # (no "simple" portability-warnings are).
  33. #
  34. cat >Makefile.am <<END
  35. EXTRA_LIBRARIES = libfoo.a
  36. libfoo_a_SOURCES = foo.c
  37. END
  38. # Sanity check: extra-portability warnings causes the expected error.
  39. AUTOMAKE_fails -Wextra-portability
  40. grep 'requires.*AM_PROG_AR' stderr
  41. # Warnings in extra-portability category are not enabled by default.
  42. $AUTOMAKE
  43. # -Wall enables extra-portability.
  44. AUTOMAKE_fails -Wall
  45. grep 'requires.*AM_PROG_AR' stderr
  46. # Disabling portability disables extra-portability as well.
  47. $AUTOMAKE -Wextra-portability -Wno-portability
  48. $AUTOMAKE -Wall -Wno-portability
  49. #
  50. # Now, a setup where also a "simple" portability warning is present.
  51. #
  52. echo 'var = $(foo--bar)' >> Makefile.am
  53. # Enabling extra-portability enables portability as well ...
  54. AUTOMAKE_fails -Wextra-portability
  55. grep 'foo--bar' stderr
  56. grep 'requires.*AM_PROG_AR' stderr
  57. # ... even if it had been previously disabled.
  58. AUTOMAKE_fails -Wno-portability -Wextra-portability
  59. grep 'foo--bar' stderr
  60. grep 'requires.*AM_PROG_AR' stderr
  61. # Disabling extra-portability leaves portability intact (1).
  62. AUTOMAKE_fails -Wportability -Wno-extra-portability
  63. grep 'foo--bar' stderr
  64. grep 'requires.*AM_PROG_AR' stderr && exit 1
  65. # Disabling extra-portability leaves portability intact (2).
  66. AUTOMAKE_fails -Wall -Wno-extra-portability
  67. grep 'foo--bar' stderr
  68. grep 'requires.*AM_PROG_AR' stderr && exit 1
  69. # Enabling portability does not enable extra-portability.
  70. AUTOMAKE_fails -Wportability
  71. grep 'foo--bar' stderr
  72. grep 'requires.*AM_PROG_AR' stderr && exit 1
  73. # Disabling portability disables extra-portability.
  74. $AUTOMAKE -Wno-portability
  75. $AUTOMAKE -Wextra-portability -Wno-portability
  76. $AUTOMAKE -Wall -Wno-portability
  77. :