ac_prog_antlr.m4 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. AC_DEFUN([AC_LIB_ANTLR],[
  2. AC_MSG_CHECKING([for the ANTLR parser generator JAR file])
  3. if test -z "$ANTLR_JAR"; then
  4. for antlr_lib_home in `ls -d /usr/local/share/antlr* 2> /dev/null` \
  5. /usr/share/antlr/lib /usr/share/java /usr/lib;
  6. do
  7. if test -f "$antlr_lib_home/antlr.jar"; then
  8. ANTLR_JAR="$antlr_lib_home/antlr.jar"
  9. break
  10. fi
  11. done
  12. fi
  13. test -f $ANTLR_JAR || AC_MSG_ERROR([specified ANTLR jar file $ANTLR_JAR not found.]) \
  14. && AC_MSG_RESULT([$ANTLR_JAR])
  15. AC_SUBST(ANTLR_JAR)
  16. AC_PROVIDE([$0])dnl
  17. ])
  18. AC_DEFUN([AC_PROG_ANTLR],[
  19. AC_REQUIRE([AC_PROG_JAVA])dnl
  20. AC_CHECK_TOOLS([ANTLR], [cantlr runantlr antlr])
  21. if test "x$ANTLR" = x; then
  22. if test -z "$JAVA"; then
  23. AC_MSG_ERROR(Failed to find either an antlr binary or a suitable Java runtime for ANTLR.)
  24. else
  25. if test -z "$ANTLR_JAR"; then
  26. AC_MSG_ERROR(Failed to find either an antlr binary or a suitable antlr jar file.)
  27. else
  28. ANTLR="$JAVA -classpath $ANTLR_JAR antlr.Tool"
  29. fi
  30. fi
  31. fi
  32. AC_SUBST(ANTLR)
  33. AC_MSG_CHECKING([for antlr $1.$2.$3 or better])
  34. antlr_version_str=`$ANTLR 2>&1 | head -n 1 | sed '/.*Version */!d; s///;q'`
  35. if test "$antlr_version_str"; then
  36. antlr_version_regex='s/\([[[:digit:]]]\+\)\.\([[[:digit:]]]\+\)\.\([[[:digit:]]]\+\).*$/'
  37. antlr_version_major=`echo $antlr_version_str | sed "$antlr_version_regex\\1/"`
  38. antlr_version_minor=`echo $antlr_version_str | sed "$antlr_version_regex\\2/"`
  39. antlr_version_micro=`echo $antlr_version_str | sed "$antlr_version_regex\\3/"`
  40. (test $antlr_version_major -gt $1 || \
  41. (test $antlr_version_major -eq $1 && \
  42. test $antlr_version_minor -gt $2) || \
  43. (test $antlr_version_major -eq $1 && \
  44. test $antlr_version_minor -eq $2 && \
  45. test $antlr_version_micro -ge $3))
  46. fi
  47. AC_MSG_RESULT($antlr_version_major.$antlr_version_minor.$antlr_version_micro)
  48. ])