dnl m4/sgpemv2-dirs.m4 - Copyright 2005, 2006, University
dnl                      of Padova, dept. of Pure and Applied
dnl                      Mathematics
dnl
dnl This file is part of SGPEMv2.
dnl
dnl This is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 2 of the License, or
dnl (at your option) any later version.
dnl
dnl SGPEMv2 is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with SGPEMv2; if not, write to the Free Software
dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

dnl ---------- AC_PROG_SGPEMV2 ---------------------
dnl
dnl Synopsis: AC_PROG_SGPEMV2([min_version])
dnl
dnl This macro checks if sgpemv2 is installed, and 
dnl AC_SUBSTs the following variables:
dnl
dnl SGPEMV2_CFLAGS       -> necessary includes for compiling 
dnl                         plugins
dnl SGPEMV2_LIBS         -> libraries to link against when 
dnl                         building a loadable plugin
dnl SGPEMV2_POLICIES_DIR -> global policies directory
dnl SGPEMV2_PLUGINS_DIR  -> global plugins directory
dnl
dnl This is particularly useful for plugin installation.
dnl It takes a parameter which is the minimal version
dnl installed of sgpemv2 this macro checks for.
dnl The parameter is mandatory.
dnl
dnl Example of usage: AC_PROG_SGPEMV2([0.1])
dnl ------------------------------------------------
AC_DEFUN([AC_PROG_SGPEMV2],
[ 
  PKG_PROG_PKG_CONFIG([0.20])

  if test "x$1" = "x"; then
  	AC_MSG_FAILURE([Wrong number of parameters passed to macro AC@&t@_PROG_SGPEMV2. Please contact this package mantainer.])
  fi
  
  _pkg_sgpemv2_module="sgpemv2 >= $1"

  PKG_CHECK_MODULES([SGPEMV2], [$_pkg_sgpemv2_module],
  		:, AC_MSG_ERROR([$SGPEMV2_PKG_ERRORS]))
 
  AC_MSG_CHECKING([for sgpemv2 compiler flags])
  AC_MSG_RESULT([$SGPEMV2_CFLAGS])

  AC_MSG_CHECKING([for sgpemv2 linking flags])
  AC_MSG_RESULT([$SGPEMV2_LIBS])

  AC_MSG_CHECKING([for sgpemv2 policies default installation directory])
  SGPEMV2_POLICIES_DIR=`$PKG_CONFIG --variable=policies_dir "$_pkg_sgpemv2_module" 2>/dev/null`
  if test "x$SGPEMV2_POLICIES_DIR" = "x"; then
  	AC_MSG_ERROR([Unable to retrieve value])
  else
  	AC_MSG_RESULT([$SGPEMV2_POLICIES_DIR])
  fi

  AC_MSG_CHECKING([for sgpemv2 plugins default installation directory])
  SGPEMV2_PLUGINS_DIR=`$PKG_CONFIG --variable=plugins_dir "$_pkg_sgpemv2_module" 2>/dev/null`
  if test "x$SGPEMV2_PLUGINS_DIR" = "x"; then
  	AC_MSG_ERROR([Unable to retrieve value])
  else
	AC_MSG_RESULT([$SGPEMV2_PLUGINS_DIR])
  fi

  AC_SUBST([SGPEMV2_POLICIES_DIR])
  AC_SUBST([SGPEMV2_PLUGINS_DIR])

])dnl ------- AC_PROG_SGPEMV2 ----------------------

