<div dir="ltr">Merged in master and stable-1.2, thanks!<div><br></div><div>Jérémie</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jul 2, 2015 at 3:12 PM, Jonathan Rajotte <span dir="ltr"><<a href="mailto:jonathan.rajotte-julien@efficios.com" target="_blank">jonathan.rajotte-julien@efficios.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This new m4 macro make check for a supported version of Bison.<br>
This macro is valid starting from commit id<br>
e79137accc7ea0352cd4677ff22818f9c68d4eab of the GNU Bison git tree[1].<br>
This check works for version 1.29b to this day.<br>
<br>
[1] <a href="http://git.savannah.gnu.org/cgit/bison.git/commit/?id=e79137accc7ea0352cd4677ff22818f9c68d4eab" rel="noreferrer" target="_blank">http://git.savannah.gnu.org/cgit/bison.git/commit/?id=e79137accc7ea0352cd4677ff22818f9c68d4eab</a><br>
<br>
Fixes: #891<br>
Signed-off-by: Jonathan Rajotte <<a href="mailto:jonathan.rajotte-julien@efficios.com">jonathan.rajotte-julien@efficios.com</a>><br>
---<br>
<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a> | 4 +<br>
m4/ax_compare_version.m4 | 177 ++++++++++++++++++++++++++++++++++++++++++++<br>
m4/ax_prog_bison_version.m4 | 64 ++++++++++++++++<br>
3 files changed, 245 insertions(+)<br>
create mode 100644 m4/ax_compare_version.m4<br>
create mode 100644 m4/ax_prog_bison_version.m4<br>
<br>
diff --git a/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a> b/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
index f8d43d8..3421cbd 100644<br>
--- a/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
+++ b/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
@@ -35,6 +35,10 @@ if test ! -f "$srcdir/formats/ctf/metadata/ctf-parser.h"; then<br>
AC_MSG_ERROR([[bison not found and is required when building from git.<br>
Please install bison]])<br>
fi<br>
+ AC_PATH_PROG([BISON],[bison])<br>
+ AX_PROG_BISON_VERSION([2.4], [],[<br>
+ AC_MSG_ERROR([[Bison >= 2.4 is required when building from git]])<br>
+ ])<br>
fi<br>
<br>
if test ! -f "$srcdir/formats/ctf/metadata/ctf-lexer.c"; then<br>
diff --git a/m4/ax_compare_version.m4 b/m4/ax_compare_version.m4<br>
new file mode 100644<br>
index 0000000..74dc0fd<br>
--- /dev/null<br>
+++ b/m4/ax_compare_version.m4<br>
@@ -0,0 +1,177 @@<br>
+# ===========================================================================<br>
+# <a href="http://www.gnu.org/software/autoconf-archive/ax_compare_version.html" rel="noreferrer" target="_blank">http://www.gnu.org/software/autoconf-archive/ax_compare_version.html</a><br>
+# ===========================================================================<br>
+#<br>
+# SYNOPSIS<br>
+#<br>
+# AX_COMPARE_VERSION(VERSION_A, OP, VERSION_B, [ACTION-IF-TRUE], [ACTION-IF-FALSE])<br>
+#<br>
+# DESCRIPTION<br>
+#<br>
+# This macro compares two version strings. Due to the various number of<br>
+# minor-version numbers that can exist, and the fact that string<br>
+# comparisons are not compatible with numeric comparisons, this is not<br>
+# necessarily trivial to do in a autoconf script. This macro makes doing<br>
+# these comparisons easy.<br>
+#<br>
+# The six basic comparisons are available, as well as checking equality<br>
+# limited to a certain number of minor-version levels.<br>
+#<br>
+# The operator OP determines what type of comparison to do, and can be one<br>
+# of:<br>
+#<br>
+# eq - equal (test A == B)<br>
+# ne - not equal (test A != B)<br>
+# le - less than or equal (test A <= B)<br>
+# ge - greater than or equal (test A >= B)<br>
+# lt - less than (test A < B)<br>
+# gt - greater than (test A > B)<br>
+#<br>
+# Additionally, the eq and ne operator can have a number after it to limit<br>
+# the test to that number of minor versions.<br>
+#<br>
+# eq0 - equal up to the length of the shorter version<br>
+# ne0 - not equal up to the length of the shorter version<br>
+# eqN - equal up to N sub-version levels<br>
+# neN - not equal up to N sub-version levels<br>
+#<br>
+# When the condition is true, shell commands ACTION-IF-TRUE are run,<br>
+# otherwise shell commands ACTION-IF-FALSE are run. The environment<br>
+# variable 'ax_compare_version' is always set to either 'true' or 'false'<br>
+# as well.<br>
+#<br>
+# Examples:<br>
+#<br>
+# AX_COMPARE_VERSION([3.15.7],[lt],[3.15.8])<br>
+# AX_COMPARE_VERSION([3.15],[lt],[3.15.8])<br>
+#<br>
+# would both be true.<br>
+#<br>
+# AX_COMPARE_VERSION([3.15.7],[eq],[3.15.8])<br>
+# AX_COMPARE_VERSION([3.15],[gt],[3.15.8])<br>
+#<br>
+# would both be false.<br>
+#<br>
+# AX_COMPARE_VERSION([3.15.7],[eq2],[3.15.8])<br>
+#<br>
+# would be true because it is only comparing two minor versions.<br>
+#<br>
+# AX_COMPARE_VERSION([3.15.7],[eq0],[3.15])<br>
+#<br>
+# would be true because it is only comparing the lesser number of minor<br>
+# versions of the two values.<br>
+#<br>
+# Note: The characters that separate the version numbers do not matter. An<br>
+# empty string is the same as version 0. OP is evaluated by autoconf, not<br>
+# configure, so must be a string, not a variable.<br>
+#<br>
+# The author would like to acknowledge Guido Draheim whose advice about<br>
+# the m4_case and m4_ifvaln functions make this macro only include the<br>
+# portions necessary to perform the specific comparison specified by the<br>
+# OP argument in the final configure script.<br>
+#<br>
+# LICENSE<br>
+#<br>
+# Copyright (c) 2008 Tim Toolan <<a href="mailto:toolan@ele.uri.edu">toolan@ele.uri.edu</a>><br>
+#<br>
+# Copying and distribution of this file, with or without modification, are<br>
+# permitted in any medium without royalty provided the copyright notice<br>
+# and this notice are preserved. This file is offered as-is, without any<br>
+# warranty.<br>
+<br>
+#serial 11<br>
+<br>
+dnl #########################################################################<br>
+AC_DEFUN([AX_COMPARE_VERSION], [<br>
+ AC_REQUIRE([AC_PROG_AWK])<br>
+<br>
+ # Used to indicate true or false condition<br>
+ ax_compare_version=false<br>
+<br>
+ # Convert the two version strings to be compared into a format that<br>
+ # allows a simple string comparison. The end result is that a version<br>
+ # string of the form 1.12.5-r617 will be converted to the form<br>
+ # 0001001200050617. In other words, each number is zero padded to four<br>
+ # digits, and non digits are removed.<br>
+ AS_VAR_PUSHDEF([A],[ax_compare_version_A])<br>
+ A=`echo "$1" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \<br>
+ -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \<br>
+ -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \<br>
+ -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \<br>
+ -e 's/[[^0-9]]//g'`<br>
+<br>
+ AS_VAR_PUSHDEF([B],[ax_compare_version_B])<br>
+ B=`echo "$3" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \<br>
+ -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \<br>
+ -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \<br>
+ -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \<br>
+ -e 's/[[^0-9]]//g'`<br>
+<br>
+ dnl # In the case of le, ge, lt, and gt, the strings are sorted as necessary<br>
+ dnl # then the first line is used to determine if the condition is true.<br>
+ dnl # The sed right after the echo is to remove any indented white space.<br>
+ m4_case(m4_tolower($2),<br>
+ [lt],[<br>
+ ax_compare_version=`echo "x$A<br>
+x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/false/;s/x${B}/true/;1q"`<br>
+ ],<br>
+ [gt],[<br>
+ ax_compare_version=`echo "x$A<br>
+x$B" | sed 's/^ *//' | sort | sed "s/x${A}/false/;s/x${B}/true/;1q"`<br>
+ ],<br>
+ [le],[<br>
+ ax_compare_version=`echo "x$A<br>
+x$B" | sed 's/^ *//' | sort | sed "s/x${A}/true/;s/x${B}/false/;1q"`<br>
+ ],<br>
+ [ge],[<br>
+ ax_compare_version=`echo "x$A<br>
+x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/true/;s/x${B}/false/;1q"`<br>
+ ],[<br>
+ dnl Split the operator from the subversion count if present.<br>
+ m4_bmatch(m4_substr($2,2),<br>
+ [0],[<br>
+ # A count of zero means use the length of the shorter version.<br>
+ # Determine the number of characters in A and B.<br>
+ ax_compare_version_len_A=`echo "$A" | $AWK '{print(length)}'`<br>
+ ax_compare_version_len_B=`echo "$B" | $AWK '{print(length)}'`<br>
+<br>
+ # Set A to no more than B's length and B to no more than A's length.<br>
+ A=`echo "$A" | sed "s/\(.\{$ax_compare_version_len_B\}\).*/\1/"`<br>
+ B=`echo "$B" | sed "s/\(.\{$ax_compare_version_len_A\}\).*/\1/"`<br>
+ ],<br>
+ [[0-9]+],[<br>
+ # A count greater than zero means use only that many subversions<br>
+ A=`echo "$A" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"`<br>
+ B=`echo "$B" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"`<br>
+ ],<br>
+ [.+],[<br>
+ AC_WARNING(<br>
+ [illegal OP numeric parameter: $2])<br>
+ ],[])<br>
+<br>
+ # Pad zeros at end of numbers to make same length.<br>
+ ax_compare_version_tmp_A="$A`echo $B | sed 's/./0/g'`"<br>
+ B="$B`echo $A | sed 's/./0/g'`"<br>
+ A="$ax_compare_version_tmp_A"<br>
+<br>
+ # Check for equality or inequality as necessary.<br>
+ m4_case(m4_tolower(m4_substr($2,0,2)),<br>
+ [eq],[<br>
+ test "x$A" = "x$B" && ax_compare_version=true<br>
+ ],<br>
+ [ne],[<br>
+ test "x$A" != "x$B" && ax_compare_version=true<br>
+ ],[<br>
+ AC_WARNING([illegal OP parameter: $2])<br>
+ ])<br>
+ ])<br>
+<br>
+ AS_VAR_POPDEF([A])dnl<br>
+ AS_VAR_POPDEF([B])dnl<br>
+<br>
+ dnl # Execute ACTION-IF-TRUE / ACTION-IF-FALSE.<br>
+ if test "$ax_compare_version" = "true" ; then<br>
+ m4_ifvaln([$4],[$4],[:])dnl<br>
+ m4_ifvaln([$5],[else $5])dnl<br>
+ fi<br>
+]) dnl AX_COMPARE_VERSION<br>
diff --git a/m4/ax_prog_bison_version.m4 b/m4/ax_prog_bison_version.m4<br>
new file mode 100644<br>
index 0000000..6b95585<br>
--- /dev/null<br>
+++ b/m4/ax_prog_bison_version.m4<br>
@@ -0,0 +1,64 @@<br>
+# SYNOPSIS<br>
+#<br>
+# AX_PROG_BISON_VERSION([VERSION],[ACTION-IF-TRUE],[ACTION-IF-FALSE])<br>
+#<br>
+# DESCRIPTION<br>
+#<br>
+# Makes sure that bison version is greater or equal to the version indicated.<br>
+# If true the shell commands in ACTION-IF-TRUE are executed. If not the shell<br>
+# commands in commands in ACTION-IF-TRUE are executed. If not the shell<br>
+# commands in ACTION-IF-FALSE are run. Note if $BISON is not set (for example<br>
+# by running AC_CHECK_PROG or AC_PATH_PROG) the macro will fail.<br>
+#<br>
+# Example:<br>
+#<br>
+# AC_PATH_PROG([BISON],[bison])<br>
+# AX_PROG_BISON_VERSION([3.0.2],[ ... ],[ ... ])<br>
+#<br>
+# This will check to make sure that the bison you have is at least<br>
+# version 3.0.2 or greater.<br>
+#<br>
+# NOTE: This macro uses the $BISON variable to perform the check.<br>
+#<br>
+# LICENSE<br>
+#<br>
+# Copyright (c) 2015 Jonathan Rajotte-Julien <<a href="mailto:jonathan.rajotte-julien@efficios.com">jonathan.rajotte-julien@efficios.com</a>><br>
+#<br>
+# Copying and distribution of this file, with or without modification, are<br>
+# permitted in any medium without royalty provided the copyright notice<br>
+# and this notice are preserved. This file is offered as-is, without any<br>
+# warranty.<br>
+<br>
+#serial 12<br>
+<br>
+AC_DEFUN([AX_PROG_BISON_VERSION],[<br>
+ AC_REQUIRE([AC_PROG_SED])<br>
+ AC_REQUIRE([AC_PROG_GREP])<br>
+<br>
+ AS_IF([test -n "$BISON"],[<br>
+ ax_bison_version="$1"<br>
+<br>
+ AC_MSG_CHECKING([for bison version])<br>
+ changequote(<<,>>)<br>
+ bison_version=`$BISON --version 2>&1 \<br>
+ | $SED -n -e '/bison (GNU Bison)/b inspect<br>
+b<br>
+: inspect<br>
+s/.* (\{0,1\}\([0-9]*\.[0-9]*\.[0-9]*\))\{0,1\}.*/\1/;p'`<br>
+ changequote([,])<br>
+ AC_MSG_RESULT($bison_version)<br>
+<br>
+ AC_SUBST([BISON_VERSION],[$bison_version])<br>
+<br>
+ AX_COMPARE_VERSION([$bison_version],[ge],[$ax_bison_version],[<br>
+ :<br>
+ $2<br>
+ ],[<br>
+ :<br>
+ $3<br>
+ ])<br>
+ ],[<br>
+ AC_MSG_WARN([could not find bison])<br>
+ $3<br>
+ ])<br>
+])<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.1.4<br>
<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Jérémie Galarneau<br>EfficiOS Inc.<br><a href="http://www.efficios.com" target="_blank">http://www.efficios.com</a></div>
</div>