2 # Check for ANTLR's runantlr script. Will set ANTLR to the location of the
5 AC_DEFUN([AC_PROG_ANTLR], [
7 # Get the location of the runantlr script
11 [--with-antlr=RUNANTLR],
12 [location of the ANTLR's `runantlr` script]
17 # Check the existance of the runantlr script
18 if test -z "$ANTLR"; then
19 AC_CHECK_PROGS(ANTLR, [runantlr antlr])
21 AC_CHECK_PROG(ANTLR, "$ANTLR", "$ANTLR", [])
23 if test no$ANTLR = "no";
26 [Couldn't find the runantlr script, make sure that the parser code has
27 been generated already. To obtain ANTLR see <http://www.antlr.org/>.]
32 # Define the ANTL related variables
37 # Check the existnace of the ANTLR C++ runtime library and headers
38 # Will set ANTLR_CPPFLAGS and ANTLR_LIBS to the location of the ANTLR headers
39 # and library respectively
41 AC_DEFUN([AC_LIB_ANTLR],[
43 # Get the location of the ANTLR c++ includes and libraries
47 [--with-antlr-prefix=PATH],
48 [set the search path for ANTLR headers and libraries to `PATH/include`
49 and `PATH/lib`. By default we look in /usr, /usr/local, /opt and
53 ANTLR_PREFIXES="$withval",
54 ANTLR_PREFIXES="/usr/local /usr /opt/local /opt"
57 AC_MSG_CHECKING(for antlr C++ runtime library)
59 # Use C++ and remember the variables we are changing
61 OLD_CPPFLAGS="$CPPFLAGS"
64 # Try all the includes/libs set in ANTLR_PREFIXES
65 for antlr_prefix in $ANTLR_PREFIXES
67 CPPFLAGS="$OLD_CPPFLAGS -I$antlr_prefix/include"
68 LIBS="$OLD_LIBS -L$antlr_prefix/lib -lantlr-pic"
71 #include <antlr/CommonAST.hpp>
72 class MyAST : public ANTLR_USE_NAMESPACE(antlr)CommonAST {
79 AC_MSG_RESULT(found in $antlr_prefix)
80 ANTLR_INCLUDES="-I$antlr_prefix/include"
81 ANTLR_LDFLAGS="-L$antlr_prefix/lib -lantlr-pic"
85 CPPFLAGS="$OLD_CPPFLAGS -I$antlr_prefix/include"
86 LIBS="$OLD_LIBS -L$antlr_prefix/lib -lantlr"
89 #include <antlr/CommonAST.hpp>
90 class MyAST : public ANTLR_USE_NAMESPACE(antlr)CommonAST {
97 AC_MSG_RESULT(found in $antlr_prefix)
98 ANTLR_INCLUDES="-I$antlr_prefix/include"
99 ANTLR_LDFLAGS="-L$antlr_prefix/lib -lantlr"
104 AC_MSG_ERROR([ANTLR C++ runtime not found, see <http://www.antlr.org/>])
111 # Return the old compile variables and pop the language.
113 CPPFLAGS="$OLD_CPPFLAGS"
116 # Define the ANTLR include/libs variables
117 AC_SUBST(ANTLR_INCLUDES)
118 AC_SUBST(ANTLR_LDFLAGS)