tests: avoid a spurious failure on MSYS
[platform/upstream/automake.git] / t / extra-portability.sh
1 #! /bin/sh
2 # Copyright (C) 2011-2013 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
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'.
22
23 . test-init.sh
24
25 # We want (almost) complete control over automake options.
26 AUTOMAKE="$am_original_AUTOMAKE --foreign -Werror"
27
28 cat >>configure.ac <<END
29 AC_PROG_CC
30 AC_PROG_RANLIB
31 AC_OUTPUT
32 END
33
34 $ACLOCAL
35
36 #
37 # First, a setup where only an extra-portability warning is present
38 # (no "simple" portability-warnings are).
39 #
40
41 cat >Makefile.am <<END
42 EXTRA_LIBRARIES = libfoo.a
43 libfoo_a_SOURCES = sub/foo.c
44 END
45
46 # Sanity check: extra-portability warnings causes the expected error.
47 AUTOMAKE_fails -Wextra-portability
48 grep 'requires.*AM_PROG_AR' stderr
49
50 # Warnings in extra-portability category are not enabled by default.
51 $AUTOMAKE
52
53 # -Wall enables extra-portability.
54 AUTOMAKE_fails -Wall
55 grep 'requires.*AM_PROG_AR' stderr
56
57 # Disabling portability disables extra-portability as well.
58 $AUTOMAKE -Wextra-portability -Wno-portability
59 $AUTOMAKE -Wall -Wno-portability
60
61 #
62 # Now, a setup where also a "simple" portability warning is present.
63 #
64
65 # Per-target flags require the use of AM_PROG_CC_C_O in configure.ac.
66 echo libfoo_a_CPPFLAGS = -Dwhatever >> Makefile.am
67
68 # Enabling extra-portability enables portability as well ...
69 AUTOMAKE_fails -Wextra-portability
70 grep 'requires.*AM_PROG_CC_C_O' stderr
71 grep 'requires.*AM_PROG_AR' stderr
72 # ... even if it had been previously disabled.
73 AUTOMAKE_fails -Wno-portability -Wextra-portability
74 grep 'requires.*AM_PROG_CC_C_O' stderr
75 grep 'requires.*AM_PROG_AR' stderr
76
77 # Disabling extra-portability leaves portability intact (1).
78 AUTOMAKE_fails -Wportability -Wno-extra-portability
79 grep 'requires.*AM_PROG_CC_C_O' stderr
80 grep 'requires.*AM_PROG_AR' stderr && exit 1
81 # Disabling extra-portability leaves portability intact (2).
82 AUTOMAKE_fails -Wall -Wno-extra-portability
83 grep 'requires.*AM_PROG_CC_C_O' stderr
84 grep 'requires.*AM_PROG_AR' stderr && exit 1
85
86 # Enabling portability does not enable extra-portability.
87 AUTOMAKE_fails -Wportability
88 grep 'requires.*AM_PROG_CC_C_O' stderr
89 grep 'requires.*AM_PROG_AR' stderr && exit 1
90
91 # Disabling portability disables extra-portability.
92 $AUTOMAKE -Wno-portability
93 $AUTOMAKE -Wextra-portability -Wno-portability
94 $AUTOMAKE -Wall -Wno-portability
95
96 :