tests: give few vala tests more significant names
[platform/upstream/automake.git] / t / vala-per-target-flags.sh
1 #! /bin/sh
2 # Copyright (C) 1996-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 # Test per-target flags in vala support.
18
19 required="pkg-config valac gcc GNUmake"
20 . test-init.sh
21
22 mkdir src
23
24 cat >> configure.ac <<'END'
25 AC_PROG_CC
26 AM_PROG_CC_C_O
27 AM_PROG_VALAC([0.7.0])
28 PKG_CHECK_MODULES([GOBJECT], [gobject-2.0 >= 2.4])
29 AC_CONFIG_FILES([src/Makefile])
30 AC_OUTPUT
31 END
32
33 cat > Makefile.am <<'END'
34 SUBDIRS = src
35 END
36
37 cat > src/Makefile.am <<'END'
38 bin_PROGRAMS = foo bar
39 foo_CFLAGS = $(GOBJECT_CFLAGS)
40 foo_LDADD = $(GOBJECT_LIBS)
41 foo_SOURCES = xfoo.vala
42 bar_SOURCES = xbar.vala
43 bar_VALAFLAGS = -D BAR
44 bar_CFLAGS = $(GOBJECT_CFLAGS)
45 bar_LDADD = $(GOBJECT_LIBS)
46 END
47
48 cat > src/xfoo.vala <<'END'
49 int main ()
50 {
51   stdout.printf ("foo\n");
52   return 0;
53 }
54 END
55
56 cat > src/xbar.vala <<'END'
57 void main ()
58 {
59 #if BAR
60   stdout.printf ("bar\n");
61 #else
62   stdout.oops_an_invalid_method ();
63 #endif
64 }
65 END
66
67 $ACLOCAL
68 $AUTOCONF
69 $AUTOMAKE -a
70
71 grep PKG_CHECK_MODULES configure && skip_ "pkg-config m4 macros not found"
72
73 ./configure
74 $MAKE
75
76 if ! cross_compiling; then
77   ./src/foo
78   ./src/bar
79   test "$(./src/foo)" = foo
80   test "$(./src/bar)" = bar
81 fi
82
83 # Test clean rules.
84
85 cp config.status config.sav
86
87 $MAKE clean
88 test -f src/xfoo.c
89 test -f src/xbar.c
90
91 $MAKE distclean
92 test -f src/xfoo.c
93 test -f src/xbar.c
94
95 # Re-create Makefile.
96 mv config.sav config.status
97 ./config.status
98
99 $MAKE maintainer-clean
100 test ! -e src/xfoo.c
101 test ! -e src/xbar.c
102
103 :