From: mquinson Date: Fri, 4 Feb 2005 11:23:25 +0000 (+0000) Subject: A proper macro to test the flex version X-Git-Tag: v3.3~4494 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/a47fa7dc6a96461ec3f71dbf52c0cd48308e48c5 A proper macro to test the flex version git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@857 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/acmacro/flex.m4 b/acmacro/flex.m4 new file mode 100644 index 0000000000..1821e617d3 --- /dev/null +++ b/acmacro/flex.m4 @@ -0,0 +1,50 @@ +dnl AC_PROG_FLEX: Check whether the LEXer is flex, and which version it has +dnl The first arg must be a version number with 3 parts. + +dnl hint: I guess you want to check for a version number higher to 2.5.31 + +AC_DEFUN([_AC_PROG_FLEX_HELPER_TOO_OLD],[ + AC_MSG_NOTICE([Found flex is too old. Parsers won't get updated (Found v$FLEX_VERSION < v$1)]) + LEX="$SHELL $missing_dir/missing flex"; + AC_SUBST(LEXLIB, '') +]) + +AC_DEFUN([AC_PROG_FLEX], + [ + AC_PROG_LEX + if test "$LEX" != flex; then + AC_MSG_NOTICE([Flex not found. Parsers won't get updated.]) + LEX="$SHELL $missing_dir/missing flex"; + AC_SUBST(LEXLIB, '') + else + if test "x$1" != "x" ; then + dnl + dnl We were asked to check the version number + dnl + set -x + changequote(<<, >>)dnl because of the regexp [blabla] + FLEX_VERSION=`flex --version | sed -e 's/^[^0-9]*//' -e 's/[^0-9]*$//'` + + FLEX_VER_MAJ=`echo "$FLEX_VERSION" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\1/'` + FLEX_VER_MED=`echo "$FLEX_VERSION" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\2/'` + FLEX_VER_MIN=`echo "$FLEX_VERSION" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\3/'` + + WANT_VER_MAJ=`echo $1 | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\1/'`; + WANT_VER_MED=`echo $1 | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\2/'`; + WANT_VER_MIN=`echo $1 | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\3/'`; + changequote([, ])dnl back to normality, there is no regexp afterward + + if test "$FLEX_VER_MAJ" -lt "$WANT_VER_MAJ" || + test "$FLEX_VER_MAJ" -eq "$WANT_VER_MAJ" -a "$FLEX_VER_MED" -lt "$WANT_VER_MED" || + test "$FLEX_VER_MAJ" -eq "$WANT_VER_MAJ" -a "$FLEX_VER_MED" -eq "$WANT_VER_MED" -a "$FLEX_VER_MIN" -lt "$WANT_VER_MIN" ; + then + AC_MSG_NOTICE([Found flex is too old. Parsers won't get updated (Found v$FLEX_VERSION < v$1)]) + LEX="$SHELL $missing_dir/missing flex"; + AC_SUBST(LEXLIB, '') + fi + set +x + fi + fi + AC_MSG_NOTICE([Flex found. Parsers will get updated]) + exit 0 +])