blob: 917638ae4b9e54cbb15d69a398852d90b39bbb20 [file] [log] [blame]
Ed Warnickecb9cada2015-12-08 15:45:58 -07001# ===========================================================================
2# http://www.gnu.org/software/autoconf-archive/ax_java_check_class.html
3# ===========================================================================
4#
5# SYNOPSIS
6#
7# AX_JAVA_CHECK_CLASS(<class>,<action-if-found>,<action-if-not-found>)
8#
9# DESCRIPTION
10#
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).
15#
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.
21#
22# LICENSE
23#
24# Copyright (c) 2008 Duncan Simpson <dps@simpson.demon.co.uk>
25#
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.
30#
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.
35#
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/>.
38#
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.
46#
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.
51
52#serial 9
53
54AU_ALIAS([DPS_JAVA_CHECK_CLASS], [AX_JAVA_CHECK_CLASS])
55AC_DEFUN([AX_JAVA_CHECK_CLASS],[
56m4_define([cache_val],[m4_translit(ax_cv_have_java_class_$1, " ." ,"__")])
57if test "x$CLASSPATH" != "x"; then
58xtra=" with classpath ${CLASSPATH}"
59xopts=`echo ${CLASSPATH} | ${SED} 's/^ *://'`
60xopts="-classpath $xopts"
61else xtra=""; xopts=""; fi
62cache_var="cache_val"AS_TR_SH([_Jc_${JAVAC}_Cp_${CLASSPATH}])
63AC_CACHE_CHECK([if the $1 class is available$xtra], [$cache_var], [
64JAVA_TEST=Test.java
65CLASS_TEST=Test.class
66cat << \EOF > $JAVA_TEST
67/* [#]xline __oline__ "configure" */
68import $1;
69public class Test {
70}
71EOF
72if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $xopts $JAVA_TEST) >/dev/null 2>&1; then
73 eval "${cache_var}=yes"
74else
75 eval "${cache_var}=no"
76 echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD
77 cat $JAVA_TEST >&AS_MESSAGE_LOG_FD
78fi
79rm -f $JAVA_TEST $CLASS_TEST
80])
81if eval 'test "x$'${cache_var}'" = "xyes"'; then
82$2
83true; else
84$3
85false; fi])