[devhelp/wip/tintou/gobject-introspection] Add support for GObject Introspection macros



commit 72ae8f2ba8d6c9477e5b66443e4c66a853570bf1
Author: Corentin Noël <corentin elementary io>
Date:   Sun Oct 30 02:44:23 2016 +0100

    Add support for GObject Introspection macros
    
    https://bugzilla.gnome.org/show_bug.cgi?id=770785

 Makefile.am         |    3 +-
 configure.ac        |    2 +
 m4/introspection.m4 |   96 +++++++++++++++++++++++++++++++++++++++++++++++++++
 src/Makefile.am     |   45 ++++++++++++++++++++++++
 src/dh-settings.h   |    2 +-
 5 files changed, 146 insertions(+), 2 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 414b36d..20554a4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,8 +1,9 @@
 ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
+DISTCHECK_CONFIGURE_FLAGS = --enable-introspection
 
 SUBDIRS = po src data misc contrib docs
 
-EXTRA_DIST = autogen.sh
+EXTRA_DIST = autogen.sh m4/introspection.m4
 
 DISTCLEANFILES = intltool-extract  \
                 intltool-merge    \
diff --git a/configure.ac b/configure.ac
index 36540da..5ef94dd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -42,6 +42,8 @@ GLIB_GSETTINGS
 
 PKG_PROG_PKG_CONFIG
 
+GOBJECT_INTROSPECTION_CHECK([1.30.0])
+
 GNOME_COMPILE_WARNINGS([maximum])
 
 AC_CHECK_LIBM
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 dbe1eca..c1ef6a1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -114,3 +114,48 @@ dh-enum-types.c: dh-enum-types.c.template $(INST_H_FILES) $(GLIB_MKENUMS)
        $(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template dh-enum-types.c.template $(INST_H_FILES)) > $@
 
 DISTCLEANFILES = $(BUILT_SOURCES)
+
+-include $(INTROSPECTION_MAKEFILE)
+INTROSPECTION_GIRS =
+INTROSPECTION_SCANNER_ARGS = \
+       --add-include-path=$(srcdir) \
+       --warn-all \
+       --identifier-prefix Dh \
+       --identifier-prefix dh \
+       --pkg-export libdevhelp-3.0 \
+       --c-include="devhelp/devhelp.h"
+
+INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir)
+
+if HAVE_INTROSPECTION
+introspection_sources = \
+       dh-app.c                                        \
+       dh-assistant.c                                  \
+       dh-assistant-view.c                             \
+       dh-book.c                                       \
+       dh-book-manager.c                               \
+       dh-book-tree.c                                  \
+       dh-common.c                                     \
+       dh-error.c                                      \
+       dh-keyword-model.c                              \
+       dh-language.c                                   \
+       dh-link.c                                       \
+       dh-sidebar.c                                    \
+       dh-window.c \
+       ${INST_H_FILES}
+
+Devhelp-3.0.gir: libdevhelp-3.la
+Devhelp_3_0_gir_INCLUDES = Gtk-3.0 WebKit2-4.0
+Devhelp_3_0_gir_CFLAGS = $(INCLUDES)
+Devhelp_3_0_gir_LIBS = libdevhelp-3.la
+Devhelp_3_0_gir_FILES = $(introspection_sources)
+INTROSPECTION_GIRS += Devhelp-3.0.gir
+
+girdir = $(datadir)/gir-1.0
+gir_DATA = $(INTROSPECTION_GIRS)
+
+typelibdir = $(libdir)/girepository-1.0
+typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
+
+DISTCLEANFILES += $(gir_DATA) $(typelib_DATA)
+endif
diff --git a/src/dh-settings.h b/src/dh-settings.h
index bf8e8df..a8fa33d 100644
--- a/src/dh-settings.h
+++ b/src/dh-settings.h
@@ -56,7 +56,7 @@ struct _DhSettingsClass{
                                const gchar *font_name_variable);
 } ;
 
-GType dh_settings_get_type (void) G_GNUC_CONST;;
+GType dh_settings_get_type (void) G_GNUC_CONST;
 
 DhSettings * dh_settings_get (void);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]