1dnl -*- mode: autoconf -*-
2dnl Copyright 2009 Johan Dahlin
3dnl
4dnl This file is free software; the author(s) gives unlimited
5dnl permission to copy and/or distribute it, with or without
6dnl modifications, as long as this notice is preserved.
7dnl
8
9# serial 1
10
11m4_define([_GOBJECT_INTROSPECTION_CHECK_INTERNAL],
12[
13    AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first
14    AC_BEFORE([AM_PROG_LIBTOOL],[$0])dnl setup libtool first
15    AC_BEFORE([LT_INIT],[$0])dnl setup libtool first
16
17    dnl enable/disable introspection
18    m4_if([$2], [require],
19    [dnl
20        enable_introspection=yes
21    ],[dnl
22        AC_ARG_ENABLE(introspection,
23                  AS_HELP_STRING([--enable-introspection[=@<:@no/auto/yes@:>@]],
24                                 [Enable introspection for this build]),,
25                                 [enable_introspection=auto])
26    ])dnl
27
28    AC_MSG_CHECKING([for gobject-introspection])
29
30    dnl presence/version checking
31    AS_CASE([$enable_introspection],
32    [no], [dnl
33        found_introspection="no (disabled, use --enable-introspection to enable)"
34    ],dnl
35    [yes],[dnl
36        PKG_CHECK_EXISTS([gobject-introspection-1.0],,
37                         AC_MSG_ERROR([gobject-introspection-1.0 is not installed]))
38        PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1],
39                         found_introspection=yes,
40                         AC_MSG_ERROR([You need to have gobject-introspection >= $1 installed to build AC_PACKAGE_NAME]))
41    ],dnl
42    [auto],[dnl
43        PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], found_introspection=yes, found_introspection=no)
44    ],dnl
45    [dnl
46        AC_MSG_ERROR([invalid argument passed to --enable-introspection, should be one of @<:@no/auto/yes@:>@])
47    ])dnl
48
49    AC_MSG_RESULT([$found_introspection])
50
51    INTROSPECTION_SCANNER=
52    INTROSPECTION_COMPILER=
53    INTROSPECTION_GENERATE=
54    INTROSPECTION_GIRDIR=
55    INTROSPECTION_TYPELIBDIR=
56    if test "x$found_introspection" = "xyes"; then
57       INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0`
58       INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0`
59       INTROSPECTION_GENERATE=`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0`
60       INTROSPECTION_GIRDIR=`$PKG_CONFIG --variable=girdir gobject-introspection-1.0`
61       INTROSPECTION_TYPELIBDIR="$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)"
62    fi
63    AC_SUBST(INTROSPECTION_SCANNER)
64    AC_SUBST(INTROSPECTION_COMPILER)
65    AC_SUBST(INTROSPECTION_GENERATE)
66    AC_SUBST(INTROSPECTION_GIRDIR)
67    AC_SUBST(INTROSPECTION_TYPELIBDIR)
68
69    AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes")
70])
71
72
73dnl Usage:
74dnl   GOBJECT_INTROSPECTION_CHECK([minimum-g-i-version])
75
76AC_DEFUN([GOBJECT_INTROSPECTION_CHECK],
77[
78  _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1])
79])
80
81dnl Usage:
82dnl   GOBJECT_INTROSPECTION_REQUIRE([minimum-g-i-version])
83
84
85AC_DEFUN([GOBJECT_INTROSPECTION_REQUIRE],
86[
87  _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1], [require])
88])
89