blob: 02039600604a7620c49ddfb87bee27d025f89c38 [file] [log] [blame]
David Reissd9cdf422009-03-13 21:25:29 +00001dnl @synopsis AX_JAVAC_AND_JAVA
David Reisseaa8d7e2009-05-12 23:16:53 +00002dnl @synopsis AX_CHECK_JAVA_CLASS(CLASSNAME)
David Reissd9cdf422009-03-13 21:25:29 +00003dnl
David Reisseaa8d7e2009-05-12 23:16:53 +00004dnl Test for the presence of a JDK, and (optionally) specific classes.
David Reissd9cdf422009-03-13 21:25:29 +00005dnl
6dnl If "JAVA" is defined in the environment, that will be the only
7dnl java command tested. Otherwise, a hard-coded list will be used.
8dnl Similarly for "JAVAC".
9dnl
Konrad Grochowski3b5dacb2014-11-24 10:55:31 +010010dnl AX_JAVAC_AND_JAVA does not currently support testing for a particular
David Reisseaa8d7e2009-05-12 23:16:53 +000011dnl Java version, testing for only one of "java" and "javac", or
12dnl compiling or running user-provided Java code.
David Reissd9cdf422009-03-13 21:25:29 +000013dnl
14dnl After AX_JAVAC_AND_JAVA runs, the shell variables "success" and
15dnl "ax_javac_and_java" are set to "yes" or "no", and "JAVAC" and
16dnl "JAVA" are set to the appropriate commands.
17dnl
David Reisseaa8d7e2009-05-12 23:16:53 +000018dnl AX_CHECK_JAVA_CLASS must be run after AX_JAVAC_AND_JAVA.
19dnl It tests for the presence of a class based on a fully-qualified name.
20dnl It sets the shell variable "success" to "yes" or "no".
21dnl
David Reissd9cdf422009-03-13 21:25:29 +000022dnl @category Java
David Reissd9cdf422009-03-13 21:25:29 +000023dnl @version 2009-02-09
24dnl @license AllPermissive
25dnl
26dnl Copyright (C) 2009 David Reiss
27dnl Copying and distribution of this file, with or without modification,
28dnl are permitted in any medium without royalty provided the copyright
29dnl notice and this notice are preserved.
30
31
32AC_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
Jens Geyerda0b71f2015-07-27 23:15:10 +020060 # prevent $JAVA VM issues with UTF-8 path names (THRIFT-3271)
61 oLC_ALL="$LC_ALL"
62 LC_ALL=""
63
David Reissd9cdf422009-03-13 21:25:29 +000064 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
Jens Geyerda0b71f2015-07-27 23:15:10 +020076 # restore LC_ALL
77 LC_ALL="$oLC_ALL"
78 oLC_ALL=""
79
David Reissd9cdf422009-03-13 21:25:29 +000080 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 ])
David Reisseaa8d7e2009-05-12 23:16:53 +000097
98
99AC_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 ])
Jake Farrell210d7662011-05-25 21:07:29 +0000116
117
118AC_DEFUN([AX_CHECK_ANT_VERSION],
119 [
120 AC_MSG_CHECKING(for ant version > $2)
Nasko Vasilev12fcb0d2017-09-12 00:40:49 +0200121 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"`
Jake Farrell210d7662011-05-25 21:07:29 +0000122 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