1#! /bin/sh
2# Copyright (C) 2002-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# Check that Automake warns about variables containing spaces
18# and other non-POSIX characters.
19
20. test-init.sh
21
22cat >Makefile.am <<'EOF'
23L01 = $(shell echo *)
24L02 = $$(not an error)
25L03 = $$(this is)$${ok too}
26L04 = $(nextvariableisbad)$(addsuffix .a, $(A))
27L05 = "$(bad boy)"
28L06 = $(this:is= ok)
29L07 = ${three errors}${on this} $(long line)
30L08$(o u c h): $(wildcard *.c)
31	${another Error}
32	echo $${ok-this is}
33L11: $(thisis) $(ok)
34	${here}
35EOF
36
37$ACLOCAL
38# Make sure this warning is print in the 'portability' category.
39$AUTOMAKE --warnings=no-error,none,portability 2>stderr \
40  || { cat stderr >&2; exit 1; }
41cat stderr >&2
42
43# Lines number are printed in error message.
44# Use them to make sure errors are diagnosed against the right lines.
45
46# No error expected apart from those on these lines.
47grep -v '^Makefile\.am:[145789]:' stderr | grep . && exit 1
48
49# Now check some individual values.
50grep ':1:.*shell echo' stderr
51grep 'nextvariableisbad' stderr && exit 1
52grep ':4:.*addsuffix' stderr
53grep ':5:.*bad boy' stderr
54grep ':7:.*three errors' stderr
55grep ':7:.*on this' stderr
56grep ':7:.*long line' stderr
57grep ':8:.*o u c h' stderr
58grep ':8:.*wildcard' stderr
59grep ':9:.*another Error' stderr
60
61$EGREP 'ok|thisis|here' stderr && exit 1
62
63# None of these errors be diagnosed with '-Wno-portability'.
64$AUTOMAKE -Wno-portability
65
66# Likewise if we add this in the Makefile.am
67# (although this makes some difference internally: AUTOMAKE_OPTIONS is
68# processed far later).
69echo 'AUTOMAKE_OPTIONS = -Wno-portability' >> Makefile.am
70$AUTOMAKE
71
72:
73