Blame m4/vapigen.m4

Packit 7e555f
dnl vapigen.m4
Packit 7e555f
dnl
Packit 7e555f
dnl Copyright 2012 Evan Nemerson
Packit 7e555f
dnl
Packit 7e555f
dnl This library is free software; you can redistribute it and/or
Packit 7e555f
dnl modify it under the terms of the GNU Lesser General Public
Packit 7e555f
dnl License as published by the Free Software Foundation; either
Packit 7e555f
dnl version 2.1 of the License, or (at your option) any later version.
Packit 7e555f
dnl
Packit 7e555f
dnl This library is distributed in the hope that it will be useful,
Packit 7e555f
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 7e555f
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 7e555f
dnl Lesser General Public License for more details.
Packit 7e555f
dnl
Packit 7e555f
dnl You should have received a copy of the GNU Lesser General Public
Packit 7e555f
dnl License along with this library; if not, write to the Free Software
Packit 7e555f
dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
Packit 7e555f
Packit 7e555f
# VAPIGEN_CHECK([VERSION], [API_VERSION], [FOUND_INTROSPECTION], [DEFAULT])
Packit 7e555f
# --------------------------------------
Packit 7e555f
# Check vapigen existence and version
Packit 7e555f
#
Packit 7e555f
# See http://live.gnome.org/Vala/UpstreamGuide for detailed documentation
Packit 7e555f
AC_DEFUN([VAPIGEN_CHECK],
Packit 7e555f
[
Packit 7e555f
  AS_IF([test "x$3" != "xyes"], [
Packit 7e555f
      m4_provide_if([GOBJECT_INTROSPECTION_CHECK], [], [
Packit 7e555f
          m4_provide_if([GOBJECT_INTROSPECTION_REQUIRE], [], [
Packit 7e555f
              AC_MSG_ERROR([[You must call GOBJECT_INTROSPECTION_CHECK or GOBJECT_INTROSPECTION_REQUIRE before using VAPIGEN_CHECK unless using the FOUND_INTROSPECTION argument is "yes"]])
Packit 7e555f
            ])
Packit 7e555f
        ])
Packit 7e555f
    ])
Packit 7e555f
Packit 7e555f
  AC_ARG_ENABLE([vala],
Packit 7e555f
    [AS_HELP_STRING([--enable-vala[=@<:@no/auto/yes@:>@]],[build Vala bindings @<:@default=]ifelse($4,,auto,$4)[@:>@])],,[
Packit 7e555f
      AS_IF([test "x$4" = "x"], [
Packit 7e555f
          enable_vala=auto
Packit 7e555f
        ], [
Packit 7e555f
          enable_vala=$4
Packit 7e555f
        ])
Packit 7e555f
    ])
Packit 7e555f
Packit 7e555f
  AS_CASE([$enable_vala], [no], [enable_vala=no],
Packit 7e555f
      [yes], [
Packit 7e555f
        AS_IF([test "x$3" != "xyes" -a "x$found_introspection" != "xyes"], [
Packit 7e555f
            AC_MSG_ERROR([Vala bindings require GObject Introspection])
Packit 7e555f
          ])
Packit 7e555f
      ], [auto], [
Packit 7e555f
        AS_IF([test "x$3" != "xyes" -a "x$found_introspection" != "xyes"], [
Packit 7e555f
            enable_vala=no
Packit 7e555f
          ])
Packit 7e555f
      ], [
Packit 7e555f
        AC_MSG_ERROR([Invalid argument passed to --enable-vala, should be one of @<:@no/auto/yes@:>@])
Packit 7e555f
      ])
Packit 7e555f
Packit 7e555f
  AS_IF([test "x$2" = "x"], [
Packit 7e555f
      vapigen_pkg_name=vapigen
Packit 7e555f
    ], [
Packit 7e555f
      vapigen_pkg_name=vapigen-$2
Packit 7e555f
    ])
Packit 7e555f
  AS_IF([test "x$1" = "x"], [
Packit 7e555f
      vapigen_pkg="$vapigen_pkg_name"
Packit 7e555f
    ], [
Packit 7e555f
      vapigen_pkg="$vapigen_pkg_name >= $1"
Packit 7e555f
    ])
Packit 7e555f
Packit 7e555f
  PKG_PROG_PKG_CONFIG
Packit 7e555f
Packit 7e555f
  PKG_CHECK_EXISTS([$vapigen_pkg], [
Packit 7e555f
      AS_IF([test "$enable_vala" = "auto"], [
Packit 7e555f
          enable_vala=yes
Packit 7e555f
        ])
Packit 7e555f
    ], [
Packit 7e555f
      AS_CASE([$enable_vala], [yes], [
Packit 7e555f
          AC_MSG_ERROR([$vapigen_pkg not found])
Packit 7e555f
        ], [auto], [
Packit 7e555f
          enable_vala=no
Packit 7e555f
        ])
Packit 7e555f
    ])
Packit 7e555f
Packit 7e555f
  AC_MSG_CHECKING([for vapigen])
Packit 7e555f
Packit 7e555f
  AS_CASE([$enable_vala],
Packit 7e555f
    [yes], [
Packit 7e555f
      VAPIGEN=`$PKG_CONFIG --variable=vapigen $vapigen_pkg_name`
Packit 7e555f
      VAPIGEN_MAKEFILE=`$PKG_CONFIG --variable=datadir $vapigen_pkg_name`/vala/Makefile.vapigen
Packit 7e555f
      AS_IF([test "x$2" = "x"], [
Packit 7e555f
          VAPIGEN_VAPIDIR=`$PKG_CONFIG --variable=vapidir $vapigen_pkg_name`
Packit 7e555f
        ], [
Packit 7e555f
          VAPIGEN_VAPIDIR=`$PKG_CONFIG --variable=vapidir_versioned $vapigen_pkg_name`
Packit 7e555f
        ])
Packit 7e555f
    ])
Packit 7e555f
Packit 7e555f
  AC_MSG_RESULT([$enable_vala])
Packit 7e555f
Packit 7e555f
  AC_SUBST([VAPIGEN])
Packit 7e555f
  AC_SUBST([VAPIGEN_VAPIDIR])
Packit 7e555f
  AC_SUBST([VAPIGEN_MAKEFILE])
Packit 7e555f
Packit 7e555f
  AM_CONDITIONAL(ENABLE_VAPIGEN, test "x$enable_vala" = "xyes")
Packit 7e555f
])