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 -z "$ANTLR"; then
10 AC_CHECK_PROGS(ANTLR, [antlr3])
12 AC_CHECK_PROG(ANTLR, "$ANTLR", "$ANTLR", [])
14 if test no$ANTLR = "no";
17 [Couldn't find the antlr3 script, make sure that the parser code has
18 been generated already. To obtain ANTLR see <http://www.antlr.org/>.]
23 # Define the ANTL related variables
28 # Check the existence of the ANTLR3 C runtime library and headers
29 # Will set ANTLR_INCLUDES and ANTLR_LIBS to the location of the ANTLR
30 # headers and library respectively
32 AC_DEFUN([AC_LIB_ANTLR],[
33 AC_ARG_VAR(ANTLR_HOME, [path to libantlr3c installation])
35 # Get the location of the ANTLR3 C includes and libraries
39 [--with-antlr-dir=PATH],
40 [path to ANTLR C headers and libraries]
42 ANTLR_PREFIXES="$withval",
43 ANTLR_PREFIXES="$ANTLR_HOME /usr/local /usr /opt/local /opt"
46 AC_MSG_CHECKING(for ANTLR3 C runtime library)
48 # Use C and remember the variables we are changing
50 OLD_CPPFLAGS="$CPPFLAGS"
53 # Try all the includes/libs set in ANTLR_PREFIXES
54 for antlr_prefix in $ANTLR_PREFIXES
56 CPPFLAGS="$OLD_CPPFLAGS -I$antlr_prefix/include"
57 LIBS="$OLD_LIBS -L$antlr_prefix/lib -lantlr3c"
63 pANTLR3_UINT8 fName = (pANTLR3_UINT8)"foo";
64 pANTLR3_INPUT_STREAM input = antlr3AsciiFileStreamNew(fName);
69 AC_MSG_RESULT(found in $antlr_prefix)
70 ANTLR_INCLUDES="-I$antlr_prefix/include"
71 ANTLR_LDFLAGS="-L$antlr_prefix/lib -lantlr3c"
76 AC_MSG_ERROR([ANTLR3 C runtime not found, see <http://www.antlr.org/>])
81 # Return the old compile variables and pop the language.
83 CPPFLAGS="$OLD_CPPFLAGS"
86 # Define the ANTLR include/libs variables
87 AC_SUBST(ANTLR_INCLUDES)
88 AC_SUBST(ANTLR_LDFLAGS)