Merge branch 'fix-pr14560' into micro
[platform/upstream/automake.git] / t / yacc-dist-nobuild-subdir.sh
1 #! /bin/sh
2 # Copyright (C) 2011-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 VPATH builds and "make distcheck" works with packages
18 # using yacc and the automake 'subdir-objects' option.
19 # Exposes automake bug#8485.
20
21 required='cc yacc'
22 . test-init.sh
23
24 # This test is bounded to fail for any implementation that
25 # triggers automake bug#7884.
26 useless_vpath_rebuild && skip_ "would trip on automake bug#7884"
27
28 cat >> configure.ac << 'END'
29 AC_PROG_CC
30 AM_PROG_CC_C_O
31 AC_PROG_YACC
32 AC_OUTPUT
33 END
34
35 mkdir sub
36
37 cat > sub/parse.y << 'END'
38 %{
39 int yylex () { return 0; }
40 void yyerror (char *s) { return; }
41 %}
42 %%
43 x : 'x' {};
44 %%
45 int main (void)
46 {
47   return yyparse ();
48 }
49 END
50
51 cat > Makefile.am <<'END'
52 AUTOMAKE_OPTIONS = subdir-objects
53 noinst_PROGRAMS = foo bar
54 foo_SOURCES = sub/parse.y
55 bar_SOURCES = $(foo_SOURCES)
56 AM_YFLAGS = -d
57 bar_YFLAGS =
58 END
59
60 $ACLOCAL
61 $AUTOCONF
62 $AUTOMAKE -a
63
64 ./configure
65 $MAKE distdir
66
67 # Yacc-derived C source and header files must be built and distributed.
68
69 test   -f sub/parse.c
70 test   -f sub/parse.h
71 test   -f sub/bar-parse.c
72 test ! -e sub/bar-parse.h
73
74 test   -f $distdir/sub/parse.c
75 test   -f $distdir/sub/parse.h
76 test   -f $distdir/sub/bar-parse.c
77 test ! -e $distdir/sub/bar-parse.h
78
79 # But they shouldn't be rebuilt in VPATH builds.
80
81 mkdir $distdir/build
82 chmod -R a-w $distdir
83 cd $distdir/build
84 chmod u+w .
85 # Try to enable dependency tracking even with slow dependency
86 # extractors, to improve coverage.
87 ../configure --enable-dependency-tracking YACC=false
88 $MAKE
89 ls -l sub/*.[ch] && exit 1
90
91 env DISTCHECK_CONFIGURE_FLAGS='YACC=false' $MAKE distcheck
92
93 :