vala tests: avoid spurious failure with older GObject
[platform/upstream/automake.git] / t / vala2.sh
1 #! /bin/sh
2 # Copyright (C) 1996-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 compiling Vala code really works with recursive make.
18
19 required="libtool libtoolize pkg-config valac gcc GNUmake"
20 . ./defs || Exit 1
21
22 mkdir src
23
24 cat >> 'configure.ac' << 'END'
25 AC_PROG_CC
26 AM_PROG_CC_C_O
27 AC_PROG_LIBTOOL
28 AM_PROG_VALAC([0.7.0])
29 PKG_CHECK_MODULES([GOBJECT], [gobject-2.0 >= 2.4])
30 AC_CONFIG_FILES([src/Makefile])
31 AC_OUTPUT
32 END
33
34 cat > 'Makefile.am' <<'END'
35 SUBDIRS = src
36 END
37
38 cat > 'src/Makefile.am' <<'END'
39 bin_PROGRAMS = zardoz
40 zardoz_VALAFLAGS = -H zardoz.h
41 zardoz_CFLAGS = $(GOBJECT_CFLAGS)
42 zardoz_LDADD = $(GOBJECT_LIBS)
43 zardoz_SOURCES = zardoz.vala
44 END
45
46 cat > 'src/zardoz.vala' <<'END'
47 using GLib;
48
49 public class Zardoz {
50   public static void main () {
51     stdout.printf ("Zardoz!\n");
52   }
53 }
54 END
55
56 libtoolize
57
58 $ACLOCAL
59 $AUTOCONF
60 $AUTOMAKE -a
61
62 ./configure || skip_ "configure failure"
63 $MAKE
64
65 # Test rebuild rules.
66 rm -f src/zardoz.h
67 $MAKE -C src zardoz.h
68
69 $MAKE distcheck
70 $MAKE distclean
71 mkdir build
72 cd build
73 ../configure
74 $MAKE
75 $MAKE distcheck
76
77 # Test rebuild rules from builddir.
78 rm -f ../src/zardoz.c
79 $MAKE
80 grep 'Zardoz!' ../src/zardoz.c
81 sed 's/Zardoz!/FooBar!/' ../src/zardoz.c > t
82 mv -f t ../src/zardoz.c
83 $MAKE
84 grep 'FooBar!' ../src/zardoz.c
85 grep 'Zardoz!' ../src/zardoz.c && Exit 1
86
87 :