## # Check for ANTLR's antlr3 script. # Will set ANTLR to the location of the script. ## AC_DEFUN([AC_PROG_ANTLR], [ AC_ARG_VAR([ANTLR],[location of the antlr3 script]) # Check the existence of the runantlr script if test "x$ANTLR" = "x"; then AC_PATH_PROG(ANTLR, [antlr3]) else AC_MSG_CHECKING([antlr3 script ($ANTLR)]) if test ! -e "$ANTLR"; then AC_MSG_RESULT([not found]) unset ANTLR elif test ! -x "$ANTLR"; then AC_MSG_RESULT([not executable]) unset ANTLR else AC_MSG_RESULT([OK]) fi fi if test "x$ANTLR" = "x"; then AC_MSG_WARN( [No usable antlr3 script found. Make sure that the parser code has been generated already. To obtain ANTLR see .] ) ANTLR_VERSION= else ANTLR_VERSION="`$ANTLR -version 2>&1 | sed 's,.*\ int main() { pANTLR3_TOKEN_FACTORY factory = antlr3TokenFactoryNew((pANTLR3_INPUT_STREAM) NULL); return 0; } ])], [ AC_MSG_RESULT(found in $antlr_prefix) ANTLR_INCLUDES="-I$antlr_prefix/include" ANTLR_LDFLAGS="-L$antlr_prefix/lib -lantlr3c" break ], [ AC_MSG_RESULT(no) AC_MSG_ERROR([ANTLR3 C runtime not found, see ]) ] ) done AC_MSG_CHECKING([for presence of older antlr3AsciiFileStreamNew()]) AC_LINK_IFELSE([AC_LANG_SOURCE( [ #include int main() { pANTLR3_UINT8 fName = (pANTLR3_UINT8)"foo"; pANTLR3_INPUT_STREAM input = antlr3AsciiFileStreamNew(fName); return 0; } ])], [ AC_MSG_RESULT([found it (must be antlr3 3.2 or similar)]) if test -n "$ANTLR_VERSION" -a "$ANTLR_VERSION" != 3.2; then AC_MSG_WARN([your antlr parser generator is version $ANTLR_VERSION, which doesn't match the library!]) fi CVC4CPPFLAGS="${CVC4CPPFLAGS:+$CVC4CPPFLAGS }-DCVC4_ANTLR3_OLD_INPUT_STREAM" ], [ AC_MSG_RESULT(failed) AC_MSG_CHECKING([for presence of newer antlr3FileStreamNew()]) AC_LINK_IFELSE([AC_LANG_SOURCE( [ #include int main() { pANTLR3_UINT8 fName = (pANTLR3_UINT8)"foo"; pANTLR3_INPUT_STREAM input = antlr3FileStreamNew(fName, ANTLR3_ENC_8BIT); return 0; } ])], [ AC_MSG_RESULT([found it (must be antlr3 3.4 or similar)]) if test -n "$ANTLR_VERSION" -a "$ANTLR_VERSION" != 3.4; then AC_MSG_WARN([your antlr parser generator is version $ANTLR_VERSION, which doesn't match the library!]) fi ], [ AC_MSG_ERROR([cannot figure out how to create an antlr3 input stream, bailing..]) ] ) ] ) # Return the old compile variables and pop the language. LIBS="$OLD_LIBS" CPPFLAGS="$OLD_CPPFLAGS" AC_LANG_POP() # Define the ANTLR include/libs variables AC_SUBST(ANTLR_INCLUDES) AC_SUBST(ANTLR_LDFLAGS) ])