rename-tests: rework some code for clarity and safety
[platform/upstream/automake.git] / t / yflags-cxx.sh
1 #! /bin/sh
2 # Copyright (C) 2010-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 $(YFLAGS) takes precedence over both $(AM_YFLAGS) and
18 # $(foo_YFLAGS).
19 # Please keep this in sync with the sister tests yflags.sh, lflags.sh
20 # and lflags2.sh.
21
22 . test-init.sh
23
24 cat >fake-yacc <<'END'
25 #!/bin/sh
26 echo '/*' "$*" '*/' >y.tab.c
27 echo 'extern int dummy;' >> y.tab.c
28 END
29 chmod a+x fake-yacc
30
31 cat >> configure.ac <<'END'
32 AC_SUBST([CXX], [false])
33 # Simulate presence of Yacc using our fake-yacc script.
34 AC_SUBST([YACC], ['$(abs_top_srcdir)'/fake-yacc])
35 AC_OUTPUT
36 END
37
38 cat > Makefile.am <<'END'
39 AUTOMAKE_OPTIONS = no-dependencies
40 bin_PROGRAMS = foo bar
41 foo_SOURCES = main.cc foo.yy
42 bar_SOURCES = main.cc bar.y++
43 AM_YFLAGS = __am_flags__
44 bar_YFLAGS = __bar_flags__
45 END
46
47 $ACLOCAL
48 $AUTOMAKE -a
49
50 grep '\$(YFLAGS).*\$(bar_YFLAGS)' Makefile.in && exit 1
51 grep '\$(YFLAGS).*\$(AM_YFLAGS)' Makefile.in && exit 1
52
53 : > foo.yy
54 : > bar.y++
55
56 $AUTOCONF
57 ./configure
58 run_make YFLAGS=__user_flags__ foo.cc bar-bar.c++
59
60 cat foo.cc
61 cat bar-bar.c++
62
63 grep '__am_flags__.*__user_flags__' foo.cc
64 grep '__bar_flags__.*__user_flags__' bar-bar.c++
65
66 :