1dnl vapigen.m4 2dnl 3dnl Copyright 2012 Evan Nemerson, Daniel Espinosa 4dnl 5dnl This library is free software; you can redistribute it and/or 6dnl modify it under the terms of the GNU Lesser General Public 7dnl License as published by the Free Software Foundation; either 8dnl version 2.1 of the License, or (at your option) any later version. 9dnl 10dnl This library is distributed in the hope that it will be useful, 11dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 12dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13dnl Lesser General Public License for more details. 14dnl 15dnl You should have received a copy of the GNU Lesser General Public 16dnl License along with this library; if not, write to the Free Software 17dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 19# VAPIGEN_CHECK([VERSION], [API_VERSION], [FOUND-INTROSPECTION], [DEFAULT]) 20# -------------------------------------- 21# Check vapigen existence and version. GObject Introspection is required, then 22# set FOUND-INTROSPECTION to [yes] or use call GOBJECT_INTROSPECTION_CHECK or 23# GOBJECT_INTROSPECTION_REQUIRE. This is an internal macro, use VAPIGEN_CHECK, 24# VAPIGEN_GI_CHECK or VAPIGEN_GI_REQUIRE. 25# 26# See http://live.gnome.org/Vala/UpstreamGuide for detailed documentation 27m4_define([_VAPIGEN_CHECK_INTERNAL], 28[ 29 AC_REQUIRE([PKG_PROG_PKG_CONFIG]) 30 AC_REQUIRE([AM_PROG_VALAC]) 31 AC_ARG_ENABLE([vala], 32 [AS_HELP_STRING([--enable-vala[=@<:@no/auto/yes@:>@]],[build Vala bindings @<:@default=]ifelse($4,,auto,$4)[@:>@])],,[ 33 AS_IF([ test "x$4" = "x"], [ 34 enable_vala=auto 35 ], [ 36 enable_vala=$4 37 ]) 38 ]) 39 AS_IF([ test "x$enable_vala" = "xyes" -o "x$enable_vala" = "xauto"], 40 [ 41 AS_IF([ test "x$3" != "xyes" -a "x$found_introspection" != "xyes"], [ 42 AC_MSG_ERROR([Vala bindings require GObject Introspection]) 43 ]) 44 ], [ 45 AS_IF([ test "x$enable_vala" != "no"],[ 46 vapigen_pkg_found=no 47 ],[ 48 AC_MSG_ERROR([Invalid argument passed to --enable-vala, should be one of @<:@no/auto/yes@:>@]) 49 ]) 50 ]) 51 AS_IF([ test "x$2" = "x"], [ 52 vapigen_pkg_name=vapigen 53 ], [ 54 vapigen_pkg_name=vapigen-$2 55 ]) 56 AS_IF([ test "x$1" = "x"], [ 57 vapigen_pkg="$vapigen_pkg_name" 58 ], [ 59 vapigen_pkg="$vapigen_pkg_name >= $1" 60 ]) 61 AS_IF([ test "x$enable_vala" = "xyes" -o "x$enable_vala" = "xauto"], [ 62 AC_MSG_CHECKING([for vapigen $vapigen_pkg_name]) 63 PKG_CHECK_EXISTS([ $vapigen_pkg ], [ 64 vapigen_pkg_found=yes 65 ], [ 66 vapigen_pkg_found=no 67 AC_MSG_RESULT([no]) 68 AC_MSG_NOTICE([Searching for $vapigen_pkg_name program...]) 69 AC_PATH_PROG(VAPIGEN, [$vapigen_pkg_name], [no]) 70 if test "x$VAPIGEN" = "xno" 71 then 72 check_prog=no 73 else 74 check_prog=yes 75 fi 76 ]) 77 78 AS_CASE([$vapigen_pkg_found], 79 [yes], [ 80 VAPIGEN=`$PKG_CONFIG --variable=vapigen vapigen` 81 VAPIGEN_MAKEFILE=`$PKG_CONFIG --variable=datadir vapigen`/vala/Makefile.vapigen 82 VAPIDIR=`$PKG_CONFIG --variable=vapidir vapigen` 83 AS_IF([ test "x$2" = "x"], [ 84 VAPIGEN_VAPIDIR=`$PKG_CONFIG --variable=vapidir vapigen` 85 ], [ 86 VAPIGEN_VAPIDIR=`$PKG_CONFIG --variable=vapidir_versioned vapigen` 87 ]) 88 ], 89 [no], [ 90 AS_CASE([$check_prog],[no],[ 91 AC_MSG_ERROR([Can't locate $vapigen_pkg program]) 92 ], [yes], [ 93 AS_IF([ test "x$2" = "x"], [ 94 vala_pkg_name=libvala 95 ], [ 96 vala_pkg_name=libvala-$2 97 ]) 98 AS_IF([ test "x$1" = "x"], [ 99 vala_pkg="$vala_pkg_name" 100 ], [ 101 vala_pkg="$vala_pkg_name >= $1" 102 ]) 103 AC_MSG_CHECKING([for $vala_pkg]) 104 PKG_CHECK_EXISTS([$vala_pkg], [ 105 VALA_DATADIR=`pkg-config $vala_pkg --variable=datadir` 106 VAPIDIR="$VALA_DATADIR/vala/vapi" 107 VAPIGEN_MAKEFILE="$VALA_DATADIR/vala/Makefile.vapigen" 108 AS_IF([ test "x$2" = "x"], [ 109 VAPIGEN_VAPIDIR=`$PKG_CONFIG --variable=vapidir vapigen` 110 ], [ 111 VAPIGEN_VAPIDIR=`$PKG_CONFIG --variable=vapidir_versioned vapigen` 112 ]) 113 vapigen_pkg_found=yes 114 ], [ 115 AS_CASE([$enable_vala], [yes], [ 116 AC_MSG_ERROR([$vala_pkg not found]) 117 ], [auto], [ 118 vapigen_pkg_found=no 119 ]) 120 ]) 121 ]) 122 ]) 123 124 AC_MSG_RESULT([$vapigen_pkg_found]) 125 126 127 ]) 128 AC_SUBST([VAPIGEN]) 129 AC_SUBST([VAPIGEN_VAPIDIR]) 130 AC_SUBST([VAPIDIR]) 131 AC_SUBST([VAPIGEN_MAKEFILE]) 132 133 AM_CONDITIONAL(ENABLE_VAPIGEN, test "x$vapigen_pkg_found" = "xyes") 134]) 135 136dnl Check VAPIGEN 137# VAPIGEN_CHECK([VERSION], [API_VERSION], [FOUND-INTROSPECTION], [DEFAULT]) 138# -------------------------------------- 139# Check vapigen existence and version. Set FOUND-INTROSPECTION to [yes] 140# if you have detected GObject Introspection without GOBJECT_INTROSPECTION_CHECK 141# or GOBJECT_INTROSPECTION_REQUIRE macros. 142# 143# See http://live.gnome.org/Vala/UpstreamGuide for detailed documentation 144AC_DEFUN([VAPIGEN_CHECK], 145[ 146 _VAPIGEN_CHECK_INTERNAL($1,$2,$3,$4) 147] 148) 149 150dnl usage: 151# VAPIGEN_GI_CHECK([VERSION], [API_VERSION], [DEFAULT]) 152# -------------------------------------- 153# Check vapigen existence and version. You must call GOBJECT_INTROSPECTION_CHECK 154# first in order to call this macro. 155# 156# See http://live.gnome.org/Vala/UpstreamGuide for detailed documentation 157AC_DEFUN([VAPIGEN_GI_CHECK], 158[ 159 AC_REQUIRE([GOBJECT_INTROSPECTION_CHECK]) 160 _VAPIGEN_CHECK_INTERNAL([$1],[$2],[$found_introspection],[$3]) 161] 162) 163 164dnl usage: 165# VAPIGEN_GI_REQUIRE([VERSION], [API_VERSION], [DEFAULT]) 166# -------------------------------------- 167# Check vapigen existence and version. You must call GOBJECT_INTROSPECTION_REQUIRE 168# first in order to call this macro. 169# 170# See http://live.gnome.org/Vala/UpstreamGuide for detailed documentation 171AC_DEFUN([VAPIGEN_GI_REQUIRE], 172[ 173 AC_REQUIRE([GOBJECT_INTROSPECTION_REQUIRE]) 174 _VAPIGEN_CHECK_INTERNAL([$1],[$2],[$found_introspection],[$3]) 175] 176) 177 178