2 # Check for ANTLR's antlr3 script.
3 # Will set ANTLR to the location of the script.
5 AC_DEFUN([AC_PROG_ANTLR], [
6 AC_ARG_VAR([ANTLR],[location of the antlr3 script])
8 # Check the existence of the runantlr script
9 if test "x$ANTLR" = "x"; then
10 AC_PATH_PROG(ANTLR, [antlr3])
12 AC_MSG_CHECKING([antlr3 script ($ANTLR)])
13 if test ! -e "$ANTLR"; then
14 AC_MSG_RESULT([not found])
16 elif test ! -x "$ANTLR"; then
17 AC_MSG_RESULT([not executable])
23 if test "x$ANTLR" = "x"; then
25 [No usable antlr3 script found. Make sure that the parser code has
26 been generated already. To obtain ANTLR see <http://www.antlr.org/>.]
32 # Check the existence of the ANTLR3 C runtime library and headers
33 # Will set ANTLR_INCLUDES and ANTLR_LIBS to the location of the ANTLR
34 # headers and library respectively
36 AC_DEFUN([AC_LIB_ANTLR],[
37 AC_ARG_VAR(ANTLR_HOME, [path to libantlr3c installation])
39 # Get the location of the ANTLR3 C includes and libraries
43 [--with-antlr-dir=PATH],
44 [path to ANTLR C headers and libraries]
46 ANTLR_PREFIXES="$withval",
47 ANTLR_PREFIXES="$ANTLR_HOME /usr/local /usr /opt/local /opt"
50 AC_MSG_CHECKING(for ANTLR3 C runtime library)
52 # Use C and remember the variables we are changing
54 OLD_CPPFLAGS="$CPPFLAGS"
57 # Try all the includes/libs set in ANTLR_PREFIXES
58 for antlr_prefix in $ANTLR_PREFIXES
60 CPPFLAGS="$OLD_CPPFLAGS -I$antlr_prefix/include"
61 LIBS="$OLD_LIBS -L$antlr_prefix/lib -lantlr3c"
67 pANTLR3_STRING_FACTORY factory = antlr3StringFactoryNew(ANTLR3_ENC_8BIT);
72 AC_MSG_RESULT(found in $antlr_prefix)
73 ANTLR_INCLUDES="-I$antlr_prefix/include"
74 ANTLR_LDFLAGS="-L$antlr_prefix/lib -lantlr3c"
79 AC_MSG_ERROR([ANTLR3 C runtime not found, see <http://www.antlr.org/>])
84 # Return the old compile variables and pop the language.
86 CPPFLAGS="$OLD_CPPFLAGS"
89 # Define the ANTLR include/libs variables
90 AC_SUBST(ANTLR_INCLUDES)
91 AC_SUBST(ANTLR_LDFLAGS)