940ef23db628e8ad1208b4b6bade7157ef3169cd
[platform/upstream/automake.git] / tests / dollarvar.test
1 #!/bin/sh
2 # Copyright (C) 2009-2012 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 # Test to make sure that -Wportability complains about recursive
18 # variable expansions and variables containing '$', '$(...)', or
19 # '${...}' in the name.  We support recursive variable expansions using
20 # the latter two constructs for the 'silent-rules' option, and they are
21 # rather widely supported in practice.  OTOH variable definitions
22 # containing a '$' on the left hand side of an assignment are not
23 # portable in practice, even though POSIX allows them.  :-/
24
25 . ./defs || Exit 1
26
27 cat >Makefile.am <<'EOF'
28 x = 1
29 foo$x = 1
30 bar$(x) = 1
31 baz${x} = 1
32 bla = $(foo$x)
33 bli = $(foo$(x))
34 blo = $(foo${x})
35 EOF
36
37 $ACLOCAL
38 AUTOMAKE_fails -Wportability
39 grep 'Makefile.am:2' stderr
40 grep 'Makefile.am:3' stderr
41 grep 'Makefile.am:4' stderr
42 grep 'Makefile.am:5' stderr
43 grep 'Makefile.am:6' stderr
44 grep 'Makefile.am:7' stderr
45
46 # On the other hand, if we allow 'silent-rules' mode, then we need to
47 # allow recursive variable expansion, too.
48
49 # This should work with the AM_SILENT_RULES macro.
50 $sleep
51 echo 'AM_SILENT_RULES' >> configure.ac
52
53 $ACLOCAL --force
54 AUTOMAKE_fails -Wportability
55 grep 'Makefile.am:2' stderr
56 grep 'Makefile.am:3' stderr
57 grep 'Makefile.am:4' stderr
58 grep 'Makefile.am:5' stderr
59 grep 'Makefile.am:6' stderr && Exit 1
60 grep 'Makefile.am:7' stderr && Exit 1
61
62
63 :