test: protect more yacc declarations against C vs. C++ linkage.
[automake.git] / t / vala-mix.sh
bloba57101dc25984ecb117fc8fd1ff14a3a4407fd34
1 #! /bin/sh
2 # Copyright (C) 2012-2024 Free Software Foundation, Inc.
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.
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.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
17 # Vala sources and C sources in the same program. Functional test.
19 required='valac cc pkg-config GNUmake'
20 . test-init.sh
22 cat >> configure.ac <<'END'
23 AC_PROG_CC
24 AM_PROG_VALAC([0.7.3])
25 PKG_CHECK_MODULES([GOBJECT], [gobject-2.0 >= 2.4])
26 AC_OUTPUT
27 END
29 cat > Makefile.am <<'END'
30 bin_PROGRAMS = zardoz mu baz
31 AM_CFLAGS = $(GOBJECT_CFLAGS)
32 LDADD = $(GOBJECT_LIBS)
33 zardoz_SOURCES = foo.vala bar.c
34 mu_SOURCES = 1.vala 2.c
35 mu_VALAFLAGS = --main=run
36 mu_CFLAGS = -DHAVE_MU $(AM_CFLAGS)
37 baz_SOURCES = baz.c
38 END
40 if ! cross_compiling; then
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
50 cat > foo.vala <<'END'
51 int main ()
53 stdout.printf ("foo is alive\n");
54 return 0;
56 END
58 echo 'extern int i = 0;' > bar.c
60 cat > 1.vala <<'END'
61 int run ()
63 stdout.printf ("Howdy, World!\n");
64 return 0;
66 END
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
77 # For automake bug#11229.
78 cat > baz.c <<'END'
79 int main (void)
81 return 0;
83 END
85 $ACLOCAL
86 $AUTOMAKE -a
87 $AUTOCONF
89 ./configure
91 $MAKE all
92 ls -l # For debugging.
93 $MAKE check
95 have_generated_files ()
97 test -f mu_vala.stamp
98 test -f zardoz_vala.stamp
99 test -f foo.c
100 test -f 1.c
103 # Our vala-related rules must create stamp files and intermediate
104 # C files.
105 have_generated_files
107 # Remake rules are not uselessly triggered.
108 $MAKE -q
109 $MAKE -n | $FGREP vala.stamp && exit 1
111 # Check the distribution.
112 $MAKE distcheck
114 # Stamp files and intermediate C files should *not* be removed
115 # by "make clean".
116 $MAKE clean
117 have_generated_files
119 # But stamp files should be removed by "maintainer-clean" (the
120 # behaviour w.r.t. intermediate C files is still unclear, and
121 # better left undefined for the moment).
122 $MAKE maintainer-clean
123 ls *vala*.stamp | grep . && exit 1