From cd7dfaf8eb2605c633c94d558ec82d05becc1db2 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Sun, 8 Jan 2012 09:47:53 +0100 Subject: [PATCH 1/6] Build introspection typelib As per https://live.gnome.org/GObjectIntrospection/AutotoolsIntegration This requires a slight reorderingof $(xklavier_headers) so that g-ir-scanner does not run into unresolved symbols. --- Makefile.am | 3 +- configure.ac | 5 ++- libxklavier/Makefile.am | 30 ++++++++++++++- m4/introspection.m4 | 94 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 128 insertions(+), 4 deletions(-) create mode 100644 m4/introspection.m4 diff --git a/Makefile.am b/Makefile.am index f687171..2a1f059 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,9 +5,10 @@ SUBDIRS = libxklavier doc tests EXTRA_DIST = libxklavier.spec libxklavier.spec.in \ autogen.sh \ CREDITS libxklavier.pc.in \ + m4/introspection.m4 \ $(config_xml_DATA) -DISTCHECK_CONFIGURE_FLAGS=--enable-gtk-doc +DISTCHECK_CONFIGURE_FLAGS=--enable-gtk-doc --enable-introspection pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libxklavier.pc diff --git a/configure.ac b/configure.ac index 5d505e8..d4c1745 100644 --- a/configure.ac +++ b/configure.ac @@ -10,7 +10,7 @@ AC_CONFIG_SRCDIR([libxklavier/xklavier.c]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_AUX_DIR([build-aux]) -AM_INIT_AUTOMAKE([1.10 dist-bzip2]) +AM_INIT_AUTOMAKE([1.10 dist-bzip2 -Wno-portability]) AM_MAINTAINER_MODE([enable]) # Support silent build rules, requires at least automake-1.11. Disable @@ -35,6 +35,9 @@ LT_INIT AM_GNU_GETTEXT([external]) AM_GNU_GETTEXT_VERSION([0.17]) +# Introspection +GOBJECT_INTROSPECTION_CHECK([1.30.0]) + m4_ifset([GTK_DOC_CHECK], [ GTK_DOC_CHECK(1.0) ], [ diff --git a/libxklavier/Makefile.am b/libxklavier/Makefile.am index 1101f9a..6c8631a 100644 --- a/libxklavier/Makefile.am +++ b/libxklavier/Makefile.am @@ -24,8 +24,8 @@ AM_CFLAGS=-Wall -DDATA_DIR=\"$(datadir)/$(PACKAGE)\" \ lib_LTLIBRARIES = libxklavier.la noinst_HEADERS = xklavier_private.h xklavier_private_xkb.h xklavier_private_xmm.h -xklavier_headers = xklavier.h xkl_config_registry.h xkl_engine.h \ - xkl_config_rec.h xkl_config_item.h xkl_engine_marshal.h +xklavier_headers = xkl_engine.h xkl_config_item.h xkl_config_registry.h \ + xkl_config_rec.h xkl_engine_marshal.h xklavier.h xklavier_built_headers = xkl-enum-types.h xklavier_built_cfiles = xkl-enum-types.c @@ -80,4 +80,30 @@ xkl-enum-types.c: $(xklavier_headers) xkl-enum-types.h && rm -f new-xkl-enum-types.c DISTCLEANFILES=$(xklavier_built_headers) $(xklavier_built_cfiles) stamp-xkl-enum-types.h +CLEANFILES= +# build intospection typelib +-include $(INTROSPECTION_MAKEFILE) +INTROSPECTION_GIRS = +INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) --warn-all +INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir) + +if HAVE_INTROSPECTION +# avoid introspecting private headers +introspection_sources = $(xklavier_headers) $(filter %.c, $(libxklavier_la_SOURCES)) + +Xkl-1.0.gir: libxklavier.la +Xkl_1_0_gir_INCLUDES = GObject-2.0 xlib-2.0 +Xkl_1_0_gir_CFLAGS = $(INCLUDES) $(X_CFLAGS) $(XML_CFLAGS) $(GLIB_CFLAGS) $(XINPUT_CFLAGS) +Xkl_1_0_gir_LIBS = libxklavier.la +Xkl_1_0_gir_FILES = $(xklavier_headers) $(introspection_sources) +INTROSPECTION_GIRS += Xkl-1.0.gir + +girdir = $(datadir)/gir-1.0 +gir_DATA = $(INTROSPECTION_GIRS) + +typelibdir = $(libdir)/girepository-1.0 +typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib) + +CLEANFILES += $(gir_DATA) $(typelib_DATA) +endif diff --git a/m4/introspection.m4 b/m4/introspection.m4 new file mode 100644 index 0000000..589721c --- /dev/null +++ b/m4/introspection.m4 @@ -0,0 +1,94 @@ +dnl -*- mode: autoconf -*- +dnl Copyright 2009 Johan Dahlin +dnl +dnl This file is free software; the author(s) gives unlimited +dnl permission to copy and/or distribute it, with or without +dnl modifications, as long as this notice is preserved. +dnl + +# serial 1 + +m4_define([_GOBJECT_INTROSPECTION_CHECK_INTERNAL], +[ + AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first + AC_BEFORE([AM_PROG_LIBTOOL],[$0])dnl setup libtool first + AC_BEFORE([LT_INIT],[$0])dnl setup libtool first + + dnl enable/disable introspection + m4_if([$2], [require], + [dnl + enable_introspection=yes + ],[dnl + AC_ARG_ENABLE(introspection, + AS_HELP_STRING([--enable-introspection[=@<:@no/auto/yes@:>@]], + [Enable introspection for this build]),, + [enable_introspection=auto]) + ])dnl + + AC_MSG_CHECKING([for gobject-introspection]) + + dnl presence/version checking + AS_CASE([$enable_introspection], + [no], [dnl + found_introspection="no (disabled, use --enable-introspection to enable)" + ],dnl + [yes],[dnl + PKG_CHECK_EXISTS([gobject-introspection-1.0],, + AC_MSG_ERROR([gobject-introspection-1.0 is not installed])) + PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], + found_introspection=yes, + AC_MSG_ERROR([You need to have gobject-introspection >= $1 installed to build AC_PACKAGE_NAME])) + ],dnl + [auto],[dnl + PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], found_introspection=yes, found_introspection=no) + ],dnl + [dnl + AC_MSG_ERROR([invalid argument passed to --enable-introspection, should be one of @<:@no/auto/yes@:>@]) + ])dnl + + AC_MSG_RESULT([$found_introspection]) + + INTROSPECTION_SCANNER= + INTROSPECTION_COMPILER= + INTROSPECTION_GENERATE= + INTROSPECTION_GIRDIR= + INTROSPECTION_TYPELIBDIR= + if test "x$found_introspection" = "xyes"; then + INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0` + INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0` + INTROSPECTION_GENERATE=`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0` + INTROSPECTION_GIRDIR=`$PKG_CONFIG --variable=girdir gobject-introspection-1.0` + INTROSPECTION_TYPELIBDIR="$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)" + INTROSPECTION_CFLAGS=`$PKG_CONFIG --cflags gobject-introspection-1.0` + INTROSPECTION_LIBS=`$PKG_CONFIG --libs gobject-introspection-1.0` + INTROSPECTION_MAKEFILE=`$PKG_CONFIG --variable=datadir gobject-introspection-1.0`/gobject-introspection-1.0/Makefile.introspection + fi + AC_SUBST(INTROSPECTION_SCANNER) + AC_SUBST(INTROSPECTION_COMPILER) + AC_SUBST(INTROSPECTION_GENERATE) + AC_SUBST(INTROSPECTION_GIRDIR) + AC_SUBST(INTROSPECTION_TYPELIBDIR) + AC_SUBST(INTROSPECTION_CFLAGS) + AC_SUBST(INTROSPECTION_LIBS) + AC_SUBST(INTROSPECTION_MAKEFILE) + + AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes") +]) + + +dnl Usage: +dnl GOBJECT_INTROSPECTION_CHECK([minimum-g-i-version]) + +AC_DEFUN([GOBJECT_INTROSPECTION_CHECK], +[ + _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1]) +]) + +dnl Usage: +dnl GOBJECT_INTROSPECTION_REQUIRE([minimum-g-i-version]) + + +AC_DEFUN([GOBJECT_INTROSPECTION_REQUIRE], +[ + _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1], [require]) +]) -- 1.7.7.3