doc: typos in test file.
[automake.git] / t / extra-portability.sh
blob52c61be5fbd58524ae768a6d330f9118e185f163
1 #! /bin/sh
2 # Copyright (C) 2011-2024 Free Software Foundation, Inc.
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.
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.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
17 # Check interactions between the 'portability' and 'extra-portability'
18 # warning categories:
19 # 1. '-Wextra-portability' must imply '-Wportability'.
20 # 2. '-Wno-portability' must imply '-Wno-extra-portability'.
21 # 3. '-Wall' must imply '-Wextra-portability'.
23 . test-init.sh
25 # We want (almost) complete control over automake options.
26 AUTOMAKE="$am_original_AUTOMAKE --foreign -Werror"
28 cat >>configure.ac <<END
29 AC_PROG_CC
30 AC_PROG_RANLIB
31 AC_OUTPUT
32 END
34 $ACLOCAL
37 # First, a setup where only an extra-portability warning is present
38 # (no "simple" portability-warnings are).
41 cat >Makefile.am <<END
42 EXTRA_LIBRARIES = libfoo.a
43 libfoo_a_SOURCES = foo.c
44 END
46 # Sanity check: extra-portability warnings causes the expected error.
47 AUTOMAKE_fails -Wextra-portability
48 grep 'requires.*AM_PROG_AR' stderr
50 # Warnings in extra-portability category are not enabled by default.
51 $AUTOMAKE
53 # -Wall enables extra-portability.
54 AUTOMAKE_fails -Wall
55 grep 'requires.*AM_PROG_AR' stderr
57 # Disabling portability disables extra-portability as well.
58 $AUTOMAKE -Wextra-portability -Wno-portability
59 $AUTOMAKE -Wall -Wno-portability
62 # Now, a setup where also a "simple" portability warning is present.
65 echo 'var = $(foo--bar)' >> Makefile.am
67 # Enabling extra-portability enables portability as well ...
68 AUTOMAKE_fails -Wextra-portability
69 grep 'foo--bar' stderr
70 grep 'requires.*AM_PROG_AR' stderr
71 # ... even if it had been previously disabled.
72 AUTOMAKE_fails -Wno-portability -Wextra-portability
73 grep 'foo--bar' stderr
74 grep 'requires.*AM_PROG_AR' stderr
76 # Disabling extra-portability leaves portability intact (1).
77 AUTOMAKE_fails -Wportability -Wno-extra-portability
78 grep 'foo--bar' stderr
79 grep 'requires.*AM_PROG_AR' stderr && exit 1
80 # Disabling extra-portability leaves portability intact (2).
81 AUTOMAKE_fails -Wall -Wno-extra-portability
82 grep 'foo--bar' stderr
83 grep 'requires.*AM_PROG_AR' stderr && exit 1
85 # Enabling portability does not enable extra-portability.
86 AUTOMAKE_fails -Wportability
87 grep 'foo--bar' stderr
88 grep 'requires.*AM_PROG_AR' stderr && exit 1
90 # Disabling portability disables extra-portability.
91 $AUTOMAKE -Wno-portability
92 $AUTOMAKE -Wextra-portability -Wno-portability
93 $AUTOMAKE -Wall -Wno-portability