m4/gst-parser.m4: Unconditionally require flex 2.5.31 and bison 1.875.
[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   bison_min_version=1.875
14   bison_version=`$BISON_PATH --version | head -n 1 | sed 's/^.*) //' | sed 's/[[a-zA-Z]]*$//' | cut -d' ' -f1`
15   AC_MSG_CHECKING([bison version $bison_version >= $bison_min_version])
16
17   if perl -w <<EOF
18     exit ($bison_version < $bison_min_version) ? 0 : 1;
19 EOF 
20   then 
21     AC_MSG_RESULT([yes])
22   else 
23     AC_MSG_ERROR([no])
24   fi
25 ])
26
27 AC_DEFUN([AG_GST_FLEX_CHECK],
28 [
29   dnl we require flex for building the parser
30   AC_PATH_PROG(FLEX_PATH, flex, no)
31   if test x$FLEX_PATH = xno; then
32     AC_MSG_ERROR(Could not find flex)
33   fi
34   
35   dnl check flex version
36   dnl we need version >= 2.5.31 for the reentrancy support
37   dnl in the parser. 
38   flex_min_version=2.5.31
39   flex_version=`$FLEX_PATH --version | head -n 1 | sed 's/^.* //' | sed 's/[[a-zA-Z]]*$//' | cut -d' ' -f1`
40   AC_MSG_CHECKING([flex version $flex_version >= $flex_min_version])
41   if perl -w <<EOF
42     (\$min_version_major, \$min_version_minor, \$min_version_micro ) = "$flex_min_version" =~ /(\d+)\.(\d+)\.(\d+)/;
43     (\$flex_version_major, \$flex_version_minor, \$flex_version_micro ) = "$flex_version" =~ /(\d+)\.(\d+)\.(\d+)/;
44     exit (((\$flex_version_major > \$min_version_major) ||
45      ((\$flex_version_major == \$min_version_major) &&
46       (\$flex_version_minor > \$min_version_minor)) ||
47      ((\$flex_version_major == \$min_version_major) &&
48       (\$flex_version_minor == \$min_version_minor) &&
49       (\$flex_version_micro >= \$min_version_micro)))
50      ? 0 : 1);
51 EOF
52   then
53     AC_MSG_RESULT(yes)
54   else
55     AC_MSG_ERROR([no])
56   fi
57 ])