| 1 |
dnl Check for presence of the Ragel State Machine generator. |
| 2 |
dnl |
| 3 |
dnl This macro checks for the presence of the ragel tool in the system, |
| 4 |
dnl and whether the ragel tool is absolutely needed for a complete |
| 5 |
dnl build. |
| 6 |
dnl |
| 7 |
dnl To check for the need for Ragel, you have to provide the relative |
| 8 |
dnl path of a source file generated through Ragel: if the file is |
| 9 |
dnl present in the source tree, a missing ragel command will not cause |
| 10 |
dnl the configure to abort. |
| 11 |
|
| 12 |
AC_DEFUN([_RAGEL_VARS], [ |
| 13 |
AC_ARG_VAR([RAGEL], [Ragel generator command]) |
| 14 |
AC_ARG_VAR([RAGELFLAGS], [Ragel generator flags]) |
| 15 |
]) |
| 16 |
|
| 17 |
AC_DEFUN([CHECK_RAGEL], [ |
| 18 |
AC_REQUIRE([_RAGEL_VARS]) |
| 19 |
AC_CHECK_PROG([RAGEL], [ragel], [ragel], [no]) |
| 20 |
|
| 21 |
dnl We set RAGEL to false so that it would execute the "false" |
| 22 |
dnl command if needed. |
| 23 |
AS_IF([test x"$RAGEL" = x"no"], |
| 24 |
[RAGEL=false], |
| 25 |
AS_IF([test x"$2" != "x"], |
| 26 |
[ragel_version=`$RAGEL --version | sed -n -e '1s:.*version \(@<:@0-9@:>@\.@<:@0-9@:>@\) .*:\1:p'` |
| 27 |
ragel_version_compare=`echo $ragel_version | tr -d .` |
| 28 |
ragel_wanted_version=`echo $2 | tr -d .` |
| 29 |
AS_IF([test $ragel_version_compare -lt $ragel_wanted_version], |
| 30 |
[AC_MSG_WARN([Found Ragel $ragel_version but Ragel $2 requested]) |
| 31 |
RAGEL=false |
| 32 |
]) |
| 33 |
])) |
| 34 |
|
| 35 |
dnl Only test the need if not found |
| 36 |
AS_IF([test x"$RAGEL" = x"false"], [ |
| 37 |
AC_MSG_CHECKING([whether we need ragel to regenerate sources]) |
| 38 |
AS_IF([test -a "${srcdir}/$1"], [ragel_needed=no], [ragel_needed=yes]) |
| 39 |
AC_MSG_RESULT([$ragel_needed]) |
| 40 |
|
| 41 |
AS_IF([test x"$ragel_needed" = x"yes"], |
| 42 |
[AC_MSG_ERROR([dnl |
| 43 |
You need Ragel to build from development sources. |
| 44 |
You can find Ragel at http://www.complang.org/ragel/dnl |
| 45 |
])]) |
| 46 |
]) |
| 47 |
]) |
| 48 |
|
| 49 |
AC_DEFUN([CHECK_RAGEL_AM], [ |
| 50 |
CHECK_RAGEL([$1], [$2]) |
| 51 |
|
| 52 |
AM_CONDITIONAL([HAVE_RAGEL], [test x"$RAGEL" != x"false"]) |
| 53 |
]) |