]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
1 | dnl @synopsis AX_JAVAC_AND_JAVA |
2 | dnl @synopsis AX_CHECK_JAVA_CLASS(CLASSNAME) | |
3 | dnl | |
4 | dnl Test for the presence of a JDK, and (optionally) specific classes. | |
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 | |
10 | dnl AX_JAVAC_AND_JAVA does not currently 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. | |
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 | |
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 | |
22 | dnl @category Java | |
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 | # prevent $JAVA VM issues with UTF-8 path names (THRIFT-3271) | |
61 | oLC_ALL="$LC_ALL" | |
62 | LC_ALL="" | |
63 | ||
64 | IFS="," | |
65 | for JAVA in $JAVA_PROGS ; do | |
66 | IFS="$oIFS" | |
67 | ||
68 | echo "Running \"$JAVA configtest_ax_javac_and_java\"" >&AS_MESSAGE_LOG_FD | |
69 | if $JAVA configtest_ax_javac_and_java >&AS_MESSAGE_LOG_FD 2>&1 ; then | |
70 | success=yes | |
71 | break 2 | |
72 | fi | |
73 | ||
74 | done | |
75 | ||
76 | # restore LC_ALL | |
77 | LC_ALL="$oLC_ALL" | |
78 | oLC_ALL="" | |
79 | ||
80 | fi | |
81 | ||
82 | done | |
83 | ||
84 | rm -f configtest_ax_javac_and_java.java configtest_ax_javac_and_java.class | |
85 | ||
86 | if test "$success" != "yes" ; then | |
87 | AC_MSG_RESULT(no) | |
88 | JAVAC="" | |
89 | JAVA="" | |
90 | else | |
91 | AC_MSG_RESULT(yes) | |
92 | fi | |
93 | ||
94 | ax_javac_and_java="$success" | |
95 | ||
96 | ]) | |
97 | ||
98 | ||
99 | AC_DEFUN([AX_CHECK_JAVA_CLASS], | |
100 | [ | |
101 | AC_MSG_CHECKING(for Java class [$1]) | |
102 | ||
103 | echo "import $1; public class configtest_ax_javac_and_java { public static void main(String args@<:@@:>@) { } }" > configtest_ax_javac_and_java.java | |
104 | ||
105 | echo "Running \"$JAVAC configtest_ax_javac_and_java.java\"" >&AS_MESSAGE_LOG_FD | |
106 | if $JAVAC configtest_ax_javac_and_java.java >&AS_MESSAGE_LOG_FD 2>&1 ; then | |
107 | AC_MSG_RESULT(yes) | |
108 | success=yes | |
109 | else | |
110 | AC_MSG_RESULT(no) | |
111 | success=no | |
112 | fi | |
113 | ||
114 | rm -f configtest_ax_javac_and_java.java configtest_ax_javac_and_java.class | |
115 | ]) | |
116 | ||
117 | ||
118 | AC_DEFUN([AX_CHECK_ANT_VERSION], | |
119 | [ | |
120 | AC_MSG_CHECKING(for ant version > $2) | |
121 | ANT_VALID=`expr "x$(printf "$2\n$($1 -version 2>/dev/null | sed -n 's/.*version \(@<:@0-9\.@:>@*\).*/\1/p')" | sort -t '.' -k 1,1 -k 2,2 -k 3,3 -g | sed -n 1p)" = "x$2"` | |
122 | if test "x$ANT_VALID" = "x1" ; then | |
123 | AC_MSG_RESULT(yes) | |
124 | else | |
125 | AC_MSG_RESULT(no) | |
126 | ANT="" | |
127 | fi | |
128 | ]) | |
129 |