doc: update Vala documentation
[automake.git] / t / vala-mix2.sh
blob957007621a6a7cd3088f4c8e2746c9a3498ee888
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, C and C++ sources and C and C++ headers in the same
18 # program. Functional test. See automake bug#10894.
20 required='valac cc c++ pkg-config GNUmake'
21 . test-init.sh
23 cat >> configure.ac <<'END'
24 AC_PROG_CC
25 AC_PROG_CXX
26 AM_PROG_VALAC([0.7.3])
27 PKG_CHECK_MODULES([GOBJECT], [gobject-2.0 >= 2.4])
28 AC_OUTPUT
29 END
31 cat > Makefile.am <<'END'
32 bin_PROGRAMS = zardoz
33 AM_CFLAGS = $(GOBJECT_CFLAGS)
34 zardoz_LDADD = $(GOBJECT_LIBS)
35 zardoz_SOURCES = zardoz.vala foo.h bar.c baz.c zen.hh master.cxx
36 END
38 cat > zardoz.vala <<'END'
39 int main ()
41 stdout.printf ("foo is alive\n");
42 return 0;
44 END
46 cat > foo.h <<'END'
47 extern int foo;
48 int bar (void);
49 int baz (void);
50 END
52 cat > bar.c <<'END'
53 #include "foo.h"
54 int bar (void) { return foo + baz (); }
55 END
57 cat > baz.c <<'END'
58 #include "foo.h"
59 int foo = 0;
60 int baz (void) { return 0; }
61 END
63 cat > zen.hh <<'END'
64 #include <iostream>
65 END
67 cat > master.cxx <<'END'
68 #include "zen.hh"
69 void chatty (void) { std::cout << "Hello, stranger!\n"; }
70 END
72 $ACLOCAL
73 $AUTOMAKE -a
74 $AUTOCONF
76 # Do not reject slower dependency extractors.
77 ./configure --enable-dependency-tracking
79 $MAKE all
80 ls -l # For debugging.
82 have_generated_files ()
84 test -f zardoz_vala.stamp
85 test -f zardoz.c
88 # Our vala-related rules must create stamp files and intermediate
89 # C files.
90 have_generated_files
92 # Remake rules are not uselessly triggered.
93 $MAKE -q
94 $MAKE -n | $FGREP vala.stamp && exit 1
96 # But are triggered when they should.
97 for file in zardoz.vala foo.h bar.c baz.c zen.hh master.cxx; do
98 $sleep
99 echo '& choke me !' >> $file
100 $MAKE && exit 1
101 $sleep
102 sed '$d' $file > t
103 mv -f t $file
104 $MAKE
105 done
107 # Check the distribution.
108 $MAKE distcheck
110 # Stamp files and intermediate C files should *not* be removed
111 # by "make clean".
112 $MAKE clean
113 ls -l # For debugging.
114 have_generated_files
116 # But stamp files should be removed by "maintainer-clean" (the
117 # behaviour w.r.t. intermediate C files is still unclear, and
118 # better left undefined for the moment).
119 $MAKE maintainer-clean
120 ls *vala*.stamp | grep . && exit 1