Blame m4/introspection.m4

Packit a7d494
dnl -*- mode: autoconf -*-
Packit a7d494
dnl Copyright 2009 Johan Dahlin
Packit a7d494
dnl
Packit a7d494
dnl This file is free software; the author(s) gives unlimited
Packit a7d494
dnl permission to copy and/or distribute it, with or without
Packit a7d494
dnl modifications, as long as this notice is preserved.
Packit a7d494
dnl
Packit a7d494
Packit a7d494
# serial 1
Packit a7d494
Packit a7d494
m4_define([_GOBJECT_INTROSPECTION_CHECK_INTERNAL],
Packit a7d494
[
Packit a7d494
    AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first
Packit a7d494
    AC_BEFORE([AM_PROG_LIBTOOL],[$0])dnl setup libtool first
Packit a7d494
    AC_BEFORE([LT_INIT],[$0])dnl setup libtool first
Packit a7d494
Packit a7d494
    dnl enable/disable introspection
Packit a7d494
    m4_if([$2], [require],
Packit a7d494
    [dnl
Packit a7d494
        enable_introspection=yes
Packit a7d494
    ],[dnl
Packit a7d494
        AC_ARG_ENABLE(introspection,
Packit a7d494
                  AS_HELP_STRING([--enable-introspection[=@<:@no/auto/yes@:>@]],
Packit a7d494
                                 [Enable introspection for this build]),, 
Packit a7d494
                                 [enable_introspection=auto])
Packit a7d494
    ])dnl
Packit a7d494
Packit a7d494
    AC_MSG_CHECKING([for gobject-introspection])
Packit a7d494
Packit a7d494
    dnl presence/version checking
Packit a7d494
    AS_CASE([$enable_introspection],
Packit a7d494
    [no], [dnl
Packit a7d494
        found_introspection="no (disabled, use --enable-introspection to enable)"
Packit a7d494
    ],dnl
Packit a7d494
    [yes],[dnl
Packit a7d494
        PKG_CHECK_EXISTS([gobject-introspection-1.0],,
Packit a7d494
                         AC_MSG_ERROR([gobject-introspection-1.0 is not installed]))
Packit a7d494
        PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1],
Packit a7d494
                         found_introspection=yes,
Packit a7d494
                         AC_MSG_ERROR([You need to have gobject-introspection >= $1 installed to build AC_PACKAGE_NAME]))
Packit a7d494
    ],dnl
Packit a7d494
    [auto],[dnl
Packit a7d494
        PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], found_introspection=yes, found_introspection=no)
Packit a7d494
	dnl Canonicalize enable_introspection
Packit a7d494
	enable_introspection=$found_introspection
Packit a7d494
    ],dnl
Packit a7d494
    [dnl	
Packit a7d494
        AC_MSG_ERROR([invalid argument passed to --enable-introspection, should be one of @<:@no/auto/yes@:>@])
Packit a7d494
    ])dnl
Packit a7d494
Packit a7d494
    AC_MSG_RESULT([$found_introspection])
Packit a7d494
Packit a7d494
    INTROSPECTION_SCANNER=
Packit a7d494
    INTROSPECTION_COMPILER=
Packit a7d494
    INTROSPECTION_GENERATE=
Packit a7d494
    INTROSPECTION_GIRDIR=
Packit a7d494
    INTROSPECTION_TYPELIBDIR=
Packit a7d494
    if test "x$found_introspection" = "xyes"; then
Packit a7d494
       INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0`
Packit a7d494
       INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0`
Packit a7d494
       INTROSPECTION_GENERATE=`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0`
Packit a7d494
       INTROSPECTION_GIRDIR=`$PKG_CONFIG --variable=girdir gobject-introspection-1.0`
Packit a7d494
       INTROSPECTION_TYPELIBDIR="$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)"
Packit a7d494
       INTROSPECTION_CFLAGS=`$PKG_CONFIG --cflags gobject-introspection-1.0`
Packit a7d494
       INTROSPECTION_LIBS=`$PKG_CONFIG --libs gobject-introspection-1.0`
Packit a7d494
       INTROSPECTION_MAKEFILE=`$PKG_CONFIG --variable=datadir gobject-introspection-1.0`/gobject-introspection-1.0/Makefile.introspection
Packit a7d494
    fi
Packit a7d494
    AC_SUBST(INTROSPECTION_SCANNER)
Packit a7d494
    AC_SUBST(INTROSPECTION_COMPILER)
Packit a7d494
    AC_SUBST(INTROSPECTION_GENERATE)
Packit a7d494
    AC_SUBST(INTROSPECTION_GIRDIR)
Packit a7d494
    AC_SUBST(INTROSPECTION_TYPELIBDIR)
Packit a7d494
    AC_SUBST(INTROSPECTION_CFLAGS)
Packit a7d494
    AC_SUBST(INTROSPECTION_LIBS)
Packit a7d494
    AC_SUBST(INTROSPECTION_MAKEFILE)
Packit a7d494
Packit a7d494
    AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes")
Packit a7d494
])
Packit a7d494
Packit a7d494
Packit a7d494
dnl Usage:
Packit a7d494
dnl   GOBJECT_INTROSPECTION_CHECK([minimum-g-i-version])
Packit a7d494
Packit a7d494
AC_DEFUN([GOBJECT_INTROSPECTION_CHECK],
Packit a7d494
[
Packit a7d494
  _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1])
Packit a7d494
])
Packit a7d494
Packit a7d494
dnl Usage:
Packit a7d494
dnl   GOBJECT_INTROSPECTION_REQUIRE([minimum-g-i-version])
Packit a7d494
Packit a7d494
Packit a7d494
AC_DEFUN([GOBJECT_INTROSPECTION_REQUIRE],
Packit a7d494
[
Packit a7d494
  _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1], [require])
Packit a7d494
])