From f7ca244a677b777dcd5fc67990125232c5909616 Mon Sep 17 00:00:00 2001 From: Olivier Duchateau Date: Fri, 15 Feb 2019 18:45:55 +0100 Subject: [PATCH] GObject introspection support --- Makefile.am | 6 ++- configure.ac.in | 16 ++++--- garcon-gtk/Makefile.am | 38 +++++++++++++++++ garcon/Makefile.am | 34 +++++++++++++++ m4/introspection.m4 | 96 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 183 insertions(+), 7 deletions(-) create mode 100644 m4/introspection.m4 diff --git a/Makefile.am b/Makefile.am index 8f1d2cd..97e1516 100644 --- a/Makefile.am +++ b/Makefile.am @@ -52,7 +52,8 @@ EXTRA_DIST = \ STATUS \ intltool-extract.in \ intltool-merge.in \ - intltool-update.in + intltool-update.in \ + m4/introspection.m4 DISTCLEANFILES = \ intltool-extract \ @@ -60,4 +61,5 @@ DISTCLEANFILES = \ intltool-update DISTCHECK_CONFIGURE_FLAGS = \ - --enable-gtk-doc + --enable-gtk-doc \ + --enable-introspection diff --git a/configure.ac.in b/configure.ac.in index 281a91f..e448d01 100644 --- a/configure.ac.in +++ b/configure.ac.in @@ -38,7 +38,7 @@ m4_define([garcon_debug_default], [ifelse(garcon_version_tag(), [git], [yes], [m dnl **************************** dnl *** For intltool support *** dnl **************************** -m4_define([intltool_minimum_version], [0.35]) +m4_define([intltool_minimum_version], [0.51]) dnl *************************** dnl *** Initialize autoconf *** @@ -47,7 +47,7 @@ AC_COPYRIGHT([Copyright (c) 2007-2011 Jannis Pohlmann Copyright (c) 2012-2018 The Xfce development team ]) AC_INIT([garcon], [garcon_version], [https://bugzilla.xfce.org/]) -AC_PREREQ([2.50]) +AC_PREREQ([2.69]) AC_CONFIG_MACRO_DIRS([m4]) AC_REVISION([@REVISION@]) AC_CANONICAL_TARGET() @@ -55,7 +55,7 @@ AC_CANONICAL_TARGET() dnl *************************** dnl *** Initialize automake *** dnl *************************** -AM_INIT_AUTOMAKE([1.8 dist-bzip2 tar-ustar no-dist-gzip]) +AM_INIT_AUTOMAKE([1.16 dist-bzip2 tar-ustar no-dist-gzip]) AC_CONFIG_HEADERS([config.h]) AM_MAINTAINER_MODE() m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) @@ -91,7 +91,7 @@ dnl ******************************** AM_PROG_AS() AC_PROG_CC() AC_PROG_INSTALL() -IT_PROG_INTLTOOL([intltool_minimum_version], [no-xml]) +IT_PROG_INTLTOOL([intltool_minimum_version]) AM_PROG_CC_C_O() dnl ************************** @@ -146,6 +146,11 @@ dnl *** Check for gtk-doc *** dnl ************************* GTK_DOC_CHECK([1.0]) +dnl *************************************** +dnl *** Check for GObject Introspection *** +dnl *************************************** +GOBJECT_INTROSPECTION_CHECK([1.50.0]) + dnl *********************************** dnl *** Check for debugging support *** dnl *********************************** @@ -179,10 +184,11 @@ dnl *************************** echo echo "Build Configuration:" echo -echo "* Debug Support: $enable_debug" +echo "* Debug support: $enable_debug" if test x"$GTK2_FOUND" = x"yes" -a x"$LIBXFCE4UI_FOUND" = x"yes"; then echo "* GTK2 support: yes" else echo "* GTK2 support: no" fi +echo "* GObject Introspection support: $enable_introspection" echo diff --git a/garcon-gtk/Makefile.am b/garcon-gtk/Makefile.am index 1096e51..b6d2d13 100644 --- a/garcon-gtk/Makefile.am +++ b/garcon-gtk/Makefile.am @@ -134,3 +134,41 @@ endif # Required for gtk-doc and make distcheck dist-hook: all + +-include $(INTROSPECTION_MAKEFILE) +INTROSPECTION_GIRS = +INTROSPECTION_SCANNER_ENV = CC="$(CC)" +INTROSPECTION_SCANNER_ARGS = \ + --add-include-path=$(srcdir) \ + --add-include-path=$(top_buildir)/garcon \ + --include-uninstalled=$(top_builddir)/garcon/Garcon-1.0.gir \ + --warn-all \ + -DGARCON_COMPILATION \ + --c-include=garcon-gtk/garcon-gtk.h +INTROSPECTION_COMPILER_ARGS = \ + --includedir=$(srcdir) \ + --includedir=. \ + --includedir=../garcon + +if HAVE_INTROSPECTION +introspection_sources = $(libgarcon_gtk3_1_la_SOURCES) + +GarconGtk-1.0.gir: libgarcon-gtk3-1.la \ + $(top_builddir)/garcon/Garcon-1.0.gir Makefile +GarconGtk_1_0_gir_INCLUDES = GObject-2.0 GLib-2.0 Gio-2.0 \ + Gtk-3.0 libxfce4util-1.0 libxfce4ui-2.0 +GarconGtk_1_0_gir_CFLAGS = $(AM_CPPFLAGS) +GarconGtk_1_0_gir_LIBS = libgarcon-gtk3-1.la \ + $(top_builddir)/garcon/libgarcon-1.la +GarconGtk_1_0_gir_FILES = $(introspection_sources) +GarconGtk_1_0_gir_EXPORT_PACKAGES = garcon-gtk3-1 +INTROSPECTION_GIRS += GarconGtk-1.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/garcon/Makefile.am b/garcon/Makefile.am index c9d7e7e..7af4d04 100644 --- a/garcon/Makefile.am +++ b/garcon/Makefile.am @@ -149,3 +149,37 @@ garcon-marshal.c: garcon-marshal.list Makefile # Required for gtk-doc and make distcheck dist-hook: all + +-include $(INTROSPECTION_MAKEFILE) +INTROSPECTION_GIRS = +INTROSPECTION_SCANNER_ENV = CC="$(CC)" +INTROSPECTION_SCANNER_ARGS = \ + --add-include-path=$(srcdir) \ + --warn-all \ + -DGARCON_COMPILATION \ + --symbol-prefix=g_ \ + --symbol-prefix=garcon_ \ + --c-include=garcon/garcon.h +INTROSPECTION_COMPILER_ARGS = \ + --includedir=$(srcdir) \ + --includedir=. + +if HAVE_INTROSPECTION +introspection_sources = $(filter-out %private.h %private.c, $(libgarcon_1_la_SOURCES)) + +Garcon-1.0.gir: libgarcon-1.la Makefile +Garcon_1_0_gir_INCLUDES = GObject-2.0 GLib-2.0 Gio-2.0 libxfce4util-1.0 +Garcon_1_0_gir_CFLAGS = $(AM_CPPFLAGS) +Garcon_1_0_gir_LIBS = libgarcon-1.la +Garcon_1_0_gir_FILES = $(introspection_sources) +Garcon_1_0_gir_EXPORT_PACKAGES = garcon-1 +INTROSPECTION_GIRS += Garcon-1.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/m4/introspection.m4 b/m4/introspection.m4 new file mode 100644 index 0000000..aa7b3b4 --- /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]) +]) -- 2.20.1