[mm-common] Implement MM_PREREQ() Autoconf macro



commit c9f22e1c767efaa916e82de5b0dbea7b18fe0670
Author: Daniel Elstner <daniel kitta gmail com>
Date:   Sat Aug 15 00:05:08 2009 +0200

    Implement MM_PREREQ() Autoconf macro
    
    * macros/mm-common.m4.in: New configure input file.
    (_MM_PRE_INIT): Move macro from mm-module.m4 to mm-common.m4.
    (MM_PREREQ): Implement a version check macro akin to AC_PREREQ() and
    similar macros.  This may be used to ensure the presence of a minimum
    version of the mm-common package at the time the configure script is
    generated, should the need ever arise.
    * configure.ac (AC_CONFIG_FILES): Add output file macros/mm-common.m4.
    * Makefile.am (aclocal_macro_DATA): Install macros/mm-common.m4.

 .gitignore             |    1 +
 Makefile.am            |    1 +
 configure.ac           |    1 +
 macros/mm-common.m4.in |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 50 insertions(+), 0 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 43fc048..ef82553 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,4 +12,5 @@
 /mm-common-*.tar.*
 /doctags/libstdc++.tag
 /doctags/mm-common-*.pc
+/macros/mm-common.m4
 /util/mm-common-prepare
diff --git a/Makefile.am b/Makefile.am
index d135f4e..e79e9ba 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -28,6 +28,7 @@ dist_build_support_DATA =		\
 	build/generate-binding.am
 
 aclocal_macrodir = $(datadir)/aclocal
+aclocal_macro_DATA = macros/mm-common.m4
 dist_aclocal_macro_DATA =		\
 	macros/mm-doc.m4		\
 	macros/mm-module.m4		\
diff --git a/configure.ac b/configure.ac
index d4f6e34..93be16c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -35,5 +35,6 @@ AS_IF([test "x$USE_MAINTAINER_MODE" != xno && test "x$CURL$WGET" = x],
 AC_CONFIG_FILES([Makefile
                  doctags/mm-common-libstdc++.pc
                  doctags/mm-common-libstdc++-uninstalled.pc
+                 macros/mm-common.m4
                  util/mm-common-prepare])
 AC_OUTPUT
diff --git a/macros/mm-common.m4.in b/macros/mm-common.m4.in
new file mode 100644
index 0000000..b616327
--- /dev/null
+++ b/macros/mm-common.m4.in
@@ -0,0 +1,47 @@
+## Copyright (c) 2009  Openismus GmbH  <http://www.openismus.com/>
+##
+## @configure_input@
+##
+## 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([ PACKAGE_NAME@], [ PACKAGE_VERSION@], [$1], m4_defn([AC_PACKAGE_NAME]))[]dnl
+])



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