tests: expose automake bug#13940
[platform/upstream/automake.git] / t / vala-recursive-setup.sh
1 #! /bin/sh
2 # Copyright (C) 1996-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 compiling Vala code really works with recursive make.
18
19 required="pkg-config valac gcc GNUmake"
20 . test-init.sh
21
22 mkdir src
23
24 cat >> 'configure.ac' << 'END'
25 AC_PROG_CC
26 AM_PROG_CC_C_O
27 AM_PROG_VALAC([0.7.0])
28 PKG_CHECK_MODULES([GOBJECT], [gobject-2.0 >= 2.4])
29 AC_CONFIG_FILES([src/Makefile])
30 AC_OUTPUT
31 END
32
33 cat > 'Makefile.am' <<'END'
34 SUBDIRS = src
35 END
36
37 cat > 'src/Makefile.am' <<'END'
38 bin_PROGRAMS = zardoz
39 zardoz_VALAFLAGS = -H zardoz.h
40 zardoz_CFLAGS = $(GOBJECT_CFLAGS)
41 zardoz_LDADD = $(GOBJECT_LIBS)
42 zardoz_SOURCES = zardoz.vala
43 END
44
45 cat > 'src/zardoz.vala' <<'END'
46 using GLib;
47
48 public class Zardoz {
49   public static void main () {
50     stdout.printf ("Zardoz!\n");
51   }
52 }
53 END
54
55 $ACLOCAL
56 $AUTOCONF
57 $AUTOMAKE -a
58
59 ./configure
60 $MAKE
61
62 # Test rebuild rules.
63
64 rm -f src/zardoz.h
65 $MAKE -C src zardoz.h
66 test -f src/zardoz.h
67 rm -f src/zardoz.c
68 $MAKE -C src
69 test -f src/zardoz.c
70
71 echo am--error > src/zardoz.h
72 echo am--error > src/zardoz.c
73 $sleep
74 touch src/zardoz.vala
75 $MAKE
76 grep 'am--error' src/zardoz.[ch] && exit 1
77
78 # Check the distribution.
79
80 $MAKE distcheck
81 $MAKE distclean
82
83 # Tru a VPATH setup.
84
85 mkdir build
86 cd build
87 ../configure
88 $MAKE
89 $MAKE distcheck
90
91 # Test rebuild rules from builddir.
92
93 rm -f ../src/zardoz.h
94 $MAKE -C src ../../src/zardoz.h
95 test -f ../src/zardoz.h
96
97 rm -f ../src/zardoz.c
98 $MAKE
99 grep 'Zardoz!' ../src/zardoz.c
100
101 $sleep
102 sed 's/Zardoz!/FooBar!/' ../src/zardoz.vala > t
103 mv -f t ../src/zardoz.vala
104 $MAKE
105 grep 'FooBar!' ../src/zardoz.c
106 grep 'Zardoz!' ../src/zardoz.c && exit 1
107
108 :