am-ft: make the environment available earlier
[platform/upstream/automake.git] / t / vars3.sh
1 #! /bin/sh
2 # Copyright (C) 2002-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 # Check that Automake warns about variables containing spaces
18 # and other non-POSIX characters.
19
20 . test-init.sh
21
22 cat >Makefile.am <<'EOF'
23 L01 = $(shell echo *)
24 L02 = $$(not an error)
25 L03 = $$(this is)$${ok too}
26 L04 = $(nextvariableisbad)$(addsuffix .a, $(A))
27 L05 = "$(bad boy)"
28 L06 = $(this:is= ok)
29 L07 = ${three errors}${on this} $(long line)
30 L08$(o u c h): $(wildcard *.c)
31         ${another Error}
32         echo $${ok-this is}
33 L11: $(thisis) $(ok)
34         ${here}
35 EOF
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; }
41 cat 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.
47 grep -v '^Makefile\.am:[145789]:' stderr | grep . && exit 1
48
49 # Now check some individual values.
50 grep ':1:.*shell echo' stderr
51 grep 'nextvariableisbad' stderr && exit 1
52 grep ':4:.*addsuffix' stderr
53 grep ':5:.*bad boy' stderr
54 grep ':7:.*three errors' stderr
55 grep ':7:.*on this' stderr
56 grep ':7:.*long line' stderr
57 grep ':8:.*o u c h' stderr
58 grep ':8:.*wildcard' stderr
59 grep ':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).
69 echo 'AUTOMAKE_OPTIONS = -Wno-portability' >> Makefile.am
70 $AUTOMAKE
71
72 :