Update autotools to Vala usage

This commit is contained in:
Gergely Polonkai 2016-02-27 16:19:57 +01:00
parent de402cfa92
commit 2eb4828cdb
7 changed files with 174 additions and 22 deletions

9
.gitignore vendored
View File

@ -27,7 +27,8 @@ Makefile.in
.libs/
/stamp-h1
/gtk-doc.make
/m4/
/m4/*
!/m4/valac.m4
/GPATH
/GRTAGS
/GSYMS
@ -54,3 +55,9 @@ Makefile.in
/docs/reference/matrix-glib/matrix-glib.signals
/docs/reference/matrix-glib/matrix-glib.types
/docs/reference/matrix-glib/*.bak
# Vala related files
/src/Matrix-0.0.vapi
/src/vala-temp
/src/vala-stamp
/src/matrix-glib.h

View File

@ -83,31 +83,27 @@ AC_SUBST([LT_CURRENT], matrix_glib_lt_current)
AC_SUBST([LT_REVISION], matrix_glib_lt_revision)
AC_SUBST([LT_AGE], matrix_glib_lt_age)
AC_SUBST([MATRIX_GLIB_MAJOR_MINOR_VERSION], matrix_glib_major_minor_version)
# This is used to identify a set of API compatible between versions
# - If new versions are compatible with the actual one, just leave
# this untouched
# - If new version breaks API change it in order to allow parallel
# installations with old versions. Change name of pc files to use
# a new API, too
AC_SUBST([API_VERSION], matrix_glib_api_version)
AC_SUBST([MATRIX_GLIB_VERSION], matrix_glib_base_version)
### Dependencies
GLIB_REQUIRED=2.38.0
GLIB_REQUIRED=2.40.0
VALA_REQUIRED=0.30.0
LIBVALA_REQUIRED=0.30
GIO_REQUIRED=2.22
SOUP_REQUIRED=2.44.2
JSON_REQUIRED=0.16.2
# Check GLib
PKG_CHECK_MODULES([GLIB],
[glib-2.0 >= $GLIB_REQUIRED])
[glib-2.0 >= $GLIB_REQUIRED
gobject-2.0 >= $GLIB_REQUIRED])
# Check GObject
PKG_CHECK_MODULES([GOBJECT],
[gobject-2.0 >= $GLIB_REQUIRED])
# Check for vala
VALAC_CHECK
# Check for GIO
PKG_CHECK_MODULES([GIO], [gio-2.0 >= $GIO_REQUIRED])
# Check for libSoup
PKG_CHECK_MODULES([SOUP], [libsoup-2.4 >= $SOUP_REQUIRED])
@ -139,8 +135,14 @@ fi
AC_SUBST([MATRIX_GLIB_MAJOR_VERSION], matrix_glib_major_version)
AC_SUBST([MATRIX_GLIB_MINOR_VERSION], matrix_glib_minor_version)
AC_SUBST([MATRIX_GLIB_MICRO_VERSION], matrix_glib_micro_version)
# This is used to identify a set of API compatible between versions
# - If new versions are compatible with the actual one, just leave
# this untouched
# - If new version breaks API change it in order to allow parallel
# installations with old versions. Change name of pc files to use
# a new API, too
AC_SUBST([MATRIX_GLIB_API_VERSION], matrix_glib_api_version)
AC_SUBST([MATRIX_GLIB_API_VERSION_U], [AS_TR_SH(matrix_glib_api_version)])
m4_ifdef([GTK_DOC_CHECK], [
GTK_DOC_CHECK([1.20], [--flavour no-tmpl])
@ -151,9 +153,6 @@ AM_CONDITIONAL([ENABLE_GTK_DOC], false)
AC_PATH_PROG([GLIB_MKENUMS], [glib-mkenums])
AC_PATH_PROG([GLIB_GENMARSHAL], [glib-genmarshal])
LIBMATRIX_GLIB_LIBS='$(top_builddir)/src/libmatrix-glib-$(MATRIX_GLIB_API_VERSION).la'
AC_SUBST(LIBMATRIX_GLIB_LIBS)
AC_CONFIG_FILES([
Makefile
src/Makefile

View File

@ -79,7 +79,9 @@ expand_content_files=
# e.g. GTKDOC_CFLAGS=-I$(top_srcdir) -I$(top_builddir) $(GTK_DEBUG_FLAGS)
# e.g. GTKDOC_LIBS=$(top_builddir)/gtk/$(gtktargetlib)
GTKDOC_CFLAGS=
GTKDOC_LIBS=$(LIBMATRIX_GLIB_LIBS) $(NULL)
GTKDOC_LIBS = \
$(top_builddir)/src/libmatrix-glib-$(MATRIX_GLIB_API_VERSION).la \
$(NULL)
# This includes the standard gtk-doc make rules, copied by gtkdocize.
include $(top_srcdir)/gtk-doc.make

76
m4/valac.m4 Normal file
View File

@ -0,0 +1,76 @@
dnl vapigen.m4
dnl
dnl Copyright 2014 Daniel Espinosa
dnl
dnl This library is free software; you can redistribute it and/or
dnl modify it under the terms of the GNU Lesser General Public
dnl License as published by the Free Software Foundation; either
dnl version 2.1 of the License, or (at your option) any later version.
dnl
dnl This library is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
dnl Lesser General Public License for more details.
dnl
dnl You should have received a copy of the GNU Lesser General Public
dnl License along with this library; if not, write to the Free Software
dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
# VALAC_CHECK([VERSION], [API_VERSION])
# --------------------------------------
# Check valac existence and version.
m4_define([_VALAC_CHECK_INTERNAL],
[
AC_REQUIRE([PKG_PROG_PKG_CONFIG])
AS_IF([ test "x$2" = "x" ], [
AM_PROG_VALAC($1)
AS_IF([ test "x$VALAC" = "xno"], [
check_prog=no
AC_MSG_ERROR([valac is not installed])
], [
check_prog=yes
VALAC_VERSION=`$VALAC --api-version`
VAPIDIR=$datadir/vala-$VALAC_VERSION/vapi
VAPIDIR_UNVERSIONED=$datadir/vala-$VALAC_VERSION/vapi
])
], [
AS_IF([ test "x$1" = "x"], [
vala_pkg="libvala-$2"
], [
vala_pkg="libvala-$2 >= $1"
])
AC_MSG_CHECKING([for $vala_pkg])
PKG_CHECK_EXISTS([ $vala_pkg ], [
vala_pkg_found=yes
VAPIGEN=`$PKG_CONFIG --variable=vapigen libvala-$2`
VAPIGEN_MAKEFILE=`$PKG_CONFIG --variable=datadir libvala-$2`/vala/Makefile.vapigen
VAPIDIR=`$PKG_CONFIG --variable=vapidir libvala-$2`
GEN_INTROSPECT=`$PKG_CONFIG --variable=gen_introspect libvala-$2`
vala_datadir=`$PKG_CONFIG --variable=datadir libvala-$2`
VAPIDIR_UNVERSIONED=$vala_datadir/vala/vapi
VALA_GEN_INTROSPECT=`$PKG_CONFIG --variable=vala_gen_introspect libvala-$2`
], [
vala_pkg_found=no
AC_MSG_ERROR([no package libvala-$2 is installed])
])
AC_MSG_RESULT([$vala_pkg_found])
])
AC_SUBST([VAPIGEN])
AC_SUBST([VAPIGEN_VAPIDIR])
AC_SUBST([VAPIDIR])
AC_SUBST([VAPIDIR_UNVERSIONED])
AC_SUBST([VAPIGEN_MAKEFILE])
AC_SUBST([GEN_INTROSPECT])
AC_SUBST([VALA_GEN_INTROSPECT])
AC_SUBST([VALAC_VERSION])
])
dnl Check VAPIGEN
# VALAC_CHECK([VERSION], [API_VERSION], [DEFAULT])
# --------------------------------------
# Check vapigen existence and version.
AC_DEFUN([VALAC_CHECK],
[
_VALAC_CHECK_INTERNAL($1,$2,$3)
]
)

View File

@ -1,13 +1,69 @@
include $(top_srcdir)/vala-globals.mk
AM_CPPFLAGS = -DG_LOG_DOMAIN=\"Matrix-GLib\"
# Empty variables for elements to be added later
CLEANFILES =
BUILT_SOURCES =
EXTRA_DIST =
AM_VALAFLAGS =
# Name of the public header file
PUBLIC_HEADER = matrix-glib.h
# Libraries to create
lib_LTLIBRARIES = libmatrix-glib-0.0.la
# Vala source files
libmatrix_glib_0_0_la_VALA_SOURCES = \
$(NULL)
AM_CPPFLAGS += \
-include $(CONFIG_HEADER) \
-I$(top_srcdir) \
-g \
-Wall \
$(GLIB_CFLAGS) \
$(GOBJECT_CFLAGS) \
$(SOUP_CFLAGS) \
$(JSON_CFLAGS) \
$(VALA_CFLAGS) \
$(NULL)
AM_VALAFLAGS += \
--library=Matrix-$(MATRIX_GLIB_API_VERSION) \
$(VALA_PKG_LIST) \
--vapi=Matrix-$(MATRIX_GLIB_API_VERSION).vapi \
-H $(PUBLIC_HEADER) \
-C \
--use-header \
--gir=Matrix-$(MATRIX_GLIB_API_VERSION).gir \
$(NULL)
vala-stamp: $(libmatrix_glib_0_0_la_VALA_SOURCES)
@rm -f vala-temp
@touch vala-temp
$(AM_V_GEN) $(VALAC) $(AM_VALAFLAGS) $^
@mv -f vala-temp $@
CLEANFILES += \
$(PUBLIC_HEADER) \
$(libmatrix_glib_0_0_la_VALA_SOURCES:.vala=.c) \
$(NULL)
$(libmatrix_glib_0_0_la_VALA_SOURCES:.vala=.c): vala-stamp
@if test -f $@; then :; else \
trap 'rm -rf vala-lock vala-stamp' 1 2 13 15; \
if mkdir vala-lock 2> /dev/null; then \
rm -f vala-stamp; \
$(MAKE) $(AM_MAKEFLAGS) vala-stamp; \
rmdir vala-lock; \
else \
while test -d vala-lock; do sleep 1; done; \
test -f vala-stamp; exit $$?; \
fi \
fi
# Binaries to create
bin_PROGRAMS = test-api-client
@ -32,6 +88,7 @@ matrix_enum_headers = \
libmatrix_glib_0_0_la_SOURCES = \
$(INST_H_BUILT_FILES) \
matrix-marshalers.c \
$(libmatrix_glib_0_0_la_VALA_SOURCES:.vala=.c) \
matrix-version.c \
matrix-types.c \
matrix-api.c \
@ -60,6 +117,8 @@ libmatrix_glib_0_0_la_LIBADD = \
libmatrix_glib_0_0_la_LDFLAGS = \
-version-info "$(LT_CURRENT)":"$(LT_REVISION)":"$(LT_AGE)"
$(PUBLIC_HEADER): vala-stamp
BUILT_SOURCES += \
matrix-enumtypes.c \
matrix-enumtypes.h \
@ -68,7 +127,7 @@ BUILT_SOURCES += \
$(NULL)
test_api_client_SOURCES = test-api-client.c
test_api_client_CFLAGS = $(libmatrix_glib_0_0_la_CFLAGS)
test_api_client_CFLAGS = $(libmatrix_glib_0_0_la_CFLAGS) $(AM_CFLAGS)
test_api_client_LDADD = \
$(libmatrix_glib_0_0_la_LIBADD) \
libmatrix-glib-$(MATRIX_GLIB_API_VERSION).la \
@ -152,6 +211,7 @@ typelibs_DATA = Matrix-$(MATRIX_GLIB_API_VERSION).typelib
headerdir = $(includedir)/matrix-glib-$(MATRIX_GLIB_API_VERSION)
header_DATA = \
$(PUBLIC_HEADER) \
$(INST_H_SRC_FILES) \
$(INST_H_BUILT_FILES) \
$(NULL)

3
src/Matrix-0.0.deps Normal file
View File

@ -0,0 +1,3 @@
gio-2.0
Json-1.0
libsoup-2.4

5
vala-globals.mk Normal file
View File

@ -0,0 +1,5 @@
VALA_PKG_LIST = \
--pkg=gio-2.0 \
--pkg=Json-1.0 \
--pkg=libsoup-2.4 \
$(NULL)