summaryrefslogtreecommitdiff
path: root/macros
diff options
context:
space:
mode:
authorDaniel Elstner <danielk@openismus.com>2009-08-21 11:48:32 +0200
committerDaniel Elstner <danielk@openismus.com>2009-08-21 11:48:32 +0200
commit82cb7f751f4e15e5f97c6f21fc83447cbaba4174 (patch)
tree21acc2f2f238feef2d2ebc4db8ba80aae10552ee /macros
parent64fbdc551b3027d88046ef5d26f7bad880498ea4 (diff)
downloadmm-common-82cb7f751f4e15e5f97c6f21fc83447cbaba4174.tar.gz
Refactor Perl checks into separate Autoconf macros
* macros/mm-pkg.m4 (MM_PATH_PERL): New Autoconf macro to locate the Perl interpreter executable. (MM_CHECK_PERL): New Autoconf macro to require a minimum version of the Perl interpreter. * macros/mm-doc.m4 (_MM_ARG_ENABLE_DOCUMENTATION): Remove Perl check. (MM_ARG_ENABLE_DOCUMENTATION): Require MM_PATH_PERL.
Diffstat (limited to 'macros')
-rw-r--r--macros/mm-doc.m47
-rw-r--r--macros/mm-pkg.m460
2 files changed, 58 insertions, 9 deletions
diff --git a/macros/mm-doc.m4 b/macros/mm-doc.m4
index 2b6df21..5dc69cd 100644
--- a/macros/mm-doc.m4
+++ b/macros/mm-doc.m4
@@ -1,4 +1,4 @@
-## Copyright (c) 2009 Daniel Elstner <daniel.kitta@gmail.com>
+## Copyright (c) 2009 Openismus GmbH <http://www.openismus.com/>
##
## This file is part of mm-common.
##
@@ -15,7 +15,7 @@
## You should have received a copy of the GNU General Public License
## along with mm-common. If not, see <http://www.gnu.org/licenses/>.
-#serial 20090819
+#serial 20090821
## _MM_CONFIG_DOCTOOL_DIR
##
@@ -81,12 +81,10 @@ m4_define([_MM_ARG_ENABLE_DOCUMENTATION],
[dnl
AC_PROVIDE([$0])[]dnl
dnl
-AC_ARG_VAR([PERL], [path to Perl interpreter])[]dnl
AC_ARG_VAR([DOT], [path to dot utility])[]dnl
AC_ARG_VAR([DOXYGEN], [path to Doxygen utility])[]dnl
AC_ARG_VAR([XSLTPROC], [path to xsltproc utility])[]dnl
dnl
-AC_PATH_PROG([PERL], [perl], [perl])
AC_PATH_PROG([DOT], [dot], [dot])
AC_PATH_PROG([DOXYGEN], [doxygen], [doxygen])
AC_PATH_PROG([XSLTPROC], [xsltproc], [xsltproc])
@@ -142,6 +140,7 @@ AC_DEFUN([MM_ARG_ENABLE_DOCUMENTATION],
[dnl
AC_BEFORE([$0], [MM_ARG_WITH_TAGFILE_DOC])[]dnl
AC_REQUIRE([_MM_PRE_INIT])[]dnl
+AC_REQUIRE([MM_PATH_PERL])[]dnl
AC_REQUIRE([MM_CONFIG_DOCTOOL_DIR])[]dnl
AC_REQUIRE([_MM_ARG_ENABLE_DOCUMENTATION])[]dnl
])
diff --git a/macros/mm-pkg.m4 b/macros/mm-pkg.m4
index b0634f3..0b8813b 100644
--- a/macros/mm-pkg.m4
+++ b/macros/mm-pkg.m4
@@ -1,4 +1,4 @@
-## Copyright (c) 2009 Daniel Elstner <daniel.kitta@gmail.com>
+## Copyright (c) 2009 Openismus GmbH <http://www.openismus.com/>
##
## This file is part of mm-common.
##
@@ -15,7 +15,57 @@
## You should have received a copy of the GNU General Public License
## along with mm-common. If not, see <http://www.gnu.org/licenses/>.
-#serial 20090814
+#serial 20090821
+
+## _MM_PATH_PERL
+##
+## Internal helper macro for MM_PATH_PERL.
+##
+m4_define([_MM_PATH_PERL],
+[dnl
+AC_PROVIDE([$0])[]dnl
+AC_ARG_VAR([PERL], [path to Perl interpreter])[]dnl
+AC_PATH_PROG([PERL], [perl], [perl])[]dnl
+])
+
+## MM_PATH_PERL
+##
+## Locate the Perl interpreter and set the substitution variable PERL
+## to the full path to the perl executable if found, or to 'perl' if
+## not found. Also call AC_ARG_VAR() on the PERL variable.
+##
+AC_DEFUN([MM_PATH_PERL],
+[dnl
+AC_REQUIRE([_MM_PRE_INIT])[]dnl
+AC_REQUIRE([_MM_PATH_PERL])[]dnl
+])
+
+## _MM_CHECK_PERL(min-version, [action-if-found], [action-if-not-found])
+##
+## Internal helper macro for MM_CHECK_PERL.
+##
+m4_define([_MM_CHECK_PERL],
+[dnl
+AS_IF([$PERL -e 'require v$1; exit 0;' >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD],
+ [$2], m4_ifval([$2$3], [[$3]],
+ [[AC_MSG_FAILURE([[At least Perl ]$1[ is required to build $PACKAGE.]])]]))[]dnl
+])
+
+## MM_CHECK_PERL([min-version], [action-if-found], [action-if-not-found])
+##
+## Run MM_PATH_PERL and then check whether the Perl interpreter can be
+## executed and whether it meets the version requirement of <min-version>
+## or later. Execute <action-if-found> on success, otherwise execute
+## <action-if-not-found>. The default value of <min-version> is 5.6.0
+## if the argument is empty.
+##
+AC_DEFUN([MM_CHECK_PERL],
+[dnl
+m4_assert([$# >= 2])[]dnl
+AC_REQUIRE([_MM_PRE_INIT])[]dnl
+AC_REQUIRE([_MM_PATH_PERL])[]dnl
+_MM_CHECK_PERL(m4_ifval([$1], [[$1]], [[5.6.0]]), [$2], [$3])[]dnl
+])
## MM_PKG_CONFIG_SUBST(variable, arguments, [action-if-found], [action-if-not-found])
##
@@ -31,11 +81,11 @@ m4_assert([$# >= 2])[]dnl
AC_REQUIRE([_MM_PRE_INIT])[]dnl
AC_REQUIRE([PKG_PROG_PKG_CONFIG])[]dnl
AC_MSG_CHECKING([for $1])
-
-AS_IF([test -z "${$1+set}"],
+dnl
+AS_IF([test -z "[$]{$1+set}"],
[$1=`$PKG_CONFIG $2 2>&AS_MESSAGE_LOG_FD`
AS_IF([test "[$]?" -eq 0], [$3], [$4])])
-
+dnl
AC_MSG_RESULT([[$]$1])
AC_SUBST([$1])[]dnl
])