Merge branch 'msvc' into maint
[platform/upstream/automake.git] / tests / extra-portability.test
1 #! /bin/sh
2 # Copyright (C) 2011  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' does *not* imply `-Wextra-portability'.
22
23 . ./defs || Exit 1
24
25 set -e
26
27 # We want (almost) complete control over automake options.
28 # FIXME: use $original_AUTOMAKE here once we are merged into master.
29 AUTOMAKE="`(set $AUTOMAKE && echo $1)` --foreign -Werror"
30
31 cat >>configure.in <<END
32 AC_PROG_CC
33 AC_PROG_RANLIB
34 AC_OUTPUT
35 END
36
37 $ACLOCAL
38
39 #
40 # First, a setup where only an extra-portability warning is present
41 # (no "simple" portability-warnings are).
42 #
43
44 cat >Makefile.am <<END
45 EXTRA_LIBRARIES = libfoo.a
46 libfoo_a_SOURCES = sub/foo.c
47 END
48
49 # Sanity check: extra-portability warnings causes the expected error.
50 AUTOMAKE_fails -Wextra-portability
51 grep 'requires.*AM_PROG_AR' stderr
52
53 # Warnings in extra-portability category are not enabled by default.
54 $AUTOMAKE
55
56 # `-Wall' does not enable extra-portability warnings.
57 $AUTOMAKE -Wall -Werror
58
59 # Enabling extra-portability works.
60 AUTOMAKE_fails -Wnone -Wextra-portability
61 grep 'requires.*AM_PROG_AR' stderr
62 # Disabling portability disables extra-portability.
63 $AUTOMAKE -Wno-portability -Wall
64 $AUTOMAKE -Wextra-portability -Wno-portability -Wall
65
66 echo libfoo_a_CPPFLAGS = -Dwhatever >> Makefile.am
67
68 # Enabling extra-portability enables portability.
69 AUTOMAKE_fails -Wnone -Wextra-portability
70 # The expected diagnostic is
71 #    Makefile.am:2: compiling `foo.c' with per-target flags requires `AM_PROG_CC_C_O' in `configure.in'
72 #    .../lib/am/library.am: `libfoo.a': linking libraries using a non-POSIX
73 #    .../lib/am/library.am: archiver requires `AM_PROG_AR' in `configure.in'
74 #    Makefile.am:1:   while processing library `libfoo.a'
75 grep 'requires.*AM_PROG_CC_C_O' stderr
76 grep 'requires.*AM_PROG_AR' stderr
77
78 # `-Wall' does not reset extra portability warnings to their
79 # default (i.e., disabled).
80 AUTOMAKE_fails -Wextra-portability -Wall
81 grep 'requires.*AM_PROG_CC_C_O' stderr
82 grep 'requires.*AM_PROG_AR' stderr
83
84 # Disabling extra-portability leaves portability intact.
85 AUTOMAKE_fails -Wportability -Wno-extra-portability
86 grep 'requires.*AM_PROG_CC_C_O' stderr
87 grep 'requires.*AM_PROG_AR' stderr && Exit 1
88
89 # `-Wall' does not set extra portability warnings if they have
90 # been previously disabled.
91 AUTOMAKE_fails -Wno-extra-portability -Wall
92 grep 'requires.*AM_PROG_CC_C_O' stderr
93 grep 'requires.*AM_PROG_AR' stderr && Exit 1
94
95 # Enabling portability does not enable extra-portability.
96 AUTOMAKE_fails -Wnone -Wportability
97 grep 'requires.*AM_PROG_CC_C_O' stderr
98 grep 'requires.*AM_PROG_AR' stderr && Exit 1
99
100 # Disabling portability disables extra-portability.
101 $AUTOMAKE -Wno-portability
102 $AUTOMAKE -Wextra-portability -Wno-portability
103 $AUTOMAKE -Wall -Wno-portability
104
105 :