Merge branch 'msvc' into maint
[platform/upstream/automake.git] / tests / warnopts.test
1 #! /bin/sh
2 # Copyright (C) 2002, 2003, 2004  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 # Make sure that we can enable or disable warnings on a per-file basis.
18
19 . ./defs || Exit 1
20
21 set -e
22
23 cat >>configure.in <<END
24 AC_CONFIG_FILES([sub/Makefile])
25 AC_OUTPUT
26 END
27
28 mkdir sub
29
30 # These two Makefile contain the same errors, but have different
31 # warnings disabled.
32
33 cat >Makefile.am <<END
34 AUTOMAKE_OPTIONS = -Wno-obsolete
35 INCLUDES = -Ifoo
36 foo_SOURCES = unused
37 SUBDIRS = sub
38 END
39
40 cat >sub/Makefile.am <<END
41 AUTOMAKE_OPTIONS = -Wno-syntax
42 INCLUDES = -Ifoo
43 foo_SOURCES = unused
44 END
45
46 $ACLOCAL
47 AUTOMAKE_fails
48 # The expected diagnostic is
49 #   Makefile.am:3: unused variable: `foo_SOURCES'
50 #   sub/Makefile.am:2: `INCLUDES' is the old name for `AM_CPPFLAGS'
51 grep '^Makefile.am:.*foo_SOURCES' stderr
52 grep '^sub/Makefile.am:.*INCLUDES' stderr
53 grep '^sub/Makefile.am:.*foo_SOURCES' stderr && Exit 1
54 grep '^Makefile.am:.*INCLUDES' stderr && Exit 1
55 # Only three lines of warnings.
56 test `wc -l < stderr` = 3
57
58 # On fast machines the autom4te.cache created during the above run of
59 # $AUTOMAKE is likely to have the same time stamp as the configure.in
60 # created below; thus causing traces for the old configure.in to be
61 # used.  We could do `$sleep', but it's faster to erase the
62 # directory.  (Erase autom4te*.cache, not autom4te.cache, because some
63 # bogus installations of Autoconf use a versioned cache.)
64 rm -rf autom4te*.cache
65
66 # If we add a global -Wnone, all warnings should disappear.
67 cat >configure.in <<END
68 AC_INIT([warnopts], [1.0])
69 AM_INIT_AUTOMAKE([-Wnone])
70 AC_CONFIG_FILES([Makefile sub/Makefile])
71 AC_OUTPUT
72 END
73 $ACLOCAL
74 $AUTOMAKE