m4/gst-parser.m4: Need to use double square brackets again so m4 doesn't remove them...
[platform/upstream/gst-common.git] / m4 / gst-parser.m4
1 AC_DEFUN([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   bison_min_version=1.35
12   bison_version=`$BISON_PATH --version | head -n 1 | sed 's/^.*) //' | sed 's/[[a-zA-Z]]*$//' | cut -d' ' -f1`
13   AC_MSG_CHECKING([bison version $bison_version >= $bison_min_version])
14
15   if perl -w <<EOF
16     exit ($bison_version < $bison_min_version) ? 0 : 1;
17 EOF 
18   then 
19     AC_MSG_RESULT([yes])
20   else 
21     AC_MSG_RESULT([no])
22     AC_MSG_ERROR([Your bison version is too old, $bison_min_version or later is required.])
23   fi
24 ])
25
26 AC_DEFUN([GST_FLEX_CHECK],
27 [
28   dnl we require flex for building the parser
29   dnl FIXME: check if AC_PROG_LEX is suitable here
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   flex_min_version=2.5.6
37   flex_version=`$FLEX_PATH --version | head -n 1 | sed 's/^.* //' | sed 's/[[a-zA-Z]]*$//' | cut -d' ' -f1`
38   AC_MSG_CHECKING([flex version $flex_version >= $flex_min_version])
39   if perl -w <<EOF
40     (\$min_version_major, \$min_version_minor, \$min_version_micro ) = "$flex_min_version" =~ /(\d+)\.(\d+)\.(\d+)/;
41     (\$flex_version_major, \$flex_version_minor, \$flex_version_micro ) = "$flex_version" =~ /(\d+)\.(\d+)\.(\d+)/;
42     exit (((\$flex_version_major > \$min_version_major) ||
43      ((\$flex_version_major == \$min_version_major) &&
44       (\$flex_version_minor >= \$min_version_minor)) ||
45      ((\$flex_version_major == \$min_version_major) &&
46       (\$flex_version_minor >= \$min_version_minor) &&
47       (\$flex_version_micro >= \$min_version_micro)))
48      ? 0 : 1);
49 EOF
50   then
51     AC_MSG_RESULT(yes)
52     AC_DEFINE(HAVE_MT_SAVE_FLEX, 1,
53       [Defined if we have recent enough flex, which is MT save])
54   else
55     AC_MSG_RESULT(no)
56   fi
57 ])