news: fix typo
[platform/upstream/automake.git] / t / vala-mix.sh
1 #! /bin/sh
2 # Copyright (C) 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 # Vala sources and C sources in the same program.  Functional test.
18
19 required='valac cc GNUmake'
20 . ./defs || Exit 1
21
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
28
29 cat > Makefile.am <<'END'
30 bin_PROGRAMS = zardoz mu
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 END
37
38 if cross_compiling; then :; else
39   unindent >> Makefile.am <<'END'
40     check-local:
41         ./zardoz
42         ./mu
43         ./zardoz | grep "foo is alive"
44         ./mu | grep "Howdy, World!"
45 END
46 fi
47
48 cat > foo.vala <<'END'
49 int main ()
50 {
51   stdout.printf ("foo is alive\n");
52   return 0;
53 }
54 END
55
56 echo 'extern int i = 0;' > bar.c
57
58 cat > 1.vala <<'END'
59 int run ()
60 {
61   stdout.printf ("Howdy, World!\n");
62   return 0;
63 }
64 END
65
66 cat > 2.c <<'END'
67 #ifdef HAVE_MU
68 int all_is_ok = 1;
69 #else
70 #error "HAVE_MU no defined"
71 chocke me
72 #endif
73 END
74
75 $ACLOCAL
76 $AUTOMAKE -a
77 $AUTOCONF
78
79 ./configure
80
81 $MAKE all
82 ls -l # For debugging.
83 $MAKE check
84
85 have_generated_files ()
86 {
87   test -f mu_vala.stamp
88   test -f zardoz_vala.stamp
89   test -f foo.c
90   test -f 1.c
91 }
92
93 # Our vala-related rules must create stamp files and intermediate
94 # C files.
95 have_generated_files
96
97 # Remake rules are not uselessly triggered.
98 $MAKE -q
99 $MAKE -n | $FGREP vala.stamp && Exit 1
100
101 # Check the distribution.
102 $MAKE distcheck
103
104 # Stamp files and intermediate C files should *not* be removed
105 # by "make clean".
106 $MAKE clean
107 have_generated_files
108
109 # But stamp files should be removed by "maintainer-clean" (the
110 # behaviour w.r.t. intermediate C files is still unclear, and
111 # better left undefined for the moment).
112 $MAKE maintainer-clean
113 ls *vala*.stamp | grep . && Exit 1
114
115 :