Merge branch 'msvc' into maint
[platform/upstream/automake.git] / tests / vala5.test
1 #! /bin/sh
2 # Copyright (C) 1996, 2001, 2002, 2006, 2008, 2009, 2012 Free Software
3 # Foundation, Inc.
4 #
5 # This file is part of GNU Automake.
6 #
7 # GNU Automake is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2, or (at your option)
10 # any later version.
11 #
12 # GNU Automake is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with Automake; see the file COPYING.  If not, write to
19 # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 # Boston, MA 02110-1301, USA.
21
22 # Test per-target flags.
23
24 required="pkg-config valac gcc GNUmake"
25 . ./defs || Exit 1
26
27 set -e
28
29 mkdir src
30
31 cat >> configure.in <<'END'
32 AC_PROG_CC
33 AM_PROG_CC_C_O
34 AM_PROG_VALAC([0.7.0])
35 PKG_CHECK_MODULES([GOBJECT], [gobject-2.0 >= 2.10])
36 AC_CONFIG_FILES([src/Makefile])
37 AC_OUTPUT
38 END
39
40 cat > Makefile.am <<'END'
41 SUBDIRS = src
42 END
43
44 cat > src/Makefile.am <<'END'
45 bin_PROGRAMS = foo bar
46 foo_CFLAGS = $(GOBJECT_CFLAGS)
47 foo_LDADD = $(GOBJECT_LIBS)
48 foo_SOURCES = xfoo.vala
49 bar_SOURCES = xbar.vala
50 bar_VALAFLAGS = -D BAR
51 bar_CFLAGS = $(GOBJECT_CFLAGS)
52 bar_LDADD = $(GOBJECT_LIBS)
53 END
54
55 cat > src/xfoo.vala <<'END'
56 int main ()
57 {
58   stdout.printf ("foo\n");
59   return 0;
60 }
61 END
62
63 cat > src/xbar.vala <<'END'
64 void main ()
65 {
66 #if BAR
67   stdout.printf ("bar\n");
68 #else
69   stdout.oops_an_invalid_method ();
70 #endif
71 }
72 END
73
74 $ACLOCAL
75 $AUTOCONF
76 $AUTOMAKE -a
77
78 grep PKG_CHECK_MODULES configure && skip_ "pkg-config m4 macros not found"
79
80 ./configure
81 $MAKE
82
83 if cross_compiling; then :; else
84   ./src/foo
85   ./src/bar
86   test `./src/foo` = foo
87   test `./src/bar` = bar
88 fi
89
90 :