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_TOKEN_FACTORY factory = antlr3TokenFactoryNew((pANTLR3_INPUT_STREAM) NULL);
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 AC_MSG_CHECKING([for presence of older antlr3AsciiFileStreamNew()])
90 pANTLR3_UINT8 fName = (pANTLR3_UINT8)"foo";
91 pANTLR3_INPUT_STREAM input = antlr3AsciiFileStreamNew(fName);
96 AC_MSG_RESULT([found it (must be antlr3 3.2 or similar)])
97 CVC4CPPFLAGS="${CVC4CPPFLAGS:+$CVC4CPPFLAGS }-DCVC4_ANTLR3_OLD_INPUT_STREAM"
100 AC_MSG_RESULT(failed)
101 AC_MSG_CHECKING([for presence of newer antlr3FileStreamNew()])
107 pANTLR3_UINT8 fName = (pANTLR3_UINT8)"foo";
108 pANTLR3_INPUT_STREAM input = antlr3FileStreamNew(fName, ANTLR3_ENC_8BIT);
113 AC_MSG_RESULT([found it (must be antlr3 3.4 or similar)])
116 AC_MSG_ERROR([cannot figure out how to create an antlr3 input stream, bailing..])
122 # Return the old compile variables and pop the language.
124 CPPFLAGS="$OLD_CPPFLAGS"
127 # Define the ANTLR include/libs variables
128 AC_SUBST(ANTLR_INCLUDES)
129 AC_SUBST(ANTLR_LDFLAGS)