ax_check_java_plugin.m4 revision 237944f3
1# ===========================================================================
2#   http://www.gnu.org/software/autoconf-archive/ax_check_java_plugin.html
3# ===========================================================================
4#
5# SYNOPSIS
6#
7#   AX_CHECK_JAVA_PLUGIN(<shell-variable>)
8#
9# DESCRIPTION
10#
11#   This macro sets <shell-variable> to empty on failure and to a compatible
12#   version of plugin.jar otherwise. Directories searched are /usr/java/*
13#   and /usr/local/java/*, which are assumed to be j{dk,re} installations.
14#   Apply the shell variable as you see fit. If sun changes things so
15#   <jre>/lib/plugin.jar is not the magic file it will stop working.
16#
17#   This macro assumes that unzip, zipinfo or pkzipc is available (and can
18#   list the contents of the jar archive). The first two are assumed to work
19#   similarly enough to the infozip versisonms. The pkzipc version is
20#   assumed to work if I undertstand the documentation on pkware's site but
21#   YMMV. I do not have access to pwkware's version to test it.
22#
23# LICENSE
24#
25#   Copyright (c) 2008 Duncan Simpson <dps@simpson.demon.co.uk>
26#
27#   This program is free software; you can redistribute it and/or modify it
28#   under the terms of the GNU General Public License as published by the
29#   Free Software Foundation; either version 2 of the License, or (at your
30#   option) any later version.
31#
32#   This program is distributed in the hope that it will be useful, but
33#   WITHOUT ANY WARRANTY; without even the implied warranty of
34#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
35#   Public License for more details.
36#
37#   You should have received a copy of the GNU General Public License along
38#   with this program. If not, see <http://www.gnu.org/licenses/>.
39#
40#   As a special exception, the respective Autoconf Macro's copyright owner
41#   gives unlimited permission to copy, distribute and modify the configure
42#   scripts that are the output of Autoconf when processing the Macro. You
43#   need not follow the terms of the GNU General Public License when using
44#   or distributing such scripts, even though portions of the text of the
45#   Macro appear in them. The GNU General Public License (GPL) does govern
46#   all other use of the material that constitutes the Autoconf Macro.
47#
48#   This special exception to the GPL applies to versions of the Autoconf
49#   Macro released by the Autoconf Archive. When you make and distribute a
50#   modified version of the Autoconf Macro, you may extend this special
51#   exception to the GPL to apply to your modified version as well.
52
53#serial 7
54
55AU_ALIAS([DPS_CHECK_PLUGIN], [AX_CHECK_JAVA_PLUGIN])
56AC_DEFUN([AX_CHECK_JAVA_PLUGIN],
57[AC_REQUIRE([AC_PROG_AWK])
58AC_REQUIRE([AC_PROG_FGREP])
59AC_CHECK_PROG(ZIPINFO,[zipinfo unzip pkzipc])
60AC_MSG_CHECKING([for the java plugin])
61case "x$ZIPINFO" in
62[*/zipinfo)]
63	zipinf="zipinfo -1" ;;
64[*/unzip)]
65	zipinf="unzip -l";;
66[*/pkzipc)]
67	ziping="unzipc -view";;
68[x*)]
69	AC_MSG_RESULT([skiped, none of zipinfo, unzip and pkzipc found])
70	AC_SUBST($1,[])
71	zipinf="";;
72esac
73if test "x$zipinf" != "x"; then
74jplugin=""
75for jhome in `ls -dr /usr/java/* /usr/local/java/* 2> /dev/null`; do
76for jfile in lib/plugin.jar jre/lib/plugin.jar; do
77if test "x$jplugin" = "x" && test -f "$jhome/$jfile"; then
78eval "$zipinf $jhome/$jfile | $AWK '{ print \$NF; }' | $FGREP netscape/javascript/JSObject" >/dev/null 2>/dev/null
79if test $? -eq 0; then
80dnl Some version of gcj (and javac) refuse to work with some files
81dnl that pass this test. To stop this problem make sure that the compiler
82dnl still works with this jar file in the classpath
83cat << \EOF > Test.java
84/* [#]line __oline__ "configure" */
85public class Test {
86}
87EOF
88if eval "$JAVAC -classpath $jhome/$jfile Test.java 2>/dev/null >/dev/null" && test -f Test.class; then
89jplugin="$jhome/$jfile"
90fi
91rm -f Test.java Test.class
92fi; fi; done; done
93if test "x$jplugin" != "x"; then
94AC_SUBST($1,$jplugin)
95AC_MSG_RESULT($jplugin)
96else
97AC_MSG_RESULT([java plugin not found])
98AC_SUBST($1,[])
99fi
100fi
101])
102