[gnome-builder] build: add helper m4 modules



commit a62d6924a917615cf88238cbb1b096fa3d52f88d
Author: Christian Hergert <chergert redhat com>
Date:   Tue Oct 11 21:06:52 2016 -0700

    build: add helper m4 modules

 build/autotools/mm-common.m4 |   47 ++++++++
 build/autotools/mm-doc.m4    |  252 ++++++++++++++++++++++++++++++++++++++++++
 build/autotools/mm-module.m4 |   87 +++++++++++++++
 build/autotools/mm-pkg.m4    |  123 ++++++++++++++++++++
 4 files changed, 509 insertions(+), 0 deletions(-)
---
diff --git a/build/autotools/mm-common.m4 b/build/autotools/mm-common.m4
new file mode 100644
index 0000000..c7bff59
--- /dev/null
+++ b/build/autotools/mm-common.m4
@@ -0,0 +1,47 @@
+## Copyright (c) 2009  Openismus GmbH  <http://www.openismus.com/>
+##
+## macros/mm-common.m4.  Generated from mm-common.m4.in by configure.
+##
+## mm-common is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published
+## by the Free Software Foundation, either version 2 of the License,
+## or (at your option) any later version.
+##
+## mm-common is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## 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
+
+## _MM_PRE_INIT
+##
+## Private pre-initialization macro for use with AC_REQUIRE().  For now,
+## all it does is register a forbidden token pattern with autom4te, so
+## that unexpanded macro calls in the output can be caught.
+##
+AC_DEFUN([_MM_PRE_INIT], [m4_pattern_forbid([^_?MM_])])
+
+## _MM_PREREQ(this-package, this-version, min-version, user-package)
+##
+m4_define([_MM_PREREQ],
+[dnl
+m4_if(m4_quote(m4_version_compare([$2], [$3])), [-1],
+      [m4_fatal([$4 requires $1 $3 (version $2 is installed)])])[]dnl
+])
+
+## MM_PREREQ(min-version)
+##
+## Require at least mm-common <min-version> to be installed, otherwise
+## abort with a fatal error message.  The version is checked statically
+## at the time the configure script is generated.
+##
+AC_DEFUN([MM_PREREQ],
+[dnl
+m4_assert([$# >= 1])[]dnl
+AC_REQUIRE([_MM_PRE_INIT])[]dnl
+_MM_PREREQ([mm-common], [0.9.10], [$1], m4_defn([AC_PACKAGE_NAME]))[]dnl
+])
diff --git a/build/autotools/mm-doc.m4 b/build/autotools/mm-doc.m4
new file mode 100644
index 0000000..1e89f7d
--- /dev/null
+++ b/build/autotools/mm-doc.m4
@@ -0,0 +1,252 @@
+## Copyright (c) 2009, 2010, 2011  Openismus GmbH  <http://www.openismus.com/>
+##
+## This file is part of mm-common.
+##
+## mm-common is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published
+## by the Free Software Foundation, either version 2 of the License,
+## or (at your option) any later version.
+##
+## mm-common is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## 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 20110327
+
+## _MM_CONFIG_DOCTOOL_DIR
+##
+## Query pkg-config for the location of the documentation utilities
+## shared by the GNOME C++ bindings.  This is the code path invoked
+## from MM_CONFIG_DOCTOOL_DIR when called without a directory name.
+##
+m4_define([_MM_CONFIG_DOCTOOL_DIR],
+[dnl
+AC_PROVIDE([$0])[]dnl
+AC_REQUIRE([PKG_PROG_PKG_CONFIG])[]dnl
+dnl
+AC_MSG_CHECKING([location of documentation utilities])
+AS_IF([test "x$MMDOCTOOLDIR" = x],
+[
+  MMDOCTOOLDIR=`$PKG_CONFIG --variable=doctooldir mm-common-util 2>&AS_MESSAGE_LOG_FD`
+  AS_IF([test "[$]?" -ne 0],
+        [AC_MSG_ERROR([[not found
+The required module mm-common-util could not be found on this system.  If you
+are running a binary distribution and the mm-common package is installed,
+make sure that any separate development package for mm-common is installed
+as well.  If you built mm-common yourself, it may be necessary to adjust
+the PKG_CONFIG_PATH environment variable for pkg-config to find it.
+]])])
+])
+AC_MSG_RESULT([$MMDOCTOOLDIR])[]dnl
+])
+
+## MM_CONFIG_DOCTOOL_DIR([directory])
+##
+## Define the location of the documentation utilities shared by the
+## GNOME C++ binding modules.  If the <directory> argument is given,
+## it should name a directory relative to the toplevel directory of
+## the source tree.
+##
+## The directory name is used by mm-common-prepare as the destination
+## for copying the required files into the source tree.  The files are not
+## distributed if first parameter is empty.
+##
+AC_DEFUN([MM_CONFIG_DOCTOOL_DIR],
+[dnl
+AC_REQUIRE([_MM_PRE_INIT])[]dnl
+AC_REQUIRE([MM_CHECK_GNU_MAKE])[]dnl
+m4_ifval([$1], [MMDOCTOOLDIR='[$]{top_srcdir}/$1'], [AC_REQUIRE([_MM_CONFIG_DOCTOOL_DIR])])
+AM_CONDITIONAL([DIST_DOCTOOLS], [test 'x$1' != 'x'])dnl
+AC_SUBST([MMDOCTOOLDIR])[]dnl
+])
+
+## _MM_ARG_ENABLE_DOCUMENTATION
+##
+## Implementation of MM_ARG_ENABLE_DOCUMENTATION, pulled in indirectly
+## through AC_REQUIRE() to make sure it is expanded only once.
+##
+m4_define([_MM_ARG_ENABLE_DOCUMENTATION],
+[dnl
+AC_PROVIDE([$0])[]dnl
+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([DOT], [dot], [dot])
+AC_PATH_PROG([DOXYGEN], [doxygen], [doxygen])
+AC_PATH_PROG([XSLTPROC], [xsltproc], [xsltproc])
+dnl
+AC_ARG_ENABLE([documentation],
+              [AS_HELP_STRING([--disable-documentation],
+                              [do not build or install the documentation])],
+              [ENABLE_DOCUMENTATION=$enableval],
+              [ENABLE_DOCUMENTATION=auto])
+AS_IF([test "x$ENABLE_DOCUMENTATION" != xno],
+[
+  mm_err=
+  AS_IF([test "x$MMDOCTOOLDIR" = x], [mm_err='dnl
+The mm-common-util module is available, but the installation of mm-common on this
+machine is missing the shared documentation utilities of the GNOME C++
+bindings.  It may be necessary to upgrade to a more recent release of
+mm-common in order to build '$PACKAGE_NAME' and install the documentation.'],
+        [test "x$PERL" = xperl], [mm_err='Perl is required for installing the documentation.'],
+        [test "x$USE_MAINTAINER_MODE" != xno],
+  [
+    test "x$DOT" != xdot || mm_err=' dot'
+    test "x$DOXYGEN" != xdoxygen || mm_err="$mm_err doxygen"
+    test "x$XSLTPROC" != xxsltproc || mm_err="$mm_err xsltproc"
+    test -z "$mm_err" || mm_err='The documentation cannot be generated because
+not all of the required tools are available:'$mm_err
+  ])
+  AS_IF([test -z "$mm_err"], [ENABLE_DOCUMENTATION=yes],
+        [test "x$ENABLE_DOCUMENTATION" = xyes], [AC_MSG_FAILURE([[$mm_err]])],
+        [ENABLE_DOCUMENTATION=no; AC_MSG_WARN([[$mm_err]])])
+])
+AM_CONDITIONAL([ENABLE_DOCUMENTATION], [test "x$ENABLE_DOCUMENTATION" = xyes])
+AC_SUBST([DOXYGEN_TAGFILES], [[]])
+AC_SUBST([DOCINSTALL_FLAGS], [[]])[]dnl
+])
+
+## MM_ARG_ENABLE_DOCUMENTATION
+##
+## Provide the --disable-documentation configure option.  By default,
+## the documentation will be included in the build.  If not explicitly
+## disabled, also check whether the necessary tools are installed, and
+## abort if any are missing.
+##
+## The tools checked for are Perl, dot, Doxygen and xsltproc.  The
+## substitution variables PERL, DOT, DOXYGEN and XSLTPROC are set to
+## the command paths, unless overridden in the user environment.
+##
+## If the package provides the --enable-maintainer-mode option, the
+## tools dot, Doxygen and xsltproc are mandatory only when maintainer
+## mode is enabled.  Perl is required for the installdox utility even
+## if not in maintainer mode.
+##
+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_CONFIG_DOCTOOL_DIR])[]dnl
+AC_REQUIRE([MM_PATH_PERL])[]dnl
+AC_REQUIRE([_MM_ARG_ENABLE_DOCUMENTATION])[]dnl
+])
+
+## _MM_TR_URI(shell-expression)
+##
+## Internal macro that expands to a reusable shell construct which
+## functions as a poor man's filesystem path to URI translator.
+## The input <shell-expression> is expanded within double quotes.
+##
+m4_define([_MM_TR_URI],
+[dnl
+[`expr "X$1" : 'X\(.*[^\\/]\)[\\/]*' 2>&]AS_MESSAGE_LOG_FD[ |]dnl
+[ sed 's|[\\]|/|g;s| |%20|g;s|^/|file:///|;s|^.:/|file:///&|' 2>&]AS_MESSAGE_LOG_FD[`]dnl
+])
+
+## _MM_ARG_WITH_TAGFILE_DOC(option-basename, pkg-variable, tagfilename, [module])
+##
+m4_define([_MM_ARG_WITH_TAGFILE_DOC],
+[dnl
+  AC_MSG_CHECKING([for $1 documentation])
+  AC_ARG_WITH([$1-doc],
+              [AS_HELP_STRING([[--with-$1-doc=[TAGFILE@]HTMLREFDIR]],
+                              [Link to external $1 documentation]m4_ifval([$4], [[ [auto]]]))],
+  [
+    mm_htmlrefdir=`[expr "X@$withval" : '.*@\(.*\)' 2>&]AS_MESSAGE_LOG_FD`
+    mm_tagname=`[expr "X/$withval" : '[^@]*[\\/]\([^\\/@]*\)@' 2>&]AS_MESSAGE_LOG_FD`
+    mm_tagpath=`[expr "X$withval" : 'X\([^@]*\)@' 2>&]AS_MESSAGE_LOG_FD`
+    test "x$mm_tagname" != x || mm_tagname="$3"
+    test "x$mm_tagpath" != x || mm_tagpath=$mm_tagname[]dnl
+  ], [
+    mm_htmlrefdir=
+    mm_tagname="$3"
+    mm_tagpath=$mm_tagname[]dnl
+  ])
+  # Prepend working direcory if the tag file path starts with ./ or ../
+  AS_CASE([$mm_tagpath], [[.[\\/]*|..[\\/]*]], [mm_tagpath=`pwd`/$mm_tagpath])
+
+m4_ifval([$4], [dnl
+  # If no local directory was specified, get the default from the .pc file
+  AS_IF([test "x$mm_htmlrefdir" = x],
+  [
+    mm_htmlrefdir=`$PKG_CONFIG --variable=htmlrefdir "$4" 2>&AS_MESSAGE_LOG_FD`dnl
+  ])
+  # If the user specified a Web URL, allow it to override the public location
+  AS_CASE([$mm_htmlrefdir], [[http://*|https://*]], [mm_htmlrefpub=$mm_htmlrefdir],
+  [
+    mm_htmlrefpub=`$PKG_CONFIG --variable=htmlrefpub "$4" 2>&AS_MESSAGE_LOG_FD`
+    test "x$mm_htmlrefpub" != x || mm_htmlrefpub=$mm_htmlrefdir
+    test "x$mm_htmlrefdir" != x || mm_htmlrefdir=$mm_htmlrefpub
+  ])
+  # The user-supplied tag-file name takes precedence if it includes the path
+  AS_CASE([$mm_tagpath], [[*[\\/]*]],,
+  [
+    mm_doxytagfile=`$PKG_CONFIG --variable=doxytagfile "$4" 2>&AS_MESSAGE_LOG_FD`
+    test "x$mm_doxytagfile" = x || mm_tagpath=$mm_doxytagfile
+  ])
+  # Remove trailing slashes and translate to URI
+  mm_htmlrefpub=_MM_TR_URI([$mm_htmlrefpub])
+])[]dnl
+  mm_htmlrefdir=_MM_TR_URI([$mm_htmlrefdir])
+
+  AC_MSG_RESULT([$mm_tagpath@$mm_htmlrefdir])
+
+  AS_IF([test "x$USE_MAINTAINER_MODE" != xno && test ! -f "$mm_tagpath"],
+        [AC_MSG_WARN([Doxygen tag file $3 not found])])
+  AS_IF([test "x$mm_htmlrefdir" = x],
+        [AC_MSG_WARN([Location of external $1 documentation not set])],
+        [AS_IF([test "x$DOCINSTALL_FLAGS" = x],
+               [DOCINSTALL_FLAGS="-l '$mm_tagname@$mm_htmlrefdir/'"],
+               [DOCINSTALL_FLAGS="$DOCINSTALL_FLAGS -l '$mm_tagname@$mm_htmlrefdir/'"])])
+
+  AS_IF([test "x$mm_$2" = x], [mm_val=$mm_tagpath], [mm_val="$mm_tagpath=$mm_$2"])
+  AS_IF([test "x$DOXYGEN_TAGFILES" = x],
+        [DOXYGEN_TAGFILES=[\]"$mm_val[\]"],
+        [DOXYGEN_TAGFILES="$DOXYGEN_TAGFILES "[\]"$mm_val[\]"])[]dnl
+])
+
+## MM_ARG_WITH_TAGFILE_DOC(tagfilename, [module])
+##
+## Provide a --with-<tagfilebase>-doc=[/path/tagfile@]htmlrefdir configure
+## option, which may be used to specify the location of a tag file and the
+## path to the corresponding HTML reference documentation.  If the project
+## provides the maintainer mode option and maintainer mode is not enabled,
+## the user does not have to provide the full path to the tag file.  The
+## full path is only required for rebuilding the documentation.
+##
+## If the optional <module> argument has been specified, and either the tag
+## file or the HTML location have not been overridden by the user already,
+## try to retrieve the missing paths automatically via pkg-config.  Also ask
+## pkg-config for the URI to the online documentation, for use as the preset
+## location when the documentation is generated.
+##
+## A warning message will be shown if the HTML path could not be determined.
+## If maintainer mode is active, a warning is also displayed if the tag file
+## could not be found.
+##
+## The results are appended to the substitution variables DOXYGEN_TAGFILES
+## and DOCINSTALL_FLAGS, using the following format:
+##
+##  DOXYGEN_TAGFILES = "/path/tagfile=htmlrefpub" [...]
+##  DOCINSTALL_FLAGS = -l 'tagfile@htmlrefdir' [...]
+##
+## The substitutions are intended to be used for the Doxygen configuration,
+## and as argument list to the doc-install.pl or installdox utility.
+##
+AC_DEFUN([MM_ARG_WITH_TAGFILE_DOC],
+[dnl
+m4_assert([$# >= 1])[]dnl
+m4_ifval([$2], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])])[]dnl
+AC_REQUIRE([MM_CONFIG_DOCTOOL_DIR])[]dnl
+AC_REQUIRE([_MM_ARG_ENABLE_DOCUMENTATION])[]dnl
+dnl
+AS_IF([test "x$ENABLE_DOCUMENTATION" != xno],
+      [_MM_ARG_WITH_TAGFILE_DOC(m4_quote(m4_bpatsubst([$1], [[+]*\([-+][0123456789]\|[._]\).*$])),
+                                [htmlref]m4_ifval([$2], [[pub]], [[dir]]), [$1], [$2])])[]dnl
+])
diff --git a/build/autotools/mm-module.m4 b/build/autotools/mm-module.m4
new file mode 100644
index 0000000..028edea
--- /dev/null
+++ b/build/autotools/mm-module.m4
@@ -0,0 +1,87 @@
+## Copyright (c) 2009  Openismus GmbH  <http://www.openismus.com/>
+##
+## This file is part of mm-common.
+##
+## mm-common is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published
+## by the Free Software Foundation, either version 2 of the License,
+## or (at your option) any later version.
+##
+## mm-common is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## 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 20091228
+
+## _MM_INIT_MODULE_VERSION(basename, BASENAME, [major], [minor], [micro])
+##
+m4_define([_MM_INIT_MODULE_VERSION],
+[dnl
+m4_ifval([$3],
+[AC_SUBST([$2][_MAJOR_VERSION], [$3])
+AC_DEFINE([$2][_MAJOR_VERSION], [$3], [Major version number of $1.])
+])[]dnl
+m4_ifval([$4],
+[AC_SUBST([$2][_MINOR_VERSION], [$4])
+AC_DEFINE([$2][_MINOR_VERSION], [$4], [Minor version number of $1.])
+])[]dnl
+m4_ifval([$5],
+[AC_SUBST([$2][_MICRO_VERSION], [$5])
+AC_DEFINE([$2][_MICRO_VERSION], [$5], [Micro version number of $1.])
+])[]dnl
+])
+
+## _MM_INIT_MODULE_SUBST(module-name, module-version, basename, api-version, BASENAME)
+##
+m4_define([_MM_INIT_MODULE_SUBST],
+[dnl
+AC_SUBST([$5][_MODULE_NAME], ['$1'])
+AC_SUBST([$5][_VERSION], ['$2'])
+m4_ifval([$4],
+[AC_SUBST([$5][_API_VERSION], ['$4'])
+])[]dnl
+_MM_INIT_MODULE_VERSION([$3], [$5], m4_bpatsubst([$2], [[^0123456789]+], [,]))[]dnl
+])
+
+## _MM_INIT_MODULE_BASENAME(module-name, module-version, basename, api-version)
+##
+m4_define([_MM_INIT_MODULE_BASENAME],
+          [_MM_INIT_MODULE_SUBST([$1], [$2], [$3], [$4],
+                                 m4_quote(AS_TR_CPP(m4_quote(m4_translit([$3], [+], [X])))))])
+
+## MM_INIT_MODULE(module-name, [module-version])
+##
+## Set up substitution variables and macro definitions for a module with
+## the specified pkg-config <module-name> and <module-version> triplet.
+## If no <module-version> is specified, it defaults to the expansion of
+## AC_PACKAGE_VERSION.
+##
+## Substitutions: <BASENAME>_MODULE_NAME        <module-name>
+##                <BASENAME>_VERSION            <module-version>
+##                <BASENAME>_API_VERSION        <api-version>
+##                <BASENAME>_MAJOR_VERSION      <major>
+##                <BASENAME>_MINOR_VERSION      <minor>
+##                <BASENAME>_MICRO_VERSION      <micro>
+##
+## Macro defines: <BASENAME>_MAJOR_VERSION      <major>
+##                <BASENAME>_MINOR_VERSION      <minor>
+##                <BASENAME>_MICRO_VERSION      <micro>
+##
+## Where:         <BASENAME>                    AS_TR_CPP(<basename> =~ tr/+/X/)
+##                <basename>[-<api-version>]    <module-name>
+##                <major>.<minor>.<micro>[.*]   <module-version>
+##
+AC_DEFUN([MM_INIT_MODULE],
+[dnl
+m4_assert([$# >= 1])[]dnl
+AC_REQUIRE([_MM_PRE_INIT])[]dnl
+AC_REQUIRE([MM_CHECK_GNU_MAKE])[]dnl
+_MM_INIT_MODULE_BASENAME([$1],
+                 m4_quote(m4_ifval([$2], [$2], m4_defn([AC_PACKAGE_VERSION]))),
+                 m4_quote(m4_bpatsubst([$1], [[-.0123456789]+$])),
+                 m4_quote(m4_bregexp([$1], [-?\([.0123456789]+\)$], [\1])))[]dnl
+])
diff --git a/build/autotools/mm-pkg.m4 b/build/autotools/mm-pkg.m4
new file mode 100644
index 0000000..86f94d2
--- /dev/null
+++ b/build/autotools/mm-pkg.m4
@@ -0,0 +1,123 @@
+## Copyright (c) 2009  Openismus GmbH  <http://www.openismus.com/>
+##
+## This file is part of mm-common.
+##
+## mm-common is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published
+## by the Free Software Foundation, either version 2 of the License,
+## or (at your option) any later version.
+##
+## mm-common is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## 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 20090822
+
+## _MM_CHECK_GNU_MAKE
+##
+## Implementation of MM_CHECK_GNU_MAKE.
+##
+m4_define([_MM_CHECK_GNU_MAKE],
+[dnl
+AC_PROVIDE([$0])[]dnl
+AC_MSG_CHECKING([whether [$]{MAKE-make} supports GNU make features])
+cat >conftest.make <<'_MMEOF'
+override reverse = [$](2)[$](subst ,, )[$](1)
+override result := [$](word 2,[$](call reverse,success,failure))
+all: ; test '[$](result)' = success
+.PHONY: all
+_MMEOF
+AS_IF([[$]{MAKE-make} -f conftest.make >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD],
+      [mm_gnu_make=yes], [mm_gnu_make=no])
+rm -f conftest.make
+AC_MSG_RESULT([$mm_gnu_make])
+AS_IF([test "x$mm_gnu_make" != xyes],
+      [AC_MSG_FAILURE([[The GNU make program is required to build $PACKAGE_NAME.]])])[]dnl
+])
+
+## MM_CHECK_GNU_MAKE
+##
+## Check whether the installed make program supports GNU make features.
+## If the test fails, display an error message and abort.
+##
+AC_DEFUN([MM_CHECK_GNU_MAKE],
+[dnl
+AC_REQUIRE([_MM_PRE_INIT])[]dnl
+AC_REQUIRE([_MM_CHECK_GNU_MAKE])[]dnl
+])
+
+## _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_NAME.]])]]))[]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
+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])
+##
+## Run the pkg-config utility with the specified command-line <arguments>
+## and capture its standard output in the named shell <variable>.  If the
+## command exited successfully, execute <action-if-found> in the shell if
+## specified.  If the command failed, run <action-if-not-found> if given,
+## otherwise ignore the error.
+##
+AC_DEFUN([MM_PKG_CONFIG_SUBST],
+[dnl
+m4_assert([$# >= 2])[]dnl
+AC_REQUIRE([_MM_PRE_INIT])[]dnl
+AC_REQUIRE([PKG_PROG_PKG_CONFIG])[]dnl
+AC_MSG_CHECKING([for $1])
+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
+])


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]