From: P. F. Chimento Date: Mon, 13 Jun 2011 12:17:28 +0000 (+0200) Subject: Add introspection to build process X-Git-Tag: v0.9~79 X-Git-Url: https://git.stderr.nl/gitweb?p=projects%2Fchimara%2Fchimara.git;a=commitdiff_plain;h=7242acd9825d3395634ab17a8bbfde55694c64bd Add introspection to build process So that the build generates a GObject Introspection Repository from which we can automatically generate bindings for other programming languages! --- diff --git a/Makefile.am b/Makefile.am index a163df8..352b3d3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -18,18 +18,29 @@ dist_chimaradoc_DATA = \ pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = chimara.pc chimara-plugin.pc -EXTRA_DIST = chimara.pc.in chimara-plugin.pc.in chimara.spec.in +EXTRA_DIST = \ + chimara.pc.in + chimara-plugin.pc.in + chimara.spec.in + m4/introspection.m4 DISTCLEANFILES = chimara.pc chimara-plugin.pc chimara.spec +macros_ignore = codeset gettext glibc2 glibc21 gtk-doc iconv intdiv0 intl \ + intldir intlmacosx intltool intmax inttypes_h inttypes-pri lcmessage \ + lib-ld lib-link lib-prefix libtool lock longlong lt~obsolete ltoptions \ + ltsugar ltversion nls po printf-posix progtest size_max stdint_h uintmax_t \ + visibility wchar_t wint_t xsize + MAINTAINERCLEANFILES = ABOUT-NLS INSTALL aclocal.m4 compile config.guess \ config.h.in config.rpath config.sub depcomp gtk-doc.make install-sh \ - intltool-extract.in intltool-merge.in intltool-update.in ltmain.sh missing \ - ylwrap m4 autom4te.cache + intltool-extract.in intltool-merge.in intltool-update.in ltmain.sh missing \ + ylwrap autom4te.cache \ + $(addprefix 'm4/',$(addsuffix '.m4', $(macros_ignore))) ACLOCAL_AMFLAGS = -I m4 -DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc +DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc --enable-introspection if BUILDING_RPM EXTRA_DIST += chimara.spec diff --git a/configure.ac b/configure.ac index 6a47b54..9e73d11 100644 --- a/configure.ac +++ b/configure.ac @@ -2,16 +2,17 @@ ### INITIALIZATION ############################################################ -# Initialize Autoconf +AC_PREREQ([2.62]) # Oldest version of Autoconf that works with introspection +# Initialize Autoconf # Args: (human-readable package name, package version, bug report address, # tarballname) AC_INIT([chimara], [0.9]) # Sanity check to make sure we are running Autoconf from the right directory AC_CONFIG_SRCDIR(libchimara/chimara-glk.c) # Put m4 macros in their own directory -AC_CONFIG_MACRO_DIR(m4) +AC_CONFIG_MACRO_DIR([m4]) # Initialize Automake -AM_INIT_AUTOMAKE([-Wall]) +AM_INIT_AUTOMAKE([-Wall -Wno-portability]) # Configure with --enable-silent-rules to cut down on clutter m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) @@ -45,7 +46,7 @@ AC_PROG_YACC # Building nitfol requires yacc ### DECLARE PROGRAMS ########################################################## AC_PROG_INSTALL # Install -LT_INIT([dlopen]) # Libtool 2.2.6 and up +LT_INIT([dlopen]) # Libtool 2.2.6 and up LT_PREREQ([2.2.6]) AM_GNU_GETTEXT([external]) # Gettext, link to system libintl IT_PROG_INTLTOOL([0.40.0]) # Intltool @@ -72,6 +73,10 @@ GETTEXT_PACKAGE=chimara AC_SUBST(GETTEXT_PACKAGE) AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [GETTEXT package name]) +### INTROSPECTION ############################################################## + +GOBJECT_INTROSPECTION_CHECK([0.6.7]) + ### ILIAD ##################################################################### AC_ARG_ENABLE([iliad], [AS_HELP_STRING([--enable-iliad=@<:@yes/no@:>@], diff --git a/libchimara/Makefile.am b/libchimara/Makefile.am index 3f98d08..7724b74 100644 --- a/libchimara/Makefile.am +++ b/libchimara/Makefile.am @@ -71,5 +71,33 @@ chimara-marshallers.h: chimara-marshallers.txt $(AM_V_GEN)glib-genmarshal --header --prefix=_chimara_marshal $< > $@ EXTRA_DIST = doc.c glkstart.c chimara-marshallers.txt +CLEANFILES = + +-include $(INTROSPECTION_MAKEFILE) +INTROSPECTION_GIRS = +INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) +INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir) + +if HAVE_INTROSPECTION +introspection_sources = \ + chimara-glk.c chimara-glk.h \ + chimara-if.c chimara-if.h + +Chimara-1.0.gir: libchimara.la +Chimara_1_0_gir_INCLUDES = GObject-2.0 GLib-2.0 Gtk-2.0 +Chimara_1_0_gir_CFLAGS = @CHIMARA_CFLAGS@ -I$(top_srcdir) +Chimara_1_0_gir_LIBS = libchimara.la +Chimara_1_0_gir_FILES = $(introspection_sources) +Chimara_1_0_gir_SCANNERFLAGS = --warn-all +INTROSPECTION_GIRS += Chimara-1.0.gir + +girdir = $(datadir)/gir-1.0 +gir_DATA = $(INTROSPECTION_GIRS) + +typelibdir = $(libdir)/girepository-1.0 +typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib) + +CLEANFILES += $(gir_DATA) $(typelib_DATA) +endif -include $(top_srcdir)/git.mk diff --git a/m4/introspection.m4 b/m4/introspection.m4 new file mode 100644 index 0000000..589721c --- /dev/null +++ b/m4/introspection.m4 @@ -0,0 +1,94 @@ +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)" + 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]) +])