tests: never source test-defs.sh directly, source test-lib.sh instead
[automake.git] / t / vala-mix.sh
blob2580bd07493be74e4c807c0547c6578a941e9c07
1 #! /bin/sh
2 # Copyright (C) 2012 Free Software Foundation, Inc.
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.
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.
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/>.
17 # Vala sources and C sources in the same program. Functional test.
19 required='valac cc GNUmake'
20 . ./defs || exit 1
22 cat >> configure.ac <<'END'
23 AC_PROG_CC
24 AM_PROG_CC_C_O
25 AM_PROG_VALAC([0.7.3])
26 AC_OUTPUT
27 END
29 cat > Makefile.am <<'END'
30 bin_PROGRAMS = zardoz mu baz
31 AM_VALAFLAGS = --profile=posix
32 zardoz_SOURCES = foo.vala bar.c
33 mu_SOURCES = 1.vala 2.c
34 mu_VALAFLAGS = $(AM_VALAFLAGS) --main=run
35 mu_CFLAGS = -DHAVE_MU
36 baz_SOURCES = baz.c
37 END
39 if ! cross_compiling; then
40 unindent >> Makefile.am <<'END'
41 check-local:
42 ./zardoz
43 ./mu
44 ./zardoz | grep "foo is alive"
45 ./mu | grep "Howdy, World!"
46 END
49 cat > foo.vala <<'END'
50 int main ()
52 stdout.printf ("foo is alive\n");
53 return 0;
55 END
57 echo 'extern int i = 0;' > bar.c
59 cat > 1.vala <<'END'
60 int run ()
62 stdout.printf ("Howdy, World!\n");
63 return 0;
65 END
67 cat > 2.c <<'END'
68 #ifdef HAVE_MU
69 int all_is_ok = 1;
70 #else
71 #error "HAVE_MU no defined"
72 chocke me
73 #endif
74 END
76 # For automake bug#11229.
77 cat > baz.c <<'END'
78 int main (void)
80 return 0;
82 END
84 $ACLOCAL
85 $AUTOMAKE -a
86 $AUTOCONF
88 ./configure
90 $MAKE all
91 ls -l # For debugging.
92 $MAKE check
94 have_generated_files ()
96 test -f mu_vala.stamp
97 test -f zardoz_vala.stamp
98 test -f foo.c
99 test -f 1.c
102 # Our vala-related rules must create stamp files and intermediate
103 # C files.
104 have_generated_files
106 # Remake rules are not uselessly triggered.
107 $MAKE -q
108 $MAKE -n | $FGREP vala.stamp && exit 1
110 # Check the distribution.
111 $MAKE distcheck
113 # Stamp files and intermediate C files should *not* be removed
114 # by "make clean".
115 $MAKE clean
116 have_generated_files
118 # But stamp files should be removed by "maintainer-clean" (the
119 # behaviour w.r.t. intermediate C files is still unclear, and
120 # better left undefined for the moment).
121 $MAKE maintainer-clean
122 ls *vala*.stamp | grep . && exit 1