private sync
[external/ragel.git] / contrib / ragel.m4
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"], [RAGEL=false])
24
25   dnl Only test the need if not found
26   AS_IF([test x"$RAGEL" = x"false"], [
27     AC_MSG_CHECKING([whether we need ragel to regenerate sources])
28     AS_IF([test -a ${srcdir}/$1], [ragel_needed=no], [ragel_needed=yes])
29     AC_MSG_RESULT([$ragel_needed])
30
31     AS_IF([test x"$ragel_needed" = x"yes"],
32       [AC_MSG_ERROR([dnl
33 You need Ragel to build from development sources.
34 You can find Ragel at http://www.complang.org/ragel/dnl
35       ])])
36   ])
37 ])
38
39 AC_DEFUN([CHECK_RAGEL_AM], [
40   CHECK_RAGEL([$1])
41
42   AM_CONDITIONAL([HAVE_RAGEL], [test x"$RAGEL" != x"false"])
43 ])