diff options
author | Dejan Jovanović <dejan.jovanovic@gmail.com> | 2009-12-04 04:06:54 +0000 |
---|---|---|
committer | Dejan Jovanović <dejan.jovanovic@gmail.com> | 2009-12-04 04:06:54 +0000 |
commit | 7ae25006aa380df63469f593b523ddf6dd0d2e53 (patch) | |
tree | f8da669e0d8e90ef463482e966b98ecb45d45ad0 /config | |
parent | 9ecb0c727cf214809395afa0a1b615ea2e64f934 (diff) |
Adding support for ANTLR checking in autogen.sh (config/antlr.m4). Commiting antlr SMT grammar that should compile, but is not yet integrated. Tests of compilation and antlr crashes appreciated.
Diffstat (limited to 'config')
-rw-r--r-- | config/antlr.m4 | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/config/antlr.m4 b/config/antlr.m4 new file mode 100644 index 000000000..e19f3c42d --- /dev/null +++ b/config/antlr.m4 @@ -0,0 +1,96 @@ +## +# Check for ANTLR's runantlr script. Will set ANTLR to the location of the +# runantlr script +## +AC_DEFUN([AC_PROG_ANTLR], [ + + # Get the location of the runantlr script + AC_ARG_WITH( + [antlr], + AC_HELP_STRING( + [--with-antlr=RUNANTLR], + [location of the ANTLR's `runantlr` script] + ), + ANTLR="$withval", + ANTLR="runantlr" + ) + + # Check the existance of the runantlr script + AC_CHECK_PROG(ANTLR, "$ANTLR", "$ANTLR", []) + if test no$ANTLR = "no"; + then + AC_MSG_WARN( + [Couldn't find the runantlr script, make sure that the parser code has + been generated already. To obtain ANTLR see <http://www.antlr.org/>.] + ) + AC_MSG_RESULT(no) + fi + + # Define the ANTL related variables + AC_SUBST(ANTLR) +]) + +## +# Check the existnace of the ANTLR C++ runtime library and headers +# Will set ANTLR_CPPFLAGS and ANTLR_LIBS to the location of the ANTLR headers +# and library respectively +## +AC_DEFUN([AC_LIB_ANTLR],[ + + # Get the location of the ANTLR c++ includes and libraries + AC_ARG_WITH( + [antlr-prefix], + AC_HELP_STRING( + [--with-antlr-prefix=PATH], + [set the search path for ANTLR headers and libraries to `PATH/include` + and `PATH/lib`. By default we look in /usr, /usr/local, /opt and + /opt/local. + ] + ), + ANTLR_PREFIXES="$withval", + ANTLR_PREFIXES="/usr/local /usr /opt/local /opt" + ) + + AC_MSG_CHECKING(for antlr C++ runtime library) + + # Use C++ and remember the variables we are changing + AC_LANG_PUSH(C++) + OLD_CPPFLAGS="$CPPFLAGS" + OLD_LIBS="$LIBS" + + # Try all the includes/libs set in ANTLR_PREFIXES + for antlr_prefix in $ANTLR_PREFIXES + do + CPPFLAGS="$OLD_CPPFLAGS -I$antlr_prefix/include" + LIBS="$OLD_LIBS -L$antlr_prefix/lib -lantlr" + AC_LINK_IFELSE( + [ + #include <antlr/CommonAST.hpp> + class MyAST : public ANTLR_USE_NAMESPACE(antlr)CommonAST { + }; + int main() { + MyAST ast; + } + ], + [ + AC_MSG_RESULT(found in $antlr_prefix) + ANTLR_INCLUDES="-I$antlr_prefix/include" + ANTLR_LDFLAGS="-L$antlr_prefix/lib -lantlr" + break + ], + [ + AC_MSG_RESULT(no) + AC_MSG_ERROR([ANTLR C++ runtime not found, see <http://www.antlr.org/>]) + ] + ) + done + + # 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) +])
\ No newline at end of file |