f325b2
From 839e15f8019b8eb4b4986367aef5c77c58ed3412 Mon Sep 17 00:00:00 2001
f325b2
From: Pranav Kant <pranavk@gnome.org>
f325b2
Date: Sat, 15 Aug 2015 18:48:53 +0530
f325b2
Subject: [PATCH 110/398] create_tree.sh: Generate g-i files
f325b2
f325b2
Change-Id: I1749b5b02018cfe6f85a13aed8de4b31a09788e3
f325b2
Reviewed-on: https://gerrit.libreoffice.org/18494
f325b2
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
f325b2
Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
f325b2
(cherry picked from commit 8f2aace934eb2a91a273b6104de6383108b5c82a)
f325b2
---
f325b2
 configure.ac                       |  6 +++
f325b2
 m4/introspection.m4                | 94 ++++++++++++++++++++++++++++++++++++++
f325b2
 sysui/desktop/share/create_tree.sh | 13 ++++++
f325b2
 3 files changed, 113 insertions(+)
f325b2
 create mode 100644 m4/introspection.m4
f325b2
f325b2
diff --git a/configure.ac b/configure.ac
f325b2
index 4e27231f6a5f..b1ec23a5afa3 100644
f325b2
--- a/configure.ac
f325b2
+++ b/configure.ac
f325b2
@@ -181,6 +181,11 @@ SRC_ROOT=`pwd`
f325b2
 cd $BUILDDIR
f325b2
 x_Cygwin=[\#]
f325b2
 
f325b2
+dnl ======================================
f325b2
+dnl Required GObject introspection version
f325b2
+dnl ======================================
f325b2
+INTROSPECTION_REQUIRED_VERSION=1.32.0
f325b2
+
f325b2
 dnl ===================================================================
f325b2
 dnl Search all the common names for GNU Make
f325b2
 dnl ===================================================================
f325b2
@@ -9903,6 +9908,7 @@ if test "x$enable_gtk3" = "xyes"; then
f325b2
     PKG_CHECK_MODULES(GTK3, gtk+-3.0 >= 3.8 gtk+-unix-print-3.0 gmodule-no-export-2.0 glib-2.0 >= 2.38 cairo, ENABLE_GTK3="TRUE", ENABLE_GTK3="")
f325b2
     if test "x$ENABLE_GTK3" = "xTRUE"; then
f325b2
         R="gtk3"
f325b2
+        GOBJECT_INTROSPECTION_CHECK(INTROSPECTION_REQUIRED_VERSION)
f325b2
     else
f325b2
         AC_MSG_ERROR([gtk3 or dependent libraries of the correct versions, not found])
f325b2
     fi
f325b2
diff --git a/m4/introspection.m4 b/m4/introspection.m4
f325b2
new file mode 100644
f325b2
index 000000000000..532bad82addf
f325b2
--- /dev/null
f325b2
+++ b/m4/introspection.m4
f325b2
@@ -0,0 +1,94 @@
f325b2
+dnl -*- mode: autoconf -*-
f325b2
+dnl Copyright 2009 Johan Dahlin
f325b2
+dnl
f325b2
+dnl This file is free software; the author(s) gives unlimited
f325b2
+dnl permission to copy and/or distribute it, with or without
f325b2
+dnl modifications, as long as this notice is preserved.
f325b2
+dnl
f325b2
+
f325b2
+# serial 1
f325b2
+
f325b2
+m4_define([_GOBJECT_INTROSPECTION_CHECK_INTERNAL],
f325b2
+[
f325b2
+    AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first
f325b2
+    AC_BEFORE([AM_PROG_LIBTOOL],[$0])dnl setup libtool first
f325b2
+    AC_BEFORE([LT_INIT],[$0])dnl setup libtool first
f325b2
+
f325b2
+    dnl enable/disable introspection
f325b2
+    m4_if([$2], [require],
f325b2
+    [dnl
f325b2
+        enable_introspection=yes
f325b2
+    ],[dnl
f325b2
+        AC_ARG_ENABLE(introspection,
f325b2
+                  AS_HELP_STRING([--enable-introspection[=@<:@no/auto/yes@:>@]],
f325b2
+                                 [Enable introspection for this build]),,
f325b2
+                                 [enable_introspection=auto])
f325b2
+    ])dnl
f325b2
+
f325b2
+    AC_MSG_CHECKING([for gobject-introspection])
f325b2
+
f325b2
+    dnl presence/version checking
f325b2
+    AS_CASE([$enable_introspection],
f325b2
+    [no], [dnl
f325b2
+        found_introspection="no (disabled, use --enable-introspection to enable)"
f325b2
+    ],dnl
f325b2
+    [yes],[dnl
f325b2
+        PKG_CHECK_EXISTS([gobject-introspection-1.0],,
f325b2
+                         AC_MSG_ERROR([gobject-introspection-1.0 is not installed]))
f325b2
+        PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1],
f325b2
+                         found_introspection=yes,
f325b2
+                         AC_MSG_ERROR([You need to have gobject-introspection >= $1 installed to build AC_PACKAGE_NAME]))
f325b2
+    ],dnl
f325b2
+    [auto],[dnl
f325b2
+        PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], found_introspection=yes, found_introspection=no)
f325b2
+	dnl Canonicalize enable_introspection
f325b2
+	enable_introspection=$found_introspection
f325b2
+    ],dnl
f325b2
+    [dnl
f325b2
+        AC_MSG_ERROR([invalid argument passed to --enable-introspection, should be one of @<:@no/auto/yes@:>@])
f325b2
+    ])dnl
f325b2
+
f325b2
+    AC_MSG_RESULT([$found_introspection])
f325b2
+
f325b2
+    INTROSPECTION_SCANNER=
f325b2
+    INTROSPECTION_COMPILER=
f325b2
+    INTROSPECTION_GENERATE=
f325b2
+    INTROSPECTION_GIRDIR=
f325b2
+    INTROSPECTION_TYPELIBDIR=
f325b2
+    if test "x$found_introspection" = "xyes"; then
f325b2
+       INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0`
f325b2
+       INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0`
f325b2
+       INTROSPECTION_GENERATE=`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0`
f325b2
+       INTROSPECTION_GIRDIR=`$PKG_CONFIG --variable=girdir gobject-introspection-1.0`
f325b2
+       INTROSPECTION_TYPELIBDIR="$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)"
f325b2
+       INTROSPECTION_CFLAGS=`$PKG_CONFIG --cflags gobject-introspection-1.0`
f325b2
+       INTROSPECTION_LIBS=`$PKG_CONFIG --libs gobject-introspection-1.0`
f325b2
+       INTROSPECTION_MAKEFILE=`$PKG_CONFIG --variable=datadir gobject-introspection-1.0`/gobject-introspection-1.0/Makefile.introspection
f325b2
+    fi
f325b2
+    AC_SUBST(INTROSPECTION_SCANNER)
f325b2
+    AC_SUBST(INTROSPECTION_COMPILER)
f325b2
+    AC_SUBST(INTROSPECTION_GENERATE)
f325b2
+    AC_SUBST(INTROSPECTION_GIRDIR)
f325b2
+    AC_SUBST(INTROSPECTION_TYPELIBDIR)
f325b2
+    AC_SUBST(INTROSPECTION_CFLAGS)
f325b2
+    AC_SUBST(INTROSPECTION_LIBS)
f325b2
+    AC_SUBST(INTROSPECTION_MAKEFILE)
f325b2
+])
f325b2
+
f325b2
+
f325b2
+dnl Usage:
f325b2
+dnl   GOBJECT_INTROSPECTION_CHECK([minimum-g-i-version])
f325b2
+
f325b2
+AC_DEFUN([GOBJECT_INTROSPECTION_CHECK],
f325b2
+[
f325b2
+  _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1])
f325b2
+])
f325b2
+
f325b2
+dnl Usage:
f325b2
+dnl   GOBJECT_INTROSPECTION_REQUIRE([minimum-g-i-version])
f325b2
+
f325b2
+
f325b2
+AC_DEFUN([GOBJECT_INTROSPECTION_REQUIRE],
f325b2
+[
f325b2
+  _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1], [require])
f325b2
+])
f325b2
diff --git a/sysui/desktop/share/create_tree.sh b/sysui/desktop/share/create_tree.sh
f325b2
index c6be0bb2a688..45b7c6cb09db 100755
f325b2
--- a/sysui/desktop/share/create_tree.sh
f325b2
+++ b/sysui/desktop/share/create_tree.sh
f325b2
@@ -87,3 +87,16 @@ for i in base calc draw impress writer; do
f325b2
     cp "${APPDATA_SOURCE_DIR}/libreoffice-${i}.appdata.xml" "${DESTDIR}/${PREFIXDIR}/share/appdata/${PREFIX}-${i}.appdata.xml"
f325b2
 done
f325b2
 
f325b2
+# Generate gobject-introspection files
f325b2
+mkdir -p "${DESTDIR}/${PREFIXDIR}/share/gir-1.0"
f325b2
+g-ir-scanner "${SRCDIR}/include/LibreOfficeKit/LibreOfficeKitGtk.h" "${SRCDIR}/libreofficekit/source/gtk/lokdocview.cxx" \
f325b2
+             `${PKG_CONFIG} --cflags gobject-introspection-1.0 gtk+-3.0` -I"${SRCDIR}/include/" \
f325b2
+             --include=GLib-2.0 --include=GObject-2.0 --include=Gio-2.0 \
f325b2
+             --library=libreofficekitgtk --library-path="${DESTDIR}/${INSTALLDIR}/program" \
f325b2
+             --include=Gdk-3.0 --include=GdkPixbuf-2.0 --include=Gtk-3.0 \
f325b2
+             --namespace=LOKDocView --nsversion=0.1 --identifier-prefix=LOKDoc --symbol-prefix=lok_doc \
f325b2
+             --output="${DESTDIR}/${PREFIXDIR}/share/gir-1.0/LOKDocView-0.1.gir" --warn-all --no-libtool
f325b2
+
f325b2
+mkdir -p "${DESTDIR}/${LIBDIR}/girepository-1.0"
f325b2
+g-ir-compiler "${DESTDIR}/${PREFIXDIR}/share/gir-1.0/LOKDocView-0.1.gir" \
f325b2
+              --output="${DESTDIR}/${LIBDIR}/girepository-1.0/LOKDocView-0.1.typelib"
f325b2
-- 
f325b2
2.12.0
f325b2