summaryrefslogtreecommitdiff
path: root/t/vala-libs-distcheck.sh
blob: 8066ca5fd7e9f2b098eb1ce861db30e2fe8d4e3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#! /bin/sh
# Copyright (C) 2012-2023 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Building libraries (libtool and static) from Vala sources.
# And use of vapi files to call C code from Vala.

required="valac cc pkg-config libtoolize GNUmake"
am_create_testdir=empty
. test-init.sh

cat >> configure.ac << 'END'
AC_INIT([atest],[0.1])
AC_CONFIG_SRCDIR([data/atest.pc.in])
AC_SUBST([API_VERSION],[0])

AM_INIT_AUTOMAKE
AM_MAINTAINER_MODE([enable])
AM_PROG_AR
LT_INIT

AC_PROG_CC
AC_PROG_INSTALL
PKG_PROG_PKG_CONFIG([0.22])
AM_PROG_VALAC([0.32])

PKG_CHECK_MODULES(ATEST, [gio-2.0])

AC_CONFIG_FILES([
	Makefile

	src/Makefile

	src/atest-$API_VERSION.deps:src/atest.deps.in

	data/Makefile
	data/atest-$API_VERSION.pc:data/atest.pc.in

],[],
[API_VERSION='$API_VERSION'])
AC_OUTPUT
END


cat > Makefile.am << 'END'
SUBDIRS=data src
END

mkdir data

cat > data/atest.pc.in << 'END'
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
datarootdir=@datarootdir@
datadir=@datadir@
includedir=@includedir@

Name: atest-@API_VERSION@
Description: atest library
Version: @VERSION@
Requires: glib-2.0 gobject-2.0
Libs: -L${libdir} -latest-@API_VERSION@
Cflags: -I${includedir}/atest-@API_VERSION@
END


cat > data/Makefile.am << 'END'
# pkg-config data
# Note that the template file is called atest.pc.in, but generates a
# versioned .pc file using some magic in AC_CONFIG_FILES.
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = atest-$(API_VERSION).pc

DISTCLEANFILES = $(pkgconfig_DATA)
EXTRA_DIST = atest.pc.in
END

mkdir src

cat > src/atest.deps.in << 'END'
glib-2.0
END


cat > src/atest.vala << 'END'
using GLib;

namespace Atest {
	public class A {
		public bool foo() { return false; }
	}
}
END

cat > src/Makefile.am << 'END'
lib_LTLIBRARIES = libatest-@API_VERSION@.la

libatest_@API_VERSION@_la_SOURCES = \
	atest.vala \
	cservice.c \
	cservice.h \
	$(NULL)


libatest_@API_VERSION@_la_CPPFLAGS = \
	-DOKOKIMDEFINED=1 \
	$(NULL)

libatest_@API_VERSION@_la_CFLAGS = \
	$(ATEST_CFLAGS) \
	$(WARN_CFLAGS) \
	$(NULL)

libatest_@API_VERSION@_la_LIBADD = \
	$(ATEST_LIBS) \
	$(NULL)

libatest_@API_VERSION@_la_LDFLAGS = \
	$(WARN_LDFLAGS) \
	$(NULL)

libatest_@API_VERSION@_la_VALAFLAGS = \
	--vapidir=$(VAPIDIR) \
	--vapidir=$(srcdir) \
	--pkg cservice \
	--thread \
	--target-glib=2.44 \
	--pkg glib-2.0 \
	-H atest.h \
	--library atest-@API_VERSION@ \
	$(NULL)

header_DATA=atest.h
headerdir=$(includedir)/atest-@API_VERSION@/atest

atest-@API_VERSION@.deps:
	cp atest.deps atest-@API_VERSION@.deps

vapi_DATA=atest-@API_VERSION@.vapi atest-@API_VERSION@.deps
vapidir=$(VAPIDIR)

CLEANFILES = atest-@API_VERSION@.deps
END


cat > src/cservice.c << 'END'
#include "cservice.h"
int c_service_mu_call (void)
{
  return OKOKIMDEFINED;
}
END

cat > src/cservice.h << 'END'
int c_service_mu (void);
END

cat > src/cservice.vapi <<'END'
namespace CService {
  public class Mu {
    [CCode (cheader_filename = "cservice.h", cname = "c_service_mu_call")]
    public int call ();
  }
}
END

libtoolize
$ACLOCAL
$AUTOCONF
$AUTOMAKE -a

./configure

$MAKE
test -f src/libatest_0_la_vala.stamp
test -f src/libatest-0.la

$MAKE distcheck

: