Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
keep documentation in sync with implementation
[simgrid.git] / acmacro / flex.m4
1 dnl AC_PROG_FLEX: Check whether the LEXer is flex, and which version it has
2 dnl The first arg must be a version number with 3 parts.
3
4 dnl You may want to check for version >= 2.5.31 (the one breaking posix compatibility)
5
6
7 dnl Copyright (C) 2005. Martin Quinson. All rights reserved.
8
9 dnl This file is part of the SimGrid project. This is free software: 
10 dnl You can redistribute and/or modify it under the terms of the 
11 dnl GNU LGPL (v2.1) licence.
12
13
14 AC_DEFUN([_AC_PROG_FLEX_HELPER_TOO_OLD],[
15   AC_MSG_NOTICE([Found flex is too old. Parsers won't get updated (Found v$FLEX_VERSION < v$1)])
16   LEX="$SHELL $missing_dir/missing flex";
17   AC_SUBST(LEXLIB, '')
18 ])
19
20 AC_DEFUN([AC_PROG_FLEX],
21  [
22 AC_PREREQ(2.50)dnl
23 AC_REQUIRE([AM_MISSING_HAS_RUN])dnl
24 AC_REQUIRE([AC_PROG_LEX])dnl
25   if test "$LEX" != flex; then
26     AC_MSG_NOTICE([Flex not found. Parsers won't get updated.])
27     LEX=${am_missing_run}flex
28     AC_SUBST(LEXLIB, '')
29   else
30     if test "x$1" != "x" ; then
31       dnl
32       dnl We were asked to check the version number
33       dnl
34       changequote(<<, >>)dnl because of the regexp [blabla]
35       FLEX_VERSION=`flex --version | sed -e 's/^[^0-9]*//' -e 's/[^0-9]*$//'`
36
37       FLEX_VER_MAJ=`echo "$FLEX_VERSION" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\1/'`
38       FLEX_VER_MED=`echo "$FLEX_VERSION" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\2/'`
39       FLEX_VER_MIN=`echo "$FLEX_VERSION" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\3/'`
40
41       WANT_VER_MAJ=`echo $1 | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\1/'`;
42       WANT_VER_MED=`echo $1 | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\2/'`;
43       WANT_VER_MIN=`echo $1 | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\3/'`;
44       changequote([, ])dnl back to normality, there is no regexp afterward
45  
46       if test "$FLEX_VER_MAJ" -lt "$WANT_VER_MAJ" ||
47          test "$FLEX_VER_MAJ" -eq "$WANT_VER_MAJ" -a "$FLEX_VER_MED" -lt "$WANT_VER_MED"  ||
48          test "$FLEX_VER_MAJ" -eq "$WANT_VER_MAJ" -a "$FLEX_VER_MED" -eq "$WANT_VER_MED" -a "$FLEX_VER_MIN" -lt "$WANT_VER_MIN" ;
49       then
50         AC_MSG_NOTICE([Found flex is too old. Parsers won't get updated (Found v$FLEX_VERSION < v$1)])
51         LEX=${am_missing_run}flex
52         AC_SUBST(LEXLIB, '')
53       else
54         AC_MSG_NOTICE([Flex found. Parsers will get updated])      
55       fi
56     fi
57   fi
58 ])