From e297d0024cc142005e29447b3eadd2dfa5f87af8 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Tue, 23 Mar 2010 00:00:49 +0200 Subject: use GOBJECT_INTROSPECTION_CHECK from gobject-introspection instead of own autoconf code doing the same Behavior change: introspection now defaults to "auto" instead of "yes". --- Makefile.am | 2 + autogen.sh | 2 + configure.ac | 23 ++---------- m4/introspection.m4 | 94 ++++++++++++++++++++++++++++++++++++++++++++++++ src/polkit/Makefile.am | 16 ++++---- 5 files changed, 109 insertions(+), 28 deletions(-) create mode 100644 m4/introspection.m4 diff --git a/Makefile.am b/Makefile.am index 6516385..81656b9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,7 @@ ## Process this file with automake to produce Makefile.in +ACLOCAL_AMFLAGS = -I m4 + SUBDIRS = actions data src docs po NULL = diff --git a/autogen.sh b/autogen.sh index 4d25597..6a08292 100755 --- a/autogen.sh +++ b/autogen.sh @@ -68,6 +68,8 @@ if test -z "$*"; then echo fi +ACLOCAL_FLAGS="-I m4" + case $CC in xlc ) am_opt=--include-deps;; diff --git a/configure.ac b/configure.ac index 73519f6..e07db38 100644 --- a/configure.ac +++ b/configure.ac @@ -4,6 +4,7 @@ AC_PREREQ(2.59c) AC_INIT(polkit, 0.96, http://lists.freedesktop.org/mailman/listinfo/polkit-devel) AM_INIT_AUTOMAKE(polkit, 0.96) AM_CONFIG_HEADER(config.h) +AC_CONFIG_MACRO_DIR([m4]) AM_MAINTAINER_MODE m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) @@ -353,25 +354,7 @@ case "$host_os" in ;; esac -# GObject introspection -# -AC_ARG_ENABLE([introspection], - AS_HELP_STRING([--enable-introspection], [enable 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 --variable=girdir gobject-introspection-1.0)]) - #AC_SUBST([GIRTYPELIBDIR], [$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)]) - GIRDIR=${datadir}/gir-1.0 - GIRTYPELIBDIR=${libdir}/girepository-1.0 - AC_SUBST(GIRDIR) - AC_SUBST(GIRTYPELIBDIR) -fi -AM_CONDITIONAL([ENABLE_INTROSPECTION], [test "x$enable_introspection" = xyes]) +GOBJECT_INTROSPECTION_CHECK([0.6.2]) AC_ARG_ENABLE([examples], AS_HELP_STRING([--enable-examples], [Build the example programs]),, @@ -432,7 +415,7 @@ echo " cflags: ${CFLAGS} cppflags: ${CPPFLAGS} xsltproc: ${XSLTPROC} - introspection: ${enable_introspection} + introspection: ${found_introspection} Distribution/OS: ${with_os_type} authentication framework: ${POLKIT_AUTHFW} 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]) +]) diff --git a/src/polkit/Makefile.am b/src/polkit/Makefile.am index ad345db..cca8b2d 100644 --- a/src/polkit/Makefile.am +++ b/src/polkit/Makefile.am @@ -125,15 +125,15 @@ libpolkit_gobject_1_la_LIBADD = \ libpolkit_gobject_1_la_LDFLAGS = -export-symbols-regex '(^polkit_.*)' -if ENABLE_INTROSPECTION -girdir = $(GIRDIR) +if HAVE_INTROSPECTION +girdir = $(INTROSPECTION_GIRDIR) gir_DATA = Polkit-1.0.gir -typelibsdir = $(GIRTYPELIBDIR) +typelibsdir = $(INTROSPECTION_TYPELIBDIR) typelibs_DATA = Polkit-1.0.typelib -Polkit-1.0.gir: libpolkit-gobject-1.la $(G_IR_SCANNER) Makefile.am - $(G_IR_SCANNER) -v \ +Polkit-1.0.gir: libpolkit-gobject-1.la $(INTROSPECTION_SCANNER) Makefile.am + $(INTROSPECTION_SCANNER) -v \ --namespace Polkit \ --nsversion=1.0 \ --include=Gio-2.0 \ @@ -167,10 +167,10 @@ Polkit-1.0.gir: libpolkit-gobject-1.la $(G_IR_SCANNER) Makefile.am $(srcdir)/polkitunixuser.h \ $(NULL) -Polkit-1.0.typelib: Polkit-1.0.gir $(G_IR_COMPILER) - $(G_IR_COMPILER) $< -o $@ +Polkit-1.0.typelib: Polkit-1.0.gir $(INTROSPECTION_COMPILER) + $(INTROSPECTION_COMPILER) $< -o $@ -endif # ENABLE_INTROSPECTION +endif # HAVE_INTROSPECTION EXTRA_DIST = polkitenumtypes.h.template polkitenumtypes.c.template CLEANFILES = $(gir_DATA) $(typelibs_DATA) -- 1.5.6.1