David Reiss | d9cdf42 | 2009-03-13 21:25:29 +0000 | [diff] [blame] | 1 | dnl @synopsis AX_JAVAC_AND_JAVA |
David Reiss | eaa8d7e | 2009-05-12 23:16:53 +0000 | [diff] [blame] | 2 | dnl @synopsis AX_CHECK_JAVA_CLASS(CLASSNAME) |
David Reiss | d9cdf42 | 2009-03-13 21:25:29 +0000 | [diff] [blame] | 3 | dnl |
David Reiss | eaa8d7e | 2009-05-12 23:16:53 +0000 | [diff] [blame] | 4 | dnl Test for the presence of a JDK, and (optionally) specific classes. |
David Reiss | d9cdf42 | 2009-03-13 21:25:29 +0000 | [diff] [blame] | 5 | dnl |
| 6 | dnl If "JAVA" is defined in the environment, that will be the only |
| 7 | dnl java command tested. Otherwise, a hard-coded list will be used. |
| 8 | dnl Similarly for "JAVAC". |
| 9 | dnl |
David Reiss | eaa8d7e | 2009-05-12 23:16:53 +0000 | [diff] [blame] | 10 | dnl AX_JAVAC_AND_JAVA does not currenly support testing for a particular |
| 11 | dnl Java version, testing for only one of "java" and "javac", or |
| 12 | dnl compiling or running user-provided Java code. |
David Reiss | d9cdf42 | 2009-03-13 21:25:29 +0000 | [diff] [blame] | 13 | dnl |
| 14 | dnl After AX_JAVAC_AND_JAVA runs, the shell variables "success" and |
| 15 | dnl "ax_javac_and_java" are set to "yes" or "no", and "JAVAC" and |
| 16 | dnl "JAVA" are set to the appropriate commands. |
| 17 | dnl |
David Reiss | eaa8d7e | 2009-05-12 23:16:53 +0000 | [diff] [blame] | 18 | dnl AX_CHECK_JAVA_CLASS must be run after AX_JAVAC_AND_JAVA. |
| 19 | dnl It tests for the presence of a class based on a fully-qualified name. |
| 20 | dnl It sets the shell variable "success" to "yes" or "no". |
| 21 | dnl |
David Reiss | d9cdf42 | 2009-03-13 21:25:29 +0000 | [diff] [blame] | 22 | dnl @category Java |
David Reiss | d9cdf42 | 2009-03-13 21:25:29 +0000 | [diff] [blame] | 23 | dnl @version 2009-02-09 |
| 24 | dnl @license AllPermissive |
| 25 | dnl |
| 26 | dnl Copyright (C) 2009 David Reiss |
| 27 | dnl Copying and distribution of this file, with or without modification, |
| 28 | dnl are permitted in any medium without royalty provided the copyright |
| 29 | dnl notice and this notice are preserved. |
| 30 | |
| 31 | |
| 32 | AC_DEFUN([AX_JAVAC_AND_JAVA], |
| 33 | [ |
| 34 | |
| 35 | dnl Hard-coded default commands to test. |
| 36 | JAVAC_PROGS="javac,jikes,gcj -C" |
| 37 | JAVA_PROGS="java,kaffe" |
| 38 | |
| 39 | dnl Allow the user to specify an alternative. |
| 40 | if test -n "$JAVAC" ; then |
| 41 | JAVAC_PROGS="$JAVAC" |
| 42 | fi |
| 43 | if test -n "$JAVA" ; then |
| 44 | JAVA_PROGS="$JAVA" |
| 45 | fi |
| 46 | |
| 47 | AC_MSG_CHECKING(for javac and java) |
| 48 | |
| 49 | echo "public class configtest_ax_javac_and_java { public static void main(String args@<:@@:>@) { } }" > configtest_ax_javac_and_java.java |
| 50 | success=no |
| 51 | oIFS="$IFS" |
| 52 | |
| 53 | IFS="," |
| 54 | for JAVAC in $JAVAC_PROGS ; do |
| 55 | IFS="$oIFS" |
| 56 | |
| 57 | echo "Running \"$JAVAC configtest_ax_javac_and_java.java\"" >&AS_MESSAGE_LOG_FD |
| 58 | if $JAVAC configtest_ax_javac_and_java.java >&AS_MESSAGE_LOG_FD 2>&1 ; then |
| 59 | |
| 60 | IFS="," |
| 61 | for JAVA in $JAVA_PROGS ; do |
| 62 | IFS="$oIFS" |
| 63 | |
| 64 | echo "Running \"$JAVA configtest_ax_javac_and_java\"" >&AS_MESSAGE_LOG_FD |
| 65 | if $JAVA configtest_ax_javac_and_java >&AS_MESSAGE_LOG_FD 2>&1 ; then |
| 66 | success=yes |
| 67 | break 2 |
| 68 | fi |
| 69 | |
| 70 | done |
| 71 | |
| 72 | fi |
| 73 | |
| 74 | done |
| 75 | |
| 76 | rm -f configtest_ax_javac_and_java.java configtest_ax_javac_and_java.class |
| 77 | |
| 78 | if test "$success" != "yes" ; then |
| 79 | AC_MSG_RESULT(no) |
| 80 | JAVAC="" |
| 81 | JAVA="" |
| 82 | else |
| 83 | AC_MSG_RESULT(yes) |
| 84 | fi |
| 85 | |
| 86 | ax_javac_and_java="$success" |
| 87 | |
| 88 | ]) |
David Reiss | eaa8d7e | 2009-05-12 23:16:53 +0000 | [diff] [blame] | 89 | |
| 90 | |
| 91 | AC_DEFUN([AX_CHECK_JAVA_CLASS], |
| 92 | [ |
| 93 | AC_MSG_CHECKING(for Java class [$1]) |
| 94 | |
| 95 | echo "import $1; public class configtest_ax_javac_and_java { public static void main(String args@<:@@:>@) { } }" > configtest_ax_javac_and_java.java |
| 96 | |
| 97 | echo "Running \"$JAVAC configtest_ax_javac_and_java.java\"" >&AS_MESSAGE_LOG_FD |
| 98 | if $JAVAC configtest_ax_javac_and_java.java >&AS_MESSAGE_LOG_FD 2>&1 ; then |
| 99 | AC_MSG_RESULT(yes) |
| 100 | success=yes |
| 101 | else |
| 102 | AC_MSG_RESULT(no) |
| 103 | success=no |
| 104 | fi |
| 105 | |
| 106 | rm -f configtest_ax_javac_and_java.java configtest_ax_javac_and_java.class |
| 107 | ]) |
Jake Farrell | 210d766 | 2011-05-25 21:07:29 +0000 | [diff] [blame] | 108 | |
| 109 | |
| 110 | AC_DEFUN([AX_CHECK_ANT_VERSION], |
| 111 | [ |
| 112 | AC_MSG_CHECKING(for ant version > $2) |
| 113 | ANT_VALID=`expr $($1 -version 2>/dev/null | sed -n 's/.*version \(@<:@0-9\.@:>@*\).*/\1/p') \>= $2` |
| 114 | if test "x$ANT_VALID" = "x1" ; then |
| 115 | AC_MSG_RESULT(yes) |
| 116 | else |
| 117 | AC_MSG_RESULT(no) |
| 118 | ANT="" |
| 119 | fi |
| 120 | ]) |
| 121 | |