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