Merge branch 'micro' into maint
[platform/upstream/automake.git] / t / yacc-cxx-grepping.sh
1 #! /bin/sh
2 # Copyright (C) 1997-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 # Test to make sure Yacc + C++ is not obviously broken.
18 # See also related tests 'yacc-cxx.sh' and 'yacc-d-cxx.sh',
19 # which does much more in-depth checks (but requires an actual
20 # Yacc program and a working C++ compiler).
21
22 . test-init.sh
23
24 cat >> configure.ac << 'END'
25 AC_PROG_CXX
26 AC_PROG_YACC
27 END
28
29 cat > Makefile.am << 'END'
30 bin_PROGRAMS = foo bar baz qux
31 foo_SOURCES = foo.y++
32 bar_SOURCES = bar.ypp
33 baz_SOURCES = baz.yy
34 qux_SOURCES = qux.yxx
35 END
36
37 $ACLOCAL
38 $AUTOMAKE -a
39
40 $EGREP '(\.[ch]|foo|bar|baz|qux)' Makefile.in # For debugging.
41
42 $EGREP '(foo|bar|baz|qux)\.h' Makefile.in && exit 1
43
44 sed -e 's/^/ /' -e 's/$/ /' Makefile.in >mk
45
46 $FGREP ' foo.c++ ' mk
47 $FGREP ' bar.cpp ' mk
48 $FGREP ' baz.cc '  mk
49 $FGREP ' qux.cxx ' mk
50
51 cat >> Makefile.am <<END
52 AM_YFLAGS = -d
53 qux_YFLAGS = foo
54 END
55
56 $AUTOMAKE
57
58 $EGREP '(\.[ch]|foo|bar|baz|qux)' Makefile.in # For debugging.
59
60 sed -e 's/^/ /' -e 's/$/ /' Makefile.in >mk
61
62 $FGREP ' foo.c++ ' mk
63 $FGREP ' foo.h++ ' mk
64 $FGREP ' bar.cpp ' mk
65 $FGREP ' bar.hpp ' mk
66 $FGREP ' baz.cc '  mk
67 $FGREP ' baz.hh '  mk
68
69 $EGREP '(^| )foo\.h\+\+(:| .*:)' Makefile.in
70 $EGREP '(^| )bar\.hpp(:| .*:)'   Makefile.in
71 $EGREP '(^| )baz\.hh(:| .*:)'    Makefile.in
72
73 grep ' foo\.h[ :]' mk && exit 1
74 grep ' bar\.h[ :]' mk && exit 1
75 grep ' baz\.h[ :]' mk && exit 1
76
77 $FGREP ' qux-qux.cxx ' mk
78 $EGREP '(^| )qux-qux\.cxx(:| .*:)' Makefile.in
79 grep 'qux\.h.*:' Makefile.in && exit 1
80
81 :