1 # ===========================================================================
2 # http://www.gnu.org/software/autoconf-archive/ax_java_check_class.html
3 # ===========================================================================
7 # AX_JAVA_CHECK_CLASS(<class>,<action-if-found>,<action-if-not-found>)
11 # Test if a Java class is available. Based on AX_PROG_JAVAC_WORKS. This
12 # version uses a cache variable which is both compiler, options and
13 # classpath dependent (so if you switch from javac to gcj it correctly
14 # notices and redoes the test).
16 # The macro tries to compile a minimal program importing <class>. Some
17 # newer compilers moan about the failure to use this but fail or produce a
18 # class file anyway. All moaing is sunk to /dev/null since I only wanted
19 # to know if the class could be imported. This is a recommended followup
20 # to AX_CHECK_JAVA_PLUGIN with classpath appropriately adjusted.
24 # Copyright (c) 2008 Duncan Simpson <dps@simpson.demon.co.uk>
26 # This program is free software; you can redistribute it and/or modify it
27 # under the terms of the GNU General Public License as published by the
28 # Free Software Foundation; either version 2 of the License, or (at your
29 # option) any later version.
31 # This program is distributed in the hope that it will be useful, but
32 # WITHOUT ANY WARRANTY; without even the implied warranty of
33 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
34 # Public License for more details.
36 # You should have received a copy of the GNU General Public License along
37 # with this program. If not, see <http://www.gnu.org/licenses/>.
39 # As a special exception, the respective Autoconf Macro's copyright owner
40 # gives unlimited permission to copy, distribute and modify the configure
41 # scripts that are the output of Autoconf when processing the Macro. You
42 # need not follow the terms of the GNU General Public License when using
43 # or distributing such scripts, even though portions of the text of the
44 # Macro appear in them. The GNU General Public License (GPL) does govern
45 # all other use of the material that constitutes the Autoconf Macro.
47 # This special exception to the GPL applies to versions of the Autoconf
48 # Macro released by the Autoconf Archive. When you make and distribute a
49 # modified version of the Autoconf Macro, you may extend this special
50 # exception to the GPL to apply to your modified version as well.
54 AU_ALIAS([DPS_JAVA_CHECK_CLASS], [AX_JAVA_CHECK_CLASS])
55 AC_DEFUN([AX_JAVA_CHECK_CLASS],[
56 m4_define([cache_val],[m4_translit(ax_cv_have_java_class_$1, " ." ,"__")])
57 if test "x$CLASSPATH" != "x"; then
58 xtra=" with classpath ${CLASSPATH}"
59 xopts=`echo ${CLASSPATH} | ${SED} 's/^ *://'`
60 xopts="-classpath $xopts"
61 else xtra=""; xopts=""; fi
62 cache_var="cache_val"AS_TR_SH([_Jc_${JAVAC}_Cp_${CLASSPATH}])
63 AC_CACHE_CHECK([if the $1 class is available$xtra], [$cache_var], [
66 cat << \EOF > $JAVA_TEST
67 /* [#]xline __oline__ "configure" */
72 if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $xopts $JAVA_TEST) >/dev/null 2>&1; then
73 eval "${cache_var}=yes"
75 eval "${cache_var}=no"
76 echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD
77 cat $JAVA_TEST >&AS_MESSAGE_LOG_FD
79 rm -f $JAVA_TEST $CLASS_TEST
81 if eval 'test "x$'${cache_var}'" = "xyes"'; then