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