From 9e9b647843072d84f58c89c0743b97a2dd7245a4 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Wed, 7 Aug 2013 11:03:03 +0200 Subject: [PATCH 1/6] build: Port to Makefile.introspection for GIR support --- Makefile.am | 3 ++ m4/introspection.m4 | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/Makefile.am | 66 ++++++++++++++++++------------------ 3 files changed, 133 insertions(+), 32 deletions(-) create mode 100644 m4/introspection.m4 diff --git a/Makefile.am b/Makefile.am index 4f72a9a..0d84e2f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,6 +3,8 @@ NULL = SUBDIRS = src data demo po +DISTCHECK_CONFIGURE_FLAGS = --enable-introspection + INTLTOOL_FILES = \ intltool-extract.in \ intltool-merge.in \ @@ -19,6 +21,7 @@ DISTCLEANFILES = \ EXTRA_DIST = \ .version \ $(INTLTOOL_FILES) \ + m4/introspection.m4 \ $(NULL) MAINTAINERCLEANFILES = \ diff --git a/m4/introspection.m4 b/m4/introspection.m4 new file mode 100644 index 0000000..d89c3d9 --- /dev/null +++ b/m4/introspection.m4 @@ -0,0 +1,96 @@ +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 Canonicalize enable_introspection + enable_introspection=$found_introspection + ],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]) +]) diff --git a/src/Makefile.am b/src/Makefile.am index 4bc281a..d72e268 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -43,40 +43,42 @@ CLEANFILES = $(BUILT_SOURCES) pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = geoclue-2.0.pc +# D-Bus interface +EXTRA_DIST = geoclue-interface.xml + +# Introspection +-include $(INTROSPECTION_MAKEFILE) +INTROSPECTION_GIRS = +INTROSPECTION_SCANNER_ARGS = --warn-all +INTROSPECTION_COMPILER_ARGS = + if HAVE_INTROSPECTION +Geoclue-1.0.gir: libgeoclue-1.0.la +Geoclue_1_0_gir_INCLUDES = GObject-2.0 Gio-2.0 +Geoclue_1_0_gir_CFLAGS = \ + -I$(top_srcdir)/src \ + -I$(top_builddir)/src \ + $(NULL) +Geoclue_1_0_gir_PACKAGES = glib-2.0 gobject-2.0 gio-2.0 +Geoclue_1_0_gir_LIBS = libgeoclue-1.0.la +Geoclue_1_0_gir_FILES = $(libgeoclue_1_0_la_SOURCES) $(libgeoclue_1_0_la_HEADERS) +Geoclue_1_0_gir_NAMESPACE = Geoclue +Geoclue_1_0_gir_EXPORT_PACKAGES = geoclue-1.0 +Geoclue_1_0_gir_SCANNERFLAGS = \ + --nsversion=1.0 \ + --symbol-prefix=gclue \ + --identifier-prefix=GClue \ + --c-include='geoclue.h' + +INTROSPECTION_GIRS += Geoclue-1.0.gir + girdir = $(datadir)/gir-1.0 -gir_DATA = Geoclue-1.0.gir - -typelibsdir = $(libdir)/girepository-1.0 -typelibs_DATA = Geoclue-1.0.typelib - -Geoclue-1.0.gir: $(libgeoclue_1_0_la_SOURCES) $(libgeoclue_1_0_la_HEADERS) - $(INTROSPECTION_SCANNER) -v \ - --warn-all \ - --namespace Geoclue \ - --identifier-prefix=GClue \ - --symbol-prefix=gclue \ - --nsversion=1.0 \ - --include=Gio-2.0 \ - --library=geoclue-1.0 \ - --output $@ \ - --pkg=glib-2.0 \ - --pkg=gobject-2.0 \ - --pkg=gio-2.0 \ - --pkg-export=geoclue-1.0 \ - --libtool=$(top_builddir)/libtool \ - --c-include='geoclue.h' \ - -I$(top_srcdir)/src \ - -I$(top_builddir)/src \ - $^ \ - $(NULL) - -Geoclue-1.0.gir: libgeoclue-1.0.la $(INTROSPECTION_SCANNER) Makefile.am -Geoclue-1.0.typelib: Geoclue-1.0.gir $(INTROSPECTION_COMPILER) - $(INTROSPECTION_COMPILER) $< -o $@ - -CLEANFILES += $(gir_DATA) $(typelibs_DATA) -EXTRA_DIST = geoclue-interface.xml +gir_DATA = $(INTROSPECTION_GIRS) + +typelibdir = $(libdir)/girepository-1.0 +typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib) + +CLEANFILES += $(gir_DATA) $(typelib_DATA) endif # HAVE_INTROSPECTION -- 1.8.3.1