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