tests: remove most uses of the AM_PROG_CC_C_O obsolete macro
[platform/upstream/automake.git] / t / vala-libs.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 # Building libraries (libtool and static) from Vala sources.
18 # And use of vapi files to call C code from Vala.
19
20 required="valac cc pkg-config libtoolize GNUmake"
21 . test-init.sh
22
23 cat >> configure.ac << 'END'
24 AC_PROG_CC
25 AM_PROG_AR
26 AC_PROG_RANLIB
27 AC_PROG_LIBTOOL
28 AM_PROG_VALAC([0.7.3])
29 PKG_CHECK_MODULES([GOBJECT], [gobject-2.0 >= 2.4])
30 AC_OUTPUT
31 END
32
33 cat > Makefile.am << 'END'
34 lib_LIBRARIES = libmu.a
35 lib_LTLIBRARIES = src/libzardoz.la
36 libmu_a_SOURCES = mu.vala mu2.c mu.vapi mu2.h
37 libmu_a_CPPFLAGS = -DOKOKIMDEFINED=1
38 libmu_a_VALAFLAGS = --vapidir=$(srcdir)
39 AM_CFLAGS = $(GOBJECT_CFLAGS)
40 src_libzardoz_la_LIBADD = $(GOBJECT_LIBS)
41 src_libzardoz_la_SOURCES = src/zardoz-foo.vala src/zardoz-bar.vala
42 src/zardoz-bar.vala: src/zardoz-foo.vala
43         sed 's/Foo/Bar/g' $< >$@
44 END
45
46 libtoolize
47 $ACLOCAL
48 $AUTOCONF
49 $AUTOMAKE -a
50
51 ./configure
52
53 cat > mu2.c << 'END'
54 #include "mu2.h"
55 int mu2 (void)
56 {
57   return OKOKIMDEFINED;
58 }
59 END
60
61 cat > mu2.h << 'END'
62 int mu2 (void);
63 END
64
65 cat > mu.vapi <<'END'
66 [CCode (cheader_filename = "mu2.h", cname = "mu2")]
67 public int c_mu2 ();
68 END
69
70 cat > mu.vala << 'END'
71 int main ()
72 {
73   stdout.printf ("mumumu\n");
74   return c_mu2 ();
75 }
76 END
77
78 mkdir src
79 cat > src/zardoz-foo.vala << 'END'
80 using GLib;
81 public class Foo {
82   public static void zap () {
83     stdout.printf ("FooFooFoo!\n");
84   }
85 }
86 END
87
88 $MAKE
89 test -f libmu.a
90 test -f src/libzardoz.la
91 $FGREP "mumumu" mu.c
92 $FGREP "FooFooFoo" src/zardoz-foo.c
93 $FGREP "BarBarBar" src/zardoz-bar.c
94 test -f libmu_a_vala.stamp
95 test -f src_libzardoz_la_vala.stamp
96
97 $MAKE distcheck
98
99 :