introspection.m4 3.6 KB

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