Add build machinery for gobject-introspection data

configure.ac: Check for gobject-introspection

build/introspection.m4: Include the file that defines the
GOBJECT_CHECK_INTROSPECTION m4 macro in case we want to disable
the introspection data generation.

clutter/json/Makefile.am: Build the .gir for "ClutterJson"
  (json-glib as part of the Clutter library)

clutter/Makefile.am: Build the .gir for clutter, compile the
  Clutter and ClutterJson girs into typelibs, and install them.
  Also move GCC_FLAGS from $(INCLUDES) to $(AM_CFLAGS) since it includes
  non-preprocessor flag like -Wall.

See also:

  http://bugzilla.openedhand.com/show_bug.cgi?id=1450

Based on a patch by: Owen W. Taylor <otaylor@fishsoup.net>

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
This commit is contained in:
Emmanuele Bassi 2009-02-20 14:39:51 +00:00
parent c5afd98416
commit 21aa09748c
5 changed files with 177 additions and 1 deletions

View File

@ -2,6 +2,7 @@ NULL =
EXTRA_DIST = \
dolt.m4 \
introspection.m4 \
gtk-doc.m4 \
shave.in \
shave-libtool.in \

View File

@ -0,0 +1,88 @@
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)"
fi
AC_SUBST(INTROSPECTION_SCANNER)
AC_SUBST(INTROSPECTION_COMPILER)
AC_SUBST(INTROSPECTION_GENERATE)
AC_SUBST(INTROSPECTION_GIRDIR)
AC_SUBST(INTROSPECTION_TYPELIBDIR)
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])
])

View File

@ -32,12 +32,13 @@ INCLUDES = \
-DCLUTTER_COMPILATION=1 \
-DG_DISABLE_DEPRECATED \
-DG_LOG_DOMAIN=\"Clutter\" \
$(GCC_FLAGS) \
$(CLUTTER_CFLAGS) \
$(CLUTTER_DEBUG_CFLAGS) \
$(MAINTAINER_CFLAGS) \
$(NULL)
AM_CFLAGS=$(GCC_FLAGS)
LDADD = \
$(CLUTTER_LT_LDFLAGS) \
-export-dynamic \
@ -236,6 +237,64 @@ clutter_HEADERS = \
clutter-version.h \
clutter.h
if HAVE_INTROSPECTION
BUILT_GIRSOURCES =
if LOCAL_JSON_GLIB
json_gir_include_path=--add-include-path=json
endif
# We can't reference the list of COGL header files, since they are in a
# subdir Makefile.am, so just extract them from cogl.h instead. The doc comments
# for COGL are in the headers, so we don't need the source files.
Clutter-@CLUTTER_API_VERSION@.gir: $(INTROSPECTION_SCANNER) libclutter-@CLUTTER_FLAVOUR@-@CLUTTER_API_VERSION@.la
cogl_headers=`sed -n "s/#include <cogl\/\([^>]*\)>/cogl\/\1/p" < cogl/cogl.h` ; \
$(INTROSPECTION_SCANNER) -v --namespace Clutter --nsversion=@CLUTTER_API_VERSION@ \
$(INCLUDES) \
$(json_gir_include_path) \
--include=GL-1.0 \
--include=GObject-2.0 \
--include=Pango-1.0 \
--include=PangoCairo-1.0 \
--include=ClutterJson-@CLUTTER_API_VERSION@ \
--library=clutter-@CLUTTER_FLAVOUR@-@CLUTTER_API_VERSION@ \
--libtool="$(top_builddir)/doltlibtool" \
--pkg gobject-2.0 \
--pkg pango \
--pkg pangocairo \
--output $@ \
$(clutter_HEADERS) \
$$cogl_headers \
$(source_c)
BUILT_GIRSOURCES += Clutter-@CLUTTER_API_VERSION@.gir
if LOCAL_JSON_GLIB
# We build ClutterJson.gir in the json/ subdir, but it needs to reference the shared library
# that it's built into, so we delay compiling the gir into typelib until after we've built
# the shared library. To create the final ClutterJson.gir that we compiler and install, we
# transfer the shared-library="" line from Clutter.gir to ClutterJson.gir
ClutterJson-@CLUTTER_API_VERSION@.gir: Clutter-@CLUTTER_API_VERSION@.gir json/ClutterJson-@CLUTTER_API_VERSION@.gir
shlib=`sed -n 's/.*shared-library="\([^"]*\)".*/\1/p' < Clutter-@CLUTTER_API_VERSION@.gir` ; \
sed "s/shared-library=\"clutter-json\"/shared-library=\"$$shlib\"/"< json/ClutterJson-@CLUTTER_API_VERSION@.gir > $@
BUILT_GIRSOURCES += ClutterJson-@CLUTTER_API_VERSION@.gir
endif
# INTROSPECTION_GIRDIR/INTROSPECTION_TYPELIBDIR aren't the right place to install
# thing - we need to install inside our prefix.
girdir = $(datadir)/gir-1.0
gir_DATA = $(BUILT_GIRSOURCES)
typelibsdir = $(libdir)/girepository-1.0/
typelibs_DATA = $(BUILT_GIRSOURCES:.gir=.typelib)
%.typelib: %.gir $(INTROSPECTION_COMPILER)
$(DEBUG) $(INTROSPECTION_COMPILER) --includedir=$(srcdir) --includedir=. $(INTROSPECTION_COMPILER_OPTS) $< -o $(builddir)/$(@F)
CLEANFILES += $(BUILT_GIRSOURCES) $(typelibs_DATA)
endif
DISTCLEANFILES = \
$(ENUMFILES) \
$(MARSHALFILES) \

View File

@ -26,3 +26,27 @@ INCLUDES = \
clutterjsondir = $(includedir)/clutter-@CLUTTER_MAJORMINOR@/clutter/json
clutterjson_HEADERS = $(source_h)
noinst_DATA =
CLEANFILES =
if HAVE_INTROSPECTION
BUILT_GIRSOURCES =
ClutterJson-@CLUTTER_API_VERSION@.gir: $(INTROSPECTION_SCANNER) libclutter-json.la
$(INTROSPECTION_SCANNER) -v --namespace ClutterJson --nsversion=@CLUTTER_API_VERSION@ \
--add-include-path=$(srcdir) --add-include-path=. \
--include=GObject-2.0 \
--library=clutter-json \
--libtool="$(top_builddir)/doltlibtool" \
--pkg gobject-2.0 \
--output $@ \
$(clutterjson_HEADERS) \
$(source_c)
BUILT_GIRSOURCES += ClutterJson-@CLUTTER_API_VERSION@.gir
noinst_DATA += $(BUILT_GIRSOURCES)
CLEANFILES += $(BUILT_GIRSOURCES)
endif

View File

@ -596,6 +596,9 @@ if test "x$enable_maintainer_flags" = "xyes"; then
fi
AC_SUBST(MAINTAINER_CFLAGS)
dnl = GObject-Introspection check ==========================================
GOBJECT_INTROSPECTION_CHECK([0.6.3])
dnl = GTK Doc check ========================================================
@ -721,6 +724,7 @@ echo " Debug level: ${enable_debug}"
echo " Compiler flags: ${CPPFLAGS} ${MAINTAINER_CFLAGS}"
echo " Build API Documentation: ${enable_gtk_doc}"
echo " Build Manual Documentation: ${enable_manual}"
echo " Build Introspection data: ${enable_introspection}"
echo ""