linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Adrian Bunk <adrian.bunk@movial.com>
To: linux-hotplug@vger.kernel.org
Subject: [udev patch] use GOBJECT_INTROSPECTION_CHECK from
Date: Mon, 22 Mar 2010 18:49:33 +0000	[thread overview]
Message-ID: <20100322184933.GG16884@localhost.pp.htv.fi> (raw)

instead of own autoconf code doing the same

Behavior change:
introspection now defaults to "auto" instead of "yes".
---
 Makefile.am         |   14 ++++----
 configure.ac        |   16 +-------
 m4/introspection.m4 |   94 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 103 insertions(+), 21 deletions(-)
 create mode 100644 m4/introspection.m4

diff --git a/Makefile.am b/Makefile.am
index 68a68d9..ad98998 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -369,11 +369,11 @@ extras/gudev/gudevenumtypes.c: extras/gudev/gudevenumtypes.c.template extras/gud
 	$(AM_V_GEN)glib-mkenums --template $^ > \
 	    $@.tmp && mv $@.tmp $@
 
-if ENABLE_INTROSPECTION
-extras/gudev/GUdev-1.0.gir: extras/gudev/libgudev-1.0.la $(G_IR_SCANNER) Makefile.am
+if HAVE_INTROSPECTION
+extras/gudev/GUdev-1.0.gir: extras/gudev/libgudev-1.0.la $(INTROSPECTION_SCANNER) Makefile.am
 	$(AM_V_GEN)PKG_CONFIG_PATH=$(top_builddir)/data:$$PKG_CONFIG_PATH \
 	LD_LIBRARY_PATH=$(top_builddir)/extras/gudev \
-	$(G_IR_SCANNER) -v \
+	$(INTROSPECTION_SCANNER) -v \
 		--namespace GUdev \
 		--nsversion=1.0 \
 		--include=GObject-2.0 \
@@ -395,17 +395,17 @@ extras/gudev/GUdev-1.0.gir: extras/gudev/libgudev-1.0.la $(G_IR_SCANNER) Makefil
 		$(top_srcdir)/extras/gudev/gudevclient.c \
 		$(top_srcdir)/extras/gudev/gudevdevice.c
 
-extras/gudev/GUdev-1.0.typelib: extras/gudev/GUdev-1.0.gir $(G_IR_COMPILER)
+extras/gudev/GUdev-1.0.typelib: extras/gudev/GUdev-1.0.gir $(INTROSPECTION_COMPILER)
 	$(AM_V_GEN)g-ir-compiler $< -o $@
 
-girdir = $(GIRDIR)
+girdir = $(INTROSPECTION_GIRDIR)
 gir_DATA = extras/gudev/GUdev-1.0.gir
 
-typelibsdir = $(GIRTYPELIBDIR)
+typelibsdir = $(INTROSPECTION_TYPELIBDIR)
 typelibs_DATA = extras/gudev/GUdev-1.0.typelib
 
 CLEANFILES += $(gir_DATA) $(typelibs_DATA)
-endif # ENABLE_INTROSPECTION
+endif # HAVE_INTROSPECTION
 
 # ------------------------------------------------------------------------------
 # Bluetooth HID devices with special magic to switch the device
diff --git a/configure.ac b/configure.ac
index d53dd12..319a948 100644
--- a/configure.ac
+++ b/configure.ac
@@ -87,19 +87,7 @@ if test "x$enable_extras" = xyes; then
 fi
 AM_CONDITIONAL([ENABLE_EXTRAS], [test "x$enable_extras" = xyes])
 
-AC_ARG_ENABLE([introspection],
-	AS_HELP_STRING([--disable-introspection], [disable GObject introspection]),
-	[], [enable_introspection=yes])
-if test "x$enable_introspection" = xyes; then
-	PKG_CHECK_MODULES([INTROSPECTION], [gobject-introspection-1.0 >= 0.6.2])
-	AC_DEFINE([ENABLE_INTROSPECTION], [1], [enable GObject introspection support])
-	AC_SUBST([G_IR_SCANNER], [$($PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0)])
-	AC_SUBST([G_IR_COMPILER], [$($PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0)])
-	AC_SUBST([G_IR_GENERATE], [$($PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0)])
-	AC_SUBST([GIRDIR], [$($PKG_CONFIG --define-variableÚtadir=${datadir} --variable=girdir gobject-introspection-1.0)])
-	AC_SUBST([GIRTYPELIBDIR], [$($PKG_CONFIG --define-variable=libdir=${libdir} --variable=typelibdir gobject-introspection-1.0)])
-fi
-AM_CONDITIONAL([ENABLE_INTROSPECTION], [test "x$enable_introspection" = xyes])
+GOBJECT_INTROSPECTION_CHECK([0.6.2])
 
 AC_CONFIG_HEADERS(config.h)
 AC_CONFIG_FILES([
@@ -140,7 +128,7 @@ AC_MSG_RESULT([
 	ldflags:		${LDFLAGS}
 
 	extras:			${enable_extras}
-	gintrospection:		${enable_introspection}
+	gintrospection:		${found_introspection}
 
 	usb.ids:		${USB_DATABASE}
 	pci.ids:		${PCI_DATABASE}
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Útadir 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])
+])
-- 
1.5.6.1


                 reply	other threads:[~2010-03-22 18:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100322184933.GG16884@localhost.pp.htv.fi \
    --to=adrian.bunk@movial.com \
    --cc=linux-hotplug@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).