tests: expose automake bug#14560
[platform/upstream/automake.git] / t / vala-mix.sh
1 #! /bin/sh
2 # Copyright (C) 2012-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 # Vala sources and C sources in the same program.  Functional test.
18
19 required='valac cc pkg-config GNUmake'
20 . test-init.sh
21
22 cat >> configure.ac <<'END'
23 AC_PROG_CC
24 AM_PROG_CC_C_O
25 AM_PROG_VALAC([0.7.3])
26 PKG_CHECK_MODULES([GOBJECT], [gobject-2.0 >= 2.4])
27 AC_OUTPUT
28 END
29
30 cat > Makefile.am <<'END'
31 bin_PROGRAMS = zardoz mu baz
32 AM_CFLAGS = $(GOBJECT_CFLAGS)
33 LDADD = $(GOBJECT_LIBS)
34 zardoz_SOURCES = foo.vala bar.c
35 mu_SOURCES = 1.vala 2.c
36 mu_VALAFLAGS = --main=run
37 mu_CFLAGS = -DHAVE_MU $(AM_CFLAGS)
38 baz_SOURCES = baz.c
39 END
40
41 if ! cross_compiling; then
42   unindent >> Makefile.am <<'END'
43     check-local:
44         ./zardoz
45         ./mu
46         ./zardoz | grep "foo is alive"
47         ./mu | grep "Howdy, World!"
48 END
49 fi
50
51 cat > foo.vala <<'END'
52 int main ()
53 {
54   stdout.printf ("foo is alive\n");
55   return 0;
56 }
57 END
58
59 echo 'extern int i = 0;' > bar.c
60
61 cat > 1.vala <<'END'
62 int run ()
63 {
64   stdout.printf ("Howdy, World!\n");
65   return 0;
66 }
67 END
68
69 cat > 2.c <<'END'
70 #ifdef HAVE_MU
71 int all_is_ok = 1;
72 #else
73 #error "HAVE_MU no defined"
74 chocke me
75 #endif
76 END
77
78 # For automake bug#11229.
79 cat > baz.c <<'END'
80 int main (void)
81 {
82   return 0;
83 }
84 END
85
86 $ACLOCAL
87 $AUTOMAKE -a
88 $AUTOCONF
89
90 ./configure
91
92 $MAKE all
93 ls -l # For debugging.
94 $MAKE check
95
96 have_generated_files ()
97 {
98   test -f mu_vala.stamp
99   test -f zardoz_vala.stamp
100   test -f foo.c
101   test -f 1.c
102 }
103
104 # Our vala-related rules must create stamp files and intermediate
105 # C files.
106 have_generated_files
107
108 # Remake rules are not uselessly triggered.
109 $MAKE -q
110 $MAKE -n | $FGREP vala.stamp && exit 1
111
112 # Check the distribution.
113 $MAKE distcheck
114
115 # Stamp files and intermediate C files should *not* be removed
116 # by "make clean".
117 $MAKE clean
118 have_generated_files
119
120 # But stamp files should be removed by "maintainer-clean" (the
121 # behaviour w.r.t. intermediate C files is still unclear, and
122 # better left undefined for the moment).
123 $MAKE maintainer-clean
124 ls *vala*.stamp | grep . && exit 1
125
126 :