am-ft: make the environment available earlier
[platform/upstream/automake.git] / t / warnings-override.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 # The warnings specified in Makefile.am:AUTOMAKE_OPTIONS should override
18 # those specified in configure.ac:AM_INIT_AUTOMAKE, and both should
19 # override the warnings specified on the command line.
20 # NOTE: the current semantics might not be the best one (even if it has
21 # been in place for quite a long time); see also Automake bug #7673.
22 # Update this test if the semantics are changed.
23
24 . test-init.sh
25
26 # We want (almost) complete control over automake options.
27 AUTOMAKE="$am_original_AUTOMAKE -Werror"
28
29 cat > Makefile.am <<'END'
30 FOO := bar
31 AUTOMAKE_OPTIONS =
32 END
33
34 set_warnings ()
35 {
36   set +x
37   sed <$2 >$2-t -e "s|^\\(AUTOMAKE_OPTIONS\\) *=.*|\\1 = $1|" \
38                 -e "s|^\\(AM_INIT_AUTOMAKE\\).*|\\1([$1])|"
39   mv -f $2-t $2
40   set -x
41   cat $2
42 }
43
44 ok ()
45 {
46   $AUTOMAKE $*
47 }
48
49 ko ()
50 {
51   AUTOMAKE_fails $*
52   grep '^Makefile\.am:1:.*:=.*not portable' stderr
53 }
54
55 $ACLOCAL
56
57 # Files required in gnu strictness.
58 touch README INSTALL NEWS AUTHORS ChangeLog COPYING
59
60 rm -rf autom4te*.cache
61 set_warnings '-Wno-portability' Makefile.am
62 set_warnings '' configure.ac
63
64 ok -Wportability
65 ok
66
67 rm -rf autom4te*.cache
68 set_warnings '' Makefile.am
69 set_warnings '-Wno-portability' configure.ac
70
71 ok -Wportability
72 ok
73
74 rm -rf autom4te*.cache
75 set_warnings '-Wno-portability' Makefile.am
76 set_warnings '-Wno-portability' configure.ac
77
78 ok -Wportability
79
80 rm -rf autom4te*.cache
81 set_warnings '-Wportability' Makefile.am
82 set_warnings '' configure.ac
83
84 ko
85 ko -Wno-portability
86
87 rm -rf autom4te*.cache
88 set_warnings '' Makefile.am
89 set_warnings '-Wportability' configure.ac
90
91 ko
92 ko -Wno-portability
93
94 rm -rf autom4te*.cache
95 set_warnings '-Wportability' Makefile.am
96 set_warnings '-Wportability' configure.ac
97 ko -Wno-portability
98
99 rm -rf autom4te*.cache
100 set_warnings '-Wno-portability' Makefile.am
101 set_warnings '-Wportability' configure.ac
102 ok
103 ok -Wportability
104
105 rm -rf autom4te*.cache
106 set_warnings '-Wportability' Makefile.am
107 set_warnings '-Wno-portability' configure.ac
108 ko
109 ko -Wno-portability
110
111 :