m4/gst-parser.m4: Fix bison version number detection for older --version output forma...
[platform/upstream/gst-common.git] / m4 / gst-parser.m4
1 AC_DEFUN([AG_GST_BISON_CHECK],
2 [
3   dnl FIXME: check if AC_PROG_YACC is suitable here
4   dnl FIXME: make precious
5   AC_PATH_PROG(BISON_PATH, bison, no)
6   if test x$BISON_PATH = xno; then
7     AC_MSG_ERROR(Could not find bison)
8   fi
9
10   dnl check bison version
11   dnl we need version >= 1.875 for the reentrancy support
12   dnl in the parser.
13   dnl First lines observed: 'bison (GNU Bison) 2.3' or 'GNU Bison version 1.28'
14   bison_min_version=1.875
15   bison_version=`$BISON_PATH --version | head -n 1 |  sed 's/^[[^0-9]]*//' | sed 's/[[^0-9]]*$//' | cut -d' ' -f1`
16   AC_MSG_CHECKING([bison version $bison_version >= $bison_min_version])
17
18   if perl -w <<EOF
19     exit ($bison_version < $bison_min_version) ? 0 : 1;
20 EOF 
21   then 
22     AC_MSG_RESULT([yes])
23   else 
24     AC_MSG_ERROR([no])
25   fi
26 ])
27
28 AC_DEFUN([AG_GST_FLEX_CHECK],
29 [
30   dnl we require flex for building the parser
31   AC_PATH_PROG(FLEX_PATH, flex, no)
32   if test x$FLEX_PATH = xno; then
33     AC_MSG_ERROR(Could not find flex)
34   fi
35   
36   dnl check flex version
37   dnl we need version >= 2.5.31 for the reentrancy support
38   dnl in the parser. 
39   flex_min_version=2.5.31
40   flex_version=`$FLEX_PATH --version | head -n 1 | sed 's/^.* //' | sed 's/[[a-zA-Z]]*$//' | cut -d' ' -f1`
41   AC_MSG_CHECKING([flex version $flex_version >= $flex_min_version])
42   if perl -w <<EOF
43     (\$min_version_major, \$min_version_minor, \$min_version_micro ) = "$flex_min_version" =~ /(\d+)\.(\d+)\.(\d+)/;
44     (\$flex_version_major, \$flex_version_minor, \$flex_version_micro ) = "$flex_version" =~ /(\d+)\.(\d+)\.(\d+)/;
45     exit (((\$flex_version_major > \$min_version_major) ||
46      ((\$flex_version_major == \$min_version_major) &&
47       (\$flex_version_minor > \$min_version_minor)) ||
48      ((\$flex_version_major == \$min_version_major) &&
49       (\$flex_version_minor == \$min_version_minor) &&
50       (\$flex_version_micro >= \$min_version_micro)))
51      ? 0 : 1);
52 EOF
53   then
54     AC_MSG_RESULT(yes)
55   else
56     AC_MSG_ERROR([no])
57   fi
58 ])