1#! /bin/sh
2# Copyright (C) 2010-2021 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 <https://www.gnu.org/licenses/>.
16
17# Make sure we warn about possible variable typos when we should.
18
19. test-init.sh
20
21cat >>configure.ac <<'END'
22AC_PROG_RANLIB
23AC_OUTPUT
24END
25
26cat >Makefile.am <<'END'
27foo_SOURCES = unused
28nodist_foo_SOURCES = unused
29EXTRA_foo_SOURCES = unused
30foo_LDADD = unused
31foo_LDFLAGS = unused
32foo_DEPENDENCIES = unused
33EXTRA_foo_DEPENDENCIES = unused
34
35libfoo_a_SOURCES = unused
36nodist_libfoo_a_SOURCES = unused
37EXTRA_libfoo_a_SOURCES = unused
38libfoo_a_LIBADD = unused
39libfoo_a_DEPENDENCIES = unused
40EXTRA_libfoo_a_DEPENDENCIES = unused
41END
42
43$ACLOCAL
44AUTOMAKE_fails -Wno-extra-portability
45# The expected diagnostic is:
46# automake: warnings are treated as errors
47# Makefile.am:2: warning: variable 'nodist_foo_SOURCES' is defined but no program or
48# Makefile.am:2: library has 'foo' as canonical name (possible typo)
49# Makefile.am:1: warning: variable 'foo_SOURCES' is defined but no program or
50# Makefile.am:1: library has 'foo' as canonical name (possible typo)
51# Makefile.am:9: warning: variable 'libfoo_a_SOURCES' is defined but no program or
52# Makefile.am:9: library has 'libfoo_a' as canonical name (possible typo)
53# Makefile.am:10: warning: variable 'nodist_libfoo_a_SOURCES' is defined but no program or
54# Makefile.am:10: library has 'libfoo_a' as canonical name (possible typo)
55# Makefile.am:11: warning: variable 'EXTRA_libfoo_a_SOURCES' is defined but no program or
56# Makefile.am:11: library has 'libfoo_a' as canonical name (possible typo)
57# Makefile.am:3: warning: variable 'EXTRA_foo_SOURCES' is defined but no program or
58# Makefile.am:3: library has 'foo' as canonical name (possible typo)
59# Makefile.am:12: warning: variable 'libfoo_a_LIBADD' is defined but no program or
60# Makefile.am:12: library has 'libfoo_a' as canonical name (possible typo)
61# Makefile.am:4: warning: variable 'foo_LDADD' is defined but no program or
62# Makefile.am:4: library has 'foo' as canonical name (possible typo)
63# Makefile.am:5: warning: variable 'foo_LDFLAGS' is defined but no program or
64# Makefile.am:5: library has 'foo' as canonical name (possible typo)
65# Makefile.am:14: warning: variable 'EXTRA_libfoo_a_DEPENDENCIES' is defined but no program or
66# Makefile.am:14: library has 'libfoo_a' as canonical name (possible typo)
67# Makefile.am:7: warning: variable 'EXTRA_foo_DEPENDENCIES' is defined but no program or
68# Makefile.am:7: library has 'foo' as canonical name (possible typo)
69# Makefile.am:6: warning: variable 'foo_DEPENDENCIES' is defined but no program or
70# Makefile.am:6: library has 'foo' as canonical name (possible typo)
71# Makefile.am:13: warning: variable 'libfoo_a_DEPENDENCIES' is defined but no program or
72# Makefile.am:13: library has 'libfoo_a' as canonical name (possible typo)
73
74grep 'as canonical' stderr | grep -v ' .foo. ' | grep -v ' .libfoo_a. ' \
75  && exit 1
76test $(grep -c 'variable.*is defined but' stderr) -eq 13
77
78# If we add a global -Wnone, all warnings should disappear.
79$AUTOMAKE -Wnone
80
81# Likewise, if matching programs or libraries are defined.
82cat >>Makefile.am <<'END'
83bin_PROGRAMS = foo
84lib_LIBRARIES = libfoo.a
85END
86
87$AUTOMAKE -Wno-extra-portability
88
89:
90