Merge branch 'fix-pr14560' into micro
[platform/upstream/automake.git] / t / dollarvar2.sh
1 #!/bin/sh
2 # Copyright (C) 2009-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 # Test to make sure that -Wportability turns on portability-recursive,
18 # likewise for -Wno-...
19
20 . test-init.sh
21
22 #
23 # First, try a setup where we have a 'portability-recursive' warning,
24 # but no "simple" 'portability' warning.
25 #
26
27 cat >Makefile.am <<'EOF'
28 x = 1
29 bla = $(foo$(x))
30 EOF
31
32 $ACLOCAL
33
34 # Enabling 'portability' warnings should enable 'portability-recursive'
35 # warnings.
36 AUTOMAKE_fails -Wnone -Wportability
37 grep 'recursive variable expansion' stderr
38 # 'portability-recursive' warnings can be enabled by themselves.
39 AUTOMAKE_fails -Wnone -Wportability-recursive
40 grep 'recursive variable expansion' stderr
41
42 # Various ways to disable 'portability-recursive'.
43 $AUTOMAKE -Wno-all
44 $AUTOMAKE -Wno-portability
45 $AUTOMAKE -Wall -Wno-portability-recursive
46
47 # '-Wno-portability-recursive' after '-Wportability' correctly disables
48 # 'portability-recursive' warnings.
49 $AUTOMAKE -Wportability -Wno-portability-recursive
50
51 # '-Wno-portability' disables 'portability-recursive' warnings; but
52 # a later '-Wportability-recursive' re-enables them.  This time, we
53 # use AUTOMAKE_OPTIONS to specify the warning levels.
54 echo 'AUTOMAKE_OPTIONS = -Wno-portability' >> Makefile.am
55 $AUTOMAKE
56 echo 'AUTOMAKE_OPTIONS += -Wportability-recursive' >> Makefile.am
57 AUTOMAKE_fails
58 grep 'recursive variable expansion' stderr
59
60 #
61 # Now try a setup where we have both a 'portability' warning and
62 # a 'portability-recursive' one.
63 #
64
65 cat >Makefile.am <<'EOF'
66 x = 1
67 bla = $(foo$(x))
68 noinst_PROGRAMS = foo
69 foo_CPPFLAGS = -Dwhatever
70 EOF
71
72 echo AC_PROG_CC >> configure.ac
73
74 $ACLOCAL --force
75
76 # Can disable both 'portability' and 'portability-recursive' warnings.
77 $AUTOMAKE -Wno-portability
78
79 # Disabling 'portability-recursive' warnings should not disable
80 # 'portability' warnings.
81 AUTOMAKE_fails -Wportability -Wno-portability-recursive
82 grep AM_PROG_CC_C_O stderr
83 grep 'recursive variable expansion' stderr && exit 1
84
85 # Enabling 'portability-recursive' warnings should not enable
86 # all the 'portability' warning.
87 AUTOMAKE_fails -Wno-portability -Wportability-recursive
88 grep AM_PROG_CC_C_O stderr && exit 1
89 grep 'recursive variable expansion' stderr
90
91 :